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.SetScalingMode( ImageAttributes::ScaleToFill );
35 scaleToFillAttributes.SetSize( 160, 120 );
36 gCancelAttributes.push_back( scaleToFillAttributes );
38 // Hit the derived dimensions code:
39 ImageAttributes scaleToFillAttributesDeriveWidth = scaleToFillAttributes;
40 scaleToFillAttributesDeriveWidth.SetSize( 0, 120 );
41 gCancelAttributes.push_back( scaleToFillAttributesDeriveWidth );
43 ImageAttributes scaleToFillAttributesDeriveHeight = scaleToFillAttributes;
44 scaleToFillAttributesDeriveHeight.SetSize( 160, 0 );
45 gCancelAttributes.push_back( scaleToFillAttributesDeriveHeight );
47 // Try to push a tall crop:
48 ImageAttributes scaleToFillAttributesTall = scaleToFillAttributes;
49 scaleToFillAttributesTall.SetSize( 160, 480 );
50 ImageAttributes scaleToFillAttributesTall2 = scaleToFillAttributes;
51 scaleToFillAttributesTall2.SetSize( 160, 509 );
52 ImageAttributes scaleToFillAttributesTall3 = scaleToFillAttributes;
53 scaleToFillAttributesTall3.SetSize( 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.SetSize( 320, 60 );
61 ImageAttributes scaleToFillAttributesWide2 = scaleToFillAttributes;
62 scaleToFillAttributesWide2.SetSize( 317, 60 );
63 ImageAttributes scaleToFillAttributesWide3 = scaleToFillAttributes;
64 scaleToFillAttributesWide3.SetSize( 317, 53 );
65 gCancelAttributes.push_back( scaleToFillAttributesWide );
66 gCancelAttributes.push_back( scaleToFillAttributesWide2 );
67 gCancelAttributes.push_back( scaleToFillAttributesWide3 );
69 ImageAttributes shrinkToFitAttributes = scaleToFillAttributes;
70 shrinkToFitAttributes.SetScalingMode( ImageAttributes::ShrinkToFit );
71 gCancelAttributes.push_back( shrinkToFitAttributes );
73 ImageAttributes fitWidthAttributes = scaleToFillAttributes;
74 fitWidthAttributes.SetScalingMode( ImageAttributes::FitWidth );
75 gCancelAttributes.push_back( fitWidthAttributes );
77 ImageAttributes fitHeightAttributes = scaleToFillAttributes;
78 fitHeightAttributes.SetScalingMode( ImageAttributes::FitHeight );
79 gCancelAttributes.push_back( fitHeightAttributes );
81 ///@ToDo: Add attribute variants for all scale modes.
83 // Pad the array to a prime number to mitigate any accidental periodic
84 // patterns in which image file has which attributes applied to its load:
86 const float lastUniques = gCancelAttributes.size() - 0.001f;
87 while( gCancelAttributes.size() < 61u )
89 gCancelAttributes.push_back( gCancelAttributes[unsigned(drand48() * lastUniques)] );
93 void utc_dali_loading_cleanup(void)
98 test_return_value = TET_PASS;