• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 #ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED
17 #include "gtest/gtest.h"
18 #define private public
19 #define protected public
20 #include "notification_preferences.h"
21 #include "smart_reminder_center.h"
22 #include "ans_inner_errors.h"
23 #undef private
24 #undef protected
25 
26 using namespace testing::ext;
27 namespace OHOS {
28 namespace Notification {
29 
30 class SmartReminderCenterTest : public testing::Test {
31 public:
SmartReminderCenterTest()32     SmartReminderCenterTest()
33     {}
~SmartReminderCenterTest()34     ~SmartReminderCenterTest()
35     {}
SetUpTestCas(void)36     static void SetUpTestCas(void) {};
TearDownTestCase(void)37     static void TearDownTestCase(void) {};
38     void SetUp();
TearDown()39     void TearDown() {};
40 public:
41     std::shared_ptr<SmartReminderCenter> smartReminderCenter_;
42 };
43 
SetUp(void)44 void SmartReminderCenterTest::SetUp(void)
45 {
46     smartReminderCenter_ = DelayedSingleton<SmartReminderCenter>::GetInstance();
47 }
48 
49 /**
50  * @tc.name: Test IsNeedSynergy
51  * @tc.desc: Test IsNeedSynergy
52  * @tc.type: FUNC
53  */
54 HWTEST_F(SmartReminderCenterTest, IsNeedSynergy_00001, Function | SmallTest | Level1)
55 {
56     NotificationConstant::SlotType slotType = NotificationConstant::SlotType::SOCIAL_COMMUNICATION;
57     string deviceType = "test";
58     string ownerBundleName = "testName";
59     int32_t ownerUid = 100;
60 
61     auto res = smartReminderCenter_->IsNeedSynergy(slotType, deviceType, ownerBundleName, ownerUid);
62     ASSERT_FALSE(res);
63 
64     auto err = NotificationPreferences::GetInstance()->SetSmartReminderEnabled(deviceType, true);
65     ASSERT_EQ(err, ERR_OK);
66     res = smartReminderCenter_->IsNeedSynergy(slotType, deviceType, ownerBundleName, ownerUid);
67     ASSERT_FALSE(res);
68 
69     err = NotificationPreferences::GetInstance()->SetSmartReminderEnabled(deviceType, true);
70     ASSERT_EQ(err, ERR_OK);
71     res = smartReminderCenter_->IsNeedSynergy(slotType, deviceType, ownerBundleName, ownerUid);
72     ASSERT_FALSE(res);
73 
74     sptr<NotificationBundleOption> bundleOption(new NotificationBundleOption(ownerBundleName, ownerUid));
75     err = NotificationPreferences::GetInstance()->SetDistributedEnabledByBundle(bundleOption, deviceType, true);
76     ASSERT_EQ(err, ERR_OK);
77     res = smartReminderCenter_->IsNeedSynergy(slotType, deviceType, ownerBundleName, ownerUid);
78     ASSERT_TRUE(res);
79 }
80 
81 /**
82  * @tc.name: Test HandleAffectedReminder
83  * @tc.desc: Test HandleAffectedReminder
84  * @tc.type: FUNC
85  */
86 HWTEST_F(SmartReminderCenterTest, HandleAffectedReminder_00001, Function | SmallTest | Level1)
87 {
88     string deviceType = "test";
89     shared_ptr<ReminderAffected> reminderAffected = make_shared<ReminderAffected>();
90     std::vector<std::pair<std::string, std::string>> affectedBy;
91     auto affectedByOne = std::make_pair("test", "0000");
92     affectedBy.push_back(affectedByOne);
93     reminderAffected->affectedBy_ = affectedBy;
94     reminderAffected->reminderFlags_ = make_shared<NotificationFlags>();
95 
96     set<string> validDevices;
97     validDevices.insert("test");
98 
99     shared_ptr<map<string, shared_ptr<NotificationFlags>>> notificationFlagsOfDevices =
100         make_shared<map<string, shared_ptr<NotificationFlags>>>();
101 
102     map<string, bitset<DistributedDeviceStatus::STATUS_SIZE>> statusMap;
103     statusMap.insert(pair<string,
104         bitset<DistributedDeviceStatus::STATUS_SIZE>>("test", bitset<DistributedDeviceStatus::STATUS_SIZE>(0)));
105 
106     auto res = smartReminderCenter_->HandleAffectedReminder(
107         deviceType, reminderAffected, validDevices,
108         statusMap,  notificationFlagsOfDevices);
109     ASSERT_TRUE(res);
110 
111     auto affectedByTwo = std::make_pair("test111", "1111");
112     affectedBy.push_back(affectedByTwo);
113     reminderAffected->affectedBy_ = affectedBy;
114     res = smartReminderCenter_->HandleAffectedReminder(
115         deviceType, reminderAffected, validDevices,
116         statusMap,  notificationFlagsOfDevices);
117     ASSERT_FALSE(res);
118 }
119 
120 /**
121  * @tc.name: Test IsCollaborationAllowed
122  * @tc.desc: Test IsCollaborationAllowed
123  * @tc.type: FUNC
124  */
125 HWTEST_F(SmartReminderCenterTest, IsCollaborationAllowed_00001, Function | SmallTest | Level1)
126 {
127     sptr<NotificationRequest> request(new NotificationRequest(1));
128     auto res = smartReminderCenter_->IsCollaborationAllowed(request);
129     ASSERT_TRUE(res);
130 
131     request->SetIsSystemApp(true);
132     request->SetNotDistributed(true);
133     res = smartReminderCenter_->IsCollaborationAllowed(request);
134     ASSERT_FALSE(res);
135 
136     request->SetNotDistributed(false);
137     request->SetForceDistributed(true);
138     res = smartReminderCenter_->IsCollaborationAllowed(request);
139     ASSERT_TRUE(res);
140 
141     request->SetForceDistributed(false);
142     res = smartReminderCenter_->IsCollaborationAllowed(request);
143     ASSERT_TRUE(res);
144 }
145 
146 /**
147  * @tc.name: Test ReminderDecisionProcess
148  * @tc.desc: Test ReminderDecisionProcess
149  * @tc.type: FUNC
150  */
151 HWTEST_F(SmartReminderCenterTest, ReminderDecisionProcess_00001, Function | SmallTest | Level1)
152 {
153     sptr<NotificationRequest> request(new NotificationRequest(1));
154     request->SetIsSystemApp(true);
155     request->SetNotDistributed(true);
156     auto deviceFlags = request->GetDeviceFlags();
157     ASSERT_EQ(deviceFlags, nullptr);
158 
159     smartReminderCenter_->ReminderDecisionProcess(request);
160     deviceFlags = request->GetDeviceFlags();
161     ASSERT_NE(deviceFlags, nullptr);
162 }
163 
164 /**
165  * @tc.name: Test ReminderDecisionProcess
166  * @tc.desc: Test ReminderDecisionProcess
167  * @tc.type: FUNC
168  */
169 HWTEST_F(SmartReminderCenterTest, InitValidDevices_00001, Function | SmallTest | Level1)
170 {
171     // need subscriber
172     sptr<NotificationRequest> request(new NotificationRequest(1));
173     request->SetSlotType(NotificationConstant::SlotType::LIVE_VIEW);
174 
175     set<string> validDevices;
176     set<string> smartDevices;
177     map<string, bitset<DistributedDeviceStatus::STATUS_SIZE>> statusMap;
178     NotificationPreferences::GetInstance()->SetDistributedEnabledBySlot(
179                 request->GetSlotType(), "headset", true);
180     smartReminderCenter_->InitValidDevices(validDevices, smartDevices, statusMap,  request);
181     ASSERT_EQ(request->GetNotificationControlFlags(), 0);
182 }
183 
184 /**
185  * @tc.name: Test ReminderDecisionProcess
186  * @tc.desc: Test ReminderDecisionProcess
187  * @tc.type: FUNC
188  */
189 HWTEST_F(SmartReminderCenterTest, InitValidDevices_00002, Function | SmallTest | Level1)
190 {
191     // need subscriber
192     std::string ownerBundleName = "test";
193     int32_t ownerUid = 100;
194     sptr<NotificationRequest> request(new NotificationRequest(1));
195     request->SetSlotType(NotificationConstant::SlotType::SOCIAL_COMMUNICATION);
196     request->SetOwnerBundleName(ownerBundleName);
197     request->SetOwnerUid(ownerUid);
198 
199     std::string deviceType = "headset";
200     auto res = NotificationPreferences::GetInstance()->SetSmartReminderEnabled(deviceType, true);
201     ASSERT_EQ(res, 0);
202 
203     sptr<NotificationBundleOption> bundleOption(
204         new (std::nothrow) NotificationBundleOption(ownerBundleName, ownerUid));
205     res = NotificationPreferences::GetInstance()->SetDistributedEnabledByBundle(
206         bundleOption, deviceType, true);
207     ASSERT_EQ(res, 0);
208 
209     set<string> validDevices;
210     set<string> smartDevices;
211     map<string, bitset<DistributedDeviceStatus::STATUS_SIZE>> statusMap;
212     smartReminderCenter_->InitValidDevices(validDevices, smartDevices, statusMap, request);
213     ASSERT_EQ(request->GetNotificationControlFlags(), 0);
214 }
215 #ifdef ALL_SCENARIO_COLLABORATION
216 /**
217  * @tc.name: InitPcPadDevices_100
218  * @tc.desc: Test InitPcPadDevices
219  * @tc.type: FUNC
220  */
221 HWTEST_F(SmartReminderCenterTest, InitPcPadDevices_100, Function | SmallTest | Level1)
222 {
223     std::string deviceType = NotificationConstant::PC_DEVICE_TYPE;
224     set<string> validDevices;
225     set<string> smartDevices;
226     sptr<NotificationRequest> request(new NotificationRequest(1));
227     request->SetSlotType(NotificationConstant::SlotType::LIVE_VIEW);
228     map<string, bitset<DistributedDeviceStatus::STATUS_SIZE>> statusMap;
229 
230     smartReminderCenter_->InitPcPadDevices(deviceType, validDevices, smartDevices, statusMap, request);
231 
232     ASSERT_EQ(validDevices.size(), 0);
233     ASSERT_EQ(smartDevices.size(), 0);
234 }
235 
236 /**
237  * @tc.name: InitPcPadDevices_200
238  * @tc.desc: Test InitPcPadDevices when CURRENT DEVICE with live view slot type
239  * @tc.type: FUNC
240  */
241 HWTEST_F(SmartReminderCenterTest, InitPcPadDevices_200, Function | SmallTest | Level1)
242 {
243     std::string deviceType = NotificationConstant::CURRENT_DEVICE_TYPE;
244     set<string> validDevices;
245     set<string> smartDevices;
246     sptr<NotificationRequest> request(new NotificationRequest(1));
247     request->SetSlotType(NotificationConstant::SlotType::LIVE_VIEW);
248     map<string, bitset<DistributedDeviceStatus::STATUS_SIZE>> statusMap;
249 
250     smartReminderCenter_->InitPcPadDevices(deviceType, validDevices, smartDevices, statusMap, request);
251 
252     ASSERT_EQ(validDevices.size(), 0);
253     ASSERT_EQ(smartDevices.size(), 0);
254 }
255 
256 /**
257  * @tc.name: InitPcPadDevices_300
258  * @tc.desc: Test InitPcPadDevices when ANS_VOIP
259  * @tc.type: FUNC
260  */
261 HWTEST_F(SmartReminderCenterTest, InitPcPadDevices_300, Function | SmallTest | Level1)
262 {
263     std::string deviceType = NotificationConstant::PC_DEVICE_TYPE;
264     set<string> validDevices;
265     set<string> smartDevices;
266     sptr<NotificationRequest> request(new NotificationRequest(1));
267     request->SetClassification(NotificationConstant::ANS_VOIP);
268     map<string, bitset<DistributedDeviceStatus::STATUS_SIZE>> statusMap;
269     smartReminderCenter_->InitPcPadDevices(deviceType, validDevices, smartDevices, statusMap, request);
270 
271     ASSERT_EQ(validDevices.size(), 0);
272     ASSERT_EQ(smartDevices.size(), 0);
273 }
274 #endif
275 
276 /**
277  * @tc.name: FillRequestExtendInfo_100
278  * @tc.desc: Test FillRequestExtendInfo
279  * @tc.type: FUNC
280  */
281 HWTEST_F(SmartReminderCenterTest, FillRequestExtendInfo_100, Function | SmallTest | Level1)
282 {
283     std::string deviceType = "testType";
284     std::string deviceId = "testId";
285     DeviceStatus deviceStatus(deviceType, deviceId);
286     sptr<NotificationRequest> request(new NotificationRequest(1));
287     AppExecFwk::ApplicationInfo appInfo;
288     appInfo.name = "testName";
289     appInfo.appIndex = 0;
290     AppExecFwk::BundleResourceInfo bundleResourceInfo;
291     bundleResourceInfo.label = "label";
292 
293     smartReminderCenter_->FillRequestExtendInfo(deviceType, deviceStatus, request, appInfo, bundleResourceInfo);
294 
295     ASSERT_NE(request->GetExtendInfo(), nullptr);
296 }
297 
298 /**
299  * @tc.name: HandleReminderMethods_100
300  * @tc.desc: Test HandleReminderMethods
301  * @tc.type: FUNC
302  */
303 HWTEST_F(SmartReminderCenterTest, HandleReminderMethods_100, Function | SmallTest | Level1)
304 {
305     string deviceType = NotificationConstant::CURRENT_DEVICE_TYPE;
306     map<string, vector<shared_ptr<ReminderAffected>>> reminderFilterDevice{};
307     sptr<NotificationRequest> request(new NotificationRequest(1));
308     request->SetClassification("ANS_VOIP");
309     set<string> syncDevices;
310     set<string> smartDevices;
311     shared_ptr<NotificationFlags> defaultFlag = nullptr;
312     map<string, bitset<DistributedDeviceStatus::STATUS_SIZE>> statusMap{};
313     shared_ptr<map<string, shared_ptr<NotificationFlags>>> notificationFlagsOfDevices =
314         make_shared<map<string, shared_ptr<NotificationFlags>>>();
315 
316     smartReminderCenter_->HandleReminderMethods(deviceType, reminderFilterDevice, request, syncDevices,
317         smartDevices, defaultFlag, statusMap, notificationFlagsOfDevices);
318 
319     ASSERT_EQ(syncDevices.find(deviceType), syncDevices.end());
320 }
321 
322 /**
323  * @tc.name: HandleReminderMethods_200
324  * @tc.desc: Test HandleReminderMethods
325  * @tc.type: FUNC
326  */
327 HWTEST_F(SmartReminderCenterTest, HandleReminderMethods_200, Function | SmallTest | Level1)
328 {
329     string deviceType = NotificationConstant::CURRENT_DEVICE_TYPE;
330     map<string, vector<shared_ptr<ReminderAffected>>> reminderFilterDevice{};
331     sptr<NotificationRequest> request(new NotificationRequest(1));
332     set<string> syncDevices;
333     syncDevices.insert(deviceType);
334     set<string> smartDevices;
335     auto defaultFlag = std::make_shared<NotificationFlags>();
336     map<string, bitset<DistributedDeviceStatus::STATUS_SIZE>> statusMap{};
337     shared_ptr<map<string, shared_ptr<NotificationFlags>>> notificationFlagsOfDevices =
338         make_shared<map<string, shared_ptr<NotificationFlags>>>();
339 
340     smartReminderCenter_->HandleReminderMethods(deviceType, reminderFilterDevice, request, syncDevices,
341         smartDevices, defaultFlag, statusMap, notificationFlagsOfDevices);
342 
343     ASSERT_EQ(smartDevices.find(deviceType), smartDevices.end());
344 }
345 
346 /**
347  * @tc.name: HandleReminderMethods_300
348  * @tc.desc: Test HandleReminderMethods
349  * @tc.type: FUNC
350  */
351 HWTEST_F(SmartReminderCenterTest, HandleReminderMethods_300, Function | SmallTest | Level1)
352 {
353     string deviceType = NotificationConstant::CURRENT_DEVICE_TYPE;
354     map<string, vector<shared_ptr<ReminderAffected>>> reminderFilterDevice{};
355     sptr<NotificationRequest> request(new NotificationRequest(1));
356     set<string> syncDevices;
357     syncDevices.insert(deviceType);
358     set<string> smartDevices;
359     smartDevices.insert(deviceType);
360     shared_ptr<NotificationFlags> defaultFlag = make_shared<NotificationFlags>();;
361     map<string, bitset<DistributedDeviceStatus::STATUS_SIZE>> statusMap{};
362     shared_ptr<map<string, shared_ptr<NotificationFlags>>> notificationFlagsOfDevices =
363         make_shared<map<string, shared_ptr<NotificationFlags>>>();
364 
365     smartReminderCenter_->HandleReminderMethods(deviceType, reminderFilterDevice, request, syncDevices,
366         smartDevices, defaultFlag, statusMap, notificationFlagsOfDevices);
367 
368     ASSERT_NE(notificationFlagsOfDevices->find(deviceType), notificationFlagsOfDevices->end());
369 }
370 
371 /**
372  * @tc.name: HandleReminderMethods_400
373  * @tc.desc: Test HandleReminderMethods
374  * @tc.type: FUNC
375  */
376 HWTEST_F(SmartReminderCenterTest, HandleReminderMethods_400, Function | SmallTest | Level1)
377 {
378     string deviceType = NotificationConstant::CURRENT_DEVICE_TYPE;
379     map<string, vector<shared_ptr<ReminderAffected>>> reminderFilterDevice{};
380     sptr<NotificationRequest> request(new NotificationRequest(1));
381     set<string> syncDevices;
382     syncDevices.insert(deviceType);
383     set<string> smartDevices;
384     smartDevices.insert(deviceType);
385     shared_ptr<NotificationFlags> defaultFlag = make_shared<NotificationFlags>();;
386     map<string, bitset<DistributedDeviceStatus::STATUS_SIZE>> statusMap{};
387     shared_ptr<map<string, shared_ptr<NotificationFlags>>> notificationFlagsOfDevices =
388         make_shared<map<string, shared_ptr<NotificationFlags>>>();
389 
390     smartReminderCenter_->HandleReminderMethods(deviceType, reminderFilterDevice, request, syncDevices,
391         smartDevices, defaultFlag, statusMap, notificationFlagsOfDevices);
392 
393     ASSERT_EQ(statusMap.find(deviceType), statusMap.end());
394 }
395 
396 /**
397  * @tc.name: HandleReminderMethods_500
398  * @tc.desc: Test HandleReminderMethods
399  * @tc.type: FUNC
400  */
401 HWTEST_F(SmartReminderCenterTest, HandleReminderMethods_500, Function | SmallTest | Level1)
402 {
403     string deviceType = NotificationConstant::CURRENT_DEVICE_TYPE;
404     map<string, vector<shared_ptr<ReminderAffected>>> reminderFilterDevice{};
405     sptr<NotificationRequest> request(new NotificationRequest(1));
406     set<string> syncDevices;
407     syncDevices.insert(deviceType);
408     set<string> smartDevices;
409     smartDevices.insert(deviceType);
410     smartDevices.insert("headset");
411     shared_ptr<NotificationFlags> defaultFlag = make_shared<NotificationFlags>();;
412     map<string, bitset<DistributedDeviceStatus::STATUS_SIZE>> statusMap{};
413     shared_ptr<map<string, shared_ptr<NotificationFlags>>> notificationFlagsOfDevices =
414         make_shared<map<string, shared_ptr<NotificationFlags>>>();
415 
416     smartReminderCenter_->HandleReminderMethods(deviceType, reminderFilterDevice, request, syncDevices,
417         smartDevices, defaultFlag, statusMap, notificationFlagsOfDevices);
418 
419     ASSERT_EQ(statusMap.find(deviceType), statusMap.end());
420 }
421 
422 /**
423  * @tc.name: HandleReminderMethods_600
424  * @tc.desc: Test HandleReminderMethods
425  * @tc.type: FUNC
426  */
427 HWTEST_F(SmartReminderCenterTest, HandleReminderMethods_600, Function | SmallTest | Level1)
428 {
429     string deviceType = NotificationConstant::CURRENT_DEVICE_TYPE;
430     map<string, vector<shared_ptr<ReminderAffected>>> reminderFilterDevice{};
431     vector<shared_ptr<ReminderAffected>> reminderAffecteds = { nullptr };
432     std::string key = "5";
433     reminderFilterDevice[key] = reminderAffecteds;
434     sptr<NotificationRequest> request(new NotificationRequest(1));
435     auto localLiveViewContent = std::make_shared<NotificationLocalLiveViewContent>();
436     auto content = std::make_shared<NotificationContent>(localLiveViewContent);
437     request->SetContent(content);
438     request->SetSlotType(NotificationConstant::SlotType::LIVE_VIEW);
439     set<string> syncDevices;
440     syncDevices.insert(deviceType);
441     set<string> smartDevices;
442     smartDevices.insert(deviceType);
443     smartDevices.insert("headset");
444     shared_ptr<NotificationFlags> defaultFlag = make_shared<NotificationFlags>();;
445     map<string, bitset<DistributedDeviceStatus::STATUS_SIZE>> statusMap{};
446     shared_ptr<map<string, shared_ptr<NotificationFlags>>> notificationFlagsOfDevices =
447         make_shared<map<string, shared_ptr<NotificationFlags>>>();
448 
449     smartReminderCenter_->HandleReminderMethods(deviceType, reminderFilterDevice, request, syncDevices,
450         smartDevices, defaultFlag, statusMap, notificationFlagsOfDevices);
451 
452     ASSERT_EQ(statusMap.find(deviceType), statusMap.end());
453 }
454 
455 /**
456  * @tc.name: HandleReminderMethods_700
457  * @tc.desc: Test HandleReminderMethods
458  * @tc.type: FUNC
459  */
460 HWTEST_F(SmartReminderCenterTest, HandleReminderMethods_700, Function | SmallTest | Level1)
461 {
462     string deviceType = NotificationConstant::CURRENT_DEVICE_TYPE;
463     map<string, vector<shared_ptr<ReminderAffected>>> reminderFilterDevice{};
464     auto reminderAffected = std::make_shared<ReminderAffected>();
465     reminderAffected->status_ = "1111";
466     vector<shared_ptr<ReminderAffected>> reminderAffecteds = { reminderAffected };
467     std::string key = "5";
468     reminderFilterDevice[key] = reminderAffecteds;
469     sptr<NotificationRequest> request(new NotificationRequest(1));
470     auto localLiveViewContent = std::make_shared<NotificationLocalLiveViewContent>();
471     auto content = std::make_shared<NotificationContent>(localLiveViewContent);
472     request->SetContent(content);
473     request->SetSlotType(NotificationConstant::SlotType::LIVE_VIEW);
474     set<string> syncDevices;
475     syncDevices.insert(deviceType);
476     set<string> smartDevices;
477     smartDevices.insert(deviceType);
478     smartDevices.insert("headset");
479     shared_ptr<NotificationFlags> defaultFlag = make_shared<NotificationFlags>();;
480     map<string, bitset<DistributedDeviceStatus::STATUS_SIZE>> statusMap = {};
481     statusMap.insert(pair<string,
482         bitset<DistributedDeviceStatus::STATUS_SIZE>>("1111", bitset<DistributedDeviceStatus::STATUS_SIZE>(0)));
483     shared_ptr<map<string, shared_ptr<NotificationFlags>>> notificationFlagsOfDevices =
484         make_shared<map<string, shared_ptr<NotificationFlags>>>();
485 
486     smartReminderCenter_->HandleReminderMethods(deviceType, reminderFilterDevice, request, syncDevices,
487         smartDevices, defaultFlag, statusMap, notificationFlagsOfDevices);
488 
489     auto bitStatus = bitset<DistributedDeviceStatus::STATUS_SIZE>(0);
490     ASSERT_FALSE(smartReminderCenter_->CompareStatus(reminderAffected->status_, bitStatus));
491 }
492 
493 /**
494  * @tc.name: HandleReminderMethods_800
495  * @tc.desc: Test HandleReminderMethods
496  * @tc.type: FUNC
497  */
498 HWTEST_F(SmartReminderCenterTest, HandleReminderMethods_800, Function | SmallTest | Level1)
499 {
500     string deviceType = NotificationConstant::CURRENT_DEVICE_TYPE;
501     map<string, vector<shared_ptr<ReminderAffected>>> reminderFilterDevice{};
502     auto reminderAffected = std::make_shared<ReminderAffected>();
503     reminderAffected->status_ = "0000";
504     vector<shared_ptr<ReminderAffected>> reminderAffecteds = { reminderAffected };
505     std::string key = "5";
506     reminderFilterDevice[key] = reminderAffecteds;
507     sptr<NotificationRequest> request(new NotificationRequest(1));
508     auto localLiveViewContent = std::make_shared<NotificationLocalLiveViewContent>();
509     auto content = std::make_shared<NotificationContent>(localLiveViewContent);
510     request->SetContent(content);
511     request->SetSlotType(NotificationConstant::SlotType::LIVE_VIEW);
512     set<string> syncDevices;
513     syncDevices.insert(deviceType);
514     set<string> smartDevices;
515     smartDevices.insert(deviceType);
516     smartDevices.insert("headset");
517     shared_ptr<NotificationFlags> defaultFlag = make_shared<NotificationFlags>();;
518     map<string, bitset<DistributedDeviceStatus::STATUS_SIZE>> statusMap = {};
519     statusMap.insert(pair<string,
520         bitset<DistributedDeviceStatus::STATUS_SIZE>>("1111", bitset<DistributedDeviceStatus::STATUS_SIZE>(0)));
521     shared_ptr<map<string, shared_ptr<NotificationFlags>>> notificationFlagsOfDevices =
522         make_shared<map<string, shared_ptr<NotificationFlags>>>();
523 
524     smartReminderCenter_->HandleReminderMethods(deviceType, reminderFilterDevice, request, syncDevices,
525         smartDevices, defaultFlag, statusMap, notificationFlagsOfDevices);
526 
527     auto bitStatus = bitset<DistributedDeviceStatus::STATUS_SIZE>(0);
528     ASSERT_TRUE(smartReminderCenter_->CompareStatus(reminderAffected->status_, bitStatus));
529     ASSERT_EQ(reminderAffected->affectedBy_.size(), 0);
530 }
531 
532 /**
533  * @tc.name: HandleReminderMethods_900
534  * @tc.desc: Test HandleReminderMethods
535  * @tc.type: FUNC
536  */
537 HWTEST_F(SmartReminderCenterTest, HandleReminderMethods_900, Function | SmallTest | Level1)
538 {
539     string deviceType = NotificationConstant::CURRENT_DEVICE_TYPE;
540     map<string, vector<shared_ptr<ReminderAffected>>> reminderFilterDevice{};
541     auto reminderAffected = std::make_shared<ReminderAffected>();
542     reminderAffected->status_ = "0000";
543     reminderAffected->affectedBy_ = { std::make_pair("test111", "0000") };
544     vector<shared_ptr<ReminderAffected>> reminderAffecteds = { reminderAffected };
545     std::string key = "5";
546     reminderFilterDevice[key] = reminderAffecteds;
547     sptr<NotificationRequest> request(new NotificationRequest(1));
548     auto localLiveViewContent = std::make_shared<NotificationLocalLiveViewContent>();
549     auto content = std::make_shared<NotificationContent>(localLiveViewContent);
550     request->SetContent(content);
551     request->SetSlotType(NotificationConstant::SlotType::LIVE_VIEW);
552     set<string> syncDevices;
553     syncDevices.insert(deviceType);
554     set<string> smartDevices;
555     smartDevices.insert(deviceType);
556     smartDevices.insert("headset");
557     shared_ptr<NotificationFlags> defaultFlag = make_shared<NotificationFlags>();;
558     map<string, bitset<DistributedDeviceStatus::STATUS_SIZE>> statusMap = {};
559     statusMap.insert(pair<string,
560         bitset<DistributedDeviceStatus::STATUS_SIZE>>("1111", bitset<DistributedDeviceStatus::STATUS_SIZE>(0)));
561     shared_ptr<map<string, shared_ptr<NotificationFlags>>> notificationFlagsOfDevices =
562         make_shared<map<string, shared_ptr<NotificationFlags>>>();
563 
564     smartReminderCenter_->HandleReminderMethods(deviceType, reminderFilterDevice, request, syncDevices,
565         smartDevices, defaultFlag, statusMap, notificationFlagsOfDevices);
566 
567     auto bitStatus = bitset<DistributedDeviceStatus::STATUS_SIZE>(0);
568     ASSERT_TRUE(smartReminderCenter_->CompareStatus(reminderAffected->status_, bitStatus));
569     ASSERT_NE(reminderAffected->affectedBy_.size(), 0);
570 }
571 
572 /**
573  * @tc.name: GetAppSwitch_100
574  * @tc.desc: Test GetAppSwitch
575  * @tc.type: FUNC
576  */
577 HWTEST_F(SmartReminderCenterTest, GetAppSwitch_100, Function | SmallTest | Level1)
578 {
579     const string deviceType = NotificationConstant::WEARABLE_DEVICE_TYPE;
580     const string ownerBundleName = "testBundle";
581     int32_t ownerUid = 0;
582 
583     auto ret = smartReminderCenter_->GetAppSwitch(deviceType, ownerBundleName, ownerUid);
584 
585     ASSERT_FALSE(ret);
586 }
587 
588 /**
589  * @tc.name: GetSmartSwitch_100
590  * @tc.desc: Test GetSmartSwitch
591  * @tc.type: FUNC
592  */
593 HWTEST_F(SmartReminderCenterTest, GetSmartSwitch_100, Function | SmallTest | Level1)
594 {
595     const string deviceType = NotificationConstant::WEARABLE_DEVICE_TYPE;
596 
597     auto ret = smartReminderCenter_->GetSmartSwitch(deviceType);
598 
599     ASSERT_FALSE(ret);
600 }
601 
602 /**
603  * @tc.name: GetReminderAffecteds_100
604  * @tc.desc: Test GetReminderAffecteds
605  * @tc.type: FUNC
606  */
607 HWTEST_F(SmartReminderCenterTest, GetReminderAffecteds_100, Function | SmallTest | Level1)
608 {
609     map<string, vector<shared_ptr<ReminderAffected>>> reminderFilterDevice{};
610     sptr<NotificationRequest> request(new NotificationRequest(1));
611     auto localLiveViewContent = std::make_shared<NotificationLocalLiveViewContent>();
612     auto content = std::make_shared<NotificationContent>(localLiveViewContent);
613     request->SetContent(content);
614     request->SetSlotType(NotificationConstant::SlotType::LIVE_VIEW);
615     vector<shared_ptr<ReminderAffected>> reminderAffecteds;
616 
617     smartReminderCenter_->GetReminderAffecteds(reminderFilterDevice, request, reminderAffecteds);
618 
619     std::string key = "5#7#0";
620     ASSERT_EQ(reminderFilterDevice.find(key), reminderFilterDevice.end());
621 }
622 
623 /**
624  * @tc.name: GetReminderAffecteds_200
625  * @tc.desc: Test GetReminderAffecteds
626  * @tc.type: FUNC
627  */
628 HWTEST_F(SmartReminderCenterTest, GetReminderAffecteds_200, Function | SmallTest | Level1)
629 {
630     map<string, vector<shared_ptr<ReminderAffected>>> reminderFilterDevice{};
631     sptr<NotificationRequest> request(new NotificationRequest(1));
632     auto localLiveViewContent = std::make_shared<NotificationLocalLiveViewContent>();
633     auto content = std::make_shared<NotificationContent>(localLiveViewContent);
634     request->SetContent(content);
635     request->SetSlotType(NotificationConstant::SlotType::LIVE_VIEW);
636     vector<shared_ptr<ReminderAffected>> reminderAffecteds;
637 
638     smartReminderCenter_->GetReminderAffecteds(reminderFilterDevice, request, reminderAffecteds);
639 
640     std::string key = "5#7#0";
641     ASSERT_EQ(reminderFilterDevice.find(key), reminderFilterDevice.end());
642 }
643 
644 /**
645  * @tc.name: GetReminderAffecteds_300
646  * @tc.desc: Test GetReminderAffecteds
647  * @tc.type: FUNC
648  */
649 HWTEST_F(SmartReminderCenterTest, GetReminderAffecteds_300, Function | SmallTest | Level1)
650 {
651     map<string, vector<shared_ptr<ReminderAffected>>> reminderFilterDevice{};
652     sptr<NotificationRequest> request(new NotificationRequest(1));
653     auto localLiveViewContent = std::make_shared<NotificationLocalLiveViewContent>();
654     auto content = std::make_shared<NotificationContent>(localLiveViewContent);
655     request->SetContent(content);
656     request->SetSlotType(NotificationConstant::SlotType::LIVE_VIEW);
657     vector<shared_ptr<ReminderAffected>> reminderAffecteds;
658     std::string key = "5#7#0";
659     reminderFilterDevice[key] = reminderAffecteds;
660 
661     smartReminderCenter_->GetReminderAffecteds(reminderFilterDevice, request, reminderAffecteds);
662 
663     std::string key1 = "5#7";
664     ASSERT_EQ(reminderFilterDevice.find(key1), reminderFilterDevice.end());
665 }
666 
667 /**
668  * @tc.name: GetReminderAffecteds_400
669  * @tc.desc: Test GetReminderAffecteds
670  * @tc.type: FUNC
671  */
672 HWTEST_F(SmartReminderCenterTest, GetReminderAffecteds_400, Function | SmallTest | Level1)
673 {
674     map<string, vector<shared_ptr<ReminderAffected>>> reminderFilterDevice{};
675     sptr<NotificationRequest> request(new NotificationRequest(1));
676     auto localLiveViewContent = std::make_shared<NotificationLocalLiveViewContent>();
677     auto content = std::make_shared<NotificationContent>(localLiveViewContent);
678     request->SetContent(content);
679     request->SetSlotType(NotificationConstant::SlotType::LIVE_VIEW);
680     vector<shared_ptr<ReminderAffected>> reminderAffecteds;
681     std::string key = "5#7";
682     reminderFilterDevice[key] = reminderAffecteds;
683 
684     smartReminderCenter_->GetReminderAffecteds(reminderFilterDevice, request, reminderAffecteds);
685 
686     std::string key1 = "5";
687     ASSERT_EQ(reminderFilterDevice.find(key1), reminderFilterDevice.end());
688 }
689 
690 /**
691  * @tc.name: GetReminderAffecteds_500
692  * @tc.desc: Test GetReminderAffecteds
693  * @tc.type: FUNC
694  */
695 HWTEST_F(SmartReminderCenterTest, GetReminderAffecteds_500, Function | SmallTest | Level1)
696 {
697     map<string, vector<shared_ptr<ReminderAffected>>> reminderFilterDevice{};
698     sptr<NotificationRequest> request(new NotificationRequest(1));
699     auto localLiveViewContent = std::make_shared<NotificationLocalLiveViewContent>();
700     auto content = std::make_shared<NotificationContent>(localLiveViewContent);
701     request->SetContent(content);
702     request->SetSlotType(NotificationConstant::SlotType::LIVE_VIEW);
703     vector<shared_ptr<ReminderAffected>> reminderAffecteds;
704     vector<shared_ptr<ReminderAffected>> reminderAffecteds1 = { nullptr };
705     std::string key = "5";
706     reminderFilterDevice[key] = reminderAffecteds1;
707 
708     smartReminderCenter_->GetReminderAffecteds(reminderFilterDevice, request, reminderAffecteds);
709 
710     ASSERT_EQ(reminderAffecteds.size(), 1);
711 }
712 }   //namespace Notification
713 }   //namespace OHOS
714 #endif
715