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
16import { describe, expect, it } from '@ohos/hypium'
17import vsync from 'libnativevsync.so'
18
19export default function nativeVsyncTest() {
20  describe('NativeVsyncTest', () => {
21
22    /**
23     * @tc.number     : SUB_BASIC_GRAPHICS_SPECIAL_API_C_NATIVE_VSYNC_0100
24     * @tc.name       : testNativeVSyncCreateNull
25     * @tc.desc       : test OH_NativeVSync_Create
26     * @tc.size       : MediumTest
27     * @tc.type       : Function
28     * @tc.level      : Level 4
29     */
30    it('testNativeVSyncCreateNull', 0, async (done: Function) => {
31      let result: number = vsync.oHNativeVSyncCreateNull();
32      console.info("testNativeVSyncCreateNull result:" + result)
33      expect(result).assertEqual(-1);
34      done();
35    });
36
37    /**
38     * @tc.number     : SUB_BASIC_GRAPHICS_SPECIAL_API_C_NATIVE_VSYNC_0101
39     * @tc.name       : testNativeVSyncCreateNotEq
40     * @tc.desc       : test OH_NativeVSync_Create
41     * @tc.size       : MediumTest
42     * @tc.type       : Function
43     * @tc.level      : Level 3
44     */
45
46    it('testNativeVSyncCreateNotEq', 0, async (done: Function) => {
47      let result: number = vsync.oHNativeVSyncCreateNotEq();
48      console.info("testNativeVSyncCreateNotEq result:" + result)
49      expect(result).assertEqual(0);
50      done();
51    });
52
53    /**
54     * @tc.number     : SUB_BASIC_GRAPHICS_SPECIAL_API_C_NATIVE_VSYNC_0102
55     * @tc.name       : testNativeVSyncCreateNormal
56     * @tc.desc       : test OH_NativeVSync_Create
57     * @tc.size       : MediumTest
58     * @tc.type       : Function
59     * @tc.level      : Level 0
60     */
61
62    it('testNativeVSyncCreateNormal', 0, async (done: Function) => {
63      let result: Array<number> = vsync.oHNativeVSyncCreateNormal();
64      console.info("testNativeVSyncCreateNormal result:" + result)
65      expect(result[0]).assertEqual(0);
66      // 有错误,再次调用接口调用成功,
67      // expect(result[1]).assertEqual(-1);
68      done();
69    });
70
71    /**
72     * @tc.number     : SUB_BASIC_GRAPHICS_SPECIAL_API_C_NATIVE_VSYNC_0103
73     * @tc.name       : testNativeVSyncCreateAbnormal
74     * @tc.desc       : test OH_NativeVSync_Create
75     * @tc.size       : MediumTest
76     * @tc.type       : Function
77     * @tc.level      : Level 3
78     */
79
80    it('testNativeVSyncCreateAbnormal', 0, async (done: Function) => {
81      let result: number = vsync.oHNativeVSyncCreateAbnormal();
82      console.info("testNativeVSyncCreateAbnormal result:" + result)
83      expect(result).assertEqual(0);
84      done();
85    });
86
87    /**
88     * @tc.number     : SUB_BASIC_GRAPHICS_SPECIAL_API_C_NATIVE_VSYNC_0104
89     * @tc.name       : testNativeVSyncCreateDifLenth
90     * @tc.desc       : test OH_NativeVSync_Create
91     * @tc.size       : MediumTest
92     * @tc.type       : Function
93     * @tc.level      : Level 2
94     */
95
96    it('testNativeVSyncCreateDifLenth', 0, async (done: Function) => {
97      let result: Array<number> = vsync.oHNativeVSyncCreateDifLenth();
98      console.info("testNativeVSyncCreateDifLenth result:" + result)
99      expect(result).assertEqual(0);
100      done();
101    });
102
103    /**
104     * @tc.number     : SUB_BASIC_GRAPHICS_SPECIAL_API_C_NATIVE_VSYNC_0105
105     * @tc.name       : testNativeVSyncCreateMuch
106     * @tc.desc       : test OH_NativeVSync_Create
107     * @tc.size       : MediumTest
108     * @tc.type       : Function
109     * @tc.level      : Level 0
110     */
111
112    it('testNativeVSyncCreateMuch', 0, async (done: Function) => {
113      let result: number = vsync.oHNativeVSyncCreateMuch();
114      console.info("testNativeVSyncCreateMuch result:" + result)
115      expect(result).assertEqual(0);
116      done();
117    });
118
119    /**
120     * @tc.number     : SUB_BASIC_GRAPHICS_SPECIAL_API_C_NATIVE_VSYNC_0106
121     * @tc.name       : testNativeVSyncGetPeriodNullptr
122     * @tc.desc       : test OH_NativeVSync_GetPeriod
123     * @tc.size       : MediumTest
124     * @tc.type       : Function
125     * @tc.level      : Level 3
126     */
127
128    it('testNativeVSyncGetPeriodNullptr', 0, async (done: Function) => {
129      let result: number = vsync.oHNativeVSyncGetPeriodNullptr();
130      console.info("testNativeVSyncGetPeriodNullptr result:" + result);
131      expect(result).assertEqual(40001000);
132      done();
133    });
134    
135    /**
136     * @tc.number     : SUB_BASIC_GRAPHICS_SPECIAL_API_C_NATIVE_VSYNC_0109
137     * @tc.name       : testNativeVSyncRequestFrameNullptr
138     * @tc.desc       : test OH_NativeVSync_RequestFrame
139     * @tc.size       : MediumTest
140     * @tc.type       : Function
141     * @tc.level      : Level 3
142     */
143
144    it('testNativeVSyncRequestFrameNullptr', 0, async (done: Function) => {
145      let result: Array<number> = vsync.oHNativeVSyncRequestFrameNullptr();
146      console.info("testNativeVSyncRequestFrameNullptr result:" + result);
147      expect(result).assertEqual(0);
148      done();
149    });
150
151    /**
152     * @tc.number     : SUB_BASIC_GRAPHICS_SPECIAL_API_C_NATIVE_VSYNC_0110
153     * @tc.name       : testNativeVSyncRequestFrameNormal
154     * @tc.desc       : test OH_NativeVSync_RequestFrame
155     * @tc.size       : MediumTest
156     * @tc.type       : Function
157     * @tc.level      : Level 0
158     */
159
160    it('testNativeVSyncRequestFrameNormal', 0, async (done: Function) => {
161      let result: number = vsync.oHNativeVSyncRequestFrameNormal();
162      console.info("testNativeVSyncRequestFrameNormal result:" + result);
163      expect(result).assertEqual(0);
164      done();
165    });
166
167    /**
168     * @tc.number     : SUB_BASIC_GRAPHICS_SPECIAL_API_C_NATIVE_VSYNC_0111
169     * @tc.name       : testNativeVSyncRequestFrameParamErr
170     * @tc.desc       : test OH_NativeVSync_RequestFrame
171     * @tc.size       : MediumTest
172     * @tc.type       : Function
173     * @tc.level      : Level 4
174     */
175
176    it('testNativeVSyncRequestFrameParamErr', 0, async (done: Function) => {
177      let result: number = vsync.oHNativeVSyncRequestFrameParamErr();
178      console.info("testNativeVSyncRequestFrameParamErr result:" + result);
179      expect(result).assertEqual(0);
180      done();
181    });
182
183    it('testOHNativeVSyncCreate001', 0, async (done: Function) => {
184      let result: number = vsync.oHNativeVSyncCreate();
185      expect(result).assertEqual(0);
186      done();
187    });
188
189    /**
190     * @tc.number     : SUB_GRAPHIC_GRAPHIC_2D_NATIVE_VSYNC_OH_NATIVEVSYNC_CREATE_0200
191     * @tc.name       : testOHNativeVSyncCreate002
192     * @tc.desc       : test OH_NativeVSync_Create
193     * @tc.size       : MediumTest
194     * @tc.type       : Function
195     * @tc.level      : Level 1
196     */
197    it('testOHNativeVSyncCreate002', 0, async (done: Function) => {
198      let result: number = vsync.oHNativeVSyncCreateFOne();
199      expect(result).assertEqual(0);
200      done();
201    });
202
203    /**
204     * @tc.number     : SUB_GRAPHIC_GRAPHIC_2D_NATIVE_VSYNC_OH_NATIVEVSYNC_REQUESTFRAME_0100
205     * @tc.name       : testOHNativeVSyncRequestFrame001
206     * @tc.desc       : test OH_NativeVSync_RequestFrame
207     * @tc.size       : MediumTest
208     * @tc.type       : Function
209     * @tc.level      : Level 1
210     */
211    it('testOHNativeVSyncRequestFrame001', 0, async (done: Function) => {
212      let result: number = vsync.oHNativeVSyncRequestFrame();
213      expect(result).assertEqual(0);
214      done();
215    });
216
217    /**
218     * @tc.number     : SUB_GRAPHIC_GRAPHIC_2D_NATIVE_VSYNC_OH_NATIVEVSYNC_REQUESTFRAME_0200
219     * @tc.name       : testOHNativeVSyncRequestFrame002
220     * @tc.desc       : test OH_NativeVSync_RequestFrame
221     * @tc.size       : MediumTest
222     * @tc.type       : Function
223     * @tc.level      : Level 1
224     */
225    it('testOHNativeVSyncRequestFrame002', 0, async (done: Function) => {
226      let result: number = vsync.oHNativeVSyncRequestFrameFOne();
227      expect(result).assertEqual(0);
228      done();
229    });
230
231    /**
232     * @tc.number     : SUB_GRAPHIC_GRAPHIC_2D_NATIVE_VSYNC_OH_NATIVEVSYNC_REQUESTFRAME_0300
233     * @tc.name       : testOHNativeVSyncRequestFrame003
234     * @tc.desc       : test OH_NativeVSync_RequestFrame
235     * @tc.size       : MediumTest
236     * @tc.type       : Function
237     * @tc.level      : Level 1
238     */
239    it('testOHNativeVSyncRequestFrame003', 0, async (done: Function) => {
240      let result: number = vsync.oHNativeVSyncRequestFrameFTwo();
241      expect(result).assertEqual(0);
242      done();
243    });
244
245    /**
246     * @tc.number     : SUB_GRAPHIC_GRAPHIC_2D_NATIVE_VSYNC_OH_NATIVEVSYNC_GETPERIOD_0100
247     * @tc.name       : testOHNativeVSyncGetPeriod001
248     * @tc.desc       : test OH_NativeVSync_GetPeriod
249     * @tc.size       : MediumTest
250     * @tc.type       : Function
251     * @tc.level      : Level 1
252     */
253    it('testOHNativeVSyncGetPeriod001', 0, async (done: Function) => {
254      let result: number = vsync.oHNativeVSyncGetPeriod();
255      expect(result).assertEqual(0);
256      done();
257    });
258
259    /**
260     * @tc.number     : SUB_GRAPHIC_GRAPHIC_2D_NATIVE_VSYNC_OH_NATIVEVSYNC_GETPERIOD_0100
261     * @tc.name       : testOHNativeVSyncGetPeriod002
262     * @tc.desc       : test OH_NativeVSync_GetPeriod
263     * @tc.size       : MediumTest
264     * @tc.type       : Function
265     * @tc.level      : Level 1
266     */
267    it('testOHNativeVSyncGetPeriod002', 0, async (done: Function) => {
268      let result: number = vsync.oHNativeVSyncGetPeriodFOne();
269      expect(result).assertEqual(0);
270      done();
271    });
272
273  })
274}