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 UtcDaliAnimatedImageLoadingCopyMoveP(void)
50 Dali::AnimatedImageLoading animatedImageLoading = Dali::AnimatedImageLoading::New(gGif_100_None, true);
52 Dali::AnimatedImageLoading copied = animatedImageLoading;
54 DALI_TEST_EQUALS((bool)animatedImageLoading, true, TEST_LOCATION);
55 DALI_TEST_EQUALS((bool)copied, true, TEST_LOCATION);
57 Dali::AnimatedImageLoading moved = std::move(animatedImageLoading);
59 DALI_TEST_EQUALS((bool)animatedImageLoading, false, TEST_LOCATION);
60 DALI_TEST_EQUALS((bool)copied, true, TEST_LOCATION);
61 DALI_TEST_EQUALS((bool)moved, true, TEST_LOCATION);
63 Dali::AnimatedImageLoading copiedAssign;
64 copiedAssign = copied;
66 Dali::AnimatedImageLoading movedAssign;
67 movedAssign = std::move(moved);
69 DALI_TEST_EQUALS((bool)animatedImageLoading, false, TEST_LOCATION);
70 DALI_TEST_EQUALS((bool)copied, true, TEST_LOCATION);
71 DALI_TEST_EQUALS((bool)moved, false, TEST_LOCATION);
72 DALI_TEST_EQUALS((bool)copiedAssign, true, TEST_LOCATION);
73 DALI_TEST_EQUALS((bool)movedAssign, true, TEST_LOCATION);
78 int UtcDaliAnimatedImageLoadingGetImageSizeP(void)
80 Dali::AnimatedImageLoading animatedImageLoading = Dali::AnimatedImageLoading::New(gGif_100_None, true);
81 ImageDimensions imageSize = animatedImageLoading.GetImageSize();
83 // Check that the image size is [100, 100]
84 DALI_TEST_EQUALS(imageSize.GetWidth(), 100u, TEST_LOCATION);
85 DALI_TEST_EQUALS(imageSize.GetHeight(), 100u, TEST_LOCATION);
90 int UtcDaliAnimatedImageLoadingGetImageSizeN(void)
92 Dali::AnimatedImageLoading animatedImageLoading = Dali::AnimatedImageLoading::New(gGifNonExist, true);
93 ImageDimensions imageSize = animatedImageLoading.GetImageSize();
95 // Check that it returns zero size when the animated image is not valid
96 DALI_TEST_EQUALS(imageSize.GetWidth(), 0u, TEST_LOCATION);
97 DALI_TEST_EQUALS(imageSize.GetHeight(), 0u, TEST_LOCATION);
102 int UtcDaliAnimatedImageLoadingInvalidGif(void)
104 Dali::AnimatedImageLoading animatedImageLoading = Dali::AnimatedImageLoading::New(gGifInvalid, true);
105 Dali::Devel::PixelBuffer pixelBuffer = animatedImageLoading.LoadFrame(0);
107 // The pixel buffer should be empty.
108 DALI_TEST_CHECK(!pixelBuffer);