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

Side by Side Diff: chrome/browser/automation/automation_misc_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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "chrome/browser/automation/automation_provider_observers.h" 9 #include "chrome/browser/automation/automation_provider_observers.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_tabstrip.h" 11 #include "chrome/browser/ui/browser_tabstrip.h"
12 #include "chrome/common/automation_constants.h" 12 #include "chrome/common/automation_constants.h"
13 #include "chrome/common/automation_events.h" 13 #include "chrome/common/automation_events.h"
14 #include "chrome/test/base/in_process_browser_test.h" 14 #include "chrome/test/base/in_process_browser_test.h"
15 #include "chrome/test/base/ui_test_utils.h" 15 #include "chrome/test/base/ui_test_utils.h"
16 #include "content/public/browser/render_view_host.h" 16 #include "content/public/browser/render_view_host.h"
17 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
18 #include "content/public/test/browser_test_utils.h"
18 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
21 #include "ui/gfx/point.h" 22 #include "ui/gfx/point.h"
22 23
23 class AutomationMiscBrowserTest : public InProcessBrowserTest { 24 class AutomationMiscBrowserTest : public InProcessBrowserTest {
24 public: 25 public:
25 AutomationMiscBrowserTest() {} 26 AutomationMiscBrowserTest() {}
26 27
27 virtual ~AutomationMiscBrowserTest() {} 28 virtual ~AutomationMiscBrowserTest() {}
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 MockMouseEventCallback mock; 66 MockMouseEventCallback mock;
66 EXPECT_CALL(mock, 67 EXPECT_CALL(mock,
67 OnSuccess( 68 OnSuccess(
68 testing::AllOf( 69 testing::AllOf(
69 testing::Property(&gfx::Point::x, testing::Eq(5)), 70 testing::Property(&gfx::Point::x, testing::Eq(5)),
70 testing::Property(&gfx::Point::y, testing::Eq(10))))) 71 testing::Property(&gfx::Point::y, testing::Eq(10)))))
71 .Times(2); 72 .Times(2);
72 73
73 content::RenderViewHost* view = 74 content::RenderViewHost* view =
74 chrome::GetActiveWebContents(browser())->GetRenderViewHost(); 75 chrome::GetActiveWebContents(browser())->GetRenderViewHost();
75 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( 76 ASSERT_TRUE(content::ExecuteJavaScript(
76 view, 77 view,
77 L"", 78 L"",
78 L"window.didClick = false;" 79 L"window.didClick = false;"
79 L"document.body.innerHTML =" 80 L"document.body.innerHTML ="
80 L" '<a style=\\'position:absolute; left:0; top:0\\'>link</a>';" 81 L" '<a style=\\'position:absolute; left:0; top:0\\'>link</a>';"
81 L"document.querySelector('a').addEventListener('click', function() {" 82 L"document.querySelector('a').addEventListener('click', function() {"
82 L" window.didClick = true;" 83 L" window.didClick = true;"
83 L"}, true);")); 84 L"}, true);"));
84 AutomationMouseEvent automation_event; 85 AutomationMouseEvent automation_event;
85 automation_event.location_script_chain.push_back( 86 automation_event.location_script_chain.push_back(
86 ScriptEvaluationRequest("{'x': 5, 'y': 10}", "")); 87 ScriptEvaluationRequest("{'x': 5, 'y': 10}", ""));
87 WebKit::WebMouseEvent& mouse_event = automation_event.mouse_event; 88 WebKit::WebMouseEvent& mouse_event = automation_event.mouse_event;
88 mouse_event.type = WebKit::WebInputEvent::MouseDown; 89 mouse_event.type = WebKit::WebInputEvent::MouseDown;
89 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; 90 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft;
90 mouse_event.clickCount = 1; 91 mouse_event.clickCount = 1;
91 new AutomationMouseEventProcessor( 92 new AutomationMouseEventProcessor(
92 view, automation_event, mock.completion_callback(), 93 view, automation_event, mock.completion_callback(),
93 mock.error_callback()); 94 mock.error_callback());
94 mouse_event.type = WebKit::WebInputEvent::MouseUp; 95 mouse_event.type = WebKit::WebInputEvent::MouseUp;
95 new AutomationMouseEventProcessor( 96 new AutomationMouseEventProcessor(
96 view, automation_event, mock.completion_callback(), 97 view, automation_event, mock.completion_callback(),
97 mock.error_callback()); 98 mock.error_callback());
98 99
99 bool did_click = false; 100 bool did_click = false;
100 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 101 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
101 view, 102 view,
102 L"", 103 L"",
103 L"window.domAutomationController.send(window.didClick);", 104 L"window.domAutomationController.send(window.didClick);",
104 &did_click)); 105 &did_click));
105 EXPECT_TRUE(did_click); 106 EXPECT_TRUE(did_click);
106 } 107 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_browsertest.cc ('k') | chrome/browser/automation/automation_tab_helper_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698