1 //
2 // Copyright (C) 2025 The Android Open Source Project
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 #include "nfa_wlc_api.h"
17
18 #include <gmock/gmock.h>
19 #include <gtest/gtest.h>
20
21 #include "nfa_wlc_int.h"
22
mock_callback(tNFA_WLC_EVT event,tNFA_WLC_EVT_DATA * p_data)23 static void mock_callback(__attribute__((unused)) tNFA_WLC_EVT event,
24 __attribute__((unused)) tNFA_WLC_EVT_DATA* p_data) {}
25
TEST(NfaWlcApiTest,WlcEnable)26 TEST(NfaWlcApiTest, WlcEnable) {
27 EXPECT_EQ(NFA_WlcEnable(nullptr), NFA_STATUS_FAILED);
28 EXPECT_EQ(NFA_WlcEnable(mock_callback), NFA_STATUS_OK);
29 }
30
TEST(NfaWlcApiTest,WlcStart)31 TEST(NfaWlcApiTest, WlcStart) {
32 tNFA_WLC_MODE mode;
33 mode = 1;
34 EXPECT_EQ(NFA_WlcStart(mode), NFA_STATUS_INVALID_PARAM);
35 mode = 0;
36 EXPECT_EQ(NFA_WlcStart(mode), NFA_STATUS_OK);
37 }
38
TEST(NfaWlcApiTest,WlcStartWPT)39 TEST(NfaWlcApiTest, WlcStartWPT) {
40 uint8_t power_adj_req;
41 uint8_t wpt_time_int;
42 power_adj_req = 0x15;
43 wpt_time_int = 0;
44 EXPECT_FALSE(NFA_WlcStartWPT(power_adj_req, wpt_time_int));
45 power_adj_req = POWER_ADJ_REQ_DEC_MIN;
46 wpt_time_int = 0x14;
47 EXPECT_FALSE(NFA_WlcStartWPT(power_adj_req, wpt_time_int));
48 wpt_time_int = WPT_DURATION_INT_MAX;
49 EXPECT_EQ(NFA_WlcStartWPT(power_adj_req, wpt_time_int), NFA_STATUS_OK);
50 }