1 /*
2 * Copyright (c) 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 #include <gtest/gtest.h>
16 #include "hidumper_test_utils.h"
17
18 using namespace testing::ext;
19 namespace OHOS {
20 namespace HiviewDFX {
21 class SADumperTest : public testing::Test {
22 public:
23 static void SetUpTestCase(void);
24 static void TearDownTestCase(void);
25 void SetUp();
26 void TearDown();
27 };
28
SetUpTestCase(void)29 void SADumperTest::SetUpTestCase(void)
30 {
31 }
TearDownTestCase(void)32 void SADumperTest::TearDownTestCase(void)
33 {
34 }
SetUp(void)35 void SADumperTest::SetUp(void)
36 {
37 }
TearDown(void)38 void SADumperTest::TearDown(void)
39 {
40 }
41
42 /**
43 * @tc.name: SADumperTest001
44 * @tc.desc: Test SA HiviewService result contain "log".
45 * @tc.type: FUNC
46 * @tc.require: issueI5NWZQ
47 */
48 HWTEST_F(SADumperTest, SADumperTest001, TestSize.Level3)
49 {
50 std::string cmd = "hidumper -s 1201 -a '-p Faultlogger'";
51 std::string str = "log";
52 ASSERT_TRUE(HidumperTestUtils::GetInstance().IsExistInCmdResult(cmd, str));
53 }
54
55 /**
56 * @tc.name: SADumperTest002
57 * @tc.desc: Test SA WindowManagerService result contain "WindowName".
58 * @tc.type: FUNC
59 * @tc.require: issueI5NX04
60 */
61 HWTEST_F(SADumperTest, SADumperTest002, TestSize.Level3)
62 {
63 std::string cmd = "hidumper -s WindowManagerService -a '-w 6 -default'";
64 std::string str = "WindowName";
65 ASSERT_TRUE(HidumperTestUtils::GetInstance().IsExistInCmdResult(cmd, str));
66 cmd = "hidumper -s WindowManagerService -a -a";
67 ASSERT_TRUE(HidumperTestUtils::GetInstance().IsExistInCmdResult(cmd, str));
68 }
69
70 /**
71 * @tc.name: SADumperTest003
72 * @tc.desc: Test SA RenderService result contain "ScreenInfo".
73 * @tc.type: FUNC
74 * @tc.require: issueI5NWZQ
75 */
76 HWTEST_F(SADumperTest, SADumperTest003, TestSize.Level3)
77 {
78 std::string cmd = "hidumper -s 10 -a allInfo";
79 std::string str = "ScreenInfo";
80 ASSERT_TRUE(HidumperTestUtils::GetInstance().IsExistInCmdResult(cmd, str));
81 }
82
83 /**
84 * @tc.name: SADumperTest004
85 * @tc.desc: Test SA WorkSchedule result contain "Work".
86 * @tc.type: FUNC
87 * @tc.require: issueI5NWZQ
88 */
89 HWTEST_F(SADumperTest, SADumperTest004, TestSize.Level3)
90 {
91 std::string cmd = "hidumper -s 1904 -a -a";
92 std::string str = "Work";
93 ASSERT_TRUE(HidumperTestUtils::GetInstance().IsExistInCmdResult(cmd, str));
94 }
95 /**
96 * @tc.name: SADumperTest005
97 * @tc.desc: Test SA AbilityManagerService result contain "User".
98 * @tc.type: FUNC
99 * @tc.require: issueI5NWZQ
100 */
101 HWTEST_F(SADumperTest, SADumperTest005, TestSize.Level3)
102 {
103 std::string cmd = "hidumper -s AbilityManagerService -a -l";
104 std::string str = "User";
105 ASSERT_TRUE(HidumperTestUtils::GetInstance().IsExistInCmdResult(cmd, str));
106 }
107
108 /**
109 * @tc.name: SADumperTest006
110 * @tc.desc: Test SA DisplayManagerService result contain "Screen".
111 * @tc.type: FUNC
112 * @tc.require: issueI5NWZQ
113 */
114 HWTEST_F(SADumperTest, SADumperTest006, TestSize.Level3)
115 {
116 std::string cmd = "hidumper -s DisplayManagerService -a '-s -a'";
117 std::string str = "Screen";
118 ASSERT_TRUE(HidumperTestUtils::GetInstance().IsExistInCmdResult(cmd, str));
119 }
120
121 /**
122 * @tc.name: SADumperTest007
123 * @tc.desc: Test SA ScreenlockService result contain "Screen".
124 * @tc.type: FUNC
125 * @tc.require: issueI5NWZQ
126 */
127 HWTEST_F(SADumperTest, SADumperTest007, TestSize.Level3)
128 {
129 std::string cmd = "hidumper -s ScreenlockService -a -all";
130 std::string str = "system";
131 ASSERT_TRUE(HidumperTestUtils::GetInstance().IsExistInCmdResult(cmd, str));
132 }
133
134 /**
135 * @tc.name: SADumperTest008
136 * @tc.desc: Test SA MultimodalInput result contain "Windows".
137 * @tc.type: FUNC
138 * @tc.require: issueI5NWZQ
139 */
140 HWTEST_F(SADumperTest, SADumperTest008, TestSize.Level3)
141 {
142 std::string cmd = "hidumper -s MultimodalInput -a -w";
143 std::string str = "Windows";
144 ASSERT_TRUE(HidumperTestUtils::GetInstance().IsExistInCmdResult(cmd, str));
145 }
146
147 /**
148 * @tc.name: SADumperTest009
149 * @tc.desc: Test SA RenderService result contain "Graphic".
150 * @tc.type: FUNC
151 * @tc.require: issueI5NWZQ
152 */
153 HWTEST_F(SADumperTest, SADumperTest009, TestSize.Level3)
154 {
155 std::string path = "/data/log/hidumper/RenderService.txt";
156 std::string cmd = "hidumper -s 10 -a -h > " + path;
157 std::string str = "Graphic";
158 ASSERT_TRUE(HidumperTestUtils::GetInstance().IsExistStrInFile(cmd, str, path));
159 system("rm -rf /data/log/hidumper/RenderService.txt");
160 }
161
162 /**
163 * @tc.name: SADumperTest009
164 * @tc.desc: Test zip SA RenderService result not contain "Graphic".
165 * @tc.type: FUNC
166 * @tc.require: issueI5NWZQ
167 */
168 HWTEST_F(SADumperTest, SADumperTest010, TestSize.Level3)
169 {
170 std::string cmd = "hidumper -s 10 -a -h --zip";
171 std::string str = "Graphic";
172 ASSERT_FALSE(HidumperTestUtils::GetInstance().IsExistInCmdResult(cmd, str));
173 }
174 } // namespace HiviewDFX
175 } // namespace OHOS