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.
18 #include "utc-image-loading-common.h"
20 double GetTimeMilliseconds( Integration::PlatformAbstraction& abstraction )
23 clock_gettime( CLOCK_MONOTONIC, &timeSpec );
24 return ( timeSpec.tv_sec * 1e3 ) + ( timeSpec.tv_nsec / 1e6 );
27 /** Live platform abstraction recreated for each test case. */
28 TizenPlatform::TizenPlatformAbstraction* gAbstraction = 0;
30 /** A variety of parameters to reach different code paths in image loading code. */
31 std::vector<ImageParameters> gCancelAttributes;
33 void utc_dali_loading_startup(void)
35 test_return_value = TET_UNDEF;
36 gAbstraction = TizenPlatform::CreatePlatformAbstraction();
38 // Setup some loading parameters to engage post-processing stages:
40 ImageParameters scaleToFillAttributes;
41 scaleToFillAttributes.second.first = FittingMode::SCALE_TO_FILL;
42 scaleToFillAttributes.first = ImageDimensions( 160, 120 );
43 gCancelAttributes.push_back( scaleToFillAttributes );
45 // Hit the derived dimensions code:
46 ImageParameters scaleToFillAttributesDeriveWidth = scaleToFillAttributes;
47 scaleToFillAttributesDeriveWidth.first = ImageDimensions( 0, 120 );
48 gCancelAttributes.push_back( scaleToFillAttributesDeriveWidth );
50 ImageParameters scaleToFillAttributesDeriveHeight = scaleToFillAttributes;
51 scaleToFillAttributesDeriveHeight.first = ImageDimensions( 160, 0 );
52 gCancelAttributes.push_back( scaleToFillAttributesDeriveHeight );
54 // Try to push a tall crop:
55 ImageParameters scaleToFillAttributesTall = scaleToFillAttributes;
56 scaleToFillAttributesTall.first = ImageDimensions( 160, 480 );
57 ImageParameters scaleToFillAttributesTall2 = scaleToFillAttributes;
58 scaleToFillAttributesTall2.first = ImageDimensions( 160, 509 );
59 ImageParameters scaleToFillAttributesTall3 = scaleToFillAttributes;
60 scaleToFillAttributesTall3.first = ImageDimensions( 37, 251 );
61 gCancelAttributes.push_back( scaleToFillAttributesTall );
62 gCancelAttributes.push_back( scaleToFillAttributesTall2 );
63 gCancelAttributes.push_back( scaleToFillAttributesTall3 );
65 // Try to push a wide crop:
66 ImageParameters scaleToFillAttributesWide = scaleToFillAttributes;
67 scaleToFillAttributesWide.first = ImageDimensions( 320, 60 );
68 ImageParameters scaleToFillAttributesWide2 = scaleToFillAttributes;
69 scaleToFillAttributesWide2.first = ImageDimensions( 317, 60 );
70 ImageParameters scaleToFillAttributesWide3 = scaleToFillAttributes;
71 scaleToFillAttributesWide3.first = ImageDimensions( 317, 53 );
72 gCancelAttributes.push_back( scaleToFillAttributesWide );
73 gCancelAttributes.push_back( scaleToFillAttributesWide2 );
74 gCancelAttributes.push_back( scaleToFillAttributesWide3 );
76 ImageParameters shrinkToFitAttributes = scaleToFillAttributes;
77 shrinkToFitAttributes.second.first = FittingMode::SHRINK_TO_FIT;
78 gCancelAttributes.push_back( shrinkToFitAttributes );
80 ImageParameters fitWidthAttributes = scaleToFillAttributes;
81 fitWidthAttributes.second.first = FittingMode::FIT_WIDTH;
82 gCancelAttributes.push_back( fitWidthAttributes );
84 ImageParameters fitHeightAttributes = scaleToFillAttributes;
85 fitHeightAttributes.second.first = FittingMode::FIT_HEIGHT;
86 gCancelAttributes.push_back( fitHeightAttributes );
88 ///@ToDo: Add attribute variants for all scale modes.
89 ///@ToDo: Add attribute variants for all filter modes.
91 // Pad the array to a prime number to mitigate any accidental periodic
92 // patterns in which image file has which attributes applied to its load:
94 const float lastUniques = gCancelAttributes.size() - 0.001f;
95 while( gCancelAttributes.size() < 61u )
97 gCancelAttributes.push_back( gCancelAttributes[unsigned(drand48() * lastUniques)] );
101 void utc_dali_loading_cleanup(void)
106 test_return_value = TET_PASS;