| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 11 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
| 12 #include "chrome/browser/policy/mock_configuration_policy_provider.h" | 12 #include "chrome/browser/policy/mock_configuration_policy_provider.h" |
| 13 #include "chrome/browser/prefs/browser_prefs.h" | 13 #include "chrome/browser/prefs/browser_prefs.h" |
| 14 #include "chrome/browser/prefs/command_line_pref_store.h" | 14 #include "chrome/browser/prefs/command_line_pref_store.h" |
| 15 #include "chrome/browser/prefs/pref_change_registrar.h" | 15 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 16 #include "chrome/browser/prefs/pref_observer_mock.h" | 16 #include "chrome/browser/prefs/pref_observer_mock.h" |
| 17 #include "chrome/browser/prefs/pref_service_mock_builder.h" | 17 #include "chrome/browser/prefs/pref_service_mock_builder.h" |
| 18 #include "chrome/browser/prefs/pref_value_store.h" | 18 #include "chrome/browser/prefs/pref_value_store.h" |
| 19 #include "chrome/browser/prefs/testing_pref_store.h" | 19 #include "chrome/browser/prefs/testing_pref_store.h" |
| 20 #include "chrome/common/chrome_paths.h" | 20 #include "chrome/common/chrome_paths.h" |
| 21 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 23 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 23 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 24 #include "chrome/test/base/testing_pref_service.h" | 24 #include "chrome/test/base/testing_pref_service.h" |
| 25 #include "chrome/test/base/testing_pref_service.h" | |
| 26 #include "chrome/test/base/testing_profile.h" | 25 #include "chrome/test/base/testing_profile.h" |
| 27 #include "content/browser/tab_contents/test_tab_contents.h" | 26 #include "content/browser/tab_contents/test_tab_contents.h" |
| 28 #include "content/test/test_browser_thread.h" | 27 #include "content/test/test_browser_thread.h" |
| 29 #include "testing/gmock/include/gmock/gmock.h" | 28 #include "testing/gmock/include/gmock/gmock.h" |
| 30 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 31 #include "ui/base/test/data/resource.h" | 30 #include "ui/base/test/data/resource.h" |
| 32 | 31 |
| 33 using content::BrowserThread; | 32 using content::BrowserThread; |
| 34 using testing::_; | 33 using testing::_; |
| 35 using testing::Mock; | 34 using testing::Mock; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 prefs.FindPreference(prefs::kStabilityLaunchCount); | 142 prefs.FindPreference(prefs::kStabilityLaunchCount); |
| 144 ASSERT_TRUE(pref); | 143 ASSERT_TRUE(pref); |
| 145 const Value* value = pref->GetValue(); | 144 const Value* value = pref->GetValue(); |
| 146 ASSERT_TRUE(value); | 145 ASSERT_TRUE(value); |
| 147 EXPECT_EQ(Value::TYPE_INTEGER, value->GetType()); | 146 EXPECT_EQ(Value::TYPE_INTEGER, value->GetType()); |
| 148 int actual_int_value = -1; | 147 int actual_int_value = -1; |
| 149 EXPECT_TRUE(value->GetAsInteger(&actual_int_value)); | 148 EXPECT_TRUE(value->GetAsInteger(&actual_int_value)); |
| 150 EXPECT_EQ(kTestValue, actual_int_value); | 149 EXPECT_EQ(kTestValue, actual_int_value); |
| 151 } | 150 } |
| 152 | 151 |
| 152 TEST(PrefServiceTest, UpdateCommandLinePrefStore) { |
| 153 TestingPrefService prefs; |
| 154 prefs.RegisterBooleanPref(prefs::kCloudPrintProxyEnabled, false); |
| 155 |
| 156 // Check to make sure the value is as expected. |
| 157 const PrefService::Preference* pref = |
| 158 prefs.FindPreference(prefs::kCloudPrintProxyEnabled); |
| 159 ASSERT_TRUE(pref); |
| 160 const Value* value = pref->GetValue(); |
| 161 ASSERT_TRUE(value); |
| 162 EXPECT_EQ(Value::TYPE_BOOLEAN, value->GetType()); |
| 163 bool actual_bool_value = true; |
| 164 EXPECT_TRUE(value->GetAsBoolean(&actual_bool_value)); |
| 165 EXPECT_EQ(false, actual_bool_value); |
| 166 |
| 167 // Change the command line. |
| 168 CommandLine cmd_line(CommandLine::NO_PROGRAM); |
| 169 cmd_line.AppendSwitch(switches::kEnableCloudPrintProxy); |
| 170 |
| 171 // Call UpdateCommandLinePrefStore and check to see if the value has changed. |
| 172 prefs.UpdateCommandLinePrefStore(&cmd_line); |
| 173 pref = prefs.FindPreference(prefs::kCloudPrintProxyEnabled); |
| 174 ASSERT_TRUE(pref); |
| 175 value = pref->GetValue(); |
| 176 ASSERT_TRUE(value); |
| 177 EXPECT_EQ(Value::TYPE_BOOLEAN, value->GetType()); |
| 178 actual_bool_value = false; |
| 179 EXPECT_TRUE(value->GetAsBoolean(&actual_bool_value)); |
| 180 EXPECT_EQ(true, actual_bool_value); |
| 181 } |
| 182 |
| 153 class PrefServiceSetValueTest : public testing::Test { | 183 class PrefServiceSetValueTest : public testing::Test { |
| 154 protected: | 184 protected: |
| 155 static const char kName[]; | 185 static const char kName[]; |
| 156 static const char kValue[]; | 186 static const char kValue[]; |
| 157 | 187 |
| 158 TestingPrefService prefs_; | 188 TestingPrefService prefs_; |
| 159 PrefObserverMock observer_; | 189 PrefObserverMock observer_; |
| 160 }; | 190 }; |
| 161 | 191 |
| 162 const char PrefServiceSetValueTest::kName[] = "name"; | 192 const char PrefServiceSetValueTest::kName[] = "name"; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 #if defined(OS_MACOSX) | 316 #if defined(OS_MACOSX) |
| 287 const char kDefaultFont[] = "Times"; | 317 const char kDefaultFont[] = "Times"; |
| 288 #elif defined(OS_CHROMEOS) | 318 #elif defined(OS_CHROMEOS) |
| 289 const char kDefaultFont[] = "Tinos"; | 319 const char kDefaultFont[] = "Tinos"; |
| 290 #else | 320 #else |
| 291 const char kDefaultFont[] = "Times New Roman"; | 321 const char kDefaultFont[] = "Times New Roman"; |
| 292 #endif | 322 #endif |
| 293 EXPECT_EQ(ASCIIToUTF16(kDefaultFont), webkit_prefs.standard_font_family); | 323 EXPECT_EQ(ASCIIToUTF16(kDefaultFont), webkit_prefs.standard_font_family); |
| 294 EXPECT_TRUE(webkit_prefs.javascript_enabled); | 324 EXPECT_TRUE(webkit_prefs.javascript_enabled); |
| 295 } | 325 } |
| OLD | NEW |