Dali 3D User Interface Engine
utc-Dali-Window.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 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 <Ecore_X.h>
20 #include <devel-api/adaptor-framework/drag-and-drop-detector.h>
21 #include <dali-test-suite-utils.h>
22 
23 using namespace Dali;
24 
26 {
28 }
29 
31 {
33 }
34 
35 namespace
36 {
37 
38 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 
40 } // unnamed namespace
41 
42 extern "C"
43 {
44 
45 Ecore_X_Screen* ecore_x_default_screen_get(void)
46 {
47  screenId += 8;
48  return (Ecore_X_Screen*)screenId;
49 }
50 
51 void ecore_x_screen_size_get(const Ecore_X_Screen *screen, int *w, int *h)
52 {
53  *w = 100;
54  *h = 100;
55 }
56 
57 Ecore_X_Window ecore_x_window_argb_new(Ecore_X_Window parent, int x, int y, int w, int h)
58 {
59  return 0;
60 }
61 
62 }
63 
65 {
66  Dali::Window window;
67  DALI_TEST_CHECK( !window );
68  END_TEST;
69 }
70 
72 {
73  Dali::Window window;
74  Dali::Window copy( window );
75  DALI_TEST_CHECK( copy == window );
76 
77  END_TEST;
78 }
79 
81 {
82  Internal::Adaptor::Window* internalWindow = NULL;
83  Dali::Window window(internalWindow);
84  DALI_TEST_CHECK( !window ); // Should not reach here!
85 
86  END_TEST;
87 }
88 
90 {
91  const Dali::Window window;
92  Dali::Window copy;
93  DALI_TEST_CHECK( ! copy );
94  copy = window;
95  DALI_TEST_CHECK( copy == window );
96 
97  END_TEST;
98 }
99 
101 {
102  Dali::Window* window = new Dali::Window();
103  delete window;
104 
105  DALI_TEST_CHECK( true );
106  END_TEST;
107 }
108 
110 {
111  // Attempt to create a new window
112  try
113  {
114  PositionSize windowPosition(0, 0, 0, 0);
115  Dali::Window window = Dali::Window::New( windowPosition, "test-window", true );
116 
117  tet_result( TET_FAIL );
118  }
119  catch ( DaliException& e )
120  {
121  DALI_TEST_ASSERT( e, "Failed to create X window", TEST_LOCATION );
122  }
123 
124  // Attempt to create a new window
125  try
126  {
127  PositionSize windowPosition(0, 0, 0, 0);
128  Dali::Window window = Dali::Window::New( windowPosition, "test-window", "test-window-class", true );
129 
130  tet_result( TET_FAIL );
131  }
132  catch ( DaliException& e )
133  {
134  DALI_TEST_ASSERT( e, "Failed to create X window", TEST_LOCATION );
135  }
136 
137  END_TEST;
138 }
139 
141 {
142  Dali::Window window;
143  try
144  {
146  DALI_TEST_CHECK( false ); // Should not reach here!
147  }
148  catch( ... )
149  {
150  DALI_TEST_CHECK( true );
151  }
152 
153  END_TEST;
154 }
155 
157 {
158  Dali::Window window;
159  try
160  {
162  DALI_TEST_CHECK( false ); // Should not reach here!
163  }
164  catch( ... )
165  {
166  DALI_TEST_CHECK( true );
167  }
168 
169  END_TEST;
170 }
171 
173 {
174  Dali::Window window;
175  try
176  {
178  DALI_TEST_CHECK( false ); // Should not reach here!
179  }
180  catch( ... )
181  {
182  DALI_TEST_CHECK( true );
183  }
184 
185  END_TEST;
186 }
187 
189 {
190  Dali::Window window;
191  try
192  {
193  window.SetClass("window-name", "window-class");
194  DALI_TEST_CHECK( false ); // Should not reach here!
195  }
196  catch( ... )
197  {
198  DALI_TEST_CHECK( true );
199  }
200 
201  END_TEST;
202 }
203 
205 {
206  Dali::Window window;
207  try
208  {
209  window.Raise();
210  DALI_TEST_CHECK( false ); // Should not reach here!
211  }
212  catch( ... )
213  {
214  DALI_TEST_CHECK( true );
215  }
216 
217  END_TEST;
218 }
219 
221 {
222  Dali::Window window;
223  try
224  {
225  window.Lower();
226  DALI_TEST_CHECK( false ); // Should not reach here!
227  }
228  catch( ... )
229  {
230  DALI_TEST_CHECK( true );
231  }
232 
233  END_TEST;
234 }
235 
237 {
238  Dali::Window window;
239  try
240  {
241  window.Activate();
242  DALI_TEST_CHECK( false ); // Should not reach here!
243  }
244  catch( ... )
245  {
246  DALI_TEST_CHECK( true );
247  }
248 
249  END_TEST;
250 }
251 
253 {
254  Dali::Window window;
255  try
256  {
258  DALI_TEST_CHECK( false ); // Should not reach here!
259  }
260  catch( ... )
261  {
262  DALI_TEST_CHECK( true );
263  }
264 
265  END_TEST;
266 }
267 
269 {
270  Dali::Window window;
271  try
272  {
274  DALI_TEST_CHECK( false ); // Should not reach here!
275  }
276  catch( ... )
277  {
278  DALI_TEST_CHECK( true );
279  }
280 
281  END_TEST;
282 }
283 
285 {
286  Dali::Window window;
287  try
288  {
290  DALI_TEST_CHECK( false ); // Should not reach here!
291  }
292  catch( ... )
293  {
294  DALI_TEST_CHECK( true );
295  }
296 
297  END_TEST;
298 }
299 
301 {
302  Dali::Window window;
303  try
304  {
306  DALI_TEST_CHECK( orientation == Dali::Window::PORTRAIT ); // Should not reach here!
307  }
308  catch( ... )
309  {
310  DALI_TEST_CHECK( true );
311  }
312 
313  END_TEST;
314 }
315 
317 {
318  Dali::Window window;
319  try
320  {
321  DragAndDropDetector detector = window.GetDragAndDropDetector();
322  DALI_TEST_CHECK( !detector ); // Should not reach here!
323  }
324  catch( ... )
325  {
326  DALI_TEST_CHECK( true );
327  }
328 
329  END_TEST;
330 }
331 
333 {
334  Dali::Window window;
335  try
336  {
337  Dali::Any handle = window.GetNativeHandle();
338  DALI_TEST_CHECK( false ); // Should not reach here!
339  }
340  catch( ... )
341  {
342  DALI_TEST_CHECK( true );
343  }
344 
345  END_TEST;
346 }
347 
349 {
350  Dali::Window window;
351  try
352  {
354  DALI_TEST_CHECK( false ); // Should not reach here!
355  }
356  catch( ... )
357  {
358  DALI_TEST_CHECK( true );
359  }
360 
361  END_TEST;
362 }
363 
364 
365 
366 
Dali Docs Home
Read more about Dali