From d7e133451f2c9aac489a4de2ba79df4b3d6996c0 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Fri, 15 Jul 2016 10:28:27 +0100 Subject: [PATCH] (Automated Tests) Combined dali and dali-devel Total 1907 tests, 1 less than combined total before. This is because UtcLinearConstrainerApply was duplicated in both dali and dali-devel. Change-Id: I52ae9e9da91d10259db0d7cc5dd1dc2ba45ecd63 --- automated-tests/src/dali-devel/CMakeLists.txt | 64 --- .../src/dali-devel/tct-dali-devel-core.cpp | 51 -- automated-tests/src/dali-devel/utc-Dali-Actor.cpp | 180 ------- .../src/dali-devel/utc-Dali-Constrainer.cpp | 546 --------------------- automated-tests/src/dali/CMakeLists.txt | 16 +- automated-tests/src/dali/utc-Dali-Actor.cpp | 155 ++++++ .../src/{dali-devel => dali}/utc-Dali-Atlas.cpp | 0 .../utc-Dali-ConditionalWait.cpp | 0 automated-tests/src/dali/utc-Dali-Constrainer.cpp | 412 ++++++++++++++++ .../src/{dali-devel => dali}/utc-Dali-Context.cpp | 0 .../utc-Dali-DistanceField.cpp | 0 .../src/{dali-devel => dali}/utc-Dali-Hash.cpp | 0 .../utc-Dali-HitTestAlgorithm.cpp | 0 .../src/{dali-devel => dali}/utc-Dali-Mutex.cpp | 0 .../{dali-devel => dali}/utc-Dali-Scripting.cpp | 0 .../utc-Dali-SignalDelegate.cpp | 0 .../src/{dali-devel => dali}/utc-Dali-Thread.cpp | 0 .../{dali-devel => dali}/utc-Dali-WeakHandle.cpp | 0 18 files changed, 581 insertions(+), 843 deletions(-) delete mode 100644 automated-tests/src/dali-devel/CMakeLists.txt delete mode 100644 automated-tests/src/dali-devel/tct-dali-devel-core.cpp delete mode 100644 automated-tests/src/dali-devel/utc-Dali-Actor.cpp delete mode 100644 automated-tests/src/dali-devel/utc-Dali-Constrainer.cpp rename automated-tests/src/{dali-devel => dali}/utc-Dali-Atlas.cpp (100%) rename automated-tests/src/{dali-devel => dali}/utc-Dali-ConditionalWait.cpp (100%) rename automated-tests/src/{dali-devel => dali}/utc-Dali-Context.cpp (100%) rename automated-tests/src/{dali-devel => dali}/utc-Dali-DistanceField.cpp (100%) rename automated-tests/src/{dali-devel => dali}/utc-Dali-Hash.cpp (100%) rename automated-tests/src/{dali-devel => dali}/utc-Dali-HitTestAlgorithm.cpp (100%) rename automated-tests/src/{dali-devel => dali}/utc-Dali-Mutex.cpp (100%) rename automated-tests/src/{dali-devel => dali}/utc-Dali-Scripting.cpp (100%) rename automated-tests/src/{dali-devel => dali}/utc-Dali-SignalDelegate.cpp (100%) rename automated-tests/src/{dali-devel => dali}/utc-Dali-Thread.cpp (100%) rename automated-tests/src/{dali-devel => dali}/utc-Dali-WeakHandle.cpp (100%) diff --git a/automated-tests/src/dali-devel/CMakeLists.txt b/automated-tests/src/dali-devel/CMakeLists.txt deleted file mode 100644 index 6a462bd..0000000 --- a/automated-tests/src/dali-devel/CMakeLists.txt +++ /dev/null @@ -1,64 +0,0 @@ -SET(PKG_NAME "dali-devel") - -SET(EXEC_NAME "tct-${PKG_NAME}-core") -SET(RPM_NAME "core-${PKG_NAME}-tests") - -SET(CAPI_LIB "dali-devel") - -SET(TC_SOURCES - utc-Dali-Actor.cpp - utc-Dali-Atlas.cpp - utc-Dali-ConditionalWait.cpp - utc-Dali-Context.cpp - utc-Dali-Constrainer.cpp - utc-Dali-DistanceField.cpp - utc-Dali-Hash.cpp - utc-Dali-HitTestAlgorithm.cpp - utc-Dali-Mutex.cpp - utc-Dali-SignalDelegate.cpp - utc-Dali-Scripting.cpp - utc-Dali-Thread.cpp - utc-Dali-WeakHandle.cpp -) - -LIST(APPEND TC_SOURCES - ../dali/dali-test-suite-utils/mesh-builder.cpp - ../dali/dali-test-suite-utils/dali-test-suite-utils.cpp - ../dali/dali-test-suite-utils/test-actor-utils.cpp - ../dali/dali-test-suite-utils/test-harness.cpp - ../dali/dali-test-suite-utils/test-application.cpp - ../dali/dali-test-suite-utils/test-gesture-manager.cpp - ../dali/dali-test-suite-utils/test-gl-abstraction.cpp - ../dali/dali-test-suite-utils/test-gl-sync-abstraction.cpp - ../dali/dali-test-suite-utils/test-native-image.cpp - ../dali/dali-test-suite-utils/test-platform-abstraction.cpp - ../dali/dali-test-suite-utils/test-render-controller.cpp - ../dali/dali-test-suite-utils/test-trace-call-stack.cpp -) - -PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED - dali-core -) - -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${${CAPI_LIB}_CFLAGS_OTHER} -O0 -ggdb --coverage -Wall -Werror") - -FOREACH(directory ${${CAPI_LIB}_LIBRARY_DIRS}) - SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -L${directory}") -ENDFOREACH(directory ${CAPI_LIB_LIBRARY_DIRS}) - -INCLUDE_DIRECTORIES( - ../../.. - . - ${${CAPI_LIB}_INCLUDE_DIRS} - ../dali/dali-test-suite-utils -) - -ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.cpp ${TC_SOURCES}) -TARGET_LINK_LIBRARIES(${EXEC_NAME} - ${${CAPI_LIB}_LIBRARIES} - -lpthread -) - -INSTALL(PROGRAMS ${EXEC_NAME} - DESTINATION ${BIN_DIR}/${EXEC_NAME} -) diff --git a/automated-tests/src/dali-devel/tct-dali-devel-core.cpp b/automated-tests/src/dali-devel/tct-dali-devel-core.cpp deleted file mode 100644 index 4553f75..0000000 --- a/automated-tests/src/dali-devel/tct-dali-devel-core.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include -#include -#include -#include "tct-dali-devel-core.h" - -int main(int argc, char * const argv[]) -{ - int result = TestHarness::EXIT_STATUS_BAD_ARGUMENT; - - const char* optString = "rs"; - bool optRerunFailed(true); - bool optRunSerially(false); - - int nextOpt = 0; - do - { - nextOpt = getopt( argc, argv, optString ); - switch(nextOpt) - { - case 'r': - optRerunFailed = true; - break; - case 's': - optRunSerially = true; - break; - case '?': - TestHarness::Usage(argv[0]); - exit(TestHarness::EXIT_STATUS_BAD_ARGUMENT); - break; - } - } while( nextOpt != -1 ); - - if( optind == argc ) // no testcase name in argument list - { - if( optRunSerially ) - { - result = TestHarness::RunAll( argv[0], tc_array ); - } - else - { - result = TestHarness::RunAllInParallel( argv[0], tc_array, optRerunFailed ); - } - } - else - { - // optind is index of next argument - interpret as testcase name - result = TestHarness::FindAndRunTestCase(tc_array, argv[optind]); - } - return result; -} diff --git a/automated-tests/src/dali-devel/utc-Dali-Actor.cpp b/automated-tests/src/dali-devel/utc-Dali-Actor.cpp deleted file mode 100644 index 92d6eb3..0000000 --- a/automated-tests/src/dali-devel/utc-Dali-Actor.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2015 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 - -//& set: DaliActor - -using std::string; -using namespace Dali; - - -int UtcDaliActorAddRendererP(void) -{ - tet_infoline("Testing Actor::AddRenderer"); - TestApplication application; - - Actor actor = Actor::New(); - - DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION ); - - Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); - Renderer renderer = Renderer::New(geometry, shader); - - actor.AddRenderer( renderer ); - DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliActorAddRendererN(void) -{ - tet_infoline("Testing Actor::AddRenderer"); - TestApplication application; - - Actor actor = Actor::New(); - Renderer renderer; - - // try illegal Add - try - { - actor.AddRenderer( renderer ); - tet_printf("Assertion test failed - no Exception\n" ); - tet_result(TET_FAIL); - } - catch(Dali::DaliException& e) - { - DALI_TEST_PRINT_ASSERT( e ); - DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION); - DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION ); - } - catch(...) - { - tet_printf("Assertion test failed - wrong Exception\n" ); - tet_result(TET_FAIL); - } - - END_TEST; -} - -int UtcDaliActorAddRendererOnStage(void) -{ - tet_infoline("Testing Actor::AddRenderer"); - TestApplication application; - - Actor actor = Actor::New(); - Stage::GetCurrent().Add(actor); - - application.SendNotification(); - application.Render(0); - - Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); - Renderer renderer = Renderer::New(geometry, shader); - - application.SendNotification(); - application.Render(0); - - try - { - actor.AddRenderer( renderer ); - tet_result(TET_PASS); - } - catch(...) - { - tet_result(TET_FAIL); - } - - END_TEST; -} - -int UtcDaliActorRemoveRendererP1(void) -{ - tet_infoline("Testing Actor::RemoveRenderer"); - TestApplication application; - - Actor actor = Actor::New(); - - DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION ); - - Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); - Renderer renderer = Renderer::New(geometry, shader); - - actor.AddRenderer( renderer ); - DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION ); - - actor.RemoveRenderer(renderer); - DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION ); - - - END_TEST; -} - -int UtcDaliActorRemoveRendererP2(void) -{ - tet_infoline("Testing Actor::RemoveRenderer"); - TestApplication application; - - Actor actor = Actor::New(); - - DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION ); - - Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); - Renderer renderer = Renderer::New(geometry, shader); - - actor.AddRenderer( renderer ); - DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION ); - - actor.RemoveRenderer(0); - DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION ); - - - END_TEST; -} - - -int UtcDaliActorRemoveRendererN(void) -{ - tet_infoline("Testing Actor::RemoveRenderer"); - TestApplication application; - - Actor actor = Actor::New(); - - DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION ); - - Geometry geometry = CreateQuadGeometry(); - Shader shader = CreateShader(); - Renderer renderer = Renderer::New(geometry, shader); - - actor.AddRenderer( renderer ); - DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION ); - - actor.RemoveRenderer(10); - DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); - - END_TEST; -} diff --git a/automated-tests/src/dali-devel/utc-Dali-Constrainer.cpp b/automated-tests/src/dali-devel/utc-Dali-Constrainer.cpp deleted file mode 100644 index 076a9c2..0000000 --- a/automated-tests/src/dali-devel/utc-Dali-Constrainer.cpp +++ /dev/null @@ -1,546 +0,0 @@ -/* - * 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 - -using namespace Dali; -using namespace Dali::Internal; - -namespace -{ - -static void SetupPath( Dali::Path& path) -{ - path.AddPoint(Vector3( 30.0, 80.0, 0.0)); - path.AddPoint(Vector3( 70.0, 120.0, 0.0)); - path.AddPoint(Vector3(100.0, 100.0, 0.0)); - - //Control points for first segment - path.AddControlPoint( Vector3( 39.0, 90.0, 0.0) ); - path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) ); - - //Control points for second segment - path.AddControlPoint(Vector3( 78.0, 120.0, 0.0) ); - path.AddControlPoint(Vector3( 93.0, 104.0, 0.0) ); -} - -static void SetupPathConstrainer( Dali::PathConstrainer& PathConstrainer) -{ - PathConstrainer.SetProperty( Dali::PathConstrainer::Property::FORWARD, Vector3(1.0f,0.0f,0.0f) ); - - Dali::Property::Array points; - points.Resize(3); - points[0] = Vector3( 30.0, 80.0, 0.0); - points[1] = Vector3( 70.0, 120.0, 0.0); - points[2] = Vector3(100.0, 100.0, 0.0); - PathConstrainer.SetProperty( Dali::PathConstrainer::Property::POINTS, points ); - - points.Resize(4); - points[0] = Vector3( 39.0, 90.0, 0.0); - points[1] = Vector3( 56.0, 119.0, 0.0); - points[2] = Vector3( 78.0, 120.0, 0.0); - points[3] = Vector3( 93.0, 104.0, 0.0); - PathConstrainer.SetProperty( Dali::PathConstrainer::Property::CONTROL_POINTS, points ); -} - -static void SetupLinearConstrainerUniformProgress( Dali::LinearConstrainer& linearConstrainer) -{ - Dali::Property::Array points; - points.Resize(3); - points[0] = 0.0f; - points[1] = 1.0f; - points[2] = 0.0f; - linearConstrainer.SetProperty( Dali::LinearConstrainer::Property::VALUE, points ); -} - -static void SetupLinearConstrainerNonUniformProgress( Dali::LinearConstrainer& linearConstrainer) -{ - Dali::Property::Array points; - points.Resize(3); - points[0] = 0.0f; - points[1] = 1.0f; - points[2] = 0.0f; - linearConstrainer.SetProperty( Dali::LinearConstrainer::Property::VALUE, points ); - - points[0] = 0.0f; - points[1] = 0.25f; - points[2] = 1.0f; - linearConstrainer.SetProperty( Dali::LinearConstrainer::Property::PROGRESS, points ); -} - -} // anonymous namespace - -//PathConstrainer test cases -int UtcPathConstrainerApply(void) -{ - TestApplication application; - - Dali::Actor actor = Dali::Actor::New(); - - // Register a float property - Property::Index index = actor.RegisterProperty( "t", 0.0f ); - - Dali::Stage::GetCurrent().Add(actor); - - //Create a Path - Dali::Path path = Dali::Path::New(); - SetupPath(path); - - //Create a PathConstrainer - Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New(); - SetupPathConstrainer( pathConstrainer ); - - //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t" - Vector2 range( 0.0f, 1.0f ); - pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range ); - - //Create an animation to animate the custom property - float durationSeconds(1.0f); - Dali::Animation animation = Dali::Animation::New(durationSeconds); - animation.AnimateTo(Dali::Property(actor,index),1.0f); - animation.Play(); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 20% progress */); - - Vector3 position, tangent; - path.Sample(0.2f, position, tangent ); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 40% progress */); - path.Sample(0.4f, position, tangent ); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 60% progress */); - path.Sample(0.6f, position, tangent ); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 80% progress */); - path.Sample(0.8f, position, tangent ); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* 100% progress */); - path.Sample(1.0f, position, tangent ); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*200.0f)/* beyond the animation duration*/); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); - - END_TEST; -} - -int UtcPathConstrainerApplyRange(void) -{ - TestApplication application; - - Dali::Actor actor = Dali::Actor::New(); - - // Register a float property - Property::Index index = actor.RegisterProperty( "t", 0.0f ); - Dali::Stage::GetCurrent().Add(actor); - - //Create a Path - Dali::Path path = Dali::Path::New(); - SetupPath(path); - - //Create a PathConstrainer - Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New(); - SetupPathConstrainer( pathConstrainer ); - - //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t" - Vector2 range( 100.0f, 300.0f ); - pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range ); - - - //Create an animation to animate the custom property - float durationSeconds(1.0f); - Dali::Animation animation = Dali::Animation::New(durationSeconds); - animation.AnimateTo(Dali::Property(actor,index),400.0f); - animation.Play(); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - - - Vector3 position, tangent; - float tValue; - actor.GetProperty(index).Get(tValue); - float currentCursor = ( tValue - range.x ) / (range.y-range.x); - path.Sample(currentCursor, position, tangent ); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); - actor.GetProperty(index).Get(tValue); - currentCursor = ( tValue - range.x ) / (range.y-range.x); - path.Sample(currentCursor, position, tangent ); - path.Sample(0.5, position, tangent ); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); - actor.GetProperty(index).Get(tValue); - currentCursor = ( tValue - range.x ) / (range.y-range.x); - path.Sample(currentCursor, position, tangent ); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 100% progress */); - actor.GetProperty(index).Get(tValue); - currentCursor = ( tValue - range.x ) / (range.y-range.x); - path.Sample(currentCursor, position, tangent ); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* beyond the animation duration*/); - actor.GetProperty(index).Get(tValue); - currentCursor = ( tValue - range.x ) / (range.y-range.x); - path.Sample(currentCursor, position, tangent ); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); - - END_TEST; -} - -int UtcPathConstrainerDestroy(void) -{ - TestApplication application; - - Dali::Actor actor = Dali::Actor::New(); - - // Register a float property - Property::Index index = actor.RegisterProperty( "t", 0.0f ); - Dali::Stage::GetCurrent().Add(actor); - - { - //Create a Path - Dali::Path path = Dali::Path::New(); - SetupPath(path); - - //Create a PathConstrainer - Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New(); - SetupPathConstrainer( pathConstrainer ); - - //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t" - Vector2 range( 0.0f, 1.0f ); - pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range ); - - //Test that the constraint is correctly applied - actor.SetProperty(index,0.5f); - application.SendNotification(); - application.Render(static_cast(1.0f)); - - Vector3 position, tangent; - path.Sample(0.5f, position, tangent ); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); - - } - - //PathConstrainer has been destroyed. Constraint in the actor should have been removed - actor.SetProperty(index,0.75f); - application.SendNotification(); - application.Render(static_cast(1.0f)); - - DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); - - END_TEST; -} - -int UtcPathConstrainerRemove(void) -{ - TestApplication application; - - Dali::Actor actor = Dali::Actor::New(); - - // Register a float property - Property::Index index = actor.RegisterProperty( "t", 0.0f ); - Dali::Stage::GetCurrent().Add(actor); - - //Create a Path - Dali::Path path = Dali::Path::New(); - SetupPath(path); - - //Create a PathConstrainer - Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New(); - SetupPathConstrainer( pathConstrainer ); - - //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t" - Vector2 range( 0.0f, 1.0f ); - pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range ); - - //Test that the constraint is correctly applied - actor.SetProperty(index,0.5f); - application.SendNotification(); - application.Render(static_cast(1.0f)); - - Vector3 position, tangent; - path.Sample(0.5f, position, tangent ); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); - - //Remove constraint - pathConstrainer.Remove( actor ); - actor.SetProperty(index,0.75f); - application.SendNotification(); - application.Render(static_cast(1.0f)); - - DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); - - END_TEST; -} - -//LinearConstrainer test cases -int UtcLinearConstrainerDownCast(void) -{ - TestApplication application; - Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New(); - - BaseHandle handle( linearConstrainer ); - Dali::LinearConstrainer linearConstrainer2 = Dali::LinearConstrainer::DownCast( handle ); - DALI_TEST_EQUALS( (bool)linearConstrainer2, true, TEST_LOCATION ); - - BaseHandle handle2; - Dali:: LinearConstrainer linearConstrainer3 = Dali::LinearConstrainer::DownCast( handle2 ); - DALI_TEST_EQUALS( (bool)linearConstrainer3, false, TEST_LOCATION ); - - END_TEST; -} - -int UtcLinearConstrainerCopyConstructor(void) -{ - TestApplication application; - Dali::LinearConstrainer linearConstrainer; - DALI_TEST_EQUALS( (bool)linearConstrainer, false, TEST_LOCATION ); - - linearConstrainer = Dali::LinearConstrainer::New(); - DALI_TEST_EQUALS( (bool)linearConstrainer, true, TEST_LOCATION ); - - // call the copy constructor - Dali::LinearConstrainer linearConstrainer2( linearConstrainer ); - DALI_TEST_EQUALS( (bool)linearConstrainer2, true, TEST_LOCATION ); - - END_TEST; -} - -int UtcLinearConstrainerApply(void) -{ - TestApplication application; - - Dali::Actor actor = Dali::Actor::New(); - - // Register a float property - Property::Index index = actor.RegisterProperty( "t", 0.0f ); - - Dali::Stage::GetCurrent().Add(actor); - - - //Create a LinearConstrainer without specifying progress for values - Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New(); - SetupLinearConstrainerUniformProgress( linearConstrainer ); - - //Apply the linear constraint to the actor's position. The source property for the constraint will be the custom property "t" - Vector2 range( 0.0f, 1.0f ); - linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range ); - - //Create an animation to animate the custom property - float durationSeconds(1.0f); - Dali::Animation animation = Dali::Animation::New(durationSeconds); - animation.AnimateTo(Dali::Property(actor,index),1.0f); - animation.Play(); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - - DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); - DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); - DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 100% progress */); - DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* beyond the animation duration*/); - DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION ); - - //Setup a LinearConstrainer specifying the progress for each value - linearConstrainer.Remove(actor); - SetupLinearConstrainerNonUniformProgress( linearConstrainer ); - linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range ); - - actor.SetProperty(index,0.0f); - animation.Play(); - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - - DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); - DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 2.0f/3.0f, Math::MACHINE_EPSILON_1, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); - DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f/3.0f, Math::MACHINE_EPSILON_1, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 100% progress */); - DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* beyond the animation duration*/); - DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION ); - - END_TEST; -} - -int UtcLinearConstrainerApplyRange(void) -{ - TestApplication application; - - Dali::Actor actor = Dali::Actor::New(); - - // Register a float property - Property::Index index = actor.RegisterProperty( "t", 100.0f ); - Dali::Stage::GetCurrent().Add(actor); - - //Create a LinearConstrainer - Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New(); - SetupLinearConstrainerUniformProgress( linearConstrainer ); - - //Apply the linear constraint to the actor's position. The source property for the constraint will be the custom property "t" - Vector2 range( 100.0f, 300.0f ); - linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range ); - - - //Create an animation to animate the custom property - float durationSeconds(1.0f); - Dali::Animation animation = Dali::Animation::New(durationSeconds); - animation.AnimateTo(Dali::Property(actor,index),300.0f); - animation.Play(); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); - - DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); - DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); - DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* 100% progress */); - DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast(durationSeconds*250.0f)/* beyond the animation duration*/); - DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION ); - - END_TEST; -} - -int UtcLinearConstrainerDestroy(void) -{ - TestApplication application; - - Dali::Actor actor = Dali::Actor::New(); - - // Register a float property - Property::Index index = actor.RegisterProperty( "t", 0.0f ); - Dali::Stage::GetCurrent().Add(actor); - - { - //Create a LinearConstrainer - Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New(); - SetupLinearConstrainerUniformProgress( linearConstrainer ); - - //Apply the linear constraint to the actor's position. The source property for the constraint will be the custom property "t" - Vector2 range( 0.0f, 1.0f ); - linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range ); - - //Test that the constraint is correctly applied - actor.SetProperty(index,0.5f); - application.SendNotification(); - application.Render(static_cast(1.0f)); - - DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION ); - - } - - //LinearConstrainer has been destroyed. Constraint in the actor should have been removed - actor.SetProperty(index,0.75f); - application.SendNotification(); - application.Render(static_cast(1.0f)); - - DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION ); - - END_TEST; -} - -int UtcLinearConstrainerRemove(void) -{ - TestApplication application; - - Dali::Actor actor = Dali::Actor::New(); - - // Register a float property - Property::Index index = actor.RegisterProperty( "t", 0.0f ); - Dali::Stage::GetCurrent().Add(actor); - - //Create a LinearConstrainer - Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New(); - SetupLinearConstrainerUniformProgress( linearConstrainer ); - - //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t" - Vector2 range( 0.0f, 1.0f ); - linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range ); - - //Test that the constraint is correctly applied - actor.SetProperty(index,0.5f); - application.SendNotification(); - application.Render(static_cast(1.0f)); - - DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION ); - - //Remove constraint - linearConstrainer.Remove( actor ); - actor.SetProperty(index,0.75f); - application.SendNotification(); - application.Render(static_cast(1.0f)); - - DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION ); - - END_TEST; -} diff --git a/automated-tests/src/dali/CMakeLists.txt b/automated-tests/src/dali/CMakeLists.txt index 5e888e7..0a55d1b 100644 --- a/automated-tests/src/dali/CMakeLists.txt +++ b/automated-tests/src/dali/CMakeLists.txt @@ -11,16 +11,21 @@ SET(TC_SOURCES utc-Dali-AngleAxis.cpp utc-Dali-Animation.cpp utc-Dali-Any.cpp + utc-Dali-Atlas.cpp utc-Dali-BaseHandle.cpp utc-Dali-BufferImage.cpp utc-Dali-CameraActor.cpp + utc-Dali-ConditionalWait.cpp + utc-Dali-ConnectionTracker.cpp + utc-Dali-Constrainer.cpp utc-Dali-Constraint.cpp utc-Dali-ConstraintFunction.cpp utc-Dali-Constraints.cpp utc-Dali-ConstraintSource.cpp - utc-Dali-ConnectionTracker.cpp + utc-Dali-Context.cpp utc-Dali-CustomActor.cpp utc-Dali-Degree.cpp + utc-Dali-DistanceField.cpp utc-Dali-EncodedBufferImage.cpp utc-Dali-FrameBuffer.cpp utc-Dali-FrameBufferImage.cpp @@ -28,6 +33,8 @@ SET(TC_SOURCES utc-Dali-Gesture.cpp utc-Dali-GestureDetector.cpp utc-Dali-Handle.cpp + utc-Dali-Hash.cpp + utc-Dali-HitTestAlgorithm.cpp utc-Dali-HoverProcessing.cpp utc-Dali-Image.cpp utc-Dali-IntrusivePtr.cpp @@ -40,6 +47,7 @@ SET(TC_SOURCES utc-Dali-Matrix.cpp utc-Dali-Matrix3.cpp utc-Dali-MeshMaterial.cpp + utc-Dali-Mutex.cpp utc-Dali-NativeImage.cpp utc-Dali-NinePatchImages.cpp utc-Dali-ObjectRegistry.cpp @@ -65,7 +73,9 @@ SET(TC_SOURCES utc-Dali-RenderTaskList.cpp utc-Dali-ResourceImage.cpp utc-Dali-Sampler.cpp + utc-Dali-Scripting.cpp utc-Dali-Shader.cpp + utc-Dali-SignalDelegate.cpp utc-Dali-SignalTemplatesFunctors.cpp utc-Dali-SignalTemplates.cpp utc-Dali-Stage.cpp @@ -73,6 +83,7 @@ SET(TC_SOURCES utc-Dali-TapGestureDetector.cpp utc-Dali-Texture.cpp utc-Dali-TextureSet.cpp + utc-Dali-Thread.cpp utc-Dali-TouchEventCombiner.cpp utc-Dali-TouchProcessing.cpp utc-Dali-TouchDataProcessing.cpp @@ -82,8 +93,8 @@ SET(TC_SOURCES utc-Dali-Vector2.cpp utc-Dali-Vector3.cpp utc-Dali-Vector4.cpp + utc-Dali-WeakHandle.cpp utc-Dali-WheelEvent.cpp - utc-Dali-Constrainer.cpp ) LIST(APPEND TC_SOURCES @@ -120,6 +131,7 @@ INCLUDE_DIRECTORIES( ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.cpp ${TC_SOURCES}) TARGET_LINK_LIBRARIES(${EXEC_NAME} ${${CAPI_LIB}_LIBRARIES} + -lpthread ) INSTALL(PROGRAMS ${EXEC_NAME} diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp index 2386eeb..f4f3fcc 100644 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -22,6 +22,7 @@ #include #include #include +#include //& set: DaliActor @@ -3395,3 +3396,157 @@ int UtcDaliActorDrawModePropertyAsString(void) END_TEST; } + +int UtcDaliActorAddRendererP(void) +{ + tet_infoline("Testing Actor::AddRenderer"); + TestApplication application; + + Actor actor = Actor::New(); + + DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION ); + + Geometry geometry = CreateQuadGeometry(); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); + + actor.AddRenderer( renderer ); + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliActorAddRendererN(void) +{ + tet_infoline("Testing Actor::AddRenderer"); + TestApplication application; + + Actor actor = Actor::New(); + Renderer renderer; + + // try illegal Add + try + { + actor.AddRenderer( renderer ); + tet_printf("Assertion test failed - no Exception\n" ); + tet_result(TET_FAIL); + } + catch(Dali::DaliException& e) + { + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION); + DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION ); + } + catch(...) + { + tet_printf("Assertion test failed - wrong Exception\n" ); + tet_result(TET_FAIL); + } + + END_TEST; +} + +int UtcDaliActorAddRendererOnStage(void) +{ + tet_infoline("Testing Actor::AddRenderer"); + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(0); + + Geometry geometry = CreateQuadGeometry(); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); + + application.SendNotification(); + application.Render(0); + + try + { + actor.AddRenderer( renderer ); + tet_result(TET_PASS); + } + catch(...) + { + tet_result(TET_FAIL); + } + + END_TEST; +} + +int UtcDaliActorRemoveRendererP1(void) +{ + tet_infoline("Testing Actor::RemoveRenderer"); + TestApplication application; + + Actor actor = Actor::New(); + + DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION ); + + Geometry geometry = CreateQuadGeometry(); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); + + actor.AddRenderer( renderer ); + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION ); + + actor.RemoveRenderer(renderer); + DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION ); + + + END_TEST; +} + +int UtcDaliActorRemoveRendererP2(void) +{ + tet_infoline("Testing Actor::RemoveRenderer"); + TestApplication application; + + Actor actor = Actor::New(); + + DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION ); + + Geometry geometry = CreateQuadGeometry(); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); + + actor.AddRenderer( renderer ); + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION ); + + actor.RemoveRenderer(0); + DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION ); + + + END_TEST; +} + + +int UtcDaliActorRemoveRendererN(void) +{ + tet_infoline("Testing Actor::RemoveRenderer"); + TestApplication application; + + Actor actor = Actor::New(); + + DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION ); + + Geometry geometry = CreateQuadGeometry(); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New(geometry, shader); + + actor.AddRenderer( renderer ); + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION ); + + actor.RemoveRenderer(10); + DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); + + END_TEST; +} diff --git a/automated-tests/src/dali-devel/utc-Dali-Atlas.cpp b/automated-tests/src/dali/utc-Dali-Atlas.cpp similarity index 100% rename from automated-tests/src/dali-devel/utc-Dali-Atlas.cpp rename to automated-tests/src/dali/utc-Dali-Atlas.cpp diff --git a/automated-tests/src/dali-devel/utc-Dali-ConditionalWait.cpp b/automated-tests/src/dali/utc-Dali-ConditionalWait.cpp similarity index 100% rename from automated-tests/src/dali-devel/utc-Dali-ConditionalWait.cpp rename to automated-tests/src/dali/utc-Dali-ConditionalWait.cpp diff --git a/automated-tests/src/dali/utc-Dali-Constrainer.cpp b/automated-tests/src/dali/utc-Dali-Constrainer.cpp index 3398341..076a9c2 100644 --- a/automated-tests/src/dali/utc-Dali-Constrainer.cpp +++ b/automated-tests/src/dali/utc-Dali-Constrainer.cpp @@ -27,6 +27,41 @@ using namespace Dali::Internal; namespace { + +static void SetupPath( Dali::Path& path) +{ + path.AddPoint(Vector3( 30.0, 80.0, 0.0)); + path.AddPoint(Vector3( 70.0, 120.0, 0.0)); + path.AddPoint(Vector3(100.0, 100.0, 0.0)); + + //Control points for first segment + path.AddControlPoint( Vector3( 39.0, 90.0, 0.0) ); + path.AddControlPoint(Vector3( 56.0, 119.0, 0.0) ); + + //Control points for second segment + path.AddControlPoint(Vector3( 78.0, 120.0, 0.0) ); + path.AddControlPoint(Vector3( 93.0, 104.0, 0.0) ); +} + +static void SetupPathConstrainer( Dali::PathConstrainer& PathConstrainer) +{ + PathConstrainer.SetProperty( Dali::PathConstrainer::Property::FORWARD, Vector3(1.0f,0.0f,0.0f) ); + + Dali::Property::Array points; + points.Resize(3); + points[0] = Vector3( 30.0, 80.0, 0.0); + points[1] = Vector3( 70.0, 120.0, 0.0); + points[2] = Vector3(100.0, 100.0, 0.0); + PathConstrainer.SetProperty( Dali::PathConstrainer::Property::POINTS, points ); + + points.Resize(4); + points[0] = Vector3( 39.0, 90.0, 0.0); + points[1] = Vector3( 56.0, 119.0, 0.0); + points[2] = Vector3( 78.0, 120.0, 0.0); + points[3] = Vector3( 93.0, 104.0, 0.0); + PathConstrainer.SetProperty( Dali::PathConstrainer::Property::CONTROL_POINTS, points ); +} + static void SetupLinearConstrainerUniformProgress( Dali::LinearConstrainer& linearConstrainer) { Dali::Property::Array points; @@ -54,6 +89,261 @@ static void SetupLinearConstrainerNonUniformProgress( Dali::LinearConstrainer& l } // anonymous namespace +//PathConstrainer test cases +int UtcPathConstrainerApply(void) +{ + TestApplication application; + + Dali::Actor actor = Dali::Actor::New(); + + // Register a float property + Property::Index index = actor.RegisterProperty( "t", 0.0f ); + + Dali::Stage::GetCurrent().Add(actor); + + //Create a Path + Dali::Path path = Dali::Path::New(); + SetupPath(path); + + //Create a PathConstrainer + Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New(); + SetupPathConstrainer( pathConstrainer ); + + //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t" + Vector2 range( 0.0f, 1.0f ); + pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range ); + + //Create an animation to animate the custom property + float durationSeconds(1.0f); + Dali::Animation animation = Dali::Animation::New(durationSeconds); + animation.AnimateTo(Dali::Property(actor,index),1.0f); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 20% progress */); + + Vector3 position, tangent; + path.Sample(0.2f, position, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 40% progress */); + path.Sample(0.4f, position, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 60% progress */); + path.Sample(0.6f, position, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 80% progress */); + path.Sample(0.8f, position, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 100% progress */); + path.Sample(1.0f, position, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + + END_TEST; +} + +int UtcPathConstrainerApplyRange(void) +{ + TestApplication application; + + Dali::Actor actor = Dali::Actor::New(); + + // Register a float property + Property::Index index = actor.RegisterProperty( "t", 0.0f ); + Dali::Stage::GetCurrent().Add(actor); + + //Create a Path + Dali::Path path = Dali::Path::New(); + SetupPath(path); + + //Create a PathConstrainer + Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New(); + SetupPathConstrainer( pathConstrainer ); + + //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t" + Vector2 range( 100.0f, 300.0f ); + pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range ); + + + //Create an animation to animate the custom property + float durationSeconds(1.0f); + Dali::Animation animation = Dali::Animation::New(durationSeconds); + animation.AnimateTo(Dali::Property(actor,index),400.0f); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + + Vector3 position, tangent; + float tValue; + actor.GetProperty(index).Get(tValue); + float currentCursor = ( tValue - range.x ) / (range.y-range.x); + path.Sample(currentCursor, position, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + actor.GetProperty(index).Get(tValue); + currentCursor = ( tValue - range.x ) / (range.y-range.x); + path.Sample(currentCursor, position, tangent ); + path.Sample(0.5, position, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + actor.GetProperty(index).Get(tValue); + currentCursor = ( tValue - range.x ) / (range.y-range.x); + path.Sample(currentCursor, position, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 100% progress */); + actor.GetProperty(index).Get(tValue); + currentCursor = ( tValue - range.x ) / (range.y-range.x); + path.Sample(currentCursor, position, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* beyond the animation duration*/); + actor.GetProperty(index).Get(tValue); + currentCursor = ( tValue - range.x ) / (range.y-range.x); + path.Sample(currentCursor, position, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + + END_TEST; +} + +int UtcPathConstrainerDestroy(void) +{ + TestApplication application; + + Dali::Actor actor = Dali::Actor::New(); + + // Register a float property + Property::Index index = actor.RegisterProperty( "t", 0.0f ); + Dali::Stage::GetCurrent().Add(actor); + + { + //Create a Path + Dali::Path path = Dali::Path::New(); + SetupPath(path); + + //Create a PathConstrainer + Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New(); + SetupPathConstrainer( pathConstrainer ); + + //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t" + Vector2 range( 0.0f, 1.0f ); + pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range ); + + //Test that the constraint is correctly applied + actor.SetProperty(index,0.5f); + application.SendNotification(); + application.Render(static_cast(1.0f)); + + Vector3 position, tangent; + path.Sample(0.5f, position, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + + } + + //PathConstrainer has been destroyed. Constraint in the actor should have been removed + actor.SetProperty(index,0.75f); + application.SendNotification(); + application.Render(static_cast(1.0f)); + + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + + END_TEST; +} + +int UtcPathConstrainerRemove(void) +{ + TestApplication application; + + Dali::Actor actor = Dali::Actor::New(); + + // Register a float property + Property::Index index = actor.RegisterProperty( "t", 0.0f ); + Dali::Stage::GetCurrent().Add(actor); + + //Create a Path + Dali::Path path = Dali::Path::New(); + SetupPath(path); + + //Create a PathConstrainer + Dali::PathConstrainer pathConstrainer = Dali::PathConstrainer::New(); + SetupPathConstrainer( pathConstrainer ); + + //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t" + Vector2 range( 0.0f, 1.0f ); + pathConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION), Property(actor,index), range ); + + //Test that the constraint is correctly applied + actor.SetProperty(index,0.5f); + application.SendNotification(); + application.Render(static_cast(1.0f)); + + Vector3 position, tangent; + path.Sample(0.5f, position, tangent ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), position, TEST_LOCATION ); + + //Remove constraint + pathConstrainer.Remove( actor ); + actor.SetProperty(index,0.75f); + application.SendNotification(); + application.Render(static_cast(1.0f)); + + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + + END_TEST; +} + +//LinearConstrainer test cases +int UtcLinearConstrainerDownCast(void) +{ + TestApplication application; + Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New(); + + BaseHandle handle( linearConstrainer ); + Dali::LinearConstrainer linearConstrainer2 = Dali::LinearConstrainer::DownCast( handle ); + DALI_TEST_EQUALS( (bool)linearConstrainer2, true, TEST_LOCATION ); + + BaseHandle handle2; + Dali:: LinearConstrainer linearConstrainer3 = Dali::LinearConstrainer::DownCast( handle2 ); + DALI_TEST_EQUALS( (bool)linearConstrainer3, false, TEST_LOCATION ); + + END_TEST; +} + +int UtcLinearConstrainerCopyConstructor(void) +{ + TestApplication application; + Dali::LinearConstrainer linearConstrainer; + DALI_TEST_EQUALS( (bool)linearConstrainer, false, TEST_LOCATION ); + + linearConstrainer = Dali::LinearConstrainer::New(); + DALI_TEST_EQUALS( (bool)linearConstrainer, true, TEST_LOCATION ); + + // call the copy constructor + Dali::LinearConstrainer linearConstrainer2( linearConstrainer ); + DALI_TEST_EQUALS( (bool)linearConstrainer2, true, TEST_LOCATION ); + + END_TEST; +} + int UtcLinearConstrainerApply(void) { TestApplication application; @@ -132,3 +422,125 @@ int UtcLinearConstrainerApply(void) END_TEST; } +int UtcLinearConstrainerApplyRange(void) +{ + TestApplication application; + + Dali::Actor actor = Dali::Actor::New(); + + // Register a float property + Property::Index index = actor.RegisterProperty( "t", 100.0f ); + Dali::Stage::GetCurrent().Add(actor); + + //Create a LinearConstrainer + Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New(); + SetupLinearConstrainerUniformProgress( linearConstrainer ); + + //Apply the linear constraint to the actor's position. The source property for the constraint will be the custom property "t" + Vector2 range( 100.0f, 300.0f ); + linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range ); + + + //Create an animation to animate the custom property + float durationSeconds(1.0f); + Dali::Animation animation = Dali::Animation::New(durationSeconds); + animation.AnimateTo(Dali::Property(actor,index),300.0f); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 100% progress */); + DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* beyond the animation duration*/); + DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION ); + + END_TEST; +} + +int UtcLinearConstrainerDestroy(void) +{ + TestApplication application; + + Dali::Actor actor = Dali::Actor::New(); + + // Register a float property + Property::Index index = actor.RegisterProperty( "t", 0.0f ); + Dali::Stage::GetCurrent().Add(actor); + + { + //Create a LinearConstrainer + Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New(); + SetupLinearConstrainerUniformProgress( linearConstrainer ); + + //Apply the linear constraint to the actor's position. The source property for the constraint will be the custom property "t" + Vector2 range( 0.0f, 1.0f ); + linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range ); + + //Test that the constraint is correctly applied + actor.SetProperty(index,0.5f); + application.SendNotification(); + application.Render(static_cast(1.0f)); + + DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION ); + + } + + //LinearConstrainer has been destroyed. Constraint in the actor should have been removed + actor.SetProperty(index,0.75f); + application.SendNotification(); + application.Render(static_cast(1.0f)); + + DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION ); + + END_TEST; +} + +int UtcLinearConstrainerRemove(void) +{ + TestApplication application; + + Dali::Actor actor = Dali::Actor::New(); + + // Register a float property + Property::Index index = actor.RegisterProperty( "t", 0.0f ); + Dali::Stage::GetCurrent().Add(actor); + + //Create a LinearConstrainer + Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New(); + SetupLinearConstrainerUniformProgress( linearConstrainer ); + + //Apply the path constraint to the actor's position. The source property for the constraint will be the custom property "t" + Vector2 range( 0.0f, 1.0f ); + linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range ); + + //Test that the constraint is correctly applied + actor.SetProperty(index,0.5f); + application.SendNotification(); + application.Render(static_cast(1.0f)); + + DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION ); + + //Remove constraint + linearConstrainer.Remove( actor ); + actor.SetProperty(index,0.75f); + application.SendNotification(); + application.Render(static_cast(1.0f)); + + DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION ); + + END_TEST; +} diff --git a/automated-tests/src/dali-devel/utc-Dali-Context.cpp b/automated-tests/src/dali/utc-Dali-Context.cpp similarity index 100% rename from automated-tests/src/dali-devel/utc-Dali-Context.cpp rename to automated-tests/src/dali/utc-Dali-Context.cpp diff --git a/automated-tests/src/dali-devel/utc-Dali-DistanceField.cpp b/automated-tests/src/dali/utc-Dali-DistanceField.cpp similarity index 100% rename from automated-tests/src/dali-devel/utc-Dali-DistanceField.cpp rename to automated-tests/src/dali/utc-Dali-DistanceField.cpp diff --git a/automated-tests/src/dali-devel/utc-Dali-Hash.cpp b/automated-tests/src/dali/utc-Dali-Hash.cpp similarity index 100% rename from automated-tests/src/dali-devel/utc-Dali-Hash.cpp rename to automated-tests/src/dali/utc-Dali-Hash.cpp diff --git a/automated-tests/src/dali-devel/utc-Dali-HitTestAlgorithm.cpp b/automated-tests/src/dali/utc-Dali-HitTestAlgorithm.cpp similarity index 100% rename from automated-tests/src/dali-devel/utc-Dali-HitTestAlgorithm.cpp rename to automated-tests/src/dali/utc-Dali-HitTestAlgorithm.cpp diff --git a/automated-tests/src/dali-devel/utc-Dali-Mutex.cpp b/automated-tests/src/dali/utc-Dali-Mutex.cpp similarity index 100% rename from automated-tests/src/dali-devel/utc-Dali-Mutex.cpp rename to automated-tests/src/dali/utc-Dali-Mutex.cpp diff --git a/automated-tests/src/dali-devel/utc-Dali-Scripting.cpp b/automated-tests/src/dali/utc-Dali-Scripting.cpp similarity index 100% rename from automated-tests/src/dali-devel/utc-Dali-Scripting.cpp rename to automated-tests/src/dali/utc-Dali-Scripting.cpp diff --git a/automated-tests/src/dali-devel/utc-Dali-SignalDelegate.cpp b/automated-tests/src/dali/utc-Dali-SignalDelegate.cpp similarity index 100% rename from automated-tests/src/dali-devel/utc-Dali-SignalDelegate.cpp rename to automated-tests/src/dali/utc-Dali-SignalDelegate.cpp diff --git a/automated-tests/src/dali-devel/utc-Dali-Thread.cpp b/automated-tests/src/dali/utc-Dali-Thread.cpp similarity index 100% rename from automated-tests/src/dali-devel/utc-Dali-Thread.cpp rename to automated-tests/src/dali/utc-Dali-Thread.cpp diff --git a/automated-tests/src/dali-devel/utc-Dali-WeakHandle.cpp b/automated-tests/src/dali/utc-Dali-WeakHandle.cpp similarity index 100% rename from automated-tests/src/dali-devel/utc-Dali-WeakHandle.cpp rename to automated-tests/src/dali/utc-Dali-WeakHandle.cpp -- 2.7.4