mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-11-27 09:10:54 +00:00
添加TDD
Signed-off-by: xcxcxcx2019 <liujiaming35@huawei.com>
This commit is contained in:
parent
6431b88b9a
commit
36b651690e
@ -36,6 +36,7 @@ void RSImageBaseTest::SetUpTestCase() {}
|
||||
void RSImageBaseTest::TearDownTestCase() {}
|
||||
void RSImageBaseTest::SetUp() {}
|
||||
void RSImageBaseTest::TearDown() {}
|
||||
Drawing::ColorType GetColorTypeWithVKFormat(VkFormat vkFormat);
|
||||
|
||||
/**
|
||||
* @tc.name: DrawImageTest
|
||||
@ -279,4 +280,550 @@ HWTEST_F(RSImageBaseTest, ProcessYUVImageTest, TestSize.Level1)
|
||||
imageBase->ProcessYUVImage(gpuContext);
|
||||
EXPECT_EQ(RSPixelMapUtil::ConvertYUVPixelMapToDrawingImage(gpuContext, pixelMap), nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: MarkRenderServiceImageTest001
|
||||
* @tc.desc: Verify function MarkRenderServiceImage
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, MarkRenderServiceImageTest001, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
pixelMap->allocatorType_ = Media::AllocatorType::SHARE_MEM_ALLOC;
|
||||
pixelMap->editable_ = true;
|
||||
pixelMap->isAstic_ = true;
|
||||
imageBase->SetPixelMap(pixelMap);
|
||||
imageBase->MarkRenderServiceImage();
|
||||
EXPECT_TRUE(imageBase->renderServiceImage_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: MarkRenderServiceImageTest002
|
||||
* @tc.desc: Verify function MarkRenderServiceImage
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, MarkRenderServiceImageTest002, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
pixelMap->allocatorType_ = Media::AllocatorType::HEAP_ALLOC;
|
||||
pixelMap->editable_ = true;
|
||||
pixelMap->isAstic_ = true;
|
||||
imageBase->SetPixelMap(pixelMap);
|
||||
imageBase->MarkRenderServiceImage();
|
||||
EXPECT_TRUE(imageBase->renderServiceImage_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: MarkRenderServiceImageTest003
|
||||
* @tc.desc: Verify function MarkRenderServiceImage
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, MarkRenderServiceImageTest003, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
auto ImageInfo = std::make_shared<Media::ImageInfo>();
|
||||
ImageInfo->pixelFormat = Media::PixelFormat::RGBA_F16;
|
||||
imageBase->canPurgeShareMemFlag_ = RSImageBase::CanPurgeFlag::UNINITED;
|
||||
pixelMap->allocatorType_ = Media::AllocatorType::SHARE_MEM_ALLOC;
|
||||
pixelMap->editable_ = true;
|
||||
pixelMap->isAstic_ = true;
|
||||
imageBase->SetPixelMap(pixelMap);
|
||||
imageBase->MarkRenderServiceImage();
|
||||
EXPECT_TRUE(imageBase->renderServiceImage_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetColorTypeWithVKFormatTest
|
||||
* @tc.desc: Verify function GetColorTypeWithVKFormat
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, GetColorTypeWithVKFormatTest, TestSize.Level1)
|
||||
{
|
||||
VkFormat vkFormat = VK_FORMAT_R8G8B8A8_UNORM;
|
||||
EXPECT_EQ(GetColorTypeWithVKFormat(vkFormat), Drawing::COLORTYPE_RGBA_8888);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetColorTypeWithVKFormatTest001
|
||||
* @tc.desc: Verify function GetColorTypeWithVKFormat
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, GetColorTypeWithVKFormatTest001, TestSize.Level1)
|
||||
{
|
||||
VkFormat vkFormat = VK_FORMAT_R16G16B16A16_SFLOAT;
|
||||
EXPECT_EQ(GetColorTypeWithVKFormat(vkFormat), Drawing::COLORTYPE_RGBA_F16);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetColorTypeWithVKFormatTest002
|
||||
* @tc.desc: Verify function GetColorTypeWithVKFormat
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, GetColorTypeWithVKFormatTest002, TestSize.Level1)
|
||||
{
|
||||
VkFormat vkFormat = VK_FORMAT_R5G6B5_UNORM_PACK16;
|
||||
EXPECT_EQ(GetColorTypeWithVKFormat(vkFormat), Drawing::COLORTYPE_RGB_565);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetColorTypeWithVKFormatTest003
|
||||
* @tc.desc: Verify function GetColorTypeWithVKFormat
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, GetColorTypeWithVKFormatTest003, TestSize.Level1)
|
||||
{
|
||||
VkFormat vkFormat = VK_FORMAT_A2B10G10R10_UNORM_PACK32;
|
||||
EXPECT_EQ(GetColorTypeWithVKFormat(vkFormat), Drawing::COLORTYPE_RGBA_1010102);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetColorTypeWithVKFormatTest004
|
||||
* @tc.desc: Verify function GetColorTypeWithVKFormat
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, GetColorTypeWithVKFormatTest004, TestSize.Level1)
|
||||
{
|
||||
VkFormat vkFormat = VK_FORMAT_R32_SFLOAT;
|
||||
EXPECT_EQ(GetColorTypeWithVKFormat(vkFormat), Drawing::COLORTYPE_RGBA_8888);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PurgeTest001
|
||||
* @tc.desc: Verify function Purge
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, PurgeTest001, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
imageBase->SetPixelMap(pixelMap);
|
||||
ASSERT_NE(imageBase, nullptr);
|
||||
imageBase->Purge();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PurgeTest002
|
||||
* @tc.desc: Verify function Purge
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, PurgeTest002, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
auto image = std::make_shared<Drawing::Image>();
|
||||
imageBase->SetImage(image);
|
||||
imageBase->uniqueId_ = 1;
|
||||
imageBase->canPurgeShareMemFlag_ = RSImageBase::CanPurgeFlag::ENABLED;
|
||||
ASSERT_NE(imageBase, nullptr);
|
||||
imageBase->Purge();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PurgeTest003
|
||||
* @tc.desc: Verify function Purge
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, PurgeTest003, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
auto image = std::make_shared<Drawing::Image>();
|
||||
imageBase->SetImage(image);
|
||||
imageBase->uniqueId_ = -1;
|
||||
imageBase->canPurgeShareMemFlag_ = RSImageBase::CanPurgeFlag::ENABLED;
|
||||
ASSERT_NE(imageBase, nullptr);
|
||||
imageBase->Purge();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PurgeTest004
|
||||
* @tc.desc: Verify function Purge
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, PurgeTest004, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
auto image = std::make_shared<Drawing::Image>();
|
||||
imageBase->SetImage(image);
|
||||
imageBase->uniqueId_ = 1;
|
||||
imageBase->canPurgeShareMemFlag_ = RSImageBase::CanPurgeFlag::DISABLED;
|
||||
ASSERT_NE(imageBase, nullptr);
|
||||
imageBase->Purge();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PurgeTest005
|
||||
* @tc.desc: Verify function Purge
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, PurgeTest005, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
auto image = std::make_shared<Drawing::Image>();
|
||||
imageBase->SetImage(image);
|
||||
imageBase->uniqueId_ = -1;
|
||||
imageBase->canPurgeShareMemFlag_ = RSImageBase::CanPurgeFlag::DISABLED;
|
||||
ASSERT_NE(imageBase, nullptr);
|
||||
imageBase->Purge();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PurgeTest006
|
||||
* @tc.desc: Verify function Purge
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, PurgeTest006, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
auto image = std::make_shared<Drawing::Image>();
|
||||
imageBase->SetImage(image);
|
||||
imageBase->uniqueId_ = 1;
|
||||
imageBase->canPurgeShareMemFlag_ = RSImageBase::CanPurgeFlag::ENABLED;
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
pixelMap->allocatorType_ = Media::AllocatorType::SHARE_MEM_ALLOC;
|
||||
pixelMap->isUnMap_ = true;
|
||||
imageBase->SetPixelMap(pixelMap);
|
||||
ASSERT_NE(imageBase, nullptr);
|
||||
imageBase->Purge();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PurgeTest007
|
||||
* @tc.desc: Verify function Purge
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, PurgeTest007, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
auto image = std::make_shared<Drawing::Image>();
|
||||
imageBase->SetImage(image);
|
||||
imageBase->uniqueId_ = 1;
|
||||
imageBase->canPurgeShareMemFlag_ = RSImageBase::CanPurgeFlag::ENABLED;
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
pixelMap->allocatorType_ = Media::AllocatorType::HEAP_ALLOC;
|
||||
pixelMap->isUnMap_ = true;
|
||||
imageBase->SetPixelMap(pixelMap);
|
||||
ASSERT_NE(imageBase, nullptr);
|
||||
imageBase->Purge();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PurgeTest008
|
||||
* @tc.desc: Verify function Purge
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, PurgeTest008, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
auto image = std::make_shared<Drawing::Image>();
|
||||
imageBase->SetImage(image);
|
||||
imageBase->uniqueId_ = 1;
|
||||
imageBase->canPurgeShareMemFlag_ = RSImageBase::CanPurgeFlag::ENABLED;
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
pixelMap->allocatorType_ = Media::AllocatorType::HEAP_ALLOC;
|
||||
pixelMap->isUnMap_ = false;
|
||||
imageBase->SetPixelMap(pixelMap);
|
||||
ASSERT_NE(imageBase, nullptr);
|
||||
imageBase->Purge();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UnmarshallingDrawingImageAndPixelMapTest
|
||||
* @tc.desc: Verify function UnmarshallingDrawingImageAndPixelMap
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, UnmarshallingDrawingImageAndPixelMapTest, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
Parcel parcel;
|
||||
parcel.WriteInt32(-1);
|
||||
uint64_t uniqueId = 1;
|
||||
bool useSKImage = false;
|
||||
auto image = std::make_shared<Drawing::Image>();
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
pixelMap->allocatorType_ = Media::AllocatorType::HEAP_ALLOC;
|
||||
void* addr = nullptr;
|
||||
bool ret = imageBase->UnmarshallingDrawingImageAndPixelMap(parcel, uniqueId, useSKImage, pixelMap, addr);
|
||||
EXPECT_EQ(ret, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UnmarshallingDrawingImageAndPixelMapTest001
|
||||
* @tc.desc: Verify function UnmarshallingDrawingImageAndPixelMap
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, UnmarshallingDrawingImageAndPixelMapTest001, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
Parcel parcel;
|
||||
parcel.WriteInt32(1);
|
||||
uint64_t uniqueId = 1;
|
||||
bool useSKImage = false;
|
||||
auto image = std::make_shared<Drawing::Image>();
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
void* addr = nullptr;
|
||||
bool ret = imageBase->UnmarshallingDrawingImageAndPixelMap(parcel, uniqueId, useSKImage, pixelMap, addr);
|
||||
EXPECT_EQ(ret, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UnmarshallingDrawingImageAndPixelMapTest002
|
||||
* @tc.desc: Verify function UnmarshallingDrawingImageAndPixelMap
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, UnmarshallingDrawingImageAndPixelMapTest002, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
Parcel parcel;
|
||||
parcel.WriteInt32(1);
|
||||
uint64_t uniqueId = 1;
|
||||
bool useSKImage = true;
|
||||
auto image = std::make_shared<Drawing::Image>();
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
void* addr = nullptr;
|
||||
bool ret = imageBase->UnmarshallingDrawingImageAndPixelMap(parcel, uniqueId, useSKImage, pixelMap, addr);
|
||||
EXPECT_EQ(ret, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: MakeFromTextureForVKTest
|
||||
* @tc.desc: Verify function MakeFromTextureForVK
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, MakeFromTextureForVKTest, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
auto image = std::make_shared<Drawing::Image>();
|
||||
Drawing::Canvas canvas = RSPaintFilterCanvas(std::make_shared<Drawing::Canvas>().get());
|
||||
EXPECT_EQ(imageBase->MakeFromTextureForVK(canvas, nullptr), nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: MakeFromTextureForVKTest001
|
||||
* @tc.desc: Verify function MakeFromTextureForVK
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, MakeFromTextureForVKTest001, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
auto image = std::make_shared<Drawing::Image>();
|
||||
sptr<SurfaceBuffer> surfaceBuffer = SurfaceBuffer::Create().GetRefPtr();
|
||||
Drawing::Canvas canvas = RSPaintFilterCanvas(std::make_shared<Drawing::Canvas>().get());
|
||||
canvas.gpuContext_ = std::make_shared<Drawing::GPUContext>();
|
||||
EXPECT_EQ(imageBase->MakeFromTextureForVK(canvas, surfaceBuffer), nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: MakeFromTextureForVKTest002
|
||||
* @tc.desc: Verify function MakeFromTextureForVK
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, MakeFromTextureForVKTest002, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
auto image = std::make_shared<Drawing::Image>();
|
||||
sptr<SurfaceBuffer> surfaceBuffer = SurfaceBuffer::Create().GetRefPtr();
|
||||
Drawing::Canvas canvas = RSPaintFilterCanvas(std::make_shared<Drawing::Canvas>().get());
|
||||
imageBase->nativeWindowBuffer_ = nullptr;
|
||||
EXPECT_EQ(imageBase->MakeFromTextureForVK(canvas, surfaceBuffer), nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: MakeFromTextureForVKTest003
|
||||
* @tc.desc: Verify function MakeFromTextureForVK
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, MakeFromTextureForVKTest003, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
auto image = std::make_shared<Drawing::Image>();
|
||||
sptr<SurfaceBuffer> surfaceBuffer = SurfaceBuffer::Create().GetRefPtr();
|
||||
Drawing::Canvas canvas = RSPaintFilterCanvas(std::make_shared<Drawing::Canvas>().get());
|
||||
imageBase->nativeWindowBuffer_ = nullptr;
|
||||
imageBase->backendTexture_.isValid_ = true;
|
||||
EXPECT_EQ(imageBase->MakeFromTextureForVK(canvas, surfaceBuffer), nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: MakeFromTextureForVKTest004
|
||||
* @tc.desc: Verify function MakeFromTextureForVK
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, MakeFromTextureForVKTest004, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
auto image = std::make_shared<Drawing::Image>();
|
||||
sptr<SurfaceBuffer> surfaceBuffer = SurfaceBuffer::Create().GetRefPtr();
|
||||
Drawing::Canvas canvas = RSPaintFilterCanvas(std::make_shared<Drawing::Canvas>().get());
|
||||
imageBase->nativeWindowBuffer_ = nullptr;
|
||||
imageBase->backendTexture_.isValid_ = false;
|
||||
EXPECT_EQ(imageBase->MakeFromTextureForVK(canvas, surfaceBuffer), nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: BindPixelMapToDrawingImageTest
|
||||
* @tc.desc: Verify function BindPixelMapToDrawingImage
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, BindPixelMapToDrawingImageTest, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
Drawing::Canvas canvas = RSPaintFilterCanvas(std::make_shared<Drawing::Canvas>().get());
|
||||
ASSERT_NE(imageBase, nullptr);
|
||||
imageBase->BindPixelMapToDrawingImage(canvas);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: BindPixelMapToDrawingImageTest001
|
||||
* @tc.desc: Verify function BindPixelMapToDrawingImage
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, BindPixelMapToDrawingImageTest001, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
auto image = std::make_shared<Drawing::Image>();
|
||||
imageBase->SetImage(image);
|
||||
Drawing::Canvas canvas = RSPaintFilterCanvas(std::make_shared<Drawing::Canvas>().get());
|
||||
ASSERT_NE(imageBase, nullptr);
|
||||
imageBase->BindPixelMapToDrawingImage(canvas);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: BindPixelMapToDrawingImageTest002
|
||||
* @tc.desc: Verify function BindPixelMapToDrawingImage
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, BindPixelMapToDrawingImageTest002, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
pixelMap->isAstc_ = true;
|
||||
imageBase->SetPixelMap(pixelMap);
|
||||
Drawing::Canvas canvas = RSPaintFilterCanvas(std::make_shared<Drawing::Canvas>().get());
|
||||
ASSERT_NE(imageBase, nullptr);
|
||||
imageBase->BindPixelMapToDrawingImage(canvas);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: BindPixelMapToDrawingImageTest003
|
||||
* @tc.desc: Verify function BindPixelMapToDrawingImage
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, BindPixelMapToDrawingImageTest003, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
pixelMap->isAstc_ = false;
|
||||
imageBase->SetPixelMap(pixelMap);
|
||||
Drawing::Canvas canvas = RSPaintFilterCanvas(std::make_shared<Drawing::Canvas>().get());
|
||||
ASSERT_NE(imageBase, nullptr);
|
||||
imageBase->BindPixelMapToDrawingImage(canvas);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: BindPixelMapToDrawingImageTest004
|
||||
* @tc.desc: Verify function BindPixelMapToDrawingImage
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, BindPixelMapToDrawingImageTest004, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
pixelMap->isAstc_ = true;
|
||||
imageBase->SetPixelMap(pixelMap);
|
||||
auto image = std::make_shared<Drawing::Image>();
|
||||
imageBase->SetImage(image);
|
||||
Drawing::Canvas canvas = RSPaintFilterCanvas(std::make_shared<Drawing::Canvas>().get());
|
||||
ASSERT_NE(imageBase, nullptr);
|
||||
imageBase->BindPixelMapToDrawingImage(canvas);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: BindPixelMapToDrawingImageTest005
|
||||
* @tc.desc: Verify function BindPixelMapToDrawingImage
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, BindPixelMapToDrawingImageTest005, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
pixelMap->isAstc_ = false;
|
||||
imageBase->SetPixelMap(pixelMap);
|
||||
auto image = std::make_shared<Drawing::Image>();
|
||||
imageBase->SetImage(image);
|
||||
Drawing::Canvas canvas = RSPaintFilterCanvas(std::make_shared<Drawing::Canvas>().get());
|
||||
ASSERT_NE(imageBase, nullptr);
|
||||
imageBase->BindPixelMapToDrawingImage(canvas);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: BindPixelMapToDrawingImageTest006
|
||||
* @tc.desc: Verify function BindPixelMapToDrawingImage
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, BindPixelMapToDrawingImageTest006, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
pixelMap->isAstc_ = false;
|
||||
pixelMap->editable_ = true;
|
||||
imageBase->SetPixelMap(pixelMap);
|
||||
auto image = std::make_shared<Drawing::Image>();
|
||||
imageBase->SetImage(image);
|
||||
Drawing::Canvas canvas = RSPaintFilterCanvas(std::make_shared<Drawing::Canvas>().get());
|
||||
ASSERT_NE(imageBase, nullptr);
|
||||
imageBase->BindPixelMapToDrawingImage(canvas);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: BindPixelMapToDrawingImageTest007
|
||||
* @tc.desc: Verify function BindPixelMapToDrawingImage
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageBaseTest, BindPixelMapToDrawingImageTest007, TestSize.Level1)
|
||||
{
|
||||
auto imageBase = std::make_shared<RSImageBase>();
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
pixelMap->isAstc_ = false;
|
||||
pixelMap->editable_ = false;
|
||||
imageBase->SetPixelMap(pixelMap);
|
||||
auto image = std::make_shared<Drawing::Image>();
|
||||
imageBase->SetImage(image);
|
||||
Drawing::Canvas canvas = RSPaintFilterCanvas(std::make_shared<Drawing::Canvas>().get());
|
||||
ASSERT_NE(imageBase, nullptr);
|
||||
imageBase->BindPixelMapToDrawingImage(canvas);
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
@ -251,4 +251,263 @@ HWTEST_F(RSImageCacheTest, ReleaseUniqueIdListTest, TestSize.Level1)
|
||||
EXPECT_TRUE(RSImageCache::Instance().uniqueIdList_.empty());
|
||||
RSImageCache::Instance().uniqueIdList_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetDrawingImageCacheTest
|
||||
* @tc.desc: Verify function GetDrawingImageCache
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageCacheTest, GetDrawingImageCacheTest, TestSize.Level1)
|
||||
{
|
||||
RSImageCache& imageCache = RSImageCache::Instance();
|
||||
auto img = std::make_shared<Drawing::Image>();
|
||||
imageCache.CacheDrawingImage(1, img);
|
||||
EXPECT_EQ(imageCache.GetDrawingImageCache(1), img);
|
||||
imageCache.drawingImageCache_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetPixelMapCacheTest001
|
||||
* @tc.desc: Verify function GetPixelMapCache
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageCacheTest, GetPixelMapCacheTest001, TestSize.Level1)
|
||||
{
|
||||
RSImageCache& imageCache = RSImageCache::Instance();
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
imageCache.CacheDrawingImage(1, pixelMap);
|
||||
EXPECT_EQ(imageCache.GetPixelMapCache(1), pixelMap);
|
||||
imageCache.pixelMapCache_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: IncreasePixelMapCacheRefCountTest001
|
||||
* @tc.desc: Verify function IncreasePixelMapCacheRefCount
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageCacheTest, IncreasePixelMapCacheRefCountTest001, TestSize.Level1)
|
||||
{
|
||||
RSImageCache& imageCache = RSImageCache::Instance();
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
imageCache.CacheDrawingImage(1, pixelMap);
|
||||
imageCache.IncreasePixelMapCacheRefCount(1);
|
||||
EXPECT_TRUE(true);
|
||||
imageCache.pixelMapCache_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ReleasePixelMapCacheTest001
|
||||
* @tc.desc: Verify function ReleasePixelMapCache
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageCacheTest, ReleasePixelMapCacheTest001, TestSize.Level1)
|
||||
{
|
||||
RSImageCache& imageCache = RSImageCache::Instance();
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
imageCache.CacheDrawingImage(1, pixelMap);
|
||||
imageCache.ReleasePixelMapCache(1);
|
||||
EXPECT_TRUE(true);
|
||||
imageCache.pixelMapCache_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ReleasePixelMapCacheTest002
|
||||
* @tc.desc: Verify function ReleasePixelMapCache
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageCacheTest, ReleasePixelMapCacheTest002, TestSize.Level1)
|
||||
{
|
||||
RSImageCache& imageCache = RSImageCache::Instance();
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
imageCache.pixelMapCache_.emplace(1, std::make_pair(nullptr, 0));
|
||||
pixelMap->allocatorType_ = Media::AllocatorType::DMA_ALLOC;
|
||||
imageCache.ReleasePixelMapCache(1);
|
||||
EXPECT_TRUE(true);
|
||||
imageCache.pixelMapCache_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ReleasePixelMapCacheTest003
|
||||
* @tc.desc: Verify function ReleasePixelMapCache
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageCacheTest, ReleasePixelMapCacheTest003, TestSize.Level1)
|
||||
{
|
||||
RSImageCache& imageCache = RSImageCache::Instance();
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
imageCache.pixelMapCache_.emplace(1, std::make_pair(nullptr, 1));
|
||||
pixelMap->allocatorType_ = Media::AllocatorType::DMA_ALLOC;
|
||||
imageCache.ReleasePixelMapCache(1);
|
||||
EXPECT_TRUE(true);
|
||||
imageCache.pixelMapCache_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ReleasePixelMapCacheTest004
|
||||
* @tc.desc: Verify function ReleasePixelMapCache
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageCacheTest, ReleasePixelMapCacheTest004, TestSize.Level1)
|
||||
{
|
||||
RSImageCache& imageCache = RSImageCache::Instance();
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
imageCache.pixelMapCache_.emplace(1, std::make_pair(pixelMap, 0));
|
||||
pixelMap->allocatorType_ = Media::AllocatorType::HEAP_ALLOC;
|
||||
imageCache.ReleasePixelMapCache(1);
|
||||
EXPECT_TRUE(true);
|
||||
imageCache.pixelMapCache_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ReleasePixelMapCacheTest005
|
||||
* @tc.desc: Verify function ReleasePixelMapCache
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageCacheTest, ReleasePixelMapCacheTest005, TestSize.Level1)
|
||||
{
|
||||
RSImageCache& imageCache = RSImageCache::Instance();
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
imageCache.pixelMapCache_.emplace(1, std::make_pair(pixelMap, 1));
|
||||
pixelMap->allocatorType_ = Media::AllocatorType::HEAP_ALLOC;
|
||||
imageCache.ReleasePixelMapCache(1);
|
||||
EXPECT_TRUE(true);
|
||||
imageCache.pixelMapCache_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetRenderDrawingImageCacheByPixelMapIdTest001
|
||||
* @tc.desc: Verify function GetRenderDrawingImageCacheByPixelMapId
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageCacheTest, GetRenderDrawingImageCacheByPixelMapIdTest001, TestSize.Level1)
|
||||
{
|
||||
RSImageCache& imageCache = RSImageCache::Instance();
|
||||
auto img = std::make_shared<Drawing::Image>();
|
||||
imageCache.CacheRenderDrawingImageByPixelMapId(1, img, 0);
|
||||
EXPECT_EQ(imageCache.GetRenderDrawingImageCacheByPixelMapId(1, 0), img);
|
||||
imageCache.pixelMapIdRelatedDrawingImageCache_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ReleaseDrawingImageCacheByPixelMapIdTest001
|
||||
* @tc.desc: Verify function ReleaseDrawingImageCacheByPixelMapId
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageCacheTest, ReleaseDrawingImageCacheByPixelMapIdTest001, TestSize.Level1)
|
||||
{
|
||||
RSImageCache& imageCache = RSImageCache::Instance();
|
||||
auto img = std::make_shared<Drawing::Image>();
|
||||
imageCache.CacheRenderDrawingImageByPixelMapId(1, img, 0);
|
||||
imageCache.ReleaseDrawingImageCacheByPixelMapId(1);
|
||||
EXPECT_TRUE(true);
|
||||
imageCache.pixelMapIdRelatedDrawingImageCache_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: CachePixelMapTest
|
||||
* @tc.desc: Verify function CachePixelMap
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageCacheTest, CachePixelMapTest, TestSize.Level1)
|
||||
{
|
||||
RSImageCache& imageCache = RSImageCache::Instance();
|
||||
uint64_t uniqueId = 1;
|
||||
imageCache.CachePixelMap(uniqueId, nullptr);
|
||||
EXPECT_FALSE(imageCache.pixelMapCache_.empty());
|
||||
imageCache.pixelMapCache_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: CachePixelMapTest001
|
||||
* @tc.desc: Verify function CachePixelMap
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageCacheTest, CachePixelMapTest001, TestSize.Level1)
|
||||
{
|
||||
RSImageCache& imageCache = RSImageCache::Instance();
|
||||
uint64_t uniqueId = 0;
|
||||
imageCache.CachePixelMap(uniqueId, nullptr);
|
||||
EXPECT_TRUE(true);
|
||||
imageCache.pixelMapCache_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: CachePixelMapTest002
|
||||
* @tc.desc: Verify function CachePixelMap
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageCacheTest, CachePixelMapTest002, TestSize.Level1)
|
||||
{
|
||||
RSImageCache& imageCache = RSImageCache::Instance();
|
||||
uint64_t uniqueId = 1;
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
pixelMap->allocatorType_ = Media::AllocatorType::DMA_ALLOC;
|
||||
imageCache.CachePixelMap(uniqueId, pixelMap);
|
||||
EXPECT_FALSE(imageCache.pixelMapCache_.empty());
|
||||
imageCache.pixelMapCache_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: CachePixelMapTest003
|
||||
* @tc.desc: Verify function CachePixelMap
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageCacheTest, CachePixelMapTest003, TestSize.Level1)
|
||||
{
|
||||
RSImageCache& imageCache = RSImageCache::Instance();
|
||||
uint64_t uniqueId = 0;
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
pixelMap->allocatorType_ = Media::AllocatorType::DMA_ALLOC;
|
||||
imageCache.CachePixelMap(uniqueId, pixelMap);
|
||||
EXPECT_TRUE(true);
|
||||
imageCache.pixelMapCache_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: CachePixelMapTest004
|
||||
* @tc.desc: Verify function CachePixelMap
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageCacheTest, CachePixelMapTest004, TestSize.Level1)
|
||||
{
|
||||
RSImageCache& imageCache = RSImageCache::Instance();
|
||||
uint64_t uniqueId = 1;
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
pixelMap->allocatorType_ = Media::AllocatorType::HEAP_ALLOC;
|
||||
imageCache.CachePixelMap(uniqueId, pixelMap);
|
||||
EXPECT_FALSE(imageCache.pixelMapCache_.empty());
|
||||
imageCache.pixelMapCache_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: CachePixelMapTest005
|
||||
* @tc.desc: Verify function CachePixelMap
|
||||
* @tc.type:FUNC
|
||||
* @tc.require: issue#IB2B3G
|
||||
*/
|
||||
HWTEST_F(RSImageCacheTest, CachePixelMapTest005, TestSize.Level1)
|
||||
{
|
||||
RSImageCache& imageCache = RSImageCache::Instance();
|
||||
uint64_t uniqueId = 0;
|
||||
auto pixelMap = std::make_shared<Media::PixelMap>();
|
||||
pixelMap->allocatorType_ = Media::AllocatorType::HEAP_ALLOC;
|
||||
imageCache.CachePixelMap(uniqueId, pixelMap);
|
||||
EXPECT_TRUE(true);
|
||||
imageCache.pixelMapCache_.clear();
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
Loading…
Reference in New Issue
Block a user