• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <parameters.h>
19 #include "util.h"
20 #include "boot_animation_strategy.h"
21 
22 using namespace testing;
23 using namespace testing::ext;
24 
25 namespace OHOS::Rosen {
26 class BootAnimationStrategyTest : public testing::Test {
27 public:
28     static void SetUpTestCase();
29     static void TearDownTestCase();
30     void SetUp() override;
31     void TearDown() override;
32 };
33 
SetUpTestCase()34 void BootAnimationStrategyTest::SetUpTestCase() {}
TearDownTestCase()35 void BootAnimationStrategyTest::TearDownTestCase() {}
SetUp()36 void BootAnimationStrategyTest::SetUp() {}
TearDown()37 void BootAnimationStrategyTest::TearDown() {}
38 
39 /**
40  * @tc.name: BootAnimationStrategyTest_001
41  * @tc.desc: Verify the CheckExitAniamtion
42  * @tc.type:FUNC
43  */
44 HWTEST_F(BootAnimationStrategyTest, BootAnimationStrategyTest_001, TestSize.Level0)
45 {
46     std::shared_ptr<BootAnimationStrategy> bas1 = std::make_shared<BootAnimationStrategy>();
47     bas1->isAnimationEnd_ = false;
48     bas1->CheckExitAnimation();
49 
50     std::shared_ptr<BootAnimationStrategy> bas2 = std::make_shared<BootAnimationStrategy>();
51     bas2->isAnimationEnd_ = true;
52     bas2->CheckExitAnimation();
53 
54     std::shared_ptr<BootAnimationStrategy> bas3 = std::make_shared<BootAnimationStrategy>();
55     bas3->isAnimationEnd_ = true;
56     system::SetParameter(BOOT_COMPLETED, "false");
57     EXPECT_EQ(false, system::GetBoolParameter(BOOT_COMPLETED, false));
58     bas3->CheckExitAnimation();
59 
60     std::shared_ptr<BootAnimationStrategy> bas4 = std::make_shared<BootAnimationStrategy>();
61     bas4->isAnimationEnd_ = true;
62     system::SetParameter(BOOT_COMPLETED, "true");
63     EXPECT_EQ(true, system::GetBoolParameter(BOOT_COMPLETED, false));
64     bas4->CheckExitAnimation();
65 }
66 
67 /**
68  * @tc.name: BootAnimationStrategyTest_002
69  * @tc.desc: Verify the IsOtaUpdate
70  * @tc.type:FUNC
71  */
72 HWTEST_F(BootAnimationStrategyTest, BootAnimationStrategyTest_002, TestSize.Level0)
73 {
74     std::shared_ptr<BootAnimationStrategy> strategy = std::make_shared<BootAnimationStrategy>();
75     bool result = system::SetParameter("persist.dupdate_engine.update_type", "manual");
76     EXPECT_EQ(result, strategy->IsOtaUpdate());
77 
78     result = system::SetParameter("persist.dupdate_engine.update_type", "night");
79     EXPECT_EQ(result, strategy->IsOtaUpdate());
80 
81     system::SetParameter("persist.dupdate_engine.update_type", "test");
82     EXPECT_EQ(false, strategy->IsOtaUpdate());
83 }
84 }
85