| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #endif | 28 #endif |
| 29 | 29 |
| 30 class ExtensionService; | 30 class ExtensionService; |
| 31 class Profile; | 31 class Profile; |
| 32 class TestingProfile; | 32 class TestingProfile; |
| 33 | 33 |
| 34 namespace content { | 34 namespace content { |
| 35 class BrowserContext; | 35 class BrowserContext; |
| 36 } | 36 } |
| 37 | 37 |
| 38 namespace sync_preferences { |
| 39 class TestingPrefServiceSyncable; |
| 40 } |
| 41 |
| 38 namespace extensions { | 42 namespace extensions { |
| 39 | 43 |
| 40 class ExtensionRegistry; | 44 class ExtensionRegistry; |
| 41 | 45 |
| 42 // A unittest infrastructure which creates an ExtensionService. Whenever | 46 // A unittest infrastructure which creates an ExtensionService. Whenever |
| 43 // possible, use this instead of creating a browsertest. | 47 // possible, use this instead of creating a browsertest. |
| 44 // Note: Before adding methods to this class, please, please, please think about | 48 // Note: Before adding methods to this class, please, please, please think about |
| 45 // whether they should go here or in a more specific subclass. Lots of things | 49 // whether they should go here or in a more specific subclass. Lots of things |
| 46 // need an ExtensionService, but they don't all need to know how you want yours | 50 // need an ExtensionService, but they don't all need to know how you want yours |
| 47 // to be initialized. | 51 // to be initialized. |
| 48 class ExtensionServiceTestBase : public testing::Test { | 52 class ExtensionServiceTestBase : public testing::Test { |
| 49 public: | 53 public: |
| 50 struct ExtensionServiceInitParams { | 54 struct ExtensionServiceInitParams { |
| 51 base::FilePath profile_path; | 55 base::FilePath profile_path; |
| 52 base::FilePath pref_file; | 56 base::FilePath pref_file; |
| 53 base::FilePath extensions_install_dir; | 57 base::FilePath extensions_install_dir; |
| 54 bool autoupdate_enabled; // defaults to false. | 58 bool autoupdate_enabled; // defaults to false. |
| 55 bool is_first_run; // defaults to true. | 59 bool is_first_run; // defaults to true. |
| 56 bool profile_is_supervised; // defaults to false. | 60 bool profile_is_supervised; // defaults to false. |
| 57 | 61 |
| 58 // Though you could use this constructor, you probably want to use | 62 // Though you could use this constructor, you probably want to use |
| 59 // CreateDefaultInitParams(), and then make a change or two. | 63 // CreateDefaultInitParams(), and then make a change or two. |
| 60 ExtensionServiceInitParams(); | 64 ExtensionServiceInitParams(); |
| 61 ExtensionServiceInitParams(const ExtensionServiceInitParams& other); | 65 ExtensionServiceInitParams(const ExtensionServiceInitParams& other); |
| 62 }; | 66 }; |
| 63 | 67 |
| 64 // Public because parameterized test cases need it to be, or else the compiler | 68 // Public because parameterized test cases need it to be, or else the compiler |
| 65 // barfs. | 69 // barfs. |
| 66 static void SetUpTestCase(); // faux-verride (static override). | 70 static void SetUpTestCase(); // faux-verride (static override). |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 void ValidateStringPref(const std::string& extension_id, | 114 void ValidateStringPref(const std::string& extension_id, |
| 111 const std::string& pref_path, | 115 const std::string& pref_path, |
| 112 const std::string& expected_val); | 116 const std::string& expected_val); |
| 113 | 117 |
| 114 // TODO(rdevlin.cronin): Pull out more methods from ExtensionServiceTest that | 118 // TODO(rdevlin.cronin): Pull out more methods from ExtensionServiceTest that |
| 115 // are commonly used and/or reimplemented. For instance, methods to install | 119 // are commonly used and/or reimplemented. For instance, methods to install |
| 116 // extensions from various locations, etc. | 120 // extensions from various locations, etc. |
| 117 | 121 |
| 118 content::BrowserContext* browser_context(); | 122 content::BrowserContext* browser_context(); |
| 119 Profile* profile(); | 123 Profile* profile(); |
| 124 sync_preferences::TestingPrefServiceSyncable* testing_pref_service(); |
| 120 ExtensionService* service() { return service_; } | 125 ExtensionService* service() { return service_; } |
| 121 ExtensionRegistry* registry() { return registry_; } | 126 ExtensionRegistry* registry() { return registry_; } |
| 122 const base::FilePath& extensions_install_dir() const { | 127 const base::FilePath& extensions_install_dir() const { |
| 123 return extensions_install_dir_; | 128 return extensions_install_dir_; |
| 124 } | 129 } |
| 125 const base::FilePath& data_dir() const { return data_dir_; } | 130 const base::FilePath& data_dir() const { return data_dir_; } |
| 126 const base::ScopedTempDir& temp_dir() const { return temp_dir_; } | 131 const base::ScopedTempDir& temp_dir() const { return temp_dir_; } |
| 127 | 132 |
| 128 private: | 133 private: |
| 129 // Must be declared before anything that may make use of the | 134 // Must be declared before anything that may make use of the |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 chromeos::ScopedTestCrosSettings test_cros_settings_; | 179 chromeos::ScopedTestCrosSettings test_cros_settings_; |
| 175 chromeos::ScopedTestUserManager test_user_manager_; | 180 chromeos::ScopedTestUserManager test_user_manager_; |
| 176 #endif | 181 #endif |
| 177 | 182 |
| 178 DISALLOW_COPY_AND_ASSIGN(ExtensionServiceTestBase); | 183 DISALLOW_COPY_AND_ASSIGN(ExtensionServiceTestBase); |
| 179 }; | 184 }; |
| 180 | 185 |
| 181 } // namespace extensions | 186 } // namespace extensions |
| 182 | 187 |
| 183 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_TEST_BASE_H_ | 188 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_TEST_BASE_H_ |
| OLD | NEW |