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

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

Issue 48973005: Move TouchEvent timeout code to the TouchEventQueue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 7 years 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/command_line.h"
6 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
7 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
8 #include "content/browser/renderer_host/input/gesture_event_filter.h" 9 #include "content/browser/renderer_host/input/gesture_event_filter.h"
9 #include "content/browser/renderer_host/input/input_router_client.h" 10 #include "content/browser/renderer_host/input/input_router_client.h"
10 #include "content/browser/renderer_host/input/input_router_impl.h" 11 #include "content/browser/renderer_host/input/input_router_impl.h"
11 #include "content/browser/renderer_host/input/mock_input_ack_handler.h" 12 #include "content/browser/renderer_host/input/mock_input_ack_handler.h"
12 #include "content/browser/renderer_host/input/mock_input_router_client.h" 13 #include "content/browser/renderer_host/input/mock_input_router_client.h"
13 #include "content/common/content_constants_internal.h" 14 #include "content/common/content_constants_internal.h"
14 #include "content/common/edit_command.h" 15 #include "content/common/edit_command.h"
15 #include "content/common/input/synthetic_web_input_event_builders.h" 16 #include "content/common/input/synthetic_web_input_event_builders.h"
16 #include "content/common/input/web_input_event_traits.h" 17 #include "content/common/input/web_input_event_traits.h"
17 #include "content/common/input_messages.h" 18 #include "content/common/input_messages.h"
18 #include "content/common/view_messages.h" 19 #include "content/common/view_messages.h"
20 #include "content/public/common/content_switches.h"
19 #include "content/public/test/mock_render_process_host.h" 21 #include "content/public/test/mock_render_process_host.h"
20 #include "content/public/test/test_browser_context.h" 22 #include "content/public/test/test_browser_context.h"
21 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
22 #include "ui/events/keycodes/keyboard_codes.h" 24 #include "ui/events/keycodes/keyboard_codes.h"
23 25
24 #if defined(OS_WIN) || defined(USE_AURA) 26 #if defined(OS_WIN) || defined(USE_AURA)
25 #include "content/browser/renderer_host/ui_events_helper.h" 27 #include "content/browser/renderer_host/ui_events_helper.h"
26 #include "ui/events/event.h" 28 #include "ui/events/event.h"
27 #endif 29 #endif
28 30
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 scoped_ptr<IPC::Message> response( 255 scoped_ptr<IPC::Message> response(
254 new InputHostMsg_HandleInputEvent_ACK(0, type, ack_result, 256 new InputHostMsg_HandleInputEvent_ACK(0, type, ack_result,
255 ui::LatencyInfo())); 257 ui::LatencyInfo()));
256 input_router_->OnMessageReceived(*response); 258 input_router_->OnMessageReceived(*response);
257 } 259 }
258 260
259 InputRouterImpl* input_router() const { 261 InputRouterImpl* input_router() const {
260 return input_router_.get(); 262 return input_router_.get();
261 } 263 }
262 264
263 bool no_touch_to_renderer() {
264 return input_router()->touch_event_queue_->no_touch_to_renderer();
265 }
266
267 bool TouchEventQueueEmpty() const { 265 bool TouchEventQueueEmpty() const {
268 return input_router()->touch_event_queue_->empty(); 266 return input_router()->touch_event_queue_->empty();
269 } 267 }
270 268
269 bool TouchEventTimeoutEnabled() const {
270 return input_router()->touch_event_queue_->ack_timeout_enabled();
271 }
272
271 size_t GetSentMessageCountAndResetSink() { 273 size_t GetSentMessageCountAndResetSink() {
272 size_t count = process_->sink().message_count(); 274 size_t count = process_->sink().message_count();
273 process_->sink().ClearMessages(); 275 process_->sink().ClearMessages();
274 return count; 276 return count;
275 } 277 }
276 278
277 scoped_ptr<MockRenderProcessHost> process_; 279 scoped_ptr<MockRenderProcessHost> process_;
278 scoped_ptr<MockInputRouterClient> client_; 280 scoped_ptr<MockInputRouterClient> client_;
279 scoped_ptr<MockInputAckHandler> ack_handler_; 281 scoped_ptr<MockInputAckHandler> ack_handler_;
280 scoped_ptr<InputRouterImpl> input_router_; 282 scoped_ptr<InputRouterImpl> input_router_;
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 845
844 SendInputEventACK(WebInputEvent::GestureTap, 846 SendInputEventACK(WebInputEvent::GestureTap,
845 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 847 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
846 848
847 // Now that the Tap has been ACKed, the ShowPress events should receive 849 // Now that the Tap has been ACKed, the ShowPress events should receive
848 // synthetics acks, and fire immediately. 850 // synthetics acks, and fire immediately.
849 EXPECT_EQ(2U, GetSentMessageCountAndResetSink()); 851 EXPECT_EQ(2U, GetSentMessageCountAndResetSink());
850 EXPECT_EQ(3U, ack_handler_->GetAndResetAckCount()); 852 EXPECT_EQ(3U, ack_handler_->GetAndResetAckCount());
851 } 853 }
852 854
855 // Test that touch ack timeout behavior is properly configured via the command
856 // line, and toggled by the view update flags.
857 TEST_F(InputRouterImplTest, TouchAckTimeoutConfigured) {
858 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
859 switches::kTouchAckTimeoutDelayMs, "5");
860 TearDown();
861 SetUp();
862 ASSERT_TRUE(TouchEventTimeoutEnabled());
863
864 // A fixed page scale or mobile viewport should disable the touch timeout.
865 input_router()->OnViewUpdated(InputRouter::FIXED_PAGE_SCALE);
866 EXPECT_FALSE(TouchEventTimeoutEnabled());
867
868 input_router()->OnViewUpdated(InputRouter::VIEW_FLAGS_NONE);
869 EXPECT_TRUE(TouchEventTimeoutEnabled());
870
871 input_router()->OnViewUpdated(InputRouter::MOBILE_VIEWPORT);
872 EXPECT_FALSE(TouchEventTimeoutEnabled());
873
874 input_router()->OnViewUpdated(InputRouter::MOBILE_VIEWPORT |
875 InputRouter::FIXED_PAGE_SCALE);
876 EXPECT_FALSE(TouchEventTimeoutEnabled());
877
878 input_router()->OnViewUpdated(InputRouter::VIEW_FLAGS_NONE);
879 EXPECT_TRUE(TouchEventTimeoutEnabled());
880 }
881
853 } // namespace content 882 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/input_router_impl.cc ('k') | content/browser/renderer_host/input/timeout_monitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698