Index: content/browser/renderer_host/input/input_router_impl_unittest.cc |
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 69adf747ef95443f9dbe1a10cc7d1abc2fa4a8fa..12e16be7b60078727e79cb4d605b3a8f9b7f6673 100644 |
--- a/content/browser/renderer_host/input/input_router_impl_unittest.cc |
+++ b/content/browser/renderer_host/input/input_router_impl_unittest.cc |
@@ -145,10 +145,11 @@ class InputRouterImplTest : public testing::Test { |
ack_handler_.reset(new MockInputAckHandler()); |
CommandLine* command_line = CommandLine::ForCurrentProcess(); |
command_line->AppendSwitch(switches::kValidateInputEventStream); |
- input_router_.reset(new InputRouterImpl( |
- process_.get(), client_.get(), ack_handler_.get(), MSG_ROUTING_NONE)); |
- input_router_->gesture_event_queue_.set_debounce_enabled_for_testing( |
- false); |
+ input_router_.reset(new InputRouterImpl(process_.get(), |
+ client_.get(), |
+ ack_handler_.get(), |
+ MSG_ROUTING_NONE, |
+ config_)); |
client_->set_input_router(input_router()); |
ack_handler_->set_input_router(input_router()); |
} |
@@ -163,6 +164,14 @@ class InputRouterImplTest : public testing::Test { |
browser_context_.reset(); |
} |
+ void SetUpForTouchAckTimeoutTest(int timeout_ms) { |
+ config_.touch_config.touch_ack_timeout_delay = |
+ base::TimeDelta::FromMilliseconds(timeout_ms); |
+ config_.touch_config.touch_ack_timeout_supported = true; |
+ TearDown(); |
+ SetUp(); |
+ } |
+ |
void SimulateKeyboardEvent(WebInputEvent::Type type, bool is_shortcut) { |
WebKeyboardEvent event = SyntheticWebKeyboardEventBuilder::Build(type); |
NativeWebKeyboardEvent native_event; |
@@ -330,6 +339,7 @@ class InputRouterImplTest : public testing::Test { |
base::MessageLoop::current()->Run(); |
} |
+ InputRouterImpl::Config config_; |
scoped_ptr<MockRenderProcessHost> process_; |
scoped_ptr<MockInputRouterClient> client_; |
scoped_ptr<MockInputAckHandler> ack_handler_; |
@@ -1011,17 +1021,11 @@ TEST_F(InputRouterImplTest, GestureShowPressIsInOrder) { |
EXPECT_EQ(3U, ack_handler_->GetAndResetAckCount()); |
} |
-// Test that touch ack timeout behavior is properly configured via the command |
-// line, and toggled by view update flags and allowed touch actions. |
+// Test that touch ack timeout behavior is properly toggled by view update flags |
+// and allowed touch actions. |
TEST_F(InputRouterImplTest, TouchAckTimeoutConfigured) { |
- // Unless explicitly supported via the command-line, the touch timeout should |
- // be disabled. |
- EXPECT_FALSE(TouchEventTimeoutEnabled()); |
- |
- CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
- switches::kTouchAckTimeoutDelayMs, "1"); |
- TearDown(); |
- SetUp(); |
+ const int timeout_ms = 1; |
+ SetUpForTouchAckTimeoutTest(timeout_ms); |
ASSERT_TRUE(TouchEventTimeoutEnabled()); |
// Verify that the touch ack timeout fires upon the delayed ack. |
@@ -1029,7 +1033,7 @@ TEST_F(InputRouterImplTest, TouchAckTimeoutConfigured) { |
SendTouchEvent(); |
EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
- RunTasksAndWait(base::TimeDelta::FromMilliseconds(2)); |
+ RunTasksAndWait(base::TimeDelta::FromMilliseconds(timeout_ms + 1)); |
// The timed-out event should have been ack'ed. |
EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
@@ -1095,10 +1099,8 @@ TEST_F(InputRouterImplTest, TouchAckTimeoutConfigured) { |
// the touch timeout. |
TEST_F(InputRouterImplTest, |
TouchAckTimeoutDisabledForTouchSequenceAfterTouchActionNone) { |
- CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
- switches::kTouchAckTimeoutDelayMs, "1"); |
- TearDown(); |
- SetUp(); |
+ const int timeout_ms = 1; |
+ SetUpForTouchAckTimeoutTest(timeout_ms); |
ASSERT_TRUE(TouchEventTimeoutEnabled()); |
OnHasTouchEventHandlers(true); |
@@ -1128,7 +1130,7 @@ TEST_F(InputRouterImplTest, |
EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
// Delay the ack. The timeout should *not* fire. |
- RunTasksAndWait(base::TimeDelta::FromMilliseconds(2)); |
+ RunTasksAndWait(base::TimeDelta::FromMilliseconds(timeout_ms + 1)); |
EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
@@ -1154,7 +1156,7 @@ TEST_F(InputRouterImplTest, |
EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
// Wait for the touch ack timeout to fire. |
- RunTasksAndWait(base::TimeDelta::FromMilliseconds(2)); |
+ RunTasksAndWait(base::TimeDelta::FromMilliseconds(timeout_ms + 1)); |
EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
} |