Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(320)

Side by Side Diff: chrome/browser/extensions/extension_service_test_base.h

Issue 1086733002: Ensure tests have an active task runner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/at_exit.h" 8 #include "base/at_exit.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 content::BrowserContext* browser_context(); 96 content::BrowserContext* browser_context();
97 Profile* profile(); 97 Profile* profile();
98 ExtensionService* service() { return service_; } 98 ExtensionService* service() { return service_; }
99 ExtensionRegistry* registry() { return registry_; } 99 ExtensionRegistry* registry() { return registry_; }
100 const base::FilePath& extensions_install_dir() const { 100 const base::FilePath& extensions_install_dir() const {
101 return extensions_install_dir_; 101 return extensions_install_dir_;
102 } 102 }
103 const base::FilePath& data_dir() const { return data_dir_; } 103 const base::FilePath& data_dir() const { return data_dir_; }
104 const base::ScopedTempDir& temp_dir() const { return temp_dir_; } 104 const base::ScopedTempDir& temp_dir() const { return temp_dir_; }
105 105
106 private:
107 // Destroying at_exit_manager_ will delete all LazyInstances, so it must come
108 // after thread_bundle_ in the destruction order.
109 base::ShadowingAtExitManager at_exit_manager_;
110 scoped_ptr<content::TestBrowserThreadBundle> thread_bundle_;
111
112 protected:
106 // It's unfortunate that these are exposed to subclasses (rather than used 113 // It's unfortunate that these are exposed to subclasses (rather than used
107 // through the accessor methods above), but too many tests already use them 114 // through the accessor methods above), but too many tests already use them
108 // directly. 115 // directly.
109 116
110 // The associated testing profile. 117 // The associated testing profile.
111 scoped_ptr<TestingProfile> profile_; 118 scoped_ptr<TestingProfile> profile_;
112 119
113 // The ExtensionService, whose lifetime is managed by |profile|'s 120 // The ExtensionService, whose lifetime is managed by |profile|'s
114 // ExtensionSystem. 121 // ExtensionSystem.
115 ExtensionService* service_; 122 ExtensionService* service_;
116 ScopedTestingLocalState testing_local_state_; 123 ScopedTestingLocalState testing_local_state_;
117 124
118 private: 125 private:
119 void CreateExtensionService(const ExtensionServiceInitParams& params); 126 void CreateExtensionService(const ExtensionServiceInitParams& params);
120 127
121 // Destroy temp_dir_ after thread_bundle_ so clean-up tasks can still use the 128 // Destroy temp_dir_ after thread_bundle_ so clean-up tasks can still use the
122 // directory. 129 // directory.
123 base::ScopedTempDir temp_dir_; 130 base::ScopedTempDir temp_dir_;
124 131
125 // Destroying at_exit_manager_ will delete all LazyInstances, so it must come
126 // after thread_bundle_ in the destruction order.
127 base::ShadowingAtExitManager at_exit_manager_;
128 scoped_ptr<content::TestBrowserThreadBundle> thread_bundle_;
129
130 // Whether or not the thread bundle was reset in the test. 132 // Whether or not the thread bundle was reset in the test.
131 bool did_reset_thread_bundle_; 133 bool did_reset_thread_bundle_;
132 134
133 // The directory into which extensions are installed. 135 // The directory into which extensions are installed.
134 base::FilePath extensions_install_dir_; 136 base::FilePath extensions_install_dir_;
135 137
136 // chrome/test/data/extensions/ 138 // chrome/test/data/extensions/
137 base::FilePath data_dir_; 139 base::FilePath data_dir_;
138 140
139 content::InProcessUtilityThreadHelper in_process_utility_thread_helper_; 141 content::InProcessUtilityThreadHelper in_process_utility_thread_helper_;
140 142
141 // The associated ExtensionRegistry, for convenience. 143 // The associated ExtensionRegistry, for convenience.
142 extensions::ExtensionRegistry* registry_; 144 extensions::ExtensionRegistry* registry_;
143 145
144 #if defined OS_CHROMEOS 146 #if defined OS_CHROMEOS
145 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; 147 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
146 chromeos::ScopedTestCrosSettings test_cros_settings_; 148 chromeos::ScopedTestCrosSettings test_cros_settings_;
147 chromeos::ScopedTestUserManager test_user_manager_; 149 chromeos::ScopedTestUserManager test_user_manager_;
148 #endif 150 #endif
149 }; 151 };
150 152
151 } // namespace extensions 153 } // namespace extensions
152 154
153 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_TEST_BASE_H_ 155 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_TEST_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698