Loading services/surfaceflinger/tests/fakehwc/FakeComposerClient.cpp +2 −3 Original line number Original line Diff line number Diff line Loading @@ -36,7 +36,6 @@ #include <thread> #include <thread> constexpr Config NULL_DISPLAY_CONFIG = static_cast<Config>(0); constexpr Config NULL_DISPLAY_CONFIG = static_cast<Config>(0); constexpr Display DEFAULT_DISPLAY = static_cast<Display>(1); using namespace sftest; using namespace sftest; Loading Loading @@ -168,7 +167,7 @@ void FakeComposerClient::enableCallback(bool enable) { ALOGV("enableCallback"); ALOGV("enableCallback"); mCallbacksOn = enable; mCallbacksOn = enable; if (mCallbacksOn) { if (mCallbacksOn) { mClient->onHotplug(DEFAULT_DISPLAY, IComposerCallback::Connection::CONNECTED); mClient->onHotplug(PRIMARY_DISPLAY, IComposerCallback::Connection::CONNECTED); } } } } Loading Loading @@ -507,7 +506,7 @@ void FakeComposerClient::requestVSync(uint64_t vsyncTime) { if (mSurfaceComposer != nullptr) { if (mSurfaceComposer != nullptr) { mSurfaceComposer->injectVSync(timestamp); mSurfaceComposer->injectVSync(timestamp); } else { } else { mClient->onVsync(DEFAULT_DISPLAY, timestamp); mClient->onVsync(PRIMARY_DISPLAY, timestamp); } } } } } } Loading services/surfaceflinger/tests/fakehwc/FakeComposerClient.h +10 −0 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,9 @@ #include "ComposerClient.h" #include "ComposerClient.h" #include "RenderState.h" #include "RenderState.h" // Needed for display type/ID enums #include <hardware/hwcomposer_defs.h> #include <utils/Condition.h> #include <utils/Condition.h> #include <chrono> #include <chrono> Loading @@ -40,6 +43,13 @@ class SurfaceComposerClient; namespace sftest { namespace sftest { // NOTE: The ID's need to be exactly these. VR composer and parts of // the SurfaceFlinger assume the display IDs to have these values // despite the enum being documented as a display type. // TODO: Reference to actual documentation constexpr Display PRIMARY_DISPLAY = static_cast<Display>(HWC_DISPLAY_PRIMARY); constexpr Display EXTERNAL_DISPLAY = static_cast<Display>(HWC_DISPLAY_EXTERNAL); class FakeComposerClient : public ComposerBase { class FakeComposerClient : public ComposerBase { public: public: FakeComposerClient(); FakeComposerClient(); Loading services/surfaceflinger/tests/fakehwc/SFFakeHwc_test.cpp +18 −22 Original line number Original line Diff line number Diff line Loading @@ -168,17 +168,15 @@ void DisplayTest::SetUp() { android::hardware::ProcessState::self()->startThreadPool(); android::hardware::ProcessState::self()->startThreadPool(); android::ProcessState::self()->startThreadPool(); android::ProcessState::self()->startThreadPool(); EXPECT_CALL(*mMockComposer, getDisplayType(1, _)) EXPECT_CALL(*mMockComposer, getDisplayType(PRIMARY_DISPLAY, _)) .WillOnce(DoAll(SetArgPointee<1>(IComposerClient::DisplayType::PHYSICAL), .WillOnce(DoAll(SetArgPointee<1>(IComposerClient::DisplayType::PHYSICAL), Return(Error::NONE))); Return(Error::NONE))); // Seems to be doubled right now, once for display ID 1 and once for 0. This sounds fishy // Primary display will be queried twice for all 5 attributes. One // but encoding that here exactly. // set of queries comes from the SurfaceFlinger proper an the EXPECT_CALL(*mMockComposer, getDisplayAttribute(1, 1, _, _)) // other set from the VR composer. .Times(5) // TODO: Is VR composer always present? Change to atLeast(5)? .WillRepeatedly(Invoke(mMockComposer, &MockComposerClient::getDisplayAttributeFake)); EXPECT_CALL(*mMockComposer, getDisplayAttribute(PRIMARY_DISPLAY, 1, _, _)) // TODO: Find out what code is generating the ID 0. .Times(2 * 5) EXPECT_CALL(*mMockComposer, getDisplayAttribute(0, 1, _, _)) .Times(5) .WillRepeatedly(Invoke(mMockComposer, &MockComposerClient::getDisplayAttributeFake)); .WillRepeatedly(Invoke(mMockComposer, &MockComposerClient::getDisplayAttributeFake)); startSurfaceFlinger(); startSurfaceFlinger(); Loading Loading @@ -207,31 +205,32 @@ void DisplayTest::TearDown() { TEST_F(DisplayTest, Hotplug) { TEST_F(DisplayTest, Hotplug) { ALOGD("DisplayTest::Hotplug"); ALOGD("DisplayTest::Hotplug"); EXPECT_CALL(*mMockComposer, getDisplayType(2, _)) EXPECT_CALL(*mMockComposer, getDisplayType(EXTERNAL_DISPLAY, _)) .Times(2) .Times(2) .WillRepeatedly(DoAll(SetArgPointee<1>(IComposerClient::DisplayType::PHYSICAL), .WillRepeatedly(DoAll(SetArgPointee<1>(IComposerClient::DisplayType::PHYSICAL), Return(Error::NONE))); Return(Error::NONE))); // The attribute queries will get done twice. This is for defaults // The attribute queries will get done twice. This is for defaults EXPECT_CALL(*mMockComposer, getDisplayAttribute(2, 1, _, _)) EXPECT_CALL(*mMockComposer, getDisplayAttribute(EXTERNAL_DISPLAY, 1, _, _)) .Times(2 * 3) .Times(2 * 3) .WillRepeatedly(Invoke(mMockComposer, &MockComposerClient::getDisplayAttributeFake)); .WillRepeatedly(Invoke(mMockComposer, &MockComposerClient::getDisplayAttributeFake)); // ... and then special handling for dimensions. Specifying this // ... and then special handling for dimensions. Specifying this // rules later means that gmock will try them first, i.e., // rules later means that gmock will try them first, i.e., // ordering of width/height vs. the default implementation for // ordering of width/height vs. the default implementation for // other queries is significant. // other queries is significant. EXPECT_CALL(*mMockComposer, getDisplayAttribute(2, 1, IComposerClient::Attribute::WIDTH, _)) EXPECT_CALL(*mMockComposer, getDisplayAttribute(EXTERNAL_DISPLAY, 1, IComposerClient::Attribute::WIDTH, _)) .Times(2) .Times(2) .WillRepeatedly(DoAll(SetArgPointee<3>(400), Return(Error::NONE))); .WillRepeatedly(DoAll(SetArgPointee<3>(400), Return(Error::NONE))); EXPECT_CALL(*mMockComposer, getDisplayAttribute(2, 1, IComposerClient::Attribute::HEIGHT, _)) EXPECT_CALL(*mMockComposer, getDisplayAttribute(EXTERNAL_DISPLAY, 1, IComposerClient::Attribute::HEIGHT, _)) .Times(2) .Times(2) .WillRepeatedly(DoAll(SetArgPointee<3>(200), Return(Error::NONE))); .WillRepeatedly(DoAll(SetArgPointee<3>(200), Return(Error::NONE))); // TODO: Width and height queries are not actually called. Display // TODO: Width and height queries are not actually called. Display // info returns dimensions 0x0 in display info. Why? // info returns dimensions 0x0 in display info. Why? mMockComposer->hotplugDisplay(static_cast<Display>(2), mMockComposer->hotplugDisplay(EXTERNAL_DISPLAY, IComposerCallback::Connection::CONNECTED); IComposerCallback::Connection::CONNECTED); { { sp<android::IBinder> display( sp<android::IBinder> display( Loading @@ -257,13 +256,11 @@ TEST_F(DisplayTest, Hotplug) { } } } } mMockComposer->hotplugDisplay(static_cast<Display>(2), mMockComposer->hotplugDisplay(EXTERNAL_DISPLAY, IComposerCallback::Connection::DISCONNECTED); IComposerCallback::Connection::DISCONNECTED); mMockComposer->clearFrames(); mMockComposer->clearFrames(); mMockComposer->hotplugDisplay(static_cast<Display>(2), mMockComposer->hotplugDisplay(EXTERNAL_DISPLAY, IComposerCallback::Connection::CONNECTED); IComposerCallback::Connection::CONNECTED); { { sp<android::IBinder> display( sp<android::IBinder> display( Loading @@ -288,8 +285,7 @@ TEST_F(DisplayTest, Hotplug) { ASSERT_EQ(NO_ERROR, surfaceControl->show()); ASSERT_EQ(NO_ERROR, surfaceControl->show()); } } } } mMockComposer->hotplugDisplay(static_cast<Display>(2), mMockComposer->hotplugDisplay(EXTERNAL_DISPLAY, IComposerCallback::Connection::DISCONNECTED); IComposerCallback::Connection::DISCONNECTED); } } //////////////////////////////////////////////// //////////////////////////////////////////////// Loading Loading
services/surfaceflinger/tests/fakehwc/FakeComposerClient.cpp +2 −3 Original line number Original line Diff line number Diff line Loading @@ -36,7 +36,6 @@ #include <thread> #include <thread> constexpr Config NULL_DISPLAY_CONFIG = static_cast<Config>(0); constexpr Config NULL_DISPLAY_CONFIG = static_cast<Config>(0); constexpr Display DEFAULT_DISPLAY = static_cast<Display>(1); using namespace sftest; using namespace sftest; Loading Loading @@ -168,7 +167,7 @@ void FakeComposerClient::enableCallback(bool enable) { ALOGV("enableCallback"); ALOGV("enableCallback"); mCallbacksOn = enable; mCallbacksOn = enable; if (mCallbacksOn) { if (mCallbacksOn) { mClient->onHotplug(DEFAULT_DISPLAY, IComposerCallback::Connection::CONNECTED); mClient->onHotplug(PRIMARY_DISPLAY, IComposerCallback::Connection::CONNECTED); } } } } Loading Loading @@ -507,7 +506,7 @@ void FakeComposerClient::requestVSync(uint64_t vsyncTime) { if (mSurfaceComposer != nullptr) { if (mSurfaceComposer != nullptr) { mSurfaceComposer->injectVSync(timestamp); mSurfaceComposer->injectVSync(timestamp); } else { } else { mClient->onVsync(DEFAULT_DISPLAY, timestamp); mClient->onVsync(PRIMARY_DISPLAY, timestamp); } } } } } } Loading
services/surfaceflinger/tests/fakehwc/FakeComposerClient.h +10 −0 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,9 @@ #include "ComposerClient.h" #include "ComposerClient.h" #include "RenderState.h" #include "RenderState.h" // Needed for display type/ID enums #include <hardware/hwcomposer_defs.h> #include <utils/Condition.h> #include <utils/Condition.h> #include <chrono> #include <chrono> Loading @@ -40,6 +43,13 @@ class SurfaceComposerClient; namespace sftest { namespace sftest { // NOTE: The ID's need to be exactly these. VR composer and parts of // the SurfaceFlinger assume the display IDs to have these values // despite the enum being documented as a display type. // TODO: Reference to actual documentation constexpr Display PRIMARY_DISPLAY = static_cast<Display>(HWC_DISPLAY_PRIMARY); constexpr Display EXTERNAL_DISPLAY = static_cast<Display>(HWC_DISPLAY_EXTERNAL); class FakeComposerClient : public ComposerBase { class FakeComposerClient : public ComposerBase { public: public: FakeComposerClient(); FakeComposerClient(); Loading
services/surfaceflinger/tests/fakehwc/SFFakeHwc_test.cpp +18 −22 Original line number Original line Diff line number Diff line Loading @@ -168,17 +168,15 @@ void DisplayTest::SetUp() { android::hardware::ProcessState::self()->startThreadPool(); android::hardware::ProcessState::self()->startThreadPool(); android::ProcessState::self()->startThreadPool(); android::ProcessState::self()->startThreadPool(); EXPECT_CALL(*mMockComposer, getDisplayType(1, _)) EXPECT_CALL(*mMockComposer, getDisplayType(PRIMARY_DISPLAY, _)) .WillOnce(DoAll(SetArgPointee<1>(IComposerClient::DisplayType::PHYSICAL), .WillOnce(DoAll(SetArgPointee<1>(IComposerClient::DisplayType::PHYSICAL), Return(Error::NONE))); Return(Error::NONE))); // Seems to be doubled right now, once for display ID 1 and once for 0. This sounds fishy // Primary display will be queried twice for all 5 attributes. One // but encoding that here exactly. // set of queries comes from the SurfaceFlinger proper an the EXPECT_CALL(*mMockComposer, getDisplayAttribute(1, 1, _, _)) // other set from the VR composer. .Times(5) // TODO: Is VR composer always present? Change to atLeast(5)? .WillRepeatedly(Invoke(mMockComposer, &MockComposerClient::getDisplayAttributeFake)); EXPECT_CALL(*mMockComposer, getDisplayAttribute(PRIMARY_DISPLAY, 1, _, _)) // TODO: Find out what code is generating the ID 0. .Times(2 * 5) EXPECT_CALL(*mMockComposer, getDisplayAttribute(0, 1, _, _)) .Times(5) .WillRepeatedly(Invoke(mMockComposer, &MockComposerClient::getDisplayAttributeFake)); .WillRepeatedly(Invoke(mMockComposer, &MockComposerClient::getDisplayAttributeFake)); startSurfaceFlinger(); startSurfaceFlinger(); Loading Loading @@ -207,31 +205,32 @@ void DisplayTest::TearDown() { TEST_F(DisplayTest, Hotplug) { TEST_F(DisplayTest, Hotplug) { ALOGD("DisplayTest::Hotplug"); ALOGD("DisplayTest::Hotplug"); EXPECT_CALL(*mMockComposer, getDisplayType(2, _)) EXPECT_CALL(*mMockComposer, getDisplayType(EXTERNAL_DISPLAY, _)) .Times(2) .Times(2) .WillRepeatedly(DoAll(SetArgPointee<1>(IComposerClient::DisplayType::PHYSICAL), .WillRepeatedly(DoAll(SetArgPointee<1>(IComposerClient::DisplayType::PHYSICAL), Return(Error::NONE))); Return(Error::NONE))); // The attribute queries will get done twice. This is for defaults // The attribute queries will get done twice. This is for defaults EXPECT_CALL(*mMockComposer, getDisplayAttribute(2, 1, _, _)) EXPECT_CALL(*mMockComposer, getDisplayAttribute(EXTERNAL_DISPLAY, 1, _, _)) .Times(2 * 3) .Times(2 * 3) .WillRepeatedly(Invoke(mMockComposer, &MockComposerClient::getDisplayAttributeFake)); .WillRepeatedly(Invoke(mMockComposer, &MockComposerClient::getDisplayAttributeFake)); // ... and then special handling for dimensions. Specifying this // ... and then special handling for dimensions. Specifying this // rules later means that gmock will try them first, i.e., // rules later means that gmock will try them first, i.e., // ordering of width/height vs. the default implementation for // ordering of width/height vs. the default implementation for // other queries is significant. // other queries is significant. EXPECT_CALL(*mMockComposer, getDisplayAttribute(2, 1, IComposerClient::Attribute::WIDTH, _)) EXPECT_CALL(*mMockComposer, getDisplayAttribute(EXTERNAL_DISPLAY, 1, IComposerClient::Attribute::WIDTH, _)) .Times(2) .Times(2) .WillRepeatedly(DoAll(SetArgPointee<3>(400), Return(Error::NONE))); .WillRepeatedly(DoAll(SetArgPointee<3>(400), Return(Error::NONE))); EXPECT_CALL(*mMockComposer, getDisplayAttribute(2, 1, IComposerClient::Attribute::HEIGHT, _)) EXPECT_CALL(*mMockComposer, getDisplayAttribute(EXTERNAL_DISPLAY, 1, IComposerClient::Attribute::HEIGHT, _)) .Times(2) .Times(2) .WillRepeatedly(DoAll(SetArgPointee<3>(200), Return(Error::NONE))); .WillRepeatedly(DoAll(SetArgPointee<3>(200), Return(Error::NONE))); // TODO: Width and height queries are not actually called. Display // TODO: Width and height queries are not actually called. Display // info returns dimensions 0x0 in display info. Why? // info returns dimensions 0x0 in display info. Why? mMockComposer->hotplugDisplay(static_cast<Display>(2), mMockComposer->hotplugDisplay(EXTERNAL_DISPLAY, IComposerCallback::Connection::CONNECTED); IComposerCallback::Connection::CONNECTED); { { sp<android::IBinder> display( sp<android::IBinder> display( Loading @@ -257,13 +256,11 @@ TEST_F(DisplayTest, Hotplug) { } } } } mMockComposer->hotplugDisplay(static_cast<Display>(2), mMockComposer->hotplugDisplay(EXTERNAL_DISPLAY, IComposerCallback::Connection::DISCONNECTED); IComposerCallback::Connection::DISCONNECTED); mMockComposer->clearFrames(); mMockComposer->clearFrames(); mMockComposer->hotplugDisplay(static_cast<Display>(2), mMockComposer->hotplugDisplay(EXTERNAL_DISPLAY, IComposerCallback::Connection::CONNECTED); IComposerCallback::Connection::CONNECTED); { { sp<android::IBinder> display( sp<android::IBinder> display( Loading @@ -288,8 +285,7 @@ TEST_F(DisplayTest, Hotplug) { ASSERT_EQ(NO_ERROR, surfaceControl->show()); ASSERT_EQ(NO_ERROR, surfaceControl->show()); } } } } mMockComposer->hotplugDisplay(static_cast<Display>(2), mMockComposer->hotplugDisplay(EXTERNAL_DISPLAY, IComposerCallback::Connection::DISCONNECTED); IComposerCallback::Connection::DISCONNECTED); } } //////////////////////////////////////////////// //////////////////////////////////////////////// Loading