diff --git a/frameworks/innerkitsimpl/test/unittest/image_format_convert_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_format_convert_test.cpp index bac1991d31175111555879dd26e0957a93d55f82..eba19668fcd8054def4e126e052f7bef88ad469e 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_format_convert_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_format_convert_test.cpp @@ -1359,28 +1359,6 @@ HWTEST_F(ImageFormatConvertTest, NV21P010ToRGBAF16_003, TestSize.Level1) GTEST_LOG_(INFO) << "ImageFormatConvertTest: NV21P010ToRGBAF16_003 end"; } -HWTEST_F(ImageFormatConvertTest, NV12P010ToRGBA_1010102_004, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "ImageFormatConvertTest: NV12P010ToRGBA_1010102_004 start"; - PixelFormat srcFormat = PixelFormat::YCBCR_P010; - PixelFormat destFormat = PixelFormat::RGBA_1010102; - Size srcSize = { P010_ORIGINAL_WIDTH, P010_ORIGINAL_HEIGHT }; - uint32_t destBuffersize = srcSize.width * srcSize.height * BYTES_PER_PIXEL_RGBA; - YuvP010ConvertToRgb(srcFormat, destFormat, srcSize, destBuffersize); - GTEST_LOG_(INFO) << "ImageFormatConvertTest: NV12P010ToRGBA_1010102_004 end"; -} - -HWTEST_F(ImageFormatConvertTest, NV21P010ToRGBA_1010102_004, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "ImageFormatConvertTest: NV21P010ToRGBA_1010102_004 start"; - PixelFormat srcFormat = PixelFormat::YCRCB_P010; - PixelFormat destFormat = PixelFormat::RGBA_1010102; - Size srcSize = { P010_ORIGINAL_WIDTH, P010_ORIGINAL_HEIGHT }; - uint32_t destBuffersize = srcSize.width * srcSize.height * BYTES_PER_PIXEL_RGBA; - YuvP010ConvertToRgb(srcFormat, destFormat, srcSize, destBuffersize); - GTEST_LOG_(INFO) << "ImageFormatConvertTest: NV21P010ToRGBA_1010102_004 end"; -} - HWTEST_F(ImageFormatConvertTest, RGB565ToNV12P010_001, TestSize.Level3) { GTEST_LOG_(INFO) << "ImageFormatConvertTest.RGB565ToNV12P010_001: start"; @@ -1820,36 +1798,6 @@ HWTEST_F(ImageFormatConvertTest, ConvertImageFormat_Test_004, TestSize.Level1) GTEST_LOG_(INFO) << "ImageFormatConvertTest: ConvertImageFormat_Test_004 end"; } -HWTEST_F(ImageFormatConvertTest, ConvertImageFormat_Test_005, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "ImageFormatConvertTest: ConvertImageFormat_Test_005 start"; - ConvertDataInfo srcDataInfo; - DestConvertInfo destInfo; - srcDataInfo.buffer = nullptr; - uint32_t ret = ImageFormatConvert::ConvertImageFormat(srcDataInfo, destInfo); - EXPECT_EQ(ret, ERR_IMAGE_INVALID_PARAMETER); - uint8_t data = 0; - srcDataInfo.buffer = &data; - srcDataInfo.pixelFormat = PixelFormat::ARGB_8888; - srcDataInfo.imageSize = {1, 1}; - srcDataInfo.bufferSize = 4; - destInfo.format = PixelFormat::UNKNOWN; - destInfo.width = srcDataInfo.imageSize.width; - destInfo.height = srcDataInfo.imageSize.height; - ret = ImageFormatConvert::ConvertImageFormat(srcDataInfo, destInfo); - EXPECT_EQ(ret, ERR_IMAGE_INVALID_PARAMETER); - srcDataInfo.pixelFormat = PixelFormat::UNKNOWN; - destInfo.format = PixelFormat::ARGB_8888; - ret = ImageFormatConvert::ConvertImageFormat(srcDataInfo, destInfo); - EXPECT_EQ(ret, ERR_IMAGE_INVALID_PARAMETER); - srcDataInfo.pixelFormat = PixelFormat::RGB_565; - destInfo.format = PixelFormat::NV21; - srcDataInfo.bufferSize = 2; - ret = ImageFormatConvert::ConvertImageFormat(srcDataInfo, destInfo); - EXPECT_EQ(ret, SUCCESS); - GTEST_LOG_(INFO) << "ImageFormatConvertTest: ConvertImageFormat_Test_005 end"; -} - HWTEST_F(ImageFormatConvertTest, PixelMapFormatConvert_001, TestSize.Level1) { GTEST_LOG_(INFO) << "ImageFormatConvertTest: PixelMapFormatConvert_001 start"; diff --git a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_jpeg_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_jpeg_test.cpp index 208bf75e6c768f56cfa9767026f9f4db554cd307..1c07d7affabcae0803705cefef189c1ca9fcce79 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_jpeg_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_jpeg_test.cpp @@ -61,7 +61,6 @@ static const std::string IMAGE_OUTPUT_JPEG_MULTI_ONETIME2_PATH = "/data/test/tes static const std::string IMAGE_HW_EXIF_PATH = "/data/local/tmp/image/test_jpeg_readmetadata004.jpg"; static const std::string IMAGE_NO_EXIF_PATH = "/data/local/tmp/image/hasNoExif.jpg"; static const std::string IMAGE_HW_MNOTE_FOCUS_MODE_EXIF_AUTO_PATH = "/data/local/tmp/image/focus_mode_exif_auto.jpg"; -static const std::string IMAGE_HW_MNOTE_FOCUS_MODE_EXIF_AF_S_PATH = "/data/local/tmp/image/focus_mode_exif_af_s.jpg"; static const std::string IMAGE_HW_MNOTE_FOCUS_MODE_EXIF_AF_C_PATH = "/data/local/tmp/image/focus_mode_exif_af_c.jpg"; static const std::string IMAGE_HW_MNOTE_FOCUS_MODE_EXIF_AF_MF_PATH = "/data/local/tmp/image/focus_mode_exif_af_mf.jpg"; @@ -2280,27 +2279,6 @@ HWTEST_F(ImageSourceJpegTest, GetImagePropertyStringTest0054, TestSize.Level3) ASSERT_EQ(value, "Auto"); } -/** - * @tc.name: GetImagePropertyStringTest0055 - * @tc.desc: get HwMnoteFocusModeExif AF_S test - * @tc.type: FUNC - */ -HWTEST_F(ImageSourceJpegTest, GetImagePropertyStringTest0055, TestSize.Level3) -{ - uint32_t errorCode = 0; - SourceOptions opts; - std::unique_ptr imageSource = - ImageSource::CreateImageSource(IMAGE_HW_MNOTE_FOCUS_MODE_EXIF_AF_S_PATH, opts, errorCode); - ASSERT_EQ(errorCode, SUCCESS); - - uint32_t index = 0; - std::string value = "0"; - std::string key = "HwMnoteFocusModeExif"; - uint32_t res = imageSource->GetImagePropertyString(index, key, value); - ASSERT_EQ(res, SUCCESS); - ASSERT_EQ(value, "AF_S"); -} - /** * @tc.name: GetImagePropertyStringTest0056 * @tc.desc: get HwMnoteFocusModeExif AF_C test diff --git a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_raw_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_raw_test.cpp index 69f8e3f653221b287307034f0a31e3e0f3016f77..62de6d91a721be94a2abe3896f09a60aca17ea71 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_raw_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_raw_test.cpp @@ -30,7 +30,6 @@ using namespace OHOS::Media; namespace OHOS { namespace Multimedia { static const std::string IMAGE_INPUT_DNG_PATH = "/data/local/tmp/image/test.dng"; -static const std::string IMAGE_INPUT_DNG_WITH_JPG_PREVIEW_PATH = "/data/local/tmp/image/dng_with_jpg.dng"; static const std::string IMAGE_INPUT_RAW_PATH = "/data/local/tmp/image/raw1.dng"; static const std::string IMAGE_OUTPUT_DNG_FILE_PATH = "/data/test/test_raw_file.jpg"; @@ -555,361 +554,5 @@ HWTEST_F(ImageSourceRawTest, RawGetEncodedFormat001, TestSize.Level3) EXPECT_EQ(imageinfo2.encodedFormat.empty(), false); GTEST_LOG_(INFO) << "ImageSourceRawTest: RawGetEncodedFormat001 imageinfo2: " << imageinfo2.encodedFormat; } - -/** - * @tc.name: DngImageDecode001 - * @tc.desc: Decode dng image with jpg from file source stream(default:RGBA_8888) - * @tc.type: FUNC - */ -HWTEST_F(ImageSourceRawTest, DngImageDecode001, TestSize.Level3) -{ - /** - * @tc.steps: step1. create image source by correct raw file path and format hit. - * @tc.expected: step1. create image source success. - */ - uint32_t errorCode = 0; - SourceOptions opts; - opts.formatHint = "image/x-raw"; - std::unique_ptr imageSource = ImageSource::CreateImageSource(IMAGE_INPUT_DNG_WITH_JPG_PREVIEW_PATH, - opts, errorCode); - ASSERT_EQ(errorCode, SUCCESS); - ASSERT_NE(imageSource.get(), nullptr); - /** - * @tc.steps: step2. decode image source to pixel map by default decode options(RGBA_8888). - * @tc.expected: step2. decode image source to pixel map success. - */ - DecodeOptions decodeOpts; - std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); - ASSERT_EQ(errorCode, SUCCESS); - ASSERT_NE(pixelMap, nullptr); - ASSERT_NE(pixelMap.get(), nullptr); - ASSERT_EQ(pixelMap->GetAlphaType(), AlphaType::IMAGE_ALPHA_TYPE_PREMUL); - /** - * @tc.steps: step3. compress the pixel map to jpeg file. - * @tc.expected: step3. pack pixel map success and compare the jpeg compress file size. - */ - int64_t packSize = OHOS::ImageSourceUtil::PackImage(IMAGE_OUTPUT_DNG_FILE_PATH, std::move(pixelMap)); - ASSERT_NE(packSize, 0); -} - -/** - * @tc.name: DngImageDecode002 - * @tc.desc: Decode dng image with jpg from file source stream(BGRA_8888) - * @tc.type: FUNC - */ -HWTEST_F(ImageSourceRawTest, DngImageDecode002, TestSize.Level3) -{ - /** - * @tc.steps: step1. create image source by correct file path and format hit. - * @tc.expected: step1. create image source success. - */ - uint32_t errorCode = 0; - SourceOptions opts; - opts.formatHint = "image/raw"; - std::unique_ptr imageSource = ImageSource::CreateImageSource(IMAGE_INPUT_DNG_WITH_JPG_PREVIEW_PATH, - opts, errorCode); - ASSERT_EQ(errorCode, SUCCESS); - ASSERT_NE(imageSource.get(), nullptr); - /** - * @tc.steps: step2. decode image source to pixel map using pixel format BGRA_8888. - * @tc.expected: step2. decode image source to pixel map success. - */ - DecodeOptions decodeOpts; - decodeOpts.desiredPixelFormat = PixelFormat::BGRA_8888; - std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); - ASSERT_EQ(errorCode, SUCCESS); - ASSERT_NE(pixelMap, nullptr); - ASSERT_NE(pixelMap.get(), nullptr); - ASSERT_EQ(pixelMap->GetAlphaType(), AlphaType::IMAGE_ALPHA_TYPE_PREMUL); - /** - * @tc.steps: step3. compress the pixel map to jpeg file. - * @tc.expected: step3. pack pixel map success and compare the jpeg compress file size. - */ - int64_t packSize = OHOS::ImageSourceUtil::PackImage(IMAGE_OUTPUT_DNG_FILE_PATH, std::move(pixelMap)); - ASSERT_NE(packSize, 0); -} - -/** - * @tc.name: DngImageDecode003 - * @tc.desc: Decode dng image with jpg from file source stream(RGB_565) - * @tc.type: FUNC - */ -HWTEST_F(ImageSourceRawTest, DngImageDecode003, TestSize.Level3) -{ - /** - * @tc.steps: step1. create image source by correct file path. - * @tc.expected: step1. create image source success. - */ - uint32_t errorCode = 0; - SourceOptions opts; - opts.formatHint = "image/x-raw"; - std::unique_ptr imageSource = ImageSource::CreateImageSource(IMAGE_INPUT_DNG_WITH_JPG_PREVIEW_PATH, - opts, errorCode); - ASSERT_EQ(errorCode, SUCCESS); - ASSERT_NE(imageSource.get(), nullptr); - /** - * @tc.steps: step2. decode image source to pixel map using pixel format RGB_565. - * @tc.expected: step2. decode image source to pixel map success. - */ - DecodeOptions decodeOpts; - decodeOpts.desiredPixelFormat = PixelFormat::RGB_565; - std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); - ASSERT_EQ(errorCode, SUCCESS); - ASSERT_NE(pixelMap.get(), nullptr); - ASSERT_EQ(pixelMap->GetAlphaType(), AlphaType::IMAGE_ALPHA_TYPE_PREMUL); -} - -/** - * @tc.name: DngImageDecode004 - * @tc.desc: Decode Dng image with jpg from file source stream(ARGB_8888) - * @tc.type: FUNC - */ -HWTEST_F(ImageSourceRawTest, DngImageDecode004, TestSize.Level3) -{ - /** - * @tc.steps: step1. create image source by correct file path and format hit. - * @tc.expected: step1. create image source success. - */ - uint32_t errorCode = 0; - SourceOptions opts; - opts.formatHint = "image/raw"; - std::unique_ptr imageSource = ImageSource::CreateImageSource(IMAGE_INPUT_DNG_WITH_JPG_PREVIEW_PATH, - opts, errorCode); - ASSERT_EQ(errorCode, SUCCESS); - ASSERT_NE(imageSource.get(), nullptr); - /** - * @tc.steps: step2. decode image source to pixel map using pixel format BGRA_8888. - * @tc.expected: step2. decode image source to pixel map success. - */ - DecodeOptions decodeOpts; - decodeOpts.desiredPixelFormat = PixelFormat::BGRA_8888; - std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); - ASSERT_EQ(errorCode, SUCCESS); - ASSERT_NE(pixelMap, nullptr); - ASSERT_NE(pixelMap.get(), nullptr); - ASSERT_EQ(pixelMap->GetAlphaType(), AlphaType::IMAGE_ALPHA_TYPE_PREMUL); - /** - * @tc.steps: step3. compress the pixel map to jpeg file. - * @tc.expected: step3. pack pixel map success and compare the jpeg compress file size. - */ - int64_t packSize = OHOS::ImageSourceUtil::PackImage(IMAGE_OUTPUT_DNG_FILE_PATH, std::move(pixelMap)); - ASSERT_NE(packSize, 0); -} - -/** - * @tc.name: DngImageDecode005 - * @tc.desc: Create dng source by correct file path and default format hit. - * @tc.type: FUNC - */ -HWTEST_F(ImageSourceRawTest, DngImageDecode005, TestSize.Level3) -{ - /** - * @tc.steps: step1. create image source by correct file path and default format hit. - * @tc.expected: step1. create image source success. - */ - uint32_t errorCode = 0; - SourceOptions opts; - std::unique_ptr imageSource = ImageSource::CreateImageSource(IMAGE_INPUT_DNG_WITH_JPG_PREVIEW_PATH, - opts, errorCode); - ASSERT_EQ(errorCode, SUCCESS); - ASSERT_NE(imageSource.get(), nullptr); - /** - * @tc.steps: step2. get image info from input image. - * @tc.expected: step2. get image info success. - */ - ImageInfo imageInfo; - uint32_t ret = imageSource->GetImageInfo(0, imageInfo); - ASSERT_EQ(ret, SUCCESS); - ret = imageSource->GetImageInfo(imageInfo); - ASSERT_EQ(imageInfo.size.width, 4032); - ASSERT_EQ(imageInfo.size.height, 3024); -} - -/** - * @tc.name: DngImageDecode006 - * @tc.desc: Create image source by correct dng file path and wrong format hit. - * @tc.type: FUNC - */ -HWTEST_F(ImageSourceRawTest, DngImageDecode006, TestSize.Level3) -{ - /** - * @tc.steps: step1. create image source by correct file path and wrong format hit. - * @tc.expected: step1. create image source success. - */ - uint32_t errorCode = 0; - SourceOptions opts; - opts.formatHint = "image/png"; - std::unique_ptr imageSource = ImageSource::CreateImageSource(IMAGE_INPUT_DNG_WITH_JPG_PREVIEW_PATH, - opts, errorCode); - ASSERT_EQ(errorCode, SUCCESS); - ASSERT_NE(imageSource.get(), nullptr); -} - -/** - * @tc.name: DngImageDecode007 - * @tc.desc: Decode dng image from buffer source stream - * @tc.type: FUNC - */ -HWTEST_F(ImageSourceRawTest, DngImageDecode007, TestSize.Level3) -{ - /** - * @tc.steps: step1. create image source by buffer source stream and default format hit - * @tc.expected: step1. create image source success. - */ - size_t bufferSize = 0; - bool ret = ImageUtils::GetFileSize(IMAGE_INPUT_DNG_WITH_JPG_PREVIEW_PATH, bufferSize); - ASSERT_EQ(ret, true); - auto *buffer = reinterpret_cast(malloc(bufferSize)); - ASSERT_NE(buffer, nullptr); - ret = OHOS::ImageSourceUtil::ReadFileToBuffer(IMAGE_INPUT_DNG_WITH_JPG_PREVIEW_PATH, buffer, bufferSize); - ASSERT_EQ(ret, true); - uint32_t errorCode = 0; - SourceOptions opts; - std::unique_ptr imageSource = ImageSource::CreateImageSource(buffer, bufferSize, opts, errorCode); - ASSERT_EQ(errorCode, SUCCESS); - ASSERT_NE(imageSource.get(), nullptr); - /** - * @tc.steps: step2. decode image source to pixel map by default decode options - * @tc.expected: step2. decode image source to pixel map success. - */ - DecodeOptions decodeOpts; - std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); - ASSERT_EQ(errorCode, SUCCESS); - ASSERT_NE(pixelMap.get(), nullptr); - - ImageInfo imageInfo; - pixelMap->GetImageInfo(imageInfo); - decodeOpts.CropRect = { imageInfo.size.width - 1, imageInfo.size.height - 1, 1, 1 }; - std::unique_ptr cropPixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); - ASSERT_NE(pixelMap, nullptr); - ASSERT_NE(pixelMap.get(), nullptr); - cropPixelMap->GetImageInfo(imageInfo); - ASSERT_EQ(imageInfo.size.width, 1); - ASSERT_EQ(imageInfo.size.height, 1); - /** - * @tc.steps: step3. compress the pixel map to jpeg file. - * @tc.expected: step3. pack pixel map success and compare the jpeg compress file size. - */ - ImagePacker imagePacker; - int64_t packSize = OHOS::ImageSourceUtil::PackImage(IMAGE_OUTPUT_DNG_FILE_PATH, std::move(pixelMap)); - ASSERT_NE(packSize, 0); - free(buffer); -} - -/** - * @tc.name: DngImageDecode008 - * @tc.desc: Decode dng image from istream source stream - * @tc.type: FUNC - */ -HWTEST_F(ImageSourceRawTest, DngImageDecode008, TestSize.Level3) -{ - /** - * @tc.steps: step1. create image source by istream source stream and default format hit - * @tc.expected: step1. create image source success. - */ - std::unique_ptr fs = std::make_unique(); - fs->open(IMAGE_INPUT_DNG_WITH_JPG_PREVIEW_PATH, std::fstream::binary | std::fstream::in); - bool isOpen = fs->is_open(); - ASSERT_EQ(isOpen, true); - uint32_t errorCode = 0; - SourceOptions opts; - std::unique_ptr imageSource = ImageSource::CreateImageSource(std::move(fs), opts, errorCode); - ASSERT_EQ(errorCode, SUCCESS); - ASSERT_NE(imageSource.get(), nullptr); - /** - * @tc.steps: step2. decode image source to pixel map by default decode options - * @tc.expected: step2. decode image source to pixel map success. - */ - DecodeOptions decodeOpts; - std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); - ASSERT_EQ(errorCode, SUCCESS); - ASSERT_NE(pixelMap, nullptr); - ASSERT_NE(pixelMap.get(), nullptr); - /** - * @tc.steps: step3. compress the pixel map to jpeg file. - * @tc.expected: step3. pack pixel map success and the jpeg compress file size. - */ - int64_t packSize = OHOS::ImageSourceUtil::PackImage(IMAGE_OUTPUT_DNG_FILE_PATH, std::move(pixelMap)); - ASSERT_NE(packSize, 0); -} - -/** - * @tc.name: DngImageDecode009 - * @tc.desc: Decode raw image multiple times from one imageSource - * @tc.type: FUNC - */ -HWTEST_F(ImageSourceRawTest, DngImageDecode009, TestSize.Level3) -{ - /** - * @tc.steps: step1. create image source by file path. - * @tc.expected: step1. create image source success. - */ - uint32_t errorCode = 0; - SourceOptions opts; - std::unique_ptr imageSource = ImageSource::CreateImageSource(IMAGE_INPUT_DNG_WITH_JPG_PREVIEW_PATH, - opts, errorCode); - ASSERT_EQ(errorCode, SUCCESS); - ASSERT_NE(imageSource.get(), nullptr); - /** - * @tc.steps: step2. decode image source to pixel map by default decode options. - * @tc.expected: step2. decode image source to pixel map success. - */ - DecodeOptions decodeOpts; - std::unique_ptr pixelMap1 = imageSource->CreatePixelMap(decodeOpts, errorCode); - ASSERT_EQ(errorCode, SUCCESS); - ASSERT_NE(pixelMap1, nullptr); - ASSERT_NE(pixelMap1.get(), nullptr); - /** - * @tc.steps: step3. decode image source to pixel map by default decode options again. - * @tc.expected: step3. decode image source to pixel map success. - */ - std::unique_ptr pixelMap2 = imageSource->CreatePixelMap(decodeOpts, errorCode); - ASSERT_EQ(errorCode, SUCCESS); - ASSERT_NE(pixelMap2, nullptr); - ASSERT_NE(pixelMap2.get(), nullptr); - /** - * @tc.steps: step4. compress the pixel map to jpeg file. - * @tc.expected: step4. pack pixel map success and compare the jpeg compress file size. - */ - int64_t packSize = OHOS::ImageSourceUtil::PackImage(IMAGE_OUTPUT_DNG_FILE_PATH, std::move(pixelMap1)); - ASSERT_NE(packSize, 0); - packSize = OHOS::ImageSourceUtil::PackImage(IMAGE_OUTPUT_DNG_FILE_PATH, std::move(pixelMap2)); - ASSERT_NE(packSize, 0); -} - -/** - * @tc.name: DngImageDecode010 - * @tc.desc: Decode wrong raw image from one imageSource - * @tc.type: FUNC - */ -HWTEST_F(ImageSourceRawTest, DngImageDecode010, TestSize.Level3) -{ - /** - * @tc.steps: step1. create image source by buffer source stream and default format hit, modify data buffer to wrong - * format. - * @tc.expected: step1. create image source success. - */ - size_t bufferSize = 0; - bool ret = ImageUtils::GetFileSize(IMAGE_INPUT_DNG_WITH_JPG_PREVIEW_PATH, bufferSize); - ASSERT_EQ(ret, true); - auto *buffer = reinterpret_cast(malloc(bufferSize)); - ASSERT_NE(buffer, nullptr); - ret = OHOS::ImageSourceUtil::ReadFileToBuffer(IMAGE_INPUT_DNG_WITH_JPG_PREVIEW_PATH, buffer, bufferSize); - ASSERT_EQ(ret, true); - buffer[bufferSize] = 43; - uint32_t errorCode = 0; - SourceOptions opts; - std::unique_ptr imageSource = ImageSource::CreateImageSource(buffer, bufferSize, opts, errorCode); - ASSERT_EQ(errorCode, SUCCESS); - ASSERT_NE(imageSource.get(), nullptr); - /** - * @tc.steps: step2. decode image source to pixel map by default decode options - * @tc.expected: step2. decode image source to pixel map failed, because format error. - */ - DecodeOptions decodeOpts; - std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); - ASSERT_EQ(errorCode, SUCCESS); - ASSERT_NE(pixelMap.get(), nullptr); -} } // namespace Multimedia } // namespace OHOS diff --git a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_test.cpp index 7dbdb8c908bc3399b8572f156516d7935a59e5c2..c88743eca1460e2d1b9e68829fcd7760a0a00899 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_test.cpp @@ -56,7 +56,6 @@ static const std::string IMAGE_INPUT_JPEG_BROKEN_TWO = "/data/local/tmp/image/te static const std::string IMAGE_URL_PREFIX = "data:image/"; static const std::string IMAGE_INPUT_JPG_PATH_EXACTSIZE = "/data/local/tmp/image/800-500.jpg"; static const std::string IMAGE_JPG_THREE_GAINMAP_HDR_PATH = "/data/local/tmp/image/three_gainmap_hdr.jpg"; -static const std::string IMAGE_HEIC_THREE_GAINMAP_HDR_PATH = "/data/local/tmp/image/three_gainmap_hdr.heic"; static const int32_t DEFAULT_DMA_SIZE = 512 * 512; static const int32_t NUM_1_MINUS = -1; static const int32_t IMAGE_INPUT_JPG_WIDTH = 800; @@ -3172,31 +3171,5 @@ HWTEST_F(ImageSourceTest, WideGamutTest002, TestSize.Level3) Media::PixelFormat pixelFormat = pixelMap->GetPixelFormat(); ASSERT_EQ(pixelFormat, Media::PixelFormat::RGBA_1010102); } - -/** - * @tc.name: WideGamutTest001 - * @tc.desc: test WideGamut one channel gainmap Jpeg HDR input - * @tc.type: FUNC - */ -HWTEST_F(ImageSourceTest, WideGamutTest003, TestSize.Level3) -{ - uint32_t errorCode = 0; - SourceOptions opts; - opts.formatHint = "image/heif"; - std::unique_ptr imageSource = ImageSource::CreateImageSource(IMAGE_HEIC_THREE_GAINMAP_HDR_PATH, - opts, errorCode); - ASSERT_EQ(errorCode, SUCCESS); - ASSERT_NE(imageSource.get(), nullptr); - uint32_t index = 0; - DecodeOptions decodeOpts; - decodeOpts.isCreateWideGamutSdrPixelMap = true; - decodeOpts.desiredDynamicRange = Media::DecodeDynamicRange::AUTO; - std::unique_ptr pixelMap = imageSource->CreatePixelMap(index, decodeOpts, errorCode); - ASSERT_EQ(errorCode, SUCCESS); - bool isHdr = pixelMap->IsHdr(); - ASSERT_EQ(isHdr, true); - Media::PixelFormat pixelFormat = pixelMap->GetPixelFormat(); - ASSERT_EQ(pixelFormat, Media::PixelFormat::RGBA_1010102); -} } // namespace Multimedia } // namespace OHOS \ No newline at end of file diff --git a/frameworks/innerkitsimpl/test/unittest/image_utils_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_utils_test.cpp index 3f7229a402f7757d682b1ef314101af01854c81f..3368b0c80a3133fa235227e51521f10cd78e3b06 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_utils_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_utils_test.cpp @@ -749,108 +749,5 @@ HWTEST_F(ImageUtilsTest, CheckMulOverflowTest012, TestSize.Level3) res = ImageUtils::CheckMulOverflow(INT32_MAX, mockHeight, INT32_MAX); EXPECT_FALSE(res); } - -/** - * @tc.name: IsValidAuxiliaryInfoTest001 - * @tc.desc: Test ImageUtils::IsValidAuxiliaryInfo() with JPEG image. - * Verify auxiliary info validation against decoded PixelMap. - * @tc.type: FUNC - */ -HWTEST_F(ImageUtilsTest, IsValidAuxiliaryInfoTest001, TestSize.Level3) -{ - uint32_t errorCode = -1; - SourceOptions opts; - std::unique_ptr imageSource = - ImageSource::CreateImageSource(IMAGE_JPEG_PATH.c_str(), opts, errorCode); - ASSERT_EQ(errorCode, OHOS::Media::SUCCESS); - ASSERT_NE(imageSource.get(), nullptr); - - DecodeOptions dstOpts; - std::shared_ptr pixelMap = imageSource->CreatePixelMapEx(0, dstOpts, errorCode); - ASSERT_EQ(errorCode, OHOS::Media::SUCCESS); - ASSERT_NE(pixelMap, nullptr); - AuxiliaryPictureInfo auxiliaryPictureInfo; - ImageInfo info; - pixelMap->GetImageInfo(info); - auxiliaryPictureInfo.size = info.size; - auxiliaryPictureInfo.pixelFormat = info.pixelFormat; - bool ret = ImageUtils::IsValidAuxiliaryInfo(pixelMap, auxiliaryPictureInfo); - EXPECT_TRUE(ret); -} - -/** - * @tc.name: GetByteCountTest001 - * @tc.desc: Test ImageUtils::GetByteCount() with default format. - * Verify correct byte count after JPEG decoding. - * @tc.type: FUNC - */ -HWTEST_F(ImageUtilsTest, GetByteCountTest001, TestSize.Level3) -{ - uint32_t errorCode = -1; - SourceOptions opts; - std::unique_ptr imageSource = - ImageSource::CreateImageSource(IMAGE_JPEG_PATH.c_str(), opts, errorCode); - ASSERT_EQ(errorCode, OHOS::Media::SUCCESS); - ASSERT_NE(imageSource.get(), nullptr); - - DecodeOptions dstOpts; - std::shared_ptr pixelMap = imageSource->CreatePixelMapEx(0, dstOpts, errorCode); - ASSERT_EQ(errorCode, OHOS::Media::SUCCESS); - ASSERT_NE(pixelMap, nullptr); - ImageInfo info; - pixelMap->GetImageInfo(info); - int32_t ret = ImageUtils::GetByteCount(info); - EXPECT_GT(ret, 0); -} - -/** - * @tc.name: GetYUVByteCountTest001 - * @tc.desc: Test ImageUtils::GetYUVByteCount() with NV21 format. - * Verify correct YUV byte count after decoding JPEG to PixelMap. - * @tc.type: FUNC - */ -HWTEST_F(ImageUtilsTest, GetYUVByteCountTest001, TestSize.Level3) -{ - uint32_t errorCode = -1; - SourceOptions opts; - std::unique_ptr imageSource = - ImageSource::CreateImageSource(IMAGE_JPEG_PATH.c_str(), opts, errorCode); - ASSERT_EQ(errorCode, OHOS::Media::SUCCESS); - ASSERT_NE(imageSource.get(), nullptr); - - DecodeOptions dstOpts; - dstOpts.desiredPixelFormat = PixelFormat::NV21; - std::shared_ptr pixelMap = imageSource->CreatePixelMapEx(0, dstOpts, errorCode); - ASSERT_EQ(errorCode, OHOS::Media::SUCCESS); - ASSERT_NE(pixelMap, nullptr); - ImageInfo info; - pixelMap->GetImageInfo(info); - int32_t ret = ImageUtils::GetYUVByteCount(info); - EXPECT_GT(ret, 0); -} - -/** - * @tc.name: DumpPixelMapTest001 - * @tc.desc: Test ImageUtils::DumpPixelMap(). - * Judge whether the input parameters of the function have changed - * @tc.type: FUNC - */ -HWTEST_F(ImageUtilsTest, DumpPixelMapTest001, TestSize.Level3) -{ - GTEST_LOG_(INFO) << "ImageUtilsTest: DumpPixelMapTest001 start"; - uint32_t errorCode = -1; - SourceOptions opts; - std::unique_ptr imageSource = - ImageSource::CreateImageSource(IMAGE_JPEG_PATH.c_str(), opts, errorCode); - ASSERT_EQ(errorCode, OHOS::Media::SUCCESS); - ASSERT_NE(imageSource.get(), nullptr); - - DecodeOptions dstOpts; - std::shared_ptr pixelMap = imageSource->CreatePixelMapEx(0, dstOpts, errorCode); - std::string customFileName = "test"; - uint64_t imageId = 0; - Media::ImageUtils::DumpPixelMap(pixelMap.get(), customFileName, imageId); - GTEST_LOG_(INFO) << "ImageUtilsTest: DumpPixelMapTest001 end"; -} } } \ No newline at end of file diff --git a/frameworks/innerkitsimpl/test/unittest/picture_test/picture_test.cpp b/frameworks/innerkitsimpl/test/unittest/picture_test/picture_test.cpp index 0fa34067ee505100b2dae2c3363151615ec5d72a..eb608bc53814943943048e1c942c2e8a37526edb 100644 --- a/frameworks/innerkitsimpl/test/unittest/picture_test/picture_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/picture_test/picture_test.cpp @@ -681,20 +681,6 @@ HWTEST_F(PictureTest, CreateExifMetadataTest001, TestSize.Level2) GTEST_LOG_(INFO) << "PictureTest: CreateExifMetadataTest001 end"; } -/** - * @tc.name: SetExifMetadataByExifMetadataTest001 - * @tc.desc: Set nullptr to picture exifMetadata_. - * @tc.type: FUNC - */ -HWTEST_F(PictureTest, SetExifMetadataByExifMetadataTest001, TestSize.Level2) -{ - std::shared_ptr exifMetadata = nullptr; - std::unique_ptr picture = CreatePicture(); - ASSERT_NE(picture, nullptr); - int32_t result = picture->SetExifMetadata(exifMetadata); - EXPECT_EQ(result, ERR_IMAGE_INVALID_PARAMETER); -} - /** * @tc.name: SetExifMetadataTest001 * @tc.desc: test the SetExifMetadata of Picture diff --git a/frameworks/innerkitsimpl/test/unittest/plugin_test/ext_decoder_test.cpp b/frameworks/innerkitsimpl/test/unittest/plugin_test/ext_decoder_test.cpp index 77486d05fee743e1fea5a5391a553cc9d61e25d6..38802e28448fdaa5b67b2edfadb5e83e62453286 100644 --- a/frameworks/innerkitsimpl/test/unittest/plugin_test/ext_decoder_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/plugin_test/ext_decoder_test.cpp @@ -64,7 +64,6 @@ const static string IMAGE_INPUT_JPEG_PATH = "/data/local/tmp/image/test_hw1.jpg" static const std::string IMAGE_DEST = "/data/local/tmp/image/test_encode_out.dat"; static const std::string IMAGE_HEIFHDR_SRC = "/data/local/tmp/image/test_heif_hdr.heic"; static const std::string IMAGE_JPG_THREE_GAINMAP_HDR_PATH = "/data/local/tmp/image/three_gainmap_hdr.jpg"; -static const std::string IMAGE_HEIC_THREE_GAINMAP_HDR_PATH = "/data/local/tmp/image/three_gainmap_hdr.heic"; static const std::string IMAGE_INCOMPLETE_GIF_PATH = "/data/local/tmp/image/test_broken.gif"; class ExtDecoderTest : public testing::Test { public: @@ -2201,74 +2200,6 @@ HWTEST_F(ExtDecoderTest, EncodePixelMapTest001, TestSize.Level3) EXPECT_NE(imageSourceDest, nullptr); } -/** - * @tc.name: EncodeWideGamutPixelMapAndDecodeTest001 - * @tc.desc: Test HEIF encoding from a RGBA_1010102 format PixelMap and decode to widegamut image. - * @tc.type: FUNC - */ -HWTEST_F(ExtDecoderTest, EncodeWideGamutPixelMapAndDecodeTest001, TestSize.Level3) -{ - uint32_t errorCode = 0; - SourceOptions sourceOpts; - std::unique_ptr imageSource = - ImageSource::CreateImageSource(IMAGE_HEIC_THREE_GAINMAP_HDR_PATH.c_str(), sourceOpts, errorCode); - ASSERT_NE(imageSource, nullptr); - DecodeOptions opts; - opts.desiredDynamicRange = DecodeDynamicRange::AUTO; - opts.isCreateWideGamutSdrPixelMap = true; - std::shared_ptr pixelmap = imageSource->CreatePixelMap(opts, errorCode); - ASSERT_EQ(errorCode, OHOS::Media::SUCCESS); - ASSERT_NE(pixelmap, nullptr); -#ifdef IMAGE_COLORSPACE_FLAG - auto colorSpace = pixelmap->InnerGetGrColorSpace(); - auto colorSpaceName = outColorSpace.GetColorSpaceName(); - EXPECT_EQ(colorSpace, ColorManager::colorSPaceName::DISPLAY_BT2020_SRGB); -#endif - ImagePacker packer; - PackOption option; - option.format = "image/heif"; - option.needsPackProperties = true; - option.desiredDynamicRange = EncodeDynamicRange::AUTO; - uint32_t startpc = packer.StartPacking(IMAGE_DEST, option); - ASSERT_EQ(startpc, OHOS::Media::SUCCESS); - uint32_t retAddImage = packer.AddImage(*pixelmap); - ASSERT_EQ(retAddImage, OHOS::Media::SUCCESS); - uint32_t retFinalizePacking = packer.FinalizePacking(); - ASSERT_EQ(retFinalizePacking, OHOS::Media::SUCCESS); - std::unique_ptr imageSourceDest = ImageSource::CreateImageSource(IMAGE_DEST, sourceOpts, errorCode); - EXPECT_EQ(errorCode, OHOS::Media::SUCCESS); - EXPECT_NE(imageSourceDest, nullptr); - DecodeOptions optsForDest; - optsForDest.desiredDynamicRange = DecodeDynamicRange::AUTO; - optsForDest.isCreateWideGamutSdrPixelMap = true; - std::shared_ptr pixelmapAfterPacker = imageSourceDest->CreatePixelMap(optsForDest, errorCode); -#ifdef IMAGE_COLORSPACE_FLAG - auto newColorspace = pixelmapAfterPacker->InnerGetGrColorSpace(); - auto newColorSpaceName = outColorSpace.GetColorSpaceName(); - EXPECT_EQ(colorSpace, ColorManager::colorSPaceName::DISPLAY_BT2020_SRGB); -#endif -} - -/** - * @tc.name: EncodeWideGamutPixelMapAndDecodeTest002 - * @tc.desc: Test HEIF encoding from a YCBCR_P010 format PixelMap and decode to widegamut image. - * @tc.type: FUNC - */ -HWTEST_F(ExtDecoderTest, EncodeWideGamutPixelMapAndDecodeTest002, TestSize.Level3) -{ - uint32_t errorCode = 0; - SourceOptions sourceOpts; - std::unique_ptr imageSource = - ImageSource::CreateImageSource(IMAGE_HEIC_THREE_GAINMAP_HDR_PATH.c_str(), sourceOpts, errorCode); - ASSERT_NE(imageSource, nullptr); - DecodeOptions opts; - opts.photoDesiredPixelFormat = PixelFormat::YCBCR_P010; - opts.isCreateWideGamutSdrPixelMap = true; - std::shared_ptr pixelmap = imageSource->CreatePixelMap(opts, errorCode); - ASSERT_NE(errorCode, OHOS::Media::SUCCESS); - ASSERT_EQ(pixelmap, nullptr); -} - /** * @tc.name: EncodeWideGamutPixelMapAndDecodeTest003 * @tc.desc: Test JPEG encoding from a RGBA_1010102 format PixelMap and decode to widegamut image. diff --git a/frameworks/innerkitsimpl/test/unittest/plugin_test/plugin_libjpeg_test.cpp b/frameworks/innerkitsimpl/test/unittest/plugin_test/plugin_libjpeg_test.cpp index 69fb2db2fac0a79cfc08393119c9d2f8d278c7e2..d5dd3c372a6666ac32504e331fea1905500d952b 100644 --- a/frameworks/innerkitsimpl/test/unittest/plugin_test/plugin_libjpeg_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/plugin_test/plugin_libjpeg_test.cpp @@ -39,7 +39,6 @@ constexpr uint32_t COMPONENT_NUM_BGRA = 4; constexpr uint32_t COMPONENT_NUM_RGB = 3; constexpr uint32_t COMPONENT_NUM_GRAY = 1; constexpr uint8_t COMPONENT_NUM_YUV420SP = 3; -constexpr uint8_t SAMPLE_FACTOR_TWO = 2; static constexpr uint32_t NUM_1000 = 1000; constexpr int32_t OPTS_SIZE = 16; @@ -2232,44 +2231,6 @@ HWTEST_F(PluginLibJpegTest, Jpeg_EncoderTest004, TestSize.Level3) GTEST_LOG_(INFO) << "PluginLibJpegTest: Jpeg_EncoderTest004 end"; } -/** - * @tc.name: Jpeg_EncoderTest005 - * @tc.desc: SetYuv420spExtraConfig - * @tc.type: FUNC - */ -HWTEST_F(PluginLibJpegTest, Jpeg_EncoderTest005, TestSize.Level3) -{ - GTEST_LOG_(INFO) << "PluginLibJpegTest: Jpeg_EncoderTest005 start"; - auto Jpegencoder = std::make_shared(); - Jpegencoder->encodeInfo_.comp_info = new jpeg_component_info; - Jpegencoder->SetYuv420spExtraConfig(); - ASSERT_EQ(Jpegencoder->encodeInfo_.comp_info[0].h_samp_factor, SAMPLE_FACTOR_TWO); - delete Jpegencoder->encodeInfo_.comp_info; - GTEST_LOG_(INFO) << "PluginLibJpegTest: Jpeg_EncoderTest005 end"; -} - -/** - * @tc.name: Jpeg_EncoderTest006 - * @tc.desc: Deinterweave - * @tc.type: FUNC - */ -HWTEST_F(PluginLibJpegTest, Jpeg_EncoderTest006, TestSize.Level3) -{ - GTEST_LOG_(INFO) << "PluginLibJpegTest: Jpeg_EncoderTest006 start"; - auto Jpegencoder = std::make_shared(); - Media::PixelMap pixelmap; - Jpegencoder->pixelMaps_.push_back(&pixelmap); - uint8_t *uvPlane = nullptr; - uint8_t *uPlane = nullptr; - uint8_t *vPlane = nullptr; - uint32_t curRow = 0; - uint32_t width = 0; - uint32_t height = 0; - Jpegencoder->Deinterweave(uvPlane, uPlane, vPlane, curRow, width, height); - ASSERT_EQ(pixelmap.imageInfo_.pixelFormat, PixelFormat::UNKNOWN); - GTEST_LOG_(INFO) << "PluginLibJpegTest: Jpeg_EncoderTest006 end"; -} - /** * @tc.name: PluginLibJpegTest_FinalizeEncodeTest001 * @tc.desc: Verify that JpegEncoder encodes NV12 format image using FinalizeEncode. diff --git a/test/resource/image/images/bad_mpf_offset.jpg b/test/resource/image/images/bad_mpf_offset.jpg new file mode 100644 index 0000000000000000000000000000000000000000..4d4cad7f97f53d7aaae72d95661c4cc2fb96e595 Binary files /dev/null and b/test/resource/image/images/bad_mpf_offset.jpg differ diff --git a/test/resource/image/images/test_heif.heic b/test/resource/image/images/test_heif.heic new file mode 100644 index 0000000000000000000000000000000000000000..aa6bc53e02fa7953555cd6a8dba423446d97bf67 Binary files /dev/null and b/test/resource/image/images/test_heif.heic differ diff --git a/test/resource/image/images/test_heif_hdr.heic b/test/resource/image/images/test_heif_hdr.heic new file mode 100644 index 0000000000000000000000000000000000000000..9318f3c0255586f42a72a120163d784a4ff0af99 Binary files /dev/null and b/test/resource/image/images/test_heif_hdr.heic differ diff --git a/test/resource/image/images/test_remove_exif.dng b/test/resource/image/images/test_remove_exif.dng new file mode 100644 index 0000000000000000000000000000000000000000..0ac01b93fa0830f702016dc8e30aa344430859ce Binary files /dev/null and b/test/resource/image/images/test_remove_exif.dng differ diff --git a/test/resource/image/images/three_gainmap_hdr.jpg b/test/resource/image/images/three_gainmap_hdr.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a7e7fe6da1925ba2004d4f85158840fb96c9bf1a Binary files /dev/null and b/test/resource/image/images/three_gainmap_hdr.jpg differ diff --git a/test/resource/image/ohos_test.xml b/test/resource/image/ohos_test.xml index afd187e12c4f0c38bd6e8a6f9c5b6eb7db919f03..143454a61a790e256f33cf6a1bf5108630b2f901 100644 --- a/test/resource/image/ohos_test.xml +++ b/test/resource/image/ohos_test.xml @@ -58,7 +58,6 @@