blob: 885196f3f326337432cac9d95dc5c196738ca5e0 [file] [log] [blame]
Jeff Brown5912f952013-07-01 19:10:31 -07001/*
2 * Copyright (C) 2010 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 "TestHelpers.h"
18
19#include <unistd.h>
20#include <sys/mman.h>
21#include <time.h>
22
23#include <cutils/ashmem.h>
24#include <gtest/gtest.h>
25#include <input/InputTransport.h>
26#include <utils/Timers.h>
27#include <utils/StopWatch.h>
28
29namespace android {
30
31class InputPublisherAndConsumerTest : public testing::Test {
32protected:
33 sp<InputChannel> serverChannel, clientChannel;
34 InputPublisher* mPublisher;
35 InputConsumer* mConsumer;
36 PreallocatedInputEventFactory mEventFactory;
37
38 virtual void SetUp() {
Siarhei Vishniakouf93fcf42017-11-22 16:00:14 -080039 status_t result = InputChannel::openInputChannelPair("channel name",
Jeff Brown5912f952013-07-01 19:10:31 -070040 serverChannel, clientChannel);
Siarhei Vishniakou54d3e182020-01-15 17:38:38 -080041 ASSERT_EQ(OK, result);
Jeff Brown5912f952013-07-01 19:10:31 -070042
43 mPublisher = new InputPublisher(serverChannel);
44 mConsumer = new InputConsumer(clientChannel);
45 }
46
47 virtual void TearDown() {
48 if (mPublisher) {
49 delete mPublisher;
Yi Kong5bed83b2018-07-17 12:53:47 -070050 mPublisher = nullptr;
Jeff Brown5912f952013-07-01 19:10:31 -070051 }
52
53 if (mConsumer) {
54 delete mConsumer;
Yi Kong5bed83b2018-07-17 12:53:47 -070055 mConsumer = nullptr;
Jeff Brown5912f952013-07-01 19:10:31 -070056 }
57
58 serverChannel.clear();
59 clientChannel.clear();
60 }
61
62 void PublishAndConsumeKeyEvent();
63 void PublishAndConsumeMotionEvent();
Siarhei Vishniakou7feb2ea2019-11-25 15:11:23 -080064 void PublishAndConsumeFocusEvent();
Jeff Brown5912f952013-07-01 19:10:31 -070065};
66
67TEST_F(InputPublisherAndConsumerTest, GetChannel_ReturnsTheChannel) {
68 EXPECT_EQ(serverChannel.get(), mPublisher->getChannel().get());
69 EXPECT_EQ(clientChannel.get(), mConsumer->getChannel().get());
70}
71
72void InputPublisherAndConsumerTest::PublishAndConsumeKeyEvent() {
73 status_t status;
74
Siarhei Vishniakoua62a8dd2018-06-08 21:17:33 +010075 constexpr uint32_t seq = 15;
76 constexpr int32_t deviceId = 1;
Siarhei Vishniakou3826d472020-01-27 10:44:40 -060077 constexpr uint32_t source = AINPUT_SOURCE_KEYBOARD;
Siarhei Vishniakoua62a8dd2018-06-08 21:17:33 +010078 constexpr int32_t displayId = ADISPLAY_ID_DEFAULT;
Siarhei Vishniakou9c858ac2020-01-23 14:20:11 -060079 constexpr std::array<uint8_t, 32> hmac = {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21,
80 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10,
81 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
Siarhei Vishniakoua62a8dd2018-06-08 21:17:33 +010082 constexpr int32_t action = AKEY_EVENT_ACTION_DOWN;
83 constexpr int32_t flags = AKEY_EVENT_FLAG_FROM_SYSTEM;
84 constexpr int32_t keyCode = AKEYCODE_ENTER;
85 constexpr int32_t scanCode = 13;
86 constexpr int32_t metaState = AMETA_ALT_LEFT_ON | AMETA_ALT_ON;
87 constexpr int32_t repeatCount = 1;
88 constexpr nsecs_t downTime = 3;
89 constexpr nsecs_t eventTime = 4;
Jeff Brown5912f952013-07-01 19:10:31 -070090
Siarhei Vishniakou9c858ac2020-01-23 14:20:11 -060091 status = mPublisher->publishKeyEvent(seq, deviceId, source, displayId, hmac, action, flags,
92 keyCode, scanCode, metaState, repeatCount, downTime,
93 eventTime);
Jeff Brown5912f952013-07-01 19:10:31 -070094 ASSERT_EQ(OK, status)
95 << "publisher publishKeyEvent should return OK";
96
97 uint32_t consumeSeq;
98 InputEvent* event;
Siarhei Vishniakou777a10b2018-01-31 16:45:06 -080099 status = mConsumer->consume(&mEventFactory, true /*consumeBatches*/, -1, &consumeSeq, &event);
Jeff Brown5912f952013-07-01 19:10:31 -0700100 ASSERT_EQ(OK, status)
101 << "consumer consume should return OK";
102
Yi Kong5bed83b2018-07-17 12:53:47 -0700103 ASSERT_TRUE(event != nullptr)
Jeff Brown5912f952013-07-01 19:10:31 -0700104 << "consumer should have returned non-NULL event";
105 ASSERT_EQ(AINPUT_EVENT_TYPE_KEY, event->getType())
106 << "consumer should have returned a key event";
107
108 KeyEvent* keyEvent = static_cast<KeyEvent*>(event);
109 EXPECT_EQ(seq, consumeSeq);
110 EXPECT_EQ(deviceId, keyEvent->getDeviceId());
111 EXPECT_EQ(source, keyEvent->getSource());
Siarhei Vishniakoua62a8dd2018-06-08 21:17:33 +0100112 EXPECT_EQ(displayId, keyEvent->getDisplayId());
Siarhei Vishniakou9c858ac2020-01-23 14:20:11 -0600113 EXPECT_EQ(hmac, keyEvent->getHmac());
Jeff Brown5912f952013-07-01 19:10:31 -0700114 EXPECT_EQ(action, keyEvent->getAction());
115 EXPECT_EQ(flags, keyEvent->getFlags());
116 EXPECT_EQ(keyCode, keyEvent->getKeyCode());
117 EXPECT_EQ(scanCode, keyEvent->getScanCode());
118 EXPECT_EQ(metaState, keyEvent->getMetaState());
119 EXPECT_EQ(repeatCount, keyEvent->getRepeatCount());
120 EXPECT_EQ(downTime, keyEvent->getDownTime());
121 EXPECT_EQ(eventTime, keyEvent->getEventTime());
122
123 status = mConsumer->sendFinishedSignal(seq, true);
124 ASSERT_EQ(OK, status)
125 << "consumer sendFinishedSignal should return OK";
126
127 uint32_t finishedSeq = 0;
128 bool handled = false;
129 status = mPublisher->receiveFinishedSignal(&finishedSeq, &handled);
130 ASSERT_EQ(OK, status)
131 << "publisher receiveFinishedSignal should return OK";
132 ASSERT_EQ(seq, finishedSeq)
133 << "publisher receiveFinishedSignal should have returned the original sequence number";
134 ASSERT_TRUE(handled)
135 << "publisher receiveFinishedSignal should have set handled to consumer's reply";
136}
137
138void InputPublisherAndConsumerTest::PublishAndConsumeMotionEvent() {
139 status_t status;
140
Siarhei Vishniakou777a10b2018-01-31 16:45:06 -0800141 constexpr uint32_t seq = 15;
142 constexpr int32_t deviceId = 1;
Siarhei Vishniakou3826d472020-01-27 10:44:40 -0600143 constexpr uint32_t source = AINPUT_SOURCE_TOUCHSCREEN;
Siarhei Vishniakoua62a8dd2018-06-08 21:17:33 +0100144 constexpr int32_t displayId = ADISPLAY_ID_DEFAULT;
Siarhei Vishniakou9c858ac2020-01-23 14:20:11 -0600145 constexpr std::array<uint8_t, 32> hmac = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
146 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
147 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
Siarhei Vishniakou777a10b2018-01-31 16:45:06 -0800148 constexpr int32_t action = AMOTION_EVENT_ACTION_MOVE;
149 constexpr int32_t actionButton = 0;
150 constexpr int32_t flags = AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED;
151 constexpr int32_t edgeFlags = AMOTION_EVENT_EDGE_FLAG_TOP;
152 constexpr int32_t metaState = AMETA_ALT_LEFT_ON | AMETA_ALT_ON;
153 constexpr int32_t buttonState = AMOTION_EVENT_BUTTON_PRIMARY;
Siarhei Vishniakou16a2e302019-01-14 19:21:45 -0800154 constexpr MotionClassification classification = MotionClassification::AMBIGUOUS_GESTURE;
Siarhei Vishniakou9c858ac2020-01-23 14:20:11 -0600155 constexpr float xScale = 2;
156 constexpr float yScale = 3;
Siarhei Vishniakou777a10b2018-01-31 16:45:06 -0800157 constexpr float xOffset = -10;
158 constexpr float yOffset = -20;
159 constexpr float xPrecision = 0.25;
160 constexpr float yPrecision = 0.5;
Garfield Tan00f511d2019-06-12 16:55:40 -0700161 constexpr float xCursorPosition = 1.3;
162 constexpr float yCursorPosition = 50.6;
Siarhei Vishniakou777a10b2018-01-31 16:45:06 -0800163 constexpr nsecs_t downTime = 3;
164 constexpr size_t pointerCount = 3;
165 constexpr nsecs_t eventTime = 4;
Jeff Brown5912f952013-07-01 19:10:31 -0700166 PointerProperties pointerProperties[pointerCount];
167 PointerCoords pointerCoords[pointerCount];
168 for (size_t i = 0; i < pointerCount; i++) {
169 pointerProperties[i].clear();
170 pointerProperties[i].id = (i + 2) % pointerCount;
171 pointerProperties[i].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
172
173 pointerCoords[i].clear();
174 pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_X, 100 * i);
175 pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_Y, 200 * i);
176 pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 0.5 * i);
177 pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_SIZE, 0.7 * i);
178 pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, 1.5 * i);
179 pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, 1.7 * i);
180 pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, 2.5 * i);
181 pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, 2.7 * i);
182 pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, 3.5 * i);
183 }
184
Siarhei Vishniakou9c858ac2020-01-23 14:20:11 -0600185 status = mPublisher->publishMotionEvent(seq, deviceId, source, displayId, hmac, action,
186 actionButton, flags, edgeFlags, metaState, buttonState,
187 classification, xScale, yScale, xOffset, yOffset,
188 xPrecision, yPrecision, xCursorPosition,
189 yCursorPosition, downTime, eventTime, pointerCount,
190 pointerProperties, pointerCoords);
Jeff Brown5912f952013-07-01 19:10:31 -0700191 ASSERT_EQ(OK, status)
192 << "publisher publishMotionEvent should return OK";
193
194 uint32_t consumeSeq;
195 InputEvent* event;
Siarhei Vishniakou777a10b2018-01-31 16:45:06 -0800196 status = mConsumer->consume(&mEventFactory, true /*consumeBatches*/, -1, &consumeSeq, &event);
Jeff Brown5912f952013-07-01 19:10:31 -0700197 ASSERT_EQ(OK, status)
198 << "consumer consume should return OK";
199
Yi Kong5bed83b2018-07-17 12:53:47 -0700200 ASSERT_TRUE(event != nullptr)
Jeff Brown5912f952013-07-01 19:10:31 -0700201 << "consumer should have returned non-NULL event";
202 ASSERT_EQ(AINPUT_EVENT_TYPE_MOTION, event->getType())
203 << "consumer should have returned a motion event";
204
205 MotionEvent* motionEvent = static_cast<MotionEvent*>(event);
206 EXPECT_EQ(seq, consumeSeq);
207 EXPECT_EQ(deviceId, motionEvent->getDeviceId());
208 EXPECT_EQ(source, motionEvent->getSource());
Siarhei Vishniakou777a10b2018-01-31 16:45:06 -0800209 EXPECT_EQ(displayId, motionEvent->getDisplayId());
Siarhei Vishniakou9c858ac2020-01-23 14:20:11 -0600210 EXPECT_EQ(hmac, motionEvent->getHmac());
Jeff Brown5912f952013-07-01 19:10:31 -0700211 EXPECT_EQ(action, motionEvent->getAction());
212 EXPECT_EQ(flags, motionEvent->getFlags());
213 EXPECT_EQ(edgeFlags, motionEvent->getEdgeFlags());
214 EXPECT_EQ(metaState, motionEvent->getMetaState());
215 EXPECT_EQ(buttonState, motionEvent->getButtonState());
Siarhei Vishniakou16a2e302019-01-14 19:21:45 -0800216 EXPECT_EQ(classification, motionEvent->getClassification());
Siarhei Vishniakou9c858ac2020-01-23 14:20:11 -0600217 EXPECT_EQ(xScale, motionEvent->getXScale());
218 EXPECT_EQ(yScale, motionEvent->getYScale());
219 EXPECT_EQ(xOffset, motionEvent->getXOffset());
220 EXPECT_EQ(yOffset, motionEvent->getYOffset());
Jeff Brown5912f952013-07-01 19:10:31 -0700221 EXPECT_EQ(xPrecision, motionEvent->getXPrecision());
222 EXPECT_EQ(yPrecision, motionEvent->getYPrecision());
Garfield Tan00f511d2019-06-12 16:55:40 -0700223 EXPECT_EQ(xCursorPosition, motionEvent->getRawXCursorPosition());
224 EXPECT_EQ(yCursorPosition, motionEvent->getRawYCursorPosition());
chaviw82357092020-01-28 13:13:06 -0800225 EXPECT_EQ(xCursorPosition * xScale + xOffset, motionEvent->getXCursorPosition());
226 EXPECT_EQ(yCursorPosition * yScale + yOffset, motionEvent->getYCursorPosition());
Jeff Brown5912f952013-07-01 19:10:31 -0700227 EXPECT_EQ(downTime, motionEvent->getDownTime());
228 EXPECT_EQ(eventTime, motionEvent->getEventTime());
229 EXPECT_EQ(pointerCount, motionEvent->getPointerCount());
230 EXPECT_EQ(0U, motionEvent->getHistorySize());
231
232 for (size_t i = 0; i < pointerCount; i++) {
233 SCOPED_TRACE(i);
234 EXPECT_EQ(pointerProperties[i].id, motionEvent->getPointerId(i));
235 EXPECT_EQ(pointerProperties[i].toolType, motionEvent->getToolType(i));
236
237 EXPECT_EQ(pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_X),
238 motionEvent->getRawX(i));
239 EXPECT_EQ(pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_Y),
240 motionEvent->getRawY(i));
chaviw82357092020-01-28 13:13:06 -0800241 EXPECT_EQ(pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_X) * xScale + xOffset,
242 motionEvent->getX(i));
243 EXPECT_EQ(pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_Y) * yScale + yOffset,
244 motionEvent->getY(i));
Jeff Brown5912f952013-07-01 19:10:31 -0700245 EXPECT_EQ(pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_PRESSURE),
246 motionEvent->getPressure(i));
247 EXPECT_EQ(pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_SIZE),
248 motionEvent->getSize(i));
249 EXPECT_EQ(pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR),
250 motionEvent->getTouchMajor(i));
251 EXPECT_EQ(pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR),
252 motionEvent->getTouchMinor(i));
253 EXPECT_EQ(pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR),
254 motionEvent->getToolMajor(i));
255 EXPECT_EQ(pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR),
256 motionEvent->getToolMinor(i));
257 EXPECT_EQ(pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION),
258 motionEvent->getOrientation(i));
259 }
260
261 status = mConsumer->sendFinishedSignal(seq, false);
262 ASSERT_EQ(OK, status)
263 << "consumer sendFinishedSignal should return OK";
264
265 uint32_t finishedSeq = 0;
266 bool handled = true;
267 status = mPublisher->receiveFinishedSignal(&finishedSeq, &handled);
268 ASSERT_EQ(OK, status)
269 << "publisher receiveFinishedSignal should return OK";
270 ASSERT_EQ(seq, finishedSeq)
271 << "publisher receiveFinishedSignal should have returned the original sequence number";
272 ASSERT_FALSE(handled)
273 << "publisher receiveFinishedSignal should have set handled to consumer's reply";
274}
275
Siarhei Vishniakou7feb2ea2019-11-25 15:11:23 -0800276void InputPublisherAndConsumerTest::PublishAndConsumeFocusEvent() {
277 status_t status;
278
279 constexpr uint32_t seq = 15;
280 constexpr bool hasFocus = true;
281 constexpr bool inTouchMode = true;
282
283 status = mPublisher->publishFocusEvent(seq, hasFocus, inTouchMode);
284 ASSERT_EQ(OK, status) << "publisher publishKeyEvent should return OK";
285
286 uint32_t consumeSeq;
287 InputEvent* event;
288 status = mConsumer->consume(&mEventFactory, true /*consumeBatches*/, -1, &consumeSeq, &event);
289 ASSERT_EQ(OK, status) << "consumer consume should return OK";
290
291 ASSERT_TRUE(event != nullptr) << "consumer should have returned non-NULL event";
292 ASSERT_EQ(AINPUT_EVENT_TYPE_FOCUS, event->getType())
293 << "consumer should have returned a focus event";
294
295 FocusEvent* focusEvent = static_cast<FocusEvent*>(event);
296 EXPECT_EQ(seq, consumeSeq);
297 EXPECT_EQ(hasFocus, focusEvent->getHasFocus());
298 EXPECT_EQ(inTouchMode, focusEvent->getInTouchMode());
299
300 status = mConsumer->sendFinishedSignal(seq, true);
301 ASSERT_EQ(OK, status) << "consumer sendFinishedSignal should return OK";
302
303 uint32_t finishedSeq = 0;
304 bool handled = false;
305 status = mPublisher->receiveFinishedSignal(&finishedSeq, &handled);
306 ASSERT_EQ(OK, status) << "publisher receiveFinishedSignal should return OK";
307 ASSERT_EQ(seq, finishedSeq)
308 << "publisher receiveFinishedSignal should have returned the original sequence number";
309 ASSERT_TRUE(handled)
310 << "publisher receiveFinishedSignal should have set handled to consumer's reply";
311}
312
Jeff Brown5912f952013-07-01 19:10:31 -0700313TEST_F(InputPublisherAndConsumerTest, PublishKeyEvent_EndToEnd) {
314 ASSERT_NO_FATAL_FAILURE(PublishAndConsumeKeyEvent());
315}
316
317TEST_F(InputPublisherAndConsumerTest, PublishMotionEvent_EndToEnd) {
318 ASSERT_NO_FATAL_FAILURE(PublishAndConsumeMotionEvent());
319}
320
Siarhei Vishniakou7feb2ea2019-11-25 15:11:23 -0800321TEST_F(InputPublisherAndConsumerTest, PublishFocusEvent_EndToEnd) {
322 ASSERT_NO_FATAL_FAILURE(PublishAndConsumeFocusEvent());
323}
324
Siarhei Vishniakoub0fffdd2017-11-10 20:16:56 -0800325TEST_F(InputPublisherAndConsumerTest, PublishMotionEvent_WhenSequenceNumberIsZero_ReturnsError) {
Jeff Brown5912f952013-07-01 19:10:31 -0700326 status_t status;
Siarhei Vishniakoub0fffdd2017-11-10 20:16:56 -0800327 const size_t pointerCount = 1;
Jeff Brown5912f952013-07-01 19:10:31 -0700328 PointerProperties pointerProperties[pointerCount];
329 PointerCoords pointerCoords[pointerCount];
Siarhei Vishniakoub0fffdd2017-11-10 20:16:56 -0800330 for (size_t i = 0; i < pointerCount; i++) {
331 pointerProperties[i].clear();
332 pointerCoords[i].clear();
333 }
Jeff Brown5912f952013-07-01 19:10:31 -0700334
Siarhei Vishniakou9c858ac2020-01-23 14:20:11 -0600335 status = mPublisher->publishMotionEvent(0, 0, 0, 0, INVALID_HMAC, 0, 0, 0, 0, 0, 0,
336 MotionClassification::NONE, 1 /* xScale */,
337 1 /* yScale */, 0, 0, 0, 0,
338 AMOTION_EVENT_INVALID_CURSOR_POSITION,
339 AMOTION_EVENT_INVALID_CURSOR_POSITION, 0, 0,
340 pointerCount, pointerProperties, pointerCoords);
Jeff Brown5912f952013-07-01 19:10:31 -0700341 ASSERT_EQ(BAD_VALUE, status)
342 << "publisher publishMotionEvent should return BAD_VALUE";
343}
344
Siarhei Vishniakoub0fffdd2017-11-10 20:16:56 -0800345TEST_F(InputPublisherAndConsumerTest, PublishMotionEvent_WhenPointerCountLessThan1_ReturnsError) {
346 status_t status;
347 const size_t pointerCount = 0;
348 PointerProperties pointerProperties[pointerCount];
349 PointerCoords pointerCoords[pointerCount];
350
Siarhei Vishniakou9c858ac2020-01-23 14:20:11 -0600351 status = mPublisher->publishMotionEvent(1, 0, 0, 0, INVALID_HMAC, 0, 0, 0, 0, 0, 0,
352 MotionClassification::NONE, 1 /* xScale */,
353 1 /* yScale */, 0, 0, 0, 0,
354 AMOTION_EVENT_INVALID_CURSOR_POSITION,
355 AMOTION_EVENT_INVALID_CURSOR_POSITION, 0, 0,
356 pointerCount, pointerProperties, pointerCoords);
Siarhei Vishniakoub0fffdd2017-11-10 20:16:56 -0800357 ASSERT_EQ(BAD_VALUE, status)
358 << "publisher publishMotionEvent should return BAD_VALUE";
359}
360
361TEST_F(InputPublisherAndConsumerTest,
362 PublishMotionEvent_WhenPointerCountGreaterThanMax_ReturnsError) {
Jeff Brown5912f952013-07-01 19:10:31 -0700363 status_t status;
364 const size_t pointerCount = MAX_POINTERS + 1;
365 PointerProperties pointerProperties[pointerCount];
366 PointerCoords pointerCoords[pointerCount];
367 for (size_t i = 0; i < pointerCount; i++) {
368 pointerProperties[i].clear();
369 pointerCoords[i].clear();
370 }
371
Siarhei Vishniakou9c858ac2020-01-23 14:20:11 -0600372 status = mPublisher->publishMotionEvent(1, 0, 0, 0, INVALID_HMAC, 0, 0, 0, 0, 0, 0,
373 MotionClassification::NONE, 1 /* xScale */,
374 1 /* yScale */, 0, 0, 0, 0,
375 AMOTION_EVENT_INVALID_CURSOR_POSITION,
376 AMOTION_EVENT_INVALID_CURSOR_POSITION, 0, 0,
377 pointerCount, pointerProperties, pointerCoords);
Jeff Brown5912f952013-07-01 19:10:31 -0700378 ASSERT_EQ(BAD_VALUE, status)
379 << "publisher publishMotionEvent should return BAD_VALUE";
380}
381
382TEST_F(InputPublisherAndConsumerTest, PublishMultipleEvents_EndToEnd) {
383 ASSERT_NO_FATAL_FAILURE(PublishAndConsumeMotionEvent());
384 ASSERT_NO_FATAL_FAILURE(PublishAndConsumeKeyEvent());
385 ASSERT_NO_FATAL_FAILURE(PublishAndConsumeMotionEvent());
Siarhei Vishniakou7feb2ea2019-11-25 15:11:23 -0800386 ASSERT_NO_FATAL_FAILURE(PublishAndConsumeFocusEvent());
Jeff Brown5912f952013-07-01 19:10:31 -0700387 ASSERT_NO_FATAL_FAILURE(PublishAndConsumeMotionEvent());
388 ASSERT_NO_FATAL_FAILURE(PublishAndConsumeKeyEvent());
389}
390
391} // namespace android