summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/platform/widget/input/scroll_predictor_unittest.cc
blob: ada25ead61fb17db6f119a3b2f6aa32b497e4c8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/platform/widget/input/scroll_predictor.h"

#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/test/scoped_feature_list.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/platform/input/predictor_factory.h"
#include "third_party/blink/renderer/platform/widget/input/prediction/empty_filter.h"
#include "third_party/blink/renderer/platform/widget/input/prediction/empty_predictor.h"
#include "third_party/blink/renderer/platform/widget/input/prediction/filter_factory.h"
#include "third_party/blink/renderer/platform/widget/input/prediction/kalman_predictor.h"
#include "third_party/blink/renderer/platform/widget/input/prediction/least_squares_predictor.h"
#include "third_party/blink/renderer/platform/widget/input/prediction/linear_predictor.h"

namespace blink {
namespace test {
namespace {

constexpr double kEpsilon = 0.001;

}  // namespace

class ScrollPredictorTest : public testing::Test {
 public:
  ScrollPredictorTest() {}

  void SetUp() override {
    original_events_.clear();
    scroll_predictor_ = std::make_unique<ScrollPredictor>();
    scroll_predictor_->predictor_ = std::make_unique<EmptyPredictor>();
  }

  void SetUpLSQPredictor() {
    scroll_predictor_->predictor_ = std::make_unique<LeastSquaresPredictor>();
  }

  std::unique_ptr<WebInputEvent> CreateGestureScrollUpdate(
      float delta_x = 0,
      float delta_y = 0,
      double time_delta_in_milliseconds = 0,
      WebGestureEvent::InertialPhaseState phase =
          WebGestureEvent::InertialPhaseState::kNonMomentum) {
    WebGestureEvent gesture(
        WebInputEvent::Type::kGestureScrollUpdate, WebInputEvent::kNoModifiers,
        WebInputEvent::GetStaticTimeStampForTests() +
            base::TimeDelta::FromMillisecondsD(time_delta_in_milliseconds),
        WebGestureDevice::kTouchscreen);
    gesture.data.scroll_update.delta_x = delta_x;
    gesture.data.scroll_update.delta_y = delta_y;
    gesture.data.scroll_update.inertial_phase = phase;

    original_events_.emplace_back(gesture.Clone(), ui::LatencyInfo(),
                                  base::NullCallback());

    return gesture.Clone();
  }

  void CoalesceWith(const std::unique_ptr<WebInputEvent>& new_event,
                    std::unique_ptr<WebInputEvent>& old_event) {
    old_event->Coalesce(*new_event);
  }

  void SendGestureScrollBegin() {
    WebGestureEvent gesture_begin(WebInputEvent::Type::kGestureScrollBegin,
                                  WebInputEvent::kNoModifiers,
                                  WebInputEvent::GetStaticTimeStampForTests(),
                                  WebGestureDevice::kTouchscreen);
    scroll_predictor_->ResetOnGestureScrollBegin(gesture_begin);
  }

  void HandleResampleScrollEvents(std::unique_ptr<WebInputEvent>& event,
                                  double time_delta_in_milliseconds = 0) {
    std::unique_ptr<EventWithCallback> event_with_callback =
        std::make_unique<EventWithCallback>(std::move(event), ui::LatencyInfo(),
                                            base::TimeTicks(),
                                            base::NullCallback());
    event_with_callback->original_events() = std::move(original_events_);

    event_with_callback = scroll_predictor_->ResampleScrollEvents(
        std::move(event_with_callback),
        WebInputEvent::GetStaticTimeStampForTests() +
            base::TimeDelta::FromMillisecondsD(time_delta_in_milliseconds));

    event = event_with_callback->event().Clone();
  }

  std::unique_ptr<InputPredictor::InputData> PredictionAvailable(
      double time_delta_in_milliseconds = 0) {
    return scroll_predictor_->predictor_->GeneratePrediction(
        WebInputEvent::GetStaticTimeStampForTests() +
        base::TimeDelta::FromMillisecondsD(time_delta_in_milliseconds));
  }

