Check the feature in order to execute HAL accordance with the feature. 25/187125/2 accepted/tizen/unified/20180821.091013 submit/tizen/20180820.085416 submit/tizen/20180820.100957
authorsaerome.kim <saerome.kim@samsung.com>
Mon, 20 Aug 2018 07:07:37 +0000 (16:07 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 20 Aug 2018 07:49:16 +0000 (16:49 +0900)
Change-Id: Ic4cbc0c66a8c70c2dd02a7a9b7811a0984f2f22b
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
haltest/zigbee-manager-haltests.cpp

index 52de0dd..810047d 100644 (file)
 
 #include "zbl.h"
 
-#define FEATURE_ZIGBEE       "http://tizen.org/feature/network.zigbee"
-static bool g_bFeatureZb = false;
-
 using ::testing::InitGoogleTest;
 using ::testing::Test;
 using ::testing::TestCase;
 
-static bool __check_feature_supported(char *key)
-{
-       bool value = false;
-       int ret = system_info_get_platform_bool(key, &value);
+const char *feature_name = (char *)"http://tizen.org/feature/network.zigbee";
 
-       EXPECT_EQ(SYSTEM_INFO_ERROR_NONE, ret) << "system_info_get_platform_bool failed";
-       EXPECT_EQ(true, value) << key << " feature is not supported";
+static bool __check_feature_supported()
+{
+       bool zigbee_supported = FALSE;
+       if (!system_info_get_platform_bool(feature_name, &zigbee_supported)) {
+               if (FALSE == zigbee_supported) {
+                       GLOGD("zigbee feature is disabled");
+                       return ZIGBEE_ERROR_NOT_SUPPORTED;
+               }
+               return ZIGBEE_ERROR_NONE;
+       } else {
+               GLOGD("Error - Feature getting from System Info");
+               return ZIGBEE_ERROR_INVALID_PARAMETER;
+       }
 
-       return value;
 }
 
 /*
@@ -57,13 +61,12 @@ static bool __check_feature_supported(char *key)
 */
 TEST(ZigbeeManager, Enable_p)
 {
-       g_bFeatureZb = __check_feature_supported((char*)FEATURE_ZIGBEE);
-       ASSERT_EQ(true, g_bFeatureZb) << FEATURE_ZIGBEE << " feature is not supported";
-
        int ret = ZIGBEE_ERROR_NONE;
        Zigbee zb_mgr;
 
-       ret = zb_mgr.zbl_enable();
+       if (ZIGBEE_ERROR_NONE == __check_feature_supported()) {
+               ret = zb_mgr.zbl_enable();
+       }
        EXPECT_EQ(ZIGBEE_ERROR_NONE, ret);
 }
 
@@ -82,13 +85,12 @@ TEST(ZigbeeManager, Enable_p)
 */
 TEST(ZigbeeManager, Disable_p)
 {
-       g_bFeatureZb = __check_feature_supported((char*)FEATURE_ZIGBEE);
-       ASSERT_EQ(true, g_bFeatureZb) << FEATURE_ZIGBEE << " feature is not supported";
-
        int ret = ZIGBEE_ERROR_NONE;
        Zigbee zb_mgr;
 
-       ret = zb_mgr.zbl_disable();
+       if (ZIGBEE_ERROR_NONE == __check_feature_supported()) {
+               ret = zb_mgr.zbl_disable();
+       }
        EXPECT_EQ(ZIGBEE_ERROR_NONE, ret);
 }