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 | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 27 | #include <android/native_window.h> |
| 28 | |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 29 | #include <binder/Binder.h> |
| 30 | #include <binder/IServiceManager.h> |
| 31 | #include <binder/Parcel.h> |
| 32 | #include <binder/ProcessState.h> |
| 33 | |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 34 | #include <gui/ISurfaceComposer.h> |
| 35 | #include <gui/Surface.h> |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 36 | #include <gui/SurfaceComposerClient.h> |
| 37 | #include <gui/SurfaceControl.h> |
| 38 | |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 39 | #include <android/os/IInputFlinger.h> |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 40 | #include <input/Input.h> |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 41 | #include <input/InputTransport.h> |
| 42 | #include <input/InputWindow.h> |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 43 | |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 44 | #include <ui/DisplayConfig.h> |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 45 | #include <ui/Rect.h> |
| 46 | #include <ui/Region.h> |
| 47 | |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 48 | using android::os::IInputFlinger; |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 49 | |
Vishnu Nair | 958da93 | 2020-08-21 17:12:37 -0700 | [diff] [blame] | 50 | namespace android::test { |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 51 | |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 52 | using Transaction = SurfaceComposerClient::Transaction; |
| 53 | |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 54 | sp<IInputFlinger> getInputFlinger() { |
| 55 | sp<IBinder> input(defaultServiceManager()->getService( |
| 56 | String16("inputflinger"))); |
| 57 | if (input == nullptr) { |
| 58 | ALOGE("Failed to link to input service"); |
| 59 | } else { ALOGE("Linked to input"); } |
| 60 | return interface_cast<IInputFlinger>(input); |
| 61 | } |
| 62 | |
| 63 | // We use the top 10 layers as a way to haphazardly place ourselves above anything else. |
| 64 | static const int LAYER_BASE = INT32_MAX - 10; |
Chris Ye | 6c4243b | 2020-07-22 12:07:12 -0700 | [diff] [blame] | 65 | static constexpr std::chrono::nanoseconds DISPATCHING_TIMEOUT = 5s; |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 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 | mInputFlinger = getInputFlinger(); |
Garfield Tan | 1560166 | 2020-09-22 15:32:38 -0700 | [diff] [blame] | 73 | mClientChannel = std::make_shared<InputChannel>(); |
| 74 | mInputFlinger->createInputChannel("testchannels", mClientChannel.get()); |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 75 | |
| 76 | populateInputInfo(width, height); |
| 77 | |
| 78 | mInputConsumer = new InputConsumer(mClientChannel); |
| 79 | } |
| 80 | |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 81 | static std::unique_ptr<InputSurface> makeColorInputSurface(const sp<SurfaceComposerClient> &scc, |
| 82 | int width, int height) { |
| 83 | sp<SurfaceControl> surfaceControl = |
| 84 | scc->createSurface(String8("Test Surface"), 0 /* bufHeight */, 0 /* bufWidth */, |
Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 85 | PIXEL_FORMAT_RGBA_8888, |
| 86 | ISurfaceComposerClient::eFXSurfaceEffect); |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 87 | return std::make_unique<InputSurface>(surfaceControl, width, height); |
| 88 | } |
| 89 | |
| 90 | static std::unique_ptr<InputSurface> makeBufferInputSurface( |
| 91 | const sp<SurfaceComposerClient> &scc, int width, int height) { |
| 92 | sp<SurfaceControl> surfaceControl = |
| 93 | scc->createSurface(String8("Test Buffer Surface"), width, height, |
| 94 | PIXEL_FORMAT_RGBA_8888, 0 /* flags */); |
| 95 | return std::make_unique<InputSurface>(surfaceControl, width, height); |
| 96 | } |
| 97 | |
chaviw | 7e72caf | 2020-12-02 16:50:43 -0800 | [diff] [blame] | 98 | static std::unique_ptr<InputSurface> makeBlastInputSurface(const sp<SurfaceComposerClient> &scc, |
| 99 | int width, int height) { |
| 100 | sp<SurfaceControl> surfaceControl = |
| 101 | scc->createSurface(String8("Test Buffer Surface"), width, height, |
| 102 | PIXEL_FORMAT_RGBA_8888, |
| 103 | ISurfaceComposerClient::eFXSurfaceBufferState); |
| 104 | return std::make_unique<InputSurface>(surfaceControl, width, height); |
| 105 | } |
| 106 | |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 107 | static std::unique_ptr<InputSurface> makeContainerInputSurface( |
| 108 | const sp<SurfaceComposerClient> &scc, int width, int height) { |
| 109 | sp<SurfaceControl> surfaceControl = |
| 110 | scc->createSurface(String8("Test Container Surface"), 0 /* bufHeight */, |
| 111 | 0 /* bufWidth */, PIXEL_FORMAT_RGBA_8888, |
| 112 | ISurfaceComposerClient::eFXSurfaceContainer); |
| 113 | return std::make_unique<InputSurface>(surfaceControl, width, height); |
| 114 | } |
| 115 | |
arthurhung | b4a0f85 | 2020-06-16 11:02:50 +0800 | [diff] [blame] | 116 | static std::unique_ptr<InputSurface> makeCursorInputSurface( |
| 117 | const sp<SurfaceComposerClient> &scc, int width, int height) { |
| 118 | sp<SurfaceControl> surfaceControl = |
| 119 | scc->createSurface(String8("Test Cursor Surface"), 0 /* bufHeight */, |
| 120 | 0 /* bufWidth */, PIXEL_FORMAT_RGBA_8888, |
| 121 | ISurfaceComposerClient::eCursorWindow); |
| 122 | return std::make_unique<InputSurface>(surfaceControl, width, height); |
| 123 | } |
| 124 | |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 125 | InputEvent* consumeEvent() { |
| 126 | waitForEventAvailable(); |
| 127 | |
| 128 | InputEvent *ev; |
| 129 | uint32_t seqId; |
| 130 | status_t consumed = mInputConsumer->consume(&mInputEventFactory, true, -1, &seqId, &ev); |
| 131 | if (consumed != OK) { |
| 132 | return nullptr; |
| 133 | } |
Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 134 | status_t status = mInputConsumer->sendFinishedSignal(seqId, true); |
| 135 | EXPECT_EQ(OK, status) << "Could not send finished signal"; |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 136 | return ev; |
| 137 | } |
| 138 | |
Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 139 | void assertFocusChange(bool hasFocus) { |
| 140 | InputEvent *ev = consumeEvent(); |
| 141 | ASSERT_NE(ev, nullptr); |
| 142 | ASSERT_EQ(AINPUT_EVENT_TYPE_FOCUS, ev->getType()); |
| 143 | FocusEvent *focusEvent = static_cast<FocusEvent *>(ev); |
| 144 | EXPECT_EQ(hasFocus, focusEvent->getHasFocus()); |
| 145 | } |
| 146 | |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 147 | void expectTap(int x, int y) { |
| 148 | InputEvent* ev = consumeEvent(); |
Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 149 | ASSERT_NE(ev, nullptr); |
| 150 | ASSERT_EQ(AINPUT_EVENT_TYPE_MOTION, ev->getType()); |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 151 | MotionEvent* mev = static_cast<MotionEvent*>(ev); |
| 152 | EXPECT_EQ(AMOTION_EVENT_ACTION_DOWN, mev->getAction()); |
| 153 | EXPECT_EQ(x, mev->getX(0)); |
| 154 | EXPECT_EQ(y, mev->getY(0)); |
arthurhung | b4a0f85 | 2020-06-16 11:02:50 +0800 | [diff] [blame] | 155 | EXPECT_EQ(0, mev->getFlags() & VERIFIED_MOTION_EVENT_FLAGS); |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 156 | |
| 157 | ev = consumeEvent(); |
Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 158 | ASSERT_NE(ev, nullptr); |
| 159 | ASSERT_EQ(AINPUT_EVENT_TYPE_MOTION, ev->getType()); |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 160 | mev = static_cast<MotionEvent*>(ev); |
| 161 | EXPECT_EQ(AMOTION_EVENT_ACTION_UP, mev->getAction()); |
arthurhung | b4a0f85 | 2020-06-16 11:02:50 +0800 | [diff] [blame] | 162 | EXPECT_EQ(0, mev->getFlags() & VERIFIED_MOTION_EVENT_FLAGS); |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 163 | } |
| 164 | |
chaviw | 39cfa2e | 2020-11-04 14:19:02 -0800 | [diff] [blame] | 165 | void expectTapWithFlag(int x, int y, int32_t flags) { |
| 166 | InputEvent *ev = consumeEvent(); |
| 167 | ASSERT_NE(ev, nullptr); |
| 168 | ASSERT_EQ(AINPUT_EVENT_TYPE_MOTION, ev->getType()); |
| 169 | MotionEvent *mev = static_cast<MotionEvent *>(ev); |
| 170 | EXPECT_EQ(AMOTION_EVENT_ACTION_DOWN, mev->getAction()); |
| 171 | EXPECT_EQ(x, mev->getX(0)); |
| 172 | EXPECT_EQ(y, mev->getY(0)); |
| 173 | EXPECT_EQ(flags, mev->getFlags() & flags); |
| 174 | |
| 175 | ev = consumeEvent(); |
| 176 | ASSERT_NE(ev, nullptr); |
| 177 | ASSERT_EQ(AINPUT_EVENT_TYPE_MOTION, ev->getType()); |
| 178 | mev = static_cast<MotionEvent *>(ev); |
| 179 | EXPECT_EQ(AMOTION_EVENT_ACTION_UP, mev->getAction()); |
| 180 | EXPECT_EQ(flags, mev->getFlags() & flags); |
| 181 | } |
| 182 | |
Garfield Tan | 1560166 | 2020-09-22 15:32:38 -0700 | [diff] [blame] | 183 | ~InputSurface() { mInputFlinger->removeInputChannel(mClientChannel->getConnectionToken()); } |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 184 | |
| 185 | void doTransaction(std::function<void(SurfaceComposerClient::Transaction&, |
| 186 | const sp<SurfaceControl>&)> transactionBody) { |
| 187 | SurfaceComposerClient::Transaction t; |
| 188 | transactionBody(t, mSurfaceControl); |
| 189 | t.apply(true); |
| 190 | } |
| 191 | |
chaviw | 7e72caf | 2020-12-02 16:50:43 -0800 | [diff] [blame] | 192 | void showAt(int x, int y, Rect crop = Rect(0, 0, 100, 100)) { |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 193 | SurfaceComposerClient::Transaction t; |
| 194 | t.show(mSurfaceControl); |
| 195 | t.setInputWindowInfo(mSurfaceControl, mInputInfo); |
| 196 | t.setLayer(mSurfaceControl, LAYER_BASE); |
| 197 | t.setPosition(mSurfaceControl, x, y); |
chaviw | 7e72caf | 2020-12-02 16:50:43 -0800 | [diff] [blame] | 198 | t.setCrop_legacy(mSurfaceControl, crop); |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 199 | t.setAlpha(mSurfaceControl, 1); |
| 200 | t.apply(true); |
| 201 | } |
| 202 | |
Vishnu Nair | 958da93 | 2020-08-21 17:12:37 -0700 | [diff] [blame] | 203 | void requestFocus() { |
| 204 | SurfaceComposerClient::Transaction t; |
| 205 | t.setFocusedWindow(mInputInfo.token, nullptr, systemTime(SYSTEM_TIME_MONOTONIC), |
| 206 | 0 /* displayId */); |
| 207 | t.apply(true); |
| 208 | } |
| 209 | |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 210 | private: |
| 211 | void waitForEventAvailable() { |
| 212 | struct pollfd fd; |
| 213 | |
| 214 | fd.fd = mClientChannel->getFd(); |
| 215 | fd.events = POLLIN; |
| 216 | poll(&fd, 1, 3000); |
| 217 | } |
| 218 | |
| 219 | void populateInputInfo(int width, int height) { |
Garfield Tan | 1560166 | 2020-09-22 15:32:38 -0700 | [diff] [blame] | 220 | mInputInfo.token = mClientChannel->getConnectionToken(); |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 221 | mInputInfo.name = "Test info"; |
Michael Wright | 44753b1 | 2020-07-08 13:48:11 +0100 | [diff] [blame] | 222 | mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCH_MODAL; |
| 223 | mInputInfo.type = InputWindowInfo::Type::BASE_APPLICATION; |
Siarhei Vishniakou | c1ae556 | 2020-06-30 14:22:57 -0500 | [diff] [blame] | 224 | mInputInfo.dispatchingTimeout = 5s; |
Robert Carr | e07e103 | 2018-11-26 12:55:53 -0800 | [diff] [blame] | 225 | mInputInfo.globalScaleFactor = 1.0; |
Vishnu Nair | 47074b8 | 2020-08-14 11:54:47 -0700 | [diff] [blame] | 226 | mInputInfo.focusable = true; |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 227 | mInputInfo.hasWallpaper = false; |
| 228 | mInputInfo.paused = false; |
| 229 | |
| 230 | mInputInfo.touchableRegion.orSelf(Rect(0, 0, width, height)); |
| 231 | |
| 232 | // TODO: Fill in from SF? |
| 233 | mInputInfo.ownerPid = 11111; |
| 234 | mInputInfo.ownerUid = 11111; |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 235 | mInputInfo.displayId = 0; |
Robert Carr | 740167f | 2018-10-11 19:03:41 -0700 | [diff] [blame] | 236 | |
| 237 | InputApplicationInfo aInfo; |
| 238 | aInfo.token = new BBinder(); |
| 239 | aInfo.name = "Test app info"; |
Siarhei Vishniakou | 7062295 | 2020-07-30 11:17:23 -0500 | [diff] [blame] | 240 | aInfo.dispatchingTimeoutMillis = |
| 241 | std::chrono::duration_cast<std::chrono::milliseconds>(DISPATCHING_TIMEOUT).count(); |
Robert Carr | 740167f | 2018-10-11 19:03:41 -0700 | [diff] [blame] | 242 | |
| 243 | mInputInfo.applicationInfo = aInfo; |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 244 | } |
| 245 | public: |
| 246 | sp<SurfaceControl> mSurfaceControl; |
Siarhei Vishniakou | ce5ab08 | 2020-07-09 17:03:21 -0500 | [diff] [blame] | 247 | std::shared_ptr<InputChannel> mClientChannel; |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 248 | sp<IInputFlinger> mInputFlinger; |
| 249 | |
| 250 | InputWindowInfo mInputInfo; |
| 251 | |
| 252 | PreallocatedInputEventFactory mInputEventFactory; |
| 253 | InputConsumer* mInputConsumer; |
| 254 | }; |
| 255 | |
| 256 | class InputSurfacesTest : public ::testing::Test { |
| 257 | public: |
| 258 | InputSurfacesTest() { |
| 259 | ProcessState::self()->startThreadPool(); |
| 260 | } |
| 261 | |
| 262 | void SetUp() { |
| 263 | mComposerClient = new SurfaceComposerClient; |
| 264 | ASSERT_EQ(NO_ERROR, mComposerClient->initCheck()); |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 265 | |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 266 | const auto display = mComposerClient->getInternalDisplayToken(); |
Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 267 | ASSERT_NE(display, nullptr); |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 268 | |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 269 | DisplayConfig config; |
| 270 | ASSERT_EQ(NO_ERROR, mComposerClient->getActiveDisplayConfig(display, &config)); |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 271 | |
| 272 | // After a new buffer is queued, SurfaceFlinger is notified and will |
| 273 | // latch the new buffer on next vsync. Let's heuristically wait for 3 |
| 274 | // vsyncs. |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 275 | mBufferPostDelay = static_cast<int32_t>(1e6 / config.refreshRate) * 3; |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | void TearDown() { |
| 279 | mComposerClient->dispose(); |
| 280 | } |
| 281 | |
| 282 | std::unique_ptr<InputSurface> makeSurface(int width, int height) { |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 283 | return InputSurface::makeColorInputSurface(mComposerClient, width, height); |
| 284 | } |
| 285 | |
| 286 | void postBuffer(const sp<SurfaceControl> &layer) { |
| 287 | // wait for previous transactions (such as setSize) to complete |
| 288 | Transaction().apply(true); |
| 289 | ANativeWindow_Buffer buffer = {}; |
| 290 | EXPECT_EQ(NO_ERROR, layer->getSurface()->lock(&buffer, nullptr)); |
| 291 | ASSERT_EQ(NO_ERROR, layer->getSurface()->unlockAndPost()); |
| 292 | // Request an empty transaction to get applied synchronously to ensure the buffer is |
| 293 | // latched. |
| 294 | Transaction().apply(true); |
| 295 | usleep(mBufferPostDelay); |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | sp<SurfaceComposerClient> mComposerClient; |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 299 | int32_t mBufferPostDelay; |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 300 | }; |
| 301 | |
| 302 | void injectTap(int x, int y) { |
| 303 | char *buf1, *buf2; |
| 304 | asprintf(&buf1, "%d", x); |
| 305 | asprintf(&buf2, "%d", y); |
| 306 | if (fork() == 0) { |
| 307 | execlp("input", "input", "tap", buf1, buf2, NULL); |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | TEST_F(InputSurfacesTest, can_receive_input) { |
| 312 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 313 | surface->showAt(100, 100); |
| 314 | |
| 315 | injectTap(101, 101); |
| 316 | |
Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 317 | EXPECT_NE(surface->consumeEvent(), nullptr); |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 318 | } |
| 319 | |
Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 320 | /** |
| 321 | * Set up two surfaces side-by-side. Tap each surface. |
| 322 | * Next, swap the positions of the two surfaces. Inject tap into the two |
| 323 | * original locations. Ensure that the tap is received by the surfaces in the |
| 324 | * reverse order. |
| 325 | */ |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 326 | TEST_F(InputSurfacesTest, input_respects_positioning) { |
| 327 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 328 | surface->showAt(100, 100); |
| 329 | |
| 330 | std::unique_ptr<InputSurface> surface2 = makeSurface(100, 100); |
| 331 | surface2->showAt(200, 200); |
| 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); |
| 358 | surface2->showAt(10, 10); |
| 359 | |
| 360 | surface->doTransaction([](auto &t, auto &sc) { |
| 361 | t.setLayer(sc, LAYER_BASE + 1); |
| 362 | }); |
| 363 | |
| 364 | injectTap(11, 11); |
| 365 | surface->expectTap(1, 1); |
| 366 | |
| 367 | surface2->doTransaction([](auto &t, auto &sc) { |
| 368 | t.setLayer(sc, LAYER_BASE + 1); |
| 369 | }); |
| 370 | |
| 371 | injectTap(11, 11); |
| 372 | surface2->expectTap(1, 1); |
| 373 | |
| 374 | surface2->doTransaction([](auto &t, auto &sc) { |
| 375 | t.hide(sc); |
| 376 | }); |
| 377 | |
| 378 | injectTap(11, 11); |
| 379 | surface->expectTap(1, 1); |
| 380 | } |
| 381 | |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 382 | // Surface Insets are set to offset the client content and draw a border around the client surface |
| 383 | // (such as shadows in dialogs). Inputs sent to the client are offset such that 0,0 is the start |
| 384 | // of the client content. |
| 385 | TEST_F(InputSurfacesTest, input_respects_surface_insets) { |
| 386 | std::unique_ptr<InputSurface> bgSurface = makeSurface(100, 100); |
| 387 | std::unique_ptr<InputSurface> fgSurface = makeSurface(100, 100); |
| 388 | bgSurface->showAt(100, 100); |
| 389 | |
| 390 | fgSurface->mInputInfo.surfaceInset = 5; |
| 391 | fgSurface->showAt(100, 100); |
| 392 | |
| 393 | injectTap(106, 106); |
| 394 | fgSurface->expectTap(1, 1); |
| 395 | |
| 396 | injectTap(101, 101); |
| 397 | bgSurface->expectTap(1, 1); |
| 398 | } |
| 399 | |
| 400 | // Ensure a surface whose insets are cropped, handles the touch offset correctly. ref:b/120413463 |
| 401 | TEST_F(InputSurfacesTest, input_respects_cropped_surface_insets) { |
| 402 | std::unique_ptr<InputSurface> parentSurface = makeSurface(100, 100); |
| 403 | std::unique_ptr<InputSurface> childSurface = makeSurface(100, 100); |
| 404 | parentSurface->showAt(100, 100); |
| 405 | |
| 406 | childSurface->mInputInfo.surfaceInset = 10; |
| 407 | childSurface->showAt(100, 100); |
| 408 | |
| 409 | childSurface->doTransaction([&](auto &t, auto &sc) { |
| 410 | t.setPosition(sc, -5, -5); |
Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 411 | t.reparent(sc, parentSurface->mSurfaceControl); |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 412 | }); |
| 413 | |
| 414 | injectTap(106, 106); |
| 415 | childSurface->expectTap(1, 1); |
| 416 | |
| 417 | injectTap(101, 101); |
| 418 | parentSurface->expectTap(1, 1); |
| 419 | } |
| 420 | |
Arthur Hung | 118b114 | 2019-05-08 21:25:59 +0800 | [diff] [blame] | 421 | // Ensure a surface whose insets are scaled, handles the touch offset correctly. |
| 422 | TEST_F(InputSurfacesTest, input_respects_scaled_surface_insets) { |
| 423 | std::unique_ptr<InputSurface> bgSurface = makeSurface(100, 100); |
| 424 | std::unique_ptr<InputSurface> fgSurface = makeSurface(100, 100); |
| 425 | bgSurface->showAt(100, 100); |
| 426 | |
| 427 | fgSurface->mInputInfo.surfaceInset = 5; |
| 428 | fgSurface->showAt(100, 100); |
| 429 | |
| 430 | fgSurface->doTransaction([&](auto &t, auto &sc) { t.setMatrix(sc, 2.0, 0, 0, 4.0); }); |
| 431 | |
| 432 | // expect = touch / scale - inset |
| 433 | injectTap(112, 124); |
| 434 | fgSurface->expectTap(1, 1); |
| 435 | |
| 436 | injectTap(101, 101); |
| 437 | bgSurface->expectTap(1, 1); |
| 438 | } |
| 439 | |
Ady Abraham | 282f1d7 | 2019-07-24 18:05:56 -0700 | [diff] [blame] | 440 | TEST_F(InputSurfacesTest, input_respects_scaled_surface_insets_overflow) { |
| 441 | std::unique_ptr<InputSurface> fgSurface = makeSurface(100, 100); |
| 442 | // In case we pass the very big inset without any checking. |
| 443 | fgSurface->mInputInfo.surfaceInset = INT32_MAX; |
| 444 | fgSurface->showAt(100, 100); |
| 445 | |
| 446 | fgSurface->doTransaction([&](auto &t, auto &sc) { t.setMatrix(sc, 2.0, 0, 0, 2.0); }); |
| 447 | |
| 448 | // expect no crash for overflow, and inset size to be clamped to surface size |
| 449 | injectTap(202, 202); |
| 450 | fgSurface->expectTap(1, 1); |
| 451 | } |
| 452 | |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 453 | // Ensure we ignore transparent region when getting screen bounds when positioning input frame. |
| 454 | TEST_F(InputSurfacesTest, input_ignores_transparent_region) { |
| 455 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 456 | surface->doTransaction([](auto &t, auto &sc) { |
| 457 | Region transparentRegion(Rect(0, 0, 10, 10)); |
| 458 | t.setTransparentRegionHint(sc, transparentRegion); |
| 459 | }); |
| 460 | surface->showAt(100, 100); |
| 461 | injectTap(101, 101); |
| 462 | surface->expectTap(1, 1); |
| 463 | } |
| 464 | |
Vishnu Nair | f8678ba | 2019-10-11 18:11:26 -0700 | [diff] [blame] | 465 | // TODO(b/139494112) update tests once we define expected behavior |
| 466 | // Ensure we still send input to the surface regardless of surface visibility changes due to the |
| 467 | // first buffer being submitted or alpha changes. |
| 468 | // Original bug ref: b/120839715 |
| 469 | TEST_F(InputSurfacesTest, input_ignores_buffer_layer_buffer) { |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 470 | std::unique_ptr<InputSurface> bgSurface = makeSurface(100, 100); |
| 471 | std::unique_ptr<InputSurface> bufferSurface = |
| 472 | InputSurface::makeBufferInputSurface(mComposerClient, 100, 100); |
| 473 | |
| 474 | bgSurface->showAt(10, 10); |
| 475 | bufferSurface->showAt(10, 10); |
| 476 | |
| 477 | injectTap(11, 11); |
Vishnu Nair | f8678ba | 2019-10-11 18:11:26 -0700 | [diff] [blame] | 478 | bufferSurface->expectTap(1, 1); |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 479 | |
| 480 | postBuffer(bufferSurface->mSurfaceControl); |
| 481 | injectTap(11, 11); |
| 482 | bufferSurface->expectTap(1, 1); |
| 483 | } |
| 484 | |
Vishnu Nair | f8678ba | 2019-10-11 18:11:26 -0700 | [diff] [blame] | 485 | TEST_F(InputSurfacesTest, input_ignores_buffer_layer_alpha) { |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 486 | std::unique_ptr<InputSurface> bgSurface = makeSurface(100, 100); |
| 487 | std::unique_ptr<InputSurface> bufferSurface = |
| 488 | InputSurface::makeBufferInputSurface(mComposerClient, 100, 100); |
| 489 | postBuffer(bufferSurface->mSurfaceControl); |
| 490 | |
| 491 | bgSurface->showAt(10, 10); |
| 492 | bufferSurface->showAt(10, 10); |
| 493 | |
| 494 | injectTap(11, 11); |
| 495 | bufferSurface->expectTap(1, 1); |
| 496 | |
| 497 | bufferSurface->doTransaction([](auto &t, auto &sc) { t.setAlpha(sc, 0.0); }); |
| 498 | |
| 499 | injectTap(11, 11); |
Vishnu Nair | f8678ba | 2019-10-11 18:11:26 -0700 | [diff] [blame] | 500 | bufferSurface->expectTap(1, 1); |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 501 | } |
| 502 | |
Vishnu Nair | f8678ba | 2019-10-11 18:11:26 -0700 | [diff] [blame] | 503 | TEST_F(InputSurfacesTest, input_ignores_color_layer_alpha) { |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 504 | std::unique_ptr<InputSurface> bgSurface = makeSurface(100, 100); |
| 505 | std::unique_ptr<InputSurface> fgSurface = makeSurface(100, 100); |
| 506 | |
| 507 | bgSurface->showAt(10, 10); |
| 508 | fgSurface->showAt(10, 10); |
| 509 | |
| 510 | injectTap(11, 11); |
| 511 | fgSurface->expectTap(1, 1); |
| 512 | |
| 513 | fgSurface->doTransaction([](auto &t, auto &sc) { t.setAlpha(sc, 0.0); }); |
| 514 | |
| 515 | injectTap(11, 11); |
Vishnu Nair | f8678ba | 2019-10-11 18:11:26 -0700 | [diff] [blame] | 516 | fgSurface->expectTap(1, 1); |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | TEST_F(InputSurfacesTest, input_respects_container_layer_visiblity) { |
| 520 | std::unique_ptr<InputSurface> bgSurface = makeSurface(100, 100); |
| 521 | std::unique_ptr<InputSurface> containerSurface = |
| 522 | InputSurface::makeContainerInputSurface(mComposerClient, 100, 100); |
| 523 | |
| 524 | bgSurface->showAt(10, 10); |
| 525 | containerSurface->showAt(10, 10); |
| 526 | |
| 527 | injectTap(11, 11); |
| 528 | containerSurface->expectTap(1, 1); |
| 529 | |
| 530 | containerSurface->doTransaction([](auto &t, auto &sc) { t.hide(sc); }); |
| 531 | |
| 532 | injectTap(11, 11); |
| 533 | bgSurface->expectTap(1, 1); |
| 534 | } |
chaviw | fbe5d9c | 2018-12-26 12:23:37 -0800 | [diff] [blame] | 535 | |
Arthur Hung | d20b270 | 2019-01-14 18:16:16 +0800 | [diff] [blame] | 536 | TEST_F(InputSurfacesTest, input_respects_outscreen) { |
| 537 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 538 | surface->showAt(-1, -1); |
| 539 | |
| 540 | injectTap(0, 0); |
| 541 | surface->expectTap(1, 1); |
| 542 | } |
arthurhung | b4a0f85 | 2020-06-16 11:02:50 +0800 | [diff] [blame] | 543 | |
| 544 | TEST_F(InputSurfacesTest, input_ignores_cursor_layer) { |
| 545 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 546 | std::unique_ptr<InputSurface> cursorSurface = |
| 547 | InputSurface::makeCursorInputSurface(mComposerClient, 10, 10); |
| 548 | |
| 549 | surface->showAt(10, 10); |
arthurhung | b4a0f85 | 2020-06-16 11:02:50 +0800 | [diff] [blame] | 550 | cursorSurface->showAt(10, 10); |
| 551 | |
| 552 | injectTap(11, 11); |
| 553 | surface->expectTap(1, 1); |
| 554 | } |
Vishnu Nair | 958da93 | 2020-08-21 17:12:37 -0700 | [diff] [blame] | 555 | |
| 556 | TEST_F(InputSurfacesTest, can_be_focused) { |
| 557 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 558 | surface->showAt(100, 100); |
| 559 | surface->requestFocus(); |
| 560 | |
| 561 | surface->assertFocusChange(true); |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 562 | } |
chaviw | 44a6d2b | 2020-09-08 17:14:16 -0700 | [diff] [blame] | 563 | |
| 564 | TEST_F(InputSurfacesTest, rotate_surface) { |
| 565 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 566 | surface->showAt(10, 10); |
| 567 | surface->doTransaction([](auto &t, auto &sc) { |
| 568 | t.setMatrix(sc, 0, 1, -1, 0); // 90 degrees |
| 569 | }); |
| 570 | injectTap(8, 11); |
| 571 | surface->expectTap(1, 2); |
| 572 | |
| 573 | surface->doTransaction([](auto &t, auto &sc) { |
| 574 | t.setMatrix(sc, -1, 0, 0, -1); // 180 degrees |
| 575 | }); |
| 576 | injectTap(9, 8); |
| 577 | surface->expectTap(1, 2); |
| 578 | |
| 579 | surface->doTransaction([](auto &t, auto &sc) { |
| 580 | t.setMatrix(sc, 0, -1, 1, 0); // 270 degrees |
| 581 | }); |
| 582 | injectTap(12, 9); |
| 583 | surface->expectTap(1, 2); |
| 584 | } |
| 585 | |
| 586 | TEST_F(InputSurfacesTest, rotate_surface_with_scale) { |
| 587 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 588 | surface->showAt(10, 10); |
| 589 | surface->doTransaction([](auto &t, auto &sc) { |
| 590 | t.setMatrix(sc, 0, 2, -4, 0); // 90 degrees |
| 591 | }); |
| 592 | injectTap(2, 12); |
| 593 | surface->expectTap(1, 2); |
| 594 | |
| 595 | surface->doTransaction([](auto &t, auto &sc) { |
| 596 | t.setMatrix(sc, -2, 0, 0, -4); // 180 degrees |
| 597 | }); |
| 598 | injectTap(8, 2); |
| 599 | surface->expectTap(1, 2); |
| 600 | |
| 601 | surface->doTransaction([](auto &t, auto &sc) { |
| 602 | t.setMatrix(sc, 0, -2, 4, 0); // 270 degrees |
| 603 | }); |
| 604 | injectTap(18, 8); |
| 605 | surface->expectTap(1, 2); |
| 606 | } |
| 607 | |
| 608 | TEST_F(InputSurfacesTest, rotate_surface_with_scale_and_insets) { |
| 609 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 610 | surface->mInputInfo.surfaceInset = 5; |
| 611 | surface->showAt(100, 100); |
| 612 | |
| 613 | surface->doTransaction([](auto &t, auto &sc) { |
| 614 | t.setMatrix(sc, 0, 2, -4, 0); // 90 degrees |
| 615 | }); |
| 616 | injectTap(40, 120); |
| 617 | surface->expectTap(5, 10); |
| 618 | |
| 619 | surface->doTransaction([](auto &t, auto &sc) { |
| 620 | t.setMatrix(sc, -2, 0, 0, -4); // 180 degrees |
| 621 | }); |
| 622 | injectTap(80, 40); |
| 623 | surface->expectTap(5, 10); |
| 624 | |
| 625 | surface->doTransaction([](auto &t, auto &sc) { |
| 626 | t.setMatrix(sc, 0, -2, 4, 0); // 270 degrees |
| 627 | }); |
| 628 | injectTap(160, 80); |
| 629 | surface->expectTap(5, 10); |
| 630 | } |
| 631 | |
chaviw | 39cfa2e | 2020-11-04 14:19:02 -0800 | [diff] [blame] | 632 | TEST_F(InputSurfacesTest, touch_flag_obscured) { |
| 633 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 634 | surface->showAt(100, 100); |
| 635 | |
| 636 | // Add non touchable window to fully cover touchable window. Window behind gets touch, but |
| 637 | // with flag AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED |
| 638 | std::unique_ptr<InputSurface> nonTouchableSurface = makeSurface(100, 100); |
| 639 | nonTouchableSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE; |
| 640 | nonTouchableSurface->mInputInfo.ownerUid = 22222; |
Bernardo Rufino | 602ef71 | 2020-12-21 11:02:18 +0000 | [diff] [blame^] | 641 | // Overriding occlusion mode otherwise the touch would be discarded at InputDispatcher by |
| 642 | // the default obscured/untrusted touch filter introduced in S. |
| 643 | nonTouchableSurface->mInputInfo.touchOcclusionMode = TouchOcclusionMode::ALLOW; |
chaviw | 39cfa2e | 2020-11-04 14:19:02 -0800 | [diff] [blame] | 644 | nonTouchableSurface->showAt(100, 100); |
| 645 | |
| 646 | injectTap(190, 199); |
| 647 | surface->expectTapWithFlag(90, 99, AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED); |
| 648 | } |
| 649 | |
| 650 | TEST_F(InputSurfacesTest, touch_flag_partially_obscured_with_crop) { |
| 651 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 652 | surface->showAt(100, 100); |
| 653 | |
| 654 | // Add non touchable window to cover touchable window, but parent is cropped to not cover area |
| 655 | // that will be tapped. Window behind gets touch, but with flag |
| 656 | // AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED |
| 657 | std::unique_ptr<InputSurface> parentSurface = makeSurface(100, 100); |
| 658 | std::unique_ptr<InputSurface> nonTouchableSurface = makeSurface(100, 100); |
| 659 | nonTouchableSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE; |
| 660 | parentSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE; |
| 661 | nonTouchableSurface->mInputInfo.ownerUid = 22222; |
| 662 | parentSurface->mInputInfo.ownerUid = 22222; |
| 663 | nonTouchableSurface->showAt(0, 0); |
| 664 | parentSurface->showAt(100, 100); |
| 665 | |
| 666 | nonTouchableSurface->doTransaction([&](auto &t, auto &sc) { |
| 667 | t.setCrop_legacy(parentSurface->mSurfaceControl, Rect(0, 0, 50, 50)); |
| 668 | t.reparent(sc, parentSurface->mSurfaceControl); |
| 669 | }); |
| 670 | |
| 671 | injectTap(190, 199); |
| 672 | surface->expectTapWithFlag(90, 99, AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED); |
| 673 | } |
| 674 | |
| 675 | TEST_F(InputSurfacesTest, touch_not_obscured_with_crop) { |
| 676 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 677 | surface->showAt(100, 100); |
| 678 | |
| 679 | // Add non touchable window to cover touchable window, but parent is cropped to avoid covering |
| 680 | // the touchable window. Window behind gets touch with no obscured flags. |
| 681 | std::unique_ptr<InputSurface> parentSurface = makeSurface(100, 100); |
| 682 | std::unique_ptr<InputSurface> nonTouchableSurface = makeSurface(100, 100); |
| 683 | nonTouchableSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE; |
| 684 | parentSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE; |
| 685 | nonTouchableSurface->mInputInfo.ownerUid = 22222; |
| 686 | parentSurface->mInputInfo.ownerUid = 22222; |
| 687 | nonTouchableSurface->showAt(0, 0); |
| 688 | parentSurface->showAt(50, 50); |
| 689 | |
| 690 | nonTouchableSurface->doTransaction([&](auto &t, auto &sc) { |
| 691 | t.setCrop_legacy(parentSurface->mSurfaceControl, Rect(0, 0, 50, 50)); |
| 692 | t.reparent(sc, parentSurface->mSurfaceControl); |
| 693 | }); |
| 694 | |
| 695 | injectTap(101, 110); |
| 696 | surface->expectTap(1, 10); |
| 697 | } |
| 698 | |
chaviw | 7e72caf | 2020-12-02 16:50:43 -0800 | [diff] [blame] | 699 | TEST_F(InputSurfacesTest, touch_not_obscured_with_zero_sized_bql) { |
| 700 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 701 | |
| 702 | std::unique_ptr<InputSurface> bufferSurface = |
| 703 | InputSurface::makeBufferInputSurface(mComposerClient, 0, 0); |
| 704 | bufferSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE; |
| 705 | bufferSurface->mInputInfo.ownerUid = 22222; |
| 706 | |
| 707 | surface->showAt(10, 10); |
| 708 | bufferSurface->showAt(50, 50, Rect::EMPTY_RECT); |
| 709 | |
| 710 | injectTap(11, 11); |
| 711 | surface->expectTap(1, 1); |
| 712 | } |
| 713 | |
| 714 | TEST_F(InputSurfacesTest, touch_not_obscured_with_zero_sized_blast) { |
| 715 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 716 | |
| 717 | std::unique_ptr<InputSurface> bufferSurface = |
| 718 | InputSurface::makeBlastInputSurface(mComposerClient, 0, 0); |
| 719 | bufferSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE; |
| 720 | bufferSurface->mInputInfo.ownerUid = 22222; |
| 721 | |
| 722 | surface->showAt(10, 10); |
| 723 | bufferSurface->showAt(50, 50, Rect::EMPTY_RECT); |
| 724 | |
| 725 | injectTap(11, 11); |
| 726 | surface->expectTap(1, 1); |
| 727 | } |
| 728 | |
Vishnu Nair | 958da93 | 2020-08-21 17:12:37 -0700 | [diff] [blame] | 729 | } // namespace android::test |