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

Side by Side Diff: chrome/browser/extensions/test_extension_system.cc

Issue 10795052: Improve unit testing of socket API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed build break on release builds. Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/test_extension_system.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/extensions/test_extension_system.h" 5 #include "chrome/browser/extensions/test_extension_system.h"
6 6
7 #include "chrome/browser/extensions/api/alarms/alarm_manager.h" 7 #include "chrome/browser/extensions/api/alarms/alarm_manager.h"
8 #include "chrome/browser/extensions/event_router.h" 8 #include "chrome/browser/extensions/event_router.h"
9 #include "chrome/browser/extensions/extension_devtools_manager.h" 9 #include "chrome/browser/extensions/extension_devtools_manager.h"
10 #include "chrome/browser/extensions/extension_info_map.h" 10 #include "chrome/browser/extensions/extension_info_map.h"
11 #include "chrome/browser/extensions/extension_pref_value_map.h" 11 #include "chrome/browser/extensions/extension_pref_value_map.h"
12 #include "chrome/browser/extensions/extension_pref_value_map_factory.h" 12 #include "chrome/browser/extensions/extension_pref_value_map_factory.h"
13 #include "chrome/browser/extensions/extension_process_manager.h" 13 #include "chrome/browser/extensions/extension_process_manager.h"
14 #include "chrome/browser/extensions/extension_service.h" 14 #include "chrome/browser/extensions/extension_service.h"
15 #include "chrome/browser/extensions/extension_system.h" 15 #include "chrome/browser/extensions/extension_system.h"
16 #include "chrome/browser/extensions/message_service.h" 16 #include "chrome/browser/extensions/message_service.h"
17 #include "chrome/browser/extensions/state_store.h" 17 #include "chrome/browser/extensions/state_store.h"
18 #include "chrome/browser/extensions/user_script_master.h" 18 #include "chrome/browser/extensions/user_script_master.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/value_store/testing_value_store.h" 20 #include "chrome/browser/value_store/testing_value_store.h"
21 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
22 #include "content/public/browser/browser_thread.h"
23
24 using content::BrowserThread;
22 25
23 namespace extensions { 26 namespace extensions {
24 27
25 TestExtensionSystem::TestExtensionSystem(Profile* profile) 28 TestExtensionSystem::TestExtensionSystem(Profile* profile)
26 : profile_(profile), 29 : profile_(profile),
27 info_map_(new ExtensionInfoMap()) { 30 info_map_(new ExtensionInfoMap()) {
28 } 31 }
29 32
30 TestExtensionSystem::~TestExtensionSystem() { 33 TestExtensionSystem::~TestExtensionSystem() {
31 } 34 }
32 35
33 void TestExtensionSystem::Shutdown() { 36 void TestExtensionSystem::Shutdown() {
34 extension_process_manager_.reset(); 37 extension_process_manager_.reset();
35 } 38 }
36 39
37 void TestExtensionSystem::CreateExtensionProcessManager() { 40 void TestExtensionSystem::CreateExtensionProcessManager() {
38 extension_process_manager_.reset(ExtensionProcessManager::Create(profile_)); 41 extension_process_manager_.reset(ExtensionProcessManager::Create(profile_));
39 } 42 }
40 43
41 void TestExtensionSystem::CreateAlarmManager( 44 void TestExtensionSystem::CreateAlarmManager(
42 AlarmManager::TimeProvider now) { 45 AlarmManager::TimeProvider now) {
43 alarm_manager_.reset(new AlarmManager(profile_, now)); 46 alarm_manager_.reset(new AlarmManager(profile_, now));
44 } 47 }
45 48
49 void TestExtensionSystem::CreateSocketManager() {
50 // Note that we're intentionally creating the socket manager on the wrong
51 // thread (not the IO thread). This is because we don't want to presume or
52 // require that there be an IO thread in a lightweight test context. If we do
53 // need thread-specific behavior someday, we'll probably need something like
54 // CreateSocketManagerOnThreadForTesting(thread_id). But not today.
55 BrowserThread::ID id;
56 CHECK(BrowserThread::GetCurrentThreadIdentifier(&id));
57 socket_manager_.reset(new ApiResourceManager<Socket>(id));
58 }
59
46 ExtensionService* TestExtensionSystem::CreateExtensionService( 60 ExtensionService* TestExtensionSystem::CreateExtensionService(
47 const CommandLine* command_line, 61 const CommandLine* command_line,
48 const FilePath& install_directory, 62 const FilePath& install_directory,
49 bool autoupdate_enabled) { 63 bool autoupdate_enabled) {
50 bool extensions_disabled = 64 bool extensions_disabled =
51 command_line && command_line->HasSwitch(switches::kDisableExtensions); 65 command_line && command_line->HasSwitch(switches::kDisableExtensions);
52 66
53 // Note that the GetPrefs() creates a TestingPrefService, therefore 67 // Note that the GetPrefs() creates a TestingPrefService, therefore
54 // the extension controlled pref values set in extension_prefs_ 68 // the extension controlled pref values set in extension_prefs_
55 // are not reflected in the pref service. One would need to 69 // are not reflected in the pref service. One would need to
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 RulesRegistryService* TestExtensionSystem::rules_registry_service() { 145 RulesRegistryService* TestExtensionSystem::rules_registry_service() {
132 return NULL; 146 return NULL;
133 } 147 }
134 148
135 ApiResourceManager<SerialConnection>* 149 ApiResourceManager<SerialConnection>*
136 TestExtensionSystem::serial_connection_manager() { 150 TestExtensionSystem::serial_connection_manager() {
137 return NULL; 151 return NULL;
138 } 152 }
139 153
140 ApiResourceManager<Socket>*TestExtensionSystem::socket_manager() { 154 ApiResourceManager<Socket>*TestExtensionSystem::socket_manager() {
141 return NULL; 155 return socket_manager_.get();
142 } 156 }
143 157
144 ApiResourceManager<UsbDeviceResource>* 158 ApiResourceManager<UsbDeviceResource>*
145 TestExtensionSystem::usb_device_resource_manager() { 159 TestExtensionSystem::usb_device_resource_manager() {
146 return NULL; 160 return NULL;
147 } 161 }
148 162
149 // static 163 // static
150 ProfileKeyedService* TestExtensionSystem::Build(Profile* profile) { 164 ProfileKeyedService* TestExtensionSystem::Build(Profile* profile) {
151 return new TestExtensionSystem(profile); 165 return new TestExtensionSystem(profile);
152 } 166 }
153 167
154 } // namespace extensions 168 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/test_extension_system.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698