1 /* 2 * Copyright (C) 2023 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 #include <gtest/gtest.h> 16 #include <gmock/gmock.h> 17 #include "securec.h" 18 #include "wifi_hal_crpc_p2p.h" 19 20 using ::testing::_; 21 using ::testing::AtLeast; 22 using ::testing::Eq; 23 using ::testing::ext::TestSize; 24 25 namespace OHOS { 26 namespace Wifi { 27 const int CONTEXT_BUFFER = 1024; 28 class WifiHalCrpcP2pTets : public testing::Test { 29 public: SetUpTestCase()30 static void SetUpTestCase() {} TearDownTestCase()31 static void TearDownTestCase() {} SetUp()32 virtual void SetUp() {} TearDown()33 virtual void TearDown() {} 34 }; 35 36 HWTEST_F(WifiHalCrpcP2pTets, RpcP2pSetWpsSecondaryDeviceTypeTest, TestSize.Level1) 37 { 38 RpcServer svr, *server = nullptr; 39 Context cont, *context = nullptr; 40 EXPECT_EQ(RpcP2pSetWpsSecondaryDeviceType(server, &cont), -1); 41 EXPECT_EQ(RpcP2pSetWpsSecondaryDeviceType(&svr, context), -1); 42 context = CreateContext(CONTEXT_BUFFER); 43 EXPECT_EQ(RpcP2pSetWpsSecondaryDeviceType(&svr, &cont), -1); 44 RpcP2pSetWpsSecondaryDeviceType(&svr, context); 45 } 46 47 HWTEST_F(WifiHalCrpcP2pTets, RpcP2pGetPeerTest, TestSize.Level1) 48 { 49 RpcServer svr, *server = nullptr; 50 Context cont, *context = nullptr; 51 EXPECT_EQ(RpcP2pGetPeer(server, &cont), -1); 52 EXPECT_EQ(RpcP2pGetPeer(&svr, context), -1); 53 context = CreateContext(CONTEXT_BUFFER); 54 RpcP2pGetPeer(&svr, context); 55 } 56 57 HWTEST_F(WifiHalCrpcP2pTets, RpcP2pGetFrequenciesTest, TestSize.Level1) 58 { 59 RpcServer svr, *server = nullptr; 60 Context cont, *context = nullptr; 61 EXPECT_EQ(RpcP2pGetFrequencies(server, &cont), -1); 62 EXPECT_EQ(RpcP2pGetFrequencies(&svr, context), -1); 63 context = CreateContext(CONTEXT_BUFFER); 64 RpcP2pGetFrequencies(&svr, context); 65 } 66 67 HWTEST_F(WifiHalCrpcP2pTets, RpcP2pSetGroupConfigTest, TestSize.Level1) 68 { 69 RpcServer svr, *server = nullptr; 70 Context cont, *context = nullptr; 71 EXPECT_EQ(RpcP2pSetGroupConfig(server, &cont), -1); 72 EXPECT_EQ(RpcP2pSetGroupConfig(&svr, context), -1); 73 context = CreateContext(CONTEXT_BUFFER); 74 RpcP2pSetGroupConfig(&svr, context); 75 } 76 77 HWTEST_F(WifiHalCrpcP2pTets, RpcP2pGetGroupConfigTest, TestSize.Level1) 78 { 79 RpcServer svr, *server = nullptr; 80 Context cont, *context = nullptr; 81 EXPECT_EQ(RpcP2pGetGroupConfig(server, &cont), -1); 82 EXPECT_EQ(RpcP2pGetGroupConfig(&svr, context), -1); 83 context = CreateContext(CONTEXT_BUFFER); 84 RpcP2pGetGroupConfig(&svr, context); 85 } 86 87 HWTEST_F(WifiHalCrpcP2pTets, RpcP2pAddNetworkTest, TestSize.Level1) 88 { 89 RpcServer svr, *server = nullptr; 90 Context cont, *context = nullptr; 91 EXPECT_EQ(RpcP2pAddNetwork(server, &cont), -1); 92 EXPECT_EQ(RpcP2pAddNetwork(&svr, context), -1); 93 context = CreateContext(CONTEXT_BUFFER); 94 RpcP2pAddNetwork(&svr, context); 95 } 96 97 HWTEST_F(WifiHalCrpcP2pTets, RpcP2pHid2dConnectTest, TestSize.Level1) 98 { 99 RpcServer svr, *server = nullptr; 100 Context cont, *context = nullptr; 101 EXPECT_EQ(RpcP2pHid2dConnect(server, &cont), -1); 102 EXPECT_EQ(RpcP2pHid2dConnect(&svr, context), -1); 103 context = CreateContext(CONTEXT_BUFFER); 104 RpcP2pHid2dConnect(&svr, context); 105 } 106 } // namespace Wifi 107 } // namespace OHOS 108