summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-14 19:36:31 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-14 19:36:31 +0000
commitb65de8b9d5bfa020d97122c1eff2115fa8e97561 (patch)
tree3eb86aed4e3352cbca7cc4b78e76f5ee26d7388c
parent5e70f14644629b7f9fe9126553758aed25e17128 (diff)
downloadchromium_src-b65de8b9d5bfa020d97122c1eff2115fa8e97561.zip
chromium_src-b65de8b9d5bfa020d97122c1eff2115fa8e97561.tar.gz
chromium_src-b65de8b9d5bfa020d97122c1eff2115fa8e97561.tar.bz2
Fix to use FilePath in more unittests.
Landing patch for Thiago Farina, original review: http://codereview.chromium.org/187005 BUG=None TEST=run unit_tests.exe, base_unittests.exe. Review URL: http://codereview.chromium.org/193101 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26142 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/path_service_unittest.cc2
-rw-r--r--base/sys_info_unittest.cc5
-rw-r--r--chrome/browser/browser_focus_uitest.cc8
-rw-r--r--chrome/browser/importer/firefox_profile_lock_unittest.cc9
-rw-r--r--chrome/browser/printing/printing_layout_uitest.cc15
-rw-r--r--chrome/browser/privacy_blacklist/blacklist_io_unittest.cc24
-rw-r--r--chrome/installer/setup/setup_util_unittest.cc15
7 files changed, 35 insertions, 43 deletions
diff --git a/base/path_service_unittest.cc b/base/path_service_unittest.cc
index d9eb0a5..32f49b2 100644
--- a/base/path_service_unittest.cc
+++ b/base/path_service_unittest.cc
@@ -27,7 +27,7 @@ bool ReturnsValidPath(int dir_type) {
#if defined(OS_WIN)
// Function to test DIR_LOCAL_APP_DATA_LOW on Windows XP. Make sure it fails.
bool ReturnsInvalidPath(int dir_type) {
- std::wstring path;
+ FilePath path;
bool result = PathService::Get(base::DIR_LOCAL_APP_DATA_LOW, &path);
return !result && path.empty();
}
diff --git a/base/sys_info_unittest.cc b/base/sys_info_unittest.cc
index 8c5391f..160abd6 100644
--- a/base/sys_info_unittest.cc
+++ b/base/sys_info_unittest.cc
@@ -22,9 +22,10 @@ TEST_F(SysInfoTest, AmountOfMem) {
TEST_F(SysInfoTest, AmountOfFreeDiskSpace) {
// We aren't actually testing that it's correct, just that it's sane.
- std::wstring tmp_path;
+ FilePath tmp_path;
ASSERT_TRUE(file_util::GetTempDir(&tmp_path));
- EXPECT_GT(base::SysInfo::AmountOfFreeDiskSpace(tmp_path), 0) << tmp_path;
+ EXPECT_GT(base::SysInfo::AmountOfFreeDiskSpace(tmp_path.ToWStringHack()), 0)
+ << tmp_path.value();
}
TEST_F(SysInfoTest, GetEnvVar) {
diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc
index 87290dd..d2cab01 100644
--- a/chrome/browser/browser_focus_uitest.cc
+++ b/chrome/browser/browser_focus_uitest.cc
@@ -48,7 +48,7 @@ const int kActionDelayMs = 500;
const wchar_t kSimplePage[] = L"files/focus/page_with_focus.html";
const wchar_t kStealFocusPage[] = L"files/focus/page_steals_focus.html";
const wchar_t kTypicalPage[] = L"files/focus/typical_page.html";
-const wchar_t kTypicalPageName[] = L"typical_page.html";
+const char kTypicalPageName[] = "typical_page.html";
class BrowserFocusTest : public InProcessBrowserTest {
public:
@@ -148,11 +148,11 @@ class TestInterstitialPage : public InterstitialPage {
TestInterstitialPage(TabContents* tab, bool new_navigation, const GURL& url)
: InterstitialPage(tab, new_navigation, url),
waiting_for_dom_response_(false) {
- std::wstring file_path;
+ FilePath file_path;
bool r = PathService::Get(chrome::DIR_TEST_DATA, &file_path);
EXPECT_TRUE(r);
- file_util::AppendToPath(&file_path, L"focus");
- file_util::AppendToPath(&file_path, kTypicalPageName);
+ file_path = file_path.AppendASCII("focus");
+ file_path = file_path.AppendASCII(kTypicalPageName);
r = file_util::ReadFileToString(file_path, &html_contents_);
EXPECT_TRUE(r);
}
diff --git a/chrome/browser/importer/firefox_profile_lock_unittest.cc b/chrome/browser/importer/firefox_profile_lock_unittest.cc
index fc5c911..1f365d0 100644
--- a/chrome/browser/importer/firefox_profile_lock_unittest.cc
+++ b/chrome/browser/importer/firefox_profile_lock_unittest.cc
@@ -80,9 +80,10 @@ TEST_F(FirefoxProfileLockTest, ProfileLock) {
// If for some reason the lock file is left behind by the previous owner, we
// should still be able to lock it, at least in the Windows implementation.
TEST_F(FirefoxProfileLockTest, ProfileLockOrphaned) {
- std::wstring test_path;
- file_util::CreateNewTempDirectory(L"firefox_profile", &test_path);
- FilePath lock_file_path = FilePath::FromWStringHack(test_path);
+ FilePath test_path;
+ file_util::CreateNewTempDirectory(FILE_PATH_LITERAL("firefox_profile"),
+ &test_path);
+ FilePath lock_file_path = test_path;
FileAutoDeleter deleter(lock_file_path);
lock_file_path = lock_file_path.Append(FirefoxProfileLock::kLockFileName);
@@ -94,7 +95,7 @@ TEST_F(FirefoxProfileLockTest, ProfileLockOrphaned) {
scoped_ptr<FirefoxProfileLock> lock;
EXPECT_EQ(static_cast<FirefoxProfileLock*>(NULL), lock.get());
- lock.reset(new FirefoxProfileLock(test_path));
+ lock.reset(new FirefoxProfileLock(test_path.ToWStringHack()));
EXPECT_TRUE(lock->HasAcquired());
lock->Unlock();
EXPECT_FALSE(lock->HasAcquired());
diff --git a/chrome/browser/printing/printing_layout_uitest.cc b/chrome/browser/printing/printing_layout_uitest.cc
index f135566..6b86e83 100644
--- a/chrome/browser/printing/printing_layout_uitest.cc
+++ b/chrome/browser/printing/printing_layout_uitest.cc
@@ -27,10 +27,10 @@ const wchar_t kDocRoot[] = L"chrome/test/data";
class PrintingLayoutTest : public PrintingTest<UITest> {
public:
PrintingLayoutTest() {
- emf_path_ = browser_directory_.ToWStringHack();
- file_util::AppendToPath(&emf_path_, L"metafile_dumps");
+ emf_path_ = browser_directory_;
+ emf_path_ = emf_path_.AppendASCII("metafile_dumps");
launch_arguments_.AppendSwitchWithValue(L"debug-print",
- L'"' + emf_path_ + L'"');
+ L'"' + emf_path_.value() + L'"');
show_window_ = true;
}
@@ -156,8 +156,7 @@ class PrintingLayoutTest : public PrintingTest<UITest> {
bool found_emf = false;
bool found_prn = false;
for (int i = 0; i < 100; ++i) {
- file_util::FileEnumerator enumerator(
- FilePath::FromWStringHack(emf_path()), false,
+ file_util::FileEnumerator enumerator(emf_path(), false,
file_util::FileEnumerator::FILES);
emf_file.clear();
prn_file.clear();
@@ -198,11 +197,11 @@ class PrintingLayoutTest : public PrintingTest<UITest> {
return CommandLine::ForCurrentProcess()->HasSwitch(kGenerateSwitch);
}
- const std::wstring& emf_path() const { return emf_path_; }
+ const FilePath& emf_path() const { return emf_path_; }
- std::wstring emf_path_;
+ FilePath emf_path_;
- DISALLOW_EVIL_CONSTRUCTORS(PrintingLayoutTest);
+ DISALLOW_COPY_AND_ASSIGN(PrintingLayoutTest);
};
// Tests that don't need UI access.
diff --git a/chrome/browser/privacy_blacklist/blacklist_io_unittest.cc b/chrome/browser/privacy_blacklist/blacklist_io_unittest.cc
index cd43449..ccc380a 100644
--- a/chrome/browser/privacy_blacklist/blacklist_io_unittest.cc
+++ b/chrome/browser/privacy_blacklist/blacklist_io_unittest.cc
@@ -16,11 +16,9 @@ TEST(BlacklistIOTest, Generic) {
FilePath data_dir;
PathService::Get(chrome::DIR_TEST_DATA, &data_dir);
- FilePath input =
- data_dir.Append(FilePath::FromWStringHack(L"blacklist_small.pbl"));
+ FilePath input = data_dir.AppendASCII("blacklist_small.pbl");
- FilePath expected =
- data_dir.Append(FilePath::FromWStringHack(L"blacklist_small.pbr"));
+ FilePath expected = data_dir.AppendASCII("blacklist_small.pbr");
BlacklistIO io;
EXPECT_TRUE(io.Read(input));
@@ -40,7 +38,7 @@ TEST(BlacklistIOTest, Generic) {
FilePath output;
PathService::Get(base::DIR_TEMP, &output);
- output = output.Append(FilePath::FromWStringHack(L"blacklist_small.pbr"));
+ output = output.AppendASCII("blacklist_small.pbr");
CHECK(io.Write(output));
EXPECT_TRUE(file_util::ContentsEqual(output, expected));
EXPECT_TRUE(file_util::Delete(output, false));
@@ -50,16 +48,13 @@ TEST(BlacklistIOTest, Combine) {
// Testing data path.
FilePath data_dir;
PathService::Get(chrome::DIR_TEST_DATA, &data_dir);
- data_dir = data_dir.Append(FilePath::FromWStringHack(L"blacklist_samples"));
+ data_dir = data_dir.AppendASCII("blacklist_samples");
- FilePath input1 =
- data_dir.Append(FilePath::FromWStringHack(L"annoying_ads.pbl"));
+ FilePath input1 = data_dir.AppendASCII("annoying_ads.pbl");
- FilePath input2 =
- data_dir.Append(FilePath::FromWStringHack(L"block_flash.pbl"));
+ FilePath input2 = data_dir.AppendASCII("block_flash.pbl");
- FilePath input3 =
- data_dir.Append(FilePath::FromWStringHack(L"session_cookies.pbl"));
+ FilePath input3 = data_dir.AppendASCII("session_cookies.pbl");
BlacklistIO io;
EXPECT_TRUE(io.Read(input1));
@@ -94,10 +89,9 @@ TEST(BlacklistIOTest, Combine) {
FilePath output;
PathService::Get(base::DIR_TEMP, &output);
- output = output.Append(FilePath::FromWStringHack(L"combine3.pbr"));
+ output = output.AppendASCII("combine3.pbr");
- FilePath expected =
- data_dir.Append(FilePath::FromWStringHack(L"combine3.pbr"));
+ FilePath expected = data_dir.AppendASCII("combine3.pbr");
CHECK(io.Write(output));
EXPECT_TRUE(file_util::ContentsEqual(output, expected));
diff --git a/chrome/installer/setup/setup_util_unittest.cc b/chrome/installer/setup/setup_util_unittest.cc
index 39003bc..34a26fe 100644
--- a/chrome/installer/setup/setup_util_unittest.cc
+++ b/chrome/installer/setup/setup_util_unittest.cc
@@ -135,9 +135,8 @@ TEST_F(SetupUtilTest, GetInstallPreferencesTest) {
// Test that we are parsing Chrome version correctly.
TEST_F(SetupUtilTest, GetVersionFromDirTest) {
// Create a version dir
- std::wstring chrome_dir(test_dir_.value());
- file_util::AppendToPath(&chrome_dir, L"1.0.0.0");
- CreateDirectory(chrome_dir.c_str(), NULL);
+ FilePath chrome_dir = test_dir_.AppendASCII("1.0.0.0");
+ file_util::CreateDirectory(chrome_dir);
ASSERT_TRUE(file_util::PathExists(chrome_dir));
scoped_ptr<installer::Version> version(
setup_util::GetVersionFromDir(test_dir_.value()));
@@ -147,15 +146,13 @@ TEST_F(SetupUtilTest, GetVersionFromDirTest) {
ASSERT_FALSE(file_util::PathExists(chrome_dir));
ASSERT_TRUE(setup_util::GetVersionFromDir(test_dir_.value()) == NULL);
- chrome_dir = test_dir_.value();
- file_util::AppendToPath(&chrome_dir, L"ABC");
- CreateDirectory(chrome_dir.c_str(), NULL);
+ chrome_dir = test_dir_.AppendASCII("ABC");
+ file_util::CreateDirectory(chrome_dir);
ASSERT_TRUE(file_util::PathExists(chrome_dir));
ASSERT_TRUE(setup_util::GetVersionFromDir(test_dir_.value()) == NULL);
- chrome_dir = test_dir_.value();
- file_util::AppendToPath(&chrome_dir, L"2.3.4.5");
- CreateDirectory(chrome_dir.c_str(), NULL);
+ chrome_dir = test_dir_.AppendASCII("2.3.4.5");
+ file_util::CreateDirectory(chrome_dir);
ASSERT_TRUE(file_util::PathExists(chrome_dir));
version.reset(setup_util::GetVersionFromDir(test_dir_.value()));
ASSERT_TRUE(version->GetString() == L"2.3.4.5");