License conversion from Flora to Apache 2.0
[platform/core/uifw/dali-adaptor.git] / automated-tests / TET / dali-external-lib-stubs / test-appcore.h
1 //#ifndef __TEST_APPCORE_H__
2 //#define __TEST_APPCORE_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 /**
22  * Dali-env provides a stub for appcore used by dali-core on desktop.
23  * This file is used for over-riding appcore functions with test functions
24  * which allow us to do things like simulate orientation change
25  */
26
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32
33 typedef struct {
34     size_t event_data_size;
35     void *event_data;
36 } sensor_event_data_t;
37
38
39 void *registered_data = NULL;
40
41 typedef enum {
42   UNKNOWN_SENSOR  = 0x0000,
43   ACCELEROMETER_SENSOR    = 0x0001,
44   GEOMAGNETIC_SENSOR  = 0x0002,
45   LIGHT_SENSOR  = 0x0004,
46   PROXIMITY_SENSOR  = 0x0008,
47   THERMOMETER_SENSOR  = 0x0010,
48   GYROSCOPE_SENSOR  = 0x0020,
49   PRESSURE_SENSOR = 0x0040,
50   MOTION_SENSOR = 0x0080,
51 } sensor_type_t;
52
53 enum accelerometer_evet_type {
54   ACCELEROMETER_EVENT_ROTATION_CHECK    = (ACCELEROMETER_SENSOR<<16) |0x0001,
55   ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME = (ACCELEROMETER_SENSOR<<16) |0x0002,
56   ACCELEROMETER_EVENT_CALIBRATION_NEEDED    = (ACCELEROMETER_SENSOR<<16) |0x0004,
57 };
58
59
60 enum accelerometer_rotate_state {
61   ROTATION_UNKNOWN    = 0,
62   ROTATION_LANDSCAPE_LEFT   = 1,
63   ROTATION_PORTRAIT_TOP   = 2,
64   ROTATION_PORTRAIT_BTM   = 3,
65   ROTATION_LANDSCAPE_RIGHT  = 4,
66   ROTATION_EVENT_0    = 2,  /*CCW base*/
67   ROTATION_EVENT_90   = 1,  /*CCW base*/
68   ROTATION_EVENT_180    = 3,  /*CCW base*/
69   ROTATION_EVENT_270    = 4,  /*CCW base*/
70 };
71
72  /**
73  * Rotaion modes
74  * @see appcore_set_rotation_cb(), appcore_get_rotation_state()
75  */
76 enum appcore_rm {
77   APPCORE_RM_UNKNOWN,
78         /**< Unknown mode */
79   APPCORE_RM_PORTRAIT_NORMAL,
80            /**< Portrait mode */
81   APPCORE_RM_PORTRAIT_REVERSE,
82             /**< Portrait upside down mode */
83   APPCORE_RM_LANDSCAPE_NORMAL,
84             /**< Left handed landscape mode */
85   APPCORE_RM_LANDSCAPE_REVERSE,
86         /**< Right handed landscape mode */
87   APPCORE_RM_INVALID = 0x99 // undefined
88 };
89
90 int (*rotate_function) (enum appcore_rm, void *) = NULL;
91 bool CallbackInstalled = false;
92
93 int appcore_set_rotation_cb(int (*cb) (enum appcore_rm, void *), void *data)
94 {
95   rotate_function = cb;
96   registered_data = data;
97
98   tet_printf("installed rotation call back\n");
99   CallbackInstalled = true;
100
101   return 0;
102 }
103 int appcore_unset_rotation_cb(void)
104 {
105   rotate_function = NULL;
106   registered_data = NULL;
107
108   tet_printf("removed rotation call back\n");
109
110   CallbackInstalled = false;
111
112   return 0;
113 }
114
115 // new function to simulate a change in orientation
116 void appcore_force_orientation(appcore_rm rm)
117 {
118   if (CallbackInstalled)
119   {
120     rotate_function(rm,registered_data);
121   }
122 }
123
124
125 #ifdef __cplusplus
126 }
127 #endif
128
129
130
131 //#endif // __TEST_APPCORE_H__