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