diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-02 05:59:37 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-02 05:59:37 +0000 |
commit | 6fad26338ed6119903826156f307e20fe6657c31 (patch) | |
tree | 5c6baed35fce907a0cea47ed6091c941db8ebfd1 /chrome/common/pref_service_unittest.cc | |
parent | f75c8f13b967b01babc9454506e9d2ed00519e39 (diff) | |
download | chromium_src-6fad26338ed6119903826156f307e20fe6657c31.zip chromium_src-6fad26338ed6119903826156f307e20fe6657c31.tar.gz chromium_src-6fad26338ed6119903826156f307e20fe6657c31.tar.bz2 |
Third patch in getting rid of caching MessageLoop pointers and always using ChromeThread instead.
BUG=25354
Review URL: http://codereview.chromium.org/342068
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30687 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/pref_service_unittest.cc')
-rw-r--r-- | chrome/common/pref_service_unittest.cc | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/chrome/common/pref_service_unittest.cc b/chrome/common/pref_service_unittest.cc index 29b4b09..29b19c3 100644 --- a/chrome/common/pref_service_unittest.cc +++ b/chrome/common/pref_service_unittest.cc @@ -4,7 +4,9 @@ #include "app/test/data/resource.h" #include "base/file_util.h" +#include "base/message_loop.h" #include "base/path_service.h" +#include "chrome/browser/chrome_thread.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/json_value_serializer.h" #include "chrome/common/notification_service.h" @@ -81,7 +83,7 @@ TEST_F(PrefServiceTest, Basic) { { // Test that it fails on nonexistent file. FilePath bogus_input_file = data_dir_.AppendASCII("read.txt"); - PrefService prefs(bogus_input_file, NULL); + PrefService prefs(bogus_input_file); EXPECT_FALSE(prefs.ReloadPersistentPrefs()); } @@ -91,7 +93,7 @@ TEST_F(PrefServiceTest, Basic) { // Test that the persistent value can be loaded. FilePath input_file = test_dir_.AppendASCII("write.json"); ASSERT_TRUE(file_util::PathExists(input_file)); - PrefService prefs(input_file, NULL); + PrefService prefs(input_file); ASSERT_TRUE(prefs.ReloadPersistentPrefs()); // Register test prefs. @@ -141,10 +143,14 @@ TEST_F(PrefServiceTest, Basic) { EXPECT_EQ(some_path.value(), prefs.GetFilePath(kSomeDirectory).value()); // Serialize and compare to expected output. + // SavePersistentPrefs uses ImportantFileWriter which needs a file thread. + MessageLoop message_loop; + ChromeThread file_thread(ChromeThread::FILE, &message_loop); FilePath output_file = test_dir_.AppendASCII("write.json"); FilePath golden_output_file = data_dir_.AppendASCII("write.golden.json"); ASSERT_TRUE(file_util::PathExists(golden_output_file)); ASSERT_TRUE(prefs.SavePersistentPrefs()); + MessageLoop::current()->RunAllPending(); EXPECT_TRUE(file_util::TextContentsEqual(golden_output_file, output_file)); ASSERT_TRUE(file_util::Delete(output_file, false)); } @@ -159,7 +165,7 @@ TEST_F(PrefServiceTest, Overlay) { std::wstring transient_string(L"transient"); FilePath persistent_file = data_dir_.AppendASCII("overlay.json"); - PrefService prefs(persistent_file, NULL); + PrefService prefs(persistent_file); EXPECT_TRUE(prefs.ReloadPersistentPrefs()); Value* transient_value; @@ -286,7 +292,7 @@ TEST_F(PrefServiceTest, Observers) { FilePath input_file = data_dir_.AppendASCII("read.json"); EXPECT_TRUE(file_util::PathExists(input_file)); - PrefService prefs(input_file, NULL); + PrefService prefs(input_file); EXPECT_TRUE(prefs.ReloadPersistentPrefs()); @@ -329,7 +335,7 @@ TEST_F(PrefServiceTest, Observers) { // TODO(port): port this test to POSIX. #if defined(OS_WIN) TEST_F(PrefServiceTest, LocalizedPrefs) { - PrefService prefs(FilePath(), NULL); + PrefService prefs((FilePath())); const wchar_t kBoolean[] = L"boolean"; const wchar_t kInteger[] = L"integer"; const wchar_t kString[] = L"string"; @@ -352,7 +358,7 @@ TEST_F(PrefServiceTest, LocalizedPrefs) { #endif TEST_F(PrefServiceTest, NoObserverFire) { - PrefService prefs(FilePath(), NULL); + PrefService prefs((FilePath())); const wchar_t pref_name[] = L"homepage"; prefs.RegisterStringPref(pref_name, L""); @@ -387,7 +393,7 @@ TEST_F(PrefServiceTest, NoObserverFire) { } TEST_F(PrefServiceTest, HasPrefPath) { - PrefService prefs(FilePath(), NULL); + PrefService prefs((FilePath())); const wchar_t path[] = L"fake.path"; |