• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <fcntl.h>
18 #include <gtest/gtest.h>
19 #include "jpeg_decoder.h"
20 #include "image_packer.h"
21 #include "buffer_source_stream.h"
22 #include "exif_info.h"
23 #include "mock_data_stream.h"
24 #include "attr_data.h"
25 
26 using namespace testing::ext;
27 using namespace OHOS::Media;
28 namespace OHOS {
29 namespace ImagePlugin {
30 static constexpr size_t STREAM_SIZE = 1000;
31 const std::string BITS_PER_SAMPLE = "BitsPerSample";
32 const std::string ORIENTATION = "Orientation";
33 const std::string IMAGE_LENGTH = "ImageLength";
34 const std::string IMAGE_WIDTH = "ImageWidth";
35 const std::string GPS_LATITUDE = "GPSLatitude";
36 const std::string GPS_LONGITUDE = "GPSLongitude";
37 const std::string GPS_LATITUDE_REF = "GPSLatitudeRef";
38 const std::string GPS_LONGITUDE_REF = "GPSLongitudeRef";
39 const std::string DATE_TIME_ORIGINAL = "DateTimeOriginal";
40 const std::string DATE_TIME_ORIGINAL_MEDIA = "DateTimeOriginalForMedia";
41 const std::string EXPOSURE_TIME = "ExposureTime";
42 const std::string F_NUMBER = "FNumber";
43 const std::string ISO_SPEED_RATINGS = "ISOSpeedRatings";
44 const std::string SCENE_TYPE = "SceneType";
45 const std::string USER_COMMENT = "UserComment";
46 const std::string PIXEL_X_DIMENSION = "PixelXDimension";
47 const std::string PIXEL_Y_DIMENSION = "PixelYDimension";
48 const std::string WHITE_BALANCE = "WhiteBalance";
49 const std::string FOCAL_LENGTH_IN_35_MM_FILM = "FocalLengthIn35mmFilm";
50 const std::string HW_MNOTE_CAPTURE_MODE = "HwMnoteCaptureMode";
51 const std::string HW_MNOTE_PHYSICAL_APERTURE = "HwMnotePhysicalAperture";
52 const std::string DATE_TIME = "DateTime";
53 constexpr uint8_t JPG_MARKER_PREFIX = 0XFF;
54 constexpr uint8_t JPG_MARKER_RST = 0XD0;
55 constexpr uint8_t JPG_MARKER_RST0 = 0XD0;
56 constexpr uint8_t JPG_MARKER_APP = 0XE0;
57 constexpr uint8_t JPG_MARKER_APP0 = 0XE0;
58 static const std::string IMAGE_INPUT_JPG_PATH = "/data/local/tmp/image/800-500.jpg";
59 static constexpr int32_t IMAGE_INPUT_JPG_WIDTH = 800;
60 static constexpr int32_t IMAGE_INPUT_JPG_HEIGHT = 500;
61 static constexpr int32_t NUM_4 = 4;
62 static constexpr int PERMISSION_GPS_TYPE = 1;
63 static const std::string IMAGE_INPUT_EXIF_PATH = "/data/local/tmp/image/test_exif.jpg";
64 class JpegDecoderTest : public testing::Test {
65 public:
JpegDecoderTest()66     JpegDecoderTest() {}
~JpegDecoderTest()67     ~JpegDecoderTest() {}
68 };
69 
70 /**
71  * @tc.name: JpegDecoderTest001
72  * @tc.desc: Test of SetSource
73  * @tc.type: FUNC
74  */
75 HWTEST_F(JpegDecoderTest, JpegDecoderTest001, TestSize.Level3)
76 {
77     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest001 start";
78     auto jpegDecoder = std::make_shared<JpegDecoder>();
79     int size = STREAM_SIZE;
80     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
81     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
82     jpegDecoder->SetSource(*streamPtr.release());
83     bool result = (jpegDecoder != nullptr);
84     ASSERT_EQ(result, true);
85     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest001 end";
86 }
87 
88 /**
89  * @tc.name: JpegDecoderTest002
90  * @tc.desc: Test of SetDecodeOptions
91  * @tc.type: FUNC
92  */
93 HWTEST_F(JpegDecoderTest, JpegDecoderTest002, TestSize.Level3)
94 {
95     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest002 start";
96     auto jpegDecoder = std::make_shared<JpegDecoder>();
97     int size = 1;
98     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
99     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
100     ASSERT_NE(streamPtr, nullptr);
101     jpegDecoder->SetSource(*streamPtr.release());
102     PixelDecodeOptions opts;
103     PlImageInfo info;
104     jpegDecoder->state_ = JpegDecodingState::IMAGE_DECODING;
105     uint32_t result = jpegDecoder->SetDecodeOptions(0, opts, info);
106     ASSERT_EQ(result, ERR_IMAGE_SOURCE_DATA_INCOMPLETE);
107     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest002 end";
108 }
109 
110 /**
111  * @tc.name: JpegDecoderTest003
112  * @tc.desc: Test of SetDecodeOptions
113  * @tc.type: FUNC
114  */
115 HWTEST_F(JpegDecoderTest, JpegDecoderTest003, TestSize.Level3)
116 {
117     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest003 start";
118     auto jpegDecoder = std::make_shared<JpegDecoder>();
119     int size = STREAM_SIZE;
120     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
121     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
122     jpegDecoder->SetSource(*streamPtr.release());
123     PixelDecodeOptions opts;
124     PlImageInfo info;
125     uint32_t result = jpegDecoder->SetDecodeOptions(JPEG_IMAGE_NUM, opts, info);
126     ASSERT_EQ(result, ERR_IMAGE_INVALID_PARAMETER);
127     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest003 end";
128 }
129 
130 /**
131  * @tc.name: JpegDecoderTest004
132  * @tc.desc: Test of SetDecodeOptions
133  * @tc.type: FUNC
134  */
135 HWTEST_F(JpegDecoderTest, JpegDecoderTest004, TestSize.Level3)
136 {
137     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest004 start";
138     auto jpegDecoder = std::make_shared<JpegDecoder>();
139     auto mock = std::make_shared<MockInputDataStream>();
140     mock->SetReturn(false);
141     jpegDecoder->SetSource(*mock.get());
142     PixelDecodeOptions opts;
143     PlImageInfo info;
144     jpegDecoder->state_ = JpegDecodingState::UNDECIDED;
145     uint32_t result = jpegDecoder->SetDecodeOptions(0, opts, info);
146     ASSERT_EQ(result, ERR_MEDIA_INVALID_OPERATION);
147     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest004 end";
148 }
149 
150 /**
151  * @tc.name: JpegDecoderTest005
152  * @tc.desc: Test of GetImageSize
153  * @tc.type: FUNC
154  */
155 HWTEST_F(JpegDecoderTest, JpegDecoderTest005, TestSize.Level3)
156 {
157     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest005 start";
158     auto jpegDecoder = std::make_shared<JpegDecoder>();
159     int size = 1;
160     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
161     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
162     ASSERT_NE(streamPtr, nullptr);
163     jpegDecoder->SetSource(*streamPtr.release());
164     ImagePlugin::Size plSize;
165     uint32_t result = jpegDecoder->GetImageSize(0, plSize);
166     ASSERT_EQ(result, ERR_IMAGE_SOURCE_DATA_INCOMPLETE);
167     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest005 end";
168 }
169 
170 /**
171  * @tc.name: JpegDecoderTest006
172  * @tc.desc: Test of GetImageSize
173  * @tc.type: FUNC
174  */
175 HWTEST_F(JpegDecoderTest, JpegDecoderTest006, TestSize.Level3)
176 {
177     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest006 start";
178     auto jpegDecoder = std::make_shared<JpegDecoder>();
179     int size = 1;
180     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
181     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
182     ASSERT_NE(streamPtr, nullptr);
183     jpegDecoder->SetSource(*streamPtr.release());
184     ImagePlugin::Size plSize;
185     uint32_t result = jpegDecoder->GetImageSize(0, plSize);
186     ASSERT_EQ(result, ERR_IMAGE_SOURCE_DATA_INCOMPLETE);
187     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest006 end";
188 }
189 
190 /**
191  * @tc.name: JpegDecoderTest007
192  * @tc.desc: Test of GetImageSize
193  * @tc.type: FUNC
194  */
195 HWTEST_F(JpegDecoderTest, JpegDecoderTest007, TestSize.Level3)
196 {
197     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest007 start";
198     auto jpegDecoder = std::make_shared<JpegDecoder>();
199     int size = STREAM_SIZE;
200     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
201     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
202     ImagePlugin::Size plSize;
203     jpegDecoder->SetSource(*streamPtr.release());
204     uint32_t result = jpegDecoder->GetImageSize(2, plSize);
205     ASSERT_EQ(result, ERR_IMAGE_INVALID_PARAMETER);
206     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest007 end";
207 }
208 
209 /**
210  * @tc.name: JpegDecoderTest008
211  * @tc.desc: Test of GetImageSize
212  * @tc.type: FUNC
213  */
214 HWTEST_F(JpegDecoderTest, JpegDecoderTest008, TestSize.Level3)
215 {
216     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest008 start";
217     auto jpegDecoder = std::make_shared<JpegDecoder>();
218     int size = STREAM_SIZE;
219     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
220     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
221     ImagePlugin::Size plSize;
222     jpegDecoder->SetSource(*streamPtr.release());
223     // check input parameter, index = JPEG_IMAGE_NUM
224     uint32_t result = jpegDecoder->GetImageSize(JPEG_IMAGE_NUM, plSize);
225     ASSERT_EQ(result, ERR_IMAGE_INVALID_PARAMETER);
226     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest008 end";
227 }
228 
229 /**
230  * @tc.name: JpegDecoderTest009
231  * @tc.desc: Test of GetImageSize
232  * @tc.type: FUNC
233  */
234 HWTEST_F(JpegDecoderTest, JpegDecoderTest009, TestSize.Level3)
235 {
236     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest009 start";
237     auto jpegDecoder = std::make_shared<JpegDecoder>();
238     auto mock = std::make_shared<MockInputDataStream>();
239     mock->SetReturn(true);
240     jpegDecoder->SetSource(*mock.get());
241     ImagePlugin::Size plSize;
242     jpegDecoder->state_ = JpegDecodingState::UNDECIDED;
243     uint32_t result = jpegDecoder->GetImageSize(0, plSize);
244     ASSERT_EQ(result, ERR_MEDIA_INVALID_OPERATION);
245     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest009 end";
246 }
247 
248 /**
249  * @tc.name: JpegDecoderTest0010
250  * @tc.desc: Test of GetImageSize
251  * @tc.type: FUNC
252  */
253 HWTEST_F(JpegDecoderTest, JpegDecoderTest0010, TestSize.Level3)
254 {
255     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0010 start";
256     auto jpegDecoder = std::make_shared<JpegDecoder>();
257     int size = 1;
258     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
259     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
260     ASSERT_NE(streamPtr, nullptr);
261     jpegDecoder->SetSource(*streamPtr.release());
262     ImagePlugin::Size plSize;
263     uint32_t result = jpegDecoder->GetImageSize(0, plSize);
264     ASSERT_EQ(result, ERR_IMAGE_SOURCE_DATA_INCOMPLETE);
265     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0010 end";
266 }
267 
268 /**
269  * @tc.name: JpegDecoderTest0011
270  * @tc.desc: Test of Decode
271  * @tc.type: FUNC
272  */
273 HWTEST_F(JpegDecoderTest, JpegDecoderTest0011, TestSize.Level3)
274 {
275     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0011 start";
276     auto jpegDecoder = std::make_shared<JpegDecoder>();
277     int size = STREAM_SIZE;
278     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
279     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
280     jpegDecoder->SetSource(*streamPtr.release());
281     DecodeContext context;
282     uint32_t result = jpegDecoder->Decode(2, context);
283     ASSERT_EQ(result, ERR_IMAGE_INVALID_PARAMETER);
284     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0011 end";
285 }
286 
287 /**
288  * @tc.name: JpegDecoderTest0012
289  * @tc.desc: Test of Decode
290  * @tc.type: FUNC
291  */
292 HWTEST_F(JpegDecoderTest, JpegDecoderTest0012, TestSize.Level3)
293 {
294     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0012 start";
295     auto jpegDecoder = std::make_shared<JpegDecoder>();
296     int size = STREAM_SIZE;
297     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
298     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
299     jpegDecoder->SetSource(*streamPtr.release());
300     DecodeContext context;
301     uint32_t result = jpegDecoder->Decode(JPEG_IMAGE_NUM, context);
302     ASSERT_EQ(result, ERR_IMAGE_INVALID_PARAMETER);
303     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0012 end";
304 }
305 
306 /**
307  * @tc.name: JpegDecoderTest0013
308  * @tc.desc: Test of Decode
309  * @tc.type: FUNC
310  */
311 HWTEST_F(JpegDecoderTest, JpegDecoderTest0013, TestSize.Level3)
312 {
313     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0013 start";
314     auto jpegDecoder = std::make_shared<JpegDecoder>();
315     int size = STREAM_SIZE;
316     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
317     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
318     jpegDecoder->SetSource(*streamPtr.release());
319     DecodeContext context;
320     uint32_t result = jpegDecoder->Decode(0, context);
321     ASSERT_EQ(result, ERR_MEDIA_INVALID_OPERATION);
322     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0013 end";
323 }
324 
325 /**
326  * @tc.name: JpegDecoderTest0014
327  * @tc.desc: Test of Decode
328  * @tc.type: FUNC
329  */
330 HWTEST_F(JpegDecoderTest, JpegDecoderTest0014, TestSize.Level3)
331 {
332     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0014 start";
333     auto jpegDecoder = std::make_shared<JpegDecoder>();
334     int size = 1;
335     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
336     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
337     ASSERT_NE(streamPtr, nullptr);
338     jpegDecoder->SetSource(*streamPtr.release());
339     DecodeContext context;
340     jpegDecoder->state_ = JpegDecodingState::IMAGE_ERROR;
341     uint32_t ret = jpegDecoder->Decode(0, context);
342     ASSERT_EQ(ret, ERR_IMAGE_SOURCE_DATA_INCOMPLETE);
343     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0014 end";
344 }
345 
346 /**
347  * @tc.name: JpegDecoderTest0015
348  * @tc.desc: Test of PromoteIncrementalDecode
349  * @tc.type: FUNC
350  */
351 HWTEST_F(JpegDecoderTest, JpegDecoderTest0015, TestSize.Level3)
352 {
353     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0015 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(2, context);
361     ASSERT_EQ(result, ERR_IMAGE_INVALID_PARAMETER);
362     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0015 end";
363 }
364 
365 /**
366  * @tc.name: JpegDecoderTest0016
367  * @tc.desc: Test of PromoteIncrementalDecode
368  * @tc.type: FUNC
369  */
370 HWTEST_F(JpegDecoderTest, JpegDecoderTest0016, TestSize.Level3)
371 {
372     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0016 start";
373     auto jpegDecoder = std::make_shared<JpegDecoder>();
374     int size = STREAM_SIZE;
375     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
376     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
377     jpegDecoder->SetSource(*streamPtr.release());
378     ProgDecodeContext context;
379     uint32_t result = jpegDecoder->PromoteIncrementalDecode(JPEG_IMAGE_NUM, context);
380     ASSERT_EQ(result, ERR_IMAGE_INVALID_PARAMETER);
381     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0016 end";
382 }
383 /**
384  * @tc.name: JpegDecoderTest0017
385  * @tc.desc: Test of PromoteIncrementalDecode
386  * @tc.type: FUNC
387  */
388 HWTEST_F(JpegDecoderTest, JpegDecoderTest0017, TestSize.Level3)
389 {
390     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0017 start";
391     auto jpegDecoder = std::make_shared<JpegDecoder>();
392     int size = 1;
393     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
394     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
395     ASSERT_NE(streamPtr, nullptr);
396     jpegDecoder->SetSource(*streamPtr.release());
397     ProgDecodeContext context;
398     uint32_t result = jpegDecoder->PromoteIncrementalDecode(0, context);
399     ASSERT_EQ(result, ERR_MEDIA_INVALID_OPERATION);
400     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0017 end";
401 }
402 
403 /**
404  * @tc.name: JpegDecoderTest0018
405  * @tc.desc: Test of GetImagePropertyInt
406  * @tc.type: FUNC
407  */
408 HWTEST_F(JpegDecoderTest, JpegDecoderTest0018, TestSize.Level3)
409 {
410     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0018 start";
411     auto jpegDecoder = std::make_shared<JpegDecoder>();
412     int size = STREAM_SIZE;
413     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
414     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
415     jpegDecoder->SetSource(*streamPtr.release());
416     std::string key = ORIENTATION;
417     int32_t value = 0;
418     uint32_t result = jpegDecoder->GetImagePropertyInt(0, key, value);
419     ASSERT_EQ(result, ERR_MEDIA_VALUE_INVALID);
420     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0018 end";
421 }
422 
423 /**
424  * @tc.name: JpegDecoderTest0019
425  * @tc.desc: Test of GetImagePropertyInt
426  * @tc.type: FUNC
427  */
428 HWTEST_F(JpegDecoderTest, JpegDecoderTest0019, TestSize.Level3)
429 {
430     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0019 start";
431     auto jpegDecoder = std::make_shared<JpegDecoder>();
432     int size = STREAM_SIZE;
433     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
434     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
435     jpegDecoder->SetSource(*streamPtr.release());
436     std::string key = IMAGE_LENGTH;
437     int32_t value = 0;
438     uint32_t result = jpegDecoder->GetImagePropertyInt(0, key, value);
439     ASSERT_EQ(result, ERR_MEDIA_VALUE_INVALID);
440     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0019 end";
441 }
442 
443 /**
444  * @tc.name: JpegDecoderTest0020
445  * @tc.desc: Test of GetImagePropertyInt
446  * @tc.type: FUNC
447  */
448 HWTEST_F(JpegDecoderTest, JpegDecoderTest0020, TestSize.Level3)
449 {
450     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0020 start";
451     auto jpegDecoder = std::make_shared<JpegDecoder>();
452     int size = STREAM_SIZE;
453     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
454     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
455     jpegDecoder->SetSource(*streamPtr.release());
456     std::string key = ACTUAL_IMAGE_ENCODED_FORMAT;
457     int32_t value = 0;
458     uint32_t result = jpegDecoder->GetImagePropertyInt(0, key, value);
459     ASSERT_EQ(result, Media::ERR_MEDIA_VALUE_INVALID);
460     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0020 end";
461 }
462 
463 /**
464  * @tc.name: JpegDecoderTest0021
465  * @tc.desc: Test of GetImagePropertyString
466  * @tc.type: FUNC
467  */
468 HWTEST_F(JpegDecoderTest, JpegDecoderTest0021, TestSize.Level3)
469 {
470     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0021 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 = BITS_PER_SAMPLE;
477     std::string value = "";
478     EXIFInfo exifInfo_;
479     jpegDecoder->GetImagePropertyString(0, key, value);
480     ASSERT_EQ(value, exifInfo_.bitsPerSample_);
481     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0021 end";
482 }
483 
484 /**
485  * @tc.name: JpegDecoderTest0022
486  * @tc.desc: Test of GetImagePropertyString
487  * @tc.type: FUNC
488  */
489 HWTEST_F(JpegDecoderTest, JpegDecoderTest0022, TestSize.Level3)
490 {
491     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0022 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 = ORIENTATION;
498     std::string value = "";
499     EXIFInfo exifInfo_;
500     jpegDecoder->GetImagePropertyString(0, key, value);
501     ASSERT_EQ(value, exifInfo_.orientation_);
502     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0022 end";
503 }
504 
505 /**
506  * @tc.name: JpegDecoderTest0023
507  * @tc.desc: Test of GetImagePropertyString
508  * @tc.type: FUNC
509  */
510 HWTEST_F(JpegDecoderTest, JpegDecoderTest0023, TestSize.Level3)
511 {
512     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0023 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_LENGTH;
519     std::string value = "";
520     EXIFInfo exifInfo_;
521     jpegDecoder->GetImagePropertyString(0, key, value);
522     ASSERT_EQ(value, exifInfo_.imageLength_);
523     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0023 end";
524 }
525 
526 /**
527  * @tc.name: JpegDecoderTest0024
528  * @tc.desc: Test of GetImagePropertyString
529  * @tc.type: FUNC
530  */
531 HWTEST_F(JpegDecoderTest, JpegDecoderTest0024, TestSize.Level3)
532 {
533     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0024 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 = IMAGE_WIDTH;
540     std::string value = "";
541     EXIFInfo exifInfo_;
542     jpegDecoder->GetImagePropertyString(0, key, value);
543     ASSERT_EQ(value, exifInfo_.imageWidth_);
544     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0024 end";
545 }
546 
547 /**
548  * @tc.name: JpegDecoderTest0025
549  * @tc.desc: Test of GetImagePropertyString
550  * @tc.type: FUNC
551  */
552 HWTEST_F(JpegDecoderTest, JpegDecoderTest0025, TestSize.Level3)
553 {
554     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0025 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_LATITUDE;
561     std::string value = "";
562     EXIFInfo exifInfo_;
563     jpegDecoder->GetImagePropertyString(0, key, value);
564     ASSERT_EQ(value, exifInfo_.gpsLatitude_);
565     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0025 end";
566 }
567 
568 /**
569  * @tc.name: JpegDecoderTest0026
570  * @tc.desc: Test of GetImagePropertyString
571  * @tc.type: FUNC
572  */
573 HWTEST_F(JpegDecoderTest, JpegDecoderTest0026, TestSize.Level3)
574 {
575     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0026 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_LONGITUDE;
582     std::string value = "";
583     EXIFInfo exifInfo_;
584     jpegDecoder->GetImagePropertyString(0, key, value);
585     ASSERT_EQ(value, exifInfo_.gpsLongitude_);
586     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0026 end";
587 }
588 
589 /**
590  * @tc.name: JpegDecoderTest0027
591  * @tc.desc: Test of GetImagePropertyString
592  * @tc.type: FUNC
593  */
594 HWTEST_F(JpegDecoderTest, JpegDecoderTest0027, TestSize.Level3)
595 {
596     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0027 start";
597     auto jpegDecoder = std::make_shared<JpegDecoder>();
598     int size = STREAM_SIZE;
599     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
600     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
601     jpegDecoder->SetSource(*streamPtr.release());
602     std::string key = GPS_LATITUDE_REF;
603     std::string value = "";
604     EXIFInfo exifInfo_;
605     jpegDecoder->GetImagePropertyString(0, key, value);
606     ASSERT_EQ(value, exifInfo_.gpsLatitudeRef_);
607     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0027 end";
608 }
609 
610 
611 /**
612  * @tc.name: JpegDecoderTest0028
613  * @tc.desc: Test of GetImagePropertyString
614  * @tc.type: FUNC
615  */
616 HWTEST_F(JpegDecoderTest, JpegDecoderTest0028, TestSize.Level3)
617 {
618     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0028 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 = GPS_LONGITUDE_REF;
625     std::string value = "";
626     EXIFInfo exifInfo_;
627     jpegDecoder->GetImagePropertyString(0, key, value);
628     ASSERT_EQ(value, exifInfo_.gpsLongitudeRef_);
629     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0028 end";
630 }
631 
632 /**
633  * @tc.name: JpegDecoderTest0029
634  * @tc.desc: Test of GetImagePropertyString
635  * @tc.type: FUNC
636  */
637 HWTEST_F(JpegDecoderTest, JpegDecoderTest0029, TestSize.Level3)
638 {
639     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0029 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;
646     std::string value = "";
647     EXIFInfo exifInfo_;
648     jpegDecoder->GetImagePropertyString(0, key, value);
649     ASSERT_EQ(value, exifInfo_.dateTimeOriginal_);
650     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0029 end";
651 }
652 
653 /**
654  * @tc.name: JpegDecoderTest0030
655  * @tc.desc: Test of GetImagePropertyString
656  * @tc.type: FUNC
657  */
658 HWTEST_F(JpegDecoderTest, JpegDecoderTest0030, TestSize.Level3)
659 {
660     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0030 start";
661     auto jpegDecoder = std::make_shared<JpegDecoder>();
662     int size = STREAM_SIZE;
663     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
664     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
665     jpegDecoder->SetSource(*streamPtr.release());
666     std::string key = DATE_TIME_ORIGINAL_MEDIA;
667     std::string value = "";
668     uint32_t ret = jpegDecoder->GetImagePropertyString(0, key, value);
669     ASSERT_EQ(ret, Media::SUCCESS);
670     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0030 end";
671 }
672 
673 /**
674  * @tc.name: JpegDecoderTest0031
675  * @tc.desc: Test of GetImagePropertyString
676  * @tc.type: FUNC
677  */
678 HWTEST_F(JpegDecoderTest, JpegDecoderTest0031, TestSize.Level3)
679 {
680     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0031 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 = EXPOSURE_TIME;
687     std::string value = "";
688     EXIFInfo exifInfo_;
689     jpegDecoder->GetImagePropertyString(0, key, value);
690     ASSERT_EQ(value, exifInfo_.exposureTime_);
691     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0031 end";
692 }
693 
694 /**
695  * @tc.name: JpegDecoderTest0032
696  * @tc.desc: Test of GetImagePropertyString
697  * @tc.type: FUNC
698  */
699 HWTEST_F(JpegDecoderTest, JpegDecoderTest0032, TestSize.Level3)
700 {
701     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0032 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 = F_NUMBER;
708     std::string value = "";
709     EXIFInfo exifInfo_;
710     jpegDecoder->GetImagePropertyString(0, key, value);
711     ASSERT_EQ(value, exifInfo_.fNumber_);
712     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0032 end";
713 }
714 
715 /**
716  * @tc.name: JpegDecoderTest0033
717  * @tc.desc: Test of GetImagePropertyString
718  * @tc.type: FUNC
719  */
720 HWTEST_F(JpegDecoderTest, JpegDecoderTest0033, TestSize.Level3)
721 {
722     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0033 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 = ISO_SPEED_RATINGS;
729     std::string value = "";
730     EXIFInfo exifInfo_;
731     jpegDecoder->GetImagePropertyString(0, key, value);
732     ASSERT_EQ(value, exifInfo_.isoSpeedRatings_);
733     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0033 end";
734 }
735 
736 /**
737  * @tc.name: JpegDecoderTest0034
738  * @tc.desc: Test of GetImagePropertyString
739  * @tc.type: FUNC
740  */
741 HWTEST_F(JpegDecoderTest, JpegDecoderTest0034, TestSize.Level3)
742 {
743     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0034 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 = SCENE_TYPE;
750     std::string value = "";
751     EXIFInfo exifInfo_;
752     jpegDecoder->GetImagePropertyString(0, key, value);
753     ASSERT_EQ(value, exifInfo_.sceneType_);
754     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0034 end";
755 }
756 
757 /**
758  * @tc.name: JpegDecoderTest0035
759  * @tc.desc: Test of GetImagePropertyString
760  * @tc.type: FUNC
761  */
762 HWTEST_F(JpegDecoderTest, JpegDecoderTest0035, TestSize.Level3)
763 {
764     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0035 start";
765     auto jpegDecoder = std::make_shared<JpegDecoder>();
766     int size = STREAM_SIZE;
767     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
768     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
769     jpegDecoder->SetSource(*streamPtr.release());
770     std::string key = "";
771     std::string value = "";
772     int32_t result = jpegDecoder->GetImagePropertyString(0, key, value);
773     ASSERT_EQ(result, Media::ERR_IMAGE_DECODE_EXIF_UNSUPPORT);
774     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0035 end";
775 }
776 
777 /**
778  * @tc.name: JpegDecoderTest0036
779  * @tc.desc: Test of GetImagePropertyString
780  * @tc.type: FUNC
781  */
782 HWTEST_F(JpegDecoderTest, JpegDecoderTest0036, TestSize.Level3)
783 {
784     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0036 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 = ACTUAL_IMAGE_ENCODED_FORMAT;
791     std::string value = "";
792     int32_t result = jpegDecoder->GetImagePropertyString(0, key, value);
793     ASSERT_EQ(result, Media::ERR_MEDIA_VALUE_INVALID);
794     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0036 end";
795 }
796 
797 
798 /**
799  * @tc.name: JpegDecoderTest0037
800  * @tc.desc: Test of GetImagePropertyStringEx
801  * @tc.type: FUNC
802  */
803 HWTEST_F(JpegDecoderTest, JpegDecoderTest0037, TestSize.Level3)
804 {
805     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0037 start";
806     auto jpegDecoder = std::make_shared<JpegDecoder>();
807     int size = STREAM_SIZE;
808     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
809     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
810     jpegDecoder->SetSource(*streamPtr.release());
811     std::string key = "";
812     std::string value = "";
813     int32_t result = jpegDecoder->GetImagePropertyStringEx(key, value);
814     ASSERT_EQ(result, ERR_IMAGE_DECODE_EXIF_UNSUPPORT);
815     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0037 end";
816 }
817 
818 /**
819  * @tc.name: JpegDecoderTest0038
820  * @tc.desc: Test of GetImagePropertyStringEx
821  * @tc.type: FUNC
822  */
823 HWTEST_F(JpegDecoderTest, JpegDecoderTest0038, TestSize.Level3)
824 {
825     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0038 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 = USER_COMMENT;
832     std::string value = "";
833     EXIFInfo exifInfo_;
834     jpegDecoder->GetImagePropertyString(key, value);
835     ASSERT_EQ(value, exifInfo_.userComment_);
836     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0038 end";
837 }
838 
839 /**
840  * @tc.name: JpegDecoderTest0039
841  * @tc.desc: Test of GetImagePropertyStringEx
842  * @tc.type: FUNC
843  */
844 HWTEST_F(JpegDecoderTest, JpegDecoderTest0039, TestSize.Level3)
845 {
846     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0039 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_X_DIMENSION;
853     std::string value = "";
854     EXIFInfo exifInfo_;
855     jpegDecoder->GetImagePropertyString(key, value);
856     ASSERT_EQ(value, exifInfo_.pixelXDimension_);
857     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0039 end";
858 }
859 
860 /**
861  * @tc.name: JpegDecoderTest0040
862  * @tc.desc: Test of GetImagePropertyStringEx
863  * @tc.type: FUNC
864  */
865 HWTEST_F(JpegDecoderTest, JpegDecoderTest0040, TestSize.Level3)
866 {
867     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0040 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 = PIXEL_Y_DIMENSION;
874     std::string value = "";
875     EXIFInfo exifInfo_;
876     jpegDecoder->GetImagePropertyString(key, value);
877     ASSERT_EQ(value, exifInfo_.pixelYDimension_);
878     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0040 end";
879 }
880 
881 /**
882  * @tc.name: JpegDecoderTest0041
883  * @tc.desc: Test of GetImagePropertyStringEx
884  * @tc.type: FUNC
885  */
886 HWTEST_F(JpegDecoderTest, JpegDecoderTest0041, TestSize.Level3)
887 {
888     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0041 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 = WHITE_BALANCE;
895     std::string value = "";
896     EXIFInfo exifInfo_;
897     jpegDecoder->GetImagePropertyString(key, value);
898     ASSERT_EQ(value, exifInfo_.whiteBalance_);
899     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0041 end";
900 }
901 
902 /**
903  * @tc.name: JpegDecoderTest0042
904  * @tc.desc: Test of GetImagePropertyStringEx
905  * @tc.type: FUNC
906  */
907 HWTEST_F(JpegDecoderTest, JpegDecoderTest0042, TestSize.Level3)
908 {
909     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0042 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 = FOCAL_LENGTH_IN_35_MM_FILM;
916     std::string value = "";
917     EXIFInfo exifInfo_;
918     jpegDecoder->GetImagePropertyString(key, value);
919     ASSERT_EQ(value, exifInfo_.focalLengthIn35mmFilm_);
920     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0042 end";
921 }
922 
923 /**
924  * @tc.name: JpegDecoderTest0043
925  * @tc.desc: Test of GetImagePropertyStringEx
926  * @tc.type: FUNC
927  */
928 HWTEST_F(JpegDecoderTest, JpegDecoderTest0043, TestSize.Level3)
929 {
930     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0043 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_CAPTURE_MODE;
937     std::string value = "";
938     EXIFInfo exifInfo_;
939     jpegDecoder->GetImagePropertyString(key, value);
940     ASSERT_EQ(value, exifInfo_.hwMnoteCaptureMode_);
941     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0043 end";
942 }
943 
944 /**
945  * @tc.name: JpegDecoderTest0044
946  * @tc.desc: Test of GetImagePropertyStringEx
947  * @tc.type: FUNC
948  */
949 HWTEST_F(JpegDecoderTest, JpegDecoderTest0044, TestSize.Level3)
950 {
951     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0044 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 = HW_MNOTE_PHYSICAL_APERTURE;
958     std::string value = "";
959     EXIFInfo exifInfo_;
960     jpegDecoder->GetImagePropertyString(key, value);
961     ASSERT_EQ(value, exifInfo_.hwMnotePhysicalAperture_);
962     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0044 end";
963 }
964 
965 /**
966  * @tc.name: JpegDecoderTest0045
967  * @tc.desc: Test of ModifyImageProperty
968  * @tc.type: FUNC
969  */
970 HWTEST_F(JpegDecoderTest, JpegDecoderTest0045, TestSize.Level3)
971 {
972     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0045 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 = "";
979     std::string path = "";
980     std::string value = "";
981     int32_t result = jpegDecoder->ModifyImageProperty(0, key, value, path);
982     ASSERT_EQ(result, Media::ERR_IMAGE_DECODE_EXIF_UNSUPPORT);
983     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0045 end";
984 }
985 
986 /**
987  * @tc.name: JpegDecoderTest0046
988  * @tc.desc: Test of ModifyImageProperty
989  * @tc.type: FUNC
990  */
991 HWTEST_F(JpegDecoderTest, JpegDecoderTest0046, TestSize.Level3)
992 {
993     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0046 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 = ORIENTATION;
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: JpegDecoderTest0046 end";
1005 }
1006 
1007 /**
1008  * @tc.name: JpegDecoderTest0047
1009  * @tc.desc: Test of ModifyImageProperty
1010  * @tc.type: FUNC
1011  */
1012 HWTEST_F(JpegDecoderTest, JpegDecoderTest0047, TestSize.Level3)
1013 {
1014     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0047 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     int32_t result = jpegDecoder->ModifyImageProperty(0, key, value, path);
1024     ASSERT_EQ(result, ERR_MEDIA_IO_ABNORMAL);
1025     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0047 end";
1026 }
1027 
1028 /**
1029  * @tc.name: JpegDecoderTest0048
1030  * @tc.desc: Test of ModifyImageProperty
1031  * @tc.type: FUNC
1032  */
1033 HWTEST_F(JpegDecoderTest, JpegDecoderTest0048, TestSize.Level3)
1034 {
1035     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0048 start";
1036     auto jpegDecoder = std::make_shared<JpegDecoder>();
1037     int size = STREAM_SIZE;
1038     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
1039     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
1040     jpegDecoder->SetSource(*streamPtr.release());
1041     std::string key = IMAGE_LENGTH;
1042     std::string path = "";
1043     std::string value = "";
1044     int fd = 0;
1045     int32_t result = jpegDecoder->ModifyImageProperty(0, key, value, fd);
1046     ASSERT_EQ(result, ERR_MEDIA_BUFFER_TOO_SMALL);
1047     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0048 end";
1048 }
1049 
1050 /**
1051  * @tc.name: JpegDecoderTest0049
1052  * @tc.desc: Test of ModifyImageProperty
1053  * @tc.type: FUNC
1054  */
1055 HWTEST_F(JpegDecoderTest, JpegDecoderTest0049, TestSize.Level3)
1056 {
1057     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0049 start";
1058     auto jpegDecoder = std::make_shared<JpegDecoder>();
1059     int size = STREAM_SIZE;
1060     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
1061     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
1062     jpegDecoder->SetSource(*streamPtr.release());
1063     std::string key = "";
1064     std::string path = "";
1065     std::string value = "";
1066     int fd = 0;
1067     int32_t result = jpegDecoder->ModifyImageProperty(0, key, value, fd);
1068     ASSERT_EQ(result, Media::ERR_IMAGE_DECODE_EXIF_UNSUPPORT);
1069     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0049 end";
1070 }
1071 
1072 /**
1073  * @tc.name: JpegDecoderTest0050
1074  * @tc.desc: Test of ModifyImageProperty
1075  * @tc.type: FUNC
1076  */
1077 HWTEST_F(JpegDecoderTest, JpegDecoderTest0050, TestSize.Level3)
1078 {
1079     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0050 start";
1080     auto jpegDecoder = std::make_shared<JpegDecoder>();
1081     int size = STREAM_SIZE;
1082     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
1083     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
1084     jpegDecoder->SetSource(*streamPtr.release());
1085     uint32_t index = 0;
1086     std::string key = DATE_TIME;
1087     uint8_t *data1 = nullptr;
1088     std::string value = "";
1089     uint32_t usize = 0;
1090     int32_t result = jpegDecoder->ModifyImageProperty(index, key, value, data1, usize);
1091     ASSERT_EQ(result, Media::ERR_IMAGE_DECODE_EXIF_UNSUPPORT);
1092     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0050 end";
1093 }
1094 
1095 /**
1096  * @tc.name: JpegDecoderTest0051
1097  * @tc.desc: Test of IsMarker
1098  * @tc.type: FUNC
1099  */
1100 HWTEST_F(JpegDecoderTest, JpegDecoderTest0051, TestSize.Level3)
1101 {
1102     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0051 start";
1103     auto jpegDecoder = std::make_shared<JpegDecoder>();
1104     int size = STREAM_SIZE;
1105     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
1106     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
1107     jpegDecoder->SetSource(*streamPtr.release());
1108     uint8_t rawMarkerPrefix = JPG_MARKER_PREFIX;
1109     uint8_t rawMarkderCode = JPG_MARKER_RST0;
1110     uint8_t markerCode = JPG_MARKER_RST;
1111     std::vector<std::pair<uint32_t, uint32_t>> ranges;
1112     ranges.push_back(std::make_pair(0, 0));
1113     int32_t result = jpegDecoder->IsMarker(rawMarkerPrefix, rawMarkderCode, markerCode);
1114     ASSERT_EQ(result, true);
1115     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0051 end";
1116 }
1117 
1118 /**
1119  * @tc.name: JpegDecoderTest0052
1120  * @tc.desc: Test of IsMarker
1121  * @tc.type: FUNC
1122  */
1123 HWTEST_F(JpegDecoderTest, JpegDecoderTest0052, TestSize.Level3)
1124 {
1125     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0052 start";
1126     auto jpegDecoder = std::make_shared<JpegDecoder>();
1127     int size = STREAM_SIZE;
1128     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
1129     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
1130     jpegDecoder->SetSource(*streamPtr.release());
1131     uint8_t rawMarkerPrefix = JPG_MARKER_PREFIX;
1132     uint8_t rawMarkderCode = JPG_MARKER_APP0;
1133     uint8_t markerCode = JPG_MARKER_APP;
1134     std::vector<std::pair<uint32_t, uint32_t>> ranges;
1135     ranges.push_back(std::make_pair(0, 0));
1136     int32_t result = jpegDecoder->IsMarker(rawMarkerPrefix, rawMarkderCode, markerCode);
1137     ASSERT_EQ(result, true);
1138     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0052 end";
1139 }
1140 
1141 /**
1142  * @tc.name: JpegDecoderTest0053
1143  * @tc.desc: Test of GetDecodeFormat
1144  * @tc.type: FUNC
1145  */
1146 HWTEST_F(JpegDecoderTest, JpegDecoderTest0053, TestSize.Level3)
1147 {
1148     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0053 start";
1149     auto jpegDecoder = std::make_shared<JpegDecoder>();
1150     PixelFormat outputFormat;
1151     jpegDecoder->GetDecodeFormat(PixelFormat::UNKNOWN, outputFormat);
1152     ASSERT_EQ(outputFormat, PixelFormat::RGBA_8888);
1153     jpegDecoder->GetDecodeFormat(PixelFormat::RGBA_8888, outputFormat);
1154     ASSERT_EQ(outputFormat, PixelFormat::RGBA_8888);
1155     jpegDecoder->GetDecodeFormat(PixelFormat::BGRA_8888, outputFormat);
1156     ASSERT_EQ(outputFormat, PixelFormat::BGRA_8888);
1157     jpegDecoder->GetDecodeFormat(PixelFormat::ARGB_8888, outputFormat);
1158     jpegDecoder->GetDecodeFormat(PixelFormat::ALPHA_8, outputFormat);
1159     jpegDecoder->GetDecodeFormat(PixelFormat::RGB_565, outputFormat);
1160     ASSERT_EQ(outputFormat, PixelFormat::RGB_888);
1161     jpegDecoder->GetDecodeFormat(PixelFormat::RGB_888, outputFormat);
1162     jpegDecoder->GetDecodeFormat(PixelFormat::ASTC_8x8, outputFormat);
1163     ASSERT_EQ(outputFormat, PixelFormat::RGBA_8888);
1164     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0053 end";
1165 }
1166 
1167 /**
1168  * @tc.name: JpegDecoderTest0054
1169  * @tc.desc: Test of GetImageSize
1170  * @tc.type: FUNC
1171  */
1172 HWTEST_F(JpegDecoderTest, JpegDecoderTest0054, TestSize.Level3)
1173 {
1174     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0054 start";
1175     auto jpegDecoder = std::make_shared<JpegDecoder>();
1176     uint32_t index = 0;
1177     Size size;
1178     jpegDecoder->state_ = JpegDecodingState::IMAGE_DECODED;
1179     uint32_t ret = jpegDecoder->GetImageSize(index, size);
1180     ASSERT_EQ(ret, Media::SUCCESS);
1181     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0054 end";
1182 }
1183 
1184 /**
1185  * @tc.name: JpegDecoderTest0055
1186  * @tc.desc: Test of IsMarker
1187  * @tc.type: FUNC
1188  */
1189 HWTEST_F(JpegDecoderTest, JpegDecoderTest0055, TestSize.Level3)
1190 {
1191     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0055 start";
1192     auto jpegDecoder = std::make_shared<JpegDecoder>();
1193     uint8_t rawMarkerPrefix = JPG_MARKER_RST;
1194     uint8_t rawMarkderCode = JPG_MARKER_RST;
1195     uint8_t markerCode = 0;
1196     bool ret = jpegDecoder->IsMarker(rawMarkerPrefix, rawMarkderCode, markerCode);
1197     ASSERT_EQ(ret, false);
1198     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0055 end";
1199 }
1200 
1201 /**
1202  * @tc.name: JpegDecoderTest0056
1203  * @tc.desc: Test of GetMakerImagePropertyString
1204  * @tc.type: FUNC
1205  */
1206 HWTEST_F(JpegDecoderTest, JpegDecoderTest0056, TestSize.Level3)
1207 {
1208     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0056 start";
1209     auto jpegDecoder = std::make_shared<JpegDecoder>();
1210     std::string key = "test";
1211     std::string value = "test";
1212     EXIFInfo ei;
1213     jpegDecoder->exifInfo_ = ei;
1214     jpegDecoder->exifInfo_.makerInfoTagValueMap.insert(std::make_pair(key, value));
1215     uint32_t ret = jpegDecoder->GetMakerImagePropertyString(key, value);
1216     ASSERT_EQ(ret, Media::SUCCESS);
1217     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0056 end";
1218 }
1219 
1220 /**
1221  * @tc.name: JpegDecoderTest0057
1222  * @tc.desc: Test of GetImagePropertyString
1223  * @tc.type: FUNC
1224  */
1225 HWTEST_F(JpegDecoderTest, JpegDecoderTest0057, TestSize.Level3)
1226 {
1227     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0057 start";
1228     auto jpegDecoder = std::make_shared<JpegDecoder>();
1229     int size = STREAM_SIZE;
1230     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
1231     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
1232     jpegDecoder->SetSource(*streamPtr.release());
1233     std::string key = ISO_SPEED_RATINGS;
1234     std::string value = "";
1235     EXIFInfo ei;
1236     jpegDecoder->exifInfo_ = ei;
1237     jpegDecoder->exifInfo_.isoSpeedRatings_ = "ISOSpeedRatings";
1238     jpegDecoder->GetImagePropertyString(key, value);
1239     ASSERT_EQ(value, jpegDecoder->exifInfo_.isoSpeedRatings_);
1240     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0057 end";
1241 }
1242 
1243 /**
1244  * @tc.name: JpegDecoderTest0058
1245  * @tc.desc: Test of GetImagePropertyInt
1246  * @tc.type: FUNC
1247  */
1248 HWTEST_F(JpegDecoderTest, JpegDecoderTest0058, TestSize.Level3)
1249 {
1250     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0058 start";
1251     auto jpegDecoder = std::make_shared<JpegDecoder>();
1252     int size = STREAM_SIZE;
1253     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
1254     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
1255     jpegDecoder->SetSource(*streamPtr.release());
1256     std::string key = ORIENTATION;
1257     int32_t value = 0;
1258     uint32_t index = 0;
1259     EXIFInfo ei;
1260     jpegDecoder->exifInfo_ = ei;
1261     jpegDecoder->exifInfo_.isExifDataParsed_ = true;
1262     jpegDecoder->exifInfo_.orientation_ = "Right-top";
1263     uint32_t ret = jpegDecoder->GetImagePropertyInt(index, key, value);
1264     ASSERT_EQ(value, 90);
1265     ASSERT_EQ(ret, Media::SUCCESS);
1266     GTEST_LOG_(INFO) << "JpegDecoderTest: JpegDecoderTest0058 end";
1267 }
1268 
1269 /**
1270  * @tc.name: JpegDecoderTest_SetDecodeOptionsTest001
1271  * @tc.desc: Verify that JpegDecoder decodes image when desired size is smaller than the actual size.
1272  * @tc.type: FUNC
1273  */
1274 HWTEST_F(JpegDecoderTest, SetDecodeOptionsTest006, TestSize.Level3)
1275 {
1276     GTEST_LOG_(INFO) << "JpegDecoderTest: SetDecodeOptionsTest006 start";
1277     auto jpegDecoder = std::make_shared<JpegDecoder>();
1278     ASSERT_NE(jpegDecoder, nullptr);
1279     uint32_t errorCode = -1;
1280     SourceOptions sourceOpts;
1281     sourceOpts.formatHint = "image/jpeg";
1282     std::unique_ptr<ImageSource> imageSource =
1283         ImageSource::CreateImageSource(IMAGE_INPUT_JPG_PATH, sourceOpts, errorCode);
1284     ASSERT_NE(imageSource, nullptr);
1285     ASSERT_EQ(errorCode, SUCCESS);
1286     jpegDecoder->SetSource(*(imageSource->sourceStreamPtr_.get()));
1287 
1288     PixelDecodeOptions decodeOpts;
1289     decodeOpts.desiredPixelFormat = PixelFormat::ARGB_8888;
1290     decodeOpts.editable = true;
1291     decodeOpts.desiredSize.width = IMAGE_INPUT_JPG_WIDTH / NUM_4;
1292     decodeOpts.desiredSize.height = IMAGE_INPUT_JPG_HEIGHT / NUM_4;
1293 
1294     PlImageInfo plInfo;
1295     errorCode = jpegDecoder->SetDecodeOptions(0, decodeOpts, plInfo);
1296     ASSERT_EQ(errorCode, SUCCESS);
1297     GTEST_LOG_(INFO) << "JpegDecoderTest: SetDecodeOptionsTest006 end";
1298 }
1299 
1300 /**
1301  * @tc.name: JpegDecoderTest_DecodeTest003
1302  * @tc.desc: Verify that JpegDecoder decodes image and using DMA_ALLOC allocator type.
1303  * @tc.type: FUNC
1304  */
1305 HWTEST_F(JpegDecoderTest, DecodeTest003, TestSize.Level3)
1306 {
1307     GTEST_LOG_(INFO) << "JpegDecoderTest: DecodeTest003 start";
1308     auto jpegDecoder = std::make_shared<JpegDecoder>();
1309     ASSERT_NE(jpegDecoder, nullptr);
1310     uint32_t errorCode = -1;
1311     SourceOptions sourceOpts;
1312     sourceOpts.formatHint = "image/jpeg";
1313     std::unique_ptr<ImageSource> imageSource =
1314         ImageSource::CreateImageSource(IMAGE_INPUT_JPG_PATH, sourceOpts, errorCode);
1315     ASSERT_NE(imageSource, nullptr);
1316     ASSERT_EQ(errorCode, SUCCESS);
1317     jpegDecoder->SetSource(*(imageSource->sourceStreamPtr_.get()));
1318 
1319     PixelDecodeOptions decodeOpts;
1320     decodeOpts.desiredPixelFormat = PixelFormat::RGBA_8888;
1321     decodeOpts.editable = true;
1322     decodeOpts.desiredSize.width = IMAGE_INPUT_JPG_WIDTH;
1323     decodeOpts.desiredSize.height = IMAGE_INPUT_JPG_HEIGHT;
1324     PlImageInfo plInfo;
1325 
1326     errorCode = jpegDecoder->SetDecodeOptions(0, decodeOpts, plInfo);
1327     ASSERT_EQ(errorCode, SUCCESS);
1328 
1329     DecodeContext decodeContext;
1330     decodeContext.allocatorType = AllocatorType::DMA_ALLOC;
1331     errorCode = jpegDecoder->Decode(0, decodeContext);
1332     ASSERT_EQ(errorCode, SUCCESS);
1333     GTEST_LOG_(INFO) << "JpegDecoderTest: DecodeTest003 end";
1334 }
1335 
1336 /**
1337  * @tc.name: JpegDecoderTest_DecodeTest004
1338  * @tc.desc: Verify that JpegDecoder decodes image double.
1339  * @tc.type: FUNC
1340  */
1341 HWTEST_F(JpegDecoderTest, DecodeTest004, TestSize.Level3)
1342 {
1343     GTEST_LOG_(INFO) << "JpegDecoderTest: DecodeTest004 start";
1344     auto jpegDecoder = std::make_shared<JpegDecoder>();
1345     ASSERT_NE(jpegDecoder, nullptr);
1346     uint32_t errorCode = -1;
1347     SourceOptions sourceOpts;
1348     sourceOpts.formatHint = "image/jpeg";
1349     std::unique_ptr<ImageSource> imageSource =
1350         ImageSource::CreateImageSource(IMAGE_INPUT_JPG_PATH, sourceOpts, errorCode);
1351     ASSERT_NE(imageSource, nullptr);
1352     ASSERT_EQ(errorCode, SUCCESS);
1353     jpegDecoder->SetSource(*(imageSource->sourceStreamPtr_.get()));
1354 
1355     PixelDecodeOptions decodeOpts;
1356     decodeOpts.desiredPixelFormat = PixelFormat::RGBA_8888;
1357     decodeOpts.editable = true;
1358     decodeOpts.desiredSize.width = IMAGE_INPUT_JPG_WIDTH;
1359     decodeOpts.desiredSize.height = IMAGE_INPUT_JPG_HEIGHT;
1360 
1361     PlImageInfo plInfo;
1362     errorCode = jpegDecoder->SetDecodeOptions(0, decodeOpts, plInfo);
1363     ASSERT_EQ(errorCode, SUCCESS);
1364 
1365     DecodeContext decodeContext;
1366     decodeContext.allocatorType = AllocatorType::HEAP_ALLOC;
1367     errorCode = jpegDecoder->Decode(0, decodeContext);
1368     ASSERT_EQ(errorCode, SUCCESS);
1369 
1370     DecodeContext decodeContext_double;
1371     errorCode = jpegDecoder->Decode(0, decodeContext_double);
1372     ASSERT_EQ(errorCode, SUCCESS);
1373     GTEST_LOG_(INFO) << "JpegDecoderTest: DecodeTest004 end";
1374 }
1375 
1376 /**
1377  * @tc.name: JpegDecoderTest_DecodeTest005
1378  * @tc.desc: Verify that JpegDecoder decodes image double.
1379  * @tc.type: FUNC
1380  */
1381 HWTEST_F(JpegDecoderTest, DecodeTest005, TestSize.Level3)
1382 {
1383     GTEST_LOG_(INFO) << "JpegDecoderTest: DecodeTest005 start";
1384     auto jpegDecoder = std::make_shared<JpegDecoder>();
1385     ASSERT_NE(jpegDecoder, nullptr);
1386     uint32_t errorCode = -1;
1387     SourceOptions sourceOpts;
1388     sourceOpts.formatHint = "image/jpeg";
1389     std::unique_ptr<ImageSource> imageSource =
1390         ImageSource::CreateImageSource(IMAGE_INPUT_JPG_PATH, sourceOpts, errorCode);
1391     ASSERT_NE(imageSource, nullptr);
1392     ASSERT_EQ(errorCode, SUCCESS);
1393     jpegDecoder->SetSource(*(imageSource->sourceStreamPtr_.get()));
1394 
1395     PixelDecodeOptions decodeOpts;
1396     decodeOpts.desiredPixelFormat = PixelFormat::RGBA_8888;
1397     decodeOpts.editable = true;
1398     decodeOpts.desiredSize.width = IMAGE_INPUT_JPG_WIDTH;
1399     decodeOpts.desiredSize.height = IMAGE_INPUT_JPG_HEIGHT;
1400 
1401     PlImageInfo plInfo;
1402     errorCode = jpegDecoder->SetDecodeOptions(0, decodeOpts, plInfo);
1403     ASSERT_EQ(errorCode, SUCCESS);
1404 
1405     DecodeContext decodeContext;
1406     decodeContext.allocatorType = AllocatorType::HEAP_ALLOC;
1407     std::map<std::string, MultimediaPlugin::AttrData> capabilites;
1408     capabilites.insert(std::map<std::string, MultimediaPlugin::AttrData>::value_type("encodeFormat",
1409         MultimediaPlugin::AttrData(sourceOpts.formatHint)));
1410     jpegDecoder->hwJpegDecompress_ = JpegDecoder::pluginServer_.CreateObject<AbsImageDecompressComponent>(
1411         AbsImageDecompressComponent::SERVICE_DEFAULT, capabilites);
1412     errorCode = jpegDecoder->Decode(0, decodeContext);
1413     ASSERT_EQ(errorCode, SUCCESS);
1414 
1415     DecodeContext decodeContext_double;
1416     errorCode = jpegDecoder->Decode(0, decodeContext_double);
1417     ASSERT_EQ(errorCode, SUCCESS);
1418     GTEST_LOG_(INFO) << "JpegDecoderTest: DecodeTest005 end";
1419 }
1420 
1421 /**
1422  * @tc.name: JpegDecoderTest_StartDecompressTest001
1423  * @tc.desc: Verify that JpegDecoder call StartDecompress jpeg_color_space == JCS_CMYK and
1424  *           desiredPixelFormat == PixelFormat::ALPHA_8.
1425  * @tc.type: FUNC
1426  */
1427 HWTEST_F(JpegDecoderTest, StartDecompressTest001, TestSize.Level3)
1428 {
1429     GTEST_LOG_(INFO) << "JpegDecoderTest: StartDecompressTest001 start";
1430     auto jpegDecoder = std::make_shared<JpegDecoder>();
1431     ASSERT_NE(jpegDecoder, nullptr);
1432     uint32_t errorCode = -1;
1433     SourceOptions sourceOpts;
1434     sourceOpts.formatHint = "image/jpeg";
1435     std::unique_ptr<ImageSource> imageSource =
1436         ImageSource::CreateImageSource(IMAGE_INPUT_JPG_PATH, sourceOpts, errorCode);
1437     ASSERT_NE(imageSource, nullptr);
1438     ASSERT_EQ(errorCode, SUCCESS);
1439     jpegDecoder->SetSource(*(imageSource->sourceStreamPtr_.get()));
1440 
1441     PixelDecodeOptions decodeOpts;
1442     decodeOpts.desiredPixelFormat = PixelFormat::ALPHA_8;
1443     decodeOpts.editable = true;
1444     decodeOpts.desiredSize.width = IMAGE_INPUT_JPG_WIDTH;
1445     decodeOpts.desiredSize.height = IMAGE_INPUT_JPG_HEIGHT;
1446 
1447     jpegDecoder->CreateDecoder();
1448     jpegDecoder->decodeInfo_.jpeg_color_space = JCS_CMYK;
1449     errorCode = jpegDecoder->StartDecompress(decodeOpts);
1450     ASSERT_EQ(errorCode, ERR_IMAGE_UNKNOWN_FORMAT);
1451     GTEST_LOG_(INFO) << "JpegDecoderTest: StartDecompressTest001 end";
1452 }
1453 
1454 /**
1455  * @tc.name: JpegDecoderTest_FormatTimeStampTest002
1456  * @tc.desc: Verify that JpegDecoder call FormatTimeStamp when input is all numbers.
1457  * @tc.type: FUNC
1458  */
1459 HWTEST_F(JpegDecoderTest, FormatTimeStampTest002, TestSize.Level3)
1460 {
1461     GTEST_LOG_(INFO) << "JpegDecoderTest: FormatTimeStampTest002 start";
1462     auto jpegDecoder = std::make_shared<JpegDecoder>();
1463     ASSERT_NE(jpegDecoder, nullptr);
1464     std::string src{"123456789"}, des;
1465     jpegDecoder->FormatTimeStamp(des, src);
1466     src += "-01-01 00:00:00";
1467     ASSERT_EQ(des, src);
1468     GTEST_LOG_(INFO) << "JpegDecoderTest: FormatTimeStampTest002 end";
1469 }
1470 
1471 /**
1472  * @tc.name: JpegDecoderTest_FormatTimeStampTest003
1473  * @tc.desc: Verify that JpegDecoder call FormatTimeStamp when input is 123456789-.
1474  * @tc.type: FUNC
1475  */
1476 HWTEST_F(JpegDecoderTest, FormatTimeStampTest003, TestSize.Level3)
1477 {
1478     GTEST_LOG_(INFO) << "JpegDecoderTest: FormatTimeStampTest003 start";
1479     auto jpegDecoder = std::make_shared<JpegDecoder>();
1480     ASSERT_NE(jpegDecoder, nullptr);
1481     std::string src{"123456789-"}, des;
1482     jpegDecoder->FormatTimeStamp(des, src);
1483     src = "123456789--01 00:00:00";
1484     ASSERT_EQ(des, src);
1485     GTEST_LOG_(INFO) << "JpegDecoderTest: FormatTimeStampTest003 end";
1486 }
1487 
1488 /**
1489  * @tc.name: JpegDecoderTest_FormatTimeStampTest004
1490  * @tc.desc: Verify that JpegDecoder call FormatTimeStamp when input is 12345 6789.
1491  * @tc.type: FUNC
1492  */
1493 HWTEST_F(JpegDecoderTest, FormatTimeStampTest004, TestSize.Level3)
1494 {
1495     GTEST_LOG_(INFO) << "JpegDecoderTest: FormatTimeStampTest004 start";
1496     auto jpegDecoder = std::make_shared<JpegDecoder>();
1497     ASSERT_NE(jpegDecoder, nullptr);
1498     std::string src{"12345 6789"}, des;
1499     jpegDecoder->FormatTimeStamp(des, src);
1500     src = "12345-01-01 6789:00:00";
1501     ASSERT_EQ(des, src);
1502     GTEST_LOG_(INFO) << "JpegDecoderTest: FormatTimeStampTest004 end";
1503 }
1504 
1505 /**
1506  * @tc.name: JpegDecoderTest_FormatTimeStampTest005
1507  * @tc.desc: Verify that JpegDecoder call FormatTimeStamp when input is 123-45 6789:.
1508  * @tc.type: FUNC
1509  */
1510 HWTEST_F(JpegDecoderTest, FormatTimeStampTest005, TestSize.Level3)
1511 {
1512     GTEST_LOG_(INFO) << "JpegDecoderTest: FormatTimeStampTest005 start";
1513     auto jpegDecoder = std::make_shared<JpegDecoder>();
1514     ASSERT_NE(jpegDecoder, nullptr);
1515     std::string src{"123-45 6789:"}, des;
1516     jpegDecoder->FormatTimeStamp(des, src);
1517     src = "123-45-01 6789::00";
1518     ASSERT_EQ(des, src);
1519     GTEST_LOG_(INFO) << "JpegDecoderTest: FormatTimeStampTest005 end";
1520 }
1521 
1522 /**
1523  * @tc.name: JpegDecoderTest_GetFilterAreaTest002
1524  * @tc.desc: Verify that JpegDecoder call GetFileterArea.
1525  * @tc.type: FUNC
1526  */
1527 HWTEST_F(JpegDecoderTest, GetFilterAreaTest002, TestSize.Level3)
1528 {
1529     GTEST_LOG_(INFO) << "JpegDecoderTest: GetFilterAreaTest002 start";
1530     uint32_t errorCode = -1;
1531     auto jpegDecoder = std::make_shared<JpegDecoder>();
1532     ASSERT_NE(jpegDecoder, nullptr);
1533     SourceOptions sourceOpts;
1534     sourceOpts.formatHint = "image/jpeg";
1535     std::unique_ptr<ImageSource> imageSource =
1536         ImageSource::CreateImageSource(IMAGE_INPUT_EXIF_PATH, sourceOpts, errorCode);
1537     ASSERT_NE(imageSource, nullptr);
1538     ASSERT_EQ(errorCode, SUCCESS);
1539     jpegDecoder->SetSource(*(imageSource->sourceStreamPtr_.get()));
1540 
1541     int privacyType = PERMISSION_GPS_TYPE;
1542     std::vector<std::pair<uint32_t, uint32_t>> ranges;
1543     errorCode = jpegDecoder->GetFilterArea(privacyType, ranges);
1544     ASSERT_EQ(errorCode, SUCCESS);
1545     GTEST_LOG_(INFO) << "JpegDecoderTest: GetFilterAreaTest002 end";
1546 }
1547 
1548 /**
1549  * @tc.name: JpegDecoderTest_ModifyImagePropertyTest007
1550  * @tc.desc: Verify that JpegDecoder call ModifyImageProperty.
1551  * @tc.type: FUNC
1552  */
1553 HWTEST_F(JpegDecoderTest, ModifyImagePropertyTest007, TestSize.Level3)
1554 {
1555     GTEST_LOG_(INFO) << "JpegDecoderTest: ModifyImagePropertyTest007 start";
1556     uint32_t errorCode = -1;
1557     auto jpegDecoder = std::make_shared<JpegDecoder>();
1558     ASSERT_NE(jpegDecoder, nullptr);
1559     SourceOptions sourceOpts;
1560     sourceOpts.formatHint = "image/jpeg";
1561     std::unique_ptr<ImageSource> imageSource =
1562         ImageSource::CreateImageSource(IMAGE_INPUT_EXIF_PATH, sourceOpts, errorCode);
1563     ASSERT_NE(imageSource, nullptr);
1564     ASSERT_EQ(errorCode, SUCCESS);
1565     jpegDecoder->SetSource(*(imageSource->sourceStreamPtr_.get()));
1566 
1567     std::string key{SCENE_TYPE}, value{"t"};
1568     errorCode = jpegDecoder->ModifyImageProperty(0, key, value,
1569         imageSource->sourceStreamPtr_->GetDataPtr(), imageSource->sourceStreamPtr_->GetStreamSize());
1570     ASSERT_EQ(errorCode, SUCCESS);
1571 
1572     errorCode = jpegDecoder->exifInfo_.ModifyExifData(key, value,
1573         imageSource->sourceStreamPtr_->GetDataPtr(), imageSource->sourceStreamPtr_->GetStreamSize());
1574     ASSERT_EQ(errorCode, SUCCESS);
1575     GTEST_LOG_(INFO) << "JpegDecoderTest: ModifyImagePropertyTest007 end";
1576 }
1577 
1578 /**
1579  * @tc.name: JpegDecoderTest_ModifyImagePropertyTest008
1580  * @tc.desc: Verify that JpegDecoder call ModifyImageProperty.
1581  * @tc.type: FUNC
1582  */
1583 HWTEST_F(JpegDecoderTest, ModifyImagePropertyTest008, TestSize.Level3)
1584 {
1585     GTEST_LOG_(INFO) << "JpegDecoderTest: ModifyImagePropertyTest008 start";
1586     uint32_t errorCode = -1;
1587     auto jpegDecoder = std::make_shared<JpegDecoder>();
1588     ASSERT_NE(jpegDecoder, nullptr);
1589 
1590     std::string key{SCENE_TYPE}, value{"t"};
1591     uint8_t* data = nullptr;
1592     uint32_t size = 0;
1593 
1594     errorCode = jpegDecoder->ModifyImageProperty(0, key, value, data, size);
1595     ASSERT_EQ(errorCode, ERR_IMAGE_SOURCE_DATA);
1596     GTEST_LOG_(INFO) << "JpegDecoderTest: ModifyImagePropertyTest008 end";
1597 }
1598 
1599 /**
1600  * @tc.name: JpegDecoderTest_ModifyImagePropertyTest009
1601  * @tc.desc: Verify that JpegDecoder call ModifyImageProperty.
1602  * @tc.type: FUNC
1603  */
1604 HWTEST_F(JpegDecoderTest, ModifyImagePropertyTest009, TestSize.Level3)
1605 {
1606     GTEST_LOG_(INFO) << "JpegDecoderTest: ModifyImagePropertyTest009 start";
1607     uint32_t errorCode = -1;
1608     auto jpegDecoder = std::make_shared<JpegDecoder>();
1609     ASSERT_NE(jpegDecoder, nullptr);
1610 
1611     std::string key{SCENE_TYPE}, value{"t"};
1612     errorCode = jpegDecoder->ModifyImageProperty(0, key, value, IMAGE_INPUT_EXIF_PATH);
1613     ASSERT_EQ(errorCode, SUCCESS);
1614 
1615     errorCode = jpegDecoder->exifInfo_.ModifyExifData(key, value, IMAGE_INPUT_EXIF_PATH);
1616     ASSERT_EQ(errorCode, SUCCESS);
1617     GTEST_LOG_(INFO) << "JpegDecoderTest: ModifyImagePropertyTest009 end";
1618 }
1619 
1620 /**
1621  * @tc.name: JpegDecoderTest_ModifyImagePropertyTest010
1622  * @tc.desc: Verify that JpegDecoder call ModifyImageProperty.
1623  * @tc.type: FUNC
1624  */
1625 HWTEST_F(JpegDecoderTest, ModifyImagePropertyTest010, TestSize.Level3)
1626 {
1627     GTEST_LOG_(INFO) << "JpegDecoderTest: ModifyImagePropertyTest010 start";
1628     uint32_t errorCode = -1;
1629     auto jpegDecoder = std::make_shared<JpegDecoder>();
1630     ASSERT_NE(jpegDecoder, nullptr);
1631 
1632     std::string key{SCENE_TYPE}, value{"t"};
1633     int fd = open(IMAGE_INPUT_EXIF_PATH.c_str(), O_RDWR, S_IRUSR | S_IWUSR);
1634     bool exifOpenFailed = (fd < 0);
1635     ASSERT_EQ(exifOpenFailed, false);
1636 
1637     errorCode = jpegDecoder->ModifyImageProperty(0, key, value, fd);
1638     ASSERT_EQ(errorCode, SUCCESS);
1639 
1640     errorCode = jpegDecoder->exifInfo_.ModifyExifData(key, value, fd);
1641     ASSERT_EQ(errorCode, SUCCESS);
1642     GTEST_LOG_(INFO) << "JpegDecoderTest: ModifyImagePropertyTest010 end";
1643 }
1644 
1645 /**
1646  * @tc.name: JpegDecoderTest_ModifyImagePropertyTest011
1647  * @tc.desc: Verify that JpegDecoder call ModifyImageProperty that modify latitude property.
1648  * @tc.type: FUNC
1649  */
1650 HWTEST_F(JpegDecoderTest, ModifyImagePropertyTest011, TestSize.Level3)
1651 {
1652     GTEST_LOG_(INFO) << "JpegDecoderTest: ModifyImagePropertyTest011 start";
1653     uint32_t errorCode = -1;
1654     auto jpegDecoder = std::make_shared<JpegDecoder>();
1655     ASSERT_NE(jpegDecoder, nullptr);
1656 
1657     std::string key{GPS_LATITUDE}, value{"38,51,6"};
1658     errorCode = jpegDecoder->ModifyImageProperty(0, key, value, IMAGE_INPUT_EXIF_PATH);
1659     ASSERT_EQ(errorCode, SUCCESS);
1660     GTEST_LOG_(INFO) << "JpegDecoderTest: ModifyImagePropertyTest011 end";
1661 }
1662 
1663 /**
1664  * @tc.name: JpegDecoderTest_GetExifDataTest001
1665  * @tc.desc: Verify that JpegDecoder's exifInfo_ call GetExifData to get DATE_TIME_ORIGINAL_MEDIA.
1666  * @tc.type: FUNC
1667  */
1668 HWTEST_F(JpegDecoderTest, GetExifDataTest001, TestSize.Level3)
1669 {
1670     GTEST_LOG_(INFO) << "JpegDecoderTest: GetExifDataTest001 start";
1671     uint32_t errorCode = -1;
1672     auto jpegDecoder = std::make_shared<JpegDecoder>();
1673     ASSERT_NE(jpegDecoder, nullptr);
1674 
1675     errorCode = jpegDecoder->ModifyImageProperty(0, "DateTimeOriginal", "1234-5-6 12:00:00", IMAGE_INPUT_EXIF_PATH);
1676     std::string key{"DateTimeOriginalForMedia"}, value;
1677     errorCode = jpegDecoder->exifInfo_.GetExifData(key, value);
1678     ASSERT_EQ(errorCode, SUCCESS);
1679     GTEST_LOG_(INFO) << "JpegDecoderTest: GetExifDataTest001 end";
1680 }
1681 
1682 /**
1683  * @tc.name: JpegDecoderTest_GetExifDataTest002
1684  * @tc.desc: Verify that JpegDecoder's exifInfo_ call GetExifData to get TAG_ORIENTATION_INT.
1685  * @tc.type: FUNC
1686  */
1687 HWTEST_F(JpegDecoderTest, GetExifDataTest002, TestSize.Level3)
1688 {
1689     GTEST_LOG_(INFO) << "JpegDecoderTest: GetExifDataTest002 start";
1690     uint32_t errorCode = -1;
1691     auto jpegDecoder = std::make_shared<JpegDecoder>();
1692     ASSERT_NE(jpegDecoder, nullptr);
1693 
1694     errorCode = jpegDecoder->ModifyImageProperty(0, "Orientation", "Right-top", IMAGE_INPUT_EXIF_PATH);
1695     std::string key{"OrientationInt"}, value;
1696     errorCode = jpegDecoder->exifInfo_.GetExifData(key, value);
1697     ASSERT_EQ(errorCode, ERR_IMAGE_DECODE_EXIF_UNSUPPORT);
1698     GTEST_LOG_(INFO) << "JpegDecoderTest: GetExifDataTest002 end";
1699 }
1700 
1701 /**
1702  * @tc.name: CheckInputDataValidTest001
1703  * @tc.desc: Verify JPEG header validation logic. Test cases: null buffer, size=0, invalid magic bytes,
1704  *           valid magic bytes.
1705  * @tc.type: FUNC
1706  */
1707 HWTEST_F(JpegDecoderTest, CheckInputDataValidTest001, TestSize.Level3)
1708 {
1709     GTEST_LOG_(INFO) << "JpegDecoderTest: CheckInputDataValidTest001 start";
1710     EXIFInfo exifInfo;
1711     uint32_t result = exifInfo.CheckInputDataValid(nullptr, 10);
1712     EXPECT_EQ(result, Media::ERR_IMAGE_SOURCE_DATA);
1713     unsigned char dummy[2] = {0xFF, 0xD8};
1714     result = exifInfo.CheckInputDataValid(dummy, 0);
1715     EXPECT_EQ(result, Media::ERR_MEDIA_BUFFER_TOO_SMALL);
1716     unsigned char notFFButD8[2] = {0x00, 0xD8};
1717     result = exifInfo.CheckInputDataValid(notFFButD8, 2);
1718     EXPECT_EQ(result, Media::ERR_IMAGE_MISMATCHED_FORMAT);
1719     unsigned char ffButNotD8[2] = {0xFF, 0x00};
1720     result = exifInfo.CheckInputDataValid(ffButNotD8, 2);
1721     EXPECT_EQ(result, Media::ERR_IMAGE_MISMATCHED_FORMAT);
1722     unsigned char notFFAndNotD8[2] = {0x00, 0x00};
1723     result = exifInfo.CheckInputDataValid(notFFAndNotD8, 2);
1724     EXPECT_EQ(result, Media::ERR_IMAGE_MISMATCHED_FORMAT);
1725     unsigned char validJpeg[2] = {0xFF, 0xD8};
1726     result = exifInfo.CheckInputDataValid(validJpeg, 2);
1727     EXPECT_EQ(result, Media::SUCCESS);
1728     GTEST_LOG_(INFO) << "JpegDecoderTest: CheckInputDataValidTest001 end";
1729 }
1730 
1731 /**
1732  * @tc.name: CreateExifDataTest001
1733  * @tc.desc: Verify EXIF data creation logic. Test cases: null input, buffer with "Exif" tag, buffer without "Exif" tag
1734  *           (auto-create new EXIF data).
1735  * @tc.type: FUNC
1736  */
1737 HWTEST_F(JpegDecoderTest, CreateExifDataTest001, TestSize.Level3)
1738 {
1739     GTEST_LOG_(INFO) << "JpegDecoderTest: CreateExifDataTest001 start";
1740     EXIFInfo exifInfo;
1741     ExifData* ptrData = nullptr;
1742     bool isNewExifData = false;
1743     bool ret = exifInfo.CreateExifData(nullptr, 10, &ptrData, isNewExifData);
1744     EXPECT_FALSE(ret);
1745     unsigned char bufExif[16] = {0};
1746     bufExif[6] = 'E'; bufExif[7] = 'x'; bufExif[8] = 'i'; bufExif[9] = 'f';
1747     ret = exifInfo.CreateExifData(bufExif, 16, &ptrData, isNewExifData);
1748     EXPECT_TRUE(ret);
1749     ptrData = nullptr;
1750     ret = exifInfo.CreateExifData(bufExif, 16, &ptrData, isNewExifData);
1751     EXPECT_TRUE(ret);
1752     EXPECT_FALSE(isNewExifData);
1753     unsigned char bufNoExif[16] = {0};
1754     ptrData = nullptr;
1755     ret = exifInfo.CreateExifData(bufNoExif, 16, &ptrData, isNewExifData);
1756     EXPECT_TRUE(ret);
1757     ptrData = nullptr;
1758     ret = exifInfo.CreateExifData(bufNoExif, 16, &ptrData, isNewExifData);
1759     EXPECT_TRUE(ret);
1760     EXPECT_TRUE(isNewExifData);
1761     GTEST_LOG_(INFO) << "JpegDecoderTest: CreateExifDataTest001 end";
1762 }
1763 }
1764 }