Dali 3D User Interface Engine
utc-Dali-Application.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 <dali-test-suite-utils.h>
20 
21 using namespace Dali;
22 
24 {
26 }
27 
29 {
31 }
32 
33 namespace
34 {
35 
37 {
39  : initCalled( false ),
40  application( app )
41  {
42  application.InitSignal().Connect( this, &MyTestApp::Create );
43  }
44 
45  void Create(Application& app)
46  {
47  initCalled = true;
48  }
49 
50  void Quit()
51  {
52  application.Quit();
53  }
54 
55  // Data
56  bool initCalled;
58 };
59 
61 {
62 }
63 
65 {
66 }
67 
68 } // unnamed namespace
69 
71 {
72  Application application = Application::New();
73 
74  MyTestApp testApp( application );
75 
76  DALI_TEST_CHECK( application );
77 
78  END_TEST;
79 }
80 
82 {
83  int argc( 1 );
84  const char* argList[1] = { "program" };
85  char** argv = const_cast<char**>(argList);
86 
87  Application application = Application::New( &argc, &argv );
88 
89  MyTestApp testApp( application );
90 
91  DALI_TEST_CHECK( application );
92 
93  END_TEST;
94 }
95 
97 {
98  int argc( 1 );
99  const char* argList[1] = { "program" };
100  char** argv = const_cast<char**>(argList);
101 
102  Application application = Application::New( &argc, &argv, "stylesheet" );
103 
104  MyTestApp testApp( application );
105 
106  DALI_TEST_CHECK( application );
107 
108  END_TEST;
109 }
110 
112 {
113  int argc( 1 );
114  const char* argList[1] = { "program" };
115  char** argv = const_cast<char**>(argList);
116 
117  Application application = Application::New( &argc, &argv, "stylesheet", Application::TRANSPARENT );
118 
119  MyTestApp testApp( application );
120 
121  DALI_TEST_CHECK( application );
122 
123  END_TEST;
124 }
125 
127 {
128  Application application = Application::New();
129  Application copy( application );
130  DALI_TEST_CHECK( copy == application );
131 
132  Application assigned;
133  DALI_TEST_CHECK( !assigned );
134  assigned = application;
135  DALI_TEST_CHECK( copy == assigned );
136 
137  END_TEST;
138 }
139 
141 {
142  Application application;
143 
144  try
145  {
146  application.MainLoop();
147  DALI_TEST_CHECK( false ); // Should not get here
148  }
149  catch( ... )
150  {
151  DALI_TEST_CHECK( true );
152  }
153 
154  END_TEST;
155 }
156 
158 {
159  Application application;
160 
161  try
162  {
164  DALI_TEST_CHECK( false ); // Should not get here
165  }
166  catch( ... )
167  {
168  DALI_TEST_CHECK( true );
169  }
170 
171  END_TEST;
172 }
173 
175 {
176  Application application;
177 
178  try
179  {
180  application.Lower();
181  DALI_TEST_CHECK( false ); // Should not get here
182  }
183  catch( ... )
184  {
185  DALI_TEST_CHECK( true );
186  }
187 
188  END_TEST;
189 }
190 
192 {
193  Application application;
194 
195  try
196  {
197  application.Quit();
198  DALI_TEST_CHECK( false ); // Should not get here
199  }
200  catch( ... )
201  {
202  DALI_TEST_CHECK( true );
203  }
204 
205  END_TEST;
206 }
207 
209 {
210  Application application;
211 
212  try
213  {
214  CallbackBase* callback = NULL;
215  application.AddIdle( callback );
216  DALI_TEST_CHECK( false ); // Should not get here
217  }
218  catch( ... )
219  {
220  DALI_TEST_CHECK( true );
221  }
222 
223  END_TEST;
224 }
225 
227 {
228  Application application;
229 
230  try
231  {
232  (void) application.GetWindow();
233  DALI_TEST_CHECK( false ); // Should not get here
234  }
235  catch( ... )
236  {
237  DALI_TEST_CHECK( true );
238  }
239 
240  END_TEST;
241 }
242 
244 {
245  Application application;
246 
247  try
248  {
249  application.ReplaceWindow( PositionSize(), "window" );
250  DALI_TEST_CHECK( false ); // Should not get here
251  }
252  catch( ... )
253  {
254  DALI_TEST_CHECK( true );
255  }
256 
257  END_TEST;
258 }
259 
261 {
262  Application application;
263 
264  try
265  {
266  application.SetViewMode( STEREO_VERTICAL );
267  DALI_TEST_CHECK( false ); // Should not get here
268  }
269  catch( ... )
270  {
271  DALI_TEST_CHECK( true );
272  }
273 
274  END_TEST;
275 }
276 
278 {
279  Application application;
280 
281  try
282  {
283  (void) application.GetViewMode();
284  DALI_TEST_CHECK( false ); // Should not get here
285  }
286  catch( ... )
287  {
288  DALI_TEST_CHECK( true );
289  }
290 
291  END_TEST;
292 }
293 
295 {
296  Application application;
297 
298  try
299  {
300  application.SetStereoBase( 1.0f );
301  DALI_TEST_CHECK( false ); // Should not get here
302  }
303  catch( ... )
304  {
305  DALI_TEST_CHECK( true );
306  }
307 
308  END_TEST;
309 }
310 
312 {
313  Application application;
314 
315  try
316  {
317  (void) application.GetStereoBase();
318  DALI_TEST_CHECK( false ); // Should not get here
319  }
320  catch( ... )
321  {
322  DALI_TEST_CHECK( true );
323  }
324 
325  END_TEST;
326 }
327 
329 {
330  Application application = Application::New();
331  application.InitSignal().Connect( &ApplicationSignalCallback );
332  DALI_TEST_CHECK( application );
333 
334  END_TEST;
335 }
336 
338 {
339  Application application;
340 
341  try
342  {
343  application.InitSignal().Connect( &ApplicationSignalCallback );
344  DALI_TEST_CHECK( false ); // Should not get here
345  }
346  catch( ... )
347  {
348  DALI_TEST_CHECK( true );
349  }
350 
351  END_TEST;
352 }
353 
355 {
356  Application application = Application::New();
357  application.TerminateSignal().Connect( &ApplicationSignalCallback );
358  DALI_TEST_CHECK( application );
359 
360  END_TEST;
361 }
362 
364 {
365  Application application;
366 
367  try
368  {
369  application.TerminateSignal().Connect( &ApplicationSignalCallback );
370  DALI_TEST_CHECK( false ); // Should not get here
371  }
372  catch( ... )
373  {
374  DALI_TEST_CHECK( true );
375  }
376 
377  END_TEST;
378 }
379 
381 {
382  Application application = Application::New();
383  application.PauseSignal().Connect( &ApplicationSignalCallback );
384  DALI_TEST_CHECK( application );
385 
386  END_TEST;
387 }
388 
390 {
391  Application application;
392 
393  try
394  {
395  application.PauseSignal().Connect( &ApplicationSignalCallback );
396  DALI_TEST_CHECK( false ); // Should not get here
397  }
398  catch( ... )
399  {
400  DALI_TEST_CHECK( true );
401  }
402 
403  END_TEST;
404 }
405 
407 {
408  Application application = Application::New();
409  application.ResumeSignal().Connect( &ApplicationSignalCallback );
410  DALI_TEST_CHECK( application );
411 
412  END_TEST;
413 }
414 
416 {
417  Application application;
418 
419  try
420  {
421  application.ResumeSignal().Connect( &ApplicationSignalCallback );
422  DALI_TEST_CHECK( false ); // Should not get here
423  }
424  catch( ... )
425  {
426  DALI_TEST_CHECK( true );
427  }
428 
429  END_TEST;
430 }
431 
433 {
434  Application application = Application::New();
435  application.ResetSignal().Connect( &ApplicationSignalCallback );
436  DALI_TEST_CHECK( application );
437 
438  END_TEST;
439 }
440 
442 {
443  Application application;
444 
445  try
446  {
447  application.ResetSignal().Connect( &ApplicationSignalCallback );
448  DALI_TEST_CHECK( false ); // Should not get here
449  }
450  catch( ... )
451  {
452  DALI_TEST_CHECK( true );
453  }
454 
455  END_TEST;
456 }
457 
459 {
460  Application application = Application::New();
461  application.ResizeSignal().Connect( &ApplicationSignalCallback );
462  DALI_TEST_CHECK( application );
463 
464  END_TEST;
465 }
466 
468 {
469  Application application;
470 
471  try
472  {
473  application.ResizeSignal().Connect( &ApplicationSignalCallback );
474  DALI_TEST_CHECK( false ); // Should not get here
475  }
476  catch( ... )
477  {
478  DALI_TEST_CHECK( true );
479  }
480 
481  END_TEST;
482 }
483 
485 {
486  Application application = Application::New();
487  application.AppControlSignal().Connect( &ApplicationControlSignalCallback );
488  DALI_TEST_CHECK( application );
489 
490  END_TEST;
491 }
492 
494 {
495  Application application;
496 
497  try
498  {
499  application.AppControlSignal().Connect( &ApplicationControlSignalCallback );
500  DALI_TEST_CHECK( false ); // Should not get here
501  }
502  catch( ... )
503  {
504  DALI_TEST_CHECK( true );
505  }
506 
507  END_TEST;
508 }
509 
511 {
512  Application application = Application::New();
513  application.LanguageChangedSignal().Connect( &ApplicationSignalCallback );
514  DALI_TEST_CHECK( application );
515 
516  END_TEST;
517 }
518 
520 {
521  Application application;
522 
523  try
524  {
525  application.LanguageChangedSignal().Connect( &ApplicationSignalCallback );
526  DALI_TEST_CHECK( false ); // Should not get here
527  }
528  catch( ... )
529  {
530  DALI_TEST_CHECK( true );
531  }
532 
533  END_TEST;
534 }
535 
537 {
538  Application application = Application::New();
539  application.RegionChangedSignal().Connect( &ApplicationSignalCallback );
540  DALI_TEST_CHECK( application );
541 
542  END_TEST;
543 }
544 
546 {
547  Application application;
548 
549  try
550  {
551  application.RegionChangedSignal().Connect( &ApplicationSignalCallback );
552  DALI_TEST_CHECK( false ); // Should not get here
553  }
554  catch( ... )
555  {
556  DALI_TEST_CHECK( true );
557  }
558 
559  END_TEST;
560 }
561 
563 {
564  Application application = Application::New();
565  application.BatteryLowSignal().Connect( &ApplicationSignalCallback );
566  DALI_TEST_CHECK( application );
567 
568  END_TEST;
569 }
570 
572 {
573  Application application;
574 
575  try
576  {
577  application.BatteryLowSignal().Connect( &ApplicationSignalCallback );
578  DALI_TEST_CHECK( false ); // Should not get here
579  }
580  catch( ... )
581  {
582  DALI_TEST_CHECK( true );
583  }
584 
585  END_TEST;
586 }
587 
589 {
590  Application application = Application::New();
591  application.MemoryLowSignal().Connect( &ApplicationSignalCallback );
592  DALI_TEST_CHECK( application );
593 
594  END_TEST;
595 }
596 
598 {
599  Application application;
600 
601  try
602  {
603  application.MemoryLowSignal().Connect( &ApplicationSignalCallback );
604  DALI_TEST_CHECK( false ); // Should not get here
605  }
606  catch( ... )
607  {
608  DALI_TEST_CHECK( true );
609  }
610 
611  END_TEST;
612 }
Dali Docs Home
Read more about Dali