From 32586fda966f6f408fb2dc94ca121177728de83c Mon Sep 17 00:00:00 2001 From: liuyanzhi Date: Wed, 23 Aug 2023 09:19:44 +0000 Subject: [PATCH] fix TDD Signed-off-by: liuyanzhi Change-Id: I90229ac637a607635fe93625a87c48bab5ff712e --- .../reminder_request_branch_test.cpp | 6 +-- .../reminder_request_calendar_test.cpp | 44 +++++++++---------- .../unittest/reminder_request_timer_test.cpp | 8 ++-- .../ans_image_util_unit_test.cpp | 10 ++--- .../ans_manager_proxy_unit_test.cpp | 10 ++--- ...anced_notification_service_branch_test.cpp | 10 ++--- .../advanced_notification_service_test.cpp | 6 +-- .../notification_subscriber_manager_test.cpp | 10 ++--- .../notification_service_test.cpp | 6 +-- 9 files changed, 55 insertions(+), 55 deletions(-) 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 fada42eee..422422e2d 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 048e74d1a..fbfa0a05e 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 fe539a7e3..ac6c58324 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 718f12727..bbe2b23dd 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 07d9cbe19..dea0644af 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 1d3c55a94..e6f3102b4 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 0c4e2d8b2..e6cd0d828 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 7d7c75770..a02e082b4 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 5ad3f6932..f3d25bf3e 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 {} -- Gitee