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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_TEST_BASE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_TEST_BASE_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_TEST_BASE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_TEST_BASE_H_ |
7 | 7 |
| 8 #include <string> |
| 9 |
8 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
9 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
10 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 13 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
12 #include "chrome/test/base/scoped_testing_local_state.h" | 15 #include "chrome/test/base/scoped_testing_local_state.h" |
13 #include "content/public/test/test_browser_thread_bundle.h" | 16 #include "content/public/test/test_browser_thread_bundle.h" |
14 #include "content/public/test/test_utils.h" | 17 #include "content/public/test/test_utils.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
16 | 19 |
17 #if defined(OS_CHROMEOS) | 20 #if defined(OS_CHROMEOS) |
18 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" | 21 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" |
19 #include "chrome/browser/chromeos/settings/cros_settings.h" | 22 #include "chrome/browser/chromeos/settings/cros_settings.h" |
20 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 23 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 85 |
83 // Initialize an ExtensionService with a few already-installed extensions. | 86 // Initialize an ExtensionService with a few already-installed extensions. |
84 void InitializeGoodInstalledExtensionService(); | 87 void InitializeGoodInstalledExtensionService(); |
85 | 88 |
86 // Initialize an ExtensionService with autoupdate enabled. | 89 // Initialize an ExtensionService with autoupdate enabled. |
87 void InitializeExtensionServiceWithUpdater(); | 90 void InitializeExtensionServiceWithUpdater(); |
88 | 91 |
89 // Resets the browser thread bundle to one with |options|. | 92 // Resets the browser thread bundle to one with |options|. |
90 void ResetThreadBundle(int options); | 93 void ResetThreadBundle(int options); |
91 | 94 |
| 95 // Helpers to check the existence and values of extension prefs. |
| 96 size_t GetPrefKeyCount(); |
| 97 void ValidatePrefKeyCount(size_t count); |
| 98 testing::AssertionResult ValidateBooleanPref( |
| 99 const std::string& extension_id, |
| 100 const std::string& pref_path, |
| 101 bool expected_val); |
| 102 void ValidateIntegerPref(const std::string& extension_id, |
| 103 const std::string& pref_path, |
| 104 int expected_val); |
| 105 void ValidateStringPref(const std::string& extension_id, |
| 106 const std::string& pref_path, |
| 107 const std::string& expected_val); |
| 108 |
92 // TODO(rdevlin.cronin): Pull out more methods from ExtensionServiceTest that | 109 // TODO(rdevlin.cronin): Pull out more methods from ExtensionServiceTest that |
93 // are commonly used and/or reimplemented. For instance, methods to install | 110 // are commonly used and/or reimplemented. For instance, methods to install |
94 // extensions from various locations, etc. | 111 // extensions from various locations, etc. |
95 | 112 |
96 content::BrowserContext* browser_context(); | 113 content::BrowserContext* browser_context(); |
97 Profile* profile(); | 114 Profile* profile(); |
98 ExtensionService* service() { return service_; } | 115 ExtensionService* service() { return service_; } |
99 ExtensionRegistry* registry() { return registry_; } | 116 ExtensionRegistry* registry() { return registry_; } |
100 const base::FilePath& extensions_install_dir() const { | 117 const base::FilePath& extensions_install_dir() const { |
101 return extensions_install_dir_; | 118 return extensions_install_dir_; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 content::InProcessUtilityThreadHelper in_process_utility_thread_helper_; | 158 content::InProcessUtilityThreadHelper in_process_utility_thread_helper_; |
142 | 159 |
143 // The associated ExtensionRegistry, for convenience. | 160 // The associated ExtensionRegistry, for convenience. |
144 extensions::ExtensionRegistry* registry_; | 161 extensions::ExtensionRegistry* registry_; |
145 | 162 |
146 #if defined OS_CHROMEOS | 163 #if defined OS_CHROMEOS |
147 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 164 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
148 chromeos::ScopedTestCrosSettings test_cros_settings_; | 165 chromeos::ScopedTestCrosSettings test_cros_settings_; |
149 chromeos::ScopedTestUserManager test_user_manager_; | 166 chromeos::ScopedTestUserManager test_user_manager_; |
150 #endif | 167 #endif |
| 168 |
| 169 DISALLOW_COPY_AND_ASSIGN(ExtensionServiceTestBase); |
151 }; | 170 }; |
152 | 171 |
153 } // namespace extensions | 172 } // namespace extensions |
154 | 173 |
155 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_TEST_BASE_H_ | 174 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_TEST_BASE_H_ |
OLD | NEW |