revise unittest code quality accepted/tizen/unified/20200428.125850 submit/tizen/20200428.090338
authorYoungjae Shin <yj99.shin@samsung.com>
Tue, 28 Apr 2020 08:51:42 +0000 (17:51 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Tue, 28 Apr 2020 09:03:15 +0000 (18:03 +0900)
display/DisplayDenyPalmTouch.cpp
packaging/modes-plugins.spec
unittests/mdsp_test_app.cpp
unittests/mdsp_test_bt.cpp
unittests/mdsp_test_display.cpp
unittests/mdsp_test_integration.cpp
unittests/mdsp_test_media.cpp
unittests/mdsp_test_pkg.cpp
unittests/mdsp_test_vconf.cpp
unittests/mdsp_test_wifi.cpp
unittests/mode/tizen_Power-Save_mode.xml

index 8cc27b9..6666b97 100644 (file)
@@ -51,6 +51,7 @@ int DisplayDenyPalmTouch::set(bool val)
        }
 
        int ret = efl_util_gesture_activate_set(gestureHandle, EFL_UTIL_GESTURE_TYPE_PALM_COVER, !val);
+       efl_util_gesture_deinitialize(gestureHandle);
        ecore_wl2_display_disconnect(displayHandle);
        ecore_wl2_shutdown();
 
index f5d6f71..acba964 100644 (file)
@@ -100,15 +100,14 @@ systemctl restart modes.service
 
 %posttrans unittests
 systemctl restart modes.service
-export XDG_RUNTIME_DIR=/run
 %{modes_plugin_test_dir}/modes-plugintest-app
-%{modes_plugin_test_dir}/modes-plugintest-vconf
-%{modes_plugin_test_dir}/modes-plugintest-media
+XDG_RUNTIME_DIR=/run %{modes_plugin_test_dir}/modes-plugintest-media
 %{modes_plugin_test_dir}/modes-plugintest-wifi
 %{modes_plugin_test_dir}/modes-plugintest-bt
-%{modes_plugin_test_dir}/modes-plugintest-mode
 %{modes_plugin_test_dir}/modes-plugintest-pkg
-%{modes_plugin_test_dir}/modes-plugintest-display
+XDG_RUNTIME_DIR=/run %{modes_plugin_test_dir}/modes-plugintest-display
+%{modes_plugin_test_dir}/modes-plugintest-vconf
+%{modes_plugin_test_dir}/modes-plugintest-mode
 
 %postun -p /sbin/ldconfig
 
index 67eed26..e25e87a 100644 (file)
@@ -51,7 +51,8 @@ protected:
                action->undo();
                g_main_loop_quit(loop);
                plugin->deleteAction(action);
-               return false;
+
+               return G_SOURCE_REMOVE;
        }
 
        static gboolean checkSetUndoIdler(gpointer data)
@@ -72,36 +73,44 @@ protected:
 
        static void changedCB(void *userData)
        {
-               const char *appName = (char*)userData;
-               std::cout << appName << "is terminated" << std::endl;
+               PluginAction *action = (PluginAction*)userData;
+
+               cbCalled = true;
+               std::cout << ">>>>>>>> changedCB: Terminated <<<<<<<<" << std::endl;
+               appUndoTimeout(action);
        }
 
        static gboolean checkChangedCBIdler(gpointer data)
        {
+               sleep(1);
                PluginAction *action = plugin->newAction("launch");
                EXPECT_FALSE(action->IsCurrentValue(std::string(testApp)));
                result = action->set(std::string(testApp));
                EXPECT_EQ(MODES_ERROR_NONE, result);
 
-               int ret = action->setChangedCallback(changedCB, (void*)testApp);
-               EXPECT_EQ(MODES_ERROR_NONE, ret);
-
-               app_context_h runAppContext = NULL;
-               app_manager_get_app_context(testApp, &runAppContext);
-               app_manager_terminate_app(runAppContext);
-
                if (MODES_ERROR_NONE == result) {
-                       g_timeout_add(1000, appUndoTimeout, action);
+                       int ret = action->setChangedCallback(changedCB, action);
+                       EXPECT_EQ(MODES_ERROR_NONE, ret);
+                       g_timeout_add(20000, appUndoTimeout, action); //For running continue
                } else {
                        g_main_loop_quit(loop);
                        plugin->deleteAction(action);
                }
 
+               sleep(1);
+               app_context_h runAppContext = NULL;
+               int ret = app_manager_get_app_context(testApp, &runAppContext);
+               if (APP_MANAGER_ERROR_NONE != ret)
+                       std::cout << testApp << " get_app_context() Fail:" << ret << std::endl;
+               else
+                       app_manager_terminate_app(runAppContext);
+
                return G_SOURCE_REMOVE;
        }
 
        static const char *testApp;
        static int result;
