• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #define private public
17 #include <gtest/gtest.h>
18 
19 #define private public
20 #define protected public
21 #include "notification_preferences_database.h"
22 #include "notification_rdb_data_mgr.h"
23 #undef private
24 #undef protected
25 #include "mock_os_account_manager.h"
26 
27 using namespace testing::ext;
28 namespace OHOS {
29 namespace Notification {
30 class NotificationPreferencesDatabaseTest : public testing::Test {
31 public:
SetUpTestCase()32     static void SetUpTestCase() {};
TearDownTestCase()33     static void TearDownTestCase() {};
SetUp()34     void SetUp() {};
TearDown()35     void TearDown() {};
36 
37     const std::string bundleName_ = "bundleName";
38     const int bundleUid_ = 2001;
39     int32_t userId = 100;
40     std::unique_ptr<NotificationPreferencesDatabase> preferncesDB_ =
41         std::make_unique<NotificationPreferencesDatabase>();
42 };
43 
44 /**
45  * @tc.name      : PutSlotsToDisturbeDB_00100
46  * @tc.number    :
47  * @tc.desc      : Put slots into Disturbe DB, return is true.
48  */
49 HWTEST_F(NotificationPreferencesDatabaseTest, PutSlotsToDisturbeDB_00100, Function | SmallTest | Level1)
50 {
51     std::vector<sptr<NotificationSlot>> slots;
52     sptr<NotificationSlot> slot1 = new NotificationSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION);
53     sptr<NotificationSlot> slot2 = new NotificationSlot(NotificationConstant::SlotType::SERVICE_REMINDER);
54     slots.push_back(slot1);
55     slots.push_back(slot2);
56     EXPECT_TRUE(preferncesDB_->PutSlotsToDisturbeDB(bundleName_, bundleUid_, slots));
57 }
58 
59 /**
60  * @tc.name      : PutSlotsToDisturbeDB_00200
61  * @tc.number    :
62  * @tc.desc      : Put slots into Disturbe DB when bundle name is null, return is true.
63  */
64 HWTEST_F(NotificationPreferencesDatabaseTest, PutSlotsToDisturbeDB_00200, Function | SmallTest | Level1)
65 {
66     std::vector<sptr<NotificationSlot>> slots;
67     sptr<NotificationSlot> slot1 = new NotificationSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION);
68     sptr<NotificationSlot> slot2 = new NotificationSlot(NotificationConstant::SlotType::SERVICE_REMINDER);
69     slots.push_back(slot1);
70     slots.push_back(slot2);
71     EXPECT_FALSE(preferncesDB_->PutSlotsToDisturbeDB(std::string(), 0, slots));
72 }
73 
74 /**
75  * @tc.name      : PutSlotsToDisturbeDB_00300
76  * @tc.number    :
77  * @tc.desc      : Put slots into Disturbe DB when slots is null, return is false.
78  */
79 HWTEST_F(NotificationPreferencesDatabaseTest, PutSlotsToDisturbeDB_00300, Function | SmallTest | Level1)
80 {
81     std::vector<sptr<NotificationSlot>> slots;
82     EXPECT_FALSE(preferncesDB_->PutSlotsToDisturbeDB(bundleName_, bundleUid_, slots));
83 }
84 
85 /**
86  * @tc.name      : PutShowBadge_00100
87  * @tc.number    :
88  * @tc.desc      : Put bundle show badge into disturbe DB, return is true.
89  */
90 HWTEST_F(NotificationPreferencesDatabaseTest, PutShowBadge_00100, Function | SmallTest | Level1)
91 {
92     NotificationPreferencesInfo::BundleInfo bundleInfo;
93     bundleInfo.SetBundleName(bundleName_);
94     bundleInfo.SetBundleUid(bundleUid_);
95     EXPECT_TRUE(preferncesDB_->PutShowBadge(bundleInfo, true));
96     EXPECT_TRUE(preferncesDB_->PutShowBadge(bundleInfo, false));
97 }
98 
99 /**
100  * @tc.number    : PutShowBadge_00200
101  * @tc.name      :
102  * @tc.desc      : Put bundle show badge into disturbe DB when bundle name is null, return is false.
103  */
104 HWTEST_F(NotificationPreferencesDatabaseTest, PutShowBadge_00200, Function | SmallTest | Level1)
105 {
106     NotificationPreferencesInfo::BundleInfo bundleInfo;
107     bundleInfo.SetBundleName(std::string());
108     EXPECT_FALSE(preferncesDB_->PutShowBadge(bundleInfo, false));
109 }
110 
111 /**
112  * @tc.name      : PutImportance_00100
113  * @tc.number    :
114  * @tc.desc      : Put bundle importance into disturbe DB, return is true.
115  */
116 HWTEST_F(NotificationPreferencesDatabaseTest, PutImportance_00100, Function | SmallTest | Level1)
117 {
118     NotificationPreferencesInfo::BundleInfo bundleInfo;
119     bundleInfo.SetBundleName(bundleName_);
120     bundleInfo.SetBundleUid(bundleUid_);
121 
122     EXPECT_TRUE(
123         preferncesDB_->PutImportance(bundleInfo, OHOS::Notification::NotificationSlot::NotificationLevel::LEVEL_NONE));
124     EXPECT_TRUE(
125         preferncesDB_->PutImportance(bundleInfo, OHOS::Notification::NotificationSlot::NotificationLevel::LEVEL_MIN));
126     EXPECT_TRUE(
127         preferncesDB_->PutImportance(bundleInfo, OHOS::Notification::NotificationSlot::NotificationLevel::LEVEL_LOW));
128     EXPECT_TRUE(preferncesDB_->PutImportance(
129         bundleInfo, OHOS::Notification::NotificationSlot::NotificationLevel::LEVEL_DEFAULT));
130     EXPECT_TRUE(
131         preferncesDB_->PutImportance(bundleInfo, OHOS::Notification::NotificationSlot::NotificationLevel::LEVEL_HIGH));
132     EXPECT_TRUE(preferncesDB_->PutImportance(
133         bundleInfo, OHOS::Notification::NotificationSlot::NotificationLevel::LEVEL_UNDEFINED));
134 }
135 
136 /**
137  * @tc.name      : PutImportance_00200
138  * @tc.number    :
139  * @tc.desc      : Put bundle importance into disturbe DB when bundle name is null, return is false.
140  */
141 HWTEST_F(NotificationPreferencesDatabaseTest, PutImportance_00200, Function | SmallTest | Level1)
142 {
143     NotificationPreferencesInfo::BundleInfo bundleInfo;
144     bundleInfo.SetBundleName(std::string());
145     bundleInfo.SetBundleUid(0);
146 
147     EXPECT_FALSE(
148         preferncesDB_->PutImportance(bundleInfo, OHOS::Notification::NotificationSlot::NotificationLevel::LEVEL_NONE));
149 }
150 
151 /**
152  * @tc.name      : PutTotalBadgeNums_00100
153  * @tc.number    :
154  * @tc.desc      : Put bundle total badge nums into disturbe DB, return is true.
155  */
156 HWTEST_F(NotificationPreferencesDatabaseTest, PutTotalBadgeNums_00100, Function | SmallTest | Level1)
157 {
158     NotificationPreferencesInfo::BundleInfo bundleInfo;
159     bundleInfo.SetBundleName(bundleName_);
160     bundleInfo.SetBundleUid(bundleUid_);
161     EXPECT_TRUE(preferncesDB_->PutTotalBadgeNums(bundleInfo, 0));
162 }
163 
164 /**
165  * @tc.number    : PutTotalBadgeNums_00200
166  * @tc.name      :
167  * @tc.desc      : Put bundle total badge nums into disturbe DB when bundle name is null, return is false.
168  */
169 HWTEST_F(NotificationPreferencesDatabaseTest, PutTotalBadgeNums_00200, Function | SmallTest | Level1)
170 {
171     NotificationPreferencesInfo::BundleInfo bundleInfo;
172     bundleInfo.SetBundleName(std::string());
173     bundleInfo.SetBundleUid(bundleUid_);
174     EXPECT_FALSE(preferncesDB_->PutTotalBadgeNums(bundleInfo, 0));
175 }
176 
177 /**
178  * @tc.name      : PutNotificationsEnabledForBundle_00100
179  * @tc.number    :
180  * @tc.desc      : Put bundle enable into disturbe DB, return is true.
181  */
182 HWTEST_F(NotificationPreferencesDatabaseTest, PutNotificationsEnabledForBundle_00100, Function | SmallTest | Level1)
183 {
184     NotificationPreferencesInfo::BundleInfo bundleInfo;
185     bundleInfo.SetBundleName(bundleName_);
186     bundleInfo.SetBundleUid(bundleUid_);
187     EXPECT_TRUE(preferncesDB_->PutNotificationsEnabledForBundle(bundleInfo,
188         NotificationConstant::SWITCH_STATE::USER_MODIFIED_ON));
189     EXPECT_TRUE(preferncesDB_->PutNotificationsEnabledForBundle(bundleInfo,
190         NotificationConstant::SWITCH_STATE::USER_MODIFIED_OFF));
191 }
192 
193 /**
194  * @tc.name      : PutNotificationsEnabledForBundle_00200
195  * @tc.number    :
196  * @tc.desc      : Put bundle enable into disturbe DB when bundle name is null, return is false.
197  */
198 HWTEST_F(NotificationPreferencesDatabaseTest, PutNotificationsEnabledForBundle_00200, Function | SmallTest | Level1)
199 {
200     NotificationPreferencesInfo::BundleInfo bundleInfo;
201     bundleInfo.SetBundleName(std::string());
202     bundleInfo.SetBundleUid(bundleUid_);
203     EXPECT_FALSE(preferncesDB_->PutNotificationsEnabledForBundle(bundleInfo,
204         NotificationConstant::SWITCH_STATE::USER_MODIFIED_OFF));
205 }
206 
207 /**
208  * @tc.name      : PutNotificationsEnabledForBundle_00300
209  * @tc.number    :
210  * @tc.desc      : Put bundle enable into disturbe DB when bundle name is null, return is false.
211  */
212 HWTEST_F(NotificationPreferencesDatabaseTest, PutNotificationsEnabledForBundle_00300, Function | SmallTest | Level1)
213 {
214     NotificationPreferencesInfo::BundleInfo bundleInfo;
215     bundleInfo.SetBundleName(bundleName_);
216     bundleInfo.SetBundleUid(bundleUid_);
217     ASSERT_TRUE(preferncesDB_->PutNotificationsEnabledForBundle(bundleInfo,
218         NotificationConstant::SWITCH_STATE::USER_MODIFIED_ON));
219     ASSERT_TRUE(preferncesDB_->RemoveEnabledDbByBundleName(bundleName_, bundleUid_));
220 }
221 
222 /**
223  * @tc.number    : PutNotificationsEnabled_00100
224  * @tc.name      :
225  * @tc.desc      : Put notification enable into disturbe DB, return is true.
226  */
227 HWTEST_F(NotificationPreferencesDatabaseTest, PutNotificationsEnabled_00100, Function | SmallTest | Level1)
228 {
229     EXPECT_TRUE(preferncesDB_->PutNotificationsEnabled(userId, true));
230     EXPECT_TRUE(preferncesDB_->PutNotificationsEnabled(userId, false));
231 }
232 
233 /**
234  * @tc.number    : PutDoNotDisturbDate_00100
235  * @tc.name      :
236  * @tc.desc      : Put disturbe mode into disturbe DB when DoNotDisturbType is NONE, return is true.
237  */
238 HWTEST_F(NotificationPreferencesDatabaseTest, PutDoNotDisturbDate_00100, Function | SmallTest | Level1)
239 {
240     sptr<NotificationDoNotDisturbDate> date =
241         new NotificationDoNotDisturbDate(NotificationConstant::DoNotDisturbType::NONE, 0, 0);
242     EXPECT_TRUE(preferncesDB_->PutDoNotDisturbDate(userId, date));
243 }
244 
245 /**
246  * @tc.number    : PutDoNotDisturbDate_00200
247  * @tc.name      :
248  * @tc.desc      : Put disturbe mode into disturbe DB when DoNotDisturbType is ONCE, return is true.
249  */
250 HWTEST_F(NotificationPreferencesDatabaseTest, PutDoNotDisturbDate_00200, Function | SmallTest | Level1)
251 {
252     std::chrono::system_clock::time_point timePoint = std::chrono::system_clock::now();
253     auto beginDuration = std::chrono::duration_cast<std::chrono::milliseconds>(timePoint.time_since_epoch());
254     int64_t beginDate = beginDuration.count();
255     timePoint += std::chrono::hours(1);
256     auto endDuration = std::chrono::duration_cast<std::chrono::milliseconds>(timePoint.time_since_epoch());
257     int64_t endDate = endDuration.count();
258     sptr<NotificationDoNotDisturbDate> date =
259         new NotificationDoNotDisturbDate(NotificationConstant::DoNotDisturbType::ONCE, beginDate, endDate);
260     EXPECT_TRUE(preferncesDB_->PutDoNotDisturbDate(userId, date));
261 }
262 
263 /**
264  * @tc.number    : PutDoNotDisturbDate_00300
265  * @tc.name      :
266  * @tc.desc      : Put disturbe mode into disturbe DB when DoNotDisturbType is DAILY, return is true.
267  */
268 HWTEST_F(NotificationPreferencesDatabaseTest, PutDoNotDisturbDate_00300, Function | SmallTest | Level1)
269 {
270     std::chrono::system_clock::time_point timePoint = std::chrono::system_clock::now();
271     auto beginDuration = std::chrono::duration_cast<std::chrono::milliseconds>(timePoint.time_since_epoch());
272     int64_t beginDate = beginDuration.count();
273     timePoint += std::chrono::hours(1);
274     auto endDuration = std::chrono::duration_cast<std::chrono::milliseconds>(timePoint.time_since_epoch());
275     int64_t endDate = endDuration.count();
276     sptr<NotificationDoNotDisturbDate> date =
277         new NotificationDoNotDisturbDate(NotificationConstant::DoNotDisturbType::DAILY, beginDate, endDate);
278 
279     EXPECT_TRUE(preferncesDB_->PutDoNotDisturbDate(userId, date));
280 }
281 
282 /**
283  * @tc.number    : PutDoNotDisturbDate_00400
284  * @tc.name      :
285  * @tc.desc      : Put disturbe mode into disturbe DB when DoNotDisturbType is CLEARLY, return is true.
286  */
287 HWTEST_F(NotificationPreferencesDatabaseTest, PutDoNotDisturbDate_00400, Function | SmallTest | Level1)
288 {
289     std::chrono::system_clock::time_point timePoint = std::chrono::system_clock::now();
290     auto beginDuration = std::chrono::duration_cast<std::chrono::milliseconds>(timePoint.time_since_epoch());
291     int64_t beginDate = beginDuration.count();
292     timePoint += std::chrono::hours(1);
293     auto endDuration = std::chrono::duration_cast<std::chrono::milliseconds>(timePoint.time_since_epoch());
294     int64_t endDate = endDuration.count();
295     sptr<NotificationDoNotDisturbDate> date =
296         new NotificationDoNotDisturbDate(NotificationConstant::DoNotDisturbType::CLEARLY, beginDate, endDate);
297 
298     EXPECT_TRUE(preferncesDB_->PutDoNotDisturbDate(userId, date));
299 }
300 
301 /**
302  * @tc.name      : RemoveAllDataFromDisturbeDB_00100
303  * @tc.number    :
304  * @tc.desc      : Remove all bundle info from disturbe DB, return is true.
305  */
306 HWTEST_F(NotificationPreferencesDatabaseTest, RemoveAllDataFromDisturbeDB_00100, Function | SmallTest | Level1)
307 {
308     EXPECT_TRUE(preferncesDB_->RemoveAllDataFromDisturbeDB());
309 }
310 
311 /**
312  * @tc.name      : RemoveBundleFromDisturbeDB_00100
313  * @tc.number    :
314  * @tc.desc      : Remove a bundle info from disturbe DB, return is true.
315  */
316 HWTEST_F(NotificationPreferencesDatabaseTest, RemoveBundleFromDisturbeDB_00100, Function | SmallTest | Level1)
317 {
318     NotificationPreferencesInfo::BundleInfo bundleInfo;
319     bundleInfo.SetBundleName(bundleName_);
320     bundleInfo.SetBundleUid(bundleUid_);
321     const int32_t uid = -1;
322     EXPECT_TRUE(preferncesDB_->PutTotalBadgeNums(bundleInfo, 0));
323     ASSERT_EQ(true, preferncesDB_->RemoveBundleFromDisturbeDB(bundleName_, uid));
324 }
325 
326 /**
327  * @tc.name      : RemoveBundleFromDisturbeDB_00200
328  * @tc.number    :
329  * @tc.desc      : Remove a bundle info from disturbe DB when bundle name is null, return is true.
330  */
331 HWTEST_F(NotificationPreferencesDatabaseTest, RemoveBundleFromDisturbeDB_00200, Function | SmallTest | Level1)
332 {
333     const int32_t uid = -1;
334     ASSERT_EQ(true, preferncesDB_->RemoveBundleFromDisturbeDB(std::string(), uid));
335 }
336 
337 /**
338  * @tc.name      : RemoveSlotFromDisturbeDB_00100
339  * @tc.number    :
340  * @tc.desc      : Remove slot from disturbe DB, return is true.
341  */
342 HWTEST_F(NotificationPreferencesDatabaseTest, RemoveSlotFromDisturbeDB_00100, Function | SmallTest | Level1)
343 {
344     std::vector<sptr<NotificationSlot>> slots;
345     sptr<NotificationSlot> slot1 = new NotificationSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION);
346     slots.push_back(slot1);
347     EXPECT_TRUE(preferncesDB_->PutSlotsToDisturbeDB(bundleName_, bundleUid_, slots));
348     EXPECT_TRUE(preferncesDB_->RemoveSlotFromDisturbeDB(
349         bundleName_ + std::to_string(bundleUid_),
350         OHOS::Notification::NotificationConstant::SlotType::SOCIAL_COMMUNICATION, -1));
351 }
352 
353 /**
354  * @tc.name      : RemoveSlotFromDisturbeDB_00200
355  * @tc.number    :
356  * @tc.desc      : Remove slot from disturbe DB when bundle name is null, return is false
357  */
358 HWTEST_F(NotificationPreferencesDatabaseTest, RemoveSlotFromDisturbeDB_00200, Function | SmallTest | Level1)
359 {
360     EXPECT_FALSE(preferncesDB_->RemoveSlotFromDisturbeDB(
361         std::string(), OHOS::Notification::NotificationConstant::SlotType::SOCIAL_COMMUNICATION, -1));
362 }
363 
364 /**
365  * @tc.name      : CheckKvStore_00100
366  * @tc.number    :
367  * @tc.desc      : Check disturbe DB is exsit, return is true.
368  */
369 HWTEST_F(NotificationPreferencesDatabaseTest, CheckKvStore_00100, Function | SmallTest | Level1)
370 {
371     EXPECT_TRUE(preferncesDB_->CheckRdbStore());
372 }
373 
374 /**
375  * @tc.name      : CheckKvStore_00200
376  * @tc.number    :
377  * @tc.desc      : Check disturbe DB is exsit, return is false.
378  */
379 HWTEST_F(NotificationPreferencesDatabaseTest, CheckKvStore_00300, Function | SmallTest | Level1)
380 {
381     EXPECT_TRUE(preferncesDB_->CheckRdbStore());
382     std::vector<sptr<NotificationSlot>> slots;
383     sptr<NotificationSlot> slot1 = new NotificationSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION);
384     sptr<NotificationSlot> slot2 = new NotificationSlot(NotificationConstant::SlotType::SERVICE_REMINDER);
385     slots.push_back(slot1);
386     slots.push_back(slot2);
387     EXPECT_TRUE(preferncesDB_->PutSlotsToDisturbeDB(bundleName_, bundleUid_, slots));
388 }
389 
390 /**
391  * @tc.name      : PutBundlePropertyValueToDisturbeDB_00100
392  * @tc.number    :
393  * @tc.desc      : Put bundle property value to disturbeDB, return is true.
394  */
395 HWTEST_F(NotificationPreferencesDatabaseTest, PutBundlePropertyValueToDisturbeDB_00100, Function | SmallTest | Level1)
396 {
397     NotificationPreferencesInfo::BundleInfo info;
398     ASSERT_EQ(true, preferncesDB_->PutBundlePropertyValueToDisturbeDB(info));
399 }
400 
401 /**
402  * @tc.number    : ChangeSlotToEntry_00100
403  * @tc.name      :
404  * @tc.desc      : Change slot to entry.
405  */
406 HWTEST_F(NotificationPreferencesDatabaseTest, ChangeSlotToEntry_00100, Function | SmallTest | Level1)
407 {
408     sptr<NotificationSlot> slot = new NotificationSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION);
409     std::unordered_map<std::string, std::string> values;
410     EXPECT_TRUE(preferncesDB_->SlotToEntry(bundleName_, bundleUid_, slot, values));
411 }
412 
413 /**
414  * @tc.name      : CheckBundle_00100
415  * @tc.number    :
416  * @tc.desc      :Check bundle is exsit, return true when exsiting, create a bundle when does not exsit.
417  */
418 HWTEST_F(NotificationPreferencesDatabaseTest, CheckBundle_00100, Function | SmallTest | Level1)
419 {
420     ASSERT_EQ(true, preferncesDB_->CheckBundle(bundleName_, bundleUid_));
421 }
422 
423 /**
424  * @tc.number    : PutBundlePropertyToDisturbeDB_00100
425  * @tc.name      : PutBundlePropertyToDisturbeDB
426  * @tc.desc      : Test PutBundlePropertyToDisturbeDB function return is true
427  * @tc.require   : issueI5S4VP
428  */
429 HWTEST_F(NotificationPreferencesDatabaseTest, PutBundlePropertyToDisturbeDB_00100, Function | SmallTest | Level1)
430 {
431     NotificationPreferencesInfo::BundleInfo bundleInfo;
432     bundleInfo.SetBundleName(bundleName_);
433     bundleInfo.SetBundleUid(bundleUid_);
434     ASSERT_EQ(preferncesDB_->PutBundlePropertyToDisturbeDB(bundleInfo), false);
435 }
436 
437 /**
438  * @tc.number    : RemoveAllSlotsFromDisturbeDB_00100
439  * @tc.name      : RemoveAllSlotsFromDisturbeDB
440  * @tc.desc      : Test RemoveAllSlotsFromDisturbeDB function return is true
441  * @tc.require   : issueI5S4VP
442  */
443 HWTEST_F(NotificationPreferencesDatabaseTest, RemoveAllSlotsFromDisturbeDB_00100, Function | SmallTest | Level1)
444 {
445     std::string bundleKey = "BundleKey";
446     ASSERT_EQ(preferncesDB_->RemoveAllSlotsFromDisturbeDB(bundleKey, -1), true);
447 }
448 
449 /**
450  * @tc.number    : RemoveNotificationEnable_00100
451  * @tc.name      : RemoveNotificationEnable
452  * @tc.desc      : Test RemoveNotificationEnable function when parameter is normal return is true
453  * @tc.require   : issueI5SR8J
454  */
455 HWTEST_F(NotificationPreferencesDatabaseTest, RemoveNotificationEnable_00100, Function | SmallTest | Level1)
456 {
457     int32_t userId = 1;
458     ASSERT_EQ(preferncesDB_->RemoveNotificationEnable(userId), true);
459 }
460 
461 /**
462  * @tc.number    : RemoveDoNotDisturbDate_00100
463  * @tc.name      : RemoveDoNotDisturbDate
464  * @tc.desc      : Test RemoveDoNotDisturbDate function when parameter is normal return is true
465  * @tc.require   : issueI5SR8J
466  */
467 HWTEST_F(NotificationPreferencesDatabaseTest, RemoveDoNotDisturbDate_00100, Function | SmallTest | Level1)
468 {
469     int32_t userId = 1;
470     ASSERT_EQ(preferncesDB_->RemoveDoNotDisturbDate(userId), true);
471 }
472 
473 /**
474  * @tc.number    : ParseBundlePropertyFromDisturbeDB_00100
475  * @tc.name      : ParseBundlePropertyFromDisturbeDB
476  */
477 HWTEST_F(NotificationPreferencesDatabaseTest, ParseBundlePropertyFromDisturbeDB_00100, Function | SmallTest | Level1)
478 {
479     NotificationPreferencesInfo::BundleInfo bundleInfo;
480     bundleInfo.SetBundleName(bundleName_);
481     bundleInfo.SetBundleUid(bundleUid_);
482     std::string bundleKey = "bundleKey";
483     std::pair<std::string, std::string> entry;
484     entry.first = "ans_bundle_bundleKey_name";
485     entry.second = "1";
486     ASSERT_NE(nullptr, preferncesDB_);
487     preferncesDB_->ParseBundlePropertyFromDisturbeDB(bundleInfo, bundleKey, entry);
488 }
489 
490 /**
491  * @tc.number    : ParseBundlePropertyFromDisturbeDB_00200
492  * @tc.name      : ParseBundlePropertyFromDisturbeDB
493  */
494 HWTEST_F(NotificationPreferencesDatabaseTest, ParseBundlePropertyFromDisturbeDB_00200, Function | SmallTest | Level1)
495 {
496     NotificationPreferencesInfo::BundleInfo bundleInfo;
497     bundleInfo.SetBundleName(bundleName_);
498     bundleInfo.SetBundleUid(bundleUid_);
499     std::string bundleKey = "bundleKey";
500     std::pair<std::string, std::string> entry;
501     entry.first = "ans_bundle_bundleKey_importance";
502     entry.second = "1";
503     ASSERT_NE(nullptr, preferncesDB_);
504     preferncesDB_->ParseBundlePropertyFromDisturbeDB(bundleInfo, bundleKey, entry);
505 }
506 
507 /**
508  * @tc.number    : ParseBundlePropertyFromDisturbeDB_00300
509  * @tc.name      : ParseBundlePropertyFromDisturbeDB
510  */
511 HWTEST_F(NotificationPreferencesDatabaseTest, ParseBundlePropertyFromDisturbeDB_00300, Function | SmallTest | Level1)
512 {
513     NotificationPreferencesInfo::BundleInfo bundleInfo;
514     bundleInfo.SetBundleName(bundleName_);
515     bundleInfo.SetBundleUid(bundleUid_);
516     std::string bundleKey = "bundleKey";
517     std::pair<std::string, std::string> entry;
518     entry.first = "ans_bundle_bundleKey_showBadge";
519     entry.second = "1";
520     ASSERT_NE(nullptr, preferncesDB_);
521     preferncesDB_->ParseBundlePropertyFromDisturbeDB(bundleInfo, bundleKey, entry);
522 }
523 
524 /**
525  * @tc.number    : ParseBundlePropertyFromDisturbeDB_00400
526  * @tc.name      : ParseBundlePropertyFromDisturbeDB
527  */
528 HWTEST_F(NotificationPreferencesDatabaseTest, ParseBundlePropertyFromDisturbeDB_00400, Function | SmallTest | Level1)
529 {
530     NotificationPreferencesInfo::BundleInfo bundleInfo;
531     bundleInfo.SetBundleName(bundleName_);
532     bundleInfo.SetBundleUid(bundleUid_);
533     std::string bundleKey = "bundleKey";
534     std::pair<std::string, std::string> entry;
535     entry.first = "ans_bundle_bundleKey_badgeTotalNum";
536     entry.second = "1";
537     ASSERT_NE(nullptr, preferncesDB_);
538     preferncesDB_->ParseBundlePropertyFromDisturbeDB(bundleInfo, bundleKey, entry);
539 }
540 
541 /**
542  * @tc.number    : ParseBundlePropertyFromDisturbeDB_00500
543  * @tc.name      : ParseBundlePropertyFromDisturbeDB
544  */
545 HWTEST_F(NotificationPreferencesDatabaseTest, ParseBundlePropertyFromDisturbeDB_00500, Function | SmallTest | Level1)
546 {
547     NotificationPreferencesInfo::BundleInfo bundleInfo;
548     bundleInfo.SetBundleName(bundleName_);
549     bundleInfo.SetBundleUid(bundleUid_);
550     std::string bundleKey = "bundleKey";
551     std::pair<std::string, std::string> entry;
552     entry.first = "ans_bundle_bundleKey_privateAllowed";
553     entry.second = "1";
554     ASSERT_NE(nullptr, preferncesDB_);
555     preferncesDB_->ParseBundlePropertyFromDisturbeDB(bundleInfo, bundleKey, entry);
556 }
557 
558 /**
559  * @tc.number    : ParseBundlePropertyFromDisturbeDB_00600
560  * @tc.name      : ParseBundlePropertyFromDisturbeDB
561  */
562 HWTEST_F(NotificationPreferencesDatabaseTest, ParseBundlePropertyFromDisturbeDB_00600, Function | SmallTest | Level1)
563 {
564     NotificationPreferencesInfo::BundleInfo bundleInfo;
565     bundleInfo.SetBundleName(bundleName_);
566     bundleInfo.SetBundleUid(bundleUid_);
567     std::string bundleKey = "bundleKey";
568     std::pair<std::string, std::string> entry;
569     entry.first = "ans_bundle_bundleKey_enabledNotification";
570     entry.second = "1";
571     ASSERT_NE(nullptr, preferncesDB_);
572     preferncesDB_->ParseBundlePropertyFromDisturbeDB(bundleInfo, bundleKey, entry);
573 }
574 
575 /**
576  * @tc.number    : ParseBundlePropertyFromDisturbeDB_00700
577  * @tc.name      : ParseBundlePropertyFromDisturbeDB
578  */
579 HWTEST_F(NotificationPreferencesDatabaseTest, ParseBundlePropertyFromDisturbeDB_00700, Function | SmallTest | Level1)
580 {
581     NotificationPreferencesInfo::BundleInfo bundleInfo;
582     bundleInfo.SetBundleName(bundleName_);
583     bundleInfo.SetBundleUid(bundleUid_);
584     std::string bundleKey = "bundleKey";
585     std::pair<std::string, std::string> entry;
586     entry.first = "ans_bundle_bundleKey_poppedDialog";
587     entry.second = "1";
588     ASSERT_NE(nullptr, preferncesDB_);
589     preferncesDB_->ParseBundlePropertyFromDisturbeDB(bundleInfo, bundleKey, entry);
590 }
591 
592 /**
593  * @tc.number    : ParseBundlePropertyFromDisturbeDB_00800
594  * @tc.name      : ParseBundlePropertyFromDisturbeDB
595  */
596 HWTEST_F(NotificationPreferencesDatabaseTest, ParseBundlePropertyFromDisturbeDB_00800, Function | SmallTest | Level1)
597 {
598     NotificationPreferencesInfo::BundleInfo bundleInfo;
599     bundleInfo.SetBundleName(bundleName_);
600     bundleInfo.SetBundleUid(bundleUid_);
601     std::string bundleKey = "bundleKey";
602     std::pair<std::string, std::string> entry;
603     entry.first = "ans_bundle_bundleKey_uid";
604     entry.second = "1";
605     ASSERT_NE(nullptr, preferncesDB_);
606     preferncesDB_->ParseBundlePropertyFromDisturbeDB(bundleInfo, bundleKey, entry);
607 }
608 
609 /**
610  * @tc.number    : ParseBundlePropertyFromDisturbeDB_00900
611  * @tc.name      : ParseBundlePropertyFromDisturbeDB
612  */
613 HWTEST_F(NotificationPreferencesDatabaseTest, ParseBundlePropertyFromDisturbeDB_00900, Function | SmallTest | Level1)
614 {
615     NotificationPreferencesInfo::BundleInfo bundleInfo;
616     bundleInfo.SetBundleName(bundleName_);
617     bundleInfo.SetBundleUid(bundleUid_);
618     std::string bundleKey = "bundleKey";
619     std::pair<std::string, std::string> entry;
620     entry.first = "ans_bundle_bundleKey_showBadgeEnable";
621     entry.second = "1";
622     ASSERT_NE(nullptr, preferncesDB_);
623     preferncesDB_->ParseBundlePropertyFromDisturbeDB(bundleInfo, bundleKey, entry);
624     auto show = bundleInfo.GetIsShowBadge();
625     ASSERT_TRUE(show);
626 }
627 
628 /**
629  * @tc.number    : ParseBundlePropertyFromDisturbeDB_01000
630  * @tc.name      : ParseBundlePropertyFromDisturbeDB
631  */
632 HWTEST_F(NotificationPreferencesDatabaseTest, ParseBundlePropertyFromDisturbeDB_01000, Function | SmallTest | Level1)
633 {
634     NotificationPreferencesInfo::BundleInfo bundleInfo;
635     bundleInfo.SetBundleName(bundleName_);
636     bundleInfo.SetBundleUid(bundleUid_);
637     std::string bundleKey = "bundleKey";
638     std::pair<std::string, std::string> entry;
639     entry.first = "ans_bundle_bundleKey_bundleReminderFlagsType";
640     entry.second = "1";
641     ASSERT_NE(nullptr, preferncesDB_);
642     preferncesDB_->ParseBundlePropertyFromDisturbeDB(bundleInfo, bundleKey, entry);
643     auto show = bundleInfo.GetSlotFlags();
644     ASSERT_EQ(show, 1);
645 }
646 
647 /**
648  * @tc.number    : ParseSlotFromDisturbeDB_00100
649  * @tc.name      : ParseSlotFromDisturbeDB
650  */
651 HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_00100, Function | SmallTest | Level1)
652 {
653     NotificationPreferencesInfo::BundleInfo bundleInfo;
654     bundleInfo.SetBundleName(bundleName_);
655     bundleInfo.SetBundleUid(bundleUid_);
656     std::string bundleKey = "bundleKey";
657     std::pair<std::string, std::string> entry;
658     entry.first = "ans_bundle_bundleKey_slot_type_1_id";
659     entry.second = "1";
660     ASSERT_NE(nullptr, preferncesDB_);
661     preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry, -1);
662 }
663 
664 /**
665  * @tc.number    : ParseSlotFromDisturbeDB_00200
666  * @tc.name      : ParseSlotFromDisturbeDB
667  */
668 HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_00200, Function | SmallTest | Level1)
669 {
670     NotificationPreferencesInfo::BundleInfo bundleInfo;
671     bundleInfo.SetBundleName(bundleName_);
672     bundleInfo.SetBundleUid(bundleUid_);
673     std::string bundleKey = "bundleKey";
674     std::pair<std::string, std::string> entry;
675     entry.first = "ans_bundle_bundleKey_slot_type_1_name";
676     entry.second = "1";
677     ASSERT_NE(nullptr, preferncesDB_);
678     preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry, -1);
679 }
680 
681 /**
682  * @tc.number    : ParseSlotFromDisturbeDB_00300
683  * @tc.name      : ParseSlotFromDisturbeDB
684  */
685 HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_00300, Function | SmallTest | Level1)
686 {
687     NotificationPreferencesInfo::BundleInfo bundleInfo;
688     bundleInfo.SetBundleName(bundleName_);
689     bundleInfo.SetBundleUid(bundleUid_);
690     std::string bundleKey = "bundleKey";
691     std::pair<std::string, std::string> entry;
692     entry.first = "ans_bundle_bundleKey_slot_type_1_description";
693     entry.second = "1";
694     ASSERT_NE(nullptr, preferncesDB_);
695     preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry, -1);
696 }
697 
698 /**
699  * @tc.number    : ParseSlotFromDisturbeDB_00400
700  * @tc.name      : ParseSlotFromDisturbeDB
701  */
702 HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_00400, Function | SmallTest | Level1)
703 {
704     NotificationPreferencesInfo::BundleInfo bundleInfo;
705     bundleInfo.SetBundleName(bundleName_);
706     bundleInfo.SetBundleUid(bundleUid_);
707     std::string bundleKey = "bundleKey";
708     std::pair<std::string, std::string> entry;
709     entry.first = "ans_bundle_bundleKey_slot_type_1_level";
710     entry.second = "1";
711     ASSERT_NE(nullptr, preferncesDB_);
712     preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry, -1);
713 }
714 
715 /**
716  * @tc.number    : ParseSlotFromDisturbeDB_00500
717  * @tc.name      : ParseSlotFromDisturbeDB
718  */
719 HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_00500, Function | SmallTest | Level1)
720 {
721     NotificationPreferencesInfo::BundleInfo bundleInfo;
722     bundleInfo.SetBundleName(bundleName_);
723     bundleInfo.SetBundleUid(bundleUid_);
724     std::string bundleKey = "bundleKey";
725     std::pair<std::string, std::string> entry;
726     entry.first = "ans_bundle_bundleKey_slot_type_1_showBadge";
727     entry.second = "1";
728     ASSERT_NE(nullptr, preferncesDB_);
729     preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry, -1);
730 }
731 
732 /**
733  * @tc.number    : ParseSlotFromDisturbeDB_00600
734  * @tc.name      : ParseSlotFromDisturbeDB
735  */
736 HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_00600, Function | SmallTest | Level1)
737 {
738     NotificationPreferencesInfo::BundleInfo bundleInfo;
739     bundleInfo.SetBundleName(bundleName_);
740     bundleInfo.SetBundleUid(bundleUid_);
741     std::string bundleKey = "bundleKey";
742     std::pair<std::string, std::string> entry;
743     entry.first = "ans_bundle_bundleKey_slot_type_1_enableLight";
744     entry.second = "1";
745     ASSERT_NE(nullptr, preferncesDB_);
746     preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry, -1);
747 }
748 
749 /**
750  * @tc.number    : ParseSlotFromDisturbeDB_00700
751  * @tc.name      : ParseSlotFromDisturbeDB
752  */
753 HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_00700, Function | SmallTest | Level1)
754 {
755     NotificationPreferencesInfo::BundleInfo bundleInfo;
756     bundleInfo.SetBundleName(bundleName_);
757     bundleInfo.SetBundleUid(bundleUid_);
758     std::string bundleKey = "bundleKey";
759     std::pair<std::string, std::string> entry;
760     entry.first = "ans_bundle_bundleKey_slot_type_1_enableVibration";
761     entry.second = "1";
762     ASSERT_NE(nullptr, preferncesDB_);
763     preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry, -1);
764 }
765 
766 /**
767  * @tc.number    : ParseSlotFromDisturbeDB_00800
768  * @tc.name      : ParseSlotFromDisturbeDB
769  */
770 HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_00800, Function | SmallTest | Level1)
771 {
772     NotificationPreferencesInfo::BundleInfo bundleInfo;
773     bundleInfo.SetBundleName(bundleName_);
774     bundleInfo.SetBundleUid(bundleUid_);
775     std::string bundleKey = "bundleKey";
776     std::pair<std::string, std::string> entry;
777     entry.first = "ans_bundle_bundleKey_slot_type_1_ledLightColor";
778     entry.second = "1";
779     ASSERT_NE(nullptr, preferncesDB_);
780     preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry, -1);
781 }
782 
783 /**
784  * @tc.number    : ParseSlotFromDisturbeDB_00900
785  * @tc.name      : ParseSlotFromDisturbeDB
786  */
787 HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_00900, Function | SmallTest | Level1)
788 {
789     NotificationPreferencesInfo::BundleInfo bundleInfo;
790     bundleInfo.SetBundleName(bundleName_);
791     bundleInfo.SetBundleUid(bundleUid_);
792     std::string bundleKey = "bundleKey";
793     std::pair<std::string, std::string> entry;
794     entry.first = "ans_bundle_bundleKey_slot_type_1_lockscreenVisibleness";
795     entry.second = "1";
796     ASSERT_NE(nullptr, preferncesDB_);
797     preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry, -1);
798 }
799 
800 /**
801  * @tc.number    : ParseSlotFromDisturbeDB_01000
802  * @tc.name      : ParseSlotFromDisturbeDB
803  */
804 HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_01000, Function | SmallTest | Level1)
805 {
806     NotificationPreferencesInfo::BundleInfo bundleInfo;
807     bundleInfo.SetBundleName(bundleName_);
808     bundleInfo.SetBundleUid(bundleUid_);
809     std::string bundleKey = "bundleKey";
810     std::pair<std::string, std::string> entry;
811     entry.first = "ans_bundle_bundleKey_slot_type_1_sound";
812     entry.second = "1";
813     ASSERT_NE(nullptr, preferncesDB_);
814     preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry, -1);
815 }
816 
817 /**
818  * @tc.number    : ParseSlotFromDisturbeDB_01100
819  * @tc.name      : ParseSlotFromDisturbeDB
820  */
821 HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_01100, Function | SmallTest | Level1)
822 {
823     NotificationPreferencesInfo::BundleInfo bundleInfo;
824     bundleInfo.SetBundleName(bundleName_);
825     bundleInfo.SetBundleUid(bundleUid_);
826     std::string bundleKey = "bundleKey";
827     std::pair<std::string, std::string> entry;
828     entry.first = "ans_bundle_bundleKey_slot_type_1_vibrationSytle";
829     entry.second = "1";
830     ASSERT_NE(nullptr, preferncesDB_);
831     preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry, -1);
832 }
833 
834 /**
835  * @tc.number    : ParseSlotFromDisturbeDB_01200
836  * @tc.name      : ParseSlotFromDisturbeDB
837  */
838 HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_01200, Function | SmallTest | Level1)
839 {
840     NotificationPreferencesInfo::BundleInfo bundleInfo;
841     bundleInfo.SetBundleName(bundleName_);
842     bundleInfo.SetBundleUid(bundleUid_);
843     std::string bundleKey = "bundleKey";
844     std::pair<std::string, std::string> entry;
845     entry.first = "ans_bundle_bundleKey_slot_type_1_enableBypassDnd";
846     entry.second = "1";
847     ASSERT_NE(nullptr, preferncesDB_);
848     preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry, -1);
849 }
850 
851 /**
852  * @tc.number    : ParseSlotFromDisturbeDB_01300
853  * @tc.name      : ParseSlotFromDisturbeDB
854  */
855 HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_01300, Function | SmallTest | Level1)
856 {
857     NotificationPreferencesInfo::BundleInfo bundleInfo;
858     bundleInfo.SetBundleName(bundleName_);
859     bundleInfo.SetBundleUid(bundleUid_);
860     std::string bundleKey = "bundleKey";
861     std::pair<std::string, std::string> entry;
862     entry.first = "ans_bundle_bundleKey_slot_type_1_enabled";
863     entry.second = "1";
864     ASSERT_NE(nullptr, preferncesDB_);
865     preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry, -1);
866 }
867 
868 /**
869  * @tc.number    : ParseSlotFromDisturbeDB_01400
870  * @tc.name      : ParseSlotFromDisturbeDB
871  */
872 HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_01400, Function | SmallTest | Level1)
873 {
874     NotificationPreferencesInfo::BundleInfo bundleInfo;
875     bundleInfo.SetBundleName(bundleName_);
876     bundleInfo.SetBundleUid(bundleUid_);
877     std::string bundleKey = "bundleKey";
878     std::pair<std::string, std::string> entry;
879     entry.first = "ans_bundle_bundleKey_slot_type_1_reminderFlagsType";
880     entry.second = "1";
881     ASSERT_NE(nullptr, preferncesDB_);
882     preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry, -1);
883 }
884 
885 /**
886  * @tc.number    : ParseSlotFromDisturbeDB_01500
887  * @tc.name      : ParseSlotFromDisturbeDB
888  */
889 HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_01500, Function | SmallTest | Level1)
890 {
891     NotificationPreferencesInfo::BundleInfo bundleInfo;
892     bundleInfo.SetBundleName(bundleName_);
893     bundleInfo.SetBundleUid(bundleUid_);
894     std::string bundleKey = "bundleKey";
895     std::pair<std::string, std::string> entry;
896     entry.first = "ans_bundle_bundleKey_slot_type_1_authorizedStatus";
897     entry.second = "1";
898     ASSERT_NE(nullptr, preferncesDB_);
899     preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry, -1);
900 }
901 
902 /**
903  * @tc.number    : ParseSlotFromDisturbeDB_01600
904  * @tc.name      : ParseSlotFromDisturbeDB
905  */
906 HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_01600, Function | SmallTest | Level1)
907 {
908     NotificationPreferencesInfo::BundleInfo bundleInfo;
909     bundleInfo.SetBundleName(bundleName_);
910     bundleInfo.SetBundleUid(bundleUid_);
911     std::string bundleKey = "bundleKey";
912     std::pair<std::string, std::string> entry;
913     entry.first = "ans_bundle_bundleKey_slot_type_1_authHintCnt";
914     entry.second = "1";
915     ASSERT_NE(nullptr, preferncesDB_);
916     preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry, -1);
917 }
918 
919 /**
920  * @tc.number    : ParseSlotFromDisturbeDB_01700
921  * @tc.name      : ParseSlotFromDisturbeDB
922  */
923 HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_01700, Function | SmallTest | Level1)
924 {
925     NotificationPreferencesInfo::BundleInfo bundleInfo;
926     bundleInfo.SetBundleName(bundleName_);
927     bundleInfo.SetBundleUid(bundleUid_);
928     std::string bundleKey = "bundleKey";
929     std::pair<std::string, std::string> entry;
930     entry.first = "ans_bundle_bundleKey_slot_type_1_reminderMode";
931     entry.second = "1";
932     ASSERT_NE(nullptr, preferncesDB_);
933     preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry, -1);
934 }
935 
936 /**
937  * @tc.number    : ParseSlotFromDisturbeDB_01800
938  * @tc.name      : ParseSlotFromDisturbeDB
939  */
940 HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_01800, Function | SmallTest | Level1)
941 {
942     NotificationPreferencesInfo::BundleInfo bundleInfo;
943     bundleInfo.SetBundleName(bundleName_);
944     bundleInfo.SetBundleUid(bundleUid_);
945     std::string bundleKey = "bundleKey";
946     std::pair<std::string, std::string> entry;
947     entry.first = "ans_bundle_bundleKey_slot_type_1_vibrationSytle";
948     entry.second = "1";
949     ASSERT_NE(nullptr, preferncesDB_);
950     preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry, -1);
951 }
952 
953 /**
954  * @tc.name      : PutHasPoppedDialog_00100
955  * @tc.number    :
956  * @tc.desc      : Put bundle total badge nums into disturbe DB, return is true.
957  * @tc.require   : issueI62SME
958  */
959 HWTEST_F(NotificationPreferencesDatabaseTest, PutHasPoppedDialog_00100, Function | SmallTest | Level1)
960 {
961     NotificationPreferencesInfo::BundleInfo bundleInfo;
962     bundleInfo.SetBundleName(bundleName_);
963     bundleInfo.SetBundleUid(bundleUid_);
964     EXPECT_TRUE(preferncesDB_->PutHasPoppedDialog(bundleInfo, 0));
965 }
966 
967 /**
968  * @tc.number    : PutHasPoppedDialog_00200
969  * @tc.name      :
970  * @tc.desc      : Put bundle total badge nums into disturbe DB when bundle name is null, return is false.
971  * @tc.require   : #issueI62SME
972  */
973 HWTEST_F(NotificationPreferencesDatabaseTest, PutHasPoppedDialog_00200, Function | SmallTest | Level1)
974 {
975     NotificationPreferencesInfo::BundleInfo bundleInfo;
976     bundleInfo.SetBundleName(std::string());
977     bundleInfo.SetBundleUid(bundleUid_);
978     EXPECT_FALSE(preferncesDB_->PutHasPoppedDialog(bundleInfo, 0));
979 }
980 
981 /**
982  * @tc.number    : PutDoNotDisturbDate_00500
983  * @tc.name      :
984  * @tc.desc      : Put disturbe mode into disturbe DB when date is nullptr, return is false.
985  * @tc.require   : #issueI62SME
986  */
987 HWTEST_F(NotificationPreferencesDatabaseTest, PutDoNotDisturbDate_00500, Function | SmallTest | Level1)
988 {
989     int32_t userId = 0;
990     ASSERT_EQ(preferncesDB_->PutDoNotDisturbDate(userId, nullptr), false);
991 }
992 
993 /**
994  * @tc.number    : RemoveAllSlotsFromDisturbeDB_00200
995  * @tc.name      : RemoveAllSlotsFromDisturbeDB
996  * @tc.desc      : Test RemoveAllSlotsFromDisturbeDB function return is true
997  * @tc.require   : #issueI62SME
998  */
999 HWTEST_F(NotificationPreferencesDatabaseTest, RemoveAllSlotsFromDisturbeDB_00200, Function | SmallTest | Level1)
1000 {
1001     std::string bundleKey = "";
1002     ASSERT_EQ(preferncesDB_->RemoveAllSlotsFromDisturbeDB(bundleKey, -1), false);
1003 }
1004 
1005 /**
1006  * @tc.number    : ChangeSlotToEntry_00200
1007  * @tc.name      :
1008  * @tc.desc      : Change slot to entry.
1009  * @tc.require   : #issueI62SME
1010  */
1011 HWTEST_F(NotificationPreferencesDatabaseTest, ChangeSlotToEntry_00200, Function | SmallTest | Level1)
1012 {
1013     std::unordered_map<std::string, std::string> values;
1014     ASSERT_EQ(preferncesDB_->SlotToEntry(bundleName_, bundleUid_, nullptr, values), false);
1015 }
1016 
1017 /**
1018  * @tc.name: SetSmartReminderEnabled_0100
1019  * @tc.desc: test SetSmartReminderEnabled with parameters
1020  * @tc.type: FUNC
1021  */
1022 HWTEST_F(NotificationPreferencesDatabaseTest, SetSmartReminderEnabled_0100, TestSize.Level1)
1023 {
1024     bool enable = true;
1025     bool ret = preferncesDB_->SetSmartReminderEnabled("testDeviceType1111", enable);
1026     ASSERT_EQ(ret, true);
1027 }
1028 
1029 /**
1030  * @tc.name: IsSmartReminderEnabled_0100
1031  * @tc.desc: test IsSmartReminderEnabled with parameters, expect errorCode ERR_ANS_SERVICE_NOT_CONNECTED
1032  * @tc.type: FUNC
1033  */
1034 HWTEST_F(NotificationPreferencesDatabaseTest, IsSmartReminderEnabled_0100, TestSize.Level1)
1035 {
1036     bool enable = true;
1037     bool result = preferncesDB_->IsSmartReminderEnabled("testDeviceType1111", enable);
1038     ASSERT_EQ(result, true);
1039 }
1040 
1041 /**
1042  * @tc.name      : GetAllNotificationEnabledBundles_00100
1043  * @tc.number    : GetAllNotificationEnabledBundles
1044  * @tc.desc      : Check func GetAllNotificationEnabledBundles, return true
1045  */
1046 HWTEST_F(NotificationPreferencesDatabaseTest, GetAllNotificationEnabledBundles_00100, Function | SmallTest | Level1)
1047 {
1048     std::vector<NotificationBundleOption> bundleOption;
1049     ASSERT_EQ(true, preferncesDB_->GetAllNotificationEnabledBundles(bundleOption));
1050 }
1051 
1052 /**
1053  * @tc.name      : GetAllNotificationEnabledBundles_00200
1054  * @tc.number    : GetAllNotificationEnabledBundles
1055  * @tc.desc      : Check func GetAllNotificationEnabledBundles,no data in db return false
1056  */
1057 HWTEST_F(NotificationPreferencesDatabaseTest, GetAllNotificationEnabledBundles_00200, Function | SmallTest | Level1)
1058 {
1059     preferncesDB_->rdbDataManager_ = nullptr;
1060     std::vector<NotificationBundleOption> bundleOption;
1061     ASSERT_EQ(false, preferncesDB_->GetAllNotificationEnabledBundles(bundleOption));
1062 }
1063 
1064 /**
1065  * @tc.number    : RemoveAnsBundleDbInfo_00200
1066  * @tc.name      :
1067  * @tc.desc      : Test RemoveAnsBundleDbInfo function.
1068  * @tc.require   : #issueI62SME
1069  */
1070 HWTEST_F(NotificationPreferencesDatabaseTest, RemoveAnsBundleDbInfo_00200, Function | SmallTest | Level1)
1071 {
1072     std::string bundleName = "bundleName";
1073     int32_t uid = 1;
1074     ASSERT_EQ(preferncesDB_->RemoveAnsBundleDbInfo(bundleName, uid), true);
1075 }
1076 
1077 /**
1078  * @tc.name: GenerateBundleLablel_0100
1079  * @tc.desc: test GenerateBundleLablel with parameters
1080  * @tc.type: FUNC
1081  */
1082 HWTEST_F(NotificationPreferencesDatabaseTest, GenerateBundleLablel_0100, TestSize.Level1)
1083 {
1084     NotificationPreferencesInfo::BundleInfo bundleInfo;
1085     bundleInfo.SetBundleName("name");
1086     bundleInfo.SetBundleUid(1);
1087     std::string deviceType = "test";
1088     auto ret = preferncesDB_->GenerateBundleLablel(bundleInfo, deviceType);
1089     ASSERT_EQ(ret, "enabledDistributedNotification-name-1-test");
1090 }
1091 
1092 /**
1093  * @tc.name: GenerateBundleLablel_0100
1094  * @tc.desc: test GenerateBundleLablel
1095  * @tc.type: FUNC
1096  */
1097 HWTEST_F(NotificationPreferencesDatabaseTest, GenerateBundleLablel_0200, TestSize.Level1)
1098 {
1099     NotificationConstant::SlotType slotType = NotificationConstant::SlotType::SOCIAL_COMMUNICATION;
1100     std::string deviceType = "test";
1101     auto res = preferncesDB_->GenerateBundleLablel(slotType, deviceType, userId);
1102     ASSERT_EQ(res, "enabledSlotDistributedNotification-test-0-100");
1103 }
1104 
1105 /**
1106  * @tc.name: PutDistributedEnabledForBundle_0100
1107  * @tc.desc: test PutDistributedEnabledForBundle with parameters
1108  * @tc.type: FUNC
1109  */
1110 HWTEST_F(NotificationPreferencesDatabaseTest, PutDistributedEnabledForBundle_0100, TestSize.Level1)
1111 {
1112     NotificationPreferencesInfo::BundleInfo bundleInfo;
1113     bundleInfo.SetBundleName("name");
1114     bundleInfo.SetBundleUid(1);
1115     std::string deviceType = "testDeviceType1111";
1116     bool enable = true;
1117     bool ret = preferncesDB_->PutDistributedEnabledForBundle(deviceType, bundleInfo, enable);
1118     ASSERT_EQ(ret, true);
1119 }
1120 
1121 /**
1122  * @tc.name: PutDistributedEnabledForBundle_0200
1123  * @tc.desc: test PutDistributedEnabledForBundle with parameters
1124  * @tc.type: FUNC
1125  */
1126 HWTEST_F(NotificationPreferencesDatabaseTest, PutDistributedEnabledForBundle_0200, TestSize.Level1)
1127 {
1128     NotificationPreferencesInfo::BundleInfo bundleInfo;
1129     bundleInfo.SetBundleName("");
1130     bundleInfo.SetBundleUid(1);
1131     std::string deviceType = "testDeviceType1111";
1132     bool enable = true;
1133     bool ret = preferncesDB_->PutDistributedEnabledForBundle(deviceType, bundleInfo, enable);
1134     ASSERT_EQ(ret, false);
1135 }
1136 
1137 /**
1138  * @tc.name: GetDistributedEnabledForBundle_0100
1139  * @tc.desc: test GetDistributedEnabledForBundle with parameters, expect errorCode ERR_ANS_SERVICE_NOT_CONNECTED
1140  * @tc.type: FUNC
1141  */
1142 HWTEST_F(NotificationPreferencesDatabaseTest, GetDistributedEnabledForBundle_0100, TestSize.Level1)
1143 {
1144     NotificationPreferencesInfo::BundleInfo bundleInfo;
1145     bundleInfo.SetBundleName("name");
1146     bundleInfo.SetBundleUid(1);
1147     std::string deviceType = "testDeviceType1111";
1148     bool enable = true;
1149     bool result = preferncesDB_->GetDistributedEnabledForBundle(deviceType, bundleInfo, enable);
1150     ASSERT_EQ(result, true);
1151 }
1152 
1153 /**
1154  * @tc.name: GetDistributedEnabledForBundle_0200
1155  * @tc.desc: test GetDistributedEnabledForBundle with parameters, expect errorCode ERR_ANS_SERVICE_NOT_CONNECTED
1156  * @tc.type: FUNC
1157  */
1158 HWTEST_F(NotificationPreferencesDatabaseTest, GetDistributedEnabledForBundle_0200, TestSize.Level1)
1159 {
1160     NotificationPreferencesInfo::BundleInfo bundleInfo;
1161     bundleInfo.SetBundleName("");
1162     bundleInfo.SetBundleUid(1);
1163     std::string deviceType = "testDeviceType1111";
1164     bool enable = true;
1165     bool result = preferncesDB_->GetDistributedEnabledForBundle(deviceType, bundleInfo, enable);
1166     ASSERT_EQ(result, false);
1167 }
1168 
1169 /**
1170  * @tc.name: GetDistributedAuthStatus_0100
1171  * @tc.desc: test GetDistributedAuthStatus with invalid accountLocalId
1172  * @tc.type: FUNC
1173  */
1174 HWTEST_F(NotificationPreferencesDatabaseTest, GetDistributedAuthStatus_0100, TestSize.Level1)
1175 {
1176     MockOsAccountManager::MockGetForegroundOsAccountLocalId(-1);
1177     std::string deviceType = "deviceType";
1178     std::string deviceId = "deviceId";
1179     int32_t targetUserId = 100;
1180     bool isAuth;
1181     bool result = preferncesDB_->GetDistributedAuthStatus(deviceType, deviceId, targetUserId, isAuth);
1182     MockOsAccountManager::MockGetForegroundOsAccountLocalId(100);
1183     ASSERT_EQ(result, false);
1184     ASSERT_EQ(isAuth, false);
1185 }
1186 
1187 /**
1188  * @tc.name: GetDistributedAuthStatus_0200
1189  * @tc.desc: test GetDistributedAuthStatus when NativeRdb::E_EMPTY_VALUES_BUCKET
1190  * @tc.type: FUNC
1191  */
1192 HWTEST_F(NotificationPreferencesDatabaseTest, GetDistributedAuthStatus_0200, TestSize.Level1)
1193 {
1194     std::string deviceType = "deviceType";
1195     std::string deviceId = "deviceId";
1196     int32_t targetUserId = 100;
1197     bool isAuth;
1198     bool result = preferncesDB_->GetDistributedAuthStatus(deviceType, deviceId, targetUserId, isAuth);
1199     ASSERT_EQ(result, true);
1200     ASSERT_EQ(isAuth, false);
1201 }
1202 
1203 /**
1204  * @tc.name: GetDistributedAuthStatus_0300
1205  * @tc.desc: test GetDistributedAuthStatus when NativeRdb::E_OK
1206  * @tc.type: FUNC
1207  */
1208 HWTEST_F(NotificationPreferencesDatabaseTest, GetDistributedAuthStatus_0300, TestSize.Level1)
1209 {
1210     std::string deviceType = "deviceType";
1211     std::string deviceId = "deviceId";
1212     int32_t targetUserId = 100;
1213     bool isAuth = true;
1214     bool result = preferncesDB_->SetDistributedAuthStatus(deviceType, deviceId, targetUserId, isAuth);
1215     ASSERT_EQ(result, true);
1216     result = preferncesDB_->GetDistributedAuthStatus(deviceType, deviceId, targetUserId, isAuth);
1217     ASSERT_EQ(result, true);
1218     ASSERT_EQ(isAuth, true);
1219 }
1220 
1221 /**
1222  * @tc.name: SetDistributedAuthStatus_0100
1223  * @tc.desc: test SetDistributedAuthStatus with invalid accountLocalId
1224  * @tc.type: FUNC
1225  */
1226 HWTEST_F(NotificationPreferencesDatabaseTest, SetDistributedAuthStatus_0100, TestSize.Level1)
1227 {
1228     MockOsAccountManager::MockGetForegroundOsAccountLocalId(-1);
1229     std::string deviceType = "deviceType";
1230     std::string deviceId = "deviceId";
1231     int32_t targetUserId = 100;
1232     bool isAuth = true;
1233     bool result = preferncesDB_->SetDistributedAuthStatus(deviceType, deviceId, targetUserId, isAuth);
1234     MockOsAccountManager::MockGetForegroundOsAccountLocalId(100);
1235     ASSERT_EQ(result, false);
1236 }
1237 
1238 /**
1239  * @tc.name: AddDoNotDisturbProfiles_0100
1240  * @tc.desc: test AddDoNotDisturbProfiles run success.
1241  * @tc.type: FUNC
1242  */
1243 HWTEST_F(NotificationPreferencesDatabaseTest, AddDoNotDisturbProfiles_0100, TestSize.Level1)
1244 {
1245     int32_t userId = 1;
1246     std::vector<sptr<NotificationDoNotDisturbProfile>> profiles;
1247     sptr<NotificationDoNotDisturbProfile> profile = new (std::nothrow) NotificationDoNotDisturbProfile();
1248     profile->SetProfileId(1);
1249     profile->SetProfileName("Name");
1250     std::string bundleName = "bundleName";
1251     int32_t uid = 1;
1252     NotificationBundleOption notificationBundleOption(bundleName, uid);
1253     vector<NotificationBundleOption> trustlist;
1254     trustlist.emplace_back(notificationBundleOption);
1255     profile->SetProfileTrustList(trustlist);
1256     profiles.emplace_back(profile);
1257 
1258     auto res = preferncesDB_->AddDoNotDisturbProfiles(userId, profiles);
1259     ASSERT_EQ(res, true);
1260 }
1261 
1262 /**
1263  * @tc.name: AddDoNotDisturbProfiles_0200
1264  * @tc.desc: test AddDoNotDisturbProfiles
1265  * @tc.type: FUNC
1266  */
1267 HWTEST_F(NotificationPreferencesDatabaseTest, AddDoNotDisturbProfiles_0200, TestSize.Level1)
1268 {
1269     std::vector<sptr<NotificationDoNotDisturbProfile>> profiles;
1270     sptr<NotificationDoNotDisturbProfile> profile = nullptr;
1271     profiles.push_back(profile);
1272     auto ret = preferncesDB_->AddDoNotDisturbProfiles(userId, profiles);
1273     ASSERT_FALSE(ret);
1274 }
1275 
1276 /**
1277  * @tc.name: RemoveDoNotDisturbProfiles_0100
1278  * @tc.desc: test RemoveDoNotDisturbProfiles run success.
1279  * @tc.type: FUNC
1280  */
1281 HWTEST_F(NotificationPreferencesDatabaseTest, RemoveDoNotDisturbProfiles_0100, TestSize.Level1)
1282 {
1283     int32_t userId = 1;
1284     std::vector<sptr<NotificationDoNotDisturbProfile>> profiles;
1285     sptr<NotificationDoNotDisturbProfile> profile = new (std::nothrow) NotificationDoNotDisturbProfile();
1286     profile->SetProfileId(1);
1287     profile->SetProfileName("Name");
1288     std::string bundleName = "bundleName";
1289     int32_t uid = 1;
1290     NotificationBundleOption notificationBundleOption(bundleName, uid);
1291     vector<NotificationBundleOption> trustlist;
1292     trustlist.emplace_back(notificationBundleOption);
1293     profile->SetProfileTrustList(trustlist);
1294     profiles.emplace_back(profile);
1295 
1296     preferncesDB_->AddDoNotDisturbProfiles(userId, profiles);
1297     auto res = preferncesDB_->RemoveDoNotDisturbProfiles(userId, profiles);
1298     ASSERT_EQ(res, true);
1299 }
1300 
1301 /**
1302  * @tc.name: RemoveDoNotDisturbProfiles_0200
1303  * @tc.desc: test RemoveDoNotDisturbProfiles
1304  * @tc.type: FUNC
1305  */
1306 HWTEST_F(NotificationPreferencesDatabaseTest, RemoveDoNotDisturbProfiles_0200, TestSize.Level1)
1307 {
1308     std::vector<sptr<NotificationDoNotDisturbProfile>> profiles;
1309     sptr<NotificationDoNotDisturbProfile> profile = nullptr;
1310     profiles.push_back(profile);
1311     auto ret = preferncesDB_->RemoveDoNotDisturbProfiles(userId, profiles);
1312     ASSERT_FALSE(ret);
1313 }
1314 
1315 /**
1316  * @tc.name: GetDoNotDisturbProfiles_0100
1317  * @tc.desc: test GetDoNotDisturbProfiles return of QueryData is not zero.
1318  * @tc.type: FUNC
1319  */
1320 HWTEST_F(NotificationPreferencesDatabaseTest, GetDoNotDisturbProfiles_0100, TestSize.Level1)
1321 {
1322     int32_t userId = 1;
1323     std::vector<sptr<NotificationDoNotDisturbProfile>> profiles;
1324     sptr<NotificationDoNotDisturbProfile> profile = new (std::nothrow) NotificationDoNotDisturbProfile();
1325     profiles.emplace_back(profile);
1326     preferncesDB_->AddDoNotDisturbProfiles(userId, profiles);
1327     std::string key;
1328     auto res = preferncesDB_->GetDoNotDisturbProfiles(key, profile, -1);
1329     ASSERT_EQ(res, false);
1330 }
1331 
1332 /**
1333  * @tc.name: GetDoNotDisturbProfile_0100
1334  * @tc.desc: test GetDoNotDisturbProfile when profiles is empty.
1335  * @tc.type: FUNC
1336  */
1337 HWTEST_F(NotificationPreferencesDatabaseTest, GetDoNotDisturbProfile_0100, TestSize.Level1)
1338 {
1339     NotificationPreferencesInfo info;
1340     int32_t userId = 1;
1341     preferncesDB_->GetDoNotDisturbProfile(info, userId);
1342     int32_t profileId = 1;
1343     sptr<NotificationDoNotDisturbProfile> profile;
1344     auto res = info.GetDoNotDisturbProfiles(profileId, userId, profile);
1345     auto infos = new (std::nothrow) NotificationPreferencesInfo();
1346     ASSERT_EQ(res, false);
1347 }
1348 
1349 /**
1350  * @tc.name: SetDisableNotificationInfo_0100
1351  * @tc.desc: test SetDisableNotificationInfo.
1352  * @tc.type: FUNC
1353  */
1354 HWTEST_F(NotificationPreferencesDatabaseTest, SetDisableNotificationInfo_0100, TestSize.Level1)
1355 {
1356     std::shared_ptr<NotificationPreferencesDatabase> notificationPreferencesDatabase =
1357         std::make_shared<NotificationPreferencesDatabase>();
1358     EXPECT_FALSE(notificationPreferencesDatabase->SetDisableNotificationInfo(nullptr));
1359 }
1360 
1361 /**
1362  * @tc.name: SetDisableNotificationInfo_0200
1363  * @tc.desc: test SetDisableNotificationInfo.
1364  * @tc.type: FUNC
1365  */
1366 HWTEST_F(NotificationPreferencesDatabaseTest, SetDisableNotificationInfo_0200, TestSize.Level1)
1367 {
1368     std::shared_ptr<NotificationPreferencesDatabase> notificationPreferencesDatabase =
1369         std::make_shared<NotificationPreferencesDatabase>();
1370     sptr<NotificationDisable> notificationDisable = new (std::nothrow) NotificationDisable();
1371     EXPECT_FALSE(notificationPreferencesDatabase->SetDisableNotificationInfo(notificationDisable));
1372 }
1373 
1374 /**
1375  * @tc.name: SetDisableNotificationInfo_0300
1376  * @tc.desc: test SetDisableNotificationInfo.
1377  * @tc.type: FUNC
1378  */
1379 HWTEST_F(NotificationPreferencesDatabaseTest, SetDisableNotificationInfo_0300, TestSize.Level1)
1380 {
1381     std::shared_ptr<NotificationPreferencesDatabase> notificationPreferencesDatabase =
1382         std::make_shared<NotificationPreferencesDatabase>();
1383     sptr<NotificationDisable> notificationDisable = new (std::nothrow) NotificationDisable();
1384     notificationDisable->SetDisabled(true);
1385     notificationDisable->SetBundleList({ "com.example.app" });
1386     EXPECT_TRUE(notificationPreferencesDatabase->SetDisableNotificationInfo(notificationDisable));
1387 }
1388 
1389 /**
1390  * @tc.name: GetDisableNotificationInfo_0100
1391  * @tc.desc: test GetDisableNotificationInfo.
1392  * @tc.type: FUNC
1393  */
1394 HWTEST_F(NotificationPreferencesDatabaseTest, GetDisableNotificationInfo_0100, TestSize.Level1)
1395 {
1396     std::shared_ptr<NotificationPreferencesDatabase> notificationPreferencesDatabase =
1397         std::make_shared<NotificationPreferencesDatabase>();
1398     sptr<NotificationDisable> notificationDisable = new (std::nothrow) NotificationDisable();
1399     notificationDisable->SetDisabled(true);
1400     notificationDisable->SetBundleList({ "com.example.app" });
1401     notificationPreferencesDatabase->SetDisableNotificationInfo(notificationDisable);
1402     NotificationDisable disable;
1403     EXPECT_TRUE(notificationPreferencesDatabase->GetDisableNotificationInfo(disable));
1404 }
1405 
1406 /**
1407  * @tc.name: IsDistributedEnabledEmptyForBundle_0100
1408  * @tc.desc: test IsDistributedEnabledEmptyForBundle
1409  * @tc.type: FUNC
1410  */
1411 HWTEST_F(NotificationPreferencesDatabaseTest, IsDistributedEnabledEmptyForBundle_0100, TestSize.Level1)
1412 {
1413     NotificationPreferencesInfo::BundleInfo bundleInfo;
1414     bundleInfo.SetBundleName("testBundleName");
1415     bundleInfo.SetBundleUid(1000);
1416     std::string deviceType = "testType";
1417     bool ret = preferncesDB_->IsDistributedEnabledEmptyForBundle(deviceType, bundleInfo);
1418     EXPECT_FALSE(ret);
1419 }
1420 
1421 /**
1422  * @tc.name: GetSmartReminderEnableFromCCM_0100
1423  * @tc.desc: test GetSmartReminderEnableFromCCM
1424  * @tc.type: FUNC
1425  */
1426 HWTEST_F(NotificationPreferencesDatabaseTest, GetSmartReminderEnableFromCCM_0100, TestSize.Level1)
1427 {
1428     std::string deviceType = "testType";
1429     bool enabled = true;
1430     preferncesDB_->GetSmartReminderEnableFromCCM(deviceType, enabled);
1431     EXPECT_FALSE(enabled);
1432     preferncesDB_->isCachedSmartReminderEnableList_ = true;
1433     preferncesDB_->smartReminderEnableList_.clear();
1434     preferncesDB_->GetSmartReminderEnableFromCCM(deviceType, enabled);
1435     EXPECT_FALSE(enabled);
1436     preferncesDB_->smartReminderEnableList_.push_back("test");
1437     preferncesDB_->GetSmartReminderEnableFromCCM(deviceType, enabled);
1438     EXPECT_FALSE(enabled);
1439     preferncesDB_->smartReminderEnableList_.push_back(deviceType);
1440     preferncesDB_->GetSmartReminderEnableFromCCM(deviceType, enabled);
1441     EXPECT_TRUE(enabled);
1442 }
1443 
1444 /**
1445  * @tc.name: GenerateSubscriberExistFlagKey_0100
1446  * @tc.desc: test GenerateSubscriberExistFlagKey
1447  * @tc.type: FUNC
1448  */
1449 HWTEST_F(NotificationPreferencesDatabaseTest, GenerateSubscriberExistFlagKey_0100, TestSize.Level1)
1450 {
1451     std::string deviceType = "testType";
1452     int32_t userId = 0;
1453     auto ret = preferncesDB_->GenerateSubscriberExistFlagKey(deviceType, userId);
1454     std::string flag = "existFlag";
1455     std::string middleLine = "-";
1456     std::string key = flag.append(middleLine).append(deviceType).append(middleLine).append(std::to_string(userId));
1457     ASSERT_EQ(ret, key);
1458 }
1459 
1460 /**
1461  * @tc.name: SetSubscriberExistFlag_0100
1462  * @tc.desc: test SetSubscriberExistFlag
1463  * @tc.type: FUNC
1464  */
1465 HWTEST_F(NotificationPreferencesDatabaseTest, SetSubscriberExistFlag_0100, TestSize.Level1)
1466 {
1467     auto ret = preferncesDB_->SetSubscriberExistFlag(DEVICE_TYPE_HEADSET, false);
1468     EXPECT_TRUE(ret);
1469     bool enabled = true;
1470     ret = preferncesDB_->GetSubscriberExistFlag(DEVICE_TYPE_HEADSET, enabled);
1471     EXPECT_TRUE(ret);
1472     EXPECT_FALSE(enabled);
1473 }
1474 
1475 /**
1476  * @tc.name: GetSubscriberExistFlag_0100
1477  * @tc.desc: test GetSubscriberExistFlag
1478  * @tc.type: FUNC
1479  */
1480 HWTEST_F(NotificationPreferencesDatabaseTest, GetSubscriberExistFlag_0100, TestSize.Level1)
1481 {
1482     auto ret = preferncesDB_->SetSubscriberExistFlag(DEVICE_TYPE_HEADSET, true);
1483     EXPECT_TRUE(ret);
1484     bool enabled = false;
1485     ret = preferncesDB_->GetSubscriberExistFlag(DEVICE_TYPE_HEADSET, enabled);
1486     EXPECT_TRUE(ret);
1487     EXPECT_TRUE(enabled);
1488 }
1489 
1490 /**
1491  * @tc.name: IsNotificationSlotFlagsExists_0100
1492  * @tc.desc: test IsNotificationSlotFlagsExists
1493  * @tc.type: FUNC
1494  */
1495 HWTEST_F(NotificationPreferencesDatabaseTest, IsNotificationSlotFlagsExists_0100, TestSize.Level1)
1496 {
1497     sptr<NotificationBundleOption> bundleOption = nullptr;
1498     auto ret = preferncesDB_->IsNotificationSlotFlagsExists(bundleOption);
1499     ASSERT_FALSE(ret);
1500 }
1501 
1502 /**
1503  * @tc.name: ParseFromDisturbeDB_0100
1504  * @tc.desc: test ParseFromDisturbeDB
1505  * @tc.type: FUNC
1506  */
1507 HWTEST_F(NotificationPreferencesDatabaseTest, ParseFromDisturbeDB_0100, TestSize.Level1)
1508 {
1509     NotificationPreferencesInfo preferencesInfo;
1510     auto ret = preferncesDB_->ParseFromDisturbeDB(preferencesInfo, userId);
1511     ASSERT_TRUE(ret);
1512 }
1513 
1514 /**
1515  * @tc.name: ParseBundleFromDistureDB_0100
1516  * @tc.desc: test ParseBundleFromDistureDB
1517  * @tc.type: FUNC
1518  */
1519 HWTEST_F(NotificationPreferencesDatabaseTest, ParseBundleFromDistureDB_0100, TestSize.Level1)
1520 {
1521     NotificationPreferencesInfo preferencesInfo;
1522     std::unordered_map<std::string, std::string> values;
1523     values["test"] =  "test";
1524     preferncesDB_->ParseBundleFromDistureDB(preferencesInfo, values, userId);
1525     ASSERT_EQ(1, preferencesInfo.infos_.size());
1526     preferencesInfo.infos_.clear();
1527 }
1528 
1529 /**
1530  * @tc.name: StringToVector_0100
1531  * @tc.desc: test StringToVector
1532  * @tc.type: FUNC
1533  */
1534 HWTEST_F(NotificationPreferencesDatabaseTest, StringToVector_0100, TestSize.Level1)
1535 {
1536     std::string str = "";
1537     std::vector<int64_t> data;
1538     preferncesDB_->StringToVector(str, data);
1539     ASSERT_EQ(0, data.size());
1540 }
1541 
1542 /**
1543  * @tc.name: StringToVector_0200
1544  * @tc.desc: test StringToVector
1545  * @tc.type: FUNC
1546  */
1547 HWTEST_F(NotificationPreferencesDatabaseTest, StringToVector_0200, TestSize.Level1)
1548 {
1549     std::string str = "1_2_3";
1550     std::vector<int64_t> data;
1551     preferncesDB_->StringToVector(str, data);
1552     ASSERT_EQ(2, data.size());
1553 }
1554 
1555 /**
1556  * @tc.name: GetByteFromDb_0100
1557  * @tc.desc: test GetByteFromDb
1558  * @tc.type: FUNC
1559  */
1560 HWTEST_F(NotificationPreferencesDatabaseTest, GetByteFromDb_0100, TestSize.Level1)
1561 {
1562     std::string key;
1563     std::vector<uint8_t> value;
1564     auto res = preferncesDB_->GetByteFromDb(key, value, userId);
1565     ASSERT_NE(res, ERR_OK);
1566 }
1567 
1568 /**
1569  * @tc.name: DeleteBatchKvFromDb_0100
1570  * @tc.desc: test DeleteBatchKvFromDb
1571  * @tc.type: FUNC
1572  */
1573 HWTEST_F(NotificationPreferencesDatabaseTest, DeleteBatchKvFromDb_0100, TestSize.Level1)
1574 {
1575     std::vector<std::string> keys;
1576     auto res = preferncesDB_->DeleteBatchKvFromDb(keys, userId);
1577     ASSERT_EQ(res, ERR_OK);
1578 }
1579 
1580 /**
1581  * @tc.name: SetDistributedEnabledBySlot_0100
1582  * @tc.desc: test SetDistributedEnabledBySlot
1583  * @tc.type: FUNC
1584  */
1585 HWTEST_F(NotificationPreferencesDatabaseTest, SetDistributedEnabledBySlot_0100, TestSize.Level1)
1586 {
1587     NotificationConstant::SlotType slotType = NotificationConstant::SlotType::SOCIAL_COMMUNICATION;
1588     std::string deviceType = "test1";
1589 
1590     auto res = preferncesDB_->SetDistributedEnabledBySlot(slotType, deviceType, true);
1591     ASSERT_EQ(res, true);
1592 
1593     bool enabled = false;
1594     res = preferncesDB_->IsDistributedEnabledBySlot(slotType, deviceType, enabled);
1595     ASSERT_EQ(res, true);
1596     ASSERT_EQ(enabled, true);
1597 }
1598 
1599 /**
1600  * @tc.name: SetDistributedEnabledBySlot_0200
1601  * @tc.desc: test SetDistributedEnabledBySlot
1602  * @tc.type: FUNC
1603  */
1604 HWTEST_F(NotificationPreferencesDatabaseTest, SetDistributedEnabledBySlot_0200, TestSize.Level1)
1605 {
1606     NotificationConstant::SlotType slotType = NotificationConstant::SlotType::SOCIAL_COMMUNICATION;
1607     std::string deviceType = "test2";
1608 
1609     bool enabled = false;
1610     auto res = preferncesDB_->IsDistributedEnabledBySlot(slotType, deviceType, enabled);
1611     ASSERT_EQ(res, true);
1612     ASSERT_EQ(enabled, true);
1613 }
1614 
1615 /**
1616  * @tc.name: UpdateBundlePropertyToDisturbeDB_0100
1617  * @tc.desc: test UpdateBundlePropertyToDisturbeDB
1618  * @tc.type: FUNC
1619  */
1620 HWTEST_F(NotificationPreferencesDatabaseTest, UpdateBundlePropertyToDisturbeDB_0100, TestSize.Level1)
1621 {
1622     NotificationPreferencesInfo::BundleInfo bundleInfo;
1623     bundleInfo.SetBundleName("test1");
1624     bundleInfo.SetBundleUid(1000);
1625 
1626     auto res = preferncesDB_->UpdateBundlePropertyToDisturbeDB(userId, bundleInfo);
1627     ASSERT_EQ(res, true);
1628 }
1629 
1630 /**
1631  * @tc.name: UpdateBundlePropertyToDisturbeDB_0200
1632  * @tc.desc: test UpdateBundlePropertyToDisturbeDB
1633  * @tc.type: FUNC
1634  */
1635 HWTEST_F(NotificationPreferencesDatabaseTest, UpdateBundlePropertyToDisturbeDB_0200, TestSize.Level1)
1636 {
1637     NotificationPreferencesInfo::BundleInfo bundleInfo;
1638     bundleInfo.SetBundleName("");
1639     bundleInfo.SetBundleUid(1000);
1640 
1641     auto res = preferncesDB_->UpdateBundlePropertyToDisturbeDB(userId, bundleInfo);
1642     ASSERT_EQ(res, false);
1643 }
1644 
1645 /**
1646  * @tc.name: IsAgentRelationship_0201
1647  * @tc.desc: test IsAgentRelationship
1648  * @tc.type: FUNC
1649  */
1650 HWTEST_F(NotificationPreferencesDatabaseTest, IsAgentRelationship_0201, TestSize.Level1)
1651 {
1652     std::string cacheString;
1653     preferncesDB_->GetValueFromDisturbeDB("PROXY_PKG", SUBSCRIBE_USER_INIT,
__anondf1e31d10102(const int32_t &status, std::string &value) 1654         [&](const int32_t &status, std::string &value) {
1655         switch (status) {
1656             case NativeRdb::E_OK: {
1657                 cacheString = value;
1658                 break;
1659             }
1660         }
1661     });
1662 
1663     std::string value = "[{\"app\":\"ohos.example.app\",\"service\":\"ohos.example.app\"}]";
1664     int32_t result = preferncesDB_->SetKvToDb("PROXY_PKG", value, SUBSCRIBE_USER_INIT);
1665     ASSERT_EQ(result, 0);
1666     bool isAgent = preferncesDB_->IsAgentRelationship("ohos.example.app", "ohos.example.app");
1667     ASSERT_EQ(isAgent, true);
1668     isAgent = preferncesDB_->IsAgentRelationship("ohos.example.app", "ohos.example.app1");
1669     ASSERT_EQ(isAgent, false);
1670     // delete data
1671     result = preferncesDB_->DeleteKvFromDb("PROXY_PKG", SUBSCRIBE_USER_INIT);
1672     ASSERT_EQ(result, 0);
1673     isAgent = preferncesDB_->IsAgentRelationship("ohos.example.app", "ohos.example.app");
1674     ASSERT_EQ(isAgent, false);
1675 
1676     // insert data not array
1677     value = "{\"app\":\"ohos.example.app\",\"service\":\"ohos.example.app\"}";
1678     result = preferncesDB_->SetKvToDb("PROXY_PKG", value, SUBSCRIBE_USER_INIT);
1679     ASSERT_EQ(result, 0);
1680     isAgent = preferncesDB_->IsAgentRelationship("ohos.example.app", "ohos.example.app");
1681     ASSERT_EQ(isAgent, false);
1682 
1683     // insert empty data
1684     result = preferncesDB_->SetKvToDb("PROXY_PKG", std::string(), SUBSCRIBE_USER_INIT);
1685     ASSERT_EQ(result, 0);
1686     isAgent = preferncesDB_->IsAgentRelationship("ohos.example.app", "ohos.example.app");
1687     ASSERT_EQ(isAgent, false);
1688 
1689     // recover data
1690     result = preferncesDB_->SetKvToDb("PROXY_PKG", cacheString, SUBSCRIBE_USER_INIT);
1691     ASSERT_EQ(result, 0);
1692 }
1693 
1694 /**
1695  * @tc.name: UpdateBundleSlotToDisturbeDB_0202
1696  * @tc.desc: test UpdateBundleSlotToDisturbeDB
1697  * @tc.type: FUNC
1698  */
1699 HWTEST_F(NotificationPreferencesDatabaseTest, UpdateBundleSlotToDisturbeDB_0202, TestSize.Level1)
1700 {
1701     int32_t userId = 100;
1702     int32_t bundleUid = 100000;
1703     std::string bundleName = "ohos.example.demo";
1704     std::vector<sptr<NotificationSlot>> slots;
1705     // updata empty slots
1706     bool result = preferncesDB_->UpdateBundleSlotToDisturbeDB(userId, bundleName, bundleUid, slots);
1707     ASSERT_EQ(result, true);
1708 
1709     sptr<NotificationSlot> slotInfo = new (std::nothrow) NotificationSlot(NotificationConstant::SlotType::LIVE_VIEW);
1710     slots.push_back(slotInfo);
1711     // update empty bundle name
1712     result = preferncesDB_->UpdateBundleSlotToDisturbeDB(userId, "", bundleUid, slots);
1713     ASSERT_EQ(result, false);
1714 
1715     // update slots
1716     result = preferncesDB_->UpdateBundleSlotToDisturbeDB(userId, bundleName, bundleUid, slots);
1717     ASSERT_EQ(result, true);
1718 }
1719 
1720 /**
1721  * @tc.name: DelBatchCloneBundleInfo_0203
1722  * @tc.desc: test DelBatchCloneBundleInfo
1723  * @tc.type: FUNC
1724  */
1725 HWTEST_F(NotificationPreferencesDatabaseTest, DelBatchCloneBundleInfo_0203, TestSize.Level1)
1726 {
1727     NotificationCloneBundleInfo bundleInfo;
1728     bundleInfo.SetAppIndex(0);
1729     bundleInfo.SetSlotFlags(59);
1730     bundleInfo.SetBundleName("ohos.example.demo");
1731     std::vector<NotificationCloneBundleInfo> cloneBundleInfo;
1732     cloneBundleInfo.push_back(bundleInfo);
1733     bool result = preferncesDB_->UpdateBatchCloneBundleInfo(100, cloneBundleInfo);
1734     ASSERT_EQ(result, true);
1735     result = preferncesDB_->DelBatchCloneBundleInfo(100, cloneBundleInfo);
1736     ASSERT_EQ(result, true);
1737 }
1738 
1739 /**
1740  * @tc.name: SetBundleRemoveFlag_0204
1741  * @tc.desc: test SetBundleRemoveFlag
1742  * @tc.type: FUNC
1743  */
1744 HWTEST_F(NotificationPreferencesDatabaseTest, SetBundleRemoveFlag_0204, TestSize.Level1)
1745 {
1746     sptr<NotificationBundleOption> bundle = nullptr;
1747     bool result = preferncesDB_->GetBundleRemoveFlag(bundle, NotificationConstant::SlotType::LIVE_VIEW, 1);
1748     ASSERT_EQ(result, true);
1749 
1750     bundle = new (std::nothrow) NotificationBundleOption("ohos.example.demo", 10000);
1751     result = preferncesDB_->GetBundleRemoveFlag(bundle, NotificationConstant::SlotType::LIVE_VIEW, 1);
1752     ASSERT_EQ(result, false);
1753     result = preferncesDB_->GetBundleRemoveFlag(bundle, NotificationConstant::SlotType::LIVE_VIEW, 2);
1754     ASSERT_EQ(result, false);
1755 
1756     result = preferncesDB_->SetBundleRemoveFlag(bundle, NotificationConstant::SlotType::LIVE_VIEW, 1);
1757     ASSERT_EQ(result, true);
1758     result = preferncesDB_->SetBundleRemoveFlag(bundle, NotificationConstant::SlotType::LIVE_VIEW, 2);
1759     ASSERT_EQ(result, true);
1760 
1761     result = preferncesDB_->GetBundleRemoveFlag(bundle, NotificationConstant::SlotType::LIVE_VIEW, 1);
1762     ASSERT_EQ(result, true);
1763 
1764     // delete data
1765     std::string key = "label_ans_remove_ohos.example.demo10000_5";
1766     int32_t res = preferncesDB_->DeleteKvFromDb(key, 100);
1767     ASSERT_EQ(res, 0);
1768     key = "label_ans_remove_2_ohos.example.demo10000_5";
1769     res = preferncesDB_->DeleteKvFromDb(key, 100);
1770     ASSERT_EQ(res, 0);
1771 }
1772 
1773 /**
1774  * @tc.name: DelCloneProfileInfo_0205
1775  * @tc.desc: test DelCloneProfileInfo
1776  * @tc.type: FUNC
1777  */
1778 HWTEST_F(NotificationPreferencesDatabaseTest, DelCloneProfileInfo_0205, TestSize.Level1)
1779 {
1780     NotificationBundleOption bundle1 = NotificationBundleOption("ohos.example.demo", 10000);
1781     NotificationBundleOption bundle2 = NotificationBundleOption("ohos.example.demo", 10001);
1782     std::vector<NotificationBundleOption> trustList;
1783     trustList.push_back(bundle1);
1784     trustList.push_back(bundle2);
1785 
1786     // update profile1 and profile2
1787     sptr<NotificationDoNotDisturbProfile> profile1 = new (std::nothrow) NotificationDoNotDisturbProfile();
1788     profile1->SetProfileId(1);
1789     profile1->SetProfileName("name1");
1790     profile1->SetProfileTrustList(trustList);
1791     sptr<NotificationDoNotDisturbProfile> profile2 = new (std::nothrow) NotificationDoNotDisturbProfile();
1792     profile2->SetProfileId(2);
1793     profile2->SetProfileName("name1");
1794     profile2->SetProfileTrustList(trustList);
1795     std::vector<sptr<NotificationDoNotDisturbProfile>> profileInfo;
1796     profileInfo.push_back(profile1);
1797     profileInfo.push_back(profile2);
1798     bool result = preferncesDB_->UpdateBatchCloneProfileInfo(100, profileInfo);
1799     ASSERT_EQ(result, true);
1800     // delete profile1
1801     result = preferncesDB_->DelCloneProfileInfo(100, profile1);
1802     ASSERT_EQ(result, true);
1803     std::vector<sptr<NotificationDoNotDisturbProfile>> tmpProfilesInfo;
1804     preferncesDB_->GetAllCloneProfileInfo(100, tmpProfilesInfo);
1805     ASSERT_EQ((int32_t)tmpProfilesInfo.size(), 1);
1806 
1807     std::vector<sptr<NotificationDoNotDisturbProfile>> deleteProfileInfo;
1808     deleteProfileInfo.push_back(profile2);
1809     result = preferncesDB_->DelBatchCloneProfileInfo(100, deleteProfileInfo);
1810     ASSERT_EQ(result, true);
1811 }
1812 
1813 /**
1814  * @tc.name: PutDistributedDevicelist_0100
1815  * @tc.desc: Test PutDistributedDevicelist
1816  * @tc.type: FUNC
1817  */
1818 HWTEST_F(NotificationPreferencesDatabaseTest, PutDistributedDevicelist_0100, TestSize.Level1)
1819 {
1820     preferncesDB_->rdbDataManager_ = nullptr;
1821     std::string deviceTypes = "deviceTypes";
1822     int32_t userId = 100;
1823     auto ret = preferncesDB_->PutDistributedDevicelist(deviceTypes, userId);
1824     ASSERT_EQ(ret, false);
1825 }
1826 
1827 /**
1828  * @tc.name: PutDistributedDevicelist_0200
1829  * @tc.desc: Test PutDistributedDevicelist
1830  * @tc.type: FUNC
1831  */
1832 HWTEST_F(NotificationPreferencesDatabaseTest, PutDistributedDevicelist_0200, TestSize.Level1)
1833 {
1834     preferncesDB_ = std::make_unique<NotificationPreferencesDatabase>();
1835     ASSERT_NE(preferncesDB_, nullptr);
1836     std::string deviceTypes = "deviceTypes";
1837     int32_t userId = 100;
1838     auto ret = preferncesDB_->PutDistributedDevicelist(deviceTypes, userId);
1839     ASSERT_EQ(ret, true);
1840 }
1841 
1842 /**
1843  * @tc.name: GetDistributedDevicelist_0100
1844  * @tc.desc: Test GetDistributedDevicelist
1845  * @tc.type: FUNC
1846  */
1847 HWTEST_F(NotificationPreferencesDatabaseTest, GetDistributedDevicelist_0100, TestSize.Level1)
1848 {
1849     std::string deviceTypes;
1850     int32_t userId = 100;
1851     auto ret = preferncesDB_->PutDistributedDevicelist(deviceTypes, userId);
1852     ASSERT_EQ(ret, true);
1853     ret = preferncesDB_->GetDistributedDevicelist(deviceTypes);
1854     ASSERT_EQ(ret, true);
1855 }
1856 
1857 /**
1858  * @tc.name: GetDistributedDevicelist_0200
1859  * @tc.desc: Test GetDistributedDevicelist
1860  * @tc.type: FUNC
1861  */
1862 HWTEST_F(NotificationPreferencesDatabaseTest, GetDistributedDevicelist_0200, TestSize.Level1)
1863 {
1864     std::string deviceTypes = "deviceTypes";
1865     int32_t userId = 100;
1866     auto ret = preferncesDB_->PutDistributedDevicelist(deviceTypes, userId);
1867     ASSERT_EQ(ret, true);
1868     ret = preferncesDB_->GetDistributedDevicelist(deviceTypes);
1869     ASSERT_EQ(ret, true);
1870     ASSERT_EQ(deviceTypes.empty(), false);
1871 }
1872 
1873 /**
1874  * @tc.name: GetDistributedDevicelist_0300
1875  * @tc.desc: Test GetDistributedDevicelist
1876  * @tc.type: FUNC
1877  */
1878 HWTEST_F(NotificationPreferencesDatabaseTest, GetDistributedDevicelist_0300, TestSize.Level1)
1879 {
1880     std::string deviceTypes1 = "deviceTypes1";
1881     int32_t userId1 = 100;
1882     auto ret = preferncesDB_->PutDistributedDevicelist(deviceTypes1, userId1);
1883     ASSERT_EQ(ret, true);
1884     std::string deviceTypes2 = "deviceTypes2";
1885     int32_t userId2 = 101;
1886     ret = preferncesDB_->PutDistributedDevicelist(deviceTypes2, userId2);
1887     ASSERT_EQ(ret, true);
1888     std::string deviceTypes;
1889     ret = preferncesDB_->GetDistributedDevicelist(deviceTypes);
1890     ASSERT_EQ(ret, true);
1891     ASSERT_EQ(deviceTypes, deviceTypes1);
1892 }
1893 
1894 /**
1895  * @tc.name: SetDisableNotificationInfo_0400
1896  * @tc.desc: test SetDisableNotificationInfo.
1897  * @tc.type: FUNC
1898  */
1899 HWTEST_F(NotificationPreferencesDatabaseTest, SetDisableNotificationInfo_0400, TestSize.Level1)
1900 {
1901     std::shared_ptr<NotificationPreferencesDatabase> notificationPreferencesDatabase =
1902         std::make_shared<NotificationPreferencesDatabase>();
1903     sptr<NotificationDisable> notificationDisable = new (std::nothrow) NotificationDisable();
1904     notificationDisable->SetDisabled(true);
1905     notificationDisable->SetBundleList({ "com.example.app" });
1906     notificationDisable->SetUserId(101);
1907     EXPECT_TRUE(notificationPreferencesDatabase->SetDisableNotificationInfo(notificationDisable));
1908 }
1909 }  // namespace Notification
1910 }  // namespace OHOS
1911