X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-adaptor%2Futc-Dali-GifLoading.cpp;h=669b7294fea895373780a0bda6ca8106861f83f2;hb=afe08dc50446f00bb0f78439960be465bcb2e7aa;hp=5bd36983899656913a8ce1dee55699cb16eb94e4;hpb=d6f438b79eb80a549c967abdfa7d9d09acb760d6;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/automated-tests/src/dali-adaptor/utc-Dali-GifLoading.cpp b/automated-tests/src/dali-adaptor/utc-Dali-GifLoading.cpp index 5bd3698..669b729 100644 --- a/automated-tests/src/dali-adaptor/utc-Dali-GifLoading.cpp +++ b/automated-tests/src/dali-adaptor/utc-Dali-GifLoading.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,10 +15,10 @@ * */ -#include -#include #include -#include +#include +#include +#include using namespace Dali; @@ -34,100 +34,117 @@ static const char* gGif_100_Bgnd = TEST_RESOURCE_DIR "/canvas-bgnd.gif"; // this image if not exist, for negative test static const char* gGifNonExist = "non-exist.gif"; -void VerifyLoad( std::vector& pixelDataList, Dali::Vector& frameDelayList, - uint32_t frameCount, uint32_t width, uint32_t height, uint32_t delay ) +void VerifyLoad(std::vector& pixelDataList, Dali::Vector& frameDelayList, uint32_t frameCount, uint32_t width, uint32_t height, uint32_t delay) { - DALI_TEST_EQUALS( pixelDataList.size(), frameCount, TEST_LOCATION ); - DALI_TEST_EQUALS( frameDelayList.Size(), frameCount, TEST_LOCATION ); + DALI_TEST_EQUALS(pixelDataList.size(), frameCount, TEST_LOCATION); + DALI_TEST_EQUALS(frameDelayList.Size(), frameCount, TEST_LOCATION); - for( uint32_t idx = 0; idx pixelDataList; - Dali::Vector frameDelayList; + Dali::Vector frameDelayList; - std::unique_ptr gifLoading = GifLoading::New( gGif_100_None ); - bool succeed = gifLoading->LoadAllFrames( pixelDataList, frameDelayList ); + Dali::AnimatedImageLoading animatedImageLoading = Dali::AnimatedImageLoading::New(gGif_100_None, true); + bool succeed = animatedImageLoading.LoadNextNFrames(0u, animatedImageLoading.GetImageCount(), pixelDataList); + frameDelayList.Clear(); + frameDelayList.Resize(animatedImageLoading.GetImageCount(), 0); + for(uint32_t i = 0; i < animatedImageLoading.GetImageCount(); ++i) + { + frameDelayList[i] = animatedImageLoading.GetFrameInterval(i); + } // Check that the loading succeed - DALI_TEST_CHECK( succeed ); - VerifyLoad( pixelDataList, frameDelayList, 5u, 100u, 100u, 1000u ); + DALI_TEST_CHECK(succeed); + VerifyLoad(pixelDataList, frameDelayList, 5u, 100u, 100u, 1000u); pixelDataList.clear(); - gifLoading = GifLoading::New( gGif_100_Prev ); - succeed = gifLoading->LoadAllFrames( pixelDataList, frameDelayList ); + animatedImageLoading = Dali::AnimatedImageLoading::New(gGif_100_Prev, true); + succeed = animatedImageLoading.LoadNextNFrames(0u, animatedImageLoading.GetImageCount(), pixelDataList); + frameDelayList.Clear(); + frameDelayList.Resize(animatedImageLoading.GetImageCount(), 0); + for(uint32_t i = 0; i < animatedImageLoading.GetImageCount(); ++i) + { + frameDelayList[i] = animatedImageLoading.GetFrameInterval(i); + } + // Check that the loading succeed - DALI_TEST_CHECK( succeed ); - VerifyLoad( pixelDataList, frameDelayList, 5u, 100u, 100u, 1000u ); + DALI_TEST_CHECK(succeed); + VerifyLoad(pixelDataList, frameDelayList, 5u, 100u, 100u, 1000u); pixelDataList.clear(); - gifLoading = GifLoading::New( gGif_100_Bgnd ); - succeed = gifLoading->LoadAllFrames( pixelDataList, frameDelayList ); + animatedImageLoading = Dali::AnimatedImageLoading::New(gGif_100_Bgnd, true); + succeed = animatedImageLoading.LoadNextNFrames(0u, animatedImageLoading.GetImageCount(), pixelDataList); + frameDelayList.Clear(); + frameDelayList.Resize(animatedImageLoading.GetImageCount(), 0); + for(uint32_t i = 0; i < animatedImageLoading.GetImageCount(); ++i) + { + frameDelayList[i] = animatedImageLoading.GetFrameInterval(i); + } // Check that the loading succeed - DALI_TEST_CHECK( succeed ); - VerifyLoad( pixelDataList, frameDelayList, 5u, 100u, 100u, 1000u ); + DALI_TEST_CHECK(succeed); + VerifyLoad(pixelDataList, frameDelayList, 5u, 100u, 100u, 1000u); END_TEST; } -int UtcDaliGifLoadingN(void) +int UtcDaliAnimatedImageLoadingN(void) { std::vector pixelDataList; - Dali::Vector frameDelayList; + Dali::Vector frameDelayList; - std::unique_ptr gifLoading = GifLoading::New( gGifNonExist ); - bool succeed = gifLoading->LoadAllFrames( pixelDataList, frameDelayList ); + Dali::AnimatedImageLoading animatedImageLoading = Dali::AnimatedImageLoading::New(gGifNonExist, true); + bool succeed = animatedImageLoading.LoadNextNFrames(0u, animatedImageLoading.GetImageCount(), pixelDataList); // Check that the loading failed - DALI_TEST_CHECK( !succeed ); + DALI_TEST_CHECK(!succeed); // Check that both pixelDataList and frameDelayList are empty - DALI_TEST_EQUALS( pixelDataList.size(), 0u, TEST_LOCATION ); - DALI_TEST_EQUALS( frameDelayList.Size(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS(pixelDataList.size(), 0u, TEST_LOCATION); END_TEST; } -int UtcDaliGifLoadingGetImageSizeP(void) +int UtcDaliAnimatedImageLoadingGetImageSizeP(void) { - std::unique_ptr gifLoading = GifLoading::New( gGif_100_None ); - ImageDimensions imageSize = gifLoading->GetImageSize(); + Dali::AnimatedImageLoading animatedImageLoading = Dali::AnimatedImageLoading::New(gGif_100_None, true); + ImageDimensions imageSize = animatedImageLoading.GetImageSize(); // Check that the image size is [100, 100] - DALI_TEST_EQUALS( imageSize.GetWidth(), 100u, TEST_LOCATION ); - DALI_TEST_EQUALS( imageSize.GetHeight(), 100u, TEST_LOCATION ); + DALI_TEST_EQUALS(imageSize.GetWidth(), 100u, TEST_LOCATION); + DALI_TEST_EQUALS(imageSize.GetHeight(), 100u, TEST_LOCATION); END_TEST; } -int UtcDaliGifLoadingGetImageSizeN(void) +int UtcDaliAnimatedImageLoadingGetImageSizeN(void) { - std::unique_ptr gifLoading = GifLoading::New( gGifNonExist ); - ImageDimensions imageSize = gifLoading->GetImageSize(); + Dali::AnimatedImageLoading animatedImageLoading = Dali::AnimatedImageLoading::New(gGifNonExist, true); + ImageDimensions imageSize = animatedImageLoading.GetImageSize(); - // Check that it returns zero size when the gif is not valid - DALI_TEST_EQUALS( imageSize.GetWidth(), 0u, TEST_LOCATION ); - DALI_TEST_EQUALS( imageSize.GetHeight(), 0u, TEST_LOCATION ); + // Check that it returns zero size when the animated image is not valid + DALI_TEST_EQUALS(imageSize.GetWidth(), 0u, TEST_LOCATION); + DALI_TEST_EQUALS(imageSize.GetHeight(), 0u, TEST_LOCATION); END_TEST; }