From: Adeel Kazmi Date: Thu, 11 Jun 2015 15:21:04 +0000 (+0100) Subject: Added tests for EffectsView X-Git-Tag: dali_1.0.45~8 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=ea24e7f19288fcd3f6cc4807bb7c0263e0c77795 Added tests for EffectsView Change-Id: Ie9af9cfaa4906cf3bb5b7b85fefe6f6a6750536f --- diff --git a/automated-tests/src/dali-toolkit/CMakeLists.txt b/automated-tests/src/dali-toolkit/CMakeLists.txt index 523b97a..bc2bfb0 100644 --- a/automated-tests/src/dali-toolkit/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit/CMakeLists.txt @@ -18,6 +18,7 @@ SET(TC_SOURCES utc-Dali-CubeTransitionEffect.cpp utc-Dali-DisplacementEffect.cpp utc-Dali-DistanceFieldEffect.cpp + utc-Dali-EffectsView.cpp utc-Dali-GaussianBlurView.cpp utc-Dali-JsonParser.cpp utc-Dali-KeyInputFocusManager.cpp diff --git a/automated-tests/src/dali-toolkit/utc-Dali-EffectsView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-EffectsView.cpp new file mode 100644 index 0000000..dc1e25a --- /dev/null +++ b/automated-tests/src/dali-toolkit/utc-Dali-EffectsView.cpp @@ -0,0 +1,626 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include +#include +#include +#include +#include + +using namespace Dali; +using namespace Toolkit; + +void dali_effectsview_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void dali_effectsview_cleanup(void) +{ + test_return_value = TET_PASS; +} + +int UtcDaliEffectsViewNew(void) +{ + ToolkitTestApplication application; + + EffectsView view; + DALI_TEST_CHECK( !view ); + + view = EffectsView::New(); + DALI_TEST_CHECK( view ); + + Stage::GetCurrent().Add( view ); + + application.SendNotification(); + application.Render(); + + END_TEST; +} + +int UtcDaliEffectsViewCopyAndAssignment(void) +{ + ToolkitTestApplication application; + + EffectsView view = EffectsView::New(); + DALI_TEST_CHECK( view ); + + EffectsView copy( view ); + DALI_TEST_CHECK( copy == view ); + + EffectsView assign; + DALI_TEST_CHECK( !assign ); + assign = view; + DALI_TEST_CHECK( assign == view ); + + // Self assignment + assign = assign; + DALI_TEST_CHECK( assign ); + DALI_TEST_CHECK( assign == view ); + + END_TEST; +} + +int UtcDaliEffectsViewDownCast(void) +{ + ToolkitTestApplication application; + + BaseHandle view = EffectsView::New(); + DALI_TEST_CHECK( EffectsView::DownCast( view ) ); + + BaseHandle empty; + DALI_TEST_CHECK( ! EffectsView::DownCast( empty ) ); + + BaseHandle another = Actor::New(); + DALI_TEST_CHECK( ! EffectsView::DownCast( another ) ); + + END_TEST; +} + +int UtcDaliEffectsViewSetGetTypeP(void) +{ + ToolkitTestApplication application; + + EffectsView view = EffectsView::New(); + DALI_TEST_CHECK( view.GetType() == EffectsView::INVALID_TYPE ); + + view.SetType( EffectsView::DROP_SHADOW ); + DALI_TEST_CHECK( view.GetType() == EffectsView::DROP_SHADOW ); + + view.SetType( EffectsView::EMBOSS ); + DALI_TEST_CHECK( view.GetType() == EffectsView::EMBOSS ); + + END_TEST; +} + +int UtcDaliEffectsViewSetTypeN(void) +{ + ToolkitTestApplication application; + + EffectsView view; + try + { + view.SetType( EffectsView::DROP_SHADOW ); + DALI_TEST_CHECK( false ); // Should not get here + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + + END_TEST; +} + +int UtcDaliEffectsViewGetTypeN(void) +{ + ToolkitTestApplication application; + + EffectsView view; + try + { + EffectsView::EffectType type = view.GetType(); + (void) type; + DALI_TEST_CHECK( false ); // Should not get here + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + + END_TEST; +} + +int UtcDaliEffectsViewEnableP(void) +{ + ToolkitTestApplication application; + + EffectsView view = EffectsView::New(); + Stage stage = Stage::GetCurrent(); + DALI_TEST_CHECK( stage.GetRenderTaskList().GetTaskCount() == 1 ); + + view.Enable(); + DALI_TEST_CHECK( stage.GetRenderTaskList().GetTaskCount() > 1 ); + + END_TEST; +} + +int UtcDaliEffectsViewEnableN(void) +{ + ToolkitTestApplication application; + + EffectsView view; + try + { + view.Enable(); + DALI_TEST_CHECK( false ); // Should not get here + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + + END_TEST; +} + +int UtcDaliEffectsViewDisableP(void) +{ + ToolkitTestApplication application; + + EffectsView view = EffectsView::New(); + Stage stage = Stage::GetCurrent(); + DALI_TEST_CHECK( stage.GetRenderTaskList().GetTaskCount() == 1 ); + + view.Enable(); + DALI_TEST_CHECK( stage.GetRenderTaskList().GetTaskCount() > 1 ); + + view.Disable(); + DALI_TEST_CHECK( stage.GetRenderTaskList().GetTaskCount() == 1 ); + + END_TEST; +} + +int UtcDaliEffectsViewDisableN(void) +{ + ToolkitTestApplication application; + + EffectsView view; + try + { + view.Disable(); + DALI_TEST_CHECK( false ); // Should not get here + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + + END_TEST; +} + +int UtcDaliEffectsViewRefreshP(void) +{ + ToolkitTestApplication application; + + EffectsView view = EffectsView::New(); + try + { + view.Refresh(); + DALI_TEST_CHECK( true ); + } + catch( ... ) + { + DALI_TEST_CHECK( false ); // Should not get here! + } + + END_TEST; +} + +int UtcDaliEffectsViewRefreshN(void) +{ + ToolkitTestApplication application; + + EffectsView view; + try + { + view.Refresh(); + DALI_TEST_CHECK( false ); // Should not get here + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + + END_TEST; +} + +int UtcDaliEffectsViewSetPixelFormatP(void) +{ + ToolkitTestApplication application; + + EffectsView view = EffectsView::New(); + try + { + view.SetPixelFormat( Pixel::RGBA8888 ); + DALI_TEST_CHECK( true ); + } + catch( ... ) + { + DALI_TEST_CHECK( false ); // Should not get here! + } + + END_TEST; +} + +int UtcDaliEffectsViewSetPixelFormatN(void) +{ + ToolkitTestApplication application; + + EffectsView view; + try + { + view.SetPixelFormat( Pixel::RGBA8888 ); + DALI_TEST_CHECK( false ); // Should not get here + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + + END_TEST; +} + +int UtcDaliEffectsViewSetGetOutputImage(void) +{ + ToolkitTestApplication application; + + EffectsView view = EffectsView::New(); + FrameBufferImage image = FrameBufferImage::New(); + DALI_TEST_CHECK( image ); + + view.SetOutputImage( image ); + DALI_TEST_CHECK( view.GetOutputImage() == image ); + + // Replace with another image + FrameBufferImage image2 = FrameBufferImage::New(); + DALI_TEST_CHECK( image2 ); + view.SetOutputImage( image2 ); + DALI_TEST_CHECK( view.GetOutputImage() == image2 ); + + // Remove output image + view.SetOutputImage( FrameBufferImage() ); + DALI_TEST_CHECK( ! view.GetOutputImage() ); + + END_TEST; +} + +int UtcDaliEffectsViewSetOutputImageN(void) +{ + ToolkitTestApplication application; + + EffectsView view; + try + { + view.SetOutputImage( FrameBufferImage::New() ); + DALI_TEST_CHECK( false ); // Should not get here + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + + END_TEST; +} + +int UtcDaliEffectsViewGetOutputImageN(void) +{ + ToolkitTestApplication application; + + EffectsView view; + try + { + FrameBufferImage image = view.GetOutputImage(); + (void)image; + DALI_TEST_CHECK( false ); // Should not get here + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + + END_TEST; +} + +int UtcDaliEffectsViewGetEffectSizePropertyIndexP(void) +{ + ToolkitTestApplication application; + + EffectsView view = EffectsView::New(); + DALI_TEST_CHECK( Property::INVALID_INDEX != view.GetEffectSizePropertyIndex() ); + + END_TEST; +} + +int UtcDaliEffectsViewGetEffectSizePropertyIndexN(void) +{ + ToolkitTestApplication application; + + EffectsView view; + try + { + Property::Index index = view.GetEffectSizePropertyIndex(); + (void)index; + DALI_TEST_CHECK( false ); // Should not get here + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + + END_TEST; +} + +int UtcDaliEffectsViewGetEffectStrengthPropertyIndexP(void) +{ + ToolkitTestApplication application; + + EffectsView view = EffectsView::New(); + DALI_TEST_CHECK( Property::INVALID_INDEX != view.GetEffectStrengthPropertyIndex() ); + + END_TEST; +} + +int UtcDaliEffectsViewGetEffectStrengthPropertyIndexN(void) +{ + ToolkitTestApplication application; + + EffectsView view; + try + { + Property::Index index = view.GetEffectStrengthPropertyIndex(); + (void)index; + DALI_TEST_CHECK( false ); // Should not get here + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + + END_TEST; +} + +int UtcDaliEffectsViewGetEffectOffsetPropertyIndexP(void) +{ + ToolkitTestApplication application; + + EffectsView view = EffectsView::New(); + DALI_TEST_CHECK( Property::INVALID_INDEX != view.GetEffectOffsetPropertyIndex() ); + + END_TEST; +} + +int UtcDaliEffectsViewGetEffectOffsetPropertyIndexN(void) +{ + ToolkitTestApplication application; + + EffectsView view; + try + { + Property::Index index = view.GetEffectOffsetPropertyIndex(); + (void)index; + DALI_TEST_CHECK( false ); // Should not get here + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + + END_TEST; +} + +int UtcDaliEffectsViewGetEffectColorPropertyIndexP(void) +{ + ToolkitTestApplication application; + + EffectsView view = EffectsView::New(); + DALI_TEST_CHECK( Property::INVALID_INDEX != view.GetEffectColorPropertyIndex() ); + + END_TEST; +} + +int UtcDaliEffectsViewGetEffectColorPropertyIndexN(void) +{ + ToolkitTestApplication application; + + EffectsView view; + try + { + Property::Index index = view.GetEffectColorPropertyIndex(); + (void)index; + DALI_TEST_CHECK( false ); // Should not get here + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + + END_TEST; +} + +int UtcDaliEffectsViewGetSetBackgroundColor(void) +{ + ToolkitTestApplication application; + + EffectsView view = EffectsView::New(); + view.SetBackgroundColor( Color::RED ); + DALI_TEST_CHECK( Color::RED == view.GetBackgroundColor() ); + + view.SetBackgroundColor( Color::YELLOW ); + DALI_TEST_CHECK( Color::YELLOW == view.GetBackgroundColor() ); + + END_TEST; +} + +int UtcDaliEffectsViewSetBackgroundColorN(void) +{ + ToolkitTestApplication application; + + EffectsView view; + try + { + view.SetBackgroundColor( Color::RED ); + DALI_TEST_CHECK( false ); // Should not get here + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + + END_TEST; +} + +int UtcDaliEffectsViewGetBackgroundColorN(void) +{ + ToolkitTestApplication application; + + EffectsView view; + try + { + Vector4 color = view.GetBackgroundColor(); + (void)color; + DALI_TEST_CHECK( false ); // Should not get here + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + + END_TEST; +} + +int UtcDaliEffectsViewSetRefreshOnDemandP(void) +{ + ToolkitTestApplication application; + + EffectsView view = EffectsView::New(); + FrameBufferImage image = FrameBufferImage::New(); + view.SetOutputImage( image ); + view.Enable(); + + Stage stage = Stage::GetCurrent(); + stage.Add( view ); + + RenderTaskList renderTaskList = stage.GetRenderTaskList(); + DALI_TEST_CHECK( renderTaskList.GetTask( 1 ).GetRefreshRate() == RenderTask::REFRESH_ALWAYS ); + DALI_TEST_CHECK( renderTaskList.GetTask( 2 ).GetRefreshRate() == RenderTask::REFRESH_ALWAYS ); + + view.SetRefreshOnDemand( true ); + DALI_TEST_CHECK( renderTaskList.GetTask( 1 ).GetRefreshRate() == RenderTask::REFRESH_ONCE ); + DALI_TEST_CHECK( renderTaskList.GetTask( 2 ).GetRefreshRate() == RenderTask::REFRESH_ONCE ); + + view.SetRefreshOnDemand( false ); + DALI_TEST_CHECK( renderTaskList.GetTask( 1 ).GetRefreshRate() == RenderTask::REFRESH_ALWAYS ); + DALI_TEST_CHECK( renderTaskList.GetTask( 2 ).GetRefreshRate() == RenderTask::REFRESH_ALWAYS ); + + END_TEST; +} + +int UtcDaliEffectsViewSetRefreshOnDemandN(void) +{ + ToolkitTestApplication application; + + EffectsView view; + try + { + view.SetRefreshOnDemand( false ); + DALI_TEST_CHECK( false ); // Should not get here + } + catch( ... ) + { + DALI_TEST_CHECK( true ); + } + + END_TEST; +} + +int UtcDaliEffectsViewSizeSet(void) +{ + ToolkitTestApplication application; + Stage stage = Stage::GetCurrent(); + + { + EffectsView view = EffectsView::New(); + view.SetSize( 200.0f, 200.0f, 200.0f ); + stage.Add( view ); + view.Enable(); + application.SendNotification(); + application.Render(); + view.Disable(); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( view.GetCurrentSize(), Vector3( 200.0f, 200.0f, 200.0f ), TEST_LOCATION ); + } + + { + EffectsView view = EffectsView::New(); + view.SetOutputImage( FrameBufferImage::New( 200, 200 ) ); + view.SetType( EffectsView::EMBOSS ); + view.SetSize( 200.0f, 200.0f, 200.0f ); + stage.Add( view ); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( view.GetCurrentSize(), Vector3( 200.0f, 200.0f, 200.0f ), TEST_LOCATION ); + } + + { + EffectsView view = EffectsView::New(); + view.SetType( EffectsView::DROP_SHADOW ); + view.SetSize( 200.0f, 200.0f, 200.0f ); + stage.Add( view ); + application.SendNotification(); + application.Render(); + + stage.Remove( view ); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( view.GetCurrentSize(), Vector3( 200.0f, 200.0f, 200.0f ), TEST_LOCATION ); + } + + END_TEST; +} + +int UtcDaliEffectsViewTypeRegistry(void) +{ + ToolkitTestApplication application; + + TypeRegistry typeRegistry = TypeRegistry::Get(); + DALI_TEST_CHECK( typeRegistry ); + + TypeInfo typeInfo = typeRegistry.GetTypeInfo( "EffectsView" ); + DALI_TEST_CHECK( typeInfo ); + + BaseHandle handle = typeInfo.CreateInstance(); + DALI_TEST_CHECK( handle ); + + EffectsView view = EffectsView::DownCast( handle ); + DALI_TEST_CHECK( view ); + + END_TEST; +}