[dali_1.0.42] Merge branch 'tizen'
[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 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   END_TEST;
125 }
126
127 int UtcDaliWindowShowIndicatorN(void)
128 {
129   Dali::Window window;
130   try
131   {
132     window.ShowIndicator(Dali::Window::VISIBLE);
133     DALI_TEST_CHECK( false ); // Should not reach here!
134   }
135   catch( ... )
136   {
137     DALI_TEST_CHECK( true );
138   }
139
140   END_TEST;
141 }
142
143 int UtcDaliWindowSetIndicatorBgOpacityN(void)
144 {
145   Dali::Window window;
146   try
147   {
148     window.SetIndicatorBgOpacity(Dali::Window::OPAQUE);
149     DALI_TEST_CHECK( false ); // Should not reach here!
150   }
151   catch( ... )
152   {
153     DALI_TEST_CHECK( true );
154   }
155
156   END_TEST;
157 }
158
159 int UtcDaliWindowRotateIndicatorN(void)
160 {
161   Dali::Window window;
162   try
163   {
164     window.RotateIndicator(Dali::Window::PORTRAIT);
165     DALI_TEST_CHECK( false ); // Should not reach here!
166   }
167   catch( ... )
168   {
169     DALI_TEST_CHECK( true );
170   }
171
172   END_TEST;
173 }
174
175 int UtcDaliWindowSetClassN(void)
176 {
177   Dali::Window window;
178   try
179   {
180     window.SetClass("window-name", "window-class");
181     DALI_TEST_CHECK( false ); // Should not reach here!
182   }
183   catch( ... )
184   {
185     DALI_TEST_CHECK( true );
186   }
187
188   END_TEST;
189 }
190
191 int UtcDaliWindowRaiseN(void)
192 {
193   Dali::Window window;
194   try
195   {
196     window.Raise();
197     DALI_TEST_CHECK( false ); // Should not reach here!
198   }
199   catch( ... )
200   {
201     DALI_TEST_CHECK( true );
202   }
203
204   END_TEST;
205 }
206
207 int UtcDaliWindowLowerN(void)
208 {
209   Dali::Window window;
210   try
211   {
212     window.Lower();
213     DALI_TEST_CHECK( false ); // Should not reach here!
214   }
215   catch( ... )
216   {
217     DALI_TEST_CHECK( true );
218   }
219
220   END_TEST;
221 }
222
223 int UtcDaliWindowActivateN(void)
224 {
225   Dali::Window window;
226   try
227   {
228     window.Activate();
229     DALI_TEST_CHECK( false ); // Should not reach here!
230   }
231   catch( ... )
232   {
233     DALI_TEST_CHECK( true );
234   }
235
236   END_TEST;
237 }
238
239 int UtcDaliWindowAddAvailableOrientationN(void)
240 {
241   Dali::Window window;
242   try
243   {
244     window.AddAvailableOrientation(Dali::Window::PORTRAIT);
245     DALI_TEST_CHECK( false ); // Should not reach here!
246   }
247   catch( ... )
248   {
249     DALI_TEST_CHECK( true );
250   }
251
252   END_TEST;
253 }
254
255 int UtcDaliWindowRemoveAvailableOrientationN(void)
256 {
257   Dali::Window window;
258   try
259   {
260     window.RemoveAvailableOrientation(Dali::Window::PORTRAIT);
261     DALI_TEST_CHECK( false ); // Should not reach here!
262   }
263   catch( ... )
264   {
265     DALI_TEST_CHECK( true );
266   }
267
268   END_TEST;
269 }
270
271 int UtcDaliWindowSetPreferredOrientationN(void)
272 {
273   Dali::Window window;
274   try
275   {
276     window.SetPreferredOrientation(Dali::Window::PORTRAIT);
277     DALI_TEST_CHECK( false ); // Should not reach here!
278   }
279   catch( ... )
280   {
281     DALI_TEST_CHECK( true );
282   }
283
284   END_TEST;
285 }
286
287 int UtcDaliWindowGetPreferredOrientationN(void)
288 {
289   Dali::Window window;
290   try
291   {
292     Dali::Window::WindowOrientation orientation = window.GetPreferredOrientation();
293     DALI_TEST_CHECK( orientation == Dali::Window::PORTRAIT ); // Should not reach here!
294   }
295   catch( ... )
296   {
297     DALI_TEST_CHECK( true );
298   }
299
300   END_TEST;
301 }
302
303 int UtcDaliWindowGetDragAndDropDetectorN(void)
304 {
305   Dali::Window window;
306   try
307   {
308     DragAndDropDetector detector = window.GetDragAndDropDetector();
309     DALI_TEST_CHECK( !detector ); // Should not reach here!
310   }
311   catch( ... )
312   {
313     DALI_TEST_CHECK( true );
314   }
315
316   END_TEST;
317 }
318
319 int UtcDaliWindowGetNativeHandleN(void)
320 {
321   Dali::Window window;
322   try
323   {
324     Dali::Any handle = window.GetNativeHandle();
325     DALI_TEST_CHECK( false ); // Should not reach here!
326   }
327   catch( ... )
328   {
329     DALI_TEST_CHECK( true );
330   }
331
332   END_TEST;
333 }
334
335 int UtcDaliWindowIndicatorVisibilityChangedSignalN(void)
336 {
337   Dali::Window window;
338   try
339   {
340     window.IndicatorVisibilityChangedSignal();
341     DALI_TEST_CHECK( false ); // Should not reach here!
342   }
343   catch( ... )
344   {
345     DALI_TEST_CHECK( true );
346   }
347
348   END_TEST;
349 }
350
351
352
353