Name: capi-network-wifi-direct
Summary: Network WiFi-Direct Library
-Version: 1.3.2
+Version: 1.3.3
Release: 1
Group: Network & Connectivity/API
License: Apache-2.0
int ret = WIFI_DIRECT_ERROR_NONE;
unsigned int channel;
- if (g_client_info.is_registered == false) {
- WDC_LOGE("Client is NOT registered");
- __WDC_LOG_FUNC_END__;
- return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
- }
+ CHECK_INITIALIZED();
if (!cb) {
WDC_LOGE("NULL Param [callback]!");
wifi_direct_manager_mock_generate_activation_signal();
}
+bool wifi_direct_foreach_supported_channel_cb(unsigned int channel, void *user_data)
+{
+ return true;
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_foreach_supported_channel_Positive)
+{
+ int ret;
+
+ ret = wifi_direct_foreach_supported_channel(wifi_direct_foreach_supported_channel_cb, nullptr);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_foreach_supported_channel_Negative1)
+{
+ int ret = wifi_direct_foreach_supported_channel(nullptr, nullptr);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_INVALID_PARAMETER, ret);
+}
+
+TEST_F(WifiDirectSettingTest, wifi_direct_foreach_supported_channel_Negative2)
+{
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_deactivation_signal();
+
+ ret = wifi_direct_foreach_supported_channel(wifi_direct_foreach_supported_channel_cb, nullptr);
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NOT_PERMITTED, ret);
+
+ ret = wifi_direct_activate();
+ ASSERT_EQ(WIFI_DIRECT_ERROR_NONE, ret);
+
+ wifi_direct_manager_mock_generate_activation_signal();
+}
+
class WifiDirectConnectTest : public ::testing::Test {
protected:
void SetUp() override
GError *disconnect(std::string &mac_addr);
GError *getConnectedPeers(GVariant **ret);
GError *GetConnectingPeer(GVariant **ret);
+ GError *getSupportedChannels(GVariant **ret);
GVariant *getPeerInfoGvariant(void);
GVariant *getDiscoveredPeersGvariant(void);
WifiDirectManager *mgr_;
};
-
class GetWpsPinHandler : WifiDirectMethod {
public:
GetWpsPinHandler(WifiDirectManager *mgr) : mgr_(mgr){};
"GetWpsPin";
WifiDirectManager *mgr_;
};
+
+class GetSupportedChannelsHandler : WifiDirectMethod {
+public:
+ GetSupportedChannelsHandler(WifiDirectManager *mgr) : mgr_(mgr){};
+ ~GetSupportedChannelsHandler()
+ {
+ };
+ GVariant *handleMethod(GVariant *parameters, GError **error) override
+ {
+ GVariant *ret = NULL;
+
+ *error = mgr_->getSupportedChannels(&ret);
+
+ return ret;
+ }
+ std::string getMethodName()
+ {
+ return method_name_;
+ }
+private:
+ const std::string method_name_ =
+ "GetSupportedChannels";
+ WifiDirectManager *mgr_;
+};
+
WifiDirectManager::WifiDirectManager()
{
this->group_ = nullptr;
GetWpsPinHandler *get_wps_pin_handler = new GetWpsPinHandler(this);
this->method_map_[get_wps_pin_handler->getMethodName()] = (WifiDirectMethod *)get_wps_pin_handler;
+ GetSupportedChannelsHandler *get_supported_channels_handler = new GetSupportedChannelsHandler(this);
+ this->method_map_[get_supported_channels_handler->getMethodName()] = (WifiDirectMethod *)get_supported_channels_handler;
+
}
WifiDirectManager::~WifiDirectManager()
return ret;
}
+GError *WifiDirectManager::getSupportedChannels(GVariant **ret)
+{
+ if (this->state_ < WifiDirectState::kWifiDirectStateActivated)
+ return this->error_handler_.NotPermitted();
+
+ GVariantBuilder *builder = NULL;
+
+ unsigned int channel_data[] = {1, 6, 11};
+ builder = g_variant_builder_new(G_VARIANT_TYPE("au"));
+ for (int i = 0; i < 3; i++) {
+ g_variant_builder_add(builder, "u", channel_data[i]);
+ }
+
+ *ret = g_variant_new("(iau)", WIFI_DIRECT_ERROR_NONE, builder);
+ g_variant_builder_unref(builder);
+
+ return NULL;
+}
+
GVariant *WifiDirectManager::activated(void)
{
this->setState(WifiDirectState::kWifiDirectStateActivated);