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

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

Issue 1409163006: Migrating tests to use EmbeddedTestServer (/chrome/browser misc) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 1 month 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/location.h" 9 #include "base/location.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 DevToolsSanityTest() : window_(NULL) {} 138 DevToolsSanityTest() : window_(NULL) {}
139 139
140 protected: 140 protected:
141 void RunTest(const std::string& test_name, const std::string& test_page) { 141 void RunTest(const std::string& test_name, const std::string& test_page) {
142 OpenDevToolsWindow(test_page, false); 142 OpenDevToolsWindow(test_page, false);
143 RunTestFunction(window_, test_name.c_str()); 143 RunTestFunction(window_, test_name.c_str());
144 CloseDevToolsWindow(); 144 CloseDevToolsWindow();
145 } 145 }
146 146
147 void LoadTestPage(const std::string& test_page) { 147 void LoadTestPage(const std::string& test_page) {
148 GURL url = test_server()->GetURL(test_page); 148 GURL url = spawned_test_server()->GetURL(test_page);
149 ui_test_utils::NavigateToURL(browser(), url); 149 ui_test_utils::NavigateToURL(browser(), url);
150 } 150 }
151 151
152 void OpenDevToolsWindow(const std::string& test_page, bool is_docked) { 152 void OpenDevToolsWindow(const std::string& test_page, bool is_docked) {
153 ASSERT_TRUE(test_server()->Start()); 153 ASSERT_TRUE(spawned_test_server()->Start());
154 LoadTestPage(test_page); 154 LoadTestPage(test_page);
155 155
156 window_ = DevToolsWindowTesting::OpenDevToolsWindowSync(GetInspectedTab(), 156 window_ = DevToolsWindowTesting::OpenDevToolsWindowSync(GetInspectedTab(),
157 is_docked); 157 is_docked);
158 } 158 }
159 159
160 WebContents* GetInspectedTab() { 160 WebContents* GetInspectedTab() {
161 return browser()->tab_strip_model()->GetWebContentsAt(0); 161 return browser()->tab_strip_model()->GetWebContentsAt(0);
162 } 162 }
163 163
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 477 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
478 base::MessageLoop::QuitWhenIdleClosure()); 478 base::MessageLoop::QuitWhenIdleClosure());
479 delete this; 479 delete this;
480 } 480 }
481 scoped_refptr<WorkerData> worker_data_; 481 scoped_refptr<WorkerData> worker_data_;
482 }; 482 };
483 483
484 void RunTest(const char* test_name, 484 void RunTest(const char* test_name,
485 const char* test_page, 485 const char* test_page,
486 const char* worker_path) { 486 const char* worker_path) {
487 ASSERT_TRUE(test_server()->Start()); 487 ASSERT_TRUE(spawned_test_server()->Start());
488 GURL url = test_server()->GetURL(test_page); 488 GURL url = spawned_test_server()->GetURL(test_page);
489 ui_test_utils::NavigateToURL(browser(), url); 489 ui_test_utils::NavigateToURL(browser(), url);
490 490
491 scoped_refptr<WorkerData> worker_data = 491 scoped_refptr<WorkerData> worker_data =
492 WaitForFirstSharedWorker(worker_path); 492 WaitForFirstSharedWorker(worker_path);
493 OpenDevToolsWindowForSharedWorker(worker_data.get()); 493 OpenDevToolsWindowForSharedWorker(worker_data.get());
494 RunTestFunction(window_, test_name); 494 RunTestFunction(window_, test_name);
495 CloseDevToolsWindow(); 495 CloseDevToolsWindow();
496 } 496 }
497 497
498 static void TerminateWorkerOnIOThread(scoped_refptr<WorkerData> worker_data) { 498 static void TerminateWorkerOnIOThread(scoped_refptr<WorkerData> worker_data) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 RunBeforeUnloadSanityTest(false, base::Bind( 609 RunBeforeUnloadSanityTest(false, base::Bind(
610 &chrome::CloseAllBrowsers)); 610 &chrome::CloseAllBrowsers));
611 } 611 }
612 612
613 // Tests that inspected tab gets closed if devtools renderer 613 // Tests that inspected tab gets closed if devtools renderer
614 // becomes unresponsive during beforeunload event interception. 614 // becomes unresponsive during beforeunload event interception.
615 // @see http://crbug.com/322380 615 // @see http://crbug.com/322380
616 // Disabled because of http://crbug.com/410327 616 // Disabled because of http://crbug.com/410327
617 IN_PROC_BROWSER_TEST_F(DevToolsUnresponsiveBeforeUnloadTest, 617 IN_PROC_BROWSER_TEST_F(DevToolsUnresponsiveBeforeUnloadTest,
618 DISABLED_TestUndockedDevToolsUnresponsive) { 618 DISABLED_TestUndockedDevToolsUnresponsive) {
619 ASSERT_TRUE(test_server()->Start()); 619 ASSERT_TRUE(spawned_test_server()->Start());
620 LoadTestPage(kDebuggerTestPage); 620 LoadTestPage(kDebuggerTestPage);
621 DevToolsWindow* devtools_window = OpenDevToolWindowOnWebContents( 621 DevToolsWindow* devtools_window = OpenDevToolWindowOnWebContents(
622 GetInspectedTab(), false); 622 GetInspectedTab(), false);
623 623
624 scoped_refptr<content::MessageLoopRunner> runner = 624 scoped_refptr<content::MessageLoopRunner> runner =
625 new content::MessageLoopRunner; 625 new content::MessageLoopRunner;
626 DevToolsWindowTesting::Get(devtools_window)->SetCloseCallback( 626 DevToolsWindowTesting::Get(devtools_window)->SetCloseCallback(
627 runner->QuitClosure()); 627 runner->QuitClosure());
628 628
629 ASSERT_TRUE(content::ExecuteScript( 629 ASSERT_TRUE(content::ExecuteScript(
630 DevToolsWindowTesting::Get(devtools_window)->main_web_contents()-> 630 DevToolsWindowTesting::Get(devtools_window)->main_web_contents()->
631 GetRenderViewHost(), 631 GetRenderViewHost(),
632 "window.addEventListener('beforeunload'," 632 "window.addEventListener('beforeunload',"
633 "function(event) { while (true); });")); 633 "function(event) { while (true); });"));
634 CloseInspectedTab(); 634 CloseInspectedTab();
635 runner->Run(); 635 runner->Run();
636 } 636 }
637 637
638 // Tests that closing worker inspector window does not cause browser crash 638 // Tests that closing worker inspector window does not cause browser crash
639 // @see http://crbug.com/323031 639 // @see http://crbug.com/323031
640 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, 640 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest,
641 TestWorkerWindowClosing) { 641 TestWorkerWindowClosing) {
642 ASSERT_TRUE(test_server()->Start()); 642 ASSERT_TRUE(spawned_test_server()->Start());
643 LoadTestPage(kDebuggerTestPage); 643 LoadTestPage(kDebuggerTestPage);
644 DevToolsWindow* devtools_window = OpenDevToolWindowOnWebContents( 644 DevToolsWindow* devtools_window = OpenDevToolWindowOnWebContents(
645 GetInspectedTab(), false); 645 GetInspectedTab(), false);
646 646
647 OpenDevToolsPopupWindow(devtools_window); 647 OpenDevToolsPopupWindow(devtools_window);
648 CloseDevToolsPopupWindow(devtools_window); 648 CloseDevToolsPopupWindow(devtools_window);
649 } 649 }
650 650
651 // Tests that BeforeUnload event gets called on devtools that are opened 651 // Tests that BeforeUnload event gets called on devtools that are opened
652 // on another devtools. 652 // on another devtools.
653 // Disabled because of http://crbug.com/497857 653 // Disabled because of http://crbug.com/497857
654 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, 654 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest,
655 DISABLED_TestDevToolsOnDevTools) { 655 DISABLED_TestDevToolsOnDevTools) {
656 ASSERT_TRUE(test_server()->Start()); 656 ASSERT_TRUE(spawned_test_server()->Start());
657 LoadTestPage(kDebuggerTestPage); 657 LoadTestPage(kDebuggerTestPage);
658 658
659 std::vector<DevToolsWindow*> windows; 659 std::vector<DevToolsWindow*> windows;
660 std::vector<content::WindowedNotificationObserver*> close_observers; 660 std::vector<content::WindowedNotificationObserver*> close_observers;
661 content::WebContents* inspected_web_contents = GetInspectedTab(); 661 content::WebContents* inspected_web_contents = GetInspectedTab();
662 for (int i = 0; i < 3; ++i) { 662 for (int i = 0; i < 3; ++i) {
663 DevToolsWindow* devtools_window = OpenDevToolWindowOnWebContents( 663 DevToolsWindow* devtools_window = OpenDevToolWindowOnWebContents(
664 inspected_web_contents, i == 0); 664 inspected_web_contents, i == 0);
665 windows.push_back(devtools_window); 665 windows.push_back(devtools_window);
666 content::WindowedNotificationObserver* close_observer = 666 content::WindowedNotificationObserver* close_observer =
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestSettings) { 831 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestSettings) {
832 OpenDevToolsWindow("about:blank", true); 832 OpenDevToolsWindow("about:blank", true);
833 RunTestFunction(window_, "testSettings"); 833 RunTestFunction(window_, "testSettings");
834 CloseDevToolsWindow(); 834 CloseDevToolsWindow();
835 } 835 }
836 836
837 // Tests that external navigation from inspector page is always handled by 837 // Tests that external navigation from inspector page is always handled by
838 // DevToolsWindow and results in inspected page navigation. 838 // DevToolsWindow and results in inspected page navigation.
839 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestDevToolsExternalNavigation) { 839 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestDevToolsExternalNavigation) {
840 OpenDevToolsWindow(kDebuggerTestPage, true); 840 OpenDevToolsWindow(kDebuggerTestPage, true);
841 GURL url = test_server()->GetURL(kNavigateBackTestPage); 841 GURL url = spawned_test_server()->GetURL(kNavigateBackTestPage);
842 ui_test_utils::UrlLoadObserver observer(url, 842 ui_test_utils::UrlLoadObserver observer(url,
843 content::NotificationService::AllSources()); 843 content::NotificationService::AllSources());
844 ASSERT_TRUE(content::ExecuteScript( 844 ASSERT_TRUE(content::ExecuteScript(
845 main_web_contents(), 845 main_web_contents(),
846 std::string("window.location = \"") + url.spec() + "\"")); 846 std::string("window.location = \"") + url.spec() + "\""));
847 observer.Wait(); 847 observer.Wait();
848 848
849 ASSERT_TRUE(main_web_contents()->GetURL(). 849 ASSERT_TRUE(main_web_contents()->GetURL().
850 SchemeIs(content::kChromeDevToolsScheme)); 850 SchemeIs(content::kChromeDevToolsScheme));
851 ASSERT_EQ(url, GetInspectedTab()->GetURL()); 851 ASSERT_EQ(url, GetInspectedTab()->GetURL());
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 switches::kAshBrowserTests)) 929 switches::kAshBrowserTests))
930 return; 930 return;
931 #endif 931 #endif
932 932
933 RunTest("testSharedWorker", kSharedWorkerTestPage, kSharedWorkerTestWorker); 933 RunTest("testSharedWorker", kSharedWorkerTestPage, kSharedWorkerTestWorker);
934 } 934 }
935 935
936 // Disabled, crashes under Dr.Memory and ASan, http://crbug.com/432444. 936 // Disabled, crashes under Dr.Memory and ASan, http://crbug.com/432444.
937 IN_PROC_BROWSER_TEST_F(WorkerDevToolsSanityTest, 937 IN_PROC_BROWSER_TEST_F(WorkerDevToolsSanityTest,
938 DISABLED_PauseInSharedWorkerInitialization) { 938 DISABLED_PauseInSharedWorkerInitialization) {
939 ASSERT_TRUE(test_server()->Start()); 939 ASSERT_TRUE(spawned_test_server()->Start());
940 GURL url = test_server()->GetURL(kReloadSharedWorkerTestPage); 940 GURL url = spawned_test_server()->GetURL(kReloadSharedWorkerTestPage);
941 ui_test_utils::NavigateToURL(browser(), url); 941 ui_test_utils::NavigateToURL(browser(), url);
942 942
943 scoped_refptr<WorkerData> worker_data = 943 scoped_refptr<WorkerData> worker_data =
944 WaitForFirstSharedWorker(kReloadSharedWorkerTestWorker); 944 WaitForFirstSharedWorker(kReloadSharedWorkerTestWorker);
945 OpenDevToolsWindowForSharedWorker(worker_data.get()); 945 OpenDevToolsWindowForSharedWorker(worker_data.get());
946 946
947 // We should make sure that the worker inspector has loaded before 947 // We should make sure that the worker inspector has loaded before
948 // terminating worker. 948 // terminating worker.
949 RunTestFunction(window_, "testPauseInSharedWorkerInitialization1"); 949 RunTestFunction(window_, "testPauseInSharedWorkerInitialization1");
950 950
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 (defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD)) 1030 (defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD))
1031 #define MAYBE_TestScreenshotRecording DISABLED_TestScreenshotRecording 1031 #define MAYBE_TestScreenshotRecording DISABLED_TestScreenshotRecording
1032 #else 1032 #else
1033 #define MAYBE_TestScreenshotRecording TestScreenshotRecording 1033 #define MAYBE_TestScreenshotRecording TestScreenshotRecording
1034 #endif 1034 #endif
1035 // Tests raw headers text. 1035 // Tests raw headers text.
1036 IN_PROC_BROWSER_TEST_F(DevToolsPixelOutputTests, 1036 IN_PROC_BROWSER_TEST_F(DevToolsPixelOutputTests,
1037 MAYBE_TestScreenshotRecording) { 1037 MAYBE_TestScreenshotRecording) {
1038 RunTest("testScreenshotRecording", std::string()); 1038 RunTest("testScreenshotRecording", std::string());
1039 } 1039 }
OLDNEW
« no previous file with comments | « chrome/browser/devtools/device/port_forwarding_browsertest.cc ('k') | chrome/browser/do_not_track_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698