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 16#include "dm_radar_helper_test.h" 17 18#include "dm_radar_helper.h" 19 20namespace OHOS { 21namespace DistributedHardware { 22void DmRadarHelperTest::SetUp() 23{ 24} 25 26void DmRadarHelperTest::TearDown() 27{ 28} 29 30void DmRadarHelperTest::SetUpTestCase() 31{ 32} 33 34void DmRadarHelperTest::TearDownTestCase() 35{ 36} 37 38HWTEST_F(DmRadarHelperTest, ReportDiscoverRegCallback_001, testing::ext::TestSize.Level0) 39{ 40 struct RadarInfo info = { 0 }; 41 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE); 42 bool res = DmRadarHelper::GetInstance().ReportDiscoverRegCallback(info); 43 EXPECT_EQ(res, true); 44} 45 46HWTEST_F(DmRadarHelperTest, ReportDiscoverRegCallback_002, testing::ext::TestSize.Level0) 47{ 48 struct RadarInfo info = { 0 }; 49 info.stageRes = static_cast<int32_t>(StageRes::STAGE_CANCEL); 50 bool res = DmRadarHelper::GetInstance().ReportDiscoverRegCallback(info); 51 EXPECT_EQ(res, true); 52} 53 54HWTEST_F(DmRadarHelperTest, ReportDiscoverResCallback_001, testing::ext::TestSize.Level0) 55{ 56 struct RadarInfo info = { 0 }; 57 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE); 58 bool res = DmRadarHelper::GetInstance().ReportDiscoverResCallback(info); 59 EXPECT_EQ(res, true); 60} 61 62HWTEST_F(DmRadarHelperTest, ReportDiscoverUserRes_001, testing::ext::TestSize.Level0) 63{ 64 struct RadarInfo info = { 0 }; 65 info.stageRes = static_cast<int32_t>(StageRes::STAGE_CANCEL); 66 bool res = DmRadarHelper::GetInstance().ReportDiscoverUserRes(info); 67 EXPECT_EQ(res, true); 68} 69HWTEST_F(DmRadarHelperTest, ReportDiscoverUserRes_002, testing::ext::TestSize.Level0) 70{ 71 struct RadarInfo info = { 0 }; 72 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE); 73 bool res = DmRadarHelper::GetInstance().ReportDiscoverUserRes(info); 74 EXPECT_EQ(res, true); 75} 76HWTEST_F(DmRadarHelperTest, ReportAuthStart_001, testing::ext::TestSize.Level0) 77{ 78 bool res = DmRadarHelper::GetInstance().ReportAuthStart("udid", "pkgname"); 79 EXPECT_EQ(res, true); 80} 81HWTEST_F(DmRadarHelperTest, ReportAuthOpenSession_001, testing::ext::TestSize.Level0) 82{ 83 struct RadarInfo info = { 0 }; 84 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE); 85 bool res = DmRadarHelper::GetInstance().ReportAuthOpenSession(info); 86 EXPECT_EQ(res, true); 87} 88HWTEST_F(DmRadarHelperTest, ReportAuthOpenSession_002, testing::ext::TestSize.Level0) 89{ 90 struct RadarInfo info = { 0 }; 91 info.stageRes = static_cast<int32_t>(StageRes::STAGE_SUCC); 92 bool res = DmRadarHelper::GetInstance().ReportAuthOpenSession(info); 93 EXPECT_EQ(res, true); 94} 95HWTEST_F(DmRadarHelperTest, ReportAuthSessionOpenCb_001, testing::ext::TestSize.Level0) 96{ 97 struct RadarInfo info = { 0 }; 98 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE); 99 bool res = DmRadarHelper::GetInstance().ReportAuthSessionOpenCb(info); 100 EXPECT_EQ(res, true); 101} 102HWTEST_F(DmRadarHelperTest, ReportAuthSendRequest_001, testing::ext::TestSize.Level0) 103{ 104 struct RadarInfo info = { 0 }; 105 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE); 106 bool res = DmRadarHelper::GetInstance().ReportAuthSendRequest(info); 107 EXPECT_EQ(res, true); 108} 109HWTEST_F(DmRadarHelperTest, ReportAuthPullAuthBox_001, testing::ext::TestSize.Level0) 110{ 111 struct RadarInfo info = { 0 }; 112 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE); 113 bool res = DmRadarHelper::GetInstance().ReportAuthPullAuthBox(info); 114 EXPECT_EQ(res, true); 115} 116HWTEST_F(DmRadarHelperTest, ReportAuthConfirmBox_001, testing::ext::TestSize.Level0) 117{ 118 struct RadarInfo info = { 0 }; 119 info.stageRes = static_cast<int32_t>(StageRes::STAGE_SUCC); 120 bool res = DmRadarHelper::GetInstance().ReportAuthConfirmBox(info); 121 EXPECT_EQ(res, true); 122} 123HWTEST_F(DmRadarHelperTest, ReportAuthConfirmBox_002, testing::ext::TestSize.Level0) 124{ 125 struct RadarInfo info = { 0 }; 126 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE); 127 bool res = DmRadarHelper::GetInstance().ReportAuthConfirmBox(info); 128 EXPECT_EQ(res, true); 129} 130HWTEST_F(DmRadarHelperTest, ReportAuthCreateGroup_001, testing::ext::TestSize.Level0) 131{ 132 struct RadarInfo info = { 0 }; 133 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE); 134 bool res = DmRadarHelper::GetInstance().ReportAuthCreateGroup(info); 135 EXPECT_EQ(res, true); 136} 137HWTEST_F(DmRadarHelperTest, ReportAuthCreateGroup_002, testing::ext::TestSize.Level0) 138{ 139 struct RadarInfo info = { 0 }; 140 info.stageRes = static_cast<int32_t>(StageRes::STAGE_SUCC); 141 bool res = DmRadarHelper::GetInstance().ReportAuthCreateGroup(info); 142 EXPECT_EQ(res, true); 143} 144HWTEST_F(DmRadarHelperTest, ReportAuthCreateGroupCb_001, testing::ext::TestSize.Level0) 145{ 146 int32_t stageRes = static_cast<int32_t>(StageRes::STAGE_SUCC); 147 bool res = DmRadarHelper::GetInstance().ReportAuthCreateGroupCb("funcName", stageRes); 148 EXPECT_EQ(res, true); 149} 150HWTEST_F(DmRadarHelperTest, ReportAuthCreateGroupCb_002, testing::ext::TestSize.Level0) 151{ 152 int32_t stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE); 153 bool res = DmRadarHelper::GetInstance().ReportAuthCreateGroupCb("funcName", stageRes); 154 EXPECT_EQ(res, true); 155} 156HWTEST_F(DmRadarHelperTest, ReportAuthPullPinBox_001, testing::ext::TestSize.Level0) 157{ 158 struct RadarInfo info = { 0 }; 159 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE); 160 bool res = DmRadarHelper::GetInstance().ReportAuthPullPinBox(info); 161 EXPECT_EQ(res, true); 162} 163HWTEST_F(DmRadarHelperTest, ReportAuthInputPinBox_001, testing::ext::TestSize.Level0) 164{ 165 struct RadarInfo info = { 0 }; 166 info.stageRes = static_cast<int32_t>(StageRes::STAGE_SUCC); 167 bool res = DmRadarHelper::GetInstance().ReportAuthInputPinBox(info); 168 EXPECT_EQ(res, true); 169} 170HWTEST_F(DmRadarHelperTest, ReportAuthInputPinBox_002, testing::ext::TestSize.Level0) 171{ 172 struct RadarInfo info = { 0 }; 173 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE); 174 bool res = DmRadarHelper::GetInstance().ReportAuthInputPinBox(info); 175 EXPECT_EQ(res, true); 176} 177HWTEST_F(DmRadarHelperTest, ReportAuthAddGroup_001, testing::ext::TestSize.Level0) 178{ 179 struct RadarInfo info = { 0 }; 180 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE); 181 bool res = DmRadarHelper::GetInstance().ReportAuthAddGroup(info); 182 EXPECT_EQ(res, true); 183} 184HWTEST_F(DmRadarHelperTest, ReportAuthAddGroup_002, testing::ext::TestSize.Level0) 185{ 186 struct RadarInfo info = { 0 }; 187 info.stageRes = static_cast<int32_t>(StageRes::STAGE_SUCC); 188 bool res = DmRadarHelper::GetInstance().ReportAuthAddGroup(info); 189 EXPECT_EQ(res, true); 190} 191HWTEST_F(DmRadarHelperTest, ReportAuthAddGroupCb_001, testing::ext::TestSize.Level0) 192{ 193 int32_t stageRes = static_cast<int32_t>(StageRes::STAGE_SUCC); 194 bool res = DmRadarHelper::GetInstance().ReportAuthAddGroupCb("func", stageRes); 195 EXPECT_EQ(res, true); 196} 197HWTEST_F(DmRadarHelperTest, ReportAuthAddGroupCb_002, testing::ext::TestSize.Level0) 198{ 199 struct RadarInfo info = { 0 }; 200 int32_t stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE); 201 bool res = DmRadarHelper::GetInstance().ReportAuthAddGroupCb("func", stageRes); 202 EXPECT_EQ(res, true); 203} 204HWTEST_F(DmRadarHelperTest, ReportNetworkOnline_001, testing::ext::TestSize.Level0) 205{ 206 struct RadarInfo info = { 0 }; 207 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE); 208 bool res = DmRadarHelper::GetInstance().ReportNetworkOnline(info); 209 EXPECT_EQ(res, true); 210} 211HWTEST_F(DmRadarHelperTest, ReportNetworkOffline_001, testing::ext::TestSize.Level0) 212{ 213 struct RadarInfo info = { 0 }; 214 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE); 215 bool res = DmRadarHelper::GetInstance().ReportNetworkOffline(info); 216 EXPECT_EQ(res, true); 217} 218HWTEST_F(DmRadarHelperTest, ReportDeleteTrustRelation_001, testing::ext::TestSize.Level0) 219{ 220 struct RadarInfo info = { 0 }; 221 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE); 222 bool res = DmRadarHelper::GetInstance().ReportDeleteTrustRelation(info); 223 224 int32_t stageRes = static_cast<int32_t>(StageRes::STAGE_SUCC); 225 std::string str = "test"; 226 DmRadarHelper::GetInstance().ReportCreatePinHolder(str, 0, str, 0, stageRes); 227 DmRadarHelper::GetInstance().ReportDestroyPinHolder(str, str, 0, stageRes); 228 229 stageRes = static_cast<int32_t>(StageRes::STAGE_FAIL); 230 DmRadarHelper::GetInstance().ReportCreatePinHolder(str, 0, str, 0, stageRes); 231 DmRadarHelper::GetInstance().ReportDestroyPinHolder(str, str, 0, stageRes); 232 233 int32_t bizStage = static_cast<int32_t>(PinHolderStage::RECEIVE_DESTROY_PIN_HOLDER_MSG); 234 DmRadarHelper::GetInstance().ReportSendOrReceiveHolderMsg(bizStage, str, ""); 235 bizStage = static_cast<int32_t>(PinHolderStage::RECEIVE_CREATE_PIN_HOLDER_MSG); 236 DmRadarHelper::GetInstance().ReportSendOrReceiveHolderMsg(bizStage, str, ""); 237 238 EXPECT_EQ(res, true); 239} 240} // namespace DistributedHardware 241} // namespace OHOS 242