Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 1 | // Copyright 2019 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 5 | #include "cc/metrics/average_lag_tracker.h" |
| 6 | |
| 7 | #include <memory> |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 8 | |
| 9 | #include "base/test/metrics/histogram_tester.h" |
| 10 | #include "testing/gmock/include/gmock/gmock.h" |
| 11 | #include "testing/gtest/include/gtest/gtest.h" |
| 12 | |
| 13 | using base::Bucket; |
| 14 | using testing::ElementsAre; |
| 15 | |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 16 | namespace cc { |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 17 | namespace { |
| 18 | |
| 19 | class AverageLagTrackerTest : public testing::Test { |
| 20 | public: |
| 21 | AverageLagTrackerTest() { ResetHistograms(); } |
| 22 | |
| 23 | void ResetHistograms() { |
Peter Boström | f238104 | 2019-08-27 00:25:03 | [diff] [blame] | 24 | histogram_tester_ = std::make_unique<base::HistogramTester>(); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | const base::HistogramTester& histogram_tester() { return *histogram_tester_; } |
| 28 | |
| 29 | void SetUp() override { |
Joao Victor Almeida | ae356d4 | 2021-07-06 16:24:34 | [diff] [blame] | 30 | average_lag_tracker_ = std::make_unique<AverageLagTracker>(); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 31 | } |
| 32 | |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 33 | void SyntheticTouchScrollBegin(base::TimeTicks event_time, |
| 34 | base::TimeTicks frame_time, |
| 35 | float delta, |
| 36 | float predicted_delta = 0) { |
| 37 | AverageLagTracker::EventInfo event_info( |
Mohsen Izadi | 9f0a9f7 | 2021-09-08 22:44:38 | [diff] [blame] | 38 | delta, predicted_delta != 0 ? predicted_delta : delta, event_time, |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 39 | AverageLagTracker::EventType::ScrollBegin); |
| 40 | event_info.finish_timestamp = frame_time; |
Joao Victor Almeida | ae356d4 | 2021-07-06 16:24:34 | [diff] [blame] | 41 | average_lag_tracker_->AddScrollEventInFrame(event_info); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 42 | } |
| 43 | |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 44 | void SyntheticTouchScrollUpdate(base::TimeTicks event_time, |
| 45 | base::TimeTicks frame_time, |
| 46 | float delta, |
| 47 | float predicted_delta = 0) { |
| 48 | AverageLagTracker::EventInfo event_info( |
Mohsen Izadi | 9f0a9f7 | 2021-09-08 22:44:38 | [diff] [blame] | 49 | delta, predicted_delta != 0 ? predicted_delta : delta, event_time, |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 50 | AverageLagTracker::EventType::ScrollUpdate); |
| 51 | event_info.finish_timestamp = frame_time; |
Joao Victor Almeida | ae356d4 | 2021-07-06 16:24:34 | [diff] [blame] | 52 | average_lag_tracker_->AddScrollEventInFrame(event_info); |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | void CheckScrollBeginHistograms(int bucket_value, int count) { |
| 56 | EXPECT_THAT(histogram_tester().GetAllSamples( |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 57 | "Event.Latency.ScrollBegin.Touch.AverageLagPresentation"), |
| 58 | ElementsAre(Bucket(bucket_value, count))); |
Joao Victor Almeida | 49b3d690 | 2021-07-06 17:35:55 | [diff] [blame] | 59 | |
| 60 | EXPECT_THAT( |
| 61 | histogram_tester().GetAllSamples("Event.Latency.ScrollBegin.Touch." |
| 62 | "AverageLagPresentation.NoPrediction"), |
| 63 | ElementsAre(Bucket(bucket_value, count))); |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | void CheckScrollUpdateHistograms(int bucket_value, int count) { |
| 67 | EXPECT_THAT(histogram_tester().GetAllSamples( |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 68 | "Event.Latency.ScrollUpdate.Touch.AverageLagPresentation"), |
| 69 | ElementsAre(Bucket(bucket_value, count))); |
Joao Victor Almeida | 49b3d690 | 2021-07-06 17:35:55 | [diff] [blame] | 70 | |
| 71 | EXPECT_THAT( |
| 72 | histogram_tester().GetAllSamples("Event.Latency.ScrollUpdate.Touch." |
| 73 | "AverageLagPresentation.NoPrediction"), |
| 74 | ElementsAre(Bucket(bucket_value, count))); |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | void CheckPredictionPositiveHistograms(int bucket_value, int count) { |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 78 | EXPECT_THAT(histogram_tester().GetAllSamples( |
| 79 | "Event.Latency.ScrollUpdate.Touch.AverageLagPresentation." |
| 80 | "PredictionPositive"), |
| 81 | ElementsAre(Bucket(bucket_value, count))); |
| 82 | } |
| 83 | |
Joao Victor Almeida | 49b3d690 | 2021-07-06 17:35:55 | [diff] [blame] | 84 | void CheckRemainingLagPercentageHistograms(int bucket_value, int count) { |
| 85 | EXPECT_THAT(histogram_tester().GetAllSamples( |
| 86 | "Event.Latency.ScrollUpdate.Touch.AverageLagPresentation." |
| 87 | "RemainingLagPercentage"), |
| 88 | ElementsAre(Bucket(bucket_value, count))); |
| 89 | } |
| 90 | |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 91 | void CheckPredictionNegativeHistograms(int bucket_value, int count) { |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 92 | EXPECT_THAT(histogram_tester().GetAllSamples( |
| 93 | "Event.Latency.ScrollUpdate.Touch.AverageLagPresentation." |
| 94 | "PredictionNegative"), |
| 95 | ElementsAre(Bucket(bucket_value, count))); |
| 96 | } |
| 97 | |
| 98 | void CheckScrollUpdateHistogramsTotalCount(int count) { |
| 99 | histogram_tester().ExpectTotalCount( |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 100 | "Event.Latency.ScrollUpdate.Touch.AverageLagPresentation", count); |
Joao Victor Almeida | 49b3d690 | 2021-07-06 17:35:55 | [diff] [blame] | 101 | histogram_tester().ExpectTotalCount( |
| 102 | "Event.Latency.ScrollUpdate.Touch.AverageLagPresentation.NoPrediction", |
| 103 | count); |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | void CheckPredictionPositiveHistogramsTotalCount(int count) { |
| 107 | histogram_tester().ExpectTotalCount( |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 108 | "Event.Latency.ScrollUpdate.Touch.AverageLagPresentation." |
| 109 | "PredictionPositive", |
| 110 | count); |
| 111 | } |
| 112 | |
| 113 | void CheckPredictionNegativeHistogramsTotalCount(int count) { |
| 114 | histogram_tester().ExpectTotalCount( |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 115 | "Event.Latency.ScrollUpdate.Touch.AverageLagPresentation." |
| 116 | "PredictionNegative", |
| 117 | count); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | protected: |
Joao Victor Almeida | ae356d4 | 2021-07-06 16:24:34 | [diff] [blame] | 121 | std::unique_ptr<AverageLagTracker> average_lag_tracker_; |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 122 | |
| 123 | std::unique_ptr<base::HistogramTester> histogram_tester_; |
| 124 | }; |
| 125 | |
| 126 | base::TimeTicks MillisecondsToTimeTicks(float t_ms) { |
Peter Kasting | e5a38ed | 2021-10-02 03:06:35 | [diff] [blame^] | 127 | return base::TimeTicks() + base::Milliseconds(t_ms); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | // Simulate a simple situation that events at every 10ms and start at t=15ms, |
| 131 | // frame swaps at every 10ms too and start at t=20ms and test we record one |
| 132 | // UMA for ScrollUpdate in one second. |
| 133 | TEST_F(AverageLagTrackerTest, OneSecondInterval) { |
Peter Kasting | e5a38ed | 2021-10-02 03:06:35 | [diff] [blame^] | 134 | base::TimeTicks event_time = base::TimeTicks() + base::Milliseconds(5); |
| 135 | base::TimeTicks frame_time = base::TimeTicks() + base::Milliseconds(10); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 136 | float scroll_delta = 10; |
| 137 | |
| 138 | // ScrollBegin |
Peter Kasting | e5a38ed | 2021-10-02 03:06:35 | [diff] [blame^] | 139 | event_time += base::Milliseconds(10); // 15ms |
| 140 | frame_time += base::Milliseconds(10); // 20ms |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 141 | SyntheticTouchScrollBegin(event_time, frame_time, scroll_delta); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 142 | |
| 143 | // Send 101 ScrollUpdate events to verify that there is 1 AverageLag record |
| 144 | // per 1 second. |
| 145 | const int kUpdates = 101; |
| 146 | for (int i = 0; i < kUpdates; i++) { |
Peter Kasting | e5a38ed | 2021-10-02 03:06:35 | [diff] [blame^] | 147 | event_time += base::Milliseconds(10); |
| 148 | frame_time += base::Milliseconds(10); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 149 | // First 50 has positive delta, others negetive delta. |
| 150 | const int sign = (i < kUpdates / 2) ? 1 : -1; |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 151 | SyntheticTouchScrollUpdate(event_time, frame_time, sign * scroll_delta); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | // ScrollBegin report_time is at 20ms, so the next ScrollUpdate report_time is |
| 155 | // at 1020ms. The last event_time that finish this report should be later than |
| 156 | // 1020ms. |
Peter Kasting | e5a38ed | 2021-10-02 03:06:35 | [diff] [blame^] | 157 | EXPECT_EQ(event_time, base::TimeTicks() + base::Milliseconds(1025)); |
| 158 | EXPECT_EQ(frame_time, base::TimeTicks() + base::Milliseconds(1030)); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 159 | |
| 160 | // ScrollBegin AverageLag are the area between the event original component |
| 161 | // (time=15ms, delta=10px) to the frame swap time (time=20ms, expect finger |
| 162 | // position at delta=15px). The AverageLag scaled to 1 second is |
| 163 | // (0.5*(10px+15px)*5ms)/5ms = 12.5px. |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 164 | CheckScrollBeginHistograms(12, 1); |
| 165 | |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 166 | // This ScrollUpdate AverageLag are calculated as the finger uniformly scroll |
| 167 | // 10px each frame. For scroll up/down frame, the Lag at the last frame swap |
| 168 | // is 5px, and Lag at this frame swap is 15px. For the one changing direction, |
| 169 | // the Lag is from 5 to 10 and down to 5 again. So total LagArea is 99 * 100, |
| 170 | // plus 75. the AverageLag in 1 second is 9.975px. |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 171 | CheckScrollUpdateHistograms(9, 1); |
| 172 | CheckPredictionPositiveHistograms(0, 1); |
| 173 | CheckPredictionNegativeHistogramsTotalCount(0); |
Joao Victor Almeida | 49b3d690 | 2021-07-06 17:35:55 | [diff] [blame] | 174 | CheckRemainingLagPercentageHistograms(100 - 0, 1); |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 175 | |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 176 | ResetHistograms(); |
| 177 | |
| 178 | // Send another ScrollBegin to end the unfinished ScrollUpdate report. |
Peter Kasting | e5a38ed | 2021-10-02 03:06:35 | [diff] [blame^] | 179 | event_time += base::Milliseconds(10); |
| 180 | frame_time += base::Milliseconds(10); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 181 | SyntheticTouchScrollBegin(event_time, frame_time, scroll_delta); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 182 | |
| 183 | // The last ScrollUpdate's lag is 8.75px and truncated to 8. |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 184 | CheckScrollUpdateHistograms(8, 1); |
| 185 | CheckPredictionPositiveHistograms(0, 1); |
| 186 | CheckPredictionNegativeHistogramsTotalCount(0); |
Joao Victor Almeida | 49b3d690 | 2021-07-06 17:35:55 | [diff] [blame] | 187 | CheckRemainingLagPercentageHistograms(100 - 0, 1); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | // Test the case that event's frame swap time is later than next event's |
| 191 | // creation time. (i.e, event at t=10ms will be dispatch at t=30ms, while next |
| 192 | // event is at t=20ms). |
| 193 | TEST_F(AverageLagTrackerTest, LargerLatency) { |
| 194 | base::TimeTicks event_time = MillisecondsToTimeTicks(10); |
Peter Kasting | e5a38ed | 2021-10-02 03:06:35 | [diff] [blame^] | 195 | base::TimeTicks frame_time = event_time + base::Milliseconds(20); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 196 | float scroll_delta = 10; |
| 197 | |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 198 | SyntheticTouchScrollBegin(event_time, frame_time, scroll_delta); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 199 | |
| 200 | // Send 2 ScrollUpdate. The second one will record AverageLag.ScrollBegin as |
| 201 | // it's event_time is larger or equal to ScrollBegin's frame_time. |
| 202 | for (int i = 0; i < 2; i++) { |
Peter Kasting | e5a38ed | 2021-10-02 03:06:35 | [diff] [blame^] | 203 | event_time += base::Milliseconds(10); |
| 204 | frame_time = event_time + base::Milliseconds(20); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 205 | SyntheticTouchScrollUpdate(event_time, frame_time, scroll_delta); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | // ScrollBegin AveragLag are from t=10ms to t=30ms, with absolute scroll |
| 209 | // position from 10 to 30. The AverageLag should be: |
| 210 | // (0.5*(10px + 30px)*20ms/20ms) = 20px. |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 211 | CheckScrollBeginHistograms(20, 1); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 212 | |
| 213 | // Another ScrollBegin to flush unfinished frames. |
| 214 | // event_time doesn't matter here because the previous frames' lag are |
| 215 | // compute from their frame_time. |
| 216 | event_time = MillisecondsToTimeTicks(1000); |
| 217 | frame_time = MillisecondsToTimeTicks(1000); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 218 | SyntheticTouchScrollBegin(event_time, frame_time, scroll_delta); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 219 | // The to unfinished frames' lag are (finger_positon-rendered_position)*time, |
| 220 | // AverageLag is ((30px-10px)*10ms+(30px-20px)*10ms)/20ms = 15px. |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 221 | CheckScrollUpdateHistograms(14, 1); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | // Test that multiple latency being flush in the same frame swap. |
| 225 | TEST_F(AverageLagTrackerTest, TwoLatencyInfoInSameFrame) { |
| 226 | // ScrollBegin |
| 227 | base::TimeTicks event_time = MillisecondsToTimeTicks(10); |
| 228 | base::TimeTicks frame_time = MillisecondsToTimeTicks(20); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 229 | SyntheticTouchScrollBegin(event_time, frame_time, -10 /* scroll_delta */); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 230 | |
| 231 | // ScrollUpdate with event_time >= ScrollBegin frame_time will generate |
| 232 | // a histogram for AverageLag.ScrollBegin. |
| 233 | event_time = MillisecondsToTimeTicks(20); |
| 234 | frame_time = MillisecondsToTimeTicks(30); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 235 | SyntheticTouchScrollUpdate(event_time, frame_time, -10 /* scroll_delta */); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 236 | |
| 237 | // Absolute position from -10 to -20. The AverageLag should be: |
| 238 | // (0.5*(10px + 20px)*10ms/10ms) = 15px. |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 239 | CheckScrollBeginHistograms(14, 1); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 240 | |
| 241 | event_time = MillisecondsToTimeTicks(25); |
| 242 | frame_time = MillisecondsToTimeTicks(30); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 243 | SyntheticTouchScrollUpdate(event_time, frame_time, 5 /* scroll_delta */); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 244 | |
| 245 | // Another ScrollBegin to flush unfinished frames. |
| 246 | event_time = MillisecondsToTimeTicks(1000); |
| 247 | frame_time = MillisecondsToTimeTicks(1000); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 248 | SyntheticTouchScrollBegin(event_time, frame_time, 0); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 249 | |
| 250 | // The ScrollUpdates are at t=20ms, finger_pos=-20px, rendered_pos=-10px, |
| 251 | // at t=25ms, finger_pos=-15px, rendered_pos=-10px; |
| 252 | // To t=30ms both events get flush. |
| 253 | // AverageLag is (0.5*(10px+5px)*5ms + 5px*5ms)/10ms = 6.25px |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 254 | CheckScrollUpdateHistograms(6, 1); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | // Test the case that switching direction causes lag at current frame |
| 258 | // time and previous frame time are in different direction. |
| 259 | TEST_F(AverageLagTrackerTest, ChangeDirectionInFrame) { |
| 260 | // ScrollBegin |
| 261 | base::TimeTicks event_time = MillisecondsToTimeTicks(10); |
| 262 | base::TimeTicks frame_time = MillisecondsToTimeTicks(20); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 263 | SyntheticTouchScrollBegin(event_time, frame_time, 10 /* scroll_delta */); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 264 | |
| 265 | // At t=20, lag = 10px. |
| 266 | event_time = MillisecondsToTimeTicks(20); |
| 267 | frame_time = MillisecondsToTimeTicks(30); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 268 | SyntheticTouchScrollUpdate(event_time, frame_time, 10 /* scroll_delta */); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 269 | |
| 270 | // At t=30, lag = -10px. |
| 271 | event_time = MillisecondsToTimeTicks(30); |
| 272 | frame_time = MillisecondsToTimeTicks(40); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 273 | SyntheticTouchScrollUpdate(event_time, frame_time, -20 /* scroll_delta */); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 274 | |
| 275 | // Another ScrollBegin to flush unfinished frames. |
| 276 | event_time = MillisecondsToTimeTicks(1000); |
| 277 | frame_time = MillisecondsToTimeTicks(1000); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 278 | SyntheticTouchScrollBegin(event_time, frame_time, 0); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 279 | |
| 280 | // From t=20 to t=30, lag_area=2*(0.5*10px*5ms)=50px*ms. |
| 281 | // From t=30 to t=40, lag_area=20px*10ms=200px*ms |
| 282 | // AverageLag = (50+200)/20 = 12.5px. |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 283 | CheckScrollUpdateHistograms(12, 1); |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 284 | } |
| 285 | |
Ella Ge | 7d1d3be20 | 2019-04-08 16:47:59 | [diff] [blame] | 286 | // A simple case without scroll prediction to compare with the two with |
| 287 | // prediction cases below. |
| 288 | TEST_F(AverageLagTrackerTest, NoScrollPrediction) { |
Daniel Libby | f7cf7738 | 2019-05-06 19:23:44 | [diff] [blame] | 289 | // ScrollBegin, at t=5, finger_pos=5px. |
Ella Ge | 7d1d3be20 | 2019-04-08 16:47:59 | [diff] [blame] | 290 | base::TimeTicks event_time = MillisecondsToTimeTicks(5); |
| 291 | base::TimeTicks frame_time = MillisecondsToTimeTicks(10); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 292 | SyntheticTouchScrollBegin(event_time, frame_time, 5 /* scroll_delta */); |
Ella Ge | 7d1d3be20 | 2019-04-08 16:47:59 | [diff] [blame] | 293 | |
| 294 | // ScrollUpdate, at t=15, finger_pos=15px. |
| 295 | event_time = MillisecondsToTimeTicks(15); |
| 296 | frame_time = MillisecondsToTimeTicks(20); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 297 | SyntheticTouchScrollUpdate(event_time, frame_time, 10 /* scroll_delta */); |
Ella Ge | 7d1d3be20 | 2019-04-08 16:47:59 | [diff] [blame] | 298 | |
| 299 | // ScrollUpdate, at t=25, finger_pos=25px. |
| 300 | event_time = MillisecondsToTimeTicks(25); |
| 301 | frame_time = MillisecondsToTimeTicks(30); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 302 | SyntheticTouchScrollUpdate(event_time, frame_time, 10 /* scroll_delta */); |
Ella Ge | 7d1d3be20 | 2019-04-08 16:47:59 | [diff] [blame] | 303 | |
| 304 | // Another ScrollBegin to flush unfinished frames. |
| 305 | event_time = MillisecondsToTimeTicks(1000); |
| 306 | frame_time = MillisecondsToTimeTicks(1000); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 307 | SyntheticTouchScrollBegin(event_time, frame_time, 0); |
Ella Ge | 7d1d3be20 | 2019-04-08 16:47:59 | [diff] [blame] | 308 | |
| 309 | // Prediction hasn't take affect on ScrollBegin so it'll stay the same. |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 310 | CheckScrollBeginHistograms(7, 1); |
Ella Ge | 7d1d3be20 | 2019-04-08 16:47:59 | [diff] [blame] | 311 | // At t=10, finger_pos = 10px, rendered_pos = 5px. |
| 312 | // At t=20, finger_pos = 20px, rendered_pos = 15px. |
| 313 | // At t=30, finger_pos = 25px, rendered_pos = 25px. |
| 314 | // AverageLag = ((5px+15px)*10ms/2 + (5px+10px)*5ms/2 + 10px*5ms)/20ms |
| 315 | // = 9.375 |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 316 | CheckScrollUpdateHistograms(9, 1); |
Ella Ge | 7d1d3be20 | 2019-04-08 16:47:59 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | // Test AverageLag with perfect scroll prediction. |
| 320 | TEST_F(AverageLagTrackerTest, ScrollPrediction) { |
Daniel Libby | f7cf7738 | 2019-05-06 19:23:44 | [diff] [blame] | 321 | // ScrollBegin, at t=5, finger_pos=5px. |
Ella Ge | 7d1d3be20 | 2019-04-08 16:47:59 | [diff] [blame] | 322 | // Predict frame_time=10, predicted_pos = 10px. |
| 323 | base::TimeTicks event_time = MillisecondsToTimeTicks(5); |
| 324 | base::TimeTicks frame_time = MillisecondsToTimeTicks(10); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 325 | SyntheticTouchScrollBegin(event_time, frame_time, 5 /* scroll_delta */, |
| 326 | 10 /* predicted_delta */); |
Ella Ge | 7d1d3be20 | 2019-04-08 16:47:59 | [diff] [blame] | 327 | |
| 328 | // ScrollUpdate, at t=15, finger_pos=15px. |
| 329 | // Predict frame_time=20, predicted_pos = 20px. |
| 330 | event_time = MillisecondsToTimeTicks(15); |
| 331 | frame_time = MillisecondsToTimeTicks(20); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 332 | SyntheticTouchScrollUpdate(event_time, frame_time, 10 /* scroll_delta */, |
| 333 | 10 /* predicted_delta */); |
Ella Ge | 7d1d3be20 | 2019-04-08 16:47:59 | [diff] [blame] | 334 | |
| 335 | // ScrollUpdate, at t=25, finger_pos=25px. |
| 336 | // Predict frame_time=30, predicted_pos = 30px. |
| 337 | event_time = MillisecondsToTimeTicks(25); |
| 338 | frame_time = MillisecondsToTimeTicks(30); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 339 | SyntheticTouchScrollUpdate(event_time, frame_time, 10 /* scroll_delta */, |
| 340 | 10 /* predicted_delta */); |
Ella Ge | 7d1d3be20 | 2019-04-08 16:47:59 | [diff] [blame] | 341 | |
| 342 | // Another ScrollBegin to flush unfinished frames. |
| 343 | event_time = MillisecondsToTimeTicks(1000); |
| 344 | frame_time = MillisecondsToTimeTicks(1000); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 345 | SyntheticTouchScrollBegin(event_time, frame_time, 0); |
Ella Ge | 7d1d3be20 | 2019-04-08 16:47:59 | [diff] [blame] | 346 | |
| 347 | // Prediction hasn't take affect on ScrollBegin so it'll stay the same. |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 348 | CheckScrollBeginHistograms(7, 1); |
Ella Ge | 7d1d3be20 | 2019-04-08 16:47:59 | [diff] [blame] | 349 | // At t=10, finger_pos = 10px, rendered_pos = 10px. |
| 350 | // At t=20, finger_pos = 20px, rendered_pos = 20px. |
| 351 | // At t=30, finger_pos = 25px, rendered_pos = 30px. |
| 352 | // AverageLag = ((0px+10px)*10ms/2 + (0px+5px)*10ms/2 + 5px*5ms)/20ms |
| 353 | // = 4.375px |
Daniel Libby | f7cf7738 | 2019-05-06 19:23:44 | [diff] [blame] | 354 | // AverageLag (w/o prediction) |
| 355 | // ((5px+15px)*10ms/2 + (5px+10px)*5ms/2 + 10px*5ms)/20ms |
| 356 | // = 9.375px |
| 357 | // Positive effect of prediction = 5px |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 358 | CheckScrollUpdateHistograms(4, 1); |
| 359 | CheckPredictionPositiveHistograms(5, 1); |
| 360 | CheckPredictionNegativeHistogramsTotalCount(0); |
Joao Victor Almeida | 49b3d690 | 2021-07-06 17:35:55 | [diff] [blame] | 361 | CheckRemainingLagPercentageHistograms(100 * 4.375 / 9.375, 1); |
Ella Ge | 7d1d3be20 | 2019-04-08 16:47:59 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | // Test AverageLag with imperfect scroll prediction. |
| 365 | TEST_F(AverageLagTrackerTest, ImperfectScrollPrediction) { |
Daniel Libby | f7cf7738 | 2019-05-06 19:23:44 | [diff] [blame] | 366 | // ScrollBegin, at t=5, finger_pos=5px. |
Ella Ge | 7d1d3be20 | 2019-04-08 16:47:59 | [diff] [blame] | 367 | // Predict frame_time=10, predicted_pos(over) = 12px. |
| 368 | base::TimeTicks event_time = MillisecondsToTimeTicks(5); |
| 369 | base::TimeTicks frame_time = MillisecondsToTimeTicks(10); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 370 | SyntheticTouchScrollBegin(event_time, frame_time, 5 /* scroll_delta */, |
| 371 | 12 /* predicted_delta */); |
Ella Ge | 7d1d3be20 | 2019-04-08 16:47:59 | [diff] [blame] | 372 | |
| 373 | // ScrollUpdate, at t=15, finger_pos=15px. |
| 374 | // Predict frame_time=20, predicted_pos(under) = 17px. |
| 375 | event_time = MillisecondsToTimeTicks(15); |
| 376 | frame_time = MillisecondsToTimeTicks(20); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 377 | SyntheticTouchScrollUpdate(event_time, frame_time, 10 /* scroll_delta */, |
| 378 | 5 /* predicted_delta */); |
Ella Ge | 7d1d3be20 | 2019-04-08 16:47:59 | [diff] [blame] | 379 | |
| 380 | // ScrollUpdate, at t=25, finger_pos=25px. |
| 381 | // Predict frame_time=30, predicted_pos(over) = 31px. |
| 382 | event_time = MillisecondsToTimeTicks(25); |
| 383 | frame_time = MillisecondsToTimeTicks(30); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 384 | SyntheticTouchScrollUpdate(event_time, frame_time, 10 /* scroll_delta */, |
| 385 | 14 /* predicted_delta */); |
Ella Ge | 7d1d3be20 | 2019-04-08 16:47:59 | [diff] [blame] | 386 | |
| 387 | // Another ScrollBegin to flush unfinished frames. |
| 388 | event_time = MillisecondsToTimeTicks(1000); |
| 389 | frame_time = MillisecondsToTimeTicks(1000); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 390 | SyntheticTouchScrollBegin(event_time, frame_time, 0); |
Ella Ge | 7d1d3be20 | 2019-04-08 16:47:59 | [diff] [blame] | 391 | |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 392 | CheckScrollBeginHistograms(7, 1); |
Ella Ge | 7d1d3be20 | 2019-04-08 16:47:59 | [diff] [blame] | 393 | // AverageLag = ((2px*2ms/2+8px*8ms/2)+ ((3px+8px)*5ms/2+8px*5ms))/20ms |
| 394 | // = 5.075px |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 395 | CheckScrollUpdateHistograms(5, 1); |
Daniel Libby | f7cf7738 | 2019-05-06 19:23:44 | [diff] [blame] | 396 | // AverageLag (w/o prediction = |
| 397 | // ((5px+15px)*10ms/2 + (5px+10px)*5ms/2 + 10px*5ms)/20ms |
| 398 | // = 9.375px |
| 399 | // Positive effect of prediction = 4.3px |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 400 | CheckPredictionPositiveHistograms(4, 1); |
| 401 | CheckPredictionNegativeHistogramsTotalCount(0); |
Joao Victor Almeida | 49b3d690 | 2021-07-06 17:35:55 | [diff] [blame] | 402 | CheckRemainingLagPercentageHistograms(100 * 5.075 / 9.375, 1); |
Daniel Libby | f7cf7738 | 2019-05-06 19:23:44 | [diff] [blame] | 403 | } |
| 404 | |
| 405 | TEST_F(AverageLagTrackerTest, NegativePredictionEffect) { |
| 406 | // ScrollBegin, at t=5, finger_pos=5px. |
| 407 | // Predict frame_time=10, predicted_pos(over) = 20px. |
| 408 | base::TimeTicks event_time = MillisecondsToTimeTicks(5); |
| 409 | base::TimeTicks frame_time = MillisecondsToTimeTicks(10); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 410 | SyntheticTouchScrollBegin(event_time, frame_time, 5 /* scroll_delta */, |
| 411 | 20 /* predicted_delta */); |
Daniel Libby | f7cf7738 | 2019-05-06 19:23:44 | [diff] [blame] | 412 | |
| 413 | // ScrollUpdate, at t=15, finger_pos=15px. |
| 414 | // Predict frame_time=20, predicted_pos(over) = 60px. |
| 415 | event_time = MillisecondsToTimeTicks(15); |
| 416 | frame_time = MillisecondsToTimeTicks(20); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 417 | SyntheticTouchScrollUpdate(event_time, frame_time, 10 /* scroll_delta */, |
| 418 | 40 /* predicted_delta */); |
Daniel Libby | f7cf7738 | 2019-05-06 19:23:44 | [diff] [blame] | 419 | |
| 420 | // ScrollUpdate, at t=25, finger_pos=25px. |
| 421 | // Predict frame_time=30, predicted_pos(over) = 60px. |
| 422 | event_time = MillisecondsToTimeTicks(25); |
| 423 | frame_time = MillisecondsToTimeTicks(30); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 424 | SyntheticTouchScrollUpdate(event_time, frame_time, 10 /* scroll_delta */, |
| 425 | 0 /* predicted_delta */); |
Daniel Libby | f7cf7738 | 2019-05-06 19:23:44 | [diff] [blame] | 426 | |
| 427 | // Another ScrollBegin to flush unfinished frames. |
| 428 | event_time = MillisecondsToTimeTicks(1000); |
| 429 | frame_time = MillisecondsToTimeTicks(1000); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 430 | SyntheticTouchScrollBegin(event_time, frame_time, 0); |
Daniel Libby | f7cf7738 | 2019-05-06 19:23:44 | [diff] [blame] | 431 | |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 432 | CheckScrollBeginHistograms(7, 1); |
Daniel Libby | f7cf7738 | 2019-05-06 19:23:44 | [diff] [blame] | 433 | // AverageLag = ((10px+0px)*10ms/2)+ ((40px+35px)*5ms/2+35px*5ms))/20ms |
| 434 | // = 20.625px |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 435 | CheckScrollUpdateHistograms(20, 1); |
Daniel Libby | f7cf7738 | 2019-05-06 19:23:44 | [diff] [blame] | 436 | // AverageLag (w/o prediction = |
| 437 | // ((5px+15px)*10ms/2 + (5px+10px)*5ms/2 + 10px*5ms)/20ms |
| 438 | // = 9.375px |
| 439 | // Negative effect of prediction = 11.25 |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 440 | CheckPredictionPositiveHistogramsTotalCount(0); |
| 441 | CheckPredictionNegativeHistograms(11, 1); |
Joao Victor Almeida | 49b3d690 | 2021-07-06 17:35:55 | [diff] [blame] | 442 | |
| 443 | // 100 * 20.625 / 9.375 = 220 is logged into bucket 219. |
| 444 | CheckRemainingLagPercentageHistograms(219, 1); |
Daniel Libby | f7cf7738 | 2019-05-06 19:23:44 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | TEST_F(AverageLagTrackerTest, NoPredictionEffect) { |
| 448 | // ScrollBegin, at t=5, finger_pos=5px. |
| 449 | // Predict frame_time=10, predicted_pos(over) = 25px. |
| 450 | base::TimeTicks event_time = MillisecondsToTimeTicks(5); |
| 451 | base::TimeTicks frame_time = MillisecondsToTimeTicks(10); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 452 | SyntheticTouchScrollBegin(event_time, frame_time, 5 /* scroll_delta */, |
| 453 | 25 /* predicted_delta */); |
Daniel Libby | f7cf7738 | 2019-05-06 19:23:44 | [diff] [blame] | 454 | |
| 455 | // ScrollUpdate, at t=15, finger_pos=15px. |
| 456 | // Predict frame_time=20, predicted_pos(over) = 32px. |
| 457 | event_time = MillisecondsToTimeTicks(15); |
| 458 | frame_time = MillisecondsToTimeTicks(20); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 459 | SyntheticTouchScrollUpdate(event_time, frame_time, 10 /* scroll_delta */, |
| 460 | 7 /* predicted_delta */); |
Daniel Libby | f7cf7738 | 2019-05-06 19:23:44 | [diff] [blame] | 461 | |
| 462 | // ScrollUpdate, at t=25, finger_pos=25px. |
| 463 | // Predict frame_time=30, predicted_pos(over) = 37px. |
| 464 | event_time = MillisecondsToTimeTicks(25); |
| 465 | frame_time = MillisecondsToTimeTicks(30); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 466 | SyntheticTouchScrollUpdate(event_time, frame_time, 10 /* scroll_delta */, |
| 467 | 5 /* predicted_delta */); |
Daniel Libby | f7cf7738 | 2019-05-06 19:23:44 | [diff] [blame] | 468 | |
| 469 | // Another ScrollBegin to flush unfinished frames. |
| 470 | event_time = MillisecondsToTimeTicks(1000); |
| 471 | frame_time = MillisecondsToTimeTicks(1000); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 472 | SyntheticTouchScrollBegin(event_time, frame_time, 0); |
Daniel Libby | f7cf7738 | 2019-05-06 19:23:44 | [diff] [blame] | 473 | |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 474 | CheckScrollBeginHistograms(7, 1); |
Daniel Libby | f7cf7738 | 2019-05-06 19:23:44 | [diff] [blame] | 475 | // AverageLag = ((15px+5px)*10ms/2 + (12px+7px)*5ms/2 + 7px*5ms)/20ms |
| 476 | // = 9.125px |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 477 | CheckScrollUpdateHistograms(9, 1); |
Daniel Libby | f7cf7738 | 2019-05-06 19:23:44 | [diff] [blame] | 478 | // AverageLag (w/o prediction) = |
| 479 | // ((5px+15px)*10ms/2 + (5px+10px)*5ms/2 + 10px*5ms)/20ms |
| 480 | // = 9.375px |
| 481 | // Prediction slightly positive, we should see a 0 bucket in |
| 482 | // PredictionPositive UMA |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 483 | CheckPredictionPositiveHistograms(0, 1); |
| 484 | CheckPredictionNegativeHistogramsTotalCount(0); |
Ella Ge | 7d1d3be20 | 2019-04-08 16:47:59 | [diff] [blame] | 485 | } |
| 486 | |
Matt Amert | 9da83c3 | 2019-11-06 06:04:31 | [diff] [blame] | 487 | // Tests that when an event arrives out-of-order, the average lag tracker |
| 488 | // properly ignores it. |
| 489 | TEST_F(AverageLagTrackerTest, EventOutOfOrder) { |
| 490 | base::TimeTicks event_time = MillisecondsToTimeTicks(5); |
| 491 | base::TimeTicks frame_time = MillisecondsToTimeTicks(10); |
| 492 | float scroll_delta = 5.f; |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 493 | SyntheticTouchScrollBegin(event_time, frame_time, scroll_delta); |
Matt Amert | 9da83c3 | 2019-11-06 06:04:31 | [diff] [blame] | 494 | |
| 495 | event_time = MillisecondsToTimeTicks(15); |
| 496 | frame_time = MillisecondsToTimeTicks(20); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 497 | SyntheticTouchScrollUpdate(event_time, frame_time, scroll_delta); |
Matt Amert | 9da83c3 | 2019-11-06 06:04:31 | [diff] [blame] | 498 | |
| 499 | event_time = MillisecondsToTimeTicks(25); |
| 500 | frame_time = MillisecondsToTimeTicks(30); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 501 | SyntheticTouchScrollUpdate(event_time, frame_time, scroll_delta); |
Matt Amert | 9da83c3 | 2019-11-06 06:04:31 | [diff] [blame] | 502 | |
| 503 | // A ScrollBegin to flush unfinished frames. |
| 504 | event_time = MillisecondsToTimeTicks(1000); |
| 505 | frame_time = MillisecondsToTimeTicks(1000); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 506 | SyntheticTouchScrollBegin(event_time, frame_time, 0); |
Matt Amert | 9da83c3 | 2019-11-06 06:04:31 | [diff] [blame] | 507 | |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 508 | CheckScrollUpdateHistogramsTotalCount(1); |
Matt Amert | 9da83c3 | 2019-11-06 06:04:31 | [diff] [blame] | 509 | |
| 510 | // Send an event whose timestamp is earlier than the most recent event, |
| 511 | // representing an event that gets process out of order. |
| 512 | base::TimeTicks earlier_event_time = MillisecondsToTimeTicks(15); |
| 513 | frame_time = MillisecondsToTimeTicks(1010); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 514 | SyntheticTouchScrollUpdate(earlier_event_time, frame_time, scroll_delta); |
Matt Amert | 9da83c3 | 2019-11-06 06:04:31 | [diff] [blame] | 515 | |
| 516 | // Another ScrollBegin to flush unfinished frames. |
| 517 | event_time = MillisecondsToTimeTicks(2000); |
| 518 | frame_time = MillisecondsToTimeTicks(2000); |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 519 | SyntheticTouchScrollBegin(event_time, frame_time, 0); |
Matt Amert | 9da83c3 | 2019-11-06 06:04:31 | [diff] [blame] | 520 | |
| 521 | // Ensure that the event was ignored. |
Joao Victor Almeida | 0b3c5a9 | 2020-07-07 21:04:43 | [diff] [blame] | 522 | CheckScrollUpdateHistogramsTotalCount(1); |
Matt Amert | 9da83c3 | 2019-11-06 06:04:31 | [diff] [blame] | 523 | } |
| 524 | |
Ella Ge | 792e4f1 | 2019-04-05 17:32:15 | [diff] [blame] | 525 | } // namespace |
Joao Victor Almeida | 917ce17 | 2020-07-07 20:56:12 | [diff] [blame] | 526 | } // namespace cc |