b71cedda55ecdaa67a4c7e747d9ca9b369084791
[platform/core/uifw/dali-adaptor.git] / automated-tests / src / dali-adaptor / utc-Dali-GifLoading.cpp
1 /*
2  * Copyright (c) 2020 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 } // namespace
34
35 void utc_dali_animated_image_loader_startup(void)
36 {
37   test_return_value = TET_UNDEF;
38 }
39
40 void utc_dali_animated_image_loader_cleanup(void)
41 {
42   test_return_value = TET_PASS;
43 }
44
45 int UtcDaliAnimatedImageLoadingGetImageSizeP(void)
46 {
47   Dali::AnimatedImageLoading animatedImageLoading = Dali::AnimatedImageLoading::New(gGif_100_None, true);
48   ImageDimensions            imageSize            = animatedImageLoading.GetImageSize();
49
50   // Check that the image size is [100, 100]
51   DALI_TEST_EQUALS(imageSize.GetWidth(), 100u, TEST_LOCATION);
52   DALI_TEST_EQUALS(imageSize.GetHeight(), 100u, TEST_LOCATION);
53
54   END_TEST;
55 }
56
57 int UtcDaliAnimatedImageLoadingGetImageSizeN(void)
58 {
59   Dali::AnimatedImageLoading animatedImageLoading = Dali::AnimatedImageLoading::New(gGifNonExist, true);
60   ImageDimensions            imageSize            = animatedImageLoading.GetImageSize();
61
62   // Check that it returns zero size when the animated image is not valid
63   DALI_TEST_EQUALS(imageSize.GetWidth(), 0u, TEST_LOCATION);
64   DALI_TEST_EQUALS(imageSize.GetHeight(), 0u, TEST_LOCATION);
65
66   END_TEST;
67 }