75c2957029adf8e6c4a8c585c6803e703b0a95ee
[platform/core/uifw/dali-adaptor.git] / automated-tests / src / dali-adaptor / utc-Dali-ImageLoading.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 <dali/dali.h>
20 #include <dali-test-suite-utils.h>
21 #include <dali/devel-api/adaptor-framework/image-loading.h>
22
23 using namespace Dali;
24
25 namespace
26 {
27 // resolution: 34*34, pixel format: RGBA8888
28 static const char* gImage_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png";
29 // resolution: 128*128, pixel format: RGB888
30 static const char* gImage_128_RGB = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
31
32 // this is image is not exist, for negative test
33 static const char* gImageNonExist = "non-exist.jpg";
34 }
35
36 void utc_dali_load_image_startup(void)
37 {
38   test_return_value = TET_UNDEF;
39 }
40
41 void utc_dali_load_image_cleanup(void)
42 {
43   test_return_value = TET_PASS;
44 }
45
46 int UtcDaliLoadImageP(void)
47 {
48   PixelData pixelData = Dali::LoadImageFromFile( gImage_34_RGBA );
49   DALI_TEST_CHECK( pixelData );
50   DALI_TEST_EQUALS( pixelData.GetWidth(), 34u, TEST_LOCATION );
51   DALI_TEST_EQUALS( pixelData.GetHeight(), 34u, TEST_LOCATION );
52   DALI_TEST_EQUALS( pixelData.GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION  );
53
54   PixelData pixelData2 = Dali::LoadImageFromFile( gImage_128_RGB );
55   DALI_TEST_CHECK( pixelData2 );
56   DALI_TEST_EQUALS( pixelData2.GetWidth(), 128u, TEST_LOCATION  );
57   DALI_TEST_EQUALS( pixelData2.GetHeight(), 128u, TEST_LOCATION  );
58   DALI_TEST_EQUALS( pixelData2.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION  );
59
60   END_TEST;
61 }
62
63 int UtcDaliLoadImageN(void)
64 {
65   PixelData pixelData = Dali::LoadImageFromFile( gImageNonExist );
66   DALI_TEST_CHECK( !pixelData );
67
68   END_TEST;
69 }