1/* 2 * Copyright (c) 2022 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 "UTTest_dm_dfx.h" 17 18namespace OHOS { 19namespace DistributedHardware { 20void DmDfxTest::SetUp() 21{ 22} 23void DmDfxTest::TearDown() 24{ 25} 26void DmDfxTest::SetUpTestCase() 27{ 28} 29void DmDfxTest::TearDownTestCase() 30{ 31} 32 33namespace { 34 35/** 36 * @tc.name: ShowHelp_001 37 * @tc.desc: Return DM_OK 38 * @tc.type: FUNC 39 * @tc.require: AR000GHSJK 40 */ 41HWTEST_F(DmDfxTest, ShowHelp_001, testing::ext::TestSize.Level0) 42{ 43 std::string result = ""; 44 int32_t ret = HiDumpHelper::GetInstance().ShowHelp(result); 45 EXPECT_EQ(ret, DM_OK); 46} 47 48/** 49 * @tc.name: ShowIllealInfomation_001 50 * @tc.desc: Return DM_OK 51 * @tc.type: FUNC 52 * @tc.require: AR000GHSJK 53 */ 54HWTEST_F(DmDfxTest, ShowIllealInfomation_001, testing::ext::TestSize.Level0) 55{ 56 std::string result = ""; 57 int32_t ret = HiDumpHelper::GetInstance().ShowIllealInfomation(result); 58 EXPECT_EQ(ret, DM_OK); 59} 60 61/** 62 * @tc.name: GetArgsType_001 63 * @tc.desc: Return ERR_DM_FAILED 64 * @tc.type: FUNC 65 * @tc.require: AR000GHSJK 66 */ 67HWTEST_F(DmDfxTest, GetArgsType_001, testing::ext::TestSize.Level0) 68{ 69 std::vector<std::string> args; 70 std::vector<HidumperFlag> Flag; 71 int32_t ret = HiDumpHelper::GetInstance().GetArgsType(args, Flag); 72 EXPECT_EQ(ret, ERR_DM_FAILED); 73} 74 75/** 76 * @tc.name: GetArgsType_002 77 * @tc.desc: Return ERR_DM_FAILED 78 * @tc.type: FUNC 79 * @tc.require: AR000GHSJK 80 */ 81HWTEST_F(DmDfxTest, GetArgsType_002, testing::ext::TestSize.Level0) 82{ 83 std::string str = std::string(ARGS_HELP_INFO); 84 std::vector<std::string> args; 85 args.push_back(str); 86 std::vector<HidumperFlag> Flag; 87 int32_t ret = HiDumpHelper::GetInstance().GetArgsType(args, Flag); 88 EXPECT_EQ(ret, ERR_DM_FAILED); 89} 90 91/** 92 * @tc.name: SetNodeInfo_001 93 * @tc.desc: HiDumpHelper::GetInstance().nodeInfo_.size() plus 1 94 * @tc.type: FUNC 95 * @tc.require: AR000GHSJK 96 */ 97HWTEST_F(DmDfxTest, SetNodeInfo_001, testing::ext::TestSize.Level0) 98{ 99 DmDeviceInfo deviceInfo; 100 HiDumpHelper::GetInstance().SetNodeInfo(deviceInfo); 101 EXPECT_EQ(HiDumpHelper::GetInstance().nodeInfos_.size(), 1); 102} 103 104/** 105 * @tc.name: ShowAllLoadTrustedList_001 106 * @tc.desc: Return DM_OK 107 * @tc.type: FUNC 108 * @tc.require: AR000GHSJK 109 */ 110HWTEST_F(DmDfxTest, ShowAllLoadTrustedList_001, testing::ext::TestSize.Level0) 111{ 112 std::string result = ""; 113 int32_t ret = HiDumpHelper::GetInstance().ShowAllLoadTrustedList(result); 114 EXPECT_TRUE(!result.empty()); 115 EXPECT_EQ(ret, DM_OK); 116} 117 118/** 119 * @tc.name: ShowAllLoadTrustedList_002 120 * @tc.desc: Return DM_OK 121 * @tc.type: FUNC 122 * @tc.require: AR000GHSJK 123 */ 124HWTEST_F(DmDfxTest, ShowAllLoadTrustedList_002, testing::ext::TestSize.Level0) 125{ 126 std::string result = ""; 127 DmDeviceInfo deviceInfo; 128 deviceInfo.deviceTypeId = 1; 129 deviceInfo.range = 11; 130 HiDumpHelper::GetInstance().nodeInfos_.push_back(deviceInfo); 131 int32_t ret = HiDumpHelper::GetInstance().ShowAllLoadTrustedList(result); 132 EXPECT_TRUE(!result.empty()); 133 EXPECT_EQ(ret, DM_OK); 134} 135 136/** 137 * @tc.name: GetDeviceType_001 138 * @tc.desc: set deviceTypeId id 8, Return string is not empty 139 * @tc.type: FUNC 140 * @tc.require: AR000GHSJK 141 */ 142HWTEST_F(DmDfxTest, GetDeviceType_001, testing::ext::TestSize.Level0) 143{ 144 int32_t deviceTypeId = 8; 145 std::string ret = HiDumpHelper::GetInstance().GetDeviceType(deviceTypeId); 146 EXPECT_TRUE(!ret.empty()); 147} 148 149/** 150 * @tc.name: GetDeviceType_002 151 * @tc.desc: set deviceTypeId id 10000, Return string is not empty 152 * @tc.type: FUNC 153 * @tc.require: AR000GHSJK 154 */ 155HWTEST_F(DmDfxTest, GetDeviceType_002, testing::ext::TestSize.Level0) 156{ 157 int32_t deviceTypeId = 10000; 158 std::string ret = HiDumpHelper::GetInstance().GetDeviceType(deviceTypeId); 159 EXPECT_TRUE(ret.empty()); 160} 161 162/** 163 * @tc.name: ProcessDump_001 164 * @tc.desc: Return DM_OK 165 * @tc.type: FUNC 166 * @tc.require: AR000GHSJK 167 */ 168HWTEST_F(DmDfxTest, ProcessDump_001, testing::ext::TestSize.Level0) 169{ 170 HidumperFlag flag = HidumperFlag::HIDUMPER_GET_HELP; 171 std::string result; 172 int32_t ret = HiDumpHelper::GetInstance().ProcessDump(flag, result); 173 EXPECT_EQ(ret, DM_OK); 174} 175 176/** 177 * @tc.name: ProcessDump_002 178 * @tc.desc: Return DM_OK 179 * @tc.type: FUNC 180 * @tc.require: AR000GHSJK 181 */ 182HWTEST_F(DmDfxTest, ProcessDump_002, testing::ext::TestSize.Level0) 183{ 184 HidumperFlag flag = HidumperFlag::HIDUMPER_GET_TRUSTED_LIST; 185 std::string result; 186 int32_t ret = HiDumpHelper::GetInstance().ProcessDump(flag, result); 187 EXPECT_EQ(ret, DM_OK); 188} 189 190/** 191 * @tc.name: ProcessDump_003 192 * @tc.desc: Return DM_OK 193 * @tc.type: FUNC 194 * @tc.require: AR000GHSJK 195 */ 196HWTEST_F(DmDfxTest, ProcessDump_003, testing::ext::TestSize.Level0) 197{ 198 HidumperFlag flag = HidumperFlag::HIDUMPER_UNKNOWN; 199 std::string result; 200 int32_t ret = HiDumpHelper::GetInstance().ProcessDump(flag, result); 201 EXPECT_EQ(ret, DM_OK); 202} 203 204/** 205 * @tc.name: HiDump_001 206 * @tc.desc: Return DM_OK 207 * @tc.type: FUNC 208 * @tc.require: AR000GHSJK 209 */ 210HWTEST_F(DmDfxTest, HiDump_001, testing::ext::TestSize.Level0) 211{ 212 std::vector<std::string> args; 213 std::string result; 214 int32_t ret = HiDumpHelper::GetInstance().HiDump(args, result); 215 EXPECT_EQ(ret, DM_OK); 216} 217 218/** 219 * @tc.name: HiDump_002 220 * @tc.desc: Return DM_OK 221 * @tc.type: FUNC 222 * @tc.require: AR000GHSJK 223 */ 224HWTEST_F(DmDfxTest, HiDump_002, testing::ext::TestSize.Level0) 225{ 226 std::string str = "argsTest"; 227 std::vector<std::string> args; 228 args.push_back(str); 229 std::string result; 230 int32_t ret = HiDumpHelper::GetInstance().HiDump(args, result); 231 EXPECT_EQ(ret, DM_OK); 232} 233 234/** 235 * @tc.name: HiDump_003 236 * @tc.desc: Return DM_OK 237 * @tc.type: FUNC 238 * @tc.require: AR000GHSJK 239 */ 240HWTEST_F(DmDfxTest, HiDump_003, testing::ext::TestSize.Level0) 241{ 242 std::string str = std::string(HIDUMPER_GET_TRUSTED_LIST_INFO); 243 std::vector<std::string> args; 244 args.push_back(str); 245 std::string result; 246 int32_t ret = HiDumpHelper::GetInstance().HiDump(args, result); 247 EXPECT_EQ(ret, DM_OK); 248} 249} // namespace 250} // namespace DistributedHardware 251} // namespace OHOS