SF: Moving EventThread::Connection out of impl class
This is part of Scheduler refactoring. EventThread::Connection should be
a wrapper that translates IDisplayEventConnection into EventThread calls.
Test: SF tests pass.
Bug: 113612090
Change-Id: I2bcf0c45a33638c59f7828085c563dbc52b2d66e
diff --git a/services/surfaceflinger/tests/unittests/EventThreadTest.cpp b/services/surfaceflinger/tests/unittests/EventThreadTest.cpp
index fb3b7a2..acbed51 100644
--- a/services/surfaceflinger/tests/unittests/EventThreadTest.cpp
+++ b/services/surfaceflinger/tests/unittests/EventThreadTest.cpp
@@ -47,10 +47,10 @@
class EventThreadTest : public testing::Test {
protected:
- class MockEventThreadConnection : public android::impl::EventThread::Connection {
+ class MockEventThreadConnection : public android::EventThreadConnection {
public:
explicit MockEventThreadConnection(android::impl::EventThread* eventThread)
- : android::impl::EventThread::Connection(eventThread) {}
+ : android::EventThreadConnection(eventThread) {}
MOCK_METHOD1(postEvent, status_t(const DisplayEventReceiver::Event& event));
};
diff --git a/services/surfaceflinger/tests/unittests/SchedulerTest.cpp b/services/surfaceflinger/tests/unittests/SchedulerTest.cpp
index 35f30d7..4253ad8 100644
--- a/services/surfaceflinger/tests/unittests/SchedulerTest.cpp
+++ b/services/surfaceflinger/tests/unittests/SchedulerTest.cpp
@@ -23,9 +23,10 @@
class SchedulerTest : public testing::Test {
protected:
- class MockEventThreadConnection : public BnDisplayEventConnection {
+ class MockEventThreadConnection : public android::EventThreadConnection {
public:
- MockEventThreadConnection() = default;
+ explicit MockEventThreadConnection(EventThread* eventThread)
+ : EventThreadConnection(eventThread) {}
~MockEventThreadConnection() = default;
MOCK_METHOD1(stealReceiveChannel, status_t(gui::BitTube* outChannel));
@@ -77,7 +78,9 @@
std::unique_ptr<mock::EventThread> eventThread = std::make_unique<mock::EventThread>();
mEventThread = eventThread.get();
mScheduler = std::make_unique<MockScheduler>(std::move(eventThread));
- mEventThreadConnection = new MockEventThreadConnection();
+ EXPECT_CALL(*mEventThread, registerDisplayEventConnection(_)).WillOnce(Return(0));
+
+ mEventThreadConnection = new MockEventThreadConnection(mEventThread);
// createConnection call to scheduler makes a createEventConnection call to EventThread. Make
// sure that call gets executed and returns an EventThread::Connection object.
diff --git a/services/surfaceflinger/tests/unittests/mock/MockEventThread.h b/services/surfaceflinger/tests/unittests/mock/MockEventThread.h
index 0a1c827..bb6e183 100644
--- a/services/surfaceflinger/tests/unittests/mock/MockEventThread.h
+++ b/services/surfaceflinger/tests/unittests/mock/MockEventThread.h
@@ -28,12 +28,16 @@
EventThread();
~EventThread() override;
- MOCK_CONST_METHOD0(createEventConnection, sp<BnDisplayEventConnection>());
+ MOCK_CONST_METHOD0(createEventConnection, sp<EventThreadConnection>());
MOCK_METHOD0(onScreenReleased, void());
MOCK_METHOD0(onScreenAcquired, void());
MOCK_METHOD2(onHotplugReceived, void(DisplayType, bool));
MOCK_CONST_METHOD1(dump, void(std::string&));
MOCK_METHOD1(setPhaseOffset, void(nsecs_t phaseOffset));
+ MOCK_METHOD1(registerDisplayEventConnection,
+ status_t(const sp<android::EventThreadConnection> &));
+ MOCK_METHOD2(setVsyncRate, void(uint32_t, const sp<android::EventThreadConnection> &));
+ MOCK_METHOD1(requestNextVsync, void(const sp<android::EventThreadConnection> &));
};
} // namespace mock
diff --git a/services/surfaceflinger/tests/unittests/mock/MockMessageQueue.h b/services/surfaceflinger/tests/unittests/mock/MockMessageQueue.h
index f2f3675..dc8d606 100644
--- a/services/surfaceflinger/tests/unittests/mock/MockMessageQueue.h
+++ b/services/surfaceflinger/tests/unittests/mock/MockMessageQueue.h
@@ -18,6 +18,7 @@
#include <gmock/gmock.h>
+#include "Scheduler/EventThread.h"
#include "Scheduler/MessageQueue.h"
namespace android {
@@ -30,7 +31,7 @@
MOCK_METHOD1(init, void(const sp<SurfaceFlinger>&));
MOCK_METHOD1(setEventThread, void(android::EventThread*));
- MOCK_METHOD1(setEventConnection, void(const sp<BnDisplayEventConnection>& connection));
+ MOCK_METHOD1(setEventConnection, void(const sp<android::EventThreadConnection>& connection));
MOCK_METHOD0(waitMessage, void());
MOCK_METHOD2(postMessage, status_t(const sp<MessageBase>&, nsecs_t));
MOCK_METHOD0(invalidate, void());