X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-CameraActor.cpp;h=415f6cfd8fd07b5a24eb6083b75561d02ac6ec27;hb=e08e2992259823c5f9832ad959ffa510b0445a6c;hp=5e92e444b39c18aa5b78508972dd8bd4b8e68f04;hpb=5dfaf978c5bd38c489c25f85fc53c385f1cfaeb5;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/automated-tests/src/dali/utc-Dali-CameraActor.cpp b/automated-tests/src/dali/utc-Dali-CameraActor.cpp index 5e92e44..415f6cf 100644 --- a/automated-tests/src/dali/utc-Dali-CameraActor.cpp +++ b/automated-tests/src/dali/utc-Dali-CameraActor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -20,6 +20,8 @@ #include #include #include +#include + #include "dali-test-suite-utils/dali-test-suite-utils.h" @@ -66,6 +68,16 @@ const char* const RENDER_SHADOW_FRAGMENT_SOURCE = " gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n" "}\n"; +struct PropertyDetails +{ + std::string name; ///< The name of the property. + Property::Type type; ///< The property type. + bool writable; ///< Whether the property is writable + bool animatable; ///< Whether the property is animatable. + bool constraintInput; ///< Whether the property can be used as an input to a constraint. + Property::Index enumIndex; ///< Used to check the index is correct within a debug build. +}; + } // Anonymous namespace @@ -223,10 +235,8 @@ int UtcDaliCameraActorSetGetTypeP(void) actor.SetType( Dali::Camera::LOOK_AT_TARGET ); DALI_TEST_EQUALS( actor.GetType(), Dali::Camera::LOOK_AT_TARGET, TEST_LOCATION ); - std::string sValue; - actor.GetProperty( CameraActor::Property::TYPE ).Get( sValue ); - std::string result( "LOOK_AT_TARGET"); - DALI_TEST_EQUALS( result, sValue, TEST_LOCATION ); + DALI_TEST_EQUALS( "LOOK_AT_TARGET", actor.GetProperty< std::string >( CameraActor::Property::TYPE ), TEST_LOCATION ); + DALI_TEST_EQUALS( "LOOK_AT_TARGET", actor.GetCurrentProperty< std::string >( CameraActor::Property::TYPE ), TEST_LOCATION ); END_TEST; } @@ -349,7 +359,6 @@ int UtcDaliCameraActorGetFieldOfViewN(void) END_TEST; } -//todor int UtcDaliCameraActorSetAspectRatioP(void) { TestApplication application; @@ -1207,6 +1216,9 @@ int UtcDaliCameraActorDefaultProperties(void) tet_infoline( "Testing Dali::CameraActor DefaultProperties" ); CameraActor actor = CameraActor::New(); + Stage stage = Stage::GetCurrent(); + stage.Add(actor); + stage.GetRenderTaskList().GetTask(0).SetCameraActor( actor ); actor.SetAspectRatio( TEST_ASPECT_RATIO ); Stage::GetCurrent().Add( actor ); @@ -1265,6 +1277,123 @@ int UtcDaliCameraActorDefaultProperties(void) END_TEST; } +template< typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8> +void TEST_CAMERA_PROPERTY( P1 camera, P2 stringName, P3 type, P4 isWriteable, P5 isAnimateable, P6 isConstraintInput, P7 enumName, P8 LOCATION ) +{ + DALI_TEST_EQUALS( camera.GetPropertyName( enumName ), stringName, LOCATION ); + DALI_TEST_EQUALS( camera.GetPropertyIndex( stringName ), static_cast(enumName), LOCATION ); + DALI_TEST_EQUALS( camera.GetPropertyType( enumName ), type, LOCATION ); + DALI_TEST_EQUALS( camera.IsPropertyWritable( enumName ), isWriteable, LOCATION ); + DALI_TEST_EQUALS( camera.IsPropertyAnimatable( enumName ), isAnimateable, LOCATION ); + DALI_TEST_EQUALS( camera.IsPropertyAConstraintInput( enumName ), isConstraintInput, LOCATION ); +} +int UtcDaliCameraActorDefaultPropertiesInherited(void) +{ + TestApplication application; + + CameraActor actor = CameraActor::New(); + Stage stage = Stage::GetCurrent(); + stage.Add(actor); + stage.GetRenderTaskList().GetTask(0).SetCameraActor( actor ); + + Stage::GetCurrent().Add( actor ); + application.Render( 0 ); + application.SendNotification(); + + const PropertyDetails CAMERA_DEFAULT_PROPERTY[] = + { +// actor + { "parentOrigin", Property::VECTOR3, true, false, true, Dali::Actor::Property::PARENT_ORIGIN }, + { "parentOriginX", Property::FLOAT, true, false, true, Dali::Actor::Property::PARENT_ORIGIN_X }, + { "parentOriginY", Property::FLOAT, true, false, true, Dali::Actor::Property::PARENT_ORIGIN_Y }, + { "parentOriginZ", Property::FLOAT, true, false, true, Dali::Actor::Property::PARENT_ORIGIN_Z }, + { "anchorPoint", Property::VECTOR3, true, false, true, Dali::Actor::Property::ANCHOR_POINT }, + { "anchorPointX", Property::FLOAT, true, false, true, Dali::Actor::Property::ANCHOR_POINT_X }, + { "anchorPointY", Property::FLOAT, true, false, true, Dali::Actor::Property::ANCHOR_POINT_Y }, + { "anchorPointZ", Property::FLOAT, true, false, true, Dali::Actor::Property::ANCHOR_POINT_Z }, + { "size", Property::VECTOR3, true, true, true, Dali::Actor::Property::SIZE }, + { "sizeWidth", Property::FLOAT, true, true, true, Dali::Actor::Property::SIZE_WIDTH }, + { "sizeHeight", Property::FLOAT, true, true, true, Dali::Actor::Property::SIZE_HEIGHT }, + { "sizeDepth", Property::FLOAT, true, true, true, Dali::Actor::Property::SIZE_DEPTH }, + { "position", Property::VECTOR3, true, true, true, Dali::Actor::Property::POSITION }, + { "positionX", Property::FLOAT, true, true, true, Dali::Actor::Property::POSITION_X }, + { "positionY", Property::FLOAT, true, true, true, Dali::Actor::Property::POSITION_Y }, + { "positionZ", Property::FLOAT, true, true, true, Dali::Actor::Property::POSITION_Z }, + { "worldPosition", Property::VECTOR3, false, false, true, Dali::Actor::Property::WORLD_POSITION }, + { "worldPositionX", Property::FLOAT, false, false, true, Dali::Actor::Property::WORLD_POSITION_X }, + { "worldPositionY", Property::FLOAT, false, false, true, Dali::Actor::Property::WORLD_POSITION_Y }, + { "worldPositionZ", Property::FLOAT, false, false, true, Dali::Actor::Property::WORLD_POSITION_Z }, + { "orientation", Property::ROTATION, true, true, true, Dali::Actor::Property::ORIENTATION }, + { "worldOrientation", Property::ROTATION, false, false, true, Dali::Actor::Property::WORLD_ORIENTATION }, + { "scale", Property::VECTOR3, true, true, true, Dali::Actor::Property::SCALE }, + { "scaleX", Property::FLOAT, true, true, true, Dali::Actor::Property::SCALE_X }, + { "scaleY", Property::FLOAT, true, true, true, Dali::Actor::Property::SCALE_Y }, + { "scaleZ", Property::FLOAT, true, true, true, Dali::Actor::Property::SCALE_Z }, + { "worldScale", Property::VECTOR3, false, false, true, Dali::Actor::Property::WORLD_SCALE }, + { "visible", Property::BOOLEAN, true, true, true, Dali::Actor::Property::VISIBLE }, + { "color", Property::VECTOR4, true, true, true, Dali::Actor::Property::COLOR }, + { "colorRed", Property::FLOAT, true, true, true, Dali::Actor::Property::COLOR_RED }, + { "colorGreen", Property::FLOAT, true, true, true, Dali::Actor::Property::COLOR_GREEN }, + { "colorBlue", Property::FLOAT, true, true, true, Dali::Actor::Property::COLOR_BLUE }, + { "colorAlpha", Property::FLOAT, true, true, true, Dali::Actor::Property::COLOR_ALPHA }, + { "worldColor", Property::VECTOR4, false, false, true, Dali::Actor::Property::WORLD_COLOR }, + { "worldMatrix", Property::MATRIX, false, false, true, Dali::Actor::Property::WORLD_MATRIX }, + { "name", Property::STRING, true, false, false, Dali::Actor::Property::NAME }, + { "sensitive", Property::BOOLEAN, true, false, false, Dali::Actor::Property::SENSITIVE }, + { "leaveRequired", Property::BOOLEAN, true, false, false, Dali::Actor::Property::LEAVE_REQUIRED }, + { "inheritOrientation", Property::BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_ORIENTATION }, + { "inheritScale", Property::BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_SCALE }, + { "colorMode", Property::STRING, true, false, false, Dali::Actor::Property::COLOR_MODE }, + { "drawMode", Property::STRING, true, false, false, Dali::Actor::Property::DRAW_MODE }, + { "sizeModeFactor", Property::VECTOR3, true, false, false, Dali::Actor::Property::SIZE_MODE_FACTOR }, + { "widthResizePolicy", Property::STRING, true, false, false, Dali::Actor::Property::WIDTH_RESIZE_POLICY }, + { "heightResizePolicy", Property::STRING, true, false, false, Dali::Actor::Property::HEIGHT_RESIZE_POLICY }, + { "sizeScalePolicy", Property::STRING, true, false, false, Dali::Actor::Property::SIZE_SCALE_POLICY }, + { "widthForHeight", Property::BOOLEAN, true, false, false, Dali::Actor::Property::WIDTH_FOR_HEIGHT }, + { "heightForWidth", Property::BOOLEAN, true, false, false, Dali::Actor::Property::HEIGHT_FOR_WIDTH }, + { "padding", Property::VECTOR4, true, false, false, Dali::Actor::Property::PADDING }, + { "minimumSize", Property::VECTOR2, true, false, false, Dali::Actor::Property::MINIMUM_SIZE }, + { "maximumSize", Property::VECTOR2, true, false, false, Dali::Actor::Property::MAXIMUM_SIZE }, + { "inheritPosition", Property::BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_POSITION }, + { "clippingMode", Property::STRING, true, false, false, Dali::Actor::Property::CLIPPING_MODE }, + { "layoutDirection", Property::STRING, true, false, false, Dali::Actor::Property::LAYOUT_DIRECTION }, + { "inheritLayoutDirection", Property::BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_LAYOUT_DIRECTION }, + { "siblingOrder", Property::INTEGER, true, false, false, Dali::DevelActor::Property::SIBLING_ORDER }, + { "opacity", Property::FLOAT, true, true, true, Dali::DevelActor::Property::OPACITY }, + { "screenPosition", Property::VECTOR2, false, false, false, Dali::DevelActor::Property::SCREEN_POSITION }, + { "positionUsesAnchorPoint",Property::BOOLEAN, true, false, false, Dali::DevelActor::Property::POSITION_USES_ANCHOR_POINT }, + { "culled", Property::BOOLEAN, false, false, true, Dali::DevelActor::Property::CULLED }, +// camera own + { "type", Property::STRING, true, false, true, Dali::CameraActor::Property::TYPE }, + { "projectionMode", Property::STRING, true, false, true, Dali::CameraActor::Property::PROJECTION_MODE }, + { "fieldOfView", Property::FLOAT, true, false, true, Dali::CameraActor::Property::FIELD_OF_VIEW }, + { "aspectRatio", Property::FLOAT, true, false, true, Dali::CameraActor::Property::ASPECT_RATIO }, + { "nearPlaneDistance", Property::FLOAT, true, false, true, Dali::CameraActor::Property::NEAR_PLANE_DISTANCE }, + { "farPlaneDistance", Property::FLOAT, true, false, true, Dali::CameraActor::Property::FAR_PLANE_DISTANCE }, + { "leftPlaneDistance", Property::FLOAT, true, false, true, Dali::CameraActor::Property::LEFT_PLANE_DISTANCE }, + { "rightPlaneDistance", Property::FLOAT, true, false, true, Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE }, + { "topPlaneDistance", Property::FLOAT, true, false, true, Dali::CameraActor::Property::TOP_PLANE_DISTANCE }, + { "bottomPlaneDistance", Property::FLOAT, true, false, true, Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE }, + { "targetPosition", Property::VECTOR3, true, false, true, Dali::CameraActor::Property::TARGET_POSITION }, + { "projectionMatrix", Property::MATRIX, false, false, true, Dali::CameraActor::Property::PROJECTION_MATRIX }, + { "viewMatrix", Property::MATRIX, false, false, true, Dali::CameraActor::Property::VIEW_MATRIX }, + { "invertYAxis", Property::BOOLEAN, true, false, true, Dali::CameraActor::Property::INVERT_Y_AXIS } + }; + + for( uint32_t index = 0; index < (sizeof(CAMERA_DEFAULT_PROPERTY)/sizeof(PropertyDetails)); ++index ) + { + TEST_CAMERA_PROPERTY( actor, + CAMERA_DEFAULT_PROPERTY[ index ].name, + CAMERA_DEFAULT_PROPERTY[ index ].type, + CAMERA_DEFAULT_PROPERTY[ index ].writable, + CAMERA_DEFAULT_PROPERTY[ index ].animatable, + CAMERA_DEFAULT_PROPERTY[ index ].constraintInput, + CAMERA_DEFAULT_PROPERTY[ index ].enumIndex, + TEST_LOCATION ); + } + END_TEST; +} + int UtcDaliCameraActorModelView(void) { TestApplication application; @@ -1272,7 +1401,7 @@ int UtcDaliCameraActorModelView(void) BufferImage image = CreateBufferImage(); - ImageActor actor = ImageActor::New( image ); + Actor actor = CreateRenderableActor(image); actor.SetSize( 100.0f, 100.0f ); actor.SetPosition( 20.0f, 30.0f, 40.0f ); actor.SetParentOrigin( ParentOrigin::CENTER ); @@ -1308,9 +1437,9 @@ int UtcDaliCameraActorReadProjectionMatrix(void) application.Render(); application.SendNotification(); Image image = CreateBufferImage(); - ImageActor imageActor = ImageActor::New( image ); - imageActor.SetSize( 100.0f, 100.0f ); - Stage::GetCurrent().Add( imageActor ); + Actor actor = CreateRenderableActor( image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE ); + actor.SetSize( 100.0f, 100.0f ); + Stage::GetCurrent().Add( actor ); Matrix projectionMatrix; Matrix viewMatrix; @@ -1318,18 +1447,15 @@ int UtcDaliCameraActorReadProjectionMatrix(void) camera.GetProperty( CameraActor::CameraActor::Property::PROJECTION_MATRIX ).Get( projectionMatrix ); camera.GetProperty( CameraActor::CameraActor::Property::VIEW_MATRIX ).Get( viewMatrix ); - ShaderEffect shaderEffect = ShaderEffect::New( RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE ); - imageActor.SetShaderEffect( shaderEffect ); + actor.RegisterProperty( SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME, Matrix::IDENTITY ); + actor.RegisterProperty( SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME, Matrix::IDENTITY ); - shaderEffect.SetUniform( SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME, Matrix::IDENTITY ); - shaderEffect.SetUniform( SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME, Matrix::IDENTITY ); + Property::Index projectionMatrixPropertyIndex = actor.GetPropertyIndex( SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME ); + Property::Index viewMatrixPropertyIndex = actor.GetPropertyIndex( SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME ); - Property::Index projectionMatrixPropertyIndex = shaderEffect.GetPropertyIndex( SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME ); - Property::Index viewMatrixPropertyIndex = shaderEffect.GetPropertyIndex( SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME ); - - Constraint projectionMatrixConstraint = Constraint::New( shaderEffect, projectionMatrixPropertyIndex, EqualToConstraint() ); + Constraint projectionMatrixConstraint = Constraint::New( actor, projectionMatrixPropertyIndex, EqualToConstraint() ); projectionMatrixConstraint.AddSource( Source( camera, CameraActor::Property::PROJECTION_MATRIX ) ); - Constraint viewMatrixConstraint = Constraint::New( shaderEffect, viewMatrixPropertyIndex, EqualToConstraint() ); + Constraint viewMatrixConstraint = Constraint::New( actor, viewMatrixPropertyIndex, EqualToConstraint() ); viewMatrixConstraint.AddSource( Source( camera, CameraActor::Property::VIEW_MATRIX ) ); projectionMatrixConstraint.Apply(); @@ -1469,6 +1595,7 @@ int UtcDaliCameraActorCheckLookAtAndFreeLookViews02(void) stage.Add( target ); stage.Add( freeLookCameraActor ); stage.Add( lookAtCameraActor ); + stage.GetRenderTaskList().GetTask(0).SetCameraActor( freeLookCameraActor ); // Create an arbitrary vector for( float x=-1.0f; x<=1.0f; x+=0.1f ) @@ -1489,20 +1616,17 @@ int UtcDaliCameraActorCheckLookAtAndFreeLookViews02(void) application.SendNotification(); application.Render(); Matrix freeLookViewMatrix; - Matrix lookAtViewMatrix; freeLookCameraActor.GetProperty( CameraActor::CameraActor::Property::VIEW_MATRIX ).Get( freeLookViewMatrix ); - lookAtCameraActor.GetProperty( CameraActor::CameraActor::Property::VIEW_MATRIX ).Get( lookAtViewMatrix ); Matrix freeLookWorld = freeLookCameraActor.GetCurrentWorldMatrix(); Matrix freeLookTest( false ); Matrix::Multiply( freeLookTest, freeLookViewMatrix, freeLookWorld ); DALI_TEST_EQUALS( freeLookTest, Matrix::IDENTITY, 0.01f, TEST_LOCATION ); - - DALI_TEST_EQUALS( freeLookViewMatrix, lookAtViewMatrix, 0.01, TEST_LOCATION ); } } } + END_TEST; } @@ -1526,6 +1650,7 @@ int UtcDaliCameraActorCheckLookAtAndFreeLookViews03(void) Actor cameraAnchor = Actor::New(); cameraAnchor.Add( freeLookCameraActor ); stage.Add( cameraAnchor ); + stage.GetRenderTaskList().GetTask(0).SetCameraActor( freeLookCameraActor ); for( float angle = 1.0f; angle <= 180.0f; angle += 1.0f ) {