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

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

Issue 2227563003: Refactoring button field and its type (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix new instances Created 4 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/browser/renderer_host/input/synthetic_gesture_controller.h" 5 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 199
200 class MockDragMouseTarget : public MockMoveGestureTarget { 200 class MockDragMouseTarget : public MockMoveGestureTarget {
201 public: 201 public:
202 MockDragMouseTarget() : started_(false) {} 202 MockDragMouseTarget() : started_(false) {}
203 ~MockDragMouseTarget() override {} 203 ~MockDragMouseTarget() override {}
204 204
205 void DispatchInputEventToPlatform(const WebInputEvent& event) override { 205 void DispatchInputEventToPlatform(const WebInputEvent& event) override {
206 ASSERT_TRUE(WebInputEvent::isMouseEventType(event.type)); 206 ASSERT_TRUE(WebInputEvent::isMouseEventType(event.type));
207 const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event); 207 const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event);
208 if (!started_) { 208 if (!started_) {
209 EXPECT_EQ(mouse_event.button, WebMouseEvent::ButtonLeft); 209 EXPECT_EQ(mouse_event.button, WebMouseEvent::Button::Left);
210 EXPECT_EQ(mouse_event.clickCount, 1); 210 EXPECT_EQ(mouse_event.clickCount, 1);
211 EXPECT_EQ(mouse_event.type, WebInputEvent::MouseDown); 211 EXPECT_EQ(mouse_event.type, WebInputEvent::MouseDown);
212 start_.SetPoint(mouse_event.x, mouse_event.y); 212 start_.SetPoint(mouse_event.x, mouse_event.y);
213 last_mouse_point_ = start_; 213 last_mouse_point_ = start_;
214 started_ = true; 214 started_ = true;
215 } else { 215 } else {
216 EXPECT_EQ(mouse_event.button, WebMouseEvent::ButtonLeft); 216 EXPECT_EQ(mouse_event.button, WebMouseEvent::Button::Left);
217 ASSERT_NE(mouse_event.type, WebInputEvent::MouseDown); 217 ASSERT_NE(mouse_event.type, WebInputEvent::MouseDown);
218 218
219 gfx::PointF mouse_point(mouse_event.x, mouse_event.y); 219 gfx::PointF mouse_point(mouse_event.x, mouse_event.y);
220 gfx::Vector2dF delta = mouse_point - last_mouse_point_; 220 gfx::Vector2dF delta = mouse_point - last_mouse_point_;
221 total_abs_move_distance_length_ += delta.Length(); 221 total_abs_move_distance_length_ += delta.Length();
222 if (mouse_event.type == WebInputEvent::MouseUp) 222 if (mouse_event.type == WebInputEvent::MouseUp)
223 start_to_end_distance_ = mouse_point - start_; 223 start_to_end_distance_ = mouse_point - start_;
224 last_mouse_point_ = mouse_point; 224 last_mouse_point_ = mouse_point;
225 } 225 }
226 } 226 }
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 MockSyntheticTapMouseTarget() {} 443 MockSyntheticTapMouseTarget() {}
444 ~MockSyntheticTapMouseTarget() override {} 444 ~MockSyntheticTapMouseTarget() override {}
445 445
446 void DispatchInputEventToPlatform(const WebInputEvent& event) override { 446 void DispatchInputEventToPlatform(const WebInputEvent& event) override {
447 ASSERT_TRUE(WebInputEvent::isMouseEventType(event.type)); 447 ASSERT_TRUE(WebInputEvent::isMouseEventType(event.type));
448 const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event); 448 const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event);
449 449
450 switch (state_) { 450 switch (state_) {
451 case NOT_STARTED: 451 case NOT_STARTED:
452 EXPECT_EQ(mouse_event.type, WebInputEvent::MouseDown); 452 EXPECT_EQ(mouse_event.type, WebInputEvent::MouseDown);
453 EXPECT_EQ(mouse_event.button, WebMouseEvent::ButtonLeft); 453 EXPECT_EQ(mouse_event.button, WebMouseEvent::Button::Left);
454 EXPECT_EQ(mouse_event.clickCount, 1); 454 EXPECT_EQ(mouse_event.clickCount, 1);
455 position_ = gfx::PointF(mouse_event.x, mouse_event.y); 455 position_ = gfx::PointF(mouse_event.x, mouse_event.y);
456 start_time_ = base::TimeDelta::FromMilliseconds( 456 start_time_ = base::TimeDelta::FromMilliseconds(
457 static_cast<int64_t>(mouse_event.timeStampSeconds * 1000)); 457 static_cast<int64_t>(mouse_event.timeStampSeconds * 1000));
458 state_ = STARTED; 458 state_ = STARTED;
459 break; 459 break;
460 case STARTED: 460 case STARTED:
461 EXPECT_EQ(mouse_event.type, WebInputEvent::MouseUp); 461 EXPECT_EQ(mouse_event.type, WebInputEvent::MouseUp);
462 EXPECT_EQ(mouse_event.button, WebMouseEvent::ButtonLeft); 462 EXPECT_EQ(mouse_event.button, WebMouseEvent::Button::Left);
463 EXPECT_EQ(mouse_event.clickCount, 1); 463 EXPECT_EQ(mouse_event.clickCount, 1);
464 EXPECT_EQ(position_, gfx::PointF(mouse_event.x, mouse_event.y)); 464 EXPECT_EQ(position_, gfx::PointF(mouse_event.x, mouse_event.y));
465 stop_time_ = base::TimeDelta::FromMilliseconds( 465 stop_time_ = base::TimeDelta::FromMilliseconds(
466 static_cast<int64_t>(mouse_event.timeStampSeconds * 1000)); 466 static_cast<int64_t>(mouse_event.timeStampSeconds * 1000));
467 state_ = FINISHED; 467 state_ = FINISHED;
468 break; 468 break;
469 case FINISHED: 469 case FINISHED:
470 EXPECT_FALSE(true); 470 EXPECT_FALSE(true);
471 break; 471 break;
472 } 472 }
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 EXPECT_EQ(0, num_failure_); 1467 EXPECT_EQ(0, num_failure_);
1468 EXPECT_TRUE(tap_target->GestureFinished()); 1468 EXPECT_TRUE(tap_target->GestureFinished());
1469 EXPECT_EQ(tap_target->position(), params.position); 1469 EXPECT_EQ(tap_target->position(), params.position);
1470 EXPECT_EQ(tap_target->GetDuration().InMilliseconds(), params.duration_ms); 1470 EXPECT_EQ(tap_target->GetDuration().InMilliseconds(), params.duration_ms);
1471 EXPECT_GE(GetTotalTime(), 1471 EXPECT_GE(GetTotalTime(),
1472 base::TimeDelta::FromMilliseconds(params.duration_ms)); 1472 base::TimeDelta::FromMilliseconds(params.duration_ms));
1473 } 1473 }
1474 1474
1475 } // namespace 1475 } // namespace
1476 1476
1477 } // namespace content 1477 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698