• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 #include "common_event_subscribe_info.h"
16 
17 #include "testConfigParser.h"
18 
19 #include <gtest/gtest.h>
20 
21 using namespace testing::ext;
22 
23 namespace OHOS {
24 namespace EventFwk {
25 namespace {
26 const int32_t PRIORITYTEST1 = 1;
27 const int32_t PRIORITYTEST2 = 2;
28 const int32_t PRIORITYTEST3 = 0;
29 const int32_t PRIORITYTEST4 = -1;
30 const int32_t PRIORITYTEST5 = -2;
31 
32 const std::string PERMISSIONTEST1 = "permissiontest1";
33 const std::string PERMISSIONTEST2 = "permissiontest2";
34 const std::string PERMISSIONTEST3 = "permissiontest3";
35 const std::string PERMISSIONTEST4 = "permissiontest4";
36 const std::string PERMISSIONTEST5 = "permissiontest5";
37 
38 const std::string DEVICEIDTEST1 = "deviceIdtest1";
39 const std::string DEVICEIDTEST2 = "deviceIdtest2";
40 const std::string DEVICEIDTEST3 = "deviceIdtest3";
41 const std::string DEVICEIDTEST4 = "deviceIdtest4";
42 const std::string DEVICEIDTEST5 = "deviceIdtest5";
43 }  // namespace
44 class ActsCESSubscribeInfoTest : public testing::Test {
45 public:
46     static void SetUpTestCase();
47     static void TearDownTestCase();
48     void SetUp();
49     void TearDown();
50     static StressTestLevel stLevel_;
51 };
52 StressTestLevel ActsCESSubscribeInfoTest::stLevel_{};
53 
SetUpTestCase()54 void ActsCESSubscribeInfoTest::SetUpTestCase()
55 {
56     TestConfigParser tcp;
57     tcp.ParseFromFile4StressTest(STRESS_TEST_CONFIG_FILE_PATH, stLevel_);
58     std::cout << "stress test level : "
59               << "AMS : " << stLevel_.AMSLevel << " "
60               << "BMS : " << stLevel_.BMSLevel << " "
61               << "CES : " << stLevel_.CESLevel << std::endl;
62 }
63 
TearDownTestCase()64 void ActsCESSubscribeInfoTest::TearDownTestCase()
65 {}
66 
SetUp()67 void ActsCESSubscribeInfoTest::SetUp()
68 {}
69 
TearDown()70 void ActsCESSubscribeInfoTest::TearDown()
71 {}
72 
73 /*
74  * @tc.number: CES_SubscribeInfo_Priority_0100
75  * @tc.name: SetPriority and GetPriority
76  * @tc.desc: Verify the function of  CommonEventSubscribeInfo: SetPriority and GetPriority
77  */
78 HWTEST_F(ActsCESSubscribeInfoTest, CES_SubscribeInfo_Priority_0100, Function | MediumTest | Level1)
79 {
80     bool result = false;
81     std::string eventName = "setPriorityTest1";
82     MatchingSkills matchingSkills;
83     for (int i = 1; i <= stLevel_.CESLevel; i++) {
84         matchingSkills.AddEvent(eventName);
85         CommonEventSubscribeInfo subscribeInfo(matchingSkills);
86         subscribeInfo.SetPriority(PRIORITYTEST1);
87         if (subscribeInfo.GetPriority() != PRIORITYTEST1) {
88             GTEST_LOG_(INFO) << "CES_SubscribeInfo_Priority_0100 failed ,frequency: " << i;
89             result = false;
90             break;
91         } else {
92             result = true;
93         }
94         matchingSkills.RemoveEvent(eventName);
95     }
96     if (result && stLevel_.CESLevel >= 1) {
97         GTEST_LOG_(INFO) << "CES_SubscribeInfo_Priority_0100 stress level: " << stLevel_.CESLevel;
98     }
99     EXPECT_TRUE(result);
100 }
101 
102 /*
103  * @tc.number: CES_SubscribeInfo_Priority_0200
104  * @tc.name: SetPriority and GetPriority
105  * @tc.desc: Verify the function of CommonEventSubscribeInfo by another event name: SetPriority and GetPriority
106  */
107 HWTEST_F(ActsCESSubscribeInfoTest, CES_SubscribeInfo_Priority_0200, Function | MediumTest | Level1)
108 {
109     bool result = false;
110     std::string eventName = "priorityTest2";
111     MatchingSkills matchingSkills;
112     for (int i = 1; i <= stLevel_.CESLevel; i++) {
113         matchingSkills.AddEvent(eventName);
114         CommonEventSubscribeInfo subscribeInfo(matchingSkills);
115         subscribeInfo.SetPriority(PRIORITYTEST2);
116         if (subscribeInfo.GetPriority() != PRIORITYTEST2) {
117             GTEST_LOG_(INFO) << "CES_SubscribeInfo_Priority_0200 failed ,frequency: " << i;
118             result = false;
119             break;
120         } else {
121             result = true;
122         }
123         matchingSkills.RemoveEvent(eventName);
124     }
125     if (result && stLevel_.CESLevel >= 1) {
126         GTEST_LOG_(INFO) << "CES_SubscribeInfo_Priority_0200 stress level: " << stLevel_.CESLevel;
127     }
128     EXPECT_TRUE(result);
129 }
130 
131 /*
132  * @tc.number: CES_SubscribeInfo_Priority_0300
133  * @tc.name: SetPriority and GetPriority
134  * @tc.desc: Verify the function of CommonEventSubscribeInfo by other event name: SetPriority and GetPriority
135  */
136 HWTEST_F(ActsCESSubscribeInfoTest, CES_SubscribeInfo_Priority_0300, Function | MediumTest | Level1)
137 {
138     bool result = false;
139     std::string eventName = "priorityTest3";
140     MatchingSkills matchingSkills;
141     for (int i = 1; i <= stLevel_.CESLevel; i++) {
142         matchingSkills.AddEvent(eventName);
143         CommonEventSubscribeInfo subscribeInfo(matchingSkills);
144         subscribeInfo.SetPriority(PRIORITYTEST3);
145         if (subscribeInfo.GetPriority() != PRIORITYTEST3) {
146             GTEST_LOG_(INFO) << "CES_SubscribeInfo_Priority_0300 failed ,frequency: " << i;
147             result = false;
148             break;
149         } else {
150             result = true;
151         }
152         matchingSkills.RemoveEvent(eventName);
153     }
154     if (result && stLevel_.CESLevel >= 1) {
155         GTEST_LOG_(INFO) << "CES_SubscribeInfo_Priority_0300 stress level: " << stLevel_.CESLevel;
156     }
157     EXPECT_TRUE(result);
158 }
159 
160 /*
161  * @tc.number: CES_SubscribeInfo_Priority_0400
162  * @tc.name: SetPriority and GetPriority
163  * @tc.desc: Verify the function of CommonEventSubscribeInfo by other event name: SetPriority and GetPriority
164  */
165 HWTEST_F(ActsCESSubscribeInfoTest, CES_SubscribeInfo_Priority_0400, Function | MediumTest | Level2)
166 {
167     bool result = false;
168     std::string eventName = "priorityTest4";
169     MatchingSkills matchingSkills;
170     for (int i = 1; i <= stLevel_.CESLevel; i++) {
171         matchingSkills.AddEvent(eventName);
172         CommonEventSubscribeInfo subscribeInfo(matchingSkills);
173         subscribeInfo.SetPriority(PRIORITYTEST4);
174         if (subscribeInfo.GetPriority() != PRIORITYTEST4) {
175             GTEST_LOG_(INFO) << "CES_SubscribeInfo_Priority_0400 failed ,frequency: " << i;
176             result = false;
177             break;
178         } else {
179             result = true;
180         }
181         matchingSkills.RemoveEvent(eventName);
182     }
183     if (result && stLevel_.CESLevel >= 1) {
184         GTEST_LOG_(INFO) << "CES_SubscribeInfo_Priority_0400 stress level: " << stLevel_.CESLevel;
185     }
186     EXPECT_TRUE(result);
187 }
188 
189 /*
190  * @tc.number: CES_SubscribeInfo_Priority_0500
191  * @tc.name: SetPriority and GetPriority
192  * @tc.desc: Verify the function of CommonEventSubscribeInfo by other event name: SetPriority and GetPriority
193  */
194 HWTEST_F(ActsCESSubscribeInfoTest, CES_SubscribeInfo_Priority_0500, Function | MediumTest | Level2)
195 {
196     bool result = false;
197     std::string eventName = "priorityTest5";
198     MatchingSkills matchingSkills;
199     for (int i = 1; i <= stLevel_.CESLevel; i++) {
200         matchingSkills.AddEvent(eventName);
201         CommonEventSubscribeInfo subscribeInfo(matchingSkills);
202         subscribeInfo.SetPriority(PRIORITYTEST5);
203         if (subscribeInfo.GetPriority() != PRIORITYTEST5) {
204             GTEST_LOG_(INFO) << "CES_SubscribeInfo_Priority_0500 failed ,frequency: " << i;
205             result = false;
206             break;
207         } else {
208             result = true;
209         }
210         matchingSkills.RemoveEvent(eventName);
211     }
212     if (result && stLevel_.CESLevel >= 1) {
213         GTEST_LOG_(INFO) << "CES_SubscribeInfo_Priority_0500 stress level: " << stLevel_.CESLevel;
214     }
215     EXPECT_TRUE(result);
216 }
217 
218 /*
219  * @tc.number: CES_SubscribeInfo_Permission_0100
220  * @tc.name: SetPermission and GetPermission
221  * @tc.desc: Verify the function of CommonEventSubscribeInfo: SetPermission and GetPermission
222  */
223 HWTEST_F(ActsCESSubscribeInfoTest, CES_SubscribeInfo_Permission_0100, Function | MediumTest | Level1)
224 {
225     bool result = false;
226     std::string eventName = "permissionTEST1";
227     MatchingSkills matchingSkills;
228     for (int i = 1; i <= stLevel_.CESLevel; i++) {
229         matchingSkills.AddEvent(eventName);
230         CommonEventSubscribeInfo subscribeInfo(matchingSkills);
231         subscribeInfo.SetPermission(PERMISSIONTEST1);
232         if (subscribeInfo.GetPermission() != PERMISSIONTEST1) {
233             GTEST_LOG_(INFO) << "CES_SubscribeInfo_Permission_0100 failed ,frequency: " << i;
234             result = false;
235             break;
236         } else {
237             result = true;
238         }
239         matchingSkills.RemoveEvent(eventName);
240     }
241     if (result && stLevel_.CESLevel >= 1) {
242         GTEST_LOG_(INFO) << "CES_SubscribeInfo_Permission_0100 stress level: " << stLevel_.CESLevel;
243     }
244     EXPECT_TRUE(result);
245 }
246 
247 /*
248  * @tc.number: CES_SubscribeInfo_Permission_0200
249  * @tc.name: SetPermission and GetPermission
250  * @tc.desc: Verify the function of CommonEventSubscribeInfo by another event name: SetPermission and
251  *                      GetPermission
252  */
253 HWTEST_F(ActsCESSubscribeInfoTest, CES_SubscribeInfo_Permission_0200, Function | MediumTest | Level1)
254 {
255     bool result = false;
256     std::string eventName = "permissionTEST2";
257     MatchingSkills matchingSkills;
258     for (int i = 1; i <= stLevel_.CESLevel; i++) {
259         matchingSkills.AddEvent(eventName);
260         CommonEventSubscribeInfo subscribeInfo(matchingSkills);
261         subscribeInfo.SetPermission(PERMISSIONTEST2);
262         if (subscribeInfo.GetPermission() != PERMISSIONTEST2) {
263             GTEST_LOG_(INFO) << "CES_SubscribeInfo_Permission_0200 failed ,frequency: " << i;
264             result = false;
265             break;
266         } else {
267             result = true;
268         }
269         matchingSkills.RemoveEvent(eventName);
270     }
271     if (result && stLevel_.CESLevel >= 1) {
272         GTEST_LOG_(INFO) << "CES_SubscribeInfo_Permission_0200 stress level: " << stLevel_.CESLevel;
273     }
274     EXPECT_TRUE(result);
275 }
276 
277 /*
278  * @tc.number: CES_SubscribeInfo_Permission_0300
279  * @tc.name: SetPermission and GetPermission
280  * @tc.desc: Verify the function of CommonEventSubscribeInfo by other event name: SetPermission and GetPermission
281  */
282 HWTEST_F(ActsCESSubscribeInfoTest, CES_SubscribeInfo_Permission_0300, Function | MediumTest | Level1)
283 {
284     bool result = false;
285     std::string eventName = "permissionTEST3";
286     MatchingSkills matchingSkills;
287     for (int i = 1; i <= stLevel_.CESLevel; i++) {
288         matchingSkills.AddEvent(eventName);
289         CommonEventSubscribeInfo subscribeInfo(matchingSkills);
290         subscribeInfo.SetPermission(PERMISSIONTEST3);
291         if (subscribeInfo.GetPermission() != PERMISSIONTEST3) {
292             GTEST_LOG_(INFO) << "CES_SubscribeInfo_Permission_0300 failed ,frequency: " << i;
293             result = false;
294             break;
295         } else {
296             result = true;
297         }
298         matchingSkills.RemoveEvent(eventName);
299     }
300     if (result && stLevel_.CESLevel >= 1) {
301         GTEST_LOG_(INFO) << "CES_SubscribeInfo_Permission_0300 stress level: " << stLevel_.CESLevel;
302     }
303     EXPECT_TRUE(result);
304 }
305 
306 /*
307  * @tc.number: CES_SubscribeInfo_Permission_0400
308  * @tc.name: SetPermission and GetPermission
309  * @tc.desc: Verify the function of CommonEventSubscribeInfo by other event name: SetPermission and GetPermission
310  */
311 HWTEST_F(ActsCESSubscribeInfoTest, CES_SubscribeInfo_Permission_0400, Function | MediumTest | Level1)
312 {
313     bool result = false;
314     std::string eventName = "permissionTEST4";
315     MatchingSkills matchingSkills;
316     for (int i = 1; i <= stLevel_.CESLevel; i++) {
317         matchingSkills.AddEvent(eventName);
318         CommonEventSubscribeInfo subscribeInfo(matchingSkills);
319         subscribeInfo.SetPermission(PERMISSIONTEST4);
320         if (subscribeInfo.GetPermission() != PERMISSIONTEST4) {
321             GTEST_LOG_(INFO) << "CES_SubscribeInfo_Permission_0400 failed ,frequency: " << i;
322             result = false;
323             break;
324         } else {
325             result = true;
326         }
327         matchingSkills.RemoveEvent(eventName);
328     }
329     if (result && stLevel_.CESLevel >= 1) {
330         GTEST_LOG_(INFO) << "CES_SubscribeInfo_Permission_0400 stress level: " << stLevel_.CESLevel;
331     }
332     EXPECT_TRUE(result);
333 }
334 
335 /*
336  * @tc.number: CES_SubscribeInfo_Permission_0500
337  * @tc.name: SetPermission and GetPermission
338  * @tc.desc: Verify the function of CommonEventSubscribeInfo by other event name: SetPermission and GetPermission
339  */
340 HWTEST_F(ActsCESSubscribeInfoTest, CES_SubscribeInfo_Permission_0500, Function | MediumTest | Level1)
341 {
342     bool result = false;
343     std::string eventName = "permissionTEST5";
344     MatchingSkills matchingSkills;
345     for (int i = 1; i <= stLevel_.CESLevel; i++) {
346         matchingSkills.AddEvent(eventName);
347         CommonEventSubscribeInfo subscribeInfo(matchingSkills);
348         subscribeInfo.SetPermission(PERMISSIONTEST5);
349         if (subscribeInfo.GetPermission() != PERMISSIONTEST5) {
350             GTEST_LOG_(INFO) << "CES_SubscribeInfo_Permission_0500 failed ,frequency: " << i;
351             result = false;
352             break;
353         } else {
354             result = true;
355         }
356         matchingSkills.RemoveEvent(eventName);
357     }
358     if (result && stLevel_.CESLevel >= 1) {
359         GTEST_LOG_(INFO) << "CES_SubscribeInfo_Permission_0500 stress level: " << stLevel_.CESLevel;
360     }
361     EXPECT_TRUE(result);
362 }
363 
364 /*
365  * @tc.number: CES_SubscribeInfo_ThreadMode_0100
366  * @tc.name: SetThreadMode and GetThreadMode of ThreadMode::HANDLER
367  * @tc.desc:  Verify the function of CommonEventSubscribeInfo: SetThreadMode and GetThreadMode of
368  *                       ThreadMode::HANDLER
369  */
370 HWTEST_F(ActsCESSubscribeInfoTest, CES_SubscribeInfo_ThreadMode_0100, Function | MediumTest | Level1)
371 {
372     bool result = false;
373     std::string eventName = "threadModeTESTHANDLER";
374     MatchingSkills matchingSkills;
375     for (int i = 1; i <= stLevel_.CESLevel; i++) {
376         matchingSkills.AddEvent(eventName);
377         CommonEventSubscribeInfo subscribeInfo(matchingSkills);
378         subscribeInfo.SetThreadMode(CommonEventSubscribeInfo::ThreadMode::HANDLER);
379         if (subscribeInfo.GetThreadMode() != CommonEventSubscribeInfo::ThreadMode::HANDLER) {
380             GTEST_LOG_(INFO) << "CES_SubscribeInfo_ThreadMode_0100 failed ,frequency: " << i;
381             result = false;
382             break;
383         } else {
384             result = true;
385         }
386         matchingSkills.RemoveEvent(eventName);
387     }
388     if (result && stLevel_.CESLevel >= 1) {
389         GTEST_LOG_(INFO) << "CES_SubscribeInfo_ThreadMode_0100 stress level: " << stLevel_.CESLevel;
390     }
391     EXPECT_TRUE(result);
392 }
393 
394 /*
395  * @tc.number: CES_SubscribeInfo_ThreadMode_0200
396  * @tc.name: SetThreadMode and GetThreadMode of ThreadMode::POST
397  * @tc.desc: Verify the function of CommonEventSubscribeInfo: SetThreadMode and GetThreadMode of ThreadMode::POST
398  */
399 HWTEST_F(ActsCESSubscribeInfoTest, CES_SubscribeInfo_ThreadMode_0200, Function | MediumTest | Level1)
400 {
401     bool result = false;
402     std::string eventName = "threadModeTESTPOST";
403     MatchingSkills matchingSkills;
404     for (int i = 1; i <= stLevel_.CESLevel; i++) {
405         matchingSkills.AddEvent(eventName);
406         CommonEventSubscribeInfo subscribeInfo(matchingSkills);
407         subscribeInfo.SetThreadMode(CommonEventSubscribeInfo::ThreadMode::POST);
408         if (subscribeInfo.GetThreadMode() != CommonEventSubscribeInfo::ThreadMode::POST) {
409             GTEST_LOG_(INFO) << "CES_SubscribeInfo_ThreadMode_0200 failed ,frequency: " << i;
410             result = false;
411             break;
412         } else {
413             result = true;
414         }
415         matchingSkills.RemoveEvent(eventName);
416     }
417     if (result && stLevel_.CESLevel >= 1) {
418         GTEST_LOG_(INFO) << "CES_SubscribeInfo_ThreadMode_0200 stress level: " << stLevel_.CESLevel;
419     }
420     EXPECT_TRUE(result);
421 }
422 
423 /*
424  * @tc.number: CES_SubscribeInfo_ThreadMode_0300
425  * @tc.name: SetThreadMode and GetThreadMode of ThreadMode::ASYNC
426  * @tc.desc: Verify the function of CommonEventSubscribeInfo: SetThreadMode and GetThreadMode of
427  *                      ThreadMode::ASYNC
428  */
429 HWTEST_F(ActsCESSubscribeInfoTest, CES_SubscribeInfo_ThreadMode_0300, Function | MediumTest | Level1)
430 {
431     bool result = false;
432     std::string eventName = "threadModeTESTASYNC";
433     MatchingSkills matchingSkills;
434     for (int i = 1; i <= stLevel_.CESLevel; i++) {
435         matchingSkills.AddEvent(eventName);
436         CommonEventSubscribeInfo subscribeInfo(matchingSkills);
437         subscribeInfo.SetThreadMode(CommonEventSubscribeInfo::ThreadMode::ASYNC);
438         if (subscribeInfo.GetThreadMode() != CommonEventSubscribeInfo::ThreadMode::ASYNC) {
439             GTEST_LOG_(INFO) << "CES_SubscribeInfo_ThreadMode_0300 failed ,frequency: " << i;
440             result = false;
441             break;
442         } else {
443             result = true;
444         }
445         matchingSkills.RemoveEvent(eventName);
446     }
447     if (result && stLevel_.CESLevel >= 1) {
448         GTEST_LOG_(INFO) << "CES_SubscribeInfo_ThreadMode_0300 stress level: " << stLevel_.CESLevel;
449     }
450     EXPECT_TRUE(result);
451 }
452 
453 /*
454  * @tc.number: CES_SubscribeInfo_ThreadMode_0400
455  * @tc.name: SetThreadMode and GetThreadMode of ThreadMode::BACKGROUND
456  * @tc.desc: Verify the function of CommonEventSubscribeInfo: SetThreadMode and GetThreadMode of
457  *                      ThreadMode::BACKGROUND
458  */
459 HWTEST_F(ActsCESSubscribeInfoTest, CES_SubscribeInfo_ThreadMode_0400, Function | MediumTest | Level1)
460 {
461     bool result = false;
462     std::string eventName = "threadModeTESTBACKGROUND";
463     MatchingSkills matchingSkills;
464     for (int i = 1; i <= stLevel_.CESLevel; i++) {
465         matchingSkills.AddEvent(eventName);
466         CommonEventSubscribeInfo subscribeInfo(matchingSkills);
467         subscribeInfo.SetThreadMode(CommonEventSubscribeInfo::ThreadMode::BACKGROUND);
468         if (subscribeInfo.GetThreadMode() != CommonEventSubscribeInfo::ThreadMode::BACKGROUND) {
469             GTEST_LOG_(INFO) << "CES_SubscribeInfo_ThreadMode_0400 failed ,frequency: " << i;
470             result = false;
471             break;
472         } else {
473             result = true;
474         }
475         matchingSkills.RemoveEvent(eventName);
476     }
477     if (result && stLevel_.CESLevel >= 1) {
478         GTEST_LOG_(INFO) << "CES_SubscribeInfo_ThreadMode_0400 stress level: " << stLevel_.CESLevel;
479     }
480     EXPECT_TRUE(result);
481 }
482 
483 /*
484  * @tc.number: CES_SubscribeInfo_DeviceId_0100
485  * @tc.name: SetDeviceId and GetDeviceId
486  * @tc.desc: Verify the function of CommonEventSubscribeInfo: SetDeviceId and GetDeviceId
487  */
488 HWTEST_F(ActsCESSubscribeInfoTest, CES_SubscribeInfo_DeviceId_0100, Function | MediumTest | Level1)
489 {
490     bool result = false;
491     std::string eventName = "deviceIdTEST1";
492     MatchingSkills matchingSkills;
493     for (int i = 1; i <= stLevel_.CESLevel; i++) {
494         matchingSkills.AddEvent(eventName);
495         CommonEventSubscribeInfo subscribeInfo(matchingSkills);
496         subscribeInfo.SetDeviceId(DEVICEIDTEST1);
497         if (subscribeInfo.GetDeviceId() != DEVICEIDTEST1) {
498             GTEST_LOG_(INFO) << "CES_SubscribeInfo_DeviceId_0100 failed ,frequency: " << i;
499             result = false;
500             break;
501         } else {
502             result = true;
503         }
504         matchingSkills.RemoveEvent(eventName);
505     }
506     if (result && stLevel_.CESLevel >= 1) {
507         GTEST_LOG_(INFO) << "CES_SubscribeInfo_DeviceId_0100 stress level: " << stLevel_.CESLevel;
508     }
509     EXPECT_TRUE(result);
510 }
511 
512 /*
513  * @tc.number: CES_SubscribeInfo_DeviceId_0200
514  * @tc.name: SetDeviceId and GetDeviceId
515  * @tc.desc: Verify the function of CommonEventSubscribeInfo by other event name: SetDeviceId and GetDeviceId
516  */
517 HWTEST_F(ActsCESSubscribeInfoTest, CES_SubscribeInfo_DeviceId_0200, Function | MediumTest | Level1)
518 {
519     bool result = false;
520     std::string eventName = "deviceIdTEST2";
521     MatchingSkills matchingSkills;
522     for (int i = 1; i <= stLevel_.CESLevel; i++) {
523         matchingSkills.AddEvent(eventName);
524         CommonEventSubscribeInfo subscribeInfo(matchingSkills);
525         subscribeInfo.SetDeviceId(DEVICEIDTEST2);
526         if (subscribeInfo.GetDeviceId() != DEVICEIDTEST2) {
527             GTEST_LOG_(INFO) << "CES_SubscribeInfo_DeviceId_0200 failed ,frequency: " << i;
528             result = false;
529             break;
530         } else {
531             result = true;
532         }
533         matchingSkills.RemoveEvent(eventName);
534     }
535     if (result && stLevel_.CESLevel >= 1) {
536         GTEST_LOG_(INFO) << "CES_SubscribeInfo_DeviceId_0200 stress level: " << stLevel_.CESLevel;
537     }
538     EXPECT_TRUE(result);
539 }
540 
541 /*
542  * @tc.number: CES_SubscribeInfo_DeviceId_0300
543  * @tc.name: SetDeviceId and GetDeviceId
544  * @tc.desc: Verify the function of CommonEventSubscribeInfo by other event name: SetDeviceId and GetDeviceId
545  */
546 HWTEST_F(ActsCESSubscribeInfoTest, CES_SubscribeInfo_DeviceId_0300, Function | MediumTest | Level1)
547 {
548     bool result = false;
549     std::string eventName = "deviceIdTEST3";
550     MatchingSkills matchingSkills;
551     for (int i = 1; i <= stLevel_.CESLevel; i++) {
552         matchingSkills.AddEvent(eventName);
553         CommonEventSubscribeInfo subscribeInfo(matchingSkills);
554         subscribeInfo.SetDeviceId(DEVICEIDTEST3);
555         if (subscribeInfo.GetDeviceId() != DEVICEIDTEST3) {
556             GTEST_LOG_(INFO) << "CES_SubscribeInfo_DeviceId_0300 failed ,frequency: " << i;
557             result = false;
558             break;
559         } else {
560             result = true;
561         }
562         matchingSkills.RemoveEvent(eventName);
563     }
564     if (result && stLevel_.CESLevel >= 1) {
565         GTEST_LOG_(INFO) << "CES_SubscribeInfo_DeviceId_0300 stress level: " << stLevel_.CESLevel;
566     }
567     EXPECT_TRUE(result);
568 }
569 
570 /*
571  * @tc.number: CES_SubscribeInfo_DeviceId_0400
572  * @tc.name: SetDeviceId and GetDeviceId
573  * @tc.desc: Verify the function of CommonEventSubscribeInfo by other event name: SetDeviceId and GetDeviceId
574  */
575 HWTEST_F(ActsCESSubscribeInfoTest, CES_SubscribeInfo_DeviceId_0400, Function | MediumTest | Level1)
576 {
577     bool result = false;
578     std::string eventName = "deviceIdTEST4";
579     MatchingSkills matchingSkills;
580     for (int i = 1; i <= stLevel_.CESLevel; i++) {
581         matchingSkills.AddEvent(eventName);
582         CommonEventSubscribeInfo subscribeInfo(matchingSkills);
583         subscribeInfo.SetDeviceId(DEVICEIDTEST4);
584         if (subscribeInfo.GetDeviceId() != DEVICEIDTEST4) {
585             GTEST_LOG_(INFO) << "CES_SubscribeInfo_DeviceId_0400 failed ,frequency: " << i;
586             result = false;
587             break;
588         } else {
589             result = true;
590         }
591         matchingSkills.RemoveEvent(eventName);
592     }
593     if (result && stLevel_.CESLevel >= 1) {
594         GTEST_LOG_(INFO) << "CES_SubscribeInfo_DeviceId_0400 stress level: " << stLevel_.CESLevel;
595     }
596     EXPECT_TRUE(result);
597 }
598 
599 /*
600  * @tc.number: CES_SubscribeInfo_DeviceId_0500
601  * @tc.name: SetDeviceId and GetDeviceId
602  * @tc.desc: Verify the function of CommonEventSubscribeInfo by other event name: SetDeviceId and GetDeviceId
603  */
604 HWTEST_F(ActsCESSubscribeInfoTest, CES_SubscribeInfo_DeviceId_0500, Function | MediumTest | Level1)
605 {
606     bool result = false;
607     std::string eventName = "deviceIdTEST5";
608     MatchingSkills matchingSkills;
609     for (int i = 1; i <= stLevel_.CESLevel; i++) {
610         matchingSkills.AddEvent(eventName);
611         CommonEventSubscribeInfo subscribeInfo(matchingSkills);
612         subscribeInfo.SetDeviceId(DEVICEIDTEST5);
613         if (subscribeInfo.GetDeviceId() != DEVICEIDTEST5) {
614             GTEST_LOG_(INFO) << "CES_SubscribeInfo_DeviceId_0500 failed ,frequency: " << i;
615             result = false;
616             break;
617         } else {
618             result = true;
619         }
620         matchingSkills.RemoveEvent(eventName);
621     }
622     if (result && stLevel_.CESLevel >= 1) {
623         GTEST_LOG_(INFO) << "CES_SubscribeInfo_DeviceId_0500 stress level: " << stLevel_.CESLevel;
624     }
625     EXPECT_TRUE(result);
626 }
627 
628 /*
629  * @tc.number: CES_SubscribeInfo_GetMatchingSkills_0100
630  * @tc.name: GetMatchingSkills
631  * @tc.desc: Verify the function of CommonEventSubscribeInfo: GetMatchingSkills
632  */
633 HWTEST_F(ActsCESSubscribeInfoTest, CES_SubscribeInfo_GetMatchingSkills_0100, Function | MediumTest | Level1)
634 {
635     bool result = false;
636     std::string eventName = "getMatchingSkills";
637     MatchingSkills matchingSkills;
638     for (int i = 1; i <= stLevel_.CESLevel; i++) {
639         matchingSkills.AddEvent(eventName);
640         CommonEventSubscribeInfo subscribeInfo(matchingSkills);
641         if (!subscribeInfo.GetMatchingSkills().HasEvent(eventName)) {
642             GTEST_LOG_(INFO) << "CES_SubscribeInfo_GetMatchingSkills_0100 failed ,frequency: " << i;
643             result = false;
644             break;
645         } else {
646             result = true;
647         }
648         matchingSkills.RemoveEvent(eventName);
649     }
650     if (result && stLevel_.CESLevel >= 1) {
651         GTEST_LOG_(INFO) << "CES_SubscribeInfo_GetMatchingSkills_0100 stress level: " << stLevel_.CESLevel;
652     }
653     EXPECT_TRUE(result);
654 }
655 }  // namespace EventFwk
656 }  // namespace OHOS