diff --git a/surface/test/unittest/surface_buffer_impl_test.cpp b/surface/test/unittest/surface_buffer_impl_test.cpp index 1de977cd26cd292f7f1e6bef1cd4643ed32b798c..0db74e1f73d152b8496c198776abee745c7bf1c2 100644 --- a/surface/test/unittest/surface_buffer_impl_test.cpp +++ b/surface/test/unittest/surface_buffer_impl_test.cpp @@ -18,6 +18,7 @@ #include #include #include +#include "v1_1/buffer_handle_meta_key_type.h" using namespace testing; using namespace testing::ext; @@ -116,6 +117,13 @@ HWTEST_F(SurfaceBufferImplTest, State002, Function | MediumTest | Level2) ASSERT_EQ(buffer->GetFormat(), GRAPHIC_PIXEL_FMT_RGBA_8888); ASSERT_EQ(buffer->GetUsage(), BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE | BUFFER_USAGE_MEM_DMA); ASSERT_EQ(buffer->GetSurfaceBufferColorGamut(), GraphicColorGamut::GRAPHIC_COLOR_GAMUT_DCI_P3); + + buffer->SetBufferHandle(nullptr); + ASSERT_EQ(buffer->GetPhyAddr(), 0); + ASSERT_EQ(buffer->GetStride(), -1); + vector keys; + ASSERT_EQ(buffer->ListMetadataKeys(keys), GSERROR_NOT_INIT); + ASSERT_EQ(buffer->EraseMetadataKey(1), GSERROR_NOT_INIT); } /* @@ -186,10 +194,14 @@ HWTEST_F(SurfaceBufferImplTest, Metadata001, Function | MediumTest | Level2) uint32_t setMetadata = 4260097; std::vector setData; ASSERT_EQ(MetadataHelper::ConvertMetadataToVec(setMetadata, setData), OHOS::GSERROR_OK); + ASSERT_EQ(sbi->SetMetadata(0, setData), GSERROR_INVALID_ARGUMENTS); + ASSERT_EQ(sbi->SetMetadata(HDI::Display::Graphic::Common::V1_1::ATTRKEY_END, setData), GSERROR_INVALID_ARGUMENTS); sret = sbi->SetMetadata(metadataKey, setData); ASSERT_TRUE(sret == OHOS::GSERROR_OK || GSErrorStr(sret) == "<500 api call failed>with low error "); std::vector getData; + ASSERT_EQ(sbi->GetMetadata(0, getData), GSERROR_INVALID_ARGUMENTS); + ASSERT_EQ(sbi->GetMetadata(HDI::Display::Graphic::Common::V1_1::ATTRKEY_END, getData), GSERROR_INVALID_ARGUMENTS); sret = sbi->GetMetadata(metadataKey, getData); ASSERT_TRUE(sret == OHOS::GSERROR_OK || GSErrorStr(sret) == "<500 api call failed>with low error "); @@ -209,6 +221,8 @@ HWTEST_F(SurfaceBufferImplTest, Metadata001, Function | MediumTest | Level2) ASSERT_EQ(keys[0], metadataKey); } + ASSERT_EQ(sbi->EraseMetadataKey(0), GSERROR_INVALID_ARGUMENTS); + ASSERT_EQ(sbi->EraseMetadataKey(HDI::Display::Graphic::Common::V1_1::ATTRKEY_END), GSERROR_INVALID_ARGUMENTS); sret = sbi->EraseMetadataKey(metadataKey); ASSERT_TRUE(sret == OHOS::GSERROR_OK || GSErrorStr(sret) == "<500 api call failed>with low error ");