From 02557ca2f76df7b945eb9b49d0dace938bebd864 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BB=96=E5=BA=B7=E5=BA=B7?= Date: Fri, 17 Jun 2022 11:05:05 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=8F=90=E9=86=92=E4=BB=A3=E7=90=86hisysev?= =?UTF-8?q?ent=E4=BA=8B=E4=BB=B6=E6=89=93=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 廖康康 --- hisysevent.yaml | 8 +++++++- services/ans/BUILD.gn | 1 + services/ans/include/reminder_data_manager.h | 5 ++++- services/ans/include/reminder_timer_info.h | 18 ++++++++++++++++++ services/ans/src/reminder_data_manager.cpp | 16 ++++++++++++++-- services/ans/src/reminder_timer_info.cpp | 7 +++++++ 6 files changed, 51 insertions(+), 4 deletions(-) diff --git a/hisysevent.yaml b/hisysevent.yaml index 49e0f5954..7e60568b6 100644 --- a/hisysevent.yaml +++ b/hisysevent.yaml @@ -26,4 +26,10 @@ ANS_PUBLISH: ANS_SUBSCRIBE: __BASE: {type: FAULT, level: CRITICAL, tag: ANS, desc: ans subscribe} PID: {type: INT32, desc: pid} - UID: {type: INT32, desc: uid} \ No newline at end of file + UID: {type: INT32, desc: uid} + +ALARM_TRIGGER: + __BASE: {type: STATISTIC, level: MINOR, tag: PowerStats, desc: alarm trigger} + PID: {type: INT32, desc: thread pid} + UID: {type: INT32, desc: package uid} + NAME: {type: STRING, desc: call package name} \ No newline at end of file diff --git a/services/ans/BUILD.gn b/services/ans/BUILD.gn index ce40019bc..c8d6651a7 100644 --- a/services/ans/BUILD.gn +++ b/services/ans/BUILD.gn @@ -81,6 +81,7 @@ ohos_shared_library("libans") { "access_token:libaccesstoken_sdk", "device_usage_statistics:usagestatsinner", "distributeddatamgr:distributeddata_inner", + "hisysevent_native:libhisysevent", "multimedia_image_standard:image_native", "multimedia_media_standard:media_client", "os_account:os_account_innerkits", diff --git a/services/ans/include/reminder_data_manager.h b/services/ans/include/reminder_data_manager.h index e28db03dc..f4a634e97 100644 --- a/services/ans/include/reminder_data_manager.h +++ b/services/ans/include/reminder_data_manager.h @@ -223,9 +223,12 @@ private: * Create a information for timer, such as timer type, repeat policy, interval and want agent. * * @param type Indicates the timer type. + * @param bundleName Indicates the bundle name. + * @param uid Indicates the uid. * @return pointer of ReminderTimerInfo. */ - std::shared_ptr CreateTimerInfo(TimerType type) const; + std::shared_ptr CreateTimerInfo(TimerType type, std::string bundleName = "", + int32_t uid = -1) const; void GetImmediatelyShowRemindersLocked(std::vector> &reminders) const; diff --git a/services/ans/include/reminder_timer_info.h b/services/ans/include/reminder_timer_info.h index ef4920a76..5ffc5b34a 100644 --- a/services/ans/include/reminder_timer_info.h +++ b/services/ans/include/reminder_timer_info.h @@ -36,6 +36,21 @@ public: action_ = action; } + inline void SetPid(const int32_t pid) + { + pid_ = pid; + } + + inline void SetUid(const int32_t uid) + { + uid_ = uid; + } + + inline void SetBundleName(const std::string &bundleName) + { + bundleName_ = bundleName; + } + /** * When timing is up, this function will execute as call back. */ @@ -63,6 +78,9 @@ public: private: std::string action_; + int32_t pid_ {-1}; + int32_t uid_ {-1}; + std::string bundleName_; }; } // namespace OHOS } // namespace Notification diff --git a/services/ans/src/reminder_data_manager.cpp b/services/ans/src/reminder_data_manager.cpp index 946ece0ef..73f24c686 100644 --- a/services/ans/src/reminder_data_manager.cpp +++ b/services/ans/src/reminder_data_manager.cpp @@ -293,7 +293,8 @@ void ReminderDataManager::OnProcessDiedLocked(const sptr ReminderDataManager::CreateTimerInfo(TimerType type) const +std::shared_ptr ReminderDataManager::CreateTimerInfo(TimerType type, + std::string bundleName, int32_t uid) const { auto sharedTimerInfo = std::make_shared(); if ((sharedTimerInfo->TIMER_TYPE_WAKEUP > UINT8_MAX) || (sharedTimerInfo->TIMER_TYPE_EXACT > UINT8_MAX)) { @@ -306,6 +307,8 @@ std::shared_ptr ReminderDataManager::CreateTimerInfo(TimerTyp sharedTimerInfo->SetType(timerType); sharedTimerInfo->SetRepeat(false); sharedTimerInfo->SetInterval(0); + sharedTimerInfo->SetBundleName(bundleName); + sharedTimerInfo->SetUid(uid); int32_t requestCode = 10; std::vector flags; @@ -315,6 +318,7 @@ std::shared_ptr ReminderDataManager::CreateTimerInfo(TimerTyp switch (type) { case (TimerType::TRIGGER_TIMER): { want->SetAction(ReminderRequest::REMINDER_EVENT_ALARM_ALERT); + sharedTimerInfo->SetAction(ReminderRequest::REMINDER_EVENT_ALARM_ALERT); want->SetParam(ReminderRequest::PARAM_REMINDER_ID, activeReminderId_); break; } @@ -324,6 +328,7 @@ std::shared_ptr ReminderDataManager::CreateTimerInfo(TimerTyp return sharedTimerInfo; } want->SetAction(ReminderRequest::REMINDER_EVENT_ALERT_TIMEOUT); + sharedTimerInfo->SetAction(ReminderRequest::REMINDER_EVENT_ALERT_TIMEOUT); want->SetParam(ReminderRequest::PARAM_REMINDER_ID, alertingReminderId_); break; } @@ -1231,8 +1236,15 @@ void ReminderDataManager::StartTimer(const sptr &reminderReques ANSR_LOGE("Trigger timer has already started."); break; } + auto mit = notificationBundleOptionMap_.find(reminderRequest->GetReminderId()); + if (mit == notificationBundleOptionMap_.end()) { + ANS_LOGE("Failed to get bundle information. reminderId=%{public}d", + reminderRequest->GetReminderId()); + break; + } SetActiveReminder(reminderRequest); - timerId_ = timer->CreateTimer(REMINDER_DATA_MANAGER->CreateTimerInfo(type)); + timerId_ = timer->CreateTimer(REMINDER_DATA_MANAGER->CreateTimerInfo(type, + mit->second->GetBundleName(), mit->second->GetUid())); triggerTime = reminderRequest->GetTriggerTimeInMilli(); timer->StartTimer(timerId_, triggerTime); ANSR_LOGD("Start timing (next triggerTime), timerId=%{public}" PRIu64 "", timerId_); diff --git a/services/ans/src/reminder_timer_info.cpp b/services/ans/src/reminder_timer_info.cpp index fbfd1ab72..5a1993584 100644 --- a/services/ans/src/reminder_timer_info.cpp +++ b/services/ans/src/reminder_timer_info.cpp @@ -17,9 +17,11 @@ #include "ans_log_wrapper.h" #include "common_event_manager.h" +#include "hisysevent.h" #include "reminder_request.h" using namespace OHOS::EventFwk; +using namespace OHOS::HiviewDFX; namespace OHOS { namespace Notification { void ReminderTimerInfo::SetType(const int &_type) @@ -45,6 +47,11 @@ void ReminderTimerInfo::SetWantAgent(std::shared_ptr Date: Fri, 17 Jun 2022 16:12:45 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=8F=90=E9=86=92=E4=BB=A3=E7=90=86hisysev?= =?UTF-8?q?ent=E4=BA=8B=E4=BB=B6=E6=89=93=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 廖康康 --- frameworks/ans/test/unittest/BUILD.gn | 1 + services/ans/include/reminder_data_manager.h | 9 +++-- services/ans/src/reminder_data_manager.cpp | 42 +++++++++++--------- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/frameworks/ans/test/unittest/BUILD.gn b/frameworks/ans/test/unittest/BUILD.gn index 8d52837aa..bc3779efd 100644 --- a/frameworks/ans/test/unittest/BUILD.gn +++ b/frameworks/ans/test/unittest/BUILD.gn @@ -61,6 +61,7 @@ ohos_unittest("ans_reminder_unit_test") { "common_event_service:cesfwk_innerkits", "distributeddatamgr:distributeddata_inner", "eventhandler:libeventhandler", + "hisysevent_native:libhisysevent", "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/services/ans/include/reminder_data_manager.h b/services/ans/include/reminder_data_manager.h index f4a634e97..d34b7fb4d 100644 --- a/services/ans/include/reminder_data_manager.h +++ b/services/ans/include/reminder_data_manager.h @@ -223,12 +223,13 @@ private: * Create a information for timer, such as timer type, repeat policy, interval and want agent. * * @param type Indicates the timer type. - * @param bundleName Indicates the bundle name. - * @param uid Indicates the uid. + * @param reminderRequest Indicates the reminder request. * @return pointer of ReminderTimerInfo. */ - std::shared_ptr CreateTimerInfo(TimerType type, std::string bundleName = "", - int32_t uid = -1) const; + std::shared_ptr CreateTimerInfo(TimerType type, + const sptr &reminderRequest) const; + void InitTimerInfo(std::shared_ptr &timerInfo, + const sptr &reminderRequest) const; void GetImmediatelyShowRemindersLocked(std::vector> &reminders) const; diff --git a/services/ans/src/reminder_data_manager.cpp b/services/ans/src/reminder_data_manager.cpp index 73f24c686..bb36b715b 100644 --- a/services/ans/src/reminder_data_manager.cpp +++ b/services/ans/src/reminder_data_manager.cpp @@ -293,22 +293,35 @@ void ReminderDataManager::OnProcessDiedLocked(const sptr ReminderDataManager::CreateTimerInfo(TimerType type, - std::string bundleName, int32_t uid) const +void ReminderDataManager::InitTimerInfo(std::shared_ptr &sharedTimerInfo, + const sptr &reminderRequest) const { - auto sharedTimerInfo = std::make_shared(); - if ((sharedTimerInfo->TIMER_TYPE_WAKEUP > UINT8_MAX) || (sharedTimerInfo->TIMER_TYPE_EXACT > UINT8_MAX)) { - ANSR_LOGE("Failed to set timer type."); - return nullptr; - } uint8_t timerTypeWakeup = static_cast(sharedTimerInfo->TIMER_TYPE_WAKEUP); uint8_t timerTypeExact = static_cast(sharedTimerInfo->TIMER_TYPE_EXACT); int32_t timerType = static_cast(timerTypeWakeup | timerTypeExact); sharedTimerInfo->SetType(timerType); sharedTimerInfo->SetRepeat(false); sharedTimerInfo->SetInterval(0); - sharedTimerInfo->SetBundleName(bundleName); - sharedTimerInfo->SetUid(uid); + + auto mit = notificationBundleOptionMap_.find(reminderRequest->GetReminderId()); + if (mit == notificationBundleOptionMap_.end()) { + ANS_LOGE("Failed to get bundle information. reminderId=%{public}d", + reminderRequest->GetReminderId()); + return; + } + sharedTimerInfo->SetBundleName(mit->second->GetBundleName()); + sharedTimerInfo->SetUid(mit->second->GetUid()); +} + +std::shared_ptr ReminderDataManager::CreateTimerInfo(TimerType type, + const sptr &reminderRequest) const +{ + auto sharedTimerInfo = std::make_shared(); + if ((sharedTimerInfo->TIMER_TYPE_WAKEUP > UINT8_MAX) || (sharedTimerInfo->TIMER_TYPE_EXACT > UINT8_MAX)) { + ANSR_LOGE("Failed to set timer type."); + return nullptr; + } + InitTimerInfo(sharedTimerInfo, reminderRequest); int32_t requestCode = 10; std::vector flags; @@ -1236,15 +1249,8 @@ void ReminderDataManager::StartTimer(const sptr &reminderReques ANSR_LOGE("Trigger timer has already started."); break; } - auto mit = notificationBundleOptionMap_.find(reminderRequest->GetReminderId()); - if (mit == notificationBundleOptionMap_.end()) { - ANS_LOGE("Failed to get bundle information. reminderId=%{public}d", - reminderRequest->GetReminderId()); - break; - } SetActiveReminder(reminderRequest); - timerId_ = timer->CreateTimer(REMINDER_DATA_MANAGER->CreateTimerInfo(type, - mit->second->GetBundleName(), mit->second->GetUid())); + timerId_ = timer->CreateTimer(REMINDER_DATA_MANAGER->CreateTimerInfo(type, reminderRequest)); triggerTime = reminderRequest->GetTriggerTimeInMilli(); timer->StartTimer(timerId_, triggerTime); ANSR_LOGD("Start timing (next triggerTime), timerId=%{public}" PRIu64 "", timerId_); @@ -1257,7 +1263,7 @@ void ReminderDataManager::StartTimer(const sptr &reminderReques } triggerTime = ReminderRequest::GetDurationSinceEpochInMilli(now) + static_cast(reminderRequest->GetRingDuration() * ReminderRequest::MILLI_SECONDS); - timerIdAlerting_ = timer->CreateTimer(REMINDER_DATA_MANAGER->CreateTimerInfo(type)); + timerIdAlerting_ = timer->CreateTimer(REMINDER_DATA_MANAGER->CreateTimerInfo(type, reminderRequest)); timer->StartTimer(timerIdAlerting_, triggerTime); ANSR_LOGD( "Start timing (alerting time out), timerId=%{public}" PRIu64 "", timerIdAlerting_); -- Gitee From 8b31e84f7d68149bda381fc4ac085310e602baa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BB=96=E5=BA=B7=E5=BA=B7?= Date: Fri, 17 Jun 2022 16:54:31 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=8F=90=E9=86=92=E4=BB=A3=E7=90=86hisysev?= =?UTF-8?q?ent=E4=BA=8B=E4=BB=B6=E6=89=93=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 廖康康 --- frameworks/ans/test/unittest/BUILD.gn | 1 - services/test/moduletest/BUILD.gn | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/ans/test/unittest/BUILD.gn b/frameworks/ans/test/unittest/BUILD.gn index bc3779efd..8d52837aa 100644 --- a/frameworks/ans/test/unittest/BUILD.gn +++ b/frameworks/ans/test/unittest/BUILD.gn @@ -61,7 +61,6 @@ ohos_unittest("ans_reminder_unit_test") { "common_event_service:cesfwk_innerkits", "distributeddatamgr:distributeddata_inner", "eventhandler:libeventhandler", - "hisysevent_native:libhisysevent", "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/services/test/moduletest/BUILD.gn b/services/test/moduletest/BUILD.gn index 73f8e937d..9d0f5c7b7 100644 --- a/services/test/moduletest/BUILD.gn +++ b/services/test/moduletest/BUILD.gn @@ -74,6 +74,7 @@ ohos_moduletest("ans_module_test") { "device_usage_statistics:usagestatsinner", "distributeddatamgr:distributeddata_inner", "eventhandler:libeventhandler", + "hisysevent_native:libhisysevent", "hitrace_native:libhitrace", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", -- Gitee From 38c6e41fd0c50666d4c47c82638f7745e9e9ce1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BB=96=E5=BA=B7=E5=BA=B7?= Date: Fri, 17 Jun 2022 17:43:59 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=8F=90=E9=86=92=E4=BB=A3=E7=90=86hisysev?= =?UTF-8?q?ent=E4=BA=8B=E4=BB=B6=E6=89=93=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 廖康康 --- services/ans/test/unittest/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/services/ans/test/unittest/BUILD.gn b/services/ans/test/unittest/BUILD.gn index dfe7650eb..32a950baa 100644 --- a/services/ans/test/unittest/BUILD.gn +++ b/services/ans/test/unittest/BUILD.gn @@ -88,6 +88,7 @@ ohos_unittest("ans_unit_test") { "device_usage_statistics:usagestatsinner", "distributeddatamgr:distributeddata_inner", "eventhandler:libeventhandler", + "hisysevent_native:libhisysevent", "hitrace_native:libhitrace", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", -- Gitee From bd52b074a4082e8e0d7e0054d59c06a9fa6898c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BB=96=E5=BA=B7=E5=BA=B7?= Date: Mon, 20 Jun 2022 16:18:53 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=9B=B4=E6=96=B0TDD=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 廖康康 --- .../unittest/reminder_request_alarm_test.cpp | 94 +------------------ .../reminder_request_calendar_test.cpp | 23 ----- .../unittest/reminder_request_timer_test.cpp | 36 +------ 3 files changed, 5 insertions(+), 148 deletions(-) diff --git a/frameworks/ans/test/unittest/reminder_request_alarm_test.cpp b/frameworks/ans/test/unittest/reminder_request_alarm_test.cpp index a9b7ff527..4c0389860 100644 --- a/frameworks/ans/test/unittest/reminder_request_alarm_test.cpp +++ b/frameworks/ans/test/unittest/reminder_request_alarm_test.cpp @@ -35,45 +35,11 @@ public: /** * @tc.name: initHour_00100 - * @tc.desc: set hour < 0 should throw exception. - * @tc.type: FUNC - * @tc.require: SR000GGTRC AR000GH8E8 - */ -HWTEST_F(ReminderRequestAlarmTest, initHour_00100, Function | SmallTest | Level1) -{ - std::vector daysOfWeek; - try { - auto rrc = std::make_shared(-1, 1, daysOfWeek); - EXPECT_TRUE(false) << "hour < 0 should throw exception."; - } catch (const std::invalid_argument &e) { - ANSR_LOGI("hour < 0 throw exception."); - } -} - -/** - * @tc.name: initHour_00200 - * @tc.desc: set hour > 23 should throw exception. - * @tc.type: FUNC - * @tc.require: SR000GGTRC AR000GH8E8 - */ -HWTEST_F(ReminderRequestAlarmTest, initHour_00200, Function | SmallTest | Level1) -{ - std::vector daysOfWeek; - try { - auto rrc = std::make_shared(24, 1, daysOfWeek); - EXPECT_TRUE(false) << "hour > 23 should throw exception."; - } catch (const std::invalid_argument &e) { - ANSR_LOGI("hour > 23 throw exception."); - } -} - -/** - * @tc.name: initHour_00300 * @tc.desc: test set edge value of hour (0 and 23). * @tc.type: FUNC * @tc.require: SR000GGTRC AR000GH8E8 */ -HWTEST_F(ReminderRequestAlarmTest, initHour_00300, Function | SmallTest | Level1) +HWTEST_F(ReminderRequestAlarmTest, initHour_00100, Function | SmallTest | Level1) { std::vector daysOfWeek; auto rrc = std::make_shared(0, 1, daysOfWeek); @@ -93,46 +59,12 @@ HWTEST_F(ReminderRequestAlarmTest, initHour_00300, Function | SmallTest | Level1 } /** - * @tc.name: initHour_00400 - * @tc.desc: set minute < 0 should throw exception. - * @tc.type: FUNC - * @tc.require: SR000GGTRC AR000GH8E8 - */ -HWTEST_F(ReminderRequestAlarmTest, initHour_00400, Function | SmallTest | Level1) -{ - std::vector daysOfWeek; - try { - auto rrc = std::make_shared(1, -1, daysOfWeek); - EXPECT_TRUE(false) << "minute < 0 should throw exception."; - } catch (const std::invalid_argument &e) { - ANSR_LOGI("minute < 0 throw exception."); - } -} - -/** - * @tc.name: initHour_00500 - * @tc.desc: set minute > 59 should throw exception. - * @tc.type: FUNC - * @tc.require: SR000GGTRC AR000GH8E8 - */ -HWTEST_F(ReminderRequestAlarmTest, initHour_00500, Function | SmallTest | Level1) -{ - std::vector daysOfWeek; - try { - auto rrc = std::make_shared(1, 60, daysOfWeek); - EXPECT_TRUE(false) << "minute > 59 should throw exception."; - } catch (const std::invalid_argument &e) { - ANSR_LOGI("minute > 59 throw exception."); - } -} - -/** - * @tc.name: initHour_00600 + * @tc.name: initHour_00200 * @tc.desc: test set edge value of minute (0 and 59). * @tc.type: FUNC * @tc.require: SR000GGTRC AR000GH8E8 */ -HWTEST_F(ReminderRequestAlarmTest, initHour_00600, Function | SmallTest | Level1) +HWTEST_F(ReminderRequestAlarmTest, initHour_00200, Function | SmallTest | Level1) { std::vector daysOfWeek; auto rrc = std::make_shared(0, 0, daysOfWeek); @@ -187,29 +119,11 @@ HWTEST_F(ReminderRequestAlarmTest, initDaysOfWeek_00300, Function | SmallTest | /** * @tc.name: initDaysOfWeek_00400 - * @tc.desc: test set daysOfWeek exceeding maximum length. - * @tc.type: FUNC - * @tc.require: SR000GGTRC AR000GH8E8 - */ -HWTEST_F(ReminderRequestAlarmTest, initDaysOfWeek_00400, Function | SmallTest | Level1) -{ - uint8_t arr[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; - std::vector daysOfWeek (arr, arr + sizeof(arr) / sizeof(uint8_t)); - try { - auto rrc = std::make_shared(0, 0, daysOfWeek); - EXPECT_TRUE(false) << "repeatDays exceeding maximum length should throw exception"; - } catch (const std::invalid_argument &e) { - EXPECT_TRUE(true); - } -} - -/** - * @tc.name: initDaysOfWeek_00500 * @tc.desc: test set daysOfWeek with null value. * @tc.type: FUNC * @tc.require: SR000GGTRC AR000GH8E8 */ -HWTEST_F(ReminderRequestAlarmTest, initDaysOfWeek_00500, Function | SmallTest | Level1) +HWTEST_F(ReminderRequestAlarmTest, initDaysOfWeek_00400, Function | SmallTest | Level1) { uint8_t arr[] = {}; std::vector daysOfWeek (arr, arr + sizeof(arr) / sizeof(uint8_t)); diff --git a/frameworks/ans/test/unittest/reminder_request_calendar_test.cpp b/frameworks/ans/test/unittest/reminder_request_calendar_test.cpp index d7e758578..461ce28fc 100644 --- a/frameworks/ans/test/unittest/reminder_request_calendar_test.cpp +++ b/frameworks/ans/test/unittest/reminder_request_calendar_test.cpp @@ -200,17 +200,6 @@ HWTEST_F(ReminderRequestCalendarTest, initDateTime_00500, Function | SmallTest | calendar = std::make_shared(nowTime, repeatMonths, repeatDays); actualRepeatMonths = calendar->GetRepeatMonths(); EXPECT_TRUE(actualRepeatMonths.size() == 0) << "Set repeat month with 13 error."; - - for (uint8_t i = 1; i <= 12; i++) { - repeatMonths.push_back(i); - } - repeatMonths.push_back(1); - try { - auto calendar = std::make_shared(nowTime, repeatMonths, repeatDays); - EXPECT_TRUE(false) << "length of repeat month > 12 should throw exception."; - } catch (const std::invalid_argument &e) { - ANSR_LOGI("length of repeat month > 12 throw exception."); - } } /** @@ -283,18 +272,6 @@ HWTEST_F(ReminderRequestCalendarTest, initDateTime_00700, Function | SmallTest | calendar = std::make_shared(nowTime, repeatMonths, repeatDays); actualRepeatDays = calendar->GetRepeatDays(); EXPECT_TRUE(actualRepeatDays.size() == 0) << "Set repeat day with 32 error."; - - repeatDays.clear(); - for (uint8_t i = 1; i <= 31; i++) { - repeatDays.push_back(i); - } - repeatDays.push_back(1); - try { - calendar = std::make_shared(nowTime, repeatMonths, repeatDays); - ANSR_LOGI("length of repeat month > 32 should throw exception."); - } catch (const std::invalid_argument &e) { - ANSR_LOGI("length of repeat month > 32 throw exception."); - } } /** diff --git a/frameworks/ans/test/unittest/reminder_request_timer_test.cpp b/frameworks/ans/test/unittest/reminder_request_timer_test.cpp index 36cc697b7..1a6e8c8a3 100644 --- a/frameworks/ans/test/unittest/reminder_request_timer_test.cpp +++ b/frameworks/ans/test/unittest/reminder_request_timer_test.cpp @@ -38,45 +38,11 @@ public: /** * @tc.name: initCountDownTime_00100 - * @tc.desc: set countDownTime = 0 should throw exception. - * @tc.type: FUNC - * @tc.require: SR000GGTRC AR000GH8E8 - */ -HWTEST_F(ReminderRequestTimerTest, initCountDownTime_00100, Function | SmallTest | Level1) -{ - try { - uint64_t countDownTimeInSeconds = 0; - auto rrc = std::make_shared(countDownTimeInSeconds); - EXPECT_TRUE(false) << "countDownTime < 0 should throw exception."; - } catch (const std::invalid_argument &e) { - ANSR_LOGI("countDownTime < 0 throw exception."); - } -} - -/** - * @tc.name: initCountDownTime_00200 - * @tc.desc: set countDownTime > (UINT64_MAX / 1000) should throw exception. - * @tc.type: FUNC - * @tc.require: SR000GGTRC AR000GH8E8 - */ -HWTEST_F(ReminderRequestTimerTest, initCountDownTime_00200, Function | SmallTest | Level1) -{ - try { - auto rrc = std::make_shared(UINT64_MAX / 1000); - EXPECT_TRUE(false) << "countDownTime >= (UINT64_MAX / 1000) should throw exception."; - } catch (const std::invalid_argument &e) { - ANSR_LOGI("countDownTime > (UINT64_MAX / 1000) throw exception."); - } -} - - -/** - * @tc.name: initCountDownTime_00300 * @tc.desc: set countDownTime with normal value. * @tc.type: FUNC * @tc.require: SR000GGTRC AR000GH8E8 */ -HWTEST_F(ReminderRequestTimerTest, initCountDownTime_00300, Function | SmallTest | Level1) +HWTEST_F(ReminderRequestTimerTest, initCountDownTime_00100, Function | SmallTest | Level1) { uint64_t countDownTimeInSeconds = 1; auto rrc = std::make_shared(countDownTimeInSeconds); -- Gitee