• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 #include <gtest/gtest.h>
16 #include "native_vsync.h"
17 
18 using namespace testing;
19 using namespace testing::ext;
20 
21 namespace OHOS {
22 namespace Rosen {
23 class NativeVsyncTest : public testing::Test {
24 public:
25     static void SetUpTestCase();
26     static void TearDownTestCase();
27 
28     static inline OH_NativeVSync* native_vsync = nullptr;
29 };
30 
SetUpTestCase()31 void NativeVsyncTest::SetUpTestCase()
32 {
33 }
34 
TearDownTestCase()35 void NativeVsyncTest::TearDownTestCase()
36 {
37 }
38 
OnVSync(long long timestamp,void * data)39 static void OnVSync(long long timestamp, void* data)
40 {
41 }
42 
43 namespace {
44 /*
45 * Function: OH_NativeVSync_Create
46 * Type: Function
47 * Rank: Important(2)
48 * EnvConditions: N/A
49 * CaseDescription: 1. call OH_NativeVSync_Create by abnormal input
50 *                  2. check ret
51  */
52 HWTEST_F(NativeVsyncTest, OH_NativeVSync_Create001, Function | MediumTest | Level2)
53 {
54     ASSERT_EQ(OH_NativeVSync_Create(nullptr, 0), nullptr);
55 }
56 
57 /*
58 * Function: OH_NativeVSync_Create
59 * Type: Function
60 * Rank: Important(2)
61 * EnvConditions: N/A
62 * CaseDescription: 1. call OH_NativeVSync_Create
63 *                  2. check ret
64  */
65 HWTEST_F(NativeVsyncTest, OH_NativeVSync_Create002, Function | MediumTest | Level2)
66 {
67     char name[] = "test";
68     native_vsync = OH_NativeVSync_Create(name, sizeof(name));
69     ASSERT_NE(native_vsync, nullptr);
70 }
71 
72 /*
73 * Function: OH_NativeVSync_RequestFrame
74 * Type: Function
75 * Rank: Important(2)
76 * EnvConditions: N/A
77 * CaseDescription: 1. call OH_NativeVSync_RequestFrame by abnormal input
78 *                  2. check ret
79  */
80 HWTEST_F(NativeVsyncTest, OH_NativeVSync_RequestFrame001, Function | MediumTest | Level2)
81 {
82     ASSERT_NE(OH_NativeVSync_RequestFrame(nullptr, nullptr, nullptr), 0);
83 }
84 
85 /*
86 * Function: OH_NativeVSync_RequestFrame
87 * Type: Function
88 * Rank: Important(2)
89 * EnvConditions: N/A
90 * CaseDescription: 1. call OH_NativeVSync_RequestFrame by abnormal input
91 *                  2. check ret
92  */
93 HWTEST_F(NativeVsyncTest, OH_NativeVSync_RequestFrame002, Function | MediumTest | Level2)
94 {
95     ASSERT_NE(OH_NativeVSync_RequestFrame(native_vsync, nullptr, nullptr), 0);
96 }
97 
98 /*
99 * Function: OH_NativeVSync_RequestFrame
100 * Type: Function
101 * Rank: Important(2)
102 * EnvConditions: N/A
103 * CaseDescription: 1. call OH_NativeVSync_RequestFrame
104 *                  2. check ret
105  */
106 HWTEST_F(NativeVsyncTest, OH_NativeVSync_RequestFrame003, Function | MediumTest | Level2)
107 {
108     OH_NativeVSync_FrameCallback callback = OnVSync;
109     ASSERT_EQ(OH_NativeVSync_RequestFrame(native_vsync, callback, nullptr), 0);
110 }
111 
112 /*
113 * Function: OH_NativeVSync_Destroy
114 * Type: Function
115 * Rank: Important(2)
116 * EnvConditions: N/A
117 * CaseDescription: 1. call OH_NativeVSync_Destroy by abnormal input
118 *                  2. check ret
119  */
120 HWTEST_F(NativeVsyncTest, OH_NativeVSync_Destroy001, Function | MediumTest | Level2)
121 {
122     OH_NativeVSync_Destroy(nullptr);
123 }
124 
125 /*
126 * Function: OH_NativeVSync_Destroy
127 * Type: Function
128 * Rank: Important(2)
129 * EnvConditions: N/A
130 * CaseDescription: 1. call OH_NativeVSync_Destroy
131 *                  2. check ret
132  */
133 HWTEST_F(NativeVsyncTest, OH_NativeVSync_Destroy002, Function | MediumTest | Level2)
134 {
135     OH_NativeVSync_Destroy(native_vsync);
136 }
137 } // namespace
138 } // namespace Rosen
139 } // namespace OHOS