Formatting automated-tests
[platform/core/uifw/dali-adaptor.git] / automated-tests / src / dali-platform-abstraction / utc-image-loading-common.h
1 /*
2  * Copyright (c) 2019 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 #ifndef DALI_TEST_SUITE_IMAGE_LOADING_COMMON_H
19 #define DALI_TEST_SUITE_IMAGE_LOADING_COMMON_H
20 #include <dali-test-suite-utils.h>
21 #include <dali/dali.h>
22 #include <dali/internal/legacy/common/tizen-platform-abstraction.h>
23 #include <stdlib.h>
24 #include <unistd.h>
25 #include <ctime>
26 #include <iostream>
27
28 using namespace Dali;
29 using namespace Dali::Integration;
30
31 namespace
32 {
33 /**
34  * The number of loads issued in test cases is a multiple of this. The higher it
35  * is, the more the tests stress the system but the longer they take to run.
36  * A value of 1000 is enough to make load tests take tens of seconds each
37  * on desktop. */
38 const unsigned NUM_LOAD_GROUPS_TO_ISSUE = 158;
39
40 /**
41  * The number of loads to issue when they will be cancelled.
42  * Cancelled loads are cheap so we do a lot.
43  */
44 const unsigned NUM_CANCELLED_LOAD_GROUPS_TO_ISSUE = NUM_LOAD_GROUPS_TO_ISSUE * 10;
45
46 /** The number of times to ask for resource load status. */
47 const unsigned MAX_NUM_RESOURCE_TRIES = 10;
48
49 /** The maximum time to wait for loads to complete when the number of expected loads is known. */
50 const unsigned MAX_MILLIS_TO_WAIT_FOR_KNOWN_LOADS = 1000 * 60;
51
52 /** Images that should load without issue. */
53 const char* const VALID_IMAGES[] = {
54   TEST_IMAGE_DIR "/frac.jpg",
55   TEST_IMAGE_DIR "/frac.24.bmp",
56   TEST_IMAGE_DIR "/frac.png",
57   TEST_IMAGE_DIR "/interlaced.gif",
58   TEST_IMAGE_DIR "/pattern.gif",
59   TEST_IMAGE_DIR "/fractal-compressed-ETC1_RGB8_OES-45x80.ktx",
60   TEST_IMAGE_DIR "/fractal-compressed-RGBA_ASTC_4x4_KHR-32x64.astc",
61   TEST_IMAGE_DIR "/test-image-4x4-32bpp.ico",
62   TEST_IMAGE_DIR "/test-image.wbmp"};
63 const unsigned NUM_VALID_IMAGES = sizeof(VALID_IMAGES) / sizeof(VALID_IMAGES[0]);
64
65 } // namespace
66
67 /** Live platform abstraction recreated for each test case. */
68 extern TizenPlatform::TizenPlatformAbstraction* gAbstraction;
69
70 /** A variety of parameters to reach different code paths in the image loading. */
71 typedef std::pair<ImageDimensions, std::pair<FittingMode::Type, std::pair<SamplingMode::Type, bool> > > ImageParameters;
72 extern std::vector<ImageParameters>                                                                     gCancelAttributes;
73
74 double GetTimeMilliseconds(Integration::PlatformAbstraction& abstraction); ///< Returns elapsed milliseconds.
75
76 void utc_dali_loading_startup(void);
77 void utc_dali_loading_cleanup(void);
78
79 #endif // DALI_TEST_SUITE_IMAGE_LOADING_COMMON_H