  gfx::PointF GetLastAccumulatedDelta() {
    return scroll_predictor_->last_predicted_accumulated_delta_;
  }

  bool GetResamplingState() {
    return scroll_predictor_->should_resample_scroll_events_;
  }

  bool isFilteringEnabled() { return scroll_predictor_->filtering_enabled_; }

  void ConfigurePredictorFieldTrialAndInitialize(
      const base::Feature& feature,
      const std::string& predictor_type) {
    base::FieldTrialParams params;
    params["predictor"] = predictor_type;
    scoped_feature_list_.Reset();
    scoped_feature_list_.InitAndEnableFeatureWithParameters(feature, params);
    EXPECT_EQ(params["predictor"],
              GetFieldTrialParamValueByFeature(feature, "predictor"));
    scroll_predictor_ = std::make_unique<ScrollPredictor>();
  }

  void ConfigureFilterFieldTrialAndInitialize(const base::Feature& feature,
                                              const std::string& filter_name) {
    base::FieldTrialParams params;
    params["filter"] = filter_name;

    scoped_feature_list_.Reset();
    scoped_feature_list_.InitAndEnableFeatureWithParameters(feature, params);
    EXPECT_EQ(params["filter"],
              GetFieldTrialParamValueByFeature(feature, "filter"));
    scroll_predictor_ = std::make_unique<ScrollPredictor>();
  }

  void ConfigurePredictorAndFilterFieldTrialAndInitialize(
      const base::Feature& pred_feature,
      const std::string& predictor_type,
      const base::Feature& filter_feature,
      const std::string& filter_type) {
    base::FieldTrialParams pred_field_params;
    pred_field_params["predictor"] = predictor_type;
    base::test::ScopedFeatureList::FeatureAndParams prediction_params = {
        pred_feature, pred_field_params};

    base::FieldTrialParams filter_field_params;
    filter_field_params["filter"] = filter_type;
    base::test::ScopedFeatureList::FeatureAndParams filter_params = {
        filter_feature, filter_field_params};

    scoped_feature_list_.Reset();
    scoped_feature_list_.InitWithFeaturesAndParameters(
        {prediction_params, filter_params}, {});

    EXPECT_EQ(pred_field_params["predictor"],
              GetFieldTrialParamValueByFeature(pred_feature, "predictor"));
    EXPECT_EQ(filter_field_params["filter"],
              GetFieldTrialParamValueByFeature(filter_feature, "filter"));

    scroll_predictor_ = std::make_unique<ScrollPredictor>();
  }

  void VerifyPredictorType(const char* expected_type) {
    EXPECT_EQ(expected_type, scroll_predictor_->predictor_->GetName());
  }

  void VerifyFilterType(const char* expected_type) {
    EXPECT_EQ(expected_type, scroll_predictor_->filter_->GetName());
  }

 protected:
  EventWithCallback::OriginalEventList original_events_;
  std::unique_ptr<ScrollPredictor> scroll_predictor_;

  base::test::ScopedFeatureList scoped_feature_list_;

