X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-CameraActor.cpp;h=0f700bf48340f94d813e163502c501d1db1045ea;hb=72d3e464f0fdaaf6db6206873408e8d845f02cd4;hp=15e86c4abda851898119b83f3707514566042d71;hpb=0c082da88cc60e3dcda92b7627285c6998a5ae08;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 15e86c4..0f700bf 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,7 @@ #include #include #include +#include #include "dali-test-suite-utils/dali-test-suite-utils.h" @@ -223,10 +224,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", DevelHandle::GetCurrentProperty< std::string >( actor, CameraActor::Property::TYPE ), TEST_LOCATION ); END_TEST; } @@ -260,7 +259,7 @@ int UtcDaliCameraActorSetGetTypeN(void) DALI_TEST_ASSERT( e, "camera", TEST_LOCATION ); } - DALI_TEST_EQUALS( (int)cameraType, (int)Dali::Camera::FREE_LOOK, TEST_LOCATION ); + DALI_TEST_EQUALS( cameraType, Dali::Camera::FREE_LOOK, TEST_LOCATION ); END_TEST; } @@ -349,7 +348,6 @@ int UtcDaliCameraActorGetFieldOfViewN(void) END_TEST; } -//todor int UtcDaliCameraActorSetAspectRatioP(void) { TestApplication application; @@ -786,7 +784,7 @@ int UtcDaliCameraActorSetPerspectiveProjectionP(void) actor.GetProperty( CameraActor::Property::FAR_PLANE_DISTANCE ).Get( value ); DALI_TEST_EQUALS( 4245.f, value, FLOAT_EPSILON, TEST_LOCATION ); - DALI_TEST_EQUALS( (int)actor.GetProjectionMode(), (int)Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION ); END_TEST; } @@ -809,7 +807,7 @@ int UtcDaliCameraActorSetPerspectiveProjectionN(void) DALI_TEST_EQUALS( nearClippingPlane, actor.GetNearClippingPlane(), FLOAT_EPSILON, TEST_LOCATION ); DALI_TEST_EQUALS( farClippingPlane, actor.GetFarClippingPlane(), FLOAT_EPSILON, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetProjectionMode(), (int)Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION ); END_TEST; } @@ -869,7 +867,7 @@ int UtcDaliCameraActorSetOrthographicProjectionP1(void) Vector3 pos = actor.GetCurrentPosition(); DALI_TEST_EQUALS( defaultPos.z, pos.z, 0.001f, TEST_LOCATION ); - DALI_TEST_EQUALS( (int)actor.GetProjectionMode(), (int)Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION ); END_TEST; } @@ -933,7 +931,7 @@ int UtcDaliCameraActorSetOrthographicProjectionP2(void) actor.GetProperty( CameraActor::Property::BOTTOM_PLANE_DISTANCE ).Get( value ); DALI_TEST_EQUALS( 500.0f, value, FLOAT_EPSILON, TEST_LOCATION ); - DALI_TEST_EQUALS( (int)actor.GetProjectionMode(), (int)Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION ); END_TEST; } @@ -983,7 +981,7 @@ int UtcDaliCameraActorSetOrthographicProjectionP3(void) actor.GetProperty( CameraActor::Property::BOTTOM_PLANE_DISTANCE ).Get( value ); DALI_TEST_EQUALS( 500.0f, value, FLOAT_EPSILON, TEST_LOCATION ); - DALI_TEST_EQUALS( (int)actor.GetProjectionMode(), (int)Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION ); std::string stringValue; actor.GetProperty( CameraActor::Property::PROJECTION_MODE ).Get( stringValue ); DALI_TEST_EQUALS( stringValue, "ORTHOGRAPHIC_PROJECTION", TEST_LOCATION ); @@ -1003,20 +1001,20 @@ int UtcDaliCameraActorSetProjectionModeP(void) actor.SetProjectionMode( Dali::Camera::PERSPECTIVE_PROJECTION ); - DALI_TEST_EQUALS( (int)actor.GetProjectionMode(), (int)Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION ); DALI_TEST_EQUALS( actor.GetNearClippingPlane(), 200.0f, FLOAT_EPSILON, TEST_LOCATION ); DALI_TEST_EQUALS( actor.GetFarClippingPlane(), 400.0f, FLOAT_EPSILON, TEST_LOCATION ); actor.SetProjectionMode( Dali::Camera::ORTHOGRAPHIC_PROJECTION ); - DALI_TEST_EQUALS( (int)actor.GetProjectionMode(), (int)Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION ); DALI_TEST_EQUALS( actor.GetNearClippingPlane(), 200.0f, FLOAT_EPSILON, TEST_LOCATION ); DALI_TEST_EQUALS( actor.GetFarClippingPlane(), 400.0f, FLOAT_EPSILON, TEST_LOCATION ); // Check setting the property. Property::Value setValue = "PERSPECTIVE_PROJECTION"; actor.SetProperty( CameraActor::Property::PROJECTION_MODE, setValue ); - DALI_TEST_EQUALS( (int)actor.GetProjectionMode(), (int)Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION ); END_TEST; } @@ -1050,10 +1048,10 @@ int UtcDaliCameraActorGetProjectionModeP(void) CameraActor actor = CameraActor::New(); actor.SetOrthographicProjection( Size::ONE ); - DALI_TEST_EQUALS( (int)actor.GetProjectionMode(), (int)Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::ORTHOGRAPHIC_PROJECTION, TEST_LOCATION ); actor.SetPerspectiveProjection( Size( 100.f, 150.f ) ); - DALI_TEST_EQUALS( (int)actor.GetProjectionMode(), (int)Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProjectionMode(), Dali::Camera::PERSPECTIVE_PROJECTION, TEST_LOCATION ); // Check getting the property. std::string stringValue; @@ -1207,6 +1205,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 ); @@ -1272,7 +1273,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 +1309,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 +1319,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 ); - - shaderEffect.SetUniform( SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME, Matrix::IDENTITY ); - shaderEffect.SetUniform( SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME, Matrix::IDENTITY ); + actor.RegisterProperty( SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME, Matrix::IDENTITY ); + actor.RegisterProperty( SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME, Matrix::IDENTITY ); - Property::Index projectionMatrixPropertyIndex = shaderEffect.GetPropertyIndex( SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME ); - Property::Index viewMatrixPropertyIndex = shaderEffect.GetPropertyIndex( SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME ); + Property::Index projectionMatrixPropertyIndex = actor.GetPropertyIndex( SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME ); + Property::Index viewMatrixPropertyIndex = actor.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 +1467,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 +1488,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 +1522,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 ) {