Simplify the setup and teardown logic of tests 83/286183/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Thu, 17 Nov 2022 06:21:36 +0000 (15:21 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Fri, 30 Dec 2022 01:45:04 +0000 (10:45 +0900)
- Requirements:
The setup and teardown method is too complicated to change.

- Contents:
This patch simplifies the setup and teardown method for future
refactoring and adding new TCs.

Change-Id: I706e7f0fcf5b50f86546ae0c63aa8e27ff491180
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
tests/src/vc_unittests.cpp

index 780b61e..6963fbc 100644 (file)
@@ -135,6 +135,23 @@ static void __vc_mgr_finish()
        EXPECT_EQ(vc_mgr_deinitialize(), VC_ERROR_NONE);
 }
 
+static bool __is_vc_supported()
+{
+       bool is_vc_supported = false;
+       bool is_mic_supported = false;
+       if (0 != system_info_get_platform_bool("http://tizen.org/feature/speech.control", &is_vc_supported))
+       {
+               is_vc_supported = false;
+       }
+
+       if (0 != system_info_get_platform_bool("http://tizen.org/feature/microphone", &is_mic_supported))
+       {
+               is_mic_supported = false;
+       }
+
+       return (is_vc_supported && is_mic_supported);
+}
+
 namespace {
 
 class VCTest : public testing::Test {
@@ -143,44 +160,16 @@ class VCTest : public testing::Test {
                        ecore_init();
                        ecore_main_loop_glib_integrate();
 
-                       cynara_check_set_result(CYNARA_API_ACCESS_ALLOWED);
+                       g_vc_supported = __is_vc_supported();
 
-                       g_vc_supported = false;
-                       bool mic_supported = false;
-                       bool vc_supported = false;
-                       if (0 == system_info_get_platform_bool("http://tizen.org/feature/speech.control", &vc_supported))
-                       {
-                               if (0 == system_info_get_platform_bool("http://tizen.org/feature/microphone", &mic_supported))
-                               {
-                                       if (true == vc_supported && true == mic_supported)
-                                       {
-                                               g_vc_supported = true;
-                                       }
-                               }
+                       if (false == g_vc_supported) {
+                               g_vc_init = false;
+                               return;
                        }
 
-                       g_vc_init = false;
-                       if (true == g_vc_supported)
-                       {
-                               int ret = VC_ERROR_NONE;
-                               ret = vc_initialize();
-                               if (VC_ERROR_NONE == ret)
-                               {
-                                       ret = vc_set_state_changed_cb(__vc_state_changed_cb, NULL);
-                                       if (VC_ERROR_NONE != ret)
-                                       {
-                                               g_vc_init = false;
-                                       }
-                                       else
-                                       {
-                                               g_vc_init = true;
-                                       }
-                               }
-                               else
-                               {
-                                       g_vc_init = false;
-                               }
-                       }
+                       g_vc_init = true;
+                       vc_initialize();
+                       vc_set_state_changed_cb(__vc_state_changed_cb, NULL);
                }
 
                virtual void TearDown()
@@ -188,12 +177,9 @@ class VCTest : public testing::Test {
                        if (true == g_vc_supported)
                        {
                                vc_unset_state_changed_cb();
-
                                vc_deinitialize();
                        }
 
-                       g_vc_init = false;
-
                        ecore_shutdown();
                }
 };