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

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

Issue 2782893002: WebMouseEvent coordinates are now fractional & private (Closed)
Patch Set: Rebased, fixed a comment in web_input_event_builders_mac.mm 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.setPositionInWidget(1, 1);
314 mouse_wheel_0.event.y = 1;
315 mouse_wheel_1 = CreateMouseWheel(2, 2); 314 mouse_wheel_1 = CreateMouseWheel(2, 2);
316 mouse_wheel_1.event.x = 2; 315 mouse_wheel_1.event.setPositionInWidget(2, 2);
317 mouse_wheel_1.event.y = 2;
318 MouseWheelEventWithLatencyInfo mouse_wheel_1_copy = mouse_wheel_1; 316 MouseWheelEventWithLatencyInfo mouse_wheel_1_copy = mouse_wheel_1;
319 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1)); 317 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1));
320 EXPECT_EQ(mouse_wheel_0.event.modifiers(), mouse_wheel_1.event.modifiers()); 318 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); 319 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); 320 EXPECT_EQ(mouse_wheel_0.event.phase, mouse_wheel_1.event.phase);
323 EXPECT_EQ(mouse_wheel_0.event.momentumPhase, 321 EXPECT_EQ(mouse_wheel_0.event.momentumPhase,
324 mouse_wheel_1.event.momentumPhase); 322 mouse_wheel_1.event.momentumPhase);
325 EXPECT_EQ(mouse_wheel_0.event.hasPreciseScrollingDeltas, 323 EXPECT_EQ(mouse_wheel_0.event.hasPreciseScrollingDeltas,
326 mouse_wheel_1.event.hasPreciseScrollingDeltas); 324 mouse_wheel_1.event.hasPreciseScrollingDeltas);
327 Coalesce(mouse_wheel_0, &mouse_wheel_1); 325 Coalesce(mouse_wheel_0, &mouse_wheel_1);
328 326
329 // Coalesced event has the position of the most recent event. 327 // Coalesced event has the position of the most recent event.
330 EXPECT_EQ(1, mouse_wheel_1.event.x); 328 EXPECT_EQ(1, mouse_wheel_1.event.positionInWidget().x);
331 EXPECT_EQ(1, mouse_wheel_1.event.y); 329 EXPECT_EQ(1, mouse_wheel_1.event.positionInWidget().y);
332 330
333 // deltaX/Y, wheelTicksX/Y, and movementX/Y of the coalesced event are 331 // deltaX/Y, wheelTicksX/Y, and movementX/Y of the coalesced event are
334 // calculated properly. 332 // calculated properly.
335 EXPECT_EQ(mouse_wheel_1_copy.event.deltaX + mouse_wheel_0.event.deltaX, 333 EXPECT_EQ(mouse_wheel_1_copy.event.deltaX + mouse_wheel_0.event.deltaX,
336 mouse_wheel_1.event.deltaX); 334 mouse_wheel_1.event.deltaX);
337 EXPECT_EQ(mouse_wheel_1_copy.event.deltaY + mouse_wheel_0.event.deltaY, 335 EXPECT_EQ(mouse_wheel_1_copy.event.deltaY + mouse_wheel_0.event.deltaY,
338 mouse_wheel_1.event.deltaY); 336 mouse_wheel_1.event.deltaY);
339 EXPECT_EQ( 337 EXPECT_EQ(
340 mouse_wheel_1_copy.event.wheelTicksX + mouse_wheel_0.event.wheelTicksX, 338 mouse_wheel_1_copy.event.wheelTicksX + mouse_wheel_0.event.wheelTicksX,
341 mouse_wheel_1.event.wheelTicksX); 339 mouse_wheel_1.event.wheelTicksX);
(...skipping 13 matching lines...) Expand all
355 MouseWheelEventWithLatencyInfo mouse_wheel_1 = 353 MouseWheelEventWithLatencyInfo mouse_wheel_1 =
356 CreateMouseWheelEvent(10.0, 2, 2); 354 CreateMouseWheelEvent(10.0, 2, 2);
357 355
358 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1)); 356 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1));
359 Coalesce(mouse_wheel_1, &mouse_wheel_0); 357 Coalesce(mouse_wheel_1, &mouse_wheel_0);
360 EXPECT_EQ(10.0, mouse_wheel_0.event.timeStampSeconds()); 358 EXPECT_EQ(10.0, mouse_wheel_0.event.timeStampSeconds());
361 } 359 }
362 360
363 } // namespace 361 } // namespace
364 } // namespace content 362 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/site_per_process_browsertest.cc ('k') | content/common/input/input_param_traits_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698