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

Side by Side Diff: content/common/input/event_with_latency_info_unittest.cc

Issue 2782893002: WebMouseEvent coordinates are now fractional & private (Closed)
Patch Set: Fixed compile failures. Created 3 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/common/input/event_with_latency_info.h" 5 #include "content/common/input/event_with_latency_info.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/WebKit/public/platform/WebInputEvent.h" 10 #include "third_party/WebKit/public/platform/WebInputEvent.h"
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 // deltaY should coalesce. 303 // deltaY should coalesce.
304 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1)); 304 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1));
305 305
306 // WebMouseWheelEvent objects with different modifiers should not coalesce. 306 // WebMouseWheelEvent objects with different modifiers should not coalesce.
307 mouse_wheel_0 = CreateMouseWheelEvent(2.0, 1, 1, WebInputEvent::ControlKey); 307 mouse_wheel_0 = CreateMouseWheelEvent(2.0, 1, 1, WebInputEvent::ControlKey);
308 mouse_wheel_1 = CreateMouseWheelEvent(2.0, 1, 1, WebInputEvent::ShiftKey); 308 mouse_wheel_1 = CreateMouseWheelEvent(2.0, 1, 1, WebInputEvent::ShiftKey);
309 EXPECT_FALSE(CanCoalesce(mouse_wheel_0, mouse_wheel_1)); 309 EXPECT_FALSE(CanCoalesce(mouse_wheel_0, mouse_wheel_1));
310 310
311 // Coalesce old and new events. 311 // Coalesce old and new events.
312 mouse_wheel_0 = CreateMouseWheel(1, 1); 312 mouse_wheel_0 = CreateMouseWheel(1, 1);
313 mouse_wheel_0.event.x = 1; 313 mouse_wheel_0.event.position.x = 1;
314 mouse_wheel_0.event.y = 1; 314 mouse_wheel_0.event.position.y = 1;
315 mouse_wheel_1 = CreateMouseWheel(2, 2); 315 mouse_wheel_1 = CreateMouseWheel(2, 2);
316 mouse_wheel_1.event.x = 2; 316 mouse_wheel_1.event.position.x = 2;
317 mouse_wheel_1.event.y = 2; 317 mouse_wheel_1.event.position.y = 2;
318 MouseWheelEventWithLatencyInfo mouse_wheel_1_copy = mouse_wheel_1; 318 MouseWheelEventWithLatencyInfo mouse_wheel_1_copy = mouse_wheel_1;
319 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1)); 319 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1));
320 EXPECT_EQ(mouse_wheel_0.event.modifiers(), mouse_wheel_1.event.modifiers()); 320 EXPECT_EQ(mouse_wheel_0.event.modifiers(), mouse_wheel_1.event.modifiers());
321 EXPECT_EQ(mouse_wheel_0.event.scrollByPage, mouse_wheel_1.event.scrollByPage); 321 EXPECT_EQ(mouse_wheel_0.event.scrollByPage, mouse_wheel_1.event.scrollByPage);
322 EXPECT_EQ(mouse_wheel_0.event.phase, mouse_wheel_1.event.phase); 322 EXPECT_EQ(mouse_wheel_0.event.phase, mouse_wheel_1.event.phase);
323 EXPECT_EQ(mouse_wheel_0.event.momentumPhase, 323 EXPECT_EQ(mouse_wheel_0.event.momentumPhase,
324 mouse_wheel_1.event.momentumPhase); 324 mouse_wheel_1.event.momentumPhase);
325 EXPECT_EQ(mouse_wheel_0.event.hasPreciseScrollingDeltas, 325 EXPECT_EQ(mouse_wheel_0.event.hasPreciseScrollingDeltas,
326 mouse_wheel_1.event.hasPreciseScrollingDeltas); 326 mouse_wheel_1.event.hasPreciseScrollingDeltas);
327 Coalesce(mouse_wheel_0, &mouse_wheel_1); 327 Coalesce(mouse_wheel_0, &mouse_wheel_1);
328 328
329 // Coalesced event has the position of the most recent event. 329 // Coalesced event has the position of the most recent event.
330 EXPECT_EQ(1, mouse_wheel_1.event.x); 330 EXPECT_EQ(1, mouse_wheel_1.event.position.x);
331 EXPECT_EQ(1, mouse_wheel_1.event.y); 331 EXPECT_EQ(1, mouse_wheel_1.event.position.y);
332 332
333 // deltaX/Y, wheelTicksX/Y, and movementX/Y of the coalesced event are 333 // deltaX/Y, wheelTicksX/Y, and movementX/Y of the coalesced event are
334 // calculated properly. 334 // calculated properly.
335 EXPECT_EQ(mouse_wheel_1_copy.event.deltaX + mouse_wheel_0.event.deltaX, 335 EXPECT_EQ(mouse_wheel_1_copy.event.deltaX + mouse_wheel_0.event.deltaX,
336 mouse_wheel_1.event.deltaX); 336 mouse_wheel_1.event.deltaX);
337 EXPECT_EQ(mouse_wheel_1_copy.event.deltaY + mouse_wheel_0.event.deltaY, 337 EXPECT_EQ(mouse_wheel_1_copy.event.deltaY + mouse_wheel_0.event.deltaY,
338 mouse_wheel_1.event.deltaY); 338 mouse_wheel_1.event.deltaY);
339 EXPECT_EQ( 339 EXPECT_EQ(
340 mouse_wheel_1_copy.event.wheelTicksX + mouse_wheel_0.event.wheelTicksX, 340 mouse_wheel_1_copy.event.wheelTicksX + mouse_wheel_0.event.wheelTicksX,
341 mouse_wheel_1.event.wheelTicksX); 341 mouse_wheel_1.event.wheelTicksX);
(...skipping 13 matching lines...) Expand all
355 MouseWheelEventWithLatencyInfo mouse_wheel_1 = 355 MouseWheelEventWithLatencyInfo mouse_wheel_1 =
356 CreateMouseWheelEvent(10.0, 2, 2); 356 CreateMouseWheelEvent(10.0, 2, 2);
357 357
358 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1)); 358 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1));
359 Coalesce(mouse_wheel_1, &mouse_wheel_0); 359 Coalesce(mouse_wheel_1, &mouse_wheel_0);
360 EXPECT_EQ(10.0, mouse_wheel_0.event.timeStampSeconds()); 360 EXPECT_EQ(10.0, mouse_wheel_0.event.timeStampSeconds());
361 } 361 }
362 362
363 } // namespace 363 } // namespace
364 } // namespace content 364 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698