  DISALLOW_COPY_AND_ASSIGN(ScrollPredictorTest);
};

TEST_F(ScrollPredictorTest, ScrollResamplingStates) {
  // initial
  EXPECT_FALSE(GetResamplingState());

  // after GSB
  SendGestureScrollBegin();
  EXPECT_TRUE(GetResamplingState());

  // after GSU with no phase
  std::unique_ptr<WebInputEvent> gesture_update =
      CreateGestureScrollUpdate(0, 10, 10 /* ms */);
  HandleResampleScrollEvents(gesture_update, 15 /* ms */);
  EXPECT_TRUE(GetResamplingState());

  // after GSU with momentum phase
  gesture_update = CreateGestureScrollUpdate(
      0, 10, 10 /* ms */, WebGestureEvent::InertialPhaseState::kMomentum);
  HandleResampleScrollEvents(gesture_update, 15 /* ms */);
  EXPECT_FALSE(GetResamplingState());

  // after GSE
  WebGestureEvent gesture_end(WebInputEvent::Type::kGestureScrollEnd,
                              WebInputEvent::kNoModifiers,
                              WebInputEvent::GetStaticTimeStampForTests(),
                              WebGestureDevice::kTouchscreen);
  std::unique_ptr<WebInputEvent> event = gesture_end.Clone();
  HandleResampleScrollEvents(event);
  EXPECT_FALSE(GetResamplingState());
}

TEST_F(ScrollPredictorTest, ResampleGestureScrollEvents) {
  SendGestureScrollBegin();
  EXPECT_FALSE(PredictionAvailable());

  std::unique_ptr<WebInputEvent> gesture_update =
      CreateGestureScrollUpdate(0, -20);
  HandleResampleScrollEvents(gesture_update);
  EXPECT_EQ(-20, static_cast<const WebGestureEvent*>(gesture_update.get())
                     ->data.scroll_update.delta_y);

  // Aggregated event delta doesn't change with empty predictor applied.
  gesture_update = CreateGestureScrollUpdate(0, -20);
  CoalesceWith(CreateGestureScrollUpdate(0, -40), gesture_update);
  EXPECT_EQ(-60, static_cast<const WebGestureEvent*>(gesture_update.get())
                     ->data.scroll_update.delta_y);
  HandleResampleScrollEvents(gesture_update);
  EXPECT_EQ(-60, static_cast<const WebGestureEvent*>(gesture_update.get())
                     ->data.scroll_update.delta_y);

  // Cumulative amount of scroll from the GSB is stored in the empty predictor.
  auto result = PredictionAvailable();
  EXPECT_TRUE(result);
  EXPECT_EQ(-80, result->pos.y());

  // Send another GSB, Prediction will be reset.
  SendGestureScrollBegin();
  EXPECT_FALSE(PredictionAvailable());

  // Sent another GSU.
  gesture_update = CreateGestureScrollUpdate(0, -35);
  HandleResampleScrollEvents(gesture_update);
  EXPECT_EQ(-35, static_cast<const WebGestureEvent*>(gesture_update.get())
                     ->data.scroll_update.delta_y);
  // Total amount of scroll is track from the last GSB.
  result = PredictionAvailable();
  EXPECT_TRUE(result);
  EXPECT_EQ(-35, result->pos.y());
}

TEST_F(ScrollPredictorTest, ScrollInDifferentDirection) {
  SendGestureScrollBegin();

  // Scroll down.
  std::unique_ptr<WebInputEvent> gesture_update =
      CreateGestureScrollUpdate(0, -20);
  HandleResampleScrollEvents(gesture_update);
  EXPECT_EQ(-20, static_cast<const WebGestureEvent*>(gesture_update.get())
                     ->data.scroll_update.delta_y);
  auto result = PredictionAvailable();
  EXPECT_TRUE(result);
  EXPECT_EQ(-20, result->pos.y());

  // Scroll up.
  gesture_update = CreateGestureScrollUpdate(0, 25);
  HandleResampleScrollEvents(gesture_update);
  EXPECT_EQ(0, static_cast<const WebGestureEvent*>(gesture_update.get())
                   ->data.scroll_update.delta_x);
  EXPECT_EQ(25, static_cast<const WebGestureEvent*>(gesture_update.get())
                    ->data.scroll_update.delta_y);
  result = PredictionAvailable();
  EXPECT_TRUE(result);
  EXPECT_EQ(0, result->pos.x());
  EXPECT_EQ(5, result->pos.y());

  // Scroll left + right.
  gesture_update = CreateGestureScrollUpdate(-35, 0);
  CoalesceWith(CreateGestureScrollUpdate(60, 0), gesture_update);
  HandleResampleScrollEvents(gesture_update);
  EXPECT_EQ(25, static_cast<const WebGestureEvent*>(gesture_update.get())
                    ->data.scroll_update.delta_x);
  EXPECT_EQ(0, static_cast<const WebGestureEvent*>(gesture_update.get())
                   ->data.scroll_update.delta_y);
  result = PredictionAvailable();
  EXPECT_TRUE(result);
  EXPECT_EQ(25, result->pos.x());
  EXPECT_EQ(5, result->pos.y());
}

TEST_F(ScrollPredictorTest, ScrollUpdateWithEmptyOriginalEventList) {
  SendGestureScrollBegin();

  // Send a GSU with empty original event list.
  std::unique_ptr<WebInputEvent> gesture_update =
      CreateGestureScrollUpdate(0, -20);
  original_events_.clear();
  HandleResampleScrollEvents(gesture_update);
  EXPECT_EQ(-20, static_cast<const WebGestureEvent*>(gesture_update.get())
                     ->data.scroll_update.delta_y);

  // No prediction available because the event is skipped.
  EXPECT_FALSE(PredictionAvailable());

  // Send a GSU with original event.
  gesture_update = CreateGestureScrollUpdate(0, -30);
  HandleResampleScrollEvents(gesture_update);
  EXPECT_EQ(-30, static_cast<const WebGestureEvent*>(gesture_update.get())
                     ->data.scroll_update.delta_y);

  // Send another GSU with empty original event list.
  gesture_update = CreateGestureScrollUpdate(0, -40);
  original_events_.clear();
  HandleResampleScrollEvents(gesture_update);
  EXPECT_EQ(-40, static_cast<const WebGestureEvent*>(gesture_update.get())
                     ->data.scroll_update.delta_y);

  // Prediction only track GSU with original event list.
  auto result = PredictionAvailable();
  EXPECT_TRUE(result);
  EXPECT_EQ(-30, result->pos.y());
}

TEST_F(ScrollPredictorTest, LSQPredictorTest) {
  SetUpLSQPredictor();
  SendGestureScrollBegin();

  // Send 1st GSU, no prediction available.
  std::unique_ptr<WebInputEvent> gesture_update =
      CreateGestureScrollUpdate(0, -30, 8 /* ms */);
  HandleResampleScrollEvents(gesture_update, 16 /* ms */);
  EXPECT_FALSE(PredictionAvailable(16 /* ms */));
  EXPECT_EQ(-30, static_cast<const WebGestureEvent*>(gesture_update.get())
                     ->data.scroll_update.delta_y);
  EXPECT_EQ(
      WebInputEvent::GetStaticTimeStampForTests() +
          base::TimeDelta::FromMillisecondsD(8 /* ms */),
      static_cast<const WebGestureEvent*>(gesture_update.get())->TimeStamp());

  // Send 2nd GSU, no prediction available, event aligned at original timestamp.
  gesture_update = CreateGestureScrollUpdate(0, -30, 16 /* ms */);
  HandleResampleScrollEvents(gesture_update, 24 /* ms */);
  EXPECT_EQ(-30, static_cast<const WebGestureEvent*>(gesture_update.get())
                     ->data.scroll_update.delta_y);
  EXPECT_EQ(
      WebInputEvent::GetStaticTimeStampForTests() +
          base::TimeDelta::FromMillisecondsD(16 /* ms */),
      static_cast<const WebGestureEvent*>(gesture_update.get())->TimeStamp());
  EXPECT_FALSE(PredictionAvailable(24 /* ms */));

  // Send 3rd and 4th GSU, prediction result returns the sum of delta_y, event
  // aligned at frame time.
  gesture_update = CreateGestureScrollUpdate(0, -30, 24 /* ms */);
  HandleResampleScrollEvents(gesture_update, 32 /* ms */);
  EXPECT_EQ(-60, static_cast<const WebGestureEvent*>(gesture_update.get())
                     ->data.scroll_update.delta_y);
  EXPECT_EQ(
      WebInputEvent::GetStaticTimeStampForTests() +
          base::TimeDelta::FromMillisecondsD(32 /* ms */),
      static_cast<const WebGestureEvent*>(gesture_update.get())->TimeStamp());
  auto result = PredictionAvailable(32 /* ms */);
  EXPECT_TRUE(result);
  EXPECT_EQ(-120, result->pos.y());

  gesture_update = CreateGestureScrollUpdate(0, -30, 32 /* ms */);
  HandleResampleScrollEvents(gesture_update, 40 /* ms */);
  EXPECT_EQ(-30, static_cast<const WebGestureEvent*>(gesture_update.get())
                     ->data.scroll_update.delta_y);
  EXPECT_EQ(
      WebInputEvent::GetStaticTimeStampForTests() +
          base::TimeDelta::FromMillisecondsD(40 /* ms */),
      static_cast<const WebGestureEvent*>(gesture_update.get())->TimeStamp());
  result = PredictionAvailable(40 /* ms */);
  EXPECT_TRUE(result);
  EXPECT_EQ(-150, result->pos.y());
}

TEST_F(ScrollPredictorTest, ScrollPredictorNotChangeScrollDirection) {
  SetUpLSQPredictor();
  SendGestureScrollBegin();

  // Send 4 GSUs with delta_y = 10
  std::unique_ptr<WebInputEvent> gesture_update =
      CreateGestureScrollUpdate(0, 10, 10 /* ms */);
  HandleResampleScrollEvents(gesture_update, 15 /* ms */);
  gesture_update = CreateGestureScrollUpdate(0, 10, 20 /* ms */);
  HandleResampleScrollEvents(gesture_update, 25 /* ms */);
  gesture_update = CreateGestureScrollUpdate(0, 10, 30 /* ms */);
  HandleResampleScrollEvents(gesture_update, 35 /* ms */);
  gesture_update = CreateGestureScrollUpdate(0, 10, 40 /* ms */);
  HandleResampleScrollEvents(gesture_update, 45 /* ms */);
  EXPECT_NEAR(10,
              static_cast<const WebGestureEvent*>(gesture_update.get())
                  ->data.scroll_update.delta_y,
              kEpsilon);
  EXPECT_NEAR(45, GetLastAccumulatedDelta().y(), kEpsilon);

  // Send a GSU with delta_y = 2. So last resampled GSU we calculated is
  // overhead. No scroll back in this case.
  gesture_update = CreateGestureScrollUpdate(0, 2, 50 /* ms */);
  HandleResampleScrollEvents(gesture_update, 55 /* ms */);
  EXPECT_EQ(0, static_cast<const WebGestureEvent*>(gesture_update.get())
                   ->data.scroll_update.delta_y);
  EXPECT_NEAR(45, GetLastAccumulatedDelta().y(), kEpsilon);

  // Send a GSU with different scroll direction. Resampled GSU is in the new
  // direction.
  gesture_update = CreateGestureScrollUpdate(0, -6, 60 /* ms */);
  HandleResampleScrollEvents(gesture_update, 60 /* ms */);
  EXPECT_NEAR(-9,
              static_cast<const WebGestureEvent*>(gesture_update.get())
                  ->data.scroll_update.delta_y,
              kEpsilon);
  EXPECT_NEAR(36, GetLastAccumulatedDelta().y(), kEpsilon);
}

TEST_F(ScrollPredictorTest, ScrollPredictorTypeSelection) {
  // Use LinearResampling predictor by default.
  scroll_predictor_ = std::make_unique<ScrollPredictor>();
  VerifyPredictorType(blink::features::kScrollPredictorNameLinearResampling);

  // When resampling is enabled, predictor type is set from
  // kResamplingScrollEvents.
  ConfigurePredictorFieldTrialAndInitialize(
      blink::features::kResamplingScrollEvents,
      blink::features::kScrollPredictorNameEmpty);
  VerifyPredictorType(blink::features::kScrollPredictorNameEmpty);

  ConfigurePredictorFieldTrialAndInitialize(
      blink::features::kResamplingScrollEvents,
      blink::features::kScrollPredictorNameLsq);
  VerifyPredictorType(blink::features::kScrollPredictorNameLsq);

  ConfigurePredictorFieldTrialAndInitialize(
      blink::features::kResamplingScrollEvents,
      blink::features::kScrollPredictorNameKalman);
  VerifyPredictorType(blink::features::kScrollPredictorNameKalman);

  ConfigurePredictorFieldTrialAndInitialize(
      blink::features::kResamplingScrollEvents,
      blink::features::kScrollPredictorNameLinearFirst);
  VerifyPredictorType(blink::features::kScrollPredictorNameLinearFirst);
}

// Check the right filter is selected
TEST_F(ScrollPredictorTest, DefaultFilter) {
  ConfigureFilterFieldTrialAndInitialize(
      blink::features::kFilteringScrollPrediction, "");
  VerifyFilterType(blink::features::kFilterNameEmpty);
  EXPECT_TRUE(isFilteringEnabled());

  ConfigureFilterFieldTrialAndInitialize(
      blink::features::kFilteringScrollPrediction,
      blink::features::kFilterNameEmpty);
  VerifyFilterType(blink::features::kFilterNameEmpty);
  EXPECT_TRUE(isFilteringEnabled());

  ConfigureFilterFieldTrialAndInitialize(
      blink::features::kFilteringScrollPrediction,
      blink::features::kFilterNameOneEuro);
  VerifyFilterType(blink::features::kFilterNameOneEuro);
  EXPECT_TRUE(isFilteringEnabled());
}

// We first send 100 events to the scroll predictor with kalman predictor
// enabled and filetring disable and save the results.
// We then send the same events with kalman and the empty filter, we should
// expect the same results.
TEST_F(ScrollPredictorTest, FilteringPrediction) {
  ConfigurePredictorFieldTrialAndInitialize(
      blink::features::kResamplingScrollEvents,
      blink::features::kScrollPredictorNameKalman);

  std::vector<double> accumulated_deltas;
  std::unique_ptr<WebInputEvent> gesture_update;

  for (int i = 0; i < 100; i++) {
    // Create event at time 8*i
    gesture_update = CreateGestureScrollUpdate(0, 3 * i, 8 * i /* ms */);
    // Handle the event 5 ms later
    HandleResampleScrollEvents(gesture_update, 8 * i + 5 /* ms */);
    EXPECT_FALSE(isFilteringEnabled());
    accumulated_deltas.push_back(GetLastAccumulatedDelta().y());
  }
  EXPECT_EQ((int)accumulated_deltas.size(), 100);

  // Now we enable filtering and compare the deltas
  ConfigurePredictorAndFilterFieldTrialAndInitialize(
      blink::features::kResamplingScrollEvents,
      blink::features::kScrollPredictorNameKalman,
      blink::features::kFilteringScrollPrediction,
      blink::features::kFilterNameEmpty);
  scroll_predictor_ = std::make_unique<ScrollPredictor>();

  for (int i = 0; i < 100; i++) {
    // Create event at time 8*i
    gesture_update = CreateGestureScrollUpdate(0, 3 * i, 8 * i /* ms */);
    // Handle the event 5 ms later
    HandleResampleScrollEvents(gesture_update, 8 * i + 5 /* ms */);
    EXPECT_TRUE(isFilteringEnabled());
    EXPECT_NEAR(accumulated_deltas[i], GetLastAccumulatedDelta().y(), 0.00001);
  }
}

}  // namespace test
}  // namespace blink