Merge "Introduce WindowData" into devel/master
[platform/core/uifw/dali-adaptor.git] / automated-tests / src / dali-adaptor / utc-Dali-GifLoading.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <dali-test-suite-utils.h>
19 #include <dali/dali.h>
20 #include <dali/devel-api/adaptor-framework/animated-image-loading.h>
21 #include <stdlib.h>
22
23 using namespace Dali;
24
25 namespace
26 {
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";
29
30 // this image if not exist, for negative test
31 static const char* gGifNonExist = "non-exist.gif";
32
33 // this image exists but it is not a gif file.
34 static const char* gGifInvalid = TEST_RESOURCE_DIR "/invalid.gif";
35
36 } // namespace
37
38 void utc_dali_animated_image_loader_startup(void)
39 {
40   test_return_value = TET_UNDEF;
41 }
42
43 void utc_dali_animated_image_loader_cleanup(void)
44 {
45   test_return_value = TET_PASS;
46 }
47
48 int UtcDaliAnimatedImageLoadingCopyMoveP(void)
49 {
50   Dali::AnimatedImageLoading animatedImageLoading = Dali::AnimatedImageLoading::New(gGif_100_None, true);
51
52   Dali::AnimatedImageLoading copied = animatedImageLoading;
53
54   DALI_TEST_EQUALS((bool)animatedImageLoading, true, TEST_LOCATION);
55   DALI_TEST_EQUALS((bool)copied, true, TEST_LOCATION);
56
57   Dali::AnimatedImageLoading moved = std::move(animatedImageLoading);
58
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);
62
63   Dali::AnimatedImageLoading copiedAssign;
64   copiedAssign = copied;
65
66   Dali::AnimatedImageLoading movedAssign;
67   movedAssign = std::move(moved);
68
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);
74
75   END_TEST;
76 }
77
78 int UtcDaliAnimatedImageLoadingGetImageSizeP(void)
79 {
80   Dali::AnimatedImageLoading animatedImageLoading = Dali::AnimatedImageLoading::New(gGif_100_None, true);
81   ImageDimensions            imageSize            = animatedImageLoading.GetImageSize();
82
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);
86
87   END_TEST;
88 }
89
90 int UtcDaliAnimatedImageLoadingGetImageSizeN(void)
91 {
92   Dali::AnimatedImageLoading animatedImageLoading = Dali::AnimatedImageLoading::New(gGifNonExist, true);
93   ImageDimensions            imageSize            = animatedImageLoading.GetImageSize();
94
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);
98
99   END_TEST;
100 }
101
102 int UtcDaliAnimatedImageLoadingInvalidGif(void)
103 {
104   Dali::AnimatedImageLoading animatedImageLoading = Dali::AnimatedImageLoading::New(gGifInvalid, true);
105   Dali::Devel::PixelBuffer   pixelBuffer          = animatedImageLoading.LoadFrame(0);
106
107   // The pixel buffer should be empty.
108   DALI_TEST_CHECK(!pixelBuffer);
109
110   END_TEST;
111 }