OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/shell/browser/shell_prefs.h" | 5 #include "extensions/shell/browser/shell_prefs.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "components/prefs/pref_service.h" | 10 #include "components/prefs/pref_service.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 public: | 38 public: |
39 ShellPrefsTest() {} | 39 ShellPrefsTest() {} |
40 ~ShellPrefsTest() override {} | 40 ~ShellPrefsTest() override {} |
41 | 41 |
42 protected: | 42 protected: |
43 content::TestBrowserThreadBundle thread_bundle_; | 43 content::TestBrowserThreadBundle thread_bundle_; |
44 PrefsTestBrowserContext browser_context_; | 44 PrefsTestBrowserContext browser_context_; |
45 }; | 45 }; |
46 | 46 |
47 TEST_F(ShellPrefsTest, CreateLocalState) { | 47 TEST_F(ShellPrefsTest, CreateLocalState) { |
48 scoped_ptr<PrefService> local_state = | 48 std::unique_ptr<PrefService> local_state = |
49 shell_prefs::CreateLocalState(browser_context_.GetPath()); | 49 shell_prefs::CreateLocalState(browser_context_.GetPath()); |
50 ASSERT_TRUE(local_state); | 50 ASSERT_TRUE(local_state); |
51 | 51 |
52 #if defined(OS_CHROMEOS) | 52 #if defined(OS_CHROMEOS) |
53 // Verify prefs were registered. | 53 // Verify prefs were registered. |
54 EXPECT_TRUE(local_state->FindPreference("hardware.audio_output_enabled")); | 54 EXPECT_TRUE(local_state->FindPreference("hardware.audio_output_enabled")); |
55 | 55 |
56 // Verify the test values were read. | 56 // Verify the test values were read. |
57 EXPECT_FALSE(local_state->GetBoolean("hardware.audio_output_enabled")); | 57 EXPECT_FALSE(local_state->GetBoolean("hardware.audio_output_enabled")); |
58 #endif | 58 #endif |
59 } | 59 } |
60 | 60 |
61 TEST_F(ShellPrefsTest, CreateUserPrefService) { | 61 TEST_F(ShellPrefsTest, CreateUserPrefService) { |
62 // Create the pref service. This loads the test pref file. | 62 // Create the pref service. This loads the test pref file. |
63 scoped_ptr<PrefService> service = | 63 std::unique_ptr<PrefService> service = |
64 shell_prefs::CreateUserPrefService(&browser_context_); | 64 shell_prefs::CreateUserPrefService(&browser_context_); |
65 | 65 |
66 // Some basic extension preferences are registered. | 66 // Some basic extension preferences are registered. |
67 EXPECT_TRUE(service->FindPreference("extensions.settings")); | 67 EXPECT_TRUE(service->FindPreference("extensions.settings")); |
68 EXPECT_TRUE(service->FindPreference("extensions.toolbarsize")); | 68 EXPECT_TRUE(service->FindPreference("extensions.toolbarsize")); |
69 EXPECT_FALSE(service->FindPreference("should.not.exist")); | 69 EXPECT_FALSE(service->FindPreference("should.not.exist")); |
70 | 70 |
71 // User prefs from the file have been read correctly. | 71 // User prefs from the file have been read correctly. |
72 EXPECT_EQ("1.2.3.4", service->GetString("extensions.last_chrome_version")); | 72 EXPECT_EQ("1.2.3.4", service->GetString("extensions.last_chrome_version")); |
73 EXPECT_EQ(123, service->GetInteger("extensions.toolbarsize")); | 73 EXPECT_EQ(123, service->GetInteger("extensions.toolbarsize")); |
74 | 74 |
75 // The user prefs system has been initialized. | 75 // The user prefs system has been initialized. |
76 EXPECT_EQ(service.get(), user_prefs::UserPrefs::Get(&browser_context_)); | 76 EXPECT_EQ(service.get(), user_prefs::UserPrefs::Get(&browser_context_)); |
77 } | 77 } |
78 | 78 |
79 } // namespace | 79 } // namespace |
80 } // namespace extensions | 80 } // namespace extensions |
OLD | NEW |