• 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 #include <vsync_station.h>
18 
19 using namespace testing;
20 using namespace testing::ext;
21 
22 namespace OHOS {
23 namespace Rosen {
24 class VsyncStationTest : public testing::Test {
25 public:
26     static void SetUpTestCase();
27     static void TearDownTestCase();
28     void SetUp() override;
29     void TearDown() override;
30 };
31 
SetUpTestCase()32 void VsyncStationTest::SetUpTestCase() {}
33 
TearDownTestCase()34 void VsyncStationTest::TearDownTestCase() {}
35 
SetUp()36 void VsyncStationTest::SetUp() {}
37 
TearDown()38 void VsyncStationTest::TearDown() {}
39 
40 namespace {
41 /**
42  * @tc.name: RequestVsyncOneWindow
43  * @tc.desc: RequestVsyncOneWindow Test
44  * @tc.type: FUNC
45  */
46 HWTEST_F(VsyncStationTest, RequestVsyncOneWindow, Function | SmallTest | Level3)
47 {
48     NodeId nodeId = 0;
49     std::shared_ptr<VsyncStation> vsyncStation = std::make_shared<VsyncStation>(nodeId);
50     std::shared_ptr<VsyncCallback> vsyncCallback = std::make_shared<VsyncCallback>();
51     ASSERT_NE(vsyncStation, nullptr);
52     vsyncStation->RequestVsync(vsyncCallback);
53 }
54 
55 /**
56  * @tc.name: RequestVsyncMultiWindow
57  * @tc.desc: RequestVsyncMultiWindow Test
58  * @tc.type: FUNC
59  */
60 HWTEST_F(VsyncStationTest, RequestVsyncMultiWindow, Function | SmallTest | Level3)
61 {
62     NodeId nodeId0 = 0;
63     std::shared_ptr<VsyncStation> vsyncStation0 = std::make_shared<VsyncStation>(nodeId0);
64     std::shared_ptr<VsyncCallback> vsyncCallback0 = std::make_shared<VsyncCallback>();
65     ASSERT_NE(vsyncStation0, nullptr);
66     vsyncStation0->RequestVsync(vsyncCallback0);
67     NodeId nodeId1 = 1;
68     std::shared_ptr<VsyncStation> vsyncStation1 = std::make_shared<VsyncStation>(nodeId1);
69     std::shared_ptr<VsyncCallback> vsyncCallback1 = std::make_shared<VsyncCallback>();
70     ASSERT_NE(vsyncStation1, nullptr);
71     vsyncStation1->RequestVsync(vsyncCallback1);
72 }
73 
74 /**
75  * @tc.name: GetFrameRateLinkerId
76  * @tc.desc: GetFrameRateLinkerId Test
77  * @tc.type: FUNC
78  */
79 HWTEST_F(VsyncStationTest, GetFrameRateLinkerId, Function | SmallTest | Level3)
80 {
81     NodeId nodeId0 = 0;
82     std::shared_ptr<VsyncStation> vsyncStation0 = std::make_shared<VsyncStation>(nodeId0);
83     ASSERT_NE(vsyncStation0, nullptr);
84     ASSERT_NE(-1, vsyncStation0->GetFrameRateLinkerId());
85     NodeId nodeId1 = 1;
86     std::shared_ptr<VsyncStation> vsyncStation1 = std::make_shared<VsyncStation>(nodeId1);
87     ASSERT_NE(vsyncStation1, nullptr);
88     ASSERT_NE(-1, vsyncStation1->GetFrameRateLinkerId());
89 }
90 
91 /**
92  * @tc.name: FlushFrameRate
93  * @tc.desc: FlushFrameRate Test
94  * @tc.type: FUNC
95  */
96 HWTEST_F(VsyncStationTest, FlushFrameRate, Function | SmallTest | Level3)
97 {
98     NodeId nodeId0 = 0;
99     std::shared_ptr<VsyncStation> vsyncStation0 = std::make_shared<VsyncStation>(nodeId0);
100     ASSERT_NE(vsyncStation0, nullptr);
101     uint32_t rate0 = 60;
102     int32_t animatorExpectedFrameRate = -1;
103     vsyncStation0->FlushFrameRate(rate0, animatorExpectedFrameRate);
104     NodeId nodeId1 = 1;
105     std::shared_ptr<VsyncStation> vsyncStation1 = std::make_shared<VsyncStation>(nodeId1);
106     ASSERT_NE(vsyncStation1, nullptr);
107     uint32_t rate1 = 120;
108     vsyncStation1->FlushFrameRate(rate1, animatorExpectedFrameRate);
109 }
110 
111 /**
112  * @tc.name: SetFrameRateLinkerEnable
113  * @tc.desc: SetFrameRateLinkerEnable Test
114  * @tc.type: FUNC
115  */
116 HWTEST_F(VsyncStationTest, SetFrameRateLinkerEnable, Function | SmallTest | Level3)
117 {
118     NodeId nodeId0 = 0;
119     std::shared_ptr<VsyncStation> vsyncStation0 = std::make_shared<VsyncStation>(nodeId0);
120     ASSERT_NE(vsyncStation0, nullptr);
121     bool enable0 = false;
122     vsyncStation0->SetFrameRateLinkerEnable(enable0);
123     NodeId nodeId1 = 1;
124     std::shared_ptr<VsyncStation> vsyncStation1 = std::make_shared<VsyncStation>(nodeId1);
125     ASSERT_NE(vsyncStation1, nullptr);
126     bool enable1 = true;
127     vsyncStation1->SetFrameRateLinkerEnable(enable1);
128 }
129 
130 /**
131  * @tc.name: SetUiDvsyncSwitch
132  * @tc.desc: SetUiDvsyncSwitch Test
133  * @tc.type: FUNC
134  */
135 HWTEST_F(VsyncStationTest, SetUiDvsyncSwitch, Function | SmallTest | Level3)
136 {
137     NodeId nodeId = 0;
138     std::shared_ptr<VsyncStation> vsyncStation = std::make_shared<VsyncStation>(nodeId);
139     ASSERT_NE(vsyncStation, nullptr);
140     vsyncStation->SetUiDvsyncSwitch(true);
141     vsyncStation->SetUiDvsyncSwitch(false);
142 }
143 } // namespace
144 } // namespace Rosen
145 } // namespace OHOS