OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2016 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 "web/tests/SelectionTestBase.h" | |
6 | |
7 #include "web/WebLocalFrameImpl.h" | |
8 | |
9 namespace blink { | |
10 namespace { | |
11 IntSize scaled(IntSize p, float scale) | |
12 { | |
13 p.scale(scale, scale); | |
14 return p; | |
15 } | |
16 } // namespace | |
17 | |
18 void SelectionTestBase::emulateMouseDrag(const IntPoint& downPoint, const IntPoi nt& upPoint, int modifiers, DragFlags dragFlags) | |
19 { | |
20 if (dragFlags & SendDownEvent) { | |
21 const auto& downEvent = FrameTestHelpers::createMouseEvent(WebMouseEvent ::MouseDown, WebMouseEvent::ButtonLeft, downPoint, modifiers); | |
22 m_webView->handleInputEvent(downEvent); | |
23 } | |
24 | |
25 static const int kMoveEventsNumber = 10; | |
tkent
2016/03/25 03:33:03
"static" for const local variable doesn't make sen
| |
26 static const float kMoveIncrementFraction = 1. / kMoveEventsNumber; | |
27 const auto& upDownVector = upPoint - downPoint; | |
28 for (int i = 0; i < kMoveEventsNumber; ++i) { | |
29 const auto& movePoint = downPoint + scaled(upDownVector, i * kMoveIncrem entFraction); | |
30 const auto& moveEvent = FrameTestHelpers::createMouseEvent(WebMouseEvent ::MouseMove, WebMouseEvent::ButtonLeft, movePoint, modifiers); | |
31 m_webView->handleInputEvent(moveEvent); | |
32 } | |
33 | |
34 if (dragFlags & SendUpEvent) { | |
35 const auto& upEvent = FrameTestHelpers::createMouseEvent(WebMouseEvent:: MouseUp, WebMouseEvent::ButtonLeft, upPoint, modifiers); | |
36 m_webView->handleInputEvent(upEvent); | |
37 } | |
38 } | |
39 | |
40 void SelectionTestBase::emulateMouseClick(const IntPoint& clickPoint, WebMouseEv ent::Button button, int modifiers, int count) | |
41 { | |
42 auto event = FrameTestHelpers::createMouseEvent(WebMouseEvent::MouseDown, bu tton, clickPoint, modifiers); | |
43 event.clickCount = count; | |
44 m_webView->handleInputEvent(event); | |
45 event.type = WebMouseEvent::MouseUp; | |
46 m_webView->handleInputEvent(event); | |
47 } | |
48 | |
49 void SelectionTestBase::emulateMouseDown(const IntPoint& clickPoint, WebMouseEve nt::Button button, int modifiers, int count) | |
50 { | |
51 auto event = FrameTestHelpers::createMouseEvent(WebMouseEvent::MouseDown, bu tton, clickPoint, modifiers); | |
52 event.clickCount = count; | |
53 m_webView->handleInputEvent(event); | |
54 } | |
55 | |
56 std::string SelectionTestBase::getSelectionText() | |
57 { | |
58 return m_mainFrame->selectionAsText().utf8(); | |
59 } | |
60 } // namespace blink | |
OLD | NEW |