diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-04 20:46:06 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-04 20:46:06 +0000 |
commit | ceeb87e90224c8743995b999661eede7c31b6346 (patch) | |
tree | 459f0698b022e42ead17cb742be9ff7f9d1b441f /chrome | |
parent | f3208bd4c625527d854c3bf49908352199488c48 (diff) | |
download | chromium_src-ceeb87e90224c8743995b999661eede7c31b6346.zip chromium_src-ceeb87e90224c8743995b999661eede7c31b6346.tar.gz chromium_src-ceeb87e90224c8743995b999661eede7c31b6346.tar.bz2 |
Get rid of kPathSeparator on windows. Port some wstring function to take FilePaths. Re-enable relevant posix unit tests.
Review URL: http://codereview.chromium.org/12893
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6387 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser_uitest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/download/download_uitest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/download/save_page_uitest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/history/starred_url_database_unittest.cc | 15 | ||||
-rw-r--r-- | chrome/browser/history/url_database_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/history/visit_database_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/importer/ie_importer.cc | 2 | ||||
-rw-r--r-- | chrome/browser/safe_browsing/database_perftest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/session_history_uitest.cc | 8 | ||||
-rw-r--r-- | chrome/browser/session_restore_uitest.cc | 17 | ||||
-rw-r--r-- | chrome/browser/ssl_uitest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/tab_restore_uitest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/url_fetcher_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/visitedlink_perftest.cc | 24 | ||||
-rw-r--r-- | chrome/browser/webdata/web_database_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/test/tab_switching/tab_switching_test.cc | 4 |
16 files changed, 47 insertions, 45 deletions
diff --git a/chrome/browser/browser_uitest.cc b/chrome/browser/browser_uitest.cc index 3bbffe1..f3e42e3 100644 --- a/chrome/browser/browser_uitest.cc +++ b/chrome/browser/browser_uitest.cc @@ -230,7 +230,7 @@ TEST_F(BrowserTest, JavascriptAlertActivatesTab) { TEST_F(BrowserTest, DuplicateTab) { std::wstring path_prefix = test_data_directory_; file_util::AppendToPath(&path_prefix, L"session_history"); - path_prefix += file_util::kPathSeparator; + path_prefix += FilePath::kSeparators[0]; GURL url1 = net::FilePathToFileURL(path_prefix + L"bot1.html"); GURL url2 = net::FilePathToFileURL(path_prefix + L"bot2.html"); GURL url3 = GURL("about:blank"); diff --git a/chrome/browser/download/download_uitest.cc b/chrome/browser/download/download_uitest.cc index 92e826f..52d67ba 100644 --- a/chrome/browser/download/download_uitest.cc +++ b/chrome/browser/download/download_uitest.cc @@ -102,7 +102,7 @@ class DownloadTest : public UITest { virtual void SetUp() { UITest::SetUp(); download_prefix_ = GetDownloadDirectory(); - download_prefix_ += file_util::kPathSeparator; + download_prefix_ += FilePath::kSeparators[0]; } protected: diff --git a/chrome/browser/download/save_page_uitest.cc b/chrome/browser/download/save_page_uitest.cc index 551c335..0c75c21 100644 --- a/chrome/browser/download/save_page_uitest.cc +++ b/chrome/browser/download/save_page_uitest.cc @@ -52,7 +52,7 @@ class SavePageTest : public UITest { virtual void SetUp() { UITest::SetUp(); EXPECT_TRUE(file_util::CreateNewTempDirectory(L"", &save_dir_)); - save_dir_ += file_util::kPathSeparator; + save_dir_ += FilePath::kSeparators[0]; } std::wstring save_dir_; diff --git a/chrome/browser/history/starred_url_database_unittest.cc b/chrome/browser/history/starred_url_database_unittest.cc index 32e834d..b570358 100644 --- a/chrome/browser/history/starred_url_database_unittest.cc +++ b/chrome/browser/history/starred_url_database_unittest.cc @@ -66,18 +66,19 @@ class StarredURLDatabaseTest : public testing::Test, // Test setup. void SetUp() { PathService::Get(base::DIR_TEMP, &db_file_); - db_file_.push_back(file_util::kPathSeparator); - db_file_.append(L"VisitTest.db"); + db_file_ = db_file_.Append(FILE_PATH_LITERAL("VisitTest.db")); file_util::Delete(db_file_, false); // Copy db file over that contains starred table. - std::wstring old_history_path; + FilePath old_history_path; PathService::Get(chrome::DIR_TEST_DATA, &old_history_path); - file_util::AppendToPath(&old_history_path, L"bookmarks"); - file_util::AppendToPath(&old_history_path, L"History_with_empty_starred"); + old_history_path = old_history_path.Append(FILE_PATH_LITERAL("bookmarks")); + old_history_path = old_history_path.Append( + FILE_PATH_LITERAL("History_with_empty_starred")); file_util::CopyFile(old_history_path, db_file_); - EXPECT_EQ(SQLITE_OK, sqlite3_open(WideToUTF8(db_file_).c_str(), &db_)); + EXPECT_EQ(SQLITE_OK, + sqlite3_open(WideToUTF8(db_file_.ToWStringHack()).c_str(), &db_)); statement_cache_ = new SqliteStatementCache(db_); // Initialize the tables for this test. @@ -99,7 +100,7 @@ class StarredURLDatabaseTest : public testing::Test, return *statement_cache_; } - std::wstring db_file_; + FilePath db_file_; sqlite3* db_; SqliteStatementCache* statement_cache_; }; diff --git a/chrome/browser/history/url_database_unittest.cc b/chrome/browser/history/url_database_unittest.cc index c58029d..2159e45 100644 --- a/chrome/browser/history/url_database_unittest.cc +++ b/chrome/browser/history/url_database_unittest.cc @@ -39,7 +39,7 @@ class URLDatabaseTest : public testing::Test, // Test setup. void SetUp() { PathService::Get(base::DIR_TEMP, &db_file_); - db_file_.push_back(file_util::kPathSeparator); + db_file_.push_back(FilePath::kSeparators[0]); db_file_.append(L"URLTest.db"); EXPECT_EQ(SQLITE_OK, sqlite3_open(WideToUTF8(db_file_).c_str(), &db_)); diff --git a/chrome/browser/history/visit_database_unittest.cc b/chrome/browser/history/visit_database_unittest.cc index 1992f0b..47846b6 100644 --- a/chrome/browser/history/visit_database_unittest.cc +++ b/chrome/browser/history/visit_database_unittest.cc @@ -41,7 +41,7 @@ class VisitDatabaseTest : public testing::Test, // Test setup. void SetUp() { PathService::Get(base::DIR_TEMP, &db_file_); - db_file_.push_back(file_util::kPathSeparator); + db_file_.push_back(FilePath::kSeparators[0]); db_file_.append(L"VisitTest.db"); file_util::Delete(db_file_, false); diff --git a/chrome/browser/importer/ie_importer.cc b/chrome/browser/importer/ie_importer.cc index 2e5d919..450e5165 100644 --- a/chrome/browser/importer/ie_importer.cc +++ b/chrome/browser/importer/ie_importer.cc @@ -495,7 +495,7 @@ void IEImporter::ParseFavoritesFolder(const FavoritesInfo& info, entry.url = url; entry.creation_time = GetFileCreationTime(*it); if (!relative_path.empty()) - SplitString(relative_path, file_util::kPathSeparator, &entry.path); + file_util::PathComponents(relative_path, &entry.path); // Flatten the bookmarks in Link folder onto bookmark toolbar. Otherwise, // put it into "Other bookmarks". diff --git a/chrome/browser/safe_browsing/database_perftest.cc b/chrome/browser/safe_browsing/database_perftest.cc index c39a58d..273bda4 100644 --- a/chrome/browser/safe_browsing/database_perftest.cc +++ b/chrome/browser/safe_browsing/database_perftest.cc @@ -45,7 +45,7 @@ class Database { // get an empty file for the test DB std::wstring filename; PathService::Get(base::DIR_TEMP, &filename); - filename.push_back(file_util::kPathSeparator); + filename.push_back(FilePath::kSeparators[0]); filename.append(ASCIIToWide(name)); if (create) { @@ -390,7 +390,7 @@ class SafeBrowsingDatabaseTest { logging::DELETE_OLD_LOG_FILE); PathService::Get(base::DIR_TEMP, &filename_); - filename_.push_back(file_util::kPathSeparator); + filename_.push_back(FilePath::kSeparators[0]); filename_.append(name); } diff --git a/chrome/browser/session_history_uitest.cc b/chrome/browser/session_history_uitest.cc index dc72ef1..251a3ba 100644 --- a/chrome/browser/session_history_uitest.cc +++ b/chrome/browser/session_history_uitest.cc @@ -22,11 +22,11 @@ const wchar_t kDocRoot[] = L"chrome/test/data"; class SessionHistoryTest : public UITest { protected: SessionHistoryTest() : UITest() { - wstring path_prefix = test_data_directory_; - file_util::AppendToPath(&path_prefix, L"session_history"); - path_prefix += file_util::kPathSeparator; + FilePath path = FilePath::FromWStringHack(test_data_directory_); + path = path.Append(FILE_PATH_LITERAL("session_history")) + .Append(FilePath::StringType(&FilePath::kSeparators[0], 1)); - url_prefix_ = UTF8ToWide(net::FilePathToFileURL(path_prefix).spec()); + url_prefix_ = UTF8ToWide(net::FilePathToFileURL(path).spec()); } virtual void SetUp() { diff --git a/chrome/browser/session_restore_uitest.cc b/chrome/browser/session_restore_uitest.cc index dede0fc9a..f93098a 100644 --- a/chrome/browser/session_restore_uitest.cc +++ b/chrome/browser/session_restore_uitest.cc @@ -21,13 +21,16 @@ namespace { class SessionRestoreUITest : public UITest { protected: SessionRestoreUITest() : UITest() { - std::wstring path_prefix = test_data_directory_; - file_util::AppendToPath(&path_prefix, L"session_history"); - path_prefix += file_util::kPathSeparator; - - url1 = net::FilePathToFileURL(path_prefix + L"bot1.html"); - url2 = net::FilePathToFileURL(path_prefix + L"bot2.html"); - url3 = net::FilePathToFileURL(path_prefix + L"bot3.html"); + FilePath path_prefix = FilePath::FromWStringHack(test_data_directory_); + path_prefix = path_prefix.Append(FILE_PATH_LITERAL("session_history")) + .Append(FilePath::StringType(&FilePath::kSeparators[0], 1)); + + url1 = net::FilePathToFileURL( + path_prefix.Append(FILE_PATH_LITERAL("bot1.html"))); + url2 = net::FilePathToFileURL( + path_prefix.Append(FILE_PATH_LITERAL("bot2.html"))); + url3 = net::FilePathToFileURL( + path_prefix.Append(FILE_PATH_LITERAL("bot3.html"))); } virtual void QuitBrowserAndRestore() { diff --git a/chrome/browser/ssl_uitest.cc b/chrome/browser/ssl_uitest.cc index feea5e0..906c28c 100644 --- a/chrome/browser/ssl_uitest.cc +++ b/chrome/browser/ssl_uitest.cc @@ -32,7 +32,7 @@ class SSLUITest : public UITest { PathService::Get(base::DIR_SOURCE_ROOT, &cert_dir_); cert_dir_ += L"/chrome/test/data/ssl/certificates/"; std::replace(cert_dir_.begin(), cert_dir_.end(), - L'/', file_util::kPathSeparator); + L'/', FilePath::kSeparators[0]); } TabProxy* GetActiveTabProxy() { diff --git a/chrome/browser/tab_restore_uitest.cc b/chrome/browser/tab_restore_uitest.cc index d108d0f..6e813e8 100644 --- a/chrome/browser/tab_restore_uitest.cc +++ b/chrome/browser/tab_restore_uitest.cc @@ -21,7 +21,7 @@ class TabRestoreUITest : public UITest { TabRestoreUITest() : UITest() { std::wstring path_prefix = test_data_directory_; file_util::AppendToPath(&path_prefix, L"session_history"); - path_prefix += file_util::kPathSeparator; + path_prefix += FilePath::kSeparators[0]; url1_ = net::FilePathToFileURL(path_prefix + L"bot1.html"); url2_ = net::FilePathToFileURL(path_prefix + L"bot2.html"); } diff --git a/chrome/browser/url_fetcher_unittest.cc b/chrome/browser/url_fetcher_unittest.cc index 7f737c4..b842b762 100644 --- a/chrome/browser/url_fetcher_unittest.cc +++ b/chrome/browser/url_fetcher_unittest.cc @@ -263,7 +263,7 @@ URLFetcherBadHTTPSTest::URLFetcherBadHTTPSTest() { PathService::Get(base::DIR_SOURCE_ROOT, &cert_dir_); cert_dir_ += L"/chrome/test/data/ssl/certificates/"; std::replace(cert_dir_.begin(), cert_dir_.end(), - L'/', file_util::kPathSeparator); + L'/', FilePath::kSeparators[0]); } // The "server certificate expired" error should result in automatic diff --git a/chrome/browser/visitedlink_perftest.cc b/chrome/browser/visitedlink_perftest.cc index 328e9fe..d589f92 100644 --- a/chrome/browser/visitedlink_perftest.cc +++ b/chrome/browser/visitedlink_perftest.cc @@ -34,14 +34,12 @@ VisitedLinkMaster::PostNewTableEvent DummyBroadcastNewTableEvent; void DummyBroadcastNewTableEvent(base::SharedMemory *table) { } -// Call at the beginning of the test to retrieve the database name and to -// delete any old databases left by previous unit tests. The input buffer -// should be MAX_PATH long. -void InitDBName(wchar_t* db_name) { - ASSERT_TRUE(GetCurrentDirectory(MAX_PATH, db_name)); - if (db_name[wcslen(db_name) - 1] != file_util::kPathSeparator) - wcsncat_s(db_name, MAX_PATH, &file_util::kPathSeparator, 1); - wcscat_s(db_name, MAX_PATH, L"TempVisitedLinks"); +// Call at the beginning of the test to retrieve the database name. +void InitDBName(std::wstring* db_name) { + FilePath db_path; + ASSERT_TRUE(file_util::GetCurrentDirectory(&db_path)); + db_path = db_path.Append(FILE_PATH_LITERAL("TempVisitedLinks")); + *db_name = db_path.ToWStringHack(); } // this checks IsVisited for the URLs starting with the given prefix and @@ -62,13 +60,13 @@ void FillTable(VisitedLinkMaster& master, const char* prefix, class VisitedLink : public testing::Test { protected: - wchar_t db_name_[MAX_PATH]; + std::wstring db_name_; virtual void SetUp() { - InitDBName(db_name_); - DeleteFile(db_name_); + InitDBName(&db_name_); + file_util::Delete(db_name_, false); } virtual void TearDown() { - DeleteFile(db_name_); + file_util::Delete(db_name_, false); } }; @@ -145,7 +143,7 @@ TEST_F(VisitedLink, TestLoad) { for (int i = 0; i < load_count; i++) { // make sure the file has to be re-loaded - file_util::EvictFileFromSystemCache(db_name_); + file_util::EvictFileFromSystemCache(db_name_.c_str()); // cold load (no OS cache, hopefully) { diff --git a/chrome/browser/webdata/web_database_unittest.cc b/chrome/browser/webdata/web_database_unittest.cc index 785409a..1fe4ce4 100644 --- a/chrome/browser/webdata/web_database_unittest.cc +++ b/chrome/browser/webdata/web_database_unittest.cc @@ -28,7 +28,7 @@ class WebDatabaseTest : public testing::Test { _itow_s(static_cast<int>(GetTickCount()), b, arraysize(b), 10); PathService::Get(chrome::DIR_TEST_DATA, &file_); - file_ += file_util::kPathSeparator; + file_ += FilePath::kSeparators[0]; file_ += L"TestWebDatabase"; file_ += b; file_ += L".db"; diff --git a/chrome/test/tab_switching/tab_switching_test.cc b/chrome/test/tab_switching/tab_switching_test.cc index 14a993a..612181c 100644 --- a/chrome/test/tab_switching/tab_switching_test.cc +++ b/chrome/test/tab_switching/tab_switching_test.cc @@ -33,7 +33,7 @@ class TabSwitchingUITest : public UITest { file_util::UpOneDirectory(&path_prefix_); file_util::AppendToPath(&path_prefix_, L"data"); file_util::AppendToPath(&path_prefix_, L"tab_switching"); - path_prefix_ += file_util::kPathSeparator; + path_prefix_ += FilePath::kSeparators[0]; show_window_ = true; } @@ -120,7 +120,7 @@ class TabSwitchingUITest : public UITest { for (int i = 0; i < arraysize(files); ++i) { file_name = path_prefix_; file_name += files[i]; - file_name += file_util::kPathSeparator; + file_name += FilePath::kSeparators[0]; file_name += L"index.html"; browser_proxy_->AppendTab(net::FilePathToFileURL(file_name)); number_of_new_tabs_opened++; |