1 /*
2  * Copyright (c) 2023 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 "boot_animation_utils.h"
19 #include "parameters.h"
20 
21 using namespace testing;
22 using namespace testing::ext;
23 
24 namespace OHOS::Rosen {
25 class BootAnimationUtilsTest : public testing::Test {
26 public:
27     static void SetUpTestCase();
28     static void TearDownTestCase();
29     void SetUp() override;
30     void TearDown() override;
31 };
32 
SetUpTestCase()33 void BootAnimationUtilsTest::SetUpTestCase() {}
TearDownTestCase()34 void BootAnimationUtilsTest::TearDownTestCase() {}
SetUp()35 void BootAnimationUtilsTest::SetUp() {}
TearDown()36 void BootAnimationUtilsTest::TearDown() {}
37 
38 /**
39  * @tc.name: SetBootAnimationSoundEnabled
40  * @tc.desc: Verify the SetBootAnimationSoundEnabled
41  * @tc.type:FUNC
42  */
43 HWTEST_F(BootAnimationUtilsTest, SetBootAnimationSoundEnabled, TestSize.Level1)
44 {
45     BootAnimationUtils::SetBootAnimationSoundEnabled(false);
46     bool soundEnabled =
47         std::atoi((system::GetParameter("persist.graphic.bootsound.enabled", "1")).c_str()) != 0;
48     EXPECT_EQ(soundEnabled, false);
49 }
50 
51 /**
52  * @tc.name: GetBootAnimationSoundEnabled
53  * @tc.desc: Verify the GetBootAnimationSoundEnabled
54  * @tc.type:FUNC
55  */
56 HWTEST_F(BootAnimationUtilsTest, GetBootAnimationSoundEnabled, TestSize.Level1)
57 {
58     bool isEnabled = BootAnimationUtils::GetBootAnimationSoundEnabled();
59     bool soundEnabled =
60         std::atoi((system::GetParameter("persist.graphic.bootsound.enabled", "1")).c_str()) != 0;
61     EXPECT_EQ(soundEnabled, isEnabled);
62 }
63 }
64