From 8060858cbd0a62bc2c29d356064268de83117ecc Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Wed, 2 Sep 2020 15:29:17 +0900 Subject: [PATCH 01/16] DSWindowManager: add TCs Change-Id: If005e3d9b2b5151fca6d5b30af68aa00e28f5fc8 --- tests/DSWindowManager-test.cpp | 384 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 357 insertions(+), 27 deletions(-) diff --git a/tests/DSWindowManager-test.cpp b/tests/DSWindowManager-test.cpp index cc3de04..43f5d02 100644 --- a/tests/DSWindowManager-test.cpp +++ b/tests/DSWindowManager-test.cpp @@ -31,28 +31,25 @@ using namespace display_server; -DSWindowManager* g_winMgr = nullptr; - class DSWindowManagerTest : public ::testing::Test { public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - g_winMgr = DSWindowManager::getInstance(); - } - void TearDown(void) override - { - DSWindowManager::releaseInstance(); - g_winMgr = nullptr; - unsetenv("XDG_RUNTIME_DIR"); - } + void SetUp(void) override + { + char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); + setenv("XDG_RUNTIME_DIR", xdir, 1); + } + void TearDown(void) override + { + unsetenv("XDG_RUNTIME_DIR"); + } }; TEST_F(DSWindowManagerTest, GetWindowManager) { - EXPECT_TRUE(g_winMgr != nullptr); + DSWindowManager *winMgr = DSWindowManager::getInstance(); + EXPECT_TRUE(winMgr != nullptr); + DSWindowManager::releaseInstance(); } TEST_F(DSWindowManagerTest, RegisterWindow) @@ -60,7 +57,8 @@ TEST_F(DSWindowManagerTest, RegisterWindow) bool ret = false; DSZone *foundZone = nullptr; - EXPECT_TRUE(g_winMgr != nullptr); + DSWindowManager *winMgr = DSWindowManager::getInstance(); + EXPECT_TRUE(winMgr != nullptr); auto zone = std::make_shared(); EXPECT_TRUE(zone != nullptr); @@ -68,19 +66,21 @@ TEST_F(DSWindowManagerTest, RegisterWindow) auto window = std::make_shared(); EXPECT_TRUE(window != nullptr); - foundZone = g_winMgr->getZone(window.get()); + foundZone = winMgr->getZone(window.get()); EXPECT_TRUE(foundZone == nullptr); - ret = g_winMgr->registerWindow(zone.get(), window.get()); + ret = winMgr->registerWindow(zone.get(), window.get()); EXPECT_TRUE(ret == true); - foundZone = g_winMgr->getZone(window.get()); + foundZone = winMgr->getZone(window.get()); EXPECT_TRUE(foundZone == zone.get()); - g_winMgr->unregisterWindow(zone.get(), window.get()); + winMgr->unregisterWindow(zone.get(), window.get()); - foundZone = g_winMgr->getZone(window.get()); + foundZone = winMgr->getZone(window.get()); EXPECT_TRUE(foundZone == nullptr); + + DSWindowManager::releaseInstance(); } TEST_F(DSWindowManagerTest, RegisterSurface) @@ -88,7 +88,8 @@ TEST_F(DSWindowManagerTest, RegisterSurface) bool ret = false; DSZone *foundZone = nullptr; - EXPECT_TRUE(g_winMgr != nullptr); + DSWindowManager *winMgr = DSWindowManager::getInstance(); + EXPECT_TRUE(winMgr != nullptr); auto zone = std::make_shared(); EXPECT_TRUE(zone != nullptr); @@ -96,19 +97,348 @@ TEST_F(DSWindowManagerTest, RegisterSurface) auto surface = std::make_shared(); EXPECT_TRUE(surface != nullptr); - foundZone = g_winMgr->getZone(surface.get()); + foundZone = winMgr->getZone(surface.get()); EXPECT_TRUE(foundZone == nullptr); - ret = g_winMgr->registerSurface(zone.get(), surface.get()); + ret = winMgr->registerSurface(zone.get(), surface.get()); EXPECT_TRUE(ret == true); - foundZone = g_winMgr->getZone(surface.get()); + foundZone = winMgr->getZone(surface.get()); EXPECT_TRUE(foundZone == zone.get()); - g_winMgr->unregisterSurface(zone.get(), surface.get()); + winMgr->unregisterSurface(zone.get(), surface.get()); - foundZone = g_winMgr->getZone(surface.get()); + foundZone = winMgr->getZone(surface.get()); EXPECT_TRUE(foundZone == nullptr); + + DSWindowManager::releaseInstance(); +} + +TEST_F(DSWindowManagerTest, ParentTest_P1) +{ + bool ret = false; + + DSWindowManager *winMgr = DSWindowManager::getInstance(); + EXPECT_TRUE(winMgr != nullptr); + + auto zone = std::make_shared(); + EXPECT_TRUE(zone != nullptr); + + auto surface = std::make_shared(); + EXPECT_TRUE(surface != nullptr); + + auto surface2 = std::make_shared(); + EXPECT_TRUE(surface2 != nullptr); + + zone->testCreateWindow(surface); + zone->testCreateWindow(surface2); + + ret = winMgr->registerSurface(zone.get(), surface.get()); + EXPECT_TRUE(ret == true); + + ret = winMgr->registerSurface(zone.get(), surface2.get()); + EXPECT_TRUE(ret == true); + + ret = winMgr->setWindowParent(surface.get(), nullptr); + EXPECT_TRUE(ret == true); + + ret = winMgr->setWindowParent(surface.get(), surface2.get()); + EXPECT_TRUE(ret == true); + + DSWindowManager::releaseInstance(); +} + +TEST_F(DSWindowManagerTest, ParentTest_N1) +{ + bool ret = false; + + DSWindowManager *winMgr = DSWindowManager::getInstance(); + EXPECT_TRUE(winMgr != nullptr); + + auto zone = std::make_shared(); + EXPECT_TRUE(zone != nullptr); + + auto zone2 = std::make_shared(); + EXPECT_TRUE(zone2 != nullptr); + + auto surface = std::make_shared(); + EXPECT_TRUE(surface != nullptr); + + auto surface2 = std::make_shared(); + EXPECT_TRUE(surface2 != nullptr); + + // Not registered to DSZone + ret = winMgr->setWindowParent(surface.get(), surface2.get()); + EXPECT_TRUE(ret == false); + + winMgr->registerSurface(zone.get(), surface.get()); + winMgr->registerSurface(zone2.get(), surface2.get()); + + // Not SAME DSZone + ret = winMgr->setWindowParent(surface.get(), surface2.get()); + EXPECT_TRUE(ret == false); + + DSWindowManager::releaseInstance(); +} + +TEST_F(DSWindowManagerTest, PropertyTest) +{ + bool ret = false; + DSWindow *window = nullptr; + + DSWindowManager *winMgr = DSWindowManager::getInstance(); + EXPECT_TRUE(winMgr != nullptr); + + auto zone = std::make_shared(); + EXPECT_TRUE(zone != nullptr); + + auto surface = std::make_shared(); + EXPECT_TRUE(surface != nullptr); + + DSWaylandSurface *surface_ptr = surface.get(); + EXPECT_TRUE(surface_ptr != nullptr); + + zone->testCreateWindow(surface); + + ret = winMgr->registerSurface(zone.get(), surface_ptr); + EXPECT_TRUE(ret == true); + + std::list> winList = zone->getWindowList(); + for (auto w : winList) + { + if (w->surface() == surface_ptr) + { + window = w.get(); + } + } + EXPECT_TRUE(window != nullptr); + + winMgr->setWindowTitle(surface_ptr, "test"); + const std::string str = window->getTitle(); + EXPECT_TRUE(str == "test"); + + winMgr->setWindowType(surface_ptr, 3); + + winMgr->setWindowAllowUserGeometry(surface_ptr, true); + winMgr->setWindowGeometry(surface_ptr, 100, 200, 320, 480); + stGeometry geo = winMgr->getWindowGeometry(surface_ptr); + EXPECT_TRUE(geo.x == 100); + EXPECT_TRUE(geo.y == 200); + EXPECT_TRUE(geo.w == 320); + EXPECT_TRUE(geo.h == 480); + + winMgr->setWindowPosition(surface_ptr, 50, 100); + geo = winMgr->getWindowGeometry(surface_ptr); + EXPECT_TRUE(geo.x == 50); + EXPECT_TRUE(geo.y == 100); + + DSWindowManager::releaseInstance(); +} + +TEST_F(DSWindowManagerTest, AuxHintsTest) +{ + bool ret = false; + + DSWindowManager *winMgr = DSWindowManager::getInstance(); + EXPECT_TRUE(winMgr != nullptr); + + auto zone = std::make_shared(); + EXPECT_TRUE(zone != nullptr); + + auto surface = std::make_shared(); + EXPECT_TRUE(surface != nullptr); + + DSWaylandSurface *surface_ptr = surface.get(); + EXPECT_TRUE(surface_ptr != nullptr); + + zone->testCreateWindow(surface); + + ret = winMgr->registerSurface(zone.get(), surface_ptr); + EXPECT_TRUE(ret == true); + + std::list auxList = winMgr->getWindowSupportedAuxHints(surface_ptr); + EXPECT_TRUE(auxList.size() > 0); + + winMgr->addWindowAuxHint(surface_ptr, 1, "wm.policy.win.user.geometry", "1"); + winMgr->setWindowGeometry(surface_ptr, 100, 200, 320, 480); + stGeometry geo = winMgr->getWindowGeometry(surface_ptr); + EXPECT_TRUE(geo.x == 100); + EXPECT_TRUE(geo.y == 200); + EXPECT_TRUE(geo.w == 320); + EXPECT_TRUE(geo.h == 480); + + winMgr->changeWindowAuxHint(surface_ptr, 1, "0"); + geo = winMgr->getWindowGeometry(surface_ptr); + EXPECT_TRUE(geo.x == 0); + EXPECT_TRUE(geo.y == 0); + + winMgr->removeWindowAuxHint(surface_ptr, 1); + + DSWindowManager::releaseInstance(); +} + +TEST_F(DSWindowManagerTest, StackTest) +{ + bool ret = false; + DSWindow *resultWindow[3]; + + DSWindowManager *winMgr = DSWindowManager::getInstance(); + EXPECT_TRUE(winMgr != nullptr); + + auto zone = std::make_shared(); + EXPECT_TRUE(zone != nullptr); + + auto surface0 = std::make_shared(); + EXPECT_TRUE(surface0 != nullptr); + DSWaylandSurface *surface_ptr0 = surface0.get(); + EXPECT_TRUE(surface_ptr0 != nullptr); + + auto surface1 = std::make_shared(); + EXPECT_TRUE(surface1 != nullptr); + DSWaylandSurface *surface_ptr1 = surface1.get(); + EXPECT_TRUE(surface_ptr1 != nullptr); + + auto surface2 = std::make_shared(); + EXPECT_TRUE(surface2 != nullptr); + DSWaylandSurface *surface_ptr2 = surface2.get(); + EXPECT_TRUE(surface_ptr2 != nullptr); + + zone->testCreateWindow(surface0); + zone->testCreateWindow(surface1); + zone->testCreateWindow(surface2); + + ret = winMgr->registerSurface(zone.get(), surface_ptr0); + EXPECT_TRUE(ret == true); + ret = winMgr->registerSurface(zone.get(), surface_ptr1); + EXPECT_TRUE(ret == true); + ret = winMgr->registerSurface(zone.get(), surface_ptr2); + EXPECT_TRUE(ret == true); + + std::list> winList = zone->getWindowList(); + int id = 0; + for (auto w : winList) + { + resultWindow[id] = w.get(); + id++; + } + EXPECT_TRUE(resultWindow[0]->surface() == surface_ptr2); + EXPECT_TRUE(resultWindow[1]->surface() == surface_ptr1); + EXPECT_TRUE(resultWindow[2]->surface() == surface_ptr0); + + // ACTIVATE window + winMgr->activateWindow(surface_ptr0); + + winList = zone->getWindowList(); + id = 0; + for (auto w : winList) + { + resultWindow[id] = w.get(); + id++; + } + EXPECT_TRUE(resultWindow[0]->surface() == surface_ptr0); + EXPECT_TRUE(resultWindow[1]->surface() == surface_ptr2); + EXPECT_TRUE(resultWindow[2]->surface() == surface_ptr1); + + // LOWER window + winMgr->lowerWindow(surface_ptr2); + + winList = zone->getWindowList(); + id = 0; + for (auto w : winList) + { + resultWindow[id] = w.get(); + id++; + } + EXPECT_TRUE(resultWindow[0]->surface() == surface_ptr0); + EXPECT_TRUE(resultWindow[1]->surface() == surface_ptr1); + EXPECT_TRUE(resultWindow[2]->surface() == surface_ptr2); + + // RAISE window + winMgr->raiseWindow(surface_ptr2); + + winList = zone->getWindowList(); + id = 0; + for (auto w : winList) + { + resultWindow[id] = w.get(); + id++; + } + EXPECT_TRUE(resultWindow[0]->surface() == surface_ptr2); + EXPECT_TRUE(resultWindow[1]->surface() == surface_ptr0); + EXPECT_TRUE(resultWindow[2]->surface() == surface_ptr1); + + DSWindowManager::releaseInstance(); +} + +TEST_F(DSWindowManagerTest, FocusTest) +{ + bool ret = false; + DSWindow *window = nullptr; + + DSWindowManager *winMgr = DSWindowManager::getInstance(); + EXPECT_TRUE(winMgr != nullptr); + + auto zone = std::make_shared(); + EXPECT_TRUE(zone != nullptr); + + auto surface = std::make_shared(); + EXPECT_TRUE(surface != nullptr); + + DSWaylandSurface *surface_ptr = surface.get(); + EXPECT_TRUE(surface_ptr != nullptr); + + zone->testCreateWindow(surface); + + ret = winMgr->registerSurface(zone.get(), surface_ptr); + EXPECT_TRUE(ret == true); + + std::list> winList = zone->getWindowList(); + for (auto w : winList) + { + if (w->surface() == surface_ptr) + { + window = w.get(); + } + } + EXPECT_TRUE(window != nullptr); + + EXPECT_TRUE(window->getSkipFocus() == false); + + winMgr->setWindowSkipFocus(surface_ptr, true); + EXPECT_TRUE(window->getSkipFocus() == true); } +TEST_F(DSWindowManagerTest, KeyboardTest) +{ + bool ret = false; + + DSWindowManager *winMgr = DSWindowManager::getInstance(); + EXPECT_TRUE(winMgr != nullptr); + + auto zone = std::make_shared(); + EXPECT_TRUE(zone != nullptr); + + auto surface = std::make_shared(); + EXPECT_TRUE(surface != nullptr); + + DSWaylandSurface *surface_ptr = surface.get(); + EXPECT_TRUE(surface_ptr != nullptr); + + zone->testCreateWindow(surface); + + ret = winMgr->registerSurface(zone.get(), surface_ptr); + EXPECT_TRUE(ret == true); + + ret = winMgr->setWindowVkbdFloating(surface_ptr, true); + EXPECT_TRUE(ret == true); + + ret = winMgr->getWindowVkbdFloating(surface_ptr); + EXPECT_TRUE(ret == true); + + ret = winMgr->setWindowVkbdFloating(surface_ptr, false); + EXPECT_TRUE(ret == true); + + ret = winMgr->getWindowVkbdFloating(surface_ptr); + EXPECT_TRUE(ret == false); +} -- 2.7.4 From 88099be79f859220177914c2eff0b415ff746e16 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 2 Sep 2020 14:34:31 +0900 Subject: [PATCH 02/16] DSRenderEngineDaliImpl-test: Added TC to improve coverage Change-Id: Ib352a858d48172c6a18a20a077c4640bf99e227e Signed-off-by: Joonbum Ko --- tests/DSRenderEngineDaliImpl-test.cpp | 239 ++++++++++++++++++++++++++++++++++ 1 file changed, 239 insertions(+) diff --git a/tests/DSRenderEngineDaliImpl-test.cpp b/tests/DSRenderEngineDaliImpl-test.cpp index d794532..001fc8a 100644 --- a/tests/DSRenderEngineDaliImpl-test.cpp +++ b/tests/DSRenderEngineDaliImpl-test.cpp @@ -290,3 +290,242 @@ TEST_F(DSRenderEngineDaliTest, RenderEngine_ComposeTwoRenderView) usleep(1000000); } } + +TEST_F(DSRenderEngineDaliTest, RenderEngine_RaiseToTop) +{ + std::unique_ptr displayDevice = std::make_unique(); + std::list> outputList = displayDevice->getOutputList(); + EXPECT_TRUE(outputList.size() != 0); + + IDSDisplayDeviceOutput::ConnectorType connType; + IDSDisplayDeviceOutput::ConnectState connState; + std::shared_ptr deviceHWC; + + for (std::shared_ptr output : outputList) { + connType = output->getConnectType(); + EXPECT_TRUE(connType <= IDSDisplayDeviceOutput::TYPE_DSI); + connState = output->getConnectState(); + EXPECT_TRUE(connState <= IDSDisplayDeviceOutput::STATE_MODESET); + if (connState == IDSDisplayDeviceOutput::STATE_DISCONNECTED) + continue; + + auto bestMode = (output->getAvailableModes()).front(); + EXPECT_TRUE(output->setMode(bestMode) == true); + EXPECT_TRUE(output->getMode() == bestMode); + + deviceHWC = output->getHWC(); + EXPECT_TRUE(deviceHWC != nullptr); + + auto bufferQueue = deviceHWC->getTargetBufferQueue(); + EXPECT_TRUE(deviceHWC != nullptr); + + auto renderEngine = std::make_unique(bufferQueue); + EXPECT_TRUE(renderEngine != nullptr); + + int imgWidth = 500; + int imgHeight = 500; + + // for 1st renderView -- begin -- + auto renderViewA = renderEngine->makeRenderView(); + EXPECT_TRUE(renderViewA != nullptr); + + // create RED image buffer + tbm_surface_h tbmTextureA = DSRenderEngineDaliTest::createTbmTexture( + imgWidth, imgHeight, 255, 0, 0, 255); + EXPECT_TRUE(tbmTextureA != nullptr); + + auto imageSourceBufferA = std::make_shared (imgWidth, imgHeight, IDSBuffer::FORMAT_ARGB8888, tbmTextureA); + EXPECT_TRUE(renderViewA->setBuffer(imageSourceBufferA)); + // -- end -- + + // for 2nd renderView -- begin -- + auto renderViewB = renderEngine->makeRenderView(); + EXPECT_TRUE(renderViewB != nullptr); + + // The buffer size of the second renderView is half of the first. + // create BLUE image buffer + tbm_surface_h tbmTextureB = DSRenderEngineDaliTest::createTbmTexture( + imgWidth/2, imgHeight/2, 0, 0, 255, 255); + EXPECT_TRUE(tbmTextureB != nullptr); + + auto imageSourceBufferB = std::make_shared (imgWidth/2, imgHeight/2, IDSBuffer::FORMAT_ARGB8888, tbmTextureB); + EXPECT_TRUE(renderViewB->setBuffer(imageSourceBufferB)); + // -- end -- + + // raise renderViewA to Top + renderViewA->raiseToTop(); + + EXPECT_TRUE(renderEngine->renderFrame()); + + /* + * Since renderViewA was created and added before renderViewB, + * renderViewB should be drawn above and renderViewA below. + * But because renderViewA called raiseToTop(), A rises up and covers B. + * + * ┌─────────────┐ + * │ │ + * │ A │ + * │ │ + * │ red │ + * │   │ + * └─────────────┘ + */ + + usleep(1000000); + + EXPECT_TRUE(bufferQueue->canAcquireBuffer(true)); + + // commit + EXPECT_TRUE(deviceHWC->commit()); + + usleep(1000000); + } +} + +TEST_F(DSRenderEngineDaliTest, RenderEngine_LowerToBottom) +{ + std::unique_ptr displayDevice = std::make_unique(); + std::list> outputList = displayDevice->getOutputList(); + EXPECT_TRUE(outputList.size() != 0); + + IDSDisplayDeviceOutput::ConnectorType connType; + IDSDisplayDeviceOutput::ConnectState connState; + std::shared_ptr deviceHWC; + + for (std::shared_ptr output : outputList) { + connType = output->getConnectType(); + EXPECT_TRUE(connType <= IDSDisplayDeviceOutput::TYPE_DSI); + connState = output->getConnectState(); + EXPECT_TRUE(connState <= IDSDisplayDeviceOutput::STATE_MODESET); + if (connState == IDSDisplayDeviceOutput::STATE_DISCONNECTED) + continue; + + auto bestMode = (output->getAvailableModes()).front(); + EXPECT_TRUE(output->setMode(bestMode) == true); + EXPECT_TRUE(output->getMode() == bestMode); + + deviceHWC = output->getHWC(); + EXPECT_TRUE(deviceHWC != nullptr); + + auto bufferQueue = deviceHWC->getTargetBufferQueue(); + EXPECT_TRUE(deviceHWC != nullptr); + + auto renderEngine = std::make_unique(bufferQueue); + EXPECT_TRUE(renderEngine != nullptr); + + int imgWidth = 500; + int imgHeight = 500; + + // for 1st renderView -- begin -- + auto renderViewA = renderEngine->makeRenderView(); + EXPECT_TRUE(renderViewA != nullptr); + + // create RED image buffer + tbm_surface_h tbmTextureA = DSRenderEngineDaliTest::createTbmTexture( + imgWidth, imgHeight, 255, 0, 0, 255); + EXPECT_TRUE(tbmTextureA != nullptr); + + auto imageSourceBufferA = std::make_shared (imgWidth, imgHeight, IDSBuffer::FORMAT_ARGB8888, tbmTextureA); + EXPECT_TRUE(renderViewA->setBuffer(imageSourceBufferA)); + // -- end -- + + // for 2nd renderView -- begin -- + auto renderViewB = renderEngine->makeRenderView(); + EXPECT_TRUE(renderViewB != nullptr); + + // The buffer size of the second renderView is half of the first. + // create BLUE image buffer + tbm_surface_h tbmTextureB = DSRenderEngineDaliTest::createTbmTexture( + imgWidth/2, imgHeight/2, 0, 0, 255, 255); + EXPECT_TRUE(tbmTextureB != nullptr); + + auto imageSourceBufferB = std::make_shared (imgWidth/2, imgHeight/2, IDSBuffer::FORMAT_ARGB8888, tbmTextureB); + EXPECT_TRUE(renderViewB->setBuffer(imageSourceBufferB)); + // -- end -- + + // raise renderViewA to Top + renderViewB->lowerToBottom(); + + EXPECT_TRUE(renderEngine->renderFrame()); + + /* + * Since renderViewA was created and added before renderViewB, + * renderViewB should be drawn above and renderViewA below. + * But because renderViewB called lowerToBottom(), B lower down and covered by A. + * + * ┌─────────────┐ + * │ │ + * │ A │ + * │ │ + * │ red │ + * │   │ + * └─────────────┘ + */ + + usleep(1000000); + + EXPECT_TRUE(bufferQueue->canAcquireBuffer(true)); + + // commit + EXPECT_TRUE(deviceHWC->commit()); + + usleep(1000000); + } +} + +TEST_F(DSRenderEngineDaliTest, RenderEngine_SetPosition) +{ + std::unique_ptr displayDevice = std::make_unique(); + std::list> outputList = displayDevice->getOutputList(); + EXPECT_TRUE(outputList.size() != 0); + + IDSDisplayDeviceOutput::ConnectorType connType; + IDSDisplayDeviceOutput::ConnectState connState; + std::shared_ptr deviceHWC; + + for (std::shared_ptr output : outputList) { + connType = output->getConnectType(); + EXPECT_TRUE(connType <= IDSDisplayDeviceOutput::TYPE_DSI); + connState = output->getConnectState(); + EXPECT_TRUE(connState <= IDSDisplayDeviceOutput::STATE_MODESET); + if (connState == IDSDisplayDeviceOutput::STATE_DISCONNECTED) + continue; + + auto bestMode = (output->getAvailableModes()).front(); + EXPECT_TRUE(output->setMode(bestMode) == true); + EXPECT_TRUE(output->getMode() == bestMode); + + deviceHWC = output->getHWC(); + EXPECT_TRUE(deviceHWC != nullptr); + + auto bufferQueue = deviceHWC->getTargetBufferQueue(); + EXPECT_TRUE(deviceHWC != nullptr); + + auto renderEngine = std::make_unique(bufferQueue); + EXPECT_TRUE(renderEngine != nullptr); + auto renderView = renderEngine->makeRenderView(); + EXPECT_TRUE(renderView != nullptr); + + renderView->setPosition(200, 200); + + int imgWidth = 500; + int imgHeight = 500; + + tbm_surface_h tbmTexture = DSRenderEngineDaliTest::createTbmTexture( + imgWidth, imgHeight, 255, 0, 0, 255); + EXPECT_TRUE(tbmTexture != nullptr); + + auto imageSourceBuffer = std::make_shared (imgWidth, imgHeight, IDSBuffer::FORMAT_ARGB8888, tbmTexture); + EXPECT_TRUE(renderView->setBuffer(imageSourceBuffer)); + EXPECT_TRUE(renderEngine->renderFrame()); + + usleep(1000000); + + EXPECT_TRUE(bufferQueue->canAcquireBuffer(true)); + + // commit + EXPECT_TRUE(deviceHWC->commit()); + + usleep(1000000); + } +} -- 2.7.4 From eb3e74057e8afcde13a3f29631e86c72ad85b78c Mon Sep 17 00:00:00 2001 From: Duna Oh Date: Wed, 2 Sep 2020 15:56:35 +0900 Subject: [PATCH 03/16] DSTizenAppinfoMgr: add more test cases for better code coverage Change-Id: I5d54261a7a1a00e87ddd2b8998928b2659058bf2 --- src/DSTizenAppinfo/DSTizenAppinfo.cpp | 27 +++++++++++++---- src/DSTizenAppinfo/DSTizenAppinfo.h | 14 ++++++--- src/DSTizenAppinfo/DSTizenAppinfoMgr.cpp | 52 ++++++++++++++++---------------- tests/DSTizenAppinfo-test.cpp | 52 +++++++++++++++++++++++++++----- 4 files changed, 100 insertions(+), 45 deletions(-) diff --git a/src/DSTizenAppinfo/DSTizenAppinfo.cpp b/src/DSTizenAppinfo/DSTizenAppinfo.cpp index 905ea02..aed4335 100644 --- a/src/DSTizenAppinfo/DSTizenAppinfo.cpp +++ b/src/DSTizenAppinfo/DSTizenAppinfo.cpp @@ -34,6 +34,10 @@ DSTizenAppinfo::DSTizenAppinfo(std::string appid) __appId = appid; } +DSTizenAppinfo::~DSTizenAppinfo() +{ +} + void DSTizenAppinfo::setAppId(std::string appId) { __appId = appId; @@ -44,31 +48,42 @@ void DSTizenAppinfo::setPid(pid_t pid) __pid = pid; } -DSTizenAppinfo::~DSTizenAppinfo() +void DSTizenAppinfo::setBaseOutputAvailable(bool isAvailable) +{ + __base_output_available = isAvailable; +} + +void DSTizenAppinfo::setBaseOutputWidth(int w) +{ + __base_output_width = w; +} + +void DSTizenAppinfo::setBaseOutputHeight(int h) { + __base_output_height = h; } -pid_t DSTizenAppinfo::pid() +pid_t DSTizenAppinfo::getPid() { return __pid; } -std::string DSTizenAppinfo::appId() +std::string DSTizenAppinfo::getAppId() { return __appId; } -bool DSTizenAppinfo::base_output_available() +bool DSTizenAppinfo::getBaseOutputAvailable() { return __base_output_available; } -int DSTizenAppinfo::base_output_width() +int DSTizenAppinfo::getBaseOutputWidth() { return __base_output_width; } -int DSTizenAppinfo::base_output_height() +int DSTizenAppinfo::getBaseOutputHeight() { return __base_output_height; } diff --git a/src/DSTizenAppinfo/DSTizenAppinfo.h b/src/DSTizenAppinfo/DSTizenAppinfo.h index 5eecb93..0564806 100644 --- a/src/DSTizenAppinfo/DSTizenAppinfo.h +++ b/src/DSTizenAppinfo/DSTizenAppinfo.h @@ -38,11 +38,15 @@ public: void setAppId(std::string appId); void setPid(pid_t pid); - pid_t pid(void); - std::string appId(void); - bool base_output_available(void); - int base_output_width(void); - int base_output_height(void); + void setBaseOutputAvailable(bool isAvailable); + void setBaseOutputWidth(int w); + void setBaseOutputHeight(int h); + + std::string getAppId(void); + pid_t getPid(void); + bool getBaseOutputAvailable(void); + int getBaseOutputWidth(void); + int getBaseOutputHeight(void); private: std::string __appId; diff --git a/src/DSTizenAppinfo/DSTizenAppinfoMgr.cpp b/src/DSTizenAppinfo/DSTizenAppinfoMgr.cpp index 356e865..e63dc22 100644 --- a/src/DSTizenAppinfo/DSTizenAppinfoMgr.cpp +++ b/src/DSTizenAppinfo/DSTizenAppinfoMgr.cpp @@ -54,17 +54,17 @@ std::shared_ptr DSTizenAppinfoMgrPrivate::getTizenAppinfo(std::s std::shared_ptr DSTizenAppinfoMgrPrivate::getTizenAppinfo(pid_t pid) { - std::shared_ptr ptr_appinfo; - DSTizenAppinfo * appinfo; + std::shared_ptr ptr_appinfo(nullptr); + DSTizenAppinfo * appinfo(nullptr); for (auto it = __appIdMap.begin(); it != __appIdMap.end(); it++) { ptr_appinfo = it->second; - if (ptr_appinfo == nullptr) - continue; - - appinfo = ptr_appinfo.get() ; - if ((appinfo) && (appinfo->pid() == pid)) { - return ptr_appinfo; + if (ptr_appinfo) + { + appinfo = ptr_appinfo.get() ; + if ((appinfo) && (appinfo->getPid() == pid)) { + return ptr_appinfo; + } } } return nullptr; @@ -72,7 +72,7 @@ std::shared_ptr DSTizenAppinfoMgrPrivate::getTizenAppinfo(pid_t std::shared_ptr DSTizenAppinfoMgrPrivate::addTizenAppinfo(std::string appId) { - std::shared_ptr appinfo = nullptr; + std::shared_ptr appinfo(nullptr); appinfo = std::make_shared(appId); if (appinfo != nullptr) { @@ -154,10 +154,12 @@ std::shared_ptr DSTizenAppinfoMgr::addTizenAppinfo(std::string a if (appinfo == nullptr) { appinfo = priv->addTizenAppinfo(appId); DSLOG_INF("DSTizenAppinfoMgr", "New TizenAppinfo(apppId:%s) added", appId.c_str()); + return appinfo; } - else + else { DSLOG_INF("DSTizenAppinfoMgr", "Adding TizenAppinfo(apppId:%s) failed..", appId.c_str()); - return appinfo; + return nullptr; + } } bool DSTizenAppinfoMgr::removeTizenAppinfo(std::string appId) @@ -167,16 +169,16 @@ bool DSTizenAppinfoMgr::removeTizenAppinfo(std::string appId) ret = priv->removeTizenAppinfo(appId); if (ret) - DSLOG_INF("DSTizenAppinfoMgr", "Removing TizenAppinfo(appId:%s) failedd..", appId.c_str()); - else DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) removed", appId.c_str()); + else + DSLOG_INF("DSTizenAppinfoMgr", "Removing TizenAppinfo(appId:%s) failed..", appId.c_str()); return ret; } void DSTizenAppinfoMgr::updateTizenAppinfo(std::string appId, pid_t pid) { - std::shared_ptr ptr_appinfo; - DSTizenAppinfo * appinfo; + std::shared_ptr ptr_appinfo(nullptr); + DSTizenAppinfo * appinfo(nullptr); ptr_appinfo = getTizenAppinfo(appId); if (ptr_appinfo == nullptr) @@ -192,23 +194,21 @@ void DSTizenAppinfoMgr::updateTizenAppinfo(std::string appId, pid_t pid) bool DSTizenAppinfoMgr::getBaseOutputResolution(pid_t pid, int *res_w, int *res_h) { - std::shared_ptr ptr_appinfo; - DSTizenAppinfo * appinfo; + std::shared_ptr ptr_appinfo(nullptr); + DSTizenAppinfo * appinfo(nullptr); ptr_appinfo = getTizenAppinfo(pid); - if (ptr_appinfo = nullptr) + if (ptr_appinfo == nullptr) return false; appinfo = ptr_appinfo.get(); - if (appinfo == nullptr) - return false; - - if (!appinfo->base_output_available()) - return false; + if ((appinfo) && (appinfo->getBaseOutputAvailable())) { + if (res_w) *res_w = appinfo->getBaseOutputWidth(); + if (res_h) *res_h = appinfo->getBaseOutputHeight(); - if (res_w) *res_w = appinfo->base_output_width(); - if (res_h) *res_h = appinfo->base_output_height(); - return true; + return true; + } + return false; } } diff --git a/tests/DSTizenAppinfo-test.cpp b/tests/DSTizenAppinfo-test.cpp index 2b2b7bc..10a0d8a 100644 --- a/tests/DSTizenAppinfo-test.cpp +++ b/tests/DSTizenAppinfo-test.cpp @@ -44,9 +44,20 @@ public: TEST_F(DSTizenAppinfoTest, NewTizenAppinfo) { std::string appId1{"com.appinfo.first"}; + std::string appId2{"com.appinfo.second"}; + DSTizenAppinfo *appinfo = new DSTizenAppinfo(appId1); EXPECT_TRUE(appinfo != nullptr); + pid_t pid = 1234; + appinfo->setPid(pid); + appinfo->setAppId(appId2); + EXPECT_TRUE(appinfo->getAppId().compare(appId2) == 0); + + EXPECT_TRUE(appinfo->getBaseOutputAvailable() == false); + EXPECT_TRUE(appinfo->getBaseOutputWidth() == 0); + EXPECT_TRUE(appinfo->getBaseOutputHeight() == 0); + if (appinfo) delete appinfo; } @@ -60,20 +71,45 @@ TEST_F(DSTizenAppinfoTest, NewTizenAppinfoMgr) { std::string appId1{"com.appinfo.first"}; std::string appId2{"com.appinfo.second"}; + std::string appId3{"com.appinfo.third"}; + pid_t pid1 = 1234, pid2 = 4321; + int res_w = 0, res_h = 0; - std::shared_ptr app1 = appinfoMgr->addTizenAppinfo(appId1); + std::shared_ptr app1(nullptr), app2(nullptr), app3(nullptr), temp(nullptr); + + app1 = appinfoMgr->addTizenAppinfo(appId1); EXPECT_TRUE(app1 != nullptr); - std::shared_ptr app2 = appinfoMgr->addTizenAppinfo(appId2); + app2 = appinfoMgr->addTizenAppinfo(appId2); EXPECT_TRUE(app2 != nullptr); + //FAIL to add a new appinfo using the existing appId + app3 = appinfoMgr->addTizenAppinfo(appId2); + EXPECT_TRUE(app3 == nullptr); + + temp = appinfoMgr->getTizenAppinfo(appId2); + EXPECT_TRUE(temp != nullptr); + + EXPECT_TRUE(appinfoMgr->removeTizenAppinfo(appId2) == true); + //FAIL to remove non-existing appinfo + EXPECT_TRUE(appinfoMgr->removeTizenAppinfo("com.appinfo.noname") == false); - std::shared_ptr temp = appinfoMgr->getTizenAppinfo(appId2); + app1->setPid(pid1); //app1 - (appId1, 1234) + temp = nullptr; + temp = appinfoMgr->getTizenAppinfo(pid1); //temp = app1 - (appId1, 1234) EXPECT_TRUE(temp != nullptr); - appinfoMgr->removeTizenAppinfo(appId2); - pid_t pid = 1234; - app1->setPid(pid); - temp = appinfoMgr->getTizenAppinfo(pid); - appinfoMgr->removeTizenAppinfo(temp->appId()); + appinfoMgr->updateTizenAppinfo(appId1, pid2); //app1 - (appId1, 4321) + appinfoMgr->updateTizenAppinfo(appId2, pid2); //no appinfo with appId2 + + EXPECT_TRUE(appinfoMgr->getBaseOutputResolution(pid1, &res_w, &res_h) == false); //no appinfo with pid1 + + app1->setBaseOutputAvailable(true); + app1->setBaseOutputWidth(720); + app1->setBaseOutputHeight(1280); + + EXPECT_TRUE(appinfoMgr->getBaseOutputResolution(pid2, &res_w, &res_h) == true); //app1 + EXPECT_TRUE(res_w == 720); + EXPECT_TRUE(res_h == 1280); + appinfoMgr->removeTizenAppinfo(app1->getAppId()); DSTizenAppinfoMgr::releaseInstance(); } -- 2.7.4 From 1e7e3fbe1de7c8f5b394d6f956ed209c06255125 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Wed, 2 Sep 2020 16:38:49 +0900 Subject: [PATCH 04/16] DSWindow: add set/getType APIs Change-Id: Ic199b31bd3df174bc818788cc4d3b6b79169f9be --- src/DSWindow/DSWindow.cpp | 26 +++++++++++++++++++++++++- src/DSWindow/DSWindow.h | 3 +++ src/DSWindow/DSWindowPrivate.h | 4 ++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/DSWindow/DSWindow.cpp b/src/DSWindow/DSWindow.cpp index eeecad6..300e29d 100644 --- a/src/DSWindow/DSWindow.cpp +++ b/src/DSWindow/DSWindow.cpp @@ -33,6 +33,7 @@ DSWindowPrivate::DSWindowPrivate(DSWindow *p_ptr) : DSObjectPrivate(p_ptr), __p_ptr(p_ptr), __parent(nullptr), + __type(0), __x(0), __y(0), __w(0), @@ -70,6 +71,16 @@ void DSWindowPrivate::destroy(void) { } +void DSWindowPrivate::setType(int type) +{ + __type = type; +} + +int DSWindowPrivate::getType(void) +{ + return __type; +} + void DSWindowPrivate::setParent(DSWindow *parent) { __parent = parent; @@ -279,6 +290,19 @@ void DSWindow::destroy(void) priv->destroy(); } +void DSWindow::setType(int type) +{ + DSLOG_DBG("DSWindow", "Set type (%d). DSWindow:%p", type, this); + DS_GET_PRIV(DSWindow); + priv->setType(type); +} + +int DSWindow::getType(void) +{ + DS_GET_PRIV(DSWindow); + return priv->getType(); +} + void DSWindow::setParent(DSWindow *parent) { if (parent == this) return; @@ -316,7 +340,7 @@ int DSWindow::showState(void) bool DSWindow::setTitle(const std::string &title) { - DSLOG_DBG("DSWindow", "title:%s", title.c_str()); + DSLOG_DBG("DSWindow", "title:%s. DSWindow:%p", title.c_str(), this); DS_GET_PRIV(DSWindow); return priv->setTitle(title); diff --git a/src/DSWindow/DSWindow.h b/src/DSWindow/DSWindow.h index 808cc03..ac303b7 100644 --- a/src/DSWindow/DSWindow.h +++ b/src/DSWindow/DSWindow.h @@ -50,6 +50,9 @@ public: bool create(std::shared_ptr waylandSurface); void destroy(void); + void setType(int type); + int getType(void); + void setParent(DSWindow *parent); DSWindow *getParent(void); diff --git a/src/DSWindow/DSWindowPrivate.h b/src/DSWindow/DSWindowPrivate.h index b7e35d5..eb71181 100644 --- a/src/DSWindow/DSWindowPrivate.h +++ b/src/DSWindow/DSWindowPrivate.h @@ -47,6 +47,9 @@ public: bool create(std::shared_ptr waylandSurface); void destroy(void); + void setType(int type); + int getType(void); + void setParent(DSWindow *parent); DSWindow *getParent(void); @@ -86,6 +89,7 @@ private: DSWindow *__parent; std::list __childList; + int __type; int __x, __y; unsigned int __w; unsigned int __h; -- 2.7.4 From ddbd1920ca4a30345095523fb83d904da4f391d4 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Wed, 2 Sep 2020 16:41:18 +0900 Subject: [PATCH 05/16] DSWindowShell: implements setType function Change-Id: I53d65ce7fb04463554b2d88ded0cd7475e1fd9ca --- src/DSWindowShell/DSWindowShell.cpp | 7 +++++-- src/DSWindowShell/DSWindowShellPrivate.cpp | 16 ++++++++++++---- src/DSWindowShell/DSWindowShellPrivate.h | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/DSWindowShell/DSWindowShell.cpp b/src/DSWindowShell/DSWindowShell.cpp index 2bbbe33..cba4622 100644 --- a/src/DSWindowShell/DSWindowShell.cpp +++ b/src/DSWindowShell/DSWindowShell.cpp @@ -126,6 +126,8 @@ bool DSWindowShell::setSkipFocus(bool set) bool DSWindowShell::setPosition(int x, int y) { + DSLOG_DBG("DSWindowShell", "DSWindowShell:%p, Set Position (%d, %d)", this, x, y); + DS_GET_PRIV(DSWindowShell); return priv->setPosition(x, y); } @@ -139,14 +141,15 @@ stPosition DSWindowShell::getPosition(void) bool DSWindowShell::setSize(unsigned int w, unsigned int h) { - DS_GET_PRIV(DSWindowShell); + DSLOG_DBG("DSWindowShell", "DSWindowShell:%p, Set Size (%d, %d)", this, w, h); + DS_GET_PRIV(DSWindowShell); return priv->setSize(w, h); } bool DSWindowShell::setGeometry(int x, int y, unsigned int w, unsigned int h) { - DSLOG_DBG("DSWindowShell", "Set Geometry (%d, %d, %d, %d)", x, y, w, h); + DSLOG_DBG("DSWindowShell", "DSWindowShell:%p, Set Geometry (%d, %d, %d, %d)", this, x, y, w, h); DS_GET_PRIV(DSWindowShell); return priv->setGeometry(x, y, w, h); diff --git a/src/DSWindowShell/DSWindowShellPrivate.cpp b/src/DSWindowShell/DSWindowShellPrivate.cpp index 0187256..45233be 100644 --- a/src/DSWindowShell/DSWindowShellPrivate.cpp +++ b/src/DSWindowShell/DSWindowShellPrivate.cpp @@ -162,11 +162,11 @@ void DSWindowShellPrivate::__handleAuxHint(stWindowAuxHint *hint) else set = false; - __handleUserGeometryHint(set); + __handleUserGeometryProperty(set); } } -bool DSWindowShellPrivate::__handleUserGeometryHint(bool setUserGeometry) +bool DSWindowShellPrivate::__handleUserGeometryProperty(bool setUserGeometry) { if (!__window) return false; @@ -586,11 +586,20 @@ int DSWindowShellPrivate::getIconicState(void) bool DSWindowShellPrivate::setType(int type) { + if (__window) + __window->setType(type); + + if (type == 9) // utility + __handleUserGeometryProperty(true); + return true; } int DSWindowShellPrivate::getType(void) { + if (__window) + return __window->getType(); + return 0; } @@ -650,8 +659,7 @@ bool DSWindowShellPrivate::getVkbdFloating() void DSWindowShellPrivate::setAllowUserGeometry(bool set) { - if (__window) - __window->allowUserGeometry(set); + __handleUserGeometryProperty(set); } diff --git a/src/DSWindowShell/DSWindowShellPrivate.h b/src/DSWindowShell/DSWindowShellPrivate.h index d9d864c..d882d40 100644 --- a/src/DSWindowShell/DSWindowShellPrivate.h +++ b/src/DSWindowShell/DSWindowShellPrivate.h @@ -130,7 +130,7 @@ private: struct stWindowAuxHint* __findAuxHint(int32_t id); void __handleAuxHint(stWindowAuxHint *hint); - bool __handleUserGeometryHint(bool setUserGeometry); + bool __handleUserGeometryProperty(bool setUserGeometry); void __onWindowBufferChanged(std::shared_ptr buffer); -- 2.7.4 From ec5a367ff87d037a7d6a92d5bcddd831abc4b302 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Wed, 2 Sep 2020 16:42:43 +0900 Subject: [PATCH 06/16] DSWaylandTizenPolicy: implements tizen_policy_set_type Change-Id: If368807a941efb2fa6637e950553643c493906b2 --- src/DSWaylandServer/DSWaylandTizenPolicy.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp index 0e7ba7f..d33e82a 100644 --- a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp +++ b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp @@ -160,7 +160,13 @@ void DSWaylandTizenPolicyPrivate::tizen_policy_set_role(Resource *resource, stru void DSWaylandTizenPolicyPrivate::tizen_policy_set_type(Resource *resource, struct ::wl_resource *surface, uint32_t win_type) { - DSLOG_DBG("TizenPolicyPriv", ""); + DSLOG_DBG("TizenPolicyPriv", "tizen_policy_set_type, wl_surface:%p, type:%d", surface, win_type); + + DSWaylandSurface *dswlSurface = DSWaylandSurface::fromWlResource(surface); + if (!dswlSurface) return; + if (!__wm) return; + + __wm->setWindowType(dswlSurface, win_type); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_conformant(Resource *resource, struct ::wl_resource *surface) -- 2.7.4 From c2c6e292269b749e84d8159f99f0b93043a9a2e9 Mon Sep 17 00:00:00 2001 From: Duna Oh Date: Wed, 2 Sep 2020 17:30:41 +0900 Subject: [PATCH 07/16] DSTizenAppinfo-test: add null checking Change-Id: I889ad97281da76110c93565bfc7c23aca87b082b --- tests/DSTizenAppinfo-test.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/DSTizenAppinfo-test.cpp b/tests/DSTizenAppinfo-test.cpp index 10a0d8a..ff9a6e9 100644 --- a/tests/DSTizenAppinfo-test.cpp +++ b/tests/DSTizenAppinfo-test.cpp @@ -49,17 +49,19 @@ TEST_F(DSTizenAppinfoTest, NewTizenAppinfo) DSTizenAppinfo *appinfo = new DSTizenAppinfo(appId1); EXPECT_TRUE(appinfo != nullptr); - pid_t pid = 1234; - appinfo->setPid(pid); - appinfo->setAppId(appId2); - EXPECT_TRUE(appinfo->getAppId().compare(appId2) == 0); + if (appinfo) + { + pid_t pid = 1234; + appinfo->setPid(pid); + appinfo->setAppId(appId2); + EXPECT_TRUE(appinfo->getAppId().compare(appId2) == 0); - EXPECT_TRUE(appinfo->getBaseOutputAvailable() == false); - EXPECT_TRUE(appinfo->getBaseOutputWidth() == 0); - EXPECT_TRUE(appinfo->getBaseOutputHeight() == 0); + EXPECT_TRUE(appinfo->getBaseOutputAvailable() == false); + EXPECT_TRUE(appinfo->getBaseOutputWidth() == 0); + EXPECT_TRUE(appinfo->getBaseOutputHeight() == 0); - if (appinfo) delete appinfo; + } } TEST_F(DSTizenAppinfoTest, NewTizenAppinfoMgr) -- 2.7.4 From cf7a9a7b6acca6e339b6994f7d334f4665bcf66d Mon Sep 17 00:00:00 2001 From: "Junseok, Kim" Date: Wed, 2 Sep 2020 16:34:31 +0900 Subject: [PATCH 08/16] DSObject: add LCOV_EXCL Change-Id: I831ace5fb745eb4616be05eb3d41cff43c00a857 --- src/DSObject/DSObjectPrivate.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/DSObject/DSObjectPrivate.cpp b/src/DSObject/DSObjectPrivate.cpp index e14a26a..af09cc5 100644 --- a/src/DSObject/DSObjectPrivate.cpp +++ b/src/DSObject/DSObjectPrivate.cpp @@ -84,6 +84,7 @@ namespace display_server __type_info.name = name; } +/*LCOV_EXCL_START*/ DSObjectPrivate& DSObjectPrivate::operator=(DSObjectPrivate &&p) { if (__p_ptr) @@ -101,5 +102,6 @@ namespace display_server return *this; } +/*LCOV_EXCL_STOP*/ } // namespace display_server -- 2.7.4 From ed39149758b51712686ff1c54211e676306acb79 Mon Sep 17 00:00:00 2001 From: "Junseok, Kim" Date: Wed, 2 Sep 2020 16:34:48 +0900 Subject: [PATCH 09/16] DSObject-test: add test for get/set property Change-Id: Iba8ea501a9cd1129634aa1cf67ab6a0724a0fbbf --- tests/DSObject-test.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/DSObject-test.cpp b/tests/DSObject-test.cpp index 48e3465..3f88433 100644 --- a/tests/DSObject-test.cpp +++ b/tests/DSObject-test.cpp @@ -146,6 +146,26 @@ TEST_F(DSObjectTest, DSObjectSetGetName) } } +TEST_F(DSObjectTest, DSObjectSetGetProperty) +{ + DSObject *obj = new DSObject(); + ASSERT_NE(obj, nullptr) << "Failed to create DSObject"; + + obj->setProperty("testKey", "testValue", DSPropertyType::STRING); + + try + { + std::string data = std::get(obj->getProperty("testKey")); + EXPECT_EQ(data, "testValue") << "value mismatch"; + } + catch(const DSPropertyException &e) + { + ASSERT_TRUE(false) << "Exception catched! : " << e.what(); + } + + delete obj; +} + TEST_F(DSObjectTest, NewDSObjecPrivate) { DSObject *obj = nullptr; @@ -196,6 +216,26 @@ TEST_F(DSObjectTest, DerivedObjectSetGetName) } } +TEST_F(DSObjectTest, DerivedObjectGetProperty) +{ + TempObject *obj = new TempObject(); + ASSERT_NE(obj, nullptr) << "Failed to create TempObject"; + + obj->setProperty("testKey", "testValue", DSPropertyType::STRING); + + try + { + std::string data = std::get(obj->getProperty("testKey")); + EXPECT_EQ(data, "testValue") << "value mismatch"; + } + catch(const DSPropertyException &e) + { + ASSERT_TRUE(false) << "Exception catched! : " << e.what(); + } + + delete obj; +} + TEST_F(DSObjectTest, DerivedObjectPimpl) { unsigned int vIn = 0xdeadbeaf; -- 2.7.4 From 11b49d4d8893124c87e3d7434da4f78b9eee4fe1 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 2 Sep 2020 17:42:24 +0900 Subject: [PATCH 10/16] samples: check the return values Change-Id: I85cae4a952afc980a8e282be1f4f34aa3f0e36d7 --- samples/exampleCompositor.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/samples/exampleCompositor.cpp b/samples/exampleCompositor.cpp index a7b23a2..872ec8c 100644 --- a/samples/exampleCompositor.cpp +++ b/samples/exampleCompositor.cpp @@ -66,8 +66,11 @@ public: __canvas = std::make_shared(); - __canvas->attachPolicyArea(__policyArea); - __canvas->attachDisplayArea(__displayArea); + if (!__canvas->attachPolicyArea(__policyArea)) + return nullptr; + + if (!__canvas->attachDisplayArea(__displayArea)) + return nullptr; __textInput = std::make_shared(); -- 2.7.4 From abf65ec3bf578ae9480bfe5a59fd86c298fb7a23 Mon Sep 17 00:00:00 2001 From: "Junseok, Kim" Date: Wed, 2 Sep 2020 14:38:27 +0900 Subject: [PATCH 11/16] DSProperty: move DSPropertyExceptopn from private class to public class Change-Id: Id68c0a4ebc1ed5c44b9cba8953fbd28c6e4b9ef5 --- src/DSProperty/DSProperty.h | 16 ++++++++++++++++ src/DSProperty/DSPropertyPrivate.h | 16 ---------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/DSProperty/DSProperty.h b/src/DSProperty/DSProperty.h index 3039fba..d3abdd0 100644 --- a/src/DSProperty/DSProperty.h +++ b/src/DSProperty/DSProperty.h @@ -32,6 +32,22 @@ namespace display_server class DSPropertyPrivate; +struct DSPropertyException : public std::exception +{ +public: + DSPropertyException(std::string str) + : __msg(str) + {} + + virtual const char *what() const noexcept override + { + return __msg.c_str(); + } + +private: + std::string __msg; +}; + class DSProperty { public: diff --git a/src/DSProperty/DSPropertyPrivate.h b/src/DSProperty/DSPropertyPrivate.h index d851a29..59c6002 100644 --- a/src/DSProperty/DSPropertyPrivate.h +++ b/src/DSProperty/DSPropertyPrivate.h @@ -43,22 +43,6 @@ using DSPropertyType = enum type { using DSPropertyVariant = std::variant; -struct DSPropertyException : public std::exception -{ -public: - DSPropertyException(std::string str) - : __msg(str) - {} - - virtual const char *what() const noexcept override - { - return __msg.c_str(); - } - -private: - std::string __msg; -}; - class DSPropertyPrivate { public: -- 2.7.4 From 4bd9747ae94990d88084f4b7febb6a8f502f48eb Mon Sep 17 00:00:00 2001 From: "Junseok, Kim" Date: Wed, 2 Sep 2020 14:39:40 +0900 Subject: [PATCH 12/16] DSProperty: change overrided private initializer using args Change-Id: Ia17d11ccca5e367c4d0d001c5980f9e7a3463d31 --- src/DSProperty/DSProperty.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DSProperty/DSProperty.cpp b/src/DSProperty/DSProperty.cpp index ac581a7..d65d029 100644 --- a/src/DSProperty/DSProperty.cpp +++ b/src/DSProperty/DSProperty.cpp @@ -31,7 +31,7 @@ DSProperty::DSProperty() {} DSProperty::DSProperty(std::string key, const DSPropertyVariant &data, DSPropertyType type) - : __d_ptr(new DSPropertyPrivate(this)) + : __d_ptr(new DSPropertyPrivate(this, key, data, type)) { __d_func()->__setKey(key); __d_func()->__setData(data, type); -- 2.7.4 From 4dedd02bd79fd29cb96b710a41b1100f8c13b04e Mon Sep 17 00:00:00 2001 From: "Junseok, Kim" Date: Wed, 2 Sep 2020 14:41:35 +0900 Subject: [PATCH 13/16] DSProperty-test: renew test codes renew test codes - divide tests by function group - use DSPropertyException - add new test for pointer data type Change-Id: I989d4b5aaa700fb2357fcfb807d86dab9418a17e --- tests/DSProperty-test.cpp | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/tests/DSProperty-test.cpp b/tests/DSProperty-test.cpp index 85ae4f1..9f71eb8 100644 --- a/tests/DSProperty-test.cpp +++ b/tests/DSProperty-test.cpp @@ -40,37 +40,61 @@ public: } }; -TEST_F(DSPropertyTest, CreateProperty) +TEST_F(DSPropertyTest, NewDSProperty) { /* DSProperty::DSProperty()*/ DSProperty *pro = new DSProperty(); ASSERT_NE(pro, nullptr) << "Failed to DSProperty()"; delete pro; +} +TEST_F(DSPropertyTest, SetGetProperty) +{ /* DSProperty::DSProperty(std::__cxx11::string, const DSPropertyVariant&, DSPropertyType) */ - pro = new DSProperty("testProperty", 2020, DSPropertyType::INTEGER); + DSProperty *pro = new DSProperty("testProperty", 2020, DSPropertyType::INTEGER); ASSERT_NE(pro, nullptr) << "Failed to DSProperty(key, data, type)"; ASSERT_EQ(pro->getKey(), "testProperty") << "Key value mismatch!"; ASSERT_EQ(pro->getType(), DSPropertyType::INTEGER) << "Type mistmatch!!"; try { int data = std::get(pro->getData()); ASSERT_TRUE(data == 2020) << "data value mismatch!!"; - } catch (std::bad_variant_access &e) { + } catch (DSPropertyException &e) { ASSERT_TRUE(false) << e.what(); } delete pro; +} +TEST_F(DSPropertyTest, NewProperty2) +{ /* DSProperty::DSProperty(DSProperty&) */ DSProperty pro_s("testProperty2", 20.20, DSPropertyType::DOUBLE); - pro = new DSProperty(pro_s); + DSProperty *pro = new DSProperty(pro_s); ASSERT_NE(pro, nullptr) << "Failed to DSProperty(const DSProperty&)"; ASSERT_EQ(pro->getKey(), "testProperty2") << "Key value mismatch!"; ASSERT_EQ(pro->getType(), DSPropertyType::DOUBLE) << "Type mistmatch!!"; try { double data = std::get(pro->getData()); ASSERT_TRUE(data == 20.20) << "data value mismatch!!"; - } catch (std::bad_variant_access &e) { + } catch (DSPropertyException &e) { ASSERT_TRUE(false) << e.what(); } delete pro; } + +TEST_F(DSPropertyTest, CopyAssign) +{ + /* DSProperty::DSProperty(DSProperty&) */ + DSObject *obj = new DSObject(); + DSProperty pro_s("testProperty3", (void *)obj, DSPropertyType::POINTER); + DSProperty pro = pro_s; + ASSERT_EQ(pro.getKey(), "testProperty3") << "Key value mismatch!"; + ASSERT_EQ(pro.getType(), DSPropertyType::POINTER) << "Type mistmatch!!"; + try { + DSObject *data = (DSObject *)std::get(pro.getData()); + ASSERT_TRUE(data == obj) << "data value mismatch!!"; + } catch (DSPropertyException &e) { + ASSERT_TRUE(false) << e.what(); + } + + if (obj) delete obj; +} -- 2.7.4 From c5e847d6467507329babc689be4eb4e66ba9bd9c Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 2 Sep 2020 14:01:32 +0900 Subject: [PATCH 14/16] tests : add some tests for DSCanvas Change-Id: I2fa4bbf489bd27ece922fc3a3cd82a76624dc980 --- tests/DSCanvas-test.cpp | 76 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 2 deletions(-) diff --git a/tests/DSCanvas-test.cpp b/tests/DSCanvas-test.cpp index a81a83e..0fd165f 100644 --- a/tests/DSCanvas-test.cpp +++ b/tests/DSCanvas-test.cpp @@ -50,7 +50,7 @@ TEST_F(DSCanvasTest, NewDSCanvas) EXPECT_TRUE(canvas != nullptr); } -TEST_F(DSCanvasTest, attachPolicyArea) +TEST_F(DSCanvasTest, attachPolicyArea_Positive1) { auto canvas = std::make_unique(); EXPECT_TRUE(canvas != nullptr); @@ -59,7 +59,56 @@ TEST_F(DSCanvasTest, attachPolicyArea) EXPECT_TRUE(canvas->attachPolicyArea(policyArea) == true); } -TEST_F(DSCanvasTest, displayArea_Negetive1) +TEST_F(DSCanvasTest, attachPolicyArea_Twice) +{ + auto canvas = std::make_unique(); + EXPECT_TRUE(canvas != nullptr); + auto policyArea = std::make_shared(); + EXPECT_TRUE(policyArea != nullptr); + EXPECT_TRUE(canvas->attachPolicyArea(policyArea) == true); + + EXPECT_TRUE(canvas->attachPolicyArea(policyArea) == false); +} + +TEST_F(DSCanvasTest, attachPolicyArea_N_DisplayArea) +{ + auto canvas = std::make_unique(); + EXPECT_TRUE(canvas != nullptr); + + auto policyArea = std::make_shared(); + EXPECT_TRUE(policyArea != nullptr); + EXPECT_TRUE(canvas->attachPolicyArea(policyArea) == true); + + auto displayDevice = std::make_unique(); + auto outputList = displayDevice->getOutputList(); + for (auto displayDeviceOutput : outputList) { + auto output = std::make_shared(displayDeviceOutput); + EXPECT_TRUE(output != nullptr); + EXPECT_TRUE(output->applyResolutionAuto() == true); + auto displayArea = std::make_shared(output); + EXPECT_TRUE(displayArea != nullptr); + EXPECT_TRUE(canvas->attachDisplayArea(displayArea) == true); + } +} + +TEST_F(DSCanvasTest, attachDisplayArea_Positive1) +{ + auto canvas = std::make_unique(); + EXPECT_TRUE(canvas != nullptr); + + auto displayDevice = std::make_unique(); + auto outputList = displayDevice->getOutputList(); + for (auto displayDeviceOutput : outputList) { + auto output = std::make_shared(displayDeviceOutput); + EXPECT_TRUE(output != nullptr); + EXPECT_TRUE(output->applyResolutionAuto() == true); + auto displayArea = std::make_shared(output); + EXPECT_TRUE(displayArea != nullptr); + EXPECT_TRUE(canvas->attachDisplayArea(displayArea) == true); + } +} + +TEST_F(DSCanvasTest, attachDisplayArea_Twice) { auto canvas = std::make_unique(); EXPECT_TRUE(canvas != nullptr); @@ -72,6 +121,29 @@ TEST_F(DSCanvasTest, displayArea_Negetive1) EXPECT_TRUE(output->applyResolutionAuto() == true); auto displayArea = std::make_shared(output); EXPECT_TRUE(displayArea != nullptr); + EXPECT_TRUE(canvas->attachDisplayArea(displayArea) == true); + EXPECT_TRUE(canvas->attachDisplayArea(displayArea) == false); } } + +TEST_F(DSCanvasTest, attachDisplayArea_N_PolicyArea) +{ + auto canvas = std::make_unique(); + EXPECT_TRUE(canvas != nullptr); + + auto displayDevice = std::make_unique(); + auto outputList = displayDevice->getOutputList(); + for (auto displayDeviceOutput : outputList) { + auto output = std::make_shared(displayDeviceOutput); + EXPECT_TRUE(output != nullptr); + EXPECT_TRUE(output->applyResolutionAuto() == true); + auto displayArea = std::make_shared(output); + EXPECT_TRUE(displayArea != nullptr); + EXPECT_TRUE(canvas->attachDisplayArea(displayArea) == true); + + auto policyArea = std::make_shared(); + EXPECT_TRUE(policyArea != nullptr); + EXPECT_TRUE(canvas->attachPolicyArea(policyArea) == true); + } +} -- 2.7.4 From 6e651658ebff8effa167e5bfd15ceeac1f01e186 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 2 Sep 2020 14:06:36 +0900 Subject: [PATCH 15/16] tests: add getOutput test Change-Id: Id47bb015bf9358cfb3da0c0f9fe5527baba95f5b --- tests/DSDisplayArea-test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/DSDisplayArea-test.cpp b/tests/DSDisplayArea-test.cpp index 3fb3af7..ef97af1 100644 --- a/tests/DSDisplayArea-test.cpp +++ b/tests/DSDisplayArea-test.cpp @@ -70,5 +70,6 @@ TEST_F(DSDisplayAreaTest, BasicMethods) auto displayArea = std::make_shared(output); EXPECT_TRUE(displayArea->getWidth() == output->getResolutionWidth()); EXPECT_TRUE(displayArea->getHeight() == output->getResolutionHeight()); + EXPECT_TRUE(displayArea->getOutput() == output); } } -- 2.7.4 From 8d55bd62398e7dd275b26b6ebabe51e3b428c333 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 2 Sep 2020 14:52:41 +0900 Subject: [PATCH 16/16] DSDisplayDeviceHWCTDMImpl: add LCOV exceptions Change-Id: I09abcc5167dc47655349416069b56273d261810f --- src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp | 14 ++++++++++++++ .../DSDisplayDeviceHWCWindowTDMTargetImpl.cpp | 10 +++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp index b6be04f..2355e11 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp @@ -52,7 +52,9 @@ std::shared_ptr DSDisplayDeviceHWCTDMImpl::getTargetBufferQueue( tqueue = tdm_hwc_get_client_target_buffer_queue(__thwc, &terror); if (terror != TDM_ERROR_NONE) { +/*LCOV_EXCL_START*/ DSLOG_ERR("HWCTDM", "tdm_hwc_get_client_target_buffer_queue fails."); +/*LCOV_EXCL_STOP*/ } __bufferQueue = std::make_shared(tqueue); @@ -70,8 +72,10 @@ bool DSDisplayDeviceHWCTDMImpl::setTargetBuffer(std::shared_ptr buffe terror = tdm_hwc_set_client_target_buffer(__thwc, (tbm_surface_h)buffer->getNativeBuffer(), fb_damage); if (terror != TDM_ERROR_NONE) { +/*LCOV_EXCL_START*/ DSLOG_ERR("TDM_HWC", "tdm_hwc_set_client_target_buffer fails."); return false; +/*LCOV_EXCL_STOP*/ } return true; @@ -85,14 +89,18 @@ std::shared_ptr DSDisplayDeviceHWCTDMImpl::makeHWCWin twindow = tdm_hwc_create_window(__thwc, &terror); if (!twindow) { +/*LCOV_EXCL_START*/ DSLOG_ERR("HWCTDM", "tdm_hwc_create_window fails."); return nullptr; +/*LCOV_EXCL_STOP*/ } deviceHWCWindow = std::make_shared(twindow); if (!deviceHWCWindow) { +/*LCOV_EXCL_START*/ DSLOG_ERR("HWCTDM", "new DSDisplayDeviceHWCWindowTDMImpl fails."); return nullptr; +/*LCOV_EXCL_STOP*/ } return deviceHWCWindow; @@ -152,9 +160,11 @@ bool DSDisplayDeviceHWCTDMImpl::commit() //TODO: commit with async terror = tdm_hwc_commit(__thwc, true, NULL, NULL); if (terror != TDM_ERROR_NONE) { +/*LCOV_EXCL_START*/ DSLOG_ERR("HWCTDM", "tdm_hwc_commit fails."); __presentFrameDoneWindows(); return false; +/*LCOV_EXCL_STOP*/ } DSLOG_INF("HWCTDM", "HWC COMMIT COMMIT COMMIT ~#######"); @@ -186,9 +196,11 @@ bool DSDisplayDeviceHWCTDMImpl::__validate(uint32_t &numChanges) // validate thwc_windows terror = tdm_hwc_validate(__thwc, thwc_windows, numVisibleHWCWins, &numChanges); if (terror != TDM_ERROR_NONE) { +/*LCOV_EXCL_START*/ DSLOG_ERR("TDM_HWC", "tdm_hwc_validate fails."); free(thwc_windows); return false; +/*LCOV_EXCL_STOP*/ } free(thwc_windows); @@ -242,8 +254,10 @@ bool DSDisplayDeviceHWCTDMImpl::__acceptValidation() // TODO: accept_validation is depending on the transitions. terror = tdm_hwc_accept_validation(__thwc); if (terror != TDM_ERROR_NONE) { +/*LCOV_EXCL_STOP*/ DSLOG_ERR("TDM_HWC", "tdm_hwc_accept_validation fails."); return false; +/*LCOV_EXCL_STOP*/ } return true; diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp index 37269ec..fc67c7c 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp @@ -34,7 +34,9 @@ DSDisplayDeviceHWCWindowTDMTargetImpl::DSDisplayDeviceHWCWindowTDMTargetImpl(IDS __ecoreFdHandler(nullptr) { if (!ecore_init()) { +/*LCOV_EXCL_START*/ DSLOG_ERR("EventLoop", "ecore_init() fails."); +/*LCOV_EXCL_STOP*/ } __eventFd = eventfd(0, EFD_NONBLOCK); @@ -93,6 +95,7 @@ void DSDisplayDeviceHWCWindowTDMTargetImpl::onPresentFrameDone() Eina_Bool DSDisplayDeviceHWCWindowTDMTargetImpl::__onFdHandler(void *data, Ecore_Fd_Handler *hdlr) { +/*LCOV_EXCL_START*/ int len; int fd; char buffer[64]; @@ -106,6 +109,7 @@ Eina_Bool DSDisplayDeviceHWCWindowTDMTargetImpl::__onFdHandler(void *data, Ecore DSLOG_WRN("DSDisplayDeviceHWCWindowTDMTargetImpl", "failed to read buffer from event fd:%m"); return ECORE_CALLBACK_RENEW; +/*LCOV_EXCL_STOP*/ } void DSDisplayDeviceHWCWindowTDMTargetImpl::__onAcquirable(void *data) @@ -114,8 +118,12 @@ void DSDisplayDeviceHWCWindowTDMTargetImpl::__onAcquirable(void *data) int ret; ret = write(__eventFd, &value, sizeof(value)); - if (ret == -1) + if (ret == -1) { +/*LCOV_EXCL_START*/ DSLOG_WRN("DSDisplayDeviceHWCWindowTDMTargetImpl", "failed to write a value on event fd:%m"); +/*LCOV_EXCL_STOP*/ + } + } } -- 2.7.4