From 03c61f11205932ce76f574f894dba54339612757 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Thu, 17 Nov 2022 15:21:36 +0900 Subject: [PATCH] Simplify the setup and teardown logic of tests - 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 --- tests/src/vc_unittests.cpp | 62 +++++++++++++++----------------------- 1 file changed, 24 insertions(+), 38 deletions(-) diff --git a/tests/src/vc_unittests.cpp b/tests/src/vc_unittests.cpp index 780b61e..6963fbc 100644 --- a/tests/src/vc_unittests.cpp +++ b/tests/src/vc_unittests.cpp @@ -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(); } }; -- 2.34.1