diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-04 17:50:31 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-04 17:50:31 +0000 |
commit | b647e0b22430373766687242da51ee1453a19558 (patch) | |
tree | f6f67aa96441563d779d3bea9b84ceede26812c5 /chrome | |
parent | 4c70b7a559f7188a2820b38e6dad2758a310b55c (diff) | |
download | chromium_src-b647e0b22430373766687242da51ee1453a19558.zip chromium_src-b647e0b22430373766687242da51ee1453a19558.tar.gz chromium_src-b647e0b22430373766687242da51ee1453a19558.tar.bz2 |
Deprecate wstring version of PathService::Get() in unit tests.
Review URL: http://codereview.chromium.org/100292
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15221 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
7 files changed, 47 insertions, 51 deletions
diff --git a/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc b/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc index b34b14c..d1f5a4e 100644 --- a/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc +++ b/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc @@ -15,9 +15,8 @@ class BookmarkHTMLWriterTest : public testing::Test { protected: virtual void SetUp() { ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &path_)); - file_util::AppendToPath(&path_, L"bookmarks.html"); + path_ = path_.AppendASCII("bookmarks.html"); file_util::Delete(path_, true); - } virtual void TearDown() { @@ -53,7 +52,7 @@ class BookmarkHTMLWriterTest : public testing::Test { EXPECT_TRUE(path_count < 3 || entry.path[3] == f3); } - std::wstring path_; + FilePath path_; }; // Tests bookmark_html_writer by populating a BookmarkModel, writing it out by @@ -100,19 +99,19 @@ TEST_F(BookmarkHTMLWriterTest, Test) { model.AddURLWithCreationTime(f4, 0, url1_title, url1, t1); // Write to a temp file. - bookmark_html_writer::WriteBookmarks(NULL, &model, path_); + bookmark_html_writer::WriteBookmarks(NULL, &model, path_.ToWStringHack()); // Read the bookmarks back in. std::vector<ProfileWriter::BookmarkEntry> parsed_bookmarks; - Firefox2Importer::ImportBookmarksFile(path_, std::set<GURL>(), false, - L"x", NULL, &parsed_bookmarks, NULL, - NULL); + Firefox2Importer::ImportBookmarksFile(path_.ToWStringHack(), std::set<GURL>(), + false, L"x", NULL, &parsed_bookmarks, + NULL, NULL); // Verify we got back what we wrote. ASSERT_EQ(6U, parsed_bookmarks.size()); // Hardcode the value of IDS_BOOKMARK_BAR_FOLDER_NAME in en-US locale - // because all the unit tests are run in en-US locale. - const wchar_t* kBookmarkBarFolderName = L"Bookmarks bar"; + // because all the unit tests are run in en-US locale. + const wchar_t* kBookmarkBarFolderName = L"Bookmarks bar"; AssertBookmarkEntryEquals(parsed_bookmarks[0], false, url1, url1_title, t1, kBookmarkBarFolderName, f1_title, std::wstring()); AssertBookmarkEntryEquals(parsed_bookmarks[1], false, url2, url2_title, t2, diff --git a/chrome/browser/extensions/extension_unittest.cc b/chrome/browser/extensions/extension_unittest.cc index f160117..0607186 100644 --- a/chrome/browser/extensions/extension_unittest.cc +++ b/chrome/browser/extensions/extension_unittest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/file_path.h" #include "base/string_util.h" #include "base/path_service.h" #include "chrome/browser/extensions/extension.h" @@ -24,10 +25,9 @@ TEST(ExtensionTest, InitFromValueInvalid) { ExtensionErrorReporter::Init(false); // Start with a valid extension manifest - std::wstring extensions_dir; - ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_dir)); - FilePath extensions_path = FilePath::FromWStringHack(extensions_dir) - .AppendASCII("extensions") + FilePath extensions_path; + ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); + extensions_path = extensions_path.AppendASCII("extensions") .AppendASCII("good") .AppendASCII("extension1") .AppendASCII("1") diff --git a/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc index d49dc66..94a9a52 100644 --- a/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc +++ b/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc @@ -4,7 +4,6 @@ // // Unit tests for the SafeBrowsing storage system. -#include "base/file_path.h" #include "base/file_util.h" #include "base/logging.h" #include "base/path_service.h" @@ -1029,15 +1028,15 @@ void PrintStat(const char* name) { } std::wstring GetFullSBDataPath(const std::wstring& path) { - std::wstring full_path; + FilePath full_path; CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &full_path)); - file_util::AppendToPath(&full_path, L"chrome"); - file_util::AppendToPath(&full_path, L"test"); - file_util::AppendToPath(&full_path, L"data"); - file_util::AppendToPath(&full_path, L"safe_browsing"); - file_util::AppendToPath(&full_path, path); + full_path = full_path.AppendASCII("chrome"); + full_path = full_path.AppendASCII("test"); + full_path = full_path.AppendASCII("data"); + full_path = full_path.AppendASCII("safe_browsing"); + full_path = full_path.Append(FilePath::FromWStringHack(path)); CHECK(file_util::PathExists(full_path)); - return full_path; + return full_path.ToWStringHack(); } struct ChunksInfo { diff --git a/chrome/browser/search_engines/template_url_model_unittest.cc b/chrome/browser/search_engines/template_url_model_unittest.cc index 8c0ea36..4a4bace 100644 --- a/chrome/browser/search_engines/template_url_model_unittest.cc +++ b/chrome/browser/search_engines/template_url_model_unittest.cc @@ -39,16 +39,15 @@ class TemplateURLModelTestingProfile : public TestingProfile { void SetUp() { // Name a subdirectory of the temp directory. ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_)); - file_util::AppendToPath(&test_dir_, L"TemplateURLModelTest"); + test_dir_ = test_dir_.AppendASCII("TemplateURLModelTest"); // Create a fresh, empty copy of this directory. file_util::Delete(test_dir_, true); file_util::CreateDirectory(test_dir_); - std::wstring path = test_dir_; - file_util::AppendToPath(&path, L"TestDataService.db"); + FilePath path = test_dir_.AppendASCII("TestDataService.db"); service_ = new WebDataService; - EXPECT_TRUE(service_->InitWithPath(FilePath::FromWStringHack(path))); + EXPECT_TRUE(service_->InitWithPath(path)); } void TearDown() { @@ -64,7 +63,7 @@ class TemplateURLModelTestingProfile : public TestingProfile { private: scoped_refptr<WebDataService> service_; - std::wstring test_dir_; + FilePath test_dir_; }; // Trivial subclass of TemplateURLModel that records the last invocation of diff --git a/chrome/browser/search_engines/template_url_parser_unittest.cc b/chrome/browser/search_engines/template_url_parser_unittest.cc index bac35c4..77c794c 100644 --- a/chrome/browser/search_engines/template_url_parser_unittest.cc +++ b/chrome/browser/search_engines/template_url_parser_unittest.cc @@ -17,11 +17,11 @@ class TemplateURLParserTest : public testing::Test { virtual void SetUp() { ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &full_path_)); - file_util::AppendToPath(&full_path_, L"osdd"); + full_path_ = full_path_.AppendASCII("osdd"); if (!file_util::PathExists(full_path_)) { LOG(ERROR) << L"This test can't be run without some non-redistributable data"; - full_path_.clear(); + full_path_ = FilePath(); } } @@ -35,12 +35,11 @@ class TemplateURLParserTest : public testing::Test { // use a return value due to internally using ASSERT_). void ParseFile(const std::wstring& file_name, TemplateURLParser::ParameterFilter* filter) { - std::wstring full_path(full_path_); - file_util::AppendToPath(&full_path, file_name); + FilePath full_path; parse_result_ = false; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &full_path)); - file_util::AppendToPath(&full_path, L"osdd"); - file_util::AppendToPath(&full_path, file_name); + full_path = full_path.AppendASCII("osdd"); + full_path = full_path.Append(FilePath::FromWStringHack(file_name)); ASSERT_TRUE(file_util::PathExists(full_path)); std::string contents; @@ -53,7 +52,7 @@ class TemplateURLParserTest : public testing::Test { // ParseFile parses the results into this template_url. TemplateURL template_url_; - std::wstring full_path_; + FilePath full_path_; // Result of the parse. bool parse_result_; diff --git a/chrome/browser/webdata/web_database_unittest.cc b/chrome/browser/webdata/web_database_unittest.cc index cacb04d..09e5be4 100644 --- a/chrome/browser/webdata/web_database_unittest.cc +++ b/chrome/browser/webdata/web_database_unittest.cc @@ -24,10 +24,10 @@ class WebDatabaseTest : public testing::Test { virtual void SetUp() { PathService::Get(chrome::DIR_TEST_DATA, &file_); - file_ += FilePath::kSeparators[0]; - file_ += L"TestWebDatabase"; - file_ += Int64ToWString(base::Time::Now().ToInternalValue()); - file_ += L".db"; + const std::string test_db = "TestWebDatabase" + + Int64ToString(base::Time::Now().ToInternalValue()) + + ".db"; + file_ = file_.AppendASCII(test_db); file_util::Delete(file_, false); } @@ -79,13 +79,13 @@ class WebDatabaseTest : public testing::Test { url->set_prepopulate_id(id); } - std::wstring file_; + FilePath file_; }; TEST_F(WebDatabaseTest, Keywords) { WebDatabase db; - EXPECT_TRUE(db.Init(file_)); + EXPECT_TRUE(db.Init(file_.ToWStringHack())); TemplateURL template_url; template_url.set_short_name(L"short_name"); @@ -146,7 +146,7 @@ TEST_F(WebDatabaseTest, Keywords) { TEST_F(WebDatabaseTest, KeywordMisc) { WebDatabase db; - EXPECT_TRUE(db.Init(file_)); + EXPECT_TRUE(db.Init(file_.ToWStringHack())); ASSERT_EQ(0, db.GetDefaulSearchProviderID()); ASSERT_EQ(0, db.GetBuitinKeywordVersion()); @@ -161,7 +161,7 @@ TEST_F(WebDatabaseTest, KeywordMisc) { TEST_F(WebDatabaseTest, UpdateKeyword) { WebDatabase db; - EXPECT_TRUE(db.Init(file_)); + EXPECT_TRUE(db.Init(file_.ToWStringHack())); TemplateURL template_url; template_url.set_short_name(L"short_name"); @@ -223,7 +223,7 @@ TEST_F(WebDatabaseTest, UpdateKeyword) { TEST_F(WebDatabaseTest, KeywordWithNoFavicon) { WebDatabase db; - EXPECT_TRUE(db.Init(file_)); + EXPECT_TRUE(db.Init(file_.ToWStringHack())); TemplateURL template_url; template_url.set_short_name(L"short_name"); @@ -250,7 +250,7 @@ TEST_F(WebDatabaseTest, KeywordWithNoFavicon) { TEST_F(WebDatabaseTest, Logins) { WebDatabase db; - EXPECT_TRUE(db.Init(file_)); + EXPECT_TRUE(db.Init(file_.ToWStringHack())); std::vector<PasswordForm*> result; @@ -383,7 +383,7 @@ TEST_F(WebDatabaseTest, Logins) { TEST_F(WebDatabaseTest, Autofill) { WebDatabase db; - EXPECT_TRUE(db.Init(file_)); + EXPECT_TRUE(db.Init(file_.ToWStringHack())); Time t1 = Time::Now(); @@ -515,7 +515,7 @@ static void ClearResults(std::vector<PasswordForm*>* results) { TEST_F(WebDatabaseTest, ClearPrivateData_SavedPasswords) { WebDatabase db; - EXPECT_TRUE(db.Init(file_)); + EXPECT_TRUE(db.Init(file_.ToWStringHack())); std::vector<PasswordForm*> result; @@ -557,7 +557,7 @@ TEST_F(WebDatabaseTest, ClearPrivateData_SavedPasswords) { TEST_F(WebDatabaseTest, BlacklistedLogins) { WebDatabase db; - EXPECT_TRUE(db.Init(file_)); + EXPECT_TRUE(db.Init(file_.ToWStringHack())); std::vector<PasswordForm*> result; // Verify the database is empty. @@ -596,7 +596,7 @@ TEST_F(WebDatabaseTest, BlacklistedLogins) { TEST_F(WebDatabaseTest, WebAppHasAllImages) { WebDatabase db; - EXPECT_TRUE(db.Init(file_)); + EXPECT_TRUE(db.Init(file_.ToWStringHack())); GURL url("http://google.com/"); // Initial value for unknown web app should be false. @@ -614,7 +614,7 @@ TEST_F(WebDatabaseTest, WebAppHasAllImages) { TEST_F(WebDatabaseTest, WebAppImages) { WebDatabase db; - ASSERT_TRUE(db.Init(file_)); + ASSERT_TRUE(db.Init(file_.ToWStringHack())); GURL url("http://google.com/"); // Web app should initially have no images. diff --git a/chrome/renderer/extensions/json_schema_unittest.cc b/chrome/renderer/extensions/json_schema_unittest.cc index 200c435..15a4d8c 100755 --- a/chrome/renderer/extensions/json_schema_unittest.cc +++ b/chrome/renderer/extensions/json_schema_unittest.cc @@ -28,10 +28,10 @@ class JsonSchemaTest : public V8UnitTest { ExecuteScriptInContext(js, kJsonSchema); // Add the test functions to the context. - std::wstring test_js_file_path; + FilePath test_js_file_path; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_js_file_path)); - file_util::AppendToPath(&test_js_file_path, L"extensions"); - file_util::AppendToPath(&test_js_file_path, UTF8ToWide(kJsonSchemaTest)); + test_js_file_path = test_js_file_path.AppendASCII("extensions"); + test_js_file_path = test_js_file_path.AppendASCII(kJsonSchemaTest); std::string test_js; ASSERT_TRUE(file_util::ReadFileToString(test_js_file_path, &test_js)); ExecuteScriptInContext(test_js, kJsonSchemaTest); |