Removed traces of ImageAttributes and dead old JPEG loader
[platform/core/uifw/dali-adaptor.git] / automated-tests / src / dali-platform-abstraction / utc-image-loading-common.cpp
1 /*
2  * Copyright (c) 2014 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 "utc-image-loading-common.h"
19
20 /** Live platform abstraction recreated for each test case. */
21 Integration::PlatformAbstraction * gAbstraction = 0;
22
23 /** A variety of parameters to reach different code paths in image loading code. */
24 std::vector<ImageParameters> gCancelAttributes;
25
26 void utc_dali_loading_startup(void)
27 {
28   test_return_value = TET_UNDEF;
29   gAbstraction = CreatePlatformAbstraction();
30
31   // Setup some loading parameters to engage post-processing stages:
32
33   ImageParameters scaleToFillAttributes;
34   scaleToFillAttributes.second.first = FittingMode::SCALE_TO_FILL;
35   scaleToFillAttributes.first = ImageDimensions( 160, 120 );
36   gCancelAttributes.push_back( scaleToFillAttributes );
37
38   // Hit the derived dimensions code:
39   ImageParameters scaleToFillAttributesDeriveWidth = scaleToFillAttributes;
40   scaleToFillAttributesDeriveWidth.first = ImageDimensions( 0, 120 );
41   gCancelAttributes.push_back( scaleToFillAttributesDeriveWidth );
42
43   ImageParameters scaleToFillAttributesDeriveHeight = scaleToFillAttributes;
44   scaleToFillAttributesDeriveHeight.first = ImageDimensions( 160, 0 );
45   gCancelAttributes.push_back( scaleToFillAttributesDeriveHeight );
46
47   // Try to push a tall crop:
48   ImageParameters scaleToFillAttributesTall = scaleToFillAttributes;
49   scaleToFillAttributesTall.first = ImageDimensions( 160, 480 );
50   ImageParameters scaleToFillAttributesTall2 = scaleToFillAttributes;
51   scaleToFillAttributesTall2.first = ImageDimensions( 160, 509 );
52   ImageParameters scaleToFillAttributesTall3 = scaleToFillAttributes;
53   scaleToFillAttributesTall3.first = ImageDimensions( 37, 251 );
54   gCancelAttributes.push_back( scaleToFillAttributesTall );
55   gCancelAttributes.push_back( scaleToFillAttributesTall2 );
56   gCancelAttributes.push_back( scaleToFillAttributesTall3 );
57
58   // Try to push a wide crop:
59   ImageParameters scaleToFillAttributesWide = scaleToFillAttributes;
60   scaleToFillAttributesWide.first = ImageDimensions( 320, 60 );
61   ImageParameters scaleToFillAttributesWide2 = scaleToFillAttributes;
62   scaleToFillAttributesWide2.first = ImageDimensions( 317, 60 );
63   ImageParameters scaleToFillAttributesWide3 = scaleToFillAttributes;
64   scaleToFillAttributesWide3.first = ImageDimensions( 317, 53 );
65   gCancelAttributes.push_back( scaleToFillAttributesWide );
66   gCancelAttributes.push_back( scaleToFillAttributesWide2 );
67   gCancelAttributes.push_back( scaleToFillAttributesWide3 );
68
69   ImageParameters shrinkToFitAttributes = scaleToFillAttributes;
70   shrinkToFitAttributes.second.first = FittingMode::SHRINK_TO_FIT;
71   gCancelAttributes.push_back( shrinkToFitAttributes );
72
73   ImageParameters fitWidthAttributes = scaleToFillAttributes;
74   fitWidthAttributes.second.first = FittingMode::FIT_WIDTH;
75   gCancelAttributes.push_back( fitWidthAttributes );
76
77   ImageParameters fitHeightAttributes = scaleToFillAttributes;
78   fitHeightAttributes.second.first = FittingMode::FIT_HEIGHT;
79   gCancelAttributes.push_back( fitHeightAttributes );
80
81   ///@ToDo: Add attribute variants for all scale modes.
82   ///@ToDo: Add attribute variants for all filter modes.
83
84   // Pad the array to a prime number to mitigate any accidental periodic
85   // patterns in which image file has which attributes applied to its load:
86   srand48( 104729 );
87   const float lastUniques = gCancelAttributes.size() - 0.001f;
88   while( gCancelAttributes.size() < 61u )
89   {
90     gCancelAttributes.push_back( gCancelAttributes[unsigned(drand48() * lastUniques)] );
91   }
92 }
93
94 void utc_dali_loading_cleanup(void)
95 {
96   delete gAbstraction;
97   gAbstraction = 0;
98
99   test_return_value = TET_PASS;
100 }