Update UTC for Window
[platform/core/uifw/dali-adaptor.git] / automated-tests / src / dali-adaptor / utc-Dali-Window.cpp
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
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 class Internal::Adaptor::Window;
39
40 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
41
42 } // unnamed namespace
43
44 extern "C"
45 {
46
47 Ecore_X_Screen* ecore_x_default_screen_get(void)
48 {
49   screenId += 8;
50   return (Ecore_X_Screen*)screenId;
51 }
52
53 void ecore_x_screen_size_get(const Ecore_X_Screen *screen, int *w, int *h)
54 {
55  *w = 100;
56  *h = 100;
57 }
58
59 Ecore_X_Window ecore_x_window_argb_new(Ecore_X_Window parent, int x, int y, int w, int h)
60 {
61   return 0;
62 }
63
64 }
65
66 int UtcDaliWindowConstructorP(void)
67 {
68   Dali::Window window;
69   DALI_TEST_CHECK( !window );
70   END_TEST;
71 }
72
73 int UtcDaliWindowCopyConstructorP(void)
74 {
75   Dali::Window window;
76   Dali::Window copy( window );
77   DALI_TEST_CHECK( copy == window );
78
79   END_TEST;
80 }
81
82 int UtcDaliWindowConstructorFromInternalPointerN(void)
83 {
84   Internal::Adaptor::Window* internalWindow = NULL;
85   Dali::Window window(internalWindow);
86   DALI_TEST_CHECK( !window ); // Should not reach here!
87
88   END_TEST;
89 }
90
91 int UtcDaliWindowAssignmentOperatorP(void)
92 {
93   const Dali::Window window;
94   Dali::Window copy;
95   DALI_TEST_CHECK( ! copy );
96   copy = window;
97   DALI_TEST_CHECK( copy == window );
98
99   END_TEST;
100 }
101
102 int UtcDaliWindowDestructorP(void)
103 {
104   Dali::Window* window = new Dali::Window();
105   delete window;
106
107   DALI_TEST_CHECK( true );
108   END_TEST;
109 }
110
111 int UtcDaliWindowNewN(void)
112 {
113   // Attempt to create a new window
114   try
115   {
116     PositionSize windowPosition(0, 0, 0, 0);
117     Dali::Window window = Dali::Window::New( windowPosition, "test-window", true );
118
119     tet_result( TET_FAIL );
120   }
121   catch ( DaliException& e )
122   {
123     DALI_TEST_ASSERT( e, "Failed to create X window", TEST_LOCATION );
124   }
125
126   END_TEST;
127 }
128
129 int UtcDaliWindowShowIndicatorN(void)
130 {
131   Dali::Window window;
132   try
133   {
134     window.ShowIndicator(Dali::Window::VISIBLE);
135     DALI_TEST_CHECK( false ); // Should not reach here!
136   }
137   catch( ... )
138   {
139     DALI_TEST_CHECK( true );
140   }
141
142   END_TEST;
143 }
144
145 int UtcDaliWindowSetIndicatorBgOpacityN(void)
146 {
147   Dali::Window window;
148   try
149   {
150     window.SetIndicatorBgOpacity(Dali::Window::OPAQUE);
151     DALI_TEST_CHECK( false ); // Should not reach here!
152   }
153   catch( ... )
154   {
155     DALI_TEST_CHECK( true );
156   }
157
158   END_TEST;
159 }
160
161 int UtcDaliWindowRotateIndicatorN(void)
162 {
163   Dali::Window window;
164   try
165   {
166     window.RotateIndicator(Dali::Window::PORTRAIT);
167     DALI_TEST_CHECK( false ); // Should not reach here!
168   }
169   catch( ... )
170   {
171     DALI_TEST_CHECK( true );
172   }
173
174   END_TEST;
175 }
176
177 int UtcDaliWindowSetClassN(void)
178 {
179   Dali::Window window;
180   try
181   {
182     window.SetClass("window-name", "window-class");
183     DALI_TEST_CHECK( false ); // Should not reach here!
184   }
185   catch( ... )
186   {
187     DALI_TEST_CHECK( true );
188   }
189
190   END_TEST;
191 }
192
193 int UtcDaliWindowRaiseN(void)
194 {
195   Dali::Window window;
196   try
197   {
198     window.Raise();
199     DALI_TEST_CHECK( false ); // Should not reach here!
200   }
201   catch( ... )
202   {
203     DALI_TEST_CHECK( true );
204   }
205
206   END_TEST;
207 }
208
209 int UtcDaliWindowLowerN(void)
210 {
211   Dali::Window window;
212   try
213   {
214     window.Lower();
215     DALI_TEST_CHECK( false ); // Should not reach here!
216   }
217   catch( ... )
218   {
219     DALI_TEST_CHECK( true );
220   }
221
222   END_TEST;
223 }
224
225 int UtcDaliWindowActivateN(void)
226 {
227   Dali::Window window;
228   try
229   {
230     window.Activate();
231     DALI_TEST_CHECK( false ); // Should not reach here!
232   }
233   catch( ... )
234   {
235     DALI_TEST_CHECK( true );
236   }
237
238   END_TEST;
239 }
240
241 int UtcDaliWindowAddAvailableOrientationN(void)
242 {
243   Dali::Window window;
244   try
245   {
246     window.AddAvailableOrientation(Dali::Window::PORTRAIT);
247     DALI_TEST_CHECK( false ); // Should not reach here!
248   }
249   catch( ... )
250   {
251     DALI_TEST_CHECK( true );
252   }
253
254   END_TEST;
255 }
256
257 int UtcDaliWindowRemoveAvailableOrientationN(void)
258 {
259   Dali::Window window;
260   try
261   {
262     window.RemoveAvailableOrientation(Dali::Window::PORTRAIT);
263     DALI_TEST_CHECK( false ); // Should not reach here!
264   }
265   catch( ... )
266   {
267     DALI_TEST_CHECK( true );
268   }
269
270   END_TEST;
271 }
272
273 int UtcDaliWindowSetPreferredOrientationN(void)
274 {
275   Dali::Window window;
276   try
277   {
278     window.SetPreferredOrientation(Dali::Window::PORTRAIT);
279     DALI_TEST_CHECK( false ); // Should not reach here!
280   }
281   catch( ... )
282   {
283     DALI_TEST_CHECK( true );
284   }
285
286   END_TEST;
287 }
288
289 int UtcDaliWindowGetPreferredOrientationN(void)
290 {
291   Dali::Window window;
292   try
293   {
294     Dali::Window::WindowOrientation orientation = window.GetPreferredOrientation();
295     DALI_TEST_CHECK( orientation == Dali::Window::PORTRAIT ); // Should not reach here!
296   }
297   catch( ... )
298   {
299     DALI_TEST_CHECK( true );
300   }
301
302   END_TEST;
303 }
304
305 int UtcDaliWindowGetDragAndDropDetectorN(void)
306 {
307   Dali::Window window;
308   try
309   {
310     DragAndDropDetector detector = window.GetDragAndDropDetector();
311     DALI_TEST_CHECK( !detector ); // Should not reach here!
312   }
313   catch( ... )
314   {
315     DALI_TEST_CHECK( true );
316   }
317
318   END_TEST;
319 }
320
321 int UtcDaliWindowGetNativeHandleN(void)
322 {
323   Dali::Window window;
324   try
325   {
326     Dali::Any handle = window.GetNativeHandle();
327     DALI_TEST_CHECK( false ); // Should not reach here!
328   }
329   catch( ... )
330   {
331     DALI_TEST_CHECK( true );
332   }
333
334   END_TEST;
335 }
336
337 int UtcDaliWindowIndicatorVisibilityChangedSignalN(void)
338 {
339   Dali::Window window;
340   try
341   {
342     window.IndicatorVisibilityChangedSignal();
343     DALI_TEST_CHECK( false ); // Should not reach here!
344   }
345   catch( ... )
346   {
347     DALI_TEST_CHECK( true );
348   }
349
350   END_TEST;
351 }
352
353
354
355