ut: remove gtest codes
[platform/core/uifw/libtdm.git] / ut / stubs / stub_tdm_display.h
1 #ifndef STUB_TDM_DISPLAY_H
2 #define STUB_TDM_DISPLAY_H
3
4 #include "tdm.h"
5
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9
10 static int stub_tdm_output_cb_commit_called;
11 static int stub_tdm_output_cb_vblank_called;
12 static int stub_tdm_output_cb_status_called;
13 static int stub_tdm_output_cb_dpms_called;
14 static int stub_tdm_output_get_mode_error;
15 static tdm_output_mode stub_tdm_mode;
16 static tdm_output_change_handler stub_tdm_output_change_handler;
17 static tdm_output_dpms stub_tdm_dpms_returned_value;
18 static int stub_tdm_output_wait_vblank_error;
19
20 static void
21 stub_tdm_display_init()
22 {
23         stub_tdm_output_cb_commit_called = 0;
24         stub_tdm_output_cb_vblank_called = 0;
25         stub_tdm_output_cb_dpms_called = 0;
26         stub_tdm_output_get_mode_error = 0;
27         stub_tdm_output_change_handler = NULL;
28         stub_tdm_dpms_returned_value = TDM_OUTPUT_DPMS_ON;
29         stub_tdm_mode.vrefresh = 24;
30         stub_tdm_output_wait_vblank_error = 0;
31 }
32
33 static void
34 stub_tdm_output_cb_commit(tdm_output *output_backend, unsigned int sequence,
35                                          unsigned int tv_sec, unsigned int tv_usec, void *user_data)
36 {
37         (void)output_backend;
38         (void)sequence;
39         (void)tv_sec;
40         (void)tv_usec;
41         (void)user_data;
42
43         stub_tdm_output_cb_commit_called = 1;
44 }
45
46 static void
47 stub_tdm_output_cb_vblank(tdm_output *output_backend, unsigned int sequence,
48                                          unsigned int tv_sec, unsigned int tv_usec, void *user_data)
49 {
50         (void)output_backend;
51         (void)sequence;
52         (void)tv_sec;
53         (void)tv_usec;
54         (void)user_data;
55
56         stub_tdm_output_cb_vblank_called = 1;
57 }
58
59 static void
60 stub_tdm_output_cb_status(tdm_output *output_backend, tdm_output_conn_status status,
61                                          void *user_data)
62 {
63         (void)output_backend;
64         (void)status;
65         (void)user_data;
66
67         stub_tdm_output_cb_status_called = 1;
68 }
69
70 static void
71 stub_tdm_output_cb_dpms(tdm_output *output_backend, tdm_output_dpms dpms, void *user_data)
72 {
73         (void)output_backend;
74         (void)dpms;
75         (void)user_data;
76
77         stub_tdm_output_cb_dpms_called = 1;
78 }
79
80 static tdm_error
81 stub_tdm_output_get_mode(tdm_output *output, const tdm_output_mode **mode)
82 {
83         if (stub_tdm_output_get_mode_error) {
84                 *mode = NULL;
85                 return TDM_ERROR_OPERATION_FAILED;
86         }
87
88         *mode = &stub_tdm_mode;
89
90         return TDM_ERROR_NONE;
91 }
92
93 static tdm_error
94 stub_tdm_output_get_dpms(tdm_output *output, tdm_output_dpms *dpms_value)
95 {
96         (void)output;
97
98         *dpms_value = stub_tdm_dpms_returned_value;
99         return TDM_ERROR_NONE;
100 }
101
102 static tdm_error
103 stub_tdm_output_add_change_handler(tdm_output *output,
104                                                           tdm_output_change_handler func,
105                                                           void *user_data)
106 {
107         (void)output;
108         (void)user_data;
109
110         stub_tdm_output_change_handler = func;
111
112         return TDM_ERROR_NONE;
113 }
114
115 static void
116 stub_tdm_output_remove_change_handler(tdm_output *output,
117                                                                  tdm_output_change_handler func,
118                                                                  void *user_data)
119 {
120         (void)output;
121         (void)user_data;
122
123         stub_tdm_output_change_handler = func;
124 }
125
126 static tdm_error
127 stub_tdm_output_wait_vblank(tdm_output *output, int interval, int sync,
128                                            tdm_output_vblank_handler func, void *user_data)
129 {
130         if (stub_tdm_output_wait_vblank_error)
131                 return TDM_ERROR_DPMS_OFF;
132
133         return TDM_ERROR_NONE;
134 }
135
136 #ifdef __cplusplus
137 }
138 #endif
139
140 #define tdm_output_cb_commit stub_tdm_output_cb_commit
141 #define tdm_output_cb_vblank stub_tdm_output_cb_vblank
142 #define tdm_output_cb_status stub_tdm_output_cb_status
143 #define tdm_output_cb_dpms stub_tdm_output_cb_dpms
144 #define tdm_output_get_mode stub_tdm_output_get_mode
145 #define tdm_output_get_dpms stub_tdm_output_get_dpms
146 #define tdm_output_add_change_handler stub_tdm_output_add_change_handler
147 #define tdm_output_remove_change_handler stub_tdm_output_remove_change_handler
148 #define tdm_output_wait_vblank stub_tdm_output_wait_vblank
149
150 #endif // STUB_TDM_DISPLAY_H