OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/extensions/extension_host.h" | 9 #include "chrome/browser/extensions/extension_host.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/common/chrome_notification_types.h" |
13 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
14 #include "chrome/test/in_process_browser_test.h" | 15 #include "chrome/test/in_process_browser_test.h" |
15 #include "chrome/test/ui_test_utils.h" | 16 #include "chrome/test/ui_test_utils.h" |
16 #include "content/browser/debugger/devtools_client_host.h" | 17 #include "content/browser/debugger/devtools_client_host.h" |
17 #include "content/browser/debugger/devtools_manager.h" | 18 #include "content/browser/debugger/devtools_manager.h" |
18 #include "content/browser/debugger/devtools_window.h" | 19 #include "content/browser/debugger/devtools_window.h" |
19 #include "content/browser/renderer_host/render_view_host.h" | 20 #include "content/browser/renderer_host/render_view_host.h" |
20 #include "content/browser/tab_contents/tab_contents.h" | 21 #include "content/browser/tab_contents/tab_contents.h" |
21 #include "content/common/notification_registrar.h" | 22 #include "content/common/notification_registrar.h" |
22 #include "content/common/notification_service.h" | 23 #include "content/common/notification_service.h" |
23 #include "net/test/test_server.h" | 24 #include "net/test/test_server.h" |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
27 // Used to block until a dev tools client window's browser is closed. | 28 // Used to block until a dev tools client window's browser is closed. |
28 class BrowserClosedObserver : public NotificationObserver { | 29 class BrowserClosedObserver : public NotificationObserver { |
29 public: | 30 public: |
30 explicit BrowserClosedObserver(Browser* browser) { | 31 explicit BrowserClosedObserver(Browser* browser) { |
31 registrar_.Add(this, NotificationType::BROWSER_CLOSED, | 32 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSED, |
32 Source<Browser>(browser)); | 33 Source<Browser>(browser)); |
33 ui_test_utils::RunMessageLoop(); | 34 ui_test_utils::RunMessageLoop(); |
34 } | 35 } |
35 | 36 |
36 virtual void Observe(NotificationType type, | 37 virtual void Observe(int type, |
37 const NotificationSource& source, | 38 const NotificationSource& source, |
38 const NotificationDetails& details) { | 39 const NotificationDetails& details) { |
39 MessageLoopForUI::current()->Quit(); | 40 MessageLoopForUI::current()->Quit(); |
40 } | 41 } |
41 | 42 |
42 private: | 43 private: |
43 NotificationRegistrar registrar_; | 44 NotificationRegistrar registrar_; |
44 DISALLOW_COPY_AND_ASSIGN(BrowserClosedObserver); | 45 DISALLOW_COPY_AND_ASSIGN(BrowserClosedObserver); |
45 }; | 46 }; |
46 | 47 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 FilePath path = test_extensions_dir_.AppendASCII(extension_name); | 176 FilePath path = test_extensions_dir_.AppendASCII(extension_name); |
176 ASSERT_TRUE(LoadExtensionFromPath(path)) << "Failed to load extension."; | 177 ASSERT_TRUE(LoadExtensionFromPath(path)) << "Failed to load extension."; |
177 } | 178 } |
178 | 179 |
179 private: | 180 private: |
180 bool LoadExtensionFromPath(const FilePath& path) { | 181 bool LoadExtensionFromPath(const FilePath& path) { |
181 ExtensionService* service = browser()->profile()->GetExtensionService(); | 182 ExtensionService* service = browser()->profile()->GetExtensionService(); |
182 size_t num_before = service->extensions()->size(); | 183 size_t num_before = service->extensions()->size(); |
183 { | 184 { |
184 NotificationRegistrar registrar; | 185 NotificationRegistrar registrar; |
185 registrar.Add(this, NotificationType::EXTENSION_LOADED, | 186 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
186 NotificationService::AllSources()); | 187 NotificationService::AllSources()); |
187 CancelableQuitTask* delayed_quit = | 188 CancelableQuitTask* delayed_quit = |
188 new CancelableQuitTask("Extension load timed out."); | 189 new CancelableQuitTask("Extension load timed out."); |
189 MessageLoop::current()->PostDelayedTask(FROM_HERE, delayed_quit, | 190 MessageLoop::current()->PostDelayedTask(FROM_HERE, delayed_quit, |
190 4*1000); | 191 4*1000); |
191 service->LoadExtension(path); | 192 service->LoadExtension(path); |
192 ui_test_utils::RunMessageLoop(); | 193 ui_test_utils::RunMessageLoop(); |
193 delayed_quit->cancel(); | 194 delayed_quit->cancel(); |
194 } | 195 } |
195 size_t num_after = service->extensions()->size(); | 196 size_t num_after = service->extensions()->size(); |
196 if (num_after != (num_before + 1)) | 197 if (num_after != (num_before + 1)) |
197 return false; | 198 return false; |
198 | 199 |
199 return WaitForExtensionHostsToLoad(); | 200 return WaitForExtensionHostsToLoad(); |
200 } | 201 } |
201 | 202 |
202 bool WaitForExtensionHostsToLoad() { | 203 bool WaitForExtensionHostsToLoad() { |
203 // Wait for all the extension hosts that exist to finish loading. | 204 // Wait for all the extension hosts that exist to finish loading. |
204 // NOTE: This assumes that the extension host list is not changing while | 205 // NOTE: This assumes that the extension host list is not changing while |
205 // this method is running. | 206 // this method is running. |
206 | 207 |
207 NotificationRegistrar registrar; | 208 NotificationRegistrar registrar; |
208 registrar.Add(this, NotificationType::EXTENSION_HOST_DID_STOP_LOADING, | 209 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, |
209 NotificationService::AllSources()); | 210 NotificationService::AllSources()); |
210 CancelableQuitTask* delayed_quit = | 211 CancelableQuitTask* delayed_quit = |
211 new CancelableQuitTask("Extension host load timed out."); | 212 new CancelableQuitTask("Extension host load timed out."); |
212 MessageLoop::current()->PostDelayedTask(FROM_HERE, delayed_quit, | 213 MessageLoop::current()->PostDelayedTask(FROM_HERE, delayed_quit, |
213 4*1000); | 214 4*1000); |
214 | 215 |
215 ExtensionProcessManager* manager = | 216 ExtensionProcessManager* manager = |
216 browser()->profile()->GetExtensionProcessManager(); | 217 browser()->profile()->GetExtensionProcessManager(); |
217 for (ExtensionProcessManager::const_iterator iter = manager->begin(); | 218 for (ExtensionProcessManager::const_iterator iter = manager->begin(); |
218 iter != manager->end();) { | 219 iter != manager->end();) { |
219 if ((*iter)->did_stop_loading()) | 220 if ((*iter)->did_stop_loading()) |
220 ++iter; | 221 ++iter; |
221 else | 222 else |
222 ui_test_utils::RunMessageLoop(); | 223 ui_test_utils::RunMessageLoop(); |
223 } | 224 } |
224 | 225 |
225 delayed_quit->cancel(); | 226 delayed_quit->cancel(); |
226 return true; | 227 return true; |
227 } | 228 } |
228 | 229 |
229 void Observe(NotificationType type, | 230 void Observe(int type, |
230 const NotificationSource& source, | 231 const NotificationSource& source, |
231 const NotificationDetails& details) { | 232 const NotificationDetails& details) { |
232 switch (type.value) { | 233 switch (type) { |
233 case NotificationType::EXTENSION_LOADED: | 234 case chrome::NOTIFICATION_EXTENSION_LOADED: |
234 case NotificationType::EXTENSION_HOST_DID_STOP_LOADING: | 235 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: |
235 MessageLoopForUI::current()->Quit(); | 236 MessageLoopForUI::current()->Quit(); |
236 break; | 237 break; |
237 default: | 238 default: |
238 NOTREACHED(); | 239 NOTREACHED(); |
239 break; | 240 break; |
240 } | 241 } |
241 } | 242 } |
242 | 243 |
243 FilePath test_extensions_dir_; | 244 FilePath test_extensions_dir_; |
244 }; | 245 }; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 client_contents_->render_view_host(), | 316 client_contents_->render_view_host(), |
316 L"", | 317 L"", |
317 L"window.domAutomationController.send(" | 318 L"window.domAutomationController.send(" |
318 L"'' + (window.uiTests && (typeof uiTests.runTest)));", | 319 L"'' + (window.uiTests && (typeof uiTests.runTest)));", |
319 &result)); | 320 &result)); |
320 ASSERT_EQ("function", result) << "DevTools front-end is broken."; | 321 ASSERT_EQ("function", result) << "DevTools front-end is broken."; |
321 CloseDevToolsWindow(); | 322 CloseDevToolsWindow(); |
322 } | 323 } |
323 | 324 |
324 } // namespace | 325 } // namespace |
OLD | NEW |