summaryrefslogtreecommitdiffstats
path: root/content/browser/renderer_host/input/input_router_impl_unittest.cc
diff options
context:
space:
mode:
authorjdduke@chromium.org <jdduke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-10 03:37:03 +0000
committerjdduke@chromium.org <jdduke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-10 03:37:03 +0000
commit6320873a305f7fefca2cfd9847bb5e9a09f04bc3 (patch)
treef9f1bbdd517d0425e72cb5bfa9699e4f86f08396 /content/browser/renderer_host/input/input_router_impl_unittest.cc
parent7f14c8de777b78b445cc500b8c17d8125b195056 (diff)
downloadchromium_src-6320873a305f7fefca2cfd9847bb5e9a09f04bc3.zip
chromium_src-6320873a305f7fefca2cfd9847bb5e9a09f04bc3.tar.gz
chromium_src-6320873a305f7fefca2cfd9847bb5e9a09f04bc3.tar.bz2
Delegate touch handler registration logic to the TouchEventQueue
Teach the TouchEventQueue about touch handler registration, allowing it to make more informed touch forwarding decisions. This also prevents corner cases where a partial touch sequence would be improperly forwarded to the renderer after a touch handler is registered. BUG=332418 Review URL: https://codereview.chromium.org/132083006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244072 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/renderer_host/input/input_router_impl_unittest.cc')
-rw-r--r--content/browser/renderer_host/input/input_router_impl_unittest.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/content/browser/renderer_host/input/input_router_impl_unittest.cc b/content/browser/renderer_host/input/input_router_impl_unittest.cc
index f237d2e..8601dcc 100644
--- a/content/browser/renderer_host/input/input_router_impl_unittest.cc
+++ b/content/browser/renderer_host/input/input_router_impl_unittest.cc
@@ -269,6 +269,11 @@ class InputRouterImplTest : public testing::Test {
return input_router()->touch_event_queue_->ack_timeout_enabled();
}
+ void OnHasTouchEventHandlers(bool has_handlers) {
+ input_router_->OnMessageReceived(
+ ViewHostMsg_HasTouchEventHandlers(0, has_handlers));
+ }
+
size_t GetSentMessageCountAndResetSink() {
size_t count = process_->sink().message_count();
process_->sink().ClearMessages();
@@ -529,6 +534,8 @@ TEST_F(InputRouterImplTest,
// Tests that touch-events are queued properly.
TEST_F(InputRouterImplTest, TouchEventQueue) {
+ OnHasTouchEventHandlers(true);
+
PressTouchPoint(1, 1);
SendTouchEvent();
EXPECT_TRUE(client_->GetAndResetFilterEventCalled());
@@ -563,7 +570,7 @@ TEST_F(InputRouterImplTest, TouchEventQueue) {
// Tests that the touch-queue is emptied if a page stops listening for touch
// events.
TEST_F(InputRouterImplTest, TouchEventQueueFlush) {
- input_router_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true));
+ OnHasTouchEventHandlers(true);
EXPECT_TRUE(client_->has_touch_handler());
EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
EXPECT_TRUE(TouchEventQueueEmpty());
@@ -579,7 +586,7 @@ TEST_F(InputRouterImplTest, TouchEventQueueFlush) {
// The page stops listening for touch-events. The touch-event queue should now
// be emptied, but none of the queued touch-events should be sent to the
// renderer.
- input_router_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false));
+ OnHasTouchEventHandlers(false);
EXPECT_FALSE(client_->has_touch_handler());
EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
EXPECT_TRUE(TouchEventQueueEmpty());
@@ -702,6 +709,8 @@ TEST_F(InputRouterImplTest, UnhandledWheelEvent) {
}
TEST_F(InputRouterImplTest, TouchTypesIgnoringAck) {
+ OnHasTouchEventHandlers(true);
+
int start_type = static_cast<int>(WebInputEvent::TouchStart);
int end_type = static_cast<int>(WebInputEvent::TouchCancel);
ASSERT_LT(start_type, end_type);