Use existing callback ID for recurring callbacks
[platform/core/uifw/dali-adaptor.git] / automated-tests / src / dali-adaptor / utc-Dali-Gl-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/devel-api/adaptor-framework/gl-window.h>
20 #include <dali/internal/system/linux/dali-ecore-x.h>
21 #include <dali-test-suite-utils.h>
22 #include <adaptor-test-application.h>
23
24
25 using namespace Dali;
26
27 void utc_dali_glwindow_startup(void)
28 {
29   test_return_value = TET_UNDEF;
30 }
31
32 void utc_dali_glwindow_cleanup(void)
33 {
34   test_return_value = TET_PASS;
35 }
36
37 int UtcDaliGlWindowConstructorP(void)
38 {
39   Dali::GlWindow window;
40   DALI_TEST_CHECK( !window );
41   END_TEST;
42 }
43
44 int UtcDaliGlWindowCopyConstructorP(void)
45 {
46   Dali::GlWindow window;
47   Dali::GlWindow copy( window );
48   DALI_TEST_CHECK( copy == window );
49
50   END_TEST;
51 }
52
53 int UtcDaliGlWindowConstructorFromInternalPointerN(void)
54 {
55   Internal::Adaptor::GlWindow* internalWindow = NULL;
56   Dali::GlWindow window(internalWindow);
57   DALI_TEST_CHECK( !window );
58
59   END_TEST;
60 }
61
62 int UtcDaliGlWindowAssignmentOperatorP(void)
63 {
64   const Dali::GlWindow window;
65   Dali::GlWindow copy;
66   DALI_TEST_CHECK( ! copy );
67   copy = window;
68   DALI_TEST_CHECK( copy == window );
69
70   END_TEST;
71 }
72
73 int UtcDaliGlWindowDestructorP(void)
74 {
75   Dali::GlWindow* window = new Dali::GlWindow();
76   delete window;
77
78   DALI_TEST_CHECK( true );
79   END_TEST;
80 }
81
82 int UtcDaliGlWindowNew1(void)
83 {
84   try
85   {
86     PositionSize windowPosition(0, 0, 10, 10);
87     Dali::GlWindow window = Dali::GlWindow::New( windowPosition, "test-window", "test-window-class", true );
88     tet_result( TET_FAIL );
89   }
90   catch ( DaliException& e )
91   {
92     DALI_TEST_ASSERT( e, "Failed to create X window", TEST_LOCATION );
93   }
94
95   END_TEST;
96 }
97
98 int UtcDaliGlWindowNew2(void)
99 {
100   try
101   {
102     PositionSize windowPosition(20, 10, 10, 10);
103     Dali::GlWindow window = Dali::GlWindow::New( windowPosition, "test-window", "test-window-class", true );
104
105     tet_result( TET_FAIL );
106   }
107   catch ( DaliException& e )
108   {
109     DALI_TEST_ASSERT( e, "Failed to create X window", TEST_LOCATION );
110   }
111   END_TEST;
112 }
113
114 int UtcDaliGlWindowSetEglConfigGles20(void)
115 {
116   Dali::GlWindow window;
117   try
118   {
119     window.SetEglConfig( true, true, 0, Dali::GlWindow::GlesVersion::VERSION_2_0 );
120
121     DALI_TEST_CHECK( false);
122   }
123   catch( ... )
124   {
125     DALI_TEST_CHECK( true );
126   }
127   END_TEST;
128 }
129
130 int UtcDaliGlWindowSetEglConfigGles30(void)
131 {
132   Dali::GlWindow window;
133   try
134   {
135     window.SetEglConfig( true, true, 0, Dali::GlWindow::GlesVersion::VERSION_3_0 );
136
137     DALI_TEST_CHECK( false );
138   }
139   catch( ... )
140   {
141     DALI_TEST_CHECK( true );
142   }
143   END_TEST;
144 }
145
146 int UtcDaliGlWindowRaise(void)
147 {
148   Dali::GlWindow window;
149
150   try
151   {
152     window.Raise();
153
154     DALI_TEST_CHECK( false );
155   }
156   catch( ... )
157   {
158     DALI_TEST_CHECK( true );
159   }
160   END_TEST;
161 }
162
163 int UtcDaliGlWindowLower(void)
164 {
165   Dali::GlWindow window;
166
167   try
168   {
169     window.Lower();
170
171     DALI_TEST_CHECK( false );
172   }
173   catch( ... )
174   {
175     DALI_TEST_CHECK( true );
176   }
177   END_TEST;
178 }
179
180 int UtcDaliGlWindowActivate(void)
181 {
182   Dali::GlWindow window;
183
184   try
185   {
186     window.Activate();
187
188     DALI_TEST_CHECK( false );
189   }
190   catch( ... )
191   {
192     DALI_TEST_CHECK( true );
193   }
194   END_TEST;
195 }
196
197 int UtcDaliGlWindowShow(void)
198 {
199   Dali::GlWindow window;
200
201   try
202   {
203     window.Show();
204
205     DALI_TEST_CHECK( false );
206   }
207   catch( ... )
208   {
209     DALI_TEST_CHECK( true );
210   }
211   END_TEST;
212 }
213
214 int UtcDaliGlWindowHide(void)
215 {
216   Dali::GlWindow window;
217
218   try
219   {
220     window.Hide();
221
222     DALI_TEST_CHECK( false );
223   }
224   catch( ... )
225   {
226     DALI_TEST_CHECK( true );
227   }
228   END_TEST;
229 }
230
231 int UtcDaliGlWindowSetGetPositionSize(void)
232 {
233   Dali::GlWindow window;
234
235   try
236   {
237     PositionSize setPositionSize( 0, 0, 100, 100);
238     window.SetPositionSize( setPositionSize );
239     PositionSize getPositionSize = window.GetPositionSize();
240     DALI_TEST_CHECK( setPositionSize == getPositionSize );
241
242     setPositionSize.x = 10;
243     setPositionSize.y = 20;
244     window.SetPositionSize( setPositionSize );
245     getPositionSize = window.GetPositionSize();
246     DALI_TEST_CHECK( setPositionSize == getPositionSize );
247
248     setPositionSize.width = 50;
249     setPositionSize.height = 50;
250     window.SetPositionSize( setPositionSize );
251     getPositionSize = window.GetPositionSize();
252     DALI_TEST_CHECK( setPositionSize == getPositionSize );
253
254     setPositionSize.x = 0;
255     setPositionSize.y = 0;
256     setPositionSize.width = 100;
257     setPositionSize.height = 100;
258     window.SetPositionSize( setPositionSize );
259     getPositionSize = window.GetPositionSize();
260     DALI_TEST_CHECK( setPositionSize == getPositionSize );
261
262     DALI_TEST_CHECK( false );
263   }
264   catch( ... )
265   {
266     DALI_TEST_CHECK( true );
267   }
268   END_TEST;
269 }
270
271 int UtcDaliGlWindowSetInputRegion(void)
272 {
273   Dali::GlWindow window;
274
275   try
276   {
277     window.SetInputRegion(  Rect< int >( 0, 0, 100, 10 )  );
278
279     DALI_TEST_CHECK( false );
280   }
281   catch( ... )
282   {
283     DALI_TEST_CHECK( true );
284   }
285   END_TEST;
286 }
287
288 int UtcDaliGlWindowOpaqueState(void)
289 {
290   Dali::GlWindow window;
291
292   try
293   {
294     bool opaquestate = window.IsOpaqueState();
295     DALI_TEST_CHECK( opaquestate == true );
296
297     DALI_TEST_CHECK( false );
298   }
299   catch( ... )
300   {
301     DALI_TEST_CHECK( true );
302   }
303   END_TEST;
304 }
305
306 int UtcDaliGlWindowSetAvailableOrientations(void)
307 {
308   Dali::GlWindow window;
309
310   try
311   {
312     Dali::Vector< Dali::GlWindow::GlWindowOrientation> orientations;
313     orientations.PushBack( Dali::GlWindow::GlWindowOrientation::PORTRAIT );
314     orientations.PushBack( Dali::GlWindow::GlWindowOrientation::LANDSCAPE );
315     orientations.PushBack( Dali::GlWindow::GlWindowOrientation::PORTRAIT_INVERSE );
316     orientations.PushBack( Dali::GlWindow::GlWindowOrientation::LANDSCAPE_INVERSE );
317     orientations.PushBack( Dali::GlWindow::GlWindowOrientation::NO_ORIENTATION_PREFERENCE );
318     orientations.PushBack( Dali::GlWindow::GlWindowOrientation::PORTRAIT );
319     orientations.PushBack( Dali::GlWindow::GlWindowOrientation::LANDSCAPE );
320     orientations.PushBack( Dali::GlWindow::GlWindowOrientation::PORTRAIT_INVERSE );
321     window.SetAvailableOrientations(orientations);
322
323     DALI_TEST_CHECK( false );
324   }
325   catch( ... )
326   {
327     DALI_TEST_CHECK( true );
328   }
329   END_TEST;
330 }
331
332 int UtcDaliGlWindowSetPreferredOrientation(void)
333 {
334   Dali::GlWindow window;
335
336   try
337   {
338     window.SetPreferredOrientation(Dali::GlWindow::GlWindowOrientation::PORTRAIT);
339
340     DALI_TEST_CHECK( false );
341   }
342   catch( ... )
343   {
344     DALI_TEST_CHECK( true );
345   }
346   END_TEST;
347 }
348
349 int UtcDaliGlWindowSetPreferredOrientation1(void)
350 {
351   Dali::GlWindow window;
352
353   try
354   {
355     window.SetPreferredOrientation(Dali::GlWindow::GlWindowOrientation::NO_ORIENTATION_PREFERENCE);
356
357     DALI_TEST_CHECK( false );
358   }
359   catch( ... )
360   {
361     DALI_TEST_CHECK( true );
362   }
363   END_TEST;
364 }
365
366 int UtcDaliWindowGetCurrentOrientation(void)
367 {
368   Dali::GlWindow window;
369
370   try
371   {
372     Dali::GlWindow::GlWindowOrientation orientation = window.GetCurrentOrientation();
373     DALI_TEST_CHECK( orientation == Dali::GlWindow::GlWindowOrientation::PORTRAIT );
374
375     DALI_TEST_CHECK( false );
376   }
377   catch( ... )
378   {
379     DALI_TEST_CHECK( true );
380   }
381   END_TEST;
382 }
383
384 // Internal callback function
385 void glInit()
386 {
387 }
388
389 void glRenderFrame()
390 {
391 }
392
393 void glTerminate()
394 {
395 }
396
397 int UtcDaliGlWindowRegisterGlCallback(void)
398 {
399   Dali::GlWindow window;
400
401   try
402   {
403     window.RegisterGlCallback( glInit, glRenderFrame, glTerminate );
404
405     DALI_TEST_CHECK( false );
406   }
407   catch( ... )
408   {
409     DALI_TEST_CHECK( true );
410   }
411   END_TEST;
412 }
413
414 int UtcDaliGlWindowRenderOnce(void)
415 {
416   Dali::GlWindow window;
417
418   try
419   {
420     window.RegisterGlCallback( glInit, glRenderFrame, glTerminate );
421     window.RenderOnce();
422
423     DALI_TEST_CHECK( false );
424   }
425   catch( ... )
426   {
427     DALI_TEST_CHECK( true );
428   }
429   END_TEST;
430 }
431
432 int UtcDaliGlWindowGetSupportedAuxiliaryHintCount(void)
433 {
434   Dali::GlWindow window;
435
436   try
437   {
438     window.GetSupportedAuxiliaryHintCount();
439
440     DALI_TEST_CHECK( false );
441   }
442   catch( ... )
443   {
444     DALI_TEST_CHECK( true );
445   }
446   END_TEST;
447 }
448
449 int UtcDaliGlWindowGetSupportedAuxiliaryHint(void)
450 {
451   Dali::GlWindow window;
452
453   try
454   {
455     window.GetSupportedAuxiliaryHint( 0 );
456
457     DALI_TEST_CHECK( false );
458   }
459   catch( ... )
460   {
461     DALI_TEST_CHECK( true );
462   }
463   END_TEST;
464 }
465
466 int UtcDaliGlWindowAddAuxiliaryHint(void)
467 {
468   Dali::GlWindow window;
469
470   try
471   {
472     window.AddAuxiliaryHint( "stack_pop_to", "1" );
473
474     DALI_TEST_CHECK( false );
475   }
476   catch( ... )
477   {
478     DALI_TEST_CHECK( true );
479   }
480   END_TEST;
481 }
482
483 int UtcDaliGlWindowRemoveAuxiliaryHint(void)
484 {
485   Dali::GlWindow window;
486
487   try
488   {
489     window.RemoveAuxiliaryHint( 0 );
490
491     DALI_TEST_CHECK( false );
492   }
493   catch( ... )
494   {
495     DALI_TEST_CHECK( true );
496   }
497   END_TEST;
498 }
499
500 int UtcDaliGlWindowSetAuxiliaryHintValue(void)
501 {
502   Dali::GlWindow window;
503
504   try
505   {
506     window.SetAuxiliaryHintValue( 0,  "0" );
507
508     DALI_TEST_CHECK( false );
509   }
510   catch( ... )
511   {
512     DALI_TEST_CHECK( true );
513   }
514   END_TEST;
515 }
516
517 int UtcDaliGlWindowGetAuxiliaryHintValue(void)
518 {
519   Dali::GlWindow window;
520
521   try
522   {
523     window.GetAuxiliaryHintValue( 0 );
524
525     DALI_TEST_CHECK( false );
526   }
527   catch( ... )
528   {
529     DALI_TEST_CHECK( true );
530   }
531   END_TEST;
532 }
533
534 int UtcDaliGlWindowGetAuxiliaryHintId(void)
535 {
536   Dali::GlWindow window;
537
538   try
539   {
540     window.GetAuxiliaryHintId( "0" );
541
542     DALI_TEST_CHECK( false );
543   }
544   catch( ... )
545   {
546     DALI_TEST_CHECK( true );
547   }
548   END_TEST;
549 }
550
551 int UtcDaliGlWindowFocusChangeSignal(void)
552 {
553   Dali::GlWindow window;
554
555   try
556   {
557     window.FocusChangeSignal();
558
559     DALI_TEST_CHECK( false );
560   }
561   catch( ... )
562   {
563     DALI_TEST_CHECK( true );
564   }
565   END_TEST;
566 }
567
568 int UtcDaliGlWindowResizeSignal(void)
569 {
570   Dali::GlWindow window;
571
572   try
573   {
574     window.ResizeSignal();
575
576     DALI_TEST_CHECK( false );
577   }
578   catch( ... )
579   {
580     DALI_TEST_CHECK( true );
581   }
582   END_TEST;
583 }
584
585 int UtcDaliGlWindowKeyEventSignal(void)
586 {
587   Dali::GlWindow window;
588
589   try
590   {
591     window.KeyEventSignal();
592
593     DALI_TEST_CHECK( false );
594   }
595   catch( ... )
596   {
597     DALI_TEST_CHECK( true );
598   }
599   END_TEST;
600 }
601
602 int UtcDaliGlWindowTouchedSignal(void)
603 {
604   Dali::GlWindow window;
605
606   try
607   {
608     window.TouchedSignal();
609
610     DALI_TEST_CHECK( false );
611   }
612   catch( ... )
613   {
614     DALI_TEST_CHECK( true );
615   }
616   END_TEST;
617 }
618
619 int UtcDaliGlWindowVisibilityChangedSignal(void)
620 {
621   Dali::GlWindow window;
622
623   try
624   {
625     window.VisibilityChangedSignal();
626
627     DALI_TEST_CHECK( false );
628   }
629   catch( ... )
630   {
631     DALI_TEST_CHECK( true );
632   }
633   END_TEST;
634 }