Dali 3D User Interface Engine
utc-Dali-EffectsView.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 <iostream>
19 #include <stdlib.h>
20 #include <sstream>
24 
25 using namespace Dali;
26 using namespace Toolkit;
27 
29 {
31 }
32 
34 {
36 }
37 
39 {
40  ToolkitTestApplication application;
41 
42  EffectsView view;
43  DALI_TEST_CHECK( !view );
44 
45  view = EffectsView::New();
46  DALI_TEST_CHECK( view );
47 
48  Stage::GetCurrent().Add( view );
49 
50  application.SendNotification();
51  application.Render();
52 
53  END_TEST;
54 }
55 
57 {
58  ToolkitTestApplication application;
59 
61  DALI_TEST_CHECK( view );
62 
63  EffectsView copy( view );
64  DALI_TEST_CHECK( copy == view );
65 
66  EffectsView assign;
67  DALI_TEST_CHECK( !assign );
68  assign = view;
69  DALI_TEST_CHECK( assign == view );
70 
71  // Self assignment
72  assign = assign;
73  DALI_TEST_CHECK( assign );
74  DALI_TEST_CHECK( assign == view );
75 
76  END_TEST;
77 }
78 
80 {
81  ToolkitTestApplication application;
82 
85 
86  BaseHandle empty;
88 
89  BaseHandle another = Actor::New();
90  DALI_TEST_CHECK( ! EffectsView::DownCast( another ) );
91 
92  END_TEST;
93 }
94 
96 {
97  ToolkitTestApplication application;
98 
101 
104 
107 
108  END_TEST;
109 }
110 
112 {
113  ToolkitTestApplication application;
114 
115  EffectsView view;
116  try
117  {
119  DALI_TEST_CHECK( false ); // Should not get here
120  }
121  catch( ... )
122  {
123  DALI_TEST_CHECK( true );
124  }
125 
126  END_TEST;
127 }
128 
130 {
131  ToolkitTestApplication application;
132 
133  EffectsView view;
134  try
135  {
136  EffectsView::EffectType type = view.GetType();
137  (void) type;
138  DALI_TEST_CHECK( false ); // Should not get here
139  }
140  catch( ... )
141  {
142  DALI_TEST_CHECK( true );
143  }
144 
145  END_TEST;
146 }
147 
149 {
150  ToolkitTestApplication application;
151 
152  EffectsView view = EffectsView::New();
153  Stage stage = Stage::GetCurrent();
155 
156  view.Enable();
158 
159  END_TEST;
160 }
161 
163 {
164  ToolkitTestApplication application;
165 
166  EffectsView view;
167  try
168  {
169  view.Enable();
170  DALI_TEST_CHECK( false ); // Should not get here
171  }
172  catch( ... )
173  {
174  DALI_TEST_CHECK( true );
175  }
176 
177  END_TEST;
178 }
179 
181 {
182  ToolkitTestApplication application;
183 
184  EffectsView view = EffectsView::New();
185  Stage stage = Stage::GetCurrent();
187 
188  view.Enable();
190 
191  view.Disable();
193 
194  END_TEST;
195 }
196 
198 {
199  ToolkitTestApplication application;
200 
201  EffectsView view;
202  try
203  {
204  view.Disable();
205  DALI_TEST_CHECK( false ); // Should not get here
206  }
207  catch( ... )
208  {
209  DALI_TEST_CHECK( true );
210  }
211 
212  END_TEST;
213 }
214 
216 {
217  ToolkitTestApplication application;
218 
219  EffectsView view = EffectsView::New();
220  try
221  {
222  view.Refresh();
223  DALI_TEST_CHECK( true );
224  }
225  catch( ... )
226  {
227  DALI_TEST_CHECK( false ); // Should not get here!
228  }
229 
230  END_TEST;
231 }
232 
234 {
235  ToolkitTestApplication application;
236 
237  EffectsView view;
238  try
239  {
240  view.Refresh();
241  DALI_TEST_CHECK( false ); // Should not get here
242  }
243  catch( ... )
244  {
245  DALI_TEST_CHECK( true );
246  }
247 
248  END_TEST;
249 }
250 
252 {
253  ToolkitTestApplication application;
254 
255  EffectsView view = EffectsView::New();
256  try
257  {
259  DALI_TEST_CHECK( true );
260  }
261  catch( ... )
262  {
263  DALI_TEST_CHECK( false ); // Should not get here!
264  }
265 
266  END_TEST;
267 }
268 
270 {
271  ToolkitTestApplication application;
272 
273  EffectsView view;
274  try
275  {
277  DALI_TEST_CHECK( false ); // Should not get here
278  }
279  catch( ... )
280  {
281  DALI_TEST_CHECK( true );
282  }
283 
284  END_TEST;
285 }
286 
288 {
289  ToolkitTestApplication application;
290 
291  EffectsView view = EffectsView::New();
293  DALI_TEST_CHECK( image );
294 
295  view.SetOutputImage( image );
296  DALI_TEST_CHECK( view.GetOutputImage() == image );
297 
298  // Replace with another image
300  DALI_TEST_CHECK( image2 );
301  view.SetOutputImage( image2 );
302  DALI_TEST_CHECK( view.GetOutputImage() == image2 );
303 
304  // Remove output image
306  DALI_TEST_CHECK( ! view.GetOutputImage() );
307 
308  END_TEST;
309 }
310 
312 {
313  ToolkitTestApplication application;
314 
315  EffectsView view;
316  try
317  {
319  DALI_TEST_CHECK( false ); // Should not get here
320  }
321  catch( ... )
322  {
323  DALI_TEST_CHECK( true );
324  }
325 
326  END_TEST;
327 }
328 
330 {
331  ToolkitTestApplication application;
332 
333  EffectsView view;
334  try
335  {
336  FrameBufferImage image = view.GetOutputImage();
337  (void)image;
338  DALI_TEST_CHECK( false ); // Should not get here
339  }
340  catch( ... )
341  {
342  DALI_TEST_CHECK( true );
343  }
344 
345  END_TEST;
346 }
347 
349 {
350  ToolkitTestApplication application;
351 
352  EffectsView view = EffectsView::New();
354 
355  END_TEST;
356 }
357 
359 {
360  ToolkitTestApplication application;
361 
362  EffectsView view;
363  try
364  {
366  (void)index;
367  DALI_TEST_CHECK( false ); // Should not get here
368  }
369  catch( ... )
370  {
371  DALI_TEST_CHECK( true );
372  }
373 
374  END_TEST;
375 }
376 
378 {
379  ToolkitTestApplication application;
380 
381  EffectsView view = EffectsView::New();
383 
384  END_TEST;
385 }
386 
388 {
389  ToolkitTestApplication application;
390 
391  EffectsView view;
392  try
393  {
395  (void)index;
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  ToolkitTestApplication application;
409 
410  EffectsView view = EffectsView::New();
412 
413  END_TEST;
414 }
415 
417 {
418  ToolkitTestApplication application;
419 
420  EffectsView view;
421  try
422  {
424  (void)index;
425  DALI_TEST_CHECK( false ); // Should not get here
426  }
427  catch( ... )
428  {
429  DALI_TEST_CHECK( true );
430  }
431 
432  END_TEST;
433 }
434 
436 {
437  ToolkitTestApplication application;
438 
439  EffectsView view = EffectsView::New();
441 
442  END_TEST;
443 }
444 
446 {
447  ToolkitTestApplication application;
448 
449  EffectsView view;
450  try
451  {
453  (void)index;
454  DALI_TEST_CHECK( false ); // Should not get here
455  }
456  catch( ... )
457  {
458  DALI_TEST_CHECK( true );
459  }
460 
461  END_TEST;
462 }
463 
465 {
466  ToolkitTestApplication application;
467 
468  EffectsView view = EffectsView::New();
471 
474 
475  END_TEST;
476 }
477 
479 {
480  ToolkitTestApplication application;
481 
482  EffectsView view;
483  try
484  {
486  DALI_TEST_CHECK( false ); // Should not get here
487  }
488  catch( ... )
489  {
490  DALI_TEST_CHECK( true );
491  }
492 
493  END_TEST;
494 }
495 
497 {
498  ToolkitTestApplication application;
499 
500  EffectsView view;
501  try
502  {
503  Vector4 color = view.GetBackgroundColor();
504  (void)color;
505  DALI_TEST_CHECK( false ); // Should not get here
506  }
507  catch( ... )
508  {
509  DALI_TEST_CHECK( true );
510  }
511 
512  END_TEST;
513 }
514 
516 {
517  ToolkitTestApplication application;
518 
519  EffectsView view = EffectsView::New();
521  view.SetOutputImage( image );
522  view.Enable();
523 
524  Stage stage = Stage::GetCurrent();
525  stage.Add( view );
526 
527  RenderTaskList renderTaskList = stage.GetRenderTaskList();
530 
531  view.SetRefreshOnDemand( true );
534 
535  view.SetRefreshOnDemand( false );
538 
539  END_TEST;
540 }
541 
543 {
544  ToolkitTestApplication application;
545 
546  EffectsView view;
547  try
548  {
549  view.SetRefreshOnDemand( false );
550  DALI_TEST_CHECK( false ); // Should not get here
551  }
552  catch( ... )
553  {
554  DALI_TEST_CHECK( true );
555  }
556 
557  END_TEST;
558 }
559 
561 {
562  ToolkitTestApplication application;
563  Stage stage = Stage::GetCurrent();
564 
565  {
566  EffectsView view = EffectsView::New();
567  view.SetSize( 200.0f, 200.0f, 0.0f );
568  stage.Add( view );
569  view.Enable();
570  application.SendNotification();
571  application.Render();
572  view.Disable();
573  application.SendNotification();
574  application.Render();
575 
576  DALI_TEST_EQUALS( view.GetCurrentSize(), Vector3( 200.0f, 200.0f, 0.0f ), TEST_LOCATION );
577  }
578 
579  {
580  EffectsView view = EffectsView::New();
581  view.SetOutputImage( FrameBufferImage::New( 200, 200 ) );
583  view.SetSize( 200.0f, 200.0f, 0.0f );
584  stage.Add( view );
585  application.SendNotification();
586  application.Render();
587 
588  DALI_TEST_EQUALS( view.GetCurrentSize(), Vector3( 200.0f, 200.0f, 0.0f ), TEST_LOCATION );
589  }
590 
591  {
592  EffectsView view = EffectsView::New();
594  view.SetSize( 200.0f, 200.0f, 0.0f );
595  stage.Add( view );
596  application.SendNotification();
597  application.Render();
598 
599  stage.Remove( view );
600  application.SendNotification();
601  application.Render();
602 
603  DALI_TEST_EQUALS( view.GetCurrentSize(), Vector3( 200.0f, 200.0f, 0.0f ), TEST_LOCATION );
604  }
605 
606  END_TEST;
607 }
608 
610 {
611  ToolkitTestApplication application;
612 
613  TypeRegistry typeRegistry = TypeRegistry::Get();
614  DALI_TEST_CHECK( typeRegistry );
615 
616  TypeInfo typeInfo = typeRegistry.GetTypeInfo( "EffectsView" );
617  DALI_TEST_CHECK( typeInfo );
618 
619  BaseHandle handle = typeInfo.CreateInstance();
620  DALI_TEST_CHECK( handle );
621 
622  EffectsView view = EffectsView::DownCast( handle );
623  DALI_TEST_CHECK( view );
624 
625  END_TEST;
626 }
Dali Docs Home
Read more about Dali