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 #include <gtest/gtest.h>
16 #include <unistd.h>
17 #include <vector>
18 #include "native_vsync.h"
19 #include "graphic_common_c.h"
20
21 using namespace testing;
22 using namespace testing::ext;
23
24 namespace OHOS::Rosen {
25 namespace {
OnVSync(long long time,void * data)26 static void OnVSync(long long time, void *data)
27 {
28 }
29 }
30 class NativeVSyncGetPeriodTest : public testing::Test {
31 };
32
33 /*
34 * Function: OH_NativeVSync_GetPeriod
35 * Type: Function
36 * Rank: Important(2)
37 * EnvConditions: N/A
38 * CaseDescription: OH_NativeVSync_GetPeriod
39 */
40 HWTEST_F(NativeVSyncGetPeriodTest, NativeVSyncGetPeriod_Test, Function | MediumTest | Level2)
41 {
42 char name[] = "TestMultiTimes";
43 OH_NativeVSync *native_vsync = OH_NativeVSync_Create(name, sizeof(name));
44 OH_NativeVSync_FrameCallback callback = OnVSync;
45 OH_NativeVSync_RequestFrame(native_vsync, callback, nullptr);
46 usleep(200000); // 200000us
47 long long period = 0;
48 ASSERT_EQ(OH_NativeVSync_GetPeriod(native_vsync, &period), VSYNC_ERROR_OK);
49 ASSERT_NE(period, 0);
50 }
51 }