1 /*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include <gtest/gtest.h>
16 #include <functional>
17
18 #include "advanced_notification_service.h"
19 #include "ans_const_define.h"
20 #include "ans_inner_errors.h"
21 #include "ans_manager_proxy.h"
22 #include "if_system_ability_manager.h"
23 #include "iservice_registry.h"
24 #include "notification_helper.h"
25 #include "remote_native_token.h"
26 #include "system_ability_definition.h"
27
28 using namespace testing::ext;
29 namespace OHOS {
30 namespace Notification {
31 const int32_t SLEEP_TIME = 1;
32 static sptr<ISystemAbilityManager> systemAbilityManager =
33 SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
34
35 class AnsInnerKitsModuleSlotTest : public testing::Test {
36 public:
37 static void SetUpTestCase();
38 static void TearDownTestCase();
39 void SetUp();
40 void TearDown();
41 };
42
SetUpTestCase()43 void AnsInnerKitsModuleSlotTest::SetUpTestCase()
44 {
45 RemoteNativeToken::SetNativeToken();
46 sptr<AdvancedNotificationService> service = OHOS::Notification::AdvancedNotificationService::GetInstance();
47 OHOS::ISystemAbilityManager::SAExtraProp saExtraProp;
48 systemAbilityManager->AddSystemAbility(OHOS::ADVANCED_NOTIFICATION_SERVICE_ABILITY_ID, service, saExtraProp);
49 }
50
TearDownTestCase()51 void AnsInnerKitsModuleSlotTest::TearDownTestCase()
52 {}
53
SetUp()54 void AnsInnerKitsModuleSlotTest::SetUp()
55 {
56 NotificationHelper::RemoveAllSlots();
57 }
58
TearDown()59 void AnsInnerKitsModuleSlotTest::TearDown()
60 {}
61
62 /**
63 * @tc.number : ANS_Interface_MT_NotificationSlot_00100
64 * @tc.name : NotificationSlot_00100
65 * @tc.desc : Add notification slot(type is SOCIAL_COMMUNICATION), get notification slot and remove notification
66 * slot.
67 * @tc.expected : Add notification slot success, get notification slot correctly and remove notification slot success.
68 */
69 HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_NotificationSlot_00100, Function | MediumTest | Level1)
70 {
71 NotificationSlot slot(NotificationConstant::SOCIAL_COMMUNICATION);
72 slot.SetEnableLight(true);
73 slot.SetDescription("description");
74 slot.SetLedLightColor(0);
75 slot.SetLevel(NotificationSlot::NotificationLevel::LEVEL_LOW);
76 slot.SetSound(Uri("."));
77 std::vector<int64_t> style;
78 style.push_back(0);
79 slot.SetVibrationStyle(style);
80 slot.EnableBypassDnd(true);
81 slot.EnableBadge(true);
82 EXPECT_EQ(0, NotificationHelper::AddNotificationSlot(slot));
83 sleep(SLEEP_TIME);
84
85 sptr<NotificationSlot> spSlot;
86 EXPECT_EQ(0, NotificationHelper::GetNotificationSlot(NotificationConstant::SOCIAL_COMMUNICATION, spSlot));
87 EXPECT_NE(nullptr, spSlot);
88 GTEST_LOG_(INFO) << "after get slot dump slot information:" << spSlot->Dump();
89 EXPECT_EQ(true, spSlot->CanEnableLight());
90 EXPECT_EQ(true, spSlot->CanVibrate());
91 EXPECT_EQ("description", spSlot->GetDescription());
92 EXPECT_EQ("SOCIAL_COMMUNICATION", spSlot->GetId());
93 EXPECT_EQ(0, spSlot->GetLedLightColor());
94 EXPECT_EQ(NotificationSlot::NotificationLevel::LEVEL_LOW, spSlot->GetLevel());
95 EXPECT_EQ(NotificationConstant::SOCIAL_COMMUNICATION, spSlot->GetType());
96 EXPECT_EQ(NotificationConstant::VisiblenessType::PUBLIC, spSlot->GetLockScreenVisibleness());
97 EXPECT_EQ("SOCIAL_COMMUNICATION", spSlot->GetName());
98 EXPECT_EQ(Uri("."), spSlot->GetSound());
99 for (auto it : spSlot->GetVibrationStyle()) {
100 EXPECT_EQ(0, it);
101 }
102 EXPECT_EQ(Uri("."), spSlot->GetSound());
103 EXPECT_EQ(true, spSlot->IsEnableBypassDnd());
104 EXPECT_EQ(true, spSlot->IsShowBadge());
105 EXPECT_EQ(0, NotificationHelper::RemoveNotificationSlot(NotificationConstant::SOCIAL_COMMUNICATION));
106 EXPECT_EQ(0, NotificationHelper::GetNotificationSlot(NotificationConstant::SOCIAL_COMMUNICATION, spSlot));
107 }
108
109 /**
110 * @tc.number : ANS_Interface_MT_NotificationSlot_00200
111 * @tc.name : NotificationSlot_00200
112 * @tc.desc : Add notification slot(type is SERVICE_REMINDER), get notification slot and remove notification slot.
113 * @tc.expected : Add notification slot success, get notification slot correctly and remove notification slot success.
114 */
115 HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_NotificationSlot_00200, Function | MediumTest | Level1)
116 {
117 NotificationSlot slot(NotificationConstant::SERVICE_REMINDER);
118 slot.SetEnableLight(true);
119 slot.SetDescription("description");
120 slot.SetLedLightColor(0);
121 slot.SetLevel(NotificationSlot::NotificationLevel::LEVEL_LOW);
122 slot.SetSound(Uri("."));
123 std::vector<int64_t> style;
124 style.push_back(0);
125 slot.SetVibrationStyle(style);
126 slot.EnableBypassDnd(true);
127 slot.EnableBadge(true);
128 EXPECT_EQ(0, NotificationHelper::AddNotificationSlot(slot));
129 sleep(SLEEP_TIME);
130 sptr<NotificationSlot> spSlot;
131 EXPECT_EQ(0, NotificationHelper::GetNotificationSlot(NotificationConstant::SERVICE_REMINDER, spSlot));
132
133 EXPECT_NE(nullptr, spSlot);
134 EXPECT_EQ(true, spSlot->CanEnableLight());
135 EXPECT_EQ(true, spSlot->CanVibrate());
136 EXPECT_EQ("description", spSlot->GetDescription());
137 EXPECT_EQ("SERVICE_REMINDER", spSlot->GetId());
138 EXPECT_EQ(0, spSlot->GetLedLightColor());
139 EXPECT_EQ(NotificationSlot::NotificationLevel::LEVEL_LOW, spSlot->GetLevel());
140 EXPECT_EQ(NotificationConstant::SERVICE_REMINDER, spSlot->GetType());
141 EXPECT_EQ(NotificationConstant::VisiblenessType::PUBLIC, spSlot->GetLockScreenVisibleness());
142 EXPECT_EQ("SERVICE_REMINDER", spSlot->GetName());
143 EXPECT_EQ(Uri("."), spSlot->GetSound());
144 for (auto it : spSlot->GetVibrationStyle()) {
145 EXPECT_EQ(0, it);
146 }
147 EXPECT_EQ(Uri("."), spSlot->GetSound());
148 EXPECT_EQ(true, spSlot->IsEnableBypassDnd());
149 EXPECT_EQ(true, spSlot->IsShowBadge());
150 EXPECT_EQ(0, NotificationHelper::RemoveNotificationSlot(NotificationConstant::SERVICE_REMINDER));
151 EXPECT_EQ(0, NotificationHelper::GetNotificationSlot(NotificationConstant::SERVICE_REMINDER, spSlot));
152 }
153
154 /**
155 * @tc.number : ANS_Interface_MT_NotificationSlot_00300
156 * @tc.name : NotificationSlot_00300
157 * @tc.desc : Add notification slot(type is CONTENT_INFORMATION), get notification slot and remove notification
158 * slot.
159 * @tc.expected : Add notification slot success, get notification slot correctly and remove notification slot success.
160 */
161 HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_NotificationSlot_00300, Function | MediumTest | Level1)
162 {
163 NotificationSlot slot(NotificationConstant::CONTENT_INFORMATION);
164 slot.SetEnableLight(true);
165 slot.SetDescription("description");
166 slot.SetLedLightColor(0);
167 slot.SetLevel(NotificationSlot::NotificationLevel::LEVEL_LOW);
168 slot.SetSound(Uri("."));
169 std::vector<int64_t> style;
170 style.push_back(0);
171 slot.SetVibrationStyle(style);
172 slot.EnableBypassDnd(true);
173 slot.EnableBadge(true);
174 EXPECT_EQ(0, NotificationHelper::AddNotificationSlot(slot));
175 sleep(SLEEP_TIME);
176 sptr<NotificationSlot> spSlot;
177 EXPECT_EQ(0, NotificationHelper::GetNotificationSlot(NotificationConstant::CONTENT_INFORMATION, spSlot));
178
179 EXPECT_NE(nullptr, spSlot);
180 EXPECT_EQ(true, spSlot->CanEnableLight());
181 EXPECT_EQ(true, spSlot->CanVibrate());
182 EXPECT_EQ("description", spSlot->GetDescription());
183 EXPECT_EQ("CONTENT_INFORMATION", spSlot->GetId());
184 EXPECT_EQ(0, spSlot->GetLedLightColor());
185 EXPECT_EQ(NotificationSlot::NotificationLevel::LEVEL_LOW, spSlot->GetLevel());
186 EXPECT_EQ(NotificationConstant::CONTENT_INFORMATION, spSlot->GetType());
187 EXPECT_EQ(NotificationConstant::VisiblenessType::SECRET, spSlot->GetLockScreenVisibleness());
188 EXPECT_EQ("CONTENT_INFORMATION", spSlot->GetName());
189 EXPECT_EQ(Uri("."), spSlot->GetSound());
190 for (auto it : spSlot->GetVibrationStyle()) {
191 EXPECT_EQ(0, it);
192 }
193 EXPECT_EQ(Uri("."), spSlot->GetSound());
194 EXPECT_EQ(true, spSlot->IsEnableBypassDnd());
195 EXPECT_EQ(true, spSlot->IsShowBadge());
196 EXPECT_EQ(0, NotificationHelper::RemoveNotificationSlot(NotificationConstant::CONTENT_INFORMATION));
197 EXPECT_EQ(0, NotificationHelper::GetNotificationSlot(NotificationConstant::CONTENT_INFORMATION, spSlot));
198 }
199
200 /**
201 * @tc.number : ANS_Interface_MT_NotificationSlot_00400
202 * @tc.name : NotificationSlot_00400
203 * @tc.desc : Add notification slot(type is OTHER), get notification slot and remove notification slot.
204 * @tc.expected : Add notification slot success, get notification slot correctly and remove notification slot success.
205 */
206 HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_NotificationSlot_00400, Function | MediumTest | Level1)
207 {
208 NotificationSlot slot(NotificationConstant::OTHER);
209 slot.SetEnableLight(true);
210 slot.SetDescription("description");
211 slot.SetLedLightColor(0);
212 slot.SetLevel(NotificationSlot::NotificationLevel::LEVEL_LOW);
213 slot.SetSound(Uri("."));
214 std::vector<int64_t> style;
215 style.push_back(0);
216 slot.SetVibrationStyle(style);
217 slot.EnableBypassDnd(true);
218 slot.EnableBadge(true);
219 EXPECT_EQ(0, NotificationHelper::AddNotificationSlot(slot));
220 sleep(SLEEP_TIME);
221 sptr<NotificationSlot> spSlot;
222 EXPECT_EQ(0, NotificationHelper::GetNotificationSlot(NotificationConstant::OTHER, spSlot));
223
224 EXPECT_NE(nullptr, spSlot);
225 EXPECT_EQ(true, spSlot->CanEnableLight());
226 EXPECT_EQ(true, spSlot->CanVibrate());
227 EXPECT_EQ("description", spSlot->GetDescription());
228 EXPECT_EQ("OTHER", spSlot->GetId());
229 EXPECT_EQ(0, spSlot->GetLedLightColor());
230 EXPECT_EQ(NotificationSlot::NotificationLevel::LEVEL_LOW, spSlot->GetLevel());
231 EXPECT_EQ(NotificationConstant::OTHER, spSlot->GetType());
232 EXPECT_EQ(NotificationConstant::VisiblenessType::SECRET, spSlot->GetLockScreenVisibleness());
233 EXPECT_EQ("OTHER", spSlot->GetName());
234 EXPECT_EQ(Uri("."), spSlot->GetSound());
235 for (auto it : spSlot->GetVibrationStyle()) {
236 EXPECT_EQ(0, it);
237 }
238 EXPECT_EQ(Uri("."), spSlot->GetSound());
239 EXPECT_EQ(true, spSlot->IsEnableBypassDnd());
240 EXPECT_EQ(true, spSlot->IsShowBadge());
241 EXPECT_EQ(0, NotificationHelper::RemoveNotificationSlot(NotificationConstant::OTHER));
242 EXPECT_EQ(0, NotificationHelper::GetNotificationSlot(NotificationConstant::OTHER, spSlot));
243 }
244
245 /**
246 * @tc.number : ANS_Interface_MT_NotificationSlot_00500
247 * @tc.name : NotificationSlot_00500
248 * @tc.desc : Add notification slot(type is OTHER), slot set description character length exceed 1000
249 * characters, get notification slot and remove notification slot.
250 * @tc.expected : Add notification slot success, get notification slot correctly and remove notification slot success.
251 */
252 HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_NotificationSlot_00500, Function | MediumTest | Level1)
253 {
254 NotificationSlot slot(NotificationConstant::OTHER);
255 slot.SetEnableLight(true);
256 std::string description(2000, 'c');
257 slot.SetDescription(description);
258 slot.SetLedLightColor(0);
259 slot.SetLevel(NotificationSlot::NotificationLevel::LEVEL_LOW);
260 slot.SetSound(Uri("."));
261 std::vector<int64_t> style;
262 style.push_back(0);
263 slot.SetVibrationStyle(style);
264 slot.EnableBypassDnd(true);
265 slot.EnableBadge(true);
266 EXPECT_EQ(0, NotificationHelper::AddNotificationSlot(slot));
267 sleep(SLEEP_TIME);
268 sptr<NotificationSlot> spSlot;
269 EXPECT_EQ(0, NotificationHelper::GetNotificationSlot(NotificationConstant::OTHER, spSlot));
270
271 EXPECT_NE(nullptr, spSlot);
272 GTEST_LOG_(INFO) << "get slot is:" << spSlot->Dump();
273 EXPECT_EQ(true, spSlot->CanEnableLight());
274 EXPECT_EQ(true, spSlot->CanVibrate());
275 std::string expecteDescription(1000, 'c');
276 EXPECT_EQ(expecteDescription, spSlot->GetDescription());
277 EXPECT_EQ("OTHER", spSlot->GetId());
278 EXPECT_EQ(0, spSlot->GetLedLightColor());
279 EXPECT_EQ(NotificationSlot::NotificationLevel::LEVEL_LOW, spSlot->GetLevel());
280 EXPECT_EQ(NotificationConstant::OTHER, spSlot->GetType());
281 EXPECT_EQ(NotificationConstant::VisiblenessType::SECRET, spSlot->GetLockScreenVisibleness());
282 EXPECT_EQ("OTHER", spSlot->GetName());
283 EXPECT_EQ(Uri("."), spSlot->GetSound());
284 for (auto it : spSlot->GetVibrationStyle()) {
285 EXPECT_EQ(0, it);
286 }
287 EXPECT_EQ(Uri("."), spSlot->GetSound());
288 EXPECT_EQ(true, spSlot->IsEnableBypassDnd());
289 EXPECT_EQ(true, spSlot->IsShowBadge());
290 EXPECT_EQ(0, NotificationHelper::RemoveNotificationSlot(NotificationConstant::OTHER));
291 EXPECT_EQ(0, NotificationHelper::GetNotificationSlot(NotificationConstant::OTHER, spSlot));
292 }
293
294 /**
295 * @tc.number : ANS_Interface_MT_NotificationSlot_00600
296 * @tc.name : NotificationSlot_00600
297 * @tc.desc : Create notification slot(type is SOCIAL_COMMUNICATION), get sound and vibration.
298 * @tc.expected : Create notification slot success, get sound and vibration success.
299 */
300 HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_NotificationSlot_00600, Function | MediumTest | Level1)
301 {
302 NotificationSlot slot(NotificationConstant::SOCIAL_COMMUNICATION);
303 EXPECT_EQ("SOCIAL_COMMUNICATION", slot.GetName());
304 EXPECT_EQ(NotificationConstant::VisiblenessType::PUBLIC, slot.GetLockScreenVisibleness());
305 EXPECT_EQ(DEFAULT_NOTIFICATION_SOUND.ToString(), slot.GetSound().ToString());
306 EXPECT_TRUE(slot.CanVibrate());
307 EXPECT_EQ(DEFAULT_NOTIFICATION_VIBRATION, slot.GetVibrationStyle());
308 EXPECT_EQ(NotificationSlot::NotificationLevel::LEVEL_HIGH, slot.GetLevel());
309 }
310
311 /**
312 * @tc.number : ANS_Interface_MT_NotificationSlot_00700
313 * @tc.name : NotificationSlot_00700
314 * @tc.desc : Create notification slot(type is SERVICE_REMINDER), get sound and vibration.
315 * @tc.expected : Create notification slot success, get sound and vibration success.
316 */
317 HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_NotificationSlot_00700, Function | MediumTest | Level1)
318 {
319 NotificationSlot slot(NotificationConstant::SERVICE_REMINDER);
320 EXPECT_EQ("SERVICE_REMINDER", slot.GetName());
321 EXPECT_EQ(NotificationConstant::VisiblenessType::PUBLIC, slot.GetLockScreenVisibleness());
322 EXPECT_EQ(DEFAULT_NOTIFICATION_SOUND.ToString(), slot.GetSound().ToString());
323 EXPECT_TRUE(slot.CanVibrate());
324 EXPECT_EQ(DEFAULT_NOTIFICATION_VIBRATION, slot.GetVibrationStyle());
325 EXPECT_EQ(NotificationSlot::NotificationLevel::LEVEL_DEFAULT, slot.GetLevel());
326 }
327
328 /**
329 * @tc.number : ANS_Interface_MT_NotificationSlot_00800
330 * @tc.name : NotificationSlot_00800
331 * @tc.desc : Create notification slot(type is CONTENT_INFORMATION), get sound and vibration.
332 * @tc.expected : Create notification slot success, get sound and vibration success.
333 */
334 HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_NotificationSlot_00800, Function | MediumTest | Level1)
335 {
336 NotificationSlot slot(NotificationConstant::CONTENT_INFORMATION);
337 EXPECT_EQ("CONTENT_INFORMATION", slot.GetName());
338 EXPECT_EQ(NotificationConstant::VisiblenessType::SECRET, slot.GetLockScreenVisibleness());
339 EXPECT_EQ("", slot.GetSound().ToString());
340 EXPECT_FALSE(slot.CanVibrate());
341 EXPECT_EQ(0U, slot.GetVibrationStyle().size());
342 EXPECT_EQ(NotificationSlot::NotificationLevel::LEVEL_LOW, slot.GetLevel());
343 }
344
345 /**
346 * @tc.number : ANS_Interface_MT_NotificationSlot_00900
347 * @tc.name : NotificationSlot_00900
348 * @tc.desc : Create notification slot(type is OTHER), get sound and vibration.
349 * @tc.expected : Create notification slot success, get sound and vibration success.
350 */
351 HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_NotificationSlot_00900, Function | MediumTest | Level1)
352 {
353 NotificationSlot slot(NotificationConstant::OTHER);
354 EXPECT_EQ("OTHER", slot.GetName());
355 EXPECT_EQ(NotificationConstant::VisiblenessType::SECRET, slot.GetLockScreenVisibleness());
356 EXPECT_EQ("", slot.GetSound().ToString());
357 EXPECT_FALSE(slot.CanVibrate());
358 EXPECT_EQ(0U, slot.GetVibrationStyle().size());
359 EXPECT_EQ(NotificationSlot::NotificationLevel::LEVEL_MIN, slot.GetLevel());
360 }
361
362 /**
363 * @tc.number : ANS_Interface_MT_SetEnabledForBundleSlot_00100
364 * @tc.name : SetEnabledForBundleSlot_00100
365 * @tc.desc : Add notification slot(type is SOCIAL_COMMUNICATION), get slot default enable,
366 * set and get slot enable.
367 * @tc.expected : Add notification slot success, slot default enalbe is true, get is the same as setting.
368 */
369 HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_SetEnabledForBundleSlot_00100, Function | MediumTest | Level1)
370 {
371 NotificationSlot slot(NotificationConstant::SOCIAL_COMMUNICATION);
372 slot.SetEnableLight(true);
373 slot.SetDescription("description");
374 slot.SetLedLightColor(0);
375 slot.SetLevel(NotificationSlot::NotificationLevel::LEVEL_LOW);
376 slot.SetSound(Uri("."));
377 std::vector<int64_t> style;
378 style.push_back(0);
379 slot.SetVibrationStyle(style);
380 slot.EnableBypassDnd(true);
381 slot.EnableBadge(true);
382 EXPECT_EQ(0, NotificationHelper::AddNotificationSlot(slot));
383 sleep(SLEEP_TIME);
384 sptr<NotificationSlot> spSlot;
385 EXPECT_EQ(0, NotificationHelper::GetNotificationSlot(NotificationConstant::SOCIAL_COMMUNICATION, spSlot));
386 EXPECT_NE(spSlot, nullptr);
387 EXPECT_EQ(spSlot->GetEnable(), true);
388
389 bool enable = false;
390 NotificationBundleOption bo("bundlename", 1);
391 EXPECT_EQ(0, NotificationHelper::SetEnabledForBundleSlot(bo, NotificationConstant::SOCIAL_COMMUNICATION, enable));
392 EXPECT_EQ(0, NotificationHelper::GetEnabledForBundleSlot(bo, NotificationConstant::SOCIAL_COMMUNICATION, enable));
393 EXPECT_EQ(enable, false);
394 }
395
396 /**
397 * @tc.number : ANS_Interface_MT_SetEnabledForBundleSlot_00200
398 * @tc.name : SetEnabledForBundleSlot_00200
399 * @tc.desc : Add slot when there is no type slot, add it. (SOCIAL_COMMUNICATION)
400 * @tc.expected : Set success, and get success.
401 */
402 HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_SetEnabledForBundleSlot_00200, Function | MediumTest | Level1)
403 {
404 bool enable = true;
405 NotificationBundleOption bo("bundleName", 1);
406 EXPECT_EQ(0, NotificationHelper::SetEnabledForBundleSlot(bo, NotificationConstant::SOCIAL_COMMUNICATION, enable));
407 enable = false;
408 EXPECT_EQ(0, NotificationHelper::GetEnabledForBundleSlot(bo, NotificationConstant::SOCIAL_COMMUNICATION, enable));
409 EXPECT_EQ(enable, true);
410
411 sptr<NotificationSlot> spSlot;
412 EXPECT_EQ(0, NotificationHelper::GetNotificationSlot(NotificationConstant::SOCIAL_COMMUNICATION, spSlot));
413 EXPECT_NE(spSlot, nullptr);
414 EXPECT_EQ(spSlot->GetEnable(), true);
415 }
416
417 /**
418 * @tc.number : ANS_Interface_MT_SetEnabledForBundleSlot_00300
419 * @tc.name : SetEnabledForBundleSlot_00300
420 * @tc.desc : Add slot when there is no type slot, add it. (SERVICE_REMINDER)
421 * @tc.expected : Set false, and get false.
422 */
423 HWTEST_F(AnsInnerKitsModuleSlotTest, ANS_Interface_MT_SetEnabledForBundleSlot_00300, Function | MediumTest | Level1)
424 {
425 bool enable = false;
426 NotificationBundleOption bo("bundleName", 1);
427 EXPECT_EQ(0, NotificationHelper::SetEnabledForBundleSlot(bo, NotificationConstant::SERVICE_REMINDER, enable));
428 enable = true;
429 EXPECT_EQ(0, NotificationHelper::GetEnabledForBundleSlot(bo, NotificationConstant::SERVICE_REMINDER, enable));
430 EXPECT_EQ(enable, false);
431
432 sptr<NotificationSlot> spSlot;
433 EXPECT_EQ(0, NotificationHelper::GetNotificationSlot(NotificationConstant::SERVICE_REMINDER, spSlot));
434 EXPECT_NE(spSlot, nullptr);
435 EXPECT_EQ(spSlot->GetEnable(), false);
436 }
437 } // namespace Notification
438 } // namespace OHOS