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

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

Issue 10795090: Move ExecuteJavaScript functions from ui_test_utils.h to browser_test_utils.h so they can be reused… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
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"
(...skipping 17 matching lines...) Expand all
28 #include "content/public/browser/content_browser_client.h" 28 #include "content/public/browser/content_browser_client.h"
29 #include "content/public/browser/devtools_agent_host_registry.h" 29 #include "content/public/browser/devtools_agent_host_registry.h"
30 #include "content/public/browser/devtools_client_host.h" 30 #include "content/public/browser/devtools_client_host.h"
31 #include "content/public/browser/devtools_manager.h" 31 #include "content/public/browser/devtools_manager.h"
32 #include "content/public/browser/notification_registrar.h" 32 #include "content/public/browser/notification_registrar.h"
33 #include "content/public/browser/notification_service.h" 33 #include "content/public/browser/notification_service.h"
34 #include "content/public/browser/render_view_host.h" 34 #include "content/public/browser/render_view_host.h"
35 #include "content/public/browser/web_contents.h" 35 #include "content/public/browser/web_contents.h"
36 #include "content/public/browser/worker_service.h" 36 #include "content/public/browser/worker_service.h"
37 #include "content/public/browser/worker_service_observer.h" 37 #include "content/public/browser/worker_service_observer.h"
38 #include "content/public/test/browser_test_utils.h"
38 #include "net/test/test_server.h" 39 #include "net/test/test_server.h"
39 40
40 using content::BrowserThread; 41 using content::BrowserThread;
41 using content::DevToolsManager; 42 using content::DevToolsManager;
42 using content::DevToolsAgentHost; 43 using content::DevToolsAgentHost;
43 using content::DevToolsAgentHostRegistry; 44 using content::DevToolsAgentHostRegistry;
44 using content::NavigationController; 45 using content::NavigationController;
45 using content::RenderViewHost; 46 using content::RenderViewHost;
46 using content::WebContents; 47 using content::WebContents;
47 using content::WorkerService; 48 using content::WorkerService;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 const char kReloadSharedWorkerTestPage[] = 91 const char kReloadSharedWorkerTestPage[] =
91 "files/workers/debug_shared_worker_initialization.html"; 92 "files/workers/debug_shared_worker_initialization.html";
92 93
93 void RunTestFunction(DevToolsWindow* window, const char* test_name) { 94 void RunTestFunction(DevToolsWindow* window, const char* test_name) {
94 std::string result; 95 std::string result;
95 96
96 // At first check that JavaScript part of the front-end is loaded by 97 // At first check that JavaScript part of the front-end is loaded by
97 // checking that global variable uiTests exists(it's created after all js 98 // checking that global variable uiTests exists(it's created after all js
98 // files have been loaded) and has runTest method. 99 // files have been loaded) and has runTest method.
99 ASSERT_TRUE( 100 ASSERT_TRUE(
100 ui_test_utils::ExecuteJavaScriptAndExtractString( 101 content::ExecuteJavaScriptAndExtractString(
101 window->GetRenderViewHost(), 102 window->GetRenderViewHost(),
102 L"", 103 L"",
103 L"window.domAutomationController.send(" 104 L"window.domAutomationController.send("
104 L"'' + (window.uiTests && (typeof uiTests.runTest)));", 105 L"'' + (window.uiTests && (typeof uiTests.runTest)));",
105 &result)); 106 &result));
106 107
107 if (result == "function") { 108 if (result == "function") {
108 ASSERT_TRUE( 109 ASSERT_TRUE(
109 ui_test_utils::ExecuteJavaScriptAndExtractString( 110 content::ExecuteJavaScriptAndExtractString(
110 window->GetRenderViewHost(), 111 window->GetRenderViewHost(),
111 L"", 112 L"",
112 UTF8ToWide(base::StringPrintf("uiTests.runTest('%s')", 113 UTF8ToWide(base::StringPrintf("uiTests.runTest('%s')",
113 test_name)), 114 test_name)),
114 &result)); 115 &result));
115 EXPECT_EQ("[OK]", result); 116 EXPECT_EQ("[OK]", result);
116 } else { 117 } else {
117 FAIL() << "DevTools front-end is broken."; 118 FAIL() << "DevTools front-end is broken.";
118 } 119 }
119 } 120 }
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 observer.Wait(); 537 observer.Wait();
537 538
538 RunTestFunction(window_, "testReattachAfterCrash"); 539 RunTestFunction(window_, "testReattachAfterCrash");
539 CloseDevToolsWindow(); 540 CloseDevToolsWindow();
540 } 541 }
541 542
542 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestPageWithNoJavaScript) { 543 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestPageWithNoJavaScript) {
543 OpenDevToolsWindow("about:blank"); 544 OpenDevToolsWindow("about:blank");
544 std::string result; 545 std::string result;
545 ASSERT_TRUE( 546 ASSERT_TRUE(
546 ui_test_utils::ExecuteJavaScriptAndExtractString( 547 content::ExecuteJavaScriptAndExtractString(
547 window_->GetRenderViewHost(), 548 window_->GetRenderViewHost(),
548 L"", 549 L"",
549 L"window.domAutomationController.send(" 550 L"window.domAutomationController.send("
550 L"'' + (window.uiTests && (typeof uiTests.runTest)));", 551 L"'' + (window.uiTests && (typeof uiTests.runTest)));",
551 &result)); 552 &result));
552 ASSERT_EQ("function", result) << "DevTools front-end is broken."; 553 ASSERT_EQ("function", result) << "DevTools front-end is broken.";
553 CloseDevToolsWindow(); 554 CloseDevToolsWindow();
554 } 555 }
555 556
556 #if defined(OS_MACOSX) 557 #if defined(OS_MACOSX)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 content::CONSOLE_MESSAGE_LEVEL_LOG, 603 content::CONSOLE_MESSAGE_LEVEL_LOG,
603 "log"); 604 "log");
604 devtools_manager->AddMessageToConsole(agent_host, 605 devtools_manager->AddMessageToConsole(agent_host,
605 content::CONSOLE_MESSAGE_LEVEL_ERROR, 606 content::CONSOLE_MESSAGE_LEVEL_ERROR,
606 "error"); 607 "error");
607 RunTestFunction(window_, "checkLogAndErrorMessages"); 608 RunTestFunction(window_, "checkLogAndErrorMessages");
608 CloseDevToolsWindow(); 609 CloseDevToolsWindow();
609 } 610 }
610 611
611 } // namespace 612 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/content_settings/content_settings_browsertest.cc ('k') | chrome/browser/download/download_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698