X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-Renderer.cpp;h=d1c81f61103cbd0c2b967e29179a3a7ed0a1e86d;hb=7dbf40bfe8bc0c503e94e3943553a697384d1a3c;hp=021349fd550d84cd7f816c009115dde86778643f;hpb=1c89ce2bcf0f628f3e6ecb230cad7adfe9267759;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/automated-tests/src/dali/utc-Dali-Renderer.cpp b/automated-tests/src/dali/utc-Dali-Renderer.cpp index 021349f..d1c81f6 100644 --- a/automated-tests/src/dali/utc-Dali-Renderer.cpp +++ b/automated-tests/src/dali/utc-Dali-Renderer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -17,9 +17,11 @@ // EXTERNAL INCLUDES #include +#include #include #include +#include #include #include @@ -88,7 +90,6 @@ void renderer_test_cleanup(void) test_return_value = TET_PASS; } - int UtcDaliRendererNew01(void) { TestApplication application; @@ -163,6 +164,85 @@ int UtcDaliRendererDownCast02(void) END_TEST; } +// using a template to auto deduce the parameter types +template< typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8> +void TEST_RENDERER_PROPERTY( P1 renderer, P2 stringName, P3 type, P4 isWriteable, P5 isAnimateable, P6 isConstraintInput, P7 enumName, P8 LOCATION ) +{ + DALI_TEST_EQUALS( renderer.GetPropertyName( enumName ), stringName, LOCATION ); + DALI_TEST_EQUALS( renderer.GetPropertyIndex( stringName ), static_cast(enumName), LOCATION ); + DALI_TEST_EQUALS( renderer.GetPropertyType( enumName ), type, LOCATION ); + DALI_TEST_EQUALS( renderer.IsPropertyWritable( enumName ), isWriteable, LOCATION ); + DALI_TEST_EQUALS( renderer.IsPropertyAnimatable( enumName ), isAnimateable, LOCATION ); + DALI_TEST_EQUALS( renderer.IsPropertyAConstraintInput( enumName ), isConstraintInput, LOCATION ); +} + +int UtcDaliRendererDefaultProperties(void) +{ + TestApplication application; +/* from renderer-impl.cpp + DALI_PROPERTY( "depthIndex", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_INDEX ) + DALI_PROPERTY( "faceCullingMode", INTEGER, true, false, false, Dali::Renderer::Property::FACE_CULLING_MODE ) + DALI_PROPERTY( "blendMode", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_MODE ) + DALI_PROPERTY( "blendEquationRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_EQUATION_RGB ) + DALI_PROPERTY( "blendEquationAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_EQUATION_ALPHA ) + DALI_PROPERTY( "blendFactorSrcRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB ) + DALI_PROPERTY( "blendFactorDestRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB ) + DALI_PROPERTY( "blendFactorSrcAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA ) + DALI_PROPERTY( "blendFactorDestAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA ) + DALI_PROPERTY( "blendColor", VECTOR4, true, false, false, Dali::Renderer::Property::BLEND_COLOR ) + DALI_PROPERTY( "blendPreMultipliedAlpha", BOOLEAN, true, false, false, Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA ) + DALI_PROPERTY( "indexRangeFirst", INTEGER, true, false, false, Dali::Renderer::Property::INDEX_RANGE_FIRST ) + DALI_PROPERTY( "indexRangeCount", INTEGER, true, false, false, Dali::Renderer::Property::INDEX_RANGE_COUNT ) + DALI_PROPERTY( "depthWriteMode", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_WRITE_MODE ) + DALI_PROPERTY( "depthFunction", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_FUNCTION ) + DALI_PROPERTY( "depthTestMode", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_TEST_MODE ) + DALI_PROPERTY( "renderMode", INTEGER, true, false, false, Dali::Renderer::Property::RENDER_MODE ) + DALI_PROPERTY( "stencilFunction", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION ) + DALI_PROPERTY( "stencilFunctionMask", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION_MASK ) + DALI_PROPERTY( "stencilFunctionReference", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE ) + DALI_PROPERTY( "stencilMask", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_MASK ) + DALI_PROPERTY( "stencilOperationOnFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL ) + DALI_PROPERTY( "stencilOperationOnZFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL ) + DALI_PROPERTY( "stencilOperationOnZPass", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS ) + DALI_PROPERTY( "opacity", FLOAT, true, true, true, Dali::DevelRenderer::Property::OPACITY ) + DALI_PROPERTY( "renderingBehavior", INTEGER, true, false, false, Dali::DevelRenderer::Property::RENDERING_BEHAVIOR ) +*/ + + Geometry geometry = CreateQuadGeometry(); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); + DALI_TEST_EQUALS( renderer.GetPropertyCount(), 26, TEST_LOCATION ); + + TEST_RENDERER_PROPERTY( renderer, "depthIndex", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_INDEX, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "faceCullingMode", Property::INTEGER, true, false, false, Renderer::Property::FACE_CULLING_MODE, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "blendMode", Property::INTEGER, true, false, false, Renderer::Property::BLEND_MODE, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "blendEquationRgb", Property::INTEGER, true, false, false, Renderer::Property::BLEND_EQUATION_RGB, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "blendEquationAlpha", Property::INTEGER, true, false, false, Renderer::Property::BLEND_EQUATION_ALPHA, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "blendFactorSrcRgb", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_SRC_RGB, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "blendFactorDestRgb", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_DEST_RGB, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "blendFactorSrcAlpha", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_SRC_ALPHA, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "blendFactorDestAlpha", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_DEST_ALPHA, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "blendColor", Property::VECTOR4, true, false, false, Renderer::Property::BLEND_COLOR, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "blendPreMultipliedAlpha", Property::BOOLEAN, true, false, false, Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "indexRangeFirst", Property::INTEGER, true, false, false, Renderer::Property::INDEX_RANGE_FIRST, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "indexRangeCount", Property::INTEGER, true, false, false, Renderer::Property::INDEX_RANGE_COUNT, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "depthWriteMode", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_WRITE_MODE, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "depthFunction", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_FUNCTION, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "depthTestMode", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_TEST_MODE, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "renderMode", Property::INTEGER, true, false, false, Renderer::Property::RENDER_MODE, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "stencilFunction", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_FUNCTION, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "stencilFunctionMask", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_FUNCTION_MASK, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "stencilFunctionReference",Property::INTEGER, true, false, false, Renderer::Property::STENCIL_FUNCTION_REFERENCE, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "stencilMask", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_MASK, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "stencilOperationOnFail", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_FAIL, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "stencilOperationOnZFail", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "stencilOperationOnZPass", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "opacity", Property::FLOAT, true, true, true, DevelRenderer::Property::OPACITY, TEST_LOCATION ); + TEST_RENDERER_PROPERTY( renderer, "renderingBehavior", Property::INTEGER, true, false, false, DevelRenderer::Property::RENDERING_BEHAVIOR, TEST_LOCATION ); + + END_TEST; +} + int UtcDaliRendererSetGetGeometry(void) { TestApplication application; @@ -259,15 +339,21 @@ int UtcDaliRendererSetGetDepthIndex(void) renderer.SetProperty( Renderer::Property::DEPTH_INDEX, 1 ); + DALI_TEST_EQUALS( renderer.GetProperty(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION ); + DALI_TEST_EQUALS( renderer.GetCurrentProperty(Renderer::Property::DEPTH_INDEX), 0, TEST_LOCATION ); + application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( renderer.GetProperty(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION ); + DALI_TEST_EQUALS( renderer.GetCurrentProperty(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION ); renderer.SetProperty( Renderer::Property::DEPTH_INDEX, 10 ); + DALI_TEST_EQUALS( renderer.GetProperty(Renderer::Property::DEPTH_INDEX), 10, TEST_LOCATION ); + DALI_TEST_EQUALS( renderer.GetCurrentProperty(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION ); + application.SendNotification(); application.Render(0); - DALI_TEST_EQUALS( renderer.GetProperty(Renderer::Property::DEPTH_INDEX), 10, TEST_LOCATION ); + DALI_TEST_EQUALS( renderer.GetCurrentProperty(Renderer::Property::DEPTH_INDEX), 10, TEST_LOCATION ); END_TEST; } @@ -550,6 +636,41 @@ int UtcDaliRendererSetBlendMode01(void) END_TEST; } +int UtcDaliRendererSetBlendMode01b(void) +{ + TestApplication application; + + tet_infoline("Test setting the blend mode to on with an transparent color renders with blending enabled"); + + Geometry geometry = CreateQuadGeometry(); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New( geometry, shader ); + + Actor actor = Actor::New(); + actor.SetOpacity( 0.0f ); + actor.AddRenderer(renderer); + actor.SetSize(400, 400); + Stage::GetCurrent().Add(actor); + + renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON); + + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + glAbstraction.EnableEnableDisableCallTrace(true); + glAbstraction.EnableDrawCallTrace( true ); + + application.SendNotification(); + application.Render(); + + TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace(); + std::ostringstream blendStr; + blendStr << GL_BLEND; + DALI_TEST_CHECK( !glEnableStack.FindMethod( "Enable" ) ); + + DALI_TEST_CHECK( !glAbstraction.GetDrawTrace().FindMethod( "DrawElements" ) ); + + END_TEST; +} + int UtcDaliRendererSetBlendMode02(void) { TestApplication application; @@ -856,13 +977,23 @@ int UtcDaliRendererSetBlendColor(void) TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); renderer.SetProperty( Renderer::Property::BLEND_COLOR, Color::TRANSPARENT ); + application.SendNotification(); application.Render(); + + DALI_TEST_EQUALS( renderer.GetProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION ); + DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION ); DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), Color::TRANSPARENT, TEST_LOCATION ); renderer.SetProperty( Renderer::Property::BLEND_COLOR, Color::MAGENTA ); + + DALI_TEST_EQUALS( renderer.GetProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION ); + DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION ); + application.SendNotification(); application.Render(); + + DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION ); DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), Color::MAGENTA, TEST_LOCATION ); Vector4 color( 0.1f, 0.2f, 0.3f, 0.4f ); @@ -939,7 +1070,8 @@ int UtcDaliRendererPreMultipledAlpha(void) DALI_TEST_CHECK( gl.GetUniformValue( "uColor", actualValue ) ); DALI_TEST_EQUALS( actualValue, Vector4(1.0f, 0.0f, 1.0f, 0.5f), TEST_LOCATION ); - renderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true); + // Enable pre-multiplied alpha + renderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true ); application.SendNotification(); application.Render(); @@ -948,6 +1080,10 @@ int UtcDaliRendererPreMultipledAlpha(void) DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) ); DALI_TEST_CHECK( preMultipliedAlpha ); + value = renderer.GetCurrentProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA ); + DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) ); + DALI_TEST_CHECK( preMultipliedAlpha ); + srcFactorRgb = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB ); destFactorRgb = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB ); srcFactorAlpha = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA ); @@ -961,6 +1097,33 @@ int UtcDaliRendererPreMultipledAlpha(void) DALI_TEST_CHECK( gl.GetUniformValue( "uColor", actualValue ) ); DALI_TEST_EQUALS( actualValue, Vector4(0.5f, 0.0f, 0.5f, 0.5f), TEST_LOCATION ); + // Disable pre-multiplied alpha again + renderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, false ); + + application.SendNotification(); + application.Render(); + + value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA ); + DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) ); + DALI_TEST_CHECK( !preMultipliedAlpha ); + + value = renderer.GetCurrentProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA ); + DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) ); + DALI_TEST_CHECK( !preMultipliedAlpha ); + + srcFactorRgb = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB ); + destFactorRgb = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB ); + srcFactorAlpha = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA ); + destFactorAlpha = renderer.GetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA ); + + DALI_TEST_EQUALS( (int)BlendFactor::SRC_ALPHA, srcFactorRgb, TEST_LOCATION ); + DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorRgb, TEST_LOCATION ); + DALI_TEST_EQUALS( (int)BlendFactor::ONE, srcFactorAlpha, TEST_LOCATION ); + DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorAlpha, TEST_LOCATION ); + + DALI_TEST_CHECK( gl.GetUniformValue( "uColor", actualValue ) ); + DALI_TEST_EQUALS( actualValue, Vector4( 1.0f, 0.0f, 1.0f, 0.5f ), TEST_LOCATION ); + END_TEST; } @@ -1836,6 +1999,24 @@ int UtcDaliRendererSetIndexRange(void) renderer.SetIndexRange( 0, 5 ); application.SendNotification(); application.Render(); + + Property::Value value = renderer.GetProperty( Renderer::Property::INDEX_RANGE_FIRST ); + int convertedValue; + DALI_TEST_CHECK( value.Get( convertedValue ) ); + DALI_TEST_CHECK( convertedValue == 0 ); + + value = renderer.GetCurrentProperty( Renderer::Property::INDEX_RANGE_FIRST ); + DALI_TEST_CHECK( value.Get( convertedValue ) ); + DALI_TEST_CHECK( convertedValue == 0 ); + + value = renderer.GetProperty( Renderer::Property::INDEX_RANGE_COUNT ); + DALI_TEST_CHECK( value.Get( convertedValue ) ); + DALI_TEST_CHECK( convertedValue == 5 ); + + value = renderer.GetCurrentProperty( Renderer::Property::INDEX_RANGE_COUNT ); + DALI_TEST_CHECK( value.Get( convertedValue ) ); + DALI_TEST_CHECK( convertedValue == 5 ); + sprintf( buffer, "%u, 5, %u, indices", GL_LINE_LOOP, GL_UNSIGNED_SHORT ); bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer ); DALI_TEST_CHECK( result ); @@ -2034,15 +2215,31 @@ int UtcDaliRendererSetDepthFunction(void) * - Check it was set. */ template< typename T > -void CheckEnumerationProperty( Renderer& renderer, Property::Index propertyIndex, T initialValue, T firstCheckEnumeration, T secondCheckEnumeration, std::string secondCheckString ) +void CheckEnumerationProperty( TestApplication& application, Renderer& renderer, Property::Index propertyIndex, T initialValue, T firstCheckEnumeration, T secondCheckEnumeration, std::string secondCheckString ) { + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK( renderer.GetProperty( propertyIndex ) == static_cast( initialValue ) ); DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) == static_cast( initialValue ) ); renderer.SetProperty( propertyIndex, firstCheckEnumeration ); DALI_TEST_CHECK( renderer.GetProperty( propertyIndex ) == static_cast( firstCheckEnumeration ) ); + DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) != static_cast( firstCheckEnumeration ) ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( renderer.GetProperty( propertyIndex ) == static_cast( firstCheckEnumeration ) ); DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) == static_cast( firstCheckEnumeration ) ); + renderer.SetProperty( propertyIndex, secondCheckString ); DALI_TEST_CHECK( renderer.GetProperty( propertyIndex ) == static_cast( secondCheckEnumeration ) ); + DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) != static_cast( secondCheckEnumeration ) ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( renderer.GetProperty( propertyIndex ) == static_cast( secondCheckEnumeration ) ); DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) == static_cast( secondCheckEnumeration ) ); } @@ -2055,27 +2252,32 @@ int UtcDaliRendererEnumProperties(void) Shader shader = CreateShader(); Renderer renderer = Renderer::New( geometry, shader ); + Actor actor = Actor::New(); + actor.AddRenderer(renderer); + actor.SetSize(400, 400); + Stage::GetCurrent().Add(actor); + /* * Here we use a templatized function to perform several checks on each enumeration property. * @see CheckEnumerationProperty for details of the checks performed. */ - CheckEnumerationProperty< FaceCullingMode::Type >( renderer, Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::NONE, FaceCullingMode::FRONT, FaceCullingMode::BACK, "BACK" ); - CheckEnumerationProperty< BlendMode::Type >( renderer, Renderer::Property::BLEND_MODE, BlendMode::AUTO, BlendMode::OFF, BlendMode::ON, "ON" ); - CheckEnumerationProperty< BlendEquation::Type >( renderer, Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::ADD, BlendEquation::SUBTRACT, BlendEquation::REVERSE_SUBTRACT, "REVERSE_SUBTRACT" ); - CheckEnumerationProperty< BlendEquation::Type >( renderer, Renderer::Property::BLEND_EQUATION_ALPHA, BlendEquation::ADD, BlendEquation::SUBTRACT, BlendEquation::REVERSE_SUBTRACT, "REVERSE_SUBTRACT" ); - CheckEnumerationProperty< BlendFactor::Type >( renderer, Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR" ); - CheckEnumerationProperty< BlendFactor::Type >( renderer, Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR" ); - CheckEnumerationProperty< BlendFactor::Type >( renderer, Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::SRC_COLOR, "SRC_COLOR" ); - CheckEnumerationProperty< BlendFactor::Type >( renderer, Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR" ); - CheckEnumerationProperty< DepthWriteMode::Type >( renderer, Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::AUTO, DepthWriteMode::OFF, DepthWriteMode::ON, "ON" ); - CheckEnumerationProperty< DepthFunction::Type >( renderer, Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS, DepthFunction::ALWAYS, DepthFunction::GREATER, "GREATER" ); - CheckEnumerationProperty< DepthTestMode::Type >( renderer, Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::AUTO, DepthTestMode::OFF, DepthTestMode::ON, "ON" ); - CheckEnumerationProperty< StencilFunction::Type >( renderer, Renderer::Property::STENCIL_FUNCTION, StencilFunction::ALWAYS, StencilFunction::LESS, StencilFunction::EQUAL, "EQUAL" ); - CheckEnumerationProperty< RenderMode::Type >( renderer, Renderer::Property::RENDER_MODE, RenderMode::AUTO, RenderMode::NONE, RenderMode::STENCIL, "STENCIL" ); - CheckEnumerationProperty< StencilOperation::Type >( renderer, Renderer::Property::STENCIL_OPERATION_ON_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" ); - CheckEnumerationProperty< StencilOperation::Type >( renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" ); - CheckEnumerationProperty< StencilOperation::Type >( renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" ); + CheckEnumerationProperty< FaceCullingMode::Type >( application, renderer, Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::NONE, FaceCullingMode::FRONT, FaceCullingMode::BACK, "BACK" ); + CheckEnumerationProperty< BlendMode::Type >( application, renderer, Renderer::Property::BLEND_MODE, BlendMode::AUTO, BlendMode::OFF, BlendMode::ON, "ON" ); + CheckEnumerationProperty< BlendEquation::Type >( application, renderer, Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::ADD, BlendEquation::SUBTRACT, BlendEquation::REVERSE_SUBTRACT, "REVERSE_SUBTRACT" ); + CheckEnumerationProperty< BlendEquation::Type >( application, renderer, Renderer::Property::BLEND_EQUATION_ALPHA, BlendEquation::ADD, BlendEquation::SUBTRACT, BlendEquation::REVERSE_SUBTRACT, "REVERSE_SUBTRACT" ); + CheckEnumerationProperty< BlendFactor::Type >( application, renderer, Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR" ); + CheckEnumerationProperty< BlendFactor::Type >( application, renderer, Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR" ); + CheckEnumerationProperty< BlendFactor::Type >( application, renderer, Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::SRC_COLOR, "SRC_COLOR" ); + CheckEnumerationProperty< BlendFactor::Type >( application, renderer, Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR" ); + CheckEnumerationProperty< DepthWriteMode::Type >( application, renderer, Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::AUTO, DepthWriteMode::OFF, DepthWriteMode::ON, "ON" ); + CheckEnumerationProperty< DepthFunction::Type >( application, renderer, Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS, DepthFunction::ALWAYS, DepthFunction::GREATER, "GREATER" ); + CheckEnumerationProperty< DepthTestMode::Type >( application, renderer, Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::AUTO, DepthTestMode::OFF, DepthTestMode::ON, "ON" ); + CheckEnumerationProperty< StencilFunction::Type >( application, renderer, Renderer::Property::STENCIL_FUNCTION, StencilFunction::ALWAYS, StencilFunction::LESS, StencilFunction::EQUAL, "EQUAL" ); + CheckEnumerationProperty< RenderMode::Type >( application, renderer, Renderer::Property::RENDER_MODE, RenderMode::AUTO, RenderMode::NONE, RenderMode::STENCIL, "STENCIL" ); + CheckEnumerationProperty< StencilOperation::Type >( application, renderer, Renderer::Property::STENCIL_OPERATION_ON_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" ); + CheckEnumerationProperty< StencilOperation::Type >( application, renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" ); + CheckEnumerationProperty< StencilOperation::Type >( application, renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" ); END_TEST; } @@ -2137,9 +2339,9 @@ int UtcDaliRendererSetDepthTestMode(void) DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetDepthTestString() ) ); DALI_TEST_CHECK( !glEnableDisableStack.FindMethodAndParams( "Disable", GetDepthTestString() ) ); - // Change the layer behavior to LAYER_2D. + // Change the layer behavior to LAYER_UI. // Note this will also disable depth testing for the layer by default, we test this first. - Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_2D ); + Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_UI ); glEnableDisableStack.Reset(); application.SendNotification(); @@ -2390,6 +2592,8 @@ int UtcDaliRendererSetStencilFunction(void) ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack ); + DALI_TEST_EQUALS( static_cast( renderer.GetCurrentProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE ).Get() ), testValueReference, TEST_LOCATION ); + std::stringstream parameterStream; parameterStream << StencilFunctionLookupTable[ StencilOperation::DECREMENT_WRAP ] << ", " << testValueReference << ", 255"; @@ -2405,6 +2609,8 @@ int UtcDaliRendererSetStencilFunction(void) ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack ); + DALI_TEST_EQUALS( static_cast( renderer.GetCurrentProperty( Renderer::Property::STENCIL_FUNCTION_MASK ).Get() ), testValueMask, TEST_LOCATION ); + // Clear the stringstream. parameterStream.str( std::string() ); parameterStream << StencilFunctionLookupTable[ StencilOperation::DECREMENT_WRAP ] << ", " << testValueReference << ", " << testValueMask; @@ -2532,6 +2738,8 @@ int UtcDaliRendererSetStencilMask(void) ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack ); + DALI_TEST_EQUALS( static_cast( renderer.GetCurrentProperty( Renderer::Property::STENCIL_MASK ).Get() ), 0x00, TEST_LOCATION ); + std::string methodString( "StencilMask" ); std::string parameterString = "0"; @@ -2546,6 +2754,8 @@ int UtcDaliRendererSetStencilMask(void) ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack ); + DALI_TEST_EQUALS( static_cast( renderer.GetCurrentProperty( Renderer::Property::STENCIL_MASK ).Get() ), 0xFF, TEST_LOCATION ); + parameterString = "255"; // Check the function was called and the parameters were correct. @@ -2603,3 +2813,197 @@ int UtcDaliRendererWrongNumberOfTextures(void) END_TEST; } + +int UtcDaliRendererOpacity(void) +{ + TestApplication application; + + tet_infoline( "Test OPACITY property" ); + + Geometry geometry = CreateQuadGeometry(); + Shader shader = Shader::New( "vertexSrc", "fragmentSrc" ); + Renderer renderer = Renderer::New( geometry, shader ); + + Actor actor = Actor::New(); + actor.AddRenderer( renderer ); + actor.SetSize( 400, 400 ); + actor.SetColor( Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) ); + Stage::GetCurrent().Add( actor ); + + Property::Value value = renderer.GetProperty( DevelRenderer::Property::OPACITY ); + float opacity; + DALI_TEST_CHECK( value.Get( opacity ) ); + DALI_TEST_EQUALS( opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION ); + + application.SendNotification(); + application.Render(); + + Vector4 actualValue; + TestGlAbstraction& gl = application.GetGlAbstraction(); + DALI_TEST_CHECK( gl.GetUniformValue< Vector4 >( "uColor", actualValue ) ); + DALI_TEST_EQUALS( actualValue.a, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION ); + + renderer.SetProperty( DevelRenderer::Property::OPACITY, 0.5f ); + + application.SendNotification(); + application.Render(); + + value = renderer.GetProperty( DevelRenderer::Property::OPACITY ); + DALI_TEST_CHECK( value.Get( opacity ) ); + DALI_TEST_EQUALS( opacity, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION ); + + value = renderer.GetCurrentProperty( DevelRenderer::Property::OPACITY ); + DALI_TEST_CHECK( value.Get( opacity ) ); + DALI_TEST_EQUALS( opacity, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION ); + + DALI_TEST_CHECK( gl.GetUniformValue< Vector4 >( "uColor", actualValue ) ); + DALI_TEST_EQUALS( actualValue.a, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliRendererOpacityAnimation(void) +{ + TestApplication application; + + tet_infoline( "Test OPACITY property animation" ); + + Geometry geometry = CreateQuadGeometry(); + Shader shader = Shader::New( "vertexSrc", "fragmentSrc" ); + Renderer renderer = Renderer::New( geometry, shader ); + + Actor actor = Actor::New(); + actor.AddRenderer( renderer ); + actor.SetSize( 400, 400 ); + actor.SetColor( Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) ); + Stage::GetCurrent().Add( actor ); + + application.SendNotification(); + application.Render(0); + + Property::Value value = renderer.GetProperty( DevelRenderer::Property::OPACITY ); + float opacity; + DALI_TEST_CHECK( value.Get( opacity ) ); + DALI_TEST_EQUALS( opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION ); + + Animation animation = Animation::New( 1.0f ); + animation.AnimateTo( Property( renderer, DevelRenderer::Property::OPACITY ), 0.0f ); + animation.Play(); + + application.SendNotification(); + application.Render( 1000 ); + + value = renderer.GetProperty( DevelRenderer::Property::OPACITY ); + DALI_TEST_CHECK( value.Get( opacity ) ); + DALI_TEST_EQUALS( opacity, 0.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION ); + + renderer.SetProperty( DevelRenderer::Property::OPACITY, 0.1f ); + + animation.Clear(); + animation.AnimateBy( Property( renderer, DevelRenderer::Property::OPACITY ), 0.5f ); + animation.Play(); + + application.SendNotification(); + application.Render( 1000 ); + + value = renderer.GetProperty( DevelRenderer::Property::OPACITY ); + DALI_TEST_CHECK( value.Get( opacity ) ); + DALI_TEST_EQUALS( opacity, 0.6f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliRendererInvalidProperty(void) +{ + TestApplication application; + + tet_infoline( "Test invalid property" ); + + Geometry geometry = CreateQuadGeometry(); + Shader shader = Shader::New( "vertexSrc", "fragmentSrc" ); + Renderer renderer = Renderer::New( geometry, shader ); + + Actor actor = Actor::New(); + actor.AddRenderer( renderer ); + actor.SetSize( 400, 400 ); + Stage::GetCurrent().Add( actor ); + + application.SendNotification(); + application.Render(0); + + Property::Value value = renderer.GetProperty( Renderer::Property::DEPTH_INDEX + 100 ); + DALI_TEST_CHECK( value.GetType() == Property::Type::NONE ); + + value = renderer.GetCurrentProperty( Renderer::Property::DEPTH_INDEX + 100 ); + DALI_TEST_CHECK( value.GetType() == Property::Type::NONE ); + + END_TEST; +} + +int UtcDaliRendererRenderingBehavior(void) +{ + TestApplication application; + + tet_infoline( "Test RENDERING_BEHAVIOR property" ); + + Geometry geometry = CreateQuadGeometry(); + Shader shader = Shader::New( "vertexSrc", "fragmentSrc" ); + Renderer renderer = Renderer::New( geometry, shader ); + + Actor actor = Actor::New(); + actor.AddRenderer( renderer ); + actor.SetSize( 400, 400 ); + actor.SetColor( Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) ); + Stage::GetCurrent().Add( actor ); + + Property::Value value = renderer.GetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR ); + int renderingBehavior; + DALI_TEST_CHECK( value.Get( renderingBehavior ) ); + DALI_TEST_EQUALS( static_cast< DevelRenderer::Rendering::Type >( renderingBehavior ), DevelRenderer::Rendering::IF_REQUIRED, TEST_LOCATION ); + + application.SendNotification(); + application.Render(); + + uint32_t updateStatus = application.GetUpdateStatus(); + + DALI_TEST_CHECK( !( updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING ) ); + + renderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::CONTINUOUSLY ); + + value = renderer.GetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR ); + DALI_TEST_CHECK( value.Get( renderingBehavior ) ); + DALI_TEST_EQUALS( static_cast< DevelRenderer::Rendering::Type >( renderingBehavior ), DevelRenderer::Rendering::CONTINUOUSLY, TEST_LOCATION ); + + // Render and check the update status + application.SendNotification(); + application.Render(); + + updateStatus = application.GetUpdateStatus(); + + DALI_TEST_CHECK( updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING ); + + value = renderer.GetCurrentProperty( DevelRenderer::Property::RENDERING_BEHAVIOR ); + DALI_TEST_CHECK( value.Get( renderingBehavior ) ); + DALI_TEST_EQUALS( static_cast< DevelRenderer::Rendering::Type >( renderingBehavior ), DevelRenderer::Rendering::CONTINUOUSLY, TEST_LOCATION ); + + // Render again and check the update status + application.SendNotification(); + application.Render(); + + updateStatus = application.GetUpdateStatus(); + + DALI_TEST_CHECK( updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING ); + + // Change rendering behavior + renderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED ); + + // Render and check the update status + application.SendNotification(); + application.Render(); + + updateStatus = application.GetUpdateStatus(); + + DALI_TEST_CHECK( !( updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING ) ); + + END_TEST; +}