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