1 /*
2 * Copyright (C) 2021 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 #include <gtest/gtest.h>
17 #include "common_utils.h"
18
19 #include "image_source_native.h"
20 #include "image_source_native_impl.h"
21 #include "pixelmap_native.h"
22 #include "pixelmap_native_impl.h"
23 #include "image_utils.h"
24 #include "pixelmap_native.h"
25 #include "securec.h"
26 #include "image_mime_type.h"
27
28 using namespace testing::ext;
29
30 struct OH_ImageSource_Info {
31 int32_t width = 0;
32 int32_t height = 0;
33 bool isHdr = false;
34 Image_MimeType mimeType;
35 };
36
37 namespace OHOS {
38 namespace Media {
39 class ImagSourceNdk2Test : public testing::Test {
40 public:
ImagSourceNdk2Test()41 ImagSourceNdk2Test() {}
~ImagSourceNdk2Test()42 ~ImagSourceNdk2Test() {}
43 };
44
45 static constexpr int32_t TestLength = 2;
46 static const std::string IMAGE_JPEG_PATH_TEST = "/data/local/tmp/image/test.jpg";
47 static const std::string IMAGE_JPEG_PATH = "/data/local/tmp/image/test_picture.jpg";
48 static const std::string IMAGE_JPEG_HDR_PATH = "/data/local/tmp/image/test_jpeg_hdr.jpg";
49 static const std::string IMAGE_HEIF_PATH = "/data/local/tmp/image/test_allocator_heif.heic";
50 static const std::string IMAGE_HEIF_HDR_PATH = "/data/local/tmp/image/test_heif_hdr.heic";
51 static const std::string IMAGE_PNG_PATH = "/data/local/tmp/image/test_picture_png.png";
52 static const int32_t MAX_BUFFER_SIZE = 256;
53 static const int32_t INVALID_INDEX = 1000;
54
CreateImageSourceNative(std::string IMAGE_PATH)55 static OH_ImageSourceNative *CreateImageSourceNative(std::string IMAGE_PATH)
56 {
57 std::string realPath;
58 if (!ImageUtils::PathToRealPath(IMAGE_PATH.c_str(), realPath) || realPath.empty()) {
59 return nullptr;
60 }
61 char filePath[MAX_BUFFER_SIZE];
62 if (strcpy_s(filePath, sizeof(filePath), realPath.c_str()) != EOK) {
63 return nullptr;
64 }
65 size_t length = realPath.size();
66 OH_ImageSourceNative *source = nullptr;
67 Image_ErrorCode ret = OH_ImageSourceNative_CreateFromUri(filePath, length, &source);
68 if (ret != Image_ErrorCode::IMAGE_SUCCESS || source == nullptr) {
69 return nullptr;
70 }
71 return source;
72 }
73
74 /**
75 * @tc.name: OH_ImageSourceInfo_Create
76 * @tc.desc: test OH_ImageSourceInfo_Create
77 * @tc.type: FUNC
78 */
79 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceInfo_Create, TestSize.Level3)
80 {
81 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceInfo_Create start";
82 OH_ImageSource_Info *ops = nullptr;
83 Image_ErrorCode ret = OH_ImageSourceInfo_Create(&ops);
84 ASSERT_EQ(ret, IMAGE_SUCCESS);
85 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceInfo_Create end";
86 }
87
88 /**
89 * @tc.name: OH_ImageSourceInfo_GetWidth
90 * @tc.desc: test OH_ImageSourceInfo_GetWidth
91 * @tc.type: FUNC
92 */
93 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceInfo_GetWidth, TestSize.Level3)
94 {
95 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceInfo_GetWidth start";
96 OH_ImageSource_Info *ops = nullptr;
97 uint32_t *width = nullptr;
98 Image_ErrorCode ret = OH_ImageSourceInfo_GetWidth(ops, width);
99 ASSERT_EQ(ret, IMAGE_BAD_PARAMETER);
100 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceInfo_GetWidth end";
101 }
102
103 /**
104 * @tc.name: OH_ImageSourceInfo_GetHeight
105 * @tc.desc: test OH_ImageSourceInfo_GetHeight
106 * @tc.type: FUNC
107 */
108 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceInfo_GetHeight, TestSize.Level3)
109 {
110 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceInfo_GetHeight start";
111 OH_ImageSource_Info *ops = nullptr;
112 uint32_t *width = nullptr;
113 Image_ErrorCode ret = OH_ImageSourceInfo_GetHeight(ops, width);
114 ASSERT_EQ(ret, IMAGE_BAD_PARAMETER);
115 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceInfo_GetHeight end";
116 }
117
118 /**
119 * @tc.name: OH_ImageSourceInfo_Release
120 * @tc.desc: test OH_ImageSourceInfo_Release
121 * @tc.type: FUNC
122 */
123 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceInfo_Release, TestSize.Level3)
124 {
125 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceInfo_Release start";
126 OH_ImageSource_Info *ops = nullptr;
127 Image_ErrorCode ret = OH_ImageSourceInfo_Release(ops);
128 ASSERT_EQ(ret, IMAGE_BAD_PARAMETER);
129 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceInfo_Release end";
130 }
131
132 /**
133 * @tc.name: OH_DecodingOptions_Create
134 * @tc.desc: test OH_DecodingOptions_Create
135 * @tc.type: FUNC
136 */
137 HWTEST_F(ImagSourceNdk2Test, OH_DecodingOptions_Create, TestSize.Level3)
138 {
139 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_DecodingOptions_Create start";
140 OH_DecodingOptions *ops = nullptr;
141 Image_ErrorCode ret = OH_DecodingOptions_Create(&ops);
142 ASSERT_EQ(ret, IMAGE_SUCCESS);
143 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_DecodingOptions_Create end";
144 }
145
146 /**
147 * @tc.name: OH_ImageSource_DecodingOptionsSetGetPixelFormat
148 * @tc.desc: test OH_ImageSource_DecodingOptionsSetGetPixelFormat
149 * @tc.type: FUNC
150 */
151 HWTEST_F(ImagSourceNdk2Test, OH_ImageSource_DecodingOptionsSetGetPixelFormat, TestSize.Level3)
152 {
153 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSource_DecodingOptionsSetGetPixelFormat start";
154 OH_DecodingOptions *ops = nullptr;
155 Image_ErrorCode ret = IMAGE_UNKNOWN_ERROR;
156 int32_t pixelFormat = 0;
157 ret = OH_DecodingOptions_Create(&ops);
158 ASSERT_EQ(ret, IMAGE_SUCCESS);
159 OH_DecodingOptions_SetPixelFormat(ops, 1);
160 OH_DecodingOptions_GetPixelFormat(ops, &pixelFormat);
161 ASSERT_EQ(pixelFormat, 1);
162 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSource_DecodingOptionsSetGetPixelFormat end";
163 }
164
165 /**
166 * @tc.name: OH_ImageSource_DecodingOptionsSetGetIndex
167 * @tc.desc: test OH_ImageSource_DecodingOptionsSetGetIndex
168 * @tc.type: FUNC
169 */
170 HWTEST_F(ImagSourceNdk2Test, OH_ImageSource_DecodingOptionsSetGetIndex, TestSize.Level3)
171 {
172 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSource_DecodingOptionsSetGetIndex start";
173 OH_DecodingOptions *ops = nullptr;
174 Image_ErrorCode ret = IMAGE_UNKNOWN_ERROR;
175 uint32_t index = 0;
176 ret = OH_DecodingOptions_Create(&ops);
177 ASSERT_EQ(ret, IMAGE_SUCCESS);
178 OH_DecodingOptions_SetIndex(ops, 1);
179 OH_DecodingOptions_GetIndex(ops, &index);
180 ASSERT_EQ(index, 1);
181 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSource_DecodingOptionsSetGetIndex end";
182 }
183
184 /**
185 * @tc.name: OH_ImageSource_DecodingOptionsSetGetRotate
186 * @tc.desc: test OH_ImageSource_DecodingOptionsSetGetRotate
187 * @tc.type: FUNC
188 */
189 HWTEST_F(ImagSourceNdk2Test, OH_ImageSource_DecodingOptionsSetGetRotate, TestSize.Level3)
190 {
191 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSource_DecodingOptionsSetGetRotate start";
192 OH_DecodingOptions *ops = nullptr;
193 Image_ErrorCode ret = IMAGE_UNKNOWN_ERROR;
194 float rotate = 0;
195 ret = OH_DecodingOptions_Create(&ops);
196 ASSERT_EQ(ret, IMAGE_SUCCESS);
197 OH_DecodingOptions_SetRotate(ops, 1);
198 OH_DecodingOptions_GetRotate(ops, &rotate);
199 ASSERT_EQ(rotate, 1);
200 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSource_DecodingOptionsSetGetRotate end";
201 }
202
203 /**
204 * @tc.name: OH_ImageSource_DecodingOptionsSetGetDesiredSize
205 * @tc.desc: test OH_ImageSource_DecodingOptionsSetGetDesiredSize
206 * @tc.type: FUNC
207 */
208 HWTEST_F(ImagSourceNdk2Test, OH_ImageSource_DecodingOptionsSetGetDesiredSize, TestSize.Level3)
209 {
210 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSource_DecodingOptionsSetGetDesiredSize start";
211 OH_DecodingOptions *ops = nullptr;
212 Image_ErrorCode ret = IMAGE_UNKNOWN_ERROR;
213 Image_Size desiredSize = {0, 0};
214 Image_Size desiredSize2 = {1, 2};
215 ret = OH_DecodingOptions_Create(&ops);
216 ASSERT_EQ(ret, IMAGE_SUCCESS);
217 OH_DecodingOptions_SetDesiredSize(ops, &desiredSize2);
218 OH_DecodingOptions_GetDesiredSize(ops, &desiredSize);
219 ASSERT_EQ(desiredSize.width, desiredSize2.width);
220 ASSERT_EQ(desiredSize.height, desiredSize2.height);
221 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSource_DecodingOptionsSetGetDesiredSize end";
222 }
223
224 /**
225 * @tc.name: OH_ImageSource_DecodingOptionsSetGetDesiredRegion
226 * @tc.desc: test OH_ImageSource_DecodingOptionsSetGetDesiredRegion
227 * @tc.type: FUNC
228 */
229 HWTEST_F(ImagSourceNdk2Test, OH_ImageSource_DecodingOptionsSetGetDesiredRegion, TestSize.Level3)
230 {
231 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSource_DecodingOptionsSetGetDesiredRegion start";
232 OH_DecodingOptions *ops = nullptr;
233 Image_ErrorCode ret = IMAGE_UNKNOWN_ERROR;
234 Image_Region desiredRegion = {0, 0, 0, 0};
235 Image_Region desiredRegion2 = {1, 2, 3, 4};
236 ret = OH_DecodingOptions_Create(&ops);
237 ASSERT_EQ(ret, IMAGE_SUCCESS);
238 OH_DecodingOptions_SetDesiredRegion(ops, &desiredRegion2);
239 OH_DecodingOptions_GetDesiredRegion(ops, &desiredRegion);
240 ASSERT_EQ(desiredRegion.x, 1);
241 ASSERT_EQ(desiredRegion.y, 2);
242 ASSERT_EQ(desiredRegion.width, 3);
243 ASSERT_EQ(desiredRegion.height, 4);
244 ret = OH_DecodingOptions_Release(ops);
245 ASSERT_EQ(ret, IMAGE_SUCCESS);
246 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSource_DecodingOptionsSetGetDesiredRegion end";
247 }
248
249 /**
250 * @tc.name: OH_ImageSourceNative_CreateFromUri
251 * @tc.desc: test OH_ImageSourceNative_CreateFromUri
252 * @tc.type: FUNC
253 */
254 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreateFromUri, TestSize.Level3)
255 {
256 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreateFromUri start";
257 OH_ImageSourceNative *imageSource = nullptr;
258 char *uri = nullptr;
259 size_t uriSize = 0;
260 Image_ErrorCode ret = OH_ImageSourceNative_CreateFromUri(uri, uriSize, &imageSource);
261 ASSERT_EQ(ret, IMAGE_BAD_PARAMETER);
262 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreateFromUri end";
263 }
264
265 /**
266 * @tc.name: OH_ImageSourceNative_CreateFromFd
267 * @tc.desc: test OH_ImageSourceNative_CreateFromFd
268 * @tc.type: FUNC
269 */
270 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreateFromFd, TestSize.Level3)
271 {
272 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreateFromFd start";
273 OH_ImageSourceNative *imageSource = nullptr;
274 int32_t fd = 0;
275 Image_ErrorCode ret = OH_ImageSourceNative_CreateFromFd(fd, &imageSource);
276 ASSERT_EQ(ret, IMAGE_BAD_PARAMETER);
277 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreateFromFd end";
278 }
279
280 /**
281 * @tc.name: OH_ImageSourceNative_CreateFromData
282 * @tc.desc: test OH_ImageSourceNative_CreateFromData
283 * @tc.type: FUNC
284 */
285 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreateFromData, TestSize.Level3)
286 {
287 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreateFromData start";
288 OH_ImageSourceNative *imageSource = nullptr;
289 uint8_t* data = nullptr;
290 size_t dataSize = 0;
291 Image_ErrorCode ret = OH_ImageSourceNative_CreateFromData(data, dataSize, &imageSource);
292 ASSERT_EQ(ret, IMAGE_BAD_PARAMETER);
293 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreateFromData end";
294 }
295
296 /**
297 * @tc.name: OH_ImageSourceNative_CreateFromRawFile002
298 * @tc.desc: test OH_ImageSourceNative_CreateFromRawFile
299 * @tc.type: FUNC
300 */
301 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreateFromRawFile002, TestSize.Level3)
302 {
303 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreateFromRawFile002 start";
304 OH_ImageSourceNative *imageSource = nullptr;
305 RawFileDescriptor *rawFile = nullptr;
306 Image_ErrorCode ret = OH_ImageSourceNative_CreateFromRawFile(rawFile, &imageSource);
307 ASSERT_EQ(ret, IMAGE_BAD_PARAMETER);
308 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreateFromRawFile002 end";
309 }
310
311 /**
312 * @tc.name: OH_ImageSourceNative_CreatePixelmap
313 * @tc.desc: test OH_ImageSourceNative_CreatePixelmap
314 * @tc.type: FUNC
315 */
316 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmap, TestSize.Level3)
317 {
318 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmap start";
319 OH_ImageSourceNative *imageSource = nullptr;
320 OH_DecodingOptions* ops = nullptr;
321 OH_PixelmapNative* resPixMap = nullptr;
322 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmap(imageSource, ops, &resPixMap);
323 ASSERT_EQ(ret, IMAGE_BAD_PARAMETER);
324 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmap end";
325 }
326
327 /**
328 * @tc.name: OH_ImageSourceNative_CreatePixelmapTest001
329 * @tc.desc: test OH_ImageSourceNative_CreatePixelmapTest001
330 * @tc.type: FUNC
331 */
332 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapTest001, TestSize.Level3)
333 {
334 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest001 start";
335 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_PATH);
336 ASSERT_NE(imageSource, nullptr);
337 OH_DecodingOptions* ops = nullptr;
338 Image_Region desiredRegion = {0, 0, 0, 0};
339 Image_Region desiredRegion2 = {1920, 1080, 1920, 1080};
340 OH_DecodingOptions_Create(&ops);
341 OH_DecodingOptions_SetDesiredRegion(ops, &desiredRegion2);
342 OH_DecodingOptions_GetDesiredRegion(ops, &desiredRegion);
343 ASSERT_EQ(desiredRegion.x, 1920);
344 ASSERT_EQ(desiredRegion.y, 1080);
345 ASSERT_EQ(desiredRegion.width, 1920);
346 ASSERT_EQ(desiredRegion.height, 1080);
347 OH_DecodingOptions_SetCropAndScaleStrategy(ops, 2);
348 OH_PixelmapNative* resPixMap = nullptr;
349 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmap(imageSource, ops, &resPixMap);
350 EXPECT_EQ(ret, IMAGE_SUCCESS);
351 OH_ImageSourceNative_Release(imageSource);
352 OH_DecodingOptions_Release(ops);
353 OH_PixelmapNative_Release(resPixMap);
354 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest001 end";
355 }
356
357 /**
358 * @tc.name: OH_ImageSourceNative_CreatePixelmapTest002
359 * @tc.desc: test OH_ImageSourceNative_CreatePixelmapTest002
360 * @tc.type: FUNC
361 */
362 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapTest002, TestSize.Level3)
363 {
364 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest002 start";
365 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_PATH);
366 ASSERT_NE(imageSource, nullptr);
367 OH_DecodingOptions* ops = nullptr;
368 Image_Region desiredRegion = {0, 0, 0, 0};
369 Image_Region desiredRegion2 = {0, 0, 1920, 2160};
370 OH_DecodingOptions_Create(&ops);
371 OH_DecodingOptions_SetDesiredRegion(ops, &desiredRegion2);
372 OH_DecodingOptions_GetDesiredRegion(ops, &desiredRegion);
373 ASSERT_EQ(desiredRegion.x, 0);
374 ASSERT_EQ(desiredRegion.y, 0);
375 ASSERT_EQ(desiredRegion.width, 1920);
376 ASSERT_EQ(desiredRegion.height, 2160);
377 OH_DecodingOptions_SetCropAndScaleStrategy(ops, 2);
378 OH_PixelmapNative* resPixMap = nullptr;
379 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmap(imageSource, ops, &resPixMap);
380 EXPECT_EQ(ret, IMAGE_SUCCESS);
381 OH_ImageSourceNative_Release(imageSource);
382 OH_DecodingOptions_Release(ops);
383 OH_PixelmapNative_Release(resPixMap);
384 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest002 end";
385 }
386
387 /**
388 * @tc.name: OH_ImageSourceNative_CreatePixelmapTest003
389 * @tc.desc: test OH_ImageSourceNative_CreatePixelmapTest003
390 * @tc.type: FUNC
391 */
392 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapTest003, TestSize.Level3)
393 {
394 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest003 start";
395 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_PATH);
396 ASSERT_NE(imageSource, nullptr);
397 OH_DecodingOptions* ops = nullptr;
398 Image_Region desiredRegion = {0, 0, 0, 0};
399 Image_Region desiredRegion2 = {0, 0, 3840, 1080};
400 OH_DecodingOptions_Create(&ops);
401 OH_DecodingOptions_SetDesiredRegion(ops, &desiredRegion2);
402 OH_DecodingOptions_GetDesiredRegion(ops, &desiredRegion);
403 ASSERT_EQ(desiredRegion.x, 0);
404 ASSERT_EQ(desiredRegion.y, 0);
405 ASSERT_EQ(desiredRegion.width, 3840);
406 ASSERT_EQ(desiredRegion.height, 1080);
407 OH_DecodingOptions_SetCropAndScaleStrategy(ops, 2);
408 OH_PixelmapNative* resPixMap = nullptr;
409 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmap(imageSource, ops, &resPixMap);
410 EXPECT_EQ(ret, IMAGE_SUCCESS);
411 OH_ImageSourceNative_Release(imageSource);
412 OH_DecodingOptions_Release(ops);
413 OH_PixelmapNative_Release(resPixMap);
414 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest003 end";
415 }
416
417 /**
418 * @tc.name: OH_ImageSourceNative_CreatePixelmapTest004
419 * @tc.desc: test OH_ImageSourceNative_CreatePixelmapTest004
420 * @tc.type: FUNC
421 */
422 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapTest004, TestSize.Level3)
423 {
424 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest004 start";
425 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_PATH);
426 ASSERT_NE(imageSource, nullptr);
427 OH_DecodingOptions* ops = nullptr;
428 Image_Region desiredRegion = {0, 0, 0, 0};
429 Image_Region desiredRegion2 = {1920, 1080, 3840, 1080};
430 OH_DecodingOptions_Create(&ops);
431 OH_DecodingOptions_SetDesiredRegion(ops, &desiredRegion2);
432 OH_DecodingOptions_GetDesiredRegion(ops, &desiredRegion);
433 ASSERT_EQ(desiredRegion.x, 1920);
434 ASSERT_EQ(desiredRegion.y, 1080);
435 ASSERT_EQ(desiredRegion.width, 3840);
436 ASSERT_EQ(desiredRegion.height, 1080);
437 OH_DecodingOptions_SetCropAndScaleStrategy(ops, 2);
438 OH_PixelmapNative* resPixMap = nullptr;
439 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmap(imageSource, ops, &resPixMap);
440 EXPECT_EQ(ret, IMAGE_SUCCESS);
441 OH_ImageSourceNative_Release(imageSource);
442 OH_DecodingOptions_Release(ops);
443 OH_PixelmapNative_Release(resPixMap);
444 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest004 end";
445 }
446
447 /**
448 * @tc.name: OH_ImageSourceNative_CreatePixelmapTest005
449 * @tc.desc: test OH_ImageSourceNative_CreatePixelmapTest005
450 * @tc.type: FUNC
451 */
452 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapTest005, TestSize.Level3)
453 {
454 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest005 start";
455 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_PATH);
456 ASSERT_NE(imageSource, nullptr);
457 OH_DecodingOptions* ops = nullptr;
458 Image_Region desiredRegion = {0, 0, 0, 0};
459 Image_Region desiredRegion2 = {3840, 2160, 1920, 1080};
460 OH_DecodingOptions_Create(&ops);
461 OH_DecodingOptions_SetDesiredRegion(ops, &desiredRegion2);
462 OH_DecodingOptions_GetDesiredRegion(ops, &desiredRegion);
463 ASSERT_EQ(desiredRegion.x, 3840);
464 ASSERT_EQ(desiredRegion.y, 2160);
465 ASSERT_EQ(desiredRegion.width, 1920);
466 ASSERT_EQ(desiredRegion.height, 1080);
467 OH_DecodingOptions_SetCropAndScaleStrategy(ops, 2);
468 OH_PixelmapNative* resPixMap = nullptr;
469 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmap(imageSource, ops, &resPixMap);
470 EXPECT_EQ(ret, IMAGE_SUCCESS);
471 OH_ImageSourceNative_Release(imageSource);
472 OH_DecodingOptions_Release(ops);
473 OH_PixelmapNative_Release(resPixMap);
474 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest005 end";
475 }
476
477 /**
478 * @tc.name: OH_ImageSourceNative_CreatePixelmapTest006
479 * @tc.desc: test OH_ImageSourceNative_CreatePixelmapTest006
480 * @tc.type: FUNC
481 */
482 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapTest006, TestSize.Level3)
483 {
484 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest006 start";
485 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_PNG_PATH);
486 ASSERT_NE(imageSource, nullptr);
487 OH_DecodingOptions* ops = nullptr;
488 Image_Region desiredRegion = {0, 0, 0, 0};
489 Image_Region desiredRegion2 = {1920, 1080, 1920, 1080};
490 OH_DecodingOptions_Create(&ops);
491 OH_DecodingOptions_SetDesiredRegion(ops, &desiredRegion2);
492 OH_DecodingOptions_GetDesiredRegion(ops, &desiredRegion);
493 ASSERT_EQ(desiredRegion.x, 1920);
494 ASSERT_EQ(desiredRegion.y, 1080);
495 ASSERT_EQ(desiredRegion.width, 1920);
496 ASSERT_EQ(desiredRegion.height, 1080);
497 OH_DecodingOptions_SetCropAndScaleStrategy(ops, 2);
498 OH_PixelmapNative* resPixMap = nullptr;
499 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmap(imageSource, ops, &resPixMap);
500 EXPECT_EQ(ret, IMAGE_SUCCESS);
501 OH_ImageSourceNative_Release(imageSource);
502 OH_DecodingOptions_Release(ops);
503 OH_PixelmapNative_Release(resPixMap);
504 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest006 end";
505 }
506
507 /**
508 * @tc.name: OH_ImageSourceNative_CreatePixelmapTest007
509 * @tc.desc: test OH_ImageSourceNative_CreatePixelmapTest007
510 * @tc.type: FUNC
511 */
512 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapTest007, TestSize.Level3)
513 {
514 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest007 start";
515 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_PNG_PATH);
516 ASSERT_NE(imageSource, nullptr);
517 OH_DecodingOptions* ops = nullptr;
518 Image_Region desiredRegion = {0, 0, 0, 0};
519 Image_Region desiredRegion2 = {0, 0, 1920, 2160};
520 OH_DecodingOptions_Create(&ops);
521 OH_DecodingOptions_SetDesiredRegion(ops, &desiredRegion2);
522 OH_DecodingOptions_GetDesiredRegion(ops, &desiredRegion);
523 ASSERT_EQ(desiredRegion.x, 0);
524 ASSERT_EQ(desiredRegion.y, 0);
525 ASSERT_EQ(desiredRegion.width, 1920);
526 ASSERT_EQ(desiredRegion.height, 2160);
527 OH_DecodingOptions_SetCropAndScaleStrategy(ops, 2);
528 OH_PixelmapNative* resPixMap = nullptr;
529 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmap(imageSource, ops, &resPixMap);
530 EXPECT_EQ(ret, IMAGE_SUCCESS);
531 OH_ImageSourceNative_Release(imageSource);
532 OH_DecodingOptions_Release(ops);
533 OH_PixelmapNative_Release(resPixMap);
534 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest007 end";
535 }
536
537 /**
538 * @tc.name: OH_ImageSourceNative_CreatePixelmapTest008
539 * @tc.desc: test OH_ImageSourceNative_CreatePixelmapTest008
540 * @tc.type: FUNC
541 */
542 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapTest008, TestSize.Level3)
543 {
544 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest008 start";
545 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_PNG_PATH);
546 ASSERT_NE(imageSource, nullptr);
547 OH_DecodingOptions* ops = nullptr;
548 Image_Region desiredRegion = {0, 0, 0, 0};
549 Image_Region desiredRegion2 = {0, 0, 3840, 1080};
550 OH_DecodingOptions_Create(&ops);
551 OH_DecodingOptions_SetDesiredRegion(ops, &desiredRegion2);
552 OH_DecodingOptions_GetDesiredRegion(ops, &desiredRegion);
553 ASSERT_EQ(desiredRegion.x, 0);
554 ASSERT_EQ(desiredRegion.y, 0);
555 ASSERT_EQ(desiredRegion.width, 3840);
556 ASSERT_EQ(desiredRegion.height, 1080);
557 OH_DecodingOptions_SetCropAndScaleStrategy(ops, 2);
558 OH_PixelmapNative* resPixMap = nullptr;
559 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmap(imageSource, ops, &resPixMap);
560 EXPECT_EQ(ret, IMAGE_SUCCESS);
561 OH_ImageSourceNative_Release(imageSource);
562 OH_DecodingOptions_Release(ops);
563 OH_PixelmapNative_Release(resPixMap);
564 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest008 end";
565 }
566
567 /**
568 * @tc.name: OH_ImageSourceNative_CreatePixelmapTest009
569 * @tc.desc: test OH_ImageSourceNative_CreatePixelmapTest009
570 * @tc.type: FUNC
571 */
572 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapTest009, TestSize.Level3)
573 {
574 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest009 start";
575 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_PNG_PATH);
576 ASSERT_NE(imageSource, nullptr);
577 OH_DecodingOptions* ops = nullptr;
578 Image_Region desiredRegion = {0, 0, 0, 0};
579 Image_Region desiredRegion2 = {1920, 1080, 3840, 1080};
580 OH_DecodingOptions_Create(&ops);
581 OH_DecodingOptions_SetDesiredRegion(ops, &desiredRegion2);
582 OH_DecodingOptions_GetDesiredRegion(ops, &desiredRegion);
583 ASSERT_EQ(desiredRegion.x, 1920);
584 ASSERT_EQ(desiredRegion.y, 1080);
585 ASSERT_EQ(desiredRegion.width, 3840);
586 ASSERT_EQ(desiredRegion.height, 1080);
587 OH_DecodingOptions_SetCropAndScaleStrategy(ops, 2);
588 OH_PixelmapNative* resPixMap = nullptr;
589 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmap(imageSource, ops, &resPixMap);
590 EXPECT_EQ(ret, IMAGE_SUCCESS);
591 OH_ImageSourceNative_Release(imageSource);
592 OH_DecodingOptions_Release(ops);
593 OH_PixelmapNative_Release(resPixMap);
594 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest009 end";
595 }
596
597 /**
598 * @tc.name: OH_ImageSourceNative_CreatePixelmapTest010
599 * @tc.desc: test OH_ImageSourceNative_CreatePixelmapTest010
600 * @tc.type: FUNC
601 */
602 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapTest010, TestSize.Level3)
603 {
604 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest010 start";
605 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_PNG_PATH);
606 ASSERT_NE(imageSource, nullptr);
607 OH_DecodingOptions* ops = nullptr;
608 Image_Region desiredRegion = {0, 0, 0, 0};
609 Image_Region desiredRegion2 = {3840, 2160, 1920, 1080};
610 OH_DecodingOptions_Create(&ops);
611 OH_DecodingOptions_SetDesiredRegion(ops, &desiredRegion2);
612 OH_DecodingOptions_GetDesiredRegion(ops, &desiredRegion);
613 ASSERT_EQ(desiredRegion.x, 3840);
614 ASSERT_EQ(desiredRegion.y, 2160);
615 ASSERT_EQ(desiredRegion.width, 1920);
616 ASSERT_EQ(desiredRegion.height, 1080);
617 OH_DecodingOptions_SetCropAndScaleStrategy(ops, 2);
618 OH_PixelmapNative* resPixMap = nullptr;
619 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmap(imageSource, ops, &resPixMap);
620 EXPECT_EQ(ret, IMAGE_SUCCESS);
621 OH_ImageSourceNative_Release(imageSource);
622 OH_DecodingOptions_Release(ops);
623 OH_PixelmapNative_Release(resPixMap);
624 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest010 end";
625 }
626
627 /**
628 * @tc.name: OH_ImageSourceNative_CreatePixelmapTest011
629 * @tc.desc: test OH_ImageSourceNative_CreatePixelmapTest011
630 * @tc.type: FUNC
631 */
632 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapTest011, TestSize.Level3)
633 {
634 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest011 start";
635 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_PNG_PATH);
636 ASSERT_NE(imageSource, nullptr);
637 OH_DecodingOptions* ops = nullptr;
638 Image_Region desiredRegion = {0, 0, 0, 0};
639 Image_Region desiredRegion2 = {960, 540, 1920, 1080};
640 OH_DecodingOptions_Create(&ops);
641 OH_DecodingOptions_SetDesiredRegion(ops, &desiredRegion2);
642 OH_DecodingOptions_GetDesiredRegion(ops, &desiredRegion);
643 ASSERT_EQ(desiredRegion.x, 960);
644 ASSERT_EQ(desiredRegion.y, 540);
645 ASSERT_EQ(desiredRegion.width, 1920);
646 ASSERT_EQ(desiredRegion.height, 1080);
647 OH_DecodingOptions_SetCropAndScaleStrategy(ops, 2);
648 OH_PixelmapNative* resPixMap = nullptr;
649 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmap(imageSource, ops, &resPixMap);
650 EXPECT_EQ(ret, IMAGE_SUCCESS);
651 OH_ImageSourceNative_Release(imageSource);
652 OH_DecodingOptions_Release(ops);
653 OH_PixelmapNative_Release(resPixMap);
654 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest011 end";
655 }
656
657 /**
658 * @tc.name: OH_ImageSourceNative_CreatePixelmapTest012
659 * @tc.desc: test OH_ImageSourceNative_CreatePixelmapTest012
660 * @tc.type: FUNC
661 */
662 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapTest012, TestSize.Level3)
663 {
664 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest012 start";
665 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_PATH);
666 ASSERT_NE(imageSource, nullptr);
667 OH_DecodingOptions* ops = nullptr;
668 Image_Region desiredRegion = {0, 0, 0, 0};
669 Image_Region desiredRegion2 = {960, 540, 1920, 1080};
670 OH_DecodingOptions_Create(&ops);
671 OH_DecodingOptions_SetDesiredRegion(ops, &desiredRegion2);
672 OH_DecodingOptions_GetDesiredRegion(ops, &desiredRegion);
673 ASSERT_EQ(desiredRegion.x, 960);
674 ASSERT_EQ(desiredRegion.y, 540);
675 ASSERT_EQ(desiredRegion.width, 1920);
676 ASSERT_EQ(desiredRegion.height, 1080);
677 OH_DecodingOptions_SetCropAndScaleStrategy(ops, 2);
678 OH_PixelmapNative* resPixMap = nullptr;
679 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmap(imageSource, ops, &resPixMap);
680 EXPECT_EQ(ret, IMAGE_SUCCESS);
681 OH_ImageSourceNative_Release(imageSource);
682 OH_DecodingOptions_Release(ops);
683 OH_PixelmapNative_Release(resPixMap);
684 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest012 end";
685 }
686
687 /**
688 * @tc.name: OH_ImageSourceNative_CreatePixelmapTest013
689 * @tc.desc: test OH_ImageSourceNative_CreatePixelmapTest013
690 * @tc.type: FUNC
691 */
692 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapTest013, TestSize.Level3)
693 {
694 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest013 start";
695 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_PATH);
696 ASSERT_NE(imageSource, nullptr);
697 OH_DecodingOptions* ops = nullptr;
698 Image_Region desiredRegion = {0, 0, 0, 0};
699 Image_Region desiredRegion2 = {0, 0, 3840, 2160};
700 OH_DecodingOptions_Create(&ops);
701 OH_DecodingOptions_SetDesiredRegion(ops, &desiredRegion2);
702 OH_DecodingOptions_GetDesiredRegion(ops, &desiredRegion);
703 ASSERT_EQ(desiredRegion.x, 0);
704 ASSERT_EQ(desiredRegion.y, 0);
705 ASSERT_EQ(desiredRegion.width, 3840);
706 ASSERT_EQ(desiredRegion.height, 2160);
707 OH_DecodingOptions_SetCropAndScaleStrategy(ops, 2);
708 OH_PixelmapNative* resPixMap = nullptr;
709 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmap(imageSource, ops, &resPixMap);
710 EXPECT_EQ(ret, IMAGE_SUCCESS);
711 OH_ImageSourceNative_Release(imageSource);
712 OH_DecodingOptions_Release(ops);
713 OH_PixelmapNative_Release(resPixMap);
714 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest013 end";
715 }
716
717 /**
718 * @tc.name: OH_ImageSourceNative_CreatePixelmapTest014
719 * @tc.desc: test OH_ImageSourceNative_CreatePixelmapTest014
720 * @tc.type: FUNC
721 */
722 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapTest014, TestSize.Level3)
723 {
724 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest014 start";
725 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_PNG_PATH);
726 ASSERT_NE(imageSource, nullptr);
727 OH_DecodingOptions* ops = nullptr;
728 Image_Region desiredRegion = {0, 0, 0, 0};
729 Image_Region desiredRegion2 = {0, 0, 3840, 2160};
730 OH_DecodingOptions_Create(&ops);
731 OH_DecodingOptions_SetDesiredRegion(ops, &desiredRegion2);
732 OH_DecodingOptions_GetDesiredRegion(ops, &desiredRegion);
733 ASSERT_EQ(desiredRegion.x, 0);
734 ASSERT_EQ(desiredRegion.y, 0);
735 ASSERT_EQ(desiredRegion.width, 3840);
736 ASSERT_EQ(desiredRegion.height, 2160);
737 OH_DecodingOptions_SetCropAndScaleStrategy(ops, 2);
738 OH_PixelmapNative* resPixMap = nullptr;
739 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmap(imageSource, ops, &resPixMap);
740 EXPECT_EQ(ret, IMAGE_SUCCESS);
741 OH_ImageSourceNative_Release(imageSource);
742 OH_DecodingOptions_Release(ops);
743 OH_PixelmapNative_Release(resPixMap);
744 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapTest014 end";
745 }
746
747 /**
748 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest001
749 * @tc.desc: Test create Pixelmap use DMA.
750 * @tc.type: FUNC
751 */
752 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest001, TestSize.Level1)
753 {
754 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_PATH);
755 ASSERT_NE(imageSource, nullptr);
756 OH_DecodingOptions *opts = nullptr;
757 OH_DecodingOptions_Create(&opts);
758 ASSERT_NE(opts, nullptr);
759 OH_PixelmapNative* resPixMap = nullptr;
760 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_DMA;
761 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
762 EXPECT_EQ(ret, IMAGE_SUCCESS);
763 EXPECT_NE(resPixMap, nullptr);
764 OH_ImageSourceNative_Release(imageSource);
765 OH_DecodingOptions_Release(opts);
766 OH_PixelmapNative_Release(resPixMap);
767 }
768
769 /**
770 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest002
771 * @tc.desc: Test create Pixelmap use SHARE_MEMORY.
772 * @tc.type: FUNC
773 */
774 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest002, TestSize.Level1)
775 {
776 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_PATH);
777 ASSERT_NE(imageSource, nullptr);
778 OH_DecodingOptions *opts = nullptr;
779 OH_DecodingOptions_Create(&opts);
780 ASSERT_NE(opts, nullptr);
781 OH_PixelmapNative* resPixMap = nullptr;
782 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_SHARE_MEMORY;
783 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
784 EXPECT_EQ(ret, IMAGE_SUCCESS);
785 EXPECT_NE(resPixMap, nullptr);
786 OH_ImageSourceNative_Release(imageSource);
787 OH_DecodingOptions_Release(opts);
788 OH_PixelmapNative_Release(resPixMap);
789 }
790
791 /**
792 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest003
793 * @tc.desc: Test create Pixelmap if source is nullptr.
794 * @tc.type: FUNC
795 */
796 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest003, TestSize.Level1)
797 {
798 OH_ImageSourceNative *imageSource = nullptr;
799 OH_DecodingOptions* opts = nullptr;
800 OH_PixelmapNative* resPixMap = nullptr;
801 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_DMA;
802 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
803 EXPECT_EQ(ret, IMAGE_BAD_PARAMETER);
804 EXPECT_EQ(resPixMap, nullptr);
805 OH_ImageSourceNative_Release(imageSource);
806 }
807
808 /**
809 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest004
810 * @tc.desc: Test create Pixelmap if index is invalid.
811 * @tc.type: FUNC
812 */
813 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest004, TestSize.Level1)
814 {
815 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_PATH);
816 ASSERT_NE(imageSource, nullptr);
817 OH_DecodingOptions *opts = nullptr;
818 OH_DecodingOptions_Create(&opts);
819 ASSERT_NE(opts, nullptr);
820 uint32_t tempIndex = INVALID_INDEX;
821 Image_ErrorCode ret = OH_DecodingOptions_SetIndex(opts, tempIndex);
822 OH_PixelmapNative* resPixMap = nullptr;
823 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_DMA;
824 ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
825 EXPECT_EQ(ret, IMAGE_DECODE_FAILED);
826 EXPECT_EQ(resPixMap, nullptr);
827 OH_ImageSourceNative_Release(imageSource);
828 OH_DecodingOptions_Release(opts);
829 }
830
831 /**
832 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest005
833 * @tc.desc: Test the creation of a pixelmap using AUTO allocator for JPEG image format, expecting success.
834 * @tc.type: FUNC
835 */
836 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest005, TestSize.Level1)
837 {
838 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_PATH);
839 ASSERT_NE(imageSource, nullptr);
840 OH_DecodingOptions *opts = nullptr;
841 OH_DecodingOptions_Create(&opts);
842 ASSERT_NE(opts, nullptr);
843 OH_PixelmapNative* resPixMap = nullptr;
844 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_AUTO;
845 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
846 EXPECT_EQ(ret, IMAGE_SUCCESS);
847 EXPECT_NE(resPixMap, nullptr);
848 OH_ImageSourceNative_Release(imageSource);
849 OH_DecodingOptions_Release(opts);
850 OH_PixelmapNative_Release(resPixMap);
851 }
852
853 /**
854 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest006
855 * @tc.desc: Test the creation of a pixelmap using DMA allocator with invalid decoding options (nullptr) for JPEG image
856 * format, expecting IMAGE_BAD_PARAMETER error.
857 * @tc.type: FUNC
858 */
859 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest006, TestSize.Level1)
860 {
861 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_PATH);
862 ASSERT_NE(imageSource, nullptr);
863 OH_DecodingOptions* opts = nullptr;
864 OH_PixelmapNative* resPixMap = nullptr;
865 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_DMA;
866 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
867 EXPECT_EQ(ret, IMAGE_BAD_PARAMETER);
868 EXPECT_EQ(resPixMap, nullptr);
869 OH_ImageSourceNative_Release(imageSource);
870 OH_DecodingOptions_Release(opts);
871 OH_PixelmapNative_Release(resPixMap);
872 }
873
874 /**
875 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest007
876 * @tc.desc: Test the creation of a pixelmap using DMA allocator, with NV21 pixel format for HEIF image format,
877 * expecting success.
878 * @tc.type: FUNC
879 */
880 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest007, TestSize.Level1)
881 {
882 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_HEIF_PATH);
883 ASSERT_NE(imageSource, nullptr);
884 OH_DecodingOptions *opts = nullptr;
885 OH_DecodingOptions_Create(&opts);
886 ASSERT_NE(opts, nullptr);
887 Image_ErrorCode ret = OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_NV21);
888 EXPECT_EQ(ret, IMAGE_SUCCESS);
889 OH_PixelmapNative* resPixMap = nullptr;
890 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_DMA;
891 ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
892 EXPECT_EQ(ret, IMAGE_SUCCESS);
893 EXPECT_NE(resPixMap, nullptr);
894 OH_ImageSourceNative_Release(imageSource);
895 OH_DecodingOptions_Release(opts);
896 OH_PixelmapNative_Release(resPixMap);
897 }
898
899 /**
900 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest008
901 * @tc.desc: Test the creation of a pixelmap using DMA allocator, with RGBA_8888 pixel format for HEIF image format,
902 * expecting success.
903 * @tc.type: FUNC
904 */
905 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest008, TestSize.Level1)
906 {
907 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_HEIF_PATH);
908 ASSERT_NE(imageSource, nullptr);
909 OH_DecodingOptions *opts = nullptr;
910 OH_DecodingOptions_Create(&opts);
911 ASSERT_NE(opts, nullptr);
912 Image_ErrorCode ret = OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_RGBA_8888);
913 EXPECT_EQ(ret, IMAGE_SUCCESS);
914 OH_PixelmapNative* resPixMap = nullptr;
915 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_DMA;
916 ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
917 EXPECT_EQ(ret, IMAGE_SUCCESS);
918 EXPECT_NE(resPixMap, nullptr);
919 OH_ImageSourceNative_Release(imageSource);
920 OH_DecodingOptions_Release(opts);
921 OH_PixelmapNative_Release(resPixMap);
922 }
923
924 /**
925 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest009
926 * @tc.desc: Test the creation of a pixelmap using shared memory allocator, with NV21 pixel format for HEIF image
927 * format, expecting unsupported operation.
928 * @tc.type: FUNC
929 */
930 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest009, TestSize.Level1)
931 {
932 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_HEIF_PATH);
933 ASSERT_NE(imageSource, nullptr);
934 OH_DecodingOptions *opts = nullptr;
935 OH_DecodingOptions_Create(&opts);
936 ASSERT_NE(opts, nullptr);
937 Image_ErrorCode ret = OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_NV21);
938 EXPECT_EQ(ret, IMAGE_SUCCESS);
939 OH_PixelmapNative* resPixMap = nullptr;
940 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_SHARE_MEMORY;
941 ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
942 EXPECT_EQ(ret, IMAGE_SUCCESS);
943 EXPECT_NE(resPixMap, nullptr);
944 OH_ImageSourceNative_Release(imageSource);
945 OH_DecodingOptions_Release(opts);
946 OH_PixelmapNative_Release(resPixMap);
947 }
948
949 /**
950 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest010
951 * @tc.desc: Test the creation of a pixelmap using shared memory allocator, with RGBA_8888 pixel format for HEIF image
952 * format, expecting success.
953 * @tc.type: FUNC
954 */
955 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest010, TestSize.Level1)
956 {
957 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_HEIF_PATH);
958 ASSERT_NE(imageSource, nullptr);
959 OH_DecodingOptions *opts = nullptr;
960 OH_DecodingOptions_Create(&opts);
961 ASSERT_NE(opts, nullptr);
962 Image_ErrorCode ret = OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_RGBA_8888);
963 EXPECT_EQ(ret, IMAGE_SUCCESS);
964 OH_PixelmapNative* resPixMap = nullptr;
965 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_SHARE_MEMORY;
966 ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
967 EXPECT_EQ(ret, IMAGE_SUCCESS);
968 EXPECT_NE(resPixMap, nullptr);
969 OH_ImageSourceNative_Release(imageSource);
970 OH_DecodingOptions_Release(opts);
971 OH_PixelmapNative_Release(resPixMap);
972 }
973
974 /**
975 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest011
976 * @tc.desc: Test the creation of a pixelmap using shared memory allocator, with RGBA_8888 pixel format and HDR dynamic
977 * range, expecting unsupported operation.
978 * @tc.type: FUNC
979 */
980 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest011, TestSize.Level1)
981 {
982 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_HDR_PATH);
983 ASSERT_NE(imageSource, nullptr);
984 OH_DecodingOptions *opts = nullptr;
985 OH_DecodingOptions_Create(&opts);
986 ASSERT_NE(opts, nullptr);
987 Image_ErrorCode ret = OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_RGBA_8888);
988 EXPECT_EQ(ret, IMAGE_SUCCESS);
989 ret = OH_DecodingOptions_SetDesiredDynamicRange(opts, IMAGE_DYNAMIC_RANGE::IMAGE_DYNAMIC_RANGE_HDR);
990 EXPECT_EQ(ret, IMAGE_SUCCESS);
991 OH_PixelmapNative* resPixMap = nullptr;
992 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_SHARE_MEMORY;
993 ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
994 EXPECT_EQ(ret, IMAGE_SOURCE_UNSUPPORTED_ALLOCATOR_TYPE);
995 EXPECT_EQ(resPixMap, nullptr);
996 OH_ImageSourceNative_Release(imageSource);
997 OH_DecodingOptions_Release(opts);
998 OH_PixelmapNative_Release(resPixMap);
999 }
1000
1001 /**
1002 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest012
1003 * @tc.desc: Test the creation of a pixelmap using shared memory allocator, with RGBA_8888 pixel format and auto
1004 * dynamic range, expecting unsupported operation.
1005 * @tc.type: FUNC
1006 */
1007 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest012, TestSize.Level1)
1008 {
1009 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_HDR_PATH);
1010 ASSERT_NE(imageSource, nullptr);
1011 OH_DecodingOptions *opts = nullptr;
1012 OH_DecodingOptions_Create(&opts);
1013 ASSERT_NE(opts, nullptr);
1014 Image_ErrorCode ret = OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_RGBA_8888);
1015 EXPECT_EQ(ret, IMAGE_SUCCESS);
1016 ret = OH_DecodingOptions_SetDesiredDynamicRange(opts, IMAGE_DYNAMIC_RANGE::IMAGE_DYNAMIC_RANGE_AUTO);
1017 EXPECT_EQ(ret, IMAGE_SUCCESS);
1018 OH_PixelmapNative* resPixMap = nullptr;
1019 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_SHARE_MEMORY;
1020 ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
1021 EXPECT_EQ(ret, IMAGE_SOURCE_UNSUPPORTED_ALLOCATOR_TYPE);
1022 EXPECT_EQ(resPixMap, nullptr);
1023 OH_ImageSourceNative_Release(imageSource);
1024 OH_DecodingOptions_Release(opts);
1025 OH_PixelmapNative_Release(resPixMap);
1026 }
1027
1028 /**
1029 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest013
1030 * @tc.desc: Test the creation of a pixelmap using a DMA allocator, with RGBA_8888 pixel format and HDR dynamic range,
1031 * expecting successful operation.
1032 * @tc.type: FUNC
1033 */
1034 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest013, TestSize.Level1)
1035 {
1036 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_HDR_PATH);
1037 ASSERT_NE(imageSource, nullptr);
1038 OH_DecodingOptions *opts = nullptr;
1039 OH_DecodingOptions_Create(&opts);
1040 ASSERT_NE(opts, nullptr);
1041 Image_ErrorCode ret = OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_RGBA_8888);
1042 EXPECT_EQ(ret, IMAGE_SUCCESS);
1043 ret = OH_DecodingOptions_SetDesiredDynamicRange(opts, IMAGE_DYNAMIC_RANGE::IMAGE_DYNAMIC_RANGE_HDR);
1044 EXPECT_EQ(ret, IMAGE_SUCCESS);
1045 OH_PixelmapNative* resPixMap = nullptr;
1046 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_DMA;
1047 ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
1048 EXPECT_EQ(ret, IMAGE_SUCCESS);
1049 EXPECT_NE(resPixMap, nullptr);
1050 OH_ImageSourceNative_Release(imageSource);
1051 OH_DecodingOptions_Release(opts);
1052 OH_PixelmapNative_Release(resPixMap);
1053 }
1054
1055 /**
1056 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest014
1057 * @tc.desc: Test the creation of a pixelmap using a DMA allocator, with RGBA_8888 pixel format and auto dynamic range,
1058 * expecting successful operation.
1059 * @tc.type: FUNC
1060 */
1061 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest014, TestSize.Level1)
1062 {
1063 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_HDR_PATH);
1064 ASSERT_NE(imageSource, nullptr);
1065 OH_DecodingOptions *opts = nullptr;
1066 OH_DecodingOptions_Create(&opts);
1067 ASSERT_NE(opts, nullptr);
1068 Image_ErrorCode ret = OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_RGBA_8888);
1069 EXPECT_EQ(ret, IMAGE_SUCCESS);
1070 ret = OH_DecodingOptions_SetDesiredDynamicRange(opts, IMAGE_DYNAMIC_RANGE::IMAGE_DYNAMIC_RANGE_AUTO);
1071 EXPECT_EQ(ret, IMAGE_SUCCESS);
1072 OH_PixelmapNative* resPixMap = nullptr;
1073 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_DMA;
1074 ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
1075 EXPECT_EQ(ret, IMAGE_SUCCESS);
1076 EXPECT_NE(resPixMap, nullptr);
1077 OH_ImageSourceNative_Release(imageSource);
1078 OH_DecodingOptions_Release(opts);
1079 OH_PixelmapNative_Release(resPixMap);
1080 }
1081
1082 /**
1083 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest015
1084 * @tc.desc: Test the creation of a pixelmap using a DMA allocator, with NV21 pixel format and HDR dynamic range,
1085 * expecting successful operation.
1086 * @tc.type: FUNC
1087 */
1088 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest015, TestSize.Level1)
1089 {
1090 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_HDR_PATH);
1091 ASSERT_NE(imageSource, nullptr);
1092 OH_DecodingOptions *opts = nullptr;
1093 OH_DecodingOptions_Create(&opts);
1094 ASSERT_NE(opts, nullptr);
1095 Image_ErrorCode ret = OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_NV21);
1096 EXPECT_EQ(ret, IMAGE_SUCCESS);
1097 ret = OH_DecodingOptions_SetDesiredDynamicRange(opts, IMAGE_DYNAMIC_RANGE::IMAGE_DYNAMIC_RANGE_HDR);
1098 EXPECT_EQ(ret, IMAGE_SUCCESS);
1099 OH_PixelmapNative* resPixMap = nullptr;
1100 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_DMA;
1101 ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
1102 EXPECT_EQ(ret, IMAGE_SUCCESS);
1103 EXPECT_NE(resPixMap, nullptr);
1104 OH_ImageSourceNative_Release(imageSource);
1105 OH_DecodingOptions_Release(opts);
1106 OH_PixelmapNative_Release(resPixMap);
1107 }
1108
1109 /**
1110 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest016
1111 * @tc.desc: Test the creation of a pixelmap using a DMA allocator, with NV21 pixel format and auto dynamic range,
1112 * expecting successful operation.
1113 * @tc.type: FUNC
1114 */
1115 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest016, TestSize.Level1)
1116 {
1117 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_HDR_PATH);
1118 ASSERT_NE(imageSource, nullptr);
1119 OH_DecodingOptions *opts = nullptr;
1120 OH_DecodingOptions_Create(&opts);
1121 ASSERT_NE(opts, nullptr);
1122 Image_ErrorCode ret = OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_NV21);
1123 EXPECT_EQ(ret, IMAGE_SUCCESS);
1124 ret = OH_DecodingOptions_SetDesiredDynamicRange(opts, IMAGE_DYNAMIC_RANGE::IMAGE_DYNAMIC_RANGE_AUTO);
1125 EXPECT_EQ(ret, IMAGE_SUCCESS);
1126 OH_PixelmapNative* resPixMap = nullptr;
1127 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_DMA;
1128 ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
1129 EXPECT_EQ(ret, IMAGE_SUCCESS);
1130 EXPECT_NE(resPixMap, nullptr);
1131 OH_ImageSourceNative_Release(imageSource);
1132 OH_DecodingOptions_Release(opts);
1133 OH_PixelmapNative_Release(resPixMap);
1134 }
1135
1136 /**
1137 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest017
1138 * @tc.desc: Test the creation of a pixelmap using a shared memory allocator, with NV21 pixel format and HDR dynamic
1139 * range, expecting unsupported operation.
1140 * @tc.type: FUNC
1141 */
1142 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest017, TestSize.Level1)
1143 {
1144 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_HDR_PATH);
1145 ASSERT_NE(imageSource, nullptr);
1146 OH_DecodingOptions *opts = nullptr;
1147 OH_DecodingOptions_Create(&opts);
1148 ASSERT_NE(opts, nullptr);
1149 Image_ErrorCode ret = OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_NV21);
1150 EXPECT_EQ(ret, IMAGE_SUCCESS);
1151 ret = OH_DecodingOptions_SetDesiredDynamicRange(opts, IMAGE_DYNAMIC_RANGE::IMAGE_DYNAMIC_RANGE_HDR);
1152 EXPECT_EQ(ret, IMAGE_SUCCESS);
1153 OH_PixelmapNative* resPixMap = nullptr;
1154 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_SHARE_MEMORY;
1155 ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
1156 EXPECT_EQ(ret, IMAGE_SOURCE_UNSUPPORTED_ALLOCATOR_TYPE);
1157 EXPECT_EQ(resPixMap, nullptr);
1158 OH_ImageSourceNative_Release(imageSource);
1159 OH_DecodingOptions_Release(opts);
1160 OH_PixelmapNative_Release(resPixMap);
1161 }
1162
1163 /**
1164 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest018
1165 * @tc.desc: Test the creation of a pixelmap using a shared memory allocator, with NV21 pixel format and auto
1166 * dynamic range, expecting unsupported operation.
1167 * @tc.type: FUNC
1168 */
1169 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest018, TestSize.Level1)
1170 {
1171 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_HDR_PATH);
1172 ASSERT_NE(imageSource, nullptr);
1173 OH_DecodingOptions *opts = nullptr;
1174 OH_DecodingOptions_Create(&opts);
1175 ASSERT_NE(opts, nullptr);
1176 Image_ErrorCode ret = OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_NV21);
1177 EXPECT_EQ(ret, IMAGE_SUCCESS);
1178 ret = OH_DecodingOptions_SetDesiredDynamicRange(opts, IMAGE_DYNAMIC_RANGE::IMAGE_DYNAMIC_RANGE_AUTO);
1179 EXPECT_EQ(ret, IMAGE_SUCCESS);
1180 OH_PixelmapNative* resPixMap = nullptr;
1181 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_SHARE_MEMORY;
1182 ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
1183 EXPECT_EQ(ret, IMAGE_SOURCE_UNSUPPORTED_ALLOCATOR_TYPE);
1184 EXPECT_EQ(resPixMap, nullptr);
1185 OH_ImageSourceNative_Release(imageSource);
1186 OH_DecodingOptions_Release(opts);
1187 OH_PixelmapNative_Release(resPixMap);
1188 }
1189
1190 /**
1191 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest019
1192 * @tc.desc: Test the creation of a pixelmap using a shared memory allocator, with RGBA_8888 pixel format and HDR
1193 * dynamic range, expecting unsupported operation.
1194 * @tc.type: FUNC
1195 */
1196 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest019, TestSize.Level1)
1197 {
1198 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_HEIF_HDR_PATH);
1199 ASSERT_NE(imageSource, nullptr);
1200 OH_DecodingOptions *opts = nullptr;
1201 OH_DecodingOptions_Create(&opts);
1202 ASSERT_NE(opts, nullptr);
1203 Image_ErrorCode ret = OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_RGBA_8888);
1204 EXPECT_EQ(ret, IMAGE_SUCCESS);
1205 ret = OH_DecodingOptions_SetDesiredDynamicRange(opts, IMAGE_DYNAMIC_RANGE::IMAGE_DYNAMIC_RANGE_HDR);
1206 EXPECT_EQ(ret, IMAGE_SUCCESS);
1207 OH_PixelmapNative* resPixMap = nullptr;
1208 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_SHARE_MEMORY;
1209 ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
1210 EXPECT_EQ(ret, IMAGE_SOURCE_UNSUPPORTED_ALLOCATOR_TYPE);
1211 EXPECT_EQ(resPixMap, nullptr);
1212 OH_ImageSourceNative_Release(imageSource);
1213 OH_DecodingOptions_Release(opts);
1214 OH_PixelmapNative_Release(resPixMap);
1215 }
1216
1217 /**
1218 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest020
1219 * @tc.desc: Test the creation of a pixelmap using a shared memory allocator, with RGBA_8888 pixel format and auto
1220 * dynamic range, expecting unsupported operation.
1221 * @tc.type: FUNC
1222 */
1223 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest020, TestSize.Level1)
1224 {
1225 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_HEIF_HDR_PATH);
1226 ASSERT_NE(imageSource, nullptr);
1227 OH_DecodingOptions *opts = nullptr;
1228 OH_DecodingOptions_Create(&opts);
1229 ASSERT_NE(opts, nullptr);
1230 Image_ErrorCode ret = OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_RGBA_8888);
1231 EXPECT_EQ(ret, IMAGE_SUCCESS);
1232 ret = OH_DecodingOptions_SetDesiredDynamicRange(opts, IMAGE_DYNAMIC_RANGE::IMAGE_DYNAMIC_RANGE_AUTO);
1233 EXPECT_EQ(ret, IMAGE_SUCCESS);
1234 OH_PixelmapNative* resPixMap = nullptr;
1235 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_SHARE_MEMORY;
1236 ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
1237 EXPECT_EQ(ret, IMAGE_SOURCE_UNSUPPORTED_ALLOCATOR_TYPE);
1238 EXPECT_EQ(resPixMap, nullptr);
1239 OH_ImageSourceNative_Release(imageSource);
1240 OH_DecodingOptions_Release(opts);
1241 OH_PixelmapNative_Release(resPixMap);
1242 }
1243
1244 /**
1245 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest021
1246 * @tc.desc: Test the creation of a pixelmap using a DMA allocator, with RGBA_8888 pixel format and HDR dynamic range.
1247 * @tc.type: FUNC
1248 */
1249 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest021, TestSize.Level1)
1250 {
1251 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_HEIF_HDR_PATH);
1252 ASSERT_NE(imageSource, nullptr);
1253 OH_DecodingOptions *opts = nullptr;
1254 OH_DecodingOptions_Create(&opts);
1255 ASSERT_NE(opts, nullptr);
1256 Image_ErrorCode ret = OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_RGBA_8888);
1257 EXPECT_EQ(ret, IMAGE_SUCCESS);
1258 ret = OH_DecodingOptions_SetDesiredDynamicRange(opts, IMAGE_DYNAMIC_RANGE::IMAGE_DYNAMIC_RANGE_HDR);
1259 EXPECT_EQ(ret, IMAGE_SUCCESS);
1260 OH_PixelmapNative* resPixMap = nullptr;
1261 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_DMA;
1262 ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
1263 EXPECT_EQ(ret, IMAGE_SUCCESS);
1264 EXPECT_NE(resPixMap, nullptr);
1265 OH_ImageSourceNative_Release(imageSource);
1266 OH_DecodingOptions_Release(opts);
1267 OH_PixelmapNative_Release(resPixMap);
1268 }
1269
1270 /**
1271 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest022
1272 * @tc.desc: Test the creation of a pixelmap using a DMA allocator, with RGBA_8888 pixel format and auto dynamic range.
1273 * @tc.type: FUNC
1274 */
1275 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest022, TestSize.Level1)
1276 {
1277 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_HEIF_HDR_PATH);
1278 ASSERT_NE(imageSource, nullptr);
1279 OH_DecodingOptions *opts = nullptr;
1280 OH_DecodingOptions_Create(&opts);
1281 ASSERT_NE(opts, nullptr);
1282 Image_ErrorCode ret = OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_RGBA_8888);
1283 EXPECT_EQ(ret, IMAGE_SUCCESS);
1284 ret = OH_DecodingOptions_SetDesiredDynamicRange(opts, IMAGE_DYNAMIC_RANGE::IMAGE_DYNAMIC_RANGE_AUTO);
1285 EXPECT_EQ(ret, IMAGE_SUCCESS);
1286 OH_PixelmapNative* resPixMap = nullptr;
1287 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_DMA;
1288 ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
1289 EXPECT_EQ(ret, IMAGE_SUCCESS);
1290 EXPECT_NE(resPixMap, nullptr);
1291 OH_ImageSourceNative_Release(imageSource);
1292 OH_DecodingOptions_Release(opts);
1293 OH_PixelmapNative_Release(resPixMap);
1294 }
1295
1296 /**
1297 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest023
1298 * @tc.desc: Test the creation of a pixelmap using a DMA allocator, with NV21 pixel format and HDR dynamic range.
1299 * @tc.type: FUNC
1300 */
1301 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest023, TestSize.Level1)
1302 {
1303 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_HEIF_HDR_PATH);
1304 ASSERT_NE(imageSource, nullptr);
1305 OH_DecodingOptions *opts = nullptr;
1306 OH_DecodingOptions_Create(&opts);
1307 ASSERT_NE(opts, nullptr);
1308 Image_ErrorCode ret = OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_NV21);
1309 EXPECT_EQ(ret, IMAGE_SUCCESS);
1310 ret = OH_DecodingOptions_SetDesiredDynamicRange(opts, IMAGE_DYNAMIC_RANGE::IMAGE_DYNAMIC_RANGE_HDR);
1311 EXPECT_EQ(ret, IMAGE_SUCCESS);
1312 OH_PixelmapNative* resPixMap = nullptr;
1313 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_DMA;
1314 ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
1315 EXPECT_EQ(ret, IMAGE_SUCCESS);
1316 EXPECT_NE(resPixMap, nullptr);
1317 OH_ImageSourceNative_Release(imageSource);
1318 OH_DecodingOptions_Release(opts);
1319 OH_PixelmapNative_Release(resPixMap);
1320 }
1321
1322 /**
1323 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest024
1324 * @tc.desc: Test the creation of a pixelmap using a DMA allocator, with NV21 pixel format and auto dynamic range.
1325 * @tc.type: FUNC
1326 */
1327 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest024, TestSize.Level1)
1328 {
1329 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_HEIF_HDR_PATH);
1330 ASSERT_NE(imageSource, nullptr);
1331 OH_DecodingOptions *opts = nullptr;
1332 OH_DecodingOptions_Create(&opts);
1333 ASSERT_NE(opts, nullptr);
1334 Image_ErrorCode ret = OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_NV21);
1335 EXPECT_EQ(ret, IMAGE_SUCCESS);
1336 ret = OH_DecodingOptions_SetDesiredDynamicRange(opts, IMAGE_DYNAMIC_RANGE::IMAGE_DYNAMIC_RANGE_AUTO);
1337 EXPECT_EQ(ret, IMAGE_SUCCESS);
1338 OH_PixelmapNative* resPixMap = nullptr;
1339 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_DMA;
1340 ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
1341 EXPECT_EQ(ret, IMAGE_SUCCESS);
1342 EXPECT_NE(resPixMap, nullptr);
1343 OH_ImageSourceNative_Release(imageSource);
1344 OH_DecodingOptions_Release(opts);
1345 OH_PixelmapNative_Release(resPixMap);
1346 }
1347
1348 /**
1349 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest025
1350 * @tc.desc: Test the creation of a pixelmap using a shared memory allocator, with HDR dynamic range.
1351 * @tc.type: FUNC
1352 */
1353 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest025, TestSize.Level1)
1354 {
1355 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_HEIF_HDR_PATH);
1356 ASSERT_NE(imageSource, nullptr);
1357 OH_DecodingOptions *opts = nullptr;
1358 OH_DecodingOptions_Create(&opts);
1359 ASSERT_NE(opts, nullptr);
1360 auto ret = OH_DecodingOptions_SetDesiredDynamicRange(opts, IMAGE_DYNAMIC_RANGE::IMAGE_DYNAMIC_RANGE_HDR);
1361 EXPECT_EQ(ret, IMAGE_SUCCESS);
1362 OH_PixelmapNative* resPixMap = nullptr;
1363 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_SHARE_MEMORY;
1364 ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
1365 EXPECT_EQ(ret, IMAGE_SOURCE_UNSUPPORTED_ALLOCATOR_TYPE);
1366 EXPECT_EQ(resPixMap, nullptr);
1367 OH_ImageSourceNative_Release(imageSource);
1368 OH_DecodingOptions_Release(opts);
1369 OH_PixelmapNative_Release(resPixMap);
1370 }
1371
1372 /**
1373 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest026
1374 * @tc.desc: Test the creation of a pixelmap using a shared memory allocator, with NV21 pixel format and auto
1375 * dynamic range.
1376 * @tc.type: FUNC
1377 */
1378 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest026, TestSize.Level1)
1379 {
1380 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_HEIF_HDR_PATH);
1381 ASSERT_NE(imageSource, nullptr);
1382 OH_DecodingOptions *opts = nullptr;
1383 OH_DecodingOptions_Create(&opts);
1384 ASSERT_NE(opts, nullptr);
1385 Image_ErrorCode ret = OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_NV21);
1386 ASSERT_EQ(ret, IMAGE_SUCCESS);
1387 ret = OH_DecodingOptions_SetDesiredDynamicRange(opts, IMAGE_DYNAMIC_RANGE::IMAGE_DYNAMIC_RANGE_AUTO);
1388 ASSERT_EQ(ret, IMAGE_SUCCESS);
1389 OH_PixelmapNative* resPixMap = nullptr;
1390 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_SHARE_MEMORY;
1391 ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
1392 EXPECT_EQ(ret, IMAGE_SOURCE_UNSUPPORTED_ALLOCATOR_TYPE);
1393 EXPECT_EQ(resPixMap, nullptr);
1394 OH_ImageSourceNative_Release(imageSource);
1395 OH_DecodingOptions_Release(opts);
1396 OH_PixelmapNative_Release(resPixMap);
1397 }
1398
1399 /**
1400 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest027
1401 * @tc.desc: Test the creation of a pixelmap using a shared memory allocator, with ARGB pixel format and SDR
1402 * dynamic range.
1403 * @tc.type: FUNC
1404 */
1405 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest027, TestSize.Level1)
1406 {
1407 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_HDR_PATH);
1408 ASSERT_NE(imageSource, nullptr);
1409 OH_DecodingOptions *opts = nullptr;
1410 OH_DecodingOptions_Create(&opts);
1411 ASSERT_NE(opts, nullptr);
1412 OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_ARGB_8888);
1413 OH_DecodingOptions_SetDesiredDynamicRange(opts, IMAGE_DYNAMIC_RANGE::IMAGE_DYNAMIC_RANGE_SDR);
1414 OH_PixelmapNative* resPixMap = nullptr;
1415 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_SHARE_MEMORY;
1416 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
1417 EXPECT_EQ(ret, IMAGE_SUCCESS);
1418 EXPECT_NE(resPixMap, nullptr);
1419 EXPECT_EQ(resPixMap->GetInnerPixelmap()->GetPixelFormat(), PixelFormat::ARGB_8888);
1420 OH_ImageSourceNative_Release(imageSource);
1421 OH_DecodingOptions_Release(opts);
1422 OH_PixelmapNative_Release(resPixMap);
1423 }
1424
1425 /**
1426 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest028
1427 * @tc.desc: Test the creation of a pixelmap using a dma memory allocator, with ARGB pixel format and SDR
1428 * dynamic range.
1429 * @tc.type: FUNC
1430 */
1431 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest028, TestSize.Level1)
1432 {
1433 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_HDR_PATH);
1434 ASSERT_NE(imageSource, nullptr);
1435 OH_DecodingOptions *opts = nullptr;
1436 OH_DecodingOptions_Create(&opts);
1437 ASSERT_NE(opts, nullptr);
1438 OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_ARGB_8888);
1439 OH_DecodingOptions_SetDesiredDynamicRange(opts, IMAGE_DYNAMIC_RANGE::IMAGE_DYNAMIC_RANGE_SDR);
1440 OH_PixelmapNative* resPixMap = nullptr;
1441 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_DMA;
1442 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
1443 EXPECT_EQ(ret, IMAGE_SOURCE_UNSUPPORTED_ALLOCATOR_TYPE);
1444 EXPECT_EQ(resPixMap, nullptr);
1445 OH_ImageSourceNative_Release(imageSource);
1446 OH_DecodingOptions_Release(opts);
1447 OH_PixelmapNative_Release(resPixMap);
1448 }
1449
1450 /**
1451 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest029
1452 * @tc.desc: Test the creation of a pixelmap using a auto memory allocator, with ARGB pixel format and SDR
1453 * dynamic range.
1454 * @tc.type: FUNC
1455 */
1456 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest029, TestSize.Level1)
1457 {
1458 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_HDR_PATH);
1459 ASSERT_NE(imageSource, nullptr);
1460 OH_DecodingOptions *opts = nullptr;
1461 OH_DecodingOptions_Create(&opts);
1462 ASSERT_NE(opts, nullptr);
1463 OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_ARGB_8888);
1464 OH_DecodingOptions_SetDesiredDynamicRange(opts, IMAGE_DYNAMIC_RANGE::IMAGE_DYNAMIC_RANGE_SDR);
1465 OH_PixelmapNative* resPixMap = nullptr;
1466 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_AUTO;
1467 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
1468 EXPECT_EQ(ret, IMAGE_SUCCESS);
1469 EXPECT_NE(resPixMap, nullptr);
1470 EXPECT_EQ(resPixMap->GetInnerPixelmap()->GetPixelFormat(), PixelFormat::ARGB_8888);
1471 OH_ImageSourceNative_Release(imageSource);
1472 OH_DecodingOptions_Release(opts);
1473 OH_PixelmapNative_Release(resPixMap);
1474 }
1475
1476 /**
1477 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest030
1478 * @tc.desc: Test the creation of a pixelmap using a share memory allocator, with ARGB pixel format and HDR
1479 * dynamic range.
1480 * @tc.type: FUNC
1481 */
1482 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest030, TestSize.Level1)
1483 {
1484 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_HDR_PATH);
1485 ASSERT_NE(imageSource, nullptr);
1486 OH_DecodingOptions *opts = nullptr;
1487 OH_DecodingOptions_Create(&opts);
1488 ASSERT_NE(opts, nullptr);
1489 OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_ARGB_8888);
1490 OH_DecodingOptions_SetDesiredDynamicRange(opts, IMAGE_DYNAMIC_RANGE::IMAGE_DYNAMIC_RANGE_HDR);
1491 OH_PixelmapNative* resPixMap = nullptr;
1492 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_SHARE_MEMORY;
1493 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
1494 EXPECT_EQ(ret, IMAGE_SOURCE_UNSUPPORTED_ALLOCATOR_TYPE);
1495 EXPECT_EQ(resPixMap, nullptr);
1496 OH_ImageSourceNative_Release(imageSource);
1497 OH_DecodingOptions_Release(opts);
1498 OH_PixelmapNative_Release(resPixMap);
1499 }
1500
1501 /**
1502 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest031
1503 * @tc.desc: Test the creation of a pixelmap using a dma memory allocator, with ARGB pixel format and HDR
1504 * dynamic range.
1505 * @tc.type: FUNC
1506 */
1507 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest031, TestSize.Level1)
1508 {
1509 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_HDR_PATH);
1510 ASSERT_NE(imageSource, nullptr);
1511 OH_DecodingOptions *opts = nullptr;
1512 OH_DecodingOptions_Create(&opts);
1513 ASSERT_NE(opts, nullptr);
1514 OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_ARGB_8888);
1515 OH_DecodingOptions_SetDesiredDynamicRange(opts, IMAGE_DYNAMIC_RANGE::IMAGE_DYNAMIC_RANGE_HDR);
1516 OH_PixelmapNative* resPixMap = nullptr;
1517 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_DMA;
1518 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
1519 EXPECT_EQ(ret, IMAGE_SUCCESS);
1520 EXPECT_NE(resPixMap, nullptr);
1521 EXPECT_EQ(resPixMap->GetInnerPixelmap()->GetPixelFormat(), PixelFormat::RGBA_1010102);
1522 OH_ImageSourceNative_Release(imageSource);
1523 OH_DecodingOptions_Release(opts);
1524 OH_PixelmapNative_Release(resPixMap);
1525 }
1526
1527 /**
1528 * @tc.name: OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest032
1529 * @tc.desc: Test the creation of a pixelmap using a auto memory allocator, with ARGB pixel format and HDR
1530 * dynamic range.
1531 * @tc.type: FUNC
1532 */
1533 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapUsingAllocatorTest032, TestSize.Level1)
1534 {
1535 OH_ImageSourceNative *imageSource = CreateImageSourceNative(IMAGE_JPEG_HDR_PATH);
1536 ASSERT_NE(imageSource, nullptr);
1537 OH_DecodingOptions *opts = nullptr;
1538 OH_DecodingOptions_Create(&opts);
1539 ASSERT_NE(opts, nullptr);
1540 OH_DecodingOptions_SetPixelFormat(opts, PIXEL_FORMAT_ARGB_8888);
1541 OH_DecodingOptions_SetDesiredDynamicRange(opts, IMAGE_DYNAMIC_RANGE::IMAGE_DYNAMIC_RANGE_HDR);
1542 OH_PixelmapNative* resPixMap = nullptr;
1543 IMAGE_ALLOCATOR_TYPE allocator = IMAGE_ALLOCATOR_TYPE::IMAGE_ALLOCATOR_TYPE_AUTO;
1544 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmapUsingAllocator(imageSource, opts, allocator, &resPixMap);
1545 EXPECT_EQ(ret, IMAGE_SUCCESS);
1546 EXPECT_NE(resPixMap, nullptr);
1547 EXPECT_EQ(resPixMap->GetInnerPixelmap()->GetPixelFormat(), PixelFormat::RGBA_1010102);
1548 OH_ImageSourceNative_Release(imageSource);
1549 OH_DecodingOptions_Release(opts);
1550 OH_PixelmapNative_Release(resPixMap);
1551 }
1552
1553 /**
1554 * @tc.name: OH_ImageSourceNative_CreatePixelmapList
1555 * @tc.desc: test OH_ImageSourceNative_CreatePixelmapList
1556 * @tc.type: FUNC
1557 */
1558 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePixelmapList, TestSize.Level3)
1559 {
1560 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapList start";
1561 OH_DecodingOptions *ops = nullptr;
1562 OH_ImageSourceNative *imageSource = nullptr;
1563 OH_PixelmapNative** resVecPixMap = nullptr;
1564 size_t outSize = 0;
1565 Image_ErrorCode ret = OH_ImageSourceNative_CreatePixelmapList(imageSource, ops, resVecPixMap, outSize);
1566 ASSERT_EQ(ret, IMAGE_BAD_PARAMETER);
1567 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_CreatePixelmapList end";
1568 }
1569
1570 /**
1571 * @tc.name: OH_ImageSourceNative_GetDelayTimeList
1572 * @tc.desc: test OH_ImageSourceNative_GetDelayTimeList
1573 * @tc.type: FUNC
1574 */
1575 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_GetDelayTimeList, TestSize.Level3)
1576 {
1577 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_GetDelayTimeList start";
1578 OH_ImageSourceNative *imageSource = nullptr;
1579 int32_t* delayTimeList = nullptr;
1580 size_t size = 0;
1581 Image_ErrorCode ret = OH_ImageSourceNative_GetDelayTimeList(imageSource, delayTimeList, size);
1582 ASSERT_EQ(ret, IMAGE_BAD_PARAMETER);
1583 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_GetDelayTimeList end";
1584 }
1585
1586 /**
1587 * @tc.name: OH_ImageSourceNative_GetImageInfo
1588 * @tc.desc: test OH_ImageSourceNative_GetImageInfo
1589 * @tc.type: FUNC
1590 */
1591 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_GetImageInfo, TestSize.Level3)
1592 {
1593 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_GetImageInfo start";
1594 OH_ImageSourceNative *imageSource = nullptr;
1595 int32_t index = 0;
1596 OH_ImageSource_Info* info = nullptr;
1597 Image_ErrorCode ret = OH_ImageSourceNative_GetImageInfo(imageSource, index, info);
1598 ASSERT_EQ(ret, IMAGE_BAD_PARAMETER);
1599 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_GetImageInfo end";
1600 }
1601
1602 /**
1603 * @tc.name: OH_ImageSourceNative_GetImageProperty
1604 * @tc.desc: test OH_ImageSourceNative_GetImageProperty
1605 * @tc.type: FUNC
1606 */
1607 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_GetImageProperty, TestSize.Level3)
1608 {
1609 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_GetImageProperty start";
1610 OH_ImageSourceNative *imageSource = nullptr;
1611 Image_String* key = nullptr;
1612 Image_String* value = nullptr;
1613 Image_ErrorCode ret = OH_ImageSourceNative_GetImageProperty(imageSource, key, value);
1614 ASSERT_EQ(ret, IMAGE_BAD_PARAMETER);
1615 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_GetImageProperty end";
1616 }
1617
1618 /**
1619 * @tc.name: OH_ImageSourceNative_ModifyImageProperty
1620 * @tc.desc: test OH_ImageSourceNative_ModifyImageProperty
1621 * @tc.type: FUNC
1622 */
1623 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_ModifyImageProperty, TestSize.Level3)
1624 {
1625 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_ModifyImageProperty start";
1626 OH_ImageSourceNative *imageSource = nullptr;
1627 Image_String* key = nullptr;
1628 Image_String* value = nullptr;
1629 Image_ErrorCode ret = OH_ImageSourceNative_ModifyImageProperty(imageSource, key, value);
1630 ASSERT_EQ(ret, IMAGE_BAD_PARAMETER);
1631 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_ModifyImageProperty end";
1632 }
1633
1634 /**
1635 * @tc.name: OH_ImageSourceNative_GetFrameCount
1636 * @tc.desc: test OH_ImageSourceNative_GetFrameCount
1637 * @tc.type: FUNC
1638 */
1639 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_GetFrameCount, TestSize.Level3)
1640 {
1641 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_GetFrameCount start";
1642 OH_ImageSourceNative *imageSource = nullptr;
1643 uint32_t* res = nullptr;
1644 Image_ErrorCode ret = OH_ImageSourceNative_GetFrameCount(imageSource, res);
1645 ASSERT_EQ(ret, IMAGE_BAD_PARAMETER);
1646 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_GetFrameCount end";
1647 }
1648
1649 /**
1650 * @tc.name: OH_ImageSourceNative_Release
1651 * @tc.desc: test OH_ImageSourceNative_Release
1652 * @tc.type: FUNC
1653 */
1654 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_Release, TestSize.Level3)
1655 {
1656 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_Release start";
1657 OH_ImageSourceNative *imageSource = nullptr;
1658 Image_ErrorCode ret = OH_ImageSourceNative_Release(imageSource);
1659 ASSERT_EQ(ret, IMAGE_BAD_PARAMETER);
1660 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceNative_Release end";
1661 }
1662
1663 /**
1664 * @tc.name: OH_ImageSourceInfo_GetMimeType001
1665 * @tc.desc: test OH_ImageSourceInfo_GetMimeType
1666 * @tc.type: FUNC
1667 */
1668 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceInfo_GetMimeType001, TestSize.Level3)
1669 {
1670 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceInfo_GetMimeType001 start";
1671 OH_ImageSource_Info *info1 = nullptr;
1672 Image_ErrorCode ret = OH_ImageSourceInfo_Create(&info1);
1673 ASSERT_EQ(ret, IMAGE_SUCCESS);
1674 ASSERT_NE(info1, nullptr);
1675 OH_ImageSource_Info *info2 = nullptr;
1676
1677 Image_MimeType mimeType1;
1678 Image_MimeType *mimeType2 = nullptr;
1679 ret = OH_ImageSourceInfo_GetMimeType(info1, &mimeType1);
1680 EXPECT_EQ(ret, IMAGE_UNKNOWN_MIME_TYPE);
1681 ret = OH_ImageSourceInfo_GetMimeType(info2, &mimeType1);
1682 EXPECT_EQ(ret, IMAGE_BAD_PARAMETER);
1683 ret = OH_ImageSourceInfo_GetMimeType(info1, mimeType2);
1684 EXPECT_EQ(ret, IMAGE_BAD_PARAMETER);
1685 ret = OH_ImageSourceInfo_GetMimeType(info2, mimeType2);
1686 EXPECT_EQ(ret, IMAGE_BAD_PARAMETER);
1687
1688 ret = OH_ImageSourceInfo_Release(info1);
1689 EXPECT_EQ(ret, IMAGE_SUCCESS);
1690 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceInfo_GetMimeType001 end";
1691 }
1692
1693 /**
1694 * @tc.name: OH_ImageSourceInfo_GetMimeType002
1695 * @tc.desc: test OH_ImageSourceInfo_GetMimeType
1696 * @tc.type: FUNC
1697 */
1698 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceInfo_GetMimeType002, TestSize.Level3)
1699 {
1700 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceInfo_GetMimeType002 start";
1701 OH_ImageSource_Info *info = nullptr;
1702 Image_ErrorCode ret = OH_ImageSourceInfo_Create(&info);
1703 ASSERT_EQ(ret, IMAGE_SUCCESS);
1704
1705 Image_MimeType mimeType;
1706 ret = OH_ImageSourceInfo_GetMimeType(info, &mimeType);
1707 EXPECT_EQ(ret, IMAGE_UNKNOWN_MIME_TYPE);
1708
1709 info->mimeType.size = TestLength;
1710 ret = OH_ImageSourceInfo_GetMimeType(info, &mimeType);
1711 EXPECT_EQ(ret, IMAGE_UNKNOWN_MIME_TYPE);
1712
1713 ret = OH_ImageSourceInfo_Release(info);
1714 EXPECT_EQ(ret, IMAGE_SUCCESS);
1715 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceInfo_GetMimeType002 end";
1716 }
1717
1718 /**
1719 * @tc.name: OH_ImageSourceInfo_GetMimeType003
1720 * @tc.desc: test OH_ImageSourceInfo_GetMimeType
1721 * @tc.type: FUNC
1722 */
1723 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceInfo_GetMimeType003, TestSize.Level3)
1724 {
1725 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceInfo_GetMimeType003 start";
1726 size_t length = IMAGE_JPEG_PATH_TEST.size();
1727 char filePath[length + 1];
1728 strcpy_s(filePath, sizeof(filePath), IMAGE_JPEG_PATH_TEST.c_str());
1729
1730 OH_ImageSourceNative *source = nullptr;
1731 Image_ErrorCode ret = OH_ImageSourceNative_CreateFromUri(filePath, length, &source);
1732 EXPECT_EQ(ret, IMAGE_SUCCESS);
1733 ASSERT_NE(source, nullptr);
1734
1735 OH_ImageSource_Info *info = nullptr;
1736 ret = OH_ImageSourceInfo_Create(&info);
1737 ASSERT_EQ(ret, IMAGE_SUCCESS);
1738 int32_t index = 0;
1739 ret = OH_ImageSourceNative_GetImageInfo(source, index, info);
1740 ASSERT_EQ(ret, IMAGE_SUCCESS);
1741
1742 Image_MimeType mimeType;
1743 ret = OH_ImageSourceInfo_GetMimeType(info, &mimeType);
1744 EXPECT_EQ(ret, IMAGE_SUCCESS);
1745 ASSERT_NE(mimeType.data, nullptr);
1746 EXPECT_EQ(strcmp(mimeType.data, IMAGE_JPEG_FORMAT.c_str()), 0);
1747
1748 info->mimeType.size = 0;
1749 ret = OH_ImageSourceInfo_GetMimeType(info, &mimeType);
1750 EXPECT_EQ(ret, IMAGE_UNKNOWN_MIME_TYPE);
1751
1752 ret = OH_ImageSourceNative_Release(source);
1753 EXPECT_EQ(ret, IMAGE_SUCCESS);
1754 ret = OH_ImageSourceInfo_Release(info);
1755 EXPECT_EQ(ret, IMAGE_SUCCESS);
1756 GTEST_LOG_(INFO) << "ImagSourceNdk2Test: OH_ImageSourceInfo_GetMimeType003 end";
1757 }
1758
1759 /**
1760 * @tc.name: OH_DecodingOptionsForPicture_CreateTest001
1761 * @tc.desc: Tests the creation of decoding options for a picture.
1762 * The test checks if the decoding options are created successfully.
1763 * @tc.type: FUNC
1764 */
1765 HWTEST_F(ImagSourceNdk2Test, OH_DecodingOptionsForPicture_CreateTest001, TestSize.Level1)
1766 {
1767 OH_DecodingOptionsForPicture *options = nullptr;
1768 Image_ErrorCode ret;
1769 ret = OH_DecodingOptionsForPicture_Create(&options);
1770 EXPECT_EQ(ret, IMAGE_SUCCESS);
1771 ret = OH_DecodingOptionsForPicture_Release(options);
1772 EXPECT_EQ(ret, IMAGE_SUCCESS);
1773 }
1774
1775 /**
1776 * @tc.name: OH_DecodingOptionsForPicture_ReleaseTest001
1777 * @tc.desc: test OH_DecodingOptionsForPicture_Release with a null pointer.
1778 * @tc.type: FUNC
1779 */
1780 HWTEST_F(ImagSourceNdk2Test, OH_DecodingOptionsForPicture_ReleaseTest001, TestSize.Level3)
1781 {
1782 Image_ErrorCode ret = OH_DecodingOptionsForPicture_Release(nullptr);
1783 EXPECT_EQ(ret, IMAGE_BAD_PARAMETER);
1784 }
1785
1786 /**
1787 * @tc.name: OH_DecodingOptionsForPicture_GetDesiredAuxiliaryPicturesTest001
1788 * @tc.desc: Tests getting the desired auxiliary pictures from decoding options.
1789 * The test checks if the set and get functions work correctly.
1790 * @tc.type: FUNC
1791 */
1792 HWTEST_F(ImagSourceNdk2Test, OH_DecodingOptionsForPicture_GetDesiredAuxiliaryPicturesTest001, TestSize.Level1)
1793 {
1794 OH_DecodingOptionsForPicture *options = nullptr;
1795 Image_ErrorCode ret = OH_DecodingOptionsForPicture_Create(&options);
1796 EXPECT_EQ(ret, IMAGE_SUCCESS);
1797 ASSERT_NE(options, nullptr);
1798 size_t srcLength = TestLength;
1799 Image_AuxiliaryPictureType srcAuxTypeList[srcLength];
1800 srcAuxTypeList[0] = AUXILIARY_PICTURE_TYPE_GAINMAP;
1801 srcAuxTypeList[1] = AUXILIARY_PICTURE_TYPE_DEPTH_MAP;
1802 OH_DecodingOptionsForPicture_SetDesiredAuxiliaryPictures(options, srcAuxTypeList, srcLength);
1803 Image_AuxiliaryPictureType *dstAuxTypeList = nullptr;
1804 size_t dstLength = 0;
1805 ret = OH_DecodingOptionsForPicture_GetDesiredAuxiliaryPictures(options, &dstAuxTypeList, &dstLength);
1806 EXPECT_EQ(ret, IMAGE_SUCCESS);
1807 ASSERT_NE(dstAuxTypeList, nullptr);
1808 EXPECT_EQ(srcLength, dstLength);
1809 for (size_t index = 0; index < srcLength; index++) {
1810 EXPECT_EQ(srcAuxTypeList[index], dstAuxTypeList[index]);
1811 }
1812 delete[] dstAuxTypeList;
1813 ret = OH_DecodingOptionsForPicture_Release(options);
1814 EXPECT_EQ(ret, IMAGE_SUCCESS);
1815 }
1816
1817 /**
1818 * @tc.name: OH_DecodingOptionsForPicture_GetDesiredAuxiliaryPicturesTest002
1819 * @tc.desc: test OH_DecodingOptionsForPicture_GetDesiredAuxiliaryPictures with null pointers.
1820 * @tc.type: FUNC
1821 */
1822 HWTEST_F(ImagSourceNdk2Test, OH_DecodingOptionsForPicture_GetDesiredAuxiliaryPicturesTest002, TestSize.Level3)
1823 {
1824 Image_ErrorCode ret = OH_DecodingOptionsForPicture_GetDesiredAuxiliaryPictures(nullptr, nullptr, nullptr);
1825 EXPECT_EQ(ret, IMAGE_BAD_PARAMETER);
1826 }
1827
1828 /**
1829 * @tc.name: OH_DecodingOptionsForPicture_SetDesiredAuxiliaryPicturesTest001
1830 * @tc.desc: test OH_DecodingOptionsForPicture_SetDesiredAuxiliaryPictures with null pointers.
1831 * @tc.type: FUNC
1832 */
1833 HWTEST_F(ImagSourceNdk2Test, OH_DecodingOptionsForPicture_SetDesiredAuxiliaryPicturesTest001, TestSize.Level3)
1834 {
1835 Image_ErrorCode ret = OH_DecodingOptionsForPicture_SetDesiredAuxiliaryPictures(nullptr, nullptr, 0);
1836 EXPECT_EQ(ret, IMAGE_BAD_PARAMETER);
1837 }
1838
1839 /**
1840 * @tc.name: OH_ImageSourceNative_CreatePictureTest001
1841 * @tc.desc: test OH_ImageSourceNative_CreatePicture with null pointers.
1842 * @tc.type: FUNC
1843 */
1844 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePictureTest001, TestSize.Level3)
1845 {
1846 OH_ImageSourceNative *source = nullptr;
1847 OH_DecodingOptionsForPicture *options = nullptr;
1848 OH_PictureNative **picture = nullptr;
1849 Image_ErrorCode ret = OH_ImageSourceNative_CreatePicture(source, options, picture);
1850 ASSERT_EQ(ret, IMAGE_BAD_PARAMETER);
1851 }
1852
1853 /**
1854 * @tc.name: OH_ImageSourceNative_CreatePictureTest002
1855 * @tc.desc: Tests creating an image from a raw buffer and then extracting a picture from it.
1856 * The test checks if the creation and release of resources are successful
1857 * @tc.type: FUNC
1858 */
1859 HWTEST_F(ImagSourceNdk2Test, OH_ImageSourceNative_CreatePictureTest002, TestSize.Level1)
1860 {
1861 size_t length = IMAGE_JPEG_PATH.size();
1862 char filePath[length + 1];
1863 strcpy_s(filePath, sizeof(filePath), IMAGE_JPEG_PATH.c_str());
1864
1865 OH_ImageSourceNative *source = nullptr;
1866 OH_DecodingOptionsForPicture *options = nullptr;
1867 OH_PictureNative *picture = nullptr;
1868 Image_ErrorCode ret = OH_ImageSourceNative_CreateFromUri(filePath, length, &source);
1869 EXPECT_EQ(ret, IMAGE_SUCCESS);
1870 ASSERT_NE(source, nullptr);
1871
1872 ret = OH_DecodingOptionsForPicture_Create(&options);
1873 EXPECT_EQ(ret, IMAGE_SUCCESS);
1874 ASSERT_NE(options, nullptr);
1875
1876 ret = OH_ImageSourceNative_CreatePicture(source, options, &picture);
1877 ASSERT_EQ(ret, IMAGE_SUCCESS);
1878 ASSERT_NE(picture, nullptr);
1879
1880 ret = OH_ImageSourceNative_Release(source);
1881 ASSERT_EQ(ret, IMAGE_SUCCESS);
1882 ret = OH_DecodingOptionsForPicture_Release(options);
1883 ASSERT_EQ(ret, IMAGE_SUCCESS);
1884 OH_PictureNative_Release(picture);
1885 ASSERT_EQ(ret, IMAGE_SUCCESS);
1886 }
1887 }
1888 }
1889