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/window-devel.h>
20 #include <dali/internal/system/linux/dali-ecore-x.h>
21 #include <dali-test-suite-utils.h>
25 class DragAndDropDetector : public BaseHandle {}; // For UtcDaliWindowGetDragAndDropDetectorN
30 void utc_dali_window_startup(void)
32 test_return_value = TET_UNDEF;
35 void utc_dali_window_cleanup(void)
37 test_return_value = TET_PASS;
43 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
45 } // unnamed namespace
50 Ecore_X_Screen* ecore_x_default_screen_get(void)
53 return (Ecore_X_Screen*)screenId;
56 void ecore_x_screen_size_get(const Ecore_X_Screen *screen, int *w, int *h)
62 Ecore_X_Window ecore_x_window_argb_new(Ecore_X_Window parent, int x, int y, int w, int h)
69 int UtcDaliWindowConstructorP(void)
72 DALI_TEST_CHECK( !window );
76 int UtcDaliWindowCopyConstructorP(void)
79 Dali::Window copy( window );
80 DALI_TEST_CHECK( copy == window );
85 int UtcDaliWindowConstructorFromInternalPointerN(void)
87 Internal::Adaptor::Window* internalWindow = NULL;
88 Dali::Window window(internalWindow);
89 DALI_TEST_CHECK( !window ); // Should not reach here!
94 int UtcDaliWindowAssignmentOperatorP(void)
96 const Dali::Window window;
98 DALI_TEST_CHECK( ! copy );
100 DALI_TEST_CHECK( copy == window );
105 int UtcDaliWindowDestructorP(void)
107 Dali::Window* window = new Dali::Window();
110 DALI_TEST_CHECK( true );
114 int UtcDaliWindowNewN(void)
116 // Attempt to create a new window
119 PositionSize windowPosition(0, 0, 0, 0);
120 Dali::Window window = Dali::Window::New( windowPosition, "test-window", true );
122 tet_result( TET_FAIL );
124 catch ( DaliException& e )
126 DALI_TEST_ASSERT( e, "Failed to create X window", TEST_LOCATION );
129 // Attempt to create a new window
132 PositionSize windowPosition(0, 0, 0, 0);
133 Dali::Window window = Dali::Window::New( windowPosition, "test-window", "test-window-class", true );
135 tet_result( TET_FAIL );
137 catch ( DaliException& e )
139 DALI_TEST_ASSERT( e, "Failed to create X window", TEST_LOCATION );
145 int UtcDaliWindowShowIndicatorN(void)
150 window.ShowIndicator(Dali::Window::VISIBLE);
151 DALI_TEST_CHECK( false ); // Should not reach here!
155 DALI_TEST_CHECK( true );
161 int UtcDaliWindowSetIndicatorBgOpacityN(void)
166 window.SetIndicatorBgOpacity(Dali::Window::OPAQUE);
167 DALI_TEST_CHECK( false ); // Should not reach here!
171 DALI_TEST_CHECK( true );
177 int UtcDaliWindowRotateIndicatorN(void)
182 window.RotateIndicator(Dali::Window::PORTRAIT);
183 DALI_TEST_CHECK( false ); // Should not reach here!
187 DALI_TEST_CHECK( true );
193 int UtcDaliWindowSetClassN(void)
198 window.SetClass("window-name", "window-class");
199 DALI_TEST_CHECK( false ); // Should not reach here!
203 DALI_TEST_CHECK( true );
209 int UtcDaliWindowRaiseN(void)
215 DALI_TEST_CHECK( false ); // Should not reach here!
219 DALI_TEST_CHECK( true );
225 int UtcDaliWindowLowerN(void)
231 DALI_TEST_CHECK( false ); // Should not reach here!
235 DALI_TEST_CHECK( true );
241 int UtcDaliWindowActivateN(void)
247 DALI_TEST_CHECK( false ); // Should not reach here!
251 DALI_TEST_CHECK( true );
257 int UtcDaliWindowAddAvailableOrientationN(void)
262 window.AddAvailableOrientation(Dali::Window::PORTRAIT);
263 DALI_TEST_CHECK( false ); // Should not reach here!
267 DALI_TEST_CHECK( true );
273 int UtcDaliWindowRemoveAvailableOrientationN(void)
278 window.RemoveAvailableOrientation(Dali::Window::PORTRAIT);
279 DALI_TEST_CHECK( false ); // Should not reach here!
283 DALI_TEST_CHECK( true );
289 int UtcDaliWindowSetPreferredOrientationN(void)
294 window.SetPreferredOrientation(Dali::Window::PORTRAIT);
295 DALI_TEST_CHECK( false ); // Should not reach here!
299 DALI_TEST_CHECK( true );
305 int UtcDaliWindowGetPreferredOrientationN(void)
310 Dali::Window::WindowOrientation orientation = window.GetPreferredOrientation();
311 DALI_TEST_CHECK( orientation == Dali::Window::PORTRAIT ); // Should not reach here!
315 DALI_TEST_CHECK( true );
321 int UtcDaliWindowGetDragAndDropDetectorN(void)
326 DragAndDropDetector detector = window.GetDragAndDropDetector();
327 DALI_TEST_CHECK( !detector ); // Should not reach here!
331 DALI_TEST_CHECK( true );
337 int UtcDaliWindowGetNativeHandleN(void)
342 Dali::Any handle = window.GetNativeHandle();
343 DALI_TEST_CHECK( false ); // Should not reach here!
347 DALI_TEST_CHECK( true );
353 int UtcDaliWindowSetAcceptFocusN(void)
358 window.SetAcceptFocus( true );
359 DALI_TEST_CHECK( false ); // Should not reach here!
363 DALI_TEST_CHECK( true );
369 int UtcDaliWindowIsFocusAcceptableN(void)
374 window.IsFocusAcceptable();
375 DALI_TEST_CHECK( false ); // Should not reach here!
379 DALI_TEST_CHECK( true );
385 int UtcDaliWindowIndicatorVisibilityChangedSignalN(void)
390 window.IndicatorVisibilityChangedSignal();
391 DALI_TEST_CHECK( false ); // Should not reach here!
395 DALI_TEST_CHECK( true );
401 int UtcDaliWindowFocusChangedSignalN(void)
406 window.FocusChangedSignal();
407 DALI_TEST_CHECK( false ); // Should not reach here!
411 DALI_TEST_CHECK( true );
417 int UtcDaliWindowPartialUpdate(void)
422 std::vector<Rect<int>> damagedAreas;
423 DevelWindow::SetDamagedAreas(window, damagedAreas);
424 DALI_TEST_CHECK( false ); // Should not reach here!
428 DALI_TEST_CHECK( true );