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

Side by Side Diff: chrome/browser/devtools/devtools_sanity_browsertest.cc

Issue 12319114: Extract debugger target enumeration into a separate class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@debugger
Patch Set: Fixed compile Created 7 years, 9 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 (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/browser_list_tabcontents_provider.h"
14 #include "chrome/browser/devtools/devtools_window.h" 15 #include "chrome/browser/devtools/devtools_window.h"
16 #include "chrome/browser/extensions/extension_browsertest.h"
15 #include "chrome/browser/extensions/extension_service.h" 17 #include "chrome/browser/extensions/extension_service.h"
16 #include "chrome/browser/extensions/extension_system.h" 18 #include "chrome/browser/extensions/extension_system.h"
17 #include "chrome/browser/extensions/unpacked_installer.h" 19 #include "chrome/browser/extensions/unpacked_installer.h"
18 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_commands.h" 22 #include "chrome/browser/ui/browser_commands.h"
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" 23 #include "chrome/browser/ui/tabs/tab_strip_model.h"
22 #include "chrome/common/chrome_notification_types.h" 24 #include "chrome/common/chrome_notification_types.h"
23 #include "chrome/common/chrome_paths.h" 25 #include "chrome/common/chrome_paths.h"
24 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
25 #include "chrome/test/base/in_process_browser_test.h" 27 #include "chrome/test/base/in_process_browser_test.h"
26 #include "chrome/test/base/ui_test_utils.h" 28 #include "chrome/test/base/ui_test_utils.h"
27 #include "content/public/browser/child_process_data.h" 29 #include "content/public/browser/child_process_data.h"
28 #include "content/public/browser/content_browser_client.h" 30 #include "content/public/browser/content_browser_client.h"
29 #include "content/public/browser/devtools_agent_host.h" 31 #include "content/public/browser/devtools_agent_host.h"
30 #include "content/public/browser/devtools_client_host.h" 32 #include "content/public/browser/devtools_client_host.h"
33 #include "content/public/browser/devtools_http_handler.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"
35 #include "content/public/browser/web_contents.h" 38 #include "content/public/browser/web_contents.h"
36 #include "content/public/browser/worker_service.h" 39 #include "content/public/browser/worker_service.h"
37 #include "content/public/browser/worker_service_observer.h" 40 #include "content/public/browser/worker_service_observer.h"
41 #include "content/public/common/content_switches.h"
38 #include "content/public/test/browser_test_utils.h" 42 #include "content/public/test/browser_test_utils.h"
43 #include "net/base/tcp_listen_socket.h"
39 #include "net/test/test_server.h" 44 #include "net/test/test_server.h"
40 45
41 using content::BrowserThread; 46 using content::BrowserThread;
42 using content::DevToolsManager; 47 using content::DevToolsManager;
43 using content::DevToolsAgentHost; 48 using content::DevToolsAgentHost;
44 using content::NavigationController; 49 using content::NavigationController;
45 using content::RenderViewHost; 50 using content::RenderViewHost;
46 using content::WebContents; 51 using content::WebContents;
47 using content::WorkerService; 52 using content::WorkerService;
48 using content::WorkerServiceObserver; 53 using content::WorkerServiceObserver;
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 devtools_manager->AddMessageToConsole(agent_host, 588 devtools_manager->AddMessageToConsole(agent_host,
584 content::CONSOLE_MESSAGE_LEVEL_LOG, 589 content::CONSOLE_MESSAGE_LEVEL_LOG,
585 "log"); 590 "log");
586 devtools_manager->AddMessageToConsole(agent_host, 591 devtools_manager->AddMessageToConsole(agent_host,
587 content::CONSOLE_MESSAGE_LEVEL_ERROR, 592 content::CONSOLE_MESSAGE_LEVEL_ERROR,
588 "error"); 593 "error");
589 RunTestFunction(window_, "checkLogAndErrorMessages"); 594 RunTestFunction(window_, "checkLogAndErrorMessages");
590 CloseDevToolsWindow(); 595 CloseDevToolsWindow();
591 } 596 }
592 597
598 class RemoteDebuggingTest : public ExtensionBrowserTest {
599
600 class ResultCatcher : public content::NotificationObserver {
601 public:
602 ResultCatcher()
603 : notification_(chrome::NOTIFICATION_CHROME_END) {
604 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_TEST_PASSED,
605 content::NotificationService::AllSources());
606 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_TEST_FAILED,
607 content::NotificationService::AllSources());
608 }
609
610 virtual ~ResultCatcher() {
611 }
612
613 // Pumps the UI loop until a notification is received that an API test
614 // succeeded or failed. Returns true if the test succeeded, false otherwise.
615 bool GetNextResult() {
616 if (!received())
617 content::RunMessageLoop();
618
619 if (!received())
620 NOTREACHED();
621
622 return notification_ == chrome::NOTIFICATION_EXTENSION_TEST_PASSED;
623 }
624
625 private:
626 virtual void Observe(int type,
627 const content::NotificationSource& source,
628 const content::NotificationDetails& details) OVERRIDE {
629 if (received())
630 return;
631 notification_ = chrome::NOTIFICATION_EXTENSION_TEST_PASSED;
632 MessageLoopForUI::current()->Quit();
633 }
634
635 content::NotificationRegistrar registrar_;
636
637 chrome::NotificationType notification_;
638
639 bool received() { return notification_ != chrome::NOTIFICATION_CHROME_END; }
640 };
641
642 protected:
643
644 bool RunExtensionTest(const std::string& directory) {
645 content::DevToolsHttpHandler* devtools_http_handler_ =
646 content::DevToolsHttpHandler::Start(
647 new net::TCPListenSocketFactory("127.0.0.1", 9222),
648 "",
649 new BrowserListTabContentsProvider(
650 profile(), chrome::HOST_DESKTOP_TYPE_NATIVE));
651
652 base::FilePath test_data_path;
653 PathService::Get(chrome::DIR_TEST_DATA, &test_data_path);
654 LoadExtension(
655 test_data_path.AppendASCII("devtools").AppendASCII(directory));
656
657 ResultCatcher catcher;
658 bool result = catcher.GetNextResult();
659 devtools_http_handler_->Stop();
660 return result;
661 }
662 };
663
664 IN_PROC_BROWSER_TEST_F(RemoteDebuggingTest, TargetList) {
665 ASSERT_TRUE(RunExtensionTest("target_list"));
666 }
667
593 } // namespace 668 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_service.h » ('j') | content/browser/devtools/devtools_http_handler_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698