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

Side by Side Diff: chrome/browser/automation/automation_misc_browsertest.cc

Issue 14977013: Delete Automation[Tab/Renderer]Helper and users. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update now that 202087 is committed Created 7 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/automation/automation_provider_observers.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <string>
6
7 #include "base/bind.h"
8 #include "base/callback.h"
9 #include "chrome/browser/automation/automation_provider_observers.h"
10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/common/automation_constants.h"
13 #include "chrome/common/automation_events.h"
14 #include "chrome/test/base/in_process_browser_test.h"
15 #include "chrome/test/base/ui_test_utils.h"
16 #include "content/public/browser/render_view_host.h"
17 #include "content/public/browser/web_contents.h"
18 #include "content/public/test/browser_test_utils.h"
19 #include "testing/gmock/include/gmock/gmock.h"
20 #include "testing/gtest/include/gtest/gtest.h"
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
22 #include "ui/gfx/point.h"
23
24 class AutomationMiscBrowserTest : public InProcessBrowserTest {
25 public:
26 AutomationMiscBrowserTest() {}
27
28 virtual ~AutomationMiscBrowserTest() {}
29 };
30
31 class MockMouseEventCallback {
32 public:
33 typedef AutomationMouseEventProcessor::CompletionCallback CompletionCallback;
34 typedef AutomationMouseEventProcessor::ErrorCallback ErrorCallback;
35
36 MockMouseEventCallback() {
37 completion_callback_ = base::Bind(
38 &MockMouseEventCallback::OnSuccess,
39 base::Unretained(this));
40 error_callback_ = base::Bind(
41 &MockMouseEventCallback::OnError,
42 base::Unretained(this));
43 }
44 virtual ~MockMouseEventCallback() { }
45
46 MOCK_METHOD1(OnSuccess, void(const gfx::Point& point));
47 MOCK_METHOD1(OnError, void(const automation::Error&));
48
49 const CompletionCallback& completion_callback() {
50 return completion_callback_;
51 }
52
53 const ErrorCallback& error_callback() {
54 return error_callback_;
55 }
56
57 private:
58 CompletionCallback completion_callback_;
59 ErrorCallback error_callback_;
60
61 DISALLOW_COPY_AND_ASSIGN(MockMouseEventCallback);
62 };
63
64 // Tests that automation mouse events are processed correctly by the renderer.
65 IN_PROC_BROWSER_TEST_F(AutomationMiscBrowserTest, ProcessMouseEvent) {
66 MockMouseEventCallback mock;
67 EXPECT_CALL(mock,
68 OnSuccess(
69 testing::AllOf(
70 testing::Property(&gfx::Point::x, testing::Eq(5)),
71 testing::Property(&gfx::Point::y, testing::Eq(10)))))
72 .Times(2);
73
74 content::RenderViewHost* view =
75 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost();
76 ASSERT_TRUE(content::ExecuteScript(
77 view,
78 "window.didClick = false;"
79 "document.body.innerHTML ="
80 " '<a style=\\'position:absolute; left:0; top:0\\'>link</a>';"
81 "document.querySelector('a').addEventListener('click', function() {"
82 " window.didClick = true;"
83 "}, true);"));
84 AutomationMouseEvent automation_event;
85 automation_event.location_script_chain
86 .push_back(ScriptEvaluationRequest("{'x': 5, 'y': 10}", std::string()));
87 WebKit::WebMouseEvent& mouse_event = automation_event.mouse_event;
88 mouse_event.type = WebKit::WebInputEvent::MouseDown;
89 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft;
90 mouse_event.clickCount = 1;
91 new AutomationMouseEventProcessor(
92 view, automation_event, mock.completion_callback(),
93 mock.error_callback());
94 mouse_event.type = WebKit::WebInputEvent::MouseUp;
95 new AutomationMouseEventProcessor(
96 view, automation_event, mock.completion_callback(),
97 mock.error_callback());
98
99 bool did_click = false;
100 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
101 view,
102 "window.domAutomationController.send(window.didClick);",
103 &did_click));
104 EXPECT_TRUE(did_click);
105 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/automation/automation_provider_observers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698