From 5f8ec8607e1281c8473ed8175e85f32e59fe9d41 Mon Sep 17 00:00:00 2001 From: fseeeye Date: Mon, 17 Jul 2023 22:35:58 +0800 Subject: [PATCH 1/4] test: add UT of composer & surface --- build/gn/BUILD.gn | 11 +- build/gn/configs/system_libs/BUILD.gn | 9 + display_server/drivers/hal/base/BUILD.gn | 9 +- .../frameworks/fence/ft_build/BUILD.gn | 8 +- .../frameworks/surface/test/ft_build/BUILD.gn | 153 +++- .../buffer_client_producer_remote_test.cpp | 493 ++++++++++ .../test/ft_build/buffer_consumer_listener.h | 30 + .../test/ft_build/buffer_manager_test.cpp | 289 ++++++ .../ft_build/buffer_queue_consumer_test.cpp | 134 +++ .../buffer_queue_producer_remote_test.cpp | 272 ++++++ .../ft_build/buffer_queue_producer_test.cpp | 229 +++++ .../test/ft_build/buffer_queue_test.cpp | 520 +++++++++++ .../test/ft_build/buffer_shared_test.cpp | 241 +++++ .../test/ft_build/consumer_surface_test.cpp | 857 ++++++++++++++++++ .../test/ft_build/producer_surface_test.cpp | 828 +++++++++++++++++ .../ft_build/surface_buffer_impl_test.cpp | 147 +++ .../test/ft_build/surface_utils_test.cpp | 191 ++++ display_server/ft_build/BUILD.gn | 8 +- display_server/ft_build/ds_config.gni | 2 + .../hdi_backend/test/ft_build/BUILD.gn | 94 ++ .../test/ft_build/hdibackend_test.cpp | 78 ++ .../test/ft_build/hdidevice_test.cpp | 157 ++++ .../ft_build/hdiframebuffersurface_test.cpp | 41 + .../test/ft_build/hdilayerinfo_test.cpp | 556 ++++++++++++ .../test/ft_build/hdioutput_test.cpp | 247 +++++ .../modules/composer/vsync/ft_build/BUILD.gn | 5 +- .../composer/vsync/test/ft_build/BUILD.gn | 105 +++ .../test/ft_build/vsync_connection_test.cpp | 118 +++ .../test/ft_build/vsync_controller_test.cpp | 97 ++ .../test/ft_build/vsync_distributor_test.cpp | 254 ++++++ .../test/ft_build/vsync_generator_test.cpp | 183 ++++ .../test/ft_build/vsync_receiver_test.cpp | 123 +++ .../test/ft_build/vsync_sampler_test.cpp | 214 +++++ .../modules/render_service/ft_build/BUILD.gn | 3 +- .../src/platform/fangtian/BUILD.gn | 3 +- .../test/render_service_client_rs_demo.cpp | 25 +- display_server/utils/ft_build/BUILD.gn | 5 + .../utils/socketpair/ft_build/BUILD.gn | 2 +- .../utils/test_header/ft_build/BUILD.gn | 23 + 39 files changed, 6730 insertions(+), 34 deletions(-) create mode 100644 display_server/frameworks/surface/test/ft_build/buffer_client_producer_remote_test.cpp create mode 100644 display_server/frameworks/surface/test/ft_build/buffer_consumer_listener.h create mode 100644 display_server/frameworks/surface/test/ft_build/buffer_manager_test.cpp create mode 100644 display_server/frameworks/surface/test/ft_build/buffer_queue_consumer_test.cpp create mode 100644 display_server/frameworks/surface/test/ft_build/buffer_queue_producer_remote_test.cpp create mode 100644 display_server/frameworks/surface/test/ft_build/buffer_queue_producer_test.cpp create mode 100644 display_server/frameworks/surface/test/ft_build/buffer_queue_test.cpp create mode 100644 display_server/frameworks/surface/test/ft_build/buffer_shared_test.cpp create mode 100644 display_server/frameworks/surface/test/ft_build/consumer_surface_test.cpp create mode 100644 display_server/frameworks/surface/test/ft_build/producer_surface_test.cpp create mode 100644 display_server/frameworks/surface/test/ft_build/surface_buffer_impl_test.cpp create mode 100644 display_server/frameworks/surface/test/ft_build/surface_utils_test.cpp create mode 100644 display_server/rosen/modules/composer/hdi_backend/test/ft_build/BUILD.gn create mode 100644 display_server/rosen/modules/composer/hdi_backend/test/ft_build/hdibackend_test.cpp create mode 100644 display_server/rosen/modules/composer/hdi_backend/test/ft_build/hdidevice_test.cpp create mode 100644 display_server/rosen/modules/composer/hdi_backend/test/ft_build/hdiframebuffersurface_test.cpp create mode 100644 display_server/rosen/modules/composer/hdi_backend/test/ft_build/hdilayerinfo_test.cpp create mode 100644 display_server/rosen/modules/composer/hdi_backend/test/ft_build/hdioutput_test.cpp create mode 100644 display_server/rosen/modules/composer/vsync/test/ft_build/BUILD.gn create mode 100644 display_server/rosen/modules/composer/vsync/test/ft_build/vsync_connection_test.cpp create mode 100644 display_server/rosen/modules/composer/vsync/test/ft_build/vsync_controller_test.cpp create mode 100644 display_server/rosen/modules/composer/vsync/test/ft_build/vsync_distributor_test.cpp create mode 100644 display_server/rosen/modules/composer/vsync/test/ft_build/vsync_generator_test.cpp create mode 100644 display_server/rosen/modules/composer/vsync/test/ft_build/vsync_receiver_test.cpp create mode 100644 display_server/rosen/modules/composer/vsync/test/ft_build/vsync_sampler_test.cpp create mode 100644 display_server/utils/test_header/ft_build/BUILD.gn diff --git a/build/gn/BUILD.gn b/build/gn/BUILD.gn index 46a17c9..3b446a5 100644 --- a/build/gn/BUILD.gn +++ b/build/gn/BUILD.gn @@ -36,13 +36,20 @@ group("ft_test") { testonly = true deps = [ + # DRM Backend "//display_server/drivers/hal/test:drm_backend_test", - "//display_server/frameworks/surface/test/ft_build:test", + "//display_server/drivers/hal/test:gpu_backend_test", + # Composer + "//display_server/rosen/modules/composer/hdi_backend/test/ft_build:unittest", + "//display_server/rosen/modules/composer/vsync/test/ft_build:unittest", "//display_server/rosen/samples/composer/ft_build:hello_composer", + # Surface + "//display_server/frameworks/surface/test/ft_build:unittest", + "//display_server/frameworks/surface/test/ft_build:sample", + # RS "//display_server/rosen/modules/render_service_client/test/ft_build:render_service_client_rs_demo", "//display_server/rosen/modules/render_service_client/test/ft_build:render_service_client_gravity_demo", - "//display_server/drivers/hal/test:gpu_backend_test", "//window_manager/test/ft_build:wm_test", ] } diff --git a/build/gn/configs/system_libs/BUILD.gn b/build/gn/configs/system_libs/BUILD.gn index b485224..d98c09c 100644 --- a/build/gn/configs/system_libs/BUILD.gn +++ b/build/gn/configs/system_libs/BUILD.gn @@ -97,6 +97,11 @@ config("libz_config") { libs = [ "shared_libz" ] } +config("gtest_config") { + visibility = [ ":*" ] + libs = [ "gtest", "gtest_main" ] +} + group("c_utils") { public_configs = [ ":c_utils_config" ] } @@ -170,3 +175,7 @@ group("safwk") { group("libz") { public_configs = [ ":libz_config" ] } + +group("gtest") { + public_configs = [ ":gtest_config" ] +} diff --git a/display_server/drivers/hal/base/BUILD.gn b/display_server/drivers/hal/base/BUILD.gn index b3b36f2..8f1fff9 100644 --- a/display_server/drivers/hal/base/BUILD.gn +++ b/display_server/drivers/hal/base/BUILD.gn @@ -32,9 +32,10 @@ ft_shared_library("hal_base") { "./src/event_loop/timer_queue.cpp", ] - public_configs = [ - ":hal_base_public_config", - "//build/gn/configs/system_libs:hilog_config", - "//build/gn/configs/system_libs:c_utils_config", + public_configs = [ ":hal_base_public_config" ] + + public_deps = [ + "//build/gn/configs/system_libs:hilog", + "//build/gn/configs/system_libs:c_utils", ] } \ No newline at end of file diff --git a/display_server/frameworks/fence/ft_build/BUILD.gn b/display_server/frameworks/fence/ft_build/BUILD.gn index 5dde757..85cbef8 100755 --- a/display_server/frameworks/fence/ft_build/BUILD.gn +++ b/display_server/frameworks/fence/ft_build/BUILD.gn @@ -25,9 +25,9 @@ config("fence_config") { ft_shared_library("libfence") { sources = [ "../src/fence.cpp" ] - configs = [ - ":fence_config", - "//build/gn/configs/system_libs:hilog_config", - "//build/gn/configs/system_libs:c_utils_config" + configs = [ ":fence_config" ] + deps = [ + "//build/gn/configs/system_libs:hilog", + "//build/gn/configs/system_libs:c_utils" ] } \ No newline at end of file diff --git a/display_server/frameworks/surface/test/ft_build/BUILD.gn b/display_server/frameworks/surface/test/ft_build/BUILD.gn index e33a59d..d7e2570 100644 --- a/display_server/frameworks/surface/test/ft_build/BUILD.gn +++ b/display_server/frameworks/surface/test/ft_build/BUILD.gn @@ -12,8 +12,9 @@ # limitations under the License. import("//build/gn/fangtian.gni") +import("//display_server/ft_build/ds_config.gni") -group("test") { +group("sample") { testonly = true deps = [ @@ -21,6 +22,26 @@ group("test") { ] } +group("unittest") { + testonly = true + + deps = [ + ":buffer_client_producer_remote_test", + ":buffer_manager_test", + ":buffer_queue_consumer_test", + ":buffer_queue_producer_remote_test", + ":buffer_queue_producer_test", + ":buffer_queue_test", + ":buffer_shared_test", + ":consumer_surface_test", + ":producer_surface_test", + ":surface_buffer_impl_test", + ":surface_utils_test", + ] +} + + + ft_executable("native_window_buffer_test_oe") { testonly = true @@ -42,4 +63,132 @@ ft_executable("native_window_buffer_test_oe") { "//build/gn/configs/system_libs:hilog", "//build/gn/configs/system_libs:samgr", ] -} \ No newline at end of file +} + +config("surface_test_common_public_config") { + include_dirs = [ + "//display_server/frameworks/surface/include", + "//display_server/utils/test_header/export", + ] + + cflags = [ + "-Wall", + "-Werror", + "-g3", + # "-Dprivate=public", + # "-Dprotected=public", + ] + + defines = gpu_defines +} + +ft_static_library("surface_test_common") { + visibility = [ ":*" ] + testonly = true + + public_configs = [ ":surface_test_common_public_config" ] + + public_deps = [ + "//build/gn/configs/system_libs:hilog", + "//build/gn/configs/system_libs:ipc_core", + "//build/gn/configs/system_libs:c_utils", + "//build/gn/configs/system_libs:samgr", + "//build/gn/configs/system_libs:gtest", + + "//display_server/ft_build:libsurface", + "//display_server/utils/ft_build:buffer_handle", + "//display_server/utils/ft_build:libgraphic_utils", + "//display_server/utils/ft_build:sync_fence", + "//display_server/utils/ft_build:test_header", + ] + + libs = libgl +} + +ft_executable("buffer_client_producer_remote_test") { + testonly = true + + sources = [ "buffer_client_producer_remote_test.cpp" ] + + deps = [ ":surface_test_common" ] +} + +ft_executable("buffer_manager_test") { + testonly = true + + sources = [ "buffer_manager_test.cpp" ] + + deps = [ ":surface_test_common" ] +} + +ft_executable("buffer_queue_consumer_test") { + testonly = true + + sources = [ "buffer_queue_consumer_test.cpp" ] + + deps = [ ":surface_test_common" ] +} + +ft_executable("buffer_queue_producer_remote_test") { + testonly = true + + sources = [ "buffer_queue_producer_remote_test.cpp" ] + + deps = [ ":surface_test_common" ] +} + +ft_executable("buffer_queue_producer_test") { + testonly = true + + sources = [ "buffer_queue_producer_test.cpp" ] + + deps = [ ":surface_test_common" ] +} + +ft_executable("buffer_queue_test") { + testonly = true + + sources = [ "buffer_queue_test.cpp" ] + + deps = [ ":surface_test_common" ] +} + +ft_executable("buffer_shared_test") { + testonly = true + + sources = [ "buffer_shared_test.cpp" ] + + deps = [ ":surface_test_common" ] +} + +ft_executable("consumer_surface_test") { + testonly = true + + sources = [ "consumer_surface_test.cpp" ] + + deps = [ ":surface_test_common" ] +} + +ft_executable("producer_surface_test") { + testonly = true + + sources = [ "producer_surface_test.cpp" ] + + deps = [ ":surface_test_common" ] +} + +ft_executable("surface_buffer_impl_test") { + testonly = true + + sources = [ "surface_buffer_impl_test.cpp" ] + + deps = [ ":surface_test_common" ] +} + +ft_executable("surface_utils_test") { + testonly = true + + sources = [ "surface_utils_test.cpp" ] + + deps = [ ":surface_test_common" ] +} diff --git a/display_server/frameworks/surface/test/ft_build/buffer_client_producer_remote_test.cpp b/display_server/frameworks/surface/test/ft_build/buffer_client_producer_remote_test.cpp new file mode 100644 index 0000000..4372fe4 --- /dev/null +++ b/display_server/frameworks/surface/test/ft_build/buffer_client_producer_remote_test.cpp @@ -0,0 +1,493 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include "buffer_consumer_listener.h" +#include "sync_fence.h" + +namespace OHOS::Rosen { +class BufferClientProducerRemoteTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + static inline BufferRequestConfig requestConfig = { + .width = 0x100, + .height = 0x100, + .strideAlignment = 0x8, + .format = GRAPHIC_PIXEL_FMT_RGBA_8888, +#ifdef RS_ENABLE_GL + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_MEM_DMA, +#else + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE, +#endif + .timeout = 0, + }; + static inline BufferFlushConfig flushConfig = { + .damage = { + .w = 0x100, + .h = 0x100, + }, + }; + static inline sptr robj = nullptr; + static inline sptr bp = nullptr; + static inline std::vector deletingBuffers; + static inline pid_t pid = 0; + static inline int pipeFd[2] = {}; + static inline int pipe1Fd[2] = {}; + static inline int32_t systemAbilityID = 345135; + static inline sptr bedata = new BufferExtraDataImpl; +}; + +void BufferClientProducerRemoteTest::SetUpTestCase() +{ + if (pipe(pipeFd) < 0) { + exit(1); + } + if (pipe(pipe1Fd) < 0) { + exit(0); + } + pid = fork(); + if (pid < 0) { + exit(1); + } + if (pid == 0) { + sptr bq = new BufferQueue("test"); + ASSERT_NE(bq, nullptr); + sptr bqp = new BufferQueueProducer(bq); + ASSERT_NE(bqp, nullptr); + bq->Init(); + sptr listener = new BufferConsumerListener(); + bq->RegisterConsumerListener(listener); + auto sam = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + sam->AddSystemAbility(systemAbilityID, bqp); + close(pipeFd[1]); + close(pipe1Fd[0]); + char buf[10] = "start"; + write(pipe1Fd[1], buf, sizeof(buf)); + sleep(0); + read(pipeFd[0], buf, sizeof(buf)); + sam->RemoveSystemAbility(systemAbilityID); + close(pipeFd[0]); + close(pipe1Fd[1]); + exit(0); + } else { + close(pipeFd[0]); + close(pipe1Fd[1]); + char buf[10]; + read(pipe1Fd[0], buf, sizeof(buf)); + auto sam = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + robj = sam->GetSystemAbility(systemAbilityID); + bp = iface_cast(robj); + } +} + +void BufferClientProducerRemoteTest::TearDownTestCase() +{ + bp = nullptr; + robj = nullptr; + + char buf[10] = "over"; + write(pipeFd[1], buf, sizeof(buf)); + close(pipeFd[1]); + close(pipe1Fd[0]); + + int32_t ret = 0; + do { + waitpid(pid, nullptr, 0); + } while (ret == -1 && errno == EINTR); +} + +/* +* Function: IsProxyObject +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. check ret for IsProxyObject func + */ +TEST_F(BufferClientProducerRemoteTest, IsProxy001) +{ + ASSERT_TRUE(robj->IsProxyObject()); +} + +/* +* Function: SetQueueSize and GetQueueSize +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetQueueSize for default +* 2. call SetQueueSize and check the ret of GetQueueSize + */ +TEST_F(BufferClientProducerRemoteTest, QueueSize001) +{ + ASSERT_EQ(bp->GetQueueSize(), (uint32_t)SURFACE_DEFAULT_QUEUE_SIZE); + + GSError ret = bp->SetQueueSize(2); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bp->SetQueueSize(SURFACE_MAX_QUEUE_SIZE + 1); + ASSERT_NE(ret, OHOS::GSERROR_OK); + + ASSERT_EQ(bp->GetQueueSize(), 2u); +} + +/* +* Function: SetQueueSize and GetQueueSize +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetQueueSize for default +* 2. call SetQueueSize and check the ret of GetQueueSize + */ +TEST_F(BufferClientProducerRemoteTest, ReqCan001) +{ + IBufferProducer::RequestBufferReturnValue retval; + GSError ret = bp->RequestBuffer(requestConfig, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_NE(retval.buffer, nullptr); + + ret = bp->CancelBuffer(retval.sequence, bedata); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer and CancelBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer +* 2. call CancelBuffer 2 times + */ +TEST_F(BufferClientProducerRemoteTest, ReqCan002) +{ + IBufferProducer::RequestBufferReturnValue retval; + GSError ret = bp->RequestBuffer(requestConfig, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_EQ(retval.buffer, nullptr); + + ret = bp->CancelBuffer(retval.sequence, bedata); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bp->CancelBuffer(retval.sequence, bedata); + ASSERT_NE(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer and CancelBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer and CancelBuffer 3 times + */ +TEST_F(BufferClientProducerRemoteTest, ReqCan003) +{ + IBufferProducer::RequestBufferReturnValue retval1; + IBufferProducer::RequestBufferReturnValue retval2; + IBufferProducer::RequestBufferReturnValue retval3; + GSError ret; + + ret = bp->RequestBuffer(requestConfig, bedata, retval1); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_EQ(retval1.buffer, nullptr); + + ret = bp->RequestBuffer(requestConfig, bedata, retval2); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_NE(retval2.buffer, nullptr); + + ret = bp->RequestBuffer(requestConfig, bedata, retval3); + ASSERT_NE(ret, OHOS::GSERROR_OK); + ASSERT_EQ(retval3.buffer, nullptr); + + ret = bp->CancelBuffer(retval1.sequence, bedata); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bp->CancelBuffer(retval2.sequence, bedata); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bp->CancelBuffer(retval3.sequence, bedata); + ASSERT_NE(ret, OHOS::GSERROR_OK); +} + +/* +* Function: SetQueueSize, RequestBuffer and CancelBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetQueueSize +* 2. call RequestBuffer and CancelBuffer +* 3. call SetQueueSize again + */ +TEST_F(BufferClientProducerRemoteTest, SetQueueSizeDeleting001) +{ + GSError ret = bp->SetQueueSize(1); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + IBufferProducer::RequestBufferReturnValue retval; + ret = bp->RequestBuffer(requestConfig, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_EQ(retval.buffer, nullptr); + + ret = bp->CancelBuffer(retval.sequence, bedata); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bp->SetQueueSize(2); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer and FlushBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer +* 2. call FlushBuffer + */ +TEST_F(BufferClientProducerRemoteTest, ReqFlu001) +{ + IBufferProducer::RequestBufferReturnValue retval; + GSError ret = bp->RequestBuffer(requestConfig, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + sptr acquireFence = SyncFence::INVALID_FENCE; + ret = bp->FlushBuffer(retval.sequence, bedata, acquireFence, flushConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer and FlushBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer +* 2. call FlushBuffer 2 times + */ +TEST_F(BufferClientProducerRemoteTest, ReqFlu002) +{ + IBufferProducer::RequestBufferReturnValue retval; + GSError ret = bp->RequestBuffer(requestConfig, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + sptr acquireFence = SyncFence::INVALID_FENCE; + ret = bp->FlushBuffer(retval.sequence, bedata, acquireFence, flushConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bp->FlushBuffer(retval.sequence, bedata, acquireFence, flushConfig); + ASSERT_NE(ret, OHOS::GSERROR_OK); +} + +/* +* Function: AttachBuffer and DetachBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call AttachBuffer +* 2. call DetachBuffer +*/ +TEST_F(BufferClientProducerRemoteTest, AttachDetach001) +{ + sptr buffer = new SurfaceBufferImpl(0); + GSError ret = bp->AttachBuffer(buffer); + ASSERT_EQ(ret, OHOS::GSERROR_NOT_SUPPORT); + + ret = bp->DetachBuffer(buffer); + ASSERT_EQ(ret, OHOS::GSERROR_NOT_SUPPORT); +} + +/* +* Function: RegisterReleaseListener +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RegisterReleaseListener +*/ +TEST_F(BufferClientProducerRemoteTest, RegisterReleaseListener001) +{ + OnReleaseFunc onBufferRelease = nullptr; + GSError ret = bp->RegisterReleaseListener(onBufferRelease); + ASSERT_EQ(ret, OHOS::GSERROR_NOT_SUPPORT); +} + +/* +* Function: GetName +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetName +*/ +TEST_F(BufferClientProducerRemoteTest, GetName001) +{ + std::string name; + GSError ret = bp->GetName(name); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: GetUniqueId +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetUniqueId +*/ +TEST_F(BufferClientProducerRemoteTest, GetUniqueId001) +{ + uint64_t bpid = bp->GetUniqueId(); + ASSERT_NE(bpid, 0); +} + +/* +* Function: GetDefaultUsage +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetDefaultUsage +*/ +TEST_F(BufferClientProducerRemoteTest, GetDefaultUsage001) +{ + uint32_t usage = bp->GetDefaultUsage(); + ASSERT_EQ(usage, 0); +} + +/* +* Function: SetTransform +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetTransform +*/ +TEST_F(BufferClientProducerRemoteTest, SetTransform001) +{ + GraphicTransformType transform = GraphicTransformType::GRAPHIC_ROTATE_90; + GSError ret = bp->SetTransform(transform); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: IsSupportedAlloc +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call IsSupportedAlloc with abnormal parameters and check ret +*/ +TEST_F(BufferClientProducerRemoteTest, isSupportedAlloc001) +{ + std::vector infos; + std::vector supporteds; + GSError ret = bp->IsSupportedAlloc(infos, supporteds); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: IsSupportedAlloc +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call IsSupportedAlloc with abnormal parameters and check ret +*/ +TEST_F(BufferClientProducerRemoteTest, isSupportedAlloc002) +{ + std::vector infos; + std::vector supporteds; + GSError ret = bp->IsSupportedAlloc(infos, supporteds); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + BufferVerifyAllocInfo info = { + .width = 0x100, + .height = 0x100, +#ifdef RS_ENABLE_GL + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_MEM_DMA, +#else + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE, +#endif + .format = GRAPHIC_PIXEL_FMT_RGBA_8888, + }; + infos.push_back(info); + info.format = GRAPHIC_PIXEL_FMT_YCRCB_420_SP; + infos.push_back(info); + info.format = GRAPHIC_PIXEL_FMT_YUV_422_I; + infos.push_back(info); + + ret = bp->IsSupportedAlloc(infos, supporteds); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: SetScalingMode +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetScalingMode with abnormal parameters and check ret +*/ +TEST_F(BufferClientProducerRemoteTest, SetScalingMode001) +{ + ScalingMode scalingMode = ScalingMode::SCALING_MODE_SCALE_TO_WINDOW; + GSError ret = bp->SetScalingMode(-1, scalingMode); + ASSERT_EQ(ret, OHOS::GSERROR_NO_ENTRY); +} + +/* +* Function: SetMetaData +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetMetaData with abnormal parameters and check ret +*/ +TEST_F(BufferClientProducerRemoteTest, SetMetaData001) +{ + uint32_t sequence = 0; + std::vector metaData; + GSError ret = bp->SetMetaData(sequence, metaData); + ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: SetMetaDataSet +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetMetaDataSet with abnormal parameters and check ret +*/ +TEST_F(BufferClientProducerRemoteTest, SetMetaDataSet001) +{ + GraphicHDRMetadataKey key = GraphicHDRMetadataKey::GRAPHIC_MATAKEY_HDR10_PLUS; + std::vector metaData; + + uint32_t sequence = 0; + GSError ret = bp->SetMetaDataSet(sequence, key, metaData); + ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: GoBackground +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GoBackground +*/ +TEST_F(BufferClientProducerRemoteTest, GoBackground001) +{ + GSError ret = bp->GoBackground(); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} +} diff --git a/display_server/frameworks/surface/test/ft_build/buffer_consumer_listener.h b/display_server/frameworks/surface/test/ft_build/buffer_consumer_listener.h new file mode 100644 index 0000000..451fce2 --- /dev/null +++ b/display_server/frameworks/surface/test/ft_build/buffer_consumer_listener.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FRAMEWORKS_SURFACE_TEST_UNITTEST_BUFFER_CONSUMER_LISTENER_H +#define FRAMEWORKS_SURFACE_TEST_UNITTEST_BUFFER_CONSUMER_LISTENER_H + +#include + +namespace OHOS { +class BufferConsumerListener : public ::OHOS::IBufferConsumerListener { +public: + void OnBufferAvailable() override + { + } +}; +} // namespace OHOS + +#endif // FRAMEWORKS_SURFACE_TEST_UNITTEST_BUFFER_CONSUMER_LISTENER_H diff --git a/display_server/frameworks/surface/test/ft_build/buffer_manager_test.cpp b/display_server/frameworks/surface/test/ft_build/buffer_manager_test.cpp new file mode 100644 index 0000000..5f0be93 --- /dev/null +++ b/display_server/frameworks/surface/test/ft_build/buffer_manager_test.cpp @@ -0,0 +1,289 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include + +namespace OHOS::Rosen { +class BufferManagerTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + static inline BufferRequestConfig requestConfig = { + .width = 0x100, + .height = 0x100, + .strideAlignment = 0x8, + .format = GRAPHIC_PIXEL_FMT_RGBA_8888, +#ifdef RS_ENABLE_GL + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_MEM_DMA, +#else + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE, +#endif + .timeout = 0, + }; + static inline sptr buffer = nullptr; +}; + +void BufferManagerTest::SetUpTestCase() +{ + buffer = new SurfaceBufferImpl(); +} + +void BufferManagerTest::TearDownTestCase() +{ + buffer = nullptr; +} + +/* +* Function: GetInstance +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetInstance + */ +TEST_F(BufferManagerTest, GetInstance001) +{ + ASSERT_NE(BufferManager::GetInstance(), nullptr); +} + +/* +* Function: Alloc +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetBufferHandle +* 2. call GetInstance and Alloc +* 3. call GetBufferHandle +* 4. check ret and handle + */ +TEST_F(BufferManagerTest, Alloc001) +{ + ASSERT_EQ(buffer->GetBufferHandle(), nullptr); + + GSError ret = BufferManager::GetInstance()->Alloc(requestConfig, buffer); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + BufferHandle *handle = buffer->GetBufferHandle(); + + ASSERT_NE(handle, nullptr); + ASSERT_EQ(handle->virAddr, nullptr); +} + +/* +* Function: Map +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetBufferHandle +* 2. call GetInstance and Map +* 3. call GetBufferHandle +* 4. check ret and handle + */ +TEST_F(BufferManagerTest, Map001) +{ + BufferHandle *handle; + + handle = buffer->GetBufferHandle(); + ASSERT_NE(handle, nullptr); + ASSERT_EQ(handle->virAddr, nullptr); + + GSError ret = BufferManager::GetInstance()->Map(buffer); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + handle = buffer->GetBufferHandle(); + ASSERT_NE(handle, nullptr); + ASSERT_NE(handle->virAddr, nullptr); +} + +/* +* Function: FlushCache before Unmap +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetBufferHandle +* 2. call GetInstance and FlushCache +* 3. call GetBufferHandle +* 4. check ret and handle + */ +TEST_F(BufferManagerTest, FlushBufferBeforeUnmap001) +{ + BufferHandle *handle; + + handle = buffer->GetBufferHandle(); + ASSERT_NE(handle, nullptr); + ASSERT_NE(handle->virAddr, nullptr); + + GSError ret = BufferManager::GetInstance()->FlushCache(buffer); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + handle = buffer->GetBufferHandle(); + ASSERT_NE(handle, nullptr); + ASSERT_NE(handle->virAddr, nullptr); +} + +/* +* Function: Unmap +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetBufferHandle +* 2. call GetInstance and Unmap +* 3. call GetBufferHandle +* 4. check ret and handle + */ +TEST_F(BufferManagerTest, Unmap001) +{ + BufferHandle *handle = buffer->GetBufferHandle(); + ASSERT_NE(handle, nullptr); + ASSERT_NE(handle->virAddr, nullptr); + + GSError ret = BufferManager::GetInstance()->Unmap(buffer); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + handle = buffer->GetBufferHandle(); + ASSERT_NE(handle, nullptr); + ASSERT_EQ(handle->virAddr, nullptr); +} + +/* +* Function: FlushCache after Unmap +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetBufferHandle +* 2. call GetInstance and FlushCache +* 3. call GetBufferHandle +* 4. check ret and handle + */ +TEST_F(BufferManagerTest, FlushBufferAfterUnmap001) +{ + BufferHandle *handle; + + handle = buffer->GetBufferHandle(); + ASSERT_NE(handle, nullptr); + ASSERT_EQ(handle->virAddr, nullptr); + + BufferManager::GetInstance()->FlushCache(buffer); + + handle = buffer->GetBufferHandle(); + ASSERT_NE(handle, nullptr); + ASSERT_EQ(handle->virAddr, nullptr); +} + +/* +* Function: Free +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetBufferHandle +* 2. call GetInstance and Free +* 3. call GetBufferHandle +* 4. check ret and handle + */ +TEST_F(BufferManagerTest, Free001) +{ + BufferHandle *handle; + + handle = buffer->GetBufferHandle(); + ASSERT_NE(handle, nullptr); + ASSERT_EQ(handle->virAddr, nullptr); + + GSError ret = BufferManager::GetInstance()->Free(buffer); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + handle = buffer->GetBufferHandle(); + ASSERT_EQ(handle, nullptr); +} + +/* +* Function: cma leak +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. get cma free +* 2. alloc +* 3. free +* 4. get cma free again +* 5. diff should less then 1000KB + */ +TEST_F(BufferManagerTest, CMALeak001) +{ + // 0. buffer size = 1024KB + constexpr uint32_t width = 1024 * 3; + constexpr uint32_t height = 1024 / 4; + constexpr uint32_t strideAlignment = 8; + BufferRequestConfig requestConfig = { + .width = width, + .height = height, + .strideAlignment = strideAlignment, + .format = GRAPHIC_PIXEL_FMT_RGBA_8888, +#ifdef RS_ENABLE_GL + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_MEM_DMA, +#else + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE, +#endif + .timeout = 0, + }; + + // 1. get cma free + auto getCmaFree = []() -> uint32_t { + FILE *fp = fopen("/proc/meminfo", "r"); + if (fp == nullptr) { + GTEST_LOG_(INFO) << "fopen return " << errno << std::endl; + return 0; + } + + constexpr int keyLength = 32; + char key[keyLength]; + int cmaFree = 0; + while (fscanf_s(fp, "%s%d%*s", key, sizeof(key), &cmaFree) > 0) { + if (strcmp(key, "CmaFree:") == 0) { + return cmaFree; + } + } + + fclose(fp); + return 0; + }; + + int32_t first = getCmaFree(); + + // 2. alloc + sptr buffer = new SurfaceBufferImpl(); + GSError ret = BufferManager::GetInstance()->Alloc(requestConfig, buffer); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + auto handle = buffer->GetBufferHandle(); + ASSERT_NE(handle, nullptr); + ASSERT_EQ(handle->virAddr, nullptr); + + // 3. free + ret = BufferManager::GetInstance()->Free(buffer); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + handle = buffer->GetBufferHandle(); + ASSERT_EQ(handle, nullptr); + + // 4. get cma free again + int32_t third = getCmaFree(); + + // 5. diff should less then 1000KB + GTEST_LOG_(INFO) << "diff: " << first - third; + ASSERT_LT(first - third, 1000); +} +} diff --git a/display_server/frameworks/surface/test/ft_build/buffer_queue_consumer_test.cpp b/display_server/frameworks/surface/test/ft_build/buffer_queue_consumer_test.cpp new file mode 100644 index 0000000..f0bc26d --- /dev/null +++ b/display_server/frameworks/surface/test/ft_build/buffer_queue_consumer_test.cpp @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include "buffer_consumer_listener.h" +#include "buffer_extra_data_impl.h" +#include "sync_fence.h" + +namespace OHOS::Rosen { +class BufferQueueConsumerTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + static inline BufferRequestConfig requestConfig = { + .width = 0x100, + .height = 0x100, + .strideAlignment = 0x8, + .format = GRAPHIC_PIXEL_FMT_RGBA_8888, +#ifdef RS_ENABLE_GL + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_MEM_DMA, +#else + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE, +#endif + .timeout = 0, + }; + static inline BufferFlushConfig flushConfig = { + .damage = { + .w = 0x100, + .h = 0x100, + }, + }; + static inline int64_t timestamp = 0; + static inline Rect damage = {}; + static inline sptr bq = nullptr; + static inline sptr bqc = nullptr; + static inline sptr bedata = nullptr; +}; + +void BufferQueueConsumerTest::SetUpTestCase() +{ + bq = new BufferQueue("test"); + bq->Init(); + bqc = new BufferQueueConsumer(bq); + sptr listener = new BufferConsumerListener(); + bqc->RegisterConsumerListener(listener); + bedata = new BufferExtraDataImpl; +} + +void BufferQueueConsumerTest::TearDownTestCase() +{ + bq = nullptr; + bqc = nullptr; +} + +/* +* Function: AcquireBuffer and ReleaseBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer and FlushBuffer +* 2. call AcquireBuffer and ReleaseBuffer +* 3. check ret + */ +TEST_F(BufferQueueConsumerTest, AcqRel001) +{ + IBufferProducer::RequestBufferReturnValue retval; + GSError ret = bq->RequestBuffer(requestConfig, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_GE(retval.sequence, 0); + ASSERT_NE(retval.buffer, nullptr); + + uint8_t *addr1 = reinterpret_cast(retval.buffer->GetVirAddr()); + ASSERT_NE(addr1, nullptr); + + sptr acquireFence = SyncFence::INVALID_FENCE; + ret = bq->FlushBuffer(retval.sequence, bedata, acquireFence, flushConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bqc->AcquireBuffer(retval.buffer, retval.fence, timestamp, damage); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + sptr releaseFence = SyncFence::INVALID_FENCE; + ret = bqc->ReleaseBuffer(retval.buffer, releaseFence); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: AcquireBuffer and ReleaseBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer and FlushBuffer +* 2. call AcquireBuffer and ReleaseBuffer +* 3. call ReleaseBuffer again +* 4. check ret + */ +TEST_F(BufferQueueConsumerTest, AcqRel002) +{ + IBufferProducer::RequestBufferReturnValue retval; + GSError ret = bq->RequestBuffer(requestConfig, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_GE(retval.sequence, 0); + ASSERT_EQ(retval.buffer, nullptr); + + sptr acquireFence = SyncFence::INVALID_FENCE; + ret = bq->FlushBuffer(retval.sequence, bedata, acquireFence, flushConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + sptr& buffer = retval.buffer; + ret = bqc->AcquireBuffer(buffer, retval.fence, timestamp, damage); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + sptr releaseFence = SyncFence::INVALID_FENCE; + ret = bqc->ReleaseBuffer(buffer, releaseFence); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bqc->ReleaseBuffer(buffer, releaseFence); + ASSERT_NE(ret, OHOS::GSERROR_OK); +} +} diff --git a/display_server/frameworks/surface/test/ft_build/buffer_queue_producer_remote_test.cpp b/display_server/frameworks/surface/test/ft_build/buffer_queue_producer_remote_test.cpp new file mode 100644 index 0000000..8e2a582 --- /dev/null +++ b/display_server/frameworks/surface/test/ft_build/buffer_queue_producer_remote_test.cpp @@ -0,0 +1,272 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include "buffer_consumer_listener.h" +#include "sync_fence.h" + +namespace OHOS::Rosen { +class BufferQueueProducerRemoteTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + static inline BufferRequestConfig requestConfig = { + .width = 0x100, + .height = 0x100, + .strideAlignment = 0x8, + .format = GRAPHIC_PIXEL_FMT_RGBA_8888, +#ifdef RS_ENABLE_GL + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_MEM_DMA, +#else + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE, +#endif + .timeout = 0, + }; + static inline BufferFlushConfig flushConfig = { + .damage = { + .w = 0x100, + .h = 0x100, + }, + }; + static inline std::vector deletingBuffers; + static inline int64_t timestamp = 0; + static inline Rect damage = {}; + static inline sptr robj = nullptr; + static inline sptr bp = nullptr; + static inline sptr bq = nullptr; + static inline sptr bqp = nullptr; + static inline sptr bedata = nullptr; + static inline int32_t systemAbilityID = 345154; +}; + +void BufferQueueProducerRemoteTest::SetUpTestCase() +{ + bq = new BufferQueue("test"); + bqp = new BufferQueueProducer(bq); + bq->Init(); + sptr listener = new BufferConsumerListener(); + bq->RegisterConsumerListener(listener); + + auto sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + sm->AddSystemAbility(systemAbilityID, bqp); + + robj = sm->GetSystemAbility(systemAbilityID); + bp = iface_cast(robj); + + bedata = new OHOS::BufferExtraDataImpl; +} + +void BufferQueueProducerRemoteTest::TearDownTestCase() +{ + bp = nullptr; + robj = nullptr; + + auto sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + sm->RemoveSystemAbility(systemAbilityID); + + bqp = nullptr; + bq = nullptr; +} + +/* +* Function: IsProxyObject +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call IsProxyObject and check ret + */ +TEST_F(BufferQueueProducerRemoteTest, IsProxy001) +{ + ASSERT_FALSE(robj->IsProxyObject()); +} + +/* +* Function: SetQueueSize and GetQueueSize +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetQueueSize +* 2. call SetQueueSize again with abnormal input +* 3. check ret and call GetQueueSize + */ +TEST_F(BufferQueueProducerRemoteTest, QueueSize001) +{ + GSError ret = bp->SetQueueSize(2); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bp->SetQueueSize(SURFACE_MAX_QUEUE_SIZE + 1); + ASSERT_NE(ret, OHOS::GSERROR_OK); + + ASSERT_EQ(bp->GetQueueSize(), 2u); +} + +/* +* Function: RequestBuffer, CancelBuffer and AcquireBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer +* 2. call CancelBuffer +* 3. call AcquireBuffer and check ret + */ +TEST_F(BufferQueueProducerRemoteTest, ReqCan001) +{ + IBufferProducer::RequestBufferReturnValue retval; + GSError ret = bp->RequestBuffer(requestConfig, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bp->CancelBuffer(retval.sequence, bedata); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bq->AcquireBuffer(retval.buffer, retval.fence, timestamp, damage); + ASSERT_NE(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer, CancelBuffer and AcquireBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer +* 2. call CancelBuffer +* 3. call CancelBuffer again +* 4. call AcquireBuffer and check ret + */ +TEST_F(BufferQueueProducerRemoteTest, ReqCan002) +{ + IBufferProducer::RequestBufferReturnValue retval; + GSError ret = bp->RequestBuffer(requestConfig, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bp->CancelBuffer(retval.sequence, bedata); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bp->CancelBuffer(retval.sequence, bedata); + ASSERT_NE(ret, OHOS::GSERROR_OK); + + ret = bq->AcquireBuffer(retval.buffer, retval.fence, timestamp, damage); + ASSERT_NE(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer, CancelBuffer and AcquireBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer and CancelBuffer by different retval +* 2. call AcquireBuffer and check ret + */ +TEST_F(BufferQueueProducerRemoteTest, ReqCan003) +{ + IBufferProducer::RequestBufferReturnValue retval1; + IBufferProducer::RequestBufferReturnValue retval2; + IBufferProducer::RequestBufferReturnValue retval3; + GSError ret; + + ret = bp->RequestBuffer(requestConfig, bedata, retval1); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_EQ(retval1.buffer, nullptr); + + ret = bp->RequestBuffer(requestConfig, bedata, retval2); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_NE(retval2.buffer, nullptr); + + ret = bp->RequestBuffer(requestConfig, bedata, retval3); + ASSERT_NE(ret, OHOS::GSERROR_OK); + ASSERT_EQ(retval3.buffer, nullptr); + + ret = bp->CancelBuffer(retval1.sequence, bedata); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bp->CancelBuffer(retval2.sequence, bedata); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bp->CancelBuffer(retval3.sequence, bedata); + ASSERT_NE(ret, OHOS::GSERROR_OK); + + ret = bq->AcquireBuffer(retval1.buffer, retval1.fence, timestamp, damage); + ASSERT_NE(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer, FlushBuffer, AcquireBuffer and ReleaseBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer and FlushBuffer +* 2. call AcquireBuffer and ReleaseBuffer +* 3. call AcquireBuffer again +* 4. check ret + */ +TEST_F(BufferQueueProducerRemoteTest, ReqFlu001) +{ + IBufferProducer::RequestBufferReturnValue retval; + GSError ret = bp->RequestBuffer(requestConfig, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + sptr acquireFence = SyncFence::INVALID_FENCE; + ret = bp->FlushBuffer(retval.sequence, bedata, acquireFence, flushConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bq->AcquireBuffer(retval.buffer, retval.fence, timestamp, damage); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + sptr releaseFence = SyncFence::INVALID_FENCE; + ret = bq->ReleaseBuffer(retval.buffer, releaseFence); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bq->AcquireBuffer(retval.buffer, retval.fence, timestamp, damage); + ASSERT_NE(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer, FlushBuffer, AcquireBuffer and ReleaseBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer and FlushBuffer +* 2. call FlushBuffer again +* 3. call AcquireBuffer and ReleaseBuffer +* 4. call AcquireBuffer again +* 5. check ret + */ +TEST_F(BufferQueueProducerRemoteTest, ReqFlu002) +{ + IBufferProducer::RequestBufferReturnValue retval; + GSError ret = bp->RequestBuffer(requestConfig, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + sptr acquireFence = SyncFence::INVALID_FENCE; + ret = bp->FlushBuffer(retval.sequence, bedata, acquireFence, flushConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bp->FlushBuffer(retval.sequence, bedata, acquireFence, flushConfig); + ASSERT_NE(ret, OHOS::GSERROR_OK); + + ret = bq->AcquireBuffer(retval.buffer, retval.fence, timestamp, damage); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + sptr releaseFence = SyncFence::INVALID_FENCE; + ret = bq->ReleaseBuffer(retval.buffer, releaseFence); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bq->AcquireBuffer(retval.buffer, retval.fence, timestamp, damage); + ASSERT_NE(ret, OHOS::GSERROR_OK); +} +} diff --git a/display_server/frameworks/surface/test/ft_build/buffer_queue_producer_test.cpp b/display_server/frameworks/surface/test/ft_build/buffer_queue_producer_test.cpp new file mode 100644 index 0000000..b82d57e --- /dev/null +++ b/display_server/frameworks/surface/test/ft_build/buffer_queue_producer_test.cpp @@ -0,0 +1,229 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include "buffer_consumer_listener.h" +#include "sync_fence.h" + +namespace OHOS::Rosen { +class BufferQueueProducerTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + static inline BufferRequestConfig requestConfig = { + .width = 0x100, + .height = 0x100, + .strideAlignment = 0x8, + .format = GRAPHIC_PIXEL_FMT_RGBA_8888, +#ifdef RS_ENABLE_GL + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_MEM_DMA, +#else + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE, +#endif + .timeout = 0, + }; + static inline BufferFlushConfig flushConfig = { + .damage = { + .w = 0x100, + .h = 0x100, + }, + }; + static inline std::vector deletingBuffers; + static inline int64_t timestamp = 0; + static inline Rect damage = {}; + static inline sptr bq = nullptr; + static inline sptr bqp = nullptr; + static inline sptr bedata = nullptr; +}; + +void BufferQueueProducerTest::SetUpTestCase() +{ + bq = new BufferQueue("test"); + bq->Init(); + sptr listener = new BufferConsumerListener(); + bq->RegisterConsumerListener(listener); + bqp = new BufferQueueProducer(bq); + bedata = new OHOS::BufferExtraDataImpl; +} + +void BufferQueueProducerTest::TearDownTestCase() +{ + bq = nullptr; + bqp = nullptr; +} + +/* +* Function: SetQueueSize and GetQueueSize +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetQueueSize and get default value +* 2. call SetQueueSize +* 3. call SetQueueSize again with abnormal value +* 4. call GetQueueSize for BufferQueueProducer and BufferQueue +* 5. check ret + */ +TEST_F(BufferQueueProducerTest, QueueSize001) +{ + ASSERT_EQ(bqp->GetQueueSize(), (uint32_t)SURFACE_DEFAULT_QUEUE_SIZE); + + GSError ret = bqp->SetQueueSize(2); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bqp->SetQueueSize(SURFACE_MAX_QUEUE_SIZE + 1); + ASSERT_NE(ret, OHOS::GSERROR_OK); + + ASSERT_EQ(bqp->GetQueueSize(), 2u); + ASSERT_EQ(bq->GetQueueSize(), 2u); +} + +/* +* Function: RequestBuffer and CancelBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer +* 2. call CancelBuffer +* 3. check ret + */ +TEST_F(BufferQueueProducerTest, ReqCan001) +{ + IBufferProducer::RequestBufferReturnValue retval; + GSError ret = bqp->RequestBuffer(requestConfig, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bqp->CancelBuffer(retval.sequence, bedata); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer and CancelBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer +* 2. call CancelBuffer 2 times +* 3. check ret + */ +TEST_F(BufferQueueProducerTest, ReqCan002) +{ + IBufferProducer::RequestBufferReturnValue retval; + GSError ret = bqp->RequestBuffer(requestConfig, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bqp->CancelBuffer(retval.sequence, bedata); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bqp->CancelBuffer(retval.sequence, bedata); + ASSERT_NE(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer, and CancelBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer and CancelBuffer by different retval +* 2. check ret + */ +TEST_F(BufferQueueProducerTest, ReqCan003) +{ + IBufferProducer::RequestBufferReturnValue retval1; + IBufferProducer::RequestBufferReturnValue retval2; + IBufferProducer::RequestBufferReturnValue retval3; + + auto ret = bqp->RequestBuffer(requestConfig, bedata, retval1); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_EQ(retval1.buffer, nullptr); + + ret = bqp->RequestBuffer(requestConfig, bedata, retval2); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_NE(retval2.buffer, nullptr); + + ret = bqp->RequestBuffer(requestConfig, bedata, retval3); + ASSERT_NE(ret, OHOS::GSERROR_OK); + ASSERT_EQ(retval3.buffer, nullptr); + + ret = bqp->CancelBuffer(retval1.sequence, bedata); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bqp->CancelBuffer(retval2.sequence, bedata); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bqp->CancelBuffer(retval3.sequence, bedata); + ASSERT_NE(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer, FlushBuffer, AcquireBuffer and ReleaseBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer and FlushBuffer +* 2. call AcquireBuffer and ReleaseBuffer +* 3. check ret + */ +TEST_F(BufferQueueProducerTest, ReqFlu001) +{ + IBufferProducer::RequestBufferReturnValue retval; + GSError ret = bqp->RequestBuffer(requestConfig, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + sptr acquireFence = SyncFence::INVALID_FENCE; + ret = bqp->FlushBuffer(retval.sequence, bedata, acquireFence, flushConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bq->AcquireBuffer(retval.buffer, retval.fence, timestamp, damage); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + sptr releaseFence = SyncFence::INVALID_FENCE; + ret = bq->ReleaseBuffer(retval.buffer, releaseFence); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer, FlushBuffer, AcquireBuffer and ReleaseBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer and FlushBuffer +* 2. call FlushBuffer again +* 3. call AcquireBuffer and ReleaseBuffer +* 4. check ret + */ +TEST_F(BufferQueueProducerTest, ReqFlu002) +{ + IBufferProducer::RequestBufferReturnValue retval; + GSError ret = bqp->RequestBuffer(requestConfig, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + sptr acquireFence = SyncFence::INVALID_FENCE; + ret = bqp->FlushBuffer(retval.sequence, bedata, acquireFence, flushConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bqp->FlushBuffer(retval.sequence, bedata, acquireFence, flushConfig); + ASSERT_NE(ret, OHOS::GSERROR_OK); + + ret = bq->AcquireBuffer(retval.buffer, retval.fence, timestamp, damage); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + sptr releaseFence = SyncFence::INVALID_FENCE; + ret = bq->ReleaseBuffer(retval.buffer, releaseFence); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} +} diff --git a/display_server/frameworks/surface/test/ft_build/buffer_queue_test.cpp b/display_server/frameworks/surface/test/ft_build/buffer_queue_test.cpp new file mode 100644 index 0000000..896ce97 --- /dev/null +++ b/display_server/frameworks/surface/test/ft_build/buffer_queue_test.cpp @@ -0,0 +1,520 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include +#include "buffer_consumer_listener.h" +#include "sync_fence.h" + +namespace OHOS::Rosen { +class BufferQueueTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + static inline BufferRequestConfig requestConfig = { + .width = 0x100, + .height = 0x100, + .strideAlignment = 0x8, + .format = GRAPHIC_PIXEL_FMT_RGBA_8888, +#ifdef RS_ENABLE_GL + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_MEM_DMA, +#else + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE, +#endif + .timeout = 0, + }; + static inline BufferFlushConfig flushConfig = { + .damage = { + .w = 0x100, + .h = 0x100, + }, + }; + static inline int64_t timestamp = 0; + static inline Rect damage = {}; + static inline sptr bq = nullptr; + static inline std::map> cache; + static inline sptr bedata = nullptr; +}; + +void BufferQueueTest::SetUpTestCase() +{ + bq = new BufferQueue("test"); + sptr listener = new BufferConsumerListener(); + bq->RegisterConsumerListener(listener); + bedata = new OHOS::BufferExtraDataImpl; +} + +void BufferQueueTest::TearDownTestCase() +{ + bq = nullptr; +} + +/* +* Function: Init +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call Init and check ret + */ +TEST_F(BufferQueueTest, Init001) +{ + GSError ret = bq->Init(); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: SetQueueSize and GetQueueSize +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetQueueSize for default +* 2. call SetQueueSize +* 3. call SetQueueSize again with abnormal input +* 4. check ret and call GetQueueSize + */ +TEST_F(BufferQueueTest, QueueSize001) +{ + ASSERT_EQ(bq->GetQueueSize(), (uint32_t)SURFACE_DEFAULT_QUEUE_SIZE); + + GSError ret = bq->SetQueueSize(2); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bq->SetQueueSize(SURFACE_MAX_QUEUE_SIZE + 1); + ASSERT_NE(ret, OHOS::GSERROR_OK); + + ASSERT_EQ(bq->GetQueueSize(), 2u); +} + +/* +* Function: SetQueueSize and GetQueueSize +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetQueueSize 2 times both with abnormal input +* 2. call GetQueueSize +* 3. check ret + */ +TEST_F(BufferQueueTest, QueueSize002) +{ + GSError ret = bq->SetQueueSize(-1); + ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); + ASSERT_EQ(bq->GetQueueSize(), 2u); + + ret = bq->SetQueueSize(0); + ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); + ASSERT_EQ(bq->GetQueueSize(), 2u); +} + +/* +* Function: RequestBuffer, FlushBuffer, AcquireBuffer and ReleaseBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer and FlushBuffer +* 2. call AcquireBuffer and ReleaseBuffer +* 3. check ret + */ +TEST_F(BufferQueueTest, ReqCanFluAcqRel001) +{ + IBufferProducer::RequestBufferReturnValue retval; + + // first request + GSError ret = bq->RequestBuffer(requestConfig, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_NE(retval.buffer, nullptr); + ASSERT_GE(retval.sequence, 0); + + // add cache + cache[retval.sequence] = retval.buffer; + + // buffer queue will map + uint8_t *addr1 = reinterpret_cast(retval.buffer->GetVirAddr()); + ASSERT_NE(addr1, nullptr); + addr1[0] = 5; + + sptr acquireFence = SyncFence::INVALID_FENCE; + ret = bq->FlushBuffer(retval.sequence, bedata, acquireFence, flushConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bq->AcquireBuffer(retval.buffer, retval.fence, timestamp, damage); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_NE(retval.buffer, nullptr); + + uint8_t *addr2 = reinterpret_cast(retval.buffer->GetVirAddr()); + ASSERT_NE(addr2, nullptr); + if (addr2 != nullptr) { + ASSERT_EQ(addr2[0], 5u); + } + + sptr releaseFence = SyncFence::INVALID_FENCE; + ret = bq->ReleaseBuffer(retval.buffer, releaseFence); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer and CancelBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer +* 2. call CancelBuffer +* 3. check ret + */ +TEST_F(BufferQueueTest, ReqCanFluAcqRel002) +{ + IBufferProducer::RequestBufferReturnValue retval; + + // not first request + GSError ret = bq->RequestBuffer(requestConfig, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_GE(retval.sequence, 0); + ASSERT_EQ(retval.buffer, nullptr); + + ret = bq->CancelBuffer(retval.sequence, bedata); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer and CancelBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer +* 2. call CancelBuffer 2 times +* 3. check ret + */ +TEST_F(BufferQueueTest, ReqCanFluAcqRel003) +{ + IBufferProducer::RequestBufferReturnValue retval; + + // not first request + GSError ret = bq->RequestBuffer(requestConfig, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_GE(retval.sequence, 0); + ASSERT_EQ(retval.buffer, nullptr); + + ret = bq->CancelBuffer(retval.sequence, bedata); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bq->CancelBuffer(retval.sequence, bedata); + ASSERT_NE(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer and FlushBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer +* 2. call FlushBuffer 2 times +* 3. check ret + */ +TEST_F(BufferQueueTest, ReqCanFluAcqRel004) +{ + IBufferProducer::RequestBufferReturnValue retval; + + // not first request + GSError ret = bq->RequestBuffer(requestConfig, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_GE(retval.sequence, 0); + ASSERT_EQ(retval.buffer, nullptr); + + sptr acquireFence = SyncFence::INVALID_FENCE; + ret = bq->FlushBuffer(retval.sequence, bedata, acquireFence, flushConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bq->FlushBuffer(retval.sequence, bedata, acquireFence, flushConfig); + ASSERT_NE(ret, OHOS::GSERROR_OK); +} + +/* +* Function: AcquireBuffer and ReleaseBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call AcquireBuffer +* 2. call ReleaseBuffer 2 times +* 3. check ret + */ +TEST_F(BufferQueueTest, ReqCanFluAcqRel005) +{ + sptr buffer; + + sptr acquireFence = SyncFence::INVALID_FENCE; + GSError ret = bq->AcquireBuffer(buffer, acquireFence, timestamp, damage); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + sptr ReleaseFence = SyncFence::INVALID_FENCE; + ret = bq->ReleaseBuffer(buffer, ReleaseFence); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bq->ReleaseBuffer(buffer, ReleaseFence); + ASSERT_NE(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer, and CancelBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer and CancelBuffer by different retval +* 2. check ret + */ +TEST_F(BufferQueueTest, ReqCanFluAcqRel006) +{ + IBufferProducer::RequestBufferReturnValue retval1; + IBufferProducer::RequestBufferReturnValue retval2; + IBufferProducer::RequestBufferReturnValue retval3; + GSError ret; + + // not alloc + ret = bq->RequestBuffer(requestConfig, bedata, retval1); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_GE(retval1.sequence, 0); + ASSERT_EQ(retval1.buffer, nullptr); + + // alloc + ret = bq->RequestBuffer(requestConfig, bedata, retval2); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_GE(retval2.sequence, 0); + ASSERT_NE(retval2.buffer, nullptr); + + cache[retval2.sequence] = retval2.buffer; + + // no buffer + ret = bq->RequestBuffer(requestConfig, bedata, retval3); + ASSERT_NE(ret, OHOS::GSERROR_OK); + ASSERT_EQ(retval3.buffer, nullptr); + + ret = bq->CancelBuffer(retval1.sequence, bedata); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bq->CancelBuffer(retval2.sequence, bedata); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = bq->CancelBuffer(retval3.sequence, bedata); + ASSERT_NE(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer, ReleaseBuffer and FlushBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer +* 2. call ReleaseBuffer +* 3. call FlushBuffer +* 4. check ret + */ +TEST_F(BufferQueueTest, ReqCanFluAcqRel007) +{ + IBufferProducer::RequestBufferReturnValue retval; + + // not alloc + GSError ret = bq->RequestBuffer(requestConfig, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_GE(retval.sequence, 0); + ASSERT_EQ(retval.buffer, nullptr); + + retval.buffer = cache[retval.sequence]; + + sptr releaseFence = SyncFence::INVALID_FENCE; + ret = bq->ReleaseBuffer(retval.buffer, releaseFence); + ASSERT_NE(ret, OHOS::GSERROR_OK); + + sptr acquireFence = SyncFence::INVALID_FENCE; + ret = bq->FlushBuffer(retval.sequence, bedata, acquireFence, flushConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: AcquireBuffer, FlushBuffer and ReleaseBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call AcquireBuffer +* 2. call FlushBuffer +* 3. call ReleaseBuffer +* 4. check ret + */ +TEST_F(BufferQueueTest, ReqCanFluAcqRel008) +{ + sptr buffer; + sptr acquireFence = SyncFence::INVALID_FENCE; + + // acq from last test + GSError ret = bq->AcquireBuffer(buffer, acquireFence, timestamp, damage); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + uint32_t sequence; + for (auto it = cache.begin(); it != cache.end(); it++) { + if (it->second.GetRefPtr() == buffer.GetRefPtr()) { + sequence = it->first; + } + } + ASSERT_GE(sequence, 0); + + ret = bq->FlushBuffer(sequence, bedata, acquireFence, flushConfig); + ASSERT_NE(ret, OHOS::GSERROR_OK); + + sptr releaseFence = SyncFence::INVALID_FENCE; + ret = bq->ReleaseBuffer(buffer, releaseFence); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer and CancelBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer +* 2. call CancelBuffer +* 3. check retval and ret + */ +TEST_F(BufferQueueTest, ReqCanFluAcqRel009) +{ + IBufferProducer::RequestBufferReturnValue retval; + BufferRequestConfig deleteconfig = requestConfig; + deleteconfig.width = 1921; + + GSError ret = bq->RequestBuffer(deleteconfig, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_EQ(retval.deletingBuffers.size(), 1u); + ASSERT_GE(retval.sequence, 0); + ASSERT_NE(retval.buffer, nullptr); + + ret = bq->CancelBuffer(retval.sequence, bedata); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. set BufferRequestConfig with abnormal value +* 2. call RequestBuffer +* 3. check ret + */ +TEST_F(BufferQueueTest, RequestBuffer001) +{ + IBufferProducer::RequestBufferReturnValue retval; + BufferRequestConfig config = requestConfig; + config.width = -1; + + GSError ret = bq->RequestBuffer(config, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: RequestBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. set BufferRequestConfig with abnormal value +* 2. call RequestBuffer +* 3. check ret + */ +TEST_F(BufferQueueTest, RequestBuffer002) +{ + IBufferProducer::RequestBufferReturnValue retval; + BufferRequestConfig config = requestConfig; + config.height = -1; + + GSError ret = bq->RequestBuffer(config, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); +} + + +/* +* Function: RequestBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. set BufferRequestConfig with abnormal value +* 2. call RequestBuffer +* 3. check ret + */ +TEST_F(BufferQueueTest, RequestBuffer003) +{ + IBufferProducer::RequestBufferReturnValue retval; + BufferRequestConfig config = requestConfig; + config.strideAlignment = SURFACE_MIN_STRIDE_ALIGNMENT - 1; + + GSError ret = bq->RequestBuffer(config, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: RequestBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. set BufferRequestConfig with abnormal value +* 2. call RequestBuffer +* 3. check ret + */ +TEST_F(BufferQueueTest, RequestBuffer004) +{ + IBufferProducer::RequestBufferReturnValue retval; + BufferRequestConfig config = requestConfig; + config.strideAlignment = SURFACE_MAX_STRIDE_ALIGNMENT + 1; + + GSError ret = bq->RequestBuffer(config, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: RequestBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. set BufferRequestConfig with abnormal value +* 2. call RequestBuffer +* 3. check ret + */ +TEST_F(BufferQueueTest, RequestBuffer005) +{ + IBufferProducer::RequestBufferReturnValue retval; + BufferRequestConfig config = requestConfig; + config.strideAlignment = 3; + + GSError ret = bq->RequestBuffer(config, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: RequestBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. set BufferRequestConfig with abnormal value +* 2. call RequestBuffer +* 3. check ret + */ +TEST_F(BufferQueueTest, RequestBuffer006) +{ + IBufferProducer::RequestBufferReturnValue retval; + BufferRequestConfig config = requestConfig; + config.format = -1; + + GSError ret = bq->RequestBuffer(config, bedata, retval); + ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); +} +} diff --git a/display_server/frameworks/surface/test/ft_build/buffer_shared_test.cpp b/display_server/frameworks/surface/test/ft_build/buffer_shared_test.cpp new file mode 100644 index 0000000..d3a8476 --- /dev/null +++ b/display_server/frameworks/surface/test/ft_build/buffer_shared_test.cpp @@ -0,0 +1,241 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include +#include "buffer_extra_data_impl.h" +#include "buffer_queue.h" +#include "buffer_consumer_listener.h" +#include "buffer_manager.h" +#include "buffer_log.h" +#include "test_header.h" + +namespace OHOS::Rosen { +class BufferSharedTest : public testing::Test, public IBufferConsumerListenerClazz { +public: + static void SetUpTestCase(); + void OnBufferAvailable() override; + static void TearDownTestCase(); + + static inline sptr surf = nullptr; + static inline sptr producerSurface1 = nullptr; + static inline sptr producerSurface2 = nullptr; + static inline sptr buffer1 = nullptr; + static inline sptr buffer2 = nullptr; + static inline sptr sbuffer1 = nullptr; + static inline sptr sbuffer2 = nullptr; +}; + +void BufferSharedTest::SetUpTestCase() +{ + GTEST_LOG_(INFO) << getpid() << std::endl; + surf = Surface::CreateSurfaceAsConsumer("shared", true); + sptr listener = new BufferConsumerListener(); + surf->RegisterConsumerListener(listener); + auto producer1 = surf->GetProducer(); + producerSurface1 = Surface::CreateSurfaceAsProducer(producer1); + auto producer2 = surf->GetProducer(); + producerSurface2 = Surface::CreateSurfaceAsProducer(producer2); +} + +void BufferSharedTest::OnBufferAvailable() {} + +void BufferSharedTest::TearDownTestCase() +{ +} + +/* +* Function: RequestBuffer +* Type: Reliability +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer with buffer=buffer1, buffer2,the param is same +* 2. check ret1 and ret2 are OHOS::GSERROR_OK, check buffer1 and buffer2 is not nullptr +* 3. check the addr of buffer1 EQ buffer2 +* */ + +TEST_F(BufferSharedTest, RequestBuffer001) +{ + PART("REQUEST BUFFER TWO TIMES") { + GSError ret1, ret2; + STEP("1: request buffer") { + BufferRequestConfig requestConfig = { + .width = 0x100, + .height = 0x100, + .strideAlignment = 0x8, + .format = GRAPHIC_PIXEL_FMT_RGBA_8888, +#ifdef RS_ENABLE_GL + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_MEM_DMA, +#else + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE, +#endif + .timeout = 0, + }; + int releaseFence = -1; + ret1 = producerSurface1->RequestBuffer(buffer1, releaseFence, requestConfig); + ret2 = producerSurface2->RequestBuffer(buffer2, releaseFence, requestConfig); + } + STEP("2: check ret1 ret2 buffer1 buffer2") { + STEP_ASSERT_EQ(ret1, OHOS::GSERROR_OK); + STEP_ASSERT_NE(buffer1, nullptr); + STEP_ASSERT_EQ(ret2, OHOS::GSERROR_OK); + STEP_ASSERT_NE(buffer2, nullptr); + } + STEP("3: check buffer addr") { + STEP_ASSERT_EQ(buffer2, buffer1); + } + } +} +/* +* Function: RequestBuffer with different requestconfig +* Type: Reliability +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer with buffer=bufferDiff, +* the requestconfig is not same with buffer1 +* 2. check ret1 is GSERROR_INVALID_ARGUMENTS +* */ + +TEST_F(BufferSharedTest, RequestBufferDiff001) +{ + PART("REQUEST BUFFER with different requestconfig") { + GSError ret1; + sptr bufferDiff = nullptr; + STEP("1: request buffer") { + BufferRequestConfig diffRequestConfig = { + .width = 0x200, + .height = 0x100, + .strideAlignment = 0x8, + .format = GRAPHIC_PIXEL_FMT_RGBA_8888, +#ifdef RS_ENABLE_GL + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_MEM_DMA, +#else + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE, +#endif + .timeout = 0, + }; + int releaseFence = -1; + ret1 = producerSurface1->RequestBuffer(bufferDiff, releaseFence, diffRequestConfig); + } + STEP("2: check ret1") { + STEP_ASSERT_EQ(ret1, GSERROR_INVALID_ARGUMENTS); + } + } +} +/* +* Function: FlushBuffer +* Type: Reliability +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call FlushBuffer with buffer=buffer1, buffer2 +* 2. check ret1 and ret2 is OHOS::GSERROR_OK +* */ +TEST_F(BufferSharedTest, FlushBuffer001) +{ + PART("FlushBuffer") { + GSError ret1, ret2; + STEP("1: FlushBuffer two times") { + BufferFlushConfig flushConfig = { .damage = { .w = 0x100, .h = 0x100, }, }; + ret1 = producerSurface1->FlushBuffer(buffer1, -1, flushConfig); + ret2 = producerSurface2->FlushBuffer(buffer2, -1, flushConfig); + } + STEP("2: check ret1 ret2") { + STEP_ASSERT_EQ(ret1, OHOS::GSERROR_OK); + STEP_ASSERT_EQ(ret2, OHOS::GSERROR_OK); + } + } +} +/* +* Function: AquiredBuffer +* Type: Reliability +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call AcquireBuffer with buffer=sbuffer1, sbuffer2 +* 2. check ret1 and ret2 are GSERROR_INVALID_ARGUMENTS +* */ +TEST_F(BufferSharedTest, AquiredBuffer001) +{ + PART("AquiredBuffer") { + GSError ret1, ret2; + STEP("1: AcquireBuffer two times") { + int64_t timestamp = 0; + Rect damage = {}; + int32_t fence = -1; + + ret1 = surf->AcquireBuffer(sbuffer1, fence, timestamp, damage); + ret2 = surf->AcquireBuffer(sbuffer2, fence, timestamp, damage); + } + STEP("2: check ret1 ret2") { + STEP_ASSERT_EQ(ret1, OHOS::GSERROR_OK); + STEP_ASSERT_EQ(ret2, OHOS::GSERROR_OK); + } + STEP("3: check addr sbuffer1 and sbuffer2") { + STEP_ASSERT_EQ(sbuffer1, sbuffer2); + } + } +} +/* +* Function: CancelBuffer +* Type: Reliability +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call cancelBuffer with buffer=buffer1 +* 2. check ret1 is GSERROR_INVALID_OPERATING +* 3. call cancelBuffer with buffer=buffer2 +* 4. check ret2 is GSERROR_INVALID_OPERATING +* */ +TEST_F(BufferSharedTest, CancelBuffer001) +{ + PART("CancelBuffer") { + GSError ret1, ret2; + STEP("1: Cancel buffer1") { + ret1 = producerSurface1->CancelBuffer(buffer1); + } + STEP("2: check ret1") { + STEP_ASSERT_EQ(ret1, GSERROR_INVALID_OPERATING); + } + STEP("3: Cancel buffer2") { + ret2 = producerSurface2->CancelBuffer(buffer2); + } + STEP("4: check ret2") { + STEP_ASSERT_EQ(ret2, GSERROR_INVALID_OPERATING); + } + } +} +/* +* Function: RelaseBuffer +* Type: Reliability +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. releaseBuffer two times +* 2. check ret1 is GSERROR_INVALID_OPERATING, check ret1 is OHOS::GSERROR_OK +* */ +TEST_F(BufferSharedTest, ReleaseBuffer001) +{ + PART("ReleaseBuffer") { + GSError ret1, ret2; + STEP("1: releaseBuffer two times") { + ret1 = surf->ReleaseBuffer(sbuffer1, -1); + ret2 = surf->ReleaseBuffer(sbuffer2, -1); + } + STEP("2: check ret1, ret2") { + STEP_ASSERT_EQ(ret1, OHOS::GSERROR_OK); + STEP_ASSERT_EQ(ret2, OHOS::GSERROR_OK); + } + } +} +} diff --git a/display_server/frameworks/surface/test/ft_build/consumer_surface_test.cpp b/display_server/frameworks/surface/test/ft_build/consumer_surface_test.cpp new file mode 100644 index 0000000..3de0b5c --- /dev/null +++ b/display_server/frameworks/surface/test/ft_build/consumer_surface_test.cpp @@ -0,0 +1,857 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include "buffer_consumer_listener.h" + +namespace OHOS::Rosen { +class ConsumerSurfaceTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + static inline BufferRequestConfig requestConfig = { + .width = 0x100, + .height = 0x100, + .strideAlignment = 0x8, + .format = GRAPHIC_PIXEL_FMT_RGBA_8888, +#ifdef RS_ENABLE_GL + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_MEM_DMA, +#else + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE, +#endif + .timeout = 0, + }; + static inline BufferFlushConfig flushConfig = { + .damage = { + .w = 0x100, + .h = 0x100, + }, + }; + static inline int64_t timestamp = 0; + static inline Rect damage = {}; + static inline sptr cs = nullptr; + static inline sptr ps = nullptr; +}; + +void ConsumerSurfaceTest::SetUpTestCase() +{ + cs = Surface::CreateSurfaceAsConsumer(); + sptr listener = new BufferConsumerListener(); + cs->RegisterConsumerListener(listener); + auto p = cs->GetProducer(); + ps = Surface::CreateSurfaceAsProducer(p); +} + +void ConsumerSurfaceTest::TearDownTestCase() +{ + cs = nullptr; +} + +/* +* Function: GetProducer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. get ConsumerSurface and GetProducer +* 2. check ret + */ +TEST_F(ConsumerSurfaceTest, ConsumerSurface001) +{ + ASSERT_NE(cs, nullptr); + + sptr qs = static_cast(cs.GetRefPtr()); + ASSERT_NE(qs, nullptr); + ASSERT_NE(qs->GetProducer(), nullptr); +} + +/* +* Function: SetQueueSize and GetQueueSize +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetQueueSize and get default value +* 2. call SetQueueSize +* 3. call SetQueueSize again with abnormal value +* 4. call GetQueueSize for BufferQueueProducer and BufferQueue +* 5. check ret + */ +TEST_F(ConsumerSurfaceTest, QueueSize001) +{ + ASSERT_EQ(cs->GetQueueSize(), (uint32_t)SURFACE_DEFAULT_QUEUE_SIZE); + GSError ret = cs->SetQueueSize(2); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = cs->SetQueueSize(SURFACE_MAX_QUEUE_SIZE + 1); + ASSERT_NE(ret, OHOS::GSERROR_OK); + + ASSERT_EQ(cs->GetQueueSize(), 2u); +} + +/* +* Function: SetQueueSize and GetQueueSize +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetQueueSize +* 2. call SetQueueSize 2 times +* 3. check ret + */ +TEST_F(ConsumerSurfaceTest, QueueSize002) +{ + sptr qs = static_cast(cs.GetRefPtr()); + sptr bqp = static_cast(qs->GetProducer().GetRefPtr()); + ASSERT_EQ(bqp->GetQueueSize(), 2u); + + GSError ret = cs->SetQueueSize(1); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = cs->SetQueueSize(2); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer and FlushBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer by cs and ps +* 2. call FlushBuffer both +* 3. check ret + */ +TEST_F(ConsumerSurfaceTest, ReqCanFluAcqRel001) +{ + sptr buffer; + int releaseFence = -1; + GSError ret = cs->RequestBuffer(buffer, releaseFence, requestConfig); + ASSERT_NE(ret, OHOS::GSERROR_OK); + + ret = ps->RequestBuffer(buffer, releaseFence, requestConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_NE(buffer, nullptr); + + ret = cs->FlushBuffer(buffer, -1, flushConfig); + ASSERT_NE(ret, OHOS::GSERROR_OK); + + ret = ps->FlushBuffer(buffer, -1, flushConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = ps->RequestBuffer(buffer, releaseFence, requestConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ret = ps->FlushBuffer(buffer, -1, flushConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: AcquireBuffer and ReleaseBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call AcquireBuffer +* 2. call ReleaseBuffer +* 3. check ret + */ +TEST_F(ConsumerSurfaceTest, ReqCanFluAcqRel002) +{ + sptr buffer; + int32_t flushFence; + + GSError ret = cs->AcquireBuffer(buffer, flushFence, timestamp, damage); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_NE(buffer, nullptr); + + ret = cs->ReleaseBuffer(buffer, -1); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: AcquireBuffer and ReleaseBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call AcquireBuffer +* 2. call ReleaseBuffer 2 times +* 3. check ret + */ +TEST_F(ConsumerSurfaceTest, ReqCanFluAcqRel003) +{ + sptr buffer; + int32_t flushFence; + + GSError ret = cs->AcquireBuffer(buffer, flushFence, timestamp, damage); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_NE(buffer, nullptr); + + ret = cs->ReleaseBuffer(buffer, -1); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = cs->ReleaseBuffer(buffer, -1); + ASSERT_NE(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer and CancelBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer by cs and ps +* 2. call CancelBuffer both +* 3. check ret + */ +TEST_F(ConsumerSurfaceTest, ReqCanFluAcqRel004) +{ + sptr buffer; + int releaseFence = -1; + GSError ret = cs->RequestBuffer(buffer, releaseFence, requestConfig); + ASSERT_NE(ret, OHOS::GSERROR_OK); + + ret = ps->RequestBuffer(buffer, releaseFence, requestConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = cs->CancelBuffer(buffer); + ASSERT_NE(ret, OHOS::GSERROR_OK); + + ret = ps->CancelBuffer(buffer); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: SetUserData +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetUserData many times +* 2. check ret + */ +TEST_F(ConsumerSurfaceTest, UserData001) +{ + GSError ret; + + std::string strs[SURFACE_MAX_USER_DATA_COUNT]; + constexpr int32_t stringLengthMax = 32; + char str[stringLengthMax] = {}; + for (int i = 0; i < SURFACE_MAX_USER_DATA_COUNT; i++) { + auto secRet = snprintf_s(str, sizeof(str), sizeof(str) - 1, "%d", i); + ASSERT_GT(secRet, 0); + + strs[i] = str; + ret = cs->SetUserData(strs[i], "magic"); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + } + + ret = cs->SetUserData("-1", "error"); + ASSERT_NE(ret, OHOS::GSERROR_OK); + + std::string retStr; + for (int i = 0; i < SURFACE_MAX_USER_DATA_COUNT; i++) { + retStr = cs->GetUserData(strs[i]); + ASSERT_EQ(retStr, "magic"); + } +} + +/* +* Function: SetUserData +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetUserData many times +* 2. check ret + */ +TEST_F(ConsumerSurfaceTest, RegisterConsumerListener001) +{ + class TestConsumerListener : public IBufferConsumerListener { + public: + void OnBufferAvailable() override + { + sptr buffer; + int32_t flushFence; + + cs->AcquireBuffer(buffer, flushFence, timestamp, damage); + int32_t *p = (int32_t*)buffer->GetVirAddr(); + if (p != nullptr) { + for (int32_t i = 0; i < 128; i++) { + ASSERT_EQ(p[i], i); + } + } + + cs->ReleaseBuffer(buffer, -1); + } + }; + sptr listener = new TestConsumerListener(); + GSError ret = cs->RegisterConsumerListener(listener); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + sptr buffer; + int releaseFence = -1; + ret = ps->RequestBuffer(buffer, releaseFence, requestConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_NE(buffer, nullptr); + + int32_t *p = (int32_t*)buffer->GetVirAddr(); + if (p != nullptr) { + for (int32_t i = 0; i < 128; i++) { + p[i] = i; + } + } + + ret = ps->FlushBuffer(buffer, -1, flushConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RegisterConsumerListener, RequestBuffer and FlushBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RegisterConsumerListener +* 2. call RequestBuffer +* 3. call FlushBuffer +* 4. check ret + */ +TEST_F(ConsumerSurfaceTest, RegisterConsumerListener002) +{ + sptr listener = new BufferConsumerListener(); + GSError ret = cs->RegisterConsumerListener(listener); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + sptr buffer; + int releaseFence = -1; + ret = ps->RequestBuffer(buffer, releaseFence, requestConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_NE(buffer, nullptr); + + int32_t *p = (int32_t*)buffer->GetVirAddr(); + if (p != nullptr) { + for (int32_t i = 0; i < requestConfig.width * requestConfig.height; i++) { + p[i] = i; + } + } + + ret = ps->FlushBuffer(buffer, -1, flushConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: SetTransform and GetTransform +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetTransform by default + */ +TEST_F(ConsumerSurfaceTest, transform001) +{ + ASSERT_EQ(cs->GetTransform(), GraphicTransformType::GRAPHIC_ROTATE_NONE); +} + +/* +* Function: SetTransform and GetTransform +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetTransform with different paramaters and call GetTransform +* 2. check ret + */ +TEST_F(ConsumerSurfaceTest, transform002) +{ + GraphicTransformType transform = GraphicTransformType::GRAPHIC_ROTATE_90; + GSError ret = ps->SetTransform(transform); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_EQ(cs->GetTransform(), GraphicTransformType::GRAPHIC_ROTATE_90); +} + +/* +* Function: SetTransform and GetTransform +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetTransform with different paramaters and call GetTransform +* 2. check ret + */ +TEST_F(ConsumerSurfaceTest, transform003) +{ + GraphicTransformType transform = GraphicTransformType::GRAPHIC_ROTATE_180; + GSError ret = ps->SetTransform(transform); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_EQ(cs->GetTransform(), GraphicTransformType::GRAPHIC_ROTATE_180); +} + +/* +* Function: SetTransform and GetTransform +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetTransform with different paramaters and call GetTransform +* 2. check ret + */ +TEST_F(ConsumerSurfaceTest, transform004) +{ + GraphicTransformType transform = GraphicTransformType::GRAPHIC_ROTATE_270; + GSError ret = ps->SetTransform(transform); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_EQ(cs->GetTransform(), GraphicTransformType::GRAPHIC_ROTATE_270); +} + +/* +* Function: SetTransform and GetTransform +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetTransform with different paramaters and call GetTransform +* 2. check ret + */ +TEST_F(ConsumerSurfaceTest, transform005) +{ + GraphicTransformType transform = GraphicTransformType::GRAPHIC_ROTATE_NONE; + GSError ret = ps->SetTransform(transform); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_EQ(cs->GetTransform(), GraphicTransformType::GRAPHIC_ROTATE_NONE); +} + +/* +* Function: IsSupportedAlloc +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call IsSupportedAlloc +* 2. check ret + */ +TEST_F(ConsumerSurfaceTest, isSupportedAlloc001) +{ + std::vector infos; + std::vector supporteds; + GSError ret = cs->IsSupportedAlloc(infos, supporteds); + ASSERT_EQ(ret, OHOS::GSERROR_NOT_SUPPORT); +} + +/* +* Function: SetScalingMode and GetScalingMode +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetScalingMode with abnormal parameters and check ret + */ +TEST_F(ConsumerSurfaceTest, scalingMode001) +{ + ScalingMode scalingMode = ScalingMode::SCALING_MODE_SCALE_TO_WINDOW; + GSError ret = cs->SetScalingMode(-1, scalingMode); + ASSERT_EQ(ret, OHOS::GSERROR_NO_ENTRY); + ret = cs->GetScalingMode(-1, scalingMode); + ASSERT_EQ(ret, OHOS::GSERROR_NO_ENTRY); +} + +/* +* Function: SetScalingMode and GetScalingMode +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetScalingMode with normal parameters and check ret +* 2. call GetScalingMode and check ret + */ +TEST_F(ConsumerSurfaceTest, scalingMode002) +{ + uint32_t sequence = 0; + ScalingMode scalingMode = ScalingMode::SCALING_MODE_SCALE_TO_WINDOW; + sptr buffer; + int releaseFence = -1; + GSError ret = ps->RequestBuffer(buffer, releaseFence, requestConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_NE(buffer, nullptr); + + sequence = buffer->GetSeqNum(); + ret = cs->SetScalingMode(sequence, scalingMode); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ScalingMode scalingModeGet = ScalingMode::SCALING_MODE_FREEZE; + ret = cs->GetScalingMode(sequence, scalingModeGet); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_EQ(scalingMode, scalingModeGet); + + ret = ps->CancelBuffer(buffer); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: QueryMetaDataType +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call QueryMetaDataType and check ret + */ +TEST_F(ConsumerSurfaceTest, QueryMetaDataType001) +{ + uint32_t sequence = 0; + HDRMetaDataType type = HDRMetaDataType::HDR_META_DATA; + GSError ret = cs->QueryMetaDataType(sequence, type); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_EQ(type, HDRMetaDataType::HDR_NOT_USED); +} + +/* +* Function: QueryMetaDataType +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetMetaData with normal parameters and check ret +* 2. call QueryMetaDataType and check ret + */ +TEST_F(ConsumerSurfaceTest, QueryMetaDataType002) +{ + uint32_t sequence = 0; + std::vector metaData; + GraphicHDRMetaData data = { + .key = GraphicHDRMetadataKey::GRAPHIC_MATAKEY_RED_PRIMARY_X, + .value = 1, + }; + metaData.push_back(data); + GSError ret = cs->SetMetaData(sequence, metaData); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + HDRMetaDataType type = HDRMetaDataType::HDR_NOT_USED; + ret = cs->QueryMetaDataType(sequence, type); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_EQ(type, HDRMetaDataType::HDR_META_DATA); +} + +/* +* Function: QueryMetaDataType +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetMetaDataSet with normal parameters and check ret +* 2. call QueryMetaDataType and check ret + */ +TEST_F(ConsumerSurfaceTest, QueryMetaDataType003) +{ + uint32_t sequence = 0; + GraphicHDRMetadataKey key = GraphicHDRMetadataKey::GRAPHIC_MATAKEY_HDR10_PLUS; + std::vector metaData; + uint8_t data = 1; + metaData.push_back(data); + GSError ret = cs->SetMetaDataSet(sequence, key, metaData); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + HDRMetaDataType type = HDRMetaDataType::HDR_NOT_USED; + ret = cs->QueryMetaDataType(sequence, type); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_EQ(type, HDRMetaDataType::HDR_META_DATA_SET); +} + +/* +* Function: SetMetaData and GetMetaData +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetMetaData with abnormal parameters and check ret + */ +TEST_F(ConsumerSurfaceTest, metaData001) +{ + uint32_t sequence = 0; + std::vector metaData; + GSError ret = cs->SetMetaData(sequence, metaData); + ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: SetMetaData and GetMetaData +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetMetaData with normal parameters and check ret + */ +TEST_F(ConsumerSurfaceTest, metaData002) +{ + uint32_t sequence = 0; + std::vector metaData; + GraphicHDRMetaData data = { + .key = GraphicHDRMetadataKey::GRAPHIC_MATAKEY_RED_PRIMARY_X, + .value = 100, // for test + }; + metaData.push_back(data); + GSError ret = cs->SetMetaData(sequence, metaData); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: SetMetaData and GetMetaData +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetMetaData with normal parameters and check ret +* 2. call GetMetaData and check ret + */ +TEST_F(ConsumerSurfaceTest, metaData003) +{ + uint32_t sequence = 0; + std::vector metaData; + GraphicHDRMetaData data = { + .key = GraphicHDRMetadataKey::GRAPHIC_MATAKEY_RED_PRIMARY_X, + .value = 100, // for test + }; + metaData.push_back(data); + + sptr buffer; + int releaseFence = -1; + GSError ret = ps->RequestBuffer(buffer, releaseFence, requestConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_NE(buffer, nullptr); + + sequence = buffer->GetSeqNum(); + ret = cs->SetMetaData(sequence, metaData); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + std::vector metaDataGet; + ret = cs->GetMetaData(sequence, metaDataGet); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_EQ(metaData[0].key, metaDataGet[0].key); + ASSERT_EQ(metaData[0].value, metaDataGet[0].value); + + ret = cs->GetMetaData(sequence + 1, metaDataGet); + ASSERT_EQ(ret, OHOS::GSERROR_NO_ENTRY); + + ret = ps->CancelBuffer(buffer); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: SetMetaDataSet and GetMetaDataSet +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetMetaDataSet with abnormal parameters and check ret + */ +TEST_F(ConsumerSurfaceTest, metaDataSet001) +{ + uint32_t sequence = 0; + GraphicHDRMetadataKey key = GraphicHDRMetadataKey::GRAPHIC_MATAKEY_HDR10_PLUS; + std::vector metaData; + GSError ret = cs->SetMetaDataSet(sequence, key, metaData); + ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: SetMetaDataSet and GetMetaDataSet +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetMetaDataSet with normal parameters and check ret + */ +TEST_F(ConsumerSurfaceTest, metaDataSet002) +{ + uint32_t sequence = 0; + GraphicHDRMetadataKey key = GraphicHDRMetadataKey::GRAPHIC_MATAKEY_HDR10_PLUS; + std::vector metaData; + uint8_t data = 10; // for test + metaData.push_back(data); + GSError ret = cs->SetMetaDataSet(sequence, key, metaData); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: SetMetaDataSet and GetMetaDataSet +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetMetaDataSet with normal parameters and check ret +* 2. call GetMetaDataSet and check ret + */ +TEST_F(ConsumerSurfaceTest, metaDataSet003) +{ + uint32_t sequence = 0; + GraphicHDRMetadataKey key = GraphicHDRMetadataKey::GRAPHIC_MATAKEY_HDR10_PLUS; + std::vector metaData; + uint8_t data = 10; // for test + metaData.push_back(data); + + sptr buffer; + int releaseFence = -1; + GSError ret = ps->RequestBuffer(buffer, releaseFence, requestConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_NE(buffer, nullptr); + + sequence = buffer->GetSeqNum(); + ret = cs->SetMetaDataSet(sequence, key, metaData); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + GraphicHDRMetadataKey keyGet = GraphicHDRMetadataKey::GRAPHIC_MATAKEY_RED_PRIMARY_X; + std::vector metaDataGet; + ret = cs->GetMetaDataSet(sequence, keyGet, metaDataGet); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_EQ(key, keyGet); + ASSERT_EQ(metaData[0], metaDataGet[0]); + + ret = cs->GetMetaDataSet(sequence + 1, keyGet, metaDataGet); + ASSERT_EQ(ret, OHOS::GSERROR_NO_ENTRY); + + ret = ps->CancelBuffer(buffer); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: SetTunnelHandle and GetTunnelHandle +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetTunnelHandle with abnormal parameters and check ret + */ +TEST_F(ConsumerSurfaceTest, TunnelHandle001) +{ + GraphicExtDataHandle *handle = nullptr; + GSError ret = cs->SetTunnelHandle(handle); + ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: SetTunnelHandle and GetTunnelHandle +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetTunnelHandle with abnormal parameters and check ret + */ +TEST_F(ConsumerSurfaceTest, TunnelHandle002) +{ + GraphicExtDataHandle *handle = nullptr; + handle = new GraphicExtDataHandle(); + handle->fd = -1; + handle->reserveInts = 0; + GSError ret = cs->SetTunnelHandle(handle); + ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: SetTunnelHandle and GetTunnelHandle +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetTunnelHandle with normal parameters and check ret +* 2. call GetTunnelHandle and check ret +* @tc.require: issueI5GMZN issueI5IWHW + */ +TEST_F(ConsumerSurfaceTest, TunnelHandle003) +{ + size_t size = sizeof(GraphicExtDataHandle) + sizeof(int32_t) * 1; + GraphicExtDataHandle *handle = static_cast(malloc(size)); + handle->fd = -1; + handle->reserveInts = 1; + handle->reserve[0] = 0; + GSError ret = cs->SetTunnelHandle(handle); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = cs->SetTunnelHandle(handle); + ASSERT_EQ(ret, OHOS::GSERROR_NO_ENTRY); + + sptr handleGet = nullptr; + handleGet = cs->GetTunnelHandle(); + ASSERT_NE(handleGet, nullptr); + ASSERT_EQ(handle->fd, handleGet->GetHandle()->fd); + ASSERT_EQ(handle->reserveInts, handleGet->GetHandle()->reserveInts); + ASSERT_EQ(handle->reserve[0], handleGet->GetHandle()->reserve[0]); + free(handle); +} + +/* +* Function: disconnect +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call Disconnect and check ret + */ +TEST_F(ConsumerSurfaceTest, disconnect001) +{ + GSError ret = cs->Disconnect(); + ASSERT_EQ(ret, OHOS::GSERROR_NOT_SUPPORT); +} + +/* +* Function: SetPresentTimestamp and GetPresentTimestamp +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetPresentTimestamp and check ret +* @tc.require: issueI5I57K + */ +TEST_F(ConsumerSurfaceTest, presentTimestamp001) +{ + uint32_t sequence = 0; + GraphicPresentTimestampType type = GraphicPresentTimestampType::GRAPHIC_DISPLAY_PTS_UNSUPPORTED; + int64_t time = 0; + GSError ret = cs->GetPresentTimestamp(sequence, type, time); + ASSERT_EQ(ret, OHOS::GSERROR_NOT_SUPPORT); +} + +/* +* Function: SetPresentTimestamp and GetPresentTimestamp +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetPresentTimestamp with abnormal parameters and check ret +* @tc.require: issueI5I57K + */ +TEST_F(ConsumerSurfaceTest, presentTimestamp002) +{ + GraphicPresentTimestamp timestamp = {GRAPHIC_DISPLAY_PTS_UNSUPPORTED, 0}; + GSError ret = cs->SetPresentTimestamp(-1, timestamp); + ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: SetPresentTimestamp and GetPresentTimestamp +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetPresentTimestamp with abnormal parameters and check ret +* @tc.require: issueI5I57K + */ +TEST_F(ConsumerSurfaceTest, presentTimestamp003) +{ + GraphicPresentTimestamp timestamp = {GRAPHIC_DISPLAY_PTS_DELAY, 0}; + GSError ret = cs->SetPresentTimestamp(-1, timestamp); + ASSERT_EQ(ret, OHOS::GSERROR_NO_ENTRY); +} + +/* +* Function: SetPresentTimestamp and GetPresentTimestamp +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetPresentTimestamp with normal parameters and check ret +* @tc.require: issueI5I57K + */ +TEST_F(ConsumerSurfaceTest, presentTimestamp004) +{ + uint32_t sequence = 0; + GraphicPresentTimestamp timestamp = {GRAPHIC_DISPLAY_PTS_DELAY, 0}; + GSError ret = cs->SetPresentTimestamp(sequence, timestamp); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: SetPresentTimestamp and GetPresentTimestamp +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetPresentTimestamp with normal parameters and check ret +* @tc.require: issueI5I57K + */ +TEST_F(ConsumerSurfaceTest, presentTimestamp005) +{ + uint32_t sequence = 0; + GraphicPresentTimestamp timestamp = {GRAPHIC_DISPLAY_PTS_TIMESTAMP, 0}; + GSError ret = cs->SetPresentTimestamp(sequence, timestamp); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} +} diff --git a/display_server/frameworks/surface/test/ft_build/producer_surface_test.cpp b/display_server/frameworks/surface/test/ft_build/producer_surface_test.cpp new file mode 100644 index 0000000..50eaf59 --- /dev/null +++ b/display_server/frameworks/surface/test/ft_build/producer_surface_test.cpp @@ -0,0 +1,828 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include "buffer_consumer_listener.h" + +namespace OHOS::Rosen { +class ProducerSurfaceTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + static inline BufferRequestConfig requestConfig = { + .width = 0x100, + .height = 0x100, + .strideAlignment = 0x8, + .format = GRAPHIC_PIXEL_FMT_RGBA_8888, +#ifdef RS_ENABLE_GL + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_MEM_DMA, +#else + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE, +#endif + .timeout = 0, + }; + static inline BufferFlushConfig flushConfig = { + .damage = { + .w = 0x100, + .h = 0x100, + }, + }; + static inline int64_t timestamp = 0; + static inline Rect damage = {}; + static inline sptr csurf = nullptr; + static inline sptr producer = nullptr; + static inline sptr pSurface = nullptr; +}; + +void ProducerSurfaceTest::SetUpTestCase() +{ + csurf = Surface::CreateSurfaceAsConsumer(); + sptr listener = new BufferConsumerListener(); + csurf->RegisterConsumerListener(listener); + producer = csurf->GetProducer(); + pSurface = Surface::CreateSurfaceAsProducer(producer); +} + +void ProducerSurfaceTest::TearDownTestCase() +{ + csurf = nullptr; + producer = nullptr; + pSurface = nullptr; +} + +/* +* Function: ProducerSurface +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. check pSurface + */ +TEST_F(ProducerSurfaceTest, ProducerSurface001) +{ + ASSERT_NE(pSurface, nullptr); +} + +/* +* Function: SetQueueSize and GetQueueSize +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetQueueSize and get default value +* 2. call SetQueueSize +* 3. call SetQueueSize again with abnormal value +* 4. call GetQueueSize +* 5. check ret + */ +TEST_F(ProducerSurfaceTest, QueueSize001) +{ + ASSERT_EQ(pSurface->GetQueueSize(), (uint32_t)SURFACE_DEFAULT_QUEUE_SIZE); + GSError ret = pSurface->SetQueueSize(2); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = pSurface->SetQueueSize(SURFACE_MAX_QUEUE_SIZE + 1); + ASSERT_NE(ret, OHOS::GSERROR_OK); + + ASSERT_EQ(pSurface->GetQueueSize(), 2u); +} + +/* +* Function: RequestBuffer and FlushBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer +* 2. call FlushBuffer +* 3. check ret + */ +TEST_F(ProducerSurfaceTest, ReqCanFluAcqRel001) +{ + sptr buffer; + + int releaseFence = -1; + GSError ret = pSurface->RequestBuffer(buffer, releaseFence, requestConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_NE(buffer, nullptr); + + ret = pSurface->FlushBuffer(buffer, -1, flushConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer and FlushBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer +* 2. call FlushBuffer 2 times +* 3. check ret + */ +TEST_F(ProducerSurfaceTest, ReqCanFluAcqRel002) +{ + sptr buffer; + int releaseFence = -1; + + GSError ret = pSurface->RequestBuffer(buffer, releaseFence, requestConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_NE(buffer, nullptr); + + ret = pSurface->FlushBuffer(buffer, -1, flushConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = pSurface->FlushBuffer(buffer, -1, flushConfig); + ASSERT_NE(ret, OHOS::GSERROR_OK); +} + +/* +* Function: AcquireBuffer and ReleaseBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call AcquireBuffer and ReleaseBuffer many times +* 2. check ret + */ +TEST_F(ProducerSurfaceTest, ReqCanFluAcqRel003) +{ + sptr buffer; + int32_t flushFence; + + GSError ret = pSurface->AcquireBuffer(buffer, flushFence, timestamp, damage); + ASSERT_NE(ret, OHOS::GSERROR_OK); + + ret = pSurface->ReleaseBuffer(buffer, -1); + ASSERT_NE(ret, OHOS::GSERROR_OK); + + ret = csurf->AcquireBuffer(buffer, flushFence, timestamp, damage); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = csurf->ReleaseBuffer(buffer, -1); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = csurf->AcquireBuffer(buffer, flushFence, timestamp, damage); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = csurf->ReleaseBuffer(buffer, -1); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer and CancelBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer +* 2. call CancelBuffer +* 3. check ret + */ +TEST_F(ProducerSurfaceTest, ReqCanFluAcqRel004) +{ + sptr buffer; + + int releaseFence = -1; + GSError ret = pSurface->RequestBuffer(buffer, releaseFence, requestConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = pSurface->CancelBuffer(buffer); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer and CancelBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer +* 2. call CancelBuffer 2 times +* 3. check ret + */ +TEST_F(ProducerSurfaceTest, ReqCanFluAcqRel005) +{ + sptr buffer; + + int releaseFence = -1; + GSError ret = pSurface->RequestBuffer(buffer, releaseFence, requestConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = pSurface->CancelBuffer(buffer); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = pSurface->CancelBuffer(buffer); + ASSERT_NE(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer and CancelBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer and CancelBuffer many times +* 2. check ret + */ +TEST_F(ProducerSurfaceTest, ReqCanFluAcqRel006) +{ + sptr buffer; + sptr buffer1; + sptr buffer2; + int releaseFence = -1; + + GSError ret = pSurface->RequestBuffer(buffer, releaseFence, requestConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = pSurface->RequestBuffer(buffer1, releaseFence, requestConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = pSurface->RequestBuffer(buffer2, releaseFence, requestConfig); + ASSERT_NE(ret, OHOS::GSERROR_OK); + + ret = pSurface->CancelBuffer(buffer); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = pSurface->CancelBuffer(buffer1); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = pSurface->CancelBuffer(buffer2); + ASSERT_NE(ret, OHOS::GSERROR_OK); +} + +/* +* Function: GetQueueSize and SetQueueSize +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetQeueSize +* 2. call SetQueueSize 2 times +* 3. check ret + */ +TEST_F(ProducerSurfaceTest, SetQueueSizeDeleting001) +{ + sptr cs = static_cast(csurf.GetRefPtr()); + sptr bqp = static_cast(cs->GetProducer().GetRefPtr()); + ASSERT_EQ(bqp->GetQueueSize(), 2u); + + GSError ret = pSurface->SetQueueSize(1); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = pSurface->SetQueueSize(2); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: RequestBuffer, ReleaseBuffer and CancelBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestBuffer +* 2. call ReleaseBuffer +* 3. call CancelBuffer +* 4. check ret + */ +TEST_F(ProducerSurfaceTest, ReqCanFluAcqRel007) +{ + sptr buffer; + + int releaseFence = -1; + GSError ret = pSurface->RequestBuffer(buffer, releaseFence, requestConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = pSurface->ReleaseBuffer(buffer, -1); + ASSERT_NE(ret, OHOS::GSERROR_OK); + + ret = pSurface->CancelBuffer(buffer); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: SetUserData and GetUserData +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetUserData and GetUserData many times +* 2. check ret + */ +TEST_F(ProducerSurfaceTest, UserData001) +{ + GSError ret; + + std::string strs[SURFACE_MAX_USER_DATA_COUNT]; + constexpr int32_t stringLengthMax = 32; + char str[stringLengthMax] = {}; + for (int i = 0; i < SURFACE_MAX_USER_DATA_COUNT; i++) { + auto secRet = snprintf_s(str, sizeof(str), sizeof(str) - 1, "%d", i); + ASSERT_GT(secRet, 0); + + strs[i] = str; + ret = pSurface->SetUserData(strs[i], "magic"); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + } + + ret = pSurface->SetUserData("-1", "error"); + ASSERT_NE(ret, OHOS::GSERROR_OK); + + std::string retStr; + for (int i = 0; i < SURFACE_MAX_USER_DATA_COUNT; i++) { + retStr = pSurface->GetUserData(strs[i]); + ASSERT_EQ(retStr, "magic"); + } +} + +/* +* Function: RegisterConsumerListener +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RegisterConsumerListener +* 2. check ret + */ +TEST_F(ProducerSurfaceTest, RegisterConsumerListener001) +{ + sptr listener = new BufferConsumerListener(); + GSError ret = pSurface->RegisterConsumerListener(listener); + ASSERT_NE(ret, OHOS::GSERROR_OK); +} + +/* +* Function: GetUniqueId +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetUniqueId +* 2. check ret + */ +TEST_F(ProducerSurfaceTest, UniqueId001) +{ + uint64_t uniqueId = pSurface->GetUniqueId(); + ASSERT_NE(uniqueId, 0); +} + +/* +* Function: SetTransform and GetTransform +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetTransform with default and check ret + */ +TEST_F(ProducerSurfaceTest, transform001) +{ + ASSERT_EQ(pSurface->GetTransform(), GraphicTransformType::GRAPHIC_ROTATE_BUTT); + GSError ret = pSurface->SetTransform(GraphicTransformType::GRAPHIC_ROTATE_NONE); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: SetTransform and GetTransform +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetTransform with other parameters and check ret + */ +TEST_F(ProducerSurfaceTest, transform002) +{ + GSError ret = pSurface->SetTransform(GraphicTransformType::GRAPHIC_ROTATE_90); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: SetTransform and GetTransform +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetTransform with other parameters and check ret + */ +TEST_F(ProducerSurfaceTest, transform003) +{ + GSError ret = pSurface->SetTransform(GraphicTransformType::GRAPHIC_ROTATE_180); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: SetTransform and GetTransform +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetTransform with other parameters and check ret + */ +TEST_F(ProducerSurfaceTest, transform004) +{ + GSError ret = pSurface->SetTransform(GraphicTransformType::GRAPHIC_ROTATE_270); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: IsSupportedAlloc +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call IsSupportedAlloc with abnormal parameters and check ret + */ +TEST_F(ProducerSurfaceTest, isSupportedAlloc001) +{ + std::vector infos; + std::vector supporteds; + GSError ret = pSurface->IsSupportedAlloc(infos, supporteds); + ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: IsSupportedAlloc +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call IsSupportedAlloc with abnormal parameters and check ret + */ +TEST_F(ProducerSurfaceTest, isSupportedAlloc002) +{ + std::vector infos; + std::vector supporteds; + GSError ret = pSurface->IsSupportedAlloc(infos, supporteds); + ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); + + BufferVerifyAllocInfo info = { + .width = 0x100, + .height = 0x100, +#ifdef RS_ENABLE_GL + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_MEM_DMA, +#else + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE, +#endif + .format = GRAPHIC_PIXEL_FMT_RGBA_8888, + }; + infos.push_back(info); + info.format = GRAPHIC_PIXEL_FMT_YCRCB_420_SP; + infos.push_back(info); + info.format = GRAPHIC_PIXEL_FMT_YUV_422_I; + infos.push_back(info); + + ret = pSurface->IsSupportedAlloc(infos, supporteds); + ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: IsSupportedAlloc +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call IsSupportedAlloc with normal parameters and check ret + */ +TEST_F(ProducerSurfaceTest, isSupportedAlloc003) +{ + std::vector infos; + std::vector supporteds; + BufferVerifyAllocInfo info = { + .width = 0x100, + .height = 0x100, +#ifdef RS_ENABLE_GL + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_MEM_DMA, +#else + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE, +#endif + .format = GRAPHIC_PIXEL_FMT_RGBA_8888, + }; + infos.push_back(info); + info.format = GRAPHIC_PIXEL_FMT_YCRCB_420_SP; + infos.push_back(info); + info.format = GRAPHIC_PIXEL_FMT_YUV_422_I; + infos.push_back(info); + + supporteds.push_back(false); + supporteds.push_back(false); + supporteds.push_back(false); + + GSError ret = pSurface->IsSupportedAlloc(infos, supporteds); + ASSERT_EQ(ret, OHOS::GSERROR_OK); // mock data result + ASSERT_EQ(supporteds[0], true); // mock data result + ASSERT_EQ(supporteds[1], true); // mock data result + ASSERT_EQ(supporteds[2], false); // mock data result +} + +/* +* Function: SetScalingMode and GetScalingMode +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetScalingMode with abnormal parameters and check ret + */ +TEST_F(ProducerSurfaceTest, scalingMode001) +{ + ScalingMode scalingMode = ScalingMode::SCALING_MODE_SCALE_TO_WINDOW; + GSError ret = pSurface->SetScalingMode(-1, scalingMode); + ASSERT_EQ(ret, OHOS::GSERROR_NO_ENTRY); +} + +/* +* Function: SetScalingMode and GetScalingMode +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetScalingMode with normal parameters and check ret +* 2. call GetScalingMode and check ret + */ +TEST_F(ProducerSurfaceTest, scalingMode002) +{ + ScalingMode scalingMode = ScalingMode::SCALING_MODE_SCALE_TO_WINDOW; + sptr buffer; + int releaseFence = -1; + GSError ret = pSurface->RequestBuffer(buffer, releaseFence, requestConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_NE(buffer, nullptr); + + uint32_t sequence = buffer->GetSeqNum(); + ret = pSurface->SetScalingMode(sequence, scalingMode); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = pSurface->GetScalingMode(sequence, scalingMode); + ASSERT_EQ(ret, OHOS::GSERROR_NOT_SUPPORT); + + ret = pSurface->CancelBuffer(buffer); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: SetMetaData and GetMetaData +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetMetaData with abnormal parameters and check ret + */ +TEST_F(ProducerSurfaceTest, metaData001) +{ + uint32_t sequence = 0; + std::vector metaData; + GSError ret = pSurface->SetMetaData(sequence, metaData); + ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: SetMetaData and GetMetaData +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetMetaData with abnormal parameters and check ret + */ +TEST_F(ProducerSurfaceTest, metaData002) +{ + std::vector metaData; + GraphicHDRMetaData data = { + .key = GraphicHDRMetadataKey::GRAPHIC_MATAKEY_RED_PRIMARY_X, + .value = 100, // for test + }; + metaData.push_back(data); + GSError ret = pSurface->SetMetaData(-1, metaData); + ASSERT_EQ(ret, OHOS::GSERROR_NO_ENTRY); +} + +/* +* Function: SetMetaData and GetMetaData +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetMetaData with normal parameters and check ret +* 2. call GetMetaData and check ret + */ +TEST_F(ProducerSurfaceTest, metaData003) +{ + uint32_t sequence = 0; + std::vector metaData; + GraphicHDRMetaData data = { + .key = GraphicHDRMetadataKey::GRAPHIC_MATAKEY_RED_PRIMARY_X, + .value = 100, // for test + }; + metaData.push_back(data); + sptr buffer; + int releaseFence = -1; + GSError ret = pSurface->RequestBuffer(buffer, releaseFence, requestConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_NE(buffer, nullptr); + + sequence = buffer->GetSeqNum(); + ret = pSurface->SetMetaData(sequence, metaData); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = pSurface->GetMetaData(sequence, metaData); + ASSERT_EQ(ret, OHOS::GSERROR_NOT_SUPPORT); + + ret = pSurface->CancelBuffer(buffer); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: SetMetaDataSet and GetMetaDataSet +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetMetaDataSet with abnormal parameters and check ret + */ +TEST_F(ProducerSurfaceTest, metaDataSet001) +{ + GraphicHDRMetadataKey key = GraphicHDRMetadataKey::GRAPHIC_MATAKEY_HDR10_PLUS; + std::vector metaData; + + uint32_t sequence = 0; + GSError ret = pSurface->SetMetaDataSet(sequence, key, metaData); + ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: SetMetaDataSet and GetMetaDataSet +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetMetaDataSet with abnormal parameters and check ret + */ +TEST_F(ProducerSurfaceTest, metaDataSet002) +{ + GraphicHDRMetadataKey key = GraphicHDRMetadataKey::GRAPHIC_MATAKEY_HDR10_PLUS; + std::vector metaData; + + uint8_t data = 10; // for test + metaData.push_back(data); + GSError ret = pSurface->SetMetaDataSet(-1, key, metaData); + ASSERT_EQ(ret, OHOS::GSERROR_NO_ENTRY); +} + +/* +* Function: SetMetaDataSet and GetMetaDataSet +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetMetaDataSet with normal parameters and check ret +* 2. call GetMetaDataSet and check ret + */ +TEST_F(ProducerSurfaceTest, metaDataSet003) +{ + GraphicHDRMetadataKey key = GraphicHDRMetadataKey::GRAPHIC_MATAKEY_HDR10_PLUS; + std::vector metaData; + uint32_t sequence = 0; + uint8_t data = 10; // for test + metaData.push_back(data); + + sptr buffer; + int releaseFence = -1; + GSError ret = pSurface->RequestBuffer(buffer, releaseFence, requestConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_NE(buffer, nullptr); + + sequence = buffer->GetSeqNum(); + ret = pSurface->SetMetaDataSet(sequence, key, metaData); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = pSurface->GetMetaDataSet(sequence, key, metaData); + ASSERT_EQ(ret, OHOS::GSERROR_NOT_SUPPORT); + + ret = pSurface->CancelBuffer(buffer); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: QueryMetaDataType +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call QueryMetaDataType and check ret + */ +TEST_F(ProducerSurfaceTest, QueryMetaDataType001) +{ + uint32_t sequence = 0; + HDRMetaDataType type = HDRMetaDataType::HDR_NOT_USED; + GSError ret = pSurface->QueryMetaDataType(sequence, type); + ASSERT_EQ(ret, OHOS::GSERROR_NOT_SUPPORT); +} + +/* +* Function: SetTunnelHandle and GetTunnelHandle +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetTunnelhandle and check ret +* @tc.require: issueI5GMZN issueI5IWHW + */ +TEST_F(ProducerSurfaceTest, tunnelHandle001) +{ + ASSERT_EQ(pSurface->GetTunnelHandle(), nullptr); +} + +/* +* Function: SetTunnelHandle and GetTunnelHandle +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetTunnelhandle with normal parameters and check ret + */ +TEST_F(ProducerSurfaceTest, tunnelHandle002) +{ + GraphicExtDataHandle *handle = nullptr; + handle = static_cast(malloc(sizeof(GraphicExtDataHandle) + sizeof(int32_t) * 1)); + handle->fd = -1; + handle->reserveInts = 1; + handle->reserve[0] = 0; + GSError ret = pSurface->SetTunnelHandle(handle); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = pSurface->SetTunnelHandle(handle); + ASSERT_EQ(ret, OHOS::GSERROR_NO_ENTRY); + free(handle); +} + +/* +* Function: disconnect +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call Disconnect and check ret + */ +TEST_F(ProducerSurfaceTest, disconnect001) +{ + GSError ret = pSurface->Disconnect(); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: SetPresentTimestamp and GetPresentTimestamp +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetPresentTimestamp and check ret +* @tc.require: issueI5I57K + */ +TEST_F(ProducerSurfaceTest, presentTimestamp001) +{ + uint32_t sequence = 0; + GraphicPresentTimestamp timestamp = {GRAPHIC_DISPLAY_PTS_UNSUPPORTED, 0}; + + GSError ret = pSurface->SetPresentTimestamp(sequence, timestamp); + ASSERT_EQ(ret, OHOS::GSERROR_NOT_SUPPORT); +} + +/* +* Function: SetPresentTimestamp and GetPresentTimestamp +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetPresentTimestamp with normal parameters and check ret +* @tc.require: issueI5I57K + */ +TEST_F(ProducerSurfaceTest, presentTimestamp002) +{ + uint32_t sequence = 0; + GraphicPresentTimestampType type = GraphicPresentTimestampType::GRAPHIC_DISPLAY_PTS_UNSUPPORTED; + int64_t time = 0; + + GSError ret = pSurface->GetPresentTimestamp(sequence, type, time); + ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: SetPresentTimestamp and GetPresentTimestamp +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetPresentTimestamp with normal parameters and check ret +* @tc.require: issueI5I57K + */ +TEST_F(ProducerSurfaceTest, presentTimestamp003) +{ + GraphicPresentTimestampType type = GraphicPresentTimestampType::GRAPHIC_DISPLAY_PTS_DELAY; + int64_t time = 0; + GSError ret = pSurface->GetPresentTimestamp(-1, type, time); + ASSERT_EQ(ret, OHOS::GSERROR_NO_ENTRY); +} + +/* +* Function: SetPresentTimestamp and GetPresentTimestamp +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetPresentTimestamp and check ret +* @tc.require: issueI5I57K + */ +TEST_F(ProducerSurfaceTest, presentTimestamp004) +{ + sptr buffer; + int releaseFence = -1; + GSError ret = pSurface->RequestBuffer(buffer, releaseFence, requestConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + ASSERT_NE(buffer, nullptr); + + uint32_t sequence = buffer->GetSeqNum(); + GraphicPresentTimestampType type = GraphicPresentTimestampType::GRAPHIC_DISPLAY_PTS_DELAY; + int64_t time = 0; + ret = pSurface->GetPresentTimestamp(sequence, type, time); + ASSERT_EQ(ret, OHOS::GSERROR_NO_ENTRY); + + ret = pSurface->CancelBuffer(buffer); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} +} diff --git a/display_server/frameworks/surface/test/ft_build/surface_buffer_impl_test.cpp b/display_server/frameworks/surface/test/ft_build/surface_buffer_impl_test.cpp new file mode 100644 index 0000000..7a26e82 --- /dev/null +++ b/display_server/frameworks/surface/test/ft_build/surface_buffer_impl_test.cpp @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include + +namespace OHOS::Rosen { +class SurfaceBufferImplTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + static inline BufferRequestConfig requestConfig = { + .width = 0x100, + .height = 0x100, + .strideAlignment = 0x8, + .format = GRAPHIC_PIXEL_FMT_RGBA_8888, +#ifdef RS_ENABLE_GL + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_MEM_DMA, +#else + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE, +#endif + .timeout = 0, + .colorGamut = GraphicColorGamut::GRAPHIC_COLOR_GAMUT_DCI_P3, + }; + static inline sptr buffer = nullptr; + static inline int32_t val32 = 0; + static inline int64_t val64 = 0; +}; + +void SurfaceBufferImplTest::SetUpTestCase() +{ + buffer = nullptr; + val32 = 0; + val64 = 0; +} + +void SurfaceBufferImplTest::TearDownTestCase() +{ + buffer = nullptr; +} + +/* +* Function: GetSeqNum +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. new SurfaceBufferImpl and GetSeqNum +* 2. new SurfaceBufferImpl again and check GetSeqNum = oldSeq + 1 + */ +TEST_F(SurfaceBufferImplTest, NewSeqIncrease001) +{ + buffer = new SurfaceBufferImpl(); + int oldSeq = buffer->GetSeqNum(); + + buffer = new SurfaceBufferImpl(); + ASSERT_EQ(oldSeq + 1, buffer->GetSeqNum()); +} + +/* +* Function: check buffer state +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. check buffer state, such as bufferhandle, virAddr, fileDescriptor and size + */ +TEST_F(SurfaceBufferImplTest, State001) +{ + ASSERT_EQ(buffer->GetBufferHandle(), nullptr); + ASSERT_EQ(buffer->GetVirAddr(), nullptr); + ASSERT_EQ(buffer->GetFileDescriptor(), -1); + ASSERT_EQ(buffer->GetSize(), 0u); +} + +/* +* Function: check buffer state +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetBufferHandle and Alloc +* 2. check buffer state, such as bufferhandle, virAddr and size +* 3. call Free +* 4. check ret + */ +TEST_F(SurfaceBufferImplTest, State002) +{ + ASSERT_EQ(buffer->GetBufferHandle(), nullptr); + + GSError ret = buffer->Alloc(requestConfig); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ASSERT_NE(buffer->GetBufferHandle(), nullptr); + ASSERT_NE(buffer->GetVirAddr(), nullptr); + ASSERT_NE(buffer->GetSize(), 0u); + ASSERT_EQ(buffer->GetFormat(), GRAPHIC_PIXEL_FMT_RGBA_8888); +#ifdef RS_ENABLE_GL + ASSERT_EQ(buffer->GetUsage(), BUFFER_USAGE_CPU_READ | BUFFER_USAGE_MEM_DMA); +#else + ASSERT_EQ(buffer->GetUsage(), BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE); +#endif + ASSERT_EQ(buffer->GetSurfaceBufferColorGamut(), GraphicColorGamut::GRAPHIC_COLOR_GAMUT_DCI_P3); + + ret = BufferManager::GetInstance()->Free(buffer); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: parcel +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. new SurfaceBufferImpl and Alloc +* 2. call Set data interface +* 3. call WriteSurfaceBufferImpl and ReadSurfaceBufferImpl +* 4. call Get data interface +* 5. check ret + */ +TEST_F(SurfaceBufferImplTest, Parcel001) +{ + sptr sbi = new SurfaceBufferImpl(0); + const auto &bm = BufferManager::GetInstance(); + auto sret = bm->Alloc(requestConfig, sbi); + ASSERT_EQ(sret, OHOS::GSERROR_OK); + + MessageParcel parcel; + WriteSurfaceBufferImpl(parcel, sbi->GetSeqNum(), sbi); + + sptr buffer = nullptr; + uint32_t seq; + ReadSurfaceBufferImpl(parcel, seq, buffer); + ASSERT_NE(buffer, nullptr); +} +} diff --git a/display_server/frameworks/surface/test/ft_build/surface_utils_test.cpp b/display_server/frameworks/surface/test/ft_build/surface_utils_test.cpp new file mode 100644 index 0000000..65a0ace --- /dev/null +++ b/display_server/frameworks/surface/test/ft_build/surface_utils_test.cpp @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include "buffer_consumer_listener.h" + +namespace OHOS::Rosen { +class SurfaceUtilsTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + static inline sptr csurface1 = nullptr; + static inline sptr producer1 = nullptr; + static inline sptr psurface1 = nullptr; + + static inline sptr csurface2 = nullptr; + static inline sptr producer2 = nullptr; + static inline sptr psurface2 = nullptr; + + static inline SurfaceUtils *utils = nullptr; +}; + +void SurfaceUtilsTest::SetUpTestCase() +{ + csurface1 = Surface::CreateSurfaceAsConsumer(); + sptr listener1 = new BufferConsumerListener(); + csurface1->RegisterConsumerListener(listener1); + producer1 = csurface1->GetProducer(); + psurface1 = Surface::CreateSurfaceAsProducer(producer1); + + csurface2 = Surface::CreateSurfaceAsConsumer(); + sptr listener2 = new BufferConsumerListener(); + csurface2->RegisterConsumerListener(listener2); + producer2 = csurface2->GetProducer(); + psurface2 = Surface::CreateSurfaceAsProducer(producer2); +} + +void SurfaceUtilsTest::TearDownTestCase() +{ + csurface1 = nullptr; + producer1 = nullptr; + psurface1 = nullptr; + + csurface2 = nullptr; + producer2 = nullptr; + psurface2 = nullptr; + utils = nullptr; +} + +/* +* Function: GetInstance +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetInstance +* 2. check ret + */ +TEST_F(SurfaceUtilsTest, GetInstance001) +{ + utils = SurfaceUtils::GetInstance(); + ASSERT_NE(utils, nullptr); +} + +/* +* Function: GetInstance +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call Add +* 2. check ret + */ +TEST_F(SurfaceUtilsTest, Add001) +{ + GSError ret = utils->Add(psurface1->GetUniqueId(), nullptr); + ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: GetInstance +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call Add 2 times +* 2. check ret + */ +TEST_F(SurfaceUtilsTest, Add002) +{ + GSError ret = utils->Add(psurface1->GetUniqueId(), psurface1); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = utils->Add(psurface1->GetUniqueId(), psurface1); + ASSERT_EQ(ret, OHOS::GSERROR_OK); +} + +/* +* Function: GetSurface +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetSurface by abnormal uniqueId +* 2. check ret + */ +TEST_F(SurfaceUtilsTest, GetSurface001) +{ + sptr surface = utils->GetSurface(0); + ASSERT_EQ(surface, nullptr); +} + +/* +* Function: GetSurface +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetSurface +* 2. check ret + */ +TEST_F(SurfaceUtilsTest, GetSurface002) +{ + sptr surface1 = utils->GetSurface(psurface1->GetUniqueId()); + ASSERT_NE(surface1, nullptr); +} + +/* +* Function: GetSurface +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetSurface +* 2. call Add +* 3. call GetSurface again +* 4. check ret + */ +TEST_F(SurfaceUtilsTest, GetSurface003) +{ + sptr surface2 = utils->GetSurface(psurface2->GetUniqueId()); + ASSERT_EQ(surface2, nullptr); + + GSError ret = utils->Add(psurface2->GetUniqueId(), psurface2); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + surface2 = utils->GetSurface(psurface2->GetUniqueId()); + ASSERT_NE(surface2, nullptr); +} + +/* +* Function: Remove +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call Remove +* 2. check ret + */ +TEST_F(SurfaceUtilsTest, Remove001) +{ + GSError ret = utils->Remove(0); + ASSERT_EQ(ret, GSERROR_INVALID_OPERATING); +} + +/* +* Function: Remove +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call Remove 2 times +* 2. check ret + */ +TEST_F(SurfaceUtilsTest, Remove002) +{ + GSError ret = utils->Remove(psurface1->GetUniqueId()); + ASSERT_EQ(ret, OHOS::GSERROR_OK); + + ret = utils->Remove(psurface1->GetUniqueId()); + ASSERT_EQ(ret, SURFACE_ERROR_INVALID_OPERATING); +} +} \ No newline at end of file diff --git a/display_server/ft_build/BUILD.gn b/display_server/ft_build/BUILD.gn index eaa0425..2ffd237 100644 --- a/display_server/ft_build/BUILD.gn +++ b/display_server/ft_build/BUILD.gn @@ -15,13 +15,9 @@ import("//build/gn/fangtian.gni") import("ds_config.gni") group("libsurface") { - public_deps = [ "frameworks/surface:surface" ] + public_deps = [ "../frameworks/surface/ft_build:surface" ] } group("libfence") { - public_deps = [ "frameworks/fence:libfence" ] -} - -group("libgl") { - public_deps = libgl + public_deps = [ "../frameworks/fence/ft_build:libfence" ] } diff --git a/display_server/ft_build/ds_config.gni b/display_server/ft_build/ds_config.gni index 550530d..a2f0b58 100644 --- a/display_server/ft_build/ds_config.gni +++ b/display_server/ft_build/ds_config.gni @@ -25,9 +25,11 @@ if (graphic_standard_feature_ace_enable_gpu) { "RS_ENABLE_GL", ] ds_enable_gpu = true + libgl = [ "EGL", "GLESv2" ] } else { gpu_defines = [ "ACE_DISABLE_GL" ] ds_enable_gpu = false + libgl = [] } if (graphic_standard_feature_rs_enable_eglimage) { diff --git a/display_server/rosen/modules/composer/hdi_backend/test/ft_build/BUILD.gn b/display_server/rosen/modules/composer/hdi_backend/test/ft_build/BUILD.gn new file mode 100644 index 0000000..60ab123 --- /dev/null +++ b/display_server/rosen/modules/composer/hdi_backend/test/ft_build/BUILD.gn @@ -0,0 +1,94 @@ +# Copyright (c) 2023 Huawei Technologies Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/gn/fangtian.gni") + +group("unittest") { + testonly = true + + deps = [ + ":hdibackend_test", + ":hdidevice_test", + ":hdiframebuffersurface_test", + ":hdilayerinfo_test", + ":hdioutput_test", + ] +} + +config("hdibackend_test_common_public_config") { + include_dirs = [ + "//display_server/rosen/modules/composer/hdi_backend/include", + "//display_server/rosen/modules/composer/hdi_backend/test", + "//display_server/interfaces/inner_api/surface", + ] + + cflags = [ + "-Wall", + "-Werror", + "-g3", + ] +} + +ft_static_library("hdibackend_test_common") { + visibility = [ ":*" ] + testonly = true + + public_configs = [ ":hdibackend_test_common_public_config" ] + + public_deps = [ + "//display_server/ft_build:libsurface", + "//display_server/rosen/modules/composer/ft_build:libcomposer", + "//build/gn/configs/system_libs:gtest", + "//build/gn/configs/system_libs:ipc_core", + ] +} + +ft_executable("hdibackend_test") { + testonly = true + + sources = [ "hdibackend_test.cpp" ] + + deps = [ ":hdibackend_test_common" ] +} + +ft_executable("hdidevice_test") { + testonly = true + + sources = [ "hdidevice_test.cpp" ] + + deps = [ ":hdibackend_test_common" ] +} + +ft_executable("hdiframebuffersurface_test") { + testonly = true + + sources = [ "hdiframebuffersurface_test.cpp" ] + + deps = [ ":hdibackend_test_common" ] +} + +ft_executable("hdilayerinfo_test") { + testonly = true + + sources = [ "hdilayerinfo_test.cpp" ] + + deps = [ ":hdibackend_test_common" ] +} + +ft_executable("hdioutput_test") { + testonly = true + + sources = [ "hdioutput_test.cpp" ] + + deps = [ ":hdibackend_test_common" ] +} diff --git a/display_server/rosen/modules/composer/hdi_backend/test/ft_build/hdibackend_test.cpp b/display_server/rosen/modules/composer/hdi_backend/test/ft_build/hdibackend_test.cpp new file mode 100644 index 0000000..92aa1ac --- /dev/null +++ b/display_server/rosen/modules/composer/hdi_backend/test/ft_build/hdibackend_test.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "hdi_backend.h" + +#include + +namespace OHOS { +namespace Rosen { +class HdiBackendTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + static inline HdiBackend* hdiBackend_ = nullptr; +}; + +void HdiBackendTest::SetUpTestCase() +{ + hdiBackend_ = HdiBackend::GetInstance(); +} + +void HdiBackendTest::TearDownTestCase() {} + +namespace { +/** + * @tc.name: RegScreenHotplug001 + * @tc.desc: Verify the RegScreenHotplug of hdibackend + * @tc.type:FUNC + * @tc.require:AR000GGP0P + * @tc.author: + */ +TEST_F(HdiBackendTest, RegScreenHotplug001) +{ + ASSERT_EQ(HdiBackendTest::hdiBackend_->RegScreenHotplug(nullptr, nullptr), ROSEN_ERROR_INVALID_ARGUMENTS); +} + +/** + * @tc.name: RegPrepareComplete001 + * @tc.desc: Verify the RegPrepareComplete of hdibackend + * @tc.type:FUNC + * @tc.require:AR000GGP0P + * @tc.author: + */ + +TEST_F(HdiBackendTest, RegPrepareComplete001) +{ + auto func = [](sptr &, const struct PrepareCompleteParam ¶m, void* data) -> void {}; + ASSERT_EQ(HdiBackendTest::hdiBackend_->RegPrepareComplete(func, nullptr), ROSEN_ERROR_OK); +} + +/** + * @tc.name: RegPrepareComplete002 + * @tc.desc: Verify the RegPrepareComplete of hdibackend + * @tc.type:FUNC + * @tc.require:AR000GGP0P + * @tc.author: + */ + +TEST_F(HdiBackendTest, RegPrepareComplete002) +{ + ASSERT_EQ(HdiBackendTest::hdiBackend_->RegPrepareComplete(nullptr, nullptr), ROSEN_ERROR_INVALID_ARGUMENTS); +} +} // namespace +} // namespace Rosen +} // namespace OHOS diff --git a/display_server/rosen/modules/composer/hdi_backend/test/ft_build/hdidevice_test.cpp b/display_server/rosen/modules/composer/hdi_backend/test/ft_build/hdidevice_test.cpp new file mode 100644 index 0000000..68012ed --- /dev/null +++ b/display_server/rosen/modules/composer/hdi_backend/test/ft_build/hdidevice_test.cpp @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "hdi_device.h" +#include + +namespace OHOS { +namespace Rosen { +class HdiDeviceTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + static inline HdiDevice* hdiDevice_ = nullptr; +}; + +void HdiDeviceTest::SetUpTestCase() +{ + hdiDevice_ = HdiDevice::GetInstance(); + hdiDevice_->ResetHdiFuncs(); +} + +void HdiDeviceTest::TearDownTestCase() +{ + hdiDevice_ = nullptr; +} + +namespace { +/* +* Function: all DeviceFuncs +* Type: Function +* Rank: Important(3) +* EnvConditions: N/A +* CaseDescription: 1. call all DeviceFuncs +* 2. check ret +*/ +TEST_F(HdiDeviceTest, DeviceFuncs001) +{ + HotPlugCallback hotPlugCallback = nullptr; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->RegHotPlugCallback(hotPlugCallback, nullptr), DISPLAY_NULL_PTR); + uint32_t screenId = 0, screenModeId = 0, screenLightLevel = 0, num = 1; + VBlankCallback vblCallback = nullptr; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->RegScreenVBlankCallback(screenId, vblCallback, nullptr), DISPLAY_NULL_PTR); + bool enabled = false, needFlush = false; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetScreenVsyncEnabled(screenId, enabled), DISPLAY_NULL_PTR); + DisplayCapability dcpInfo; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->GetScreenCapability(screenId, dcpInfo), DISPLAY_NULL_PTR); + std::vector dmodes; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->GetScreenSupportedModes(screenId, dmodes), DISPLAY_NULL_PTR); + ASSERT_EQ(HdiDeviceTest::hdiDevice_->GetScreenMode(screenId, screenModeId), DISPLAY_NULL_PTR); + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetScreenMode(screenId, screenModeId), DISPLAY_NULL_PTR); + DispPowerStatus dstatus = POWER_STATUS_ON; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->GetScreenPowerStatus(screenId, dstatus), DISPLAY_NULL_PTR); + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetScreenPowerStatus(screenId, dstatus), DISPLAY_NULL_PTR); + ASSERT_EQ(HdiDeviceTest::hdiDevice_->GetScreenBacklight(screenId, screenLightLevel), DISPLAY_NULL_PTR); + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetScreenBacklight(screenId, screenLightLevel), DISPLAY_NULL_PTR); + ASSERT_EQ(HdiDeviceTest::hdiDevice_->PrepareScreenLayers(screenId, needFlush), DISPLAY_NULL_PTR); + std::vector layersId; + std::vector types; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->GetScreenCompChange(screenId, layersId, types), DISPLAY_NULL_PTR); + BufferHandle *buffer = nullptr; + sptr fence = nullptr; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetScreenClientBuffer(screenId, buffer, fence), DISPLAY_NULL_PTR); + IRect damageRect = {0, 0, 0, 0}; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetScreenClientDamage(screenId, num, damageRect), DISPLAY_NULL_PTR); + std::vector layers; + std::vector> fences; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->GetScreenReleaseFence(screenId, layers, fences), DISPLAY_NULL_PTR); + std::vector gamuts; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->GetScreenSupportedColorGamuts(screenId, gamuts), DISPLAY_NULL_PTR); + GraphicColorGamut gamut = GRAPHIC_COLOR_GAMUT_INVALID; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetScreenColorGamut(screenId, gamut), DISPLAY_NULL_PTR); + ASSERT_EQ(HdiDeviceTest::hdiDevice_->GetScreenColorGamut(screenId, gamut), DISPLAY_NULL_PTR); + GamutMap gamutMap = GAMUT_MAP_CONSTANT; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetScreenGamutMap(screenId, gamutMap), DISPLAY_NULL_PTR); + ASSERT_EQ(HdiDeviceTest::hdiDevice_->GetScreenGamutMap(screenId, gamutMap), DISPLAY_NULL_PTR); + const float *matrix; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetScreenColorTransform(screenId, matrix), DISPLAY_NULL_PTR); + HDRCapability info; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->GetHDRCapabilityInfos(screenId, info), DISPLAY_NULL_PTR); + std::vector keys; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->GetSupportedMetaDataKey(screenId, keys), DISPLAY_NULL_PTR); + ASSERT_EQ(HdiDeviceTest::hdiDevice_->Commit(screenId, fence), DISPLAY_NULL_PTR); +} + +/* +* Function: all LayerFuncs +* Type: Function +* Rank: Important(3) +* EnvConditions: N/A +* CaseDescription: 1. call all LayerFuncs +* 2. check ret +*/ +TEST_F(HdiDeviceTest, LayerFuncs001) +{ + uint32_t screenId = 0, layerId = 0; + GraphicLayerAlpha alpha; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetLayerAlpha(screenId, layerId, alpha), DISPLAY_NULL_PTR); + IRect layerRect = {0, 0, 0, 0}; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetLayerSize(screenId, layerId, layerRect), DISPLAY_NULL_PTR); + GraphicTransformType type = GRAPHIC_ROTATE_NONE; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetTransformMode(screenId, layerId, type), DISPLAY_NULL_PTR); + uint32_t num = 1; + IRect visible = {0, 0, 0, 0}; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetLayerVisibleRegion(screenId, layerId, num, visible), DISPLAY_NULL_PTR); + IRect dirty = {0, 0, 0, 0}; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetLayerDirtyRegion(screenId, layerId, dirty), DISPLAY_NULL_PTR); + BufferHandle *handle = nullptr; + sptr acquireFence = nullptr; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetLayerBuffer(screenId, layerId, handle, acquireFence), DISPLAY_NULL_PTR); + GraphicCompositionType cmpType = GRAPHIC_COMPOSITION_CLIENT; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetLayerCompositionType(screenId, layerId, cmpType), DISPLAY_NULL_PTR); + GraphicBlendType blendType = GRAPHIC_BLEND_NONE; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetLayerBlendType(screenId, layerId, blendType), DISPLAY_NULL_PTR); + IRect crop = {0, 0, 0, 0}; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetLayerCrop(screenId, layerId, crop), DISPLAY_NULL_PTR); + uint32_t zorder = 0; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetLayerZorder(screenId, layerId, zorder), DISPLAY_NULL_PTR); + bool isPreMulti = false; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetLayerPreMulti(screenId, layerId, isPreMulti), DISPLAY_NULL_PTR); + float *matrix; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetLayerColorTransform(screenId, layerId, matrix), DISPLAY_NULL_PTR); + GraphicColorDataSpace colorSpace = GRAPHIC_COLOR_DATA_SPACE_UNKNOWN; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetLayerColorDataSpace(screenId, layerId, colorSpace), DISPLAY_NULL_PTR); + ASSERT_EQ(HdiDeviceTest::hdiDevice_->GetLayerColorDataSpace(screenId, layerId, colorSpace), DISPLAY_NULL_PTR); + std::vector metaData; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetLayerMetaData(screenId, layerId, metaData), DISPLAY_NULL_PTR); + GraphicHDRMetadataKey key = GRAPHIC_MATAKEY_RED_PRIMARY_X; + std::vector metaDatas; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetLayerMetaDataSet(screenId, layerId, key, metaDatas), DISPLAY_NULL_PTR); + GraphicExtDataHandle *extDataHandle = nullptr; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->SetLayerTunnelHandle(screenId, layerId, extDataHandle), DISPLAY_NULL_PTR); + GraphicPresentTimestampType presentTimesType = GRAPHIC_DISPLAY_PTS_UNSUPPORTED; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->GetSupportedPresentTimestampType(screenId, layerId, presentTimesType), + DISPLAY_NULL_PTR); + GraphicPresentTimestamp timestamp; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->GetPresentTimestamp(screenId, layerId, timestamp), DISPLAY_NULL_PTR); + GraphicLayerInfo layerInfo; + ASSERT_EQ(HdiDeviceTest::hdiDevice_->CreateLayer(screenId, layerInfo, layerId), DISPLAY_NULL_PTR); + ASSERT_EQ(HdiDeviceTest::hdiDevice_->CloseLayer(screenId, layerId), DISPLAY_NULL_PTR); +} + +} // namespace +} // namespace Rosen +} // namespace OHOS diff --git a/display_server/rosen/modules/composer/hdi_backend/test/ft_build/hdiframebuffersurface_test.cpp b/display_server/rosen/modules/composer/hdi_backend/test/ft_build/hdiframebuffersurface_test.cpp new file mode 100644 index 0000000..f3ddfae --- /dev/null +++ b/display_server/rosen/modules/composer/hdi_backend/test/ft_build/hdiframebuffersurface_test.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "hdi_framebuffer_surface.h" + +#include + +namespace OHOS { +namespace Rosen { +class HdiFramebufferSurfaceTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + static inline sptr hdiFramebufferSurface_ = nullptr; +}; + +void HdiFramebufferSurfaceTest::SetUpTestCase() +{ + hdiFramebufferSurface_ = HdiFramebufferSurface::CreateFramebufferSurface(); + ASSERT_NE(hdiFramebufferSurface_, nullptr); +} + +void HdiFramebufferSurfaceTest::TearDownTestCase() +{ + hdiFramebufferSurface_ = nullptr; +} +} // namespace Rosen +} // namespace OHOS diff --git a/display_server/rosen/modules/composer/hdi_backend/test/ft_build/hdilayerinfo_test.cpp b/display_server/rosen/modules/composer/hdi_backend/test/ft_build/hdilayerinfo_test.cpp new file mode 100644 index 0000000..702e585 --- /dev/null +++ b/display_server/rosen/modules/composer/hdi_backend/test/ft_build/hdilayerinfo_test.cpp @@ -0,0 +1,556 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "hdi_layer_info.h" +#include "surface_tunnel_handle.h" +#include "sync_fence.h" + +#include + +namespace OHOS { +namespace Rosen { +class HdiLayerInfoTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + static inline std::shared_ptr hdiLayerInfo_; +}; + +void HdiLayerInfoTest::SetUpTestCase() +{ + hdiLayerInfo_ = HdiLayerInfo::CreateHdiLayerInfo(); +} + +void HdiLayerInfoTest::TearDownTestCase() {} + +namespace { +/** + * @tc.name: GetZorder001 + * @tc.desc: Verify the GetZorder of hdilayerinfo + * @tc.type:FUNC + * @tc.require:AR000GGP0P + * @tc.author: + */ +TEST_F(HdiLayerInfoTest, GetZorder001) +{ + HdiLayerInfoTest::hdiLayerInfo_->SetZorder(1); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetZorder(), 1u); +} + +/** + * @tc.name: GetSurface001 + * @tc.desc: Verify the GetSurface of hdilayerinfo + * @tc.type:FUNC + * @tc.require:AR000GGP0P + * @tc.author: + */ +TEST_F(HdiLayerInfoTest, GetSurface001) +{ + sptr surface = nullptr; + HdiLayerInfoTest::hdiLayerInfo_->SetSurface(surface); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetSurface(), nullptr); +} + +/** + * @tc.name: GetBuffer001 + * @tc.desc: Verify the GetBuffer of hdilayerinfo + * @tc.type:FUNC + * @tc.require:AR000GGP0P + * @tc.author: + */ +TEST_F(HdiLayerInfoTest, GetBuffer001) +{ + sptr acquireFence = SyncFence::INVALID_FENCE; + sptr sbuffer = nullptr; + HdiLayerInfoTest::hdiLayerInfo_->SetBuffer(sbuffer, acquireFence); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetBuffer(), nullptr); +} + +/** + * @tc.name: GetAcquireFence001 + * @tc.desc: Verify the GetAcquireFence of hdilayerinfo + * @tc.type:FUNC + * @tc.require:AR000GGP0P + * @tc.author: + */ +TEST_F(HdiLayerInfoTest, GetAcquireFence001) +{ + ASSERT_NE(HdiLayerInfoTest::hdiLayerInfo_->GetAcquireFence(), nullptr); +} + +/** + * @tc.name: GetAlpha001 + * @tc.desc: Verify the GetAlpha of hdilayerinfo + * @tc.type:FUNC + * @tc.require:AR000GGP0P + * @tc.author: + */ +TEST_F(HdiLayerInfoTest, GetAlpha001) +{ + GraphicLayerAlpha layerAlpha = { + .enGlobalAlpha = true, + .enPixelAlpha = true, + .alpha0 = 0, + .alpha1 = 0, + .gAlpha = 0, + }; + HdiLayerInfoTest::hdiLayerInfo_->SetAlpha(layerAlpha); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetAlpha().enGlobalAlpha, layerAlpha.enGlobalAlpha); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetAlpha().enPixelAlpha, layerAlpha.enPixelAlpha); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetAlpha().alpha0, layerAlpha.alpha0); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetAlpha().alpha1, layerAlpha.alpha1); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetAlpha().gAlpha, layerAlpha.gAlpha); +} + +/** + * @tc.name: GetTransformType001 + * @tc.desc: Verify the GetTransformType of hdilayerinfo + * @tc.type:FUNC + * @tc.require:AR000GGP0P + * @tc.author: + */ +TEST_F(HdiLayerInfoTest, GetTransformType001) +{ + GraphicTransformType type = GraphicTransformType::GRAPHIC_ROTATE_90; + HdiLayerInfoTest::hdiLayerInfo_->SetTransform(type); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetTransformType(), GraphicTransformType::GRAPHIC_ROTATE_90); + + type = GraphicTransformType::GRAPHIC_ROTATE_180; + HdiLayerInfoTest::hdiLayerInfo_->SetTransform(type); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetTransformType(), GraphicTransformType::GRAPHIC_ROTATE_180); + + type = GraphicTransformType::GRAPHIC_ROTATE_270; + HdiLayerInfoTest::hdiLayerInfo_->SetTransform(type); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetTransformType(), GraphicTransformType::GRAPHIC_ROTATE_270); +} + +/** + * @tc.name: GetCompositionType001 + * @tc.desc: Verify the GetCompositionType of hdilayerinfo + * @tc.type:FUNC + * @tc.require:AR000GGP0P + * @tc.author: + */ +TEST_F(HdiLayerInfoTest, GetCompositionType001) +{ + GraphicCompositionType type = GRAPHIC_COMPOSITION_CLIENT; + HdiLayerInfoTest::hdiLayerInfo_->SetCompositionType(type); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetCompositionType(), GRAPHIC_COMPOSITION_CLIENT); + + type = GRAPHIC_COMPOSITION_DEVICE; + HdiLayerInfoTest::hdiLayerInfo_->SetCompositionType(type); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetCompositionType(), GRAPHIC_COMPOSITION_DEVICE); + + type = GRAPHIC_COMPOSITION_CURSOR; + HdiLayerInfoTest::hdiLayerInfo_->SetCompositionType(type); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetCompositionType(), GRAPHIC_COMPOSITION_CURSOR); +} + +/** + * @tc.name: GetVisibleNum001 + * @tc.desc: Verify the GetVisibleNum of hdilayerinfo + * @tc.type:FUNC + * @tc.require:AR000GGP0P + * @tc.author: + */ +TEST_F(HdiLayerInfoTest, GetVisibleNum001) +{ + IRect iRect = { + .x = 0, + .y = 0, + .w = 800, + .h = 600, + }; + HdiLayerInfoTest::hdiLayerInfo_->SetVisibleRegion(1, iRect); + ASSERT_NE(HdiLayerInfoTest::hdiLayerInfo_->GetVisibleNum(), 0u); +} + +/** + * @tc.name: GetVisibleRegion001 + * @tc.desc: Verify the GetVisibleRegion of hdilayerinfo + * @tc.type:FUNC + * @tc.require:AR000GGP0P + * @tc.author: + */ +TEST_F(HdiLayerInfoTest, GetVisibleRegion001) +{ + IRect iRect = { + .x = 0, + .y = 0, + .w = 800, + .h = 600, + }; + HdiLayerInfoTest::hdiLayerInfo_->SetVisibleRegion(1, iRect); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetVisibleRegion().x, iRect.x); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetVisibleRegion().y, iRect.y); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetVisibleRegion().w, iRect.w); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetVisibleRegion().h, iRect.h); +} + +/** + * @tc.name: GetDirtyRegion001 + * @tc.desc: Verify the GetDirtyRegion of hdilayerinfo + * @tc.type:FUNC + * @tc.require:AR000GGP0P + * @tc.author: + */ +TEST_F(HdiLayerInfoTest, GetDirtyRegion001) +{ + IRect iRect = { + .x = 0, + .y = 0, + .w = 800, + .h = 600, + }; + HdiLayerInfoTest::hdiLayerInfo_->SetDirtyRegion(iRect); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetDirtyRegion().x, iRect.x); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetDirtyRegion().y, iRect.y); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetDirtyRegion().w, iRect.w); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetDirtyRegion().h, iRect.h); +} + +/** + * @tc.name: GetBlendType001 + * @tc.desc: Verify the GetBlendType of hdilayerinfo + * @tc.type:FUNC + * @tc.require:AR000GGP0P + * @tc.author: + */ +TEST_F(HdiLayerInfoTest, GetBlendType001) +{ + GraphicBlendType type = GraphicBlendType::GRAPHIC_BLEND_CLEAR; + HdiLayerInfoTest::hdiLayerInfo_->SetBlendType(type); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetBlendType(), GraphicBlendType::GRAPHIC_BLEND_CLEAR); + + type = GraphicBlendType::GRAPHIC_BLEND_SRC; + HdiLayerInfoTest::hdiLayerInfo_->SetBlendType(type); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetBlendType(), GraphicBlendType::GRAPHIC_BLEND_SRC); + + type = GraphicBlendType::GRAPHIC_BLEND_SRCOVER; + HdiLayerInfoTest::hdiLayerInfo_->SetBlendType(type); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetBlendType(), GraphicBlendType::GRAPHIC_BLEND_SRCOVER); +} + +/** + * @tc.name: GetCropRect001 + * @tc.desc: Verify the GetCropRect of hdilayerinfo + * @tc.type:FUNC + * @tc.require:AR000GGP0P + * @tc.author: + */ +TEST_F(HdiLayerInfoTest, GetCropRect001) +{ + IRect iRect = { + .x = 0, + .y = 0, + .w = 800, + .h = 600, + }; + HdiLayerInfoTest::hdiLayerInfo_->SetCropRect(iRect); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetCropRect().x, iRect.x); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetCropRect().y, iRect.y); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetCropRect().w, iRect.w); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetCropRect().h, iRect.h); +} + +/** + * @tc.name: GetLayerSize001 + * @tc.desc: Verify the GetLayerSize of hdilayerinfo + * @tc.type:FUNC + * @tc.require:AR000GGP0P + * @tc.author: + */ +TEST_F(HdiLayerInfoTest, GetLayerSize001) +{ + IRect iRect = { + .x = 0, + .y = 0, + .w = 800, + .h = 600, + }; + HdiLayerInfoTest::hdiLayerInfo_->SetLayerSize(iRect); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetLayerSize().x, iRect.x); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetLayerSize().y, iRect.y); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetLayerSize().w, iRect.w); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetLayerSize().h, iRect.h); +} + +/** + * @tc.name: IsPreMulti001 + * @tc.desc: Verify the IsPreMulti of hdilayerinfo + * @tc.type:FUNC + * @tc.require:AR000GGP0P + * @tc.author: + */ +TEST_F(HdiLayerInfoTest, IsPreMulti001) +{ + HdiLayerInfoTest::hdiLayerInfo_->SetPreMulti(true); + ASSERT_NE(HdiLayerInfoTest::hdiLayerInfo_->IsPreMulti(), false); + + HdiLayerInfoTest::hdiLayerInfo_->SetPreMulti(false); + ASSERT_NE(HdiLayerInfoTest::hdiLayerInfo_->IsPreMulti(), true); +} + +/* +* Function: SetTunnelHandleChange and GetTunnelHandleChange +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call GetTunnelHandleChange with default +* 2. call SetTunnelHandleChange +* 3. call GetTunnelHandleChange and check ret + */ +TEST_F(HdiLayerInfoTest, TunnelHandleChange001) +{ + bool change = HdiLayerInfoTest::hdiLayerInfo_->GetTunnelHandleChange(); + ASSERT_EQ(change, false); + HdiLayerInfoTest::hdiLayerInfo_->SetTunnelHandleChange(true); + change = HdiLayerInfoTest::hdiLayerInfo_->GetTunnelHandleChange(); + ASSERT_EQ(change, true); +} + +/* +* Function: SetTunnelHandle and GetTunnelHandle +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call GetTunnelHandle with default +* @tc.require: issueI5GMZN issueI5IWHW + */ +TEST_F(HdiLayerInfoTest, TunnelHandle001) +{ + sptr handle = HdiLayerInfoTest::hdiLayerInfo_->GetTunnelHandle(); + ASSERT_EQ(handle, nullptr); +} + +/* +* Function: SetTunnelHandle and GetTunnelHandle +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetTunnelHandle +* 2. call GetTunnelHandle and check ret +* @tc.require: issueI5GMZN issueI5IWHW + */ +TEST_F(HdiLayerInfoTest, TunnelHandle002) +{ + sptr handle = HdiLayerInfoTest::hdiLayerInfo_->GetTunnelHandle(); + ASSERT_EQ(handle, nullptr); + + sptr tunnelHandle = new SurfaceTunnelHandle; + size_t size = sizeof(GraphicExtDataHandle) + sizeof(int32_t) * 1; + GraphicExtDataHandle *handleSet = static_cast(malloc(size)); + handleSet->fd = -1; + handleSet->reserveInts = 1; + handleSet->reserve[0] = 0; + ASSERT_EQ(tunnelHandle->SetHandle(handleSet), OHOS::GSERROR_OK); + ASSERT_NE(tunnelHandle, nullptr); + HdiLayerInfoTest::hdiLayerInfo_->SetTunnelHandle(tunnelHandle); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetTunnelHandle()->GetHandle()->fd, + tunnelHandle->GetHandle()->fd); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetTunnelHandle()->GetHandle()->reserveInts, + tunnelHandle->GetHandle()->reserveInts); + ASSERT_EQ(HdiLayerInfoTest::hdiLayerInfo_->GetTunnelHandle()->GetHandle()->reserve[0], + tunnelHandle->GetHandle()->reserve[0]); + free(handleSet); +} + +/* +* Function: SetColorTransform and GetColorTransform +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call GetColorTransform with default +* @tc.require: issueI5H317 + */ +TEST_F(HdiLayerInfoTest, ColorTransform001) +{ + float* transform = HdiLayerInfoTest::hdiLayerInfo_->GetColorTransform(); + ASSERT_EQ(transform, nullptr); +} + +/* +* Function: SetColorTransform and GetColorTransform +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetColorTransform +* 2. call GetColorTransform and check ret +* @tc.require: issueI5H317 + */ +TEST_F(HdiLayerInfoTest, ColorTransform002) +{ + float matrix[9] = {1, 0, 0, 0, 1, 0, 0, 0, 1}; + HdiLayerInfoTest::hdiLayerInfo_->SetColorTransform(matrix); + float* transform = HdiLayerInfoTest::hdiLayerInfo_->GetColorTransform(); + ASSERT_NE(transform, nullptr); +} + +/* +* Function: SetColorDataSpace and GetColorDataSpace +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call GetColorDataSpace with default +* @tc.require: issueI5H317 + */ +TEST_F(HdiLayerInfoTest, ColorDataSpace001) +{ + GraphicColorDataSpace colorSpace = HdiLayerInfoTest::hdiLayerInfo_->GetColorDataSpace(); + ASSERT_EQ(colorSpace, GraphicColorDataSpace::GRAPHIC_COLOR_DATA_SPACE_UNKNOWN); +} + +/* +* Function: SetColorDataSpace and GetColorDataSpace +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetColorDataSpace +* 2. call GetColorDataSpace and check ret +* @tc.require: issueI5H317 + */ +TEST_F(HdiLayerInfoTest, ColorDataSpace002) +{ + GraphicColorDataSpace colorSpaceSet = GraphicColorDataSpace::GRAPHIC_GAMUT_DISPLAY_P3; + HdiLayerInfoTest::hdiLayerInfo_->SetColorDataSpace(colorSpaceSet); + GraphicColorDataSpace colorSpaceGet = HdiLayerInfoTest::hdiLayerInfo_->GetColorDataSpace(); + ASSERT_EQ(colorSpaceSet, colorSpaceGet); +} + +/* +* Function: SetMetaData and GetMetaData +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetMetaData +* 2. call GetMetaData and check ret +* @tc.require: issueI5H317 + */ +TEST_F(HdiLayerInfoTest, MetaData001) +{ + std::vector metaData = {{GRAPHIC_MATAKEY_RED_PRIMARY_X, 1}}; + HdiLayerInfoTest::hdiLayerInfo_->SetMetaData(metaData); + std::vector metaDataGet = HdiLayerInfoTest::hdiLayerInfo_->GetMetaData(); + ASSERT_EQ(metaData[0].key, metaDataGet[0].key); + ASSERT_EQ(metaData[0].value, metaDataGet[0].value); +} + +/* +* Function: SetMetaDataSet and GetMetaDataSet +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetMetaDataSet +* 2. call GetMetaDataSet and check ret +* @tc.require: issueI5H317 + */ +TEST_F(HdiLayerInfoTest, MetaDataSet001) +{ + GraphicHDRMetaDataSet metaDataSet = {GraphicHDRMetadataKey::GRAPHIC_MATAKEY_RED_PRIMARY_X, {1, 2, 3}}; + HdiLayerInfoTest::hdiLayerInfo_->SetMetaDataSet(metaDataSet); + GraphicHDRMetaDataSet metaDataSetGet = HdiLayerInfoTest::hdiLayerInfo_->GetMetaDataSet(); + ASSERT_EQ(metaDataSet.key, metaDataSetGet.key); + ASSERT_EQ(metaDataSet.metaData[0], metaDataSetGet.metaData[0]); + ASSERT_EQ(metaDataSet.metaData[1], metaDataSetGet.metaData[1]); + ASSERT_EQ(metaDataSet.metaData[2], metaDataSetGet.metaData[2]); +} + +/* +* Function: SetIsSupportedPresentTimestamp and IsSupportedPresentTimestamp +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call IsSupportedPresentTimestamp with default +* @tc.require: issueI5I57K + */ +TEST_F(HdiLayerInfoTest, IsSupportedPresentTimestamp001) +{ + bool isSupported = HdiLayerInfoTest::hdiLayerInfo_->IsSupportedPresentTimestamp(); + ASSERT_EQ(isSupported, false); +} + +/* +* Function: SetIsSupportedPresentTimestamp and IsSupportedPresentTimestamp +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetIsSupportedPresentTimestamp +* 2. call IsSupportedPresentTimestamp and check ret +* @tc.require: issueI5I57K + */ +TEST_F(HdiLayerInfoTest, IsSupportedPresentTimestamp002) +{ + HdiLayerInfoTest::hdiLayerInfo_->SetIsSupportedPresentTimestamp(true); + bool isSupported = HdiLayerInfoTest::hdiLayerInfo_->IsSupportedPresentTimestamp(); + ASSERT_EQ(isSupported, true); + HdiLayerInfoTest::hdiLayerInfo_->SetIsSupportedPresentTimestamp(false); + isSupported = HdiLayerInfoTest::hdiLayerInfo_->IsSupportedPresentTimestamp(); + ASSERT_EQ(isSupported, false); +} + +/* +* Function: SetPresentTimestamp and GetPresentTimestamp +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call GetPresentTimestamp with default +* @tc.require: issueI5I57K + */ +TEST_F(HdiLayerInfoTest, PresentTimestamp001) +{ + GraphicPresentTimestamp timestamp = HdiLayerInfoTest::hdiLayerInfo_->GetPresentTimestamp(); + ASSERT_EQ(timestamp.type, GRAPHIC_DISPLAY_PTS_UNSUPPORTED); + ASSERT_EQ(timestamp.time, 0); +} + +/* +* Function: SetPresentTimestamp and GetPresentTimestamp +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetPresentTimestamp +* 2. call GetPresentTimestamp and check ret +* @tc.require: issueI5I57K + */ +TEST_F(HdiLayerInfoTest, PresentTimestamp002) +{ + GraphicPresentTimestamp timestampSet = {GRAPHIC_DISPLAY_PTS_DELAY, 1}; // mock data for test + HdiLayerInfoTest::hdiLayerInfo_->SetPresentTimestamp(timestampSet); + GraphicPresentTimestamp timestampGet = HdiLayerInfoTest::hdiLayerInfo_->GetPresentTimestamp(); + ASSERT_EQ(timestampSet.type, timestampGet.type); + ASSERT_EQ(timestampSet.time, timestampGet.time); +} + +/* +* Function: SetPresentTimestamp and GetPresentTimestamp +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetPresentTimestamp +* 2. call GetPresentTimestamp and check ret +* @tc.require: issueI5I57K + */ +TEST_F(HdiLayerInfoTest, PresentTimestamp003) +{ + GraphicPresentTimestamp timestampSet = {GRAPHIC_DISPLAY_PTS_TIMESTAMP, 10}; // mock data for test + HdiLayerInfoTest::hdiLayerInfo_->SetPresentTimestamp(timestampSet); + GraphicPresentTimestamp timestampGet = HdiLayerInfoTest::hdiLayerInfo_->GetPresentTimestamp(); + ASSERT_EQ(timestampSet.type, timestampGet.type); + ASSERT_EQ(timestampSet.time, timestampGet.time); +} +} // namespace +} // namespace Rosen +} // namespace OHOS diff --git a/display_server/rosen/modules/composer/hdi_backend/test/ft_build/hdioutput_test.cpp b/display_server/rosen/modules/composer/hdi_backend/test/ft_build/hdioutput_test.cpp new file mode 100644 index 0000000..b07523d --- /dev/null +++ b/display_server/rosen/modules/composer/hdi_backend/test/ft_build/hdioutput_test.cpp @@ -0,0 +1,247 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "hdi_output.h" + +#include + +namespace OHOS { +namespace Rosen { +class HdiOutputTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + static inline std::shared_ptr hdiOutput_; +}; + +void HdiOutputTest::SetUpTestCase() +{ + uint32_t screenId = 0; + hdiOutput_ = HdiOutput::CreateHdiOutput(screenId); +} + +void HdiOutputTest::TearDownTestCase() {} + +namespace { + +/* +* Function: GetFrameBufferSurface +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call GetFrameBufferSurface() +* 2. check ret +*/ +TEST_F(HdiOutputTest, GetFrameBufferSurface001) +{ + ASSERT_EQ(HdiOutputTest::hdiOutput_->GetFrameBufferSurface(), nullptr); +} + +/* +* Function: GetFramebuffer +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call GetFramebuffer() +* 2. check ret +*/ +TEST_F(HdiOutputTest, GetFramebuffer001) +{ + ASSERT_EQ(HdiOutputTest::hdiOutput_->GetFramebuffer(), nullptr); +} + +/* +* Function: ReleaseFramebuffer +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call ReleaseFramebuffer() +* 2. check ret +*/ +TEST_F(HdiOutputTest, ReleaseFramebuffer001) +{ + sptr buffer; + sptr releaseFence; + ASSERT_EQ(HdiOutputTest::hdiOutput_->ReleaseFramebuffer(buffer, releaseFence), -1); +} + +/* +* Function: GetScreenId +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call GetScreenId() +* 2. check ret +*/ +TEST_F(HdiOutputTest, GetScreenId001) +{ + ASSERT_EQ(HdiOutputTest::hdiOutput_->GetScreenId(), 0u); +} + +/* +* Function: Init +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call Init() +* 2. check ret +*/ +TEST_F(HdiOutputTest, Init001) +{ + ASSERT_EQ(HdiOutputTest::hdiOutput_->Init(), ROSEN_ERROR_OK); + // fbSurface_ already initialized + ASSERT_EQ(HdiOutputTest::hdiOutput_->Init(), ROSEN_ERROR_OK); +} + +/* +* Function: ReleaseFramebuffer +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call ReleaseFramebuffer() +* 2. check ret +*/ +TEST_F(HdiOutputTest, ReleaseFramebuffer002) +{ + sptr buffer; + sptr releaseFence; + ASSERT_EQ(HdiOutputTest::hdiOutput_->ReleaseFramebuffer(buffer, releaseFence), 0); +} + + +/* +* Function: Init +* Type: Function +* Rank: Important(3) +* EnvConditions: N/A +* CaseDescription: 1. call SetOutputDamage() +* 2. call GetOutputDamage() +* 3. check ret +*/ +TEST_F(HdiOutputTest, GetOutputDamage001) +{ + uint32_t num = 1; + IRect iRect = { + .x = 0, + .y = 0, + .w = 800, + .h = 600, + }; + HdiOutputTest::hdiOutput_->SetOutputDamage(num, iRect); + ASSERT_EQ(HdiOutputTest::hdiOutput_->GetOutputDamage().x, iRect.x); + ASSERT_EQ(HdiOutputTest::hdiOutput_->GetOutputDamage().y, iRect.y); + ASSERT_EQ(HdiOutputTest::hdiOutput_->GetOutputDamage().w, iRect.w); + ASSERT_EQ(HdiOutputTest::hdiOutput_->GetOutputDamage().h, iRect.h); +} + +/* +* Function: Init +* Type: Function +* Rank: Important(3) +* EnvConditions: N/A +* CaseDescription: 1. call SetOutputDamage() +* 2. call GetOutputDamageNum() +* 3. check ret +*/ +TEST_F(HdiOutputTest, GetOutputDamageNum001) +{ + uint32_t num = 1; + IRect iRect = { + .x = 0, + .y = 0, + .w = 800, + .h = 600, + }; + HdiOutputTest::hdiOutput_->SetOutputDamage(num, iRect); + ASSERT_EQ(HdiOutputTest::hdiOutput_->GetOutputDamageNum(), 1u); +} + +/* +* Function: GetLayerCompCapacity +* Type: Function +* Rank: Important(3) +* EnvConditions: N/A +* CaseDescription: 1. call SetLayerCompCapacity +* 2. call GetLayerCompCapacity +* 3. check ret +*/ +TEST_F(HdiOutputTest, GetLayerCompCapacity001) +{ + uint32_t layerCompositionCapacity = 8; + HdiOutputTest::hdiOutput_->SetLayerCompCapacity(layerCompositionCapacity); + ASSERT_EQ(HdiOutputTest::hdiOutput_->GetLayerCompCapacity(), 8u); +} + +/* +* Function: GetFrameBufferSurface +* Type: Function +* Rank: Important(3) +* EnvConditions: N/A +* CaseDescription: 1. call GetFrameBufferSurface +* 2. check ret +*/ +TEST_F(HdiOutputTest, GetFrameBufferSurface002) +{ + ASSERT_NE(HdiOutputTest::hdiOutput_->GetFrameBufferSurface(), nullptr); +} + +/* +* Function: GetFramebuffer +* Type: Function +* Rank: Important(3) +* EnvConditions: N/A +* CaseDescription: 1. call GetFramebuffer +* 2. check ret +*/ +TEST_F(HdiOutputTest, GetFramebuffer002) +{ + ASSERT_EQ(HdiOutputTest::hdiOutput_->GetFramebuffer(), nullptr); +} + +/* +* Function: GetDirectClientCompEnableStatus +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetDirectClientCompEnableStatus +* 2. call GetDirectClientCompEnableStatus +* 3. check ret + */ +TEST_F(HdiOutputTest, GetDirectClientCompEnableStatus001) +{ + bool enablStatus = false; + HdiOutputTest::hdiOutput_->SetDirectClientCompEnableStatus(enablStatus); + ASSERT_EQ(HdiOutputTest::hdiOutput_->GetDirectClientCompEnableStatus(), false); +} + +/* +* Function: GetDirectClientCompEnableStatus +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetDirectClientCompEnableStatus +* 2. call GetDirectClientCompEnableStatus +* 3. check ret + */ +TEST_F(HdiOutputTest, GetDirectClientCompEnableStatus002) +{ + bool enablStatus = true; + HdiOutputTest::hdiOutput_->SetDirectClientCompEnableStatus(enablStatus); + ASSERT_EQ(HdiOutputTest::hdiOutput_->GetDirectClientCompEnableStatus(), true); +} +} // namespace +} // namespace Rosen +} // namespace OHOS diff --git a/display_server/rosen/modules/composer/vsync/ft_build/BUILD.gn b/display_server/rosen/modules/composer/vsync/ft_build/BUILD.gn index 79787c4..44ae028 100644 --- a/display_server/rosen/modules/composer/vsync/ft_build/BUILD.gn +++ b/display_server/rosen/modules/composer/vsync/ft_build/BUILD.gn @@ -19,8 +19,6 @@ config("vsync_config") { include_dirs = [ "$display_server_root/utils/log", "$display_server_root/interfaces/inner_api/common", - "$rosen_root/modules/composer/vsync/include", - "$display_server_root/interfaces/inner_api/composer", "$rosen_root/include/common", "$display_server_root/utils/sandbox", "$display_server_root/utils/socketpair/export", @@ -36,6 +34,7 @@ config("vsync_config") { config("vsync_public_config") { include_dirs = [ "$rosen_root/modules/composer/vsync/include", + "$display_server_root/interfaces/inner_api/composer", ] } @@ -57,12 +56,12 @@ ft_shared_library("libvsync") { ] deps = [ - "//build/gn/configs/system_libs:eventhandler", "//build/gn/configs/system_libs:ipc_core", "//build/gn/configs/system_libs:hilog", ] public_deps = [ + "//build/gn/configs/system_libs:eventhandler", "//display_server/utils/sandbox/ft_build:sandbox_utils", "//display_server/utils/socketpair/ft_build:socketpair", "//display_server/utils/scoped_bytrace/ft_build:scoped_bytrace", diff --git a/display_server/rosen/modules/composer/vsync/test/ft_build/BUILD.gn b/display_server/rosen/modules/composer/vsync/test/ft_build/BUILD.gn new file mode 100644 index 0000000..c1fd4cc --- /dev/null +++ b/display_server/rosen/modules/composer/vsync/test/ft_build/BUILD.gn @@ -0,0 +1,105 @@ +# Copyright (c) 2023 Huawei Technologies Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/gn/fangtian.gni") + +group("unittest") { + testonly = true + + deps = [ + ":vsync_connection_test", + ":vsync_controller_test", + ":vsync_distributor_test", + ":vsync_generator_test", + ":vsync_receiver_test", + ":vsync_sampler_test", + ] +} + +config("vsync_test_common_public_config") { + include_dirs = [ + "//display_server/interfaces/inner_api/common", + "//display_server/rosen/modules/composer/vsync/include", + ] + + cflags = [ + "-Wall", + "-Werror", + "-g3", + ] +} + +ft_static_library("vsync_test_common") { + visibility = [ ":*" ] + testonly = true + + public_configs = [ ":vsync_test_common_public_config" ] + + public_deps = [ + "//build/gn/configs/system_libs:gtest", + # "//display_server/rosen/modules/composer/native_vsync/ft_build:libnative_vsync", + "//display_server/rosen/modules/composer/vsync/ft_build:libvsync", + "//display_server/utils/ft_build:socketpair", + ] +} + +ft_executable("vsync_connection_test") { + testonly = true + + sources = [ "vsync_connection_test.cpp" ] + + deps = [ ":vsync_test_common" ] +} + +ft_executable("vsync_controller_test") { + testonly = true + + sources = [ "vsync_controller_test.cpp" ] + + deps = [ ":vsync_test_common" ] +} + +ft_executable("vsync_distributor_test") { + testonly = true + + sources = [ "vsync_distributor_test.cpp" ] + + deps = [ ":vsync_test_common" ] +} + +ft_executable("vsync_generator_test") { + testonly = true + + sources = [ "vsync_generator_test.cpp" ] + + deps = [ ":vsync_test_common" ] +} + +ft_executable("vsync_receiver_test") { + testonly = true + + sources = [ "vsync_receiver_test.cpp" ] + + deps = [ + ":vsync_test_common", + "//build/gn/configs/system_libs:ipc_core" + ] +} + +ft_executable("vsync_sampler_test") { + testonly = true + + sources = [ "vsync_sampler_test.cpp" ] + + deps = [ ":vsync_test_common" ] +} diff --git a/display_server/rosen/modules/composer/vsync/test/ft_build/vsync_connection_test.cpp b/display_server/rosen/modules/composer/vsync/test/ft_build/vsync_connection_test.cpp new file mode 100644 index 0000000..2637ea1 --- /dev/null +++ b/display_server/rosen/modules/composer/vsync/test/ft_build/vsync_connection_test.cpp @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include "vsync_distributor.h" +#include "vsync_generator.h" +#include "vsync_controller.h" + +namespace OHOS { +namespace Rosen { +class VSyncConnectionTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + static inline sptr vsyncController = nullptr; + static inline sptr vsyncDistributor = nullptr; + static inline sptr vsyncGenerator = nullptr; + static inline sptr vsyncConnection = nullptr; +}; + +void VSyncConnectionTest::SetUpTestCase() +{ + vsyncGenerator = CreateVSyncGenerator(); + vsyncController = new VSyncController(vsyncGenerator, 0); + vsyncDistributor = new VSyncDistributor(vsyncController, "VSyncConnection"); + vsyncConnection = new VSyncConnection(vsyncDistributor, "VSyncConnection"); +} + +void VSyncConnectionTest::TearDownTestCase() +{ + DestroyVSyncGenerator(); + vsyncController = nullptr; + vsyncGenerator = nullptr; + vsyncDistributor = nullptr; + vsyncConnection = nullptr; +} + +namespace { +/* +* Function: RequestNextVSync001 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestNextVSync + */ +TEST_F(VSyncConnectionTest, RequestNextVSync001) +{ + ASSERT_EQ(VSyncConnectionTest::vsyncConnection->RequestNextVSync(), VSYNC_ERROR_INVALID_ARGUMENTS); +} + +/* +* Function: RequestNextVSync002 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestNextVSync + */ +TEST_F(VSyncConnectionTest, RequestNextVSync002) +{ + VSyncConnectionTest::vsyncDistributor->AddConnection(VSyncConnectionTest::vsyncConnection); + ASSERT_EQ(VSyncConnectionTest::vsyncConnection->RequestNextVSync(), VSYNC_ERROR_OK); + VSyncConnectionTest::vsyncDistributor->RemoveConnection(VSyncConnectionTest::vsyncConnection); +} + +/* +* Function: SetVSyncRate001 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetVSyncRate + */ +TEST_F(VSyncConnectionTest, SetVSyncRate001) +{ + ASSERT_EQ(VSyncConnectionTest::vsyncConnection->SetVSyncRate(0), VSYNC_ERROR_INVALID_ARGUMENTS); +} + +/* +* Function: SetVSyncRate002 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetVSyncRate + */ +TEST_F(VSyncConnectionTest, SetVSyncRate002) +{ + VSyncConnectionTest::vsyncDistributor->AddConnection(VSyncConnectionTest::vsyncConnection); + ASSERT_EQ(VSyncConnectionTest::vsyncConnection->SetVSyncRate(1), VSYNC_ERROR_OK); + VSyncConnectionTest::vsyncDistributor->RemoveConnection(VSyncConnectionTest::vsyncConnection); +} + +/* +* Function: GetReceiveFd001 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetReceiveFd + */ +TEST_F(VSyncConnectionTest, GetReceiveFd001) +{ + int32_t fd = -1; + ASSERT_EQ(VSyncConnectionTest::vsyncConnection->GetReceiveFd(fd), VSYNC_ERROR_OK); + ASSERT_NE(fd, -1); +} +} // namespace +} // namespace Rosen +} // namespace OHOS diff --git a/display_server/rosen/modules/composer/vsync/test/ft_build/vsync_controller_test.cpp b/display_server/rosen/modules/composer/vsync/test/ft_build/vsync_controller_test.cpp new file mode 100644 index 0000000..59370dc --- /dev/null +++ b/display_server/rosen/modules/composer/vsync/test/ft_build/vsync_controller_test.cpp @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include + +namespace OHOS::Rosen { +class VSyncControllerTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + static inline sptr vsyncController_ = nullptr; + static inline sptr vsyncGenerator_ = nullptr; +}; + +class VSyncControllerCallback : public VSyncController::Callback { +public: + void OnVSyncEvent(int64_t now) override; +}; + +void VSyncControllerTest::SetUpTestCase() +{ + vsyncGenerator_ = CreateVSyncGenerator(); + vsyncController_ = new VSyncController(vsyncGenerator_, 0); +} + +void VSyncControllerTest::TearDownTestCase() +{ + vsyncController_ = nullptr; + vsyncGenerator_ = nullptr; + DestroyVSyncGenerator(); +} + +void VSyncControllerCallback::OnVSyncEvent(int64_t now) {} + +/* +* Function: SetEnable +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetEnable + */ +TEST_F(VSyncControllerTest, SetEnable001) +{ + ASSERT_EQ(VSyncControllerTest::vsyncController_->SetEnable(true), VSYNC_ERROR_OK); +} + +/* +* Function: SetCallback001 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. generate a VSyncControllerCallback obj +* 2. call SetCallback + */ +TEST_F(VSyncControllerTest, SetCallback001) +{ + VSyncControllerCallback* callback = new VSyncControllerCallback; + ASSERT_EQ(VSyncControllerTest::vsyncController_->SetCallback(callback), VSYNC_ERROR_OK); + delete callback; +} + +/* +* Function: SetCallback002 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetCallback with nullptr + */ +TEST_F(VSyncControllerTest, SetCallback002) +{ + ASSERT_EQ(VSyncControllerTest::vsyncController_->SetCallback(nullptr), VSYNC_ERROR_NULLPTR); +} + +/* +* Function: SetPhaseOffset001 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetPhaseOffset + */ +TEST_F(VSyncControllerTest, SetPhaseOffset) +{ + ASSERT_EQ(VSyncControllerTest::vsyncController_->SetPhaseOffset(2), VSYNC_ERROR_OK); +} +} diff --git a/display_server/rosen/modules/composer/vsync/test/ft_build/vsync_distributor_test.cpp b/display_server/rosen/modules/composer/vsync/test/ft_build/vsync_distributor_test.cpp new file mode 100644 index 0000000..f51405d --- /dev/null +++ b/display_server/rosen/modules/composer/vsync/test/ft_build/vsync_distributor_test.cpp @@ -0,0 +1,254 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include "vsync_distributor.h" +#include "vsync_controller.h" + +namespace OHOS { +namespace Rosen { +class VSyncDistributorTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + static inline sptr vsyncController = nullptr; + static inline sptr vsyncDistributor = nullptr; + static inline sptr vsyncGenerator = nullptr; +}; + +void VSyncDistributorTest::SetUpTestCase() +{ + vsyncGenerator = CreateVSyncGenerator(); + vsyncController = new VSyncController(vsyncGenerator, 0); + vsyncDistributor = new VSyncDistributor(vsyncController, "VSyncConnection"); +} + +void VSyncDistributorTest::TearDownTestCase() +{ + vsyncDistributor = nullptr; + vsyncController = nullptr; + vsyncGenerator = nullptr; + DestroyVSyncGenerator(); +} + +namespace { +/* +* Function: AddConnection001 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call AddConnection + */ +TEST_F(VSyncDistributorTest, AddConnection001) +{ + ASSERT_EQ(VSyncDistributorTest::vsyncDistributor->AddConnection(nullptr), VSYNC_ERROR_NULLPTR); +} + +/* +* Function: AddConnection002 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call AddConnection + */ +TEST_F(VSyncDistributorTest, AddConnection002) +{ + sptr conn = new VSyncConnection(vsyncDistributor, "VSyncDistributorTest"); + ASSERT_EQ(VSyncDistributorTest::vsyncDistributor->AddConnection(conn), VSYNC_ERROR_OK); +} + +/* +* Function: RemoveConnection001 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RemoveConnection + */ +TEST_F(VSyncDistributorTest, RemoveConnection001) +{ + ASSERT_EQ(VSyncDistributorTest::vsyncDistributor->RemoveConnection(nullptr), VSYNC_ERROR_NULLPTR); +} + +/* +* Function: RemoveConnection002 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RemoveConnection + */ +TEST_F(VSyncDistributorTest, RemoveConnection002) +{ + sptr conn = new VSyncConnection(vsyncDistributor, "VSyncDistributorTest"); + ASSERT_EQ(VSyncDistributorTest::vsyncDistributor->RemoveConnection(conn), VSYNC_ERROR_INVALID_ARGUMENTS); +} + +/* +* Function: RemoveConnection003 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RemoveConnection + */ +TEST_F(VSyncDistributorTest, RemoveConnection003) +{ + sptr conn = new VSyncConnection(vsyncDistributor, "VSyncDistributorTest"); + VSyncDistributorTest::vsyncDistributor->AddConnection(conn); + ASSERT_EQ(VSyncDistributorTest::vsyncDistributor->RemoveConnection(conn), VSYNC_ERROR_OK); +} + +/* +* Function: RequestNextVSync001 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestNextVSync + */ +TEST_F(VSyncDistributorTest, RequestNextVSync001) +{ + ASSERT_EQ(VSyncDistributorTest::vsyncDistributor->RequestNextVSync(nullptr), VSYNC_ERROR_NULLPTR); +} + +/* +* Function: RequestNextVSync002 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestNextVSync + */ +TEST_F(VSyncDistributorTest, RequestNextVSync002) +{ + sptr conn = new VSyncConnection(vsyncDistributor, "VSyncDistributorTest"); + ASSERT_EQ(VSyncDistributorTest::vsyncDistributor->RequestNextVSync(conn), VSYNC_ERROR_INVALID_ARGUMENTS); +} + +/* +* Function: RequestNextVSync003 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestNextVSync + */ +TEST_F(VSyncDistributorTest, RequestNextVSync003) +{ + sptr conn = new VSyncConnection(vsyncDistributor, "VSyncDistributorTest"); + VSyncDistributorTest::vsyncDistributor->AddConnection(conn); + ASSERT_EQ(VSyncDistributorTest::vsyncDistributor->RequestNextVSync(conn), VSYNC_ERROR_OK); +} + +/* +* Function: SetVSyncRate001 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetVSyncRate + */ +TEST_F(VSyncDistributorTest, SetVSyncRate001) +{ + ASSERT_EQ(VSyncDistributorTest::vsyncDistributor->SetVSyncRate(0, nullptr), VSYNC_ERROR_INVALID_ARGUMENTS); +} + +/* +* Function: SetVSyncRate002 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetVSyncRate + */ +TEST_F(VSyncDistributorTest, SetVSyncRate002) +{ + sptr conn = new VSyncConnection(vsyncDistributor, "VSyncDistributorTest"); + ASSERT_EQ(VSyncDistributorTest::vsyncDistributor->SetVSyncRate(1, conn), VSYNC_ERROR_INVALID_ARGUMENTS); +} + +/* +* Function: SetVSyncRate003 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetVSyncRate + */ +TEST_F(VSyncDistributorTest, SetVSyncRate003) +{ + sptr conn = new VSyncConnection(vsyncDistributor, "VSyncDistributorTest"); + VSyncDistributorTest::vsyncDistributor->AddConnection(conn); + ASSERT_EQ(VSyncDistributorTest::vsyncDistributor->SetVSyncRate(1, conn), VSYNC_ERROR_OK); +} + +/* +* Function: SetVSyncRate004 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetVSyncRate + */ +TEST_F(VSyncDistributorTest, SetVSyncRate004) +{ + sptr conn = new VSyncConnection(vsyncDistributor, "VSyncDistributorTest"); + VSyncDistributorTest::vsyncDistributor->AddConnection(conn); + ASSERT_EQ(VSyncDistributorTest::vsyncDistributor->SetVSyncRate(1, conn), VSYNC_ERROR_OK); + ASSERT_EQ(VSyncDistributorTest::vsyncDistributor->SetVSyncRate(1, conn), VSYNC_ERROR_INVALID_ARGUMENTS); +} + +/* +* Function: SetHighPriorityVSyncRate001 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetHighPriorityVSyncRate with abnormal parameters and check ret + */ +TEST_F(VSyncDistributorTest, SetHighPriorityVSyncRate001) +{ + ASSERT_EQ(VSyncDistributorTest::vsyncDistributor->SetHighPriorityVSyncRate(0, nullptr), + VSYNC_ERROR_INVALID_ARGUMENTS); + ASSERT_EQ(VSyncDistributorTest::vsyncDistributor->SetHighPriorityVSyncRate(1, nullptr), + VSYNC_ERROR_INVALID_ARGUMENTS); + sptr conn = new VSyncConnection(vsyncDistributor, "VSyncDistributorTest"); + ASSERT_EQ(VSyncDistributorTest::vsyncDistributor->SetHighPriorityVSyncRate(1, conn), VSYNC_ERROR_INVALID_ARGUMENTS); +} + +/* +* Function: SetHighPriorityVSyncRate002 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetHighPriorityVSyncRate with normal parameters and check ret + */ +TEST_F(VSyncDistributorTest, SetHighPriorityVSyncRate002) +{ + sptr conn = new VSyncConnection(vsyncDistributor, "VSyncDistributorTest"); + VSyncDistributorTest::vsyncDistributor->AddConnection(conn); + ASSERT_EQ(VSyncDistributorTest::vsyncDistributor->SetHighPriorityVSyncRate(1, conn), VSYNC_ERROR_OK); + ASSERT_EQ(VSyncDistributorTest::vsyncDistributor->SetHighPriorityVSyncRate(1, conn), VSYNC_ERROR_INVALID_ARGUMENTS); + ASSERT_EQ(VSyncDistributorTest::vsyncDistributor->SetHighPriorityVSyncRate(2, conn), VSYNC_ERROR_OK); +} + +/* +* Function: GetVSyncConnectionInfos001 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetVSyncConnectionInfos and check ret + */ +TEST_F(VSyncDistributorTest, GetVSyncConnectionInfos001) +{ + std::vector infos; + ASSERT_EQ(VSyncDistributorTest::vsyncDistributor->GetVSyncConnectionInfos(infos), VSYNC_ERROR_OK); + sptr conn = new VSyncConnection(vsyncDistributor, "VSyncDistributorTest"); + VSyncDistributorTest::vsyncDistributor->AddConnection(conn); + ASSERT_EQ(VSyncDistributorTest::vsyncDistributor->GetVSyncConnectionInfos(infos), VSYNC_ERROR_OK); +} +} // namespace +} // namespace Rosen +} // namespace OHOS diff --git a/display_server/rosen/modules/composer/vsync/test/ft_build/vsync_generator_test.cpp b/display_server/rosen/modules/composer/vsync/test/ft_build/vsync_generator_test.cpp new file mode 100644 index 0000000..f23ad49 --- /dev/null +++ b/display_server/rosen/modules/composer/vsync/test/ft_build/vsync_generator_test.cpp @@ -0,0 +1,183 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "vsync_generator.h" + +#include + +namespace OHOS { +namespace Rosen { +class VSyncGeneratorTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + static inline sptr vsyncGenerator_; +}; + +void VSyncGeneratorTest::SetUpTestCase() +{ + vsyncGenerator_ = CreateVSyncGenerator(); +} + +void VSyncGeneratorTest::TearDownTestCase() +{ + vsyncGenerator_ = nullptr; + DestroyVSyncGenerator(); +} + +class VSyncGeneratorTestCallback : public VSyncGenerator::Callback { +public: + void OnVSyncEvent(int64_t) override; +}; + +void VSyncGeneratorTestCallback::OnVSyncEvent(int64_t time) +{ +} + +namespace { +/* +* Function: UpdateMode001 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call UpdateMode + */ +TEST_F(VSyncGeneratorTest, UpdateMode001) +{ + ASSERT_EQ(VSyncGeneratorTest::vsyncGenerator_->UpdateMode(2, 0, 0), VSYNC_ERROR_OK); +} + +/* +* Function: UpdateMode002 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call UpdateMode + */ +TEST_F(VSyncGeneratorTest, UpdateMode002) +{ + ASSERT_EQ(VSyncGeneratorTest::vsyncGenerator_->UpdateMode(2, 0, -1), VSYNC_ERROR_INVALID_ARGUMENTS); +} + +/* +* Function: AddListener001 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call AddListener + */ +TEST_F(VSyncGeneratorTest, AddListener001) +{ + sptr callback1 = new VSyncGeneratorTestCallback; + ASSERT_EQ(VSyncGeneratorTest::vsyncGenerator_->AddListener(2, callback1), VSYNC_ERROR_OK); +} + +/* +* Function: AddListener002 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call AddListener + */ +TEST_F(VSyncGeneratorTest, AddListener002) +{ + ASSERT_EQ(VSyncGeneratorTest::vsyncGenerator_->AddListener(2, nullptr), VSYNC_ERROR_INVALID_ARGUMENTS); +} + +/* +* Function: RemoveListener001 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RemoveListener + */ +TEST_F(VSyncGeneratorTest, RemoveListener001) +{ + sptr callback2 = new VSyncGeneratorTestCallback; + VSyncGeneratorTest::vsyncGenerator_->AddListener(2, callback2); + ASSERT_EQ(VSyncGeneratorTest::vsyncGenerator_->RemoveListener(callback2), VSYNC_ERROR_OK); +} + +/* +* Function: RemoveListener002 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RemoveListener + */ +TEST_F(VSyncGeneratorTest, RemoveListener002) +{ + ASSERT_EQ(VSyncGeneratorTest::vsyncGenerator_->RemoveListener(nullptr), VSYNC_ERROR_INVALID_ARGUMENTS); +} + +/* +* Function: RemoveListener003 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RemoveListener + */ +TEST_F(VSyncGeneratorTest, RemoveListener003) +{ + sptr callback3 = new VSyncGeneratorTestCallback; + VSyncGeneratorTest::vsyncGenerator_->AddListener(2, callback3); + sptr callback4 = new VSyncGeneratorTestCallback; + ASSERT_EQ(VSyncGeneratorTest::vsyncGenerator_->RemoveListener(callback4), VSYNC_ERROR_INVALID_ARGUMENTS); +} + +/* +* Function: ChangePhaseOffset001 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call ChangePhaseOffset + */ +TEST_F(VSyncGeneratorTest, ChangePhaseOffset001) +{ + sptr callback5 = new VSyncGeneratorTestCallback; + VSyncGeneratorTest::vsyncGenerator_->AddListener(2, callback5); + ASSERT_EQ(VSyncGeneratorTest::vsyncGenerator_->ChangePhaseOffset(callback5, 1), VSYNC_ERROR_OK); +} + +/* +* Function: ChangePhaseOffset002 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call ChangePhaseOffset + */ +TEST_F(VSyncGeneratorTest, ChangePhaseOffset002) +{ + ASSERT_EQ(VSyncGeneratorTest::vsyncGenerator_->ChangePhaseOffset(nullptr, 1), VSYNC_ERROR_INVALID_ARGUMENTS); +} + +/* +* Function: ChangePhaseOffset003 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call ChangePhaseOffset + */ +TEST_F(VSyncGeneratorTest, ChangePhaseOffset003) +{ + sptr callback6 = new VSyncGeneratorTestCallback; + VSyncGeneratorTest::vsyncGenerator_->AddListener(2, callback6); + sptr callback7 = new VSyncGeneratorTestCallback; + ASSERT_EQ(VSyncGeneratorTest::vsyncGenerator_->ChangePhaseOffset(callback7, 1), VSYNC_ERROR_INVALID_OPERATING); +} +} // namespace +} // namespace Rosen +} // namespace OHOS diff --git a/display_server/rosen/modules/composer/vsync/test/ft_build/vsync_receiver_test.cpp b/display_server/rosen/modules/composer/vsync/test/ft_build/vsync_receiver_test.cpp new file mode 100644 index 0000000..e4df3e4 --- /dev/null +++ b/display_server/rosen/modules/composer/vsync/test/ft_build/vsync_receiver_test.cpp @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "vsync_receiver.h" +#include "vsync_distributor.h" +#include "vsync_controller.h" + +namespace OHOS { +namespace Rosen { +static void OnVSync(int64_t now, void* data) {} +class vsyncReceiverTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + static inline sptr vsyncController = nullptr; + static inline sptr vsyncDistributor = nullptr; + static inline sptr vsyncGenerator = nullptr; + static inline sptr conn = nullptr; + static inline sptr vsyncReceiver = nullptr; +}; + +void vsyncReceiverTest::SetUpTestCase() +{ + vsyncGenerator = CreateVSyncGenerator(); + vsyncController = new VSyncController(vsyncGenerator, 0); + vsyncDistributor = new VSyncDistributor(vsyncController, "vsyncReceiverTest"); + conn = new VSyncConnection(vsyncDistributor, "vsyncReceiverTest"); + vsyncReceiver = new VSyncReceiver(conn); +} + +void vsyncReceiverTest::TearDownTestCase() +{ + vsyncReceiver = nullptr; + vsyncController = nullptr; + vsyncGenerator = nullptr; + vsyncDistributor = nullptr; + conn = nullptr; + DestroyVSyncGenerator(); +} + +namespace { +/* +* Function: Init001 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call Init + */ +TEST_F(vsyncReceiverTest, Init001) +{ + ASSERT_EQ(vsyncReceiverTest::vsyncReceiver->Init(), VSYNC_ERROR_OK); +} + +/* +* Function: RequestNextVSync001 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call RequestNextVSync + */ +TEST_F(vsyncReceiverTest, RequestNextVSync001) +{ + VSyncReceiver::FrameCallback fcb = { + .userData_ = this, + .callback_ = OnVSync, + }; + vsyncDistributor->AddConnection(conn); + ASSERT_EQ(vsyncReceiverTest::vsyncReceiver->RequestNextVSync(fcb), VSYNC_ERROR_OK); + vsyncDistributor->RemoveConnection(conn); +} + +/* +* Function: SetVSyncRate001 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetVSyncRate + */ +TEST_F(vsyncReceiverTest, SetVSyncRate001) +{ + VSyncReceiver::FrameCallback fcb = { + .userData_ = this, + .callback_ = OnVSync, + }; + vsyncDistributor->AddConnection(conn); + ASSERT_EQ(vsyncReceiverTest::vsyncReceiver->SetVSyncRate(fcb, 0), VSYNC_ERROR_INVALID_ARGUMENTS); + vsyncDistributor->RemoveConnection(conn); +} + +/* +* Function: SetVSyncRate002 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetVSyncRate + */ +TEST_F(vsyncReceiverTest, SetVSyncRate002) +{ + VSyncReceiver::FrameCallback fcb = { + .userData_ = this, + .callback_ = OnVSync, + }; + vsyncDistributor->AddConnection(conn); + ASSERT_EQ(vsyncReceiverTest::vsyncReceiver->SetVSyncRate(fcb, 1), VSYNC_ERROR_OK); + vsyncDistributor->RemoveConnection(conn); +} +} // namespace +} // namespace Rosen +} // namespace OHOS diff --git a/display_server/rosen/modules/composer/vsync/test/ft_build/vsync_sampler_test.cpp b/display_server/rosen/modules/composer/vsync/test/ft_build/vsync_sampler_test.cpp new file mode 100644 index 0000000..02f550d --- /dev/null +++ b/display_server/rosen/modules/composer/vsync/test/ft_build/vsync_sampler_test.cpp @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "vsync_sampler.h" + +#include + +namespace OHOS { +namespace Rosen { +namespace { +constexpr int32_t SAMPLER_NUMBER = 6; +} +class VSyncSamplerTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + static inline sptr vsyncSampler = nullptr; +}; + +void VSyncSamplerTest::SetUpTestCase() +{ + vsyncSampler = CreateVSyncSampler(); +} + +void VSyncSamplerTest::TearDownTestCase() {} + +namespace { +/* +* Function: AddSample001 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call AddSample + */ +TEST_F(VSyncSamplerTest, AddSample001) +{ + ASSERT_EQ(VSyncSamplerTest::vsyncSampler->AddSample(0), true); + VSyncSamplerTest::vsyncSampler->Reset(); +} + +/* +* Function: AddSample002 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call AddSample + */ +TEST_F(VSyncSamplerTest, AddSample002) +{ + bool ret = true; + for (int i = 0; i < SAMPLER_NUMBER; i++) { + ret = VSyncSamplerTest::vsyncSampler->AddSample(i); + } + ASSERT_EQ(ret, false); + VSyncSamplerTest::vsyncSampler->Reset(); +} + +/* +* Function: BeginSample001 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call BeginSample + */ +TEST_F(VSyncSamplerTest, BeginSample001) +{ + bool ret = true; + for (int i = 0; i < SAMPLER_NUMBER; i++) { + ret = VSyncSamplerTest::vsyncSampler->AddSample(i); + } + ASSERT_EQ(ret, false); + + VSyncSamplerTest::vsyncSampler->BeginSample(); + ASSERT_EQ(VSyncSamplerTest::vsyncSampler->AddSample(6), true); + VSyncSamplerTest::vsyncSampler->Reset(); +} + +/* +* Function: GetPeriod001 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetPeriod + */ +TEST_F(VSyncSamplerTest, GetPeriod001) +{ + ASSERT_EQ(VSyncSamplerTest::vsyncSampler->GetPeriod(), 0); +} + +/* +* Function: GetPeriod002 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetPeriod + */ +TEST_F(VSyncSamplerTest, GetPeriod002) +{ + bool ret = true; + for (int i = 0; i < SAMPLER_NUMBER; i++) { + ret = VSyncSamplerTest::vsyncSampler->AddSample(i); + } + ASSERT_EQ(ret, false); + ASSERT_EQ(VSyncSamplerTest::vsyncSampler->GetPeriod(), 1); + VSyncSamplerTest::vsyncSampler->Reset(); +} + +/* +* Function: GetPhase001 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetPhase + */ +TEST_F(VSyncSamplerTest, GetPhase001) +{ + VSyncSamplerTest::vsyncSampler->AddSample(0); + ASSERT_EQ(VSyncSamplerTest::vsyncSampler->GetPhase(), 0); + VSyncSamplerTest::vsyncSampler->Reset(); +} + +/* +* Function: GetPhase002 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetPhase + */ +TEST_F(VSyncSamplerTest, GetPhase002) +{ + bool ret = true; + for (int i = 0; i < SAMPLER_NUMBER; i++) { + ret = VSyncSamplerTest::vsyncSampler->AddSample(i); + } + ASSERT_EQ(ret, false); + ASSERT_EQ(VSyncSamplerTest::vsyncSampler->GetPhase(), 0); + VSyncSamplerTest::vsyncSampler->Reset(); +} + +/* +* Function: GetRefrenceTime001 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetRefrenceTime + */ +TEST_F(VSyncSamplerTest, GetRefrenceTime001) +{ + ASSERT_EQ(VSyncSamplerTest::vsyncSampler->GetRefrenceTime(), 0); +} + +/* +* Function: GetRefrenceTime002 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetRefrenceTime + */ +TEST_F(VSyncSamplerTest, GetRefrenceTime002) +{ + bool ret = true; + for (int i = 1; i < SAMPLER_NUMBER + 1; i++) { + ret = VSyncSamplerTest::vsyncSampler->AddSample(i); + } + ASSERT_EQ(ret, false); + ASSERT_EQ(VSyncSamplerTest::vsyncSampler->GetRefrenceTime(), 1); +} + +/* +* Function: AddPresentFenceTime001 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call AddPresentFenceTime + */ +TEST_F(VSyncSamplerTest, AddPresentFenceTime001) +{ + ASSERT_EQ(VSyncSamplerTest::vsyncSampler->AddPresentFenceTime(6), false); + VSyncSamplerTest::vsyncSampler->Reset(); +} + +/* +* Function: AddPresentFenceTime002 +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call AddPresentFenceTime + */ +TEST_F(VSyncSamplerTest, AddPresentFenceTime002) +{ + bool ret = true; + for (int i = 1; i < SAMPLER_NUMBER + 1; i++) { + ret = VSyncSamplerTest::vsyncSampler->AddSample(i); + } + ASSERT_EQ(ret, false); + ASSERT_EQ(VSyncSamplerTest::vsyncSampler->AddPresentFenceTime(SAMPLER_NUMBER + 1), false); + VSyncSamplerTest::vsyncSampler->Reset(); +} +} // namespace +} // namespace Rosen +} // namespace OHOS diff --git a/display_server/rosen/modules/render_service/ft_build/BUILD.gn b/display_server/rosen/modules/render_service/ft_build/BUILD.gn index 4f51d6e..f885efd 100644 --- a/display_server/rosen/modules/render_service/ft_build/BUILD.gn +++ b/display_server/rosen/modules/render_service/ft_build/BUILD.gn @@ -97,5 +97,6 @@ ft_shared_library("librender_service") { "//build/gn/configs/system_libs:image", ] - libs = ["png", "EGL", "GLESv2" ] + libs = ["png" ] + libs += libgl } diff --git a/display_server/rosen/modules/render_service_base/src/platform/fangtian/BUILD.gn b/display_server/rosen/modules/render_service_base/src/platform/fangtian/BUILD.gn index 77b5c19..91aa761 100644 --- a/display_server/rosen/modules/render_service_base/src/platform/fangtian/BUILD.gn +++ b/display_server/rosen/modules/render_service_base/src/platform/fangtian/BUILD.gn @@ -94,7 +94,8 @@ ft_source_set("rosen_fangtian_sources") { "$rosen_root/modules/2d_graphics/src", "$rosen_root/modules/render_service_client/core", ] - libs = [ "crypto", "EGL", "GLESv2" ] + libs = [ "crypto" ] + libs += libgl } deps = [ diff --git a/display_server/rosen/modules/render_service_client/test/render_service_client_rs_demo.cpp b/display_server/rosen/modules/render_service_client/test/render_service_client_rs_demo.cpp index c7189aa..103a7d0 100644 --- a/display_server/rosen/modules/render_service_client/test/render_service_client_rs_demo.cpp +++ b/display_server/rosen/modules/render_service_client/test/render_service_client_rs_demo.cpp @@ -16,21 +16,26 @@ #include #include +#include "include/core/SkCanvas.h" +#include "include/core/SkImageInfo.h" +// RS Base #include "command/rs_base_node_command.h" #include "command/rs_display_node_command.h" #include "command/rs_surface_node_command.h" #include "common/rs_common_def.h" -#include "include/core/SkCanvas.h" -#include "include/core/SkImageInfo.h" #include "pipeline/rs_render_result.h" #include "pipeline/rs_render_thread.h" +// RS client #include "ui/rs_canvas_node.h" #include "ui/rs_surface_extractor.h" #include "ui/rs_ui_director.h" -#include "transaction/rs_interfaces.h" #include "ui/rs_display_node.h" #include "ui/rs_surface_node.h" +#include "transaction/rs_interfaces.h" +// 2d_graphics +#ifdef ACE_ENABLE_GPU #include "render_context/render_context.h" +#endif using namespace OHOS; using namespace OHOS::Rosen; @@ -282,18 +287,18 @@ public: isGPU_ = false; #endif - id = DmsMock::GetInstance().GetDefaultDisplayId(); - std::cout << "RS default screen id is " << id << ".\n"; - auto activeModeInfo = DmsMock::GetInstance().GetDisplayActiveMode(id); + id_ = DmsMock::GetInstance().GetDefaultDisplayId(); + std::cout << "RS default screen id is " << id_ << ".\n"; + auto activeModeInfo = DmsMock::GetInstance().GetDisplayActiveMode(id_); if (activeModeInfo) { screenWidth_ = activeModeInfo->GetScreenWidth(); screenheight_ = activeModeInfo->GetScreenHeight(); screenRefreshRate_ = static_cast(activeModeInfo->GetScreenRefreshRate()); - std::cout << "Display " << id << " active mode info:\n"; + std::cout << "Display " << id_ << " active mode info:\n"; std::cout << "Width: " << screenWidth_ << ", Height: " << screenheight_; std::cout << ", RefreshRate: " << screenRefreshRate_ << "Hz.\n"; } else { - std::cout << "Display " << id << " has no active mode!\n"; + std::cout << "Display " << id_ << " has no active mode!\n"; } RenderContextInit(); std::cout << "Render service Client rs Demo.cpp testInit end\n"; @@ -334,7 +339,7 @@ public: RSDisplayNodeConfig config; RSDisplayNode::SharedPtr displayNode = RSDisplayNode::Create(config); - displayNode->SetScreenId(id); + displayNode->SetScreenId(id_); displayNode->SetBounds(0, 0, screenWidth_, screenheight_); displayNode->AddChild(surfaceNode1, -1); displayNode->AddChild(surfaceNode2, -1); @@ -374,7 +379,7 @@ private: int screenWidth_ = 0; int screenheight_ = 0; int screenRefreshRate_ = 0; - DisplayId id; + DisplayId id_; }; // class RSDemoTestCase } // namespace OHOS::Rosen diff --git a/display_server/utils/ft_build/BUILD.gn b/display_server/utils/ft_build/BUILD.gn index 7207480..5652984 100644 --- a/display_server/utils/ft_build/BUILD.gn +++ b/display_server/utils/ft_build/BUILD.gn @@ -36,6 +36,10 @@ group("sandbox_utils") { public_deps = [ "${utils_dir}/sandbox/ft_build:sandbox_utils" ] } +group("test_header") { + public_deps = [ "${utils_dir}/test_header/ft_build:test_header" ] +} + config("libgraphic_utils_public_config") { include_dirs = [ "//foundation/graphic/graphic_2d/interfaces/inner_api/common" ] @@ -50,5 +54,6 @@ ft_shared_library("libgraphic_utils") { ":socketpair", ":sync_fence", ":sandbox_utils", + ":test_header", ] } diff --git a/display_server/utils/socketpair/ft_build/BUILD.gn b/display_server/utils/socketpair/ft_build/BUILD.gn index f05a0aa..6470785 100644 --- a/display_server/utils/socketpair/ft_build/BUILD.gn +++ b/display_server/utils/socketpair/ft_build/BUILD.gn @@ -36,7 +36,7 @@ ft_shared_library("socketpair") { public_configs = [ ":socketpair_public_config" ] - deps = [ + public_deps = [ "//display_server/utils/scoped_bytrace/ft_build:scoped_bytrace", "//build/gn/configs/system_libs:hilog", diff --git a/display_server/utils/test_header/ft_build/BUILD.gn b/display_server/utils/test_header/ft_build/BUILD.gn new file mode 100644 index 0000000..db9cfe9 --- /dev/null +++ b/display_server/utils/test_header/ft_build/BUILD.gn @@ -0,0 +1,23 @@ +# Copyright (c) 2023 Huawei Technologies Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/gn/fangtian.gni") + +config("test_header_public_config") { + include_dirs = [ "export" ] +} + +group("test_header") { + public_configs = [ ":test_header_public_config" ] + public_deps = [ "//build/gn/configs/system_libs:hilog" ] +} -- Gitee From 39eacc6a6afb588cad24d140ae8f505153787a37 Mon Sep 17 00:00:00 2001 From: fseeeye Date: Tue, 18 Jul 2023 21:34:34 +0800 Subject: [PATCH 2/4] feat(test): add UT of rs --- build/gn/BUILD.gn | 5 +- .../frameworks/surface/test/ft_build/BUILD.gn | 34 + .../test/ft_build/native_buffer_test.cpp | 378 ++ .../test/ft_build/native_image_test.cpp | 591 ++++ .../test/ft_build/native_window_test.cpp | 851 +++++ .../frameworks/surfaceimage/ft_build/BUILD.gn | 62 + display_server/ft_build/BUILD.gn | 5 + .../composer/native_vsync/ft_build/BUILD.gn | 53 + .../composer/vsync/test/ft_build/BUILD.gn | 11 +- .../vsync/test/ft_build/native_vsync_test.cpp | 136 + .../render_service_base/ft_build/BUILD.gn | 6 +- .../test/ft_build/BUILD.gn | 10 + .../test/unittest/ft_build/BUILD.gn | 64 + .../unittest/ft_build/rs_interfaces_test.cpp | 934 +++++ .../render_service_base/ft_build/BUILD.gn | 54 + .../transaction/rs_transaction_proxy_test.cpp | 99 + .../render_service_client/ft_build/BUILD.gn | 62 + .../transaction/rs_transaction_test.cpp | 46 + .../ft_build/ui/rs_display_node_test.cpp | 172 + .../ft_build/ui/rs_node_test.cpp | 3137 +++++++++++++++++ .../ft_build/ui/rs_surface_extractor_test.cpp | 53 + .../ft_build/ui/rs_surface_node_test.cpp | 1090 ++++++ 22 files changed, 7847 insertions(+), 6 deletions(-) create mode 100644 display_server/frameworks/surface/test/ft_build/native_buffer_test.cpp create mode 100644 display_server/frameworks/surface/test/ft_build/native_image_test.cpp create mode 100644 display_server/frameworks/surface/test/ft_build/native_window_test.cpp create mode 100644 display_server/frameworks/surfaceimage/ft_build/BUILD.gn create mode 100644 display_server/rosen/modules/composer/native_vsync/ft_build/BUILD.gn create mode 100644 display_server/rosen/modules/composer/vsync/test/ft_build/native_vsync_test.cpp create mode 100644 display_server/rosen/modules/render_service_client/test/unittest/ft_build/BUILD.gn create mode 100644 display_server/rosen/modules/render_service_client/test/unittest/ft_build/rs_interfaces_test.cpp create mode 100644 display_server/rosen/test/render_service/render_service_base/ft_build/BUILD.gn create mode 100644 display_server/rosen/test/render_service/render_service_base/ft_build/transaction/rs_transaction_proxy_test.cpp create mode 100644 display_server/rosen/test/render_service/render_service_client/ft_build/BUILD.gn create mode 100644 display_server/rosen/test/render_service/render_service_client/ft_build/transaction/rs_transaction_test.cpp create mode 100644 display_server/rosen/test/render_service/render_service_client/ft_build/ui/rs_display_node_test.cpp create mode 100644 display_server/rosen/test/render_service/render_service_client/ft_build/ui/rs_node_test.cpp create mode 100644 display_server/rosen/test/render_service/render_service_client/ft_build/ui/rs_surface_extractor_test.cpp create mode 100644 display_server/rosen/test/render_service/render_service_client/ft_build/ui/rs_surface_node_test.cpp diff --git a/build/gn/BUILD.gn b/build/gn/BUILD.gn index 3b446a5..bae243d 100644 --- a/build/gn/BUILD.gn +++ b/build/gn/BUILD.gn @@ -47,8 +47,9 @@ group("ft_test") { "//display_server/frameworks/surface/test/ft_build:unittest", "//display_server/frameworks/surface/test/ft_build:sample", # RS - "//display_server/rosen/modules/render_service_client/test/ft_build:render_service_client_rs_demo", - "//display_server/rosen/modules/render_service_client/test/ft_build:render_service_client_gravity_demo", + "//display_server/rosen/test/render_service/render_service_base/ft_build:unittest", + "//display_server/rosen/test/render_service/render_service_client/ft_build:unittest", + "//display_server/rosen/modules/render_service_client/test/ft_build:test", "//window_manager/test/ft_build:wm_test", ] diff --git a/display_server/frameworks/surface/test/ft_build/BUILD.gn b/display_server/frameworks/surface/test/ft_build/BUILD.gn index d7e2570..d076213 100644 --- a/display_server/frameworks/surface/test/ft_build/BUILD.gn +++ b/display_server/frameworks/surface/test/ft_build/BUILD.gn @@ -37,6 +37,10 @@ group("unittest") { ":producer_surface_test", ":surface_buffer_impl_test", ":surface_utils_test", + ":native_window_test", + # TODO: enable native_image + # ":native_image_test", + # ":native_buffer_test", ] } @@ -96,6 +100,8 @@ ft_static_library("surface_test_common") { "//build/gn/configs/system_libs:gtest", "//display_server/ft_build:libsurface", + # TODO: enable native_image + # "//display_server/ft_build:libnative_image", "//display_server/utils/ft_build:buffer_handle", "//display_server/utils/ft_build:libgraphic_utils", "//display_server/utils/ft_build:sync_fence", @@ -192,3 +198,31 @@ ft_executable("surface_utils_test") { deps = [ ":surface_test_common" ] } + +ft_executable("native_window_test") { + testonly = true + + sources = [ "native_window_test.cpp" ] + + deps = [ ":surface_test_common" ] +} + +# TODO: enable native_image +# ft_executable("native_image_test") { +# testonly = true + +# sources = [] +# if (ds_enable_gpu == true) { +# sources = [ "native_image_test.cpp" ] +# } + +# deps = [ ":surface_test_common" ] +# } + +# ft_executable("native_buffer_test") { +# testonly = true + +# sources = [ "native_buffer_test.cpp" ] + +# deps = [ ":surface_test_common" ] +# } diff --git a/display_server/frameworks/surface/test/ft_build/native_buffer_test.cpp b/display_server/frameworks/surface/test/ft_build/native_buffer_test.cpp new file mode 100644 index 0000000..7fcc596 --- /dev/null +++ b/display_server/frameworks/surface/test/ft_build/native_buffer_test.cpp @@ -0,0 +1,378 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include "native_buffer.h" +#include "native_buffer_inner.h" +#include "native_window.h" +#include "surface_type.h" +#include "graphic_common_c.h" + +namespace OHOS::Rosen { +class BufferConsumerListener : public IBufferConsumerListener { +public: + void OnBufferAvailable() override + { + } +}; + +class NativeBufferTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + static inline OH_NativeBuffer_Config config = { + .width = 0x100, + .height = 0x100, + .format = GRAPHIC_PIXEL_FMT_RGBA_8888, +#ifdef RS_ENABLE_GL + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_MEM_DMA, +#else + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE, +#endif + }; + static inline OH_NativeBuffer_Config checkConfig = {}; + static inline OH_NativeBuffer* buffer = nullptr; +}; + +void NativeBufferTest::SetUpTestCase() +{ + buffer = nullptr; +} + +void NativeBufferTest::TearDownTestCase() +{ + buffer = nullptr; +} + +/* +* Function: OH_NativeBuffer_Alloc +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeBuffer_Alloc by abnormal input +* 2. check ret +*/ +TEST_F(NativeBufferTest, OHNativeBufferAlloc001) +{ + buffer = OH_NativeBuffer_Alloc(nullptr); + ASSERT_EQ(buffer, nullptr); +} + +/* +* Function: OH_NativeBuffer_Alloc +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeBuffer_Alloc +* 2. check ret +*/ +TEST_F(NativeBufferTest, OHNativeBufferAlloc002) +{ + buffer = OH_NativeBuffer_Alloc(&config); + ASSERT_NE(buffer, nullptr); +} + +/* +* Function: OH_NativeBuffer_GetSeqNum +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeBuffer_GetSeqNum by abnormal input +* 2. check ret +*/ +TEST_F(NativeBufferTest, OHNativeBufferGetSeqNum001) +{ + uint32_t id = OH_NativeBuffer_GetSeqNum(nullptr); + ASSERT_EQ(id, GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: OH_NativeBuffer_GetSeqNum +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeBuffer_GetSeqNum +* 2. check ret +*/ +TEST_F(NativeBufferTest, OHNativeBufferGetSeqNum002) +{ + uint32_t id = OH_NativeBuffer_GetSeqNum(buffer); + ASSERT_NE(id, GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: OH_NativeBuffer_GetConfig +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeBuffer_GetConfig +* 2. check ret + */ +TEST_F(NativeBufferTest, OHNativeBufferGetConfig001) +{ + OH_NativeBuffer_GetConfig(buffer, &checkConfig); + ASSERT_NE(&checkConfig, nullptr); +} + +/* +* Function: OH_NativeBuffer_GetConfig +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeBuffer_GetConfig by abnormal input +* 2. check ret +*/ +TEST_F(NativeBufferTest, OHNativeBufferGetConfig002) +{ + checkConfig.width = 0x0; + checkConfig.height = 0x0; + checkConfig.format = 0x0; + checkConfig.usage = 0x0; + OH_NativeBuffer_GetConfig(nullptr, &checkConfig); + ASSERT_EQ(checkConfig.width, 0x0); + ASSERT_EQ(checkConfig.height, 0x0); + ASSERT_EQ(checkConfig.format, 0x0); + ASSERT_EQ(checkConfig.usage, 0x0); +} + +/* +* Function: OH_NativeBuffer_Reference +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeBuffer_Reference by abnormal input +* 2. check ret +*/ +TEST_F(NativeBufferTest, OHNativeBufferReference001) +{ + int32_t ret = OH_NativeBuffer_Reference(nullptr); + ASSERT_NE(ret, GSERROR_OK); +} + +/* +* Function: OH_NativeBuffer_Reference +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeBuffer_Reference +* 2. check ret +*/ +TEST_F(NativeBufferTest, OHNativeBufferReference002) +{ + int32_t ret = OH_NativeBuffer_Reference(buffer); + ASSERT_EQ(ret, GSERROR_OK); +} + +/* +* Function: OH_NativeBuffer_Unreference +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeBuffer_Unreference by abnormal input +* 2. check ret +*/ +TEST_F(NativeBufferTest, OHNativeBufferUnreference001) +{ + int32_t ret = OH_NativeBuffer_Unreference(nullptr); + ASSERT_NE(ret, GSERROR_OK); +} + +/* +* Function: OH_NativeBuffer_Unreference +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeBuffer_Unreference +* 2. check ret +*/ +TEST_F(NativeBufferTest, OHNativeBufferUnreference002) +{ + int32_t ret = OH_NativeBuffer_Unreference(buffer); + ASSERT_EQ(ret, GSERROR_OK); +} + +/* +* Function: OH_NativeBuffer_GetSeqNum and OH_NativeBuffer_Unreference +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeBuffer_GetSeqNum +* 2. call OH_NativeBuffer_Unreference +* 3. OH_NativeBuffer_Alloc again +* 4. check OH_NativeBuffer_GetSeqNum = oldSeq + 1 +*/ +TEST_F(NativeBufferTest, OHNativeBufferGetSeqNum003) +{ + uint32_t oldSeq = OH_NativeBuffer_GetSeqNum(buffer); + int32_t ret = OH_NativeBuffer_Unreference(buffer); + ASSERT_EQ(ret, GSERROR_OK); + buffer = OH_NativeBuffer_Alloc(&config); + ASSERT_EQ(oldSeq + 1, OH_NativeBuffer_GetSeqNum(buffer)); +} + +/* +* Function: OH_NativeBuffer_GetBufferHandle +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeBuffer_GetBufferHandle +* 2. check result +*/ +TEST_F(NativeBufferTest, OHNativeBufferGetBufferHandle001) +{ + const BufferHandle* handle = OH_NativeBuffer_GetBufferHandle(buffer); + ASSERT_NE(handle, nullptr); +} + +/* +* Function: OH_NativeBuffer_GetNativeBufferConfig +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeBuffer_GetNativeBufferConfig +* 2. check result +*/ +TEST_F(NativeBufferTest, OHNativeBufferGetNativeBufferConfig001) +{ + OH_NativeBuffer_Config testConfig = {}; + OH_NativeBuffer_GetNativeBufferConfig(buffer, &testConfig); + ASSERT_EQ(testConfig.width, config.width); + ASSERT_EQ(testConfig.height, config.height); + ASSERT_EQ(testConfig.format, config.format); + ASSERT_EQ(testConfig.usage, config.usage); +} + +/* +* Function: OH_NativeBuffer_Map +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeBuffer_Map by abnormal input +* 2. check ret +*/ +TEST_F(NativeBufferTest, OHNativeBufferMap001) +{ + void *virAddr = nullptr; + int32_t ret = OH_NativeBuffer_Map(nullptr, &virAddr); + ASSERT_NE(ret, GSERROR_OK); +} + +/* +* Function: OH_NativeBuffer_Map +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeBuffer_Map +* 2. check ret +*/ +TEST_F(NativeBufferTest, OHNativeBufferMap002) +{ + void *virAddr = nullptr; + int32_t ret = OH_NativeBuffer_Map(buffer, &virAddr); + ASSERT_EQ(ret, GSERROR_OK); + ASSERT_NE(virAddr, nullptr); +} + +/* +* Function: OH_NativeBuffer_Unmap +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeBuffer_Unmap by abnormal input +* 2. check ret +*/ +TEST_F(NativeBufferTest, OHNativeBufferUnmap001) +{ + int32_t ret = OH_NativeBuffer_Unmap(nullptr); + ASSERT_NE(ret, GSERROR_OK); +} + +/* +* Function: OH_NativeBuffer_Unmap and OH_NativeBuffer_Unreference +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeBuffer_Unmap +* 2. check ret +* 3. call OH_NativeBuffer_Unreference +*/ +TEST_F(NativeBufferTest, OHNativeBufferUnmap002) +{ + int32_t ret = OH_NativeBuffer_Unmap(buffer); + ASSERT_EQ(ret, GSERROR_OK); + ret = OH_NativeBuffer_Unreference(buffer); + ASSERT_EQ(ret, GSERROR_OK); +} + +/* +* Function: OH_NativeBufferFromNativeWindowBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeBufferFromNativeWindowBuffer by abnormal input +* 2. check ret +*/ +TEST_F(NativeBufferTest, NativeBufferFromNativeWindowBuffer001) +{ + OH_NativeBuffer* nativeBuffer = OH_NativeBufferFromNativeWindowBuffer(nullptr); + ASSERT_EQ(nativeBuffer, nullptr); +} + +/* +* Function: OH_NativeBufferFromNativeWindowBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeBufferFromNativeWindowBuffer +* 2. check ret +*/ +TEST_F(NativeBufferTest, NativeBufferFromNativeWindowBuffer002) +{ + sptr cSurface = Surface::CreateSurfaceAsConsumer(); + sptr listener = new BufferConsumerListener(); + cSurface->RegisterConsumerListener(listener); + sptr producer = cSurface->GetProducer(); + sptr pSurface = Surface::CreateSurfaceAsProducer(producer); + int32_t fence; + sptr sBuffer = nullptr; + BufferRequestConfig requestConfig = { + .width = 0x100, // small + .height = 0x100, // small + .strideAlignment = 0x8, + .format = GRAPHIC_PIXEL_FMT_RGBA_8888, +#ifdef RS_ENABLE_GL + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_MEM_DMA, +#else + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE, +#endif + .timeout = 0, + }; + pSurface->RequestBuffer(sBuffer, fence, requestConfig); + NativeWindow* nativeWindow = OH_NativeWindow_CreateNativeWindow(&pSurface); + ASSERT_NE(nativeWindow, nullptr); + NativeWindowBuffer* nativeWindowBuffer = OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer(&sBuffer); + ASSERT_NE(nativeWindowBuffer, nullptr); + OH_NativeBuffer* nativeBuffer = OH_NativeBufferFromNativeWindowBuffer(nativeWindowBuffer); + ASSERT_NE(nativeBuffer, nullptr); + + sBuffer = nullptr; + cSurface = nullptr; + producer = nullptr; + pSurface = nullptr; + nativeWindow = nullptr; + nativeWindowBuffer = nullptr; +} +} \ No newline at end of file diff --git a/display_server/frameworks/surface/test/ft_build/native_image_test.cpp b/display_server/frameworks/surface/test/ft_build/native_image_test.cpp new file mode 100644 index 0000000..d4464d6 --- /dev/null +++ b/display_server/frameworks/surface/test/ft_build/native_image_test.cpp @@ -0,0 +1,591 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include "graphic_common_c.h" +#include "surface_type.h" +#include "window.h" +#include "GLES/gl.h" +#include "buffer_log.h" +using namespace std; + +namespace OHOS::Rosen { +using GetPlatformDisplayExt = PFNEGLGETPLATFORMDISPLAYEXTPROC; +constexpr const char* EGL_EXT_PLATFORM_WAYLAND = "EGL_EXT_platform_wayland"; +constexpr const char* EGL_KHR_PLATFORM_WAYLAND = "EGL_KHR_platform_wayland"; +constexpr int32_t EGL_CONTEXT_CLIENT_VERSION_NUM = 2; +constexpr char CHARACTER_WHITESPACE = ' '; +constexpr const char* CHARACTER_STRING_WHITESPACE = " "; +constexpr const char* EGL_GET_PLATFORM_DISPLAY_EXT = "eglGetPlatformDisplayEXT"; + +struct TEST_IMAGE { + int a; + bool b; +}; + +static bool CheckEglExtension(const char* extensions, const char* extension) +{ + size_t extlen = strlen(extension); + const char* end = extensions + strlen(extensions); + + while (extensions < end) { + size_t n = 0; + /* Skip whitespaces, if any */ + if (*extensions == CHARACTER_WHITESPACE) { + extensions++; + continue; + } + n = strcspn(extensions, CHARACTER_STRING_WHITESPACE); + /* Compare strings */ + if (n == extlen && strncmp(extension, extensions, n) == 0) { + return true; /* Found */ + } + extensions += n; + } + /* Not found */ + return false; +} + +static EGLDisplay GetPlatformEglDisplay(EGLenum platform, void* native_display, const EGLint* attrib_list) +{ + static GetPlatformDisplayExt eglGetPlatformDisplayExt = NULL; + + if (!eglGetPlatformDisplayExt) { + const char* extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); + if (extensions && + (CheckEglExtension(extensions, EGL_EXT_PLATFORM_WAYLAND) || + CheckEglExtension(extensions, EGL_KHR_PLATFORM_WAYLAND))) { + eglGetPlatformDisplayExt = (GetPlatformDisplayExt)eglGetProcAddress(EGL_GET_PLATFORM_DISPLAY_EXT); + } + } + + if (eglGetPlatformDisplayExt) { + return eglGetPlatformDisplayExt(platform, native_display, attrib_list); + } + + return eglGetDisplay((EGLNativeDisplayType)native_display); +} + +class NativeImageTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + static void InitEglContext(); + static void Deinit(); + + static inline OH_NativeImage* image = nullptr; + static inline OHNativeWindow* nativeWindow = nullptr; + static inline GLuint textureId = 0; + static inline GLuint textureId2 = 0; + static inline EGLDisplay eglDisplay_ = EGL_NO_DISPLAY; + static inline EGLContext eglContext_ = EGL_NO_CONTEXT; + static inline EGLConfig config_;; +}; + +void NativeImageTest::SetUpTestCase() +{ + image = nullptr; + nativeWindow = nullptr; + glGenTextures(1, &textureId); + glGenTextures(1, &textureId2); +} + +void NativeImageTest::TearDownTestCase() +{ + image = nullptr; + nativeWindow = nullptr; + Deinit(); +} + +void NativeImageTest::InitEglContext() +{ + if (eglContext_ != EGL_NO_DISPLAY) { + return; + } + + BLOGI("Creating EGLContext!!!"); + eglDisplay_ = GetPlatformEglDisplay(EGL_PLATFORM_OHOS_KHR, EGL_DEFAULT_DISPLAY, NULL); + if (eglDisplay_ == EGL_NO_DISPLAY) { + BLOGW("Failed to create EGLDisplay gl errno : %{public}x", eglGetError()); + return; + } + + EGLint major = 0; + EGLint minor = 0; + if (eglInitialize(eglDisplay_, &major, &minor) == EGL_FALSE) { + BLOGE("Failed to initialize EGLDisplay"); + return; + } + + if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE) { + BLOGE("Failed to bind OpenGL ES API"); + return; + } + + unsigned int ret; + EGLint count; + EGLint config_attribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, 8, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT, EGL_NONE }; + + ret = eglChooseConfig(eglDisplay_, config_attribs, &config_, 1, &count); + if (!(ret && static_cast(count) >= 1)) { + BLOGE("Failed to eglChooseConfig"); + return; + } + + static const EGLint context_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, EGL_CONTEXT_CLIENT_VERSION_NUM, EGL_NONE }; + + eglContext_ = eglCreateContext(eglDisplay_, config_, EGL_NO_CONTEXT, context_attribs); + if (eglContext_ == EGL_NO_CONTEXT) { + BLOGE("Failed to create egl context %{public}x", eglGetError()); + return; + } + + eglMakeCurrent(eglDisplay_, EGL_NO_SURFACE, EGL_NO_SURFACE, eglContext_); + + BLOGW("Create EGL context successfully, version %{public}d.%{public}d", major, minor); +} + +void NativeImageTest::Deinit() +{ + if (eglDisplay_ == EGL_NO_DISPLAY) { + return; + } + eglDestroyContext(eglDisplay_, eglContext_); + eglMakeCurrent(eglDisplay_, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + eglTerminate(eglDisplay_); + eglReleaseThread(); + + eglDisplay_ = EGL_NO_DISPLAY; + eglContext_ = EGL_NO_CONTEXT; +} + +/* +* Function: OH_NativeImage_Create +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeImage_Create +* 2. check ret +* @tc.require: issueI5KG61 +*/ +TEST_F(NativeImageTest, OHNativeImageCreate001) +{ + image = OH_NativeImage_Create(textureId, GL_TEXTURE_2D); + ASSERT_NE(image, nullptr); +} + +/* +* Function: OH_NativeImage_AcquireNativeWindow +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeImage_AcquireNativeWindow by abnormal input +* 2. check ret +* @tc.require: issueI5KG61 +*/ +TEST_F(NativeImageTest, OHNativeImageAcquireNativeWindow001) +{ + nativeWindow = OH_NativeImage_AcquireNativeWindow(nullptr); + ASSERT_EQ(nativeWindow, nullptr); +} + +/* +* Function: OH_NativeImage_AcquireNativeWindow +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeImage_AcquireNativeWindow +* 2. check ret +* @tc.require: issueI5KG61 +*/ +TEST_F(NativeImageTest, OHNativeImageAcquireNativeWindow002) +{ + nativeWindow = OH_NativeImage_AcquireNativeWindow(image); + ASSERT_NE(nativeWindow, nullptr); +} + +/* +* Function: OH_NativeImage_AttachContext +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeImage_AttachContext by abnormal input +* 2. check ret +* @tc.require: issueI5KG61 +*/ +TEST_F(NativeImageTest, OHNativeImageAttachContext001) +{ + int32_t ret = OH_NativeImage_AttachContext(nullptr, textureId); + ASSERT_NE(ret, SURFACE_ERROR_OK); +} + +/* +* Function: OH_NativeImage_DetachContext +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeImage_DetachContext by abnormal input +* 2. check ret +* @tc.require: issueI5KG61 +*/ +TEST_F(NativeImageTest, OHNativeImageDetachContext001) +{ + int32_t ret = OH_NativeImage_DetachContext(nullptr); + ASSERT_NE(ret, SURFACE_ERROR_OK); +} + +/* +* Function: OH_NativeImage_DetachContext +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeImage_DetachContext +* 2. check ret +* @tc.require: issueI5KG61 +*/ +TEST_F(NativeImageTest, OHNativeImageDetachContext002) +{ + int32_t ret = OH_NativeImage_DetachContext(image); + ASSERT_EQ(ret, SURFACE_ERROR_INIT); +} + +/* +* Function: OH_NativeImage_DetachContext +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeImage_DetachContext +* 2. check ret +* @tc.require: issueI5KG61 +*/ +TEST_F(NativeImageTest, OHNativeImageDetachContext003) +{ + InitEglContext(); + int32_t ret = OH_NativeImage_DetachContext(image); + ASSERT_EQ(ret, SURFACE_ERROR_ERROR); +} + +/* +* Function: OH_NativeImage_AttachContext +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeImage_AttachContext +* 2. check ret +* @tc.require: issueI5KG61 +*/ +TEST_F(NativeImageTest, OHNativeImageAttachContext002) +{ + int32_t ret = OH_NativeImage_AttachContext(image, textureId); + ASSERT_EQ(ret, SURFACE_ERROR_OK); +} + +/* +* Function: OH_NativeImage_UpdateSurfaceImage +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeImage_UpdateSurfaceImage by abnormal input +* 2. check ret +* @tc.require: issueI5KG61 +*/ +TEST_F(NativeImageTest, OHNativeImageUpdateSurfaceImage001) +{ + int32_t ret = OH_NativeImage_UpdateSurfaceImage(nullptr); + ASSERT_NE(ret, SURFACE_ERROR_OK); +} + +/* +* Function: OH_NativeImage_UpdateSurfaceImage +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeImage_UpdateSurfaceImage +* 2. check ret +* @tc.require: issueI5KG61 +*/ +TEST_F(NativeImageTest, OHNativeImageUpdateSurfaceImage002) +{ + int32_t ret = OH_NativeImage_UpdateSurfaceImage(image); + ASSERT_NE(ret, SURFACE_ERROR_OK); +} + +/* +* Function: OH_NativeImage_UpdateSurfaceImage +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowRequestBuffer +* 2. call OH_NativeWindow_NativeWindowFlushBuffer +* 3. OH_NativeImage_UpdateSurfaceImage +* 4. check ret +* @tc.require: issueI5KG61 +*/ +TEST_F(NativeImageTest, OHNativeImageUpdateSurfaceImage003) +{ + int code = SET_USAGE; + uint64_t usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_MEM_DMA; + int32_t ret = NativeWindowHandleOpt(nativeWindow, code, usage); + if (ret != GSERROR_OK) { + std::cout << "NativeWindowHandleOpt SET_USAGE faile" << std::endl; + } + code = SET_BUFFER_GEOMETRY; + int32_t width = 0x100; + int32_t height = 0x100; + ret = NativeWindowHandleOpt(nativeWindow, code, width, height); + if (ret != GSERROR_OK) { + std::cout << "NativeWindowHandleOpt SET_BUFFER_GEOMETRY failed" << std::endl; + } + code = SET_STRIDE; + int32_t stride = 0x8; + ret = NativeWindowHandleOpt(nativeWindow, code, stride); + if (ret != GSERROR_OK) { + std::cout << "NativeWindowHandleOpt SET_STRIDE failed" << std::endl; + } + code = SET_FORMAT; + int32_t format = GRAPHIC_PIXEL_FMT_RGBA_8888; + ret = NativeWindowHandleOpt(nativeWindow, code, format); + if (ret != GSERROR_OK) { + std::cout << "NativeWindowHandleOpt SET_FORMAT failed" << std::endl; + } + + NativeWindowBuffer* nativeWindowBuffer = nullptr; + int fenceFd = -1; + ret = OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &nativeWindowBuffer, &fenceFd); + ASSERT_EQ(ret, GSERROR_OK); + + struct OHNativeWindowRegion *region = new OHNativeWindowRegion(); + struct OHNativeWindowRegion::Rect *rect = new OHNativeWindowRegion::Rect(); + rect->x = 0x100; + rect->y = 0x100; + rect->w = 0x100; + rect->h = 0x100; + region->rects = rect; + ret = OH_NativeWindow_NativeWindowFlushBuffer(nativeWindow, nativeWindowBuffer, fenceFd, *region); + ASSERT_EQ(ret, GSERROR_OK); + delete region; + + ret = OH_NativeImage_UpdateSurfaceImage(image); + ASSERT_EQ(ret, SURFACE_ERROR_OK); +} + +/* +* Function: OH_NativeImage_GetTimestamp +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeImage_GetTimestamp by abnormal input +* 2. check ret +* @tc.require: issueI5KG61 +*/ +TEST_F(NativeImageTest, OHNativeImageGetTimestamp001) +{ + int64_t timeStamp = OH_NativeImage_GetTimestamp(nullptr); + ASSERT_EQ(timeStamp, SURFACE_ERROR_ERROR); +} + +/* +* Function: OH_NativeImage_GetTimestamp +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeImage_GetTimestamp +* 2. check ret +* @tc.require: issueI5KG61 +*/ +TEST_F(NativeImageTest, OHNativeImageGetTimestamp002) +{ + int64_t timeStamp = OH_NativeImage_GetTimestamp(image); + ASSERT_NE(timeStamp, SURFACE_ERROR_ERROR); +} + +/* +* Function: OH_NativeImage_GetTransformMatrix +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeImage_GetTransformMatrix by abnormal input +* 2. check ret +* @tc.require: issueI5KG61 +*/ +TEST_F(NativeImageTest, OHNativeImageGetTransformMatrix001) +{ + float matrix[16]; + int32_t ret = OH_NativeImage_GetTransformMatrix(nullptr, matrix); + ASSERT_NE(ret, SURFACE_ERROR_OK); +} + +/* +* Function: OH_NativeImage_GetTransformMatrix +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeImage_GetTransformMatrix +* 2. check ret +* @tc.require: issueI5KG61 +*/ +TEST_F(NativeImageTest, OHNativeImageGetTransformMatrix002) +{ + float matrix[16]; + int32_t ret = OH_NativeImage_GetTransformMatrix(image, matrix); + ASSERT_EQ(ret, SURFACE_ERROR_OK); +} + +/* +* Function: OH_NativeImage_AttachContext +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeImage_AttachContext with another texture +* 2. check ret +* @tc.require: issueI5KG61 +*/ +TEST_F(NativeImageTest, OHNativeImageAttachContext003) +{ + int32_t ret = OH_NativeImage_AttachContext(image, textureId2); + ASSERT_EQ(ret, SURFACE_ERROR_OK); +} + +/* +* Function: OH_NativeImage_UpdateSurfaceImage +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowRequestBuffer +* 2. call OH_NativeWindow_NativeWindowFlushBuffer +* 3. OH_NativeImage_UpdateSurfaceImage after the bound OPENGL ES texture changed +* 4. check ret +* @tc.require: issueI5KG61 +*/ +TEST_F(NativeImageTest, OHNativeImageUpdateSurfaceImage004) +{ + NativeWindowBuffer* nativeWindowBuffer = nullptr; + int fenceFd = -1; + int32_t ret = OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &nativeWindowBuffer, &fenceFd); + ASSERT_EQ(ret, GSERROR_OK); + + struct OHNativeWindowRegion *region = new OHNativeWindowRegion(); + struct OHNativeWindowRegion::Rect *rect = new OHNativeWindowRegion::Rect(); + rect->x = 0x100; + rect->y = 0x100; + rect->w = 0x100; + rect->h = 0x100; + region->rects = rect; + ret = OH_NativeWindow_NativeWindowFlushBuffer(nativeWindow, nativeWindowBuffer, fenceFd, *region); + ASSERT_EQ(ret, GSERROR_OK); + delete region; + + ret = OH_NativeImage_UpdateSurfaceImage(image); + ASSERT_EQ(ret, SURFACE_ERROR_OK); +} + +/* +* Function: OH_NativeImage_DetachContext +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeImage_DetachContext +* 2. check ret +* @tc.require: issueI5KG61 +*/ +TEST_F(NativeImageTest, OHNativeImageDetachContext004) +{ + int32_t ret = OH_NativeImage_DetachContext(image); + ASSERT_EQ(ret, SURFACE_ERROR_OK); +} + +/* +* Function: OH_NativeImage_AttachContext +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeImage_AttachContext after OH_NativeImage_DetachContext +* 2. check ret +* @tc.require: issueI5KG61 +*/ +TEST_F(NativeImageTest, OHNativeImageAttachContext004) +{ + int32_t ret = OH_NativeImage_AttachContext(image, textureId2); + ASSERT_EQ(ret, SURFACE_ERROR_OK); +} + +/* +* Function: OH_NativeImage_UpdateSurfaceImage +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowRequestBuffer +* 2. call OH_NativeWindow_NativeWindowFlushBuffer +* 3. OH_NativeImage_UpdateSurfaceImage again +* 4. check ret +* @tc.require: issueI5KG61 +*/ +TEST_F(NativeImageTest, OHNativeImageUpdateSurfaceImage005) +{ + NativeWindowBuffer* nativeWindowBuffer = nullptr; + int fenceFd = -1; + int32_t ret = OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &nativeWindowBuffer, &fenceFd); + ASSERT_EQ(ret, GSERROR_OK); + + struct OHNativeWindowRegion *region = new OHNativeWindowRegion(); + struct OHNativeWindowRegion::Rect *rect = new OHNativeWindowRegion::Rect(); + rect->x = 0x100; + rect->y = 0x100; + rect->w = 0x100; + rect->h = 0x100; + region->rects = rect; + ret = OH_NativeWindow_NativeWindowFlushBuffer(nativeWindow, nativeWindowBuffer, fenceFd, *region); + ASSERT_EQ(ret, GSERROR_OK); + delete region; + + ret = OH_NativeImage_UpdateSurfaceImage(image); + ASSERT_EQ(ret, SURFACE_ERROR_OK); +} + +/* +* Function: OH_NativeImage_Destroy +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeImage_Destroy by abnormal input +* 2. check ret +* @tc.require: issueI5KG61 +*/ +TEST_F(NativeImageTest, OHNativeImageDestroy001) +{ + OH_NativeImage_Destroy(nullptr); + ASSERT_NE(image, nullptr); +} + +/* +* Function: OH_NativeImage_Destroy +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeImage_Destroy +* 2. check ret +* @tc.require: issueI5KG61 +*/ +TEST_F(NativeImageTest, OHNativeImageDestroy002) +{ + OH_NativeImage_Destroy(&image); + ASSERT_EQ(image, nullptr); +} +} \ No newline at end of file diff --git a/display_server/frameworks/surface/test/ft_build/native_window_test.cpp b/display_server/frameworks/surface/test/ft_build/native_window_test.cpp new file mode 100644 index 0000000..a6259e6 --- /dev/null +++ b/display_server/frameworks/surface/test/ft_build/native_window_test.cpp @@ -0,0 +1,851 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include "buffer_log.h" +#include "external_window.h" + +namespace OHOS::Rosen { +class BufferConsumerListener : public IBufferConsumerListener { +public: + void OnBufferAvailable() override + { + } +}; + +static OHExtDataHandle *AllocOHExtDataHandle(uint32_t reserveInts) +{ + size_t handleSize = sizeof(OHExtDataHandle) + (sizeof(int32_t) * reserveInts); + OHExtDataHandle *handle = static_cast(malloc(handleSize)); + if (handle == nullptr) { + BLOGE("AllocOHExtDataHandle malloc %zu failed", handleSize); + return nullptr; + } + auto ret = memset_s(handle, handleSize, 0, handleSize); + if (ret != EOK) { + BLOGE("AllocOHExtDataHandle memset_s failed"); + return nullptr; + } + handle->fd = -1; + handle->reserveInts = reserveInts; + for (uint32_t i = 0; i < reserveInts; i++) { + handle->reserve[i] = -1; + } + return handle; +} + +static void FreeOHExtDataHandle(OHExtDataHandle *handle) +{ + if (handle == nullptr) { + BLOGW("FreeOHExtDataHandle with nullptr handle"); + return ; + } + if (handle->fd >= 0) { + close(handle->fd); + handle->fd = -1; + } + free(handle); +} + +class NativeWindowTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + static inline BufferRequestConfig requestConfig = {}; + static inline BufferFlushConfig flushConfig = {}; + static inline sptr cSurface = nullptr; + static inline sptr producer = nullptr; + static inline sptr pSurface = nullptr; + static inline sptr sBuffer = nullptr; + static inline NativeWindow* nativeWindow = nullptr; + static inline NativeWindowBuffer* nativeWindowBuffer = nullptr; +}; + +void NativeWindowTest::SetUpTestCase() +{ + requestConfig = { + .width = 0x100, // small + .height = 0x100, // small + .strideAlignment = 0x8, + .format = GRAPHIC_PIXEL_FMT_RGBA_8888, +#ifdef RS_ENABLE_GL + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_MEM_DMA, +#else + .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE, +#endif + .timeout = 0, + }; + + cSurface = Surface::CreateSurfaceAsConsumer(); + sptr listener = new BufferConsumerListener(); + cSurface->RegisterConsumerListener(listener); + producer = cSurface->GetProducer(); + pSurface = Surface::CreateSurfaceAsProducer(producer); + int32_t fence; + pSurface->RequestBuffer(sBuffer, fence, requestConfig); +} + +void NativeWindowTest::TearDownTestCase() +{ + flushConfig = { .damage = { + .w = 0x100, + .h = 0x100, + } }; + pSurface->FlushBuffer(sBuffer, -1, flushConfig); + sBuffer = nullptr; + cSurface = nullptr; + producer = nullptr; + pSurface = nullptr; + nativeWindow = nullptr; + nativeWindowBuffer = nullptr; +} + +/* +* Function: OH_NativeWindow_CreateNativeWindow +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_CreateNativeWindow by abnormal input +* 2. check ret + */ +TEST_F(NativeWindowTest, CreateNativeWindow001) +{ + ASSERT_EQ(OH_NativeWindow_CreateNativeWindow(nullptr), nullptr); +} + +/* +* Function: OH_NativeWindow_CreateNativeWindow +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_CreateNativeWindow +* 2. check ret + */ +TEST_F(NativeWindowTest, CreateNativeWindow002) +{ + nativeWindow = OH_NativeWindow_CreateNativeWindow(&pSurface); + ASSERT_NE(nativeWindow, nullptr); +} + +/* +* Function: OH_NativeWindow_NativeWindowHandleOpt +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowHandleOpt by abnormal input +* 2. check ret + */ +TEST_F(NativeWindowTest, HandleOpt001) +{ + int code = SET_USAGE; + uint64_t usage = BUFFER_USAGE_CPU_READ; + ASSERT_EQ(OH_NativeWindow_NativeWindowHandleOpt(nullptr, code, usage), OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: OH_NativeWindow_NativeWindowHandleOpt +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowHandleOpt by different param +* 2. check ret + */ +TEST_F(NativeWindowTest, HandleOpt002) +{ + int code = SET_USAGE; + uint64_t usageSet = BUFFER_USAGE_CPU_READ; + ASSERT_EQ(OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, usageSet), OHOS::GSERROR_OK); + + code = GET_USAGE; + uint64_t usageGet = BUFFER_USAGE_CPU_WRITE; + ASSERT_EQ(OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, &usageGet), OHOS::GSERROR_OK); + ASSERT_EQ(usageSet, usageGet); +} + +/* +* Function: OH_NativeWindow_NativeWindowHandleOpt +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowHandleOpt by different param +* 2. check ret + */ +TEST_F(NativeWindowTest, HandleOpt003) +{ + int code = SET_BUFFER_GEOMETRY; + int32_t heightSet = 0x100; + int32_t widthSet = 0x100; + ASSERT_EQ(OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, heightSet, widthSet), OHOS::GSERROR_OK); + + code = GET_BUFFER_GEOMETRY; + int32_t heightGet = 0; + int32_t widthGet = 0; + ASSERT_EQ(OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, &heightGet, &widthGet), OHOS::GSERROR_OK); + ASSERT_EQ(heightSet, heightGet); + ASSERT_EQ(widthSet, widthGet); +} + +/* +* Function: OH_NativeWindow_NativeWindowHandleOpt +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowHandleOpt by different param +* 2. check ret + */ +TEST_F(NativeWindowTest, HandleOpt004) +{ + int code = SET_FORMAT; + int32_t formatSet = GRAPHIC_PIXEL_FMT_RGBA_8888; + ASSERT_EQ(OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, formatSet), OHOS::GSERROR_OK); + + code = GET_FORMAT; + int32_t formatGet = GRAPHIC_PIXEL_FMT_CLUT8; + ASSERT_EQ(OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, &formatGet), OHOS::GSERROR_OK); + ASSERT_EQ(formatSet, formatGet); +} + +/* +* Function: OH_NativeWindow_NativeWindowHandleOpt +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowHandleOpt by different param +* 2. check ret + */ +TEST_F(NativeWindowTest, HandleOpt005) +{ + int code = SET_STRIDE; + int32_t strideSet = 0x8; + ASSERT_EQ(OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, strideSet), OHOS::GSERROR_OK); + + code = GET_STRIDE; + int32_t strideGet = 0; + ASSERT_EQ(OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, &strideGet), OHOS::GSERROR_OK); + ASSERT_EQ(strideSet, strideGet); +} + +/* +* Function: OH_NativeWindow_NativeWindowHandleOpt +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowHandleOpt by different param +* 2. check ret + */ +TEST_F(NativeWindowTest, HandleOpt006) +{ + int code = SET_COLOR_GAMUT; + int32_t colorGamutSet = static_cast(GraphicColorGamut::GRAPHIC_COLOR_GAMUT_DCI_P3); + ASSERT_EQ(OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, colorGamutSet), OHOS::GSERROR_OK); + + code = GET_COLOR_GAMUT; + int32_t colorGamutGet = 0; + ASSERT_EQ(OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, &colorGamutGet), OHOS::GSERROR_OK); + ASSERT_EQ(colorGamutSet, colorGamutGet); +} + +/* +* Function: OH_NativeWindow_NativeWindowHandleOpt +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowHandleOpt by different param +* 2. check ret + */ +TEST_F(NativeWindowTest, HandleOpt007) +{ + int code = SET_TIMEOUT; + int32_t timeoutSet = 10; // 10: for test + ASSERT_EQ(OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, timeoutSet), OHOS::GSERROR_OK); + + code = GET_TIMEOUT; + int32_t timeoutGet = 0; + ASSERT_EQ(OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, &timeoutGet), OHOS::GSERROR_OK); + ASSERT_EQ(timeoutSet, timeoutGet); +} + +/* +* Function: OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer by abnormal input +* 2. check ret + */ +TEST_F(NativeWindowTest, CreateNativeWindowBuffer001) +{ + ASSERT_EQ(OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer(nullptr), nullptr); +} + +/* +* Function: OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer +* 2. check ret + */ +TEST_F(NativeWindowTest, CreateNativeWindowBuffer002) +{ + nativeWindowBuffer = OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer(&sBuffer); + ASSERT_NE(nativeWindowBuffer, nullptr); +} + +/* +* Function: OH_NativeWindow_NativeWindowRequestBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowRequestBuffer by abnormal input +* 2. check ret + */ +TEST_F(NativeWindowTest, RequestBuffer001) +{ + ASSERT_EQ(OH_NativeWindow_NativeWindowRequestBuffer(nullptr, &nativeWindowBuffer, nullptr), + OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: OH_NativeWindow_NativeWindowRequestBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowRequestBuffer by abnormal input +* 2. check ret + */ +TEST_F(NativeWindowTest, RequestBuffer002) +{ + ASSERT_EQ(OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, nullptr, nullptr), + OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: OH_NativeWindow_GetBufferHandleFromNative +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_GetBufferHandleFromNative by abnormal input +* 2. check ret + */ +TEST_F(NativeWindowTest, GetBufferHandle001) +{ + ASSERT_EQ(OH_NativeWindow_GetBufferHandleFromNative(nullptr), nullptr); +} + +/* +* Function: OH_NativeWindow_GetBufferHandleFromNative +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_GetBufferHandleFromNative +* 2. check ret + */ +TEST_F(NativeWindowTest, GetBufferHandle002) +{ + struct NativeWindowBuffer *buffer = new NativeWindowBuffer(); + buffer->sfbuffer = sBuffer; + ASSERT_NE(OH_NativeWindow_GetBufferHandleFromNative(nativeWindowBuffer), nullptr); + delete buffer; +} + +/* +* Function: OH_NativeWindow_NativeWindowFlushBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowFlushBuffer by abnormal input +* 2. check ret + */ +TEST_F(NativeWindowTest, FlushBuffer001) +{ + int fenceFd = -1; + struct OHNativeWindowRegion *region = new OHNativeWindowRegion(); + struct OHNativeWindowRegion::Rect * rect = new OHNativeWindowRegion::Rect(); + rect->x = 0x100; + rect->y = 0x100; + rect->w = 0x100; + rect->h = 0x100; + region->rects = rect; + + ASSERT_EQ(OH_NativeWindow_NativeWindowFlushBuffer(nullptr, nullptr, fenceFd, *region), + OHOS::GSERROR_INVALID_ARGUMENTS); + delete region; +} + +/* +* Function: OH_NativeWindow_NativeWindowFlushBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowFlushBuffer by abnormal input +* 2. check ret + */ +TEST_F(NativeWindowTest, FlushBuffer002) +{ + int fenceFd = -1; + struct OHNativeWindowRegion *region = new OHNativeWindowRegion(); + struct OHNativeWindowRegion::Rect * rect = new OHNativeWindowRegion::Rect(); + rect->x = 0x100; + rect->y = 0x100; + rect->w = 0x100; + rect->h = 0x100; + region->rects = rect; + + ASSERT_EQ(OH_NativeWindow_NativeWindowFlushBuffer(nativeWindow, nullptr, fenceFd, *region), + OHOS::GSERROR_INVALID_ARGUMENTS); + delete region; +} + +/* +* Function: OH_NativeWindow_NativeWindowFlushBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowFlushBuffer +* 2. check ret + */ +TEST_F(NativeWindowTest, FlushBuffer003) +{ + int fenceFd = -1; + struct OHNativeWindowRegion *region = new OHNativeWindowRegion(); + struct OHNativeWindowRegion::Rect * rect = new OHNativeWindowRegion::Rect(); + rect->x = 0x100; + rect->y = 0x100; + rect->w = 0x100; + rect->h = 0x100; + region->rects = rect; + + ASSERT_EQ(OH_NativeWindow_NativeWindowFlushBuffer(nativeWindow, nativeWindowBuffer, fenceFd, *region), + OHOS::GSERROR_OK); + delete region; +} + +/* +* Function: OH_NativeWindow_NativeWindowAbortBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowAbortBuffer by abnormal input +* 2. check ret + */ +TEST_F(NativeWindowTest, CancelBuffer001) +{ + ASSERT_EQ(OH_NativeWindow_NativeWindowAbortBuffer(nullptr, nullptr), OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: OH_NativeWindow_NativeWindowAbortBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowAbortBuffer by abnormal input +* 2. check ret + */ +TEST_F(NativeWindowTest, CancelBuffer002) +{ + ASSERT_EQ(OH_NativeWindow_NativeWindowAbortBuffer(nativeWindow, nullptr), OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: OH_NativeWindow_NativeWindowAbortBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowAbortBuffer +* 2. check ret + */ +TEST_F(NativeWindowTest, CancelBuffer003) +{ + ASSERT_EQ(OH_NativeWindow_NativeWindowAbortBuffer(nativeWindow, nativeWindowBuffer), OHOS::GSERROR_OK); +} + +/* +* Function: OH_NativeWindow_NativeObjectReference +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeObjectReference +* 2. check ret + */ +TEST_F(NativeWindowTest, Reference001) +{ + struct NativeWindowBuffer *buffer = new NativeWindowBuffer(); + buffer->sfbuffer = sBuffer; + ASSERT_EQ(OH_NativeWindow_NativeObjectReference(reinterpret_cast(buffer)), OHOS::GSERROR_OK); + delete buffer; +} + +/* +* Function: OH_NativeWindow_NativeObjectUnreference +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeObjectUnreference +* 2. check ret + */ +TEST_F(NativeWindowTest, Unreference001) +{ + struct NativeWindowBuffer *buffer = new NativeWindowBuffer(); + buffer->sfbuffer = sBuffer; + ASSERT_EQ(OH_NativeWindow_NativeObjectUnreference(reinterpret_cast(buffer)), OHOS::GSERROR_OK); + delete buffer; +} + +/* +* Function: OH_NativeWindow_DestroyNativeWindow +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_DestroyNativeWindow by abnormal input +* 2. check ret + */ +TEST_F(NativeWindowTest, DestroyNativeWindow001) +{ + OH_NativeWindow_DestroyNativeWindow(nullptr); +} + +/* +* Function: OH_NativeWindow_DestroyNativeWindow +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_DestroyNativeWindow +* 2. check ret + */ +TEST_F(NativeWindowTest, DestroyNativeWindow002) +{ + OH_NativeWindow_DestroyNativeWindow(nativeWindow); +} + +/* +* Function: OH_NativeWindow_DestroyNativeWindowBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_DestroyNativeWindowBuffer by abnormal input +* 2. check ret + */ +TEST_F(NativeWindowTest, OH_NativeWindow_DestroyNativeWindowBuffer001) +{ + OH_NativeWindow_DestroyNativeWindowBuffer(nullptr); +} + +/* +* Function: OH_NativeWindow_DestroyNativeWindowBuffer +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_DestroyNativeWindowBuffer again +* 2. check ret + */ +TEST_F(NativeWindowTest, OH_NativeWindow_DestroyNativeWindowBuffer002) +{ + OH_NativeWindow_DestroyNativeWindowBuffer(nativeWindowBuffer); +} + +/* +* Function: OH_NativeWindow_NativeWindowSetScalingMode +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowSetScalingMode with abnormal parameters and check ret + */ +TEST_F(NativeWindowTest, SetScalingMode001) +{ + OHScalingMode scalingMode = OHScalingMode::OH_SCALING_MODE_SCALE_TO_WINDOW; + ASSERT_EQ(OH_NativeWindow_NativeWindowSetScalingMode(nullptr, -1, scalingMode), OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: OH_NativeWindow_NativeWindowSetScalingMode +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowSetScalingMode with abnormal parameters and check ret + */ +TEST_F(NativeWindowTest, SetScalingMode002) +{ + OHScalingMode scalingMode = OHScalingMode::OH_SCALING_MODE_SCALE_TO_WINDOW; + ASSERT_EQ(OH_NativeWindow_NativeWindowSetScalingMode(nativeWindow, -1, scalingMode), OHOS::GSERROR_NO_ENTRY); +} + +/* +* Function: OH_NativeWindow_NativeWindowSetScalingMode +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowSetScalingMode with abnormal parameters and check ret + */ +TEST_F(NativeWindowTest, SetScalingMode003) +{ + int32_t sequence = 0; + ASSERT_EQ(OH_NativeWindow_NativeWindowSetScalingMode(nativeWindow, sequence, + static_cast(OHScalingMode::OH_SCALING_MODE_NO_SCALE_CROP + 1)), + OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: OH_NativeWindow_NativeWindowSetScalingMode +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowSetScalingMode with abnormal parameters and check ret +* 2. call OH_NativeWindow_NativeWindowSetScalingMode with normal parameters and check ret + */ +TEST_F(NativeWindowTest, SetScalingMode004) +{ + int32_t sequence = 0; + OHScalingMode scalingMode = OHScalingMode::OH_SCALING_MODE_SCALE_TO_WINDOW; + ASSERT_EQ(OH_NativeWindow_NativeWindowSetScalingMode(nativeWindow, sequence, scalingMode), OHOS::GSERROR_OK); +} + +/* +* Function: OH_NativeWindow_NativeWindowSetMetaData +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowSetMetaData with abnormal parameters and check ret + */ +TEST_F(NativeWindowTest, SetMetaData001) +{ + ASSERT_EQ(OH_NativeWindow_NativeWindowSetMetaData(nullptr, -1, 0, nullptr), OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: OH_NativeWindow_NativeWindowSetMetaData +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowSetMetaData with abnormal parameters and check ret + */ +TEST_F(NativeWindowTest, SetMetaData002) +{ + ASSERT_EQ(OH_NativeWindow_NativeWindowSetMetaData(nativeWindow, -1, 0, nullptr), OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: OH_NativeWindow_NativeWindowSetMetaData +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowSetMetaData with abnormal parameters and check ret +* 2. call OH_NativeWindow_NativeWindowSetMetaData with normal parameters and check ret + */ +TEST_F(NativeWindowTest, SetMetaData003) +{ + int32_t sequence = 0; + ASSERT_EQ(OH_NativeWindow_NativeWindowSetMetaData(nativeWindow, sequence, 0, nullptr), + OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: OH_NativeWindow_NativeWindowSetMetaData +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowSetMetaData with abnormal parameters and check ret + */ +TEST_F(NativeWindowTest, SetMetaData004) +{ + int32_t sequence = 0; + int32_t size = 1; + ASSERT_EQ(OH_NativeWindow_NativeWindowSetMetaData(nativeWindow, sequence, size, nullptr), + OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: OH_NativeWindow_NativeWindowSetMetaData +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowSetMetaData with abnormal parameters and check ret + */ +TEST_F(NativeWindowTest, SetMetaData005) +{ + int32_t size = 1; + const OHHDRMetaData metaData[] = {{OH_METAKEY_RED_PRIMARY_X, 0}}; + ASSERT_EQ(OH_NativeWindow_NativeWindowSetMetaData(nativeWindow, -1, size, metaData), OHOS::GSERROR_NO_ENTRY); +} + +/* +* Function: OH_NativeWindow_NativeWindowSetMetaData +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowSetMetaData with normal parameters and check ret + */ +TEST_F(NativeWindowTest, SetMetaData006) +{ + int32_t sequence = 0; + int32_t size = 1; + const OHHDRMetaData metaData[] = {{OH_METAKEY_RED_PRIMARY_X, 0}}; + ASSERT_EQ(OH_NativeWindow_NativeWindowSetMetaData(nativeWindow, sequence, size, metaData), OHOS::GSERROR_OK); +} + +/* +* Function: OH_NativeWindow_NativeWindowSetMetaDataSet +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowSetMetaDataSet with abnormal parameters and check ret + */ +TEST_F(NativeWindowTest, SetMetaDataSet001) +{ + OHHDRMetadataKey key = OHHDRMetadataKey::OH_METAKEY_HDR10_PLUS; + ASSERT_EQ(OH_NativeWindow_NativeWindowSetMetaDataSet(nullptr, -1, key, 0, nullptr), + OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: OH_NativeWindow_NativeWindowSetMetaDataSet +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowSetMetaDataSet with abnormal parameters and check ret + */ +TEST_F(NativeWindowTest, SetMetaDataSet002) +{ + OHHDRMetadataKey key = OHHDRMetadataKey::OH_METAKEY_HDR10_PLUS; + ASSERT_EQ(OH_NativeWindow_NativeWindowSetMetaDataSet(nativeWindow, -1, key, 0, nullptr), + OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: OH_NativeWindow_NativeWindowSetMetaDataSet +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowSetMetaDataSet with abnormal parameters and check ret + */ +TEST_F(NativeWindowTest, SetMetaDataSet003) +{ + int32_t sequence = 0; + OHHDRMetadataKey key = OHHDRMetadataKey::OH_METAKEY_HDR10_PLUS; + ASSERT_EQ(OH_NativeWindow_NativeWindowSetMetaDataSet(nativeWindow, sequence, key, 0, nullptr), + OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: OH_NativeWindow_NativeWindowSetMetaDataSet +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowSetMetaDataSet with abnormal parameters and check ret + */ +TEST_F(NativeWindowTest, SetMetaDataSet004) +{ + int32_t sequence = 0; + int32_t size = 1; + OHHDRMetadataKey key = OHHDRMetadataKey::OH_METAKEY_HDR10_PLUS; + ASSERT_EQ(OH_NativeWindow_NativeWindowSetMetaDataSet(nativeWindow, sequence, key, size, nullptr), + OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: OH_NativeWindow_NativeWindowSetMetaDataSet +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowSetMetaDataSet with abnormal parameters and check ret + */ +TEST_F(NativeWindowTest, SetMetaDataSet005) +{ + int32_t size = 1; + OHHDRMetadataKey key = OHHDRMetadataKey::OH_METAKEY_HDR10_PLUS; + const uint8_t metaData[] = {0}; + ASSERT_EQ(OH_NativeWindow_NativeWindowSetMetaDataSet(nativeWindow, -1, key, size, metaData), + OHOS::GSERROR_NO_ENTRY); +} + +/* +* Function: OH_NativeWindow_NativeWindowSetMetaDataSet +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowSetMetaDataSet with normal parameters and check ret + */ +TEST_F(NativeWindowTest, SetMetaDataSet006) +{ + int32_t sequence = 0; + int32_t size = 1; + OHHDRMetadataKey key = OHHDRMetadataKey::OH_METAKEY_HDR10_PLUS; + const uint8_t metaData[] = {0}; + ASSERT_EQ(OH_NativeWindow_NativeWindowSetMetaDataSet(nativeWindow, sequence, key, size, metaData), + OHOS::GSERROR_OK); +} + +/* +* Function: OH_NativeWindow_NativeWindowSetTunnelHandle +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowSetTunnelHandle with abnormal parameters and check ret + */ +TEST_F(NativeWindowTest, SetTunnelHandle001) +{ + ASSERT_EQ(OH_NativeWindow_NativeWindowSetTunnelHandle(nullptr, nullptr), OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: OH_NativeWindow_NativeWindowSetTunnelHandle +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowSetTunnelHandle with abnormal parameters and check ret + */ +TEST_F(NativeWindowTest, SetTunnelHandle002) +{ + ASSERT_EQ(OH_NativeWindow_NativeWindowSetTunnelHandle(nativeWindow, nullptr), OHOS::GSERROR_INVALID_ARGUMENTS); +} + +/* +* Function: OH_NativeWindow_NativeWindowSetTunnelHandle +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowSetTunnelHandle with normal parameters and check ret + */ +TEST_F(NativeWindowTest, SetTunnelHandle003) +{ + uint32_t reserveInts = 1; + OHExtDataHandle *handle = AllocOHExtDataHandle(reserveInts); + ASSERT_EQ(OH_NativeWindow_NativeWindowSetTunnelHandle(nativeWindow, handle), OHOS::GSERROR_OK); + FreeOHExtDataHandle(handle); +} + +/* +* Function: OH_NativeWindow_NativeWindowSetTunnelHandle +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeWindow_NativeWindowSetTunnelHandle with normal parameters and check ret +* @tc.require: issueI5GMZN issueI5IWHW + */ +TEST_F(NativeWindowTest, SetTunnelHandle004) +{ + uint32_t reserveInts = 2; + OHExtDataHandle *handle = AllocOHExtDataHandle(reserveInts); + nativeWindow = OH_NativeWindow_CreateNativeWindow(&pSurface); + ASSERT_NE(nativeWindow, nullptr); + ASSERT_EQ(OH_NativeWindow_NativeWindowSetTunnelHandle(nativeWindow, handle), OHOS::GSERROR_OK); + ASSERT_EQ(OH_NativeWindow_NativeWindowSetTunnelHandle(nativeWindow, handle), OHOS::GSERROR_NO_ENTRY); + FreeOHExtDataHandle(handle); +} +} diff --git a/display_server/frameworks/surfaceimage/ft_build/BUILD.gn b/display_server/frameworks/surfaceimage/ft_build/BUILD.gn new file mode 100644 index 0000000..2bbf80b --- /dev/null +++ b/display_server/frameworks/surfaceimage/ft_build/BUILD.gn @@ -0,0 +1,62 @@ +# Copyright (c) 2023 Huawei Technologies Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/gn/fangtian.gni") +import("//display_server/ft_build/ds_config.gni") + +config("native_image_config") { + visibility = [ ":*" ] + + cflags = [ + "-Wall", + "-Werror", + "-g3", + ] +} + +config("libnative_image_public_config") { + include_dirs = [ + "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include", + "//display_server/frameworks/surface/include", + "//display_server/utils/sandbox", + "../include", + ] +} + +ft_shared_library("libnative_image") { + sources = [] + if (ds_enable_gpu) { + sources += [ + "../src/native_image.cpp", + "../src/surface_image.cpp", + ] + } + + configs = [ ":native_image_config" ] + + public_configs = [ ":libnative_image_public_config" ] + + deps = [ + "//display_server/frameworks/surface/ft_build:surface", + "//display_server/utils/ft_build:sync_fence", + ] + + libs = libgl + + output_extension = "so" + + public_deps = [ + "//build/gn/configs/system_libs:c_utils", + "//build/gn/configs/system_libs:hilog", + ] +} \ No newline at end of file diff --git a/display_server/ft_build/BUILD.gn b/display_server/ft_build/BUILD.gn index 2ffd237..9fc0509 100644 --- a/display_server/ft_build/BUILD.gn +++ b/display_server/ft_build/BUILD.gn @@ -18,6 +18,11 @@ group("libsurface") { public_deps = [ "../frameworks/surface/ft_build:surface" ] } +# TODO: enable native_image +# group("libnative_image") { +# public_deps = [ "../frameworks/surfaceimage/ft_build:libnative_image" ] +# } + group("libfence") { public_deps = [ "../frameworks/fence/ft_build:libfence" ] } diff --git a/display_server/rosen/modules/composer/native_vsync/ft_build/BUILD.gn b/display_server/rosen/modules/composer/native_vsync/ft_build/BUILD.gn new file mode 100644 index 0000000..555e982 --- /dev/null +++ b/display_server/rosen/modules/composer/native_vsync/ft_build/BUILD.gn @@ -0,0 +1,53 @@ +# Copyright (c) 2023 Huawei Technologies Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/gn/fangtian.gni") + +config("native_vsync_config") { + visibility = [ ":*" ] + + cflags = [ + "-Wall", + "-Werror", + "-g3", + ] +} + +config("native_vsync_public_config") { + include_dirs = + [ "//display_server/interfaces/inner_api/composer" ] +} + +ft_shared_library("libnative_vsync") { + sources = [ "../native_vsync.cpp" ] + + include_dirs = [ + "//display_server/utils/log", + "//display_server/interfaces/inner_api/common", + ] + + configs = [ ":native_vsync_config" ] + + public_configs = [ ":native_vsync_public_config" ] + + output_extension = "so" + + deps = [ + "//display_server/rosen/modules/render_service_client/ft_build:librender_service_client", + ] + + public_deps = [ + "//build/gn/configs/system_libs:c_utils", + "//build/gn/configs/system_libs:hilog", + ] +} diff --git a/display_server/rosen/modules/composer/vsync/test/ft_build/BUILD.gn b/display_server/rosen/modules/composer/vsync/test/ft_build/BUILD.gn index c1fd4cc..db97b43 100644 --- a/display_server/rosen/modules/composer/vsync/test/ft_build/BUILD.gn +++ b/display_server/rosen/modules/composer/vsync/test/ft_build/BUILD.gn @@ -23,6 +23,7 @@ group("unittest") { ":vsync_generator_test", ":vsync_receiver_test", ":vsync_sampler_test", + ":native_vsync_test", ] } @@ -47,7 +48,7 @@ ft_static_library("vsync_test_common") { public_deps = [ "//build/gn/configs/system_libs:gtest", - # "//display_server/rosen/modules/composer/native_vsync/ft_build:libnative_vsync", + "//display_server/rosen/modules/composer/native_vsync/ft_build:libnative_vsync", "//display_server/rosen/modules/composer/vsync/ft_build:libvsync", "//display_server/utils/ft_build:socketpair", ] @@ -103,3 +104,11 @@ ft_executable("vsync_sampler_test") { deps = [ ":vsync_test_common" ] } + +ft_executable("native_vsync_test") { + testonly = true + + sources = [ "native_vsync_test.cpp" ] + + deps = [ ":vsync_test_common" ] +} diff --git a/display_server/rosen/modules/composer/vsync/test/ft_build/native_vsync_test.cpp b/display_server/rosen/modules/composer/vsync/test/ft_build/native_vsync_test.cpp new file mode 100644 index 0000000..affac7e --- /dev/null +++ b/display_server/rosen/modules/composer/vsync/test/ft_build/native_vsync_test.cpp @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include "native_vsync.h" + +namespace OHOS { +namespace Rosen { +class NativeVsyncTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + static inline OH_NativeVSync* native_vsync = nullptr; +}; + +void NativeVsyncTest::SetUpTestCase() +{ +} + +void NativeVsyncTest::TearDownTestCase() +{ +} + +static void OnVSync(long long timestamp, void* data) +{ +} + +namespace { +/* +* Function: OH_NativeVSync_Create +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeVSync_Create by abnormal input +* 2. check ret + */ +TEST_F(NativeVsyncTest, OH_NativeVSync_Create001) +{ + ASSERT_EQ(OH_NativeVSync_Create(nullptr, 0), nullptr); +} + +/* +* Function: OH_NativeVSync_Create +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeVSync_Create +* 2. check ret + */ +TEST_F(NativeVsyncTest, OH_NativeVSync_Create002) +{ + char name[] = "test"; + native_vsync = OH_NativeVSync_Create(name, sizeof(name)); + ASSERT_NE(native_vsync, nullptr); +} + +/* +* Function: OH_NativeVSync_RequestFrame +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeVSync_RequestFrame by abnormal input +* 2. check ret + */ +TEST_F(NativeVsyncTest, OH_NativeVSync_RequestFrame001) +{ + ASSERT_NE(OH_NativeVSync_RequestFrame(nullptr, nullptr, nullptr), 0); +} + +/* +* Function: OH_NativeVSync_RequestFrame +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeVSync_RequestFrame by abnormal input +* 2. check ret + */ +TEST_F(NativeVsyncTest, OH_NativeVSync_RequestFrame002) +{ + ASSERT_NE(OH_NativeVSync_RequestFrame(native_vsync, nullptr, nullptr), 0); +} + +/* +* Function: OH_NativeVSync_RequestFrame +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeVSync_RequestFrame +* 2. check ret + */ +TEST_F(NativeVsyncTest, OH_NativeVSync_RequestFrame003) +{ + OH_NativeVSync_FrameCallback callback = OnVSync; + ASSERT_EQ(OH_NativeVSync_RequestFrame(native_vsync, callback, nullptr), 0); +} + +/* +* Function: OH_NativeVSync_Destroy +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeVSync_Destroy by abnormal input +* 2. check ret + */ +TEST_F(NativeVsyncTest, OH_NativeVSync_Destroy001) +{ + OH_NativeVSync_Destroy(nullptr); +} + +/* +* Function: OH_NativeVSync_Destroy +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call OH_NativeVSync_Destroy +* 2. check ret + */ +TEST_F(NativeVsyncTest, OH_NativeVSync_Destroy002) +{ + OH_NativeVSync_Destroy(native_vsync); +} +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/display_server/rosen/modules/render_service_base/ft_build/BUILD.gn b/display_server/rosen/modules/render_service_base/ft_build/BUILD.gn index 27f584a..157e5ba 100644 --- a/display_server/rosen/modules/render_service_base/ft_build/BUILD.gn +++ b/display_server/rosen/modules/render_service_base/ft_build/BUILD.gn @@ -157,7 +157,7 @@ ft_source_set("render_service_base_src") { public_configs = [ ":render_service_base_public_config", ] - deps = [ + public_deps = [ "../src/platform/fangtian:rosen_fangtian_sources", ] @@ -182,7 +182,7 @@ ft_source_set("render_service_base_src") { "$display_server_root/interfaces/inner_api/common", ] - deps += [ + deps = [ "//build/gn/configs/system_libs:c_utils", "//build/gn/configs/system_libs:ipc_core", "//build/gn/configs/system_libs:hitrace_meter", @@ -191,7 +191,7 @@ ft_source_set("render_service_base_src") { "//build/gn/configs/system_libs:image", ] - public_deps = [ + public_deps += [ "$display_server_root/utils/sandbox/ft_build:sandbox_utils", "$display_server_root/utils/sync_fence/ft_build:sync_fence", ] diff --git a/display_server/rosen/modules/render_service_client/test/ft_build/BUILD.gn b/display_server/rosen/modules/render_service_client/test/ft_build/BUILD.gn index 698038c..c904166 100644 --- a/display_server/rosen/modules/render_service_client/test/ft_build/BUILD.gn +++ b/display_server/rosen/modules/render_service_client/test/ft_build/BUILD.gn @@ -14,6 +14,16 @@ import("//build/gn/fangtian.gni") import("//display_server/ft_build/ds_config.gni") +group("test") { + testonly = true + + deps = [ + ":render_service_client_rs_demo", + ":render_service_client_gravity_demo", + "../unittest/ft_build:unittest", + ] +} + ft_executable("render_service_client_rs_demo") { sources = [ "../render_service_client_rs_demo.cpp" ] diff --git a/display_server/rosen/modules/render_service_client/test/unittest/ft_build/BUILD.gn b/display_server/rosen/modules/render_service_client/test/unittest/ft_build/BUILD.gn new file mode 100644 index 0000000..ce07b60 --- /dev/null +++ b/display_server/rosen/modules/render_service_client/test/unittest/ft_build/BUILD.gn @@ -0,0 +1,64 @@ +# Copyright (c) 2023 Huawei Technologies Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/gn/fangtian.gni") + +group("unittest") { + testonly = true + + deps = [ + ":RSInterfacesTest" + ] +} + +config("rs_client_test_common_public_config") { + include_dirs = [ + "//display_server/frameworks/surface/include", + "//display_server/rosen/modules/render_service_client/core", + ] + + cflags = [ + "-Wall", + "-Werror", + "-g3", + # "-Dprivate=public", + # "-Dprotected=public", + ] +} + +ft_static_library("rs_client_test_common") { + visibility = [ ":*" ] + testonly = true + + public_configs = [ ":rs_client_test_common_public_config" ] + + public_deps = [ + "//display_server/ft_build:libsurface", + "//display_server/rosen/modules/render_service_base/ft_build:librender_service_base", + "//display_server/rosen/modules/render_service_client/ft_build:librender_service_client", + + "//build/gn/configs/system_libs:hilog", + "//build/gn/configs/system_libs:c_utils", + "//build/gn/configs/system_libs:samgr", + "//build/gn/configs/system_libs:gtest", + ] +} + +ft_executable("RSInterfacesTest") { + testonly = true + + sources = [ "rs_interfaces_test.cpp" ] + + deps = [ ":rs_client_test_common" ] +} + diff --git a/display_server/rosen/modules/render_service_client/test/unittest/ft_build/rs_interfaces_test.cpp b/display_server/rosen/modules/render_service_client/test/unittest/ft_build/rs_interfaces_test.cpp new file mode 100644 index 0000000..f3ce750 --- /dev/null +++ b/display_server/rosen/modules/render_service_client/test/unittest/ft_build/rs_interfaces_test.cpp @@ -0,0 +1,934 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +#include "transaction/rs_interfaces.h" + +namespace OHOS { +namespace Rosen { +class RSInterfacesTest : public testing::Test { +public: + static constexpr HiviewDFX::HiLogLabel LOG_LABEL = { LOG_CORE, 0, "RSInterfacesTest" }; + + static void SetUpTestCase() + { + rsInterfaces = &(RSInterfaces::GetInstance()); + } + + static void TearDownTestCase() + { + rsInterfaces = nullptr; + } + + static inline RSInterfaces* rsInterfaces = nullptr; +}; + +/* +* Function: GetDefaultScreenId +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetDefaultScreenId +* 2. check ret +*/ +TEST_F(RSInterfacesTest, GetDefaultScreenId) +{ + ScreenId defaultScreenId = rsInterfaces->GetDefaultScreenId(); + EXPECT_NE(defaultScreenId, INVALID_SCREEN_ID); +} + +/* +* Function: CreateVirtualScreen +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call CreateVirtualScreen, use normal parameters. +* 2. check ret +*/ +TEST_F(RSInterfacesTest, CreateVirtualScreen001) +{ + auto csurface = Surface::CreateSurfaceAsConsumer(); + EXPECT_NE(csurface, nullptr); + auto producer = csurface->GetProducer(); + auto psurface = Surface::CreateSurfaceAsProducer(producer); + EXPECT_NE(csurface, nullptr); + + ScreenId virtualScreenId = rsInterfaces->CreateVirtualScreen( + "virtual0", 320, 180, psurface, INVALID_SCREEN_ID, -1); + EXPECT_NE(virtualScreenId, INVALID_SCREEN_ID); + + rsInterfaces->RemoveVirtualScreen(virtualScreenId); +} + +/* +* Function: CreateVirtualScreen +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call CreateVirtualScreen, use nullptr surface +* 2. check ret +*/ +TEST_F(RSInterfacesTest, CreateVirtualScreen002) +{ + ScreenId virtualScreenId = rsInterfaces->CreateVirtualScreen( + "virtual0", 320, 180, nullptr, INVALID_SCREEN_ID, -1); + EXPECT_NE(virtualScreenId, INVALID_SCREEN_ID); + rsInterfaces->RemoveVirtualScreen(virtualScreenId); +} + +/* +* Function: CreateVirtualScreen +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call CreateVirtualScreen twice with the same surface +* 2. check ret +*/ +TEST_F(RSInterfacesTest, CreateVirtualScreen003) +{ + auto csurface = Surface::CreateSurfaceAsConsumer(); + EXPECT_NE(csurface, nullptr); + auto producer = csurface->GetProducer(); + auto psurface = Surface::CreateSurfaceAsProducer(producer); + EXPECT_NE(csurface, nullptr); + + ScreenId virtualScreenId1 = rsInterfaces->CreateVirtualScreen( + "virtual1", 320, 180, psurface, INVALID_SCREEN_ID, -1); + EXPECT_NE(virtualScreenId1, INVALID_SCREEN_ID); + + ScreenId virtualScreenId2 = rsInterfaces->CreateVirtualScreen( + "virtual2", 320, 180, psurface, INVALID_SCREEN_ID, -1); + EXPECT_EQ(virtualScreenId2, INVALID_SCREEN_ID); + + rsInterfaces->RemoveVirtualScreen(virtualScreenId1); +} + +/* +* Function: CreateVirtualScreen +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call CreateVirtualScreen with other get/set funcs +* 2. check ret +*/ +TEST_F(RSInterfacesTest, CreateVirtualScreen004) +{ + ScreenId virtualScreenId = rsInterfaces->CreateVirtualScreen( + "virtual0", 320, 180, nullptr, INVALID_SCREEN_ID, -1); + EXPECT_NE(virtualScreenId, INVALID_SCREEN_ID); + + auto supportedScreenModes = rsInterfaces->GetScreenSupportedModes(virtualScreenId); + EXPECT_EQ(supportedScreenModes.size(), 0); + + rsInterfaces->SetScreenActiveMode(virtualScreenId, 0); + auto modeInfo = rsInterfaces->GetScreenActiveMode(virtualScreenId); + EXPECT_EQ(modeInfo.GetScreenModeId(), -1); + + rsInterfaces->SetScreenPowerStatus(virtualScreenId, ScreenPowerStatus::POWER_STATUS_ON); + usleep(50000); // wait 50000us to ensure SetScreenPowerStatus done. + auto powerStatus = rsInterfaces->GetScreenPowerStatus(virtualScreenId); + EXPECT_EQ(powerStatus, ScreenPowerStatus::INVALID_POWER_STATUS); + + auto screenCapability = rsInterfaces->GetScreenCapability(virtualScreenId); + EXPECT_EQ(screenCapability.GetPhyWidth(), 0); + EXPECT_EQ(screenCapability.GetName(), "virtual0"); + + auto backLight = rsInterfaces->GetScreenBacklight(virtualScreenId); + EXPECT_EQ(backLight, -1); + rsInterfaces->RemoveVirtualScreen(virtualScreenId); +} + +/* +* Function: GetScreenSupportedModes +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetScreenSupportedModes +* 2. check ret +*/ +TEST_F(RSInterfacesTest, GetScreenSupportedModes001) +{ + auto screenId = rsInterfaces->GetDefaultScreenId(); + EXPECT_NE(screenId, INVALID_SCREEN_ID); + + auto supportedScreenModes = rsInterfaces->GetScreenSupportedModes(screenId); + EXPECT_GT(supportedScreenModes.size(), 0); +} + +/* +* Function: GetScreenSupportedModes +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetScreenSupportedModes with INVALID_SCREEN_ID +* 2. check ret +*/ +TEST_F(RSInterfacesTest, GetScreenSupportedModes002) +{ + auto supportedScreenModes = rsInterfaces->GetScreenSupportedModes(INVALID_SCREEN_ID); + EXPECT_EQ(supportedScreenModes.size(), 0); +} + +/* +* Function: SetScreenActiveMode +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetScreenActiveMode +* 2. check +*/ +TEST_F(RSInterfacesTest, SetScreenActiveMode001) +{ + auto screenId = rsInterfaces->GetDefaultScreenId(); + EXPECT_NE(screenId, INVALID_SCREEN_ID); + + rsInterfaces->SetScreenActiveMode(screenId, 0); + auto modeInfo = rsInterfaces->GetScreenActiveMode(screenId); + EXPECT_EQ(modeInfo.GetScreenModeId(), 0); +} + +/* +* Function: SetScreenActiveMode +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetScreenActiveMode +* 2. check +*/ +TEST_F(RSInterfacesTest, SetScreenActiveMode002) +{ + auto screenId = rsInterfaces->GetDefaultScreenId(); + EXPECT_NE(screenId, INVALID_SCREEN_ID); + + auto supportedScreenModes = rsInterfaces->GetScreenSupportedModes(screenId); + EXPECT_GT(supportedScreenModes.size(), 0); + + rsInterfaces->SetScreenActiveMode(screenId, 0); + auto modeInfo = rsInterfaces->GetScreenActiveMode(screenId); + EXPECT_EQ(modeInfo.GetScreenModeId(), 0); +} + +/* +* Function: GetScreenActiveMode +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetScreenActiveMode +* 2. check +*/ +TEST_F(RSInterfacesTest, GetScreenActiveMode001) +{ + auto screenId = rsInterfaces->GetDefaultScreenId(); + EXPECT_NE(screenId, INVALID_SCREEN_ID); + + rsInterfaces->SetScreenActiveMode(screenId, 0); + auto modeInfo = rsInterfaces->GetScreenActiveMode(screenId); + EXPECT_EQ(modeInfo.GetScreenModeId(), 0); + EXPECT_NE(modeInfo.GetScreenRefreshRate(), 0); + EXPECT_NE(modeInfo.GetScreenHeight(), -1); + EXPECT_NE(modeInfo.GetScreenWidth(), -1); +} + +/* +* Function: GetScreenActiveMode +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetScreenActiveMode with INVALID_SCREEN_ID +* 2. check +*/ +TEST_F(RSInterfacesTest, GetScreenActiveMode002) +{ + auto modeInfo = rsInterfaces->GetScreenActiveMode(INVALID_SCREEN_ID); + EXPECT_EQ(modeInfo.GetScreenHeight(), -1); + EXPECT_EQ(modeInfo.GetScreenWidth(), -1); +} + +/* +* Function: SetScreenPowerStatus +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetScreenPowerStatus with INVALID_SCREEN_ID +* 2. check +*/ +TEST_F(RSInterfacesTest, SetScreenPowerStatus001) +{ + auto screenId = rsInterfaces->GetDefaultScreenId(); + EXPECT_NE(screenId, INVALID_SCREEN_ID); + + rsInterfaces->SetScreenPowerStatus(INVALID_SCREEN_ID, ScreenPowerStatus::POWER_STATUS_STANDBY); +} + +/* +* Function: SetScreenPowerStatus +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetScreenPowerStatus with value of POWER_STATUS_ON +* 2. check +*/ +TEST_F(RSInterfacesTest, SetScreenPowerStatus002) +{ + auto screenId = rsInterfaces->GetDefaultScreenId(); + EXPECT_NE(screenId, INVALID_SCREEN_ID); + + rsInterfaces->SetScreenPowerStatus(screenId, ScreenPowerStatus::POWER_STATUS_ON); + usleep(50000); // wait 50000us to ensure SetScreenPowerStatus done. + auto powerStatus = rsInterfaces->GetScreenPowerStatus(screenId); + EXPECT_EQ(powerStatus, ScreenPowerStatus::POWER_STATUS_ON); +} + +/* +* Function: GetScreenPowerStatus +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetScreenPowerStatus when set POWER_STATUS_ON +* 2. check +*/ +TEST_F(RSInterfacesTest, GetScreenPowerStatus001) +{ + auto screenId = rsInterfaces->GetDefaultScreenId(); + EXPECT_NE(screenId, INVALID_SCREEN_ID); + + rsInterfaces->SetScreenPowerStatus(screenId, ScreenPowerStatus::POWER_STATUS_ON); + usleep(50000); // wait 50000us to ensure SetScreenPowerStatus done. + auto powerStatus = rsInterfaces->GetScreenPowerStatus(screenId); + EXPECT_EQ(powerStatus, ScreenPowerStatus::POWER_STATUS_ON); +} + +/* +* Function: GetScreenPowerStatus +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetScreenPowerStatus when INVALID screenID +* 2. check +*/ +TEST_F(RSInterfacesTest, GetScreenPowerStatus002) +{ + auto powerStatus = rsInterfaces->GetScreenPowerStatus(INVALID_SCREEN_ID); + EXPECT_EQ(powerStatus, ScreenPowerStatus::INVALID_POWER_STATUS); +} + +/* +* Function: GetScreenCapability +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetScreenCapability +* 2. check +*/ +TEST_F(RSInterfacesTest, GetScreenCapability001) +{ + auto screenId = rsInterfaces->GetDefaultScreenId(); + EXPECT_NE(screenId, INVALID_SCREEN_ID); + + auto screenCapability = rsInterfaces->GetScreenCapability(screenId); + EXPECT_NE(screenCapability.GetType(), DISP_INVALID); +} + +/* +* Function: GetScreenCapability +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetScreenCapability with INVALID_SCREEN_ID +* 2. check +*/ +TEST_F(RSInterfacesTest, GetScreenCapability002) +{ + auto screenCapability = rsInterfaces->GetScreenCapability(INVALID_SCREEN_ID); + EXPECT_EQ(screenCapability.GetPhyWidth(), 0); + EXPECT_EQ(screenCapability.GetPhyHeight(), 0); +} + +/* +* Function: GetScreenData +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetScreenData +* 2. check +*/ +TEST_F(RSInterfacesTest, GetScreenData001) +{ + auto screenId = rsInterfaces->GetDefaultScreenId(); + EXPECT_NE(screenId, INVALID_SCREEN_ID); + + auto screenData = rsInterfaces->GetScreenData(screenId); + EXPECT_GT(screenData.GetSupportModeInfo().size(), 0); + + auto screenCapability = screenData.GetCapability(); + EXPECT_NE(screenCapability.GetType(), DISP_INVALID); + + auto modeInfo = screenData.GetActivityModeInfo(); + EXPECT_NE(modeInfo.GetScreenModeId(), -1); + EXPECT_NE(modeInfo.GetScreenRefreshRate(), 0); + EXPECT_NE(modeInfo.GetScreenHeight(), -1); + EXPECT_NE(modeInfo.GetScreenWidth(), -1); +} + +/* +* Function: GetScreenData +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetScreenData with INVALID_SCREEN_ID +* 2. check +*/ +TEST_F(RSInterfacesTest, GetScreenData002) +{ + auto screenData = rsInterfaces->GetScreenData(INVALID_SCREEN_ID); + EXPECT_EQ(screenData.GetSupportModeInfo().size(), 0); + + auto screenCapability = screenData.GetCapability(); + EXPECT_EQ(screenCapability.GetPhyWidth(), 0); + EXPECT_EQ(screenCapability.GetPhyHeight(), 0); + + auto modeInfo = screenData.GetActivityModeInfo(); + EXPECT_EQ(modeInfo.GetScreenHeight(), -1); + EXPECT_EQ(modeInfo.GetScreenWidth(), -1); +} + +/* +* Function: SetScreenBacklight +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetScreenBacklight with value:50 +* 2. check +*/ +// TEST_F(RSInterfacesTest, SetScreenBacklight001) +// { +// auto screenId = rsInterfaces->GetDefaultScreenId(); +// EXPECT_NE(screenId, INVALID_SCREEN_ID); + +// rsInterfaces->SetScreenBacklight(screenId, 50); +// auto backLight = rsInterfaces->GetScreenBacklight(screenId); +// EXPECT_EQ(backLight, 50); +// } + +/* +* Function: SetScreenBacklight +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetScreenBacklight with value:100 +* 2. check +*/ +// TEST_F(RSInterfacesTest, SetScreenBacklight002) +// { +// auto screenId = rsInterfaces->GetDefaultScreenId(); +// EXPECT_NE(screenId, INVALID_SCREEN_ID); + +// rsInterfaces->SetScreenBacklight(screenId, 100); +// auto backLight = rsInterfaces->GetScreenBacklight(screenId); +// EXPECT_EQ(backLight, 100); +// } + +/* +* Function: GetScreenBacklight +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetScreenBacklight with value: 50 +* 2. check +*/ +// TEST_F(RSInterfacesTest, GetScreenBacklight001) +// { +// auto screenId = rsInterfaces->GetDefaultScreenId(); +// EXPECT_NE(screenId, INVALID_SCREEN_ID); + +// rsInterfaces->SetScreenBacklight(screenId, 50); +// auto backLight = rsInterfaces->GetScreenBacklight(screenId); +// EXPECT_EQ(backLight, 50); +// } + +/* +* Function: GetScreenBacklight +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetScreenBacklight INVALID_SCREEN_ID +* 2. check +*/ +// TEST_F(RSInterfacesTest, GetScreenBacklight002) +// { +// auto backLight = rsInterfaces->GetScreenBacklight(INVALID_SCREEN_ID); +// EXPECT_EQ(backLight, -1); +// } + +/* +* Function: SetScreenChangeCallback +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetScreenChangeCallback +* 2. wait 2s and check the ret +*/ +TEST_F(RSInterfacesTest, SetScreenChangeCallback) +{ + ScreenId screenId = INVALID_SCREEN_ID; + ScreenEvent screenEvent = ScreenEvent::UNKNOWN; + bool callbacked = false; + auto callback = [&screenId, &screenEvent, &callbacked](ScreenId id, ScreenEvent event) { + screenId = id; + screenEvent = event; + callbacked = true; + }; + int32_t status = rsInterfaces->SetScreenChangeCallback(callback); + EXPECT_EQ(status, StatusCode::SUCCESS); + sleep(2); // wait 2s to check if the callback returned. + if (status == StatusCode::SUCCESS) { + EXPECT_NE(screenId, INVALID_SCREEN_ID); + EXPECT_NE(screenEvent, ScreenEvent::UNKNOWN); + } else { + EXPECT_EQ(screenId, INVALID_SCREEN_ID); + EXPECT_EQ(screenEvent, ScreenEvent::UNKNOWN); + } +} + +/* +* Function: GetScreenSupportedColorGamuts +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetScreenSupportedColorGamuts with INVALID_SCREEN_ID +* 2. check ret +*/ +// TEST_F(RSInterfacesTest, GetScreenSupportedColorGamuts002) +// { +// std::vector modes; +// int ret = rsInterfaces->GetScreenSupportedColorGamuts(INVALID_SCREEN_ID, modes); +// EXPECT_EQ(ret, StatusCode::SCREEN_NOT_FOUND); +// } + +/* +* Function: GetScreenSupportedMetaDataKeys +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetScreenSupportedMetaDataKeys +* 2. check ret +* @tc.require: IssueI5KGK4 +*/ +TEST_F(RSInterfacesTest, GetScreenSupportedMetaDataKeys001) +{ + auto screenId = rsInterfaces->GetDefaultScreenId(); + EXPECT_NE(screenId, INVALID_SCREEN_ID); + std::vector keys; + int ret = rsInterfaces->GetScreenSupportedMetaDataKeys(screenId, keys); + EXPECT_EQ(ret, StatusCode::SUCCESS); + EXPECT_EQ(keys[0], ScreenHDRMetadataKey::MATAKEY_RED_PRIMARY_X); // ScreenHDRMetadataKey now is mock data. +} + +/* +* Function: GetScreenSupportedMetaDataKeys +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetScreenSupportedMetaDataKeys with INVALID_SCREEN_ID +* 2. check ret +* @tc.require: IssueI5KGK4 +*/ +TEST_F(RSInterfacesTest, GetScreenSupportedMetaDataKeys002) +{ + std::vector keys; + int ret = rsInterfaces->GetScreenSupportedMetaDataKeys(INVALID_SCREEN_ID, keys); + EXPECT_EQ(ret, StatusCode::SCREEN_NOT_FOUND); +} + +/* +* Function: GetScreenColorGamut +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetScreenColorGamut with INVALID_SCREEN_ID +* 2. check ret +*/ +// TEST_F(RSInterfacesTest, GetScreenColorGamut002) +// { +// ScreenColorGamut mode = ScreenColorGamut::COLOR_GAMUT_INVALID; +// int ret = rsInterfaces->GetScreenColorGamut(INVALID_SCREEN_ID, mode); +// EXPECT_EQ(ret, StatusCode::SCREEN_NOT_FOUND); +// } + +/* +* Function: SetScreenColorGamut +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetScreenColorGamut with INVALID_SCREEN_ID +* 2. check ret +*/ +// TEST_F(RSInterfacesTest, SetScreenColorGamut002) +// { +// int ret = rsInterfaces->SetScreenColorGamut(INVALID_SCREEN_ID, 0); +// EXPECT_EQ(ret, StatusCode::SCREEN_NOT_FOUND); +// } + +/* +* Function: SetScreenGamutMap +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetScreenGamutMap with INVALID_SCREEN_ID +* 2. check ret +*/ +// TEST_F(RSInterfacesTest, SetScreenGamutMap002) +// { +// ScreenGamutMap gamutMap = ScreenGamutMap::GAMUT_MAP_CONSTANT; +// int ret = rsInterfaces->SetScreenGamutMap(INVALID_SCREEN_ID, gamutMap); +// EXPECT_EQ(ret, StatusCode::SCREEN_NOT_FOUND); +// } + +/* +* Function: GetScreenGamutMap +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetScreenGamutMap with INVALID_SCREEN_ID +* 2. check ret +*/ +// TEST_F(RSInterfacesTest, GetScreenGamutMap002) +// { +// ScreenGamutMap gamutMap = ScreenGamutMap::GAMUT_MAP_CONSTANT; +// int ret = rsInterfaces->GetScreenGamutMap(INVALID_SCREEN_ID, gamutMap); +// EXPECT_EQ(ret, StatusCode::SCREEN_NOT_FOUND); +// } + +/* +* Function: GetScreenHDRCapability +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetScreenHDRCapability +* 2. check ret +* @tc.require: IssueI5KGK4 +*/ +TEST_F(RSInterfacesTest, GetScreenHDRCapability001) +{ + auto screenId = rsInterfaces->GetDefaultScreenId(); + EXPECT_NE(screenId, INVALID_SCREEN_ID); + + RSScreenHDRCapability hdrCapability; + int ret = rsInterfaces->GetScreenHDRCapability(screenId, hdrCapability); + EXPECT_EQ(ret, StatusCode::SUCCESS); + EXPECT_EQ(hdrCapability.GetMaxLum(), 1000); // maxLum now is mock data +} + +/* +* Function: GetScreenHDRCapability +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetScreenHDRCapability with INVALID_SCREEN_ID +* 2. check ret +* @tc.require: IssueI5KGK4 +*/ +TEST_F(RSInterfacesTest, GetScreenHDRCapability002) +{ + RSScreenHDRCapability hdrCapability; + int ret = rsInterfaces->GetScreenHDRCapability(INVALID_SCREEN_ID, hdrCapability); + EXPECT_EQ(ret, StatusCode::SCREEN_NOT_FOUND); +} + +/* +* Function: GetScreenType +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetScreenType +* 2. check ret +*/ +TEST_F(RSInterfacesTest, GetScreenType001) +{ + auto screenId = rsInterfaces->GetDefaultScreenId(); + EXPECT_NE(screenId, INVALID_SCREEN_ID); + + RSScreenType type; + int ret = rsInterfaces->GetScreenType(screenId, type); + EXPECT_EQ(ret, StatusCode::SUCCESS); +} + +/* +* Function: GetScreenType +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetScreenType with INVALID_SCREEN_ID +* 2. check ret +*/ +TEST_F(RSInterfacesTest, GetScreenType002) +{ + RSScreenType type; + int ret = rsInterfaces->GetScreenType(INVALID_SCREEN_ID, type); + EXPECT_EQ(ret, StatusCode::SCREEN_NOT_FOUND); +} + +/* +* Function: SetVirtualScreenResolution/GetVirtualScreenResolution +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. Call CreateVirtualScreen, use normal parameters. +* 2. Use SetVirtualScreenResolution to change the width and height of virtualScreen +* 3. Use GetVirtualScreenResolution to get current width and height of virtualScreen +* 4. Check current width and height of virtualScreen +*/ +TEST_F(RSInterfacesTest, SetVirtualScreenResolution001) +{ + auto csurface = Surface::CreateSurfaceAsConsumer(); + EXPECT_NE(csurface, nullptr); + auto producer = csurface->GetProducer(); + auto psurface = Surface::CreateSurfaceAsProducer(producer); + uint32_t defaultWidth = 720; + uint32_t defaultHeight = 1280; + uint32_t newWidth = 1920; + uint32_t newHeight = 1080; + EXPECT_NE(psurface, nullptr); + + ScreenId virtualScreenId = rsInterfaces->CreateVirtualScreen( + "virtual5", defaultWidth, defaultHeight, psurface, INVALID_SCREEN_ID, -1); + EXPECT_NE(virtualScreenId, INVALID_SCREEN_ID); + + auto curVirtualScreenResolution = rsInterfaces->GetVirtualScreenResolution(virtualScreenId); + EXPECT_EQ(curVirtualScreenResolution.GetVirtualScreenWidth(), defaultWidth); + EXPECT_EQ(curVirtualScreenResolution.GetVirtualScreenHeight(), defaultHeight); + + rsInterfaces->SetVirtualScreenResolution(virtualScreenId, newWidth, newHeight); + + curVirtualScreenResolution = rsInterfaces->GetVirtualScreenResolution(virtualScreenId); + EXPECT_EQ(curVirtualScreenResolution.GetVirtualScreenWidth(), newWidth); + EXPECT_EQ(curVirtualScreenResolution.GetVirtualScreenHeight(), newHeight); + + rsInterfaces->RemoveVirtualScreen(virtualScreenId); +} + +/* +* Function: GetAllScreenIds +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call GetAllScreenIds +* 2. check vector size +*/ +TEST_F(RSInterfacesTest, GetAllScreenIds) +{ + std::vector ids = rsInterfaces->GetAllScreenIds(); + int32_t size = ids.size(); + EXPECT_GT(ids.size(), 0); + auto csurface = Surface::CreateSurfaceAsConsumer(); + EXPECT_NE(csurface, nullptr); + auto producer = csurface->GetProducer(); + auto psurface = Surface::CreateSurfaceAsProducer(producer); + uint32_t defaultWidth = 720; + uint32_t defaultHeight = 1280; + EXPECT_NE(psurface, nullptr); + + ScreenId virtualScreenId = rsInterfaces->CreateVirtualScreen( + "virtual6", defaultWidth, defaultHeight, psurface, INVALID_SCREEN_ID, -1); + EXPECT_NE(virtualScreenId, INVALID_SCREEN_ID); + ids = rsInterfaces->GetAllScreenIds(); + EXPECT_EQ(size + 1, ids.size()); +} + +/* +* Function: SetScreenSkipFrameInterval +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetScreenSkipFrameInterval with invalid parameters and check ret +*/ +TEST_F(RSInterfacesTest, SetScreenSkipFrameInterval001) +{ + ScreenId screenId = INVALID_SCREEN_ID; + uint32_t skipFrameInterval = 1; + int32_t ret = rsInterfaces->SetScreenSkipFrameInterval(screenId, skipFrameInterval); + EXPECT_EQ(ret, StatusCode::SCREEN_NOT_FOUND); +} + +/* +* Function: SetScreenSkipFrameInterval +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetScreenSkipFrameInterval with invalid parameters and check ret +*/ +TEST_F(RSInterfacesTest, SetScreenSkipFrameInterval002) +{ + ScreenId screenId = rsInterfaces->GetDefaultScreenId(); + EXPECT_NE(screenId, INVALID_SCREEN_ID); + uint32_t skipFrameInterval = 0; + int32_t ret = rsInterfaces->SetScreenSkipFrameInterval(screenId, skipFrameInterval); + EXPECT_EQ(ret, StatusCode::INVALID_ARGUMENTS); +} + +/* +* Function: SetScreenSkipFrameInterval +* Type: Function +* Rank: Important(2) +* EnvConditions: N/A +* CaseDescription: 1. call SetScreenSkipFrameInterval with invalid parameters and check ret +*/ +TEST_F(RSInterfacesTest, SetScreenSkipFrameInterval003) +{ + ScreenId screenId = rsInterfaces->GetDefaultScreenId(); + EXPECT_NE(screenId, INVALID_SCREEN_ID); + uint32_t skipFrameInterval = 100; // for test + int32_t ret = rsInterfaces->SetScreenSkipFrameInterval(screenId, skipFrameInterval); + EXPECT_EQ(ret, StatusCode::INVALID_ARGUMENTS); +} + +/* +* Function: SetScreenSkipFrameInterval +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetScreenSkipFrameInterval with valid parameters and check ret +*/ +TEST_F(RSInterfacesTest, SetScreenSkipFrameInterval004) +{ + ScreenId screenId = rsInterfaces->GetDefaultScreenId(); + EXPECT_NE(screenId, INVALID_SCREEN_ID); + float skipFrameInterval = 2.1; // for test + int32_t ret = rsInterfaces->SetScreenSkipFrameInterval(screenId, skipFrameInterval); + EXPECT_EQ(ret, StatusCode::SUCCESS); +} + +/* +* Function: SetScreenSkipFrameInterval +* Type: Function +* Rank: Important(1) +* EnvConditions: N/A +* CaseDescription: 1. call SetScreenSkipFrameInterval with valid parameters and check ret +*/ +TEST_F(RSInterfacesTest, SetScreenSkipFrameInterval005) +{ + ScreenId screenId = rsInterfaces->GetDefaultScreenId(); + EXPECT_NE(screenId, INVALID_SCREEN_ID); + uint32_t skipFrameInterval = 1; + int32_t ret = rsInterfaces->SetScreenSkipFrameInterval(screenId, skipFrameInterval); + ASSERT_EQ(ret, StatusCode::SUCCESS); +} + +/* + * @tc.name: ScreenGamutMap_001 + * @tc.desc: Test SetScreenGamutMap And GetScreenGamutMap + * @tc.type: FUNC + * @tc.require: issueI60RFZ + */ +// TEST_F(RSInterfacesTest, ScreenGamutMap_001) +// { +// ScreenId defaultScreenId = rsInterfaces->GetDefaultScreenId(); +// ScreenGamutMap mode = ScreenGamutMap::GAMUT_MAP_CONSTANT; +// uint32_t statusMode = rsInterfaces->SetScreenGamutMap(defaultScreenId, mode); +// ASSERT_EQ(statusMode, StatusCode::HDI_ERROR); +// statusMode = rsInterfaces->GetScreenGamutMap(defaultScreenId, mode); +// ASSERT_EQ(statusMode, StatusCode::HDI_ERROR); +// } + +/* + * @tc.name: RegisterOcclusionChangeCallback Test + * @tc.desc: RegisterOcclusionChangeCallback Test + * @tc.type: FUNC + * @tc.require: + */ +TEST_F(RSInterfacesTest, RegisterOcclusionChangeCallback_Test) +{ + ASSERT_NE(rsInterfaces, nullptr); + OcclusionChangeCallback cb = [](std::shared_ptr data){}; + int32_t ret = rsInterfaces->RegisterOcclusionChangeCallback(cb); + ASSERT_EQ(ret, 0); +} + +/* + * @tc.name: UnRegisterOcclusionChangeCallback Test + * @tc.desc: UnRegisterOcclusionChangeCallback Test + * @tc.type: FUNC + * @tc.require: + */ +TEST_F(RSInterfacesTest, UnRegisterOcclusionChangeCallback_Test) +{ + ASSERT_NE(rsInterfaces, nullptr); + OcclusionChangeCallback cb = [](std::shared_ptr data){}; + int32_t ret = rsInterfaces->UnRegisterOcclusionChangeCallback(cb); + ASSERT_EQ(ret, 0); +} + +/* + * @tc.name: SetRenderModeChangeCallback Test + * @tc.desc: SetRenderModeChangeCallback Test + * @tc.type: FUNC + * @tc.require: + */ +TEST_F(RSInterfacesTest, SetRenderModeChangeCallback_Test) +{ + ASSERT_NE(rsInterfaces, nullptr); + RenderModeChangeCallback cb = [](bool flag){}; + int32_t ret = rsInterfaces->SetRenderModeChangeCallback(cb); + ASSERT_EQ(ret, 0); +} + +/* + * @tc.name: UpdateRenderMode True Test + * @tc.desc: UpdateRenderMode True Test + * @tc.type: FUNC + * @tc.require: + */ +TEST_F(RSInterfacesTest, UpdateRenderMode_True) +{ + ASSERT_NE(rsInterfaces, nullptr); + rsInterfaces->UpdateRenderMode(true); +} + +/* + * @tc.name: UpdateRenderMode False Test + * @tc.desc: UpdateRenderMode False Test + * @tc.type: FUNC + * @tc.require: + */ +TEST_F(RSInterfacesTest, UpdateRenderMode_False) +{ + ASSERT_NE(rsInterfaces, nullptr); + rsInterfaces->UpdateRenderMode(false); +} + +/* + * @tc.name: SetVirtualScreenSurface Test a notfound id + * @tc.desc: SetVirtualScreenSurface Test a notfound id + * @tc.type: FUNC + * @tc.require: + */ +TEST_F(RSInterfacesTest, SetVirtualScreenSurface_Test) +{ + ASSERT_NE(rsInterfaces, nullptr); + auto csurface = Surface::CreateSurfaceAsConsumer(); + ASSERT_NE(csurface, nullptr); + auto producer = csurface->GetProducer(); + auto psurface = Surface::CreateSurfaceAsProducer(producer); + ASSERT_NE(psurface, nullptr); + + int32_t ret = rsInterfaces->SetVirtualScreenSurface(123, psurface); + ASSERT_EQ(ret, 0); +} +} // namespace Rosen +} // namespace OHOS diff --git a/display_server/rosen/test/render_service/render_service_base/ft_build/BUILD.gn b/display_server/rosen/test/render_service/render_service_base/ft_build/BUILD.gn new file mode 100644 index 0000000..7ce9b35 --- /dev/null +++ b/display_server/rosen/test/render_service/render_service_base/ft_build/BUILD.gn @@ -0,0 +1,54 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/gn/fangtian.gni") +import("//display_server/ft_build/ds_config.gni") + +group("unittest") { + testonly = true + + deps = [ + ":RSRenderServiceBaseTransactionTest" + ] +} + +ft_executable("RSRenderServiceBaseTransactionTest") { + sources = [ + "transaction/rs_transaction_proxy_test.cpp", + ] + + include_dirs = [ + # "$ace_root", + "//display_server/rosen/modules/render_service_base", + "//display_server/interfaces/inner_api/common", + "//display_server/rosen/modules/render_service_base/include", + "//display_server/rosen/include", + "//display_server/rosen/test/include", + # "//third_party/flutter/skia/src", + ] + + configs = [ + # ":transaction_test", + # "$ace_root:ace_test_config", + "//display_server/rosen/modules/render_service_base/ft_build:render_service_base_public_config", + ] + + deps = [ + "//display_server/rosen/modules/render_service_base/ft_build:render_service_base_src", + + "//build/gn/configs/system_libs:skia", + "//build/gn/configs/system_libs:gtest", + "//build/gn/configs/system_libs:c_utils", + "//build/gn/configs/system_libs:ipc_core", + ] +} diff --git a/display_server/rosen/test/render_service/render_service_base/ft_build/transaction/rs_transaction_proxy_test.cpp b/display_server/rosen/test/render_service/render_service_base/ft_build/transaction/rs_transaction_proxy_test.cpp new file mode 100644 index 0000000..628ece0 --- /dev/null +++ b/display_server/rosen/test/render_service/render_service_base/ft_build/transaction/rs_transaction_proxy_test.cpp @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, Hardware + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "command/rs_command.h" +#include "transaction/rs_render_service_client.h" +#include "transaction/rs_transaction_proxy.h" + +namespace OHOS { +namespace Rosen { +class RSTransactionProxyTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; + +void RSTransactionProxyTest::SetUpTestCase() {} +void RSTransactionProxyTest::TearDownTestCase() {} +void RSTransactionProxyTest::SetUp() {} +void RSTransactionProxyTest::TearDown() {} + +/** + * @tc.name: SetRenderThreadClient001 + * @tc.desc: test + * @tc.type:FUNC + * @tc.require: + */ +TEST_F(RSTransactionProxyTest, SetRenderThreadClient001) +{ + auto renderServiceClient = std::make_shared(); + ASSERT_NE(renderServiceClient, nullptr); + RSTransactionProxy::GetInstance()->SetRenderServiceClient(renderServiceClient); +} + +/** + * @tc.name: SetRenderThreadClient002 + * @tc.desc: test + * @tc.type:FUNC + * @tc.require: + */ +TEST_F(RSTransactionProxyTest, SetRenderThreadClient002) +{ + auto renderServiceClient = nullptr; + ASSERT_EQ(renderServiceClient, nullptr); + RSTransactionProxy::GetInstance()->SetRenderServiceClient(renderServiceClient); +} + +/** + * @tc.name: FlushImplicitTransaction001 + * @tc.desc: test + * @tc.type:FUNC + * @tc.require: + */ +TEST_F(RSTransactionProxyTest, FlushImplicitTransaction001) +{ + uint64_t timestamp = 1; + RSTransactionProxy::GetInstance()->FlushImplicitTransaction(timestamp); +} + +/** + * @tc.name: FlushImplicitTransactionFromRT001 + * @tc.desc: test + * @tc.type:FUNC + * @tc.require: + */ +TEST_F(RSTransactionProxyTest, FlushImplicitTransactionFromRT001) +{ + uint64_t timestamp = 1; + RSTransactionProxy::GetInstance()->FlushImplicitTransactionFromRT(timestamp); +} + +/** + * @tc.name: Commit001 + * @tc.desc: test + * @tc.type:FUNC + * @tc.require: + */ +TEST_F(RSTransactionProxyTest, Commit001) +{ + uint64_t timestamp = 1; + RSTransactionProxy::GetInstance()->Commit(timestamp); +} +} // namespace Rosen +} // namespace OHOS diff --git a/display_server/rosen/test/render_service/render_service_client/ft_build/BUILD.gn b/display_server/rosen/test/render_service/render_service_client/ft_build/BUILD.gn new file mode 100644 index 0000000..391993c --- /dev/null +++ b/display_server/rosen/test/render_service/render_service_client/ft_build/BUILD.gn @@ -0,0 +1,62 @@ +# Copyright (c) 2023 Huawei Technologies Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/gn/fangtian.gni") +import("//display_server/ft_build/ds_config.gni") + +group("unittest") { + testonly = true + + deps = [ + ":RSRenderTransactionTest", + ":RSRenderServiceClientUITest", + ] +} + +config("rs_client_unittest_common_public_config") { + include_dirs = [ + "//display_server/rosen/modules/render_service_client", + "//display_server/rosen/test/include" + ] +} + +ft_static_library("rs_client_unittest_common") { + public_configs = [ + ":rs_client_unittest_common_public_config", + "//display_server/rosen/modules/render_service_client/ft_build:render_service_client_public_config", + ] + + public_deps = [ + "//display_server/rosen/modules/render_service_client/ft_build:render_service_client_src", + "//build/gn/configs/system_libs:gtest", + ] +} + +ft_executable("RSRenderTransactionTest") { + sources = [ "transaction/rs_transaction_test.cpp" ] + + deps = [ ":rs_client_unittest_common" ] +} + +ft_executable("RSRenderServiceClientUITest") { + sources = [ + "ui/rs_display_node_test.cpp", + "ui/rs_surface_node_test.cpp", + "ui/rs_surface_extractor_test.cpp", + # "ui/rs_node_test.cpp", + ] + + cflags_cc = [ "-Wno-c++11-narrowing" ] + + deps = [ ":rs_client_unittest_common" ] +} diff --git a/display_server/rosen/test/render_service/render_service_client/ft_build/transaction/rs_transaction_test.cpp b/display_server/rosen/test/render_service/render_service_client/ft_build/transaction/rs_transaction_test.cpp new file mode 100644 index 0000000..0027920 --- /dev/null +++ b/display_server/rosen/test/render_service/render_service_client/ft_build/transaction/rs_transaction_test.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "gtest/gtest.h" +#include "transaction/rs_transaction.h" + +namespace OHOS::Rosen { +class RSTransactionTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; + +void RSTransactionTest::SetUpTestCase() {} +void RSTransactionTest::TearDownTestCase() {} +void RSTransactionTest::SetUp() {} +void RSTransactionTest::TearDown() {} + +/** + * @tc.name: FlushImplicitTransaction001 + * @tc.desc: + * @tc.type: + * @tc.require: + * @tc.author: + */ +TEST_F(RSTransactionTest, FlushImplicitTransaction001) +{ + // RSRenderThreadClient cannot be created, + // which constructor is privated. + // Only use its static function. + RSTransaction::FlushImplicitTransaction(); +} +} // namespace OHOS::Rosen diff --git a/display_server/rosen/test/render_service/render_service_client/ft_build/ui/rs_display_node_test.cpp b/display_server/rosen/test/render_service/render_service_client/ft_build/ui/rs_display_node_test.cpp new file mode 100644 index 0000000..8980c84 --- /dev/null +++ b/display_server/rosen/test/render_service/render_service_client/ft_build/ui/rs_display_node_test.cpp @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gtest/gtest.h" +#include "transaction/rs_interfaces.h" +#include "ui/rs_display_node.h" + +namespace OHOS::Rosen { +class RSDisplayNodeTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; + +void RSDisplayNodeTest::SetUpTestCase() {} +void RSDisplayNodeTest::TearDownTestCase() {} +void RSDisplayNodeTest::SetUp() {} +void RSDisplayNodeTest::TearDown() {} + +class TestSurfaceCapture : public SurfaceCaptureCallback { +public: + TestSurfaceCapture() + { + showNode_ = nullptr; + } + explicit TestSurfaceCapture(std::shared_ptr surfaceNode) + { + showNode_ = surfaceNode; + } + ~TestSurfaceCapture() override {} + void OnSurfaceCapture(std::shared_ptr pixelmap) override {} + bool IsTestSuccess() + { + return testSuccess; + } +private: + bool testSuccess = true; + std::shared_ptr showNode_; +}; // class TestSurfaceCapture + +/** + * @tc.name: Create001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSDisplayNodeTest, Create001) +{ + /** + * @tc.steps: step1. create RSDisplayNode + */ + RSDisplayNodeConfig c; + RSDisplayNode::SharedPtr displayNode = RSDisplayNode::Create(c); + ASSERT_TRUE(displayNode != nullptr); +} + +/** + * @tc.name: GetType001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSDisplayNodeTest, GetType001) +{ + RSDisplayNodeConfig c; + RSDisplayNode::SharedPtr displayNode = RSDisplayNode::Create(c); + ASSERT_TRUE(displayNode != nullptr); + ASSERT_TRUE(displayNode->GetType() == RSUINodeType::DISPLAY_NODE); +} + +/** + * @tc.name: TakeSurfaceCapture001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSDisplayNodeTest, TakeSurfaceCapture001) +{ + /** + * @tc.steps: step1. create RSDisplayNode + */ + RSDisplayNodeConfig c; + RSDisplayNode::SharedPtr displayNode = RSDisplayNode::Create(c); + ASSERT_TRUE(displayNode != nullptr); + auto surfaceCaptureMock = std::make_shared(); + RSInterfaces::GetInstance().TakeSurfaceCapture(displayNode, surfaceCaptureMock); +} + +/** + * @tc.name: SetSecurityDisplay001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSDisplayNodeTest, SetSecurityDisplay001) +{ + /** + * @tc.steps: step1. create RSDisplayNode + */ + RSDisplayNodeConfig c; + RSDisplayNode::SharedPtr displayNode = RSDisplayNode::Create(c); + ASSERT_TRUE(displayNode != nullptr); + /** + * @tc.steps: step2. set SecurityDisplay + */ + displayNode->SetSecurityDisplay(true); + EXPECT_TRUE(displayNode->GetSecurityDisplay()); +} + +/** + * @tc.name: SetSecurityDisplay002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSDisplayNodeTest, SetSecurityDisplay002) +{ + /** + * @tc.steps: step1. create RSDisplayNode + */ + RSDisplayNodeConfig c; + RSDisplayNode::SharedPtr displayNode = RSDisplayNode::Create(c); + /** + * @tc.steps: step2. set SecurityDisplay + */ + ASSERT_TRUE(displayNode != nullptr); + displayNode->SetSecurityDisplay(false); + EXPECT_FALSE(displayNode->GetSecurityDisplay()); +} + + +/** + * @tc.name: GetSecurityDisplay001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSDisplayNodeTest, GetSecurityDisplay001) +{ + /** + * @tc.steps: step1. create RSDisplayNode + */ + RSDisplayNodeConfig c; + RSDisplayNode::SharedPtr displayNode = RSDisplayNode::Create(c); + ASSERT_TRUE(displayNode != nullptr); + EXPECT_FALSE(displayNode->GetSecurityDisplay()); +} + +/** + * @tc.name: SetScreenId001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSDisplayNodeTest, SetScreenId001) +{ + /** + * @tc.steps: step1. create RSDisplayNode + */ + RSDisplayNodeConfig c; + RSDisplayNode::SharedPtr displayNode = RSDisplayNode::Create(c); + ASSERT_TRUE(displayNode != nullptr); + displayNode->SetScreenId(1); +} +} // namespace OHOS::Rosen \ No newline at end of file diff --git a/display_server/rosen/test/render_service/render_service_client/ft_build/ui/rs_node_test.cpp b/display_server/rosen/test/render_service/render_service_client/ft_build/ui/rs_node_test.cpp new file mode 100644 index 0000000..92bb395 --- /dev/null +++ b/display_server/rosen/test/render_service/render_service_client/ft_build/ui/rs_node_test.cpp @@ -0,0 +1,3137 @@ +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "gtest/gtest.h" +#include "animation/rs_animation.h" +#include "animation/rs_transition.h" +#include "modifier/rs_property_modifier.h" +#include "ui/rs_canvas_node.h" +#include "ui/rs_surface_node.h" + +namespace OHOS::Rosen { +class RSNodeTest : public testing::Test { +public: + constexpr static float floatData[] = { + 0.0f, 485.44f, -34.4f, + std::numeric_limits::max(), std::numeric_limits::min(), + }; + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; + +void RSNodeTest::SetUpTestCase() {} +void RSNodeTest::TearDownTestCase() {} +void RSNodeTest::SetUp() {} +void RSNodeTest::TearDown() {} + +/** + * @tc.name: LifeCycle001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, LifeCycle001) +{ + /** + * @tc.steps: step1. create RSNode and add child + */ + auto rootNode = RSCanvasNode::Create(); + ASSERT_TRUE(rootNode != nullptr); + + auto child1 = RSCanvasNode::Create(); + auto child2 = RSCanvasNode::Create(); + auto child3 = RSCanvasNode::Create(); + rootNode->AddChild(child1, -1); + rootNode->AddChild(child2, 0); + child1->AddChild(child3, 1); + + EXPECT_EQ(rootNode->GetId() + 1, child1->GetId()); + + /** + * @tc.steps: step2. remove child + */ + rootNode->RemoveChild(child2); +} + +/** + * @tc.name: LifeCycle002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, LifeCycle002) +{ + /** + * @tc.steps: step1. create RSNode and add child + */ + auto rootNode = RSCanvasNode::Create(); + ASSERT_TRUE(rootNode != nullptr); + + auto child1 = RSCanvasNode::Create(); + auto child2 = RSCanvasNode::Create(); + auto child3 = RSCanvasNode::Create(); + rootNode->AddChild(child1, -1); + rootNode->AddChild(child2, 0); + child1->AddChild(child3, 1); + /** + * @tc.steps: step2. remove child + */ + rootNode->RemoveChild(child2); +} + +/** + * @tc.name: LifeCycle003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, LifeCycle003) +{ + /** + * @tc.steps: step1. create RSNode and add child + */ + auto rootNode = RSCanvasNode::Create(); + ASSERT_TRUE(rootNode != nullptr); + + auto child1 = RSCanvasNode::Create(); + auto child2 = RSCanvasNode::Create(); + auto child3 = RSCanvasNode::Create(); + rootNode->AddChild(child1, -1); + rootNode->AddChild(child2, 0); + child1->AddChild(child3, 1); + /** + * @tc.steps: step2. remove child + */ + rootNode->RemoveFromTree(); +} + +/** + * @tc.name: LifeCycle004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, LifeCycle004) +{ + /** + * @tc.steps: step1. create RSNode and add child + */ + auto rootNode = RSCanvasNode::Create(); + ASSERT_TRUE(rootNode != nullptr); + + auto child1 = RSCanvasNode::Create(); + auto child2 = RSCanvasNode::Create(); + auto child3 = RSCanvasNode::Create(); + rootNode->AddChild(child1, -1); + rootNode->AddChild(child2, 0); + child1->AddChild(child3, 1); + /** + * @tc.steps: step2. remove child + */ + rootNode->ClearChildren(); +} + +/** + * @tc.name: LifeCycle005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, LifeCycle005) +{ + /** + * @tc.steps: step1. create RSNode and add child + */ + auto rootNode = RSCanvasNode::Create(); + ASSERT_TRUE(rootNode != nullptr); + + auto child1 = RSCanvasNode::Create(); + auto child2 = RSCanvasNode::Create(); + auto child3 = RSCanvasNode::Create(); + rootNode->AddChild(child1, -1); + rootNode->AddChild(child2, 0); + child1->AddChild(child3, 1); + /** + * @tc.steps: step2. remove child + */ + rootNode->RemoveChild(child3); +} + +/** + * @tc.name: Recording001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, Recording001) +{ + /** + * @tc.steps: step1. create RSNode and RSUIDirector + */ + auto rsNode = RSCanvasNode::Create(); + + /** + * @tc.steps: step2. begin recording + */ + EXPECT_FALSE(rsNode->IsRecording()); + rsNode->BeginRecording(500, 400); + EXPECT_TRUE(rsNode->IsRecording()); +} + +/** + * @tc.name: SetPaintOrder001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetPaintOrder001) +{ + /** + * @tc.steps: step1. create RSNode and RSUIDirector + */ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetPaintOrder(true); +} + +/** + * @tc.name: SetandGetBounds001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBounds001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBounds(floatData[0], floatData[1], floatData[2], floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBounds().x_, floatData[0])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBounds().y_, floatData[1])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBounds().z_, floatData[2])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBounds().w_, floatData[3])); +} + +/** + * @tc.name: SetandGetBounds002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBounds002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBounds(floatData[3], floatData[1], floatData[2], floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBounds().x_, floatData[3])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBounds().y_, floatData[1])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBounds().z_, floatData[2])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBounds().w_, floatData[0])); +} + +/** + * @tc.name: SetandGetBounds003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBounds003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBounds(floatData[3], floatData[2], floatData[1], floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBounds().x_, floatData[3])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBounds().y_, floatData[2])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBounds().z_, floatData[1])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBounds().w_, floatData[0])); +} + +/** + * @tc.name: SetandGetBoundsWidth001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBoundsWidth001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBoundsWidth(floatData[1]); + rsNode->SetBoundsWidth(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBounds().z_, floatData[1])); +} + +/** + * @tc.name: SetandGetBoundsWidth002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBoundsWidth002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBoundsWidth(floatData[2]); + rsNode->SetBoundsWidth(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBounds().z_, floatData[2])); +} + +/** + * @tc.name: SetandGetBoundsWidth003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBoundsWidth003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBoundsWidth(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBounds().z_, floatData[3])); +} + +/** + * @tc.name: SetandGetBoundsWidth004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBoundsWidth004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBoundsWidth(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBounds().z_, floatData[4])); +} + +/** + * @tc.name: SetandGetBoundsWidth005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBoundsWidth005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBoundsWidth(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBounds().z_, floatData[0])); +} + +/** + * @tc.name: SetandGetBoundsHeight001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBoundsHeight001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBoundsHeight(floatData[1]); + rsNode->SetBoundsHeight(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBounds().w_, floatData[1])); +} + +/** + * @tc.name: SetandGetBoundsHeight002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBoundsHeight002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBoundsHeight(floatData[2]); + rsNode->SetBoundsHeight(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBounds().w_, floatData[2])); +} + +/** + * @tc.name: SetandGetBoundsHeight003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBoundsHeight003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBoundsHeight(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBounds().w_, floatData[3])); +} + +/** + * @tc.name: SetandGetBoundsHeight004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBoundsHeight004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBoundsHeight(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBounds().w_, floatData[4])); +} + +/** + * @tc.name: SetandGetBoundsHeight005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBoundsHeight005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBoundsHeight(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBounds().w_, floatData[0])); +} + +/** + * @tc.name: SetandGetFrame001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFrame001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetFrame(floatData[0], floatData[1], floatData[2], floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetFrame().x_, floatData[0])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetFrame().y_, floatData[1])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetFrame().z_, floatData[2])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetFrame().w_, floatData[3])); +} + +/** + * @tc.name: SetandGetFrame002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFrame002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetFrame(floatData[3], floatData[1], floatData[2], floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetFrame().x_, floatData[3])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetFrame().y_, floatData[1])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetFrame().z_, floatData[2])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetFrame().w_, floatData[0])); +} + +/** + * @tc.name: SetandGetFrame003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFrame003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetFrame(floatData[3], floatData[2], floatData[1], floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetFrame().x_, floatData[3])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetFrame().y_, floatData[2])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetFrame().z_, floatData[1])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetFrame().w_, floatData[0])); +} + +/** + * @tc.name: SetandGetFramePositionX001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFramePositionX001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetFramePositionX(floatData[1]); + rsNode->SetFramePositionX(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetFrame().x_, floatData[1])); +} + +/** + * @tc.name: SetandGetFramePositionX002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFramePositionX002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetFramePositionX(floatData[2]); + rsNode->SetFramePositionX(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetFrame().x_, floatData[2])); +} + +/** + * @tc.name: SetandGetFramePositionX003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFramePositionX003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetFramePositionX(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetFrame().x_, floatData[3])); +} + +/** + * @tc.name: SetandGetFramePositionX004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFramePositionX004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetFramePositionX(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetFrame().x_, floatData[4])); +} + +/** + * @tc.name: SetandGetFramePositionX005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFramePositionX005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetFramePositionX(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetFrame().x_, floatData[0])); +} + +/** + * @tc.name: SetandGetFramePositionY001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFramePositionY001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetFramePositionY(floatData[1]); + rsNode->SetFramePositionY(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetFrame().y_, floatData[1])); +} + +/** + * @tc.name: SetandGetFramePositionY002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFramePositionY002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetFramePositionY(floatData[2]); + rsNode->SetFramePositionY(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetFrame().y_, floatData[2])); +} + +/** + * @tc.name: SetandGetFramePositionY003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFramePositionY003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetFramePositionY(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetFrame().y_, floatData[3])); +} + +/** + * @tc.name: SetandGetFramePositionY004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFramePositionY004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetFramePositionY(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetFrame().y_, floatData[4])); +} + +/** + * @tc.name: SetandGetFramePositionY005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFramePositionY005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetFramePositionY(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetFrame().y_, floatData[0])); +} + +/** + * @tc.name: SetandGetPositionZ001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetPositionZ001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetPositionZ(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetPositionZ(), floatData[1])); +} + +/** + * @tc.name: SetandGetPositionZ002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetPositionZ002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetPositionZ(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetPositionZ(), floatData[2])); +} + +/** + * @tc.name: SetandGetPositionZ003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetPositionZ003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetPositionZ(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetPositionZ(), floatData[3])); +} + +/** + * @tc.name: SetandGetPositionZ004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetPositionZ004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetPositionZ(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetPositionZ(), floatData[4])); +} + +/** + * @tc.name: SetandGetPositionZ005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetPositionZ005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetPositionZ(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetPositionZ(), floatData[0])); +} + +/** + * @tc.name: SetandGetCornerRadius001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetCornerRadius001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetCornerRadius(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetCornerRadius().x_, floatData[1])); +} + +/** + * @tc.name: SetandGetCornerRadius002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetCornerRadius002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetCornerRadius(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetCornerRadius().x_, floatData[2])); +} + +/** + * @tc.name: SetandGetCornerRadius003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetCornerRadius003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetCornerRadius(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetCornerRadius().x_, floatData[3])); +} + +/** + * @tc.name: SetandGetCornerRadius004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetCornerRadius004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetCornerRadius(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetCornerRadius().x_, floatData[4])); +} + +/** + * @tc.name: SetandGetCornerRadius005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetCornerRadius005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetCornerRadius(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetCornerRadius().x_, floatData[0])); +} + +/** + * @tc.name: SetandGetRotationThree001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetRotationThree001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetRotation(floatData[1], floatData[2], floatData[3]); +} + +/** + * @tc.name: SetandGetRotation001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetRotation001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetRotation(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetRotation(), floatData[1])); +} + +/** + * @tc.name: SetandGetRotation002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetRotation002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetRotation(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetRotation(), floatData[2])); +} + +/** + * @tc.name: SetandGetRotation003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetRotation003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetRotation(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetRotation(), floatData[3])); +} + +/** + * @tc.name: SetandGetRotation004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetRotation004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetRotation(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetRotation(), floatData[4])); +} + +/** + * @tc.name: SetandGetRotation005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetRotation005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetRotation(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetRotation(), floatData[0])); +} + +/** + * @tc.name: SetandGetRotationX001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetRotationX001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetRotationX(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetRotationX(), floatData[1])); +} + +/** + * @tc.name: SetandGetRotationX002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetRotationX002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetRotationX(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetRotationX(), floatData[2])); +} + +/** + * @tc.name: SetandGetRotationX003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetRotationX003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetRotationX(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetRotationX(), floatData[3])); +} + +/** + * @tc.name: SetandGetRotationX004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetRotationX004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetRotationX(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetRotationX(), floatData[4])); +} + +/** + * @tc.name: SetandGetRotationX005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetRotationX005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetRotationX(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetRotationX(), floatData[0])); +} + +/** + * @tc.name: SetandGetRotationY001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetRotationY001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetRotationY(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetRotationY(), floatData[1])); +} + +/** + * @tc.name: SetandGetRotationY002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetRotationY002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetRotationY(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetRotationY(), floatData[2])); +} + +/** + * @tc.name: SetandGetRotationY003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetRotationY003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetRotationY(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetRotationY(), floatData[3])); +} + +/** + * @tc.name: SetandGetRotationY004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetRotationY004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetRotationY(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetRotationY(), floatData[4])); +} + +/** + * @tc.name: SetandGetRotationY005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetRotationY005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetRotationY(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetRotationY(), floatData[0])); +} + + +/** + * @tc.name: SetandGetScaleX001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetScaleX001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetScaleX(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetScale().x_, floatData[1])); +} + +/** + * @tc.name: SetandGetScaleX002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetScaleX002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetScaleX(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetScale().x_, floatData[2])); +} + +/** + * @tc.name: SetandGetScaleX003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetScaleX003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetScaleX(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetScale().x_, floatData[3])); +} + +/** + * @tc.name: SetandGetScaleX004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetScaleX004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetScaleX(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetScale().x_, floatData[4])); +} + +/** + * @tc.name: SetandGetScaleX005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetScaleX005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetScaleX(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetScale().x_, floatData[0])); +} + +/** + * @tc.name: SetandGetScale001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetScale001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetScale(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetScale().x_, floatData[1])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetScale().y_, floatData[1])); +} + +/** + * @tc.name: SetandGetScale002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetScale002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetScale(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetScale().x_, floatData[2])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetScale().y_, floatData[2])); +} + +/** + * @tc.name: SetandGetScale003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetScale003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetScale(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetScale().x_, floatData[3])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetScale().y_, floatData[3])); +} + +/** + * @tc.name: SetandGetScale004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetScale004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetScale(floatData[3], floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetScale().x_, floatData[3])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetScale().y_, floatData[0])); +} + +/** + * @tc.name: SetandGetScale0005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetScale0005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetScale(floatData[2], floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetScale().x_, floatData[2])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetScale().y_, floatData[1])); +} + +/** + * @tc.name: SetandGetScaleY001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetScaleY001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetScaleY(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetScale().y_, floatData[1])); +} + +/** + * @tc.name: SetandGetScaleY002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetScaleY002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetScaleY(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetScale().y_, floatData[2])); +} + +/** + * @tc.name: SetandGetScaleY003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetScaleY003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetScaleY(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetScale().y_, floatData[3])); +} + +/** + * @tc.name: SetandGetScaleY004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetScaleY004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetScaleY(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetScale().y_, floatData[4])); +} + +/** + * @tc.name: SetandGetScaleY005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetScaleY005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetScaleY(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetScale().y_, floatData[0])); +} + +/** + * @tc.name: SetandGetAlphaOffscreen001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetAlphaOffscreen001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetAlphaOffscreen(true); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetAlphaOffscreen(), true)); +} + +/** + * @tc.name: SetandGetAlphaOffscreen002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetAlphaOffscreen002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetAlphaOffscreen(false); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetAlphaOffscreen(), false)); +} + +/** + * @tc.name: SetandGetAlpha001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetAlpha001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetAlpha(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetAlpha(), floatData[1])); +} + +/** + * @tc.name: SetandGetAlpha002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetAlpha002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetAlpha(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetAlpha(), floatData[2])); +} + +/** + * @tc.name: SetandGetAlpha003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetAlpha003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetAlpha(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetAlpha(), floatData[3])); +} + +/** + * @tc.name: SetandGetAlpha004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetAlpha004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetAlpha(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetAlpha(), floatData[4])); +} + +/** + * @tc.name: SetandGetAlpha005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetAlpha005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetAlpha(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetAlpha(), floatData[0])); +} + +/** + * @tc.name: SetandGetBgImageSize001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBgImageSize001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImageSize(floatData[0], floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImageWidth(), floatData[0])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImageHeight(), floatData[1])); +} + +/** + * @tc.name: SetandGetBgImageSize002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBgImageSize002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImageSize(floatData[3], floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImageWidth(), floatData[3])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImageHeight(), floatData[1])); +} + +/** + * @tc.name: SetandGetBgImageSize003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBgImageSize003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImageSize(floatData[3], floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImageWidth(), floatData[3])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImageHeight(), floatData[2])); +} + +/** + * @tc.name: SetandGetBgImageWidth001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBgImageWidth001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImageWidth(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImageWidth(), floatData[1])); +} + +/** + * @tc.name: SetandGetBgImageWidth002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBgImageWidth002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImageWidth(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImageWidth(), floatData[2])); +} + +/** + * @tc.name: SetandGetBgImageWidth003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBgImageWidth003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImageWidth(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImageWidth(), floatData[3])); +} + +/** + * @tc.name: SetandGetBgImageWidth004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBgImageWidth004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImageWidth(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImageWidth(), floatData[4])); +} + +/** + * @tc.name: SetandGetBgImageWidth005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBgImageWidth005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImageWidth(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImageWidth(), floatData[0])); +} + +/** + * @tc.name: SetandGetBgImageHeight001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBgImageHeight001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImageHeight(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImageHeight(), floatData[1])); +} + +/** + * @tc.name: SetandGetBgImageHeight002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBgImageHeight002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImageHeight(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImageHeight(), floatData[2])); +} + +/** + * @tc.name: SetandGetBgImageHeight003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBgImageHeight003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImageHeight(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImageHeight(), floatData[3])); +} + +/** + * @tc.name: SetandGetBgImageHeight004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBgImageHeight004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImageHeight(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImageHeight(), floatData[4])); +} + +/** + * @tc.name: SetandGetBgImageHeight005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBgImageHeight005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImageHeight(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImageHeight(), floatData[0])); +} + +/** + * @tc.name: SetandSetBgImagePosition001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandSetBgImagePosition001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImagePosition(floatData[2], floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImagePositionX(), floatData[2])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImagePositionY(), floatData[3])); +} + +/** + * @tc.name: SetandSetBgImagePosition002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandSetBgImagePosition002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImagePosition(floatData[2], floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImagePositionX(), floatData[2])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImagePositionY(), floatData[0])); +} + +/** + * @tc.name: SetandSetBgImagePosition003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandSetBgImagePosition003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImagePosition(floatData[1], floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImagePositionX(), floatData[1])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImagePositionY(), floatData[3])); +} + +/** + * @tc.name: SetandGetBgImagePositionX001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBgImagePositionX001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImagePositionX(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImagePositionX(), floatData[1])); +} + +/** + * @tc.name: SetandGetBgImagePositionX002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBgImagePositionX002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImagePositionX(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImagePositionX(), floatData[2])); +} + +/** + * @tc.name: SetandGetBgImagePositionX003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBgImagePositionX003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImagePositionX(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImagePositionX(), floatData[3])); +} + +/** + * @tc.name: SetandGetBgImagePositionX004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBgImagePositionX004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImagePositionX(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImagePositionX(), floatData[4])); +} + +/** + * @tc.name: SetandGetBgImagePositionX005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBgImagePositionX005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImagePositionX(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImagePositionX(), floatData[0])); +} + +/** + * @tc.name: SetandGetBgImagePositionY001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBgImagePositionY001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImagePositionY(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImagePositionY(), floatData[1])); +} + +/** + * @tc.name: SetandGetBgImagePositionY002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBgImagePositionY002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImagePositionY(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImagePositionY(), floatData[2])); +} + +/** + * @tc.name: SetandGetBgImagePositionY003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBgImagePositionY003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImagePositionY(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImagePositionY(), floatData[3])); +} + +/** + * @tc.name: SetandGetBgImagePositionY004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBgImagePositionY004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImagePositionY(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImagePositionY(), floatData[4])); +} + +/** + * @tc.name: SetandGetBgImagePositionY005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBgImagePositionY005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBgImagePositionY(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBgImagePositionY(), floatData[0])); +} + +/** + * @tc.name: SetandGetBorderWidth001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBorderWidth001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBorderWidth(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBorderWidth().x_, floatData[1])); +} + +/** + * @tc.name: SetandGetBorderWidth002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBorderWidth002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBorderWidth(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBorderWidth().x_, floatData[2])); +} + +/** + * @tc.name: SetandGetBorderWidth003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBorderWidth003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBorderWidth(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBorderWidth().x_, floatData[3])); +} + +/** + * @tc.name: SetandGetBorderWidth004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBorderWidth004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBorderWidth(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBorderWidth().x_, floatData[4])); +} + +/** + * @tc.name: SetandGetBorderWidth005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBorderWidth005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetBorderWidth(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetBorderWidth().x_, floatData[0])); +} + +/** + * @tc.name: SetandGetPivot001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetPivot001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetPivot(floatData[0], floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetPivot().x_, floatData[0])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetPivot().y_, floatData[1])); +} + +/** + * @tc.name: SetandGetPivot002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetPivot002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetPivot(floatData[3], floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetPivot().x_, floatData[3])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetPivot().y_, floatData[2])); +} + +/** + * @tc.name: SetandGetPivot003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetPivot003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetPivot(floatData[1], floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetPivot().x_, floatData[1])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetPivot().y_, floatData[3])); +} + +/** + * @tc.name: SetandGetPivotX001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetPivotX001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetPivotX(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetPivot().x_, floatData[1])); +} + +/** + * @tc.name: SetandGetPivotX002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetPivotX002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetPivotX(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetPivot().x_, floatData[2])); +} + +/** + * @tc.name: SetandGetPivotX003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetPivotX003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetPivotX(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetPivot().x_, floatData[3])); +} + +/** + * @tc.name: SetandGetPivotX004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetPivotX004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetPivotX(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetPivot().x_, floatData[4])); +} + +/** + * @tc.name: SetandGetPivotX005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetPivotX005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetPivotX(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetPivot().x_, floatData[0])); +} + +/** + * @tc.name: SetandGetPivotY001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetPivotY001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetPivotY(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetPivot().y_, floatData[1])); +} + +/** + * @tc.name: SetandGetPivotY002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetPivotY002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetPivotY(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetPivot().y_, floatData[2])); +} + +/** + * @tc.name: SetandGetPivotY003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetPivotY003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetPivotY(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetPivot().y_, floatData[3])); +} + +/** + * @tc.name: SetandGetPivotY004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetPivotY004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetPivotY(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetPivot().y_, floatData[4])); +} + +/** + * @tc.name: SetandGetPivotY005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetPivotY005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetPivotY(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetPivot().y_, floatData[0])); +} + +/** + * @tc.name: SetandGetShadowOffset001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowOffset001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowOffset(floatData[2], floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowOffsetX(), floatData[2])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowOffsetY(), floatData[3])); +} + +/** + * @tc.name: SetandGetShadowOffset002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowOffset002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowOffset(floatData[2], floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowOffsetX(), floatData[2])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowOffsetY(), floatData[0])); +} + +/** + * @tc.name: SetandGetShadowOffset003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowOffset003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowOffset(floatData[1], floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowOffsetX(), floatData[1])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowOffsetY(), floatData[3])); +} +/** + * @tc.name: SetandGetShadowOffsetX001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowOffsetX001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowOffsetX(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowOffsetX(), floatData[1])); +} + +/** + * @tc.name: SetandGetShadowOffsetX002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowOffsetX002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowOffsetX(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowOffsetX(), floatData[2])); +} + +/** + * @tc.name: SetandGetShadowOffsetX003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowOffsetX003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowOffsetX(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowOffsetX(), floatData[3])); +} + +/** + * @tc.name: SetandGetShadowOffsetX004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowOffsetX004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowOffsetX(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowOffsetX(), floatData[4])); +} + +/** + * @tc.name: SetandGetShadowOffsetX005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowOffsetX005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowOffsetX(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowOffsetX(), floatData[0])); +} + +/** + * @tc.name: SetandGetShadowOffsetY001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowOffsetY001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowOffsetY(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowOffsetY(), floatData[1])); +} + +/** + * @tc.name: SetandGetShadowOffsetY002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowOffsetY002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowOffsetY(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowOffsetY(), floatData[2])); +} + +/** + * @tc.name: SetandGetShadowOffsetY003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowOffsetY003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowOffsetY(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowOffsetY(), floatData[3])); +} + +/** + * @tc.name: SetandGetShadowOffsetY004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowOffsetY004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowOffsetY(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowOffsetY(), floatData[4])); +} + +/** + * @tc.name: SetandGetShadowOffsetY005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowOffsetY005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowOffsetY(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowOffsetY(), floatData[0])); +} + +/** + * @tc.name: SetandGetShadowAlpha001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowAlpha001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowAlpha(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowAlpha(), floatData[1], 0.02f)); +} + +/** + * @tc.name: SetandGetShadowAlpha002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowAlpha002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowAlpha(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowAlpha(), floatData[2], 0.02f)); +} + +/** + * @tc.name: SetandGetShadowAlpha003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowAlpha003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowAlpha(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowAlpha(), floatData[3], 0.02f)); +} + +/** + * @tc.name: SetandGetShadowAlpha004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowAlpha004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowAlpha(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowAlpha(), floatData[4], 0.02f)); +} + +/** + * @tc.name: SetandGetShadowAlpha005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowAlpha005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowAlpha(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowAlpha(), + std::clamp(floatData[0], 0.0f, 1.0f), 0.02f)); +} + +/** + * @tc.name: SetandGetShadowElevation001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowElevation001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowElevation(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowElevation(), floatData[1])); +} + +/** + * @tc.name: SetandGetShadowElevation002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowElevation002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowElevation(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowElevation(), floatData[2])); +} + +/** + * @tc.name: SetandGetShadowElevation003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowElevation003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowElevation(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowElevation(), floatData[3])); +} + +/** + * @tc.name: SetandGetShadowElevation004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowElevation004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowElevation(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowElevation(), floatData[4])); +} + +/** + * @tc.name: SetandGetShadowElevation005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowElevation005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowElevation(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowElevation(), floatData[0])); +} + +/** + * @tc.name: SetandGetShadowRadius001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowRadius001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowRadius(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowRadius(), floatData[1])); +} + +/** + * @tc.name: SetandGetShadowRadius002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowRadius002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowRadius(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowRadius(), floatData[2])); +} + +/** + * @tc.name: SetandGetShadowRadius003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowRadius003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowRadius(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowRadius(), floatData[3])); +} + +/** + * @tc.name: SetandGetShadowRadius004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowRadius004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowRadius(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowRadius(), floatData[4])); +} + +/** + * @tc.name: SetandGetShadowRadius005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowRadius005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetShadowRadius(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetShadowRadius(), floatData[0])); +} + +/** + * @tc.name: SetandGetShadowColor001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowColor001) +{ + auto rsNode = RSCanvasNode::Create(); + constexpr uint32_t colorValue = 0x034123; + rsNode->SetShadowColor(colorValue); + EXPECT_TRUE(rsNode->GetStagingProperties().GetShadowColor() == Color::FromArgbInt(colorValue)); +} + +/** + * @tc.name: SetandGetShadowColor002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowColor002) +{ + auto rsNode = RSCanvasNode::Create(); + constexpr uint32_t colorValue = 0x45ba87; + rsNode->SetShadowColor(colorValue); + EXPECT_TRUE(rsNode->GetStagingProperties().GetShadowColor() == Color::FromArgbInt(colorValue)); +} + +/** + * @tc.name: SetandGetShadowColor003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowColor003) +{ + auto rsNode = RSCanvasNode::Create(); + constexpr uint32_t colorValue = 0x32aadd; + rsNode->SetShadowColor(colorValue); + EXPECT_TRUE(rsNode->GetStagingProperties().GetShadowColor() == Color::FromArgbInt(colorValue)); +} + +/** + * @tc.name: SetandGetShadowColor004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowColor004) +{ + auto rsNode = RSCanvasNode::Create(); + constexpr uint32_t colorValue = std::numeric_limits::max(); + rsNode->SetShadowColor(colorValue); + EXPECT_TRUE(rsNode->GetStagingProperties().GetShadowColor() == Color::FromArgbInt(colorValue)); +} + +/** + * @tc.name: SetandGetShadowColor005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetShadowColor005) +{ + auto rsNode = RSCanvasNode::Create(); + constexpr uint32_t colorValue = std::numeric_limits::min(); + rsNode->SetShadowColor(colorValue); + EXPECT_TRUE(rsNode->GetStagingProperties().GetShadowColor() == Color::FromArgbInt(colorValue)); +} + +/** + * @tc.name: SetandGetTranslateThree001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetTranslateThree001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetTranslate(floatData[1], floatData[2], floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetTranslate().x_, floatData[1])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetTranslate().y_, floatData[2])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetTranslateZ(), floatData[3])); +} + +/** + * @tc.name: SetandGetTranslateThree002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetTranslateThree002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetTranslate(floatData[0], floatData[0], floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetTranslate().x_, floatData[0])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetTranslate().y_, floatData[0])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetTranslateZ(), floatData[2])); +} + +/** + * @tc.name: SetandGetTranslateThree003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetTranslateThree003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetTranslate(floatData[1], floatData[3], floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetTranslate().x_, floatData[1])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetTranslate().y_, floatData[3])); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetTranslateZ(), floatData[1])); +} + +/** + * @tc.name: SetandGetTranslateX001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetTranslateX001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetTranslateX(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetTranslate().x_, floatData[1])); +} + +/** + * @tc.name: SetandGetTranslateX002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetTranslateX002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetTranslateX(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetTranslate().x_, floatData[2])); +} + +/** + * @tc.name: SetandGetTranslateX003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetTranslateX003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetTranslateX(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetTranslate().x_, floatData[3])); +} + +/** + * @tc.name: SetandGetTranslateX004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetTranslateX004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetTranslateX(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetTranslate().x_, floatData[4])); +} + +/** + * @tc.name: SetandGetTranslateX005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetTranslateX005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetTranslateX(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetTranslate().x_, floatData[0])); +} + +/** + * @tc.name: SetandGetTranslateY001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetTranslateY001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetTranslateY(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetTranslate().y_, floatData[1])); +} + +/** + * @tc.name: SetandGetTranslateY002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetTranslateY002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetTranslateY(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetTranslate().y_, floatData[2])); +} + +/** + * @tc.name: SetandGetTranslateY003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetTranslateY003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetTranslateY(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetTranslate().y_, floatData[3])); +} + +/** + * @tc.name: SetandGetTranslateY004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetTranslateY004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetTranslateY(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetTranslate().y_, floatData[4])); +} + +/** + * @tc.name: SetandGetTranslateY005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetTranslateY005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetTranslateY(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetTranslate().y_, floatData[0])); +} + +/** + * @tc.name: SetandGetTranslateZ001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetTranslateZ001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetTranslateZ(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetTranslateZ(), floatData[1])); +} + +/** + * @tc.name: SetandGetTranslateZ002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetTranslateZ002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetTranslateZ(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetTranslateZ(), floatData[2])); +} + +/** + * @tc.name: SetandGetTranslateZ003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetTranslateZ003) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetTranslateZ(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetTranslateZ(), floatData[3])); +} + +/** + * @tc.name: SetandGetTranslateZ004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetTranslateZ004) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetTranslateZ(floatData[4]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetTranslateZ(), floatData[4])); +} + +/** + * @tc.name: SetandGetTranslateZ005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetTranslateZ005) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetTranslateZ(floatData[0]); + EXPECT_TRUE(ROSEN_EQ(rsNode->GetStagingProperties().GetTranslateZ(), floatData[0])); +} + +/** + * @tc.name: SetandGetClipToBounds001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetClipToBounds001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetClipToBounds(true); + EXPECT_EQ(rsNode->GetStagingProperties().GetClipToBounds(), true); +} + +/** + * @tc.name: SetandGetClipToBounds002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetClipToBounds002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetClipToBounds(false); + EXPECT_EQ(rsNode->GetStagingProperties().GetClipToBounds(), false); +} + +/** + * @tc.name: SetandGetClipToFrame001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetClipToFrame001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetClipToFrame(true); + EXPECT_EQ(rsNode->GetStagingProperties().GetClipToFrame(), true); +} + +/** + * @tc.name: SetandGetClipToFrame002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetClipToFrame002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetClipToFrame(false); + EXPECT_EQ(rsNode->GetStagingProperties().GetClipToFrame(), false); +} + +/** + * @tc.name: SetandGetVisible001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetVisible001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetVisible(true); + EXPECT_EQ(rsNode->GetStagingProperties().GetVisible(), true); +} + +/** + * @tc.name: SetandGetVisible002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetVisible002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->SetVisible(false); + EXPECT_EQ(rsNode->GetStagingProperties().GetVisible(), false); +} + +/** + * @tc.name: SetandGetBorderStyle001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBorderStyle001) +{ + auto rsNode = RSCanvasNode::Create(); + uint32_t borderStyle = static_cast(BorderStyle::SOLID); + rsNode->SetBorderStyle(borderStyle); + EXPECT_TRUE(rsNode->GetStagingProperties().GetBorderStyle().x_ == borderStyle); +} + +/** + * @tc.name: SetandGetBorderStyle002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBorderStyle002) +{ + auto rsNode = RSCanvasNode::Create(); + uint32_t borderStyle = static_cast(BorderStyle::DASHED); + rsNode->SetBorderStyle(borderStyle); + EXPECT_TRUE(rsNode->GetStagingProperties().GetBorderStyle().x_ == borderStyle); +} + +/** + * @tc.name: SetandGetBorderStyle003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBorderStyle003) +{ + auto rsNode = RSCanvasNode::Create(); + uint32_t borderStyle = static_cast(BorderStyle::DOTTED); + rsNode->SetBorderStyle(borderStyle); + EXPECT_TRUE(rsNode->GetStagingProperties().GetBorderStyle().x_ == borderStyle); +} + +/** + * @tc.name: SetandGetBorderStyle004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBorderStyle004) +{ + auto rsNode = RSCanvasNode::Create(); + uint32_t borderStyle = static_cast(BorderStyle::NONE); + rsNode->SetBorderStyle(borderStyle); + EXPECT_TRUE(rsNode->GetStagingProperties().GetBorderStyle().x_ == borderStyle); +} + +/** + * @tc.name: SetandGetFrameGravity001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFrameGravity001) +{ + auto rsNode = RSCanvasNode::Create(); + Gravity gravity = Gravity::CENTER; + rsNode->SetFrameGravity(gravity); + EXPECT_TRUE(rsNode->GetStagingProperties().GetFrameGravity() == gravity); +} + +/** + * @tc.name: SetandGetFrameGravity002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFrameGravity002) +{ + auto rsNode = RSCanvasNode::Create(); + Gravity gravity = Gravity::TOP; + rsNode->SetFrameGravity(gravity); + EXPECT_TRUE(rsNode->GetStagingProperties().GetFrameGravity() == gravity); +} + +/** + * @tc.name: SetandGetFrameGravity003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFrameGravity003) +{ + auto rsNode = RSCanvasNode::Create(); + Gravity gravity = Gravity::BOTTOM; + rsNode->SetFrameGravity(gravity); + EXPECT_TRUE(rsNode->GetStagingProperties().GetFrameGravity() == gravity); +} + +/** + * @tc.name: SetandGetFrameGravity004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFrameGravity004) +{ + auto rsNode = RSCanvasNode::Create(); + Gravity gravity = Gravity::LEFT; + rsNode->SetFrameGravity(gravity); + EXPECT_TRUE(rsNode->GetStagingProperties().GetFrameGravity() == gravity); +} + +/** + * @tc.name: SetandGetFrameGravity005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFrameGravity005) +{ + auto rsNode = RSCanvasNode::Create(); + Gravity gravity = Gravity::RIGHT; + rsNode->SetFrameGravity(gravity); + EXPECT_TRUE(rsNode->GetStagingProperties().GetFrameGravity() == gravity); +} + +/** + * @tc.name: SetandGetFrameGravity006 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFrameGravity006) +{ + auto rsNode = RSCanvasNode::Create(); + Gravity gravity = Gravity::TOP_LEFT; + rsNode->SetFrameGravity(gravity); + EXPECT_TRUE(rsNode->GetStagingProperties().GetFrameGravity() == gravity); +} + +/** + * @tc.name: SetandGetFrameGravity007 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFrameGravity007) +{ + auto rsNode = RSCanvasNode::Create(); + Gravity gravity = Gravity::TOP_RIGHT; + rsNode->SetFrameGravity(gravity); + EXPECT_TRUE(rsNode->GetStagingProperties().GetFrameGravity() == gravity); +} + +/** + * @tc.name: SetandGetFrameGravity008 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFrameGravity008) +{ + auto rsNode = RSCanvasNode::Create(); + Gravity gravity = Gravity::BOTTOM_LEFT; + rsNode->SetFrameGravity(gravity); + EXPECT_TRUE(rsNode->GetStagingProperties().GetFrameGravity() == gravity); +} + +/** + * @tc.name: SetandGetFrameGravity009 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFrameGravity009) +{ + auto rsNode = RSCanvasNode::Create(); + Gravity gravity = Gravity::BOTTOM_RIGHT; + rsNode->SetFrameGravity(gravity); + EXPECT_TRUE(rsNode->GetStagingProperties().GetFrameGravity() == gravity); +} + +/** + * @tc.name: SetandGetFrameGravity010 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFrameGravity010) +{ + auto rsNode = RSCanvasNode::Create(); + Gravity gravity = Gravity::RESIZE; + rsNode->SetFrameGravity(gravity); + EXPECT_TRUE(rsNode->GetStagingProperties().GetFrameGravity() == gravity); +} + +/** + * @tc.name: SetandGetFrameGravity011 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFrameGravity011) +{ + auto rsNode = RSCanvasNode::Create(); + Gravity gravity = Gravity::RESIZE_ASPECT; + rsNode->SetFrameGravity(gravity); + EXPECT_TRUE(rsNode->GetStagingProperties().GetFrameGravity() == gravity); +} + +/** + * @tc.name: SetandGetFrameGravity012 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetFrameGravity012) +{ + auto rsNode = RSCanvasNode::Create(); + Gravity gravity = Gravity::RESIZE_ASPECT_FILL; + rsNode->SetFrameGravity(gravity); + EXPECT_TRUE(rsNode->GetStagingProperties().GetFrameGravity() == gravity); +} + +/** + * @tc.name: SetandGetForegroundColor001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetForegroundColor001) +{ + auto rsNode = RSCanvasNode::Create(); + constexpr uint32_t colorValue = 0x034123; + rsNode->SetForegroundColor(colorValue); + EXPECT_TRUE(rsNode->GetStagingProperties().GetForegroundColor() == Color::FromArgbInt(colorValue)); +} + +/** + * @tc.name: SetandGetForegroundColor002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetForegroundColor002) +{ + auto rsNode = RSCanvasNode::Create(); + constexpr uint32_t colorValue = std::numeric_limits::max(); + rsNode->SetForegroundColor(colorValue); + EXPECT_TRUE(rsNode->GetStagingProperties().GetForegroundColor() == Color::FromArgbInt(colorValue)); +} + +/** + * @tc.name: SetandGetForegroundColor003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetForegroundColor003) +{ + auto rsNode = RSCanvasNode::Create(); + constexpr uint32_t colorValue = std::numeric_limits::min(); + rsNode->SetForegroundColor(colorValue); + EXPECT_TRUE(rsNode->GetStagingProperties().GetForegroundColor() == Color::FromArgbInt(colorValue)); +} + +/** + * @tc.name: SetandGetBackgroundColor001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBackgroundColor001) +{ + auto rsNode = RSCanvasNode::Create(); + constexpr uint32_t colorValue = 0x034123; + rsNode->SetBackgroundColor(colorValue); + EXPECT_TRUE(rsNode->GetStagingProperties().GetBackgroundColor() == Color::FromArgbInt(colorValue)); +} + +/** + * @tc.name: SetandGetBackgroundColor002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBackgroundColor002) +{ + auto rsNode = RSCanvasNode::Create(); + constexpr uint32_t colorValue = std::numeric_limits::max(); + rsNode->SetBackgroundColor(colorValue); + EXPECT_TRUE(rsNode->GetStagingProperties().GetBackgroundColor() == Color::FromArgbInt(colorValue)); +} + +/** + * @tc.name: SetandGetBackgroundColor003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBackgroundColor003) +{ + auto rsNode = RSCanvasNode::Create(); + constexpr uint32_t colorValue = std::numeric_limits::min(); + rsNode->SetBackgroundColor(colorValue); + EXPECT_TRUE(rsNode->GetStagingProperties().GetBackgroundColor() == Color::FromArgbInt(colorValue)); +} + +/** + * @tc.name: SetandGetBorderColor001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBorderColor001) +{ + auto rsNode = RSCanvasNode::Create(); + constexpr uint32_t colorValue = 0x034123; + rsNode->SetBorderColor(colorValue); + EXPECT_TRUE(rsNode->GetStagingProperties().GetBorderColor() == Color::FromArgbInt(colorValue)); +} + +/** + * @tc.name: SetandGetBorderColor002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBorderColor002) +{ + auto rsNode = RSCanvasNode::Create(); + constexpr uint32_t colorValue = std::numeric_limits::max(); + rsNode->SetBorderColor(colorValue); + EXPECT_TRUE(rsNode->GetStagingProperties().GetBorderColor() == Color::FromArgbInt(colorValue)); +} + +/** + * @tc.name: SetandGetBorderColor003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetBorderColor003) +{ + auto rsNode = RSCanvasNode::Create(); + constexpr uint32_t colorValue = std::numeric_limits::min(); + rsNode->SetBorderColor(colorValue); + EXPECT_TRUE(rsNode->GetStagingProperties().GetBorderColor() == Color::FromArgbInt(colorValue)); +} + +/** + * @tc.name: SetandGetRotationVector001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetRotationVector001) +{ + auto rsNode = RSCanvasNode::Create(); + Vector4f quaternion(std::numeric_limits::min(), 2.f, 3.f, 4.f); + rsNode->SetRotation(quaternion); +} + +/** + * @tc.name: SetandGetTranslateVector001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetTranslateVector001) +{ + auto rsNode = RSCanvasNode::Create(); + Vector2f quaternion(std::numeric_limits::max(), 2.f); + rsNode->SetTranslate(quaternion); +} + +/** + * @tc.name: CreateBlurFilter001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, CreateBlurFilter001) +{ + auto rsNode = RSCanvasNode::Create(); + std::shared_ptr backgroundFilter = RSFilter::CreateBlurFilter(floatData[0], floatData[1]); + rsNode->SetBackgroundFilter(backgroundFilter); + EXPECT_TRUE(rsNode->GetStagingProperties().GetBackgroundFilter() == backgroundFilter); +} + +/** + * @tc.name: CreateBlurFilter002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, CreateBlurFilter002) +{ + auto rsNode = RSCanvasNode::Create(); + std::shared_ptr backgroundFilter = RSFilter::CreateBlurFilter(floatData[1], floatData[2]); + rsNode->SetBackgroundFilter(backgroundFilter); + EXPECT_TRUE(rsNode->GetStagingProperties().GetBackgroundFilter() == backgroundFilter); +} + +/** + * @tc.name: CreateBlurFilter003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, CreateBlurFilter003) +{ + auto rsNode = RSCanvasNode::Create(); + std::shared_ptr backgroundFilter = RSFilter::CreateBlurFilter(floatData[2], floatData[3]); + rsNode->SetBackgroundFilter(backgroundFilter); + EXPECT_TRUE(rsNode->GetStagingProperties().GetBackgroundFilter() == backgroundFilter); +} + +/** + * @tc.name: CreateBlurFilter004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, CreateBlurFilter004) +{ + auto rsNode = RSCanvasNode::Create(); + std::shared_ptr backgroundFilter = RSFilter::CreateBlurFilter(floatData[3], floatData[4]); + rsNode->SetBackgroundFilter(backgroundFilter); + EXPECT_TRUE(rsNode->GetStagingProperties().GetBackgroundFilter() == backgroundFilter); +} + +/** + * @tc.name: CreateBlurFilter005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, CreateBlurFilter005) +{ + auto rsNode = RSCanvasNode::Create(); + std::shared_ptr backgroundFilter = RSFilter::CreateBlurFilter(floatData[4], floatData[0]); + rsNode->SetBackgroundFilter(backgroundFilter); + EXPECT_TRUE(rsNode->GetStagingProperties().GetBackgroundFilter() == backgroundFilter); +} + +/** + * @tc.name: CreateNormalFilter001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, CreateNormalFilter001) +{ + auto rsNode = RSCanvasNode::Create(); + std::shared_ptr filter = RSFilter::CreateBlurFilter(floatData[0], floatData[1]); + rsNode->SetFilter(filter); + EXPECT_TRUE(rsNode->GetStagingProperties().GetFilter() == filter); +} + +/** + * @tc.name: CreateNormalFilter002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, CreateNormalFilter002) +{ + auto rsNode = RSCanvasNode::Create(); + std::shared_ptr filter = RSFilter::CreateBlurFilter(floatData[1], floatData[2]); + rsNode->SetFilter(filter); + EXPECT_TRUE(rsNode->GetStagingProperties().GetFilter() == filter); +} + +/** + * @tc.name: CreateNormalFilter003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, CreateNormalFilter003) +{ + auto rsNode = RSCanvasNode::Create(); + std::shared_ptr filter = RSFilter::CreateBlurFilter(floatData[2], floatData[3]); + rsNode->SetFilter(filter); + EXPECT_TRUE(rsNode->GetStagingProperties().GetFilter() == filter); +} + +/** + * @tc.name: CreateNormalFilter004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, CreateNormalFilter004) +{ + auto rsNode = RSCanvasNode::Create(); + std::shared_ptr filter = RSFilter::CreateBlurFilter(floatData[3], floatData[4]); + rsNode->SetFilter(filter); + EXPECT_TRUE(rsNode->GetStagingProperties().GetFilter() == filter); +} + +/** + * @tc.name: CreateNormalFilter005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, CreateNormalFilter005) +{ + auto rsNode = RSCanvasNode::Create(); + std::shared_ptr filter = RSFilter::CreateBlurFilter(floatData[4], floatData[0]); + rsNode->SetFilter(filter); + EXPECT_TRUE(rsNode->GetStagingProperties().GetFilter() == filter); +} + +/** + * @tc.name: SetandGetClipBounds001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetandGetClipBounds001) +{ + auto rsNode = RSCanvasNode::Create(); + std::shared_ptr clipPath = RSPath::CreateRSPath(); + rsNode->SetClipBounds(clipPath); + EXPECT_TRUE(rsNode->GetStagingProperties().GetClipBounds() == clipPath); +} + +/** + * @tc.name: GetId001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, GetId001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->GetId(); +} + +/** + * @tc.name: GetChildren001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, GetChildren001) +{ + auto rsNode = RSCanvasNode::Create(); + auto c = rsNode->GetChildren(); +} + +/** + * @tc.name: GetChildren002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, GetChildren002) +{ + auto rsNode = RSCanvasNode::Create(); + const auto c = rsNode->GetChildren(); +} + +/** + * @tc.name: GetStagingProperties001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, GetStagingProperties001) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->GetStagingProperties(); +} + +/** + * @tc.name: GetMotionPathOption001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, GetMotionPathOption002) +{ + auto rsNode = RSCanvasNode::Create(); + rsNode->GetMotionPathOption(); +} + +/** + * @tc.name: SetBgImage001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetBgImage001) +{ + auto rsNode = RSCanvasNode::Create(); + auto image = std::make_shared(); + rsNode->SetBgImage(image); +} + +/** + * @tc.name: SetBackgroundShader001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetBackgroundShader001) +{ + auto rsNode = RSCanvasNode::Create(); + auto shader = RSShader::CreateRSShader(); + rsNode->SetBackgroundShader(shader); +} + +/** + * @tc.name: SetCompositingFilter001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetCompositingFilter001) +{ + auto rsNode = RSCanvasNode::Create(); + auto compositingFilter = RSFilter::CreateBlurFilter(0.0f, 0.0f); + rsNode->SetCompositingFilter(compositingFilter); +} + +/** + * @tc.name: SetShadowPath001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetShadowPath001) +{ + auto rsNode = RSCanvasNode::Create(); + auto shadowpath = RSPath::CreateRSPath(); + rsNode->SetShadowPath(shadowpath); +} + +template +void SetPropertyTest(RSModifierType modifierType, T value1, T value2) +{ + auto node = RSCanvasNode::Create(); + node->SetProperty(modifierType, value1); + node->SetProperty(modifierType, value1); + node->SetProperty(modifierType, value2); +}; + +/** + * @tc.name: SetProperty001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetProperty001) +{ + SetPropertyTest, float>( + RSModifierType::ALPHA, 0.0f, 0.5f); + SetPropertyTest, bool>( + RSModifierType::ALPHA_OFFSCREEN, false, true); + SetPropertyTest, Vector4f>( + RSModifierType::BOUNDS, Vector4f(), Vector4f(25.f)); + SetPropertyTest, Vector4f>( + RSModifierType::FRAME, Vector4f(), Vector4f(25.f)); + SetPropertyTest, float>( + RSModifierType::POSITION_Z, 1.f, 2.f); + SetPropertyTest, Vector2f>( + RSModifierType::PIVOT, Vector2f(0.f, 0.f), Vector2f(1.f, 1.f)); + SetPropertyTest, Vector4f>( + RSModifierType::CORNER_RADIUS, Vector4f(), Vector4f(1.f)); + SetPropertyTest, Quaternion>( + RSModifierType::QUATERNION, Quaternion(), Quaternion(0.f, 1.f, 0.f, 0.f)); + SetPropertyTest, float>( + RSModifierType::ROTATION, 45.f, 90.f); + SetPropertyTest, float>( + RSModifierType::ROTATION_X, 45.f, 90.f); + SetPropertyTest, float>( + RSModifierType::ROTATION_Y, 45.f, 90.f); + SetPropertyTest, Vector2f>( + RSModifierType::TRANSLATE, Vector2f(10.f, 10.f), Vector2f(1.f, 1.f)); + SetPropertyTest, float>( + RSModifierType::TRANSLATE_Z, 45.f, 90.f); + SetPropertyTest, Vector2f>( + RSModifierType::SCALE, Vector2f(0.f, 0.f), Vector2f(1.f, 1.f)); + SetPropertyTest, Color>( + RSModifierType::FOREGROUND_COLOR, Color(), Color(0xFF00FF00)); + SetPropertyTest, Color>( + RSModifierType::BACKGROUND_COLOR, Color(), Color(0xFF00FF00)); + SetPropertyTest>, std::shared_ptr>( + RSModifierType::BG_IMAGE, std::make_shared(), nullptr); + SetPropertyTest, float>( + RSModifierType::BG_IMAGE_WIDTH, 45.f, 90.f); + SetPropertyTest, float>( + RSModifierType::BG_IMAGE_HEIGHT, 45.f, 90.f); + SetPropertyTest>, Vector4>( + RSModifierType::BORDER_COLOR, Vector4(), Vector4(Color(0xFF00FF00))); + SetPropertyTest, Vector4f>( + RSModifierType::BORDER_WIDTH, Vector4f(), Vector4f(1.f)); + SetPropertyTest>, Vector4>( + RSModifierType::BORDER_STYLE, Vector4(), Vector4(1)); + SetPropertyTest>, std::shared_ptr>( + RSModifierType::FILTER, RSFilter::CreateBlurFilter(1.f, 1.f), nullptr); + SetPropertyTest, Color>( + RSModifierType::SHADOW_COLOR, Color(), Color(0xFF00FF00)); + SetPropertyTest, float>( + RSModifierType::SHADOW_OFFSET_X, 1.f, 2.f); + SetPropertyTest, float>( + RSModifierType::SHADOW_OFFSET_Y, 1.f, 2.f); + SetPropertyTest, float>( + RSModifierType::SHADOW_ALPHA, 0.2f, 0.5f); + SetPropertyTest, float>( + RSModifierType::SHADOW_ELEVATION, 1.f, 2.f); + SetPropertyTest, float>( + RSModifierType::SHADOW_RADIUS, 1.f, 2.f); + SetPropertyTest>, std::shared_ptr>( + RSModifierType::SHADOW_PATH, RSPath::CreateRSPath(), nullptr); + SetPropertyTest, Gravity>( + RSModifierType::FRAME_GRAVITY, Gravity::TOP_RIGHT, Gravity::RESIZE); + SetPropertyTest>, std::shared_ptr>( + RSModifierType::CLIP_BOUNDS, RSPath::CreateRSPath(), nullptr); + SetPropertyTest, bool>( + RSModifierType::CLIP_TO_BOUNDS, false, true); + SetPropertyTest, bool>( + RSModifierType::CLIP_TO_FRAME, false, true); + SetPropertyTest, bool>( + RSModifierType::VISIBLE, false, true); + SetPropertyTest>, std::shared_ptr>( + RSModifierType::MASK, std::make_shared(), nullptr); +} + +/** + * @tc.name: SetModifier001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetModifier001) +{ + RSSurfaceNodeConfig surfaceNodeConfig; + auto node = RSSurfaceNode::Create(surfaceNodeConfig, false); + auto value = Vector4f(100.f); + auto prop = std::make_shared>(value); + auto modifier = std::make_shared(prop); + + node->AddModifier(nullptr); + node->RemoveModifier(modifier); + node->AddModifier(modifier); + ASSERT_TRUE(node != nullptr); + ASSERT_EQ(node->GetStagingProperties().GetBounds(), value); + node->AddModifier(modifier); + node->RemoveModifier(modifier); +} + + +class RSC_EXPORT MockRSNode : public RSNode { +public: + MockRSNode() : RSNode(false) {} + virtual ~MockRSNode() = default; + std::vector GetModifierIds() const { + return RSNode::GetModifierIds(); + } +}; + +/** + * @tc.name: SetModifier002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSNodeTest, SetModifier002) +{ + auto node = RSCanvasNode::Create(); + node->SetMotionPathOption(std::make_shared("")); + { + auto value = Vector4f(100.f); + auto prop = std::make_shared>(value); + auto modifier = std::make_shared(prop); + node->AddModifier(modifier); + ASSERT_TRUE(node != nullptr); + ASSERT_EQ(node->GetStagingProperties().GetBounds(), value); + node->RemoveModifier(modifier); + } + { + auto value = Vector4f(100.f); + auto prop = std::make_shared>(value); + auto modifier = std::make_shared(prop); + node->AddModifier(modifier); + ASSERT_TRUE(node != nullptr); + ASSERT_EQ(node->GetStagingProperties().GetFrame(), value); + node->RemoveModifier(modifier); + } + { + auto value = Vector2f(200.f, 300.f); + auto prop = std::make_shared>(value); + auto modifier = std::make_shared(prop); + node->AddModifier(modifier); + ASSERT_TRUE(node != nullptr); + ASSERT_EQ(node->GetStagingProperties().GetTranslate(), value); + node->RemoveModifier(modifier); + } + { + auto value = Vector2f(2.f, 2.f); + auto prop = std::make_shared>(value); + auto modifier = std::make_shared(prop); + node->AddModifier(modifier); + ASSERT_TRUE(node != nullptr); + ASSERT_EQ(node->GetStagingProperties().GetScale(), value); + node->RemoveModifier(modifier); + } + + auto node1 = std::make_shared(); + node1->DumpNode(0); + auto animation = std::make_shared(RSTransitionEffect::OPACITY, true); + animation->SetDuration(100); + animation->SetTimingCurve(RSAnimationTimingCurve::EASE_IN_OUT); + animation->SetFinishCallback([]() {}); + node1->AddAnimation(animation); + node1->DumpNode(0); + ASSERT_TRUE(node1->GetModifierIds().size() == 0); + auto value = Vector2f(2.f, 2.f); + auto prop = std::make_shared>(value); + auto modifier = std::make_shared(prop); + node1->AddModifier(modifier); + node1->DumpNode(0); + ASSERT_TRUE(node1->GetModifierIds().size() == 1); +} +} // namespace OHOS::Rosen diff --git a/display_server/rosen/test/render_service/render_service_client/ft_build/ui/rs_surface_extractor_test.cpp b/display_server/rosen/test/render_service/render_service_client/ft_build/ui/rs_surface_extractor_test.cpp new file mode 100644 index 0000000..e955170 --- /dev/null +++ b/display_server/rosen/test/render_service/render_service_client/ft_build/ui/rs_surface_extractor_test.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gtest/gtest.h" +#include "ui/rs_surface_extractor.h" +#include "ui/rs_surface_node.h" + +namespace OHOS::Rosen { +class RSSurfaceExtractorTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; + +void RSSurfaceExtractorTest::SetUpTestCase() {} +void RSSurfaceExtractorTest::TearDownTestCase() {} +void RSSurfaceExtractorTest::SetUp() {} +void RSSurfaceExtractorTest::TearDown() {} + +/** + * @tc.name: ExtractRSSurface001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceExtractorTest, ExtractRSSurface001) +{ + // RSSurfaceExtractor cannot be created, + // which constructor is privated. + // Only use its static function. + RSSurfaceNodeConfig c; + + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + ASSERT_TRUE(surfaceNode != nullptr); + + RSSurfaceExtractor::ExtractRSSurface(surfaceNode); + auto node = RSSurfaceExtractor::ExtractRSSurface(nullptr); + ASSERT_TRUE(node == nullptr); +} +} // namespace OHOS::Rosen \ No newline at end of file diff --git a/display_server/rosen/test/render_service/render_service_client/ft_build/ui/rs_surface_node_test.cpp b/display_server/rosen/test/render_service/render_service_client/ft_build/ui/rs_surface_node_test.cpp new file mode 100644 index 0000000..57dc532 --- /dev/null +++ b/display_server/rosen/test/render_service/render_service_client/ft_build/ui/rs_surface_node_test.cpp @@ -0,0 +1,1090 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gtest/gtest.h" +#include "ui/rs_surface_node.h" +#include "limit_number.h" +static constexpr uint32_t FIRST_COLOR_VALUE = 0x034123; +static constexpr uint32_t SECOND_COLOR_VALUE = 0x45ba87; +static constexpr uint32_t THIRD_COLOR_VALUE = 0x32aadd; +namespace OHOS::Rosen { +class RSSurfaceNodeTest : public testing::Test { +public: + constexpr static float floatData[] = { + 0.0f, 485.44f, -34.4f, + std::numeric_limits::max(), std::numeric_limits::min(), + }; + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; + +void RSSurfaceNodeTest::SetUpTestCase() {} +void RSSurfaceNodeTest::TearDownTestCase() {} +void RSSurfaceNodeTest::SetUp() {} +void RSSurfaceNodeTest::TearDown() {} + +/** + * @tc.name: Create001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, Create001) +{ + RSSurfaceNodeConfig c; + + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + ASSERT_TRUE(surfaceNode != nullptr); + + auto surface = surfaceNode->GetSurface(); + ASSERT_TRUE(surface != nullptr); +} + +/** + * @tc.name: CreateNodeInRenderThread001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, CreateNodeInRenderThread001) +{ + RSSurfaceNodeConfig c; + + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + ASSERT_TRUE(surfaceNode != nullptr); + + surfaceNode->CreateNodeInRenderThread(); +} + +/** + * @tc.name: SetBufferAvailableCallback001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, SetBufferAvailableCallback001) +{ + RSSurfaceNodeConfig c; + + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + ASSERT_TRUE(surfaceNode != nullptr); + + bool isSuccess = surfaceNode->SetBufferAvailableCallback([]() { + std::cout << "SetBufferAvailableCallback" << std::endl; + }); + ASSERT_TRUE(isSuccess); +} + +/** + * @tc.name: SetandGetBounds001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, SetandGetBounds001) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetBounds(TestSrc::limitNumber::floatLimit[0], TestSrc::limitNumber::floatLimit[1], + TestSrc::limitNumber::floatLimit[2], TestSrc::limitNumber::floatLimit[3]); + auto bounds = surfaceNode->GetStagingProperties().GetBounds(); + EXPECT_TRUE(ROSEN_EQ(bounds.x_, TestSrc::limitNumber::floatLimit[0])); + EXPECT_TRUE(ROSEN_EQ(bounds.y_, TestSrc::limitNumber::floatLimit[1])); + EXPECT_TRUE(ROSEN_EQ(bounds.z_, TestSrc::limitNumber::floatLimit[2])); + EXPECT_TRUE(ROSEN_EQ(bounds.w_, TestSrc::limitNumber::floatLimit[3])); +} + +/** + * @tc.name: SetandGetBounds002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, SetandGetBounds002) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetBounds(TestSrc::limitNumber::floatLimit[3], TestSrc::limitNumber::floatLimit[1], + TestSrc::limitNumber::floatLimit[2], TestSrc::limitNumber::floatLimit[0]); + auto bounds = surfaceNode->GetStagingProperties().GetBounds(); + EXPECT_TRUE(ROSEN_EQ(bounds.x_, TestSrc::limitNumber::floatLimit[3])); + EXPECT_TRUE(ROSEN_EQ(bounds.y_, TestSrc::limitNumber::floatLimit[1])); + EXPECT_TRUE(ROSEN_EQ(bounds.z_, TestSrc::limitNumber::floatLimit[2])); + EXPECT_TRUE(ROSEN_EQ(bounds.w_, TestSrc::limitNumber::floatLimit[0])); +} + +/** + * @tc.name: SetandGetBounds003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, SetandGetBounds003) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetBounds(TestSrc::limitNumber::floatLimit[3], TestSrc::limitNumber::floatLimit[2], + TestSrc::limitNumber::floatLimit[1], TestSrc::limitNumber::floatLimit[0]); + auto bounds = surfaceNode->GetStagingProperties().GetBounds(); + EXPECT_TRUE(ROSEN_EQ(bounds.x_, TestSrc::limitNumber::floatLimit[3])); + EXPECT_TRUE(ROSEN_EQ(bounds.y_, TestSrc::limitNumber::floatLimit[2])); + EXPECT_TRUE(ROSEN_EQ(bounds.z_, TestSrc::limitNumber::floatLimit[1])); + EXPECT_TRUE(ROSEN_EQ(bounds.w_, TestSrc::limitNumber::floatLimit[0])); +} + +/** + * @tc.name: SetandGetBounds004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, SetandGetBounds004) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + Vector4f quaternion(TestSrc::limitNumber::floatLimit[0], TestSrc::limitNumber::floatLimit[1], + TestSrc::limitNumber::floatLimit[2], TestSrc::limitNumber::floatLimit[3]); + surfaceNode->SetBounds(quaternion); + auto bounds = surfaceNode->GetStagingProperties().GetBounds(); + EXPECT_TRUE(ROSEN_EQ(bounds.x_, TestSrc::limitNumber::floatLimit[0])); + EXPECT_TRUE(ROSEN_EQ(bounds.y_, TestSrc::limitNumber::floatLimit[1])); + EXPECT_TRUE(ROSEN_EQ(bounds.z_, TestSrc::limitNumber::floatLimit[2])); + EXPECT_TRUE(ROSEN_EQ(bounds.w_, TestSrc::limitNumber::floatLimit[3])); +} + +/** + * @tc.name: SetandGetBounds005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, SetandGetBounds005) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + Vector4f quaternion(TestSrc::limitNumber::floatLimit[3], TestSrc::limitNumber::floatLimit[1], + TestSrc::limitNumber::floatLimit[2], TestSrc::limitNumber::floatLimit[0]); + surfaceNode->SetBounds(quaternion); + auto bounds = surfaceNode->GetStagingProperties().GetBounds(); + EXPECT_TRUE(ROSEN_EQ(bounds.x_, TestSrc::limitNumber::floatLimit[3])); + EXPECT_TRUE(ROSEN_EQ(bounds.y_, TestSrc::limitNumber::floatLimit[1])); + EXPECT_TRUE(ROSEN_EQ(bounds.z_, TestSrc::limitNumber::floatLimit[2])); + EXPECT_TRUE(ROSEN_EQ(bounds.w_, TestSrc::limitNumber::floatLimit[0])); +} + +/** + * @tc.name: SetandGetBounds006 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, SetandGetBounds006) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + Vector4f quaternion(TestSrc::limitNumber::floatLimit[3], TestSrc::limitNumber::floatLimit[2], + TestSrc::limitNumber::floatLimit[1], TestSrc::limitNumber::floatLimit[0]); + surfaceNode->SetBounds(quaternion); + auto bounds = surfaceNode->GetStagingProperties().GetBounds(); + EXPECT_TRUE(ROSEN_EQ(bounds.x_, TestSrc::limitNumber::floatLimit[3])); + EXPECT_TRUE(ROSEN_EQ(bounds.y_, TestSrc::limitNumber::floatLimit[2])); + EXPECT_TRUE(ROSEN_EQ(bounds.z_, TestSrc::limitNumber::floatLimit[1])); + EXPECT_TRUE(ROSEN_EQ(bounds.w_, TestSrc::limitNumber::floatLimit[0])); +} + +/** + * @tc.name: SetandGetBoundsWidth001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, SetandGetBoundsWidth001) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetBoundsWidth(TestSrc::limitNumber::floatLimit[1]); + auto bounds = surfaceNode->GetStagingProperties().GetBounds(); + EXPECT_TRUE(ROSEN_EQ(bounds.z_, TestSrc::limitNumber::floatLimit[1])); +} + +/** + * @tc.name: SetandGetBoundsWidth002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, SetandGetBoundsWidth002) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetBoundsWidth(TestSrc::limitNumber::floatLimit[2]); + auto bounds = surfaceNode->GetStagingProperties().GetBounds(); + EXPECT_TRUE(ROSEN_EQ(bounds.z_, TestSrc::limitNumber::floatLimit[2])); +} + +/** + * @tc.name: SetandGetBoundsWidth003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, SetandGetBoundsWidth003) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetBoundsWidth(TestSrc::limitNumber::floatLimit[3]); + auto bounds = surfaceNode->GetStagingProperties().GetBounds(); + EXPECT_TRUE(ROSEN_EQ(bounds.z_, TestSrc::limitNumber::floatLimit[3])); +} + +/** + * @tc.name: SetandGetBoundsWidth004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, SetandGetBoundsWidth004) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetBoundsWidth(TestSrc::limitNumber::floatLimit[4]); + auto bounds = surfaceNode->GetStagingProperties().GetBounds(); + EXPECT_TRUE(ROSEN_EQ(bounds.z_, TestSrc::limitNumber::floatLimit[4])); +} + +/** + * @tc.name: SetandGetBoundsWidth005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, SetandGetBoundsWidth005) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetBoundsWidth(TestSrc::limitNumber::floatLimit[0]); + auto bounds = surfaceNode->GetStagingProperties().GetBounds(); + EXPECT_TRUE(ROSEN_EQ(bounds.z_, TestSrc::limitNumber::floatLimit[0])); +} + +/** + * @tc.name: SetandGetBoundsHeight001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, SetandGetBoundsHeight001) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetBoundsHeight(TestSrc::limitNumber::floatLimit[1]); + auto bounds = surfaceNode->GetStagingProperties().GetBounds(); + EXPECT_TRUE(ROSEN_EQ(bounds.w_, TestSrc::limitNumber::floatLimit[1])); +} + +/** + * @tc.name: SetandGetBoundsHeight002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, SetandGetBoundsHeight002) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetBoundsHeight(TestSrc::limitNumber::floatLimit[2]); + auto bounds = surfaceNode->GetStagingProperties().GetBounds(); + EXPECT_TRUE(ROSEN_EQ(bounds.w_, TestSrc::limitNumber::floatLimit[2])); +} + +/** + * @tc.name: SetandGetBoundsHeight003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, SetandGetBoundsHeight003) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetBoundsHeight(TestSrc::limitNumber::floatLimit[3]); + auto bounds = surfaceNode->GetStagingProperties().GetBounds(); + EXPECT_TRUE(ROSEN_EQ(bounds.w_, TestSrc::limitNumber::floatLimit[3])); +} + +/** + * @tc.name: SetandGetBoundsHeight004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, SetandGetBoundsHeight004) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetBoundsHeight(TestSrc::limitNumber::floatLimit[4]); + auto bounds = surfaceNode->GetStagingProperties().GetBounds(); + EXPECT_TRUE(ROSEN_EQ(bounds.w_, TestSrc::limitNumber::floatLimit[4])); +} + +/** + * @tc.name: SetandGetBoundsHeight005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, SetandGetBoundsHeight005) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetBoundsHeight(TestSrc::limitNumber::floatLimit[0]); + auto bounds = surfaceNode->GetStagingProperties().GetBounds(); + EXPECT_TRUE(ROSEN_EQ(bounds.w_, TestSrc::limitNumber::floatLimit[0])); +} + +/** + * @tc.name: SetSecurityLayer001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, SetSecurityLayer001) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetSecurityLayer(true); + EXPECT_TRUE(surfaceNode->GetSecurityLayer()); +} + +/** + * @tc.name: SetSecurityLayer002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, SetSecurityLayer002) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetSecurityLayer(false); + EXPECT_FALSE(surfaceNode->GetSecurityLayer()); +} + +/** + * @tc.name: GetSecurityLayer001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, GetSecurityLayer001) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + EXPECT_FALSE(surfaceNode->GetSecurityLayer()); +} + +/** + * @tc.name: Marshalling001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, Marshalling001) +{ + RSSurfaceNodeConfig c; + + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + ASSERT_TRUE(surfaceNode != nullptr); + + Parcel parcel; + surfaceNode->Marshalling(parcel); +} + +/** + * @tc.name: Marshalling002 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, Marshalling002) +{ + Parcel parcel; + auto surfaceNode = RSSurfaceNode::Unmarshalling(parcel); + EXPECT_TRUE(surfaceNode == nullptr); +} + +/** + * @tc.name: Marshalling003 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, Marshalling003) +{ + RSSurfaceNodeConfig c; + + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + ASSERT_TRUE(surfaceNode != nullptr); + + Parcel parcel; + surfaceNode->Marshalling(parcel); + RSSurfaceNode::Unmarshalling(parcel); +} + +/** + * @tc.name: Marshalling004 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, Marshalling004) +{ + RSSurfaceNodeConfig c; + + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + ASSERT_TRUE(surfaceNode != nullptr); + + Parcel parcel; + surfaceNode->Marshalling(parcel); + RSSurfaceNode::Unmarshalling(parcel); + RSSurfaceNode::Unmarshalling(parcel); +} + +/** + * @tc.name: Marshalling005 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, Marshalling005) +{ + RSSurfaceNodeConfig c; + + RSSurfaceNode::SharedPtr surfaceNode1 = RSSurfaceNode::Create(c); + ASSERT_TRUE(surfaceNode1 != nullptr); + RSSurfaceNode::SharedPtr surfaceNode2 = RSSurfaceNode::Create(c); + ASSERT_TRUE(surfaceNode2 != nullptr); + + Parcel parcel; + surfaceNode1->Marshalling(parcel); + surfaceNode2->Marshalling(parcel); + RSSurfaceNode::Unmarshalling(parcel); +} + +/** + * @tc.name: GetSurface001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, GetSurface001) +{ + RSSurfaceNodeConfig c; + + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + ASSERT_TRUE(surfaceNode != nullptr); + + surfaceNode->GetSurface(); +} + +/** + * @tc.name: GetType001 + * @tc.desc: + * @tc.type:FUNC + */ +TEST_F(RSSurfaceNodeTest, GetType001) +{ + RSSurfaceNodeConfig c; + + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + ASSERT_TRUE(surfaceNode != nullptr); + ASSERT_TRUE(surfaceNode->GetType() == RSUINodeType::SURFACE_NODE); +} + +/** + * @tc.name: SetCornerRadius001 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetCornerRadius001) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetCornerRadius(floatData[0]); + ASSERT_TRUE(surfaceNode != nullptr); + auto result = surfaceNode->GetStagingProperties().GetCornerRadius()[0]; + EXPECT_TRUE(ROSEN_EQ(floatData[0], result)); +} + +/** + * @tc.name: SetCornerRadius002 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetCornerRadius002) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetCornerRadius(floatData[1]); + ASSERT_TRUE(surfaceNode != nullptr); + auto result = surfaceNode->GetStagingProperties().GetCornerRadius()[1]; + EXPECT_TRUE(ROSEN_EQ(floatData[1], result)); +} + +/** + * @tc.name: SetCornerRadius003 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetCornerRadius003) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetCornerRadius(floatData[2]); + ASSERT_TRUE(surfaceNode != nullptr); + auto result = surfaceNode->GetStagingProperties().GetCornerRadius()[2]; + EXPECT_TRUE(ROSEN_EQ(floatData[2], result)); +} + +/** + * @tc.name: SetBackgroundFilter001 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetBackgroundFilter001) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + std::shared_ptr backgroundFilter = RSFilter::CreateBlurFilter(floatData[0], + floatData[1]); + surfaceNode->SetBackgroundFilter(backgroundFilter); + EXPECT_TRUE(surfaceNode->GetStagingProperties().GetBackgroundFilter() == backgroundFilter); +} + +/** + * @tc.name: SetBackgroundFilter002 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetBackgroundFilter002) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + std::shared_ptr backgroundFilter = RSFilter::CreateBlurFilter(floatData[1], + floatData[2]); + surfaceNode->SetBackgroundFilter(backgroundFilter); + EXPECT_TRUE(surfaceNode->GetStagingProperties().GetBackgroundFilter() == backgroundFilter); +} + +/** + * @tc.name: SetBackgroundFilter003 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetBackgroundFilter003) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + std::shared_ptr backgroundFilter = RSFilter::CreateBlurFilter(floatData[2], + floatData[3]); + surfaceNode->SetBackgroundFilter(backgroundFilter); + EXPECT_TRUE(surfaceNode->GetStagingProperties().GetBackgroundFilter() == backgroundFilter); +} + +/** + * @tc.name: SetFilter001 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetFilter001) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + std::shared_ptr filter = RSFilter::CreateBlurFilter(floatData[0], + floatData[1]); + surfaceNode->SetFilter(filter); + EXPECT_TRUE(surfaceNode->GetStagingProperties().GetFilter() == filter); +} + +/** + * @tc.name: SetFilter002 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetFilter002) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + std::shared_ptr filter = RSFilter::CreateBlurFilter(floatData[1], + floatData[2]); + surfaceNode->SetFilter(filter); + EXPECT_TRUE(surfaceNode->GetStagingProperties().GetFilter() == filter); +} + +/** + * @tc.name: SetFilter003 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetFilter003) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + std::shared_ptr filter = RSFilter::CreateBlurFilter(floatData[2], + floatData[3]); + surfaceNode->SetFilter(filter); + EXPECT_TRUE(surfaceNode->GetStagingProperties().GetFilter() == filter); +} + +/** + * @tc.name: SetCompositingFilter001 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetCompositingFilter001) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + ASSERT_TRUE(surfaceNode != nullptr); + auto compositingFilter = RSFilter::CreateBlurFilter(floatData[0], + floatData[1]); + surfaceNode->SetCompositingFilter(compositingFilter); +} + +/** + * @tc.name: SetCompositingFilter002 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetCompositingFilter002) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + ASSERT_TRUE(surfaceNode != nullptr); + auto compositingFilter = RSFilter::CreateBlurFilter(floatData[1], + floatData[2]); + surfaceNode->SetCompositingFilter(compositingFilter); +} + +/** + * @tc.name: SetCompositingFilter003 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetCompositingFilter003) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + ASSERT_TRUE(surfaceNode != nullptr); + auto compositingFilter = RSFilter::CreateBlurFilter(floatData[2], + floatData[3]); + surfaceNode->SetCompositingFilter(compositingFilter); +} + +/** + * @tc.name: SetShadowOffset001 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetShadowOffset001) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetShadowOffset(floatData[2], floatData[3]); + EXPECT_TRUE(ROSEN_EQ(surfaceNode->GetStagingProperties().GetShadowOffsetX(), floatData[2])); + EXPECT_TRUE(ROSEN_EQ(surfaceNode->GetStagingProperties().GetShadowOffsetY(), floatData[3])); +} + +/** + * @tc.name: SetShadowOffset002 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetShadowOffset002) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetShadowOffset(floatData[2], floatData[0]); + EXPECT_TRUE(ROSEN_EQ(surfaceNode->GetStagingProperties().GetShadowOffsetX(), floatData[2])); + EXPECT_TRUE(ROSEN_EQ(surfaceNode->GetStagingProperties().GetShadowOffsetY(), floatData[0])); +} + +/** + * @tc.name: SetShadowOffset003 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetShadowOffset003) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetShadowOffset(floatData[1], floatData[3]); + EXPECT_TRUE(ROSEN_EQ(surfaceNode->GetStagingProperties().GetShadowOffsetX(), floatData[1])); + EXPECT_TRUE(ROSEN_EQ(surfaceNode->GetStagingProperties().GetShadowOffsetY(), floatData[3])); +} +/** + * @tc.name: SetShadowOffsetX001 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetShadowOffsetX001) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetShadowOffsetX(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(surfaceNode->GetStagingProperties().GetShadowOffsetX(), floatData[1])); +} + +/** + * @tc.name: SetShadowOffsetX002 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetShadowOffsetX002) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetShadowOffsetX(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(surfaceNode->GetStagingProperties().GetShadowOffsetX(), floatData[2])); +} + +/** + * @tc.name: SetShadowOffsetX003 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetShadowOffsetX003) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetShadowOffsetX(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(surfaceNode->GetStagingProperties().GetShadowOffsetX(), floatData[3])); +} + +/** + * @tc.name: SetShadowOffsetY001 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetShadowOffsetY001) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetShadowOffsetY(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(surfaceNode->GetStagingProperties().GetShadowOffsetY(), floatData[1])); +} + +/** + * @tc.name: SetShadowOffsetY002 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetShadowOffsetY002) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetShadowOffsetY(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(surfaceNode->GetStagingProperties().GetShadowOffsetY(), floatData[2])); +} + +/** + * @tc.name: SetShadowOffsetY003 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetShadowOffsetY003) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetShadowOffsetY(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(surfaceNode->GetStagingProperties().GetShadowOffsetY(), floatData[3])); +} + +/** + * @tc.name: SetShadowAlpha001 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetShadowAlpha001) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetShadowAlpha(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(surfaceNode->GetStagingProperties().GetShadowAlpha(), floatData[1])); +} + +/** + * @tc.name: SetShadowAlpha002 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetShadowAlpha002) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetShadowAlpha(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(surfaceNode->GetStagingProperties().GetShadowAlpha(), floatData[2])); +} + +/** + * @tc.name: SetShadowAlpha003 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetShadowAlpha003) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetShadowAlpha(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(surfaceNode->GetStagingProperties().GetShadowAlpha(), floatData[3])); +} + +/** + * @tc.name: SetShadowElevation001 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetShadowElevation001) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetShadowElevation(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(surfaceNode->GetStagingProperties().GetShadowElevation(), floatData[1])); +} + +/** + * @tc.name: SetShadowElevation002 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetShadowElevation002) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetShadowElevation(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(surfaceNode->GetStagingProperties().GetShadowElevation(), floatData[2])); +} + +/** + * @tc.name: SetShadowElevation003 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetShadowElevation003) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetShadowElevation(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(surfaceNode->GetStagingProperties().GetShadowElevation(), floatData[3])); +} + +/** + * @tc.name: SetShadowRadius001 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetShadowRadius001) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetShadowRadius(floatData[1]); + EXPECT_TRUE(ROSEN_EQ(surfaceNode->GetStagingProperties().GetShadowRadius(), floatData[1])); +} + +/** + * @tc.name: SetShadowRadius002 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetShadowRadius002) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetShadowRadius(floatData[2]); + EXPECT_TRUE(ROSEN_EQ(surfaceNode->GetStagingProperties().GetShadowRadius(), floatData[2])); +} + +/** + * @tc.name: SetShadowRadius003 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetShadowRadius003) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetShadowRadius(floatData[3]); + EXPECT_TRUE(ROSEN_EQ(surfaceNode->GetStagingProperties().GetShadowRadius(), floatData[3])); +} + +/** + * @tc.name: SetShadowColor001 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetShadowColor001) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetShadowColor(FIRST_COLOR_VALUE); + EXPECT_TRUE(surfaceNode->GetStagingProperties().GetShadowColor() == Color::FromArgbInt(FIRST_COLOR_VALUE)); +} + +/** + * @tc.name: SetShadowColor002 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetShadowColor002) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetShadowColor(SECOND_COLOR_VALUE); + EXPECT_TRUE(surfaceNode->GetStagingProperties().GetShadowColor() == Color::FromArgbInt(SECOND_COLOR_VALUE)); +} + +/** + * @tc.name: SetShadowColor003 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetShadowColor003) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetShadowColor(THIRD_COLOR_VALUE); + EXPECT_TRUE(surfaceNode->GetStagingProperties().GetShadowColor() == Color::FromArgbInt(THIRD_COLOR_VALUE)); +} + +/** + * @tc.name: SetAppFreeze001 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetAppFreeze001) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetAppFreeze(true); +} + +/** + * @tc.name: SetContainerWindow001 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetContainerWindow001) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetContainerWindow(true, 1.f); +} + +/** + * @tc.name: SetIsNotifyUIBufferAvailable001 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, SetIsNotifyUIBufferAvailable001) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->SetIsNotifyUIBufferAvailable(true); +} + +/** + * @tc.name: ClearChildren001 + * @tc.desc: + * @tc.type: FUNC + * @tc.require: issueI5J8R1 + */ +TEST_F(RSSurfaceNodeTest, ClearChildren001) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + surfaceNode->CreateNodeInRenderThread(); + RSSurfaceNodeConfig c2; + RSSurfaceNode::SharedPtr surfaceNode2 = RSSurfaceNode::Create(c2); + surfaceNode->AddChild(surfaceNode2, -1); + surfaceNode->RemoveChild(surfaceNode2); + surfaceNode->ClearChildren(); +} + +/** + * @tc.name: SetAppFreeze Test True + * @tc.desc: SetAppFreeze Test True + * @tc.type: FUNC + * @tc.require: + */ +TEST_F(RSSurfaceNodeTest, SetAppFreeze_True) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + ASSERT_NE(surfaceNode, nullptr); + surfaceNode->SetAppFreeze(true); +} + +/** + * @tc.name: SetAppFreeze Test False + * @tc.desc: SetAppFreeze Test False + * @tc.type: FUNC + * @tc.require: + */ +TEST_F(RSSurfaceNodeTest, SetAppFreeze_False) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + ASSERT_NE(surfaceNode, nullptr); + surfaceNode->SetAppFreeze(false); +} + +/** + * @tc.name: SetContainerWindow Test True + * @tc.desc: SetContainerWindow Test True + * @tc.type: FUNC + * @tc.require: + */ +TEST_F(RSSurfaceNodeTest, SetContainerWindow_True) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + ASSERT_NE(surfaceNode, nullptr); + surfaceNode->SetContainerWindow(true, 1.0f); +} + +/** + * @tc.name: SetContainerWindow Test False + * @tc.desc: SetContainerWindow Test False + * @tc.type: FUNC + * @tc.require: + */ +TEST_F(RSSurfaceNodeTest, SetContainerWindow_False) +{ + RSSurfaceNodeConfig c; + RSSurfaceNode::SharedPtr surfaceNode = RSSurfaceNode::Create(c); + ASSERT_NE(surfaceNode, nullptr); + surfaceNode->SetContainerWindow(false, 1.0f); +} +} // namespace OHOS::Rosen \ No newline at end of file -- Gitee From e6036f89cf161b7a3f2438bb92e9220e68245c80 Mon Sep 17 00:00:00 2001 From: fseeeye Date: Wed, 19 Jul 2023 10:07:19 +0800 Subject: [PATCH 3/4] test: adjust test code --- build/gn/BUILD.gn | 2 +- display_server/frameworks/surface/test/ft_build/BUILD.gn | 4 ++-- .../{systemtest => ft_build}/native_window_buffer_test_oe.cpp | 0 .../render_service_client/test/unittest/ft_build/BUILD.gn | 3 --- .../test/render_service/render_service_base/ft_build/BUILD.gn | 4 ---- 5 files changed, 3 insertions(+), 10 deletions(-) rename display_server/frameworks/surface/test/{systemtest => ft_build}/native_window_buffer_test_oe.cpp (100%) diff --git a/build/gn/BUILD.gn b/build/gn/BUILD.gn index bae243d..0787c0a 100644 --- a/build/gn/BUILD.gn +++ b/build/gn/BUILD.gn @@ -45,7 +45,7 @@ group("ft_test") { "//display_server/rosen/samples/composer/ft_build:hello_composer", # Surface "//display_server/frameworks/surface/test/ft_build:unittest", - "//display_server/frameworks/surface/test/ft_build:sample", + "//display_server/frameworks/surface/test/ft_build:systemtest", # RS "//display_server/rosen/test/render_service/render_service_base/ft_build:unittest", "//display_server/rosen/test/render_service/render_service_client/ft_build:unittest", diff --git a/display_server/frameworks/surface/test/ft_build/BUILD.gn b/display_server/frameworks/surface/test/ft_build/BUILD.gn index d076213..bb649a3 100644 --- a/display_server/frameworks/surface/test/ft_build/BUILD.gn +++ b/display_server/frameworks/surface/test/ft_build/BUILD.gn @@ -14,7 +14,7 @@ import("//build/gn/fangtian.gni") import("//display_server/ft_build/ds_config.gni") -group("sample") { +group("systemtest") { testonly = true deps = [ @@ -49,7 +49,7 @@ group("unittest") { ft_executable("native_window_buffer_test_oe") { testonly = true - sources = [ "../systemtest/native_window_buffer_test_oe.cpp" ] + sources = [ "native_window_buffer_test_oe.cpp" ] cflags = [ "-Wall", diff --git a/display_server/frameworks/surface/test/systemtest/native_window_buffer_test_oe.cpp b/display_server/frameworks/surface/test/ft_build/native_window_buffer_test_oe.cpp similarity index 100% rename from display_server/frameworks/surface/test/systemtest/native_window_buffer_test_oe.cpp rename to display_server/frameworks/surface/test/ft_build/native_window_buffer_test_oe.cpp diff --git a/display_server/rosen/modules/render_service_client/test/unittest/ft_build/BUILD.gn b/display_server/rosen/modules/render_service_client/test/unittest/ft_build/BUILD.gn index ce07b60..a37f967 100644 --- a/display_server/rosen/modules/render_service_client/test/unittest/ft_build/BUILD.gn +++ b/display_server/rosen/modules/render_service_client/test/unittest/ft_build/BUILD.gn @@ -31,8 +31,6 @@ config("rs_client_test_common_public_config") { "-Wall", "-Werror", "-g3", - # "-Dprivate=public", - # "-Dprotected=public", ] } @@ -61,4 +59,3 @@ ft_executable("RSInterfacesTest") { deps = [ ":rs_client_test_common" ] } - diff --git a/display_server/rosen/test/render_service/render_service_base/ft_build/BUILD.gn b/display_server/rosen/test/render_service/render_service_base/ft_build/BUILD.gn index 7ce9b35..f107cf0 100644 --- a/display_server/rosen/test/render_service/render_service_base/ft_build/BUILD.gn +++ b/display_server/rosen/test/render_service/render_service_base/ft_build/BUILD.gn @@ -28,18 +28,14 @@ ft_executable("RSRenderServiceBaseTransactionTest") { ] include_dirs = [ - # "$ace_root", "//display_server/rosen/modules/render_service_base", "//display_server/interfaces/inner_api/common", "//display_server/rosen/modules/render_service_base/include", "//display_server/rosen/include", "//display_server/rosen/test/include", - # "//third_party/flutter/skia/src", ] configs = [ - # ":transaction_test", - # "$ace_root:ace_test_config", "//display_server/rosen/modules/render_service_base/ft_build:render_service_base_public_config", ] -- Gitee From cc6ac7954b40ffc721c0222a954c2d612da5c8af Mon Sep 17 00:00:00 2001 From: fseeeye Date: Wed, 19 Jul 2023 11:19:54 +0800 Subject: [PATCH 4/4] build: fix native_vsync_test building error --- .../rosen/modules/composer/native_vsync/ft_build/BUILD.gn | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/display_server/rosen/modules/composer/native_vsync/ft_build/BUILD.gn b/display_server/rosen/modules/composer/native_vsync/ft_build/BUILD.gn index 555e982..538f159 100644 --- a/display_server/rosen/modules/composer/native_vsync/ft_build/BUILD.gn +++ b/display_server/rosen/modules/composer/native_vsync/ft_build/BUILD.gn @@ -42,11 +42,9 @@ ft_shared_library("libnative_vsync") { output_extension = "so" - deps = [ + public_deps = [ "//display_server/rosen/modules/render_service_client/ft_build:librender_service_client", - ] - public_deps = [ "//build/gn/configs/system_libs:c_utils", "//build/gn/configs/system_libs:hilog", ] -- Gitee