1094332d3Sopenharmony_ci/* 2094332d3Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License. 5094332d3Sopenharmony_ci * You may obtain a copy of the License at 6094332d3Sopenharmony_ci * 7094332d3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8094332d3Sopenharmony_ci * 9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and 13094332d3Sopenharmony_ci * limitations under the License. 14094332d3Sopenharmony_ci */ 15094332d3Sopenharmony_ci 16094332d3Sopenharmony_ci#include <mutex> 17094332d3Sopenharmony_ci#include <chrono> 18094332d3Sopenharmony_ci#include <cinttypes> 19094332d3Sopenharmony_ci#include <algorithm> 20094332d3Sopenharmony_ci#include <condition_variable> 21094332d3Sopenharmony_ci#include <benchmark/benchmark.h> 22094332d3Sopenharmony_ci#include "gtest/gtest.h" 23094332d3Sopenharmony_ci#include "v1_2/include/idisplay_composer_interface.h" 24094332d3Sopenharmony_ci#include "v1_1/display_composer_type.h" 25094332d3Sopenharmony_ci#include "v1_0/display_buffer_type.h" 26094332d3Sopenharmony_ci#include "display_test.h" 27094332d3Sopenharmony_ci#include "display_test_utils.h" 28094332d3Sopenharmony_ci#include "hdi_composition_check.h" 29094332d3Sopenharmony_ci#include "hdi_test_device.h" 30094332d3Sopenharmony_ci#include "hdi_test_device_common.h" 31094332d3Sopenharmony_ci#include "hdi_test_display.h" 32094332d3Sopenharmony_ci#include "hdi_test_render_utils.h" 33094332d3Sopenharmony_ci 34094332d3Sopenharmony_ciusing namespace OHOS::HDI::Display::Buffer::V1_0; 35094332d3Sopenharmony_ciusing namespace OHOS::HDI::Display::Composer::V1_2; 36094332d3Sopenharmony_ciusing namespace OHOS::HDI::Display::TEST; 37094332d3Sopenharmony_ciusing namespace testing::ext; 38094332d3Sopenharmony_ci 39094332d3Sopenharmony_cistatic sptr<Composer::V1_2::IDisplayComposerInterface> g_composerDevice = nullptr; 40094332d3Sopenharmony_cistatic std::shared_ptr<IDisplayBuffer> g_gralloc = nullptr; 41094332d3Sopenharmony_cistatic std::vector<uint32_t> g_displayIds; 42094332d3Sopenharmony_ci 43094332d3Sopenharmony_cinamespace { 44094332d3Sopenharmony_ciclass DisplayBenchmarkTest : public benchmark::Fixture { 45094332d3Sopenharmony_cipublic: 46094332d3Sopenharmony_ci void TearDown(const ::benchmark::State &state); 47094332d3Sopenharmony_ci static void OnMode(uint32_t modeId, uint64_t vBlankPeriod, void* data); 48094332d3Sopenharmony_ci static void OnseamlessChange(uint32_t devId, void* data); 49094332d3Sopenharmony_ci static void TestRefreshCallback(uint32_t devId, void* data); 50094332d3Sopenharmony_ci}; 51094332d3Sopenharmony_ci 52094332d3Sopenharmony_civoid DisplayBenchmarkTest::TearDown(const ::benchmark::State &state) 53094332d3Sopenharmony_ci{ 54094332d3Sopenharmony_ci HdiTestDevice::GetInstance().Clear(); 55094332d3Sopenharmony_ci} 56094332d3Sopenharmony_ci 57094332d3Sopenharmony_civoid DisplayBenchmarkTest::OnMode(uint32_t modeId, uint64_t vBlankPeriod, void* data) 58094332d3Sopenharmony_ci{ 59094332d3Sopenharmony_ci} 60094332d3Sopenharmony_ci 61094332d3Sopenharmony_civoid DisplayBenchmarkTest::OnseamlessChange(uint32_t devId, void* data) 62094332d3Sopenharmony_ci{ 63094332d3Sopenharmony_ci} 64094332d3Sopenharmony_ci 65094332d3Sopenharmony_civoid DisplayBenchmarkTest::TestRefreshCallback(uint32_t devId, void* data) 66094332d3Sopenharmony_ci{ 67094332d3Sopenharmony_ci} 68094332d3Sopenharmony_ci 69094332d3Sopenharmony_ci/** 70094332d3Sopenharmony_ci * @tc.name: SetClientBufferCacheCountTest 71094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface SetClientBufferCacheCount. 72094332d3Sopenharmony_ci */ 73094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, SetClientBufferCacheCountTest)(benchmark::State &state) 74094332d3Sopenharmony_ci{ 75094332d3Sopenharmony_ci int32_t ret; 76094332d3Sopenharmony_ci const uint32_t CACHE_COUNT = 5; 77094332d3Sopenharmony_ci for (auto _ : state) { 78094332d3Sopenharmony_ci ret = g_composerDevice->SetClientBufferCacheCount(g_displayIds[0], CACHE_COUNT); 79094332d3Sopenharmony_ci } 80094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 81094332d3Sopenharmony_ci} 82094332d3Sopenharmony_ci 83094332d3Sopenharmony_ci/** 84094332d3Sopenharmony_ci * @tc.name: GetDisplayCapabilityTest 85094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface GetDisplayCapability. 86094332d3Sopenharmony_ci */ 87094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, GetDisplayCapabilityTest)(benchmark::State &state) 88094332d3Sopenharmony_ci{ 89094332d3Sopenharmony_ci int32_t ret; 90094332d3Sopenharmony_ci DisplayCapability info; 91094332d3Sopenharmony_ci for (auto _ : state) { 92094332d3Sopenharmony_ci ret = g_composerDevice->GetDisplayCapability(g_displayIds[0], info); 93094332d3Sopenharmony_ci } 94094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 95094332d3Sopenharmony_ci} 96094332d3Sopenharmony_ci 97094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, GetDisplayCapabilityTest)-> 98094332d3Sopenharmony_ci Iterations(100)->Repetitions(3)->ReportAggregatesOnly(); 99094332d3Sopenharmony_ci 100094332d3Sopenharmony_ci/** 101094332d3Sopenharmony_ci * @tc.name: GetDisplaySupportedModesTest 102094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface GetDisplaySupportedModes. 103094332d3Sopenharmony_ci */ 104094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, GetDisplaySupportedModesTest)(benchmark::State &state) 105094332d3Sopenharmony_ci{ 106094332d3Sopenharmony_ci int32_t ret; 107094332d3Sopenharmony_ci std::vector<DisplayModeInfo> modes; 108094332d3Sopenharmony_ci for (auto _ : state) { 109094332d3Sopenharmony_ci ret = g_composerDevice->GetDisplaySupportedModes(g_displayIds[0], modes); 110094332d3Sopenharmony_ci } 111094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 112094332d3Sopenharmony_ci} 113094332d3Sopenharmony_ci 114094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, GetDisplaySupportedModesTest)-> 115094332d3Sopenharmony_ci Iterations(100)->Repetitions(3)->ReportAggregatesOnly(); 116094332d3Sopenharmony_ci 117094332d3Sopenharmony_ci/** 118094332d3Sopenharmony_ci * @tc.name: GetDisplayModeTest 119094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface GetDisplayMode. 120094332d3Sopenharmony_ci */ 121094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, GetDisplayModeTest)(benchmark::State &state) 122094332d3Sopenharmony_ci{ 123094332d3Sopenharmony_ci int32_t ret; 124094332d3Sopenharmony_ci uint32_t modeId = 0; 125094332d3Sopenharmony_ci for (auto _ : state) { 126094332d3Sopenharmony_ci ret = g_composerDevice->GetDisplayMode(modeId, modeId); 127094332d3Sopenharmony_ci } 128094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 129094332d3Sopenharmony_ci} 130094332d3Sopenharmony_ci 131094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, GetDisplayModeTest)-> 132094332d3Sopenharmony_ci Iterations(100)->Repetitions(3)->ReportAggregatesOnly(); 133094332d3Sopenharmony_ci 134094332d3Sopenharmony_ci/** 135094332d3Sopenharmony_ci * @tc.name: SetDisplayModeTest 136094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface SetDisplayMode. 137094332d3Sopenharmony_ci */ 138094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, SetDisplayModeTest)(benchmark::State &state) 139094332d3Sopenharmony_ci{ 140094332d3Sopenharmony_ci int32_t ret; 141094332d3Sopenharmony_ci const uint32_t modeId = 0; 142094332d3Sopenharmony_ci for (auto _ : state) { 143094332d3Sopenharmony_ci ret = g_composerDevice->SetDisplayMode(g_displayIds[0], modeId); 144094332d3Sopenharmony_ci } 145094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 146094332d3Sopenharmony_ci} 147094332d3Sopenharmony_ci 148094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, SetDisplayModeTest)-> 149094332d3Sopenharmony_ci Iterations(100)->Repetitions(3)->ReportAggregatesOnly(); 150094332d3Sopenharmony_ci 151094332d3Sopenharmony_ci/** 152094332d3Sopenharmony_ci * @tc.name: GetDisplayPowerStatusTest 153094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface GetDisplayPowerStatus. 154094332d3Sopenharmony_ci */ 155094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, GetDisplayPowerStatusTest)(benchmark::State &state) 156094332d3Sopenharmony_ci{ 157094332d3Sopenharmony_ci int32_t ret; 158094332d3Sopenharmony_ci Composer::V1_0::DispPowerStatus powerStatus = Composer::V1_0::DispPowerStatus::POWER_STATUS_OFF; 159094332d3Sopenharmony_ci for (auto _ : state) { 160094332d3Sopenharmony_ci ret = g_composerDevice->GetDisplayPowerStatus(g_displayIds[0], powerStatus); 161094332d3Sopenharmony_ci } 162094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 163094332d3Sopenharmony_ci} 164094332d3Sopenharmony_ci 165094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, GetDisplayPowerStatusTest)-> 166094332d3Sopenharmony_ci Iterations(100)->Repetitions(3)->ReportAggregatesOnly(); 167094332d3Sopenharmony_ci 168094332d3Sopenharmony_ci/** 169094332d3Sopenharmony_ci * @tc.name: SetDisplayPowerStatusTest 170094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface SetDisplayPowerStatus. 171094332d3Sopenharmony_ci */ 172094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, SetDisplayPowerStatusTest)(benchmark::State &state) 173094332d3Sopenharmony_ci{ 174094332d3Sopenharmony_ci int32_t ret; 175094332d3Sopenharmony_ci for (auto _ : state) { 176094332d3Sopenharmony_ci ret = g_composerDevice->SetDisplayPowerStatus(g_displayIds[0], 177094332d3Sopenharmony_ci Composer::V1_0::DispPowerStatus::POWER_STATUS_ON); 178094332d3Sopenharmony_ci } 179094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 180094332d3Sopenharmony_ci} 181094332d3Sopenharmony_ci 182094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, SetDisplayPowerStatusTest)-> 183094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 184094332d3Sopenharmony_ci 185094332d3Sopenharmony_ci/** 186094332d3Sopenharmony_ci * @tc.name: GetDisplayBacklightTest 187094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface GetDisplayBacklight. 188094332d3Sopenharmony_ci */ 189094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, GetDisplayBacklightTest)(benchmark::State &state) 190094332d3Sopenharmony_ci{ 191094332d3Sopenharmony_ci int32_t ret; 192094332d3Sopenharmony_ci uint32_t level; 193094332d3Sopenharmony_ci for (auto _ : state) { 194094332d3Sopenharmony_ci ret = g_composerDevice->GetDisplayBacklight(g_displayIds[0], level); 195094332d3Sopenharmony_ci } 196094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 197094332d3Sopenharmony_ci} 198094332d3Sopenharmony_ci 199094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, GetDisplayBacklightTest)-> 200094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 201094332d3Sopenharmony_ci 202094332d3Sopenharmony_ci/** 203094332d3Sopenharmony_ci * @tc.name: SetDisplayBacklightTest 204094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface SetDisplayBacklight. 205094332d3Sopenharmony_ci */ 206094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, SetDisplayBacklightTest)(benchmark::State &state) 207094332d3Sopenharmony_ci{ 208094332d3Sopenharmony_ci int32_t ret; 209094332d3Sopenharmony_ci const uint32_t level = 10; 210094332d3Sopenharmony_ci for (auto _ : state) { 211094332d3Sopenharmony_ci ret = g_composerDevice->SetDisplayBacklight(g_displayIds[0], level); 212094332d3Sopenharmony_ci } 213094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 214094332d3Sopenharmony_ci} 215094332d3Sopenharmony_ci 216094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, SetDisplayBacklightTest)-> 217094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 218094332d3Sopenharmony_ci 219094332d3Sopenharmony_ci/** 220094332d3Sopenharmony_ci * @tc.name: CreateAndDestroyLayerTest 221094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface CreateLayer And DestroyLayer. 222094332d3Sopenharmony_ci */ 223094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, CreateAndDestroyLayerTest)(benchmark::State &state) 224094332d3Sopenharmony_ci{ 225094332d3Sopenharmony_ci int32_t ret; 226094332d3Sopenharmony_ci LayerInfo layerInfo; 227094332d3Sopenharmony_ci uint32_t layerId; 228094332d3Sopenharmony_ci for (auto _ : state) { 229094332d3Sopenharmony_ci uint32_t bufferCount = 3; 230094332d3Sopenharmony_ci ret = g_composerDevice->CreateLayer(g_displayIds[0], layerInfo, bufferCount, layerId); 231094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 232094332d3Sopenharmony_ci ret = g_composerDevice->DestroyLayer(g_displayIds[0], layerId); 233094332d3Sopenharmony_ci } 234094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 235094332d3Sopenharmony_ci} 236094332d3Sopenharmony_ci 237094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, CreateAndDestroyLayerTest)-> 238094332d3Sopenharmony_ci Iterations(10)->Repetitions(3)->ReportAggregatesOnly(); 239094332d3Sopenharmony_ci 240094332d3Sopenharmony_ci/** 241094332d3Sopenharmony_ci * @tc.name: GetDisplayCompChangeTest 242094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface GetDisplayCompChange. 243094332d3Sopenharmony_ci */ 244094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, GetDisplayCompChangeTest)(benchmark::State &state) 245094332d3Sopenharmony_ci{ 246094332d3Sopenharmony_ci std::vector<uint32_t> layers {}; 247094332d3Sopenharmony_ci std::vector<int32_t> type {}; 248094332d3Sopenharmony_ci int32_t ret; 249094332d3Sopenharmony_ci for (auto _ : state) { 250094332d3Sopenharmony_ci ret = g_composerDevice->GetDisplayCompChange(g_displayIds[0], layers, type); 251094332d3Sopenharmony_ci } 252094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 253094332d3Sopenharmony_ci} 254094332d3Sopenharmony_ci 255094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, GetDisplayCompChangeTest)-> 256094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 257094332d3Sopenharmony_ci 258094332d3Sopenharmony_ci/** 259094332d3Sopenharmony_ci * @tc.name: GetDisplayReleaseFenceTest 260094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface GetDisplayReleaseFence. 261094332d3Sopenharmony_ci */ 262094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, GetDisplayReleaseFenceTest)(benchmark::State &state) 263094332d3Sopenharmony_ci{ 264094332d3Sopenharmony_ci std::vector<uint32_t> layers {}; 265094332d3Sopenharmony_ci std::vector<int32_t> fences {}; 266094332d3Sopenharmony_ci int32_t ret; 267094332d3Sopenharmony_ci for (auto _ : state) { 268094332d3Sopenharmony_ci ret = g_composerDevice->GetDisplayReleaseFence(g_displayIds[0], layers, fences); 269094332d3Sopenharmony_ci } 270094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 271094332d3Sopenharmony_ci} 272094332d3Sopenharmony_ci 273094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, GetDisplayReleaseFenceTest)-> 274094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 275094332d3Sopenharmony_ci 276094332d3Sopenharmony_ci/** 277094332d3Sopenharmony_ci * @tc.name: CreateAndDestroyVirtualDisplayTest 278094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface CreateVirtualDisplay and DestroyVirtualDisplay. 279094332d3Sopenharmony_ci */ 280094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, CreateAndDestroyVirtualDisplayTest)(benchmark::State &state) 281094332d3Sopenharmony_ci{ 282094332d3Sopenharmony_ci int32_t ret; 283094332d3Sopenharmony_ci const uint32_t WIDTH = 100; 284094332d3Sopenharmony_ci const uint32_t HEIGHT = 100; 285094332d3Sopenharmony_ci int32_t format = 0; 286094332d3Sopenharmony_ci for (auto _ : state) { 287094332d3Sopenharmony_ci ret = g_composerDevice->CreateVirtualDisplay(WIDTH, HEIGHT, format, g_displayIds[0]); 288094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_FAILURE, ret); 289094332d3Sopenharmony_ci ret = g_composerDevice->DestroyVirtualDisplay(g_displayIds[0]); 290094332d3Sopenharmony_ci } 291094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_FAILURE, ret); 292094332d3Sopenharmony_ci} 293094332d3Sopenharmony_ci 294094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, CreateAndDestroyVirtualDisplayTest)-> 295094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 296094332d3Sopenharmony_ci 297094332d3Sopenharmony_ci/** 298094332d3Sopenharmony_ci * @tc.name: SetVirtualDisplayBufferTest 299094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface SetVirtualDisplayBuffer. 300094332d3Sopenharmony_ci */ 301094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, SetVirtualDisplayBufferTest)(benchmark::State &state) 302094332d3Sopenharmony_ci{ 303094332d3Sopenharmony_ci BufferHandle* buffer = nullptr; 304094332d3Sopenharmony_ci int32_t ret; 305094332d3Sopenharmony_ci int32_t fence = -1; 306094332d3Sopenharmony_ci 307094332d3Sopenharmony_ci AllocInfo info; 308094332d3Sopenharmony_ci info.width = 100; 309094332d3Sopenharmony_ci info.height = 100; 310094332d3Sopenharmony_ci info.usage = OHOS::HDI::Display::Composer::V1_0::HBM_USE_MEM_DMA | 311094332d3Sopenharmony_ci OHOS::HDI::Display::Composer::V1_0::HBM_USE_CPU_READ | 312094332d3Sopenharmony_ci OHOS::HDI::Display::Composer::V1_0::HBM_USE_CPU_WRITE; 313094332d3Sopenharmony_ci info.format = Composer::V1_0::PIXEL_FMT_RGBA_8888; 314094332d3Sopenharmony_ci 315094332d3Sopenharmony_ci g_gralloc->AllocMem(info, buffer); 316094332d3Sopenharmony_ci ASSERT_TRUE(buffer != nullptr); 317094332d3Sopenharmony_ci 318094332d3Sopenharmony_ci for (auto _ : state) { 319094332d3Sopenharmony_ci ret = g_composerDevice->SetVirtualDisplayBuffer(g_displayIds[0], *buffer, fence); 320094332d3Sopenharmony_ci } 321094332d3Sopenharmony_ci g_gralloc->FreeMem(*buffer); 322094332d3Sopenharmony_ci // not support 323094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_FAILURE, ret); 324094332d3Sopenharmony_ci} 325094332d3Sopenharmony_ci 326094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, SetVirtualDisplayBufferTest)-> 327094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 328094332d3Sopenharmony_ci 329094332d3Sopenharmony_ci/** 330094332d3Sopenharmony_ci * @tc.name: SetDisplayPropertyTest 331094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface SetDisplayProperty. 332094332d3Sopenharmony_ci */ 333094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, SetDisplayPropertyTest)(benchmark::State &state) 334094332d3Sopenharmony_ci{ 335094332d3Sopenharmony_ci int32_t ret; 336094332d3Sopenharmony_ci uint32_t id = 1; 337094332d3Sopenharmony_ci uint64_t value = 0; 338094332d3Sopenharmony_ci for (auto _ : state) { 339094332d3Sopenharmony_ci ret = g_composerDevice->SetDisplayProperty(g_displayIds[0], id, value); 340094332d3Sopenharmony_ci } 341094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_FAILURE, ret); 342094332d3Sopenharmony_ci} 343094332d3Sopenharmony_ci 344094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, SetDisplayPropertyTest)-> 345094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 346094332d3Sopenharmony_ci 347094332d3Sopenharmony_ci/** 348094332d3Sopenharmony_ci * @tc.name: GetDisplayPropertyTest 349094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface GetDisplayProperty. 350094332d3Sopenharmony_ci */ 351094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, GetDisplayPropertyTest)(benchmark::State &state) 352094332d3Sopenharmony_ci{ 353094332d3Sopenharmony_ci int32_t ret; 354094332d3Sopenharmony_ci uint32_t id = 1; 355094332d3Sopenharmony_ci uint64_t value = 0; 356094332d3Sopenharmony_ci for (auto _ : state) { 357094332d3Sopenharmony_ci ret = g_composerDevice->GetDisplayProperty(g_displayIds[0], id, value); 358094332d3Sopenharmony_ci } 359094332d3Sopenharmony_ci int32_t result = DISPLAY_FAILURE; 360094332d3Sopenharmony_ci if (ret == DISPLAY_SUCCESS || ret == DISPLAY_NOT_SUPPORT) { 361094332d3Sopenharmony_ci result = DISPLAY_SUCCESS; 362094332d3Sopenharmony_ci } 363094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, result); 364094332d3Sopenharmony_ci} 365094332d3Sopenharmony_ci 366094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, GetDisplayPropertyTest)-> 367094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 368094332d3Sopenharmony_ci 369094332d3Sopenharmony_ci 370094332d3Sopenharmony_ci/** 371094332d3Sopenharmony_ci * @tc.name: GetDisplaySupportedModesExtTest 372094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface GetDisplaySupportedModesExtTest. 373094332d3Sopenharmony_ci */ 374094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, GetDisplaySupportedModesExtTest)(benchmark::State &state) 375094332d3Sopenharmony_ci{ 376094332d3Sopenharmony_ci int32_t ret; 377094332d3Sopenharmony_ci std::vector<DisplayModeInfoExt> modes; 378094332d3Sopenharmony_ci for (auto _ : state) { 379094332d3Sopenharmony_ci ret = g_composerDevice->GetDisplaySupportedModesExt(g_displayIds[0], modes); 380094332d3Sopenharmony_ci } 381094332d3Sopenharmony_ci if (ret == DISPLAY_NOT_SUPPORT) { 382094332d3Sopenharmony_ci return; 383094332d3Sopenharmony_ci } 384094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 385094332d3Sopenharmony_ci} 386094332d3Sopenharmony_ci 387094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, GetDisplaySupportedModesExtTest)-> 388094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 389094332d3Sopenharmony_ci 390094332d3Sopenharmony_ci/** 391094332d3Sopenharmony_ci * @tc.name: SetDisplayModeAsyncTest 392094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface SetDisplayModeAsyncTest. 393094332d3Sopenharmony_ci */ 394094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, SetDisplayModeAsyncTest)(benchmark::State &state) 395094332d3Sopenharmony_ci{ 396094332d3Sopenharmony_ci int32_t ret; 397094332d3Sopenharmony_ci uint32_t modeid = 0; 398094332d3Sopenharmony_ci for (auto _ : state) { 399094332d3Sopenharmony_ci ret = g_composerDevice->SetDisplayModeAsync(g_displayIds[0], modeid, OnMode); 400094332d3Sopenharmony_ci } 401094332d3Sopenharmony_ci if (ret == DISPLAY_NOT_SUPPORT) { 402094332d3Sopenharmony_ci return; 403094332d3Sopenharmony_ci } 404094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 405094332d3Sopenharmony_ci} 406094332d3Sopenharmony_ci 407094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, SetDisplayModeAsyncTest)-> 408094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 409094332d3Sopenharmony_ci 410094332d3Sopenharmony_ci/** 411094332d3Sopenharmony_ci * @tc.name: GetDisplayVBlankPeriodTest 412094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface GetDisplayVBlankPeriodTest. 413094332d3Sopenharmony_ci */ 414094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, GetDisplayVBlankPeriodTest)(benchmark::State &state) 415094332d3Sopenharmony_ci{ 416094332d3Sopenharmony_ci int32_t ret; 417094332d3Sopenharmony_ci uint64_t period = 0; 418094332d3Sopenharmony_ci for (auto _ : state) { 419094332d3Sopenharmony_ci ret = g_composerDevice->GetDisplayVBlankPeriod(g_displayIds[0], period); 420094332d3Sopenharmony_ci } 421094332d3Sopenharmony_ci if (ret == DISPLAY_NOT_SUPPORT) { 422094332d3Sopenharmony_ci return; 423094332d3Sopenharmony_ci } 424094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 425094332d3Sopenharmony_ci} 426094332d3Sopenharmony_ci 427094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, GetDisplayVBlankPeriodTest)-> 428094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 429094332d3Sopenharmony_ci 430094332d3Sopenharmony_ci/** 431094332d3Sopenharmony_ci * @tc.name: RegSeamlessChangeCallbackTest 432094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface RegSeamlessChangeCallbackTest. 433094332d3Sopenharmony_ci */ 434094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, RegSeamlessChangeCallbackTest)(benchmark::State &state) 435094332d3Sopenharmony_ci{ 436094332d3Sopenharmony_ci int32_t ret; 437094332d3Sopenharmony_ci for (auto _ : state) { 438094332d3Sopenharmony_ci ret = g_composerDevice->RegSeamlessChangeCallback(OnseamlessChange, nullptr); 439094332d3Sopenharmony_ci } 440094332d3Sopenharmony_ci if (ret == DISPLAY_NOT_SUPPORT) { 441094332d3Sopenharmony_ci return; 442094332d3Sopenharmony_ci } 443094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 444094332d3Sopenharmony_ci} 445094332d3Sopenharmony_ci 446094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, RegSeamlessChangeCallbackTest)-> 447094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 448094332d3Sopenharmony_ci 449094332d3Sopenharmony_ci/** 450094332d3Sopenharmony_ci * @tc.name: SetLayerPerFrameParameterTest 451094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface SetLayerPerFrameParameter. 452094332d3Sopenharmony_ci */ 453094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, SetLayerPerFrameParameterTest)(benchmark::State &state) 454094332d3Sopenharmony_ci{ 455094332d3Sopenharmony_ci int32_t ret; 456094332d3Sopenharmony_ci LayerInfo layerInfo; 457094332d3Sopenharmony_ci uint32_t layerId; 458094332d3Sopenharmony_ci std::string key = "FilmFilter"; 459094332d3Sopenharmony_ci std::vector<int8_t> value = { 1 }; 460094332d3Sopenharmony_ci uint32_t bufferCount = 3; 461094332d3Sopenharmony_ci ret = g_composerDevice->CreateLayer(g_displayIds[0], layerInfo, bufferCount, layerId); 462094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 463094332d3Sopenharmony_ci for (auto _ : state) { 464094332d3Sopenharmony_ci ret = g_composerDevice->SetLayerPerFrameParameter(g_displayIds[0], layerId, key, value); 465094332d3Sopenharmony_ci } 466094332d3Sopenharmony_ci g_composerDevice->DestroyLayer(g_displayIds[0], layerId); 467094332d3Sopenharmony_ci if (ret == DISPLAY_NOT_SUPPORT) { 468094332d3Sopenharmony_ci return; 469094332d3Sopenharmony_ci } 470094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 471094332d3Sopenharmony_ci} 472094332d3Sopenharmony_ci 473094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, SetLayerPerFrameParameterTest)-> 474094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 475094332d3Sopenharmony_ci 476094332d3Sopenharmony_ci/** 477094332d3Sopenharmony_ci * @tc.name: GetSupportedLayerPerFrameParameterKeyTest 478094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface GetSupportedLayerPerFrameParameterKey. 479094332d3Sopenharmony_ci */ 480094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, GetSupportedLayerPerFrameParameterKeyTest)(benchmark::State &state) 481094332d3Sopenharmony_ci{ 482094332d3Sopenharmony_ci int32_t ret; 483094332d3Sopenharmony_ci std::vector<std::string> keys; 484094332d3Sopenharmony_ci for (auto _ : state) { 485094332d3Sopenharmony_ci ret = g_composerDevice->GetSupportedLayerPerFrameParameterKey(keys); 486094332d3Sopenharmony_ci } 487094332d3Sopenharmony_ci if (ret == DISPLAY_NOT_SUPPORT) { 488094332d3Sopenharmony_ci return; 489094332d3Sopenharmony_ci } 490094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 491094332d3Sopenharmony_ci} 492094332d3Sopenharmony_ci 493094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, GetSupportedLayerPerFrameParameterKeyTest)-> 494094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 495094332d3Sopenharmony_ci 496094332d3Sopenharmony_ci/** 497094332d3Sopenharmony_ci * @tc.name: SetDisplayOverlayResolutionTest 498094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface SetDisplayOverlayResolution. 499094332d3Sopenharmony_ci */ 500094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, SetDisplayOverlayResolutionTest)(benchmark::State &state) 501094332d3Sopenharmony_ci{ 502094332d3Sopenharmony_ci int32_t ret; 503094332d3Sopenharmony_ci DisplayModeInfo mode = HdiTestDevice::GetInstance().GetFirstDisplay()->GetCurrentMode(); 504094332d3Sopenharmony_ci for (auto _ : state) { 505094332d3Sopenharmony_ci ret = g_composerDevice->SetDisplayOverlayResolution(g_displayIds[0], mode.width, mode.height); 506094332d3Sopenharmony_ci } 507094332d3Sopenharmony_ci if (ret == DISPLAY_NOT_SUPPORT) { 508094332d3Sopenharmony_ci return; 509094332d3Sopenharmony_ci } 510094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 511094332d3Sopenharmony_ci} 512094332d3Sopenharmony_ci 513094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, SetDisplayOverlayResolutionTest)-> 514094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 515094332d3Sopenharmony_ci 516094332d3Sopenharmony_ci/** 517094332d3Sopenharmony_ci * @tc.name: RegRefreshCallbackTest 518094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface RegRefreshCallback. 519094332d3Sopenharmony_ci */ 520094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, RegRefreshCallbackTest)(benchmark::State &state) 521094332d3Sopenharmony_ci{ 522094332d3Sopenharmony_ci int32_t ret; 523094332d3Sopenharmony_ci for (auto _ : state) { 524094332d3Sopenharmony_ci ret = g_composerDevice->RegRefreshCallback(TestRefreshCallback, nullptr); 525094332d3Sopenharmony_ci } 526094332d3Sopenharmony_ci if (ret == DISPLAY_NOT_SUPPORT) { 527094332d3Sopenharmony_ci return; 528094332d3Sopenharmony_ci } 529094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 530094332d3Sopenharmony_ci} 531094332d3Sopenharmony_ci 532094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, RegRefreshCallbackTest)-> 533094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 534094332d3Sopenharmony_ci 535094332d3Sopenharmony_ci/** 536094332d3Sopenharmony_ci * @tc.name: GetDisplaySupportedColorGamutsTest 537094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface GetDisplaySupportedColorGamuts. 538094332d3Sopenharmony_ci */ 539094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, GetDisplaySupportedColorGamutsTest)(benchmark::State &state) 540094332d3Sopenharmony_ci{ 541094332d3Sopenharmony_ci int32_t ret; 542094332d3Sopenharmony_ci std::vector<ColorGamut> gamuts; 543094332d3Sopenharmony_ci for (auto _ : state) { 544094332d3Sopenharmony_ci ret = g_composerDevice->GetDisplaySupportedColorGamuts(g_displayIds[0], gamuts); 545094332d3Sopenharmony_ci } 546094332d3Sopenharmony_ci if (ret == DISPLAY_NOT_SUPPORT) { 547094332d3Sopenharmony_ci return; 548094332d3Sopenharmony_ci } 549094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 550094332d3Sopenharmony_ci} 551094332d3Sopenharmony_ci 552094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, GetDisplaySupportedColorGamutsTest)-> 553094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 554094332d3Sopenharmony_ci 555094332d3Sopenharmony_ci/** 556094332d3Sopenharmony_ci * @tc.name: GetHDRCapabilityInfosTest 557094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface GetHDRCapabilityInfos. 558094332d3Sopenharmony_ci */ 559094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, GetHDRCapabilityInfosTest)(benchmark::State &state) 560094332d3Sopenharmony_ci{ 561094332d3Sopenharmony_ci int32_t ret; 562094332d3Sopenharmony_ci HDRCapability info = { 0 }; 563094332d3Sopenharmony_ci for (auto _ : state) { 564094332d3Sopenharmony_ci ret = g_composerDevice->GetHDRCapabilityInfos(g_displayIds[0], info); 565094332d3Sopenharmony_ci } 566094332d3Sopenharmony_ci if (ret == DISPLAY_NOT_SUPPORT) { 567094332d3Sopenharmony_ci return; 568094332d3Sopenharmony_ci } 569094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 570094332d3Sopenharmony_ci} 571094332d3Sopenharmony_ci 572094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, GetHDRCapabilityInfosTest)-> 573094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 574094332d3Sopenharmony_ci 575094332d3Sopenharmony_ci/** 576094332d3Sopenharmony_ci * @tc.name: SetDisplayClientCropTest 577094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface SetDisplayClientCrop. 578094332d3Sopenharmony_ci */ 579094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, SetDisplayClientCropTest)(benchmark::State &state) 580094332d3Sopenharmony_ci{ 581094332d3Sopenharmony_ci int32_t ret; 582094332d3Sopenharmony_ci int32_t width = 100; 583094332d3Sopenharmony_ci int32_t height = 100; 584094332d3Sopenharmony_ci IRect rect = {0, 0, width, height}; 585094332d3Sopenharmony_ci for (auto _ : state) { 586094332d3Sopenharmony_ci ret = g_composerDevice->SetDisplayClientCrop(g_displayIds[0], rect); 587094332d3Sopenharmony_ci } 588094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_FAILURE, ret); 589094332d3Sopenharmony_ci} 590094332d3Sopenharmony_ci 591094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, SetDisplayClientCropTest)-> 592094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 593094332d3Sopenharmony_ci 594094332d3Sopenharmony_ci/** 595094332d3Sopenharmony_ci * @tc.name: SetHardwareCursorPositionTest 596094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface SetHardwareCursorPositionTest. 597094332d3Sopenharmony_ci */ 598094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, SetHardwareCursorPositionTest)(benchmark::State &state) 599094332d3Sopenharmony_ci{ 600094332d3Sopenharmony_ci int32_t ret = 0; 601094332d3Sopenharmony_ci int32_t x = 1; 602094332d3Sopenharmony_ci int32_t y = 1; 603094332d3Sopenharmony_ci for (auto _ : state) { 604094332d3Sopenharmony_ci ret = g_composerDevice->SetHardwareCursorPosition(g_displayIds[0], x, y); 605094332d3Sopenharmony_ci } 606094332d3Sopenharmony_ci if (ret == DISPLAY_SUCCESS || ret == DISPLAY_NOT_SUPPORT) { 607094332d3Sopenharmony_ci ret = DISPLAY_SUCCESS; 608094332d3Sopenharmony_ci } 609094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 610094332d3Sopenharmony_ci} 611094332d3Sopenharmony_ci 612094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, SetHardwareCursorPositionTest)-> 613094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 614094332d3Sopenharmony_ci 615094332d3Sopenharmony_ci/** 616094332d3Sopenharmony_ci * @tc.name: EnableHardwareCursorStatsTest 617094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface EnableHardwareCursorStatsTest. 618094332d3Sopenharmony_ci */ 619094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, EnableHardwareCursorStatsTest)(benchmark::State &state) 620094332d3Sopenharmony_ci{ 621094332d3Sopenharmony_ci int32_t ret = 0; 622094332d3Sopenharmony_ci bool enable = true; 623094332d3Sopenharmony_ci for (auto _ : state) { 624094332d3Sopenharmony_ci ret = g_composerDevice->EnableHardwareCursorStats(g_displayIds[0], enable); 625094332d3Sopenharmony_ci } 626094332d3Sopenharmony_ci if (ret == DISPLAY_SUCCESS || ret == DISPLAY_NOT_SUPPORT) { 627094332d3Sopenharmony_ci ret = DISPLAY_SUCCESS; 628094332d3Sopenharmony_ci } 629094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 630094332d3Sopenharmony_ci} 631094332d3Sopenharmony_ci 632094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, EnableHardwareCursorStatsTest)-> 633094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 634094332d3Sopenharmony_ci 635094332d3Sopenharmony_ci/** 636094332d3Sopenharmony_ci * @tc.name: GetHardwareCursorStatsTest 637094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface GetHardwareCursorStatsTest. 638094332d3Sopenharmony_ci */ 639094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, GetHardwareCursorStatsTest)(benchmark::State &state) 640094332d3Sopenharmony_ci{ 641094332d3Sopenharmony_ci int32_t ret = 0; 642094332d3Sopenharmony_ci uint32_t frameCount = 0; 643094332d3Sopenharmony_ci uint32_t vsyncCount = 0; 644094332d3Sopenharmony_ci for (auto _ : state) { 645094332d3Sopenharmony_ci ret = g_composerDevice->GetHardwareCursorStats(g_displayIds[0], frameCount, vsyncCount); 646094332d3Sopenharmony_ci } 647094332d3Sopenharmony_ci if (ret == DISPLAY_SUCCESS || ret == DISPLAY_NOT_SUPPORT) { 648094332d3Sopenharmony_ci ret = DISPLAY_SUCCESS; 649094332d3Sopenharmony_ci } 650094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 651094332d3Sopenharmony_ci} 652094332d3Sopenharmony_ci 653094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, GetHardwareCursorStatsTest)-> 654094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 655094332d3Sopenharmony_ci 656094332d3Sopenharmony_ci/** 657094332d3Sopenharmony_ci * @tc.name: ClearClientBufferTest 658094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface ClearClientBufferTest. 659094332d3Sopenharmony_ci */ 660094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, ClearClientBufferTest)(benchmark::State &state) 661094332d3Sopenharmony_ci{ 662094332d3Sopenharmony_ci int32_t ret = 0; 663094332d3Sopenharmony_ci for (auto _ : state) { 664094332d3Sopenharmony_ci ret = g_composerDevice->ClearClientBuffer(g_displayIds[0]); 665094332d3Sopenharmony_ci } 666094332d3Sopenharmony_ci if (ret == DISPLAY_NOT_SUPPORT) { 667094332d3Sopenharmony_ci return; 668094332d3Sopenharmony_ci } 669094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_SUCCESS, ret); 670094332d3Sopenharmony_ci} 671094332d3Sopenharmony_ci 672094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, ClearClientBufferTest)-> 673094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 674094332d3Sopenharmony_ci 675094332d3Sopenharmony_ci/** 676094332d3Sopenharmony_ci * @tc.name: ClearLayerBufferTest 677094332d3Sopenharmony_ci * @tc.desc: Benchmarktest for interface ClearLayerBufferTest. 678094332d3Sopenharmony_ci */ 679094332d3Sopenharmony_ciBENCHMARK_F(DisplayBenchmarkTest, ClearLayerBufferTest)(benchmark::State &state) 680094332d3Sopenharmony_ci{ 681094332d3Sopenharmony_ci int32_t ret = 0; 682094332d3Sopenharmony_ci uint32_t layerId = 1; 683094332d3Sopenharmony_ci for (auto _ : state) { 684094332d3Sopenharmony_ci ret = g_composerDevice->ClearLayerBuffer(g_displayIds[0], layerId); 685094332d3Sopenharmony_ci } 686094332d3Sopenharmony_ci if (ret == DISPLAY_NOT_SUPPORT) { 687094332d3Sopenharmony_ci return; 688094332d3Sopenharmony_ci } 689094332d3Sopenharmony_ci EXPECT_EQ(DISPLAY_FAILURE, ret); 690094332d3Sopenharmony_ci} 691094332d3Sopenharmony_ci 692094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(DisplayBenchmarkTest, ClearLayerBufferTest)-> 693094332d3Sopenharmony_ci Iterations(30)->Repetitions(3)->ReportAggregatesOnly(); 694094332d3Sopenharmony_ci 695094332d3Sopenharmony_ci} // namespace 696094332d3Sopenharmony_ci 697094332d3Sopenharmony_ciint main(int argc, char** argv) 698094332d3Sopenharmony_ci{ 699094332d3Sopenharmony_ci int ret = HdiTestDevice::GetInstance().InitDevice(); 700094332d3Sopenharmony_ci DISPLAY_TEST_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_TEST_LOGE("Init Device Failed")); 701094332d3Sopenharmony_ci ::testing::InitGoogleTest(&argc, argv); 702094332d3Sopenharmony_ci ::benchmark::Initialize(&argc, argv); 703094332d3Sopenharmony_ci if (::benchmark::ReportUnrecognizedArguments(argc, argv)) { 704094332d3Sopenharmony_ci return 1; 705094332d3Sopenharmony_ci } 706094332d3Sopenharmony_ci g_composerDevice = HdiTestDevice::GetInstance().GetDeviceInterface(); 707094332d3Sopenharmony_ci DISPLAY_TEST_CHK_RETURN((g_composerDevice == nullptr), DISPLAY_FAILURE, 708094332d3Sopenharmony_ci DISPLAY_TEST_LOGE("get composer interface failed")); 709094332d3Sopenharmony_ci g_gralloc.reset(IDisplayBuffer::Get()); 710094332d3Sopenharmony_ci DISPLAY_TEST_CHK_RETURN((g_gralloc == nullptr), DISPLAY_FAILURE, 711094332d3Sopenharmony_ci DISPLAY_TEST_LOGE("get buffer interface failed")); 712094332d3Sopenharmony_ci auto display = HdiTestDevice::GetInstance().GetFirstDisplay(); 713094332d3Sopenharmony_ci if (display != nullptr) { 714094332d3Sopenharmony_ci g_displayIds = HdiTestDevice::GetInstance().GetDevIds(); 715094332d3Sopenharmony_ci display->SetDisplayVsyncEnabled(false); 716094332d3Sopenharmony_ci } 717094332d3Sopenharmony_ci ::benchmark::RunSpecifiedBenchmarks(); 718094332d3Sopenharmony_ci ::benchmark::Shutdown(); 719094332d3Sopenharmony_ci HdiTestDevice::GetInstance().GetFirstDisplay()->ResetClientLayer(); 720094332d3Sopenharmony_ci return ret; 721094332d3Sopenharmony_ci} 722