GCC 9.2 Support
[platform/core/uifw/dali-adaptor.git] / automated-tests / src / dali-adaptor / utc-Dali-Window.cpp
1 /*
2  * Copyright (c) 2020 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 #include <dali/dali.h>
19 #include <dali/internal/system/linux/dali-ecore-x.h>
20 #include <dali-test-suite-utils.h>
21
22 namespace Dali
23 {
24 class DragAndDropDetector : public BaseHandle {}; // For UtcDaliWindowGetDragAndDropDetectorN
25 }
26
27 using namespace Dali;
28
29 void utc_dali_window_startup(void)
30 {
31   test_return_value = TET_UNDEF;
32 }
33
34 void utc_dali_window_cleanup(void)
35 {
36   test_return_value = TET_PASS;
37 }
38
39 namespace
40 {
41
42 intptr_t screenId = 0; // intptr_t has the same size as a pointer and is platform independent so this can be returned as a pointer in ecore_x_default_screen_get below without compilation warnings
43
44 } // unnamed namespace
45
46 extern "C"
47 {
48
49 Ecore_X_Screen* ecore_x_default_screen_get(void)
50 {
51   screenId += 8;
52   return (Ecore_X_Screen*)screenId;
53 }
54
55 void ecore_x_screen_size_get(const Ecore_X_Screen *screen, int *w, int *h)
56 {
57  *w = 100;
58  *h = 100;
59 }
60
61 Ecore_X_Window ecore_x_window_argb_new(Ecore_X_Window parent, int x, int y, int w, int h)
62 {
63   return 0;
64 }
65
66 }
67
68 int UtcDaliWindowConstructorP(void)
69 {
70   Dali::Window window;
71   DALI_TEST_CHECK( !window );
72   END_TEST;
73 }
74
75 int UtcDaliWindowCopyConstructorP(void)
76 {
77   Dali::Window window;
78   Dali::Window copy( window );
79   DALI_TEST_CHECK( copy == window );
80
81   END_TEST;
82 }
83
84 int UtcDaliWindowConstructorFromInternalPointerN(void)
85 {
86   Internal::Adaptor::Window* internalWindow = NULL;
87   Dali::Window window(internalWindow);
88   DALI_TEST_CHECK( !window ); // Should not reach here!
89
90   END_TEST;
91 }
92
93 int UtcDaliWindowAssignmentOperatorP(void)
94 {
95   const Dali::Window window;
96   Dali::Window copy;
97   DALI_TEST_CHECK( ! copy );
98   copy = window;
99   DALI_TEST_CHECK( copy == window );
100
101   END_TEST;
102 }
103
104 int UtcDaliWindowDestructorP(void)
105 {
106   Dali::Window* window = new Dali::Window();
107   delete window;
108
109   DALI_TEST_CHECK( true );
110   END_TEST;
111 }
112
113 int UtcDaliWindowNewN(void)
114 {
115   // Attempt to create a new window
116   try
117   {
118     PositionSize windowPosition(0, 0, 0, 0);
119     Dali::Window window = Dali::Window::New( windowPosition, "test-window", true );
120
121     tet_result( TET_FAIL );
122   }
123   catch ( DaliException& e )
124   {
125     DALI_TEST_ASSERT( e, "Failed to create X window", TEST_LOCATION );
126   }
127
128   // Attempt to create a new window
129   try
130   {
131     PositionSize windowPosition(0, 0, 0, 0);
132     Dali::Window window = Dali::Window::New( windowPosition, "test-window", "test-window-class", true );
133
134     tet_result( TET_FAIL );
135   }
136   catch ( DaliException& e )
137   {
138     DALI_TEST_ASSERT( e, "Failed to create X window", TEST_LOCATION );
139   }
140
141   END_TEST;
142 }
143
144 int UtcDaliWindowShowIndicatorN(void)
145 {
146   Dali::Window window;
147   try
148   {
149     window.ShowIndicator(Dali::Window::VISIBLE);
150     DALI_TEST_CHECK( false ); // Should not reach here!
151   }
152   catch( ... )
153   {
154     DALI_TEST_CHECK( true );
155   }
156
157   END_TEST;
158 }
159
160 int UtcDaliWindowSetIndicatorBgOpacityN(void)
161 {
162   Dali::Window window;
163   try
164   {
165     window.SetIndicatorBgOpacity(Dali::Window::OPAQUE);
166     DALI_TEST_CHECK( false ); // Should not reach here!
167   }
168   catch( ... )
169   {
170     DALI_TEST_CHECK( true );
171   }
172
173   END_TEST;
174 }
175
176 int UtcDaliWindowRotateIndicatorN(void)
177 {
178   Dali::Window window;
179   try
180   {
181     window.RotateIndicator(Dali::Window::PORTRAIT);
182     DALI_TEST_CHECK( false ); // Should not reach here!
183   }
184   catch( ... )
185   {
186     DALI_TEST_CHECK( true );
187   }
188
189   END_TEST;
190 }
191
192 int UtcDaliWindowSetClassN(void)
193 {
194   Dali::Window window;
195   try
196   {
197     window.SetClass("window-name", "window-class");
198     DALI_TEST_CHECK( false ); // Should not reach here!
199   }
200   catch( ... )
201   {
202     DALI_TEST_CHECK( true );
203   }
204
205   END_TEST;
206 }
207
208 int UtcDaliWindowRaiseN(void)
209 {
210   Dali::Window window;
211   try
212   {
213     window.Raise();
214     DALI_TEST_CHECK( false ); // Should not reach here!
215   }
216   catch( ... )
217   {
218     DALI_TEST_CHECK( true );
219   }
220
221   END_TEST;
222 }
223
224 int UtcDaliWindowLowerN(void)
225 {
226   Dali::Window window;
227   try
228   {
229     window.Lower();
230     DALI_TEST_CHECK( false ); // Should not reach here!
231   }
232   catch( ... )
233   {
234     DALI_TEST_CHECK( true );
235   }
236
237   END_TEST;
238 }
239
240 int UtcDaliWindowActivateN(void)
241 {
242   Dali::Window window;
243   try
244   {
245     window.Activate();
246     DALI_TEST_CHECK( false ); // Should not reach here!
247   }
248   catch( ... )
249   {
250     DALI_TEST_CHECK( true );
251   }
252
253   END_TEST;
254 }
255
256 int UtcDaliWindowAddAvailableOrientationN(void)
257 {
258   Dali::Window window;
259   try
260   {
261     window.AddAvailableOrientation(Dali::Window::PORTRAIT);
262     DALI_TEST_CHECK( false ); // Should not reach here!
263   }
264   catch( ... )
265   {
266     DALI_TEST_CHECK( true );
267   }
268
269   END_TEST;
270 }
271
272 int UtcDaliWindowRemoveAvailableOrientationN(void)
273 {
274   Dali::Window window;
275   try
276   {
277     window.RemoveAvailableOrientation(Dali::Window::PORTRAIT);
278     DALI_TEST_CHECK( false ); // Should not reach here!
279   }
280   catch( ... )
281   {
282     DALI_TEST_CHECK( true );
283   }
284
285   END_TEST;
286 }
287
288 int UtcDaliWindowSetPreferredOrientationN(void)
289 {
290   Dali::Window window;
291   try
292   {
293     window.SetPreferredOrientation(Dali::Window::PORTRAIT);
294     DALI_TEST_CHECK( false ); // Should not reach here!
295   }
296   catch( ... )
297   {
298     DALI_TEST_CHECK( true );
299   }
300
301   END_TEST;
302 }
303
304 int UtcDaliWindowGetPreferredOrientationN(void)
305 {
306   Dali::Window window;
307   try
308   {
309     Dali::Window::WindowOrientation orientation = window.GetPreferredOrientation();
310     DALI_TEST_CHECK( orientation == Dali::Window::PORTRAIT ); // Should not reach here!
311   }
312   catch( ... )
313   {
314     DALI_TEST_CHECK( true );
315   }
316
317   END_TEST;
318 }
319
320 int UtcDaliWindowGetDragAndDropDetectorN(void)
321 {
322   Dali::Window window;
323   try
324   {
325     DragAndDropDetector detector = window.GetDragAndDropDetector();
326     DALI_TEST_CHECK( !detector ); // Should not reach here!
327   }
328   catch( ... )
329   {
330     DALI_TEST_CHECK( true );
331   }
332
333   END_TEST;
334 }
335
336 int UtcDaliWindowGetNativeHandleN(void)
337 {
338   Dali::Window window;
339   try
340   {
341     Dali::Any handle = window.GetNativeHandle();
342     DALI_TEST_CHECK( false ); // Should not reach here!
343   }
344   catch( ... )
345   {
346     DALI_TEST_CHECK( true );
347   }
348
349   END_TEST;
350 }
351
352 int UtcDaliWindowSetAcceptFocusN(void)
353 {
354   Dali::Window window;
355   try
356   {
357     window.SetAcceptFocus( true );
358     DALI_TEST_CHECK( false ); // Should not reach here!
359   }
360   catch( ... )
361   {
362     DALI_TEST_CHECK( true );
363   }
364
365   END_TEST;
366 }
367
368 int UtcDaliWindowIsFocusAcceptableN(void)
369 {
370   Dali::Window window;
371   try
372   {
373     window.IsFocusAcceptable();
374     DALI_TEST_CHECK( false ); // Should not reach here!
375   }
376   catch( ... )
377   {
378     DALI_TEST_CHECK( true );
379   }
380
381   END_TEST;
382 }
383
384 int UtcDaliWindowIndicatorVisibilityChangedSignalN(void)
385 {
386   Dali::Window window;
387   try
388   {
389     window.IndicatorVisibilityChangedSignal();
390     DALI_TEST_CHECK( false ); // Should not reach here!
391   }
392   catch( ... )
393   {
394     DALI_TEST_CHECK( true );
395   }
396
397   END_TEST;
398 }
399
400 int UtcDaliWindowFocusChangedSignalN(void)
401 {
402   Dali::Window window;
403   try
404   {
405     window.FocusChangedSignal();
406     DALI_TEST_CHECK( false ); // Should not reach here!
407   }
408   catch( ... )
409   {
410     DALI_TEST_CHECK( true );
411   }
412
413   END_TEST;
414 }