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

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-event: mandol_line Created 5 years, 1 month 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::PointF(), gfx::PointF(), 1086 ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(),
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, gfx::PointF(30.f, 30.f), 0, 1113 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0,
1114 ui::EventTimeForNow()); 1114 ui::EventTimeForNow());
1115 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(20.f, 20.f), 0, 1115 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0,
1116 ui::EventTimeForNow()); 1116 ui::EventTimeForNow());
1117 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(20.f, 20.f), 0, 1117 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(20, 20), 0,
1118 ui::EventTimeForNow()); 1118 ui::EventTimeForNow());
1119 1119
1120 // 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
1121 // reach the renderer. 1121 // reach the renderer.
1122 view_->OnTouchEvent(&press); 1122 view_->OnTouchEvent(&press);
1123 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); 1123 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
1124 EXPECT_TRUE(press.synchronous_handling_disabled()); 1124 EXPECT_TRUE(press.synchronous_handling_disabled());
1125 EXPECT_EQ(ui::MotionEvent::ACTION_DOWN, pointer_state().GetAction()); 1125 EXPECT_EQ(ui::MotionEvent::ACTION_DOWN, pointer_state().GetAction());
1126 1126
1127 view_->OnTouchEvent(&move); 1127 view_->OnTouchEvent(&move);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 1162
1163 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); 1163 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false));
1164 1164
1165 // Ack'ing the outstanding event should flush the pending touch queue. 1165 // Ack'ing the outstanding event should flush the pending touch queue.
1166 InputEventAck ack(blink::WebInputEvent::TouchStart, 1166 InputEventAck ack(blink::WebInputEvent::TouchStart,
1167 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, 1167 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS,
1168 press.unique_event_id()); 1168 press.unique_event_id());
1169 widget_host_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack)); 1169 widget_host_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack));
1170 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); 1170 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
1171 1171
1172 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::PointF(20.f, 20.f), 0, 1172 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0,
1173 base::Time::NowFromSystemTime() - base::Time()); 1173 base::Time::NowFromSystemTime() - base::Time());
1174 view_->OnTouchEvent(&move2); 1174 view_->OnTouchEvent(&move2);
1175 EXPECT_TRUE(press.synchronous_handling_disabled()); 1175 EXPECT_TRUE(press.synchronous_handling_disabled());
1176 EXPECT_EQ(ui::MotionEvent::ACTION_MOVE, pointer_state().GetAction()); 1176 EXPECT_EQ(ui::MotionEvent::ACTION_MOVE, pointer_state().GetAction());
1177 EXPECT_EQ(1U, pointer_state().GetPointerCount()); 1177 EXPECT_EQ(1U, pointer_state().GetPointerCount());
1178 1178
1179 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::PointF(20.f, 20.f), 0, 1179 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(20, 20), 0,
1180 base::Time::NowFromSystemTime() - base::Time()); 1180 base::Time::NowFromSystemTime() - base::Time());
1181 view_->OnTouchEvent(&release2); 1181 view_->OnTouchEvent(&release2);
1182 EXPECT_TRUE(press.synchronous_handling_disabled()); 1182 EXPECT_TRUE(press.synchronous_handling_disabled());
1183 EXPECT_EQ(0U, pointer_state().GetPointerCount()); 1183 EXPECT_EQ(0U, pointer_state().GetPointerCount());
1184 } 1184 }
1185 1185
1186 // Checks that touch-event state is maintained correctly for multiple touch 1186 // Checks that touch-event state is maintained correctly for multiple touch
1187 // points. 1187 // points.
1188 TEST_F(RenderWidgetHostViewAuraTest, MultiTouchPointsStates) { 1188 TEST_F(RenderWidgetHostViewAuraTest, MultiTouchPointsStates) {
1189 view_->InitAsFullscreen(parent_view_); 1189 view_->InitAsFullscreen(parent_view_);
1190 view_->Show(); 1190 view_->Show();
1191 view_->UseFakeDispatcher(); 1191 view_->UseFakeDispatcher();
1192 GetSentMessageCountAndResetSink(); 1192 GetSentMessageCountAndResetSink();
1193 1193
1194 ui::TouchEvent press0(ui::ET_TOUCH_PRESSED, gfx::PointF(30.f, 30.f), 0, 1194 ui::TouchEvent press0(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0,
1195 ui::EventTimeForNow()); 1195 ui::EventTimeForNow());
1196 1196
1197 view_->OnTouchEvent(&press0); 1197 view_->OnTouchEvent(&press0);
1198 SendTouchEventACK(blink::WebInputEvent::TouchStart, 1198 SendTouchEventACK(blink::WebInputEvent::TouchStart,
1199 INPUT_EVENT_ACK_STATE_CONSUMED, 1199 INPUT_EVENT_ACK_STATE_CONSUMED,
1200 press0.unique_event_id()); 1200 press0.unique_event_id());
1201 EXPECT_EQ(ui::MotionEvent::ACTION_DOWN, pointer_state().GetAction()); 1201 EXPECT_EQ(ui::MotionEvent::ACTION_DOWN, pointer_state().GetAction());
1202 EXPECT_EQ(1U, pointer_state().GetPointerCount()); 1202 EXPECT_EQ(1U, pointer_state().GetPointerCount());
1203 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); 1203 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount());
1204 1204
1205 ui::TouchEvent move0(ui::ET_TOUCH_MOVED, gfx::PointF(20.f, 20.f), 0, 1205 ui::TouchEvent move0(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0,
1206 ui::EventTimeForNow()); 1206 ui::EventTimeForNow());
1207 1207
1208 view_->OnTouchEvent(&move0); 1208 view_->OnTouchEvent(&move0);
1209 SendTouchEventACK(blink::WebInputEvent::TouchMove, 1209 SendTouchEventACK(blink::WebInputEvent::TouchMove,
1210 INPUT_EVENT_ACK_STATE_CONSUMED, 1210 INPUT_EVENT_ACK_STATE_CONSUMED,
1211 move0.unique_event_id()); 1211 move0.unique_event_id());
1212 EXPECT_EQ(ui::MotionEvent::ACTION_MOVE, pointer_state().GetAction()); 1212 EXPECT_EQ(ui::MotionEvent::ACTION_MOVE, pointer_state().GetAction());
1213 EXPECT_EQ(1U, pointer_state().GetPointerCount()); 1213 EXPECT_EQ(1U, pointer_state().GetPointerCount());
1214 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); 1214 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount());
1215 1215
1216 // 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
1217 // StatePressed, the state of the first touch point is StateStationary. 1217 // StatePressed, the state of the first touch point is StateStationary.
1218 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(10.f, 10.f), 1, 1218 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1,
1219 ui::EventTimeForNow()); 1219 ui::EventTimeForNow());
1220 1220
1221 view_->OnTouchEvent(&press1); 1221 view_->OnTouchEvent(&press1);
1222 SendTouchEventACK(blink::WebInputEvent::TouchStart, 1222 SendTouchEventACK(blink::WebInputEvent::TouchStart,
1223 INPUT_EVENT_ACK_STATE_CONSUMED, 1223 INPUT_EVENT_ACK_STATE_CONSUMED,
1224 press1.unique_event_id()); 1224 press1.unique_event_id());
1225 EXPECT_EQ(ui::MotionEvent::ACTION_POINTER_DOWN, pointer_state().GetAction()); 1225 EXPECT_EQ(ui::MotionEvent::ACTION_POINTER_DOWN, pointer_state().GetAction());
1226 EXPECT_EQ(1, pointer_state().GetActionIndex()); 1226 EXPECT_EQ(1, pointer_state().GetActionIndex());
1227 EXPECT_EQ(2U, pointer_state().GetPointerCount()); 1227 EXPECT_EQ(2U, pointer_state().GetPointerCount());
1228 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); 1228 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount());
1229 1229
1230 // 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
1231 // StateMoved, the state of the first touch point is StateStationary. 1231 // StateMoved, the state of the first touch point is StateStationary.
1232 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::PointF(30.f, 30.f), 1, 1232 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(30, 30), 1,
1233 ui::EventTimeForNow()); 1233 ui::EventTimeForNow());
1234 1234
1235 view_->OnTouchEvent(&move1); 1235 view_->OnTouchEvent(&move1);
1236 SendTouchEventACK(blink::WebInputEvent::TouchMove, 1236 SendTouchEventACK(blink::WebInputEvent::TouchMove,
1237 INPUT_EVENT_ACK_STATE_CONSUMED, 1237 INPUT_EVENT_ACK_STATE_CONSUMED,
1238 move1.unique_event_id()); 1238 move1.unique_event_id());
1239 EXPECT_EQ(ui::MotionEvent::ACTION_MOVE, pointer_state().GetAction()); 1239 EXPECT_EQ(ui::MotionEvent::ACTION_MOVE, pointer_state().GetAction());
1240 EXPECT_EQ(2U, pointer_state().GetPointerCount()); 1240 EXPECT_EQ(2U, pointer_state().GetPointerCount());
1241 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); 1241 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount());
1242 1242
1243 // 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
1244 // StateMoved, the state of the second touch point is StateStationary. 1244 // StateMoved, the state of the second touch point is StateStationary.
1245 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::PointF(10.f, 10.f), 0, 1245 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(10, 10), 0,
1246 ui::EventTimeForNow()); 1246 ui::EventTimeForNow());
1247 1247
1248 view_->OnTouchEvent(&move2); 1248 view_->OnTouchEvent(&move2);
1249 SendTouchEventACK(blink::WebInputEvent::TouchMove, 1249 SendTouchEventACK(blink::WebInputEvent::TouchMove,
1250 INPUT_EVENT_ACK_STATE_CONSUMED, 1250 INPUT_EVENT_ACK_STATE_CONSUMED,
1251 move2.unique_event_id()); 1251 move2.unique_event_id());
1252 EXPECT_EQ(ui::MotionEvent::ACTION_MOVE, pointer_state().GetAction()); 1252 EXPECT_EQ(ui::MotionEvent::ACTION_MOVE, pointer_state().GetAction());
1253 EXPECT_EQ(2U, pointer_state().GetPointerCount()); 1253 EXPECT_EQ(2U, pointer_state().GetPointerCount());
1254 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); 1254 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount());
1255 1255
1256 ui::TouchEvent cancel0(ui::ET_TOUCH_CANCELLED, gfx::PointF(10.f, 10.f), 0, 1256 ui::TouchEvent cancel0(ui::ET_TOUCH_CANCELLED, gfx::Point(10, 10), 0,
1257 ui::EventTimeForNow()); 1257 ui::EventTimeForNow());
1258 1258
1259 // 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
1260 // StateCancelled, the state of the other touch point is StateStationary. 1260 // StateCancelled, the state of the other touch point is StateStationary.
1261 view_->OnTouchEvent(&cancel0); 1261 view_->OnTouchEvent(&cancel0);
1262 EXPECT_EQ(1U, pointer_state().GetPointerCount()); 1262 EXPECT_EQ(1U, pointer_state().GetPointerCount());
1263 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); 1263 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount());
1264 1264
1265 ui::TouchEvent cancel1(ui::ET_TOUCH_CANCELLED, gfx::PointF(30.f, 30.f), 1, 1265 ui::TouchEvent cancel1(ui::ET_TOUCH_CANCELLED, gfx::Point(30, 30), 1,
1266 ui::EventTimeForNow()); 1266 ui::EventTimeForNow());
1267 1267
1268 view_->OnTouchEvent(&cancel1); 1268 view_->OnTouchEvent(&cancel1);
1269 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); 1269 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount());
1270 EXPECT_EQ(0U, pointer_state().GetPointerCount()); 1270 EXPECT_EQ(0U, pointer_state().GetPointerCount());
1271 } 1271 }
1272 1272
1273 // 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
1274 // handler on the page. 1274 // handler on the page.
1275 TEST_F(RenderWidgetHostViewAuraTest, TouchEventSyncAsync) { 1275 TEST_F(RenderWidgetHostViewAuraTest, TouchEventSyncAsync) {
1276 view_->InitAsChild(NULL); 1276 view_->InitAsChild(NULL);
1277 view_->Show(); 1277 view_->Show();
1278 1278
1279 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); 1279 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true));
1280 1280
1281 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(30.f, 30.f), 0, 1281 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0,
1282 ui::EventTimeForNow()); 1282 ui::EventTimeForNow());
1283 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(20.f, 20.f), 0, 1283 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0,
1284 ui::EventTimeForNow()); 1284 ui::EventTimeForNow());
1285 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(20.f, 20.f), 0, 1285 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(20, 20), 0,
1286 ui::EventTimeForNow()); 1286 ui::EventTimeForNow());
1287 1287
1288 view_->OnTouchEvent(&press); 1288 view_->OnTouchEvent(&press);
1289 EXPECT_TRUE(press.synchronous_handling_disabled()); 1289 EXPECT_TRUE(press.synchronous_handling_disabled());
1290 EXPECT_EQ(ui::MotionEvent::ACTION_DOWN, pointer_state().GetAction()); 1290 EXPECT_EQ(ui::MotionEvent::ACTION_DOWN, pointer_state().GetAction());
1291 EXPECT_EQ(1U, pointer_state().GetPointerCount()); 1291 EXPECT_EQ(1U, pointer_state().GetPointerCount());
1292 1292
1293 view_->OnTouchEvent(&move); 1293 view_->OnTouchEvent(&move);
1294 EXPECT_TRUE(move.synchronous_handling_disabled()); 1294 EXPECT_TRUE(move.synchronous_handling_disabled());
1295 EXPECT_EQ(ui::MotionEvent::ACTION_MOVE, pointer_state().GetAction()); 1295 EXPECT_EQ(ui::MotionEvent::ACTION_MOVE, pointer_state().GetAction());
(...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after
2478 } 2478 }
2479 2479
2480 // Ensures that touch event positions are never truncated to integers. 2480 // Ensures that touch event positions are never truncated to integers.
2481 TEST_F(RenderWidgetHostViewAuraTest, TouchEventPositionsArentRounded) { 2481 TEST_F(RenderWidgetHostViewAuraTest, TouchEventPositionsArentRounded) {
2482 const float kX = 30.58f; 2482 const float kX = 30.58f;
2483 const float kY = 50.23f; 2483 const float kY = 50.23f;
2484 2484
2485 view_->InitAsChild(NULL); 2485 view_->InitAsChild(NULL);
2486 view_->Show(); 2486 view_->Show();
2487 2487
2488 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, 2488 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(), 0,
2489 gfx::PointF(kX, kY),
2490 0,
2491 ui::EventTimeForNow()); 2489 ui::EventTimeForNow());
2490 press.set_location_f(gfx::PointF(kX, kY));
2491 press.set_root_location_f(gfx::PointF(kX, kY));
2492 2492
2493 view_->OnTouchEvent(&press); 2493 view_->OnTouchEvent(&press);
2494 EXPECT_EQ(ui::MotionEvent::ACTION_DOWN, pointer_state().GetAction()); 2494 EXPECT_EQ(ui::MotionEvent::ACTION_DOWN, pointer_state().GetAction());
2495 EXPECT_EQ(1U, pointer_state().GetPointerCount()); 2495 EXPECT_EQ(1U, pointer_state().GetPointerCount());
2496 EXPECT_EQ(kX, pointer_state().GetX(0)); 2496 EXPECT_EQ(kX, pointer_state().GetX(0));
2497 EXPECT_EQ(kY, pointer_state().GetY(0)); 2497 EXPECT_EQ(kY, pointer_state().GetY(0));
2498 } 2498 }
2499 2499
2500 // Tests that scroll ACKs are correctly handled by the overscroll-navigation 2500 // Tests that scroll ACKs are correctly handled by the overscroll-navigation
2501 // controller. 2501 // controller.
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after
3422 // Tests that invalid touch events are consumed and handled 3422 // Tests that invalid touch events are consumed and handled
3423 // synchronously. 3423 // synchronously.
3424 TEST_F(RenderWidgetHostViewAuraTest, 3424 TEST_F(RenderWidgetHostViewAuraTest,
3425 InvalidEventsHaveSyncHandlingDisabled) { 3425 InvalidEventsHaveSyncHandlingDisabled) {
3426 view_->InitAsChild(NULL); 3426 view_->InitAsChild(NULL);
3427 view_->Show(); 3427 view_->Show();
3428 GetSentMessageCountAndResetSink(); 3428 GetSentMessageCountAndResetSink();
3429 3429
3430 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); 3430 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true));
3431 3431
3432 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(30.f, 30.f), 0, 3432 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0,
3433 ui::EventTimeForNow()); 3433 ui::EventTimeForNow());
3434 3434
3435 // Construct a move with a touch id which doesn't exist. 3435 // Construct a move with a touch id which doesn't exist.
3436 ui::TouchEvent invalid_move(ui::ET_TOUCH_MOVED, gfx::PointF(30.f, 30.f), 1, 3436 ui::TouchEvent invalid_move(ui::ET_TOUCH_MOVED, gfx::Point(30, 30), 1,
3437 ui::EventTimeForNow()); 3437 ui::EventTimeForNow());
3438 3438
3439 // Valid press is handled asynchronously. 3439 // Valid press is handled asynchronously.
3440 view_->OnTouchEvent(&press); 3440 view_->OnTouchEvent(&press);
3441 EXPECT_TRUE(press.synchronous_handling_disabled()); 3441 EXPECT_TRUE(press.synchronous_handling_disabled());
3442 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 3442 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3443 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_CONSUMED); 3443 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_CONSUMED);
3444 3444
3445 // Invalid move is handled synchronously, but is consumed. It should not 3445 // Invalid move is handled synchronously, but is consumed. It should not
3446 // be forwarded to the renderer. 3446 // be forwarded to the renderer.
(...skipping 21 matching lines...) Expand all
3468 } 3468 }
3469 } 3469 }
3470 3470
3471 TEST_F(RenderWidgetHostViewAuraTest, SetCanScrollForWebMouseWheelEvent) { 3471 TEST_F(RenderWidgetHostViewAuraTest, SetCanScrollForWebMouseWheelEvent) {
3472 view_->InitAsChild(NULL); 3472 view_->InitAsChild(NULL);
3473 view_->Show(); 3473 view_->Show();
3474 3474
3475 sink_->ClearMessages(); 3475 sink_->ClearMessages();
3476 3476
3477 // Simulates the mouse wheel event with ctrl modifier applied. 3477 // Simulates the mouse wheel event with ctrl modifier applied.
3478 ui::MouseWheelEvent event(gfx::Vector2d(1, 1), gfx::PointF(), gfx::PointF(), 3478 ui::MouseWheelEvent event(gfx::Vector2d(1, 1), gfx::Point(), gfx::Point(),
3479 ui::EventTimeForNow(), ui::EF_CONTROL_DOWN, 0); 3479 ui::EventTimeForNow(), ui::EF_CONTROL_DOWN, 0);
3480 view_->OnMouseEvent(&event); 3480 view_->OnMouseEvent(&event);
3481 3481
3482 const WebInputEvent* input_event = 3482 const WebInputEvent* input_event =
3483 GetInputEventFromMessage(*sink_->GetMessageAt(0)); 3483 GetInputEventFromMessage(*sink_->GetMessageAt(0));
3484 const WebMouseWheelEvent* wheel_event = 3484 const WebMouseWheelEvent* wheel_event =
3485 static_cast<const WebMouseWheelEvent*>(input_event); 3485 static_cast<const WebMouseWheelEvent*>(input_event);
3486 // Check if the canScroll set to false when ctrl-scroll is generated from 3486 // Check if the canScroll set to false when ctrl-scroll is generated from
3487 // mouse wheel event. 3487 // mouse wheel event.
3488 EXPECT_FALSE(wheel_event->canScroll); 3488 EXPECT_FALSE(wheel_event->canScroll);
3489 sink_->ClearMessages(); 3489 sink_->ClearMessages();
3490 3490
3491 // Ack'ing the outstanding event should flush the pending event queue. 3491 // Ack'ing the outstanding event should flush the pending event queue.
3492 SendInputEventACK(blink::WebInputEvent::MouseWheel, 3492 SendInputEventACK(blink::WebInputEvent::MouseWheel,
3493 INPUT_EVENT_ACK_STATE_CONSUMED); 3493 INPUT_EVENT_ACK_STATE_CONSUMED);
3494 3494
3495 // Simulates the mouse wheel event with no modifier applied. 3495 // Simulates the mouse wheel event with no modifier applied.
3496 event = ui::MouseWheelEvent(gfx::Vector2d(1, 1), gfx::PointF(), gfx::PointF(), 3496 event = ui::MouseWheelEvent(gfx::Vector2d(1, 1), gfx::Point(), gfx::Point(),
3497 ui::EventTimeForNow(), ui::EF_NONE, 0); 3497 ui::EventTimeForNow(), ui::EF_NONE, 0);
3498 3498
3499 view_->OnMouseEvent(&event); 3499 view_->OnMouseEvent(&event);
3500 3500
3501 input_event = GetInputEventFromMessage(*sink_->GetMessageAt(0)); 3501 input_event = GetInputEventFromMessage(*sink_->GetMessageAt(0));
3502 wheel_event = static_cast<const WebMouseWheelEvent*>(input_event); 3502 wheel_event = static_cast<const WebMouseWheelEvent*>(input_event);
3503 // Check if the canScroll set to true when no modifier is applied to the 3503 // Check if the canScroll set to true when no modifier is applied to the
3504 // mouse wheel event. 3504 // mouse wheel event.
3505 EXPECT_TRUE(wheel_event->canScroll); 3505 EXPECT_TRUE(wheel_event->canScroll);
3506 sink_->ClearMessages(); 3506 sink_->ClearMessages();
3507 3507
3508 SendInputEventACK(blink::WebInputEvent::MouseWheel, 3508 SendInputEventACK(blink::WebInputEvent::MouseWheel,
3509 INPUT_EVENT_ACK_STATE_CONSUMED); 3509 INPUT_EVENT_ACK_STATE_CONSUMED);
3510 3510
3511 // Simulates the scroll event with ctrl modifier applied. 3511 // Simulates the scroll event with ctrl modifier applied.
3512 ui::ScrollEvent scroll(ui::ET_SCROLL, gfx::PointF(2.f, 2.f), 3512 ui::ScrollEvent scroll(ui::ET_SCROLL, gfx::Point(2, 2), ui::EventTimeForNow(),
3513 ui::EventTimeForNow(), ui::EF_CONTROL_DOWN, 0, 5, 0, 5, 3513 ui::EF_CONTROL_DOWN, 0, 5, 0, 5, 2);
3514 2);
3515 view_->OnScrollEvent(&scroll); 3514 view_->OnScrollEvent(&scroll);
3516 3515
3517 input_event = GetInputEventFromMessage(*sink_->GetMessageAt(0)); 3516 input_event = GetInputEventFromMessage(*sink_->GetMessageAt(0));
3518 wheel_event = static_cast<const WebMouseWheelEvent*>(input_event); 3517 wheel_event = static_cast<const WebMouseWheelEvent*>(input_event);
3519 // Check if the canScroll set to true when ctrl-touchpad-scroll is generated 3518 // Check if the canScroll set to true when ctrl-touchpad-scroll is generated
3520 // from scroll event. 3519 // from scroll event.
3521 EXPECT_TRUE(wheel_event->canScroll); 3520 EXPECT_TRUE(wheel_event->canScroll);
3522 } 3521 }
3523 3522
3524 // Ensures that the mapping from ui::TouchEvent to blink::WebTouchEvent doesn't 3523 // Ensures that the mapping from ui::TouchEvent to blink::WebTouchEvent doesn't
3525 // lose track of the number of acks required. 3524 // lose track of the number of acks required.
3526 TEST_F(RenderWidgetHostViewAuraTest, CorrectNumberOfAcksAreDispatched) { 3525 TEST_F(RenderWidgetHostViewAuraTest, CorrectNumberOfAcksAreDispatched) {
3527 view_->InitAsFullscreen(parent_view_); 3526 view_->InitAsFullscreen(parent_view_);
3528 view_->Show(); 3527 view_->Show();
3529 view_->UseFakeDispatcher(); 3528 view_->UseFakeDispatcher();
3530 3529
3531 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::PointF(30.f, 30.f), 0, 3530 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0,
3532 ui::EventTimeForNow()); 3531 ui::EventTimeForNow());
3533 3532
3534 view_->OnTouchEvent(&press1); 3533 view_->OnTouchEvent(&press1);
3535 SendTouchEventACK(blink::WebInputEvent::TouchStart, 3534 SendTouchEventACK(blink::WebInputEvent::TouchStart,
3536 INPUT_EVENT_ACK_STATE_CONSUMED, press1.unique_event_id()); 3535 INPUT_EVENT_ACK_STATE_CONSUMED, press1.unique_event_id());
3537 3536
3538 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::PointF(20.f, 20.f), 1, 3537 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(20, 20), 1,
3539 ui::EventTimeForNow()); 3538 ui::EventTimeForNow());
3540 view_->OnTouchEvent(&press2); 3539 view_->OnTouchEvent(&press2);
3541 SendTouchEventACK(blink::WebInputEvent::TouchStart, 3540 SendTouchEventACK(blink::WebInputEvent::TouchStart,
3542 INPUT_EVENT_ACK_STATE_CONSUMED, press2.unique_event_id()); 3541 INPUT_EVENT_ACK_STATE_CONSUMED, press2.unique_event_id());
3543 3542
3544 EXPECT_EQ(2U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); 3543 EXPECT_EQ(2U, view_->dispatcher_->GetAndResetProcessedTouchEventCount());
3545 } 3544 }
3546 3545
3547 // Tests that the scroll deltas stored within the overscroll controller get 3546 // Tests that the scroll deltas stored within the overscroll controller get
3548 // reset at the end of the overscroll gesture even if the overscroll threshold 3547 // reset at the end of the overscroll gesture even if the overscroll threshold
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3603 ViewMsg_SetSurfaceIdNamespace::Read(msg, &params); 3602 ViewMsg_SetSurfaceIdNamespace::Read(msg, &params);
3604 view_->InitAsChild(NULL); 3603 view_->InitAsChild(NULL);
3605 view_->Show(); 3604 view_->Show();
3606 view_->SetSize(size); 3605 view_->SetSize(size);
3607 view_->OnSwapCompositorFrame(0, 3606 view_->OnSwapCompositorFrame(0,
3608 MakeDelegatedFrame(1.f, size, gfx::Rect(size))); 3607 MakeDelegatedFrame(1.f, size, gfx::Rect(size)));
3609 EXPECT_EQ(view_->GetSurfaceIdNamespace(), base::get<0>(params)); 3608 EXPECT_EQ(view_->GetSurfaceIdNamespace(), base::get<0>(params));
3610 } 3609 }
3611 3610
3612 } // namespace content 3611 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698