diff --git a/test/resource/ansSTSlotGroupTest/BUILD.gn b/test/resource/ansSTSlotGroupTest/BUILD.gn index 0018e05b840f2547a2eb17956731e8261e8eb40c..8dbed1163f3d0ed7e52a95760dc8286000cd33e3 100644 --- a/test/resource/ansSTSlotGroupTest/BUILD.gn +++ b/test/resource/ansSTSlotGroupTest/BUILD.gn @@ -67,6 +67,6 @@ ohos_shared_library("libraryAnsSTSlotGroupTest") { "ipc:ipc_core", ] - subsystem_name = "notification" - part_name = "ans_standard" + subsystem_name = "anssystemtest" + part_name = "test" } diff --git a/test/resource/ansSTSlotGroupTest/config.json b/test/resource/ansSTSlotGroupTest/config.json index bc9a6fa50b65f0b256ddc25fa1a567dc449810d1..9228a94af690e366f17630db89cd5a0cd7eb190d 100644 --- a/test/resource/ansSTSlotGroupTest/config.json +++ b/test/resource/ansSTSlotGroupTest/config.json @@ -30,6 +30,7 @@ "abilities": [{ "name": "AnsSlotGroupSystemTest", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AnsSlotGroupSystemTest Ability zofa label", "launchType": "singletop", "orientation": "unspecified", diff --git a/test/resource/ansSTSlotGroupTest/src/ans_slotgroup_test.cpp b/test/resource/ansSTSlotGroupTest/src/ans_slotgroup_test.cpp index a1efa3a98c2a369eb6c15714eff37e2dc62ebd69..ac933f8011044b179392e5577fb42e19bc2c19c3 100644 --- a/test/resource/ansSTSlotGroupTest/src/ans_slotgroup_test.cpp +++ b/test/resource/ansSTSlotGroupTest/src/ans_slotgroup_test.cpp @@ -20,49 +20,90 @@ namespace OHOS { namespace AppExecFwk { void AnsSlotGroupSystemTest::OnStart(const Want &want) { - APP_LOGI("====> ans SlotGroup test start====>"); - Notification::NotificationSlotGroup notificationSlotGroupTest("id_test", "name_test"); - - if (notificationSlotGroupTest.GetId().empty()) { - ANS_LOGI("====> Notification slot group id is invalid====>"); + APP_LOGI("====>Ans SlotGroup test start:====>"); + Notification::NotificationSlotGroup slotGroupTest("id_test", "name_test"); + if (slotGroupTest.GetId().empty()) { + ANS_LOGI("====>Notification slot group id is invalid====>"); } else { - ANS_LOGI("====> Notification slot group id is====> %{public}s", notificationSlotGroupTest.GetId().c_str()); + ANS_LOGI("====>Notification slot group id is====> %{public}s", slotGroupTest.GetId().c_str()); } - - ErrCode errcodeAdd = Notification::NotificationHelper::AddNotificationSlotGroup(notificationSlotGroupTest); - APP_LOGI("====> ansSlotGroupTest add:====> %{public}d", errcodeAdd); - - Notification::NotificationSlot notificationSlotFirst( - Notification::NotificationConstant::SlotType::SOCIAL_COMMUNICATION); - Notification::NotificationSlot notificationSlotSecond( - Notification::NotificationConstant::SlotType::SERVICE_REMINDER); - - notificationSlotFirst.SetSlotGroup("id_test"); - notificationSlotSecond.SetSlotGroup("id_test"); - - ErrCode errcodeAddSlotFirst = Notification::NotificationHelper::AddNotificationSlot(notificationSlotFirst); - ErrCode errcodeAddSlotSecond = Notification::NotificationHelper::AddNotificationSlot(notificationSlotSecond); - - APP_LOGI("====> ansSlotGroupTest errcodeAddSlotFirst:====> %{public}d", errcodeAddSlotFirst); - APP_LOGI("====> ansSlotGroupTest errcodeAddSlotSecond:====> %{public}d", errcodeAddSlotSecond); + ErrCode errAddGroupTest = Notification::NotificationHelper::AddNotificationSlotGroup(slotGroupTest); + APP_LOGI("====>add a SlotGroup with id name id_test, ErrCode is====> %{public}d", errAddGroupTest); + + Notification::NotificationSlot slotFirst(Notification::NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + Notification::NotificationSlot slotSecond(Notification::NotificationConstant::SlotType::SERVICE_REMINDER); + Notification::NotificationSlot slotThird(Notification::NotificationConstant::SlotType::CONTENT_INFORMATION); + Notification::NotificationSlot slotFourth(Notification::NotificationConstant::SlotType::OTHER); + Notification::NotificationSlot slotFifth(Notification::NotificationConstant::SlotType::CUSTOM); + + slotFirst.SetSlotGroup("id_test"); + slotSecond.SetSlotGroup("id_test"); + slotThird.SetSlotGroup("id_test"); + slotFourth.SetSlotGroup("id_test"); + slotFifth.SetSlotGroup("id_test"); + + ErrCode errAddSlotFirst = Notification::NotificationHelper::AddNotificationSlot(slotFirst); + ErrCode errAddSlotSecond = Notification::NotificationHelper::AddNotificationSlot(slotSecond); + ErrCode errAddSlotThird = Notification::NotificationHelper::AddNotificationSlot(slotThird); + ErrCode errAddSlotFourth = Notification::NotificationHelper::AddNotificationSlot(slotFourth); + ErrCode errAddSlotFifth = Notification::NotificationHelper::AddNotificationSlot(slotFifth); + + APP_LOGI("====>add SOCIAL_COMMUNICATION type slot, ErrCode is====> %{public}d", errAddSlotFirst); + APP_LOGI("====>add SERVICE_REMINDER type slot, ErrCode is====> %{public}d", errAddSlotSecond); + APP_LOGI("====>add CONTENT_INFORMATION type slot, ErrCode is====> %{public}d", errAddSlotThird); + APP_LOGI("====>add OTHER type slot, ErrCode is====> %{public}d", errAddSlotFourth); + APP_LOGI("====>add CUSTOM type slot, ErrCode is====> %{public}d", errAddSlotFifth); sptr group; ErrCode errcodeGet = Notification::NotificationHelper::GetNotificationSlotGroup("id_test", group); - APP_LOGI("====> ansSlotGroupTest get:====> %{public}d", errcodeGet); - + APP_LOGI("====>get SlotGroup after adding SlotGroup and slots, ErrCode is====> %{public}d", errcodeGet); if (group != nullptr) { std::string dumpGroupStr = group->Dump(); - APP_LOGI("====> ansSlotGroupTest dump:====> %{public}s", dumpGroupStr.c_str()); - APP_LOGI("====> ansSlotGroupTest the size of slots:====> %{public}zu", group->GetSlots().size()); + APP_LOGI("====>obtained group dump====> %{public}s", dumpGroupStr.c_str()); + APP_LOGI("====>the number of slots in the obtained group====> %{public}zu", group->GetSlots().size()); + + ErrCode errcodeRem = Notification::NotificationHelper::RemoveNotificationSlotGroup("id_test"); + APP_LOGI("====>remove the group whose id is id_test, ErrCode is====> %{public}d", errcodeRem); + sptr groupTwo; + ErrCode errcodeGetTwo = Notification::NotificationHelper::GetNotificationSlotGroup("id_test", groupTwo); + APP_LOGI("====>get SlotGroup after removing SlotGroup, ErrCode is====> %{public}d", errcodeGetTwo); + + ErrCode errAddGroupTestSecond = Notification::NotificationHelper::AddNotificationSlotGroup(slotGroupTest); + APP_LOGI("====>add SlotGroup again with id name id_test, ErrCode is====> %{public}d", errAddGroupTestSecond); + sptr groupSecond; + ErrCode errcodeGetSecond = Notification::NotificationHelper::GetNotificationSlotGroup("id_test", groupSecond); + APP_LOGI("====>get SlotGroup again after adding SlotGroup again, ErrCode is: %{public}d", errcodeGetSecond); + if (groupSecond != nullptr) { + dumpGroupStr = groupSecond->Dump(); + APP_LOGI("====>the second time obtained group dump====> %{public}s", dumpGroupStr.c_str()); + APP_LOGI("====>the number of slots in second obtained group: %{public}zu", groupSecond->GetSlots().size()); + + Notification::NotificationSlotGroup slotGroupFirst("id_first", "name_first"); + ErrCode errAddGroupFirst = Notification::NotificationHelper::AddNotificationSlotGroup(slotGroupFirst); + APP_LOGI("====>add SlotGroup with id name id_first, ErrCode is====> %{public}d", errAddGroupFirst); + + Notification::NotificationSlotGroup slotGroupSecond("id_second", "name_second"); + ErrCode errAddGroupSecond = Notification::NotificationHelper::AddNotificationSlotGroup(slotGroupSecond); + APP_LOGI("====>add SlotGroup with id name id_second, ErrCode is====> %{public}d", errAddGroupSecond); + + Notification::NotificationSlotGroup slotGroupThird("id_third", "name_third"); + ErrCode errAddGroupThird = Notification::NotificationHelper::AddNotificationSlotGroup(slotGroupThird); + APP_LOGI("====>add SlotGroup with id name id_third, ErrCode is====> %{public}d", errAddGroupThird); + + Notification::NotificationSlotGroup slotGroupFourth("id_fourth", "name_fourth"); + ErrCode errAddGroupFourth = Notification::NotificationHelper::AddNotificationSlotGroup(slotGroupFourth); + APP_LOGI("====>add SlotGroup with id name id_fourth, ErrCode is====> %{public}d", errAddGroupFourth); + + Notification::NotificationSlotGroup slotGroupFifth("id_fifth", "name_fifth"); + ErrCode errAddGroupFifth = Notification::NotificationHelper::AddNotificationSlotGroup(slotGroupFifth); + APP_LOGI("====>add SlotGroup with id name id_fifth, ErrCode is====> %{public}d", errAddGroupFifth); + } else { + ANS_LOGI("====>fail to get group after adding SlotGroup for the second time====>"); + } } else { - APP_LOGI("====>group is null====>"); + ANS_LOGI("====>fail to get group after adding SlotGroup and slots for the first time====>"); } - ErrCode errcodeRem = Notification::NotificationHelper::RemoveNotificationSlotGroup("id_test"); - APP_LOGI("====> ansSlotGroupTest remove:====> %{public}d", errcodeRem); - sptr groupTwo; - ErrCode errcodeGetTwo = Notification::NotificationHelper::GetNotificationSlotGroup("id_test", groupTwo); - APP_LOGI("====> ansSlotGroupTest get:====> %{public}d", errcodeGetTwo); Ability::OnStart(want); } diff --git a/test/resource/ansSlotGroupHap/AnsSTSlotGroupTest.hap b/test/resource/ansSlotGroupHap/AnsSTSlotGroupTest.hap index 62a810190d1093a65ae99d6b7e729b3e20a3cecb..0132daeec68f4c4e81ce4f02e6352cec88a7be96 100755 Binary files a/test/resource/ansSlotGroupHap/AnsSTSlotGroupTest.hap and b/test/resource/ansSlotGroupHap/AnsSTSlotGroupTest.hap differ