2 * Copyright (c) 2017 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.
19 #include <dali/dali.h>
20 #include <dali-test-suite-utils.h>
21 #include <dali/devel-api/adaptor-framework/image-loading.h>
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";
32 // this is image is not exist, for negative test
33 static const char* gImageNonExist = "non-exist.jpg";
36 void utc_dali_load_image_startup(void)
38 test_return_value = TET_UNDEF;
41 void utc_dali_load_image_cleanup(void)
43 test_return_value = TET_PASS;
46 int UtcDaliLoadImageP(void)
48 Devel::PixelBuffer pixelBuffer = Dali::LoadImageFromFile( gImage_34_RGBA );
49 DALI_TEST_CHECK( pixelBuffer );
50 DALI_TEST_EQUALS( pixelBuffer.GetWidth(), 34u, TEST_LOCATION );
51 DALI_TEST_EQUALS( pixelBuffer.GetHeight(), 34u, TEST_LOCATION );
52 DALI_TEST_EQUALS( pixelBuffer.GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION );
54 Devel::PixelBuffer pixelBuffer2 = Dali::LoadImageFromFile( gImage_128_RGB );
55 DALI_TEST_CHECK( pixelBuffer2 );
56 DALI_TEST_EQUALS( pixelBuffer2.GetWidth(), 128u, TEST_LOCATION );
57 DALI_TEST_EQUALS( pixelBuffer2.GetHeight(), 128u, TEST_LOCATION );
58 DALI_TEST_EQUALS( pixelBuffer2.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION );
63 int UtcDaliLoadImageN(void)
65 Devel::PixelBuffer pixelBuffer = Dali::LoadImageFromFile( gImageNonExist );
66 DALI_TEST_CHECK( !pixelBuffer );
72 int UtcDaliDownloadImageP(void)
74 std::string url("file://");
75 url.append( gImage_34_RGBA );
77 std::string url2("file://");
78 url2.append( gImage_128_RGB );
80 Devel::PixelBuffer pixelBuffer = Dali::DownloadImageSynchronously( url );
81 DALI_TEST_CHECK( pixelBuffer );
82 DALI_TEST_EQUALS( pixelBuffer.GetWidth(), 34u, TEST_LOCATION );
83 DALI_TEST_EQUALS( pixelBuffer.GetHeight(), 34u, TEST_LOCATION );
84 DALI_TEST_EQUALS( pixelBuffer.GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION );
86 Devel::PixelBuffer pixelBuffer2 = Dali::DownloadImageSynchronously( url2 );
87 DALI_TEST_CHECK( pixelBuffer2 );
88 DALI_TEST_EQUALS( pixelBuffer2.GetWidth(), 128u, TEST_LOCATION );
89 DALI_TEST_EQUALS( pixelBuffer2.GetHeight(), 128u, TEST_LOCATION );
90 DALI_TEST_EQUALS( pixelBuffer2.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION );
95 int UtcDaliDownloadImageN(void)
97 Devel::PixelBuffer pixelBuffer = Dali::DownloadImageSynchronously( gImageNonExist );
98 DALI_TEST_CHECK( !pixelBuffer );