+       static bool cbCalled;
        static GMainLoop *loop;
        static GThread *my_thread;
        static Plugin *plugin;
@@ -109,6 +118,7 @@ protected:
 
 const char *AppPluginTest::testApp = "org.tizen.setting";
 int AppPluginTest::result = 0;
+bool AppPluginTest::cbCalled = false;
 Plugin *AppPluginTest::plugin = nullptr;
 GMainLoop *AppPluginTest::loop = NULL;
 
@@ -120,12 +130,14 @@ TEST_F(AppPluginTest, CheckSetUndo)
 
 TEST_F(AppPluginTest, checkChangedCB)
 {
-       sleep(3);
+       cbCalled = false;
        g_idle_add(checkChangedCBIdler, NULL);
        g_main_loop_run(loop);
+       //TODO: at posttrans of unittest, changedCB is not called
+       //EXPECT_EQ(cbCalled, true);
 }
 
 int main(int argc, char **argv) {
-       testing::InitGoogleTest(&argc, argv);
+       ::testing::InitGoogleTest(&argc, argv);
        return RUN_ALL_TESTS();
 }
index 3c5d4c5..4fc5d24 100644 (file)
@@ -119,7 +119,7 @@ TEST_F(BtPluginTest, btTest)
 
 int main(int argc, char **argv)
 {
-       testing::InitGoogleTest(&argc, argv);
+       ::testing::InitGoogleTest(&argc, argv);
        return RUN_ALL_TESTS();
 }
 
index f774dbd..c038d5a 100644 (file)
@@ -133,6 +133,6 @@ TEST_F(displayPluginTest, setDenyPalmTouch)
 }
 
 int main(int argc, char **argv) {
-       testing::InitGoogleTest(&argc, argv);
+       ::testing::InitGoogleTest(&argc, argv);
        return RUN_ALL_TESTS();
 }
index 566246a..825ad59 100644 (file)
@@ -103,9 +103,8 @@ TEST_F(IntegrationTest, runMode_waterlock)
        EXPECT_EQ(MODES_ERROR_NONE, result);
 }
 
-
 int main(int argc, char **argv)
 {
-       testing::InitGoogleTest(&argc, argv);
+       ::testing::InitGoogleTest(&argc, argv);
        return RUN_ALL_TESTS();
 }
index fa1ddd5..8bed4ad 100644 (file)
@@ -158,6 +158,6 @@ TEST_F(MediaPluginTest, setUndoMediaVolume)
 }
 
 int main(int argc, char **argv) {
-       testing::InitGoogleTest(&argc, argv);
+       ::testing::InitGoogleTest(&argc, argv);
        return RUN_ALL_TESTS();
 }
index e6bb2a3..936a05b 100644 (file)
@@ -16,6 +16,7 @@
 #include <glib.h>
 #include <string>
 #include <gtest/gtest.h>
+#include <vconf.h>
 #include <Plugin.h>
 #include "plugin-def.h"
 
@@ -38,6 +39,7 @@ protected:
                loop = NULL;
                objectDelete(plugin);
                plugin = nullptr;
+               vconf_set_str("db/setting/menuscreen/package_name", "org.tizen.homescreen-efl");
        }
 
        static gboolean pkgPluginIdler(gpointer data)
@@ -71,6 +73,6 @@ TEST_F(PkgPluginTest, setUndoTest)
 }
 
 int main(int argc, char **argv) {
-       testing::InitGoogleTest(&argc, argv);
+       ::testing::InitGoogleTest(&argc, argv);
        return RUN_ALL_TESTS();
 }
index e457149..c6f2230 100644 (file)
@@ -189,6 +189,6 @@ TEST_F(VconfPluginTest, callbackPluginVconf)
 }
 
 int main(int argc, char **argv) {
-       testing::InitGoogleTest(&argc, argv);
+       ::testing::InitGoogleTest(&argc, argv);
        return RUN_ALL_TESTS();
 }
index 3b49df8..9605663 100644 (file)
@@ -90,6 +90,6 @@ TEST_F(WifiPluginTest, wifiTest)
 }
 
 int main(int argc, char **argv) {
-       testing::InitGoogleTest(&argc, argv);
+       ::testing::InitGoogleTest(&argc, argv);
        return RUN_ALL_TESTS();
 }
index e8531ef..6e47222 100644 (file)
@@ -9,5 +9,6 @@
     <action rule="vconf.db.setting.sound.vibration_on" restrict="lock">0</action>
     <action rule="vconf.db.location.setting.Usemylocation" restrict="lock">0</action>
     <action rule="vconf.db.setting.menuscreen.package_name" restrict="lock">org.tizen.menu-screen</action>
+    <undo rule="vconf.db.setting.menuscreen.package_name" restrict="lock">org.tizen.homescreen-efl</undo>
   </mode>
 </tizenModes>