2 * Copyright (c) 2014 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.
18 #include "utc-image-loading-common.h"
20 /** Live platform abstraction recreated for each test case. */
21 Integration::PlatformAbstraction * gAbstraction = 0;
23 /** A variety of ImageAttributes to reach different code paths that have embedded code paths. */
24 std::vector<ImageAttributes> gCancelAttributes;
26 void utc_dali_loading_startup(void)
28 test_return_value = TET_UNDEF;
29 gAbstraction = CreatePlatformAbstraction();
31 // Setup some ImageAttributes to engage post-processing stages:
33 ImageAttributes scaleToFillAttributes;
34 scaleToFillAttributes.second.first = FittingMode::SCALE_TO_FILL;
35 scaleToFillAttributes.first = ImageDimensions( 160, 120 );
36 gCancelAttributes.push_back( scaleToFillAttributes );
38 // Hit the derived dimensions code:
39 ImageAttributes scaleToFillAttributesDeriveWidth = scaleToFillAttributes;
40 scaleToFillAttributesDeriveWidth.first = ImageDimensions( 0, 120 );
41 gCancelAttributes.push_back( scaleToFillAttributesDeriveWidth );
43 ImageAttributes scaleToFillAttributesDeriveHeight = scaleToFillAttributes;
44 scaleToFillAttributesDeriveHeight.first = ImageDimensions( 160, 0 );
45 gCancelAttributes.push_back( scaleToFillAttributesDeriveHeight );
47 // Try to push a tall crop:
48 ImageAttributes scaleToFillAttributesTall = scaleToFillAttributes;
49 scaleToFillAttributesTall.first = ImageDimensions( 160, 480 );
50 ImageAttributes scaleToFillAttributesTall2 = scaleToFillAttributes;
51 scaleToFillAttributesTall2.first = ImageDimensions( 160, 509 );
52 ImageAttributes scaleToFillAttributesTall3 = scaleToFillAttributes;
53 scaleToFillAttributesTall3.first = ImageDimensions( 37, 251 );
54 gCancelAttributes.push_back( scaleToFillAttributesTall );
55 gCancelAttributes.push_back( scaleToFillAttributesTall2 );
56 gCancelAttributes.push_back( scaleToFillAttributesTall3 );
58 // Try to push a wide crop:
59 ImageAttributes scaleToFillAttributesWide = scaleToFillAttributes;
60 scaleToFillAttributesWide.first = ImageDimensions( 320, 60 );
61 ImageAttributes scaleToFillAttributesWide2 = scaleToFillAttributes;
62 scaleToFillAttributesWide2.first = ImageDimensions( 317, 60 );
63 ImageAttributes scaleToFillAttributesWide3 = scaleToFillAttributes;
64 scaleToFillAttributesWide3.first = ImageDimensions( 317, 53 );
65 gCancelAttributes.push_back( scaleToFillAttributesWide );
66 gCancelAttributes.push_back( scaleToFillAttributesWide2 );
67 gCancelAttributes.push_back( scaleToFillAttributesWide3 );
69 ImageAttributes shrinkToFitAttributes = scaleToFillAttributes;
70 shrinkToFitAttributes.second.first = FittingMode::SHRINK_TO_FIT;
71 gCancelAttributes.push_back( shrinkToFitAttributes );
73 ImageAttributes fitWidthAttributes = scaleToFillAttributes;
74 fitWidthAttributes.second.first = FittingMode::FIT_WIDTH;
75 gCancelAttributes.push_back( fitWidthAttributes );
77 ImageAttributes fitHeightAttributes = scaleToFillAttributes;
78 fitHeightAttributes.second.first = FittingMode::FIT_HEIGHT;
79 gCancelAttributes.push_back( fitHeightAttributes );
81 ///@ToDo: Add attribute variants for all scale modes.
82 ///@ToDo: Add attribute variants for all filter modes.
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:
87 const float lastUniques = gCancelAttributes.size() - 0.001f;
88 while( gCancelAttributes.size() < 61u )
90 gCancelAttributes.push_back( gCancelAttributes[unsigned(drand48() * lastUniques)] );
94 void utc_dali_loading_cleanup(void)
99 test_return_value = TET_PASS;