2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
27 void utc_dali_glwindow_startup(void)
29 test_return_value = TET_UNDEF;
32 void utc_dali_glwindow_cleanup(void)
34 test_return_value = TET_PASS;
37 int UtcDaliGlWindowConstructorP(void)
39 Dali::GlWindow window;
40 DALI_TEST_CHECK( !window );
44 int UtcDaliGlWindowCopyConstructorP(void)
46 Dali::GlWindow window;
47 Dali::GlWindow copy( window );
48 DALI_TEST_CHECK( copy == window );
53 int UtcDaliGlWindowConstructorFromInternalPointerN(void)
55 Internal::Adaptor::GlWindow* internalWindow = NULL;
56 Dali::GlWindow window(internalWindow);
57 DALI_TEST_CHECK( !window );
62 int UtcDaliGlWindowAssignmentOperatorP(void)
64 const Dali::GlWindow window;
66 DALI_TEST_CHECK( ! copy );
68 DALI_TEST_CHECK( copy == window );
73 int UtcDaliGlWindowDestructorP(void)
75 Dali::GlWindow* window = new Dali::GlWindow();
78 DALI_TEST_CHECK( true );
82 int UtcDaliGlWindowNew1(void)
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 );
90 catch ( DaliException& e )
92 DALI_TEST_ASSERT( e, "Failed to create X window", TEST_LOCATION );
98 int UtcDaliGlWindowNew2(void)
102 PositionSize windowPosition(20, 10, 10, 10);
103 Dali::GlWindow window = Dali::GlWindow::New( windowPosition, "test-window", "test-window-class", true );
105 tet_result( TET_FAIL );
107 catch ( DaliException& e )
109 DALI_TEST_ASSERT( e, "Failed to create X window", TEST_LOCATION );
114 int UtcDaliGlWindowSetEglConfigGles20(void)
116 Dali::GlWindow window;
119 window.SetEglConfig( true, true, 0, Dali::GlWindow::GlesVersion::VERSION_2_0 );
121 DALI_TEST_CHECK( false);
125 DALI_TEST_CHECK( true );
130 int UtcDaliGlWindowSetEglConfigGles30(void)
132 Dali::GlWindow window;
135 window.SetEglConfig( true, true, 0, Dali::GlWindow::GlesVersion::VERSION_3_0 );
137 DALI_TEST_CHECK( false );
141 DALI_TEST_CHECK( true );
146 int UtcDaliGlWindowRaise(void)
148 Dali::GlWindow window;
154 DALI_TEST_CHECK( false );
158 DALI_TEST_CHECK( true );
163 int UtcDaliGlWindowLower(void)
165 Dali::GlWindow window;
171 DALI_TEST_CHECK( false );
175 DALI_TEST_CHECK( true );
180 int UtcDaliGlWindowActivate(void)
182 Dali::GlWindow window;
188 DALI_TEST_CHECK( false );
192 DALI_TEST_CHECK( true );
197 int UtcDaliGlWindowShow(void)
199 Dali::GlWindow window;
205 DALI_TEST_CHECK( false );
209 DALI_TEST_CHECK( true );
214 int UtcDaliGlWindowHide(void)
216 Dali::GlWindow window;
222 DALI_TEST_CHECK( false );
226 DALI_TEST_CHECK( true );
231 int UtcDaliGlWindowSetGetPositionSize(void)
233 Dali::GlWindow window;
237 PositionSize setPositionSize( 0, 0, 100, 100);
238 window.SetPositionSize( setPositionSize );
239 PositionSize getPositionSize = window.GetPositionSize();
240 DALI_TEST_CHECK( setPositionSize == getPositionSize );
242 setPositionSize.x = 10;
243 setPositionSize.y = 20;
244 window.SetPositionSize( setPositionSize );
245 getPositionSize = window.GetPositionSize();
246 DALI_TEST_CHECK( setPositionSize == getPositionSize );
248 setPositionSize.width = 50;
249 setPositionSize.height = 50;
250 window.SetPositionSize( setPositionSize );
251 getPositionSize = window.GetPositionSize();
252 DALI_TEST_CHECK( setPositionSize == getPositionSize );
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 );
262 DALI_TEST_CHECK( false );
266 DALI_TEST_CHECK( true );
271 int UtcDaliGlWindowSetInputRegion(void)
273 Dali::GlWindow window;
277 window.SetInputRegion( Rect< int >( 0, 0, 100, 10 ) );
279 DALI_TEST_CHECK( false );
283 DALI_TEST_CHECK( true );
288 int UtcDaliGlWindowOpaqueState(void)
290 Dali::GlWindow window;
294 bool opaquestate = window.IsOpaqueState();
295 DALI_TEST_CHECK( opaquestate == true );
297 DALI_TEST_CHECK( false );
301 DALI_TEST_CHECK( true );
306 int UtcDaliGlWindowSetAvailableOrientations(void)
308 Dali::GlWindow window;
312 Dali::Vector< Dali::WindowOrientation> orientations;
313 orientations.PushBack( Dali::WindowOrientation::PORTRAIT );
314 orientations.PushBack( Dali::WindowOrientation::LANDSCAPE );
315 orientations.PushBack( Dali::WindowOrientation::PORTRAIT_INVERSE );
316 orientations.PushBack( Dali::WindowOrientation::LANDSCAPE_INVERSE );
317 orientations.PushBack( Dali::WindowOrientation::NO_ORIENTATION_PREFERENCE );
318 orientations.PushBack( Dali::WindowOrientation::PORTRAIT );
319 orientations.PushBack( Dali::WindowOrientation::LANDSCAPE );
320 orientations.PushBack( Dali::WindowOrientation::PORTRAIT_INVERSE );
321 window.SetAvailableOrientations(orientations);
323 DALI_TEST_CHECK( false );
327 DALI_TEST_CHECK( true );
332 int UtcDaliGlWindowSetPreferredOrientation(void)
334 Dali::GlWindow window;
338 window.SetPreferredOrientation(Dali::WindowOrientation::PORTRAIT);
340 DALI_TEST_CHECK( false );
344 DALI_TEST_CHECK( true );
349 int UtcDaliGlWindowSetPreferredOrientation1(void)
351 Dali::GlWindow window;
355 window.SetPreferredOrientation(Dali::WindowOrientation::NO_ORIENTATION_PREFERENCE);
357 DALI_TEST_CHECK( false );
361 DALI_TEST_CHECK( true );
366 int UtcDaliWindowGetCurrentOrientation(void)
368 Dali::GlWindow window;
372 Dali::WindowOrientation orientation = window.GetCurrentOrientation();
373 DALI_TEST_CHECK( orientation == Dali::WindowOrientation::PORTRAIT );
375 DALI_TEST_CHECK( false );
379 DALI_TEST_CHECK( true );
384 // Internal callback function
389 int glRenderFrame(void)
391 static unsigned int retFlag = 0;
395 void glTerminate(void)
399 int UtcDaliGlWindowRegisterGlCallback(void)
401 Dali::GlWindow window;
405 window.RegisterGlCallback( Dali::MakeCallback( glInit ), Dali::MakeCallback( glRenderFrame ), Dali::MakeCallback( glTerminate ) );
407 DALI_TEST_CHECK( false );
411 DALI_TEST_CHECK( true );
416 int UtcDaliGlWindowRenderOnce(void)
418 Dali::GlWindow window;
422 window.RegisterGlCallback( Dali::MakeCallback( glInit ), Dali::MakeCallback( glRenderFrame ), Dali::MakeCallback( glTerminate ) );
425 DALI_TEST_CHECK( false );
429 DALI_TEST_CHECK( true );
434 int UtcDaliGlWindowGetSupportedAuxiliaryHintCount(void)
436 Dali::GlWindow window;
440 window.GetSupportedAuxiliaryHintCount();
442 DALI_TEST_CHECK( false );
446 DALI_TEST_CHECK( true );
451 int UtcDaliGlWindowGetSupportedAuxiliaryHint(void)
453 Dali::GlWindow window;
457 window.GetSupportedAuxiliaryHint( 0 );
459 DALI_TEST_CHECK( false );
463 DALI_TEST_CHECK( true );
468 int UtcDaliGlWindowAddAuxiliaryHint(void)
470 Dali::GlWindow window;
474 window.AddAuxiliaryHint( "stack_pop_to", "1" );
476 DALI_TEST_CHECK( false );
480 DALI_TEST_CHECK( true );
485 int UtcDaliGlWindowRemoveAuxiliaryHint(void)
487 Dali::GlWindow window;
491 window.RemoveAuxiliaryHint( 0 );
493 DALI_TEST_CHECK( false );
497 DALI_TEST_CHECK( true );
502 int UtcDaliGlWindowSetAuxiliaryHintValue(void)
504 Dali::GlWindow window;
508 window.SetAuxiliaryHintValue( 0, "0" );
510 DALI_TEST_CHECK( false );
514 DALI_TEST_CHECK( true );
519 int UtcDaliGlWindowGetAuxiliaryHintValue(void)
521 Dali::GlWindow window;
525 window.GetAuxiliaryHintValue( 0 );
527 DALI_TEST_CHECK( false );
531 DALI_TEST_CHECK( true );
536 int UtcDaliGlWindowGetAuxiliaryHintId(void)
538 Dali::GlWindow window;
542 window.GetAuxiliaryHintId( "0" );
544 DALI_TEST_CHECK( false );
548 DALI_TEST_CHECK( true );
553 int UtcDaliGlWindowFocusChangeSignal(void)
555 Dali::GlWindow window;
559 window.FocusChangeSignal();
561 DALI_TEST_CHECK( false );
565 DALI_TEST_CHECK( true );
570 int UtcDaliGlWindowResizeSignal(void)
572 Dali::GlWindow window;
576 window.ResizeSignal();
578 DALI_TEST_CHECK( false );
582 DALI_TEST_CHECK( true );
587 int UtcDaliGlWindowKeyEventSignal(void)
589 Dali::GlWindow window;
593 window.KeyEventSignal();
595 DALI_TEST_CHECK( false );
599 DALI_TEST_CHECK( true );
604 int UtcDaliGlWindowTouchedSignal(void)
606 Dali::GlWindow window;
610 window.TouchedSignal();
612 DALI_TEST_CHECK( false );
616 DALI_TEST_CHECK( true );
621 int UtcDaliGlWindowVisibilityChangedSignal(void)
623 Dali::GlWindow window;
627 window.VisibilityChangedSignal();
629 DALI_TEST_CHECK( false );
633 DALI_TEST_CHECK( true );