1 /*
2  * Copyright (c) 2023-2024 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 "dscreen_hidumper_test.h"
17 
18 using namespace testing::ext;
19 
20 namespace OHOS {
21 namespace DistributedHardware {
SetUpTestCase(void)22 void DScreenHidumperTest::SetUpTestCase(void) {}
23 
TearDownTestCase(void)24 void DScreenHidumperTest::TearDownTestCase(void) {}
25 
SetUp()26 void DScreenHidumperTest::SetUp() {}
27 
TearDown()28 void DScreenHidumperTest::TearDown() {}
29 
30 /**
31  * @tc.name: Dump_001
32  * @tc.desc: Verify the Dump function.
33  * @tc.type: FUNC
34  * @tc.require: Issue Number
35  */
36 HWTEST_F(DScreenHidumperTest, Dump_001, TestSize.Level1)
37 {
38     std::string result;
39     std::string helpStr;
40     std::vector<std::string> argsStr;
41     DscreenHidumper::GetInstance().ShowHelp(helpStr);
42     bool ret = DscreenHidumper::GetInstance().Dump(argsStr, result);
43     EXPECT_EQ(true, ret);
44     EXPECT_EQ(helpStr, result);
45 }
46 
47 /**
48  * @tc.name: Dump_002
49  * @tc.desc: Verify the Dump function.
50  * @tc.type: FUNC
51  * @tc.require: Issue Number
52  */
53 HWTEST_F(DScreenHidumperTest, Dump_002, TestSize.Level1)
54 {
55     std::string result;
56     std::vector<std::string> argsStr = {"arg1", "arg2"};
57     bool ret = DscreenHidumper::GetInstance().Dump(argsStr, result);
58     EXPECT_EQ(true, ret);
59     EXPECT_EQ("unknown command, -h for help.", result);
60 }
61 
62 /**
63  * @tc.name: Dump_003
64  * @tc.desc: Verify the Dump function.
65  * @tc.type: FUNC
66  * @tc.require: Issue Number
67  */
68 HWTEST_F(DScreenHidumperTest, Dump_003, TestSize.Level1)
69 {
70     std::string result;
71     std::string helpStr;
72     std::vector<std::string> argsStr = {"-h"};
73     DscreenHidumper::GetInstance().ShowHelp(helpStr);
74     bool ret = DscreenHidumper::GetInstance().Dump(argsStr, result);
75     EXPECT_EQ(true, ret);
76     EXPECT_EQ(helpStr, result);
77 }
78 
79 } // namespace DistributedHardware
80 } // namespace OHOS