blob: 79fb034ccc6266a09af977b63ed385c66092e7e2 [file] [log] [blame]
Lloyd Pique24b0a482018-03-09 18:52:26 -08001/*
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>
22
23#include <log/log.h>
24
25#include <utils/Errors.h>
26
27#include "AsyncCallRecorder.h"
Ana Krulecfefcb582018-08-07 14:22:37 -070028#include "Scheduler/EventThread.h"
Lloyd Pique24b0a482018-03-09 18:52:26 -080029
30using namespace std::chrono_literals;
31using namespace std::placeholders;
32
33using testing::_;
34using testing::Invoke;
35
36namespace android {
37namespace {
38
39class MockVSyncSource : public VSyncSource {
40public:
41 MOCK_METHOD1(setVSyncEnabled, void(bool));
42 MOCK_METHOD1(setCallback, void(VSyncSource::Callback*));
43 MOCK_METHOD1(setPhaseOffset, void(nsecs_t));
44};
45
46} // namespace
47
48class EventThreadTest : public testing::Test {
49protected:
Dominik Laskowskif654d572018-12-20 11:03:06 -080050 class MockEventThreadConnection : public EventThreadConnection {
Lloyd Pique24b0a482018-03-09 18:52:26 -080051 public:
Dominik Laskowskif654d572018-12-20 11:03:06 -080052 MockEventThreadConnection(android::impl::EventThread* eventThread,
53 ResyncCallback&& resyncCallback)
54 : EventThreadConnection(eventThread, std::move(resyncCallback)) {}
Lloyd Pique24b0a482018-03-09 18:52:26 -080055 MOCK_METHOD1(postEvent, status_t(const DisplayEventReceiver::Event& event));
56 };
57
58 using ConnectionEventRecorder =
59 AsyncCallRecorderWithCannedReturn<status_t (*)(const DisplayEventReceiver::Event&)>;
60
61 EventThreadTest();
62 ~EventThreadTest() override;
63
64 void createThread();
65 sp<MockEventThreadConnection> createConnection(ConnectionEventRecorder& recorder);
66
67 void expectVSyncSetEnabledCallReceived(bool expectedState);
68 void expectVSyncSetPhaseOffsetCallReceived(nsecs_t expectedPhaseOffset);
69 VSyncSource::Callback* expectVSyncSetCallbackCallReceived();
70 void expectInterceptCallReceived(nsecs_t expectedTimestamp);
71 void expectVsyncEventReceivedByConnection(const char* name,
72 ConnectionEventRecorder& connectionEventRecorder,
73 nsecs_t expectedTimestamp, unsigned expectedCount);
74 void expectVsyncEventReceivedByConnection(nsecs_t expectedTimestamp, unsigned expectedCount);
Dominik Laskowski00a6fa22018-06-06 16:42:02 -070075 void expectHotplugEventReceivedByConnection(EventThread::DisplayType expectedDisplayType,
76 bool expectedConnected);
Lloyd Pique24b0a482018-03-09 18:52:26 -080077
78 AsyncCallRecorder<void (*)(bool)> mVSyncSetEnabledCallRecorder;
79 AsyncCallRecorder<void (*)(VSyncSource::Callback*)> mVSyncSetCallbackCallRecorder;
80 AsyncCallRecorder<void (*)(nsecs_t)> mVSyncSetPhaseOffsetCallRecorder;
81 AsyncCallRecorder<void (*)()> mResyncCallRecorder;
82 AsyncCallRecorder<void (*)(nsecs_t)> mInterceptVSyncCallRecorder;
83 ConnectionEventRecorder mConnectionEventCallRecorder{0};
84
85 MockVSyncSource mVSyncSource;
Dominik Laskowski029cc122019-01-23 19:52:06 -080086 VSyncSource::Callback* mCallback = nullptr;
Lloyd Pique24b0a482018-03-09 18:52:26 -080087 std::unique_ptr<android::impl::EventThread> mThread;
88 sp<MockEventThreadConnection> mConnection;
89};
90
91EventThreadTest::EventThreadTest() {
92 const ::testing::TestInfo* const test_info =
93 ::testing::UnitTest::GetInstance()->current_test_info();
94 ALOGD("**** Setting up for %s.%s\n", test_info->test_case_name(), test_info->name());
95
96 EXPECT_CALL(mVSyncSource, setVSyncEnabled(_))
97 .WillRepeatedly(Invoke(mVSyncSetEnabledCallRecorder.getInvocable()));
98
99 EXPECT_CALL(mVSyncSource, setCallback(_))
100 .WillRepeatedly(Invoke(mVSyncSetCallbackCallRecorder.getInvocable()));
101
102 EXPECT_CALL(mVSyncSource, setPhaseOffset(_))
103 .WillRepeatedly(Invoke(mVSyncSetPhaseOffsetCallRecorder.getInvocable()));
104
105 createThread();
106 mConnection = createConnection(mConnectionEventCallRecorder);
Dominik Laskowski1eba0202019-01-24 09:14:40 -0800107
108 // A display must be connected for VSYNC events to be delivered.
109 mThread->onHotplugReceived(EventThread::DisplayType::Primary, true);
110 expectHotplugEventReceivedByConnection(EventThread::DisplayType::Primary, true);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800111}
112
113EventThreadTest::~EventThreadTest() {
114 const ::testing::TestInfo* const test_info =
115 ::testing::UnitTest::GetInstance()->current_test_info();
116 ALOGD("**** Tearing down after %s.%s\n", test_info->test_case_name(), test_info->name());
Dominik Laskowski029cc122019-01-23 19:52:06 -0800117
118 // EventThread should unregister itself as VSyncSource callback.
119 EXPECT_FALSE(expectVSyncSetCallbackCallReceived());
Lloyd Pique24b0a482018-03-09 18:52:26 -0800120}
121
122void EventThreadTest::createThread() {
123 mThread =
124 std::make_unique<android::impl::EventThread>(&mVSyncSource,
Lloyd Pique24b0a482018-03-09 18:52:26 -0800125 mInterceptVSyncCallRecorder.getInvocable(),
126 "unit-test-event-thread");
Dominik Laskowski029cc122019-01-23 19:52:06 -0800127
128 // EventThread should register itself as VSyncSource callback.
129 mCallback = expectVSyncSetCallbackCallReceived();
130 ASSERT_TRUE(mCallback);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800131}
132
133sp<EventThreadTest::MockEventThreadConnection> EventThreadTest::createConnection(
134 ConnectionEventRecorder& recorder) {
Dominik Laskowskif654d572018-12-20 11:03:06 -0800135 sp<MockEventThreadConnection> connection =
136 new MockEventThreadConnection(mThread.get(), mResyncCallRecorder.getInvocable());
Lloyd Pique24b0a482018-03-09 18:52:26 -0800137 EXPECT_CALL(*connection, postEvent(_)).WillRepeatedly(Invoke(recorder.getInvocable()));
138 return connection;
139}
140
141void EventThreadTest::expectVSyncSetEnabledCallReceived(bool expectedState) {
142 auto args = mVSyncSetEnabledCallRecorder.waitForCall();
143 ASSERT_TRUE(args.has_value());
144 EXPECT_EQ(expectedState, std::get<0>(args.value()));
145}
146
147void EventThreadTest::expectVSyncSetPhaseOffsetCallReceived(nsecs_t expectedPhaseOffset) {
148 auto args = mVSyncSetPhaseOffsetCallRecorder.waitForCall();
149 ASSERT_TRUE(args.has_value());
150 EXPECT_EQ(expectedPhaseOffset, std::get<0>(args.value()));
151}
152
153VSyncSource::Callback* EventThreadTest::expectVSyncSetCallbackCallReceived() {
154 auto callbackSet = mVSyncSetCallbackCallRecorder.waitForCall();
155 return callbackSet.has_value() ? std::get<0>(callbackSet.value()) : nullptr;
156}
157
158void EventThreadTest::expectInterceptCallReceived(nsecs_t expectedTimestamp) {
159 auto args = mInterceptVSyncCallRecorder.waitForCall();
160 ASSERT_TRUE(args.has_value());
161 EXPECT_EQ(expectedTimestamp, std::get<0>(args.value()));
162}
163
164void EventThreadTest::expectVsyncEventReceivedByConnection(
165 const char* name, ConnectionEventRecorder& connectionEventRecorder,
166 nsecs_t expectedTimestamp, unsigned expectedCount) {
167 auto args = connectionEventRecorder.waitForCall();
168 ASSERT_TRUE(args.has_value()) << name << " did not receive an event for timestamp "
169 << expectedTimestamp;
170 const auto& event = std::get<0>(args.value());
171 EXPECT_EQ(DisplayEventReceiver::DISPLAY_EVENT_VSYNC, event.header.type)
172 << name << " did not get the correct event for timestamp " << expectedTimestamp;
173 EXPECT_EQ(expectedTimestamp, event.header.timestamp)
174 << name << " did not get the expected timestamp for timestamp " << expectedTimestamp;
175 EXPECT_EQ(expectedCount, event.vsync.count)
176 << name << " did not get the expected count for timestamp " << expectedTimestamp;
177}
178
179void EventThreadTest::expectVsyncEventReceivedByConnection(nsecs_t expectedTimestamp,
180 unsigned expectedCount) {
181 expectVsyncEventReceivedByConnection("mConnectionEventCallRecorder",
182 mConnectionEventCallRecorder, expectedTimestamp,
183 expectedCount);
184}
185
Dominik Laskowski00a6fa22018-06-06 16:42:02 -0700186void EventThreadTest::expectHotplugEventReceivedByConnection(
187 EventThread::DisplayType expectedDisplayType, bool expectedConnected) {
188 const uint32_t expectedDisplayId =
189 expectedDisplayType == EventThread::DisplayType::Primary ? 0 : 1;
190
Lloyd Pique24b0a482018-03-09 18:52:26 -0800191 auto args = mConnectionEventCallRecorder.waitForCall();
192 ASSERT_TRUE(args.has_value());
193 const auto& event = std::get<0>(args.value());
194 EXPECT_EQ(DisplayEventReceiver::DISPLAY_EVENT_HOTPLUG, event.header.type);
Dominik Laskowski00a6fa22018-06-06 16:42:02 -0700195 EXPECT_EQ(expectedDisplayId, event.header.id);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800196 EXPECT_EQ(expectedConnected, event.hotplug.connected);
197}
198
199namespace {
200
201/* ------------------------------------------------------------------------
202 * Test cases
203 */
204
205TEST_F(EventThreadTest, canCreateAndDestroyThreadWithNoEventsSent) {
206 EXPECT_FALSE(mVSyncSetEnabledCallRecorder.waitForUnexpectedCall().has_value());
207 EXPECT_FALSE(mVSyncSetCallbackCallRecorder.waitForCall(0us).has_value());
208 EXPECT_FALSE(mVSyncSetPhaseOffsetCallRecorder.waitForCall(0us).has_value());
209 EXPECT_FALSE(mResyncCallRecorder.waitForCall(0us).has_value());
210 EXPECT_FALSE(mInterceptVSyncCallRecorder.waitForCall(0us).has_value());
211 EXPECT_FALSE(mConnectionEventCallRecorder.waitForCall(0us).has_value());
212}
213
Dominik Laskowski1eba0202019-01-24 09:14:40 -0800214TEST_F(EventThreadTest, vsyncRequestIsIgnoredIfDisplayIsDisconnected) {
215 mThread->onHotplugReceived(EventThread::DisplayType::Primary, false);
216 expectHotplugEventReceivedByConnection(EventThread::DisplayType::Primary, false);
217
218 // Signal that we want the next vsync event to be posted to the connection.
219 mThread->requestNextVsync(mConnection, false);
220
221 // EventThread should not enable vsync callbacks.
222 EXPECT_FALSE(mVSyncSetEnabledCallRecorder.waitForUnexpectedCall().has_value());
223
224 // Use the received callback to signal a vsync event.
225 // The event should not be received by the interceptor nor the connection.
226 mCallback->onVSyncEvent(123);
227 EXPECT_FALSE(mInterceptVSyncCallRecorder.waitForCall(0us).has_value());
228 EXPECT_FALSE(mConnectionEventCallRecorder.waitForCall(0us).has_value());
229}
230
Lloyd Pique24b0a482018-03-09 18:52:26 -0800231TEST_F(EventThreadTest, requestNextVsyncPostsASingleVSyncEventToTheConnection) {
232 // Signal that we want the next vsync event to be posted to the connection
Ana Krulec7d1d6832018-12-27 11:10:09 -0800233 mThread->requestNextVsync(mConnection, false);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800234
235 // EventThread should immediately request a resync.
236 EXPECT_TRUE(mResyncCallRecorder.waitForCall().has_value());
237
Dominik Laskowski029cc122019-01-23 19:52:06 -0800238 // EventThread should enable vsync callbacks.
Lloyd Pique24b0a482018-03-09 18:52:26 -0800239 expectVSyncSetEnabledCallReceived(true);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800240
241 // Use the received callback to signal a first vsync event.
242 // The interceptor should receive the event, as well as the connection.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800243 mCallback->onVSyncEvent(123);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800244 expectInterceptCallReceived(123);
245 expectVsyncEventReceivedByConnection(123, 1u);
246
247 // Use the received callback to signal a second vsync event.
248 // The interceptor should receive the event, but the the connection should
249 // not as it was only interested in the first.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800250 mCallback->onVSyncEvent(456);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800251 expectInterceptCallReceived(456);
252 EXPECT_FALSE(mConnectionEventCallRecorder.waitForUnexpectedCall().has_value());
253
254 // EventThread should also detect that at this point that it does not need
255 // any more vsync events, and should disable their generation.
256 expectVSyncSetEnabledCallReceived(false);
257}
258
259TEST_F(EventThreadTest, setVsyncRateZeroPostsNoVSyncEventsToThatConnection) {
260 // Create a first connection, register it, and request a vsync rate of zero.
261 ConnectionEventRecorder firstConnectionEventRecorder{0};
262 sp<MockEventThreadConnection> firstConnection = createConnection(firstConnectionEventRecorder);
263 mThread->setVsyncRate(0, firstConnection);
264
265 // By itself, this should not enable vsync events
266 EXPECT_FALSE(mVSyncSetEnabledCallRecorder.waitForUnexpectedCall().has_value());
267 EXPECT_FALSE(mVSyncSetCallbackCallRecorder.waitForCall(0us).has_value());
268
269 // However if there is another connection which wants events at a nonzero rate.....
270 ConnectionEventRecorder secondConnectionEventRecorder{0};
271 sp<MockEventThreadConnection> secondConnection =
272 createConnection(secondConnectionEventRecorder);
273 mThread->setVsyncRate(1, secondConnection);
274
Dominik Laskowski029cc122019-01-23 19:52:06 -0800275 // EventThread should enable vsync callbacks.
Lloyd Pique24b0a482018-03-09 18:52:26 -0800276 expectVSyncSetEnabledCallReceived(true);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800277
278 // Send a vsync event. EventThread should then make a call to the
279 // interceptor, and the second connection. The first connection should not
280 // get the event.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800281 mCallback->onVSyncEvent(123);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800282 expectInterceptCallReceived(123);
283 EXPECT_FALSE(firstConnectionEventRecorder.waitForUnexpectedCall().has_value());
284 expectVsyncEventReceivedByConnection("secondConnection", secondConnectionEventRecorder, 123,
285 1u);
286}
287
288TEST_F(EventThreadTest, setVsyncRateOnePostsAllEventsToThatConnection) {
289 mThread->setVsyncRate(1, mConnection);
290
Dominik Laskowski029cc122019-01-23 19:52:06 -0800291 // EventThread should enable vsync callbacks.
Lloyd Pique24b0a482018-03-09 18:52:26 -0800292 expectVSyncSetEnabledCallReceived(true);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800293
294 // Send a vsync event. EventThread should then make a call to the
295 // interceptor, and the connection.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800296 mCallback->onVSyncEvent(123);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800297 expectInterceptCallReceived(123);
298 expectVsyncEventReceivedByConnection(123, 1u);
299
300 // A second event should go to the same places.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800301 mCallback->onVSyncEvent(456);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800302 expectInterceptCallReceived(456);
303 expectVsyncEventReceivedByConnection(456, 2u);
304
305 // A third event should go to the same places.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800306 mCallback->onVSyncEvent(789);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800307 expectInterceptCallReceived(789);
308 expectVsyncEventReceivedByConnection(789, 3u);
309}
310
311TEST_F(EventThreadTest, setVsyncRateTwoPostsEveryOtherEventToThatConnection) {
312 mThread->setVsyncRate(2, mConnection);
313
Dominik Laskowski029cc122019-01-23 19:52:06 -0800314 // EventThread should enable vsync callbacks.
Lloyd Pique24b0a482018-03-09 18:52:26 -0800315 expectVSyncSetEnabledCallReceived(true);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800316
317 // The first event will be seen by the interceptor, and not the connection.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800318 mCallback->onVSyncEvent(123);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800319 expectInterceptCallReceived(123);
320 EXPECT_FALSE(mConnectionEventCallRecorder.waitForUnexpectedCall().has_value());
321
322 // The second event will be seen by the interceptor and the connection.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800323 mCallback->onVSyncEvent(456);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800324 expectInterceptCallReceived(456);
325 expectVsyncEventReceivedByConnection(456, 2u);
326
327 // The third event will be seen by the interceptor, and not the connection.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800328 mCallback->onVSyncEvent(789);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800329 expectInterceptCallReceived(789);
330 EXPECT_FALSE(mConnectionEventCallRecorder.waitForUnexpectedCall().has_value());
331
332 // The fourth event will be seen by the interceptor and the connection.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800333 mCallback->onVSyncEvent(101112);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800334 expectInterceptCallReceived(101112);
335 expectVsyncEventReceivedByConnection(101112, 4u);
336}
337
338TEST_F(EventThreadTest, connectionsRemovedIfInstanceDestroyed) {
339 mThread->setVsyncRate(1, mConnection);
340
Dominik Laskowski029cc122019-01-23 19:52:06 -0800341 // EventThread should enable vsync callbacks.
Lloyd Pique24b0a482018-03-09 18:52:26 -0800342 expectVSyncSetEnabledCallReceived(true);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800343
344 // Destroy the only (strong) reference to the connection.
345 mConnection = nullptr;
346
347 // The first event will be seen by the interceptor, and not the connection.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800348 mCallback->onVSyncEvent(123);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800349 expectInterceptCallReceived(123);
350 EXPECT_FALSE(mConnectionEventCallRecorder.waitForUnexpectedCall().has_value());
351
352 // EventThread should disable vsync callbacks
353 expectVSyncSetEnabledCallReceived(false);
354}
355
356TEST_F(EventThreadTest, connectionsRemovedIfEventDeliveryError) {
357 ConnectionEventRecorder errorConnectionEventRecorder{NO_MEMORY};
358 sp<MockEventThreadConnection> errorConnection = createConnection(errorConnectionEventRecorder);
359 mThread->setVsyncRate(1, errorConnection);
360
Dominik Laskowski029cc122019-01-23 19:52:06 -0800361 // EventThread should enable vsync callbacks.
Lloyd Pique24b0a482018-03-09 18:52:26 -0800362 expectVSyncSetEnabledCallReceived(true);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800363
364 // The first event will be seen by the interceptor, and by the connection,
365 // which then returns an error.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800366 mCallback->onVSyncEvent(123);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800367 expectInterceptCallReceived(123);
368 expectVsyncEventReceivedByConnection("errorConnection", errorConnectionEventRecorder, 123, 1u);
369
370 // A subsequent event will be seen by the interceptor and not by the
371 // connection.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800372 mCallback->onVSyncEvent(456);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800373 expectInterceptCallReceived(456);
374 EXPECT_FALSE(errorConnectionEventRecorder.waitForUnexpectedCall().has_value());
375
376 // EventThread should disable vsync callbacks with the second event
377 expectVSyncSetEnabledCallReceived(false);
378}
379
380TEST_F(EventThreadTest, eventsDroppedIfNonfatalEventDeliveryError) {
381 ConnectionEventRecorder errorConnectionEventRecorder{WOULD_BLOCK};
382 sp<MockEventThreadConnection> errorConnection = createConnection(errorConnectionEventRecorder);
383 mThread->setVsyncRate(1, errorConnection);
384
Dominik Laskowski029cc122019-01-23 19:52:06 -0800385 // EventThread should enable vsync callbacks.
Lloyd Pique24b0a482018-03-09 18:52:26 -0800386 expectVSyncSetEnabledCallReceived(true);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800387
388 // The first event will be seen by the interceptor, and by the connection,
389 // which then returns an non-fatal error.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800390 mCallback->onVSyncEvent(123);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800391 expectInterceptCallReceived(123);
392 expectVsyncEventReceivedByConnection("errorConnection", errorConnectionEventRecorder, 123, 1u);
393
394 // A subsequent event will be seen by the interceptor, and by the connection,
395 // which still then returns an non-fatal error.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800396 mCallback->onVSyncEvent(456);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800397 expectInterceptCallReceived(456);
398 expectVsyncEventReceivedByConnection("errorConnection", errorConnectionEventRecorder, 456, 2u);
399
400 // EventThread will not disable vsync callbacks as the errors are non-fatal.
401 EXPECT_FALSE(mVSyncSetEnabledCallRecorder.waitForUnexpectedCall().has_value());
402}
403
404TEST_F(EventThreadTest, setPhaseOffsetForwardsToVSyncSource) {
405 mThread->setPhaseOffset(321);
406 expectVSyncSetPhaseOffsetCallReceived(321);
407}
408
409TEST_F(EventThreadTest, postHotplugPrimaryDisconnect) {
Dominik Laskowski00a6fa22018-06-06 16:42:02 -0700410 mThread->onHotplugReceived(EventThread::DisplayType::Primary, false);
411 expectHotplugEventReceivedByConnection(EventThread::DisplayType::Primary, false);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800412}
413
414TEST_F(EventThreadTest, postHotplugPrimaryConnect) {
Dominik Laskowski00a6fa22018-06-06 16:42:02 -0700415 mThread->onHotplugReceived(EventThread::DisplayType::Primary, true);
416 expectHotplugEventReceivedByConnection(EventThread::DisplayType::Primary, true);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800417}
418
419TEST_F(EventThreadTest, postHotplugExternalDisconnect) {
Dominik Laskowski00a6fa22018-06-06 16:42:02 -0700420 mThread->onHotplugReceived(EventThread::DisplayType::External, false);
421 expectHotplugEventReceivedByConnection(EventThread::DisplayType::External, false);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800422}
423
424TEST_F(EventThreadTest, postHotplugExternalConnect) {
Dominik Laskowski00a6fa22018-06-06 16:42:02 -0700425 mThread->onHotplugReceived(EventThread::DisplayType::External, true);
426 expectHotplugEventReceivedByConnection(EventThread::DisplayType::External, true);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800427}
428
429} // namespace
430} // namespace android