Parallelize PlatformAbstraction image loading tests
[platform/core/uifw/dali-adaptor.git] / automated-tests / src / dali-platform-abstraction / utc-image-loading-common.h
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 #ifndef __DALI_TEST_SUITE_IMAGE_LOADING_COMMON_H__
19 #define __DALI_TEST_SUITE_IMAGE_LOADING_COMMON_H__
20 #include <unistd.h>
21 #include <iostream>
22 #include <stdlib.h>
23 #include <dali/dali.h>
24 #include <dali-test-suite-utils.h>
25 #include "slp-platform-abstraction.h"
26 #include "resource-collector.h"
27
28 using namespace Dali;
29 using namespace Dali::Integration;
30 using namespace Dali::Internal::Platform;
31
32 namespace
33 {
34 /**
35  * The number of loads issued in test cases is a multiple of this. The higher it
36  * is, the more the tests stress the system but the longer they take to run.
37  * A value of 1000 is enough to make load tests take tens of seconds each
38  * on desktop. */
39 const unsigned NUM_LOAD_GROUPS_TO_ISSUE = 158;
40
41 /**
42  * The number of loads to issue when they will be cancelled.
43  * Cancelled loads are cheap so we do a lot.
44  */
45 const unsigned NUM_CANCELLED_LOAD_GROUPS_TO_ISSUE = NUM_LOAD_GROUPS_TO_ISSUE * 10;
46
47 /** The number of times to ask for resource load status. */
48 const unsigned MAX_NUM_RESOURCE_TRIES = 10;
49
50 /** The maximum time to wait for loads to complete when the number of expected loads is known. */
51 const unsigned MAX_MILLIS_TO_WAIT_FOR_KNOWN_LOADS = 1000 * 60;
52
53 /** Images that should load without issue. */
54 const char* const VALID_IMAGES[] = {
55   TEST_IMAGE_DIR "/frac.jpg",
56   TEST_IMAGE_DIR "/frac.24.bmp",
57   TEST_IMAGE_DIR "/frac.png",
58   TEST_IMAGE_DIR "/interlaced.gif",
59   TEST_IMAGE_DIR "/pattern.gif"
60 };
61 const unsigned NUM_VALID_IMAGES = sizeof(VALID_IMAGES) / sizeof(VALID_IMAGES[0]);
62
63 ///@ToDo: Add valid ktx, ico, and wbmp image examples.
64
65 /** Returns elapsed milliseconds. */
66 double GetTimeMilliseconds( Integration::PlatformAbstraction& abstraction )
67 {
68   unsigned int seconds;
69   unsigned int microseconds;
70   abstraction.GetTimeMicroseconds( seconds, microseconds );
71   double milliseconds = seconds * 1000.0 + microseconds / 1000.0;
72   return milliseconds;
73 }
74
75 } // anon namespace
76
77 /** Live platform abstraction recreated for each test case. */
78 extern Integration::PlatformAbstraction * gAbstraction;
79
80 /** A variety of ImageAttributes to reach different code paths that have embedded code paths. */
81 extern std::vector<ImageAttributes> gCancelAttributes;
82
83
84 void utc_dali_loading_startup(void);
85 void utc_dali_loading_cleanup(void);
86
87 #endif // __DALI_TEST_SUITE_IMAGE_LOADING_COMMON_H__