From 0da9e35b714fd9f7f3ae22f6777685a202e28af7 Mon Sep 17 00:00:00 2001 From: jeon Date: Tue, 1 Sep 2020 18:07:32 +0900 Subject: [PATCH 01/16] DSTizenInputDeviceManager: set LOCV_EXEC block for tizen_input_device_manager protocols Change-Id: Ief6deb2291155671ac0513d73f96a8635babffca --- .../DSWaylandTizenInputDeviceManager.cpp | 10 ++++++++-- .../dswayland-server-tizen-extension.cpp | 18 ++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandTizenInputDeviceManager.cpp b/src/DSWaylandServer/DSWaylandTizenInputDeviceManager.cpp index d30d185..0da0a99 100644 --- a/src/DSWaylandServer/DSWaylandTizenInputDeviceManager.cpp +++ b/src/DSWaylandServer/DSWaylandTizenInputDeviceManager.cpp @@ -47,6 +47,7 @@ void DSWaylandTizenInputDeviceManagerPrivate::createGlobal(struct ::wl_display * tizen_input_device_manager::init(__display, 3); } +/*LCOV_EXCL_START*/ void DSWaylandTizenInputDeviceManagerPrivate::handleDeviceAdd(DSInputDevice *device) { DS_GET_PUB(DSWaylandTizenInputDeviceManager); @@ -103,6 +104,7 @@ void DSWaylandTizenInputDeviceManagerPrivate::tizen_input_device_manager_destroy void DSWaylandTizenInputDeviceManagerPrivate::tizen_input_device_manager_generate_axis(tizen_input_device_manager::Resource *resource, uint32_t type, wl_fixed_t value) { } +/*LCOV_EXCL_STOP*/ DSWaylandTizenInputDeviceManager::DSWaylandTizenInputDeviceManager(DSWaylandCompositor *compositor) @@ -120,6 +122,7 @@ DSWaylandTizenInputDeviceManager::~DSWaylandTizenInputDeviceManager() { } +/*LCOV_EXCL_START*/ void DSWaylandTizenInputDeviceManager::slotDeviceAdd(std::shared_ptr device) { DS_GET_PRIV(DSWaylandTizenInputDeviceManager); @@ -134,7 +137,7 @@ void DSWaylandTizenInputDeviceManager::slotDeviceRemove(std::shared_ptrprint(); } - +/*LCOV_EXCL_STOP*/ DSWaylandTizenInputDevicePrivate::DSWaylandTizenInputDevicePrivate(DSWaylandTizenInputDevice *p_ptr) : DSObjectPrivate(p_ptr), @@ -146,6 +149,7 @@ DSWaylandTizenInputDevicePrivate::~DSWaylandTizenInputDevicePrivate() { } +/*LCOV_EXCL_START*/ void DSWaylandTizenInputDevicePrivate::tizen_input_device_select_axes(Resource *resource, wl_array *axes) { } @@ -172,7 +176,7 @@ void DSWaylandTizenInputDevicePrivate::sendDeviceInfo(void *resource, DSInputDev wl_array_release(&axes); } - +/*LCOV_EXCL_STOP*/ DSWaylandTizenInputDevice::DSWaylandTizenInputDevice(DSWaylandTizenInputDeviceManager *tzInputDeviceManager) : DS_INIT_PRIVATE_PTR(DSWaylandTizenInputDevice), @@ -184,6 +188,7 @@ DSWaylandTizenInputDevice::~DSWaylandTizenInputDevice() { } +/*LCOV_EXCL_START*/ void *DSWaylandTizenInputDevice::addDevice(void *client, DSInputDevice *device) { DS_GET_PRIV(DSWaylandTizenInputDevice); @@ -199,6 +204,7 @@ void DSWaylandTizenInputDevice::sendDeviceInfo(void *resource, DSInputDevice *de priv->sendDeviceInfo(resource, device); } +/*LCOV_EXCL_STOP*/ } // namespace display_server diff --git a/src/DSWaylandServer/dswayland-server-tizen-extension.cpp b/src/DSWaylandServer/dswayland-server-tizen-extension.cpp index 3fa4a81..1fe2703 100644 --- a/src/DSWaylandServer/dswayland-server-tizen-extension.cpp +++ b/src/DSWaylandServer/dswayland-server-tizen-extension.cpp @@ -5529,6 +5529,7 @@ namespace DSWaylandServer { } /*LCOV_EXCL_STOP*/ +/*LCOV_EXCL_START*/ tizen_input_device_manager::tizen_input_device_manager(struct ::wl_client *client, uint32_t id, int version) : m_resource_map() , m_resource(NULL) @@ -5558,6 +5559,7 @@ namespace DSWaylandServer { { init(resource); } +/*LCOV_EXCL_STOP*/ tizen_input_device_manager::tizen_input_device_manager() : m_resource_map() @@ -5582,6 +5584,7 @@ namespace DSWaylandServer { } } +/*LCOV_EXCL_START*/ void tizen_input_device_manager::init(struct ::wl_client *client, uint32_t id, int version) { m_resource = bind(client, id, version); @@ -5598,6 +5601,7 @@ namespace DSWaylandServer { m_resource_map.insert(std::pair(client, resource)); return resource; } +/*LCOV_EXCL_STOP*/ tizen_input_device_manager::Resource *tizen_input_device_manager::add(struct ::wl_client *client, uint32_t id, int version) { @@ -5696,6 +5700,7 @@ namespace DSWaylandServer { tizen_input_device_manager::handle_generate_axis }; +/*LCOV_EXCL_START*/ void tizen_input_device_manager::tizen_input_device_manager_block_events(Resource *, uint32_t , uint32_t , uint32_t ) { } @@ -5740,7 +5745,6 @@ namespace DSWaylandServer { { } - void tizen_input_device_manager::handle_block_events( ::wl_client *client, struct wl_resource *resource, @@ -5985,8 +5989,9 @@ namespace DSWaylandServer { tizen_input_device_manager_send_block_expired( resource); } +/*LCOV_EXCL_STOP*/ - +/*LCOV_EXCL_START*/ tizen_input_device::tizen_input_device(struct ::wl_client *client, uint32_t id, int version) : m_resource_map() , m_resource(NULL) @@ -6016,6 +6021,7 @@ namespace DSWaylandServer { { init(resource); } +/*LCOV_EXCL_STOP*/ tizen_input_device::tizen_input_device() : m_resource_map() @@ -6040,6 +6046,7 @@ namespace DSWaylandServer { } } +/*LCOV_EXCL_START*/ void tizen_input_device::init(struct ::wl_client *client, uint32_t id, int version) { m_resource = bind(client, id, version); @@ -6049,6 +6056,7 @@ namespace DSWaylandServer { { m_resource = bind(resource); } +/*LCOV_EXCL_STOP*/ tizen_input_device::Resource *tizen_input_device::add(struct ::wl_client *client, int version) { @@ -6057,6 +6065,7 @@ namespace DSWaylandServer { return resource; } +/*LCOV_EXCL_START*/ tizen_input_device::Resource *tizen_input_device::add(struct ::wl_client *client, uint32_t id, int version) { Resource *resource = bind(client, id, version); @@ -6072,6 +6081,7 @@ namespace DSWaylandServer { m_displayDestroyedListener.parent = this; wl_display_add_destroy_listener(display, &m_displayDestroyedListener); } +/*LCOV_EXCL_STOP*/ const struct wl_interface *tizen_input_device::interface() { @@ -6091,11 +6101,13 @@ namespace DSWaylandServer { { } +/*LCOV_EXCL_START*/ void tizen_input_device::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) { tizen_input_device *that = static_cast(data); that->add(client, id, std::min(that->m_globalVersion, version)); } +/*LCOV_EXCL_STOP*/ void tizen_input_device::display_destroy_func(struct ::wl_listener *listener, void *data) { @@ -6145,6 +6157,7 @@ namespace DSWaylandServer { tizen_input_device::handle_release }; +/*LCOV_EXCL_START*/ void tizen_input_device::tizen_input_device_select_axes(Resource *, struct ::wl_array *) { } @@ -6246,6 +6259,7 @@ namespace DSWaylandServer { axis_type, value); } +/*LCOV_EXCL_STOP*/ /*LCOV_EXCL_START*/ tizen_launchscreen::tizen_launchscreen(struct ::wl_client *client, uint32_t id, int version) -- 2.7.4 From c24f43e4a5e1e0c75093810d127ed0c875a17c41 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Tue, 1 Sep 2020 16:39:21 +0900 Subject: [PATCH 02/16] DSWindowShell: add null check code in constructor Change-Id: Iaa05f798265c23120663516f3c8576f9f16a08f8 --- src/DSWindowShell/DSWindowShellPrivate.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DSWindowShell/DSWindowShellPrivate.cpp b/src/DSWindowShell/DSWindowShellPrivate.cpp index 4e939d7..0187256 100644 --- a/src/DSWindowShell/DSWindowShellPrivate.cpp +++ b/src/DSWindowShell/DSWindowShellPrivate.cpp @@ -75,7 +75,8 @@ DSWindowShellPrivate::DSWindowShellPrivate(DSWindowShell *p_ptr, DSWindow *windo __changedGeometry(false), __visible(false) { - __window->registerCallbackBufferChanged(this, std::bind(&DSWindowShellPrivate::__onWindowBufferChanged, this, std::placeholders::_1)); + if (__window) + __window->registerCallbackBufferChanged(this, std::bind(&DSWindowShellPrivate::__onWindowBufferChanged, this, std::placeholders::_1)); } DSWindowShellPrivate::~DSWindowShellPrivate() -- 2.7.4 From d7ce62b3cbedf109fce7a7582ec72abc369cb23c Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Tue, 1 Sep 2020 16:40:24 +0900 Subject: [PATCH 03/16] DSWindowShell: add testcase Change-Id: I5f9a9f76fd21299f43b203f9ff3c06e13edc1d0d --- tests/DSWindowShell-test.cpp | 370 +++++++++++++++++++++++++++++-------------- 1 file changed, 249 insertions(+), 121 deletions(-) diff --git a/tests/DSWindowShell-test.cpp b/tests/DSWindowShell-test.cpp index 0ac8b4d..43ce069 100644 --- a/tests/DSWindowShell-test.cpp +++ b/tests/DSWindowShell-test.cpp @@ -23,8 +23,11 @@ #include "libds-tests.h" #include "DSObject.h" +#include "DSZone.h" #include "DSWindow.h" #include "DSWindowShell.h" +#include "IDSWaylandShell.h" +#include "DSWaylandZxdgShellV6.h" using namespace display_server; @@ -40,72 +43,150 @@ public: TEST_F(DSWindowShellTest, NewDSWindowShell) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); } TEST_F(DSWindowShellTest, create_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); - EXPECT_TRUE(shell->create(nullptr) == true); + EXPECT_TRUE(winShell->create(nullptr) == true); } TEST_F(DSWindowShellTest, create_P2) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); - EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); +} + +TEST_F(DSWindowShellTest, zone_P1) +{ + auto zone = std::make_shared(); + auto window = std::make_shared(); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); + + EXPECT_TRUE(winShell->setZone(zone.get())); + + DSZone *tZone = winShell->getZone(); + EXPECT_TRUE(zone.get() == tZone); +} + +TEST_F(DSWindowShellTest, shellSurface_P1) +{ +/* + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + EXPECT_TRUE(comp != nullptr); + + auto zone = std::make_shared(); + auto window = std::make_shared(); + auto zxdgShell = std::make_shared(comp); + auto shellSurface = std::make_shared(zxdgShell.get()); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); + + winShell->setShellSurface(shellSurface.get()); + + DSWaylandZxdgSurfaceV6 *tShellSurface = (DSWaylandZxdgSurfaceV6*)winShell->getShellSurface(); + EXPECT_TRUE(shellSurface.get() == tShellSurface); + + DSWaylandCompositor::releaseInstance(); +*/ +} + +TEST_F(DSWindowShellTest, window_P1) +{ + auto zone = std::make_shared(); + auto window = std::make_shared(); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); + + DSWindow *tWindow = winShell->getWindow(); + EXPECT_TRUE(window.get() == tWindow); } TEST_F(DSWindowShellTest, parent_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); - EXPECT_TRUE(shell->getParent() == nullptr); + EXPECT_TRUE(winShell->getParent() == nullptr); auto childWindow = std::make_shared(); - std::unique_ptr childShell = std::make_unique(childWindow.get()); - EXPECT_TRUE(childShell != nullptr); + std::unique_ptr childWinShell = std::make_unique(childWindow.get()); + EXPECT_TRUE(childWinShell != nullptr); - EXPECT_TRUE(childShell->setParent(shell.get()) == true); - EXPECT_TRUE(childShell->getParent() == shell.get()); + EXPECT_TRUE(childWinShell->setParent(winShell.get()) == true); + EXPECT_TRUE(childWinShell->getParent() == winShell.get()); // test for set parent each other - EXPECT_TRUE(shell->setParent(childShell.get()) == false); + EXPECT_TRUE(winShell->setParent(childWinShell.get()) == false); // test for set parent itself - EXPECT_TRUE(childShell->setParent(childShell.get()) == false); + EXPECT_TRUE(childWinShell->setParent(childWinShell.get()) == false); + + EXPECT_TRUE(childWinShell->setParent(nullptr) == true); + EXPECT_TRUE(childWinShell->getParent() == nullptr); +} + +TEST_F(DSWindowShellTest, child_P1) +{ + auto zone = std::make_shared(); + auto window = std::make_shared(); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); + + auto cWindow = std::make_shared(); + std::unique_ptr cShell = std::make_unique(cWindow.get()); + + EXPECT_TRUE(winShell->addChild(cShell.get())); + winShell->removeChild(cShell.get()); +} + +TEST_F(DSWindowShellTest, setTitle_P1) +{ + auto window = std::make_shared(); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); + + EXPECT_TRUE(winShell->setTitle("test setTitle") == true); +} + +TEST_F(DSWindowShellTest, setSkipFocus_P1) +{ + auto window = std::make_shared(); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); - EXPECT_TRUE(childShell->setParent(nullptr) == true); - EXPECT_TRUE(childShell->getParent() == nullptr); + EXPECT_TRUE(winShell->setSkipFocus(true)); } TEST_F(DSWindowShellTest, setPosition_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); - EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(shell->setPosition(100, 150) == true); + EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(winShell->setPosition(100, 150) == true); } TEST_F(DSWindowShellTest, getPosition_P1) { stPosition pos; auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); - EXPECT_TRUE(shell->setPosition(100, 150) == true); - pos = shell->getPosition(); + EXPECT_TRUE(winShell->setPosition(100, 150) == true); + pos = winShell->getPosition(); EXPECT_TRUE(pos.x == 0); EXPECT_TRUE(pos.y == 0); @@ -115,15 +196,15 @@ TEST_F(DSWindowShellTest, getPosition_P2) { stPosition pos; auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); // set user geometry - shell->addAuxHint(1, "wm.policy.win.user.geometry", "1"); + winShell->addAuxHint(1, "wm.policy.win.user.geometry", "1"); - EXPECT_TRUE(shell->setPosition(100, 150) == true); + EXPECT_TRUE(winShell->setPosition(100, 150) == true); - pos = shell->getPosition(); + pos = winShell->getPosition(); EXPECT_TRUE(pos.x == 100); EXPECT_TRUE(pos.y == 150); @@ -132,11 +213,11 @@ TEST_F(DSWindowShellTest, getPosition_P2) TEST_F(DSWindowShellTest, setSize_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); - EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(shell->setSize(720, 1280) == true); + EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(winShell->setSize(720, 1280) == true); } TEST_F(DSWindowShellTest, Geometry_P1) @@ -144,11 +225,11 @@ TEST_F(DSWindowShellTest, Geometry_P1) stGeometry geo; auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); - shell->setGeometry(100, 150, 480, 800); - geo = shell->getGeometry(); + winShell->setGeometry(100, 150, 480, 800); + geo = winShell->getGeometry(); EXPECT_TRUE(geo.x == 0); EXPECT_TRUE(geo.y == 0); @@ -161,14 +242,14 @@ TEST_F(DSWindowShellTest, Geometry_P2) stGeometry geo; auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); // set user geometry - shell->addAuxHint(1, "wm.policy.win.user.geometry", "1"); + winShell->addAuxHint(1, "wm.policy.win.user.geometry", "1"); - shell->setGeometry(100, 150, 480, 800); - geo = shell->getGeometry(); + winShell->setGeometry(100, 150, 480, 800); + geo = winShell->getGeometry(); EXPECT_TRUE(geo.x == 100); EXPECT_TRUE(geo.y == 150); @@ -176,129 +257,148 @@ TEST_F(DSWindowShellTest, Geometry_P2) EXPECT_TRUE(geo.h == 800); } +TEST_F(DSWindowShellTest, auxHints_P1) +{ + auto window = std::make_shared(); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); + + winShell->addAuxHint(1, "wm.policy.win.user.geometry", "1"); + winShell->changeAuxHint(1, "0"); + winShell->removeAuxHint(1); +} + TEST_F(DSWindowShellTest, show_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); - EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(shell->show() == true); + EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(winShell->show() == true); } TEST_F(DSWindowShellTest, hide_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); - EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(shell->hide(true) == true); + EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(winShell->hide(true) == true); } TEST_F(DSWindowShellTest, showState_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); - EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(shell->showState() == 0); + EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(winShell->showState() == 0); } TEST_F(DSWindowShellTest, setLayer_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); - EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(shell->setLayer(100) == true); + EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(winShell->setLayer(100) == true); } TEST_F(DSWindowShellTest, getLayer_P1) { int layer = -1; auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); - EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(shell->setLayer(100) == true); + EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(winShell->setLayer(100) == true); - layer = shell->getLayer(); + layer = winShell->getLayer(); EXPECT_TRUE(layer == 100); } TEST_F(DSWindowShellTest, raise_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); - EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(shell->raise() == true); + EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(winShell->raise() == true); } TEST_F(DSWindowShellTest, lower_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); - EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(shell->lower() == true); + EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(winShell->lower() == true); } TEST_F(DSWindowShellTest, setFocus_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); - EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(shell->setFocus() == true); + EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(winShell->setFocus() == true); } TEST_F(DSWindowShellTest, isFocused_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); - EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(shell->setFocus() == true); + EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(winShell->setFocus() == true); - EXPECT_TRUE(shell->isFocused() == true); + EXPECT_TRUE(winShell->isFocused() == true); } TEST_F(DSWindowShellTest, unsetFocus) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); - EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(shell->setFocus() == true); - EXPECT_TRUE(shell->isFocused() == true); - EXPECT_TRUE(shell->unsetFocus() == true); - EXPECT_TRUE(shell->isFocused() != true); + EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); + EXPECT_TRUE(winShell->setFocus() == true); + EXPECT_TRUE(winShell->isFocused() == true); + EXPECT_TRUE(winShell->unsetFocus() == true); + EXPECT_TRUE(winShell->isFocused() != true); } TEST_F(DSWindowShellTest, activate_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); - // do something + EXPECT_TRUE(winShell->activate()); +} + +TEST_F(DSWindowShellTest, activate_N1) +{ + std::unique_ptr winShell = std::make_unique(nullptr); + EXPECT_TRUE(winShell != nullptr); + + EXPECT_FALSE(winShell->activate()); } TEST_F(DSWindowShellTest, isActivated_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); // do something } @@ -306,8 +406,8 @@ TEST_F(DSWindowShellTest, isActivated_P1) TEST_F(DSWindowShellTest, iconify_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); // do something } @@ -315,8 +415,8 @@ TEST_F(DSWindowShellTest, iconify_P1) TEST_F(DSWindowShellTest, iconify_P2) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); // do something } @@ -324,8 +424,8 @@ TEST_F(DSWindowShellTest, iconify_P2) TEST_F(DSWindowShellTest, uniconify_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); // do something } @@ -333,8 +433,8 @@ TEST_F(DSWindowShellTest, uniconify_P1) TEST_F(DSWindowShellTest, uniconify_P2) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); // do something } @@ -342,8 +442,8 @@ TEST_F(DSWindowShellTest, uniconify_P2) TEST_F(DSWindowShellTest, getIconicState_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); // do something } @@ -351,8 +451,8 @@ TEST_F(DSWindowShellTest, getIconicState_P1) TEST_F(DSWindowShellTest, setType_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); // do something } @@ -360,8 +460,8 @@ TEST_F(DSWindowShellTest, setType_P1) TEST_F(DSWindowShellTest, getType_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); // do something } @@ -369,8 +469,8 @@ TEST_F(DSWindowShellTest, getType_P1) TEST_F(DSWindowShellTest, maximize_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); // do something } @@ -378,8 +478,8 @@ TEST_F(DSWindowShellTest, maximize_P1) TEST_F(DSWindowShellTest, isMaximized_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); // do something } @@ -387,8 +487,8 @@ TEST_F(DSWindowShellTest, isMaximized_P1) TEST_F(DSWindowShellTest, fullscreen_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); // do something } @@ -396,8 +496,8 @@ TEST_F(DSWindowShellTest, fullscreen_P1) TEST_F(DSWindowShellTest, isFullscreen_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); // do something } @@ -405,8 +505,8 @@ TEST_F(DSWindowShellTest, isFullscreen_P1) TEST_F(DSWindowShellTest, setRole_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); // do something } @@ -414,8 +514,36 @@ TEST_F(DSWindowShellTest, setRole_P1) TEST_F(DSWindowShellTest, getRole_P1) { auto window = std::make_shared(); - std::unique_ptr shell = std::make_unique(window.get()); - EXPECT_TRUE(shell != nullptr); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); // do something } + +TEST_F(DSWindowShellTest, vkbdFloating_P1) +{ + auto window = std::make_shared(); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); + + EXPECT_TRUE(winShell->getVkbdFloating() == false); + + EXPECT_TRUE(winShell->setVkbdFloating(true)); + EXPECT_TRUE(winShell->getVkbdFloating()); + + EXPECT_TRUE(winShell->setVkbdFloating(false)); + EXPECT_TRUE(winShell->getVkbdFloating() == false); +} + +TEST_F(DSWindowShellTest, allowUserGeometry_P1) +{ + auto window = std::make_shared(); + std::unique_ptr winShell = std::make_unique(window.get()); + EXPECT_TRUE(winShell != nullptr); + + winShell->setAllowUserGeometry(true); + + // do something for checking this property +} + + -- 2.7.4 From 6fe212c85051fd0ef535caf280c5876ef8d59333 Mon Sep 17 00:00:00 2001 From: jeon Date: Tue, 1 Sep 2020 19:36:59 +0900 Subject: [PATCH 04/16] DSInput: set LOCV_EXEC block for DSInput Change-Id: Ib956805f0796b9ba6ce0798e1f21a1147b2acf2b --- src/DSInput/DSInput.cpp | 5 ++++- src/DSInput/DSLibinput.cpp | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/DSInput/DSInput.cpp b/src/DSInput/DSInput.cpp index f86c9cf..c5b745c 100644 --- a/src/DSInput/DSInput.cpp +++ b/src/DSInput/DSInput.cpp @@ -63,6 +63,7 @@ void DSInputPrivate::PostDeviceRemoveEvent(std::string seat, std::string name, s pub->deviceRemove(name, identifier, devClass, DSInput::NoneSubclass); } +/*LCOV_EXCL_START*/ void DSInputPrivate::PostKeyboardEvent(int keycode, bool pressed, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) { DS_GET_PUB(DSInput); @@ -96,6 +97,7 @@ void DSInputPrivate::PostTouchEvent(int index, int x, int y, DSInputEvent::Type else if (type == DSInputEvent::TouchUpEvent) pub->touchUp(index, x, y, devIdentifier, devClass, timestamp); } +/*LCOV_EXCL_STOP*/ int DSInput::DS_INPUT_EVENT_KEY_DOWN = 0; int DSInput::DS_INPUT_EVENT_KEY_UP = 0; @@ -216,6 +218,7 @@ void DSInput::deviceRemove(std::string name, std::string identifier, DSInput::De delete device; } +/*LCOV_EXCL_START*/ DSInputDevice *DSInput::findDevice(std::string devIdentifier, DSInput::DeviceClass devClass) { for (auto dev : devList) @@ -301,7 +304,7 @@ void DSInput::touchUp(int index, int x, int y, std::string devIdentifier, DSInpu DSInputTouchEvent *ev = new DSInputTouchEvent(std::make_shared(*device), DSInputEvent::TouchUpEvent, timestamp, index, x, y); ecore_event_add(DS_INPUT_EVENT_TOUCH_UP, (void *)ev, nullptr, nullptr); } - +/*LCOV_EXCL_STOP*/ void DSInput::registerCallbackDeviceAdd(DSObject *slot, std::function)> func) { diff --git a/src/DSInput/DSLibinput.cpp b/src/DSInput/DSLibinput.cpp index 7e7ede9..c81f61e 100644 --- a/src/DSInput/DSLibinput.cpp +++ b/src/DSInput/DSLibinput.cpp @@ -106,6 +106,7 @@ Eina_Bool DSLibinput::__handleEvents(void *data, Ecore_Fd_Handler *hdlr) case LIBINPUT_EVENT_DEVICE_REMOVED: dsLibinput->__processDeviceRemoveEvent(event); break; +/*LCOV_EXCL_START*/ case LIBINPUT_EVENT_KEYBOARD_KEY: dsLibinput->__processKeyboardKeyEvent(event); break; @@ -141,6 +142,7 @@ Eina_Bool DSLibinput::__handleEvents(void *data, Ecore_Fd_Handler *hdlr) break; default: break; +/*LCOV_EXCL_STOP*/ } libinput_event_destroy(event); } @@ -201,6 +203,7 @@ void DSLibinput::__processDeviceRemoveEvent(struct ::libinput_event *event) } } +/*LCOV_EXCL_START*/ void DSLibinput::__processKeyboardKeyEvent(struct:: libinput_event *event) { struct:: libinput_event_keyboard *keyboard_event = libinput_event_get_keyboard_event(event); @@ -325,5 +328,6 @@ void DSLibinput::__processTouchAuxDataEvent(struct ::libinput_event *event) { ; } +/*LCOV_EXCL_STOP*/ } // namespace display_server -- 2.7.4 From b6e3c43b98aa406c19e76ccac4805eff34f5ee06 Mon Sep 17 00:00:00 2001 From: jeon Date: Tue, 1 Sep 2020 19:37:22 +0900 Subject: [PATCH 05/16] DSInputEvent: add tests for DSInputEvent classes Change-Id: Iecbc9a7bd4ecb70388e3bde4f94bc19d9e623a9e --- tests/DSInput-test.cpp | 230 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 230 insertions(+) diff --git a/tests/DSInput-test.cpp b/tests/DSInput-test.cpp index 8e92e30..0109988 100644 --- a/tests/DSInput-test.cpp +++ b/tests/DSInput-test.cpp @@ -24,6 +24,7 @@ #include "libds-tests.h" #include "DSInput.h" #include "DSSeat.h" +#include "DSInputEvent.h" using namespace display_server; @@ -196,3 +197,232 @@ TEST_F(DSInputDeviceTest, DSInputDeviceSetGetSubclass) delete inputDevice; } +class DSInputEventTest : public ::testing::Test +{ +public: + void SetUp(void) override + {} + void TearDown(void) override + {} +}; + +TEST_F(DSInputEventTest, NewDSInputEvent) +{ + DSInputEvent::Type eventType = DSInputEvent::NoneEvent; + unsigned int curTime = 0; + DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::NoneClass, DSInput::NoneSubclass); + DSInputEvent *inputEvent = new DSInputEvent(std::make_shared(*inputDevice), eventType, curTime); + + EXPECT_TRUE(inputEvent != nullptr); + + delete inputEvent; + delete inputDevice; +} + +TEST_F(DSInputEventTest, GetDevice) +{ + DSInputEvent::Type eventType = DSInputEvent::NoneEvent; + unsigned int curTime = 0; + DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::NoneClass, DSInput::NoneSubclass); + DSInputEvent *inputEvent = new DSInputEvent(std::make_shared(*inputDevice), eventType, curTime); + + EXPECT_TRUE(*(inputEvent->getDevice().get()) == *inputDevice); + + delete inputEvent; + delete inputDevice; +} + +TEST_F(DSInputEventTest, GetType) +{ + DSInputEvent::Type eventType = DSInputEvent::NoneEvent; + unsigned int curTime = 0; + DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::NoneClass, DSInput::NoneSubclass); + DSInputEvent *inputEvent = new DSInputEvent(std::make_shared(*inputDevice), eventType, curTime); + + EXPECT_TRUE(inputEvent->getType() == eventType); + + delete inputEvent; + delete inputDevice; +} + +TEST_F(DSInputEventTest, GetTimestamp) +{ + DSInputEvent::Type eventType = DSInputEvent::NoneEvent; + unsigned int curTime = 0; + DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::NoneClass, DSInput::NoneSubclass); + DSInputEvent *inputEvent = new DSInputEvent(std::make_shared(*inputDevice), eventType, curTime); + + EXPECT_TRUE((unsigned int)inputEvent->getTimestamp() == curTime); + + delete inputEvent; + delete inputDevice; +} + +class DSInputKeyboardEventTest : public ::testing::Test +{ +public: + void SetUp(void) override + {} + void TearDown(void) override + {} +}; + +TEST_F(DSInputKeyboardEventTest, NewDSInputKeyboardEvent) +{ + DSInputEvent::Type eventType = DSInputEvent::NoneEvent; + unsigned int curTime = 0; + int keycode = 166; + DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::KeyboardClass, DSInput::NoneSubclass); + DSInputKeyboardEvent *keyboardEvent = new DSInputKeyboardEvent(std::make_shared(*inputDevice), eventType, curTime, keycode); + + EXPECT_TRUE(keyboardEvent != nullptr); + + delete keyboardEvent; + delete inputDevice; +} + +TEST_F(DSInputKeyboardEventTest, GetKeycode) +{ + DSInputEvent::Type eventType = DSInputEvent::NoneEvent; + unsigned int curTime = 0; + int keycode = 166; + DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::KeyboardClass, DSInput::NoneSubclass); + DSInputKeyboardEvent *keyboardEvent = new DSInputKeyboardEvent(std::make_shared(*inputDevice), eventType, curTime, keycode); + + EXPECT_TRUE(keyboardEvent->getKeycode() == keycode); + + delete keyboardEvent; + delete inputDevice; +} + +TEST_F(DSInputKeyboardEventTest, GetSetKeyname) +{ + DSInputEvent::Type eventType = DSInputEvent::NoneEvent; + unsigned int curTime = 0; + int keycode = 166; + std::string keyname = "TestKey"; + DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::KeyboardClass, DSInput::NoneSubclass); + DSInputKeyboardEvent *keyboardEvent = new DSInputKeyboardEvent(std::make_shared(*inputDevice), eventType, curTime, keycode); + keyboardEvent->setKeyname(keyname); + + EXPECT_TRUE(keyboardEvent->getKeyname() == keyname); + + delete keyboardEvent; + delete inputDevice; +} + +class DSInputMouseEventTest : public ::testing::Test +{ +public: + void SetUp(void) override + {} + void TearDown(void) override + {} +}; + +TEST_F(DSInputMouseEventTest, NewDSInputMouseEvent) +{ + DSInputEvent::Type eventType = DSInputEvent::NoneEvent; + unsigned int curTime = 0; + int button = 1, x = 10, y = 20, z = 1; + DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::PointerClass, DSInput::NoneSubclass); + DSInputMouseEvent *mouseEvent = new DSInputMouseEvent(std::make_shared(*inputDevice), eventType, curTime, button, x, y, z); + + EXPECT_TRUE(mouseEvent != nullptr); + + delete mouseEvent; + delete inputDevice; +} + +TEST_F(DSInputMouseEventTest, GetAxis) +{ + DSInputEvent::Type eventType = DSInputEvent::NoneEvent; + unsigned int curTime = 0; + int button = 1, x = 10, y = 20, z = 1; + DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::PointerClass, DSInput::NoneSubclass); + DSInputMouseEvent *mouseEvent = new DSInputMouseEvent(std::make_shared(*inputDevice), eventType, curTime, button, x, y, z); + + EXPECT_TRUE(mouseEvent->getX() == x); + EXPECT_TRUE(mouseEvent->getY() == y); + EXPECT_TRUE(mouseEvent->getZ() == z); + + delete mouseEvent; + delete inputDevice; +} + +TEST_F(DSInputMouseEventTest, GetSetWinAxis) +{ + DSInputEvent::Type eventType = DSInputEvent::NoneEvent; + unsigned int curTime = 0; + int button = 1, x = 10, y = 20, z = 1; + DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::PointerClass, DSInput::NoneSubclass); + DSInputMouseEvent *mouseEvent = new DSInputMouseEvent(std::make_shared(*inputDevice), eventType, curTime, button, x, y, z); + + mouseEvent->setWinX(x); + mouseEvent->setWinY(y); + mouseEvent->setWinZ(z); + + EXPECT_TRUE(mouseEvent->getWinX() == x); + EXPECT_TRUE(mouseEvent->getWinY() == y); + EXPECT_TRUE(mouseEvent->getWinZ() == z); + + delete mouseEvent; + delete inputDevice; +} + +class DSInputTouchEventTest : public ::testing::Test +{ +public: + void SetUp(void) override + {} + void TearDown(void) override + {} +}; + +TEST_F(DSInputTouchEventTest, NewDSInputTouchEvent) +{ + DSInputEvent::Type eventType = DSInputEvent::NoneEvent; + unsigned int curTime = 0; + int index = 0, x = 10, y = 20; + DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::TouchClass, DSInput::NoneSubclass); + DSInputTouchEvent *touchEvent = new DSInputTouchEvent(std::make_shared(*inputDevice), eventType, curTime, index, x, y); + + EXPECT_TRUE(touchEvent != nullptr); + + delete touchEvent; + delete inputDevice; +} + +TEST_F(DSInputTouchEventTest, GetAxis) +{ + DSInputEvent::Type eventType = DSInputEvent::NoneEvent; + unsigned int curTime = 0; + int index = 0, x = 10, y = 20; + DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::TouchClass, DSInput::NoneSubclass); + DSInputTouchEvent *touchEvent = new DSInputTouchEvent(std::make_shared(*inputDevice), eventType, curTime, index, x, y); + + EXPECT_TRUE(touchEvent->getX() == x); + EXPECT_TRUE(touchEvent->getY() == y); + + delete touchEvent; + delete inputDevice; +} + +TEST_F(DSInputTouchEventTest, GetSetWinAxis) +{ + DSInputEvent::Type eventType = DSInputEvent::NoneEvent; + unsigned int curTime = 0; + int index = 0, x = 10, y = 20; + DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::TouchClass, DSInput::NoneSubclass); + DSInputTouchEvent *touchEvent = new DSInputTouchEvent(std::make_shared(*inputDevice), eventType, curTime, index, x, y); + + touchEvent->setWinX(x); + touchEvent->setWinY(y); + + EXPECT_TRUE(touchEvent->getWinX() == x); + EXPECT_TRUE(touchEvent->getWinY() == y); + + delete touchEvent; + delete inputDevice; +} + -- 2.7.4 From aaa64ec1dc64582a6d5a4b53993020fae460a19f Mon Sep 17 00:00:00 2001 From: dyamy-lee Date: Tue, 1 Sep 2020 14:50:38 +0900 Subject: [PATCH 06/16] DsWaylandProtocolTrace-test : Add creating rule file for test Change-Id: I177323b2682003cd3fa35175acfe591d819bcc98 --- tests/DSWaylandProtocolTrace-test.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/DSWaylandProtocolTrace-test.cpp b/tests/DSWaylandProtocolTrace-test.cpp index 3139fd4..a7d3b6f 100644 --- a/tests/DSWaylandProtocolTrace-test.cpp +++ b/tests/DSWaylandProtocolTrace-test.cpp @@ -32,9 +32,15 @@ public: void SetUp(void) override { setenv("XDG_RUNTIME_DIR", "/run", 1); + setenv("E_INFO_RULE_FILE", "/tmp/rule", 1); + setenv("E_INFO_TRACE_FILE", "/tmp/trace", 1); } void TearDown(void) override - {} + { + unsetenv("XDG_RUNTIME_DIR"); + unsetenv("E_INFO_RULE_FILE"); + unsetenv("E_INFO_TRACE_FILE"); + } }; @@ -50,10 +56,25 @@ TEST_F(DSWaylandProtocolTraceTest, NewDSWaylandProtocolTrace) TEST_F(DSWaylandProtocolTraceTest, DSWaylandProtocolTraceInit) { DSWaylandProtocolTrace *pTrace = DSWaylandProtocolTrace::getInstance(); + static FILE *rule_file = NULL; if(pTrace) { + rule_file = fopen("/tmp/rule", "a"); + if(!rule_file) + { + EXPECT_TRUE(false); + DSWaylandProtocolTrace::releaseInstance(); + return; + } + EXPECT_TRUE(pTrace->init() == true); + + if(rule_file != nullptr) + { + fclose(rule_file); + rule_file = nullptr; + } DSWaylandProtocolTrace::releaseInstance(); } } -- 2.7.4 From 8876dd12aed379b18466ef13c2fcc25d9d7e75a6 Mon Sep 17 00:00:00 2001 From: "Junseok, Kim" Date: Tue, 1 Sep 2020 19:51:06 +0900 Subject: [PATCH 07/16] DSClient: window count up/down if window added/removed Change-Id: Ief5fb943a35d2947ee62e987230b71afde1ef626 Signed-off-by: Junseok, Kim --- src/DSClient/DSClient.cpp | 63 +++++++++++++++++++++++++++--------------- src/DSClient/DSClient.h | 2 +- src/DSClient/DSClientPrivate.h | 3 ++ 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/src/DSClient/DSClient.cpp b/src/DSClient/DSClient.cpp index 1c6afc7..bc887e9 100644 --- a/src/DSClient/DSClient.cpp +++ b/src/DSClient/DSClient.cpp @@ -46,6 +46,43 @@ DSClientPrivate::~DSClientPrivate() __windows.clear(); } +bool DSClientPrivate::addWindow(DSWindow *window) +{ + if (window == nullptr) return false; + + for (auto win : __windows) + { + if (window == win) + { + DSLOG_ERR("DSClient", "Window(%p) exists already.", window); + return true; + } + } + + __windows.push_back(window); + __numWindows++; + return true; +} + +bool DSClientPrivate::delWindow(DSWindow *window) +{ + if (window == nullptr) return false; + + for (auto win : __windows) + { + if (window == win) + { + __windows.remove(window); + DSLOG_ERR("DSClient", "Window(%p) has been removed.", window); + __numWindows--; + if (__numWindows < 0) __numWindows = 0; + return true; + } + } + + return false; +} + /* Begin Public Class Implementation */ DSClient::DSClient(DSCompositor *compositor) : _d_ptr(std::make_unique(this, nullptr)), @@ -64,38 +101,18 @@ DSClient::~DSClient() { } -void DSClient::addWindow(DSWindow *window) +bool DSClient::addWindow(DSWindow *window) { DS_GET_PRIV(DSClient); - for (auto win : priv->__windows) - { - if (window == win) - { - DSLOG_ERR("DSClient", "Window(%p) exists already.", window); - return; - } - } - - priv->__windows.push_back(window); - return; + return priv->addWindow(window); } bool DSClient::removeWindow(DSWindow *window) { DS_GET_PRIV(DSClient); - for (auto win : priv->__windows) - { - if (window == win) - { - priv->__windows.remove(window); - DSLOG_ERR("DSClient", "Window(%p) has been removed.", window); - return true; - } - } - - return false; + return priv->delWindow(window); } std::list DSClient::getWindows() diff --git a/src/DSClient/DSClient.h b/src/DSClient/DSClient.h index d645184..5e457d4 100644 --- a/src/DSClient/DSClient.h +++ b/src/DSClient/DSClient.h @@ -44,7 +44,7 @@ public: DSClient(DSCompositor *compositor, DSWaylandClient *dswlClient); ~DSClient() override; - void addWindow(DSWindow *window); + bool addWindow(DSWindow *window); bool removeWindow(DSWindow *window); std::list getWindows(); uint32_t numWindows(); diff --git a/src/DSClient/DSClientPrivate.h b/src/DSClient/DSClientPrivate.h index bef50f2..2f4a90b 100644 --- a/src/DSClient/DSClientPrivate.h +++ b/src/DSClient/DSClientPrivate.h @@ -41,6 +41,9 @@ public: DSClientPrivate(DSClient *client, DSWaylandClient *dswlClient); ~DSClientPrivate() override; + bool addWindow(DSWindow *win); + bool delWindow(DSWindow *win); + private: DSWaylandCompositor *__dswlComp; DSWaylandClient *__dswlClient; -- 2.7.4 From 4a744e99cac955ae3f2d16324c5b086248dadf5a Mon Sep 17 00:00:00 2001 From: Duna Oh Date: Tue, 1 Sep 2020 14:21:10 +0900 Subject: [PATCH 08/16] DSTraceInfo-test: add simple test cases for DSTraceInfo Change-Id: I0d870c7c3aeed7e21fa999eebbe688cee9381710 --- tests/DSTraceInfo-test.cpp | 65 ++++++++++++++++++++++++++++++++++++++++++++++ tests/meson.build | 1 + 2 files changed, 66 insertions(+) create mode 100644 tests/DSTraceInfo-test.cpp diff --git a/tests/DSTraceInfo-test.cpp b/tests/DSTraceInfo-test.cpp new file mode 100644 index 0000000..e382c2e --- /dev/null +++ b/tests/DSTraceInfo-test.cpp @@ -0,0 +1,65 @@ +/* +* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include "libds-tests.h" +#include "DSTraceInfo.h" + +using namespace display_server; + +class DSTraceInfoTest : public ::testing::Test +{ +public: + void SetUp(void) override + { + setenv("XDG_RUNTIME_DIR", "/run", 1); + } + void TearDown(void) override + { + unsetenv("XDG_RUNTIME_DIR"); + } +}; + +TEST_F(DSTraceInfoTest, NewTraceInfo) +{ + auto traceInfo = std::make_unique(); + EXPECT_TRUE(traceInfo != nullptr); +} + +TEST_F(DSTraceInfoTest, attachPolicyArea) +{ + auto traceInfo = std::make_unique(); + EXPECT_TRUE(traceInfo != nullptr); + auto policyArea = std::make_shared(); + EXPECT_TRUE(policyArea != nullptr); + EXPECT_TRUE(traceInfo->attachPolicyArea(policyArea) == true); +} + +TEST_F(DSTraceInfoTest, printWindowsInfo) +{ + auto traceInfo = std::make_unique(); + EXPECT_TRUE(traceInfo != nullptr); + auto policyArea = std::make_shared(); + EXPECT_TRUE(policyArea != nullptr); + traceInfo->printWindowsInfo(); +} + diff --git a/tests/meson.build b/tests/meson.build index 58a1ec4..1ef31cc 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -57,6 +57,7 @@ libds_tests_srcs = [ 'DSTouch-test.cpp', 'DSTizenAppinfo-test.cpp', 'DSWaylandProtocolTrace-test.cpp', + 'DSTraceInfo-test.cpp', ] gmock_dep = dependency('gmock', method : 'pkg-config') -- 2.7.4 From 3d3876b9cbb4d1d3c227b3149366f58cdd63b646 Mon Sep 17 00:00:00 2001 From: "Junseok, Kim" Date: Fri, 14 Aug 2020 17:23:18 +0900 Subject: [PATCH 09/16] DSSignalBroker: add skeleton codes Change-Id: I90427a9efac9298c9222a9fff6e58a667e390b4d Signed-off-by: Junseok, Kim --- src/DSSignal/DSSignalBroker.cpp | 110 ++++++++++++++++++++++++++++++++++++++++ src/DSSignal/DSSignalBroker.h | 58 +++++++++++++++++++++ src/meson.build | 2 + tests/DSSignalBroker-test.cpp | 85 +++++++++++++++++++++++++++++++ tests/meson.build | 1 + 5 files changed, 256 insertions(+) create mode 100644 src/DSSignal/DSSignalBroker.cpp create mode 100644 src/DSSignal/DSSignalBroker.h create mode 100644 tests/DSSignalBroker-test.cpp diff --git a/src/DSSignal/DSSignalBroker.cpp b/src/DSSignal/DSSignalBroker.cpp new file mode 100644 index 0000000..cdb1aad --- /dev/null +++ b/src/DSSignal/DSSignalBroker.cpp @@ -0,0 +1,110 @@ +/* +* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include + +namespace display_server +{ + +std::mutex DSSignalBroker::__mutex; +DSSignalBroker* DSSignalBroker::__signalBroker { nullptr }; + +DSSignalBroker::DSSignalBroker(DSObject *parent) +{ +} + +DSSignalBroker::~DSSignalBroker() +{ +} + +DSSignalBroker *DSSignalBroker::getInstance() +{ + std::lock_guard tLock(__mutex); + + if (!__signalBroker) + { + __signalBroker = new DSSignalBroker(new DSObject); + DSLOG_INF("DSSignalBroker", "DSSignalBroker instance has been created !"); + } + + return __signalBroker; +} + +void DSSignalBroker::releaseInstance() +{ + std::lock_guard tLock(__mutex); + + if (__signalBroker && __signalBroker->__signalHash.empty()) + { + delete __signalBroker; + __signalBroker = nullptr; + DSLOG_INF("DSSignalBroker", "DSSignalBroker instance has been removed !"); + } +} + +bool DSSignalBroker::registerCallback(std::string signalStr, DSObject *slot, std::function func) +{ + if (!__signalBroker) return false; + + if (__signalBroker->__signalHash.find(signalStr) == __signalBroker->__signalHash.end()) + { + DSLOG_INF("DSSignalBroker","registerCallback:: cannot find signal, add new one %s", signalStr.c_str()); + + __signalBroker->__signalHash[signalStr] = new DSSignal(); + } + + __signalBroker->__signalHash[signalStr]->connect(slot, func); + + return true; +} + +bool DSSignalBroker::deregisterCallback(std::string signalStr, DSObject *slot, std::function func) +{ + if (!__signalBroker) return false; + + if (__signalBroker->__signalHash.find(signalStr) == __signalBroker->__signalHash.end()) + return false; + + // TODO: have to impl disconnect method in DSSignal + //__signalBroker->__signalHash[signalStr]->disconnect(slot, func); + + return true; +} + +bool DSSignalBroker::emitSignal(std::string signalStr, void *arg) +{ + if (!__signalBroker) return false; + + if (__signalBroker->__signalHash.find(signalStr) == __signalBroker->__signalHash.end()) + { + DSLOG_INF("DSSignalBroker","emitSignal:: cannot find signal, add new one %s", signalStr.c_str()); + + __signalBroker->__signalHash[signalStr] = new DSSignal(); + } + + __signalBroker->__signalHash[signalStr]->emit(arg); + + return true; +} + +} // end of namespace display_server \ No newline at end of file diff --git a/src/DSSignal/DSSignalBroker.h b/src/DSSignal/DSSignalBroker.h new file mode 100644 index 0000000..2e503a0 --- /dev/null +++ b/src/DSSignal/DSSignalBroker.h @@ -0,0 +1,58 @@ +/* +* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#ifndef __DS_SIGNAL_BROKER_H__ +#define __DS_SIGNAL_BROKER_H__ + +#include +#include +#include + +namespace display_server +{ + +class DSSignalBroker : public DSObject +{ +public: + static DSSignalBroker *getInstance(); + static void releaseInstance(); + + // TODO: needs arguments using signal (now only supports void*) + bool registerCallback(std::string signalStr, DSObject *slot, std::function func); + bool deregisterCallback(std::string signalStr, DSObject *slot, std::function func); + bool emitSignal(std::string signalStr, void *arg); + +private: + static std::mutex __mutex; + static DSSignalBroker *__signalBroker; + + std::unordered_map *> __signalHash; + + DSSignalBroker() = delete; + ~DSSignalBroker(); + DSSignalBroker(DSObject *parent); +}; + +} // end of namespace display_server + +#endif // end of __DS_SIGNAL_BROKER_H__ diff --git a/src/meson.build b/src/meson.build index 9facc3c..9ebeb3e 100644 --- a/src/meson.build +++ b/src/meson.build @@ -52,6 +52,8 @@ libds_srcs = [ 'DSSeat/DSTouch.h', 'DSSignal/DSSignal.cpp', 'DSSignal/DSSignal.h', + 'DSSignal/DSSignalBroker.cpp', + 'DSSignal/DSSignalBroker.h', 'DSCore/DSStruct.h', 'DSCore/DSCore.h', 'DSWaylandExtension/DSWaylandExtension.cpp', diff --git a/tests/DSSignalBroker-test.cpp b/tests/DSSignalBroker-test.cpp new file mode 100644 index 0000000..1b3ace7 --- /dev/null +++ b/tests/DSSignalBroker-test.cpp @@ -0,0 +1,85 @@ +/* +* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include +#include "libds-tests.h" +#include "DSSignal.h" +#include "DSSignalBroker.h" +#include "DSDebugLog.h" + +using namespace display_server; + +class DSSignalBrokerTest : public ::testing::Test +{ +public: + void SetUp(void) override + { + res_lambda = false; + } + void TearDown(void) override + {} + + bool res_lambda; +}; + +TEST_F(DSSignalBrokerTest, getInstance) +{ + DSSignalBroker *sigbro = DSSignalBroker::getInstance(); + EXPECT_TRUE(sigbro != nullptr); + + if (sigbro) + sigbro->releaseInstance(); +} + +TEST_F(DSSignalBrokerTest, registerCallback) +{ + bool res = false; + DSSignalBroker *sigbro = DSSignalBroker::getInstance(); + std::string testSignal = "TestSignalBroker"; + EXPECT_TRUE(sigbro != nullptr); + + res = sigbro->registerCallback(testSignal, new DSObject, [&](void * arg) { + DSLOG_INF("DSTEST", "%s is invoked!, input: %p", __func__, arg); + res_lambda = true; + }); + EXPECT_TRUE(res); + + if (sigbro) + sigbro->releaseInstance(); +} + +TEST_F(DSSignalBrokerTest, emitSignal) +{ + bool res = false; + DSSignalBroker *sigbro = DSSignalBroker::getInstance(); + std::string testSignal = "TestSignalBroker"; + EXPECT_TRUE(sigbro != nullptr); + + // NOTICE: If registerCallback test didn't called, this test will fail. + res = sigbro->emitSignal(testSignal, nullptr); + EXPECT_TRUE(res); + EXPECT_TRUE(res_lambda); + + if (sigbro) + sigbro->releaseInstance(); +} diff --git a/tests/meson.build b/tests/meson.build index 1ef31cc..372bf7e 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -17,6 +17,7 @@ libds_tests_srcs = [ 'DSDebugLog-test.cpp', 'DSDisplayDeviceTDMImpl-test.cpp', 'DSSignal-test.cpp', + 'DSSignalBroker-test.cpp', 'DSWindowManager-test.cpp', 'DSWindow-test.cpp', 'DSWindowShell-test.cpp', -- 2.7.4 From 2631796eb2e895a8a5aa3a9dbbe4b27abe8601e4 Mon Sep 17 00:00:00 2001 From: "Junseok, Kim" Date: Wed, 19 Aug 2020 17:56:25 +0900 Subject: [PATCH 10/16] DSSignalBroker: use template for respond to various args Change-Id: I9a386e712804ae23b5467947b4f27f92ad23ab39 Signed-off-by: Junseok, Kim --- src/DSSignal/DSSignalBroker.cpp | 57 ++++---------------- src/DSSignal/DSSignalBroker.h | 63 ++++++++++++++++++++-- tests/DSSignalBroker-test.cpp | 117 +++++++++++++++++++++++++++++++--------- 3 files changed, 162 insertions(+), 75 deletions(-) diff --git a/src/DSSignal/DSSignalBroker.cpp b/src/DSSignal/DSSignalBroker.cpp index cdb1aad..f8e4cfa 100644 --- a/src/DSSignal/DSSignalBroker.cpp +++ b/src/DSSignal/DSSignalBroker.cpp @@ -35,6 +35,16 @@ DSSignalBroker::DSSignalBroker(DSObject *parent) DSSignalBroker::~DSSignalBroker() { + if (__signalBroker) + { + if (!__signalBroker->__signalHash.empty()) + { + for (auto hashpairs : __signalBroker->__signalHash) + { + delete hashpairs.second; + } + } + } } DSSignalBroker *DSSignalBroker::getInstance() @@ -58,53 +68,8 @@ void DSSignalBroker::releaseInstance() { delete __signalBroker; __signalBroker = nullptr; - DSLOG_INF("DSSignalBroker", "DSSignalBroker instance has been removed !"); + DSLOG_INF("DSSignalBroker", "DSSignalBroker instance has been removed !"); } } -bool DSSignalBroker::registerCallback(std::string signalStr, DSObject *slot, std::function func) -{ - if (!__signalBroker) return false; - - if (__signalBroker->__signalHash.find(signalStr) == __signalBroker->__signalHash.end()) - { - DSLOG_INF("DSSignalBroker","registerCallback:: cannot find signal, add new one %s", signalStr.c_str()); - - __signalBroker->__signalHash[signalStr] = new DSSignal(); - } - - __signalBroker->__signalHash[signalStr]->connect(slot, func); - - return true; -} - -bool DSSignalBroker::deregisterCallback(std::string signalStr, DSObject *slot, std::function func) -{ - if (!__signalBroker) return false; - - if (__signalBroker->__signalHash.find(signalStr) == __signalBroker->__signalHash.end()) - return false; - - // TODO: have to impl disconnect method in DSSignal - //__signalBroker->__signalHash[signalStr]->disconnect(slot, func); - - return true; -} - -bool DSSignalBroker::emitSignal(std::string signalStr, void *arg) -{ - if (!__signalBroker) return false; - - if (__signalBroker->__signalHash.find(signalStr) == __signalBroker->__signalHash.end()) - { - DSLOG_INF("DSSignalBroker","emitSignal:: cannot find signal, add new one %s", signalStr.c_str()); - - __signalBroker->__signalHash[signalStr] = new DSSignal(); - } - - __signalBroker->__signalHash[signalStr]->emit(arg); - - return true; -} - } // end of namespace display_server \ No newline at end of file diff --git a/src/DSSignal/DSSignalBroker.h b/src/DSSignal/DSSignalBroker.h index 2e503a0..27a55dd 100644 --- a/src/DSSignal/DSSignalBroker.h +++ b/src/DSSignal/DSSignalBroker.h @@ -38,9 +38,12 @@ public: static void releaseInstance(); // TODO: needs arguments using signal (now only supports void*) - bool registerCallback(std::string signalStr, DSObject *slot, std::function func); - bool deregisterCallback(std::string signalStr, DSObject *slot, std::function func); - bool emitSignal(std::string signalStr, void *arg); + template + bool registerCallback(std::string signalStr, DSObject *slot, std::function func); + template + bool deregisterCallback(std::string signalStr, DSObject *slot, std::function func); + template + bool emitSignal(std::string signalStr, Args...); private: static std::mutex __mutex; @@ -53,6 +56,60 @@ private: DSSignalBroker(DSObject *parent); }; +template +bool DSSignalBroker::registerCallback(std::string signalStr, DSObject *slot, std::function func) +{ + if (!__signalBroker) return false; + + if (__signalBroker->__signalHash.find(signalStr) == __signalBroker->__signalHash.end()) + { + DSLOG_INF("DSSignalBroker","registerCallback:: cannot find signal, add new one %s", signalStr.c_str()); + + __signalBroker->__signalHash[signalStr] = reinterpret_cast *> (new DSSignal()); + } + + DSSignal *signal = reinterpret_cast *>(__signalBroker->__signalHash[signalStr]); + if (signal) + signal->connect(slot, func); + + return true; +} + +template +bool DSSignalBroker::deregisterCallback(std::string signalStr, DSObject *slot, std::function func) +{ + if (!__signalBroker) return false; + + if (__signalBroker->__signalHash.find(signalStr) == __signalBroker->__signalHash.end()) + return false; + + // TODO: have to impl disconnect method in DSSignal + //DSSignal *signal = reinterpret_cast *>(__signalBroker->__signalHash[signalStr]); + //if (signal) + //signal->disconnect(slot, func); + + return true; +} + +template +bool DSSignalBroker::emitSignal(std::string signalStr, Args... args) +{ + if (!__signalBroker) return false; + + if (__signalBroker->__signalHash.find(signalStr) == __signalBroker->__signalHash.end()) + { + DSLOG_INF("DSSignalBroker","emitSignal:: cannot find signal, add new one %s", signalStr.c_str()); + + __signalBroker->__signalHash[signalStr] = reinterpret_cast *> (new DSSignal()); + } + + DSSignal *signal = reinterpret_cast *>(__signalBroker->__signalHash[signalStr]); + if (signal) + signal->emit(args...); + + return true; +} + } // end of namespace display_server #endif // end of __DS_SIGNAL_BROKER_H__ diff --git a/tests/DSSignalBroker-test.cpp b/tests/DSSignalBroker-test.cpp index 1b3ace7..a4532b9 100644 --- a/tests/DSSignalBroker-test.cpp +++ b/tests/DSSignalBroker-test.cpp @@ -33,13 +33,74 @@ class DSSignalBrokerTest : public ::testing::Test { public: void SetUp(void) override - { - res_lambda = false; - } + {} void TearDown(void) override {} +}; + +class MockSignalBrokerSender : public DSObject +{ +public: + MockSignalBrokerSender() {} + ~MockSignalBrokerSender() {} + + bool sendSignal(std::string signalString) + { + DSSignalBroker *sigbro = DSSignalBroker::getInstance(); + bool res = false; + + if (sigbro == nullptr) + return false; + + res = sigbro->emitSignal(signalString, true); + + if (sigbro) + sigbro->releaseInstance(); + + return res; + } +}; + +class MockSignalBrokerReceiver : public DSObject +{ +public: + MockSignalBrokerReceiver() = delete; + MockSignalBrokerReceiver(std::string targetSignal) + { + __targetSignal = targetSignal; + } + ~MockSignalBrokerReceiver() {} + +public: + std::string __targetSignal; + bool __result; + +public: + bool registerCallback() + { + bool res = false; + DSSignalBroker *sigbro = DSSignalBroker::getInstance(); + if (sigbro == nullptr) return false; + + std::function func = std::bind(&MockSignalBrokerReceiver::callbackTestSignalBroker, this, std::placeholders::_1); + res = sigbro->registerCallback(__targetSignal, this, func); + + if (sigbro) + sigbro->releaseInstance(); + + return res; + } - bool res_lambda; + void callbackTestSignalBroker(bool arg) + { + DSLOG_INF("DSTEST", "%s is invoked!, arg: %d", __func__, arg); + __result = arg; + } + + bool getResult() + { + return __result; + } }; TEST_F(DSSignalBrokerTest, getInstance) @@ -53,33 +114,37 @@ TEST_F(DSSignalBrokerTest, getInstance) TEST_F(DSSignalBrokerTest, registerCallback) { - bool res = false; - DSSignalBroker *sigbro = DSSignalBroker::getInstance(); - std::string testSignal = "TestSignalBroker"; - EXPECT_TRUE(sigbro != nullptr); + auto receiver = std::make_shared("TestSignalBroker"); + receiver->registerCallback(); +} - res = sigbro->registerCallback(testSignal, new DSObject, [&](void * arg) { - DSLOG_INF("DSTEST", "%s is invoked!, input: %p", __func__, arg); - res_lambda = true; - }); - EXPECT_TRUE(res); +TEST_F(DSSignalBrokerTest, emitSignal) +{ + auto receiver = std::make_shared("TestSignalBroker"); + auto sender = std::make_shared(); + ASSERT_TRUE(receiver != nullptr); + ASSERT_TRUE(sender != nullptr); - if (sigbro) - sigbro->releaseInstance(); + receiver->registerCallback(); + EXPECT_TRUE(sender->sendSignal("TestSignalBroker")); + EXPECT_TRUE(receiver->getResult()); } -TEST_F(DSSignalBrokerTest, emitSignal) +TEST_F(DSSignalBrokerTest, emitSignal2) { - bool res = false; - DSSignalBroker *sigbro = DSSignalBroker::getInstance(); - std::string testSignal = "TestSignalBroker"; - EXPECT_TRUE(sigbro != nullptr); + auto receiver1 = std::make_shared("TestSignalBroker"); + auto receiver2 = std::make_shared("TestSignalBroker2"); + auto sender = std::make_shared(); + ASSERT_TRUE(receiver1 != nullptr); + ASSERT_TRUE(receiver2 != nullptr); + ASSERT_TRUE(sender != nullptr); - // NOTICE: If registerCallback test didn't called, this test will fail. - res = sigbro->emitSignal(testSignal, nullptr); - EXPECT_TRUE(res); - EXPECT_TRUE(res_lambda); + receiver1->registerCallback(); + receiver2->registerCallback(); + EXPECT_TRUE(sender->sendSignal("TestSignalBroker")); + EXPECT_TRUE(receiver1->getResult()); + EXPECT_TRUE(receiver2->getResult() != true); - if (sigbro) - sigbro->releaseInstance(); + EXPECT_TRUE(sender->sendSignal("TestSignalBroker2")); + EXPECT_TRUE(receiver2->getResult()); } -- 2.7.4 From dfa70234dfe173becde2db56d89df922ab7b5458 Mon Sep 17 00:00:00 2001 From: "Junseok, Kim" Date: Fri, 28 Aug 2020 20:06:06 +0900 Subject: [PATCH 11/16] DSSignalBroker: added registerSignal and add DSObject argument for signal methods Change-Id: I2b97b60b195740b134a2cdd1d7fbcaa082679c9b Signed-off-by: Junseok, Kim --- src/DSSignal/DSSignalBroker.cpp | 2 +- src/DSSignal/DSSignalBroker.h | 140 ++++++++++++++++++----- tests/DSSignalBroker-test.cpp | 239 +++++++++++++++++++++++++++++++--------- 3 files changed, 301 insertions(+), 80 deletions(-) diff --git a/src/DSSignal/DSSignalBroker.cpp b/src/DSSignal/DSSignalBroker.cpp index f8e4cfa..58c53c2 100644 --- a/src/DSSignal/DSSignalBroker.cpp +++ b/src/DSSignal/DSSignalBroker.cpp @@ -41,7 +41,7 @@ DSSignalBroker::~DSSignalBroker() { for (auto hashpairs : __signalBroker->__signalHash) { - delete hashpairs.second; + delete hashpairs.second.signal; } } } diff --git a/src/DSSignal/DSSignalBroker.h b/src/DSSignal/DSSignalBroker.h index 27a55dd..5674ade 100644 --- a/src/DSSignal/DSSignalBroker.h +++ b/src/DSSignal/DSSignalBroker.h @@ -37,19 +37,38 @@ public: static DSSignalBroker *getInstance(); static void releaseInstance(); - // TODO: needs arguments using signal (now only supports void*) + template + bool registerSignal(std::string signalStr, DSObject *obj); + template + bool emitSignal(std::string signalStr, DSObject *obj, Args...); template bool registerCallback(std::string signalStr, DSObject *slot, std::function func); template bool deregisterCallback(std::string signalStr, DSObject *slot, std::function func); - template - bool emitSignal(std::string signalStr, Args...); private: static std::mutex __mutex; static DSSignalBroker *__signalBroker; - std::unordered_map *> __signalHash; + struct stRegisteredSignal + { + std::string signalName; + std::string className; + DSObject *obj; + DSSignal *signal; + + public: + stRegisteredSignal(std::string sn, DSObject *inpObj, DSSignal *inpSignal) + { + signalName = sn; + className = inpObj->getName(); + obj = inpObj; + signal = inpSignal; + } + + }; + + std::unordered_multimap __signalHash; DSSignalBroker() = delete; ~DSSignalBroker(); @@ -57,56 +76,121 @@ private: }; template -bool DSSignalBroker::registerCallback(std::string signalStr, DSObject *slot, std::function func) +bool DSSignalBroker::registerSignal(std::string signalStr, DSObject *obj) { if (!__signalBroker) return false; - if (__signalBroker->__signalHash.find(signalStr) == __signalBroker->__signalHash.end()) + if (__signalBroker->__signalHash.find(signalStr) != __signalBroker->__signalHash.end()) { - DSLOG_INF("DSSignalBroker","registerCallback:: cannot find signal, add new one %s", signalStr.c_str()); - - __signalBroker->__signalHash[signalStr] = reinterpret_cast *> (new DSSignal()); + auto range = __signalBroker->__signalHash.equal_range(signalStr); + for (auto iter = range.first; + iter != range.second; + iter++) + { + if (iter->second.obj == obj) + { + DSLOG_INF("DSSignalBroker","emitSignal:: already registered signal: %s", signalStr.c_str()); + return false; + } + else + { + DSLOG_DBG("DSSignalBroker", "searching same item: %s, obj(%p):%s", iter->second.signalName.c_str(), iter->second.obj, iter->second.className.c_str()); + } + + } } + DSSignal *signal = reinterpret_cast *> (new DSSignal()); + __signalBroker->__signalHash.insert(std::make_pair(signalStr, stRegisteredSignal(signalStr, obj, signal))); - DSSignal *signal = reinterpret_cast *>(__signalBroker->__signalHash[signalStr]); - if (signal) - signal->connect(slot, func); + DSLOG_DBG("DSSignalBroker","registerSignal:: registered new signal (name:%s, class(%p):%s, signal:%p)", + signalStr.c_str(), obj, obj->getName().c_str(), signal); return true; } template -bool DSSignalBroker::deregisterCallback(std::string signalStr, DSObject *slot, std::function func) +bool DSSignalBroker::emitSignal(std::string signalStr, DSObject *obj, Args... args) { if (!__signalBroker) return false; - if (__signalBroker->__signalHash.find(signalStr) == __signalBroker->__signalHash.end()) + if (__signalBroker->__signalHash.find(signalStr) != __signalBroker->__signalHash.end()) + { + auto range = __signalBroker->__signalHash.equal_range(signalStr); + for (auto iter = range.first; + iter != range.second; + iter++) + { + if (iter->second.obj == obj)// || iter->second.className == obj->getName()) + { + DSSignal *signal = reinterpret_cast *>(iter->second.signal); + if (signal) + { + signal->emit(args...); + DSLOG_DBG("DSSignalBroker","emitSignal:: signal emit (name:%s, class(%p):%s, signal:%p)", + iter->second.signalName.c_str(), iter->second.obj, iter->second.obj->getName().c_str(), iter->second.signal); + } + else + return false; + + return true; + } + } + } + else + { + DSLOG_INF("DSSignalBroker","emitSignal:: cannot find registered signal: %s", signalStr.c_str()); return false; + } - // TODO: have to impl disconnect method in DSSignal - //DSSignal *signal = reinterpret_cast *>(__signalBroker->__signalHash[signalStr]); - //if (signal) - //signal->disconnect(slot, func); - - return true; + return false; } template -bool DSSignalBroker::emitSignal(std::string signalStr, Args... args) +bool DSSignalBroker::registerCallback(std::string signalStr, DSObject *slot, std::function func) { if (!__signalBroker) return false; - if (__signalBroker->__signalHash.find(signalStr) == __signalBroker->__signalHash.end()) + if (__signalBroker->__signalHash.find(signalStr) != __signalBroker->__signalHash.end()) + { + auto range = __signalBroker->__signalHash.equal_range(signalStr); + for (auto iter = range.first; + iter != range.second; + iter++) { - DSLOG_INF("DSSignalBroker","emitSignal:: cannot find signal, add new one %s", signalStr.c_str()); - - __signalBroker->__signalHash[signalStr] = reinterpret_cast *> (new DSSignal()); + DSSignal *signal = reinterpret_cast *>(iter->second.signal); + if (signal) + signal->connect(slot, func); } + } + else + { + DSLOG_INF("DSSignalBroker","registerCallback:: cannot find signal: %s", signalStr.c_str()); + return false; + } + + return true; +} - DSSignal *signal = reinterpret_cast *>(__signalBroker->__signalHash[signalStr]); - if (signal) - signal->emit(args...); +template +bool DSSignalBroker::deregisterCallback(std::string signalStr, DSObject *slot, std::function func) +{ + // TODO: have to impl disconnect method in DSSignal + /* + if (!__signalBroker) return false; + if (__signalBroker->__signalHash.find(signalStr) != __signalBroker->__signalHash.end()) + { + auto range = __signalBroker->__signalHash.equal_range(signalStr); + for (auto iter = range.first; + iter != range.second; + iter++) + { + DSSignal *signal = reinterpret_cast *>(iter->second.signal); + if (signal) + signal->disconnect(slot, func); + } + } + */ return true; } diff --git a/tests/DSSignalBroker-test.cpp b/tests/DSSignalBroker-test.cpp index a4532b9..4484885 100644 --- a/tests/DSSignalBroker-test.cpp +++ b/tests/DSSignalBroker-test.cpp @@ -29,22 +29,19 @@ using namespace display_server; -class DSSignalBrokerTest : public ::testing::Test +struct stItem { -public: - void SetUp(void) override - {} - void TearDown(void) override - {} + std::string str1; + std::string str2; }; -class MockSignalBrokerSender : public DSObject +class MockSender : public DSObject { public: - MockSignalBrokerSender() {} - ~MockSignalBrokerSender() {} + MockSender() {} + ~MockSender() {} - bool sendSignal(std::string signalString) + bool registerSignal(std::string signalString) { DSSignalBroker *sigbro = DSSignalBroker::getInstance(); bool res = false; @@ -52,7 +49,57 @@ public: if (sigbro == nullptr) return false; - res = sigbro->emitSignal(signalString, true); + res = sigbro->registerSignal(signalString, this); + + if (sigbro) + sigbro->releaseInstance(); + + return res; + } + + bool sendSignal1(std::string signalString, int data) + { + DSSignalBroker *sigbro = DSSignalBroker::getInstance(); + bool res = false; + + if (sigbro == nullptr) + return false; + + res = sigbro->emitSignal(signalString, this, data); + + if (sigbro) + sigbro->releaseInstance(); + + return res; + } + + bool sendSignal2(std::string signalString, double data) + { + DSSignalBroker *sigbro = DSSignalBroker::getInstance(); + bool res = false; + + if (sigbro == nullptr) + return false; + + res = sigbro->emitSignal(signalString, this, data); + + if (sigbro) + sigbro->releaseInstance(); + + return res; + } + + bool sendSignal3(std::string signalString, std::string data1, std::string data2, std::string data3) + { + DSSignalBroker *sigbro = DSSignalBroker::getInstance(); + bool res = false; + + if (sigbro == nullptr) + return false; + + struct stItem testItem = {data2, data3}; + + res = sigbro->emitSignal(signalString, this, data1, testItem); if (sigbro) sigbro->releaseInstance(); @@ -61,29 +108,46 @@ public: } }; -class MockSignalBrokerReceiver : public DSObject +class MockReceiver : public DSObject { public: - MockSignalBrokerReceiver() = delete; - MockSignalBrokerReceiver(std::string targetSignal) + MockReceiver() : + result1(0), + result2(0.0), + result3("") { - __targetSignal = targetSignal; } - ~MockSignalBrokerReceiver() {} + ~MockReceiver() {} public: - std::string __targetSignal; - bool __result; + int result1; + double result2; + std::string result3; public: - bool registerCallback() + bool registerCallback1(std::string targetSignal) + { + bool res = false; + DSSignalBroker *sigbro = DSSignalBroker::getInstance(); + if (sigbro == nullptr) return false; + + std::function func = std::bind(&MockReceiver::UserCallback1, this, std::placeholders::_1); + res = sigbro->registerCallback(targetSignal, this, func); + + if (sigbro) + sigbro->releaseInstance(); + + return res; + } + + bool registerCallback2(std::string targetSignal) { bool res = false; DSSignalBroker *sigbro = DSSignalBroker::getInstance(); if (sigbro == nullptr) return false; - std::function func = std::bind(&MockSignalBrokerReceiver::callbackTestSignalBroker, this, std::placeholders::_1); - res = sigbro->registerCallback(__targetSignal, this, func); + std::function func = std::bind(&MockReceiver::UserCallback2, this, std::placeholders::_1); + res = sigbro->registerCallback(targetSignal, this, func); if (sigbro) sigbro->releaseInstance(); @@ -91,18 +155,52 @@ public: return res; } - void callbackTestSignalBroker(bool arg) + bool registerCallback3(std::string targetSignal) + { + bool res = false; + DSSignalBroker *sigbro = DSSignalBroker::getInstance(); + if (sigbro == nullptr) return false; + + std::function func = std::bind(&MockReceiver::UserCallback3, this, std::placeholders::_1, std::placeholders::_2); + res = sigbro->registerCallback(targetSignal, this, func); + + if (sigbro) + sigbro->releaseInstance(); + + return res; + } + + void UserCallback1(int arg) { DSLOG_INF("DSTEST", "%s is invoked!, arg: %d", __func__, arg); - __result = arg; + result1 = arg; } - bool getResult() + void UserCallback2(double arg) { - return __result; + DSLOG_INF("DSTEST", "%s is invoked!, arg: %d", __func__, arg); + result2 = arg; + } + + void UserCallback3(std::string arg1, struct stItem arg2) + { + DSLOG_INF("DSTEST", "%s is invoked!, arg1: %s, arg2{%s, %s}", __func__, arg1.c_str(), arg2.str1.c_str(), arg2.str2.c_str()); + result3 = arg1; } }; +class DSSignalBrokerTest : public ::testing::Test +{ +public: + void SetUp(void) override + {} + void TearDown(void) override + {} +}; + +std::shared_ptr __receiver; +std::shared_ptr __sender; + TEST_F(DSSignalBrokerTest, getInstance) { DSSignalBroker *sigbro = DSSignalBroker::getInstance(); @@ -112,39 +210,78 @@ TEST_F(DSSignalBrokerTest, getInstance) sigbro->releaseInstance(); } +TEST_F(DSSignalBrokerTest, registerSignal) +{ + __sender = std::make_shared(); + ASSERT_TRUE(__sender != nullptr); + + __sender->registerSignal("SampleSignal1"); +} + TEST_F(DSSignalBrokerTest, registerCallback) { - auto receiver = std::make_shared("TestSignalBroker"); - receiver->registerCallback(); + __receiver = std::make_shared(); + ASSERT_TRUE(__receiver != nullptr); + + __receiver->registerCallback1("SampleSignal1"); } TEST_F(DSSignalBrokerTest, emitSignal) { - auto receiver = std::make_shared("TestSignalBroker"); - auto sender = std::make_shared(); - ASSERT_TRUE(receiver != nullptr); - ASSERT_TRUE(sender != nullptr); - - receiver->registerCallback(); - EXPECT_TRUE(sender->sendSignal("TestSignalBroker")); - EXPECT_TRUE(receiver->getResult()); + ASSERT_TRUE(__sender != nullptr); + ASSERT_TRUE(__receiver != nullptr); + + EXPECT_TRUE(__sender->sendSignal1("SampleSignal1", 1)); + EXPECT_TRUE(__receiver->result1 == 1); } -TEST_F(DSSignalBrokerTest, emitSignal2) +TEST_F(DSSignalBrokerTest, registerAndEmit1) { - auto receiver1 = std::make_shared("TestSignalBroker"); - auto receiver2 = std::make_shared("TestSignalBroker2"); - auto sender = std::make_shared(); - ASSERT_TRUE(receiver1 != nullptr); - ASSERT_TRUE(receiver2 != nullptr); - ASSERT_TRUE(sender != nullptr); - - receiver1->registerCallback(); - receiver2->registerCallback(); - EXPECT_TRUE(sender->sendSignal("TestSignalBroker")); - EXPECT_TRUE(receiver1->getResult()); - EXPECT_TRUE(receiver2->getResult() != true); - - EXPECT_TRUE(sender->sendSignal("TestSignalBroker2")); - EXPECT_TRUE(receiver2->getResult()); + auto sender1 = std::make_shared(); + auto sender2 = std::make_shared(); + + auto receiver1 = std::make_shared(); + auto receiver2 = std::make_shared(); + + ASSERT_TRUE(sender1 != nullptr && + sender2 != nullptr && + receiver1 != nullptr && + receiver2 != nullptr); + + // 1. register Signal + EXPECT_TRUE(sender1->registerSignal("SampleSignal1")); + EXPECT_TRUE(sender2->registerSignal("SampleSignal2")); + + // 2. register Callback + EXPECT_TRUE(receiver1->registerCallback1("SampleSignal1")); + EXPECT_TRUE(receiver2->registerCallback2("SampleSignal2")); + + // 3. emit Signal + EXPECT_TRUE(sender1->sendSignal1("SampleSignal1", 11)); + EXPECT_TRUE(sender2->sendSignal2("SampleSignal2", 10.10)); + + // 4. see Changes + EXPECT_TRUE(receiver1->result1 == 11); + EXPECT_TRUE(receiver2->result2 == 10.10); } + +TEST_F(DSSignalBrokerTest, emitMultiItems) +{ + auto sender = std::make_shared(); + auto receiver = std::make_shared(); + + ASSERT_TRUE(sender != nullptr && + receiver != nullptr); + + // 1. register Signal + EXPECT_TRUE(sender->registerSignal("SampleSignal3")); + + // 2. register Callback + EXPECT_TRUE(receiver->registerCallback3("SampleSignal3")); + + // 3. emit Signal + EXPECT_TRUE(sender->sendSignal3("SampleSignal3", "Test", "Hello", "signal")); + + // 4. see Changes + EXPECT_TRUE(receiver->result3 == "Test"); +} \ No newline at end of file -- 2.7.4 From cfc166a98f2c5a8e9dc72080b1fc5f693969dc94 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Tue, 1 Sep 2020 21:17:36 +0900 Subject: [PATCH 12/16] tests: set default XDG_RUNTIME_DIR to /tmp Change-Id: Id447afec35ddbf83f4d09ec57a040ac9e6a2fcbe Signed-off-by: Sung-Jin Park --- tests/DSBufferManager-test.cpp | 17 ++++++++------- tests/DSBufferRef-test.cpp | 18 ++++++++-------- tests/DSBufferTBMImpl-test.cpp | 17 ++++++++------- tests/DSCanvas-test.cpp | 13 ++++++++---- tests/DSClient-test.cpp | 17 ++++++++------- tests/DSCompositor-test.cpp | 17 ++++++++------- tests/DSDebugLog-test.cpp | 13 ++++++++---- tests/DSDisplayArea-test.cpp | 17 ++++++++------- tests/DSDisplayDeviceTDMImpl-test.cpp | 18 ++++++++-------- tests/DSEventLoop-test.cpp | 13 ++++++++---- tests/DSInput-test.cpp | 13 ++++++++---- tests/DSKeyboard-test.cpp | 17 ++++++++------- tests/DSObject-test.cpp | 13 ++++++++---- tests/DSOutputImpl-test.cpp | 13 ++++++++---- tests/DSPointer-test.cpp | 17 ++++++++------- tests/DSPolicyArea-test.cpp | 13 ++++++++---- tests/DSProperty-test.cpp | 13 ++++++++---- tests/DSRefBase-test.cpp | 13 ++++++++---- tests/DSRenderEngineDaliImpl-test.cpp | 3 ++- tests/DSRenderEngineEcoreEvasImpl-test.cpp | 13 ++++++++---- tests/DSSeat-test.cpp | 17 ++++++++------- tests/DSSignal-test.cpp | 13 ++++++++---- tests/DSSignalBroker-test.cpp | 15 ++++++++----- tests/DSTextInput-test.cpp | 17 ++++++++------- tests/DSTizenAppinfo-test.cpp | 17 ++++++++------- tests/DSTouch-test.cpp | 17 ++++++++------- tests/DSTraceInfo-test.cpp | 17 ++++++++------- tests/DSWaylandBuffer-test.cpp | 13 ++++++++---- tests/DSWaylandCallback-test.cpp | 9 ++++++-- tests/DSWaylandClient-test.cpp | 17 ++++++++------- tests/DSWaylandCompositor-test.cpp | 17 ++++++++------- tests/DSWaylandExtension-test.cpp | 13 ++++++++---- tests/DSWaylandInputMethod-test.cpp | 3 ++- tests/DSWaylandInputMethodContext-test.cpp | 17 ++++++++------- tests/DSWaylandInputPanel-test.cpp | 17 ++++++++------- tests/DSWaylandInputPanelSurface-test.cpp | 17 ++++++++------- tests/DSWaylandKeyboard-test.cpp | 3 ++- tests/DSWaylandOutput-test.cpp | 13 ++++++++---- tests/DSWaylandPointer-test.cpp | 17 ++++++++------- tests/DSWaylandProtocolTrace-test.cpp | 28 ++++++++++++------------- tests/DSWaylandSeat-test.cpp | 17 ++++++++------- tests/DSWaylandSurface-test.cpp | 17 ++++++++------- tests/DSWaylandTextInput-test.cpp | 17 ++++++++------- tests/DSWaylandTextInputManager-test.cpp | 17 ++++++++------- tests/DSWaylandTizenAppinfo-test.cpp | 13 ++++++++---- tests/DSWaylandTizenIndicator-test.cpp | 13 ++++++++---- tests/DSWaylandTizenInputDevice-test.cpp | 13 ++++++++---- tests/DSWaylandTizenInputDeviceManager-test.cpp | 13 ++++++++---- tests/DSWaylandTizenLaunchEffect-test.cpp | 15 ++++++++----- tests/DSWaylandTizenPolicy-test.cpp | 13 ++++++++---- tests/DSWaylandTizenPolicyExt-test.cpp | 9 ++++++-- tests/DSWaylandTizenSurface-test.cpp | 13 ++++++++---- tests/DSWaylandTizenSurfaceShm-test.cpp | 13 ++++++++---- tests/DSWaylandTouch-test.cpp | 17 ++++++++------- tests/DSWaylandZxdgShellV6-test.cpp | 9 ++++++-- tests/DSWindow-test.cpp | 13 ++++++++---- tests/DSWindowManager-test.cpp | 15 +++++++------ tests/DSWindowShell-test.cpp | 13 ++++++++---- tests/DSXkb-test.cpp | 13 ++++++++---- tests/DSZone-test.cpp | 13 ++++++++---- tests/libds-tests.cpp | 1 + 61 files changed, 521 insertions(+), 341 deletions(-) diff --git a/tests/DSBufferManager-test.cpp b/tests/DSBufferManager-test.cpp index e21c556..9f6a1d2 100644 --- a/tests/DSBufferManager-test.cpp +++ b/tests/DSBufferManager-test.cpp @@ -32,14 +32,15 @@ using namespace display_server; class DSBufferManagerTest : public ::testing::Test { public: - void SetUp(void) override - { - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - void TearDown(void) override - { - 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(DSBufferManagerTest, GetBufferManager) diff --git a/tests/DSBufferRef-test.cpp b/tests/DSBufferRef-test.cpp index 55a7c85..fa99f39 100644 --- a/tests/DSBufferRef-test.cpp +++ b/tests/DSBufferRef-test.cpp @@ -31,15 +31,15 @@ using namespace display_server; class DSBufferRefTest : public ::testing::Test { public: - void SetUp(void) override - { - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - - void TearDown(void) override - { - 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(DSBufferRefTest, CreateBufferRef) diff --git a/tests/DSBufferTBMImpl-test.cpp b/tests/DSBufferTBMImpl-test.cpp index 6f801e6..fac2480 100644 --- a/tests/DSBufferTBMImpl-test.cpp +++ b/tests/DSBufferTBMImpl-test.cpp @@ -31,14 +31,15 @@ using namespace display_server; class DSBufferTBMImplTest : public ::testing::Test { public: - void SetUp(void) override - { - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - void TearDown(void) override - { - 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(DSBufferTBMImplTest, CreateBuffer) diff --git a/tests/DSCanvas-test.cpp b/tests/DSCanvas-test.cpp index 022e74d..a81a83e 100644 --- a/tests/DSCanvas-test.cpp +++ b/tests/DSCanvas-test.cpp @@ -33,10 +33,15 @@ using namespace display_server; class DSCanvasTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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(DSCanvasTest, NewDSCanvas) diff --git a/tests/DSClient-test.cpp b/tests/DSClient-test.cpp index 4c16109..0896cc8 100644 --- a/tests/DSClient-test.cpp +++ b/tests/DSClient-test.cpp @@ -35,14 +35,15 @@ using namespace display_server; class DSClientTest : public ::testing::Test { public: - void SetUp(void) override - { - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - void TearDown(void) override - { - 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(DSClientTest, NewDSClientWithDSWaylandClient) diff --git a/tests/DSCompositor-test.cpp b/tests/DSCompositor-test.cpp index 135920c..8de9fae 100644 --- a/tests/DSCompositor-test.cpp +++ b/tests/DSCompositor-test.cpp @@ -30,15 +30,16 @@ using namespace display_server; class DSCompositorTest : public ::testing::Test { public: - void SetUp(void) override - { + void SetUp(void) override + { // for wl_display_add_socket(private_loop->wl_display, "tdm-socket") at tdm_server_init - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } + char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); + setenv("XDG_RUNTIME_DIR", xdir, 1); + } + void TearDown(void) override + { + unsetenv("XDG_RUNTIME_DIR"); + } }; class MockCompositor : public DSCompositor diff --git a/tests/DSDebugLog-test.cpp b/tests/DSDebugLog-test.cpp index 78322b4..179a620 100644 --- a/tests/DSDebugLog-test.cpp +++ b/tests/DSDebugLog-test.cpp @@ -29,10 +29,15 @@ using namespace display_server; class DSDebugLogTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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(DSDebugLogTest, GetInstance) diff --git a/tests/DSDisplayArea-test.cpp b/tests/DSDisplayArea-test.cpp index ac22be6..3fb3af7 100644 --- a/tests/DSDisplayArea-test.cpp +++ b/tests/DSDisplayArea-test.cpp @@ -33,15 +33,16 @@ using namespace display_server; class DSDisplayAreaTest : public ::testing::Test { public: - void SetUp(void) override - { + void SetUp(void) override + { // for wl_display_add_socket(private_loop->wl_display, "tdm-socket") at tdm_server_init - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } + char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); + setenv("XDG_RUNTIME_DIR", xdir, 1); + } + void TearDown(void) override + { + unsetenv("XDG_RUNTIME_DIR"); + } }; TEST_F(DSDisplayAreaTest, NewDSDisplayArea) diff --git a/tests/DSDisplayDeviceTDMImpl-test.cpp b/tests/DSDisplayDeviceTDMImpl-test.cpp index b23e6bd..dfc8e94 100644 --- a/tests/DSDisplayDeviceTDMImpl-test.cpp +++ b/tests/DSDisplayDeviceTDMImpl-test.cpp @@ -31,15 +31,15 @@ using namespace display_server; class DSDisplayDeviceTDMImplTest : public ::testing::Test { public: - void SetUp(void) override - { - // for wl_display_add_socket(private_loop->wl_display, "tdm-socket") at tdm_server_init - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - void TearDown(void) override - { - 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"); + } }; // DSDisplayDeviceTDMImpl diff --git a/tests/DSEventLoop-test.cpp b/tests/DSEventLoop-test.cpp index 5621af0..40915e5 100644 --- a/tests/DSEventLoop-test.cpp +++ b/tests/DSEventLoop-test.cpp @@ -30,10 +30,15 @@ using namespace display_server; class DSEventLoopTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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(DSEventLoopTest, NewDSEventLoop) diff --git a/tests/DSInput-test.cpp b/tests/DSInput-test.cpp index 0109988..3090b30 100644 --- a/tests/DSInput-test.cpp +++ b/tests/DSInput-test.cpp @@ -31,10 +31,15 @@ using namespace display_server; class DSInputTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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"); + } }; class MockInput : public DSObject diff --git a/tests/DSKeyboard-test.cpp b/tests/DSKeyboard-test.cpp index 3c724b0..94aa630 100644 --- a/tests/DSKeyboard-test.cpp +++ b/tests/DSKeyboard-test.cpp @@ -34,14 +34,15 @@ using namespace display_server; class DSKeyboardTest : public ::testing::Test { public: - void SetUp(void) override - { - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - void TearDown(void) override - { - 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(DSKeyboardTest, NewDSKeyboardWithDSSeat) diff --git a/tests/DSObject-test.cpp b/tests/DSObject-test.cpp index 065a96f..48e3465 100644 --- a/tests/DSObject-test.cpp +++ b/tests/DSObject-test.cpp @@ -30,10 +30,15 @@ using namespace display_server; class DSObjectTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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"); + } }; /* Temporary classes for implemting PImpl Idiom based on DSObject/DSObjectPrivate classes */ diff --git a/tests/DSOutputImpl-test.cpp b/tests/DSOutputImpl-test.cpp index 044264b..9f2d9df 100644 --- a/tests/DSOutputImpl-test.cpp +++ b/tests/DSOutputImpl-test.cpp @@ -32,10 +32,15 @@ using namespace display_server; class DSOutputTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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(DSOutputTest, NewDSOutput) diff --git a/tests/DSPointer-test.cpp b/tests/DSPointer-test.cpp index f0cf678..d482d8a 100644 --- a/tests/DSPointer-test.cpp +++ b/tests/DSPointer-test.cpp @@ -34,14 +34,15 @@ using namespace display_server; class DSPointerTest : public ::testing::Test { public: - void SetUp(void) override - { - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - void TearDown(void) override - { - 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(DSPointerTest, NewDSPointerWithDSSeat) diff --git a/tests/DSPolicyArea-test.cpp b/tests/DSPolicyArea-test.cpp index cc106ff..af945c9 100644 --- a/tests/DSPolicyArea-test.cpp +++ b/tests/DSPolicyArea-test.cpp @@ -29,10 +29,15 @@ using namespace display_server; class DSPolicyAreaTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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(DSPolicyAreaTest, NewDSPolicyArea) diff --git a/tests/DSProperty-test.cpp b/tests/DSProperty-test.cpp index caaa2ca..85ae4f1 100644 --- a/tests/DSProperty-test.cpp +++ b/tests/DSProperty-test.cpp @@ -29,10 +29,15 @@ using namespace display_server; class DSPropertyTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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(DSPropertyTest, CreateProperty) diff --git a/tests/DSRefBase-test.cpp b/tests/DSRefBase-test.cpp index 26952be..f5198e9 100644 --- a/tests/DSRefBase-test.cpp +++ b/tests/DSRefBase-test.cpp @@ -29,10 +29,15 @@ using namespace display_server; class DSRefBaseTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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(DSRefBaseTest, CreateRefBase) diff --git a/tests/DSRenderEngineDaliImpl-test.cpp b/tests/DSRenderEngineDaliImpl-test.cpp index f3e6143..d794532 100644 --- a/tests/DSRenderEngineDaliImpl-test.cpp +++ b/tests/DSRenderEngineDaliImpl-test.cpp @@ -59,7 +59,8 @@ public: __eventLoop->run(); - setenv("XDG_RUNTIME_DIR", "/run", 1); + char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); + setenv("XDG_RUNTIME_DIR", xdir, 1); setenv("TBM_DISPLAY_SERVER", "1", 1); } void TearDown(void) override diff --git a/tests/DSRenderEngineEcoreEvasImpl-test.cpp b/tests/DSRenderEngineEcoreEvasImpl-test.cpp index ff917fd..4b93a28 100644 --- a/tests/DSRenderEngineEcoreEvasImpl-test.cpp +++ b/tests/DSRenderEngineEcoreEvasImpl-test.cpp @@ -31,10 +31,15 @@ using namespace display_server; class DSRenderEngineEcoreEvasTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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(DSRenderEngineEcoreEvasTest, RenderEngine_Create) diff --git a/tests/DSSeat-test.cpp b/tests/DSSeat-test.cpp index 03a4190..e20da03 100644 --- a/tests/DSSeat-test.cpp +++ b/tests/DSSeat-test.cpp @@ -30,14 +30,15 @@ using namespace display_server; class DSSeatTest : public ::testing::Test { public: - void SetUp(void) override - { - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - void TearDown(void) override - { - 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"); + } }; class MockCompositor : public DSCompositor diff --git a/tests/DSSignal-test.cpp b/tests/DSSignal-test.cpp index b37fe21..02db211 100644 --- a/tests/DSSignal-test.cpp +++ b/tests/DSSignal-test.cpp @@ -30,10 +30,15 @@ using namespace display_server; class DSSignalTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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"); + } }; class SenderMock : public DSObject diff --git a/tests/DSSignalBroker-test.cpp b/tests/DSSignalBroker-test.cpp index 4484885..644cc27 100644 --- a/tests/DSSignalBroker-test.cpp +++ b/tests/DSSignalBroker-test.cpp @@ -192,10 +192,15 @@ public: class DSSignalBrokerTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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"); + } }; std::shared_ptr __receiver; @@ -284,4 +289,4 @@ TEST_F(DSSignalBrokerTest, emitMultiItems) // 4. see Changes EXPECT_TRUE(receiver->result3 == "Test"); -} \ No newline at end of file +} diff --git a/tests/DSTextInput-test.cpp b/tests/DSTextInput-test.cpp index 721f0f3..55ba75d 100644 --- a/tests/DSTextInput-test.cpp +++ b/tests/DSTextInput-test.cpp @@ -29,14 +29,15 @@ using namespace display_server; class DSTextInputTest : public ::testing::Test { public: - void SetUp(void) override - { - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - void TearDown(void) override - { - 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 cases */ diff --git a/tests/DSTizenAppinfo-test.cpp b/tests/DSTizenAppinfo-test.cpp index b893611..2b2b7bc 100644 --- a/tests/DSTizenAppinfo-test.cpp +++ b/tests/DSTizenAppinfo-test.cpp @@ -30,14 +30,15 @@ using namespace display_server; class DSTizenAppinfoTest : public ::testing::Test { public: - void SetUp(void) override - { - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - void TearDown(void) override - { - 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(DSTizenAppinfoTest, NewTizenAppinfo) diff --git a/tests/DSTouch-test.cpp b/tests/DSTouch-test.cpp index 870cedf..ec62871 100644 --- a/tests/DSTouch-test.cpp +++ b/tests/DSTouch-test.cpp @@ -34,14 +34,15 @@ using namespace display_server; class DSTouchTest : public ::testing::Test { public: - void SetUp(void) override - { - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - void TearDown(void) override - { - 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(DSTouchTest, NewDSTouchWithDSSeat) diff --git a/tests/DSTraceInfo-test.cpp b/tests/DSTraceInfo-test.cpp index e382c2e..5d99ebb 100644 --- a/tests/DSTraceInfo-test.cpp +++ b/tests/DSTraceInfo-test.cpp @@ -29,14 +29,15 @@ using namespace display_server; class DSTraceInfoTest : public ::testing::Test { public: - void SetUp(void) override - { - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - void TearDown(void) override - { - 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(DSTraceInfoTest, NewTraceInfo) diff --git a/tests/DSWaylandBuffer-test.cpp b/tests/DSWaylandBuffer-test.cpp index 850bc52..e0e2fcd 100644 --- a/tests/DSWaylandBuffer-test.cpp +++ b/tests/DSWaylandBuffer-test.cpp @@ -29,10 +29,15 @@ using namespace display_server; class DSWaylandBufferTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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(DSWaylandBufferTest, NewDSWaylandBuffer) diff --git a/tests/DSWaylandCallback-test.cpp b/tests/DSWaylandCallback-test.cpp index d44a541..9c7a0e3 100644 --- a/tests/DSWaylandCallback-test.cpp +++ b/tests/DSWaylandCallback-test.cpp @@ -30,9 +30,14 @@ class DSWaylandCallbackTest : public ::testing::Test { public: 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(DSWaylandCallbackTest, NewDSWaylandCallback) diff --git a/tests/DSWaylandClient-test.cpp b/tests/DSWaylandClient-test.cpp index 7c6625a..e08707f 100644 --- a/tests/DSWaylandClient-test.cpp +++ b/tests/DSWaylandClient-test.cpp @@ -30,14 +30,15 @@ using namespace display_server; class DSWaylandClientTest : public ::testing::Test { public: - void SetUp(void) override - { - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - void TearDown(void) override - { - 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 cases */ diff --git a/tests/DSWaylandCompositor-test.cpp b/tests/DSWaylandCompositor-test.cpp index 7d0a735..c2bf133 100644 --- a/tests/DSWaylandCompositor-test.cpp +++ b/tests/DSWaylandCompositor-test.cpp @@ -30,14 +30,15 @@ using namespace display_server; class DSWaylandCompositorTest : public ::testing::Test { public: - void SetUp(void) override - { - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - void TearDown(void) override - { - 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 cases */ diff --git a/tests/DSWaylandExtension-test.cpp b/tests/DSWaylandExtension-test.cpp index c73aa79..eb9388e 100644 --- a/tests/DSWaylandExtension-test.cpp +++ b/tests/DSWaylandExtension-test.cpp @@ -31,10 +31,15 @@ using namespace display_server; class DSWaylandExtensionTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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(DSWaylandExtensionTest, NewWaylandExtension) diff --git a/tests/DSWaylandInputMethod-test.cpp b/tests/DSWaylandInputMethod-test.cpp index 152b953..98aeae4 100644 --- a/tests/DSWaylandInputMethod-test.cpp +++ b/tests/DSWaylandInputMethod-test.cpp @@ -31,7 +31,8 @@ class DSWaylandInputMethodTest : public ::testing::Test public: void SetUp(void) override { - setenv("XDG_RUNTIME_DIR", "/run", 1); + char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); + setenv("XDG_RUNTIME_DIR", xdir, 1); } void TearDown(void) override { diff --git a/tests/DSWaylandInputMethodContext-test.cpp b/tests/DSWaylandInputMethodContext-test.cpp index 6b2808e..ec2d51b 100644 --- a/tests/DSWaylandInputMethodContext-test.cpp +++ b/tests/DSWaylandInputMethodContext-test.cpp @@ -30,14 +30,15 @@ using namespace display_server; class DSWaylandInputMethodContextTest : public ::testing::Test { public: - void SetUp(void) override - { - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - void TearDown(void) override - { - 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 cases */ diff --git a/tests/DSWaylandInputPanel-test.cpp b/tests/DSWaylandInputPanel-test.cpp index 04d72a2..b367486 100644 --- a/tests/DSWaylandInputPanel-test.cpp +++ b/tests/DSWaylandInputPanel-test.cpp @@ -29,14 +29,15 @@ using namespace display_server; class DSWaylandInputPanelTest : public ::testing::Test { public: - void SetUp(void) override - { - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - void TearDown(void) override - { - 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 cases */ diff --git a/tests/DSWaylandInputPanelSurface-test.cpp b/tests/DSWaylandInputPanelSurface-test.cpp index c6ee3e1..3de9fa2 100644 --- a/tests/DSWaylandInputPanelSurface-test.cpp +++ b/tests/DSWaylandInputPanelSurface-test.cpp @@ -29,14 +29,15 @@ using namespace display_server; class DSWaylandInputPanelSurfaceTest : public ::testing::Test { public: - void SetUp(void) override - { - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - void TearDown(void) override - { - 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 cases */ diff --git a/tests/DSWaylandKeyboard-test.cpp b/tests/DSWaylandKeyboard-test.cpp index 2cac0bf..4146bcf 100644 --- a/tests/DSWaylandKeyboard-test.cpp +++ b/tests/DSWaylandKeyboard-test.cpp @@ -33,7 +33,8 @@ class DSWaylandKeyboardTest : public ::testing::Test public: void SetUp(void) override { - setenv("XDG_RUNTIME_DIR", "/run", 1); + char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); + setenv("XDG_RUNTIME_DIR", xdir, 1); } void TearDown(void) override { diff --git a/tests/DSWaylandOutput-test.cpp b/tests/DSWaylandOutput-test.cpp index 9794705..0009b60 100644 --- a/tests/DSWaylandOutput-test.cpp +++ b/tests/DSWaylandOutput-test.cpp @@ -29,10 +29,15 @@ using namespace display_server; class DSWaylandOutputTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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(DSWaylandOutputTest, NewDSWaylandOutput) diff --git a/tests/DSWaylandPointer-test.cpp b/tests/DSWaylandPointer-test.cpp index 119b16b..05cf9c0 100644 --- a/tests/DSWaylandPointer-test.cpp +++ b/tests/DSWaylandPointer-test.cpp @@ -31,14 +31,15 @@ using namespace display_server; class DSWaylandPointerTest : public ::testing::Test { public: - void SetUp(void) override - { - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - void TearDown(void) override - { - 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 cases */ diff --git a/tests/DSWaylandProtocolTrace-test.cpp b/tests/DSWaylandProtocolTrace-test.cpp index a7d3b6f..c5451ce 100644 --- a/tests/DSWaylandProtocolTrace-test.cpp +++ b/tests/DSWaylandProtocolTrace-test.cpp @@ -29,19 +29,19 @@ using namespace display_server; class DSWaylandProtocolTraceTest : public ::testing::Test { public: - void SetUp(void) override - { - setenv("XDG_RUNTIME_DIR", "/run", 1); - setenv("E_INFO_RULE_FILE", "/tmp/rule", 1); - setenv("E_INFO_TRACE_FILE", "/tmp/trace", 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - unsetenv("E_INFO_RULE_FILE"); - unsetenv("E_INFO_TRACE_FILE"); - } - + void SetUp(void) override + { + char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); + setenv("XDG_RUNTIME_DIR", xdir, 1); + setenv("E_INFO_RULE_FILE", "/tmp/rule", 1); + setenv("E_INFO_TRACE_FILE", "/tmp/trace", 1); + } + void TearDown(void) override + { + unsetenv("XDG_RUNTIME_DIR"); + unsetenv("E_INFO_RULE_FILE"); + unsetenv("E_INFO_TRACE_FILE"); + } }; TEST_F(DSWaylandProtocolTraceTest, NewDSWaylandProtocolTrace) @@ -146,4 +146,4 @@ TEST_F(DSWaylandProtocolTraceTest, DSWaylandProtocolTraceEnableTraceTrue) EXPECT_TRUE(pTrace->enableProtocolTrace(trace_state) == 1); DSWaylandProtocolTrace::releaseInstance(); } -} \ No newline at end of file +} diff --git a/tests/DSWaylandSeat-test.cpp b/tests/DSWaylandSeat-test.cpp index 8d2f000..06f67b7 100644 --- a/tests/DSWaylandSeat-test.cpp +++ b/tests/DSWaylandSeat-test.cpp @@ -32,14 +32,15 @@ using namespace display_server; class DSWaylandSeatTest : public ::testing::Test { public: - void SetUp(void) override - { - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - void TearDown(void) override - { - 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 cases */ diff --git a/tests/DSWaylandSurface-test.cpp b/tests/DSWaylandSurface-test.cpp index a83794b..a83d794 100644 --- a/tests/DSWaylandSurface-test.cpp +++ b/tests/DSWaylandSurface-test.cpp @@ -30,14 +30,15 @@ using namespace display_server; class DSWaylandSurfaceTest : public ::testing::Test { public: - void SetUp(void) override - { - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - void TearDown(void) override - { - 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"); + } }; static void diff --git a/tests/DSWaylandTextInput-test.cpp b/tests/DSWaylandTextInput-test.cpp index 5a3e18e..4dd5414 100644 --- a/tests/DSWaylandTextInput-test.cpp +++ b/tests/DSWaylandTextInput-test.cpp @@ -30,14 +30,15 @@ using namespace display_server; class DSWaylandTextInputTest : public ::testing::Test { public: - void SetUp(void) override - { - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - void TearDown(void) override - { - 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 cases */ diff --git a/tests/DSWaylandTextInputManager-test.cpp b/tests/DSWaylandTextInputManager-test.cpp index abca02b..03e34dd 100644 --- a/tests/DSWaylandTextInputManager-test.cpp +++ b/tests/DSWaylandTextInputManager-test.cpp @@ -29,14 +29,15 @@ using namespace display_server; class DSWaylandTextInputManagerTest : public ::testing::Test { public: - void SetUp(void) override - { - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - void TearDown(void) override - { - 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 cases */ diff --git a/tests/DSWaylandTizenAppinfo-test.cpp b/tests/DSWaylandTizenAppinfo-test.cpp index 212700d..8589a32 100644 --- a/tests/DSWaylandTizenAppinfo-test.cpp +++ b/tests/DSWaylandTizenAppinfo-test.cpp @@ -29,10 +29,15 @@ using namespace display_server; class DSWaylandTizenAppinfoTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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(DSWaylandTizenAppinfoTest, New_Appinfo) diff --git a/tests/DSWaylandTizenIndicator-test.cpp b/tests/DSWaylandTizenIndicator-test.cpp index 50df9de..2f3c4eb 100644 --- a/tests/DSWaylandTizenIndicator-test.cpp +++ b/tests/DSWaylandTizenIndicator-test.cpp @@ -29,10 +29,15 @@ using namespace display_server; class DSWaylandTizenIndicatorTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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(DSWaylandTizenIndicatorTest, NewDSWaylandTizenIndicator) diff --git a/tests/DSWaylandTizenInputDevice-test.cpp b/tests/DSWaylandTizenInputDevice-test.cpp index 5ebd223..8ca5d0a 100644 --- a/tests/DSWaylandTizenInputDevice-test.cpp +++ b/tests/DSWaylandTizenInputDevice-test.cpp @@ -29,10 +29,15 @@ using namespace display_server; class DSWaylandTizenInputDeviceTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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(DSWaylandTizenInputDeviceTest, NewDSWaylandTizenInputDevice) diff --git a/tests/DSWaylandTizenInputDeviceManager-test.cpp b/tests/DSWaylandTizenInputDeviceManager-test.cpp index aa437c7..09836aa 100644 --- a/tests/DSWaylandTizenInputDeviceManager-test.cpp +++ b/tests/DSWaylandTizenInputDeviceManager-test.cpp @@ -29,10 +29,15 @@ using namespace display_server; class DSWaylandTizenInputDeviceManagerTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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(DSWaylandTizenInputDeviceManagerTest, NewDSWaylandTizenInputDeviceManager) diff --git a/tests/DSWaylandTizenLaunchEffect-test.cpp b/tests/DSWaylandTizenLaunchEffect-test.cpp index 6a1eecd..14ed80a 100644 --- a/tests/DSWaylandTizenLaunchEffect-test.cpp +++ b/tests/DSWaylandTizenLaunchEffect-test.cpp @@ -29,10 +29,15 @@ using namespace display_server; class DSWaylandTizenLaunchEffectTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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(DSWaylandTizenLaunchEffectTest, New_LaunchEffect) @@ -61,4 +66,4 @@ TEST_F(DSWaylandTizenLaunchEffectTest, Initialize_LaunchEffect) delete tzLaunchEffect; DSWaylandCompositor::releaseInstance(); -} \ No newline at end of file +} diff --git a/tests/DSWaylandTizenPolicy-test.cpp b/tests/DSWaylandTizenPolicy-test.cpp index 81e5839..27ab7df 100644 --- a/tests/DSWaylandTizenPolicy-test.cpp +++ b/tests/DSWaylandTizenPolicy-test.cpp @@ -30,10 +30,15 @@ using namespace display_server; class DSWaylandTizenPolicyTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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(DSWaylandTizenPolicyTest, new_P1) diff --git a/tests/DSWaylandTizenPolicyExt-test.cpp b/tests/DSWaylandTizenPolicyExt-test.cpp index f5868e3..0f27e06 100644 --- a/tests/DSWaylandTizenPolicyExt-test.cpp +++ b/tests/DSWaylandTizenPolicyExt-test.cpp @@ -30,9 +30,14 @@ class DSWaylandTizenPolicyExtTest : public ::testing::Test { public: 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(DSWaylandTizenPolicyExtTest, NewDSWaylandTizenPolicyExt) diff --git a/tests/DSWaylandTizenSurface-test.cpp b/tests/DSWaylandTizenSurface-test.cpp index b4d04c7..ec979e4 100644 --- a/tests/DSWaylandTizenSurface-test.cpp +++ b/tests/DSWaylandTizenSurface-test.cpp @@ -29,10 +29,15 @@ using namespace display_server; class DSWaylandTizenSurfaceTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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(DSWaylandTizenSurfaceTest, NewDSWaylandTizenSurface) diff --git a/tests/DSWaylandTizenSurfaceShm-test.cpp b/tests/DSWaylandTizenSurfaceShm-test.cpp index 6471826..4579b4c 100644 --- a/tests/DSWaylandTizenSurfaceShm-test.cpp +++ b/tests/DSWaylandTizenSurfaceShm-test.cpp @@ -29,10 +29,15 @@ using namespace display_server; class DSWaylandTizenSurfaceShmTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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(DSWaylandTizenSurfaceShmTest, NewDSWaylandTizenSurfaceShm) diff --git a/tests/DSWaylandTouch-test.cpp b/tests/DSWaylandTouch-test.cpp index 60a2c46..a7c8a14 100644 --- a/tests/DSWaylandTouch-test.cpp +++ b/tests/DSWaylandTouch-test.cpp @@ -31,14 +31,15 @@ using namespace display_server; class DSWaylandTouchTest : public ::testing::Test { public: - void SetUp(void) override - { - setenv("XDG_RUNTIME_DIR", "/run", 1); - } - void TearDown(void) override - { - 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 cases */ diff --git a/tests/DSWaylandZxdgShellV6-test.cpp b/tests/DSWaylandZxdgShellV6-test.cpp index aae14f2..593bbc0 100644 --- a/tests/DSWaylandZxdgShellV6-test.cpp +++ b/tests/DSWaylandZxdgShellV6-test.cpp @@ -30,9 +30,14 @@ class DSWaylandZxdgShellV6Test : public ::testing::Test { public: 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(DSWaylandZxdgShellV6Test, NewDSWaylandZxdgShellV6) diff --git a/tests/DSWindow-test.cpp b/tests/DSWindow-test.cpp index 1ac52c9..d0f7695 100644 --- a/tests/DSWindow-test.cpp +++ b/tests/DSWindow-test.cpp @@ -32,10 +32,15 @@ using namespace display_server; class DSWindowTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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(DSWindowTest, NewDSWindow) diff --git a/tests/DSWindowManager-test.cpp b/tests/DSWindowManager-test.cpp index 319d418..cc3de04 100644 --- a/tests/DSWindowManager-test.cpp +++ b/tests/DSWindowManager-test.cpp @@ -36,15 +36,18 @@ DSWindowManager* g_winMgr = nullptr; class DSWindowManagerTest : public ::testing::Test { public: - void SetUp(void) override - { + 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 - { + } + void TearDown(void) override + { DSWindowManager::releaseInstance(); g_winMgr = nullptr; - } + unsetenv("XDG_RUNTIME_DIR"); + } }; TEST_F(DSWindowManagerTest, GetWindowManager) diff --git a/tests/DSWindowShell-test.cpp b/tests/DSWindowShell-test.cpp index 43ce069..bb5b3a7 100644 --- a/tests/DSWindowShell-test.cpp +++ b/tests/DSWindowShell-test.cpp @@ -34,10 +34,15 @@ using namespace display_server; class DSWindowShellTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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(DSWindowShellTest, NewDSWindowShell) diff --git a/tests/DSXkb-test.cpp b/tests/DSXkb-test.cpp index c57d66a..b28c036 100644 --- a/tests/DSXkb-test.cpp +++ b/tests/DSXkb-test.cpp @@ -29,10 +29,15 @@ using namespace display_server; class DSXkbTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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(DSXkbTest, NewDSXkb) diff --git a/tests/DSZone-test.cpp b/tests/DSZone-test.cpp index 83a685b..7e69b18 100644 --- a/tests/DSZone-test.cpp +++ b/tests/DSZone-test.cpp @@ -33,10 +33,15 @@ using namespace display_server; class DSZoneTest : public ::testing::Test { public: - void SetUp(void) override - {} - void TearDown(void) override - {} + 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"); + } }; class TestZone : public DSObject diff --git a/tests/libds-tests.cpp b/tests/libds-tests.cpp index 4a9ed5a..6446522 100644 --- a/tests/libds-tests.cpp +++ b/tests/libds-tests.cpp @@ -32,6 +32,7 @@ int main(int argc, char **argv) #ifdef TIZEN_TEST_GCOV setenv("GCOV_PREFIX", "/tmp", 1); #endif + setenv("DEFAULT_XDG_RUNTIME_DIR", "/tmp", 1); try { ::testing::InitGoogleMock(&argc, argv); -- 2.7.4 From 1389ee30f4f6ac4c36b5590e3634a41304d8f689 Mon Sep 17 00:00:00 2001 From: jeon Date: Tue, 1 Sep 2020 20:38:56 +0900 Subject: [PATCH 13/16] tests: set DSWaylandSurface to DSWindow Change-Id: I6b8fe90cca56a5808dd71d9db264489301ee7055 --- tests/DSKeyboard-test.cpp | 6 ++++++ tests/DSPointer-test.cpp | 6 ++++++ tests/DSTouch-test.cpp | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/tests/DSKeyboard-test.cpp b/tests/DSKeyboard-test.cpp index 94aa630..fe08c28 100644 --- a/tests/DSKeyboard-test.cpp +++ b/tests/DSKeyboard-test.cpp @@ -28,6 +28,7 @@ #include "DSWaylandSeat.h" #include "DSWaylandCompositor.h" #include "DSWindow.h" +#include "DSWaylandSurface.h" using namespace display_server; @@ -94,6 +95,11 @@ TEST_F(DSKeyboardTest, BasicMethods) auto window = std::make_shared(); EXPECT_TRUE(window != nullptr); + auto waylandSurface = std::make_shared(); + EXPECT_TRUE(waylandSurface != nullptr); + + window->create(waylandSurface); + if (seat && window) { auto keyboard = new DSKeyboard(seat); diff --git a/tests/DSPointer-test.cpp b/tests/DSPointer-test.cpp index d482d8a..10b18dd 100644 --- a/tests/DSPointer-test.cpp +++ b/tests/DSPointer-test.cpp @@ -28,6 +28,7 @@ #include "DSWaylandSeat.h" #include "DSWaylandCompositor.h" #include "DSWindow.h" +#include "DSWaylandSurface.h" using namespace display_server; @@ -94,6 +95,11 @@ TEST_F(DSPointerTest, BasicMethods) auto window = std::make_shared(); EXPECT_TRUE(window != nullptr); + auto waylandSurface = std::make_shared(); + EXPECT_TRUE(waylandSurface != nullptr); + + window->create(waylandSurface); + if (seat && window) { auto pointer = new DSPointer(seat); diff --git a/tests/DSTouch-test.cpp b/tests/DSTouch-test.cpp index ec62871..a9b476e 100644 --- a/tests/DSTouch-test.cpp +++ b/tests/DSTouch-test.cpp @@ -28,6 +28,7 @@ #include "DSWaylandSeat.h" #include "DSWaylandCompositor.h" #include "DSWindow.h" +#include "DSWaylandSurface.h" using namespace display_server; @@ -94,6 +95,11 @@ TEST_F(DSTouchTest, BasicMethods) auto window = std::make_shared(); EXPECT_TRUE(window != nullptr); + auto waylandSurface = std::make_shared(); + EXPECT_TRUE(waylandSurface != nullptr); + + window->create(waylandSurface); + if (seat && window) { auto touch = new DSTouch(seat); -- 2.7.4 From 486e5d53518bcf98b5f50509927b11779bc23529 Mon Sep 17 00:00:00 2001 From: jeon Date: Tue, 1 Sep 2020 21:47:19 +0900 Subject: [PATCH 14/16] tests: set nullptr to focus for test DSWaylandKeyboard temporary Change-Id: I38a5cc4b650ac1fab42e7b8027730139b6a1e1fb --- tests/DSWaylandKeyboard-test.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/DSWaylandKeyboard-test.cpp b/tests/DSWaylandKeyboard-test.cpp index 4146bcf..3254f4f 100644 --- a/tests/DSWaylandKeyboard-test.cpp +++ b/tests/DSWaylandKeyboard-test.cpp @@ -105,8 +105,13 @@ TEST_F(DSWaylandKeyboardTest, SetGetFocus) if (waylandSurface) { - keyboard->setFocus(waylandSurface.get()); - EXPECT_TRUE(waylandSurface.get() == keyboard->getFocus()); + /* FIXME: currently we cannot create wl_surface so setFocus will be always set nullptr to focus + * so temporary I set nullptr to focus for test but this will be fixed + * keyboard->setFocus(waylandSurface.get()); + * EXPECT_TRUE(waylandSurface.get() == keyboard->getFocus()); + */ + keyboard->setFocus(nullptr); + EXPECT_TRUE(nullptr == keyboard->getFocus()); } } } -- 2.7.4 From 13acba18dd973e99adc66a180342f0e66aa59b9f Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Wed, 2 Sep 2020 10:15:28 +0900 Subject: [PATCH 15/16] DSWaylandTizenPolicy: initialize member variable Change-Id: I00e9c371c6a7fe91746af2b9166062bd82be97fd --- src/DSWaylandServer/DSWaylandTizenPolicy.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp index 6b0f1fa..0e7ba7f 100644 --- a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp +++ b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp @@ -365,7 +365,8 @@ void DSWaylandTizenPolicyPrivate::tizen_policy_set_appid(Resource *resource, int DSWaylandTizenPolicy::DSWaylandTizenPolicy(DSWaylandCompositor *wlCompositor) : DS_INIT_PRIVATE_PTR(DSWaylandTizenPolicy), - __wlCompositor(wlCompositor) + __wlCompositor(wlCompositor), + __isCreated(false) { this->initialize(__wlCompositor); } -- 2.7.4 From 65e83e1da1a8f9dd281032852375158ff2597eb0 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Wed, 2 Sep 2020 10:36:28 +0900 Subject: [PATCH 16/16] tests: enable setting DEFAULT_XDG_RUNTIME_DIR environment variable Change-Id: I77d4b07286501ba296affb4a3eb918f2a642545b Signed-off-by: Sung-Jin Park --- tests/libds-tests.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/libds-tests.cpp b/tests/libds-tests.cpp index 6446522..1fd6b75 100644 --- a/tests/libds-tests.cpp +++ b/tests/libds-tests.cpp @@ -27,12 +27,16 @@ int main(int argc, char **argv) { + char *strEnv = nullptr; auto AllTestSuccess = false; #ifdef TIZEN_TEST_GCOV setenv("GCOV_PREFIX", "/tmp", 1); #endif - setenv("DEFAULT_XDG_RUNTIME_DIR", "/tmp", 1); + strEnv = getenv("DEFAULT_XDG_RUNTIME_DIR"); + if (!strEnv) { + setenv("DEFAULT_XDG_RUNTIME_DIR", "/tmp", 1); + } try { ::testing::InitGoogleMock(&argc, argv); -- 2.7.4