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

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

Issue 1050993004: Route touchmove existence notifications to the TouchEventQueue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 3 months 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 <math.h> 5 #include <math.h>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
14 #include "content/browser/renderer_host/input/gesture_event_queue.h" 14 #include "content/browser/renderer_host/input/gesture_event_queue.h"
15 #include "content/browser/renderer_host/input/input_router_client.h" 15 #include "content/browser/renderer_host/input/input_router_client.h"
16 #include "content/browser/renderer_host/input/input_router_impl.h" 16 #include "content/browser/renderer_host/input/input_router_impl.h"
17 #include "content/browser/renderer_host/input/mock_input_ack_handler.h" 17 #include "content/browser/renderer_host/input/mock_input_ack_handler.h"
18 #include "content/browser/renderer_host/input/mock_input_router_client.h" 18 #include "content/browser/renderer_host/input/mock_input_router_client.h"
19 #include "content/common/content_constants_internal.h" 19 #include "content/common/content_constants_internal.h"
20 #include "content/common/edit_command.h" 20 #include "content/common/edit_command.h"
21 #include "content/common/input/synthetic_web_input_event_builders.h" 21 #include "content/common/input/synthetic_web_input_event_builders.h"
22 #include "content/common/input/touch_action.h" 22 #include "content/common/input/touch_action.h"
23 #include "content/common/input/web_input_event_traits.h" 23 #include "content/common/input/web_input_event_traits.h"
24 #include "content/common/input_messages.h" 24 #include "content/common/input_messages.h"
25 #include "content/common/view_messages.h"
26 #include "content/public/common/content_switches.h" 25 #include "content/public/common/content_switches.h"
27 #include "content/public/test/mock_render_process_host.h" 26 #include "content/public/test/mock_render_process_host.h"
28 #include "content/public/test/test_browser_context.h" 27 #include "content/public/test/test_browser_context.h"
29 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
30 #include "ui/events/keycodes/keyboard_codes.h" 29 #include "ui/events/keycodes/keyboard_codes.h"
31 30
32 #if defined(USE_AURA) 31 #if defined(USE_AURA)
33 #include "content/browser/renderer_host/ui_events_helper.h" 32 #include "content/browser/renderer_host/ui_events_helper.h"
34 #include "ui/events/event.h" 33 #include "ui/events/event.h"
35 #endif 34 #endif
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 size_t GetAndResetDidFlushCount() { 308 size_t GetAndResetDidFlushCount() {
310 return client_->GetAndResetDidFlushCount(); 309 return client_->GetAndResetDidFlushCount();
311 } 310 }
312 311
313 bool HasPendingEvents() const { 312 bool HasPendingEvents() const {
314 return input_router_->HasPendingEvents(); 313 return input_router_->HasPendingEvents();
315 } 314 }
316 315
317 void OnHasTouchEventHandlers(bool has_handlers) { 316 void OnHasTouchEventHandlers(bool has_handlers) {
318 input_router_->OnMessageReceived( 317 input_router_->OnMessageReceived(
319 ViewHostMsg_HasTouchEventHandlers(0, has_handlers)); 318 InputHostMsg_HasTouchEventHandlers(0, has_handlers));
320 } 319 }
321 320
322 void OnSetTouchAction(content::TouchAction touch_action) { 321 void OnSetTouchAction(content::TouchAction touch_action) {
323 input_router_->OnMessageReceived( 322 input_router_->OnMessageReceived(
324 InputHostMsg_SetTouchAction(0, touch_action)); 323 InputHostMsg_SetTouchAction(0, touch_action));
325 } 324 }
326 325
327 size_t GetSentMessageCountAndResetSink() { 326 size_t GetSentMessageCountAndResetSink() {
328 size_t count = process_->sink().message_count(); 327 size_t count = process_->sink().message_count();
329 process_->sink().ClearMessages(); 328 process_->sink().ClearMessages();
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 SendTouchEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED, 851 SendTouchEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED,
853 touch_press_event_id); 852 touch_press_event_id);
854 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); 853 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
855 EXPECT_TRUE(TouchEventQueueEmpty()); 854 EXPECT_TRUE(TouchEventQueueEmpty());
856 } 855 }
857 856
858 #if defined(USE_AURA) 857 #if defined(USE_AURA)
859 // Tests that the acked events have correct state. (ui::Events are used only on 858 // Tests that the acked events have correct state. (ui::Events are used only on
860 // windows and aura) 859 // windows and aura)
861 TEST_F(InputRouterImplTest, AckedTouchEventState) { 860 TEST_F(InputRouterImplTest, AckedTouchEventState) {
862 input_router_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); 861 input_router_->OnMessageReceived(InputHostMsg_HasTouchEventHandlers(0, true));
863 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); 862 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
864 EXPECT_TRUE(TouchEventQueueEmpty()); 863 EXPECT_TRUE(TouchEventQueueEmpty());
865 864
866 // Send a bunch of events, and make sure the ACKed events are correct. 865 // Send a bunch of events, and make sure the ACKed events are correct.
867 ScopedVector<ui::TouchEvent> expected_events; 866 ScopedVector<ui::TouchEvent> expected_events;
868 867
869 // Use a custom timestamp for all the events to test that the acked events 868 // Use a custom timestamp for all the events to test that the acked events
870 // have the same timestamp; 869 // have the same timestamp;
871 base::TimeDelta timestamp = base::Time::NowFromSystemTime() - base::Time(); 870 base::TimeDelta timestamp = base::Time::NowFromSystemTime() - base::Time();
872 timestamp -= base::TimeDelta::FromSeconds(600); 871 timestamp -= base::TimeDelta::FromSeconds(600);
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
1829 client_overscroll = client_->GetAndResetOverscroll(); 1828 client_overscroll = client_->GetAndResetOverscroll();
1830 EXPECT_EQ(wheel_overscroll.accumulated_overscroll, 1829 EXPECT_EQ(wheel_overscroll.accumulated_overscroll,
1831 client_overscroll.accumulated_overscroll); 1830 client_overscroll.accumulated_overscroll);
1832 EXPECT_EQ(wheel_overscroll.latest_overscroll_delta, 1831 EXPECT_EQ(wheel_overscroll.latest_overscroll_delta,
1833 client_overscroll.latest_overscroll_delta); 1832 client_overscroll.latest_overscroll_delta);
1834 EXPECT_EQ(wheel_overscroll.current_fling_velocity, 1833 EXPECT_EQ(wheel_overscroll.current_fling_velocity,
1835 client_overscroll.current_fling_velocity); 1834 client_overscroll.current_fling_velocity);
1836 } 1835 }
1837 1836
1838 } // namespace content 1837 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698