X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-Path.cpp;h=08499ae7867059d04b35a9530af9f043203a813f;hb=72d3e464f0fdaaf6db6206873408e8d845f02cd4;hp=4a41766f12810d6dbbbf73b03f84da2ba6ee11d5;hpb=432923e17cb38a99fc012473ef97fa8c4fc36162;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/automated-tests/src/dali/utc-Dali-Path.cpp b/automated-tests/src/dali/utc-Dali-Path.cpp index 4a41766..08499ae 100644 --- a/automated-tests/src/dali/utc-Dali-Path.cpp +++ b/automated-tests/src/dali/utc-Dali-Path.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. @@ -19,6 +19,7 @@ #include #include +#include #include using namespace Dali; @@ -189,6 +190,27 @@ int utcDaliPathGenerateControlPoints01(void) END_TEST; } +int utcDaliPathGetPointCount(void) +{ + TestApplication application; + Dali::Path path = Dali::Path::New(); + + DALI_TEST_EQUALS(path.GetPointCount(), 0u, TEST_LOCATION); + + path.AddPoint(Vector3( 50.0, 50.0, 0.0)); + path.AddPoint(Vector3(120.0, 70.0, 0.0)); + path.AddPoint(Vector3(190.0, 250.0, 0.0)); + path.AddPoint(Vector3(260.0, 260.0, 0.0)); + + DALI_TEST_EQUALS(path.GetPointCount(), 4u, TEST_LOCATION); + + path.AddPoint(Vector3(330.0, 220.0, 0.0)); + path.AddPoint(Vector3(400.0, 50.0, 0.0)); + + DALI_TEST_EQUALS(path.GetPointCount(), 6u, TEST_LOCATION); + END_TEST; +} + int utcDaliPathGenerateControlPoints02(void) { TestApplication application; @@ -272,3 +294,182 @@ int UtcDaliPathSample01(void) END_TEST; } +int UtcDaliPathDownCast(void) +{ + TestApplication application; + + Dali::Path path = Dali::Path::New(); + Handle handle = path; + SetupPath(path); + + Dali::Path path2 = Dali::Path::DownCast(handle); + DALI_TEST_CHECK(path2); + + //t = 0 + Vector3 position, tangent; + path2.Sample(0.0f, position, tangent ); + DALI_TEST_EQUALS(position.x, 30.0f, TEST_LOCATION); + DALI_TEST_EQUALS(position.y, 80.0f, TEST_LOCATION); + DALI_TEST_EQUALS(tangent.x, 0.6f, 0.1f, TEST_LOCATION); + DALI_TEST_EQUALS(tangent.y, 0.7f, 0.1f, TEST_LOCATION); + + //t = 0.25 + path2.Sample(0.25f, position, tangent ); + DALI_TEST_EQUALS(position.x, 48.0f, 2.0f, TEST_LOCATION); + DALI_TEST_EQUALS(position.y, 102.0f, 2.0f, TEST_LOCATION); + DALI_TEST_EQUALS(tangent.x, 0.6f, 0.1f, TEST_LOCATION); + DALI_TEST_EQUALS(tangent.y, 0.7f, 0.1f, TEST_LOCATION); + + // t = 0.5 + path2.Sample(0.5f, position, tangent ); + DALI_TEST_EQUALS(position.x, 70.0f, TEST_LOCATION); + DALI_TEST_EQUALS(position.y, 120.0f, TEST_LOCATION); + DALI_TEST_EQUALS(tangent.x, 1.0f, 0.1f, TEST_LOCATION); + DALI_TEST_EQUALS(tangent.y, 0.0f, 0.1f, TEST_LOCATION); + + + //t = 0.75 + path2.Sample(0.75f, position, tangent ); + DALI_TEST_EQUALS(position.x, 85.0f, 2.0f, TEST_LOCATION); + DALI_TEST_EQUALS(position.y, 112.0f, 2.0f, TEST_LOCATION); + DALI_TEST_EQUALS(tangent.x, 0.7f, 0.1f, TEST_LOCATION); + DALI_TEST_EQUALS(tangent.y, -0.6f, 0.1f, TEST_LOCATION); + + // t = 1 + path2.Sample(1.0f, position, tangent ); + DALI_TEST_EQUALS(position.x, 100.0f, TEST_LOCATION); + DALI_TEST_EQUALS(position.y, 100.0f, TEST_LOCATION); + DALI_TEST_EQUALS(tangent.x, 0.8f, 0.1f, TEST_LOCATION); + DALI_TEST_EQUALS(tangent.y, -0.4f, 0.1f, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliPathAssignment(void) +{ + TestApplication application; + + Dali::Path path = Dali::Path::New(); + SetupPath(path); + + Dali::Path path2; + path2 = path; + DALI_TEST_CHECK(path2); + + //t = 0 + Vector3 position, tangent; + path2.Sample(0.0f, position, tangent ); + DALI_TEST_EQUALS(position.x, 30.0f, TEST_LOCATION); + DALI_TEST_EQUALS(position.y, 80.0f, TEST_LOCATION); + DALI_TEST_EQUALS(tangent.x, 0.6f, 0.1f, TEST_LOCATION); + DALI_TEST_EQUALS(tangent.y, 0.7f, 0.1f, TEST_LOCATION); + + //t = 0.25 + path2.Sample(0.25f, position, tangent ); + DALI_TEST_EQUALS(position.x, 48.0f, 2.0f, TEST_LOCATION); + DALI_TEST_EQUALS(position.y, 102.0f, 2.0f, TEST_LOCATION); + DALI_TEST_EQUALS(tangent.x, 0.6f, 0.1f, TEST_LOCATION); + DALI_TEST_EQUALS(tangent.y, 0.7f, 0.1f, TEST_LOCATION); + + // t = 0.5 + path2.Sample(0.5f, position, tangent ); + DALI_TEST_EQUALS(position.x, 70.0f, TEST_LOCATION); + DALI_TEST_EQUALS(position.y, 120.0f, TEST_LOCATION); + DALI_TEST_EQUALS(tangent.x, 1.0f, 0.1f, TEST_LOCATION); + DALI_TEST_EQUALS(tangent.y, 0.0f, 0.1f, TEST_LOCATION); + + + //t = 0.75 + path2.Sample(0.75f, position, tangent ); + DALI_TEST_EQUALS(position.x, 85.0f, 2.0f, TEST_LOCATION); + DALI_TEST_EQUALS(position.y, 112.0f, 2.0f, TEST_LOCATION); + DALI_TEST_EQUALS(tangent.x, 0.7f, 0.1f, TEST_LOCATION); + DALI_TEST_EQUALS(tangent.y, -0.6f, 0.1f, TEST_LOCATION); + + // t = 1 + path2.Sample(1.0f, position, tangent ); + DALI_TEST_EQUALS(position.x, 100.0f, TEST_LOCATION); + DALI_TEST_EQUALS(position.y, 100.0f, TEST_LOCATION); + DALI_TEST_EQUALS(tangent.x, 0.8f, 0.1f, TEST_LOCATION); + DALI_TEST_EQUALS(tangent.y, -0.4f, 0.1f, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliPathPropertyPoints(void) +{ + TestApplication application; + + Dali::Path path = Dali::Path::New(); + + Dali::Property::Array points; + points.Add( Vector3( 100.0f, 100.0f, 100.0f ) ) + .Add( Vector3( 200.0f, 200.0f, 200.0f ) ) + .Add( Vector3( 300.0f, 300.0f, 300.0f ) ); + path.SetProperty( Dali::Path::Property::POINTS, points ); + + { + Property::Value value = path.GetProperty( Dali::Path::Property::POINTS ); + Property::Array* array = value.GetArray(); + DALI_TEST_CHECK( array ); + + const unsigned int noOfPoints = points.Size(); + for( unsigned int i = 0; i < noOfPoints; ++i ) + { + DALI_TEST_EQUALS( ( *array )[i].Get< Vector3 >(), points[i].Get< Vector3 >(), TEST_LOCATION ); + } + } + + { + Property::Value value = DevelHandle::GetCurrentProperty( path, Dali::Path::Property::POINTS ); + Property::Array* array = value.GetArray(); + DALI_TEST_CHECK( array ); + + const unsigned int noOfPoints = points.Size(); + for( unsigned int i = 0; i < noOfPoints; ++i ) + { + DALI_TEST_EQUALS( ( *array )[i].Get< Vector3 >(), points[i].Get< Vector3 >(), TEST_LOCATION ); + } + } + + END_TEST; +} + +int UtcDaliPathPropertyControlPoints(void) +{ + TestApplication application; + + Dali::Path path = Dali::Path::New(); + + Dali::Property::Array points; + points.Add( Vector3( 0.1f, 0.1f, 0.1f ) ) + .Add( Vector3( 0.2f, 0.2f, 0.2f ) ) + .Add( Vector3( 0.3f, 0.3f, 0.3f ) ); + path.SetProperty( Dali::Path::Property::CONTROL_POINTS, points ); + + { + Property::Value value = path.GetProperty( Dali::Path::Property::CONTROL_POINTS ); + Property::Array* array = value.GetArray(); + DALI_TEST_CHECK( array ); + + const unsigned int noOfPoints = points.Size(); + for( unsigned int i = 0; i < noOfPoints; ++i ) + { + DALI_TEST_EQUALS( ( *array )[i].Get< Vector3 >(), points[i].Get< Vector3 >(), TEST_LOCATION ); + } + } + + { + Property::Value value = DevelHandle::GetCurrentProperty( path, Dali::Path::Property::CONTROL_POINTS ); + Property::Array* array = value.GetArray(); + DALI_TEST_CHECK( array ); + + const unsigned int noOfPoints = points.Size(); + for( unsigned int i = 0; i < noOfPoints; ++i ) + { + DALI_TEST_EQUALS( ( *array )[i].Get< Vector3 >(), points[i].Get< Vector3 >(), TEST_LOCATION ); + } + } + + END_TEST; +}