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 20 using namespace testing; 21 using namespace testing::ext; 22 23 namespace OHOS::Rosen { 24 namespace { 25 class VSyncLimitTest : public testing::Test { 26 }; 27 28 /* 29 * Function: OH_NativeVSync_Create 30 * Type: Function 31 * Rank: Important(2) 32 * EnvConditions: N/A 33 * CaseDescription: NativeVSyncLimitTest 34 */ 35 HWTEST_F(VSyncLimitTest, NativeVSyncLimitTest, Function | MediumTest | Level2) 36 { 37 std::vector<OH_NativeVSync *> nativeVsyncArray; 38 char name[] = "vsyncLimitTest"; 39 for (int i = 0; i < 257; i++) { 40 OH_NativeVSync *native_vsync = OH_NativeVSync_Create(name, sizeof(name)); 41 ASSERT_NE(native_vsync, nullptr); 42 nativeVsyncArray.push_back(native_vsync); 43 } 44 OH_NativeVSync *nativeVsync = OH_NativeVSync_Create(name, sizeof(name)); 45 ASSERT_EQ(nativeVsync, nullptr); 46 for (int i = 0; i < nativeVsyncArray.size(); i++) { 47 OH_NativeVSync_Destroy(nativeVsyncArray[i]); 48 } 49 } 50 } 51 }