1 /*
2 * Copyright (c) 2021 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 "subcommand_list_test.h"
17
18 #include "subcommand_list.h"
19
20 using namespace testing::ext;
21 using namespace std;
22 using namespace OHOS::HiviewDFX;
23 namespace OHOS {
24 namespace Developtools {
25 namespace HiPerf {
26 class SubCommandListTest : public testing::Test {
27 public:
28 static void SetUpTestCase(void);
29 static void TearDownTestCase(void);
30 void SetUp();
31 void TearDown();
32
33 SubCommandList subCommandList;
34 };
35
SetUpTestCase()36 void SubCommandListTest::SetUpTestCase() {}
37
TearDownTestCase()38 void SubCommandListTest::TearDownTestCase() {}
39
SetUp()40 void SubCommandListTest::SetUp() {}
41
TearDown()42 void SubCommandListTest::TearDown() {}
43
44 /**
45 * @tc.name: TestOnSubCommandHW
46 * @tc.desc:
47 * @tc.type: FUNC
48 */
49 HWTEST_F(SubCommandListTest, TestOnSubCommandHW, TestSize.Level1)
50 {
51 std::vector<std::string> args;
52 StdoutRecord stdoutRecord;
53 stdoutRecord.Start();
54
55 args = {"hw"};
56 EXPECT_EQ(subCommandList.OnSubCommand(args), true);
57 std::string stringOut = stdoutRecord.Stop();
58 }
59
60 /**
61 * @tc.name: TestOnSubCommandSW
62 * @tc.desc:
63 * @tc.type: FUNC
64 */
65 HWTEST_F(SubCommandListTest, TestOnSubCommandSW, TestSize.Level1)
66 {
67 std::vector<std::string> args;
68 StdoutRecord stdoutRecord;
69 stdoutRecord.Start();
70
71 args = {"sw"};
72 EXPECT_EQ(subCommandList.OnSubCommand(args), true);
73 std::string stringOut = stdoutRecord.Stop();
74 }
75
76 /**
77 * @tc.name: TestOnSubCommandTP
78 * @tc.desc:
79 * @tc.type: FUNC
80 */
81 HWTEST_F(SubCommandListTest, TestOnSubCommandTP, TestSize.Level1)
82 {
83 std::vector<std::string> args;
84 StdoutRecord stdoutRecord;
85 stdoutRecord.Start();
86
87 args = {"tp"};
88 EXPECT_EQ(subCommandList.OnSubCommand(args), true); // still not support
89 std::string stringOut = stdoutRecord.Stop();
90 }
91
92 /**
93 * @tc.name: TestOnSubCommandCACHE
94 * @tc.desc:
95 * @tc.type: FUNC
96 */
97 HWTEST_F(SubCommandListTest, TestOnSubCommandCACHE, TestSize.Level1)
98 {
99 std::vector<std::string> args;
100 StdoutRecord stdoutRecord;
101 stdoutRecord.Start();
102
103 args = {"cache"};
104 EXPECT_EQ(subCommandList.OnSubCommand(args), true);
105 std::string stringOut = stdoutRecord.Stop();
106 }
107
108 /**
109 * @tc.name: TestOnSubCommandRAW
110 * @tc.desc:
111 * @tc.type: FUNC
112 */
113 HWTEST_F(SubCommandListTest, TestOnSubCommandRAW, TestSize.Level1)
114 {
115 std::vector<std::string> args;
116 StdoutRecord stdoutRecord;
117 stdoutRecord.Start();
118
119 args = {"raw"};
120 EXPECT_EQ(subCommandList.OnSubCommand(args), true);
121 std::string stringOut = stdoutRecord.Stop();
122 }
123
124 /**
125 * @tc.name: TestOnSubCommandERROR
126 * @tc.desc:
127 * @tc.type: FUNC
128 */
129 HWTEST_F(SubCommandListTest, TestOnSubCommandERROR, TestSize.Level1)
130 {
131 std::vector<std::string> args;
132 StdoutRecord stdoutRecord;
133 stdoutRecord.Start();
134
135 args = {"error"};
136 EXPECT_EQ(subCommandList.OnSubCommand(args), false);
137 std::string stringOut = stdoutRecord.Stop();
138 }
139
140 /**
141 * @tc.name: TestOnSubCommandEmpty
142 * @tc.desc:
143 * @tc.type: FUNC
144 */
145 HWTEST_F(SubCommandListTest, TestOnSubCommandEmpty, TestSize.Level1)
146 {
147 std::vector<std::string> args;
148 StdoutRecord stdoutRecord;
149 stdoutRecord.Start();
150
151 args.clear();
152 EXPECT_EQ(subCommandList.OnSubCommand(args), true);
153 std::string stringOut = stdoutRecord.Stop();
154 }
155
156 /**
157 * @tc.name: TestRegisterSubCommandList
158 * @tc.desc:
159 * @tc.type: FUNC
160 */
161 HWTEST_F(SubCommandListTest, TestRegisterSubCommandList, TestSize.Level1)
162 {
163 subCommandList.RegisterSubCommandList();
164 EXPECT_EQ(1, 1);
165 }
166 } // namespace HiPerf
167 } // namespace Developtools
168 } // namespace OHOS