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

Side by Side Diff: ui/events/blink/blink_event_util_unittest.cc

Issue 2723023005: Make sure resent events that don't match ids are not coalesced. (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « ui/events/blink/blink_event_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ui/events/blink/blink_event_util.h" 5 #include "ui/events/blink/blink_event_util.h"
6 6
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "third_party/WebKit/public/platform/WebGestureEvent.h" 9 #include "third_party/WebKit/public/platform/WebGestureEvent.h"
10 #include "third_party/WebKit/public/platform/WebInputEvent.h" 10 #include "third_party/WebKit/public/platform/WebInputEvent.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 touch_point.movementY = -4; 148 touch_point.movementY = -4;
149 event_to_be_coalesced.touches[event_to_be_coalesced.touchesLength++] = 149 event_to_be_coalesced.touches[event_to_be_coalesced.touchesLength++] =
150 touch_point; 150 touch_point;
151 151
152 EXPECT_TRUE(CanCoalesce(event_to_be_coalesced, coalesced_event)); 152 EXPECT_TRUE(CanCoalesce(event_to_be_coalesced, coalesced_event));
153 Coalesce(event_to_be_coalesced, &coalesced_event); 153 Coalesce(event_to_be_coalesced, &coalesced_event);
154 EXPECT_EQ(8, coalesced_event.touches[0].movementX); 154 EXPECT_EQ(8, coalesced_event.touches[0].movementX);
155 EXPECT_EQ(6, coalesced_event.touches[0].movementY); 155 EXPECT_EQ(6, coalesced_event.touches[0].movementY);
156 } 156 }
157 157
158 TEST(BlinkEventUtilTest, WebMouseWheelEventCoalescing) {
159 blink::WebMouseWheelEvent coalesced_event(
160 blink::WebInputEvent::MouseWheel, blink::WebInputEvent::NoModifiers,
161 blink::WebInputEvent::TimeStampForTesting);
162 coalesced_event.deltaX = 1;
163 coalesced_event.deltaY = 1;
164
165 blink::WebMouseWheelEvent event_to_be_coalesced(
166 blink::WebInputEvent::MouseWheel, blink::WebInputEvent::NoModifiers,
167 blink::WebInputEvent::TimeStampForTesting);
168 event_to_be_coalesced.deltaX = 3;
169 event_to_be_coalesced.deltaY = 4;
170
171 EXPECT_TRUE(CanCoalesce(event_to_be_coalesced, coalesced_event));
172 Coalesce(event_to_be_coalesced, &coalesced_event);
173 EXPECT_EQ(4, coalesced_event.deltaX);
174 EXPECT_EQ(5, coalesced_event.deltaY);
175
176 event_to_be_coalesced.resendingPluginId = 3;
177 EXPECT_FALSE(CanCoalesce(event_to_be_coalesced, coalesced_event));
178 }
179
180 TEST(BlinkEventUtilTest, WebGestureEventCoalescing) {
181 blink::WebGestureEvent coalesced_event(
182 blink::WebInputEvent::GestureScrollUpdate,
183 blink::WebInputEvent::NoModifiers,
184 blink::WebInputEvent::TimeStampForTesting);
185 coalesced_event.data.scrollUpdate.deltaX = 1;
186 coalesced_event.data.scrollUpdate.deltaY = 1;
187
188 blink::WebGestureEvent event_to_be_coalesced(
189 blink::WebInputEvent::GestureScrollUpdate,
190 blink::WebInputEvent::NoModifiers,
191 blink::WebInputEvent::TimeStampForTesting);
192 event_to_be_coalesced.data.scrollUpdate.deltaX = 3;
193 event_to_be_coalesced.data.scrollUpdate.deltaY = 4;
194
195 EXPECT_TRUE(CanCoalesce(event_to_be_coalesced, coalesced_event));
196 Coalesce(event_to_be_coalesced, &coalesced_event);
197 EXPECT_EQ(4, coalesced_event.data.scrollUpdate.deltaX);
198 EXPECT_EQ(5, coalesced_event.data.scrollUpdate.deltaY);
199
200 event_to_be_coalesced.resendingPluginId = 3;
201 EXPECT_FALSE(CanCoalesce(event_to_be_coalesced, coalesced_event));
202 }
203
158 } // namespace ui 204 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/blink/blink_event_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698