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 fada42eee93b83b73d48dc06724a3480595d1b25..422422e2d6e6be68b1248bb0a6c07a3feeecb549 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 @@ -15,14 +15,14 @@ #include -#define private public #define protected public +#define private public #include "reminder_request.h" -#undef private #undef protected - +#undef private extern void MockNowInstantMilli(bool mockRet); + using namespace testing::ext; namespace OHOS { namespace Notification { diff --git a/frameworks/ans/test/unittest/reminder_request_calendar_test.cpp b/frameworks/ans/test/unittest/reminder_request_calendar_test.cpp index 048e74d1a7438090a729f425d16d9b8ab3877cf0..fbfa0a05e70f57e47b0c2ea7c5be4861735bb4c1 100644 --- a/frameworks/ans/test/unittest/reminder_request_calendar_test.cpp +++ b/frameworks/ans/test/unittest/reminder_request_calendar_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 @@ -33,8 +33,8 @@ public: { ReminderHelper::CancelAllReminders(); } - static void TearDownTestCase() {} void SetUp() {} + static void TearDownTestCase() {} void TearDown() { ReminderHelper::CancelAllReminders(); @@ -186,18 +186,18 @@ HWTEST_F(ReminderRequestCalendarTest, initDateTime_00500, Function | SmallTest | EXPECT_NE(nullptr, tmp); tm nowTime = *tmp; nowTime.tm_year += 1; - std::vector repeatMonths; - std::vector repeatDays; - repeatMonths.push_back(-1); - repeatDays.push_back(1); - auto calendar = std::make_shared(nowTime, repeatMonths, repeatDays); + std::vector repeatMonth; + std::vector repeatDay; + repeatMonth.push_back(-1); + repeatDay.push_back(1); + auto calendar = std::make_shared(nowTime, repeatMonth, repeatDay); calendar->SetNextTriggerTime(); std::vector actualRepeatMonths = calendar->GetRepeatMonths(); EXPECT_TRUE(actualRepeatMonths.size() == 0) << "Set repeat month with -1 error."; - repeatMonths.clear(); - repeatMonths.push_back(13); - calendar = std::make_shared(nowTime, repeatMonths, repeatDays); + repeatMonth.clear(); + repeatMonth.push_back(13); + calendar = std::make_shared(nowTime, repeatMonth, repeatDay); calendar->SetNextTriggerTime(); actualRepeatMonths = calendar->GetRepeatMonths(); EXPECT_TRUE(actualRepeatMonths.size() == 0) << "Set repeat month with 13 error."; @@ -760,22 +760,22 @@ HWTEST_F(ReminderRequestCalendarTest, UpdateNextReminder_00004, Function | Small uint8_t month = 1; calendar->SetMonth(month, isSet); - bool result1 = calendar->IsRepeatMonth(month); - EXPECT_EQ(result1, false); + bool result7 = calendar->IsRepeatMonth(month); + EXPECT_EQ(result7, false); - auto rrc = std::make_shared(); - rrc->SetSnoozeTimes(1); - EXPECT_EQ(rrc->GetSnoozeTimes(), 1) << "Get snoozeTimes not 1"; + auto reminderRequest = std::make_shared(); + reminderRequest->SetSnoozeTimes(1); + EXPECT_EQ(reminderRequest->GetSnoozeTimes(), 1) << "Get snoozeTimes not 1"; - rrc->SetSnoozeTimesDynamic(0); - EXPECT_EQ(rrc->GetSnoozeTimesDynamic(), 0) << "Get snoozeTimesDynamic not 1"; + reminderRequest->SetSnoozeTimesDynamic(0); + EXPECT_EQ(reminderRequest->GetSnoozeTimesDynamic(), 0) << "Get snoozeTimesDynamic not 1"; - uint32_t minTimeIntervalInSecond = 5 * 60; - rrc->SetTimeInterval(1); - EXPECT_EQ(rrc->GetTimeInterval(), minTimeIntervalInSecond); + uint32_t minTimeIntervalInSeconds = 5 * 60; + reminderRequest->SetTimeInterval(1); + EXPECT_EQ(reminderRequest->GetTimeInterval(), minTimeIntervalInSeconds); - bool result3 = calendar->UpdateNextReminder(); - EXPECT_EQ(result3, false); + bool result6 = calendar->UpdateNextReminder(); + EXPECT_EQ(result6, false); } /** diff --git a/frameworks/ans/test/unittest/reminder_request_timer_test.cpp b/frameworks/ans/test/unittest/reminder_request_timer_test.cpp index fe539a7e366ac55481e5f3bd6d0145b30d685cbd..ac6c583246e577b41d7bd79cba27de51dffdec3b 100644 --- a/frameworks/ans/test/unittest/reminder_request_timer_test.cpp +++ b/frameworks/ans/test/unittest/reminder_request_timer_test.cpp @@ -24,16 +24,16 @@ namespace OHOS { namespace Notification { class ReminderRequestTimerTest : public testing::Test { public: - static void SetUpTestCase() + void SetUp() {} + void TearDown() { ReminderHelper::CancelAllReminders(); } - static void TearDownTestCase() {} - void SetUp() {} - void TearDown() + static void SetUpTestCase() { ReminderHelper::CancelAllReminders(); } + static void TearDownTestCase() {} }; /** diff --git a/frameworks/core/test/unittest/ans_image_util_test/ans_image_util_unit_test.cpp b/frameworks/core/test/unittest/ans_image_util_test/ans_image_util_unit_test.cpp index 718f1272734813506c1f84143c7d89c273efcba5..bbe2b23ddeddebb4fe3cb7b8647a31f69c171ef7 100644 --- a/frameworks/core/test/unittest/ans_image_util_test/ans_image_util_unit_test.cpp +++ b/frameworks/core/test/unittest/ans_image_util_test/ans_image_util_unit_test.cpp @@ -454,11 +454,11 @@ HWTEST_F(AnsImageUtilUnitTest, CreatePixelMapTest_0400, Function | MediumTest | MockImageSourceCreateImageSource(false, 0); MockImageSourceGetSupportedFormats(0); MockImageSourceCreatePixelMap(true, 0); - std::shared_ptr imageUtil = std::make_shared(); - ASSERT_NE(nullptr, imageUtil); - std::string inFilePath = "testInfile"; - std::string format = "testFormat"; - std::shared_ptr res = imageUtil->CreatePixelMap(inFilePath, format); + std::shared_ptr ansImageUtil = std::make_shared(); + ASSERT_NE(nullptr, ansImageUtil); + std::string testInfile = "testInfile"; + std::string testFormat = "testFormat"; + std::shared_ptr res = ansImageUtil->CreatePixelMap(testInfile, testFormat); EXPECT_EQ(nullptr, res); MockResetImageSourceState(); MockResetImagePackerState(); 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 07d9cbe199834285bf5c9af2c9c8c8c86c3d6377..dea0644af9513851b7d618c87c892cd63ce0e1b1 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 @@ -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 @@ -103,8 +103,6 @@ int SendRequestReplaceString(uint32_t code, MessageParcel &data, MessageParcel & class TestSubscriber : public NotificationSubscriber { public: - void OnConnected() override - {} void OnDisconnected() override {} void OnDied() override @@ -113,17 +111,19 @@ public: {} void OnDoNotDisturbDateChange(const std::shared_ptr &date) override {} + void OnConnected() override + {} void OnEnabledNotificationChanged( const std::shared_ptr &callbackData) override {} void OnCanceled(const std::shared_ptr &request, const std::shared_ptr &sortingMap, int deleteReason) override {} + void OnBadgeChanged(const std::shared_ptr &badgeData) override + {} void OnConsumed(const std::shared_ptr &request, const std::shared_ptr &sortingMap) override {} - void OnBadgeChanged(const std::shared_ptr &badgeData) override - {} }; /* diff --git a/services/ans/test/unittest/advanced_notification_service_branch_test.cpp b/services/ans/test/unittest/advanced_notification_service_branch_test.cpp index 1d3c55a948516e43f4e9f9a70389f26985d94f56..e6f3102b4342c2d688015ac2be9bf0da2b945bef 100644 --- a/services/ans/test/unittest/advanced_notification_service_branch_test.cpp +++ b/services/ans/test/unittest/advanced_notification_service_branch_test.cpp @@ -86,22 +86,22 @@ inline void SleepForFC() class TestAnsSubscriber : public NotificationSubscriber { public: + void OnDied() override + {} void OnConnected() override {} void OnDisconnected() override {} - void OnDied() override - {} void OnUpdate(const std::shared_ptr &sortingMap) override {} void OnDoNotDisturbDateChange(const std::shared_ptr &date) override {} - void OnEnabledNotificationChanged( - const std::shared_ptr &callbackData) override - {} void OnCanceled(const std::shared_ptr &request, const std::shared_ptr &sortingMap, int32_t deleteReason) override {} + void OnEnabledNotificationChanged( + const std::shared_ptr &callbackData) override + {} void OnConsumed(const std::shared_ptr &request, const std::shared_ptr &sortingMap) override {} diff --git a/services/ans/test/unittest/advanced_notification_service_test.cpp b/services/ans/test/unittest/advanced_notification_service_test.cpp index 0c4e2d8b2d4ece5960a5cf449fa3b842bf1c5476..e6cd0d8287d98904cbfff9e01ddc29188fbe53d1 100644 --- a/services/ans/test/unittest/advanced_notification_service_test.cpp +++ b/services/ans/test/unittest/advanced_notification_service_test.cpp @@ -97,6 +97,8 @@ inline void SleepForFC() class TestAnsSubscriber : public NotificationSubscriber { public: + void OnDoNotDisturbDateChange(const std::shared_ptr &date) override + {} void OnConnected() override {} void OnDisconnected() override @@ -105,7 +107,7 @@ public: {} void OnUpdate(const std::shared_ptr &sortingMap) override {} - void OnDoNotDisturbDateChange(const std::shared_ptr &date) override + void OnBadgeChanged(const std::shared_ptr &badgeData) override {} void OnEnabledNotificationChanged( const std::shared_ptr &callbackData) override @@ -116,8 +118,6 @@ public: void OnConsumed(const std::shared_ptr &request, const std::shared_ptr &sortingMap) override {} - void OnBadgeChanged(const std::shared_ptr &badgeData) override - {} }; void AdvancedNotificationServiceTest::TestAddSlot(NotificationConstant::SlotType type) diff --git a/services/ans/test/unittest/notification_subscriber_manager_test.cpp b/services/ans/test/unittest/notification_subscriber_manager_test.cpp index 7d7c75770015b2ca12ab299f7716e56efb945c74..a02e082b43b15c87a0022986b6b8934ad3e9eed8 100644 --- a/services/ans/test/unittest/notification_subscriber_manager_test.cpp +++ b/services/ans/test/unittest/notification_subscriber_manager_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 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 @@ -41,10 +41,6 @@ private: {} void OnDied() override {} - void OnUpdate(const std::shared_ptr &sortingMap) override - {} - void OnDoNotDisturbDateChange(const std::shared_ptr &date) override - {} void OnEnabledNotificationChanged( const std::shared_ptr &callbackData) override {} @@ -54,6 +50,10 @@ private: void OnConsumed(const std::shared_ptr &request, const std::shared_ptr &sortingMap) override {} + void OnUpdate(const std::shared_ptr &sortingMap) override + {} + void OnDoNotDisturbDateChange(const std::shared_ptr &date) override + {} void OnBadgeChanged(const std::shared_ptr &badgeData) override {} }; diff --git a/test/bechmarktest/notification_services_test/notification_service_test.cpp b/test/bechmarktest/notification_services_test/notification_service_test.cpp index 5ad3f693297e5fdefc3e394c26b6a8ad74f7f34c..f3d25bf3ed69a7aea1b2e5c8452f9a53242802a3 100644 --- a/test/bechmarktest/notification_services_test/notification_service_test.cpp +++ b/test/bechmarktest/notification_services_test/notification_service_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 @@ -67,8 +67,6 @@ public: {} void OnDisconnected() override {} - void OnDied() override - {} void OnUpdate(const std::shared_ptr &sortingMap) override {} void OnDoNotDisturbDateChange(const std::shared_ptr &date) override @@ -76,6 +74,8 @@ public: void OnEnabledNotificationChanged( const std::shared_ptr &callbackData) override {} + void OnDied() override + {} void OnCanceled(const std::shared_ptr &request, const std::shared_ptr &sortingMap, int deleteReason) override {}