• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 "stats_service_dump_test.h"
17 #include "stats_log.h"
18 
19 #include <display_power_info.h>
20 #include <hisysevent.h>
21 #include <running_lock_info.h>
22 #include <string_ex.h>
23 
24 #include "battery_stats_listener.h"
25 #include "battery_stats_service.h"
26 #include "hisysevent_operation.h"
27 #include "stats_hisysevent.h"
28 #include "stats_service_test_proxy.h"
29 #include "stats_service_write_event.h"
30 
31 using namespace testing::ext;
32 using namespace OHOS::HiviewDFX;
33 using namespace OHOS::PowerMgr;
34 using namespace OHOS;
35 using namespace std;
36 
37 namespace {
38 static sptr<BatteryStatsService> g_statsService = nullptr;
39 static std::shared_ptr<StatsServiceTestProxy> g_statsServiceProxy = nullptr;
40 static std::vector<std::string> dumpArgs;
41 } // namespace
42 
SetUpTestCase()43 void StatsServiceDumpTest::SetUpTestCase()
44 {
45     ParserAveragePowerFile();
46     g_statsService = BatteryStatsService::GetInstance();
47     g_statsService->OnStart();
48     g_statsService->isBootCompleted_ = true;
49 
50     if (g_statsService->listenerPtr_ == nullptr) {
51         g_statsService->listenerPtr_ = std::make_shared<BatteryStatsListener>();
52     }
53 
54     if (g_statsServiceProxy == nullptr) {
55         g_statsServiceProxy = std::make_shared<StatsServiceTestProxy>(g_statsService);
56     }
57     dumpArgs.push_back("-batterystats");
58 }
59 
TearDownTestCase()60 void StatsServiceDumpTest::TearDownTestCase()
61 {
62     g_statsService->listenerPtr_ = nullptr;
63     g_statsService->OnStop();
64 }
65 
SetUp()66 void StatsServiceDumpTest::SetUp()
67 {
68     auto statsService = BatteryStatsService::GetInstance();
69     statsService->SetOnBattery(true);
70 }
71 
TearDown()72 void StatsServiceDumpTest::TearDown()
73 {
74     auto statsService = BatteryStatsService::GetInstance();
75     statsService->SetOnBattery(false);
76 }
77 
78 namespace {
79 /**
80  * @tc.name: StatsServiceDumpTest_001
81  * @tc.desc: test Dump function(BATTERY_CHANGED)
82  * @tc.type: FUNC
83  * @tc.require: issueI663DX
84  */
85 HWTEST_F (StatsServiceDumpTest, StatsServiceDumpTest_001, TestSize.Level0)
86 {
87     STATS_HILOGI(LABEL_TEST, "StatsServiceDumpTest_001 start");
88     ASSERT_NE(g_statsServiceProxy, nullptr);
89     auto statsService = BatteryStatsService::GetInstance();
90     g_statsServiceProxy->ResetIpc();
91 
92     int32_t batteryLevel = 60;
93     int32_t batteryChargerType = 2;
94 
95     StatsWriteHiSysEvent(statsService,
96         HiSysEvent::Domain::BATTERY, StatsHiSysEvent::BATTERY_CHANGED, HiSysEvent::EventType::STATISTIC, "LEVEL",
97         batteryLevel, "CHARGER", batteryChargerType);
98 
99     std::string expectedDebugInfo;
100     expectedDebugInfo.append("Battery level = ")
101         .append(ToString(batteryLevel))
102         .append(", Charger type = ")
103         .append(ToString(batteryChargerType));
104 
105     std::string actualDebugInfo;
106     g_statsServiceProxy->ShellDumpIpc(dumpArgs, dumpArgs.size(), actualDebugInfo);
107     GTEST_LOG_(INFO) << __func__ << ": expected debug info: " << expectedDebugInfo;
108     GTEST_LOG_(INFO) << __func__ << ": actual debug info: " << actualDebugInfo;
109     auto index = actualDebugInfo.find(expectedDebugInfo);
110     EXPECT_TRUE(index != string::npos);
111 
112     StatsWriteHiSysEvent(statsService,
113         HiSysEvent::Domain::BATTERY, StatsHiSysEvent::BATTERY_CHANGED, HiSysEvent::EventType::STATISTIC);
114     std::string expectedMissInfo;
115     expectedMissInfo.append("Battery level = ").append(ToString(-1));
116     std::string actualMissInfo;
117     g_statsServiceProxy->ShellDumpIpc(dumpArgs, dumpArgs.size(), actualMissInfo);
118     auto missIndex = actualMissInfo.find(expectedMissInfo);
119     EXPECT_TRUE(missIndex != string::npos);
120     STATS_HILOGI(LABEL_TEST, "StatsServiceDumpTest_001 end");
121 }
122 
123 /**
124  * @tc.name: StatsServiceDumpTest_002
125  * @tc.desc: test Dump function(POWER_RUNNINGLOCK)
126  * @tc.type: FUNC
127  * @tc.require: issueI663DX
128  */
129 HWTEST_F (StatsServiceDumpTest, StatsServiceDumpTest_002, TestSize.Level0)
130 {
131     STATS_HILOGI(LABEL_TEST, "StatsServiceDumpTest_002 start");
132     ASSERT_NE(g_statsServiceProxy, nullptr);
133     auto statsService = BatteryStatsService::GetInstance();
134     g_statsServiceProxy->ResetIpc();
135 
136     int32_t uid = 10001;
137     int32_t pid = 3456;
138     int32_t stateLock = 1;
139     int32_t stateUnlock = 0;
140     int32_t type = static_cast<int32_t>(RunningLockType::RUNNINGLOCK_SCREEN);
141     std::string name = " StatsServiceDumpTest_002";
142 
143     StatsWriteHiSysEvent(statsService,
144         HiSysEvent::Domain::POWER, StatsHiSysEvent::POWER_RUNNINGLOCK, HiSysEvent::EventType::STATISTIC, "PID", pid,
145         "UID", uid, "STATE", stateLock, "TYPE", type, "NAME", name);
146     usleep(US_PER_MS);
147     StatsWriteHiSysEvent(statsService,
148         HiSysEvent::Domain::POWER, StatsHiSysEvent::POWER_RUNNINGLOCK, HiSysEvent::EventType::STATISTIC, "PID", pid,
149         "UID", uid, "STATE", stateUnlock, "TYPE", type, "NAME", name);
150 
151     std::string expectedDebugInfo;
152     expectedDebugInfo.append("UID = ")
153         .append(ToString(uid))
154         .append(", PID = ")
155         .append(ToString(pid))
156         .append(", wakelock type = ")
157         .append(ToString(type))
158         .append(", wakelock name = ")
159         .append(name);
160 
161     std::string actualDebugInfo;
162     g_statsServiceProxy->ShellDumpIpc(dumpArgs, dumpArgs.size(), actualDebugInfo);
163     GTEST_LOG_(INFO) << __func__ << ": expected debug info: " << expectedDebugInfo;
164     GTEST_LOG_(INFO) << __func__ << ": actual debug info: " << actualDebugInfo;
165     auto index = actualDebugInfo.find(expectedDebugInfo);
166     EXPECT_TRUE(index != string::npos);
167 
168     StatsWriteHiSysEvent(statsService,
169         HiSysEvent::Domain::POWER, StatsHiSysEvent::POWER_RUNNINGLOCK, HiSysEvent::EventType::STATISTIC);
170     std::string expectedMissInfo;
171     expectedMissInfo.append(", wakelock name = ").append("");
172     std::string actualMissInfo;
173     g_statsServiceProxy->ShellDumpIpc(dumpArgs, dumpArgs.size(), actualMissInfo);
174     auto missIndex = actualMissInfo.find(expectedMissInfo);
175     EXPECT_TRUE(missIndex != string::npos);
176     STATS_HILOGI(LABEL_TEST, "StatsServiceDumpTest_002 end");
177 }
178 
179 /**
180  * @tc.name: StatsServiceDumpTest_003
181  * @tc.desc: test Dump function(BACKLIGHT_DISCOUNT)
182  * @tc.type: FUNC
183  * @tc.require: issueI663DX
184  */
185 HWTEST_F (StatsServiceDumpTest, StatsServiceDumpTest_003, TestSize.Level0)
186 {
187     STATS_HILOGI(LABEL_TEST, "StatsServiceDumpTest_003 start");
188     ASSERT_NE(g_statsServiceProxy, nullptr);
189     auto statsService = BatteryStatsService::GetInstance();
190     g_statsServiceProxy->ResetIpc();
191 
192     int32_t ratio = 100;
193 
194     StatsWriteHiSysEvent(statsService,
195         HiSysEvent::Domain::DISPLAY, StatsHiSysEvent::BACKLIGHT_DISCOUNT,
196         HiSysEvent::EventType::STATISTIC, "RATIO", ratio);
197     std::string expectedDebugInfo;
198     expectedDebugInfo.append("Additional debug info: ")
199         .append("Event name = ")
200         .append(StatsHiSysEvent::BACKLIGHT_DISCOUNT)
201         .append(" Ratio = ")
202         .append(ToString(ratio));
203 
204     std::string actualDebugInfo;
205     g_statsServiceProxy->ShellDumpIpc(dumpArgs, dumpArgs.size(), actualDebugInfo);
206     GTEST_LOG_(INFO) << __func__ << ": expected debug info: " << expectedDebugInfo;
207     GTEST_LOG_(INFO) << __func__ << ": actual debug info: " << actualDebugInfo;
208     auto index = actualDebugInfo.find(expectedDebugInfo);
209     EXPECT_TRUE(index != string::npos);
210 
211     StatsWriteHiSysEvent(statsService,
212         HiSysEvent::Domain::DISPLAY, StatsHiSysEvent::BACKLIGHT_DISCOUNT, HiSysEvent::EventType::STATISTIC);
213     std::string expectedMissInfo;
214     expectedMissInfo.append(" Ratio = ").append("");
215     std::string actualMissInfo;
216     g_statsServiceProxy->ShellDumpIpc(dumpArgs, dumpArgs.size(), actualMissInfo);
217     auto missIndex = actualMissInfo.find(expectedMissInfo);
218     EXPECT_TRUE(missIndex != string::npos);
219     STATS_HILOGI(LABEL_TEST, "StatsServiceDumpTest_003 end");
220 }
221 
222 /**
223  * @tc.name: StatsServiceDumpTest_004
224  * @tc.desc: test Dump function(POWER_WORKSCHEDULER)
225  * @tc.type: FUNC
226  * @tc.require: issueI663DX
227  */
228 HWTEST_F (StatsServiceDumpTest, StatsServiceDumpTest_004, TestSize.Level0)
229 {
230     STATS_HILOGI(LABEL_TEST, "StatsServiceDumpTest_004 start");
231     ASSERT_NE(g_statsServiceProxy, nullptr);
232     auto statsService = BatteryStatsService::GetInstance();
233     g_statsServiceProxy->ResetIpc();
234 
235     int32_t pid = 3457;
236     int32_t uid = 10002;
237     int32_t type = 1;
238     int32_t interval = 30000;
239     int32_t state = 5;
240 
241     StatsWriteHiSysEvent(statsService,
242         HiSysEvent::Domain::STATS, StatsHiSysEvent::POWER_WORKSCHEDULER,
243         HiSysEvent::EventType::STATISTIC, "PID", pid,
244         "UID", uid, "TYPE", type, "INTERVAL", interval, "STATE", state);
245 
246     std::string expectedDebugInfo;
247     expectedDebugInfo.append("UID = ")
248         .append(ToString(uid))
249         .append(", PID = ")
250         .append(ToString(pid))
251         .append(", work type = ")
252         .append(ToString(type))
253         .append(", work interval = ")
254         .append(ToString(interval))
255         .append(", work state = ")
256         .append(ToString(state));
257 
258     std::string actualDebugInfo;
259     g_statsServiceProxy->ShellDumpIpc(dumpArgs, dumpArgs.size(), actualDebugInfo);
260     GTEST_LOG_(INFO) << __func__ << ": expected debug info: " << expectedDebugInfo;
261     GTEST_LOG_(INFO) << __func__ << ": actual debug info: " << actualDebugInfo;
262     auto index = actualDebugInfo.find(expectedDebugInfo);
263     EXPECT_TRUE(index != string::npos);
264 
265     StatsWriteHiSysEvent(statsService,
266         HiSysEvent::Domain::STATS, StatsHiSysEvent::POWER_WORKSCHEDULER, HiSysEvent::EventType::STATISTIC);
267     std::string expectedMissInfo;
268     expectedMissInfo.append(", work interval = ").append("");
269     std::string actualMissInfo;
270     g_statsServiceProxy->ShellDumpIpc(dumpArgs, dumpArgs.size(), actualMissInfo);
271     auto missIndex = actualMissInfo.find(expectedMissInfo);
272     EXPECT_TRUE(missIndex != string::npos);
273     STATS_HILOGI(LABEL_TEST, "StatsServiceDumpTest_004 end");
274 }
275 
276 /**
277  * @tc.name: StatsServiceDumpTest_005
278  * @tc.desc: test Dump function(POWER_TEMPERATURE)
279  * @tc.type: FUNC
280  * @tc.require: issueI663DX
281  */
282 HWTEST_F (StatsServiceDumpTest, StatsServiceDumpTest_005, TestSize.Level0)
283 {
284     STATS_HILOGI(LABEL_TEST, "StatsServiceDumpTest_005 start");
285     ASSERT_NE(g_statsServiceProxy, nullptr);
286     auto statsService = BatteryStatsService::GetInstance();
287     g_statsServiceProxy->ResetIpc();
288 
289     std::string partName = "Battery";
290     int32_t temperature = 40;
291 
292     StatsWriteHiSysEvent(statsService,
293         HiSysEvent::Domain::THERMAL, StatsHiSysEvent::POWER_TEMPERATURE, HiSysEvent::EventType::STATISTIC, "NAME",
294         partName, "TEMPERATURE", temperature);
295 
296     std::string expectedDebugInfo;
297     expectedDebugInfo.append("Additional debug info: ")
298         .append("Event name = POWER_TEMPERATURE")
299         .append(" Name = ")
300         .append(partName);
301 
302     std::string actualDebugInfo;
303     g_statsServiceProxy->ShellDumpIpc(dumpArgs, dumpArgs.size(), actualDebugInfo);
304     GTEST_LOG_(INFO) << __func__ << ": expected debug info: " << expectedDebugInfo;
305     GTEST_LOG_(INFO) << __func__ << ": actual debug info: " << actualDebugInfo;
306     auto index = actualDebugInfo.find(expectedDebugInfo);
307     EXPECT_TRUE(index != string::npos);
308 
309     StatsWriteHiSysEvent(statsService,
310         HiSysEvent::Domain::THERMAL, StatsHiSysEvent::POWER_TEMPERATURE, HiSysEvent::EventType::STATISTIC);
311     std::string expectedMissInfo;
312     expectedMissInfo.append("Additional debug info: ")
313         .append("Event name = POWER_TEMPERATURE")
314         .append(" Name = ")
315         .append("");
316     std::string actualMissInfo;
317     g_statsServiceProxy->ShellDumpIpc(dumpArgs, dumpArgs.size(), actualMissInfo);
318     auto missIndex = actualMissInfo.find(expectedMissInfo);
319     EXPECT_TRUE(missIndex != string::npos);
320     STATS_HILOGI(LABEL_TEST, "StatsServiceDumpTest_005 end");
321 }
322 
323 /**
324  * @tc.name: StatsServiceDumpTest_006
325  * @tc.desc: test Dump function(START_REMOTE_ABILITY)
326  * @tc.type: FUNC
327  * @tc.require: issueI663DX
328  */
329 HWTEST_F (StatsServiceDumpTest, StatsServiceDumpTest_006, TestSize.Level0)
330 {
331     STATS_HILOGI(LABEL_TEST, "StatsServiceDumpTest_006 start");
332     ASSERT_NE(g_statsServiceProxy, nullptr);
333     auto statsService = BatteryStatsService::GetInstance();
334     g_statsServiceProxy->ResetIpc();
335 
336     std::string callType = "DUBAI_TAG_DIST_SCHED_TO_REMOTE";
337     int32_t callUid = 10003;
338     int32_t callPid = 3458;
339     std::string targetBundle = "TargetBundleName";
340     std::string targetAbility = "TargetAbilityName";
341     int32_t callAppUid = 9568;
342     int32_t result = 1;
343 
344     StatsWriteHiSysEvent(statsService,
345         HiSysEvent::Domain::DISTRIBUTED_SCHEDULE,
346         StatsHiSysEvent::START_REMOTE_ABILITY, HiSysEvent::EventType::BEHAVIOR,
347         "CALLING_TYPE", callType, "CALLING_UID", callUid, "CALLING_PID", callPid, "TARGET_BUNDLE", targetBundle,
348         "TARGET_ABILITY", targetAbility, "CALLING_APP_UID", callAppUid, "RESULT", result);
349 
350     std::string expectedDebugInfo;
351     expectedDebugInfo.append("Additional debug info: ")
352         .append("Event name = START_REMOTE_ABILITY")
353         .append(" Calling Type = ")
354         .append(callType);
355 
356     std::string actualDebugInfo;
357     g_statsServiceProxy->ShellDumpIpc(dumpArgs, dumpArgs.size(), actualDebugInfo);
358     GTEST_LOG_(INFO) << __func__ << ": expected debug info: " << expectedDebugInfo;
359     GTEST_LOG_(INFO) << __func__ << ": actual debug info: " << actualDebugInfo;
360     auto index = actualDebugInfo.find(expectedDebugInfo);
361     EXPECT_TRUE(index != string::npos);
362 
363     StatsWriteHiSysEvent(statsService,
364         HiSysEvent::Domain::DISTRIBUTED_SCHEDULE,
365         StatsHiSysEvent::START_REMOTE_ABILITY, HiSysEvent::EventType::BEHAVIOR);
366     std::string expectedMissInfo;
367     expectedMissInfo.append("Additional debug info: ")
368         .append("Event name = START_REMOTE_ABILITY")
369         .append(" Calling Type = ")
370         .append("");
371     std::string actualMissInfo;
372     g_statsServiceProxy->ShellDumpIpc(dumpArgs, dumpArgs.size(), actualMissInfo);
373     auto missIndex = actualMissInfo.find(expectedMissInfo);
374     EXPECT_TRUE(missIndex != string::npos);
375     STATS_HILOGI(LABEL_TEST, "StatsServiceDumpTest_006 end");
376 }
377 
378 /**
379  * @tc.name: StatsServiceDumpTest_007
380  * @tc.desc: test Dump function(THERMAL_ACTION_TRIGGERED)
381  * @tc.type: FUNC
382  * @tc.require: issueI663DX
383  */
384 HWTEST_F (StatsServiceDumpTest, StatsServiceDumpTest_007, TestSize.Level0)
385 {
386     STATS_HILOGI(LABEL_TEST, "StatsServiceDumpTest_007 start");
387     ASSERT_NE(g_statsServiceProxy, nullptr);
388     auto statsService = BatteryStatsService::GetInstance();
389     g_statsServiceProxy->ResetIpc();
390 
391     std::string actionName = "thermallevel";
392     int32_t value = 3;
393     float ratio = 0.60;
394     int32_t beginPos = 0;
395     int32_t ratioLen = 4;
396 
397     StatsWriteHiSysEvent(statsService,
398         HiviewDFX::HiSysEvent::Domain::THERMAL, StatsHiSysEvent::THERMAL_ACTION_TRIGGERED,
399         HiviewDFX::HiSysEvent::EventType::STATISTIC, "ACTION", actionName, "VALUE", value, "RATIO", ratio);
400 
401     std::string expectedDebugInfo;
402     expectedDebugInfo.append("Additional debug info: ")
403         .append("Event name = ACTION_TRIGGERED")
404         .append(" Action name = ")
405         .append(actionName)
406         .append(" Value = ")
407         .append(ToString(value))
408         .append(" Ratio = ")
409         .append(std::to_string(ratio).substr(beginPos, ratioLen));
410 
411     std::string actualDebugInfo;
412     g_statsServiceProxy->ShellDumpIpc(dumpArgs, dumpArgs.size(), actualDebugInfo);
413     GTEST_LOG_(INFO) << __func__ << ": expected debug info: " << expectedDebugInfo;
414     GTEST_LOG_(INFO) << __func__ << ": actual debug info: " << actualDebugInfo;
415     auto index = actualDebugInfo.find(expectedDebugInfo);
416     EXPECT_TRUE(index != string::npos);
417 
418     StatsWriteHiSysEvent(statsService,
419         HiSysEvent::Domain::THERMAL, StatsHiSysEvent::THERMAL_ACTION_TRIGGERED, HiSysEvent::EventType::STATISTIC);
420     std::string expectedMissInfo;
421     expectedMissInfo.append("Additional debug info: ")
422         .append("Event name = ACTION_TRIGGERED")
423         .append(" Action name = ")
424         .append("");
425     std::string actualMissInfo;
426     g_statsServiceProxy->ShellDumpIpc(dumpArgs, dumpArgs.size(), actualMissInfo);
427     auto missIndex = actualMissInfo.find(expectedMissInfo);
428     EXPECT_TRUE(missIndex != string::npos);
429     STATS_HILOGI(LABEL_TEST, "StatsServiceDumpTest_007 end");
430 }
431 
432 /**
433  * @tc.name: StatsServiceDumpTest_008
434  * @tc.desc: test Dump function(AMBIENT_LIGHT)
435  * @tc.type: FUNC
436  * @tc.require: issueI663DX
437  */
438 HWTEST_F (StatsServiceDumpTest, StatsServiceDumpTest_008, TestSize.Level0)
439 {
440     STATS_HILOGI(LABEL_TEST, "StatsServiceDumpTest_008 start");
441     ASSERT_NE(g_statsServiceProxy, nullptr);
442     auto statsService = BatteryStatsService::GetInstance();
443     g_statsServiceProxy->ResetIpc();
444 
445     int32_t type = 100;
446     int32_t level = 101;
447 
448     StatsWriteHiSysEvent(statsService,
449         HiSysEvent::Domain::DISPLAY, StatsHiSysEvent::AMBIENT_LIGHT,
450         HiSysEvent::EventType::STATISTIC, "TYPE", type, "LEVEL", level);
451 
452     std::string expectedDebugInfo;
453     expectedDebugInfo.append("Additional debug info: ")
454         .append("Event name = ")
455         .append(StatsHiSysEvent::AMBIENT_LIGHT)
456         .append(" Ambient type = ")
457         .append(ToString(type))
458         .append(" Ambient brightness = ")
459         .append(ToString(level));
460 
461     std::string actualDebugInfo;
462     g_statsServiceProxy->ShellDumpIpc(dumpArgs, dumpArgs.size(), actualDebugInfo);
463     GTEST_LOG_(INFO) << __func__ << ": expected debug info: " << expectedDebugInfo;
464     GTEST_LOG_(INFO) << __func__ << ": actual debug info: " << actualDebugInfo;
465     auto index = actualDebugInfo.find(expectedDebugInfo);
466     EXPECT_TRUE(index != string::npos);
467 
468     StatsWriteHiSysEvent(statsService,
469         HiSysEvent::Domain::DISPLAY, StatsHiSysEvent::AMBIENT_LIGHT, HiSysEvent::EventType::STATISTIC);
470     std::string expectedMissInfo;
471     expectedMissInfo.append("Additional debug info: ")
472         .append("Event name = ")
473         .append(StatsHiSysEvent::AMBIENT_LIGHT)
474         .append(" Ambient type = ")
475         .append("");
476     std::string actualMissInfo;
477     g_statsServiceProxy->ShellDumpIpc(dumpArgs, dumpArgs.size(), actualMissInfo);
478     auto missIndex = actualMissInfo.find(expectedMissInfo);
479     EXPECT_TRUE(missIndex != string::npos);
480     STATS_HILOGI(LABEL_TEST, "StatsServiceDumpTest_008 end");
481 }
482 
483 /**
484  * @tc.name: StatsServiceDumpTest_009
485  * @tc.desc: test Dump function(args is none or help)
486  * @tc.type: FUNC
487  * @tc.require: issueI663DX
488  */
489 HWTEST_F (StatsServiceDumpTest, StatsServiceDumpTest_009, TestSize.Level0)
490 {
491     STATS_HILOGI(LABEL_TEST, "StatsServiceDumpTest_009 start");
492     ASSERT_NE(g_statsServiceProxy, nullptr);
493     auto statsService = BatteryStatsService::GetInstance();
494     g_statsServiceProxy->ResetIpc();
495 
496     std::vector<std::string> dumpArgsNone {};
497     std::vector<std::string> dumpArgsHelp {};
498     dumpArgsHelp.push_back("-h");
499 
500     std::string expectedDebugInfo;
501     expectedDebugInfo.append("usage: statistics <command> [<options>]\n");
502 
503     std::string noneDebugInfo;
504     g_statsServiceProxy->ShellDumpIpc(dumpArgsNone, dumpArgsNone.size(), noneDebugInfo);
505     auto noneIndex = noneDebugInfo.find(expectedDebugInfo);
506     EXPECT_TRUE(noneIndex != string::npos);
507 
508     std::string helpDebugInfo;
509     g_statsServiceProxy->ShellDumpIpc(dumpArgsHelp, dumpArgsHelp.size(), helpDebugInfo);
510     auto helpIndex = helpDebugInfo.find(expectedDebugInfo);
511     EXPECT_TRUE(helpIndex != string::npos);
512     STATS_HILOGI(LABEL_TEST, "StatsServiceDumpTest_009 end");
513 }
514 }