blob: ad7dcb42178f749be52b3cf1eee34b3422bea031 [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
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -080039constexpr PhysicalDisplayId INTERNAL_DISPLAY_ID = 111;
40constexpr PhysicalDisplayId EXTERNAL_DISPLAY_ID = 222;
41
Lloyd Pique24b0a482018-03-09 18:52:26 -080042class MockVSyncSource : public VSyncSource {
43public:
44 MOCK_METHOD1(setVSyncEnabled, void(bool));
45 MOCK_METHOD1(setCallback, void(VSyncSource::Callback*));
46 MOCK_METHOD1(setPhaseOffset, void(nsecs_t));
47};
48
49} // namespace
50
51class EventThreadTest : public testing::Test {
52protected:
Dominik Laskowskif654d572018-12-20 11:03:06 -080053 class MockEventThreadConnection : public EventThreadConnection {
Lloyd Pique24b0a482018-03-09 18:52:26 -080054 public:
Dominik Laskowskif654d572018-12-20 11:03:06 -080055 MockEventThreadConnection(android::impl::EventThread* eventThread,
56 ResyncCallback&& resyncCallback)
57 : EventThreadConnection(eventThread, std::move(resyncCallback)) {}
Lloyd Pique24b0a482018-03-09 18:52:26 -080058 MOCK_METHOD1(postEvent, status_t(const DisplayEventReceiver::Event& event));
59 };
60
61 using ConnectionEventRecorder =
62 AsyncCallRecorderWithCannedReturn<status_t (*)(const DisplayEventReceiver::Event&)>;
63
64 EventThreadTest();
65 ~EventThreadTest() override;
66
67 void createThread();
68 sp<MockEventThreadConnection> createConnection(ConnectionEventRecorder& recorder);
69
70 void expectVSyncSetEnabledCallReceived(bool expectedState);
71 void expectVSyncSetPhaseOffsetCallReceived(nsecs_t expectedPhaseOffset);
72 VSyncSource::Callback* expectVSyncSetCallbackCallReceived();
73 void expectInterceptCallReceived(nsecs_t expectedTimestamp);
74 void expectVsyncEventReceivedByConnection(const char* name,
75 ConnectionEventRecorder& connectionEventRecorder,
76 nsecs_t expectedTimestamp, unsigned expectedCount);
77 void expectVsyncEventReceivedByConnection(nsecs_t expectedTimestamp, unsigned expectedCount);
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -080078 void expectHotplugEventReceivedByConnection(PhysicalDisplayId expectedDisplayId,
Dominik Laskowski00a6fa22018-06-06 16:42:02 -070079 bool expectedConnected);
Lloyd Pique24b0a482018-03-09 18:52:26 -080080
81 AsyncCallRecorder<void (*)(bool)> mVSyncSetEnabledCallRecorder;
82 AsyncCallRecorder<void (*)(VSyncSource::Callback*)> mVSyncSetCallbackCallRecorder;
83 AsyncCallRecorder<void (*)(nsecs_t)> mVSyncSetPhaseOffsetCallRecorder;
84 AsyncCallRecorder<void (*)()> mResyncCallRecorder;
85 AsyncCallRecorder<void (*)(nsecs_t)> mInterceptVSyncCallRecorder;
86 ConnectionEventRecorder mConnectionEventCallRecorder{0};
87
88 MockVSyncSource mVSyncSource;
Dominik Laskowski029cc122019-01-23 19:52:06 -080089 VSyncSource::Callback* mCallback = nullptr;
Lloyd Pique24b0a482018-03-09 18:52:26 -080090 std::unique_ptr<android::impl::EventThread> mThread;
91 sp<MockEventThreadConnection> mConnection;
92};
93
94EventThreadTest::EventThreadTest() {
95 const ::testing::TestInfo* const test_info =
96 ::testing::UnitTest::GetInstance()->current_test_info();
97 ALOGD("**** Setting up for %s.%s\n", test_info->test_case_name(), test_info->name());
98
99 EXPECT_CALL(mVSyncSource, setVSyncEnabled(_))
100 .WillRepeatedly(Invoke(mVSyncSetEnabledCallRecorder.getInvocable()));
101
102 EXPECT_CALL(mVSyncSource, setCallback(_))
103 .WillRepeatedly(Invoke(mVSyncSetCallbackCallRecorder.getInvocable()));
104
105 EXPECT_CALL(mVSyncSource, setPhaseOffset(_))
106 .WillRepeatedly(Invoke(mVSyncSetPhaseOffsetCallRecorder.getInvocable()));
107
108 createThread();
109 mConnection = createConnection(mConnectionEventCallRecorder);
Dominik Laskowski1eba0202019-01-24 09:14:40 -0800110
111 // A display must be connected for VSYNC events to be delivered.
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800112 mThread->onHotplugReceived(INTERNAL_DISPLAY_ID, true);
113 expectHotplugEventReceivedByConnection(INTERNAL_DISPLAY_ID, true);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800114}
115
116EventThreadTest::~EventThreadTest() {
117 const ::testing::TestInfo* const test_info =
118 ::testing::UnitTest::GetInstance()->current_test_info();
119 ALOGD("**** Tearing down after %s.%s\n", test_info->test_case_name(), test_info->name());
Dominik Laskowski029cc122019-01-23 19:52:06 -0800120
121 // EventThread should unregister itself as VSyncSource callback.
122 EXPECT_FALSE(expectVSyncSetCallbackCallReceived());
Lloyd Pique24b0a482018-03-09 18:52:26 -0800123}
124
125void EventThreadTest::createThread() {
126 mThread =
127 std::make_unique<android::impl::EventThread>(&mVSyncSource,
Lloyd Pique24b0a482018-03-09 18:52:26 -0800128 mInterceptVSyncCallRecorder.getInvocable(),
129 "unit-test-event-thread");
Dominik Laskowski029cc122019-01-23 19:52:06 -0800130
131 // EventThread should register itself as VSyncSource callback.
132 mCallback = expectVSyncSetCallbackCallReceived();
133 ASSERT_TRUE(mCallback);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800134}
135
136sp<EventThreadTest::MockEventThreadConnection> EventThreadTest::createConnection(
137 ConnectionEventRecorder& recorder) {
Dominik Laskowskif654d572018-12-20 11:03:06 -0800138 sp<MockEventThreadConnection> connection =
139 new MockEventThreadConnection(mThread.get(), mResyncCallRecorder.getInvocable());
Lloyd Pique24b0a482018-03-09 18:52:26 -0800140 EXPECT_CALL(*connection, postEvent(_)).WillRepeatedly(Invoke(recorder.getInvocable()));
141 return connection;
142}
143
144void EventThreadTest::expectVSyncSetEnabledCallReceived(bool expectedState) {
145 auto args = mVSyncSetEnabledCallRecorder.waitForCall();
146 ASSERT_TRUE(args.has_value());
147 EXPECT_EQ(expectedState, std::get<0>(args.value()));
148}
149
150void EventThreadTest::expectVSyncSetPhaseOffsetCallReceived(nsecs_t expectedPhaseOffset) {
151 auto args = mVSyncSetPhaseOffsetCallRecorder.waitForCall();
152 ASSERT_TRUE(args.has_value());
153 EXPECT_EQ(expectedPhaseOffset, std::get<0>(args.value()));
154}
155
156VSyncSource::Callback* EventThreadTest::expectVSyncSetCallbackCallReceived() {
157 auto callbackSet = mVSyncSetCallbackCallRecorder.waitForCall();
158 return callbackSet.has_value() ? std::get<0>(callbackSet.value()) : nullptr;
159}
160
161void EventThreadTest::expectInterceptCallReceived(nsecs_t expectedTimestamp) {
162 auto args = mInterceptVSyncCallRecorder.waitForCall();
163 ASSERT_TRUE(args.has_value());
164 EXPECT_EQ(expectedTimestamp, std::get<0>(args.value()));
165}
166
167void EventThreadTest::expectVsyncEventReceivedByConnection(
168 const char* name, ConnectionEventRecorder& connectionEventRecorder,
169 nsecs_t expectedTimestamp, unsigned expectedCount) {
170 auto args = connectionEventRecorder.waitForCall();
171 ASSERT_TRUE(args.has_value()) << name << " did not receive an event for timestamp "
172 << expectedTimestamp;
173 const auto& event = std::get<0>(args.value());
174 EXPECT_EQ(DisplayEventReceiver::DISPLAY_EVENT_VSYNC, event.header.type)
175 << name << " did not get the correct event for timestamp " << expectedTimestamp;
176 EXPECT_EQ(expectedTimestamp, event.header.timestamp)
177 << name << " did not get the expected timestamp for timestamp " << expectedTimestamp;
178 EXPECT_EQ(expectedCount, event.vsync.count)
179 << name << " did not get the expected count for timestamp " << expectedTimestamp;
180}
181
182void EventThreadTest::expectVsyncEventReceivedByConnection(nsecs_t expectedTimestamp,
183 unsigned expectedCount) {
184 expectVsyncEventReceivedByConnection("mConnectionEventCallRecorder",
185 mConnectionEventCallRecorder, expectedTimestamp,
186 expectedCount);
187}
188
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800189void EventThreadTest::expectHotplugEventReceivedByConnection(PhysicalDisplayId expectedDisplayId,
190 bool expectedConnected) {
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 Laskowskidcb38bb2019-01-25 02:35:50 -0800195 EXPECT_EQ(expectedDisplayId, event.header.displayId);
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) {
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800215 mThread->onHotplugReceived(INTERNAL_DISPLAY_ID, false);
216 expectHotplugEventReceivedByConnection(INTERNAL_DISPLAY_ID, false);
Dominik Laskowski1eba0202019-01-24 09:14:40 -0800217
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());
Dominik Laskowski1eba0202019-01-24 09:14:40 -0800223}
224
Lloyd Pique24b0a482018-03-09 18:52:26 -0800225TEST_F(EventThreadTest, requestNextVsyncPostsASingleVSyncEventToTheConnection) {
226 // Signal that we want the next vsync event to be posted to the connection
Ana Krulec7d1d6832018-12-27 11:10:09 -0800227 mThread->requestNextVsync(mConnection, false);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800228
229 // EventThread should immediately request a resync.
230 EXPECT_TRUE(mResyncCallRecorder.waitForCall().has_value());
231
Dominik Laskowski029cc122019-01-23 19:52:06 -0800232 // EventThread should enable vsync callbacks.
Lloyd Pique24b0a482018-03-09 18:52:26 -0800233 expectVSyncSetEnabledCallReceived(true);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800234
235 // Use the received callback to signal a first vsync event.
236 // The interceptor should receive the event, as well as the connection.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800237 mCallback->onVSyncEvent(123);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800238 expectInterceptCallReceived(123);
239 expectVsyncEventReceivedByConnection(123, 1u);
240
241 // Use the received callback to signal a second vsync event.
242 // The interceptor should receive the event, but the the connection should
243 // not as it was only interested in the first.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800244 mCallback->onVSyncEvent(456);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800245 expectInterceptCallReceived(456);
246 EXPECT_FALSE(mConnectionEventCallRecorder.waitForUnexpectedCall().has_value());
247
248 // EventThread should also detect that at this point that it does not need
249 // any more vsync events, and should disable their generation.
250 expectVSyncSetEnabledCallReceived(false);
251}
252
253TEST_F(EventThreadTest, setVsyncRateZeroPostsNoVSyncEventsToThatConnection) {
254 // Create a first connection, register it, and request a vsync rate of zero.
255 ConnectionEventRecorder firstConnectionEventRecorder{0};
256 sp<MockEventThreadConnection> firstConnection = createConnection(firstConnectionEventRecorder);
257 mThread->setVsyncRate(0, firstConnection);
258
259 // By itself, this should not enable vsync events
260 EXPECT_FALSE(mVSyncSetEnabledCallRecorder.waitForUnexpectedCall().has_value());
261 EXPECT_FALSE(mVSyncSetCallbackCallRecorder.waitForCall(0us).has_value());
262
263 // However if there is another connection which wants events at a nonzero rate.....
264 ConnectionEventRecorder secondConnectionEventRecorder{0};
265 sp<MockEventThreadConnection> secondConnection =
266 createConnection(secondConnectionEventRecorder);
267 mThread->setVsyncRate(1, secondConnection);
268
Dominik Laskowski029cc122019-01-23 19:52:06 -0800269 // EventThread should enable vsync callbacks.
Lloyd Pique24b0a482018-03-09 18:52:26 -0800270 expectVSyncSetEnabledCallReceived(true);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800271
272 // Send a vsync event. EventThread should then make a call to the
273 // interceptor, and the second connection. The first connection should not
274 // get the event.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800275 mCallback->onVSyncEvent(123);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800276 expectInterceptCallReceived(123);
277 EXPECT_FALSE(firstConnectionEventRecorder.waitForUnexpectedCall().has_value());
278 expectVsyncEventReceivedByConnection("secondConnection", secondConnectionEventRecorder, 123,
279 1u);
280}
281
282TEST_F(EventThreadTest, setVsyncRateOnePostsAllEventsToThatConnection) {
283 mThread->setVsyncRate(1, mConnection);
284
Dominik Laskowski029cc122019-01-23 19:52:06 -0800285 // EventThread should enable vsync callbacks.
Lloyd Pique24b0a482018-03-09 18:52:26 -0800286 expectVSyncSetEnabledCallReceived(true);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800287
288 // Send a vsync event. EventThread should then make a call to the
289 // interceptor, and the connection.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800290 mCallback->onVSyncEvent(123);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800291 expectInterceptCallReceived(123);
292 expectVsyncEventReceivedByConnection(123, 1u);
293
294 // A second event should go to the same places.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800295 mCallback->onVSyncEvent(456);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800296 expectInterceptCallReceived(456);
297 expectVsyncEventReceivedByConnection(456, 2u);
298
299 // A third event should go to the same places.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800300 mCallback->onVSyncEvent(789);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800301 expectInterceptCallReceived(789);
302 expectVsyncEventReceivedByConnection(789, 3u);
303}
304
305TEST_F(EventThreadTest, setVsyncRateTwoPostsEveryOtherEventToThatConnection) {
306 mThread->setVsyncRate(2, mConnection);
307
Dominik Laskowski029cc122019-01-23 19:52:06 -0800308 // EventThread should enable vsync callbacks.
Lloyd Pique24b0a482018-03-09 18:52:26 -0800309 expectVSyncSetEnabledCallReceived(true);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800310
311 // The first event will be seen by the interceptor, and not the connection.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800312 mCallback->onVSyncEvent(123);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800313 expectInterceptCallReceived(123);
314 EXPECT_FALSE(mConnectionEventCallRecorder.waitForUnexpectedCall().has_value());
315
316 // The second event will be seen by the interceptor and the connection.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800317 mCallback->onVSyncEvent(456);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800318 expectInterceptCallReceived(456);
319 expectVsyncEventReceivedByConnection(456, 2u);
320
321 // The third event will be seen by the interceptor, and not the connection.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800322 mCallback->onVSyncEvent(789);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800323 expectInterceptCallReceived(789);
324 EXPECT_FALSE(mConnectionEventCallRecorder.waitForUnexpectedCall().has_value());
325
326 // The fourth event will be seen by the interceptor and the connection.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800327 mCallback->onVSyncEvent(101112);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800328 expectInterceptCallReceived(101112);
329 expectVsyncEventReceivedByConnection(101112, 4u);
330}
331
332TEST_F(EventThreadTest, connectionsRemovedIfInstanceDestroyed) {
333 mThread->setVsyncRate(1, mConnection);
334
Dominik Laskowski029cc122019-01-23 19:52:06 -0800335 // EventThread should enable vsync callbacks.
Lloyd Pique24b0a482018-03-09 18:52:26 -0800336 expectVSyncSetEnabledCallReceived(true);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800337
338 // Destroy the only (strong) reference to the connection.
339 mConnection = nullptr;
340
341 // The first event will be seen by the interceptor, and not the connection.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800342 mCallback->onVSyncEvent(123);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800343 expectInterceptCallReceived(123);
344 EXPECT_FALSE(mConnectionEventCallRecorder.waitForUnexpectedCall().has_value());
345
346 // EventThread should disable vsync callbacks
347 expectVSyncSetEnabledCallReceived(false);
348}
349
350TEST_F(EventThreadTest, connectionsRemovedIfEventDeliveryError) {
351 ConnectionEventRecorder errorConnectionEventRecorder{NO_MEMORY};
352 sp<MockEventThreadConnection> errorConnection = createConnection(errorConnectionEventRecorder);
353 mThread->setVsyncRate(1, errorConnection);
354
Dominik Laskowski029cc122019-01-23 19:52:06 -0800355 // EventThread should enable vsync callbacks.
Lloyd Pique24b0a482018-03-09 18:52:26 -0800356 expectVSyncSetEnabledCallReceived(true);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800357
358 // The first event will be seen by the interceptor, and by the connection,
359 // which then returns an error.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800360 mCallback->onVSyncEvent(123);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800361 expectInterceptCallReceived(123);
362 expectVsyncEventReceivedByConnection("errorConnection", errorConnectionEventRecorder, 123, 1u);
363
364 // A subsequent event will be seen by the interceptor and not by the
365 // connection.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800366 mCallback->onVSyncEvent(456);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800367 expectInterceptCallReceived(456);
368 EXPECT_FALSE(errorConnectionEventRecorder.waitForUnexpectedCall().has_value());
369
370 // EventThread should disable vsync callbacks with the second event
371 expectVSyncSetEnabledCallReceived(false);
372}
373
374TEST_F(EventThreadTest, eventsDroppedIfNonfatalEventDeliveryError) {
375 ConnectionEventRecorder errorConnectionEventRecorder{WOULD_BLOCK};
376 sp<MockEventThreadConnection> errorConnection = createConnection(errorConnectionEventRecorder);
377 mThread->setVsyncRate(1, errorConnection);
378
Dominik Laskowski029cc122019-01-23 19:52:06 -0800379 // EventThread should enable vsync callbacks.
Lloyd Pique24b0a482018-03-09 18:52:26 -0800380 expectVSyncSetEnabledCallReceived(true);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800381
382 // The first event will be seen by the interceptor, and by the connection,
383 // which then returns an non-fatal error.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800384 mCallback->onVSyncEvent(123);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800385 expectInterceptCallReceived(123);
386 expectVsyncEventReceivedByConnection("errorConnection", errorConnectionEventRecorder, 123, 1u);
387
388 // A subsequent event will be seen by the interceptor, and by the connection,
389 // which still then returns an non-fatal error.
Dominik Laskowski029cc122019-01-23 19:52:06 -0800390 mCallback->onVSyncEvent(456);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800391 expectInterceptCallReceived(456);
392 expectVsyncEventReceivedByConnection("errorConnection", errorConnectionEventRecorder, 456, 2u);
393
394 // EventThread will not disable vsync callbacks as the errors are non-fatal.
395 EXPECT_FALSE(mVSyncSetEnabledCallRecorder.waitForUnexpectedCall().has_value());
396}
397
398TEST_F(EventThreadTest, setPhaseOffsetForwardsToVSyncSource) {
399 mThread->setPhaseOffset(321);
400 expectVSyncSetPhaseOffsetCallReceived(321);
401}
402
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800403TEST_F(EventThreadTest, postHotplugInternalDisconnect) {
404 mThread->onHotplugReceived(INTERNAL_DISPLAY_ID, false);
405 expectHotplugEventReceivedByConnection(INTERNAL_DISPLAY_ID, false);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800406}
407
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800408TEST_F(EventThreadTest, postHotplugInternalConnect) {
409 mThread->onHotplugReceived(INTERNAL_DISPLAY_ID, true);
410 expectHotplugEventReceivedByConnection(INTERNAL_DISPLAY_ID, true);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800411}
412
413TEST_F(EventThreadTest, postHotplugExternalDisconnect) {
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800414 mThread->onHotplugReceived(EXTERNAL_DISPLAY_ID, false);
415 expectHotplugEventReceivedByConnection(EXTERNAL_DISPLAY_ID, false);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800416}
417
418TEST_F(EventThreadTest, postHotplugExternalConnect) {
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800419 mThread->onHotplugReceived(EXTERNAL_DISPLAY_ID, true);
420 expectHotplugEventReceivedByConnection(EXTERNAL_DISPLAY_ID, true);
Lloyd Pique24b0a482018-03-09 18:52:26 -0800421}
422
423} // namespace
424} // namespace android