• 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 "boot_animation_utils.h"
19 #include "boot_sound_player.h"
20 #include "parameters.h"
21 
22 using namespace testing;
23 using namespace testing::ext;
24 
25 namespace OHOS::Rosen {
26 class BootSoundPlayerTest : 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 BootSoundPlayerTest::SetUpTestCase() {}
TearDownTestCase()35 void BootSoundPlayerTest::TearDownTestCase() {}
SetUp()36 void BootSoundPlayerTest::SetUp() {}
TearDown()37 void BootSoundPlayerTest::TearDown() {}
38 
39 /**
40  * @tc.name: BootSoundPlayerTest_001
41  * @tc.desc: Verify the Play
42  * @tc.type:FUNC
43  */
44 HWTEST_F(BootSoundPlayerTest, BootSoundPlayerTest_001, TestSize.Level1)
45 {
46     PlayerParams params1;
47     params1.soundEnabled = false;
48     std::shared_ptr<BootSoundPlayer> player1 = std::make_shared<BootSoundPlayer>(params1);
49     player1->Play();
50 
51     PlayerParams params2;
52     params2.soundEnabled = true;
53     std::shared_ptr<BootSoundPlayer> player2 = std::make_shared<BootSoundPlayer>(params2);
54     player2->Play();
55 
56     PlayerParams params3;
57     params3.soundEnabled = true;
58     std::shared_ptr<BootSoundPlayer> player3 = std::make_shared<BootSoundPlayer>(params3);
59     BootAnimationUtils::SetBootAnimationSoundEnabled(false);
60     EXPECT_EQ(BootAnimationUtils::GetBootAnimationSoundEnabled(), false);
61     player3->Play();
62 }
63 
64 /**
65  * @tc.name: BootSoundPlayerTest_002
66  * @tc.desc: Verify the Play
67  * @tc.type:FUNC
68  */
69 HWTEST_F(BootSoundPlayerTest, BootSoundPlayerTest_002, TestSize.Level1)
70 {
71     PlayerParams params;
72     params.soundEnabled = true;
73     std::shared_ptr<BootSoundPlayer> player = std::make_shared<BootSoundPlayer>(params);
74     BootAnimationUtils::SetBootAnimationSoundEnabled(true);
75     system::SetParameter(BOOT_SOUND, std::to_string(MIN_VOLUME));
76     EXPECT_EQ(BootAnimationUtils::GetBootAnimationSoundEnabled(), true);
77     player->Play();
78 }
79 
80 /**
81  * @tc.name: BootSoundPlayerTest_003
82  * @tc.desc: Verify the Play
83  * @tc.type:FUNC
84  */
85 HWTEST_F(BootSoundPlayerTest, BootSoundPlayerTest_003, TestSize.Level1)
86 {
87     PlayerParams params;
88     params.soundEnabled = true;
89     std::shared_ptr<BootSoundPlayer> player = std::make_shared<BootSoundPlayer>(params);
90     BootAnimationUtils::SetBootAnimationSoundEnabled(true);
91     system::SetParameter(BOOT_SOUND, std::to_string(MIN_VOLUME + 1));
92     EXPECT_EQ(BootAnimationUtils::GetBootAnimationSoundEnabled(), true);
93     player->Play();
94 }
95 }
96