| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright 2018 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 <gtest/gtest.h> | 
|  | 18 | #include <stdlib.h> | 
|  | 19 | #include <unistd.h> | 
|  | 20 | #include <sys/time.h> | 
|  | 21 | #include <sys/types.h> | 
|  | 22 | #include <stdio.h> | 
|  | 23 | #include <poll.h> | 
|  | 24 |  | 
|  | 25 | #include <memory> | 
|  | 26 |  | 
| Vishnu Nair | cbe9c10 | 2022-02-08 02:53:27 +0000 | [diff] [blame] | 27 | #include <android/keycodes.h> | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 28 | #include <android/native_window.h> | 
|  | 29 |  | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 30 | #include <binder/Binder.h> | 
|  | 31 | #include <binder/IServiceManager.h> | 
|  | 32 | #include <binder/Parcel.h> | 
|  | 33 | #include <binder/ProcessState.h> | 
|  | 34 |  | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 35 | #include <gui/ISurfaceComposer.h> | 
|  | 36 | #include <gui/Surface.h> | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 37 | #include <gui/SurfaceComposerClient.h> | 
|  | 38 | #include <gui/SurfaceControl.h> | 
|  | 39 |  | 
|  | 40 | #include <input/InputWindow.h> | 
|  | 41 | #include <input/IInputFlinger.h> | 
|  | 42 | #include <input/InputTransport.h> | 
|  | 43 | #include <input/Input.h> | 
|  | 44 |  | 
| Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 45 | #include <ui/DisplayConfig.h> | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 46 | #include <ui/Rect.h> | 
|  | 47 | #include <ui/Region.h> | 
|  | 48 |  | 
|  | 49 |  | 
|  | 50 | namespace android { | 
|  | 51 | namespace test { | 
|  | 52 |  | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 53 | using Transaction = SurfaceComposerClient::Transaction; | 
|  | 54 |  | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 55 | sp<IInputFlinger> getInputFlinger() { | 
|  | 56 | sp<IBinder> input(defaultServiceManager()->getService( | 
|  | 57 | String16("inputflinger"))); | 
|  | 58 | if (input == nullptr) { | 
|  | 59 | ALOGE("Failed to link to input service"); | 
|  | 60 | } else { ALOGE("Linked to input"); } | 
|  | 61 | return interface_cast<IInputFlinger>(input); | 
|  | 62 | } | 
|  | 63 |  | 
|  | 64 | // We use the top 10 layers as a way to haphazardly place ourselves above anything else. | 
|  | 65 | static const int LAYER_BASE = INT32_MAX - 10; | 
|  | 66 |  | 
|  | 67 | class InputSurface { | 
|  | 68 | public: | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 69 | InputSurface(const sp<SurfaceControl> &sc, int width, int height) { | 
|  | 70 | mSurfaceControl = sc; | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 71 |  | 
|  | 72 | InputChannel::openInputChannelPair("testchannels", mServerChannel, mClientChannel); | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 73 |  | 
|  | 74 | mInputFlinger = getInputFlinger(); | 
|  | 75 | mInputFlinger->registerInputChannel(mServerChannel); | 
|  | 76 |  | 
|  | 77 | populateInputInfo(width, height); | 
|  | 78 |  | 
|  | 79 | mInputConsumer = new InputConsumer(mClientChannel); | 
|  | 80 | } | 
|  | 81 |  | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 82 | static std::unique_ptr<InputSurface> makeColorInputSurface(const sp<SurfaceComposerClient> &scc, | 
|  | 83 | int width, int height) { | 
|  | 84 | sp<SurfaceControl> surfaceControl = | 
|  | 85 | scc->createSurface(String8("Test Surface"), 0 /* bufHeight */, 0 /* bufWidth */, | 
| Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 86 | PIXEL_FORMAT_RGBA_8888, | 
|  | 87 | ISurfaceComposerClient::eFXSurfaceEffect); | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 88 | return std::make_unique<InputSurface>(surfaceControl, width, height); | 
|  | 89 | } | 
|  | 90 |  | 
|  | 91 | static std::unique_ptr<InputSurface> makeBufferInputSurface( | 
|  | 92 | const sp<SurfaceComposerClient> &scc, int width, int height) { | 
|  | 93 | sp<SurfaceControl> surfaceControl = | 
|  | 94 | scc->createSurface(String8("Test Buffer Surface"), width, height, | 
|  | 95 | PIXEL_FORMAT_RGBA_8888, 0 /* flags */); | 
|  | 96 | return std::make_unique<InputSurface>(surfaceControl, width, height); | 
|  | 97 | } | 
|  | 98 |  | 
|  | 99 | static std::unique_ptr<InputSurface> makeContainerInputSurface( | 
|  | 100 | const sp<SurfaceComposerClient> &scc, int width, int height) { | 
|  | 101 | sp<SurfaceControl> surfaceControl = | 
|  | 102 | scc->createSurface(String8("Test Container Surface"), 0 /* bufHeight */, | 
|  | 103 | 0 /* bufWidth */, PIXEL_FORMAT_RGBA_8888, | 
|  | 104 | ISurfaceComposerClient::eFXSurfaceContainer); | 
|  | 105 | return std::make_unique<InputSurface>(surfaceControl, width, height); | 
|  | 106 | } | 
|  | 107 |  | 
| arthurhung | b4a0f85 | 2020-06-16 11:02:50 +0800 | [diff] [blame] | 108 | static std::unique_ptr<InputSurface> makeCursorInputSurface( | 
|  | 109 | const sp<SurfaceComposerClient> &scc, int width, int height) { | 
|  | 110 | sp<SurfaceControl> surfaceControl = | 
|  | 111 | scc->createSurface(String8("Test Cursor Surface"), 0 /* bufHeight */, | 
|  | 112 | 0 /* bufWidth */, PIXEL_FORMAT_RGBA_8888, | 
|  | 113 | ISurfaceComposerClient::eCursorWindow); | 
|  | 114 | return std::make_unique<InputSurface>(surfaceControl, width, height); | 
|  | 115 | } | 
|  | 116 |  | 
| Vishnu Nair | cbe9c10 | 2022-02-08 02:53:27 +0000 | [diff] [blame] | 117 | InputEvent *consumeEvent(int timeoutMs = 3000) { | 
|  | 118 | waitForEventAvailable(timeoutMs); | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 119 |  | 
|  | 120 | InputEvent *ev; | 
|  | 121 | uint32_t seqId; | 
|  | 122 | status_t consumed = mInputConsumer->consume(&mInputEventFactory, true, -1, &seqId, &ev); | 
|  | 123 | if (consumed != OK) { | 
|  | 124 | return nullptr; | 
|  | 125 | } | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 126 | status_t status = mInputConsumer->sendFinishedSignal(seqId, true); | 
|  | 127 | EXPECT_EQ(OK, status) << "Could not send finished signal"; | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 128 | return ev; | 
|  | 129 | } | 
|  | 130 |  | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 131 | void assertFocusChange(bool hasFocus) { | 
|  | 132 | InputEvent *ev = consumeEvent(); | 
|  | 133 | ASSERT_NE(ev, nullptr); | 
|  | 134 | ASSERT_EQ(AINPUT_EVENT_TYPE_FOCUS, ev->getType()); | 
|  | 135 | FocusEvent *focusEvent = static_cast<FocusEvent *>(ev); | 
|  | 136 | EXPECT_EQ(hasFocus, focusEvent->getHasFocus()); | 
|  | 137 | } | 
|  | 138 |  | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 139 | void expectTap(int x, int y) { | 
|  | 140 | InputEvent* ev = consumeEvent(); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 141 | ASSERT_NE(ev, nullptr); | 
|  | 142 | ASSERT_EQ(AINPUT_EVENT_TYPE_MOTION, ev->getType()); | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 143 | MotionEvent* mev = static_cast<MotionEvent*>(ev); | 
|  | 144 | EXPECT_EQ(AMOTION_EVENT_ACTION_DOWN, mev->getAction()); | 
|  | 145 | EXPECT_EQ(x, mev->getX(0)); | 
|  | 146 | EXPECT_EQ(y, mev->getY(0)); | 
| arthurhung | b4a0f85 | 2020-06-16 11:02:50 +0800 | [diff] [blame] | 147 | EXPECT_EQ(0, mev->getFlags() & VERIFIED_MOTION_EVENT_FLAGS); | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 148 |  | 
|  | 149 | ev = consumeEvent(); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 150 | ASSERT_NE(ev, nullptr); | 
|  | 151 | ASSERT_EQ(AINPUT_EVENT_TYPE_MOTION, ev->getType()); | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 152 | mev = static_cast<MotionEvent*>(ev); | 
|  | 153 | EXPECT_EQ(AMOTION_EVENT_ACTION_UP, mev->getAction()); | 
| arthurhung | b4a0f85 | 2020-06-16 11:02:50 +0800 | [diff] [blame] | 154 | EXPECT_EQ(0, mev->getFlags() & VERIFIED_MOTION_EVENT_FLAGS); | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 155 | } | 
|  | 156 |  | 
| Vishnu Nair | cbe9c10 | 2022-02-08 02:53:27 +0000 | [diff] [blame] | 157 | void expectKey(uint32_t keycode) { | 
|  | 158 | InputEvent *ev = consumeEvent(); | 
|  | 159 | ASSERT_NE(ev, nullptr); | 
|  | 160 | ASSERT_EQ(AINPUT_EVENT_TYPE_KEY, ev->getType()); | 
|  | 161 | KeyEvent *keyEvent = static_cast<KeyEvent *>(ev); | 
|  | 162 | EXPECT_EQ(AMOTION_EVENT_ACTION_DOWN, keyEvent->getAction()); | 
|  | 163 | EXPECT_EQ(keycode, keyEvent->getKeyCode()); | 
|  | 164 | EXPECT_EQ(0, keyEvent->getFlags() & VERIFIED_KEY_EVENT_FLAGS); | 
|  | 165 |  | 
|  | 166 | ev = consumeEvent(); | 
|  | 167 | ASSERT_NE(ev, nullptr); | 
|  | 168 | ASSERT_EQ(AINPUT_EVENT_TYPE_KEY, ev->getType()); | 
|  | 169 | keyEvent = static_cast<KeyEvent *>(ev); | 
|  | 170 | EXPECT_EQ(AMOTION_EVENT_ACTION_UP, keyEvent->getAction()); | 
|  | 171 | EXPECT_EQ(keycode, keyEvent->getKeyCode()); | 
|  | 172 | EXPECT_EQ(0, keyEvent->getFlags() & VERIFIED_KEY_EVENT_FLAGS); | 
|  | 173 | } | 
|  | 174 |  | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 175 | ~InputSurface() { | 
|  | 176 | mInputFlinger->unregisterInputChannel(mServerChannel); | 
|  | 177 | } | 
|  | 178 |  | 
|  | 179 | void doTransaction(std::function<void(SurfaceComposerClient::Transaction&, | 
|  | 180 | const sp<SurfaceControl>&)> transactionBody) { | 
|  | 181 | SurfaceComposerClient::Transaction t; | 
|  | 182 | transactionBody(t, mSurfaceControl); | 
|  | 183 | t.apply(true); | 
|  | 184 | } | 
|  | 185 |  | 
|  | 186 | void showAt(int x, int y) { | 
|  | 187 | SurfaceComposerClient::Transaction t; | 
|  | 188 | t.show(mSurfaceControl); | 
|  | 189 | t.setInputWindowInfo(mSurfaceControl, mInputInfo); | 
|  | 190 | t.setLayer(mSurfaceControl, LAYER_BASE); | 
|  | 191 | t.setPosition(mSurfaceControl, x, y); | 
|  | 192 | t.setCrop_legacy(mSurfaceControl, Rect(0, 0, 100, 100)); | 
|  | 193 | t.setAlpha(mSurfaceControl, 1); | 
|  | 194 | t.apply(true); | 
|  | 195 | } | 
|  | 196 |  | 
|  | 197 | private: | 
| Vishnu Nair | cbe9c10 | 2022-02-08 02:53:27 +0000 | [diff] [blame] | 198 | void waitForEventAvailable(int timeoutMs) { | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 199 | struct pollfd fd; | 
|  | 200 |  | 
|  | 201 | fd.fd = mClientChannel->getFd(); | 
|  | 202 | fd.events = POLLIN; | 
| Vishnu Nair | cbe9c10 | 2022-02-08 02:53:27 +0000 | [diff] [blame] | 203 | poll(&fd, 1, timeoutMs); | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 204 | } | 
|  | 205 |  | 
|  | 206 | void populateInputInfo(int width, int height) { | 
| Siarhei Vishniakou | 26d3cfb | 2019-10-15 17:02:32 -0700 | [diff] [blame] | 207 | mInputInfo.token = mServerChannel->getConnectionToken(); | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 208 | mInputInfo.name = "Test info"; | 
|  | 209 | mInputInfo.layoutParamsFlags = InputWindowInfo::FLAG_NOT_TOUCH_MODAL; | 
|  | 210 | mInputInfo.layoutParamsType = InputWindowInfo::TYPE_BASE_APPLICATION; | 
| Siarhei Vishniakou | 097c3db | 2020-05-06 14:18:38 -0700 | [diff] [blame] | 211 | mInputInfo.dispatchingTimeout = seconds_to_nanoseconds(5); | 
| Robert Carr | e07e103 | 2018-11-26 12:55:53 -0800 | [diff] [blame] | 212 | mInputInfo.globalScaleFactor = 1.0; | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 213 | mInputInfo.canReceiveKeys = true; | 
|  | 214 | mInputInfo.hasFocus = true; | 
|  | 215 | mInputInfo.hasWallpaper = false; | 
|  | 216 | mInputInfo.paused = false; | 
|  | 217 |  | 
|  | 218 | mInputInfo.touchableRegion.orSelf(Rect(0, 0, width, height)); | 
|  | 219 |  | 
|  | 220 | // TODO: Fill in from SF? | 
|  | 221 | mInputInfo.ownerPid = 11111; | 
|  | 222 | mInputInfo.ownerUid = 11111; | 
|  | 223 | mInputInfo.inputFeatures = 0; | 
|  | 224 | mInputInfo.displayId = 0; | 
| Robert Carr | 740167f | 2018-10-11 19:03:41 -0700 | [diff] [blame] | 225 |  | 
|  | 226 | InputApplicationInfo aInfo; | 
|  | 227 | aInfo.token = new BBinder(); | 
|  | 228 | aInfo.name = "Test app info"; | 
| Siarhei Vishniakou | 097c3db | 2020-05-06 14:18:38 -0700 | [diff] [blame] | 229 | aInfo.dispatchingTimeout = seconds_to_nanoseconds(5); | 
| Robert Carr | 740167f | 2018-10-11 19:03:41 -0700 | [diff] [blame] | 230 |  | 
|  | 231 | mInputInfo.applicationInfo = aInfo; | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 232 | } | 
|  | 233 | public: | 
|  | 234 | sp<SurfaceControl> mSurfaceControl; | 
|  | 235 | sp<InputChannel> mServerChannel, mClientChannel; | 
|  | 236 | sp<IInputFlinger> mInputFlinger; | 
|  | 237 |  | 
|  | 238 | InputWindowInfo mInputInfo; | 
|  | 239 |  | 
|  | 240 | PreallocatedInputEventFactory mInputEventFactory; | 
|  | 241 | InputConsumer* mInputConsumer; | 
|  | 242 | }; | 
|  | 243 |  | 
|  | 244 | class InputSurfacesTest : public ::testing::Test { | 
|  | 245 | public: | 
|  | 246 | InputSurfacesTest() { | 
|  | 247 | ProcessState::self()->startThreadPool(); | 
|  | 248 | } | 
|  | 249 |  | 
|  | 250 | void SetUp() { | 
|  | 251 | mComposerClient = new SurfaceComposerClient; | 
|  | 252 | ASSERT_EQ(NO_ERROR, mComposerClient->initCheck()); | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 253 |  | 
| Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 254 | const auto display = mComposerClient->getInternalDisplayToken(); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 255 | ASSERT_NE(display, nullptr); | 
| Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 256 |  | 
| Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 257 | DisplayConfig config; | 
|  | 258 | ASSERT_EQ(NO_ERROR, mComposerClient->getActiveDisplayConfig(display, &config)); | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 259 |  | 
|  | 260 | // After a new buffer is queued, SurfaceFlinger is notified and will | 
|  | 261 | // latch the new buffer on next vsync.  Let's heuristically wait for 3 | 
|  | 262 | // vsyncs. | 
| Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 263 | mBufferPostDelay = static_cast<int32_t>(1e6 / config.refreshRate) * 3; | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 264 | } | 
|  | 265 |  | 
|  | 266 | void TearDown() { | 
|  | 267 | mComposerClient->dispose(); | 
|  | 268 | } | 
|  | 269 |  | 
|  | 270 | std::unique_ptr<InputSurface> makeSurface(int width, int height) { | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 271 | return InputSurface::makeColorInputSurface(mComposerClient, width, height); | 
|  | 272 | } | 
|  | 273 |  | 
|  | 274 | void postBuffer(const sp<SurfaceControl> &layer) { | 
|  | 275 | // wait for previous transactions (such as setSize) to complete | 
|  | 276 | Transaction().apply(true); | 
|  | 277 | ANativeWindow_Buffer buffer = {}; | 
|  | 278 | EXPECT_EQ(NO_ERROR, layer->getSurface()->lock(&buffer, nullptr)); | 
|  | 279 | ASSERT_EQ(NO_ERROR, layer->getSurface()->unlockAndPost()); | 
|  | 280 | // Request an empty transaction to get applied synchronously to ensure the buffer is | 
|  | 281 | // latched. | 
|  | 282 | Transaction().apply(true); | 
|  | 283 | usleep(mBufferPostDelay); | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 284 | } | 
|  | 285 |  | 
|  | 286 | sp<SurfaceComposerClient> mComposerClient; | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 287 | int32_t mBufferPostDelay; | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 288 | }; | 
|  | 289 |  | 
|  | 290 | void injectTap(int x, int y) { | 
|  | 291 | char *buf1, *buf2; | 
|  | 292 | asprintf(&buf1, "%d", x); | 
|  | 293 | asprintf(&buf2, "%d", y); | 
|  | 294 | if (fork() == 0) { | 
|  | 295 | execlp("input", "input", "tap", buf1, buf2, NULL); | 
|  | 296 | } | 
|  | 297 | } | 
|  | 298 |  | 
| Vishnu Nair | cbe9c10 | 2022-02-08 02:53:27 +0000 | [diff] [blame] | 299 | void injectKey(uint32_t keycode) { | 
|  | 300 | char *buf1; | 
|  | 301 | asprintf(&buf1, "%d", keycode); | 
|  | 302 | if (fork() == 0) { | 
|  | 303 | execlp("input", "input", "keyevent", buf1, NULL); | 
|  | 304 | } | 
|  | 305 | } | 
|  | 306 |  | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 307 | TEST_F(InputSurfacesTest, can_receive_input) { | 
|  | 308 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); | 
|  | 309 | surface->showAt(100, 100); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 310 | surface->assertFocusChange(true); | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 311 |  | 
|  | 312 | injectTap(101, 101); | 
|  | 313 |  | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 314 | EXPECT_NE(surface->consumeEvent(), nullptr); | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 315 | } | 
|  | 316 |  | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 317 | /** | 
|  | 318 | * Set up two surfaces side-by-side. Tap each surface. | 
|  | 319 | * Next, swap the positions of the two surfaces. Inject tap into the two | 
|  | 320 | * original locations. Ensure that the tap is received by the surfaces in the | 
|  | 321 | * reverse order. | 
|  | 322 | */ | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 323 | TEST_F(InputSurfacesTest, input_respects_positioning) { | 
|  | 324 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); | 
|  | 325 | surface->showAt(100, 100); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 326 | surface->assertFocusChange(true); | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 327 |  | 
|  | 328 | std::unique_ptr<InputSurface> surface2 = makeSurface(100, 100); | 
|  | 329 | surface2->showAt(200, 200); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 330 | surface->assertFocusChange(false); | 
|  | 331 | surface2->assertFocusChange(true); | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 332 |  | 
|  | 333 | injectTap(201, 201); | 
|  | 334 | surface2->expectTap(1, 1); | 
|  | 335 |  | 
|  | 336 | injectTap(101, 101); | 
|  | 337 | surface->expectTap(1, 1); | 
|  | 338 |  | 
|  | 339 | surface2->doTransaction([](auto &t, auto &sc) { | 
|  | 340 | t.setPosition(sc, 100, 100); | 
|  | 341 | }); | 
|  | 342 | surface->doTransaction([](auto &t, auto &sc) { | 
|  | 343 | t.setPosition(sc, 200, 200); | 
|  | 344 | }); | 
|  | 345 |  | 
|  | 346 | injectTap(101, 101); | 
|  | 347 | surface2->expectTap(1, 1); | 
|  | 348 |  | 
|  | 349 | injectTap(201, 201); | 
|  | 350 | surface->expectTap(1, 1); | 
|  | 351 | } | 
|  | 352 |  | 
|  | 353 | TEST_F(InputSurfacesTest, input_respects_layering) { | 
|  | 354 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); | 
|  | 355 | std::unique_ptr<InputSurface> surface2 = makeSurface(100, 100); | 
|  | 356 |  | 
|  | 357 | surface->showAt(10, 10); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 358 | surface->assertFocusChange(true); | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 359 | surface2->showAt(10, 10); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 360 | surface->assertFocusChange(false); | 
|  | 361 | surface2->assertFocusChange(true); | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 362 |  | 
|  | 363 | surface->doTransaction([](auto &t, auto &sc) { | 
|  | 364 | t.setLayer(sc, LAYER_BASE + 1); | 
|  | 365 | }); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 366 | surface2->assertFocusChange(false); | 
|  | 367 | surface->assertFocusChange(true); | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 368 |  | 
|  | 369 | injectTap(11, 11); | 
|  | 370 | surface->expectTap(1, 1); | 
|  | 371 |  | 
|  | 372 | surface2->doTransaction([](auto &t, auto &sc) { | 
|  | 373 | t.setLayer(sc, LAYER_BASE + 1); | 
|  | 374 | }); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 375 | surface2->assertFocusChange(true); | 
|  | 376 | surface->assertFocusChange(false); | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 377 |  | 
|  | 378 | injectTap(11, 11); | 
|  | 379 | surface2->expectTap(1, 1); | 
|  | 380 |  | 
|  | 381 | surface2->doTransaction([](auto &t, auto &sc) { | 
|  | 382 | t.hide(sc); | 
|  | 383 | }); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 384 | surface2->assertFocusChange(false); | 
|  | 385 | surface->assertFocusChange(true); | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 386 |  | 
|  | 387 | injectTap(11, 11); | 
|  | 388 | surface->expectTap(1, 1); | 
|  | 389 | } | 
|  | 390 |  | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 391 | // Surface Insets are set to offset the client content and draw a border around the client surface | 
|  | 392 | // (such as shadows in dialogs). Inputs sent to the client are offset such that 0,0 is the start | 
|  | 393 | // of the client content. | 
|  | 394 | TEST_F(InputSurfacesTest, input_respects_surface_insets) { | 
|  | 395 | std::unique_ptr<InputSurface> bgSurface = makeSurface(100, 100); | 
|  | 396 | std::unique_ptr<InputSurface> fgSurface = makeSurface(100, 100); | 
|  | 397 | bgSurface->showAt(100, 100); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 398 | bgSurface->assertFocusChange(true); | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 399 |  | 
|  | 400 | fgSurface->mInputInfo.surfaceInset = 5; | 
|  | 401 | fgSurface->showAt(100, 100); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 402 | fgSurface->assertFocusChange(true); | 
|  | 403 | bgSurface->assertFocusChange(false); | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 404 |  | 
|  | 405 | injectTap(106, 106); | 
|  | 406 | fgSurface->expectTap(1, 1); | 
|  | 407 |  | 
|  | 408 | injectTap(101, 101); | 
|  | 409 | bgSurface->expectTap(1, 1); | 
|  | 410 | } | 
|  | 411 |  | 
|  | 412 | // Ensure a surface whose insets are cropped, handles the touch offset correctly. ref:b/120413463 | 
|  | 413 | TEST_F(InputSurfacesTest, input_respects_cropped_surface_insets) { | 
|  | 414 | std::unique_ptr<InputSurface> parentSurface = makeSurface(100, 100); | 
|  | 415 | std::unique_ptr<InputSurface> childSurface = makeSurface(100, 100); | 
|  | 416 | parentSurface->showAt(100, 100); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 417 | parentSurface->assertFocusChange(true); | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 418 |  | 
|  | 419 | childSurface->mInputInfo.surfaceInset = 10; | 
|  | 420 | childSurface->showAt(100, 100); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 421 | childSurface->assertFocusChange(true); | 
|  | 422 | parentSurface->assertFocusChange(false); | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 423 |  | 
|  | 424 | childSurface->doTransaction([&](auto &t, auto &sc) { | 
|  | 425 | t.setPosition(sc, -5, -5); | 
|  | 426 | t.reparent(sc, parentSurface->mSurfaceControl->getHandle()); | 
|  | 427 | }); | 
|  | 428 |  | 
|  | 429 | injectTap(106, 106); | 
|  | 430 | childSurface->expectTap(1, 1); | 
|  | 431 |  | 
|  | 432 | injectTap(101, 101); | 
|  | 433 | parentSurface->expectTap(1, 1); | 
|  | 434 | } | 
|  | 435 |  | 
| Arthur Hung | 118b114 | 2019-05-08 21:25:59 +0800 | [diff] [blame] | 436 | // Ensure a surface whose insets are scaled, handles the touch offset correctly. | 
|  | 437 | TEST_F(InputSurfacesTest, input_respects_scaled_surface_insets) { | 
|  | 438 | std::unique_ptr<InputSurface> bgSurface = makeSurface(100, 100); | 
|  | 439 | std::unique_ptr<InputSurface> fgSurface = makeSurface(100, 100); | 
|  | 440 | bgSurface->showAt(100, 100); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 441 | bgSurface->assertFocusChange(true); | 
| Arthur Hung | 118b114 | 2019-05-08 21:25:59 +0800 | [diff] [blame] | 442 |  | 
|  | 443 | fgSurface->mInputInfo.surfaceInset = 5; | 
|  | 444 | fgSurface->showAt(100, 100); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 445 | bgSurface->assertFocusChange(false); | 
|  | 446 | fgSurface->assertFocusChange(true); | 
| Arthur Hung | 118b114 | 2019-05-08 21:25:59 +0800 | [diff] [blame] | 447 |  | 
|  | 448 | fgSurface->doTransaction([&](auto &t, auto &sc) { t.setMatrix(sc, 2.0, 0, 0, 4.0); }); | 
|  | 449 |  | 
|  | 450 | // expect = touch / scale - inset | 
|  | 451 | injectTap(112, 124); | 
|  | 452 | fgSurface->expectTap(1, 1); | 
|  | 453 |  | 
|  | 454 | injectTap(101, 101); | 
|  | 455 | bgSurface->expectTap(1, 1); | 
|  | 456 | } | 
|  | 457 |  | 
| Ady Abraham | 282f1d7 | 2019-07-24 18:05:56 -0700 | [diff] [blame] | 458 | TEST_F(InputSurfacesTest, input_respects_scaled_surface_insets_overflow) { | 
|  | 459 | std::unique_ptr<InputSurface> fgSurface = makeSurface(100, 100); | 
|  | 460 | // In case we pass the very big inset without any checking. | 
|  | 461 | fgSurface->mInputInfo.surfaceInset = INT32_MAX; | 
|  | 462 | fgSurface->showAt(100, 100); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 463 | fgSurface->assertFocusChange(true); | 
| Ady Abraham | 282f1d7 | 2019-07-24 18:05:56 -0700 | [diff] [blame] | 464 |  | 
|  | 465 | fgSurface->doTransaction([&](auto &t, auto &sc) { t.setMatrix(sc, 2.0, 0, 0, 2.0); }); | 
|  | 466 |  | 
|  | 467 | // expect no crash for overflow, and inset size to be clamped to surface size | 
|  | 468 | injectTap(202, 202); | 
|  | 469 | fgSurface->expectTap(1, 1); | 
|  | 470 | } | 
|  | 471 |  | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 472 | // Ensure we ignore transparent region when getting screen bounds when positioning input frame. | 
|  | 473 | TEST_F(InputSurfacesTest, input_ignores_transparent_region) { | 
|  | 474 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); | 
|  | 475 | surface->doTransaction([](auto &t, auto &sc) { | 
|  | 476 | Region transparentRegion(Rect(0, 0, 10, 10)); | 
|  | 477 | t.setTransparentRegionHint(sc, transparentRegion); | 
|  | 478 | }); | 
|  | 479 | surface->showAt(100, 100); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 480 | surface->assertFocusChange(true); | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 481 | injectTap(101, 101); | 
|  | 482 | surface->expectTap(1, 1); | 
|  | 483 | } | 
|  | 484 |  | 
| Vishnu Nair | f8678ba | 2019-10-11 18:11:26 -0700 | [diff] [blame] | 485 | // TODO(b/139494112) update tests once we define expected behavior | 
|  | 486 | // Ensure we still send input to the surface regardless of surface visibility changes due to the | 
|  | 487 | // first buffer being submitted or alpha changes. | 
|  | 488 | // Original bug ref: b/120839715 | 
|  | 489 | TEST_F(InputSurfacesTest, input_ignores_buffer_layer_buffer) { | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 490 | std::unique_ptr<InputSurface> bgSurface = makeSurface(100, 100); | 
|  | 491 | std::unique_ptr<InputSurface> bufferSurface = | 
|  | 492 | InputSurface::makeBufferInputSurface(mComposerClient, 100, 100); | 
|  | 493 |  | 
|  | 494 | bgSurface->showAt(10, 10); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 495 | bgSurface->assertFocusChange(true); | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 496 | bufferSurface->showAt(10, 10); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 497 | bgSurface->assertFocusChange(false); | 
|  | 498 | bufferSurface->assertFocusChange(true); | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 499 |  | 
|  | 500 | injectTap(11, 11); | 
| Vishnu Nair | f8678ba | 2019-10-11 18:11:26 -0700 | [diff] [blame] | 501 | bufferSurface->expectTap(1, 1); | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 502 |  | 
|  | 503 | postBuffer(bufferSurface->mSurfaceControl); | 
|  | 504 | injectTap(11, 11); | 
|  | 505 | bufferSurface->expectTap(1, 1); | 
|  | 506 | } | 
|  | 507 |  | 
| Vishnu Nair | f8678ba | 2019-10-11 18:11:26 -0700 | [diff] [blame] | 508 | TEST_F(InputSurfacesTest, input_ignores_buffer_layer_alpha) { | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 509 | std::unique_ptr<InputSurface> bgSurface = makeSurface(100, 100); | 
|  | 510 | std::unique_ptr<InputSurface> bufferSurface = | 
|  | 511 | InputSurface::makeBufferInputSurface(mComposerClient, 100, 100); | 
|  | 512 | postBuffer(bufferSurface->mSurfaceControl); | 
|  | 513 |  | 
|  | 514 | bgSurface->showAt(10, 10); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 515 | bgSurface->assertFocusChange(true); | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 516 | bufferSurface->showAt(10, 10); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 517 | bufferSurface->assertFocusChange(true); | 
|  | 518 | bgSurface->assertFocusChange(false); | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 519 |  | 
|  | 520 | injectTap(11, 11); | 
|  | 521 | bufferSurface->expectTap(1, 1); | 
|  | 522 |  | 
|  | 523 | bufferSurface->doTransaction([](auto &t, auto &sc) { t.setAlpha(sc, 0.0); }); | 
|  | 524 |  | 
|  | 525 | injectTap(11, 11); | 
| Vishnu Nair | f8678ba | 2019-10-11 18:11:26 -0700 | [diff] [blame] | 526 | bufferSurface->expectTap(1, 1); | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 527 | } | 
|  | 528 |  | 
| Vishnu Nair | f8678ba | 2019-10-11 18:11:26 -0700 | [diff] [blame] | 529 | TEST_F(InputSurfacesTest, input_ignores_color_layer_alpha) { | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 530 | std::unique_ptr<InputSurface> bgSurface = makeSurface(100, 100); | 
|  | 531 | std::unique_ptr<InputSurface> fgSurface = makeSurface(100, 100); | 
|  | 532 |  | 
|  | 533 | bgSurface->showAt(10, 10); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 534 | bgSurface->assertFocusChange(true); | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 535 | fgSurface->showAt(10, 10); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 536 | bgSurface->assertFocusChange(false); | 
|  | 537 | fgSurface->assertFocusChange(true); | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 538 |  | 
|  | 539 | injectTap(11, 11); | 
|  | 540 | fgSurface->expectTap(1, 1); | 
|  | 541 |  | 
|  | 542 | fgSurface->doTransaction([](auto &t, auto &sc) { t.setAlpha(sc, 0.0); }); | 
|  | 543 |  | 
|  | 544 | injectTap(11, 11); | 
| Vishnu Nair | f8678ba | 2019-10-11 18:11:26 -0700 | [diff] [blame] | 545 | fgSurface->expectTap(1, 1); | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 546 | } | 
|  | 547 |  | 
|  | 548 | TEST_F(InputSurfacesTest, input_respects_container_layer_visiblity) { | 
|  | 549 | std::unique_ptr<InputSurface> bgSurface = makeSurface(100, 100); | 
|  | 550 | std::unique_ptr<InputSurface> containerSurface = | 
|  | 551 | InputSurface::makeContainerInputSurface(mComposerClient, 100, 100); | 
|  | 552 |  | 
|  | 553 | bgSurface->showAt(10, 10); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 554 | bgSurface->assertFocusChange(true); | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 555 | containerSurface->showAt(10, 10); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 556 | bgSurface->assertFocusChange(false); | 
|  | 557 | containerSurface->assertFocusChange(true); | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 558 |  | 
|  | 559 | injectTap(11, 11); | 
|  | 560 | containerSurface->expectTap(1, 1); | 
|  | 561 |  | 
|  | 562 | containerSurface->doTransaction([](auto &t, auto &sc) { t.hide(sc); }); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 563 | containerSurface->assertFocusChange(false); | 
|  | 564 | bgSurface->assertFocusChange(true); | 
| Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 565 |  | 
|  | 566 | injectTap(11, 11); | 
|  | 567 | bgSurface->expectTap(1, 1); | 
|  | 568 | } | 
| chaviw | fbe5d9c | 2018-12-26 12:23:37 -0800 | [diff] [blame] | 569 |  | 
| Arthur Hung | d20b270 | 2019-01-14 18:16:16 +0800 | [diff] [blame] | 570 | TEST_F(InputSurfacesTest, input_respects_outscreen) { | 
|  | 571 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); | 
|  | 572 | surface->showAt(-1, -1); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 573 | surface->assertFocusChange(true); | 
| Arthur Hung | d20b270 | 2019-01-14 18:16:16 +0800 | [diff] [blame] | 574 |  | 
|  | 575 | injectTap(0, 0); | 
|  | 576 | surface->expectTap(1, 1); | 
|  | 577 | } | 
| arthurhung | b4a0f85 | 2020-06-16 11:02:50 +0800 | [diff] [blame] | 578 |  | 
|  | 579 | TEST_F(InputSurfacesTest, input_ignores_cursor_layer) { | 
|  | 580 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); | 
|  | 581 | std::unique_ptr<InputSurface> cursorSurface = | 
|  | 582 | InputSurface::makeCursorInputSurface(mComposerClient, 10, 10); | 
|  | 583 |  | 
|  | 584 | surface->showAt(10, 10); | 
|  | 585 | surface->assertFocusChange(true); | 
|  | 586 | cursorSurface->showAt(10, 10); | 
|  | 587 |  | 
|  | 588 | injectTap(11, 11); | 
|  | 589 | surface->expectTap(1, 1); | 
|  | 590 | } | 
| Vishnu Nair | cbe9c10 | 2022-02-08 02:53:27 +0000 | [diff] [blame] | 591 |  | 
|  | 592 | TEST_F(InputSurfacesTest, drop_input_policy) { | 
|  | 593 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); | 
|  | 594 | surface->doTransaction( | 
|  | 595 | [&](auto &t, auto &sc) { t.setDropInputMode(sc, gui::DropInputMode::ALL); }); | 
|  | 596 | surface->showAt(100, 100); | 
|  | 597 | surface->assertFocusChange(true); | 
|  | 598 |  | 
|  | 599 | injectTap(101, 101); | 
|  | 600 | EXPECT_EQ(surface->consumeEvent(100), nullptr); | 
|  | 601 |  | 
|  | 602 | injectKey(AKEYCODE_V); | 
|  | 603 | EXPECT_EQ(surface->consumeEvent(100), nullptr); | 
| Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 604 | } | 
|  | 605 | } | 
| Vishnu Nair | cbe9c10 | 2022-02-08 02:53:27 +0000 | [diff] [blame] | 606 | } // namespace android |