From ddb558eda55cee4991004f1b9bd82e5b819f92fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=99=BA=E5=8B=87?= Date: Fri, 22 Aug 2025 15:51:40 +0800 Subject: [PATCH] =?UTF-8?q?UT=E7=94=A8=E4=BE=8B=E4=BB=A3=E7=A0=81=E5=90=8C?= =?UTF-8?q?=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张智勇 --- frameworks/innerkitsimpl/test/BUILD.gn | 1 - .../unittest/picture_test/picture_test.cpp | 20 ++++------- .../test/unittest/post_proc_test.cpp | 36 +++++++++++++------ 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/frameworks/innerkitsimpl/test/BUILD.gn b/frameworks/innerkitsimpl/test/BUILD.gn index 0bdf6f63a..5325d271b 100644 --- a/frameworks/innerkitsimpl/test/BUILD.gn +++ b/frameworks/innerkitsimpl/test/BUILD.gn @@ -1914,7 +1914,6 @@ ohos_unittest("imageformatconverttest") { "${image_subsystem}/interfaces/innerkits/include", ] sources = [ - "${image_subsystem}/frameworks/innerkitsimpl/test/unittest/image_format_convert_fail_test.cpp", "${image_subsystem}/frameworks/innerkitsimpl/test/unittest/image_format_convert_test.cpp", ] deps = [ diff --git a/frameworks/innerkitsimpl/test/unittest/picture_test/picture_test.cpp b/frameworks/innerkitsimpl/test/unittest/picture_test/picture_test.cpp index e2f5214b8..0fa34067e 100644 --- a/frameworks/innerkitsimpl/test/unittest/picture_test/picture_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/picture_test/picture_test.cpp @@ -44,18 +44,16 @@ static const std::string IMAGE_INPUT_JPEG_PATH = "/data/local/tmp/image/test_met static const std::string IMAGE_INPUT_EXIF_JPEG_PATH = "/data/local/tmp/image/test_exif.jpg"; static const int32_t SIZE_WIDTH = 2; static const int32_t SIZE_HEIGHT = 3; -static const int32_t SIZE_STRIDE = 8; -static const int32_t BUFFER_LENGTH = 25; +static const int32_t BUFFER_LENGTH = 8; static std::shared_ptr CreatePixelMap() { - const uint32_t color[BUFFER_LENGTH] = { 0x80, 0x02, 0x04, 0x08, 0x40, 0x02, 0x04, 0x08, - 0x80, 0x02, 0x04, 0x08, 0x40, 0x02, 0x04, 0x80, 0x02, 0x04, 0x08, 0x40, 0x02, 0x04, 0x08, 0x80, 0x02 }; + const uint32_t color[BUFFER_LENGTH] = { 0x80, 0x02, 0x04, 0x08, 0x40, 0x02, 0x04, 0x08}; InitializationOptions options; options.size.width = SIZE_WIDTH; options.size.height = SIZE_HEIGHT; - options.srcPixelFormat = PixelFormat::RGBA_8888; - options.pixelFormat = PixelFormat::RGBA_8888; + options.srcPixelFormat = PixelFormat::UNKNOWN; + options.pixelFormat = PixelFormat::UNKNOWN; options.alphaType = AlphaType::IMAGE_ALPHA_TYPE_OPAQUE; std::unique_ptr tmpPixelMap = PixelMap::Create(color, BUFFER_LENGTH, options); std::shared_ptr pixelmap = std::move(tmpPixelMap); @@ -81,12 +79,6 @@ static std::shared_ptr CreateAuxiliaryPicture(AuxiliaryPicture } Size size = {SIZE_WIDTH, SIZE_HEIGHT}; std::unique_ptr tmpAuxiliaryPicture = AuxiliaryPicture::Create(pixelmap, type, size); - AuxiliaryPictureInfo auxiliaryPictureInfo; - auxiliaryPictureInfo.size = size; - auxiliaryPictureInfo.pixelFormat = PixelFormat::RGBA_8888; - auxiliaryPictureInfo.rowStride = SIZE_STRIDE; - auxiliaryPictureInfo.auxiliaryPictureType = AuxiliaryPictureType::GAINMAP; - tmpAuxiliaryPicture->SetAuxiliaryPictureInfo(auxiliaryPictureInfo); EXPECT_NE(tmpAuxiliaryPicture, nullptr); if (tmpAuxiliaryPicture == nullptr) { return nullptr; @@ -706,7 +698,7 @@ HWTEST_F(PictureTest, SetExifMetadataByExifMetadataTest001, TestSize.Level2) /** * @tc.name: SetExifMetadataTest001 * @tc.desc: test the SetExifMetadata of Picture - * @tc.type: FUNC + * when surfaceBuffer is nullptr,return ERR_IMAGE_INVALID_PARAMETER */ HWTEST_F(PictureTest, SetExifMetadataTest001, TestSize.Level3) { @@ -721,7 +713,7 @@ HWTEST_F(PictureTest, SetExifMetadataTest001, TestSize.Level3) /** * @tc.name: SetExifMetadataTest002 * @tc.desc: test the SetExifMetadata of Picture - * @tc.type: FUNC + * when surfaceBuffer->getExtraData() is nullptr,return ERR_IMAGE_INVALID_PARAMETER */ HWTEST_F(PictureTest, SetExifMetadataTest002, TestSize.Level3) { diff --git a/frameworks/innerkitsimpl/test/unittest/post_proc_test.cpp b/frameworks/innerkitsimpl/test/unittest/post_proc_test.cpp index 511204956..3a3a53fe3 100644 --- a/frameworks/innerkitsimpl/test/unittest/post_proc_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/post_proc_test.cpp @@ -957,24 +957,38 @@ HWTEST_F(PostProcTest, CenterDisplayTest001, TestSize.Level3) { GTEST_LOG_(INFO) << "PostProcTest: CenterDisplayTest001 start"; PostProc postProc; - PixelMap pixelMap; + PixelMap tmpPixelMap; int32_t srcWidth = 0; int32_t srcHeight = 0; int32_t targetWidth = 0; int32_t targetHeight = 0; - bool ret = postProc.CenterDisplay(pixelMap, srcWidth, srcHeight, targetWidth, targetHeight); + bool ret = postProc.CenterDisplay(tmpPixelMap, srcWidth, srcHeight, targetWidth, targetHeight); ASSERT_EQ(ret, false); - targetWidth = 1; - targetHeight = 1; - pixelMap.imageInfo_.pixelFormat = PixelFormat::ALPHA_8; - pixelMap.allocatorType_ = AllocatorType::HEAP_ALLOC; - ret = postProc.CenterDisplay(pixelMap, srcWidth, srcHeight, targetWidth, targetHeight); + + srcWidth = 500; + srcHeight = 500; + targetWidth = 100; + targetHeight = 100; + InitializationOptions opts; + opts.size.width = srcWidth; + opts.size.height = srcHeight; + opts.pixelFormat = PixelFormat::ARGB_8888; + opts.allocatorType = AllocatorType::HEAP_ALLOC; + std::unique_ptr pixelMap1 = PixelMap::Create(opts); + ASSERT_NE(pixelMap1.get(), nullptr); + ret = postProc.CenterDisplay(*(pixelMap1.get()), srcWidth, srcHeight, targetWidth, targetHeight); ASSERT_EQ(ret, true); - pixelMap.allocatorType_ = AllocatorType::DMA_ALLOC; - ret = postProc.CenterDisplay(pixelMap, srcWidth, srcHeight, targetWidth, targetHeight); + + opts.allocatorType = AllocatorType::DMA_ALLOC; + std::unique_ptr pixelMap2 = PixelMap::Create(opts); + ASSERT_NE(pixelMap2.get(), nullptr); + ret = postProc.CenterDisplay(*(pixelMap2.get()), srcWidth, srcHeight, targetWidth, targetHeight); ASSERT_EQ(ret, true); - pixelMap.allocatorType_ = AllocatorType::DEFAULT; - ret = postProc.CenterDisplay(pixelMap, srcWidth, srcHeight, targetWidth, targetHeight); + + opts.allocatorType = AllocatorType::DEFAULT; + std::unique_ptr pixelMap3 = PixelMap::Create(opts); + ASSERT_NE(pixelMap3.get(), nullptr); + ret = postProc.CenterDisplay(*(pixelMap3.get()), srcWidth, srcHeight, targetWidth, targetHeight); ASSERT_EQ(ret, true); GTEST_LOG_(INFO) << "PostProcTest: CenterDisplayTest001 end"; } -- Gitee