1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <cstdint>
17 #include <cstdio>
18 #include <cstdlib>
19 #include <string>
20 #include <unistd.h>
21 #include <fcntl.h>
22 #include <gtest/gtest.h>
23 #include "hdf_uhdf_test.h"
24 #include "hdf_io_service_if.h"
25 #include "hdf_wifi_test.h"
26 
27 using namespace testing::ext;
28 
29 namespace FlowControlTest {
30 class WiFiFlowControlTest : public testing::Test {
31 public:
32     static void SetUpTestCase();
33     static void TearDownTestCase();
34     void SetUp();
35     void TearDown();
36 };
37 
SetUpTestCase()38 void WiFiFlowControlTest::SetUpTestCase()
39 {
40     HdfTestOpenService();
41     struct HdfTestMsg msg = {TEST_WIFI_TYPE, WIFI_FLOW_CONTROL_INIT, -1};
42     HdfTestSendMsgToService(&msg);
43 }
44 
TearDownTestCase()45 void WiFiFlowControlTest::TearDownTestCase()
46 {
47     struct HdfTestMsg msg = {TEST_WIFI_TYPE, WIFI_FLOW_CONTROL_DEINIT, -1};
48     HdfTestSendMsgToService(&msg);
49     HdfTestCloseService();
50 }
51 
SetUp()52 void WiFiFlowControlTest::SetUp() {}
53 
TearDown()54 void WiFiFlowControlTest::TearDown() {}
55 
56 /**
57  * @tc.name: WiFiFlowControlGetQueueID001
58  * @tc.desc: Obtains the priority ID of a flow control queue
59  * @tc.type: FUNC
60  */
HWTEST_F(WiFiFlowControlTest, SUB_WLAN_FLOW_CONTROL_GetQueueID_0001, Function | MediumTest | Level1)61 HWTEST_F(WiFiFlowControlTest, SUB_WLAN_FLOW_CONTROL_GetQueueID_0001, Function | MediumTest | Level1)
62 {
63     struct HdfTestMsg msg = {TEST_WIFI_TYPE, WIFI_FLOW_CONTROL_GET_QUEUE_ID, -1};
64     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
65 }
66 
67 /**
68  * @tc.name: WiFiFlowControlSendData001
69  * @tc.desc: Sends data of a flow control
70  * @tc.type: FUNC
71  */
HWTEST_F(WiFiFlowControlTest, SUB_WLAN_FLOW_CONTROL_SendData_0001, Function | MediumTest | Level1)72 HWTEST_F(WiFiFlowControlTest, SUB_WLAN_FLOW_CONTROL_SendData_0001, Function | MediumTest | Level1)
73 {
74     struct HdfTestMsg msg = {TEST_WIFI_TYPE, WIFI_FLOW_CONTROL_SEND_DATA, -1};
75     EXPECT_EQ(0, HdfTestSendMsgToService(&msg));
76 }
77 };
78