2 * Copyright (c) 2021 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-test-suite-utils.h>
19 #include <dali/dali.h>
20 #include <dali/devel-api/adaptor-framework/window-devel.h>
21 #include <dali/internal/system/linux/dali-ecore-x.h>
25 void utc_dali_window_startup(void)
27 test_return_value = TET_UNDEF;
30 void utc_dali_window_cleanup(void)
32 test_return_value = TET_PASS;
37 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
39 } // unnamed namespace
43 Ecore_X_Screen* ecore_x_default_screen_get(void)
46 return (Ecore_X_Screen*)screenId;
49 void ecore_x_screen_size_get(const Ecore_X_Screen* screen, int* w, int* h)
55 Ecore_X_Window ecore_x_window_argb_new(Ecore_X_Window parent, int x, int y, int w, int h)
61 int UtcDaliWindowConstructorP(void)
64 DALI_TEST_CHECK(!window);
68 int UtcDaliWindowCopyConstructorP(void)
71 Dali::Window copy(window);
72 DALI_TEST_CHECK(copy == window);
77 int UtcDaliWindowConstructorFromInternalPointerN(void)
79 Internal::Adaptor::Window* internalWindow = NULL;
80 Dali::Window window(internalWindow);
81 DALI_TEST_CHECK(!window); // Should not reach here!
86 int UtcDaliWindowAssignmentOperatorP(void)
88 const Dali::Window window;
90 DALI_TEST_CHECK(!copy);
92 DALI_TEST_CHECK(copy == window);
97 int UtcDaliWindowDestructorP(void)
99 Dali::Window* window = new Dali::Window();
102 DALI_TEST_CHECK(true);
106 int UtcDaliWindowNewN(void)
108 // Attempt to create a new window
111 PositionSize windowPosition(0, 0, 0, 0);
112 Dali::Window window = Dali::Window::New(windowPosition, "test-window", true);
114 tet_result(TET_FAIL);
116 catch(DaliException& e)
118 DALI_TEST_ASSERT(e, "Failed to create X window", TEST_LOCATION);
121 // Attempt to create a new window
124 PositionSize windowPosition(0, 0, 0, 0);
125 Dali::Window window = Dali::Window::New(windowPosition, "test-window", "test-window-class", true);
127 tet_result(TET_FAIL);
129 catch(DaliException& e)
131 DALI_TEST_ASSERT(e, "Failed to create X window", TEST_LOCATION);
137 int UtcDaliWindowSetClassN(void)
142 window.SetClass("window-name", "window-class");
143 DALI_TEST_CHECK(false); // Should not reach here!
147 DALI_TEST_CHECK(true);
153 int UtcDaliWindowRaiseN(void)
159 DALI_TEST_CHECK(false); // Should not reach here!
163 DALI_TEST_CHECK(true);
169 int UtcDaliWindowLowerN(void)
175 DALI_TEST_CHECK(false); // Should not reach here!
179 DALI_TEST_CHECK(true);
185 int UtcDaliWindowActivateN(void)
191 DALI_TEST_CHECK(false); // Should not reach here!
195 DALI_TEST_CHECK(true);
201 int UtcDaliWindowAddAvailableOrientationN(void)
206 window.AddAvailableOrientation(Dali::WindowOrientation::PORTRAIT);
207 DALI_TEST_CHECK(false); // Should not reach here!
211 DALI_TEST_CHECK(true);
217 int UtcDaliWindowRemoveAvailableOrientationN(void)
222 window.RemoveAvailableOrientation(Dali::WindowOrientation::PORTRAIT);
223 DALI_TEST_CHECK(false); // Should not reach here!
227 DALI_TEST_CHECK(true);
233 int UtcDaliWindowSetPreferredOrientationN(void)
238 window.SetPreferredOrientation(Dali::WindowOrientation::PORTRAIT);
239 DALI_TEST_CHECK(false); // Should not reach here!
243 DALI_TEST_CHECK(true);
249 int UtcDaliWindowGetPreferredOrientationN(void)
254 Dali::WindowOrientation orientation = window.GetPreferredOrientation();
255 DALI_TEST_CHECK(orientation == Dali::WindowOrientation::PORTRAIT); // Should not reach here!
259 DALI_TEST_CHECK(true);
265 int UtcDaliWindowGetNativeHandleN(void)
270 Dali::Any handle = window.GetNativeHandle();
271 DALI_TEST_CHECK(false); // Should not reach here!
275 DALI_TEST_CHECK(true);
281 int UtcDaliWindowSetAcceptFocusN(void)
286 window.SetAcceptFocus(true);
287 DALI_TEST_CHECK(false); // Should not reach here!
291 DALI_TEST_CHECK(true);
297 int UtcDaliWindowIsFocusAcceptableN(void)
302 window.IsFocusAcceptable();
303 DALI_TEST_CHECK(false); // Should not reach here!
307 DALI_TEST_CHECK(true);
313 int UtcDaliWindowFocusChangeSignalN(void)
318 window.FocusChangeSignal();
319 DALI_TEST_CHECK(false); // Should not reach here!
323 DALI_TEST_CHECK(true);
329 int UtcDaliWindowSetPositionNegative(void)
331 Dali::Window instance;
334 Dali::Uint16Pair arg1;
335 instance.SetPosition(arg1);
336 DALI_TEST_CHECK(false); // Should not get here
340 DALI_TEST_CHECK(true); // We expect an assert
345 int UtcDaliWindowResizeSignalNegative(void)
347 Dali::Window instance;
350 instance.ResizeSignal();
351 DALI_TEST_CHECK(false); // Should not get here
355 DALI_TEST_CHECK(true); // We expect an assert
360 int UtcDaliWindowSetBrightnessNegative(void)
362 Dali::Window instance;
366 instance.SetBrightness(arg1);
367 DALI_TEST_CHECK(false); // Should not get here
371 DALI_TEST_CHECK(true); // We expect an assert
376 int UtcDaliWindowTouchedSignalNegative(void)
378 Dali::Window instance;
381 instance.TouchedSignal();
382 DALI_TEST_CHECK(false); // Should not get here
386 DALI_TEST_CHECK(true); // We expect an assert
391 int UtcDaliWindowKeyEventSignalNegative(void)
393 Dali::Window instance;
396 instance.KeyEventSignal();
397 DALI_TEST_CHECK(false); // Should not get here
401 DALI_TEST_CHECK(true); // We expect an assert
406 int UtcDaliWindowSetAcceptFocusNegative(void)
408 Dali::Window instance;
412 instance.SetAcceptFocus(arg1);
413 DALI_TEST_CHECK(false); // Should not get here
417 DALI_TEST_CHECK(true); // We expect an assert
422 int UtcDaliWindowSetInputRegionNegative(void)
424 Dali::Window instance;
427 Dali::Rect<int> arg1;
428 instance.SetInputRegion(arg1);
429 DALI_TEST_CHECK(false); // Should not get here
433 DALI_TEST_CHECK(true); // We expect an assert
438 int UtcDaliWindowSetOpaqueStateNegative(void)
440 Dali::Window instance;
444 instance.SetOpaqueState(arg1);
445 DALI_TEST_CHECK(false); // Should not get here
449 DALI_TEST_CHECK(true); // We expect an assert
454 int UtcDaliWindowSetTransparencyNegative(void)
456 Dali::Window instance;
460 instance.SetTransparency(arg1);
461 DALI_TEST_CHECK(false); // Should not get here
465 DALI_TEST_CHECK(true); // We expect an assert
470 int UtcDaliWindowAddAuxiliaryHintNegative(void)
472 Dali::Window instance;
477 instance.AddAuxiliaryHint(arg1,arg2);
478 DALI_TEST_CHECK(false); // Should not get here
482 DALI_TEST_CHECK(true); // We expect an assert
487 int UtcDaliWindowSetScreenOffModeNegative(void)
489 Dali::Window instance;
492 Dali::WindowScreenOffMode arg1(Dali::WindowScreenOffMode::NEVER);
493 instance.SetScreenOffMode(arg1);
494 DALI_TEST_CHECK(false); // Should not get here
498 DALI_TEST_CHECK(true); // We expect an assert
503 int UtcDaliWindowFocusChangeSignalNegative(void)
505 Dali::Window instance;
508 instance.FocusChangeSignal();
509 DALI_TEST_CHECK(false); // Should not get here
513 DALI_TEST_CHECK(true); // We expect an assert
518 int UtcDaliWindowGetRenderTaskListNegative(void)
520 Dali::Window instance;
523 instance.GetRenderTaskList();
524 DALI_TEST_CHECK(false); // Should not get here
528 DALI_TEST_CHECK(true); // We expect an assert
533 int UtcDaliWindowSetBackgroundColorNegative(void)
535 Dali::Window instance;
539 instance.SetBackgroundColor(arg1);
540 DALI_TEST_CHECK(false); // Should not get here
544 DALI_TEST_CHECK(true); // We expect an assert
549 int UtcDaliWindowRemoveAuxiliaryHintNegative(void)
551 Dali::Window instance;
554 unsigned int arg1(0u);
555 instance.RemoveAuxiliaryHint(arg1);
556 DALI_TEST_CHECK(false); // Should not get here
560 DALI_TEST_CHECK(true); // We expect an assert
565 int UtcDaliWindowSetNotificationLevelNegative(void)
567 Dali::Window instance;
570 Dali::WindowNotificationLevel arg1(Dali::WindowNotificationLevel::NONE);
571 instance.SetNotificationLevel(arg1);
572 DALI_TEST_CHECK(false); // Should not get here
576 DALI_TEST_CHECK(true); // We expect an assert
581 int UtcDaliWindowSetAuxiliaryHintValueNegative(void)
583 Dali::Window instance;
586 unsigned int arg1(0u);
588 instance.SetAuxiliaryHintValue(arg1,arg2);
589 DALI_TEST_CHECK(false); // Should not get here
593 DALI_TEST_CHECK(true); // We expect an assert
598 int UtcDaliWindowAddAvailableOrientationNegative(void)
600 Dali::Window instance;
603 Dali::WindowOrientation arg1(Dali::WindowOrientation::PORTRAIT);
604 instance.AddAvailableOrientation(arg1);
605 DALI_TEST_CHECK(false); // Should not get here
609 DALI_TEST_CHECK(true); // We expect an assert
614 int UtcDaliWindowGetPreferredOrientationNegative(void)
616 Dali::Window instance;
619 instance.GetPreferredOrientation();
620 DALI_TEST_CHECK(false); // Should not get here
624 DALI_TEST_CHECK(true); // We expect an assert
629 int UtcDaliWindowSetPreferredOrientationNegative(void)
631 Dali::Window instance;
634 Dali::WindowOrientation arg1(Dali::WindowOrientation::PORTRAIT);
635 instance.SetPreferredOrientation(arg1);
636 DALI_TEST_CHECK(false); // Should not get here
640 DALI_TEST_CHECK(true); // We expect an assert
645 int UtcDaliWindowRemoveAvailableOrientationNegative(void)
647 Dali::Window instance;
650 Dali::WindowOrientation arg1(Dali::WindowOrientation::PORTRAIT);
651 instance.RemoveAvailableOrientation(arg1);
652 DALI_TEST_CHECK(false); // Should not get here
656 DALI_TEST_CHECK(true); // We expect an assert
661 int UtcDaliWindowAddNegative(void)
663 Dali::Window instance;
668 DALI_TEST_CHECK(false); // Should not get here
672 DALI_TEST_CHECK(true); // We expect an assert
677 int UtcDaliWindowHideNegative(void)
679 Dali::Window instance;
683 DALI_TEST_CHECK(false); // Should not get here
687 DALI_TEST_CHECK(true); // We expect an assert
692 int UtcDaliWindowShowNegative(void)
694 Dali::Window instance;
698 DALI_TEST_CHECK(false); // Should not get here
702 DALI_TEST_CHECK(true); // We expect an assert
707 int UtcDaliWindowLowerNegative(void)
709 Dali::Window instance;
713 DALI_TEST_CHECK(false); // Should not get here
717 DALI_TEST_CHECK(true); // We expect an assert
722 int UtcDaliWindowRaiseNegative(void)
724 Dali::Window instance;
728 DALI_TEST_CHECK(false); // Should not get here
732 DALI_TEST_CHECK(true); // We expect an assert
737 int UtcDaliWindowRemoveNegative(void)
739 Dali::Window instance;
743 instance.Remove(arg1);
744 DALI_TEST_CHECK(false); // Should not get here
748 DALI_TEST_CHECK(true); // We expect an assert
753 int UtcDaliWindowSetSizeNegative(void)
755 Dali::Window instance;
758 Dali::Uint16Pair arg1;
759 instance.SetSize(arg1);
760 DALI_TEST_CHECK(false); // Should not get here
764 DALI_TEST_CHECK(true); // We expect an assert
769 int UtcDaliWindowSetTypeNegative(void)
771 Dali::Window instance;
774 Dali::WindowType arg1(Dali::WindowType::NORMAL);
775 instance.SetType(arg1);
776 DALI_TEST_CHECK(false); // Should not get here
780 DALI_TEST_CHECK(true); // We expect an assert
785 int UtcDaliWindowActivateNegative(void)
787 Dali::Window instance;
791 DALI_TEST_CHECK(false); // Should not get here
795 DALI_TEST_CHECK(true); // We expect an assert
800 int UtcDaliWindowSetClassNegative(void)
802 Dali::Window instance;
807 instance.SetClass(arg1,arg2);
808 DALI_TEST_CHECK(false); // Should not get here
812 DALI_TEST_CHECK(true); // We expect an assert
817 int UtcDaliWindowGetPositionNegative(void)
819 Dali::Window instance;
822 instance.GetPosition();
823 DALI_TEST_CHECK(false); // Should not get here
827 DALI_TEST_CHECK(true); // We expect an assert
832 int UtcDaliWindowGetRootLayerNegative(void)
834 Dali::Window instance;
837 instance.GetRootLayer();
838 DALI_TEST_CHECK(false); // Should not get here
842 DALI_TEST_CHECK(true); // We expect an assert
847 int UtcDaliWindowGetBrightnessNegative(void)
849 Dali::Window instance;
852 instance.GetBrightness();
853 DALI_TEST_CHECK(false); // Should not get here
857 DALI_TEST_CHECK(true); // We expect an assert
862 int UtcDaliWindowGetLayerCountNegative(void)
864 Dali::Window instance;
867 instance.GetLayerCount();
868 DALI_TEST_CHECK(false); // Should not get here
872 DALI_TEST_CHECK(true); // We expect an assert
877 int UtcDaliWindowIsOpaqueStateNegative(void)
879 Dali::Window instance;
882 instance.IsOpaqueState();
883 DALI_TEST_CHECK(false); // Should not get here
887 DALI_TEST_CHECK(true); // We expect an assert
892 int UtcDaliWindowGetNativeHandleNegative(void)
894 Dali::Window instance;
897 instance.GetNativeHandle();
898 DALI_TEST_CHECK(false); // Should not get here
902 DALI_TEST_CHECK(true); // We expect an assert
907 int UtcDaliWindowGetScreenOffModeNegative(void)
909 Dali::Window instance;
912 instance.GetScreenOffMode();
913 DALI_TEST_CHECK(false); // Should not get here
917 DALI_TEST_CHECK(true); // We expect an assert
922 int UtcDaliWindowIsFocusAcceptableNegative(void)
924 Dali::Window instance;
927 instance.IsFocusAcceptable();
928 DALI_TEST_CHECK(false); // Should not get here
932 DALI_TEST_CHECK(true); // We expect an assert
937 int UtcDaliWindowGetAuxiliaryHintIdNegative(void)
939 Dali::Window instance;
943 instance.GetAuxiliaryHintId(arg1);
944 DALI_TEST_CHECK(false); // Should not get here
948 DALI_TEST_CHECK(true); // We expect an assert
953 int UtcDaliWindowGetBackgroundColorNegative(void)
955 Dali::Window instance;
958 instance.GetBackgroundColor();
959 DALI_TEST_CHECK(false); // Should not get here
963 DALI_TEST_CHECK(true); // We expect an assert
968 int UtcDaliWindowGetNotificationLevelNegative(void)
970 Dali::Window instance;
973 instance.GetNotificationLevel();
974 DALI_TEST_CHECK(false); // Should not get here
978 DALI_TEST_CHECK(true); // We expect an assert
983 int UtcDaliWindowGetAuxiliaryHintValueNegative(void)
985 Dali::Window instance;
988 unsigned int arg1(0u);
989 instance.GetAuxiliaryHintValue(arg1);
990 DALI_TEST_CHECK(false); // Should not get here
994 DALI_TEST_CHECK(true); // We expect an assert
999 int UtcDaliWindowGetSupportedAuxiliaryHintNegative(void)
1001 Dali::Window instance;
1004 unsigned int arg1(0u);
1005 instance.GetSupportedAuxiliaryHint(arg1);
1006 DALI_TEST_CHECK(false); // Should not get here
1010 DALI_TEST_CHECK(true); // We expect an assert
1015 int UtcDaliWindowGetSupportedAuxiliaryHintCountNegative(void)
1017 Dali::Window instance;
1020 instance.GetSupportedAuxiliaryHintCount();
1021 DALI_TEST_CHECK(false); // Should not get here
1025 DALI_TEST_CHECK(true); // We expect an assert
1030 int UtcDaliWindowGetDpiNegative(void)
1032 Dali::Window instance;
1036 DALI_TEST_CHECK(false); // Should not get here
1040 DALI_TEST_CHECK(true); // We expect an assert
1045 int UtcDaliWindowGetSizeNegative(void)
1047 Dali::Window instance;
1051 DALI_TEST_CHECK(false); // Should not get here
1055 DALI_TEST_CHECK(true); // We expect an assert
1060 int UtcDaliWindowGetTypeNegative(void)
1062 Dali::Window instance;
1066 DALI_TEST_CHECK(false); // Should not get here
1070 DALI_TEST_CHECK(true); // We expect an assert
1075 int UtcDaliWindowGetLayerNegative(void)
1077 Dali::Window instance;
1080 unsigned int arg1(0u);
1081 instance.GetLayer(arg1);
1082 DALI_TEST_CHECK(false); // Should not get here
1086 DALI_TEST_CHECK(true); // We expect an assert
1091 int UtcDaliWindowIsVisibleNegative(void)
1093 Dali::Window instance;
1096 instance.IsVisible();
1097 DALI_TEST_CHECK(false); // Should not get here
1101 DALI_TEST_CHECK(true); // We expect an assert
1106 int UtcDaliWindowGetNativeIdNegative(void)
1111 DevelWindow::GetNativeId(arg1);
1112 DALI_TEST_CHECK(false); // Should not get here
1116 DALI_TEST_CHECK(true); // We expect an assert
1121 int UtcDaliWindowSetPositionSizeNegative(void)
1126 Dali::Rect<int> arg2;
1127 DevelWindow::SetPositionSize(arg1,arg2);
1128 DALI_TEST_CHECK(false); // Should not get here
1132 DALI_TEST_CHECK(true); // We expect an assert
1137 int UtcDaliWindowWheelEventSignalNegative(void)
1142 DevelWindow::WheelEventSignal(arg1);
1143 DALI_TEST_CHECK(false); // Should not get here
1147 DALI_TEST_CHECK(true); // We expect an assert
1152 int UtcDaliWindowGetCurrentOrientationNegative(void)
1157 DevelWindow::GetCurrentOrientation(arg1);
1158 DALI_TEST_CHECK(false); // Should not get here
1162 DALI_TEST_CHECK(true); // We expect an assert
1167 int UtcDaliWindowGetPhysicalOrientationNegative(void)
1172 DevelWindow::GetPhysicalOrientation(arg1);
1173 DALI_TEST_CHECK(false); // Should not get here
1177 DALI_TEST_CHECK(true); // We expect an assert
1182 int UtcDaliWindowVisibilityChangedSignalNegative(void)
1187 DevelWindow::VisibilityChangedSignal(arg1);
1188 DALI_TEST_CHECK(false); // Should not get here
1192 DALI_TEST_CHECK(true); // We expect an assert
1197 int UtcDaliWindowAddFrameRenderedCallbackNegative(void)
1202 std::unique_ptr<Dali::CallbackBase> arg2;
1204 DevelWindow::AddFrameRenderedCallback(arg1,std::move(arg2),arg3);
1205 DALI_TEST_CHECK(false); // Should not get here
1209 DALI_TEST_CHECK(true); // We expect an assert
1214 int UtcDaliWindowSetAvailableOrientationsNegative(void)
1219 Dali::Vector<Dali::WindowOrientation> arg2;
1220 DevelWindow::SetAvailableOrientations(arg1,arg2);
1221 DALI_TEST_CHECK(false); // Should not get here
1225 DALI_TEST_CHECK(true); // We expect an assert
1230 int UtcDaliWindowAddFramePresentedCallbackNegative(void)
1235 std::unique_ptr<Dali::CallbackBase> arg2;
1237 DevelWindow::AddFramePresentedCallback(arg1,std::move(arg2),arg3);
1238 DALI_TEST_CHECK(false); // Should not get here
1242 DALI_TEST_CHECK(true); // We expect an assert
1247 int UtcDaliWindowTransitionEffectEventSignalNegative(void)
1252 DevelWindow::TransitionEffectEventSignal(arg1);
1253 DALI_TEST_CHECK(false); // Should not get here
1257 DALI_TEST_CHECK(true); // We expect an assert
1262 int UtcDaliWindowEventProcessingFinishedSignalNegative(void)
1267 DevelWindow::EventProcessingFinishedSignal(arg1);
1268 DALI_TEST_CHECK(false); // Should not get here
1272 DALI_TEST_CHECK(true); // We expect an assert
1277 int UtcDaliWindowKeyboardRepeatSettingsChangedSignalNegative(void)
1282 DevelWindow::KeyboardRepeatSettingsChangedSignal(arg1);
1283 DALI_TEST_CHECK(false); // Should not get here
1287 DALI_TEST_CHECK(true); // We expect an assert
1292 int UtcDaliWindowUnparentNegative(void)
1297 DevelWindow::Unparent(arg1);
1298 DALI_TEST_CHECK(false); // Should not get here
1302 DALI_TEST_CHECK(true); // We expect an assert
1307 int UtcDaliWindowGetParentNegative(void)
1312 DevelWindow::GetParent(arg1);
1313 DALI_TEST_CHECK(false); // Should not get here
1317 DALI_TEST_CHECK(true); // We expect an assert
1322 int UtcDaliWindowSetParentNegative(void)
1328 DevelWindow::SetParent(arg1,arg2);
1329 DALI_TEST_CHECK(false); // Should not get here
1333 DALI_TEST_CHECK(true); // We expect an assert