OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 last_mouse_x_(-1), | 39 last_mouse_x_(-1), |
40 last_mouse_y_(-1) { | 40 last_mouse_y_(-1) { |
41 last_event_time_seconds_ = | 41 last_event_time_seconds_ = |
42 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); | 42 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); |
43 event_time_delta_seconds_ = 0.1; | 43 event_time_delta_seconds_ = 0.1; |
44 } | 44 } |
45 | 45 |
46 virtual ~TouchEmulatorTest() {} | 46 virtual ~TouchEmulatorTest() {} |
47 | 47 |
48 // testing::Test | 48 // testing::Test |
49 virtual void SetUp() OVERRIDE { | 49 virtual void SetUp() override { |
50 #if defined(USE_AURA) | 50 #if defined(USE_AURA) |
51 aura::Env::CreateInstance(true); | 51 aura::Env::CreateInstance(true); |
52 screen_.reset(aura::TestScreen::Create(gfx::Size())); | 52 screen_.reset(aura::TestScreen::Create(gfx::Size())); |
53 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); | 53 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); |
54 #endif | 54 #endif |
55 | 55 |
56 emulator_.reset(new TouchEmulator(this)); | 56 emulator_.reset(new TouchEmulator(this)); |
57 emulator_->Enable(); | 57 emulator_->Enable(); |
58 } | 58 } |
59 | 59 |
60 virtual void TearDown() OVERRIDE { | 60 virtual void TearDown() override { |
61 emulator_->Disable(); | 61 emulator_->Disable(); |
62 EXPECT_EQ("", ExpectedEvents()); | 62 EXPECT_EQ("", ExpectedEvents()); |
63 | 63 |
64 #if defined(USE_AURA) | 64 #if defined(USE_AURA) |
65 aura::Env::DeleteInstance(); | 65 aura::Env::DeleteInstance(); |
66 screen_.reset(); | 66 screen_.reset(); |
67 #endif | 67 #endif |
68 } | 68 } |
69 | 69 |
70 virtual void ForwardGestureEvent( | 70 virtual void ForwardGestureEvent( |
71 const blink::WebGestureEvent& event) OVERRIDE { | 71 const blink::WebGestureEvent& event) override { |
72 forwarded_events_.push_back(event.type); | 72 forwarded_events_.push_back(event.type); |
73 } | 73 } |
74 | 74 |
75 virtual void ForwardEmulatedTouchEvent( | 75 virtual void ForwardEmulatedTouchEvent( |
76 const blink::WebTouchEvent& event) OVERRIDE { | 76 const blink::WebTouchEvent& event) override { |
77 forwarded_events_.push_back(event.type); | 77 forwarded_events_.push_back(event.type); |
78 EXPECT_EQ(1U, event.touchesLength); | 78 EXPECT_EQ(1U, event.touchesLength); |
79 EXPECT_EQ(last_mouse_x_, event.touches[0].position.x); | 79 EXPECT_EQ(last_mouse_x_, event.touches[0].position.x); |
80 EXPECT_EQ(last_mouse_y_, event.touches[0].position.y); | 80 EXPECT_EQ(last_mouse_y_, event.touches[0].position.y); |
81 int expectedCancelable = event.type != WebInputEvent::TouchCancel; | 81 int expectedCancelable = event.type != WebInputEvent::TouchCancel; |
82 EXPECT_EQ(expectedCancelable, event.cancelable); | 82 EXPECT_EQ(expectedCancelable, event.cancelable); |
83 if (ack_touches_synchronously_) { | 83 if (ack_touches_synchronously_) { |
84 emulator()->HandleTouchEventAck( | 84 emulator()->HandleTouchEventAck( |
85 event, INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); | 85 event, INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 virtual void SetCursor(const WebCursor& cursor) OVERRIDE {} | 89 virtual void SetCursor(const WebCursor& cursor) override {} |
90 | 90 |
91 virtual void ShowContextMenuAtPoint(const gfx::Point& point) OVERRIDE {} | 91 virtual void ShowContextMenuAtPoint(const gfx::Point& point) override {} |
92 | 92 |
93 protected: | 93 protected: |
94 TouchEmulator* emulator() const { | 94 TouchEmulator* emulator() const { |
95 return emulator_.get(); | 95 return emulator_.get(); |
96 } | 96 } |
97 | 97 |
98 int modifiers() const { | 98 int modifiers() const { |
99 return shift_pressed_ ? WebInputEvent::ShiftKey : 0; | 99 return shift_pressed_ ? WebInputEvent::ShiftKey : 0; |
100 } | 100 } |
101 | 101 |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 MouseDown(100, 200); | 516 MouseDown(100, 200); |
517 EXPECT_EQ("TouchStart GestureTapDown", ExpectedEvents()); | 517 EXPECT_EQ("TouchStart GestureTapDown", ExpectedEvents()); |
518 MouseUp(200, 200); | 518 MouseUp(200, 200); |
519 EXPECT_EQ( | 519 EXPECT_EQ( |
520 "TouchMove GestureTapCancel GestureScrollBegin GestureScrollUpdate" | 520 "TouchMove GestureTapCancel GestureScrollBegin GestureScrollUpdate" |
521 " TouchEnd GestureScrollEnd", | 521 " TouchEnd GestureScrollEnd", |
522 ExpectedEvents()); | 522 ExpectedEvents()); |
523 } | 523 } |
524 | 524 |
525 } // namespace content | 525 } // namespace content |
OLD | NEW |