2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <dali-test-suite-utils.h>
19 #include <dali/dali.h>
20 #include <dali/devel-api/adaptor-framework/animated-image-loading.h>
27 // test gif image, resolution: 100*100, 5 frames, delay: 1 second, disposal method: none
28 static const char* gGif_100_None = TEST_RESOURCE_DIR "/canvas-none.gif";
30 // this image if not exist, for negative test
31 static const char* gGifNonExist = "non-exist.gif";
33 // this image exists but it is not a gif file.
34 static const char* gGifInvalid = TEST_RESOURCE_DIR "/invalid.gif";
38 void utc_dali_animated_image_loader_startup(void)
40 test_return_value = TET_UNDEF;
43 void utc_dali_animated_image_loader_cleanup(void)
45 test_return_value = TET_PASS;
48 int UtcDaliAnimatedImageLoadingGetImageSizeP(void)
50 Dali::AnimatedImageLoading animatedImageLoading = Dali::AnimatedImageLoading::New(gGif_100_None, true);
51 ImageDimensions imageSize = animatedImageLoading.GetImageSize();
53 // Check that the image size is [100, 100]
54 DALI_TEST_EQUALS(imageSize.GetWidth(), 100u, TEST_LOCATION);
55 DALI_TEST_EQUALS(imageSize.GetHeight(), 100u, TEST_LOCATION);
60 int UtcDaliAnimatedImageLoadingGetImageSizeN(void)
62 Dali::AnimatedImageLoading animatedImageLoading = Dali::AnimatedImageLoading::New(gGifNonExist, true);
63 ImageDimensions imageSize = animatedImageLoading.GetImageSize();
65 // Check that it returns zero size when the animated image is not valid
66 DALI_TEST_EQUALS(imageSize.GetWidth(), 0u, TEST_LOCATION);
67 DALI_TEST_EQUALS(imageSize.GetHeight(), 0u, TEST_LOCATION);
72 int UtcDaliAnimatedImageLoadingInvalidGif(void)
74 Dali::AnimatedImageLoading animatedImageLoading = Dali::AnimatedImageLoading::New(gGifInvalid, true);
75 Dali::Devel::PixelBuffer pixelBuffer = animatedImageLoading.LoadFrame(0);
77 // The pixel buffer should be empty.
78 DALI_TEST_CHECK(!pixelBuffer);