• 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  * @tc.name: OH_NativeVSync_Create001
46  * @tc.desc: test for call OH_NativeVSync_Create by abnormal input and check ret
47  * @tc.type: FUNC
48  */
49 HWTEST_F(NativeVsyncTest, OH_NativeVSync_Create001, Function | MediumTest | Level2)
50 {
51     ASSERT_EQ(OH_NativeVSync_Create(nullptr, 0), nullptr);
52 }
53 
54 /*
55  * @tc.name: OH_NativeVSync_Create002
56  * @tc.desc: test for call OH_NativeVSync_Create and check ret
57  * @tc.type: FUNC
58  */
59 HWTEST_F(NativeVsyncTest, OH_NativeVSync_Create002, Function | MediumTest | Level2)
60 {
61     char name[] = "test";
62     native_vsync = OH_NativeVSync_Create(name, sizeof(name));
63     ASSERT_NE(native_vsync, nullptr);
64 }
65 
66 /*
67  * @tc.name: OH_NativeVSync_RequestFrame001
68  * @tc.desc: test for call OH_NativeVSync_RequestFrame by abnormal input and check ret
69  * @tc.type: FUNC
70  */
71 HWTEST_F(NativeVsyncTest, OH_NativeVSync_RequestFrame001, Function | MediumTest | Level2)
72 {
73     ASSERT_NE(OH_NativeVSync_RequestFrame(nullptr, nullptr, nullptr), 0);
74 }
75 
76 /*
77  * @tc.name: OH_NativeVSync_RequestFrame002
78  * @tc.desc: test for call OH_NativeVSync_RequestFrame by abnormal input and check ret
79  * @tc.type: FUNC
80  */
81 HWTEST_F(NativeVsyncTest, OH_NativeVSync_RequestFrame002, Function | MediumTest | Level2)
82 {
83     ASSERT_NE(OH_NativeVSync_RequestFrame(native_vsync, nullptr, nullptr), 0);
84 }
85 
86 /*
87  * @tc.name: OH_NativeVSync_RequestFrame003
88  * @tc.desc: test for call OH_NativeVSync_RequestFrame and check ret
89  * @tc.type: FUNC
90  */
91 HWTEST_F(NativeVsyncTest, OH_NativeVSync_RequestFrame003, Function | MediumTest | Level2)
92 {
93     OH_NativeVSync_FrameCallback callback = OnVSync;
94     ASSERT_EQ(OH_NativeVSync_RequestFrame(native_vsync, callback, nullptr), 0);
95 }
96 
97 /*
98  * @tc.name: OH_NativeVSync_Destroy001
99  * @tc.desc: test for call OH_NativeVSync_Destroy by abnormal input and check ret
100  * @tc.type: FUNC
101  */
102 HWTEST_F(NativeVsyncTest, OH_NativeVSync_Destroy001, Function | MediumTest | Level2)
103 {
104     OH_NativeVSync_Destroy(nullptr);
105 }
106 
107 /*
108  * @tc.name: OH_NativeVSync_Destroy002
109  * @tc.desc: test for call OH_NativeVSync_Destroy and check ret
110  * @tc.type: FUNC
111  */
112 HWTEST_F(NativeVsyncTest, OH_NativeVSync_Destroy002, Function | MediumTest | Level2)
113 {
114     OH_NativeVSync_Destroy(native_vsync);
115 }
116 } // namespace
117 } // namespace Rosen
118 } // namespace OHOS