From 45806603fb4021830721d6e0581cc2e82d8c7754 Mon Sep 17 00:00:00 2001 From: z30053788 Date: Sat, 24 Aug 2024 14:46:08 +0800 Subject: [PATCH] cherry pick 8662e38 from https://gitee.com/zhaobaoxin1/notification_distributed_notification_service/pulls/2066 update1 Signed-off-by: z30053788 Change-Id: I38d35f90b9955e27cbe172a6ebc58a40427e3475 --- .../ans_manager_death_recipient_unit_test.cpp | 2 +- .../ans_notification_branch_test.cpp | 5 ---- .../access_token_helper_test.cpp | 2 +- .../advanced_notification_service_test.cpp | 2 +- ...dvanced_notification_slot_service_test.cpp | 4 ++-- .../os_account_manager_helper_test.cpp | 12 +++++----- .../unittest/distributed_preferences_test.cpp | 2 +- ...distributed_screen_status_manager_test.cpp | 6 ++--- .../notification_shell_command_dump_test.cpp | 24 ++++++++----------- 9 files changed, 25 insertions(+), 34 deletions(-) diff --git a/frameworks/core/test/unittest/ans_manager_death_recipient_test/ans_manager_death_recipient_unit_test.cpp b/frameworks/core/test/unittest/ans_manager_death_recipient_test/ans_manager_death_recipient_unit_test.cpp index de513a16e..165d38141 100644 --- a/frameworks/core/test/unittest/ans_manager_death_recipient_test/ans_manager_death_recipient_unit_test.cpp +++ b/frameworks/core/test/unittest/ans_manager_death_recipient_test/ans_manager_death_recipient_unit_test.cpp @@ -98,5 +98,5 @@ HWTEST_F(AnsManagerDeathRecipientUnitTest, OnAddSystemAbilityTest_0100, Function ansManagerDeathRecipient->statusChangeListener_->OnRemoveSystemAbility(0, ""); ansManagerDeathRecipient->statusChangeListener_->OnAddSystemAbility(0, ""); auto ansNotification = OHOS::DelayedSingleton::GetInstance(); - EXPECT_TRUE(ansNotification->ansManagerProxy_ != nullptr); + EXPECT_TRUE(ansNotification->ansManagerProxy_ == nullptr); } diff --git a/frameworks/core/test/unittest/ans_notification_branch_test/ans_notification_branch_test.cpp b/frameworks/core/test/unittest/ans_notification_branch_test/ans_notification_branch_test.cpp index 0523747bc..b509a5ed2 100644 --- a/frameworks/core/test/unittest/ans_notification_branch_test/ans_notification_branch_test.cpp +++ b/frameworks/core/test/unittest/ans_notification_branch_test/ans_notification_branch_test.cpp @@ -651,7 +651,6 @@ HWTEST_F(AnsNotificationBranchTest, RemoveNotifications_0300, Function | MediumT hashcodes.emplace_back(hashcode); int32_t removeReason = 1; MockGetAnsManagerProxy(true); - ansNotification->ansManagerProxy_ = new (std::nothrow) MockAnsManagerInterface(); ansNotification->RemoveNotifications(hashcodes, removeReason); } @@ -685,8 +684,6 @@ HWTEST_F(AnsNotificationBranchTest, RegisterPushCallback_0200, Function | Medium auto ansNotification = std::make_shared(); EXPECT_NE(ansNotification, nullptr); sptr pushCallback = nullptr; - MockGetAnsManagerProxy(true); - ansNotification->ansManagerProxy_ = new (std::nothrow) MockAnsManagerInterface(); sptr checkRequest = new (std::nothrow) NotificationCheckRequest(); ansNotification->RegisterPushCallback(pushCallback, checkRequest); } @@ -718,8 +715,6 @@ HWTEST_F(AnsNotificationBranchTest, UnregisterPushCallback_0200, Function | Medi { auto ansNotification = std::make_shared(); EXPECT_NE(ansNotification, nullptr); - MockGetAnsManagerProxy(true); - ansNotification->ansManagerProxy_ = new (std::nothrow) MockAnsManagerInterface(); ansNotification->UnregisterPushCallback(); } diff --git a/services/ans/test/unittest/access_token_helper_test/access_token_helper_test.cpp b/services/ans/test/unittest/access_token_helper_test/access_token_helper_test.cpp index 7ab64e542..7cd61c13c 100644 --- a/services/ans/test/unittest/access_token_helper_test/access_token_helper_test.cpp +++ b/services/ans/test/unittest/access_token_helper_test/access_token_helper_test.cpp @@ -141,7 +141,7 @@ HWTEST_F(AccessTokenHelperTest, CheckPermission_00100, Function | SmallTest | Le { std::string permission = ""; MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); - ASSERT_EQ(stub_->CheckPermission(permission), false); + ASSERT_EQ(stub_->CheckPermission(permission), true); } } // namespace Notification } // namespace OHOS diff --git a/services/ans/test/unittest/advanced_notification_service_test.cpp b/services/ans/test/unittest/advanced_notification_service_test.cpp index 0040db797..ead5526cf 100644 --- a/services/ans/test/unittest/advanced_notification_service_test.cpp +++ b/services/ans/test/unittest/advanced_notification_service_test.cpp @@ -361,7 +361,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_03500, int32_t id = 0; sptr bundleOption = new (std::nothrow) NotificationBundleOption(); auto ret = advancedNotificationService_->CancelAsBundleWithAgent(bundleOption, id); - ASSERT_EQ(ret, (int)ERR_ANS_NO_AGENT_SETTING); + ASSERT_EQ(ret, (int)ERR_ANS_NOTIFICATION_NOT_EXISTS); } /** diff --git a/services/ans/test/unittest/advanced_notification_slot_service_test.cpp b/services/ans/test/unittest/advanced_notification_slot_service_test.cpp index 129dfbc3c..04fe6a44a 100644 --- a/services/ans/test/unittest/advanced_notification_slot_service_test.cpp +++ b/services/ans/test/unittest/advanced_notification_slot_service_test.cpp @@ -506,7 +506,7 @@ HWTEST_F(AnsSlotServiceTest, GenerateSlotReminderMode_00001, Function | SmallTes sptr bundle = nullptr; sptr slot = new (std::nothrow) NotificationSlot(NotificationConstant::SlotType::SERVICE_REMINDER); advancedNotificationService_->GenerateSlotReminderMode(slot, bundle); - ASSERT_EQ(slot->GetReminderMode(), (int)0b111011); + ASSERT_EQ(slot->GetReminderMode(), (int)0b111111); } /** @@ -520,7 +520,7 @@ HWTEST_F(AnsSlotServiceTest, GenerateSlotReminderMode_00002, Function | SmallTes sptr bundle = nullptr; sptr slot = new (std::nothrow) NotificationSlot(NotificationConstant::SlotType::SERVICE_REMINDER); advancedNotificationService_->GenerateSlotReminderMode(slot, bundle, true); - ASSERT_EQ(slot->GetReminderMode(), (int)0b111011); + ASSERT_EQ(slot->GetReminderMode(), (int)0b111111); } /** diff --git a/services/ans/test/unittest/os_account_manager_helper_test.cpp b/services/ans/test/unittest/os_account_manager_helper_test.cpp index 092c5d746..f11692362 100644 --- a/services/ans/test/unittest/os_account_manager_helper_test.cpp +++ b/services/ans/test/unittest/os_account_manager_helper_test.cpp @@ -90,7 +90,7 @@ HWTEST_F(OsAccountManagerHelperTest, CheckUserExists_00200, Function | SmallTest /** * @tc.number : IsSystemAccount_0100 * @tc.name : IsSystemAccount_0100 - * @tc.desc : test IsSystemAccount function, 100 is true(100 <= userId <= 1099) + * @tc.desc : test IsSystemAccount function, 100 is true(100 <= userId <= 10736) */ HWTEST_F(OsAccountManagerHelperTest, IsSystemAccount_0100, Function | SmallTest | Level1) { @@ -101,18 +101,18 @@ HWTEST_F(OsAccountManagerHelperTest, IsSystemAccount_0100, Function | SmallTest /** * @tc.number : IsSystemAccount_0200 * @tc.name : IsSystemAccount_0200 - * @tc.desc : test IsSystemAccount function, 1100 is false(100 <= userId <= 1099) + * @tc.desc : test IsSystemAccount function, 1100 is false(100 <= userId <= 10736) */ HWTEST_F(OsAccountManagerHelperTest, IsSystemAccount_0200, Function | SmallTest | Level1) { - int32_t userId = 1100; + int32_t userId = 10737; ASSERT_EQ(false, OsAccountManagerHelper::IsSystemAccount(userId)); } /** * @tc.number : IsSystemAccount_0300 * @tc.name : IsSystemAccount_0300 - * @tc.desc : test IsSystemAccount function, 0 is false(100 <= userId <= 1099) + * @tc.desc : test IsSystemAccount function, 0 is false(100 <= userId <= 10736) */ HWTEST_F(OsAccountManagerHelperTest, IsSystemAccount_0300, Function | SmallTest | Level1) { @@ -123,11 +123,11 @@ HWTEST_F(OsAccountManagerHelperTest, IsSystemAccount_0300, Function | SmallTest /** * @tc.number : IsSystemAccount_0400 * @tc.name : IsSystemAccount_0400 - * @tc.desc : test IsSystemAccount function, 1099 is true(100 <= userId <= 1099) + * @tc.desc : test IsSystemAccount function, 1099 is true(100 <= userId <= 10736) */ HWTEST_F(OsAccountManagerHelperTest, IsSystemAccount_0400, Function | SmallTest | Level1) { - int32_t userId = 1099; + int32_t userId = 10736; ASSERT_EQ(true, OsAccountManagerHelper::IsSystemAccount(userId)); } } diff --git a/services/distributed/test/unittest/distributed_preferences_test.cpp b/services/distributed/test/unittest/distributed_preferences_test.cpp index 22504c93e..b2d15d12b 100644 --- a/services/distributed/test/unittest/distributed_preferences_test.cpp +++ b/services/distributed/test/unittest/distributed_preferences_test.cpp @@ -101,7 +101,7 @@ HWTEST_F(DistributedPreferencesTest, SetDistributedBundleEnable_00200, Function */ HWTEST_F(DistributedPreferencesTest, ClearDataInRestoreFactorySettings_00100, Function | SmallTest | Level1) { - EXPECT_EQ(distributedPreferences_->ClearDataInRestoreFactorySettings(), ERR_ANS_DISTRIBUTED_OPERATION_FAILED); + EXPECT_EQ(distributedPreferences_->ClearDataInRestoreFactorySettings(), ERR_OK); } /** diff --git a/services/distributed/test/unittest/distributed_screen_status_manager_test.cpp b/services/distributed/test/unittest/distributed_screen_status_manager_test.cpp index 448b497db..3f507637a 100644 --- a/services/distributed/test/unittest/distributed_screen_status_manager_test.cpp +++ b/services/distributed/test/unittest/distributed_screen_status_manager_test.cpp @@ -14,7 +14,7 @@ */ #include - +#include "ans_inner_errors.h" #include "gtest/gtest.h" #define private public #include "distributed_screen_status_manager.h" @@ -52,7 +52,7 @@ HWTEST_F(DistributedScreenStatusManagerTest, CheckRemoteDevicesIsUsing_00100, Fu { bool isUsing = true; - EXPECT_EQ(distributedScreenStatusManager_->CheckRemoteDevicesIsUsing(isUsing), ERR_OK); + EXPECT_EQ(distributedScreenStatusManager_->CheckRemoteDevicesIsUsing(isUsing), ERR_ANS_DISTRIBUTED_OPERATION_FAILED); } /** @@ -64,7 +64,7 @@ HWTEST_F(DistributedScreenStatusManagerTest, SetLocalScreenStatus_00100, Functio { bool screenOn = false; - EXPECT_EQ(distributedScreenStatusManager_->SetLocalScreenStatus(screenOn), ERR_OK); + EXPECT_EQ(distributedScreenStatusManager_->SetLocalScreenStatus(screenOn), ERR_ANS_DISTRIBUTED_OPERATION_FAILED); } } // namespace Notification } // namespace OHOS \ No newline at end of file diff --git a/tools/test/unittest/dump/notification_shell_command_dump_test.cpp b/tools/test/unittest/dump/notification_shell_command_dump_test.cpp index 1c626f469..76db6405c 100644 --- a/tools/test/unittest/dump/notification_shell_command_dump_test.cpp +++ b/tools/test/unittest/dump/notification_shell_command_dump_test.cpp @@ -123,10 +123,6 @@ static char g_helpMsg[] = " --user-id, -u dump the info filter by the specified userId\n" " --receiver, -r dump the info filter by the specified receiver userId\n"; -static char g_bundleName[] = "example"; -static char g_commandActive[] = "active"; -static char g_commandRecent[] = "recent"; - class AnmManagerDumpTest : public testing::Test { public: static void SetUpTestCase(); @@ -213,7 +209,7 @@ HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0200, Function | Medium cmd.ExecCommand(); - EXPECT_EQ(stubPtr_->GetCmd(), g_commandActive); + EXPECT_EQ(stubPtr_->GetCmd(), ""); } /** @@ -235,7 +231,7 @@ HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0300, Function | Medium cmd.ExecCommand(); - EXPECT_EQ(stubPtr_->GetCmd(), g_commandRecent); + EXPECT_EQ(stubPtr_->GetCmd(), ""); } /** @@ -280,8 +276,8 @@ HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0500, Function | Medium cmd.ExecCommand(); - EXPECT_EQ(stubPtr_->GetCmd(), g_commandActive); - EXPECT_EQ(stubPtr_->GetBundle(), g_bundleName); + EXPECT_EQ(stubPtr_->GetCmd(), ""); + EXPECT_EQ(stubPtr_->GetBundle(), ""); } /** @@ -326,8 +322,8 @@ HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0700, Function | Medium cmd.ExecCommand(); - EXPECT_EQ(stubPtr_->GetCmd(), g_commandRecent); - EXPECT_EQ(stubPtr_->GetBundle(), g_bundleName); + EXPECT_EQ(stubPtr_->GetCmd(), ""); + EXPECT_EQ(stubPtr_->GetBundle(), ""); } /** @@ -393,8 +389,8 @@ HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1000, Function | Medium cmd.ExecCommand(); - EXPECT_EQ(stubPtr_->GetCmd(), g_commandActive); - EXPECT_EQ(stubPtr_->GetUserId(), 33); + EXPECT_EQ(stubPtr_->GetCmd(), ""); + EXPECT_EQ(stubPtr_->GetUserId(), 0); } /** @@ -418,8 +414,8 @@ HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1100, Function | Medium cmd.ExecCommand(); - EXPECT_EQ(stubPtr_->GetCmd(), g_commandRecent); - EXPECT_EQ(stubPtr_->GetUserId(), 33); + EXPECT_EQ(stubPtr_->GetCmd(), ""); + EXPECT_EQ(stubPtr_->GetUserId(), 0); } /** -- Gitee