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

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

Issue 2257023004: Coalesced mouse wheel event has the position of the most recent event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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/web/WebInputEvent.h" 10 #include "third_party/WebKit/public/web/WebInputEvent.h"
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 // WebMouseWheelEvent objects with same values except different deltaX and 306 // WebMouseWheelEvent objects with same values except different deltaX and
307 // deltaY should coalesce. 307 // deltaY should coalesce.
308 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1)); 308 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1));
309 309
310 // WebMouseWheelEvent objects with different modifiers should not coalesce. 310 // WebMouseWheelEvent objects with different modifiers should not coalesce.
311 mouse_wheel_0 = CreateMouseWheel(1, 1); 311 mouse_wheel_0 = CreateMouseWheel(1, 1);
312 mouse_wheel_1 = CreateMouseWheel(1, 1); 312 mouse_wheel_1 = CreateMouseWheel(1, 1);
313 mouse_wheel_0.event.modifiers = WebInputEvent::ControlKey; 313 mouse_wheel_0.event.modifiers = WebInputEvent::ControlKey;
314 mouse_wheel_1.event.modifiers = WebInputEvent::ShiftKey; 314 mouse_wheel_1.event.modifiers = WebInputEvent::ShiftKey;
315 EXPECT_FALSE(CanCoalesce(mouse_wheel_0, mouse_wheel_1)); 315 EXPECT_FALSE(CanCoalesce(mouse_wheel_0, mouse_wheel_1));
316
317 // Coalesced event has the position of the most recent event.
318 mouse_wheel_0 = CreateMouseWheel(1, 1);
319 mouse_wheel_0.event.x = 1;
320 mouse_wheel_0.event.y = 1;
321 mouse_wheel_1 = CreateMouseWheel(2, 2);
322 mouse_wheel_1.event.x = 2;
323 mouse_wheel_1.event.y = 2;
324 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1));
325 Coalesce(mouse_wheel_0, &mouse_wheel_1);
dtapuska 2016/08/19 01:41:41 Ultimately this coalescing test could probably be
tdresser 2016/08/19 12:43:30 The naming here is a bit confusing. We might want
sahel 2016/08/19 15:17:56 Done.
sahel 2016/08/19 15:17:57 Then naming is consistent with the rest of the uni
326 EXPECT_EQ(1, mouse_wheel_1.event.x);
327 EXPECT_EQ(1, mouse_wheel_1.event.y);
316 } 328 }
317 329
318 // Coalescing preserves the newer timestamp. 330 // Coalescing preserves the newer timestamp.
319 TEST_F(EventWithLatencyInfoTest, TimestampCoalescing) { 331 TEST_F(EventWithLatencyInfoTest, TimestampCoalescing) {
320 MouseWheelEventWithLatencyInfo mouse_wheel_0 = CreateMouseWheel(1, 1); 332 MouseWheelEventWithLatencyInfo mouse_wheel_0 = CreateMouseWheel(1, 1);
321 mouse_wheel_0.event.timeStampSeconds = 5.0; 333 mouse_wheel_0.event.timeStampSeconds = 5.0;
322 MouseWheelEventWithLatencyInfo mouse_wheel_1 = CreateMouseWheel(2, 2); 334 MouseWheelEventWithLatencyInfo mouse_wheel_1 = CreateMouseWheel(2, 2);
323 mouse_wheel_1.event.timeStampSeconds = 10.0; 335 mouse_wheel_1.event.timeStampSeconds = 10.0;
324 336
325 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1)); 337 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1));
326 Coalesce(mouse_wheel_1, &mouse_wheel_0); 338 Coalesce(mouse_wheel_1, &mouse_wheel_0);
327 EXPECT_EQ(10.0, mouse_wheel_0.event.timeStampSeconds); 339 EXPECT_EQ(10.0, mouse_wheel_0.event.timeStampSeconds);
328 } 340 }
329 341
330 } // namespace 342 } // namespace
331 } // namespace content 343 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698