2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include <dali-toolkit-test-suite-utils.h>
22 #include <dali-toolkit/dali-toolkit.h>
23 #include <dali-toolkit/devel-api/controls/effects-view/effects-view.h>
26 using namespace Toolkit;
28 void dali_effectsview_startup(void)
30 test_return_value = TET_UNDEF;
33 void dali_effectsview_cleanup(void)
35 test_return_value = TET_PASS;
38 int UtcDaliEffectsViewNew(void)
40 ToolkitTestApplication application;
43 DALI_TEST_CHECK( !view );
45 view = EffectsView::New();
46 DALI_TEST_CHECK( view );
48 Stage::GetCurrent().Add( view );
50 application.SendNotification();
56 int UtcDaliEffectsViewCopyAndAssignment(void)
58 ToolkitTestApplication application;
60 EffectsView view = EffectsView::New();
61 DALI_TEST_CHECK( view );
63 EffectsView copy( view );
64 DALI_TEST_CHECK( copy == view );
67 DALI_TEST_CHECK( !assign );
69 DALI_TEST_CHECK( assign == view );
73 DALI_TEST_CHECK( assign );
74 DALI_TEST_CHECK( assign == view );
79 int UtcDaliEffectsViewDownCast(void)
81 ToolkitTestApplication application;
83 BaseHandle view = EffectsView::New();
84 DALI_TEST_CHECK( EffectsView::DownCast( view ) );
87 DALI_TEST_CHECK( ! EffectsView::DownCast( empty ) );
89 BaseHandle another = Actor::New();
90 DALI_TEST_CHECK( ! EffectsView::DownCast( another ) );
95 int UtcDaliEffectsViewSetGetTypeP(void)
97 ToolkitTestApplication application;
99 EffectsView view = EffectsView::New();
100 DALI_TEST_CHECK( view.GetType() == EffectsView::INVALID_TYPE );
102 view.SetType( EffectsView::DROP_SHADOW );
103 DALI_TEST_CHECK( view.GetType() == EffectsView::DROP_SHADOW );
105 view.SetType( EffectsView::EMBOSS );
106 DALI_TEST_CHECK( view.GetType() == EffectsView::EMBOSS );
111 int UtcDaliEffectsViewSetTypeN(void)
113 ToolkitTestApplication application;
118 view.SetType( EffectsView::DROP_SHADOW );
119 DALI_TEST_CHECK( false ); // Should not get here
123 DALI_TEST_CHECK( true );
129 int UtcDaliEffectsViewGetTypeN(void)
131 ToolkitTestApplication application;
136 EffectsView::EffectType type = view.GetType();
138 DALI_TEST_CHECK( false ); // Should not get here
142 DALI_TEST_CHECK( true );
148 int UtcDaliEffectsViewEnableP(void)
150 ToolkitTestApplication application;
152 EffectsView view = EffectsView::New();
153 Stage stage = Stage::GetCurrent();
154 DALI_TEST_CHECK( stage.GetRenderTaskList().GetTaskCount() == 1 );
157 DALI_TEST_CHECK( stage.GetRenderTaskList().GetTaskCount() > 1 );
162 int UtcDaliEffectsViewEnableN(void)
164 ToolkitTestApplication application;
170 DALI_TEST_CHECK( false ); // Should not get here
174 DALI_TEST_CHECK( true );
180 int UtcDaliEffectsViewDisableP(void)
182 ToolkitTestApplication application;
184 EffectsView view = EffectsView::New();
185 Stage stage = Stage::GetCurrent();
186 DALI_TEST_CHECK( stage.GetRenderTaskList().GetTaskCount() == 1 );
189 DALI_TEST_CHECK( stage.GetRenderTaskList().GetTaskCount() > 1 );
192 DALI_TEST_CHECK( stage.GetRenderTaskList().GetTaskCount() == 1 );
197 int UtcDaliEffectsViewDisableN(void)
199 ToolkitTestApplication application;
205 DALI_TEST_CHECK( false ); // Should not get here
209 DALI_TEST_CHECK( true );
215 int UtcDaliEffectsViewRefreshP(void)
217 ToolkitTestApplication application;
219 EffectsView view = EffectsView::New();
223 DALI_TEST_CHECK( true );
227 DALI_TEST_CHECK( false ); // Should not get here!
233 int UtcDaliEffectsViewRefreshN(void)
235 ToolkitTestApplication application;
241 DALI_TEST_CHECK( false ); // Should not get here
245 DALI_TEST_CHECK( true );
251 int UtcDaliEffectsViewSetPixelFormatP(void)
253 ToolkitTestApplication application;
255 EffectsView view = EffectsView::New();
258 view.SetPixelFormat( Pixel::RGBA8888 );
259 DALI_TEST_CHECK( true );
263 DALI_TEST_CHECK( false ); // Should not get here!
269 int UtcDaliEffectsViewSetPixelFormatN(void)
271 ToolkitTestApplication application;
276 view.SetPixelFormat( Pixel::RGBA8888 );
277 DALI_TEST_CHECK( false ); // Should not get here
281 DALI_TEST_CHECK( true );
287 int UtcDaliEffectsViewSetGetOutputImage(void)
289 ToolkitTestApplication application;
291 EffectsView view = EffectsView::New();
292 FrameBufferImage image = FrameBufferImage::New();
293 DALI_TEST_CHECK( image );
295 view.SetOutputImage( image );
296 DALI_TEST_CHECK( view.GetOutputImage() == image );
298 // Replace with another image
299 FrameBufferImage image2 = FrameBufferImage::New();
300 DALI_TEST_CHECK( image2 );
301 view.SetOutputImage( image2 );
302 DALI_TEST_CHECK( view.GetOutputImage() == image2 );
304 // Remove output image
305 view.SetOutputImage( FrameBufferImage() );
306 DALI_TEST_CHECK( ! view.GetOutputImage() );
311 int UtcDaliEffectsViewSetOutputImageN(void)
313 ToolkitTestApplication application;
318 view.SetOutputImage( FrameBufferImage::New() );
319 DALI_TEST_CHECK( false ); // Should not get here
323 DALI_TEST_CHECK( true );
329 int UtcDaliEffectsViewGetOutputImageN(void)
331 ToolkitTestApplication application;
336 FrameBufferImage image = view.GetOutputImage();
338 DALI_TEST_CHECK( false ); // Should not get here
342 DALI_TEST_CHECK( true );
348 int UtcDaliEffectsViewGetEffectSizePropertyIndexP(void)
350 ToolkitTestApplication application;
352 EffectsView view = EffectsView::New();
353 DALI_TEST_CHECK( Property::INVALID_INDEX != view.GetEffectSizePropertyIndex() );
358 int UtcDaliEffectsViewGetEffectSizePropertyIndexN(void)
360 ToolkitTestApplication application;
365 Property::Index index = view.GetEffectSizePropertyIndex();
367 DALI_TEST_CHECK( false ); // Should not get here
371 DALI_TEST_CHECK( true );
377 int UtcDaliEffectsViewGetEffectStrengthPropertyIndexP(void)
379 ToolkitTestApplication application;
381 EffectsView view = EffectsView::New();
382 DALI_TEST_CHECK( Property::INVALID_INDEX != view.GetEffectStrengthPropertyIndex() );
387 int UtcDaliEffectsViewGetEffectStrengthPropertyIndexN(void)
389 ToolkitTestApplication application;
394 Property::Index index = view.GetEffectStrengthPropertyIndex();
396 DALI_TEST_CHECK( false ); // Should not get here
400 DALI_TEST_CHECK( true );
406 int UtcDaliEffectsViewGetEffectOffsetPropertyIndexP(void)
408 ToolkitTestApplication application;
410 EffectsView view = EffectsView::New();
411 DALI_TEST_CHECK( Property::INVALID_INDEX != view.GetEffectOffsetPropertyIndex() );
416 int UtcDaliEffectsViewGetEffectOffsetPropertyIndexN(void)
418 ToolkitTestApplication application;
423 Property::Index index = view.GetEffectOffsetPropertyIndex();
425 DALI_TEST_CHECK( false ); // Should not get here
429 DALI_TEST_CHECK( true );
435 int UtcDaliEffectsViewGetEffectColorPropertyIndexP(void)
437 ToolkitTestApplication application;
439 EffectsView view = EffectsView::New();
440 DALI_TEST_CHECK( Property::INVALID_INDEX != view.GetEffectColorPropertyIndex() );
445 int UtcDaliEffectsViewGetEffectColorPropertyIndexN(void)
447 ToolkitTestApplication application;
452 Property::Index index = view.GetEffectColorPropertyIndex();
454 DALI_TEST_CHECK( false ); // Should not get here
458 DALI_TEST_CHECK( true );
464 int UtcDaliEffectsViewGetSetBackgroundColor(void)
466 ToolkitTestApplication application;
468 EffectsView view = EffectsView::New();
469 view.SetBackgroundColor( Color::RED );
470 DALI_TEST_CHECK( Color::RED == view.GetBackgroundColor() );
472 view.SetBackgroundColor( Color::YELLOW );
473 DALI_TEST_CHECK( Color::YELLOW == view.GetBackgroundColor() );
478 int UtcDaliEffectsViewSetBackgroundColorN(void)
480 ToolkitTestApplication application;
485 view.SetBackgroundColor( Color::RED );
486 DALI_TEST_CHECK( false ); // Should not get here
490 DALI_TEST_CHECK( true );
496 int UtcDaliEffectsViewGetBackgroundColorN(void)
498 ToolkitTestApplication application;
503 Vector4 color = view.GetBackgroundColor();
505 DALI_TEST_CHECK( false ); // Should not get here
509 DALI_TEST_CHECK( true );
515 int UtcDaliEffectsViewSetRefreshOnDemandP(void)
517 ToolkitTestApplication application;
519 EffectsView view = EffectsView::New();
520 FrameBufferImage image = FrameBufferImage::New();
521 view.SetOutputImage( image );
524 Stage stage = Stage::GetCurrent();
527 RenderTaskList renderTaskList = stage.GetRenderTaskList();
528 DALI_TEST_CHECK( renderTaskList.GetTask( 1 ).GetRefreshRate() == RenderTask::REFRESH_ALWAYS );
529 DALI_TEST_CHECK( renderTaskList.GetTask( 2 ).GetRefreshRate() == RenderTask::REFRESH_ALWAYS );
531 view.SetRefreshOnDemand( true );
532 DALI_TEST_CHECK( renderTaskList.GetTask( 1 ).GetRefreshRate() == RenderTask::REFRESH_ONCE );
533 DALI_TEST_CHECK( renderTaskList.GetTask( 2 ).GetRefreshRate() == RenderTask::REFRESH_ONCE );
535 view.SetRefreshOnDemand( false );
536 DALI_TEST_CHECK( renderTaskList.GetTask( 1 ).GetRefreshRate() == RenderTask::REFRESH_ALWAYS );
537 DALI_TEST_CHECK( renderTaskList.GetTask( 2 ).GetRefreshRate() == RenderTask::REFRESH_ALWAYS );
542 int UtcDaliEffectsViewSetRefreshOnDemandN(void)
544 ToolkitTestApplication application;
549 view.SetRefreshOnDemand( false );
550 DALI_TEST_CHECK( false ); // Should not get here
554 DALI_TEST_CHECK( true );
560 int UtcDaliEffectsViewSizeSet(void)
562 ToolkitTestApplication application;
563 Stage stage = Stage::GetCurrent();
566 EffectsView view = EffectsView::New();
567 view.SetSize( 200.0f, 200.0f, 0.0f );
570 application.SendNotification();
571 application.Render();
573 application.SendNotification();
574 application.Render();
576 DALI_TEST_EQUALS( view.GetCurrentSize(), Vector3( 200.0f, 200.0f, 0.0f ), TEST_LOCATION );
580 EffectsView view = EffectsView::New();
581 view.SetOutputImage( FrameBufferImage::New( 200, 200 ) );
582 view.SetType( EffectsView::EMBOSS );
583 view.SetSize( 200.0f, 200.0f, 0.0f );
585 application.SendNotification();
586 application.Render();
588 DALI_TEST_EQUALS( view.GetCurrentSize(), Vector3( 200.0f, 200.0f, 0.0f ), TEST_LOCATION );
592 EffectsView view = EffectsView::New();
593 view.SetType( EffectsView::DROP_SHADOW );
594 view.SetSize( 200.0f, 200.0f, 0.0f );
596 application.SendNotification();
597 application.Render();
599 stage.Remove( view );
600 application.SendNotification();
601 application.Render();
603 DALI_TEST_EQUALS( view.GetCurrentSize(), Vector3( 200.0f, 200.0f, 0.0f ), TEST_LOCATION );
609 int UtcDaliEffectsViewTypeRegistry(void)
611 ToolkitTestApplication application;
613 TypeRegistry typeRegistry = TypeRegistry::Get();
614 DALI_TEST_CHECK( typeRegistry );
616 TypeInfo typeInfo = typeRegistry.GetTypeInfo( "EffectsView" );
617 DALI_TEST_CHECK( typeInfo );
619 BaseHandle handle = typeInfo.CreateInstance();
620 DALI_TEST_CHECK( handle );
622 EffectsView view = EffectsView::DownCast( handle );
623 DALI_TEST_CHECK( view );