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 #define private public 16 #define protected public 17 #include <gtest/gtest.h> 18 #include <fstream> 19 #include "post_proc.h" 20 #include "image_source.h" 21 #include "image_type.h" 22 #include "image_utils.h" 23 #include "media_errors.h" 24 #include "pixel_map.h" 25 #include "image_source_util.h" 26 #include "memory_manager.h" 27 28 using namespace testing::ext; 29 using namespace OHOS::Media; 30 31 namespace OHOS { 32 namespace Multimedia { 33 static const std::string IMAGE_INPUT_JPEG_PATH = "/data/local/tmp/image/test.jpg"; 34 class PostProcTest : public testing::Test { 35 public: PostProcTest()36 PostProcTest() {} ~PostProcTest()37 ~PostProcTest() {} 38 }; 39 40 /** 41 * @tc.name: PostProcTest001 42 * @tc.desc: test DecodePostProc 43 * @tc.type: FUNC 44 */ 45 HWTEST_F(PostProcTest, PostProcTest001, TestSize.Level3) 46 { 47 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest001 start"; 48 std::unique_ptr<std::fstream> fs = std::make_unique<std::fstream>(); 49 fs->open("/data/local/tmp/image/test.jpg", std::fstream::binary | std::fstream::in); 50 bool isOpen = fs->is_open(); 51 ASSERT_EQ(isOpen, true); 52 uint32_t errorCode = 0; 53 SourceOptions opts; 54 std::unique_ptr<ImageSource> imageSource = ImageSource::CreateImageSource(std::move(fs), opts, errorCode); 55 ASSERT_EQ(errorCode, SUCCESS); 56 ASSERT_NE(imageSource.get(), nullptr); 57 58 DecodeOptions decodeOpts; 59 decodeOpts.CropRect.top = 3; 60 decodeOpts.CropRect.width = 100; 61 decodeOpts.CropRect.left = 3; 62 decodeOpts.CropRect.height = 200; 63 decodeOpts.desiredSize.width = 200; 64 decodeOpts.desiredSize.height = 400; 65 decodeOpts.rotateDegrees = 90; 66 std::unique_ptr<PixelMap> pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); 67 ASSERT_EQ(errorCode, SUCCESS); 68 ASSERT_NE(pixelMap.get(), nullptr); 69 70 PostProc postProc; 71 FinalOutputStep finalOutputStep = FinalOutputStep::NO_CHANGE; 72 errorCode = postProc.DecodePostProc(decodeOpts, *(pixelMap.get()), finalOutputStep); 73 ASSERT_EQ(errorCode, SUCCESS); 74 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest001 end"; 75 } 76 77 /** 78 * @tc.name: PostProcTest003 79 * @tc.desc: test DecodePostProc ROTATE_CHANGE 80 * @tc.type: FUNC 81 */ 82 HWTEST_F(PostProcTest, PostProcTest003, TestSize.Level3) 83 { 84 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest003 start"; 85 std::unique_ptr<std::fstream> fs = std::make_unique<std::fstream>(); 86 fs->open("/data/local/tmp/image/test.jpg", std::fstream::binary | std::fstream::in); 87 bool isOpen = fs->is_open(); 88 ASSERT_EQ(isOpen, true); 89 uint32_t errorCode = 0; 90 SourceOptions opts; 91 std::unique_ptr<ImageSource> imageSource = ImageSource::CreateImageSource(std::move(fs), opts, errorCode); 92 ASSERT_EQ(errorCode, SUCCESS); 93 ASSERT_NE(imageSource.get(), nullptr); 94 95 DecodeOptions decodeOpts; 96 decodeOpts.CropRect.top = 3; 97 decodeOpts.CropRect.width = 100; 98 decodeOpts.CropRect.left = 3; 99 decodeOpts.CropRect.height = 200; 100 decodeOpts.desiredSize.width = 200; 101 decodeOpts.desiredSize.height = 400; 102 decodeOpts.rotateDegrees = 90; 103 std::unique_ptr<PixelMap> pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); 104 ASSERT_EQ(errorCode, SUCCESS); 105 ASSERT_NE(pixelMap.get(), nullptr); 106 107 PostProc postProc; 108 FinalOutputStep finalOutputStep = FinalOutputStep::ROTATE_CHANGE; 109 errorCode = postProc.DecodePostProc(decodeOpts, *(pixelMap.get()), finalOutputStep); 110 ASSERT_EQ(errorCode, SUCCESS); 111 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest003 end"; 112 } 113 114 /** 115 * @tc.name: PostProcTest004 116 * @tc.desc: test DecodePostProc SIZE_CHANGE 117 * @tc.type: FUNC 118 */ 119 HWTEST_F(PostProcTest, PostProcTest004, TestSize.Level3) 120 { 121 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest004 start"; 122 123 std::unique_ptr<std::fstream> fs = std::make_unique<std::fstream>(); 124 fs->open("/data/local/tmp/image/test.jpg", std::fstream::binary | std::fstream::in); 125 bool isOpen = fs->is_open(); 126 ASSERT_EQ(isOpen, true); 127 uint32_t errorCode = 0; 128 SourceOptions opts; 129 std::unique_ptr<ImageSource> imageSource = ImageSource::CreateImageSource(std::move(fs), opts, errorCode); 130 ASSERT_EQ(errorCode, SUCCESS); 131 ASSERT_NE(imageSource.get(), nullptr); 132 133 DecodeOptions decodeOpts; 134 decodeOpts.CropRect.top = 3; 135 decodeOpts.CropRect.width = 100; 136 decodeOpts.CropRect.left = 3; 137 decodeOpts.CropRect.height = 200; 138 decodeOpts.desiredSize.width = 200; 139 decodeOpts.desiredSize.height = 400; 140 decodeOpts.rotateDegrees = 90; 141 std::unique_ptr<PixelMap> pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); 142 ASSERT_EQ(errorCode, SUCCESS); 143 ASSERT_NE(pixelMap.get(), nullptr); 144 145 PostProc postProc; 146 FinalOutputStep finalOutputStep = FinalOutputStep::SIZE_CHANGE; 147 errorCode = postProc.DecodePostProc(decodeOpts, *(pixelMap.get()), finalOutputStep); 148 ASSERT_EQ(errorCode, SUCCESS); 149 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest004 end"; 150 } 151 152 /** 153 * @tc.name: PostProcTest005 154 * @tc.desc: test DecodePostProc DENSITY_CHANGE 155 * @tc.type: FUNC 156 */ 157 HWTEST_F(PostProcTest, PostProcTest005, TestSize.Level3) 158 { 159 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest005 start"; 160 161 std::unique_ptr<std::fstream> fs = std::make_unique<std::fstream>(); 162 fs->open("/data/local/tmp/image/test.jpg", std::fstream::binary | std::fstream::in); 163 bool isOpen = fs->is_open(); 164 ASSERT_EQ(isOpen, true); 165 uint32_t errorCode = 0; 166 SourceOptions opts; 167 std::unique_ptr<ImageSource> imageSource = ImageSource::CreateImageSource(std::move(fs), opts, errorCode); 168 ASSERT_EQ(errorCode, SUCCESS); 169 ASSERT_NE(imageSource.get(), nullptr); 170 171 DecodeOptions decodeOpts; 172 decodeOpts.CropRect.top = 3; 173 decodeOpts.CropRect.width = 100; 174 decodeOpts.CropRect.left = 3; 175 decodeOpts.CropRect.height = 200; 176 decodeOpts.desiredSize.width = 200; 177 decodeOpts.desiredSize.height = 400; 178 decodeOpts.rotateDegrees = 90; 179 std::unique_ptr<PixelMap> pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); 180 ASSERT_EQ(errorCode, SUCCESS); 181 ASSERT_NE(pixelMap.get(), nullptr); 182 183 PostProc postProc; 184 FinalOutputStep finalOutputStep = FinalOutputStep::DENSITY_CHANGE; 185 errorCode = postProc.DecodePostProc(decodeOpts, *(pixelMap.get()), finalOutputStep); 186 ASSERT_EQ(errorCode, SUCCESS); 187 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest005 end"; 188 } 189 190 /** 191 * @tc.name: PostProcTest08 192 * @tc.desc: test CenterScale 193 * @tc.type: FUNC 194 */ 195 HWTEST_F(PostProcTest, PostProcTest008, TestSize.Level3) 196 { 197 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest008 start"; 198 std::unique_ptr<std::fstream> fs = std::make_unique<std::fstream>(); 199 fs->open("/data/local/tmp/image/test.jpg", std::fstream::binary | std::fstream::in); 200 bool isOpen = fs->is_open(); 201 ASSERT_EQ(isOpen, true); 202 uint32_t errorCode = 0; 203 SourceOptions opts; 204 std::unique_ptr<ImageSource> imageSource = ImageSource::CreateImageSource(std::move(fs), opts, errorCode); 205 ASSERT_EQ(errorCode, SUCCESS); 206 ASSERT_NE(imageSource.get(), nullptr); 207 208 DecodeOptions decodeOpts; 209 decodeOpts.CropRect.top = 3; 210 decodeOpts.CropRect.width = 100; 211 decodeOpts.CropRect.left = 3; 212 decodeOpts.CropRect.height = 200; 213 decodeOpts.desiredSize.width = 200; 214 decodeOpts.desiredSize.height = 400; 215 decodeOpts.rotateDegrees = 90; 216 std::unique_ptr<PixelMap> pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); 217 ASSERT_EQ(errorCode, SUCCESS); 218 ASSERT_NE(pixelMap.get(), nullptr); 219 220 PostProc postProc; 221 Size targetSize; 222 targetSize.width = 100; 223 targetSize.height = 200; 224 bool ret = postProc.CenterScale(targetSize, *pixelMap); 225 ASSERT_EQ(ret, true); 226 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest008 end"; 227 } 228 229 /** 230 * @tc.name: PostProcTest009 231 * @tc.desc: test CenterScale size is 0 or -1 232 * @tc.type: FUNC 233 */ 234 HWTEST_F(PostProcTest, PostProcTest009, TestSize.Level3) 235 { 236 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest009 start"; 237 std::unique_ptr<std::fstream> fs = std::make_unique<std::fstream>(); 238 fs->open("/data/local/tmp/image/test.jpg", std::fstream::binary | std::fstream::in); 239 bool isOpen = fs->is_open(); 240 ASSERT_EQ(isOpen, true); 241 uint32_t errorCode = 0; 242 SourceOptions opts; 243 std::unique_ptr<ImageSource> imageSource = ImageSource::CreateImageSource(std::move(fs), opts, errorCode); 244 ASSERT_EQ(errorCode, SUCCESS); 245 ASSERT_NE(imageSource.get(), nullptr); 246 247 DecodeOptions decodeOpts; 248 decodeOpts.CropRect.top = 3; 249 decodeOpts.CropRect.width = 100; 250 decodeOpts.CropRect.left = 3; 251 decodeOpts.CropRect.height = 200; 252 decodeOpts.desiredSize.width = 200; 253 decodeOpts.desiredSize.height = 400; 254 decodeOpts.rotateDegrees = 90; 255 std::unique_ptr<PixelMap> pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); 256 ASSERT_EQ(errorCode, SUCCESS); 257 ASSERT_NE(pixelMap.get(), nullptr); 258 259 PostProc postProc; 260 Size targetSize; 261 targetSize.width = 0; 262 targetSize.height = -1; 263 bool ret = postProc.CenterScale(targetSize, *pixelMap); 264 ASSERT_NE(ret, true); 265 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest009 end"; 266 } 267 268 /** 269 * @tc.name: PostProcTest0010 270 * @tc.desc: test CenterScale 271 * @tc.type: FUNC 272 */ 273 HWTEST_F(PostProcTest, PostProcTest0010, TestSize.Level3) 274 { 275 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0010 start"; 276 std::unique_ptr<std::fstream> fs = std::make_unique<std::fstream>(); 277 fs->open("/data/local/tmp/image/test.jpg", std::fstream::binary | std::fstream::in); 278 bool isOpen = fs->is_open(); 279 ASSERT_EQ(isOpen, true); 280 uint32_t errorCode = 0; 281 SourceOptions opts; 282 std::unique_ptr<ImageSource> imageSource = ImageSource::CreateImageSource(std::move(fs), opts, errorCode); 283 ASSERT_EQ(errorCode, SUCCESS); 284 ASSERT_NE(imageSource.get(), nullptr); 285 286 DecodeOptions decodeOpts; 287 decodeOpts.CropRect.top = 3; 288 decodeOpts.CropRect.width = 100; 289 decodeOpts.CropRect.left = 3; 290 decodeOpts.CropRect.height = 200; 291 decodeOpts.desiredSize.width = 200; 292 decodeOpts.desiredSize.height = 400; 293 decodeOpts.rotateDegrees = 90; 294 std::unique_ptr<PixelMap> pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); 295 ASSERT_EQ(errorCode, SUCCESS); 296 ASSERT_NE(pixelMap.get(), nullptr); 297 298 PostProc postProc; 299 Size targetSize; 300 targetSize.width = 200; 301 targetSize.height = 400; 302 bool ret = postProc.CenterScale(targetSize, *pixelMap); 303 ASSERT_EQ(ret, true); 304 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0010 end"; 305 } 306 307 /** 308 * @tc.name: PostProcTest0011 309 * @tc.desc: test CenterScale 310 * @tc.type: FUNC 311 */ 312 HWTEST_F(PostProcTest, PostProcTest0011, TestSize.Level3) 313 { 314 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0011 start"; 315 std::unique_ptr<std::fstream> fs = std::make_unique<std::fstream>(); 316 fs->open("/data/local/tmp/image/test.jpg", std::fstream::binary | std::fstream::in); 317 bool isOpen = fs->is_open(); 318 ASSERT_EQ(isOpen, true); 319 uint32_t errorCode = 0; 320 SourceOptions opts; 321 std::unique_ptr<ImageSource> imageSource = ImageSource::CreateImageSource(std::move(fs), opts, errorCode); 322 ASSERT_EQ(errorCode, SUCCESS); 323 ASSERT_NE(imageSource.get(), nullptr); 324 325 DecodeOptions decodeOpts; 326 decodeOpts.CropRect.top = 3; 327 decodeOpts.CropRect.width = 100; 328 decodeOpts.CropRect.left = 3; 329 decodeOpts.CropRect.height = 200; 330 decodeOpts.desiredSize.width = 200; 331 decodeOpts.desiredSize.height = 400; 332 decodeOpts.rotateDegrees = 90; 333 std::unique_ptr<PixelMap> pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); 334 ASSERT_EQ(errorCode, SUCCESS); 335 ASSERT_NE(pixelMap.get(), nullptr); 336 337 PostProc postProc; 338 Size targetSize; 339 targetSize.width = 600; 340 targetSize.height = 900; 341 bool ret = postProc.CenterScale(targetSize, *pixelMap); 342 ASSERT_EQ(ret, true); 343 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0011 end"; 344 } 345 346 /** 347 * @tc.name: PostProcTest0012 348 * @tc.desc: test CenterScale 349 * @tc.type: FUNC 350 */ 351 HWTEST_F(PostProcTest, PostProcTest0012, TestSize.Level3) 352 { 353 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0012 start"; 354 int32_t width = 200; 355 int32_t height = 300; 356 InitializationOptions opts; 357 opts.size.width = width; 358 opts.size.height = height; 359 opts.pixelFormat = PixelFormat::ARGB_8888; 360 std::unique_ptr<PixelMap> pixelMap = PixelMap::Create(opts); 361 ASSERT_NE(pixelMap.get(), nullptr); 362 363 PostProc postProc; 364 Size targetSize; 365 targetSize.width = 400; 366 targetSize.height = 600; 367 bool ret = postProc.CenterScale(targetSize, *pixelMap); 368 ASSERT_EQ(ret, true); 369 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0012 end"; 370 } 371 372 /** 373 * @tc.name: PostProcTest0013 374 * @tc.desc: test CenterScale 375 * @tc.type: FUNC 376 */ 377 HWTEST_F(PostProcTest, PostProcTest0013, TestSize.Level3) 378 { 379 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0013 start"; 380 int32_t width = 200; 381 int32_t height = 300; 382 InitializationOptions opts; 383 opts.size.width = width; 384 opts.size.height = height; 385 opts.pixelFormat = PixelFormat::ARGB_8888; 386 std::unique_ptr<PixelMap> pixelMap = PixelMap::Create(opts); 387 ASSERT_NE(pixelMap.get(), nullptr); 388 389 PostProc postProc; 390 Size targetSize; 391 targetSize.width = 100; 392 targetSize.height = 600; 393 bool ret = postProc.CenterScale(targetSize, *pixelMap); 394 ASSERT_EQ(ret, true); 395 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0013 end"; 396 } 397 398 /** 399 * @tc.name: PostProcTest0014 400 * @tc.desc: test CenterScale 401 * @tc.type: FUNC 402 */ 403 HWTEST_F(PostProcTest, PostProcTest0014, TestSize.Level3) 404 { 405 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0014 start"; 406 int32_t width = 200; 407 int32_t height = 300; 408 InitializationOptions opts; 409 opts.size.width = width; 410 opts.size.height = height; 411 opts.pixelFormat = PixelFormat::ARGB_8888; 412 std::unique_ptr<PixelMap> pixelMap = PixelMap::Create(opts); 413 ASSERT_NE(pixelMap.get(), nullptr); 414 415 PostProc postProc; 416 Size targetSize; 417 targetSize.width = 400; 418 targetSize.height = 200; 419 bool ret = postProc.CenterScale(targetSize, *pixelMap); 420 ASSERT_EQ(ret, true); 421 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0014 end"; 422 } 423 424 /** 425 * @tc.name: PostProcTest0016 426 * @tc.desc: test ConvertProc 427 * @tc.type: FUNC 428 */ 429 HWTEST_F(PostProcTest, PostProcTest0016, TestSize.Level3) 430 { 431 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0016 start"; 432 Rect cropRect; 433 cropRect.top = 3; 434 cropRect.width = 100; 435 cropRect.left = 3; 436 cropRect.height = 200; 437 std::unique_ptr<std::fstream> fs = std::make_unique<std::fstream>(); 438 fs->open("/data/local/tmp/image/test.jpg", std::fstream::binary | std::fstream::in); 439 bool isOpen = fs->is_open(); 440 ASSERT_EQ(isOpen, true); 441 uint32_t errorCode = 0; 442 SourceOptions opts; 443 std::unique_ptr<ImageSource> imageSource = ImageSource::CreateImageSource(std::move(fs), opts, errorCode); 444 ASSERT_EQ(errorCode, SUCCESS); 445 ASSERT_NE(imageSource.get(), nullptr); 446 447 DecodeOptions decodeOpts; 448 decodeOpts.CropRect.top = 3; 449 decodeOpts.CropRect.width = 100; 450 decodeOpts.CropRect.left = 3; 451 decodeOpts.CropRect.height = 200; 452 decodeOpts.desiredSize.width = 200; 453 decodeOpts.desiredSize.height = 400; 454 decodeOpts.rotateDegrees = 90; 455 std::unique_ptr<PixelMap> pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); 456 ASSERT_EQ(errorCode, SUCCESS); 457 ASSERT_NE(pixelMap.get(), nullptr); 458 459 PostProc postProc; 460 ImageInfo srcImageInfo; 461 ImageInfo dstImageInfo; 462 pixelMap->GetImageInfo(srcImageInfo); 463 uint32_t ret = postProc.ConvertProc(cropRect, dstImageInfo, *pixelMap, srcImageInfo); 464 ASSERT_NE(ret, -1); 465 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0016 end"; 466 } 467 468 /** 469 * @tc.name: PostProcTest0017 470 * @tc.desc: test ConvertProc 471 * @tc.type: FUNC 472 */ 473 HWTEST_F(PostProcTest, PostProcTest0017, TestSize.Level3) 474 { 475 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0016 start"; 476 Rect cropRect; 477 cropRect.top = 0; 478 cropRect.width = 100; 479 cropRect.left = 0; 480 cropRect.height = 200; 481 std::unique_ptr<std::fstream> fs = std::make_unique<std::fstream>(); 482 fs->open("/data/local/tmp/image/test.jpg", std::fstream::binary | std::fstream::in); 483 bool isOpen = fs->is_open(); 484 ASSERT_EQ(isOpen, true); 485 uint32_t errorCode = 0; 486 SourceOptions opts; 487 std::unique_ptr<ImageSource> imageSource = ImageSource::CreateImageSource(std::move(fs), opts, errorCode); 488 ASSERT_EQ(errorCode, SUCCESS); 489 ASSERT_NE(imageSource.get(), nullptr); 490 491 DecodeOptions decodeOpts; 492 decodeOpts.CropRect.top = 0; 493 decodeOpts.CropRect.width = 100; 494 decodeOpts.CropRect.left = 0; 495 decodeOpts.CropRect.height = 200; 496 decodeOpts.desiredSize.width = 100; 497 decodeOpts.desiredSize.height = 200; 498 std::unique_ptr<PixelMap> pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); 499 ASSERT_EQ(errorCode, SUCCESS); 500 ASSERT_NE(pixelMap.get(), nullptr); 501 502 PostProc postProc; 503 ImageInfo srcImageInfo; 504 ImageInfo dstImageInfo; 505 pixelMap->GetImageInfo(srcImageInfo); 506 srcImageInfo.pixelFormat = PixelFormat::ARGB_8888; 507 dstImageInfo.pixelFormat = PixelFormat::ARGB_8888; 508 uint32_t ret = postProc.ConvertProc(cropRect, dstImageInfo, *pixelMap, srcImageInfo); 509 ASSERT_EQ(ret, SUCCESS); 510 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0016 end"; 511 } 512 513 /** 514 * @tc.name: PostProcTest0018 515 * @tc.desc: test ConvertProc 516 * @tc.type: FUNC 517 */ 518 HWTEST_F(PostProcTest, PostProcTest0018, TestSize.Level3) 519 { 520 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0018 start"; 521 Rect cropRect; 522 cropRect.top = 0; 523 cropRect.width = 100; 524 cropRect.left = 0; 525 cropRect.height = 200; 526 std::unique_ptr<std::fstream> fs = std::make_unique<std::fstream>(); 527 fs->open("/data/local/tmp/image/test.jpg", std::fstream::binary | std::fstream::in); 528 bool isOpen = fs->is_open(); 529 ASSERT_EQ(isOpen, true); 530 uint32_t errorCode = 0; 531 SourceOptions opts; 532 std::unique_ptr<ImageSource> imageSource = ImageSource::CreateImageSource(std::move(fs), opts, errorCode); 533 ASSERT_EQ(errorCode, SUCCESS); 534 ASSERT_NE(imageSource.get(), nullptr); 535 536 DecodeOptions decodeOpts; 537 decodeOpts.CropRect.top = 3; 538 decodeOpts.CropRect.width = 100; 539 decodeOpts.CropRect.left = 3; 540 decodeOpts.CropRect.height = 200; 541 decodeOpts.desiredSize.width = 100; 542 decodeOpts.desiredSize.height = 200; 543 std::unique_ptr<PixelMap> pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); 544 ASSERT_EQ(errorCode, SUCCESS); 545 ASSERT_NE(pixelMap.get(), nullptr); 546 547 PostProc postProc; 548 ImageInfo srcImageInfo; 549 ImageInfo dstImageInfo; 550 pixelMap->GetImageInfo(srcImageInfo); 551 srcImageInfo.pixelFormat = PixelFormat::RGB_888; 552 dstImageInfo.pixelFormat = PixelFormat::ARGB_8888; 553 uint32_t ret = postProc.ConvertProc(cropRect, dstImageInfo, *pixelMap, srcImageInfo); 554 ASSERT_EQ(ret, SUCCESS); 555 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0018 end"; 556 } 557 558 /** 559 * @tc.name: PostProcTest0027 560 * @tc.desc:RotatePixelMap 561 * @tc.type: FUNC 562 */ 563 HWTEST_F(PostProcTest, PostProcTest0027, TestSize.Level3) 564 { 565 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0027 start"; 566 std::unique_ptr<std::fstream> fs = std::make_unique<std::fstream>(); 567 fs->open("/data/local/tmp/image/test.jpg", std::fstream::binary | std::fstream::in); 568 bool isOpen = fs->is_open(); 569 ASSERT_EQ(isOpen, true); 570 uint32_t errorCode = 0; 571 SourceOptions opts; 572 std::unique_ptr<ImageSource> imageSource = ImageSource::CreateImageSource(std::move(fs), opts, errorCode); 573 ASSERT_EQ(errorCode, SUCCESS); 574 ASSERT_NE(imageSource.get(), nullptr); 575 576 DecodeOptions decodeOpts; 577 decodeOpts.CropRect.top = 3; 578 decodeOpts.CropRect.width = 100; 579 decodeOpts.CropRect.left = 3; 580 decodeOpts.CropRect.height = 200; 581 decodeOpts.desiredSize.width = 200; 582 decodeOpts.desiredSize.height = 400; 583 decodeOpts.rotateDegrees = 90; 584 std::unique_ptr<PixelMap> pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); 585 ASSERT_EQ(errorCode, SUCCESS); 586 ASSERT_NE(pixelMap.get(), nullptr); 587 588 PostProc postProc; 589 bool ret = postProc.RotatePixelMap(decodeOpts.rotateDegrees, *pixelMap); 590 ASSERT_EQ(ret, true); 591 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0027 end"; 592 } 593 594 /** 595 * @tc.name: PostProcTest0028 596 * @tc.desc:ScalePixelMap 597 * @tc.type: FUNC 598 */ 599 HWTEST_F(PostProcTest, PostProcTest0028, TestSize.Level3) 600 { 601 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0028 start"; 602 std::unique_ptr<std::fstream> fs = std::make_unique<std::fstream>(); 603 fs->open("/data/local/tmp/image/test.jpg", std::fstream::binary | std::fstream::in); 604 bool isOpen = fs->is_open(); 605 ASSERT_EQ(isOpen, true); 606 uint32_t errorCode = 0; 607 SourceOptions opts; 608 std::unique_ptr<ImageSource> imageSource = ImageSource::CreateImageSource(std::move(fs), opts, errorCode); 609 ASSERT_EQ(errorCode, SUCCESS); 610 ASSERT_NE(imageSource.get(), nullptr); 611 612 DecodeOptions decodeOpts; 613 decodeOpts.CropRect.top = 3; 614 decodeOpts.CropRect.width = 100; 615 decodeOpts.CropRect.left = 3; 616 decodeOpts.CropRect.height = 200; 617 decodeOpts.desiredSize.width = 200; 618 decodeOpts.desiredSize.height = 400; 619 decodeOpts.rotateDegrees = 90; 620 std::unique_ptr<PixelMap> pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); 621 ASSERT_EQ(errorCode, SUCCESS); 622 ASSERT_NE(pixelMap.get(), nullptr); 623 624 PostProc postProc; 625 bool ret = postProc.ScalePixelMap(decodeOpts.desiredSize, *pixelMap); 626 ASSERT_EQ(ret, true); 627 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0028 end"; 628 } 629 630 HWTEST_F(PostProcTest, PostProcTest0030, TestSize.Level3) 631 { 632 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0030 start"; 633 uint32_t errorCode = 0; 634 SourceOptions opts; 635 std::unique_ptr<ImageSource> imageSource = ImageSource::CreateImageSource(IMAGE_INPUT_JPEG_PATH, opts, errorCode); 636 ASSERT_EQ(errorCode, SUCCESS); 637 ASSERT_NE(imageSource.get(), nullptr); 638 639 uint32_t index = 0; 640 DecodeOptions optsPixel; 641 errorCode = 0; 642 std::unique_ptr<PixelMap> pixelMap = imageSource->CreatePixelMap(index, optsPixel, errorCode); 643 ASSERT_EQ(errorCode, SUCCESS); 644 ASSERT_NE(pixelMap.get(), nullptr); 645 646 PostProc postProc; 647 float scaleX = 1.0; 648 float scaleY = 1.0; 649 bool ret = postProc.ScalePixelMap(scaleX, scaleY, *pixelMap); 650 ASSERT_EQ(ret, true); 651 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0030 end"; 652 } 653 654 /** 655 * @tc.name: PostProcTest0031 656 * @tc.desc: test ScalePixelMap 657 * @tc.type: FUNC 658 */ 659 HWTEST_F(PostProcTest, PostProcTest0031, TestSize.Level3) 660 { 661 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0031 start"; 662 uint32_t errorCode = 0; 663 SourceOptions opts; 664 std::unique_ptr<ImageSource> imageSource = ImageSource::CreateImageSource(IMAGE_INPUT_JPEG_PATH, opts, errorCode); 665 ASSERT_EQ(errorCode, SUCCESS); 666 ASSERT_NE(imageSource.get(), nullptr); 667 668 uint32_t index = 0; 669 DecodeOptions optsPixel; 670 errorCode = 0; 671 std::unique_ptr<PixelMap> pixelMap = imageSource->CreatePixelMap(index, optsPixel, errorCode); 672 ASSERT_EQ(errorCode, SUCCESS); 673 ASSERT_NE(pixelMap.get(), nullptr); 674 675 PostProc postProc; 676 float scaleX = 0.1; 677 float scaleY = 0.1; 678 bool ret = postProc.ScalePixelMap(scaleX, scaleY, *pixelMap); 679 ASSERT_EQ(ret, true); 680 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0031 end"; 681 } 682 683 /** 684 * @tc.name: PostProcTest0032 685 * @tc.desc: test TranslatePixelMap 686 * @tc.type: FUNC 687 */ 688 HWTEST_F(PostProcTest, PostProcTest0032, TestSize.Level3) 689 { 690 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0032start"; 691 uint32_t errorCode = 0; 692 SourceOptions opts; 693 std::unique_ptr<ImageSource> imageSource = ImageSource::CreateImageSource(IMAGE_INPUT_JPEG_PATH, opts, errorCode); 694 ASSERT_EQ(errorCode, SUCCESS); 695 ASSERT_NE(imageSource.get(), nullptr); 696 697 uint32_t index = 0; 698 DecodeOptions optsPixel; 699 errorCode = 0; 700 std::unique_ptr<PixelMap> pixelMap = imageSource->CreatePixelMap(index, optsPixel, errorCode); 701 ASSERT_EQ(errorCode, SUCCESS); 702 ASSERT_NE(pixelMap.get(), nullptr); 703 704 PostProc postProc; 705 float tX = 3.0; 706 float tY = 1.0; 707 bool ret = postProc.TranslatePixelMap(tX, tY, *pixelMap); 708 ASSERT_EQ(ret, true); 709 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0032 end"; 710 } 711 712 /** 713 * @tc.name: PostProcTest0033 714 * @tc.desc: test DecodePostProc 715 * @tc.type: FUNC 716 */ 717 HWTEST_F(PostProcTest, PostProcTest0033, TestSize.Level3) 718 { 719 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0033 start"; 720 DecodeOptions decodeOpts; 721 PixelMap pixelMap; 722 PostProc postProc; 723 FinalOutputStep finalOutputStep = FinalOutputStep::NO_CHANGE; 724 uint32_t errorCode = postProc.DecodePostProc(decodeOpts, pixelMap, finalOutputStep); 725 ASSERT_NE(errorCode, SUCCESS); 726 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0033 end"; 727 } 728 729 /** 730 * @tc.name: PostProcTest0034 731 * @tc.desc: test DecodePostProc MemoryUsagePreference is LOW_RAM 732 * @tc.type: FUNC 733 */ 734 HWTEST_F(PostProcTest, PostProcTest0034, TestSize.Level3) 735 { 736 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0034 start"; 737 std::unique_ptr<std::fstream> fs = std::make_unique<std::fstream>(); 738 fs->open("/data/local/tmp/image/test.jpg", std::fstream::binary | std::fstream::in); 739 bool isOpen = fs->is_open(); 740 ASSERT_EQ(isOpen, true); 741 uint32_t errorCode = 0; 742 SourceOptions opts; 743 std::unique_ptr<ImageSource> imageSource = ImageSource::CreateImageSource(std::move(fs), opts, errorCode); 744 ASSERT_EQ(errorCode, SUCCESS); 745 ASSERT_NE(imageSource.get(), nullptr); 746 747 DecodeOptions decodeOpts; 748 decodeOpts.CropRect.top = 3; 749 decodeOpts.CropRect.width = 100; 750 decodeOpts.CropRect.left = 3; 751 decodeOpts.CropRect.height = 200; 752 decodeOpts.desiredSize.width = 200; 753 decodeOpts.desiredSize.height = 400; 754 decodeOpts.preference = MemoryUsagePreference::LOW_RAM; 755 std::unique_ptr<PixelMap> pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); 756 ASSERT_EQ(errorCode, SUCCESS); 757 ASSERT_NE(pixelMap.get(), nullptr); 758 759 ImageInfo imageInfo; 760 imageInfo.baseDensity = 1; 761 imageInfo.alphaType = AlphaType::IMAGE_ALPHA_TYPE_OPAQUE; 762 pixelMap->SetImageInfo(imageInfo); 763 764 PostProc postProc; 765 FinalOutputStep finalOutputStep = FinalOutputStep::DENSITY_CHANGE; 766 errorCode = postProc.DecodePostProc(decodeOpts, *(pixelMap.get()), finalOutputStep); 767 ASSERT_EQ(errorCode, SUCCESS); 768 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0034 end"; 769 } 770 771 /** 772 * @tc.name: PostProcTest0035 773 * @tc.desc: test DecodePostProc MemoryUsagePreference is DEFAULT 774 * @tc.type: FUNC 775 */ 776 HWTEST_F(PostProcTest, PostProcTest0035, TestSize.Level3) 777 { 778 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0035 start"; 779 std::unique_ptr<std::fstream> fs = std::make_unique<std::fstream>(); 780 fs->open("/data/local/tmp/image/test.jpg", std::fstream::binary | std::fstream::in); 781 bool isOpen = fs->is_open(); 782 ASSERT_EQ(isOpen, true); 783 uint32_t errorCode = 0; 784 SourceOptions opts; 785 std::unique_ptr<ImageSource> imageSource = ImageSource::CreateImageSource(std::move(fs), opts, errorCode); 786 ASSERT_EQ(errorCode, SUCCESS); 787 ASSERT_NE(imageSource.get(), nullptr); 788 789 DecodeOptions decodeOpts; 790 decodeOpts.CropRect.top = 3; 791 decodeOpts.CropRect.width = 100; 792 decodeOpts.CropRect.left = 3; 793 decodeOpts.CropRect.height = 200; 794 decodeOpts.desiredSize.width = 200; 795 decodeOpts.desiredSize.height = 400; 796 std::unique_ptr<PixelMap> pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); 797 ASSERT_EQ(errorCode, SUCCESS); 798 ASSERT_NE(pixelMap.get(), nullptr); 799 800 ImageInfo imageInfo; 801 imageInfo.baseDensity = 1; 802 imageInfo.alphaType = AlphaType::IMAGE_ALPHA_TYPE_OPAQUE; 803 pixelMap->SetImageInfo(imageInfo); 804 805 PostProc postProc; 806 FinalOutputStep finalOutputStep = FinalOutputStep::DENSITY_CHANGE; 807 errorCode = postProc.DecodePostProc(decodeOpts, *(pixelMap.get()), finalOutputStep); 808 ASSERT_EQ(errorCode, SUCCESS); 809 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0035 end"; 810 } 811 812 /** 813 * @tc.name: PostProcTest0036 814 * @tc.desc: test DecodePostProc AlphaType is IMAGE_ALPHA_TYPE_UNPREMUL 815 * @tc.type: FUNC 816 */ 817 HWTEST_F(PostProcTest, PostProcTest0036, TestSize.Level3) 818 { 819 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0036 start"; 820 std::unique_ptr<std::fstream> fs = std::make_unique<std::fstream>(); 821 fs->open("/data/local/tmp/image/test.jpg", std::fstream::binary | std::fstream::in); 822 bool isOpen = fs->is_open(); 823 ASSERT_EQ(isOpen, true); 824 uint32_t errorCode = 0; 825 SourceOptions opts; 826 std::unique_ptr<ImageSource> imageSource = ImageSource::CreateImageSource(std::move(fs), opts, errorCode); 827 ASSERT_EQ(errorCode, SUCCESS); 828 ASSERT_NE(imageSource.get(), nullptr); 829 830 DecodeOptions decodeOpts; 831 decodeOpts.CropRect.top = 3; 832 decodeOpts.CropRect.width = 100; 833 decodeOpts.CropRect.left = 3; 834 decodeOpts.CropRect.height = 200; 835 decodeOpts.desiredSize.width = 200; 836 decodeOpts.desiredSize.height = 400; 837 std::unique_ptr<PixelMap> pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); 838 ASSERT_EQ(errorCode, SUCCESS); 839 ASSERT_NE(pixelMap.get(), nullptr); 840 841 ImageInfo imageInfo; 842 imageInfo.baseDensity = 1; 843 imageInfo.alphaType = AlphaType::IMAGE_ALPHA_TYPE_UNPREMUL; 844 pixelMap->SetImageInfo(imageInfo); 845 846 PostProc postProc; 847 FinalOutputStep finalOutputStep = FinalOutputStep::DENSITY_CHANGE; 848 errorCode = postProc.DecodePostProc(decodeOpts, *(pixelMap.get()), finalOutputStep); 849 ASSERT_EQ(errorCode, SUCCESS); 850 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0036 end"; 851 } 852 853 /** 854 * @tc.name: PostProcTest0037 855 * @tc.desc: test CenterScale 856 * @tc.type: FUNC 857 */ 858 HWTEST_F(PostProcTest, PostProcTest0037, TestSize.Level3) 859 { 860 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0037 start"; 861 std::unique_ptr<std::fstream> fs = std::make_unique<std::fstream>(); 862 fs->open("/data/local/tmp/image/test.jpg", std::fstream::binary | std::fstream::in); 863 bool isOpen = fs->is_open(); 864 ASSERT_EQ(isOpen, true); 865 uint32_t errorCode = 0; 866 SourceOptions opts; 867 std::unique_ptr<ImageSource> imageSource = ImageSource::CreateImageSource(std::move(fs), opts, errorCode); 868 ASSERT_EQ(errorCode, SUCCESS); 869 ASSERT_NE(imageSource.get(), nullptr); 870 871 DecodeOptions decodeOpts; 872 decodeOpts.CropRect.top = 3; 873 decodeOpts.CropRect.width = 100; 874 decodeOpts.CropRect.left = 3; 875 decodeOpts.CropRect.height = 200; 876 decodeOpts.desiredSize.width = 200; 877 decodeOpts.desiredSize.height = 400; 878 std::unique_ptr<PixelMap> pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode); 879 ASSERT_EQ(errorCode, SUCCESS); 880 ASSERT_NE(pixelMap.get(), nullptr); 881 pixelMap->imageInfo_.size.width = 1; 882 pixelMap->imageInfo_.size.height = 1; 883 pixelMap->isAstc_ = true; 884 885 PostProc postProc; 886 Size size; 887 size.width = 2; 888 size.height = 2; 889 bool ret = postProc.CenterScale(size, *(pixelMap.get())); 890 ASSERT_EQ(ret, true); 891 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0037 end"; 892 } 893 894 /** 895 * @tc.name: PostProcTest0038 896 * @tc.desc: test CheckScanlineFilter 897 * @tc.type: FUNC 898 */ 899 HWTEST_F(PostProcTest, PostProcTest0038, TestSize.Level3) 900 { 901 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0038 start"; 902 Rect cropRect; 903 ImageInfo dstImageInfo; 904 PixelMap pixelMap; 905 int32_t pixelBytes = 0; 906 ScanlineFilter scanlineFilter; 907 PostProc postProc; 908 postProc.decodeOpts_.allocatorType = AllocatorType::SHARE_MEM_ALLOC; 909 uint32_t ret = postProc.CheckScanlineFilter(cropRect, dstImageInfo, pixelMap, pixelBytes, scanlineFilter); 910 ASSERT_EQ(ret, ERR_IMAGE_CROP); 911 postProc.decodeOpts_.allocatorType = AllocatorType::DEFAULT; 912 dstImageInfo.size.width = 0; 913 ret = postProc.CheckScanlineFilter(cropRect, dstImageInfo, pixelMap, pixelBytes, scanlineFilter); 914 ASSERT_EQ(ret, ERR_IMAGE_CROP); 915 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0038 end"; 916 } 917 918 /** 919 * @tc.name: PostProcTest0039 920 * @tc.desc: test PixelConvertProc 921 * @tc.type: FUNC 922 */ 923 HWTEST_F(PostProcTest, PostProcTest0039, TestSize.Level3) 924 { 925 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0039 start"; 926 ImageInfo dstImageInfo; 927 PixelMap pixelMap; 928 ImageInfo srcImageInfo; 929 PostProc postProc; 930 dstImageInfo.pixelFormat = PixelFormat::UNKNOWN; 931 uint32_t ret = postProc.PixelConvertProc(dstImageInfo, pixelMap, srcImageInfo); 932 ASSERT_EQ(ret, ERR_IMAGE_CROP); 933 dstImageInfo.pixelFormat = PixelFormat::ARGB_8888; 934 dstImageInfo.size.width = 1; 935 dstImageInfo.size.height = 1; 936 srcImageInfo.pixelFormat = PixelFormat::UNKNOWN; 937 postProc.decodeOpts_.allocatorType = AllocatorType::HEAP_ALLOC; 938 ret = postProc.PixelConvertProc(dstImageInfo, pixelMap, srcImageInfo); 939 ASSERT_EQ(ret, ERR_IMAGE_CROP); 940 GTEST_LOG_(INFO) << "PostProcTest: PostProcTest0039 end"; 941 } 942 943 /** 944 * @tc.name: CenterDisplayTest001 945 * @tc.desc: test CenterDisplay 946 * @tc.type: FUNC 947 */ 948 HWTEST_F(PostProcTest, CenterDisplayTest001, TestSize.Level3) 949 { 950 GTEST_LOG_(INFO) << "PostProcTest: CenterDisplayTest001 start"; 951 PostProc postProc; 952 PixelMap pixelMap; 953 int32_t srcWidth = 0; 954 int32_t srcHeight = 0; 955 int32_t targetWidth = 0; 956 int32_t targetHeight = 0; 957 bool ret = postProc.CenterDisplay(pixelMap, srcWidth, srcHeight, targetWidth, targetHeight); 958 ASSERT_EQ(ret, false); 959 targetWidth = 1; 960 targetHeight = 1; 961 pixelMap.imageInfo_.pixelFormat = PixelFormat::ALPHA_8; 962 pixelMap.allocatorType_ = AllocatorType::HEAP_ALLOC; 963 ret = postProc.CenterDisplay(pixelMap, srcWidth, srcHeight, targetWidth, targetHeight); 964 ASSERT_EQ(ret, true); 965 pixelMap.allocatorType_ = AllocatorType::DMA_ALLOC; 966 ret = postProc.CenterDisplay(pixelMap, srcWidth, srcHeight, targetWidth, targetHeight); 967 ASSERT_EQ(ret, true); 968 pixelMap.allocatorType_ = AllocatorType::DEFAULT; 969 ret = postProc.CenterDisplay(pixelMap, srcWidth, srcHeight, targetWidth, targetHeight); 970 ASSERT_EQ(ret, true); 971 GTEST_LOG_(INFO) << "PostProcTest: CenterDisplayTest001 end"; 972 } 973 974 /** 975 * @tc.name: TransformTest001 976 * @tc.desc: test Transform 977 * @tc.type: FUNC 978 */ 979 HWTEST_F(PostProcTest, TransformTest001, TestSize.Level3) 980 { 981 GTEST_LOG_(INFO) << "PostProcTest: TransformTest001 start"; 982 PostProc postProc; 983 BasicTransformer trans; 984 PixmapInfo input; 985 PixelMap pixelMap; 986 pixelMap.isTransformered_ = true; 987 bool ret = postProc.Transform(trans, input, pixelMap); 988 ASSERT_EQ(ret, false); 989 pixelMap.isTransformered_ = false; 990 postProc.decodeOpts_.allocatorType = AllocatorType::SHARE_MEM_ALLOC; 991 ret = postProc.Transform(trans, input, pixelMap); 992 ASSERT_EQ(ret, false); 993 postProc.decodeOpts_.allocatorType = AllocatorType::HEAP_ALLOC; 994 ret = postProc.Transform(trans, input, pixelMap); 995 ASSERT_EQ(ret, false); 996 GTEST_LOG_(INFO) << "PostProcTest: TransformTest001 end"; 997 } 998 999 /** 1000 * @tc.name: ScalePixelMapExTest001 1001 * @tc.desc: test ScalePixelMapEx 1002 * @tc.type: FUNC 1003 */ 1004 HWTEST_F(PostProcTest, ScalePixelMapExTest001, TestSize.Level3) 1005 { 1006 GTEST_LOG_(INFO) << "PostProcTest: ScalePixelMapExTest001 start"; 1007 PostProc postProc; 1008 Size desiredSize; 1009 PixelMap pixelMap; 1010 AntiAliasingOption option = AntiAliasingOption::NONE; 1011 pixelMap.imageInfo_.size.width = 0; 1012 pixelMap.imageInfo_.size.height = 0; 1013 bool ret = postProc.ScalePixelMapEx(desiredSize, pixelMap, option); 1014 ASSERT_EQ(ret, false); 1015 pixelMap.imageInfo_.size.width = 1; 1016 pixelMap.imageInfo_.size.height = 1; 1017 pixelMap.data_ = new uint8_t; 1018 ret = postProc.ScalePixelMapEx(desiredSize, pixelMap, option); 1019 ASSERT_EQ(ret, false); 1020 pixelMap.imageInfo_.pixelFormat = PixelFormat::ALPHA_8; 1021 pixelMap.allocatorType_ = AllocatorType::CUSTOM_ALLOC; 1022 ret = postProc.ScalePixelMapEx(desiredSize, pixelMap, option); 1023 ASSERT_EQ(ret, false); 1024 pixelMap.allocatorType_ = AllocatorType::SHARE_MEM_ALLOC; 1025 AbsMemory absMemory; 1026 absMemory.data.data = new uint8_t; 1027 ret = postProc.ScalePixelMapEx(desiredSize, pixelMap, option); 1028 ASSERT_EQ(ret, false); 1029 delete pixelMap.data_; 1030 GTEST_LOG_(INFO) << "PostProcTest: ScalePixelMapExTest001 end"; 1031 } 1032 } 1033 }