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 | |
Marin Shalamanov | a7fe304 | 2021-01-29 21:02:08 +0100 | [diff] [blame^] | 44 | #include <ui/DisplayMode.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; |
Vishnu Nair | 9ad0146 | 2021-01-15 12:55:14 -0800 | [diff] [blame] | 205 | FocusRequest request; |
| 206 | request.token = mInputInfo.token; |
| 207 | request.windowName = mInputInfo.name; |
| 208 | request.focusedToken = nullptr; |
| 209 | request.focusedWindowName = ""; |
| 210 | request.timestamp = systemTime(SYSTEM_TIME_MONOTONIC); |
| 211 | request.displayId = 0; |
| 212 | t.setFocusedWindow(request); |
Vishnu Nair | 958da93 | 2020-08-21 17:12:37 -0700 | [diff] [blame] | 213 | t.apply(true); |
| 214 | } |
| 215 | |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 216 | private: |
| 217 | void waitForEventAvailable() { |
| 218 | struct pollfd fd; |
| 219 | |
| 220 | fd.fd = mClientChannel->getFd(); |
| 221 | fd.events = POLLIN; |
| 222 | poll(&fd, 1, 3000); |
| 223 | } |
| 224 | |
| 225 | void populateInputInfo(int width, int height) { |
Garfield Tan | 1560166 | 2020-09-22 15:32:38 -0700 | [diff] [blame] | 226 | mInputInfo.token = mClientChannel->getConnectionToken(); |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 227 | mInputInfo.name = "Test info"; |
Michael Wright | 44753b1 | 2020-07-08 13:48:11 +0100 | [diff] [blame] | 228 | mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCH_MODAL; |
| 229 | mInputInfo.type = InputWindowInfo::Type::BASE_APPLICATION; |
Siarhei Vishniakou | c1ae556 | 2020-06-30 14:22:57 -0500 | [diff] [blame] | 230 | mInputInfo.dispatchingTimeout = 5s; |
Robert Carr | e07e103 | 2018-11-26 12:55:53 -0800 | [diff] [blame] | 231 | mInputInfo.globalScaleFactor = 1.0; |
Vishnu Nair | 47074b8 | 2020-08-14 11:54:47 -0700 | [diff] [blame] | 232 | mInputInfo.focusable = true; |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 233 | mInputInfo.hasWallpaper = false; |
| 234 | mInputInfo.paused = false; |
| 235 | |
| 236 | mInputInfo.touchableRegion.orSelf(Rect(0, 0, width, height)); |
| 237 | |
| 238 | // TODO: Fill in from SF? |
| 239 | mInputInfo.ownerPid = 11111; |
| 240 | mInputInfo.ownerUid = 11111; |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 241 | mInputInfo.displayId = 0; |
Robert Carr | 740167f | 2018-10-11 19:03:41 -0700 | [diff] [blame] | 242 | |
| 243 | InputApplicationInfo aInfo; |
| 244 | aInfo.token = new BBinder(); |
| 245 | aInfo.name = "Test app info"; |
Siarhei Vishniakou | 7062295 | 2020-07-30 11:17:23 -0500 | [diff] [blame] | 246 | aInfo.dispatchingTimeoutMillis = |
| 247 | std::chrono::duration_cast<std::chrono::milliseconds>(DISPATCHING_TIMEOUT).count(); |
Robert Carr | 740167f | 2018-10-11 19:03:41 -0700 | [diff] [blame] | 248 | |
| 249 | mInputInfo.applicationInfo = aInfo; |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 250 | } |
| 251 | public: |
| 252 | sp<SurfaceControl> mSurfaceControl; |
Siarhei Vishniakou | ce5ab08 | 2020-07-09 17:03:21 -0500 | [diff] [blame] | 253 | std::shared_ptr<InputChannel> mClientChannel; |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 254 | sp<IInputFlinger> mInputFlinger; |
| 255 | |
| 256 | InputWindowInfo mInputInfo; |
| 257 | |
| 258 | PreallocatedInputEventFactory mInputEventFactory; |
| 259 | InputConsumer* mInputConsumer; |
| 260 | }; |
| 261 | |
| 262 | class InputSurfacesTest : public ::testing::Test { |
| 263 | public: |
| 264 | InputSurfacesTest() { |
| 265 | ProcessState::self()->startThreadPool(); |
| 266 | } |
| 267 | |
| 268 | void SetUp() { |
| 269 | mComposerClient = new SurfaceComposerClient; |
| 270 | ASSERT_EQ(NO_ERROR, mComposerClient->initCheck()); |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 271 | |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 272 | const auto display = mComposerClient->getInternalDisplayToken(); |
Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 273 | ASSERT_NE(display, nullptr); |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 274 | |
Marin Shalamanov | a7fe304 | 2021-01-29 21:02:08 +0100 | [diff] [blame^] | 275 | ui::DisplayMode mode; |
| 276 | ASSERT_EQ(NO_ERROR, mComposerClient->getActiveDisplayMode(display, &mode)); |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 277 | |
| 278 | // After a new buffer is queued, SurfaceFlinger is notified and will |
| 279 | // latch the new buffer on next vsync. Let's heuristically wait for 3 |
| 280 | // vsyncs. |
Marin Shalamanov | a7fe304 | 2021-01-29 21:02:08 +0100 | [diff] [blame^] | 281 | mBufferPostDelay = static_cast<int32_t>(1e6 / mode.refreshRate) * 3; |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | void TearDown() { |
| 285 | mComposerClient->dispose(); |
| 286 | } |
| 287 | |
| 288 | std::unique_ptr<InputSurface> makeSurface(int width, int height) { |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 289 | return InputSurface::makeColorInputSurface(mComposerClient, width, height); |
| 290 | } |
| 291 | |
| 292 | void postBuffer(const sp<SurfaceControl> &layer) { |
| 293 | // wait for previous transactions (such as setSize) to complete |
| 294 | Transaction().apply(true); |
| 295 | ANativeWindow_Buffer buffer = {}; |
| 296 | EXPECT_EQ(NO_ERROR, layer->getSurface()->lock(&buffer, nullptr)); |
| 297 | ASSERT_EQ(NO_ERROR, layer->getSurface()->unlockAndPost()); |
| 298 | // Request an empty transaction to get applied synchronously to ensure the buffer is |
| 299 | // latched. |
| 300 | Transaction().apply(true); |
| 301 | usleep(mBufferPostDelay); |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | sp<SurfaceComposerClient> mComposerClient; |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 305 | int32_t mBufferPostDelay; |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 306 | }; |
| 307 | |
| 308 | void injectTap(int x, int y) { |
| 309 | char *buf1, *buf2; |
| 310 | asprintf(&buf1, "%d", x); |
| 311 | asprintf(&buf2, "%d", y); |
| 312 | if (fork() == 0) { |
| 313 | execlp("input", "input", "tap", buf1, buf2, NULL); |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | TEST_F(InputSurfacesTest, can_receive_input) { |
| 318 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 319 | surface->showAt(100, 100); |
| 320 | |
| 321 | injectTap(101, 101); |
| 322 | |
Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 323 | EXPECT_NE(surface->consumeEvent(), nullptr); |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 324 | } |
| 325 | |
Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 326 | /** |
| 327 | * Set up two surfaces side-by-side. Tap each surface. |
| 328 | * Next, swap the positions of the two surfaces. Inject tap into the two |
| 329 | * original locations. Ensure that the tap is received by the surfaces in the |
| 330 | * reverse order. |
| 331 | */ |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 332 | TEST_F(InputSurfacesTest, input_respects_positioning) { |
| 333 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 334 | surface->showAt(100, 100); |
| 335 | |
| 336 | std::unique_ptr<InputSurface> surface2 = makeSurface(100, 100); |
| 337 | surface2->showAt(200, 200); |
| 338 | |
| 339 | injectTap(201, 201); |
| 340 | surface2->expectTap(1, 1); |
| 341 | |
| 342 | injectTap(101, 101); |
| 343 | surface->expectTap(1, 1); |
| 344 | |
| 345 | surface2->doTransaction([](auto &t, auto &sc) { |
| 346 | t.setPosition(sc, 100, 100); |
| 347 | }); |
| 348 | surface->doTransaction([](auto &t, auto &sc) { |
| 349 | t.setPosition(sc, 200, 200); |
| 350 | }); |
| 351 | |
| 352 | injectTap(101, 101); |
| 353 | surface2->expectTap(1, 1); |
| 354 | |
| 355 | injectTap(201, 201); |
| 356 | surface->expectTap(1, 1); |
| 357 | } |
| 358 | |
| 359 | TEST_F(InputSurfacesTest, input_respects_layering) { |
| 360 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 361 | std::unique_ptr<InputSurface> surface2 = makeSurface(100, 100); |
| 362 | |
| 363 | surface->showAt(10, 10); |
| 364 | surface2->showAt(10, 10); |
| 365 | |
| 366 | surface->doTransaction([](auto &t, auto &sc) { |
| 367 | t.setLayer(sc, LAYER_BASE + 1); |
| 368 | }); |
| 369 | |
| 370 | injectTap(11, 11); |
| 371 | surface->expectTap(1, 1); |
| 372 | |
| 373 | surface2->doTransaction([](auto &t, auto &sc) { |
| 374 | t.setLayer(sc, LAYER_BASE + 1); |
| 375 | }); |
| 376 | |
| 377 | injectTap(11, 11); |
| 378 | surface2->expectTap(1, 1); |
| 379 | |
| 380 | surface2->doTransaction([](auto &t, auto &sc) { |
| 381 | t.hide(sc); |
| 382 | }); |
| 383 | |
| 384 | injectTap(11, 11); |
| 385 | surface->expectTap(1, 1); |
| 386 | } |
| 387 | |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 388 | // Surface Insets are set to offset the client content and draw a border around the client surface |
| 389 | // (such as shadows in dialogs). Inputs sent to the client are offset such that 0,0 is the start |
| 390 | // of the client content. |
| 391 | TEST_F(InputSurfacesTest, input_respects_surface_insets) { |
| 392 | std::unique_ptr<InputSurface> bgSurface = makeSurface(100, 100); |
| 393 | std::unique_ptr<InputSurface> fgSurface = makeSurface(100, 100); |
| 394 | bgSurface->showAt(100, 100); |
| 395 | |
| 396 | fgSurface->mInputInfo.surfaceInset = 5; |
| 397 | fgSurface->showAt(100, 100); |
| 398 | |
| 399 | injectTap(106, 106); |
| 400 | fgSurface->expectTap(1, 1); |
| 401 | |
| 402 | injectTap(101, 101); |
| 403 | bgSurface->expectTap(1, 1); |
| 404 | } |
| 405 | |
| 406 | // Ensure a surface whose insets are cropped, handles the touch offset correctly. ref:b/120413463 |
| 407 | TEST_F(InputSurfacesTest, input_respects_cropped_surface_insets) { |
| 408 | std::unique_ptr<InputSurface> parentSurface = makeSurface(100, 100); |
| 409 | std::unique_ptr<InputSurface> childSurface = makeSurface(100, 100); |
| 410 | parentSurface->showAt(100, 100); |
| 411 | |
| 412 | childSurface->mInputInfo.surfaceInset = 10; |
| 413 | childSurface->showAt(100, 100); |
| 414 | |
| 415 | childSurface->doTransaction([&](auto &t, auto &sc) { |
| 416 | t.setPosition(sc, -5, -5); |
Pablo Gamito | 11dcc22 | 2020-09-12 15:49:39 +0000 | [diff] [blame] | 417 | t.reparent(sc, parentSurface->mSurfaceControl); |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 418 | }); |
| 419 | |
| 420 | injectTap(106, 106); |
| 421 | childSurface->expectTap(1, 1); |
| 422 | |
| 423 | injectTap(101, 101); |
| 424 | parentSurface->expectTap(1, 1); |
| 425 | } |
| 426 | |
Arthur Hung | 118b114 | 2019-05-08 21:25:59 +0800 | [diff] [blame] | 427 | // Ensure a surface whose insets are scaled, handles the touch offset correctly. |
| 428 | TEST_F(InputSurfacesTest, input_respects_scaled_surface_insets) { |
| 429 | std::unique_ptr<InputSurface> bgSurface = makeSurface(100, 100); |
| 430 | std::unique_ptr<InputSurface> fgSurface = makeSurface(100, 100); |
| 431 | bgSurface->showAt(100, 100); |
| 432 | |
| 433 | fgSurface->mInputInfo.surfaceInset = 5; |
| 434 | fgSurface->showAt(100, 100); |
| 435 | |
| 436 | fgSurface->doTransaction([&](auto &t, auto &sc) { t.setMatrix(sc, 2.0, 0, 0, 4.0); }); |
| 437 | |
| 438 | // expect = touch / scale - inset |
| 439 | injectTap(112, 124); |
| 440 | fgSurface->expectTap(1, 1); |
| 441 | |
| 442 | injectTap(101, 101); |
| 443 | bgSurface->expectTap(1, 1); |
| 444 | } |
| 445 | |
Ady Abraham | 282f1d7 | 2019-07-24 18:05:56 -0700 | [diff] [blame] | 446 | TEST_F(InputSurfacesTest, input_respects_scaled_surface_insets_overflow) { |
| 447 | std::unique_ptr<InputSurface> fgSurface = makeSurface(100, 100); |
| 448 | // In case we pass the very big inset without any checking. |
| 449 | fgSurface->mInputInfo.surfaceInset = INT32_MAX; |
| 450 | fgSurface->showAt(100, 100); |
| 451 | |
| 452 | fgSurface->doTransaction([&](auto &t, auto &sc) { t.setMatrix(sc, 2.0, 0, 0, 2.0); }); |
| 453 | |
| 454 | // expect no crash for overflow, and inset size to be clamped to surface size |
| 455 | injectTap(202, 202); |
| 456 | fgSurface->expectTap(1, 1); |
| 457 | } |
| 458 | |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 459 | // Ensure we ignore transparent region when getting screen bounds when positioning input frame. |
| 460 | TEST_F(InputSurfacesTest, input_ignores_transparent_region) { |
| 461 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 462 | surface->doTransaction([](auto &t, auto &sc) { |
| 463 | Region transparentRegion(Rect(0, 0, 10, 10)); |
| 464 | t.setTransparentRegionHint(sc, transparentRegion); |
| 465 | }); |
| 466 | surface->showAt(100, 100); |
| 467 | injectTap(101, 101); |
| 468 | surface->expectTap(1, 1); |
| 469 | } |
| 470 | |
Vishnu Nair | f8678ba | 2019-10-11 18:11:26 -0700 | [diff] [blame] | 471 | // TODO(b/139494112) update tests once we define expected behavior |
| 472 | // Ensure we still send input to the surface regardless of surface visibility changes due to the |
| 473 | // first buffer being submitted or alpha changes. |
| 474 | // Original bug ref: b/120839715 |
| 475 | TEST_F(InputSurfacesTest, input_ignores_buffer_layer_buffer) { |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 476 | std::unique_ptr<InputSurface> bgSurface = makeSurface(100, 100); |
| 477 | std::unique_ptr<InputSurface> bufferSurface = |
| 478 | InputSurface::makeBufferInputSurface(mComposerClient, 100, 100); |
| 479 | |
| 480 | bgSurface->showAt(10, 10); |
| 481 | bufferSurface->showAt(10, 10); |
| 482 | |
| 483 | injectTap(11, 11); |
Vishnu Nair | f8678ba | 2019-10-11 18:11:26 -0700 | [diff] [blame] | 484 | bufferSurface->expectTap(1, 1); |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 485 | |
| 486 | postBuffer(bufferSurface->mSurfaceControl); |
| 487 | injectTap(11, 11); |
| 488 | bufferSurface->expectTap(1, 1); |
| 489 | } |
| 490 | |
Vishnu Nair | f8678ba | 2019-10-11 18:11:26 -0700 | [diff] [blame] | 491 | TEST_F(InputSurfacesTest, input_ignores_buffer_layer_alpha) { |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 492 | std::unique_ptr<InputSurface> bgSurface = makeSurface(100, 100); |
| 493 | std::unique_ptr<InputSurface> bufferSurface = |
| 494 | InputSurface::makeBufferInputSurface(mComposerClient, 100, 100); |
| 495 | postBuffer(bufferSurface->mSurfaceControl); |
| 496 | |
| 497 | bgSurface->showAt(10, 10); |
| 498 | bufferSurface->showAt(10, 10); |
| 499 | |
| 500 | injectTap(11, 11); |
| 501 | bufferSurface->expectTap(1, 1); |
| 502 | |
| 503 | bufferSurface->doTransaction([](auto &t, auto &sc) { t.setAlpha(sc, 0.0); }); |
| 504 | |
| 505 | injectTap(11, 11); |
Vishnu Nair | f8678ba | 2019-10-11 18:11:26 -0700 | [diff] [blame] | 506 | bufferSurface->expectTap(1, 1); |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 507 | } |
| 508 | |
Vishnu Nair | f8678ba | 2019-10-11 18:11:26 -0700 | [diff] [blame] | 509 | TEST_F(InputSurfacesTest, input_ignores_color_layer_alpha) { |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 510 | std::unique_ptr<InputSurface> bgSurface = makeSurface(100, 100); |
| 511 | std::unique_ptr<InputSurface> fgSurface = makeSurface(100, 100); |
| 512 | |
| 513 | bgSurface->showAt(10, 10); |
| 514 | fgSurface->showAt(10, 10); |
| 515 | |
| 516 | injectTap(11, 11); |
| 517 | fgSurface->expectTap(1, 1); |
| 518 | |
| 519 | fgSurface->doTransaction([](auto &t, auto &sc) { t.setAlpha(sc, 0.0); }); |
| 520 | |
| 521 | injectTap(11, 11); |
Vishnu Nair | f8678ba | 2019-10-11 18:11:26 -0700 | [diff] [blame] | 522 | fgSurface->expectTap(1, 1); |
Vishnu Nair | de19f85 | 2018-12-18 16:11:53 -0800 | [diff] [blame] | 523 | } |
| 524 | |
| 525 | TEST_F(InputSurfacesTest, input_respects_container_layer_visiblity) { |
| 526 | std::unique_ptr<InputSurface> bgSurface = makeSurface(100, 100); |
| 527 | std::unique_ptr<InputSurface> containerSurface = |
| 528 | InputSurface::makeContainerInputSurface(mComposerClient, 100, 100); |
| 529 | |
| 530 | bgSurface->showAt(10, 10); |
| 531 | containerSurface->showAt(10, 10); |
| 532 | |
| 533 | injectTap(11, 11); |
| 534 | containerSurface->expectTap(1, 1); |
| 535 | |
| 536 | containerSurface->doTransaction([](auto &t, auto &sc) { t.hide(sc); }); |
| 537 | |
| 538 | injectTap(11, 11); |
| 539 | bgSurface->expectTap(1, 1); |
| 540 | } |
chaviw | fbe5d9c | 2018-12-26 12:23:37 -0800 | [diff] [blame] | 541 | |
Arthur Hung | d20b270 | 2019-01-14 18:16:16 +0800 | [diff] [blame] | 542 | TEST_F(InputSurfacesTest, input_respects_outscreen) { |
| 543 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 544 | surface->showAt(-1, -1); |
| 545 | |
| 546 | injectTap(0, 0); |
| 547 | surface->expectTap(1, 1); |
| 548 | } |
arthurhung | b4a0f85 | 2020-06-16 11:02:50 +0800 | [diff] [blame] | 549 | |
| 550 | TEST_F(InputSurfacesTest, input_ignores_cursor_layer) { |
| 551 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 552 | std::unique_ptr<InputSurface> cursorSurface = |
| 553 | InputSurface::makeCursorInputSurface(mComposerClient, 10, 10); |
| 554 | |
| 555 | surface->showAt(10, 10); |
arthurhung | b4a0f85 | 2020-06-16 11:02:50 +0800 | [diff] [blame] | 556 | cursorSurface->showAt(10, 10); |
| 557 | |
| 558 | injectTap(11, 11); |
| 559 | surface->expectTap(1, 1); |
| 560 | } |
Vishnu Nair | 958da93 | 2020-08-21 17:12:37 -0700 | [diff] [blame] | 561 | |
| 562 | TEST_F(InputSurfacesTest, can_be_focused) { |
| 563 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 564 | surface->showAt(100, 100); |
| 565 | surface->requestFocus(); |
| 566 | |
| 567 | surface->assertFocusChange(true); |
Robert Carr | 1c4c559 | 2018-09-24 13:18:43 -0700 | [diff] [blame] | 568 | } |
chaviw | 44a6d2b | 2020-09-08 17:14:16 -0700 | [diff] [blame] | 569 | |
| 570 | TEST_F(InputSurfacesTest, rotate_surface) { |
| 571 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 572 | surface->showAt(10, 10); |
| 573 | surface->doTransaction([](auto &t, auto &sc) { |
| 574 | t.setMatrix(sc, 0, 1, -1, 0); // 90 degrees |
| 575 | }); |
| 576 | injectTap(8, 11); |
| 577 | surface->expectTap(1, 2); |
| 578 | |
| 579 | surface->doTransaction([](auto &t, auto &sc) { |
| 580 | t.setMatrix(sc, -1, 0, 0, -1); // 180 degrees |
| 581 | }); |
| 582 | injectTap(9, 8); |
| 583 | surface->expectTap(1, 2); |
| 584 | |
| 585 | surface->doTransaction([](auto &t, auto &sc) { |
| 586 | t.setMatrix(sc, 0, -1, 1, 0); // 270 degrees |
| 587 | }); |
| 588 | injectTap(12, 9); |
| 589 | surface->expectTap(1, 2); |
| 590 | } |
| 591 | |
| 592 | TEST_F(InputSurfacesTest, rotate_surface_with_scale) { |
| 593 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 594 | surface->showAt(10, 10); |
| 595 | surface->doTransaction([](auto &t, auto &sc) { |
| 596 | t.setMatrix(sc, 0, 2, -4, 0); // 90 degrees |
| 597 | }); |
| 598 | injectTap(2, 12); |
| 599 | surface->expectTap(1, 2); |
| 600 | |
| 601 | surface->doTransaction([](auto &t, auto &sc) { |
| 602 | t.setMatrix(sc, -2, 0, 0, -4); // 180 degrees |
| 603 | }); |
| 604 | injectTap(8, 2); |
| 605 | surface->expectTap(1, 2); |
| 606 | |
| 607 | surface->doTransaction([](auto &t, auto &sc) { |
| 608 | t.setMatrix(sc, 0, -2, 4, 0); // 270 degrees |
| 609 | }); |
| 610 | injectTap(18, 8); |
| 611 | surface->expectTap(1, 2); |
| 612 | } |
| 613 | |
| 614 | TEST_F(InputSurfacesTest, rotate_surface_with_scale_and_insets) { |
| 615 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 616 | surface->mInputInfo.surfaceInset = 5; |
| 617 | surface->showAt(100, 100); |
| 618 | |
| 619 | surface->doTransaction([](auto &t, auto &sc) { |
| 620 | t.setMatrix(sc, 0, 2, -4, 0); // 90 degrees |
| 621 | }); |
| 622 | injectTap(40, 120); |
| 623 | surface->expectTap(5, 10); |
| 624 | |
| 625 | surface->doTransaction([](auto &t, auto &sc) { |
| 626 | t.setMatrix(sc, -2, 0, 0, -4); // 180 degrees |
| 627 | }); |
| 628 | injectTap(80, 40); |
| 629 | surface->expectTap(5, 10); |
| 630 | |
| 631 | surface->doTransaction([](auto &t, auto &sc) { |
| 632 | t.setMatrix(sc, 0, -2, 4, 0); // 270 degrees |
| 633 | }); |
| 634 | injectTap(160, 80); |
| 635 | surface->expectTap(5, 10); |
| 636 | } |
| 637 | |
chaviw | 39cfa2e | 2020-11-04 14:19:02 -0800 | [diff] [blame] | 638 | TEST_F(InputSurfacesTest, touch_flag_obscured) { |
| 639 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 640 | surface->showAt(100, 100); |
| 641 | |
| 642 | // Add non touchable window to fully cover touchable window. Window behind gets touch, but |
| 643 | // with flag AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED |
| 644 | std::unique_ptr<InputSurface> nonTouchableSurface = makeSurface(100, 100); |
| 645 | nonTouchableSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE; |
| 646 | nonTouchableSurface->mInputInfo.ownerUid = 22222; |
Bernardo Rufino | 602ef71 | 2020-12-21 11:02:18 +0000 | [diff] [blame] | 647 | // Overriding occlusion mode otherwise the touch would be discarded at InputDispatcher by |
| 648 | // the default obscured/untrusted touch filter introduced in S. |
| 649 | nonTouchableSurface->mInputInfo.touchOcclusionMode = TouchOcclusionMode::ALLOW; |
chaviw | 39cfa2e | 2020-11-04 14:19:02 -0800 | [diff] [blame] | 650 | nonTouchableSurface->showAt(100, 100); |
| 651 | |
| 652 | injectTap(190, 199); |
| 653 | surface->expectTapWithFlag(90, 99, AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED); |
| 654 | } |
| 655 | |
| 656 | TEST_F(InputSurfacesTest, touch_flag_partially_obscured_with_crop) { |
| 657 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 658 | surface->showAt(100, 100); |
| 659 | |
| 660 | // Add non touchable window to cover touchable window, but parent is cropped to not cover area |
| 661 | // that will be tapped. Window behind gets touch, but with flag |
| 662 | // AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED |
| 663 | std::unique_ptr<InputSurface> parentSurface = makeSurface(100, 100); |
| 664 | std::unique_ptr<InputSurface> nonTouchableSurface = makeSurface(100, 100); |
| 665 | nonTouchableSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE; |
| 666 | parentSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE; |
| 667 | nonTouchableSurface->mInputInfo.ownerUid = 22222; |
| 668 | parentSurface->mInputInfo.ownerUid = 22222; |
| 669 | nonTouchableSurface->showAt(0, 0); |
| 670 | parentSurface->showAt(100, 100); |
| 671 | |
| 672 | nonTouchableSurface->doTransaction([&](auto &t, auto &sc) { |
| 673 | t.setCrop_legacy(parentSurface->mSurfaceControl, Rect(0, 0, 50, 50)); |
| 674 | t.reparent(sc, parentSurface->mSurfaceControl); |
| 675 | }); |
| 676 | |
| 677 | injectTap(190, 199); |
| 678 | surface->expectTapWithFlag(90, 99, AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED); |
| 679 | } |
| 680 | |
| 681 | TEST_F(InputSurfacesTest, touch_not_obscured_with_crop) { |
| 682 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 683 | surface->showAt(100, 100); |
| 684 | |
| 685 | // Add non touchable window to cover touchable window, but parent is cropped to avoid covering |
| 686 | // the touchable window. Window behind gets touch with no obscured flags. |
| 687 | std::unique_ptr<InputSurface> parentSurface = makeSurface(100, 100); |
| 688 | std::unique_ptr<InputSurface> nonTouchableSurface = makeSurface(100, 100); |
| 689 | nonTouchableSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE; |
| 690 | parentSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE; |
| 691 | nonTouchableSurface->mInputInfo.ownerUid = 22222; |
| 692 | parentSurface->mInputInfo.ownerUid = 22222; |
| 693 | nonTouchableSurface->showAt(0, 0); |
| 694 | parentSurface->showAt(50, 50); |
| 695 | |
| 696 | nonTouchableSurface->doTransaction([&](auto &t, auto &sc) { |
| 697 | t.setCrop_legacy(parentSurface->mSurfaceControl, Rect(0, 0, 50, 50)); |
| 698 | t.reparent(sc, parentSurface->mSurfaceControl); |
| 699 | }); |
| 700 | |
| 701 | injectTap(101, 110); |
| 702 | surface->expectTap(1, 10); |
| 703 | } |
| 704 | |
chaviw | 7e72caf | 2020-12-02 16:50:43 -0800 | [diff] [blame] | 705 | TEST_F(InputSurfacesTest, touch_not_obscured_with_zero_sized_bql) { |
| 706 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 707 | |
| 708 | std::unique_ptr<InputSurface> bufferSurface = |
| 709 | InputSurface::makeBufferInputSurface(mComposerClient, 0, 0); |
| 710 | bufferSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE; |
| 711 | bufferSurface->mInputInfo.ownerUid = 22222; |
| 712 | |
| 713 | surface->showAt(10, 10); |
| 714 | bufferSurface->showAt(50, 50, Rect::EMPTY_RECT); |
| 715 | |
| 716 | injectTap(11, 11); |
| 717 | surface->expectTap(1, 1); |
| 718 | } |
| 719 | |
| 720 | TEST_F(InputSurfacesTest, touch_not_obscured_with_zero_sized_blast) { |
| 721 | std::unique_ptr<InputSurface> surface = makeSurface(100, 100); |
| 722 | |
| 723 | std::unique_ptr<InputSurface> bufferSurface = |
| 724 | InputSurface::makeBlastInputSurface(mComposerClient, 0, 0); |
| 725 | bufferSurface->mInputInfo.flags = InputWindowInfo::Flag::NOT_TOUCHABLE; |
| 726 | bufferSurface->mInputInfo.ownerUid = 22222; |
| 727 | |
| 728 | surface->showAt(10, 10); |
| 729 | bufferSurface->showAt(50, 50, Rect::EMPTY_RECT); |
| 730 | |
| 731 | injectTap(11, 11); |
| 732 | surface->expectTap(1, 1); |
| 733 | } |
| 734 | |
Vishnu Nair | 958da93 | 2020-08-21 17:12:37 -0700 | [diff] [blame] | 735 | } // namespace android::test |