1 /* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include <gtest/gtest.h> 17 18 #include "ans_log_wrapper.h" 19 #include "reminder_request_timer.h" 20 #include "reminder_helper.h" 21 22 using namespace testing::ext; 23 namespace OHOS { 24 namespace Notification { 25 class ReminderRequestTimerTest : public testing::Test { 26 public: SetUp()27 void SetUp() {} TearDown()28 void TearDown() 29 { 30 ReminderHelper::CancelAllReminders(); 31 } SetUpTestCase()32 static void SetUpTestCase() 33 { 34 ReminderHelper::CancelAllReminders(); 35 } TearDownTestCase()36 static void TearDownTestCase() {} 37 }; 38 39 /** 40 * @tc.name: initCountDownTime_00100 41 * @tc.desc: set countDownTime with normal value. 42 * @tc.type: FUNC 43 * @tc.require: SR000GGTRC AR000GH8E8 44 */ 45 HWTEST_F(ReminderRequestTimerTest, initCountDownTime_00100, Function | SmallTest | Level1) 46 { 47 uint64_t countDownTimeInSeconds = 1; 48 auto rrc = std::make_shared<ReminderRequestTimer>(countDownTimeInSeconds); 49 EXPECT_TRUE(rrc->GetInitInfo() == 1) << "countDownTime is not 1"; 50 51 countDownTimeInSeconds = 10; 52 auto rrc2 = std::make_shared<ReminderRequestTimer>(countDownTimeInSeconds); 53 EXPECT_TRUE(rrc2->GetInitInfo() == 10) << "countDownTime is not 10"; 54 55 countDownTimeInSeconds = 100; 56 auto rrc3 = std::make_shared<ReminderRequestTimer>(countDownTimeInSeconds); 57 EXPECT_TRUE(rrc3->GetInitInfo() == 100) << "countDownTime is not 1"; 58 } 59 60 /** 61 * @tc.number : ANS_OnDateTimeChange_01000 62 * @tc.name : OnDateTimeChange01000 63 * @tc.type : FUNC 64 * @tc.require : issueI5R30Z 65 */ 66 HWTEST_F(ReminderRequestTimerTest, OnDateTimeChange_00100, Function | SmallTest | Level1) 67 { 68 uint64_t countDownTimeInSeconds = 1; 69 auto rrc = std::make_shared<ReminderRequestTimer>(countDownTimeInSeconds); 70 auto result = rrc->OnDateTimeChange(); 71 EXPECT_EQ(result, false); 72 } 73 74 /** 75 * @tc.number : ANS_OnTimeZoneChange_01000 76 * @tc.name : OnTimeZoneChange01000 77 * @tc.type : FUNC 78 * @tc.require : issueI5R30Z 79 */ 80 HWTEST_F(ReminderRequestTimerTest, OnTimeZoneChange_00100, Function | SmallTest | Level1) 81 { 82 uint64_t countDownTimeInSeconds = 1; 83 auto rrc = std::make_shared<ReminderRequestTimer>(countDownTimeInSeconds); 84 auto result = rrc->OnTimeZoneChange(); 85 EXPECT_EQ(result, false); 86 } 87 88 /** 89 * @tc.number : ANS_Marshalling_01000 90 * @tc.name : Marshalling01000 91 * @tc.type : FUNC 92 * @tc.require : issueI5R30Z 93 */ 94 HWTEST_F(ReminderRequestTimerTest, Marshalling_00100, Function | SmallTest | Level1) 95 { 96 uint64_t countDownTimeInSeconds = 1; 97 Parcel parcel; 98 auto rrc = std::make_shared<ReminderRequestTimer>(countDownTimeInSeconds); 99 auto result = rrc->Marshalling(parcel); 100 EXPECT_EQ(result, true); 101 } 102 103 /** 104 * @tc.number : ANS_ReadFromParcel_01000 105 * @tc.name : ReadFromParcel01000 106 * @tc.type : FUNC 107 * @tc.require : issueI5R30Z 108 */ 109 HWTEST_F(ReminderRequestTimerTest, ReadFromParcel_00100, Function | SmallTest | Level1) 110 { 111 uint64_t countDownTimeInSeconds = 1; 112 Parcel parcel; 113 auto rrc = std::make_shared<ReminderRequestTimer>(countDownTimeInSeconds); 114 auto result = rrc->ReadFromParcel(parcel); 115 EXPECT_EQ(result, false); 116 } 117 } 118 }