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

Side by Side Diff: content/browser/renderer_host/render_widget_host_unittest.cc

Issue 821223002: Pass gesture detector config type when enabling touch emulator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@touch-emulator-enabled
Patch Set: Created 5 years, 12 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 6 #include "base/bind.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/timer/timer.h" 10 #include "base/timer/timer.h"
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 result += WebInputEventTraits::GetName(event->type); 1027 result += WebInputEventTraits::GetName(event->type);
1028 } 1028 }
1029 process->sink().ClearMessages(); 1029 process->sink().ClearMessages();
1030 return result; 1030 return result;
1031 } 1031 }
1032 1032
1033 TEST_F(RenderWidgetHostTest, TouchEmulator) { 1033 TEST_F(RenderWidgetHostTest, TouchEmulator) {
1034 simulated_event_time_delta_seconds_ = 0.1; 1034 simulated_event_time_delta_seconds_ = 0.1;
1035 // Immediately ack all touches instead of sending them to the renderer. 1035 // Immediately ack all touches instead of sending them to the renderer.
1036 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); 1036 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false));
1037 host_->SetTouchEventEmulationEnabled(true); 1037 host_->SetTouchEventEmulationEnabled(
1038 true, ui::GestureProviderConfigType::GENERIC_MOBILE);
1038 process_->sink().ClearMessages(); 1039 process_->sink().ClearMessages();
1039 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); 1040 view_->set_bounds(gfx::Rect(0, 0, 400, 200));
1040 view_->Show(); 1041 view_->Show();
1041 1042
1042 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 10, 0, false); 1043 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 10, 0, false);
1043 EXPECT_EQ(0U, process_->sink().message_count()); 1044 EXPECT_EQ(0U, process_->sink().message_count());
1044 1045
1045 // Mouse press becomes touch start which in turn becomes tap. 1046 // Mouse press becomes touch start which in turn becomes tap.
1046 SimulateMouseEvent(WebInputEvent::MouseDown, 10, 10, 0, true); 1047 SimulateMouseEvent(WebInputEvent::MouseDown, 10, 10, 0, true);
1047 EXPECT_EQ(WebInputEvent::TouchStart, host_->acked_touch_event_type()); 1048 EXPECT_EQ(WebInputEvent::TouchStart, host_->acked_touch_event_type());
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 SimulateMouseEvent( 1127 SimulateMouseEvent(
1127 WebInputEvent::MouseMove, 10, 120, WebInputEvent::ShiftKey, true); 1128 WebInputEvent::MouseMove, 10, 120, WebInputEvent::ShiftKey, true);
1128 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); 1129 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type());
1129 EXPECT_EQ("GesturePinchUpdate", 1130 EXPECT_EQ("GesturePinchUpdate",
1130 GetInputMessageTypes(process_)); 1131 GetInputMessageTypes(process_));
1131 SendInputEventACK(WebInputEvent::GesturePinchUpdate, 1132 SendInputEventACK(WebInputEvent::GesturePinchUpdate,
1132 INPUT_EVENT_ACK_STATE_CONSUMED); 1133 INPUT_EVENT_ACK_STATE_CONSUMED);
1133 EXPECT_EQ(0U, process_->sink().message_count()); 1134 EXPECT_EQ(0U, process_->sink().message_count());
1134 1135
1135 // Turn off emulation during a pinch. 1136 // Turn off emulation during a pinch.
1136 host_->SetTouchEventEmulationEnabled(false); 1137 host_->SetTouchEventEmulationEnabled(
1138 false, ui::GestureProviderConfigType::GENERIC_MOBILE);
1137 EXPECT_EQ(WebInputEvent::TouchCancel, host_->acked_touch_event_type()); 1139 EXPECT_EQ(WebInputEvent::TouchCancel, host_->acked_touch_event_type());
1138 EXPECT_EQ("GesturePinchEnd GestureScrollEnd", 1140 EXPECT_EQ("GesturePinchEnd GestureScrollEnd",
1139 GetInputMessageTypes(process_)); 1141 GetInputMessageTypes(process_));
1140 EXPECT_EQ(0U, process_->sink().message_count()); 1142 EXPECT_EQ(0U, process_->sink().message_count());
1141 1143
1142 // Mouse event should pass untouched. 1144 // Mouse event should pass untouched.
1143 SimulateMouseEvent( 1145 SimulateMouseEvent(
1144 WebInputEvent::MouseMove, 10, 10, WebInputEvent::ShiftKey, true); 1146 WebInputEvent::MouseMove, 10, 10, WebInputEvent::ShiftKey, true);
1145 EXPECT_EQ("MouseMove", GetInputMessageTypes(process_)); 1147 EXPECT_EQ("MouseMove", GetInputMessageTypes(process_));
1146 SendInputEventACK(WebInputEvent::MouseMove, 1148 SendInputEventACK(WebInputEvent::MouseMove,
1147 INPUT_EVENT_ACK_STATE_CONSUMED); 1149 INPUT_EVENT_ACK_STATE_CONSUMED);
1148 EXPECT_EQ(0U, process_->sink().message_count()); 1150 EXPECT_EQ(0U, process_->sink().message_count());
1149 1151
1150 // Turn on emulation. 1152 // Turn on emulation.
1151 host_->SetTouchEventEmulationEnabled(true); 1153 host_->SetTouchEventEmulationEnabled(
1154 true, ui::GestureProviderConfigType::GENERIC_MOBILE);
1152 EXPECT_EQ(0U, process_->sink().message_count()); 1155 EXPECT_EQ(0U, process_->sink().message_count());
1153 1156
1154 // Another touch. 1157 // Another touch.
1155 SimulateMouseEvent(WebInputEvent::MouseDown, 10, 10, 0, true); 1158 SimulateMouseEvent(WebInputEvent::MouseDown, 10, 10, 0, true);
1156 EXPECT_EQ(WebInputEvent::TouchStart, host_->acked_touch_event_type()); 1159 EXPECT_EQ(WebInputEvent::TouchStart, host_->acked_touch_event_type());
1157 EXPECT_EQ("GestureTapDown", GetInputMessageTypes(process_)); 1160 EXPECT_EQ("GestureTapDown", GetInputMessageTypes(process_));
1158 EXPECT_EQ(0U, process_->sink().message_count()); 1161 EXPECT_EQ(0U, process_->sink().message_count());
1159 1162
1160 // Scroll. 1163 // Scroll.
1161 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 30, 0, true); 1164 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 30, 0, true);
1162 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); 1165 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type());
1163 EXPECT_EQ( 1166 EXPECT_EQ(
1164 "GestureTapCancel GestureScrollBegin GestureScrollUpdate", 1167 "GestureTapCancel GestureScrollBegin GestureScrollUpdate",
1165 GetInputMessageTypes(process_)); 1168 GetInputMessageTypes(process_));
1166 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 1169 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
1167 INPUT_EVENT_ACK_STATE_CONSUMED); 1170 INPUT_EVENT_ACK_STATE_CONSUMED);
1168 1171
1169 // Turn off emulation during a scroll. 1172 // Turn off emulation during a scroll.
1170 host_->SetTouchEventEmulationEnabled(false); 1173 host_->SetTouchEventEmulationEnabled(
1174 false, ui::GestureProviderConfigType::GENERIC_MOBILE);
1171 EXPECT_EQ(WebInputEvent::TouchCancel, host_->acked_touch_event_type()); 1175 EXPECT_EQ(WebInputEvent::TouchCancel, host_->acked_touch_event_type());
1172 1176
1173 EXPECT_EQ("GestureScrollEnd", GetInputMessageTypes(process_)); 1177 EXPECT_EQ("GestureScrollEnd", GetInputMessageTypes(process_));
1174 EXPECT_EQ(0U, process_->sink().message_count()); 1178 EXPECT_EQ(0U, process_->sink().message_count());
1175 } 1179 }
1176 1180
1177 #define TEST_InputRouterRoutes_NOARGS(INPUTMSG) \ 1181 #define TEST_InputRouterRoutes_NOARGS(INPUTMSG) \
1178 TEST_F(RenderWidgetHostTest, InputRouterRoutes##INPUTMSG) { \ 1182 TEST_F(RenderWidgetHostTest, InputRouterRoutes##INPUTMSG) { \
1179 host_->SetupForInputRouterTest(); \ 1183 host_->SetupForInputRouterTest(); \
1180 host_->INPUTMSG(); \ 1184 host_->INPUTMSG(); \
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 // Having an initial size set means that the size information had been sent 1468 // Having an initial size set means that the size information had been sent
1465 // with the reqiest to new up the RenderView and so subsequent WasResized 1469 // with the reqiest to new up the RenderView and so subsequent WasResized
1466 // calls should not result in new IPC (unless the size has actually changed). 1470 // calls should not result in new IPC (unless the size has actually changed).
1467 host_->WasResized(); 1471 host_->WasResized();
1468 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); 1472 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
1469 EXPECT_EQ(initial_size_, host_->old_resize_params_->new_size); 1473 EXPECT_EQ(initial_size_, host_->old_resize_params_->new_size);
1470 EXPECT_TRUE(host_->resize_ack_pending_); 1474 EXPECT_TRUE(host_->resize_ack_pending_);
1471 } 1475 }
1472 1476
1473 } // namespace content 1477 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698