+TEST(Hal_wifi_direct, Init_p)
+{
+ g_bFeatureP2P = __check_feature_supported((char*)WIFIDIRECT_FEATURE);
+ ASSERT_EQ(true, g_bFeatureP2P) << WIFIDIRECT_FEATURE << " feature is not supported";
+
+ int rv = wifi_direct_initialize();
+ EXPECT_EQ(WIFI_DIRECT_ERROR_NONE, rv) << "Initialization failure";
+}
+
+TEST(Hal_wifi_direct, Activate_p)
+{
+ ASSERT_EQ(true, g_bFeatureP2P) << WIFIDIRECT_FEATURE << " feature is not supported";
+
+ int rv;
+ wifi_direct_state_e state = WIFI_DIRECT_STATE_ACTIVATED;
+
+ rv = wifi_direct_get_state(&state);
+ ASSERT_EQ(0, rv) << "Failed to get Wi-Fi Direct device state";
+
+ if (state != WIFI_DIRECT_STATE_DEACTIVATED)
+ goto done;
+
+ rv = wifi_direct_set_device_state_changed_cb(__device_state_changed_cb, NULL);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, rv) << "Failed to set activation callback";
+
+ rv = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, rv) << "Failed to activate Wi-Fi Direct device";
+
+ RUN_GMAIN_LOOP(__timeout_callback);
+
+ EXPECT_EQ(WIFI_DIRECT_ERROR_NONE, rst_p2p) << "Activetion failure";
+ rst_p2p = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+
+ rv = wifi_direct_get_state(&state);
+ EXPECT_EQ(0, rv) << "Failed to get Wi-Fi Direct device state";
+ EXPECT_EQ(WIFI_DIRECT_STATE_ACTIVATED, state) << "Activetion failure";
+
+done:
+ if (p2p_ifname[0])
+ rv = access(p2p_ifname, F_OK);
+ else
+ rv = access(WIFI_P2P_PATH, F_OK);
+ EXPECT_EQ(0, rv) << "Could not access " << WIFI_ADDRESS_PATH;
+}
+
+TEST(Hal_wifi_direct, Deactivate_p)
+{
+ ASSERT_EQ(true, g_bFeatureP2P) << WIFIDIRECT_FEATURE << " feature is not supported";
+
+ int rv;
+
+ rv = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, rv) << "Failed to deactivate Wi-Fi Direct";
+
+ RUN_GMAIN_LOOP(__timeout_callback);
+
+ EXPECT_EQ(WIFI_DIRECT_ERROR_NONE, rst_p2p) << "Deactivation failure";
+ rst_p2p = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+
+ wifi_direct_state_e state = WIFI_DIRECT_STATE_ACTIVATED;
+ rv = wifi_direct_get_state(&state);
+ EXPECT_EQ(0, rv) << "Failed to get Wi-Fi Direct device state";
+
+ EXPECT_EQ(WIFI_DIRECT_STATE_DEACTIVATED, state) << "Deactivetion failure";
+
+ if (p2p_ifname[0])
+ rv = access(p2p_ifname, F_OK);
+ else
+ rv = access(WIFI_P2P_PATH, F_OK);
+ EXPECT_EQ(-1, rv) << WIFI_P2P_PATH << " is exist";
+
+ rv = wifi_direct_unset_device_state_changed_cb();
+ EXPECT_EQ(WIFI_DIRECT_ERROR_NONE, rv) << "Failed to unset activation callback";
+}
+
+TEST(Hal_wifi_direct, Deinit_p)
+{
+ ASSERT_EQ(true, g_bFeatureP2P) << WIFIDIRECT_FEATURE << " feature is not supported";
+
+ int rv = wifi_direct_deinitialize();
+ EXPECT_EQ(WIFI_DIRECT_ERROR_NONE, rv) << "Deinitialization failure";
+}
+
+TEST(Hal_softap, Init_p)
+{
+ g_bFeatureWifi = __check_feature_supported((char*)FEATURE_WIFI);
+ ASSERT_EQ(true, g_bFeatureWifi) << FEATURE_WIFI << " feature is not supported";
+
+ int ret = SOFTAP_ERROR_NONE;
+
+ ret = softap_create(&sa);
+ ASSERT_EQ(SOFTAP_ERROR_NONE, ret) << "Initialization failure";
+
+ ret = softap_set_enabled_cb(sa, __enabled_cb, NULL);
+ EXPECT_EQ(SOFTAP_ERROR_NONE, ret) << "Fail to set enabled callback!!";
+
+ ret = softap_set_disabled_cb(sa, __disabled_cb, NULL);
+ EXPECT_EQ(SOFTAP_ERROR_NONE, ret) << "Fail to set disabled callback!!";
+}
+
+TEST(Hal_softap, Activate_p)
+{
+ ASSERT_EQ(true, g_bFeatureWifi) << FEATURE_WIFI << " feature is not supported";
+
+ int ret = SOFTAP_ERROR_NONE;
+ bool enabled = false;
+
+ ret = softap_is_enabled(sa, &enabled);
+ ASSERT_EQ(SOFTAP_ERROR_NONE, ret) << "Failed to get SoftAP state";
+
+ if (enabled)
+ goto done;
+
+ ret = softap_enable(sa);
+ ASSERT_EQ(SOFTAP_ERROR_NONE, ret) << "Failed to enable SoftAP";
+
+ RUN_GMAIN_LOOP(__timeout_callback);
+
+ EXPECT_EQ(SOFTAP_ERROR_NONE, g_error) << "Failed to enable SoftAP";
+ EXPECT_EQ(true, g_is_requested) << "Failed to enable SoftAP";
+
+done:
+ ret = access(WIFI_ADDRESS_PATH, F_OK);
+ EXPECT_EQ(0, ret) << "Could not access " << WIFI_ADDRESS_PATH;
+}
+
+TEST(Hal_softap, Deactivate_p)
+{
+ ASSERT_EQ(true, g_bFeatureWifi) << FEATURE_WIFI << " feature is not supported";
+
+ int ret = SOFTAP_ERROR_NONE;
+
+ ret = softap_disable(sa);
+ ASSERT_EQ(SOFTAP_ERROR_NONE, ret) << "Failed to disable SoftAP";
+
+ RUN_GMAIN_LOOP(__timeout_callback);
+
+ EXPECT_EQ(SOFTAP_ERROR_NONE, g_error) << "Failed to disable SoftAP" << g_code;
+
+ ret = access(WIFI_ADDRESS_PATH, F_OK);
+ EXPECT_EQ(-1, ret) << WIFI_ADDRESS_PATH << " is exist";
+}
+
+TEST(Hal_softap, Deinit_p)
+{
+ ASSERT_EQ(true, g_bFeatureWifi) << FEATURE_WIFI << " feature is not supported";
+
+ int ret = SOFTAP_ERROR_NONE;
+
+ ret = softap_unset_enabled_cb(sa);
+ EXPECT_EQ(SOFTAP_ERROR_NONE, ret) << "Fail to unset enabled callback!!";
+
+ ret = softap_unset_disabled_cb(sa);
+ EXPECT_EQ(SOFTAP_ERROR_NONE, ret) << "Fail to unset disabled callback!!";
+
+ ret = softap_destroy(sa);
+ EXPECT_EQ(SOFTAP_ERROR_NONE, ret) << "Deinitialization failure";
+}
+