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 "device_status_collect_manager_test.h"
17 
18 #include "sa_profiles.h"
19 #include "string_ex.h"
20 #include "test_log.h"
21 
22 #define private public
23 #include "common_event_collect.h"
24 #include "device_status_collect_manager.h"
25 #ifdef SUPPORT_COMMON_EVENT
26 #include "common_event_collect.h"
27 #include "common_event_manager.h"
28 #include "device_switch_collect.h"
29 #endif
30 
31 #ifdef SUPPORT_DEVICE_MANAGER
32 #include "device_networking_collect.h"
33 #endif
34 
35 #ifdef SUPPORT_SWITCH_COLLECT
36 #include "device_switch_collect.h"
37 #endif
38 
39 using namespace std;
40 using namespace testing;
41 using namespace testing::ext;
42 using namespace OHOS;
43 
44 namespace OHOS {
45 namespace {
46 constexpr int32_t MAX_WAIT_TIME = 10000;
47 constexpr int64_t EXTRA_ID = 1;
48 const std::string SA_TAG_DEVICE_ON_LINE = "deviceonline";
49 const std::string WIFI_NAME = "wifi_status";
50 constexpr int32_t MOCK_PLUGIN = 20;
51 sptr<DeviceStatusCollectManager> collect;
52 }
53 
SetUpTestCase()54 void DeviceStatusCollectManagerTest::SetUpTestCase()
55 {
56     DTEST_LOG << "SetUpTestCase" << std::endl;
57 }
58 
TearDownTestCase()59 void DeviceStatusCollectManagerTest::TearDownTestCase()
60 {
61     DTEST_LOG << "TearDownTestCase" << std::endl;
62 }
63 
SetUp()64 void DeviceStatusCollectManagerTest::SetUp()
65 {
66     collect = new DeviceStatusCollectManager();
67     DTEST_LOG << "SetUp" << std::endl;
68 }
69 
TearDown()70 void DeviceStatusCollectManagerTest::TearDown()
71 {
72     collect->CleanFfrt();
73     DTEST_LOG << "TearDown" << std::endl;
74 }
75 
PostTask(std::shared_ptr<FFRTHandler> & collectHandler)76 void DeviceStatusCollectManagerTest::PostTask(
77     std::shared_ptr<FFRTHandler>& collectHandler)
78 {
79     isCaseDone = false;
80     auto caseDoneNotifyTask = [this]() {
81         std::lock_guard<std::mutex> autoLock(caseDoneLock_);
82         isCaseDone = true;
83         caseDoneCondition_.notify_one();
84     };
85     if (collectHandler != nullptr) {
86         collectHandler->PostTask(caseDoneNotifyTask);
87     }
88     std::unique_lock<std::mutex> lock(caseDoneLock_);
89     caseDoneCondition_.wait_for(lock, std::chrono::milliseconds(MAX_WAIT_TIME),
90         [&] () { return isCaseDone; });
91 }
92 
CheckCondition(const OnDemandCondition & condition)93 bool MockCollectPlugin::CheckCondition(const OnDemandCondition& condition)
94 {
95     return mockCheckConditionResult_;
96 }
97 
98 /**
99  * @tc.name: FilterOnDemandSaProfiles001
100  * @tc.desc: test FilterOnDemandSaProfiles with different parameters
101  * @tc.type: FUNC
102  */
103 HWTEST_F(DeviceStatusCollectManagerTest, FilterOnDemandSaProfiles001, TestSize.Level3)
104 {
105     DTEST_LOG << " FilterOnDemandSaProfiles001 BEGIN" << std::endl;
106     std::list<SaProfile> saProfiles;
107     collect->FilterOnDemandSaProfiles(saProfiles);
108     EXPECT_EQ(true, collect->onDemandSaProfiles_.empty());
109     SaProfile saProfile;
110     OnDemandEvent event = { DEVICE_ONLINE, SA_TAG_DEVICE_ON_LINE, "on" };
111     saProfile.startOnDemand.onDemandEvents.emplace_back(event);
112     saProfiles.emplace_back(saProfile);
113     collect->FilterOnDemandSaProfiles(saProfiles);
114     EXPECT_EQ(false, collect->onDemandSaProfiles_.empty());
115     OnDemandEvent event1 = { DEVICE_ONLINE, SA_TAG_DEVICE_ON_LINE, "off" };
116     saProfile.stopOnDemand.onDemandEvents.emplace_back(event1);
117     saProfiles.emplace_back(saProfile);
118     collect->FilterOnDemandSaProfiles(saProfiles);
119     EXPECT_EQ(false, collect->onDemandSaProfiles_.empty());
120     DTEST_LOG << " FilterOnDemandSaProfiles001 END" << std::endl;
121 }
122 
123 /**
124  * @tc.name: GetSaControlListByEvent001
125  * @tc.desc: test GetSaControlListByEvent with different parameters
126  * @tc.type: FUNC
127  */
128 HWTEST_F(DeviceStatusCollectManagerTest, GetSaControlListByEvent001, TestSize.Level3)
129 {
130     DTEST_LOG << " GetSaControlListByEvent001 BEGIN" << std::endl;
131     collect->collectPluginMap_[DEVICE_ONLINE] = new MockCollectPlugin(collect);
132     OnDemandEvent event = { DEVICE_ONLINE, SA_TAG_DEVICE_ON_LINE, "on" };
133     std::list<SaControlInfo> saControlList;
134     collect->GetSaControlListByEvent(event, saControlList);
135     EXPECT_EQ(true, saControlList.empty());
136     SaProfile saProfile;
137     OnDemandEvent event1 = { DEVICE_ONLINE, SA_TAG_DEVICE_ON_LINE, "on" };
138     OnDemandEvent event2 = { DEVICE_ONLINE, SA_TAG_DEVICE_ON_LINE, "off" };
139     saProfile.startOnDemand.onDemandEvents.emplace_back(event1);
140     saProfile.stopOnDemand.onDemandEvents.emplace_back(event2);
141     collect->onDemandSaProfiles_.emplace_back(saProfile);
142     collect->GetSaControlListByEvent(event, saControlList);
143     EXPECT_EQ(false, saControlList.empty());
144     saControlList.clear();
145     event.value = "off";
146     collect->GetSaControlListByEvent(event, saControlList);
147     EXPECT_EQ(false, saControlList.empty());
148     saControlList.clear();
149     event.value = "";
150     collect->GetSaControlListByEvent(event, saControlList);
151     EXPECT_EQ(true, saControlList.empty());
152     event.name = "settingswitch";
153     collect->GetSaControlListByEvent(event, saControlList);
154     EXPECT_EQ(true, saControlList.empty());
155     event.eventId = SETTING_SWITCH;
156     collect->GetSaControlListByEvent(event, saControlList);
157     EXPECT_EQ(true, saControlList.empty());
158     DTEST_LOG << " GetSaControlListByEvent001 END" << std::endl;
159 }
160 
161 /**
162  * @tc.name: SortSaControlListByLoadPriority001
163  * @tc.desc: test SortSaControlListByLoadPriority with saprofiles that have different ondemand priority
164  * @tc.type: FUNC
165  * @tc.require: I7VXXO
166  */
167 HWTEST_F(DeviceStatusCollectManagerTest, SortSaControlListByLoadPriority001, TestSize.Level3)
168 {
169     DTEST_LOG << " SaControlListByEvent001 BEGIN" << std::endl;
170     collect->collectPluginMap_[DEVICE_ONLINE] = new MockCollectPlugin(collect);
171     OnDemandEvent event = { DEVICE_ONLINE, SA_TAG_DEVICE_ON_LINE, "on" };
172     OnDemandEvent event1 = { DEVICE_ONLINE, SA_TAG_DEVICE_ON_LINE, "on" };
173     event1.loadPriority = 2;
174     OnDemandEvent event2 = { DEVICE_ONLINE, SA_TAG_DEVICE_ON_LINE, "on" };
175     event2.loadPriority = 1;
176     SaProfile saProfile1;
177     saProfile1.startOnDemand.onDemandEvents.emplace_back(event1);
178     SaProfile saProfile2;
179     saProfile2.startOnDemand.onDemandEvents.emplace_back(event2);
180     collect->onDemandSaProfiles_.emplace_back(saProfile1);
181     collect->onDemandSaProfiles_.emplace_back(saProfile2);
182 
183     std::list<SaControlInfo> saControlList;
184     collect->GetSaControlListByEvent(event, saControlList);
185     EXPECT_EQ(2, saControlList.front().loadPriority);
186     EXPECT_EQ(1, saControlList.back().loadPriority);
187 
188     collect->SortSaControlListByLoadPriority(saControlList);
189     EXPECT_EQ(1, saControlList.front().loadPriority);
190     EXPECT_EQ(2, saControlList.back().loadPriority);
191 }
192 
193 /**
194  * @tc.name: UnInit001
195  * @tc.desc: test UnInit
196  * @tc.type: FUNC
197  */
198 HWTEST_F(DeviceStatusCollectManagerTest, UnInit001, TestSize.Level3)
199 {
200     DTEST_LOG << " UnInit001 BEGIN" << std::endl;
201     collect->UnInit();
202     EXPECT_EQ(true, collect->collectPluginMap_.empty());
203 
204     sptr<CommonEventCollect> commonEventCollect = new CommonEventCollect(nullptr);
205     sptr<DeviceSwitchCollect> deviceSwitchCollect =
206         new DeviceSwitchCollect(collect);
207     sptr<ICollectPlugin> networkingCollect = new DeviceNetworkingCollect(nullptr);
208     collect->collectPluginMap_[COMMON_EVENT] = commonEventCollect;
209     collect->collectPluginMap_[SETTING_SWITCH] = deviceSwitchCollect;
210     collect->collectPluginMap_[DEVICE_ONLINE] = networkingCollect;
211     collect->collectHandler_ = std::make_shared<FFRTHandler>("collect");
212 
213     collect->SetFfrt();
214     collect->CleanFfrt();
215     collect->UnInit();
216     EXPECT_EQ(true, collect->collectPluginMap_.empty());
217     DTEST_LOG << " UnInit001 END" << std::endl;
218 }
219 
220 /**
221  * @tc.name: GetSaExtraDataIdList001
222  * @tc.desc: test GetSaExtraDataIdList
223  * @tc.type: FUNC
224  */
225 HWTEST_F(DeviceStatusCollectManagerTest, GetSaExtraDataIdList001, TestSize.Level3)
226 {
227     OnDemandEvent event = { DEVICE_ONLINE, SA_TAG_DEVICE_ON_LINE, "on" };
228     std::list<SaControlInfo> saControlList;
229     collect->SaveCacheCommonEventSaExtraId(event, saControlList);
230     collect->SaveSaExtraDataId(1, 1);
231     collect->ClearSaExtraDataId(1);
232 
233     std::vector<int64_t> extraDataIdList;
234     int32_t ret = collect->GetSaExtraDataIdList(1, extraDataIdList, "test");
235     EXPECT_EQ(ret, ERR_INVALID_VALUE);
236 
237     sptr<CommonEventCollect> commonEventCollect = new CommonEventCollect(nullptr);
238     collect->collectPluginMap_[COMMON_EVENT] = commonEventCollect;
239 
240     ret = collect->GetSaExtraDataIdList(1, extraDataIdList, "");
241     EXPECT_EQ(ret, ERR_OK);
242 }
243 
244 /**
245  * @tc.name: StartCollect001
246  * @tc.desc: test StartCollect with empty collectHandler.
247  * @tc.type: FUNC
248  */
249 HWTEST_F(DeviceStatusCollectManagerTest, StartCollect001, TestSize.Level3)
250 {
251     DTEST_LOG << " StartCollect001 BEGIN" << std::endl;
252     collect->StartCollect();
253     EXPECT_EQ(nullptr, collect->collectHandler_);
254     DTEST_LOG << " StartCollect001 END" << std::endl;
255 }
256 
257 /**
258  * @tc.name: CheckConditions001
259  * @tc.desc: test CheckConditions, with empty conditions.
260  * @tc.type: FUNC
261  * @tc.require: I6JE38
262  */
263 HWTEST_F(DeviceStatusCollectManagerTest, CheckConditions001, TestSize.Level3)
264 {
265     DTEST_LOG << " CheckConditions001 BEGIN" << std::endl;
266     std::list<SaProfile> saProfiles;
267 
268     OnDemandEvent event;
269     bool result = collect->CheckConditions(event);
270     EXPECT_EQ(result, true);
271     DTEST_LOG << " CheckConditions001 END" << std::endl;
272 }
273 
274 /**
275  * @tc.name: CheckConditions002
276  * @tc.desc: test CheckConditions, with invalid condition eventId.
277  * @tc.type: FUNC
278  * @tc.require: I6JE38
279  */
280 HWTEST_F(DeviceStatusCollectManagerTest, CheckConditions002, TestSize.Level3)
281 {
282     DTEST_LOG << " CheckConditions002 BEGIN" << std::endl;
283     std::list<SaProfile> saProfiles;
284     OnDemandCondition condition;
285     condition.eventId = -1;
286     OnDemandEvent event;
287     event.conditions.push_back(condition);
288     bool result = collect->CheckConditions(event);
289     EXPECT_EQ(result, false);
290     DTEST_LOG << " CheckConditions002 END" << std::endl;
291 }
292 
293 /**
294  * @tc.name: CheckConditions003
295  * @tc.desc: test CheckConditions, with collect plugin is nullptr.
296  * @tc.type: FUNC
297  * @tc.require: I6JE38
298  */
299 HWTEST_F(DeviceStatusCollectManagerTest, CheckConditions003, TestSize.Level3)
300 {
301     DTEST_LOG << " CheckConditions003 BEGIN" << std::endl;
302     std::list<SaProfile> saProfiles;
303     collect->collectPluginMap_[MOCK_PLUGIN] = nullptr;
304     OnDemandCondition condition;
305     condition.eventId = MOCK_PLUGIN;
306     OnDemandEvent event;
307     event.conditions.push_back(condition);
308     bool result = collect->CheckConditions(event);
309     EXPECT_EQ(result, false);
310     DTEST_LOG << " CheckConditions003 END" << std::endl;
311 }
312 
313 /**
314  * @tc.name: CheckConditions004
315  * @tc.desc: test CheckConditions, with condition not pass.
316  * @tc.type: FUNC
317  * @tc.require: I6JE38
318  */
319 HWTEST_F(DeviceStatusCollectManagerTest, CheckConditions004, TestSize.Level3)
320 {
321     DTEST_LOG << " CheckConditions004 BEGIN" << std::endl;
322     std::list<SaProfile> saProfiles;
323     collect->collectPluginMap_[MOCK_PLUGIN] = new MockCollectPlugin(collect);
324     OnDemandCondition condition;
325     condition.eventId = MOCK_PLUGIN;
326     OnDemandEvent event;
327     event.conditions.push_back(condition);
328     bool result = collect->CheckConditions(event);
329     EXPECT_EQ(result, false);
330     DTEST_LOG << " CheckConditions004 END" << std::endl;
331 }
332 
333 /**
334  * @tc.name: CheckConditions005
335  * @tc.desc: test CheckConditions, with condition pass.
336  * @tc.type: FUNC
337  * @tc.require: I6JE38
338  */
339 HWTEST_F(DeviceStatusCollectManagerTest, CheckConditions005, TestSize.Level3)
340 {
341     DTEST_LOG << " CheckConditions005 BEGIN" << std::endl;
342     std::list<SaProfile> saProfiles;
343     sptr<MockCollectPlugin> mockCollectPlugin = new MockCollectPlugin(collect);
344     mockCollectPlugin->mockCheckConditionResult_ = true;
345     collect->collectPluginMap_[MOCK_PLUGIN] = mockCollectPlugin;
346     OnDemandCondition condition;
347     condition.eventId = MOCK_PLUGIN;
348     OnDemandEvent event;
349     event.conditions.push_back(condition);
350     bool result = collect->CheckConditions(event);
351     EXPECT_EQ(result, true);
352     DTEST_LOG << " CheckConditions005 END" << std::endl;
353 }
354 
355 /**
356  * @tc.name: CheckExtraMessages001
357  * @tc.desc: test CheckExtraMessages, with empty OnDemandEvent.
358  * @tc.type: FUNC
359  * @tc.require: I6JE38
360  */
361 HWTEST_F(DeviceStatusCollectManagerTest, CheckExtraMessages001, TestSize.Level3)
362 {
363     DTEST_LOG << " CheckExtraMessages001 BEGIN" << std::endl;
364     OnDemandEvent event;
365     bool result = collect->CheckExtraMessages(event, event);
366     EXPECT_EQ(result, false);
367     DTEST_LOG << " CheckExtraMessages001 END" << std::endl;
368 }
369 
370 /**
371  * @tc.name: CheckExtraMessages002
372  * @tc.desc: test CheckExtraMessages with COMMON_EVENT is not in collectPluginMap_
373  * @tc.type: FUNC
374  * @tc.require: I6W735
375  */
376 HWTEST_F(DeviceStatusCollectManagerTest, CheckExtraMessages002, TestSize.Level3)
377 {
378     collect->collectPluginMap_.clear();
379     OnDemandEvent event;
380     event.eventId = COMMON_EVENT;
381     int32_t ret = collect->CheckExtraMessages(event, event);
382     EXPECT_EQ(ret, false);
383 }
384 
385 /**
386  * @tc.name: CheckExtraMessages003
387  * @tc.desc: test CheckExtraMessages with collectPluginMap_[COMMON_EVENT] is nullptr
388  * @tc.type: FUNC
389  * @tc.require: I6W735
390  */
391 HWTEST_F(DeviceStatusCollectManagerTest, CheckExtraMessages003, TestSize.Level3)
392 {
393     collect->collectPluginMap_.clear();
394     collect->collectPluginMap_[COMMON_EVENT] = nullptr;
395     collect->RemoveWhiteCommonEvent();
396     OnDemandEvent event;
397     event.eventId = COMMON_EVENT;
398     int32_t ret = collect->CheckExtraMessages(event, event);
399     EXPECT_EQ(ret, false);
400 }
401 
402 /**
403  * @tc.name: CheckExtraMessages004
404  * @tc.desc: test CheckExtraMessages, pass
405  * @tc.type: FUNC
406  * @tc.require: I6W735
407  */
408 HWTEST_F(DeviceStatusCollectManagerTest, CheckExtraMessages004, TestSize.Level3)
409 {
410     DTEST_LOG << " CheckExtraMessages004 BEGIN" << std::endl;
411     sptr<CommonEventCollect> commonEventCollect = new CommonEventCollect(nullptr);
412     std::shared_ptr<CommonHandler> commonHandler = std::make_shared<CommonHandler>(commonEventCollect);
413 
414     std::map<std::string, std::string> want;
415     want["1"] = "1";
416     OnDemandReasonExtraData extraData = OnDemandReasonExtraData(1, "", want);
417     commonEventCollect->extraDatas_[1] = extraData;
418     OnDemandEvent event, profile;
419     event.extraDataId = 1;
420     event.eventId = COMMON_EVENT;
421     profile.eventId = COMMON_EVENT;
422     profile.extraMessages["1"] = "1";
423 
424     collect->collectPluginMap_.clear();
425     collect->collectPluginMap_[COMMON_EVENT] = commonEventCollect;
426     collect->RemoveWhiteCommonEvent();
427     bool result = collect->CheckExtraMessages(event, profile);
428     EXPECT_EQ(result, true);
429     DTEST_LOG << " CheckExtraMessages004 END" << std::endl;
430 }
431 
432 /**
433  * @tc.name: CheckExtraMessages005
434  * @tc.desc: test CheckExtraMessages, not pass
435  * @tc.type: FUNC
436  * @tc.require: I6W735
437  */
438 HWTEST_F(DeviceStatusCollectManagerTest, CheckExtraMessages005, TestSize.Level3)
439 {
440     DTEST_LOG << " CheckExtraMessages005 BEGIN" << std::endl;
441     sptr<CommonEventCollect> commonEventCollect = new CommonEventCollect(nullptr);
442     std::shared_ptr<CommonHandler> commonHandler = std::make_shared<CommonHandler>(commonEventCollect);
443 
444     std::map<std::string, std::string> want;
445     want["1"] = "1";
446     OnDemandReasonExtraData extraData = OnDemandReasonExtraData(1, "", want);
447     commonEventCollect->extraDatas_[1] = extraData;
448     OnDemandEvent event, profile;
449     event.extraDataId = 1;
450     event.eventId = COMMON_EVENT;
451     profile.eventId = COMMON_EVENT;
452     profile.extraMessages["1"] = "2";
453 
454     collect->collectPluginMap_.clear();
455     collect->collectPluginMap_[COMMON_EVENT] = commonEventCollect;
456     bool result = collect->CheckExtraMessages(event, profile);
457     EXPECT_EQ(result, false);
458     DTEST_LOG << " CheckExtraMessages005 END" << std::endl;
459 }
460 
461 
462 /**
463  * @tc.name: ReportEvent001
464  * @tc.desc: test ReportEvent, with empty collectHandler.
465  * @tc.type: FUNC
466  */
467 HWTEST_F(DeviceStatusCollectManagerTest, ReportEvent001, TestSize.Level3)
468 {
469     DTEST_LOG << " ReportEvent001 BEGIN" << std::endl;
470     OnDemandEvent event;
471     collect->ReportEvent(event);
472     EXPECT_EQ(nullptr, collect->collectHandler_);
473     DTEST_LOG << " ReportEvent001 END" << std::endl;
474 }
475 
476 /**
477  * @tc.name: ReportEvent002
478  * @tc.desc: test ReportEvent, with empty saControlList.
479  * @tc.type: FUNC
480  */
481 HWTEST_F(DeviceStatusCollectManagerTest, ReportEvent002, TestSize.Level3)
482 {
483     DTEST_LOG << " ReportEvent002 BEGIN" << std::endl;
484     std::list<SaProfile> saProfiles;
485     collect->Init(saProfiles);
486     OnDemandEvent event;
487     collect->ReportEvent(event);
488     EXPECT_EQ(true, collect->collectHandler_ != nullptr);
489     PostTask(collect->collectHandler_);
490     collect->PostDelayTask(nullptr, -1);
491     collect->PostDelayTask(nullptr, std::numeric_limits<int32_t>::max());
492     event = { DEVICE_ONLINE, SA_TAG_DEVICE_ON_LINE, "on" };
493     collect->ReportEvent(event);
494     DTEST_LOG << " ReportEvent002 END" << std::endl;
495 }
496 
497 /**
498  * @tc.name: ReportEvent003
499  * @tc.desc: test ReportEvent, report success.
500  * @tc.type: FUNC
501  */
502 HWTEST_F(DeviceStatusCollectManagerTest, ReportEvent003, TestSize.Level3)
503 {
504     DTEST_LOG << " ReportEvent003 BEGIN" << std::endl;
505     std::list<SaProfile> saProfiles;
506     collect->Init(saProfiles);
507     OnDemandEvent event = { DEVICE_ONLINE, SA_TAG_DEVICE_ON_LINE, "on" };
508     std::list<SaControlInfo> saControlList;
509     SaProfile saProfile;
510     OnDemandEvent event1 = { DEVICE_ONLINE, SA_TAG_DEVICE_ON_LINE, "on" };
511     OnDemandEvent event2 = { DEVICE_ONLINE, SA_TAG_DEVICE_ON_LINE, "off" };
512     saProfile.startOnDemand.onDemandEvents.emplace_back(event1);
513     saProfile.stopOnDemand.onDemandEvents.emplace_back(event2);
514     collect->onDemandSaProfiles_.emplace_back(saProfile);
515     collect->ReportEvent(event);
516     EXPECT_EQ(true, collect->collectHandler_ != nullptr);
517     PostTask(collect->collectHandler_);
518     DTEST_LOG << " ReportEvent003 END" << std::endl;
519 }
520 
521 /**
522  * @tc.name: AddCollectEvents001
523  * @tc.desc: test AddCollectEvents, with events
524  * @tc.type: FUNC
525  * @tc.require: I6UUNW
526  */
527 HWTEST_F(DeviceStatusCollectManagerTest, AddCollectEvents001, TestSize.Level3)
528 {
529     DTEST_LOG << "AddCollectEvents001 begin" << std::endl;
530     std::vector<OnDemandEvent> events;
531     int32_t ret = collect->AddCollectEvents(events);
532     EXPECT_EQ(ret, ERR_OK);
533     DTEST_LOG << "AddCollectEvents001 end" << std::endl;
534 }
535 
536 /**
537  * @tc.name: AddCollectEvents002
538  * @tc.desc: test AddCollectEvents, with event wifi on
539  * @tc.type: FUNC
540  * @tc.require: I76X9Q
541  */
542 HWTEST_F(DeviceStatusCollectManagerTest, AddCollectEvents002, TestSize.Level3)
543 {
544     DTEST_LOG << "AddCollectEvents002 begin" << std::endl;
545     OnDemandEvent onDemandEvent = {SETTING_SWITCH, WIFI_NAME, "on"};
546     std::vector<OnDemandEvent> events {onDemandEvent};
547     int32_t ret = collect->AddCollectEvents(events);
548     EXPECT_EQ(ret, ERR_INVALID_VALUE);
549     DTEST_LOG << "AddCollectEvents002 end" << std::endl;
550 }
551 
552 /**
553  * @tc.name: AddCollectEvents003
554  * @tc.desc: test AddCollectEvents, with eventID is invalid
555  * @tc.type: FUNC
556  * @tc.require: I76X9Q
557  */
558 HWTEST_F(DeviceStatusCollectManagerTest, AddCollectEvents003, TestSize.Level3)
559 {
560     DTEST_LOG << "AddCollectEvents003 begin" << std::endl;
561     OnDemandEvent onDemandEvent = {-1, WIFI_NAME, "on"};
562     std::vector<OnDemandEvent> events {onDemandEvent};
563     int32_t ret = collect->AddCollectEvents(events);
564     EXPECT_EQ(ret, ERR_INVALID_VALUE);
565     DTEST_LOG << "AddCollectEvents003 end" << std::endl;
566 }
567 
568 /**
569  * @tc.name: GetOnDemandEvents001
570  * @tc.desc: test GetOnDemandEvents, systemAbilityId is invalid, OnDemandPolicyType is START_POLICY
571  * @tc.type: FUNC
572  * @tc.require: I6UUNW
573  */
574 HWTEST_F(DeviceStatusCollectManagerTest, GetOnDemandEvents001, TestSize.Level3)
575 {
576     DTEST_LOG << "GetOnDemandEvents001 begin" << std::endl;
577     int32_t systemAbilityId = -1;
578     OnDemandPolicyType type = OnDemandPolicyType::START_POLICY;
579     std::vector<OnDemandEvent> events;
580     int32_t ret = collect->GetOnDemandEvents(systemAbilityId, type, events);
581     EXPECT_EQ(ret, ERR_INVALID_VALUE);
582     DTEST_LOG << "GetOnDemandEvents001 end" << std::endl;
583 }
584 
585 /**
586  * @tc.name: GetOnDemandEvents002
587  * @tc.desc: test GetOnDemandEvents, systemAbilityId is valid, OnDemandPolicyType is STOP_POLICY
588  * @tc.type: FUNC
589  * @tc.require: I6UUNW
590  */
591 HWTEST_F(DeviceStatusCollectManagerTest, GetOnDemandEvents002, TestSize.Level3)
592 {
593     DTEST_LOG << "GetOnDemandEvents002 begin" << std::endl;
594     int32_t systemAbilityId = 0;
595     OnDemandPolicyType type = OnDemandPolicyType::STOP_POLICY;
596     std::vector<OnDemandEvent> events;
597     int32_t ret = collect->GetOnDemandEvents(systemAbilityId, type, events);
598     EXPECT_EQ(ret, ERR_INVALID_VALUE);
599     DTEST_LOG << "GetOnDemandEvents002 end" << std::endl;
600 }
601 
602 /**
603  * @tc.name: GetOnDemandEvents003
604  * @tc.desc: test GetOnDemandEvents, with event wifi on, OnDemandPolicyType is STOP_POLICY
605  * @tc.type: FUNC
606  * @tc.require: I76X9Q
607  */
608 HWTEST_F(DeviceStatusCollectManagerTest, GetOnDemandEvents003, TestSize.Level3)
609 {
610     DTEST_LOG << "GetOnDemandEvents003 begin" << std::endl;
611     int32_t systemAbilityId = 123;
612     OnDemandPolicyType type = OnDemandPolicyType::STOP_POLICY;
613     OnDemandEvent onDemandEvent = {SETTING_SWITCH, WIFI_NAME, "on"};
614     SaProfile saprofile = {u"test", systemAbilityId};
615     collect->onDemandSaProfiles_.push_back(saprofile);
616     std::vector<OnDemandEvent> events {onDemandEvent};
617     int32_t ret = collect->GetOnDemandEvents(systemAbilityId, type, events);
618     EXPECT_EQ(ret, ERR_OK);
619     DTEST_LOG << "GetOnDemandEvents003 end" << std::endl;
620 }
621 
622 /**
623  * @tc.name: GetOnDemandEvents004
624  * @tc.desc: test GetOnDemandEvents, with event wifi on, OnDemandPolicyType is START_POLICY
625  * @tc.type: FUNC
626  * @tc.require: I76X9Q
627  */
628 HWTEST_F(DeviceStatusCollectManagerTest, GetOnDemandEvents004, TestSize.Level3)
629 {
630     DTEST_LOG << "GetOnDemandEvents004 begin" << std::endl;
631     int32_t systemAbilityId = 123;
632     OnDemandPolicyType type = OnDemandPolicyType::START_POLICY;
633     OnDemandEvent onDemandEvent = {SETTING_SWITCH, WIFI_NAME, "on"};
634     SaProfile saprofile = {u"test", systemAbilityId};
635     collect->onDemandSaProfiles_.push_back(saprofile);
636     std::vector<OnDemandEvent> events {onDemandEvent};
637     int32_t ret = collect->GetOnDemandEvents(systemAbilityId, type, events);
638     EXPECT_EQ(ret, ERR_OK);
639     DTEST_LOG << "GetOnDemandEvents004 end" << std::endl;
640 }
641 
642 /**
643  * @tc.name: GetOnDemandEvents005
644  * @tc.desc: test GetOnDemandEvents, with event wifi on, OnDemandPolicyType is invalid
645  * @tc.type: FUNC
646  * @tc.require: I76X9Q
647  */
648 HWTEST_F(DeviceStatusCollectManagerTest, GetOnDemandEvents005, TestSize.Level3)
649 {
650     DTEST_LOG << "GetOnDemandEvents005 begin" << std::endl;
651     int32_t systemAbilityId = 123;
652     OnDemandPolicyType invalidType = (OnDemandPolicyType)2;
653     OnDemandEvent onDemandEvent = {SETTING_SWITCH, WIFI_NAME, "on"};
654     std::vector<OnDemandEvent> events {onDemandEvent};
655     int32_t ret = collect->GetOnDemandEvents(systemAbilityId, invalidType, events);
656     EXPECT_EQ(ret, ERR_INVALID_VALUE);
657     DTEST_LOG << "GetOnDemandEvents005 end" << std::endl;
658 }
659 
660 /**
661  * @tc.name: UpdateOnDemandEvents001
662  * @tc.desc: test UpdateOnDemandEvents, systemAbilityId is invalid, OnDemandPolicyType is START_POLICY
663  * @tc.type: FUNC
664  * @tc.require: I6UUNW
665  */
666 HWTEST_F(DeviceStatusCollectManagerTest, UpdateOnDemandEvents001, TestSize.Level3)
667 {
668     DTEST_LOG << "UpdateOnDemandEvents001 begin" << std::endl;
669     int32_t systemAbilityId = -1;
670     OnDemandPolicyType type = OnDemandPolicyType::START_POLICY;
671     std::vector<OnDemandEvent> events;
672     int32_t ret = collect->UpdateOnDemandEvents(systemAbilityId, type, events);
673     EXPECT_EQ(ret, ERR_INVALID_VALUE);
674     DTEST_LOG << "UpdateOnDemandEvents001 end" << std::endl;
675 }
676 
677 /**
678  * @tc.name: UpdateOnDemandEvents002
679  * @tc.desc: test UpdateOnDemandEvents, systemAbilityId is valid, OnDemandPolicyType is STOP_POLICY
680  * @tc.type: FUNC
681  * @tc.require: I6UUNW
682  */
683 HWTEST_F(DeviceStatusCollectManagerTest, UpdateOnDemandEvents002, TestSize.Level3)
684 {
685     DTEST_LOG << "UpdateOnDemandEvents002 begin" << std::endl;
686     int32_t systemAbilityId = 0;
687     OnDemandPolicyType type = OnDemandPolicyType::STOP_POLICY;
688     std::vector<OnDemandEvent> events;
689     int32_t ret = collect->UpdateOnDemandEvents(systemAbilityId, type, events);
690     EXPECT_EQ(ret, ERR_INVALID_VALUE);
691     DTEST_LOG << "UpdateOnDemandEvents002 end" << std::endl;
692 }
693 
694 /**
695  * @tc.name: UpdateOnDemandEvents003
696  * @tc.desc: test UpdateOnDemandEvents, with event wifi on
697  * @tc.type: FUNC
698  * @tc.require: I76X9Q
699  */
700 HWTEST_F(DeviceStatusCollectManagerTest, UpdateOnDemandEvents003, TestSize.Level3)
701 {
702     DTEST_LOG << "UpdateOnDemandEvents003 begin" << std::endl;
703     int32_t systemAbilityId = 123;
704     OnDemandPolicyType type = OnDemandPolicyType::STOP_POLICY;
705     OnDemandEvent onDemandEvent = {SETTING_SWITCH, WIFI_NAME, "on"};
706     SaProfile saprofile = {u"test", systemAbilityId};
707     collect->onDemandSaProfiles_.push_back(saprofile);
708     std::vector<OnDemandEvent> events {onDemandEvent};
709     int32_t ret = collect->UpdateOnDemandEvents(systemAbilityId, type, events);
710     EXPECT_EQ(ret, ERR_INVALID_VALUE);
711     DTEST_LOG << "UpdateOnDemandEvents003 end" << std::endl;
712 }
713 
714 /**
715  * @tc.name: GetOnDemandReasonExtraData001
716  * @tc.desc: test GetOnDemandReasonExtraData with COMMON_EVENT is not in collectPluginMap_
717  * @tc.type: FUNC
718  * @tc.require: I6W735
719  */
720 HWTEST_F(DeviceStatusCollectManagerTest, GetOnDemandReasonExtraData001, TestSize.Level3)
721 {
722     collect->collectPluginMap_.clear();
723     OnDemandReasonExtraData onDemandReasonExtraData;
724     int32_t ret = collect->GetOnDemandReasonExtraData(EXTRA_ID, onDemandReasonExtraData);
725     EXPECT_EQ(ret, ERR_INVALID_VALUE);
726 }
727 
728 /**
729  * @tc.name: GetOnDemandReasonExtraData002
730  * @tc.desc: test GetOnDemandReasonExtraData with collectPluginMap_[COMMON_EVENT] is nullptr
731  * @tc.type: FUNC
732  * @tc.require: I6W735
733  */
734 HWTEST_F(DeviceStatusCollectManagerTest, GetOnDemandReasonExtraData002, TestSize.Level3)
735 {
736     collect->collectPluginMap_.clear();
737     collect->collectPluginMap_[COMMON_EVENT] = nullptr;
738     OnDemandReasonExtraData onDemandReasonExtraData;
739     int32_t ret = collect->GetOnDemandReasonExtraData(EXTRA_ID, onDemandReasonExtraData);
740     EXPECT_EQ(ret, ERR_INVALID_VALUE);
741 }
742 
743 /**
744  * @tc.name: GetOnDemandReasonExtraData003
745  * @tc.desc: test GetOnDemandReasonExtraData with collectPluginMap_[COMMON_EVENT]'s extraDataId is not correct
746  * @tc.type: FUNC
747  * @tc.require: I6W735
748  */
749 HWTEST_F(DeviceStatusCollectManagerTest, GetOnDemandReasonExtraData003, TestSize.Level3)
750 {
751     sptr<CommonEventCollect> commonEventCollect = new CommonEventCollect(nullptr);
752     collect->collectPluginMap_.clear();
753     collect->collectPluginMap_[COMMON_EVENT] = commonEventCollect;
754     OnDemandReasonExtraData onDemandReasonExtraData;
755     int32_t ret = collect->GetOnDemandReasonExtraData(EXTRA_ID, onDemandReasonExtraData);
756     EXPECT_EQ(ret, ERR_INVALID_VALUE);
757 }
758 
759 /**
760  * @tc.name: GetOnDemandReasonExtraData004
761  * @tc.desc: test GetOnDemandReasonExtraData, get extraData
762  * @tc.type: FUNC
763  * @tc.require: I6W735
764  */
765 HWTEST_F(DeviceStatusCollectManagerTest, GetOnDemandReasonExtraData004, TestSize.Level3)
766 {
767     sptr<CommonEventCollect> commonEventCollect = new CommonEventCollect(nullptr);
768     commonEventCollect->workHandler_ = std::make_shared<CommonHandler>(commonEventCollect);
769     EventFwk::CommonEventData eventData;
770     commonEventCollect->SaveOnDemandReasonExtraData(eventData);
771     collect->collectPluginMap_.clear();
772     collect->collectPluginMap_[COMMON_EVENT] = commonEventCollect;
773     OnDemandReasonExtraData onDemandReasonExtraData;
774     int32_t ret = collect->GetOnDemandReasonExtraData(EXTRA_ID, onDemandReasonExtraData);
775     EXPECT_EQ(ret, ERR_OK);
776 }
777 
778 /**
779  * @tc.name: AddCollectEvents004
780  * @tc.desc: test AddCollectEvents with nullptr
781  * @tc.type: FUNC
782  * @tc.require: I7FBV6
783  */
784 HWTEST_F(DeviceStatusCollectManagerTest, AddCollectEvents004, TestSize.Level3)
785 {
786     collect->collectPluginMap_[SETTING_SWITCH] = nullptr;
787     OnDemandEvent onDemandEvent = { SETTING_SWITCH, WIFI_NAME, "on" };
788     std::vector<OnDemandEvent> events {onDemandEvent};
789     int32_t ret = collect->AddCollectEvents(events);
790     EXPECT_EQ(ret, ERR_INVALID_VALUE);
791 }
792 
793 /**
794  * @tc.name: AddCollectEvents005
795  * @tc.desc: test AddCollectEvents with invalid event name
796  * @tc.type: FUNC
797  * @tc.require: I7FBV6
798  */
799 HWTEST_F(DeviceStatusCollectManagerTest, AddCollectEvents005, TestSize.Level3)
800 {
801     sptr<DeviceSwitchCollect> deviceSwitchCollect =
802         new DeviceSwitchCollect(collect);
803     collect->collectPluginMap_[SETTING_SWITCH] = deviceSwitchCollect;
804     OnDemandEvent onDemandEvent = { SETTING_SWITCH, "test", "on" };
805     std::vector<OnDemandEvent> events {onDemandEvent};
806     int32_t ret = collect->AddCollectEvents(events);
807     EXPECT_EQ(ret, ERR_INVALID_VALUE);
808 }
809 
810 /**
811  * @tc.name: RemoveUnusedEventsLocked001
812  * @tc.desc: test RemoveUnusedEventsLocked, with events is empty
813  * @tc.type: FUNC
814  * @tc.require: I7VZ98
815  */
816 HWTEST_F(DeviceStatusCollectManagerTest, RemoveUnusedEventsLocked001, TestSize.Level3)
817 {
818     std::vector<OnDemandEvent> events;
819     int32_t ret = collect->RemoveUnusedEventsLocked(events);
820     EXPECT_EQ(ret, ERR_OK);
821 }
822 
823 /**
824  * @tc.name: RemoveUnusedEventsLocked002
825  * @tc.desc: test RemoveUnusedEventsLocked, with event not in collectPluginMap_
826  * @tc.type: FUNC
827  * @tc.require: I7VZ98
828  */
829 HWTEST_F(DeviceStatusCollectManagerTest, RemoveUnusedEventsLocked002, TestSize.Level3)
830 {
831     OnDemandEvent onDemandEvent = {-1, WIFI_NAME, "on"};
832     std::vector<OnDemandEvent> events {onDemandEvent};
833     int32_t ret = collect->RemoveUnusedEventsLocked(events);
834     EXPECT_EQ(ret, ERR_OK);
835 }
836 
837 /**
838  * @tc.name: RemoveUnusedEventsLocked003
839  * @tc.desc: test RemoveUnusedEventsLocked with nullptr
840  * @tc.type: FUNC
841  * @tc.require: I7VZ98
842  */
843 HWTEST_F(DeviceStatusCollectManagerTest, RemoveUnusedEventsLocked003, TestSize.Level3)
844 {
845     collect->collectPluginMap_[SETTING_SWITCH] = nullptr;
846     OnDemandEvent onDemandEvent = { SETTING_SWITCH, WIFI_NAME, "on" };
847     std::vector<OnDemandEvent> events {onDemandEvent};
848     int32_t ret = collect->RemoveUnusedEventsLocked(events);
849     EXPECT_EQ(ret, ERR_OK);
850 }
851 
852 /**
853  * @tc.name: RemoveUnusedEventsLocked004
854  * @tc.desc: test RemoveUnusedEventsLocked with eventUsed is false
855  * @tc.type: FUNC
856  * @tc.require: I7VZ98
857  */
858 HWTEST_F(DeviceStatusCollectManagerTest, RemoveUnusedEventsLocked004, TestSize.Level3)
859 {
860     sptr<DeviceSwitchCollect> deviceSwitchCollect =
861         new DeviceSwitchCollect(collect);
862     collect->collectPluginMap_[SETTING_SWITCH] = deviceSwitchCollect;
863     OnDemandEvent onDemandEvent = { SETTING_SWITCH, "test", "on" };
864     std::vector<OnDemandEvent> events {onDemandEvent};
865     int32_t ret = collect->RemoveUnusedEventsLocked(events);
866     EXPECT_EQ(ret, ERR_OK);
867 }
868 
869 /**
870  * @tc.name: TypeAndSaidToString001
871  * @tc.desc: test TypeAndSaidToString
872  * @tc.type: FUNC
873  * @tc.require: I7VZ98
874  */
875 HWTEST_F(DeviceStatusCollectManagerTest, TypeAndSaidToString001, TestSize.Level3)
876 {
877     OnDemandPolicyType type = OnDemandPolicyType::START_POLICY;
878     std::string str = collect->TypeAndSaidToString(type, 1);
879     EXPECT_EQ(str, "start#1#");
880 
881     type = OnDemandPolicyType::STOP_POLICY;
882     str = collect->TypeAndSaidToString(type, 1);
883     EXPECT_EQ(str, "stop#1#");
884 }
885 
886 /**
887  * @tc.name: StringToTypeAndSaid001
888  * @tc.desc: test StringToTypeAndSaid
889  * @tc.type: FUNC
890  * @tc.require: I7VZ98
891  */
892 HWTEST_F(DeviceStatusCollectManagerTest, StringToTypeAndSaid001, TestSize.Level3)
893 {
894     OnDemandPolicyType type = OnDemandPolicyType::START_POLICY;
895     int32_t said = 0;
896     collect->StringToTypeAndSaid("start#1#", type, said);
897     EXPECT_EQ(type, OnDemandPolicyType::START_POLICY);
898     EXPECT_EQ(said, 1);
899 
900     said = 0;
901     collect->StringToTypeAndSaid("stop#1#", type, said);
902     EXPECT_EQ(type, OnDemandPolicyType::STOP_POLICY);
903     EXPECT_EQ(said, 1);
904 
905     said = 0;
906     collect->StringToTypeAndSaid("test#1#", type, said);
907     EXPECT_EQ(said, 0);
908 
909     said = 0;
910     collect->StringToTypeAndSaid("start#", type, said);
911     EXPECT_EQ(said, 0);
912 }
913 
914 /**
915  * @tc.name: NeedPersistOnDemandEvent001
916  * @tc.desc: test NeedPersistOnDemandEvent
917  * @tc.type: FUNC
918  * @tc.require: I7VZ98
919  */
920 HWTEST_F(DeviceStatusCollectManagerTest, NeedPersistOnDemandEvent001, TestSize.Level3)
921 {
922     OnDemandEvent onDemandEvent = { SETTING_SWITCH, "test", "on" };
923     bool ret = collect->NeedPersistOnDemandEvent(onDemandEvent);
924     EXPECT_EQ(ret, false);
925 
926     onDemandEvent.eventId = TIMED_EVENT;
927     onDemandEvent.name = "test";
928     ret = collect->NeedPersistOnDemandEvent(onDemandEvent);
929     EXPECT_EQ(ret, false);
930 
931     onDemandEvent.eventId = TIMED_EVENT;
932     onDemandEvent.name = "timedevent";
933     onDemandEvent.persistence = false;
934     ret = collect->NeedPersistOnDemandEvent(onDemandEvent);
935     EXPECT_EQ(ret, false);
936 
937     onDemandEvent.persistence = true;
938     ret = collect->NeedPersistOnDemandEvent(onDemandEvent);
939     EXPECT_EQ(ret, true);
940 }
941 
942 /**
943  * @tc.name: IsSameEventName001
944  * @tc.desc: test IsSameEventName with event1 and event2 is the same
945  * @tc.type: FUNC
946  * @tc.require: I7VZ98
947  */
948 HWTEST_F(DeviceStatusCollectManagerTest, IsSameEventName001, TestSize.Level3)
949 {
950     OnDemandEvent event1 = { SETTING_SWITCH, "test", "on" };
951     OnDemandEvent event2 = { SETTING_SWITCH, "test", "off" };
952     bool ret = collect->IsSameEventName(event1, event2);
953     EXPECT_EQ(ret, true);
954 }
955 
956 /**
957  * @tc.name: IsSameEventName002
958  * @tc.desc: test IsSameEventName with event1 and event2 is not the same
959  * @tc.type: FUNC
960  * @tc.require: I7VZ98
961  */
962 HWTEST_F(DeviceStatusCollectManagerTest, IsSameEventName002, TestSize.Level3)
963 {
964     OnDemandEvent event1 = { SETTING_SWITCH, "test", "on" };
965     OnDemandEvent event2 = { SETTING_SWITCH, "test1", "off" };
966     bool ret = collect->IsSameEventName(event1, event2);
967     EXPECT_EQ(ret, false);
968 }
969 
970 /**
971  * @tc.name: IsSameEventName003
972  * @tc.desc: test IsSameEventName with event1 and event2 is the same
973  * @tc.type: FUNC
974  * @tc.require: I7VZ98
975  */
976 HWTEST_F(DeviceStatusCollectManagerTest, IsSameEventName003, TestSize.Level3)
977 {
978     OnDemandEvent event1 = { TIMED_EVENT, "loopevent", "60" };
979     OnDemandEvent event2 = { TIMED_EVENT, "loopevent", "60" };
980     bool ret = collect->IsSameEventName(event1, event2);
981     EXPECT_EQ(ret, true);
982 }
983 
984 /**
985  * @tc.name: IsSameEventName004
986  * @tc.desc: test IsSameEventName with event1 and event2 is not the same
987  * @tc.type: FUNC
988  * @tc.require: I7VZ98
989  */
990 HWTEST_F(DeviceStatusCollectManagerTest, IsSameEventName004, TestSize.Level3)
991 {
992     OnDemandEvent event1 = { TIMED_EVENT, "loopevent", "60" };
993     OnDemandEvent event2 = { TIMED_EVENT, "loopevent", "30" };
994     bool ret = collect->IsSameEventName(event1, event2);
995     EXPECT_EQ(ret, false);
996 }
997 
998 /**
999  * @tc.name: CheckEventUsedLocked001
1000  * @tc.desc: test CheckEventUsedLocked with event exist
1001  * @tc.require: I7VZ98
1002  */
1003 HWTEST_F(DeviceStatusCollectManagerTest, CheckEventUsedLocked001, TestSize.Level3)
1004 {
1005     SaProfile saProfile;
1006     OnDemandEvent event1 = { DEVICE_ONLINE, SA_TAG_DEVICE_ON_LINE, "on" };
1007     OnDemandEvent event2 = { DEVICE_ONLINE, SA_TAG_DEVICE_ON_LINE, "off" };
1008     saProfile.startOnDemand.onDemandEvents.emplace_back(event1);
1009     saProfile.stopOnDemand.onDemandEvents.emplace_back(event2);
1010     collect->onDemandSaProfiles_.emplace_back(saProfile);
1011     bool ret = collect->CheckEventUsedLocked(event1);
1012     EXPECT_EQ(ret, true);
1013 }
1014 
1015 /**
1016  * @tc.name: CheckEventUsedLocked002
1017  * @tc.desc: test CheckEventUsedLocked with onDemandSaProfiles_ is empty
1018  * @tc.require: I7VZ98
1019  */
1020 HWTEST_F(DeviceStatusCollectManagerTest, CheckEventUsedLocked002, TestSize.Level3)
1021 {
1022     collect->onDemandSaProfiles_.clear();
1023     OnDemandEvent event1 = { DEVICE_ONLINE, SA_TAG_DEVICE_ON_LINE, "on" };
1024     bool ret = collect->CheckEventUsedLocked(event1);
1025     EXPECT_EQ(ret, false);
1026 }
1027 } // namespace OHOS
1028