132a6e48fSopenharmony_ci/* 232a6e48fSopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 332a6e48fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 432a6e48fSopenharmony_ci * you may not use this file except in compliance with the License. 532a6e48fSopenharmony_ci * You may obtain a copy of the License at 632a6e48fSopenharmony_ci * 732a6e48fSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 832a6e48fSopenharmony_ci * 932a6e48fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1032a6e48fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1132a6e48fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1232a6e48fSopenharmony_ci * See the License for the specific language governing permissions and 1332a6e48fSopenharmony_ci * limitations under the License. 1432a6e48fSopenharmony_ci */ 1532a6e48fSopenharmony_ci#include <securec.h> 1632a6e48fSopenharmony_ci#include <gtest/gtest.h> 1732a6e48fSopenharmony_ci#include <surface.h> 1832a6e48fSopenharmony_ci#include <consumer_surface.h> 1932a6e48fSopenharmony_ci#include <producer_surface.h> 2032a6e48fSopenharmony_ci#include "buffer_consumer_listener.h" 2132a6e48fSopenharmony_ci#include <native_window.h> 2232a6e48fSopenharmony_ci#include "sync_fence.h" 2332a6e48fSopenharmony_ci#include "producer_surface_delegator.h" 2432a6e48fSopenharmony_ci 2532a6e48fSopenharmony_ciusing namespace testing; 2632a6e48fSopenharmony_ciusing namespace testing::ext; 2732a6e48fSopenharmony_ci 2832a6e48fSopenharmony_cinamespace OHOS::Rosen { 2932a6e48fSopenharmony_ciclass ProducerSurfaceTest : public testing::Test { 3032a6e48fSopenharmony_cipublic: 3132a6e48fSopenharmony_ci static void SetUpTestCase(); 3232a6e48fSopenharmony_ci static void TearDownTestCase(); 3332a6e48fSopenharmony_ci void SetUp() override; 3432a6e48fSopenharmony_ci void TearDown() override; 3532a6e48fSopenharmony_ci 3632a6e48fSopenharmony_ci static inline BufferRequestConfig requestConfig = { 3732a6e48fSopenharmony_ci .width = 0x100, 3832a6e48fSopenharmony_ci .height = 0x100, 3932a6e48fSopenharmony_ci .strideAlignment = 0x8, 4032a6e48fSopenharmony_ci .format = GRAPHIC_PIXEL_FMT_RGBA_8888, 4132a6e48fSopenharmony_ci .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE | BUFFER_USAGE_MEM_DMA, 4232a6e48fSopenharmony_ci .timeout = 0, 4332a6e48fSopenharmony_ci }; 4432a6e48fSopenharmony_ci static inline BufferFlushConfig flushConfig = { 4532a6e48fSopenharmony_ci .damage = { 4632a6e48fSopenharmony_ci .w = 0x100, 4732a6e48fSopenharmony_ci .h = 0x100, 4832a6e48fSopenharmony_ci }, 4932a6e48fSopenharmony_ci }; 5032a6e48fSopenharmony_ci static inline int64_t timestamp = 0; 5132a6e48fSopenharmony_ci static inline Rect damage = {}; 5232a6e48fSopenharmony_ci static inline sptr<IConsumerSurface> csurf = nullptr; 5332a6e48fSopenharmony_ci static inline sptr<IBufferProducer> producer = nullptr; 5432a6e48fSopenharmony_ci static inline sptr<Surface> pSurface = nullptr; 5532a6e48fSopenharmony_ci static inline sptr<ProducerSurfaceDelegator> surfaceDelegator = nullptr; 5632a6e48fSopenharmony_ci static inline uint32_t firstSeqnum = 0; 5732a6e48fSopenharmony_ci 5832a6e48fSopenharmony_ci static inline GSError OnBufferRelease(sptr<SurfaceBuffer> &buffer) 5932a6e48fSopenharmony_ci { 6032a6e48fSopenharmony_ci return GSERROR_OK; 6132a6e48fSopenharmony_ci } 6232a6e48fSopenharmony_ci sptr<ProducerSurface> surface_ = nullptr; 6332a6e48fSopenharmony_ci}; 6432a6e48fSopenharmony_ci 6532a6e48fSopenharmony_civoid ProducerSurfaceTest::SetUpTestCase() 6632a6e48fSopenharmony_ci{ 6732a6e48fSopenharmony_ci csurf = IConsumerSurface::Create(); 6832a6e48fSopenharmony_ci sptr<IBufferConsumerListener> listener = new BufferConsumerListener(); 6932a6e48fSopenharmony_ci csurf->RegisterConsumerListener(listener); 7032a6e48fSopenharmony_ci producer = csurf->GetProducer(); 7132a6e48fSopenharmony_ci pSurface = Surface::CreateSurfaceAsProducer(producer); 7232a6e48fSopenharmony_ci pSurface->RegisterReleaseListener(OnBufferRelease); 7332a6e48fSopenharmony_ci} 7432a6e48fSopenharmony_ci 7532a6e48fSopenharmony_civoid ProducerSurfaceTest::TearDownTestCase() 7632a6e48fSopenharmony_ci{ 7732a6e48fSopenharmony_ci pSurface->UnRegisterReleaseListener(); 7832a6e48fSopenharmony_ci csurf = nullptr; 7932a6e48fSopenharmony_ci producer = nullptr; 8032a6e48fSopenharmony_ci pSurface = nullptr; 8132a6e48fSopenharmony_ci} 8232a6e48fSopenharmony_ci 8332a6e48fSopenharmony_civoid ProducerSurfaceTest::SetUp() 8432a6e48fSopenharmony_ci{ 8532a6e48fSopenharmony_ci surface_ = new ProducerSurface(producer); 8632a6e48fSopenharmony_ci ASSERT_NE(surface_, nullptr); 8732a6e48fSopenharmony_ci surface_->producer_ = nullptr; 8832a6e48fSopenharmony_ci} 8932a6e48fSopenharmony_ci 9032a6e48fSopenharmony_civoid ProducerSurfaceTest::TearDown() 9132a6e48fSopenharmony_ci{ 9232a6e48fSopenharmony_ci surface_ = nullptr; 9332a6e48fSopenharmony_ci} 9432a6e48fSopenharmony_ci 9532a6e48fSopenharmony_ci/* 9632a6e48fSopenharmony_ci* Function: ProducerSurface 9732a6e48fSopenharmony_ci* Type: Function 9832a6e48fSopenharmony_ci* Rank: Important(2) 9932a6e48fSopenharmony_ci* EnvConditions: N/A 10032a6e48fSopenharmony_ci* CaseDescription: 1. check pSurface 10132a6e48fSopenharmony_ci */ 10232a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, ProducerSurface001, Function | MediumTest | Level2) 10332a6e48fSopenharmony_ci{ 10432a6e48fSopenharmony_ci ASSERT_NE(pSurface, nullptr); 10532a6e48fSopenharmony_ci} 10632a6e48fSopenharmony_ci 10732a6e48fSopenharmony_ci/* 10832a6e48fSopenharmony_ci* Function: GetProducerInitInfo 10932a6e48fSopenharmony_ci* Type: Function 11032a6e48fSopenharmony_ci* Rank: Important(2) 11132a6e48fSopenharmony_ci* EnvConditions: N/A 11232a6e48fSopenharmony_ci* CaseDescription: 1. check pSurface 11332a6e48fSopenharmony_ci */ 11432a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, GetProducerInitInfo001, Function | MediumTest | Level2) 11532a6e48fSopenharmony_ci{ 11632a6e48fSopenharmony_ci ProducerInitInfo info; 11732a6e48fSopenharmony_ci GSError ret = surface_->GetProducerInitInfo(info); 11832a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 11932a6e48fSopenharmony_ci} 12032a6e48fSopenharmony_ci 12132a6e48fSopenharmony_ci/* 12232a6e48fSopenharmony_ci* Function: RequestBuffer 12332a6e48fSopenharmony_ci* Type: Function 12432a6e48fSopenharmony_ci* Rank: Important(2) 12532a6e48fSopenharmony_ci* EnvConditions: N/A 12632a6e48fSopenharmony_ci* CaseDescription: 1. call RequestBuffer with producer_ is nullptr 12732a6e48fSopenharmony_ci* 2. check ret 12832a6e48fSopenharmony_ci */ 12932a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, RequestBuffer001, Function | MediumTest | Level2) 13032a6e48fSopenharmony_ci{ 13132a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer = SurfaceBuffer::Create(); 13232a6e48fSopenharmony_ci int releaseFence = -1; 13332a6e48fSopenharmony_ci GSError ret = surface_->RequestBuffer(buffer, releaseFence, requestConfig); 13432a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 13532a6e48fSopenharmony_ci} 13632a6e48fSopenharmony_ci 13732a6e48fSopenharmony_ci/* 13832a6e48fSopenharmony_ci* Function: RequestBuffer 13932a6e48fSopenharmony_ci* Type: Function 14032a6e48fSopenharmony_ci* Rank: Important(2) 14132a6e48fSopenharmony_ci* EnvConditions: N/A 14232a6e48fSopenharmony_ci* CaseDescription: 1. call RequestBuffer with nullptr params 14332a6e48fSopenharmony_ci* 2. check ret 14432a6e48fSopenharmony_ci */ 14532a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, RequestBuffer002, Function | MediumTest | Level2) 14632a6e48fSopenharmony_ci{ 14732a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer = nullptr; 14832a6e48fSopenharmony_ci int releaseFence = -1; 14932a6e48fSopenharmony_ci GSError ret = surface_->RequestBuffer(buffer, releaseFence, requestConfig); 15032a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 15132a6e48fSopenharmony_ci} 15232a6e48fSopenharmony_ci 15332a6e48fSopenharmony_ci/* 15432a6e48fSopenharmony_ci* Function: RequestBuffer 15532a6e48fSopenharmony_ci* Type: Function 15632a6e48fSopenharmony_ci* Rank: Important(2) 15732a6e48fSopenharmony_ci* EnvConditions: N/A 15832a6e48fSopenharmony_ci* CaseDescription: 1. call RequestBuffer with nullptr params 15932a6e48fSopenharmony_ci* 2. check ret 16032a6e48fSopenharmony_ci */ 16132a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, RequestBuffer003, Function | MediumTest | Level2) 16232a6e48fSopenharmony_ci{ 16332a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer = SurfaceBuffer::Create(); 16432a6e48fSopenharmony_ci sptr<SyncFence> releaseFence = nullptr; 16532a6e48fSopenharmony_ci GSError ret = surface_->RequestBuffer(buffer, releaseFence, requestConfig); 16632a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 16732a6e48fSopenharmony_ci} 16832a6e48fSopenharmony_ci 16932a6e48fSopenharmony_ci/* 17032a6e48fSopenharmony_ci* Function: RequestBuffer 17132a6e48fSopenharmony_ci* Type: Function 17232a6e48fSopenharmony_ci* Rank: Important(2) 17332a6e48fSopenharmony_ci* EnvConditions: N/A 17432a6e48fSopenharmony_ci* CaseDescription: 1. call RequestBuffer with nullptr params 17532a6e48fSopenharmony_ci* 2. check ret 17632a6e48fSopenharmony_ci */ 17732a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, RequestBuffer004, Function | MediumTest | Level2) 17832a6e48fSopenharmony_ci{ 17932a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer = nullptr; 18032a6e48fSopenharmony_ci sptr<SyncFence> releaseFence = nullptr; 18132a6e48fSopenharmony_ci GSError ret = surface_->RequestBuffer(buffer, releaseFence, requestConfig); 18232a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 18332a6e48fSopenharmony_ci} 18432a6e48fSopenharmony_ci 18532a6e48fSopenharmony_ci/* 18632a6e48fSopenharmony_ci* Function: RequestBuffers 18732a6e48fSopenharmony_ci* Type: Function 18832a6e48fSopenharmony_ci* Rank: Important(2) 18932a6e48fSopenharmony_ci* EnvConditions: N/A 19032a6e48fSopenharmony_ci* CaseDescription: 1. call RequestBuffers with producer_ is nullptr 19132a6e48fSopenharmony_ci* 2. check ret 19232a6e48fSopenharmony_ci */ 19332a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, RequestBuffers001, Function | MediumTest | Level2) 19432a6e48fSopenharmony_ci{ 19532a6e48fSopenharmony_ci std::vector<sptr<SurfaceBuffer>> sfbuffers; 19632a6e48fSopenharmony_ci std::vector<sptr<SyncFence>> releaseFences; 19732a6e48fSopenharmony_ci GSError ret = surface_->RequestBuffers(sfbuffers, releaseFences, requestConfig); 19832a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 19932a6e48fSopenharmony_ci} 20032a6e48fSopenharmony_ci 20132a6e48fSopenharmony_ci/* 20232a6e48fSopenharmony_ci* Function: FlushBuffer 20332a6e48fSopenharmony_ci* Type: Function 20432a6e48fSopenharmony_ci* Rank: Important(2) 20532a6e48fSopenharmony_ci* EnvConditions: N/A 20632a6e48fSopenharmony_ci* CaseDescription: 1. call FlushBuffer with producer_ is nullptr 20732a6e48fSopenharmony_ci* 2. check ret 20832a6e48fSopenharmony_ci */ 20932a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, FlushBuffer001, Function | MediumTest | Level2) 21032a6e48fSopenharmony_ci{ 21132a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer = SurfaceBuffer::Create(); 21232a6e48fSopenharmony_ci GSError ret = surface_->FlushBuffer(buffer, SyncFence::INVALID_FENCE, flushConfig); 21332a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 21432a6e48fSopenharmony_ci} 21532a6e48fSopenharmony_ci 21632a6e48fSopenharmony_ci/* 21732a6e48fSopenharmony_ci* Function: FlushBuffer 21832a6e48fSopenharmony_ci* Type: Function 21932a6e48fSopenharmony_ci* Rank: Important(2) 22032a6e48fSopenharmony_ci* EnvConditions: N/A 22132a6e48fSopenharmony_ci* CaseDescription: 1. call FlushBuffer with nullptr params 22232a6e48fSopenharmony_ci* 2. check ret 22332a6e48fSopenharmony_ci */ 22432a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, FlushBuffer002, Function | MediumTest | Level2) 22532a6e48fSopenharmony_ci{ 22632a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer = SurfaceBuffer::Create(); 22732a6e48fSopenharmony_ci GSError ret = surface_->FlushBuffer(buffer, nullptr, flushConfig); 22832a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 22932a6e48fSopenharmony_ci} 23032a6e48fSopenharmony_ci 23132a6e48fSopenharmony_ci/* 23232a6e48fSopenharmony_ci* Function: FlushBuffer 23332a6e48fSopenharmony_ci* Type: Function 23432a6e48fSopenharmony_ci* Rank: Important(2) 23532a6e48fSopenharmony_ci* EnvConditions: N/A 23632a6e48fSopenharmony_ci* CaseDescription: 1. call FlushBuffer with nullptr params 23732a6e48fSopenharmony_ci* 2. check ret 23832a6e48fSopenharmony_ci */ 23932a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, FlushBuffer003, Function | MediumTest | Level2) 24032a6e48fSopenharmony_ci{ 24132a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer = nullptr; 24232a6e48fSopenharmony_ci GSError ret = surface_->FlushBuffer(buffer, SyncFence::INVALID_FENCE, flushConfig); 24332a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 24432a6e48fSopenharmony_ci} 24532a6e48fSopenharmony_ci 24632a6e48fSopenharmony_ci/* 24732a6e48fSopenharmony_ci* Function: FlushBuffers 24832a6e48fSopenharmony_ci* Type: Function 24932a6e48fSopenharmony_ci* Rank: Important(2) 25032a6e48fSopenharmony_ci* EnvConditions: N/A 25132a6e48fSopenharmony_ci* CaseDescription: 1. call FlushBuffers with producer_ is nullptr 25232a6e48fSopenharmony_ci* 2. check ret 25332a6e48fSopenharmony_ci */ 25432a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, FlushBuffers001, Function | MediumTest | Level2) 25532a6e48fSopenharmony_ci{ 25632a6e48fSopenharmony_ci std::vector<sptr<SurfaceBuffer>> buffers; 25732a6e48fSopenharmony_ci buffers.push_back(SurfaceBuffer::Create()); 25832a6e48fSopenharmony_ci std::vector<sptr<SyncFence>> flushFences; 25932a6e48fSopenharmony_ci std::vector<BufferFlushConfigWithDamages> configs; 26032a6e48fSopenharmony_ci GSError ret = surface_->FlushBuffers(buffers, flushFences, configs); 26132a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 26232a6e48fSopenharmony_ci} 26332a6e48fSopenharmony_ci 26432a6e48fSopenharmony_ci/* 26532a6e48fSopenharmony_ci* Function: GetLastFlushedBuffer 26632a6e48fSopenharmony_ci* Type: Function 26732a6e48fSopenharmony_ci* Rank: Important(2) 26832a6e48fSopenharmony_ci* EnvConditions: N/A 26932a6e48fSopenharmony_ci* CaseDescription: 1. call GetLastFlushedBuffer with producer_ is nullptr 27032a6e48fSopenharmony_ci* 2. check ret 27132a6e48fSopenharmony_ci */ 27232a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, GetLastFlushedBuffer001, Function | MediumTest | Level2) 27332a6e48fSopenharmony_ci{ 27432a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer = SurfaceBuffer::Create(); 27532a6e48fSopenharmony_ci sptr<SyncFence> fence; 27632a6e48fSopenharmony_ci float matrix[16]; 27732a6e48fSopenharmony_ci GSError ret = surface_->GetLastFlushedBuffer(buffer, fence, matrix, false); 27832a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 27932a6e48fSopenharmony_ci} 28032a6e48fSopenharmony_ci 28132a6e48fSopenharmony_ci/* 28232a6e48fSopenharmony_ci* Function: CancelBuffer 28332a6e48fSopenharmony_ci* Type: Function 28432a6e48fSopenharmony_ci* Rank: Important(2) 28532a6e48fSopenharmony_ci* EnvConditions: N/A 28632a6e48fSopenharmony_ci* CaseDescription: 1. call CancelBuffer with producer_ is nullptr 28732a6e48fSopenharmony_ci* 2. check ret 28832a6e48fSopenharmony_ci */ 28932a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, CancelBuffer001, Function | MediumTest | Level2) 29032a6e48fSopenharmony_ci{ 29132a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer = SurfaceBuffer::Create(); 29232a6e48fSopenharmony_ci GSError ret = surface_->CancelBuffer(buffer); 29332a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::SURFACE_ERROR_UNKOWN); 29432a6e48fSopenharmony_ci} 29532a6e48fSopenharmony_ci 29632a6e48fSopenharmony_ci/* 29732a6e48fSopenharmony_ci* Function: AttachBufferToQueue 29832a6e48fSopenharmony_ci* Type: Function 29932a6e48fSopenharmony_ci* Rank: Important(2) 30032a6e48fSopenharmony_ci* EnvConditions: N/A 30132a6e48fSopenharmony_ci* CaseDescription: 1. call AttachBufferToQueue with producer_ is nullptr 30232a6e48fSopenharmony_ci* 2. check ret 30332a6e48fSopenharmony_ci */ 30432a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, AttachBufferToQueue001, Function | MediumTest | Level2) 30532a6e48fSopenharmony_ci{ 30632a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer = SurfaceBuffer::Create(); 30732a6e48fSopenharmony_ci GSError ret = surface_->AttachBufferToQueue(buffer); 30832a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::SURFACE_ERROR_UNKOWN); 30932a6e48fSopenharmony_ci} 31032a6e48fSopenharmony_ci 31132a6e48fSopenharmony_ci/* 31232a6e48fSopenharmony_ci* Function: DetachBufferFromQueue 31332a6e48fSopenharmony_ci* Type: Function 31432a6e48fSopenharmony_ci* Rank: Important(2) 31532a6e48fSopenharmony_ci* EnvConditions: N/A 31632a6e48fSopenharmony_ci* CaseDescription: 1. call DetachBufferFromQueue with producer_ is nullptr 31732a6e48fSopenharmony_ci* 2. check ret 31832a6e48fSopenharmony_ci */ 31932a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, DetachBufferFromQueue001, Function | MediumTest | Level2) 32032a6e48fSopenharmony_ci{ 32132a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer = SurfaceBuffer::Create(); 32232a6e48fSopenharmony_ci GSError ret = surface_->DetachBufferFromQueue(buffer); 32332a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::SURFACE_ERROR_UNKOWN); 32432a6e48fSopenharmony_ci} 32532a6e48fSopenharmony_ci 32632a6e48fSopenharmony_ci/* 32732a6e48fSopenharmony_ci* Function: DetachBuffer 32832a6e48fSopenharmony_ci* Type: Function 32932a6e48fSopenharmony_ci* Rank: Important(2) 33032a6e48fSopenharmony_ci* EnvConditions: N/A 33132a6e48fSopenharmony_ci* CaseDescription: 1. call DetachBuffer with producer_ is nullptr 33232a6e48fSopenharmony_ci* 2. check ret 33332a6e48fSopenharmony_ci */ 33432a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, DetachBuffer001, Function | MediumTest | Level2) 33532a6e48fSopenharmony_ci{ 33632a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer = SurfaceBuffer::Create(); 33732a6e48fSopenharmony_ci GSError ret = surface_->DetachBuffer(buffer); 33832a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 33932a6e48fSopenharmony_ci} 34032a6e48fSopenharmony_ci 34132a6e48fSopenharmony_ci/* 34232a6e48fSopenharmony_ci* Function: SetQueueSize and GetQueueSize 34332a6e48fSopenharmony_ci* Type: Function 34432a6e48fSopenharmony_ci* Rank: Important(2) 34532a6e48fSopenharmony_ci* EnvConditions: N/A 34632a6e48fSopenharmony_ci* CaseDescription: 1. call GetQueueSize and get default value 34732a6e48fSopenharmony_ci* 2. call SetQueueSize 34832a6e48fSopenharmony_ci* 3. call SetQueueSize again with abnormal value 34932a6e48fSopenharmony_ci* 4. call GetQueueSize 35032a6e48fSopenharmony_ci* 5. check ret 35132a6e48fSopenharmony_ci */ 35232a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, QueueSize001, Function | MediumTest | Level2) 35332a6e48fSopenharmony_ci{ 35432a6e48fSopenharmony_ci ASSERT_EQ(pSurface->GetQueueSize(), (uint32_t)SURFACE_DEFAULT_QUEUE_SIZE); 35532a6e48fSopenharmony_ci GSError ret = pSurface->SetQueueSize(2); 35632a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 35732a6e48fSopenharmony_ci 35832a6e48fSopenharmony_ci ret = pSurface->SetQueueSize(SURFACE_MAX_QUEUE_SIZE + 1); 35932a6e48fSopenharmony_ci ASSERT_NE(ret, OHOS::GSERROR_OK); 36032a6e48fSopenharmony_ci 36132a6e48fSopenharmony_ci ASSERT_EQ(pSurface->GetQueueSize(), 2u); 36232a6e48fSopenharmony_ci} 36332a6e48fSopenharmony_ci 36432a6e48fSopenharmony_ci/* 36532a6e48fSopenharmony_ci* Function: SetQueueSize and GetQueueSize 36632a6e48fSopenharmony_ci* Type: Function 36732a6e48fSopenharmony_ci* Rank: Important(2) 36832a6e48fSopenharmony_ci* EnvConditions: N/A 36932a6e48fSopenharmony_ci* CaseDescription: 1. call GetQueueSize with producer_ is nullptr and check ret 37032a6e48fSopenharmony_ci* 2. call SetQueueSize with producer_ is nullptr and check ret 37132a6e48fSopenharmony_ci */ 37232a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, QueueSize002, Function | MediumTest | Level2) 37332a6e48fSopenharmony_ci{ 37432a6e48fSopenharmony_ci uint32_t queueSize = surface_->GetQueueSize(); 37532a6e48fSopenharmony_ci ASSERT_EQ(queueSize, 0); 37632a6e48fSopenharmony_ci GSError ret = surface_->SetQueueSize(queueSize); 37732a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 37832a6e48fSopenharmony_ci} 37932a6e48fSopenharmony_ci 38032a6e48fSopenharmony_ci/* 38132a6e48fSopenharmony_ci* Function: GetDefaultWidth, GetDefaultHeight and SetDefaultWidthAndHeight 38232a6e48fSopenharmony_ci* Type: Function 38332a6e48fSopenharmony_ci* Rank: Important(2) 38432a6e48fSopenharmony_ci* EnvConditions: N/A 38532a6e48fSopenharmony_ci* CaseDescription: 1. call SetDefaultWidthAndHeight with producer_ is nullptr and check ret 38632a6e48fSopenharmony_ci* 2. call GetDefaultWidth with producer_ is nullptr and check ret 38732a6e48fSopenharmony_ci* 3. call GetDefaultHeight with producer_ is nullptr and check ret 38832a6e48fSopenharmony_ci */ 38932a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, DefaultWidthAndHeight001, Function | MediumTest | Level2) 39032a6e48fSopenharmony_ci{ 39132a6e48fSopenharmony_ci GSError ret = surface_->SetDefaultWidthAndHeight(0, 0); 39232a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_NOT_SUPPORT); 39332a6e48fSopenharmony_ci int32_t width = surface_->GetDefaultWidth(); 39432a6e48fSopenharmony_ci ASSERT_EQ(width, -1); // -1 is default width 39532a6e48fSopenharmony_ci int32_t height = surface_->GetDefaultHeight(); 39632a6e48fSopenharmony_ci ASSERT_EQ(height, -1); // -1 is default height 39732a6e48fSopenharmony_ci} 39832a6e48fSopenharmony_ci 39932a6e48fSopenharmony_ci/* 40032a6e48fSopenharmony_ci* Function: SetTransformHint and GetTransformHint 40132a6e48fSopenharmony_ci* Type: Function 40232a6e48fSopenharmony_ci* Rank: Important(2) 40332a6e48fSopenharmony_ci* EnvConditions: N/A 40432a6e48fSopenharmony_ci* CaseDescription: 1. call SetTransformHint with producer_ is nullptr and check ret 40532a6e48fSopenharmony_ci* 2. call GetTransformHint with producer_ is nullptr and check ret 40632a6e48fSopenharmony_ci */ 40732a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, TransformHint001, Function | MediumTest | Level2) 40832a6e48fSopenharmony_ci{ 40932a6e48fSopenharmony_ci GSError ret = surface_->SetTransformHint(GraphicTransformType::GRAPHIC_ROTATE_NONE); 41032a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 41132a6e48fSopenharmony_ci GraphicTransformType type = surface_->GetTransformHint(); 41232a6e48fSopenharmony_ci ASSERT_EQ(type, GraphicTransformType::GRAPHIC_ROTATE_NONE); 41332a6e48fSopenharmony_ci} 41432a6e48fSopenharmony_ci 41532a6e48fSopenharmony_ci/* 41632a6e48fSopenharmony_ci* Function: SetDefaultUsage and GetDefaultUsage 41732a6e48fSopenharmony_ci* Type: Function 41832a6e48fSopenharmony_ci* Rank: Important(2) 41932a6e48fSopenharmony_ci* EnvConditions: N/A 42032a6e48fSopenharmony_ci* CaseDescription: 1. call SetDefaultUsage with producer_ is nullptr and check ret 42132a6e48fSopenharmony_ci* 2. call GetDefaultUsage with producer_ is nullptr and check ret 42232a6e48fSopenharmony_ci */ 42332a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, DefaultUsage001, Function | MediumTest | Level2) 42432a6e48fSopenharmony_ci{ 42532a6e48fSopenharmony_ci GSError ret = surface_->SetDefaultUsage(0); 42632a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 42732a6e48fSopenharmony_ci uint64_t usage = surface_->GetDefaultUsage(); 42832a6e48fSopenharmony_ci ASSERT_EQ(usage, 0); 42932a6e48fSopenharmony_ci} 43032a6e48fSopenharmony_ci 43132a6e48fSopenharmony_ci/* 43232a6e48fSopenharmony_ci* Function: RequestBuffer and FlushBuffer 43332a6e48fSopenharmony_ci* Type: Function 43432a6e48fSopenharmony_ci* Rank: Important(2) 43532a6e48fSopenharmony_ci* EnvConditions: N/A 43632a6e48fSopenharmony_ci* CaseDescription: 1. call RequestBuffer 43732a6e48fSopenharmony_ci* 2. call FlushBuffer 43832a6e48fSopenharmony_ci* 3. check ret 43932a6e48fSopenharmony_ci */ 44032a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, ReqCanFluAcqRel001, Function | MediumTest | Level2) 44132a6e48fSopenharmony_ci{ 44232a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer; 44332a6e48fSopenharmony_ci 44432a6e48fSopenharmony_ci int releaseFence = -1; 44532a6e48fSopenharmony_ci GSError ret = pSurface->RequestBuffer(buffer, releaseFence, requestConfig); 44632a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 44732a6e48fSopenharmony_ci ASSERT_NE(buffer, nullptr); 44832a6e48fSopenharmony_ci firstSeqnum = buffer->GetSeqNum(); 44932a6e48fSopenharmony_ci 45032a6e48fSopenharmony_ci ret = pSurface->FlushBuffer(buffer, -1, flushConfig); 45132a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 45232a6e48fSopenharmony_ci} 45332a6e48fSopenharmony_ci 45432a6e48fSopenharmony_ci/* 45532a6e48fSopenharmony_ci* Function: RequestBuffer and FlushBuffer 45632a6e48fSopenharmony_ci* Type: Function 45732a6e48fSopenharmony_ci* Rank: Important(2) 45832a6e48fSopenharmony_ci* EnvConditions: N/A 45932a6e48fSopenharmony_ci* CaseDescription: 1. call RequestBuffer 46032a6e48fSopenharmony_ci* 2. call FlushBuffer 2 times 46132a6e48fSopenharmony_ci* 3. check ret 46232a6e48fSopenharmony_ci */ 46332a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, ReqCanFluAcqRel002, Function | MediumTest | Level2) 46432a6e48fSopenharmony_ci{ 46532a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer; 46632a6e48fSopenharmony_ci int releaseFence = -1; 46732a6e48fSopenharmony_ci 46832a6e48fSopenharmony_ci GSError ret = pSurface->RequestBuffer(buffer, releaseFence, requestConfig); 46932a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 47032a6e48fSopenharmony_ci ASSERT_NE(buffer, nullptr); 47132a6e48fSopenharmony_ci 47232a6e48fSopenharmony_ci ret = pSurface->FlushBuffer(buffer, -1, flushConfig); 47332a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 47432a6e48fSopenharmony_ci 47532a6e48fSopenharmony_ci ret = pSurface->FlushBuffer(buffer, -1, flushConfig); 47632a6e48fSopenharmony_ci ASSERT_NE(ret, OHOS::GSERROR_OK); 47732a6e48fSopenharmony_ci} 47832a6e48fSopenharmony_ci 47932a6e48fSopenharmony_ci/* 48032a6e48fSopenharmony_ci* Function: AcquireBuffer and ReleaseBuffer 48132a6e48fSopenharmony_ci* Type: Function 48232a6e48fSopenharmony_ci* Rank: Important(2) 48332a6e48fSopenharmony_ci* EnvConditions: N/A 48432a6e48fSopenharmony_ci* CaseDescription: 1. call AcquireBuffer and ReleaseBuffer many times 48532a6e48fSopenharmony_ci* 2. check ret 48632a6e48fSopenharmony_ci */ 48732a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, ReqCanFluAcqRel003, Function | MediumTest | Level2) 48832a6e48fSopenharmony_ci{ 48932a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer; 49032a6e48fSopenharmony_ci int32_t flushFence; 49132a6e48fSopenharmony_ci 49232a6e48fSopenharmony_ci GSError ret = csurf->AcquireBuffer(buffer, flushFence, timestamp, damage); 49332a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 49432a6e48fSopenharmony_ci 49532a6e48fSopenharmony_ci ret = csurf->ReleaseBuffer(buffer, -1); 49632a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 49732a6e48fSopenharmony_ci 49832a6e48fSopenharmony_ci ret = csurf->AcquireBuffer(buffer, flushFence, timestamp, damage); 49932a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 50032a6e48fSopenharmony_ci 50132a6e48fSopenharmony_ci ret = csurf->ReleaseBuffer(buffer, -1); 50232a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 50332a6e48fSopenharmony_ci} 50432a6e48fSopenharmony_ci 50532a6e48fSopenharmony_ci/* 50632a6e48fSopenharmony_ci* Function: RequestBuffer and CancelBuffer 50732a6e48fSopenharmony_ci* Type: Function 50832a6e48fSopenharmony_ci* Rank: Important(2) 50932a6e48fSopenharmony_ci* EnvConditions: N/A 51032a6e48fSopenharmony_ci* CaseDescription: 1. call RequestBuffer 51132a6e48fSopenharmony_ci* 2. call CancelBuffer 51232a6e48fSopenharmony_ci* 3. check ret 51332a6e48fSopenharmony_ci */ 51432a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, ReqCanFluAcqRel004, Function | MediumTest | Level2) 51532a6e48fSopenharmony_ci{ 51632a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer; 51732a6e48fSopenharmony_ci 51832a6e48fSopenharmony_ci int releaseFence = -1; 51932a6e48fSopenharmony_ci GSError ret = pSurface->RequestBuffer(buffer, releaseFence, requestConfig); 52032a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 52132a6e48fSopenharmony_ci 52232a6e48fSopenharmony_ci ret = pSurface->CancelBuffer(buffer); 52332a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 52432a6e48fSopenharmony_ci} 52532a6e48fSopenharmony_ci 52632a6e48fSopenharmony_ci/* 52732a6e48fSopenharmony_ci* Function: RequestBuffer and CancelBuffer 52832a6e48fSopenharmony_ci* Type: Function 52932a6e48fSopenharmony_ci* Rank: Important(2) 53032a6e48fSopenharmony_ci* EnvConditions: N/A 53132a6e48fSopenharmony_ci* CaseDescription: 1. call RequestBuffer 53232a6e48fSopenharmony_ci* 2. call CancelBuffer 2 times 53332a6e48fSopenharmony_ci* 3. check ret 53432a6e48fSopenharmony_ci */ 53532a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, ReqCanFluAcqRel005, Function | MediumTest | Level2) 53632a6e48fSopenharmony_ci{ 53732a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer; 53832a6e48fSopenharmony_ci 53932a6e48fSopenharmony_ci int releaseFence = -1; 54032a6e48fSopenharmony_ci GSError ret = pSurface->RequestBuffer(buffer, releaseFence, requestConfig); 54132a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 54232a6e48fSopenharmony_ci 54332a6e48fSopenharmony_ci ret = pSurface->CancelBuffer(buffer); 54432a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 54532a6e48fSopenharmony_ci 54632a6e48fSopenharmony_ci ret = pSurface->CancelBuffer(buffer); 54732a6e48fSopenharmony_ci ASSERT_NE(ret, OHOS::GSERROR_OK); 54832a6e48fSopenharmony_ci} 54932a6e48fSopenharmony_ci 55032a6e48fSopenharmony_ci/* 55132a6e48fSopenharmony_ci* Function: RequestBuffer and CancelBuffer 55232a6e48fSopenharmony_ci* Type: Function 55332a6e48fSopenharmony_ci* Rank: Important(2) 55432a6e48fSopenharmony_ci* EnvConditions: N/A 55532a6e48fSopenharmony_ci* CaseDescription: 1. call RequestBuffer and CancelBuffer many times 55632a6e48fSopenharmony_ci* 2. check ret 55732a6e48fSopenharmony_ci */ 55832a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, ReqCanFluAcqRel006, Function | MediumTest | Level2) 55932a6e48fSopenharmony_ci{ 56032a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer; 56132a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer1; 56232a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer2; 56332a6e48fSopenharmony_ci int releaseFence = -1; 56432a6e48fSopenharmony_ci 56532a6e48fSopenharmony_ci GSError ret = pSurface->RequestBuffer(buffer, releaseFence, requestConfig); 56632a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 56732a6e48fSopenharmony_ci 56832a6e48fSopenharmony_ci ret = pSurface->RequestBuffer(buffer1, releaseFence, requestConfig); 56932a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 57032a6e48fSopenharmony_ci 57132a6e48fSopenharmony_ci ret = pSurface->RequestBuffer(buffer2, releaseFence, requestConfig); 57232a6e48fSopenharmony_ci ASSERT_NE(ret, OHOS::GSERROR_OK); 57332a6e48fSopenharmony_ci 57432a6e48fSopenharmony_ci ret = pSurface->CancelBuffer(buffer); 57532a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 57632a6e48fSopenharmony_ci 57732a6e48fSopenharmony_ci ret = pSurface->CancelBuffer(buffer1); 57832a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 57932a6e48fSopenharmony_ci 58032a6e48fSopenharmony_ci ret = pSurface->CancelBuffer(buffer2); 58132a6e48fSopenharmony_ci ASSERT_NE(ret, OHOS::GSERROR_OK); 58232a6e48fSopenharmony_ci} 58332a6e48fSopenharmony_ci 58432a6e48fSopenharmony_ci/* 58532a6e48fSopenharmony_ci* Function: GetQueueSize and SetQueueSize 58632a6e48fSopenharmony_ci* Type: Function 58732a6e48fSopenharmony_ci* Rank: Important(2) 58832a6e48fSopenharmony_ci* EnvConditions: N/A 58932a6e48fSopenharmony_ci* CaseDescription: 1. call GetQeueSize 59032a6e48fSopenharmony_ci* 2. call SetQueueSize 2 times 59132a6e48fSopenharmony_ci* 3. check ret 59232a6e48fSopenharmony_ci */ 59332a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, SetQueueSizeDeleting001, Function | MediumTest | Level2) 59432a6e48fSopenharmony_ci{ 59532a6e48fSopenharmony_ci sptr<ConsumerSurface> cs = static_cast<ConsumerSurface*>(csurf.GetRefPtr()); 59632a6e48fSopenharmony_ci sptr<BufferQueueProducer> bqp = static_cast<BufferQueueProducer*>(cs->GetProducer().GetRefPtr()); 59732a6e48fSopenharmony_ci ASSERT_EQ(bqp->GetQueueSize(), 2u); 59832a6e48fSopenharmony_ci 59932a6e48fSopenharmony_ci GSError ret = pSurface->SetQueueSize(1); 60032a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 60132a6e48fSopenharmony_ci 60232a6e48fSopenharmony_ci ret = pSurface->SetQueueSize(2); 60332a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 60432a6e48fSopenharmony_ci} 60532a6e48fSopenharmony_ci 60632a6e48fSopenharmony_ci/* 60732a6e48fSopenharmony_ci* Function: RequestBuffer, ReleaseBuffer and CancelBuffer 60832a6e48fSopenharmony_ci* Type: Function 60932a6e48fSopenharmony_ci* Rank: Important(2) 61032a6e48fSopenharmony_ci* EnvConditions: N/A 61132a6e48fSopenharmony_ci* CaseDescription: 1. call RequestBuffer 61232a6e48fSopenharmony_ci* 2. call ReleaseBuffer 61332a6e48fSopenharmony_ci* 3. call CancelBuffer 61432a6e48fSopenharmony_ci* 4. check ret 61532a6e48fSopenharmony_ci */ 61632a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, ReqCanFluAcqRel007, Function | MediumTest | Level2) 61732a6e48fSopenharmony_ci{ 61832a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer; 61932a6e48fSopenharmony_ci 62032a6e48fSopenharmony_ci int releaseFence = -1; 62132a6e48fSopenharmony_ci GSError ret = pSurface->RequestBuffer(buffer, releaseFence, requestConfig); 62232a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 62332a6e48fSopenharmony_ci 62432a6e48fSopenharmony_ci ret = pSurface->CancelBuffer(buffer); 62532a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 62632a6e48fSopenharmony_ci} 62732a6e48fSopenharmony_ci 62832a6e48fSopenharmony_ci/* 62932a6e48fSopenharmony_ci* Function: SetUserData and GetUserData 63032a6e48fSopenharmony_ci* Type: Function 63132a6e48fSopenharmony_ci* Rank: Important(2) 63232a6e48fSopenharmony_ci* EnvConditions: N/A 63332a6e48fSopenharmony_ci* CaseDescription: 1. call SetUserData and GetUserData many times 63432a6e48fSopenharmony_ci* 2. check ret 63532a6e48fSopenharmony_ci */ 63632a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, UserData001, Function | MediumTest | Level2) 63732a6e48fSopenharmony_ci{ 63832a6e48fSopenharmony_ci GSError ret; 63932a6e48fSopenharmony_ci 64032a6e48fSopenharmony_ci std::string strs[SURFACE_MAX_USER_DATA_COUNT]; 64132a6e48fSopenharmony_ci constexpr int32_t stringLengthMax = 32; 64232a6e48fSopenharmony_ci char str[stringLengthMax] = {}; 64332a6e48fSopenharmony_ci for (int i = 0; i < SURFACE_MAX_USER_DATA_COUNT; i++) { 64432a6e48fSopenharmony_ci auto secRet = snprintf_s(str, sizeof(str), sizeof(str) - 1, "%d", i); 64532a6e48fSopenharmony_ci ASSERT_GT(secRet, 0); 64632a6e48fSopenharmony_ci 64732a6e48fSopenharmony_ci strs[i] = str; 64832a6e48fSopenharmony_ci ret = pSurface->SetUserData(strs[i], "magic"); 64932a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 65032a6e48fSopenharmony_ci } 65132a6e48fSopenharmony_ci 65232a6e48fSopenharmony_ci ret = pSurface->SetUserData("-1", "error"); 65332a6e48fSopenharmony_ci ASSERT_NE(ret, OHOS::GSERROR_OK); 65432a6e48fSopenharmony_ci 65532a6e48fSopenharmony_ci std::string retStr; 65632a6e48fSopenharmony_ci for (int i = 0; i < SURFACE_MAX_USER_DATA_COUNT; i++) { 65732a6e48fSopenharmony_ci retStr = pSurface->GetUserData(strs[i]); 65832a6e48fSopenharmony_ci ASSERT_EQ(retStr, "magic"); 65932a6e48fSopenharmony_ci } 66032a6e48fSopenharmony_ci} 66132a6e48fSopenharmony_ci 66232a6e48fSopenharmony_ci/* 66332a6e48fSopenharmony_ci* Function: UserDataChangeListen 66432a6e48fSopenharmony_ci* Type: Function 66532a6e48fSopenharmony_ci* Rank: Important(2) 66632a6e48fSopenharmony_ci* EnvConditions: N/A 66732a6e48fSopenharmony_ci* CaseDescription: 1. RegisterUserDataChangeListen 66832a6e48fSopenharmony_ci* 2. SetUserData 66932a6e48fSopenharmony_ci* 3. check ret 67032a6e48fSopenharmony_ci */ 67132a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, UserDataChangeListen001, Function | MediumTest | Level2) 67232a6e48fSopenharmony_ci{ 67332a6e48fSopenharmony_ci sptr<IConsumerSurface> csurfTestUserData = IConsumerSurface::Create(); 67432a6e48fSopenharmony_ci sptr<IBufferConsumerListener> listenerTestUserData = new BufferConsumerListener(); 67532a6e48fSopenharmony_ci csurfTestUserData->RegisterConsumerListener(listenerTestUserData); 67632a6e48fSopenharmony_ci sptr<IBufferProducer> producerTestUserData = csurf->GetProducer(); 67732a6e48fSopenharmony_ci sptr<Surface> pSurfaceTestUserData = Surface::CreateSurfaceAsProducer(producerTestUserData); 67832a6e48fSopenharmony_ci 67932a6e48fSopenharmony_ci GSError ret1 = OHOS::GSERROR_INVALID_ARGUMENTS; 68032a6e48fSopenharmony_ci GSError ret2 = OHOS::GSERROR_INVALID_ARGUMENTS; 68132a6e48fSopenharmony_ci auto func1 = [&ret1](const std::string& key, const std::string& value) { 68232a6e48fSopenharmony_ci ret1 = OHOS::GSERROR_OK; 68332a6e48fSopenharmony_ci }; 68432a6e48fSopenharmony_ci auto func2 = [&ret2](const std::string& key, const std::string& value) { 68532a6e48fSopenharmony_ci ret2 = OHOS::GSERROR_OK; 68632a6e48fSopenharmony_ci }; 68732a6e48fSopenharmony_ci pSurfaceTestUserData->RegisterUserDataChangeListener("func1", func1); 68832a6e48fSopenharmony_ci pSurfaceTestUserData->RegisterUserDataChangeListener("func2", func2); 68932a6e48fSopenharmony_ci pSurfaceTestUserData->RegisterUserDataChangeListener("func3", nullptr); 69032a6e48fSopenharmony_ci ASSERT_EQ(pSurfaceTestUserData->RegisterUserDataChangeListener("func2", func2), OHOS::GSERROR_INVALID_ARGUMENTS); 69132a6e48fSopenharmony_ci 69232a6e48fSopenharmony_ci if (pSurfaceTestUserData->SetUserData("Regist", "OK") == OHOS::GSERROR_OK) { 69332a6e48fSopenharmony_ci ASSERT_EQ(ret1, OHOS::GSERROR_OK); 69432a6e48fSopenharmony_ci ASSERT_EQ(ret2, OHOS::GSERROR_OK); 69532a6e48fSopenharmony_ci } 69632a6e48fSopenharmony_ci 69732a6e48fSopenharmony_ci ret1 = OHOS::GSERROR_INVALID_ARGUMENTS; 69832a6e48fSopenharmony_ci ret2 = OHOS::GSERROR_INVALID_ARGUMENTS; 69932a6e48fSopenharmony_ci pSurfaceTestUserData->UnRegisterUserDataChangeListener("func1"); 70032a6e48fSopenharmony_ci ASSERT_EQ(pSurfaceTestUserData->UnRegisterUserDataChangeListener("func1"), OHOS::GSERROR_INVALID_ARGUMENTS); 70132a6e48fSopenharmony_ci 70232a6e48fSopenharmony_ci if (pSurfaceTestUserData->SetUserData("UnRegist", "INVALID") == OHOS::GSERROR_OK) { 70332a6e48fSopenharmony_ci ASSERT_EQ(ret1, OHOS::GSERROR_INVALID_ARGUMENTS); 70432a6e48fSopenharmony_ci ASSERT_EQ(ret2, OHOS::GSERROR_OK); 70532a6e48fSopenharmony_ci } 70632a6e48fSopenharmony_ci 70732a6e48fSopenharmony_ci ret1 = OHOS::GSERROR_INVALID_ARGUMENTS; 70832a6e48fSopenharmony_ci ret2 = OHOS::GSERROR_INVALID_ARGUMENTS; 70932a6e48fSopenharmony_ci pSurfaceTestUserData->ClearUserDataChangeListener(); 71032a6e48fSopenharmony_ci pSurfaceTestUserData->RegisterUserDataChangeListener("func1", func1); 71132a6e48fSopenharmony_ci if (pSurfaceTestUserData->SetUserData("Clear", "OK") == OHOS::GSERROR_OK) { 71232a6e48fSopenharmony_ci ASSERT_EQ(ret1, OHOS::GSERROR_OK); 71332a6e48fSopenharmony_ci ASSERT_EQ(ret2, OHOS::GSERROR_INVALID_ARGUMENTS); 71432a6e48fSopenharmony_ci } 71532a6e48fSopenharmony_ci} 71632a6e48fSopenharmony_ci 71732a6e48fSopenharmony_ci/* 71832a6e48fSopenharmony_ci* Function: UserDataChangeListen 71932a6e48fSopenharmony_ci* Type: Function 72032a6e48fSopenharmony_ci* Rank: Important(2) 72132a6e48fSopenharmony_ci* EnvConditions: N/A 72232a6e48fSopenharmony_ci* CaseDescription: 1. RegisterUserDataChangeListen 72332a6e48fSopenharmony_ci* 2. SetUserData 72432a6e48fSopenharmony_ci* 3. check ret 72532a6e48fSopenharmony_ci */ 72632a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, UserDataChangeListen002, Function | MediumTest | Level2) 72732a6e48fSopenharmony_ci{ 72832a6e48fSopenharmony_ci sptr<IConsumerSurface> csurfTestUserData = IConsumerSurface::Create(); 72932a6e48fSopenharmony_ci sptr<IBufferConsumerListener> listenerTestUserData = new BufferConsumerListener(); 73032a6e48fSopenharmony_ci csurfTestUserData->RegisterConsumerListener(listenerTestUserData); 73132a6e48fSopenharmony_ci sptr<IBufferProducer> producerTestUserData = csurf->GetProducer(); 73232a6e48fSopenharmony_ci sptr<Surface> pSurfaceTestUserData = Surface::CreateSurfaceAsProducer(producerTestUserData); 73332a6e48fSopenharmony_ci 73432a6e48fSopenharmony_ci auto func = [&pSurfaceTestUserData](const std::string& FuncName) { 73532a6e48fSopenharmony_ci constexpr int32_t RegisterListenerNum = 1000; 73632a6e48fSopenharmony_ci std::vector<GSError> ret(RegisterListenerNum, OHOS::GSERROR_INVALID_ARGUMENTS); 73732a6e48fSopenharmony_ci std::string strs[RegisterListenerNum]; 73832a6e48fSopenharmony_ci constexpr int32_t stringLengthMax = 32; 73932a6e48fSopenharmony_ci char str[stringLengthMax] = {}; 74032a6e48fSopenharmony_ci for (int i = 0; i < RegisterListenerNum; i++) { 74132a6e48fSopenharmony_ci auto secRet = snprintf_s(str, sizeof(str), sizeof(str) - 1, "%s%d", FuncName.c_str(), i); 74232a6e48fSopenharmony_ci ASSERT_GT(secRet, 0); 74332a6e48fSopenharmony_ci strs[i] = str; 74432a6e48fSopenharmony_ci ASSERT_EQ(pSurfaceTestUserData->RegisterUserDataChangeListener(strs[i], [i, &ret] 74532a6e48fSopenharmony_ci (const std::string& key, const std::string& value) { 74632a6e48fSopenharmony_ci ret[i] = OHOS::GSERROR_OK; 74732a6e48fSopenharmony_ci }), OHOS::GSERROR_OK); 74832a6e48fSopenharmony_ci } 74932a6e48fSopenharmony_ci 75032a6e48fSopenharmony_ci if (pSurfaceTestUserData->SetUserData("Regist", FuncName) == OHOS::GSERROR_OK) { 75132a6e48fSopenharmony_ci for (int i = 0; i < RegisterListenerNum; i++) { 75232a6e48fSopenharmony_ci ASSERT_EQ(ret[i], OHOS::GSERROR_OK); 75332a6e48fSopenharmony_ci } 75432a6e48fSopenharmony_ci } 75532a6e48fSopenharmony_ci 75632a6e48fSopenharmony_ci for (int i = 0; i < RegisterListenerNum; i++) { 75732a6e48fSopenharmony_ci pSurfaceTestUserData->UnRegisterUserDataChangeListener(strs[i]); 75832a6e48fSopenharmony_ci } 75932a6e48fSopenharmony_ci }; 76032a6e48fSopenharmony_ci 76132a6e48fSopenharmony_ci std::thread t1(func, "thread1"); 76232a6e48fSopenharmony_ci std::thread t2(func, "thread2"); 76332a6e48fSopenharmony_ci t1.join(); 76432a6e48fSopenharmony_ci t2.join(); 76532a6e48fSopenharmony_ci} 76632a6e48fSopenharmony_ci 76732a6e48fSopenharmony_ci/* 76832a6e48fSopenharmony_ci* Function: GetUniqueId 76932a6e48fSopenharmony_ci* Type: Function 77032a6e48fSopenharmony_ci* Rank: Important(2) 77132a6e48fSopenharmony_ci* EnvConditions: N/A 77232a6e48fSopenharmony_ci* CaseDescription: 1. call GetUniqueId 77332a6e48fSopenharmony_ci* 2. check ret 77432a6e48fSopenharmony_ci */ 77532a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, UniqueId001, Function | MediumTest | Level2) 77632a6e48fSopenharmony_ci{ 77732a6e48fSopenharmony_ci uint64_t uniqueId = pSurface->GetUniqueId(); 77832a6e48fSopenharmony_ci ASSERT_NE(uniqueId, 0); 77932a6e48fSopenharmony_ci} 78032a6e48fSopenharmony_ci 78132a6e48fSopenharmony_ci/* 78232a6e48fSopenharmony_ci* Function: SetTransform and GetTransform 78332a6e48fSopenharmony_ci* Type: Function 78432a6e48fSopenharmony_ci* Rank: Important(2) 78532a6e48fSopenharmony_ci* EnvConditions: N/A 78632a6e48fSopenharmony_ci* CaseDescription: 1. call GetTransform with default and check ret 78732a6e48fSopenharmony_ci */ 78832a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, transform001, Function | MediumTest | Level2) 78932a6e48fSopenharmony_ci{ 79032a6e48fSopenharmony_ci GSError ret = pSurface->SetTransform(GraphicTransformType::GRAPHIC_ROTATE_NONE); 79132a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 79232a6e48fSopenharmony_ci} 79332a6e48fSopenharmony_ci 79432a6e48fSopenharmony_ci/* 79532a6e48fSopenharmony_ci* Function: SetTransform and GetTransform 79632a6e48fSopenharmony_ci* Type: Function 79732a6e48fSopenharmony_ci* Rank: Important(1) 79832a6e48fSopenharmony_ci* EnvConditions: N/A 79932a6e48fSopenharmony_ci* CaseDescription: 1. call SetTransform with other parameters and check ret 80032a6e48fSopenharmony_ci */ 80132a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, transform002, Function | MediumTest | Level1) 80232a6e48fSopenharmony_ci{ 80332a6e48fSopenharmony_ci GSError ret = pSurface->SetTransform(GraphicTransformType::GRAPHIC_ROTATE_90); 80432a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 80532a6e48fSopenharmony_ci} 80632a6e48fSopenharmony_ci 80732a6e48fSopenharmony_ci/* 80832a6e48fSopenharmony_ci* Function: SetTransform and GetTransform 80932a6e48fSopenharmony_ci* Type: Function 81032a6e48fSopenharmony_ci* Rank: Important(1) 81132a6e48fSopenharmony_ci* EnvConditions: N/A 81232a6e48fSopenharmony_ci* CaseDescription: 1. call SetTransform with other parameters and check ret 81332a6e48fSopenharmony_ci */ 81432a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, transform003, Function | MediumTest | Level1) 81532a6e48fSopenharmony_ci{ 81632a6e48fSopenharmony_ci GSError ret = pSurface->SetTransform(GraphicTransformType::GRAPHIC_ROTATE_180); 81732a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 81832a6e48fSopenharmony_ci} 81932a6e48fSopenharmony_ci 82032a6e48fSopenharmony_ci/* 82132a6e48fSopenharmony_ci* Function: SetTransform and GetTransform 82232a6e48fSopenharmony_ci* Type: Function 82332a6e48fSopenharmony_ci* Rank: Important(1) 82432a6e48fSopenharmony_ci* EnvConditions: N/A 82532a6e48fSopenharmony_ci* CaseDescription: 1. call SetTransform with other parameters and check ret 82632a6e48fSopenharmony_ci */ 82732a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, transform004, Function | MediumTest | Level1) 82832a6e48fSopenharmony_ci{ 82932a6e48fSopenharmony_ci GSError ret = pSurface->SetTransform(GraphicTransformType::GRAPHIC_ROTATE_270); 83032a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 83132a6e48fSopenharmony_ci} 83232a6e48fSopenharmony_ci 83332a6e48fSopenharmony_ci/* 83432a6e48fSopenharmony_ci* Function: SetTransform and GetTransform 83532a6e48fSopenharmony_ci* Type: Function 83632a6e48fSopenharmony_ci* Rank: Important(1) 83732a6e48fSopenharmony_ci* EnvConditions: N/A 83832a6e48fSopenharmony_ci* CaseDescription: 1. call SetTransform with producer_ is nullptr and check ret 83932a6e48fSopenharmony_ci* 2. call GetTransform with producer_ is nullptr and check ret 84032a6e48fSopenharmony_ci */ 84132a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, transform005, Function | MediumTest | Level1) 84232a6e48fSopenharmony_ci{ 84332a6e48fSopenharmony_ci GSError ret = surface_->SetTransform(GraphicTransformType::GRAPHIC_ROTATE_270); 84432a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 84532a6e48fSopenharmony_ci GraphicTransformType type = surface_->GetTransform(); 84632a6e48fSopenharmony_ci ASSERT_EQ(type, GraphicTransformType::GRAPHIC_ROTATE_BUTT); 84732a6e48fSopenharmony_ci} 84832a6e48fSopenharmony_ci 84932a6e48fSopenharmony_ci/* 85032a6e48fSopenharmony_ci* Function: IsSupportedAlloc 85132a6e48fSopenharmony_ci* Type: Function 85232a6e48fSopenharmony_ci* Rank: Important(2) 85332a6e48fSopenharmony_ci* EnvConditions: N/A 85432a6e48fSopenharmony_ci* CaseDescription: 1. call IsSupportedAlloc with abnormal parameters and check ret 85532a6e48fSopenharmony_ci */ 85632a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, isSupportedAlloc001, Function | MediumTest | Level2) 85732a6e48fSopenharmony_ci{ 85832a6e48fSopenharmony_ci std::vector<BufferVerifyAllocInfo> infos; 85932a6e48fSopenharmony_ci std::vector<bool> supporteds; 86032a6e48fSopenharmony_ci GSError ret = pSurface->IsSupportedAlloc(infos, supporteds); 86132a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 86232a6e48fSopenharmony_ci} 86332a6e48fSopenharmony_ci 86432a6e48fSopenharmony_ci/* 86532a6e48fSopenharmony_ci* Function: IsSupportedAlloc 86632a6e48fSopenharmony_ci* Type: Function 86732a6e48fSopenharmony_ci* Rank: Important(2) 86832a6e48fSopenharmony_ci* EnvConditions: N/A 86932a6e48fSopenharmony_ci* CaseDescription: 1. call IsSupportedAlloc with abnormal parameters and check ret 87032a6e48fSopenharmony_ci */ 87132a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, isSupportedAlloc002, Function | MediumTest | Level2) 87232a6e48fSopenharmony_ci{ 87332a6e48fSopenharmony_ci std::vector<BufferVerifyAllocInfo> infos; 87432a6e48fSopenharmony_ci std::vector<bool> supporteds; 87532a6e48fSopenharmony_ci GSError ret = pSurface->IsSupportedAlloc(infos, supporteds); 87632a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 87732a6e48fSopenharmony_ci 87832a6e48fSopenharmony_ci BufferVerifyAllocInfo info = { 87932a6e48fSopenharmony_ci .width = 0x100, 88032a6e48fSopenharmony_ci .height = 0x100, 88132a6e48fSopenharmony_ci .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE | BUFFER_USAGE_MEM_DMA, 88232a6e48fSopenharmony_ci .format = GRAPHIC_PIXEL_FMT_RGBA_8888, 88332a6e48fSopenharmony_ci }; 88432a6e48fSopenharmony_ci infos.push_back(info); 88532a6e48fSopenharmony_ci info.format = GRAPHIC_PIXEL_FMT_YCRCB_420_SP; 88632a6e48fSopenharmony_ci infos.push_back(info); 88732a6e48fSopenharmony_ci info.format = GRAPHIC_PIXEL_FMT_YUV_422_I; 88832a6e48fSopenharmony_ci infos.push_back(info); 88932a6e48fSopenharmony_ci 89032a6e48fSopenharmony_ci ret = pSurface->IsSupportedAlloc(infos, supporteds); 89132a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 89232a6e48fSopenharmony_ci} 89332a6e48fSopenharmony_ci 89432a6e48fSopenharmony_ci/* 89532a6e48fSopenharmony_ci* Function: IsSupportedAlloc 89632a6e48fSopenharmony_ci* Type: Function 89732a6e48fSopenharmony_ci* Rank: Important(1) 89832a6e48fSopenharmony_ci* EnvConditions: N/A 89932a6e48fSopenharmony_ci* CaseDescription: 1. call IsSupportedAlloc with normal parameters and check ret 90032a6e48fSopenharmony_ci */ 90132a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, isSupportedAlloc003, Function | MediumTest | Level1) 90232a6e48fSopenharmony_ci{ 90332a6e48fSopenharmony_ci std::vector<BufferVerifyAllocInfo> infos; 90432a6e48fSopenharmony_ci std::vector<bool> supporteds; 90532a6e48fSopenharmony_ci BufferVerifyAllocInfo info = { 90632a6e48fSopenharmony_ci .width = 0x100, 90732a6e48fSopenharmony_ci .height = 0x100, 90832a6e48fSopenharmony_ci .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE | BUFFER_USAGE_MEM_DMA, 90932a6e48fSopenharmony_ci .format = GRAPHIC_PIXEL_FMT_RGBA_8888, 91032a6e48fSopenharmony_ci }; 91132a6e48fSopenharmony_ci infos.push_back(info); 91232a6e48fSopenharmony_ci info.format = GRAPHIC_PIXEL_FMT_YCRCB_420_SP; 91332a6e48fSopenharmony_ci infos.push_back(info); 91432a6e48fSopenharmony_ci info.format = GRAPHIC_PIXEL_FMT_YUV_422_I; 91532a6e48fSopenharmony_ci infos.push_back(info); 91632a6e48fSopenharmony_ci 91732a6e48fSopenharmony_ci supporteds.push_back(false); 91832a6e48fSopenharmony_ci supporteds.push_back(false); 91932a6e48fSopenharmony_ci supporteds.push_back(false); 92032a6e48fSopenharmony_ci 92132a6e48fSopenharmony_ci GSError ret = pSurface->IsSupportedAlloc(infos, supporteds); 92232a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); // mock data result 92332a6e48fSopenharmony_ci ASSERT_EQ(supporteds[0], true); // mock data result 92432a6e48fSopenharmony_ci ASSERT_EQ(supporteds[1], true); // mock data result 92532a6e48fSopenharmony_ci ASSERT_EQ(supporteds[2], false); // mock data result 92632a6e48fSopenharmony_ci} 92732a6e48fSopenharmony_ci 92832a6e48fSopenharmony_ci/* 92932a6e48fSopenharmony_ci* Function: IsSupportedAlloc 93032a6e48fSopenharmony_ci* Type: Function 93132a6e48fSopenharmony_ci* Rank: Important(2) 93232a6e48fSopenharmony_ci* EnvConditions: N/A 93332a6e48fSopenharmony_ci* CaseDescription: 1. call IsSupportedAlloc with producer_ is nullptr and check ret 93432a6e48fSopenharmony_ci */ 93532a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, isSupportedAlloc004, Function | MediumTest | Level2) 93632a6e48fSopenharmony_ci{ 93732a6e48fSopenharmony_ci std::vector<BufferVerifyAllocInfo> infos; 93832a6e48fSopenharmony_ci std::vector<bool> supporteds; 93932a6e48fSopenharmony_ci GSError ret = surface_->IsSupportedAlloc(infos, supporteds); 94032a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 94132a6e48fSopenharmony_ci} 94232a6e48fSopenharmony_ci 94332a6e48fSopenharmony_ci/* 94432a6e48fSopenharmony_ci* Function: SetScalingMode and GetScalingMode 94532a6e48fSopenharmony_ci* Type: Function 94632a6e48fSopenharmony_ci* Rank: Important(2) 94732a6e48fSopenharmony_ci* EnvConditions: N/A 94832a6e48fSopenharmony_ci* CaseDescription: 1. call SetScalingMode with abnormal parameters and check ret 94932a6e48fSopenharmony_ci */ 95032a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, scalingMode001, Function | MediumTest | Level2) 95132a6e48fSopenharmony_ci{ 95232a6e48fSopenharmony_ci ScalingMode scalingMode = ScalingMode::SCALING_MODE_SCALE_TO_WINDOW; 95332a6e48fSopenharmony_ci GSError ret = pSurface->SetScalingMode(-1, scalingMode); 95432a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_NO_ENTRY); 95532a6e48fSopenharmony_ci} 95632a6e48fSopenharmony_ci 95732a6e48fSopenharmony_ci/* 95832a6e48fSopenharmony_ci* Function: SetScalingMode and GetScalingMode 95932a6e48fSopenharmony_ci* Type: Function 96032a6e48fSopenharmony_ci* Rank: Important(1) 96132a6e48fSopenharmony_ci* EnvConditions: N/A 96232a6e48fSopenharmony_ci* CaseDescription: 1. call SetScalingMode with normal parameters and check ret 96332a6e48fSopenharmony_ci* 2. call GetScalingMode and check ret 96432a6e48fSopenharmony_ci */ 96532a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, scalingMode002, Function | MediumTest | Level1) 96632a6e48fSopenharmony_ci{ 96732a6e48fSopenharmony_ci ScalingMode scalingMode = ScalingMode::SCALING_MODE_SCALE_TO_WINDOW; 96832a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer; 96932a6e48fSopenharmony_ci int releaseFence = -1; 97032a6e48fSopenharmony_ci GSError ret = pSurface->RequestBuffer(buffer, releaseFence, requestConfig); 97132a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 97232a6e48fSopenharmony_ci ASSERT_NE(buffer, nullptr); 97332a6e48fSopenharmony_ci 97432a6e48fSopenharmony_ci uint32_t sequence = buffer->GetSeqNum(); 97532a6e48fSopenharmony_ci ret = pSurface->SetScalingMode(sequence, scalingMode); 97632a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 97732a6e48fSopenharmony_ci 97832a6e48fSopenharmony_ci ret = pSurface->CancelBuffer(buffer); 97932a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 98032a6e48fSopenharmony_ci} 98132a6e48fSopenharmony_ci 98232a6e48fSopenharmony_ci/* 98332a6e48fSopenharmony_ci* Function: SetScalingMode003 98432a6e48fSopenharmony_ci* Type: Function 98532a6e48fSopenharmony_ci* Rank: Important(2) 98632a6e48fSopenharmony_ci* EnvConditions: N/A 98732a6e48fSopenharmony_ci* CaseDescription: 1. call SetScalingMode with abnormal parameters and check ret 98832a6e48fSopenharmony_ci */ 98932a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, scalingMode003, Function | MediumTest | Level2) 99032a6e48fSopenharmony_ci{ 99132a6e48fSopenharmony_ci ScalingMode scalingMode = ScalingMode::SCALING_MODE_SCALE_TO_WINDOW; 99232a6e48fSopenharmony_ci GSError ret = pSurface->SetScalingMode(scalingMode); 99332a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 99432a6e48fSopenharmony_ci} 99532a6e48fSopenharmony_ci 99632a6e48fSopenharmony_ci/* 99732a6e48fSopenharmony_ci* Function: SetScalingMode and GetScalingMode 99832a6e48fSopenharmony_ci* Type: Function 99932a6e48fSopenharmony_ci* Rank: Important(2) 100032a6e48fSopenharmony_ci* EnvConditions: N/A 100132a6e48fSopenharmony_ci* CaseDescription: 1. call SetScalingMode with producer_ is nullptr and check ret 100232a6e48fSopenharmony_ci* 2. call GetScalingMode and check ret 100332a6e48fSopenharmony_ci */ 100432a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, scalingMode004, Function | MediumTest | Level2) 100532a6e48fSopenharmony_ci{ 100632a6e48fSopenharmony_ci ScalingMode scalingMode = ScalingMode::SCALING_MODE_SCALE_TO_WINDOW; 100732a6e48fSopenharmony_ci GSError ret = surface_->SetScalingMode(scalingMode); 100832a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 100932a6e48fSopenharmony_ci ret = surface_->SetScalingMode(0, scalingMode); 101032a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 101132a6e48fSopenharmony_ci ret = surface_->GetScalingMode(0, scalingMode); 101232a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_NOT_SUPPORT); 101332a6e48fSopenharmony_ci} 101432a6e48fSopenharmony_ci 101532a6e48fSopenharmony_ci/* 101632a6e48fSopenharmony_ci* Function: SetMetaData and GetMetaData 101732a6e48fSopenharmony_ci* Type: Function 101832a6e48fSopenharmony_ci* Rank: Important(2) 101932a6e48fSopenharmony_ci* EnvConditions: N/A 102032a6e48fSopenharmony_ci* CaseDescription: 1. call SetMetaData with abnormal parameters and check ret 102132a6e48fSopenharmony_ci */ 102232a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, metaData001, Function | MediumTest | Level2) 102332a6e48fSopenharmony_ci{ 102432a6e48fSopenharmony_ci std::vector<GraphicHDRMetaData> metaData; 102532a6e48fSopenharmony_ci GSError ret = pSurface->SetMetaData(firstSeqnum, metaData); 102632a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 102732a6e48fSopenharmony_ci} 102832a6e48fSopenharmony_ci 102932a6e48fSopenharmony_ci/* 103032a6e48fSopenharmony_ci* Function: SetMetaData and GetMetaData 103132a6e48fSopenharmony_ci* Type: Function 103232a6e48fSopenharmony_ci* Rank: Important(2) 103332a6e48fSopenharmony_ci* EnvConditions: N/A 103432a6e48fSopenharmony_ci* CaseDescription: 1. call SetMetaData with abnormal parameters and check ret 103532a6e48fSopenharmony_ci */ 103632a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, metaData002, Function | MediumTest | Level2) 103732a6e48fSopenharmony_ci{ 103832a6e48fSopenharmony_ci std::vector<GraphicHDRMetaData> metaData; 103932a6e48fSopenharmony_ci GraphicHDRMetaData data = { 104032a6e48fSopenharmony_ci .key = GraphicHDRMetadataKey::GRAPHIC_MATAKEY_RED_PRIMARY_X, 104132a6e48fSopenharmony_ci .value = 100, // for test 104232a6e48fSopenharmony_ci }; 104332a6e48fSopenharmony_ci metaData.push_back(data); 104432a6e48fSopenharmony_ci GSError ret = pSurface->SetMetaData(-1, metaData); 104532a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_NO_ENTRY); 104632a6e48fSopenharmony_ci} 104732a6e48fSopenharmony_ci 104832a6e48fSopenharmony_ci/* 104932a6e48fSopenharmony_ci* Function: SetMetaData and GetMetaData 105032a6e48fSopenharmony_ci* Type: Function 105132a6e48fSopenharmony_ci* Rank: Important(1) 105232a6e48fSopenharmony_ci* EnvConditions: N/A 105332a6e48fSopenharmony_ci* CaseDescription: 1. call SetMetaData with normal parameters and check ret 105432a6e48fSopenharmony_ci* 2. call GetMetaData and check ret 105532a6e48fSopenharmony_ci */ 105632a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, metaData003, Function | MediumTest | Level1) 105732a6e48fSopenharmony_ci{ 105832a6e48fSopenharmony_ci std::vector<GraphicHDRMetaData> metaData; 105932a6e48fSopenharmony_ci GraphicHDRMetaData data = { 106032a6e48fSopenharmony_ci .key = GraphicHDRMetadataKey::GRAPHIC_MATAKEY_RED_PRIMARY_X, 106132a6e48fSopenharmony_ci .value = 100, // for test 106232a6e48fSopenharmony_ci }; 106332a6e48fSopenharmony_ci metaData.push_back(data); 106432a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer; 106532a6e48fSopenharmony_ci int releaseFence = -1; 106632a6e48fSopenharmony_ci GSError ret = pSurface->RequestBuffer(buffer, releaseFence, requestConfig); 106732a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 106832a6e48fSopenharmony_ci ASSERT_NE(buffer, nullptr); 106932a6e48fSopenharmony_ci 107032a6e48fSopenharmony_ci uint32_t sequence = buffer->GetSeqNum(); 107132a6e48fSopenharmony_ci ret = pSurface->SetMetaData(sequence, metaData); 107232a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 107332a6e48fSopenharmony_ci 107432a6e48fSopenharmony_ci ret = pSurface->CancelBuffer(buffer); 107532a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 107632a6e48fSopenharmony_ci} 107732a6e48fSopenharmony_ci 107832a6e48fSopenharmony_ci/* 107932a6e48fSopenharmony_ci* Function: SetMetaData and GetMetaData 108032a6e48fSopenharmony_ci* Type: Function 108132a6e48fSopenharmony_ci* Rank: Important(2) 108232a6e48fSopenharmony_ci* EnvConditions: N/A 108332a6e48fSopenharmony_ci* CaseDescription: 1. call SetMetaData with producer_ is nullptr and check ret 108432a6e48fSopenharmony_ci* 2. call GetMetaData and check ret 108532a6e48fSopenharmony_ci */ 108632a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, metaData004, Function | MediumTest | Level2) 108732a6e48fSopenharmony_ci{ 108832a6e48fSopenharmony_ci std::vector<GraphicHDRMetaData> metaData; 108932a6e48fSopenharmony_ci GSError ret = surface_->SetMetaData(0, metaData); 109032a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 109132a6e48fSopenharmony_ci GraphicHDRMetaData data = { 109232a6e48fSopenharmony_ci .key = GraphicHDRMetadataKey::GRAPHIC_MATAKEY_RED_PRIMARY_X, 109332a6e48fSopenharmony_ci .value = 100, // 100 metaData value for test 109432a6e48fSopenharmony_ci }; 109532a6e48fSopenharmony_ci metaData.push_back(data); 109632a6e48fSopenharmony_ci ret = surface_->SetMetaData(0, metaData); 109732a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 109832a6e48fSopenharmony_ci ret = surface_->GetMetaData(0, metaData); 109932a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_NOT_SUPPORT); 110032a6e48fSopenharmony_ci} 110132a6e48fSopenharmony_ci 110232a6e48fSopenharmony_ci/* 110332a6e48fSopenharmony_ci* Function: SetMetaDataSet and GetMetaDataSet 110432a6e48fSopenharmony_ci* Type: Function 110532a6e48fSopenharmony_ci* Rank: Important(2) 110632a6e48fSopenharmony_ci* EnvConditions: N/A 110732a6e48fSopenharmony_ci* CaseDescription: 1. call SetMetaDataSet with abnormal parameters and check ret 110832a6e48fSopenharmony_ci */ 110932a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, metaDataSet001, Function | MediumTest | Level2) 111032a6e48fSopenharmony_ci{ 111132a6e48fSopenharmony_ci GraphicHDRMetadataKey key = GraphicHDRMetadataKey::GRAPHIC_MATAKEY_HDR10_PLUS; 111232a6e48fSopenharmony_ci std::vector<uint8_t> metaData; 111332a6e48fSopenharmony_ci 111432a6e48fSopenharmony_ci GSError ret = pSurface->SetMetaDataSet(firstSeqnum, key, metaData); 111532a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 111632a6e48fSopenharmony_ci} 111732a6e48fSopenharmony_ci 111832a6e48fSopenharmony_ci/* 111932a6e48fSopenharmony_ci* Function: SetMetaDataSet and GetMetaDataSet 112032a6e48fSopenharmony_ci* Type: Function 112132a6e48fSopenharmony_ci* Rank: Important(2) 112232a6e48fSopenharmony_ci* EnvConditions: N/A 112332a6e48fSopenharmony_ci* CaseDescription: 1. call SetMetaDataSet with abnormal parameters and check ret 112432a6e48fSopenharmony_ci */ 112532a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, metaDataSet002, Function | MediumTest | Level2) 112632a6e48fSopenharmony_ci{ 112732a6e48fSopenharmony_ci GraphicHDRMetadataKey key = GraphicHDRMetadataKey::GRAPHIC_MATAKEY_HDR10_PLUS; 112832a6e48fSopenharmony_ci std::vector<uint8_t> metaData; 112932a6e48fSopenharmony_ci 113032a6e48fSopenharmony_ci uint8_t data = 10; // for test 113132a6e48fSopenharmony_ci metaData.push_back(data); 113232a6e48fSopenharmony_ci GSError ret = pSurface->SetMetaDataSet(-1, key, metaData); 113332a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_NO_ENTRY); 113432a6e48fSopenharmony_ci} 113532a6e48fSopenharmony_ci 113632a6e48fSopenharmony_ci/* 113732a6e48fSopenharmony_ci* Function: SetMetaDataSet and GetMetaDataSet 113832a6e48fSopenharmony_ci* Type: Function 113932a6e48fSopenharmony_ci* Rank: Important(1) 114032a6e48fSopenharmony_ci* EnvConditions: N/A 114132a6e48fSopenharmony_ci* CaseDescription: 1. call SetMetaDataSet with normal parameters and check ret 114232a6e48fSopenharmony_ci* 2. call GetMetaDataSet and check ret 114332a6e48fSopenharmony_ci */ 114432a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, metaDataSet003, Function | MediumTest | Level1) 114532a6e48fSopenharmony_ci{ 114632a6e48fSopenharmony_ci GraphicHDRMetadataKey key = GraphicHDRMetadataKey::GRAPHIC_MATAKEY_HDR10_PLUS; 114732a6e48fSopenharmony_ci std::vector<uint8_t> metaData; 114832a6e48fSopenharmony_ci uint8_t data = 10; // for test 114932a6e48fSopenharmony_ci metaData.push_back(data); 115032a6e48fSopenharmony_ci 115132a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer; 115232a6e48fSopenharmony_ci int releaseFence = -1; 115332a6e48fSopenharmony_ci GSError ret = pSurface->RequestBuffer(buffer, releaseFence, requestConfig); 115432a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 115532a6e48fSopenharmony_ci ASSERT_NE(buffer, nullptr); 115632a6e48fSopenharmony_ci 115732a6e48fSopenharmony_ci uint32_t sequence = buffer->GetSeqNum(); 115832a6e48fSopenharmony_ci ret = pSurface->SetMetaDataSet(sequence, key, metaData); 115932a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 116032a6e48fSopenharmony_ci 116132a6e48fSopenharmony_ci ret = pSurface->CancelBuffer(buffer); 116232a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 116332a6e48fSopenharmony_ci} 116432a6e48fSopenharmony_ci 116532a6e48fSopenharmony_ci/* 116632a6e48fSopenharmony_ci* Function: SetMetaDataSet and GetMetaDataSet 116732a6e48fSopenharmony_ci* Type: Function 116832a6e48fSopenharmony_ci* Rank: Important(2) 116932a6e48fSopenharmony_ci* EnvConditions: N/A 117032a6e48fSopenharmony_ci* CaseDescription: 1. call SetMetaDataSet with producer_ is nullptr and check ret 117132a6e48fSopenharmony_ci* 2. call GetMetaDataSet and check ret 117232a6e48fSopenharmony_ci */ 117332a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, metaDataSet004, Function | MediumTest | Level2) 117432a6e48fSopenharmony_ci{ 117532a6e48fSopenharmony_ci GraphicHDRMetadataKey key = GraphicHDRMetadataKey::GRAPHIC_MATAKEY_HDR10_PLUS; 117632a6e48fSopenharmony_ci std::vector<uint8_t> metaData; 117732a6e48fSopenharmony_ci 117832a6e48fSopenharmony_ci uint8_t data = 10; // metaData value for test 117932a6e48fSopenharmony_ci metaData.push_back(data); 118032a6e48fSopenharmony_ci GSError ret = surface_->SetMetaDataSet(0, key, metaData); 118132a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 118232a6e48fSopenharmony_ci ret = surface_->GetMetaDataSet(0, key, metaData); 118332a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_NOT_SUPPORT); 118432a6e48fSopenharmony_ci} 118532a6e48fSopenharmony_ci 118632a6e48fSopenharmony_ci/* 118732a6e48fSopenharmony_ci* Function: SetTunnelHandle and GetTunnelHandle 118832a6e48fSopenharmony_ci* Type: Function 118932a6e48fSopenharmony_ci* Rank: Important(2) 119032a6e48fSopenharmony_ci* EnvConditions: N/A 119132a6e48fSopenharmony_ci* CaseDescription: 1. call SetTunnelhandle with producer_ is nullptr and check ret 119232a6e48fSopenharmony_ci */ 119332a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, tunnelHandle001, Function | MediumTest | Level2) 119432a6e48fSopenharmony_ci{ 119532a6e48fSopenharmony_ci GraphicExtDataHandle *handle = nullptr; 119632a6e48fSopenharmony_ci handle = static_cast<GraphicExtDataHandle *>(malloc(sizeof(GraphicExtDataHandle) + sizeof(int32_t) * 1)); 119732a6e48fSopenharmony_ci ASSERT_NE(handle, nullptr); 119832a6e48fSopenharmony_ci handle->fd = -1; 119932a6e48fSopenharmony_ci handle->reserveInts = 1; 120032a6e48fSopenharmony_ci handle->reserve[0] = 0; 120132a6e48fSopenharmony_ci GSError ret = surface_->SetTunnelHandle(handle); 120232a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 120332a6e48fSopenharmony_ci 120432a6e48fSopenharmony_ci sptr<SurfaceTunnelHandle> handleGet = surface_->GetTunnelHandle(); 120532a6e48fSopenharmony_ci ASSERT_EQ(handleGet, nullptr); 120632a6e48fSopenharmony_ci free(handle); 120732a6e48fSopenharmony_ci} 120832a6e48fSopenharmony_ci 120932a6e48fSopenharmony_ci/* 121032a6e48fSopenharmony_ci* Function: SetTunnelHandle and GetTunnelHandle 121132a6e48fSopenharmony_ci* Type: Function 121232a6e48fSopenharmony_ci* Rank: Important(2) 121332a6e48fSopenharmony_ci* EnvConditions: N/A 121432a6e48fSopenharmony_ci* CaseDescription: 1. call SetTunnelhandle with normal parameters and check ret 121532a6e48fSopenharmony_ci */ 121632a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, tunnelHandle002, Function | MediumTest | Level2) 121732a6e48fSopenharmony_ci{ 121832a6e48fSopenharmony_ci GraphicExtDataHandle *handle = nullptr; 121932a6e48fSopenharmony_ci handle = static_cast<GraphicExtDataHandle *>(malloc(sizeof(GraphicExtDataHandle) + sizeof(int32_t) * 1)); 122032a6e48fSopenharmony_ci ASSERT_NE(handle, nullptr); 122132a6e48fSopenharmony_ci handle->fd = -1; 122232a6e48fSopenharmony_ci handle->reserveInts = 1; 122332a6e48fSopenharmony_ci handle->reserve[0] = 0; 122432a6e48fSopenharmony_ci GSError ret = pSurface->SetTunnelHandle(handle); 122532a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 122632a6e48fSopenharmony_ci 122732a6e48fSopenharmony_ci ret = pSurface->SetTunnelHandle(handle); 122832a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_NO_ENTRY); 122932a6e48fSopenharmony_ci free(handle); 123032a6e48fSopenharmony_ci} 123132a6e48fSopenharmony_ci 123232a6e48fSopenharmony_ci/* 123332a6e48fSopenharmony_ci* Function: connect 123432a6e48fSopenharmony_ci* Type: Function 123532a6e48fSopenharmony_ci* Rank: Important(1) 123632a6e48fSopenharmony_ci* EnvConditions: N/A 123732a6e48fSopenharmony_ci* CaseDescription: 1. call connect and check ret 123832a6e48fSopenharmony_ci */ 123932a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, connect001, Function | MediumTest | Level1) 124032a6e48fSopenharmony_ci{ 124132a6e48fSopenharmony_ci GSError ret = pSurface->Connect(); 124232a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::SURFACE_ERROR_CONSUMER_IS_CONNECTED); 124332a6e48fSopenharmony_ci} 124432a6e48fSopenharmony_ci 124532a6e48fSopenharmony_ci/* 124632a6e48fSopenharmony_ci* Function: disconnect 124732a6e48fSopenharmony_ci* Type: Function 124832a6e48fSopenharmony_ci* Rank: Important(1) 124932a6e48fSopenharmony_ci* EnvConditions: N/A 125032a6e48fSopenharmony_ci* CaseDescription: 1. call Disconnect and check ret 125132a6e48fSopenharmony_ci */ 125232a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, disconnect001, Function | MediumTest | Level1) 125332a6e48fSopenharmony_ci{ 125432a6e48fSopenharmony_ci GSError ret = pSurface->Disconnect(); 125532a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 125632a6e48fSopenharmony_ci} 125732a6e48fSopenharmony_ci 125832a6e48fSopenharmony_ci/* 125932a6e48fSopenharmony_ci* Function: connect 126032a6e48fSopenharmony_ci* Type: Function 126132a6e48fSopenharmony_ci* Rank: Important(1) 126232a6e48fSopenharmony_ci* EnvConditions: N/A 126332a6e48fSopenharmony_ci* CaseDescription: 1. call connect and check ret 126432a6e48fSopenharmony_ci */ 126532a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, connect002, Function | MediumTest | Level1) 126632a6e48fSopenharmony_ci{ 126732a6e48fSopenharmony_ci GSError ret = pSurface->Connect(); 126832a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 126932a6e48fSopenharmony_ci} 127032a6e48fSopenharmony_ci 127132a6e48fSopenharmony_ci/* 127232a6e48fSopenharmony_ci* Function: disconnect 127332a6e48fSopenharmony_ci* Type: Function 127432a6e48fSopenharmony_ci* Rank: Important(1) 127532a6e48fSopenharmony_ci* EnvConditions: N/A 127632a6e48fSopenharmony_ci* CaseDescription: 1. call Disconnect and check ret 127732a6e48fSopenharmony_ci */ 127832a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, disconnect002, Function | MediumTest | Level1) 127932a6e48fSopenharmony_ci{ 128032a6e48fSopenharmony_ci GSError ret = pSurface->Disconnect(); 128132a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 128232a6e48fSopenharmony_ci} 128332a6e48fSopenharmony_ci 128432a6e48fSopenharmony_ci/* 128532a6e48fSopenharmony_ci* Function: connect 128632a6e48fSopenharmony_ci* Type: Function 128732a6e48fSopenharmony_ci* Rank: Important(1) 128832a6e48fSopenharmony_ci* EnvConditions: N/A 128932a6e48fSopenharmony_ci* CaseDescription: 1. call connect with producer_ is nullptr and check ret 129032a6e48fSopenharmony_ci */ 129132a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, connect003, Function | MediumTest | Level1) 129232a6e48fSopenharmony_ci{ 129332a6e48fSopenharmony_ci GSError ret = surface_->Connect(); 129432a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 129532a6e48fSopenharmony_ci} 129632a6e48fSopenharmony_ci 129732a6e48fSopenharmony_ci/* 129832a6e48fSopenharmony_ci* Function: disconnect 129932a6e48fSopenharmony_ci* Type: Function 130032a6e48fSopenharmony_ci* Rank: Important(1) 130132a6e48fSopenharmony_ci* EnvConditions: N/A 130232a6e48fSopenharmony_ci* CaseDescription: 1. call Disconnect with producer_ is nullptr and check ret 130332a6e48fSopenharmony_ci */ 130432a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, disconnect003, Function | MediumTest | Level1) 130532a6e48fSopenharmony_ci{ 130632a6e48fSopenharmony_ci GSError ret = surface_->Disconnect(); 130732a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 130832a6e48fSopenharmony_ci} 130932a6e48fSopenharmony_ci 131032a6e48fSopenharmony_ci/* 131132a6e48fSopenharmony_ci* Function: SetPresentTimestamp and GetPresentTimestamp 131232a6e48fSopenharmony_ci* Type: Function 131332a6e48fSopenharmony_ci* Rank: Important(2) 131432a6e48fSopenharmony_ci* EnvConditions: N/A 131532a6e48fSopenharmony_ci* CaseDescription: 1. call GetPresentTimestamp with producer_ is nullptr and check ret 131632a6e48fSopenharmony_ci* 2. call SetPresentTimestamp and check ret 131732a6e48fSopenharmony_ci */ 131832a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, presentTimestamp001, Function | MediumTest | Level2) 131932a6e48fSopenharmony_ci{ 132032a6e48fSopenharmony_ci GraphicPresentTimestampType type = GraphicPresentTimestampType::GRAPHIC_DISPLAY_PTS_UNSUPPORTED; 132132a6e48fSopenharmony_ci int64_t time = 0; 132232a6e48fSopenharmony_ci 132332a6e48fSopenharmony_ci GSError ret = surface_->GetPresentTimestamp(firstSeqnum, type, time); 132432a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 132532a6e48fSopenharmony_ci GraphicPresentTimestamp timestamp; 132632a6e48fSopenharmony_ci ret = surface_->SetPresentTimestamp(firstSeqnum, timestamp); 132732a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_NOT_SUPPORT); 132832a6e48fSopenharmony_ci} 132932a6e48fSopenharmony_ci 133032a6e48fSopenharmony_ci/* 133132a6e48fSopenharmony_ci* Function: SetPresentTimestamp and GetPresentTimestamp 133232a6e48fSopenharmony_ci* Type: Function 133332a6e48fSopenharmony_ci* Rank: Important(2) 133432a6e48fSopenharmony_ci* EnvConditions: N/A 133532a6e48fSopenharmony_ci* CaseDescription: 1. call GetPresentTimestamp with normal parameters and check ret 133632a6e48fSopenharmony_ci* @tc.require: issueI5I57K 133732a6e48fSopenharmony_ci */ 133832a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, presentTimestamp002, Function | MediumTest | Level2) 133932a6e48fSopenharmony_ci{ 134032a6e48fSopenharmony_ci GraphicPresentTimestampType type = GraphicPresentTimestampType::GRAPHIC_DISPLAY_PTS_UNSUPPORTED; 134132a6e48fSopenharmony_ci int64_t time = 0; 134232a6e48fSopenharmony_ci 134332a6e48fSopenharmony_ci GSError ret = pSurface->GetPresentTimestamp(firstSeqnum, type, time); 134432a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 134532a6e48fSopenharmony_ci} 134632a6e48fSopenharmony_ci 134732a6e48fSopenharmony_ci/* 134832a6e48fSopenharmony_ci* Function: SetPresentTimestamp and GetPresentTimestamp 134932a6e48fSopenharmony_ci* Type: Function 135032a6e48fSopenharmony_ci* Rank: Important(2) 135132a6e48fSopenharmony_ci* EnvConditions: N/A 135232a6e48fSopenharmony_ci* CaseDescription: 1. call SetPresentTimestamp with normal parameters and check ret 135332a6e48fSopenharmony_ci* @tc.require: issueI5I57K 135432a6e48fSopenharmony_ci */ 135532a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, presentTimestamp003, Function | MediumTest | Level2) 135632a6e48fSopenharmony_ci{ 135732a6e48fSopenharmony_ci GraphicPresentTimestampType type = GraphicPresentTimestampType::GRAPHIC_DISPLAY_PTS_DELAY; 135832a6e48fSopenharmony_ci int64_t time = 0; 135932a6e48fSopenharmony_ci GSError ret = pSurface->GetPresentTimestamp(-1, type, time); 136032a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_NO_ENTRY); 136132a6e48fSopenharmony_ci} 136232a6e48fSopenharmony_ci 136332a6e48fSopenharmony_ci/* 136432a6e48fSopenharmony_ci* Function: SetPresentTimestamp and GetPresentTimestamp 136532a6e48fSopenharmony_ci* Type: Function 136632a6e48fSopenharmony_ci* Rank: Important(1) 136732a6e48fSopenharmony_ci* EnvConditions: N/A 136832a6e48fSopenharmony_ci* CaseDescription: 1. call SetPresentTimestamp and check ret 136932a6e48fSopenharmony_ci* @tc.require: issueI5I57K 137032a6e48fSopenharmony_ci */ 137132a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, presentTimestamp004, Function | MediumTest | Level1) 137232a6e48fSopenharmony_ci{ 137332a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer; 137432a6e48fSopenharmony_ci int releaseFence = -1; 137532a6e48fSopenharmony_ci GSError ret = pSurface->RequestBuffer(buffer, releaseFence, requestConfig); 137632a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 137732a6e48fSopenharmony_ci ASSERT_NE(buffer, nullptr); 137832a6e48fSopenharmony_ci 137932a6e48fSopenharmony_ci uint32_t sequence = buffer->GetSeqNum(); 138032a6e48fSopenharmony_ci GraphicPresentTimestampType type = GraphicPresentTimestampType::GRAPHIC_DISPLAY_PTS_DELAY; 138132a6e48fSopenharmony_ci int64_t time = 0; 138232a6e48fSopenharmony_ci ret = pSurface->GetPresentTimestamp(sequence, type, time); 138332a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_NO_ENTRY); 138432a6e48fSopenharmony_ci 138532a6e48fSopenharmony_ci ret = pSurface->CancelBuffer(buffer); 138632a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 138732a6e48fSopenharmony_ci} 138832a6e48fSopenharmony_ci 138932a6e48fSopenharmony_ci/* 139032a6e48fSopenharmony_ci* Function: SetWptrNativeWindowToPSurface 139132a6e48fSopenharmony_ci* Type: Function 139232a6e48fSopenharmony_ci* Rank: Important(1) 139332a6e48fSopenharmony_ci* EnvConditions: N/A 139432a6e48fSopenharmony_ci* CaseDescription: 1. SetWptrNativeWindowToPSurface and check ret 139532a6e48fSopenharmony_ci* @tc.require: issueI7WYIY 139632a6e48fSopenharmony_ci */ 139732a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, SetWptrNativeWindowToPSurface001, Function | MediumTest | Level1) 139832a6e48fSopenharmony_ci{ 139932a6e48fSopenharmony_ci struct NativeWindow nativeWindow; 140032a6e48fSopenharmony_ci GSError ret = pSurface->SetWptrNativeWindowToPSurface(&nativeWindow); 140132a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 140232a6e48fSopenharmony_ci} 140332a6e48fSopenharmony_ci 140432a6e48fSopenharmony_ci/* 140532a6e48fSopenharmony_ci * Function: SetWptrNativeWindowToPSurface 140632a6e48fSopenharmony_ci * Type: Function 140732a6e48fSopenharmony_ci * Rank: Important(1) 140832a6e48fSopenharmony_ci * EnvConditions: N/A 140932a6e48fSopenharmony_ci * CaseDescription: 1. SetWptrNativeWindowToPSurface with nullptr param and check ret 141032a6e48fSopenharmony_ci * @tc.require: issueIANSVH 141132a6e48fSopenharmony_ci */ 141232a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, SetWptrNativeWindowToPSurface002, Function | MediumTest | Level1) 141332a6e48fSopenharmony_ci{ 141432a6e48fSopenharmony_ci GSError ret = surface_->SetWptrNativeWindowToPSurface(nullptr); 141532a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 141632a6e48fSopenharmony_ci} 141732a6e48fSopenharmony_ci 141832a6e48fSopenharmony_ci/* 141932a6e48fSopenharmony_ci * Function: SetWindowConfig and GetWindowConfig 142032a6e48fSopenharmony_ci * Type: Function 142132a6e48fSopenharmony_ci * Rank: Important(1) 142232a6e48fSopenharmony_ci * EnvConditions: N/A 142332a6e48fSopenharmony_ci * CaseDescription: 1. Call SetWindowConfig 142432a6e48fSopenharmony_ci * 2. Call GetWindowConfig and check ret 142532a6e48fSopenharmony_ci * @tc.require: issueIANSVH 142632a6e48fSopenharmony_ci */ 142732a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, WindowConfig001, Function | MediumTest | Level1) 142832a6e48fSopenharmony_ci{ 142932a6e48fSopenharmony_ci surface_->SetWindowConfig(requestConfig); 143032a6e48fSopenharmony_ci auto configGet = surface_->GetWindowConfig(); 143132a6e48fSopenharmony_ci ASSERT_EQ(requestConfig, configGet); 143232a6e48fSopenharmony_ci} 143332a6e48fSopenharmony_ci 143432a6e48fSopenharmony_ci/* 143532a6e48fSopenharmony_ci * Function: SetWindowConfigOpt 143632a6e48fSopenharmony_ci * Type: Function 143732a6e48fSopenharmony_ci * Rank: Important(1) 143832a6e48fSopenharmony_ci * EnvConditions: N/A 143932a6e48fSopenharmony_ci * CaseDescription: 1. Call SetWindowConfig with params 144032a6e48fSopenharmony_ci * 2. Call GetWindowConfig and check ret 144132a6e48fSopenharmony_ci * @tc.require: issueIANSVH 144232a6e48fSopenharmony_ci */ 144332a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, WindowConfig002, Function | MediumTest | Level1) 144432a6e48fSopenharmony_ci{ 144532a6e48fSopenharmony_ci surface_->SetWindowConfigWidthAndHeight(requestConfig.width, requestConfig.height); 144632a6e48fSopenharmony_ci surface_->SetWindowConfigStride(requestConfig.strideAlignment); 144732a6e48fSopenharmony_ci surface_->SetWindowConfigFormat(requestConfig.format); 144832a6e48fSopenharmony_ci surface_->SetWindowConfigUsage(requestConfig.usage); 144932a6e48fSopenharmony_ci surface_->SetWindowConfigTimeout(requestConfig.timeout); 145032a6e48fSopenharmony_ci surface_->SetWindowConfigColorGamut(requestConfig.colorGamut); 145132a6e48fSopenharmony_ci surface_->SetWindowConfigTransform(requestConfig.transform); 145232a6e48fSopenharmony_ci auto configGet = surface_->GetWindowConfig(); 145332a6e48fSopenharmony_ci ASSERT_EQ(requestConfig.width, configGet.width); 145432a6e48fSopenharmony_ci ASSERT_EQ(requestConfig.height, configGet.height); 145532a6e48fSopenharmony_ci ASSERT_EQ(requestConfig.strideAlignment, configGet.strideAlignment); 145632a6e48fSopenharmony_ci ASSERT_EQ(requestConfig.format, configGet.format); 145732a6e48fSopenharmony_ci ASSERT_EQ(requestConfig.usage, configGet.usage); 145832a6e48fSopenharmony_ci ASSERT_EQ(requestConfig.timeout, configGet.timeout); 145932a6e48fSopenharmony_ci ASSERT_EQ(requestConfig.colorGamut, configGet.colorGamut); 146032a6e48fSopenharmony_ci ASSERT_EQ(requestConfig.transform, configGet.transform); 146132a6e48fSopenharmony_ci} 146232a6e48fSopenharmony_ci 146332a6e48fSopenharmony_ci/* 146432a6e48fSopenharmony_ci* Function: AttachBuffer 146532a6e48fSopenharmony_ci* Type: Function 146632a6e48fSopenharmony_ci* Rank: Important(1) 146732a6e48fSopenharmony_ci* EnvConditions: N/A 146832a6e48fSopenharmony_ci* CaseDescription: 1. AttachBuffer and check ret 146932a6e48fSopenharmony_ci* @tc.require: issueI7WYIY 147032a6e48fSopenharmony_ci */ 147132a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, AttachBuffer001, Function | MediumTest | Level1) 147232a6e48fSopenharmony_ci{ 147332a6e48fSopenharmony_ci GSError ret = pSurface->CleanCache(); 147432a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 147532a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer = SurfaceBuffer::Create(); 147632a6e48fSopenharmony_ci ASSERT_NE(buffer, nullptr); 147732a6e48fSopenharmony_ci sptr<SyncFence> fence = SyncFence::INVALID_FENCE; 147832a6e48fSopenharmony_ci int32_t timeOut = 5; 147932a6e48fSopenharmony_ci ret = pSurface->AttachBuffer(buffer, timeOut); 148032a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 148132a6e48fSopenharmony_ci} 148232a6e48fSopenharmony_ci 148332a6e48fSopenharmony_ci/* 148432a6e48fSopenharmony_ci* Function: AttachBuffer 148532a6e48fSopenharmony_ci* Type: Function 148632a6e48fSopenharmony_ci* Rank: Important(2) 148732a6e48fSopenharmony_ci* EnvConditions: N/A 148832a6e48fSopenharmony_ci* CaseDescription: 1. call AttachBuffer with producer_ is nullptr 148932a6e48fSopenharmony_ci* 2. check ret 149032a6e48fSopenharmony_ci */ 149132a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, AttachBuffer002, Function | MediumTest | Level2) 149232a6e48fSopenharmony_ci{ 149332a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer = SurfaceBuffer::Create(); 149432a6e48fSopenharmony_ci GSError ret = surface_->AttachBuffer(buffer); 149532a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 149632a6e48fSopenharmony_ci ret = surface_->AttachBuffer(buffer, 0); 149732a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 149832a6e48fSopenharmony_ci} 149932a6e48fSopenharmony_ci 150032a6e48fSopenharmony_ci/* 150132a6e48fSopenharmony_ci* Function: RegisterSurfaceDelegator000 150232a6e48fSopenharmony_ci* Type: Function 150332a6e48fSopenharmony_ci* Rank: Important(1) 150432a6e48fSopenharmony_ci* EnvConditions: N/A 150532a6e48fSopenharmony_ci* CaseDescription: 1. RegisterSurfaceDelegator and check ret 150632a6e48fSopenharmony_ci* @tc.require: issueI7WYIY 150732a6e48fSopenharmony_ci */ 150832a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, RegisterSurfaceDelegator001, Function | MediumTest | Level1) 150932a6e48fSopenharmony_ci{ 151032a6e48fSopenharmony_ci GSError ret = pSurface->CleanCache(); 151132a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 151232a6e48fSopenharmony_ci ret = pSurface->RegisterSurfaceDelegator(nullptr); 151332a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 151432a6e48fSopenharmony_ci} 151532a6e48fSopenharmony_ci 151632a6e48fSopenharmony_ci/* 151732a6e48fSopenharmony_ci* Function: CleanCache001 151832a6e48fSopenharmony_ci* Type: Function 151932a6e48fSopenharmony_ci* Rank: Important(1) 152032a6e48fSopenharmony_ci* EnvConditions: N/A 152132a6e48fSopenharmony_ci* CaseDescription: 1. CleanCache and check ret 152232a6e48fSopenharmony_ci */ 152332a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, CleanCache001, Function | MediumTest | Level2) 152432a6e48fSopenharmony_ci{ 152532a6e48fSopenharmony_ci GSError ret = pSurface->CleanCache(true); 152632a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 152732a6e48fSopenharmony_ci} 152832a6e48fSopenharmony_ci 152932a6e48fSopenharmony_ci/* 153032a6e48fSopenharmony_ci* Function: CleanCache 153132a6e48fSopenharmony_ci* Type: Function 153232a6e48fSopenharmony_ci* Rank: Important(1) 153332a6e48fSopenharmony_ci* EnvConditions: N/A 153432a6e48fSopenharmony_ci* CaseDescription: 1. CleanCache with producer_ is nullptr and check ret 153532a6e48fSopenharmony_ci */ 153632a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, CleanCache002, Function | MediumTest | Level2) 153732a6e48fSopenharmony_ci{ 153832a6e48fSopenharmony_ci GSError ret = surface_->CleanCache(true); 153932a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 154032a6e48fSopenharmony_ci} 154132a6e48fSopenharmony_ci 154232a6e48fSopenharmony_ci/* 154332a6e48fSopenharmony_ci* Function: GoBackground 154432a6e48fSopenharmony_ci* Type: Function 154532a6e48fSopenharmony_ci* Rank: Important(1) 154632a6e48fSopenharmony_ci* EnvConditions: N/A 154732a6e48fSopenharmony_ci* CaseDescription: 1. GoBackground with producer_ is nullptr and check ret 154832a6e48fSopenharmony_ci */ 154932a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, GoBackground001, Function | MediumTest | Level2) 155032a6e48fSopenharmony_ci{ 155132a6e48fSopenharmony_ci GSError ret = surface_->GoBackground(); 155232a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 155332a6e48fSopenharmony_ci} 155432a6e48fSopenharmony_ci 155532a6e48fSopenharmony_ci/* 155632a6e48fSopenharmony_ci* Function: SetSurfaceSourceType and GetSurfaceSourceType 155732a6e48fSopenharmony_ci* Type: Function 155832a6e48fSopenharmony_ci* Rank: Important(2) 155932a6e48fSopenharmony_ci* EnvConditions: N/A 156032a6e48fSopenharmony_ci* CaseDescription: 1. call SetSurfaceSourceType and check ret 156132a6e48fSopenharmony_ci* 2. call GetSurfaceSourceType and check ret 156232a6e48fSopenharmony_ci*/ 156332a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, SurfaceSourceType001, Function | MediumTest | Level2) 156432a6e48fSopenharmony_ci{ 156532a6e48fSopenharmony_ci OHSurfaceSource sourceType = OHSurfaceSource::OH_SURFACE_SOURCE_VIDEO; 156632a6e48fSopenharmony_ci GSError ret = pSurface->SetSurfaceSourceType(sourceType); 156732a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 156832a6e48fSopenharmony_ci ASSERT_EQ(pSurface->GetSurfaceSourceType(), OH_SURFACE_SOURCE_VIDEO); 156932a6e48fSopenharmony_ci} 157032a6e48fSopenharmony_ci 157132a6e48fSopenharmony_ci/* 157232a6e48fSopenharmony_ci* Function: SetSurfaceSourceType and GetSurfaceSourceType 157332a6e48fSopenharmony_ci* Type: Function 157432a6e48fSopenharmony_ci* Rank: Important(2) 157532a6e48fSopenharmony_ci* EnvConditions: N/A 157632a6e48fSopenharmony_ci* CaseDescription: 1. call SetSurfaceSourceType with producer_ is nullptr and check ret 157732a6e48fSopenharmony_ci* 2. call GetSurfaceSourceType with producer_ is nullptr and check ret 157832a6e48fSopenharmony_ci*/ 157932a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, SurfaceSourceType002, Function | MediumTest | Level2) 158032a6e48fSopenharmony_ci{ 158132a6e48fSopenharmony_ci OHSurfaceSource sourceType = OHSurfaceSource::OH_SURFACE_SOURCE_VIDEO; 158232a6e48fSopenharmony_ci GSError ret = surface_->SetSurfaceSourceType(sourceType); 158332a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 158432a6e48fSopenharmony_ci ASSERT_EQ(surface_->GetSurfaceSourceType(), OHSurfaceSource::OH_SURFACE_SOURCE_DEFAULT); 158532a6e48fSopenharmony_ci} 158632a6e48fSopenharmony_ci 158732a6e48fSopenharmony_ci/* 158832a6e48fSopenharmony_ci* Function: SetSurfaceAppFrameworkType and GetSurfaceAppFrameworkType 158932a6e48fSopenharmony_ci* Type: Function 159032a6e48fSopenharmony_ci* Rank: Important(2) 159132a6e48fSopenharmony_ci* EnvConditions: N/A 159232a6e48fSopenharmony_ci* CaseDescription: 1. call SetSurfaceAppFrameworkType and check ret 159332a6e48fSopenharmony_ci* 2. call GetSurfaceAppFrameworkType and check ret 159432a6e48fSopenharmony_ci*/ 159532a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, SurfaceAppFrameworkType001, Function | MediumTest | Level2) 159632a6e48fSopenharmony_ci{ 159732a6e48fSopenharmony_ci std::string type = "test"; 159832a6e48fSopenharmony_ci GSError ret = pSurface->SetSurfaceAppFrameworkType(type); 159932a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 160032a6e48fSopenharmony_ci ASSERT_EQ(pSurface->GetSurfaceAppFrameworkType(), "test"); 160132a6e48fSopenharmony_ci} 160232a6e48fSopenharmony_ci 160332a6e48fSopenharmony_ci/* 160432a6e48fSopenharmony_ci* Function: SetSurfaceAppFrameworkType and GetSurfaceAppFrameworkType 160532a6e48fSopenharmony_ci* Type: Function 160632a6e48fSopenharmony_ci* Rank: Important(2) 160732a6e48fSopenharmony_ci* EnvConditions: N/A 160832a6e48fSopenharmony_ci* CaseDescription: 1. call SetSurfaceAppFrameworkType with producer_ is nullptr and check ret 160932a6e48fSopenharmony_ci* 2. call GetSurfaceAppFrameworkType with producer_ is nullptr and check ret 161032a6e48fSopenharmony_ci*/ 161132a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, SurfaceAppFrameworkType002, Function | MediumTest | Level2) 161232a6e48fSopenharmony_ci{ 161332a6e48fSopenharmony_ci std::string type = "test"; 161432a6e48fSopenharmony_ci GSError ret = surface_->SetSurfaceAppFrameworkType(type); 161532a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 161632a6e48fSopenharmony_ci ASSERT_EQ(surface_->GetSurfaceAppFrameworkType(), ""); 161732a6e48fSopenharmony_ci} 161832a6e48fSopenharmony_ci 161932a6e48fSopenharmony_ci/* 162032a6e48fSopenharmony_ci* Function: RegisterReleaseListener and UnRegisterReleaseListener 162132a6e48fSopenharmony_ci* Type: Function 162232a6e48fSopenharmony_ci* Rank: Important(2) 162332a6e48fSopenharmony_ci* EnvConditions: N/A 162432a6e48fSopenharmony_ci* CaseDescription: 1. call RegisterReleaseListener with producer_ is nullptr and check ret 162532a6e48fSopenharmony_ci* 2. call UnRegisterReleaseListener with producer_ is nullptr and check ret 162632a6e48fSopenharmony_ci*/ 162732a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, ReleaseListener001, Function | MediumTest | Level2) 162832a6e48fSopenharmony_ci{ 162932a6e48fSopenharmony_ci GSError ret = surface_->RegisterReleaseListener(OnBufferRelease); 163032a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 163132a6e48fSopenharmony_ci OnReleaseFuncWithFence releaseFuncWithFence; 163232a6e48fSopenharmony_ci ret = surface_->RegisterReleaseListener(releaseFuncWithFence); 163332a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 163432a6e48fSopenharmony_ci ret = surface_->UnRegisterReleaseListener(); 163532a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 163632a6e48fSopenharmony_ci} 163732a6e48fSopenharmony_ci 163832a6e48fSopenharmony_ci/* 163932a6e48fSopenharmony_ci* Function: RegisterUserDataChangeListener 164032a6e48fSopenharmony_ci* Type: Function 164132a6e48fSopenharmony_ci* Rank: Important(2) 164232a6e48fSopenharmony_ci* EnvConditions: N/A 164332a6e48fSopenharmony_ci* CaseDescription: 1. call RegisterUserDataChangeListener with nullptr param 164432a6e48fSopenharmony_ci* 2. check ret 164532a6e48fSopenharmony_ci*/ 164632a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, RegisterUserDataChangeListener001, Function | MediumTest | Level2) 164732a6e48fSopenharmony_ci{ 164832a6e48fSopenharmony_ci GSError ret = surface_->RegisterUserDataChangeListener("test", nullptr); 164932a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 165032a6e48fSopenharmony_ci} 165132a6e48fSopenharmony_ci 165232a6e48fSopenharmony_ci/* 165332a6e48fSopenharmony_ci* Function: RequestBuffersAndFlushBuffers 165432a6e48fSopenharmony_ci* Type: Function 165532a6e48fSopenharmony_ci* Rank: Important(1) 165632a6e48fSopenharmony_ci* EnvConditions: N/A 165732a6e48fSopenharmony_ci* CaseDescription: 1. call RequestBuffers and FlushBuffers 165832a6e48fSopenharmony_ci* @tc.require: issueI5GMZN issueI5IWHW 165932a6e48fSopenharmony_ci */ 166032a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, RequestBuffersAndFlushBuffers, Function | MediumTest | Level1) 166132a6e48fSopenharmony_ci{ 166232a6e48fSopenharmony_ci pSurface->SetQueueSize(12); 166332a6e48fSopenharmony_ci std::vector<sptr<SurfaceBuffer>> sfbuffers; 166432a6e48fSopenharmony_ci std::vector<sptr<SyncFence>> releaseFences; 166532a6e48fSopenharmony_ci EXPECT_EQ(OHOS::GSERROR_OK, pSurface->RequestBuffers(sfbuffers, releaseFences, requestConfig)); 166632a6e48fSopenharmony_ci for (size_t i = 0; i < sfbuffers.size(); ++i) { 166732a6e48fSopenharmony_ci EXPECT_NE(nullptr, sfbuffers[i]); 166832a6e48fSopenharmony_ci } 166932a6e48fSopenharmony_ci std::cout << sfbuffers.size() << std::endl; 167032a6e48fSopenharmony_ci uint32_t num = static_cast<uint32_t>(sfbuffers.size()); 167132a6e48fSopenharmony_ci std::vector<sptr<SyncFence>> flushFences; 167232a6e48fSopenharmony_ci std::vector<BufferFlushConfigWithDamages> configs; 167332a6e48fSopenharmony_ci flushFences.resize(num); 167432a6e48fSopenharmony_ci configs.reserve(num); 167532a6e48fSopenharmony_ci auto handleConfig = [](BufferFlushConfigWithDamages &config) -> void { 167632a6e48fSopenharmony_ci config.damages.reserve(1); 167732a6e48fSopenharmony_ci OHOS::Rect damage = { 167832a6e48fSopenharmony_ci .x = 0, 167932a6e48fSopenharmony_ci .y = 0, 168032a6e48fSopenharmony_ci .w = 0x100, 168132a6e48fSopenharmony_ci .h = 0x100 168232a6e48fSopenharmony_ci }; 168332a6e48fSopenharmony_ci config.damages.emplace_back(damage); 168432a6e48fSopenharmony_ci config.timestamp = 0; 168532a6e48fSopenharmony_ci }; 168632a6e48fSopenharmony_ci for (uint32_t i = 0; i < num; ++i) { 168732a6e48fSopenharmony_ci flushFences[i] = new SyncFence(-1); 168832a6e48fSopenharmony_ci BufferFlushConfigWithDamages config; 168932a6e48fSopenharmony_ci handleConfig(config); 169032a6e48fSopenharmony_ci configs.emplace_back(config); 169132a6e48fSopenharmony_ci } 169232a6e48fSopenharmony_ci flushFences[0] = nullptr; 169332a6e48fSopenharmony_ci EXPECT_EQ(OHOS::GSERROR_INVALID_ARGUMENTS, pSurface->FlushBuffers(sfbuffers, flushFences, configs)); 169432a6e48fSopenharmony_ci flushFences[0] = new SyncFence(-1); 169532a6e48fSopenharmony_ci EXPECT_EQ(OHOS::GSERROR_OK, pSurface->FlushBuffers(sfbuffers, flushFences, configs)); 169632a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer; 169732a6e48fSopenharmony_ci int32_t flushFence; 169832a6e48fSopenharmony_ci for (uint32_t i = 0; i < num; ++i) { 169932a6e48fSopenharmony_ci GSError ret = csurf->AcquireBuffer(buffer, flushFence, timestamp, damage); 170032a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 170132a6e48fSopenharmony_ci ret = csurf->ReleaseBuffer(buffer, -1); 170232a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 170332a6e48fSopenharmony_ci } 170432a6e48fSopenharmony_ci EXPECT_EQ(OHOS::GSERROR_NO_BUFFER, csurf->AcquireBuffer(buffer, flushFence, timestamp, damage)); 170532a6e48fSopenharmony_ci pSurface->SetQueueSize(2); 170632a6e48fSopenharmony_ci} 170732a6e48fSopenharmony_ci 170832a6e48fSopenharmony_ci/* 170932a6e48fSopenharmony_ci* Function: AcquireLastFlushedBuffer and ReleaseLastFlushedBuffer 171032a6e48fSopenharmony_ci* Type: Function 171132a6e48fSopenharmony_ci* Rank: Important(1) 171232a6e48fSopenharmony_ci* EnvConditions: N/A 171332a6e48fSopenharmony_ci* CaseDescription: 1. call AcquireLastFlushedBuffer OK 171432a6e48fSopenharmony_ci* 2. call AcquireLastFlushedBuffer FAIL 171532a6e48fSopenharmony_ci* 3. call ReleaseLastFlushedBuffer 171632a6e48fSopenharmony_ci */ 171732a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, AcquireLastFlushedBuffer001, Function | MediumTest | Level2) 171832a6e48fSopenharmony_ci{ 171932a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer; 172032a6e48fSopenharmony_ci int releaseFence = -1; 172132a6e48fSopenharmony_ci EXPECT_EQ(producer->SetQueueSize(3), OHOS::GSERROR_OK); 172232a6e48fSopenharmony_ci GSError ret = pSurface->RequestBuffer(buffer, releaseFence, requestConfig); 172332a6e48fSopenharmony_ci EXPECT_EQ(ret, OHOS::GSERROR_OK); 172432a6e48fSopenharmony_ci 172532a6e48fSopenharmony_ci ret = pSurface->FlushBuffer(buffer, -1, flushConfig); 172632a6e48fSopenharmony_ci EXPECT_EQ(ret, OHOS::GSERROR_OK); 172732a6e48fSopenharmony_ci 172832a6e48fSopenharmony_ci int32_t flushFence; 172932a6e48fSopenharmony_ci ret = csurf->AcquireBuffer(buffer, flushFence, timestamp, damage); 173032a6e48fSopenharmony_ci EXPECT_EQ(ret, OHOS::GSERROR_OK); 173132a6e48fSopenharmony_ci ret = csurf->ReleaseBuffer(buffer, -1); 173232a6e48fSopenharmony_ci EXPECT_EQ(ret, OHOS::GSERROR_OK); 173332a6e48fSopenharmony_ci 173432a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer1 = nullptr; 173532a6e48fSopenharmony_ci sptr<SyncFence> fence = nullptr; 173632a6e48fSopenharmony_ci float matrix[16]; 173732a6e48fSopenharmony_ci 173832a6e48fSopenharmony_ci ret = pSurface->AcquireLastFlushedBuffer(buffer1, fence, matrix, 16, false); 173932a6e48fSopenharmony_ci EXPECT_EQ(ret, OHOS::GSERROR_OK); 174032a6e48fSopenharmony_ci EXPECT_EQ(buffer->GetSeqNum(), buffer1->GetSeqNum()); 174132a6e48fSopenharmony_ci 174232a6e48fSopenharmony_ci ret = pSurface->AcquireLastFlushedBuffer(buffer1, fence, matrix, 16, false); 174332a6e48fSopenharmony_ci EXPECT_EQ(ret, OHOS::SURFACE_ERROR_BUFFER_STATE_INVALID); 174432a6e48fSopenharmony_ci 174532a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer2; 174632a6e48fSopenharmony_ci ret = pSurface->RequestBuffer(buffer2, releaseFence, requestConfig); 174732a6e48fSopenharmony_ci EXPECT_EQ(ret, OHOS::GSERROR_OK); 174832a6e48fSopenharmony_ci 174932a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer3; 175032a6e48fSopenharmony_ci ret = pSurface->RequestBuffer(buffer3, releaseFence, requestConfig); 175132a6e48fSopenharmony_ci EXPECT_EQ(ret, OHOS::GSERROR_OK); 175232a6e48fSopenharmony_ci 175332a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer4; 175432a6e48fSopenharmony_ci ret = pSurface->RequestBuffer(buffer4, releaseFence, requestConfig); 175532a6e48fSopenharmony_ci EXPECT_EQ(ret, OHOS::GSERROR_NO_BUFFER); 175632a6e48fSopenharmony_ci 175732a6e48fSopenharmony_ci ret = pSurface->ReleaseLastFlushedBuffer(buffer1); 175832a6e48fSopenharmony_ci EXPECT_EQ(ret, OHOS::GSERROR_OK); 175932a6e48fSopenharmony_ci 176032a6e48fSopenharmony_ci ret = pSurface->RequestBuffer(buffer4, releaseFence, requestConfig); 176132a6e48fSopenharmony_ci EXPECT_EQ(ret, OHOS::GSERROR_OK); 176232a6e48fSopenharmony_ci 176332a6e48fSopenharmony_ci ret = pSurface->FlushBuffer(buffer2, -1, flushConfig); 176432a6e48fSopenharmony_ci EXPECT_EQ(ret, OHOS::GSERROR_OK); 176532a6e48fSopenharmony_ci 176632a6e48fSopenharmony_ci ret = pSurface->FlushBuffer(buffer3, -1, flushConfig); 176732a6e48fSopenharmony_ci EXPECT_EQ(ret, OHOS::GSERROR_OK); 176832a6e48fSopenharmony_ci 176932a6e48fSopenharmony_ci ret = pSurface->FlushBuffer(buffer4, -1, flushConfig); 177032a6e48fSopenharmony_ci EXPECT_EQ(ret, OHOS::GSERROR_OK); 177132a6e48fSopenharmony_ci 177232a6e48fSopenharmony_ci ret = pSurface->ReleaseLastFlushedBuffer(buffer2); 177332a6e48fSopenharmony_ci EXPECT_EQ(ret, OHOS::SURFACE_ERROR_BUFFER_STATE_INVALID); 177432a6e48fSopenharmony_ci 177532a6e48fSopenharmony_ci EXPECT_EQ(pSurface->CleanCache(), OHOS::GSERROR_OK); 177632a6e48fSopenharmony_ci} 177732a6e48fSopenharmony_ci 177832a6e48fSopenharmony_ci/* 177932a6e48fSopenharmony_ci* Function: AcquireLastFlushedBuffer and ReleaseLastFlushedBuffer 178032a6e48fSopenharmony_ci* Type: Function 178132a6e48fSopenharmony_ci* Rank: Important(1) 178232a6e48fSopenharmony_ci* EnvConditions: N/A 178332a6e48fSopenharmony_ci* CaseDescription: 1. call AcquireLastFlushedBuffer FAIL 178432a6e48fSopenharmony_ci* 3. call ReleaseLastFlushedBuffer FAIL 178532a6e48fSopenharmony_ci */ 178632a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, AcquireLastFlushedBuffer002, Function | MediumTest | Level2) 178732a6e48fSopenharmony_ci{ 178832a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer1 = nullptr; 178932a6e48fSopenharmony_ci sptr<SyncFence> fence = nullptr; 179032a6e48fSopenharmony_ci float matrix[16]; 179132a6e48fSopenharmony_ci GSError ret = surface_->AcquireLastFlushedBuffer(buffer1, fence, matrix, 16, false); 179232a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 179332a6e48fSopenharmony_ci ret = surface_->ReleaseLastFlushedBuffer(buffer1); 179432a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 179532a6e48fSopenharmony_ci ret = pSurface->ReleaseLastFlushedBuffer(nullptr); 179632a6e48fSopenharmony_ci EXPECT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 179732a6e48fSopenharmony_ci} 179832a6e48fSopenharmony_ci 179932a6e48fSopenharmony_ci/* 180032a6e48fSopenharmony_ci* Function: SetHdrWhitePointBrightness and SetSdrWhitePointBrightness 180132a6e48fSopenharmony_ci* Type: Function 180232a6e48fSopenharmony_ci* Rank: Important(2) 180332a6e48fSopenharmony_ci* EnvConditions: N/A 180432a6e48fSopenharmony_ci* CaseDescription: 1. call SetHdrWhitePointBrightness with producer_ is nullptr and check ret 180532a6e48fSopenharmony_ci* 2. call SetSdrWhitePointBrightness with producer_ is nullptr and check ret 180632a6e48fSopenharmony_ci*/ 180732a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, WhitePointBrightness001, Function | MediumTest | Level2) 180832a6e48fSopenharmony_ci{ 180932a6e48fSopenharmony_ci GSError ret = surface_->SetHdrWhitePointBrightness(0); 181032a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 181132a6e48fSopenharmony_ci ret = surface_->SetSdrWhitePointBrightness(0); 181232a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 181332a6e48fSopenharmony_ci} 181432a6e48fSopenharmony_ci 181532a6e48fSopenharmony_ci/* 181632a6e48fSopenharmony_ci* Function: ReleaseLastFlushedBuffer 181732a6e48fSopenharmony_ci* Type: Function 181832a6e48fSopenharmony_ci* Rank: Important(2) 181932a6e48fSopenharmony_ci* EnvConditions: N/A 182032a6e48fSopenharmony_ci* CaseDescription: 1. call ReleaseLastFlushedBuffer with buffer is nullptr and check ret 182132a6e48fSopenharmony_ci* 2. call ReleaseLastFlushedBuffer with producer_ is nullptr and check ret 182232a6e48fSopenharmony_ci*/ 182332a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, ReleaseLastFlushedBuffer001, Function | MediumTest | Level2) 182432a6e48fSopenharmony_ci{ 182532a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer = nullptr; 182632a6e48fSopenharmony_ci GSError ret = surface_->ReleaseLastFlushedBuffer(buffer); 182732a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 182832a6e48fSopenharmony_ci buffer = SurfaceBuffer::Create(); 182932a6e48fSopenharmony_ci ret = surface_->ReleaseLastFlushedBuffer(buffer); 183032a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 183132a6e48fSopenharmony_ci} 183232a6e48fSopenharmony_ci 183332a6e48fSopenharmony_ci/* 183432a6e48fSopenharmony_ci* Function: SetGlobalAlpha 183532a6e48fSopenharmony_ci* Type: Function 183632a6e48fSopenharmony_ci* Rank: Important(2) 183732a6e48fSopenharmony_ci* EnvConditions: N/A 183832a6e48fSopenharmony_ci* CaseDescription: 1. call SetGlobalAlpha with abnormal parameters and check ret 183932a6e48fSopenharmony_ci*/ 184032a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, SetGlobalAlpha001, Function | MediumTest | Level2) 184132a6e48fSopenharmony_ci{ 184232a6e48fSopenharmony_ci int32_t alpha = -255; 184332a6e48fSopenharmony_ci GSError ret = pSurface->SetGlobalAlpha(alpha); 184432a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 184532a6e48fSopenharmony_ci alpha = 256; 184632a6e48fSopenharmony_ci ret = pSurface->SetGlobalAlpha(alpha); 184732a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_INVALID_ARGUMENTS); 184832a6e48fSopenharmony_ci alpha = 255; 184932a6e48fSopenharmony_ci ret = pSurface->SetGlobalAlpha(alpha); 185032a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 185132a6e48fSopenharmony_ci} 185232a6e48fSopenharmony_ci 185332a6e48fSopenharmony_ci/* 185432a6e48fSopenharmony_ci* Function: IsInHebcWhiletList 185532a6e48fSopenharmony_ci* Type: Function 185632a6e48fSopenharmony_ci* Rank: Important(2) 185732a6e48fSopenharmony_ci* EnvConditions: N/A 185832a6e48fSopenharmony_ci* CaseDescription: 1. call IsInHebcWhiletList and check ret 185932a6e48fSopenharmony_ci*/ 186032a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, IsInHebcWhiletList001, Function | MediumTest | Level2) 186132a6e48fSopenharmony_ci{ 186232a6e48fSopenharmony_ci bool isInHebcList = pSurface->IsInHebcList(); 186332a6e48fSopenharmony_ci ASSERT_EQ(isInHebcList, false); 186432a6e48fSopenharmony_ci} 186532a6e48fSopenharmony_ci 186632a6e48fSopenharmony_ci/* 186732a6e48fSopenharmony_ci* Function: RequestBufferNoConsumer 186832a6e48fSopenharmony_ci* Type: Function 186932a6e48fSopenharmony_ci* Rank: Important(2) 187032a6e48fSopenharmony_ci* EnvConditions: N/A 187132a6e48fSopenharmony_ci* CaseDescription: 1. call RequestBuffer and check ret 187232a6e48fSopenharmony_ci*/ 187332a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, RequestBufferNoConsumer, Function | MediumTest | Level2) 187432a6e48fSopenharmony_ci{ 187532a6e48fSopenharmony_ci sptr<IConsumerSurface> cSurfTmp = IConsumerSurface::Create(); 187632a6e48fSopenharmony_ci sptr<IBufferConsumerListener> listenerTmp = new BufferConsumerListener(); 187732a6e48fSopenharmony_ci cSurfTmp->RegisterConsumerListener(listenerTmp); 187832a6e48fSopenharmony_ci sptr<IBufferProducer> producerTmp = cSurfTmp->GetProducer(); 187932a6e48fSopenharmony_ci sptr<Surface> pSurfaceTmp = Surface::CreateSurfaceAsProducer(producerTmp); 188032a6e48fSopenharmony_ci 188132a6e48fSopenharmony_ci BufferRequestConfig requestConfigTmp = { 188232a6e48fSopenharmony_ci .width = 0x100, 188332a6e48fSopenharmony_ci .height = 0x100, 188432a6e48fSopenharmony_ci .strideAlignment = 0x8, 188532a6e48fSopenharmony_ci .format = GRAPHIC_PIXEL_FMT_RGBA_8888, 188632a6e48fSopenharmony_ci .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE | BUFFER_USAGE_MEM_DMA, 188732a6e48fSopenharmony_ci .timeout = 0, 188832a6e48fSopenharmony_ci }; 188932a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer = nullptr; 189032a6e48fSopenharmony_ci int releaseFence = -1; 189132a6e48fSopenharmony_ci GSError ret = pSurfaceTmp->RequestBuffer(buffer, releaseFence, requestConfigTmp); 189232a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 189332a6e48fSopenharmony_ci 189432a6e48fSopenharmony_ci cSurfTmp = nullptr; 189532a6e48fSopenharmony_ci ret = pSurfaceTmp->RequestBuffer(buffer, releaseFence, requestConfigTmp); 189632a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_NO_CONSUMER); 189732a6e48fSopenharmony_ci 189832a6e48fSopenharmony_ci pSurfaceTmp = nullptr; 189932a6e48fSopenharmony_ci producerTmp = nullptr; 190032a6e48fSopenharmony_ci} 190132a6e48fSopenharmony_ci 190232a6e48fSopenharmony_ci/* 190332a6e48fSopenharmony_ci* Function: RequestBufferNoListener 190432a6e48fSopenharmony_ci* Type: Function 190532a6e48fSopenharmony_ci* Rank: Important(2) 190632a6e48fSopenharmony_ci* EnvConditions: N/A 190732a6e48fSopenharmony_ci* CaseDescription: 1. call RequestBuffer and check ret 190832a6e48fSopenharmony_ci*/ 190932a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, RequestBufferNoListener, Function | MediumTest | Level2) 191032a6e48fSopenharmony_ci{ 191132a6e48fSopenharmony_ci sptr<IConsumerSurface> cSurfTmp = IConsumerSurface::Create(); 191232a6e48fSopenharmony_ci sptr<IBufferProducer> producerTmp = cSurfTmp->GetProducer(); 191332a6e48fSopenharmony_ci sptr<Surface> pSurfaceTmp = Surface::CreateSurfaceAsProducer(producerTmp); 191432a6e48fSopenharmony_ci 191532a6e48fSopenharmony_ci BufferRequestConfig requestConfigTmp = { 191632a6e48fSopenharmony_ci .width = 0x100, 191732a6e48fSopenharmony_ci .height = 0x100, 191832a6e48fSopenharmony_ci .strideAlignment = 0x8, 191932a6e48fSopenharmony_ci .format = GRAPHIC_PIXEL_FMT_RGBA_8888, 192032a6e48fSopenharmony_ci .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE | BUFFER_USAGE_MEM_DMA, 192132a6e48fSopenharmony_ci .timeout = 0, 192232a6e48fSopenharmony_ci }; 192332a6e48fSopenharmony_ci sptr<SurfaceBuffer> buffer = nullptr; 192432a6e48fSopenharmony_ci int releaseFence = -1; 192532a6e48fSopenharmony_ci GSError ret = pSurfaceTmp->RequestBuffer(buffer, releaseFence, requestConfigTmp); 192632a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::SURFACE_ERROR_CONSUMER_UNREGISTER_LISTENER); 192732a6e48fSopenharmony_ci 192832a6e48fSopenharmony_ci ret = pSurfaceTmp->Disconnect(); 192932a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 193032a6e48fSopenharmony_ci 193132a6e48fSopenharmony_ci ret = pSurfaceTmp->Connect(); 193232a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 193332a6e48fSopenharmony_ci 193432a6e48fSopenharmony_ci ret = pSurfaceTmp->Disconnect(); 193532a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 193632a6e48fSopenharmony_ci 193732a6e48fSopenharmony_ci pSurfaceTmp = nullptr; 193832a6e48fSopenharmony_ci producerTmp = nullptr; 193932a6e48fSopenharmony_ci cSurfTmp = nullptr; 194032a6e48fSopenharmony_ci} 194132a6e48fSopenharmony_ci 194232a6e48fSopenharmony_ci/* 194332a6e48fSopenharmony_ci* Function: RequestBuffersNoListener 194432a6e48fSopenharmony_ci* Type: Function 194532a6e48fSopenharmony_ci* Rank: Important(2) 194632a6e48fSopenharmony_ci* EnvConditions: N/A 194732a6e48fSopenharmony_ci* CaseDescription: 1. call RequestBuffer and check ret 194832a6e48fSopenharmony_ci*/ 194932a6e48fSopenharmony_ciHWTEST_F(ProducerSurfaceTest, RequestBuffersNoListener, Function | MediumTest | Level2) 195032a6e48fSopenharmony_ci{ 195132a6e48fSopenharmony_ci sptr<IConsumerSurface> cSurfTmp = IConsumerSurface::Create(); 195232a6e48fSopenharmony_ci sptr<IBufferProducer> producerTmp = cSurfTmp->GetProducer(); 195332a6e48fSopenharmony_ci sptr<Surface> pSurfaceTmp = Surface::CreateSurfaceAsProducer(producerTmp); 195432a6e48fSopenharmony_ci 195532a6e48fSopenharmony_ci BufferRequestConfig requestConfigTmp = { 195632a6e48fSopenharmony_ci .width = 0x100, 195732a6e48fSopenharmony_ci .height = 0x100, 195832a6e48fSopenharmony_ci .strideAlignment = 0x8, 195932a6e48fSopenharmony_ci .format = GRAPHIC_PIXEL_FMT_RGBA_8888, 196032a6e48fSopenharmony_ci .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE | BUFFER_USAGE_MEM_DMA, 196132a6e48fSopenharmony_ci .timeout = 0, 196232a6e48fSopenharmony_ci .transform = GraphicTransformType::GRAPHIC_ROTATE_BUTT, 196332a6e48fSopenharmony_ci }; 196432a6e48fSopenharmony_ci 196532a6e48fSopenharmony_ci std::vector<sptr<SurfaceBuffer>> sfbuffers; 196632a6e48fSopenharmony_ci std::vector<sptr<SyncFence>> releaseFences; 196732a6e48fSopenharmony_ci GSError ret = pSurfaceTmp->RequestBuffers(sfbuffers, releaseFences, requestConfigTmp); 196832a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::SURFACE_ERROR_UNKOWN); 196932a6e48fSopenharmony_ci 197032a6e48fSopenharmony_ci ret = pSurfaceTmp->Disconnect(); 197132a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 197232a6e48fSopenharmony_ci 197332a6e48fSopenharmony_ci ret = pSurfaceTmp->Connect(); 197432a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 197532a6e48fSopenharmony_ci 197632a6e48fSopenharmony_ci ret = pSurfaceTmp->Disconnect(); 197732a6e48fSopenharmony_ci ASSERT_EQ(ret, OHOS::GSERROR_OK); 197832a6e48fSopenharmony_ci 197932a6e48fSopenharmony_ci pSurfaceTmp = nullptr; 198032a6e48fSopenharmony_ci producerTmp = nullptr; 198132a6e48fSopenharmony_ci cSurfTmp = nullptr; 198232a6e48fSopenharmony_ci} 198332a6e48fSopenharmony_ci} 1984