| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 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 | #undef LOG_TAG | 
|  | 18 | #define LOG_TAG "LibSurfaceFlingerUnittests" | 
|  | 19 |  | 
|  | 20 | #include <gmock/gmock.h> | 
|  | 21 | #include <gtest/gtest.h> | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 22 | #include <log/log.h> | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 23 | #include <utils/Errors.h> | 
|  | 24 |  | 
|  | 25 | #include "AsyncCallRecorder.h" | 
| Ana Krulec | fefcb58 | 2018-08-07 14:22:37 -0700 | [diff] [blame] | 26 | #include "Scheduler/EventThread.h" | 
| Ady Abraham | 2139f73 | 2019-11-13 18:56:40 -0800 | [diff] [blame] | 27 | #include "Scheduler/HwcStrongTypes.h" | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 28 |  | 
|  | 29 | using namespace std::chrono_literals; | 
|  | 30 | using namespace std::placeholders; | 
|  | 31 |  | 
|  | 32 | using testing::_; | 
|  | 33 | using testing::Invoke; | 
|  | 34 |  | 
|  | 35 | namespace android { | 
| Ady Abraham | 2139f73 | 2019-11-13 18:56:40 -0800 | [diff] [blame] | 36 |  | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 37 | namespace { | 
|  | 38 |  | 
| Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 39 | constexpr PhysicalDisplayId INTERNAL_DISPLAY_ID = 111; | 
|  | 40 | constexpr PhysicalDisplayId EXTERNAL_DISPLAY_ID = 222; | 
| Ady Abraham | af0ec27 | 2019-03-28 11:38:31 -0700 | [diff] [blame] | 41 | constexpr PhysicalDisplayId DISPLAY_ID_64BIT = 0xabcd12349876fedcULL; | 
| Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 42 |  | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 43 | class MockVSyncSource : public VSyncSource { | 
|  | 44 | public: | 
| Dominik Laskowski | 6505f79 | 2019-09-18 11:10:05 -0700 | [diff] [blame] | 45 | const char* getName() const override { return "test"; } | 
|  | 46 |  | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 47 | MOCK_METHOD1(setVSyncEnabled, void(bool)); | 
|  | 48 | MOCK_METHOD1(setCallback, void(VSyncSource::Callback*)); | 
|  | 49 | MOCK_METHOD1(setPhaseOffset, void(nsecs_t)); | 
| Ady Abraham | b838aed | 2019-02-12 15:30:16 -0800 | [diff] [blame] | 50 | MOCK_METHOD1(pauseVsyncCallback, void(bool)); | 
| Ady Abraham | 5e7371c | 2020-03-24 14:47:24 -0700 | [diff] [blame] | 51 | MOCK_CONST_METHOD1(dump, void(std::string&)); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 52 | }; | 
|  | 53 |  | 
|  | 54 | } // namespace | 
|  | 55 |  | 
|  | 56 | class EventThreadTest : public testing::Test { | 
|  | 57 | protected: | 
| Dominik Laskowski | f654d57 | 2018-12-20 11:03:06 -0800 | [diff] [blame] | 58 | class MockEventThreadConnection : public EventThreadConnection { | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 59 | public: | 
| Dominik Laskowski | 6505f79 | 2019-09-18 11:10:05 -0700 | [diff] [blame] | 60 | MockEventThreadConnection(impl::EventThread* eventThread, ResyncCallback&& resyncCallback, | 
| Ady Abraham | 0f4a1b1 | 2019-06-04 16:04:04 -0700 | [diff] [blame] | 61 | ISurfaceComposer::ConfigChanged configChanged) | 
|  | 62 | : EventThreadConnection(eventThread, std::move(resyncCallback), configChanged) {} | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 63 | MOCK_METHOD1(postEvent, status_t(const DisplayEventReceiver::Event& event)); | 
|  | 64 | }; | 
|  | 65 |  | 
|  | 66 | using ConnectionEventRecorder = | 
|  | 67 | AsyncCallRecorderWithCannedReturn<status_t (*)(const DisplayEventReceiver::Event&)>; | 
|  | 68 |  | 
|  | 69 | EventThreadTest(); | 
|  | 70 | ~EventThreadTest() override; | 
|  | 71 |  | 
| Dominik Laskowski | 6505f79 | 2019-09-18 11:10:05 -0700 | [diff] [blame] | 72 | void createThread(std::unique_ptr<VSyncSource>); | 
| Ady Abraham | 0f4a1b1 | 2019-06-04 16:04:04 -0700 | [diff] [blame] | 73 | sp<MockEventThreadConnection> createConnection(ConnectionEventRecorder& recorder, | 
|  | 74 | ISurfaceComposer::ConfigChanged configChanged); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 75 |  | 
|  | 76 | void expectVSyncSetEnabledCallReceived(bool expectedState); | 
|  | 77 | void expectVSyncSetPhaseOffsetCallReceived(nsecs_t expectedPhaseOffset); | 
|  | 78 | VSyncSource::Callback* expectVSyncSetCallbackCallReceived(); | 
|  | 79 | void expectInterceptCallReceived(nsecs_t expectedTimestamp); | 
|  | 80 | void expectVsyncEventReceivedByConnection(const char* name, | 
|  | 81 | ConnectionEventRecorder& connectionEventRecorder, | 
|  | 82 | nsecs_t expectedTimestamp, unsigned expectedCount); | 
|  | 83 | void expectVsyncEventReceivedByConnection(nsecs_t expectedTimestamp, unsigned expectedCount); | 
| Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 84 | void expectHotplugEventReceivedByConnection(PhysicalDisplayId expectedDisplayId, | 
| Dominik Laskowski | 00a6fa2 | 2018-06-06 16:42:02 -0700 | [diff] [blame] | 85 | bool expectedConnected); | 
| Ady Abraham | 447052e | 2019-02-13 16:07:27 -0800 | [diff] [blame] | 86 | void expectConfigChangedEventReceivedByConnection(PhysicalDisplayId expectedDisplayId, | 
| Alec Mouri | 60aee1c | 2019-10-28 16:18:59 -0700 | [diff] [blame] | 87 | int32_t expectedConfigId, | 
|  | 88 | nsecs_t expectedVsyncPeriod); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 89 |  | 
|  | 90 | AsyncCallRecorder<void (*)(bool)> mVSyncSetEnabledCallRecorder; | 
|  | 91 | AsyncCallRecorder<void (*)(VSyncSource::Callback*)> mVSyncSetCallbackCallRecorder; | 
|  | 92 | AsyncCallRecorder<void (*)(nsecs_t)> mVSyncSetPhaseOffsetCallRecorder; | 
|  | 93 | AsyncCallRecorder<void (*)()> mResyncCallRecorder; | 
|  | 94 | AsyncCallRecorder<void (*)(nsecs_t)> mInterceptVSyncCallRecorder; | 
|  | 95 | ConnectionEventRecorder mConnectionEventCallRecorder{0}; | 
|  | 96 |  | 
| Dominik Laskowski | 6505f79 | 2019-09-18 11:10:05 -0700 | [diff] [blame] | 97 | MockVSyncSource* mVSyncSource; | 
| Dominik Laskowski | 029cc12 | 2019-01-23 19:52:06 -0800 | [diff] [blame] | 98 | VSyncSource::Callback* mCallback = nullptr; | 
| Dominik Laskowski | 6505f79 | 2019-09-18 11:10:05 -0700 | [diff] [blame] | 99 | std::unique_ptr<impl::EventThread> mThread; | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 100 | sp<MockEventThreadConnection> mConnection; | 
|  | 101 | }; | 
|  | 102 |  | 
|  | 103 | EventThreadTest::EventThreadTest() { | 
|  | 104 | const ::testing::TestInfo* const test_info = | 
|  | 105 | ::testing::UnitTest::GetInstance()->current_test_info(); | 
|  | 106 | ALOGD("**** Setting up for %s.%s\n", test_info->test_case_name(), test_info->name()); | 
|  | 107 |  | 
| Dominik Laskowski | 6505f79 | 2019-09-18 11:10:05 -0700 | [diff] [blame] | 108 | auto vsyncSource = std::make_unique<MockVSyncSource>(); | 
|  | 109 | mVSyncSource = vsyncSource.get(); | 
|  | 110 |  | 
|  | 111 | EXPECT_CALL(*mVSyncSource, setVSyncEnabled(_)) | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 112 | .WillRepeatedly(Invoke(mVSyncSetEnabledCallRecorder.getInvocable())); | 
|  | 113 |  | 
| Dominik Laskowski | 6505f79 | 2019-09-18 11:10:05 -0700 | [diff] [blame] | 114 | EXPECT_CALL(*mVSyncSource, setCallback(_)) | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 115 | .WillRepeatedly(Invoke(mVSyncSetCallbackCallRecorder.getInvocable())); | 
|  | 116 |  | 
| Dominik Laskowski | 6505f79 | 2019-09-18 11:10:05 -0700 | [diff] [blame] | 117 | EXPECT_CALL(*mVSyncSource, setPhaseOffset(_)) | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 118 | .WillRepeatedly(Invoke(mVSyncSetPhaseOffsetCallRecorder.getInvocable())); | 
|  | 119 |  | 
| Dominik Laskowski | 6505f79 | 2019-09-18 11:10:05 -0700 | [diff] [blame] | 120 | createThread(std::move(vsyncSource)); | 
| Ady Abraham | 0f4a1b1 | 2019-06-04 16:04:04 -0700 | [diff] [blame] | 121 | mConnection = createConnection(mConnectionEventCallRecorder, | 
|  | 122 | ISurfaceComposer::eConfigChangedDispatch); | 
| Dominik Laskowski | 1eba020 | 2019-01-24 09:14:40 -0800 | [diff] [blame] | 123 |  | 
|  | 124 | // A display must be connected for VSYNC events to be delivered. | 
| Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 125 | mThread->onHotplugReceived(INTERNAL_DISPLAY_ID, true); | 
|  | 126 | expectHotplugEventReceivedByConnection(INTERNAL_DISPLAY_ID, true); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 127 | } | 
|  | 128 |  | 
|  | 129 | EventThreadTest::~EventThreadTest() { | 
|  | 130 | const ::testing::TestInfo* const test_info = | 
|  | 131 | ::testing::UnitTest::GetInstance()->current_test_info(); | 
|  | 132 | ALOGD("**** Tearing down after %s.%s\n", test_info->test_case_name(), test_info->name()); | 
| Dominik Laskowski | 029cc12 | 2019-01-23 19:52:06 -0800 | [diff] [blame] | 133 |  | 
|  | 134 | // EventThread should unregister itself as VSyncSource callback. | 
| Lloyd Pique | 0655b8e | 2019-01-31 18:20:27 -0800 | [diff] [blame] | 135 | EXPECT_TRUE(!mVSyncSetCallbackCallRecorder.waitForUnexpectedCall().has_value()); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 136 | } | 
|  | 137 |  | 
| Dominik Laskowski | 6505f79 | 2019-09-18 11:10:05 -0700 | [diff] [blame] | 138 | void EventThreadTest::createThread(std::unique_ptr<VSyncSource> source) { | 
|  | 139 | mThread = std::make_unique<impl::EventThread>(std::move(source), | 
|  | 140 | mInterceptVSyncCallRecorder.getInvocable()); | 
| Dominik Laskowski | 029cc12 | 2019-01-23 19:52:06 -0800 | [diff] [blame] | 141 |  | 
|  | 142 | // EventThread should register itself as VSyncSource callback. | 
|  | 143 | mCallback = expectVSyncSetCallbackCallReceived(); | 
|  | 144 | ASSERT_TRUE(mCallback); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 145 | } | 
|  | 146 |  | 
|  | 147 | sp<EventThreadTest::MockEventThreadConnection> EventThreadTest::createConnection( | 
| Ady Abraham | 0f4a1b1 | 2019-06-04 16:04:04 -0700 | [diff] [blame] | 148 | ConnectionEventRecorder& recorder, ISurfaceComposer::ConfigChanged configChanged) { | 
| Dominik Laskowski | f654d57 | 2018-12-20 11:03:06 -0800 | [diff] [blame] | 149 | sp<MockEventThreadConnection> connection = | 
| Ady Abraham | 0f4a1b1 | 2019-06-04 16:04:04 -0700 | [diff] [blame] | 150 | new MockEventThreadConnection(mThread.get(), mResyncCallRecorder.getInvocable(), | 
|  | 151 | configChanged); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 152 | EXPECT_CALL(*connection, postEvent(_)).WillRepeatedly(Invoke(recorder.getInvocable())); | 
|  | 153 | return connection; | 
|  | 154 | } | 
|  | 155 |  | 
|  | 156 | void EventThreadTest::expectVSyncSetEnabledCallReceived(bool expectedState) { | 
|  | 157 | auto args = mVSyncSetEnabledCallRecorder.waitForCall(); | 
|  | 158 | ASSERT_TRUE(args.has_value()); | 
|  | 159 | EXPECT_EQ(expectedState, std::get<0>(args.value())); | 
|  | 160 | } | 
|  | 161 |  | 
|  | 162 | void EventThreadTest::expectVSyncSetPhaseOffsetCallReceived(nsecs_t expectedPhaseOffset) { | 
|  | 163 | auto args = mVSyncSetPhaseOffsetCallRecorder.waitForCall(); | 
|  | 164 | ASSERT_TRUE(args.has_value()); | 
|  | 165 | EXPECT_EQ(expectedPhaseOffset, std::get<0>(args.value())); | 
|  | 166 | } | 
|  | 167 |  | 
|  | 168 | VSyncSource::Callback* EventThreadTest::expectVSyncSetCallbackCallReceived() { | 
|  | 169 | auto callbackSet = mVSyncSetCallbackCallRecorder.waitForCall(); | 
|  | 170 | return callbackSet.has_value() ? std::get<0>(callbackSet.value()) : nullptr; | 
|  | 171 | } | 
|  | 172 |  | 
|  | 173 | void EventThreadTest::expectInterceptCallReceived(nsecs_t expectedTimestamp) { | 
|  | 174 | auto args = mInterceptVSyncCallRecorder.waitForCall(); | 
|  | 175 | ASSERT_TRUE(args.has_value()); | 
|  | 176 | EXPECT_EQ(expectedTimestamp, std::get<0>(args.value())); | 
|  | 177 | } | 
|  | 178 |  | 
|  | 179 | void EventThreadTest::expectVsyncEventReceivedByConnection( | 
|  | 180 | const char* name, ConnectionEventRecorder& connectionEventRecorder, | 
|  | 181 | nsecs_t expectedTimestamp, unsigned expectedCount) { | 
|  | 182 | auto args = connectionEventRecorder.waitForCall(); | 
|  | 183 | ASSERT_TRUE(args.has_value()) << name << " did not receive an event for timestamp " | 
|  | 184 | << expectedTimestamp; | 
|  | 185 | const auto& event = std::get<0>(args.value()); | 
|  | 186 | EXPECT_EQ(DisplayEventReceiver::DISPLAY_EVENT_VSYNC, event.header.type) | 
|  | 187 | << name << " did not get the correct event for timestamp " << expectedTimestamp; | 
|  | 188 | EXPECT_EQ(expectedTimestamp, event.header.timestamp) | 
|  | 189 | << name << " did not get the expected timestamp for timestamp " << expectedTimestamp; | 
|  | 190 | EXPECT_EQ(expectedCount, event.vsync.count) | 
|  | 191 | << name << " did not get the expected count for timestamp " << expectedTimestamp; | 
|  | 192 | } | 
|  | 193 |  | 
|  | 194 | void EventThreadTest::expectVsyncEventReceivedByConnection(nsecs_t expectedTimestamp, | 
|  | 195 | unsigned expectedCount) { | 
|  | 196 | expectVsyncEventReceivedByConnection("mConnectionEventCallRecorder", | 
|  | 197 | mConnectionEventCallRecorder, expectedTimestamp, | 
|  | 198 | expectedCount); | 
|  | 199 | } | 
|  | 200 |  | 
| Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 201 | void EventThreadTest::expectHotplugEventReceivedByConnection(PhysicalDisplayId expectedDisplayId, | 
|  | 202 | bool expectedConnected) { | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 203 | auto args = mConnectionEventCallRecorder.waitForCall(); | 
|  | 204 | ASSERT_TRUE(args.has_value()); | 
|  | 205 | const auto& event = std::get<0>(args.value()); | 
|  | 206 | EXPECT_EQ(DisplayEventReceiver::DISPLAY_EVENT_HOTPLUG, event.header.type); | 
| Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 207 | EXPECT_EQ(expectedDisplayId, event.header.displayId); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 208 | EXPECT_EQ(expectedConnected, event.hotplug.connected); | 
|  | 209 | } | 
|  | 210 |  | 
| Ady Abraham | 447052e | 2019-02-13 16:07:27 -0800 | [diff] [blame] | 211 | void EventThreadTest::expectConfigChangedEventReceivedByConnection( | 
| Alec Mouri | 60aee1c | 2019-10-28 16:18:59 -0700 | [diff] [blame] | 212 | PhysicalDisplayId expectedDisplayId, int32_t expectedConfigId, | 
|  | 213 | nsecs_t expectedVsyncPeriod) { | 
| Ady Abraham | 447052e | 2019-02-13 16:07:27 -0800 | [diff] [blame] | 214 | auto args = mConnectionEventCallRecorder.waitForCall(); | 
|  | 215 | ASSERT_TRUE(args.has_value()); | 
|  | 216 | const auto& event = std::get<0>(args.value()); | 
|  | 217 | EXPECT_EQ(DisplayEventReceiver::DISPLAY_EVENT_CONFIG_CHANGED, event.header.type); | 
|  | 218 | EXPECT_EQ(expectedDisplayId, event.header.displayId); | 
|  | 219 | EXPECT_EQ(expectedConfigId, event.config.configId); | 
| Alec Mouri | 60aee1c | 2019-10-28 16:18:59 -0700 | [diff] [blame] | 220 | EXPECT_EQ(expectedVsyncPeriod, event.config.vsyncPeriod); | 
| Ady Abraham | 447052e | 2019-02-13 16:07:27 -0800 | [diff] [blame] | 221 | } | 
|  | 222 |  | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 223 | namespace { | 
|  | 224 |  | 
|  | 225 | /* ------------------------------------------------------------------------ | 
|  | 226 | * Test cases | 
|  | 227 | */ | 
|  | 228 |  | 
|  | 229 | TEST_F(EventThreadTest, canCreateAndDestroyThreadWithNoEventsSent) { | 
|  | 230 | EXPECT_FALSE(mVSyncSetEnabledCallRecorder.waitForUnexpectedCall().has_value()); | 
|  | 231 | EXPECT_FALSE(mVSyncSetCallbackCallRecorder.waitForCall(0us).has_value()); | 
|  | 232 | EXPECT_FALSE(mVSyncSetPhaseOffsetCallRecorder.waitForCall(0us).has_value()); | 
|  | 233 | EXPECT_FALSE(mResyncCallRecorder.waitForCall(0us).has_value()); | 
|  | 234 | EXPECT_FALSE(mInterceptVSyncCallRecorder.waitForCall(0us).has_value()); | 
|  | 235 | EXPECT_FALSE(mConnectionEventCallRecorder.waitForCall(0us).has_value()); | 
|  | 236 | } | 
|  | 237 |  | 
| Dominik Laskowski | 1eba020 | 2019-01-24 09:14:40 -0800 | [diff] [blame] | 238 | TEST_F(EventThreadTest, vsyncRequestIsIgnoredIfDisplayIsDisconnected) { | 
| Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 239 | mThread->onHotplugReceived(INTERNAL_DISPLAY_ID, false); | 
|  | 240 | expectHotplugEventReceivedByConnection(INTERNAL_DISPLAY_ID, false); | 
| Dominik Laskowski | 1eba020 | 2019-01-24 09:14:40 -0800 | [diff] [blame] | 241 |  | 
|  | 242 | // Signal that we want the next vsync event to be posted to the connection. | 
| Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 243 | mThread->requestNextVsync(mConnection); | 
| Dominik Laskowski | 1eba020 | 2019-01-24 09:14:40 -0800 | [diff] [blame] | 244 |  | 
|  | 245 | // EventThread should not enable vsync callbacks. | 
|  | 246 | EXPECT_FALSE(mVSyncSetEnabledCallRecorder.waitForUnexpectedCall().has_value()); | 
| Dominik Laskowski | 1eba020 | 2019-01-24 09:14:40 -0800 | [diff] [blame] | 247 | } | 
|  | 248 |  | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 249 | TEST_F(EventThreadTest, requestNextVsyncPostsASingleVSyncEventToTheConnection) { | 
|  | 250 | // Signal that we want the next vsync event to be posted to the connection | 
| Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 251 | mThread->requestNextVsync(mConnection); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 252 |  | 
| Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 253 | // EventThread should immediately request a resync. | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 254 | EXPECT_TRUE(mResyncCallRecorder.waitForCall().has_value()); | 
|  | 255 |  | 
| Dominik Laskowski | 029cc12 | 2019-01-23 19:52:06 -0800 | [diff] [blame] | 256 | // EventThread should enable vsync callbacks. | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 257 | expectVSyncSetEnabledCallReceived(true); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 258 |  | 
|  | 259 | // Use the received callback to signal a first vsync event. | 
|  | 260 | // The interceptor should receive the event, as well as the connection. | 
| Ady Abraham | 5facfb1 | 2020-04-22 15:18:31 -0700 | [diff] [blame] | 261 | mCallback->onVSyncEvent(123, 456); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 262 | expectInterceptCallReceived(123); | 
|  | 263 | expectVsyncEventReceivedByConnection(123, 1u); | 
|  | 264 |  | 
|  | 265 | // Use the received callback to signal a second vsync event. | 
|  | 266 | // The interceptor should receive the event, but the the connection should | 
|  | 267 | // not as it was only interested in the first. | 
| Ady Abraham | 5facfb1 | 2020-04-22 15:18:31 -0700 | [diff] [blame] | 268 | mCallback->onVSyncEvent(456, 123); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 269 | expectInterceptCallReceived(456); | 
|  | 270 | EXPECT_FALSE(mConnectionEventCallRecorder.waitForUnexpectedCall().has_value()); | 
|  | 271 |  | 
|  | 272 | // EventThread should also detect that at this point that it does not need | 
|  | 273 | // any more vsync events, and should disable their generation. | 
|  | 274 | expectVSyncSetEnabledCallReceived(false); | 
|  | 275 | } | 
|  | 276 |  | 
|  | 277 | TEST_F(EventThreadTest, setVsyncRateZeroPostsNoVSyncEventsToThatConnection) { | 
|  | 278 | // Create a first connection, register it, and request a vsync rate of zero. | 
|  | 279 | ConnectionEventRecorder firstConnectionEventRecorder{0}; | 
| Ady Abraham | 0f4a1b1 | 2019-06-04 16:04:04 -0700 | [diff] [blame] | 280 | sp<MockEventThreadConnection> firstConnection = | 
|  | 281 | createConnection(firstConnectionEventRecorder, | 
|  | 282 | ISurfaceComposer::eConfigChangedSuppress); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 283 | mThread->setVsyncRate(0, firstConnection); | 
|  | 284 |  | 
|  | 285 | // By itself, this should not enable vsync events | 
|  | 286 | EXPECT_FALSE(mVSyncSetEnabledCallRecorder.waitForUnexpectedCall().has_value()); | 
|  | 287 | EXPECT_FALSE(mVSyncSetCallbackCallRecorder.waitForCall(0us).has_value()); | 
|  | 288 |  | 
|  | 289 | // However if there is another connection which wants events at a nonzero rate..... | 
|  | 290 | ConnectionEventRecorder secondConnectionEventRecorder{0}; | 
|  | 291 | sp<MockEventThreadConnection> secondConnection = | 
| Ady Abraham | 0f4a1b1 | 2019-06-04 16:04:04 -0700 | [diff] [blame] | 292 | createConnection(secondConnectionEventRecorder, | 
|  | 293 | ISurfaceComposer::eConfigChangedSuppress); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 294 | mThread->setVsyncRate(1, secondConnection); | 
|  | 295 |  | 
| Dominik Laskowski | 029cc12 | 2019-01-23 19:52:06 -0800 | [diff] [blame] | 296 | // EventThread should enable vsync callbacks. | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 297 | expectVSyncSetEnabledCallReceived(true); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 298 |  | 
|  | 299 | // Send a vsync event. EventThread should then make a call to the | 
|  | 300 | // interceptor, and the second connection. The first connection should not | 
|  | 301 | // get the event. | 
| Ady Abraham | 5facfb1 | 2020-04-22 15:18:31 -0700 | [diff] [blame] | 302 | mCallback->onVSyncEvent(123, 456); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 303 | expectInterceptCallReceived(123); | 
|  | 304 | EXPECT_FALSE(firstConnectionEventRecorder.waitForUnexpectedCall().has_value()); | 
|  | 305 | expectVsyncEventReceivedByConnection("secondConnection", secondConnectionEventRecorder, 123, | 
|  | 306 | 1u); | 
|  | 307 | } | 
|  | 308 |  | 
|  | 309 | TEST_F(EventThreadTest, setVsyncRateOnePostsAllEventsToThatConnection) { | 
|  | 310 | mThread->setVsyncRate(1, mConnection); | 
|  | 311 |  | 
| Dominik Laskowski | 029cc12 | 2019-01-23 19:52:06 -0800 | [diff] [blame] | 312 | // EventThread should enable vsync callbacks. | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 313 | expectVSyncSetEnabledCallReceived(true); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 314 |  | 
|  | 315 | // Send a vsync event. EventThread should then make a call to the | 
|  | 316 | // interceptor, and the connection. | 
| Ady Abraham | 5facfb1 | 2020-04-22 15:18:31 -0700 | [diff] [blame] | 317 | mCallback->onVSyncEvent(123, 456); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 318 | expectInterceptCallReceived(123); | 
|  | 319 | expectVsyncEventReceivedByConnection(123, 1u); | 
|  | 320 |  | 
|  | 321 | // A second event should go to the same places. | 
| Ady Abraham | 5facfb1 | 2020-04-22 15:18:31 -0700 | [diff] [blame] | 322 | mCallback->onVSyncEvent(456, 123); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 323 | expectInterceptCallReceived(456); | 
|  | 324 | expectVsyncEventReceivedByConnection(456, 2u); | 
|  | 325 |  | 
|  | 326 | // A third event should go to the same places. | 
| Ady Abraham | 5facfb1 | 2020-04-22 15:18:31 -0700 | [diff] [blame] | 327 | mCallback->onVSyncEvent(789, 777); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 328 | expectInterceptCallReceived(789); | 
|  | 329 | expectVsyncEventReceivedByConnection(789, 3u); | 
|  | 330 | } | 
|  | 331 |  | 
|  | 332 | TEST_F(EventThreadTest, setVsyncRateTwoPostsEveryOtherEventToThatConnection) { | 
|  | 333 | mThread->setVsyncRate(2, mConnection); | 
|  | 334 |  | 
| Dominik Laskowski | 029cc12 | 2019-01-23 19:52:06 -0800 | [diff] [blame] | 335 | // EventThread should enable vsync callbacks. | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 336 | expectVSyncSetEnabledCallReceived(true); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 337 |  | 
|  | 338 | // The first event will be seen by the interceptor, and not the connection. | 
| Ady Abraham | 5facfb1 | 2020-04-22 15:18:31 -0700 | [diff] [blame] | 339 | mCallback->onVSyncEvent(123, 456); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 340 | expectInterceptCallReceived(123); | 
|  | 341 | EXPECT_FALSE(mConnectionEventCallRecorder.waitForUnexpectedCall().has_value()); | 
|  | 342 |  | 
|  | 343 | // The second event will be seen by the interceptor and the connection. | 
| Ady Abraham | 5facfb1 | 2020-04-22 15:18:31 -0700 | [diff] [blame] | 344 | mCallback->onVSyncEvent(456, 123); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 345 | expectInterceptCallReceived(456); | 
|  | 346 | expectVsyncEventReceivedByConnection(456, 2u); | 
|  | 347 |  | 
|  | 348 | // The third event will be seen by the interceptor, and not the connection. | 
| Ady Abraham | 5facfb1 | 2020-04-22 15:18:31 -0700 | [diff] [blame] | 349 | mCallback->onVSyncEvent(789, 777); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 350 | expectInterceptCallReceived(789); | 
|  | 351 | EXPECT_FALSE(mConnectionEventCallRecorder.waitForUnexpectedCall().has_value()); | 
|  | 352 |  | 
|  | 353 | // The fourth event will be seen by the interceptor and the connection. | 
| Ady Abraham | 5facfb1 | 2020-04-22 15:18:31 -0700 | [diff] [blame] | 354 | mCallback->onVSyncEvent(101112, 7847); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 355 | expectInterceptCallReceived(101112); | 
|  | 356 | expectVsyncEventReceivedByConnection(101112, 4u); | 
|  | 357 | } | 
|  | 358 |  | 
|  | 359 | TEST_F(EventThreadTest, connectionsRemovedIfInstanceDestroyed) { | 
|  | 360 | mThread->setVsyncRate(1, mConnection); | 
|  | 361 |  | 
| Dominik Laskowski | 029cc12 | 2019-01-23 19:52:06 -0800 | [diff] [blame] | 362 | // EventThread should enable vsync callbacks. | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 363 | expectVSyncSetEnabledCallReceived(true); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 364 |  | 
|  | 365 | // Destroy the only (strong) reference to the connection. | 
|  | 366 | mConnection = nullptr; | 
|  | 367 |  | 
|  | 368 | // The first event will be seen by the interceptor, and not the connection. | 
| Ady Abraham | 5facfb1 | 2020-04-22 15:18:31 -0700 | [diff] [blame] | 369 | mCallback->onVSyncEvent(123, 456); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 370 | expectInterceptCallReceived(123); | 
|  | 371 | EXPECT_FALSE(mConnectionEventCallRecorder.waitForUnexpectedCall().has_value()); | 
|  | 372 |  | 
|  | 373 | // EventThread should disable vsync callbacks | 
|  | 374 | expectVSyncSetEnabledCallReceived(false); | 
|  | 375 | } | 
|  | 376 |  | 
|  | 377 | TEST_F(EventThreadTest, connectionsRemovedIfEventDeliveryError) { | 
|  | 378 | ConnectionEventRecorder errorConnectionEventRecorder{NO_MEMORY}; | 
| Ady Abraham | 0f4a1b1 | 2019-06-04 16:04:04 -0700 | [diff] [blame] | 379 | sp<MockEventThreadConnection> errorConnection = | 
|  | 380 | createConnection(errorConnectionEventRecorder, | 
|  | 381 | ISurfaceComposer::eConfigChangedSuppress); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 382 | mThread->setVsyncRate(1, errorConnection); | 
|  | 383 |  | 
| Dominik Laskowski | 029cc12 | 2019-01-23 19:52:06 -0800 | [diff] [blame] | 384 | // EventThread should enable vsync callbacks. | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 385 | expectVSyncSetEnabledCallReceived(true); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 386 |  | 
|  | 387 | // The first event will be seen by the interceptor, and by the connection, | 
|  | 388 | // which then returns an error. | 
| Ady Abraham | 5facfb1 | 2020-04-22 15:18:31 -0700 | [diff] [blame] | 389 | mCallback->onVSyncEvent(123, 456); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 390 | expectInterceptCallReceived(123); | 
|  | 391 | expectVsyncEventReceivedByConnection("errorConnection", errorConnectionEventRecorder, 123, 1u); | 
|  | 392 |  | 
|  | 393 | // A subsequent event will be seen by the interceptor and not by the | 
|  | 394 | // connection. | 
| Ady Abraham | 5facfb1 | 2020-04-22 15:18:31 -0700 | [diff] [blame] | 395 | mCallback->onVSyncEvent(456, 123); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 396 | expectInterceptCallReceived(456); | 
|  | 397 | EXPECT_FALSE(errorConnectionEventRecorder.waitForUnexpectedCall().has_value()); | 
|  | 398 |  | 
|  | 399 | // EventThread should disable vsync callbacks with the second event | 
|  | 400 | expectVSyncSetEnabledCallReceived(false); | 
|  | 401 | } | 
|  | 402 |  | 
| Alec Mouri | 717bcb6 | 2020-02-10 17:07:19 -0800 | [diff] [blame] | 403 | TEST_F(EventThreadTest, tracksEventConnections) { | 
|  | 404 | EXPECT_EQ(1, mThread->getEventThreadConnectionCount()); | 
|  | 405 | ConnectionEventRecorder errorConnectionEventRecorder{NO_MEMORY}; | 
|  | 406 | sp<MockEventThreadConnection> errorConnection = | 
|  | 407 | createConnection(errorConnectionEventRecorder, | 
|  | 408 | ISurfaceComposer::eConfigChangedSuppress); | 
|  | 409 | mThread->setVsyncRate(1, errorConnection); | 
|  | 410 | EXPECT_EQ(2, mThread->getEventThreadConnectionCount()); | 
|  | 411 | ConnectionEventRecorder secondConnectionEventRecorder{0}; | 
|  | 412 | sp<MockEventThreadConnection> secondConnection = | 
|  | 413 | createConnection(secondConnectionEventRecorder, | 
|  | 414 | ISurfaceComposer::eConfigChangedSuppress); | 
|  | 415 | mThread->setVsyncRate(1, secondConnection); | 
|  | 416 | EXPECT_EQ(3, mThread->getEventThreadConnectionCount()); | 
|  | 417 |  | 
|  | 418 | // EventThread should enable vsync callbacks. | 
|  | 419 | expectVSyncSetEnabledCallReceived(true); | 
|  | 420 |  | 
|  | 421 | // The first event will be seen by the interceptor, and by the connection, | 
|  | 422 | // which then returns an error. | 
| Ady Abraham | 5facfb1 | 2020-04-22 15:18:31 -0700 | [diff] [blame] | 423 | mCallback->onVSyncEvent(123, 456); | 
| Alec Mouri | 717bcb6 | 2020-02-10 17:07:19 -0800 | [diff] [blame] | 424 | expectInterceptCallReceived(123); | 
|  | 425 | expectVsyncEventReceivedByConnection("errorConnection", errorConnectionEventRecorder, 123, 1u); | 
|  | 426 | expectVsyncEventReceivedByConnection("successConnection", secondConnectionEventRecorder, 123, | 
|  | 427 | 1u); | 
|  | 428 | EXPECT_EQ(2, mThread->getEventThreadConnectionCount()); | 
|  | 429 | } | 
|  | 430 |  | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 431 | TEST_F(EventThreadTest, eventsDroppedIfNonfatalEventDeliveryError) { | 
|  | 432 | ConnectionEventRecorder errorConnectionEventRecorder{WOULD_BLOCK}; | 
| Ady Abraham | 0f4a1b1 | 2019-06-04 16:04:04 -0700 | [diff] [blame] | 433 | sp<MockEventThreadConnection> errorConnection = | 
|  | 434 | createConnection(errorConnectionEventRecorder, | 
|  | 435 | ISurfaceComposer::eConfigChangedSuppress); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 436 | mThread->setVsyncRate(1, errorConnection); | 
|  | 437 |  | 
| Dominik Laskowski | 029cc12 | 2019-01-23 19:52:06 -0800 | [diff] [blame] | 438 | // EventThread should enable vsync callbacks. | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 439 | expectVSyncSetEnabledCallReceived(true); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 440 |  | 
|  | 441 | // The first event will be seen by the interceptor, and by the connection, | 
|  | 442 | // which then returns an non-fatal error. | 
| Ady Abraham | 5facfb1 | 2020-04-22 15:18:31 -0700 | [diff] [blame] | 443 | mCallback->onVSyncEvent(123, 456); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 444 | expectInterceptCallReceived(123); | 
|  | 445 | expectVsyncEventReceivedByConnection("errorConnection", errorConnectionEventRecorder, 123, 1u); | 
|  | 446 |  | 
|  | 447 | // A subsequent event will be seen by the interceptor, and by the connection, | 
|  | 448 | // which still then returns an non-fatal error. | 
| Ady Abraham | 5facfb1 | 2020-04-22 15:18:31 -0700 | [diff] [blame] | 449 | mCallback->onVSyncEvent(456, 123); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 450 | expectInterceptCallReceived(456); | 
|  | 451 | expectVsyncEventReceivedByConnection("errorConnection", errorConnectionEventRecorder, 456, 2u); | 
|  | 452 |  | 
|  | 453 | // EventThread will not disable vsync callbacks as the errors are non-fatal. | 
|  | 454 | EXPECT_FALSE(mVSyncSetEnabledCallRecorder.waitForUnexpectedCall().has_value()); | 
|  | 455 | } | 
|  | 456 |  | 
|  | 457 | TEST_F(EventThreadTest, setPhaseOffsetForwardsToVSyncSource) { | 
|  | 458 | mThread->setPhaseOffset(321); | 
|  | 459 | expectVSyncSetPhaseOffsetCallReceived(321); | 
|  | 460 | } | 
|  | 461 |  | 
| Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 462 | TEST_F(EventThreadTest, postHotplugInternalDisconnect) { | 
|  | 463 | mThread->onHotplugReceived(INTERNAL_DISPLAY_ID, false); | 
|  | 464 | expectHotplugEventReceivedByConnection(INTERNAL_DISPLAY_ID, false); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 465 | } | 
|  | 466 |  | 
| Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 467 | TEST_F(EventThreadTest, postHotplugInternalConnect) { | 
|  | 468 | mThread->onHotplugReceived(INTERNAL_DISPLAY_ID, true); | 
|  | 469 | expectHotplugEventReceivedByConnection(INTERNAL_DISPLAY_ID, true); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 470 | } | 
|  | 471 |  | 
|  | 472 | TEST_F(EventThreadTest, postHotplugExternalDisconnect) { | 
| Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 473 | mThread->onHotplugReceived(EXTERNAL_DISPLAY_ID, false); | 
|  | 474 | expectHotplugEventReceivedByConnection(EXTERNAL_DISPLAY_ID, false); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 475 | } | 
|  | 476 |  | 
|  | 477 | TEST_F(EventThreadTest, postHotplugExternalConnect) { | 
| Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 478 | mThread->onHotplugReceived(EXTERNAL_DISPLAY_ID, true); | 
|  | 479 | expectHotplugEventReceivedByConnection(EXTERNAL_DISPLAY_ID, true); | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 480 | } | 
|  | 481 |  | 
| Ady Abraham | 447052e | 2019-02-13 16:07:27 -0800 | [diff] [blame] | 482 | TEST_F(EventThreadTest, postConfigChangedPrimary) { | 
| Alec Mouri | 60aee1c | 2019-10-28 16:18:59 -0700 | [diff] [blame] | 483 | mThread->onConfigChanged(INTERNAL_DISPLAY_ID, HwcConfigIndexType(7), 16666666); | 
|  | 484 | expectConfigChangedEventReceivedByConnection(INTERNAL_DISPLAY_ID, 7, 16666666); | 
| Ady Abraham | 447052e | 2019-02-13 16:07:27 -0800 | [diff] [blame] | 485 | } | 
|  | 486 |  | 
|  | 487 | TEST_F(EventThreadTest, postConfigChangedExternal) { | 
| Alec Mouri | 60aee1c | 2019-10-28 16:18:59 -0700 | [diff] [blame] | 488 | mThread->onConfigChanged(EXTERNAL_DISPLAY_ID, HwcConfigIndexType(5), 16666666); | 
|  | 489 | expectConfigChangedEventReceivedByConnection(EXTERNAL_DISPLAY_ID, 5, 16666666); | 
| Ady Abraham | 447052e | 2019-02-13 16:07:27 -0800 | [diff] [blame] | 490 | } | 
|  | 491 |  | 
| Ady Abraham | af0ec27 | 2019-03-28 11:38:31 -0700 | [diff] [blame] | 492 | TEST_F(EventThreadTest, postConfigChangedPrimary64bit) { | 
| Alec Mouri | 60aee1c | 2019-10-28 16:18:59 -0700 | [diff] [blame] | 493 | mThread->onConfigChanged(DISPLAY_ID_64BIT, HwcConfigIndexType(7), 16666666); | 
|  | 494 | expectConfigChangedEventReceivedByConnection(DISPLAY_ID_64BIT, 7, 16666666); | 
| Ady Abraham | af0ec27 | 2019-03-28 11:38:31 -0700 | [diff] [blame] | 495 | } | 
|  | 496 |  | 
| Ady Abraham | 0f4a1b1 | 2019-06-04 16:04:04 -0700 | [diff] [blame] | 497 | TEST_F(EventThreadTest, suppressConfigChanged) { | 
|  | 498 | ConnectionEventRecorder suppressConnectionEventRecorder{0}; | 
|  | 499 | sp<MockEventThreadConnection> suppressConnection = | 
|  | 500 | createConnection(suppressConnectionEventRecorder, | 
|  | 501 | ISurfaceComposer::eConfigChangedSuppress); | 
|  | 502 |  | 
| Alec Mouri | 60aee1c | 2019-10-28 16:18:59 -0700 | [diff] [blame] | 503 | mThread->onConfigChanged(INTERNAL_DISPLAY_ID, HwcConfigIndexType(9), 16666666); | 
|  | 504 | expectConfigChangedEventReceivedByConnection(INTERNAL_DISPLAY_ID, 9, 16666666); | 
| Ady Abraham | 0f4a1b1 | 2019-06-04 16:04:04 -0700 | [diff] [blame] | 505 |  | 
|  | 506 | auto args = suppressConnectionEventRecorder.waitForCall(); | 
|  | 507 | ASSERT_FALSE(args.has_value()); | 
|  | 508 | } | 
|  | 509 |  | 
| Lloyd Pique | 24b0a48 | 2018-03-09 18:52:26 -0800 | [diff] [blame] | 510 | } // namespace | 
|  | 511 | } // namespace android |