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

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: Addressed comments 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"
38 #include "content/public/test/browser_test_utils.h" 41 #include "content/public/test/browser_test_utils.h"
42 #include "net/base/tcp_listen_socket.h"
39 #include "net/test/test_server.h" 43 #include "net/test/test_server.h"
40 44
41 using content::BrowserThread; 45 using content::BrowserThread;
42 using content::DevToolsManager; 46 using content::DevToolsManager;
43 using content::DevToolsAgentHost; 47 using content::DevToolsAgentHost;
44 using content::NavigationController; 48 using content::NavigationController;
45 using content::RenderViewHost; 49 using content::RenderViewHost;
46 using content::WebContents; 50 using content::WebContents;
47 using content::WorkerService; 51 using content::WorkerService;
48 using content::WorkerServiceObserver; 52 using content::WorkerServiceObserver;
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 devtools_manager->AddMessageToConsole(agent_host, 587 devtools_manager->AddMessageToConsole(agent_host,
584 content::CONSOLE_MESSAGE_LEVEL_LOG, 588 content::CONSOLE_MESSAGE_LEVEL_LOG,
585 "log"); 589 "log");
586 devtools_manager->AddMessageToConsole(agent_host, 590 devtools_manager->AddMessageToConsole(agent_host,
587 content::CONSOLE_MESSAGE_LEVEL_ERROR, 591 content::CONSOLE_MESSAGE_LEVEL_ERROR,
588 "error"); 592 "error");
589 RunTestFunction(window_, "checkLogAndErrorMessages"); 593 RunTestFunction(window_, "checkLogAndErrorMessages");
590 CloseDevToolsWindow(); 594 CloseDevToolsWindow();
591 } 595 }
592 596
597 class RemoteDebuggingTest : public ExtensionBrowserTest {
598
599 class ResultCatcher : public content::NotificationObserver {
600 public:
601 ResultCatcher()
602 : notification_(chrome::NOTIFICATION_CHROME_END) {
603 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_TEST_PASSED,
604 content::NotificationService::AllSources());
605 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_TEST_FAILED,
606 content::NotificationService::AllSources());
607 }
608
609 virtual ~ResultCatcher() {
610 }
611
612 // Pumps the UI loop until a notification is received that an API test
613 // succeeded or failed. Returns true if the test succeeded, false otherwise.
614 bool GetNextResult() {
615 if (!received())
616 content::RunMessageLoop();
617
618 if (!received())
619 NOTREACHED();
620
621 return notification_ == chrome::NOTIFICATION_EXTENSION_TEST_PASSED;
622 }
623
624 private:
625 virtual void Observe(int type,
626 const content::NotificationSource& source,
627 const content::NotificationDetails& details) OVERRIDE {
628 if (received())
629 return;
630 notification_ = chrome::NOTIFICATION_EXTENSION_TEST_PASSED;
631 MessageLoopForUI::current()->Quit();
632 }
633
634 content::NotificationRegistrar registrar_;
635
636 chrome::NotificationType notification_;
637
638 bool received() { return notification_ != chrome::NOTIFICATION_CHROME_END; }
639 };
640
641 protected:
642
643 bool RunExtensionTest(const std::string& directory) {
644 content::DevToolsHttpHandler* devtools_http_handler_ =
645 content::DevToolsHttpHandler::Start(
646 new net::TCPListenSocketFactory("127.0.0.1", 9222),
647 "",
648 new BrowserListTabContentsProvider(
649 profile(), chrome::HOST_DESKTOP_TYPE_NATIVE));
650
651 base::FilePath test_data_path;
652 PathService::Get(chrome::DIR_TEST_DATA, &test_data_path);
653 LoadExtension(
654 test_data_path.AppendASCII("devtools").AppendASCII(directory));
655
656 ResultCatcher catcher;
657 bool result = catcher.GetNextResult();
658 devtools_http_handler_->Stop();
659 return result;
660 }
661 };
662
663 IN_PROC_BROWSER_TEST_F(RemoteDebuggingTest, TargetList) {
664 ASSERT_TRUE(RunExtensionTest("target_list"));
665 }
666
593 } // namespace 667 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_service.h » ('j') | content/browser/devtools/devtools_agent_host_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698