Merge branch 'devel/master' into sandbox/dkdk/tizen
[platform/core/uifw/dali-adaptor.git] / automated-tests / src / dali-adaptor-internal / utc-Dali-IcoLoader.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 <dali-test-suite-utils.h>
19 #include <stdlib.h>
20 #include <iostream>
21
22 #include <dali/internal/imaging/common/loader-ico.h>
23 #include "image-loaders.h"
24
25 using namespace Dali;
26
27 namespace
28 {
29 static const LoadFunctions IcoLoaders(TizenPlatform::LoadIcoHeader, TizenPlatform::LoadBitmapFromIco);
30
31 // Golden master image data for each icon type:
32 // Note: The bottom right corner of each image is fully transparent.
33 // Note: The first 4 sets of data *happen* to be the same, but could be different depending on the image converted.
34 //       In this case as the original image contains few colors, they can easily fit inside an 8bit palette, thus
35 //       Causing no image degradation.
36
37 uint32_t ImageCheckData_Ico4x4_32bpp_8alpha[] = {
38   0xff0000ff, 0x00ff00ff, 0x0000ffff, 0xff00ffff, 0xc04040ff, 0x40c040ff, 0x4040c0ff, 0xffff00ff, 0xa06060ff, 0x60a060ff, 0x6060a0ff, 0x00ffffff, 0xffffffff, 0x808080ff, 0x000000ff, 0x00000000};
39
40 uint32_t ImageCheckData_Ico4x4_24bpp[] = {
41   0xff0000ff, 0x00ff00ff, 0x0000ffff, 0xff00ffff, 0xc04040ff, 0x40c040ff, 0x4040c0ff, 0xffff00ff, 0xa06060ff, 0x60a060ff, 0x6060a0ff, 0x00ffffff, 0xffffffff, 0x808080ff, 0x000000ff, 0x00000000};
42
43 uint32_t ImageCheckData_Ico4x4_8bpp[] = {
44   0xff0000ff, 0x00ff00ff, 0x0000ffff, 0xff00ffff, 0xc04040ff, 0x40c040ff, 0x4040c0ff, 0xffff00ff, 0xa06060ff, 0x60a060ff, 0x6060a0ff, 0x00ffffff, 0xffffffff, 0x808080ff, 0x000000ff, 0x00000000};
45
46 uint32_t ImageCheckData_Ico4x4_4bpp[] = {
47   0xff0000ff, 0x00ff00ff, 0x0000ffff, 0xff00ffff, 0xc04040ff, 0x40c040ff, 0x4040c0ff, 0xffff00ff, 0xa06060ff, 0x60a060ff, 0x6060a0ff, 0x00ffffff, 0xffffffff, 0x808080ff, 0x000000ff, 0x00000000};
48
49 uint32_t ImageCheckData_Ico4x4_1bpp[] = {
50   0xA18783ff, 0xA18783ff, 0xA18783ff, 0xA18783ff, 0xA18783ff, 0xA18783ff, 0xA18783ff, 0xA18783ff, 0xA18783ff, 0xA18783ff, 0xA18783ff, 0xA18783ff, 0xA18783ff, 0xA18783ff, 0xA18783ff, 0xA1878300};
51
52 } // Unnamed namespace.
53
54 int UtcDaliIco32bpp8alpha(void)
55 {
56   ImageDetails image(TEST_IMAGE_DIR "/test-image-4x4-32bpp.ico", 4u, 4u);
57
58   CompareLoadedImageData(image, IcoLoaders, ImageCheckData_Ico4x4_32bpp_8alpha);
59
60   END_TEST;
61 }
62
63 int UtcDaliIco24bpp1alpha(void)
64 {
65   ImageDetails image(TEST_IMAGE_DIR "/test-image-4x4-24bpp.ico", 4u, 4u);
66
67   CompareLoadedImageData(image, IcoLoaders, ImageCheckData_Ico4x4_24bpp);
68
69   END_TEST;
70 }
71
72 int UtcDaliIco8bpp1alpha(void)
73 {
74   ImageDetails image(TEST_IMAGE_DIR "/test-image-4x4-8bpp.ico", 4u, 4u);
75
76   CompareLoadedImageData(image, IcoLoaders, ImageCheckData_Ico4x4_8bpp);
77
78   END_TEST;
79 }
80
81 int UtcDaliIco4bpp1alpha(void)
82 {
83   ImageDetails image(TEST_IMAGE_DIR "/test-image-4x4-4bpp.ico", 4u, 4u);
84
85   CompareLoadedImageData(image, IcoLoaders, ImageCheckData_Ico4x4_4bpp);
86
87   END_TEST;
88 }
89
90 int UtcDaliIco1bpp1alpha(void)
91 {
92   ImageDetails image(TEST_IMAGE_DIR "/test-image-4x4-1bpp.ico", 4u, 4u);
93
94   CompareLoadedImageData(image, IcoLoaders, ImageCheckData_Ico4x4_1bpp);
95
96   END_TEST;
97 }