| OLD | NEW |
| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "content/browser/renderer_host/input/buffered_input_router.h" | 6 #include "content/browser/renderer_host/input/buffered_input_router.h" |
| 7 #include "content/browser/renderer_host/input/input_router_unittest.h" | 7 #include "content/browser/renderer_host/input/input_router_unittest.h" |
| 8 #include "content/common/input/event_packet.h" | 8 #include "content/common/input/event_packet.h" |
| 9 #include "content/common/input_messages.h" | 9 #include "content/common/input_messages.h" |
| 10 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); | 260 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); |
| 261 EXPECT_EQ(1U, QueuedEventCount()); | 261 EXPECT_EQ(1U, QueuedEventCount()); |
| 262 SCOPED_EXPECT(client_->ExpectNeedsFlushCalled(true), "SetNeedsFlushCalled"); | 262 SCOPED_EXPECT(client_->ExpectNeedsFlushCalled(true), "SetNeedsFlushCalled"); |
| 263 | 263 |
| 264 // Subsequently queued events will not trigger another flush request. | 264 // Subsequently queued events will not trigger another flush request. |
| 265 SimulateWheelEvent(5, 0, 0, false); | 265 SimulateWheelEvent(5, 0, 0, false); |
| 266 EXPECT_EQ(2U, QueuedEventCount()); | 266 EXPECT_EQ(2U, QueuedEventCount()); |
| 267 SCOPED_EXPECT(client_->ExpectNeedsFlushCalled(false), "SetNeedsFlushCalled"); | 267 SCOPED_EXPECT(client_->ExpectNeedsFlushCalled(false), "SetNeedsFlushCalled"); |
| 268 } | 268 } |
| 269 | 269 |
| 270 TEST_F(BufferedInputRouterTest, HasQueuedGestureEvents) { | |
| 271 EXPECT_FALSE(input_router_->HasQueuedGestureEvents()); | |
| 272 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | |
| 273 WebGestureEvent::Touchpad); | |
| 274 EXPECT_TRUE(input_router_->HasQueuedGestureEvents()); | |
| 275 | |
| 276 // Only an ack'ed gesture should clear it from the queue. | |
| 277 input_router_->Flush(); | |
| 278 ASSERT_TRUE(FinishFlush(INPUT_EVENT_COULD_NOT_DELIVER)); | |
| 279 EXPECT_TRUE(input_router_->HasQueuedGestureEvents()); | |
| 280 | |
| 281 ASSERT_TRUE(FinishFlush(INPUT_EVENT_IMPL_THREAD_CONSUMED)); | |
| 282 EXPECT_FALSE(input_router_->HasQueuedGestureEvents()); | |
| 283 } | |
| 284 | |
| 285 TEST_F(BufferedInputRouterTest, GetLastKeyboardEvent) { | 270 TEST_F(BufferedInputRouterTest, GetLastKeyboardEvent) { |
| 286 EXPECT_EQ(NULL, input_router_->GetLastKeyboardEvent()); | 271 EXPECT_EQ(NULL, input_router_->GetLastKeyboardEvent()); |
| 287 | 272 |
| 288 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); | 273 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); |
| 289 EXPECT_EQ(WebInputEvent::RawKeyDown, | 274 EXPECT_EQ(WebInputEvent::RawKeyDown, |
| 290 input_router_->GetLastKeyboardEvent()->type); | 275 input_router_->GetLastKeyboardEvent()->type); |
| 291 | 276 |
| 292 // Queueing another key event does not effect the "last" event. | 277 // Queueing another key event does not effect the "last" event. |
| 293 SimulateKeyboardEvent(WebInputEvent::KeyUp); | 278 SimulateKeyboardEvent(WebInputEvent::KeyUp); |
| 294 EXPECT_EQ(WebInputEvent::RawKeyDown, | 279 EXPECT_EQ(WebInputEvent::RawKeyDown, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 input_router_->Flush(); | 311 input_router_->Flush(); |
| 327 | 312 |
| 328 ASSERT_FALSE(ack_handler_->unexpected_event_ack_called()); | 313 ASSERT_FALSE(ack_handler_->unexpected_event_ack_called()); |
| 329 EventPacket packet; | 314 EventPacket packet; |
| 330 input_router_->OnMessageReceived( | 315 input_router_->OnMessageReceived( |
| 331 InputHostMsg_HandleEventPacket_ACK(0, 0, InputEventDispositions())); | 316 InputHostMsg_HandleEventPacket_ACK(0, 0, InputEventDispositions())); |
| 332 EXPECT_TRUE(ack_handler_->unexpected_event_ack_called()); | 317 EXPECT_TRUE(ack_handler_->unexpected_event_ack_called()); |
| 333 } | 318 } |
| 334 | 319 |
| 335 } // namespace content | 320 } // namespace content |
| OLD | NEW |