blob: 26dee393c10dd6d7aaf2bb82776457853a753c7a [file] [log] [blame]
Paul Ramirezbe9c5442024-07-10 00:12:41 +00001/**
2 * Copyright 2024 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <input/Resampler.h>
18
19#include <gtest/gtest.h>
20
21#include <chrono>
22#include <memory>
23#include <vector>
24
25#include <input/Input.h>
26#include <input/InputEventBuilders.h>
27#include <input/InputTransport.h>
28#include <utils/Timers.h>
29
30namespace android {
31
32namespace {
33
34using namespace std::literals::chrono_literals;
35
36constexpr float EPSILON = MotionEvent::ROUNDING_PRECISION;
37
38struct Pointer {
39 int32_t id{0};
40 ToolType toolType{ToolType::FINGER};
41 float x{0.0f};
42 float y{0.0f};
43 bool isResampled{false};
44 /**
45 * Converts from Pointer to PointerCoords. Enables calling LegacyResampler methods and
46 * assertions only with the relevant data for tests.
47 */
48 operator PointerCoords() const;
49};
50
51Pointer::operator PointerCoords() const {
52 PointerCoords pointerCoords;
53 pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_X, x);
54 pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, y);
55 pointerCoords.isResampled = isResampled;
56 return pointerCoords;
57}
58
59struct InputSample {
60 std::chrono::milliseconds eventTime{0};
61 std::vector<Pointer> pointers{};
Paul Ramirezcf1b06e2024-08-01 17:11:58 +000062
63 explicit InputSample(std::chrono::milliseconds eventTime, const std::vector<Pointer>& pointers)
64 : eventTime{eventTime}, pointers{pointers} {}
Paul Ramirezbe9c5442024-07-10 00:12:41 +000065 /**
66 * Converts from InputSample to InputMessage. Enables calling LegacyResampler methods only with
67 * the relevant data for tests.
68 */
69 operator InputMessage() const;
70};
71
72InputSample::operator InputMessage() const {
Paul Ramirez7dfaa322024-08-21 17:44:45 +000073 InputMessageBuilder messageBuilder =
74 InputMessageBuilder{InputMessage::Type::MOTION, /*seq=*/0}
75 .eventTime(std::chrono::nanoseconds{eventTime}.count())
76 .source(AINPUT_SOURCE_TOUCHSCREEN)
77 .downTime(0);
Paul Ramirezcf1b06e2024-08-01 17:11:58 +000078
Paul Ramirez7dfaa322024-08-21 17:44:45 +000079 for (const Pointer& pointer : pointers) {
80 messageBuilder.pointer(
81 PointerBuilder{pointer.id, pointer.toolType}.x(pointer.x).y(pointer.y).isResampled(
82 pointer.isResampled));
Paul Ramirezbe9c5442024-07-10 00:12:41 +000083 }
Paul Ramirez7dfaa322024-08-21 17:44:45 +000084 return messageBuilder.build();
Paul Ramirezbe9c5442024-07-10 00:12:41 +000085}
86
87struct InputStream {
88 std::vector<InputSample> samples{};
89 int32_t action{0};
90 DeviceId deviceId{0};
91 /**
92 * Converts from InputStream to MotionEvent. Enables calling LegacyResampler methods only with
93 * the relevant data for tests.
94 */
95 operator MotionEvent() const;
96};
97
98InputStream::operator MotionEvent() const {
99 const InputSample& firstSample{*samples.begin()};
100 MotionEventBuilder motionEventBuilder =
101 MotionEventBuilder(action, AINPUT_SOURCE_CLASS_POINTER)
102 .downTime(0)
103 .eventTime(static_cast<std::chrono::nanoseconds>(firstSample.eventTime).count())
104 .deviceId(deviceId);
105 for (const Pointer& pointer : firstSample.pointers) {
106 const PointerBuilder pointerBuilder =
107 PointerBuilder(pointer.id, pointer.toolType).x(pointer.x).y(pointer.y);
108 motionEventBuilder.pointer(pointerBuilder);
109 }
110 MotionEvent motionEvent = motionEventBuilder.build();
111 const size_t numSamples = samples.size();
112 for (size_t i = 1; i < numSamples; ++i) {
113 std::vector<PointerCoords> pointersCoords{samples[i].pointers.begin(),
114 samples[i].pointers.end()};
115 motionEvent.addSample(static_cast<std::chrono::nanoseconds>(samples[i].eventTime).count(),
116 pointersCoords.data(), motionEvent.getId());
117 }
118 return motionEvent;
119}
120
121} // namespace
122
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000123/**
124 * The testing setup assumes an input rate of 200 Hz and a display rate of 60 Hz. This implies that
125 * input events are received every 5 milliseconds, while the display consumes batched events every
126 * ~16 milliseconds. The resampler's RESAMPLE_LATENCY constant determines the resample time, which
127 * is calculated as frameTime - RESAMPLE_LATENCY. resampleTime specifies the time used for
128 * resampling. For example, if the desired frame time consumption is ~16 milliseconds, the resample
129 * time would be ~11 milliseconds. Consequenly, the last added sample to the motion event has an
130 * event time of ~11 milliseconds. Note that there are specific scenarios where resampleMotionEvent
131 * is not called with a multiple of ~16 milliseconds. These cases are primarily for data addition
132 * or to test other functionalities of the resampler.
133 *
134 * Coordinates are calculated using linear interpolation (lerp) based on the last two available
135 * samples. Linear interpolation is defined as (a + alpha*(b - a)). Let t_b and t_a be the
136 * timestamps of samples a and b, respectively. The interpolation factor alpha is calculated as
137 * (resampleTime - t_a) / (t_b - t_a). The value of alpha determines whether the resampled
138 * coordinates are interpolated or extrapolated. If alpha falls within the semi-closed interval [0,
139 * 1), the coordinates are interpolated. If alpha is greater than or equal to 1, the coordinates are
140 * extrapolated.
141 *
142 * The timeline below depics an interpolation scenario
143 * -----------------------------------|---------|---------|---------|----------
144 * 10ms 11ms 15ms 16ms
145 * MOVE | MOVE |
146 * resampleTime frameTime
147 * Based on the timeline alpha is (11 - 10)/(15 - 10) = 1/5. Thus, coordinates are interpolated.
148 *
149 * The following timeline portrays an extrapolation scenario
150 * -------------------------|---------|---------|-------------------|----------
151 * 5ms 10ms 11ms 16ms
152 * MOVE MOVE | |
153 * resampleTime frameTime
154 * Likewise, alpha = (11 - 5)/(10 - 5) = 6/5. Hence, coordinates are extrapolated.
155 *
156 * If a motion event was resampled, the tests will check that the following conditions are satisfied
157 * to guarantee resampling correctness:
158 * - The motion event metadata must not change.
159 * - The number of samples in the motion event must only increment by 1.
160 * - The resampled values must be at the end of motion event coordinates.
161 * - The rasamples values must be near the hand calculations.
162 * - The resampled time must be the most recent one in motion event.
163 */
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000164class ResamplerTest : public testing::Test {
165protected:
166 ResamplerTest() : mResampler(std::make_unique<LegacyResampler>()) {}
167
168 ~ResamplerTest() override {}
169
170 void SetUp() override {}
171
172 void TearDown() override {}
173
174 std::unique_ptr<Resampler> mResampler;
175
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000176 /**
177 * Checks that beforeCall and afterCall are equal except for the mutated attributes by addSample
178 * member function.
179 * @param beforeCall MotionEvent before passing it to resampleMotionEvent
180 * @param afterCall MotionEvent after passing it to resampleMotionEvent
181 */
182 void assertMotionEventMetaDataDidNotMutate(const MotionEvent& beforeCall,
183 const MotionEvent& afterCall);
184
185 /**
186 * Asserts the MotionEvent is resampled by checking an increment in history size and that the
187 * resampled coordinates are near the expected ones.
188 */
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000189 void assertMotionEventIsResampledAndCoordsNear(
190 const MotionEvent& original, const MotionEvent& resampled,
191 const std::vector<PointerCoords>& expectedCoords);
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000192
193 void assertMotionEventIsNotResampled(const MotionEvent& original,
194 const MotionEvent& notResampled);
195};
196
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000197void ResamplerTest::assertMotionEventMetaDataDidNotMutate(const MotionEvent& beforeCall,
198 const MotionEvent& afterCall) {
199 EXPECT_EQ(beforeCall.getDeviceId(), afterCall.getDeviceId());
200 EXPECT_EQ(beforeCall.getAction(), afterCall.getAction());
201 EXPECT_EQ(beforeCall.getActionButton(), afterCall.getActionButton());
202 EXPECT_EQ(beforeCall.getButtonState(), afterCall.getButtonState());
203 EXPECT_EQ(beforeCall.getFlags(), afterCall.getFlags());
204 EXPECT_EQ(beforeCall.getEdgeFlags(), afterCall.getEdgeFlags());
205 EXPECT_EQ(beforeCall.getClassification(), afterCall.getClassification());
206 EXPECT_EQ(beforeCall.getPointerCount(), afterCall.getPointerCount());
207 EXPECT_EQ(beforeCall.getMetaState(), afterCall.getMetaState());
208 EXPECT_EQ(beforeCall.getSource(), afterCall.getSource());
209 EXPECT_EQ(beforeCall.getXPrecision(), afterCall.getXPrecision());
210 EXPECT_EQ(beforeCall.getYPrecision(), afterCall.getYPrecision());
211 EXPECT_EQ(beforeCall.getDownTime(), afterCall.getDownTime());
212 EXPECT_EQ(beforeCall.getDisplayId(), afterCall.getDisplayId());
213}
214
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000215void ResamplerTest::assertMotionEventIsResampledAndCoordsNear(
216 const MotionEvent& original, const MotionEvent& resampled,
217 const std::vector<PointerCoords>& expectedCoords) {
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000218 assertMotionEventMetaDataDidNotMutate(original, resampled);
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000219
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000220 const size_t originalSampleSize = original.getHistorySize() + 1;
221 const size_t resampledSampleSize = resampled.getHistorySize() + 1;
222 EXPECT_EQ(originalSampleSize + 1, resampledSampleSize);
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000223
224 const size_t numPointers = resampled.getPointerCount();
225 const size_t beginLatestSample = resampledSampleSize - 1;
226 for (size_t i = 0; i < numPointers; ++i) {
227 SCOPED_TRACE(i);
228 EXPECT_EQ(original.getPointerId(i), resampled.getPointerId(i));
229 EXPECT_EQ(original.getToolType(i), resampled.getToolType(i));
230
231 const PointerCoords& resampledCoords =
232 resampled.getSamplePointerCoords()[beginLatestSample * numPointers + i];
233
234 EXPECT_TRUE(resampledCoords.isResampled);
235 EXPECT_NEAR(expectedCoords[i].getX(), resampledCoords.getX(), EPSILON);
236 EXPECT_NEAR(expectedCoords[i].getY(), resampledCoords.getY(), EPSILON);
237 }
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000238}
239
240void ResamplerTest::assertMotionEventIsNotResampled(const MotionEvent& original,
241 const MotionEvent& notResampled) {
242 assertMotionEventMetaDataDidNotMutate(original, notResampled);
243 const size_t originalSampleSize = original.getHistorySize() + 1;
244 const size_t notResampledSampleSize = notResampled.getHistorySize() + 1;
245 EXPECT_EQ(originalSampleSize, notResampledSampleSize);
246}
247
Paul Ramirez68ca3d12024-08-12 23:00:50 +0000248TEST_F(ResamplerTest, NonResampledAxesArePreserved) {
249 constexpr float TOUCH_MAJOR_VALUE = 1.0f;
250
251 MotionEvent motionEvent =
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000252 InputStream{{InputSample{5ms, {{.id = 0, .x = 1.0f, .y = 1.0f, .isResampled = false}}}},
Paul Ramirez68ca3d12024-08-12 23:00:50 +0000253 AMOTION_EVENT_ACTION_MOVE};
254
255 constexpr std::chrono::nanoseconds eventTime{10ms};
256 PointerCoords pointerCoords{};
257 pointerCoords.isResampled = false;
258 pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_X, 2.0f);
259 pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, 2.0f);
260 pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, TOUCH_MAJOR_VALUE);
261
262 motionEvent.addSample(eventTime.count(), &pointerCoords, motionEvent.getId());
263
264 const InputMessage futureSample =
265 InputSample{15ms, {{.id = 0, .x = 3.0f, .y = 4.0f, .isResampled = false}}};
266
267 const MotionEvent originalMotionEvent = motionEvent;
268
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000269 mResampler->resampleMotionEvent(16ms, motionEvent, &futureSample);
Paul Ramirez68ca3d12024-08-12 23:00:50 +0000270
271 EXPECT_EQ(motionEvent.getTouchMajor(0), TOUCH_MAJOR_VALUE);
272
273 assertMotionEventIsResampledAndCoordsNear(originalMotionEvent, motionEvent,
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000274 {Pointer{.id = 0,
275 .x = 2.2f,
276 .y = 2.4f,
277 .isResampled = true}});
Paul Ramirez68ca3d12024-08-12 23:00:50 +0000278}
279
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000280TEST_F(ResamplerTest, SinglePointerNotEnoughDataToResample) {
281 MotionEvent motionEvent =
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000282 InputStream{{InputSample{5ms, {{.id = 0, .x = 1.0f, .y = 1.0f, .isResampled = false}}}},
283 AMOTION_EVENT_ACTION_MOVE};
284
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000285 const MotionEvent originalMotionEvent = motionEvent;
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000286
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000287 mResampler->resampleMotionEvent(16ms, motionEvent, /*futureSample=*/nullptr);
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000288
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000289 assertMotionEventIsNotResampled(originalMotionEvent, motionEvent);
290}
291
292TEST_F(ResamplerTest, SinglePointerDifferentDeviceIdBetweenMotionEvents) {
293 MotionEvent motionFromFirstDevice =
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000294 InputStream{{InputSample{4ms, {{.id = 0, .x = 1.0f, .y = 1.0f, .isResampled = false}}},
295 InputSample{8ms, {{.id = 0, .x = 2.0f, .y = 2.0f, .isResampled = false}}}},
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000296 AMOTION_EVENT_ACTION_MOVE,
297 .deviceId = 0};
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000298
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000299 mResampler->resampleMotionEvent(10ms, motionFromFirstDevice, nullptr);
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000300
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000301 MotionEvent motionFromSecondDevice =
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000302 InputStream{{InputSample{11ms,
303 {{.id = 0, .x = 3.0f, .y = 3.0f, .isResampled = false}}}},
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000304 AMOTION_EVENT_ACTION_MOVE,
305 .deviceId = 1};
306 const MotionEvent originalMotionEvent = motionFromSecondDevice;
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000307
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000308 mResampler->resampleMotionEvent(12ms, motionFromSecondDevice, nullptr);
309 // The MotionEvent should not be resampled because the second event came from a different device
310 // than the previous event.
311 assertMotionEventIsNotResampled(originalMotionEvent, motionFromSecondDevice);
312}
313
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000314TEST_F(ResamplerTest, SinglePointerSingleSampleInterpolation) {
315 MotionEvent motionEvent =
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000316 InputStream{{InputSample{10ms,
317 {{.id = 0, .x = 1.0f, .y = 2.0f, .isResampled = false}}}},
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000318 AMOTION_EVENT_ACTION_MOVE};
319 const InputMessage futureSample =
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000320 InputSample{15ms, {{.id = 0, .x = 2.0f, .y = 4.0f, .isResampled = false}}};
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000321
322 const MotionEvent originalMotionEvent = motionEvent;
323
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000324 mResampler->resampleMotionEvent(16ms, motionEvent, &futureSample);
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000325
326 assertMotionEventIsResampledAndCoordsNear(originalMotionEvent, motionEvent,
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000327 {Pointer{.id = 0,
328 .x = 1.2f,
329 .y = 2.4f,
330 .isResampled = true}});
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000331}
332
333TEST_F(ResamplerTest, SinglePointerDeltaTooSmallInterpolation) {
334 MotionEvent motionEvent =
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000335 InputStream{{InputSample{10ms,
336 {{.id = 0, .x = 1.0f, .y = 2.0f, .isResampled = false}}}},
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000337 AMOTION_EVENT_ACTION_MOVE};
338 const InputMessage futureSample =
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000339 InputSample{11ms, {{.id = 0, .x = 2.0f, .y = 4.0f, .isResampled = false}}};
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000340
341 const MotionEvent originalMotionEvent = motionEvent;
342
343 mResampler->resampleMotionEvent(10'500'000ns, motionEvent, &futureSample);
344
345 assertMotionEventIsNotResampled(originalMotionEvent, motionEvent);
346}
347
348/**
349 * Tests extrapolation given two MotionEvents with a single sample.
350 */
351TEST_F(ResamplerTest, SinglePointerSingleSampleExtrapolation) {
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000352 MotionEvent firstMotionEvent =
353 InputStream{{InputSample{5ms, {{.id = 0, .x = 1.0f, .y = 2.0f, .isResampled = false}}}},
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000354 AMOTION_EVENT_ACTION_MOVE};
355
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000356 mResampler->resampleMotionEvent(9ms, firstMotionEvent, nullptr);
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000357
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000358 MotionEvent secondMotionEvent =
359 InputStream{{InputSample{10ms,
360 {{.id = 0, .x = 2.0f, .y = 4.0f, .isResampled = false}}}},
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000361 AMOTION_EVENT_ACTION_MOVE};
362
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000363 const MotionEvent originalMotionEvent = secondMotionEvent;
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000364
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000365 mResampler->resampleMotionEvent(16ms, secondMotionEvent, nullptr);
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000366
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000367 assertMotionEventIsResampledAndCoordsNear(originalMotionEvent, secondMotionEvent,
368 {Pointer{.id = 0,
369 .x = 2.2f,
370 .y = 4.4f,
371 .isResampled = true}});
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000372}
373
374TEST_F(ResamplerTest, SinglePointerMultipleSampleInterpolation) {
375 MotionEvent motionEvent =
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000376 InputStream{{InputSample{5ms, {{.id = 0, .x = 1.0f, .y = 2.0f, .isResampled = false}}},
377 InputSample{10ms,
378 {{.id = 0, .x = 2.0f, .y = 3.0f, .isResampled = false}}}},
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000379 AMOTION_EVENT_ACTION_MOVE};
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000380
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000381 const InputMessage futureSample =
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000382 InputSample{15ms, {{.id = 0, .x = 3.0f, .y = 5.0f, .isResampled = false}}};
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000383
384 const MotionEvent originalMotionEvent = motionEvent;
385
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000386 mResampler->resampleMotionEvent(16ms, motionEvent, &futureSample);
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000387
388 assertMotionEventIsResampledAndCoordsNear(originalMotionEvent, motionEvent,
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000389 {Pointer{.id = 0,
390 .x = 2.2f,
391 .y = 3.4f,
392 .isResampled = true}});
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000393}
394
395TEST_F(ResamplerTest, SinglePointerMultipleSampleExtrapolation) {
396 MotionEvent motionEvent =
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000397 InputStream{{InputSample{5ms, {{.id = 0, .x = 1.0f, .y = 2.0f, .isResampled = false}}},
398 InputSample{10ms,
399 {{.id = 0, .x = 2.0f, .y = 4.0f, .isResampled = false}}}},
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000400 AMOTION_EVENT_ACTION_MOVE};
401
402 const MotionEvent originalMotionEvent = motionEvent;
403
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000404 mResampler->resampleMotionEvent(16ms, motionEvent, nullptr);
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000405
406 assertMotionEventIsResampledAndCoordsNear(originalMotionEvent, motionEvent,
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000407 {Pointer{.id = 0,
408 .x = 2.2f,
409 .y = 4.4f,
410 .isResampled = true}});
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000411}
412
413TEST_F(ResamplerTest, SinglePointerDeltaTooSmallExtrapolation) {
414 MotionEvent motionEvent =
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000415 InputStream{{InputSample{9ms, {{.id = 0, .x = 1.0f, .y = 2.0f, .isResampled = false}}},
416 InputSample{10ms,
417 {{.id = 0, .x = 2.0f, .y = 4.0f, .isResampled = false}}}},
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000418 AMOTION_EVENT_ACTION_MOVE};
419
420 const MotionEvent originalMotionEvent = motionEvent;
421
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000422 mResampler->resampleMotionEvent(16ms, motionEvent, nullptr);
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000423
424 assertMotionEventIsNotResampled(originalMotionEvent, motionEvent);
425}
426
427TEST_F(ResamplerTest, SinglePointerDeltaTooLargeExtrapolation) {
428 MotionEvent motionEvent =
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000429 InputStream{{InputSample{5ms, {{.id = 0, .x = 1.0f, .y = 2.0f, .isResampled = false}}},
430 InputSample{26ms,
431 {{.id = 0, .x = 2.0f, .y = 4.0f, .isResampled = false}}}},
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000432 AMOTION_EVENT_ACTION_MOVE};
433
434 const MotionEvent originalMotionEvent = motionEvent;
435
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000436 mResampler->resampleMotionEvent(32ms, motionEvent, nullptr);
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000437
438 assertMotionEventIsNotResampled(originalMotionEvent, motionEvent);
439}
440
441TEST_F(ResamplerTest, SinglePointerResampleTimeTooFarExtrapolation) {
442 MotionEvent motionEvent =
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000443 InputStream{{InputSample{5ms, {{.id = 0, .x = 1.0f, .y = 2.0f, .isResampled = false}}},
444 InputSample{25ms,
445 {{.id = 0, .x = 2.0f, .y = 4.0f, .isResampled = false}}}},
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000446 AMOTION_EVENT_ACTION_MOVE};
447
448 const MotionEvent originalMotionEvent = motionEvent;
449
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000450 mResampler->resampleMotionEvent(48ms, motionEvent, nullptr);
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000451
452 assertMotionEventIsResampledAndCoordsNear(originalMotionEvent, motionEvent,
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000453 {Pointer{.id = 0,
454 .x = 2.4f,
455 .y = 4.8f,
456 .isResampled = true}});
457}
458
459TEST_F(ResamplerTest, MultiplePointerSingleSampleInterpolation) {
460 MotionEvent motionEvent =
461 InputStream{{InputSample{5ms,
462 {{.id = 0, .x = 1.0f, .y = 1.0f, .isResampled = false},
463 {.id = 1, .x = 2.0f, .y = 2.0f, .isResampled = false}}}},
464 AMOTION_EVENT_ACTION_MOVE};
465
466 const InputMessage futureSample =
467 InputSample{15ms,
468 {{.id = 0, .x = 3.0f, .y = 3.0f, .isResampled = false},
469 {.id = 1, .x = 4.0f, .y = 4.0f, .isResampled = false}}};
470
471 const MotionEvent originalMotionEvent = motionEvent;
472
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000473 mResampler->resampleMotionEvent(16ms, motionEvent, &futureSample);
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000474
475 assertMotionEventIsResampledAndCoordsNear(originalMotionEvent, motionEvent,
476 {Pointer{.x = 2.2f, .y = 2.2f, .isResampled = true},
477 Pointer{.x = 3.2f, .y = 3.2f, .isResampled = true}});
478}
479
480TEST_F(ResamplerTest, MultiplePointerSingleSampleExtrapolation) {
481 MotionEvent firstMotionEvent =
482 InputStream{{InputSample{5ms,
483 {{.id = 0, .x = 1.0f, .y = 1.0f, .isResampled = false},
484 {.id = 1, .x = 2.0f, .y = 2.0f, .isResampled = false}}}},
485 AMOTION_EVENT_ACTION_MOVE};
486
487 mResampler->resampleMotionEvent(9ms, firstMotionEvent, /*futureSample=*/nullptr);
488
489 MotionEvent secondMotionEvent =
490 InputStream{{InputSample{10ms,
491 {{.id = 0, .x = 3.0f, .y = 3.0f, .isResampled = false},
492 {.id = 1, .x = 4.0f, .y = 4.0f, .isResampled = false}}}},
493 AMOTION_EVENT_ACTION_MOVE};
494
495 const MotionEvent originalMotionEvent = secondMotionEvent;
496
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000497 mResampler->resampleMotionEvent(16ms, secondMotionEvent, /*futureSample=*/nullptr);
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000498
499 assertMotionEventIsResampledAndCoordsNear(originalMotionEvent, secondMotionEvent,
500 {Pointer{.x = 3.4f, .y = 3.4f, .isResampled = true},
501 Pointer{.x = 4.4f, .y = 4.4f, .isResampled = true}});
502}
503
504TEST_F(ResamplerTest, MultiplePointerMultipleSampleInterpolation) {
505 MotionEvent motionEvent =
506 InputStream{{InputSample{5ms,
507 {{.id = 0, .x = 1.0f, .y = 1.0f, .isResampled = false},
508 {.id = 1, .x = 2.0f, .y = 2.0f, .isResampled = false}}},
509 InputSample{10ms,
510 {{.id = 0, .x = 3.0f, .y = 3.0f, .isResampled = false},
511 {.id = 1, .x = 4.0f, .y = 4.0f, .isResampled = false}}}},
512 AMOTION_EVENT_ACTION_MOVE};
513 const InputMessage futureSample =
514 InputSample{15ms,
515 {{.id = 0, .x = 5.0f, .y = 5.0f, .isResampled = false},
516 {.id = 1, .x = 6.0f, .y = 6.0f, .isResampled = false}}};
517
518 const MotionEvent originalMotionEvent = motionEvent;
519
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000520 mResampler->resampleMotionEvent(16ms, motionEvent, &futureSample);
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000521
522 assertMotionEventIsResampledAndCoordsNear(originalMotionEvent, motionEvent,
523 {Pointer{.x = 3.4f, .y = 3.4f, .isResampled = true},
524 Pointer{.x = 4.4f, .y = 4.4f, .isResampled = true}});
525}
526
527TEST_F(ResamplerTest, MultiplePointerMultipleSampleExtrapolation) {
528 MotionEvent motionEvent =
529 InputStream{{InputSample{5ms,
530 {{.id = 0, .x = 1.0f, .y = 1.0f, .isResampled = false},
531 {.id = 1, .x = 2.0f, .y = 2.0f, .isResampled = false}}},
532 InputSample{10ms,
533 {{.id = 0, .x = 3.0f, .y = 3.0f, .isResampled = false},
534 {.id = 1, .x = 4.0f, .y = 4.0f, .isResampled = false}}}},
535 AMOTION_EVENT_ACTION_MOVE};
536
537 const MotionEvent originalMotionEvent = motionEvent;
538
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000539 mResampler->resampleMotionEvent(16ms, motionEvent, /*futureSample=*/nullptr);
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000540
541 assertMotionEventIsResampledAndCoordsNear(originalMotionEvent, motionEvent,
542 {Pointer{.x = 3.4f, .y = 3.4f, .isResampled = true},
543 Pointer{.x = 4.4f, .y = 4.4f, .isResampled = true}});
544}
545
546TEST_F(ResamplerTest, MultiplePointerIncreaseNumPointersInterpolation) {
547 MotionEvent motionEvent =
548 InputStream{{InputSample{10ms,
549 {{.id = 0, .x = 1.0f, .y = 1.0f, .isResampled = false},
550 {.id = 1, .x = 2.0f, .y = 2.0f, .isResampled = false}}}},
551 AMOTION_EVENT_ACTION_MOVE};
552
553 const InputMessage futureSample =
554 InputSample{15ms,
555 {{.id = 0, .x = 3.0f, .y = 3.0f, .isResampled = false},
556 {.id = 1, .x = 4.0f, .y = 4.0f, .isResampled = false},
557 {.id = 2, .x = 5.0f, .y = 5.0f, .isResampled = false}}};
558
559 const MotionEvent originalMotionEvent = motionEvent;
560
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000561 mResampler->resampleMotionEvent(16ms, motionEvent, &futureSample);
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000562
563 assertMotionEventIsResampledAndCoordsNear(originalMotionEvent, motionEvent,
564 {Pointer{.x = 1.4f, .y = 1.4f, .isResampled = true},
565 Pointer{.x = 2.4f, .y = 2.4f, .isResampled = true}});
566
567 MotionEvent secondMotionEvent =
568 InputStream{{InputSample{25ms,
569 {{.id = 0, .x = 3.0f, .y = 3.0f, .isResampled = false},
570 {.id = 1, .x = 4.0f, .y = 4.0f, .isResampled = false},
571 {.id = 2, .x = 5.0f, .y = 5.0f, .isResampled = false}}}},
572 AMOTION_EVENT_ACTION_MOVE};
573
574 const InputMessage secondFutureSample =
575 InputSample{30ms,
576 {{.id = 0, .x = 5.0f, .y = 5.0f, .isResampled = false},
577 {.id = 1, .x = 6.0f, .y = 6.0f, .isResampled = false},
578 {.id = 2, .x = 7.0f, .y = 7.0f, .isResampled = false}}};
579
580 const MotionEvent originalSecondMotionEvent = secondMotionEvent;
581
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000582 mResampler->resampleMotionEvent(32ms, secondMotionEvent, &secondFutureSample);
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000583
584 assertMotionEventIsResampledAndCoordsNear(originalSecondMotionEvent, secondMotionEvent,
585 {Pointer{.x = 3.8f, .y = 3.8f, .isResampled = true},
586 Pointer{.x = 4.8f, .y = 4.8f, .isResampled = true},
587 Pointer{.x = 5.8f, .y = 5.8f, .isResampled = true}});
588}
589
590TEST_F(ResamplerTest, MultiplePointerIncreaseNumPointersExtrapolation) {
591 MotionEvent firstMotionEvent =
592 InputStream{{InputSample{5ms,
593 {{.id = 0, .x = 1.0f, .y = 1.0f, .isResampled = false},
594 {.id = 1, .x = 2.0f, .y = 2.0f, .isResampled = false}}}},
595 AMOTION_EVENT_ACTION_MOVE};
596
597 mResampler->resampleMotionEvent(9ms, firstMotionEvent, /*futureSample=*/nullptr);
598
599 MotionEvent secondMotionEvent =
600 InputStream{{InputSample{10ms,
601 {{.id = 0, .x = 3.0f, .y = 3.0f, .isResampled = false},
602 {.id = 1, .x = 4.0f, .y = 4.0f, .isResampled = false},
603 {.id = 2, .x = 5.0f, .y = 5.0f, .isResampled = false}}}},
604 AMOTION_EVENT_ACTION_MOVE};
605
606 const MotionEvent secondOriginalMotionEvent = secondMotionEvent;
607
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000608 mResampler->resampleMotionEvent(16ms, secondMotionEvent, /*futureSample=*/nullptr);
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000609
610 assertMotionEventIsNotResampled(secondOriginalMotionEvent, secondMotionEvent);
611}
612
613TEST_F(ResamplerTest, MultiplePointerDecreaseNumPointersInterpolation) {
614 MotionEvent motionEvent =
615 InputStream{{InputSample{10ms,
616 {{.id = 0, .x = 3.0f, .y = 3.0f, .isResampled = false},
617 {.id = 1, .x = 4.0f, .y = 4.0f, .isResampled = false},
618 {.id = 2, .x = 5.0f, .y = 5.0f, .isResampled = false}}}},
619 AMOTION_EVENT_ACTION_MOVE};
620
621 const InputMessage futureSample =
622 InputSample{15ms,
623 {{.id = 0, .x = 4.0f, .y = 4.0f, .isResampled = false},
624 {.id = 1, .x = 5.0f, .y = 5.0f, .isResampled = false}}};
625
626 const MotionEvent originalMotionEvent = motionEvent;
627
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000628 mResampler->resampleMotionEvent(16ms, motionEvent, &futureSample);
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000629
630 assertMotionEventIsNotResampled(originalMotionEvent, motionEvent);
631}
632
633TEST_F(ResamplerTest, MultiplePointerDecreaseNumPointersExtrapolation) {
634 MotionEvent firstMotionEvent =
635 InputStream{{InputSample{5ms,
636 {{.id = 0, .x = 1.0f, .y = 1.0f, .isResampled = false},
637 {.id = 1, .x = 2.0f, .y = 2.0f, .isResampled = false},
638 {.id = 2, .x = 3.0f, .y = 3.0f, .isResampled = false}}}},
639 AMOTION_EVENT_ACTION_MOVE};
640
641 mResampler->resampleMotionEvent(9ms, firstMotionEvent, /*futureSample=*/nullptr);
642
643 MotionEvent secondMotionEvent =
644 InputStream{{InputSample{10ms,
645 {{.id = 0, .x = 3.0f, .y = 3.0f, .isResampled = false},
646 {.id = 1, .x = 4.0f, .y = 4.0f, .isResampled = false}}}},
647 AMOTION_EVENT_ACTION_MOVE};
648
649 const MotionEvent secondOriginalMotionEvent = secondMotionEvent;
650
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000651 mResampler->resampleMotionEvent(16ms, secondMotionEvent, /*futureSample=*/nullptr);
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000652
653 assertMotionEventIsResampledAndCoordsNear(secondOriginalMotionEvent, secondMotionEvent,
654 {Pointer{.x = 3.4f, .y = 3.4f, .isResampled = true},
655 Pointer{.x = 4.4f, .y = 4.4f, .isResampled = true}});
656}
657
658TEST_F(ResamplerTest, MultiplePointerDifferentIdOrderInterpolation) {
659 MotionEvent motionEvent =
660 InputStream{{InputSample{10ms,
661 {{.id = 0, .x = 1.0f, .y = 1.0f, .isResampled = false},
662 {.id = 1, .x = 2.0f, .y = 2.0f, .isResampled = false}}}},
663 AMOTION_EVENT_ACTION_MOVE};
664
665 const InputMessage futureSample =
666 InputSample{15ms,
667 {{.id = 1, .x = 4.0f, .y = 4.0f, .isResampled = false},
668 {.id = 0, .x = 3.0f, .y = 3.0f, .isResampled = false}}};
669
670 const MotionEvent originalMotionEvent = motionEvent;
671
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000672 mResampler->resampleMotionEvent(16ms, motionEvent, &futureSample);
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000673
674 assertMotionEventIsNotResampled(originalMotionEvent, motionEvent);
675}
676
677TEST_F(ResamplerTest, MultiplePointerDifferentIdOrderExtrapolation) {
678 MotionEvent firstMotionEvent =
679 InputStream{{InputSample{5ms,
680 {{.id = 0, .x = 1.0f, .y = 1.0f, .isResampled = false},
681 {.id = 1, .x = 2.0f, .y = 2.0f, .isResampled = false}}}},
682 AMOTION_EVENT_ACTION_MOVE};
683
684 mResampler->resampleMotionEvent(9ms, firstMotionEvent, /*futureSample=*/nullptr);
685
686 MotionEvent secondMotionEvent =
687 InputStream{{InputSample{10ms,
688 {{.id = 1, .x = 4.0f, .y = 4.0f, .isResampled = false},
689 {.id = 0, .x = 3.0f, .y = 3.0f, .isResampled = false}}}},
690 AMOTION_EVENT_ACTION_MOVE};
691
692 const MotionEvent secondOriginalMotionEvent = secondMotionEvent;
693
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000694 mResampler->resampleMotionEvent(16ms, secondMotionEvent, /*futureSample=*/nullptr);
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000695
696 assertMotionEventIsNotResampled(secondOriginalMotionEvent, secondMotionEvent);
697}
698
699TEST_F(ResamplerTest, MultiplePointerDifferentIdsInterpolation) {
700 MotionEvent motionEvent =
701 InputStream{{InputSample{10ms,
702 {{.id = 0, .x = 1.0f, .y = 1.0f, .isResampled = false},
703 {.id = 1, .x = 2.0f, .y = 2.0f, .isResampled = false}}}},
704 AMOTION_EVENT_ACTION_MOVE};
705
706 const InputMessage futureSample =
707 InputSample{15ms,
708 {{.id = 1, .x = 4.0f, .y = 4.0f, .isResampled = false},
709 {.id = 2, .x = 3.0f, .y = 3.0f, .isResampled = false}}};
710
711 const MotionEvent originalMotionEvent = motionEvent;
712
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000713 mResampler->resampleMotionEvent(16ms, motionEvent, &futureSample);
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000714
715 assertMotionEventIsNotResampled(originalMotionEvent, motionEvent);
716}
717
718TEST_F(ResamplerTest, MultiplePointerDifferentIdsExtrapolation) {
719 MotionEvent firstMotionEvent =
720 InputStream{{InputSample{5ms,
721 {{.id = 0, .x = 1.0f, .y = 1.0f, .isResampled = false},
722 {.id = 1, .x = 2.0f, .y = 2.0f, .isResampled = false}}}},
723 AMOTION_EVENT_ACTION_MOVE};
724
725 mResampler->resampleMotionEvent(9ms, firstMotionEvent, /*futureSample=*/nullptr);
726
727 MotionEvent secondMotionEvent =
728 InputStream{{InputSample{10ms,
729 {{.id = 1, .x = 4.0f, .y = 4.0f, .isResampled = false},
730 {.id = 2, .x = 3.0f, .y = 3.0f, .isResampled = false}}}},
731 AMOTION_EVENT_ACTION_MOVE};
732
733 const MotionEvent secondOriginalMotionEvent = secondMotionEvent;
734
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000735 mResampler->resampleMotionEvent(16ms, secondMotionEvent, /*futureSample=*/nullptr);
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000736
737 assertMotionEventIsNotResampled(secondOriginalMotionEvent, secondMotionEvent);
738}
739
740TEST_F(ResamplerTest, MultiplePointerDifferentToolTypeInterpolation) {
741 MotionEvent motionEvent = InputStream{{InputSample{10ms,
742 {{.id = 0,
743 .toolType = ToolType::FINGER,
744 .x = 1.0f,
745 .y = 1.0f,
746 .isResampled = false},
747 {.id = 1,
748 .toolType = ToolType::FINGER,
749 .x = 2.0f,
750 .y = 2.0f,
751 .isResampled = false}}}},
752 AMOTION_EVENT_ACTION_MOVE};
753
754 const InputMessage futureSample = InputSample{15ms,
755 {{.id = 0,
756 .toolType = ToolType::FINGER,
757 .x = 3.0,
758 .y = 3.0,
759 .isResampled = false},
760 {.id = 1,
761 .toolType = ToolType::STYLUS,
762 .x = 4.0,
763 .y = 4.0,
764 .isResampled = false}}};
765
766 const MotionEvent originalMotionEvent = motionEvent;
767
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000768 mResampler->resampleMotionEvent(16ms, motionEvent, &futureSample);
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000769
770 assertMotionEventIsNotResampled(originalMotionEvent, motionEvent);
771}
772
773TEST_F(ResamplerTest, MultiplePointerDifferentToolTypeExtrapolation) {
774 MotionEvent firstMotionEvent = InputStream{{InputSample{5ms,
775 {{.id = 0,
776 .toolType = ToolType::FINGER,
777 .x = 1.0f,
778 .y = 1.0f,
779 .isResampled = false},
780 {.id = 1,
781 .toolType = ToolType::FINGER,
782 .x = 2.0f,
783 .y = 2.0f,
784 .isResampled = false}}}},
785 AMOTION_EVENT_ACTION_MOVE};
786
787 mResampler->resampleMotionEvent(9ms, firstMotionEvent, /*futureSample=*/nullptr);
788
789 MotionEvent secondMotionEvent = InputStream{{InputSample{10ms,
790 {{.id = 0,
791 .toolType = ToolType::FINGER,
792 .x = 1.0f,
793 .y = 1.0f,
794 .isResampled = false},
795 {.id = 1,
796 .toolType = ToolType::STYLUS,
797 .x = 2.0f,
798 .y = 2.0f,
799 .isResampled = false}}}},
800 AMOTION_EVENT_ACTION_MOVE};
801
802 const MotionEvent secondOriginalMotionEvent = secondMotionEvent;
803
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000804 mResampler->resampleMotionEvent(16ms, secondMotionEvent, /*futureSample=*/nullptr);
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000805
806 assertMotionEventIsNotResampled(secondOriginalMotionEvent, secondMotionEvent);
807}
808
809TEST_F(ResamplerTest, MultiplePointerShouldNotResampleToolTypeInterpolation) {
810 MotionEvent motionEvent = InputStream{{InputSample{10ms,
811 {{.id = 0,
812 .toolType = ToolType::PALM,
813 .x = 1.0f,
814 .y = 1.0f,
815 .isResampled = false},
816 {.id = 1,
817 .toolType = ToolType::PALM,
818 .x = 2.0f,
819 .y = 2.0f,
820 .isResampled = false}}}},
821 AMOTION_EVENT_ACTION_MOVE};
822
823 const InputMessage futureSample = InputSample{15ms,
824 {{.id = 0,
825 .toolType = ToolType::PALM,
826 .x = 3.0,
827 .y = 3.0,
828 .isResampled = false},
829 {.id = 1,
830 .toolType = ToolType::PALM,
831 .x = 4.0,
832 .y = 4.0,
833 .isResampled = false}}};
834
835 const MotionEvent originalMotionEvent = motionEvent;
836
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000837 mResampler->resampleMotionEvent(16ms, motionEvent, /*futureSample=*/nullptr);
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000838
839 assertMotionEventIsNotResampled(originalMotionEvent, motionEvent);
840}
841
842TEST_F(ResamplerTest, MultiplePointerShouldNotResampleToolTypeExtrapolation) {
843 MotionEvent motionEvent = InputStream{{InputSample{5ms,
844 {{.id = 0,
845 .toolType = ToolType::PALM,
846 .x = 1.0f,
847 .y = 1.0f,
848 .isResampled = false},
849 {.id = 1,
850 .toolType = ToolType::PALM,
851 .x = 2.0f,
852 .y = 2.0f,
853 .isResampled = false}}},
854 InputSample{10ms,
855 {{.id = 0,
856 .toolType = ToolType::PALM,
857 .x = 3.0f,
858 .y = 3.0f,
859 .isResampled = false},
860 {.id = 1,
861 .toolType = ToolType::PALM,
862 .x = 4.0f,
863 .y = 4.0f,
864 .isResampled = false}}}},
865 AMOTION_EVENT_ACTION_MOVE};
866
867 const MotionEvent originalMotionEvent = motionEvent;
868
Paul Ramirez6affbdb2024-09-11 22:20:26 +0000869 mResampler->resampleMotionEvent(16ms, motionEvent, /*futureSample=*/nullptr);
Paul Ramirezcf1b06e2024-08-01 17:11:58 +0000870
871 assertMotionEventIsNotResampled(originalMotionEvent, motionEvent);
Paul Ramirezbe9c5442024-07-10 00:12:41 +0000872}
873} // namespace android