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

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

Issue 1372253002: gfx: Make conversions from gfx::Point to PointF explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pointfconvert-gfx: . Created 5 years, 2 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 "content/browser/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.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/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 ui::CompositionUnderline(3, 4, 0xff000000, false, 0xefcdab90)); 1076 ui::CompositionUnderline(3, 4, 0xff000000, false, 0xefcdab90));
1077 1077
1078 // Caret is at the end. (This emulates Japanese MSIME 2007 and later) 1078 // Caret is at the end. (This emulates Japanese MSIME 2007 and later)
1079 composition_text.selection = gfx::Range(4); 1079 composition_text.selection = gfx::Range(4);
1080 1080
1081 view_->SetCompositionText(composition_text); 1081 view_->SetCompositionText(composition_text);
1082 EXPECT_TRUE(view_->has_composition_text_); 1082 EXPECT_TRUE(view_->has_composition_text_);
1083 sink_->ClearMessages(); 1083 sink_->ClearMessages();
1084 1084
1085 // Simulates the mouse press. 1085 // Simulates the mouse press.
1086 ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), 1086 ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, gfx::PointF(), gfx::PointF(),
1087 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 1087 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
1088 0); 1088 0);
1089 view_->OnMouseEvent(&mouse_event); 1089 view_->OnMouseEvent(&mouse_event);
1090 1090
1091 EXPECT_FALSE(view_->has_composition_text_); 1091 EXPECT_FALSE(view_->has_composition_text_);
1092 1092
1093 EXPECT_EQ(2U, sink_->message_count()); 1093 EXPECT_EQ(2U, sink_->message_count());
1094 1094
1095 if (sink_->message_count() == 2) { 1095 if (sink_->message_count() == 2) {
1096 // Verify mouse event happens after the confirm-composition event. 1096 // Verify mouse event happens after the confirm-composition event.
1097 EXPECT_EQ(InputMsg_ImeConfirmComposition::ID, 1097 EXPECT_EQ(InputMsg_ImeConfirmComposition::ID,
1098 sink_->GetMessageAt(0)->type()); 1098 sink_->GetMessageAt(0)->type());
1099 EXPECT_EQ(InputMsg_HandleInputEvent::ID, 1099 EXPECT_EQ(InputMsg_HandleInputEvent::ID,
1100 sink_->GetMessageAt(1)->type()); 1100 sink_->GetMessageAt(1)->type());
1101 } 1101 }
1102 } 1102 }
1103 1103
1104 // Checks that touch-event state is maintained correctly. 1104 // Checks that touch-event state is maintained correctly.
1105 TEST_F(RenderWidgetHostViewAuraTest, TouchEventState) { 1105 TEST_F(RenderWidgetHostViewAuraTest, TouchEventState) {
1106 view_->InitAsChild(NULL); 1106 view_->InitAsChild(NULL);
1107 view_->Show(); 1107 view_->Show();
1108 GetSentMessageCountAndResetSink(); 1108 GetSentMessageCountAndResetSink();
1109 1109
1110 // Start with no touch-event handler in the renderer. 1110 // Start with no touch-event handler in the renderer.
1111 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); 1111 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false));
1112 1112
1113 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, 1113 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(30.f, 30.f), 0,
1114 gfx::Point(30, 30),
1115 0,
1116 ui::EventTimeForNow()); 1114 ui::EventTimeForNow());
1117 ui::TouchEvent move(ui::ET_TOUCH_MOVED, 1115 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(20.f, 20.f), 0,
1118 gfx::Point(20, 20),
1119 0,
1120 ui::EventTimeForNow()); 1116 ui::EventTimeForNow());
1121 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, 1117 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(20.f, 20.f), 0,
1122 gfx::Point(20, 20),
1123 0,
1124 ui::EventTimeForNow()); 1118 ui::EventTimeForNow());
1125 1119
1126 // The touch events should get forwarded from the view, but they should not 1120 // The touch events should get forwarded from the view, but they should not
1127 // reach the renderer. 1121 // reach the renderer.
1128 view_->OnTouchEvent(&press); 1122 view_->OnTouchEvent(&press);
1129 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); 1123 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
1130 EXPECT_TRUE(press.synchronous_handling_disabled()); 1124 EXPECT_TRUE(press.synchronous_handling_disabled());
1131 EXPECT_EQ(ui::MotionEvent::ACTION_DOWN, pointer_state().GetAction()); 1125 EXPECT_EQ(ui::MotionEvent::ACTION_DOWN, pointer_state().GetAction());
1132 1126
1133 view_->OnTouchEvent(&move); 1127 view_->OnTouchEvent(&move);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 1162
1169 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); 1163 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false));
1170 1164
1171 // Ack'ing the outstanding event should flush the pending touch queue. 1165 // Ack'ing the outstanding event should flush the pending touch queue.
1172 InputEventAck ack(blink::WebInputEvent::TouchStart, 1166 InputEventAck ack(blink::WebInputEvent::TouchStart,
1173 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, 1167 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS,
1174 press.unique_event_id()); 1168 press.unique_event_id());
1175 widget_host_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack)); 1169 widget_host_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack));
1176 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); 1170 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
1177 1171
1178 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, 1172 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::PointF(20.f, 20.f), 0,
1179 base::Time::NowFromSystemTime() - base::Time()); 1173 base::Time::NowFromSystemTime() - base::Time());
1180 view_->OnTouchEvent(&move2); 1174 view_->OnTouchEvent(&move2);
1181 EXPECT_TRUE(press.synchronous_handling_disabled()); 1175 EXPECT_TRUE(press.synchronous_handling_disabled());
1182 EXPECT_EQ(ui::MotionEvent::ACTION_MOVE, pointer_state().GetAction()); 1176 EXPECT_EQ(ui::MotionEvent::ACTION_MOVE, pointer_state().GetAction());
1183 EXPECT_EQ(1U, pointer_state().GetPointerCount()); 1177 EXPECT_EQ(1U, pointer_state().GetPointerCount());
1184 1178
1185 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(20, 20), 0, 1179 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::PointF(20.f, 20.f), 0,
1186 base::Time::NowFromSystemTime() - base::Time()); 1180 base::Time::NowFromSystemTime() - base::Time());
1187 view_->OnTouchEvent(&release2); 1181 view_->OnTouchEvent(&release2);
1188 EXPECT_TRUE(press.synchronous_handling_disabled()); 1182 EXPECT_TRUE(press.synchronous_handling_disabled());
1189 EXPECT_EQ(0U, pointer_state().GetPointerCount()); 1183 EXPECT_EQ(0U, pointer_state().GetPointerCount());
1190 } 1184 }
1191 1185
1192 // Checks that touch-event state is maintained correctly for multiple touch 1186 // Checks that touch-event state is maintained correctly for multiple touch
1193 // points. 1187 // points.
1194 TEST_F(RenderWidgetHostViewAuraTest, MultiTouchPointsStates) { 1188 TEST_F(RenderWidgetHostViewAuraTest, MultiTouchPointsStates) {
1195 view_->InitAsFullscreen(parent_view_); 1189 view_->InitAsFullscreen(parent_view_);
1196 view_->Show(); 1190 view_->Show();
1197 view_->UseFakeDispatcher(); 1191 view_->UseFakeDispatcher();
1198 GetSentMessageCountAndResetSink(); 1192 GetSentMessageCountAndResetSink();
1199 1193
1200 ui::TouchEvent press0(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, 1194 ui::TouchEvent press0(ui::ET_TOUCH_PRESSED, gfx::PointF(30.f, 30.f), 0,
1201 ui::EventTimeForNow()); 1195 ui::EventTimeForNow());
1202 1196
1203 view_->OnTouchEvent(&press0); 1197 view_->OnTouchEvent(&press0);
1204 SendTouchEventACK(blink::WebInputEvent::TouchStart, 1198 SendTouchEventACK(blink::WebInputEvent::TouchStart,
1205 INPUT_EVENT_ACK_STATE_CONSUMED, 1199 INPUT_EVENT_ACK_STATE_CONSUMED,
1206 press0.unique_event_id()); 1200 press0.unique_event_id());
1207 EXPECT_EQ(ui::MotionEvent::ACTION_DOWN, pointer_state().GetAction()); 1201 EXPECT_EQ(ui::MotionEvent::ACTION_DOWN, pointer_state().GetAction());
1208 EXPECT_EQ(1U, pointer_state().GetPointerCount()); 1202 EXPECT_EQ(1U, pointer_state().GetPointerCount());
1209 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); 1203 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount());
1210 1204
1211 ui::TouchEvent move0(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, 1205 ui::TouchEvent move0(ui::ET_TOUCH_MOVED, gfx::PointF(20.f, 20.f), 0,
1212 ui::EventTimeForNow()); 1206 ui::EventTimeForNow());
1213 1207
1214 view_->OnTouchEvent(&move0); 1208 view_->OnTouchEvent(&move0);
1215 SendTouchEventACK(blink::WebInputEvent::TouchMove, 1209 SendTouchEventACK(blink::WebInputEvent::TouchMove,
1216 INPUT_EVENT_ACK_STATE_CONSUMED, 1210 INPUT_EVENT_ACK_STATE_CONSUMED,
1217 move0.unique_event_id()); 1211 move0.unique_event_id());
1218 EXPECT_EQ(ui::MotionEvent::ACTION_MOVE, pointer_state().GetAction()); 1212 EXPECT_EQ(ui::MotionEvent::ACTION_MOVE, pointer_state().GetAction());
1219 EXPECT_EQ(1U, pointer_state().GetPointerCount()); 1213 EXPECT_EQ(1U, pointer_state().GetPointerCount());
1220 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); 1214 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount());
1221 1215
1222 // For the second touchstart, only the state of the second touch point is 1216 // For the second touchstart, only the state of the second touch point is
1223 // StatePressed, the state of the first touch point is StateStationary. 1217 // StatePressed, the state of the first touch point is StateStationary.
1224 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1, 1218 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(10.f, 10.f), 1,
1225 ui::EventTimeForNow()); 1219 ui::EventTimeForNow());
1226 1220
1227 view_->OnTouchEvent(&press1); 1221 view_->OnTouchEvent(&press1);
1228 SendTouchEventACK(blink::WebInputEvent::TouchStart, 1222 SendTouchEventACK(blink::WebInputEvent::TouchStart,
1229 INPUT_EVENT_ACK_STATE_CONSUMED, 1223 INPUT_EVENT_ACK_STATE_CONSUMED,
1230 press1.unique_event_id()); 1224 press1.unique_event_id());
1231 EXPECT_EQ(ui::MotionEvent::ACTION_POINTER_DOWN, pointer_state().GetAction()); 1225 EXPECT_EQ(ui::MotionEvent::ACTION_POINTER_DOWN, pointer_state().GetAction());
1232 EXPECT_EQ(1, pointer_state().GetActionIndex()); 1226 EXPECT_EQ(1, pointer_state().GetActionIndex());
1233 EXPECT_EQ(2U, pointer_state().GetPointerCount()); 1227 EXPECT_EQ(2U, pointer_state().GetPointerCount());
1234 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); 1228 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount());
1235 1229
1236 // For the touchmove of second point, the state of the second touch point is 1230 // For the touchmove of second point, the state of the second touch point is
1237 // StateMoved, the state of the first touch point is StateStationary. 1231 // StateMoved, the state of the first touch point is StateStationary.
1238 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(30, 30), 1, 1232 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::PointF(30.f, 30.f), 1,
1239 ui::EventTimeForNow()); 1233 ui::EventTimeForNow());
1240 1234
1241 view_->OnTouchEvent(&move1); 1235 view_->OnTouchEvent(&move1);
1242 SendTouchEventACK(blink::WebInputEvent::TouchMove, 1236 SendTouchEventACK(blink::WebInputEvent::TouchMove,
1243 INPUT_EVENT_ACK_STATE_CONSUMED, 1237 INPUT_EVENT_ACK_STATE_CONSUMED,
1244 move1.unique_event_id()); 1238 move1.unique_event_id());
1245 EXPECT_EQ(ui::MotionEvent::ACTION_MOVE, pointer_state().GetAction()); 1239 EXPECT_EQ(ui::MotionEvent::ACTION_MOVE, pointer_state().GetAction());
1246 EXPECT_EQ(2U, pointer_state().GetPointerCount()); 1240 EXPECT_EQ(2U, pointer_state().GetPointerCount());
1247 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); 1241 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount());
1248 1242
1249 // For the touchmove of first point, the state of the first touch point is 1243 // For the touchmove of first point, the state of the first touch point is
1250 // StateMoved, the state of the second touch point is StateStationary. 1244 // StateMoved, the state of the second touch point is StateStationary.
1251 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(10, 10), 0, 1245 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::PointF(10.f, 10.f), 0,
1252 ui::EventTimeForNow()); 1246 ui::EventTimeForNow());
1253 1247
1254 view_->OnTouchEvent(&move2); 1248 view_->OnTouchEvent(&move2);
1255 SendTouchEventACK(blink::WebInputEvent::TouchMove, 1249 SendTouchEventACK(blink::WebInputEvent::TouchMove,
1256 INPUT_EVENT_ACK_STATE_CONSUMED, 1250 INPUT_EVENT_ACK_STATE_CONSUMED,
1257 move2.unique_event_id()); 1251 move2.unique_event_id());
1258 EXPECT_EQ(ui::MotionEvent::ACTION_MOVE, pointer_state().GetAction()); 1252 EXPECT_EQ(ui::MotionEvent::ACTION_MOVE, pointer_state().GetAction());
1259 EXPECT_EQ(2U, pointer_state().GetPointerCount()); 1253 EXPECT_EQ(2U, pointer_state().GetPointerCount());
1260 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); 1254 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount());
1261 1255
1262 ui::TouchEvent cancel0(ui::ET_TOUCH_CANCELLED, gfx::Point(10, 10), 0, 1256 ui::TouchEvent cancel0(ui::ET_TOUCH_CANCELLED, gfx::PointF(10.f, 10.f), 0,
1263 ui::EventTimeForNow()); 1257 ui::EventTimeForNow());
1264 1258
1265 // For the touchcancel, only the state of the current touch point is 1259 // For the touchcancel, only the state of the current touch point is
1266 // StateCancelled, the state of the other touch point is StateStationary. 1260 // StateCancelled, the state of the other touch point is StateStationary.
1267 view_->OnTouchEvent(&cancel0); 1261 view_->OnTouchEvent(&cancel0);
1268 EXPECT_EQ(1U, pointer_state().GetPointerCount()); 1262 EXPECT_EQ(1U, pointer_state().GetPointerCount());
1269 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); 1263 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount());
1270 1264
1271 ui::TouchEvent cancel1(ui::ET_TOUCH_CANCELLED, gfx::Point(30, 30), 1, 1265 ui::TouchEvent cancel1(ui::ET_TOUCH_CANCELLED, gfx::PointF(30.f, 30.f), 1,
1272 ui::EventTimeForNow()); 1266 ui::EventTimeForNow());
1273 1267
1274 view_->OnTouchEvent(&cancel1); 1268 view_->OnTouchEvent(&cancel1);
1275 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); 1269 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount());
1276 EXPECT_EQ(0U, pointer_state().GetPointerCount()); 1270 EXPECT_EQ(0U, pointer_state().GetPointerCount());
1277 } 1271 }
1278 1272
1279 // Checks that touch-events are queued properly when there is a touch-event 1273 // Checks that touch-events are queued properly when there is a touch-event
1280 // handler on the page. 1274 // handler on the page.
1281 TEST_F(RenderWidgetHostViewAuraTest, TouchEventSyncAsync) { 1275 TEST_F(RenderWidgetHostViewAuraTest, TouchEventSyncAsync) {
1282 view_->InitAsChild(NULL); 1276 view_->InitAsChild(NULL);
1283 view_->Show(); 1277 view_->Show();
1284 1278
1285 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); 1279 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true));
1286 1280
1287 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, 1281 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(30.f, 30.f), 0,
1288 gfx::Point(30, 30),
1289 0,
1290 ui::EventTimeForNow()); 1282 ui::EventTimeForNow());
1291 ui::TouchEvent move(ui::ET_TOUCH_MOVED, 1283 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(20.f, 20.f), 0,
1292 gfx::Point(20, 20),
1293 0,
1294 ui::EventTimeForNow()); 1284 ui::EventTimeForNow());
1295 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, 1285 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(20.f, 20.f), 0,
1296 gfx::Point(20, 20),
1297 0,
1298 ui::EventTimeForNow()); 1286 ui::EventTimeForNow());
1299 1287
1300 view_->OnTouchEvent(&press); 1288 view_->OnTouchEvent(&press);
1301 EXPECT_TRUE(press.synchronous_handling_disabled()); 1289 EXPECT_TRUE(press.synchronous_handling_disabled());
1302 EXPECT_EQ(ui::MotionEvent::ACTION_DOWN, pointer_state().GetAction()); 1290 EXPECT_EQ(ui::MotionEvent::ACTION_DOWN, pointer_state().GetAction());
1303 EXPECT_EQ(1U, pointer_state().GetPointerCount()); 1291 EXPECT_EQ(1U, pointer_state().GetPointerCount());
1304 1292
1305 view_->OnTouchEvent(&move); 1293 view_->OnTouchEvent(&move);
1306 EXPECT_TRUE(move.synchronous_handling_disabled()); 1294 EXPECT_TRUE(move.synchronous_handling_disabled());
1307 EXPECT_EQ(ui::MotionEvent::ACTION_MOVE, pointer_state().GetAction()); 1295 EXPECT_EQ(ui::MotionEvent::ACTION_MOVE, pointer_state().GetAction());
(...skipping 2130 matching lines...) Expand 10 before | Expand all | Expand 10 after
3438 // Tests that invalid touch events are consumed and handled 3426 // Tests that invalid touch events are consumed and handled
3439 // synchronously. 3427 // synchronously.
3440 TEST_F(RenderWidgetHostViewAuraTest, 3428 TEST_F(RenderWidgetHostViewAuraTest,
3441 InvalidEventsHaveSyncHandlingDisabled) { 3429 InvalidEventsHaveSyncHandlingDisabled) {
3442 view_->InitAsChild(NULL); 3430 view_->InitAsChild(NULL);
3443 view_->Show(); 3431 view_->Show();
3444 GetSentMessageCountAndResetSink(); 3432 GetSentMessageCountAndResetSink();
3445 3433
3446 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); 3434 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true));
3447 3435
3448 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, 3436 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(30.f, 30.f), 0,
3449 ui::EventTimeForNow()); 3437 ui::EventTimeForNow());
3450 3438
3451 // Construct a move with a touch id which doesn't exist. 3439 // Construct a move with a touch id which doesn't exist.
3452 ui::TouchEvent invalid_move(ui::ET_TOUCH_MOVED, gfx::Point(30, 30), 1, 3440 ui::TouchEvent invalid_move(ui::ET_TOUCH_MOVED, gfx::PointF(30.f, 30.f), 1,
3453 ui::EventTimeForNow()); 3441 ui::EventTimeForNow());
3454 3442
3455 // Valid press is handled asynchronously. 3443 // Valid press is handled asynchronously.
3456 view_->OnTouchEvent(&press); 3444 view_->OnTouchEvent(&press);
3457 EXPECT_TRUE(press.synchronous_handling_disabled()); 3445 EXPECT_TRUE(press.synchronous_handling_disabled());
3458 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 3446 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3459 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_CONSUMED); 3447 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_CONSUMED);
3460 3448
3461 // Invalid move is handled synchronously, but is consumed. It should not 3449 // Invalid move is handled synchronously, but is consumed. It should not
3462 // be forwarded to the renderer. 3450 // be forwarded to the renderer.
(...skipping 21 matching lines...) Expand all
3484 } 3472 }
3485 } 3473 }
3486 3474
3487 TEST_F(RenderWidgetHostViewAuraTest, SetCanScrollForWebMouseWheelEvent) { 3475 TEST_F(RenderWidgetHostViewAuraTest, SetCanScrollForWebMouseWheelEvent) {
3488 view_->InitAsChild(NULL); 3476 view_->InitAsChild(NULL);
3489 view_->Show(); 3477 view_->Show();
3490 3478
3491 sink_->ClearMessages(); 3479 sink_->ClearMessages();
3492 3480
3493 // Simulates the mouse wheel event with ctrl modifier applied. 3481 // Simulates the mouse wheel event with ctrl modifier applied.
3494 ui::MouseWheelEvent event(gfx::Vector2d(1, 1), gfx::Point(), gfx::Point(), 3482 ui::MouseWheelEvent event(gfx::Vector2d(1, 1), gfx::PointF(), gfx::PointF(),
3495 ui::EventTimeForNow(), ui::EF_CONTROL_DOWN, 0); 3483 ui::EventTimeForNow(), ui::EF_CONTROL_DOWN, 0);
3496 view_->OnMouseEvent(&event); 3484 view_->OnMouseEvent(&event);
3497 3485
3498 const WebInputEvent* input_event = 3486 const WebInputEvent* input_event =
3499 GetInputEventFromMessage(*sink_->GetMessageAt(0)); 3487 GetInputEventFromMessage(*sink_->GetMessageAt(0));
3500 const WebMouseWheelEvent* wheel_event = 3488 const WebMouseWheelEvent* wheel_event =
3501 static_cast<const WebMouseWheelEvent*>(input_event); 3489 static_cast<const WebMouseWheelEvent*>(input_event);
3502 // Check if the canScroll set to false when ctrl-scroll is generated from 3490 // Check if the canScroll set to false when ctrl-scroll is generated from
3503 // mouse wheel event. 3491 // mouse wheel event.
3504 EXPECT_FALSE(wheel_event->canScroll); 3492 EXPECT_FALSE(wheel_event->canScroll);
3505 sink_->ClearMessages(); 3493 sink_->ClearMessages();
3506 3494
3507 // Ack'ing the outstanding event should flush the pending event queue. 3495 // Ack'ing the outstanding event should flush the pending event queue.
3508 SendInputEventACK(blink::WebInputEvent::MouseWheel, 3496 SendInputEventACK(blink::WebInputEvent::MouseWheel,
3509 INPUT_EVENT_ACK_STATE_CONSUMED); 3497 INPUT_EVENT_ACK_STATE_CONSUMED);
3510 3498
3511 // Simulates the mouse wheel event with no modifier applied. 3499 // Simulates the mouse wheel event with no modifier applied.
3512 event = ui::MouseWheelEvent(gfx::Vector2d(1, 1), gfx::Point(), gfx::Point(), 3500 event = ui::MouseWheelEvent(gfx::Vector2d(1, 1), gfx::PointF(), gfx::PointF(),
3513 ui::EventTimeForNow(), ui::EF_NONE, 0); 3501 ui::EventTimeForNow(), ui::EF_NONE, 0);
3514 3502
3515 view_->OnMouseEvent(&event); 3503 view_->OnMouseEvent(&event);
3516 3504
3517 input_event = GetInputEventFromMessage(*sink_->GetMessageAt(0)); 3505 input_event = GetInputEventFromMessage(*sink_->GetMessageAt(0));
3518 wheel_event = static_cast<const WebMouseWheelEvent*>(input_event); 3506 wheel_event = static_cast<const WebMouseWheelEvent*>(input_event);
3519 // Check if the canScroll set to true when no modifier is applied to the 3507 // Check if the canScroll set to true when no modifier is applied to the
3520 // mouse wheel event. 3508 // mouse wheel event.
3521 EXPECT_TRUE(wheel_event->canScroll); 3509 EXPECT_TRUE(wheel_event->canScroll);
3522 sink_->ClearMessages(); 3510 sink_->ClearMessages();
3523 3511
3524 SendInputEventACK(blink::WebInputEvent::MouseWheel, 3512 SendInputEventACK(blink::WebInputEvent::MouseWheel,
3525 INPUT_EVENT_ACK_STATE_CONSUMED); 3513 INPUT_EVENT_ACK_STATE_CONSUMED);
3526 3514
3527 // Simulates the scroll event with ctrl modifier applied. 3515 // Simulates the scroll event with ctrl modifier applied.
3528 ui::ScrollEvent scroll(ui::ET_SCROLL, gfx::Point(2, 2), ui::EventTimeForNow(), 3516 ui::ScrollEvent scroll(ui::ET_SCROLL, gfx::PointF(2.f, 2.f),
3529 ui::EF_CONTROL_DOWN, 0, 5, 0, 5, 2); 3517 ui::EventTimeForNow(), ui::EF_CONTROL_DOWN, 0, 5, 0, 5,
3518 2);
3530 view_->OnScrollEvent(&scroll); 3519 view_->OnScrollEvent(&scroll);
3531 3520
3532 input_event = GetInputEventFromMessage(*sink_->GetMessageAt(0)); 3521 input_event = GetInputEventFromMessage(*sink_->GetMessageAt(0));
3533 wheel_event = static_cast<const WebMouseWheelEvent*>(input_event); 3522 wheel_event = static_cast<const WebMouseWheelEvent*>(input_event);
3534 // Check if the canScroll set to true when ctrl-touchpad-scroll is generated 3523 // Check if the canScroll set to true when ctrl-touchpad-scroll is generated
3535 // from scroll event. 3524 // from scroll event.
3536 EXPECT_TRUE(wheel_event->canScroll); 3525 EXPECT_TRUE(wheel_event->canScroll);
3537 } 3526 }
3538 3527
3539 // Ensures that the mapping from ui::TouchEvent to blink::WebTouchEvent doesn't 3528 // Ensures that the mapping from ui::TouchEvent to blink::WebTouchEvent doesn't
3540 // lose track of the number of acks required. 3529 // lose track of the number of acks required.
3541 TEST_F(RenderWidgetHostViewAuraTest, CorrectNumberOfAcksAreDispatched) { 3530 TEST_F(RenderWidgetHostViewAuraTest, CorrectNumberOfAcksAreDispatched) {
3542 view_->InitAsFullscreen(parent_view_); 3531 view_->InitAsFullscreen(parent_view_);
3543 view_->Show(); 3532 view_->Show();
3544 view_->UseFakeDispatcher(); 3533 view_->UseFakeDispatcher();
3545 3534
3546 ui::TouchEvent press1( 3535 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(30.f, 30.f), 0,
3547 ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, ui::EventTimeForNow()); 3536 ui::EventTimeForNow());
3548 3537
3549 view_->OnTouchEvent(&press1); 3538 view_->OnTouchEvent(&press1);
3550 SendTouchEventACK(blink::WebInputEvent::TouchStart, 3539 SendTouchEventACK(blink::WebInputEvent::TouchStart,
3551 INPUT_EVENT_ACK_STATE_CONSUMED, press1.unique_event_id()); 3540 INPUT_EVENT_ACK_STATE_CONSUMED, press1.unique_event_id());
3552 3541
3553 ui::TouchEvent press2( 3542 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(20.f, 20.f), 1,
3554 ui::ET_TOUCH_PRESSED, gfx::Point(20, 20), 1, ui::EventTimeForNow()); 3543 ui::EventTimeForNow());
3555 view_->OnTouchEvent(&press2); 3544 view_->OnTouchEvent(&press2);
3556 SendTouchEventACK(blink::WebInputEvent::TouchStart, 3545 SendTouchEventACK(blink::WebInputEvent::TouchStart,
3557 INPUT_EVENT_ACK_STATE_CONSUMED, press2.unique_event_id()); 3546 INPUT_EVENT_ACK_STATE_CONSUMED, press2.unique_event_id());
3558 3547
3559 EXPECT_EQ(2U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); 3548 EXPECT_EQ(2U, view_->dispatcher_->GetAndResetProcessedTouchEventCount());
3560 } 3549 }
3561 3550
3562 // Tests that the scroll deltas stored within the overscroll controller get 3551 // Tests that the scroll deltas stored within the overscroll controller get
3563 // reset at the end of the overscroll gesture even if the overscroll threshold 3552 // reset at the end of the overscroll gesture even if the overscroll threshold
3564 // isn't surpassed and the overscroll mode stays OVERSCROLL_NONE. 3553 // isn't surpassed and the overscroll mode stays OVERSCROLL_NONE.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
3618 ViewMsg_SetSurfaceIdNamespace::Read(msg, &params); 3607 ViewMsg_SetSurfaceIdNamespace::Read(msg, &params);
3619 view_->InitAsChild(NULL); 3608 view_->InitAsChild(NULL);
3620 view_->Show(); 3609 view_->Show();
3621 view_->SetSize(size); 3610 view_->SetSize(size);
3622 view_->OnSwapCompositorFrame(0, 3611 view_->OnSwapCompositorFrame(0,
3623 MakeDelegatedFrame(1.f, size, gfx::Rect(size))); 3612 MakeDelegatedFrame(1.f, size, gfx::Rect(size)));
3624 EXPECT_EQ(view_->GetSurfaceIdNamespace(), base::get<0>(params)); 3613 EXPECT_EQ(view_->GetSurfaceIdNamespace(), base::get<0>(params));
3625 } 3614 }
3626 3615
3627 } // namespace content 3616 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698