1 /* 2 * Copyright (c) 2024 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 #define private public 19 #include "recovery_info_timer.h" 20 #undef private 21 22 using namespace testing::ext; 23 using namespace testing; 24 25 namespace OHOS { 26 namespace AAFwk { 27 class RecoveryInfoTimerTest : public testing::Test { 28 public: 29 static void SetUpTestCase(void); 30 static void TearDownTestCase(void); 31 void SetUp(); 32 void TearDown(); 33 }; 34 SetUpTestCase(void)35void RecoveryInfoTimerTest::SetUpTestCase(void) 36 {} TearDownTestCase(void)37void RecoveryInfoTimerTest::TearDownTestCase(void) 38 {} TearDown(void)39void RecoveryInfoTimerTest::TearDown(void) 40 {} SetUp()41void RecoveryInfoTimerTest::SetUp() 42 {} 43 44 /** 45 * @tc.number: SubmitSaveRecoveryInfo_001 46 * @tc.name: SubmitSaveRecoveryInfo 47 * @tc.desc: Test whether SubmitSaveRecoveryInfo is called normally. 48 * @tc.type: FUNC 49 */ 50 HWTEST_F(RecoveryInfoTimerTest, SubmitSaveRecoveryInfo_001, TestSize.Level1) 51 { 52 RecoveryInfoTimer &instance = RecoveryInfoTimer::GetInstance(); 53 RecoveryInfo recoveryInfo; 54 recoveryInfo.bundleName = "testBundleName"; 55 recoveryInfo.moduleName = "testModuleName"; 56 recoveryInfo.abilityName = "testAbilityName"; 57 instance.SubmitSaveRecoveryInfo(recoveryInfo); __anon3d5eb19c0102(const RecoveryInfo &item) 58 auto findByInfo = [&recoveryInfo](const RecoveryInfo &item) { 59 return item.abilityName == recoveryInfo.abilityName && item.bundleName == recoveryInfo.bundleName && 60 item.moduleName == recoveryInfo.moduleName; 61 }; 62 auto i = find_if(instance.recoveryInfoQueue_.begin(), instance.recoveryInfoQueue_.end(), findByInfo); 63 EXPECT_TRUE(i != instance.recoveryInfoQueue_.end()); 64 } 65 } // namespace AAFwk 66 } // namespace OHOS 67