1094332d3Sopenharmony_ci/*
2094332d3Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd.
3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License.
5094332d3Sopenharmony_ci * You may obtain a copy of the License at
6094332d3Sopenharmony_ci *
7094332d3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0
8094332d3Sopenharmony_ci *
9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and
13094332d3Sopenharmony_ci * limitations under the License.
14094332d3Sopenharmony_ci */
15094332d3Sopenharmony_ci
16094332d3Sopenharmony_ci#include <cstdint>
17094332d3Sopenharmony_ci#include <cstdio>
18094332d3Sopenharmony_ci#include <cstdlib>
19094332d3Sopenharmony_ci#include <string>
20094332d3Sopenharmony_ci#include <unistd.h>
21094332d3Sopenharmony_ci#include <fcntl.h>
22094332d3Sopenharmony_ci#include <gtest/gtest.h>
23094332d3Sopenharmony_ci#include "hdf_io_service_if.h"
24094332d3Sopenharmony_ci#include "hdf_uhdf_test.h"
25094332d3Sopenharmony_ci#include "hdf_wifi_test.h"
26094332d3Sopenharmony_ci
27094332d3Sopenharmony_ciusing namespace testing::ext;
28094332d3Sopenharmony_ci
29094332d3Sopenharmony_cinamespace NetDeviceTest {
30094332d3Sopenharmony_ciclass WiFiNetDeviceTest : public testing::Test {
31094332d3Sopenharmony_cipublic:
32094332d3Sopenharmony_ci    static void SetUpTestCase();
33094332d3Sopenharmony_ci    static void TearDownTestCase();
34094332d3Sopenharmony_ci    void SetUp();
35094332d3Sopenharmony_ci    void TearDown();
36094332d3Sopenharmony_ci};
37094332d3Sopenharmony_ci
38094332d3Sopenharmony_civoid WiFiNetDeviceTest::SetUpTestCase()
39094332d3Sopenharmony_ci{
40094332d3Sopenharmony_ci    HdfTestOpenService();
41094332d3Sopenharmony_ci    struct HdfTestMsg msg = {TEST_WIFI_TYPE, WIFI_NET_DEVICE_INIT, -1};
42094332d3Sopenharmony_ci    HdfTestSendMsgToService(&msg);
43094332d3Sopenharmony_ci}
44094332d3Sopenharmony_ci
45094332d3Sopenharmony_civoid WiFiNetDeviceTest::TearDownTestCase()
46094332d3Sopenharmony_ci{
47094332d3Sopenharmony_ci    struct HdfTestMsg msg = {TEST_WIFI_TYPE, WIFI_NET_DEVICE_DEINIT, -1};
48094332d3Sopenharmony_ci    HdfTestSendMsgToService(&msg);
49094332d3Sopenharmony_ci    HdfTestCloseService();
50094332d3Sopenharmony_ci}
51094332d3Sopenharmony_ci
52094332d3Sopenharmony_civoid WiFiNetDeviceTest::SetUp() {}
53094332d3Sopenharmony_ci
54094332d3Sopenharmony_civoid WiFiNetDeviceTest::TearDown() {}
55094332d3Sopenharmony_ci
56094332d3Sopenharmony_ci/**
57094332d3Sopenharmony_ci  * @tc.name: WiFiNetDeviceInit001
58094332d3Sopenharmony_ci  * @tc.desc: init netdevice function test
59094332d3Sopenharmony_ci  * @tc.type: FUNC
60094332d3Sopenharmony_ci  * @tc.require: AR000F869H
61094332d3Sopenharmony_ci  */
62094332d3Sopenharmony_ciHWTEST_F(WiFiNetDeviceTest, WiFiNetDeviceInit001, TestSize.Level1)
63094332d3Sopenharmony_ci{
64094332d3Sopenharmony_ci    struct HdfTestMsg msg = {TEST_WIFI_TYPE, WIFI_NET_DEVICE_INIT, -1};
65094332d3Sopenharmony_ci    EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
66094332d3Sopenharmony_ci}
67094332d3Sopenharmony_ci
68094332d3Sopenharmony_ci/**
69094332d3Sopenharmony_ci  * @tc.name: WiFiNetDeviceAdd001
70094332d3Sopenharmony_ci  * @tc.desc: add netdevice function test
71094332d3Sopenharmony_ci  * @tc.type: FUNC
72094332d3Sopenharmony_ci  * @tc.require: AR000F869H
73094332d3Sopenharmony_ci  */
74094332d3Sopenharmony_ciHWTEST_F(WiFiNetDeviceTest, WiFiNetDeviceAdd001, TestSize.Level1)
75094332d3Sopenharmony_ci{
76094332d3Sopenharmony_ci    struct HdfTestMsg msg = {TEST_WIFI_TYPE, WIFI_NET_DEVICE_ADD, -1};
77094332d3Sopenharmony_ci    EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
78094332d3Sopenharmony_ci}
79094332d3Sopenharmony_ci
80094332d3Sopenharmony_ci/**
81094332d3Sopenharmony_ci  * @tc.name: WiFiNetDeviceGet001
82094332d3Sopenharmony_ci  * @tc.desc: get netdevice function test
83094332d3Sopenharmony_ci  * @tc.type: FUNC
84094332d3Sopenharmony_ci  * @tc.require: AR000F869H
85094332d3Sopenharmony_ci  */
86094332d3Sopenharmony_ciHWTEST_F(WiFiNetDeviceTest, WiFiNetDeviceGet001, TestSize.Level1)
87094332d3Sopenharmony_ci{
88094332d3Sopenharmony_ci    struct HdfTestMsg msg = {TEST_WIFI_TYPE, WIFI_NET_DEVICE_GET, -1};
89094332d3Sopenharmony_ci    EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
90094332d3Sopenharmony_ci}
91094332d3Sopenharmony_ci
92094332d3Sopenharmony_ci/**
93094332d3Sopenharmony_ci  * @tc.name: WiFiNetDeviceGetCount001
94094332d3Sopenharmony_ci  * @tc.desc: netdevice count query function test
95094332d3Sopenharmony_ci  * @tc.type: FUNC
96094332d3Sopenharmony_ci  * @tc.require: AR000F869H
97094332d3Sopenharmony_ci  */
98094332d3Sopenharmony_ciHWTEST_F(WiFiNetDeviceTest, WiFiNetDeviceGetCount001, TestSize.Level1)
99094332d3Sopenharmony_ci{
100094332d3Sopenharmony_ci    struct HdfTestMsg msg = {TEST_WIFI_TYPE, WIFI_NET_DEVICE_GET_COUNT, -1};
101094332d3Sopenharmony_ci    EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
102094332d3Sopenharmony_ci}
103094332d3Sopenharmony_ci
104094332d3Sopenharmony_ci/**
105094332d3Sopenharmony_ci  * @tc.name: WiFiNetDeviceGetCap001
106094332d3Sopenharmony_ci  * @tc.desc: netdevice capability query function test
107094332d3Sopenharmony_ci  * @tc.type: FUNC
108094332d3Sopenharmony_ci  * @tc.require: AR000F869H
109094332d3Sopenharmony_ci  */
110094332d3Sopenharmony_ciHWTEST_F(WiFiNetDeviceTest, WiFiNetDeviceGetCap001, TestSize.Level1)
111094332d3Sopenharmony_ci{
112094332d3Sopenharmony_ci    struct HdfTestMsg msg = {TEST_WIFI_TYPE, WIFI_NET_DEVICE_GET_CAP, -1};
113094332d3Sopenharmony_ci    EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
114094332d3Sopenharmony_ci}
115094332d3Sopenharmony_ci
116094332d3Sopenharmony_ci/**
117094332d3Sopenharmony_ci  * @tc.name: WiFiNetDeviceSetAddr001
118094332d3Sopenharmony_ci  * @tc.desc: set netdevice addr function test
119094332d3Sopenharmony_ci  * @tc.type: FUNC
120094332d3Sopenharmony_ci  * @tc.require: AR000F869H
121094332d3Sopenharmony_ci  */
122094332d3Sopenharmony_ciHWTEST_F(WiFiNetDeviceTest, WiFiNetDeviceSetAddr001, TestSize.Level1)
123094332d3Sopenharmony_ci{
124094332d3Sopenharmony_ci    struct HdfTestMsg msg = {TEST_WIFI_TYPE, WIFI_NET_DEVICE_SET_ADDR, -1};
125094332d3Sopenharmony_ci    EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
126094332d3Sopenharmony_ci}
127094332d3Sopenharmony_ci
128094332d3Sopenharmony_ci/**
129094332d3Sopenharmony_ci  * @tc.name: WiFiNetDeviceDhcpClient001
130094332d3Sopenharmony_ci  * @tc.desc: netdevice dhcp client function test
131094332d3Sopenharmony_ci  * @tc.type: FUNC
132094332d3Sopenharmony_ci  * @tc.require: AR000F869L
133094332d3Sopenharmony_ci  */
134094332d3Sopenharmony_ciHWTEST_F(WiFiNetDeviceTest, WiFiNetDeviceDhcpClient001, TestSize.Level1)
135094332d3Sopenharmony_ci{
136094332d3Sopenharmony_ci    struct HdfTestMsg msg = {TEST_WIFI_TYPE, WIFI_NET_DEVICE_DHCPC, -1};
137094332d3Sopenharmony_ci    EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
138094332d3Sopenharmony_ci}
139094332d3Sopenharmony_ci
140094332d3Sopenharmony_ci/**
141094332d3Sopenharmony_ci  * @tc.name: WiFiNetDeviceDhcpServer001
142094332d3Sopenharmony_ci  * @tc.desc: netdevice dhcp server function test
143094332d3Sopenharmony_ci  * @tc.type: FUNC
144094332d3Sopenharmony_ci  * @tc.require: AR000F869L
145094332d3Sopenharmony_ci  */
146094332d3Sopenharmony_ciHWTEST_F(WiFiNetDeviceTest, WiFiNetDeviceDhcpServer001, TestSize.Level1)
147094332d3Sopenharmony_ci{
148094332d3Sopenharmony_ci    struct HdfTestMsg msg = {TEST_WIFI_TYPE, WIFI_NET_DEVICE_DHCPS, -1};
149094332d3Sopenharmony_ci    EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
150094332d3Sopenharmony_ci}
151094332d3Sopenharmony_ci
152094332d3Sopenharmony_ci/**
153094332d3Sopenharmony_ci  * @tc.name: WiFiNetDeviceSetStatus001
154094332d3Sopenharmony_ci  * @tc.desc: set netdevice status function test
155094332d3Sopenharmony_ci  * @tc.type: FUNC
156094332d3Sopenharmony_ci  * @tc.require: AR000F869H
157094332d3Sopenharmony_ci  */
158094332d3Sopenharmony_ciHWTEST_F(WiFiNetDeviceTest, WiFiNetDeviceSetStatus001, TestSize.Level1)
159094332d3Sopenharmony_ci{
160094332d3Sopenharmony_ci    struct HdfTestMsg msg = {TEST_WIFI_TYPE, WIFI_NET_DEVICE_SET_STATUS, -1};
161094332d3Sopenharmony_ci    EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
162094332d3Sopenharmony_ci}
163094332d3Sopenharmony_ci
164094332d3Sopenharmony_ci/**
165094332d3Sopenharmony_ci  * @tc.name: WiFiNetDeviceSetLinkStatus001
166094332d3Sopenharmony_ci  * @tc.desc: set netdevice link status function test
167094332d3Sopenharmony_ci  * @tc.type: FUNC
168094332d3Sopenharmony_ci  * @tc.require: AR000F869H
169094332d3Sopenharmony_ci  */
170094332d3Sopenharmony_ciHWTEST_F(WiFiNetDeviceTest, WiFiNetDeviceSetLinkStatus001, TestSize.Level1)
171094332d3Sopenharmony_ci{
172094332d3Sopenharmony_ci    struct HdfTestMsg msg = {TEST_WIFI_TYPE, WIFI_NET_DEVICE_SET_LINK_STATUS, -1};
173094332d3Sopenharmony_ci    EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
174094332d3Sopenharmony_ci}
175094332d3Sopenharmony_ci
176094332d3Sopenharmony_ci/**
177094332d3Sopenharmony_ci  * @tc.name: WiFiNetDeviceRx001
178094332d3Sopenharmony_ci  * @tc.desc: netdevice receive packet function test
179094332d3Sopenharmony_ci  * @tc.type: FUNC
180094332d3Sopenharmony_ci  * @tc.require: AR000F869H
181094332d3Sopenharmony_ci  */
182094332d3Sopenharmony_ciHWTEST_F(WiFiNetDeviceTest, WiFiNetDeviceRx001, TestSize.Level1)
183094332d3Sopenharmony_ci{
184094332d3Sopenharmony_ci    struct HdfTestMsg msg = {TEST_WIFI_TYPE, WIFI_NET_DEVICE_RX, -1};
185094332d3Sopenharmony_ci    EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
186094332d3Sopenharmony_ci}
187094332d3Sopenharmony_ci
188094332d3Sopenharmony_ci/**
189094332d3Sopenharmony_ci  * @tc.name: WiFiNetDeviceDelete001
190094332d3Sopenharmony_ci  * @tc.desc: delete netdevice function test
191094332d3Sopenharmony_ci  * @tc.type: FUNC
192094332d3Sopenharmony_ci  * @tc.require: AR000F869H
193094332d3Sopenharmony_ci  */
194094332d3Sopenharmony_ciHWTEST_F(WiFiNetDeviceTest, WiFiNetDeviceDelete001, TestSize.Level1)
195094332d3Sopenharmony_ci{
196094332d3Sopenharmony_ci    struct HdfTestMsg msg = {TEST_WIFI_TYPE, WIFI_NET_DEVICE_DELETE, -1};
197094332d3Sopenharmony_ci    EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
198094332d3Sopenharmony_ci}
199094332d3Sopenharmony_ci
200094332d3Sopenharmony_ci/**
201094332d3Sopenharmony_ci  * @tc.name: WiFiNetDeviceDeInit001
202094332d3Sopenharmony_ci  * @tc.desc: deinit netdevice function test
203094332d3Sopenharmony_ci  * @tc.type: FUNC
204094332d3Sopenharmony_ci  * @tc.require: AR000F869H
205094332d3Sopenharmony_ci  */
206094332d3Sopenharmony_ciHWTEST_F(WiFiNetDeviceTest, WiFiNetDeviceDeInit001, TestSize.Level1)
207094332d3Sopenharmony_ci{
208094332d3Sopenharmony_ci    struct HdfTestMsg msg = {TEST_WIFI_TYPE, WIFI_NET_DEVICE_DEINIT, -1};
209094332d3Sopenharmony_ci    EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
210094332d3Sopenharmony_ci}
211094332d3Sopenharmony_ci};
212