• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 #include <gtest/gtest.h>
16 #include "buffer_source_stream.h"
17 #include "exif_info.h"
18 #include "image_packer.h"
19 #include "jpeg_decoder.h"
20 
21 using namespace testing::ext;
22 using namespace OHOS::Media;
23 namespace OHOS {
24 namespace ImagePlugin {
25 static constexpr size_t STREAM_SIZE_ONE = 1;
26 static constexpr size_t STREAM_SIZE_TWO = 2;
27 static constexpr size_t STREAM_SIZE = 1000;
28 const std::string COMPRESSED_BITS_PER_PIXEL = "CompressedBitsPerPixel";
29 const std::string DATE_TIME = "DateTime";
30 const std::string GPS_TIME_STAMP = "GPSTimeStamp";
31 const std::string GPS_DATE_STAMP = "GPSDateStamp";
32 const std::string IMAGE_DESCRIPTION = "ImageDescription";
33 const std::string MAKE = "Make";
34 const std::string MODEL = "Model";
35 const std::string PHOTO_MODE = "PhotoMode";
36 const std::string SENSITIVITY_TYPE = "SensitivityType";
37 const std::string STANDARD_OUTPUT_SENSITIVITY = "StandardOutputSensitivity";
38 const std::string RECOMMENDED_EXPOSURE_INDEX = "RecommendedExposureIndex";
39 const std::string ISO_SPEED = "ISOSpeedRatings";
40 const std::string APERTURE_VALUE = "ApertureValue";
41 const std::string EXPOSURE_BIAS_VALUE = "ExposureBiasValue";
42 const std::string METERING_MODE = "MeteringMode";
43 const std::string LIGHT_SOURCE = "LightSource";
44 const std::string FLASH = "Flash";
45 const std::string FOCAL_LENGTH = "FocalLength";
46 const std::string USER_COMMENT = "UserComment";
47 const std::string PIXEL_X_DIMENSION = "PixelXDimension";
48 const std::string PIXEL_Y_DIMENSION = "PixelYDimension";
49 const std::string WHITE_BALANCE = "WhiteBalance";
50 const std::string FOCAL_LENGTH_IN_35_MM_FILM = "FocalLengthIn35mmFilm";
51 const std::string HW_MNOTE_CAPTURE_MODE = "HwMnoteCaptureMode";
52 const std::string HW_MNOTE_PHYSICAL_APERTURE = "HwMnotePhysicalAperture";
53 class JpegDecoderTest : public testing::Test {
54 public:
JpegDecoderTest()55     JpegDecoderTest() {}
~JpegDecoderTest()56     ~JpegDecoderTest() {}
57 };
58 
59 class MockInputDataStream : public SourceStream {
60 public:
61     MockInputDataStream() = default;
62 
UpdateData(const uint8_t * data,uint32_t size,bool isCompleted)63     uint32_t UpdateData(const uint8_t *data, uint32_t size, bool isCompleted) override
64     {
65         return ERR_IMAGE_DATA_UNSUPPORT;
66     }
Read(uint32_t desiredSize,DataStreamBuffer & outData)67     bool Read(uint32_t desiredSize, DataStreamBuffer &outData) override
68     {
69         if (streamSize == STREAM_SIZE_ONE) {
70             streamBuffer = std::make_shared<uint8_t>(streamSize);
71             outData.inputStreamBuffer = streamBuffer.get();
72         } else if (streamSize == STREAM_SIZE_TWO) {
73             outData.dataSize = streamSize;
74         }
75         return returnValue_;
76     }
77 
Read(uint32_t desiredSize,uint8_t * outBuffer,uint32_t bufferSize,uint32_t & readSize)78     bool Read(uint32_t desiredSize, uint8_t *outBuffer, uint32_t bufferSize, uint32_t &readSize) override
79     {
80         return returnValue_;
81     }
82 
Peek(uint32_t desiredSize,DataStreamBuffer & outData)83     bool Peek(uint32_t desiredSize, DataStreamBuffer &outData) override
84     {
85         return returnValue_;
86     }
87 
Peek(uint32_t desiredSize,uint8_t * outBuffer,uint32_t bufferSize,uint32_t & readSize)88     bool Peek(uint32_t desiredSize, uint8_t *outBuffer, uint32_t bufferSize, uint32_t &readSize) override
89     {
90         return returnValue_;
91     }
92 
Tell()93     uint32_t Tell() override
94     {
95         return 0;
96     }
97 
Seek(uint32_t position)98     bool Seek(uint32_t position) override
99     {
100         return returnValue_;
101     }
102 
GetStreamType()103     uint32_t GetStreamType()
104     {
105         return -1;
106     }
107 
GetDataPtr()108     uint8_t *GetDataPtr()
109     {
110         return nullptr;
111     }
112 
IsStreamCompleted()113     bool IsStreamCompleted()
114     {
115         return returnValue_;
116     }
117 
GetStreamSize()118     size_t GetStreamSize()
119     {
120         return streamSize;
121     }
122 
SetReturn(bool returnValue)123     void SetReturn(bool returnValue)
124     {
125         returnValue_ = returnValue;
126     }
127 
SetStreamSize(size_t size)128     void SetStreamSize(size_t size)
129     {
130         streamSize = size;
131     }
132 
~MockInputDataStream()133     ~MockInputDataStream() {}
134 private:
135     bool returnValue_ = false;
136     size_t streamSize = 0;
137     std::shared_ptr<uint8_t> streamBuffer = nullptr;
138 };
139 
140 /**
141  * @tc.name: GetImagePropertyStringTest016
142  * @tc.desc: Test of GetImagePropertyString
143  * @tc.type: FUNC
144  */
145 HWTEST_F(JpegDecoderTest, GetImagePropertyStringTest016, TestSize.Level3)
146 {
147     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest016 start";
148     auto jpegDecoder = std::make_shared<JpegDecoder>();
149     int size = STREAM_SIZE;
150     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
151     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
152     jpegDecoder->SetSource(*streamPtr.release());
153     std::string key = COMPRESSED_BITS_PER_PIXEL;
154     std::string value = "";
155     EXIFInfo exifInfo_;
156     jpegDecoder->GetImagePropertyString(0, key, value);
157     ASSERT_EQ(value, exifInfo_.compressedBitsPerPixel_);
158     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest016 end";
159 }
160 
161 /**
162  * @tc.name: GetImagePropertyStringTest017
163  * @tc.desc: Test of GetImagePropertyString
164  * @tc.type: FUNC
165  */
166 HWTEST_F(JpegDecoderTest, GetImagePropertyStringTest017, TestSize.Level3)
167 {
168     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest017 start";
169     auto jpegDecoder = std::make_shared<JpegDecoder>();
170     int size = STREAM_SIZE;
171     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
172     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
173     jpegDecoder->SetSource(*streamPtr.release());
174     std::string key = DATE_TIME;
175     std::string value = "";
176     EXIFInfo exifInfo_;
177     jpegDecoder->GetImagePropertyString(0, key, value);
178     ASSERT_EQ(value, exifInfo_.dateTime_);
179     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest017 end";
180 }
181 
182 /**
183  * @tc.name: GetImagePropertyStringTest018
184  * @tc.desc: Test of GetImagePropertyString
185  * @tc.type: FUNC
186  */
187 HWTEST_F(JpegDecoderTest, GetImagePropertyStringTest018, TestSize.Level3)
188 {
189     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest018 start";
190     auto jpegDecoder = std::make_shared<JpegDecoder>();
191     int size = STREAM_SIZE;
192     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
193     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
194     jpegDecoder->SetSource(*streamPtr.release());
195     std::string key = GPS_TIME_STAMP;
196     std::string value = "";
197     EXIFInfo exifInfo_;
198     jpegDecoder->GetImagePropertyString(0, key, value);
199     ASSERT_EQ(value, exifInfo_.gpsTimeStamp_);
200     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest018 end";
201 }
202 
203 /**
204  * @tc.name: GetImagePropertyStringTest019
205  * @tc.desc: Test of GetImagePropertyString
206  * @tc.type: FUNC
207  */
208 HWTEST_F(JpegDecoderTest, GetImagePropertyStringTest019, TestSize.Level3)
209 {
210     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest019 start";
211     auto jpegDecoder = std::make_shared<JpegDecoder>();
212     int size = STREAM_SIZE;
213     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
214     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
215     jpegDecoder->SetSource(*streamPtr.release());
216     std::string key = GPS_DATE_STAMP;
217     std::string value = "";
218     EXIFInfo exifInfo_;
219     jpegDecoder->GetImagePropertyString(0, key, value);
220     ASSERT_EQ(value, exifInfo_.gpsDateStamp_);
221     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest019 end";
222 }
223 
224 /**
225  * @tc.name: GetImagePropertyStringTest020
226  * @tc.desc: Test of GetImagePropertyString
227  * @tc.type: FUNC
228  */
229 HWTEST_F(JpegDecoderTest, GetImagePropertyStringTest020, TestSize.Level3)
230 {
231     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest020 start";
232     auto jpegDecoder = std::make_shared<JpegDecoder>();
233     int size = STREAM_SIZE;
234     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
235     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
236     jpegDecoder->SetSource(*streamPtr.release());
237     std::string key = IMAGE_DESCRIPTION;
238     std::string value = "";
239     EXIFInfo exifInfo_;
240     jpegDecoder->GetImagePropertyString(0, key, value);
241     ASSERT_EQ(value, exifInfo_.imageDescription_);
242     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest020 end";
243 }
244 
245 /**
246  * @tc.name: GetImagePropertyStringTest021
247  * @tc.desc: Test of GetImagePropertyString
248  * @tc.type: FUNC
249  */
250 HWTEST_F(JpegDecoderTest, GetImagePropertyStringTest021, TestSize.Level3)
251 {
252     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest021 start";
253     auto jpegDecoder = std::make_shared<JpegDecoder>();
254     int size = STREAM_SIZE;
255     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
256     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
257     jpegDecoder->SetSource(*streamPtr.release());
258     std::string key = MAKE;
259     std::string value = "";
260     EXIFInfo exifInfo_;
261     jpegDecoder->GetImagePropertyString(0, key, value);
262     ASSERT_EQ(value, exifInfo_.make_);
263     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest021 end";
264 }
265 
266 /**
267  * @tc.name: GetImagePropertyStringTest022
268  * @tc.desc: Test of GetImagePropertyString
269  * @tc.type: FUNC
270  */
271 HWTEST_F(JpegDecoderTest, GetImagePropertyStringTest022, TestSize.Level3)
272 {
273     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest022 start";
274     auto jpegDecoder = std::make_shared<JpegDecoder>();
275     int size = STREAM_SIZE;
276     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
277     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
278     jpegDecoder->SetSource(*streamPtr.release());
279     std::string key = MODEL;
280     std::string value = "";
281     EXIFInfo exifInfo_;
282     jpegDecoder->GetImagePropertyString(0, key, value);
283     ASSERT_EQ(value, exifInfo_.model_);
284     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest022 end";
285 }
286 
287 /**
288  * @tc.name: GetImagePropertyStringTest023
289  * @tc.desc: Test of GetImagePropertyString
290  * @tc.type: FUNC
291  */
292 HWTEST_F(JpegDecoderTest, GetImagePropertyStringTest023, TestSize.Level3)
293 {
294     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest023 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     std::string key = PHOTO_MODE;
301     std::string value = "";
302     EXIFInfo exifInfo_;
303     jpegDecoder->GetImagePropertyString(0, key, value);
304     ASSERT_EQ(value, exifInfo_.photoMode_);
305     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest023 end";
306 }
307 
308 /**
309  * @tc.name: GetImagePropertyStringTest024
310  * @tc.desc: Test of GetImagePropertyString
311  * @tc.type: FUNC
312  */
313 HWTEST_F(JpegDecoderTest, GetImagePropertyStringTest024, TestSize.Level3)
314 {
315     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest024 start";
316     auto jpegDecoder = std::make_shared<JpegDecoder>();
317     int size = STREAM_SIZE;
318     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
319     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
320     jpegDecoder->SetSource(*streamPtr.release());
321     std::string key = SENSITIVITY_TYPE;
322     std::string value = "";
323     EXIFInfo exifInfo_;
324     jpegDecoder->GetImagePropertyString(0, key, value);
325     ASSERT_EQ(value, exifInfo_.sensitivityType_);
326     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest024 end";
327 }
328 
329 /**
330  * @tc.name: GetImagePropertyStringTest025
331  * @tc.desc: Test of GetImagePropertyString
332  * @tc.type: FUNC
333  */
334 HWTEST_F(JpegDecoderTest, GetImagePropertyStringTest025, TestSize.Level3)
335 {
336     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest025 start";
337     auto jpegDecoder = std::make_shared<JpegDecoder>();
338     int size = STREAM_SIZE;
339     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
340     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
341     jpegDecoder->SetSource(*streamPtr.release());
342     std::string key = STANDARD_OUTPUT_SENSITIVITY;
343     std::string value = "";
344     EXIFInfo exifInfo_;
345     jpegDecoder->GetImagePropertyString(0, key, value);
346     ASSERT_EQ(value, exifInfo_.standardOutputSensitivity_);
347     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest025 end";
348 }
349 
350 /**
351  * @tc.name: GetImagePropertyStringTest026
352  * @tc.desc: Test of GetImagePropertyString
353  * @tc.type: FUNC
354  */
355 HWTEST_F(JpegDecoderTest, GetImagePropertyStringTest026, TestSize.Level3)
356 {
357     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest026 start";
358     auto jpegDecoder = std::make_shared<JpegDecoder>();
359     int size = STREAM_SIZE;
360     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
361     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
362     jpegDecoder->SetSource(*streamPtr.release());
363     std::string key = RECOMMENDED_EXPOSURE_INDEX;
364     std::string value = "";
365     EXIFInfo exifInfo_;
366     jpegDecoder->GetImagePropertyString(0, key, value);
367     ASSERT_EQ(value, exifInfo_.recommendedExposureIndex_);
368     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest026 end";
369 }
370 
371 /**
372  * @tc.name: GetImagePropertyStringTest027
373  * @tc.desc: Test of GetImagePropertyString
374  * @tc.type: FUNC
375  */
376 HWTEST_F(JpegDecoderTest, GetImagePropertyStringTest027, TestSize.Level3)
377 {
378     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest027 start";
379     auto jpegDecoder = std::make_shared<JpegDecoder>();
380     int size = STREAM_SIZE;
381     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
382     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
383     jpegDecoder->SetSource(*streamPtr.release());
384     std::string key = APERTURE_VALUE;
385     std::string value = "";
386     EXIFInfo exifInfo_;
387     jpegDecoder->GetImagePropertyString(0, key, value);
388     ASSERT_EQ(value, exifInfo_.apertureValue_);
389     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest027 end";
390 }
391 
392 /**
393  * @tc.name: GetImagePropertyStringTest028
394  * @tc.desc: Test of GetImagePropertyString
395  * @tc.type: FUNC
396  */
397 HWTEST_F(JpegDecoderTest, GetImagePropertyStringTest028, TestSize.Level3)
398 {
399     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest028 start";
400     auto jpegDecoder = std::make_shared<JpegDecoder>();
401     int size = STREAM_SIZE;
402     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
403     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
404     jpegDecoder->SetSource(*streamPtr.release());
405     std::string key = EXPOSURE_BIAS_VALUE;
406     std::string value = "";
407     EXIFInfo exifInfo_;
408     jpegDecoder->GetImagePropertyString(0, key, value);
409     ASSERT_EQ(value, exifInfo_.exposureBiasValue_);
410     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest028 end";
411 }
412 
413 /**
414  * @tc.name: GetImagePropertyStringTest029
415  * @tc.desc: Test of GetImagePropertyString
416  * @tc.type: FUNC
417  */
418 HWTEST_F(JpegDecoderTest, GetImagePropertyStringTest029, TestSize.Level3)
419 {
420     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest029 start";
421     auto jpegDecoder = std::make_shared<JpegDecoder>();
422     int size = STREAM_SIZE;
423     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
424     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
425     jpegDecoder->SetSource(*streamPtr.release());
426     std::string key = METERING_MODE;
427     std::string value = "";
428     EXIFInfo exifInfo_;
429     jpegDecoder->GetImagePropertyString(0, key, value);
430     ASSERT_EQ(value, exifInfo_.meteringMode_);
431     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest029 end";
432 }
433 
434 /**
435  * @tc.name: GetImagePropertyStringTest030
436  * @tc.desc: Test of GetImagePropertyString
437  * @tc.type: FUNC
438  */
439 HWTEST_F(JpegDecoderTest, GetImagePropertyStringTest030, TestSize.Level3)
440 {
441     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest030 start";
442     auto jpegDecoder = std::make_shared<JpegDecoder>();
443     int size = STREAM_SIZE;
444     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
445     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
446     jpegDecoder->SetSource(*streamPtr.release());
447     std::string key = LIGHT_SOURCE;
448     std::string value = "";
449     EXIFInfo exifInfo_;
450     jpegDecoder->GetImagePropertyString(0, key, value);
451     ASSERT_EQ(value, exifInfo_.lightSource_);
452     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest030 end";
453 }
454 
455 /**
456  * @tc.name: GetImagePropertyStringTest031
457  * @tc.desc: Test of GetImagePropertyString
458  * @tc.type: FUNC
459  */
460 HWTEST_F(JpegDecoderTest, GetImagePropertyStringTest031, TestSize.Level3)
461 {
462     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest031 start";
463     auto jpegDecoder = std::make_shared<JpegDecoder>();
464     int size = STREAM_SIZE;
465     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
466     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
467     jpegDecoder->SetSource(*streamPtr.release());
468     std::string key = FLASH;
469     std::string value = "";
470     EXIFInfo exifInfo_;
471     jpegDecoder->GetImagePropertyString(0, key, value);
472     ASSERT_EQ(value, exifInfo_.flash_);
473     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest031 end";
474 }
475 
476 /**
477  * @tc.name: GetImagePropertyStringTest032
478  * @tc.desc: Test of GetImagePropertyString
479  * @tc.type: FUNC
480  */
481 HWTEST_F(JpegDecoderTest, GetImagePropertyStringTest032, TestSize.Level3)
482 {
483     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest032 start";
484     auto jpegDecoder = std::make_shared<JpegDecoder>();
485     int size = STREAM_SIZE;
486     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
487     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
488     jpegDecoder->SetSource(*streamPtr.release());
489     std::string key = FOCAL_LENGTH;
490     std::string value = "";
491     EXIFInfo exifInfo_;
492     jpegDecoder->GetImagePropertyString(0, key, value);
493     ASSERT_EQ(value, exifInfo_.focalLength_);
494     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest032 end";
495 }
496 
497 /**
498  * @tc.name: GetImagePropertyStringTest033
499  * @tc.desc: Test of GetImagePropertyString
500  * @tc.type: FUNC
501  */
502 HWTEST_F(JpegDecoderTest, GetImagePropertyStringTest033, TestSize.Level3)
503 {
504     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest033 start";
505     auto jpegDecoder = std::make_shared<JpegDecoder>();
506     int size = STREAM_SIZE;
507     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
508     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
509     jpegDecoder->SetSource(*streamPtr.release());
510     std::string key = USER_COMMENT;
511     std::string value = "";
512     EXIFInfo exifInfo_;
513     jpegDecoder->GetImagePropertyString(0, key, value);
514     ASSERT_EQ(value, exifInfo_.userComment_);
515     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest033 end";
516 }
517 
518 /**
519  * @tc.name: GetImagePropertyStringTest034
520  * @tc.desc: Test of GetImagePropertyString
521  * @tc.type: FUNC
522  */
523 HWTEST_F(JpegDecoderTest, GetImagePropertyStringTest034, TestSize.Level3)
524 {
525     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest034 start";
526     auto jpegDecoder = std::make_shared<JpegDecoder>();
527     int size = STREAM_SIZE;
528     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
529     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
530     jpegDecoder->SetSource(*streamPtr.release());
531     std::string key = PIXEL_X_DIMENSION;
532     std::string value = "";
533     EXIFInfo exifInfo_;
534     jpegDecoder->GetImagePropertyString(0, key, value);
535     ASSERT_EQ(value, exifInfo_.pixelXDimension_);
536     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest034 end";
537 }
538 
539 /**
540  * @tc.name: GetImagePropertyStringTest035
541  * @tc.desc: Test of GetImagePropertyString
542  * @tc.type: FUNC
543  */
544 HWTEST_F(JpegDecoderTest, GetImagePropertyStringTest035, TestSize.Level3)
545 {
546     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest035 start";
547     auto jpegDecoder = std::make_shared<JpegDecoder>();
548     int size = STREAM_SIZE;
549     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
550     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
551     jpegDecoder->SetSource(*streamPtr.release());
552     std::string key = PIXEL_Y_DIMENSION;
553     std::string value = "";
554     EXIFInfo exifInfo_;
555     jpegDecoder->GetImagePropertyString(0, key, value);
556     ASSERT_EQ(value, exifInfo_.pixelYDimension_);
557     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest035 end";
558 }
559 
560 /**
561  * @tc.name: GetImagePropertyStringTest036
562  * @tc.desc: Test of GetImagePropertyString
563  * @tc.type: FUNC
564  */
565 HWTEST_F(JpegDecoderTest, GetImagePropertyStringTest036, TestSize.Level3)
566 {
567     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest036 start";
568     auto jpegDecoder = std::make_shared<JpegDecoder>();
569     int size = STREAM_SIZE;
570     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
571     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
572     jpegDecoder->SetSource(*streamPtr.release());
573     std::string key = WHITE_BALANCE;
574     std::string value = "";
575     EXIFInfo exifInfo_;
576     jpegDecoder->GetImagePropertyString(0, key, value);
577     ASSERT_EQ(value, exifInfo_.whiteBalance_);
578     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest036 end";
579 }
580 
581 /**
582  * @tc.name: GetImagePropertyStringTest037
583  * @tc.desc: Test of GetImagePropertyString
584  * @tc.type: FUNC
585  */
586 HWTEST_F(JpegDecoderTest, GetImagePropertyStringTest037, TestSize.Level3)
587 {
588     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest037 start";
589     auto jpegDecoder = std::make_shared<JpegDecoder>();
590     int size = STREAM_SIZE;
591     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
592     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
593     jpegDecoder->SetSource(*streamPtr.release());
594     std::string key = FOCAL_LENGTH_IN_35_MM_FILM;
595     std::string value = "";
596     EXIFInfo exifInfo_;
597     jpegDecoder->GetImagePropertyString(0, key, value);
598     ASSERT_EQ(value, exifInfo_.focalLengthIn35mmFilm_);
599     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest037 end";
600 }
601 
602 /**
603  * @tc.name: GetImagePropertyStringTest038
604  * @tc.desc: Test of GetImagePropertyString
605  * @tc.type: FUNC
606  */
607 HWTEST_F(JpegDecoderTest, GetImagePropertyStringTest038, TestSize.Level3)
608 {
609     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest038 start";
610     auto jpegDecoder = std::make_shared<JpegDecoder>();
611     int size = STREAM_SIZE;
612     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
613     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
614     jpegDecoder->SetSource(*streamPtr.release());
615     std::string key = HW_MNOTE_CAPTURE_MODE;
616     std::string value = "";
617     EXIFInfo exifInfo_;
618     jpegDecoder->GetImagePropertyString(0, key, value);
619     ASSERT_EQ(value, exifInfo_.hwMnoteCaptureMode_);
620     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest038 end";
621 }
622 
623 /**
624  * @tc.name: GetImagePropertyStringTest039
625  * @tc.desc: Test of GetImagePropertyString
626  * @tc.type: FUNC
627  */
628 HWTEST_F(JpegDecoderTest, GetImagePropertyStringTest039, TestSize.Level3)
629 {
630     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest039 start";
631     auto jpegDecoder = std::make_shared<JpegDecoder>();
632     int size = STREAM_SIZE;
633     std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(size);
634     auto streamPtr = BufferSourceStream::CreateSourceStream(data.get(), size);
635     jpegDecoder->SetSource(*streamPtr.release());
636     std::string key = HW_MNOTE_PHYSICAL_APERTURE;
637     std::string value = "";
638     EXIFInfo exifInfo_;
639     jpegDecoder->GetImagePropertyString(0, key, value);
640     ASSERT_EQ(value, exifInfo_.hwMnotePhysicalAperture_);
641     GTEST_LOG_(INFO) << "JpegDecoderTest: GetImagePropertyStringTest039 end";
642 }
643 }
644 }