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

Side by Side Diff: content/browser/renderer_host/input/synthetic_pointer_action_unittest.cc

Issue 2573073003: Collapse the API surface on WebInputEvent via accessor functions. (Closed)
Patch Set: Fix nits Created 3 years, 11 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/time/time.h" 6 #include "base/time/time.h"
7 #include "content/browser/renderer_host/input/synthetic_gesture.h" 7 #include "content/browser/renderer_host/input/synthetic_gesture.h"
8 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" 8 #include "content/browser/renderer_host/input/synthetic_gesture_target.h"
9 #include "content/browser/renderer_host/input/synthetic_pointer_action.h" 9 #include "content/browser/renderer_host/input/synthetic_pointer_action.h"
10 #include "content/browser/renderer_host/input/synthetic_touch_driver.h" 10 #include "content/browser/renderer_host/input/synthetic_touch_driver.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 WebInputEvent::Type type_; 90 WebInputEvent::Type type_;
91 }; 91 };
92 92
93 class MockSyntheticPointerTouchActionTarget 93 class MockSyntheticPointerTouchActionTarget
94 : public MockSyntheticPointerActionTarget { 94 : public MockSyntheticPointerActionTarget {
95 public: 95 public:
96 MockSyntheticPointerTouchActionTarget() {} 96 MockSyntheticPointerTouchActionTarget() {}
97 ~MockSyntheticPointerTouchActionTarget() override {} 97 ~MockSyntheticPointerTouchActionTarget() override {}
98 98
99 void DispatchInputEventToPlatform(const WebInputEvent& event) override { 99 void DispatchInputEventToPlatform(const WebInputEvent& event) override {
100 DCHECK(WebInputEvent::isTouchEventType(event.type)); 100 DCHECK(WebInputEvent::isTouchEventType(event.type()));
101 const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event); 101 const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event);
102 type_ = touch_event.type; 102 type_ = touch_event.type();
103 for (size_t i = 0; i < WebTouchEvent::kTouchesLengthCap; ++i) { 103 for (size_t i = 0; i < WebTouchEvent::kTouchesLengthCap; ++i) {
104 indexes_[i] = touch_event.touches[i].id; 104 indexes_[i] = touch_event.touches[i].id;
105 positions_[i] = gfx::PointF(touch_event.touches[i].position); 105 positions_[i] = gfx::PointF(touch_event.touches[i].position);
106 states_[i] = touch_event.touches[i].state; 106 states_[i] = touch_event.touches[i].state;
107 } 107 }
108 touch_length_ = touch_event.touchesLength; 108 touch_length_ = touch_event.touchesLength;
109 } 109 }
110 110
111 testing::AssertionResult SyntheticTouchActionDispatchedCorrectly( 111 testing::AssertionResult SyntheticTouchActionDispatchedCorrectly(
112 const SyntheticPointerActionParams& param, 112 const SyntheticPointerActionParams& param,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 WebTouchPoint::State states_[WebTouchEvent::kTouchesLengthCap]; 168 WebTouchPoint::State states_[WebTouchEvent::kTouchesLengthCap];
169 }; 169 };
170 170
171 class MockSyntheticPointerMouseActionTarget 171 class MockSyntheticPointerMouseActionTarget
172 : public MockSyntheticPointerActionTarget { 172 : public MockSyntheticPointerActionTarget {
173 public: 173 public:
174 MockSyntheticPointerMouseActionTarget() {} 174 MockSyntheticPointerMouseActionTarget() {}
175 ~MockSyntheticPointerMouseActionTarget() override {} 175 ~MockSyntheticPointerMouseActionTarget() override {}
176 176
177 void DispatchInputEventToPlatform(const WebInputEvent& event) override { 177 void DispatchInputEventToPlatform(const WebInputEvent& event) override {
178 DCHECK(WebInputEvent::isMouseEventType(event.type)); 178 DCHECK(WebInputEvent::isMouseEventType(event.type()));
179 const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event); 179 const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event);
180 type_ = mouse_event.type; 180 type_ = mouse_event.type();
181 position_ = gfx::PointF(mouse_event.x, mouse_event.y); 181 position_ = gfx::PointF(mouse_event.x, mouse_event.y);
182 clickCount_ = mouse_event.clickCount; 182 clickCount_ = mouse_event.clickCount;
183 button_ = mouse_event.button; 183 button_ = mouse_event.button;
184 } 184 }
185 185
186 testing::AssertionResult SyntheticMouseActionDispatchedCorrectly( 186 testing::AssertionResult SyntheticMouseActionDispatchedCorrectly(
187 const SyntheticPointerActionParams& param, 187 const SyntheticPointerActionParams& param,
188 int click_count) { 188 int click_count) {
189 if (type_ != ToWebMouseEventType(param.pointer_action_type())) { 189 if (type_ != ToWebMouseEventType(param.pointer_action_type())) {
190 return testing::AssertionFailure() 190 return testing::AssertionFailure()
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 EXPECT_TRUE( 552 EXPECT_TRUE(
553 pointer_mouse_target->SyntheticMouseActionDispatchedCorrectly(param, 1)); 553 pointer_mouse_target->SyntheticMouseActionDispatchedCorrectly(param, 1));
554 554
555 ForwardSyntheticPointerAction(); 555 ForwardSyntheticPointerAction();
556 EXPECT_EQ(1, num_success_); 556 EXPECT_EQ(1, num_success_);
557 EXPECT_EQ(2, num_failure_); 557 EXPECT_EQ(2, num_failure_);
558 } 558 }
559 559
560 } // namespace 560 } // namespace
561 561
562 } // namespace content 562 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698