diff --git a/frameworks/ans/test/unittest/notification_helper_test.cpp b/frameworks/ans/test/unittest/notification_helper_test.cpp index af385f78995b29c46211877385b587af287dbdfe..021715e9f10825a16b0d47eed9a41c7342d218fd 100644 --- a/frameworks/ans/test/unittest/notification_helper_test.cpp +++ b/frameworks/ans/test/unittest/notification_helper_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -35,7 +35,6 @@ class NotificationHelperTest : public testing::Test { public: static void SetUpTestCase() { - uint64_t tokenId; const char **perms = new const char *[1]; perms[0] = "ohos.permission.NOTIFICATION_CONTROLLER"; NativeTokenInfoParams infoInstance = { @@ -48,6 +47,7 @@ public: .aplStr = "system_basic", }; + uint64_t tokenId; infoInstance.processName = "ans_reminder_unit_test"; tokenId = GetAccessTokenId(&infoInstance); SetSelfTokenID(tokenId); diff --git a/frameworks/ans/test/unittest/notification_user_input_test.cpp b/frameworks/ans/test/unittest/notification_user_input_test.cpp index 28fcd48011256e4e0d2d7cd23cd52221354fe3bb..eea44f990a02ee8d0d7ade37f3471a469177c4e3 100644 --- a/frameworks/ans/test/unittest/notification_user_input_test.cpp +++ b/frameworks/ans/test/unittest/notification_user_input_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -302,21 +302,21 @@ HWTEST_F(NotificationUserInputTest, Create_00005, Function | SmallTest | Level1) */ HWTEST_F(NotificationUserInputTest, Create_00006, Function | SmallTest | Level1) { - std::string inputKey = "this is inputKey"; + std::string inputKey = "inputKey"; std::string tag = "Tag"; - std::vector options; - std::string option = "this is option"; - options.emplace_back(option); + std::vector vecs; + std::string option = "option"; + vecs.emplace_back(option); bool permitFreeFormInput = false; std::set permitMimeTypes; - std::string permitMimeType = "this is permitMimeType"; + std::string permitMimeType = "permitMimeType"; permitMimeTypes.insert(permitMimeType); std::shared_ptr additional = std::make_shared(); Notification::NotificationConstant::InputEditType editType = Notification::NotificationConstant::InputEditType::EDIT_DISABLED; std::shared_ptr notificationUserInput = std::make_shared(); ASSERT_NE(nullptr, notificationUserInput); - notificationUserInput->Create(inputKey, tag, options, permitFreeFormInput, permitMimeTypes, + notificationUserInput->Create(inputKey, tag, vecs, permitFreeFormInput, permitMimeTypes, additional, editType); } @@ -346,14 +346,14 @@ HWTEST_F(NotificationUserInputTest, AddAdditionalData_00001, Function | SmallTes { std::string inputKey = "InputKey"; std::string tag = "Tag"; - std::vector options; + std::vector vecs; bool permitFreeFormInput = true; std::set permitMimeTypes; std::shared_ptr additional = nullptr; - Notification::NotificationConstant::InputEditType editType = + Notification::NotificationConstant::InputEditType inputEditType = Notification::NotificationConstant::InputEditType(1); - auto rrc = std::make_shared(inputKey, tag, options, permitFreeFormInput, permitMimeTypes, - additional, editType); + auto rrc = std::make_shared(inputKey, tag, vecs, permitFreeFormInput, permitMimeTypes, + additional, inputEditType); std::shared_ptr ret = rrc->GetAdditionalData(); EXPECT_EQ(ret, nullptr); AAFwk::WantParams aitional; diff --git a/frameworks/ans/test/unittest/reminder_request_alarm_test.cpp b/frameworks/ans/test/unittest/reminder_request_alarm_test.cpp index 6de29c1b49e868add09f892559f902f017b66534..41a77a276e2d9d5321691a9e49226bb9f2da4b0e 100644 --- a/frameworks/ans/test/unittest/reminder_request_alarm_test.cpp +++ b/frameworks/ans/test/unittest/reminder_request_alarm_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -510,22 +510,22 @@ HWTEST_F(ReminderRequestAlarmTest, UpdateNextReminder_00200, Function | SmallTes { uint8_t arr[] = {}; std::vector daysOfWeek (arr, arr + sizeof(arr) / sizeof(uint8_t)); - auto rrc = std::make_shared(0, 0, daysOfWeek); + auto reminderRequestAlarm = std::make_shared(0, 0, daysOfWeek); auto ret = std::make_shared(); ret->SetSnoozeTimes(1); EXPECT_EQ(ret->GetSnoozeTimes(), 1); uint32_t minTimeIntervalInSecond = 300; - rrc->SetTimeInterval(1); - EXPECT_EQ(rrc->GetTimeInterval(), minTimeIntervalInSecond); + reminderRequestAlarm->SetTimeInterval(1); + EXPECT_EQ(reminderRequestAlarm->GetTimeInterval(), minTimeIntervalInSecond); ret->SetSnoozeTimesDynamic(0); EXPECT_EQ(ret->GetSnoozeTimesDynamic(), 0); - uint8_t result = rrc->GetRepeatDay(); + uint8_t result = reminderRequestAlarm->GetRepeatDay(); EXPECT_EQ(result, 0); - EXPECT_EQ(rrc->IsRepeatReminder(), true); - EXPECT_EQ(rrc->UpdateNextReminder(), true); + EXPECT_EQ(reminderRequestAlarm->IsRepeatReminder(), true); + EXPECT_EQ(reminderRequestAlarm->UpdateNextReminder(), true); } } } \ No newline at end of file diff --git a/frameworks/ans/test/unittest/reminder_request_branch_test/reminder_request_branch_test.cpp b/frameworks/ans/test/unittest/reminder_request_branch_test/reminder_request_branch_test.cpp index 422422e2d6e6be68b1248bb0a6c07a3feeecb549..af05dd80ee29f744556a08528ff1b89c60e46dba 100644 --- a/frameworks/ans/test/unittest/reminder_request_branch_test/reminder_request_branch_test.cpp +++ b/frameworks/ans/test/unittest/reminder_request_branch_test/reminder_request_branch_test.cpp @@ -341,16 +341,16 @@ HWTEST_F(ReminderRequestBranchTest, AddActionButtons_00100, Function | SmallTest { auto reminderRequest = std::make_shared(); EXPECT_NE(reminderRequest, nullptr); - int32_t notificationId_ = 0; - reminderRequest->notificationRequest_ = new (std::nothrow) NotificationRequest(notificationId_); - std::string title = "aa"; - ReminderRequest::ActionButtonType actionButtonType = ReminderRequest::ActionButtonType::CLOSE; + int32_t notificationId = 0; + reminderRequest->notificationRequest_ = new (std::nothrow) NotificationRequest(notificationId); + std::string stringData = "aa"; + ReminderRequest::ActionButtonType buttonType = ReminderRequest::ActionButtonType::CLOSE; ReminderRequest::ActionButtonInfo info; info.type = ReminderRequest::ActionButtonType::SNOOZE; - info.title = title; + info.title = stringData; info.wantAgent = nullptr; reminderRequest->actionButtonMap_.insert( - std::pair(actionButtonType, info)); + std::pair(buttonType, info)); bool includeSnooze = true; reminderRequest->AddActionButtons(includeSnooze); } @@ -391,16 +391,16 @@ HWTEST_F(ReminderRequestBranchTest, AddActionButtons_00300, Function | SmallTest { auto reminderRequest = std::make_shared(); EXPECT_NE(reminderRequest, nullptr); - int32_t notificationId_ = 0; - reminderRequest->notificationRequest_ = new (std::nothrow) NotificationRequest(notificationId_); - std::string title = "aa"; - ReminderRequest::ActionButtonType actionButtonType = ReminderRequest::ActionButtonType::SNOOZE; + int32_t notificationIds = 0; + reminderRequest->notificationRequest_ = new (std::nothrow) NotificationRequest(notificationIds); + std::string title = "title"; + ReminderRequest::ActionButtonType actionButtonType_ = ReminderRequest::ActionButtonType::SNOOZE; ReminderRequest::ActionButtonInfo info; info.type = ReminderRequest::ActionButtonType::SNOOZE; info.title = title; info.wantAgent = nullptr; reminderRequest->actionButtonMap_.insert( - std::pair(actionButtonType, info)); + std::pair(actionButtonType_, info)); bool includeSnooze = false; reminderRequest->AddActionButtons(includeSnooze); } diff --git a/frameworks/core/test/unittest/ans_manager_proxy_test/ans_manager_proxy_unit_test.cpp b/frameworks/core/test/unittest/ans_manager_proxy_test/ans_manager_proxy_unit_test.cpp index dea0644af9513851b7d618c87c892cd63ce0e1b1..ef64859fc8c13af6bdf1b32050674f55b533bd11 100644 --- a/frameworks/core/test/unittest/ans_manager_proxy_test/ans_manager_proxy_unit_test.cpp +++ b/frameworks/core/test/unittest/ans_manager_proxy_test/ans_manager_proxy_unit_test.cpp @@ -817,12 +817,12 @@ HWTEST_F(AnsManagerProxyUnitTest, AddSlotsTest_0400, Function | MediumTest | Lev { GTEST_LOG_(INFO) << "AnsManagerProxyUnitTest, AddSlotsTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + EXPECT_CALL(*iremoteObjects, SendRequest(_, _, _, _)) .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObjects); ASSERT_NE(nullptr, proxy); std::vector> slots; sptr slot = new (std::nothrow) NotificationSlot(); @@ -863,12 +863,12 @@ HWTEST_F(AnsManagerProxyUnitTest, AddSlotsTest_0600, Function | MediumTest | Lev { GTEST_LOG_(INFO) << "AnsManagerProxyUnitTest, AddSlotsTest_0600, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + EXPECT_CALL(*iremoteObjects, SendRequest(_, _, _, _)).Times(1) .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObjects); ASSERT_NE(nullptr, proxy); std::vector> slots; sptr slot = new (std::nothrow) NotificationSlot(); @@ -3961,13 +3961,13 @@ HWTEST_F(AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0200, Functio { GTEST_LOG_(INFO) << "AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + MockWriteInterfaceToken(true); + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + EXPECT_CALL(*iremoteObjects, SendRequest(_, _, _, _)) .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObjects); ASSERT_NE(nullptr, proxy); bool enabled = false; sptr bundleOption = new (std::nothrow) NotificationBundleOption(); @@ -4205,13 +4205,13 @@ HWTEST_F(AnsManagerProxyUnitTest, SubscribeTest_0200, Function | MediumTest | Le { GTEST_LOG_(INFO) << "AnsManagerProxyUnitTest, SubscribeTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + MockWriteInterfaceToken(true); + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + EXPECT_CALL(*iremoteObjects, SendRequest(_, _, _, _)) .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObjects); ASSERT_NE(nullptr, proxy); auto subscriber = new (std::nothrow) TestSubscriber(); sptr subInfo = new (std::nothrow) NotificationSubscribeInfo(); @@ -4315,7 +4315,7 @@ HWTEST_F(AnsManagerProxyUnitTest, UnsubscribeTest_0200, Function | MediumTest | { GTEST_LOG_(INFO) << "AnsManagerProxyUnitTest, UnsubscribeTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); + MockWriteInterfaceToken(true); sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); ASSERT_NE(nullptr, iremoteObject); EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) @@ -4643,7 +4643,7 @@ HWTEST_F(AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0200, Functio { GTEST_LOG_(INFO) << "AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); + MockWriteInterfaceToken(true); sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); ASSERT_NE(nullptr, iremoteObject); EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) @@ -5751,14 +5751,14 @@ HWTEST_F(AnsManagerProxyUnitTest, PublishContinuousTaskNotificationTest_0200, Fu GTEST_LOG_(INFO) << "AnsManagerProxyUnitTest, PublishContinuousTaskNotificationTest_0200, TestSize.Level1"; MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + std::shared_ptr ansManagerProxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, ansManagerProxy); NotificationRequest request(1); sptr notification = new (std::nothrow) NotificationRequest(request); ASSERT_NE(nullptr, notification); - int32_t result = proxy->PublishContinuousTaskNotification(notification); + int32_t result = ansManagerProxy->PublishContinuousTaskNotification(notification); EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); } @@ -6669,18 +6669,18 @@ HWTEST_F(AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0200, Function | M { GTEST_LOG_(INFO) << "AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); + MockWriteInterfaceToken(true); sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); ASSERT_NE(nullptr, iremoteObject); EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; + std::shared_ptr ansManagerProxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, ansManagerProxy); sptr bundleOption = new (std::nothrow) NotificationBundleOption(); NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; - int32_t result = proxy->GetEnabledForBundleSlot(bundleOption, slotType, enabled); + bool enabled = false; + int32_t result = ansManagerProxy->GetEnabledForBundleSlot(bundleOption, slotType, enabled); EXPECT_EQ(ERR_OK, result); EXPECT_EQ(true, enabled); } @@ -7040,15 +7040,15 @@ HWTEST_F(AnsManagerProxyUnitTest, ShellDumpTest_0300, Function | MediumTest | Le { GTEST_LOG_(INFO) << "AnsManagerProxyUnitTest, ShellDumpTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + EXPECT_CALL(*iremoteObjects, SendRequest(_, _, _, _)).Times(1) .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceDumpInfo, _1, _2, _3, _4, ERR_OK, false, 0)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); + std::shared_ptr ansManagerProxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, ansManagerProxy); std::vector dumpInfo; - int32_t result = proxy->ShellDump("anm dump -A", "BundleName", 0, dumpInfo); + int32_t result = ansManagerProxy->ShellDump("anm dump -A", "BundleName", 0, dumpInfo); EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); } diff --git a/frameworks/core/test/unittest/ans_manager_stub_test/ans_manager_stub_test.cpp b/frameworks/core/test/unittest/ans_manager_stub_test/ans_manager_stub_test.cpp index f308cdbf23d06c8960eeb66fd1db10a0437ef113..5eda6c59b8c5021deacf5118650a16a0369e29aa 100644 --- a/frameworks/core/test/unittest/ans_manager_stub_test/ans_manager_stub_test.cpp +++ b/frameworks/core/test/unittest/ans_manager_stub_test/ans_manager_stub_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -1876,7 +1876,7 @@ HWTEST_F(AnsManagerStubTest, HandleGetShowBadgeEnabled01, Function | SmallTest | HWTEST_F(AnsManagerStubTest, HandleSubscribe01, Function | SmallTest | Level1) { uint32_t code = static_cast(NotificationInterfaceCode::SUBSCRIBE_NOTIFICATION); - MessageParcel data; + MessageParcel parcels; MessageParcel reply; MessageOption option = {MessageOption::TF_SYNC}; @@ -1884,12 +1884,12 @@ HWTEST_F(AnsManagerStubTest, HandleSubscribe01, Function | SmallTest | Level1) bool subcribeInfo = true; sptr info = new NotificationSubscribeInfo(); - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteParcelable(subscriber); - data.WriteBool(subcribeInfo); - data.WriteParcelable(info); + parcels.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + parcels.WriteParcelable(subscriber); + parcels.WriteBool(subcribeInfo); + parcels.WriteParcelable(info); - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, parcels, reply, option); EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); } @@ -1902,66 +1902,66 @@ HWTEST_F(AnsManagerStubTest, HandleSubscribe01, Function | SmallTest | Level1) HWTEST_F(AnsManagerStubTest, HandleSubscribe02, Function | SmallTest | Level1) { uint32_t code = static_cast(NotificationInterfaceCode::SUBSCRIBE_NOTIFICATION); - MessageParcel data; + MessageParcel parcels; MessageParcel reply; MessageOption option = {MessageOption::TF_SYNC}; sptr subscriber; sptr info = new NotificationSubscribeInfo(); - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteRemoteObject(subscriber); - data.WriteParcelable(info); + parcels.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + parcels.WriteRemoteObject(subscriber); + parcels.WriteParcelable(info); - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, parcels, reply, option); EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); } /** * @tc.name: HandleSubscribe03 - * @tc.desc: Test if the info in data is null. + * @tc.desc: Test if the info in parcels is null. * @tc.type: FUNC * @tc.require: issueI620XB */ HWTEST_F(AnsManagerStubTest, HandleSubscribe03, Function | SmallTest | Level1) { uint32_t code = static_cast(NotificationInterfaceCode::SUBSCRIBE_NOTIFICATION); - MessageParcel data; + MessageParcel parcels; MessageParcel reply; MessageOption option = {MessageOption::TF_SYNC}; sptr subscriber; bool subcribeInfo = true; - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteParcelable(subscriber); - data.WriteBool(subcribeInfo); + parcels.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + parcels.WriteParcelable(subscriber); + parcels.WriteBool(subcribeInfo); - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, parcels, reply, option); EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); } /** * @tc.name: HandleSubscribe04 - * @tc.desc: Test if the subscriber in data is null. + * @tc.desc: Test if the subscriber in parcel is null. * @tc.type: FUNC * @tc.require: issueI620XB */ HWTEST_F(AnsManagerStubTest, HandleSubscribe04, Function | SmallTest | Level1) { uint32_t code = static_cast(NotificationInterfaceCode::SUBSCRIBE_NOTIFICATION); - MessageParcel data; + MessageParcel parcels; MessageParcel reply; MessageOption option = {MessageOption::TF_SYNC}; bool subcribeInfo = true; sptr info = new NotificationSubscribeInfo(); - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteBool(subcribeInfo); - data.WriteParcelable(info); + parcels.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + parcels.WriteBool(subcribeInfo); + parcels.WriteParcelable(info); - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, parcels, reply, option); EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); } @@ -2931,18 +2931,18 @@ HWTEST_F(AnsManagerStubTest, HandleIsSpecialUserAllowedNotifyByUser02, Function HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledByUser01, Function | SmallTest | Level1) { uint32_t code = static_cast(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_BY_USER); - MessageParcel data; + MessageParcel parcels; MessageParcel reply; MessageOption option = {MessageOption::TF_SYNC}; int32_t userId = 4; bool enabled = true; - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(userId); - data.WriteBool(enabled); + parcels.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + parcels.WriteInt32(userId); + parcels.WriteBool(enabled); - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, parcels, reply, option); EXPECT_EQ(ret, (int)ERR_OK); } diff --git a/frameworks/core/test/unittest/ans_notification_annex_test/ans_notification_annex_test.cpp b/frameworks/core/test/unittest/ans_notification_annex_test/ans_notification_annex_test.cpp index 950d8f081f04bb7389cc02148aad612fa2657353..221b168055d43b11fb39fb2f5c2aeda4dd2f0b64 100644 --- a/frameworks/core/test/unittest/ans_notification_annex_test/ans_notification_annex_test.cpp +++ b/frameworks/core/test/unittest/ans_notification_annex_test/ans_notification_annex_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -17,9 +17,9 @@ #define private public #define protected public +#include "ans_manager_proxy.h" #include "ans_notification.h" #include "ans_subscriber_proxy.h" -#include "ans_manager_proxy.h" #undef private #undef protected #include "ans_inner_errors.h" diff --git a/frameworks/core/test/unittest/ans_notification_test/ans_notification_unit_test.cpp b/frameworks/core/test/unittest/ans_notification_test/ans_notification_unit_test.cpp index 4723a0cfdf2c5e016cbbd00d47a9343cca26e4b7..d05f2b4aad3d10de1827ac2d213ef036770b953b 100644 --- a/frameworks/core/test/unittest/ans_notification_test/ans_notification_unit_test.cpp +++ b/frameworks/core/test/unittest/ans_notification_test/ans_notification_unit_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -77,15 +77,15 @@ public: {} void OnDisconnected() override {} - void OnDied() override - {} void OnUpdate(const std::shared_ptr &sortingMap) override {} - void OnDoNotDisturbDateChange(const std::shared_ptr &date) override + void OnDied() override {} void OnEnabledNotificationChanged( const std::shared_ptr &callbackData) override {} + void OnDoNotDisturbDateChange(const std::shared_ptr &date) override + {} void OnCanceled(const std::shared_ptr &request, const std::shared_ptr &sortingMap, int deleteReason) override {} @@ -190,16 +190,16 @@ HWTEST_F(AnsNotificationUnitTest, GetNotificationSlot_0100, Function | MediumTes HWTEST_F(AnsNotificationUnitTest, GetNotificationSlotNumAsBundle_0100, Function | MediumTest | Level1) { MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + std::shared_ptr proxy = std::make_shared(iremoteObjects); ASSERT_NE(nullptr, proxy); ans_->GetAnsManagerProxy(); - NotificationBundleOption bundleOption; - std::string bundleName = "this is bundleName"; - bundleOption.SetBundleName(bundleName); + NotificationBundleOption bundleOptions; + std::string bundleName = "bundleName"; + bundleOptions.SetBundleName(bundleName); uint64_t num = 10; - ErrCode ret1 = ans_->GetNotificationSlotNumAsBundle(bundleOption, num); + ErrCode ret1 = ans_->GetNotificationSlotNumAsBundle(bundleOptions, num); EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); } @@ -681,13 +681,13 @@ HWTEST_F(AnsNotificationUnitTest, SetDoNotDisturbDate_0200, Function | MediumTes HWTEST_F(AnsNotificationUnitTest, SetEnabledForBundleSlot_0100, Function | MediumTest | Level1) { MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); + sptr iremoteObject_ = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject_); + std::shared_ptr proxy = std::make_shared(iremoteObject_); ASSERT_NE(nullptr, proxy); ans_->GetAnsManagerProxy(); NotificationBundleOption bundleOption; - std::string bundleName = "this is bundleName"; + std::string bundleName = "bundleName"; bundleOption.SetBundleName(bundleName); NotificationConstant::SlotType slotType = NotificationConstant::SlotType::CUSTOM; bool enabled = true; @@ -755,9 +755,9 @@ HWTEST_F(AnsNotificationUnitTest, SetSyncNotificationEnabledWithoutApp_0100, Fun HWTEST_F(AnsNotificationUnitTest, SubscribeNotification_0100, Function | MediumTest | Level1) { MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); + sptr iremoteObject_ = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject_); + std::shared_ptr proxy = std::make_shared(iremoteObject_); ASSERT_NE(nullptr, proxy); bool res = ans_->GetAnsManagerProxy(); EXPECT_EQ(res, false); diff --git a/frameworks/core/test/unittest/ans_subscriber_proxy_branch_test/ans_subscriber_proxy_branch_test.cpp b/frameworks/core/test/unittest/ans_subscriber_proxy_branch_test/ans_subscriber_proxy_branch_test.cpp index 3435db2e39db69e5e4fd9235b3bdc5a76e2e59ab..0be668a406b2270affd21c7ab91b13700e4960eb 100755 --- a/frameworks/core/test/unittest/ans_subscriber_proxy_branch_test/ans_subscriber_proxy_branch_test.cpp +++ b/frameworks/core/test/unittest/ans_subscriber_proxy_branch_test/ans_subscriber_proxy_branch_test.cpp @@ -15,11 +15,11 @@ #include -#define private public #define protected public +#define private public #include "ans_subscriber_proxy.h" -#undef private #undef protected +#undef private #include "ans_inner_errors.h" #include "ipc_types.h" #include "mock_i_remote_object.h" diff --git a/frameworks/test/moduletest/ans_innerkits_module_publish_test.cpp b/frameworks/test/moduletest/ans_innerkits_module_publish_test.cpp index 556735a7b4465b247d1def1a8ed05b513c445b39..51640904f778c58dbef9c823c6714d6b3186a512 100644 --- a/frameworks/test/moduletest/ans_innerkits_module_publish_test.cpp +++ b/frameworks/test/moduletest/ans_innerkits_module_publish_test.cpp @@ -91,14 +91,14 @@ public: void OnDied() override {} - void OnUpdate(const std::shared_ptr &sortingMap) override + void OnEnabledNotificationChanged( + const std::shared_ptr &callbackData) override {} void OnDoNotDisturbDateChange(const std::shared_ptr &date) override {} - void OnEnabledNotificationChanged( - const std::shared_ptr &callbackData) override + void OnUpdate(const std::shared_ptr &sortingMap) override {} void OnCanceled(const std::shared_ptr &request,