| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 value = pref->GetValue(); | 56 value = pref->GetValue(); |
| 57 ASSERT_TRUE(value); | 57 ASSERT_TRUE(value); |
| 58 EXPECT_EQ(base::Value::TYPE_BOOLEAN, value->GetType()); | 58 EXPECT_EQ(base::Value::TYPE_BOOLEAN, value->GetType()); |
| 59 actual_bool_value = false; | 59 actual_bool_value = false; |
| 60 EXPECT_TRUE(value->GetAsBoolean(&actual_bool_value)); | 60 EXPECT_TRUE(value->GetAsBoolean(&actual_bool_value)); |
| 61 EXPECT_TRUE(actual_bool_value); | 61 EXPECT_TRUE(actual_bool_value); |
| 62 } | 62 } |
| 63 | 63 |
| 64 class ChromePrefServiceUserFilePrefsTest : public testing::Test { | 64 class ChromePrefServiceUserFilePrefsTest : public testing::Test { |
| 65 protected: | 65 protected: |
| 66 virtual void SetUp() { | 66 void SetUp() override { |
| 67 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 67 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 68 | 68 |
| 69 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_dir_)); | 69 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_dir_)); |
| 70 data_dir_ = data_dir_.AppendASCII("pref_service"); | 70 data_dir_ = data_dir_.AppendASCII("pref_service"); |
| 71 ASSERT_TRUE(base::PathExists(data_dir_)); | 71 ASSERT_TRUE(base::PathExists(data_dir_)); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void ClearListValue(PrefService* prefs, const char* key) { | 74 void ClearListValue(PrefService* prefs, const char* key) { |
| 75 ListPrefUpdate updater(prefs, key); | 75 ListPrefUpdate updater(prefs, key); |
| 76 updater->Clear(); | 76 updater->Clear(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void ClearDictionaryValue(PrefService* prefs, const char* key) { | 79 void ClearDictionaryValue(PrefService* prefs, const char* key) { |
| 80 DictionaryPrefUpdate updater(prefs, key); | 80 DictionaryPrefUpdate updater(prefs, key); |
| 81 updater->Clear(); | 81 updater->Clear(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 // The path to temporary directory used to contain the test operations. | 84 // The path to temporary directory used to contain the test operations. |
| 85 base::ScopedTempDir temp_dir_; | 85 base::ScopedTempDir temp_dir_; |
| 86 // The path to the directory where the test data is stored. | 86 // The path to the directory where the test data is stored. |
| 87 base::FilePath data_dir_; | 87 base::FilePath data_dir_; |
| 88 // A message loop that we can use as the file thread message loop. | 88 // A message loop that we can use as the file thread message loop. |
| 89 base::MessageLoop message_loop_; | 89 base::MessageLoop message_loop_; |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 class ChromePrefServiceWebKitPrefs : public ChromeRenderViewHostTestHarness { | 92 class ChromePrefServiceWebKitPrefs : public ChromeRenderViewHostTestHarness { |
| 93 protected: | 93 protected: |
| 94 virtual void SetUp() { | 94 void SetUp() override { |
| 95 ChromeRenderViewHostTestHarness::SetUp(); | 95 ChromeRenderViewHostTestHarness::SetUp(); |
| 96 | 96 |
| 97 // Supply our own profile so we use the correct profile data. The test | 97 // Supply our own profile so we use the correct profile data. The test |
| 98 // harness is not supposed to overwrite a profile if it's already created. | 98 // harness is not supposed to overwrite a profile if it's already created. |
| 99 | 99 |
| 100 // Set some (WebKit) user preferences. | 100 // Set some (WebKit) user preferences. |
| 101 TestingPrefServiceSyncable* pref_services = | 101 TestingPrefServiceSyncable* pref_services = |
| 102 profile()->GetTestingPrefService(); | 102 profile()->GetTestingPrefService(); |
| 103 pref_services->SetUserPref(prefs::kDefaultCharset, | 103 pref_services->SetUserPref(prefs::kDefaultCharset, |
| 104 new base::StringValue("utf8")); | 104 new base::StringValue("utf8")); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 130 const char kDefaultFont[] = "Times"; | 130 const char kDefaultFont[] = "Times"; |
| 131 #elif defined(OS_CHROMEOS) | 131 #elif defined(OS_CHROMEOS) |
| 132 const char kDefaultFont[] = "Tinos"; | 132 const char kDefaultFont[] = "Tinos"; |
| 133 #else | 133 #else |
| 134 const char kDefaultFont[] = "Times New Roman"; | 134 const char kDefaultFont[] = "Times New Roman"; |
| 135 #endif | 135 #endif |
| 136 EXPECT_EQ(base::ASCIIToUTF16(kDefaultFont), | 136 EXPECT_EQ(base::ASCIIToUTF16(kDefaultFont), |
| 137 webkit_prefs.standard_font_family_map[prefs::kWebKitCommonScript]); | 137 webkit_prefs.standard_font_family_map[prefs::kWebKitCommonScript]); |
| 138 EXPECT_TRUE(webkit_prefs.javascript_enabled); | 138 EXPECT_TRUE(webkit_prefs.javascript_enabled); |
| 139 } | 139 } |
| OLD | NEW |