Add animated vector image visual
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-SyncImageLoader.cpp
1 /*
2  * Copyright (c) 2016 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 <stdlib.h>
19 #include <unistd.h>
20 #include <dali/dali.h>
21 #include <dali-toolkit-test-suite-utils.h>
22 #include <dali-toolkit/dali-toolkit.h>
23
24 using namespace Dali;
25 using namespace Dali::Toolkit;
26
27 namespace
28 {
29
30 // Resolution: 50*50, pixel format: RGBA8888
31 static const char* gImage_50_RGBA = TEST_RESOURCE_DIR "/icon-delete.png";
32
33 // Resolution: 128*128, pixel format: RGB888
34 static const char* gImage_128_RGB = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
35
36
37 void VerifyLoad( PixelData pixelData, uint32_t width, uint32_t height )
38 {
39   DALI_TEST_CHECK( pixelData );
40   DALI_TEST_EQUALS<unsigned int>( pixelData.GetWidth(), width, TEST_LOCATION );
41   DALI_TEST_EQUALS<unsigned int>( pixelData.GetHeight(), height, TEST_LOCATION );
42 }
43
44 } // anonymous namespace
45
46
47 int UtcDaliSyncImageLoaderLoad(void)
48 {
49   PixelData pixelData = Toolkit::SyncImageLoader::Load( gImage_50_RGBA );
50
51   DALI_TEST_EQUALS<bool>( pixelData, true, TEST_LOCATION );
52
53   END_TEST;
54 }
55
56 int UtcDaliSyncImageLoaderLoadWithDimensions(void)
57 {
58   PixelData pixelData = Toolkit::SyncImageLoader::Load( gImage_50_RGBA, ImageDimensions( 25, 25 ) );
59
60   VerifyLoad( pixelData, 25u, 25u );
61
62   END_TEST;
63 }
64
65 int UtcDaliSyncImageLoaderLoadWithAllOptions(void)
66 {
67   PixelData pixelData = Toolkit::SyncImageLoader::Load( gImage_128_RGB, ImageDimensions( 100, 100 ), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, true );
68
69   VerifyLoad( pixelData, 100u, 100u );
70
71   END_TEST;
72 }
73
74