| OLD | NEW |
| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/cancelable_callback.h" | 6 #include "base/cancelable_callback.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 12 #include "base/test/test_timeouts.h" | 12 #include "base/test/test_timeouts.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "chrome/browser/devtools/devtools_window.h" | 14 #include "chrome/browser/devtools/devtools_window.h" |
| 15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 16 #include "chrome/browser/extensions/extension_system.h" | 16 #include "chrome/browser/extensions/extension_system.h" |
| 17 #include "chrome/browser/extensions/unpacked_installer.h" | 17 #include "chrome/browser/extensions/unpacked_installer.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/browser_commands.h" | 20 #include "chrome/browser/ui/browser_commands.h" |
| 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 22 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
| 23 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
| 24 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
| 25 #include "chrome/common/extensions/api/content_scripts/content_scripts_handler.h
" |
| 26 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 27 #include "chrome/common/extensions/manifest_handler.h" |
| 25 #include "chrome/test/base/in_process_browser_test.h" | 28 #include "chrome/test/base/in_process_browser_test.h" |
| 26 #include "chrome/test/base/ui_test_utils.h" | 29 #include "chrome/test/base/ui_test_utils.h" |
| 27 #include "content/public/browser/child_process_data.h" | 30 #include "content/public/browser/child_process_data.h" |
| 28 #include "content/public/browser/content_browser_client.h" | 31 #include "content/public/browser/content_browser_client.h" |
| 29 #include "content/public/browser/devtools_agent_host.h" | 32 #include "content/public/browser/devtools_agent_host.h" |
| 30 #include "content/public/browser/devtools_client_host.h" | 33 #include "content/public/browser/devtools_client_host.h" |
| 31 #include "content/public/browser/devtools_manager.h" | 34 #include "content/public/browser/devtools_manager.h" |
| 32 #include "content/public/browser/notification_registrar.h" | 35 #include "content/public/browser/notification_registrar.h" |
| 33 #include "content/public/browser/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
| 34 #include "content/public/browser/render_view_host.h" | 37 #include "content/public/browser/render_view_host.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 test_extensions_dir_ = test_extensions_dir_.AppendASCII("extensions"); | 183 test_extensions_dir_ = test_extensions_dir_.AppendASCII("extensions"); |
| 181 } | 184 } |
| 182 | 185 |
| 183 protected: | 186 protected: |
| 184 // Load an extension from test\data\devtools\extensions\<extension_name> | 187 // Load an extension from test\data\devtools\extensions\<extension_name> |
| 185 void LoadExtension(const char* extension_name) { | 188 void LoadExtension(const char* extension_name) { |
| 186 FilePath path = test_extensions_dir_.AppendASCII(extension_name); | 189 FilePath path = test_extensions_dir_.AppendASCII(extension_name); |
| 187 ASSERT_TRUE(LoadExtensionFromPath(path)) << "Failed to load extension."; | 190 ASSERT_TRUE(LoadExtensionFromPath(path)) << "Failed to load extension."; |
| 188 } | 191 } |
| 189 | 192 |
| 193 void SetUpOnMainThread() OVERRIDE { |
| 194 DevToolsSanityTest::SetUpOnMainThread(); |
| 195 extensions::ManifestHandler::Register( |
| 196 extension_manifest_keys::kContentScripts, |
| 197 new extensions::ContentScriptsHandler); |
| 198 } |
| 199 |
| 190 private: | 200 private: |
| 191 bool LoadExtensionFromPath(const FilePath& path) { | 201 bool LoadExtensionFromPath(const FilePath& path) { |
| 192 ExtensionService* service = extensions::ExtensionSystem::Get( | 202 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 193 browser()->profile())->extension_service(); | 203 browser()->profile())->extension_service(); |
| 194 size_t num_before = service->extensions()->size(); | 204 size_t num_before = service->extensions()->size(); |
| 195 { | 205 { |
| 196 content::NotificationRegistrar registrar; | 206 content::NotificationRegistrar registrar; |
| 197 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 207 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| 198 content::NotificationService::AllSources()); | 208 content::NotificationService::AllSources()); |
| 199 base::CancelableClosure timeout( | 209 base::CancelableClosure timeout( |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 content::CONSOLE_MESSAGE_LEVEL_LOG, | 594 content::CONSOLE_MESSAGE_LEVEL_LOG, |
| 585 "log"); | 595 "log"); |
| 586 devtools_manager->AddMessageToConsole(agent_host, | 596 devtools_manager->AddMessageToConsole(agent_host, |
| 587 content::CONSOLE_MESSAGE_LEVEL_ERROR, | 597 content::CONSOLE_MESSAGE_LEVEL_ERROR, |
| 588 "error"); | 598 "error"); |
| 589 RunTestFunction(window_, "checkLogAndErrorMessages"); | 599 RunTestFunction(window_, "checkLogAndErrorMessages"); |
| 590 CloseDevToolsWindow(); | 600 CloseDevToolsWindow(); |
| 591 } | 601 } |
| 592 | 602 |
| 593 } // namespace | 603 } // namespace |
| OLD | NEW |