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 UtcDaliWindowSetPositionSizeWithOrientationN(void)
270 DevelWindow::SetPositionSizeWithOrientation(window, PositionSize(0, 0, 200, 100), Dali::WindowOrientation::PORTRAIT);
271 DALI_TEST_CHECK(false); // Should not reach here!
275 DALI_TEST_CHECK(true);
281 int UtcDaliWindowGetNativeHandleN(void)
286 Dali::Any handle = window.GetNativeHandle();
287 DALI_TEST_CHECK(false); // Should not reach here!
291 DALI_TEST_CHECK(true);
297 int UtcDaliWindowSetAcceptFocusN(void)
302 window.SetAcceptFocus(true);
303 DALI_TEST_CHECK(false); // Should not reach here!
307 DALI_TEST_CHECK(true);
313 int UtcDaliWindowIsFocusAcceptableN(void)
318 window.IsFocusAcceptable();
319 DALI_TEST_CHECK(false); // Should not reach here!
323 DALI_TEST_CHECK(true);
329 int UtcDaliWindowFocusChangeSignalN(void)
334 window.FocusChangeSignal();
335 DALI_TEST_CHECK(false); // Should not reach here!
339 DALI_TEST_CHECK(true);
345 int UtcDaliWindowSetPositionNegative(void)
347 Dali::Window instance;
350 Dali::Uint16Pair arg1;
351 instance.SetPosition(arg1);
352 DALI_TEST_CHECK(false); // Should not get here
356 DALI_TEST_CHECK(true); // We expect an assert
361 int UtcDaliWindowResizeSignalNegative(void)
363 Dali::Window instance;
366 instance.ResizeSignal();
367 DALI_TEST_CHECK(false); // Should not get here
371 DALI_TEST_CHECK(true); // We expect an assert
376 int UtcDaliWindowSetBrightnessNegative(void)
378 Dali::Window instance;
382 instance.SetBrightness(arg1);
383 DALI_TEST_CHECK(false); // Should not get here
387 DALI_TEST_CHECK(true); // We expect an assert
392 int UtcDaliWindowTouchedSignalNegative(void)
394 Dali::Window instance;
397 instance.TouchedSignal();
398 DALI_TEST_CHECK(false); // Should not get here
402 DALI_TEST_CHECK(true); // We expect an assert
407 int UtcDaliWindowKeyEventSignalNegative(void)
409 Dali::Window instance;
412 instance.KeyEventSignal();
413 DALI_TEST_CHECK(false); // Should not get here
417 DALI_TEST_CHECK(true); // We expect an assert
422 int UtcDaliWindowSetAcceptFocusNegative(void)
424 Dali::Window instance;
428 instance.SetAcceptFocus(arg1);
429 DALI_TEST_CHECK(false); // Should not get here
433 DALI_TEST_CHECK(true); // We expect an assert
438 int UtcDaliWindowSetInputRegionNegative(void)
440 Dali::Window instance;
443 Dali::Rect<int> arg1;
444 instance.SetInputRegion(arg1);
445 DALI_TEST_CHECK(false); // Should not get here
449 DALI_TEST_CHECK(true); // We expect an assert
454 int UtcDaliWindowSetOpaqueStateNegative(void)
456 Dali::Window instance;
460 instance.SetOpaqueState(arg1);
461 DALI_TEST_CHECK(false); // Should not get here
465 DALI_TEST_CHECK(true); // We expect an assert
470 int UtcDaliWindowSetTransparencyNegative(void)
472 Dali::Window instance;
476 instance.SetTransparency(arg1);
477 DALI_TEST_CHECK(false); // Should not get here
481 DALI_TEST_CHECK(true); // We expect an assert
486 int UtcDaliWindowAddAuxiliaryHintNegative(void)
488 Dali::Window instance;
493 instance.AddAuxiliaryHint(arg1, arg2);
494 DALI_TEST_CHECK(false); // Should not get here
498 DALI_TEST_CHECK(true); // We expect an assert
503 int UtcDaliWindowSetScreenOffModeNegative(void)
505 Dali::Window instance;
508 Dali::WindowScreenOffMode arg1(Dali::WindowScreenOffMode::NEVER);
509 instance.SetScreenOffMode(arg1);
510 DALI_TEST_CHECK(false); // Should not get here
514 DALI_TEST_CHECK(true); // We expect an assert
519 int UtcDaliWindowFocusChangeSignalNegative(void)
521 Dali::Window instance;
524 instance.FocusChangeSignal();
525 DALI_TEST_CHECK(false); // Should not get here
529 DALI_TEST_CHECK(true); // We expect an assert
534 int UtcDaliWindowGetRenderTaskListNegative(void)
536 Dali::Window instance;
539 instance.GetRenderTaskList();
540 DALI_TEST_CHECK(false); // Should not get here
544 DALI_TEST_CHECK(true); // We expect an assert
549 int UtcDaliWindowSetBackgroundColorNegative(void)
551 Dali::Window instance;
555 instance.SetBackgroundColor(arg1);
556 DALI_TEST_CHECK(false); // Should not get here
560 DALI_TEST_CHECK(true); // We expect an assert
565 int UtcDaliWindowRemoveAuxiliaryHintNegative(void)
567 Dali::Window instance;
570 unsigned int arg1(0u);
571 instance.RemoveAuxiliaryHint(arg1);
572 DALI_TEST_CHECK(false); // Should not get here
576 DALI_TEST_CHECK(true); // We expect an assert
581 int UtcDaliWindowSetNotificationLevelNegative(void)
583 Dali::Window instance;
586 Dali::WindowNotificationLevel arg1(Dali::WindowNotificationLevel::NONE);
587 instance.SetNotificationLevel(arg1);
588 DALI_TEST_CHECK(false); // Should not get here
592 DALI_TEST_CHECK(true); // We expect an assert
597 int UtcDaliWindowSetAuxiliaryHintValueNegative(void)
599 Dali::Window instance;
602 unsigned int arg1(0u);
604 instance.SetAuxiliaryHintValue(arg1, arg2);
605 DALI_TEST_CHECK(false); // Should not get here
609 DALI_TEST_CHECK(true); // We expect an assert
614 int UtcDaliWindowAddAvailableOrientationNegative(void)
616 Dali::Window instance;
619 Dali::WindowOrientation arg1(Dali::WindowOrientation::PORTRAIT);
620 instance.AddAvailableOrientation(arg1);
621 DALI_TEST_CHECK(false); // Should not get here
625 DALI_TEST_CHECK(true); // We expect an assert
630 int UtcDaliWindowGetPreferredOrientationNegative(void)
632 Dali::Window instance;
635 instance.GetPreferredOrientation();
636 DALI_TEST_CHECK(false); // Should not get here
640 DALI_TEST_CHECK(true); // We expect an assert
645 int UtcDaliWindowSetPreferredOrientationNegative(void)
647 Dali::Window instance;
650 Dali::WindowOrientation arg1(Dali::WindowOrientation::PORTRAIT);
651 instance.SetPreferredOrientation(arg1);
652 DALI_TEST_CHECK(false); // Should not get here
656 DALI_TEST_CHECK(true); // We expect an assert
661 int UtcDaliWindowRemoveAvailableOrientationNegative(void)
663 Dali::Window instance;
666 Dali::WindowOrientation arg1(Dali::WindowOrientation::PORTRAIT);
667 instance.RemoveAvailableOrientation(arg1);
668 DALI_TEST_CHECK(false); // Should not get here
672 DALI_TEST_CHECK(true); // We expect an assert
677 int UtcDaliWindowAddNegative(void)
679 Dali::Window instance;
684 DALI_TEST_CHECK(false); // Should not get here
688 DALI_TEST_CHECK(true); // We expect an assert
693 int UtcDaliWindowHideNegative(void)
695 Dali::Window instance;
699 DALI_TEST_CHECK(false); // Should not get here
703 DALI_TEST_CHECK(true); // We expect an assert
708 int UtcDaliWindowShowNegative(void)
710 Dali::Window instance;
714 DALI_TEST_CHECK(false); // Should not get here
718 DALI_TEST_CHECK(true); // We expect an assert
723 int UtcDaliWindowLowerNegative(void)
725 Dali::Window instance;
729 DALI_TEST_CHECK(false); // Should not get here
733 DALI_TEST_CHECK(true); // We expect an assert
738 int UtcDaliWindowRaiseNegative(void)
740 Dali::Window instance;
744 DALI_TEST_CHECK(false); // Should not get here
748 DALI_TEST_CHECK(true); // We expect an assert
753 int UtcDaliWindowRemoveNegative(void)
755 Dali::Window instance;
759 instance.Remove(arg1);
760 DALI_TEST_CHECK(false); // Should not get here
764 DALI_TEST_CHECK(true); // We expect an assert
769 int UtcDaliWindowSetSizeNegative(void)
771 Dali::Window instance;
774 Dali::Uint16Pair arg1;
775 instance.SetSize(arg1);
776 DALI_TEST_CHECK(false); // Should not get here
780 DALI_TEST_CHECK(true); // We expect an assert
785 int UtcDaliWindowSetTypeNegative(void)
787 Dali::Window instance;
790 Dali::WindowType arg1(Dali::WindowType::NORMAL);
791 instance.SetType(arg1);
792 DALI_TEST_CHECK(false); // Should not get here
796 DALI_TEST_CHECK(true); // We expect an assert
801 int UtcDaliWindowActivateNegative(void)
803 Dali::Window instance;
807 DALI_TEST_CHECK(false); // Should not get here
811 DALI_TEST_CHECK(true); // We expect an assert
816 int UtcDaliWindowSetClassNegative(void)
818 Dali::Window instance;
823 instance.SetClass(arg1, arg2);
824 DALI_TEST_CHECK(false); // Should not get here
828 DALI_TEST_CHECK(true); // We expect an assert
833 int UtcDaliWindowGetPositionNegative(void)
835 Dali::Window instance;
838 instance.GetPosition();
839 DALI_TEST_CHECK(false); // Should not get here
843 DALI_TEST_CHECK(true); // We expect an assert
848 int UtcDaliWindowGetRootLayerNegative(void)
850 Dali::Window instance;
853 instance.GetRootLayer();
854 DALI_TEST_CHECK(false); // Should not get here
858 DALI_TEST_CHECK(true); // We expect an assert
863 int UtcDaliWindowGetBrightnessNegative(void)
865 Dali::Window instance;
868 instance.GetBrightness();
869 DALI_TEST_CHECK(false); // Should not get here
873 DALI_TEST_CHECK(true); // We expect an assert
878 int UtcDaliWindowGetLayerCountNegative(void)
880 Dali::Window instance;
883 instance.GetLayerCount();
884 DALI_TEST_CHECK(false); // Should not get here
888 DALI_TEST_CHECK(true); // We expect an assert
893 int UtcDaliWindowIsOpaqueStateNegative(void)
895 Dali::Window instance;
898 instance.IsOpaqueState();
899 DALI_TEST_CHECK(false); // Should not get here
903 DALI_TEST_CHECK(true); // We expect an assert
908 int UtcDaliWindowGetNativeHandleNegative(void)
910 Dali::Window instance;
913 instance.GetNativeHandle();
914 DALI_TEST_CHECK(false); // Should not get here
918 DALI_TEST_CHECK(true); // We expect an assert
923 int UtcDaliWindowGetScreenOffModeNegative(void)
925 Dali::Window instance;
928 instance.GetScreenOffMode();
929 DALI_TEST_CHECK(false); // Should not get here
933 DALI_TEST_CHECK(true); // We expect an assert
938 int UtcDaliWindowIsFocusAcceptableNegative(void)
940 Dali::Window instance;
943 instance.IsFocusAcceptable();
944 DALI_TEST_CHECK(false); // Should not get here
948 DALI_TEST_CHECK(true); // We expect an assert
953 int UtcDaliWindowGetAuxiliaryHintIdNegative(void)
955 Dali::Window instance;
959 instance.GetAuxiliaryHintId(arg1);
960 DALI_TEST_CHECK(false); // Should not get here
964 DALI_TEST_CHECK(true); // We expect an assert
969 int UtcDaliWindowGetBackgroundColorNegative(void)
971 Dali::Window instance;
974 instance.GetBackgroundColor();
975 DALI_TEST_CHECK(false); // Should not get here
979 DALI_TEST_CHECK(true); // We expect an assert
984 int UtcDaliWindowGetNotificationLevelNegative(void)
986 Dali::Window instance;
989 instance.GetNotificationLevel();
990 DALI_TEST_CHECK(false); // Should not get here
994 DALI_TEST_CHECK(true); // We expect an assert
999 int UtcDaliWindowGetAuxiliaryHintValueNegative(void)
1001 Dali::Window instance;
1004 unsigned int arg1(0u);
1005 instance.GetAuxiliaryHintValue(arg1);
1006 DALI_TEST_CHECK(false); // Should not get here
1010 DALI_TEST_CHECK(true); // We expect an assert
1015 int UtcDaliWindowGetSupportedAuxiliaryHintNegative(void)
1017 Dali::Window instance;
1020 unsigned int arg1(0u);
1021 instance.GetSupportedAuxiliaryHint(arg1);
1022 DALI_TEST_CHECK(false); // Should not get here
1026 DALI_TEST_CHECK(true); // We expect an assert
1031 int UtcDaliWindowGetSupportedAuxiliaryHintCountNegative(void)
1033 Dali::Window instance;
1036 instance.GetSupportedAuxiliaryHintCount();
1037 DALI_TEST_CHECK(false); // Should not get here
1041 DALI_TEST_CHECK(true); // We expect an assert
1046 int UtcDaliWindowGetDpiNegative(void)
1048 Dali::Window instance;
1052 DALI_TEST_CHECK(false); // Should not get here
1056 DALI_TEST_CHECK(true); // We expect an assert
1061 int UtcDaliWindowGetSizeNegative(void)
1063 Dali::Window instance;
1067 DALI_TEST_CHECK(false); // Should not get here
1071 DALI_TEST_CHECK(true); // We expect an assert
1076 int UtcDaliWindowGetTypeNegative(void)
1078 Dali::Window instance;
1082 DALI_TEST_CHECK(false); // Should not get here
1086 DALI_TEST_CHECK(true); // We expect an assert
1091 int UtcDaliWindowGetLayerNegative(void)
1093 Dali::Window instance;
1096 unsigned int arg1(0u);
1097 instance.GetLayer(arg1);
1098 DALI_TEST_CHECK(false); // Should not get here
1102 DALI_TEST_CHECK(true); // We expect an assert
1107 int UtcDaliWindowIsVisibleNegative(void)
1109 Dali::Window instance;
1112 instance.IsVisible();
1113 DALI_TEST_CHECK(false); // Should not get here
1117 DALI_TEST_CHECK(true); // We expect an assert
1122 int UtcDaliWindowGetNativeIdNegative(void)
1127 DevelWindow::GetNativeId(arg1);
1128 DALI_TEST_CHECK(false); // Should not get here
1132 DALI_TEST_CHECK(true); // We expect an assert
1137 int UtcDaliWindowSetPositionSizeNegative(void)
1142 Dali::Rect<int> arg2;
1143 DevelWindow::SetPositionSize(arg1, arg2);
1144 DALI_TEST_CHECK(false); // Should not get here
1148 DALI_TEST_CHECK(true); // We expect an assert
1153 int UtcDaliWindowWheelEventSignalNegative(void)
1158 DevelWindow::WheelEventSignal(arg1);
1159 DALI_TEST_CHECK(false); // Should not get here
1163 DALI_TEST_CHECK(true); // We expect an assert
1168 int UtcDaliWindowGetCurrentOrientationNegative(void)
1173 DevelWindow::GetCurrentOrientation(arg1);
1174 DALI_TEST_CHECK(false); // Should not get here
1178 DALI_TEST_CHECK(true); // We expect an assert
1183 int UtcDaliWindowGetPhysicalOrientationNegative(void)
1188 DevelWindow::GetPhysicalOrientation(arg1);
1189 DALI_TEST_CHECK(false); // Should not get here
1193 DALI_TEST_CHECK(true); // We expect an assert
1198 int UtcDaliWindowVisibilityChangedSignalNegative(void)
1203 DevelWindow::VisibilityChangedSignal(arg1);
1204 DALI_TEST_CHECK(false); // Should not get here
1208 DALI_TEST_CHECK(true); // We expect an assert
1213 int UtcDaliWindowAddFrameRenderedCallbackNegative(void)
1218 std::unique_ptr<Dali::CallbackBase> arg2;
1220 DevelWindow::AddFrameRenderedCallback(arg1, std::move(arg2), arg3);
1221 DALI_TEST_CHECK(false); // Should not get here
1225 DALI_TEST_CHECK(true); // We expect an assert
1230 int UtcDaliWindowSetAvailableOrientationsNegative(void)
1235 Dali::Vector<Dali::WindowOrientation> arg2;
1236 DevelWindow::SetAvailableOrientations(arg1, arg2);
1237 DALI_TEST_CHECK(false); // Should not get here
1241 DALI_TEST_CHECK(true); // We expect an assert
1246 int UtcDaliWindowAddFramePresentedCallbackNegative(void)
1251 std::unique_ptr<Dali::CallbackBase> arg2;
1253 DevelWindow::AddFramePresentedCallback(arg1, std::move(arg2), arg3);
1254 DALI_TEST_CHECK(false); // Should not get here
1258 DALI_TEST_CHECK(true); // We expect an assert
1263 int UtcDaliWindowTransitionEffectEventSignalNegative(void)
1268 DevelWindow::TransitionEffectEventSignal(arg1);
1269 DALI_TEST_CHECK(false); // Should not get here
1273 DALI_TEST_CHECK(true); // We expect an assert
1278 int UtcDaliWindowEventProcessingFinishedSignalNegative(void)
1283 DevelWindow::EventProcessingFinishedSignal(arg1);
1284 DALI_TEST_CHECK(false); // Should not get here
1288 DALI_TEST_CHECK(true); // We expect an assert
1293 int UtcDaliWindowKeyboardRepeatSettingsChangedSignalNegative(void)
1298 DevelWindow::KeyboardRepeatSettingsChangedSignal(arg1);
1299 DALI_TEST_CHECK(false); // Should not get here
1303 DALI_TEST_CHECK(true); // We expect an assert
1308 int UtcDaliWindowUnparentNegative(void)
1313 DevelWindow::Unparent(arg1);
1314 DALI_TEST_CHECK(false); // Should not get here
1318 DALI_TEST_CHECK(true); // We expect an assert
1323 int UtcDaliWindowGetParentNegative(void)
1328 DevelWindow::GetParent(arg1);
1329 DALI_TEST_CHECK(false); // Should not get here
1333 DALI_TEST_CHECK(true); // We expect an assert
1338 int UtcDaliWindowSetParentNegative(void)
1344 DevelWindow::SetParent(arg1, arg2);
1345 DALI_TEST_CHECK(false); // Should not get here
1349 DALI_TEST_CHECK(true); // We expect an assert
1354 int UtcDaliWindowAddInputRegion(void)
1356 Dali::Window instance;
1359 Rect<int> includedInputRegion(0,0,720,640);
1360 DevelWindow::IncludeInputRegion(instance, includedInputRegion);
1361 DALI_TEST_CHECK(false); // Should not get here
1365 DALI_TEST_CHECK(true); // We expect an assert
1370 int UtcDaliWindowSubtractInputRegion(void)
1372 Dali::Window instance;
1375 Rect<int> includedInputRegion(0,0,720,1280);
1376 DevelWindow::IncludeInputRegion(instance, includedInputRegion);
1378 Rect<int> excludedInputRegion(0,641,720,640);
1379 DevelWindow::ExcludeInputRegion(instance, excludedInputRegion);
1381 DALI_TEST_CHECK(false); // Should not get here
1385 DALI_TEST_CHECK(true); // We expect an assert