| 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/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "chrome/browser/prefs/chrome_command_line_pref_store.h" | 7 #include "chrome/browser/prefs/chrome_command_line_pref_store.h" |
| 8 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
| 9 #include "chrome/common/pref_names.h" | 9 #include "chrome/common/pref_names.h" |
| 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 11 #include "chrome/test/base/testing_profile.h" | 11 #include "chrome/test/base/testing_profile.h" |
| 12 #include "components/prefs/pref_registry_simple.h" | 12 #include "components/prefs/pref_registry_simple.h" |
| 13 #include "components/sync_preferences/testing_pref_service_syncable.h" | 13 #include "components/sync_preferences/testing_pref_service_syncable.h" |
| 14 #include "content/public/common/web_preferences.h" | 14 #include "content/public/common/web_preferences.h" |
| 15 #include "content/public/test/test_renderer_host.h" | 15 #include "content/public/test/test_renderer_host.h" |
| 16 | 16 |
| 17 using content::RenderViewHostTester; | 17 using content::RenderViewHostTester; |
| 18 using content::WebPreferences; | 18 using content::WebPreferences; |
| 19 | 19 |
| 20 TEST(ChromePrefServiceTest, UpdateCommandLinePrefStore) { | 20 TEST(ChromePrefServiceTest, UpdateCommandLinePrefStore) { |
| 21 TestingPrefServiceSimple prefs; | 21 TestingPrefServiceSimple prefs; |
| 22 prefs.registry()->RegisterBooleanPref(prefs::kCloudPrintProxyEnabled, false); | 22 prefs.registry()->RegisterBooleanPref(prefs::kCloudPrintProxyEnabled, false); |
| 23 | 23 |
| 24 // Check to make sure the value is as expected. | 24 // Check to make sure the value is as expected. |
| 25 const PrefService::Preference* pref = | 25 const PrefService::Preference* pref = |
| 26 prefs.FindPreference(prefs::kCloudPrintProxyEnabled); | 26 prefs.FindPreference(prefs::kCloudPrintProxyEnabled); |
| 27 ASSERT_TRUE(pref); | 27 ASSERT_TRUE(pref); |
| 28 const base::Value* value = pref->GetValue(); | 28 const base::Value* value = pref->GetValue(); |
| 29 ASSERT_TRUE(value); | 29 ASSERT_TRUE(value); |
| 30 EXPECT_EQ(base::Value::TYPE_BOOLEAN, value->GetType()); | 30 EXPECT_EQ(base::Value::Type::BOOLEAN, value->GetType()); |
| 31 bool actual_bool_value = true; | 31 bool actual_bool_value = true; |
| 32 EXPECT_TRUE(value->GetAsBoolean(&actual_bool_value)); | 32 EXPECT_TRUE(value->GetAsBoolean(&actual_bool_value)); |
| 33 EXPECT_FALSE(actual_bool_value); | 33 EXPECT_FALSE(actual_bool_value); |
| 34 | 34 |
| 35 // Change the command line. | 35 // Change the command line. |
| 36 base::CommandLine cmd_line(base::CommandLine::NO_PROGRAM); | 36 base::CommandLine cmd_line(base::CommandLine::NO_PROGRAM); |
| 37 cmd_line.AppendSwitch(switches::kEnableCloudPrintProxy); | 37 cmd_line.AppendSwitch(switches::kEnableCloudPrintProxy); |
| 38 | 38 |
| 39 // Call UpdateCommandLinePrefStore and check to see if the value has changed. | 39 // Call UpdateCommandLinePrefStore and check to see if the value has changed. |
| 40 prefs.UpdateCommandLinePrefStore(new ChromeCommandLinePrefStore(&cmd_line)); | 40 prefs.UpdateCommandLinePrefStore(new ChromeCommandLinePrefStore(&cmd_line)); |
| 41 pref = prefs.FindPreference(prefs::kCloudPrintProxyEnabled); | 41 pref = prefs.FindPreference(prefs::kCloudPrintProxyEnabled); |
| 42 ASSERT_TRUE(pref); | 42 ASSERT_TRUE(pref); |
| 43 value = pref->GetValue(); | 43 value = pref->GetValue(); |
| 44 ASSERT_TRUE(value); | 44 ASSERT_TRUE(value); |
| 45 EXPECT_EQ(base::Value::TYPE_BOOLEAN, value->GetType()); | 45 EXPECT_EQ(base::Value::Type::BOOLEAN, value->GetType()); |
| 46 actual_bool_value = false; | 46 actual_bool_value = false; |
| 47 EXPECT_TRUE(value->GetAsBoolean(&actual_bool_value)); | 47 EXPECT_TRUE(value->GetAsBoolean(&actual_bool_value)); |
| 48 EXPECT_TRUE(actual_bool_value); | 48 EXPECT_TRUE(actual_bool_value); |
| 49 } | 49 } |
| 50 | 50 |
| 51 class ChromePrefServiceWebKitPrefs : public ChromeRenderViewHostTestHarness { | 51 class ChromePrefServiceWebKitPrefs : public ChromeRenderViewHostTestHarness { |
| 52 protected: | 52 protected: |
| 53 void SetUp() override { | 53 void SetUp() override { |
| 54 ChromeRenderViewHostTestHarness::SetUp(); | 54 ChromeRenderViewHostTestHarness::SetUp(); |
| 55 | 55 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 86 const char kDefaultFont[] = "Times"; | 86 const char kDefaultFont[] = "Times"; |
| 87 #elif defined(OS_CHROMEOS) | 87 #elif defined(OS_CHROMEOS) |
| 88 const char kDefaultFont[] = "Tinos"; | 88 const char kDefaultFont[] = "Tinos"; |
| 89 #else | 89 #else |
| 90 const char kDefaultFont[] = "Times New Roman"; | 90 const char kDefaultFont[] = "Times New Roman"; |
| 91 #endif | 91 #endif |
| 92 EXPECT_EQ(base::ASCIIToUTF16(kDefaultFont), | 92 EXPECT_EQ(base::ASCIIToUTF16(kDefaultFont), |
| 93 webkit_prefs.standard_font_family_map[prefs::kWebKitCommonScript]); | 93 webkit_prefs.standard_font_family_map[prefs::kWebKitCommonScript]); |
| 94 EXPECT_TRUE(webkit_prefs.javascript_enabled); | 94 EXPECT_TRUE(webkit_prefs.javascript_enabled); |
| 95 } | 95 } |
| OLD | NEW |