[dali_1.2.60] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / automated-tests / src / dali-adaptor / utc-Dali-Window.cpp
1 /*
2  * Copyright (c) 2017 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
25 void utc_dali_window_startup(void)
26 {
27   test_return_value = TET_UNDEF;
28 }
29
30 void utc_dali_window_cleanup(void)
31 {
32   test_return_value = TET_PASS;
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
64 int UtcDaliWindowConstructorP(void)
65 {
66   Dali::Window window;
67   DALI_TEST_CHECK( !window );
68   END_TEST;
69 }
70
71 int UtcDaliWindowCopyConstructorP(void)
72 {
73   Dali::Window window;
74   Dali::Window copy( window );
75   DALI_TEST_CHECK( copy == window );
76
77   END_TEST;
78 }
79
80 int UtcDaliWindowConstructorFromInternalPointerN(void)
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
89 int UtcDaliWindowAssignmentOperatorP(void)
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
100 int UtcDaliWindowDestructorP(void)
101 {
102   Dali::Window* window = new Dali::Window();
103   delete window;
104
105   DALI_TEST_CHECK( true );
106   END_TEST;
107 }
108
109 int UtcDaliWindowNewN(void)
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
140 int UtcDaliWindowShowIndicatorN(void)
141 {
142   Dali::Window window;
143   try
144   {
145     window.ShowIndicator(Dali::Window::VISIBLE);
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
156 int UtcDaliWindowSetIndicatorBgOpacityN(void)
157 {
158   Dali::Window window;
159   try
160   {
161     window.SetIndicatorBgOpacity(Dali::Window::OPAQUE);
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
172 int UtcDaliWindowRotateIndicatorN(void)
173 {
174   Dali::Window window;
175   try
176   {
177     window.RotateIndicator(Dali::Window::PORTRAIT);
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
188 int UtcDaliWindowSetClassN(void)
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
204 int UtcDaliWindowRaiseN(void)
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
220 int UtcDaliWindowLowerN(void)
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
236 int UtcDaliWindowActivateN(void)
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
252 int UtcDaliWindowAddAvailableOrientationN(void)
253 {
254   Dali::Window window;
255   try
256   {
257     window.AddAvailableOrientation(Dali::Window::PORTRAIT);
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
268 int UtcDaliWindowRemoveAvailableOrientationN(void)
269 {
270   Dali::Window window;
271   try
272   {
273     window.RemoveAvailableOrientation(Dali::Window::PORTRAIT);
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
284 int UtcDaliWindowSetPreferredOrientationN(void)
285 {
286   Dali::Window window;
287   try
288   {
289     window.SetPreferredOrientation(Dali::Window::PORTRAIT);
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
300 int UtcDaliWindowGetPreferredOrientationN(void)
301 {
302   Dali::Window window;
303   try
304   {
305     Dali::Window::WindowOrientation orientation = window.GetPreferredOrientation();
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
316 int UtcDaliWindowGetDragAndDropDetectorN(void)
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
332 int UtcDaliWindowGetNativeHandleN(void)
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
348 int UtcDaliWindowSetAcceptFocusN(void)
349 {
350   Dali::Window window;
351   try
352   {
353     window.SetAcceptFocus( true );
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 int UtcDaliWindowIsFocusAcceptableN(void)
365 {
366   Dali::Window window;
367   try
368   {
369     window.IsFocusAcceptable();
370     DALI_TEST_CHECK( false ); // Should not reach here!
371   }
372   catch( ... )
373   {
374     DALI_TEST_CHECK( true );
375   }
376
377   END_TEST;
378 }
379
380 int UtcDaliWindowIndicatorVisibilityChangedSignalN(void)
381 {
382   Dali::Window window;
383   try
384   {
385     window.IndicatorVisibilityChangedSignal();
386     DALI_TEST_CHECK( false ); // Should not reach here!
387   }
388   catch( ... )
389   {
390     DALI_TEST_CHECK( true );
391   }
392
393   END_TEST;
394 }
395
396 int UtcDaliWindowFocusChangedSignalN(void)
397 {
398   Dali::Window window;
399   try
400   {
401     window.FocusChangedSignal();
402     DALI_TEST_CHECK( false ); // Should not reach here!
403   }
404   catch( ... )
405   {
406     DALI_TEST_CHECK( true );
407   }
408
409   END_TEST;
410 }