1 /* 2 * Copyright (C) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #define private public 17 #include <gtest/gtest.h> 18 #include "jpeg_decoder.h" 19 #include "image_packer.h" 20 #include "buffer_source_stream.h" 21 #include "exif_info.h" 22 #include "mock_data_stream.h" 23 24 using namespace testing::ext; 25 using namespace OHOS::Media; 26 namespace OHOS { 27 namespace ImagePlugin { 28 static constexpr size_t STREAM_SIZE = 1000; 29 const std::string BITS_PER_SAMPLE = "BitsPerSample"; 30 const std::string ORIENTATION = "Orientation"; 31 const std::string IMAGE_LENGTH = "ImageLength"; 32 const std::string IMAGE_WIDTH = "ImageWidth"; 33 const std::string GPS_LATITUDE = "GPSLatitude"; 34 const std::string GPS_LONGITUDE = "GPSLongitude"; 35 const std::string GPS_LATITUDE_REF = "GPSLatitudeRef"; 36 const std::string GPS_LONGITUDE_REF = "GPSLongitudeRef"; 37 const std::string DATE_TIME_ORIGINAL = "DateTimeOriginal"; 38 const std::string DATE_TIME_ORIGINAL_MEDIA = "DateTimeOriginalForMedia"; 39 const std::string EXPOSURE_TIME = "ExposureTime"; 40 const std::string F_NUMBER = "FNumber"; 41 const std::string ISO_SPEED_RATINGS = "ISOSpeedRatings"; 42 const std::string SCENE_TYPE = "SceneType"; 43 const std::string USER_COMMENT = "UserComment"; 44 const std::string PIXEL_X_DIMENSION = "PixelXDimension"; 45 const std::string PIXEL_Y_DIMENSION = "PixelYDimension"; 46 const std::string WHITE_BALANCE = "WhiteBalance"; 47 const std::string FOCAL_LENGTH_IN_35_MM_FILM = "FocalLengthIn35mmFilm"; 48 const std::string HW_MNOTE_CAPTURE_MODE = "HwMnoteCaptureMode"; 49 const std::string HW_MNOTE_PHYSICAL_APERTURE = "HwMnotePhysicalAperture"; 50 const std::string DATE_TIME = "DateTime"; 51 constexpr uint8_t JPG_MARKER_PREFIX = 0XFF; 52 constexpr uint8_t JPG_MARKER_RST = 0XD0; 53 constexpr uint8_t JPG_MARKER_RST0 = 0XD0; 54 constexpr uint8_t JPG_MARKER_APP = 0XE0; 55 constexpr uint8_t JPG_MARKER_APP0 = 0XE0; 56 class JpegDecoderTest : public testing::Test { 57 public: JpegDecoderTest()58 JpegDecoderTest() {} ~JpegDecoderTest()59 ~JpegDecoderTest() {} 60 }; 61 62 /** 63 * @tc.name: JpegDecoderTest001 64 * @tc.desc: Test of SetSource 65 * @tc.type: FUNC 66 */ 67 HWTEST_F(JpegDecoderTest, JpegDecoderTest001, TestSize.Level3) 68 { 69 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest001 start"; 70 auto jpegDecoder = std::make_shared<JpegDecoder>(); 71 int size = STREAM_SIZE; 72 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 73 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 74 jpegDecoder->SetSource(*streamPtr.release()); 75 bool result = (jpegDecoder != nullptr); 76 ASSERT_EQ(result, true); 77 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest001 end"; 78 } 79 80 /** 81 * @tc.name: JpegDecoderTest002 82 * @tc.desc: Test of SetDecodeOptions 83 * @tc.type: FUNC 84 */ 85 HWTEST_F(JpegDecoderTest, JpegDecoderTest002, TestSize.Level3) 86 { 87 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest002 start"; 88 auto jpegDecoder = std::make_shared<JpegDecoder>(); 89 auto mock = std::make_shared<MockInputDataStream>(); 90 mock->SetReturn(false); 91 jpegDecoder->SetSource(*mock.get()); 92 PixelDecodeOptions opts; 93 PlImageInfo info; 94 jpegDecoder->state_ = JpegDecodingState::IMAGE_DECODING; 95 uint32_t result = jpegDecoder->SetDecodeOptions(0, opts, info); 96 ASSERT_EQ(result, ERR_IMAGE_SOURCE_DATA_INCOMPLETE); 97 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest002 end"; 98 } 99 100 /** 101 * @tc.name: JpegDecoderTest003 102 * @tc.desc: Test of SetDecodeOptions 103 * @tc.type: FUNC 104 */ 105 HWTEST_F(JpegDecoderTest, JpegDecoderTest003, TestSize.Level3) 106 { 107 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest003 start"; 108 auto jpegDecoder = std::make_shared<JpegDecoder>(); 109 int size = STREAM_SIZE; 110 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 111 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 112 jpegDecoder->SetSource(*streamPtr.release()); 113 PixelDecodeOptions opts; 114 PlImageInfo info; 115 uint32_t result = jpegDecoder->SetDecodeOptions(JPEG_IMAGE_NUM, opts, info); 116 ASSERT_EQ(result, ERR_IMAGE_INVALID_PARAMETER); 117 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest003 end"; 118 } 119 120 /** 121 * @tc.name: JpegDecoderTest004 122 * @tc.desc: Test of SetDecodeOptions 123 * @tc.type: FUNC 124 */ 125 HWTEST_F(JpegDecoderTest, JpegDecoderTest004, TestSize.Level3) 126 { 127 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest004 start"; 128 auto jpegDecoder = std::make_shared<JpegDecoder>(); 129 auto mock = std::make_shared<MockInputDataStream>(); 130 mock->SetReturn(false); 131 jpegDecoder->SetSource(*mock.get()); 132 PixelDecodeOptions opts; 133 PlImageInfo info; 134 jpegDecoder->state_ = JpegDecodingState::UNDECIDED; 135 uint32_t result = jpegDecoder->SetDecodeOptions(0, opts, info); 136 ASSERT_EQ(result, ERR_MEDIA_INVALID_OPERATION); 137 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest004 end"; 138 } 139 140 /** 141 * @tc.name: JpegDecoderTest005 142 * @tc.desc: Test of GetImageSize 143 * @tc.type: FUNC 144 */ 145 HWTEST_F(JpegDecoderTest, JpegDecoderTest005, TestSize.Level3) 146 { 147 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest005 start"; 148 auto jpegDecoder = std::make_shared<JpegDecoder>(); 149 auto mock = std::make_shared<MockInputDataStream>(); 150 jpegDecoder->SetSource(*mock.get()); 151 ImagePlugin::Size plSize; 152 uint32_t result = jpegDecoder->GetImageSize(0, plSize); 153 ASSERT_EQ(result, ERR_IMAGE_SOURCE_DATA_INCOMPLETE); 154 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest005 end"; 155 } 156 157 /** 158 * @tc.name: JpegDecoderTest006 159 * @tc.desc: Test of GetImageSize 160 * @tc.type: FUNC 161 */ 162 HWTEST_F(JpegDecoderTest, JpegDecoderTest006, TestSize.Level3) 163 { 164 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest006 start"; 165 auto jpegDecoder = std::make_shared<JpegDecoder>(); 166 auto mock = std::make_shared<MockInputDataStream>(); 167 jpegDecoder->SetSource(*mock.get()); 168 ImagePlugin::Size plSize; 169 uint32_t result = jpegDecoder->GetImageSize(0, plSize); 170 ASSERT_EQ(result, ERR_IMAGE_SOURCE_DATA_INCOMPLETE); 171 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest006 end"; 172 } 173 174 /** 175 * @tc.name: JpegDecoderTest007 176 * @tc.desc: Test of GetImageSize 177 * @tc.type: FUNC 178 */ 179 HWTEST_F(JpegDecoderTest, JpegDecoderTest007, TestSize.Level3) 180 { 181 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest007 start"; 182 auto jpegDecoder = std::make_shared<JpegDecoder>(); 183 int size = STREAM_SIZE; 184 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 185 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 186 ImagePlugin::Size plSize; 187 jpegDecoder->SetSource(*streamPtr.release()); 188 uint32_t result = jpegDecoder->GetImageSize(2, plSize); 189 ASSERT_EQ(result, ERR_IMAGE_INVALID_PARAMETER); 190 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest007 end"; 191 } 192 193 /** 194 * @tc.name: JpegDecoderTest008 195 * @tc.desc: Test of GetImageSize 196 * @tc.type: FUNC 197 */ 198 HWTEST_F(JpegDecoderTest, JpegDecoderTest008, TestSize.Level3) 199 { 200 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest008 start"; 201 auto jpegDecoder = std::make_shared<JpegDecoder>(); 202 int size = STREAM_SIZE; 203 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 204 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 205 ImagePlugin::Size plSize; 206 jpegDecoder->SetSource(*streamPtr.release()); 207 // check input parameter, index = JPEG_IMAGE_NUM 208 uint32_t result = jpegDecoder->GetImageSize(JPEG_IMAGE_NUM, plSize); 209 ASSERT_EQ(result, ERR_IMAGE_INVALID_PARAMETER); 210 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest008 end"; 211 } 212 213 /** 214 * @tc.name: JpegDecoderTest009 215 * @tc.desc: Test of GetImageSize 216 * @tc.type: FUNC 217 */ 218 HWTEST_F(JpegDecoderTest, JpegDecoderTest009, TestSize.Level3) 219 { 220 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest009 start"; 221 auto jpegDecoder = std::make_shared<JpegDecoder>(); 222 auto mock = std::make_shared<MockInputDataStream>(); 223 mock->SetReturn(true); 224 jpegDecoder->SetSource(*mock.get()); 225 ImagePlugin::Size plSize; 226 jpegDecoder->state_ = JpegDecodingState::UNDECIDED; 227 uint32_t result = jpegDecoder->GetImageSize(0, plSize); 228 ASSERT_EQ(result, ERR_MEDIA_INVALID_OPERATION); 229 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest009 end"; 230 } 231 232 /** 233 * @tc.name: JpegDecoderTest0010 234 * @tc.desc: Test of GetImageSize 235 * @tc.type: FUNC 236 */ 237 HWTEST_F(JpegDecoderTest, JpegDecoderTest0010, TestSize.Level3) 238 { 239 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0010 start"; 240 auto jpegDecoder = std::make_shared<JpegDecoder>(); 241 auto mock = std::make_shared<MockInputDataStream>(); 242 mock->SetStreamSize(1); 243 mock->SetReturn(false); 244 jpegDecoder->SetSource(*mock.get()); 245 ImagePlugin::Size plSize; 246 uint32_t result = jpegDecoder->GetImageSize(0, plSize); 247 ASSERT_EQ(result, ERR_IMAGE_SOURCE_DATA_INCOMPLETE); 248 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0010 end"; 249 } 250 251 /** 252 * @tc.name: JpegDecoderTest0011 253 * @tc.desc: Test of Decode 254 * @tc.type: FUNC 255 */ 256 HWTEST_F(JpegDecoderTest, JpegDecoderTest0011, TestSize.Level3) 257 { 258 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0011 start"; 259 auto jpegDecoder = std::make_shared<JpegDecoder>(); 260 int size = STREAM_SIZE; 261 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 262 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 263 jpegDecoder->SetSource(*streamPtr.release()); 264 DecodeContext context; 265 uint32_t result = jpegDecoder->Decode(2, context); 266 ASSERT_EQ(result, ERR_IMAGE_INVALID_PARAMETER); 267 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0011 end"; 268 } 269 270 /** 271 * @tc.name: JpegDecoderTest0012 272 * @tc.desc: Test of Decode 273 * @tc.type: FUNC 274 */ 275 HWTEST_F(JpegDecoderTest, JpegDecoderTest0012, TestSize.Level3) 276 { 277 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0012 start"; 278 auto jpegDecoder = std::make_shared<JpegDecoder>(); 279 int size = STREAM_SIZE; 280 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 281 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 282 jpegDecoder->SetSource(*streamPtr.release()); 283 DecodeContext context; 284 uint32_t result = jpegDecoder->Decode(JPEG_IMAGE_NUM, context); 285 ASSERT_EQ(result, ERR_IMAGE_INVALID_PARAMETER); 286 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0012 end"; 287 } 288 289 /** 290 * @tc.name: JpegDecoderTest0013 291 * @tc.desc: Test of Decode 292 * @tc.type: FUNC 293 */ 294 HWTEST_F(JpegDecoderTest, JpegDecoderTest0013, TestSize.Level3) 295 { 296 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0013 start"; 297 auto jpegDecoder = std::make_shared<JpegDecoder>(); 298 int size = STREAM_SIZE; 299 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 300 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 301 jpegDecoder->SetSource(*streamPtr.release()); 302 DecodeContext context; 303 uint32_t result = jpegDecoder->Decode(0, context); 304 ASSERT_EQ(result, ERR_MEDIA_INVALID_OPERATION); 305 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0013 end"; 306 } 307 308 /** 309 * @tc.name: JpegDecoderTest0014 310 * @tc.desc: Test of Decode 311 * @tc.type: FUNC 312 */ 313 HWTEST_F(JpegDecoderTest, JpegDecoderTest0014, TestSize.Level3) 314 { 315 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0014 start"; 316 auto jpegDecoder = std::make_shared<JpegDecoder>(); 317 auto mock = std::make_shared<MockInputDataStream>(); 318 mock->SetReturn(false); 319 jpegDecoder->SetSource(*mock.get()); 320 DecodeContext context; 321 jpegDecoder->state_ = JpegDecodingState::IMAGE_ERROR; 322 uint32_t ret = jpegDecoder->Decode(0, context); 323 ASSERT_EQ(ret, ERR_IMAGE_SOURCE_DATA_INCOMPLETE); 324 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0014 end"; 325 } 326 327 /** 328 * @tc.name: JpegDecoderTest0015 329 * @tc.desc: Test of PromoteIncrementalDecode 330 * @tc.type: FUNC 331 */ 332 HWTEST_F(JpegDecoderTest, JpegDecoderTest0015, TestSize.Level3) 333 { 334 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0015 start"; 335 auto jpegDecoder = std::make_shared<JpegDecoder>(); 336 int size = STREAM_SIZE; 337 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 338 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 339 jpegDecoder->SetSource(*streamPtr.release()); 340 ProgDecodeContext context; 341 uint32_t result = jpegDecoder->PromoteIncrementalDecode(2, context); 342 ASSERT_EQ(result, ERR_IMAGE_INVALID_PARAMETER); 343 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0015 end"; 344 } 345 346 /** 347 * @tc.name: JpegDecoderTest0016 348 * @tc.desc: Test of PromoteIncrementalDecode 349 * @tc.type: FUNC 350 */ 351 HWTEST_F(JpegDecoderTest, JpegDecoderTest0016, TestSize.Level3) 352 { 353 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0016 start"; 354 auto jpegDecoder = std::make_shared<JpegDecoder>(); 355 int size = STREAM_SIZE; 356 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 357 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 358 jpegDecoder->SetSource(*streamPtr.release()); 359 ProgDecodeContext context; 360 uint32_t result = jpegDecoder->PromoteIncrementalDecode(JPEG_IMAGE_NUM, context); 361 ASSERT_EQ(result, ERR_IMAGE_INVALID_PARAMETER); 362 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0016 end"; 363 } 364 /** 365 * @tc.name: JpegDecoderTest0017 366 * @tc.desc: Test of PromoteIncrementalDecode 367 * @tc.type: FUNC 368 */ 369 HWTEST_F(JpegDecoderTest, JpegDecoderTest0017, TestSize.Level3) 370 { 371 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0017 start"; 372 auto jpegDecoder = std::make_shared<JpegDecoder>(); 373 auto mock = std::make_shared<MockInputDataStream>(); 374 mock->SetReturn(false); 375 jpegDecoder->SetSource(*mock.get()); 376 ProgDecodeContext context; 377 uint32_t result = jpegDecoder->PromoteIncrementalDecode(0, context); 378 ASSERT_EQ(result, ERR_MEDIA_INVALID_OPERATION); 379 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0017 end"; 380 } 381 382 /** 383 * @tc.name: JpegDecoderTest0018 384 * @tc.desc: Test of GetImagePropertyInt 385 * @tc.type: FUNC 386 */ 387 HWTEST_F(JpegDecoderTest, JpegDecoderTest0018, TestSize.Level3) 388 { 389 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0018 start"; 390 auto jpegDecoder = std::make_shared<JpegDecoder>(); 391 int size = STREAM_SIZE; 392 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 393 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 394 jpegDecoder->SetSource(*streamPtr.release()); 395 std::string key = ORIENTATION; 396 int32_t value = 0; 397 uint32_t result = jpegDecoder->GetImagePropertyInt(0, key, value); 398 ASSERT_EQ(result, ERR_MEDIA_VALUE_INVALID); 399 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0018 end"; 400 } 401 402 /** 403 * @tc.name: JpegDecoderTest0019 404 * @tc.desc: Test of GetImagePropertyInt 405 * @tc.type: FUNC 406 */ 407 HWTEST_F(JpegDecoderTest, JpegDecoderTest0019, TestSize.Level3) 408 { 409 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0019 start"; 410 auto jpegDecoder = std::make_shared<JpegDecoder>(); 411 int size = STREAM_SIZE; 412 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 413 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 414 jpegDecoder->SetSource(*streamPtr.release()); 415 std::string key = IMAGE_LENGTH; 416 int32_t value = 0; 417 uint32_t result = jpegDecoder->GetImagePropertyInt(0, key, value); 418 ASSERT_EQ(result, ERR_MEDIA_VALUE_INVALID); 419 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0019 end"; 420 } 421 422 /** 423 * @tc.name: JpegDecoderTest0020 424 * @tc.desc: Test of GetImagePropertyInt 425 * @tc.type: FUNC 426 */ 427 HWTEST_F(JpegDecoderTest, JpegDecoderTest0020, TestSize.Level3) 428 { 429 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0020 start"; 430 auto jpegDecoder = std::make_shared<JpegDecoder>(); 431 int size = STREAM_SIZE; 432 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 433 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 434 jpegDecoder->SetSource(*streamPtr.release()); 435 std::string key = ACTUAL_IMAGE_ENCODED_FORMAT; 436 int32_t value = 0; 437 uint32_t result = jpegDecoder->GetImagePropertyInt(0, key, value); 438 ASSERT_EQ(result, Media::ERR_MEDIA_VALUE_INVALID); 439 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0020 end"; 440 } 441 442 /** 443 * @tc.name: JpegDecoderTest0021 444 * @tc.desc: Test of GetImagePropertyString 445 * @tc.type: FUNC 446 */ 447 HWTEST_F(JpegDecoderTest, JpegDecoderTest0021, TestSize.Level3) 448 { 449 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0021 start"; 450 auto jpegDecoder = std::make_shared<JpegDecoder>(); 451 int size = STREAM_SIZE; 452 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 453 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 454 jpegDecoder->SetSource(*streamPtr.release()); 455 std::string key = BITS_PER_SAMPLE; 456 std::string value = ""; 457 EXIFInfo exifInfo_; 458 jpegDecoder->GetImagePropertyString(0, key, value); 459 ASSERT_EQ(value, exifInfo_.bitsPerSample_); 460 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0021 end"; 461 } 462 463 /** 464 * @tc.name: JpegDecoderTest0022 465 * @tc.desc: Test of GetImagePropertyString 466 * @tc.type: FUNC 467 */ 468 HWTEST_F(JpegDecoderTest, JpegDecoderTest0022, TestSize.Level3) 469 { 470 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0022 start"; 471 auto jpegDecoder = std::make_shared<JpegDecoder>(); 472 int size = STREAM_SIZE; 473 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 474 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 475 jpegDecoder->SetSource(*streamPtr.release()); 476 std::string key = ORIENTATION; 477 std::string value = ""; 478 EXIFInfo exifInfo_; 479 jpegDecoder->GetImagePropertyString(0, key, value); 480 ASSERT_EQ(value, exifInfo_.orientation_); 481 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0022 end"; 482 } 483 484 /** 485 * @tc.name: JpegDecoderTest0023 486 * @tc.desc: Test of GetImagePropertyString 487 * @tc.type: FUNC 488 */ 489 HWTEST_F(JpegDecoderTest, JpegDecoderTest0023, TestSize.Level3) 490 { 491 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0023 start"; 492 auto jpegDecoder = std::make_shared<JpegDecoder>(); 493 int size = STREAM_SIZE; 494 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 495 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 496 jpegDecoder->SetSource(*streamPtr.release()); 497 std::string key = IMAGE_LENGTH; 498 std::string value = ""; 499 EXIFInfo exifInfo_; 500 jpegDecoder->GetImagePropertyString(0, key, value); 501 ASSERT_EQ(value, exifInfo_.imageLength_); 502 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0023 end"; 503 } 504 505 /** 506 * @tc.name: JpegDecoderTest0024 507 * @tc.desc: Test of GetImagePropertyString 508 * @tc.type: FUNC 509 */ 510 HWTEST_F(JpegDecoderTest, JpegDecoderTest0024, TestSize.Level3) 511 { 512 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0024 start"; 513 auto jpegDecoder = std::make_shared<JpegDecoder>(); 514 int size = STREAM_SIZE; 515 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 516 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 517 jpegDecoder->SetSource(*streamPtr.release()); 518 std::string key = IMAGE_WIDTH; 519 std::string value = ""; 520 EXIFInfo exifInfo_; 521 jpegDecoder->GetImagePropertyString(0, key, value); 522 ASSERT_EQ(value, exifInfo_.imageWidth_); 523 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0024 end"; 524 } 525 526 /** 527 * @tc.name: JpegDecoderTest0025 528 * @tc.desc: Test of GetImagePropertyString 529 * @tc.type: FUNC 530 */ 531 HWTEST_F(JpegDecoderTest, JpegDecoderTest0025, TestSize.Level3) 532 { 533 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0025 start"; 534 auto jpegDecoder = std::make_shared<JpegDecoder>(); 535 int size = STREAM_SIZE; 536 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 537 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 538 jpegDecoder->SetSource(*streamPtr.release()); 539 std::string key = GPS_LATITUDE; 540 std::string value = ""; 541 EXIFInfo exifInfo_; 542 jpegDecoder->GetImagePropertyString(0, key, value); 543 ASSERT_EQ(value, exifInfo_.gpsLatitude_); 544 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0025 end"; 545 } 546 547 /** 548 * @tc.name: JpegDecoderTest0026 549 * @tc.desc: Test of GetImagePropertyString 550 * @tc.type: FUNC 551 */ 552 HWTEST_F(JpegDecoderTest, JpegDecoderTest0026, TestSize.Level3) 553 { 554 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0026 start"; 555 auto jpegDecoder = std::make_shared<JpegDecoder>(); 556 int size = STREAM_SIZE; 557 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 558 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 559 jpegDecoder->SetSource(*streamPtr.release()); 560 std::string key = GPS_LONGITUDE; 561 std::string value = ""; 562 EXIFInfo exifInfo_; 563 jpegDecoder->GetImagePropertyString(0, key, value); 564 ASSERT_EQ(value, exifInfo_.gpsLongitude_); 565 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0026 end"; 566 } 567 568 /** 569 * @tc.name: JpegDecoderTest0027 570 * @tc.desc: Test of GetImagePropertyString 571 * @tc.type: FUNC 572 */ 573 HWTEST_F(JpegDecoderTest, JpegDecoderTest0027, TestSize.Level3) 574 { 575 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0027 start"; 576 auto jpegDecoder = std::make_shared<JpegDecoder>(); 577 int size = STREAM_SIZE; 578 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 579 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 580 jpegDecoder->SetSource(*streamPtr.release()); 581 std::string key = GPS_LATITUDE_REF; 582 std::string value = ""; 583 EXIFInfo exifInfo_; 584 jpegDecoder->GetImagePropertyString(0, key, value); 585 ASSERT_EQ(value, exifInfo_.gpsLatitudeRef_); 586 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0027 end"; 587 } 588 589 590 /** 591 * @tc.name: JpegDecoderTest0028 592 * @tc.desc: Test of GetImagePropertyString 593 * @tc.type: FUNC 594 */ 595 HWTEST_F(JpegDecoderTest, JpegDecoderTest0028, TestSize.Level3) 596 { 597 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0028 start"; 598 auto jpegDecoder = std::make_shared<JpegDecoder>(); 599 int size = STREAM_SIZE; 600 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 601 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 602 jpegDecoder->SetSource(*streamPtr.release()); 603 std::string key = GPS_LONGITUDE_REF; 604 std::string value = ""; 605 EXIFInfo exifInfo_; 606 jpegDecoder->GetImagePropertyString(0, key, value); 607 ASSERT_EQ(value, exifInfo_.gpsLongitudeRef_); 608 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0028 end"; 609 } 610 611 /** 612 * @tc.name: JpegDecoderTest0029 613 * @tc.desc: Test of GetImagePropertyString 614 * @tc.type: FUNC 615 */ 616 HWTEST_F(JpegDecoderTest, JpegDecoderTest0029, TestSize.Level3) 617 { 618 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0029 start"; 619 auto jpegDecoder = std::make_shared<JpegDecoder>(); 620 int size = STREAM_SIZE; 621 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 622 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 623 jpegDecoder->SetSource(*streamPtr.release()); 624 std::string key = DATE_TIME_ORIGINAL; 625 std::string value = ""; 626 EXIFInfo exifInfo_; 627 jpegDecoder->GetImagePropertyString(0, key, value); 628 ASSERT_EQ(value, exifInfo_.dateTimeOriginal_); 629 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0029 end"; 630 } 631 632 /** 633 * @tc.name: JpegDecoderTest0030 634 * @tc.desc: Test of GetImagePropertyString 635 * @tc.type: FUNC 636 */ 637 HWTEST_F(JpegDecoderTest, JpegDecoderTest0030, TestSize.Level3) 638 { 639 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0030 start"; 640 auto jpegDecoder = std::make_shared<JpegDecoder>(); 641 int size = STREAM_SIZE; 642 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 643 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 644 jpegDecoder->SetSource(*streamPtr.release()); 645 std::string key = DATE_TIME_ORIGINAL_MEDIA; 646 std::string value = ""; 647 uint32_t ret = jpegDecoder->GetImagePropertyString(0, key, value); 648 ASSERT_EQ(ret, Media::SUCCESS); 649 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0030 end"; 650 } 651 652 /** 653 * @tc.name: JpegDecoderTest0031 654 * @tc.desc: Test of GetImagePropertyString 655 * @tc.type: FUNC 656 */ 657 HWTEST_F(JpegDecoderTest, JpegDecoderTest0031, TestSize.Level3) 658 { 659 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0031 start"; 660 auto jpegDecoder = std::make_shared<JpegDecoder>(); 661 int size = STREAM_SIZE; 662 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 663 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 664 jpegDecoder->SetSource(*streamPtr.release()); 665 std::string key = EXPOSURE_TIME; 666 std::string value = ""; 667 EXIFInfo exifInfo_; 668 jpegDecoder->GetImagePropertyString(0, key, value); 669 ASSERT_EQ(value, exifInfo_.exposureTime_); 670 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0031 end"; 671 } 672 673 /** 674 * @tc.name: JpegDecoderTest0032 675 * @tc.desc: Test of GetImagePropertyString 676 * @tc.type: FUNC 677 */ 678 HWTEST_F(JpegDecoderTest, JpegDecoderTest0032, TestSize.Level3) 679 { 680 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0032 start"; 681 auto jpegDecoder = std::make_shared<JpegDecoder>(); 682 int size = STREAM_SIZE; 683 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 684 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 685 jpegDecoder->SetSource(*streamPtr.release()); 686 std::string key = F_NUMBER; 687 std::string value = ""; 688 EXIFInfo exifInfo_; 689 jpegDecoder->GetImagePropertyString(0, key, value); 690 ASSERT_EQ(value, exifInfo_.fNumber_); 691 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0032 end"; 692 } 693 694 /** 695 * @tc.name: JpegDecoderTest0033 696 * @tc.desc: Test of GetImagePropertyString 697 * @tc.type: FUNC 698 */ 699 HWTEST_F(JpegDecoderTest, JpegDecoderTest0033, TestSize.Level3) 700 { 701 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0033 start"; 702 auto jpegDecoder = std::make_shared<JpegDecoder>(); 703 int size = STREAM_SIZE; 704 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 705 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 706 jpegDecoder->SetSource(*streamPtr.release()); 707 std::string key = ISO_SPEED_RATINGS; 708 std::string value = ""; 709 EXIFInfo exifInfo_; 710 jpegDecoder->GetImagePropertyString(0, key, value); 711 ASSERT_EQ(value, exifInfo_.isoSpeedRatings_); 712 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0033 end"; 713 } 714 715 /** 716 * @tc.name: JpegDecoderTest0034 717 * @tc.desc: Test of GetImagePropertyString 718 * @tc.type: FUNC 719 */ 720 HWTEST_F(JpegDecoderTest, JpegDecoderTest0034, TestSize.Level3) 721 { 722 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0034 start"; 723 auto jpegDecoder = std::make_shared<JpegDecoder>(); 724 int size = STREAM_SIZE; 725 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 726 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 727 jpegDecoder->SetSource(*streamPtr.release()); 728 std::string key = SCENE_TYPE; 729 std::string value = ""; 730 EXIFInfo exifInfo_; 731 jpegDecoder->GetImagePropertyString(0, key, value); 732 ASSERT_EQ(value, exifInfo_.sceneType_); 733 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0034 end"; 734 } 735 736 /** 737 * @tc.name: JpegDecoderTest0035 738 * @tc.desc: Test of GetImagePropertyString 739 * @tc.type: FUNC 740 */ 741 HWTEST_F(JpegDecoderTest, JpegDecoderTest0035, TestSize.Level3) 742 { 743 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0035 start"; 744 auto jpegDecoder = std::make_shared<JpegDecoder>(); 745 int size = STREAM_SIZE; 746 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 747 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 748 jpegDecoder->SetSource(*streamPtr.release()); 749 std::string key = ""; 750 std::string value = ""; 751 int32_t result = jpegDecoder->GetImagePropertyString(0, key, value); 752 ASSERT_EQ(result, Media::ERR_IMAGE_DECODE_EXIF_UNSUPPORT); 753 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0035 end"; 754 } 755 756 /** 757 * @tc.name: JpegDecoderTest0036 758 * @tc.desc: Test of GetImagePropertyString 759 * @tc.type: FUNC 760 */ 761 HWTEST_F(JpegDecoderTest, JpegDecoderTest0036, TestSize.Level3) 762 { 763 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0036 start"; 764 auto jpegDecoder = std::make_shared<JpegDecoder>(); 765 int size = STREAM_SIZE; 766 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 767 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 768 jpegDecoder->SetSource(*streamPtr.release()); 769 std::string key = ACTUAL_IMAGE_ENCODED_FORMAT; 770 std::string value = ""; 771 int32_t result = jpegDecoder->GetImagePropertyString(0, key, value); 772 ASSERT_EQ(result, Media::ERR_MEDIA_VALUE_INVALID); 773 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0036 end"; 774 } 775 776 777 /** 778 * @tc.name: JpegDecoderTest0037 779 * @tc.desc: Test of GetImagePropertyStringEx 780 * @tc.type: FUNC 781 */ 782 HWTEST_F(JpegDecoderTest, JpegDecoderTest0037, TestSize.Level3) 783 { 784 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0037 start"; 785 auto jpegDecoder = std::make_shared<JpegDecoder>(); 786 int size = STREAM_SIZE; 787 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 788 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 789 jpegDecoder->SetSource(*streamPtr.release()); 790 std::string key = ""; 791 std::string value = ""; 792 int32_t result = jpegDecoder->GetImagePropertyStringEx(key, value); 793 ASSERT_EQ(result, ERR_IMAGE_DECODE_EXIF_UNSUPPORT); 794 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0037 end"; 795 } 796 797 /** 798 * @tc.name: JpegDecoderTest0038 799 * @tc.desc: Test of GetImagePropertyStringEx 800 * @tc.type: FUNC 801 */ 802 HWTEST_F(JpegDecoderTest, JpegDecoderTest0038, TestSize.Level3) 803 { 804 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0038 start"; 805 auto jpegDecoder = std::make_shared<JpegDecoder>(); 806 int size = STREAM_SIZE; 807 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 808 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 809 jpegDecoder->SetSource(*streamPtr.release()); 810 std::string key = USER_COMMENT; 811 std::string value = ""; 812 EXIFInfo exifInfo_; 813 jpegDecoder->GetImagePropertyString(key, value); 814 ASSERT_EQ(value, exifInfo_.userComment_); 815 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0038 end"; 816 } 817 818 /** 819 * @tc.name: JpegDecoderTest0039 820 * @tc.desc: Test of GetImagePropertyStringEx 821 * @tc.type: FUNC 822 */ 823 HWTEST_F(JpegDecoderTest, JpegDecoderTest0039, TestSize.Level3) 824 { 825 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0039 start"; 826 auto jpegDecoder = std::make_shared<JpegDecoder>(); 827 int size = STREAM_SIZE; 828 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 829 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 830 jpegDecoder->SetSource(*streamPtr.release()); 831 std::string key = PIXEL_X_DIMENSION; 832 std::string value = ""; 833 EXIFInfo exifInfo_; 834 jpegDecoder->GetImagePropertyString(key, value); 835 ASSERT_EQ(value, exifInfo_.pixelXDimension_); 836 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0039 end"; 837 } 838 839 /** 840 * @tc.name: JpegDecoderTest0040 841 * @tc.desc: Test of GetImagePropertyStringEx 842 * @tc.type: FUNC 843 */ 844 HWTEST_F(JpegDecoderTest, JpegDecoderTest0040, TestSize.Level3) 845 { 846 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0040 start"; 847 auto jpegDecoder = std::make_shared<JpegDecoder>(); 848 int size = STREAM_SIZE; 849 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 850 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 851 jpegDecoder->SetSource(*streamPtr.release()); 852 std::string key = PIXEL_Y_DIMENSION; 853 std::string value = ""; 854 EXIFInfo exifInfo_; 855 jpegDecoder->GetImagePropertyString(key, value); 856 ASSERT_EQ(value, exifInfo_.pixelYDimension_); 857 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0040 end"; 858 } 859 860 /** 861 * @tc.name: JpegDecoderTest0041 862 * @tc.desc: Test of GetImagePropertyStringEx 863 * @tc.type: FUNC 864 */ 865 HWTEST_F(JpegDecoderTest, JpegDecoderTest0041, TestSize.Level3) 866 { 867 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0041 start"; 868 auto jpegDecoder = std::make_shared<JpegDecoder>(); 869 int size = STREAM_SIZE; 870 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 871 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 872 jpegDecoder->SetSource(*streamPtr.release()); 873 std::string key = WHITE_BALANCE; 874 std::string value = ""; 875 EXIFInfo exifInfo_; 876 jpegDecoder->GetImagePropertyString(key, value); 877 ASSERT_EQ(value, exifInfo_.whiteBalance_); 878 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0041 end"; 879 } 880 881 /** 882 * @tc.name: JpegDecoderTest0042 883 * @tc.desc: Test of GetImagePropertyStringEx 884 * @tc.type: FUNC 885 */ 886 HWTEST_F(JpegDecoderTest, JpegDecoderTest0042, TestSize.Level3) 887 { 888 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0042 start"; 889 auto jpegDecoder = std::make_shared<JpegDecoder>(); 890 int size = STREAM_SIZE; 891 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 892 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 893 jpegDecoder->SetSource(*streamPtr.release()); 894 std::string key = FOCAL_LENGTH_IN_35_MM_FILM; 895 std::string value = ""; 896 EXIFInfo exifInfo_; 897 jpegDecoder->GetImagePropertyString(key, value); 898 ASSERT_EQ(value, exifInfo_.focalLengthIn35mmFilm_); 899 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0042 end"; 900 } 901 902 /** 903 * @tc.name: JpegDecoderTest0043 904 * @tc.desc: Test of GetImagePropertyStringEx 905 * @tc.type: FUNC 906 */ 907 HWTEST_F(JpegDecoderTest, JpegDecoderTest0043, TestSize.Level3) 908 { 909 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0043 start"; 910 auto jpegDecoder = std::make_shared<JpegDecoder>(); 911 int size = STREAM_SIZE; 912 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 913 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 914 jpegDecoder->SetSource(*streamPtr.release()); 915 std::string key = HW_MNOTE_CAPTURE_MODE; 916 std::string value = ""; 917 EXIFInfo exifInfo_; 918 jpegDecoder->GetImagePropertyString(key, value); 919 ASSERT_EQ(value, exifInfo_.hwMnoteCaptureMode_); 920 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0043 end"; 921 } 922 923 /** 924 * @tc.name: JpegDecoderTest0044 925 * @tc.desc: Test of GetImagePropertyStringEx 926 * @tc.type: FUNC 927 */ 928 HWTEST_F(JpegDecoderTest, JpegDecoderTest0044, TestSize.Level3) 929 { 930 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0044 start"; 931 auto jpegDecoder = std::make_shared<JpegDecoder>(); 932 int size = STREAM_SIZE; 933 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 934 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 935 jpegDecoder->SetSource(*streamPtr.release()); 936 std::string key = HW_MNOTE_PHYSICAL_APERTURE; 937 std::string value = ""; 938 EXIFInfo exifInfo_; 939 jpegDecoder->GetImagePropertyString(key, value); 940 ASSERT_EQ(value, exifInfo_.hwMnotePhysicalAperture_); 941 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0044 end"; 942 } 943 944 /** 945 * @tc.name: JpegDecoderTest0045 946 * @tc.desc: Test of ModifyImageProperty 947 * @tc.type: FUNC 948 */ 949 HWTEST_F(JpegDecoderTest, JpegDecoderTest0045, TestSize.Level3) 950 { 951 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0045 start"; 952 auto jpegDecoder = std::make_shared<JpegDecoder>(); 953 int size = STREAM_SIZE; 954 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 955 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 956 jpegDecoder->SetSource(*streamPtr.release()); 957 std::string key = ""; 958 std::string path = ""; 959 std::string value = ""; 960 int32_t result = jpegDecoder->ModifyImageProperty(0, key, value, path); 961 ASSERT_EQ(result, Media::ERR_IMAGE_DECODE_EXIF_UNSUPPORT); 962 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0045 end"; 963 } 964 965 /** 966 * @tc.name: JpegDecoderTest0046 967 * @tc.desc: Test of ModifyImageProperty 968 * @tc.type: FUNC 969 */ 970 HWTEST_F(JpegDecoderTest, JpegDecoderTest0046, TestSize.Level3) 971 { 972 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0046 start"; 973 auto jpegDecoder = std::make_shared<JpegDecoder>(); 974 int size = STREAM_SIZE; 975 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 976 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 977 jpegDecoder->SetSource(*streamPtr.release()); 978 std::string key = ORIENTATION; 979 std::string path = ""; 980 std::string value = ""; 981 int32_t result = jpegDecoder->ModifyImageProperty(0, key, value, path); 982 ASSERT_EQ(result, ERR_MEDIA_IO_ABNORMAL); 983 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0046 end"; 984 } 985 986 /** 987 * @tc.name: JpegDecoderTest0047 988 * @tc.desc: Test of ModifyImageProperty 989 * @tc.type: FUNC 990 */ 991 HWTEST_F(JpegDecoderTest, JpegDecoderTest0047, TestSize.Level3) 992 { 993 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0047 start"; 994 auto jpegDecoder = std::make_shared<JpegDecoder>(); 995 int size = STREAM_SIZE; 996 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 997 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 998 jpegDecoder->SetSource(*streamPtr.release()); 999 std::string key = IMAGE_LENGTH; 1000 std::string path = ""; 1001 std::string value = ""; 1002 int32_t result = jpegDecoder->ModifyImageProperty(0, key, value, path); 1003 ASSERT_EQ(result, ERR_MEDIA_IO_ABNORMAL); 1004 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0047 end"; 1005 } 1006 1007 /** 1008 * @tc.name: JpegDecoderTest0048 1009 * @tc.desc: Test of ModifyImageProperty 1010 * @tc.type: FUNC 1011 */ 1012 HWTEST_F(JpegDecoderTest, JpegDecoderTest0048, TestSize.Level3) 1013 { 1014 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0048 start"; 1015 auto jpegDecoder = std::make_shared<JpegDecoder>(); 1016 int size = STREAM_SIZE; 1017 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 1018 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 1019 jpegDecoder->SetSource(*streamPtr.release()); 1020 std::string key = IMAGE_LENGTH; 1021 std::string path = ""; 1022 std::string value = ""; 1023 int fd = 0; 1024 int32_t result = jpegDecoder->ModifyImageProperty(0, key, value, fd); 1025 ASSERT_EQ(result, ERR_MEDIA_BUFFER_TOO_SMALL); 1026 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0048 end"; 1027 } 1028 1029 /** 1030 * @tc.name: JpegDecoderTest0049 1031 * @tc.desc: Test of ModifyImageProperty 1032 * @tc.type: FUNC 1033 */ 1034 HWTEST_F(JpegDecoderTest, JpegDecoderTest0049, TestSize.Level3) 1035 { 1036 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0049 start"; 1037 auto jpegDecoder = std::make_shared<JpegDecoder>(); 1038 int size = STREAM_SIZE; 1039 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 1040 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 1041 jpegDecoder->SetSource(*streamPtr.release()); 1042 std::string key = ""; 1043 std::string path = ""; 1044 std::string value = ""; 1045 int fd = 0; 1046 int32_t result = jpegDecoder->ModifyImageProperty(0, key, value, fd); 1047 ASSERT_EQ(result, Media::ERR_IMAGE_DECODE_EXIF_UNSUPPORT); 1048 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0049 end"; 1049 } 1050 1051 /** 1052 * @tc.name: JpegDecoderTest0050 1053 * @tc.desc: Test of ModifyImageProperty 1054 * @tc.type: FUNC 1055 */ 1056 HWTEST_F(JpegDecoderTest, JpegDecoderTest0050, TestSize.Level3) 1057 { 1058 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0050 start"; 1059 auto jpegDecoder = std::make_shared<JpegDecoder>(); 1060 int size = STREAM_SIZE; 1061 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 1062 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 1063 jpegDecoder->SetSource(*streamPtr.release()); 1064 uint32_t index = 0; 1065 std::string key = DATE_TIME; 1066 uint8_t *data1 = nullptr; 1067 std::string value = ""; 1068 uint32_t usize = 0; 1069 int32_t result = jpegDecoder->ModifyImageProperty(index, key, value, data1, usize); 1070 ASSERT_EQ(result, Media::ERR_IMAGE_DECODE_EXIF_UNSUPPORT); 1071 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0050 end"; 1072 } 1073 1074 /** 1075 * @tc.name: JpegDecoderTest0051 1076 * @tc.desc: Test of IsMarker 1077 * @tc.type: FUNC 1078 */ 1079 HWTEST_F(JpegDecoderTest, JpegDecoderTest0051, TestSize.Level3) 1080 { 1081 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0051 start"; 1082 auto jpegDecoder = std::make_shared<JpegDecoder>(); 1083 int size = STREAM_SIZE; 1084 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 1085 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 1086 jpegDecoder->SetSource(*streamPtr.release()); 1087 uint8_t rawMarkerPrefix = JPG_MARKER_PREFIX; 1088 uint8_t rawMarkderCode = JPG_MARKER_RST0; 1089 uint8_t markerCode = JPG_MARKER_RST; 1090 std::vector<std::pair<uint32_t, uint32_t>> ranges; 1091 ranges.push_back(std::make_pair(0, 0)); 1092 int32_t result = jpegDecoder->IsMarker(rawMarkerPrefix, rawMarkderCode, markerCode); 1093 ASSERT_EQ(result, true); 1094 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0051 end"; 1095 } 1096 1097 /** 1098 * @tc.name: JpegDecoderTest0052 1099 * @tc.desc: Test of IsMarker 1100 * @tc.type: FUNC 1101 */ 1102 HWTEST_F(JpegDecoderTest, JpegDecoderTest0052, TestSize.Level3) 1103 { 1104 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0052 start"; 1105 auto jpegDecoder = std::make_shared<JpegDecoder>(); 1106 int size = STREAM_SIZE; 1107 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 1108 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 1109 jpegDecoder->SetSource(*streamPtr.release()); 1110 uint8_t rawMarkerPrefix = JPG_MARKER_PREFIX; 1111 uint8_t rawMarkderCode = JPG_MARKER_APP0; 1112 uint8_t markerCode = JPG_MARKER_APP; 1113 std::vector<std::pair<uint32_t, uint32_t>> ranges; 1114 ranges.push_back(std::make_pair(0, 0)); 1115 int32_t result = jpegDecoder->IsMarker(rawMarkerPrefix, rawMarkderCode, markerCode); 1116 ASSERT_EQ(result, true); 1117 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0052 end"; 1118 } 1119 1120 /** 1121 * @tc.name: JpegDecoderTest0053 1122 * @tc.desc: Test of GetDecodeFormat 1123 * @tc.type: FUNC 1124 */ 1125 HWTEST_F(JpegDecoderTest, JpegDecoderTest0053, TestSize.Level3) 1126 { 1127 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0053 start"; 1128 auto jpegDecoder = std::make_shared<JpegDecoder>(); 1129 PixelFormat outputFormat; 1130 jpegDecoder->GetDecodeFormat(PixelFormat::UNKNOWN, outputFormat); 1131 ASSERT_EQ(outputFormat, PixelFormat::RGBA_8888); 1132 jpegDecoder->GetDecodeFormat(PixelFormat::RGBA_8888, outputFormat); 1133 ASSERT_EQ(outputFormat, PixelFormat::RGBA_8888); 1134 jpegDecoder->GetDecodeFormat(PixelFormat::BGRA_8888, outputFormat); 1135 ASSERT_EQ(outputFormat, PixelFormat::BGRA_8888); 1136 jpegDecoder->GetDecodeFormat(PixelFormat::ARGB_8888, outputFormat); 1137 jpegDecoder->GetDecodeFormat(PixelFormat::ALPHA_8, outputFormat); 1138 jpegDecoder->GetDecodeFormat(PixelFormat::RGB_565, outputFormat); 1139 ASSERT_EQ(outputFormat, PixelFormat::RGB_888); 1140 jpegDecoder->GetDecodeFormat(PixelFormat::RGB_888, outputFormat); 1141 jpegDecoder->GetDecodeFormat(PixelFormat::ASTC_8x8, outputFormat); 1142 ASSERT_EQ(outputFormat, PixelFormat::RGBA_8888); 1143 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0053 end"; 1144 } 1145 1146 /** 1147 * @tc.name: JpegDecoderTest0054 1148 * @tc.desc: Test of GetImageSize 1149 * @tc.type: FUNC 1150 */ 1151 HWTEST_F(JpegDecoderTest, JpegDecoderTest0054, TestSize.Level3) 1152 { 1153 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0054 start"; 1154 auto jpegDecoder = std::make_shared<JpegDecoder>(); 1155 uint32_t index = 0; 1156 Size size; 1157 jpegDecoder->state_ = JpegDecodingState::IMAGE_DECODED; 1158 uint32_t ret = jpegDecoder->GetImageSize(index, size); 1159 ASSERT_EQ(ret, Media::SUCCESS); 1160 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0054 end"; 1161 } 1162 1163 /** 1164 * @tc.name: JpegDecoderTest0055 1165 * @tc.desc: Test of IsMarker 1166 * @tc.type: FUNC 1167 */ 1168 HWTEST_F(JpegDecoderTest, JpegDecoderTest0055, TestSize.Level3) 1169 { 1170 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0055 start"; 1171 auto jpegDecoder = std::make_shared<JpegDecoder>(); 1172 uint8_t rawMarkerPrefix = JPG_MARKER_RST; 1173 uint8_t rawMarkderCode = JPG_MARKER_RST; 1174 uint8_t markerCode = 0; 1175 bool ret = jpegDecoder->IsMarker(rawMarkerPrefix, rawMarkderCode, markerCode); 1176 ASSERT_EQ(ret, false); 1177 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0055 end"; 1178 } 1179 1180 /** 1181 * @tc.name: JpegDecoderTest0056 1182 * @tc.desc: Test of GetMakerImagePropertyString 1183 * @tc.type: FUNC 1184 */ 1185 HWTEST_F(JpegDecoderTest, JpegDecoderTest0056, TestSize.Level3) 1186 { 1187 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0056 start"; 1188 auto jpegDecoder = std::make_shared<JpegDecoder>(); 1189 std::string key = "test"; 1190 std::string value = "test"; 1191 EXIFInfo ei; 1192 jpegDecoder->exifInfo_ = ei; 1193 jpegDecoder->exifInfo_.makerInfoTagValueMap.insert(std::make_pair(key, value)); 1194 uint32_t ret = jpegDecoder->GetMakerImagePropertyString(key, value); 1195 ASSERT_EQ(ret, Media::SUCCESS); 1196 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0056 end"; 1197 } 1198 1199 /** 1200 * @tc.name: JpegDecoderTest0057 1201 * @tc.desc: Test of GetImagePropertyString 1202 * @tc.type: FUNC 1203 */ 1204 HWTEST_F(JpegDecoderTest, JpegDecoderTest0057, TestSize.Level3) 1205 { 1206 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0057 start"; 1207 auto jpegDecoder = std::make_shared<JpegDecoder>(); 1208 int size = STREAM_SIZE; 1209 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 1210 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 1211 jpegDecoder->SetSource(*streamPtr.release()); 1212 std::string key = ISO_SPEED_RATINGS; 1213 std::string value = ""; 1214 EXIFInfo ei; 1215 jpegDecoder->exifInfo_ = ei; 1216 jpegDecoder->exifInfo_.isoSpeedRatings_ = "ISOSpeedRatings"; 1217 jpegDecoder->GetImagePropertyString(key, value); 1218 ASSERT_EQ(value, jpegDecoder->exifInfo_.isoSpeedRatings_); 1219 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0057 end"; 1220 } 1221 1222 /** 1223 * @tc.name: JpegDecoderTest0058 1224 * @tc.desc: Test of GetImagePropertyInt 1225 * @tc.type: FUNC 1226 */ 1227 HWTEST_F(JpegDecoderTest, JpegDecoderTest0058, TestSize.Level3) 1228 { 1229 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0058 start"; 1230 auto jpegDecoder = std::make_shared<JpegDecoder>(); 1231 int size = STREAM_SIZE; 1232 std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size); 1233 auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size); 1234 jpegDecoder->SetSource(*streamPtr.release()); 1235 std::string key = ORIENTATION; 1236 int32_t value = 0; 1237 uint32_t index = 0; 1238 EXIFInfo ei; 1239 jpegDecoder->exifInfo_ = ei; 1240 jpegDecoder->exifInfo_.isExifDataParsed_ = true; 1241 jpegDecoder->exifInfo_.orientation_ = "Right-top"; 1242 uint32_t ret = jpegDecoder->GetImagePropertyInt(index, key, value); 1243 ASSERT_EQ(value, 90); 1244 ASSERT_EQ(ret, Media::SUCCESS); 1245 GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0058 end"; 1246 } 1247 } 1248 }