From 3354d0934d49f671df97f5cc033be51d56f5f5ea Mon Sep 17 00:00:00 2001 From: David Steele Date: Mon, 24 Mar 2014 20:06:55 +0000 Subject: [PATCH] Migrating to new test framework [Issue#] N/A [Problem] [Cause] Web-Tct & testkit-lite used. [Solution] Migrate all local test cases to use testkit-lite on desktop and target [Verification] Desktop - run build.sh, then execute.sh. Open summary.xml in your browser to see the results. Target - run "sudo ./tcbuild build", then "./tcbuild install", then use tct-mgr to execute the tests on target. Change-Id: I9d0dee70b0704503f9e977298ec665a1fcc99563 Signed-off-by: David Steele --- automated-tests/.gitignore | 11 +- automated-tests/CMakeLists.txt | 11 + automated-tests/TET/.gitignore | 8 + automated-tests/{ => TET}/_export_desktop.sh | 0 automated-tests/{ => TET}/_export_env.sh | 0 automated-tests/{ => TET}/_export_sbs.sh | 0 automated-tests/{ => TET}/_export_target_env.sh | 0 automated-tests/TET/build.sh | 68 + automated-tests/{ => TET}/build_out.sh | 0 automated-tests/{ => TET}/coverage.mk | 0 automated-tests/TET/coverage.sh | 22 + .../image-factory/.gitignore | 0 .../image-factory}/Makefile | 0 .../image-factory/file.list | 0 .../dali-internal-test-suite/image-factory/tslist | 0 .../image-factory/utc-Dali-ImageFactory.cpp | 0 .../dali-internal-test-suite/master-makefile.mk | 0 .../dali-internal-test-suite}/material/.gitignore | 0 .../dali-internal-test-suite/material}/Makefile | 0 .../dali-internal-test-suite}/material/file.list | 0 .../dali-internal-test-suite/material/tslist | 0 .../material/utc-Dali-Material.cpp | 0 .../resource-manager/.gitignore | 0 .../resource-manager}/Makefile | 0 .../resource-manager/file.list | 0 .../resource-manager/tslist | 0 .../utc-DaliInternal-ResourceClient.cpp | 0 .../{ => TET}/dali-internal-test-suite/tc-gen.sh | 0 .../dali-internal-test-suite/text/.gitignore | 0 .../dali-internal-test-suite/text}/Makefile | 0 .../dali-internal-test-suite/text/file.list | 0 .../{ => TET}/dali-internal-test-suite/text/tslist | 0 .../text/utc-DaliInternal-Font.cpp | 0 .../utc-MODULE-CLASS.cpp.in | 0 .../dali-test-suite-internal-utils.h | 0 .../dali-test-suite-utils/dali-test-suite-utils.h | 0 .../{ => TET}/dali-test-suite-utils/mesh-builder.h | 0 .../dali-test-suite-utils/test-application.cpp | 0 .../dali-test-suite-utils/test-application.h | 0 .../dali-test-suite-utils/test-gesture-manager.h | 0 .../dali-test-suite-utils/test-gl-abstraction.h | 0 .../test-gl-sync-abstraction.h | 0 .../dali-test-suite-utils/test-native-image.h | 0 .../test-platform-abstraction.h | 0 .../dali-test-suite-utils/test-render-controller.h | 0 .../dali-test-suite-utils/test-trace-call-stack.h | 0 .../{ => TET}/dali-test-suite/actors/.gitignore | 0 .../dali-test-suite/actors}/Makefile | 0 .../{ => TET}/dali-test-suite/actors/file.list | 0 .../{ => TET}/dali-test-suite/actors/tslist | 0 .../dali-test-suite/actors/tslist-renderables | 0 .../dali-test-suite/actors/tslist-text-actor | 0 .../dali-test-suite/actors/utc-Dali-Actor.cpp | 0 .../dali-test-suite/actors/utc-Dali-BaseHandle.cpp | 0 .../actors/utc-Dali-CameraActor.cpp | 0 .../actors/utc-Dali-Constrainable.cpp | 0 .../actors/utc-Dali-CustomActor.cpp | 0 .../dali-test-suite/actors/utc-Dali-Handle.cpp | 0 .../dali-test-suite/actors/utc-Dali-ImageActor.cpp | 0 .../dali-test-suite/actors/utc-Dali-Layer.cpp | 0 .../dali-test-suite/actors/utc-Dali-LightActor.cpp | 0 .../dali-test-suite/actors/utc-Dali-MeshActor.cpp | 0 .../dali-test-suite/actors/utc-Dali-Model.cpp | 0 .../actors/utc-Dali-RenderableActor.cpp | 0 .../dali-test-suite/actors/utc-Dali-Stage.cpp | 0 .../dali-test-suite/actors/utc-Dali-TextActor.cpp | 0 .../{ => TET}/dali-test-suite/animation/.gitignore | 0 .../dali-test-suite/animation}/Makefile | 0 .../{ => TET}/dali-test-suite/animation/file.list | 0 .../{ => TET}/dali-test-suite/animation/tslist | 0 .../animation/utc-Dali-ActiveConstraint.cpp | 0 .../animation/utc-Dali-AlphaFunctions.cpp | 0 .../animation/utc-Dali-Animation.cpp | 0 .../animation/utc-Dali-Constraint.cpp | 0 .../{ => TET}/dali-test-suite/common/.gitignore | 0 .../dali-test-suite/common}/Makefile | 0 .../{ => TET}/dali-test-suite/common/file.list | 0 .../dali-test-suite/common}/tc-gen.sh | 0 .../{ => TET}/dali-test-suite/common/tslist | 0 .../dali-test-suite/common/utc-Dali-Any.cpp | 0 .../common/utc-Dali-LocklessBuffer.cpp | 0 .../dali-test-suite/common/utc-Dali-Vector.cpp | 0 .../{ => TET}/dali-test-suite/context/.gitignore | 0 .../math => TET/dali-test-suite/context}/Makefile | 0 .../{ => TET}/dali-test-suite/context/file.list | 0 .../{ => TET}/dali-test-suite/context/tslist | 0 .../dali-test-suite/context/utc-Dali-Context.cpp | 0 .../{ => TET}/dali-test-suite/dynamics/.gitignore | 0 .../{ => TET}/dali-test-suite/dynamics/Makefile | 0 .../{ => TET}/dali-test-suite/dynamics/file.list | 0 .../{ => TET}/dali-test-suite/dynamics/tslist | 0 .../dynamics/utc-Dali-DynamicsBody.cpp | 0 .../dynamics/utc-Dali-DynamicsBodyConfig.cpp | 0 .../dynamics/utc-Dali-DynamicsJoint.cpp | 0 .../dynamics/utc-Dali-DynamicsShape.cpp | 0 .../dynamics/utc-Dali-DynamicsWorld.cpp | 0 .../dynamics/utc-Dali-DynamicsWorldConfig.cpp | 0 .../{ => TET}/dali-test-suite/effects/.gitignore | 0 .../dali-test-suite/effects}/Makefile | 0 .../{ => TET}/dali-test-suite/effects/file.list | 0 .../{ => TET}/dali-test-suite/effects/tslist | 0 .../effects/utc-Dali-ShaderEffect.cpp | 0 .../{ => TET}/dali-test-suite/events/.gitignore | 0 .../images => TET/dali-test-suite/events}/Makefile | 0 .../{ => TET}/dali-test-suite/events/file.list | 0 .../{ => TET}/dali-test-suite/events/tslist | 0 .../events/utc-Dali-EventProcessing.cpp | 0 .../dali-test-suite/events/utc-Dali-Gesture.cpp | 0 .../events/utc-Dali-GestureDetector.cpp | 0 .../events/utc-Dali-HitTestAlgorithm.cpp | 0 .../dali-test-suite/events/utc-Dali-KeyEvent.cpp | 0 .../events/utc-Dali-LongPressGesture.cpp | 0 .../events/utc-Dali-LongPressGestureDetector.cpp | 0 .../events/utc-Dali-MouseWheelEvent.cpp | 0 .../dali-test-suite/events/utc-Dali-PanGesture.cpp | 0 .../events/utc-Dali-PanGestureDetector.cpp | 0 .../events/utc-Dali-PinchGesture.cpp | 0 .../events/utc-Dali-PinchGestureDetector.cpp | 0 .../dali-test-suite/events/utc-Dali-TapGesture.cpp | 0 .../events/utc-Dali-TapGestureDetector.cpp | 0 .../events/utc-Dali-TouchEventCombiner.cpp | 0 .../events/utc-Dali-TouchProcessing.cpp | 0 .../{ => TET}/dali-test-suite/geometry/.gitignore | 0 .../{ => TET}/dali-test-suite/geometry/Makefile | 0 .../{ => TET}/dali-test-suite/geometry/file.list | 0 .../{ => TET}/dali-test-suite/geometry/tslist | 0 .../geometry/utc-Dali-AnimatableMesh.cpp | 0 .../dali-test-suite/geometry/utc-Dali-MeshData.cpp | 0 .../dali-test-suite/geometry/utc-Dali-Spline.cpp | 0 .../{ => TET}/dali-test-suite/images/.gitignore | 0 .../events => TET/dali-test-suite/images}/Makefile | 0 .../{ => TET}/dali-test-suite/images/file.list | 0 .../{ => TET}/dali-test-suite/images/tslist | 0 .../images/utc-Dali-BitmapImage.cpp | 0 .../images/utc-Dali-DistanceField.cpp | 0 .../images/utc-Dali-EncodedBufferImage.cpp | 0 .../images/utc-Dali-FrameBufferImage.cpp | 0 .../dali-test-suite/images/utc-Dali-GlyphImage.cpp | 0 .../dali-test-suite/images/utc-Dali-Image.cpp | 0 .../images/utc-Dali-ImageAttributes.cpp | 0 .../dali-test-suite/images/utc-Dali-Pixel.cpp | 0 .../dali-test-suite/images/utc-MODULE-CLASS.cpp.in | 0 .../{ => TET}/dali-test-suite/master-makefile.mk | 0 .../dali-test-suite}/material/.gitignore | 0 .../dali-test-suite/material}/Makefile | 0 .../dali-test-suite}/material/file.list | 0 .../{ => TET}/dali-test-suite/material/tslist | 0 .../dali-test-suite/material/utc-Dali-Material.cpp | 0 .../{ => TET}/dali-test-suite/math/.gitignore | 0 .../context => TET/dali-test-suite/math}/Makefile | 0 .../{ => TET}/dali-test-suite/math/file.list | 0 .../{ => TET}/dali-test-suite/math/tslist | 0 .../dali-test-suite/math/utc-Dali-AngleAxis.cpp | 0 .../dali-test-suite/math/utc-Dali-Degree.cpp | 0 .../dali-test-suite/math/utc-Dali-MathUtils.cpp | 0 .../dali-test-suite/math/utc-Dali-Matrix.cpp | 0 .../dali-test-suite/math/utc-Dali-Matrix3.cpp | 0 .../dali-test-suite/math/utc-Dali-Quaternion.cpp | 0 .../dali-test-suite/math/utc-Dali-Radian.cpp | 0 .../dali-test-suite/math/utc-Dali-Random.cpp | 0 .../dali-test-suite/math/utc-Dali-Rect.cpp | 0 .../dali-test-suite/math/utc-Dali-Vector2.cpp | 0 .../dali-test-suite/math/utc-Dali-Vector3.cpp | 0 .../dali-test-suite/math/utc-Dali-Vector4.cpp | 0 .../dali-test-suite/object-registry/.gitignore | 0 .../dali-test-suite/object-registry}/Makefile | 0 .../dali-test-suite/object-registry/file.list | 0 .../dali-test-suite/object-registry/tslist | 0 .../object-registry/utc-Dali-ObjectRegistry.cpp | 0 .../property-notification/.gitignore | 0 .../property-notification}/Makefile | 0 .../property-notification/file.list | 0 .../dali-test-suite/property-notification/tslist | 0 .../utc-Dali-PropertyNotification.cpp | 0 .../dali-test-suite/render-tasks/.gitignore | 0 .../dali-test-suite/render-tasks}/Makefile | 0 .../dali-test-suite/render-tasks/file.list | 0 .../{ => TET}/dali-test-suite/render-tasks/tslist | 0 .../render-tasks/utc-Dali-RenderTask.cpp | 0 .../render-tasks/utc-Dali-RenderTaskList.cpp | 0 .../{ => TET}/dali-test-suite/scripting/.gitignore | 0 .../dali-test-suite/scripting}/Makefile | 0 .../{ => TET}/dali-test-suite/scripting/file.list | 0 .../{ => TET}/dali-test-suite/scripting/tslist | 0 .../scripting/utc-Dali-Scripting.cpp | 0 .../{ => TET}/dali-test-suite/signals/.gitignore | 0 .../dali-test-suite/signals}/Makefile | 0 .../{ => TET}/dali-test-suite/signals/file.list | 0 .../{ => TET}/dali-test-suite/signals/tslist | 0 .../signals/utc-Dali-SignalTemplatesFunctors.cpp | 0 .../signals/utc-Dali-SignalTemplatesV2.cpp | 0 .../common => TET/dali-test-suite}/tc-gen.sh | 0 .../{ => TET}/dali-test-suite/text/.gitignore | 0 .../material => TET/dali-test-suite/text}/Makefile | 0 .../{ => TET}/dali-test-suite/text/file.list | 0 .../{ => TET}/dali-test-suite/text/tslist | 0 .../dali-test-suite/text/utc-Dali-Character.cpp | 0 .../dali-test-suite/text/utc-Dali-Font.cpp | 0 .../text/utc-Dali-FontParameters.cpp | 0 .../dali-test-suite/text/utc-Dali-Text.cpp | 0 .../dali-test-suite/text/utc-Dali-TextStyle.cpp | 0 .../dali-test-suite/text/utc-Dali-Utf8.cpp | 0 .../dali-test-suite/type-registry/.gitignore | 0 .../dali-test-suite/type-registry}/Makefile | 0 .../dali-test-suite/type-registry/file.list | 0 .../{ => TET}/dali-test-suite/type-registry/tslist | 0 .../type-registry/utc-Dali-TypeRegistry.cpp | 0 .../dali-test-suite/utc-MODULE-CLASS.cpp.in | 0 automated-tests/{ => TET}/debug.sh | 0 automated-tests/{ => TET}/debug_target.sh | 0 automated-tests/TET/execute.sh | 42 + automated-tests/{ => TET}/execute_target.sh | 0 automated-tests/{ => TET}/file.list | 0 automated-tests/{ => TET}/rules.mk.in | 0 automated-tests/{ => TET}/tbp.pl | 0 automated-tests/{ => TET}/tet_scen | 0 automated-tests/{ => TET}/tetbuild.cfg | 0 automated-tests/{ => TET}/tetclean.cfg | 0 automated-tests/{ => TET}/tetexec.cfg | 0 automated-tests/build.sh | 79 +- automated-tests/coverage.sh | 10 +- automated-tests/execute.sh | 65 +- automated-tests/packaging/core-dali-tests.spec | 52 + .../packaging/core-dali-unmanaged-tests.spec | 53 + automated-tests/scripts/add_all_smack_rule.sh | 26 + automated-tests/scripts/add_smack_rule.sh | 28 + automated-tests/scripts/add_style.pl | 27 + automated-tests/scripts/all_smack.rule | 28 + automated-tests/scripts/autocompletion.sh | 18 + automated-tests/scripts/init.sh | 10 + automated-tests/scripts/retriever.sh | 197 + automated-tests/scripts/summarize.pl | 104 + automated-tests/scripts/tcbuild.sh | 213 + automated-tests/scripts/tcheadgen.sh | 71 + automated-tests/scripts/tcpackageslistsgen.sh | 72 + automated-tests/scripts/tctestsgen.sh | 66 + automated-tests/src/CMakeLists.txt | 6 + automated-tests/src/common/assert.h | 82 + automated-tests/src/common/testcase.h | 18 + automated-tests/src/dali-internal/CMakeLists.txt | 52 + .../src/dali-internal/tct-dali-internal-core.cpp | 31 + .../src/dali-internal/tct-dali-internal-core.h | 126 + .../src/dali-internal/utc-Dali-ImageFactory.cpp | 584 ++ .../src/dali-internal/utc-Dali-Material.cpp | 735 ++ .../src/dali-internal/utc-DaliInternal-Font.cpp | 146 + .../utc-DaliInternal-ResourceClient.cpp | 1419 ++++ automated-tests/src/dali-unmanaged/CMakeLists.txt | 75 + .../dali-test-suite-utils/mesh-builder.cpp | 238 + .../dali-test-suite-utils/mesh-builder.h | 44 + .../dali-test-suite-utils/test-dynamics.cpp | 182 + .../dali-test-suite-utils/test-dynamics.h | 322 + .../test-platform-abstraction.cpp | 641 ++ .../test-platform-abstraction.h | 348 + .../src/dali-unmanaged/tct-dali-unmanaged-core.cpp | 31 + .../src/dali-unmanaged/tct-dali-unmanaged-core.h | 506 ++ .../src/dali-unmanaged/utc-Dali-Constrainable.cpp | 88 + .../src/dali-unmanaged/utc-Dali-Context.cpp | 240 + .../src/dali-unmanaged/utc-Dali-CustomActor.cpp | 293 + .../src/dali-unmanaged/utc-Dali-DistanceField.cpp | 67 + .../src/dali-unmanaged/utc-Dali-DynamicsBody.cpp | 553 ++ .../dali-unmanaged/utc-Dali-DynamicsBodyConfig.cpp | 606 ++ .../src/dali-unmanaged/utc-Dali-DynamicsJoint.cpp | 342 + .../src/dali-unmanaged/utc-Dali-DynamicsShape.cpp | 265 + .../src/dali-unmanaged/utc-Dali-DynamicsWorld.cpp | 191 + .../utc-Dali-DynamicsWorldConfig.cpp | 86 + .../dali-unmanaged/utc-Dali-EncodedBufferImage.cpp | 852 ++ .../dali-unmanaged/utc-Dali-HitTestAlgorithm.cpp | 404 + .../src/dali-unmanaged/utc-Dali-LightActor.cpp | 304 + .../src/dali-unmanaged/utc-Dali-LocklessBuffer.cpp | 116 + .../src/dali-unmanaged/utc-Dali-MeshActor.cpp | 840 ++ .../src/dali-unmanaged/utc-Dali-MeshData.cpp | 331 + .../src/dali-unmanaged/utc-Dali-Model.cpp | 642 ++ .../dali-unmanaged/utc-Dali-MouseWheelEvent.cpp | 274 + .../src/dali-unmanaged/utc-Dali-ObjectRegistry.cpp | 527 ++ .../src/dali-unmanaged/utc-Dali-Random.cpp | 97 + .../src/dali-unmanaged/utc-Dali-RenderTask.cpp | 128 + .../src/dali-unmanaged/utc-Dali-Scripting.cpp | 1037 +++ .../src/dali-unmanaged/utc-Dali-ShaderEffect.cpp | 215 + .../src/dali-unmanaged/utc-Dali-Spline.cpp | 634 ++ .../src/dali-unmanaged/utc-Dali-TypeRegistry.cpp | 1111 +++ .../src/dali-unmanaged/utc-Dali-Utf8.cpp | 44 + .../src/dali-unmanaged/utc-Dali-Vector.cpp | 796 ++ automated-tests/src/dali/CMakeLists.txt | 104 + .../dali-test-suite-utils.cpp | 364 + .../dali-test-suite-utils/dali-test-suite-utils.h | 404 + .../dali-test-suite-utils/test-application.cpp | 195 + .../dali/dali-test-suite-utils/test-application.h | 99 + .../dali-test-suite-utils/test-gesture-manager.cpp | 102 + .../dali-test-suite-utils/test-gesture-manager.h | 92 + .../dali-test-suite-utils/test-gl-abstraction.cpp | 90 + .../dali-test-suite-utils/test-gl-abstraction.h | 1833 ++++ .../test-gl-sync-abstraction.cpp | 135 + .../test-gl-sync-abstraction.h | 112 + .../dali-test-suite-utils/test-native-image.cpp | 39 + .../dali/dali-test-suite-utils/test-native-image.h | 51 + .../test-platform-abstraction.cpp | 637 ++ .../test-platform-abstraction.h | 350 + .../test-render-controller.cpp | 59 + .../dali-test-suite-utils/test-render-controller.h | 53 + .../test-trace-call-stack.cpp | 111 + .../dali-test-suite-utils/test-trace-call-stack.h | 96 + automated-tests/src/dali/tct-dali-core.cpp | 31 + automated-tests/src/dali/tct-dali-core.h | 2532 ++++++ .../src/dali/utc-Dali-ActiveConstraint.cpp | 335 + automated-tests/src/dali/utc-Dali-Actor.cpp | 2853 +++++++ .../src/dali/utc-Dali-AlphaFunctions.cpp | 370 + automated-tests/src/dali/utc-Dali-AngleAxis.cpp | 99 + .../src/dali/utc-Dali-AnimatableMesh.cpp | 444 + automated-tests/src/dali/utc-Dali-Animation.cpp | 8867 ++++++++++++++++++++ automated-tests/src/dali/utc-Dali-Any.cpp | 244 + automated-tests/src/dali/utc-Dali-BaseHandle.cpp | 460 + automated-tests/src/dali/utc-Dali-BitmapImage.cpp | 511 ++ automated-tests/src/dali/utc-Dali-CameraActor.cpp | 986 +++ automated-tests/src/dali/utc-Dali-Character.cpp | 161 + automated-tests/src/dali/utc-Dali-Constraint.cpp | 4028 +++++++++ automated-tests/src/dali/utc-Dali-CustomActor.cpp | 1577 ++++ automated-tests/src/dali/utc-Dali-Degree.cpp | 151 + .../src/dali/utc-Dali-EventProcessing.cpp | 86 + automated-tests/src/dali/utc-Dali-Font.cpp | 546 ++ .../src/dali/utc-Dali-FontParameters.cpp | 135 + .../src/dali/utc-Dali-FrameBufferImage.cpp | 109 + automated-tests/src/dali/utc-Dali-Gesture.cpp | 84 + .../src/dali/utc-Dali-GestureDetector.cpp | 405 + automated-tests/src/dali/utc-Dali-Handle.cpp | 909 ++ automated-tests/src/dali/utc-Dali-Image.cpp | 1094 +++ automated-tests/src/dali/utc-Dali-ImageActor.cpp | 940 +++ .../src/dali/utc-Dali-ImageAttributes.cpp | 112 + automated-tests/src/dali/utc-Dali-KeyEvent.cpp | 270 + automated-tests/src/dali/utc-Dali-Layer.cpp | 513 ++ .../src/dali/utc-Dali-LongPressGesture.cpp | 71 + .../src/dali/utc-Dali-LongPressGestureDetector.cpp | 1266 +++ automated-tests/src/dali/utc-Dali-Material.cpp | 331 + automated-tests/src/dali/utc-Dali-MathUtils.cpp | 261 + automated-tests/src/dali/utc-Dali-Matrix.cpp | 742 ++ automated-tests/src/dali/utc-Dali-Matrix3.cpp | 383 + automated-tests/src/dali/utc-Dali-MeshActor.cpp | 95 + automated-tests/src/dali/utc-Dali-PanGesture.cpp | 130 + .../src/dali/utc-Dali-PanGestureDetector.cpp | 1999 +++++ automated-tests/src/dali/utc-Dali-PinchGesture.cpp | 94 + .../src/dali/utc-Dali-PinchGestureDetector.cpp | 1185 +++ automated-tests/src/dali/utc-Dali-Pixel.cpp | 179 + .../src/dali/utc-Dali-PropertyNotification.cpp | 843 ++ automated-tests/src/dali/utc-Dali-Quaternion.cpp | 1090 +++ automated-tests/src/dali/utc-Dali-Radian.cpp | 155 + automated-tests/src/dali/utc-Dali-Rect.cpp | 277 + automated-tests/src/dali/utc-Dali-RenderTask.cpp | 2555 ++++++ .../src/dali/utc-Dali-RenderTaskList.cpp | 138 + .../src/dali/utc-Dali-RenderableActor.cpp | 503 ++ automated-tests/src/dali/utc-Dali-ShaderEffect.cpp | 1011 +++ .../src/dali/utc-Dali-SignalTemplatesFunctors.cpp | 512 ++ .../src/dali/utc-Dali-SignalTemplatesV2.cpp | 2618 ++++++ automated-tests/src/dali/utc-Dali-Stage.cpp | 596 ++ automated-tests/src/dali/utc-Dali-TapGesture.cpp | 74 + .../src/dali/utc-Dali-TapGestureDetector.cpp | 1172 +++ automated-tests/src/dali/utc-Dali-Text.cpp | 305 + automated-tests/src/dali/utc-Dali-TextActor.cpp | 822 ++ automated-tests/src/dali/utc-Dali-TextStyle.cpp | 511 ++ .../src/dali/utc-Dali-TouchEventCombiner.cpp | 774 ++ .../src/dali/utc-Dali-TouchProcessing.cpp | 1193 +++ automated-tests/src/dali/utc-Dali-Vector2.cpp | 405 + automated-tests/src/dali/utc-Dali-Vector3.cpp | 601 ++ automated-tests/src/dali/utc-Dali-Vector4.cpp | 532 ++ automated-tests/style/application.js | 194 + automated-tests/style/back_top.png | Bin 0 -> 1122 bytes automated-tests/style/blue.jpg | Bin 0 -> 954 bytes automated-tests/style/gray.jpg | Bin 0 -> 866 bytes automated-tests/style/jquery.min.js | 4 + automated-tests/style/orange.jpg | Bin 0 -> 934 bytes automated-tests/style/popup.js | 1215 +++ automated-tests/style/red.jpg | Bin 0 -> 937 bytes automated-tests/style/summary.xsl | 352 + automated-tests/style/testresult.xsl | 571 ++ automated-tests/style/tests.css | 195 + automated-tests/tcbuild | 1 + build/slp/Makefile.am | 4 +- build/slp/configure.ac | 2 +- build/slp/dali-core/Makefile.am | 4 +- 377 files changed, 77574 insertions(+), 119 deletions(-) create mode 100644 automated-tests/CMakeLists.txt create mode 100644 automated-tests/TET/.gitignore rename automated-tests/{ => TET}/_export_desktop.sh (100%) rename automated-tests/{ => TET}/_export_env.sh (100%) rename automated-tests/{ => TET}/_export_sbs.sh (100%) rename automated-tests/{ => TET}/_export_target_env.sh (100%) create mode 100755 automated-tests/TET/build.sh rename automated-tests/{ => TET}/build_out.sh (100%) rename automated-tests/{ => TET}/coverage.mk (100%) create mode 100755 automated-tests/TET/coverage.sh rename automated-tests/{ => TET}/dali-internal-test-suite/image-factory/.gitignore (100%) rename automated-tests/{dali-test-suite/type-registry => TET/dali-internal-test-suite/image-factory}/Makefile (100%) rename automated-tests/{ => TET}/dali-internal-test-suite/image-factory/file.list (100%) rename automated-tests/{ => TET}/dali-internal-test-suite/image-factory/tslist (100%) rename automated-tests/{ => TET}/dali-internal-test-suite/image-factory/utc-Dali-ImageFactory.cpp (100%) rename automated-tests/{ => TET}/dali-internal-test-suite/master-makefile.mk (100%) rename automated-tests/{dali-test-suite => TET/dali-internal-test-suite}/material/.gitignore (100%) rename automated-tests/{dali-test-suite/text => TET/dali-internal-test-suite/material}/Makefile (100%) rename automated-tests/{dali-test-suite => TET/dali-internal-test-suite}/material/file.list (100%) rename automated-tests/{ => TET}/dali-internal-test-suite/material/tslist (100%) rename automated-tests/{ => TET}/dali-internal-test-suite/material/utc-Dali-Material.cpp (100%) rename automated-tests/{ => TET}/dali-internal-test-suite/resource-manager/.gitignore (100%) rename automated-tests/{dali-test-suite/signals => TET/dali-internal-test-suite/resource-manager}/Makefile (100%) rename automated-tests/{ => TET}/dali-internal-test-suite/resource-manager/file.list (100%) rename automated-tests/{ => TET}/dali-internal-test-suite/resource-manager/tslist (100%) rename automated-tests/{ => TET}/dali-internal-test-suite/resource-manager/utc-DaliInternal-ResourceClient.cpp (100%) rename automated-tests/{ => TET}/dali-internal-test-suite/tc-gen.sh (100%) rename automated-tests/{ => TET}/dali-internal-test-suite/text/.gitignore (100%) rename automated-tests/{dali-test-suite/scripting => TET/dali-internal-test-suite/text}/Makefile (100%) rename automated-tests/{ => TET}/dali-internal-test-suite/text/file.list (100%) rename automated-tests/{ => TET}/dali-internal-test-suite/text/tslist (100%) rename automated-tests/{ => TET}/dali-internal-test-suite/text/utc-DaliInternal-Font.cpp (100%) rename automated-tests/{ => TET}/dali-internal-test-suite/utc-MODULE-CLASS.cpp.in (100%) rename automated-tests/{ => TET}/dali-test-suite-utils/dali-test-suite-internal-utils.h (100%) rename automated-tests/{ => TET}/dali-test-suite-utils/dali-test-suite-utils.h (100%) rename automated-tests/{ => TET}/dali-test-suite-utils/mesh-builder.h (100%) rename automated-tests/{ => TET}/dali-test-suite-utils/test-application.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite-utils/test-application.h (100%) rename automated-tests/{ => TET}/dali-test-suite-utils/test-gesture-manager.h (100%) rename automated-tests/{ => TET}/dali-test-suite-utils/test-gl-abstraction.h (100%) rename automated-tests/{ => TET}/dali-test-suite-utils/test-gl-sync-abstraction.h (100%) rename automated-tests/{ => TET}/dali-test-suite-utils/test-native-image.h (100%) rename automated-tests/{ => TET}/dali-test-suite-utils/test-platform-abstraction.h (100%) rename automated-tests/{ => TET}/dali-test-suite-utils/test-render-controller.h (100%) rename automated-tests/{ => TET}/dali-test-suite-utils/test-trace-call-stack.h (100%) rename automated-tests/{ => TET}/dali-test-suite/actors/.gitignore (100%) rename automated-tests/{dali-test-suite/render-tasks => TET/dali-test-suite/actors}/Makefile (100%) rename automated-tests/{ => TET}/dali-test-suite/actors/file.list (100%) rename automated-tests/{ => TET}/dali-test-suite/actors/tslist (100%) rename automated-tests/{ => TET}/dali-test-suite/actors/tslist-renderables (100%) rename automated-tests/{ => TET}/dali-test-suite/actors/tslist-text-actor (100%) rename automated-tests/{ => TET}/dali-test-suite/actors/utc-Dali-Actor.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/actors/utc-Dali-BaseHandle.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/actors/utc-Dali-CameraActor.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/actors/utc-Dali-Constrainable.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/actors/utc-Dali-CustomActor.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/actors/utc-Dali-Handle.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/actors/utc-Dali-ImageActor.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/actors/utc-Dali-Layer.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/actors/utc-Dali-LightActor.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/actors/utc-Dali-MeshActor.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/actors/utc-Dali-Model.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/actors/utc-Dali-RenderableActor.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/actors/utc-Dali-Stage.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/actors/utc-Dali-TextActor.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/animation/.gitignore (100%) rename automated-tests/{dali-test-suite/property-notification => TET/dali-test-suite/animation}/Makefile (100%) rename automated-tests/{ => TET}/dali-test-suite/animation/file.list (100%) rename automated-tests/{ => TET}/dali-test-suite/animation/tslist (100%) rename automated-tests/{ => TET}/dali-test-suite/animation/utc-Dali-ActiveConstraint.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/animation/utc-Dali-AlphaFunctions.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/animation/utc-Dali-Animation.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/animation/utc-Dali-Constraint.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/common/.gitignore (100%) rename automated-tests/{dali-test-suite/object-registry => TET/dali-test-suite/common}/Makefile (100%) rename automated-tests/{ => TET}/dali-test-suite/common/file.list (100%) rename automated-tests/{dali-test-suite => TET/dali-test-suite/common}/tc-gen.sh (100%) rename automated-tests/{ => TET}/dali-test-suite/common/tslist (100%) rename automated-tests/{ => TET}/dali-test-suite/common/utc-Dali-Any.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/common/utc-Dali-LocklessBuffer.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/common/utc-Dali-Vector.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/context/.gitignore (100%) rename automated-tests/{dali-test-suite/math => TET/dali-test-suite/context}/Makefile (100%) rename automated-tests/{ => TET}/dali-test-suite/context/file.list (100%) rename automated-tests/{ => TET}/dali-test-suite/context/tslist (100%) rename automated-tests/{ => TET}/dali-test-suite/context/utc-Dali-Context.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/dynamics/.gitignore (100%) rename automated-tests/{ => TET}/dali-test-suite/dynamics/Makefile (100%) rename automated-tests/{ => TET}/dali-test-suite/dynamics/file.list (100%) rename automated-tests/{ => TET}/dali-test-suite/dynamics/tslist (100%) rename automated-tests/{ => TET}/dali-test-suite/dynamics/utc-Dali-DynamicsBody.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/dynamics/utc-Dali-DynamicsBodyConfig.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/dynamics/utc-Dali-DynamicsJoint.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/dynamics/utc-Dali-DynamicsShape.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/dynamics/utc-Dali-DynamicsWorld.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/dynamics/utc-Dali-DynamicsWorldConfig.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/effects/.gitignore (100%) rename automated-tests/{dali-test-suite/material => TET/dali-test-suite/effects}/Makefile (100%) rename automated-tests/{ => TET}/dali-test-suite/effects/file.list (100%) rename automated-tests/{ => TET}/dali-test-suite/effects/tslist (100%) rename automated-tests/{ => TET}/dali-test-suite/effects/utc-Dali-ShaderEffect.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/events/.gitignore (100%) rename automated-tests/{dali-test-suite/images => TET/dali-test-suite/events}/Makefile (100%) rename automated-tests/{ => TET}/dali-test-suite/events/file.list (100%) rename automated-tests/{ => TET}/dali-test-suite/events/tslist (100%) rename automated-tests/{ => TET}/dali-test-suite/events/utc-Dali-EventProcessing.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/events/utc-Dali-Gesture.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/events/utc-Dali-GestureDetector.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/events/utc-Dali-HitTestAlgorithm.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/events/utc-Dali-KeyEvent.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/events/utc-Dali-LongPressGesture.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/events/utc-Dali-LongPressGestureDetector.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/events/utc-Dali-MouseWheelEvent.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/events/utc-Dali-PanGesture.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/events/utc-Dali-PanGestureDetector.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/events/utc-Dali-PinchGesture.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/events/utc-Dali-PinchGestureDetector.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/events/utc-Dali-TapGesture.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/events/utc-Dali-TapGestureDetector.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/events/utc-Dali-TouchEventCombiner.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/events/utc-Dali-TouchProcessing.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/geometry/.gitignore (100%) rename automated-tests/{ => TET}/dali-test-suite/geometry/Makefile (100%) rename automated-tests/{ => TET}/dali-test-suite/geometry/file.list (100%) rename automated-tests/{ => TET}/dali-test-suite/geometry/tslist (100%) rename automated-tests/{ => TET}/dali-test-suite/geometry/utc-Dali-AnimatableMesh.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/geometry/utc-Dali-MeshData.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/geometry/utc-Dali-Spline.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/images/.gitignore (100%) rename automated-tests/{dali-test-suite/events => TET/dali-test-suite/images}/Makefile (100%) rename automated-tests/{ => TET}/dali-test-suite/images/file.list (100%) rename automated-tests/{ => TET}/dali-test-suite/images/tslist (100%) rename automated-tests/{ => TET}/dali-test-suite/images/utc-Dali-BitmapImage.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/images/utc-Dali-DistanceField.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/images/utc-Dali-EncodedBufferImage.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/images/utc-Dali-FrameBufferImage.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/images/utc-Dali-GlyphImage.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/images/utc-Dali-Image.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/images/utc-Dali-ImageAttributes.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/images/utc-Dali-Pixel.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/images/utc-MODULE-CLASS.cpp.in (100%) rename automated-tests/{ => TET}/dali-test-suite/master-makefile.mk (100%) rename automated-tests/{dali-internal-test-suite => TET/dali-test-suite}/material/.gitignore (100%) rename automated-tests/{dali-test-suite/effects => TET/dali-test-suite/material}/Makefile (100%) rename automated-tests/{dali-internal-test-suite => TET/dali-test-suite}/material/file.list (100%) rename automated-tests/{ => TET}/dali-test-suite/material/tslist (100%) rename automated-tests/{ => TET}/dali-test-suite/material/utc-Dali-Material.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/math/.gitignore (100%) rename automated-tests/{dali-test-suite/context => TET/dali-test-suite/math}/Makefile (100%) rename automated-tests/{ => TET}/dali-test-suite/math/file.list (100%) rename automated-tests/{ => TET}/dali-test-suite/math/tslist (100%) rename automated-tests/{ => TET}/dali-test-suite/math/utc-Dali-AngleAxis.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/math/utc-Dali-Degree.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/math/utc-Dali-MathUtils.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/math/utc-Dali-Matrix.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/math/utc-Dali-Matrix3.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/math/utc-Dali-Quaternion.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/math/utc-Dali-Radian.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/math/utc-Dali-Random.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/math/utc-Dali-Rect.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/math/utc-Dali-Vector2.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/math/utc-Dali-Vector3.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/math/utc-Dali-Vector4.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/object-registry/.gitignore (100%) rename automated-tests/{dali-test-suite/common => TET/dali-test-suite/object-registry}/Makefile (100%) rename automated-tests/{ => TET}/dali-test-suite/object-registry/file.list (100%) rename automated-tests/{ => TET}/dali-test-suite/object-registry/tslist (100%) rename automated-tests/{ => TET}/dali-test-suite/object-registry/utc-Dali-ObjectRegistry.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/property-notification/.gitignore (100%) rename automated-tests/{dali-test-suite/animation => TET/dali-test-suite/property-notification}/Makefile (100%) rename automated-tests/{ => TET}/dali-test-suite/property-notification/file.list (100%) rename automated-tests/{ => TET}/dali-test-suite/property-notification/tslist (100%) rename automated-tests/{ => TET}/dali-test-suite/property-notification/utc-Dali-PropertyNotification.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/render-tasks/.gitignore (100%) rename automated-tests/{dali-test-suite/actors => TET/dali-test-suite/render-tasks}/Makefile (100%) rename automated-tests/{ => TET}/dali-test-suite/render-tasks/file.list (100%) rename automated-tests/{ => TET}/dali-test-suite/render-tasks/tslist (100%) rename automated-tests/{ => TET}/dali-test-suite/render-tasks/utc-Dali-RenderTask.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/render-tasks/utc-Dali-RenderTaskList.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/scripting/.gitignore (100%) rename automated-tests/{dali-internal-test-suite/text => TET/dali-test-suite/scripting}/Makefile (100%) rename automated-tests/{ => TET}/dali-test-suite/scripting/file.list (100%) rename automated-tests/{ => TET}/dali-test-suite/scripting/tslist (100%) rename automated-tests/{ => TET}/dali-test-suite/scripting/utc-Dali-Scripting.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/signals/.gitignore (100%) rename automated-tests/{dali-internal-test-suite/resource-manager => TET/dali-test-suite/signals}/Makefile (100%) rename automated-tests/{ => TET}/dali-test-suite/signals/file.list (100%) rename automated-tests/{ => TET}/dali-test-suite/signals/tslist (100%) rename automated-tests/{ => TET}/dali-test-suite/signals/utc-Dali-SignalTemplatesFunctors.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/signals/utc-Dali-SignalTemplatesV2.cpp (100%) rename automated-tests/{dali-test-suite/common => TET/dali-test-suite}/tc-gen.sh (100%) rename automated-tests/{ => TET}/dali-test-suite/text/.gitignore (100%) rename automated-tests/{dali-internal-test-suite/material => TET/dali-test-suite/text}/Makefile (100%) rename automated-tests/{ => TET}/dali-test-suite/text/file.list (100%) rename automated-tests/{ => TET}/dali-test-suite/text/tslist (100%) rename automated-tests/{ => TET}/dali-test-suite/text/utc-Dali-Character.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/text/utc-Dali-Font.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/text/utc-Dali-FontParameters.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/text/utc-Dali-Text.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/text/utc-Dali-TextStyle.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/text/utc-Dali-Utf8.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/type-registry/.gitignore (100%) rename automated-tests/{dali-internal-test-suite/image-factory => TET/dali-test-suite/type-registry}/Makefile (100%) rename automated-tests/{ => TET}/dali-test-suite/type-registry/file.list (100%) rename automated-tests/{ => TET}/dali-test-suite/type-registry/tslist (100%) rename automated-tests/{ => TET}/dali-test-suite/type-registry/utc-Dali-TypeRegistry.cpp (100%) rename automated-tests/{ => TET}/dali-test-suite/utc-MODULE-CLASS.cpp.in (100%) rename automated-tests/{ => TET}/debug.sh (100%) rename automated-tests/{ => TET}/debug_target.sh (100%) create mode 100755 automated-tests/TET/execute.sh rename automated-tests/{ => TET}/execute_target.sh (100%) rename automated-tests/{ => TET}/file.list (100%) rename automated-tests/{ => TET}/rules.mk.in (100%) rename automated-tests/{ => TET}/tbp.pl (100%) rename automated-tests/{ => TET}/tet_scen (100%) rename automated-tests/{ => TET}/tetbuild.cfg (100%) rename automated-tests/{ => TET}/tetclean.cfg (100%) rename automated-tests/{ => TET}/tetexec.cfg (100%) create mode 100644 automated-tests/packaging/core-dali-tests.spec create mode 100644 automated-tests/packaging/core-dali-unmanaged-tests.spec create mode 100755 automated-tests/scripts/add_all_smack_rule.sh create mode 100755 automated-tests/scripts/add_smack_rule.sh create mode 100755 automated-tests/scripts/add_style.pl create mode 100644 automated-tests/scripts/all_smack.rule create mode 100755 automated-tests/scripts/autocompletion.sh create mode 100755 automated-tests/scripts/init.sh create mode 100755 automated-tests/scripts/retriever.sh create mode 100755 automated-tests/scripts/summarize.pl create mode 100755 automated-tests/scripts/tcbuild.sh create mode 100755 automated-tests/scripts/tcheadgen.sh create mode 100755 automated-tests/scripts/tcpackageslistsgen.sh create mode 100755 automated-tests/scripts/tctestsgen.sh create mode 100644 automated-tests/src/CMakeLists.txt create mode 100644 automated-tests/src/common/assert.h create mode 100644 automated-tests/src/common/testcase.h create mode 100644 automated-tests/src/dali-internal/CMakeLists.txt create mode 100644 automated-tests/src/dali-internal/tct-dali-internal-core.cpp create mode 100644 automated-tests/src/dali-internal/tct-dali-internal-core.h create mode 100644 automated-tests/src/dali-internal/utc-Dali-ImageFactory.cpp create mode 100644 automated-tests/src/dali-internal/utc-Dali-Material.cpp create mode 100644 automated-tests/src/dali-internal/utc-DaliInternal-Font.cpp create mode 100644 automated-tests/src/dali-internal/utc-DaliInternal-ResourceClient.cpp create mode 100644 automated-tests/src/dali-unmanaged/CMakeLists.txt create mode 100644 automated-tests/src/dali-unmanaged/dali-test-suite-utils/mesh-builder.cpp create mode 100644 automated-tests/src/dali-unmanaged/dali-test-suite-utils/mesh-builder.h create mode 100644 automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-dynamics.cpp create mode 100644 automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-dynamics.h create mode 100644 automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-platform-abstraction.cpp create mode 100644 automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-platform-abstraction.h create mode 100644 automated-tests/src/dali-unmanaged/tct-dali-unmanaged-core.cpp create mode 100644 automated-tests/src/dali-unmanaged/tct-dali-unmanaged-core.h create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-Constrainable.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-Context.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-CustomActor.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-DistanceField.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-DynamicsBody.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-DynamicsBodyConfig.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-DynamicsJoint.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-DynamicsShape.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-DynamicsWorld.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-DynamicsWorldConfig.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-EncodedBufferImage.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-HitTestAlgorithm.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-LightActor.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-LocklessBuffer.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-MeshActor.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-MeshData.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-Model.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-MouseWheelEvent.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-ObjectRegistry.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-Random.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-RenderTask.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-Scripting.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-ShaderEffect.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-Spline.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-TypeRegistry.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-Utf8.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-Vector.cpp create mode 100644 automated-tests/src/dali/CMakeLists.txt create mode 100644 automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.cpp create mode 100644 automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.h create mode 100644 automated-tests/src/dali/dali-test-suite-utils/test-application.cpp create mode 100644 automated-tests/src/dali/dali-test-suite-utils/test-application.h create mode 100644 automated-tests/src/dali/dali-test-suite-utils/test-gesture-manager.cpp create mode 100644 automated-tests/src/dali/dali-test-suite-utils/test-gesture-manager.h create mode 100644 automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.cpp create mode 100644 automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.h create mode 100644 automated-tests/src/dali/dali-test-suite-utils/test-gl-sync-abstraction.cpp create mode 100644 automated-tests/src/dali/dali-test-suite-utils/test-gl-sync-abstraction.h create mode 100644 automated-tests/src/dali/dali-test-suite-utils/test-native-image.cpp create mode 100644 automated-tests/src/dali/dali-test-suite-utils/test-native-image.h create mode 100644 automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.cpp create mode 100644 automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.h create mode 100644 automated-tests/src/dali/dali-test-suite-utils/test-render-controller.cpp create mode 100644 automated-tests/src/dali/dali-test-suite-utils/test-render-controller.h create mode 100644 automated-tests/src/dali/dali-test-suite-utils/test-trace-call-stack.cpp create mode 100644 automated-tests/src/dali/dali-test-suite-utils/test-trace-call-stack.h create mode 100644 automated-tests/src/dali/tct-dali-core.cpp create mode 100644 automated-tests/src/dali/tct-dali-core.h create mode 100644 automated-tests/src/dali/utc-Dali-ActiveConstraint.cpp create mode 100644 automated-tests/src/dali/utc-Dali-Actor.cpp create mode 100644 automated-tests/src/dali/utc-Dali-AlphaFunctions.cpp create mode 100644 automated-tests/src/dali/utc-Dali-AngleAxis.cpp create mode 100644 automated-tests/src/dali/utc-Dali-AnimatableMesh.cpp create mode 100644 automated-tests/src/dali/utc-Dali-Animation.cpp create mode 100644 automated-tests/src/dali/utc-Dali-Any.cpp create mode 100644 automated-tests/src/dali/utc-Dali-BaseHandle.cpp create mode 100644 automated-tests/src/dali/utc-Dali-BitmapImage.cpp create mode 100644 automated-tests/src/dali/utc-Dali-CameraActor.cpp create mode 100644 automated-tests/src/dali/utc-Dali-Character.cpp create mode 100644 automated-tests/src/dali/utc-Dali-Constraint.cpp create mode 100644 automated-tests/src/dali/utc-Dali-CustomActor.cpp create mode 100644 automated-tests/src/dali/utc-Dali-Degree.cpp create mode 100644 automated-tests/src/dali/utc-Dali-EventProcessing.cpp create mode 100644 automated-tests/src/dali/utc-Dali-Font.cpp create mode 100644 automated-tests/src/dali/utc-Dali-FontParameters.cpp create mode 100644 automated-tests/src/dali/utc-Dali-FrameBufferImage.cpp create mode 100644 automated-tests/src/dali/utc-Dali-Gesture.cpp create mode 100644 automated-tests/src/dali/utc-Dali-GestureDetector.cpp create mode 100644 automated-tests/src/dali/utc-Dali-Handle.cpp create mode 100644 automated-tests/src/dali/utc-Dali-Image.cpp create mode 100644 automated-tests/src/dali/utc-Dali-ImageActor.cpp create mode 100644 automated-tests/src/dali/utc-Dali-ImageAttributes.cpp create mode 100644 automated-tests/src/dali/utc-Dali-KeyEvent.cpp create mode 100644 automated-tests/src/dali/utc-Dali-Layer.cpp create mode 100644 automated-tests/src/dali/utc-Dali-LongPressGesture.cpp create mode 100644 automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp create mode 100644 automated-tests/src/dali/utc-Dali-Material.cpp create mode 100644 automated-tests/src/dali/utc-Dali-MathUtils.cpp create mode 100644 automated-tests/src/dali/utc-Dali-Matrix.cpp create mode 100644 automated-tests/src/dali/utc-Dali-Matrix3.cpp create mode 100644 automated-tests/src/dali/utc-Dali-MeshActor.cpp create mode 100644 automated-tests/src/dali/utc-Dali-PanGesture.cpp create mode 100644 automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp create mode 100644 automated-tests/src/dali/utc-Dali-PinchGesture.cpp create mode 100644 automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp create mode 100644 automated-tests/src/dali/utc-Dali-Pixel.cpp create mode 100644 automated-tests/src/dali/utc-Dali-PropertyNotification.cpp create mode 100644 automated-tests/src/dali/utc-Dali-Quaternion.cpp create mode 100644 automated-tests/src/dali/utc-Dali-Radian.cpp create mode 100644 automated-tests/src/dali/utc-Dali-Rect.cpp create mode 100644 automated-tests/src/dali/utc-Dali-RenderTask.cpp create mode 100644 automated-tests/src/dali/utc-Dali-RenderTaskList.cpp create mode 100644 automated-tests/src/dali/utc-Dali-RenderableActor.cpp create mode 100644 automated-tests/src/dali/utc-Dali-ShaderEffect.cpp create mode 100644 automated-tests/src/dali/utc-Dali-SignalTemplatesFunctors.cpp create mode 100644 automated-tests/src/dali/utc-Dali-SignalTemplatesV2.cpp create mode 100644 automated-tests/src/dali/utc-Dali-Stage.cpp create mode 100644 automated-tests/src/dali/utc-Dali-TapGesture.cpp create mode 100644 automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp create mode 100644 automated-tests/src/dali/utc-Dali-Text.cpp create mode 100644 automated-tests/src/dali/utc-Dali-TextActor.cpp create mode 100644 automated-tests/src/dali/utc-Dali-TextStyle.cpp create mode 100644 automated-tests/src/dali/utc-Dali-TouchEventCombiner.cpp create mode 100644 automated-tests/src/dali/utc-Dali-TouchProcessing.cpp create mode 100644 automated-tests/src/dali/utc-Dali-Vector2.cpp create mode 100644 automated-tests/src/dali/utc-Dali-Vector3.cpp create mode 100644 automated-tests/src/dali/utc-Dali-Vector4.cpp create mode 100644 automated-tests/style/application.js create mode 100644 automated-tests/style/back_top.png create mode 100644 automated-tests/style/blue.jpg create mode 100644 automated-tests/style/gray.jpg create mode 100644 automated-tests/style/jquery.min.js create mode 100644 automated-tests/style/orange.jpg create mode 100644 automated-tests/style/popup.js create mode 100644 automated-tests/style/red.jpg create mode 100644 automated-tests/style/summary.xsl create mode 100644 automated-tests/style/testresult.xsl create mode 100644 automated-tests/style/tests.css create mode 120000 automated-tests/tcbuild diff --git a/automated-tests/.gitignore b/automated-tests/.gitignore index 8af138b..8f3f9e2 100644 --- a/automated-tests/.gitignore +++ b/automated-tests/.gitignore @@ -1,8 +1,3 @@ -!Makefile -tet_captured -results-desktop -results-target -results -/dali-test-suite-utils.pc -rules.mk -dali.info +*.xml +build +build.log diff --git a/automated-tests/CMakeLists.txt b/automated-tests/CMakeLists.txt new file mode 100644 index 0000000..9e15203 --- /dev/null +++ b/automated-tests/CMakeLists.txt @@ -0,0 +1,11 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +PROJECT(tct_coreapi_utc) + +INCLUDE(FindPkgConfig) +SET(BIN_DIR "/opt/usr/bin") + +INCLUDE_DIRECTORIES( + src/common +) + +ADD_SUBDIRECTORY(src) diff --git a/automated-tests/TET/.gitignore b/automated-tests/TET/.gitignore new file mode 100644 index 0000000..8af138b --- /dev/null +++ b/automated-tests/TET/.gitignore @@ -0,0 +1,8 @@ +!Makefile +tet_captured +results-desktop +results-target +results +/dali-test-suite-utils.pc +rules.mk +dali.info diff --git a/automated-tests/_export_desktop.sh b/automated-tests/TET/_export_desktop.sh similarity index 100% rename from automated-tests/_export_desktop.sh rename to automated-tests/TET/_export_desktop.sh diff --git a/automated-tests/_export_env.sh b/automated-tests/TET/_export_env.sh similarity index 100% rename from automated-tests/_export_env.sh rename to automated-tests/TET/_export_env.sh diff --git a/automated-tests/_export_sbs.sh b/automated-tests/TET/_export_sbs.sh similarity index 100% rename from automated-tests/_export_sbs.sh rename to automated-tests/TET/_export_sbs.sh diff --git a/automated-tests/_export_target_env.sh b/automated-tests/TET/_export_target_env.sh similarity index 100% rename from automated-tests/_export_target_env.sh rename to automated-tests/TET/_export_target_env.sh diff --git a/automated-tests/TET/build.sh b/automated-tests/TET/build.sh new file mode 100755 index 0000000..0aa030f --- /dev/null +++ b/automated-tests/TET/build.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +TEMP=`getopt -o 2vds: --long 2,verbose,desktop,scenario: \ + -n 'build_out.sh' -- "$@"` + +if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi + +# Note the quotes around `$TEMP': they are essential! +eval set -- "$TEMP" + +scenario=all +opt_verbose=0 +opt_env=scratchbox + +while true ; do + case "$1" in + -d|--desktop) opt_env=desktop ; shift ;; + -s|--scenario) scenario="$2" ; shift 2 ;; + -v|--verbose) opt_verbose=1 ; shift ;; + -2|--2) opt_env=sbs ; shift ;; + --) shift ; break ;; + *) echo "Internal error!" ; exit 1 ;; + esac +done + + +case "$opt_env" in + desktop) + . _export_desktop.sh + cat < coverage.mk +LDFLAGS += --coverage +EOF + ;; + scratchbox) + . _export_env.sh + cat < coverage.mk +LDFLAGS += +EOF + ;; + sbs) + . _export_sbs.sh + cat < coverage.mk +LDFLAGS += +EOF + ;; +esac + + +echo PATH=$PATH +echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH +echo TET_ROOT=$TET_ROOT +echo TET_SUITE_ROOT=$TET_SUITE_ROOT +echo ARCH=$ARCH + +RESULT_DIR=results-$ARCH +HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html +JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal + +# Faster cleanup. +find . -name Makefile -execdir make -f {} clean \; + +mkdir -p $RESULT_DIR +if [ $opt_verbose -eq 1 ] ; then + tcc -b -j - ./ $scenario | tee $JOURNAL_RESULT +else + tcc -b -j $JOURNAL_RESULT -p ./ $scenario +fi +./tbp.pl $JOURNAL_RESULT diff --git a/automated-tests/build_out.sh b/automated-tests/TET/build_out.sh similarity index 100% rename from automated-tests/build_out.sh rename to automated-tests/TET/build_out.sh diff --git a/automated-tests/coverage.mk b/automated-tests/TET/coverage.mk similarity index 100% rename from automated-tests/coverage.mk rename to automated-tests/TET/coverage.mk diff --git a/automated-tests/TET/coverage.sh b/automated-tests/TET/coverage.sh new file mode 100755 index 0000000..98798db --- /dev/null +++ b/automated-tests/TET/coverage.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +( cd ../build/slp ; make cov_data ) + +for i in `find . -name Makefile` ; do + ( + cd $(dirname $i) + echo `pwd` + covs=( `ls *.gcda 2>/dev/null` ) + if [[ $? -eq 0 ]] + then + make coverage + fi + ) +done + +( + cd .. ; + genhtml -o build/slp/doc/coverage `find . -name dali.info` +) + + diff --git a/automated-tests/dali-internal-test-suite/image-factory/.gitignore b/automated-tests/TET/dali-internal-test-suite/image-factory/.gitignore similarity index 100% rename from automated-tests/dali-internal-test-suite/image-factory/.gitignore rename to automated-tests/TET/dali-internal-test-suite/image-factory/.gitignore diff --git a/automated-tests/dali-test-suite/type-registry/Makefile b/automated-tests/TET/dali-internal-test-suite/image-factory/Makefile similarity index 100% rename from automated-tests/dali-test-suite/type-registry/Makefile rename to automated-tests/TET/dali-internal-test-suite/image-factory/Makefile diff --git a/automated-tests/dali-internal-test-suite/image-factory/file.list b/automated-tests/TET/dali-internal-test-suite/image-factory/file.list similarity index 100% rename from automated-tests/dali-internal-test-suite/image-factory/file.list rename to automated-tests/TET/dali-internal-test-suite/image-factory/file.list diff --git a/automated-tests/dali-internal-test-suite/image-factory/tslist b/automated-tests/TET/dali-internal-test-suite/image-factory/tslist similarity index 100% rename from automated-tests/dali-internal-test-suite/image-factory/tslist rename to automated-tests/TET/dali-internal-test-suite/image-factory/tslist diff --git a/automated-tests/dali-internal-test-suite/image-factory/utc-Dali-ImageFactory.cpp b/automated-tests/TET/dali-internal-test-suite/image-factory/utc-Dali-ImageFactory.cpp similarity index 100% rename from automated-tests/dali-internal-test-suite/image-factory/utc-Dali-ImageFactory.cpp rename to automated-tests/TET/dali-internal-test-suite/image-factory/utc-Dali-ImageFactory.cpp diff --git a/automated-tests/dali-internal-test-suite/master-makefile.mk b/automated-tests/TET/dali-internal-test-suite/master-makefile.mk similarity index 100% rename from automated-tests/dali-internal-test-suite/master-makefile.mk rename to automated-tests/TET/dali-internal-test-suite/master-makefile.mk diff --git a/automated-tests/dali-test-suite/material/.gitignore b/automated-tests/TET/dali-internal-test-suite/material/.gitignore similarity index 100% rename from automated-tests/dali-test-suite/material/.gitignore rename to automated-tests/TET/dali-internal-test-suite/material/.gitignore diff --git a/automated-tests/dali-test-suite/text/Makefile b/automated-tests/TET/dali-internal-test-suite/material/Makefile similarity index 100% rename from automated-tests/dali-test-suite/text/Makefile rename to automated-tests/TET/dali-internal-test-suite/material/Makefile diff --git a/automated-tests/dali-test-suite/material/file.list b/automated-tests/TET/dali-internal-test-suite/material/file.list similarity index 100% rename from automated-tests/dali-test-suite/material/file.list rename to automated-tests/TET/dali-internal-test-suite/material/file.list diff --git a/automated-tests/dali-internal-test-suite/material/tslist b/automated-tests/TET/dali-internal-test-suite/material/tslist similarity index 100% rename from automated-tests/dali-internal-test-suite/material/tslist rename to automated-tests/TET/dali-internal-test-suite/material/tslist diff --git a/automated-tests/dali-internal-test-suite/material/utc-Dali-Material.cpp b/automated-tests/TET/dali-internal-test-suite/material/utc-Dali-Material.cpp similarity index 100% rename from automated-tests/dali-internal-test-suite/material/utc-Dali-Material.cpp rename to automated-tests/TET/dali-internal-test-suite/material/utc-Dali-Material.cpp diff --git a/automated-tests/dali-internal-test-suite/resource-manager/.gitignore b/automated-tests/TET/dali-internal-test-suite/resource-manager/.gitignore similarity index 100% rename from automated-tests/dali-internal-test-suite/resource-manager/.gitignore rename to automated-tests/TET/dali-internal-test-suite/resource-manager/.gitignore diff --git a/automated-tests/dali-test-suite/signals/Makefile b/automated-tests/TET/dali-internal-test-suite/resource-manager/Makefile similarity index 100% rename from automated-tests/dali-test-suite/signals/Makefile rename to automated-tests/TET/dali-internal-test-suite/resource-manager/Makefile diff --git a/automated-tests/dali-internal-test-suite/resource-manager/file.list b/automated-tests/TET/dali-internal-test-suite/resource-manager/file.list similarity index 100% rename from automated-tests/dali-internal-test-suite/resource-manager/file.list rename to automated-tests/TET/dali-internal-test-suite/resource-manager/file.list diff --git a/automated-tests/dali-internal-test-suite/resource-manager/tslist b/automated-tests/TET/dali-internal-test-suite/resource-manager/tslist similarity index 100% rename from automated-tests/dali-internal-test-suite/resource-manager/tslist rename to automated-tests/TET/dali-internal-test-suite/resource-manager/tslist diff --git a/automated-tests/dali-internal-test-suite/resource-manager/utc-DaliInternal-ResourceClient.cpp b/automated-tests/TET/dali-internal-test-suite/resource-manager/utc-DaliInternal-ResourceClient.cpp similarity index 100% rename from automated-tests/dali-internal-test-suite/resource-manager/utc-DaliInternal-ResourceClient.cpp rename to automated-tests/TET/dali-internal-test-suite/resource-manager/utc-DaliInternal-ResourceClient.cpp diff --git a/automated-tests/dali-internal-test-suite/tc-gen.sh b/automated-tests/TET/dali-internal-test-suite/tc-gen.sh similarity index 100% rename from automated-tests/dali-internal-test-suite/tc-gen.sh rename to automated-tests/TET/dali-internal-test-suite/tc-gen.sh diff --git a/automated-tests/dali-internal-test-suite/text/.gitignore b/automated-tests/TET/dali-internal-test-suite/text/.gitignore similarity index 100% rename from automated-tests/dali-internal-test-suite/text/.gitignore rename to automated-tests/TET/dali-internal-test-suite/text/.gitignore diff --git a/automated-tests/dali-test-suite/scripting/Makefile b/automated-tests/TET/dali-internal-test-suite/text/Makefile similarity index 100% rename from automated-tests/dali-test-suite/scripting/Makefile rename to automated-tests/TET/dali-internal-test-suite/text/Makefile diff --git a/automated-tests/dali-internal-test-suite/text/file.list b/automated-tests/TET/dali-internal-test-suite/text/file.list similarity index 100% rename from automated-tests/dali-internal-test-suite/text/file.list rename to automated-tests/TET/dali-internal-test-suite/text/file.list diff --git a/automated-tests/dali-internal-test-suite/text/tslist b/automated-tests/TET/dali-internal-test-suite/text/tslist similarity index 100% rename from automated-tests/dali-internal-test-suite/text/tslist rename to automated-tests/TET/dali-internal-test-suite/text/tslist diff --git a/automated-tests/dali-internal-test-suite/text/utc-DaliInternal-Font.cpp b/automated-tests/TET/dali-internal-test-suite/text/utc-DaliInternal-Font.cpp similarity index 100% rename from automated-tests/dali-internal-test-suite/text/utc-DaliInternal-Font.cpp rename to automated-tests/TET/dali-internal-test-suite/text/utc-DaliInternal-Font.cpp diff --git a/automated-tests/dali-internal-test-suite/utc-MODULE-CLASS.cpp.in b/automated-tests/TET/dali-internal-test-suite/utc-MODULE-CLASS.cpp.in similarity index 100% rename from automated-tests/dali-internal-test-suite/utc-MODULE-CLASS.cpp.in rename to automated-tests/TET/dali-internal-test-suite/utc-MODULE-CLASS.cpp.in diff --git a/automated-tests/dali-test-suite-utils/dali-test-suite-internal-utils.h b/automated-tests/TET/dali-test-suite-utils/dali-test-suite-internal-utils.h similarity index 100% rename from automated-tests/dali-test-suite-utils/dali-test-suite-internal-utils.h rename to automated-tests/TET/dali-test-suite-utils/dali-test-suite-internal-utils.h diff --git a/automated-tests/dali-test-suite-utils/dali-test-suite-utils.h b/automated-tests/TET/dali-test-suite-utils/dali-test-suite-utils.h similarity index 100% rename from automated-tests/dali-test-suite-utils/dali-test-suite-utils.h rename to automated-tests/TET/dali-test-suite-utils/dali-test-suite-utils.h diff --git a/automated-tests/dali-test-suite-utils/mesh-builder.h b/automated-tests/TET/dali-test-suite-utils/mesh-builder.h similarity index 100% rename from automated-tests/dali-test-suite-utils/mesh-builder.h rename to automated-tests/TET/dali-test-suite-utils/mesh-builder.h diff --git a/automated-tests/dali-test-suite-utils/test-application.cpp b/automated-tests/TET/dali-test-suite-utils/test-application.cpp similarity index 100% rename from automated-tests/dali-test-suite-utils/test-application.cpp rename to automated-tests/TET/dali-test-suite-utils/test-application.cpp diff --git a/automated-tests/dali-test-suite-utils/test-application.h b/automated-tests/TET/dali-test-suite-utils/test-application.h similarity index 100% rename from automated-tests/dali-test-suite-utils/test-application.h rename to automated-tests/TET/dali-test-suite-utils/test-application.h diff --git a/automated-tests/dali-test-suite-utils/test-gesture-manager.h b/automated-tests/TET/dali-test-suite-utils/test-gesture-manager.h similarity index 100% rename from automated-tests/dali-test-suite-utils/test-gesture-manager.h rename to automated-tests/TET/dali-test-suite-utils/test-gesture-manager.h diff --git a/automated-tests/dali-test-suite-utils/test-gl-abstraction.h b/automated-tests/TET/dali-test-suite-utils/test-gl-abstraction.h similarity index 100% rename from automated-tests/dali-test-suite-utils/test-gl-abstraction.h rename to automated-tests/TET/dali-test-suite-utils/test-gl-abstraction.h diff --git a/automated-tests/dali-test-suite-utils/test-gl-sync-abstraction.h b/automated-tests/TET/dali-test-suite-utils/test-gl-sync-abstraction.h similarity index 100% rename from automated-tests/dali-test-suite-utils/test-gl-sync-abstraction.h rename to automated-tests/TET/dali-test-suite-utils/test-gl-sync-abstraction.h diff --git a/automated-tests/dali-test-suite-utils/test-native-image.h b/automated-tests/TET/dali-test-suite-utils/test-native-image.h similarity index 100% rename from automated-tests/dali-test-suite-utils/test-native-image.h rename to automated-tests/TET/dali-test-suite-utils/test-native-image.h diff --git a/automated-tests/dali-test-suite-utils/test-platform-abstraction.h b/automated-tests/TET/dali-test-suite-utils/test-platform-abstraction.h similarity index 100% rename from automated-tests/dali-test-suite-utils/test-platform-abstraction.h rename to automated-tests/TET/dali-test-suite-utils/test-platform-abstraction.h diff --git a/automated-tests/dali-test-suite-utils/test-render-controller.h b/automated-tests/TET/dali-test-suite-utils/test-render-controller.h similarity index 100% rename from automated-tests/dali-test-suite-utils/test-render-controller.h rename to automated-tests/TET/dali-test-suite-utils/test-render-controller.h diff --git a/automated-tests/dali-test-suite-utils/test-trace-call-stack.h b/automated-tests/TET/dali-test-suite-utils/test-trace-call-stack.h similarity index 100% rename from automated-tests/dali-test-suite-utils/test-trace-call-stack.h rename to automated-tests/TET/dali-test-suite-utils/test-trace-call-stack.h diff --git a/automated-tests/dali-test-suite/actors/.gitignore b/automated-tests/TET/dali-test-suite/actors/.gitignore similarity index 100% rename from automated-tests/dali-test-suite/actors/.gitignore rename to automated-tests/TET/dali-test-suite/actors/.gitignore diff --git a/automated-tests/dali-test-suite/render-tasks/Makefile b/automated-tests/TET/dali-test-suite/actors/Makefile similarity index 100% rename from automated-tests/dali-test-suite/render-tasks/Makefile rename to automated-tests/TET/dali-test-suite/actors/Makefile diff --git a/automated-tests/dali-test-suite/actors/file.list b/automated-tests/TET/dali-test-suite/actors/file.list similarity index 100% rename from automated-tests/dali-test-suite/actors/file.list rename to automated-tests/TET/dali-test-suite/actors/file.list diff --git a/automated-tests/dali-test-suite/actors/tslist b/automated-tests/TET/dali-test-suite/actors/tslist similarity index 100% rename from automated-tests/dali-test-suite/actors/tslist rename to automated-tests/TET/dali-test-suite/actors/tslist diff --git a/automated-tests/dali-test-suite/actors/tslist-renderables b/automated-tests/TET/dali-test-suite/actors/tslist-renderables similarity index 100% rename from automated-tests/dali-test-suite/actors/tslist-renderables rename to automated-tests/TET/dali-test-suite/actors/tslist-renderables diff --git a/automated-tests/dali-test-suite/actors/tslist-text-actor b/automated-tests/TET/dali-test-suite/actors/tslist-text-actor similarity index 100% rename from automated-tests/dali-test-suite/actors/tslist-text-actor rename to automated-tests/TET/dali-test-suite/actors/tslist-text-actor diff --git a/automated-tests/dali-test-suite/actors/utc-Dali-Actor.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-Actor.cpp similarity index 100% rename from automated-tests/dali-test-suite/actors/utc-Dali-Actor.cpp rename to automated-tests/TET/dali-test-suite/actors/utc-Dali-Actor.cpp diff --git a/automated-tests/dali-test-suite/actors/utc-Dali-BaseHandle.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-BaseHandle.cpp similarity index 100% rename from automated-tests/dali-test-suite/actors/utc-Dali-BaseHandle.cpp rename to automated-tests/TET/dali-test-suite/actors/utc-Dali-BaseHandle.cpp diff --git a/automated-tests/dali-test-suite/actors/utc-Dali-CameraActor.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-CameraActor.cpp similarity index 100% rename from automated-tests/dali-test-suite/actors/utc-Dali-CameraActor.cpp rename to automated-tests/TET/dali-test-suite/actors/utc-Dali-CameraActor.cpp diff --git a/automated-tests/dali-test-suite/actors/utc-Dali-Constrainable.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-Constrainable.cpp similarity index 100% rename from automated-tests/dali-test-suite/actors/utc-Dali-Constrainable.cpp rename to automated-tests/TET/dali-test-suite/actors/utc-Dali-Constrainable.cpp diff --git a/automated-tests/dali-test-suite/actors/utc-Dali-CustomActor.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-CustomActor.cpp similarity index 100% rename from automated-tests/dali-test-suite/actors/utc-Dali-CustomActor.cpp rename to automated-tests/TET/dali-test-suite/actors/utc-Dali-CustomActor.cpp diff --git a/automated-tests/dali-test-suite/actors/utc-Dali-Handle.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-Handle.cpp similarity index 100% rename from automated-tests/dali-test-suite/actors/utc-Dali-Handle.cpp rename to automated-tests/TET/dali-test-suite/actors/utc-Dali-Handle.cpp diff --git a/automated-tests/dali-test-suite/actors/utc-Dali-ImageActor.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-ImageActor.cpp similarity index 100% rename from automated-tests/dali-test-suite/actors/utc-Dali-ImageActor.cpp rename to automated-tests/TET/dali-test-suite/actors/utc-Dali-ImageActor.cpp diff --git a/automated-tests/dali-test-suite/actors/utc-Dali-Layer.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-Layer.cpp similarity index 100% rename from automated-tests/dali-test-suite/actors/utc-Dali-Layer.cpp rename to automated-tests/TET/dali-test-suite/actors/utc-Dali-Layer.cpp diff --git a/automated-tests/dali-test-suite/actors/utc-Dali-LightActor.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-LightActor.cpp similarity index 100% rename from automated-tests/dali-test-suite/actors/utc-Dali-LightActor.cpp rename to automated-tests/TET/dali-test-suite/actors/utc-Dali-LightActor.cpp diff --git a/automated-tests/dali-test-suite/actors/utc-Dali-MeshActor.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-MeshActor.cpp similarity index 100% rename from automated-tests/dali-test-suite/actors/utc-Dali-MeshActor.cpp rename to automated-tests/TET/dali-test-suite/actors/utc-Dali-MeshActor.cpp diff --git a/automated-tests/dali-test-suite/actors/utc-Dali-Model.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-Model.cpp similarity index 100% rename from automated-tests/dali-test-suite/actors/utc-Dali-Model.cpp rename to automated-tests/TET/dali-test-suite/actors/utc-Dali-Model.cpp diff --git a/automated-tests/dali-test-suite/actors/utc-Dali-RenderableActor.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-RenderableActor.cpp similarity index 100% rename from automated-tests/dali-test-suite/actors/utc-Dali-RenderableActor.cpp rename to automated-tests/TET/dali-test-suite/actors/utc-Dali-RenderableActor.cpp diff --git a/automated-tests/dali-test-suite/actors/utc-Dali-Stage.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-Stage.cpp similarity index 100% rename from automated-tests/dali-test-suite/actors/utc-Dali-Stage.cpp rename to automated-tests/TET/dali-test-suite/actors/utc-Dali-Stage.cpp diff --git a/automated-tests/dali-test-suite/actors/utc-Dali-TextActor.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-TextActor.cpp similarity index 100% rename from automated-tests/dali-test-suite/actors/utc-Dali-TextActor.cpp rename to automated-tests/TET/dali-test-suite/actors/utc-Dali-TextActor.cpp diff --git a/automated-tests/dali-test-suite/animation/.gitignore b/automated-tests/TET/dali-test-suite/animation/.gitignore similarity index 100% rename from automated-tests/dali-test-suite/animation/.gitignore rename to automated-tests/TET/dali-test-suite/animation/.gitignore diff --git a/automated-tests/dali-test-suite/property-notification/Makefile b/automated-tests/TET/dali-test-suite/animation/Makefile similarity index 100% rename from automated-tests/dali-test-suite/property-notification/Makefile rename to automated-tests/TET/dali-test-suite/animation/Makefile diff --git a/automated-tests/dali-test-suite/animation/file.list b/automated-tests/TET/dali-test-suite/animation/file.list similarity index 100% rename from automated-tests/dali-test-suite/animation/file.list rename to automated-tests/TET/dali-test-suite/animation/file.list diff --git a/automated-tests/dali-test-suite/animation/tslist b/automated-tests/TET/dali-test-suite/animation/tslist similarity index 100% rename from automated-tests/dali-test-suite/animation/tslist rename to automated-tests/TET/dali-test-suite/animation/tslist diff --git a/automated-tests/dali-test-suite/animation/utc-Dali-ActiveConstraint.cpp b/automated-tests/TET/dali-test-suite/animation/utc-Dali-ActiveConstraint.cpp similarity index 100% rename from automated-tests/dali-test-suite/animation/utc-Dali-ActiveConstraint.cpp rename to automated-tests/TET/dali-test-suite/animation/utc-Dali-ActiveConstraint.cpp diff --git a/automated-tests/dali-test-suite/animation/utc-Dali-AlphaFunctions.cpp b/automated-tests/TET/dali-test-suite/animation/utc-Dali-AlphaFunctions.cpp similarity index 100% rename from automated-tests/dali-test-suite/animation/utc-Dali-AlphaFunctions.cpp rename to automated-tests/TET/dali-test-suite/animation/utc-Dali-AlphaFunctions.cpp diff --git a/automated-tests/dali-test-suite/animation/utc-Dali-Animation.cpp b/automated-tests/TET/dali-test-suite/animation/utc-Dali-Animation.cpp similarity index 100% rename from automated-tests/dali-test-suite/animation/utc-Dali-Animation.cpp rename to automated-tests/TET/dali-test-suite/animation/utc-Dali-Animation.cpp diff --git a/automated-tests/dali-test-suite/animation/utc-Dali-Constraint.cpp b/automated-tests/TET/dali-test-suite/animation/utc-Dali-Constraint.cpp similarity index 100% rename from automated-tests/dali-test-suite/animation/utc-Dali-Constraint.cpp rename to automated-tests/TET/dali-test-suite/animation/utc-Dali-Constraint.cpp diff --git a/automated-tests/dali-test-suite/common/.gitignore b/automated-tests/TET/dali-test-suite/common/.gitignore similarity index 100% rename from automated-tests/dali-test-suite/common/.gitignore rename to automated-tests/TET/dali-test-suite/common/.gitignore diff --git a/automated-tests/dali-test-suite/object-registry/Makefile b/automated-tests/TET/dali-test-suite/common/Makefile similarity index 100% rename from automated-tests/dali-test-suite/object-registry/Makefile rename to automated-tests/TET/dali-test-suite/common/Makefile diff --git a/automated-tests/dali-test-suite/common/file.list b/automated-tests/TET/dali-test-suite/common/file.list similarity index 100% rename from automated-tests/dali-test-suite/common/file.list rename to automated-tests/TET/dali-test-suite/common/file.list diff --git a/automated-tests/dali-test-suite/tc-gen.sh b/automated-tests/TET/dali-test-suite/common/tc-gen.sh similarity index 100% rename from automated-tests/dali-test-suite/tc-gen.sh rename to automated-tests/TET/dali-test-suite/common/tc-gen.sh diff --git a/automated-tests/dali-test-suite/common/tslist b/automated-tests/TET/dali-test-suite/common/tslist similarity index 100% rename from automated-tests/dali-test-suite/common/tslist rename to automated-tests/TET/dali-test-suite/common/tslist diff --git a/automated-tests/dali-test-suite/common/utc-Dali-Any.cpp b/automated-tests/TET/dali-test-suite/common/utc-Dali-Any.cpp similarity index 100% rename from automated-tests/dali-test-suite/common/utc-Dali-Any.cpp rename to automated-tests/TET/dali-test-suite/common/utc-Dali-Any.cpp diff --git a/automated-tests/dali-test-suite/common/utc-Dali-LocklessBuffer.cpp b/automated-tests/TET/dali-test-suite/common/utc-Dali-LocklessBuffer.cpp similarity index 100% rename from automated-tests/dali-test-suite/common/utc-Dali-LocklessBuffer.cpp rename to automated-tests/TET/dali-test-suite/common/utc-Dali-LocklessBuffer.cpp diff --git a/automated-tests/dali-test-suite/common/utc-Dali-Vector.cpp b/automated-tests/TET/dali-test-suite/common/utc-Dali-Vector.cpp similarity index 100% rename from automated-tests/dali-test-suite/common/utc-Dali-Vector.cpp rename to automated-tests/TET/dali-test-suite/common/utc-Dali-Vector.cpp diff --git a/automated-tests/dali-test-suite/context/.gitignore b/automated-tests/TET/dali-test-suite/context/.gitignore similarity index 100% rename from automated-tests/dali-test-suite/context/.gitignore rename to automated-tests/TET/dali-test-suite/context/.gitignore diff --git a/automated-tests/dali-test-suite/math/Makefile b/automated-tests/TET/dali-test-suite/context/Makefile similarity index 100% rename from automated-tests/dali-test-suite/math/Makefile rename to automated-tests/TET/dali-test-suite/context/Makefile diff --git a/automated-tests/dali-test-suite/context/file.list b/automated-tests/TET/dali-test-suite/context/file.list similarity index 100% rename from automated-tests/dali-test-suite/context/file.list rename to automated-tests/TET/dali-test-suite/context/file.list diff --git a/automated-tests/dali-test-suite/context/tslist b/automated-tests/TET/dali-test-suite/context/tslist similarity index 100% rename from automated-tests/dali-test-suite/context/tslist rename to automated-tests/TET/dali-test-suite/context/tslist diff --git a/automated-tests/dali-test-suite/context/utc-Dali-Context.cpp b/automated-tests/TET/dali-test-suite/context/utc-Dali-Context.cpp similarity index 100% rename from automated-tests/dali-test-suite/context/utc-Dali-Context.cpp rename to automated-tests/TET/dali-test-suite/context/utc-Dali-Context.cpp diff --git a/automated-tests/dali-test-suite/dynamics/.gitignore b/automated-tests/TET/dali-test-suite/dynamics/.gitignore similarity index 100% rename from automated-tests/dali-test-suite/dynamics/.gitignore rename to automated-tests/TET/dali-test-suite/dynamics/.gitignore diff --git a/automated-tests/dali-test-suite/dynamics/Makefile b/automated-tests/TET/dali-test-suite/dynamics/Makefile similarity index 100% rename from automated-tests/dali-test-suite/dynamics/Makefile rename to automated-tests/TET/dali-test-suite/dynamics/Makefile diff --git a/automated-tests/dali-test-suite/dynamics/file.list b/automated-tests/TET/dali-test-suite/dynamics/file.list similarity index 100% rename from automated-tests/dali-test-suite/dynamics/file.list rename to automated-tests/TET/dali-test-suite/dynamics/file.list diff --git a/automated-tests/dali-test-suite/dynamics/tslist b/automated-tests/TET/dali-test-suite/dynamics/tslist similarity index 100% rename from automated-tests/dali-test-suite/dynamics/tslist rename to automated-tests/TET/dali-test-suite/dynamics/tslist diff --git a/automated-tests/dali-test-suite/dynamics/utc-Dali-DynamicsBody.cpp b/automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsBody.cpp similarity index 100% rename from automated-tests/dali-test-suite/dynamics/utc-Dali-DynamicsBody.cpp rename to automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsBody.cpp diff --git a/automated-tests/dali-test-suite/dynamics/utc-Dali-DynamicsBodyConfig.cpp b/automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsBodyConfig.cpp similarity index 100% rename from automated-tests/dali-test-suite/dynamics/utc-Dali-DynamicsBodyConfig.cpp rename to automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsBodyConfig.cpp diff --git a/automated-tests/dali-test-suite/dynamics/utc-Dali-DynamicsJoint.cpp b/automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsJoint.cpp similarity index 100% rename from automated-tests/dali-test-suite/dynamics/utc-Dali-DynamicsJoint.cpp rename to automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsJoint.cpp diff --git a/automated-tests/dali-test-suite/dynamics/utc-Dali-DynamicsShape.cpp b/automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsShape.cpp similarity index 100% rename from automated-tests/dali-test-suite/dynamics/utc-Dali-DynamicsShape.cpp rename to automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsShape.cpp diff --git a/automated-tests/dali-test-suite/dynamics/utc-Dali-DynamicsWorld.cpp b/automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsWorld.cpp similarity index 100% rename from automated-tests/dali-test-suite/dynamics/utc-Dali-DynamicsWorld.cpp rename to automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsWorld.cpp diff --git a/automated-tests/dali-test-suite/dynamics/utc-Dali-DynamicsWorldConfig.cpp b/automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsWorldConfig.cpp similarity index 100% rename from automated-tests/dali-test-suite/dynamics/utc-Dali-DynamicsWorldConfig.cpp rename to automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsWorldConfig.cpp diff --git a/automated-tests/dali-test-suite/effects/.gitignore b/automated-tests/TET/dali-test-suite/effects/.gitignore similarity index 100% rename from automated-tests/dali-test-suite/effects/.gitignore rename to automated-tests/TET/dali-test-suite/effects/.gitignore diff --git a/automated-tests/dali-test-suite/material/Makefile b/automated-tests/TET/dali-test-suite/effects/Makefile similarity index 100% rename from automated-tests/dali-test-suite/material/Makefile rename to automated-tests/TET/dali-test-suite/effects/Makefile diff --git a/automated-tests/dali-test-suite/effects/file.list b/automated-tests/TET/dali-test-suite/effects/file.list similarity index 100% rename from automated-tests/dali-test-suite/effects/file.list rename to automated-tests/TET/dali-test-suite/effects/file.list diff --git a/automated-tests/dali-test-suite/effects/tslist b/automated-tests/TET/dali-test-suite/effects/tslist similarity index 100% rename from automated-tests/dali-test-suite/effects/tslist rename to automated-tests/TET/dali-test-suite/effects/tslist diff --git a/automated-tests/dali-test-suite/effects/utc-Dali-ShaderEffect.cpp b/automated-tests/TET/dali-test-suite/effects/utc-Dali-ShaderEffect.cpp similarity index 100% rename from automated-tests/dali-test-suite/effects/utc-Dali-ShaderEffect.cpp rename to automated-tests/TET/dali-test-suite/effects/utc-Dali-ShaderEffect.cpp diff --git a/automated-tests/dali-test-suite/events/.gitignore b/automated-tests/TET/dali-test-suite/events/.gitignore similarity index 100% rename from automated-tests/dali-test-suite/events/.gitignore rename to automated-tests/TET/dali-test-suite/events/.gitignore diff --git a/automated-tests/dali-test-suite/images/Makefile b/automated-tests/TET/dali-test-suite/events/Makefile similarity index 100% rename from automated-tests/dali-test-suite/images/Makefile rename to automated-tests/TET/dali-test-suite/events/Makefile diff --git a/automated-tests/dali-test-suite/events/file.list b/automated-tests/TET/dali-test-suite/events/file.list similarity index 100% rename from automated-tests/dali-test-suite/events/file.list rename to automated-tests/TET/dali-test-suite/events/file.list diff --git a/automated-tests/dali-test-suite/events/tslist b/automated-tests/TET/dali-test-suite/events/tslist similarity index 100% rename from automated-tests/dali-test-suite/events/tslist rename to automated-tests/TET/dali-test-suite/events/tslist diff --git a/automated-tests/dali-test-suite/events/utc-Dali-EventProcessing.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-EventProcessing.cpp similarity index 100% rename from automated-tests/dali-test-suite/events/utc-Dali-EventProcessing.cpp rename to automated-tests/TET/dali-test-suite/events/utc-Dali-EventProcessing.cpp diff --git a/automated-tests/dali-test-suite/events/utc-Dali-Gesture.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-Gesture.cpp similarity index 100% rename from automated-tests/dali-test-suite/events/utc-Dali-Gesture.cpp rename to automated-tests/TET/dali-test-suite/events/utc-Dali-Gesture.cpp diff --git a/automated-tests/dali-test-suite/events/utc-Dali-GestureDetector.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-GestureDetector.cpp similarity index 100% rename from automated-tests/dali-test-suite/events/utc-Dali-GestureDetector.cpp rename to automated-tests/TET/dali-test-suite/events/utc-Dali-GestureDetector.cpp diff --git a/automated-tests/dali-test-suite/events/utc-Dali-HitTestAlgorithm.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-HitTestAlgorithm.cpp similarity index 100% rename from automated-tests/dali-test-suite/events/utc-Dali-HitTestAlgorithm.cpp rename to automated-tests/TET/dali-test-suite/events/utc-Dali-HitTestAlgorithm.cpp diff --git a/automated-tests/dali-test-suite/events/utc-Dali-KeyEvent.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-KeyEvent.cpp similarity index 100% rename from automated-tests/dali-test-suite/events/utc-Dali-KeyEvent.cpp rename to automated-tests/TET/dali-test-suite/events/utc-Dali-KeyEvent.cpp diff --git a/automated-tests/dali-test-suite/events/utc-Dali-LongPressGesture.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-LongPressGesture.cpp similarity index 100% rename from automated-tests/dali-test-suite/events/utc-Dali-LongPressGesture.cpp rename to automated-tests/TET/dali-test-suite/events/utc-Dali-LongPressGesture.cpp diff --git a/automated-tests/dali-test-suite/events/utc-Dali-LongPressGestureDetector.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-LongPressGestureDetector.cpp similarity index 100% rename from automated-tests/dali-test-suite/events/utc-Dali-LongPressGestureDetector.cpp rename to automated-tests/TET/dali-test-suite/events/utc-Dali-LongPressGestureDetector.cpp diff --git a/automated-tests/dali-test-suite/events/utc-Dali-MouseWheelEvent.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-MouseWheelEvent.cpp similarity index 100% rename from automated-tests/dali-test-suite/events/utc-Dali-MouseWheelEvent.cpp rename to automated-tests/TET/dali-test-suite/events/utc-Dali-MouseWheelEvent.cpp diff --git a/automated-tests/dali-test-suite/events/utc-Dali-PanGesture.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-PanGesture.cpp similarity index 100% rename from automated-tests/dali-test-suite/events/utc-Dali-PanGesture.cpp rename to automated-tests/TET/dali-test-suite/events/utc-Dali-PanGesture.cpp diff --git a/automated-tests/dali-test-suite/events/utc-Dali-PanGestureDetector.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-PanGestureDetector.cpp similarity index 100% rename from automated-tests/dali-test-suite/events/utc-Dali-PanGestureDetector.cpp rename to automated-tests/TET/dali-test-suite/events/utc-Dali-PanGestureDetector.cpp diff --git a/automated-tests/dali-test-suite/events/utc-Dali-PinchGesture.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-PinchGesture.cpp similarity index 100% rename from automated-tests/dali-test-suite/events/utc-Dali-PinchGesture.cpp rename to automated-tests/TET/dali-test-suite/events/utc-Dali-PinchGesture.cpp diff --git a/automated-tests/dali-test-suite/events/utc-Dali-PinchGestureDetector.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-PinchGestureDetector.cpp similarity index 100% rename from automated-tests/dali-test-suite/events/utc-Dali-PinchGestureDetector.cpp rename to automated-tests/TET/dali-test-suite/events/utc-Dali-PinchGestureDetector.cpp diff --git a/automated-tests/dali-test-suite/events/utc-Dali-TapGesture.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-TapGesture.cpp similarity index 100% rename from automated-tests/dali-test-suite/events/utc-Dali-TapGesture.cpp rename to automated-tests/TET/dali-test-suite/events/utc-Dali-TapGesture.cpp diff --git a/automated-tests/dali-test-suite/events/utc-Dali-TapGestureDetector.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-TapGestureDetector.cpp similarity index 100% rename from automated-tests/dali-test-suite/events/utc-Dali-TapGestureDetector.cpp rename to automated-tests/TET/dali-test-suite/events/utc-Dali-TapGestureDetector.cpp diff --git a/automated-tests/dali-test-suite/events/utc-Dali-TouchEventCombiner.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-TouchEventCombiner.cpp similarity index 100% rename from automated-tests/dali-test-suite/events/utc-Dali-TouchEventCombiner.cpp rename to automated-tests/TET/dali-test-suite/events/utc-Dali-TouchEventCombiner.cpp diff --git a/automated-tests/dali-test-suite/events/utc-Dali-TouchProcessing.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-TouchProcessing.cpp similarity index 100% rename from automated-tests/dali-test-suite/events/utc-Dali-TouchProcessing.cpp rename to automated-tests/TET/dali-test-suite/events/utc-Dali-TouchProcessing.cpp diff --git a/automated-tests/dali-test-suite/geometry/.gitignore b/automated-tests/TET/dali-test-suite/geometry/.gitignore similarity index 100% rename from automated-tests/dali-test-suite/geometry/.gitignore rename to automated-tests/TET/dali-test-suite/geometry/.gitignore diff --git a/automated-tests/dali-test-suite/geometry/Makefile b/automated-tests/TET/dali-test-suite/geometry/Makefile similarity index 100% rename from automated-tests/dali-test-suite/geometry/Makefile rename to automated-tests/TET/dali-test-suite/geometry/Makefile diff --git a/automated-tests/dali-test-suite/geometry/file.list b/automated-tests/TET/dali-test-suite/geometry/file.list similarity index 100% rename from automated-tests/dali-test-suite/geometry/file.list rename to automated-tests/TET/dali-test-suite/geometry/file.list diff --git a/automated-tests/dali-test-suite/geometry/tslist b/automated-tests/TET/dali-test-suite/geometry/tslist similarity index 100% rename from automated-tests/dali-test-suite/geometry/tslist rename to automated-tests/TET/dali-test-suite/geometry/tslist diff --git a/automated-tests/dali-test-suite/geometry/utc-Dali-AnimatableMesh.cpp b/automated-tests/TET/dali-test-suite/geometry/utc-Dali-AnimatableMesh.cpp similarity index 100% rename from automated-tests/dali-test-suite/geometry/utc-Dali-AnimatableMesh.cpp rename to automated-tests/TET/dali-test-suite/geometry/utc-Dali-AnimatableMesh.cpp diff --git a/automated-tests/dali-test-suite/geometry/utc-Dali-MeshData.cpp b/automated-tests/TET/dali-test-suite/geometry/utc-Dali-MeshData.cpp similarity index 100% rename from automated-tests/dali-test-suite/geometry/utc-Dali-MeshData.cpp rename to automated-tests/TET/dali-test-suite/geometry/utc-Dali-MeshData.cpp diff --git a/automated-tests/dali-test-suite/geometry/utc-Dali-Spline.cpp b/automated-tests/TET/dali-test-suite/geometry/utc-Dali-Spline.cpp similarity index 100% rename from automated-tests/dali-test-suite/geometry/utc-Dali-Spline.cpp rename to automated-tests/TET/dali-test-suite/geometry/utc-Dali-Spline.cpp diff --git a/automated-tests/dali-test-suite/images/.gitignore b/automated-tests/TET/dali-test-suite/images/.gitignore similarity index 100% rename from automated-tests/dali-test-suite/images/.gitignore rename to automated-tests/TET/dali-test-suite/images/.gitignore diff --git a/automated-tests/dali-test-suite/events/Makefile b/automated-tests/TET/dali-test-suite/images/Makefile similarity index 100% rename from automated-tests/dali-test-suite/events/Makefile rename to automated-tests/TET/dali-test-suite/images/Makefile diff --git a/automated-tests/dali-test-suite/images/file.list b/automated-tests/TET/dali-test-suite/images/file.list similarity index 100% rename from automated-tests/dali-test-suite/images/file.list rename to automated-tests/TET/dali-test-suite/images/file.list diff --git a/automated-tests/dali-test-suite/images/tslist b/automated-tests/TET/dali-test-suite/images/tslist similarity index 100% rename from automated-tests/dali-test-suite/images/tslist rename to automated-tests/TET/dali-test-suite/images/tslist diff --git a/automated-tests/dali-test-suite/images/utc-Dali-BitmapImage.cpp b/automated-tests/TET/dali-test-suite/images/utc-Dali-BitmapImage.cpp similarity index 100% rename from automated-tests/dali-test-suite/images/utc-Dali-BitmapImage.cpp rename to automated-tests/TET/dali-test-suite/images/utc-Dali-BitmapImage.cpp diff --git a/automated-tests/dali-test-suite/images/utc-Dali-DistanceField.cpp b/automated-tests/TET/dali-test-suite/images/utc-Dali-DistanceField.cpp similarity index 100% rename from automated-tests/dali-test-suite/images/utc-Dali-DistanceField.cpp rename to automated-tests/TET/dali-test-suite/images/utc-Dali-DistanceField.cpp diff --git a/automated-tests/dali-test-suite/images/utc-Dali-EncodedBufferImage.cpp b/automated-tests/TET/dali-test-suite/images/utc-Dali-EncodedBufferImage.cpp similarity index 100% rename from automated-tests/dali-test-suite/images/utc-Dali-EncodedBufferImage.cpp rename to automated-tests/TET/dali-test-suite/images/utc-Dali-EncodedBufferImage.cpp diff --git a/automated-tests/dali-test-suite/images/utc-Dali-FrameBufferImage.cpp b/automated-tests/TET/dali-test-suite/images/utc-Dali-FrameBufferImage.cpp similarity index 100% rename from automated-tests/dali-test-suite/images/utc-Dali-FrameBufferImage.cpp rename to automated-tests/TET/dali-test-suite/images/utc-Dali-FrameBufferImage.cpp diff --git a/automated-tests/dali-test-suite/images/utc-Dali-GlyphImage.cpp b/automated-tests/TET/dali-test-suite/images/utc-Dali-GlyphImage.cpp similarity index 100% rename from automated-tests/dali-test-suite/images/utc-Dali-GlyphImage.cpp rename to automated-tests/TET/dali-test-suite/images/utc-Dali-GlyphImage.cpp diff --git a/automated-tests/dali-test-suite/images/utc-Dali-Image.cpp b/automated-tests/TET/dali-test-suite/images/utc-Dali-Image.cpp similarity index 100% rename from automated-tests/dali-test-suite/images/utc-Dali-Image.cpp rename to automated-tests/TET/dali-test-suite/images/utc-Dali-Image.cpp diff --git a/automated-tests/dali-test-suite/images/utc-Dali-ImageAttributes.cpp b/automated-tests/TET/dali-test-suite/images/utc-Dali-ImageAttributes.cpp similarity index 100% rename from automated-tests/dali-test-suite/images/utc-Dali-ImageAttributes.cpp rename to automated-tests/TET/dali-test-suite/images/utc-Dali-ImageAttributes.cpp diff --git a/automated-tests/dali-test-suite/images/utc-Dali-Pixel.cpp b/automated-tests/TET/dali-test-suite/images/utc-Dali-Pixel.cpp similarity index 100% rename from automated-tests/dali-test-suite/images/utc-Dali-Pixel.cpp rename to automated-tests/TET/dali-test-suite/images/utc-Dali-Pixel.cpp diff --git a/automated-tests/dali-test-suite/images/utc-MODULE-CLASS.cpp.in b/automated-tests/TET/dali-test-suite/images/utc-MODULE-CLASS.cpp.in similarity index 100% rename from automated-tests/dali-test-suite/images/utc-MODULE-CLASS.cpp.in rename to automated-tests/TET/dali-test-suite/images/utc-MODULE-CLASS.cpp.in diff --git a/automated-tests/dali-test-suite/master-makefile.mk b/automated-tests/TET/dali-test-suite/master-makefile.mk similarity index 100% rename from automated-tests/dali-test-suite/master-makefile.mk rename to automated-tests/TET/dali-test-suite/master-makefile.mk diff --git a/automated-tests/dali-internal-test-suite/material/.gitignore b/automated-tests/TET/dali-test-suite/material/.gitignore similarity index 100% rename from automated-tests/dali-internal-test-suite/material/.gitignore rename to automated-tests/TET/dali-test-suite/material/.gitignore diff --git a/automated-tests/dali-test-suite/effects/Makefile b/automated-tests/TET/dali-test-suite/material/Makefile similarity index 100% rename from automated-tests/dali-test-suite/effects/Makefile rename to automated-tests/TET/dali-test-suite/material/Makefile diff --git a/automated-tests/dali-internal-test-suite/material/file.list b/automated-tests/TET/dali-test-suite/material/file.list similarity index 100% rename from automated-tests/dali-internal-test-suite/material/file.list rename to automated-tests/TET/dali-test-suite/material/file.list diff --git a/automated-tests/dali-test-suite/material/tslist b/automated-tests/TET/dali-test-suite/material/tslist similarity index 100% rename from automated-tests/dali-test-suite/material/tslist rename to automated-tests/TET/dali-test-suite/material/tslist diff --git a/automated-tests/dali-test-suite/material/utc-Dali-Material.cpp b/automated-tests/TET/dali-test-suite/material/utc-Dali-Material.cpp similarity index 100% rename from automated-tests/dali-test-suite/material/utc-Dali-Material.cpp rename to automated-tests/TET/dali-test-suite/material/utc-Dali-Material.cpp diff --git a/automated-tests/dali-test-suite/math/.gitignore b/automated-tests/TET/dali-test-suite/math/.gitignore similarity index 100% rename from automated-tests/dali-test-suite/math/.gitignore rename to automated-tests/TET/dali-test-suite/math/.gitignore diff --git a/automated-tests/dali-test-suite/context/Makefile b/automated-tests/TET/dali-test-suite/math/Makefile similarity index 100% rename from automated-tests/dali-test-suite/context/Makefile rename to automated-tests/TET/dali-test-suite/math/Makefile diff --git a/automated-tests/dali-test-suite/math/file.list b/automated-tests/TET/dali-test-suite/math/file.list similarity index 100% rename from automated-tests/dali-test-suite/math/file.list rename to automated-tests/TET/dali-test-suite/math/file.list diff --git a/automated-tests/dali-test-suite/math/tslist b/automated-tests/TET/dali-test-suite/math/tslist similarity index 100% rename from automated-tests/dali-test-suite/math/tslist rename to automated-tests/TET/dali-test-suite/math/tslist diff --git a/automated-tests/dali-test-suite/math/utc-Dali-AngleAxis.cpp b/automated-tests/TET/dali-test-suite/math/utc-Dali-AngleAxis.cpp similarity index 100% rename from automated-tests/dali-test-suite/math/utc-Dali-AngleAxis.cpp rename to automated-tests/TET/dali-test-suite/math/utc-Dali-AngleAxis.cpp diff --git a/automated-tests/dali-test-suite/math/utc-Dali-Degree.cpp b/automated-tests/TET/dali-test-suite/math/utc-Dali-Degree.cpp similarity index 100% rename from automated-tests/dali-test-suite/math/utc-Dali-Degree.cpp rename to automated-tests/TET/dali-test-suite/math/utc-Dali-Degree.cpp diff --git a/automated-tests/dali-test-suite/math/utc-Dali-MathUtils.cpp b/automated-tests/TET/dali-test-suite/math/utc-Dali-MathUtils.cpp similarity index 100% rename from automated-tests/dali-test-suite/math/utc-Dali-MathUtils.cpp rename to automated-tests/TET/dali-test-suite/math/utc-Dali-MathUtils.cpp diff --git a/automated-tests/dali-test-suite/math/utc-Dali-Matrix.cpp b/automated-tests/TET/dali-test-suite/math/utc-Dali-Matrix.cpp similarity index 100% rename from automated-tests/dali-test-suite/math/utc-Dali-Matrix.cpp rename to automated-tests/TET/dali-test-suite/math/utc-Dali-Matrix.cpp diff --git a/automated-tests/dali-test-suite/math/utc-Dali-Matrix3.cpp b/automated-tests/TET/dali-test-suite/math/utc-Dali-Matrix3.cpp similarity index 100% rename from automated-tests/dali-test-suite/math/utc-Dali-Matrix3.cpp rename to automated-tests/TET/dali-test-suite/math/utc-Dali-Matrix3.cpp diff --git a/automated-tests/dali-test-suite/math/utc-Dali-Quaternion.cpp b/automated-tests/TET/dali-test-suite/math/utc-Dali-Quaternion.cpp similarity index 100% rename from automated-tests/dali-test-suite/math/utc-Dali-Quaternion.cpp rename to automated-tests/TET/dali-test-suite/math/utc-Dali-Quaternion.cpp diff --git a/automated-tests/dali-test-suite/math/utc-Dali-Radian.cpp b/automated-tests/TET/dali-test-suite/math/utc-Dali-Radian.cpp similarity index 100% rename from automated-tests/dali-test-suite/math/utc-Dali-Radian.cpp rename to automated-tests/TET/dali-test-suite/math/utc-Dali-Radian.cpp diff --git a/automated-tests/dali-test-suite/math/utc-Dali-Random.cpp b/automated-tests/TET/dali-test-suite/math/utc-Dali-Random.cpp similarity index 100% rename from automated-tests/dali-test-suite/math/utc-Dali-Random.cpp rename to automated-tests/TET/dali-test-suite/math/utc-Dali-Random.cpp diff --git a/automated-tests/dali-test-suite/math/utc-Dali-Rect.cpp b/automated-tests/TET/dali-test-suite/math/utc-Dali-Rect.cpp similarity index 100% rename from automated-tests/dali-test-suite/math/utc-Dali-Rect.cpp rename to automated-tests/TET/dali-test-suite/math/utc-Dali-Rect.cpp diff --git a/automated-tests/dali-test-suite/math/utc-Dali-Vector2.cpp b/automated-tests/TET/dali-test-suite/math/utc-Dali-Vector2.cpp similarity index 100% rename from automated-tests/dali-test-suite/math/utc-Dali-Vector2.cpp rename to automated-tests/TET/dali-test-suite/math/utc-Dali-Vector2.cpp diff --git a/automated-tests/dali-test-suite/math/utc-Dali-Vector3.cpp b/automated-tests/TET/dali-test-suite/math/utc-Dali-Vector3.cpp similarity index 100% rename from automated-tests/dali-test-suite/math/utc-Dali-Vector3.cpp rename to automated-tests/TET/dali-test-suite/math/utc-Dali-Vector3.cpp diff --git a/automated-tests/dali-test-suite/math/utc-Dali-Vector4.cpp b/automated-tests/TET/dali-test-suite/math/utc-Dali-Vector4.cpp similarity index 100% rename from automated-tests/dali-test-suite/math/utc-Dali-Vector4.cpp rename to automated-tests/TET/dali-test-suite/math/utc-Dali-Vector4.cpp diff --git a/automated-tests/dali-test-suite/object-registry/.gitignore b/automated-tests/TET/dali-test-suite/object-registry/.gitignore similarity index 100% rename from automated-tests/dali-test-suite/object-registry/.gitignore rename to automated-tests/TET/dali-test-suite/object-registry/.gitignore diff --git a/automated-tests/dali-test-suite/common/Makefile b/automated-tests/TET/dali-test-suite/object-registry/Makefile similarity index 100% rename from automated-tests/dali-test-suite/common/Makefile rename to automated-tests/TET/dali-test-suite/object-registry/Makefile diff --git a/automated-tests/dali-test-suite/object-registry/file.list b/automated-tests/TET/dali-test-suite/object-registry/file.list similarity index 100% rename from automated-tests/dali-test-suite/object-registry/file.list rename to automated-tests/TET/dali-test-suite/object-registry/file.list diff --git a/automated-tests/dali-test-suite/object-registry/tslist b/automated-tests/TET/dali-test-suite/object-registry/tslist similarity index 100% rename from automated-tests/dali-test-suite/object-registry/tslist rename to automated-tests/TET/dali-test-suite/object-registry/tslist diff --git a/automated-tests/dali-test-suite/object-registry/utc-Dali-ObjectRegistry.cpp b/automated-tests/TET/dali-test-suite/object-registry/utc-Dali-ObjectRegistry.cpp similarity index 100% rename from automated-tests/dali-test-suite/object-registry/utc-Dali-ObjectRegistry.cpp rename to automated-tests/TET/dali-test-suite/object-registry/utc-Dali-ObjectRegistry.cpp diff --git a/automated-tests/dali-test-suite/property-notification/.gitignore b/automated-tests/TET/dali-test-suite/property-notification/.gitignore similarity index 100% rename from automated-tests/dali-test-suite/property-notification/.gitignore rename to automated-tests/TET/dali-test-suite/property-notification/.gitignore diff --git a/automated-tests/dali-test-suite/animation/Makefile b/automated-tests/TET/dali-test-suite/property-notification/Makefile similarity index 100% rename from automated-tests/dali-test-suite/animation/Makefile rename to automated-tests/TET/dali-test-suite/property-notification/Makefile diff --git a/automated-tests/dali-test-suite/property-notification/file.list b/automated-tests/TET/dali-test-suite/property-notification/file.list similarity index 100% rename from automated-tests/dali-test-suite/property-notification/file.list rename to automated-tests/TET/dali-test-suite/property-notification/file.list diff --git a/automated-tests/dali-test-suite/property-notification/tslist b/automated-tests/TET/dali-test-suite/property-notification/tslist similarity index 100% rename from automated-tests/dali-test-suite/property-notification/tslist rename to automated-tests/TET/dali-test-suite/property-notification/tslist diff --git a/automated-tests/dali-test-suite/property-notification/utc-Dali-PropertyNotification.cpp b/automated-tests/TET/dali-test-suite/property-notification/utc-Dali-PropertyNotification.cpp similarity index 100% rename from automated-tests/dali-test-suite/property-notification/utc-Dali-PropertyNotification.cpp rename to automated-tests/TET/dali-test-suite/property-notification/utc-Dali-PropertyNotification.cpp diff --git a/automated-tests/dali-test-suite/render-tasks/.gitignore b/automated-tests/TET/dali-test-suite/render-tasks/.gitignore similarity index 100% rename from automated-tests/dali-test-suite/render-tasks/.gitignore rename to automated-tests/TET/dali-test-suite/render-tasks/.gitignore diff --git a/automated-tests/dali-test-suite/actors/Makefile b/automated-tests/TET/dali-test-suite/render-tasks/Makefile similarity index 100% rename from automated-tests/dali-test-suite/actors/Makefile rename to automated-tests/TET/dali-test-suite/render-tasks/Makefile diff --git a/automated-tests/dali-test-suite/render-tasks/file.list b/automated-tests/TET/dali-test-suite/render-tasks/file.list similarity index 100% rename from automated-tests/dali-test-suite/render-tasks/file.list rename to automated-tests/TET/dali-test-suite/render-tasks/file.list diff --git a/automated-tests/dali-test-suite/render-tasks/tslist b/automated-tests/TET/dali-test-suite/render-tasks/tslist similarity index 100% rename from automated-tests/dali-test-suite/render-tasks/tslist rename to automated-tests/TET/dali-test-suite/render-tasks/tslist diff --git a/automated-tests/dali-test-suite/render-tasks/utc-Dali-RenderTask.cpp b/automated-tests/TET/dali-test-suite/render-tasks/utc-Dali-RenderTask.cpp similarity index 100% rename from automated-tests/dali-test-suite/render-tasks/utc-Dali-RenderTask.cpp rename to automated-tests/TET/dali-test-suite/render-tasks/utc-Dali-RenderTask.cpp diff --git a/automated-tests/dali-test-suite/render-tasks/utc-Dali-RenderTaskList.cpp b/automated-tests/TET/dali-test-suite/render-tasks/utc-Dali-RenderTaskList.cpp similarity index 100% rename from automated-tests/dali-test-suite/render-tasks/utc-Dali-RenderTaskList.cpp rename to automated-tests/TET/dali-test-suite/render-tasks/utc-Dali-RenderTaskList.cpp diff --git a/automated-tests/dali-test-suite/scripting/.gitignore b/automated-tests/TET/dali-test-suite/scripting/.gitignore similarity index 100% rename from automated-tests/dali-test-suite/scripting/.gitignore rename to automated-tests/TET/dali-test-suite/scripting/.gitignore diff --git a/automated-tests/dali-internal-test-suite/text/Makefile b/automated-tests/TET/dali-test-suite/scripting/Makefile similarity index 100% rename from automated-tests/dali-internal-test-suite/text/Makefile rename to automated-tests/TET/dali-test-suite/scripting/Makefile diff --git a/automated-tests/dali-test-suite/scripting/file.list b/automated-tests/TET/dali-test-suite/scripting/file.list similarity index 100% rename from automated-tests/dali-test-suite/scripting/file.list rename to automated-tests/TET/dali-test-suite/scripting/file.list diff --git a/automated-tests/dali-test-suite/scripting/tslist b/automated-tests/TET/dali-test-suite/scripting/tslist similarity index 100% rename from automated-tests/dali-test-suite/scripting/tslist rename to automated-tests/TET/dali-test-suite/scripting/tslist diff --git a/automated-tests/dali-test-suite/scripting/utc-Dali-Scripting.cpp b/automated-tests/TET/dali-test-suite/scripting/utc-Dali-Scripting.cpp similarity index 100% rename from automated-tests/dali-test-suite/scripting/utc-Dali-Scripting.cpp rename to automated-tests/TET/dali-test-suite/scripting/utc-Dali-Scripting.cpp diff --git a/automated-tests/dali-test-suite/signals/.gitignore b/automated-tests/TET/dali-test-suite/signals/.gitignore similarity index 100% rename from automated-tests/dali-test-suite/signals/.gitignore rename to automated-tests/TET/dali-test-suite/signals/.gitignore diff --git a/automated-tests/dali-internal-test-suite/resource-manager/Makefile b/automated-tests/TET/dali-test-suite/signals/Makefile similarity index 100% rename from automated-tests/dali-internal-test-suite/resource-manager/Makefile rename to automated-tests/TET/dali-test-suite/signals/Makefile diff --git a/automated-tests/dali-test-suite/signals/file.list b/automated-tests/TET/dali-test-suite/signals/file.list similarity index 100% rename from automated-tests/dali-test-suite/signals/file.list rename to automated-tests/TET/dali-test-suite/signals/file.list diff --git a/automated-tests/dali-test-suite/signals/tslist b/automated-tests/TET/dali-test-suite/signals/tslist similarity index 100% rename from automated-tests/dali-test-suite/signals/tslist rename to automated-tests/TET/dali-test-suite/signals/tslist diff --git a/automated-tests/dali-test-suite/signals/utc-Dali-SignalTemplatesFunctors.cpp b/automated-tests/TET/dali-test-suite/signals/utc-Dali-SignalTemplatesFunctors.cpp similarity index 100% rename from automated-tests/dali-test-suite/signals/utc-Dali-SignalTemplatesFunctors.cpp rename to automated-tests/TET/dali-test-suite/signals/utc-Dali-SignalTemplatesFunctors.cpp diff --git a/automated-tests/dali-test-suite/signals/utc-Dali-SignalTemplatesV2.cpp b/automated-tests/TET/dali-test-suite/signals/utc-Dali-SignalTemplatesV2.cpp similarity index 100% rename from automated-tests/dali-test-suite/signals/utc-Dali-SignalTemplatesV2.cpp rename to automated-tests/TET/dali-test-suite/signals/utc-Dali-SignalTemplatesV2.cpp diff --git a/automated-tests/dali-test-suite/common/tc-gen.sh b/automated-tests/TET/dali-test-suite/tc-gen.sh similarity index 100% rename from automated-tests/dali-test-suite/common/tc-gen.sh rename to automated-tests/TET/dali-test-suite/tc-gen.sh diff --git a/automated-tests/dali-test-suite/text/.gitignore b/automated-tests/TET/dali-test-suite/text/.gitignore similarity index 100% rename from automated-tests/dali-test-suite/text/.gitignore rename to automated-tests/TET/dali-test-suite/text/.gitignore diff --git a/automated-tests/dali-internal-test-suite/material/Makefile b/automated-tests/TET/dali-test-suite/text/Makefile similarity index 100% rename from automated-tests/dali-internal-test-suite/material/Makefile rename to automated-tests/TET/dali-test-suite/text/Makefile diff --git a/automated-tests/dali-test-suite/text/file.list b/automated-tests/TET/dali-test-suite/text/file.list similarity index 100% rename from automated-tests/dali-test-suite/text/file.list rename to automated-tests/TET/dali-test-suite/text/file.list diff --git a/automated-tests/dali-test-suite/text/tslist b/automated-tests/TET/dali-test-suite/text/tslist similarity index 100% rename from automated-tests/dali-test-suite/text/tslist rename to automated-tests/TET/dali-test-suite/text/tslist diff --git a/automated-tests/dali-test-suite/text/utc-Dali-Character.cpp b/automated-tests/TET/dali-test-suite/text/utc-Dali-Character.cpp similarity index 100% rename from automated-tests/dali-test-suite/text/utc-Dali-Character.cpp rename to automated-tests/TET/dali-test-suite/text/utc-Dali-Character.cpp diff --git a/automated-tests/dali-test-suite/text/utc-Dali-Font.cpp b/automated-tests/TET/dali-test-suite/text/utc-Dali-Font.cpp similarity index 100% rename from automated-tests/dali-test-suite/text/utc-Dali-Font.cpp rename to automated-tests/TET/dali-test-suite/text/utc-Dali-Font.cpp diff --git a/automated-tests/dali-test-suite/text/utc-Dali-FontParameters.cpp b/automated-tests/TET/dali-test-suite/text/utc-Dali-FontParameters.cpp similarity index 100% rename from automated-tests/dali-test-suite/text/utc-Dali-FontParameters.cpp rename to automated-tests/TET/dali-test-suite/text/utc-Dali-FontParameters.cpp diff --git a/automated-tests/dali-test-suite/text/utc-Dali-Text.cpp b/automated-tests/TET/dali-test-suite/text/utc-Dali-Text.cpp similarity index 100% rename from automated-tests/dali-test-suite/text/utc-Dali-Text.cpp rename to automated-tests/TET/dali-test-suite/text/utc-Dali-Text.cpp diff --git a/automated-tests/dali-test-suite/text/utc-Dali-TextStyle.cpp b/automated-tests/TET/dali-test-suite/text/utc-Dali-TextStyle.cpp similarity index 100% rename from automated-tests/dali-test-suite/text/utc-Dali-TextStyle.cpp rename to automated-tests/TET/dali-test-suite/text/utc-Dali-TextStyle.cpp diff --git a/automated-tests/dali-test-suite/text/utc-Dali-Utf8.cpp b/automated-tests/TET/dali-test-suite/text/utc-Dali-Utf8.cpp similarity index 100% rename from automated-tests/dali-test-suite/text/utc-Dali-Utf8.cpp rename to automated-tests/TET/dali-test-suite/text/utc-Dali-Utf8.cpp diff --git a/automated-tests/dali-test-suite/type-registry/.gitignore b/automated-tests/TET/dali-test-suite/type-registry/.gitignore similarity index 100% rename from automated-tests/dali-test-suite/type-registry/.gitignore rename to automated-tests/TET/dali-test-suite/type-registry/.gitignore diff --git a/automated-tests/dali-internal-test-suite/image-factory/Makefile b/automated-tests/TET/dali-test-suite/type-registry/Makefile similarity index 100% rename from automated-tests/dali-internal-test-suite/image-factory/Makefile rename to automated-tests/TET/dali-test-suite/type-registry/Makefile diff --git a/automated-tests/dali-test-suite/type-registry/file.list b/automated-tests/TET/dali-test-suite/type-registry/file.list similarity index 100% rename from automated-tests/dali-test-suite/type-registry/file.list rename to automated-tests/TET/dali-test-suite/type-registry/file.list diff --git a/automated-tests/dali-test-suite/type-registry/tslist b/automated-tests/TET/dali-test-suite/type-registry/tslist similarity index 100% rename from automated-tests/dali-test-suite/type-registry/tslist rename to automated-tests/TET/dali-test-suite/type-registry/tslist diff --git a/automated-tests/dali-test-suite/type-registry/utc-Dali-TypeRegistry.cpp b/automated-tests/TET/dali-test-suite/type-registry/utc-Dali-TypeRegistry.cpp similarity index 100% rename from automated-tests/dali-test-suite/type-registry/utc-Dali-TypeRegistry.cpp rename to automated-tests/TET/dali-test-suite/type-registry/utc-Dali-TypeRegistry.cpp diff --git a/automated-tests/dali-test-suite/utc-MODULE-CLASS.cpp.in b/automated-tests/TET/dali-test-suite/utc-MODULE-CLASS.cpp.in similarity index 100% rename from automated-tests/dali-test-suite/utc-MODULE-CLASS.cpp.in rename to automated-tests/TET/dali-test-suite/utc-MODULE-CLASS.cpp.in diff --git a/automated-tests/debug.sh b/automated-tests/TET/debug.sh similarity index 100% rename from automated-tests/debug.sh rename to automated-tests/TET/debug.sh diff --git a/automated-tests/debug_target.sh b/automated-tests/TET/debug_target.sh similarity index 100% rename from automated-tests/debug_target.sh rename to automated-tests/TET/debug_target.sh diff --git a/automated-tests/TET/execute.sh b/automated-tests/TET/execute.sh new file mode 100755 index 0000000..e4059ee --- /dev/null +++ b/automated-tests/TET/execute.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +TEMP=`getopt -o ds: --long desktop,scenario: \ + -n 'build_out.sh' -- "$@"` + +if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi + +# Note the quotes around `$TEMP': they are essential! +eval set -- "$TEMP" + +scenario=all +env=./_export_env.sh + +while true ; do + case "$1" in + -d|--desktop) env=./_export_desktop.sh ; shift ;; + -s|--scenario) scenario="$2" ; shift 2 ;; + --) shift ; break ;; + *) echo "Internal error!" ; exit 1 ;; + esac +done + + +# Source correct environment +. $env + + +echo PATH=$PATH +echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH +echo TET_ROOT=$TET_ROOT +echo TET_SUITE_ROOT=$TET_SUITE_ROOT +echo ARCH=$ARCH + +RESULT_DIR=results-$ARCH +HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html +JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal + +mkdir -p $RESULT_DIR + +tcc -e -j $JOURNAL_RESULT -p ./ $scenario +./tbp.pl $JOURNAL_RESULT + diff --git a/automated-tests/execute_target.sh b/automated-tests/TET/execute_target.sh similarity index 100% rename from automated-tests/execute_target.sh rename to automated-tests/TET/execute_target.sh diff --git a/automated-tests/file.list b/automated-tests/TET/file.list similarity index 100% rename from automated-tests/file.list rename to automated-tests/TET/file.list diff --git a/automated-tests/rules.mk.in b/automated-tests/TET/rules.mk.in similarity index 100% rename from automated-tests/rules.mk.in rename to automated-tests/TET/rules.mk.in diff --git a/automated-tests/tbp.pl b/automated-tests/TET/tbp.pl similarity index 100% rename from automated-tests/tbp.pl rename to automated-tests/TET/tbp.pl diff --git a/automated-tests/tet_scen b/automated-tests/TET/tet_scen similarity index 100% rename from automated-tests/tet_scen rename to automated-tests/TET/tet_scen diff --git a/automated-tests/tetbuild.cfg b/automated-tests/TET/tetbuild.cfg similarity index 100% rename from automated-tests/tetbuild.cfg rename to automated-tests/TET/tetbuild.cfg diff --git a/automated-tests/tetclean.cfg b/automated-tests/TET/tetclean.cfg similarity index 100% rename from automated-tests/tetclean.cfg rename to automated-tests/TET/tetclean.cfg diff --git a/automated-tests/tetexec.cfg b/automated-tests/TET/tetexec.cfg similarity index 100% rename from automated-tests/tetexec.cfg rename to automated-tests/TET/tetexec.cfg diff --git a/automated-tests/build.sh b/automated-tests/build.sh index 0aa030f..14eaf96 100755 --- a/automated-tests/build.sh +++ b/automated-tests/build.sh @@ -1,68 +1,25 @@ #!/bin/bash -TEMP=`getopt -o 2vds: --long 2,verbose,desktop,scenario: \ - -n 'build_out.sh' -- "$@"` +rm -rf build +mkdir build -if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi +function build +{ + (cd src/$1; ../../scripts/tcheadgen.sh tct-$1-core.h) + if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi + (cd build ; cmake .. -DMODULE=$1 ; make -j7 ) +} -# Note the quotes around `$TEMP': they are essential! -eval set -- "$TEMP" +if [ -n "$1" ] ; then + echo BUILDING ONLY $1 + build $1 -scenario=all -opt_verbose=0 -opt_env=scratchbox - -while true ; do - case "$1" in - -d|--desktop) opt_env=desktop ; shift ;; - -s|--scenario) scenario="$2" ; shift 2 ;; - -v|--verbose) opt_verbose=1 ; shift ;; - -2|--2) opt_env=sbs ; shift ;; - --) shift ; break ;; - *) echo "Internal error!" ; exit 1 ;; - esac -done - - -case "$opt_env" in - desktop) - . _export_desktop.sh - cat < coverage.mk -LDFLAGS += --coverage -EOF - ;; - scratchbox) - . _export_env.sh - cat < coverage.mk -LDFLAGS += -EOF - ;; - sbs) - . _export_sbs.sh - cat < coverage.mk -LDFLAGS += -EOF - ;; -esac - - -echo PATH=$PATH -echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH -echo TET_ROOT=$TET_ROOT -echo TET_SUITE_ROOT=$TET_SUITE_ROOT -echo ARCH=$ARCH - -RESULT_DIR=results-$ARCH -HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html -JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal - -# Faster cleanup. -find . -name Makefile -execdir make -f {} clean \; - -mkdir -p $RESULT_DIR -if [ $opt_verbose -eq 1 ] ; then - tcc -b -j - ./ $scenario | tee $JOURNAL_RESULT else - tcc -b -j $JOURNAL_RESULT -p ./ $scenario + for mod in `ls -1 src/ | grep -v CMakeList ` + do + if [ $mod != 'common' ] && [ $mod != 'manual' ]; then + echo BUILDING $mod + build $mod + fi + done fi -./tbp.pl $JOURNAL_RESULT diff --git a/automated-tests/coverage.sh b/automated-tests/coverage.sh index 98798db..0b49287 100755 --- a/automated-tests/coverage.sh +++ b/automated-tests/coverage.sh @@ -2,14 +2,16 @@ ( cd ../build/slp ; make cov_data ) -for i in `find . -name Makefile` ; do + +for i in `find . -name "*.dir"` ; do ( - cd $(dirname $i) + cd $i echo `pwd` covs=( `ls *.gcda 2>/dev/null` ) if [[ $? -eq 0 ]] then - make coverage + lcov --directory . -c -o dali.info + lcov --remove dali.info "*boost*" "/usr/include/*" "*/automated-tests/*" -o dali.info fi ) done @@ -18,5 +20,3 @@ done cd .. ; genhtml -o build/slp/doc/coverage `find . -name dali.info` ) - - diff --git a/automated-tests/execute.sh b/automated-tests/execute.sh index e4059ee..ec5c9e2 100755 --- a/automated-tests/execute.sh +++ b/automated-tests/execute.sh @@ -1,42 +1,27 @@ #!/bin/bash -TEMP=`getopt -o ds: --long desktop,scenario: \ - -n 'build_out.sh' -- "$@"` - -if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi - -# Note the quotes around `$TEMP': they are essential! -eval set -- "$TEMP" - -scenario=all -env=./_export_env.sh - -while true ; do - case "$1" in - -d|--desktop) env=./_export_desktop.sh ; shift ;; - -s|--scenario) scenario="$2" ; shift 2 ;; - --) shift ; break ;; - *) echo "Internal error!" ; exit 1 ;; - esac -done - - -# Source correct environment -. $env - - -echo PATH=$PATH -echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH -echo TET_ROOT=$TET_ROOT -echo TET_SUITE_ROOT=$TET_SUITE_ROOT -echo ARCH=$ARCH - -RESULT_DIR=results-$ARCH -HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html -JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal - -mkdir -p $RESULT_DIR - -tcc -e -j $JOURNAL_RESULT -p ./ $scenario -./tbp.pl $JOURNAL_RESULT - +function execute +{ + scripts/tctestsgen.sh $1 `pwd` desktop + testkit-lite -f `pwd`/tests.xml -o tct-${1}-core-tests.xml -A --comm localhost + scripts/add_style.pl $1 +} + +# Clean up old test results +rm -f tct*core-tests.xml + +if [ -n "$1" ] ; then + echo EXECUTING ONLY $1 + execute $1 + +else + for mod in `ls -1 src/ | grep -v CMakeList ` + do + if [ $mod != 'common' ] && [ $mod != 'manual' ]; then + echo EXECUTING $mod + execute $mod + fi + done +fi + +scripts/summarize.pl diff --git a/automated-tests/packaging/core-dali-tests.spec b/automated-tests/packaging/core-dali-tests.spec new file mode 100644 index 0000000..99b836c --- /dev/null +++ b/automated-tests/packaging/core-dali-tests.spec @@ -0,0 +1,52 @@ +%define MODULE_NAME dali +%define MODULE_LIBNAME dali +Name: core-%{MODULE_NAME}-tests +Summary: Core API unit TC (%{name}) +Version: 0.1 +Release: 0 +Group: Development/Tools +License: Apache License, Version 2.0, Samsung Properietary +Source0: %{name}-%{version}.tar.gz +Requires: dali +BuildRequires: dali-integration-devel +BuildRequires: pkgconfig(dali-core) +BuildRequires: pkgconfig(dali) +BuildRequires: libxml2-devel +BuildRequires: cmake + +%description +Core API unit TC (%{name}) + +%prep +%setup -q + +%build + +%define PREFIX "%{_libdir}/%{name}" + +export LDFLAGS+="-Wl,--rpath=%{PREFIX} -Wl,--as-needed" +cd automated-tests +cmake . -DMODULE="%{MODULE_NAME}" -DCMAKE_INSTALL_PREFIX=%{_prefix} + +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +cd automated-tests +%make_install +mkdir -p %{buildroot}/opt/usr/share/license +cp %{_builddir}/%{name}-%{version}/LICENSE %{buildroot}/opt/usr/share/license/%{name} +mkdir -p %{buildroot}/tmp/ +cp %{_builddir}/%{name}-%{version}/automated-tests/scripts/add_all_smack_rule.sh %{buildroot}/tmp/ +cp %{_builddir}/%{name}-%{version}/automated-tests/scripts/all_smack.rule %{buildroot}/tmp/ + +%post + +%postun + + +%files +/opt/usr/bin/* +/opt/usr/share/license/%{name} +/tmp/add_all_smack_rule.sh +/tmp/all_smack.rule diff --git a/automated-tests/packaging/core-dali-unmanaged-tests.spec b/automated-tests/packaging/core-dali-unmanaged-tests.spec new file mode 100644 index 0000000..dfb0ffb --- /dev/null +++ b/automated-tests/packaging/core-dali-unmanaged-tests.spec @@ -0,0 +1,53 @@ +%define MODULE_NAME dali-unmanaged +%define MODULE_LIBNAME dali-unmanaged +Name: core-%{MODULE_NAME}-tests +Summary: Core API unit TC (%{name}) +Version: 0.1 +Release: 0 +Group: Development/Tools +License: Apache License, Version 2.0, Samsung Properietary +Source0: %{name}-%{version}.tar.gz +Requires: dali +BuildRequires: dali-devel +BuildRequires: dali-integration-devel +BuildRequires: pkgconfig(dali-core) +BuildRequires: pkgconfig(dali) +BuildRequires: libxml2-devel +BuildRequires: cmake + +%description +Core API unit TC (%{name}) + +%prep +%setup -q + +%build + +%define PREFIX "%{_libdir}/%{name}" + +export LDFLAGS+="-Wl,--rpath=%{PREFIX} -Wl,--as-needed" +cd automated-tests +cmake . -DMODULE="%{MODULE_NAME}" -DCMAKE_INSTALL_PREFIX=%{_prefix} + +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +cd automated-tests +%make_install +mkdir -p %{buildroot}/opt/usr/share/license +cp %{_builddir}/%{name}-%{version}/LICENSE %{buildroot}/opt/usr/share/license/%{name} +mkdir -p %{buildroot}/tmp/ +cp %{_builddir}/%{name}-%{version}/automated-tests/scripts/add_all_smack_rule.sh %{buildroot}/tmp/ +cp %{_builddir}/%{name}-%{version}/automated-tests/scripts/all_smack.rule %{buildroot}/tmp/ + +%post + +%postun + + +%files +/opt/usr/bin/* +/opt/usr/share/license/%{name} +/tmp/add_all_smack_rule.sh +/tmp/all_smack.rule diff --git a/automated-tests/scripts/add_all_smack_rule.sh b/automated-tests/scripts/add_all_smack_rule.sh new file mode 100755 index 0000000..8efb158 --- /dev/null +++ b/automated-tests/scripts/add_all_smack_rule.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +SCRIPTDIR=`dirname $(readlink -f $0)` +SMACK_FILE=$SCRIPTDIR/all_smack.rule + +echo "" +echo "Add smack rule in $SMACK_FILE" +echo "===================================================" +echo "" + +while read rule; do + NO_BLANK=$(echo $rule | sed 's/ //g' | sed 's/ //g') + if [ ${#NO_BLANK} -lt 1 ]; then + echo "Blank" + continue + elif [ `echo $NO_BLANK|cut -c1-1` = '#' ]; then + echo "Comment" + continue + fi + + echo "echo \"$rule\" > /smack/load2" + echo "$rule" > /smack/load2 +done < $SMACK_FILE + +echo "===================================================" +echo "" diff --git a/automated-tests/scripts/add_smack_rule.sh b/automated-tests/scripts/add_smack_rule.sh new file mode 100755 index 0000000..22fe5ee --- /dev/null +++ b/automated-tests/scripts/add_smack_rule.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +SCRIPTDIR=`dirname $(readlink -f $0)` +SMACK_FILE=$SCRIPTDIR/all_smack.rule + +echo "" +echo "Add smack rule in $SMACK_FILE" +echo "===================================================" + +echo "sdb root on" +sdb root on + +while read rule; do + NO_BLANK=$(echo $rule | sed 's/ //g' | sed 's/ //g') + if [ ${#NO_BLANK} -lt 1 ]; then + #echo "Blank" + continue + elif [ `echo $NO_BLANK|cut -c1-1` = '#' ]; then + #echo "Comment" + continue + fi + + echo "sdb shell \"echo $rule > /smack/load2\"" + sdb shell "echo $rule > /smack/load2" +done < $SMACK_FILE + +echo "===================================================" +echo "" diff --git a/automated-tests/scripts/add_style.pl b/automated-tests/scripts/add_style.pl new file mode 100755 index 0000000..95888f9 --- /dev/null +++ b/automated-tests/scripts/add_style.pl @@ -0,0 +1,27 @@ +#!/usr/bin/perl + +use strict; +use Encode; +use Getopt::Long; +use Cwd; + +my $pwd = getcwd; +my $MOD_NAME = $ARGV[0]; +my $results_xml = "tct-$MOD_NAME-core-tests.xml"; +my $results_out = "results_xml.$$"; + +# Copy $results_xml, writing new stylesheet line: +# Write as second line +open RESULTS, "<$results_xml" || die "Can't open $results_xml for reading:$!\n"; +open RESULTS_OUT, ">$results_out" || die "Can't open $results_out for writing:$!\n"; +my $fline = readline RESULTS; +print RESULTS_OUT $fline; +print RESULTS_OUT "\n"; +while() +{ + print RESULTS_OUT $_; +} +close RESULTS_OUT; +close RESULTS; +unlink $results_xml; +print `mv $results_out $results_xml`; diff --git a/automated-tests/scripts/all_smack.rule b/automated-tests/scripts/all_smack.rule new file mode 100644 index 0000000..93f2b67 --- /dev/null +++ b/automated-tests/scripts/all_smack.rule @@ -0,0 +1,28 @@ +# calendar-service +_ calendar-service::svc rwx + +# capi-appfw-application +_ alarm-server::alarm rw +_ aul::launch x +_ aul::terminate x + +# capi-network-bluetooth +_ bt-service::admin w +_ bt-service::manager w +_ bt-service::gap w +_ bt-service::spp w +_ bt:service::opp w + +# capi-network-nfc +_ nfc-manager rwx +_ nfc-manager::tag rwx +_ nfc-manager::p2p rwx +_ nfc-manager::admin rwx +_ nfc-manager::common rwx + +# capi-location-* +_ location::maps rw +_ location::client rw + +# libmdm +_ mdm-server::eas rw diff --git a/automated-tests/scripts/autocompletion.sh b/automated-tests/scripts/autocompletion.sh new file mode 100755 index 0000000..d952c73 --- /dev/null +++ b/automated-tests/scripts/autocompletion.sh @@ -0,0 +1,18 @@ +#!/bin/bash +if [ -z "$TC_PROJECT_DIR" ]; then + echo "CoreAPI project directory can't be found. `basename $0` exitting..." + exit 1 +fi + +_tcbuild () { + local cur + cur=${COMP_WORDS[$COMP_CWORD]} + if [ $COMP_CWORD -eq 1 ]; then + COMPREPLY=( $( compgen -W "addmod build install rmmod" -- $cur ) ) + else #if [ $COMP_CWORD -eq 2 ]; then + COMPREPLY=( $( cd $TC_PROJECT_DIR/src; compgen -d -X "common" -- $cur ) ) + fi + return 0 +} + +complete -F _tcbuild tcbuild diff --git a/automated-tests/scripts/init.sh b/automated-tests/scripts/init.sh new file mode 100755 index 0000000..1ccd9ea --- /dev/null +++ b/automated-tests/scripts/init.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +PROJECT_DIR="$(cd "$(dirname $0)" && cd .. && pwd)" + +ln -s $PROJECT_DIR/scripts/tcbuild.sh $PROJECT_DIR/tcbuild + +echo "" >> $HOME/.bashrc +echo "# CoreAPI-tests convenience helpers" >> $HOME/.bashrc +echo "export TC_PROJECT_DIR=\"$PROJECT_DIR\"" >> $HOME/.bashrc +echo "source $PROJECT_DIR/scripts/autocompletion.sh" >> $HOME/.bashrc diff --git a/automated-tests/scripts/retriever.sh b/automated-tests/scripts/retriever.sh new file mode 100755 index 0000000..d3b123b --- /dev/null +++ b/automated-tests/scripts/retriever.sh @@ -0,0 +1,197 @@ +#!/bin/bash + +USAGE=$(cat < 2, +# - argument doesn't begin with '-' and number of arguments is > 1 +if [[ ( "$1" == -* && ( ! "$1" =~ ^-(anum|mnum|f)$ || $# > 2 ) ) || ( "$1" != -* && $# > 1 ) ]]; then + echo -e "$USAGE" + exit 1 +fi + + +# get directory from last argument (or assume current one) +if [[ ! "$1" =~ ^-(anum|mnum|f)$ ]]; then + DIR=${1:-.} +else + DIR=${2:-.} +fi + + +# populate $TC_FILES with files declared in CMakeLists.txt +get_tc_files $DIR +if [ $? != 0 ]; then + exit 1 +fi + + +# run appropriate subcommand +case "$1" in + -anum) + tc_anum $TC_FILES ;; + -mnum) + tc_mnum $TC_FILES ;; + -f) + tc_fullinfo $TC_FILES ;; + *) + tc_names $TC_FILES ;; +esac diff --git a/automated-tests/scripts/summarize.pl b/automated-tests/scripts/summarize.pl new file mode 100755 index 0000000..4a96d36 --- /dev/null +++ b/automated-tests/scripts/summarize.pl @@ -0,0 +1,104 @@ +#!/usr/bin/perl + +use strict; +use XML::Parser; +use Encode; +use Getopt::Long; +use Cwd; + +my $pwd = getcwd; +my $num_tests=0; +my $num_passes=0; +my $num_actual_passes=0; +my $text = ""; + +sub handle_start +{ + my ($p, $elt, %attrs) = @_; + + if($elt =~ /testcase/) + { + $num_tests++; + if($attrs{"result"} eq "PASS") + { + $num_passes++; + } + } + if($elt =~ /actual_result/) + { + $text = ""; + } +} + +sub handle_end +{ + my ($p, $elt) = @_; + if($elt =~ /actual_result/) + { + if($text eq "PASS") + { + $num_actual_passes++; + } + $text = ""; + } +} + +sub handle_char +{ + my ($p, $str) = @_; + $text .= $str; +} + +my($parser) = new XML::Parser(Handlers => {Start => \&handle_start, + End => \&handle_end, + Char => \&handle_char}); + + +# Write summary.xml: +open SUMMARY, ">summary.xml" || die "Can't open summary.xml for writing:$!\n"; +print SUMMARY << "EOS"; + + + + + + 2014-03-21_18_52_41 + 2014-03-21_18_57_54 + +EOS + +my $output_files = `ls tct*core-tests.xml`; +my $file; +foreach $file (split /\s+/, $output_files ) +{ + $num_tests=0; + $num_passes=0; + $num_actual_passes=0; + $text = ""; + + $parser->parsefile($file); + + my $pass_rate = sprintf("%5.2f", $num_passes * 100.0 / $num_tests); + my $num_fails = $num_tests - $num_passes; + my $fail_rate = sprintf("%5.2f", $num_fails * 100.0 / $num_tests); + + my $suite_name = $file; + $suite_name =~ s/\.xml$//; + +print SUMMARY << "EOS2"; + + $num_tests + $num_passes + $pass_rate + $num_fails + $fail_rate + 0 + 0.00 + 0 + 0.00 + +EOS2 +} + +print SUMMARY "\n"; +close SUMMARY; diff --git a/automated-tests/scripts/tcbuild.sh b/automated-tests/scripts/tcbuild.sh new file mode 100755 index 0000000..42eaef0 --- /dev/null +++ b/automated-tests/scripts/tcbuild.sh @@ -0,0 +1,213 @@ +#!/bin/bash + +#---------- DEBUG_BEGIN ---------- +#ARG="-d" # debug-on flag, might be set as $1 +# keyprompt "introductory message" -- wait until any key pressed +function keyprompt { echo -ne "\n\e[1;31m$1 -- " && read -n 1 && echo -e "\n\e[0m"; } +# d_bp -- breakpoint at which user need to press any key to proceed +function d_bp { if [[ "$ARG" == "-d" ]]; then keyprompt "d >> Press any key"; fi } +# d_showVar VARNAME -- print bash variable name +function d_showVar { if [ "$ARG" == "-d" -a -n "$1" ]; then echo "d >> ${1} = ${!1}"; fi } +# d_print "message" -- print a debug message +function d_print { if [ "$ARG" == "-d" -a -n "$1" ]; then echo -e "d >> $1"; fi } +#---------- DEBUG_END ---------- + +PROJECT_DIR="$(cd "$(dirname $0)" && pwd)" +d_showVar PROJECT_DIR + +function gbs_profile { +perl -e " +use Config::Tiny; +my \$Config = Config::Tiny->read( \"\$ENV{HOME}/.gbs.conf\" ); +my \$profile = \$Config->{general}->{profile}; +\$profile =~ s/profile.//; +print \$profile;" +} + +PROFILE=`gbs_profile` +RPM_DIR="$HOME/GBS-ROOT/local/repos/$PROFILE/armv7l/RPMS" +d_showVar RPM_DIR + +function add_module { + # argument check + if [ -z "$1" ]; then echo "Usage: `basename $0` addmod [module_lib_name]"; exit 1; fi + + MODULE_NAME=$1 + d_showVar MODULE_NAME + MODULE_NAME_C=$(echo $MODULE_NAME | sed -e 's/-\([a-z]\)/\U\1/' -e 's/^\([a-z]\)/\U\1/') + d_showVar MODULE_NAME_C + MODULE_NAME_U=$(echo $MODULE_NAME | sed -e 's/-/_/') + d_showVar MODULE_NAME_U +# MODULE_LIBNAME=${2:-capi-$MODULE_NAME} + MODULE_LIBNAME=$1 + d_showVar MODULE_LIBNAME + + echo "Adding $MODULE_NAME module to project..." + d_bp + cd $PROJECT_DIR + # prepare .spec file + echo "-- Generating packaging/core-$MODULE_NAME-tests.spec file" + if [ ! -d packaging ]; then mkdir packaging; fi + sed -e "s:\[MODULE_NAME\]:$MODULE_NAME:g" -e "s:\[MODULE_LIBNAME\]:$MODULE_LIBNAME:g" \ + templates/core-\[module_name\]-tests.spec > packaging/core-$MODULE_NAME-tests.spec + # prepare src directory + mkdir src/$MODULE_NAME + echo "-- Generating src/$MODULE_NAME/CMakeLists.txt file" + sed -e "s:%{MODULE_NAME}:$MODULE_NAME:g" -e "s:%{MODULE_LIBNAME}:$MODULE_LIBNAME:g" \ + templates/src-directory/CMakeLists.txt > src/$MODULE_NAME/CMakeLists.txt + echo "-- Generating src/$MODULE_NAME/tct-$MODULE_NAME-core.c file" + sed -e "s:%{MODULE_NAME}:$MODULE_NAME:g" \ + templates/src-directory/tct-\[module_name\]-core.c > src/$MODULE_NAME/tct-$MODULE_NAME-core.c + echo "-- Generating src/$MODULE_NAME/utc-$MODULE_NAME.c file" + sed -e "s:%{MODULE_NAME_U}:$MODULE_NAME_U:g" -e "s:%{MODULE_NAME_C}:$MODULE_NAME_C:g" \ + templates/src-directory/utc-\[module_name\].c > src/$MODULE_NAME/utc-$MODULE_NAME.c + echo "Task finished successfully" +} + +function rm_module { + # argument check + if [ -z "$1" ]; then echo "Usage: `basename $0` rmmod "; exit 1; fi + + MODULE_NAME=$1 + d_showVar MODULE_NAME + + echo "Removing $MODULE_NAME module from project..." + d_bp + echo "---- Updating /opt/tct/packages/package_list.xml" + scripts/tcpackageslistsgen.sh $MODULE_NAME /opt/tct/packages/package_list.xml 1 + if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi + # echo "---- Updating test plans" + # scripts/tcpackageslistsgen.sh $MODULE_NAME /opt/tct/manager/plan/*.xml 1 + # if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi + + cd $PROJECT_DIR + echo "-- Removing packaging/core-$MODULE_NAME-tests.spec file" + rm packaging/core-$MODULE_NAME-tests.spec + echo "-- Removing src/$MODULE_NAME directory" + rm -r src/$MODULE_NAME + echo "Task finished successfully" +} + +function build { + if [ -n "$1" ]; then + (cd src/$1; ../../scripts/tcheadgen.sh tct-$1-core.h) + if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi + cp packaging/core-$1-tests.spec ../packaging + gbs build -A armv7l --spec core-$1-tests.spec --include-all --keep-packs | \ + tee build.log | stdbuf -o0 sed -e 's/error:/\x1b[1;91m&\x1b[0m/' \ + -e 's/warning:/\x1b[93m&\x1b[0m/' + rm ../packaging/core-$1-tests.spec + else + echo "Build requires a module name" + exit 1 + fi +} + +function inst { + if [ -z "$1" ] + then + for mod in `ls -1 src/ | grep -v CMakeLists` + do + + if [ $mod != 'common' ] && [ $mod != 'manual' ]; then + + PKG_NAME="core-$mod-tests" + d_showVar PKG_NAME + VER=$(cat packaging/$PKG_NAME.spec | awk '/^Version:/ { print $2; exit; }') + d_showVar VER + PKG_VNAME="$PKG_NAME-$VER" + d_showVar PKG_VNAME + PKG_FNAME="$PKG_VNAME-0.armv7l.rpm" + d_showVar PKG_FNAME + + if [ -f "$RPM_DIR/$PKG_FNAME" ] + then + inst $mod + echo "" + fi + fi + done + else + cd $PROJECT_DIR + # setting variables + MOD_NAME="$1" + d_showVar MOD_NAME + PKG_NAME="core-$MOD_NAME-tests" + d_showVar PKG_NAME + VER=$(cat packaging/$PKG_NAME.spec | awk '/^Version:/ { print $2; exit; }') + d_showVar VER + PKG_VNAME="$PKG_NAME-$VER" + d_showVar PKG_VNAME + PKG_FNAME="$PKG_VNAME-0.armv7l.rpm" + d_showVar PKG_FNAME + TCT_DIR="opt/tct-$MOD_NAME-core-tests" + d_showVar TCT_DIR + + echo "Deploying $MOD_NAME suite to tct-mgr..." + d_bp + # prepare tct directory and files + echo "-- Preparing suite .zip file..." + echo "---- Creating /tmp/$TCT_DIR directory" + rm -r /tmp/opt > /dev/null 2>&1 + mkdir -p /tmp/$TCT_DIR + # README + echo "---- Copying /tmp/$TCT_DIR" + cp templates/tct-package/README /tmp/$TCT_DIR + # rpm + echo "---- Copying /tmp/$TCT_DIR package" + cp $RPM_DIR/$PKG_FNAME /tmp/$TCT_DIR + if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi + # inst.sh + echo "---- Generating /tmp/$TCT_DIR/inst.sh file" + sed -e "s:%{PKG_NAME}:\"$PKG_NAME\":g" -e "s:%{PKG_FULLNAME}:\"$PKG_FNAME\":g" \ + -e "s:%{PKG_DIR}:\"/opt/usr/media/tct/$TCT_DIR\":g" \ + templates/tct-package/inst.sh > /tmp/$TCT_DIR/inst.sh + chmod a+x /tmp/$TCT_DIR/inst.sh + # tests.xml + echo "---- Generating /tmp/$TCT_DIR" + scripts/tctestsgen.sh $MOD_NAME /tmp/$TCT_DIR target + if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi + # zip + echo "---- Preparing /tmp/tct/packages/tct-$MOD_NAME-core-tests-2.2.1-1.zip file" + # clear old zips + rm -r /tmp/tct/packages > /dev/null 2>&1 + mkdir -p /tmp/tct/packages + # create new zip + ( cd /tmp; zip -r /tmp/tct/packages/tct-$MOD_NAME-core-tests-2.2.1-1.zip opt > /dev/null 2>&1; ) + # deployment + echo "-- Suite deployment..." + echo "---- Copying /opt/tct/packages/tct-$MOD_NAME-core-tests-2.2.1-1.zip" + cp /tmp/tct/packages/tct-$MOD_NAME-core-tests-2.2.1-1.zip /opt/tct/packages/ + echo "---- Updating /opt/tct/packages/package_list.xml" + scripts/tcpackageslistsgen.sh $MOD_NAME /opt/tct/packages/package_list.xml 0 + if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi + # echo "---- Updating test plans" + # for file in `grep -r tct-$MOD_NAME-core-tests /opt/tct/manager/plan/ | cut -d: -f1 | uniq` + # do + # scripts/tcpackageslistsgen.sh $MOD_NAME $file + # done + # scripts/tcpackageslistsgen.sh $MOD_NAME /opt/tct/manager/plan/Full_test.xml + # if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi + echo "Task finished successfully" + fi +} + +if [ -z "$1" ]; then + # usage note + echo "Usage: `basename $0` [module_lib_name]" + exit 1 +elif [ "addmod" == "$1" ]; then + # add new module + add_module $2 $3 +elif [ "rmmod" == "$1" ]; then + # remove module + rm_module $2 +elif [ "build" == "$1" ]; then + # build the binary + build $2 +elif [ "install" == "$1" ]; then + # install + inst $2 +else + echo "Invalid subcommand: $1" +fi diff --git a/automated-tests/scripts/tcheadgen.sh b/automated-tests/scripts/tcheadgen.sh new file mode 100755 index 0000000..c7b7700 --- /dev/null +++ b/automated-tests/scripts/tcheadgen.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +if [[ -z $1 ]]; then + echo "Usage note: tcheadgen.sh " + exit 1 +fi + +FILE="$PWD/$1" +TFILE="/tmp/retr.csv" +HEADER_NAME=$(echo $1 | tr '[:lower:]' '[:upper:]' | sed -e 's/-/_/g' -e 's/\./_/') +SCRIPT_DIR="$(cd "$(dirname $0)" && pwd)" + +$SCRIPT_DIR/retriever.sh > $TFILE +if [ $? -ne 0 ]; then cat $TFILE; exit 1; fi +awk -F',' -v HEADER_NAME="$HEADER_NAME" ' + BEGIN { + OFS = ", "; + + startup_counter = 0; + startup_list[0] = ""; + + cleanup_counter = 0; + cleanup_list[0] = ""; + + testcase_counter = 0; + testcase_list[0] = ""; + + tc_array_counter = 0; + tc_array_list[0] = ""; + +print "#ifndef __" HEADER_NAME "__" +print "#define __" HEADER_NAME "__" +print "" +print "#include \"testcase.h\"" +print "" + } + { + testcase_list[testcase_counter++] = $1; + + if (startup_counter == 0 || startup_list[startup_counter-1] != $2) + startup_list[startup_counter++] = $2; + + if (startup_counter == 0 || cleanup_list[cleanup_counter-1] != $3) + cleanup_list[cleanup_counter++] = $3; + + tc_array_list[tc_array_counter++] = "\"" $1 "\", " $1 ", " $2 ", " $3; + } + END { + sc_count = (startup_counter > cleanup_counter) ? startup_counter : cleanup_counter; + for (i = 0; i < sc_count; i++) { + if (i < startup_counter && startup_list[i] != "NULL") +print "extern void " startup_list[i] "(void);" + if (i < cleanup_counter && cleanup_list[i] != "NULL") +print "extern void " cleanup_list[i] "(void);" + } + +print "" + for (i = 0; i < testcase_counter; i++) +print "extern int " testcase_list[i] "(void);" + +print "" +print "testcase tc_array[] = {" + + for (i = 0; i < tc_array_counter; i++) +print " {" tc_array_list[i] "}," + +print " {NULL, NULL}" +print "};" +print "" +print "#endif // __" HEADER_NAME "__" +}' $TFILE > $FILE diff --git a/automated-tests/scripts/tcpackageslistsgen.sh b/automated-tests/scripts/tcpackageslistsgen.sh new file mode 100755 index 0000000..15ea51f --- /dev/null +++ b/automated-tests/scripts/tcpackageslistsgen.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +if [ -z $1 -o -z $2 ]; then + echo "Usage note: tcpackageslistsgen.sh " + exit 1 +fi + +MODULE_NAME=$1 +FILE=$2 +if [ ! -f $FILE ]; then + echo "No such file: $2" + exit +fi +SCRIPT_DIR="$(cd "$(dirname $0)" && pwd)" +AUTO_NUM=$(cd $SCRIPT_DIR/..; scripts/retriever.sh -anum src/$MODULE_NAME) +if [ $? -ne 0 ]; then echo $AUTO_NUM; exit 1; fi +MAN_NUM=$(cd $SCRIPT_DIR/..; scripts/retriever.sh -mnum src/$MODULE_NAME) +if [ $? -ne 0 ]; then echo $MAN_NUM; exit 1; fi + +TFILE="/tmp/tempfile.xml" +if [ -f $TFILE ]; then + rm $TFILE +fi + +function regen { + awk -v RS='\r\n' -v ORS='\r\n' -v MODULE_NAME=$MODULE_NAME -v AUTO_NUM=$AUTO_NUM -v MAN_NUM=$MAN_NUM ' + BEGIN { + found = 0; + replaced = 0; + } + $0 ~ "" { + found = 1; + next + } + /<\/suite>/ { + if (found == 1) { +print " "; +print " " AUTO_NUM ""; +print " " MAN_NUM ""; +print " " AUTO_NUM+MAN_NUM ""; +print " tct-" MODULE_NAME "-core-tests-2.2.1-1.zip"; +print " "; + found = 0; + replaced = 1; + } else { + print $0; + } + next + } + /<\/ns3:testplan>/ { + if (replaced == 0) { +print " "; +print " " AUTO_NUM ""; +print " " MAN_NUM ""; +print " " AUTO_NUM+MAN_NUM ""; +print " tct-" MODULE_NAME "-core-tests-2.2.1-1.zip"; +print " "; +print $0 + } else { + print $0 + } + next + } + { + if (found == 0) { + print $0; + } + }' $FILE > $TFILE + cat $TFILE > $FILE +} + +regen diff --git a/automated-tests/scripts/tctestsgen.sh b/automated-tests/scripts/tctestsgen.sh new file mode 100755 index 0000000..4b920b9 --- /dev/null +++ b/automated-tests/scripts/tctestsgen.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +if [[ -z $1 ]]; then + echo "Usage note: tctestsgen.sh " + exit 1 +fi + +MODULE_NAME=$1 +MODULE_NAME_C=$(echo $MODULE_NAME | sed -e 's/-\([a-z]\)/\U\1/' -e 's/^\([a-z]\)/\U\1/') +SCRIPT_DIR="$(cd "$(dirname $0)" && pwd)" +TC_DIR="/opt/usr/bin/tct-$1-core" +if [[ $3 == "desktop" ]] ; then + TC_DIR="build/src/$1" +fi + +FILE="$2/tests.xml" +if [ -a $FILE ]; then + rm $FILE +fi +TFILE="/tmp/tcs.csv" +if [ -a $TFILE ]; then + rm $TFILE +fi + +function gen { + awk -F',' -v MODULE_NAME=$MODULE_NAME -v MODULE_NAME_C=$MODULE_NAME_C -v TC_DIR=$TC_DIR ' + BEGIN { + set = "" +print ""; +print " "; +print ""; +print " "; + } + { + if (set != "" && set != $2) { +print " " + } + + if (set != $2) { + set = $2; +print " "; + } + + tcname = $1; + tcpurpose = $3 + +print " "; +print " "; + +print " " TC_DIR "/tct-" MODULE_NAME "-core " tcname ""; +print " "; +print " "; + } + END { + if (set != "") { +print " " + } +print " " +print "" + }' $TFILE > $FILE +} + +(cd $SCRIPT_DIR/..; scripts/retriever.sh -f src/$MODULE_NAME > ${TFILE}_pre) +if [ $? -ne 0 ]; then cat ${TFILE}_pre; exit 1; fi +cat ${TFILE}_pre | sort -t',' -k2,2 -s > $TFILE +gen diff --git a/automated-tests/src/CMakeLists.txt b/automated-tests/src/CMakeLists.txt new file mode 100644 index 0000000..e4f0a2b --- /dev/null +++ b/automated-tests/src/CMakeLists.txt @@ -0,0 +1,6 @@ +IF( DEFINED MODULE ) + MESSAGE(STATUS "Building: ${CMAKE_CURRENT_SOURCE_DIR}/${MODULE}") + ADD_SUBDIRECTORY(${MODULE}) +ELSE( DEFINED MODULE ) + MESSAGE(FATAL_ERROR "No module selected to build. Aborting...") +ENDIF( DEFINED MODULE ) diff --git a/automated-tests/src/common/assert.h b/automated-tests/src/common/assert.h new file mode 100644 index 0000000..a5d6cff --- /dev/null +++ b/automated-tests/src/common/assert.h @@ -0,0 +1,82 @@ +#ifndef _ASSERT_H_ +#define _ASSERT_H_ +#include +#include + +#define assert(exp) \ + if (!(exp)) { \ + fprintf(stderr, \ + "Assert fail in %s:%d\n", __FILE__, __LINE__); \ + fprintf(stderr, \ + "Following expression is not true:\n" \ + "%s\n", #exp); \ + return 1; \ + } + +#define assert_eq(var, ref) \ + if (var != ref) { \ + fprintf(stderr, \ + "Assert fail in %s:%d\n", __FILE__, __LINE__); \ + fprintf(stderr, \ + "Values \"%s\" and \"%s\" are not equal:\n" \ + "%s == %d, %s == %d\n", \ + #var, #ref, #var, (int)var, #ref, (int)ref); \ + return 1; \ + } + +#define assert_neq(var, ref) \ + if (var == ref) { \ + fprintf(stderr, \ + "Assert fail in %s:%d\n", __FILE__, __LINE__); \ + fprintf(stderr, \ + "Values \"%s\" and \"%s\" are equal:\n" \ + "%s == %s == %d\n", \ + #var, #ref, #var, #ref, (int)ref); \ + return 1; \ + } + +#define assert_gt(var, ref) \ + if (var <= ref) { \ + fprintf(stderr, \ + "Assert fail in %s:%d\n", __FILE__, __LINE__); \ + fprintf(stderr, \ + "Value \"%s\" is not greater than \"%s\":\n" \ + "%s == %d, %s == %d\n", \ + #var, #ref, #var, var, #ref, ref); \ + return 1; \ + } + +#define assert_geq(var, ref) \ + if (var < ref) { \ + fprintf(stderr, \ + "Assert fail in %s:%d\n", __FILE__, __LINE__); \ + fprintf(stderr, \ + "Value \"%s\" is not greater or equal to \"%s\":\n" \ + "%s == %d, %s == %d\n", \ + #var, #ref, #var, var, #ref, ref); \ + return 1; \ + } + +#define assert_lt(var, ref) \ + if (var >= ref) { \ + fprintf(stderr, \ + "Assert fail in %s:%d\n", __FILE__, __LINE__); \ + fprintf(stderr, \ + "Value \"%s\" is not lower than \"%s\":\n" \ + "%s == %d, %s == %d\n", \ + #var, #ref, #var, var, #ref, ref); \ + return 1; \ + } + +#define assert_leq(var, ref) \ + if (var > ref) { \ + fprintf(stderr, \ + "Assert fail in %s:%d\n", __FILE__, __LINE__); \ + fprintf(stderr, \ + "Value \"%s\" is not lower or equal to \"%s\":\n" \ + "%s == %d, %s == %d\n", \ + #var, #ref, #var, var, #ref, ref); \ + return 1; \ + } + +#endif // _ASSERT_H_ diff --git a/automated-tests/src/common/testcase.h b/automated-tests/src/common/testcase.h new file mode 100644 index 0000000..011a452 --- /dev/null +++ b/automated-tests/src/common/testcase.h @@ -0,0 +1,18 @@ +#ifndef _TESTCASE_H_ +#define _TESTCASE_H_ + +/* pointer to startup/cleanup functions */ +typedef void (*void_fun_ptr)(void); + +/* pointer to testcase functions */ +typedef int (*tc_fun_ptr)(void); + +/* struct describing specific testcase */ +typedef struct testcase_s { + const char* name; + tc_fun_ptr function; + void_fun_ptr startup; + void_fun_ptr cleanup; +} testcase; + +#endif // _TESTCASE_H_ diff --git a/automated-tests/src/dali-internal/CMakeLists.txt b/automated-tests/src/dali-internal/CMakeLists.txt new file mode 100644 index 0000000..fd77142 --- /dev/null +++ b/automated-tests/src/dali-internal/CMakeLists.txt @@ -0,0 +1,52 @@ +SET(PKG_NAME "dali-internal") + +SET(EXEC_NAME "tct-${PKG_NAME}-core") +SET(RPM_NAME "core-${PKG_NAME}-tests") + +SET(CAPI_LIB "dali-internal") + +SET(TC_SOURCES + utc-Dali-ImageFactory.cpp + utc-Dali-Material.cpp + utc-DaliInternal-Font.cpp + utc-DaliInternal-ResourceClient.cpp +) + +LIST(APPEND TC_SOURCES + ../dali/dali-test-suite-utils/dali-test-suite-utils.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 + ../dali-unmanaged/dali-test-suite-utils/mesh-builder.cpp +) + +PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED + dali-core +) + +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -ggdb --coverage") + +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 + ../dali-unmanaged/dali-test-suite-utils + ../../.. +) + +ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.cpp ${TC_SOURCES}) +TARGET_LINK_LIBRARIES(${EXEC_NAME} + ${${CAPI_LIB}_LIBRARIES} +) + +INSTALL(PROGRAMS ${EXEC_NAME} + DESTINATION ${BIN_DIR}/${EXEC_NAME} +) diff --git a/automated-tests/src/dali-internal/tct-dali-internal-core.cpp b/automated-tests/src/dali-internal/tct-dali-internal-core.cpp new file mode 100644 index 0000000..f609ca4 --- /dev/null +++ b/automated-tests/src/dali-internal/tct-dali-internal-core.cpp @@ -0,0 +1,31 @@ +#include +#include +#include "tct-dali-internal-core.h" + +int main(int argc, const char *argv[]) +{ + int result = -1; + int i; + + if (argc != 2) { + printf("Usage: %s \n", argv[0]); + return 2; + } + + for (i = 0; tc_array[i].name; i++) { + if (!strcmp(argv[1], tc_array[i].name)) { + if (tc_array[i].startup) + tc_array[i].startup(); + + result = tc_array[i].function(); + + if (tc_array[i].cleanup) + tc_array[i].cleanup(); + + return result; + } + } + + printf("Unknown testcase name: \"%s\"\n", argv[1]); + return 2; +} diff --git a/automated-tests/src/dali-internal/tct-dali-internal-core.h b/automated-tests/src/dali-internal/tct-dali-internal-core.h new file mode 100644 index 0000000..74b4696 --- /dev/null +++ b/automated-tests/src/dali-internal/tct-dali-internal-core.h @@ -0,0 +1,126 @@ +#ifndef __TCT_DALI_INTERNAL_CORE_H__ +#define __TCT_DALI_INTERNAL_CORE_H__ + +#include "testcase.h" + +extern void utc_dali_material_startup(void); +extern void utc_dali_material_cleanup(void); + +extern int UtcDaliImageFactoryUseCachedRequest01(void); +extern int UtcDaliImageFactoryUseCachedRequest02(void); +extern int UtcDaliImageFactoryUseCachedRequest03(void); +extern int UtcDaliImageFactoryUseCachedRequest04(void); +extern int UtcDaliImageFactoryCompatibleResource01(void); +extern int UtcDaliImageFactoryCompatibleResource02(void); +extern int UtcDaliImageFactoryCompatibleResource03(void); +extern int UtcDaliImageFactoryReload01(void); +extern int UtcDaliImageFactoryReload02(void); +extern int UtcDaliImageFactoryReload03(void); +extern int UtcDaliImageFactoryReload04(void); +extern int UtcDaliImageFactoryReload05(void); +extern int UtcDaliImageFactoryReload06(void); +extern int UtcDaliMaterialMethodNew01(void); +extern int UtcDaliMaterialMethodNew02(void); +extern int UtcDaliMaterialReadyTextureOffstage(void); +extern int UtcDaliMaterialUnreadyTextureOffstage(void); +extern int UtcDaliMaterialStaging01(void); +extern int UtcDaliMaterialStaging02(void); +extern int UtcDaliMaterialSetPropsWhilstStaged(void); +extern int UtcDaliMaterialSetTextureWhilstStaged(void); +extern int UtcDaliMaterialSetUnreadyTextureWhilstStaged(void); +extern int UtcDaliMaterialIsOpaqueWithoutTexture(void); +extern int UtcDaliMaterialIsOpaqueWithTexture(void); +extern int UtcDaliMaterialIsOpaqueWithProps(void); +extern int UtcDaliMaterialRender(void); +extern int UtcDaliFontMeasureTextWidth(void); +extern int UtcDaliFontMeasureTextWidthNegative(void); +extern int UtcDaliFontMeasureTextHeight(void); +extern int UtcDaliFontMeasureTextHeightNegative(void); +extern int UtcDaliInternalRequestResourceBitmapRequests01(void); +extern int UtcDaliInternalRequestResourceBitmapRequests02(void); +extern int UtcDaliInternalRequestResourceBitmapRequests03(void); +extern int UtcDaliInternalRequestReloadBitmapRequests01(void); +extern int UtcDaliInternalRequestReloadBitmapRequests02(void); +extern int UtcDaliInternalRequestReloadBitmapRequests03(void); +extern int UtcDaliInternalSaveResource01(void); +extern int UtcDaliInternalSaveResource02(void); +extern int UtcDaliInternalSaveResource03(void); +extern int UtcDaliInternalSaveResource04(void); +extern int UtcDaliInternalSaveResource05(void); +extern int UtcDaliInternalRequestResourceTicket01(void); +extern int UtcDaliInternalRequestResourceTicket02(void); +extern int UtcDaliInternalLoadShaderRequest01(void); +extern int UtcDaliInternalLoadShaderRequest02(void); +extern int UtcDaliInternalAllocateBitmapImage01(void); +extern int UtcDaliInternalAddBitmapImage01(void); +extern int UtcDaliInternalAddBitmapImage02(void); +extern int UtcDaliInternalAddBitmapImage03(void); +extern int UtcDaliInternalGetBitmapImage01(void); +extern int UtcDaliInternalGetBitmapImage02(void); +extern int UtcDaliInternalGetBitmapImage03(void); +extern int UtcDaliInternalAllocateTexture01(void); +extern int UtcDaliInternalAddNativeImage(void); +extern int UtcDaliInternalAddFrameBufferImage(void); +extern int UtcDaliInternalAllocateMesh01(void); + +testcase tc_array[] = { + {"UtcDaliImageFactoryUseCachedRequest01", UtcDaliImageFactoryUseCachedRequest01, NULL, NULL}, + {"UtcDaliImageFactoryUseCachedRequest02", UtcDaliImageFactoryUseCachedRequest02, NULL, NULL}, + {"UtcDaliImageFactoryUseCachedRequest03", UtcDaliImageFactoryUseCachedRequest03, NULL, NULL}, + {"UtcDaliImageFactoryUseCachedRequest04", UtcDaliImageFactoryUseCachedRequest04, NULL, NULL}, + {"UtcDaliImageFactoryCompatibleResource01", UtcDaliImageFactoryCompatibleResource01, NULL, NULL}, + {"UtcDaliImageFactoryCompatibleResource02", UtcDaliImageFactoryCompatibleResource02, NULL, NULL}, + {"UtcDaliImageFactoryCompatibleResource03", UtcDaliImageFactoryCompatibleResource03, NULL, NULL}, + {"UtcDaliImageFactoryReload01", UtcDaliImageFactoryReload01, NULL, NULL}, + {"UtcDaliImageFactoryReload02", UtcDaliImageFactoryReload02, NULL, NULL}, + {"UtcDaliImageFactoryReload03", UtcDaliImageFactoryReload03, NULL, NULL}, + {"UtcDaliImageFactoryReload04", UtcDaliImageFactoryReload04, NULL, NULL}, + {"UtcDaliImageFactoryReload05", UtcDaliImageFactoryReload05, NULL, NULL}, + {"UtcDaliImageFactoryReload06", UtcDaliImageFactoryReload06, NULL, NULL}, + {"UtcDaliMaterialMethodNew01", UtcDaliMaterialMethodNew01, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliMaterialMethodNew02", UtcDaliMaterialMethodNew02, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliMaterialReadyTextureOffstage", UtcDaliMaterialReadyTextureOffstage, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliMaterialUnreadyTextureOffstage", UtcDaliMaterialUnreadyTextureOffstage, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliMaterialStaging01", UtcDaliMaterialStaging01, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliMaterialStaging02", UtcDaliMaterialStaging02, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliMaterialSetPropsWhilstStaged", UtcDaliMaterialSetPropsWhilstStaged, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliMaterialSetTextureWhilstStaged", UtcDaliMaterialSetTextureWhilstStaged, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliMaterialSetUnreadyTextureWhilstStaged", UtcDaliMaterialSetUnreadyTextureWhilstStaged, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliMaterialIsOpaqueWithoutTexture", UtcDaliMaterialIsOpaqueWithoutTexture, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliMaterialIsOpaqueWithTexture", UtcDaliMaterialIsOpaqueWithTexture, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliMaterialIsOpaqueWithProps", UtcDaliMaterialIsOpaqueWithProps, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliMaterialRender", UtcDaliMaterialRender, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliFontMeasureTextWidth", UtcDaliFontMeasureTextWidth, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliFontMeasureTextWidthNegative", UtcDaliFontMeasureTextWidthNegative, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliFontMeasureTextHeight", UtcDaliFontMeasureTextHeight, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliFontMeasureTextHeightNegative", UtcDaliFontMeasureTextHeightNegative, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalRequestResourceBitmapRequests01", UtcDaliInternalRequestResourceBitmapRequests01, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalRequestResourceBitmapRequests02", UtcDaliInternalRequestResourceBitmapRequests02, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalRequestResourceBitmapRequests03", UtcDaliInternalRequestResourceBitmapRequests03, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalRequestReloadBitmapRequests01", UtcDaliInternalRequestReloadBitmapRequests01, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalRequestReloadBitmapRequests02", UtcDaliInternalRequestReloadBitmapRequests02, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalRequestReloadBitmapRequests03", UtcDaliInternalRequestReloadBitmapRequests03, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalSaveResource01", UtcDaliInternalSaveResource01, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalSaveResource02", UtcDaliInternalSaveResource02, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalSaveResource03", UtcDaliInternalSaveResource03, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalSaveResource04", UtcDaliInternalSaveResource04, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalSaveResource05", UtcDaliInternalSaveResource05, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalRequestResourceTicket01", UtcDaliInternalRequestResourceTicket01, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalRequestResourceTicket02", UtcDaliInternalRequestResourceTicket02, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalLoadShaderRequest01", UtcDaliInternalLoadShaderRequest01, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalLoadShaderRequest02", UtcDaliInternalLoadShaderRequest02, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalAllocateBitmapImage01", UtcDaliInternalAllocateBitmapImage01, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalAddBitmapImage01", UtcDaliInternalAddBitmapImage01, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalAddBitmapImage02", UtcDaliInternalAddBitmapImage02, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalAddBitmapImage03", UtcDaliInternalAddBitmapImage03, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalGetBitmapImage01", UtcDaliInternalGetBitmapImage01, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalGetBitmapImage02", UtcDaliInternalGetBitmapImage02, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalGetBitmapImage03", UtcDaliInternalGetBitmapImage03, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalAllocateTexture01", UtcDaliInternalAllocateTexture01, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalAddNativeImage", UtcDaliInternalAddNativeImage, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalAddFrameBufferImage", UtcDaliInternalAddFrameBufferImage, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliInternalAllocateMesh01", UtcDaliInternalAllocateMesh01, utc_dali_material_startup, utc_dali_material_cleanup}, + {NULL, NULL} +}; + +#endif // __TCT_DALI_INTERNAL_CORE_H__ diff --git a/automated-tests/src/dali-internal/utc-Dali-ImageFactory.cpp b/automated-tests/src/dali-internal/utc-Dali-ImageFactory.cpp new file mode 100644 index 0000000..8506891 --- /dev/null +++ b/automated-tests/src/dali-internal/utc-Dali-ImageFactory.cpp @@ -0,0 +1,584 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +// Internal headers are allowed here +#include +#include +#include + +using namespace Dali; + +using Internal::ResourceTicketPtr; +using Internal::ImageFactory; +using Internal::ImageFactoryCache::RequestPtr; + + +namespace +{ + +static const char* gTestImageFilename = "icon_wrt.png"; + +static void EmulateImageLoaded( TestApplication& application, unsigned int width, unsigned int height ) +{ + // emulate load success + Integration::ResourceRequest* request = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true ); + Integration::ResourcePointer resource( bitmap ); + bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, width, height, width, height ); + if( request ) + { + application.GetPlatform().SetResourceLoaded( request->GetId(), request->GetType()->id, resource ); + } + + application.SendNotification(); + application.Render(); + + application.SendNotification(); + application.Render(); +} + +} //anonymous namespace + + +// High-level test for image factory request cache +int UtcDaliImageFactoryUseCachedRequest01(void) +{ + TestApplication application; + + tet_infoline( "UtcDaliImageFactoryCachedRequest01 - Request same image more than once" ); + + Image image = Image::New( gTestImageFilename ); + + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceFunc ) ); + application.GetPlatform().ResetTrace(); + + Image image2 = Image::New( gTestImageFilename ); + + application.SendNotification(); + application.Render(); + + // check resource is not loaded twice + DALI_TEST_CHECK( !application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceFunc ) ); + application.GetPlatform().ResetTrace(); + + Image image3 = Image::New( gTestImageFilename ); + + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK( !application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceFunc ) ); + END_TEST; +} + +// High-level test for image factory request cache +int UtcDaliImageFactoryUseCachedRequest02(void) +{ + TestApplication application; + + // testing resource deletion when taken off stage + tet_infoline( "UtcDaliImageFactoryCachedRequest02 - Discard previously requested resource" ); + + Image image = Image::New( gTestImageFilename, Image::Immediate, Image::Unused ); + ImageActor actor = ImageActor::New( image ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceFunc ) ); + application.GetPlatform().ResetTrace(); + + // Add actor to stage + Stage::GetCurrent().Add( actor ); + + application.Render(); + application.SendNotification(); + application.Render(); + application.SendNotification(); + + // Release the resource, request is still cached + Stage::GetCurrent().Remove( actor ); + application.Render(); + application.SendNotification(); + application.Render(); + application.SendNotification(); + + // Should find stale request in cache, so load image from filesystem + Image image2 = Image::New( gTestImageFilename ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceFunc ) ); + application.GetPlatform().ResetTrace(); + + // Resource is reloaded + Image image3 = Image::New( gTestImageFilename ); + + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( !application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceFunc ) ); + END_TEST; +} + +// Low-level test for image factory request cache +int UtcDaliImageFactoryUseCachedRequest03(void) +{ + TestApplication application; + tet_infoline( "UtcDaliImageFactoryCachedRequest03 - Request same image more than once - Request Ids" ); + + ImageFactory& imageFactory = Internal::ThreadLocalStorage::Get().GetImageFactory(); + + RequestPtr req = imageFactory.RegisterRequest( gTestImageFilename, NULL ); + ResourceTicketPtr ticket = imageFactory.Load( req.Get() ); + + RequestPtr req2 = imageFactory.RegisterRequest( gTestImageFilename, NULL ); + ResourceTicketPtr ticket2 = imageFactory.Load( req2.Get() ); + DALI_TEST_EQUALS( req, req2, TEST_LOCATION ); + DALI_TEST_EQUALS( ticket, ticket2, TEST_LOCATION ); + + req2 = imageFactory.RegisterRequest( gTestImageFilename, NULL ); + ResourceTicketPtr ticket3 = imageFactory.Load( req2.Get() ); + DALI_TEST_EQUALS( req, req2, TEST_LOCATION ); + DALI_TEST_EQUALS( ticket, ticket3, TEST_LOCATION ); + + // request differs in scaled size - not default size + ImageAttributes attr = ImageAttributes::New( 80, 160, Pixel::BGR8888 ); + req2 = imageFactory.RegisterRequest( gTestImageFilename, &attr ); + ResourceTicketPtr ticket4 = imageFactory.Load( req2.Get() ); + DALI_TEST_CHECK( req != req2 ); + END_TEST; +} + +// Low-level test for image factory request cache +int UtcDaliImageFactoryUseCachedRequest04(void) +{ + TestApplication application; + tet_infoline( "UtcDaliImageFactoryCachedRequest04 - Request same image with different Image objects - Request Ids" ); + + ImageFactory& imageFactory = Internal::ThreadLocalStorage::Get().GetImageFactory(); + + ImageAttributes attr = ImageAttributes::New( 80, 160, Pixel::BGR8888 ); + RequestPtr req = imageFactory.RegisterRequest( gTestImageFilename, &attr ); + + ImageAttributes attr2 = ImageAttributes::New( 80, 160, Pixel::BGR8888 ); + RequestPtr req2 = imageFactory.RegisterRequest( gTestImageFilename, &attr2 ); + DALI_TEST_EQUALS( req, req2, TEST_LOCATION ); + END_TEST; +} + +// Different requests, compatible resource +int UtcDaliImageFactoryCompatibleResource01(void) +{ + TestApplication application; + tet_infoline( "UtcDaliImageFactoryCompatibleResource01 - Two requests mapping to same resource" ); + + ImageFactory& imageFactory = Internal::ThreadLocalStorage::Get().GetImageFactory(); + + Vector2 testSize(80.0f, 80.0f); + application.GetPlatform().SetClosestImageSize(testSize); + + // request with default attributes ( size is 0,0 ) + RequestPtr req = imageFactory.RegisterRequest( gTestImageFilename, NULL ); + ResourceTicketPtr ticket = imageFactory.Load( req.Get() ); + + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + + // emulate load success + EmulateImageLoaded( application, 80, 80 ); + + ImageAttributes attr = ImageAttributes::New(); + attr.SetSize( 80, 80 ); + RequestPtr req2 = imageFactory.RegisterRequest( gTestImageFilename, &attr ); + ResourceTicketPtr ticket2 = imageFactory.Load( req2.Get() ); + + DALI_TEST_CHECK( req != req2 ); // different requests + DALI_TEST_EQUALS( ticket->GetId(), ticket2->GetId(), TEST_LOCATION ); // same resource + END_TEST; +} + +// Different requests, compatible resource +int UtcDaliImageFactoryCompatibleResource02(void) +{ + TestApplication application; + tet_infoline( "UtcDaliImageFactoryCompatibleResource02 - Two requests mapping to same resource." ); + + ImageFactory& imageFactory = Internal::ThreadLocalStorage::Get().GetImageFactory(); + + Vector2 testSize(80.0f, 80.0f); + application.GetPlatform().SetClosestImageSize(testSize); + + // request with default attributes ( size is 0,0 ) + RequestPtr req = imageFactory.RegisterRequest( gTestImageFilename, NULL ); + ResourceTicketPtr ticket = imageFactory.Load( req.Get() ); + + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + + // emulate load success + EmulateImageLoaded( application, 80, 80 ); + + // Request bigger size than actual image. + // This will load the same resource. + // However if image size changes later on to eg. 512*512 (file is overwritten), + // reissuing these two requests will load different resources. + // See UtcDaliImageFactoryReload06 + ImageAttributes attr = ImageAttributes::New(); + attr.SetSize( 92, 92 ); + RequestPtr req2 = imageFactory.RegisterRequest( gTestImageFilename, &attr ); + ResourceTicketPtr ticket2 = imageFactory.Load( req2.Get() ); + + DALI_TEST_CHECK( req != req2 ); // different requests + DALI_TEST_EQUALS( ticket->GetId(), ticket2->GetId(), TEST_LOCATION ); // same resource + END_TEST; +} + +// Different requests, compatible resource +int UtcDaliImageFactoryCompatibleResource03(void) +{ + TestApplication application; + tet_infoline( "UtcDaliImageFactoryCompatibleResource03 - Two requests mapping to same resource" ); + + ImageFactory& imageFactory = Internal::ThreadLocalStorage::Get().GetImageFactory(); + + Vector2 testSize(80.0f, 80.0f); + application.GetPlatform().SetClosestImageSize(testSize); + + // this time use defined attributes, nut just NULL + ImageAttributes attr = ImageAttributes::New(); + attr.SetSize( 120, 120 ); + + // request with default attributes ( size is 0,0 ) + RequestPtr req = imageFactory.RegisterRequest( gTestImageFilename, &attr ); + ResourceTicketPtr ticket = imageFactory.Load( req.Get() ); + + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + + // emulate load success + EmulateImageLoaded( application, 80, 80 ); + + ImageAttributes attr2 = ImageAttributes::New(); + attr2.SetSize( 80, 80 ); + RequestPtr req2 = imageFactory.RegisterRequest( gTestImageFilename, &attr2 ); + ResourceTicketPtr ticket2 = imageFactory.Load( req2.Get() ); + + DALI_TEST_CHECK( req != req2 ); // different requests + DALI_TEST_EQUALS( ticket->GetId(), ticket2->GetId(), TEST_LOCATION ); // same resource + END_TEST; +} + +// Test for reloading image +int UtcDaliImageFactoryReload01(void) +{ + TestApplication application; + tet_infoline( "UtcDaliImageFactoryReload01 - Reload unchanged image" ); + + Vector2 testSize(80.0f, 80.0f); + application.GetPlatform().SetClosestImageSize(testSize); + + ImageFactory& imageFactory = Internal::ThreadLocalStorage::Get().GetImageFactory(); + + RequestPtr req = imageFactory.RegisterRequest( gTestImageFilename, NULL ); + ResourceTicketPtr ticket = imageFactory.Load( req.Get() ); + + ResourceTicketPtr ticket2 = imageFactory.Reload( req.Get() ); + DALI_TEST_EQUALS( ticket, ticket2, TEST_LOCATION ); + + ResourceTicketPtr ticket3 = imageFactory.Reload( req.Get() ); + DALI_TEST_EQUALS( ticket, ticket3, TEST_LOCATION ); + END_TEST; +} + +// Testing file system access when reloading image +int UtcDaliImageFactoryReload02(void) +{ + TestApplication application; + tet_infoline( "UtcDaliImageFactoryReload02 - Reload unchanged image" ); + + ImageFactory& imageFactory = Internal::ThreadLocalStorage::Get().GetImageFactory(); + + Vector2 testSize(80.0f, 80.0f); + application.GetPlatform().SetClosestImageSize(testSize); + + RequestPtr req = imageFactory.RegisterRequest( gTestImageFilename, NULL ); + ResourceTicketPtr ticket = imageFactory.Load( req.Get() ); + + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceFunc ) ); + application.GetPlatform().ResetTrace(); + + ResourceTicketPtr ticket2 = imageFactory.Reload( req.Get() ); + + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( ticket, ticket2, TEST_LOCATION ); + // resource is still loading, do not issue another request + DALI_TEST_CHECK( !application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceFunc ) ); + + // emulate load success + EmulateImageLoaded( application, 80, 80 ); + + ResourceTicketPtr ticket3 = imageFactory.Reload( req.Get() ); + + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( ticket, ticket3, TEST_LOCATION ); + DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceFunc ) ); + application.GetPlatform().ResetTrace(); + + ticket3 = imageFactory.Reload( req.Get() ); + + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( !application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceFunc ) ); + END_TEST; +} + +// Test for reloading changed image +int UtcDaliImageFactoryReload03(void) +{ + TestApplication application; + tet_infoline( "UtcDaliImageFactoryReload03 - Reload changed image" ); + + ImageFactory& imageFactory = Internal::ThreadLocalStorage::Get().GetImageFactory(); + + Vector2 testSize( 80.0f, 80.0f ); + application.GetPlatform().SetClosestImageSize( testSize ); + + RequestPtr req = imageFactory.RegisterRequest( gTestImageFilename, NULL ); + ResourceTicketPtr ticket = imageFactory.Load( req.Get() ); + + application.SendNotification(); + application.Render(); + + // emulate load success + EmulateImageLoaded( application, 80, 80 ); + + Vector2 newSize( 192.0f, 192.0f ); + application.GetPlatform().SetClosestImageSize( newSize ); + + // Image file changed size, new resource request should be issued + ResourceTicketPtr ticket2 = imageFactory.Reload( req.Get() ); + DALI_TEST_CHECK( ticket != ticket2 ); + + ResourceTicketPtr ticket3 = imageFactory.Reload( req.Get() ); + DALI_TEST_EQUALS( ticket2, ticket3, TEST_LOCATION ); + END_TEST; +} + +// Testing file system access when reloading image +int UtcDaliImageFactoryReload04(void) +{ + TestApplication application; + tet_infoline( "UtcDaliImageFactoryReload04 - Reload unchanged image" ); + + ImageFactory& imageFactory = Internal::ThreadLocalStorage::Get().GetImageFactory(); + + Vector2 testSize(80.0f, 80.0f); + application.GetPlatform().SetClosestImageSize(testSize); + + RequestPtr req = imageFactory.RegisterRequest( gTestImageFilename, NULL ); + ResourceTicketPtr ticket = imageFactory.Load( req.Get() ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceFunc ) ); + application.GetPlatform().ResetTrace(); + + ResourceTicketPtr ticket2 = imageFactory.Reload( req.Get() ); + + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( ticket, ticket2, TEST_LOCATION ); + // resource is still loading, do not issue another request + DALI_TEST_CHECK( !application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceFunc ) ); + + // emulate load success + EmulateImageLoaded( application, 80, 80 ); + + ResourceTicketPtr ticket3 = imageFactory.Reload( req.Get() ); + + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + + // size didn't change, using same ticket + DALI_TEST_EQUALS( ticket, ticket3, TEST_LOCATION ); + DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceFunc ) ); + application.GetPlatform().ResetTrace(); + + // still loading + ticket3 = imageFactory.Reload( req.Get() ); + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( !application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceFunc ) ); + END_TEST; +} + +// Testing OnDemand + Reload +// Reload should have no effect if OnDemand Image is not loaded yet, as stated in the API documentation +int UtcDaliImageFactoryReload05(void) +{ + TestApplication application; + + tet_infoline( "UtcDaliImageFactoryReload05 - Reload OnDemand image" ); + + ImageFactory& imageFactory = Internal::ThreadLocalStorage::Get().GetImageFactory(); + + Vector2 testSize(80.0f, 80.0f); + application.GetPlatform().SetClosestImageSize(testSize); + + RequestPtr req; + ImageAttributes attr = ImageAttributes::New(); + attr.SetSize( 80, 80 ); + + // this happens first when loading Image OnDemand + req = imageFactory.RegisterRequest( gTestImageFilename, &attr ); + + application.SendNotification(); + application.Render(); + + ResourceTicketPtr ticket = imageFactory.Reload( req.Get() ); + + DALI_TEST_CHECK( !application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceFunc ) ); + DALI_TEST_CHECK( !ticket ); + + // this happens when Image is put on stage + ticket = imageFactory.Load( req.Get() ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceFunc ) ); + DALI_TEST_CHECK( ticket ); + application.GetPlatform().ResetTrace(); + + ticket = imageFactory.Reload( req.Get() ); + + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + + // still loading, no new request + DALI_TEST_CHECK( !application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceFunc ) ); + + // emulate load success + EmulateImageLoaded( application, 80, 80 ); + + ticket = imageFactory.Reload( req.Get() ); + + application.SendNotification(); + application.Render(); + + application.SendNotification(); + application.Render(); + + + DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceFunc ) ); + END_TEST; +} + +// Initally two different requests map to same resource. +// After overwriting the file, they load different image resources. +int UtcDaliImageFactoryReload06(void) +{ + TestApplication application; + tet_infoline( "UtcDaliImageFactoryReload06 - Two requests first mapping to same resource, then different resources." ); + + ImageFactory& imageFactory = Internal::ThreadLocalStorage::Get().GetImageFactory(); + + Vector2 testSize(80.0f, 80.0f); + application.GetPlatform().SetClosestImageSize(testSize); + + // request with default attributes ( size is 0,0 ) + RequestPtr req = imageFactory.RegisterRequest( gTestImageFilename, NULL ); + ResourceTicketPtr ticket = imageFactory.Load( req.Get() ); + + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + + // emulate load success + EmulateImageLoaded( application, 80, 80 ); + + // Request bigger size than actual image. + // This will load the same resource. + // However if image size changes later on to eg. 512*512 (file is overwritten), + // reissuing these two requests will load different resources. + ImageAttributes attr = ImageAttributes::New(); + attr.SetSize( 92, 92 ); + RequestPtr req2 = imageFactory.RegisterRequest( gTestImageFilename, &attr ); + ResourceTicketPtr ticket2 = imageFactory.Load( req2.Get() ); + + DALI_TEST_CHECK( req != req2 ); // different requests + DALI_TEST_EQUALS( ticket->GetId(), ticket2->GetId(), TEST_LOCATION ); // same resource + + Vector2 newSize(512.0f, 512.0f); + application.GetPlatform().SetClosestImageSize(newSize); + + // reload fixed size (192,192) request + ticket2 = imageFactory.Reload( req2.Get() ); + + // emulate load success + // note: this is the only way to emulate what size is loaded by platform abstraction + EmulateImageLoaded( application, 92, 92 ); + + // reload default size request + ticket = imageFactory.Reload( req.Get() ); + + DALI_TEST_CHECK( ticket->GetId() != ticket2->GetId() ); // different resources + END_TEST; +} diff --git a/automated-tests/src/dali-internal/utc-Dali-Material.cpp b/automated-tests/src/dali-internal/utc-Dali-Material.cpp new file mode 100644 index 0000000..40284fa --- /dev/null +++ b/automated-tests/src/dali-internal/utc-Dali-Material.cpp @@ -0,0 +1,735 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +using namespace Dali; + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +Dali::Internal::MaterialProperties TEST_PROPS; +} + +// Called only once before first test is run. +void utc_dali_material_startup(void) +{ + TEST_PROPS.mOpacity = 0.4f; + TEST_PROPS.mShininess = 0.27f; + TEST_PROPS.mDiffuseColor = Color::MAGENTA; + TEST_PROPS.mAmbientColor = Color::GREEN; + TEST_PROPS.mSpecularColor = Color::BLUE; + TEST_PROPS.mEmissiveColor = Color::RED; + test_return_value = TET_UNDEF; +} + +// Called only once after last test is run +void utc_dali_material_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ + +class TestProgram +{ +public: + TestProgram( TestApplication& application ) + : app(application) + { + Internal::Context* testContext = new Internal::Context( application.GetGlAbstraction() ); + Integration::ShaderDataPtr shaderData = new Integration::ShaderData("123", "132"); + shaderData->AllocateBuffer(10); + + Integration::ResourceId resourceId = 100; + program = Internal::Program::New(resourceId, shaderData.Get(), *testContext); + programId = app.GetGlAbstraction().GetLastProgramCreated(); + program->Use(); + } + + virtual ~TestProgram() + { + } + + Internal::Program& GetProgram() + { + return *program; + } + + float GetUniformF(std::string uniform) + { + GLint uniformLoc = program->GetUniformLocation( program->RegisterUniform( uniform ) ); + float value=0.0f; + if(app.GetGlAbstraction().GetUniformValue( programId, (GLuint) uniformLoc, value)) + { + return value; + } + return 0.0f; + } + + Vector4 GetUniformV(std::string uniform) + { + GLint uniformLoc = program->GetUniformLocation( program->RegisterUniform( uniform ) ); + Vector4 value; + if(app.GetGlAbstraction().GetUniformValue( programId, (GLuint) uniformLoc, value)) + { + return value; + } + return Vector4(); + } + + float GetOpacity() { return GetUniformF("uMaterial.mOpacity"); } + float GetShininess() { return GetUniformF("uMaterial.mShininess"); } + Vector4 GetAmbientColor() { return GetUniformV("uMaterial.mAmbient"); } + Vector4 GetDiffuseColor() { return GetUniformV("uMaterial.mDiffuse"); } + Vector4 GetSpecularColor() { return GetUniformV("uMaterial.mSpecular"); } + Vector4 GetEmissiveColor() { return GetUniformV("uMaterial.mEmissive"); } + + TestApplication& app; + GLuint programId; + Internal::Program* program; + Integration::ShaderDataPtr shaderData; +}; + + +class TestBoundTextures +{ +public: + TestBoundTextures(TestApplication& application) + : app(application) + { + std::vector ids; + ids.push_back( 8 ); // 8 = actor1 + ids.push_back( 9 ); // 9 = actor2 + ids.push_back( 10 ); // 10 = actor3 + application.GetGlAbstraction().SetNextTextureIds( ids ); + } + + std::size_t GetNumBoundTextures() + { + const std::vector& boundTextures = app.GetGlAbstraction().GetBoundTextures(); + return boundTextures.size(); + } + + bool CheckFirstTextureBound( GLuint activeTextureUnit ) + { + bool bound=false; + const std::vector& boundTextures = app.GetGlAbstraction().GetBoundTextures( activeTextureUnit ); + + if ( boundTextures.size() == 1 ) + { + if( boundTextures[0] == 8u ) + { + bound = true; + } + } + return bound; + } + + bool CheckFirstTextureDeleted() + { + return ( app.GetGlAbstraction().CheckTextureDeleted( 8u )); + } + + TestApplication& app; +}; + + +Internal::ResourceTicketPtr CheckLoadBitmap(TestApplication& application, const char* name, int w, int h) +{ + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + ImageAttributes attr; + Integration::BitmapResourceType bitmapRequest(attr); + Internal::ResourceTicketPtr ticket = resourceClient.RequestResource( bitmapRequest, name ); + application.SendNotification(); // Flush update messages + application.Render(); // Process resource request + Integration::ResourceRequest* req = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false ); + bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, w, h, w, h ); + Integration::ResourcePointer resourcePtr(bitmap); // reference it + application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr); + application.Render(); // Process LoadComplete + application.SendNotification(); // Process event messages + DALI_TEST_CHECK( ticket->GetLoadingState() == ResourceLoadingSucceeded ); + application.GetPlatform().DiscardRequest(); // Ensure load request is discarded + req=NULL; + application.GetPlatform().ResetTrace(); + + return ticket; +} + +Internal::ImagePtr LoadImage(TestApplication& application, const char* name) +{ + Internal::ImagePtr image = Internal::Image::New(name); + application.SendNotification(); // Flush update messages + application.Render(); // Process resource request + Integration::ResourceRequest* req = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false ); + bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 80,80,80,80 ); + Integration::ResourcePointer resourcePtr(bitmap); // reference it + + application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr); + application.Render(); // Process LoadComplete + application.SendNotification(); // Process event messages + application.GetPlatform().DiscardRequest(); // Ensure load request is discarded + req=NULL; + application.GetPlatform().ResetTrace(); + return image; +} + +} // Anonymous Namespace + +/********************************************************************************/ +/********************************************************************************/ +/********************************************************************************/ + +// Test new with no parameters sets up default object +int UtcDaliMaterialMethodNew01(void) +{ + TestApplication application; + + Internal::SceneGraph::Material* sceneObject = Internal::SceneGraph::Material::New(); + Internal::MaterialProperties props = sceneObject->GetProperties(); // copy. + DALI_TEST_CHECK(props.mOpacity == Dali::Material::DEFAULT_OPACITY); + DALI_TEST_CHECK(props.mShininess == Dali::Material::DEFAULT_SHININESS); + DALI_TEST_CHECK(props.mAmbientColor == Dali::Material::DEFAULT_AMBIENT_COLOR); + DALI_TEST_CHECK(props.mDiffuseColor == Dali::Material::DEFAULT_DIFFUSE_COLOR); + DALI_TEST_CHECK(props.mSpecularColor == Dali::Material::DEFAULT_SPECULAR_COLOR); + DALI_TEST_CHECK(props.mEmissiveColor == Dali::Material::DEFAULT_EMISSIVE_COLOR); + + Internal::ResourceId textureId = sceneObject->GetDiffuseTextureId(); + DALI_TEST_CHECK( !textureId ); + textureId = sceneObject->GetOpacityTextureId(); + DALI_TEST_CHECK( !textureId ); + textureId = sceneObject->GetNormalMapId(); + DALI_TEST_CHECK( !textureId ); + + DALI_TEST_CHECK(! sceneObject->HasDiffuseTexture()); + DALI_TEST_CHECK(! sceneObject->HasOpacityTexture()); + DALI_TEST_CHECK(! sceneObject->HasNormalMap()); + END_TEST; +} + +// Test new with event object sets up parameters appropriately +int UtcDaliMaterialMethodNew02(void) +{ + TestApplication application; + + Internal::Material* material = Internal::Material::New("cloth"); + DALI_TEST_CHECK(material->GetShininess() == Dali::Material::DEFAULT_SHININESS); + DALI_TEST_CHECK(material->GetAmbientColor() == Dali::Material::DEFAULT_AMBIENT_COLOR); + material->SetOpacity(0.4f); + material->SetDiffuseColor(Color::MAGENTA); + + // Create directly + Internal::SceneGraph::Material* sceneObject = Internal::SceneGraph::Material::New(material); + Internal::MaterialProperties props = sceneObject->GetProperties(); // copy. + DALI_TEST_CHECK(props.mOpacity == 0.4f); + DALI_TEST_CHECK(props.mDiffuseColor == Color::MAGENTA); + DALI_TEST_CHECK(props.mShininess == Dali::Material::DEFAULT_SHININESS); + DALI_TEST_CHECK(props.mAmbientColor == Dali::Material::DEFAULT_AMBIENT_COLOR); + DALI_TEST_CHECK(props.mSpecularColor == Dali::Material::DEFAULT_SPECULAR_COLOR); + DALI_TEST_CHECK(props.mEmissiveColor == Dali::Material::DEFAULT_EMISSIVE_COLOR); + + Internal::ResourceId textureId = sceneObject->GetDiffuseTextureId(); + DALI_TEST_CHECK( !textureId ); + textureId = sceneObject->GetOpacityTextureId(); + DALI_TEST_CHECK( !textureId ); + textureId = sceneObject->GetNormalMapId(); + DALI_TEST_CHECK( !textureId ); + + DALI_TEST_CHECK(! sceneObject->HasDiffuseTexture()); + DALI_TEST_CHECK(! sceneObject->HasOpacityTexture()); + DALI_TEST_CHECK(! sceneObject->HasNormalMap()); + + // Create indirectly + const Internal::SceneGraph::Material* sceneObject2 = material->GetSceneObject(); + DALI_TEST_CHECK( sceneObject2 != NULL ); + Internal::MaterialProperties props2 = sceneObject2->GetProperties(); // copy. + DALI_TEST_CHECK(props2.mOpacity == 0.4f); + DALI_TEST_CHECK(props2.mDiffuseColor == Color::MAGENTA); + DALI_TEST_CHECK(props2.mShininess == Dali::Material::DEFAULT_SHININESS); + DALI_TEST_CHECK(props2.mAmbientColor == Dali::Material::DEFAULT_AMBIENT_COLOR); + DALI_TEST_CHECK(props2.mSpecularColor == Dali::Material::DEFAULT_SPECULAR_COLOR); + DALI_TEST_CHECK(props2.mEmissiveColor == Dali::Material::DEFAULT_EMISSIVE_COLOR); + + DALI_TEST_CHECK(! sceneObject2->GetDiffuseTextureId()); + DALI_TEST_CHECK(! sceneObject2->GetOpacityTextureId()); + DALI_TEST_CHECK(! sceneObject2->GetNormalMapId()); + + DALI_TEST_CHECK(! sceneObject2->HasDiffuseTexture()); + DALI_TEST_CHECK(! sceneObject2->HasOpacityTexture()); + DALI_TEST_CHECK(! sceneObject2->HasNormalMap()); + END_TEST; +} + +// Test setting ready texture off stage +int UtcDaliMaterialReadyTextureOffstage(void) +{ + TestApplication application; + + Internal::ResourceTicketPtr ticket = CheckLoadBitmap(application, "diffuse.png", 80, 80); + Internal::SceneGraph::Material* sceneObject = Internal::SceneGraph::Material::New(); + sceneObject->SetDiffuseTextureId(ticket->GetId()); + + DALI_TEST_EQUALS( sceneObject->GetDiffuseTextureId(), ticket->GetId(), TEST_LOCATION ); + END_TEST; +} + +// Test setting unready texture offstage, becoming ready +int UtcDaliMaterialUnreadyTextureOffstage(void) +{ + TestApplication application; + + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + ImageAttributes attr; + Integration::BitmapResourceType bitmapRequest(attr); + Internal::ResourceTicketPtr ticket = resourceClient.RequestResource( bitmapRequest, "image.png" ); + application.SendNotification(); // Flush update messages + application.Render(); // Process resource request + + // Ticket is valid, but no resource yet + Internal::SceneGraph::Material* sceneObject = Internal::SceneGraph::Material::New(); + Internal::ResourceId textureId = ticket->GetId(); + sceneObject->SetDiffuseTextureId(textureId); + Internal::ResourceId textureId2 = sceneObject->GetDiffuseTextureId(); + DALI_TEST_CHECK( textureId == textureId2 ); + + Integration::ResourceRequest* req = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false ); + bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 80, 80, 80, 80 ); + Integration::ResourcePointer resourcePtr(bitmap); // reference it + application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr); + application.Render(); // Process LoadComplete + application.SendNotification(); // Process event messages + DALI_TEST_CHECK( ticket->GetLoadingState() == ResourceLoadingSucceeded ); + + Internal::ResourceId textureId3 = sceneObject->GetDiffuseTextureId(); + DALI_TEST_CHECK( textureId3 ); + DALI_TEST_CHECK( textureId3 == textureId ); + END_TEST; +} + +// Test staging creates render material +int UtcDaliMaterialStaging01(void) +{ + TestApplication application; + TestBoundTextures boundTextures(application); + TestProgram testProgram(application); + + // Create object and set some properties + Internal::SceneGraph::Material* sceneObject = Internal::SceneGraph::Material::New(); + DALI_TEST_CHECK( sceneObject != NULL ); + sceneObject->SetProperties(TEST_PROPS); + + // Stage the object + Internal::SceneGraph::UpdateManager& updateManager = Internal::ThreadLocalStorage::Get().GetUpdateManager(); + AddMaterialMessage( updateManager, sceneObject ); + application.SendNotification(); // Flush update Q + + application.GetPlatform().IncrementGetTimeResult( 1 ); + Integration::UpdateStatus status; + application.GetCore().Update( status ); + + // Check that a render object has been created + Internal::SceneGraph::RenderMaterial* renderMaterial = sceneObject->GetRenderMaterial(); + DALI_TEST_CHECK(renderMaterial != NULL); + // Not on render manager, and should have default props + + Internal::SceneGraph::RenderMaterialUniforms materialUniforms; + renderMaterial->SetUniforms( materialUniforms, testProgram.GetProgram(), Internal::SHADER_DEFAULT ); + + DALI_TEST_EQUALS( testProgram.GetOpacity(), 1.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( testProgram.GetShininess(), 0.5f, TEST_LOCATION ); + DALI_TEST_EQUALS( testProgram.GetAmbientColor(), Vector4(0.2f, 0.2f, 0.2f, 1.0f), TEST_LOCATION); + DALI_TEST_EQUALS( testProgram.GetDiffuseColor(), Vector4(0.8f, 0.8f, 0.8f, 1.0f), TEST_LOCATION); + DALI_TEST_EQUALS( testProgram.GetSpecularColor(), Vector4(0.0f, 0.0f, 0.0f, 1.0f), TEST_LOCATION); + DALI_TEST_EQUALS( testProgram.GetEmissiveColor(), Vector4(0.0f, 0.0f, 0.0f, 1.0f), TEST_LOCATION); + + application.Render(); //Process render Q stores & processes mat + + renderMaterial->SetUniforms( materialUniforms, testProgram.GetProgram(), Internal::SHADER_DEFAULT ); + renderMaterial->BindTextures( testProgram.GetProgram() ); + DALI_TEST_CHECK( boundTextures.GetNumBoundTextures() == 0 ); + + DALI_TEST_EQUALS( testProgram.GetOpacity(), TEST_PROPS.mOpacity, TEST_LOCATION); + DALI_TEST_EQUALS( testProgram.GetShininess(), TEST_PROPS.mShininess, TEST_LOCATION ); + DALI_TEST_EQUALS( testProgram.GetAmbientColor(), TEST_PROPS.mAmbientColor, TEST_LOCATION ); + DALI_TEST_EQUALS( testProgram.GetDiffuseColor(), TEST_PROPS.mDiffuseColor, TEST_LOCATION ); + DALI_TEST_EQUALS( testProgram.GetSpecularColor(), TEST_PROPS.mSpecularColor, TEST_LOCATION ); + DALI_TEST_EQUALS( testProgram.GetEmissiveColor(), TEST_PROPS.mEmissiveColor, TEST_LOCATION ); + END_TEST; +} + +// Test staging creates render material +int UtcDaliMaterialStaging02(void) +{ + TestApplication application; + TestBoundTextures boundTextures(application); + TestProgram testProgram(application); + + Internal::Material* material = Internal::Material::New("cloth"); + material->SetOpacity(0.4f); + material->SetDiffuseColor(Color::MAGENTA); + + // Create object and set some properties + Internal::SceneGraph::Material* sceneObject = Internal::SceneGraph::Material::New(material); + DALI_TEST_CHECK( sceneObject != NULL ); + + // Stage the object + Internal::SceneGraph::UpdateManager& updateManager = Internal::ThreadLocalStorage::Get().GetUpdateManager(); + AddMaterialMessage( updateManager, sceneObject ); + application.SendNotification(); // Flush update Q + + application.GetPlatform().IncrementGetTimeResult( 1 ); + Integration::UpdateStatus status; + application.GetCore().Update( status ); + + // Check that a render object has been created + Internal::SceneGraph::RenderMaterial* renderMaterial = sceneObject->GetRenderMaterial(); + DALI_TEST_CHECK(renderMaterial != NULL); + // Not on render manager, and should have default props + + Internal::SceneGraph::RenderMaterialUniforms materialUniforms; + renderMaterial->SetUniforms( materialUniforms, testProgram.GetProgram(), Internal::SHADER_DEFAULT ); + + DALI_TEST_EQUALS( testProgram.GetOpacity(), 1.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( testProgram.GetShininess(), 0.5f, TEST_LOCATION ); + DALI_TEST_EQUALS( testProgram.GetAmbientColor(), Vector4(0.2f, 0.2f, 0.2f, 1.0f), TEST_LOCATION); + DALI_TEST_EQUALS( testProgram.GetDiffuseColor(), Vector4(0.8f, 0.8f, 0.8f, 1.0f), TEST_LOCATION); + DALI_TEST_EQUALS( testProgram.GetSpecularColor(), Vector4(0.0f, 0.0f, 0.0f, 1.0f), TEST_LOCATION); + DALI_TEST_EQUALS( testProgram.GetEmissiveColor(), Vector4(0.0f, 0.0f, 0.0f, 1.0f), TEST_LOCATION); + + application.Render(); //Process render Q stores & processes mat + + renderMaterial->SetUniforms( materialUniforms, testProgram.GetProgram(), Internal::SHADER_DEFAULT ); + renderMaterial->BindTextures( testProgram.GetProgram() ); + + DALI_TEST_CHECK( boundTextures.GetNumBoundTextures() == 0 ); + DALI_TEST_EQUALS( testProgram.GetOpacity(), 0.4f, TEST_LOCATION); + DALI_TEST_EQUALS( testProgram.GetShininess(), Dali::Material::DEFAULT_SHININESS, TEST_LOCATION ); + DALI_TEST_EQUALS( testProgram.GetAmbientColor(), Dali::Material::DEFAULT_AMBIENT_COLOR, TEST_LOCATION ); + DALI_TEST_EQUALS( testProgram.GetDiffuseColor(), Color::MAGENTA, TEST_LOCATION ); + DALI_TEST_EQUALS( testProgram.GetSpecularColor(), Dali::Material::DEFAULT_SPECULAR_COLOR, TEST_LOCATION ); + DALI_TEST_EQUALS( testProgram.GetEmissiveColor(), Dali::Material::DEFAULT_EMISSIVE_COLOR, TEST_LOCATION ); + END_TEST; +} + + + +// Test setting properties on stage +int UtcDaliMaterialSetPropsWhilstStaged(void) +{ + TestApplication application; + TestBoundTextures boundTextures(application); + TestProgram testProgram(application); + + // Create object with default properties + Internal::SceneGraph::Material* sceneObject = Internal::SceneGraph::Material::New(); + DALI_TEST_CHECK( sceneObject != NULL ); + + // Stage the object + Internal::SceneGraph::UpdateManager& updateManager = Internal::ThreadLocalStorage::Get().GetUpdateManager(); + AddMaterialMessage( updateManager, sceneObject ); + application.SendNotification(); // Flush update Q + application.Render(); // Process update message Q then create & post to render Q + + // Check that a render object has been created + Internal::SceneGraph::RenderMaterial* renderMaterial = sceneObject->GetRenderMaterial(); + DALI_TEST_CHECK(renderMaterial != NULL); + application.Render(); // Update & Prepare renderMat, Process render Q stores & processes mat + + sceneObject->SetProperties(TEST_PROPS); + application.SendNotification(); // Flush update Q + application.Render(); // Update & Prepare material + application.Render(); // Process render Q + + Internal::SceneGraph::RenderMaterialUniforms materialUniforms; + renderMaterial->SetUniforms( materialUniforms, testProgram.GetProgram(), Internal::SHADER_DEFAULT ); + renderMaterial->BindTextures( testProgram.GetProgram() ); + + DALI_TEST_EQUALS( boundTextures.GetNumBoundTextures(), 0u, TEST_LOCATION ); + + DALI_TEST_EQUALS( testProgram.GetOpacity(), TEST_PROPS.mOpacity, TEST_LOCATION); + DALI_TEST_EQUALS( testProgram.GetShininess(), TEST_PROPS.mShininess, TEST_LOCATION ); + DALI_TEST_EQUALS( testProgram.GetAmbientColor(), TEST_PROPS.mAmbientColor, TEST_LOCATION ); + DALI_TEST_EQUALS( testProgram.GetDiffuseColor(), TEST_PROPS.mDiffuseColor, TEST_LOCATION ); + DALI_TEST_EQUALS( testProgram.GetSpecularColor(), TEST_PROPS.mSpecularColor, TEST_LOCATION ); + DALI_TEST_EQUALS( testProgram.GetEmissiveColor(), TEST_PROPS.mEmissiveColor, TEST_LOCATION ); + END_TEST; +} + +// Test setting ready texture on stage +int UtcDaliMaterialSetTextureWhilstStaged(void) +{ + TestApplication application; + TestBoundTextures boundTextures(application); + TestProgram testProgram(application); + + Internal::ResourceTicketPtr ticket = CheckLoadBitmap(application, "diffuse.png", 80, 80); + + // Create object with default properties + Internal::SceneGraph::Material* sceneObject = Internal::SceneGraph::Material::New(); + DALI_TEST_CHECK( sceneObject != NULL ); + + // Stage the object + Internal::SceneGraph::UpdateManager& updateManager = Internal::ThreadLocalStorage::Get().GetUpdateManager(); + AddMaterialMessage( updateManager, sceneObject ); + application.SendNotification(); // Flush update Q + application.Render(); // Process update message Q then create & post to render Q + + // Check that a render object has been created + Internal::SceneGraph::RenderMaterial* renderMaterial = sceneObject->GetRenderMaterial(); + DALI_TEST_CHECK(renderMaterial != NULL); + application.Render(); // Update & Prepare renderMat, Process render Q stores & processes mat + + sceneObject->SetDiffuseTextureId(ticket->GetId()); + application.SendNotification(); // Flush update Q + application.Render(); // Update & Prepare material + application.Render(); // Process render Q + + renderMaterial->BindTextures( testProgram.GetProgram() ); + DALI_TEST_CHECK( boundTextures.CheckFirstTextureBound( GL_TEXTURE0 ) ); + END_TEST; +} + +// Test setting unready texture on stage, becoming ready +int UtcDaliMaterialSetUnreadyTextureWhilstStaged(void) +{ + TestApplication application; + TestBoundTextures boundTextures(application); + TestProgram testProgram(application); + + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + ImageAttributes attr; + Integration::BitmapResourceType bitmapRequest(attr); + Internal::ResourceTicketPtr ticket = resourceClient.RequestResource( bitmapRequest, "image.png" ); + application.SendNotification(); // Flush update messages + application.Render(); // Process resource request + + + // Create object with default properties + Internal::SceneGraph::Material* sceneObject = Internal::SceneGraph::Material::New(); + DALI_TEST_CHECK( sceneObject != NULL ); + + // Stage the object + Internal::SceneGraph::UpdateManager& updateManager = Internal::ThreadLocalStorage::Get().GetUpdateManager(); + AddMaterialMessage( updateManager, sceneObject ); + application.SendNotification(); // Flush update Q + application.Render(); // Process update message Q then create & post to render Q + + // Check that a render object has been created + Internal::SceneGraph::RenderMaterial* renderMaterial = sceneObject->GetRenderMaterial(); + DALI_TEST_CHECK(renderMaterial != NULL); + application.Render(); // Update & Prepare renderMat, Process render Q stores & processes mat + + sceneObject->SetDiffuseTextureId(ticket->GetId()); + application.SendNotification(); // Flush update Q + application.Render(); // Update & Prepare material + application.Render(); // Process render Q + + renderMaterial->BindTextures( testProgram.GetProgram() ); + + DALI_TEST_EQUALS( boundTextures.GetNumBoundTextures(), 0u, TEST_LOCATION ); + + Integration::ResourceRequest* req = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false ); + bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 80, 80, 80, 80 ); + Integration::ResourcePointer resourcePtr(bitmap); // reference it + application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr); + application.Render(); // Process LoadComplete + application.SendNotification(); // Process event messages + + renderMaterial->BindTextures( testProgram.GetProgram() ); + DALI_TEST_CHECK( boundTextures.CheckFirstTextureBound( GL_TEXTURE0 ) ); + END_TEST; +} + +// Test IsOpaque without texture, with unready texture, with ready texture + +int UtcDaliMaterialIsOpaqueWithoutTexture(void) +{ + TestApplication application; + + // Create object with default properties + Internal::SceneGraph::Material* sceneObject = Internal::SceneGraph::Material::New(); + DALI_TEST_CHECK( sceneObject != NULL ); + + // Stage the object + Internal::SceneGraph::UpdateManager& updateManager = Internal::ThreadLocalStorage::Get().GetUpdateManager(); + AddMaterialMessage( updateManager, sceneObject ); + application.SendNotification(); // Flush update Q + application.Render(); // Process update message Q then create & post to render Q + + // Check that a render object has been created + Internal::SceneGraph::RenderMaterial* renderMaterial = sceneObject->GetRenderMaterial(); + DALI_TEST_CHECK(renderMaterial != NULL); + application.Render(); // Update & Prepare renderMat, Process render Q stores & processes mat + + DALI_TEST_CHECK( sceneObject->IsOpaque() ); + END_TEST; +} + +int UtcDaliMaterialIsOpaqueWithTexture(void) +{ + TestApplication application; + + Internal::ResourceTicketPtr ticket = CheckLoadBitmap(application, "diffuse.png", 80, 80); + + // Create object with default properties + Internal::SceneGraph::Material* sceneObject = Internal::SceneGraph::Material::New(); + DALI_TEST_CHECK( sceneObject != NULL ); + + // Stage the object + Internal::SceneGraph::UpdateManager& updateManager = Internal::ThreadLocalStorage::Get().GetUpdateManager(); + AddMaterialMessage( updateManager, sceneObject ); + application.SendNotification(); // Flush update Q + application.Render(); // Process update message Q then create & post to render Q + + // Check that a render object has been created + Internal::SceneGraph::RenderMaterial* renderMaterial = sceneObject->GetRenderMaterial(); + DALI_TEST_CHECK(renderMaterial != NULL); + application.Render(); // Update & Prepare renderMat, Process render Q stores & processes mat + + DALI_TEST_CHECK( sceneObject->IsOpaque() ); + + sceneObject->SetDiffuseTextureId(ticket->GetId()); + application.SendNotification(); // Flush update Q + application.Render(); // Update & Prepare material + application.Render(); // Process render Q + + DALI_TEST_CHECK( ! sceneObject->IsOpaque() ); + END_TEST; +} + + +int UtcDaliMaterialIsOpaqueWithProps(void) +{ + TestApplication application; + + // Create object with default properties + Internal::SceneGraph::Material* sceneObject = Internal::SceneGraph::Material::New(); + DALI_TEST_CHECK( sceneObject != NULL ); + + // Stage the object + Internal::SceneGraph::UpdateManager& updateManager = Internal::ThreadLocalStorage::Get().GetUpdateManager(); + AddMaterialMessage( updateManager, sceneObject ); + application.SendNotification(); // Flush update Q + application.Render(); // Process update message Q then create & post to render Q + + // Check that a render object has been created + Internal::SceneGraph::RenderMaterial* renderMaterial = sceneObject->GetRenderMaterial(); + DALI_TEST_CHECK(renderMaterial != NULL); + application.Render(); // Update & Prepare renderMat, Process render Q stores & processes mat + + DALI_TEST_CHECK( sceneObject->IsOpaque() ); + + sceneObject->SetProperties(TEST_PROPS); + application.SendNotification(); // Flush update Q + application.Render(); // Update & Prepare material + application.Render(); // Process render Q + + DALI_TEST_CHECK( ! sceneObject->IsOpaque() ); + END_TEST; +} + +int UtcDaliMaterialRender(void) +{ + TestApplication application; + TestBoundTextures boundTextures(application); + + { + + MeshData meshData; + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + BoneContainer bones; + ConstructVertices(vertices, 60); + ConstructFaces(vertices, faces); + Dali::Material material = ConstructMaterial(); + + Internal::ImagePtr image = LoadImage(application, "texture.png"); + Image imageHandle(image.Get()); + material.SetDiffuseTexture(imageHandle); + meshData.SetData(vertices, faces, bones, material); + Mesh mesh = Mesh::New(meshData); + + MeshActor actor = MeshActor::New(mesh); + std::string name = "AMeshActor"; + actor.SetName(name); + actor.SetAffectedByLighting(false); + Stage::GetCurrent().Add(actor); + + material.SetOpacity(TEST_PROPS.mOpacity); + material.SetShininess(TEST_PROPS.mShininess); + material.SetAmbientColor(TEST_PROPS.mAmbientColor); + material.SetDiffuseColor(TEST_PROPS.mDiffuseColor); + material.SetSpecularColor(TEST_PROPS.mSpecularColor); + material.SetEmissiveColor(TEST_PROPS.mEmissiveColor); + + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + application.SendNotification(); + + DALI_TEST_CHECK(application.GetGlAbstraction().CheckUniformValue("uMaterial.mOpacity", TEST_PROPS.mOpacity ) ); + DALI_TEST_CHECK(application.GetGlAbstraction().CheckUniformValue("uMaterial.mShininess", TEST_PROPS.mShininess ) ); + DALI_TEST_CHECK(application.GetGlAbstraction().CheckUniformValue("uMaterial.mAmbient", TEST_PROPS.mAmbientColor ) ); + DALI_TEST_CHECK(application.GetGlAbstraction().CheckUniformValue("uMaterial.mDiffuse", TEST_PROPS.mDiffuseColor ) ); + DALI_TEST_CHECK(application.GetGlAbstraction().CheckUniformValue("uMaterial.mSpecular", TEST_PROPS.mSpecularColor ) ); + DALI_TEST_CHECK(application.GetGlAbstraction().CheckUniformValue("uMaterial.mEmissive", TEST_PROPS.mEmissiveColor ) ); + + DALI_TEST_CHECK(boundTextures.CheckFirstTextureBound( GL_TEXTURE0 )); + + Stage::GetCurrent().Remove(actor); + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + } + application.SendNotification(); + application.Render(); + + // texture should have been removed: + DALI_TEST_CHECK( boundTextures.CheckFirstTextureDeleted() ); + END_TEST; +} diff --git a/automated-tests/src/dali-internal/utc-DaliInternal-Font.cpp b/automated-tests/src/dali-internal/utc-DaliInternal-Font.cpp new file mode 100644 index 0000000..4fe295e --- /dev/null +++ b/automated-tests/src/dali-internal/utc-DaliInternal-Font.cpp @@ -0,0 +1,146 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +// Internal headers are allowed here + +#include +#include +#include + +using namespace Dali; + +// Called only once before first test is run. +void utc_dali_internal_font_startup() +{ + test_return_value = TET_UNDEF; +} + +// Called only once after last test is run +void utc_dali_internal_font_cleanup() +{ + test_return_value = TET_PASS; +} + + +namespace +{ + +static const char* TestText = "Some text"; + + +Integration::GlyphMetrics characters[] = + { + {' ', 1, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f}, + {'S', 1, 10.0f, 20.0f, 0.0f, 1.0f, 12.0f}, + {'o', 1, 11.0f, 20.0f, 0.0f, 1.0f, 13.0f}, + {'m', 1, 12.0f, 20.0f, 0.0f, 1.0f, 14.0f}, + {'e', 1, 13.0f, 20.0f, 0.0f, 1.0f, 15.0f}, + {'t', 1, 14.0f, 20.0f, 0.0f, 1.0f, 16.0f}, + {'x', 1, 15.0f, 20.0f, 0.0f, 1.0f, 17.0f} }; + +static Integration::GlyphSet* BuildGlyphSet() +{ + Integration::GlyphSet* set = new Integration::GlyphSet(); + Integration::BitmapPtr bitmapData; + + for (unsigned int index = 0; index < sizeof(characters)/sizeof(characters[0]); index++) + { + set->AddCharacter(bitmapData, characters[index]); + } + + set->mLineHeight = 20.0f; + set->mUnitsPerEM = 2048.0f/64.0f; + + return set; +} + +static Font CreateFont(TestApplication& application) +{ + Integration::GlyphSet* glyphSet = BuildGlyphSet(); + Integration::ResourcePointer resourcePtr(glyphSet); // reference it + + // Don't use a font which could be cached otherwise cached values will be used making measure text test to fail. + Font font = Font::New(FontParameters("TET-FreeSans", "Book", PointSize(8))); + application.SendNotification(); // Send to update thread + application.Render(16); // Process request + application.Render(16); // Resource complete + application.SendNotification(); // Update event objects + application.GetPlatform().DiscardRequest(); // Ensure load request is discarded + return font; +} + +} //anonymous namespace + + +int UtcDaliFontMeasureTextWidth(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::Font::MeasureTextWidth()"); + + Font testFont = CreateFont(application); + float width = testFont.MeasureTextWidth(TestText, 30.0f); + + DALI_TEST_EQUALS(width, 270.0f, 0.001f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliFontMeasureTextWidthNegative(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::Font::MeasureTextWidth() with negative height"); + + Font testFont = CreateFont(application); + float width = testFont.MeasureTextWidth(TestText, -30.0f); + + DALI_TEST_EQUALS(width, 0.0f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliFontMeasureTextHeight(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::Font::MeasureTextHeight()"); + + Font testFont = CreateFont(application); + float height = testFont.MeasureTextHeight(TestText, 200.0f); + + DALI_TEST_EQUALS(height, 22.2222f, 0.001f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliFontMeasureTextHeightNegative(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::Font::MeasureTextHeight() with negative width"); + + Font testFont = CreateFont(application); + float height = testFont.MeasureTextHeight(TestText, -200.0f); + + DALI_TEST_EQUALS(height, 0.0f, TEST_LOCATION); + END_TEST; +} diff --git a/automated-tests/src/dali-internal/utc-DaliInternal-ResourceClient.cpp b/automated-tests/src/dali-internal/utc-DaliInternal-ResourceClient.cpp new file mode 100644 index 0000000..52b867a --- /dev/null +++ b/automated-tests/src/dali-internal/utc-DaliInternal-ResourceClient.cpp @@ -0,0 +1,1419 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +// Internal headers are allowed here + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +using namespace Dali; +#include + +namespace +{ + +class TestTicketObserver : public Internal::ResourceTicketObserver +{ +public: + TestTicketObserver() + : mLoadingFailedCalled(0), mLoadingSucceededCalled(0), + mSavingFailedCalled(0), mSavingSucceededCalled(0), + mUploadedCount(0) + {} + + int LoadFailedCalled() { + tet_printf("TicketObserver: LoadingFailed() called %d times", mLoadingFailedCalled); + return mLoadingFailedCalled; + } + int LoadSucceededCalled() { + tet_printf("TicketObserver: LoadingSucceeded() called %d times", mLoadingSucceededCalled); + return mLoadingSucceededCalled; + } + int SaveFailedCalled() { + tet_printf("TicketObserver: SavingFailed() called %d times", mSavingFailedCalled); + return mSavingFailedCalled; + } + int SaveSucceededCalled() { + tet_printf("TicketObserver: SavingSucceeded() called %d times", mSavingSucceededCalled); + return mSavingSucceededCalled; + } + int UploadCalled() { + tet_printf("TicketObserver: Uploaded() called %d times", mUploadedCount); + return mUploadedCount; + } + void Reset() { + mLoadingFailedCalled = 0; + mLoadingSucceededCalled = 0; + mSavingFailedCalled = 0; + mSavingSucceededCalled = 0; + mUploadedCount = 0; + } + +public: // From ResourceTicketObserver + virtual void ResourceLoadingFailed(const Internal::ResourceTicket& ticket) {mLoadingFailedCalled++;} + virtual void ResourceLoadingSucceeded(const Internal::ResourceTicket& ticket) {mLoadingSucceededCalled++;} + virtual void ResourceSavingFailed(const Internal::ResourceTicket& ticket) {mSavingFailedCalled++;} + virtual void ResourceSavingSucceeded(const Internal::ResourceTicket& ticket) {mSavingSucceededCalled++;} + virtual void ResourceUploaded(const Internal::ResourceTicket& ticket) {mUploadedCount++;} + +private: + int mLoadingFailedCalled; + int mLoadingSucceededCalled; + int mSavingFailedCalled; + int mSavingSucceededCalled; + int mUploadedCount; +}; + +class TestTicketLifetimeObserver : public Internal::ResourceTicketLifetimeObserver +{ +public: + TestTicketLifetimeObserver() : resourceTicketDiscarded(false) {} + + virtual void ResourceTicketDiscarded( const Internal::ResourceTicket& ticket ) + { resourceTicketDiscarded = true; } + + void Reset() { resourceTicketDiscarded = false; } + bool resourceTicketDiscarded; +}; + +static TestTicketObserver testTicketObserver; +static TestTicketLifetimeObserver testTicketLifetimeObserver; + + +Internal::ImagePtr LoadImage(TestApplication& application, char* name) +{ + Internal::ImagePtr image = Internal::Image::New(name); + application.SendNotification(); // Flush update messages + application.Render(); // Process resource request + Integration::ResourceRequest* req = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false ); + bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 80,80,80,80 ); + Integration::ResourcePointer resourcePtr(bitmap); // reference it + application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr); + application.Render(); // Process LoadComplete + application.SendNotification(); // Process event messages + application.GetPlatform().DiscardRequest(); // Ensure load request is discarded + req=NULL; + application.GetPlatform().ResetTrace(); + return image; +} + + +Internal::ResourceTicketPtr CheckLoadBitmap(TestApplication& application, const char* name, int w, int h) +{ + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + ImageAttributes attr; + Integration::BitmapResourceType bitmapRequest(attr); + Internal::ResourceTicketPtr ticket = resourceClient.RequestResource( bitmapRequest, name ); + ticket->AddObserver(testTicketObserver); + application.SendNotification(); // Flush update messages + application.Render(); // Process resource request + Integration::ResourceRequest* req = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false ); + bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, w, h, w, h ); + Integration::ResourcePointer resourcePtr(bitmap); // reference it + application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr); + application.Render(); // Process LoadComplete + application.SendNotification(); // Process event messages + DALI_TEST_CHECK( ticket->GetLoadingState() == ResourceLoadingSucceeded ); + application.GetPlatform().DiscardRequest(); // Ensure load request is discarded + req=NULL; + application.GetPlatform().ResetTrace(); + + return ticket; +} + +Internal::ResourceTicketPtr CheckLoadModel(TestApplication& application, const char* name) +{ + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + Internal::ResourceTicketPtr ticket = resourceClient.RequestResource( Integration::ModelResourceType(), name ); + ticket->AddObserver(testTicketObserver); + + application.SendNotification(); // Flush update messages + application.Render(); // Process resource request + Integration::ResourceRequest* req = application.GetPlatform().GetRequest(); + Dali::ModelData modelData = BuildTreeModel(); + Internal::ModelData& modelDataImpl = GetImplementation(modelData); + Integration::ResourcePointer resourcePtr(&modelDataImpl); + application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr); + application.Render(); // Process LoadComplete + application.SendNotification(); // Process event messages + DALI_TEST_CHECK(ticket->GetLoadingState() == ResourceLoadingSucceeded); + application.GetPlatform().DiscardRequest(); // Ensure load request is discarded + req=NULL; + application.GetPlatform().ResetTrace(); + + return ticket; +} + +} //anonymous namespace + + +void utc_dali_internal_resource_client_startup() +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_internal_resource_client_cleanup() +{ + test_return_value = TET_PASS; +} + +// Load a bitmap resource successfully, then discard it's ticket +int UtcDaliInternalRequestResourceBitmapRequests01(void) +{ + TestApplication application; // Reset all test adapter return codes + + tet_infoline("Testing bitmap requests"); + + Internal::ResourceManager& resourceManager = Internal::ThreadLocalStorage::Get().GetResourceManager(); + ImageAttributes attr; + Integration::BitmapResourceType bitmapRequest (attr); + Internal::ResourceId id(0); + + testTicketObserver.Reset(); + + { + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + /************************************************************ + * FUNCTION UNDER TEST + ***********************************************************/ + Internal::ResourceTicketPtr ticket = resourceClient.RequestResource( bitmapRequest, "image.png" ); + ticket->AddObserver(testTicketObserver); + + // Update thread will request the bitmap resource: + // Sets application.GetPlatform().mRequest + application.SendNotification(); // Run flush update queue + application.Render(1); // Process update messages + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc ) ); + + application.SendNotification(); // Send any event messages + DALI_TEST_CHECK( testTicketObserver.LoadFailedCalled() == 0 ); + DALI_TEST_CHECK( testTicketObserver.LoadSucceededCalled() == 0 ); + DALI_TEST_CHECK( ticket->GetLoadingState() == ResourceLoading ); + + Internal::ImageTicketPtr imageTicket(dynamic_cast(ticket.Get())); + DALI_TEST_CHECK( imageTicket ); + DALI_TEST_EQUALS( imageTicket->GetWidth(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( imageTicket->GetHeight(), 0, TEST_LOCATION ); + + // Create a resource + Integration::ResourceRequest* req = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false ); + bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 80, 80, 80, 80 ); + Integration::ResourcePointer resourcePtr(bitmap); // reference it + + // Set up platform abstraction to load it + id=req->GetId(); + application.GetPlatform().SetResourceLoaded( id, Integration::ResourceBitmap, resourcePtr ); + + DALI_TEST_CHECK( ! resourceManager.IsResourceLoaded(req->GetId()) ); + + // load the cache, which will immediately have the loaded resource + application.Render(0); + + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::GetResourcesFunc ) ); + + DALI_TEST_CHECK( resourceManager.IsResourceLoaded(req->GetId()) ); + Internal::BitmapMetadata bitmapData = resourceManager.GetBitmapMetadata(req->GetId()); + DALI_TEST_CHECK( bitmapData.GetWidth() == 80 ); + DALI_TEST_CHECK( bitmapData.GetHeight() == 80 ); + + DALI_TEST_EQUALS( imageTicket->GetWidth(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( imageTicket->GetHeight(), 0, TEST_LOCATION ); + + // Trigger the event thread to process notify messages. Should then trigger the signals + // in the ticket observer + application.SendNotification(); + + DALI_TEST_CHECK( ticket->GetLoadingState() == ResourceLoadingSucceeded ); + DALI_TEST_EQUALS(testTicketObserver.LoadSucceededCalled(), 1, TEST_LOCATION ); + + // Check that the image ticket was updated with the image attributes + DALI_TEST_EQUALS( imageTicket->GetWidth(), 80, TEST_LOCATION ); + DALI_TEST_EQUALS( imageTicket->GetHeight(), 80, TEST_LOCATION ); + } // Discard ticket + + application.SendNotification(); // Flush update queue (with ticket discarded message + application.Render(1); // Process update messages + application.SendNotification(); // Send event notifications + application.Render(1); // Process update messages + + // Resource should have been discarded. + DALI_TEST_CHECK( ! application.GetPlatform().WasCalled(TestPlatformAbstraction::CancelLoadFunc ) ); + DALI_TEST_CHECK( ! resourceManager.IsResourceLoaded(id)); + + DALI_TEST_EQUALS(testTicketObserver.LoadSucceededCalled(), 1, TEST_LOCATION ); + DALI_TEST_EQUALS(testTicketObserver.LoadFailedCalled(), 0, TEST_LOCATION ); + END_TEST; +} + +// Starting Loading a bitmap resource, then discard it's ticket before loading complete. +int UtcDaliInternalRequestResourceBitmapRequests02(void) +{ + TestApplication application; // Reset all test adapter return codes + + tet_infoline("Testing bitmap request ticket discard before load complete"); + + Internal::ResourceManager& resourceManager = Internal::ThreadLocalStorage::Get().GetResourceManager(); + ImageAttributes attr; + Integration::BitmapResourceType bitmapRequest (attr); + Internal::ResourceId id(0); + + testTicketObserver.Reset(); + + { + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + /************************************************************ + * FUNCTION UNDER TEST + ***********************************************************/ + Internal::ResourceTicketPtr ticket = resourceClient.RequestResource( bitmapRequest, "image.png" ); + ticket->AddObserver(testTicketObserver); + Internal::ImageTicketPtr imageTicket(dynamic_cast(ticket.Get())); + DALI_TEST_CHECK( imageTicket ); + DALI_TEST_EQUALS( imageTicket->GetWidth(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( imageTicket->GetHeight(), 0, TEST_LOCATION ); + + // Update thread will request the bitmap resource: + // Sets application.GetPlatform().mRequest + application.SendNotification(); // Run flush update queue + application.Render(1); + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc ) ); + Integration::ResourceRequest* req = application.GetPlatform().GetRequest(); + id=req->GetId(); + + application.SendNotification(); // Should produce no messages + DALI_TEST_EQUALS( testTicketObserver.LoadSucceededCalled(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( testTicketObserver.LoadFailedCalled(), 0, TEST_LOCATION ); + + DALI_TEST_CHECK( ! resourceManager.IsResourceLoaded(id)); + + DALI_TEST_EQUALS( imageTicket->GetWidth(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( imageTicket->GetHeight(), 0, TEST_LOCATION ); + DALI_TEST_CHECK( ticket->GetLoadingState() == ResourceLoading ); + + } // Discard ticket + + // Ensure ticket discarded message is sent to update thread + application.SendNotification(); // Flush update queue + application.Render(0); // Process update messages + + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::CancelLoadFunc ) ); + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::GetResourcesFunc ) ); + + DALI_TEST_CHECK( ! resourceManager.IsResourceLoaded(id)); + + // Trigger the event thread to process notify messages. Should then trigger the signals + // in the ticket observer + application.SendNotification(); + + DALI_TEST_EQUALS(testTicketObserver.LoadSucceededCalled(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS(testTicketObserver.LoadFailedCalled(), 0, TEST_LOCATION ); + END_TEST; +} + +// start loading a bitmap resource that doesn't exist, then discard it's ticket after failure +int UtcDaliInternalRequestResourceBitmapRequests03(void) +{ + TestApplication application; // Reset all test adapter return codes + + tet_infoline("Load bitmap that doesn't exist, followed by ticket discard. Expect LoadingFailed"); + + Internal::ResourceManager& resourceManager = Internal::ThreadLocalStorage::Get().GetResourceManager(); + ImageAttributes attr; + Integration::BitmapResourceType bitmapRequest (attr); + Internal::ResourceId id(0); + + testTicketObserver.Reset(); + { // Scope lifetime of ticket + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + + /************************************************************ + * FUNCTION UNDER TEST + ***********************************************************/ + Internal::ResourceTicketPtr ticket = resourceClient.RequestResource( bitmapRequest, "image.png" ); + ticket->AddObserver(testTicketObserver); + Internal::ImageTicketPtr imageTicket(dynamic_cast(ticket.Get())); + DALI_TEST_CHECK( imageTicket ); + DALI_TEST_EQUALS( imageTicket->GetWidth(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( imageTicket->GetHeight(), 0, TEST_LOCATION ); + + // Update thread will request the bitmap resource: + // Sets application.GetPlatform().mRequest + application.SendNotification(); // Run flush update queue + application.Render(1); // process update messages + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc ) ); + Integration::ResourceRequest* req = application.GetPlatform().GetRequest(); + id=req->GetId(); + application.SendNotification(); // Should produce no messages + DALI_TEST_CHECK( testTicketObserver.LoadFailedCalled() == 0 ); + DALI_TEST_CHECK( testTicketObserver.LoadSucceededCalled() == 0 ); + + DALI_TEST_CHECK( ! resourceManager.IsResourceLoaded(id)); + + application.GetPlatform().SetResourceLoadFailed(id, Integration::FailureFileNotFound ); + + application.Render(0); // Get failed result + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::GetResourcesFunc ) ); + application.SendNotification(); // send failed + DALI_TEST_CHECK( testTicketObserver.LoadFailedCalled() != 0 ); + DALI_TEST_CHECK( ticket->GetLoadingState() == ResourceLoadingFailed ); + + DALI_TEST_CHECK( testTicketObserver.LoadSucceededCalled() == 0 ); + DALI_TEST_EQUALS( imageTicket->GetWidth(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( imageTicket->GetHeight(), 0, TEST_LOCATION ); + + DALI_TEST_CHECK( ! resourceManager.IsResourceLoaded(id)); + } // Discard ticket + + application.Render(0); // Send DiscardTicket + application.SendNotification(); + + DALI_TEST_CHECK( ! resourceManager.IsResourceLoaded(id)); + END_TEST; +} + + + +// Load a bitmap resource successfully, then reload it +int UtcDaliInternalRequestReloadBitmapRequests01(void) +{ + TestApplication application; // Reset all test adapter return codes + + tet_infoline("Testing bitmap reload after successful load"); + + Internal::ResourceManager& resourceManager = Internal::ThreadLocalStorage::Get().GetResourceManager(); + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + + Internal::ResourceId id(0); + testTicketObserver.Reset(); + + { + Internal::ResourceTicketPtr ticket = CheckLoadBitmap( application, "image.png", 80, 80 ); + Internal::ImageTicketPtr imageTicket(dynamic_cast(ticket.Get())); + id = ticket->GetId(); + + // Reset call statistics - test that resource is reloaded + application.GetPlatform().ResetTrace(); + + /************************************************************ + * FUNCTION UNDER TEST + ***********************************************************/ + resourceClient.ReloadResource( ticket->GetId() ); + + DALI_TEST_CHECK( ! application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc ) ); + application.SendNotification(); // Flush update messages + application.Render(0); // Process update messages + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc ) ); + application.SendNotification(); // Process event messages + + DALI_TEST_EQUALS( ticket->GetLoadingState(), ResourceLoading, TEST_LOCATION ); + DALI_TEST_EQUALS( testTicketObserver.LoadFailedCalled(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( testTicketObserver.LoadSucceededCalled(), 1, TEST_LOCATION ); + DALI_TEST_EQUALS( testTicketObserver.UploadCalled(), 0, TEST_LOCATION ); + + // Create a new resource - the image size could have changed in the meantime + Integration::ResourceRequest* req = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap2 = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false ); + bitmap2->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 120, 120, 120, 120 ); + Integration::ResourcePointer resourcePtr2(bitmap2); // reference it + DALI_TEST_CHECK( req->GetId() == ticket->GetId() ); + application.GetPlatform().SetResourceLoaded(id, Integration::ResourceBitmap, resourcePtr2); + + application.Render(0); // Process update messages / UpdateCache + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::GetResourcesFunc ) ); + + DALI_TEST_CHECK( resourceManager.IsResourceLoaded(id)); + Internal::BitmapMetadata bitmapData = resourceManager.GetBitmapMetadata(id); + DALI_TEST_CHECK( bitmapData.GetWidth() == 120 ); + DALI_TEST_CHECK( bitmapData.GetHeight() == 120 ); + + // Ticket can't have been updated yet - it should still have old values + DALI_TEST_EQUALS( imageTicket->GetWidth(), 80, TEST_LOCATION ); + DALI_TEST_EQUALS( imageTicket->GetHeight(), 80, TEST_LOCATION ); + + application.SendNotification(); // Process event messages + application.Render(0); // Process update messages / UpdateCache + application.SendNotification(); // Process event messages + + DALI_TEST_EQUALS( testTicketObserver.LoadSucceededCalled(), 2, TEST_LOCATION ); + DALI_TEST_EQUALS( testTicketObserver.UploadCalled(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( ticket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION ); + DALI_TEST_EQUALS( imageTicket->GetWidth(), 120, TEST_LOCATION ); + DALI_TEST_EQUALS( imageTicket->GetHeight(), 120, TEST_LOCATION ); + + } // Discard ticket + + application.SendNotification(); // Flush update queue (with ticket discarded message + application.Render(1); // Process update messages + application.SendNotification(); // Send event notifications + application.Render(1); // Process update messages + + // Resource should have been discarded. + DALI_TEST_CHECK( ! application.GetPlatform().WasCalled(TestPlatformAbstraction::CancelLoadFunc ) ); + DALI_TEST_CHECK( ! resourceManager.IsResourceLoaded(id)); + + DALI_TEST_EQUALS( testTicketObserver.LoadSucceededCalled(), 2, TEST_LOCATION ); + DALI_TEST_EQUALS( testTicketObserver.LoadFailedCalled(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( testTicketObserver.UploadCalled(), 0, TEST_LOCATION ); + END_TEST; +} + + +int UtcDaliInternalRequestReloadBitmapRequests02(void) +{ + TestApplication application; // Reset all test adapter return codes + + tet_infoline("Testing bitmap reload during first load"); + + Internal::ResourceManager& resourceManager = Internal::ThreadLocalStorage::Get().GetResourceManager(); + ImageAttributes attr; + Integration::BitmapResourceType bitmapRequest (attr); + Internal::ResourceId id(0); + + testTicketObserver.Reset(); + + { + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + Internal::ResourceTicketPtr ticket = resourceClient.RequestResource( bitmapRequest, "image.png" ); + ticket->AddObserver(testTicketObserver); + + // Update thread will request the bitmap resource: + // Sets application.GetPlatform().mRequest + application.SendNotification(); // Run flush update queue + application.Render(1); // Process update messages + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc ) ); + + application.SendNotification(); // Send any event messages + DALI_TEST_CHECK( testTicketObserver.LoadFailedCalled() == 0 ); + DALI_TEST_CHECK( testTicketObserver.LoadSucceededCalled() == 0 ); + + Internal::ImageTicketPtr imageTicket(dynamic_cast(ticket.Get())); + DALI_TEST_CHECK( imageTicket ); + DALI_TEST_EQUALS( imageTicket->GetWidth(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( imageTicket->GetHeight(), 0, TEST_LOCATION ); + + + /************************************************************ + * FUNCTION UNDER TEST + ***********************************************************/ + resourceClient.ReloadResource( ticket->GetId() ); + /************************************************************ + * Expected result - current load completes as usual, no reload requested + ************************************************************/ + + application.SendNotification(); // Flush update methods + + // Reset call statistics - test that resource is not reloaded + application.GetPlatform().ResetTrace(); + + application.Render(0); // Process reload message (nothing for UpdateCache yet) + + DALI_TEST_CHECK( ! application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc ) ); + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::GetResourcesFunc ) ); + // Create a resource + Integration::ResourceRequest* req = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false ); + bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 80, 80, 80, 80 ); + Integration::ResourcePointer resourcePtr(bitmap); // reference it + + // Set up platform abstraction to load it + id=req->GetId(); + + application.GetPlatform().SetResourceLoaded(id, Integration::ResourceBitmap, resourcePtr); + + DALI_TEST_CHECK( ! resourceManager.IsResourceLoaded(id)); + + application.GetPlatform().ResetTrace(); + // load the cache, which will immediately have the loaded resource + application.Render(0); + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::GetResourcesFunc ) ); + DALI_TEST_CHECK( resourceManager.IsResourceLoaded(id)); + Internal::BitmapMetadata bitmapData = resourceManager.GetBitmapMetadata(id); + DALI_TEST_CHECK( bitmapData.GetWidth() == 80 ); + DALI_TEST_CHECK( bitmapData.GetHeight() == 80 ); + + DALI_TEST_EQUALS( imageTicket->GetWidth(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( imageTicket->GetHeight(), 0, TEST_LOCATION ); + + // Trigger the event thread to process notify messages. Should then trigger the signals + // in the ticket observer + application.SendNotification(); + + DALI_TEST_EQUALS( testTicketObserver.LoadSucceededCalled(), 1, TEST_LOCATION ); + DALI_TEST_EQUALS( testTicketObserver.UploadCalled(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( ticket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION ); + + // Check that the image ticket was updated with the image attributes + DALI_TEST_EQUALS( imageTicket->GetWidth(), 80, TEST_LOCATION ); + DALI_TEST_EQUALS( imageTicket->GetHeight(), 80, TEST_LOCATION ); + + DALI_TEST_CHECK( ! application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc ) ); + + application.SendNotification(); // Flush update messages + application.Render(0); // Process update messages + + // There should be no reload + DALI_TEST_CHECK( ! application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc ) ); + application.SendNotification(); // Process event messages + + DALI_TEST_EQUALS( ticket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION ); + DALI_TEST_EQUALS( testTicketObserver.LoadFailedCalled(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( testTicketObserver.LoadSucceededCalled(), 1, TEST_LOCATION ); + DALI_TEST_EQUALS( testTicketObserver.UploadCalled(), 0, TEST_LOCATION ); + + DALI_TEST_CHECK( resourceManager.IsResourceLoaded(id)); + bitmapData = resourceManager.GetBitmapMetadata(id); + DALI_TEST_CHECK( bitmapData.GetWidth() == 80 ); + DALI_TEST_CHECK( bitmapData.GetHeight() == 80 ); + DALI_TEST_EQUALS( imageTicket->GetWidth(), 80, TEST_LOCATION ); + DALI_TEST_EQUALS( imageTicket->GetHeight(), 80, TEST_LOCATION ); + + } // Discard ticket + END_TEST; +} + + +int UtcDaliInternalRequestReloadBitmapRequests03(void) +{ + TestApplication application; // Reset all test adapter return codes + + tet_infoline("Testing bitmap reload at end of first load"); + + Internal::ResourceManager& resourceManager = Internal::ThreadLocalStorage::Get().GetResourceManager(); + ImageAttributes attr; + Integration::BitmapResourceType bitmapRequest (attr); + Internal::ResourceId id(0); + + testTicketObserver.Reset(); + + { + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + Internal::ResourceTicketPtr ticket = resourceClient.RequestResource( bitmapRequest, "image.png" ); + ticket->AddObserver(testTicketObserver); + + // Update thread will request the bitmap resource: + // Sets application.GetPlatform().mRequest + application.SendNotification(); // Run flush update queue + application.Render(1); // Process update messages + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc ) ); + + application.SendNotification(); // Send any event messages + DALI_TEST_CHECK( testTicketObserver.LoadFailedCalled() == 0 ); + DALI_TEST_CHECK( testTicketObserver.LoadSucceededCalled() == 0 ); + + Internal::ImageTicketPtr imageTicket(dynamic_cast(ticket.Get())); + DALI_TEST_CHECK( imageTicket ); + DALI_TEST_EQUALS( imageTicket->GetWidth(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( imageTicket->GetHeight(), 0, TEST_LOCATION ); + + + /************************************************************ + * FUNCTION UNDER TEST + ***********************************************************/ + resourceClient.ReloadResource( ticket->GetId() ); + /************************************************************ + * Expected result - current load completes as usual, no reload requested + ************************************************************/ + + application.SendNotification(); // Flush update methods + + // Reset call statistics - test that resource is not reloaded + application.GetPlatform().ResetTrace(); + + // Create a resource + Integration::ResourceRequest* req = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false ); + bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 80, 80, 80, 80 ); + Integration::ResourcePointer resourcePtr(bitmap); // reference it + + // Set up platform abstraction to load it + id=req->GetId(); + + application.GetPlatform().SetResourceLoaded(id, Integration::ResourceBitmap, resourcePtr); + + DALI_TEST_CHECK( ! resourceManager.IsResourceLoaded(id)); + + application.GetPlatform().ResetTrace(); + // load the cache, which will immediately have the loaded resource + application.Render(0); + + // UpdateCache runs before ProcessMessages, so the loading resource completes before + // the reload request is handled. + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc ) ); + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::GetResourcesFunc ) ); + + DALI_TEST_CHECK( resourceManager.IsResourceLoaded(id)); + Internal::BitmapMetadata bitmapData = resourceManager.GetBitmapMetadata(id); + DALI_TEST_CHECK( bitmapData.GetWidth() == 80 ); + DALI_TEST_CHECK( bitmapData.GetHeight() == 80 ); + + DALI_TEST_EQUALS( imageTicket->GetWidth(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( imageTicket->GetHeight(), 0, TEST_LOCATION ); + + // Trigger the event thread to process notify messages. Should then trigger the signals + // in the ticket observer + application.SendNotification(); + + DALI_TEST_EQUALS( testTicketObserver.LoadSucceededCalled(), 1, TEST_LOCATION ); + DALI_TEST_EQUALS( testTicketObserver.UploadCalled(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( ticket->GetLoadingState(), ResourceLoading, TEST_LOCATION ); + + // Check that the image ticket was updated with the image attributes + DALI_TEST_EQUALS( imageTicket->GetWidth(), 80, TEST_LOCATION ); + DALI_TEST_EQUALS( imageTicket->GetHeight(), 80, TEST_LOCATION ); + + DALI_TEST_EQUALS( resourceManager.ResourcesToProcess(), true, TEST_LOCATION ); + + // Create a new resource - the image size could have changed in the meantime + req = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap2 = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false ); + bitmap2->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 120, 120, 120, 120 ); + Integration::ResourcePointer resourcePtr2(bitmap2); // reference it + DALI_TEST_CHECK( req->GetId() == id ); + application.GetPlatform().SetResourceLoaded(id, Integration::ResourceBitmap, resourcePtr2); + + application.Render(0); // Process update messages / UpdateCache + + DALI_TEST_CHECK( resourceManager.IsResourceLoaded(id)); + bitmapData = resourceManager.GetBitmapMetadata(id); + DALI_TEST_CHECK( bitmapData.GetWidth() == 120 ); + DALI_TEST_CHECK( bitmapData.GetHeight() == 120 ); + DALI_TEST_EQUALS( imageTicket->GetWidth(), 80, TEST_LOCATION ); + DALI_TEST_EQUALS( imageTicket->GetHeight(), 80, TEST_LOCATION ); + + application.SendNotification(); // Process event messages + + DALI_TEST_EQUALS( testTicketObserver.LoadSucceededCalled(), 2, TEST_LOCATION ); + + // Not staged - no GL upload + DALI_TEST_EQUALS( testTicketObserver.UploadCalled(), 0, TEST_LOCATION ); + + DALI_TEST_EQUALS( ticket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION ); + DALI_TEST_EQUALS( imageTicket->GetWidth(), 120, TEST_LOCATION ); + DALI_TEST_EQUALS( imageTicket->GetHeight(), 120, TEST_LOCATION ); + DALI_TEST_EQUALS( resourceManager.ResourcesToProcess(), false, TEST_LOCATION ); + } + END_TEST; +} + + +int UtcDaliInternalSaveResource01(void) +{ + TestApplication application; + tet_infoline("Testing SaveResource() with valid id, and valid filename"); + + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + + Dali::ModelData modelData = BuildTreeModel(); + testTicketObserver.Reset(); + + Internal::ResourceTicketPtr ticket = resourceClient.RequestResource( Integration::ModelResourceType(), "model.dae" ); + ticket->AddObserver(testTicketObserver); + + // First, load a model resource + application.SendNotification(); // Flush update messages + application.Render(); // Process resource request + Integration::ResourceRequest* req = application.GetPlatform().GetRequest(); + Internal::ModelData& modelDataImpl = GetImplementation(modelData); + Integration::ResourcePointer resourcePtr(&modelDataImpl); + + application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr); + application.Render(); // Process LoadComplete + application.SendNotification(); // Process event messages + DALI_TEST_CHECK( ticket->GetLoadingState() == ResourceLoadingSucceeded ); + + // Try saving it + resourceClient.SaveResource( ticket, "model.dali-bin" ); + application.SendNotification(); // Flush update messages + application.Render(); // Process save resource request + + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::SaveResourceFunc ) ); + req = application.GetPlatform().GetRequest(); + DALI_TEST_CHECK( req->GetType()->id == Integration::ResourceModel ); + DALI_TEST_CHECK( req->GetPath().compare("model.dali-bin") == 0 ); + + // Set up success response + application.GetPlatform().SetResourceSaved(req->GetId(), req->GetType()->id); + application.Render(); // GetResources --> SaveComplete + application.SendNotification(); // Send event messages + + DALI_TEST_CHECK( testTicketObserver.SaveSucceededCalled() == 1 ); + DALI_TEST_EQUALS( ticket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION ) +; + END_TEST; +} + + +int UtcDaliInternalSaveResource02(void) +{ + TestApplication application; + tet_infoline("Testing SaveResource() with invalid id"); + testTicketObserver.Reset(); + + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + + Dali::ModelData modelData = BuildTreeModel(); + + Internal::ResourceTicketPtr ticket = resourceClient.RequestResource( Integration::ModelResourceType(), "model.dae" ); + ticket->AddObserver(testTicketObserver); + + // First, load a model resource + application.SendNotification(); // Flush update messages + application.Render(); // Process resource request + Integration::ResourceRequest* req = application.GetPlatform().GetRequest(); + Internal::ModelData& modelDataImpl = GetImplementation(modelData); + Integration::ResourcePointer resourcePtr(&modelDataImpl); + application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr); + application.Render(); // Process LoadComplete + application.SendNotification(); // Process event messages + DALI_TEST_CHECK(ticket->GetLoadingState() == ResourceLoadingSucceeded); + application.GetPlatform().DiscardRequest(); // Ensure load request is discarded + + Internal::ResourceTypePath typePath(Integration::ModelResourceType(), ""); + Internal::ResourceTicketPtr aTicket = new Internal::ResourceTicket( testTicketLifetimeObserver, 2000, typePath ); + try + { + resourceClient.SaveResource( aTicket, "model.dali-bin" ); // Should be outside range of valid resources! + } catch (DaliException& e) + { + // Tests that a negative test of an assertion succeeds + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + + DALI_TEST_ASSERT(e, "mImpl->mTickets.find(ticket->GetId()) != mImpl->mTickets.end()", TEST_LOCATION ); + } + + application.SendNotification(); // Flush update messages + application.Render(); // Process save resource request + + // Ensure no request sent to platform abstraction + DALI_TEST_CHECK( ! application.GetPlatform().WasCalled(TestPlatformAbstraction::SaveResourceFunc ) ); + req = application.GetPlatform().GetRequest(); + DALI_TEST_CHECK ( req == NULL ); + END_TEST; +} + +int UtcDaliInternalSaveResource03(void) +{ + TestApplication application; + tet_infoline("Testing SaveResource() with invalid id"); + testTicketObserver.Reset(); + + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + + Dali::ModelData modelData = BuildTreeModel(); + + Internal::ResourceTicketPtr ticket = resourceClient.RequestResource( Integration::ModelResourceType(), "model.dae" ); + ticket->AddObserver(testTicketObserver); + + // First, load a model resource + application.SendNotification(); // Flush update messages + application.Render(); // Process resource request + Integration::ResourceRequest* req = application.GetPlatform().GetRequest(); + Internal::ModelData& modelDataImpl = GetImplementation(modelData); + Integration::ResourcePointer resourcePtr(&modelDataImpl); + application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr); + application.Render(); // Process LoadComplete + application.SendNotification(); // Process event messages + DALI_TEST_CHECK(ticket->GetLoadingState() == ResourceLoadingSucceeded); + application.GetPlatform().DiscardRequest(); // Ensure load request is discarded + + Internal::ResourceTicketPtr aTicket; + try + { + resourceClient.SaveResource( aTicket, "model.dali-bin" ); // Should be outside range of valid resources! + } catch (DaliException& e) + { + // Tests that a negative test of an assertion succeeds + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + + DALI_TEST_EQUALS(e.mCondition, "ticket", TEST_LOCATION); + } + + application.SendNotification(); // Flush update messages + application.Render(); // Process save resource request + + // Ensure no request sent to platform abstraction + DALI_TEST_CHECK( ! application.GetPlatform().WasCalled(TestPlatformAbstraction::SaveResourceFunc ) ); + req = application.GetPlatform().GetRequest(); + DALI_TEST_CHECK ( req == NULL ); + END_TEST; +} + + +int UtcDaliInternalSaveResource04(void) +{ + TestApplication application; + tet_infoline("Testing SaveResource() with valid id, but invalid filename"); + testTicketObserver.Reset(); + + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + + // First, load a model resource + Internal::ResourceTicketPtr ticket = CheckLoadModel(application, "model.dae"); + + resourceClient.SaveResource( ticket, "model.dali-bin" ); + application.SendNotification(); // Flush update messages + application.Render(); // Process save resource request + + // Set up fail response + application.GetPlatform().SetResourceSaveFailed(ticket->GetId(), Integration::FailureInvalidPath ); + application.Render(); // GetResources --> SaveFailed + application.SendNotification(); // Send event messages + + DALI_TEST_CHECK( testTicketObserver.SaveSucceededCalled() == 0 ); + DALI_TEST_CHECK( testTicketObserver.SaveFailedCalled() == 1 ); + DALI_TEST_EQUALS( ticket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION ) +; + END_TEST; +} + +int UtcDaliInternalSaveResource05(void) +{ + TestApplication application; + tet_infoline("Testing SaveResource() with valid id, but invalid resource type"); + testTicketObserver.Reset(); + + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + + // First, load a bitmap resource + Internal::ResourceTicketPtr ticket = CheckLoadBitmap(application, "bitmap.jpg", 80, 80); + + // Try saving it + resourceClient.SaveResource( ticket, "bitmap.png" ); + application.SendNotification(); // Flush update messages + application.Render(); // Process save resource request + + DALI_TEST_CHECK( ! application.GetPlatform().WasCalled(TestPlatformAbstraction::SaveResourceFunc ) ); + END_TEST; +} + +int UtcDaliInternalRequestResourceTicket01(void) +{ + TestApplication application; + tet_infoline("Testing RequestResourceTicket() with valid id"); + + testTicketObserver.Reset(); + + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + + // First, load a bitmap resource + Internal::ResourceTicketPtr ticket = CheckLoadBitmap(application, "bitmap.jpg", 80, 80); + + Internal::ResourceTicketPtr newTicket = resourceClient.RequestResourceTicket( ticket->GetId() ); + DALI_TEST_CHECK( newTicket ); + DALI_TEST_CHECK( newTicket->GetId() == ticket->GetId() ); + DALI_TEST_CHECK( newTicket->GetTypePath().type->id == ticket->GetTypePath().type->id ); + END_TEST; +} + +int UtcDaliInternalRequestResourceTicket02(void) +{ + TestApplication application; + tet_infoline("Testing RequestResourceTicket() with invalid id"); + + testTicketObserver.Reset(); + + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + + // First, load a bitmap resource + Internal::ResourceTicketPtr ticket = CheckLoadBitmap(application, "bitmap.jpg", 80, 80); + + Internal::ResourceTicketPtr newTicket = resourceClient.RequestResourceTicket( ticket->GetId() + 2000 ); + DALI_TEST_CHECK( ! newTicket ); + END_TEST; +} + +int UtcDaliInternalLoadShaderRequest01(void) +{ + TestApplication application; + tet_infoline("Testing LoadShader() success"); + testTicketObserver.Reset(); + + // Clear through all of the outstanding shader load requests from the default shader effect + std::vector< unsigned char > buffer; + for( int i=0; i<10; i++ ) + { + buffer.push_back((unsigned char)i); + } + application.GetPlatform().SetLoadFileResult( true, buffer ); + application.GetGlAbstraction().SetLinkStatus(1); + application.SendNotification(); // Flush update messages + application.Render(); // Process load shader request (immediately) + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + application.SendNotification(); + + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + + Integration::ShaderResourceType shaderRequest(123, "vertex src", "frag src"); + std::string shaderBinaryFile("shader.bin"); + Internal::ResourceTicketPtr ticket = resourceClient.LoadShader(shaderRequest, shaderBinaryFile); + DALI_TEST_CHECK( ticket ); + + application.GetPlatform().SetLoadFileResult( true, buffer ); + application.GetGlAbstraction().EnableShaderCallTrace( true ); + application.GetGlAbstraction().SetLinkStatus(1); + + application.SendNotification(); // Flush update messages + application.Render(); // Process load shader request (immediately) + + application.SendNotification(); + application.Render(); + + application.SendNotification(); + application.Render(); + + // If shader program loads OK, we shouldn't see any calls to CompileShader or SaveResource + TraceCallStack& shaderTrace = application.GetGlAbstraction().GetShaderTrace(); + DALI_TEST_CHECK( ! shaderTrace.FindMethod("CompileShader") ); + + // Ensure no request sent to platform abstraction + DALI_TEST_CHECK( ! application.GetPlatform().WasCalled(TestPlatformAbstraction::SaveResourceFunc ) ); + END_TEST; +} + +int UtcDaliInternalLoadShaderRequest02(void) +{ + TestApplication application; + tet_infoline("Testing LoadShader() failure"); + testTicketObserver.Reset(); + + // Clear through all of the outstanding shader load requests from the default shader effect + std::vector< unsigned char > buffer; + for( int i=0; i<10; i++ ) + { + buffer.push_back((unsigned char)i); + } + application.GetPlatform().SetLoadFileResult( true, buffer ); + application.GetGlAbstraction().SetLinkStatus(1); + application.SendNotification(); // Flush update messages + application.Render(); // Process load shader request (immediately) + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + application.SendNotification(); + + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + Internal::SceneGraph::UpdateManager& updateManager = Internal::ThreadLocalStorage::Get().GetUpdateManager(); + + Integration::ShaderResourceType shaderRequest(123, "vertex src", "frag src"); + std::string shaderBinaryFile("shader.bin"); + Internal::ResourceTicketPtr ticket = resourceClient.LoadShader(shaderRequest, shaderBinaryFile); + ticket->AddObserver(testTicketObserver); + + ShaderEffect::GeometryHints hints = ShaderEffect::HINT_NONE; + Internal::SceneGraph::Shader* sceneObject = new Internal::SceneGraph::Shader( hints ); + AddShaderMessage( updateManager, *sceneObject ); + + size_t shaderHash=0; + SetShaderProgramMessage( updateManager, *sceneObject, GEOMETRY_TYPE_IMAGE, Internal::SHADER_DEFAULT, ticket->GetId(), shaderHash ); + + DALI_TEST_CHECK( ticket ); + + buffer.clear(); + DALI_TEST_CHECK(buffer.size() == 0); + + application.GetPlatform().SetLoadFileResult( true, buffer ); + application.GetGlAbstraction().ResetShaderCallStack(); + application.GetGlAbstraction().EnableShaderCallTrace( true ); + application.GetGlAbstraction().SetLinkStatus(1); + application.GetGlAbstraction().SetProgramBinaryLength(20); + application.GetPlatform().SetResourceSaved (ticket->GetId(), Integration::ResourceShader ); + + application.SendNotification(); // Flush update messages + application.Render(); // Process load shader request (immediately), add responses + // to post process q + application.Render(); // this update will process old post-process-q + application.Render(); // this update will process new post-process-q + application.SendNotification(); // Send save request to event thread + application.Render(); // this update will process save request + application.Render(); // this update will get SaveComplete + application.SendNotification(); // Send save request response + + TraceCallStack& shaderTrace = application.GetGlAbstraction().GetShaderTrace(); + DALI_TEST_CHECK( shaderTrace.FindMethod("CompileShader") ); + + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::SaveResourceFunc ) ); + DALI_TEST_CHECK( testTicketObserver.SaveSucceededCalled() ); + END_TEST; +} + +int UtcDaliInternalAllocateBitmapImage01(void) +{ + TestApplication application; + tet_infoline("Testing AllocateBitmapImage()"); + testTicketObserver.Reset(); + + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + Internal::ImageTicketPtr imageTicket = resourceClient.AllocateBitmapImage(80, 80, 80, 80, Pixel::RGB565); + imageTicket->AddObserver( testTicketObserver ); + + DALI_TEST_CHECK( imageTicket ); + DALI_TEST_EQUALS ( imageTicket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetWidth(), 80, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetHeight(), 80, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetAttributes().GetPixelFormat(), Pixel::RGB565, TEST_LOCATION ); + + application.SendNotification(); // Flush update queue + application.Render(0); // Process message + application.SendNotification(); // Send message to tickets + + DALI_TEST_CHECK ( 0 == testTicketObserver.LoadSucceededCalled() ); // Check no message was sent + DALI_TEST_EQUALS ( imageTicket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetWidth(), 80, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetHeight(), 80, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetAttributes().GetPixelFormat(), Pixel::RGB565, TEST_LOCATION ); + + Integration::Bitmap* bitmap = resourceClient.GetBitmap(imageTicket); + DALI_TEST_CHECK ( bitmap != NULL ); + DALI_TEST_EQUALS ( bitmap->GetImageWidth(), 80u, TEST_LOCATION ); + DALI_TEST_EQUALS ( bitmap->GetImageHeight(), 80u, TEST_LOCATION ); + DALI_TEST_EQUALS ( bitmap->GetPackedPixelsProfile()->GetBufferWidth(), 80u, TEST_LOCATION ); + DALI_TEST_EQUALS ( bitmap->GetPackedPixelsProfile()->GetBufferHeight(), 80u, TEST_LOCATION ); + DALI_TEST_EQUALS ( bitmap->GetPixelFormat(), Pixel::RGB565, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliInternalAddBitmapImage01(void) +{ + TestApplication application; + tet_infoline("Testing AddBitmap with reserved buffer()"); + testTicketObserver.Reset(); + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false ); + bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGB565, 80, 80, 80, 80 ); + + Internal::ImageTicketPtr imageTicket = resourceClient.AddBitmapImage( bitmap ); + DALI_TEST_CHECK( imageTicket ); + imageTicket->AddObserver( testTicketObserver ); + + DALI_TEST_EQUALS ( imageTicket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetWidth(), 80, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetHeight(), 80, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetAttributes().GetPixelFormat(), Pixel::RGB565, TEST_LOCATION ); + + application.SendNotification(); // Flush update queue + application.Render(0); // Process message + application.SendNotification(); // Send message to tickets + + DALI_TEST_CHECK ( 0 == testTicketObserver.LoadSucceededCalled() ); // Check no message was sent + DALI_TEST_EQUALS ( imageTicket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetWidth(), 80, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetHeight(), 80, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetAttributes().GetPixelFormat(), Pixel::RGB565, TEST_LOCATION ); + + Integration::Bitmap* theBitmap = resourceClient.GetBitmap(imageTicket); + DALI_TEST_CHECK ( theBitmap != NULL ); + DALI_TEST_CHECK ( bitmap == theBitmap ); + DALI_TEST_EQUALS ( bitmap->GetImageWidth(), 80u, TEST_LOCATION ); + DALI_TEST_EQUALS ( bitmap->GetImageHeight(), 80u, TEST_LOCATION ); + DALI_TEST_EQUALS ( bitmap->GetPackedPixelsProfile()->GetBufferWidth(), 80u, TEST_LOCATION ); + DALI_TEST_EQUALS ( bitmap->GetPackedPixelsProfile()->GetBufferHeight(), 80u, TEST_LOCATION ); + DALI_TEST_EQUALS ( bitmap->GetPixelFormat(), Pixel::RGB565, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliInternalAddBitmapImage02(void) +{ + TestApplication application; + tet_infoline("Testing AddBitmap without reserved buffer()"); + testTicketObserver.Reset(); + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false ); + + Internal::ImageTicketPtr imageTicket = resourceClient.AddBitmapImage( bitmap ); + DALI_TEST_CHECK( imageTicket ); + imageTicket->AddObserver( testTicketObserver ); + + DALI_TEST_EQUALS ( imageTicket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetWidth(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetHeight(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetAttributes().GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION ); + DALI_TEST_CHECK ( 0 == testTicketObserver.LoadSucceededCalled() ); // Check no message was sent + + application.SendNotification(); // Flush update queue + application.Render(0); // Process message + application.SendNotification(); // Send message to tickets + + DALI_TEST_EQUALS ( imageTicket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetWidth(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetHeight(), 0, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetAttributes().GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION ); + DALI_TEST_CHECK ( 0 == testTicketObserver.LoadSucceededCalled() ); // Check no message was sent + + Integration::Bitmap* theBitmap = resourceClient.GetBitmap(imageTicket); + DALI_TEST_CHECK ( theBitmap != NULL ); + DALI_TEST_CHECK ( bitmap == theBitmap ); + DALI_TEST_EQUALS ( bitmap->GetImageWidth(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS ( bitmap->GetImageHeight(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS ( bitmap->GetPackedPixelsProfile()->GetBufferWidth(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS ( bitmap->GetPackedPixelsProfile()->GetBufferHeight(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS ( bitmap->GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION ); + + // There is no way for the ticket's image attributes to be updated if the bitmap + // reserves a buffer after ticket generation. + // Probably not an issue - there is no public API in BufferImage to change the image size. + END_TEST; +} + + +int UtcDaliInternalAddBitmapImage03(void) +{ + TestApplication application; + tet_infoline("Testing AddBitmap() with invalid bitmap"); + testTicketObserver.Reset(); + + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + Internal::ImageTicketPtr imageTicket; + bool exceptionRaised=false; + try + { + imageTicket = resourceClient.AddBitmapImage( NULL ); + } + catch( DaliException& e ) + { + exceptionRaised = true; + } + DALI_TEST_CHECK( exceptionRaised ); + DALI_TEST_CHECK( ! imageTicket ); + END_TEST; +} + +int UtcDaliInternalGetBitmapImage01(void) +{ + TestApplication application; + tet_infoline("Testing GetBitmap() with valid ticket"); + testTicketObserver.Reset(); + + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false ); + bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 20, 20, 80, 80 ); + Internal::ImageTicketPtr imageTicket = resourceClient.AddBitmapImage( bitmap ); + + Integration::Bitmap* theBitmap = resourceClient.GetBitmap(imageTicket); + DALI_TEST_CHECK ( theBitmap != NULL ); + DALI_TEST_CHECK ( bitmap == theBitmap ); + DALI_TEST_EQUALS ( bitmap->GetImageWidth(), 20u, TEST_LOCATION ); + DALI_TEST_EQUALS ( bitmap->GetImageHeight(), 20u, TEST_LOCATION ); + DALI_TEST_EQUALS ( bitmap->GetPackedPixelsProfile()->GetBufferWidth(), 80u, TEST_LOCATION ); + DALI_TEST_EQUALS ( bitmap->GetPackedPixelsProfile()->GetBufferHeight(), 80u, TEST_LOCATION ); + DALI_TEST_EQUALS ( bitmap->GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION ); + + imageTicket->AddObserver( testTicketObserver ); + application.SendNotification(); // Flush update queue + application.Render(0); // Process message + application.SendNotification(); // Send message to tickets + + theBitmap = resourceClient.GetBitmap(imageTicket); + DALI_TEST_CHECK ( theBitmap != NULL ); + DALI_TEST_CHECK ( bitmap == theBitmap ); + DALI_TEST_EQUALS ( bitmap->GetImageWidth(), 20u, TEST_LOCATION ); + DALI_TEST_EQUALS ( bitmap->GetImageHeight(), 20u, TEST_LOCATION ); + DALI_TEST_EQUALS ( bitmap->GetPackedPixelsProfile()->GetBufferWidth(), 80u, TEST_LOCATION ); + DALI_TEST_EQUALS ( bitmap->GetPackedPixelsProfile()->GetBufferHeight(), 80u, TEST_LOCATION ); + DALI_TEST_EQUALS ( bitmap->GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliInternalGetBitmapImage02(void) +{ + TestApplication application; + tet_infoline("Testing GetBitmap() with invalid ticket"); + + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + Internal::ImageTicketPtr imageTicket; + Integration::Bitmap* theBitmap = NULL; + bool exceptionRaised = false; + try + { + theBitmap = resourceClient.GetBitmap(imageTicket); + } catch (DaliException& e) + { + exceptionRaised = true; + } + DALI_TEST_CHECK( exceptionRaised ); + DALI_TEST_CHECK( ! theBitmap ); + END_TEST; +} + +int UtcDaliInternalGetBitmapImage03(void) +{ + TestApplication application; + tet_infoline("Testing GetBitmap() with valid ticket for incorrect type"); + + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); Internal::ResourceTicketPtr imageTicket = CheckLoadBitmap( application, "Stuff.png", 100, 100 ); + Internal::ResourceTicketPtr modelTicket = CheckLoadModel( application, "Stuff.dae"); + + Integration::Bitmap* theBitmap = NULL; + theBitmap = resourceClient.GetBitmap(imageTicket); + DALI_TEST_CHECK( ! theBitmap ); + + theBitmap = resourceClient.GetBitmap(modelTicket); + DALI_TEST_CHECK( ! theBitmap ); + END_TEST; +} + +int UtcDaliInternalAllocateTexture01(void) +{ + TestApplication application; + tet_infoline("Testing AllocateTexture()"); + testTicketObserver.Reset(); + + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + Internal::ResourceTicketPtr resourceTicket = resourceClient.AllocateTexture(80, 80, Pixel::L8 ); + resourceTicket->AddObserver( testTicketObserver ); + + DALI_TEST_CHECK( resourceTicket ); + DALI_TEST_EQUALS ( resourceTicket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION ); + DALI_TEST_CHECK( testTicketObserver.LoadSucceededCalled() == 0 ); + + application.SendNotification(); // Flush update queue + application.Render(0); // Process message + application.SendNotification(); // Send message to tickets + + DALI_TEST_EQUALS ( resourceTicket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION ); + DALI_TEST_CHECK( testTicketObserver.LoadSucceededCalled() == 0 ); + END_TEST; +} + +int UtcDaliInternalAddNativeImage(void) +{ + TestApplication application; + tet_infoline("Testing AddNativeImage()"); + + testTicketObserver.Reset(); + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + Internal::ResourceTicketPtr ticket; + Internal::ImageTicketPtr imageTicket; + { // Test image going out of scope after ticket creation (message to Update thread holds a ref) + TestNativeImagePointer nativeImage = TestNativeImage::New( 80, 80 ); + ticket = resourceClient.AddNativeImage( *nativeImage ); + imageTicket = dynamic_cast(ticket.Get()); + DALI_TEST_CHECK( imageTicket ); + imageTicket->AddObserver( testTicketObserver ); + } + + DALI_TEST_EQUALS ( imageTicket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetWidth(), 80, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetHeight(), 80, TEST_LOCATION ); + DALI_TEST_CHECK ( 0 == testTicketObserver.LoadSucceededCalled() ); // Check no message was sent + + application.SendNotification(); // Flush update queue + application.Render(0); // Process message + application.SendNotification(); // Send message to tickets + + DALI_TEST_EQUALS ( imageTicket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetWidth(), 80, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetHeight(), 80, TEST_LOCATION ); + DALI_TEST_CHECK ( 0 == testTicketObserver.LoadSucceededCalled() ); // Check no message was sent + + Integration::Bitmap* theBitmap = NULL; + theBitmap = resourceClient.GetBitmap(imageTicket); + + DALI_TEST_CHECK ( theBitmap == NULL ); + END_TEST; +} + +int UtcDaliInternalAddFrameBufferImage(void) +{ + TestApplication application; + tet_infoline("Testing AddFrameBufferImage()"); + + testTicketObserver.Reset(); + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + Internal::ImageTicketPtr imageTicket = resourceClient.AddFrameBufferImage(80, 80, Pixel::A8 ); + DALI_TEST_CHECK( imageTicket ); + imageTicket->AddObserver( testTicketObserver ); + + DALI_TEST_EQUALS ( imageTicket->GetWidth(), 80, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetHeight(), 80, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetAttributes().GetPixelFormat(), Pixel::A8, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION ); + DALI_TEST_CHECK ( 0 == testTicketObserver.LoadSucceededCalled() ); // Check no message was sent + + application.SendNotification(); // Flush update queue + application.Render(0); // Process message + application.SendNotification(); // Send message to tickets + + DALI_TEST_EQUALS ( imageTicket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetWidth(), 80, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetHeight(), 80, TEST_LOCATION ); + DALI_TEST_EQUALS ( imageTicket->GetAttributes().GetPixelFormat(), Pixel::A8, TEST_LOCATION ); + DALI_TEST_CHECK ( 0 == testTicketObserver.LoadSucceededCalled() ); // Check no message was sent + + Integration::Bitmap* theBitmap = NULL; + theBitmap = resourceClient.GetBitmap(imageTicket); + DALI_TEST_CHECK ( theBitmap == NULL ); + END_TEST; +} + +int UtcDaliInternalAllocateMesh01(void) +{ + TestApplication application; + tet_infoline("Testing AllocateMesh() with vald mesh data"); + + MeshData publicMeshData; + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + BoneContainer bones; + ConstructVertices(vertices, 60); + ConstructFaces(vertices, faces); + Material customMaterial = ConstructMaterial(); + publicMeshData.SetData(vertices, faces, bones, customMaterial); + publicMeshData.SetHasNormals(true); + publicMeshData.SetHasTextureCoords(true); + + testTicketObserver.Reset(); + Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); + Internal::OwnerPointer meshDataPtr( new Internal::MeshData( publicMeshData, true, true ) ); + Internal::ResourceTicketPtr meshTicket = resourceClient.AllocateMesh(meshDataPtr); + DALI_TEST_CHECK( meshTicket ); + meshTicket->AddObserver( testTicketObserver ); + + DALI_TEST_EQUALS ( meshTicket->GetLoadingState(), ResourceLoading, TEST_LOCATION ); + + application.SendNotification(); // Flush update queue + application.Render(0); // Process message + application.SendNotification(); // Send message to tickets + + DALI_TEST_EQUALS ( meshTicket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION ); + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/CMakeLists.txt b/automated-tests/src/dali-unmanaged/CMakeLists.txt new file mode 100644 index 0000000..93b4936 --- /dev/null +++ b/automated-tests/src/dali-unmanaged/CMakeLists.txt @@ -0,0 +1,75 @@ +SET(PKG_NAME "dali-unmanaged") + +SET(EXEC_NAME "tct-${PKG_NAME}-core") +SET(RPM_NAME "core-${PKG_NAME}-tests") + +SET(CAPI_LIB "dali-unmanaged") + +SET(TC_SOURCES + utc-Dali-Constrainable.cpp + utc-Dali-Context.cpp + utc-Dali-CustomActor.cpp + utc-Dali-DistanceField.cpp + utc-Dali-DynamicsBody.cpp + utc-Dali-DynamicsBodyConfig.cpp + utc-Dali-DynamicsJoint.cpp + utc-Dali-DynamicsShape.cpp + utc-Dali-DynamicsWorld.cpp + utc-Dali-DynamicsWorldConfig.cpp + utc-Dali-EncodedBufferImage.cpp + utc-Dali-HitTestAlgorithm.cpp + utc-Dali-LightActor.cpp + utc-Dali-LocklessBuffer.cpp + utc-Dali-MeshActor.cpp + utc-Dali-MeshData.cpp + utc-Dali-Model.cpp + utc-Dali-MouseWheelEvent.cpp + utc-Dali-ObjectRegistry.cpp + utc-Dali-Random.cpp + utc-Dali-RenderTask.cpp + utc-Dali-ShaderEffect.cpp + utc-Dali-Scripting.cpp + utc-Dali-Spline.cpp + utc-Dali-TypeRegistry.cpp + utc-Dali-Utf8.cpp + utc-Dali-Vector.cpp +) + +LIST(APPEND TC_SOURCES + dali-test-suite-utils/mesh-builder.cpp + dali-test-suite-utils/test-dynamics.cpp + dali-test-suite-utils/test-platform-abstraction.cpp + ../dali/dali-test-suite-utils/dali-test-suite-utils.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-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} -O0 -ggdb --coverage -DDEBUG_ENABLED") + +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-test-suite-utils + ../dali/dali-test-suite-utils +) + +ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.cpp ${TC_SOURCES}) +TARGET_LINK_LIBRARIES(${EXEC_NAME} + ${${CAPI_LIB}_LIBRARIES} +) + +INSTALL(PROGRAMS ${EXEC_NAME} + DESTINATION ${BIN_DIR}/${EXEC_NAME} +) diff --git a/automated-tests/src/dali-unmanaged/dali-test-suite-utils/mesh-builder.cpp b/automated-tests/src/dali-unmanaged/dali-test-suite-utils/mesh-builder.cpp new file mode 100644 index 0000000..06911e3 --- /dev/null +++ b/automated-tests/src/dali-unmanaged/dali-test-suite-utils/mesh-builder.cpp @@ -0,0 +1,238 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 "mesh-builder.h" + +namespace Dali +{ + +void AddVertex( MeshData::VertexContainer& verts, Vector3 V, Vector2 UV ) +{ + MeshData::Vertex meshVertex; + meshVertex.x = V.x; + meshVertex.y = V.y; + meshVertex.z = V.z; + meshVertex.u = UV.x; + meshVertex.v = UV.y; + verts.push_back(meshVertex); +} + +void SetNormal( MeshData::VertexContainer& verts, size_t vertIdx, Vector3 normal ) +{ + verts[vertIdx].nX = normal.x; + verts[vertIdx].nY = normal.y; + verts[vertIdx].nZ = normal.z; +} + +void SetBone( MeshData::VertexContainer& verts, size_t vertIdx, size_t index, size_t boneIndex, float weight) +{ + verts[vertIdx].boneIndices[index] = boneIndex; + verts[vertIdx].boneWeights[index] = weight; +} + +void SetBones(MeshData::VertexContainer& verts) +{ + // Set all verts in one corner to be affected fully by bone 0 + SetBone(verts, 0, 0, 0, 1.0f); + SetBone(verts, 1, 0, 0, 1.0f); + SetBone(verts, 2, 0, 0, 1.0f); + + // Set all verts in next corner to be affected by bone 1 and bone 2 equally + SetBone(verts, 3, 0, 1, 0.5f); + SetBone(verts, 4, 0, 1, 0.5f); + SetBone(verts, 5, 0, 1, 0.5f); + + SetBone(verts, 3, 1, 2, 0.5f); + SetBone(verts, 4, 1, 2, 0.5f); + SetBone(verts, 5, 1, 2, 0.5f); +} + +void ConstructBones(BoneContainer& bones) +{ + bones.push_back(Bone("Bone1", Matrix::IDENTITY)); + bones.push_back(Bone("Bone2", Matrix::IDENTITY)); + bones.push_back(Bone("Bone3", Matrix::IDENTITY)); +} + +void CopyVertex( MeshData::Vertex& vert, Vector3& vector ) +{ + vector.x = vert.x; + vector.y = vert.y; + vector.z = vert.z; +} + +void AddTriangle( MeshData::VertexContainer& verts, + MeshData::FaceIndices& faces, + size_t v0, size_t v1, size_t v2 ) +{ + faces.push_back(v0); + faces.push_back(v1); + faces.push_back(v2); + + // Calculate normal... + Vector3 vert0, vert1, vert2; + CopyVertex(verts[v0], vert0); + CopyVertex(verts[v1], vert1); + CopyVertex(verts[v2], vert2); + Vector3 e0 = vert1 - vert0; + Vector3 e1 = vert2 - vert1; + Vector3 normal = e0.Cross(e1); + normal.Normalize(); + SetNormal(verts, v0, normal); + SetNormal(verts, v1, normal); + SetNormal(verts, v2, normal); +} + +void ConstructVertices( MeshData::VertexContainer& vertices, float sz ) +{ + // back + AddVertex(vertices, Vector3( 0.0f, -sz, 0.0f), Vector2(0.50f, 0.50f)); // 0a 0 + AddVertex(vertices, Vector3( 0.0f, -sz, 0.0f), Vector2(0.50f, 0.50f)); // 0b 1 + AddVertex(vertices, Vector3( 0.0f, -sz, 0.0f), Vector2(0.50f, 0.50f)); // 0c 2 + + // left + AddVertex(vertices, Vector3(-sz*0.5f, sz*0.3f, sz*0.5f), Vector2(0.25f, 0.50f)); // 1a 3 + AddVertex(vertices, Vector3(-sz*0.5f, sz*0.3f, sz*0.5f), Vector2(0.25f, 0.50f)); // 1b 4 + AddVertex(vertices, Vector3(-sz*0.5f, sz*0.3f, sz*0.5f), Vector2(0.25f, 0.50f)); // 1c 5 + + // right + AddVertex(vertices, Vector3( sz*0.5f, sz*0.3f, sz*0.5f), Vector2(0.50f, 0.25f)); // 2a 6 + AddVertex(vertices, Vector3( sz*0.5f, sz*0.3f, sz*0.5f), Vector2(0.50f, 0.25f)); // 2b 7 + AddVertex(vertices, Vector3( sz*0.5f, sz*0.3f, sz*0.5f), Vector2(0.50f, 0.25f)); // 2c 8 + + // top + AddVertex(vertices, Vector3( 0.0f, sz*0.3f, -sz*0.7f), Vector2(0.25f, 0.25f)); // 3a 9 + AddVertex(vertices, Vector3( 0.0f, sz*0.3f, -sz*0.7f), Vector2(0.25f, 0.25f)); // 3b 10 + AddVertex(vertices, Vector3( 0.0f, sz*0.3f, -sz*0.7f), Vector2(0.25f, 0.25f)); // 3c 11 +} + +void ConstructFaces(MeshData::VertexContainer& vertices, MeshData::FaceIndices& faces) +{ + AddTriangle(vertices, faces, 0, 6, 3); // 0, 2, 1 back, right, left (ac) + AddTriangle(vertices, faces, 1, 9, 7); // 0, 3, 2 back, top , right (ac) + AddTriangle(vertices, faces, 2, 4, 10); // 0, 1, 3 back, left, top (ac) + AddTriangle(vertices, faces, 11, 5, 8); // 3, 1, 2 top, left, right (ac) +} + +Material ConstructMaterial() +{ + Material customMaterial = Material::New("CustomMaterial"); + customMaterial.SetOpacity(.76f); + customMaterial.SetDiffuseColor(Vector4(0.8f, 0.0f, 0.4f, 1.0f)); + customMaterial.SetAmbientColor(Vector4(0.2f, 1.0f, 0.6f, 1.0f)); + customMaterial.SetSpecularColor(Vector4(0.5f, 0.6f, 0.7f, 1.0f)); + return customMaterial; +} + + +Mesh ConstructMesh( float sz ) +{ + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + ConstructVertices( vertices, sz ); + ConstructFaces(vertices, faces); + Material customMaterial = ConstructMaterial(); + + MeshData meshData; + BoneContainer bones; + meshData.SetData(vertices, faces, bones, customMaterial); + meshData.SetHasNormals(true); + meshData.SetHasTextureCoords(true); + + Mesh mesh = Mesh::New(meshData); + return mesh; +} + + +void AddBone(Dali::BoneContainer& bones, const std::string& name, const Dali::Matrix& offsetMatrix) +{ + bones.push_back(Bone(name, offsetMatrix)); +} + +void CreateMeshData(MeshData& meshData) +{ + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + Dali::BoneContainer bones; + AddBone(bones, "trunk", Matrix::IDENTITY); + AddBone(bones, "branch", Matrix::IDENTITY); + AddBone(bones, "twig", Matrix::IDENTITY); + ConstructVertices( vertices, 50 ); + ConstructFaces(vertices, faces); + Material customMaterial = ConstructMaterial(); + meshData.SetData(vertices, faces, bones, customMaterial); + meshData.SetHasNormals(true); + meshData.SetHasTextureCoords(true); +} + +Dali::ModelData BuildTreeModel() +{ + Dali::ModelData modelData = Dali::ModelData::New("TreeModel"); + + MeshData meshData; + CreateMeshData(meshData); + modelData.AddMesh(meshData); + + Dali::Entity rootEntity = Dali::Entity::New("root"); + Dali::Entity e1 = Dali::Entity::New("trunk"); + Dali::Entity e2 = Dali::Entity::New("branch"); + Dali::Entity e3 = Dali::Entity::New("twig"); + Dali::Entity e4 = Dali::Entity::New("leaf"); + + rootEntity.SetType(Dali::Entity::OBJECT); + e1.SetType(Dali::Entity::OBJECT); + e2.SetType(Dali::Entity::OBJECT); + e3.SetType(Dali::Entity::OBJECT); + e4.SetType(Dali::Entity::OBJECT); + e4.AddMeshIndex(0); + + modelData.SetRootEntity(rootEntity); + rootEntity.Add(e1); + e1.Add(e2); + e2.Add(e3); + e2.Add(e4); + + EntityAnimatorMap twigAnimator("TwigAnim"); + twigAnimator.SetEntityName("twig"); + + KeyFrames pKF1 = KeyFrames::New(); + pKF1.Add(0.0f, Vector3(2.0f, 1.0f, 0.0f)); + pKF1.Add(0.5f, Vector3(3.0f, 1.0f, 5.0f)); + pKF1.Add(1.0f, Vector3(4.0f, 1.0f, 10.0f)); + twigAnimator.SetPositionKeyFrames(pKF1); + + EntityAnimatorMap branchAnimator("BranchAnim"); + branchAnimator.SetEntityName("branch"); + + KeyFrames pKF2 = KeyFrames::New(); + pKF2.Add(0.0f, Vector3(0.0f, 1.0f, 0.0f)); + pKF2.Add(0.25f, Vector3(-1.0f,1.0f, 5.0f)); + pKF2.Add(0.5f, Vector3(0.0f, 1.0f, 10.0f)); + pKF2.Add(0.75f, Vector3(1.0f, 1.0f, 5.0f)); + pKF2.Add(1.0f, Vector3(0.0f, 1.0f, 10.0f)); + branchAnimator.SetPositionKeyFrames(pKF2); + + ModelAnimationMap modelAnim; + modelAnim.name = "Anim1"; + modelAnim.duration = 10.0f; + modelAnim.animators.push_back(branchAnimator); + modelAnim.animators.push_back(twigAnimator); + + modelData.GetAnimationMapContainer().push_back(modelAnim); + + return modelData; +} + +} // namespace Dali diff --git a/automated-tests/src/dali-unmanaged/dali-test-suite-utils/mesh-builder.h b/automated-tests/src/dali-unmanaged/dali-test-suite-utils/mesh-builder.h new file mode 100644 index 0000000..65611fd --- /dev/null +++ b/automated-tests/src/dali-unmanaged/dali-test-suite-utils/mesh-builder.h @@ -0,0 +1,44 @@ +#ifndef MESH_BUILDER_H +#define MESH_BUILDER_H +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +namespace Dali +{ + +void AddVertex( MeshData::VertexContainer& verts, Vector3 V, Vector2 UV ); +void SetNormal( MeshData::VertexContainer& verts, size_t vertIdx, Vector3 normal ); +void SetBone( MeshData::VertexContainer& verts, size_t vertIdx, size_t index, size_t boneIndex, float weight); +void SetBones(MeshData::VertexContainer& verts); +void ConstructBones(BoneContainer& bones); +void CopyVertex( MeshData::Vertex& vert, Vector3& vector ); +void AddTriangle( MeshData::VertexContainer& verts, + MeshData::FaceIndices& faces, + size_t v0, size_t v1, size_t v2 ); +void ConstructVertices( MeshData::VertexContainer& vertices, float sz ); +void ConstructFaces(MeshData::VertexContainer& vertices, MeshData::FaceIndices& faces); +Material ConstructMaterial(); +Mesh ConstructMesh( float sz ); +void AddBone(Dali::BoneContainer& bones, const std::string& name, const Dali::Matrix& offsetMatrix); +void CreateMeshData(MeshData& meshData); +Dali::ModelData BuildTreeModel(); + +} + +#endif // MESH_BUILDER_H diff --git a/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-dynamics.cpp b/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-dynamics.cpp new file mode 100644 index 0000000..090cbac --- /dev/null +++ b/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-dynamics.cpp @@ -0,0 +1,182 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 "test-dynamics.h" + +using namespace Dali; + +namespace Dali +{ + + +TestDynamicsJoint::TestDynamicsJoint( TraceCallStack& trace ) +: mTrace( trace ) +{ + mTrace.PushCall( "DynamicsJoint::DynamicsJoint", "" ); +} + +TestDynamicsJoint::~TestDynamicsJoint() +{ + mTrace.PushCall( "DynamicsJoint::~DynamicsJoint", "" ); +} + +void TestDynamicsJoint::Initialize( + Integration::DynamicsBody* bodyA, const Vector3& positionA, const Quaternion& rotationA, const Vector3& offsetA, + Integration::DynamicsBody* bodyB, const Vector3& positionB, const Quaternion& rotationB, const Vector3& offsetB ) +{ + mTrace.PushCall( "DynamicsJoint::Initialize", "" ); +} + +void TestDynamicsJoint::SetLimit( const int axisIndex, const float lowerLimit, const float upperLimit ) +{ + mTrace.PushCall( "DynamicsJoint::SetLimit", "" ); +} + +void TestDynamicsJoint::EnableSpring( int axisIndex, bool flag ) +{ + mTrace.PushCall( "DynamicsJoint::EnableSpring", "" ); +} + +void TestDynamicsJoint::SetSpringStiffness( int axisIndex, float stiffness ) +{ + mTrace.PushCall( "DynamicsJoint::SetSpringStiffness", "" ); +} + +void TestDynamicsJoint::SetSpringDamping( int axisIndex, float damping ) +{ + mTrace.PushCall( "DynamicsJoint::SetSpringDamping", "" ); +} + +void TestDynamicsJoint::SetSpringCenterPoint( int axisIndex, float ratio ) +{ + mTrace.PushCall( "DynamicsJoint::SetSpringCenterPoint", "" ); +} + +void TestDynamicsJoint::EnableMotor( int axisIndex, bool flag ) +{ + mTrace.PushCall( "DynamicsJoint::EnableMotor", "" ); +} + +void TestDynamicsJoint::SetMotorVelocity( int axisIndex, float velocity ) +{ + mTrace.PushCall( "DynamicsJoint::SetMotorVelocity", "" ); +} + +void TestDynamicsJoint::SetMotorForce( int axisIndex, float force ) +{ + mTrace.PushCall( "DynamicsJoint::SetMotorForce", "" ); +} + + +TestDynamicsShape::TestDynamicsShape( TraceCallStack& trace ) +: mVertices( NULL ), + mFaces( NULL ), + mTrace( trace ) +{ + mTrace.PushCall( "DynamicsShape::DynamicsShape", "" ); +} + +TestDynamicsShape::~TestDynamicsShape() +{ + mTrace.PushCall( "DynamicsShape::~DynamicsShape", "" ); +} + +void TestDynamicsShape::Initialize( int type, const Vector3& dimensions ) +{ + mTrace.PushCall( "DynamicsShape::Initialize", "" ); +} + +void TestDynamicsShape::Initialize( int type, const MeshData::VertexContainer& vertices, const MeshData::FaceIndices& faceIndices ) +{ + mTrace.PushCall( "DynamicsShape::Initialize", "mesh" ); +} + +TestDynamicsBody::TestDynamicsBody( TraceCallStack& trace ) +: mSettings( NULL ), + mConserveVolume( false ), + mConserveShape( false ), + mKinematic( false ), + mActivationState( true ), + mCollisionGroup( 0 ), + mCollisionMask( 0 ), + mTrace( trace ) +{ + mTrace.PushCall( "DynamicsBody::DynamicsBody", "" ); +} + +TestDynamicsBody::~TestDynamicsBody() +{ + mTrace.PushCall( "DynamicsBody::~DynamicsBody", "" ); +} + +TestDynamicsWorld::TestDynamicsWorld( TraceCallStack& trace ) +: mSettings( NULL ), + mTrace( trace ) +{ + mTrace.PushCall( "DynamicsWorld::DynamicsWorld", "" ); +} + +TestDynamicsWorld::~TestDynamicsWorld() +{ + mTrace.PushCall( "DynamicsWorld::~DynamicsWorld", "" ); +} + + +TestDynamicsFactory::TestDynamicsFactory( TraceCallStack& trace ) : mTrace( trace ) +{ +} + +TestDynamicsFactory::~TestDynamicsFactory() +{ +} + +bool TestDynamicsFactory::InitializeDynamics( const Integration::DynamicsWorldSettings& worldSettings ) +{ + mTrace.PushCall( "DynamicsFactory::InitializeDynamics", "" ); + return true; +} + +void TestDynamicsFactory::TerminateDynamics() +{ + mTrace.PushCall( "DynamicsFactory::InitializeDynamics", "" ); +} + +Integration::DynamicsWorld* TestDynamicsFactory::CreateDynamicsWorld() +{ + mTrace.PushCall( "DynamicsFactory::CreateDynamicsWorld", "" ); + return new TestDynamicsWorld( mTrace ); +} + +Integration::DynamicsBody* TestDynamicsFactory::CreateDynamicsBody() +{ + mTrace.PushCall( "DynamicsFactory::CreateDynamicsBody", "" ); + return new TestDynamicsBody( mTrace ); +} + +Integration::DynamicsJoint* TestDynamicsFactory::CreateDynamicsJoint() +{ + mTrace.PushCall( "DynamicsFactory::CreateDynamicsJoint", "" ); + return new TestDynamicsJoint( mTrace ); +} + +Integration::DynamicsShape* TestDynamicsFactory::CreateDynamicsShape() +{ + mTrace.PushCall( "DynamicsFactory::CreateDynamicsShape", "" ); + return new TestDynamicsShape( mTrace ); +} + + +} //namespace Dali diff --git a/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-dynamics.h b/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-dynamics.h new file mode 100644 index 0000000..60b439f --- /dev/null +++ b/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-dynamics.h @@ -0,0 +1,322 @@ +#ifndef __TEST_DYNAMICS_H__ +#define __TEST_DYNAMICS_H__ + +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 +#include +#include + +#include + +namespace Dali +{ + +class TestDynamicsJoint : public Integration::DynamicsJoint +{ +public: + TestDynamicsJoint( TraceCallStack& trace ); + virtual ~TestDynamicsJoint(); + +public: // From Dali::Integration::DynamicsJoint + + void Initialize( Integration::DynamicsBody* bodyA, const Vector3& positionA, const Quaternion& rotationA, const Vector3& offsetA, + Integration::DynamicsBody* bodyB, const Vector3& positionB, const Quaternion& rotationB, const Vector3& offsetB ); + void SetLimit( const int axisIndex, const float lowerLimit, const float upperLimit ); + void EnableSpring( int axisIndex, bool flag ); + void SetSpringStiffness( int axisIndex, float stiffness ); + void SetSpringDamping( int axisIndex, float damping ); + void SetSpringCenterPoint( int axisIndex, float ratio ); + void EnableMotor( int axisIndex, bool flag ); + void SetMotorVelocity( int axisIndex, float velocity ); + void SetMotorForce( int axisIndex, float force ); + +private: + + TraceCallStack& mTrace; + +}; // class TestDynamicsJoint + +class TestDynamicsShape : public Integration::DynamicsShape +{ +public: + + TestDynamicsShape( TraceCallStack& trace ); + virtual ~TestDynamicsShape(); + +public: + void Initialize( int type, const Vector3& dimensions ); + + void Initialize( int type, const MeshData::VertexContainer& vertices, const MeshData::FaceIndices& faceIndices ); + +public: + + MeshData::VertexContainer* mVertices; + MeshData::FaceIndices* mFaces; + +private: + + TraceCallStack& mTrace; + +}; // class TestDynamicsShape + +class TestDynamicsBody : public Integration::DynamicsBody +{ +public: + TestDynamicsBody( TraceCallStack& trace ); + + virtual ~TestDynamicsBody(); + +public: // From Dali::Integration::DynamicsBody + + inline void Initialize( const Integration::DynamicsBodySettings& bodySettings, Integration::DynamicsShape* shape, + Integration::DynamicsWorld& dynamicsWorld, + const Vector3& startPosition, const Quaternion& startRotation ) + { + mTrace.PushCall( "DynamicsBody::~DynamicsBody", "" ); + } + + inline void SetMass( float mass ) + { + mTrace.PushCall( "DynamicsBody::SetMass", "" ); + } + + inline void SetElasticity( float elasticity ) + { + mTrace.PushCall( "DynamicsBody::SetElasticity", "" ); + } + + inline void SetLinearVelocity( const Vector3& velocity ) + { + mTrace.PushCall( "DynamicsBody::SetLinearVelocity", "" ); + } + + inline Vector3 GetLinearVelocity() const + { + mTrace.PushCall( "DynamicsBody::GetLinearVelocity", "" ); + return Vector3::ZERO; + } + + inline void SetAngularVelocity( const Vector3& velocity ) + { + mTrace.PushCall( "DynamicsBody::SetAngularVelocity", "" ); + } + + inline Vector3 GetAngularVelocity() const + { + mTrace.PushCall( "DynamicsBody::GetAngularVelocity", "" ); + return Vector3::ZERO; + } + + inline void SetKinematic( bool flag ) + { + mTrace.PushCall( "DynamicsBody::SetKinematic", "" ); + } + + inline bool IsKinematic() const + { + mTrace.PushCall( "DynamicsBody::IsKinematic", "" ); + return mKinematic; + } + + inline void SetSleepEnabled( bool flag ) + { + mTrace.PushCall( "DynamicsBody::SetSleepEnabled", "" ); + } + + inline void WakeUp() + { + mTrace.PushCall( "DynamicsBody::WakeUp", "" ); + } + + inline void AddAnchor( unsigned int index, const Integration::DynamicsBody* anchorBody, bool collisions ) + { + mTrace.PushCall( "DynamicsBody::AddAnchor", "" ); + } + + inline void ConserveVolume( bool flag ) + { + mTrace.PushCall( "DynamicsBody::ConserveVolume", "" ); + } + + inline void ConserveShape( bool flag ) + { + mTrace.PushCall( "DynamicsBody::ConserveShape", "" ); + } + + inline short int GetCollisionGroup() const + { + mTrace.PushCall( "DynamicsBody::GetCollisionGroup", "" ); + return mCollisionGroup; + } + + inline void SetCollisionGroup( short int collisionGroup ) + { + mTrace.PushCall( "DynamicsBody::SetCollisionGroup", "" ); + mCollisionGroup = collisionGroup; + } + + inline short int GetCollisionMask() const + { + mTrace.PushCall( "DynamicsBody::GetCollisionMask", "" ); + return mCollisionMask; + } + + inline void SetCollisionMask( short int collisionMask ) + { + mTrace.PushCall( "DynamicsBody::SetCollisionMask", "" ); + mCollisionMask = collisionMask; + } + + inline int GetType() const + { + mTrace.PushCall( "DynamicsBody::GetType", "" ); + return mSettings->type; + } + + inline bool IsActive() const + { + mTrace.PushCall( "DynamicsBody::IsActive", "" ); + return mActivationState; + } + + inline void SetTransform( const Vector3& position, const Quaternion& rotation ) + { + mTrace.PushCall( "DynamicsBody::SetTransform", "" ); + } + + inline void GetTransform( Vector3& position, Quaternion& rotation ) + { + mTrace.PushCall( "DynamicsBody::GetTransform", "" ); + } + + inline void GetSoftVertices( MeshData::VertexContainer& vertices ) const + { + mTrace.PushCall( "DynamicsBody::GetSoftVertices", "" ); + } + +private: + Dali::Integration::DynamicsBodySettings* mSettings; + bool mConserveVolume:1; + bool mConserveShape:1; + bool mKinematic:1; + bool mActivationState:1; + + short int mCollisionGroup; + short int mCollisionMask; + + TraceCallStack& mTrace; +}; // class TestDynamicsBody + +class TestDynamicsWorld : public Dali::Integration::DynamicsWorld +{ +public: + + TestDynamicsWorld( TraceCallStack& trace ); + + virtual ~TestDynamicsWorld(); + + inline void Initialize( const Dali::Integration::DynamicsWorldSettings& worldSettings ) + { + + mTrace.PushCall( "DynamicsWorld::Initialize", "" ); + } + + inline void AddBody( Dali::Integration::DynamicsBody* body ) + { + mTrace.PushCall( "DynamicsWorld::AddBody", "" ); + } + + inline void RemoveBody( Dali::Integration::DynamicsBody* body ) + { + mTrace.PushCall( "DynamicsWorld::RemoveBody", "" ); + } + + inline void AddJoint( Dali::Integration::DynamicsJoint* joint ) + { + mTrace.PushCall( "DynamicsWorld::AddJoint", "" ); + } + + inline void RemoveJoint( Dali::Integration::DynamicsJoint* joint ) + { + mTrace.PushCall( "DynamicsWorld::RemoveJoint", "" ); + } + + inline void SetGravity( const Vector3& gravity ) + { + mTrace.PushCall( "DynamicsWorld::SetGravity", "" ); + } + + inline void SetDebugDrawMode(int mode) + { + mTrace.PushCall( "DynamicsWorld::SetDebugDrawMode", "" ); + } + + inline const Integration::DynamicsDebugVertexContainer& DebugDraw() + { + mTrace.PushCall( "DynamicsWorld::DebugDraw", "" ); + return mDebugVertices; + } + + inline void Update( float elapsedSeconds ) + { + mTrace.PushCall( "DynamicsWorld::Update", "" ); + } + + inline void CheckForCollisions( Integration::CollisionDataContainer& contacts ) + { + mTrace.PushCall( "DynamicsWorld::CheckForCollisions", "" ); + } + +private: + Dali::Integration::DynamicsWorldSettings* mSettings; + Dali::Integration::DynamicsDebugVertexContainer mDebugVertices; + + TraceCallStack& mTrace; + +}; // class TestDynamicsWorld + +class TestDynamicsFactory : public Integration::DynamicsFactory +{ + +public: + + TestDynamicsFactory( TraceCallStack& trace ); + + virtual ~TestDynamicsFactory(); + + virtual bool InitializeDynamics( const Integration::DynamicsWorldSettings& worldSettings ); + + virtual void TerminateDynamics(); + + virtual Integration::DynamicsWorld* CreateDynamicsWorld(); + virtual Integration::DynamicsBody* CreateDynamicsBody(); + + virtual Integration::DynamicsJoint* CreateDynamicsJoint(); + + virtual Integration::DynamicsShape* CreateDynamicsShape(); + + TraceCallStack& mTrace; +}; // class TestDynamicsFactory + +} // Dali + +#endif // __TEST_DYNAMICS_H__ diff --git a/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-platform-abstraction.cpp b/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-platform-abstraction.cpp new file mode 100644 index 0000000..93c8ae9 --- /dev/null +++ b/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-platform-abstraction.cpp @@ -0,0 +1,641 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 "test-platform-abstraction.h" +#include "dali-test-suite-utils.h" +#include + +namespace Dali +{ + +/** + * Constructor + */ +TestPlatformAbstraction::TestPlatformAbstraction() +: mRequest(0), + mDynamicsFactory(NULL) +{ + Initialize(); +} + +/** + * Destructor + */ +TestPlatformAbstraction::~TestPlatformAbstraction() +{ + delete mDynamicsFactory; +} + +/** + * @copydoc PlatformAbstraction::GetTimeMicroseconds() + */ +void TestPlatformAbstraction::GetTimeMicroseconds(unsigned int &seconds, unsigned int µSeconds) +{ + seconds = mSeconds; + microSeconds = mMicroSeconds; + mTrace.PushCall("GetTimeMicroseconds", ""); +} + +/** + * @copydoc PlatformAbstraction::Suspend() + */ +void TestPlatformAbstraction::Suspend() +{ + mTrace.PushCall("Suspend", ""); +} + +/** + * @copydoc PlatformAbstraction::Resume() + */ +void TestPlatformAbstraction::Resume() +{ + mTrace.PushCall("Resume", ""); +} + +void TestPlatformAbstraction::GetClosestImageSize( const std::string& filename, + const ImageAttributes& attributes, + Vector2& closestSize) +{ + closestSize = mClosestSize; + mTrace.PushCall("GetClosestImageSize", ""); +} + +void TestPlatformAbstraction::GetClosestImageSize( Integration::ResourcePointer resourceBuffer, + const ImageAttributes& attributes, + Vector2& closestSize) +{ + closestSize = mClosestSize; + mTrace.PushCall("GetClosestImageSize", ""); +} + + +/** + * @copydoc PlatformAbstraction::LoadResource() + */ +void TestPlatformAbstraction::LoadResource(const Integration::ResourceRequest& request) +{ + mTrace.PushCall("LoadResource", ""); + if(mRequest != NULL) + { + delete mRequest; + tet_infoline ("Warning: multiple resource requests not handled by Test Suite. You may see unexpected errors"); + } + mRequest = new Integration::ResourceRequest(request); +} + +Integration::ResourcePointer TestPlatformAbstraction::LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath) +{ + mTrace.PushCall("LoadResourceSynchronously", ""); + return mResources.loadedResource; +} + +/** + * @copydoc PlatformAbstraction::SaveResource() + */ +void TestPlatformAbstraction::SaveResource(const Integration::ResourceRequest& request) +{ + mTrace.PushCall("SaveResource", ""); + if(mRequest != NULL) + { + delete mRequest; + tet_infoline ("Warning: multiple resource requests not handled by Test Suite. You may see unexpected errors"); + } + mRequest = new Integration::ResourceRequest(request); +} + +/** + * @copydoc PlatformAbstraction::CancelLoad() + */ +void TestPlatformAbstraction::CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId) +{ + mTrace.PushCall("CancelLoad", ""); +} + +/** + * @copydoc PlatformAbstraction::GetResources() + */ +void TestPlatformAbstraction::GetResources(Integration::ResourceCache& cache) +{ + mTrace.PushCall("GetResources", ""); + + if(mResources.loaded) + { + cache.LoadResponse( mResources.loadedId, mResources.loadedType, mResources.loadedResource, Integration::RESOURCE_COMPLETELY_LOADED ); + } + if(mResources.loadFailed) + { + cache.LoadFailed( mResources.loadFailedId, mResources.loadFailure ); + } + if(mResources.saved) + { + cache.SaveComplete( mResources.savedId, mResources.savedType ); + } + if(mResources.saveFailed) + { + cache.SaveFailed( mResources.saveFailedId, mResources.saveFailure ); + } +} + +/** + * @copydoc PlatformAbstraction::IsLoading() + */ +bool TestPlatformAbstraction::IsLoading() +{ + mTrace.PushCall("IsLoading", ""); + return mIsLoadingResult; +} + +/** + * @copydoc PlatformAbstraction::GetDefaultFontFamily() + */ +std::string TestPlatformAbstraction::GetDefaultFontFamily() const +{ + mTrace.PushCall("GetDefaultFontFamily", ""); + return mGetDefaultFontFamilyResult; +} + +/** + * @copydoc PlatformAbstraction::GetDefaultFontSize() + */ +const float TestPlatformAbstraction::GetDefaultFontSize() const +{ + mTrace.PushCall("GetDefaultFontSize", ""); + return mGetDefaultFontSizeResult; +} + +const PixelSize TestPlatformAbstraction::GetFontLineHeightFromCapsHeight(const std::string& fontFamily, const std::string& fontStyle, const CapsHeight& capsHeight) const +{ + mTrace.PushCall("GetFontLineHeightFromCapsHeight", ""); + // LineHeight will be bigger than CapsHeight, so return capsHeight + 1 + return PixelSize(capsHeight + 1); +} + +/** + * @copydoc PlatformAbstraction::GetGlyphData() + */ + +Integration::GlyphSet* TestPlatformAbstraction::GetGlyphData ( const Integration::TextResourceType& textRequest, + const std::string& fontFamily, + bool getBitmap) const +{ + if( getBitmap ) + { + mTrace.PushCall("GetGlyphData", "getBitmap:true"); + } + else + { + mTrace.PushCall("GetGlyphData", "getBitmap:false"); + } + + // It creates fake metrics for the received characters. + + Integration::GlyphSet* set = new Dali::Integration::GlyphSet(); + Integration::BitmapPtr bitmapData; + + std::set characters; + + for( Integration::TextResourceType::CharacterList::const_iterator it = textRequest.mCharacterList.begin(), endIt = textRequest.mCharacterList.end(); it != endIt; ++it ) + { + if( characters.find( it->character ) == characters.end() ) + { + characters.insert( it->character ); + Integration::GlyphMetrics character = {it->character, Integration::GlyphMetrics::LOW_QUALITY, 10.0f, 10.0f, 9.0f, 1.0f, 10.0f, it->xPosition, it->yPosition }; + + if( getBitmap ) + { + bitmapData = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true); + bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, 64, 64); + PixelBuffer* pixelBuffer = bitmapData->GetBuffer(); + memset( pixelBuffer, it->character, 64*64 ); + } + + set->AddCharacter(bitmapData, character); + } + } + + set->mLineHeight = 10.0f; + set->mAscender = 9.0f; + set->mUnitsPerEM = 2048.0f/64.0f; + set->SetAtlasResourceId( textRequest.mTextureAtlasId ); + set->mFontHash = textRequest.mFontHash; + + return set; +} + +/** + * @copydoc PlatformAbstraction::GetCachedGlyphData() + */ + +Integration::GlyphSet* TestPlatformAbstraction::GetCachedGlyphData( const Integration::TextResourceType& textRequest, + const std::string& fontFamily ) const +{ + mTrace.PushCall("GetCachedGlyphData", ""); + + // It creates fake metrics and bitmap for received numeric characters '0' through '9'. + Integration::GlyphSet* set = new Dali::Integration::GlyphSet(); + Integration::BitmapPtr bitmapData; + + std::set characters; + + for( Integration::TextResourceType::CharacterList::const_iterator it = textRequest.mCharacterList.begin(), endIt = textRequest.mCharacterList.end(); it != endIt; ++it ) + { + if( it->character >= '0' && it->character <= '9' && characters.find( it->character ) == characters.end() ) + { + characters.insert( it->character ); + Integration::GlyphMetrics character = {it->character, Integration::GlyphMetrics::HIGH_QUALITY, 10.0f, 10.0f, 9.0f, 1.0f, 10.0f, it->xPosition, it->yPosition }; + + bitmapData = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true); + bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, 64, 64); + PixelBuffer* pixelBuffer = bitmapData->GetBuffer(); + memset( pixelBuffer, it->character, 64*64 ); + set->AddCharacter(bitmapData, character); + } + } + + set->mLineHeight = 10.0f; + set->mAscender = 9.0f; + set->mUnitsPerEM = 2048.0f/64.0f; + set->SetAtlasResourceId( textRequest.mTextureAtlasId ); + set->mFontHash = textRequest.mFontHash; + + return set; +} + + +/** + * @copydoc PlatformAbstraction::GetGlobalMetrics() + */ +void TestPlatformAbstraction::GetGlobalMetrics( const std::string& fontFamily, + const std::string& fontStyle, + Integration::GlobalMetrics& globalMetrics ) const +{ + globalMetrics.lineHeight = 10.0f; + globalMetrics.ascender = 9.0f; + globalMetrics.unitsPerEM = 2048.0f/64.0f; + globalMetrics.underlineThickness = 2.f; + globalMetrics.underlinePosition = 1.f; +} + +/** + * @copydoc PlatformAbstraction::GetFontPath() + */ +std::string TestPlatformAbstraction::GetFontPath(const std::string& family, bool bold, bool italic) const +{ + mTrace.PushCall("GetFontPath", ""); + return mGetFontPathResult; + + // Do nothing with arguments +} + +/** + * @copydoc PlatformAbstraction::SetDpi() + */ +void TestPlatformAbstraction::SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical) +{ + mTrace.PushCall("SetDpi", ""); +} + +/** + * @copydoc PlatformAbstraction::GetFontFamilyForChars() + */ +std::string TestPlatformAbstraction::GetFontFamilyForChars(const TextArray& charsRequested) const +{ + mTrace.PushCall("GetFontFamilyForChars", ""); + return mGetDefaultFontFamilyResult; +} + +/** + * @copydoc PlatformAbstraction::AllGlyphsSupported() + */ +bool TestPlatformAbstraction::AllGlyphsSupported(const std::string& name, const std::string& fontStyle, const TextArray& text) const +{ + mTrace.PushCall("AllGlyphsSupported", ""); + return true; +} + +/** + * @copydoc PlatformAbstraction::ValidateFontFamilyName() + */ +bool TestPlatformAbstraction::ValidateFontFamilyName(const std::string& fontFamily, const std::string& fontStyle, bool& isDefaultSystemFont, std::string& closestMatch, std::string& closestStyleMatch) const +{ + mTrace.PushCall("ValidateFontFamilyName", ""); + return true; +} + +/** + * @copydoc PlatformAbstraction::GetFontList() + */ +std::vector TestPlatformAbstraction::GetFontList( PlatformAbstraction::FontListMode mode ) const +{ + mFontListMode = mode; + mTrace.PushCall("ValidateGetFontList", ""); + std::vector fontList; + return fontList; +} + +/** + * @copydoc PlatformAbstraction::LoadFile() + */ +bool TestPlatformAbstraction::LoadFile( const std::string& filename, std::vector< unsigned char >& buffer ) const +{ + mTrace.PushCall("LoadFile", ""); + if( mLoadFileResult.loadResult ) + { + buffer = mLoadFileResult.buffer; + } + + return mLoadFileResult.loadResult; +} + +/** + * @copydoc PlatformAbstraction::SaveFile() + */ +bool TestPlatformAbstraction::SaveFile(const std::string& filename, std::vector< unsigned char >& buffer) const +{ + mTrace.PushCall("SaveFile", ""); + return false; +} + +void TestPlatformAbstraction::JoinLoaderThreads() +{ + mTrace.PushCall("JoinLoaderThreads", ""); +} + +void TestPlatformAbstraction::UpdateDefaultsFromDevice() +{ + mTrace.PushCall("UpdateDefaultsFromDevice", ""); + mGetDefaultFontFamilyResult+=1.0f; +} + +Integration::DynamicsFactory* TestPlatformAbstraction::GetDynamicsFactory() +{ + mTrace.PushCall("GetDynamicsFactory", ""); + if( mDynamicsFactory == NULL ) + { + mDynamicsFactory = new TestDynamicsFactory( mTrace ); + } + return mDynamicsFactory; +} + +bool TestPlatformAbstraction::ReadGlobalMetricsFromCache( const std::string& fontFamily, + const std::string& fontStyle, + Integration::GlobalMetrics& globalMetrics ) +{ + mTrace.PushCall("ReadGlobalMetricsFromCacheFile", ""); + globalMetrics = mReadGlobalMetrics; // Want to copy contents... + return mReadGlobalMetricsResult; // Default false (will be set to true on subsequent write) +} + +void TestPlatformAbstraction::WriteGlobalMetricsToCache( const std::string& fontFamily, + const std::string& fontStyle, + const Integration::GlobalMetrics& globalMetrics ) +{ + // Copy so next read uses written values. TODO: Could add method + // to turn this behaviour off for more extensive testing. + mReadGlobalMetrics = globalMetrics; + mReadGlobalMetricsResult = true; + + mTrace.PushCall("WriteGlobalMetricsToCacheFile", ""); +} + +bool TestPlatformAbstraction::ReadMetricsFromCache( const std::string& fontFamily, + const std::string& fontStyle, + std::vector& glyphMetricsContainer ) +{ + mTrace.PushCall("ReadMetricsFromCacheFile", ""); + glyphMetricsContainer = mReadMetrics; + return mReadMetricsResult; // Default false (will be set to true on subsequent write) +} + +void TestPlatformAbstraction::WriteMetricsToCache( const std::string& fontFamily, + const std::string& fontStyle, + const Integration::GlyphSet& glyphSet ) +{ + // Copy so next read uses written values. TODO: Could add method + // to turn this behaviour off for more extensive testing. + const Integration::GlyphSet::CharacterList& charList = glyphSet.GetCharacterList(); + mReadMetrics.clear(); + for(std::size_t i=0, end=charList.size(); i& fileNames ) +{ + fileNames.push_back( std::string( "u1f004.png" ) ); + fileNames.push_back( std::string( "u1f0cf.png" ) ); + fileNames.push_back( std::string( "u1f170.png" ) ); + fileNames.push_back( std::string( "u1f601.png" ) ); +} + +Integration::BitmapPtr TestPlatformAbstraction::GetGlyphImage( const std::string& fontFamily, const std::string& fontStyle, float fontSize, uint32_t character ) const +{ + Integration::BitmapPtr image = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true ); + image->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 1, 1 ); + + mTrace.PushCall("GetGlyphImage", ""); + + return image; +} + + +/** Call this every test */ +void TestPlatformAbstraction::Initialize() +{ + mTrace.Reset(); + mTrace.Enable(true); + memset(&mResources, 0, sizeof(Resources)); + memset(&mReadGlobalMetrics, 0, sizeof(Integration::GlobalMetrics)); + mSeconds=0; + mMicroSeconds=0; + mIsLoadingResult=false; + mGetDefaultFontFamilyResult = "HelveticaNeue"; + mGetDefaultFontSizeResult=12.0f; + mGetFontPathResult="helvetica-12"; + mReadMetricsResult=false; + mReadGlobalMetricsResult=false; + + if(mRequest) + { + delete mRequest; + mRequest = 0; + } +} + + +bool TestPlatformAbstraction::WasCalled(TestFuncEnum func) +{ + switch(func) + { + case GetTimeMicrosecondsFunc: return mTrace.FindMethod("GetTimeMicroseconds"); + case SuspendFunc: return mTrace.FindMethod("Suspend"); + case ResumeFunc: return mTrace.FindMethod("Resume"); + case LoadResourceFunc: return mTrace.FindMethod("LoadResource"); + case SaveResourceFunc: return mTrace.FindMethod("SaveResource"); + case LoadFileFunc: return mTrace.FindMethod("LoadFile"); + case SaveFileFunc: return mTrace.FindMethod("SaveFile"); + case CancelLoadFunc: return mTrace.FindMethod("CancelLoad"); + case GetResourcesFunc: return mTrace.FindMethod("GetResources"); + case IsLoadingFunc: return mTrace.FindMethod("IsLoading"); + case GetDefaultFontFamilyFunc: return mTrace.FindMethod("GetDefaultFontFamily"); + case GetDefaultFontSizeFunc: return mTrace.FindMethod("GetDefaultFontSize"); + case GetFontLineHeightFromCapsHeightFunc: return mTrace.FindMethod("GetFontLineHeightFromCapsHeight"); + case GetGlyphDataFunc: return mTrace.FindMethod("GetGlyphData"); + case GetCachedGlyphDataFunc: return mTrace.FindMethod("GetCachedGlyphData"); + case GetFontPathFunc: return mTrace.FindMethod("GetFontPath"); + case SetDpiFunc: return mTrace.FindMethod("SetDpi"); + case JoinLoaderThreadsFunc: return mTrace.FindMethod("JoinLoaderThreads"); + case GetFontFamilyForCharsFunc: return mTrace.FindMethod("GetFontFamilyForChars"); + case AllGlyphsSupportedFunc: return mTrace.FindMethod("AllGlyphsSupported"); + case ValidateFontFamilyNameFunc: return mTrace.FindMethod("ValidateFontFamilyName"); + case UpdateDefaultsFromDeviceFunc: return mTrace.FindMethod("UpdateDefaultsFromDevice"); + case GetDynamicsFactoryFunc: return mTrace.FindMethod("GetDynamicsFactory"); + case ValidateGetFontListFunc: return mTrace.FindMethod("ValidateGetFontList"); + case ReadGlobalMetricsFromCacheFileFunc: return mTrace.FindMethod("ReadGlobalMetricsFromCacheFile"); + case WriteGlobalMetricsToCacheFileFunc: return mTrace.FindMethod("WriteGlobalMetricsToCacheFile"); + case ReadMetricsFromCacheFileFunc: return mTrace.FindMethod("ReadMetricsFromCacheFile"); + case WriteMetricsToCacheFileFunc: return mTrace.FindMethod("WriteMetricsToCacheFile"); + } + return false; +} + +void TestPlatformAbstraction::SetGetTimeMicrosecondsResult(size_t sec, size_t usec) +{ + mSeconds = sec; + mMicroSeconds = usec; +} + +void TestPlatformAbstraction::IncrementGetTimeResult(size_t milliseconds) +{ + mMicroSeconds += milliseconds * 1000u; + unsigned int additionalSeconds = mMicroSeconds / 1000000u; + + mSeconds += additionalSeconds; + mMicroSeconds -= additionalSeconds * 1000000u; +} + +void TestPlatformAbstraction::SetIsLoadingResult(bool result) +{ + mIsLoadingResult = result; +} + +void TestPlatformAbstraction::SetGetDefaultFontFamilyResult(std::string result) +{ + mGetDefaultFontFamilyResult = result; +} + +void TestPlatformAbstraction::SetGetDefaultFontSizeResult(float result) +{ + mGetDefaultFontSizeResult = result; +} + +void TestPlatformAbstraction::SetGetFontPathResult(std::string& result) +{ + mGetFontPathResult = result; +} + +void TestPlatformAbstraction::ClearReadyResources() +{ + memset(&mResources, 0, sizeof(Resources)); +} + +void TestPlatformAbstraction::SetResourceLoaded(Integration::ResourceId loadedId, + Integration::ResourceTypeId loadedType, + Integration::ResourcePointer loadedResource) +{ + mResources.loaded = true; + mResources.loadedId = loadedId; + mResources.loadedType = loadedType; + mResources.loadedResource = loadedResource; +} + +void TestPlatformAbstraction::SetResourceLoadFailed(Integration::ResourceId id, + Integration::ResourceFailure failure) +{ + mResources.loadFailed = true; + mResources.loadFailedId = id; + mResources.loadFailure = failure; +} + +void TestPlatformAbstraction::SetResourceSaved(Integration::ResourceId savedId, + Integration::ResourceTypeId savedType) +{ + mResources.saved = true; + mResources.savedId = savedId; + mResources.savedType = savedType; +} + +void TestPlatformAbstraction::SetResourceSaveFailed(Integration::ResourceId id, + Integration::ResourceFailure failure) +{ + mResources.saveFailed = true; + mResources.saveFailedId = id; + mResources.saveFailure = failure; +} + +Integration::ResourceRequest* TestPlatformAbstraction::GetRequest() +{ + return mRequest; +} + +void TestPlatformAbstraction::DiscardRequest() +{ + delete mRequest; + mRequest = NULL; +} + +void TestPlatformAbstraction::SetClosestImageSize(const Vector2& size) +{ + mClosestSize = size; +} + +void TestPlatformAbstraction::SetLoadFileResult( bool result, std::vector< unsigned char >& buffer ) +{ + mLoadFileResult.loadResult = result; + if( result ) + { + mLoadFileResult.buffer = buffer; + } +} + +void TestPlatformAbstraction::SetSaveFileResult( bool result ) +{ + mSaveFileResult = result; +} + +Integration::PlatformAbstraction::FontListMode TestPlatformAbstraction::GetLastFontListMode( ) +{ + return mFontListMode; +} + +void TestPlatformAbstraction::SetReadGlobalMetricsResult( bool success, Integration::GlobalMetrics& globalMetrics ) +{ + mReadGlobalMetricsResult = success; + mReadGlobalMetrics = globalMetrics; +} + +void TestPlatformAbstraction::SetReadMetricsResult( bool success, std::vector& glyphMetricsContainer ) +{ + mReadMetricsResult = success; + mReadMetrics = glyphMetricsContainer; // copy +} + +} // namespace Dali diff --git a/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-platform-abstraction.h b/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-platform-abstraction.h new file mode 100644 index 0000000..c23fec8 --- /dev/null +++ b/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-platform-abstraction.h @@ -0,0 +1,348 @@ +#ifndef __DALI_TEST_PLATFORM_ABSTRACTION_H__ +#define __DALI_TEST_PLATFORM_ABSTRACTION_H__ + +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +// EXTERNAL INCLUDES +#include +#include +#include + +// INTERNAL INCLUDES +#include + +#include +#include "test-trace-call-stack.h" +#include "test-dynamics.h" + +namespace Dali +{ + +/** + * Concrete implementation of the platform abstraction class. + */ +class DALI_IMPORT_API TestPlatformAbstraction : public Dali::Integration::PlatformAbstraction +{ + +public: + + struct Resources + { + bool loaded; + Integration::ResourceId loadedId; + Integration::ResourceTypeId loadedType; + Integration::ResourcePointer loadedResource; + + bool loadFailed; + Integration::ResourceId loadFailedId; + Integration::ResourceFailure loadFailure; + + bool saved; + Integration::ResourceId savedId; + Integration::ResourceTypeId savedType; + + bool saveFailed; + Integration::ResourceId saveFailedId; + Integration::ResourceFailure saveFailure; + }; + + struct LoadFileResult + { + inline LoadFileResult() + : loadResult(false) + { + + } + + bool loadResult; + std::vector< unsigned char> buffer; + }; + + /** + * Constructor + */ + TestPlatformAbstraction(); + + /** + * Destructor + */ + virtual ~TestPlatformAbstraction(); + + /** + * @copydoc PlatformAbstraction::GetTimeMicroseconds() + */ + virtual void GetTimeMicroseconds(unsigned int &seconds, unsigned int µSeconds); + + /** + * @copydoc PlatformAbstraction::Suspend() + */ + virtual void Suspend(); + + /** + * @copydoc PlatformAbstraction::Resume() + */ + virtual void Resume(); + + virtual void GetClosestImageSize( const std::string& filename, + const ImageAttributes& attributes, + Vector2& closestSize); + + virtual void GetClosestImageSize( Integration::ResourcePointer resourceBuffer, + const ImageAttributes& attributes, + Vector2& closestSize); + + /** + * @copydoc PlatformAbstraction::LoadResource() + */ + virtual void LoadResource(const Integration::ResourceRequest& request); + + virtual Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath); + + /** + * @copydoc PlatformAbstraction::SaveResource() + */ + virtual void SaveResource(const Integration::ResourceRequest& request); + + /** + * @copydoc PlatformAbstraction::CancelLoad() + */ + virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId); + + /** + * @copydoc PlatformAbstraction::GetResources() + */ + virtual void GetResources(Integration::ResourceCache& cache); + + /** + * @copydoc PlatformAbstraction::IsLoading() + */ + virtual bool IsLoading(); + + /** + * @copydoc PlatformAbstraction::GetDefaultFontFamily() + */ + virtual std::string GetDefaultFontFamily() const; + + /** + * @copydoc PlatformAbstraction::GetDefaultFontSize() + */ + virtual const float GetDefaultFontSize() const; + + virtual const PixelSize GetFontLineHeightFromCapsHeight(const std::string& fontFamily, const std::string& fontStyle, const CapsHeight& capsHeight) const; + + /** + * @copydoc PlatformAbstraction::GetGlyphData() + */ + virtual Integration::GlyphSet* GetGlyphData ( const Integration::TextResourceType& textRequest, + const std::string& fontFamily, + bool getBitmap) const; + + /** + * @copydoc PlatformAbstraction::GetCachedGlyphData() + */ + virtual Integration::GlyphSet* GetCachedGlyphData( const Integration::TextResourceType& textRequest, + const std::string& fontFamily ) const; + + + /** + * @copydoc PlatformAbstraction::GetGlobalMetrics() + */ + virtual void GetGlobalMetrics( const std::string& fontFamily, + const std::string& fontStyle, + Integration::GlobalMetrics& globalMetrics ) const; + + /** + * @copydoc PlatformAbstraction::GetFontPath() + */ + virtual std::string GetFontPath(const std::string& family, bool bold, bool italic) const; + + /** + * @copydoc PlatformAbstraction::SetDpi() + */ + virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical); + + /** + * @copydoc PlatformAbstraction::GetFontFamilyForChars() + */ + virtual std::string GetFontFamilyForChars(const TextArray& charsRequested) const; + + /** + * @copydoc PlatformAbstraction::AllGlyphsSupported() + */ + virtual bool AllGlyphsSupported(const std::string& name, const std::string& fontStyle, const TextArray& text) const; + + /** + * @copydoc PlatformAbstraction::ValidateFontFamilyName() + */ + virtual bool ValidateFontFamilyName(const std::string& fontFamily, const std::string& fontStyle, bool& isDefaultSystemFont, std::string& closestMatch, std::string& closestStyleMatch) const; + + /** + * @copydoc PlatformAbstraction::GetFontList() + */ + virtual std::vector GetFontList( PlatformAbstraction::FontListMode mode ) const; + + /** + * @copydoc PlatformAbstraction::LoadFile() + */ + virtual bool LoadFile( const std::string& filename, std::vector< unsigned char >& buffer ) const; + + /** + * @copydoc PlatformAbstraction::SaveFile() + */ + virtual bool SaveFile(const std::string& filename, std::vector< unsigned char >& buffer) const; + + virtual void JoinLoaderThreads(); + + virtual void UpdateDefaultsFromDevice(); + + virtual Integration::DynamicsFactory* GetDynamicsFactory(); + + virtual bool ReadGlobalMetricsFromCache( const std::string& fontFamily, + const std::string& fontStyle, + Integration::GlobalMetrics& globalMetrics ); + + virtual void WriteGlobalMetricsToCache( const std::string& fontFamily, + const std::string& fontStyle, + const Integration::GlobalMetrics& globalMetrics ); + + virtual bool ReadMetricsFromCache( const std::string& fontFamily, + const std::string& fontStyle, + std::vector& glyphMetricsContainer ); + virtual void WriteMetricsToCache( const std::string& fontFamily, + const std::string& fontStyle, + const Integration::GlyphSet& glyphSet ); + + virtual void GetFileNamesFromDirectory( const std::string& directoryName, + std::vector& fileNames ); + + virtual Integration::BitmapPtr GetGlyphImage( const std::string& fontFamily, const std::string& fontStyle, float fontSize, uint32_t character ) const; + + +public: // TEST FUNCTIONS + + // Enumeration of Platform Abstraction methods + typedef enum + { + GetTimeMicrosecondsFunc, + SuspendFunc, + ResumeFunc, + LoadResourceFunc, + SaveResourceFunc, + SaveFileFunc, + LoadFileFunc, + CancelLoadFunc, + GetResourcesFunc, + IsLoadingFunc, + GetDefaultFontFamilyFunc, + GetDefaultFontSizeFunc, + GetFontLineHeightFromCapsHeightFunc, + GetGlyphDataFunc, + GetCachedGlyphDataFunc, + SetDpiFunc, + GetFontPathFunc, + JoinLoaderThreadsFunc, + GetFontFamilyForCharsFunc, + AllGlyphsSupportedFunc, + ValidateFontFamilyNameFunc, + UpdateDefaultsFromDeviceFunc, + GetDynamicsFactoryFunc, + ValidateGetFontListFunc, + ReadGlobalMetricsFromCacheFileFunc, + WriteGlobalMetricsToCacheFileFunc, + ReadMetricsFromCacheFileFunc, + WriteMetricsToCacheFileFunc, + } TestFuncEnum; + + /** Call this every test */ + void Initialize(); + + inline void EnableTrace(bool enable) { mTrace.Enable(enable); } + inline void ResetTrace() { mTrace.Reset(); } + inline TraceCallStack& GetTrace() { return mTrace; } + + bool WasCalled(TestFuncEnum func); + + void SetGetTimeMicrosecondsResult(size_t sec, size_t usec); + + void IncrementGetTimeResult(size_t milliseconds); + + void SetIsLoadingResult(bool result); + + void SetGetDefaultFontFamilyResult(std::string result); + + void SetGetDefaultFontSizeResult(float result); + + void SetGetFontPathResult(std::string& result); + + void ClearReadyResources(); + + void SetResourceLoaded(Integration::ResourceId loadedId, + Integration::ResourceTypeId loadedType, + Integration::ResourcePointer loadedResource); + + void SetResourceLoadFailed(Integration::ResourceId id, + Integration::ResourceFailure failure); + + void SetResourceSaved(Integration::ResourceId savedId, + Integration::ResourceTypeId savedType); + + void SetResourceSaveFailed(Integration::ResourceId id, + Integration::ResourceFailure failure); + + Integration::ResourceRequest* GetRequest(); + + void DiscardRequest(); + + void SetClosestImageSize(const Vector2& size); + + void SetLoadFileResult( bool result, std::vector< unsigned char >& buffer ); + + void SetSaveFileResult( bool result ); + + PlatformAbstraction::FontListMode GetLastFontListMode( ); + + void SetReadGlobalMetricsResult( bool success, Integration::GlobalMetrics& globalMetrics ); + + void SetReadMetricsResult( bool success, std::vector& glyphMetricsContainer ); + + +private: + mutable TraceCallStack mTrace; + size_t mSeconds; + size_t mMicroSeconds; + bool mIsLoadingResult; + std::string mGetDefaultFontFamilyResult; + float mGetDefaultFontSizeResult; + std::string mGetFontPathResult; + Resources mResources; + Integration::ResourceRequest* mRequest; + Vector2 mSize; + Vector2 mClosestSize; + bool mReadGlobalMetricsResult; + bool mReadMetricsResult; + Integration::GlobalMetrics mReadGlobalMetrics; + std::vector mReadMetrics; + + LoadFileResult mLoadFileResult; + bool mSaveFileResult; + mutable FontListMode mFontListMode; + TestDynamicsFactory* mDynamicsFactory; +}; + +} // Dali + +#endif /* __DALI_TET_PLATFORM_ABSTRACTION_H__ */ diff --git a/automated-tests/src/dali-unmanaged/tct-dali-unmanaged-core.cpp b/automated-tests/src/dali-unmanaged/tct-dali-unmanaged-core.cpp new file mode 100644 index 0000000..65fe1e4 --- /dev/null +++ b/automated-tests/src/dali-unmanaged/tct-dali-unmanaged-core.cpp @@ -0,0 +1,31 @@ +#include +#include +#include "tct-dali-unmanaged-core.h" + +int main(int argc, const char *argv[]) +{ + int result = -1; + int i; + + if (argc != 2) { + printf("Usage: %s \n", argv[0]); + return 2; + } + + for (i = 0; tc_array[i].name; i++) { + if (!strcmp(argv[1], tc_array[i].name)) { + if (tc_array[i].startup) + tc_array[i].startup(); + + result = tc_array[i].function(); + + if (tc_array[i].cleanup) + tc_array[i].cleanup(); + + return result; + } + } + + printf("Unknown testcase name: \"%s\"\n", argv[1]); + return 2; +} diff --git a/automated-tests/src/dali-unmanaged/tct-dali-unmanaged-core.h b/automated-tests/src/dali-unmanaged/tct-dali-unmanaged-core.h new file mode 100644 index 0000000..32e2714 --- /dev/null +++ b/automated-tests/src/dali-unmanaged/tct-dali-unmanaged-core.h @@ -0,0 +1,506 @@ +#ifndef __TCT_DALI_UNMANAGED_CORE_H__ +#define __TCT_DALI_UNMANAGED_CORE_H__ + +#include "testcase.h" + +extern void utc_dali_unmanaged_startup(void); +extern void utc_dali_unmanaged_cleanup(void); + +extern int UtcDaliConstrainableDownCast(void); +extern int UtcDaliConstrainableDownCastNegative(void); +extern int UtcDaliConstrainableCustomProperty(void); +extern int UtcDaliContextVertexAttribStartup(void); +extern int UtcDaliContextVertexAttribImageRendering(void); +extern int UtcDaliContextVertexAttribImageAndModelRendering(void); +extern int UtcDaliCustomActorDoAction(void); +extern int UtcDaliGenerateDistanceField(void); +extern int UtcDaliDynamicsBodyConstructor(void); +extern int UtcDaliDynamicsBodyGetMass(void); +extern int UtcDaliDynamicsBodyGetElasticity(void); +extern int UtcDaliDynamicsBodySetLinearVelocity(void); +extern int UtcDaliDynamicsBodySetAngularVelocity(void); +extern int UtcDaliDynamicsBodySetKinematic(void); +extern int UtcDaliDynamicsBodyIsKinematic(void); +extern int UtcDaliDynamicsBodySetSleepEnabled(void); +extern int UtcDaliDynamicsBodyGetSleepEnabled(void); +extern int UtcDaliDynamicsBodyWakeUp(void); +extern int UtcDaliDynamicsBodyAddAnchor(void); +extern int UtcDaliDynamicsBodyConserveVolume(void); +extern int UtcDaliDynamicsBodyConserveShape(void); +extern int UtcDaliDynamicsBodyConfigNew(void); +extern int UtcDaliDynamicsBodyConfigConstructor(void); +extern int UtcDaliDynamicsBodyConfigType(void); +extern int UtcDaliDynamicsBodyConfigSetShape01(void); +extern int UtcDaliDynamicsBodyConfigSetShape02(void); +extern int UtcDaliDynamicsBodyConfigGetShape(void); +extern int UtcDaliDynamicsBodyConfigMass(void); +extern int UtcDaliDynamicsBodyConfigElasticity(void); +extern int UtcDaliDynamicsBodyConfigFriction(void); +extern int UtcDaliDynamicsBodyConfigLinearDamping(void); +extern int UtcDaliDynamicsBodyConfigAngularDamping(void); +extern int UtcDaliDynamicsBodyConfigLinearSleepVelocity(void); +extern int UtcDaliDynamicsBodyConfigAngularSleepVelocity(void); +extern int UtcDaliDynamicsBodyConfigCollisionGroup(void); +extern int UtcDaliDynamicsBodyConfigCollisionMask(void); +extern int UtcDaliDynamicsBodyConfigAnchorHardness(void); +extern int UtcDaliDynamicsBodyConfigVolumeConservation(void); +extern int UtcDaliDynamicsBodyConfigShapeConservation(void); +extern int UtcDaliDynamicsJointConstructor(void); +extern int UtcDaliDynamicsJointLinearLimit(void); +extern int UtcDaliDynamicsJointAngularLimit(void); +extern int UtcDaliDynamicsJointEnableSpring(void); +extern int UtcDaliDynamicsJointSetSpringStiffness(void); +extern int UtcDaliDynamicsJointSetSpringCenterPoint(void); +extern int UtcDaliDynamicsJointEnableMotor(void); +extern int UtcDaliDynamicsJointSetMotorVelocity(void); +extern int UtcDaliDynamicsJointSetMotorForce(void); +extern int UtcDaliDynamicsJointGetActor(void); +extern int UtcDaliDynamicsShapeConstructor(void); +extern int UtcDaliDynamicsShapeNewCapsule(void); +extern int UtcDaliDynamicsShapeNewCone(void); +extern int UtcDaliDynamicsShapeNewCube(void); +extern int UtcDaliDynamicsShapeNewCylinder(void); +extern int UtcDaliDynamicsShapeNewMesh(void); +extern int UtcDaliDynamicsShapeNewSphere(void); +extern int UtcDaliDynamicsShapeGetType(void); +extern int UtcDaliStageInitializeDynamics(void); +extern int UtcDaliStageGetDynamicsWorld(void); +extern int UtcDaliStageTerminateDynamics(void); +extern int UtcDaliDynamicsWorldConstructor(void); +extern int UtcDaliDynamicsWorldGravity(void); +extern int UtcDaliDynamicsWorldDebugDrawMode(void); +extern int UtcDaliDynamicsWorldRootActor(void); +extern int UtcDaliDynamicsWorldConfigConstructor(void); +extern int UtcDaliDynamicsWorldConfigNew(void); +extern int UtcDaliDynamicsWorldConfigType(void); +extern int UtcDaliEncodedBufferImageNew01(void); +extern int UtcDaliEncodedBufferImageNew02(void); +extern int UtcDaliEncodedBufferImageNew03(void); +extern int UtcDaliHitTestAlgorithmWithFunctor(void); +extern int UtcDaliHitTestAlgorithmWithFunctorOnRenderTask(void); +extern int UtcDaliHitTestAlgorithmOrtho01(void); +extern int UtcDaliHitTestAlgorithmOrtho02(void); +extern int UtcDaliHitTestAlgorithmStencil(void); +extern int UtcDaliLightActorConstructorVoid(void); +extern int UtcDaliLightActorDestructor(void); +extern int UtcDaliLightActorNew(void); +extern int UtcDaliLightActorDownCast(void); +extern int UtcDaliLightActorDownCast2(void); +extern int UtcDaliLightActorSetGetLight(void); +extern int UtcDaliLightActorSetGetActive(void); +extern int UtcDaliLightActorMeshTest(void); +extern int UtcDaliLightActorDefaultProperties(void); +extern int UtcDaliLightActorPropertyIndices(void); +extern int UtcDaliLocklessBufferWriteRead01(void); +extern int UtcDaliLocklessBufferMultipleWrites01(void); +extern int UtcDaliLocklessBufferGetSize01(void); +extern int UtcDaliMeshActorNew02(void); +extern int UtcDaliMeshActorCreateNoMeshData(void); +extern int UtcDaliMeshActorCreateSetData01(void); +extern int UtcDaliMeshActorCreateSetData02(void); +extern int UtcDaliMeshActorCreateSetData03(void); +extern int UtcDaliMeshActorCreateSetData04(void); +extern int UtcDaliMeshActorDownCast(void); +extern int UtcDaliMeshActorDownCast2(void); +extern int UtcDaliMeshActorSetMaterial01(void); +extern int UtcDaliMeshActorSetMaterial01b(void); +extern int UtcDaliMeshActorSetMaterial02(void); +extern int UtcDaliMeshActorSetMaterial02b(void); +extern int UtcDaliMeshActorSetMaterial03(void); +extern int UtcDaliMeshActorSetMaterial03b(void); +extern int UtcDaliMeshActorGetMaterial01(void); +extern int UtcDaliMeshActorGetMaterial02(void); +extern int UtcDaliMeshActorSetLighting01(void); +extern int UtcDaliMeshActorSetLighting02(void); +extern int UtcDaliMeshActorBlend01(void); +extern int UtcDaliMeshActorBlend02(void); +extern int UtcDaliMeshActorBlend03(void); +extern int UtcDaliMeshActorBlend04(void); +extern int UtcDaliMeshActorBlend05(void); +extern int UtcDaliMeshActorBlend06(void); +extern int UtcDaliMeshActorBlend07(void); +extern int UtcDaliMeshActorBlend08(void); +extern int UtcDaliMeshActorBlend09(void); +extern int UtcDaliMeshActorBoneUpdate01(void); +extern int UtcDaliMeshActorIndices(void); +extern int UtcDaliMeshDataNew(void); +extern int UtcDaliMeshDataSetData(void); +extern int UtcDaliMeshDataAddToBoundingVolume(void); +extern int UtcDaliMeshDataBoundingBox(void); +extern int UtcDaliMeshDataGetVertexCount(void); +extern int UtcDaliMeshDataGetVertices(void); +extern int UtcDaliMeshDataGetFaceCount(void); +extern int UtcDaliMeshDataGetFaces(void); +extern int UtcDaliMeshDataTextureCoords(void); +extern int UtcDaliMeshDataNormals(void); +extern int UtcDaliMeshDataGetMaterial(void); +extern int UtcDaliMeshDataSetMaterial(void); +extern int UtcDaliMeshDataGetBoneCount(void); +extern int UtcDaliMeshDataGetBones(void); +extern int UtcDaliModelConstructorVoid(void); +extern int UtcDaliModelNew(void); +extern int UtcDaliModelDownCast(void); +extern int UtcDaliModelGetLoadingState01(void); +extern int UtcDaliModelGetLoadingState02(void); +extern int UtcDaliModelGetLoadingState03(void); +extern int UtcDaliModelNumberOfAnimations(void); +extern int UtcDaliModelActorFactory(void); +extern int UtcDaliModelActorFactoryTwoMesh(void); +extern int UtcDaliModelBuildAnimation01(void); +extern int UtcDaliModelBuildAnimation02(void); +extern int UtcDaliModelBuildAnimation03(void); +extern int UtcDaliModelBuildAnimation04(void); +extern int UtcDaliModelBuildAnimation05(void); +extern int UtcDaliModelBuildAnimation06(void); +extern int UtcDaliModelBuildAnimation07(void); +extern int UtcDaliModelBuildAnimation08(void); +extern int UtcDaliMouseWheelEventConstructor(void); +extern int UtcDaliMouseWheelEventIsShiftModifier(void); +extern int UtcDaliMouseWheelEventIsCtrlModifier(void); +extern int UtcDaliMouseWheelEventIsAltModifier(void); +extern int UtcDaliMouseWheelEventIsNotShiftModifier(void); +extern int UtcDaliMouseWheelEventIsNotCtrlModifier(void); +extern int UtcDaliMouseWheelEventIsNotAltModifier(void); +extern int UtcDaliMouseWheelEventANDModifer(void); +extern int UtcDaliMouseWheelEventORModifer(void); +extern int UtcDaliMouseWheelEventSignalling(void); +extern int UtcDaliObjectRegistryGet(void); +extern int UtcDaliObjectRegistrySignalActorCreated(void); +extern int UtcDaliObjectRegistrySignalCameraCreated(void); +extern int UtcDaliObjectRegistrySignalImageActorCreated(void); +extern int UtcDaliObjectRegistrySignalLayerCreated(void); +extern int UtcDaliObjectRegistrySignalLightActorCreated(void); +extern int UtcDaliObjectRegistrySignalMeshActorCreated(void); +extern int UtcDaliObjectRegistrySignalModelCreated(void); +extern int UtcDaliObjectRegistrySignalTextActorCreated(void); +extern int UtcDaliObjectRegistrySignalAnimationCreated(void); +extern int UtcDaliObjectRegistrySignalShaderEffectCreated(void); +extern int UtcDaliRandomRangeMethod(void); +extern int UtcDaliRandomAxisMethod(void); +extern int UtcDaliRandomChanceMethod(void); +extern int UtcDaliRenderTaskSetScreenToFrameBufferMappingActor(void); +extern int UtcDaliShaderEffectFromProperties01(void); +extern int UtcDaliShaderEffectFromProperties02(void); +extern int UtcDaliShaderEffectFromProperties03(void); +extern int UtcDaliShaderEffectPropertyIndices(void); +extern int UtcDaliScriptingGetColorMode(void); +extern int UtcDaliScriptingGetPositionInheritanceMode(void); +extern int UtcDaliScriptingGetDrawMode(void); +extern int UtcDaliScriptingGetAnchorConstant(void); +extern int UtcDaliScriptingNewImageNegative(void); +extern int UtcDaliScriptingNewImage(void); +extern int UtcDaliScriptingNewShaderEffect(void); +extern int UtcDaliScriptingNewActorNegative(void); +extern int UtcDaliScriptingNewActorProperties(void); +extern int UtcDaliScriptingNewActorChildren(void); +extern int UtcDaliScriptingCreatePropertyMapActor(void); +extern int UtcDaliScriptingCreatePropertyMapImage(void); +extern int UtcDaliSplineGetYFromMonotonicX(void); +extern int utcDaliSplineGetKnot01(void); +extern int utcDaliSplineGetKnot02(void); +extern int utcDaliSplineGetKnot03(void); +extern int utcDaliSplineGetInTangent01(void); +extern int utcDaliSplineGetInTangent02(void); +extern int utcDaliSplineGetInTangent03(void); +extern int utcDaliSplineGetOutTangent01(void); +extern int utcDaliSplineGetOutTangent02(void); +extern int utcDaliSplineGetOutTangent03(void); +extern int utcDaliSplineGenerateControlPoints01(void); +extern int utcDaliSplineGenerateControlPoints02(void); +extern int utcDaliSplineGenerateControlPoints03(void); +extern int UtcDaliSplineGetY01(void); +extern int UtcDaliSplineGetY02(void); +extern int UtcDaliSplineGetY02b(void); +extern int UtcDaliSplineGetY03(void); +extern int UtcDaliSplineGetY04(void); +extern int UtcDaliSplineGetY04b(void); +extern int UtcDaliSplineGetPoint01(void); +extern int UtcDaliSplineGetPoint02(void); +extern int UtcDaliSplineGetPoint03(void); +extern int UtcDaliSplineGetPoint04(void); +extern int UtcDaliSplineGetPoint05(void); +extern int UtcDaliSplineGetPoint06(void); +extern int UtcDaliTypeRegistryCreateDaliObjects(void); +extern int UtcDaliTypeRegistryActionViaBaseHandle(void); +extern int UtcDaliTypeRegistryNames(void); +extern int UtcDaliTypeRegistryNameEquivalence(void); +extern int UtcDaliTypeRegistryCustomActor(void); +extern int UtcDaliTypeRegistryCustomSignalFailure(void); +extern int UtcDaliTypeRegistryInitFunctions(void); +extern int UtcDaliTypeRegistryNameInitFunctions(void); +extern int UtcDaliPropertyRegistration(void); +extern int UtcDaliPropertyRegistrationIndexOutOfBounds(void); +extern int UtcDaliPropertyRegistrationFunctions(void); +extern int UtcDaliPropertyRegistrationAddSameIndex(void); +extern int UtcDaliPropertyRegistrationPropertyWritable(void); +extern int UtcDaliPropertyRegistrationPropertyAnimatable(void); +extern int UtcDaliPropertyRegistrationInvalidGetAndSet(void); +extern int UtcDaliLongPressGestureDetectorTypeRegistry(void); +extern int UtcDaliPanGestureDetectorTypeRegistry(void); +extern int UtcDaliPinchGestureDetectorTypeRegistry(void); +extern int UtcDaliTapGestureDetectorTypeRegistry(void); +extern int UtcDaliUtf8SequenceLength(void); +extern int UtcDaliEmptyVectorInt(void); +extern int UtcDaliVectorInt(void); +extern int UtcDaliVectorIntCopy(void); +extern int UtcDaliVectorIntResize(void); +extern int UtcDaliVectorIntErase(void); +extern int UtcDaliVectorDoubleRemove(void); +extern int UtcDaliVectorIntSwap(void); +extern int UtcDaliVectorIterate(void); +extern int UtcDaliVectorPair(void); +extern int UtcDaliVectorAsserts(void); +extern int UtcDaliVectorAcidTest(void); +extern int UtcDaliVectorComplex(void); + +testcase tc_array[] = { + {"UtcDaliConstrainableDownCast", UtcDaliConstrainableDownCast, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliConstrainableDownCastNegative", UtcDaliConstrainableDownCastNegative, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliConstrainableCustomProperty", UtcDaliConstrainableCustomProperty, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliContextVertexAttribStartup", UtcDaliContextVertexAttribStartup, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliContextVertexAttribImageRendering", UtcDaliContextVertexAttribImageRendering, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliContextVertexAttribImageAndModelRendering", UtcDaliContextVertexAttribImageAndModelRendering, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliCustomActorDoAction", UtcDaliCustomActorDoAction, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliGenerateDistanceField", UtcDaliGenerateDistanceField, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyConstructor", UtcDaliDynamicsBodyConstructor, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyGetMass", UtcDaliDynamicsBodyGetMass, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyGetElasticity", UtcDaliDynamicsBodyGetElasticity, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodySetLinearVelocity", UtcDaliDynamicsBodySetLinearVelocity, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodySetAngularVelocity", UtcDaliDynamicsBodySetAngularVelocity, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodySetKinematic", UtcDaliDynamicsBodySetKinematic, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyIsKinematic", UtcDaliDynamicsBodyIsKinematic, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodySetSleepEnabled", UtcDaliDynamicsBodySetSleepEnabled, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyGetSleepEnabled", UtcDaliDynamicsBodyGetSleepEnabled, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyWakeUp", UtcDaliDynamicsBodyWakeUp, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyAddAnchor", UtcDaliDynamicsBodyAddAnchor, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyConserveVolume", UtcDaliDynamicsBodyConserveVolume, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyConserveShape", UtcDaliDynamicsBodyConserveShape, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyConfigNew", UtcDaliDynamicsBodyConfigNew, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyConfigConstructor", UtcDaliDynamicsBodyConfigConstructor, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyConfigType", UtcDaliDynamicsBodyConfigType, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyConfigSetShape01", UtcDaliDynamicsBodyConfigSetShape01, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyConfigSetShape02", UtcDaliDynamicsBodyConfigSetShape02, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyConfigGetShape", UtcDaliDynamicsBodyConfigGetShape, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyConfigMass", UtcDaliDynamicsBodyConfigMass, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyConfigElasticity", UtcDaliDynamicsBodyConfigElasticity, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyConfigFriction", UtcDaliDynamicsBodyConfigFriction, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyConfigLinearDamping", UtcDaliDynamicsBodyConfigLinearDamping, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyConfigAngularDamping", UtcDaliDynamicsBodyConfigAngularDamping, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyConfigLinearSleepVelocity", UtcDaliDynamicsBodyConfigLinearSleepVelocity, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyConfigAngularSleepVelocity", UtcDaliDynamicsBodyConfigAngularSleepVelocity, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyConfigCollisionGroup", UtcDaliDynamicsBodyConfigCollisionGroup, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyConfigCollisionMask", UtcDaliDynamicsBodyConfigCollisionMask, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyConfigAnchorHardness", UtcDaliDynamicsBodyConfigAnchorHardness, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyConfigVolumeConservation", UtcDaliDynamicsBodyConfigVolumeConservation, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsBodyConfigShapeConservation", UtcDaliDynamicsBodyConfigShapeConservation, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsJointConstructor", UtcDaliDynamicsJointConstructor, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsJointLinearLimit", UtcDaliDynamicsJointLinearLimit, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsJointAngularLimit", UtcDaliDynamicsJointAngularLimit, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsJointEnableSpring", UtcDaliDynamicsJointEnableSpring, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsJointSetSpringStiffness", UtcDaliDynamicsJointSetSpringStiffness, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsJointSetSpringCenterPoint", UtcDaliDynamicsJointSetSpringCenterPoint, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsJointEnableMotor", UtcDaliDynamicsJointEnableMotor, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsJointSetMotorVelocity", UtcDaliDynamicsJointSetMotorVelocity, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsJointSetMotorForce", UtcDaliDynamicsJointSetMotorForce, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsJointGetActor", UtcDaliDynamicsJointGetActor, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsShapeConstructor", UtcDaliDynamicsShapeConstructor, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsShapeNewCapsule", UtcDaliDynamicsShapeNewCapsule, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsShapeNewCone", UtcDaliDynamicsShapeNewCone, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsShapeNewCube", UtcDaliDynamicsShapeNewCube, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsShapeNewCylinder", UtcDaliDynamicsShapeNewCylinder, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsShapeNewMesh", UtcDaliDynamicsShapeNewMesh, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsShapeNewSphere", UtcDaliDynamicsShapeNewSphere, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsShapeGetType", UtcDaliDynamicsShapeGetType, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliStageInitializeDynamics", UtcDaliStageInitializeDynamics, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliStageGetDynamicsWorld", UtcDaliStageGetDynamicsWorld, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliStageTerminateDynamics", UtcDaliStageTerminateDynamics, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsWorldConstructor", UtcDaliDynamicsWorldConstructor, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsWorldGravity", UtcDaliDynamicsWorldGravity, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsWorldDebugDrawMode", UtcDaliDynamicsWorldDebugDrawMode, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsWorldRootActor", UtcDaliDynamicsWorldRootActor, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsWorldConfigConstructor", UtcDaliDynamicsWorldConfigConstructor, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsWorldConfigNew", UtcDaliDynamicsWorldConfigNew, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliDynamicsWorldConfigType", UtcDaliDynamicsWorldConfigType, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliEncodedBufferImageNew01", UtcDaliEncodedBufferImageNew01, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliEncodedBufferImageNew02", UtcDaliEncodedBufferImageNew02, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliEncodedBufferImageNew03", UtcDaliEncodedBufferImageNew03, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliHitTestAlgorithmWithFunctor", UtcDaliHitTestAlgorithmWithFunctor, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliHitTestAlgorithmWithFunctorOnRenderTask", UtcDaliHitTestAlgorithmWithFunctorOnRenderTask, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliHitTestAlgorithmOrtho01", UtcDaliHitTestAlgorithmOrtho01, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliHitTestAlgorithmOrtho02", UtcDaliHitTestAlgorithmOrtho02, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliHitTestAlgorithmStencil", UtcDaliHitTestAlgorithmStencil, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliLightActorConstructorVoid", UtcDaliLightActorConstructorVoid, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliLightActorDestructor", UtcDaliLightActorDestructor, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliLightActorNew", UtcDaliLightActorNew, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliLightActorDownCast", UtcDaliLightActorDownCast, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliLightActorDownCast2", UtcDaliLightActorDownCast2, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliLightActorSetGetLight", UtcDaliLightActorSetGetLight, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliLightActorSetGetActive", UtcDaliLightActorSetGetActive, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliLightActorMeshTest", UtcDaliLightActorMeshTest, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliLightActorDefaultProperties", UtcDaliLightActorDefaultProperties, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliLightActorPropertyIndices", UtcDaliLightActorPropertyIndices, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliLocklessBufferWriteRead01", UtcDaliLocklessBufferWriteRead01, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliLocklessBufferMultipleWrites01", UtcDaliLocklessBufferMultipleWrites01, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliLocklessBufferGetSize01", UtcDaliLocklessBufferGetSize01, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorNew02", UtcDaliMeshActorNew02, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorCreateNoMeshData", UtcDaliMeshActorCreateNoMeshData, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorCreateSetData01", UtcDaliMeshActorCreateSetData01, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorCreateSetData02", UtcDaliMeshActorCreateSetData02, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorCreateSetData03", UtcDaliMeshActorCreateSetData03, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorCreateSetData04", UtcDaliMeshActorCreateSetData04, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorDownCast", UtcDaliMeshActorDownCast, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorDownCast2", UtcDaliMeshActorDownCast2, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorSetMaterial01", UtcDaliMeshActorSetMaterial01, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorSetMaterial01b", UtcDaliMeshActorSetMaterial01b, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorSetMaterial02", UtcDaliMeshActorSetMaterial02, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorSetMaterial02b", UtcDaliMeshActorSetMaterial02b, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorSetMaterial03", UtcDaliMeshActorSetMaterial03, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorSetMaterial03b", UtcDaliMeshActorSetMaterial03b, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorGetMaterial01", UtcDaliMeshActorGetMaterial01, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorGetMaterial02", UtcDaliMeshActorGetMaterial02, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorSetLighting01", UtcDaliMeshActorSetLighting01, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorSetLighting02", UtcDaliMeshActorSetLighting02, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorBlend01", UtcDaliMeshActorBlend01, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorBlend02", UtcDaliMeshActorBlend02, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorBlend03", UtcDaliMeshActorBlend03, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorBlend04", UtcDaliMeshActorBlend04, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorBlend05", UtcDaliMeshActorBlend05, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorBlend06", UtcDaliMeshActorBlend06, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorBlend07", UtcDaliMeshActorBlend07, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorBlend08", UtcDaliMeshActorBlend08, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorBlend09", UtcDaliMeshActorBlend09, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorBoneUpdate01", UtcDaliMeshActorBoneUpdate01, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshActorIndices", UtcDaliMeshActorIndices, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshDataNew", UtcDaliMeshDataNew, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshDataSetData", UtcDaliMeshDataSetData, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshDataAddToBoundingVolume", UtcDaliMeshDataAddToBoundingVolume, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshDataBoundingBox", UtcDaliMeshDataBoundingBox, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshDataGetVertexCount", UtcDaliMeshDataGetVertexCount, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshDataGetVertices", UtcDaliMeshDataGetVertices, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshDataGetFaceCount", UtcDaliMeshDataGetFaceCount, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshDataGetFaces", UtcDaliMeshDataGetFaces, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshDataTextureCoords", UtcDaliMeshDataTextureCoords, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshDataNormals", UtcDaliMeshDataNormals, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshDataGetMaterial", UtcDaliMeshDataGetMaterial, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshDataSetMaterial", UtcDaliMeshDataSetMaterial, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshDataGetBoneCount", UtcDaliMeshDataGetBoneCount, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMeshDataGetBones", UtcDaliMeshDataGetBones, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliModelConstructorVoid", UtcDaliModelConstructorVoid, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliModelNew", UtcDaliModelNew, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliModelDownCast", UtcDaliModelDownCast, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliModelGetLoadingState01", UtcDaliModelGetLoadingState01, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliModelGetLoadingState02", UtcDaliModelGetLoadingState02, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliModelGetLoadingState03", UtcDaliModelGetLoadingState03, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliModelNumberOfAnimations", UtcDaliModelNumberOfAnimations, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliModelActorFactory", UtcDaliModelActorFactory, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliModelActorFactoryTwoMesh", UtcDaliModelActorFactoryTwoMesh, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliModelBuildAnimation01", UtcDaliModelBuildAnimation01, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliModelBuildAnimation02", UtcDaliModelBuildAnimation02, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliModelBuildAnimation03", UtcDaliModelBuildAnimation03, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliModelBuildAnimation04", UtcDaliModelBuildAnimation04, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliModelBuildAnimation05", UtcDaliModelBuildAnimation05, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliModelBuildAnimation06", UtcDaliModelBuildAnimation06, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliModelBuildAnimation07", UtcDaliModelBuildAnimation07, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliModelBuildAnimation08", UtcDaliModelBuildAnimation08, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMouseWheelEventConstructor", UtcDaliMouseWheelEventConstructor, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMouseWheelEventIsShiftModifier", UtcDaliMouseWheelEventIsShiftModifier, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMouseWheelEventIsCtrlModifier", UtcDaliMouseWheelEventIsCtrlModifier, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMouseWheelEventIsAltModifier", UtcDaliMouseWheelEventIsAltModifier, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMouseWheelEventIsNotShiftModifier", UtcDaliMouseWheelEventIsNotShiftModifier, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMouseWheelEventIsNotCtrlModifier", UtcDaliMouseWheelEventIsNotCtrlModifier, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMouseWheelEventIsNotAltModifier", UtcDaliMouseWheelEventIsNotAltModifier, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMouseWheelEventANDModifer", UtcDaliMouseWheelEventANDModifer, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMouseWheelEventORModifer", UtcDaliMouseWheelEventORModifer, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliMouseWheelEventSignalling", UtcDaliMouseWheelEventSignalling, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliObjectRegistryGet", UtcDaliObjectRegistryGet, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliObjectRegistrySignalActorCreated", UtcDaliObjectRegistrySignalActorCreated, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliObjectRegistrySignalCameraCreated", UtcDaliObjectRegistrySignalCameraCreated, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliObjectRegistrySignalImageActorCreated", UtcDaliObjectRegistrySignalImageActorCreated, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliObjectRegistrySignalLayerCreated", UtcDaliObjectRegistrySignalLayerCreated, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliObjectRegistrySignalLightActorCreated", UtcDaliObjectRegistrySignalLightActorCreated, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliObjectRegistrySignalMeshActorCreated", UtcDaliObjectRegistrySignalMeshActorCreated, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliObjectRegistrySignalModelCreated", UtcDaliObjectRegistrySignalModelCreated, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliObjectRegistrySignalTextActorCreated", UtcDaliObjectRegistrySignalTextActorCreated, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliObjectRegistrySignalAnimationCreated", UtcDaliObjectRegistrySignalAnimationCreated, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliObjectRegistrySignalShaderEffectCreated", UtcDaliObjectRegistrySignalShaderEffectCreated, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliRandomRangeMethod", UtcDaliRandomRangeMethod, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliRandomAxisMethod", UtcDaliRandomAxisMethod, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliRandomChanceMethod", UtcDaliRandomChanceMethod, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliRenderTaskSetScreenToFrameBufferMappingActor", UtcDaliRenderTaskSetScreenToFrameBufferMappingActor, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliShaderEffectFromProperties01", UtcDaliShaderEffectFromProperties01, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliShaderEffectFromProperties02", UtcDaliShaderEffectFromProperties02, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliShaderEffectFromProperties03", UtcDaliShaderEffectFromProperties03, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliShaderEffectPropertyIndices", UtcDaliShaderEffectPropertyIndices, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliScriptingGetColorMode", UtcDaliScriptingGetColorMode, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliScriptingGetPositionInheritanceMode", UtcDaliScriptingGetPositionInheritanceMode, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliScriptingGetDrawMode", UtcDaliScriptingGetDrawMode, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliScriptingGetAnchorConstant", UtcDaliScriptingGetAnchorConstant, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliScriptingNewImageNegative", UtcDaliScriptingNewImageNegative, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliScriptingNewImage", UtcDaliScriptingNewImage, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliScriptingNewShaderEffect", UtcDaliScriptingNewShaderEffect, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliScriptingNewActorNegative", UtcDaliScriptingNewActorNegative, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliScriptingNewActorProperties", UtcDaliScriptingNewActorProperties, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliScriptingNewActorChildren", UtcDaliScriptingNewActorChildren, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliScriptingCreatePropertyMapActor", UtcDaliScriptingCreatePropertyMapActor, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliScriptingCreatePropertyMapImage", UtcDaliScriptingCreatePropertyMapImage, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliSplineGetYFromMonotonicX", UtcDaliSplineGetYFromMonotonicX, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"utcDaliSplineGetKnot01", utcDaliSplineGetKnot01, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"utcDaliSplineGetKnot02", utcDaliSplineGetKnot02, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"utcDaliSplineGetKnot03", utcDaliSplineGetKnot03, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"utcDaliSplineGetInTangent01", utcDaliSplineGetInTangent01, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"utcDaliSplineGetInTangent02", utcDaliSplineGetInTangent02, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"utcDaliSplineGetInTangent03", utcDaliSplineGetInTangent03, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"utcDaliSplineGetOutTangent01", utcDaliSplineGetOutTangent01, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"utcDaliSplineGetOutTangent02", utcDaliSplineGetOutTangent02, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"utcDaliSplineGetOutTangent03", utcDaliSplineGetOutTangent03, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"utcDaliSplineGenerateControlPoints01", utcDaliSplineGenerateControlPoints01, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"utcDaliSplineGenerateControlPoints02", utcDaliSplineGenerateControlPoints02, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"utcDaliSplineGenerateControlPoints03", utcDaliSplineGenerateControlPoints03, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliSplineGetY01", UtcDaliSplineGetY01, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliSplineGetY02", UtcDaliSplineGetY02, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliSplineGetY02b", UtcDaliSplineGetY02b, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliSplineGetY03", UtcDaliSplineGetY03, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliSplineGetY04", UtcDaliSplineGetY04, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliSplineGetY04b", UtcDaliSplineGetY04b, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliSplineGetPoint01", UtcDaliSplineGetPoint01, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliSplineGetPoint02", UtcDaliSplineGetPoint02, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliSplineGetPoint03", UtcDaliSplineGetPoint03, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliSplineGetPoint04", UtcDaliSplineGetPoint04, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliSplineGetPoint05", UtcDaliSplineGetPoint05, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliSplineGetPoint06", UtcDaliSplineGetPoint06, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliTypeRegistryCreateDaliObjects", UtcDaliTypeRegistryCreateDaliObjects, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliTypeRegistryActionViaBaseHandle", UtcDaliTypeRegistryActionViaBaseHandle, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliTypeRegistryNames", UtcDaliTypeRegistryNames, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliTypeRegistryNameEquivalence", UtcDaliTypeRegistryNameEquivalence, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliTypeRegistryCustomActor", UtcDaliTypeRegistryCustomActor, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliTypeRegistryCustomSignalFailure", UtcDaliTypeRegistryCustomSignalFailure, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliTypeRegistryInitFunctions", UtcDaliTypeRegistryInitFunctions, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliTypeRegistryNameInitFunctions", UtcDaliTypeRegistryNameInitFunctions, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliPropertyRegistration", UtcDaliPropertyRegistration, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliPropertyRegistrationIndexOutOfBounds", UtcDaliPropertyRegistrationIndexOutOfBounds, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliPropertyRegistrationFunctions", UtcDaliPropertyRegistrationFunctions, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliPropertyRegistrationAddSameIndex", UtcDaliPropertyRegistrationAddSameIndex, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliPropertyRegistrationPropertyWritable", UtcDaliPropertyRegistrationPropertyWritable, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliPropertyRegistrationPropertyAnimatable", UtcDaliPropertyRegistrationPropertyAnimatable, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliPropertyRegistrationInvalidGetAndSet", UtcDaliPropertyRegistrationInvalidGetAndSet, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliLongPressGestureDetectorTypeRegistry", UtcDaliLongPressGestureDetectorTypeRegistry, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliPanGestureDetectorTypeRegistry", UtcDaliPanGestureDetectorTypeRegistry, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliPinchGestureDetectorTypeRegistry", UtcDaliPinchGestureDetectorTypeRegistry, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliTapGestureDetectorTypeRegistry", UtcDaliTapGestureDetectorTypeRegistry, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliUtf8SequenceLength", UtcDaliUtf8SequenceLength, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliEmptyVectorInt", UtcDaliEmptyVectorInt, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliVectorInt", UtcDaliVectorInt, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliVectorIntCopy", UtcDaliVectorIntCopy, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliVectorIntResize", UtcDaliVectorIntResize, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliVectorIntErase", UtcDaliVectorIntErase, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliVectorDoubleRemove", UtcDaliVectorDoubleRemove, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliVectorIntSwap", UtcDaliVectorIntSwap, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliVectorIterate", UtcDaliVectorIterate, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliVectorPair", UtcDaliVectorPair, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliVectorAsserts", UtcDaliVectorAsserts, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliVectorAcidTest", UtcDaliVectorAcidTest, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {"UtcDaliVectorComplex", UtcDaliVectorComplex, utc_dali_unmanaged_startup, utc_dali_unmanaged_cleanup}, + {NULL, NULL} +}; + +#endif // __TCT_DALI_UNMANAGED_CORE_H__ diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-Constrainable.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-Constrainable.cpp new file mode 100644 index 0000000..6b5436f --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-Constrainable.cpp @@ -0,0 +1,88 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; + +void utc_dali_unmanaged_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_unmanaged_cleanup(void) +{ + test_return_value = TET_PASS; +} + +int UtcDaliConstrainableDownCast(void) +{ + TestApplication application; + + Handle handle = Constrainable::New(); + + Constrainable customHandle1 = Constrainable::DownCast( handle ); + DALI_TEST_CHECK( customHandle1 ); + + Constrainable customHandle2 = DownCast< Constrainable >( handle ); + DALI_TEST_CHECK( customHandle2 ); + END_TEST; +} + +int UtcDaliConstrainableDownCastNegative(void) +{ + TestApplication application; + + Image image = Image::New( "temp" ); + Constrainable customHandle1 = Constrainable::DownCast( image ); + DALI_TEST_CHECK( ! customHandle1 ); + + Constrainable empty; + Constrainable customHandle2 = Constrainable::DownCast( empty ); + DALI_TEST_CHECK( ! customHandle2 ); + END_TEST; +} + +int UtcDaliConstrainableCustomProperty(void) +{ + TestApplication application; + + Constrainable handle = Constrainable::New(); + + float startValue(1.0f); + Property::Index index = handle.RegisterProperty( "test-property", startValue ); + DALI_TEST_CHECK( handle.GetProperty(index) == startValue ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( handle.GetProperty(index) == startValue ); + application.Render(0); + DALI_TEST_CHECK( handle.GetProperty(index) == startValue ); + + handle.SetProperty( index, 5.0f ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( handle.GetProperty(index) == 5.0f ); + application.Render(0); + DALI_TEST_CHECK( handle.GetProperty(index) == 5.0f ); + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-Context.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-Context.cpp new file mode 100644 index 0000000..0395c4c --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-Context.cpp @@ -0,0 +1,240 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; + +#include "mesh-builder.h" + + +namespace +{ +// Size of the VertexAttributeArray enables +// GLES specification states that there's minimum of +const unsigned int TEST_MAX_ATTRIBUTE_CACHE_SIZE = 8; + +enum TestAttribType +{ + ATTRIB_UNKNOWN = -1, + ATTRIB_POSITION, + ATTRIB_NORMAL, + ATTRIB_TEXCOORD, + ATTRIB_COLOR, + ATTRIB_BONE_WEIGHTS, + ATTRIB_BONE_INDICES, + ATTRIB_TYPE_LAST +}; + +// Create bitmap image +static BitmapImage CreateBitmapImage() +{ + BitmapImage image = BitmapImage::New(4,4,Pixel::RGBA8888); + + return image; +} + +static MeshActor CreateMeshActor() +{ + MeshData meshData; + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + BoneContainer bones; + ConstructVertices(vertices, 60); + ConstructFaces(vertices, faces); + Material customMaterial = ConstructMaterial(); + meshData.SetData(vertices, faces, bones, customMaterial); + meshData.SetHasNormals(true); + meshData.SetHasTextureCoords(true); + + Mesh mesh = Mesh::New(meshData); + MeshActor actor = MeshActor::New(mesh); + actor.SetName("Test MeshActor"); + + return actor; +} + +static LightActor CreateLight() +{ + Light light = Light::New("Light"); + light.SetType( POINT ); + light.SetAmbientColor( Vector3( 0.22f, 0.33f, 0.44f ) ); + light.SetDiffuseColor( Vector3( 0.55f, 0.66f, 0.77f) ); + light.SetSpecularColor( Vector3( 0.88f, 0.99f, 0.11f) ); + LightActor lightActor = LightActor::New(); + lightActor.SetParentOrigin( ParentOrigin::CENTER ); + lightActor.SetPosition( 0.f, 0.f, 100.0f ); + lightActor.SetLight( light ); + lightActor.SetName( light.GetName() ); + + return lightActor; +} + +static ImageActor CreateImageActor() +{ + BitmapImage image = CreateBitmapImage(); + ImageActor actor = ImageActor::New( image ); + actor.SetSize( 100.0f, 100.0f ); + actor.SetName("Test ImageActor"); + return actor; +} + +} // anonymous namespace + + +// Positive test case for a method +int UtcDaliContextVertexAttribStartup(void) +{ + tet_infoline("Testing vertex attrib initial state in context"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + // context class should initially set the vertex attrib locations to disable + // Make sure it has been modified + DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged()); + + // check the locations + for (unsigned int i = 0; i < TEST_MAX_ATTRIBUTE_CACHE_SIZE; i++) + { + DALI_TEST_CHECK( application.GetGlAbstraction().GetVertexAttribArrayState(i) == false); + } + + tet_result(TET_PASS); + END_TEST; +} + +// Tests to make the attribs only get set once when continually rendering an image actor +int UtcDaliContextVertexAttribImageRendering(void) +{ + tet_infoline("Testing vertex attrib rendering state in context with images"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + // the vertex attribs get modified on startup to set them to disabled + // clear the flag to say they've changed + application.GetGlAbstraction().ClearVertexAttribArrayChanged(); + + + // create a test image actor + ImageActor imageActor(CreateImageActor()); + Stage::GetCurrent().Add(imageActor); + + + application.SendNotification(); + application.Render(); + application.Render(); + + // check to make sure the state has changed (the image renderer will enable some + // locations). + DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged()); + + // Now check to make sure the state is cached, and isn't being set each frame. + application.GetGlAbstraction().ClearVertexAttribArrayChanged(); + + application.Render(); + application.Render(); + application.Render(); + + // if it has changed then the caching has failed + DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged() == false); + + + tet_result(TET_PASS); + END_TEST; +} + +// test to make sure the attribs change when rendering both image and mode actors +int UtcDaliContextVertexAttribImageAndModelRendering(void) +{ + tet_infoline("Testing vertex attrib rendering state in context with images and models"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + // the vertex attribs get modified on startup to set them to disabled + // clear the flag to say they've changed + application.GetGlAbstraction().ClearVertexAttribArrayChanged(); + + // create a test light, image and mesh actor. (meshes won't render without light) + + LightActor lightActor(CreateLight()); + Stage::GetCurrent().Add(lightActor); + lightActor.SetActive(true); + + MeshActor meshActor(CreateMeshActor()); + Stage::GetCurrent().Add(meshActor); + + ImageActor imageActor(CreateImageActor()); + Stage::GetCurrent().Add(imageActor); + + + application.SendNotification(); + application.Render(); + application.Render(); + + // check to make sure the state changes during the rendering of a frame + DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged()); + + // Now check to make sure the state is changing each frame. + application.GetGlAbstraction().ClearVertexAttribArrayChanged(); + + application.Render(); + application.Render(); + application.Render(); + + // make sure the state has changed + DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged()); + + // depending on the order of drawing, one of the attrib locations should be disabled + // Image uses locations 0 & 2 (position, texture) + // Model uses locations 0 & 1 (position, normals) -no textures + // so either location 1 or location 2 should be disabled after drawing. + + // see if mesh was last to draw + if (application.GetGlAbstraction().GetVertexAttribArrayState(ATTRIB_NORMAL)) + { + // texture should be disabled + DALI_TEST_CHECK( application.GetGlAbstraction().GetVertexAttribArrayState(ATTRIB_TEXCOORD) == false) + } + else + { + // image was to draw so, normals should be disabled + DALI_TEST_CHECK( application.GetGlAbstraction().GetVertexAttribArrayState(ATTRIB_NORMAL) == false) + } + + tet_result(TET_PASS); + + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-CustomActor.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-CustomActor.cpp new file mode 100644 index 0000000..796722c --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-CustomActor.cpp @@ -0,0 +1,293 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 +#include + +#include + +using namespace Dali; + +namespace +{ +std::vector< std::string > MasterCallStack; +} + +// TypeRegistry needs custom actor Implementations to have the same name (namespaces are ignored so we use one here) +namespace Impl +{ + +struct TestCustomActor : public CustomActorImpl +{ + /** + * Constructor + */ + TestCustomActor() + : CustomActorImpl( true ), // requires touch + mDaliProperty( Property::INVALID_INDEX ), + mSizeSet( Vector3::ZERO ), + mTargetSize( Vector3::ZERO ) + { + SetRequiresMouseWheelEvents(true); + } + + /** + * Destructor + */ + virtual ~TestCustomActor() + { + } + + void Initialize( const char* name = NULL ) + { + mDaliProperty = Self().RegisterProperty( "Dali", std::string("no"), Property::READ_WRITE); + + OnInitialize( name ); + } + + virtual void OnInitialize( const char* name ) {} + + /** + * Resets the call stack + */ + void ResetCallStack() + { + mSizeSet = Vector3(); + mTargetSize = Vector3(); + mMethodsCalled.clear(); + } + + void AddToCallStacks( const char* method ) + { + mMethodsCalled.push_back( method ); + + // Combine Actor name with method string + std::string nameAndMethod( Self().GetName() ); + if ( 0 == nameAndMethod.size() ) + { + nameAndMethod = "Unknown: "; + } + else + { + nameAndMethod += ": "; + } + nameAndMethod += method; + + MasterCallStack.push_back( nameAndMethod ); + } + + // From CustomActorImpl + virtual void OnStageConnection() + { + AddToCallStacks("OnStageConnection"); + } + virtual void OnStageDisconnection() + { + AddToCallStacks("OnStageDisconnection"); + } + virtual void OnChildAdd(Actor& child) + { + AddToCallStacks("OnChildAdd"); + } + virtual void OnChildRemove(Actor& child) + { + AddToCallStacks("OnChildRemove"); + } + virtual void OnPropertySet( Property::Index index, Property::Value propertyValue ) + { + AddToCallStacks("OnPropertySet"); + } + virtual void OnSizeSet(const Vector3& targetSize) + { + mSizeSet = targetSize; + AddToCallStacks("OnSizeSet"); + } + virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize) + { + mTargetSize = targetSize; + AddToCallStacks("OnSizeAnimation"); + } + virtual bool OnTouchEvent(const TouchEvent& event) + { + AddToCallStacks("OnTouchEvent"); + return true; + } + virtual bool OnMouseWheelEvent(const MouseWheelEvent& event) + { + AddToCallStacks("OnMouseWheelEvent"); + return true; + } + virtual bool OnKeyEvent(const KeyEvent& event) + { + AddToCallStacks("OnKeyEvent"); + return true; + } + virtual void OnKeyInputFocusGained() + { + AddToCallStacks("OnKeyInputFocusGained"); + } + virtual void OnKeyInputFocusLost() + { + AddToCallStacks("OnKeyInputFocusLost"); + } + virtual Actor GetChildByAlias(const std::string& actorAlias) + { + AddToCallStacks("GetChildByAlias"); + + if ("found" == actorAlias) + { + return Actor::New(); + } + else + { + return Actor(); + } + } + + void SetDaliProperty(std::string s) + { + Self().SetProperty(mDaliProperty, s) ; + } + + Property::Index mDaliProperty; + std::vector< std::string > mMethodsCalled; + Vector3 mSizeSet; + Vector3 mTargetSize; +}; +} // Namespace Impl + + +namespace +{ +/** + * Test custom actor handle + */ +class TestCustomActor : public CustomActor +{ +public: + + static TestCustomActor New() + { + Impl::TestCustomActor* impl = new Impl::TestCustomActor; + TestCustomActor custom( *impl ); // takes ownership + + impl->Initialize(); + + return custom; + } + + virtual ~TestCustomActor() + { + } + + Impl::TestCustomActor& GetImpl() + { + return static_cast(GetImplementation()); + } + + std::vector< std::string >& GetMethodsCalled() + { + return GetImpl().mMethodsCalled; + } + + void ResetCallStack() + { + GetImpl().ResetCallStack(); + } + + void SetDaliProperty(std::string s) + { + GetImpl().SetDaliProperty(s); + } + + Vector3 GetSize() + { + return GetImpl().mSizeSet; + } + + Vector3 GetTargetSize() + { + return GetImpl().mTargetSize; + } + +private: + + TestCustomActor( Impl::TestCustomActor& impl ) : CustomActor( impl ) + { + } +}; + + + +using namespace Dali; + +BaseHandle CreateActor() +{ + return TestCustomActor::New(); +} + +Dali::TypeRegistration mType( typeid(TestCustomActor), typeid(Dali::CustomActor), CreateActor ); + +} + + +int UtcDaliCustomActorDoAction(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CustomActor::DoAction()"); + + TestCustomActor custom = TestCustomActor::New(); + + BaseHandle customActorObject = custom; + + DALI_TEST_CHECK(customActorObject); + + std::vector attributes; + + // Check that an invalid command is not performed + DALI_TEST_CHECK(customActorObject.DoAction("invalidCommand", attributes) == false); + + // Check that the custom actor is visible + custom.SetVisible(true); + DALI_TEST_CHECK(custom.IsVisible() == true); + + // Check the custom actor performed an action to hide itself + DALI_TEST_CHECK(customActorObject.DoAction("hide", attributes) == true); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + // Check that the custom actor is now invisible + DALI_TEST_CHECK(custom.IsVisible() == false); + + // Check the custom actor performed an action to show itself + DALI_TEST_CHECK(customActorObject.DoAction("show", attributes) == true); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + // Check that the custom actor is now visible + DALI_TEST_CHECK(custom.IsVisible() == true); + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-DistanceField.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-DistanceField.cpp new file mode 100644 index 0000000..8ff01ce --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-DistanceField.cpp @@ -0,0 +1,67 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 +#include + +using std::max; +using namespace Dali; + +namespace +{ + +static const float ROTATION_EPSILON = 0.0001f; + +static unsigned char sourceImage[] = +{ + 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF, + 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF, + 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF, + 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF +}; + +} // anonymous namespace + + + +int UtcDaliGenerateDistanceField(void) +{ + unsigned char distanceField[4*4]; + + GenerateDistanceFieldMap(sourceImage, Size(8.0f, 8.0f), distanceField, Size(4.0f, 4.0f), 0, Size(4.0f, 4.0f)); + + if(distanceField[0] <= distanceField[5] && + distanceField[5] <= distanceField[10] && + distanceField[10] <= distanceField[15]) + { + tet_result(TET_PASS); + } + else + { + tet_result(TET_FAIL); + } + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-DynamicsBody.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-DynamicsBody.cpp new file mode 100644 index 0000000..70bc5b7 --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-DynamicsBody.cpp @@ -0,0 +1,553 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + + +int UtcDaliDynamicsBodyConstructor(void) +{ + tet_infoline("UtcDaliDynamicsBodyConstructor - DynamicsBody::DynamicsBody()"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + // Default constructor - create an uninitialized handle + DynamicsBody body; + DALI_TEST_CHECK( !body ); + + // create world and actor + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New()); + Actor actor(Actor::New()); + + // enable dynamics on the actor to create the Dynamicsbody + actor.EnableDynamics(bodyConfig); + + // initialize handle + body = actor.GetDynamicsBody(); + + DALI_TEST_CHECK( body ); + END_TEST; +} + +int UtcDaliDynamicsBodyGetMass(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + const float testMass = 1.23f; + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New()); + bodyConfig.SetMass(testMass); + Actor actor(Actor::New()); + + // enable dynamics on the actor to create the Dynamicsbody + actor.EnableDynamics(bodyConfig); + + tet_infoline("UtcDaliDynamicsBodyGetMass - DynamicsBody::GetMass"); + DALI_TEST_EQUALS( testMass, actor.GetDynamicsBody().GetMass(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliDynamicsBodyGetElasticity(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + const float testElasticity = 1.23f; + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New()); + bodyConfig.SetElasticity(testElasticity); + Actor actor(Actor::New()); + + // enable dynamics on the actor to create the Dynamicsbody + actor.EnableDynamics(bodyConfig); + + tet_infoline("UtcDaliDynamicsBodyGetMass - DynamicsBody::GetElasticity"); + DALI_TEST_EQUALS( testElasticity, actor.GetDynamicsBody().GetElasticity(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliDynamicsBodySetLinearVelocity(void) +{ + tet_infoline("UtcDaliDynamicsBodySetLinearVelocity - DynamicsBody::SetLinearVelocity"); + + TestApplication application; + TraceCallStack& trace( application.GetPlatform().GetTrace() ); + trace.Enable( true ); + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New()); + Actor actor(Actor::New()); + + // enable dynamics on the actor to create the Dynamicsbody + actor.EnableDynamics(bodyConfig); + + DynamicsBody body(actor.GetDynamicsBody()); + body.SetLinearVelocity(Vector3::ONE); + + DALI_TEST_CHECK( ! trace.FindMethod( "DynamicsBody::SetLinearVelocity" ) ); + + // update + application.SendNotification(); + application.Render(); + application.Render(); + + DALI_TEST_CHECK( trace.FindMethod( "DynamicsBody::SetLinearVelocity" ) ); + END_TEST; +} + +int UtcDaliDynamicsBodySetAngularVelocity(void) +{ + tet_infoline("UtcDaliDynamicsBodySetAngularVelocity - DynamicsBody::SetAngularVelocity"); + + TestApplication application; + TraceCallStack& trace( application.GetPlatform().GetTrace() ); + trace.Enable( true ); + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New()); + Actor actor(Actor::New()); + + // enable dynamics on the actor to create the Dynamicsbody + actor.EnableDynamics(bodyConfig); + + DynamicsBody body(actor.GetDynamicsBody()); + body.SetAngularVelocity(Vector3::ONE); + + DALI_TEST_CHECK( ! trace.FindMethod( "DynamicsBody::SetAngularVelocity" ) ); + + // update + application.SendNotification(); + application.Render(); + application.Render(); + + DALI_TEST_CHECK( trace.FindMethod( "DynamicsBody::SetAngularVelocity" ) ); + END_TEST; +} + +int UtcDaliDynamicsBodySetKinematic(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + const float testMass = 1.0f; + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New()); + bodyConfig.SetMass(testMass); + Actor actor(Actor::New()); + + // enable dynamics on the actor to create the Dynamicsbody + actor.EnableDynamics(bodyConfig); + + DynamicsBody body(actor.GetDynamicsBody()); + + DALI_TEST_EQUALS( testMass, body.GetMass(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + + tet_infoline("UtcDaliDynamicsBodySetKinematic - DynamicsBody::SetKinematic(true)"); + body.SetKinematic(true); + + DALI_TEST_CHECK( body.IsKinematic() ); + DALI_TEST_EQUALS( 0.0f, body.GetMass(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + + tet_infoline("UtcDaliDynamicsBodySetKinematic - DynamicsBody::SetKinematic(false)"); + body.SetKinematic(false); + DALI_TEST_CHECK( !body.IsKinematic() ); + DALI_TEST_EQUALS( testMass, body.GetMass(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliDynamicsBodyIsKinematic(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + const float testMass = 1.0f; + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New()); + bodyConfig.SetMass(testMass); + Actor actor(Actor::New()); + + // enable dynamics on the actor to create the Dynamicsbody + actor.EnableDynamics(bodyConfig); + + DynamicsBody body(actor.GetDynamicsBody()); + + DALI_TEST_EQUALS( testMass, body.GetMass(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + + tet_infoline("UtcDaliDynamicsBodySetKinematic - DynamicsBody::IsSetKinematic"); + body.SetKinematic(true); + + DALI_TEST_CHECK( body.IsKinematic() ); + body.SetKinematic(false); + DALI_TEST_CHECK( !body.IsKinematic() ); + END_TEST; +} + +int UtcDaliDynamicsBodySetSleepEnabled(void) +{ + tet_infoline("UtcDaliDynamicsBodySetSleepEnabled"); + + TestApplication application; + TraceCallStack& trace( application.GetPlatform().GetTrace() ); + trace.Enable( true ); + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New()); + Actor actor(Actor::New()); + + // enable dynamics on the actor to create the Dynamicsbody + actor.EnableDynamics(bodyConfig); + + DynamicsBody body(actor.GetDynamicsBody()); + + // SleepEnabled true by default + DALI_TEST_CHECK( body.GetSleepEnabled() ); + body.SetSleepEnabled(false); + + DALI_TEST_CHECK( ! trace.FindMethod( "DynamicsBody::SetSleepEnabled" ) ); + + // update + application.SendNotification(); + application.Render(); + application.Render(); + + DALI_TEST_CHECK( trace.FindMethod( "DynamicsBody::SetSleepEnabled" ) ); + + DALI_TEST_CHECK( ! body.GetSleepEnabled() ); + END_TEST; +} + +int UtcDaliDynamicsBodyGetSleepEnabled(void) +{ + tet_infoline("UtcDaliDynamicsBodyGetSleepEnabled"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New()); + Actor actor(Actor::New()); + + // enable dynamics on the actor to create the Dynamicsbody + actor.EnableDynamics(bodyConfig); + + DynamicsBody body(actor.GetDynamicsBody()); + + // SleepEnabled true by default + DALI_TEST_CHECK( body.GetSleepEnabled() ); + body.SetSleepEnabled(false); + DALI_TEST_CHECK( !body.GetSleepEnabled() ); + END_TEST; +} + +int UtcDaliDynamicsBodyWakeUp(void) +{ + tet_infoline("UtcDaliDynamicsBodyWakeUp"); + + TestApplication application; + TraceCallStack& trace( application.GetPlatform().GetTrace() ); + trace.Enable( true ); + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New()); + Actor actor(Actor::New()); + + // enable dynamics on the actor to create the Dynamicsbody + actor.EnableDynamics(bodyConfig); + + DynamicsBody body(actor.GetDynamicsBody()); + + body.WakeUp(); + + DALI_TEST_CHECK( ! trace.FindMethod( "DynamicsBody::WakeUp" ) ); + + // update + application.SendNotification(); + application.Render(); + application.Render(); + + DALI_TEST_CHECK( trace.FindMethod( "DynamicsBody::WakeUp" ) ); + END_TEST; +} + +int UtcDaliDynamicsBodyAddAnchor(void) +{ + tet_infoline("UtcDaliDynamicsBodyAddAnchor - DynamicsBody::AddAnchor()"); + + TestApplication application; + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + worldConfig.SetType(DynamicsWorldConfig::SOFT); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + Actor rootActor(Actor::New()); + world.SetRootActor(rootActor); + Stage::GetCurrent().Add(rootActor); + + DynamicsBodyConfig softConfig( DynamicsBodyConfig::New() ); + softConfig.SetType(DynamicsBodyConfig::SOFT); + Mesh mesh(Mesh::NewPlane(10.0f, 10.0f, 10, 10)); + DynamicsShape meshShape(DynamicsShape::NewMesh(mesh)); + softConfig.SetShape( meshShape ); + softConfig.SetMass(1.0f); + MeshActor softActor(MeshActor::New(mesh)); + + rootActor.Add(softActor); + softActor.EnableDynamics(softConfig); + DynamicsBody softBody(softActor.GetDynamicsBody()); + + DynamicsBodyConfig anchorConfig(DynamicsBodyConfig::New()); + anchorConfig.SetMass(0.0f); + Actor anchor(Actor::New()); + rootActor.Add(anchor); + anchor.EnableDynamics(anchorConfig); + DynamicsBody anchorBody(anchor.GetDynamicsBody()); + anchorBody.SetKinematic(true); + try + { + softBody.AddAnchor(0, anchorBody, false); + + DALI_TEST_CHECK(true) + } + catch(Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_CHECK( false ); + } + + rootActor.Remove(softActor); + rootActor.Remove(anchor); + Stage::GetCurrent().Remove(rootActor); + softActor.DisableDynamics(); + anchor.DisableDynamics(); + END_TEST; +} + +int UtcDaliDynamicsBodyConserveVolume(void) +{ + tet_infoline("UtcDaliDynamicsBodyConserveVolume"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New()); + Actor actor(Actor::New()); + + // enable dynamics on the actor to create the Dynamicsbody + actor.EnableDynamics(bodyConfig); + + DynamicsBody body(actor.GetDynamicsBody()); + + body.ConserveVolume(false); + DALI_TEST_CHECK( true ); + END_TEST; +} + +int UtcDaliDynamicsBodyConserveShape(void) +{ + tet_infoline("UtcDaliDynamicsBodyConserveShape"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New()); + Actor actor(Actor::New()); + + // enable dynamics on the actor to create the Dynamicsbody + actor.EnableDynamics(bodyConfig); + + DynamicsBody body(actor.GetDynamicsBody()); + + body.ConserveShape(false); + DALI_TEST_CHECK( true ); + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-DynamicsBodyConfig.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-DynamicsBodyConfig.cpp new file mode 100644 index 0000000..0ef41ec --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-DynamicsBodyConfig.cpp @@ -0,0 +1,606 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; + + +int UtcDaliDynamicsBodyConfigNew(void) +{ + tet_infoline("UtcDaliDynamicsBodyConfigNew - DynamicsBodyConfig::New()"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig config(DynamicsBodyConfig::New()); + + DALI_TEST_CHECK( config ); + END_TEST; +} + +int UtcDaliDynamicsBodyConfigConstructor(void) +{ + tet_infoline("UtcDaliDynamicsBodyConfigConstructor - DynamicsBodyConfig::DynamicsBodyConfig()"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + // Default constructor - create an uninitialized handle + DynamicsBodyConfig config; + + DALI_TEST_CHECK( !config ); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + // initialize handle + config = DynamicsBodyConfig::New(); + + DALI_TEST_CHECK( config ); + END_TEST; +} + +int UtcDaliDynamicsBodyConfigType(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig config(DynamicsBodyConfig::New()); + + tet_infoline("UtcDaliDynamicsBodyConfigType - DynamicsBodyConfig::GetType"); + DALI_TEST_CHECK( DynamicsBodyConfig::RIGID == config.GetType() ); + + tet_infoline("UtcDaliDynamicsBodyConfigType - DynamicsBodyConfig::SetType(const BodyType)"); + config.SetType( DynamicsBodyConfig::SOFT ); + DALI_TEST_CHECK( DynamicsBodyConfig::SOFT == config.GetType() ); + END_TEST; +} + +int UtcDaliDynamicsBodyConfigSetShape01(void) +{ + tet_infoline("UtcDaliDynamicsBodyConfigSetShape01 - DynamicsBodyConfig::SetShape(const DynamicsShape::ShapeType,const Vector3&)"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig config(DynamicsBodyConfig::New()); + + DALI_TEST_CHECK( DynamicsShape::CUBE == config.GetShape().GetType() ); + + const float radius(1.5f); + config.SetShape(DynamicsShape::SPHERE, Vector3(radius, 0.0f, 0.0f)); + + DALI_TEST_CHECK( DynamicsShape::SPHERE == config.GetShape().GetType() ); + END_TEST; +} + +int UtcDaliDynamicsBodyConfigSetShape02(void) +{ + tet_infoline("UtcDaliDynamicsBodyConfigSetShape02 - DynamicsBodyConfig::SetShape(DynamicsShape)"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig config(DynamicsBodyConfig::New()); + + DALI_TEST_CHECK( DynamicsShape::CUBE == config.GetShape().GetType() ); + + const float radius(1.5f); + DynamicsShape shape(DynamicsShape::NewSphere(radius)); + config.SetShape(shape); + + DALI_TEST_CHECK( DynamicsShape::SPHERE == config.GetShape().GetType() ); + END_TEST; +} + +int UtcDaliDynamicsBodyConfigGetShape(void) +{ + tet_infoline("UtcDaliDynamicsBodyConfigGetShape - DynamicsBodyConfig::GetShape"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig config(DynamicsBodyConfig::New()); + + DALI_TEST_CHECK( DynamicsShape::CUBE == config.GetShape().GetType() ); + END_TEST; +} + +int UtcDaliDynamicsBodyConfigMass(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + const float testMass = 1.23f; + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig config(DynamicsBodyConfig::New()); + config.SetMass(testMass); + + tet_infoline("UtcDaliDynamicsBodyConfigMass - DynamicsBodyConfig::GetMass"); + DALI_TEST_EQUALS( testMass, config.GetMass(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + + tet_infoline("UtcDaliDynamicsBodyConfigMass - DynamicsBodyConfig::SetMass"); + const float mass = config.GetMass() + 0.1f; + config.SetMass(mass); + DALI_TEST_EQUALS( mass, config.GetMass(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliDynamicsBodyConfigElasticity(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + const float testElasticity = 0.87f; + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig config(DynamicsBodyConfig::New()); + config.SetElasticity(testElasticity); + + tet_infoline("UtcDaliDynamicsBodyConfigElasticity- DynamicsBodyConfig::GetElasticity"); + DALI_TEST_EQUALS( testElasticity, config.GetElasticity(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + + tet_infoline("UtcDaliDynamicsBodyConfigElasticity - DynamicsBodyConfig::SetElasticity"); + const float elasticity = config.GetElasticity() + 0.1f; + config.SetElasticity(elasticity); + DALI_TEST_EQUALS( elasticity, config.GetElasticity(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliDynamicsBodyConfigFriction(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + const float testFriction= 0.87f; + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig config(DynamicsBodyConfig::New()); + config.SetFriction(testFriction); + + tet_infoline("UtcDaliDynamicsBodyConfigFriction - DynamicsBodyConfig::GetFriction"); + DALI_TEST_EQUALS( testFriction, config.GetFriction(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + + tet_infoline("UtcDaliDynamicsBodyConfigFriction - DynamicsBodyConfig::SetFriction"); + const float friction = config.GetFriction() + 0.1f; + config.SetFriction(friction); + DALI_TEST_EQUALS( friction, config.GetFriction(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliDynamicsBodyConfigLinearDamping(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + const float testDamping = 0.123f; + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig config(DynamicsBodyConfig::New()); + config.SetLinearDamping(testDamping); + + tet_infoline("UtcDaliDynamicsBodyConfigLinearDamping- DynamicsBodyConfig::GetLinearDamping"); + DALI_TEST_EQUALS( testDamping, config.GetLinearDamping(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + + tet_infoline("UtcDaliDynamicsBodyConfigLinearDamping - DynamicsBodyConfig::SetLinearDamping"); + const float damping = config.GetLinearDamping() + 0.1f; + config.SetLinearDamping(damping); + DALI_TEST_EQUALS( damping, config.GetLinearDamping(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliDynamicsBodyConfigAngularDamping(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + const float testDamping = 0.123f; + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig config(DynamicsBodyConfig::New()); + config.SetAngularDamping(testDamping); + + tet_infoline("UtcDaliDynamicsBodyConfigAngularDamping- DynamicsBodyConfig::GetAngularDamping"); + DALI_TEST_EQUALS( testDamping, config.GetAngularDamping(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + + tet_infoline("UtcDaliDynamicsBodyConfigAngularDamping - DynamicsBodyConfig::SetAngularDamping"); + const float damping = config.GetAngularDamping() + 0.1f; + config.SetAngularDamping(damping); + DALI_TEST_EQUALS( damping, config.GetAngularDamping(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliDynamicsBodyConfigLinearSleepVelocity(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + const float testSleepVelocity = 0.123f; + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig config(DynamicsBodyConfig::New()); + config.SetLinearSleepVelocity(testSleepVelocity); + + tet_infoline("UtcDaliDynamicsBodyConfigLinearSleepVelocity - DynamicsBodyConfig::GetLinearSleepVelocity"); + DALI_TEST_EQUALS( testSleepVelocity, config.GetLinearSleepVelocity(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + + tet_infoline("UtcDaliDynamicsBodyConfigLinearSleepVelocity - DynamicsBodyConfig::SetLinearSleepVelocity"); + const float sleepVelocity = config.GetLinearSleepVelocity() + 0.1f; + config.SetLinearSleepVelocity(sleepVelocity); + DALI_TEST_EQUALS( sleepVelocity, config.GetLinearSleepVelocity(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliDynamicsBodyConfigAngularSleepVelocity(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + const float testSleepVelocity = 0.123f; + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig config(DynamicsBodyConfig::New()); + config.SetAngularSleepVelocity(testSleepVelocity); + + tet_infoline("UtcDaliDynamicsBodyConfigAngularSleepVelocity - DynamicsBodyConfig::GetAngularSleepVelocity"); + DALI_TEST_EQUALS( testSleepVelocity, config.GetAngularSleepVelocity(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + + tet_infoline("UtcDaliDynamicsBodyConfigAngularSleepVelocity - DynamicsBodyConfig::SetAngularSleepVelocity"); + const float sleepVelocity = config.GetAngularSleepVelocity() + 0.1f; + config.SetAngularSleepVelocity(sleepVelocity); + DALI_TEST_EQUALS( sleepVelocity, config.GetAngularSleepVelocity(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliDynamicsBodyConfigCollisionGroup(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + const short int testGroup = 0x1234; + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig config(DynamicsBodyConfig::New()); + config.SetCollisionGroup(testGroup); + + tet_infoline("UtcDaliDynamicsBodyConfigCollisionGroup- DynamicsBodyConfig::GetCollisionGroup"); + DALI_TEST_EQUALS( testGroup, config.GetCollisionGroup(), TEST_LOCATION ); + + tet_infoline("UtcDaliDynamicsBodyConfigCollisionGroup - DynamicsBodyConfig::SetCollisionGroup"); + const short int group = config.GetCollisionGroup() + 1; + config.SetCollisionGroup(group); + DALI_TEST_EQUALS( group, config.GetCollisionGroup(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliDynamicsBodyConfigCollisionMask(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + const short int testMask = 0x7ffe; + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig config(DynamicsBodyConfig::New()); + config.SetCollisionMask(testMask); + + tet_infoline("UtcDaliDynamicsBodyConfigCollisionMask- DynamicsBodyConfig::GetCollisionMask"); + DALI_TEST_EQUALS( testMask, config.GetCollisionMask(), TEST_LOCATION ); + + tet_infoline("UtcDaliDynamicsBodyConfigCollisionMask - DynamicsBodyConfig::SetCollisionMask"); + const short int mask = config.GetCollisionMask() + 1; + config.SetCollisionMask(mask); + DALI_TEST_EQUALS( mask, config.GetCollisionMask(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliDynamicsBodyConfigAnchorHardness(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + const float testHardness = 0.87f; + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig config(DynamicsBodyConfig::New()); + config.SetAnchorHardness(testHardness); + + tet_infoline("UtcDaliDynamicsBodyConfigAnchorHardness - DynamicsBodyConfig::GetAnchorHardness"); + DALI_TEST_EQUALS( testHardness, config.GetAnchorHardness(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); + + tet_infoline("UtcDaliDynamicsBodyConfigAnchorHardness - DynamicsBodyConfig::SetAnchorHardness"); + const float hardness = config.GetAnchorHardness() + 0.1f; + config.SetAnchorHardness(hardness); + DALI_TEST_EQUALS( hardness, config.GetAnchorHardness(), Math::MACHINE_EPSILON_1, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliDynamicsBodyConfigVolumeConservation(void) +{ + tet_infoline("UtcDaliDynamicsBodyConfigVolumeConservation"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig config(DynamicsBodyConfig::New()); + + const float conservation = config.GetVolumeConservation() + 0.1f; + config.SetVolumeConservation(conservation); + DALI_TEST_EQUALS( conservation, config.GetVolumeConservation(), Math::MACHINE_EPSILON_1, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliDynamicsBodyConfigShapeConservation(void) +{ + tet_infoline("UtcDaliDynamicsBodyConfigShapeConservation"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig config(DynamicsBodyConfig::New()); + + const float conservation = config.GetShapeConservation() + 0.1f; + config.SetShapeConservation(conservation); + DALI_TEST_EQUALS( conservation, config.GetShapeConservation(), Math::MACHINE_EPSILON_1, TEST_LOCATION ); + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-DynamicsJoint.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-DynamicsJoint.cpp new file mode 100644 index 0000000..e6ba008 --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-DynamicsJoint.cpp @@ -0,0 +1,342 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; + + +int UtcDaliDynamicsJointConstructor(void) +{ + tet_infoline("UtcDaliDynamicsJointConstructor - DynamicsJoint::DynamicsJoint"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsJoint joint; + + DALI_TEST_CHECK( !joint ); + END_TEST; +} + +int UtcDaliDynamicsJointLinearLimit(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New()); + Actor actor1(Actor::New()); + actor1.EnableDynamics(bodyConfig); + Actor actor2(Actor::New()); + actor2.EnableDynamics(bodyConfig); + + DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) ); + + if( joint ) + { + tet_infoline("UtcDaliDynamicsJointLinearLimit - DynamicsJoint::SetLinearLimit()"); + joint.SetLinearLimit(DynamicsJoint::LINEAR_X, 0.0f, 1.0f); + } + DALI_TEST_CHECK( true ); + END_TEST; +} + +int UtcDaliDynamicsJointAngularLimit(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New()); + Actor actor1(Actor::New()); + actor1.EnableDynamics(bodyConfig); + Actor actor2(Actor::New()); + actor2.EnableDynamics(bodyConfig); + + DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) ); + + tet_infoline("UtcDaliDynamicsJointAngularLimit - DynamicsJoint::SetAngularLimit()"); + joint.SetAngularLimit(DynamicsJoint::ANGULAR_X, Degree(0.0f), Degree(1.0f) ); + DALI_TEST_CHECK( true ); + END_TEST; +} + +int UtcDaliDynamicsJointEnableSpring(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New()); + Actor actor1(Actor::New()); + actor1.EnableDynamics(bodyConfig); + Actor actor2(Actor::New()); + actor2.EnableDynamics(bodyConfig); + + DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) ); + + tet_infoline("UtcDaliDynamicsJointEnableSpring"); + joint.EnableSpring(DynamicsJoint::LINEAR_X, true ); + DALI_TEST_CHECK( true ); + END_TEST; +} + +int UtcDaliDynamicsJointSetSpringStiffness(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New()); + Actor actor1(Actor::New()); + actor1.EnableDynamics(bodyConfig); + Actor actor2(Actor::New()); + actor2.EnableDynamics(bodyConfig); + + DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) ); + + tet_infoline("UtcDaliDynamicsJointSetSpringStiffness"); + joint.SetSpringStiffness(DynamicsJoint::LINEAR_X, 1.0f ); + DALI_TEST_CHECK( true ); + END_TEST; +} + +int UtcDaliDynamicsJointSetSpringCenterPoint(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New()); + Actor actor1(Actor::New()); + actor1.EnableDynamics(bodyConfig); + Actor actor2(Actor::New()); + actor2.EnableDynamics(bodyConfig); + + DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) ); + + tet_infoline("UtcDaliDynamicsJointSetSpringCenterPoint"); + joint.SetSpringCenterPoint(DynamicsJoint::LINEAR_X, 0.5f ); + DALI_TEST_CHECK( true ); + END_TEST; +} + +int UtcDaliDynamicsJointEnableMotor(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New()); + Actor actor1(Actor::New()); + actor1.EnableDynamics(bodyConfig); + Actor actor2(Actor::New()); + actor2.EnableDynamics(bodyConfig); + + DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) ); + + tet_infoline("UtcDaliDynamicsJointEnableMotor"); + joint.EnableMotor(DynamicsJoint::LINEAR_X, true ); + DALI_TEST_CHECK( true ); + END_TEST; +} + +int UtcDaliDynamicsJointSetMotorVelocity(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New()); + Actor actor1(Actor::New()); + actor1.EnableDynamics(bodyConfig); + Actor actor2(Actor::New()); + actor2.EnableDynamics(bodyConfig); + + DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) ); + + tet_infoline("UtcDaliDynamicsJointSetMotorVelocity"); + joint.SetMotorVelocity(DynamicsJoint::LINEAR_X, 1.0f ); + DALI_TEST_CHECK( true ); + END_TEST; +} + +int UtcDaliDynamicsJointSetMotorForce(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New()); + Actor actor1(Actor::New()); + actor1.EnableDynamics(bodyConfig); + Actor actor2(Actor::New()); + actor2.EnableDynamics(bodyConfig); + + DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) ); + + tet_infoline("UtcDaliDynamicsJointSetMotorForce"); + joint.SetMotorForce(DynamicsJoint::LINEAR_X, 0.5f ); + DALI_TEST_CHECK( true ); + END_TEST; +} + +int UtcDaliDynamicsJointGetActor(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + DynamicsBodyConfig bodyConfig(DynamicsBodyConfig::New()); + Actor actor1(Actor::New()); + actor1.EnableDynamics(bodyConfig); + Actor actor2(Actor::New()); + actor2.EnableDynamics(bodyConfig); + + DynamicsJoint joint( actor1.AddDynamicsJoint(actor2, Vector3() ) ); + + tet_infoline("UtcDaliDynamicsJointGetActor"); + DALI_TEST_CHECK( joint.GetActor(true) == actor1 && joint.GetActor(false) == actor2 ); + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-DynamicsShape.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-DynamicsShape.cpp new file mode 100644 index 0000000..26de1e4 --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-DynamicsShape.cpp @@ -0,0 +1,265 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; + + +int UtcDaliDynamicsShapeConstructor(void) +{ + tet_infoline("UtcDaliDynamicsShapeConstructor - DynamicsShape::DynamicsShape"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( world ) + { + + // Default constructor - create an uninitialized handle + DynamicsShape shape; + DALI_TEST_CHECK( !shape ); + + // initialize handle + shape = DynamicsShape::NewCube(Vector3::ONE); + + DALI_TEST_CHECK( shape ); + } + else + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + } + + END_TEST; +} + +int UtcDaliDynamicsShapeNewCapsule(void) +{ + tet_infoline("UtcDaliDynamicsShapeNewCapsule - DynamicsShape::NewCapsule"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( world ) + { + + DynamicsShape shape( DynamicsShape::NewCapsule( 1.0f, 2.0f ) ); + + DALI_TEST_CHECK( shape ); + DALI_TEST_CHECK( DynamicsShape::CAPSULE == shape.GetType() ); + } + else + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + } + + END_TEST; +} + +int UtcDaliDynamicsShapeNewCone(void) +{ + tet_infoline("UtcDaliDynamicsShapeNewCone - DynamicsShape::NewCone"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( world ) + { + DynamicsShape shape( DynamicsShape::NewCone( 1.0f, 2.0f ) ); + + DALI_TEST_CHECK( shape ); + DALI_TEST_CHECK( DynamicsShape::CONE == shape.GetType() ); + } + else + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + } + + END_TEST; +} + +int UtcDaliDynamicsShapeNewCube(void) +{ + tet_infoline("UtcDaliDynamicsShapeNewCube - DynamicsShape::NewCube"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( world ) + { + DynamicsShape shape( DynamicsShape::NewCube( Vector3::ONE ) ); + + DALI_TEST_CHECK( shape ); + DALI_TEST_CHECK( DynamicsShape::CUBE == shape.GetType() ); + } + else + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + } + END_TEST; +} + +int UtcDaliDynamicsShapeNewCylinder(void) +{ + tet_infoline("UtcDaliDynamicsShapeNewCylinder - DynamicsShape::NewCylinder"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( world ) + { + DynamicsShape shape( DynamicsShape::NewCylinder( 1.0f, 2.0f ) ); + + DALI_TEST_CHECK( shape ); + DALI_TEST_CHECK( DynamicsShape::CYLINDER == shape.GetType() ); + } + else + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + } + END_TEST; +} + +int UtcDaliDynamicsShapeNewMesh(void) +{ + tet_infoline("UtcDaliDynamicsShapeNewMesh - DynamicsShape::NewMesh"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( world ) + { + DynamicsShape shape( DynamicsShape::NewMesh( Mesh::NewPlane(10.0f, 10.0f, 10, 10)) ); + + DALI_TEST_CHECK( shape ); + DALI_TEST_CHECK( DynamicsShape::MESH == shape.GetType() ); + } + else + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + } + END_TEST; +} + +int UtcDaliDynamicsShapeNewSphere(void) +{ + tet_infoline("UtcDaliDynamicsShapeNewSphere - DynamicsShape::NewSphere"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( world ) + { + DynamicsShape shape( DynamicsShape::NewSphere( 1.0f ) ); + + DALI_TEST_CHECK( shape ); + DALI_TEST_CHECK( DynamicsShape::SPHERE == shape.GetType() ); + } + else + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + } + END_TEST; +} + +int UtcDaliDynamicsShapeGetType(void) +{ + tet_infoline("UtcDaliDynamicsShapeGetType - DynamicsShape::GetType"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( world ) + { + DynamicsShape shape( DynamicsShape::NewSphere( 1.0f ) ); + + DALI_TEST_CHECK( shape ); + DALI_TEST_CHECK( DynamicsShape::SPHERE == shape.GetType() ); + } + else + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + } + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-DynamicsWorld.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-DynamicsWorld.cpp new file mode 100644 index 0000000..9b3a2cc --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-DynamicsWorld.cpp @@ -0,0 +1,191 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 +#include + +using namespace Dali; + +int UtcDaliStageInitializeDynamics(void) +{ + TestApplication application; + + Stage stage = Stage::GetCurrent(); + TraceCallStack& trace = application.GetPlatform().GetTrace(); + trace.Enable(true); + DALI_TEST_CHECK( stage.InitializeDynamics( DynamicsWorldConfig::New() ) ); + DALI_TEST_CHECK( trace.FindMethod( "GetDynamicsFactory" ) ); + DALI_TEST_CHECK( trace.FindMethod( "DynamicsFactory::InitializeDynamics" ) ); + END_TEST; +} + +int UtcDaliStageGetDynamicsWorld(void) +{ + TestApplication application; + + Stage stage = Stage::GetCurrent(); + + DALI_TEST_CHECK( !stage.GetDynamicsWorld() ); + END_TEST; +} + +int UtcDaliStageTerminateDynamics(void) +{ + TestApplication application; + + Stage stage = Stage::GetCurrent(); + + stage.TerminateDynamics(); + + DALI_TEST_CHECK( !stage.GetDynamicsWorld() ); + END_TEST; +} + +int UtcDaliDynamicsWorldConstructor(void) +{ + tet_infoline("UtcDaliDynamicsWorldConstructor - DynamicsWorld::DynamicsWorld"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + // Default constructor - create an uninitialized handle + DynamicsWorld world; + DALI_TEST_CHECK( !world ); + + // initialize handle + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + world = Stage::GetCurrent().InitializeDynamics(worldConfig); + + DALI_TEST_CHECK( world ); + END_TEST; +} + +int UtcDaliDynamicsWorldGravity(void) +{ + TestApplication application; + TraceCallStack& trace( application.GetPlatform().GetTrace() ); + trace.Enable( true ); + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + const Vector3 gravity(1.0f, 2.0f, 3.0f); + + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + tet_infoline("UtcDaliDynamicsWorldGravity - DynamicsWorld::SetGravity"); + world.SetGravity(gravity); + + // update + application.SendNotification(); + application.Render(); + application.Render(); + + DALI_TEST_CHECK( trace.FindMethod( "DynamicsWorld::SetGravity" ) ); + + tet_infoline("UtcDaliDynamicsWorldGravity - DynamicsWorld::GetGravity"); + DALI_TEST_EQUALS(gravity, world.GetGravity(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliDynamicsWorldDebugDrawMode(void) +{ + TestApplication application; + TraceCallStack& trace( application.GetPlatform().GetTrace() ); + trace.Enable( true ); + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + const Vector3 gravity(1.0f, 2.0f, 3.0f); + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + const int mode(DynamicsWorld::DEBUG_MODE_WIREFRAME | DynamicsWorld::DEBUG_MODE_AABB); + + tet_infoline("UtcDaliDynamicsWorldDebugDrawMode - DynamicsWorld::SetDebugDrawMode"); + world.SetDebugDrawMode(mode); + + // update + application.SendNotification(); + application.Render(); + application.Render(); + + DALI_TEST_CHECK( trace.FindMethod( "DynamicsWorld::SetDebugDrawMode" ) ); + + tet_infoline("UtcDaliDynamicsWorldDebugDrawMode - DynamicsWorld::GetDebugDrawMode"); + DALI_TEST_CHECK(mode == world.GetDebugDrawMode()); + END_TEST; +} + +int UtcDaliDynamicsWorldRootActor(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + const Vector3 gravity(1.0f, 2.0f, 3.0f); + DynamicsWorldConfig worldConfig(DynamicsWorldConfig::New()); + DynamicsWorld world( Stage::GetCurrent().InitializeDynamics(worldConfig) ); + + if( !world ) + { + // cannot create dynamics world, log failure and exit + DALI_TEST_CHECK( false ); + END_TEST; + } + + Actor rootActor(Actor::New()); + + tet_infoline("UtcDaliDynamicsWorldDebugDrawMode - DynamicsWorld::GetRootActor"); + Actor actor(world.GetRootActor()); + DALI_TEST_CHECK( !actor ); + + tet_infoline("UtcDaliDynamicsWorldSetRootActor - DynamicsWorld::SetRootActor"); + world.SetRootActor(rootActor); + DALI_TEST_CHECK(rootActor == world.GetRootActor()); + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-DynamicsWorldConfig.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-DynamicsWorldConfig.cpp new file mode 100644 index 0000000..7c38f91 --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-DynamicsWorldConfig.cpp @@ -0,0 +1,86 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; + + +int UtcDaliDynamicsWorldConfigConstructor(void) +{ + tet_infoline("UtcDaliDynamicsWorldConfigConstructor - DynamicsWorldConfig::DynamicsWorldConfig"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + // Default constructor - create an uninitialized handle + DynamicsWorldConfig worldConfig; + DALI_TEST_CHECK( !worldConfig ); + + // initialize handle + worldConfig = DynamicsWorldConfig::New(); + + DALI_TEST_CHECK( worldConfig ); + END_TEST; +} + +int UtcDaliDynamicsWorldConfigNew(void) +{ + tet_infoline("UtcDaliDynamicsWorldConfigNew - DynamicsWorldConfig::New"); + + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + // Default constructor - create an uninitialized handle + DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() ); + + DALI_TEST_CHECK( worldConfig ); + END_TEST; +} + +int UtcDaliDynamicsWorldConfigType(void) +{ + TestApplication application; + + // start up + application.SendNotification(); + application.Render(); + application.Render(); + + // Default constructor - create an uninitialized handle + DynamicsWorldConfig worldConfig( DynamicsWorldConfig::New() ); + + tet_infoline("UtcDaliDynamicsWorldConfigNew - DynamicsWorldConfig::GetType"); + DALI_TEST_CHECK(DynamicsWorldConfig::RIGID == worldConfig.GetType()); + + tet_infoline("UtcDaliDynamicsWorldConfigNew - DynamicsWorldConfig::SetType"); + worldConfig.SetType(DynamicsWorldConfig::SOFT); + DALI_TEST_CHECK(DynamicsWorldConfig::SOFT == worldConfig.GetType()); + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-EncodedBufferImage.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-EncodedBufferImage.cpp new file mode 100644 index 0000000..d480549 --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-EncodedBufferImage.cpp @@ -0,0 +1,852 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + + +namespace +{ +/** PNG image file converted to an array using standard linux commandline tool: + * xxd -i fractal.001.32x32.png | gvim - + * This is 720 wide x 1280 high. + */ +const unsigned char sEncodedBufferImageDataPNG[] = { + 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, + 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x02, 0xd0, 0x00, 0x00, 0x05, 0x00, + 0x08, 0x02, 0x00, 0x00, 0x00, 0xe1, 0xac, 0xf2, 0x6a, 0x00, 0x00, 0x00, + 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, 0x1c, 0xe9, 0x00, 0x00, + 0x20, 0x00, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0xed, 0xd8, 0x5d, 0x8f, + 0x5c, 0x87, 0x7d, 0xdf, 0xf1, 0x39, 0x7b, 0xce, 0xec, 0xcc, 0xce, 0x72, + 0xc9, 0x5d, 0x92, 0x22, 0x45, 0x8a, 0x22, 0x45, 0x51, 0x22, 0x25, 0x45, + 0x96, 0x6d, 0x45, 0xb6, 0x23, 0x25, 0xb5, 0x93, 0x18, 0x49, 0x6c, 0x35, + 0x48, 0xe0, 0x38, 0x76, 0xdd, 0x34, 0x35, 0x82, 0x5e, 0x04, 0x01, 0xda, + 0xdb, 0x02, 0xed, 0x55, 0x8b, 0x02, 0x05, 0x7a, 0xd1, 0x14, 0xc8, 0x65, + 0x0b, 0x17, 0x45, 0x9a, 0x06, 0x70, 0x9b, 0xd6, 0x76, 0x6c, 0x07, 0xb6, + 0x13, 0xa7, 0x89, 0x6d, 0xd5, 0x71, 0x2c, 0x89, 0xb6, 0xf5, 0x4c, 0x49, + 0x94, 0xf8, 0x24, 0x3e, 0x53, 0xe4, 0xee, 0x92, 0x3b, 0x3b, 0x0f, 0xe7, + 0x9c, 0xbe, 0x01, 0xf7, 0x22, 0xc0, 0xfc, 0xd0, 0x4e, 0xfa, 0xf9, 0xbc, + 0x80, 0x1f, 0x0f, 0xfe, 0x9c, 0x87, 0xef, 0x4e, 0xf1, 0x9d, 0xf7, 0xfd, + 0x4e, 0x27, 0x66, 0x38, 0x2d, 0x3b, 0x49, 0xc3, 0x49, 0x70, 0xff, 0xb5, + 0xe9, 0xce, 0xdc, 0xf8, 0x1f, 0xef, 0x39, 0x14, 0xbd, 0xcc, 0x87, 0x2f, + 0x5e, 0xc9, 0x8d, 0x1f, 0x5d, 0xbc, 0x93, 0x1b, 0xdf, 0xdf, 0x1d, 0xe5, + 0xc6, 0x0f, 0xae, 0x6c, 0x45, 0xcf, 0x5e, 0x14, 0xc1, 0xf1, 0x41, 0x7f, + 0x9a, 0x1b, 0xef, 0x96, 0x4d, 0xf4, 0x32, 0xbd, 0x5e, 0x9d, 0x1b, 0xaf, + 0xaa, 0xe0, 0x78, 0xdb, 0x16, 0xd1, 0xcb, 0x74, 0xa3, 0x97, 0xe9, 0xce, + 0xeb, 0x65, 0x16, 0xca, 0x36, 0xfc, 0x56, 0x0d, 0xee, 0xd7, 0xd3, 0x85, + 0x39, 0x7d, 0xf2, 0x4e, 0xa7, 0xd3, 0xd4, 0xc1, 0x87, 0x5f, 0xe8, 0x00, + 0x00, 0x84, 0x09, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, + 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, + 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, + 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, + 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, + 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, + 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, + 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, + 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0xcc, 0x4a, + 0xb5, 0xb4, 0x38, 0xcd, 0xad, 0xb7, 0xe1, 0xa7, 0xdf, 0x9a, 0x54, 0xb9, + 0xf1, 0x72, 0x1a, 0x7c, 0xfc, 0x37, 0x7e, 0xe6, 0x9e, 0xe8, 0x65, 0x8a, + 0x1f, 0x05, 0x53, 0xf2, 0x03, 0xe7, 0x5e, 0x09, 0x3e, 0x79, 0x11, 0x3c, + 0xfb, 0x30, 0xf9, 0x82, 0xe9, 0x74, 0x3a, 0xcb, 0xbd, 0x49, 0xf0, 0xd5, + 0xbe, 0x1d, 0x7c, 0xf8, 0x5d, 0xcb, 0xe3, 0xe8, 0x65, 0xb6, 0xb7, 0xcb, + 0xe4, 0x6b, 0x26, 0xf8, 0x6a, 0xef, 0x76, 0x9b, 0xe8, 0x65, 0x9a, 0xa6, + 0x08, 0x8e, 0x4f, 0x83, 0x97, 0xa9, 0x16, 0xeb, 0xdc, 0x78, 0x9d, 0x3c, + 0x4b, 0x5a, 0xf4, 0xff, 0xb4, 0x9e, 0x66, 0x7f, 0x26, 0x68, 0xea, 0xe0, + 0xc3, 0xfb, 0x85, 0x03, 0x00, 0x88, 0x13, 0x1c, 0x00, 0x80, 0xe0, 0x00, + 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, + 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, + 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, + 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, + 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, + 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, + 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, + 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, + 0x00, 0x00, 0x98, 0x95, 0xaa, 0x6d, 0x8b, 0xdc, 0x7a, 0xaf, 0x6a, 0xa2, + 0x4f, 0x3f, 0x9c, 0x06, 0x83, 0xe9, 0xed, 0x87, 0x0f, 0xe5, 0xc6, 0xef, + 0x3d, 0x79, 0x25, 0x7a, 0x99, 0xa7, 0xdf, 0x3c, 0x9f, 0x1b, 0x6f, 0x06, + 0xc5, 0x9c, 0xbe, 0xdc, 0x9b, 0x36, 0xbb, 0x3f, 0xa9, 0x83, 0x2f, 0xc8, + 0x6e, 0x19, 0x7c, 0x37, 0x4d, 0xa6, 0xd9, 0xbf, 0x3d, 0xba, 0x55, 0x9d, + 0x9c, 0x0f, 0xbe, 0x20, 0xc7, 0xe3, 0x32, 0xfb, 0x9a, 0x6c, 0x82, 0x0f, + 0xbf, 0xbd, 0x1d, 0x7c, 0xf8, 0xa2, 0x17, 0x3c, 0xcb, 0xea, 0x60, 0x34, + 0xc7, 0x2f, 0xc8, 0xe4, 0x07, 0x64, 0xf4, 0x2b, 0xbb, 0xd3, 0xe9, 0x14, + 0xc9, 0x79, 0xbf, 0x70, 0x00, 0x00, 0x71, 0x82, 0x03, 0x00, 0x10, 0x1c, + 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, + 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, + 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, + 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, + 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, + 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, + 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, + 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, + 0x1c, 0x00, 0x00, 0xb3, 0x52, 0x15, 0x45, 0x70, 0xbd, 0x68, 0xdb, 0xe8, + 0xd3, 0xdf, 0xea, 0xf5, 0x72, 0xe3, 0x4b, 0x2f, 0x5e, 0xc9, 0x8d, 0xdf, + 0xfe, 0xc5, 0xf7, 0x64, 0xff, 0x63, 0xdf, 0x3a, 0x9b, 0xdb, 0x5e, 0x9f, + 0x56, 0xb9, 0xf1, 0xbd, 0xdd, 0x26, 0x37, 0x3e, 0x6d, 0xb2, 0x85, 0x3d, + 0x1c, 0x07, 0xdf, 0x4e, 0x75, 0x59, 0xe7, 0xc6, 0x9b, 0xb6, 0x88, 0x5e, + 0x66, 0x39, 0xfa, 0x67, 0xd3, 0x42, 0xf0, 0x73, 0xa6, 0xae, 0xb3, 0x97, + 0xd9, 0xdc, 0xee, 0xe6, 0xc6, 0xff, 0x60, 0xfb, 0x68, 0x6e, 0xfc, 0x93, + 0xe3, 0xf3, 0xb9, 0xf1, 0x7e, 0x39, 0x8d, 0x9e, 0x7d, 0x34, 0x2a, 0x83, + 0x5f, 0xab, 0x55, 0x33, 0xa7, 0xaf, 0xf6, 0x4e, 0xa7, 0x53, 0x55, 0xc1, + 0x7d, 0xbf, 0x70, 0x00, 0x00, 0x71, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, + 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, + 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, + 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, + 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, + 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, + 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, + 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, + 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, + 0x00, 0x00, 0xb3, 0x52, 0x45, 0xd7, 0xdb, 0x4e, 0x11, 0xdd, 0xbf, 0xb7, + 0xdd, 0xca, 0x8d, 0xf7, 0x7a, 0xd3, 0xdc, 0xf8, 0x9f, 0x9e, 0xb9, 0x15, + 0xbd, 0xcc, 0x46, 0x5d, 0xe6, 0xc6, 0x57, 0x16, 0x82, 0x2f, 0x9b, 0xcd, + 0xba, 0xc9, 0x8d, 0xd7, 0xe1, 0x17, 0xe4, 0x9e, 0xde, 0x28, 0x37, 0x3e, + 0x69, 0x82, 0x7f, 0x1e, 0x4c, 0x46, 0xd9, 0xbf, 0x3d, 0xd6, 0x87, 0x8b, + 0xb9, 0xf1, 0x22, 0xf9, 0xbf, 0x5a, 0x15, 0x4d, 0xf4, 0x32, 0x6d, 0x72, + 0xfc, 0x91, 0x8d, 0xe0, 0xe7, 0xcc, 0x1b, 0xfb, 0xd7, 0x72, 0xe3, 0x6b, + 0xc3, 0x71, 0xf4, 0xec, 0x3b, 0x06, 0xc1, 0xfd, 0xba, 0x5e, 0x48, 0x8e, + 0x47, 0x5f, 0x32, 0x9d, 0xf1, 0x38, 0xf8, 0x76, 0xf2, 0x0b, 0x07, 0x00, + 0x10, 0x27, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, + 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, + 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, + 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, + 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, + 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, + 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, + 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, + 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x30, 0x2b, 0x55, + 0xa7, 0xd3, 0xe6, 0xd6, 0x27, 0x75, 0x36, 0x68, 0xba, 0x0b, 0x4d, 0x6e, + 0x7c, 0x47, 0x55, 0xe7, 0xc6, 0x3f, 0x7e, 0xee, 0x9d, 0xe8, 0x65, 0xbe, + 0xfb, 0xf0, 0xa1, 0xdc, 0x78, 0x3d, 0x0d, 0x5e, 0xe6, 0xd7, 0xde, 0x3a, + 0x9b, 0x3c, 0x4c, 0x1b, 0x3d, 0xfb, 0xb0, 0x2e, 0x73, 0xe3, 0x2b, 0xd5, + 0x34, 0x37, 0x3e, 0x6d, 0x8a, 0xe8, 0x65, 0x5e, 0x9a, 0xee, 0xcc, 0x8d, + 0xef, 0x5b, 0x18, 0xe7, 0xc6, 0xf7, 0x2e, 0x8c, 0xa2, 0x97, 0xb9, 0x5c, + 0xf7, 0x73, 0xe3, 0x27, 0x97, 0x57, 0x73, 0xe3, 0xb7, 0x46, 0x8b, 0xc1, + 0x57, 0x7b, 0x67, 0x3b, 0x7a, 0xf6, 0x47, 0xcb, 0x9b, 0xb9, 0xf1, 0xc5, + 0x2a, 0xf8, 0xc5, 0xd4, 0x29, 0xb2, 0x6f, 0xd5, 0xf1, 0x34, 0xf8, 0xad, + 0xed, 0x17, 0x0e, 0x00, 0x20, 0x4e, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, + 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, + 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, + 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, + 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, + 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, + 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, 0x01, + 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, + 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, + 0x00, 0x60, 0x56, 0xaa, 0xb6, 0x2d, 0x72, 0xeb, 0xa3, 0x69, 0x19, 0x7e, + 0xfe, 0x36, 0x37, 0x5d, 0x26, 0xc7, 0xef, 0x6b, 0xef, 0x44, 0xef, 0xb2, + 0xf4, 0xfa, 0xf9, 0xdc, 0xf8, 0x37, 0x0e, 0x1f, 0xca, 0x8d, 0x7f, 0xf1, + 0xc0, 0xbd, 0xb9, 0xf1, 0x5b, 0x1f, 0xd8, 0x1f, 0x3d, 0xfb, 0x3f, 0xfa, + 0xca, 0x73, 0xb9, 0xf1, 0xa6, 0x4d, 0x3e, 0x7a, 0x91, 0x7d, 0xa3, 0x16, + 0x4d, 0x70, 0xfc, 0xf7, 0x1f, 0x3d, 0x9e, 0x1b, 0xff, 0xcc, 0x0b, 0x6f, + 0x46, 0x2f, 0x73, 0xb2, 0x5d, 0xc9, 0x8d, 0x7f, 0xfd, 0x9f, 0x7d, 0x24, + 0x37, 0xfe, 0x2f, 0xfe, 0xcd, 0x97, 0x72, 0xe3, 0x77, 0x2d, 0x6d, 0x47, + 0xcf, 0x7e, 0x6b, 0x6b, 0x31, 0x37, 0x3e, 0x58, 0x9c, 0xce, 0xef, 0x7b, + 0xb5, 0x28, 0x82, 0x1f, 0x34, 0x7e, 0xe1, 0x00, 0x00, 0xe2, 0x04, 0x07, + 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, + 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, + 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, + 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, + 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, + 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, + 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, + 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, + 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x66, 0xa5, 0xda, 0x1a, 0x57, 0xc1, + 0x9c, 0x29, 0xda, 0xe8, 0xd3, 0xb7, 0x6d, 0x30, 0x98, 0xb6, 0x9b, 0x32, + 0x37, 0xde, 0x2f, 0xea, 0xe8, 0x65, 0x16, 0x17, 0x9a, 0xdc, 0xf8, 0x63, + 0x17, 0xae, 0xe5, 0xc6, 0xbf, 0xf6, 0xe4, 0xb1, 0xdc, 0xf8, 0x87, 0x5e, + 0xbe, 0x11, 0x3d, 0xfb, 0x46, 0xd1, 0x0d, 0xbe, 0x57, 0x9b, 0xe0, 0xbb, + 0x69, 0xda, 0x16, 0xd1, 0xcb, 0x4c, 0x3a, 0xc1, 0xfd, 0xeb, 0x47, 0xf7, + 0xe7, 0xc6, 0x7f, 0xf8, 0xca, 0xf5, 0xe8, 0x65, 0x5e, 0xfe, 0xc8, 0x7d, + 0xb9, 0xf1, 0xf7, 0xfc, 0xde, 0xf7, 0x72, 0xe3, 0xa7, 0x06, 0x6b, 0xb9, + 0xf1, 0x87, 0xda, 0x8d, 0xe8, 0xd9, 0x9b, 0xe4, 0x0b, 0xfe, 0xf6, 0x68, + 0x31, 0xf8, 0xd9, 0x5e, 0x65, 0xbf, 0x3b, 0xaa, 0x85, 0xe0, 0xe7, 0x8c, + 0x5f, 0x38, 0x00, 0x80, 0x38, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, + 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, + 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, + 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, + 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, + 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, + 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, + 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, + 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, + 0x80, 0x59, 0xa9, 0xea, 0xa6, 0xc8, 0xad, 0xb7, 0xe1, 0xa7, 0xbf, 0x53, + 0x57, 0xb9, 0xf1, 0x69, 0x1b, 0xbc, 0x4c, 0x11, 0xbe, 0x4c, 0x13, 0xfd, + 0x17, 0x92, 0xdb, 0xbd, 0x83, 0xcb, 0xb9, 0xf1, 0xcd, 0x93, 0x97, 0xa2, + 0x67, 0x3f, 0x53, 0x0d, 0x72, 0xe3, 0xdf, 0x1b, 0xec, 0xcd, 0x8d, 0x1f, + 0xb9, 0x7d, 0x3b, 0x7a, 0x99, 0x36, 0xf9, 0xa2, 0x19, 0x9c, 0xbd, 0x99, + 0x1b, 0xff, 0xe2, 0xa7, 0x1e, 0x8d, 0x5e, 0x66, 0x6d, 0x58, 0xe7, 0xc6, + 0x3f, 0xb6, 0x71, 0x2b, 0x37, 0x7e, 0xb8, 0x1a, 0xe6, 0xc6, 0x37, 0xba, + 0xdd, 0xe8, 0xd9, 0x77, 0x74, 0xa7, 0x73, 0xfa, 0x9d, 0x3d, 0x1e, 0x65, + 0x2f, 0x33, 0x4e, 0x26, 0x81, 0x5f, 0x38, 0x00, 0x80, 0x38, 0xc1, 0x01, + 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, 0x40, + 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, + 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, + 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, + 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, + 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, + 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, + 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, + 0x01, 0x00, 0x08, 0x0e, 0x00, 0x80, 0x59, 0xa9, 0xce, 0xdf, 0x19, 0xe4, + 0xd6, 0x6f, 0x15, 0xdd, 0xe8, 0xd3, 0xef, 0xe8, 0x4c, 0xe7, 0xb4, 0xc5, + 0x86, 0x4d, 0x36, 0xf5, 0x7e, 0xb4, 0x77, 0x6f, 0x6e, 0x7c, 0xf3, 0x76, + 0x93, 0x1b, 0x1f, 0x7c, 0xfb, 0x42, 0x6e, 0xfc, 0xf9, 0x7f, 0xf9, 0x54, + 0xf4, 0xec, 0x4b, 0x7f, 0xf8, 0x7a, 0xf0, 0x35, 0xf3, 0xeb, 0x47, 0x73, + 0xe3, 0xed, 0xbf, 0x7d, 0x3e, 0x7a, 0x99, 0x3b, 0x55, 0x99, 0x1b, 0xbf, + 0xb1, 0x63, 0x31, 0x37, 0xfe, 0xd4, 0xff, 0x38, 0x15, 0xbd, 0xcc, 0xe1, + 0xd1, 0x30, 0x37, 0xde, 0x2f, 0x82, 0x6f, 0xd5, 0xb2, 0x68, 0x83, 0x1f, + 0x32, 0x75, 0x15, 0x3d, 0x7b, 0x9b, 0x1c, 0x8f, 0x5e, 0xa6, 0x08, 0x37, + 0xc1, 0xe6, 0x34, 0xf8, 0xad, 0xed, 0x17, 0x0e, 0x00, 0x20, 0x4e, 0x70, + 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, + 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, + 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, + 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, + 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, + 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, + 0x0e, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, 0x01, + 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, 0x40, + 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x60, 0x56, 0xaa, 0xff, 0x78, 0xff, + 0xf1, 0xdc, 0xfa, 0xee, 0x8d, 0xed, 0xe8, 0xd3, 0x3f, 0x75, 0xf5, 0xca, + 0x9c, 0xde, 0x7d, 0xa3, 0xed, 0x46, 0xf7, 0x9b, 0xdb, 0xd3, 0xdc, 0xf8, + 0x5f, 0x7d, 0xfa, 0x27, 0x72, 0xe3, 0xe5, 0xe9, 0xf5, 0xdc, 0xf8, 0xd3, + 0xbf, 0xf2, 0x70, 0xf4, 0xec, 0x5f, 0xea, 0x17, 0xc1, 0xff, 0xd3, 0x2f, + 0x9c, 0xcd, 0x8d, 0x5f, 0x38, 0xba, 0x16, 0xbd, 0xcc, 0xad, 0xaa, 0xcc, + 0x8d, 0xef, 0x39, 0xb3, 0x91, 0x1b, 0x5f, 0xee, 0x34, 0xd1, 0xcb, 0x2c, + 0x15, 0x75, 0x6e, 0xbc, 0x6d, 0x93, 0x1f, 0x32, 0xc9, 0xf1, 0x4e, 0x11, + 0xbd, 0x7a, 0x67, 0x73, 0x1a, 0xfc, 0x04, 0x8e, 0x1e, 0x66, 0xd4, 0x94, + 0xd1, 0xcb, 0x7c, 0x6b, 0xed, 0xee, 0xdc, 0xb8, 0x5f, 0x38, 0x00, 0x80, + 0x38, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, + 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, + 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, + 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, + 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, + 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, + 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, + 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, + 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x80, 0x59, 0xa9, 0xce, + 0xff, 0xca, 0xc3, 0xb9, 0xf5, 0xf6, 0x6b, 0x6f, 0x45, 0x9f, 0xfe, 0x95, + 0x77, 0x87, 0xb9, 0xf1, 0x03, 0xd3, 0xed, 0xdc, 0xf8, 0xb0, 0x28, 0xa3, + 0x97, 0xb9, 0x74, 0x60, 0x67, 0xf0, 0x45, 0xb3, 0xb6, 0x98, 0x1b, 0x5f, + 0xfe, 0x07, 0x27, 0x72, 0xe3, 0x07, 0x07, 0x4b, 0xd1, 0xb3, 0x7f, 0xe6, + 0x63, 0x8f, 0xe4, 0xc6, 0xbf, 0xd4, 0xab, 0x72, 0xe3, 0x6f, 0x9d, 0xdb, + 0x8c, 0x5e, 0xe6, 0xf0, 0x72, 0xf0, 0xf2, 0xe7, 0x9e, 0xbd, 0x94, 0x1b, + 0x3f, 0xfe, 0xf5, 0xf5, 0xe8, 0x65, 0xc6, 0x45, 0xf0, 0xaf, 0xbe, 0xcd, + 0x36, 0xf8, 0x9a, 0xd9, 0xd1, 0x04, 0xc7, 0xab, 0xa2, 0x9d, 0xdf, 0xaf, + 0xd5, 0xad, 0x26, 0xf8, 0xf1, 0xfe, 0x4a, 0x77, 0x25, 0xfa, 0xf0, 0xaf, + 0x1d, 0xd9, 0x97, 0x1b, 0xf7, 0x0b, 0x07, 0x00, 0x10, 0x27, 0x38, 0x00, + 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, + 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, + 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, + 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, + 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x80, + 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, + 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, + 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, + 0x00, 0x00, 0xc1, 0x01, 0x00, 0x30, 0x2b, 0xd5, 0x3f, 0xfc, 0xdd, 0x6f, + 0xe6, 0xd6, 0x5f, 0xea, 0xad, 0x44, 0x9f, 0xfe, 0x4f, 0x7f, 0xe3, 0xfd, + 0xb9, 0xf1, 0x8f, 0xff, 0xe7, 0x93, 0xb9, 0xf1, 0x51, 0x95, 0x4d, 0xbd, + 0x95, 0x4b, 0xb7, 0x73, 0xe3, 0x4b, 0xcf, 0x5f, 0xcf, 0x8d, 0x5f, 0xde, + 0xdb, 0x9b, 0xdf, 0xbe, 0x3e, 0xd0, 0x5b, 0xca, 0x8d, 0x7f, 0xf2, 0x17, + 0x4f, 0xe4, 0xc6, 0xbf, 0xf1, 0xdc, 0xd9, 0xe8, 0x65, 0xce, 0x9d, 0xbe, + 0x99, 0x1b, 0xdf, 0xfd, 0xc6, 0x46, 0x6e, 0xfc, 0xc2, 0xca, 0x20, 0x7a, + 0x99, 0x1f, 0x1c, 0xda, 0x9f, 0x1b, 0xff, 0xd0, 0x0b, 0x97, 0x72, 0xe3, + 0xef, 0xf4, 0x83, 0x97, 0x79, 0x64, 0xb8, 0x1e, 0x3d, 0x7b, 0x99, 0x1c, + 0xaf, 0xdb, 0xe0, 0xf8, 0x1b, 0x07, 0xf6, 0x44, 0x2f, 0xf3, 0xc1, 0x1f, + 0x9c, 0x99, 0xdf, 0x4f, 0x60, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, + 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, + 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, + 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, + 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, + 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, + 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, + 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, + 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, + 0x0e, 0x00, 0x80, 0x99, 0xa9, 0xf6, 0xb5, 0xa3, 0xdc, 0x7a, 0xd1, 0x5b, + 0x8d, 0x3e, 0xfd, 0xc6, 0xfa, 0x76, 0x6e, 0xfc, 0xd5, 0x3d, 0xbb, 0x72, + 0xe3, 0xbd, 0xed, 0x69, 0xf4, 0x32, 0xa7, 0x3f, 0x79, 0x22, 0x37, 0xbe, + 0x79, 0x6e, 0x23, 0x37, 0xfe, 0xd8, 0xcf, 0x1e, 0xce, 0x8d, 0x2f, 0x86, + 0x0b, 0xbb, 0xe9, 0xb4, 0xb9, 0xf1, 0x7d, 0x65, 0x3f, 0x37, 0xfe, 0x5b, + 0x1f, 0x7a, 0x28, 0x7a, 0x99, 0xff, 0x30, 0x7e, 0x39, 0x37, 0xde, 0xfd, + 0xad, 0xe0, 0xc3, 0xbf, 0xf5, 0x85, 0xd3, 0xd1, 0xcb, 0xf4, 0x3e, 0x76, + 0x24, 0x37, 0xfe, 0xcd, 0xbf, 0x73, 0x28, 0x37, 0x7e, 0xe2, 0xf3, 0xaf, + 0x04, 0x5f, 0xed, 0xc3, 0xed, 0xe8, 0xd9, 0xfb, 0x9d, 0x26, 0x37, 0x7e, + 0x6d, 0x65, 0x29, 0x37, 0x7e, 0x76, 0xcf, 0x8e, 0xe8, 0x65, 0x9e, 0x78, + 0xfb, 0x4a, 0x6e, 0xdc, 0x2f, 0x1c, 0x00, 0x40, 0x9c, 0xe0, 0x00, 0x00, + 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, + 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, + 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, + 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, + 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, + 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, + 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, + 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, + 0x00, 0x04, 0x07, 0x00, 0xc0, 0xac, 0x54, 0xff, 0xeb, 0xd8, 0xa1, 0xdc, + 0xfa, 0x33, 0x4f, 0xdc, 0x17, 0x7d, 0xfa, 0xf7, 0x3e, 0x73, 0x31, 0x37, + 0xfe, 0xec, 0x2f, 0xdf, 0x9f, 0x1b, 0xdf, 0xb9, 0x3e, 0x89, 0x5e, 0x66, + 0x74, 0xf7, 0x52, 0x6e, 0xbc, 0xfb, 0xe8, 0x6a, 0x6e, 0xfc, 0x89, 0xfd, + 0xbb, 0x73, 0xe3, 0x6d, 0xf8, 0xed, 0x54, 0x14, 0xc5, 0x9c, 0x7e, 0x10, + 0xd4, 0xe1, 0xdb, 0x7c, 0xe2, 0xa7, 0x1f, 0xc8, 0x8d, 0xff, 0xfb, 0x2f, + 0xbf, 0x10, 0xbc, 0xcc, 0x53, 0xfb, 0xa2, 0x97, 0x59, 0x1b, 0x4f, 0x73, + 0xe3, 0xfd, 0xef, 0x04, 0x3f, 0x21, 0x77, 0x0e, 0x83, 0x1f, 0x62, 0x57, + 0xba, 0xfd, 0xec, 0x9f, 0xda, 0x75, 0x93, 0x1b, 0xff, 0xce, 0xe3, 0x47, + 0x72, 0xe3, 0x07, 0x27, 0x4d, 0xf4, 0x32, 0xbd, 0xb2, 0x0e, 0x9e, 0x5d, + 0x73, 0x01, 0x00, 0x69, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, + 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, + 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, + 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, + 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, + 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, 0x01, + 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, 0x40, + 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, + 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, + 0xb3, 0x52, 0x8d, 0xde, 0x9d, 0xe6, 0xd6, 0x3f, 0xfb, 0xdf, 0x4e, 0x46, + 0x9f, 0x7e, 0xbd, 0xec, 0xe6, 0xc6, 0x57, 0x3e, 0xbf, 0x95, 0x1b, 0xbf, + 0xb8, 0x3a, 0x88, 0x5e, 0xe6, 0xe2, 0x3b, 0xb7, 0x83, 0x67, 0xff, 0xf9, + 0x83, 0xc1, 0xb3, 0x57, 0x5d, 0x6f, 0xcb, 0xbf, 0x7d, 0x56, 0x17, 0x82, + 0xff, 0xad, 0x7f, 0xff, 0xef, 0x3e, 0x92, 0x1b, 0x3f, 0x75, 0xe5, 0x56, + 0xf4, 0x32, 0x2f, 0xfc, 0xde, 0x8f, 0x72, 0xe3, 0xdd, 0xed, 0xe0, 0xc7, + 0xfb, 0xd5, 0x41, 0x3f, 0x37, 0xfe, 0xd6, 0xa3, 0xfb, 0xa3, 0x67, 0xbf, + 0xfc, 0xd0, 0x6a, 0x6e, 0xfc, 0xc4, 0x76, 0xf0, 0xc9, 0x9f, 0xfc, 0xfc, + 0xf7, 0xa3, 0x97, 0xb9, 0xbb, 0x1c, 0xe5, 0xc6, 0xfd, 0xc2, 0x01, 0x00, + 0xc4, 0x09, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, + 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, + 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x80, + 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, + 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, + 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, + 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, + 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, + 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0xcc, 0x4a, 0xf5, + 0xb1, 0x8d, 0x8b, 0xb9, 0xf5, 0xf5, 0xa2, 0x9b, 0xcd, 0xa5, 0x3a, 0x38, + 0x7e, 0xbb, 0xa8, 0x72, 0xe3, 0xd7, 0x9a, 0x36, 0x7b, 0x99, 0xbd, 0x4b, + 0xb9, 0xf1, 0xfb, 0x7e, 0xe9, 0xde, 0xdc, 0xf8, 0xb0, 0x0d, 0xfe, 0xa7, + 0xf6, 0x8b, 0xd2, 0x7b, 0xfe, 0xff, 0xd2, 0x5f, 0x36, 0x45, 0x6e, 0xfc, + 0x68, 0x77, 0x90, 0x1b, 0x6f, 0xd6, 0xea, 0xe8, 0x65, 0x4e, 0xfd, 0xdc, + 0xdd, 0xb9, 0xf1, 0x9d, 0x9f, 0x3a, 0x96, 0x1b, 0x3f, 0xfd, 0xaf, 0x9f, + 0xcf, 0x8d, 0x2f, 0xed, 0x5c, 0x8c, 0x9e, 0xfd, 0x27, 0xff, 0xeb, 0xeb, + 0xc1, 0xcb, 0xfc, 0xc2, 0x7d, 0xb9, 0xf1, 0x1f, 0x1e, 0xb8, 0x2b, 0x7a, + 0x99, 0x7b, 0xde, 0x1d, 0x27, 0x3f, 0x07, 0x00, 0x00, 0xe2, 0x7f, 0x78, + 0x00, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, + 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, + 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, + 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, + 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, + 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, + 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, + 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, + 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x80, 0xd9, 0xa8, 0x96, 0xcb, 0x3a, + 0xb7, 0xbe, 0xd8, 0x36, 0xd1, 0xa7, 0xbf, 0x5e, 0xf7, 0x72, 0xe3, 0xdf, + 0xf8, 0xb9, 0x63, 0xb9, 0xf1, 0x41, 0xaf, 0x8c, 0x5e, 0x66, 0xb4, 0x39, + 0xc9, 0x8d, 0x9f, 0xfd, 0xf6, 0xc5, 0xdc, 0xf8, 0xf0, 0x37, 0xf6, 0xe5, + 0xc6, 0xd7, 0x04, 0xf6, 0xdf, 0x46, 0x6d, 0x72, 0xfc, 0xd8, 0xf2, 0x4a, + 0xf4, 0xe1, 0x7f, 0xfb, 0xe9, 0xf7, 0xe6, 0xc6, 0xff, 0xf8, 0xaf, 0xde, + 0xcc, 0x8d, 0x17, 0x9f, 0x38, 0x9a, 0x1b, 0xdf, 0xf5, 0x27, 0x6f, 0x47, + 0xcf, 0x7e, 0xcf, 0x78, 0x3b, 0x37, 0xfe, 0xe8, 0x57, 0x5e, 0xc8, 0x8d, + 0xaf, 0xd6, 0x93, 0xe8, 0x65, 0xca, 0x41, 0xf0, 0x5b, 0xdb, 0x07, 0x30, + 0x00, 0x10, 0x27, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, + 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, + 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, + 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, + 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, + 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, + 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, + 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, + 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x30, 0x2b, + 0x55, 0x51, 0xb4, 0xb9, 0xf5, 0xb6, 0x2d, 0xc2, 0x4f, 0xdf, 0xe4, 0xc6, + 0x7f, 0xea, 0x99, 0x73, 0xb9, 0xf1, 0x67, 0xfe, 0xc9, 0xe3, 0xd1, 0xcb, + 0x14, 0x7b, 0x7a, 0xb9, 0xf1, 0x9f, 0xfc, 0xa9, 0x7b, 0x72, 0xe3, 0x87, + 0xba, 0x4b, 0xb9, 0xf1, 0xc6, 0x3b, 0x9e, 0xbf, 0xe9, 0x87, 0x58, 0x78, + 0xbf, 0x9f, 0xfc, 0x90, 0xfc, 0x7b, 0x4f, 0x1e, 0xcf, 0x8d, 0xff, 0x97, + 0xe1, 0x2b, 0xc1, 0x4f, 0xb0, 0x4b, 0xc3, 0xec, 0x77, 0x47, 0x37, 0xf8, + 0x1f, 0xbb, 0x77, 0x34, 0xce, 0x8d, 0xdf, 0xd5, 0x1d, 0x45, 0x2f, 0x73, + 0x57, 0x27, 0xb8, 0xef, 0x17, 0x0e, 0x00, 0x20, 0x4e, 0x70, 0x00, 0x00, + 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, + 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, + 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, + 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, + 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, + 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, + 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, + 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, + 0x00, 0x82, 0x03, 0x00, 0x60, 0x56, 0xaa, 0xba, 0x2d, 0x72, 0xeb, 0x37, + 0xeb, 0xc5, 0xe8, 0xd3, 0x17, 0x6d, 0x70, 0xbc, 0x57, 0x06, 0xd7, 0x77, + 0x7d, 0xf5, 0x4c, 0xf4, 0x32, 0xe7, 0xde, 0xbf, 0x37, 0xf8, 0xa2, 0xf9, + 0xe8, 0xe1, 0xdc, 0x78, 0xe3, 0x4d, 0xc9, 0xff, 0x57, 0x8a, 0xe0, 0x27, + 0xf0, 0x42, 0x27, 0x38, 0xde, 0xdf, 0x11, 0xfc, 0x78, 0xbf, 0xf0, 0x99, + 0x13, 0xd1, 0xab, 0x5f, 0xff, 0xdc, 0x0f, 0x73, 0xe3, 0xf7, 0x97, 0xc3, + 0xdc, 0xf8, 0x60, 0x3c, 0x8d, 0x5e, 0xa6, 0x4d, 0x7e, 0xab, 0xfa, 0x85, + 0x03, 0x00, 0x88, 0x13, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, + 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, + 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, + 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, + 0x08, 0x0e, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, + 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, + 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, + 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, + 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x98, + 0x95, 0xea, 0xe4, 0xc2, 0x5a, 0x6e, 0xbd, 0x0e, 0x3f, 0x7d, 0x5d, 0x14, + 0xb9, 0xf1, 0x72, 0xd2, 0xe4, 0xc6, 0x07, 0xeb, 0xa3, 0xe8, 0x65, 0xee, + 0x7b, 0xfa, 0x48, 0x6e, 0xfc, 0xee, 0x5e, 0xdf, 0x3b, 0x07, 0xfe, 0xdf, + 0x77, 0x7a, 0x6b, 0x33, 0x37, 0x7e, 0xee, 0x5b, 0xe7, 0x73, 0xe3, 0x3b, + 0xbf, 0x75, 0x29, 0x7a, 0x99, 0x33, 0xc7, 0x56, 0x73, 0xe3, 0x1f, 0x7c, + 0xf6, 0x6a, 0x6e, 0xbc, 0x5d, 0x2c, 0xa2, 0x97, 0x99, 0xb6, 0xc1, 0x7d, + 0xbf, 0x70, 0x00, 0x00, 0x71, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x80, + 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, + 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, + 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, + 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, + 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, + 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, + 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, + 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, + 0x00, 0xb3, 0x52, 0x2d, 0x26, 0x93, 0xe3, 0x8f, 0x3e, 0x70, 0x7f, 0xf4, + 0xe9, 0xef, 0x7b, 0xf9, 0x7a, 0x6e, 0x7c, 0x7d, 0xb0, 0x98, 0x1b, 0xbf, + 0xf1, 0x8f, 0xdf, 0x1b, 0xbd, 0x4c, 0x77, 0xd2, 0xe4, 0xc6, 0x7f, 0x62, + 0xe7, 0x6a, 0x6e, 0xbc, 0xee, 0xb4, 0xde, 0x96, 0xf8, 0x9b, 0x6f, 0x26, + 0x9e, 0x7b, 0xed, 0x4a, 0x6e, 0xbc, 0xd9, 0x9c, 0xe4, 0xc6, 0xef, 0xb9, + 0x7c, 0x3b, 0x7a, 0xf6, 0xe3, 0xeb, 0xc1, 0xfd, 0xad, 0xb2, 0xca, 0x8d, + 0x5f, 0xae, 0xfb, 0xd1, 0xcb, 0x94, 0x75, 0x3b, 0xa7, 0xaf, 0x76, 0x00, + 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, + 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, + 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, + 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, + 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, + 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, + 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, + 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, + 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x80, 0x59, 0xaa, 0x7a, + 0xb7, 0x27, 0xc1, 0xf9, 0x6e, 0x11, 0x7d, 0xfa, 0x57, 0x7f, 0xe1, 0x68, + 0x6e, 0xbc, 0x9c, 0x36, 0xc1, 0xd0, 0xfb, 0xc3, 0x53, 0xd1, 0xcb, 0xdc, + 0xfb, 0xef, 0x3e, 0x9c, 0x1b, 0x6f, 0x3b, 0xed, 0x9c, 0x8e, 0x17, 0x9d, + 0xc2, 0x7b, 0x9e, 0xbf, 0xd9, 0x0b, 0xb2, 0x6d, 0xa3, 0xfb, 0x0b, 0x45, + 0xf0, 0xaf, 0xbe, 0xad, 0xeb, 0x5b, 0xb9, 0xf1, 0x7a, 0x6d, 0x31, 0x37, + 0x7e, 0xfa, 0xfd, 0xfb, 0xa2, 0x67, 0xbf, 0x75, 0x6d, 0x39, 0xf8, 0xdd, + 0xf1, 0xe2, 0xa5, 0xdc, 0xf8, 0x0b, 0xab, 0xab, 0xd9, 0x17, 0x64, 0x1d, + 0x7c, 0xc1, 0xfb, 0x85, 0x03, 0x00, 0x88, 0x13, 0x1c, 0x00, 0x80, 0xe0, + 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, + 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, + 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, + 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, + 0x0e, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, + 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, + 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, + 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x80, + 0xe0, 0x00, 0x00, 0x98, 0x95, 0xea, 0xbf, 0x3f, 0x7e, 0x2c, 0xb7, 0x7e, + 0xfc, 0xc0, 0xae, 0xe8, 0xd3, 0xef, 0xff, 0xe2, 0x8b, 0xb9, 0xf1, 0xe1, + 0x42, 0x99, 0x1b, 0x7f, 0x73, 0x6d, 0x25, 0x7a, 0x99, 0x1f, 0xfe, 0xfe, + 0xcb, 0xb9, 0xf1, 0xde, 0x67, 0x8b, 0xe0, 0x6b, 0xe6, 0xc1, 0xbd, 0xb9, + 0xf1, 0x03, 0x65, 0x2f, 0xfb, 0x7e, 0x2a, 0x8a, 0x0e, 0x3f, 0xf6, 0x30, + 0xd9, 0x3f, 0x9b, 0x82, 0xf3, 0x9b, 0x45, 0x1d, 0xbd, 0xcc, 0x17, 0x9f, + 0x3d, 0x9d, 0x1b, 0x1f, 0x7f, 0xf5, 0x6c, 0x6e, 0xfc, 0xe8, 0x38, 0x78, + 0x99, 0x3d, 0xcf, 0x5e, 0x8a, 0x9e, 0xfd, 0xd2, 0x4f, 0x1f, 0xca, 0x8d, + 0xff, 0xc5, 0xfe, 0xe0, 0xc7, 0xfb, 0x91, 0xcb, 0x9b, 0xd1, 0xcb, 0x7c, + 0xe2, 0xf4, 0xeb, 0xc9, 0xb7, 0x2a, 0x00, 0x40, 0x98, 0xe0, 0x00, 0x00, + 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, + 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, + 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, + 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, + 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, + 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, + 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, + 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, + 0x00, 0x04, 0x07, 0x00, 0xc0, 0xac, 0x54, 0xbb, 0x6f, 0x0c, 0x73, 0xeb, + 0x4f, 0xfc, 0xe0, 0xaf, 0xb3, 0xb9, 0x94, 0xec, 0xa5, 0xab, 0x4d, 0x2f, + 0x37, 0x7e, 0xfa, 0xe7, 0xef, 0x8d, 0x5e, 0xa6, 0xb8, 0xab, 0x9f, 0x1b, + 0x7f, 0xe7, 0x2f, 0x2f, 0xe4, 0xc6, 0x5f, 0x7b, 0xe9, 0x6a, 0x6e, 0xfc, + 0xb3, 0x9f, 0x7a, 0x5f, 0xf4, 0xec, 0x2b, 0x73, 0x5b, 0xf0, 0xb7, 0xda, + 0x49, 0x74, 0xff, 0xad, 0x9b, 0x9b, 0xb9, 0xf1, 0x57, 0x2f, 0xbc, 0x9b, + 0x1b, 0x3f, 0xf3, 0xfd, 0xcb, 0xd1, 0xcb, 0xdc, 0x73, 0x70, 0x25, 0x37, + 0x3e, 0x78, 0xf1, 0x46, 0x6e, 0xfc, 0xe1, 0x4b, 0x37, 0x73, 0xe3, 0x3b, + 0xea, 0x69, 0xf4, 0xec, 0xcb, 0xa7, 0x82, 0x97, 0xb9, 0xb1, 0xdc, 0xcd, + 0x8d, 0xff, 0xec, 0x8f, 0x4e, 0x47, 0x2f, 0xb3, 0xa7, 0xda, 0x0e, 0x7e, + 0x65, 0x6b, 0x2e, 0x00, 0x20, 0x4d, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, + 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, + 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, + 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, + 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, + 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, + 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, 0x01, + 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, + 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, + 0x00, 0x60, 0x56, 0xaa, 0xfb, 0x97, 0xa7, 0xb9, 0xf5, 0xdd, 0xe5, 0x24, + 0xfa, 0xf4, 0x8b, 0x0b, 0x6d, 0x6e, 0xbc, 0x08, 0x6e, 0x77, 0x7e, 0xf9, + 0x8f, 0x5e, 0x8a, 0x5e, 0xe6, 0xd4, 0x89, 0xbb, 0x72, 0xe3, 0xd3, 0x1b, + 0xe3, 0xdc, 0xf8, 0xa5, 0xdf, 0x3c, 0x91, 0x1b, 0xff, 0xdd, 0xcf, 0x7d, + 0x37, 0x7a, 0xf6, 0xbb, 0x56, 0x97, 0x82, 0x2f, 0xc8, 0x2a, 0xf8, 0xe7, + 0xc1, 0xf5, 0x73, 0x1b, 0xd1, 0xcb, 0x0c, 0xf6, 0x0f, 0x72, 0xe3, 0xe3, + 0xe7, 0xae, 0x05, 0xff, 0x4f, 0xdf, 0xc8, 0x5e, 0xe6, 0xc2, 0x53, 0xfb, + 0x72, 0xe3, 0x0f, 0x1c, 0x0c, 0xbe, 0x20, 0x0f, 0x9e, 0xbb, 0x94, 0x1b, + 0xef, 0x37, 0x4d, 0xf4, 0xec, 0xcd, 0x1b, 0x57, 0x73, 0xe3, 0x6f, 0x7c, + 0xf4, 0x81, 0xdc, 0xf8, 0xf3, 0x7b, 0xf6, 0x44, 0x2f, 0xb3, 0xb9, 0x51, + 0xe5, 0xc6, 0xfd, 0xc2, 0x01, 0x00, 0xc4, 0x09, 0x0e, 0x00, 0x40, 0x70, + 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, + 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, + 0x03, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, + 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, + 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, + 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, + 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, + 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, + 0x70, 0x00, 0x00, 0xcc, 0x4a, 0xf5, 0xc1, 0x53, 0xe7, 0x73, 0xeb, 0x2b, + 0xd5, 0x34, 0xfa, 0xf4, 0x45, 0xd1, 0xe6, 0xc6, 0x97, 0x9a, 0xe0, 0xc3, + 0x17, 0x75, 0xf6, 0xff, 0x75, 0xd7, 0x6b, 0xc1, 0x87, 0x3f, 0xb3, 0xb4, + 0x9c, 0x1b, 0x7f, 0xf5, 0xf2, 0x30, 0x37, 0xfe, 0xe0, 0x77, 0x2f, 0x45, + 0xcf, 0xfe, 0xee, 0xf1, 0xd5, 0xe0, 0x7b, 0xf5, 0xee, 0x1d, 0xb9, 0xf1, + 0xe3, 0x7f, 0x71, 0x3e, 0x7a, 0x99, 0x1b, 0x9f, 0x7e, 0x30, 0xf8, 0x6a, + 0x3f, 0xb5, 0x9e, 0x1b, 0x3f, 0x7c, 0x61, 0x3d, 0x7a, 0x99, 0x95, 0x5d, + 0x65, 0x6e, 0x7c, 0x79, 0x63, 0x9c, 0x1b, 0xdf, 0x51, 0x07, 0x3f, 0x64, + 0x56, 0x3a, 0xd9, 0xef, 0x8e, 0xdd, 0xc5, 0x28, 0x37, 0xbe, 0xf6, 0xe7, + 0xa7, 0x72, 0xe3, 0x5f, 0xfb, 0xe7, 0x1f, 0x89, 0x5e, 0x66, 0xf2, 0x07, + 0x2f, 0xe4, 0xc6, 0xfd, 0xc2, 0x01, 0x00, 0xc4, 0x09, 0x0e, 0x00, 0x40, + 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, + 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, + 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, + 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, + 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, + 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, + 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, + 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, + 0x40, 0x70, 0x00, 0x00, 0xcc, 0x4a, 0x75, 0xef, 0xd2, 0x56, 0x6e, 0xbd, + 0x69, 0x8b, 0xe8, 0xd3, 0x0f, 0x9b, 0x32, 0xf8, 0xf0, 0x45, 0x9b, 0x1b, + 0x1f, 0x14, 0x75, 0x36, 0x24, 0xeb, 0xe0, 0xc3, 0x6f, 0x17, 0xc1, 0xff, + 0xd6, 0xbd, 0xc9, 0xf1, 0x63, 0x57, 0x37, 0xa3, 0x67, 0xbf, 0xf6, 0xe1, + 0x83, 0xb9, 0xf1, 0x23, 0xff, 0xf3, 0xed, 0xdc, 0xf8, 0xfd, 0x57, 0x6f, + 0x47, 0x2f, 0x73, 0xe5, 0x73, 0x2f, 0xe4, 0xc6, 0x5f, 0xfa, 0xd5, 0x07, + 0x73, 0xe3, 0xbb, 0x4f, 0x5f, 0x8b, 0x5e, 0xe6, 0x3d, 0xcf, 0xbc, 0x95, + 0x1b, 0xef, 0xb7, 0xc1, 0xcf, 0x99, 0xa3, 0x0b, 0x77, 0x82, 0xdf, 0x4c, + 0xc9, 0x8f, 0xdf, 0x4e, 0xa7, 0x33, 0x49, 0x7e, 0x37, 0xbd, 0xb1, 0xb2, + 0x33, 0x37, 0xfe, 0x81, 0xff, 0xf4, 0x7c, 0xf4, 0x32, 0x9b, 0xfb, 0x83, + 0x0f, 0xef, 0x17, 0x0e, 0x00, 0x20, 0x4e, 0x70, 0x00, 0x00, 0x82, 0x03, + 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x80, + 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, + 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, + 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, + 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, + 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, + 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, + 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, + 0x03, 0x00, 0x60, 0x56, 0xaa, 0x41, 0x55, 0xe7, 0xd6, 0xcb, 0xa2, 0x8d, + 0x3e, 0x7d, 0xbf, 0x0e, 0x3e, 0xfc, 0xe5, 0xed, 0x7e, 0x6e, 0x7c, 0xab, + 0x29, 0xa3, 0x97, 0xf9, 0xf2, 0x47, 0x1f, 0xca, 0x8d, 0x6f, 0x27, 0x9f, + 0xfc, 0x91, 0x2f, 0x9c, 0xca, 0x8d, 0x3f, 0x38, 0xdc, 0x8c, 0x9e, 0x7d, + 0xd7, 0x57, 0x5f, 0xcd, 0x8d, 0x1f, 0xb9, 0x11, 0x7c, 0xf8, 0x61, 0x91, + 0xfd, 0xdb, 0xa3, 0x6e, 0x8b, 0xdc, 0xf8, 0x9d, 0x2a, 0xf8, 0xe4, 0x3b, + 0x27, 0xd3, 0xe8, 0x65, 0x76, 0x36, 0x93, 0xdc, 0xf8, 0xfe, 0xce, 0x28, + 0x37, 0x1e, 0xfd, 0xee, 0xe8, 0x64, 0xbf, 0x3a, 0x3a, 0x83, 0x85, 0x26, + 0x37, 0xfe, 0xf4, 0xf0, 0x62, 0xf0, 0xad, 0x34, 0x2c, 0xa2, 0x97, 0x79, + 0xa9, 0xda, 0x97, 0x1b, 0xf7, 0x0b, 0x07, 0x00, 0x10, 0x27, 0x38, 0x00, + 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, + 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, + 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, + 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, + 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x80, + 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, + 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, + 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, + 0x00, 0x00, 0xc1, 0x01, 0x00, 0x30, 0x2b, 0xd5, 0xce, 0xfe, 0x38, 0xb7, + 0x7e, 0x67, 0xd4, 0x8d, 0x3e, 0xfd, 0x52, 0x55, 0xe7, 0xc6, 0x6f, 0x2d, + 0xf5, 0x73, 0xe3, 0x5f, 0x7e, 0xec, 0x44, 0xf4, 0x32, 0xfb, 0xaf, 0x6d, + 0xe4, 0xc6, 0x1f, 0x78, 0xfb, 0x46, 0x6e, 0xfc, 0xb5, 0x87, 0xf7, 0xe5, + 0xc6, 0xef, 0x7e, 0xfe, 0x7a, 0xf4, 0xec, 0x8f, 0xdd, 0x5a, 0xcf, 0x8d, + 0x8f, 0x17, 0x82, 0x7f, 0x1e, 0x5c, 0x6f, 0x7a, 0xd1, 0xcb, 0x7c, 0xe5, + 0xe3, 0x8f, 0xe6, 0xc6, 0x0f, 0x0d, 0x83, 0x4f, 0x7e, 0x75, 0xd7, 0x52, + 0xf4, 0x32, 0xc7, 0x6f, 0x6c, 0xe6, 0xc6, 0xcb, 0xb6, 0xcd, 0x8d, 0x17, + 0x9d, 0xe0, 0x78, 0xb5, 0xd0, 0x46, 0xcf, 0xbe, 0xda, 0x9d, 0x24, 0xbf, + 0x98, 0xa6, 0xf3, 0xdb, 0x04, 0x6b, 0xeb, 0xef, 0xe4, 0xc6, 0xfd, 0xc2, + 0x01, 0x00, 0xc4, 0x09, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, + 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, + 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, + 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, + 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, + 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, + 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, + 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, + 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0xcc, + 0x4a, 0xb5, 0x58, 0x35, 0xb9, 0xf5, 0x72, 0x61, 0x12, 0x7d, 0xfa, 0x8d, + 0x61, 0x37, 0x37, 0xbe, 0xe3, 0xf6, 0x28, 0x78, 0x99, 0xb5, 0xe5, 0xe8, + 0x65, 0x1e, 0x7f, 0xf5, 0x9d, 0xdc, 0xf8, 0x89, 0xad, 0x9b, 0xb9, 0xf1, + 0xcd, 0x9b, 0x2b, 0xb9, 0xf1, 0x9d, 0x45, 0xf6, 0x05, 0xd9, 0x2d, 0xda, + 0xe4, 0x78, 0x1d, 0x3c, 0x7b, 0xdb, 0x44, 0x2f, 0xf3, 0xc0, 0x5f, 0x07, + 0x5f, 0x90, 0x6b, 0x1b, 0xdb, 0xb9, 0xf1, 0xbf, 0x7c, 0xe2, 0x70, 0xf6, + 0xad, 0xfa, 0xed, 0xeb, 0xb9, 0xf1, 0xd5, 0xe4, 0x0b, 0xb2, 0x69, 0x8b, + 0xdc, 0xf8, 0x52, 0x39, 0x8d, 0x9e, 0x7d, 0xb1, 0x0c, 0xbe, 0x9b, 0xda, + 0xe4, 0x65, 0xaa, 0x32, 0xfb, 0x56, 0x3d, 0xb0, 0xbc, 0x95, 0x1b, 0xf7, + 0x0b, 0x07, 0x00, 0x10, 0x27, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, + 0x0e, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, + 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, 0x40, + 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, + 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, + 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, + 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, + 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, + 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, + 0x30, 0x2b, 0xd5, 0x72, 0x7f, 0x32, 0xbf, 0x4f, 0x3f, 0xaa, 0x83, 0xc1, + 0xf4, 0xfd, 0xfe, 0x9e, 0xdc, 0xf8, 0xe3, 0xcf, 0xbd, 0x1e, 0xbd, 0xcc, + 0x93, 0x93, 0x2b, 0xb9, 0xf1, 0xdd, 0xfd, 0x71, 0x6e, 0xbc, 0x3e, 0x77, + 0x2e, 0x37, 0xbe, 0x5a, 0x8d, 0xa3, 0x67, 0x5f, 0xeb, 0x06, 0xdf, 0x4d, + 0xe5, 0x42, 0x9b, 0x1b, 0x5f, 0x9a, 0xd4, 0xd1, 0xcb, 0x7c, 0xfa, 0xca, + 0x99, 0xdc, 0xf8, 0x7a, 0xa7, 0x9b, 0x1b, 0xdf, 0xb8, 0xb1, 0x1a, 0xbd, + 0xcc, 0xb7, 0xdf, 0x77, 0x5f, 0x6e, 0xfc, 0xa9, 0x53, 0x17, 0x83, 0xef, + 0xa6, 0xc9, 0x8d, 0xdc, 0x78, 0x31, 0xcf, 0x7f, 0x6a, 0x57, 0x65, 0x13, + 0x7c, 0xab, 0x76, 0xb3, 0x6f, 0xd5, 0xa5, 0xc5, 0xe9, 0x9c, 0x9e, 0x1d, + 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, + 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, + 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, + 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, + 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, + 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, + 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, + 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, + 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x60, 0x96, 0xaa, + 0x85, 0x64, 0x72, 0xd4, 0x75, 0x11, 0x7d, 0xfa, 0x3d, 0x3b, 0xb6, 0x73, + 0xe3, 0xbf, 0x5e, 0x5e, 0xca, 0x8d, 0x3f, 0x7b, 0x69, 0x25, 0x7a, 0x99, + 0xa3, 0xbb, 0xef, 0x24, 0x5f, 0x34, 0x4d, 0x6e, 0xfc, 0x83, 0x83, 0x49, + 0xf0, 0x2e, 0x93, 0xec, 0xdb, 0xa9, 0x6e, 0x83, 0x2f, 0xf8, 0xa2, 0x68, + 0x73, 0xe3, 0x77, 0x95, 0x75, 0xf8, 0x2f, 0x9b, 0x5e, 0x6e, 0xbc, 0xd7, + 0x04, 0x5f, 0x90, 0xbf, 0xf4, 0xca, 0xe9, 0xe8, 0x65, 0x2e, 0x8e, 0x16, + 0x73, 0xe3, 0x5f, 0xfb, 0xd5, 0xc7, 0x72, 0xe3, 0x77, 0x7f, 0xf3, 0x64, + 0x6e, 0x7c, 0x35, 0xfd, 0x5e, 0x4d, 0x5a, 0xea, 0x06, 0xdf, 0x4d, 0x0b, + 0xc9, 0xcf, 0x81, 0xf4, 0xe7, 0x8c, 0x5f, 0x38, 0x00, 0x80, 0x38, 0xc1, + 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, + 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, + 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, + 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, + 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, + 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, + 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, + 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, + 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x80, 0x59, 0xa9, 0x96, 0x96, 0x26, + 0xb9, 0xf5, 0xba, 0xce, 0x06, 0xcd, 0x74, 0x5a, 0xe4, 0xc6, 0x77, 0x6c, + 0x6d, 0xe7, 0xc6, 0x77, 0x1f, 0x59, 0x89, 0x5e, 0x66, 0xb5, 0x1e, 0xe5, + 0xc6, 0xfb, 0x8b, 0x75, 0x6e, 0xbc, 0x28, 0xda, 0xe0, 0x0b, 0x26, 0xfc, + 0x82, 0xdc, 0x1a, 0x55, 0xb9, 0xf1, 0xe1, 0x38, 0x38, 0x3e, 0x6d, 0xb2, + 0x97, 0xe9, 0x97, 0x75, 0x67, 0x3e, 0x6d, 0x2d, 0x64, 0x9f, 0x7c, 0xb5, + 0x9b, 0x7c, 0x37, 0xed, 0xe9, 0x07, 0xbf, 0x3c, 0x26, 0xc1, 0x27, 0x9f, + 0x2e, 0x14, 0xd9, 0x17, 0x64, 0x77, 0x5e, 0x3f, 0xc4, 0x16, 0x16, 0xda, + 0xce, 0xdc, 0xf2, 0x0b, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, + 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, + 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, + 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, + 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, + 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, + 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, + 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, + 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, + 0x07, 0x00, 0x30, 0x37, 0xaa, 0xb2, 0xdb, 0xe4, 0xd6, 0xbb, 0xfd, 0x3a, + 0xfa, 0xf4, 0x6d, 0x53, 0xe4, 0xc6, 0x8f, 0x0d, 0xd6, 0x73, 0xe3, 0x87, + 0x46, 0xb7, 0xa3, 0x97, 0x99, 0x4c, 0xca, 0xdc, 0x78, 0x5d, 0x17, 0x73, + 0xfb, 0x72, 0x6f, 0xa2, 0xfb, 0x8b, 0xdd, 0xe8, 0xfe, 0x34, 0x37, 0x3d, + 0x1c, 0x57, 0xd1, 0xcb, 0xf4, 0xca, 0xe0, 0x6b, 0xa6, 0x6e, 0x82, 0x7f, + 0x38, 0x75, 0x8b, 0x36, 0x7a, 0x99, 0x69, 0x11, 0x7c, 0xf8, 0x5e, 0x27, + 0xf8, 0x39, 0xf0, 0xf5, 0x23, 0x87, 0x73, 0xe3, 0x4f, 0x5e, 0xbd, 0x1a, + 0x3d, 0xfb, 0xbd, 0xc5, 0x9d, 0xe4, 0x7c, 0xf4, 0x13, 0x32, 0xfb, 0x82, + 0x8c, 0xf2, 0x0b, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, + 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, + 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, + 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, + 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, + 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, + 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, + 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, + 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, + 0x00, 0x30, 0x37, 0xaa, 0xee, 0x62, 0x93, 0x5b, 0x2f, 0x16, 0xda, 0xe8, + 0xd3, 0xb7, 0xc9, 0xf9, 0xb6, 0x29, 0x72, 0xe3, 0xe5, 0x62, 0x1d, 0xbd, + 0xcc, 0x78, 0x58, 0xe5, 0xc6, 0x9b, 0xe4, 0x65, 0xc6, 0xe3, 0x32, 0x37, + 0x3e, 0x9d, 0x66, 0x0b, 0xbb, 0x57, 0x05, 0xff, 0x5b, 0x47, 0xc9, 0xcb, + 0x2c, 0x2d, 0x4e, 0xa3, 0x97, 0x99, 0x26, 0x5f, 0x33, 0xd1, 0x4f, 0x99, + 0xa2, 0xc9, 0x7e, 0x88, 0x9d, 0xdc, 0xb5, 0x96, 0x1b, 0x1f, 0x7c, 0xf3, + 0x74, 0x6e, 0xfc, 0x23, 0x17, 0x2f, 0xe6, 0xc6, 0x4f, 0xf4, 0x6e, 0x67, + 0xbf, 0x3b, 0x3a, 0xc9, 0x17, 0x64, 0x9b, 0x7d, 0xcd, 0xcc, 0x2f, 0xbf, + 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, + 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, + 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, + 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, + 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, + 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, + 0x08, 0x0e, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, + 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, + 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x73, + 0xa3, 0xea, 0x2d, 0x4f, 0x72, 0xeb, 0x45, 0xd1, 0xce, 0xef, 0x69, 0x9a, + 0xba, 0xc8, 0x8d, 0x8f, 0x87, 0x55, 0xf4, 0xe1, 0x7b, 0x83, 0x69, 0x6e, + 0x7c, 0xfb, 0x4e, 0x37, 0x37, 0xde, 0xef, 0x07, 0x9f, 0x7c, 0x32, 0x29, + 0xa3, 0x67, 0x1f, 0x8d, 0xca, 0xb9, 0x7d, 0xbd, 0x17, 0xd1, 0xf5, 0xb6, + 0x0d, 0xee, 0x4f, 0x93, 0xe3, 0x1b, 0x9d, 0x6e, 0xf4, 0x32, 0xe7, 0x1f, + 0xda, 0x13, 0x1c, 0x1f, 0x2c, 0xe5, 0xc6, 0x7f, 0xed, 0xe6, 0x85, 0xe0, + 0x37, 0x53, 0xf8, 0xbb, 0x63, 0x52, 0x07, 0xff, 0xd8, 0xae, 0xca, 0x69, + 0x87, 0x1f, 0xc7, 0x2f, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, + 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, + 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, + 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, + 0x08, 0x0e, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, + 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, + 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, + 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, + 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, + 0x1c, 0x00, 0xc0, 0xdc, 0xa8, 0x8a, 0x22, 0xba, 0x5f, 0xcc, 0xef, 0x69, + 0x8a, 0x64, 0x8c, 0xf5, 0x06, 0xd3, 0xe8, 0xc3, 0x6f, 0xdf, 0xe9, 0xe6, + 0xc6, 0x17, 0xfb, 0x75, 0x6e, 0x7c, 0x32, 0x0a, 0xde, 0xbd, 0xdb, 0xad, + 0xa3, 0x67, 0xaf, 0xeb, 0xf9, 0x7d, 0xc1, 0xb7, 0xd1, 0xf5, 0xab, 0xe3, + 0x7e, 0x6e, 0xfc, 0xdd, 0x49, 0xf0, 0xd5, 0x7e, 0xae, 0x5c, 0x8a, 0x5e, + 0x66, 0xdf, 0xeb, 0xb7, 0x72, 0xe3, 0xef, 0xbf, 0x73, 0x31, 0x37, 0xbe, + 0xd2, 0x04, 0x3f, 0xc4, 0x8a, 0x2a, 0xfb, 0x82, 0x1c, 0x4d, 0xcb, 0xe0, + 0xe7, 0x4c, 0xd9, 0x24, 0xbf, 0x53, 0x9b, 0xce, 0xdc, 0xf2, 0x0b, 0x07, + 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, + 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, + 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, + 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, + 0x00, 0x00, 0x82, 0x03, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, + 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, + 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, + 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, + 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x30, 0x37, 0x2a, + 0x27, 0xf8, 0x3f, 0x29, 0x8a, 0xe8, 0x7a, 0x1b, 0x7d, 0xf8, 0xb2, 0xdb, + 0xcc, 0xe9, 0x2c, 0x96, 0xde, 0xcd, 0x00, 0x00, 0x01, 0x91, 0x49, 0x44, + 0x41, 0x54, 0xd9, 0xdb, 0xb6, 0x9c, 0xdf, 0xd7, 0x4c, 0xaf, 0x57, 0x07, + 0x5f, 0x32, 0x9d, 0xe0, 0x6b, 0xe6, 0xd6, 0x56, 0x2f, 0x7a, 0x99, 0xf3, + 0xa3, 0xa5, 0xdc, 0xf8, 0xb3, 0x83, 0xb5, 0xdc, 0xf8, 0xa5, 0x13, 0xfb, + 0xa3, 0x97, 0x39, 0x7b, 0x78, 0x67, 0x6e, 0x7c, 0xf9, 0xcf, 0xde, 0xcc, + 0x8d, 0x0f, 0x87, 0xc1, 0xbf, 0x57, 0xb7, 0x9b, 0xec, 0xe7, 0x40, 0xb7, + 0x09, 0x7e, 0x42, 0x6e, 0x8d, 0x83, 0x5f, 0xac, 0xcb, 0xbd, 0x49, 0xfa, + 0xab, 0x2f, 0x37, 0xed, 0x17, 0x0e, 0x00, 0x20, 0x4e, 0x70, 0x00, 0x00, + 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, + 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, + 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, + 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, + 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, + 0x01, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, + 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, + 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, + 0x00, 0x82, 0x03, 0x00, 0x60, 0x56, 0xaa, 0xb6, 0x0d, 0xae, 0x17, 0x85, + 0x0b, 0xff, 0x78, 0x6d, 0x9b, 0x3d, 0x4d, 0xb5, 0x58, 0xe7, 0xc6, 0xeb, + 0x49, 0xb0, 0x53, 0x17, 0xfb, 0xd3, 0xdc, 0xf8, 0x64, 0x54, 0x85, 0xff, + 0x5b, 0x83, 0xe3, 0x2f, 0x6e, 0xac, 0xe6, 0xc6, 0x5f, 0xee, 0xad, 0x46, + 0x2f, 0xf3, 0x6e, 0xb7, 0x9b, 0x1b, 0x7f, 0xf6, 0x9f, 0xfe, 0x4c, 0x6e, + 0xfc, 0x37, 0xff, 0xd5, 0xd7, 0xa3, 0x97, 0x19, 0x3e, 0x1f, 0x1c, 0xff, + 0xd6, 0x93, 0x27, 0x72, 0xe3, 0xd7, 0xbe, 0xb7, 0x11, 0x7c, 0x2b, 0x4d, + 0xa3, 0x57, 0xef, 0xdc, 0x99, 0x96, 0xb9, 0xf1, 0xe5, 0xb5, 0xe0, 0xc7, + 0xfb, 0x78, 0x38, 0x8c, 0x5e, 0x66, 0xc7, 0xd2, 0x24, 0x37, 0xee, 0x17, + 0x0e, 0x00, 0x20, 0x4e, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, + 0x00, 0x00, 0x82, 0x03, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, + 0x10, 0x1c, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x10, 0x1c, 0x00, 0x80, 0xe0, + 0x00, 0x00, 0x04, 0x07, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x04, 0x07, 0x00, + 0x20, 0x38, 0x00, 0x00, 0x04, 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0x04, + 0x07, 0x00, 0x20, 0x38, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x20, 0x38, 0x00, + 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, + 0x0e, 0x00, 0x00, 0xc1, 0x01, 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, + 0x00, 0x08, 0x0e, 0x00, 0x40, 0x70, 0x00, 0x00, 0x82, 0x03, 0x00, 0x60, + 0x56, 0xfe, 0x37, 0x78, 0x5d, 0xa8, 0x59, 0xa3, 0x1a, 0x66, 0x14, 0x00, + 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 +}; + +static const unsigned int sEncodedBufferImageDataPNGLength = sizeof( sEncodedBufferImageDataPNG ); + +} // anonymous namespace + + + +// Positive test case for constructors: +int UtcDaliEncodedBufferImageNew01(void) +{ + TestApplication application; + + tet_infoline("UtcDaliEncodedBufferImageNew01() - EncodedBufferImage::New( const uint8_t * const encodedImage, const std::size_t encodedImageByteCount, const ImageAttributes& attributes, const ReleasePolicy releasePol )"); + + // Invoke default handle constructor for the Image base class: + Image image; + + DALI_TEST_CHECK( !image ); + + // Trigger image decode to initialise the handle + Dali::ImageAttributes imageAttributes; + imageAttributes.SetSize( 720, 1280 ); + imageAttributes.SetScalingMode( Dali::ImageAttributes::FitHeight ); + image = EncodedBufferImage::New( sEncodedBufferImageDataPNG, sEncodedBufferImageDataPNGLength, imageAttributes, Image::Never ); + + DALI_TEST_CHECK( image ); + + // Change the release policy to Unused: + Image image2; + + DALI_TEST_CHECK( !image2 ); + + // Trigger image decode to initialise the handle + image2 = EncodedBufferImage::New( sEncodedBufferImageDataPNG, sEncodedBufferImageDataPNGLength, imageAttributes, Image::Unused ); + + DALI_TEST_CHECK( image2 ); + END_TEST; +} + +// Negative test case for constructor - null pointer: +int UtcDaliEncodedBufferImageNew02(void) +{ + TestApplication application; + + tet_infoline("UtcDaliEncodedBufferImageNew02() - EncodedBufferImage::New( const uint8_t * const encodedImage, const std::size_t encodedImageByteCount, const ImageAttributes& attributes, const ReleasePolicy releasePol )"); + + // Invoke default handle constructor for the Image base class: + Image image; + + DALI_TEST_CHECK( !image ); + + // Trigger image decode to initialise the handle + Dali::ImageAttributes imageAttributes; + imageAttributes.SetSize( 720, 1280 ); + imageAttributes.SetScalingMode( Dali::ImageAttributes::FitHeight ); + try + { + // This should throw on the null pointer: + image = EncodedBufferImage::New( 0, sEncodedBufferImageDataPNGLength, imageAttributes, Image::Never ); + tet_result( TET_FAIL ); + } + catch (Dali::DaliException& e) + { + // Tests that a negative test of an assertion succeeds + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT_CONDITION_STARTS_WITH_SUBSTRING(e, "encodedImage && \"Null image pointer passed-in for decoding from memory.\"", TEST_LOCATION); + } + END_TEST; +} + +// Negative test case for constructor - zero-length input buffer: +int UtcDaliEncodedBufferImageNew03(void) +{ + TestApplication application; + + tet_infoline("UtcDaliEncodedBufferImageNew03() - EncodedBufferImage::New( const uint8_t * const encodedImage, const std::size_t encodedImageByteCount, const ImageAttributes& attributes, const ReleasePolicy releasePol )"); + + // Invoke default handle constructor for the Image base class: + Image image; + + DALI_TEST_CHECK( !image ); + + // Trigger image decode to initialise the handle + Dali::ImageAttributes imageAttributes; + try + { + // This should throw on the zero size: + image = EncodedBufferImage::New( sEncodedBufferImageDataPNG, /** Trigger the assertion.*/ 0, imageAttributes, Image::Never ); + tet_result( TET_FAIL ); + } + catch (Dali::DaliException& e) + { + // Tests that a negative test of an assertion succeeds + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT_CONDITION_STARTS_WITH_SUBSTRING(e, "encodedImageByteCount > 0U && \"Zero size passed for image resource in memory buffer.\"", TEST_LOCATION); + } + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-HitTestAlgorithm.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-HitTestAlgorithm.cpp new file mode 100644 index 0000000..9745187 --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-HitTestAlgorithm.cpp @@ -0,0 +1,404 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 +#include + +using namespace Dali; + +namespace +{ + +/** + * The functor to be used in the hit-test algorithm to check whether the actor is hittable. + */ +bool IsActorHittableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType type) +{ + bool hittable = false; + + switch (type) + { + case Dali::HitTestAlgorithm::CHECK_ACTOR: + { + // Check whether the actor is visible and not fully transparent. + if( actor.IsVisible() + && actor.GetCurrentWorldColor().a > 0.01f) // not FULLY_TRANSPARENT + { + // Check whether the actor has the specific name "HittableActor" + if(actor.GetName() == "HittableActor") + { + hittable = true; + } + } + break; + } + case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE: + { + if( actor.IsVisible() ) // Actor is visible, if not visible then none of its children are visible. + { + hittable = true; + } + break; + } + default: + { + break; + } + } + + return hittable; +}; + + +bool DefaultIsActorTouchableFunction(Dali::Actor actor, Dali::HitTestAlgorithm::TraverseType type) +{ + bool hittable = false; + + switch (type) + { + case Dali::HitTestAlgorithm::CHECK_ACTOR: + { + if( actor.IsVisible() && + actor.IsSensitive() && + actor.GetCurrentWorldColor().a > 0.01f) + { + hittable = true; + } + break; + } + case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE: + { + if( actor.IsVisible() && // Actor is visible, if not visible then none of its children are visible. + actor.IsSensitive()) // Actor is sensitive, if insensitive none of its children should be hittable either. + { + hittable = true; + } + break; + } + default: + { + break; + } + } + + return hittable; +}; + +} // anonymous namespace + + +// Positive test case for a method +int UtcDaliHitTestAlgorithmWithFunctor(void) +{ + TestApplication application; + tet_infoline("Testing Dali::HitTestAlgorithm functor"); + + Stage stage = Stage::GetCurrent(); + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + actor.SetName("NonHittableActor"); + stage.Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + Vector2 screenCoordinates( 10.0f, 10.0f ); + Vector2 localCoordinates; + actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y ); + + // Perform a hit-test at the given screen coordinates + Dali::HitTestAlgorithm::Results results; + Dali::HitTestAlgorithm::HitTest( stage, screenCoordinates, results, IsActorHittableFunction ); + DALI_TEST_CHECK( results.actor != actor ); + + actor.SetName("HittableActor"); + + results.actor = Actor(); + results.actorCoordinates = Vector2::ZERO; + + // Perform a hit-test at the given screen coordinates + Dali::HitTestAlgorithm::HitTest( stage, screenCoordinates, results, IsActorHittableFunction ); + DALI_TEST_CHECK( results.actor == actor ); + DALI_TEST_EQUALS( localCoordinates, results.actorCoordinates, 0.1f, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliHitTestAlgorithmWithFunctorOnRenderTask(void) +{ + TestApplication application; + tet_infoline("Testing Dali::HitTestAlgorithm functor, specific to a given render task"); + + Stage stage = Stage::GetCurrent(); + Size stageSize = stage.GetSize(); + RenderTaskList taskList = stage.GetRenderTaskList(); + + Actor actor[2]; + + for( int i=0; i<2; i++ ) + { + actor[i] = Actor::New(); + actor[i].SetSize(100.f, 100.f); + actor[i].SetParentOrigin(ParentOrigin::TOP_LEFT); + actor[i].SetAnchorPoint(AnchorPoint::TOP_LEFT); + actor[i].SetName("HittableActor"); + stage.Add(actor[i]); + } + Vector2 position( 50.f, 40.f ); + actor[1].SetPosition( position.x, position.y ); + + RenderTask renderTask[2]; + renderTask[0] = taskList.GetTask( 0u ); + + FrameBufferImage frameBufferImage = FrameBufferImage::New(stageSize.width, stageSize.height, Pixel::A8, Image::Never); + renderTask[1] = taskList.CreateTask(); + renderTask[1].SetSourceActor( actor[1] ); + renderTask[1].SetExclusive( true ); + renderTask[1].SetInputEnabled( true ); + renderTask[1].SetTargetFrameBuffer( frameBufferImage ); + renderTask[1].SetRefreshRate( RenderTask::REFRESH_ONCE ); + renderTask[1].SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION ); + + // Render and notify + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + + // Perform a hit-test at the given screen coordinates with different render tasks + + Dali::HitTestAlgorithm::Results results; + Vector2 screenCoordinates( 25.f, 25.f ); + + Dali::HitTestAlgorithm::HitTest( renderTask[0], screenCoordinates, results, IsActorHittableFunction ); + DALI_TEST_CHECK( results.actor == actor[0] ); + DALI_TEST_EQUALS( screenCoordinates, results.actorCoordinates, 0.1f, TEST_LOCATION ); + + results.actor = Actor(); + results.actorCoordinates = Vector2::ZERO; + Dali::HitTestAlgorithm::HitTest( renderTask[1], screenCoordinates, results, IsActorHittableFunction ); + DALI_TEST_CHECK( !results.actor ); + DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION ); + + screenCoordinates.x = 80.f; + screenCoordinates.y = 70.f; + + results.actor = Actor(); + results.actorCoordinates = Vector2::ZERO; + Dali::HitTestAlgorithm::HitTest( renderTask[0], screenCoordinates, results, IsActorHittableFunction ); + DALI_TEST_CHECK( results.actor == actor[0] ); + DALI_TEST_EQUALS( screenCoordinates, results.actorCoordinates, 0.1f, TEST_LOCATION ); + + results.actor = Actor(); + results.actorCoordinates = Vector2::ZERO; + Dali::HitTestAlgorithm::HitTest( renderTask[1], screenCoordinates, results, IsActorHittableFunction ); + DALI_TEST_CHECK( results.actor == actor[1]); + DALI_TEST_EQUALS( screenCoordinates - position, results.actorCoordinates, 0.1f, TEST_LOCATION ); + + + screenCoordinates.x = 120.f; + screenCoordinates.y = 130.f; + + results.actor = Actor(); + results.actorCoordinates = Vector2::ZERO; + Dali::HitTestAlgorithm::HitTest( renderTask[0], screenCoordinates, results, IsActorHittableFunction ); + DALI_TEST_CHECK( results.actor == actor[1] ); + DALI_TEST_EQUALS( screenCoordinates - position, results.actorCoordinates, 0.1f, TEST_LOCATION ); + + results.actor = Actor(); + results.actorCoordinates = Vector2::ZERO; + Dali::HitTestAlgorithm::HitTest( renderTask[1], screenCoordinates, results, IsActorHittableFunction ); + DALI_TEST_CHECK( results.actor == actor[1]); + DALI_TEST_EQUALS( screenCoordinates - position, results.actorCoordinates, 0.1f, TEST_LOCATION ); + END_TEST; +} + + +int UtcDaliHitTestAlgorithmOrtho01(void) +{ + TestApplication application; + tet_infoline("Testing Dali::HitTestAlgorithm with parallel Ortho camera()"); + + Stage stage = Stage::GetCurrent(); + RenderTaskList renderTaskList = stage.GetRenderTaskList(); + RenderTask defaultRenderTask = renderTaskList.GetTask(0u); + Dali::CameraActor cameraActor = defaultRenderTask.GetCameraActor(); + + Vector2 stageSize ( stage.GetSize() ); + cameraActor.SetOrthographicProjection( stageSize ); + cameraActor.SetPosition(0.0f, 0.0f, 1600.0f); + + Vector2 actorSize( stageSize * 0.5f ); + // Create two actors with half the size of the stage and set them to be partially overlapping + Actor blue = Actor::New(); + blue.SetName( "Blue" ); + blue.SetAnchorPoint( AnchorPoint::CENTER ); + blue.SetParentOrigin( Vector3(1.0f/3.0f, 1.0f/3.0f, 0.5f) ); + blue.SetSize( actorSize ); + blue.SetZ(30.0f); + + Actor green = Actor::New( ); + green.SetName( "Green" ); + green.SetAnchorPoint( AnchorPoint::CENTER ); + green.SetParentOrigin( Vector3(2.0f/3.0f, 2.0f/3.0f, 0.5f) ); + green.SetSize( actorSize ); + + // Add the actors to the view + stage.Add( blue ); + stage.Add( green ); + + // Render and notify + application.SendNotification(); + application.Render(0); + application.Render(10); + + HitTestAlgorithm::Results results; + HitTest(stage, Vector2( 240.0f, 400.0f ), results, &DefaultIsActorTouchableFunction); + DALI_TEST_CHECK( results.actor == blue ); + DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 5.0f/6.0f, TEST_LOCATION ); + + HitTest(stage, stageSize / 3.0f, results, &DefaultIsActorTouchableFunction); + DALI_TEST_CHECK( results.actor == blue ); + DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.5f, TEST_LOCATION ); + + HitTest(stage, stageSize * 2.0f / 3.0f, results, &DefaultIsActorTouchableFunction); + DALI_TEST_CHECK( results.actor == green ); + DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.5f, TEST_LOCATION ); + END_TEST; +} + + +int UtcDaliHitTestAlgorithmOrtho02(void) +{ + TestApplication application; + tet_infoline("Testing Dali::HitTestAlgorithm with offset Ortho camera()"); + + Stage stage = Stage::GetCurrent(); + RenderTaskList renderTaskList = stage.GetRenderTaskList(); + RenderTask defaultRenderTask = renderTaskList.GetTask(0u); + Dali::CameraActor cameraActor = defaultRenderTask.GetCameraActor(); + + Vector2 stageSize ( stage.GetSize() ); + cameraActor.SetOrthographicProjection(-stageSize.x * 0.3f, stageSize.x * 0.7f, + stageSize.y * 0.3f, -stageSize.y * 0.7f, + 800.0f, 4895.0f); + cameraActor.SetPosition(0.0f, 0.0f, 1600.0f); + + Vector2 actorSize( stageSize * 0.5f ); + // Create two actors with half the size of the stage and set them to be partially overlapping + Actor blue = Actor::New(); + blue.SetName( "Blue" ); + blue.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + blue.SetParentOrigin( Vector3(0.2f, 0.2f, 0.5f) ); + blue.SetSize( actorSize ); + blue.SetZ(30.0f); + + Actor green = Actor::New( ); + green.SetName( "Green" ); + green.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + green.SetParentOrigin( Vector3(0.4f, 0.4f, 0.5f) ); + green.SetSize( actorSize ); + + // Add the actors to the view + stage.Add( blue ); + stage.Add( green ); + + // Render and notify + application.SendNotification(); + application.Render(0); + application.Render(10); + + HitTestAlgorithm::Results results; + HitTest(stage, Vector2( 240.0f, 400.0f ), results, &DefaultIsActorTouchableFunction); + DALI_TEST_CHECK( results.actor == green ); + DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.6f, TEST_LOCATION ); + + HitTest(stage, Vector2::ZERO, results, &DefaultIsActorTouchableFunction); + DALI_TEST_CHECK( results.actor == blue ); + DALI_TEST_EQUALS( results.actorCoordinates, Vector2::ZERO, TEST_LOCATION ); + + HitTest(stage, stageSize, results, &DefaultIsActorTouchableFunction); + DALI_TEST_CHECK( ! results.actor ); + DALI_TEST_EQUALS( results.actorCoordinates, Vector2::ZERO, TEST_LOCATION ); + + // Just inside green + HitTest(stage, stageSize*0.69f, results, &DefaultIsActorTouchableFunction); + DALI_TEST_CHECK( results.actor == green ); + DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.98f, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliHitTestAlgorithmStencil(void) +{ + TestApplication application; + tet_infoline("Testing Dali::HitTestAlgorithm with a stencil"); + + Stage stage = Stage::GetCurrent(); + Actor rootLayer = stage.GetRootLayer(); + rootLayer.SetName( "RootLayer" ); + + // Create a layer + Layer layer = Layer::New(); + layer.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + layer.SetParentOrigin( ParentOrigin::TOP_LEFT ); + layer.SetName( "layer" ); + stage.Add( layer ); + + // Create a stencil and add that to the layer + Actor stencil = ImageActor::New(Dali::BitmapImage::WHITE() ); + stencil.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + stencil.SetParentOrigin( ParentOrigin::TOP_LEFT ); + stencil.SetSize( 50.0f, 50.0f ); + stencil.SetDrawMode( DrawMode::STENCIL ); + stencil.SetName( "stencil" ); + layer.Add( stencil ); + + // Create an actor and add that to the layer + Actor layerHitActor = Actor::New(); + layerHitActor.SetSize( 100.0f, 100.0f ); + layerHitActor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + layerHitActor.SetParentOrigin( ParentOrigin::TOP_LEFT ); + layerHitActor.SetName( "layerHitActor" ); + layer.Add( layerHitActor ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Hit within stencil and actor + { + HitTestAlgorithm::Results results; + HitTest(stage, Vector2( 10.0f, 10.0f ), results, &DefaultIsActorTouchableFunction); + DALI_TEST_CHECK( results.actor == layerHitActor ); + tet_printf( "Hit: %s\n", ( results.actor ? results.actor.GetName().c_str() : "NULL" ) ); + } + + // Hit within actor but outside of stencil, should hit the root-layer + { + HitTestAlgorithm::Results results; + HitTest(stage, Vector2( 60.0f, 60.0f ), results, &DefaultIsActorTouchableFunction); + DALI_TEST_CHECK( results.actor == rootLayer ); + tet_printf( "Hit: %s\n", ( results.actor ? results.actor.GetName().c_str() : "NULL" ) ); + } + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-LightActor.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-LightActor.cpp new file mode 100644 index 0000000..98cb7f5 --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-LightActor.cpp @@ -0,0 +1,304 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; + +#include "mesh-builder.h" + + +int UtcDaliLightActorConstructorVoid(void) +{ + TestApplication application; + tet_infoline("Testing Dali::LightActor::LightActor() UtcDaliLightActorConstructorVoid"); + + LightActor actor; + + DALI_TEST_CHECK(!actor); + END_TEST; +} + + +int UtcDaliLightActorDestructor(void) +{ + // This test is achieve 100% line and function coverage + TestApplication application; + tet_infoline("Testing Dali::LightActor::~LightActor() UtcDaliLightActorDestructor"); + + LightActor* actor = new LightActor; + + DALI_TEST_CHECK( ! *actor ); + + delete actor; + + DALI_TEST_CHECK( true ); + END_TEST; +} + +int UtcDaliLightActorNew(void) +{ + TestApplication application; + tet_infoline("Testing Dali::LightActor::New() UtcDaliLightActorNew"); + + LightActor actor = LightActor::New(); + + DALI_TEST_CHECK(actor); + END_TEST; +} + +int UtcDaliLightActorDownCast(void) +{ + TestApplication application; + tet_infoline("Testing Dali::LightActor::DownCast() UtcDaliLightActorDownCast"); + + LightActor actor1 = LightActor::New(); + Actor anActor = Actor::New(); + anActor.Add(actor1); + + Actor child = anActor.GetChildAt(0); + LightActor lightActor = LightActor::DownCast(child); + + DALI_TEST_CHECK(lightActor); + + Light light; + light = Light::New( "TestLight" ); + BaseHandle handle = light; + + DALI_TEST_CHECK( Light::DownCast( handle ) ); + END_TEST; +} + +int UtcDaliLightActorDownCast2(void) +{ + TestApplication application; + tet_infoline("Testing Dali::LightActor::DownCast2() UtcDaliLightActorDownCast2"); + + Actor actor1 = Actor::New(); + Actor anActor = Actor::New(); + anActor.Add(actor1); + + Actor child = anActor.GetChildAt(0); + LightActor lightActor = LightActor::DownCast(child); + DALI_TEST_CHECK(!lightActor); + + Actor unInitialzedActor; + lightActor = DownCast< LightActor >( unInitialzedActor ); + DALI_TEST_CHECK(!lightActor); + END_TEST; +} + +int UtcDaliLightActorSetGetLight(void) +{ + TestApplication application; + tet_infoline( "Testing UtcDaliLightActorSetGetLight" ); + + try + { + LightActor lightActor = LightActor::New(); + Light light1 = Light::New( "" ); + light1.SetName( "TestLight" ); + light1.SetDirection( Vector3::ZAXIS ); + light1.SetSpotAngle( Vector2::YAXIS ); + lightActor.SetLight( light1 ); + + Light light2 = lightActor.GetLight(); + + DALI_TEST_EQUALS( light1.GetName(), light2.GetName(), TEST_LOCATION ); + DALI_TEST_EQUALS( light1.GetType(), light2.GetType(), TEST_LOCATION ); + DALI_TEST_EQUALS( light1.GetFallOff(), light2.GetFallOff(), TEST_LOCATION ); + DALI_TEST_EQUALS( light1.GetSpotAngle(), light2.GetSpotAngle(), TEST_LOCATION ); + DALI_TEST_EQUALS( light1.GetAmbientColor(), light2.GetAmbientColor(), TEST_LOCATION ); + DALI_TEST_EQUALS( light1.GetDiffuseColor(), light2.GetDiffuseColor(), TEST_LOCATION ); + DALI_TEST_EQUALS( light1.GetSpecularColor(), light2.GetSpecularColor(), TEST_LOCATION ); + DALI_TEST_EQUALS( light1.GetDirection(), light2.GetDirection(), TEST_LOCATION ); + } + catch( Dali::DaliException& e ) + { + tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); + tet_result(TET_FAIL); + } + catch( ... ) + { + tet_infoline( "Unknown exception." ); + tet_result(TET_FAIL); + } + END_TEST; +} + +int UtcDaliLightActorSetGetActive(void) +{ + TestApplication application; + tet_infoline( "Testing UtcDaliLightActorSetGetActive" ); + + try + { + LightActor lightActor = LightActor::New(); + lightActor.SetActive( true ); + + DALI_TEST_CHECK( lightActor.GetActive() ); + + lightActor.SetActive( false ); + + DALI_TEST_CHECK( !lightActor.GetActive() ); + + lightActor.SetActive( true ); + + DALI_TEST_CHECK( lightActor.GetActive() ); + + lightActor.SetActive( false ); + + DALI_TEST_CHECK( !lightActor.GetActive() ); + } + catch( Dali::DaliException& e ) + { + tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); + tet_result(TET_FAIL); + } + catch( ... ) + { + tet_infoline( "Unknown exception." ); + tet_result(TET_FAIL); + } + END_TEST; +} + + +int UtcDaliLightActorMeshTest(void) +{ + TestApplication application; + tet_infoline( "Testing UtcDaliLightActorMeshTest" ); + + try + { + Mesh mesh = ConstructMesh( 50 ); + Actor actor = MeshActor::New( mesh ); + Stage::GetCurrent().Add( actor ); + + actor.SetParentOrigin( ParentOrigin::CENTER ); + actor.SetAnchorPoint( AnchorPoint::CENTER ); + actor.SetPosition( 0.0f, 0.0f, 0.0f ); + + Light light = Light::New("Light"); + light.SetType( POINT ); + light.SetAmbientColor( Vector3( 0.22f, 0.33f, 0.44f ) ); + light.SetDiffuseColor( Vector3( 0.55f, 0.66f, 0.77f) ); + light.SetSpecularColor( Vector3( 0.88f, 0.99f, 0.11f) ); + LightActor lightActor = LightActor::New(); + lightActor.SetParentOrigin( ParentOrigin::CENTER ); + lightActor.SetPosition( 0.f, 0.f, 100.0f ); + lightActor.SetLight( light ); + lightActor.SetName( light.GetName() ); + + Stage::GetCurrent().Add( lightActor ); + lightActor.SetActive( true ); + + application.SendNotification(); + application.Render(); + + // Test Ligh ambient. + DALI_TEST_CHECK( application.GetGlAbstraction().CheckUniformValue( "uLight0.mAmbient", Vector3( 0.22f, 0.33f, 0.44f ) ) ); + + // Test Ligh diffuse. + DALI_TEST_CHECK( application.GetGlAbstraction().CheckUniformValue( "uLight0.mDiffuse", Vector3( 0.55f, 0.66f, 0.77f ) ) ); + + // Test Ligh specular. + DALI_TEST_CHECK( application.GetGlAbstraction().CheckUniformValue( "uLight0.mSpecular", Vector3( 0.88f, 0.99f, 0.11f ) ) ); + + // Test Opacity. + DALI_TEST_CHECK( application.GetGlAbstraction().CheckUniformValue( "uMaterial.mOpacity", 0.76f ) ); + + // Test material Ambient color. + DALI_TEST_CHECK( application.GetGlAbstraction().CheckUniformValue( "uMaterial.mAmbient", Vector4(0.2f, 1.0f, 0.6f, 1.0f) ) ); + + // Test material Diffuse color. + DALI_TEST_CHECK( application.GetGlAbstraction().CheckUniformValue( "uMaterial.mDiffuse", Vector4(0.8f, 0.0f, 0.4f, 1.0f) ) ); + + // Test Specular color. + DALI_TEST_CHECK( application.GetGlAbstraction().CheckUniformValue( "uMaterial.mSpecular", Vector4(0.5f, 0.6f, 0.7f, 1.0f) ) ); + } + catch( Dali::DaliException& e ) + { + tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); + tet_result(TET_FAIL); + } + catch( ... ) + { + tet_infoline( "Unknown exception." ); + tet_result(TET_FAIL); + } + + DALI_TEST_CHECK( true ); + END_TEST; +} + +int UtcDaliLightActorDefaultProperties(void) +{ + TestApplication application; + tet_infoline("Testing Dali::LightActor DefaultProperties"); + + LightActor actor = LightActor::New(); + + std::vector indices ; + indices.push_back(LightActor::LIGHT_TYPE ); + indices.push_back(LightActor::ENABLE ); + indices.push_back(LightActor::FALL_OFF ); + indices.push_back(LightActor::SPOT_ANGLE ); + indices.push_back(LightActor::AMBIENT_COLOR ); + indices.push_back(LightActor::DIFFUSE_COLOR ); + indices.push_back(LightActor::SPECULAR_COLOR ); + indices.push_back(LightActor::DIRECTION ); + + DALI_TEST_CHECK(actor.GetPropertyCount() == ( Actor::New().GetPropertyCount() + indices.size() ) ); + + for(std::vector::iterator iter = indices.begin(); iter != indices.end(); ++iter) + { + DALI_TEST_CHECK( *iter == actor.GetPropertyIndex(actor.GetPropertyName(*iter)) ); + DALI_TEST_CHECK( actor.IsPropertyWritable(*iter) ); + DALI_TEST_CHECK( !actor.IsPropertyAnimatable(*iter) ); + DALI_TEST_CHECK( actor.GetPropertyType(*iter) == actor.GetPropertyType(*iter) ); // just checking call succeeds + } + + // set/get one of them + actor.GetLight().SetAmbientColor( Vector3( 0.f, 0.f, 0.f ) ); + Vector3 col( 0.22f, 0.33f, 0.44f ) ; + DALI_TEST_CHECK(actor.GetLight().GetAmbientColor() != col); + actor.SetProperty(LightActor::AMBIENT_COLOR, col); + Property::Value v = actor.GetProperty(LightActor::AMBIENT_COLOR); + DALI_TEST_CHECK(v.GetType() == Property::VECTOR3); + + DALI_TEST_CHECK(v.Get() == col); + + END_TEST; +} + +int UtcDaliLightActorPropertyIndices(void) +{ + TestApplication application; + Actor basicActor = Actor::New(); + LightActor light = LightActor::New(); + + Property::IndexContainer indices; + light.GetPropertyIndices( indices ); + DALI_TEST_CHECK( indices.size() > basicActor.GetPropertyCount() ); + DALI_TEST_EQUALS( indices.size(), light.GetPropertyCount(), TEST_LOCATION ); + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-LocklessBuffer.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-LocklessBuffer.cpp new file mode 100644 index 0000000..7e07b1a --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-LocklessBuffer.cpp @@ -0,0 +1,116 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; + +namespace +{ + +static bool ReadTest(Integration::LocklessBuffer& buf, const unsigned char exp[], size_t size) +{ + const unsigned char *res = buf.Read(); + for (size_t i=0; i + +#include +#include +#include + +using namespace Dali; + +#include + + +namespace +{ + +static Mesh NewMesh() +{ + MeshData meshData; + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + BoneContainer bones; + ConstructVertices(vertices, 60); + ConstructFaces(vertices, faces); + Material customMaterial = ConstructMaterial(); + meshData.SetData(vertices, faces, bones, customMaterial); + Mesh mesh = Mesh::New(meshData); + return mesh; +} + +} // anon mesh + + +int UtcDaliMeshActorNew02(void) +{ + TestApplication application; + TestPlatformAbstraction& platform = application.GetPlatform(); + + tet_infoline("Testing Dali::MeshActor::New()"); + + std::string modelName("AModel"); + Dali::ModelData modelData = Dali::ModelData::New(modelName); + Dali::Entity rootEntity = Dali::Entity::New("root"); + modelData.SetRootEntity(rootEntity); + rootEntity.SetType(Dali::Entity::OBJECT); + + Model model = Model::New("Fake model"); + + // Run Core - will query using TestPlatformAbstraction::GetResources(). + application.SendNotification(); + application.Render(); + + Integration::ResourceRequest* request = platform.GetRequest(); + if(request) + { + platform.SetResourceLoaded(request->GetId(), request->GetType()->id, Integration::ResourcePointer(&(modelData.GetBaseObject()))); + } + + application.Render(); + application.SendNotification(); + + Actor actor = ModelActorFactory::BuildActorTree(model, ""); // model should be loaded + + DALI_TEST_CHECK(model.GetLoadingState() == ResourceLoadingSucceeded); + DALI_TEST_CHECK(actor); + DALI_TEST_CHECK(actor.GetName().compare("root") == 0); + END_TEST; +} + + +int UtcDaliMeshActorCreateNoMeshData(void) +{ + TestApplication application; + tet_infoline("Testing Dali::Mesh::New() - Create with no mesh data"); + + try + { + MeshData meshData; + Mesh mesh = Mesh::New(meshData); + MeshActor actor1 = MeshActor::New(mesh); + } + catch(Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "object", TEST_LOCATION); + } + END_TEST; +} + + +int UtcDaliMeshActorCreateSetData01(void) +{ + TestApplication application; + tet_infoline("Testing Dali::MeshData::SetData() - Create with no verts"); + try + { + MeshData meshData; + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + BoneContainer bones; + Material customMaterial; + meshData.SetData(vertices, faces, bones, customMaterial); + Mesh mesh = Mesh::New(meshData); + MeshActor actor1 = MeshActor::New(mesh); + } + catch(Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "!vertices.empty()", TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliMeshActorCreateSetData02(void) +{ + TestApplication application; + tet_infoline("Testing Dali::MeshData::SetData - Create with no faces"); + try + { + MeshData meshData; + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + BoneContainer bones; + Material customMaterial; + ConstructVertices(vertices, 60); + meshData.SetData(vertices, faces, bones, customMaterial); + Mesh mesh = Mesh::New(meshData); + MeshActor actor1 = MeshActor::New(mesh); + } + catch(Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "!faceIndices.empty", TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliMeshActorCreateSetData03(void) +{ + TestApplication application; + tet_infoline("Testing Dali::MeshData::SetData - Create with no mats"); + try + { + MeshData meshData; + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + BoneContainer bones; + Material customMaterial; + ConstructVertices(vertices, 60); + ConstructFaces(vertices, faces); + meshData.SetData(vertices, faces, bones, customMaterial); + Mesh mesh = Mesh::New(meshData); + MeshActor actor1 = MeshActor::New(mesh); + } + catch(Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "material", TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliMeshActorCreateSetData04(void) +{ + TestApplication application; + tet_infoline("Testing Dali::MeshActor::SetData()"); + + MeshData meshData; + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + BoneContainer bones; + ConstructVertices(vertices, 60); + ConstructFaces(vertices, faces); + Material customMaterial = ConstructMaterial(); + meshData.SetData(vertices, faces, bones, customMaterial); + + Mesh mesh = Mesh::New(meshData); + MeshActor actor1 = MeshActor::New(mesh); + DALI_TEST_CHECK(actor1); + END_TEST; +} + + +int UtcDaliMeshActorDownCast(void) +{ + TestApplication application; + tet_infoline("Testing Dali::MeshActor::DownCast()"); + + MeshData meshData; + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + BoneContainer bones; + ConstructVertices(vertices, 60); + ConstructFaces(vertices, faces); + Material customMaterial = ConstructMaterial(); + meshData.SetData(vertices, faces, bones, customMaterial); + Mesh mesh = Mesh::New(meshData); + + MeshActor actor1 = MeshActor::New(mesh); + Actor anActor = Actor::New(); + anActor.Add(actor1); + + Actor child = anActor.GetChildAt(0); + MeshActor meshActor = MeshActor::DownCast(child); + + DALI_TEST_CHECK(meshActor); + END_TEST; +} + +int UtcDaliMeshActorDownCast2(void) +{ + TestApplication application; + tet_infoline("Testing Dali::MeshActor::DownCast()"); + + Actor actor1 = Actor::New(); + Actor anActor = Actor::New(); + anActor.Add(actor1); + + Actor child = anActor.GetChildAt(0); + MeshActor meshActor = MeshActor::DownCast(child); + DALI_TEST_CHECK(!meshActor); + + Actor unInitialzedActor; + meshActor = DownCast< MeshActor >( unInitialzedActor ); + DALI_TEST_CHECK(!meshActor); + END_TEST; +} + +int UtcDaliMeshActorSetMaterial01(void) +{ + TestApplication application; + tet_infoline("Testing Dali::MeshActor::SetMaterial()"); + + Mesh mesh = NewMesh(); + + MeshActor actor = MeshActor::New(mesh); + std::string name = "AMeshActor"; + Stage::GetCurrent().Add(actor); + actor.SetName(name); + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + + Material customMaterial = Material::New("CustomMaterial"); + customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f)); + + MeshActor::SetMaterial(actor, name, customMaterial); + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + + DALI_TEST_CHECK( actor.GetMaterial() == customMaterial ); + END_TEST; +} + +int UtcDaliMeshActorSetMaterial01b(void) +{ + TestApplication application; + tet_infoline("Testing Dali::MeshActor::SetMaterial()"); + + Mesh mesh = NewMesh(); + + Actor rootActor = Actor::New(); + MeshActor meshActor = MeshActor::New(mesh); + rootActor.Add(meshActor); + + std::string name = "AMeshActor"; + meshActor.SetName(name); + + Stage::GetCurrent().Add(rootActor); + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + + Material customMaterial = Material::New("CustomMaterial"); + customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f)); + + MeshActor::SetMaterial(rootActor, name, customMaterial); + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + + DALI_TEST_CHECK(meshActor.GetMaterial() == customMaterial ); + END_TEST; +} + + +int UtcDaliMeshActorSetMaterial02(void) +{ + TestApplication application; + tet_infoline("Testing Dali::MeshActor::SetMaterial()"); + + Mesh mesh = NewMesh(); + MeshActor actor = MeshActor::New(mesh); + + std::string name = "AMeshActor"; + actor.SetName(name); + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + + Material baseMat = actor.GetMaterial(); + Material customMaterial = Material::New("CustomMaterial"); + customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f)); + + MeshActor::SetMaterial(actor, "NoName", customMaterial); + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + + DALI_TEST_CHECK( actor.GetMaterial() == baseMat ); + DALI_TEST_CHECK( actor.GetMaterial() != customMaterial ); + END_TEST; +} + +int UtcDaliMeshActorSetMaterial02b(void) +{ + TestApplication application; + tet_infoline("Testing Dali::MeshActor::SetMaterial()"); + + Mesh mesh = NewMesh(); + + MeshActor actor = MeshActor::New(mesh); + Stage::GetCurrent().Add(actor); + + std::string name = "AMeshActor"; + actor.SetName(name); + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + + Material baseMat = actor.GetMaterial(); + Material customMaterial = Material::New("CustomMaterial"); + customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f)); + + MeshActor::SetMaterial(actor, "NoName", customMaterial); + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + + DALI_TEST_CHECK( actor.GetMaterial() == baseMat ); + DALI_TEST_CHECK( actor.GetMaterial() != customMaterial ); + END_TEST; +} + + +int UtcDaliMeshActorSetMaterial03(void) +{ + TestApplication application; + tet_infoline("Testing Dali::MeshActor::SetMaterial()"); + + Mesh mesh = NewMesh(); + + MeshActor actor = MeshActor::New(mesh); + std::string name = "AMeshActor"; + actor.SetName(name); + Stage::GetCurrent().Add(actor); + + Material customMaterial = Material::New("CustomMaterial"); + customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f)); + + actor.SetMaterial(customMaterial); + application.SendNotification(); + application.Render(0); + application.Render(16); + application.SendNotification(); + + DALI_TEST_CHECK(actor.GetMaterial() == customMaterial ); + END_TEST; +} + +int UtcDaliMeshActorSetMaterial03b(void) +{ + TestApplication application; + tet_infoline("Testing Dali::MeshActor::SetMaterial()"); + + Mesh mesh = NewMesh(); + + MeshActor actor = MeshActor::New(mesh); + std::string name = "AMeshActor"; + actor.SetName(name); + Stage::GetCurrent().Add(actor); + + Material customMaterial = Material::New("CustomMaterial"); + customMaterial.SetDiffuseColor(Vector4(1.0f, 0.0f, 0.0f, 1.0f)); + + actor.SetMaterial(customMaterial); + application.SendNotification(); + application.Render(0); + application.Render(16); + application.SendNotification(); + DALI_TEST_CHECK(actor.GetMaterial() == customMaterial ); + END_TEST; +} + + + +int UtcDaliMeshActorGetMaterial01(void) +{ + TestApplication application; + tet_infoline("Testing Dali::MeshActor::SetMaterial()"); + + MeshData meshData; + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + BoneContainer bones; + ConstructVertices(vertices, 60); + ConstructFaces(vertices, faces); + Material material = ConstructMaterial(); + meshData.SetData(vertices, faces, bones, material); + Mesh mesh = Mesh::New(meshData); + + MeshActor actor = MeshActor::New(mesh); + std::string name = "AMeshActor"; + actor.SetName(name); + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + + Material gotMaterial = actor.GetMaterial(); + + DALI_TEST_EQUALS( material.GetOpacity(), gotMaterial.GetOpacity(), TEST_LOCATION ); + DALI_TEST_EQUALS( material.GetAmbientColor(), gotMaterial.GetAmbientColor(), TEST_LOCATION ); + DALI_TEST_EQUALS( material.GetDiffuseColor(), gotMaterial.GetDiffuseColor(), TEST_LOCATION ); + DALI_TEST_EQUALS( material.GetSpecularColor(), gotMaterial.GetSpecularColor(), TEST_LOCATION ); + END_TEST; +} + + +int UtcDaliMeshActorGetMaterial02(void) +{ + TestApplication application; + tet_infoline("Testing Dali::MeshActor::SetMaterial()"); + + MeshData meshData; + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + BoneContainer bones; + ConstructVertices(vertices, 60); + ConstructFaces(vertices, faces); + Material material = ConstructMaterial(); + meshData.SetData(vertices, faces, bones, material); + Mesh mesh = Mesh::New(meshData); + + MeshActor actor = MeshActor::New(mesh); + std::string name = "AMeshActor"; + actor.SetName(name); + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + + Material gotMaterial = actor.GetMaterial(); + + DALI_TEST_EQUALS( material.GetOpacity(), gotMaterial.GetOpacity(), TEST_LOCATION ); + DALI_TEST_EQUALS( material.GetAmbientColor(), gotMaterial.GetAmbientColor(), TEST_LOCATION ); + DALI_TEST_EQUALS( material.GetDiffuseColor(), gotMaterial.GetDiffuseColor(), TEST_LOCATION ); + DALI_TEST_EQUALS( material.GetSpecularColor(), gotMaterial.GetSpecularColor(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliMeshActorSetLighting01(void) +{ + TestApplication application; + tet_infoline("Testing Dali::MeshActor::GetLighting()"); + + Mesh mesh = NewMesh(); + + MeshActor actor = MeshActor::New(mesh); + Stage::GetCurrent().Add(actor); + + // Mesh actors should be lit by default + DALI_TEST_EQUALS(actor.IsAffectedByLighting(), true, TEST_LOCATION); + END_TEST; +} + +int UtcDaliMeshActorSetLighting02(void) +{ + TestApplication application; + tet_infoline("Testing Dali::MeshActor::SetLighting()"); + + Mesh mesh = NewMesh(); + MeshActor actor = MeshActor::New(mesh); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + + Light light = Light::New("KeyLight"); + light.SetFallOff(Vector2(10000.0f, 10000.0f)); + LightActor keyLightActor = LightActor::New(); + keyLightActor.SetParentOrigin(ParentOrigin::CENTER); + keyLightActor.SetPosition(200.0f, 500.0f, 300.0f); + keyLightActor.SetName(light.GetName()); + + Stage::GetCurrent().Add(keyLightActor); + keyLightActor.SetLight(light); + keyLightActor.SetActive(true); + + actor.SetAffectedByLighting(true); + DALI_TEST_EQUALS(actor.IsAffectedByLighting(), true, TEST_LOCATION); + + // Test rendering to ensure that the correct shader setup is used in renderer + // (check in debugger or via coverage) + application.Render(1); + application.SendNotification(); + application.Render(1); + application.SendNotification(); + application.Render(1); + application.SendNotification(); + application.Render(1); + application.SendNotification(); + application.Render(1); + + actor.SetAffectedByLighting(false); + DALI_TEST_EQUALS(actor.IsAffectedByLighting(), false, TEST_LOCATION); + + // Test rendering to ensure that the correct shader setup is used in renderer + // (check in debugger or via coverage) + application.Render(1); + application.SendNotification(); + application.Render(1); + application.SendNotification(); + application.Render(1); + application.SendNotification(); + application.Render(1); + application.SendNotification(); + application.Render(1); + END_TEST; +} + +namespace +{ + +Material ConstructMaterial(float opacity, float diffuseOpacity) +{ + Material customMaterial = Material::New("CustomMaterial"); + customMaterial.SetOpacity(opacity); + customMaterial.SetDiffuseColor(Vector4(0.8f, 0.0f, 0.4f, diffuseOpacity)); + customMaterial.SetAmbientColor(Vector4(0.2f, 1.0f, 0.6f, 1.0f)); + customMaterial.SetSpecularColor(Vector4(0.5f, 0.6f, 0.7f, 1.0f)); + return customMaterial; +} + +static void TestBlending( TestApplication& application, Material material, float actorOpacity, BlendingMode::Type blendingMode, bool expectedBlend ) +{ + MeshData meshData; + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + BoneContainer bones; + ConstructVertices(vertices, 60); + ConstructFaces(vertices, faces); + meshData.SetData(vertices, faces, bones, material); + Mesh mesh = Mesh::New(meshData); + + application.SendNotification(); + application.Render(0); + application.Render(); + application.SendNotification(); + + MeshActor actor = MeshActor::New(mesh); + Stage::GetCurrent().Add(actor); + + actor.SetAffectedByLighting(false); + actor.SetBlendMode(blendingMode); + actor.SetOpacity(actorOpacity); + + TraceCallStack& cullFaceTrace = application.GetGlAbstraction().GetCullFaceTrace(); + cullFaceTrace.Enable(true); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( BlendEnabled( cullFaceTrace ), expectedBlend, TEST_LOCATION ); +} +} //anonymous namespace + + +int UtcDaliMeshActorBlend01(void) +{ + // Set Material with translucent color, actor color opaque, Set Use image alpha to true + // Expect blending + + TestApplication application; + tet_infoline("Testing Dali::MeshActor::Blend01()"); + + TestBlending( application, ConstructMaterial(0.5f, 0.5f), 1.0f, BlendingMode::AUTO, true ); + END_TEST; +} + + +int UtcDaliMeshActorBlend02(void) +{ + // Set material to translucent, set use image alpha to false, set actor opacity to 1.0f + // Expect no blending + + TestApplication application; + tet_infoline("Testing Dali::MeshActor::Blend02()"); + TestBlending( application, ConstructMaterial(0.5f, 0.5f), 1.0f, BlendingMode::OFF, false ); + END_TEST; +} + +int UtcDaliMeshActorBlend03(void) +{ + // Set material to opaque, set use image alpha to true, set actor opacity to 1.0f + // Expect no blending + + TestApplication application; + tet_infoline("Testing Dali::MeshActor::Blend03()"); + TestBlending( application, ConstructMaterial(1.0f, 1.0f), 1.0f, BlendingMode::AUTO, false ); + END_TEST; +} + + +int UtcDaliMeshActorBlend04(void) +{ + // Set material to have image with alpha, set use image alpha to true, set actor opacity to 1.0f + // Expect blending + TestApplication application; + tet_infoline("Testing Dali::MeshActor::Blend04()"); + + Material material = ConstructMaterial(1.0f, 1.0f); + BitmapImage image = BitmapImage::New( 100, 50, Pixel::RGBA8888 ); + material.SetDiffuseTexture( image ); + application.SendNotification(); + application.Render(0); + + TestBlending( application, material, 1.0f, BlendingMode::AUTO, true ); + END_TEST; +} + +int UtcDaliMeshActorBlend05(void) +{ + // Set material to have image with alpha, set use image alpha to false, set actor opacity to 1.0f + // Expect no blending + + TestApplication application; + tet_infoline("Testing Dali::MeshActor::Blend05()"); + + Material material = ConstructMaterial(1.0f, 1.0f); + BitmapImage image = BitmapImage::New( 100, 50, Pixel::RGBA8888 ); + material.SetDiffuseTexture( image ); + application.SendNotification(); + application.Render(0); + + TestBlending( application, material, 1.0f, BlendingMode::ON, true ); + END_TEST; +} + + +int UtcDaliMeshActorBlend06(void) +{ + // Set material to have image without alpha, set use image alpha to true, set actor opacity to 1.0f + // Expect no blending + + TestApplication application; + tet_infoline("Testing Dali::MeshActor::Blend()"); + + Material material = ConstructMaterial(1.0f, 1.0f); + BitmapImage image = BitmapImage::New( 100, 50, Pixel::RGB888 ); + material.SetDiffuseTexture( image ); + application.SendNotification(); + application.Render(0); + + TestBlending( application, material, 1.0f, BlendingMode::AUTO, false ); + END_TEST; +} + +int UtcDaliMeshActorBlend07(void) +{ + // Set material to have framebuffer with alpha, set use image alpha to true, set actor opacity to 1.0f + // Expect blending + TestApplication application; + tet_infoline("Testing Dali::MeshActor::Blend07()"); + application.Render(0); + + Material material = ConstructMaterial(1.0f, 1.0f); + FrameBufferImage image = FrameBufferImage::New( 100, 50, Pixel::RGBA8888 ); + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + RenderTask task = taskList.GetTask( 0u ); + task.SetTargetFrameBuffer( image ); // To ensure frame buffer is connected + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + application.SendNotification(); + application.Render(); + + material.SetDiffuseTexture( image ); // (to render from) + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + + TestBlending( application, material, 1.0f, BlendingMode::AUTO, true ); + END_TEST; +} + +int UtcDaliMeshActorBlend08(void) +{ + // Set material to have image with alpha, set use image alpha to false, set actor opacity to 0.5f + // Expect blending + TestApplication application; + tet_infoline("Testing Dali::MeshActor::Blend08()"); + + Material material = ConstructMaterial(1.0f, 1.0f); + BitmapImage image = BitmapImage::New( 100, 50, Pixel::RGBA8888 ); + material.SetDiffuseTexture( image ); + application.SendNotification(); + application.Render(0); + + TestBlending( application, material, 0.5f, BlendingMode::AUTO, true ); + END_TEST; +} + +int UtcDaliMeshActorBlend09(void) +{ + // Set material to have image with no alpha, set material opacity to 0.5, set use image alpha to true, set actor opacity to 1.0f + // Expect blending + TestApplication application; + tet_infoline("Testing Dali::MeshActor::Blend08()"); + + Material material = ConstructMaterial(0.5f, 1.0f); + BitmapImage image = BitmapImage::New( 100, 50, Pixel::RGB888 ); + material.SetDiffuseTexture( image ); + application.SendNotification(); + application.Render(0); + + TestBlending( application, material, 1.0f, BlendingMode::AUTO, true ); + END_TEST; +} + +int UtcDaliMeshActorBoneUpdate01(void) +{ + TestApplication application; + tet_infoline("Testing Dali::MeshActor::BoneUpdate01()"); + + // Set up a mesh with bones. + // animate bones + // ensure bone actor's world matrix is updated + + Actor trunk = Actor::New(); + trunk.SetName("trunk"); + trunk.SetPosition(Vector3(100.0f, 200.0f, 300.0f)); + trunk.SetRotation(Quaternion(M_PI*0.3f, Vector3::XAXIS)); + Actor branch = Actor::New(); + branch.SetName("branch"); + branch.SetPosition(Vector3(10.0f, 100.0f, 0.0f)); + branch.SetRotation(Quaternion(M_PI*0.2f, Vector3::YAXIS)); + + Actor twig = ImageActor::New(CreateBitmapImage()); + twig.SetName("twig"); + branch.SetPosition(Vector3(20.0f, 30.0f, 40.0f)); + + Actor bug = Actor::New(); // Not a bone + bug.SetName("bug"); + bug.SetPosition(Vector3(10.0f, 10.0f, 10.0f)); + + Stage::GetCurrent().Add(trunk); + trunk.Add(branch); + branch.Add(twig); + twig.Add(bug); + + MeshData meshData; + CreateMeshData(meshData); // Created with named bones (as above) + Mesh mesh = Mesh::New(meshData); + MeshActor meshActor = MeshActor::New(mesh); + Stage::GetCurrent().Add(meshActor); + + meshActor.BindBonesToMesh(Stage::GetCurrent().GetRootLayer()); + + application.SendNotification(); + application.Render(0); + application.Render(); + application.SendNotification(); + + // How to test? + // Need to see what bone actor's node has set as world matrix. + + Animation anim = Animation::New(1.0f); + anim.RotateBy(trunk, Radian(M_PI*0.5f), Vector3::ZAXIS); + anim.Play(); + application.SendNotification(); + application.Render(500); + application.SendNotification(); + application.Render(500); + application.SendNotification(); + application.Render(10); + + // All bones have moved. + // Check that their world matrix has been updated: ( Isn't IDENTITY ) + DALI_TEST_CHECK( ! application.GetGlAbstraction().CheckUniformValue("uModelMatrix", Matrix::IDENTITY ) ); + + Matrix worldMatrix; + GLuint programId, uniformId; + DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformIds("uModelMatrix", programId, uniformId) ); + DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue( programId, uniformId, worldMatrix) ); + + // But also check that property is calculated as needed: + Matrix calcWorldMatrix = twig.GetCurrentWorldMatrix(); + DALI_TEST_CHECK( Matrix::IDENTITY != calcWorldMatrix ); + DALI_TEST_CHECK( worldMatrix == calcWorldMatrix ); + END_TEST; + +} + +int UtcDaliMeshActorIndices(void) +{ + TestApplication application; + Actor basicActor = Actor::New(); + Mesh mesh = NewMesh(); + MeshActor meshActor = MeshActor::New(mesh); + + Property::IndexContainer indices; + meshActor.GetPropertyIndices( indices ); + DALI_TEST_CHECK( indices.size() == basicActor.GetPropertyCount() ); // Mesh Actor does not have any properties + DALI_TEST_EQUALS( indices.size(), meshActor.GetPropertyCount(), TEST_LOCATION ); + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-MeshData.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-MeshData.cpp new file mode 100644 index 0000000..844007b --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-MeshData.cpp @@ -0,0 +1,331 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; + +#include "mesh-builder.h" + + + +int UtcDaliMeshDataNew(void) +{ + TestApplication application; + MeshData meshData; + + DALI_TEST_EQUALS(meshData.HasNormals(), false, TEST_LOCATION); + DALI_TEST_EQUALS(meshData.HasTextureCoords(), false, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliMeshDataSetData(void) +{ + TestApplication application; + + MeshData meshData; + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + BoneContainer bones; + ConstructVertices(vertices, 60); + ConstructFaces(vertices, faces); + Material customMaterial = ConstructMaterial(); + meshData.SetData(vertices, faces, bones, customMaterial); + + DALI_TEST_GREATER(meshData.GetVertexCount(), 0u, TEST_LOCATION); + DALI_TEST_GREATER(meshData.GetFaceCount(), 0u, TEST_LOCATION); + + const MeshData::FaceIndices& faces2 = meshData.GetFaces(); + const MeshData::VertexContainer& verts2 = meshData.GetVertices(); + DALI_TEST_EQUALS(faces.at(0), faces2.at(0), TEST_LOCATION); + DALI_TEST_EQUALS(vertices.at(1).y, verts2.at(1).y, TEST_LOCATION); + DALI_TEST_EQUALS(meshData.GetBoneCount(), static_cast(0), TEST_LOCATION); + END_TEST; +} + +int UtcDaliMeshDataAddToBoundingVolume(void) +{ + TestApplication application; + + float sz=40.0f; + + MeshData meshData; + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + BoneContainer bones; + ConstructVertices(vertices, sz); + ConstructFaces(vertices, faces); + Material customMaterial = ConstructMaterial(); + meshData.SetData(vertices, faces, bones, customMaterial); + + Vector4 upper(-1e10f, -1e10f, -1e10f, 0.0f); + Vector4 lower(1e10f, 1e10f, 1e10f, 0.0f); + Matrix f(false); + f.SetIdentityAndScale(Vector3(2.0f, 2.0f, 2.0f)); + meshData.AddToBoundingVolume(lower, upper, f); + + Vector4 min(-sz*0.5f, -sz, -sz*0.7f, 0.0f); + Vector4 max( sz*0.5f, sz*0.3f, sz*0.5f, 0.0f); + + // Test that upper and lower bounds are set and transformed + DALI_TEST_EQUALS(lower, min*2.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(upper, max*2.0f, 0.001, TEST_LOCATION); + + // Test that mesh's upper and lower bounds are set and not transformed + DALI_TEST_EQUALS(meshData.GetBoundingBoxMin(), min, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(meshData.GetBoundingBoxMax(), max, 0.001, TEST_LOCATION); + END_TEST; +} + +int UtcDaliMeshDataBoundingBox(void) +{ + TestApplication application; + + float sz=40.0f; + MeshData meshData; + Vector4 min(-1.0f, -2.0f, -3.0f, 0.0f); + Vector4 max(1.0f, 2.0f, 3.0f, 0.0f); + meshData.SetBoundingBoxMin(min); + meshData.SetBoundingBoxMax(max); + DALI_TEST_EQUALS(meshData.GetBoundingBoxMin(), min, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(meshData.GetBoundingBoxMax(), max, 0.001, TEST_LOCATION); + + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + BoneContainer bones; + ConstructVertices(vertices, sz); + ConstructFaces(vertices, faces); + Material customMaterial = ConstructMaterial(); + meshData.SetData(vertices, faces, bones, customMaterial); + + // Check bounding box hasn't changed + DALI_TEST_EQUALS(meshData.GetBoundingBoxMin(), min, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(meshData.GetBoundingBoxMax(), max, 0.001, TEST_LOCATION); + + Vector4 upper(-1e10f, -1e10f, -1e10f, 0.0f); + Vector4 lower(1e10f, 1e10f, 1e10f, 0.0f); + meshData.AddToBoundingVolume(lower, upper, Matrix::IDENTITY); + + // Bounding box should have been update + Vector4 bbMin(-sz*0.5f, -sz, -sz*0.7f, 0.0f); + Vector4 bbMax( sz*0.5f, sz*0.3f, sz*0.5f, 0.0f); + + // Test that upper and lower bounds are set and transformed + DALI_TEST_EQUALS(lower, bbMin, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(upper, bbMax, 0.001, TEST_LOCATION); + + // Test that mesh's upper and lower bounds are set and not transformed + DALI_TEST_EQUALS(meshData.GetBoundingBoxMin(), bbMin, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(meshData.GetBoundingBoxMax(), bbMax, 0.001, TEST_LOCATION); + END_TEST; +} + +int UtcDaliMeshDataGetVertexCount(void) +{ + TestApplication application; + + MeshData meshData; + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + BoneContainer bones; + ConstructVertices(vertices, 30); + ConstructFaces(vertices, faces); + Material customMaterial = ConstructMaterial(); + + DALI_TEST_EQUALS(meshData.GetVertexCount(), static_cast(0), TEST_LOCATION); + + meshData.SetData(vertices, faces, bones, customMaterial); + DALI_TEST_EQUALS(meshData.GetVertexCount(), vertices.size(), TEST_LOCATION); + + END_TEST; +} + +int UtcDaliMeshDataGetVertices(void) +{ + TestApplication application; + MeshData meshData; + const Dali::MeshData::VertexContainer& verts1 = meshData.GetVertices(); + DALI_TEST_CHECK(verts1.size() == 0); + + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + BoneContainer bones; + ConstructVertices(vertices, 30); + ConstructFaces(vertices, faces); + Material customMaterial = ConstructMaterial(); + meshData.SetData(vertices, faces, bones, customMaterial); + + const Dali::MeshData::VertexContainer& verts2 = meshData.GetVertices(); + DALI_TEST_CHECK(verts2.size() != 0); + DALI_TEST_CHECK(verts2.size() == meshData.GetVertexCount()); + END_TEST; +} + +int UtcDaliMeshDataGetFaceCount(void) +{ + TestApplication application; + MeshData meshData; + DALI_TEST_EQUALS(meshData.GetFaceCount(), static_cast(0), TEST_LOCATION); + + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + BoneContainer bones; + ConstructVertices(vertices, 30); + ConstructFaces(vertices, faces); + Material customMaterial = ConstructMaterial(); + meshData.SetData(vertices, faces, bones, customMaterial); + + DALI_TEST_EQUALS(meshData.GetFaceCount(), faces.size() / 3, TEST_LOCATION); + END_TEST; +} + +int UtcDaliMeshDataGetFaces(void) +{ + TestApplication application; + MeshData meshData; + const Dali::MeshData::FaceIndices& faces1 = meshData.GetFaces(); + DALI_TEST_CHECK(faces1.size() == 0); + + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + BoneContainer bones; + ConstructVertices(vertices, 30); + ConstructFaces(vertices, faces); + Material customMaterial = ConstructMaterial(); + meshData.SetData(vertices, faces, bones, customMaterial); + + const Dali::MeshData::FaceIndices& faces2 = meshData.GetFaces(); + DALI_TEST_CHECK(faces2.size() != 0); + END_TEST; +} + +int UtcDaliMeshDataTextureCoords(void) +{ + TestApplication application; + MeshData meshData; + DALI_TEST_EQUALS(meshData.HasTextureCoords(), false, TEST_LOCATION); + meshData.SetHasTextureCoords(true); + DALI_TEST_EQUALS(meshData.HasTextureCoords(), true, TEST_LOCATION); + END_TEST; +} + +int UtcDaliMeshDataNormals(void) +{ + TestApplication application; + MeshData meshData; + DALI_TEST_EQUALS(meshData.HasNormals(), false, TEST_LOCATION); + meshData.SetHasNormals(true); + DALI_TEST_EQUALS(meshData.HasNormals(), true, TEST_LOCATION); + END_TEST; +} + +int UtcDaliMeshDataGetMaterial(void) +{ + TestApplication application; + MeshData meshData; + Material aMat = meshData.GetMaterial(); + DALI_TEST_CHECK(!aMat); + + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + BoneContainer bones; + ConstructVertices(vertices, 30); + ConstructFaces(vertices, faces); + Material customMaterial = ConstructMaterial(); + meshData.SetData(vertices, faces, bones, customMaterial); + + aMat = meshData.GetMaterial(); + DALI_TEST_CHECK(aMat); + END_TEST; +} + +int UtcDaliMeshDataSetMaterial(void) +{ + TestApplication application; + MeshData meshData; + + Material aMat = meshData.GetMaterial(); + DALI_TEST_CHECK(!aMat); + + Material mat1 = ConstructMaterial(); + meshData.SetMaterial(mat1); + aMat = meshData.GetMaterial(); + DALI_TEST_CHECK(mat1 == aMat); + + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + BoneContainer bones; + ConstructVertices(vertices, 30); + ConstructFaces(vertices, faces); + Material customMaterial = ConstructMaterial(); + meshData.SetData(vertices, faces, bones, customMaterial); + + aMat = meshData.GetMaterial(); + + DALI_TEST_CHECK(aMat == customMaterial); + DALI_TEST_CHECK(aMat != mat1); + + END_TEST; +} + +int UtcDaliMeshDataGetBoneCount(void) +{ + TestApplication application; + MeshData meshData; + DALI_TEST_EQUALS(meshData.GetBoneCount(), static_cast(0), TEST_LOCATION); + DALI_TEST_EQUALS(meshData.HasBones(), false, TEST_LOCATION); + + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + BoneContainer bones; + ConstructVertices(vertices, 30); + ConstructFaces(vertices, faces); + ConstructBones(bones); + Material customMaterial = ConstructMaterial(); + meshData.SetData(vertices, faces, bones, customMaterial); + + DALI_TEST_EQUALS(meshData.GetBoneCount(), static_cast(3), TEST_LOCATION); + DALI_TEST_EQUALS(meshData.HasBones(), true, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliMeshDataGetBones(void) +{ + TestApplication application; + MeshData meshData; + DALI_TEST_EQUALS(meshData.GetBoneCount(), static_cast(0), TEST_LOCATION); + const BoneContainer& bones1 = meshData.GetBones(); + DALI_TEST_CHECK(bones1.empty()); + + MeshData::VertexContainer vertices; + MeshData::FaceIndices faces; + BoneContainer bones; + ConstructVertices(vertices, 30); + ConstructFaces(vertices, faces); + ConstructBones(bones); + Material customMaterial = ConstructMaterial(); + meshData.SetData(vertices, faces, bones, customMaterial); + const BoneContainer& bones3 = meshData.GetBones(); + DALI_TEST_CHECK( ! bones3.empty() ); + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-Model.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-Model.cpp new file mode 100644 index 0000000..8dc0b00 --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-Model.cpp @@ -0,0 +1,642 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; +#include "mesh-builder.h" + +namespace +{ + +static std::string gModelFile = "blah"; + + +// Functor to test whether a Finish signal is emitted +struct AnimationFinishCheck +{ + AnimationFinishCheck(bool& signalReceived) + : mSignalReceived(signalReceived) + { + } + + void operator()(Animation& animation) + { + mSignalReceived = true; + } + + void Reset() + { + mSignalReceived = false; + } + + void CheckSignalReceived() + { + if (!mSignalReceived) + { + tet_printf("Expected Finish signal was not received\n"); + tet_result(TET_FAIL); + } + else + { + tet_result(TET_PASS); + } + } + + void CheckSignalNotReceived() + { + if (mSignalReceived) + { + tet_printf("Unexpected Finish signal was received\n"); + tet_result(TET_FAIL); + } + else + { + tet_result(TET_PASS); + } + } + + bool& mSignalReceived; // owned by individual tests +}; + +} + + +int UtcDaliModelConstructorVoid(void) +{ + TestApplication application; + tet_infoline("Testing Dali::Model::Model()"); + + Model model; + + DALI_TEST_CHECK(!model); + END_TEST; +} + +int UtcDaliModelNew(void) +{ + TestApplication application; + TestPlatformAbstraction& platform = application.GetPlatform(); + + tet_infoline("Testing Dali::Model::New()"); + + Model model = Model::New(gModelFile); + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + + DALI_TEST_CHECK(platform.WasCalled(TestPlatformAbstraction::LoadResourceFunc)); + DALI_TEST_CHECK(model); + END_TEST; +} + +int UtcDaliModelDownCast(void) +{ + TestApplication application; + tet_infoline("Testing Dali::Model::DownCast()"); + + Model model = Model::New(gModelFile); + + BaseHandle object(model); + + Model model2 = Model::DownCast(object); + DALI_TEST_CHECK(model2); + + Model model3 = DownCast< Model >(object); + DALI_TEST_CHECK(model3); + + BaseHandle unInitializedObject; + Model model4 = Model::DownCast(unInitializedObject); + DALI_TEST_CHECK(!model4); + + Model model5 = DownCast< Model >(unInitializedObject); + DALI_TEST_CHECK(!model5); + END_TEST; +} + + +int UtcDaliModelGetLoadingState01(void) +{ + TestApplication application; + TestPlatformAbstraction& platform = application.GetPlatform(); + + tet_infoline("Testing Dali::Model::New()"); + Model model = Model::New(gModelFile); + application.SendNotification(); + application.Render(); + Integration::ResourceRequest* request = platform.GetRequest(); + DALI_TEST_CHECK(model.GetLoadingState() == ResourceLoading); + DALI_TEST_EQUALS(request->GetPath(), gModelFile, TEST_LOCATION); + DALI_TEST_EQUALS(request->GetType()->id, Integration::ResourceModel, TEST_LOCATION); + END_TEST; +} + +int UtcDaliModelGetLoadingState02(void) +{ + TestApplication application; + TestPlatformAbstraction& platform = application.GetPlatform(); + + tet_infoline("Testing Dali::Model::New()"); + Dali::ModelData modelData = BuildTreeModel(); + Model model = Model::New(gModelFile); + application.SendNotification(); + application.Render(); + Integration::ResourceRequest* request = platform.GetRequest(); + if(request) + { + platform.SetResourceLoaded(request->GetId(), request->GetType()->id, Integration::ResourcePointer(&(modelData.GetBaseObject()))); + } + + // Get resources into resource cache + application.Render(); + application.SendNotification(); + + DALI_TEST_CHECK(model.GetLoadingState() == ResourceLoadingSucceeded); + END_TEST; +} + +int UtcDaliModelGetLoadingState03(void) +{ + TestApplication application; + TestPlatformAbstraction& platform = application.GetPlatform(); + + tet_infoline("Testing Dali::Model::New()"); + Model model = Model::New(gModelFile); + application.SendNotification(); + application.Render(); + Integration::ResourceRequest* request = platform.GetRequest(); + if(request) + { + platform.SetResourceLoadFailed(request->GetId(), Integration::FailureFileNotFound); + } + application.Render(); + application.SendNotification(); + + DALI_TEST_CHECK(model.GetLoadingState() == ResourceLoadingFailed); + END_TEST; +} + + +// Could probably test the signals, too! + +int UtcDaliModelNumberOfAnimations(void) +{ + TestApplication application; + tet_infoline("Testing Dali::Model::NumberOfAnimations()"); + + int animationCount = -1; + Model model = Model::New("Blah"); // Probably need to create a real model... + animationCount = model.NumberOfAnimations(); + + DALI_TEST_CHECK( -1 != animationCount ); + END_TEST; +} + +int UtcDaliModelActorFactory(void) +{ + TestApplication application; + TestPlatformAbstraction& platform = application.GetPlatform(); + + tet_infoline("Testing Dali::ModelActorFactory"); + + Dali::ModelData modelData = BuildTreeModel(); + + // Raise a request + Model model = Model::New("Tree"); + + application.SendNotification(); + application.Render(); + Integration::ResourceRequest* request = platform.GetRequest(); // Return modelData + if(request) + { + platform.SetResourceLoaded(request->GetId(), request->GetType()->id, Integration::ResourcePointer(&(modelData.GetBaseObject()))); + } + application.Render(); + application.SendNotification(); + + Actor modelRootActor = ModelActorFactory::BuildActorTree(model, ""); // model should be loaded + + DALI_TEST_CHECK(model.GetLoadingState() == ResourceLoadingSucceeded); + DALI_TEST_CHECK(modelRootActor); + DALI_TEST_CHECK(modelRootActor.GetName().compare("root") == 0); + + Actor trunk = modelRootActor.FindChildByName("trunk"); + DALI_TEST_CHECK(trunk); + Actor branch = modelRootActor.FindChildByName("branch"); + DALI_TEST_CHECK(branch); + Actor twig = modelRootActor.FindChildByName("twig"); + DALI_TEST_CHECK(twig); + MeshActor twigMeshActor = MeshActor::DownCast(twig); + DALI_TEST_CHECK(!twigMeshActor); + Actor leaf = modelRootActor.FindChildByName("leaf"); + DALI_TEST_CHECK(leaf); + MeshActor leafMeshActor = MeshActor::DownCast(leaf); + DALI_TEST_CHECK(leafMeshActor); + + Material leafMaterial = leafMeshActor.GetMaterial(); + DALI_TEST_CHECK(leafMaterial); + END_TEST; +} + +int UtcDaliModelActorFactoryTwoMesh(void) +{ + TestApplication application; + TestPlatformAbstraction& platform = application.GetPlatform(); + + tet_infoline("Testing Dali::ModelActorFactory with 2 meshes in an entity"); + + Dali::ModelData modelData = BuildTreeModel(); + Dali::Entity twoMeshEntity = Dali::Entity::New("2Mesh"); + MeshData meshData; + CreateMeshData(meshData); + MeshData meshData2; + CreateMeshData(meshData2); + unsigned int meshIndex = modelData.NumberOfMeshes(); + modelData.AddMesh(meshData); + modelData.AddMesh(meshData2); + twoMeshEntity.AddMeshIndex(meshIndex); + twoMeshEntity.AddMeshIndex(meshIndex+1); + modelData.GetRootEntity().Add(twoMeshEntity); + + // Raise a request + Model model = Model::New("Tree"); + + application.SendNotification(); + application.Render(); + Integration::ResourceRequest* request = platform.GetRequest(); // Return modelData + if(request) + { + platform.SetResourceLoaded(request->GetId(), request->GetType()->id, Integration::ResourcePointer(&(modelData.GetBaseObject()))); + } + application.Render(); + application.SendNotification(); + + Actor actor; + try + { + actor = ModelActorFactory::BuildActorTree(model, ""); // model should be loaded + } + catch( Dali::DaliException& e ) + { + tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "entity.NumberOfMeshes() == 1", TEST_LOCATION); + DALI_TEST_CHECK( !actor ); + } + END_TEST; +} + +int UtcDaliModelBuildAnimation01(void) +{ + TestApplication application; + TestPlatformAbstraction& platform = application.GetPlatform(); + + tet_infoline("Testing Dali::MeshActor::New()"); + + Dali::ModelData modelData = BuildTreeModel(); + + // Raise a request + Model model = Model::New("Tree"); + + application.SendNotification(); + application.Render(); + Integration::ResourceRequest* request = platform.GetRequest(); // Return modelData + if(request) + { + platform.SetResourceLoaded(request->GetId(), request->GetType()->id, Integration::ResourcePointer(&(modelData.GetBaseObject()))); + } + application.Render(); + application.SendNotification(); + + Actor actor = ModelActorFactory::BuildActorTree(model, ""); // model should be loaded + Stage::GetCurrent().Add(actor); + + DALI_TEST_CHECK(model.GetLoadingState() == ResourceLoadingSucceeded); + DALI_TEST_CHECK(actor); + DALI_TEST_CHECK(actor.GetName().compare("root") == 0); + + DALI_TEST_EQUALS(model.NumberOfAnimations(), static_cast(1), TEST_LOCATION); + unsigned int animIndex=0; + bool found = model.FindAnimation("Anim1", animIndex); + DALI_TEST_CHECK(found); + + Animation twigAnim = ModelActorFactory::BuildAnimation(model, actor, animIndex); + DALI_TEST_CHECK(twigAnim); + DALI_TEST_EQUALS(twigAnim.GetDuration(), 10.0f, 0.001, TEST_LOCATION); + DALI_TEST_CHECK(twigAnim.GetDefaultAlphaFunction() == Dali::AlphaFunctions::Linear); + + Actor twigActor = actor.FindChildByName("twig"); + DALI_TEST_CHECK(twigActor); + + // Start the animation + twigAnim.Play(); + + float durationSeconds = 10.0f; + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + twigAnim.FinishedSignal().Connect(&application, finishCheck); + application.SendNotification(); + application.Render(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( twigActor.GetCurrentPosition(), Vector3(2.0f, 1.0f, 0.0f), 0.01f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( twigActor.GetCurrentPosition(), Vector3(2.5f, 1.0f, 2.5f), 0.01f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*500.0f)/* 75% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( twigActor.GetCurrentPosition(), Vector3(3.5f, 1.0f, 7.5f), 0.01f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*500.0f)/* Past Finished */); + application.SendNotification(); + DALI_TEST_EQUALS( twigActor.GetCurrentPosition(), Vector3(4.0f, 1.0f, 10.0f), 0.01f, TEST_LOCATION ); + + finishCheck.CheckSignalReceived(); + END_TEST; +} + + + +int UtcDaliModelBuildAnimation02(void) +{ + TestApplication application; + TestPlatformAbstraction& platform = application.GetPlatform(); + + tet_infoline("Testing Dali::MeshActor::New()"); + + Dali::ModelData modelData = BuildTreeModel(); + + // Raise a request + Model model = Model::New("Tree"); + + application.SendNotification(); + application.Render(); + Integration::ResourceRequest* request = platform.GetRequest(); // Return modelData + if(request) + { + platform.SetResourceLoaded(request->GetId(), request->GetType()->id, Integration::ResourcePointer(&(modelData.GetBaseObject()))); + } + application.Render(); + application.SendNotification(); + + Actor actor = ModelActorFactory::BuildActorTree(model, ""); // model should be loaded + + DALI_TEST_CHECK(model.GetLoadingState() == ResourceLoadingSucceeded); + DALI_TEST_CHECK(actor); + DALI_TEST_CHECK(actor.GetName().compare("root") == 0); + + DALI_TEST_EQUALS(model.NumberOfAnimations(), static_cast(1), TEST_LOCATION); + unsigned int animIndex=0; + bool found = model.FindAnimation("Anim1", animIndex); + DALI_TEST_CHECK(found); + Animation twigAnim = ModelActorFactory::BuildAnimation(model, actor, animIndex, 5.0f); + DALI_TEST_CHECK(twigAnim); + DALI_TEST_EQUALS(twigAnim.GetDuration(), 5.0f, 0.001, TEST_LOCATION); + DALI_TEST_CHECK(twigAnim.GetDefaultAlphaFunction() == Dali::AlphaFunctions::Linear); + END_TEST; +} + + +int UtcDaliModelBuildAnimation03(void) +{ + TestApplication application; + TestPlatformAbstraction& platform = application.GetPlatform(); + + tet_infoline("Testing Dali::MeshActor::New()"); + + Dali::ModelData modelData = BuildTreeModel(); + + // Raise a request + Model model = Model::New("Tree"); + + application.SendNotification(); + application.Render(); + Integration::ResourceRequest* request = platform.GetRequest(); // Return modelData + if(request) + { + platform.SetResourceLoaded(request->GetId(), request->GetType()->id, Integration::ResourcePointer(&(modelData.GetBaseObject()))); + } + application.Render(); + application.SendNotification(); + + Actor actor = ModelActorFactory::BuildActorTree(model, ""); // model should be loaded + + DALI_TEST_CHECK(model.GetLoadingState() == ResourceLoadingSucceeded); + DALI_TEST_CHECK(actor); + DALI_TEST_CHECK(actor.GetName().compare("root") == 0); + + DALI_TEST_EQUALS(model.NumberOfAnimations(), static_cast(1), TEST_LOCATION); + unsigned int animIndex=0; + bool found = model.FindAnimation("Anim1", animIndex); + DALI_TEST_CHECK(found); + + Animation twigAnim = ModelActorFactory::BuildAnimation(model, actor, animIndex, Dali::AlphaFunctions::EaseInOut, 5.0f); + DALI_TEST_CHECK(twigAnim); + DALI_TEST_EQUALS(twigAnim.GetDuration(), 5.0f, 0.001, TEST_LOCATION); + DALI_TEST_CHECK(twigAnim.GetDefaultAlphaFunction() == Dali::AlphaFunctions::EaseInOut); + END_TEST; +} + + +int UtcDaliModelBuildAnimation04(void) +{ + TestApplication application; + TestPlatformAbstraction& platform = application.GetPlatform(); + + tet_infoline("Testing Dali::MeshActor::New()"); + + Dali::ModelData modelData = BuildTreeModel(); + + // Raise a request + Model model = Model::New("Tree"); + + application.SendNotification(); + application.Render(); + Integration::ResourceRequest* request = platform.GetRequest(); // Return modelData + if(request) + { + platform.SetResourceLoaded(request->GetId(), request->GetType()->id, Integration::ResourcePointer(&(modelData.GetBaseObject()))); + } + application.Render(); + application.SendNotification(); + + Actor actor = ModelActorFactory::BuildActorTree(model, ""); // model should be loaded + + DALI_TEST_CHECK(model.GetLoadingState() == ResourceLoadingSucceeded); + DALI_TEST_CHECK(actor); + DALI_TEST_CHECK(actor.GetName().compare("root") == 0); + + DALI_TEST_EQUALS(model.NumberOfAnimations(), static_cast(1), TEST_LOCATION); + + unsigned int animIndex=0; + bool found = model.FindAnimation("Fred", animIndex); + DALI_TEST_CHECK(!found); + END_TEST; +} + + +int UtcDaliModelBuildAnimation05(void) +{ + TestApplication application; + TestPlatformAbstraction& platform = application.GetPlatform(); + + tet_infoline("Testing Dali::MeshActor::New()"); + + Dali::ModelData modelData = BuildTreeModel(); + + // Raise a request + Model model = Model::New("Tree"); + + // Run Core - will query using TestPlatformAbstraction::GetResources(). + application.SendNotification(); + application.Render(); + Integration::ResourceRequest* request = platform.GetRequest(); // Return modelData + if(request) + { + platform.SetResourceLoaded(request->GetId(), request->GetType()->id, Integration::ResourcePointer(&(modelData.GetBaseObject()))); + } + application.Render(); + application.SendNotification(); + + Actor actor = ModelActorFactory::BuildActorTree(model, ""); // model should be loaded + + DALI_TEST_CHECK(model.GetLoadingState() == ResourceLoadingSucceeded); + DALI_TEST_CHECK(actor); + DALI_TEST_CHECK(actor.GetName().compare("root") == 0); + + DALI_TEST_EQUALS(model.NumberOfAnimations(), static_cast(1), TEST_LOCATION); + Animation twigAnim = ModelActorFactory::BuildAnimation(model, actor, 0); + DALI_TEST_CHECK(twigAnim); + DALI_TEST_EQUALS(twigAnim.GetDuration(), 10.0f, 0.001, TEST_LOCATION); + DALI_TEST_CHECK(twigAnim.GetDefaultAlphaFunction() == Dali::AlphaFunctions::Linear); + END_TEST; +} + + +int UtcDaliModelBuildAnimation06(void) +{ + TestApplication application; + TestPlatformAbstraction& platform = application.GetPlatform(); + + tet_infoline("Testing Dali::MeshActor::New()"); + + Dali::ModelData modelData = BuildTreeModel(); + + // Raise a request + Model model = Model::New("Tree"); + + application.SendNotification(); + application.Render(); + Integration::ResourceRequest* request = platform.GetRequest(); // Return modelData + if(request) + { + platform.SetResourceLoaded(request->GetId(), request->GetType()->id, Integration::ResourcePointer(&(modelData.GetBaseObject()))); + } + application.Render(); + application.SendNotification(); + + Actor actor = ModelActorFactory::BuildActorTree(model, ""); // model should be loaded + + DALI_TEST_CHECK(model.GetLoadingState() == ResourceLoadingSucceeded); + DALI_TEST_CHECK(actor); + DALI_TEST_CHECK(actor.GetName().compare("root") == 0); + + DALI_TEST_EQUALS(model.NumberOfAnimations(), static_cast(1), TEST_LOCATION); + Animation twigAnim = ModelActorFactory::BuildAnimation(model, actor, 0, 5.0f); + DALI_TEST_CHECK(twigAnim); + DALI_TEST_EQUALS(twigAnim.GetDuration(), 5.0f, 0.001, TEST_LOCATION); + DALI_TEST_CHECK(twigAnim.GetDefaultAlphaFunction() == Dali::AlphaFunctions::Linear); + END_TEST; +} + + +int UtcDaliModelBuildAnimation07(void) +{ + TestApplication application; + TestPlatformAbstraction& platform = application.GetPlatform(); + + tet_infoline("Testing Dali::MeshActor::New()"); + + Dali::ModelData modelData = BuildTreeModel(); + + // Raise a request + Model model = Model::New("Tree"); + + application.SendNotification(); + application.Render(); + Integration::ResourceRequest* request = platform.GetRequest(); // Return modelData + if(request) + { + platform.SetResourceLoaded(request->GetId(), request->GetType()->id, Integration::ResourcePointer(&(modelData.GetBaseObject()))); + } + application.Render(); + application.SendNotification(); + + Actor actor = ModelActorFactory::BuildActorTree(model, ""); // model should be loaded + + DALI_TEST_CHECK(model.GetLoadingState() == ResourceLoadingSucceeded); + DALI_TEST_CHECK(actor); + DALI_TEST_CHECK(actor.GetName().compare("root") == 0); + + DALI_TEST_EQUALS(model.NumberOfAnimations(), static_cast(1), TEST_LOCATION); + Animation twigAnim = ModelActorFactory::BuildAnimation(model, actor, 0, Dali::AlphaFunctions::Bounce); + DALI_TEST_CHECK(twigAnim); + DALI_TEST_EQUALS(twigAnim.GetDuration(), 10.0f, 0.001, TEST_LOCATION); + DALI_TEST_CHECK(twigAnim.GetDefaultAlphaFunction() == Dali::AlphaFunctions::Bounce); + END_TEST; +} + +int UtcDaliModelBuildAnimation08(void) +{ + TestApplication application; + TestPlatformAbstraction& platform = application.GetPlatform(); + + tet_infoline("Testing Dali::MeshActor::New()"); + + Dali::ModelData modelData = BuildTreeModel(); + + // Raise a request + Model model = Model::New("Tree"); + + application.SendNotification(); + application.Render(); + Integration::ResourceRequest* request = platform.GetRequest(); // Return modelData + if(request) + { + platform.SetResourceLoaded(request->GetId(), request->GetType()->id, Integration::ResourcePointer(&(modelData.GetBaseObject()))); + } + application.Render(); + application.SendNotification(); + + Actor actor = ModelActorFactory::BuildActorTree(model, ""); // model should be loaded + + DALI_TEST_CHECK(model.GetLoadingState() == ResourceLoadingSucceeded); + DALI_TEST_CHECK(actor); + DALI_TEST_CHECK(actor.GetName().compare("root") == 0); + + DALI_TEST_EQUALS(model.NumberOfAnimations(), static_cast(1), TEST_LOCATION); + + Animation twigAnim = ModelActorFactory::BuildAnimation(model, actor, 10); + DALI_TEST_CHECK(!twigAnim); + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-MouseWheelEvent.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-MouseWheelEvent.cpp new file mode 100644 index 0000000..02dfb26 --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-MouseWheelEvent.cpp @@ -0,0 +1,274 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 +#include + +using namespace Dali; + +namespace +{ + +// Key Event Test references +const static unsigned int SHIFT_MODIFIER = 0x1; +const static unsigned int CTRL_MODIFIER = 0x2; +const static unsigned int ALT_MODIFIER = 0x4; +const static unsigned int SHIFT_AND_CTRL_MODIFIER = SHIFT_MODIFIER | CTRL_MODIFIER; + + +// Stores data that is populated in the callback and will be read by the TET cases +struct SignalData +{ + SignalData() + : functorCalled(false) + {} + + void Reset() + { + functorCalled = false; + + receivedMouseWheelEvent.direction = 0; + receivedMouseWheelEvent.modifiers = 0; + receivedMouseWheelEvent.point = Vector2::ZERO; + receivedMouseWheelEvent.z = 0; + receivedMouseWheelEvent.timeStamp = 0; + + mouseWheeledActor = NULL; + } + + bool functorCalled; + MouseWheelEvent receivedMouseWheelEvent; + Actor mouseWheeledActor; +}; + +// Functor that sets the data when called +struct MouseWheelEventReceivedFunctor +{ + MouseWheelEventReceivedFunctor( SignalData& data ) : signalData( data ) { } + + bool operator()( Actor actor, const MouseWheelEvent& mouseWheelEvent ) + { + signalData.functorCalled = true; + signalData.receivedMouseWheelEvent = mouseWheelEvent; + signalData.mouseWheeledActor = actor; + + return true; + } + + SignalData& signalData; +}; + +} // anonymous namespace + +int UtcDaliMouseWheelEventConstructor(void) +{ + TestApplication application; // Reset all test adapter return codes + + MouseWheelEvent event(1, SHIFT_MODIFIER, Vector2(1.0f, 1.0f), 1, 1000u); // coustruct a mouse wheel event + + DALI_TEST_EQUALS(1, event.direction, TEST_LOCATION); // check direction + DALI_TEST_EQUALS(SHIFT_MODIFIER, event.modifiers, TEST_LOCATION); // check modifier + DALI_TEST_EQUALS(Vector2(1.0f, 1.0f), event.point, TEST_LOCATION); // check modifier + DALI_TEST_EQUALS(1, event.z, TEST_LOCATION); // check modifier + DALI_TEST_EQUALS(1000u, event.timeStamp, TEST_LOCATION); // check modifier + END_TEST; +} + +// Positive test case for a method +int UtcDaliMouseWheelEventIsShiftModifier(void) +{ + TestApplication application; // Reset all test adapter return codes + + MouseWheelEvent event; + DALI_TEST_EQUALS(0u, event.modifiers, TEST_LOCATION); + + event.modifiers = SHIFT_MODIFIER; // Set to Shift Modifier + + DALI_TEST_EQUALS(SHIFT_MODIFIER, event.modifiers, TEST_LOCATION); // check able to set + + DALI_TEST_EQUALS(true, event.IsShiftModifier(), TEST_LOCATION); // check IsShiftModifier + + END_TEST; +} + +// Positive test case for a method +int UtcDaliMouseWheelEventIsCtrlModifier(void) +{ + TestApplication application; // Reset all test adapter return codes + + MouseWheelEvent event; + DALI_TEST_EQUALS(0u, event.modifiers, TEST_LOCATION); + + event.modifiers = CTRL_MODIFIER; // Set to Ctrl Modifier + + DALI_TEST_EQUALS(CTRL_MODIFIER, event.modifiers, TEST_LOCATION); // check able to set + + DALI_TEST_EQUALS(true, event.IsCtrlModifier(), TEST_LOCATION); // check IsCtrlModifier + END_TEST; +} + +// Positive test case for a method +int UtcDaliMouseWheelEventIsAltModifier(void) +{ + TestApplication application; // Reset all test adapter return codes + + MouseWheelEvent event; + DALI_TEST_EQUALS(0u, event.modifiers, TEST_LOCATION); + + event.modifiers = ALT_MODIFIER; // Set to Alt Modifier + + DALI_TEST_EQUALS(ALT_MODIFIER, event.modifiers, TEST_LOCATION); // check able to set + + DALI_TEST_EQUALS(true, event.IsAltModifier(), TEST_LOCATION); // IsAltModifier + END_TEST; +} + +// Positive fail test case for a method +int UtcDaliMouseWheelEventIsNotShiftModifier(void) +{ + TestApplication application; // Reset all test adapter return codes + + MouseWheelEvent event(1, CTRL_MODIFIER, Vector2(1.0f, 1.0f), 1, 1000u); + + DALI_TEST_EQUALS(CTRL_MODIFIER, event.modifiers, TEST_LOCATION); // check different modifier used + + DALI_TEST_EQUALS(false, event.IsShiftModifier(), TEST_LOCATION); + END_TEST; +} + +// Positive fail test case for a method +int UtcDaliMouseWheelEventIsNotCtrlModifier(void) +{ + TestApplication application; // Reset all test adapter return codes + + MouseWheelEvent event(1, ALT_MODIFIER, Vector2(1.0f, 1.0f), 1, 1000u); + + DALI_TEST_EQUALS(ALT_MODIFIER, event.modifiers, TEST_LOCATION); // check different modifier used + + DALI_TEST_EQUALS(false, event.IsCtrlModifier(), TEST_LOCATION); + END_TEST; +} + +// Positive fail test case for a method +int UtcDaliMouseWheelEventIsNotAltModifier(void) +{ + TestApplication application; // Reset all test adapter return codes + + MouseWheelEvent event(1, SHIFT_MODIFIER, Vector2(1.0f, 1.0f), 1, 1000u); + + DALI_TEST_EQUALS(SHIFT_MODIFIER, event.modifiers, TEST_LOCATION); // check different modifier used + + DALI_TEST_EQUALS(false, event.IsAltModifier(), TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliMouseWheelEventANDModifer(void) +{ + TestApplication application; // Reset all test adapter return codes + + MouseWheelEvent event(1, SHIFT_AND_CTRL_MODIFIER, Vector2(1.0f, 1.0f), 1, 1000u); + DALI_TEST_EQUALS(true, event.IsCtrlModifier() && event.IsShiftModifier(), TEST_LOCATION); + + event.modifiers = SHIFT_MODIFIER; + + DALI_TEST_EQUALS(false, event.IsCtrlModifier() && event.IsShiftModifier(), TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliMouseWheelEventORModifer(void) +{ + TestApplication application; // Reset all test adapter return codes + + MouseWheelEvent event(1, SHIFT_AND_CTRL_MODIFIER, Vector2(1.0f, 1.0f), 1, 1000u); + DALI_TEST_EQUALS(true, event.IsCtrlModifier() || event.IsAltModifier(), TEST_LOCATION); + + event.modifiers = SHIFT_MODIFIER; + + DALI_TEST_EQUALS(false, event.IsCtrlModifier() && event.IsAltModifier(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliMouseWheelEventSignalling(void) +{ + TestApplication application; // Reset all test adapter return codes + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to actor's mouse wheel event signal + SignalData data; + MouseWheelEventReceivedFunctor functor( data ); + actor.MouseWheelEventSignal().Connect( &application, functor ); + + Vector2 screenCoordinates( 10.0f, 10.0f ); + Integration::MouseWheelEvent event(0, SHIFT_MODIFIER, screenCoordinates, 1, 1000u); + + // Emit a mouse wheel signal + application.ProcessEvent( event ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_CHECK( actor == data.mouseWheeledActor ); + DALI_TEST_EQUALS(0, data.receivedMouseWheelEvent.direction, TEST_LOCATION); // check direction + DALI_TEST_EQUALS(SHIFT_MODIFIER, data.receivedMouseWheelEvent.modifiers, TEST_LOCATION); // check modifier + DALI_TEST_EQUALS(screenCoordinates, data.receivedMouseWheelEvent.point, TEST_LOCATION); // check modifier + DALI_TEST_EQUALS(1, data.receivedMouseWheelEvent.z, TEST_LOCATION); // check modifier + DALI_TEST_EQUALS(1000u, data.receivedMouseWheelEvent.timeStamp, TEST_LOCATION); // check modifier + data.Reset(); + + // Emit a mouse wheel signal where the actor is not present, will hit the root actor though + Actor rootActor( Stage::GetCurrent().GetRootLayer() ); + + // Connect to root actor's mouse wheel event signal + SignalData rootData; + MouseWheelEventReceivedFunctor rootFunctor( rootData ); // Consumes signal + rootActor.MouseWheelEventSignal().Connect( &application, rootFunctor ); + + screenCoordinates.x = screenCoordinates.y = 300.0f; + Integration::MouseWheelEvent newEvent(0, SHIFT_MODIFIER, screenCoordinates, 1, 1000u); + application.ProcessEvent( newEvent ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); + DALI_TEST_CHECK( rootActor == rootData.mouseWheeledActor ); + DALI_TEST_EQUALS(0, rootData.receivedMouseWheelEvent.direction, TEST_LOCATION); // check direction + DALI_TEST_EQUALS(SHIFT_MODIFIER, rootData.receivedMouseWheelEvent.modifiers, TEST_LOCATION); // check modifier + DALI_TEST_EQUALS(screenCoordinates, rootData.receivedMouseWheelEvent.point, TEST_LOCATION); // check modifier + DALI_TEST_EQUALS(1, rootData.receivedMouseWheelEvent.z, TEST_LOCATION); // check modifier + DALI_TEST_EQUALS(1000u, rootData.receivedMouseWheelEvent.timeStamp, TEST_LOCATION); // check modifier + + // Remove actor from stage + Stage::GetCurrent().Remove( actor ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Emit a move at the same point, we should not be signalled. + application.ProcessEvent( event ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + data.Reset(); + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-ObjectRegistry.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-ObjectRegistry.cpp new file mode 100644 index 0000000..5de7006 --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-ObjectRegistry.cpp @@ -0,0 +1,527 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; + +#include "mesh-builder.h" + +namespace +{ + +// Functors to test whether Object created/destroyed signal is emitted for different types of Objects + +struct TestObjectDestroyedCallback +{ + TestObjectDestroyedCallback(bool& signalReceived, Dali::RefObject*& objectPointer) + : mSignalVerified(signalReceived), + mObjectPointer(objectPointer) + { + } + + void operator()(const Dali::RefObject* objectPointer) + { + tet_infoline("Verifying TestObjectDestroyedCallback()"); + + if(objectPointer == mObjectPointer) + { + mSignalVerified = true; + } + } + + bool& mSignalVerified; + Dali::RefObject*& mObjectPointer; +}; + +struct TestActorCallback +{ + TestActorCallback(bool& signalReceived) + : mSignalVerified(signalReceived) + { + } + + void operator()(BaseHandle object) + { + tet_infoline("Verifying TestActorCallback()"); + Actor actor = Actor::DownCast(object); + if(actor) + { + mSignalVerified = true; + } + } + + bool& mSignalVerified; +}; + +struct TestCameraActorCallback +{ + TestCameraActorCallback(bool& signalReceived) + : mSignalVerified(signalReceived) + { + } + void operator()(BaseHandle object) + { + tet_infoline("Verifying TestCameraActorCallback()"); + CameraActor actor = CameraActor::DownCast(object); + if(actor) + { + mSignalVerified = true; + } + } + bool& mSignalVerified; +}; + +struct TestImageActorCallback +{ + TestImageActorCallback(bool& signalReceived) + : mSignalVerified(signalReceived) + { + } + void operator()(BaseHandle object) + { + tet_infoline("Verifying TestImageActorCallback()"); + ImageActor actor = ImageActor::DownCast(object); + if(actor) + { + mSignalVerified = true; + } + } + bool& mSignalVerified; +}; + +struct TestLayerCallback +{ + TestLayerCallback(bool& signalReceived) + : mSignalVerified(signalReceived) + { + } + void operator()(BaseHandle object) + { + tet_infoline("Verifying TestLayerCallback()"); + Layer actor = Layer::DownCast(object); + if(actor) + { + mSignalVerified = true; + } + } + bool& mSignalVerified; +}; + +struct TestLightActorCallback +{ + TestLightActorCallback(bool& signalReceived) + : mSignalVerified(signalReceived) + { + } + void operator()(BaseHandle object) + { + tet_infoline("Verifying TestLightActorCallback()"); + LightActor actor = LightActor::DownCast(object); + if(actor) + { + mSignalVerified = true; + } + } + bool& mSignalVerified; +}; + +struct TestMeshActorCallback +{ + TestMeshActorCallback(bool& signalReceived) + : mSignalVerified(signalReceived) + { + } + void operator()(BaseHandle object) + { + tet_infoline("Verifying TestMeshActorCallback()"); + MeshActor actor = MeshActor::DownCast(object); + if(actor) + { + mSignalVerified = true; + } + } + bool& mSignalVerified; +}; + +struct TestModelCallback +{ + TestModelCallback(bool& signalReceived) + : mSignalVerified(signalReceived) + { + } + void operator()(BaseHandle object) + { + tet_infoline("Verifying TestModelCallback()"); + Model actor = Model::DownCast(object); + if(actor) + { + mSignalVerified = true; + } + } + bool& mSignalVerified; +}; + +struct TestTextActorCallback +{ + TestTextActorCallback(bool& signalReceived) + : mSignalVerified(signalReceived) + { + } + void operator()(BaseHandle object) + { + tet_infoline("Verifying TestTextActorCallback()"); + TextActor actor = TextActor::DownCast(object); + if(actor) + { + mSignalVerified = true; + } + } + bool& mSignalVerified; +}; + +struct TestAnimationCallback +{ + TestAnimationCallback(bool& signalReceived) + : mSignalVerified(signalReceived) + { + } + void operator()(BaseHandle object) + { + tet_infoline("Verifying TestAnimationCallback()"); + Animation actor = Animation::DownCast(object); + if(actor) + { + mSignalVerified = true; + } + } + bool& mSignalVerified; +}; + +struct TestShaderEffectCallback +{ + TestShaderEffectCallback(bool& signalReceived) + : mSignalVerified(signalReceived) + { + } + void operator()(BaseHandle object) + { + tet_infoline("Verifying TestShaderEffectCallback()"); + ShaderEffect actor = ShaderEffect::DownCast(object); + if(actor) + { + mSignalVerified = true; + } + } + bool& mSignalVerified; +}; + + +} // anonymous namespace + + + + +int UtcDaliObjectRegistryGet(void) +{ + TestApplication application; + + ObjectRegistry registry; // like this for ctor code coverage + registry= Stage::GetCurrent().GetObjectRegistry(); + + DALI_TEST_CHECK( registry ); + END_TEST; +} + + + +int UtcDaliObjectRegistrySignalActorCreated(void) +{ + tet_infoline("Testing GetObjectRegistry()"); + TestApplication application; + ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry(); + DALI_TEST_CHECK( registry ); + + bool verified = false; + TestActorCallback test(verified); + + Dali::RefObject* objectPointer = NULL; + TestObjectDestroyedCallback test2(verified, objectPointer); + + registry.ObjectCreatedSignal().Connect(&application, test); + registry.ObjectDestroyedSignal().Connect(&application, test2); + + { + Actor actor = Actor::New(); + DALI_TEST_CHECK( test.mSignalVerified ); + + verified = false; + objectPointer = actor.GetObjectPtr(); + } + DALI_TEST_CHECK( test.mSignalVerified ); + END_TEST; +} + +int UtcDaliObjectRegistrySignalCameraCreated(void) +{ + TestApplication application; + + ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry(); + + bool verified = false; + TestCameraActorCallback test(verified); + + Dali::RefObject* objectPointer = NULL; + TestObjectDestroyedCallback test2(verified, objectPointer); + + registry.ObjectCreatedSignal().Connect(&application, test); + registry.ObjectDestroyedSignal().Connect(&application, test2); + + { + CameraActor actor = CameraActor::New(); + DALI_TEST_CHECK( test.mSignalVerified ); + + verified = false; + objectPointer = actor.GetObjectPtr(); + } + DALI_TEST_CHECK( test.mSignalVerified ); + END_TEST; +} + +int UtcDaliObjectRegistrySignalImageActorCreated(void) +{ + TestApplication application; + ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry(); + + static const char* TestImageFilename = "icon_wrt.png"; + Image image = Image::New(TestImageFilename); + + bool verified = false; + TestImageActorCallback test(verified); + + Dali::RefObject* objectPointer = NULL; + TestObjectDestroyedCallback test2(verified, objectPointer); + + registry.ObjectCreatedSignal().Connect(&application, test); + registry.ObjectDestroyedSignal().Connect(&application, test2); + + { + ImageActor actor = ImageActor::New(image); + DALI_TEST_CHECK( test.mSignalVerified ); + + verified = false; + objectPointer = actor.GetObjectPtr(); + } + DALI_TEST_CHECK( test.mSignalVerified ); + END_TEST; +} + +int UtcDaliObjectRegistrySignalLayerCreated(void) +{ + TestApplication application; + ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry(); + + bool verified = false; + TestLayerCallback test(verified); + + Dali::RefObject* objectPointer = NULL; + TestObjectDestroyedCallback test2(verified, objectPointer); + + registry.ObjectCreatedSignal().Connect(&application, test); + registry.ObjectDestroyedSignal().Connect(&application, test2); + + { + Layer actor = Layer::New(); + DALI_TEST_CHECK( test.mSignalVerified ); + + verified = false; + objectPointer = actor.GetObjectPtr(); + } + DALI_TEST_CHECK( test.mSignalVerified ); + END_TEST; +} + +int UtcDaliObjectRegistrySignalLightActorCreated(void) +{ + TestApplication application; + ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry(); + + bool verified = false; + TestLightActorCallback test(verified); + + Dali::RefObject* objectPointer = NULL; + TestObjectDestroyedCallback test2(verified, objectPointer); + + registry.ObjectCreatedSignal().Connect(&application, test); + registry.ObjectDestroyedSignal().Connect(&application, test2); + + { + LightActor actor = LightActor::New(); + DALI_TEST_CHECK( test.mSignalVerified ); + + verified = false; + objectPointer = actor.GetObjectPtr(); + } + DALI_TEST_CHECK( test.mSignalVerified ); + END_TEST; +} + +int UtcDaliObjectRegistrySignalMeshActorCreated(void) +{ + TestApplication application; + ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry(); + + bool verified = false; + TestMeshActorCallback test(verified); + + Dali::RefObject* objectPointer = NULL; + TestObjectDestroyedCallback test2(verified, objectPointer); + + registry.ObjectCreatedSignal().Connect(&application, test); + registry.ObjectDestroyedSignal().Connect(&application, test2); + + Mesh mesh = ConstructMesh(60); + + { + MeshActor actor = MeshActor::New(mesh); + + DALI_TEST_CHECK(actor); + DALI_TEST_CHECK( test.mSignalVerified ); + + verified = false; + objectPointer = actor.GetObjectPtr(); + } + DALI_TEST_CHECK( test.mSignalVerified ); + END_TEST; +} + +int UtcDaliObjectRegistrySignalModelCreated(void) +{ + TestApplication application; + ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry(); + + bool verified = false; + TestModelCallback test(verified); + + Dali::RefObject* objectPointer = NULL; + TestObjectDestroyedCallback test2(verified, objectPointer); + + registry.ObjectCreatedSignal().Connect(&application, test); + registry.ObjectDestroyedSignal().Connect(&application, test2); + + { + Model model = Model::New("blah"); + DALI_TEST_CHECK( test.mSignalVerified ); + + verified = false; + objectPointer = model.GetObjectPtr(); + } + DALI_TEST_CHECK( test.mSignalVerified ); + END_TEST; +} + +int UtcDaliObjectRegistrySignalTextActorCreated(void) +{ + TestApplication application; + ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry(); + + bool verified = false; + TestTextActorCallback test(verified); + + Dali::RefObject* objectPointer = NULL; + TestObjectDestroyedCallback test2(verified, objectPointer); + + registry.ObjectCreatedSignal().Connect(&application, test); + registry.ObjectDestroyedSignal().Connect(&application, test2); + + { + TextActor actor = TextActor::New("Hello"); + DALI_TEST_CHECK( test.mSignalVerified ); + + verified = false; + objectPointer = actor.GetObjectPtr(); + } + DALI_TEST_CHECK( test.mSignalVerified ); + END_TEST; +} + +int UtcDaliObjectRegistrySignalAnimationCreated(void) +{ + TestApplication application; + ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry(); + + bool verified = false; + TestAnimationCallback test(verified); + + Dali::RefObject* objectPointer = NULL; + TestObjectDestroyedCallback test2(verified, objectPointer); + + registry.ObjectCreatedSignal().Connect(&application, test); + registry.ObjectDestroyedSignal().Connect(&application, test2); + + { + Animation animation = Animation::New(1.0f); + DALI_TEST_CHECK( test.mSignalVerified ); + + verified = false; + objectPointer = animation.GetObjectPtr(); + } + DALI_TEST_CHECK( test.mSignalVerified ); + END_TEST; +} + +int UtcDaliObjectRegistrySignalShaderEffectCreated(void) +{ + TestApplication application; + ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry(); + + static const char* VertexSource = + "void main()\n" + "{\n" + " gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\n" + " vTexCoord = aTexCoord;\n" + "}\n"; + + static const char* FragmentSource = + "void main()\n" + "{\n" + " gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n" + "}\n"; + + bool verified = false; + TestShaderEffectCallback test(verified); + + Dali::RefObject* objectPointer = NULL; + TestObjectDestroyedCallback test2(verified, objectPointer); + + registry.ObjectCreatedSignal().Connect(&application, test); + registry.ObjectDestroyedSignal().Connect(&application, test2); + + { + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); + DALI_TEST_CHECK( test.mSignalVerified ); + + verified = false; + objectPointer = effect.GetObjectPtr(); + } + DALI_TEST_CHECK( test.mSignalVerified ); + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-Random.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-Random.cpp new file mode 100644 index 0000000..eb29bad --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-Random.cpp @@ -0,0 +1,97 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; + + +int UtcDaliRandomRangeMethod(void) +{ + TestApplication application; // Reset all test adapter return codes + + float a=0, b=1; + for(size_t i=0; i<100; i++) + { + float r = Dali::Random::Range(a, b); + DALI_TEST_CHECK(r >= a && r <= b); + } + + a=100; b=-100; + for(size_t i=0; i<100; i++) + { + float r = Dali::Random::Range(a, b); + DALI_TEST_CHECK(r >= b && r <= a); + } + END_TEST; +} + + +int UtcDaliRandomAxisMethod(void) +{ + TestApplication application; // Reset all test adapter return codes + + for(size_t i=0; i<100; i++) + { + Vector4 axis = Dali::Random::Axis(); + DALI_TEST_EQUALS(axis.Length(), 1.0f, 0.0001f, TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliRandomChanceMethod(void) +{ + int bin_zero=0, bin_one=0; + + for(size_t i=0; i<100000; i++) + { + bool chance = Dali::Random::Chance(); + if(chance) + { + bin_one++; + } + else + { + bin_zero++; + } + } + // Check distribution + DALI_TEST_EQUALS((float)bin_zero / (float)bin_one, 1.0f, 0.1f, TEST_LOCATION); + + bin_zero=0; bin_one = 0; + for(size_t i=0; i<100000; i++) + { + bool chance = Dali::Random::Chance(0.25); + if(chance) {bin_one++;} else {bin_zero++;} + } + // Check distribution + DALI_TEST_EQUALS((float)bin_zero / (float)bin_one, 3.0f, 0.1f, TEST_LOCATION); + + bin_zero=0; bin_one = 0; + for(size_t i=0; i<100000; i++) + { + bool chance = Dali::Random::Chance(0.1); + if(chance) {bin_one++;} else {bin_zero++;} + } + // Check distribution + DALI_TEST_EQUALS((float)bin_zero / (float)bin_one, 9.0f, 0.1f, TEST_LOCATION); + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-RenderTask.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-RenderTask.cpp new file mode 100644 index 0000000..50054c0 --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-RenderTask.cpp @@ -0,0 +1,128 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; + +namespace +{ +// The functor to be used in the hit-test algorithm to check whether the actor is hittable. +bool IsActorHittableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType type) +{ + bool hittable = false; + + switch (type) + { + case Dali::HitTestAlgorithm::CHECK_ACTOR: + { + // Check whether the actor is visible and not fully transparent. + if( actor.IsVisible() + && actor.GetCurrentWorldColor().a > 0.01f) // not FULLY_TRANSPARENT + { + + hittable = true; + } + break; + } + case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE: + { + if( actor.IsVisible() ) // Actor is visible, if not visible then none of its children are visible. + { + hittable = true; + } + break; + } + default: + { + break; + } + } + + return hittable; +}; + +} // anonymous namespace + + +int UtcDaliRenderTaskSetScreenToFrameBufferMappingActor(void) +{ + TestApplication application; + tet_infoline("Testing RenderTask::SetScreenToFrameBufferMappingActor "); + + Stage stage = Stage::GetCurrent(); + Size stageSize = stage.GetSize(); + Actor mappingActor = Actor::New(); + Vector2 scale( 0.6f, 0.75f); + Vector2 offset( stageSize.x*0.1f, stageSize.y*0.15f); + mappingActor.SetSize( stageSize * scale ); + mappingActor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + mappingActor.SetPosition( offset.x, offset.y ); + stage.Add( mappingActor ); + + Actor offscreenActor = Actor::New(); + offscreenActor.SetSize( stageSize ); + offscreenActor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + stage.Add( offscreenActor ); + + RenderTaskList taskList = stage.GetRenderTaskList(); + RenderTask renderTask = taskList.CreateTask(); + FrameBufferImage frameBufferImage = FrameBufferImage::New(stageSize.width*scale.x, stageSize.height*scale.y, Pixel::A8, Image::Never); + renderTask.SetSourceActor( offscreenActor ); + renderTask.SetExclusive( true ); + renderTask.SetInputEnabled( true ); + renderTask.SetTargetFrameBuffer( frameBufferImage ); + renderTask.SetRefreshRate( RenderTask::REFRESH_ONCE ); + renderTask.SetScreenToFrameBufferMappingActor( mappingActor ); + + // Render and notify + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + + Vector2 screenCoordinates( stageSize.x * 0.05f, stageSize.y * 0.05f ); + Dali::HitTestAlgorithm::Results results; + Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ); + DALI_TEST_CHECK( !results.actor); + DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION ); + + screenCoordinates.x = stageSize.x * 0.265f; + screenCoordinates.y = stageSize.y * 0.33f; + results.actor = Actor(); + results.actorCoordinates = Vector2::ZERO; + Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ); + DALI_TEST_CHECK( results.actor == offscreenActor); + DALI_TEST_EQUALS( (screenCoordinates-offset)/scale , results.actorCoordinates, 0.1f, TEST_LOCATION ); + + screenCoordinates.x = stageSize.x * 0.435f; + screenCoordinates.y = stageSize.y * 0.52f; + Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ); + DALI_TEST_CHECK( results.actor == offscreenActor); + DALI_TEST_EQUALS( (screenCoordinates-offset)/scale , results.actorCoordinates, 0.1f, TEST_LOCATION ); + + screenCoordinates.x = stageSize.x * 0.65f; + screenCoordinates.y = stageSize.y * 0.95f; + Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ); + DALI_TEST_CHECK( !results.actor); + DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION ); + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-Scripting.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-Scripting.cpp new file mode 100644 index 0000000..4174b04 --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-Scripting.cpp @@ -0,0 +1,1037 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +using namespace Dali; +using namespace Dali::Scripting; + +namespace +{ + +struct StringEnum +{ + const char * string; + int value; +}; + +const StringEnum COLOR_MODE_VALUES[] = +{ + { "USE_OWN_COLOR", USE_OWN_COLOR }, + { "USE_PARENT_COLOR", USE_PARENT_COLOR }, + { "USE_OWN_MULTIPLY_PARENT_COLOR", USE_OWN_MULTIPLY_PARENT_COLOR }, + { "USE_OWN_MULTIPLY_PARENT_ALPHA", USE_OWN_MULTIPLY_PARENT_ALPHA }, +}; +const unsigned int COLOR_MODE_VALUES_COUNT = sizeof( COLOR_MODE_VALUES ) / sizeof( COLOR_MODE_VALUES[0] ); + +const StringEnum POSITION_INHERITANCE_MODE_VALUES[] = +{ + { "INHERIT_PARENT_POSITION", INHERIT_PARENT_POSITION }, + { "USE_PARENT_POSITION", USE_PARENT_POSITION }, + { "USE_PARENT_POSITION_PLUS_LOCAL_POSITION", USE_PARENT_POSITION_PLUS_LOCAL_POSITION }, + { "DONT_INHERIT_POSITION", DONT_INHERIT_POSITION }, +}; +const unsigned int POSITION_INHERITANCE_MODE_VALUES_COUNT = sizeof( POSITION_INHERITANCE_MODE_VALUES ) / sizeof( POSITION_INHERITANCE_MODE_VALUES[0] ); + +const StringEnum DRAW_MODE_VALUES[] = +{ + { "NORMAL", DrawMode::NORMAL }, + { "OVERLAY", DrawMode::OVERLAY }, + { "STENCIL", DrawMode::STENCIL }, +}; +const unsigned int DRAW_MODE_VALUES_COUNT = sizeof( DRAW_MODE_VALUES ) / sizeof( DRAW_MODE_VALUES[0] ); + + + +////////////////////////////////////////////////////////////////////////////// +// Helpers for string to enum comparisons for Image and ImageAttributes +////////////////////////////////////////////////////////////////////////////// + +/** + * Template to check enumerations of type T, with a class of type X + */ +template< typename T, typename X > +void TestEnumStrings( + Property::Map& map, // The map used to create instance of type X + const StringEnum* values, // An array of string values + unsigned int num, // Number of items in the array + T ( X::*method )() const, // The member method of X to call to get the enum + X ( *creator ) ( const Property::Value& ) // The method which creates an instance of type X +) +{ + Property::Map::iterator iter = map.end() - 1; + for ( unsigned int i = 0; i < num; ++i ) + { + iter->second = values[i].string; + tet_printf("Checking: %s: %s\n", iter->first.c_str(), values[i].string ); + X instance = creator( map ); + DALI_TEST_EQUALS( values[i].value, ( instance.*method )(), TEST_LOCATION ); + } +} + +/// Helper method to create ImageAttributes using an Image +ImageAttributes NewImageAttributes( const Property::Value& map ) +{ + Image image = NewImage( map ); + return image.GetAttributes(); +} + +////////////////////////////////////////////////////////////////////////////// +// Helpers for string to enum comparisons for Actor to Property::Map +////////////////////////////////////////////////////////////////////////////// + +/** + * Template to check enumerations of type T + */ +template< typename T > +void TestEnumStrings( + const char * const keyName, // The name of the key to check + TestApplication& application, // Reference to the application class + const StringEnum* values, // An array of string values + unsigned int num, // Number of items in the array + void ( Actor::*method )( T ) // The Actor member method to set the enumeration +) +{ + for ( unsigned int i = 0; i < num; ++i ) + { + tet_printf("Checking: %s: %s\n", keyName, values[i].string ); + + Actor actor = Actor::New(); + (actor.*method)( ( T ) values[i].value ); + + Stage::GetCurrent().Add( actor ); + application.SendNotification(); + application.Render(); + + Property::Map map; + CreatePropertyMap( actor, map ); + + DALI_TEST_CHECK( !map.empty() ); + Property::Value value( map ); + DALI_TEST_CHECK( value.HasKey( keyName ) ); + DALI_TEST_EQUALS( value.GetValue( keyName ).Get< std::string >(), values[i].string, TEST_LOCATION ); + + Stage::GetCurrent().Remove( actor ); + } +} + +////////////////////////////////////////////////////////////////////////////// + + +} // anon namespace + + + +int UtcDaliScriptingGetColorMode(void) +{ + TestApplication application; + + for ( unsigned int i = 0; i < COLOR_MODE_VALUES_COUNT; ++i ) + { + tet_printf( "Checking %s == %d\n", COLOR_MODE_VALUES[i].string, COLOR_MODE_VALUES[i].value ); + DALI_TEST_EQUALS( COLOR_MODE_VALUES[i].value, GetColorMode( COLOR_MODE_VALUES[i].string ), TEST_LOCATION ); + DALI_TEST_EQUALS( COLOR_MODE_VALUES[i].string, GetColorMode( (ColorMode) COLOR_MODE_VALUES[i].value ), TEST_LOCATION ); + } + + try + { + (void)GetColorMode("INVALID_ARG"); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliScriptingGetPositionInheritanceMode(void) +{ + TestApplication application; + + for ( unsigned int i = 0; i < POSITION_INHERITANCE_MODE_VALUES_COUNT; ++i ) + { + tet_printf( "Checking %s == %d\n", POSITION_INHERITANCE_MODE_VALUES[i].string, POSITION_INHERITANCE_MODE_VALUES[i].value ); + DALI_TEST_EQUALS( POSITION_INHERITANCE_MODE_VALUES[i].value, GetPositionInheritanceMode( POSITION_INHERITANCE_MODE_VALUES[i].string ), TEST_LOCATION ); + DALI_TEST_EQUALS( POSITION_INHERITANCE_MODE_VALUES[i].string, GetPositionInheritanceMode( (PositionInheritanceMode) POSITION_INHERITANCE_MODE_VALUES[i].value ), TEST_LOCATION ); + } + + try + { + (void)GetPositionInheritanceMode("INVALID_ARG"); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION ); + } + END_TEST; +} + + +int UtcDaliScriptingGetDrawMode(void) +{ + TestApplication application; + + for ( unsigned int i = 0; i < DRAW_MODE_VALUES_COUNT; ++i ) + { + tet_printf( "Checking %s == %d\n", DRAW_MODE_VALUES[i].string, DRAW_MODE_VALUES[i].value ); + DALI_TEST_EQUALS( DRAW_MODE_VALUES[i].value, GetDrawMode( DRAW_MODE_VALUES[i].string ), TEST_LOCATION ); + DALI_TEST_EQUALS( DRAW_MODE_VALUES[i].string, GetDrawMode( (DrawMode::Type) DRAW_MODE_VALUES[i].value ), TEST_LOCATION ); + } + + try + { + (void)GetDrawMode("INVALID_ARG"); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliScriptingGetAnchorConstant(void) +{ + TestApplication application; + + DALI_TEST_EQUALS( Dali::ParentOrigin::BACK_TOP_LEFT, GetAnchorConstant( "BACK_TOP_LEFT" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::BACK_TOP_CENTER, GetAnchorConstant( "BACK_TOP_CENTER" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::BACK_TOP_RIGHT, GetAnchorConstant( "BACK_TOP_RIGHT" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::BACK_CENTER_LEFT, GetAnchorConstant( "BACK_CENTER_LEFT" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::BACK_CENTER, GetAnchorConstant( "BACK_CENTER" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::BACK_CENTER_RIGHT, GetAnchorConstant( "BACK_CENTER_RIGHT" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::BACK_BOTTOM_LEFT, GetAnchorConstant( "BACK_BOTTOM_LEFT" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::BACK_BOTTOM_CENTER, GetAnchorConstant( "BACK_BOTTOM_CENTER" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::BACK_BOTTOM_RIGHT, GetAnchorConstant( "BACK_BOTTOM_RIGHT" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::TOP_LEFT, GetAnchorConstant( "TOP_LEFT" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::TOP_CENTER, GetAnchorConstant( "TOP_CENTER" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::TOP_RIGHT, GetAnchorConstant( "TOP_RIGHT" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::CENTER_LEFT, GetAnchorConstant( "CENTER_LEFT" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::CENTER, GetAnchorConstant( "CENTER" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::CENTER_RIGHT, GetAnchorConstant( "CENTER_RIGHT" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::BOTTOM_LEFT, GetAnchorConstant( "BOTTOM_LEFT" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::BOTTOM_CENTER, GetAnchorConstant( "BOTTOM_CENTER" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::BOTTOM_RIGHT, GetAnchorConstant( "BOTTOM_RIGHT" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::FRONT_TOP_LEFT, GetAnchorConstant( "FRONT_TOP_LEFT" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::FRONT_TOP_CENTER, GetAnchorConstant( "FRONT_TOP_CENTER" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::FRONT_TOP_RIGHT, GetAnchorConstant( "FRONT_TOP_RIGHT" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::FRONT_CENTER_LEFT, GetAnchorConstant( "FRONT_CENTER_LEFT" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::FRONT_CENTER, GetAnchorConstant( "FRONT_CENTER" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::FRONT_CENTER_RIGHT, GetAnchorConstant( "FRONT_CENTER_RIGHT" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::FRONT_BOTTOM_LEFT, GetAnchorConstant( "FRONT_BOTTOM_LEFT" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::FRONT_BOTTOM_CENTER, GetAnchorConstant( "FRONT_BOTTOM_CENTER" ), TEST_LOCATION ); + DALI_TEST_EQUALS( Dali::ParentOrigin::FRONT_BOTTOM_RIGHT, GetAnchorConstant( "FRONT_BOTTOM_RIGHT" ), TEST_LOCATION ); + + try + { + (void)GetAnchorConstant("INVALID_ARG"); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliScriptingNewImageNegative(void) +{ + TestApplication application; + + // Invalid filename + try + { + Property::Map map; + map.push_back( Property::StringValuePair( "filename", Vector3::ZERO ) ); + Image image = NewImage( map ); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION ); + } + + // Invalid load-policy + try + { + Property::Map map; + map.push_back( Property::StringValuePair( "load-policy", Vector3::ZERO ) ); + Image image = NewImage( map ); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION ); + + // Invalid value + try + { + Property::Map map; + map.push_back( Property::StringValuePair( "load-policy", "INVALID" ) ); + Image image = NewImage( map ); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION ); + } + } + + // Invalid release-policy + try + { + Property::Map map; + map.push_back( Property::StringValuePair( "release-policy", Vector3::ZERO ) ); + Image image = NewImage( map ); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION ); + + // Invalid value + try + { + Property::Map map; + map.push_back( Property::StringValuePair( "release-policy", "INVALID" ) ); + Image image = NewImage( map ); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION ); + } + } + + // Invalid width + try + { + Property::Map map; + map.push_back( Property::StringValuePair( "width", "Invalid" ) ); + map.push_back( Property::StringValuePair( "height", "Invalid" ) ); + Image image = NewImage( map ); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "value.GetType()", TEST_LOCATION ); + } + + // Invalid height + try + { + Property::Map map; + map.push_back( Property::StringValuePair( "width", 10 ) ); + map.push_back( Property::StringValuePair( "height", "Invalid" ) ); + Image image = NewImage( map ); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "value.GetType()", TEST_LOCATION ); + } + + // Invalid pixel-format + try + { + Property::Map map; + map.push_back( Property::StringValuePair( "pixel-format", Vector3::ZERO ) ); + Image image = NewImage( map ); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION ); + + // Invalid value + try + { + Property::Map map; + map.push_back( Property::StringValuePair( "pixel-format", "INVALID" ) ); + Image image = NewImage( map ); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION ); + } + } + + // Invalid scaling-mode + try + { + Property::Map map; + map.push_back( Property::StringValuePair( "scaling-mode", Vector3::ZERO ) ); + Image image = NewImage( map ); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION ); + + // Invalid value + try + { + Property::Map map; + map.push_back( Property::StringValuePair( "scaling-mode", "INVALID" ) ); + Image image = NewImage( map ); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION ); + } + } + + // Invalid crop + try + { + Property::Map map; + map.push_back( Property::StringValuePair( "crop", "Invalid" ) ); + Image image = NewImage( map ); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "map.GetValue(field).GetType()", TEST_LOCATION ); + } + + // Invalid type + try + { + Property::Map map; + map.push_back( Property::StringValuePair( "type", Vector3::ZERO ) ); + Image image = NewImage( map ); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "map.GetValue(\"type\").GetType()", TEST_LOCATION ); + + // Invalid value + try + { + Property::Map map; + map.push_back( Property::StringValuePair( "type", "INVALID" ) ); + Image image = NewImage( map ); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "!\"Unknown", TEST_LOCATION ); + } + } + END_TEST; +} + + +////////////////////////////////////////////////////////////////////////////// + +int UtcDaliScriptingNewImage(void) +{ + TestApplication application; + + Property::Map map; + map.push_back( Property::StringValuePair( "filename", "TEST_FILE" ) ); + + // Filename only + { + Image image = NewImage( map ); + DALI_TEST_EQUALS( "TEST_FILE", image.GetFilename(), TEST_LOCATION ); + } + + // load-policy + map.push_back( Property::StringValuePair( "load-policy", "" ) ); + { + const StringEnum values[] = + { + { "IMMEDIATE", Image::Immediate }, + { "ON_DEMAND", Image::OnDemand } + }; + TestEnumStrings< Image::LoadPolicy, Image >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &Image::GetLoadPolicy, &NewImage ); + } + + // release-policy + map.push_back( Property::StringValuePair( "release-policy", "" ) ); + { + const StringEnum values[] = + { + { "UNUSED", Image::Unused }, + { "NEVER", Image::Never } + }; + TestEnumStrings< Image::ReleasePolicy, Image >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &Image::GetReleasePolicy, &NewImage ); + } + + // float width and height + map.push_back( Property::StringValuePair( "width", (float) 10.0f ) ); + map.push_back( Property::StringValuePair( "height", (float) 20.0f ) ); + { + Image image = NewImage( map ); + DALI_TEST_EQUALS( image.GetWidth(), 10.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( image.GetHeight(), 20.0f, TEST_LOCATION ); + } + + // int width and height + map.erase( map.end() - 2, map.end() ); + map.push_back( Property::StringValuePair( "width", 50 ) ); + map.push_back( Property::StringValuePair( "height", 70 ) ); + { + Image image = NewImage( map ); + DALI_TEST_EQUALS( image.GetWidth(), 50u, TEST_LOCATION ); + DALI_TEST_EQUALS( image.GetHeight(), 70u, TEST_LOCATION ); + } + + //map.erase( map.end() - 2, map.end() ); + + // pixel-format + map.push_back( Property::StringValuePair( "pixel-format", "" ) ); + { + const StringEnum values[] = + { + { "A8", Pixel::A8 }, + { "L8", Pixel::L8 }, + { "LA88", Pixel::LA88 }, + { "RGB565", Pixel::RGB565 }, + { "BGR565", Pixel::BGR565 }, + { "RGBA4444", Pixel::RGBA4444 }, + { "BGRA4444", Pixel::BGRA4444 }, + { "RGBA5551", Pixel::RGBA5551 }, + { "BGRA5551", Pixel::BGRA5551 }, + { "RGB888", Pixel::RGB888 }, + { "RGB8888", Pixel::RGB8888 }, + { "BGR8888", Pixel::BGR8888 }, + { "RGBA8888", Pixel::RGBA8888 }, + { "BGRA8888", Pixel::BGRA8888 }, + { "COMPRESSED_R11_EAC", Pixel::COMPRESSED_R11_EAC }, + { "COMPRESSED_SIGNED_R11_EAC", Pixel::COMPRESSED_SIGNED_R11_EAC }, + { "COMPRESSED_RG11_EAC", Pixel::COMPRESSED_RG11_EAC }, + { "COMPRESSED_SIGNED_RG11_EAC", Pixel::COMPRESSED_SIGNED_RG11_EAC }, + { "COMPRESSED_RGB8_ETC2", Pixel::COMPRESSED_RGB8_ETC2 }, + { "COMPRESSED_SRGB8_ETC2", Pixel::COMPRESSED_SRGB8_ETC2 }, + { "COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2", Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 }, + { "COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2", Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 }, + { "COMPRESSED_RGBA8_ETC2_EAC", Pixel::COMPRESSED_RGBA8_ETC2_EAC }, + { "COMPRESSED_SRGB8_ALPHA8_ETC2_EAC", Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC }, + { "COMPRESSED_RGB8_ETC1", Pixel::COMPRESSED_RGB8_ETC1 }, + { "COMPRESSED_RGB_PVRTC_4BPPV1", Pixel::COMPRESSED_RGB_PVRTC_4BPPV1 }, + { "A8", Pixel::A8 }, // Checked already but reset so that BitmapImage works + }; + TestEnumStrings< Pixel::Format, ImageAttributes >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &ImageAttributes::GetPixelFormat, &NewImageAttributes ); + } + + // scaling-mode + map.push_back( Property::StringValuePair( "scaling-mode", "" ) ); + { + const StringEnum values[] = + { + { "SHRINK_TO_FIT", ImageAttributes::ShrinkToFit }, + { "SCALE_TO_FILL", ImageAttributes::ScaleToFill }, + { "FIT_WIDTH", ImageAttributes::FitWidth }, + { "FIT_HEIGHT", ImageAttributes::FitHeight }, + }; + TestEnumStrings< ImageAttributes::ScalingMode, ImageAttributes >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &ImageAttributes::GetScalingMode, &NewImageAttributes ); + } + + // crop + map.push_back( Property::StringValuePair( "crop", Vector4( 50, 60, 70, 80 ) ) ); + { + Image image = NewImage( map ); + ImageAttributes attributes = image.GetAttributes(); + Rect crop = attributes.GetCrop(); + DALI_TEST_EQUALS( crop.x, 50, TEST_LOCATION ); + DALI_TEST_EQUALS( crop.y, 60, TEST_LOCATION ); + DALI_TEST_EQUALS( crop.width, 70, TEST_LOCATION ); + DALI_TEST_EQUALS( crop.height, 80, TEST_LOCATION ); + } + + // type FrameBufferImage + map.push_back( Property::StringValuePair( "type", "FrameBufferImage" ) ); + { + Image image = NewImage( map ); + DALI_TEST_CHECK( FrameBufferImage::DownCast( image ) ); + } + // type BitMapImage + (map.end() - 1)->second = "BitmapImage"; + { + Image image = NewImage( map ); + DALI_TEST_CHECK( BitmapImage::DownCast( image ) ); + } + // type Image + (map.end() - 1)->second = "Image"; + { + Image image = NewImage( map ); + DALI_TEST_CHECK( Image::DownCast( image ) ); + DALI_TEST_CHECK( !FrameBufferImage::DownCast( image ) ); + DALI_TEST_CHECK( !BitmapImage::DownCast( image ) ); + } + END_TEST; +} + +int UtcDaliScriptingNewShaderEffect(void) +{ + TestApplication application; + + Property::Map programMap; + programMap.push_back( Property::StringValuePair( "vertex-filename", "bump.vert" ) ); + programMap.push_back( Property::StringValuePair( "fragment-filename", "bump.frag" ) ); + + Property::Map imageMap; + imageMap.push_back( Property::StringValuePair( "filename", "image.png" ) ); + + Property::Map map; + map.push_back( Property::StringValuePair( "image", imageMap ) ); + map.push_back( Property::StringValuePair( "program", programMap ) ); + map.push_back( Property::StringValuePair( "uLightPosition", Vector3( 0.0, 0.0, -1.5) ) ); + map.push_back( Property::StringValuePair( "uAmbientLight", (int)10 ) ); + + ShaderEffect shader = NewShaderEffect( map ); + + DALI_TEST_CHECK( shader ); + END_TEST; +} + +int UtcDaliScriptingNewActorNegative(void) +{ + TestApplication application; + + // Empty map + { + Actor handle = NewActor( Property::Map() ); + DALI_TEST_CHECK( !handle ); + } + + // Map with only properties + { + Property::Map map; + map.push_back( Property::StringValuePair( "parent-origin", ParentOrigin::TOP_CENTER ) ); + map.push_back( Property::StringValuePair( "anchor-point", AnchorPoint::TOP_CENTER ) ); + Actor handle = NewActor( map ); + DALI_TEST_CHECK( !handle ); + } + + // Add some signals to the map, we should have no signal connections as its not yet supported + { + Property::Map map; + map.push_back( Property::StringValuePair( "type", "Actor" ) ); + map.push_back( Property::StringValuePair( "signals", Property::MAP ) ); + Actor handle = NewActor( map ); + DALI_TEST_CHECK( handle ); + DALI_TEST_CHECK( !handle.MouseWheelEventSignal().GetConnectionCount() ); + DALI_TEST_CHECK( !handle.OffStageSignal().GetConnectionCount() ); + DALI_TEST_CHECK( !handle.OnStageSignal().GetConnectionCount() ); + DALI_TEST_CHECK( !handle.SetSizeSignal().GetConnectionCount() ); + DALI_TEST_CHECK( !handle.TouchedSignal().GetConnectionCount() ); + } + END_TEST; +} + +int UtcDaliScriptingNewActorProperties(void) +{ + TestApplication application; + + Property::Map map; + map.push_back( Property::StringValuePair( "type", "Actor" ) ); + map.push_back( Property::StringValuePair( "size", Vector3::ONE ) ); + map.push_back( Property::StringValuePair( "position", Vector3::XAXIS ) ); + map.push_back( Property::StringValuePair( "scale", Vector3::ONE ) ); + map.push_back( Property::StringValuePair( "visible", false ) ); + map.push_back( Property::StringValuePair( "color", Color::MAGENTA ) ); + map.push_back( Property::StringValuePair( "name", "MyActor" ) ); + map.push_back( Property::StringValuePair( "color-mode", "USE_PARENT_COLOR" ) ); + map.push_back( Property::StringValuePair( "inherit-shader-effect", false ) ); + map.push_back( Property::StringValuePair( "sensitive", false ) ); + map.push_back( Property::StringValuePair( "leave-required", true ) ); + map.push_back( Property::StringValuePair( "position-inheritance", "DONT_INHERIT_POSITION" ) ); + map.push_back( Property::StringValuePair( "draw-mode", "STENCIL" ) ); + map.push_back( Property::StringValuePair( "inherit-rotation", false ) ); + map.push_back( Property::StringValuePair( "inherit-scale", false ) ); + + // Default properties + { + Actor handle = NewActor( map ); + DALI_TEST_CHECK( handle ); + + Stage::GetCurrent().Add( handle ); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( handle.GetCurrentSize(), Vector3::ONE, TEST_LOCATION ); + DALI_TEST_EQUALS( handle.GetCurrentPosition(), Vector3::XAXIS, TEST_LOCATION ); + DALI_TEST_EQUALS( handle.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + DALI_TEST_EQUALS( handle.IsVisible(), false, TEST_LOCATION ); + DALI_TEST_EQUALS( handle.GetCurrentColor(), Color::MAGENTA, TEST_LOCATION ); + DALI_TEST_EQUALS( handle.GetName(), "MyActor", TEST_LOCATION ); + DALI_TEST_EQUALS( handle.GetColorMode(), USE_PARENT_COLOR, TEST_LOCATION ); + DALI_TEST_EQUALS( handle.GetInheritShaderEffect(), false, TEST_LOCATION ); + DALI_TEST_EQUALS( handle.IsSensitive(), false, TEST_LOCATION ); + DALI_TEST_EQUALS( handle.GetLeaveRequired(), true, TEST_LOCATION ); + DALI_TEST_EQUALS( handle.GetPositionInheritanceMode(), DONT_INHERIT_POSITION, TEST_LOCATION ); + DALI_TEST_EQUALS( handle.GetDrawMode(), DrawMode::STENCIL, TEST_LOCATION ); + DALI_TEST_EQUALS( handle.IsRotationInherited(), false, TEST_LOCATION ); + DALI_TEST_EQUALS( handle.IsScaleInherited(), false, TEST_LOCATION ); + + Stage::GetCurrent().Remove( handle ); + } + + // Check Anchor point and parent origin vector3s + map.push_back( Property::StringValuePair( "parent-origin", ParentOrigin::TOP_CENTER ) ); + map.push_back( Property::StringValuePair( "anchor-point", AnchorPoint::TOP_LEFT ) ); + { + Actor handle = NewActor( map ); + DALI_TEST_CHECK( handle ); + + Stage::GetCurrent().Add( handle ); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( handle.GetCurrentParentOrigin(), ParentOrigin::TOP_CENTER, TEST_LOCATION ); + DALI_TEST_EQUALS( handle.GetCurrentAnchorPoint(), AnchorPoint::TOP_LEFT, TEST_LOCATION ); + + Stage::GetCurrent().Remove( handle ); + } + + // Check Anchor point and parent origin STRINGS + map.erase( map.end() - 2, map.end() ); // delete previously added parent origin and anchor point + map.push_back( Property::StringValuePair( "parent-origin", "BACK_TOP_LEFT" ) ); + map.push_back( Property::StringValuePair( "anchor-point", "FRONT_CENTER_LEFT" ) ); + { + Actor handle = NewActor( map ); + DALI_TEST_CHECK( handle ); + + Stage::GetCurrent().Add( handle ); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( handle.GetCurrentParentOrigin(), ParentOrigin::BACK_TOP_LEFT, TEST_LOCATION ); + DALI_TEST_EQUALS( handle.GetCurrentAnchorPoint(), AnchorPoint::FRONT_CENTER_LEFT, TEST_LOCATION ); + + Stage::GetCurrent().Remove( handle ); + } + END_TEST; +} + +int UtcDaliScriptingNewActorChildren(void) +{ + TestApplication application; + + Property::Map map; + map.push_back( Property::StringValuePair( "type", "Actor" ) ); + map.push_back( Property::StringValuePair( "position", Vector3::XAXIS ) ); + + Property::Map child1Map; + child1Map.push_back( Property::StringValuePair( "type", "ImageActor" ) ); + child1Map.push_back( Property::StringValuePair( "position", Vector3::YAXIS ) ); + + Property::Map child2Map; + child2Map.push_back( Property::StringValuePair( "type", "TextActor" ) ); + child2Map.push_back( Property::StringValuePair( "position", Vector3::ZAXIS ) ); + + Property::Map grandChildMap; + grandChildMap.push_back( Property::StringValuePair( "type", "LightActor" ) ); + grandChildMap.push_back( Property::StringValuePair( "position", Vector3::ONE ) ); + + // Add arrays to appropriate maps + Property::Array grandChildArray; + grandChildArray.push_back( grandChildMap ); + Property::Array childArray; + child1Map.push_back( Property::StringValuePair( "actors", grandChildArray ) ); + childArray.push_back( child1Map ); + childArray.push_back( child2Map ); + map.push_back( Property::StringValuePair( "actors", childArray ) ); + + // Create + Actor handle = NewActor( map ); + DALI_TEST_CHECK( handle ); + + Stage::GetCurrent().Add( handle ); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( handle.GetCurrentPosition(), Vector3::XAXIS, TEST_LOCATION ); + DALI_TEST_EQUALS( handle.GetChildCount(), 2u, TEST_LOCATION ); + + Actor child1 = handle.GetChildAt(0); + DALI_TEST_CHECK( child1 ); + DALI_TEST_CHECK( ImageActor::DownCast( child1 ) ); + DALI_TEST_EQUALS( child1.GetCurrentPosition(), Vector3::YAXIS, TEST_LOCATION ); + DALI_TEST_EQUALS( child1.GetChildCount(), 1u, TEST_LOCATION ); + + Actor child2 = handle.GetChildAt(1); + DALI_TEST_CHECK( child2 ); + DALI_TEST_CHECK( TextActor::DownCast( child2 ) ); + DALI_TEST_EQUALS( child2.GetCurrentPosition(), Vector3::ZAXIS, TEST_LOCATION ); + DALI_TEST_EQUALS( child2.GetChildCount(), 0u, TEST_LOCATION ); + + Actor grandChild = child1.GetChildAt( 0 ); + DALI_TEST_CHECK( grandChild ); + DALI_TEST_CHECK( LightActor::DownCast( grandChild ) ); + DALI_TEST_EQUALS( grandChild.GetCurrentPosition(), Vector3::ONE, TEST_LOCATION ); + DALI_TEST_EQUALS( grandChild.GetChildCount(), 0u, TEST_LOCATION ); + + Stage::GetCurrent().Remove( handle ); + END_TEST; +} + + +int UtcDaliScriptingCreatePropertyMapActor(void) +{ + TestApplication application; + + // Actor Type + { + Actor actor = Actor::New(); + + Property::Map map; + CreatePropertyMap( actor, map ); + DALI_TEST_CHECK( !map.empty() ); + Property::Value value( map ); + DALI_TEST_CHECK( value.HasKey( "type" ) ); + DALI_TEST_EQUALS( value.GetValue( "type").Get< std::string >(), "Actor", TEST_LOCATION ); + + Stage::GetCurrent().Remove( actor ); + } + + // ImageActor Type + { + Actor actor = ImageActor::New(); + + Property::Map map; + CreatePropertyMap( actor, map ); + DALI_TEST_CHECK( !map.empty() ); + Property::Value value( map ); + DALI_TEST_CHECK( value.HasKey( "type" ) ); + DALI_TEST_EQUALS( value.GetValue( "type").Get< std::string >(), "ImageActor", TEST_LOCATION ); + + Stage::GetCurrent().Remove( actor ); + } + + // Default properties + { + Actor actor = Actor::New(); + actor.SetSize( Vector3::ONE ); + actor.SetPosition( Vector3::XAXIS ); + actor.SetScale( Vector3::ZAXIS ); + actor.SetVisible( false ); + actor.SetColor( Color::MAGENTA ); + actor.SetName( "MyActor" ); + actor.SetAnchorPoint( AnchorPoint::CENTER_LEFT ); + actor.SetParentOrigin( ParentOrigin::TOP_RIGHT ); + actor.SetInheritShaderEffect( false ); + actor.SetSensitive( false ); + actor.SetLeaveRequired( true ); + actor.SetInheritRotation( false ); + actor.SetInheritScale( false ); + + Stage::GetCurrent().Add( actor ); + application.SendNotification(); + application.Render(); + + Property::Map map; + CreatePropertyMap( actor, map ); + + DALI_TEST_CHECK( !map.empty() ); + Property::Value value( map ); + DALI_TEST_CHECK( value.HasKey( "size" ) ); + DALI_TEST_EQUALS( value.GetValue( "size" ).Get< Vector3 >(), Vector3::ONE, TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "position" ) ); + DALI_TEST_EQUALS( value.GetValue( "position" ).Get< Vector3 >(), Vector3::XAXIS, TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "scale" ) ); + DALI_TEST_EQUALS( value.GetValue( "scale" ).Get< Vector3 >(), Vector3::ZAXIS, TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "visible" ) ); + DALI_TEST_EQUALS( value.GetValue( "visible" ).Get< bool >(), false, TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "color" ) ); + DALI_TEST_EQUALS( value.GetValue( "color" ).Get< Vector4 >(), Color::MAGENTA, TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "name" ) ); + DALI_TEST_EQUALS( value.GetValue( "name").Get< std::string >(), "MyActor", TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "anchor-point" ) ); + DALI_TEST_EQUALS( value.GetValue( "anchor-point" ).Get< Vector3 >(), AnchorPoint::CENTER_LEFT, TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "parent-origin" ) ); + DALI_TEST_EQUALS( value.GetValue( "parent-origin" ).Get< Vector3 >(), ParentOrigin::TOP_RIGHT, TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "inherit-shader-effect" ) ); + DALI_TEST_EQUALS( value.GetValue( "inherit-shader-effect" ).Get< bool >(), false, TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "sensitive" ) ); + DALI_TEST_EQUALS( value.GetValue( "sensitive" ).Get< bool >(), false, TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "leave-required" ) ); + DALI_TEST_EQUALS( value.GetValue( "leave-required" ).Get< bool >(), true, TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "inherit-rotation" ) ); + DALI_TEST_EQUALS( value.GetValue( "inherit-rotation" ).Get< bool >(), false, TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "inherit-scale" ) ); + DALI_TEST_EQUALS( value.GetValue( "inherit-scale" ).Get< bool >(), false, TEST_LOCATION ); + + Stage::GetCurrent().Remove( actor ); + } + + // ColorMode + TestEnumStrings< ColorMode >( "color-mode", application, COLOR_MODE_VALUES, COLOR_MODE_VALUES_COUNT, &Actor::SetColorMode ); + + // PositionInheritanceMode + TestEnumStrings< PositionInheritanceMode >( "position-inheritance", application, POSITION_INHERITANCE_MODE_VALUES, POSITION_INHERITANCE_MODE_VALUES_COUNT, &Actor::SetPositionInheritanceMode ); + + // DrawMode + TestEnumStrings< DrawMode::Type >( "draw-mode", application, DRAW_MODE_VALUES, DRAW_MODE_VALUES_COUNT, &Actor::SetDrawMode ); + + // Children + { + Actor actor = Actor::New(); + Actor child = ImageActor::New(); + Actor grandChild = TextActor::New(); + Actor grandChild2 = LightActor::New(); + actor.Add( child ); + child.Add( grandChild ); + child.Add( grandChild2 ); + + Stage::GetCurrent().Add( actor ); + application.SendNotification(); + application.Render(); + + Property::Map map; + CreatePropertyMap( actor, map ); + DALI_TEST_CHECK( !map.empty() ); + + Property::Value value( map ); + DALI_TEST_CHECK( value.HasKey( "type" ) ); + DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "Actor", TEST_LOCATION ); + + DALI_TEST_CHECK( value.HasKey( "actors" ) ); + Property::Array children( value.GetValue( "actors").Get< Property::Array >() ); + DALI_TEST_CHECK( !children.empty() ); + Property::Map childMap( children[0].Get< Property::Map >() ); + DALI_TEST_CHECK( !childMap.empty() ); + Property::Value childValue( childMap ); + DALI_TEST_CHECK( childValue.HasKey( "type" ) ); + DALI_TEST_EQUALS( childValue.GetValue( "type" ).Get< std::string >(), "ImageActor", TEST_LOCATION ); + + DALI_TEST_CHECK( childValue.HasKey( "actors" ) ); + Property::Array grandChildren( childValue.GetValue( "actors").Get< Property::Array >() ); + DALI_TEST_CHECK( grandChildren.size() == 2u ); + + Property::Map grandChildMap( grandChildren[0].Get< Property::Map >() ); + DALI_TEST_CHECK( !grandChildMap.empty() ); + Property::Value grandChildValue( grandChildMap ); + DALI_TEST_CHECK( grandChildValue.HasKey( "type" ) ); + DALI_TEST_EQUALS( grandChildValue.GetValue( "type" ).Get< std::string >(), "TextActor", TEST_LOCATION ); + + Property::Map grandChild2Map( grandChildren[1].Get< Property::Map >() ); + DALI_TEST_CHECK( !grandChild2Map.empty() ); + Property::Value grandChild2Value( grandChild2Map ); + DALI_TEST_CHECK( grandChild2Value.HasKey( "type" ) ); + DALI_TEST_EQUALS( grandChild2Value.GetValue( "type" ).Get< std::string >(), "LightActor", TEST_LOCATION ); + + Stage::GetCurrent().Remove( actor ); + } + END_TEST; +} + +int UtcDaliScriptingCreatePropertyMapImage(void) +{ + TestApplication application; + + // Empty + { + Image image; + Property::Map map; + CreatePropertyMap( image, map ); + DALI_TEST_CHECK( map.empty() ); + } + + // Default + { + Image image = Image::New( "MY_PATH" ); + + Property::Map map; + CreatePropertyMap( image, map ); + DALI_TEST_CHECK( !map.empty() ); + + Property::Value value( map ); + DALI_TEST_CHECK( value.HasKey( "type" ) ); + DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "Image", TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "filename" ) ); + DALI_TEST_EQUALS( value.GetValue( "filename" ).Get< std::string >(), "MY_PATH", TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "load-policy") ); + DALI_TEST_EQUALS( value.GetValue( "load-policy" ).Get< std::string >(), "IMMEDIATE", TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "release-policy") ); + DALI_TEST_EQUALS( value.GetValue( "release-policy" ).Get< std::string >(), "NEVER", TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "pixel-format") ); + DALI_TEST_EQUALS( value.GetValue( "pixel-format" ).Get< std::string >(), "RGBA8888", TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "scaling-mode") ); + DALI_TEST_EQUALS( value.GetValue( "scaling-mode" ).Get< std::string >(), "SHRINK_TO_FIT", TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "crop" ) ); + DALI_TEST_EQUALS( value.GetValue( "crop" ).Get< Vector4 >(), Vector4( 0.0f, 0.0f, 1.0f, 1.0f ), TEST_LOCATION ); + DALI_TEST_CHECK( !value.HasKey( "width" ) ); + DALI_TEST_CHECK( !value.HasKey( "height" ) ); + } + + // Change values + { + ImageAttributes attributes; + attributes.SetPixelFormat( Pixel::A8 ); + attributes.SetScalingMode( ImageAttributes::FitWidth ); + attributes.SetCrop( Rect< float >( 0.5f, 0.2f, 0.2f, 0.4f ) ); + attributes.SetSize( 300, 400 ); + Image image = Image::New( "MY_PATH", attributes, Image::OnDemand, Image::Unused ); + + Property::Map map; + CreatePropertyMap( image, map ); + DALI_TEST_CHECK( !map.empty() ); + + Property::Value value( map ); + DALI_TEST_CHECK( value.HasKey( "type" ) ); + DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "Image", TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "filename" ) ); + DALI_TEST_EQUALS( value.GetValue( "filename" ).Get< std::string >(), "MY_PATH", TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "load-policy") ); + DALI_TEST_EQUALS( value.GetValue( "load-policy" ).Get< std::string >(), "ON_DEMAND", TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "release-policy") ); + DALI_TEST_EQUALS( value.GetValue( "release-policy" ).Get< std::string >(), "UNUSED", TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "pixel-format") ); + DALI_TEST_EQUALS( value.GetValue( "pixel-format" ).Get< std::string >(), "A8", TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "scaling-mode") ); + DALI_TEST_EQUALS( value.GetValue( "scaling-mode" ).Get< std::string >(), "FIT_WIDTH", TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "crop" ) ); + DALI_TEST_EQUALS( value.GetValue( "crop" ).Get< Vector4 >(), Vector4( 0.5f, 0.2f, 0.2f, 0.4f ), TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "width" ) ); + DALI_TEST_EQUALS( value.GetValue( "width" ).Get< int >(), 300, TEST_LOCATION ); + DALI_TEST_CHECK( value.HasKey( "height" ) ); + DALI_TEST_EQUALS( value.GetValue( "height" ).Get< int >(), 400, TEST_LOCATION ); + } + + // BitmapImage + { + Image image = BitmapImage::New( 200, 300, Pixel::RGBA8888 ); + Property::Map map; + CreatePropertyMap( image, map ); + Property::Value value( map ); + DALI_TEST_CHECK( value.HasKey( "type" ) ); + DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "BitmapImage", TEST_LOCATION ); + } + + // FrameBufferImage + { + Image image = FrameBufferImage::New( 200, 300, Pixel::RGBA8888 ); + Property::Map map; + CreatePropertyMap( image, map ); + Property::Value value( map ); + DALI_TEST_CHECK( value.HasKey( "type" ) ); + DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "FrameBufferImage", TEST_LOCATION ); + } + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-ShaderEffect.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-ShaderEffect.cpp new file mode 100644 index 0000000..e9d368a --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-ShaderEffect.cpp @@ -0,0 +1,215 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +using namespace Dali; + +namespace +{ + +static const char* VertexSource = +"void main()\n" +"{\n" +" gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\n" +" vTexCoord = aTexCoord;\n" +"}\n"; + +static const char* FragmentSource = +"void main()\n" +"{\n" +" gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n" +"}\n"; + +static const char* FragmentSourceUsingExtensions = +"void main()\n" +"{\n" +" float floatValue = 0.5f;\n" +" float test = fwidth(floatValue);\n" +" gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n" +" gl_FragColor.a *= test;\n" +"}\n"; + +const int GETSOURCE_BUFFER_SIZE = 0x10000; + +static const char* TestImageFilename = "icon_wrt.png"; + +} // Anonymous namespace + + +int UtcDaliShaderEffectFromProperties01(void) +{ + TestApplication application; + tet_infoline("UtcDaliShaderEffectFromProperties01()"); + + std::string fragmentShaderPrefix = "#define TEST_FS 1\n#extension GL_OES_standard_derivatives : enable"; + std::string vertexShaderPrefix = "#define TEST_VS 1"; + + // Call render to compile default shaders. + application.SendNotification(); + application.Render(); + application.Render(); + application.Render(); + + GLuint lastShaderCompiledBefore = application.GetGlAbstraction().GetLastShaderCompiled(); + + // create from type registry + + TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "ShaderEffect" ); + DALI_TEST_CHECK( typeInfo ); + ShaderEffect effect = ShaderEffect::DownCast( typeInfo.CreateInstance() ); + DALI_TEST_CHECK( effect ); + + Property::Value programMap = Property::Value(Property::MAP); + + programMap.SetValue("vertex", std::string(VertexSource)); + programMap.SetValue("fragment", std::string(FragmentSource)); + + programMap.SetValue("vertex-prefix", std::string(fragmentShaderPrefix)); + programMap.SetValue("fragment-prefix", std::string(vertexShaderPrefix)); + + programMap.SetValue("geometry-type", "GEOMETRY_TYPE_IMAGE"); + + effect.SetProperty(effect.GetPropertyIndex("program"), programMap); + + Property::Value imageMap = Property::Value(Property::MAP); + imageMap.SetValue("filename", Property::Value(TestImageFilename)); + + effect.SetProperty(effect.GetPropertyIndex("image"), imageMap); + + BitmapImage image(CreateBitmapImage()); + + ImageActor actor = ImageActor::New( image ); + actor.SetSize( 100.0f, 100.0f ); + actor.SetName("TestImageFilenameActor"); + actor.SetShaderEffect(effect); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(); + GLuint lastShaderCompiledAfter = application.GetGlAbstraction().GetLastShaderCompiled(); + bool testResult = false; + + // we should have compiled 4 shaders. + DALI_TEST_CHECK(lastShaderCompiledAfter - lastShaderCompiledBefore == 4); + if (lastShaderCompiledAfter - lastShaderCompiledBefore == 4) + { + char testVertexSourceResult[GETSOURCE_BUFFER_SIZE]; + char testFragmentSourceResult[GETSOURCE_BUFFER_SIZE]; + + // we are interested in the first two. + GLuint vertexShaderId = lastShaderCompiledBefore + 1; + GLuint fragmentShaderId = lastShaderCompiledBefore + 2; + + GLsizei lengthVertexResult; + GLsizei lengthFragmentResult; + + application.GetGlAbstraction().GetShaderSource(vertexShaderId, GETSOURCE_BUFFER_SIZE, &lengthVertexResult, testVertexSourceResult); + application.GetGlAbstraction().GetShaderSource(fragmentShaderId, GETSOURCE_BUFFER_SIZE, &lengthFragmentResult, testFragmentSourceResult); + + int vertexShaderHasPrefix = strncmp(testVertexSourceResult, "#define ", strlen("#define ")); + int fragmentShaderHasPrefix = strncmp(testFragmentSourceResult, "#define ", strlen("#define ")); + testResult = (vertexShaderHasPrefix == 0) && (fragmentShaderHasPrefix == 0); + } + DALI_TEST_CHECK(testResult); + END_TEST; +} + +int UtcDaliShaderEffectFromProperties02(void) +{ + try + { + TestApplication application; + tet_infoline("UtcDaliShaderEffectFromProperties02()"); + + // Call render to compile default shaders. + application.SendNotification(); + application.Render(); + application.Render(); + application.Render(); + + // create from type registry (currently only way to get ShaderEffect with no shader setup in constructor + TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "ShaderEffect" ); + DALI_TEST_CHECK( typeInfo ); + ShaderEffect effect = ShaderEffect::DownCast( typeInfo.CreateInstance() ); + DALI_TEST_CHECK( effect ); + + Property::Value programMap = Property::Value(Property::MAP); + + programMap.SetValue("vertex", std::string(VertexSource)); + programMap.SetValue("fragment", std::string(FragmentSource)); + + // programMap.SetValue("geometry-type", "GEOMETRY_TYPE_IMAGE"); + // dont set by value + programMap.SetValue("geometry-type", GeometryType( GEOMETRY_TYPE_IMAGE )); + + effect.SetProperty(effect.GetPropertyIndex("program"), programMap); + + tet_result( TET_FAIL ); + } + catch(Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + } + END_TEST; +} + +int UtcDaliShaderEffectFromProperties03(void) +{ + try + { + TestApplication application; + tet_infoline("UtcDaliShaderEffectFromProperties03()"); + + // Call render to compile default shaders. + application.SendNotification(); + application.Render(); + application.Render(); + application.Render(); + + // create from type registry (currently only way to get ShaderEffect with no shader setup in constructor + TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "ShaderEffect" ); + DALI_TEST_CHECK( typeInfo ); + ShaderEffect effect = ShaderEffect::DownCast( typeInfo.CreateInstance() ); + DALI_TEST_CHECK( effect ); + + // dont set unknown + effect.SetProperty( effect.GetPropertyIndex("geometry-hints"), "HINT_2" ); + + tet_result( TET_FAIL ); + } + catch(Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + } + END_TEST; +} + +int UtcDaliShaderEffectPropertyIndices(void) +{ + TestApplication application; + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); + + Property::IndexContainer indices; + effect.GetPropertyIndices( indices ); + DALI_TEST_CHECK( ! indices.empty() ); + DALI_TEST_EQUALS( indices.size(), effect.GetPropertyCount(), TEST_LOCATION ); + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-Spline.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-Spline.cpp new file mode 100644 index 0000000..9201338 --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-Spline.cpp @@ -0,0 +1,634 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; +using Dali::Spline; +using Dali::Vector3; + +namespace +{ + +// Knots fed into Allegro, which generates control points +static Spline* SetupBezierSpline1() +{ + Spline *bezierSpline = new Spline(); + + bezierSpline->AddKnot(Vector3( 50.0, 50.0, 0.0)); + bezierSpline->AddKnot(Vector3(120.0, 70.0, 0.0)); + bezierSpline->AddKnot(Vector3(190.0, 250.0, 0.0)); + bezierSpline->AddKnot(Vector3(260.0, 260.0, 0.0)); + bezierSpline->AddKnot(Vector3(330.0, 220.0, 0.0)); + bezierSpline->AddKnot(Vector3(400.0, 50.0, 0.0)); + + bezierSpline->SetInTangent (0, Vector3( 0.0, 0.0, 0.0)); + bezierSpline->SetInTangent (1, Vector3(107.0, 58.0, 0.0)); + bezierSpline->SetInTangent (2, Vector3(152.0, 220.0, 0.0)); + bezierSpline->SetInTangent (3, Vector3(243.0, 263.0, 0.0)); + bezierSpline->SetInTangent (4, Vector3(317.0, 235.0, 0.0)); + bezierSpline->SetInTangent (5, Vector3(383.0, 93.0, 0.0)); + + bezierSpline->SetOutTangent(0, Vector3( 68.0, 55.0, 0.0)); + bezierSpline->SetOutTangent(1, Vector3(156.0, 102.0, 0.0)); + bezierSpline->SetOutTangent(2, Vector3(204.0, 261.0, 0.0)); + bezierSpline->SetOutTangent(3, Vector3(280.0, 256.0, 0.0)); + bezierSpline->SetOutTangent(4, Vector3(360.0, 185.0, 0.0)); + bezierSpline->SetOutTangent(5, Vector3(410.0, 40.0, 0.0)); + return bezierSpline; +} + +// Knots fed into Allegro, which generates control points +static Spline* SetupBezierSpline2() +{ + Spline *spline = new Spline(); + spline->AddKnot(Vector3( 30.0, 80.0, 0.0)); + spline->AddKnot(Vector3( 70.0, 120.0, 0.0)); + spline->AddKnot(Vector3(100.0, 100.0, 0.0)); + spline->SetInTangent (0, Vector3( 0.0, 0.0, 0.0)); + spline->SetInTangent (1, Vector3( 56.0, 119.0, 0.0)); + spline->SetInTangent (2, Vector3( 93.0, 104.0, 0.0)); + spline->SetOutTangent(0, Vector3( 39.0, 90.0, 0.0)); + spline->SetOutTangent(1, Vector3( 78.0, 120.0, 0.0)); + spline->SetOutTangent(2, Vector3(110.0, 90.0, 0.0)); + return spline; +} + + +typedef struct +{ + float x; + float y; +} tPoint; + +tPoint test[] = { + {0.0f, 0.0f}, + {50.0f, 50.0f}, + {120.0f, 70.0f}, + {190.0f, 250.0f}, + {260.0f, 260.0f}, + {330.0f, 220.0f}, + {400.0f, 50.0f}, + {106.0f, 62.5f}, + {242.0f, 261.3f}, + {320.0f, 229.3f}, + {390.0f, 78.1f}, + {399.9999f, 50.0f}, + {401.0f, 0.0f}, + {501.0f, 0.0f}, + {-100.0f, 0.0f}, +}; + +} // anonymous namespace + + + +// Positive test case for a method +int UtcDaliSplineGetYFromMonotonicX(void) +{ + TestApplication application; + + Spline *bezierSpline = SetupBezierSpline1(); + + + for(unsigned int i=0; iGetYFromMonotonicX(test[i].x), + (float)test[i].y, 0.1f, + TEST_LOCATION); + } + + delete bezierSpline; + END_TEST; +} + +int utcDaliSplineGetKnot01(void) +{ + TestApplication application; + + Spline *bezierSpline= new Spline(); + bezierSpline->AddKnot(Vector3( 50.0, 50.0, 0.0)); + bezierSpline->AddKnot(Vector3(120.0, 70.0, 0.0)); + bezierSpline->AddKnot(Vector3(190.0, 250.0, 0.0)); + bezierSpline->AddKnot(Vector3(260.0, 260.0, 0.0)); + bezierSpline->AddKnot(Vector3(330.0, 220.0, 0.0)); + bezierSpline->AddKnot(Vector3(400.0, 50.0, 0.0)); + + DALI_TEST_EQUALS(bezierSpline->GetKnot(0), Vector3( 50.0, 50.0, 0.0), TEST_LOCATION); + DALI_TEST_EQUALS(bezierSpline->GetKnot(1), Vector3(120.0, 70.0, 0.0), TEST_LOCATION); + DALI_TEST_EQUALS(bezierSpline->GetKnot(2), Vector3(190.0, 250.0, 0.0), TEST_LOCATION); + DALI_TEST_EQUALS(bezierSpline->GetKnot(3), Vector3(260.0, 260.0, 0.0), TEST_LOCATION); + DALI_TEST_EQUALS(bezierSpline->GetKnot(4), Vector3(330.0, 220.0, 0.0), TEST_LOCATION); + DALI_TEST_EQUALS(bezierSpline->GetKnot(5), Vector3(400.0, 50.0, 0.0), TEST_LOCATION); + END_TEST; +} + +int utcDaliSplineGetKnot02(void) +{ + TestApplication application; + + Spline *bezierSpline= new Spline(); + bezierSpline->AddKnot(Vector3( 50.0, 50.0, 0.0f)); + + try + { + bezierSpline->GetKnot(1); + tet_result(TET_FAIL); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "knotIndex < mKnots.size()", TEST_LOCATION); + } + END_TEST; +} + +int utcDaliSplineGetKnot03(void) +{ + TestApplication application; + + Spline *bezierSpline= new Spline(); + + try + { + bezierSpline->GetKnot(0); + tet_result(TET_FAIL); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "knotIndex < mKnots.size()", TEST_LOCATION); + } + END_TEST; +} + +int utcDaliSplineGetInTangent01(void) +{ + TestApplication application; + + Spline *bezierSpline= new Spline(); + bezierSpline->AddKnot(Vector3( 50.0, 50.0, 0.0)); + bezierSpline->AddKnot(Vector3(120.0, 70.0, 0.0)); + bezierSpline->SetInTangent(0, Vector3(0.0f, 0.0f, 0.0)); // Intangent for initial value is unused + bezierSpline->SetInTangent(1, Vector3(108.0f, 57.0f, 0.0)); + + DALI_TEST_EQUALS(bezierSpline->GetInTangent(0), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION); + DALI_TEST_EQUALS(bezierSpline->GetInTangent(1), Vector3(108.0f, 57.0f, 0.0f), TEST_LOCATION); + END_TEST; +} + + + +int utcDaliSplineGetInTangent02(void) +{ + TestApplication application; + + Spline *bezierSpline= new Spline(); + bezierSpline->AddKnot(Vector3( 50.0, 50.0, 0.0)); + bezierSpline->AddKnot(Vector3(120.0, 70.0, 0.0)); + bezierSpline->SetInTangent(0, Vector3(0.0f, 0.0f, 0.0)); // Intangent for initial value is unused + bezierSpline->SetInTangent(1, Vector3(108.0f, 57.0f, 0.0)); + + try + { + bezierSpline->GetInTangent(5); + tet_result(TET_FAIL); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "knotIndex < mInTangents.size()", TEST_LOCATION); + } + END_TEST; +} + + +int utcDaliSplineGetInTangent03(void) +{ + TestApplication application; + + Spline *bezierSpline= new Spline(); + try + { + bezierSpline->GetInTangent(0); + tet_result(TET_FAIL); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "knotIndex < mInTangents.size()", TEST_LOCATION); + } + END_TEST; +} + + +int utcDaliSplineGetOutTangent01(void) +{ + TestApplication application; + + Spline *bezierSpline= new Spline(); + bezierSpline->AddKnot(Vector3( 50.0, 50.0, 0.0)); + bezierSpline->AddKnot(Vector3(120.0, 70.0, 0.0)); + bezierSpline->SetOutTangent(0, Vector3(0.0f, 0.0f, 0.0)); // Intangent for initial value is unused + bezierSpline->SetOutTangent(1, Vector3(108.0f, 57.0f, 0.0)); + + DALI_TEST_EQUALS(bezierSpline->GetOutTangent(0), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION); + DALI_TEST_EQUALS(bezierSpline->GetOutTangent(1), Vector3(108.0f, 57.0f, 0.0f), TEST_LOCATION); + END_TEST; +} + + + +int utcDaliSplineGetOutTangent02(void) +{ + TestApplication application; + + Spline *bezierSpline= new Spline(); + bezierSpline->AddKnot(Vector3( 50.0, 50.0, 0.0)); + bezierSpline->AddKnot(Vector3(120.0, 70.0, 0.0)); + bezierSpline->SetOutTangent(0, Vector3(0.0f, 0.0f, 0.0)); // Intangent for initial value is unused + bezierSpline->SetOutTangent(1, Vector3(108.0f, 57.0f, 0.0)); + + try + { + bezierSpline->GetOutTangent(5); + tet_result(TET_FAIL); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "knotIndex < mOutTangents.size()", TEST_LOCATION); + } + END_TEST; +} + + +int utcDaliSplineGetOutTangent03(void) +{ + TestApplication application; + + Spline *bezierSpline= new Spline(); + try + { + bezierSpline->GetOutTangent(0); + tet_result(TET_FAIL); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "knotIndex < mOutTangents.size()", TEST_LOCATION); + } + END_TEST; +} + + +int utcDaliSplineGenerateControlPoints01(void) +{ + TestApplication application; + + Spline *bezierSpline = new Spline(); + + bezierSpline->AddKnot(Vector3( 50.0, 50.0, 0.0)); + bezierSpline->AddKnot(Vector3(120.0, 70.0, 0.0)); + bezierSpline->AddKnot(Vector3(190.0, 250.0, 0.0)); + bezierSpline->AddKnot(Vector3(260.0, 260.0, 0.0)); + bezierSpline->AddKnot(Vector3(330.0, 220.0, 0.0)); + bezierSpline->AddKnot(Vector3(400.0, 50.0, 0.0)); + + bezierSpline->GenerateControlPoints(0.25); + + // first in tangent is never used, ignore it. + DALI_TEST_EQUALS(bezierSpline->GetInTangent(1), Vector3(107.0, 58.0, 0.0), 1.0, TEST_LOCATION); + DALI_TEST_EQUALS(bezierSpline->GetInTangent(2), Vector3(152.0, 220.0, 0.0), 1.0, TEST_LOCATION); + DALI_TEST_EQUALS(bezierSpline->GetInTangent(3), Vector3(243.0, 263.0, 0.0), 1.0, TEST_LOCATION); + DALI_TEST_EQUALS(bezierSpline->GetInTangent(4), Vector3(317.0, 235.0, 0.0), 1.0, TEST_LOCATION); + DALI_TEST_EQUALS(bezierSpline->GetInTangent(5), Vector3(383.0, 93.0, 0.0), 1.0, TEST_LOCATION); + + DALI_TEST_EQUALS(bezierSpline->GetOutTangent(0), Vector3( 68.0, 55.0, 0.0), 1.0, TEST_LOCATION); + DALI_TEST_EQUALS(bezierSpline->GetOutTangent(1), Vector3(156.0, 102.0, 0.0), 1.0, TEST_LOCATION); + DALI_TEST_EQUALS(bezierSpline->GetOutTangent(2), Vector3(204.0, 261.0, 0.0), 1.0, TEST_LOCATION); + DALI_TEST_EQUALS(bezierSpline->GetOutTangent(3), Vector3(280.0, 256.0, 0.0), 1.0, TEST_LOCATION); + DALI_TEST_EQUALS(bezierSpline->GetOutTangent(4), Vector3(360.0, 185.0, 0.0), 1.0, TEST_LOCATION); + // last out tangent is never used, ignore it. + END_TEST; +} + +int utcDaliSplineGenerateControlPoints02(void) +{ + TestApplication application; + + Spline *bezierSpline = new Spline(); + try + { + bezierSpline->GenerateControlPoints(0.25); + tet_result(TET_FAIL); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "numKnots > 1", TEST_LOCATION); + } + END_TEST; +} + + +int utcDaliSplineGenerateControlPoints03(void) +{ + TestApplication application; + + Spline *bezierSpline = new Spline(); + bezierSpline->AddKnot(Vector3(400.0, 50.0, 0.0f)); + try + { + bezierSpline->GenerateControlPoints(0.25); + tet_result(TET_FAIL); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "numKnots > 1", TEST_LOCATION); + } + END_TEST; +} + + +int UtcDaliSplineGetY01(void) +{ + TestApplication application; + Spline *spline = SetupBezierSpline2(); + + DALI_TEST_EQUALS(spline->GetY(0, 0.0f), 80.0f, TEST_LOCATION); // First control point + DALI_TEST_EQUALS(spline->GetY(0, 0.5f), 102.0f, 2.0f, TEST_LOCATION); + DALI_TEST_EQUALS(spline->GetY(0, 1.0f), 120.0f, TEST_LOCATION); // Second control point + DALI_TEST_EQUALS(spline->GetY(1, 0.0f), 120.0f, TEST_LOCATION); // Second control point + DALI_TEST_EQUALS(spline->GetY(1, 0.5f), 112.0f, 2.0f, TEST_LOCATION); + DALI_TEST_EQUALS(spline->GetY(1, 1.0f), 100.0f, TEST_LOCATION); // Third control point + delete spline; + END_TEST; +} + +// Test segments outside range (should assert and fail tetcase!) +int UtcDaliSplineGetY02(void) +{ + TestApplication application; + + try + { + Spline *spline = SetupBezierSpline2(); + spline->GetY(3, 0.0f); // Segment outside range - expect assertion + + // If we get here, assertion hasn't triggered. + tet_result(TET_FAIL); + delete spline; + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "segmentIndex+1 < mKnots.size() && segmentIndex < mKnots.size()", TEST_LOCATION); + } + END_TEST; +} + +// Test segments outside range (should assert and fail tetcase!) +int UtcDaliSplineGetY02b(void) +{ + TestApplication application; + try + { + Spline *spline = SetupBezierSpline2(); + spline->GetY(-1, 0.0f); // Segment outside range - expect assertion + + // If we get here, assertion hasn't triggered. + tet_result(TET_FAIL); + delete spline; + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "segmentIndex+1 < mKnots.size() && segmentIndex < mKnots.size()", TEST_LOCATION); + } + END_TEST; +} + + +// Test parameter ouside 0-1 - should return 0. +int UtcDaliSplineGetY03(void) +{ + TestApplication application; + Spline *spline = SetupBezierSpline2(); + DALI_TEST_EQUALS(spline->GetY(1, -1.0f), 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS(spline->GetY(1, 2.0f), 0.0f, TEST_LOCATION); + delete spline; + END_TEST; +} + +// Test on empty spline - should assert +int UtcDaliSplineGetY04(void) +{ + TestApplication application; + try + { + Spline *spline = new Spline(); + spline->GetY(0, 0.0f); // Should assert + tet_result(TET_FAIL); + delete spline; + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "segmentIndex+1 < mKnots.size() && segmentIndex < mKnots.size()", TEST_LOCATION); + } + END_TEST; +} + + +// Test on empty spline - should assert +int UtcDaliSplineGetY04b(void) +{ + TestApplication application; + try + { + Spline *spline = new Spline(); + spline->GetY(0, 1.0f); + tet_result(TET_FAIL); // assertion didn't trigger + delete spline; + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "segmentIndex+1 < mKnots.size() && segmentIndex < mKnots.size()", TEST_LOCATION); + } + END_TEST; +} + + + +int UtcDaliSplineGetPoint01(void) +{ + TestApplication application; + Spline *spline = SetupBezierSpline2(); + + // Test control points + Vector3 pt = spline->GetPoint(0, 0.0f); + DALI_TEST_EQUALS(pt.x, 30.0f, TEST_LOCATION); + DALI_TEST_EQUALS(pt.y, 80.0f, TEST_LOCATION); + + // Test control points + pt = spline->GetPoint(0, 1.0f); + DALI_TEST_EQUALS(pt.x, 70.0f, TEST_LOCATION); + DALI_TEST_EQUALS(pt.y, 120.0f, TEST_LOCATION); + + // Halfway point computed using Allegro engine + pt = spline->GetPoint(0, 0.5f); + DALI_TEST_EQUALS(pt.x, 47.0f, 2.0f, TEST_LOCATION); + DALI_TEST_EQUALS(pt.y, 102.0f, 2.0f, TEST_LOCATION); + + // Test control point + pt = spline->GetPoint(1, 0.0f); + DALI_TEST_EQUALS(pt.x, 70.0f, TEST_LOCATION); + DALI_TEST_EQUALS(pt.y, 120.0f, TEST_LOCATION); + + // Halfway point computed using Allegro engine + pt = spline->GetPoint(1, 0.5f); + DALI_TEST_EQUALS(pt.x, 85.0f, 2.0f, TEST_LOCATION); + DALI_TEST_EQUALS(pt.y, 112.0f, 2.0f, TEST_LOCATION); + + // Test control points + pt = spline->GetPoint(1, 1.0f); + DALI_TEST_EQUALS(pt.x, 100.0f, TEST_LOCATION); + DALI_TEST_EQUALS(pt.y, 100.0f, TEST_LOCATION); + delete spline; + END_TEST; +} + + +int UtcDaliSplineGetPoint02(void) +{ + TestApplication application; + Spline *spline = SetupBezierSpline2(); + + // Test control points + Vector3 pt = spline->GetPoint(0.0f); + DALI_TEST_EQUALS(pt.x, 30.0f, TEST_LOCATION); + DALI_TEST_EQUALS(pt.y, 80.0f, TEST_LOCATION); + + // Halfway point computed using Allegro engine + pt = spline->GetPoint(0.25f); + DALI_TEST_EQUALS(pt.x, 47.0f, 2.0f, TEST_LOCATION); + DALI_TEST_EQUALS(pt.y, 102.0f, 2.0f, TEST_LOCATION); + + // Test control points + pt = spline->GetPoint(0.5f); + DALI_TEST_EQUALS(pt.x, 70.0f, TEST_LOCATION); + DALI_TEST_EQUALS(pt.y, 120.0f, TEST_LOCATION); + + // Halfway point computed using Allegro engine + pt = spline->GetPoint(0.75f); + DALI_TEST_EQUALS(pt.x, 85.0f, 2.0f, TEST_LOCATION); + DALI_TEST_EQUALS(pt.y, 112.0f, 2.0f, TEST_LOCATION); + + // Test control points + pt = spline->GetPoint(1.0f); + DALI_TEST_EQUALS(pt.x, 100.0f, TEST_LOCATION); + DALI_TEST_EQUALS(pt.y, 100.0f, TEST_LOCATION); + delete spline; + END_TEST; +} + + +// Test on segment index out of bounds - should assert and fail tet case +int UtcDaliSplineGetPoint03(void) +{ + TestApplication application; + try + { + Spline *spline = SetupBezierSpline2(); + + spline->GetPoint(-1, 0.5f); // should assert + tet_result(TET_FAIL); + delete spline; + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "segmentIndex+1 < mKnots.size() && segmentIndex < mKnots.size()", TEST_LOCATION); + } + END_TEST; +} + +// Test on segment index out of bounds - should assert and fail tet case +int UtcDaliSplineGetPoint04(void) +{ + TestApplication application; + try + { + Spline *spline = SetupBezierSpline2(); + + spline->GetPoint(123, 0.5f); // should assert + tet_result(TET_FAIL); + delete spline; + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "segmentIndex+1 < mKnots.size() && segmentIndex < mKnots.size()", TEST_LOCATION); + } + END_TEST; +} + + +// Test on parameter out of bounds - should return 0,0 +int UtcDaliSplineGetPoint05(void) +{ + TestApplication application; + Spline *spline = SetupBezierSpline2(); + + Vector3 pt = spline->GetPoint(0, -32.0f); + DALI_TEST_EQUALS(pt.x, 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS(pt.y, 0.0f, TEST_LOCATION); + + pt = spline->GetPoint(0, 23444.0f); + DALI_TEST_EQUALS(pt.x, 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS(pt.y, 0.0f, TEST_LOCATION); + END_TEST; +} + +// Test on empty spline - should assert and fail tet case +int UtcDaliSplineGetPoint06(void) +{ + TestApplication application; + try + { + Spline *spline = new Spline(); + spline->GetPoint(0, 23444.0f); + tet_result(TET_FAIL); + delete(spline); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "segmentIndex+1 < mKnots.size() && segmentIndex < mKnots.size()", TEST_LOCATION); + } + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-TypeRegistry.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-TypeRegistry.cpp new file mode 100644 index 0000000..2e7265a --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-TypeRegistry.cpp @@ -0,0 +1,1111 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 +#include +#include +#include +#include +#include + +using namespace Dali; + + +namespace +{ + +// Stores data that is populated in the callback and will be read by the Test cases +struct SignalData +{ + SignalData() + : functorCalled( false ), + voidFunctorCalled( false ), + receivedGesture( Gesture::Clear ), + pressedActor() + {} + + void Reset() + { + functorCalled = false; + voidFunctorCalled = false; + + receivedGesture.numberOfTouches = 0u; + receivedGesture.screenPoint = Vector2(0.0f, 0.0f); + receivedGesture.localPoint = Vector2(0.0f, 0.0f); + + pressedActor = NULL; + } + + bool functorCalled; + bool voidFunctorCalled; + LongPressGesture receivedGesture; + Actor pressedActor; +}; + +// Functor that sets the data when called +struct GestureReceivedFunctor +{ + GestureReceivedFunctor(SignalData& data) : signalData(data) { } + + void operator()(Actor actor, LongPressGesture longPress) + { + signalData.functorCalled = true; + signalData.receivedGesture = longPress; + signalData.pressedActor = actor; + } + + void operator()() + { + signalData.voidFunctorCalled = true; + } + + SignalData& signalData; +}; + +// Generate a LongPressGestureEvent to send to Core +Integration::LongPressGestureEvent GenerateLongPress( + Gesture::State state, + unsigned int numberOfTouches, + Vector2 point) +{ + Integration::LongPressGestureEvent longPress( state ); + + longPress.numberOfTouches = numberOfTouches; + longPress.point = point; + + return longPress; +} + +// Generate a PanGestureEvent to send to Core +Integration::PanGestureEvent GeneratePan( + Gesture::State state, + Vector2 previousPosition, + Vector2 currentPosition, + unsigned long timeDelta, + unsigned int numberOfTouches = 1, + unsigned int time = 1u) +{ + Integration::PanGestureEvent pan(state); + + pan.previousPosition = previousPosition; + pan.currentPosition = currentPosition; + pan.timeDelta = timeDelta; + pan.numberOfTouches = numberOfTouches; + pan.time = time; + + return pan; +} +// Generate a PinchGestureEvent to send to Core +Integration::PinchGestureEvent GeneratePinch( + Gesture::State state, + float scale, + float speed, + Vector2 centerpoint) +{ + Integration::PinchGestureEvent pinch(state); + + pinch.scale = scale; + pinch.speed = speed; + pinch.centerPoint = centerpoint; + + return pinch; +} +// Generate a TapGestureEvent to send to Core +Integration::TapGestureEvent GenerateTap( + Gesture::State state, + unsigned int numberOfTaps, + unsigned int numberOfTouches, + Vector2 point) +{ + Integration::TapGestureEvent tap( state ); + + tap.numberOfTaps = numberOfTaps; + tap.numberOfTouches = numberOfTouches; + tap.point = point; + + return tap; +} + +// +// Create function as Init function called +// +static bool CreateCustomInitCalled = false; +BaseHandle CreateCustomInit(void) +{ + CreateCustomInitCalled = true; + return BaseHandle(); +} + +static bool CreateCustomNamedInitCalled = false; +BaseHandle CreateCustomNamedInit(void) +{ + CreateCustomNamedInitCalled = true; + return BaseHandle(); +} + +const std::string scriptedName("PopupStyle"); +static TypeRegistration scriptedType( scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit ); + +// Property Registration +bool setPropertyCalled = false; +bool getPropertyCalled = false; +void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value ) +{ + setPropertyCalled = true; +} +Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex ) +{ + getPropertyCalled = true; + return Property::Value( true ); +} + + + +/******************************************************************************* + * + * Custom Actor + * + ******************************************************************************/ +namespace Impl +{ +struct MyTestCustomActor : public CustomActorImpl +{ + typedef SignalV2< void ()> SignalType; + typedef SignalV2< void (float)> SignalTypeFloat; + + MyTestCustomActor() : CustomActorImpl( true ) // requires touch + { } + + virtual ~MyTestCustomActor() + { } + + void ResetCallStack() + { + } + + // From CustomActorImpl + virtual void OnStageConnection() + { + } + virtual void OnStageDisconnection() + { + } + virtual void OnChildAdd(Actor& child) + { + } + virtual void OnChildRemove(Actor& child) + { + } + virtual void OnSizeSet(const Vector3& targetSize) + { + } + virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize) + { + } + virtual bool OnTouchEvent(const TouchEvent& event) + { + return true; + } + virtual bool OnMouseWheelEvent(const MouseWheelEvent& event) + { + return true; + } + virtual bool OnKeyEvent(const KeyEvent& event) + { + return true; + } + virtual void OnKeyInputFocusGained() + { + } + virtual void OnKeyInputFocusLost() + { + } + virtual Actor GetChildByAlias(const std::string& actorAlias) + { + return Actor::New(); + } + +public: + + SignalType mSignal; +}; + +}; // namespace Impl + +class MyTestCustomActor : public CustomActor +{ +public: + + typedef SignalV2< void ()> SignalType; + typedef SignalV2< void (float)> SignalTypeFloat; + + MyTestCustomActor() + { + } + + static MyTestCustomActor New() + { + Impl::MyTestCustomActor* p = new Impl::MyTestCustomActor; + return MyTestCustomActor( *p ); // takes ownership + } + + virtual ~MyTestCustomActor() + { + } + + static MyTestCustomActor DownCast( BaseHandle handle ) + { + MyTestCustomActor result; + + CustomActor custom = Dali::CustomActor::DownCast( handle ); + if ( custom ) + { + CustomActorImpl& customImpl = custom.GetImplementation(); + + Impl::MyTestCustomActor* impl = dynamic_cast(&customImpl); + + if (impl) + { + result = MyTestCustomActor(customImpl.GetOwner()); + } + } + + return result; + } + + SignalType& GetCustomSignal() + { + Dali::RefObject& obj = GetImplementation(); + return static_cast( obj ).mSignal; + } + +private: + + MyTestCustomActor(Internal::CustomActor* internal) + : CustomActor(internal) + { + } + + MyTestCustomActor( Impl::MyTestCustomActor& impl ) + : CustomActor( impl ) + { + } +}; + + +class MyTestCustomActor2 : public CustomActor +{ +public: + + MyTestCustomActor2() + { + } + + static MyTestCustomActor2 New() + { + return MyTestCustomActor2(); // takes ownership + } + + virtual ~MyTestCustomActor2() + { + } + + static MyTestCustomActor2 DownCast( BaseHandle handle ) + { + MyTestCustomActor2 result; + + CustomActor custom = Dali::CustomActor::DownCast( handle ); + if ( custom ) + { + CustomActorImpl& customImpl = custom.GetImplementation(); + + Impl::MyTestCustomActor* impl = dynamic_cast(&customImpl); + + if (impl) + { + result = MyTestCustomActor2(customImpl.GetOwner()); + } + } + + return result; + } + +private: + + MyTestCustomActor2(Internal::CustomActor* internal) + : CustomActor(internal) + { + } + + MyTestCustomActor2( Impl::MyTestCustomActor& impl ) + : CustomActor( impl ) + { + } +}; + +static TypeRegistration customTypeInit( typeid(MyTestCustomActor2), typeid(Dali::CustomActor), CreateCustomInit, true ); + + +BaseHandle CreateCustom(void) +{ + return MyTestCustomActor::New(); +} + +static std::string lastSignalConnectionCustom; + +bool DoConnectSignalCustom( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ) +{ + lastSignalConnectionCustom = signalName; + + bool connected( true ); + + Dali::BaseHandle handle(object); + MyTestCustomActor customActor = MyTestCustomActor::DownCast(handle); + + if( "sig1" == signalName ) + { + customActor.GetCustomSignal().Connect( tracker, functor ); + } + else + { + // signalName does not match any signal + connected = false; + } + + return connected; +} + +bool DoConnectSignalCustomFailure( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ) +{ + lastSignalConnectionCustom = "failed"; + + return false; // This is supposed to fail +} + +struct CustomTestFunctor +{ + CustomTestFunctor() + { + ++mTotalInstanceCount; + ++mCurrentInstanceCount; + } + + CustomTestFunctor( const CustomTestFunctor& copyMe ) + { + ++mTotalInstanceCount; + ++mCurrentInstanceCount; + } + + ~CustomTestFunctor() + { + --mCurrentInstanceCount; + } + + void operator()() + { + ++mCallbackCount; + } + + static int mTotalInstanceCount; + static int mCurrentInstanceCount; + static int mCallbackCount; +}; + +int CustomTestFunctor::mTotalInstanceCount = 0; +int CustomTestFunctor::mCurrentInstanceCount = 0; +int CustomTestFunctor::mCallbackCount = 0; + +static void ResetFunctorCounts() +{ + CustomTestFunctor::mTotalInstanceCount = 0; + CustomTestFunctor::mCurrentInstanceCount = 0; + CustomTestFunctor::mCallbackCount = 0; +} + +static std::string lastActionCustom; +bool DoActionCustom(BaseObject* object, const std::string& actionName, const std::vector& attributes) +{ + lastActionCustom = actionName; + return true; +} + +// Custom type registration +static TypeRegistration customType1( typeid(MyTestCustomActor), typeid(Dali::CustomActor), CreateCustom ); + +// Custom signals +static SignalConnectorType customSignalConnector1( customType1, "sig1", DoConnectSignalCustom ); +static SignalConnectorType customSignalConnector2( customType1, "sig2", DoConnectSignalCustomFailure ); +static const int TEST_SIGNAL_COUNT = 2; + +// Custom actions +static TypeAction customAction1( customType1, "act1", DoActionCustom); +static const int TEST_ACTION_COUNT = 1; + +class TestConnectionTracker : public ConnectionTracker +{ +public: + + TestConnectionTracker() + { + } +}; + +} // Anonymous namespace + + +// Positive test case for a method +int UtcDaliTypeRegistryCreateDaliObjects(void) +{ + TestApplication application; + + TypeRegistry registry; // like this for ctor test coverage + registry = TypeRegistry::Get(); + + TypeInfo type; + + type = registry.GetTypeInfo( "ImageActor" ); + DALI_TEST_CHECK( type ); + DALI_TEST_CHECK( type.GetCreator() ); + DALI_TEST_CHECK( ImageActor::DownCast( type.GetCreator()() ) ); + ImageActor ia = ImageActor::DownCast(type.CreateInstance()); + DALI_TEST_CHECK( ia ); + Stage::GetCurrent().Add( ia ); + application.Render(); + + type = registry.GetTypeInfo( "TextActor" ); + DALI_TEST_CHECK( type ); + TextActor ta = TextActor::DownCast(type.CreateInstance()); + DALI_TEST_CHECK( ta ); + Stage::GetCurrent().Add( ta ); + application.Render(); + + type = registry.GetTypeInfo( "CameraActor" ); + DALI_TEST_CHECK( type ); + CameraActor ca = CameraActor::DownCast(type.CreateInstance()); + DALI_TEST_CHECK( ca ); + Stage::GetCurrent().Add( ca ); + application.Render(); + + type = registry.GetTypeInfo( "LightActor" ); + DALI_TEST_CHECK( type ); + LightActor la = LightActor::DownCast(type.CreateInstance()); + DALI_TEST_CHECK( la ); + Stage::GetCurrent().Add( la ); + application.Render(); + + // animations + type = registry.GetTypeInfo( "Animation" ); + DALI_TEST_CHECK( type ); + Animation an = Animation::DownCast(type.CreateInstance()); + DALI_TEST_CHECK( an ); + an.Play(); + application.Render(); + + // + type = registry.GetTypeInfo( "ShaderEffect" ); + DALI_TEST_CHECK( type ); + ShaderEffect ef = ShaderEffect::DownCast(type.CreateInstance()); + DALI_TEST_CHECK( ef ); + application.Render(); + + END_TEST; +} + +/******************************************************************************* + * + * Action through the base handle + * + ******************************************************************************/ +int UtcDaliTypeRegistryActionViaBaseHandle(void) +{ + TestApplication application; + + TypeInfo type; + + type = TypeRegistry::Get().GetTypeInfo( "Actor" ); + DALI_TEST_CHECK( type ); + + BaseHandle hdl = type.CreateInstance(); + DALI_TEST_CHECK( hdl ); + + Actor a = Actor::DownCast(hdl); + DALI_TEST_CHECK( a ); + + a.SetVisible(false); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK(!a.IsVisible()); + + std::vector attributes; + + DALI_TEST_CHECK(hdl.DoAction(Actor::ACTION_SHOW, attributes)); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK(a.IsVisible()); + + DALI_TEST_CHECK(!hdl.DoAction("unknown-action", attributes)); + END_TEST; +} + +int UtcDaliTypeRegistryNames(void) +{ + TestApplication application; + + TypeInfo type; + + TypeRegistry::NameContainer names = TypeRegistry::Get().GetTypeNames(); + + for(TypeRegistry::NameContainer::iterator iter = names.begin(); + iter != names.end(); ++iter) + { + type = TypeRegistry::Get().GetTypeInfo( *iter ); + DALI_TEST_CHECK( type ); + } + + END_TEST; +} + +// Check named and typeid are equivalent +int UtcDaliTypeRegistryNameEquivalence(void) +{ + TypeInfo named_type = TypeRegistry::Get().GetTypeInfo( "TextActor" ); + TypeInfo typeinfo_type = TypeRegistry::Get().GetTypeInfo( typeid(Dali::TextActor) ); + + DALI_TEST_CHECK( named_type ); + DALI_TEST_CHECK( typeinfo_type ); + + DALI_TEST_CHECK( named_type == typeinfo_type ); + + DALI_TEST_CHECK( named_type.GetName() == typeinfo_type.GetName() ); + DALI_TEST_CHECK( named_type.GetBaseName() == typeinfo_type.GetBaseName() ); + + END_TEST; +} + + +int UtcDaliTypeRegistryCustomActor(void) +{ + ResetFunctorCounts(); + + TestApplication application; + + TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" ); + DALI_TEST_CHECK( type ); + + TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" ); + DALI_TEST_CHECK( baseType ); + + BaseHandle handle = type.CreateInstance(); + DALI_TEST_CHECK( handle ); + + MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle ); + DALI_TEST_CHECK( customHandle ); + + DALI_TEST_EQUALS( type.GetActions().size(), TEST_ACTION_COUNT + baseType.GetActions().size(), TEST_LOCATION ); + DALI_TEST_EQUALS( type.GetSignals().size(), TEST_SIGNAL_COUNT + baseType.GetSignals().size(), TEST_LOCATION ); + + { + TestConnectionTracker tracker; + + bool connected = handle.ConnectSignal( &tracker, "sig1", CustomTestFunctor() ); + DALI_TEST_EQUALS( connected, true, TEST_LOCATION ); + DALI_TEST_CHECK( lastSignalConnectionCustom == "sig1" ); + DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION ); + DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION ); + + DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION ); + customHandle.GetCustomSignal().Emit(); + DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION ); + DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION ); + DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 1, TEST_LOCATION ); + } + // tracker should automatically disconnect here + DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION ); + DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION ); + + // Test that functor is disconnected + DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1, TEST_LOCATION ); + customHandle.GetCustomSignal().Emit(); + DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 1/*not incremented*/, TEST_LOCATION ); + DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION ); + DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0, TEST_LOCATION ); + + std::vector attributes; + handle.DoAction("act1", attributes); + DALI_TEST_CHECK( lastActionCustom == "act1" ); + END_TEST; +} + +int UtcDaliTypeRegistryCustomSignalFailure(void) +{ + // Test what happens when signal connnector (DoConnectSignalFailure method) returns false + + ResetFunctorCounts(); + + TestApplication application; + + TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor" ); + DALI_TEST_CHECK( type ); + + TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( "CustomActor" ); + DALI_TEST_CHECK( baseType ); + + BaseHandle handle = type.CreateInstance(); + DALI_TEST_CHECK( handle ); + + MyTestCustomActor customHandle = MyTestCustomActor::DownCast( handle ); + DALI_TEST_CHECK( customHandle ); + + DALI_TEST_EQUALS( type.GetActions().size(), TEST_ACTION_COUNT + baseType.GetActions().size(), TEST_LOCATION ); + DALI_TEST_EQUALS( type.GetSignals().size(), TEST_SIGNAL_COUNT + baseType.GetSignals().size(), TEST_LOCATION ); + + { + TestConnectionTracker tracker; + + bool connected = handle.ConnectSignal( &tracker, "sig2", CustomTestFunctor() ); + DALI_TEST_EQUALS( connected, false/*This is supposed to fail*/, TEST_LOCATION ); + DALI_TEST_CHECK( lastSignalConnectionCustom == "failed" ); + DALI_TEST_EQUALS( CustomTestFunctor::mTotalInstanceCount, 2/*temporary copy + FunctorDelegate copy*/, TEST_LOCATION ); + DALI_TEST_EQUALS( CustomTestFunctor::mCurrentInstanceCount, 0/*deleted along with FunctorDelegate*/, TEST_LOCATION ); + + // Should be a NOOP + DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION ); + customHandle.GetCustomSignal().Emit(); + DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION ); + } + // tracker should have nothing to disconnect here + + // Should be a NOOP + DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0, TEST_LOCATION ); + customHandle.GetCustomSignal().Emit(); + DALI_TEST_EQUALS( CustomTestFunctor::mCallbackCount, 0/*never called*/, TEST_LOCATION ); + END_TEST; +} + + + +int UtcDaliTypeRegistryInitFunctions(void) +{ + TestApplication application; + + DALI_TEST_CHECK( "MyTestCustomActor2" == customTypeInit.RegisteredName() ); + + DALI_TEST_CHECK( true == CreateCustomInitCalled ); + TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor2" ); + DALI_TEST_CHECK( type ); + END_TEST; +} + + + + +int UtcDaliTypeRegistryNameInitFunctions(void) +{ + TestApplication application; + + DALI_TEST_CHECK( scriptedName == scriptedType.RegisteredName() ); + + TypeInfo baseType = TypeRegistry::Get().GetTypeInfo( scriptedName ); + DALI_TEST_CHECK( baseType ); + + BaseHandle handle = baseType.CreateInstance(); + + DALI_TEST_CHECK( true == CreateCustomNamedInitCalled ); + TypeInfo type = TypeRegistry::Get().GetTypeInfo( scriptedName ); + DALI_TEST_CHECK( type ); + END_TEST; +} + + +int UtcDaliPropertyRegistration(void) +{ + TestApplication application; + TypeRegistry typeRegistry = TypeRegistry::Get(); + + // Check property count before property registration + TypeInfo typeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) ); + DALI_TEST_CHECK( typeInfo ); + BaseHandle handle = typeInfo.CreateInstance(); + DALI_TEST_CHECK( handle ); + Actor customActor = Actor::DownCast( handle ); + DALI_TEST_CHECK( customActor ); + unsigned int initialPropertyCount( customActor.GetPropertyCount() ); + + std::string propertyName( "prop-1" ); + int propertyIndex( PROPERTY_REGISTRATION_START_INDEX ); + Property::Type propertyType( Property::BOOLEAN ); + PropertyRegistration property1( customType1, propertyName, propertyIndex, propertyType, &SetProperty, &GetProperty ); + + // Check property count after registration + unsigned int postRegistrationPropertyCount( customActor.GetPropertyCount() ); + DALI_TEST_EQUALS( initialPropertyCount + 1u, postRegistrationPropertyCount, TEST_LOCATION ); + + // Add custom property and check property count + customActor.RegisterProperty( "custom-prop-1", true ); + unsigned int customPropertyCount( customActor.GetPropertyCount() ); + DALI_TEST_EQUALS( postRegistrationPropertyCount + 1u, customPropertyCount, TEST_LOCATION ); + + // Set the property, ensure SetProperty called + DALI_TEST_CHECK( !setPropertyCalled ); + customActor.SetProperty( propertyIndex, false ); + DALI_TEST_CHECK( setPropertyCalled ); + + // Get the property, ensure GetProperty called + DALI_TEST_CHECK( !getPropertyCalled ); + (void)customActor.GetProperty< bool >( propertyIndex ); + DALI_TEST_CHECK( getPropertyCalled ); + + // Check the property name + DALI_TEST_EQUALS( customActor.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION ); + DALI_TEST_EQUALS( typeInfo.GetPropertyName( propertyIndex ), propertyName, TEST_LOCATION ); + + // Check the property index + DALI_TEST_EQUALS( customActor.GetPropertyIndex( propertyName ), propertyIndex, TEST_LOCATION ); + + // Check the property type + DALI_TEST_EQUALS( customActor.GetPropertyType( propertyIndex ), propertyType, TEST_LOCATION ); + + // Check property count of type-info is 1 + Property::IndexContainer indices; + typeInfo.GetPropertyIndices( indices ); + DALI_TEST_EQUALS( indices.size(), 1u, TEST_LOCATION ); + + // Ensure indices returned from actor and customActor differ by two + Actor actor = Actor::New(); + actor.GetPropertyIndices( indices ); + unsigned int actorIndices = indices.size(); + customActor.GetPropertyIndices( indices ); + unsigned int customActorIndices = indices.size(); + DALI_TEST_EQUALS( actorIndices + 2u, customActorIndices, TEST_LOCATION ); // Custom property + registered property + END_TEST; +} + +int UtcDaliPropertyRegistrationIndexOutOfBounds(void) +{ + TestApplication application; + TypeRegistry typeRegistry = TypeRegistry::Get(); + + // Attempt to register a property type out-of-bounds index (less than) + try + { + PropertyRegistration property1( customType1, "prop-name", PROPERTY_REGISTRATION_START_INDEX - 1, Property::BOOLEAN, &SetProperty, &GetProperty ); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION ); + } + + // Attempt to register a property type out-of-bounds index (greater than) + try + { + PropertyRegistration property1( customType1, "prop-name", PROPERTY_REGISTRATION_MAX_INDEX + 1, Property::BOOLEAN, &SetProperty, &GetProperty ); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX )", TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliPropertyRegistrationFunctions(void) +{ + TestApplication application; + int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 10; + + // Attempt to register a property without a setter + try + { + PropertyRegistration property1( customType1, "prop-name", propertyIndex++, Property::BOOLEAN, NULL, &GetProperty ); + tet_result( TET_PASS ); + } + catch ( DaliException& e ) + { + tet_result( TET_FAIL ); + } + + // Attempt to register a property without a getter + try + { + PropertyRegistration property1( customType1, "prop-name", propertyIndex++, Property::BOOLEAN, NULL, NULL ); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "! \"GetProperty", TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliPropertyRegistrationAddSameIndex(void) +{ + TestApplication application; + int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 100; + + // Add one property with a valid property index + PropertyRegistration property1( customType1, "prop-name", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty ); + + // Attempt to add another property with the same index + try + { + PropertyRegistration property2( customType1, "prop-name-2", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "! \"Property index already added", TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliPropertyRegistrationPropertyWritable(void) +{ + TestApplication application; + int propertyIndex1 = PROPERTY_REGISTRATION_START_INDEX + 200; + int propertyIndex2 = PROPERTY_REGISTRATION_START_INDEX + 201; + + // Add two properties, one with SetProperty, one without + PropertyRegistration property1( customType1, "prop-name-readwrite", propertyIndex1, Property::BOOLEAN, &SetProperty, &GetProperty ); + PropertyRegistration property2( customType1, "prop-name-readonly", propertyIndex2, Property::BOOLEAN, NULL, &GetProperty ); + + // Create custom-actor + TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) ); + DALI_TEST_CHECK( typeInfo ); + BaseHandle handle = typeInfo.CreateInstance(); + DALI_TEST_CHECK( handle ); + Actor customActor = Actor::DownCast( handle ); + DALI_TEST_CHECK( customActor ); + + // Check whether properties are writable + DALI_TEST_CHECK( customActor.IsPropertyWritable( propertyIndex1 ) ); + DALI_TEST_CHECK( ! customActor.IsPropertyWritable( propertyIndex2 ) ); + END_TEST; +} + +int UtcDaliPropertyRegistrationPropertyAnimatable(void) +{ + TestApplication application; + int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 400; + + // These properties are not animatable + PropertyRegistration property1( customType1, "prop-name", propertyIndex, Property::BOOLEAN, &SetProperty, &GetProperty ); + + // Create custom-actor + TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) ); + DALI_TEST_CHECK( typeInfo ); + BaseHandle handle = typeInfo.CreateInstance(); + DALI_TEST_CHECK( handle ); + Actor customActor = Actor::DownCast( handle ); + DALI_TEST_CHECK( customActor ); + + // Check if animatable + DALI_TEST_CHECK( ! customActor.IsPropertyAnimatable( propertyIndex ) ); + END_TEST; +} + +int UtcDaliPropertyRegistrationInvalidGetAndSet(void) +{ + TestApplication application; + int propertyIndex = PROPERTY_REGISTRATION_START_INDEX + 2000; + + // Create custom-actor + TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(MyTestCustomActor) ); + DALI_TEST_CHECK( typeInfo ); + BaseHandle handle = typeInfo.CreateInstance(); + DALI_TEST_CHECK( handle ); + Actor customActor = Actor::DownCast( handle ); + DALI_TEST_CHECK( customActor ); + + // Try to set an index that hasn't been added + try + { + customActor.SetProperty( propertyIndex, true ); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION ); + } + + // Try to get an index that hasn't been added + try + { + (void) customActor.GetProperty< bool >( propertyIndex ); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "! \"Cannot find property index", TEST_LOCATION ); + } + END_TEST; +} + + + +int UtcDaliLongPressGestureDetectorTypeRegistry(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Register Type + TypeInfo type; + type = TypeRegistry::Get().GetTypeInfo( "LongPressGestureDetector" ); + DALI_TEST_CHECK( type ); + BaseHandle handle = type.CreateInstance(); + DALI_TEST_CHECK( handle ); + LongPressGestureDetector detector = LongPressGestureDetector::DownCast( handle ); + DALI_TEST_CHECK( detector ); + + // Attach actor to detector + SignalData data; + GestureReceivedFunctor functor( data ); + detector.Attach(actor); + + // Connect to signal through type + handle.ConnectSignal( &application, LongPressGestureDetector::SIGNAL_LONG_PRESS_DETECTED, functor ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Emit gesture + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureDetectorTypeRegistry(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Register Type + TypeInfo type; + type = TypeRegistry::Get().GetTypeInfo( "PanGestureDetector" ); + DALI_TEST_CHECK( type ); + BaseHandle handle = type.CreateInstance(); + DALI_TEST_CHECK( handle ); + PanGestureDetector detector = PanGestureDetector::DownCast( handle ); + DALI_TEST_CHECK( detector ); + + // Attach actor to detector + SignalData data; + GestureReceivedFunctor functor( data ); + detector.Attach(actor); + + // Connect to signal through type + handle.ConnectSignal( &application, PanGestureDetector::SIGNAL_PAN_DETECTED, functor ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Emit gesture + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPinchGestureDetectorTypeRegistry(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Register Type + TypeInfo type; + type = TypeRegistry::Get().GetTypeInfo( "PinchGestureDetector" ); + DALI_TEST_CHECK( type ); + BaseHandle handle = type.CreateInstance(); + DALI_TEST_CHECK( handle ); + PinchGestureDetector detector = PinchGestureDetector::DownCast( handle ); + DALI_TEST_CHECK( detector ); + + // Attach actor to detector + SignalData data; + GestureReceivedFunctor functor( data ); + detector.Attach(actor); + + // Connect to signal through type + handle.ConnectSignal( &application, PinchGestureDetector::SIGNAL_PINCH_DETECTED, functor ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Emit gesture + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliTapGestureDetectorTypeRegistry(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Register Type + TypeInfo type; + type = TypeRegistry::Get().GetTypeInfo( "TapGestureDetector" ); + DALI_TEST_CHECK( type ); + BaseHandle handle = type.CreateInstance(); + DALI_TEST_CHECK( handle ); + TapGestureDetector detector = TapGestureDetector::DownCast( handle ); + DALI_TEST_CHECK( detector ); + + // Attach actor to detector + SignalData data; + GestureReceivedFunctor functor( data ); + detector.Attach(actor); + + // Connect to signal through type + handle.ConnectSignal( &application, TapGestureDetector::SIGNAL_TAP_DETECTED, functor ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Emit gesture + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.voidFunctorCalled, TEST_LOCATION); + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-Utf8.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-Utf8.cpp new file mode 100644 index 0000000..7f5c1c8 --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-Utf8.cpp @@ -0,0 +1,44 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; + + +// Positive test case for a method +int UtcDaliUtf8SequenceLength(void) +{ + tet_infoline("UtcDaliUtf8SequenceLength "); + TestApplication application; + + std::string latinText( "amazing" ); + std::string japaneseText( "すごい" ); + std::string accent("é"); + + tet_infoline("utf8 1 byte Test "); + DALI_TEST_EQUALS( Utf8SequenceLength( latinText[0] ), 1u, TEST_LOCATION ); + tet_infoline("utf8 3 byte Test "); + DALI_TEST_EQUALS( Utf8SequenceLength( japaneseText[0] ), 3u, TEST_LOCATION ); + tet_infoline("utf8 2 byte Test "); + DALI_TEST_EQUALS( Utf8SequenceLength( accent[0] ), 2u, TEST_LOCATION ); + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-Vector.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-Vector.cpp new file mode 100644 index 0000000..9e4018b --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-Vector.cpp @@ -0,0 +1,796 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; + +namespace +{ + +const Dali::VectorBase::SizeType ZERO(0); + +} + + +int UtcDaliEmptyVectorInt(void) +{ + tet_infoline("Testing Dali::Vector"); + + Vector< int > intvector; + + DALI_TEST_EQUALS( ZERO, intvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, intvector.Capacity(), TEST_LOCATION ); + + intvector.Clear(); + DALI_TEST_EQUALS( ZERO, intvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, intvector.Capacity(), TEST_LOCATION ); + + intvector.Release(); + DALI_TEST_EQUALS( ZERO, intvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, intvector.Capacity(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliVectorInt(void) +{ + tet_infoline("Testing Dali::Vector"); + + Vector< int > intvector; + + DALI_TEST_EQUALS( ZERO, intvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, intvector.Capacity(), TEST_LOCATION ); + + intvector.PushBack( 11 ); + DALI_TEST_EQUALS( static_cast(1), intvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( static_cast(2), intvector.Capacity(), TEST_LOCATION ); + DALI_TEST_EQUALS( 11, intvector[ 0 ], TEST_LOCATION ); + + intvector.PushBack( 99 ); + DALI_TEST_EQUALS( static_cast(2), intvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( static_cast(2), intvector.Capacity(), TEST_LOCATION ); + DALI_TEST_EQUALS( 99, intvector[ 1 ], TEST_LOCATION ); + + intvector.PushBack( 34 ); + DALI_TEST_EQUALS( static_cast(3), intvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( static_cast(6), intvector.Capacity(), TEST_LOCATION ); + DALI_TEST_EQUALS( 11, intvector[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( 99, intvector[ 1 ], TEST_LOCATION ); + DALI_TEST_EQUALS( 34, intvector[ 2 ], TEST_LOCATION ); + + intvector.Clear(); + DALI_TEST_EQUALS( ZERO, intvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( static_cast(6), intvector.Capacity(), TEST_LOCATION ); + intvector.PushBack( 123 ); + DALI_TEST_EQUALS( static_cast(1), intvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( 123, intvector[ 0 ], TEST_LOCATION ); + END_TEST; +} + +int UtcDaliVectorIntCopy(void) +{ + tet_infoline("Testing Dali::Vector::Copy"); + + Vector< int > intvector; + DALI_TEST_EQUALS( ZERO, intvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, intvector.Capacity(), TEST_LOCATION ); + + intvector.PushBack( 99 ); + intvector.PushBack( 11 ); + intvector.PushBack( 34 ); + + // copy construct + Vector< int > intvector2( intvector ); + + DALI_TEST_EQUALS( intvector2.Count(), intvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( intvector2.Capacity(), intvector.Capacity(), TEST_LOCATION ); + DALI_TEST_EQUALS( intvector2[ 0 ], intvector[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( intvector2[ 1 ], intvector[ 1 ], TEST_LOCATION ); + DALI_TEST_EQUALS( intvector2[ 2 ], intvector[ 2 ], TEST_LOCATION ); + + // assign + Vector< int > intvector3; + DALI_TEST_EQUALS( ZERO, intvector3.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, intvector3.Capacity(), TEST_LOCATION ); + intvector2 = intvector3; + DALI_TEST_EQUALS( intvector2.Count(), intvector3.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( intvector2.Capacity(), intvector3.Capacity(), TEST_LOCATION ); + + // copy empty + Vector< int > intvector4; + intvector4.Reserve( 100 ); + DALI_TEST_EQUALS( ZERO, intvector4.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( static_cast(100), intvector4.Capacity(), TEST_LOCATION ); + intvector3 = intvector4; + DALI_TEST_EQUALS( ZERO, intvector3.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( static_cast(100), intvector3.Capacity(), TEST_LOCATION ); + + // self copy + intvector4 = intvector4; + DALI_TEST_EQUALS( ZERO, intvector4.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( static_cast(100), intvector4.Capacity(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliVectorIntResize(void) +{ + tet_infoline("Testing Dali::Vector::Resize"); + + Vector< short > vector; + DALI_TEST_EQUALS( ZERO, vector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, vector.Capacity(), TEST_LOCATION ); + + vector.Resize( 10u ); + DALI_TEST_EQUALS( static_cast(10), vector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( static_cast(10), vector.Capacity(), TEST_LOCATION ); + + vector.Resize( 4u ); + DALI_TEST_EQUALS( static_cast(4), vector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( static_cast(10), vector.Capacity(), TEST_LOCATION ); + + vector.Resize( 4u ); + DALI_TEST_EQUALS( static_cast(4), vector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( static_cast(10), vector.Capacity(), TEST_LOCATION ); + + vector.Resize( 0u ); + DALI_TEST_EQUALS( ZERO, vector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( static_cast(10), vector.Capacity(), TEST_LOCATION ); + + vector.Resize( 12u, 123 ); + DALI_TEST_EQUALS( static_cast(12), vector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( static_cast(12), vector.Capacity(), TEST_LOCATION ); + + DALI_TEST_EQUALS( vector[ 0 ], 123, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 1 ], 123, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 2 ], 123, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 3 ], 123, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 4 ], 123, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 5 ], 123, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 6 ], 123, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 7 ], 123, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 8 ], 123, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 9 ], 123, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 10 ], 123, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 11 ], 123, TEST_LOCATION ); + + vector.Resize( 13u, 321 ); + DALI_TEST_EQUALS( static_cast(13), vector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( static_cast(13), vector.Capacity(), TEST_LOCATION ); + + DALI_TEST_EQUALS( vector[ 0 ], 123, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 1 ], 123, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 2 ], 123, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 3 ], 123, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 4 ], 123, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 5 ], 123, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 6 ], 123, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 7 ], 123, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 8 ], 123, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 9 ], 123, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 10 ], 123, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 11 ], 123, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 12 ], 321, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliVectorIntErase(void) +{ + tet_infoline("Testing Dali::Vector::Erase"); + + Vector< char > vector; + DALI_TEST_EQUALS( ZERO, vector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, vector.Capacity(), TEST_LOCATION ); + vector.PushBack( 1 ); + vector.PushBack( 2 ); + vector.PushBack( 3 ); + vector.PushBack( 4 ); + vector.PushBack( 5 ); + DALI_TEST_EQUALS( static_cast(5), vector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 0 ], 1, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 1 ], 2, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 2 ], 3, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 3 ], 4, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 4 ], 5, TEST_LOCATION ); + + vector.Erase( vector.Begin() ); + DALI_TEST_EQUALS( static_cast(4), vector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 0 ], 2, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 1 ], 3, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 2 ], 4, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 3 ], 5, TEST_LOCATION ); + + Vector< char >::Iterator ret = vector.Erase( std::find( vector.Begin(), vector.End(), 4 ) ); + DALI_TEST_EQUALS( static_cast(3), vector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 0 ], 2, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 1 ], 3, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 2 ], 5, TEST_LOCATION ); + DALI_TEST_EQUALS( *ret, 5, TEST_LOCATION ); + + // try erasing last + vector.PushBack( 99 ); + DALI_TEST_EQUALS( static_cast(4), vector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 3 ], 99, TEST_LOCATION ); + ret = vector.Erase( vector.End() - 1 ); + DALI_TEST_EQUALS( static_cast(3), vector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( ret, vector.End(), TEST_LOCATION ); + + try + { + // illegal erase, one past the end + vector.Erase( vector.End() ); + tet_result(TET_FAIL); + } + catch( Dali::DaliException& e ) + { + tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT( e, "(iterator < End())", TEST_LOCATION ); + } + catch( ... ) + { + tet_printf("Assertion test failed - wrong Exception\n" ); + tet_result(TET_FAIL); + } + DALI_TEST_EQUALS( static_cast(3), vector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 0 ], 2, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 1 ], 3, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 2 ], 5, TEST_LOCATION ); + + vector.Erase( vector.Begin() + 1 ); + DALI_TEST_EQUALS( static_cast(2), vector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 0 ], 2, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 1 ], 5, TEST_LOCATION ); + + vector.Erase( vector.Begin() + 1 ); + DALI_TEST_EQUALS( static_cast(1), vector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 0 ], 2, TEST_LOCATION ); + + try + { + // illegal erase, one past the end + vector.Erase( vector.Begin() + 1 ); + tet_result(TET_FAIL); + } + catch( Dali::DaliException& e ) + { + tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT( e, "(iterator < End())", TEST_LOCATION ); + } + catch( ... ) + { + tet_printf("Assertion test failed - wrong Exception\n" ); + tet_result(TET_FAIL); + } + DALI_TEST_EQUALS( static_cast(1), vector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 0 ], 2, TEST_LOCATION ); + + vector.Erase( vector.Begin() ); + DALI_TEST_EQUALS( ZERO, vector.Count(), TEST_LOCATION ); + + try + { + // illegal erase, one before the beginning + vector.Erase( vector.Begin() - 1 ); + tet_result(TET_FAIL); + } + catch( Dali::DaliException& e ) + { + tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT( e, "(iterator < End())", TEST_LOCATION ); + } + catch( ... ) + { + tet_printf("Assertion test failed - wrong Exception\n" ); + tet_result(TET_FAIL); + } + + DALI_TEST_EQUALS( ZERO, vector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( vector.Begin(), vector.End(), TEST_LOCATION ); + + Vector< char >::Iterator endIter = vector.End(); + for( Vector< char >::Iterator iter = vector.Begin(); iter != endIter; ++iter ) + { + tet_result(TET_FAIL); + } + + vector.PushBack( 3 ); + DALI_TEST_EQUALS( static_cast(1), vector.Count(), TEST_LOCATION ); + + vector.Clear(); + DALI_TEST_EQUALS( ZERO, vector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( vector.Begin(), vector.End(), TEST_LOCATION ); + + endIter = vector.End(); + for( Vector< char >::Iterator iter = vector.Begin(); iter != endIter; ++iter ) + { + tet_result(TET_FAIL); + } + + // test a vector of pointers + Vector< int* > ptrVector; + DALI_TEST_EQUALS( ZERO, ptrVector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( ptrVector.Begin(), ptrVector.End(), TEST_LOCATION ); + + int* pointer = NULL; + ptrVector.PushBack( pointer ); + DALI_TEST_EQUALS( static_cast(1), ptrVector.Count(), TEST_LOCATION ); + + Vector< int* >::Iterator ptriter = std::find( ptrVector.Begin(), ptrVector.End(), pointer ); + ptriter = ptrVector.Erase( ptriter ); + DALI_TEST_EQUALS( ZERO, ptrVector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( ptrVector.Begin(), ptrVector.End(), TEST_LOCATION ); + DALI_TEST_EQUALS( ptrVector.Begin(), ptriter, TEST_LOCATION ); + END_TEST; +} + + +int UtcDaliVectorDoubleRemove(void) +{ + tet_infoline("Testing Dali::Vector::Remove"); + + Vector< double > vector; + DALI_TEST_EQUALS( ZERO, vector.Count(), TEST_LOCATION ); + + vector.PushBack( 11.1 ); + vector.PushBack( 22.2 ); + vector.PushBack( 33.3 ); + vector.PushBack( 44.4 ); + DALI_TEST_EQUALS( static_cast(4), vector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 0 ], 11.1, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 1 ], 22.2, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 2 ], 33.3, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 3 ], 44.4, TEST_LOCATION ); + + Vector< double >::Iterator res = std::find( vector.Begin(), vector.End(), 22.2 ); + DALI_TEST_EQUALS( 22.2, *res, TEST_LOCATION ); + vector.Remove( res ); + res = std::find( vector.Begin(), vector.End(), 22.2 ); + DALI_TEST_EQUALS( vector.End(), res, TEST_LOCATION ); + DALI_TEST_EQUALS( static_cast(3), vector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 0 ], 11.1, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 1 ], 44.4, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 2 ], 33.3, TEST_LOCATION ); + + vector.Remove( vector.End() - 1 ); + DALI_TEST_EQUALS( static_cast(2), vector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 0 ], 11.1, TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 1 ], 44.4, TEST_LOCATION ); + + vector.Remove( vector.Begin() ); + DALI_TEST_EQUALS( static_cast(1), vector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 0 ], 44.4, TEST_LOCATION ); + + try + { + // illegal erase, one past the end + vector.Remove( vector.Begin() + 1 ); + tet_result(TET_FAIL); + } + catch( Dali::DaliException& e ) + { + tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT( e, "(iterator < end)", TEST_LOCATION ); + } + catch( ... ) + { + tet_printf("Assertion test failed - wrong Exception\n" ); + tet_result(TET_FAIL); + } + DALI_TEST_EQUALS( static_cast(1), vector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( vector[ 0 ], 44.4, TEST_LOCATION ); + + vector.Remove( vector.Begin() ); + DALI_TEST_EQUALS( ZERO, vector.Count(), TEST_LOCATION ); + + try + { + // illegal erase, one before the beginning + vector.Remove( vector.Begin() - 1 ); + tet_result(TET_FAIL); + } + catch( Dali::DaliException& e ) + { + tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT( e, "(iterator < end) && (iterator >= Begin()", TEST_LOCATION ); + } + catch( ... ) + { + tet_printf("Assertion test failed - wrong Exception\n" ); + tet_result(TET_FAIL); + } + + END_TEST; +} + +int UtcDaliVectorIntSwap(void) +{ + tet_infoline("Testing Dali::Vector::Swap"); + + Vector< int > intvector; + DALI_TEST_EQUALS( ZERO, intvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, intvector.Capacity(), TEST_LOCATION ); + + intvector.PushBack( 11 ); + intvector.PushBack( 22 ); + intvector.PushBack( 33 ); + DALI_TEST_EQUALS( static_cast(3), intvector.Count(), TEST_LOCATION ); + + Vector< int > intvector2; + DALI_TEST_EQUALS( ZERO, intvector2.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, intvector2.Capacity(), TEST_LOCATION ); + + intvector2.Swap( intvector ); + DALI_TEST_EQUALS( ZERO, intvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, intvector.Capacity(), TEST_LOCATION ); + DALI_TEST_EQUALS( static_cast(3), intvector2.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( 11, intvector2[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( 22, intvector2[ 1 ], TEST_LOCATION ); + DALI_TEST_EQUALS( 33, intvector2[ 2 ], TEST_LOCATION ); + + intvector.PushBack( 99 ); + intvector.PushBack( 88 ); + DALI_TEST_EQUALS( static_cast(2), intvector.Count(), TEST_LOCATION ); + + intvector.Swap( intvector2 ); + DALI_TEST_EQUALS( static_cast(2), intvector2.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( 99, intvector2[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( 88, intvector2[ 1 ], TEST_LOCATION ); + DALI_TEST_EQUALS( static_cast(3), intvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( 11, intvector[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( 22, intvector[ 1 ], TEST_LOCATION ); + DALI_TEST_EQUALS( 33, intvector[ 2 ], TEST_LOCATION ); + + Vector< int > empty; + intvector.Swap( empty ); + DALI_TEST_EQUALS( ZERO, intvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, intvector.Capacity(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliVectorIterate(void) +{ + tet_infoline("Testing Dali::Vector::Begin"); + + Vector< float > floatvector; + DALI_TEST_EQUALS( ZERO, floatvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, floatvector.Capacity(), TEST_LOCATION ); + + floatvector.PushBack( 0.9f ); + floatvector.PushBack( 1.1f ); + floatvector.PushBack( 1.2f ); + DALI_TEST_EQUALS( static_cast(3), floatvector.Count(), TEST_LOCATION ); + + Vector< float >::Iterator iter = floatvector.Begin(); + int index = 0; + for( ; iter != floatvector.End(); ++iter, ++index ) + { + std::cout << "value " << *iter << std::endl; + DALI_TEST_EQUALS( *iter, floatvector[ index ], TEST_LOCATION ); + } + DALI_TEST_EQUALS( 3, index, TEST_LOCATION ); + + iter = std::find( floatvector.Begin(), floatvector.End(), 1.1f ); + DALI_TEST_EQUALS( 1.1f, *iter, TEST_LOCATION ); + + floatvector.Clear(); + iter = std::find( floatvector.Begin(), floatvector.End(), 1.1f ); + DALI_TEST_EQUALS( floatvector.End(), iter, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliVectorPair(void) +{ + tet_infoline("Testing Dali::Vector< std::pair< int, float > >"); + + Vector< std::pair< int, float > > pairvector; + DALI_TEST_EQUALS( ZERO, pairvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, pairvector.Capacity(), TEST_LOCATION ); + + pairvector.PushBack( std::make_pair( 5, 0.1f ) ); + pairvector.PushBack( std::make_pair( 3, 0.2f ) ); + pairvector.PushBack( std::make_pair( 4, 0.3f ) ); + pairvector.PushBack( std::make_pair( 1, 0.4f ) ); + pairvector.PushBack( std::make_pair( 2, 0.5f ) ); + DALI_TEST_EQUALS( static_cast(5), pairvector.Count(), TEST_LOCATION ); + + Vector< std::pair< int, float > >::Iterator iter = pairvector.Begin(); + int index = 0; + for( ; iter != pairvector.End(); ++iter, ++index ) + { + std::cout << "pair " << (*iter).first << ":" << (*iter).second << std::endl; + DALI_TEST_EQUALS( (*iter).first, pairvector[ index ].first, TEST_LOCATION ); + DALI_TEST_EQUALS( (*iter).second, pairvector[ index ].second, TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliVectorAsserts(void) +{ + tet_infoline("Testing Dali::Vector< int* > exception handling"); + + // empty vector + Vector< int* > pointervector; + try + { + int* value = NULL; + pointervector[ 1 ] = value; + tet_printf("Assertion expected, but not occurred at %s\n", TEST_LOCATION ); + tet_result(TET_FAIL); + } + catch(Dali::DaliException& e) + { + tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT( e, "VectorBase::mData", TEST_LOCATION ); + } + catch(...) + { + tet_printf("Assertion test failed - wrong Exception\n" ); + tet_result(TET_FAIL); + } + + try + { + int* value = NULL; + value = pointervector[ 0 ]; + (void)value; // to "use" the value + tet_printf("Assertion expected, but not occurred at %s\n", TEST_LOCATION ); + tet_result(TET_FAIL); + } + catch(Dali::DaliException& e) + { + tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT( e, "VectorBase::mData", TEST_LOCATION ); + } + catch(...) + { + tet_printf("Assertion test failed - wrong Exception\n" ); + tet_result(TET_FAIL); + } + + Vector< int* >::Iterator iter = pointervector.Begin(); + if( iter != pointervector.End() ) + { + tet_result(TET_FAIL); + } + + try + { + pointervector.Erase( pointervector.Begin() ); + tet_printf("Assertion expected, but not occurred at %s\n", TEST_LOCATION ); + tet_result(TET_FAIL); + } + catch(Dali::DaliException& e) + { + tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT( e, "VectorBase::mData", TEST_LOCATION ); + } + catch(...) + { + tet_printf("Assertion test failed - wrong Exception\n" ); + tet_result(TET_FAIL); + } + + iter = pointervector.Begin(); + if( iter != pointervector.End() ) + { + tet_result(TET_FAIL); + } + + try + { + pointervector.Remove( pointervector.Begin() ); + tet_printf("Assertion expected, but not occurred at %s\n", TEST_LOCATION ); + tet_result(TET_FAIL); + } + catch(Dali::DaliException& e) + { + tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT( e, "VectorBase::mData", TEST_LOCATION ); + } + catch(...) + { + tet_printf("Assertion test failed - wrong Exception\n" ); + tet_result(TET_FAIL); + } + + iter = pointervector.Begin(); + if( iter != pointervector.End() ) + { + tet_result(TET_FAIL); + } + + // reserve 0 space + pointervector.Reserve( 0 ); + iter = pointervector.Begin(); + if( iter != pointervector.End() ) + { + tet_result(TET_FAIL); + } + + // reserve 1 space + pointervector.Reserve( 1 ); + iter = pointervector.Begin(); + if( iter != pointervector.End() ) + { + tet_result(TET_FAIL); + } + + try + { + int* value = NULL; + pointervector[ 1 ] = value; + tet_printf("Assertion expected, but not occurred at %s\n", TEST_LOCATION ); + tet_result(TET_FAIL); + } + catch(Dali::DaliException& e) + { + tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT( e, "index < VectorBase::Count()", TEST_LOCATION ); + } + catch(...) + { + tet_printf("Assertion test failed - wrong Exception\n" ); + tet_result(TET_FAIL); + } + + try + { + int* value = pointervector[ 1 ]; + (void)value; // to "use" the value + tet_printf("Assertion expected, but not occurred at %s\n", TEST_LOCATION ); + tet_result(TET_FAIL); + } + catch(Dali::DaliException& e) + { + tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT( e, "index < VectorBase::Count()", TEST_LOCATION ); + } + catch(...) + { + tet_printf("Assertion test failed - wrong Exception\n" ); + tet_result(TET_FAIL); + } + + END_TEST; +} + +int UtcDaliVectorAcidTest(void) +{ + tet_infoline("Testing multiple Dali::Vector's"); + + // create multiple vectors + Vector< std::pair< float, float > > pairvector; + DALI_TEST_EQUALS( ZERO, pairvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, pairvector.Capacity(), TEST_LOCATION ); + Vector< double > doublevector; + DALI_TEST_EQUALS( ZERO, doublevector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, doublevector.Capacity(), TEST_LOCATION ); + Vector< int* > intptrvector; + DALI_TEST_EQUALS( ZERO, intptrvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, intptrvector.Capacity(), TEST_LOCATION ); + Vector< Dali::Actor* > actorptrvector; + DALI_TEST_EQUALS( ZERO, actorptrvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, actorptrvector.Capacity(), TEST_LOCATION ); + Vector< long > longvector; + DALI_TEST_EQUALS( ZERO, longvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, longvector.Capacity(), TEST_LOCATION ); + Vector< char > charvector; + DALI_TEST_EQUALS( ZERO, charvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, charvector.Capacity(), TEST_LOCATION ); + + // add items + static unsigned int acidCount = 10000; + int* ptr = NULL; + for( unsigned int i = 0; i < acidCount; ++i ) + { + ++ptr; + pairvector.PushBack( std::make_pair( i, i ) ); + doublevector.PushBack( (double)i ); + intptrvector.PushBack( (int*)ptr ); + actorptrvector.PushBack( (Dali::Actor*)ptr ); + longvector.PushBack( (long)i ); + charvector.PushBack( (char)i ); + } + DALI_TEST_EQUALS( acidCount, pairvector.Count(), TEST_LOCATION ); + std::size_t pairCapacity = pairvector.Capacity(); + DALI_TEST_EQUALS( acidCount, doublevector.Count(), TEST_LOCATION ); + std::size_t doubleCapacity = doublevector.Capacity(); + DALI_TEST_EQUALS( acidCount, intptrvector.Count(), TEST_LOCATION ); + std::size_t intptrCapacity = intptrvector.Capacity(); + DALI_TEST_EQUALS( acidCount, actorptrvector.Count(), TEST_LOCATION ); + std::size_t actorptrCapacity = actorptrvector.Capacity(); + DALI_TEST_EQUALS( acidCount, longvector.Count(), TEST_LOCATION ); + std::size_t longCapacity = longvector.Capacity(); + DALI_TEST_EQUALS( acidCount, charvector.Count(), TEST_LOCATION ); + std::size_t charCapacity = charvector.Capacity(); + + tet_printf("Dali::Vector< pair > capacity after %d pushbacks is %d", acidCount, pairCapacity ); + tet_printf("Dali::Vector< double > capacity after %d pushbacks is %d", acidCount, doubleCapacity ); + tet_printf("Dali::Vector< int* > capacity after %d pushbacks is %d", acidCount, intptrCapacity ); + tet_printf("Dali::Vector< Actor* > capacity after %d pushbacks is %d", acidCount, actorptrCapacity ); + tet_printf("Dali::Vector< long > capacity after %d pushbacks is %d", acidCount, longCapacity ); + tet_printf("Dali::Vector< char > capacity after %d pushbacks is %d", acidCount, charCapacity ); + + // erase items + for( unsigned int i = 0; i < acidCount; ++i ) + { + pairvector.Erase( pairvector.Begin() + ( i % pairvector.Count() ) ); + doublevector.Erase( doublevector.Begin() + ( i % doublevector.Count() ) ); + intptrvector.Erase( intptrvector.Begin() + ( i % intptrvector.Count() ) ); + actorptrvector.Erase( actorptrvector.Begin() + ( i % actorptrvector.Count() ) ); + longvector.Erase( longvector.Begin() + ( i % longvector.Count() ) ); + charvector.Erase( charvector.Begin() + ( i % charvector.Count() ) ); + } + DALI_TEST_EQUALS( ZERO, pairvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( pairCapacity, pairvector.Capacity(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, doublevector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( doubleCapacity, doublevector.Capacity(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, intptrvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( intptrCapacity, intptrvector.Capacity(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, actorptrvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( actorptrCapacity, actorptrvector.Capacity(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, longvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( longCapacity, longvector.Capacity(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, charvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( charCapacity, charvector.Capacity(), TEST_LOCATION ); + + END_TEST; +} + +namespace +{ + +bool gConstructorCalled = false; +bool gDestructorCalled = false; + +struct ComplexType +{ + ComplexType() + { + gConstructorCalled = true; + } + ~ComplexType() + { + gDestructorCalled = true; + } +}; + +} // anonymous namespace + + +int UtcDaliVectorComplex(void) +{ + tet_infoline("Testing Dali::Vector< int* > exception handling"); + + // this does not compile at the moment +/* Vector< ComplexType > classvector; + DALI_TEST_EQUALS( ZERO, classvector.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( ZERO, classvector.Capacity(), TEST_LOCATION ); + + DALI_TEST_EQUALS( false, gConstructorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( false, gDestructorCalled, TEST_LOCATION ); + classvector.PushBack( ComplexType() ); + DALI_TEST_EQUALS( true, gConstructorCalled, TEST_LOCATION ); + classvector.Clear(); + DALI_TEST_EQUALS( true, gDestructorCalled, TEST_LOCATION ); +*/ +// Vector< Actor > classvector; this does not compile yet either + tet_result(TET_PASS); // for now + END_TEST; +} diff --git a/automated-tests/src/dali/CMakeLists.txt b/automated-tests/src/dali/CMakeLists.txt new file mode 100644 index 0000000..a4cfac3 --- /dev/null +++ b/automated-tests/src/dali/CMakeLists.txt @@ -0,0 +1,104 @@ +SET(PKG_NAME "dali") + +SET(EXEC_NAME "tct-${PKG_NAME}-core") +SET(RPM_NAME "core-${PKG_NAME}-tests") + +SET(CAPI_LIB "dali") + +SET(TC_SOURCES + utc-Dali-ActiveConstraint.cpp + utc-Dali-Actor.cpp + utc-Dali-AlphaFunctions.cpp + utc-Dali-AngleAxis.cpp + utc-Dali-AnimatableMesh.cpp + utc-Dali-Animation.cpp + utc-Dali-Any.cpp + utc-Dali-BaseHandle.cpp + utc-Dali-BitmapImage.cpp + utc-Dali-CameraActor.cpp + utc-Dali-Character.cpp + utc-Dali-Constraint.cpp + utc-Dali-CustomActor.cpp + utc-Dali-Degree.cpp + utc-Dali-EventProcessing.cpp + utc-Dali-Font.cpp + utc-Dali-FontParameters.cpp + utc-Dali-FrameBufferImage.cpp + utc-Dali-Gesture.cpp + utc-Dali-GestureDetector.cpp + utc-Dali-Handle.cpp + utc-Dali-Image.cpp + utc-Dali-ImageActor.cpp + utc-Dali-ImageAttributes.cpp + utc-Dali-KeyEvent.cpp + utc-Dali-Layer.cpp + utc-Dali-LongPressGesture.cpp + utc-Dali-LongPressGestureDetector.cpp + utc-Dali-Material.cpp + utc-Dali-MathUtils.cpp + utc-Dali-Matrix.cpp + utc-Dali-Matrix3.cpp + utc-Dali-MeshActor.cpp + utc-Dali-PanGesture.cpp + utc-Dali-PanGestureDetector.cpp + utc-Dali-PinchGesture.cpp + utc-Dali-PinchGestureDetector.cpp + utc-Dali-Pixel.cpp + utc-Dali-PropertyNotification.cpp + utc-Dali-Quaternion.cpp + utc-Dali-Radian.cpp + utc-Dali-Rect.cpp + utc-Dali-RenderTask.cpp + utc-Dali-RenderTaskList.cpp + utc-Dali-RenderableActor.cpp + utc-Dali-ShaderEffect.cpp + utc-Dali-SignalTemplatesFunctors.cpp + utc-Dali-SignalTemplatesV2.cpp + utc-Dali-Stage.cpp + utc-Dali-TapGesture.cpp + utc-Dali-TapGestureDetector.cpp + utc-Dali-Text.cpp + utc-Dali-TextActor.cpp + utc-Dali-TextStyle.cpp + utc-Dali-TouchEventCombiner.cpp + utc-Dali-TouchProcessing.cpp + utc-Dali-Vector2.cpp + utc-Dali-Vector3.cpp + utc-Dali-Vector4.cpp +) + +LIST(APPEND TC_SOURCES + dali-test-suite-utils/dali-test-suite-utils.cpp + dali-test-suite-utils/test-application.cpp + dali-test-suite-utils/test-gesture-manager.cpp + dali-test-suite-utils/test-gl-abstraction.cpp + dali-test-suite-utils/test-gl-sync-abstraction.cpp + dali-test-suite-utils/test-native-image.cpp + dali-test-suite-utils/test-platform-abstraction.cpp + dali-test-suite-utils/test-render-controller.cpp + dali-test-suite-utils/test-trace-call-stack.cpp +) + +PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED + dali-core +) + +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -ggdb --coverage") + +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-test-suite-utils +) + +ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.cpp ${TC_SOURCES}) +TARGET_LINK_LIBRARIES(${EXEC_NAME} + ${${CAPI_LIB}_LIBRARIES} +) + +INSTALL(PROGRAMS ${EXEC_NAME} + DESTINATION ${BIN_DIR}/${EXEC_NAME} +) diff --git a/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.cpp b/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.cpp new file mode 100644 index 0000000..95c4769 --- /dev/null +++ b/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.cpp @@ -0,0 +1,364 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +// INTERNAL INCLUDES +#include +#include + +#include "dali-test-suite-utils.h" + +using namespace Dali; + +int test_return_value = TET_UNDEF; + +void tet_result(int value) +{ + // First TET_PASS should set to zero + // first TET_FAIL should prevent any further TET_PASS from setting back to zero + // Any TET_FAIL should set to fail or leave as fail + if( test_return_value != 1 ) + test_return_value = value; +} + +#define END_TEST \ + return ((test_return_value>0)?1:0) + + +void tet_infoline(const char* str) +{ + fprintf(stderr, "%s\n", str); +} + +void tet_printf(const char *format, ...) +{ + va_list arg; + va_start(arg, format); + vfprintf(stderr, format, arg); + va_end(arg); +} + +/** + * DALI_TEST_CHECK is a wrapper for tet_result. + * If the condition evaluates to false, then the function & line number is printed. + * @param[in] The boolean expression to check + */ +#define DALI_TEST_CHECK(condition) \ +if ( (condition) ) \ +{ \ + tet_result(TET_PASS); \ +} \ +else \ +{ \ + fprintf(stderr, "%s Failed in %s at line %d\n", __PRETTY_FUNCTION__, __FILE__, __LINE__); \ + tet_result(TET_FAIL); \ +} + +bool operator==(TimePeriod a, TimePeriod b) +{ + return Equals(a.durationSeconds, b.durationSeconds) && Equals(a.delaySeconds, b.delaySeconds) ; +} + +std::ostream& operator<< (std::ostream& o, const TimePeriod value) +{ + return o << "( Duration:" << value.durationSeconds << " Delay:" << value.delaySeconds << ")"; +} + +void DALI_TEST_EQUALS( const Matrix3& matrix1, const Matrix3& matrix2, const char* location) +{ + const float* m1 = matrix1.AsFloat(); + const float* m2 = matrix2.AsFloat(); + bool equivalent = true; + + for (int i=0;i<9;++i) + { + equivalent &= (m1[i] != m2[i]); + } + + if (!equivalent) + { + fprintf(stderr, "%s, checking\n" + "(%f, %f, %f) (%f, %f, %f)\n" + "(%f, %f, %f) == (%f, %f, %f)\n" + "(%f, %f, %f) (%f, %f, %f)\n", + location, + m1[0], m1[1], m1[2], m2[0], m2[1], m2[2], + m1[3], m1[4], m1[5], m2[3], m2[4], m2[5], + m1[6], m1[7], m1[8], m2[6], m2[7], m2[8]); + + tet_result(TET_FAIL); + } + else + { + tet_result(TET_PASS); + } +} + +void DALI_TEST_EQUALS( const Matrix3& matrix1, const Matrix3& matrix2, float epsilon, const char* location) +{ + const float* m1 = matrix1.AsFloat(); + const float* m2 = matrix2.AsFloat(); + bool equivalent = true; + + for (int i=0;i<9;++i) + { + equivalent &= (fabsf(m1[i] - m2[i]) value2 + * @param[in] value1 The first value + * @param[in] value2 The second value + * @param[in] location The TEST_LOCATION macro should be used here + */ +void DALI_TEST_GREATER(unsigned int value1, unsigned int value2, const char* location) +{ + if (!(value1 > value2)) + { + fprintf(stderr, "%s, checking %d > %d\n", location, value1, value2); + tet_result(TET_FAIL); + } + else + { + tet_result(TET_PASS); + } +} + +/** + * Test whether one float value is greater than another. + * Test succeeds if value1 > value2 + * @param[in] value1 The first value + * @param[in] value2 The second value + * @param[in] location The TEST_LOCATION macro should be used here + */ +void DALI_TEST_GREATER( float value1, float value2, const char* location) +{ + if (!(value1 > value2)) + { + fprintf(stderr, "%s, checking %f > %f\n", location, value1, value2); + tet_result(TET_FAIL); + } + else + { + tet_result(TET_PASS); + } +} + +/** + * Test whether the assertion condition that failed and thus triggered the + * exception \b e contained a given substring at the start of its literal text. + * @param[in] e The exception that we expect was fired by a runtime assertion + * failure. + * @param[in] conditionSubString The text that we expect to be present in an + * assertion which triggered the exception. + * @param[in] location The TEST_LOCATION macro should be used here. + * + * @remark **Side-effects:** The result of the tet test is set to TET_PASS if + * the substring is at the start of the exception's condition and + * TET_FAIL if it isn't. Note, if the result of a test is set multiple + * times, a TET_FAIL will override any number of TET_PASSes. + */ +void DALI_TEST_ASSERT( DaliException& e, std::string conditionSubString, const char* location ) +{ + if( 0u != e.mCondition.find( conditionSubString )) + { + fprintf(stderr, "Assertion %s failed at %s\n", conditionSubString.c_str(), location); + tet_result(TET_FAIL); + } + else + { + tet_result(TET_PASS); + } +} + +/** Self-documenting wrapper for DALI_TEST_ASSERT. + * @copydoc DALI_TEST_ASSERT() + */ +void DALI_TEST_ASSERT_CONDITION_STARTS_WITH_SUBSTRING( DaliException& exceptionFromAssertion, std::string conditionSubString, const char* location ) +{ + DALI_TEST_ASSERT(exceptionFromAssertion, conditionSubString, location); +} + +// Functor to test whether an Applied signal is emitted +ConstraintAppliedCheck::ConstraintAppliedCheck( bool& signalReceived ) +: mSignalReceived( signalReceived ) +{ +} + +void ConstraintAppliedCheck::operator()( ActiveConstraint& constraint ) +{ + mSignalReceived = true; +} + +void ConstraintAppliedCheck::Reset() +{ + mSignalReceived = false; +} + +void ConstraintAppliedCheck::CheckSignalReceived() +{ + if ( !mSignalReceived ) + { + fprintf(stderr, "Expected Applied signal was not received\n" ); + tet_result( TET_FAIL ); + } + else + { + tet_result( TET_PASS ); + } +} + +void ConstraintAppliedCheck::CheckSignalNotReceived() +{ + if ( mSignalReceived ) + { + fprintf(stderr, "Unexpected Applied signal was received\n" ); + tet_result( TET_FAIL ); + } + else + { + tet_result( TET_PASS ); + } +} + +BitmapImage CreateBitmapImage() +{ + BitmapImage image = BitmapImage::New(4,4,Pixel::RGBA8888); + + PixelBuffer* pixbuf = image.GetBuffer(); + + // Using a 4x4 image gives a better blend with the GL implementation + // than a 3x3 image + for(size_t i=0; i<16; i++) + { + pixbuf[i*4+0] = 0xFF; + pixbuf[i*4+1] = 0xFF; + pixbuf[i*4+2] = 0xFF; + pixbuf[i*4+3] = 0xFF; + } + + return image; +} diff --git a/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.h b/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.h new file mode 100644 index 0000000..134597e --- /dev/null +++ b/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.h @@ -0,0 +1,404 @@ +#ifndef __DALI_TEST_SUITE_UTILS_H__ +#define __DALI_TEST_SUITE_UTILS_H__ + +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +// INTERNAL INCLUDES +#include +#include + +void tet_infoline(const char*str); +void tet_printf(const char *format, ...); + +#include "test-application.h" + +using namespace Dali; + +#define STRINGIZE_I(text) #text +#define STRINGIZE(text) STRINGIZE_I(text) + +// the following is the other compilers way of token pasting, gcc seems to just concatenate strings automatically +//#define TOKENPASTE(x,y) x ## y +#define TOKENPASTE(x,y) x y +#define TOKENPASTE2(x,y) TOKENPASTE( x, y ) +#define TEST_LOCATION TOKENPASTE2( "Test failed in ", TOKENPASTE2( __FILE__, TOKENPASTE2( ", line ", STRINGIZE(__LINE__) ) ) ) + +#define TET_UNDEF 2 +#define TET_FAIL 1 +#define TET_PASS 0 + +extern int test_return_value; + +void tet_result(int value); + +#define END_TEST \ + return ((test_return_value>0)?1:0) + +void tet_infoline(const char* str); +void tet_printf(const char *format, ...); + +/** + * DALI_TEST_CHECK is a wrapper for tet_result. + * If the condition evaluates to false, then the function & line number is printed. + * @param[in] The boolean expression to check + */ +#define DALI_TEST_CHECK(condition) \ +if ( (condition) ) \ +{ \ + tet_result(TET_PASS); \ +} \ +else \ +{ \ + fprintf(stderr, "%s Failed in %s at line %d\n", __PRETTY_FUNCTION__, __FILE__, __LINE__); \ + tet_result(TET_FAIL); \ +} + +template +inline bool CompareType(Type value1, Type value2, float epsilon); + +/** + * A helper for fuzzy-comparing Vector2 objects + * @param[in] vector1 the first object + * @param[in] vector2 the second object + * @param[in] epsilon difference threshold + * @returns true if difference is smaller than epsilon threshold, false otherwise + */ +template <> +inline bool CompareType(float value1, float value2, float epsilon) +{ + return fabsf(value1 - value2) < epsilon; +} + +/** + * A helper for fuzzy-comparing Vector2 objects + * @param[in] vector1 the first object + * @param[in] vector2 the second object + * @param[in] epsilon difference threshold + * @returns true if difference is smaller than epsilon threshold, false otherwise + */ +template <> +inline bool CompareType(Vector2 vector1, Vector2 vector2, float epsilon) +{ + return fabsf(vector1.x - vector2.x) +inline bool CompareType(Vector3 vector1, Vector3 vector2, float epsilon) +{ + return fabsf(vector1.x - vector2.x) +inline bool CompareType(Vector4 vector1, Vector4 vector2, float epsilon) +{ + return fabsf(vector1.x - vector2.x) +inline bool CompareType(Quaternion q1, Quaternion q2, float epsilon) +{ + Quaternion q2N = -q2; // These quaternions represent the same rotation + return CompareType(q1.mVector, q2.mVector, epsilon) || CompareType(q1.mVector, q2N.mVector, epsilon); +} + +template <> +inline bool CompareType(Radian q1, Radian q2, float epsilon) +{ + return CompareType(float(q1), float(q2), epsilon); +} + +template <> +inline bool CompareType(Degree q1, Degree q2, float epsilon) +{ + return CompareType(float(q1), float(q2), epsilon); +} + +bool operator==(TimePeriod a, TimePeriod b); +std::ostream& operator<< (std::ostream& o, const TimePeriod value); + +/** + * Test whether two values are equal. + * @param[in] value1 The first value + * @param[in] value2 The second value + * @param[in] location The TEST_LOCATION macro should be used here + */ +template +inline void DALI_TEST_EQUALS(TypeA value1, TypeB value2, const char* location) +{ + if (!(value1 == value2)) + { + std::ostringstream o; + o << value1 << " == " << value2 << std::endl; + fprintf(stderr, "%s, checking %s", location, o.str().c_str()); + tet_result(TET_FAIL); + } + else + { + tet_result(TET_PASS); + } +} + +template +inline void DALI_TEST_EQUALS(Type value1, Type value2, float epsilon, const char* location) +{ + if( !CompareType(value1, value2, epsilon) ) + { + std::ostringstream o; + o << value1 << " == " << value2 << std::endl; + fprintf(stderr, "%s, checking %s", location, o.str().c_str()); + tet_result(TET_FAIL); + } + else + { + tet_result(TET_PASS); + } +} + +/** + * Test whether two TimePeriods are within a certain distance of each other. + * @param[in] value1 The first value + * @param[in] value2 The second value + * @param[in] epsilon The values must be within this distance of each other + * @param[in] location The TEST_LOCATION macro should be used here + */ +template<> +inline void DALI_TEST_EQUALS( TimePeriod value1, TimePeriod value2, float epsilon, const char* location) +{ + if ((fabs(value1.durationSeconds - value2.durationSeconds) > epsilon)) + { + fprintf(stderr, "%s, checking durations %f == %f, epsilon %f\n", location, value1.durationSeconds, value2.durationSeconds, epsilon); + tet_result(TET_FAIL); + } + else if ((fabs(value1.delaySeconds - value2.delaySeconds) > epsilon)) + { + fprintf(stderr, "%s, checking delays %f == %f, epsilon %f\n", location, value1.delaySeconds, value2.delaySeconds, epsilon); + tet_result(TET_FAIL); + } + else + { + tet_result(TET_PASS); + } +} + +/** + * Test whether two Matrix3 objects are equal. + * @param[in] matrix1 The first object + * @param[in] matrix2 The second object + * @param[in] location The TEST_LOCATION macro should be used here + */ +void DALI_TEST_EQUALS( const Matrix3& matrix1, const Matrix3& matrix2, const char* location); + +/** Test whether two Matrix3 objects are equal (fuzzy compare). + * @param[in] matrix1 The first object + * @param[in] matrix2 The second object + * @param[in] epsilon The epsilon to use for comparison + * @param[in] location The TEST_LOCATION macro should be used here + */ +void DALI_TEST_EQUALS( const Matrix3& matrix1, const Matrix3& matrix2, float epsilon, const char* location); + +/** + * Test whether two Matrix objects are equal. + * @param[in] matrix1 The first object + * @param[in] matrix2 The second object + * @param[in] location The TEST_LOCATION macro should be used here + */ +void DALI_TEST_EQUALS( const Matrix& matrix1, const Matrix& matrix2, const char* location); + +/** + * Test whether two Matrix objects are equal (fuzzy-compare). + * @param[in] matrix1 The first object + * @param[in] matrix2 The second object + * @param[in] location The TEST_LOCATION macro should be used here + */ +void DALI_TEST_EQUALS( const Matrix& matrix1, const Matrix& matrix2, float epsilon, const char* location); + +/** + * Test whether two strings are equal. + * @param[in] str1 The first string + * @param[in] str2 The second string + * @param[in] location The TEST_LOCATION macro should be used here + */ +template<> +inline void DALI_TEST_EQUALS( const char* str1, const char* str2, const char* location) +{ + if (strcmp(str1, str2)) + { + fprintf(stderr, "%s, checking '%s' == '%s'\n", location, str1, str2); + tet_result(TET_FAIL); + } + else + { + tet_result(TET_PASS); + } +} + +/** + * Test whether two strings are equal. + * @param[in] str1 The first string + * @param[in] str2 The second string + * @param[in] location The TEST_LOCATION macro should be used here + */ +template<> +inline void DALI_TEST_EQUALS( const std::string &str1, const std::string &str2, const char* location) +{ + DALI_TEST_EQUALS(str1.c_str(), str2.c_str(), location); +} + +/** + * Test whether two strings are equal. + * @param[in] str1 The first string + * @param[in] str2 The second string + * @param[in] location The TEST_LOCATION macro should be used here + */ +void DALI_TEST_EQUALS( const std::string &str1, const char* str2, const char* location); + +/** + * Test whether two strings are equal. + * @param[in] str1 The first string + * @param[in] str2 The second string + * @param[in] location The TEST_LOCATION macro should be used here + */ +void DALI_TEST_EQUALS( const char* str1, const std::string &str2, const char* location); + + +/** + * Test whether two UTF32 strings are equal. + * @param[in] str1 The first string + * @param[in] str2 The second string + * @param[in] location The TEST_LOCATION macro should be used here + */ +template<> +inline void DALI_TEST_EQUALS( const TextArray& str1, const TextArray& str2, const char* location) +{ + if (!std::equal(str1.begin(), str1.end(), str2.begin())) + { + fprintf(stderr, "%s, checking '", location); + + for( unsigned int i = 0; i < str1.size(); ++i) + { + fprintf(stderr, "%c", str1[i]); + } + + fprintf(stderr, "' == '"); + + for( unsigned int i = 0; i < str2.size(); ++i) + { + fprintf(stderr, "%c", str2[i]); + } + + fprintf(stderr, "'\n"); + + tet_result(TET_FAIL); + } + else + { + tet_result(TET_PASS); + } +} + +/** + * Test whether one unsigned integer value is greater than another. + * Test succeeds if value1 > value2 + * @param[in] value1 The first value + * @param[in] value2 The second value + * @param[in] location The TEST_LOCATION macro should be used here + */ +void DALI_TEST_GREATER(unsigned int value1, unsigned int value2, const char* location); + +/** + * Test whether one float value is greater than another. + * Test succeeds if value1 > value2 + * @param[in] value1 The first value + * @param[in] value2 The second value + * @param[in] location The TEST_LOCATION macro should be used here + */ +void DALI_TEST_GREATER( float value1, float value2, const char* location); + +/** + * Test whether the assertion condition that failed and thus triggered the + * exception \b e contained a given substring at the start of its literal text. + * @param[in] e The exception that we expect was fired by a runtime assertion + * failure. + * @param[in] conditionSubString The text that we expect to be present in an + * assertion which triggered the exception. + * @param[in] location The TEST_LOCATION macro should be used here. + * + * @remark **Side-effects:** The result of the tet test is set to TET_PASS if + * the substring is at the start of the exception's condition and + * TET_FAIL if it isn't. Note, if the result of a test is set multiple + * times, a TET_FAIL will override any number of TET_PASSes. + */ +void DALI_TEST_ASSERT( DaliException& e, std::string conditionSubString, const char* location ); + +/** Self-documenting wrapper for DALI_TEST_ASSERT. + * @copydoc DALI_TEST_ASSERT() + */ +void DALI_TEST_ASSERT_CONDITION_STARTS_WITH_SUBSTRING( DaliException& exceptionFromAssertion, std::string conditionSubString, const char* location ); + + +// Functor to test whether an Applied signal is emitted +struct ConstraintAppliedCheck +{ + ConstraintAppliedCheck( bool& signalReceived ); + void operator()( ActiveConstraint& constraint ); + void Reset(); + void CheckSignalReceived(); + void CheckSignalNotReceived(); + bool& mSignalReceived; // owned by individual tests +}; + +/** + * A Helper to test default functions + */ +template +struct DefaultFunctionCoverage +{ + DefaultFunctionCoverage() + { + T a; + T *b = new T(a); + DALI_TEST_CHECK(b); + a = *b; + delete b; + } +}; + + +// Helper to Create bitmap image +BitmapImage CreateBitmapImage(); + +#endif // __DALI_TEST_SUITE_UTILS_H__ diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-application.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-application.cpp new file mode 100644 index 0000000..5aa928e --- /dev/null +++ b/automated-tests/src/dali/dali-test-suite-utils/test-application.cpp @@ -0,0 +1,195 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 "test-application.h" + +namespace Dali +{ + + +TestApplication::TestApplication( size_t surfaceWidth, + size_t surfaceHeight, + float horizontalDpi, + float verticalDpi) +: mCore( NULL ), + mSurfaceWidth( surfaceWidth ), + mSurfaceHeight( surfaceHeight ), + mFrame( 0u ), + mDpi( horizontalDpi, verticalDpi ) +{ + Initialize(); +} + +TestApplication::TestApplication( bool initialize, + size_t surfaceWidth, + size_t surfaceHeight, + float horizontalDpi, + float verticalDpi ) +: mCore( NULL ), + mSurfaceWidth( surfaceWidth ), + mSurfaceHeight( surfaceHeight ), + mFrame( 0u ), + mDpi( horizontalDpi, verticalDpi ) +{ + if ( initialize ) + { + Initialize(); + } +} + +void TestApplication::Initialize() +{ + mCore = Dali::Integration::Core::New( + mRenderController, + mPlatformAbstraction, + mGlAbstraction, + mGlSyncAbstraction, + mGestureManager ); + + mCore->ContextCreated(); + mCore->SurfaceResized( mSurfaceWidth, mSurfaceHeight ); + mCore->SetDpi( mDpi.x, mDpi.y ); + + Dali::Integration::Log::LogFunction logFunction(&TestApplication::LogMessage); + Dali::Integration::Log::InstallLogFunction(logFunction); +} + +TestApplication::~TestApplication() +{ + Dali::Integration::Log::UninstallLogFunction(); + delete mCore; +} + +void TestApplication::LogMessage(Dali::Integration::Log::DebugPriority level, std::string& message) +{ + switch(level) + { + case Dali::Integration::Log::DebugInfo: + fprintf(stderr, "INFO: %s", message.c_str()); + break; + case Dali::Integration::Log::DebugWarning: + fprintf(stderr, "WARN: %s", message.c_str()); + break; + case Dali::Integration::Log::DebugError: + fprintf(stderr, "ERROR: %s", message.c_str()); + break; + default: + fprintf(stderr, "DEFAULT: %s", message.c_str()); + break; + } +} + +Dali::Integration::Core& TestApplication::GetCore() +{ + return *mCore; +} + +TestPlatformAbstraction& TestApplication::GetPlatform() +{ + return mPlatformAbstraction; +} + +TestRenderController& TestApplication::GetRenderController() +{ + return mRenderController; +} + +TestGlAbstraction& TestApplication::GetGlAbstraction() +{ + return mGlAbstraction; +} + +TestGlSyncAbstraction& TestApplication::GetGlSyncAbstraction() +{ + return mGlSyncAbstraction; +} + +TestGestureManager& TestApplication::GetGestureManager() +{ + return mGestureManager; +} + +void TestApplication::ProcessEvent(const Integration::Event& event) +{ + mCore->QueueEvent(event); + mCore->ProcessEvents(); +} + +void TestApplication::SendNotification() +{ + mCore->ProcessEvents(); +} + +void TestApplication::SetSurfaceWidth( unsigned int width, unsigned height ) +{ + mSurfaceWidth = width; + mSurfaceHeight = height; + + mCore->SurfaceResized( mSurfaceWidth, mSurfaceHeight ); +} + +bool TestApplication::Render( unsigned int intervalMilliseconds ) +{ + // Update Time values + mPlatformAbstraction.IncrementGetTimeResult( intervalMilliseconds ); + unsigned int seconds(0u), microseconds(0u); + mPlatformAbstraction.GetTimeMicroseconds( seconds, microseconds ); + + mCore->VSync( mFrame, seconds, microseconds ); + mCore->Update( mStatus ); + mCore->Render( mRenderStatus ); + + mFrame++; + + return mStatus.KeepUpdating() || mRenderStatus.NeedsUpdate(); +} + +unsigned int TestApplication::GetUpdateStatus() +{ + return mStatus.KeepUpdating(); +} + +bool TestApplication::UpdateOnly( unsigned int intervalMilliseconds ) +{ + // Update Time values + mPlatformAbstraction.IncrementGetTimeResult( intervalMilliseconds ); + unsigned int seconds(0u), microseconds(0u); + mPlatformAbstraction.GetTimeMicroseconds( seconds, microseconds ); + + mCore->VSync( mFrame, seconds, microseconds ); + mCore->Update( mStatus ); + + return mStatus.KeepUpdating(); +} + +bool TestApplication::RenderOnly( ) +{ + // Update Time values + mCore->Render( mRenderStatus ); + + mFrame++; + + return mRenderStatus.NeedsUpdate(); +} + +void TestApplication::ResetContext() +{ + mCore->ContextToBeDestroyed(); + mCore->ContextCreated(); +} + + +} // Namespace dali diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-application.h b/automated-tests/src/dali/dali-test-suite-utils/test-application.h new file mode 100644 index 0000000..a490c96 --- /dev/null +++ b/automated-tests/src/dali/dali-test-suite-utils/test-application.h @@ -0,0 +1,99 @@ +#ifndef __DALI_TEST_APPLICATION_H__ +#define __DALI_TEST_APPLICATION_H__ + +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +// INTERNAL INCLUDES +#include +#include "test-gesture-manager.h" +#include "test-gl-sync-abstraction.h" +#include "test-gl-abstraction.h" +#include "test-render-controller.h" +#include + +namespace Dali +{ + +class DALI_IMPORT_API TestApplication : public ConnectionTracker +{ +public: + + // Default values derived from H2 device. + static const unsigned int DEFAULT_SURFACE_WIDTH = 480; + static const unsigned int DEFAULT_SURFACE_HEIGHT = 800; + +#ifdef _CPP11 + static constexpr float DEFAULT_HORIZONTAL_DPI = 220.0f; + static constexpr float DEFAULT_VERTICAL_DPI = 217.0f; +#else + static const float DEFAULT_HORIZONTAL_DPI = 220.0f; + static const float DEFAULT_VERTICAL_DPI = 217.0f; +#endif + + static const unsigned int DEFAULT_RENDER_INTERVAL = 1; + + TestApplication( size_t surfaceWidth = DEFAULT_SURFACE_WIDTH, + size_t surfaceHeight = DEFAULT_SURFACE_HEIGHT, + float horizontalDpi = DEFAULT_HORIZONTAL_DPI, + float verticalDpi = DEFAULT_VERTICAL_DPI ); + + TestApplication( bool initialize, + size_t surfaceWidth = DEFAULT_SURFACE_WIDTH, + size_t surfaceHeight = DEFAULT_SURFACE_HEIGHT, + float horizontalDpi = DEFAULT_HORIZONTAL_DPI, + float verticalDpi = DEFAULT_VERTICAL_DPI ); + + void Initialize(); + virtual ~TestApplication(); + static void LogMessage(Dali::Integration::Log::DebugPriority level, std::string& message); + Dali::Integration::Core& GetCore(); + TestPlatformAbstraction& GetPlatform(); + TestRenderController& GetRenderController(); + TestGlAbstraction& GetGlAbstraction(); + TestGlSyncAbstraction& GetGlSyncAbstraction(); + TestGestureManager& GetGestureManager(); + void ProcessEvent(const Integration::Event& event); + void SendNotification(); + void SetSurfaceWidth( unsigned int width, unsigned height ); + bool Render( unsigned int intervalMilliseconds = DEFAULT_RENDER_INTERVAL ); + unsigned int GetUpdateStatus(); + bool UpdateOnly( unsigned int intervalMilliseconds = DEFAULT_RENDER_INTERVAL ); + bool RenderOnly( ); + void ResetContext(); + +protected: + TestPlatformAbstraction mPlatformAbstraction; + TestRenderController mRenderController; + TestGlAbstraction mGlAbstraction; + TestGlSyncAbstraction mGlSyncAbstraction; + TestGestureManager mGestureManager; + + Integration::UpdateStatus mStatus; + Integration::RenderStatus mRenderStatus; + + Integration::Core* mCore; + + unsigned int mSurfaceWidth; + unsigned int mSurfaceHeight; + unsigned int mFrame; + + Vector2 mDpi; +}; + +} // Dali + +#endif diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-gesture-manager.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-gesture-manager.cpp new file mode 100644 index 0000000..1c9feb0 --- /dev/null +++ b/automated-tests/src/dali/dali-test-suite-utils/test-gesture-manager.cpp @@ -0,0 +1,102 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 "test-gesture-manager.h" + +namespace Dali +{ + +TestGestureManager::TestGestureManager() +{ + Initialize(); +} + +/** + * Destructor + */ +TestGestureManager::~TestGestureManager() +{ +} + +/** + * @copydoc Dali::Integration::GestureManager::Register(Gesture::Type) + */ +void TestGestureManager::Register(const Integration::GestureRequest& request) +{ + mFunctionsCalled.Register = true; +} + +/** + * @copydoc Dali::Integration::GestureManager::Unregister(Gesture::Type) + */ +void TestGestureManager::Unregister(const Integration::GestureRequest& request) +{ + mFunctionsCalled.Unregister = true; +} + +/** + * @copydoc Dali::Integration::GestureManager::Update(Gesture::Type) + */ +void TestGestureManager::Update(const Integration::GestureRequest& request) +{ + mFunctionsCalled.Update = true; +} + + +/** Call this every test */ +void TestGestureManager::Initialize() +{ + mFunctionsCalled.Reset(); +} + +bool TestGestureManager::WasCalled(TestFuncEnum func) +{ + switch(func) + { + case RegisterType: return mFunctionsCalled.Register; + case UnregisterType: return mFunctionsCalled.Unregister; + case UpdateType: return mFunctionsCalled.Update; + } + return false; +} + +void TestGestureManager::ResetCallStatistics(TestFuncEnum func) +{ + switch(func) + { + case RegisterType: mFunctionsCalled.Register = false; break; + case UnregisterType: mFunctionsCalled.Unregister = false; break; + case UpdateType: mFunctionsCalled.Update = false; break; + } +} + +TestGestureManager::TestFunctions::TestFunctions() +: Register(false), + Unregister(false), + Update(false) +{ +} + +void TestGestureManager::TestFunctions::Reset() +{ + Register = false; + Unregister = false; + Update = false; +} + + + +} // namespace Dali diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-gesture-manager.h b/automated-tests/src/dali/dali-test-suite-utils/test-gesture-manager.h new file mode 100644 index 0000000..5643deb --- /dev/null +++ b/automated-tests/src/dali/dali-test-suite-utils/test-gesture-manager.h @@ -0,0 +1,92 @@ +#ifndef __DALI_TEST_GESTURE_MANAGER_H__ +#define __DALI_TEST_GESTURE_MANAGER_H__ + +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ + +/** + * Concrete implementation of the gesture manager class. + */ +class DALI_IMPORT_API TestGestureManager : public Dali::Integration::GestureManager +{ + +public: + + /** + * Constructor + */ + TestGestureManager(); + + /** + * Destructor + */ + virtual ~TestGestureManager(); + + /** + * @copydoc Dali::Integration::GestureManager::Register(Gesture::Type) + */ + virtual void Register(const Integration::GestureRequest& request); + + /** + * @copydoc Dali::Integration::GestureManager::Unregister(Gesture::Type) + */ + virtual void Unregister(const Integration::GestureRequest& request); + + /** + * @copydoc Dali::Integration::GestureManager::Update(Gesture::Type) + */ + virtual void Update(const Integration::GestureRequest& request); + +public: // TEST FUNCTIONS + + // Enumeration of Gesture Manager methods + enum TestFuncEnum + { + RegisterType, + UnregisterType, + UpdateType, + }; + + /** Call this every test */ + void Initialize(); + bool WasCalled(TestFuncEnum func); + void ResetCallStatistics(TestFuncEnum func); + +private: + + struct TestFunctions + { + TestFunctions(); + void Reset(); + + bool Register; + bool Unregister; + bool Update; + }; + + TestFunctions mFunctionsCalled; +}; + +} // Dali + +#endif // __DALI_TEST_GESTURE_MANAGER_H__ diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.cpp new file mode 100644 index 0000000..eaeef05 --- /dev/null +++ b/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.cpp @@ -0,0 +1,90 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 "test-gl-abstraction.h" + +namespace Dali +{ + +TestGlAbstraction::TestGlAbstraction() +{ + Initialize(); +} + +TestGlAbstraction::~TestGlAbstraction() {} + +void TestGlAbstraction::Initialize() +{ + mCurrentProgram = 0; + mCompileStatus = GL_TRUE; + mLinkStatus = GL_TRUE; + + mGetAttribLocationResult = 0; + mGetErrorResult = 0; + mGetStringResult = NULL; + mIsBufferResult = 0; + mIsEnabledResult = 0; + mIsFramebufferResult = 0; + mIsProgramResult = 0; + mIsRenderbufferResult = 0; + mIsShaderResult = 0; + mIsTextureResult = 0; + mVertexAttribArrayChanged = false; + + mCheckFramebufferStatusResult = 0; + mNumBinaryFormats = 1; + mBinaryFormats = 1; + mProgramBinaryLength = 0; + + mLastAutoTextureIdUsed = 0; + + mLastShaderIdUsed = 0; + mLastProgramIdUsed = 0; + mLastUniformIdUsed = 0; + mLastShaderCompiled = 0; + + mLastBlendEquationRgb = 0; + mLastBlendEquationAlpha = 0; + mLastBlendFuncSrcRgb = 0; + mLastBlendFuncDstRgb = 0; + mLastBlendFuncSrcAlpha = 0; + mLastBlendFuncDstAlpha = 0; + + mUniforms.clear(); + mProgramUniforms1i.clear(); + mProgramUniforms1f.clear(); + mProgramUniforms2f.clear(); + mProgramUniforms3f.clear(); + mProgramUniforms4f.clear(); +} + +} // Namespace dali + +bool BlendEnabled(const Dali::TraceCallStack& callStack) +{ + std::stringstream out; + out << GL_BLEND; + bool blendEnabled = callStack.FindMethodAndParams("Enable", out.str()); + return blendEnabled; +} + +bool BlendDisabled(const Dali::TraceCallStack& callStack) +{ + std::stringstream out; + out << GL_BLEND; + bool blendEnabled = callStack.FindMethodAndParams("Disable", out.str()); + return blendEnabled; +} diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.h b/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.h new file mode 100644 index 0000000..0479c6b --- /dev/null +++ b/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.h @@ -0,0 +1,1833 @@ +#ifndef __TEST_GL_ABSTRACTION_H__ +#define __TEST_GL_ABSTRACTION_H__ + +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +// EXTERNAL INCLUDES +#include +#include +#include + +// INTERNAL INCLUDES +#include + +#include +#include +#include "test-trace-call-stack.h" + +namespace Dali +{ + +static const unsigned int MAX_ATTRIBUTE_CACHE_SIZE = 64; +static const char *mStdAttribs[MAX_ATTRIBUTE_CACHE_SIZE] = +{ + "aPosition", // ATTRIB_POSITION + "aNormal", // ATTRIB_NORMAL + "aTexCoord", // ATTRIB_TEXCOORD + "aColor", // ATTRIB_COLOR + "aBoneWeights", // ATTRIB_BONE_WEIGHTS + "aBoneIndices" // ATTRIB_BONE_INDICES +}; + +class DALI_IMPORT_API TestGlAbstraction: public Dali::Integration::GlAbstraction +{ +public: + TestGlAbstraction(); + ~TestGlAbstraction(); + void Initialize(); + + /* OpenGL ES 2.0 */ + + inline void ActiveTexture( GLenum textureUnit ) + { + mActiveTextureUnit = textureUnit - GL_TEXTURE0; + } + + inline GLenum GetActiveTextureUnit() const + { + return mActiveTextureUnit + GL_TEXTURE0; + } + + inline void AttachShader( GLuint program, GLuint shader ) + { + std::stringstream out; + out << program << ", " << shader; + mShaderTrace.PushCall("AttachShader", out.str()); + } + + inline void BindAttribLocation( GLuint program, GLuint index, const char* name ) + { + } + + inline void BindBuffer( GLenum target, GLuint buffer ) + { + } + + inline void BindFramebuffer( GLenum target, GLuint framebuffer ) + { + } + + inline void BindRenderbuffer( GLenum target, GLuint renderbuffer ) + { + } + + /** + * This method can be used by test cases, to query the texture IDs that have been bound by BindTexture. + * @return A vector containing the IDs that were bound. + */ + inline const std::vector& GetBoundTextures() const + { + return mBoundTextures; + } + + /** + * Query the texture IDs that have been bound with BindTexture, with a specific active texture unit. + * @param[in] activeTextureUnit The specific active texture unit. + * @return A vector containing the IDs that were bound. + */ + inline const std::vector& GetBoundTextures( GLuint activeTextureUnit ) const + { + return mActiveTextures[ activeTextureUnit - GL_TEXTURE0 ].mBoundTextures; + } + + /** + * This method can be used by test cases, to clear the record of texture IDs that have been bound by BindTexture. + */ + inline void ClearBoundTextures() + { + mBoundTextures.clear(); + + for( unsigned int i=0; i::iterator iter=mDeletedTextureIds.begin(); iter != mDeletedTextureIds.end(); ++iter) + { + if(*iter == textureId) + { + found = true; + break; + } + } + return found; + } + + inline void ClearDeletedTextures() + { + mDeletedTextureIds.clear(); + } + + inline void DepthFunc(GLenum func) + { + } + + inline void DepthMask(GLboolean flag) + { + } + + inline void DepthRangef(GLclampf zNear, GLclampf zFar) + { + } + + inline void DetachShader(GLuint program, GLuint shader) + { + std::stringstream out; + out << program << ", " << shader; + mShaderTrace.PushCall("DetachShader", out.str()); + } + + inline void Disable(GLenum cap) + { + std::stringstream out; + out << cap; + mCullFaceTrace.PushCall("Disable", out.str()); + } + + inline void DisableVertexAttribArray(GLuint index) + { + SetVertexAttribArray( index, false ); + } + + inline void DrawArrays(GLenum mode, GLint first, GLsizei count) + { + std::stringstream out; + out << mode << ", " << first << ", " << count; + mDrawTrace.PushCall("DrawArrays", out.str()); + } + + inline void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) + { + std::stringstream out; + out << mode << ", " << count << ", " << type << ", indices"; + mDrawTrace.PushCall("DrawElements", out.str()); + } + + inline void Enable(GLenum cap) + { + std::stringstream out; + out << cap; + mCullFaceTrace.PushCall("Enable", out.str()); + } + + inline void EnableVertexAttribArray(GLuint index) + { + SetVertexAttribArray( index, true); + } + + inline void Finish(void) + { + } + + inline void Flush(void) + { + } + + inline void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) + { + } + + inline void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) + { + } + + inline void FrontFace(GLenum mode) + { + } + + inline void GenBuffers(GLsizei n, GLuint* buffers) + { + // avoids an assert in GpuBuffers + *buffers = 1u; + } + + inline void GenerateMipmap(GLenum target) + { + } + + inline void GenFramebuffers(GLsizei n, GLuint* framebuffers) + { + } + + inline void GenRenderbuffers(GLsizei n, GLuint* renderbuffers) + { + } + + /** + * This method can be used by test cases, to manipulate the texture IDs generated by GenTextures. + * @param[in] ids A vector containing the next IDs to be generated + */ + inline void SetNextTextureIds( const std::vector& ids ) + { + mNextTextureIds = ids; + } + + inline const std::vector& GetNextTextureIds() + { + return mNextTextureIds; + } + + inline void GenTextures(GLsizei n, GLuint* textures) + { + for( int i=0; isecond; + UniformIDMap::iterator it2 = uniformIDs.find( name ); + if( it2 == uniformIDs.end() ) + { + // Uniform not found, so add it... + uniformIDs[name] = ++mLastUniformIdUsed; + return mLastUniformIdUsed; + } + + return it2->second; + } + + inline void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) + { + } + + inline void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params) + { + } + + inline void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer) + { + } + + inline void Hint(GLenum target, GLenum mode) + { + } + + inline GLboolean IsBuffer(GLuint buffer) + { + return mIsBufferResult; + } + + inline GLboolean IsEnabled(GLenum cap) + { + return mIsEnabledResult; + } + + inline GLboolean IsFramebuffer(GLuint framebuffer) + { + return mIsFramebufferResult; + } + + inline GLboolean IsProgram(GLuint program) + { + return mIsProgramResult; + } + + inline GLboolean IsRenderbuffer(GLuint renderbuffer) + { + return mIsRenderbufferResult; + } + + inline GLboolean IsShader(GLuint shader) + { + return mIsShaderResult; + } + + inline GLboolean IsTexture(GLuint texture) + { + return mIsTextureResult; + } + + inline void LineWidth(GLfloat width) + { + } + + inline void LinkProgram(GLuint program) + { + std::stringstream out; + out << program; + mShaderTrace.PushCall("LinkProgram", out.str()); + } + + inline void PixelStorei(GLenum pname, GLint param) + { + } + + inline void PolygonOffset(GLfloat factor, GLfloat units) + { + } + + inline void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) + { + } + + inline void ReleaseShaderCompiler(void) + { + } + + inline void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) + { + } + + inline void SampleCoverage(GLclampf value, GLboolean invert) + { + } + + inline void Scissor(GLint x, GLint y, GLsizei width, GLsizei height) + { + } + + inline void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) + { + } + + inline void ShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length) + { + std::string stringBuilder; + for(int i = 0; i < count; ++i) + { + stringBuilder += string[i]; + } + mShaderSources[shader] = stringBuilder; + mLastShaderCompiled = shader; + } + + inline void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source) + { + const std::string shaderSource = mShaderSources[shader]; + if( static_cast(shaderSource.length()) < bufsize ) + { + strcpy(source, shaderSource.c_str()); + *length = shaderSource.length(); + } + else + { + *length = bufsize -1; + strncpy(source, shaderSource.c_str(), *length); + source[*length] = 0x0; + } + } + + inline void StencilFunc(GLenum func, GLint ref, GLuint mask) + { + } + + inline void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) + { + } + + inline void StencilMask(GLuint mask) + { + } + + inline void StencilMaskSeparate(GLenum face, GLuint mask) + { + } + + inline void StencilOp(GLenum fail, GLenum zfail, GLenum zpass) + { + } + + inline void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) + { + } + + inline void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels) + { + std::stringstream out; + out << width << ", " << height; + mTextureTrace.PushCall("TexImage2D", out.str()); + } + + inline void TexParameterf(GLenum target, GLenum pname, GLfloat param) + { + } + + inline void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params) + { + } + + inline void TexParameteri(GLenum target, GLenum pname, GLint param) + { + } + + inline void TexParameteriv(GLenum target, GLenum pname, const GLint* params) + { + } + + inline void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) + { + std::stringstream out; + out << xoffset << ", " << yoffset << ", " << width << ", " << height; + mTextureTrace.PushCall("TexSubImage2D", out.str()); + } + + inline void Uniform1f(GLint location, GLfloat x) + { + if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, x ) ) + { + mGetErrorResult = GL_INVALID_OPERATION; + } + } + + inline void Uniform1fv(GLint location, GLsizei count, const GLfloat* v) + { + for( int i = 0; i < count; ++i ) + { + if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, v[i] ) ) + { + mGetErrorResult = GL_INVALID_OPERATION; + break; + } + } + } + + inline void Uniform1i(GLint location, GLint x) + { + if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram, location, x ) ) + { + mGetErrorResult = GL_INVALID_OPERATION; + } + } + + inline void Uniform1iv(GLint location, GLsizei count, const GLint* v) + { + for( int i = 0; i < count; ++i ) + { + if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram, + location, + v[i] ) ) + { + mGetErrorResult = GL_INVALID_OPERATION; + break; + } + } + } + + inline void Uniform2f(GLint location, GLfloat x, GLfloat y) + { + if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram, + location, + Vector2( x, y ) ) ) + { + mGetErrorResult = GL_INVALID_OPERATION; + } + } + + inline void Uniform2fv(GLint location, GLsizei count, const GLfloat* v) + { + for( int i = 0; i < count; ++i ) + { + if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram, + location, + Vector2( v[2*i], v[2*i+1] ) ) ) + { + mGetErrorResult = GL_INVALID_OPERATION; + break; + } + } + } + + inline void Uniform2i(GLint location, GLint x, GLint y) + { + } + + inline void Uniform2iv(GLint location, GLsizei count, const GLint* v) + { + } + + inline void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) + { + if( ! mProgramUniforms3f.SetUniformValue( mCurrentProgram, + location, + Vector3( x, y, z ) ) ) + { + mGetErrorResult = GL_INVALID_OPERATION; + } + } + + inline void Uniform3fv(GLint location, GLsizei count, const GLfloat* v) + { + for( int i = 0; i < count; ++i ) + { + if( ! mProgramUniforms3f.SetUniformValue( + mCurrentProgram, + location, + Vector3( v[3*i], v[3*i+1], v[3*i+2] ) ) ) + { + mGetErrorResult = GL_INVALID_OPERATION; + break; + } + } + } + + inline void Uniform3i(GLint location, GLint x, GLint y, GLint z) + { + } + + inline void Uniform3iv(GLint location, GLsizei count, const GLint* v) + { + } + + inline void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) + { + if( ! mProgramUniforms4f.SetUniformValue( mCurrentProgram, + location, + Vector4( x, y, z, w ) ) ) + { + mGetErrorResult = GL_INVALID_OPERATION; + } + } + + inline void Uniform4fv(GLint location, GLsizei count, const GLfloat* v) + { + for( int i = 0; i < count; ++i ) + { + if( ! mProgramUniforms4f.SetUniformValue( + mCurrentProgram, + location, + Vector4( v[4*i], v[4*i+1], v[4*i+2], v[4*i+3] ) ) ) + { + mGetErrorResult = GL_INVALID_OPERATION; + break; + } + } + } + + inline void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) + { + } + + inline void Uniform4iv(GLint location, GLsizei count, const GLint* v) + { + } + + inline void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) + { + } + + inline void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) + { + for( int i = 0; i < count; ++i ) + { + if( ! mProgramUniformsMat3.SetUniformValue( + mCurrentProgram, + location, + Matrix3( value[0], value[1], value[2], value[3], value[4], value[5], value[6], value[7], value[8] ) ) ) + { + mGetErrorResult = GL_INVALID_OPERATION; + break; + } + } + } + + inline void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) + { + for( int i = 0; i < count; ++i ) + { + if( ! mProgramUniformsMat4.SetUniformValue( + mCurrentProgram, + location, + Matrix( value ) ) ) + { + mGetErrorResult = GL_INVALID_OPERATION; + break; + } + } + } + + inline void UseProgram(GLuint program) + { + mCurrentProgram = program; + } + + inline void ValidateProgram(GLuint program) + { + } + + inline void VertexAttrib1f(GLuint indx, GLfloat x) + { + } + + inline void VertexAttrib1fv(GLuint indx, const GLfloat* values) + { + } + + inline void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) + { + } + + inline void VertexAttrib2fv(GLuint indx, const GLfloat* values) + { + } + + inline void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) + { + } + + inline void VertexAttrib3fv(GLuint indx, const GLfloat* values) + { + } + + inline void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) + { + } + + inline void VertexAttrib4fv(GLuint indx, const GLfloat* values) + { + } + + inline void VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) + { + } + + inline void Viewport(GLint x, GLint y, GLsizei width, GLsizei height) + { + } + + /* OpenGL ES 3.0 */ + + inline void ReadBuffer(GLenum mode) + { + } + + inline void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) + { + } + + inline void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) + { + } + + inline void TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels) + { + } + + inline void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) + { + } + + inline void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) + { + } + + inline void CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data) + { + } + + inline void GenQueries(GLsizei n, GLuint* ids) + { + } + + inline void DeleteQueries(GLsizei n, const GLuint* ids) + { + } + + inline GLboolean IsQuery(GLuint id) + { + return false; + } + + inline void BeginQuery(GLenum target, GLuint id) + { + } + + inline void EndQuery(GLenum target) + { + } + + inline void GetQueryiv(GLenum target, GLenum pname, GLint* params) + { + } + + inline void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) + { + } + + inline GLboolean UnmapBuffer(GLenum target) + { + return false; + } + + inline void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) + { + } + + inline void DrawBuffers(GLsizei n, const GLenum* bufs) + { + } + + inline void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) + { + } + + inline void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) + { + } + + inline void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) + { + } + + inline void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) + { + } + + inline void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) + { + } + + inline void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) + { + } + + inline void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) + { + } + + inline void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) + { + } + + inline void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) + { + } + + inline GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) + { + return NULL; + } + + inline void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) + { + } + + inline void BindVertexArray(GLuint array) + { + } + + inline void DeleteVertexArrays(GLsizei n, const GLuint* arrays) + { + } + + inline void GenVertexArrays(GLsizei n, GLuint* arrays) + { + } + + inline GLboolean IsVertexArray(GLuint array) + { + return false; + } + + inline void GetIntegeri_v(GLenum target, GLuint index, GLint* data) + { + } + + inline void BeginTransformFeedback(GLenum primitiveMode) + { + } + + inline void EndTransformFeedback(void) + { + } + + inline void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) + { + } + + inline void BindBufferBase(GLenum target, GLuint index, GLuint buffer) + { + } + + inline void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) + { + } + + inline void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) + { + } + + inline void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) + { + } + + inline void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) + { + } + + inline void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) + { + } + + inline void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) + { + } + + inline void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) + { + } + + inline void VertexAttribI4iv(GLuint index, const GLint* v) + { + } + + inline void VertexAttribI4uiv(GLuint index, const GLuint* v) + { + } + + inline void GetUniformuiv(GLuint program, GLint location, GLuint* params) + { + } + + inline GLint GetFragDataLocation(GLuint program, const GLchar *name) + { + return -1; + } + + inline void Uniform1ui(GLint location, GLuint v0) + { + } + + inline void Uniform2ui(GLint location, GLuint v0, GLuint v1) + { + } + + inline void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) + { + } + + inline void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) + { + } + + inline void Uniform1uiv(GLint location, GLsizei count, const GLuint* value) + { + } + + inline void Uniform2uiv(GLint location, GLsizei count, const GLuint* value) + { + } + + inline void Uniform3uiv(GLint location, GLsizei count, const GLuint* value) + { + } + + inline void Uniform4uiv(GLint location, GLsizei count, const GLuint* value) + { + } + + inline void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) + { + } + + inline void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) + { + } + + inline void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) + { + } + + inline void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) + { + } + + inline const GLubyte* GetStringi(GLenum name, GLuint index) + { + return NULL; + } + + inline void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) + { + } + + inline void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) + { + } + + inline void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) + { + } + + inline GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) + { + return GL_INVALID_INDEX; + } + + inline void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) + { + } + + inline void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) + { + } + + inline void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) + { + } + + inline void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) + { + } + + inline void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) + { + } + + inline GLsync FenceSync(GLenum condition, GLbitfield flags) + { + return NULL; + } + + inline GLboolean IsSync(GLsync sync) + { + return false; + } + + inline void DeleteSync(GLsync sync) + { + } + + inline GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) + { + return 0; + } + + inline void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) + { + } + + inline void GetInteger64v(GLenum pname, GLint64* params) + { + } + + inline void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) + { + } + + inline void GetInteger64i_v(GLenum target, GLuint index, GLint64* data) + { + } + + inline void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) + { + } + + inline void GenSamplers(GLsizei count, GLuint* samplers) + { + } + + inline void DeleteSamplers(GLsizei count, const GLuint* samplers) + { + } + + inline GLboolean IsSampler(GLuint sampler) + { + return false; + } + + inline void BindSampler(GLuint unit, GLuint sampler) + { + } + + inline void SamplerParameteri(GLuint sampler, GLenum pname, GLint param) + { + } + + inline void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) + { + } + + inline void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) + { + } + + inline void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) + { + } + + inline void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) + { + } + + inline void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) + { + } + + inline void VertexAttribDivisor(GLuint index, GLuint divisor) + { + } + + inline void BindTransformFeedback(GLenum target, GLuint id) + { + } + + inline void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids) + { + } + + inline void GenTransformFeedbacks(GLsizei n, GLuint* ids) + { + } + + inline GLboolean IsTransformFeedback(GLuint id) + { + return false; + } + + inline void PauseTransformFeedback(void) + { + } + + inline void ResumeTransformFeedback(void) + { + } + + inline void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) + { + } + + inline void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) + { + } + + inline void ProgramParameteri(GLuint program, GLenum pname, GLint value) + { + } + + inline void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) + { + } + + inline void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) + { + } + + inline void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) + { + } + + inline void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) + { + } + + inline void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) + { + } + +public: // TEST FUNCTIONS + inline void SetCompileStatus( GLuint value ) { mCompileStatus = value; } + inline void SetLinkStatus( GLuint value ) { mLinkStatus = value; } + inline void SetGetAttribLocationResult( int result) { mGetAttribLocationResult = result; } + inline void SetGetErrorResult( GLenum result) { mGetErrorResult = result; } + inline void SetGetStringResult( GLubyte* result) { mGetStringResult = result; } + inline void SetIsBufferResult( GLboolean result) { mIsBufferResult = result; } + inline void SetIsEnabledResult( GLboolean result) { mIsEnabledResult = result; } + inline void SetIsFramebufferResult( GLboolean result) { mIsFramebufferResult = result; } + inline void SetIsProgramResult( GLboolean result) { mIsProgramResult = result; } + inline void SetIsRenderbufferResult( GLboolean result) { mIsRenderbufferResult = result; } + inline void SetIsShaderResult( GLboolean result) { mIsShaderResult = result; } + inline void SetIsTextureResult( GLboolean result) { mIsTextureResult = result; } + inline void SetCheckFramebufferStatusResult( GLenum result) { mCheckFramebufferStatusResult = result; } + inline void SetNumBinaryFormats( GLint numFormats ) { mNumBinaryFormats = numFormats; } + inline void SetBinaryFormats( GLint binaryFormats ) { mBinaryFormats = binaryFormats; } + inline void SetProgramBinaryLength( GLint length ) { mProgramBinaryLength = length; } + + inline bool GetVertexAttribArrayState(GLuint index) + { + if( index >= MAX_ATTRIBUTE_CACHE_SIZE ) + { + // out of range + return false; + } + return mVertexAttribArrayState[ index ]; + } + inline void ClearVertexAttribArrayChanged() { mVertexAttribArrayChanged = false; } + inline bool GetVertexAttribArrayChanged() { return mVertexAttribArrayChanged; } + + //Methods for CullFace verification + inline void EnableCullFaceCallTrace(bool enable) { mCullFaceTrace.Enable(enable); } + inline void ResetCullFaceCallStack() { mCullFaceTrace.Reset(); } + inline TraceCallStack& GetCullFaceTrace() { return mCullFaceTrace; } + + //Methods for Shader verification + inline void EnableShaderCallTrace(bool enable) { mShaderTrace.Enable(enable); } + inline void ResetShaderCallStack() { mShaderTrace.Reset(); } + inline TraceCallStack& GetShaderTrace() { return mShaderTrace; } + + //Methods for Texture verification + inline void EnableTextureCallTrace(bool enable) { mTextureTrace.Enable(enable); } + inline void ResetTextureCallStack() { mTextureTrace.Reset(); } + inline TraceCallStack& GetTextureTrace() { return mTextureTrace; } + + //Methods for Draw verification + inline void EnableDrawCallTrace(bool enable) { mDrawTrace.Enable(enable); } + inline void ResetDrawCallStack() { mDrawTrace.Reset(); } + inline TraceCallStack& GetDrawTrace() { return mDrawTrace; } + + template + inline bool CheckUniformValue( const char* name, const T& value ) const + { + for( ProgramUniformMap::const_iterator program_it = mUniforms.begin(); + program_it != mUniforms.end(); + ++program_it ) + { + const UniformIDMap &uniformIDs = program_it->second; + + UniformIDMap::const_iterator uniform_it = uniformIDs.find( name ); + if( uniform_it != uniformIDs.end() ) + { + // found one matching uniform name, lets check the value... + GLuint programId = program_it->first; + GLint uniformId = uniform_it->second; + + const ProgramUniformValue &mProgramUniforms = GetProgramUniformsForType( value ); + if( mProgramUniforms.CheckUniformValue( programId, uniformId, value ) ) + { + // the value matches + return true; + } + } + } + + fprintf(stderr, "Not found, printing possible values:" ); + for( ProgramUniformMap::const_iterator program_it = mUniforms.begin(); + program_it != mUniforms.end(); + ++program_it ) + { + const UniformIDMap &uniformIDs = program_it->second; + + UniformIDMap::const_iterator uniform_it = uniformIDs.find( name ); + if( uniform_it != uniformIDs.end() ) + { + // found one matching uniform name, lets check the value... + GLuint programId = program_it->first; + GLint uniformId = uniform_it->second; + + const ProgramUniformValue &mProgramUniforms = GetProgramUniformsForType( value ); + T origValue; + if ( mProgramUniforms.GetUniformValue(programId, uniformId, origValue) ) + { + std::stringstream out; + out << uniform_it->first << ": " << origValue; + fprintf(stderr, "%s", out.str().c_str() ); + } + } + } + return false; + } + + template + inline bool GetUniformValue( GLuint programId, GLuint uniformId, T& outValue) const + { + const ProgramUniformValue &mProgramUniforms = GetProgramUniformsForType( outValue ); + return mProgramUniforms.GetUniformValue( programId, uniformId, outValue ); + } + + inline bool GetUniformIds( const char* name, GLuint& programId, GLuint& uniformId ) const + { + for( ProgramUniformMap::const_iterator program_it = mUniforms.begin(); + program_it != mUniforms.end(); + ++program_it ) + { + const UniformIDMap &uniformIDs = program_it->second; + + UniformIDMap::const_iterator uniform_it = uniformIDs.find( name ); + if( uniform_it != uniformIDs.end() ) + { + programId = program_it->first; + uniformId = uniform_it->second; + return true; + } + } + return false; + } + + + + inline GLuint GetLastShaderCompiled() const + { + return mLastShaderCompiled; + } + + inline GLuint GetLastProgramCreated() const + { + return mLastProgramIdUsed; + } + + enum AttribType + { + ATTRIB_UNKNOWN = -1, + ATTRIB_POSITION, + ATTRIB_NORMAL, + ATTRIB_TEXCOORD, + ATTRIB_COLOR, + ATTRIB_BONE_WEIGHTS, + ATTRIB_BONE_INDICES, + ATTRIB_TYPE_LAST + }; + + +private: + GLuint mCurrentProgram; + GLuint mCompileStatus; + GLuint mLinkStatus; + GLint mGetAttribLocationResult; + GLenum mGetErrorResult; + GLubyte* mGetStringResult; + GLboolean mIsBufferResult; + GLboolean mIsEnabledResult; + GLboolean mIsFramebufferResult; + GLboolean mIsProgramResult; + GLboolean mIsRenderbufferResult; + GLboolean mIsShaderResult; + GLboolean mIsTextureResult; + GLenum mActiveTextureUnit; + GLenum mCheckFramebufferStatusResult; + GLint mNumBinaryFormats; + GLint mBinaryFormats; + GLint mProgramBinaryLength; + bool mVertexAttribArrayState[MAX_ATTRIBUTE_CACHE_SIZE]; + bool mVertexAttribArrayChanged; // whether the vertex attrib array has been changed + typedef std::map< GLuint, std::string> ShaderSourceMap; + ShaderSourceMap mShaderSources; + GLuint mLastShaderCompiled; + + Vector4 mLastBlendColor; + GLenum mLastBlendEquationRgb; + GLenum mLastBlendEquationAlpha; + GLenum mLastBlendFuncSrcRgb; + GLenum mLastBlendFuncDstRgb; + GLenum mLastBlendFuncSrcAlpha; + GLenum mLastBlendFuncDstAlpha; + + // Data for manipulating the IDs returned by GenTextures + GLuint mLastAutoTextureIdUsed; + std::vector mNextTextureIds; + std::vector mDeletedTextureIds; + std::vector mBoundTextures; + + struct ActiveTextureType + { + std::vector mBoundTextures; + }; + + ActiveTextureType mActiveTextures[ MIN_TEXTURE_UNIT_LIMIT ]; + + TraceCallStack mCullFaceTrace; + TraceCallStack mShaderTrace; + TraceCallStack mTextureTrace; + TraceCallStack mDrawTrace; + + // Shaders & Uniforms + GLuint mLastShaderIdUsed; + GLuint mLastProgramIdUsed; + GLuint mLastUniformIdUsed; + typedef std::map< std::string, GLint > UniformIDMap; + typedef std::map< GLuint, UniformIDMap > ProgramUniformMap; + ProgramUniformMap mUniforms; + + template + struct ProgramUniformValue : public std::map< GLuint, std::map< GLint, T > > + { + public: + typedef std::map< GLint, T > UniformValueMap; + typedef std::map< GLuint, UniformValueMap > Map; + + bool SetUniformValue( GLuint program, GLuint uniform, const T& value ) + { + if( program == 0 ) + { + return false; + } + + typename Map::iterator it = Map::find( program ); + if( it == Map::end() ) + { + // if its the first uniform for this program add it + std::pair< typename Map::iterator, bool > result = + Map::insert( typename Map::value_type( program, UniformValueMap() ) ); + it = result.first; + } + + UniformValueMap& uniforms = it->second; + uniforms[uniform] = value; + + return true; + } + + bool CheckUniformValue( GLuint program, GLuint uniform, const T& value ) const + { + T uniformValue; + if ( GetUniformValue( program, uniform, uniformValue ) ) + { + return value == uniformValue; + } + + return false; + } + + bool GetUniformValue( GLuint program, GLuint uniform, T& value ) const + { + if( program == 0 ) + { + return false; + } + + typename Map::const_iterator it = Map::find( program ); + if( it == Map::end() ) + { + // Uniform values always initialised as 0 + value = GetZero(); + return true; + } + + const UniformValueMap& uniforms = it->second; + typename UniformValueMap::const_iterator it2 = uniforms.find( uniform ); + if( it2 == uniforms.end() ) + { + // Uniform values always initialised as 0 + value = GetZero(); + return true; + } + value = it2->second; + + return true; + } + + T GetZero() const; + }; + ProgramUniformValue mProgramUniforms1i; + ProgramUniformValue mProgramUniforms1f; + ProgramUniformValue mProgramUniforms2f; + ProgramUniformValue mProgramUniforms3f; + ProgramUniformValue mProgramUniforms4f; + ProgramUniformValue mProgramUniformsMat4; + ProgramUniformValue mProgramUniformsMat3; + + inline const ProgramUniformValue& GetProgramUniformsForType( const int ) const + { + return mProgramUniforms1i; + } + inline const ProgramUniformValue& GetProgramUniformsForType( const float ) const + { + return mProgramUniforms1f; + } + inline const ProgramUniformValue& GetProgramUniformsForType( const Vector2& ) const + { + return mProgramUniforms2f; + } + inline const ProgramUniformValue& GetProgramUniformsForType( const Vector3& ) const + { + return mProgramUniforms3f; + } + inline const ProgramUniformValue& GetProgramUniformsForType( const Vector4& ) const + { + return mProgramUniforms4f; + } + inline const ProgramUniformValue& GetProgramUniformsForType( const Matrix& ) const + { + return mProgramUniformsMat4; + } + inline const ProgramUniformValue& GetProgramUniformsForType( const Matrix3& ) const + { + return mProgramUniformsMat3; + } + inline void SetVertexAttribArray(GLuint index, bool state) + { + if( index >= MAX_ATTRIBUTE_CACHE_SIZE ) + { + // out of range + return; + } + mVertexAttribArrayState[ index ] = state; + mVertexAttribArrayChanged = true; + } +}; + +template <> +inline int TestGlAbstraction::ProgramUniformValue::GetZero() const +{ + return 0; +} + +template <> +inline float TestGlAbstraction::ProgramUniformValue::GetZero() const +{ + return 0.0f; +} + +template <> +inline Vector2 TestGlAbstraction::ProgramUniformValue::GetZero() const +{ + return Vector2::ZERO; +} + +template <> +inline Vector3 TestGlAbstraction::ProgramUniformValue::GetZero() const +{ + return Vector3::ZERO; +} + +template <> +inline Vector4 TestGlAbstraction::ProgramUniformValue::GetZero() const +{ + return Vector4::ZERO; +} + +template <> +inline Matrix TestGlAbstraction::ProgramUniformValue::GetZero() const +{ + return Matrix(); +} + +template <> +inline Matrix3 TestGlAbstraction::ProgramUniformValue::GetZero() const +{ + return Matrix3( Matrix() ); +} + +} // namespace Dali + +bool BlendEnabled(const Dali::TraceCallStack& callStack); +bool BlendDisabled(const Dali::TraceCallStack& callStack); + + + + +#endif // __TEST_GL_ES_H__ diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-gl-sync-abstraction.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-gl-sync-abstraction.cpp new file mode 100644 index 0000000..8ea52be --- /dev/null +++ b/automated-tests/src/dali/dali-test-suite-utils/test-gl-sync-abstraction.cpp @@ -0,0 +1,135 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 "test-gl-sync-abstraction.h" + +namespace Dali +{ + +TestSyncObject::TestSyncObject(TraceCallStack& trace) +: synced(false), + mTrace(trace) +{ +} + +TestSyncObject::~TestSyncObject() +{ +} + +bool TestSyncObject::IsSynced() +{ + mTrace.PushCall("SyncObject::IsSynced", ""); // Trace the method + return synced; +} + + + +TestGlSyncAbstraction::TestGlSyncAbstraction() +{ + Initialize(); +} + +/** + * Destructor + */ +TestGlSyncAbstraction::~TestGlSyncAbstraction() +{ + for( SyncIter iter=mSyncObjects.begin(), end=mSyncObjects.end(); iter != end; ++iter ) + { + delete *iter; + } +} + +/** + * Initialize the sync objects - clear down the map + */ +void TestGlSyncAbstraction::Initialize() +{ + mSyncObjects.clear(); +} + +/** + * Create a sync object + * @return the sync object + */ +Integration::GlSyncAbstraction::SyncObject* TestGlSyncAbstraction::CreateSyncObject( ) +{ + mTrace.PushCall("CreateSyncObject", ""); // Trace the method + + TestSyncObject* syncObject = new TestSyncObject(mTrace); + mSyncObjects.push_back( syncObject ); + return syncObject; +} + +/** + * Destroy a sync object + * @param[in] syncObject The object to destroy + */ +void TestGlSyncAbstraction::DestroySyncObject( Integration::GlSyncAbstraction::SyncObject* syncObject ) +{ + std::stringstream out; + out << syncObject; + mTrace.PushCall("DestroySyncObject", out.str()); // Trace the method + + for( SyncIter iter=mSyncObjects.begin(), end=mSyncObjects.end(); iter != end; ++iter ) + { + if( *iter == syncObject ) + { + delete *iter; + mSyncObjects.erase(iter); + break; + } + } +} + + +Integration::GlSyncAbstraction::SyncObject* TestGlSyncAbstraction::GetLastSyncObject( ) +{ + if( !mSyncObjects.empty() ) + { + return mSyncObjects.back(); + } + return NULL; +} + +/** + * Test method to trigger the object sync behaviour. + * @param[in] + * @param[in] sync The sync value to set + */ +void TestGlSyncAbstraction::SetObjectSynced( Integration::GlSyncAbstraction::SyncObject* syncObject, bool sync ) +{ + TestSyncObject* testSyncObject = static_cast(syncObject); + testSyncObject->synced = sync; +} + +/** + * Turn trace on + */ +void TestGlSyncAbstraction::EnableTrace(bool enable) { mTrace.Enable(enable); } + +/** + * Reset the trace callstack + */ +void TestGlSyncAbstraction::ResetTrace() { mTrace.Reset(); } + +/** + * Get the trace object (allows test case to find methods on it) + */ +TraceCallStack& TestGlSyncAbstraction::GetTrace() { return mTrace; } + + +} // Dali diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-gl-sync-abstraction.h b/automated-tests/src/dali/dali-test-suite-utils/test-gl-sync-abstraction.h new file mode 100644 index 0000000..9dba4cc --- /dev/null +++ b/automated-tests/src/dali/dali-test-suite-utils/test-gl-sync-abstraction.h @@ -0,0 +1,112 @@ +#ifndef __TEST_GL_SYNC_ABSTRACTION_H__ +#define __TEST_GL_SYNC_ABSTRACTION_H__ + +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +// EXTERNAL INCLUDES +#include +#include +#include + +// INTERNAL INCLUDES +#include +#include +#include +#include "test-trace-call-stack.h" + +namespace Dali +{ + +class DALI_IMPORT_API TestSyncObject : public Integration::GlSyncAbstraction::SyncObject +{ +public: + TestSyncObject(TraceCallStack& trace); + ~TestSyncObject(); + bool IsSynced(); + bool synced; + TraceCallStack& mTrace; +}; + +/** + * Class to emulate the GL sync functions with tracing + */ +class DALI_IMPORT_API TestGlSyncAbstraction: public Integration::GlSyncAbstraction +{ +public: + /** + * Constructor + */ + TestGlSyncAbstraction(); + + /** + * Destructor + */ + ~TestGlSyncAbstraction(); + + /** + * Initialize the sync objects - clear down the map + */ + void Initialize(); + + /** + * Create a sync object + * @return the sync object + */ + virtual Integration::GlSyncAbstraction::SyncObject* CreateSyncObject( ); + + /** + * Destroy a sync object + * @param[in] syncObject The object to destroy + */ + virtual void DestroySyncObject( Integration::GlSyncAbstraction::SyncObject* syncObject ); + + +public: // TEST FUNCTIONS + Integration::GlSyncAbstraction::SyncObject* GetLastSyncObject( ); + + /** + * Test method to trigger the object sync behaviour. + * @param[in] + * @param[in] sync The sync value to set + */ + void SetObjectSynced( Integration::GlSyncAbstraction::SyncObject* syncObject, bool sync ); + + /** + * Turn trace on + */ + void EnableTrace(bool enable); + + /** + * Reset the trace callstack + */ + void ResetTrace(); + + /** + * Get the trace object (allows test case to find methods on it) + */ + TraceCallStack& GetTrace(); + +private: + typedef std::vector SyncContainer; + typedef SyncContainer::iterator SyncIter; + SyncContainer mSyncObjects; ///< The sync objects + TraceCallStack mTrace; ///< the trace call stack for testing +}; + +} // Dali + +#endif // __TEST_GL_SYNC_ABSTRACTION_H__ diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-native-image.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-native-image.cpp new file mode 100644 index 0000000..0604649 --- /dev/null +++ b/automated-tests/src/dali/dali-test-suite-utils/test-native-image.cpp @@ -0,0 +1,39 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 "test-application.h" +#include "test-native-image.h" + + +namespace Dali +{ + +TestNativeImagePointer TestNativeImage::New(int width, int height) +{ + return new TestNativeImage(width, height); +} + +TestNativeImage::TestNativeImage(int width, int height) +: mWidth(width), mHeight(height) +{ +} + +TestNativeImage::~TestNativeImage() +{ +} + +} // namespace dali diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-native-image.h b/automated-tests/src/dali/dali-test-suite-utils/test-native-image.h new file mode 100644 index 0000000..2ba56a7 --- /dev/null +++ b/automated-tests/src/dali/dali-test-suite-utils/test-native-image.h @@ -0,0 +1,51 @@ +#ifndef __TEST_NATIVE_IMAGE_H__ +#define __TEST_NATIVE_IMAGE_H__ + +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +// INTERNAL INCLUDES +#include + +namespace Dali +{ +class TestNativeImage; +typedef IntrusivePtr TestNativeImagePointer; + +class DALI_IMPORT_API TestNativeImage : public Dali::NativeImage +{ +public: + static TestNativeImagePointer New(int width, int height); + + inline virtual bool GlExtensionCreate() {return true;}; + inline virtual void GlExtensionDestroy() {}; + inline virtual GLenum TargetTexture() {return 1;}; + inline virtual void PrepareTexture() {}; + inline virtual unsigned int GetWidth() const {return mWidth;}; + inline virtual unsigned int GetHeight() const {return mHeight;}; + inline virtual Pixel::Format GetPixelFormat() const {return Pixel::RGBA8888;}; + +private: + TestNativeImage(int width, int height); + virtual ~TestNativeImage(); + + int mWidth; + int mHeight; +}; + +} // Dali + +#endif diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.cpp new file mode 100644 index 0000000..27e806e --- /dev/null +++ b/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.cpp @@ -0,0 +1,637 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 "test-platform-abstraction.h" +#include "dali-test-suite-utils.h" +#include + +namespace Dali +{ + +/** + * Constructor + */ +TestPlatformAbstraction::TestPlatformAbstraction() +: mRequest(0) +{ + Initialize(); +} + +/** + * Destructor + */ +TestPlatformAbstraction::~TestPlatformAbstraction() +{ +} + +/** + * @copydoc PlatformAbstraction::GetTimeMicroseconds() + */ +void TestPlatformAbstraction::GetTimeMicroseconds(unsigned int &seconds, unsigned int µSeconds) +{ + seconds = mSeconds; + microSeconds = mMicroSeconds; + mTrace.PushCall("GetTimeMicroseconds", ""); +} + +/** + * @copydoc PlatformAbstraction::Suspend() + */ +void TestPlatformAbstraction::Suspend() +{ + mTrace.PushCall("Suspend", ""); +} + +/** + * @copydoc PlatformAbstraction::Resume() + */ +void TestPlatformAbstraction::Resume() +{ + mTrace.PushCall("Resume", ""); +} + +void TestPlatformAbstraction::GetClosestImageSize( const std::string& filename, + const ImageAttributes& attributes, + Vector2& closestSize) +{ + closestSize = mClosestSize; + mTrace.PushCall("GetClosestImageSize", ""); +} + +void TestPlatformAbstraction::GetClosestImageSize( Integration::ResourcePointer resourceBuffer, + const ImageAttributes& attributes, + Vector2& closestSize) +{ + closestSize = mClosestSize; + mTrace.PushCall("GetClosestImageSize", ""); +} + + +/** + * @copydoc PlatformAbstraction::LoadResource() + */ +void TestPlatformAbstraction::LoadResource(const Integration::ResourceRequest& request) +{ + mTrace.PushCall("LoadResource", ""); + if(mRequest != NULL) + { + delete mRequest; + tet_infoline ("Warning: multiple resource requests not handled by Test Suite. You may see unexpected errors"); + } + mRequest = new Integration::ResourceRequest(request); +} + +Integration::ResourcePointer TestPlatformAbstraction::LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath ) +{ + mTrace.PushCall("LoadResourceSynchronously", ""); + return mResources.loadedResource; +} + +/** + * @copydoc PlatformAbstraction::SaveResource() + */ +void TestPlatformAbstraction::SaveResource(const Integration::ResourceRequest& request) +{ + mTrace.PushCall("SaveResource", ""); + if(mRequest != NULL) + { + delete mRequest; + tet_infoline ("Warning: multiple resource requests not handled by Test Suite. You may see unexpected errors"); + } + mRequest = new Integration::ResourceRequest(request); +} + +/** + * @copydoc PlatformAbstraction::CancelLoad() + */ +void TestPlatformAbstraction::CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId) +{ + mTrace.PushCall("CancelLoad", ""); +} + +/** + * @copydoc PlatformAbstraction::GetResources() + */ +void TestPlatformAbstraction::GetResources(Integration::ResourceCache& cache) +{ + mTrace.PushCall("GetResources", ""); + + if(mResources.loaded) + { + cache.LoadResponse( mResources.loadedId, mResources.loadedType, mResources.loadedResource, Integration::RESOURCE_COMPLETELY_LOADED ); + } + if(mResources.loadFailed) + { + cache.LoadFailed( mResources.loadFailedId, mResources.loadFailure ); + } + if(mResources.saved) + { + cache.SaveComplete( mResources.savedId, mResources.savedType ); + } + if(mResources.saveFailed) + { + cache.SaveFailed( mResources.saveFailedId, mResources.saveFailure ); + } +} + +/** + * @copydoc PlatformAbstraction::IsLoading() + */ +bool TestPlatformAbstraction::IsLoading() +{ + mTrace.PushCall("IsLoading", ""); + return mIsLoadingResult; +} + +/** + * @copydoc PlatformAbstraction::GetDefaultFontFamily() + */ +std::string TestPlatformAbstraction::GetDefaultFontFamily() const +{ + mTrace.PushCall("GetDefaultFontFamily", ""); + return mGetDefaultFontFamilyResult; +} + +/** + * @copydoc PlatformAbstraction::GetDefaultFontSize() + */ +const float TestPlatformAbstraction::GetDefaultFontSize() const +{ + mTrace.PushCall("GetDefaultFontSize", ""); + return mGetDefaultFontSizeResult; +} + +const PixelSize TestPlatformAbstraction::GetFontLineHeightFromCapsHeight(const std::string& fontFamily, const std::string& fontStyle, const CapsHeight& capsHeight) const +{ + mTrace.PushCall("GetFontLineHeightFromCapsHeight", ""); + // LineHeight will be bigger than CapsHeight, so return capsHeight + 1 + return PixelSize(capsHeight + 1); +} + +/** + * @copydoc PlatformAbstraction::GetGlyphData() + */ + +Integration::GlyphSet* TestPlatformAbstraction::GetGlyphData ( const Integration::TextResourceType& textRequest, + const std::string& fontFamily, + bool getBitmap) const +{ + if( getBitmap ) + { + mTrace.PushCall("GetGlyphData", "getBitmap:true"); + } + else + { + mTrace.PushCall("GetGlyphData", "getBitmap:false"); + } + + // It creates fake metrics for the received characters. + + Integration::GlyphSet* set = new Dali::Integration::GlyphSet(); + Integration::BitmapPtr bitmapData; + + std::set characters; + + for( Integration::TextResourceType::CharacterList::const_iterator it = textRequest.mCharacterList.begin(), endIt = textRequest.mCharacterList.end(); it != endIt; ++it ) + { + if( characters.find( it->character ) == characters.end() ) + { + characters.insert( it->character ); + Integration::GlyphMetrics character = {it->character, Integration::GlyphMetrics::LOW_QUALITY, 10.0f, 10.0f, 9.0f, 1.0f, 10.0f, it->xPosition, it->yPosition }; + + if( getBitmap ) + { + bitmapData = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true); + bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, 64, 64); + PixelBuffer* pixelBuffer = bitmapData->GetBuffer(); + memset( pixelBuffer, it->character, 64*64 ); + } + + set->AddCharacter(bitmapData, character); + } + } + + set->mLineHeight = 10.0f; + set->mAscender = 9.0f; + set->mUnitsPerEM = 2048.0f/64.0f; + set->SetAtlasResourceId( textRequest.mTextureAtlasId ); + set->mFontHash = textRequest.mFontHash; + + return set; +} + +/** + * @copydoc PlatformAbstraction::GetCachedGlyphData() + */ + +Integration::GlyphSet* TestPlatformAbstraction::GetCachedGlyphData( const Integration::TextResourceType& textRequest, + const std::string& fontFamily ) const +{ + mTrace.PushCall("GetCachedGlyphData", ""); + + // It creates fake metrics and bitmap for received numeric characters '0' through '9'. + Integration::GlyphSet* set = new Dali::Integration::GlyphSet(); + Integration::BitmapPtr bitmapData; + + std::set characters; + + for( Integration::TextResourceType::CharacterList::const_iterator it = textRequest.mCharacterList.begin(), endIt = textRequest.mCharacterList.end(); it != endIt; ++it ) + { + if( it->character >= '0' && it->character <= '9' && characters.find( it->character ) == characters.end() ) + { + characters.insert( it->character ); + Integration::GlyphMetrics character = {it->character, Integration::GlyphMetrics::HIGH_QUALITY, 10.0f, 10.0f, 9.0f, 1.0f, 10.0f, it->xPosition, it->yPosition }; + + bitmapData = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true); + bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, 64, 64); + PixelBuffer* pixelBuffer = bitmapData->GetBuffer(); + memset( pixelBuffer, it->character, 64*64 ); + set->AddCharacter(bitmapData, character); + } + } + + set->mLineHeight = 10.0f; + set->mAscender = 9.0f; + set->mUnitsPerEM = 2048.0f/64.0f; + set->SetAtlasResourceId( textRequest.mTextureAtlasId ); + set->mFontHash = textRequest.mFontHash; + + return set; +} + + +/** + * @copydoc PlatformAbstraction::GetGlobalMetrics() + */ +void TestPlatformAbstraction::GetGlobalMetrics( const std::string& fontFamily, + const std::string& fontStyle, + Integration::GlobalMetrics& globalMetrics ) const +{ + globalMetrics.lineHeight = 10.0f; + globalMetrics.ascender = 9.0f; + globalMetrics.unitsPerEM = 2048.0f/64.0f; + globalMetrics.underlineThickness = 2.f; + globalMetrics.underlinePosition = 1.f; +} + +/** + * @copydoc PlatformAbstraction::GetFontPath() + */ +std::string TestPlatformAbstraction::GetFontPath(const std::string& family, bool bold, bool italic) const +{ + mTrace.PushCall("GetFontPath", ""); + return mGetFontPathResult; + + // Do nothing with arguments +} + +/** + * @copydoc PlatformAbstraction::SetDpi() + */ +void TestPlatformAbstraction::SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical) +{ + mTrace.PushCall("SetDpi", ""); +} + +/** + * @copydoc PlatformAbstraction::GetFontFamilyForChars() + */ +std::string TestPlatformAbstraction::GetFontFamilyForChars(const TextArray& charsRequested) const +{ + mTrace.PushCall("GetFontFamilyForChars", ""); + return mGetDefaultFontFamilyResult; +} + +/** + * @copydoc PlatformAbstraction::AllGlyphsSupported() + */ +bool TestPlatformAbstraction::AllGlyphsSupported(const std::string& name, const std::string& fontStyle, const TextArray& text) const +{ + mTrace.PushCall("AllGlyphsSupported", ""); + return true; +} + +/** + * @copydoc PlatformAbstraction::ValidateFontFamilyName() + */ +bool TestPlatformAbstraction::ValidateFontFamilyName(const std::string& fontFamily, const std::string& fontStyle, bool& isDefaultSystemFont, std::string& closestMatch, std::string& closestStyleMatch) const +{ + mTrace.PushCall("ValidateFontFamilyName", ""); + return true; +} + +/** + * @copydoc PlatformAbstraction::GetFontList() + */ +std::vector TestPlatformAbstraction::GetFontList( PlatformAbstraction::FontListMode mode ) const +{ + mFontListMode = mode; + mTrace.PushCall("ValidateGetFontList", ""); + std::vector fontList; + return fontList; +} + +/** + * @copydoc PlatformAbstraction::LoadFile() + */ +bool TestPlatformAbstraction::LoadFile( const std::string& filename, std::vector< unsigned char >& buffer ) const +{ + mTrace.PushCall("LoadFile", ""); + if( mLoadFileResult.loadResult ) + { + buffer = mLoadFileResult.buffer; + } + + return mLoadFileResult.loadResult; +} + +/** + * @copydoc PlatformAbstraction::SaveFile() + */ +bool TestPlatformAbstraction::SaveFile(const std::string& filename, std::vector< unsigned char >& buffer) const +{ + mTrace.PushCall("SaveFile", ""); + return false; +} + +void TestPlatformAbstraction::JoinLoaderThreads() +{ + mTrace.PushCall("JoinLoaderThreads", ""); +} + +void TestPlatformAbstraction::UpdateDefaultsFromDevice() +{ + mTrace.PushCall("UpdateDefaultsFromDevice", ""); + mGetDefaultFontFamilyResult+=1.0f; +} + +Integration::DynamicsFactory* TestPlatformAbstraction::GetDynamicsFactory() +{ + mTrace.PushCall("GetDynamicsFactory", ""); + return NULL; +} + +bool TestPlatformAbstraction::ReadGlobalMetricsFromCache( const std::string& fontFamily, + const std::string& fontStyle, + Integration::GlobalMetrics& globalMetrics ) +{ + mTrace.PushCall("ReadGlobalMetricsFromCacheFile", ""); + globalMetrics = mReadGlobalMetrics; // Want to copy contents... + return mReadGlobalMetricsResult; // Default false (will be set to true on subsequent write) +} + +void TestPlatformAbstraction::WriteGlobalMetricsToCache( const std::string& fontFamily, + const std::string& fontStyle, + const Integration::GlobalMetrics& globalMetrics ) +{ + // Copy so next read uses written values. TODO: Could add method + // to turn this behaviour off for more extensive testing. + mReadGlobalMetrics = globalMetrics; + mReadGlobalMetricsResult = true; + + mTrace.PushCall("WriteGlobalMetricsToCacheFile", ""); +} + +bool TestPlatformAbstraction::ReadMetricsFromCache( const std::string& fontFamily, + const std::string& fontStyle, + std::vector& glyphMetricsContainer ) +{ + mTrace.PushCall("ReadMetricsFromCacheFile", ""); + glyphMetricsContainer = mReadMetrics; + return mReadMetricsResult; // Default false (will be set to true on subsequent write) +} + +void TestPlatformAbstraction::WriteMetricsToCache( const std::string& fontFamily, + const std::string& fontStyle, + const Integration::GlyphSet& glyphSet ) +{ + // Copy so next read uses written values. TODO: Could add method + // to turn this behaviour off for more extensive testing. + const Integration::GlyphSet::CharacterList& charList = glyphSet.GetCharacterList(); + mReadMetrics.clear(); + for(std::size_t i=0, end=charList.size(); i& fileNames ) +{ + fileNames.push_back( std::string( "u1f004.png" ) ); + fileNames.push_back( std::string( "u1f0cf.png" ) ); + fileNames.push_back( std::string( "u1f170.png" ) ); + fileNames.push_back( std::string( "u1f601.png" ) ); +} + + +Integration::BitmapPtr TestPlatformAbstraction::GetGlyphImage( const std::string& fontFamily, const std::string& fontStyle, float fontSize, uint32_t character ) const +{ + Integration::BitmapPtr image = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true ); + image->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 1, 1 ); + + mTrace.PushCall("GetGlyphImage", ""); + + return image; +} + + +/** Call this every test */ +void TestPlatformAbstraction::Initialize() +{ + mTrace.Reset(); + mTrace.Enable(true); + memset(&mResources, 0, sizeof(Resources)); + memset(&mReadGlobalMetrics, 0, sizeof(Integration::GlobalMetrics)); + mSeconds=0; + mMicroSeconds=0; + mIsLoadingResult=false; + mGetDefaultFontFamilyResult = "HelveticaNeue"; + mGetDefaultFontSizeResult=12.0f; + mGetFontPathResult="helvetica-12"; + mReadMetricsResult=false; + mReadGlobalMetricsResult=false; + + if(mRequest) + { + delete mRequest; + mRequest = 0; + } +} + + +bool TestPlatformAbstraction::WasCalled(TestFuncEnum func) +{ + switch(func) + { + case GetTimeMicrosecondsFunc: return mTrace.FindMethod("GetTimeMicroseconds"); + case SuspendFunc: return mTrace.FindMethod("Suspend"); + case ResumeFunc: return mTrace.FindMethod("Resume"); + case LoadResourceFunc: return mTrace.FindMethod("LoadResource"); + case SaveResourceFunc: return mTrace.FindMethod("SaveResource"); + case LoadFileFunc: return mTrace.FindMethod("LoadFile"); + case SaveFileFunc: return mTrace.FindMethod("SaveFile"); + case CancelLoadFunc: return mTrace.FindMethod("CancelLoad"); + case GetResourcesFunc: return mTrace.FindMethod("GetResources"); + case IsLoadingFunc: return mTrace.FindMethod("IsLoading"); + case GetDefaultFontFamilyFunc: return mTrace.FindMethod("GetDefaultFontFamily"); + case GetDefaultFontSizeFunc: return mTrace.FindMethod("GetDefaultFontSize"); + case GetFontLineHeightFromCapsHeightFunc: return mTrace.FindMethod("GetFontLineHeightFromCapsHeight"); + case GetGlyphDataFunc: return mTrace.FindMethod("GetGlyphData"); + case GetCachedGlyphDataFunc: return mTrace.FindMethod("GetCachedGlyphData"); + case GetFontPathFunc: return mTrace.FindMethod("GetFontPath"); + case SetDpiFunc: return mTrace.FindMethod("SetDpi"); + case JoinLoaderThreadsFunc: return mTrace.FindMethod("JoinLoaderThreads"); + case GetFontFamilyForCharsFunc: return mTrace.FindMethod("GetFontFamilyForChars"); + case AllGlyphsSupportedFunc: return mTrace.FindMethod("AllGlyphsSupported"); + case ValidateFontFamilyNameFunc: return mTrace.FindMethod("ValidateFontFamilyName"); + case UpdateDefaultsFromDeviceFunc: return mTrace.FindMethod("UpdateDefaultsFromDevice"); + case GetDynamicsFactoryFunc: return mTrace.FindMethod("GetDynamicsFactory"); + case ValidateGetFontListFunc: return mTrace.FindMethod("ValidateGetFontList"); + case ReadGlobalMetricsFromCacheFileFunc: return mTrace.FindMethod("ReadGlobalMetricsFromCacheFile"); + case WriteGlobalMetricsToCacheFileFunc: return mTrace.FindMethod("WriteGlobalMetricsToCacheFile"); + case ReadMetricsFromCacheFileFunc: return mTrace.FindMethod("ReadMetricsFromCacheFile"); + case WriteMetricsToCacheFileFunc: return mTrace.FindMethod("WriteMetricsToCacheFile"); + } + return false; +} + +void TestPlatformAbstraction::SetGetTimeMicrosecondsResult(size_t sec, size_t usec) +{ + mSeconds = sec; + mMicroSeconds = usec; +} + +void TestPlatformAbstraction::IncrementGetTimeResult(size_t milliseconds) +{ + mMicroSeconds += milliseconds * 1000u; + unsigned int additionalSeconds = mMicroSeconds / 1000000u; + + mSeconds += additionalSeconds; + mMicroSeconds -= additionalSeconds * 1000000u; +} + +void TestPlatformAbstraction::SetIsLoadingResult(bool result) +{ + mIsLoadingResult = result; +} + +void TestPlatformAbstraction::SetGetDefaultFontFamilyResult(std::string result) +{ + mGetDefaultFontFamilyResult = result; +} + +void TestPlatformAbstraction::SetGetDefaultFontSizeResult(float result) +{ + mGetDefaultFontSizeResult = result; +} + +void TestPlatformAbstraction::SetGetFontPathResult(std::string& result) +{ + mGetFontPathResult = result; +} + +void TestPlatformAbstraction::ClearReadyResources() +{ + memset(&mResources, 0, sizeof(Resources)); +} + +void TestPlatformAbstraction::SetResourceLoaded(Integration::ResourceId loadedId, + Integration::ResourceTypeId loadedType, + Integration::ResourcePointer loadedResource) +{ + mResources.loaded = true; + mResources.loadedId = loadedId; + mResources.loadedType = loadedType; + mResources.loadedResource = loadedResource; +} + +void TestPlatformAbstraction::SetResourceLoadFailed(Integration::ResourceId id, + Integration::ResourceFailure failure) +{ + mResources.loadFailed = true; + mResources.loadFailedId = id; + mResources.loadFailure = failure; +} + +void TestPlatformAbstraction::SetResourceSaved(Integration::ResourceId savedId, + Integration::ResourceTypeId savedType) +{ + mResources.saved = true; + mResources.savedId = savedId; + mResources.savedType = savedType; +} + +void TestPlatformAbstraction::SetResourceSaveFailed(Integration::ResourceId id, + Integration::ResourceFailure failure) +{ + mResources.saveFailed = true; + mResources.saveFailedId = id; + mResources.saveFailure = failure; +} + +Integration::ResourceRequest* TestPlatformAbstraction::GetRequest() +{ + return mRequest; +} + +void TestPlatformAbstraction::DiscardRequest() +{ + delete mRequest; + mRequest = NULL; +} + +void TestPlatformAbstraction::SetClosestImageSize(const Vector2& size) +{ + mClosestSize = size; +} + +void TestPlatformAbstraction::SetLoadFileResult( bool result, std::vector< unsigned char >& buffer ) +{ + mLoadFileResult.loadResult = result; + if( result ) + { + mLoadFileResult.buffer = buffer; + } +} + +void TestPlatformAbstraction::SetSaveFileResult( bool result ) +{ + mSaveFileResult = result; +} + +Integration::PlatformAbstraction::FontListMode TestPlatformAbstraction::GetLastFontListMode( ) +{ + return mFontListMode; +} + +void TestPlatformAbstraction::SetReadGlobalMetricsResult( bool success, Integration::GlobalMetrics& globalMetrics ) +{ + mReadGlobalMetricsResult = success; + mReadGlobalMetrics = globalMetrics; +} + +void TestPlatformAbstraction::SetReadMetricsResult( bool success, std::vector& glyphMetricsContainer ) +{ + mReadMetricsResult = success; + mReadMetrics = glyphMetricsContainer; // copy +} + +} // namespace Dali diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.h b/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.h new file mode 100644 index 0000000..5051fce --- /dev/null +++ b/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.h @@ -0,0 +1,350 @@ +#ifndef __DALI_TEST_PLATFORM_ABSTRACTION_H__ +#define __DALI_TEST_PLATFORM_ABSTRACTION_H__ + +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +// EXTERNAL INCLUDES +#include +#include +#include + +// INTERNAL INCLUDES +#include + +#include +#include "test-trace-call-stack.h" + + +namespace Dali +{ + +/** + * Concrete implementation of the platform abstraction class. + */ +class DALI_IMPORT_API TestPlatformAbstraction : public Dali::Integration::PlatformAbstraction +{ + +public: + + struct Resources + { + bool loaded; + Integration::ResourceId loadedId; + Integration::ResourceTypeId loadedType; + Integration::ResourcePointer loadedResource; + + bool loadFailed; + Integration::ResourceId loadFailedId; + Integration::ResourceFailure loadFailure; + + bool saved; + Integration::ResourceId savedId; + Integration::ResourceTypeId savedType; + + bool saveFailed; + Integration::ResourceId saveFailedId; + Integration::ResourceFailure saveFailure; + }; + + struct LoadFileResult + { + inline LoadFileResult() + : loadResult(false) + { + + } + + bool loadResult; + std::vector< unsigned char> buffer; + }; + + /** + * Constructor + */ + TestPlatformAbstraction(); + + /** + * Destructor + */ + virtual ~TestPlatformAbstraction(); + + /** + * @copydoc PlatformAbstraction::GetTimeMicroseconds() + */ + virtual void GetTimeMicroseconds(unsigned int &seconds, unsigned int µSeconds); + + /** + * @copydoc PlatformAbstraction::Suspend() + */ + virtual void Suspend(); + + /** + * @copydoc PlatformAbstraction::Resume() + */ + virtual void Resume(); + + virtual void GetClosestImageSize( const std::string& filename, + const ImageAttributes& attributes, + Vector2& closestSize); + + virtual void GetClosestImageSize( Integration::ResourcePointer resourceBuffer, + const ImageAttributes& attributes, + Vector2& closestSize); + + /** + * @copydoc PlatformAbstraction::LoadResource() + */ + virtual void LoadResource(const Integration::ResourceRequest& request); + + /** + * @copydoc PlatformAbstraction::LoadResourceSynchronously() + */ + virtual Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath ); + + /** + * @copydoc PlatformAbstraction::SaveResource() + */ + virtual void SaveResource(const Integration::ResourceRequest& request); + + /** + * @copydoc PlatformAbstraction::CancelLoad() + */ + virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId); + + /** + * @copydoc PlatformAbstraction::GetResources() + */ + virtual void GetResources(Integration::ResourceCache& cache); + + /** + * @copydoc PlatformAbstraction::IsLoading() + */ + virtual bool IsLoading(); + + /** + * @copydoc PlatformAbstraction::GetDefaultFontFamily() + */ + virtual std::string GetDefaultFontFamily() const; + + /** + * @copydoc PlatformAbstraction::GetDefaultFontSize() + */ + virtual const float GetDefaultFontSize() const; + + virtual const Dali::PixelSize GetFontLineHeightFromCapsHeight(const std::string& fontFamily, const std::string& fontStyle, const CapsHeight& capsHeight) const; + + /** + * @copydoc PlatformAbstraction::GetGlyphData() + */ + virtual Integration::GlyphSet* GetGlyphData ( const Integration::TextResourceType& textRequest, + const std::string& fontFamily, + bool getBitmap) const; + + /** + * @copydoc PlatformAbstraction::GetCachedGlyphData() + */ + virtual Integration::GlyphSet* GetCachedGlyphData( const Integration::TextResourceType& textRequest, + const std::string& fontFamily ) const; + + + /** + * @copydoc PlatformAbstraction::GetGlobalMetrics() + */ + virtual void GetGlobalMetrics( const std::string& fontFamily, + const std::string& fontStyle, + Integration::GlobalMetrics& globalMetrics ) const; + + /** + * @copydoc PlatformAbstraction::GetFontPath() + */ + virtual std::string GetFontPath(const std::string& family, bool bold, bool italic) const; + + /** + * @copydoc PlatformAbstraction::SetDpi() + */ + virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical); + + /** + * @copydoc PlatformAbstraction::GetFontFamilyForChars() + */ + virtual std::string GetFontFamilyForChars(const TextArray& charsRequested) const; + + /** + * @copydoc PlatformAbstraction::AllGlyphsSupported() + */ + virtual bool AllGlyphsSupported(const std::string& name, const std::string& fontStyle, const TextArray& text) const; + + /** + * @copydoc PlatformAbstraction::ValidateFontFamilyName() + */ + virtual bool ValidateFontFamilyName(const std::string& fontFamily, const std::string& fontStyle, bool& isDefaultSystemFont, std::string& closestMatch, std::string& closestStyleMatch) const; + + /** + * @copydoc PlatformAbstraction::GetFontList() + */ + virtual std::vector GetFontList( PlatformAbstraction::FontListMode mode ) const; + + /** + * @copydoc PlatformAbstraction::LoadFile() + */ + virtual bool LoadFile( const std::string& filename, std::vector< unsigned char >& buffer ) const; + + /** + * @copydoc PlatformAbstraction::SaveFile() + */ + virtual bool SaveFile(const std::string& filename, std::vector< unsigned char >& buffer) const; + + virtual void JoinLoaderThreads(); + + virtual void UpdateDefaultsFromDevice(); + + virtual Integration::DynamicsFactory* GetDynamicsFactory(); + + virtual bool ReadGlobalMetricsFromCache( const std::string& fontFamily, + const std::string& fontStyle, + Integration::GlobalMetrics& globalMetrics ); + + virtual void WriteGlobalMetricsToCache( const std::string& fontFamily, + const std::string& fontStyle, + const Integration::GlobalMetrics& globalMetrics ); + + virtual bool ReadMetricsFromCache( const std::string& fontFamily, + const std::string& fontStyle, + std::vector& glyphMetricsContainer ); + virtual void WriteMetricsToCache( const std::string& fontFamily, + const std::string& fontStyle, + const Integration::GlyphSet& glyphSet ); + + + virtual void GetFileNamesFromDirectory( const std::string& directoryName, + std::vector& fileNames ); + + virtual Integration::BitmapPtr GetGlyphImage( const std::string& fontFamily, const std::string& fontStyle, float fontSize, uint32_t character ) const; + +public: // TEST FUNCTIONS + + // Enumeration of Platform Abstraction methods + typedef enum + { + GetTimeMicrosecondsFunc, + SuspendFunc, + ResumeFunc, + LoadResourceFunc, + SaveResourceFunc, + SaveFileFunc, + LoadFileFunc, + CancelLoadFunc, + GetResourcesFunc, + IsLoadingFunc, + GetDefaultFontFamilyFunc, + GetDefaultFontSizeFunc, + GetFontLineHeightFromCapsHeightFunc, + GetGlyphDataFunc, + GetCachedGlyphDataFunc, + SetDpiFunc, + GetFontPathFunc, + JoinLoaderThreadsFunc, + GetFontFamilyForCharsFunc, + AllGlyphsSupportedFunc, + ValidateFontFamilyNameFunc, + UpdateDefaultsFromDeviceFunc, + GetDynamicsFactoryFunc, + ValidateGetFontListFunc, + ReadGlobalMetricsFromCacheFileFunc, + WriteGlobalMetricsToCacheFileFunc, + ReadMetricsFromCacheFileFunc, + WriteMetricsToCacheFileFunc, + } TestFuncEnum; + + /** Call this every test */ + void Initialize(); + + inline void EnableTrace(bool enable) { mTrace.Enable(enable); } + inline void ResetTrace() { mTrace.Reset(); } + inline TraceCallStack& GetTrace() { return mTrace; } + + bool WasCalled(TestFuncEnum func); + + void SetGetTimeMicrosecondsResult(size_t sec, size_t usec); + + void IncrementGetTimeResult(size_t milliseconds); + + void SetIsLoadingResult(bool result); + + void SetGetDefaultFontFamilyResult(std::string result); + + void SetGetDefaultFontSizeResult(float result); + + void SetGetFontPathResult(std::string& result); + + void ClearReadyResources(); + + void SetResourceLoaded(Integration::ResourceId loadedId, + Integration::ResourceTypeId loadedType, + Integration::ResourcePointer loadedResource); + + void SetResourceLoadFailed(Integration::ResourceId id, + Integration::ResourceFailure failure); + + void SetResourceSaved(Integration::ResourceId savedId, + Integration::ResourceTypeId savedType); + + void SetResourceSaveFailed(Integration::ResourceId id, + Integration::ResourceFailure failure); + + Integration::ResourceRequest* GetRequest(); + + void DiscardRequest(); + + void SetClosestImageSize(const Vector2& size); + + void SetLoadFileResult( bool result, std::vector< unsigned char >& buffer ); + + void SetSaveFileResult( bool result ); + + PlatformAbstraction::FontListMode GetLastFontListMode( ); + + void SetReadGlobalMetricsResult( bool success, Integration::GlobalMetrics& globalMetrics ); + + void SetReadMetricsResult( bool success, std::vector& glyphMetricsContainer ); + + +private: + mutable TraceCallStack mTrace; + size_t mSeconds; + size_t mMicroSeconds; + bool mIsLoadingResult; + std::string mGetDefaultFontFamilyResult; + float mGetDefaultFontSizeResult; + std::string mGetFontPathResult; + Resources mResources; + Integration::ResourceRequest* mRequest; + Vector2 mSize; + Vector2 mClosestSize; + bool mReadGlobalMetricsResult; + bool mReadMetricsResult; + Integration::GlobalMetrics mReadGlobalMetrics; + std::vector mReadMetrics; + + LoadFileResult mLoadFileResult; + bool mSaveFileResult; + mutable FontListMode mFontListMode; +}; + +} // Dali + +#endif /* __DALI_TET_PLATFORM_ABSTRACTION_H__ */ diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-render-controller.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-render-controller.cpp new file mode 100644 index 0000000..76b20de --- /dev/null +++ b/automated-tests/src/dali/dali-test-suite-utils/test-render-controller.cpp @@ -0,0 +1,59 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 "test-render-controller.h" + +namespace Dali +{ + +TestRenderController::TestRenderController() +{ + Initialize(); +} + +TestRenderController::~TestRenderController() +{ +} + +void TestRenderController::RequestUpdate() +{ + mRequestUpdateCalled = true; +} + +void TestRenderController::RequestProcessEventsOnIdle() +{ + mRequestProcessEventsOnIdleCalled = true; +} + +bool TestRenderController::WasCalled(TestRenderControllerFuncEnum func) +{ + switch(func) + { + case RequestUpdateFunc: return mRequestUpdateCalled; + case RequestProcessEventsOnIdleFunc: return mRequestProcessEventsOnIdleCalled; + } + + return false; +} + +void TestRenderController::Initialize() +{ + mRequestUpdateCalled = false; + mRequestProcessEventsOnIdleCalled = false; +} + + +} // namespace dali diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-render-controller.h b/automated-tests/src/dali/dali-test-suite-utils/test-render-controller.h new file mode 100644 index 0000000..83b64a6 --- /dev/null +++ b/automated-tests/src/dali/dali-test-suite-utils/test-render-controller.h @@ -0,0 +1,53 @@ +#ifndef __TEST_RENDER_CONTROLLER_H__ +#define __TEST_RENDER_CONTROLLER_H__ + +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ + +class DALI_IMPORT_API TestRenderController : public Dali::Integration::RenderController +{ +public: + TestRenderController(); + ~TestRenderController(); + + virtual void RequestUpdate(); + virtual void RequestProcessEventsOnIdle(); + + typedef enum + { + RequestUpdateFunc, + RequestProcessEventsOnIdleFunc, + } TestRenderControllerFuncEnum; + + bool WasCalled(TestRenderControllerFuncEnum func); + void Initialize(); + + +private: + bool mRequestUpdateCalled; + bool mRequestProcessEventsOnIdleCalled; +}; + +} // Dali + +#endif diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-trace-call-stack.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-trace-call-stack.cpp new file mode 100644 index 0000000..4837b48 --- /dev/null +++ b/automated-tests/src/dali/dali-test-suite-utils/test-trace-call-stack.cpp @@ -0,0 +1,111 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 "test-trace-call-stack.h" + +namespace Dali +{ +/** + * Constructor + */ +TraceCallStack::TraceCallStack() : mTraceActive(false) { } + +/** + * Destructor + */ +TraceCallStack::~TraceCallStack() { } + +/** + * Turn on / off tracing + */ +void TraceCallStack::Enable(bool enable) { mTraceActive = enable; } + +/** + * Push a call onto the stack if the trace is active + * @param[in] method The name of the method + * @param[in] params A comma separated list of parameter values + */ +void TraceCallStack::PushCall(std::string method, std::string params) +{ + if(mTraceActive) + { + std::vector< std::string > functionCall; + functionCall.push_back(method); + functionCall.push_back(params); + mCallStack.push_back( functionCall ); + } +} + +/** + * Search for a method in the stack + * @param[in] method The name of the method + * @return true if the method was in the stack + */ +bool TraceCallStack::FindMethod(std::string method) const +{ + bool found = false; + for( size_t i=0; i < mCallStack.size(); i++ ) + { + if( 0 == mCallStack[i][0].compare(method) ) + { + found = true; + break; + } + } + return found; +} + +/** + * Search for a method in the stack with the given parameter list + * @param[in] method The name of the method + * @param[in] params A comma separated list of parameter values + * @return true if the method was in the stack + */ +bool TraceCallStack::FindMethodAndParams(std::string method, std::string params) const +{ + bool found = false; + for( size_t i=0; i < mCallStack.size(); i++ ) + { + if( 0 == mCallStack[i][0].compare(method) && 0 == mCallStack[i][1].compare(params) ) + { + found = true; + break; + } + } + return found; +} + +/** + * Test if the given method and parameters are at a given index in the stack + * @param[in] index Index in the call stack + * @param[in] method Name of method to test + * @param[in] params A comma separated list of parameter values to test + */ +bool TraceCallStack::TestMethodAndParams(int index, std::string method, std::string params) const +{ + return ( 0 == mCallStack[index][0].compare(method) && 0 == mCallStack[index][1].compare(params) ); +} + +/** + * Reset the call stack + */ +void TraceCallStack::Reset() +{ + mCallStack.clear(); +} + + +} // namespace Dali diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-trace-call-stack.h b/automated-tests/src/dali/dali-test-suite-utils/test-trace-call-stack.h new file mode 100644 index 0000000..76d6061 --- /dev/null +++ b/automated-tests/src/dali/dali-test-suite-utils/test-trace-call-stack.h @@ -0,0 +1,96 @@ +#ifndef __TEST_TRACE_CALL_STACK_H__ +#define __TEST_TRACE_CALL_STACK_H__ + +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +namespace Dali +{ + +/** + * Helper class to track method calls in the abstraction and search for them in test cases + */ +class TraceCallStack +{ +public: + /** + * Constructor + */ + TraceCallStack(); + + /** + * Destructor + */ + ~TraceCallStack(); + + /** + * Turn on / off tracing + */ + void Enable(bool enable); + + /** + * Push a call onto the stack if the trace is active + * @param[in] method The name of the method + * @param[in] params A comma separated list of parameter values + */ + void PushCall(std::string method, std::string params); + + + /** + * Search for a method in the stack + * @param[in] method The name of the method + * @return true if the method was in the stack + */ + bool FindMethod(std::string method) const; + + /** + * Search for a method in the stack with the given parameter list + * @param[in] method The name of the method + * @param[in] params A comma separated list of parameter values + * @return true if the method was in the stack + */ + bool FindMethodAndParams(std::string method, std::string params) const; + + /** + * Test if the given method and parameters are at a given index in the stack + * @param[in] index Index in the call stack + * @param[in] method Name of method to test + * @param[in] params A comma separated list of parameter values to test + */ + bool TestMethodAndParams(int index, std::string method, std::string params) const; + + /** + * Reset the call stack + */ + void Reset(); + + /** + * Get the call stack + * @return The call stack object (Vector of vector[2] of method/paramlist strings) + */ + inline const std::vector< std::vector< std::string > >& GetCallStack() { return mCallStack; } + +private: + bool mTraceActive; ///< True if the trace is active + std::vector< std::vector< std::string > > mCallStack; ///< The call stack +}; + +} // namespace dali + +#endif //__TEST_TRACE_CALL_STACK_H__ diff --git a/automated-tests/src/dali/tct-dali-core.cpp b/automated-tests/src/dali/tct-dali-core.cpp new file mode 100644 index 0000000..84613cd --- /dev/null +++ b/automated-tests/src/dali/tct-dali-core.cpp @@ -0,0 +1,31 @@ +#include +#include +#include "tct-dali-core.h" + +int main(int argc, const char *argv[]) +{ + int result = -1; + int i; + + if (argc != 2) { + printf("Usage: %s \n", argv[0]); + return 2; + } + + for (i = 0; tc_array[i].name; i++) { + if (!strcmp(argv[1], tc_array[i].name)) { + if (tc_array[i].startup) + tc_array[i].startup(); + + result = tc_array[i].function(); + + if (tc_array[i].cleanup) + tc_array[i].cleanup(); + + return result; + } + } + + printf("Unknown testcase name: \"%s\"\n", argv[1]); + return 2; +} diff --git a/automated-tests/src/dali/tct-dali-core.h b/automated-tests/src/dali/tct-dali-core.h new file mode 100644 index 0000000..88f558e --- /dev/null +++ b/automated-tests/src/dali/tct-dali-core.h @@ -0,0 +1,2532 @@ +#ifndef __TCT_DALI_CORE_H__ +#define __TCT_DALI_CORE_H__ + +#include "testcase.h" + +extern void utc_dali_active_constraint_startup(void); +extern void utc_dali_active_constraint_cleanup(void); +extern void utc_dali_actor_startup(void); +extern void utc_dali_actor_cleanup(void); +extern void utc_dali_alpha_functions_startup(void); +extern void utc_dali_alpha_functions_cleanup(void); +extern void utc_dali_angle_axis_startup(void); +extern void utc_dali_angle_axis_cleanup(void); +extern void utc_dali_animatable_mesh_startup(void); +extern void utc_dali_animatable_mesh_cleanup(void); +extern void utc_dali_animation_startup(void); +extern void utc_dali_animation_cleanup(void); +extern void utc_dali_any_startup(void); +extern void utc_dali_any_cleanup(void); +extern void utc_base_handle_startup(void); +extern void utc_base_handle_cleanup(void); +extern void utc_dali_bitmap_image_startup(void); +extern void utc_dali_bitmap_image_cleanup(void); +extern void camera_actor_test_startup(void); +extern void camera_actor_test_cleanup(void); +extern void utc_dali_character_startup(void); +extern void utc_dali_character_cleanup(void); +extern void utc_dali_constraint_startup(void); +extern void utc_dali_constraint_cleanup(void); +extern void custom_actor_test_startup(void); +extern void custom_actor_test_cleanup(void); +extern void utc_dali_degree_startup(void); +extern void utc_dali_degree_cleanup(void); +extern void utc_dali_event_processing_startup(void); +extern void utc_dali_event_processing_cleanup(void); +extern void utc_dali_font_startup(void); +extern void utc_dali_font_cleanup(void); +extern void utc_dali_font_parameters_startup(void); +extern void utc_dali_font_parameters_cleanup(void); +extern void utc_dali_framebuffer_startup(void); +extern void utc_dali_framebuffer_cleanup(void); +extern void utc_dali_gesture_startup(void); +extern void utc_dali_gesture_cleanup(void); +extern void utc_dali_gesture_detector_startup(void); +extern void utc_dali_gesture_detector_cleanup(void); +extern void handle_test_startup(void); +extern void handle_test_cleanup(void); +extern void utc_dali_image_startup(void); +extern void utc_dali_image_cleanup(void); +extern void image_actor_test_startup(void); +extern void image_actor_test_cleanup(void); +extern void utc_dali_image_attributes_startup(void); +extern void utc_dali_image_attributes_cleanup(void); +extern void utc_dali_key_event_startup(void); +extern void utc_dali_key_event_cleanup(void); +extern void layer_test_startup(void); +extern void layer_test_cleanup(void); +extern void utc_dali_long_press_gesture_startup(void); +extern void utc_dali_long_press_gesture_cleanup(void); +extern void utc_dali_long_press_gesture_detector_startup(void); +extern void utc_dali_long_press_gesture_detector_cleanup(void); +extern void utc_dali_material_startup(void); +extern void utc_dali_material_cleanup(void); +extern void utc_dali_math_utils_startup(void); +extern void utc_dali_math_utils_cleanup(void); +extern void utc_dali_matrix_startup(void); +extern void utc_dali_matrix_cleanup(void); +extern void utc_dali_matrix3_startup(void); +extern void utc_dali_matrix3_cleanup(void); +extern void mesh_actor_test_startup(void); +extern void mesh_actor_test_cleanup(void); +extern void utc_dali_pan_gesture_startup(void); +extern void utc_dali_pan_gesture_cleanup(void); +extern void utc_dali_pan_gesture_detector_startup(void); +extern void utc_dali_pan_gesture_detector_cleanup(void); +extern void utc_dali_pinch_gesture_startup(void); +extern void utc_dali_pinch_gesture_cleanup(void); +extern void utc_dali_pinch_gesture_detector_startup(void); +extern void utc_dali_pinch_gesture_detector_cleanup(void); +extern void utc_dali_pixel_startup(void); +extern void utc_dali_pixel_cleanup(void); +extern void utc_dali_property_notification_startup(void); +extern void utc_dali_property_notification_cleanup(void); +extern void utc_dali_quaternion_startup(void); +extern void utc_dali_quaternion_cleanup(void); +extern void utc_dali_radian_startup(void); +extern void utc_dali_radian_cleanup(void); +extern void utc_dali_rect_startup(void); +extern void utc_dali_rect_cleanup(void); +extern void utc_dali_render_task_startup(void); +extern void utc_dali_render_task_cleanup(void); +extern void utc_dali_render_task_list_startup(void); +extern void utc_dali_render_task_list_cleanup(void); +extern void renderable_actor_startup(void); +extern void renderable_actor_cleanup(void); +extern void utc_dali_shader_effect_startup(void); +extern void utc_dali_shader_effect_cleanup(void); +extern void utc_dali_signal_templates_functors_startup(void); +extern void utc_dali_signal_templates_functors_cleanup(void); +extern void utc_dali_signal_templates_startup(void); +extern void utc_dali_signal_templates_cleanup(void); +extern void stage_test_startup(void); +extern void stage_test_cleanup(void); +extern void utc_dali_tap_gesture_startup(void); +extern void utc_dali_tap_gesture_cleanup(void); +extern void utc_dali_tap_gesture_detector_startup(void); +extern void utc_dali_tap_gesture_detector_cleanup(void); +extern void utc_dali_text_startup(void); +extern void utc_dali_text_cleanup(void); +extern void text_actor_test_startup(void); +extern void text_actor_test_cleanup(void); +extern void utc_dali_text_style_startup(void); +extern void utc_dali_text_style_cleanup(void); +extern void utc_dali_touch_event_combiner_startup(void); +extern void utc_dali_touch_event_combiner_cleanup(void); +extern void utc_dali_touch_processing_startup(void); +extern void utc_dali_touch_processing_cleanup(void); +extern void utc_dali_vector2_startup(void); +extern void utc_dali_vector2_cleanup(void); +extern void utc_dali_vector3_startup(void); +extern void utc_dali_vector3_cleanup(void); +extern void utc_dali_vector4_startup(void); +extern void utc_dali_vector4_cleanup(void); + +extern int UtcDaliConstraintGetTargetObject(void); +extern int UtcDaliConstraintGetTargetProperty(void); +extern int UtcDaliConstraintSetWeight(void); +extern int UtcDaliConstraintGetCurrentWeight(void); +extern int UtcDaliConstraintSignalApplied(void); +extern int UtcDaliConstraintRemove(void); +extern int UtcDaliConstraintCallback(void); +extern int UtcDaliConstraintProperties(void); +extern int UtcDaliActorNew(void); +extern int UtcDaliActorDownCast(void); +extern int UtcDaliActorDownCast2(void); +extern int UtcDaliActorGetName(void); +extern int UtcDaliActorSetName(void); +extern int UtcDaliActorGetId(void); +extern int UtcDaliActorIsRoot(void); +extern int UtcDaliActorOnStage(void); +extern int UtcDaliActorIsLayer(void); +extern int UtcDaliActorGetLayer(void); +extern int UtcDaliActorAdd(void); +extern int UtcDaliActorRemove01(void); +extern int UtcDaliActorRemove02(void); +extern int UtcDaliActorGetChildCount(void); +extern int UtcDaliActorGetChildren01(void); +extern int UtcDaliActorGetChildren02(void); +extern int UtcDaliActorGetParent01(void); +extern int UtcDaliActorGetParent02(void); +extern int UtcDaliActorSetParentOrigin(void); +extern int UtcDaliActorGetCurrentParentOrigin(void); +extern int UtcDaliActorSetAnchorPoint(void); +extern int UtcDaliActorGetCurrentAnchorPoint(void); +extern int UtcDaliActorSetSize01(void); +extern int UtcDaliActorSetSize02(void); +extern int UtcDaliActorSetSize03(void); +extern int UtcDaliActorSetSize04(void); +extern int UtcDaliActorGetCurrentSize(void); +extern int UtcDaliActorSetPosition01(void); +extern int UtcDaliActorSetPosition02(void); +extern int UtcDaliActorSetPosition03(void); +extern int UtcDaliActorSetX(void); +extern int UtcDaliActorSetY(void); +extern int UtcDaliActorSetZ(void); +extern int UtcDaliActorMoveBy(void); +extern int UtcDaliActorGetCurrentPosition(void); +extern int UtcDaliActorGetCurrentWorldPosition(void); +extern int UtcDaliActorInheritPosition(void); +extern int UtcDaliActorSetRotation01(void); +extern int UtcDaliActorSetRotation02(void); +extern int UtcDaliActorRotateBy01(void); +extern int UtcDaliActorRotateBy02(void); +extern int UtcDaliActorGetCurrentRotation(void); +extern int UtcDaliActorGetCurrentWorldRotation(void); +extern int UtcDaliActorSetScale01(void); +extern int UtcDaliActorSetScale02(void); +extern int UtcDaliActorSetScale03(void); +extern int UtcDaliActorScaleBy(void); +extern int UtcDaliActorGetCurrentScale(void); +extern int UtcDaliActorGetCurrentWorldScale(void); +extern int UtcDaliActorInheritScale(void); +extern int UtcDaliActorSetVisible(void); +extern int UtcDaliActorIsVisible(void); +extern int UtcDaliActorSetOpacity(void); +extern int UtcDaliActorGetCurrentOpacity(void); +extern int UtcDaliActorSetSensitive(void); +extern int UtcDaliActorIsSensitive(void); +extern int UtcDaliActorSetInheritShaderEffect(void); +extern int UtcDaliActorGetInheritShaderEffect(void); +extern int UtcDaliActorSetShaderEffect(void); +extern int UtcDaliActorGetShaderEffect(void); +extern int UtcDaliActorRemoveShaderEffect01(void); +extern int UtcDaliActorRemoveShaderEffect02(void); +extern int UtcDaliActorSetColor(void); +extern int UtcDaliActorGetCurrentColor(void); +extern int UtcDaliActorGetCurrentWorldColor(void); +extern int UtcDaliActorSetColorMode(void); +extern int UtcDaliActorScreenToLocal(void); +extern int UtcDaliActorSetLeaveRequired(void); +extern int UtcDaliActorGetLeaveRequired(void); +extern int UtcDaliActorSetKeyboardFocusable(void); +extern int UtcDaliActorIsKeyboardFocusable(void); +extern int UtcDaliActorApplyConstraint(void); +extern int UtcDaliActorApplyConstraintAppliedCallback(void); +extern int UtcDaliActorRemoveConstraints(void); +extern int UtcDaliActorRemoveConstraint(void); +extern int UtcDaliActorTouchedSignal(void); +extern int UtcDaliActorSetSizeSignal(void); +extern int UtcDaliActorOnOffStageSignal(void); +extern int UtcDaliActorFindChildByName(void); +extern int UtcDaliActorFindChildByAlias(void); +extern int UtcDaliActorFindChildById(void); +extern int UtcDaliActorHitTest(void); +extern int UtcDaliActorSetDrawMode(void); +extern int UtcDaliActorSetDrawModeOverlayRender(void); +extern int UtcDaliActorSetDrawModeOverlayHitTest(void); +extern int UtcDaliActorGetCurrentWorldMatrix(void); +extern int UtcDaliActorConstrainedToWorldMatrix(void); +extern int UtcDaliActorUnparent(void); +extern int UtcDaliActorGetChildAt(void); +extern int UtcDaliActorSetGetOverlay(void); +extern int UtcDaliActorDynamics(void); +extern int UtcDaliActorCreateDestroy(void); +extern int UtcDaliAlphaFunctionsDefault(void); +extern int UtcDaliAlphaFunctionsLinear(void); +extern int UtcDaliAlphaFunctionsReverse(void); +extern int UtcDaliAlphaFunctionsEaseIn(void); +extern int UtcDaliAlphaFunctionsEaseOut(void); +extern int UtcDaliAlphaFunctionsEaseInOut(void); +extern int UtcDaliAlphaFunctionsEaseInSine(void); +extern int UtcDaliAlphaFunctionsEaseOutSine(void); +extern int UtcDaliAlphaFunctionsEaseInOutSine(void); +extern int UtcDaliAlphaFunctionsBounce(void); +extern int UtcDaliAlphaFunctionsBounceBack(void); +extern int UtcDaliAlphaFunctionsEaseOutBack(void); +extern int UtcDaliAlphaFunctionsSin(void); +extern int UtcDaliAlphaFunctionsSin2x(void); +extern int UtcDaliAlphaFunctionsSquare(void); +extern int UtcDaliAlphaFunctionsEaseInSine33(void); +extern int UtcDaliAlphaFunctionsEaseOutSine33(void); +extern int UtcDaliAlphaFunctionsEaseInOutSineXX(void); +extern int UtcDaliAlphaFunctionsDoubleEaseInOutSine60(void); +extern int UtcDaliAlphaFunctionsEaseOutQuint50(void); +extern int UtcDaliAlphaFunctionsEaseOutQuint80(void); +extern int UtcDaliAlphaFunctionsEaseInBack(void); +extern int UtcDaliAlphaFunctionsEaseInOutBack(void); +extern int UtcDaliAngleAxisNew01(void); +extern int UtcDaliAngleAxisNew02(void); +extern int UtcDaliAngleAxisNew03(void); +extern int UtcDaliAngleAxisAssign(void); +extern int UtcDaliAngleAxisCopy(void); +extern int UtcDaliAnimatableMeshConstructor01(void); +extern int UtcDaliAnimatableMeshConstructor02(void); +extern int UtcDaliAnimatableMeshConstructor03(void); +extern int UtcDaliAnimatableMeshNew01(void); +extern int UtcDaliAnimatableMeshNew02(void); +extern int UtcDaliAnimatableMeshNew03(void); +extern int UtcDaliAnimatableMeshNew04(void); +extern int UtcDaliAnimatableMeshNew05(void); +extern int UtcDaliAnimatableMeshNew06(void); +extern int UtcDaliAnimatableMeshDownCast01(void); +extern int UtcDaliAnimatableMeshGetPropertyIndex01(void); +extern int UtcDaliAnimatableMeshGetPropertyIndex02(void); +extern int UtcDaliAnimatableMeshGetPropertyIndex03(void); +extern int UtcDaliAnimatableMeshGetPropertyIndex04(void); +extern int UtcDaliAnimatableMeshOperatorArray01(void); +extern int UtcDaliAnimatableMeshOperatorArray02(void); +extern int UtcDaliAnimatableMeshAnimateVertex01(void); +extern int UtcDaliAnimatableVertexSettersAndGetters(void); +extern int UtcDaliAnimatableMeshProperties(void); +extern int UtcDaliAnimatableMeshExceedVertices(void); +extern int UtcDaliAnimationNew01(void); +extern int UtcDaliAnimationNew02(void); +extern int UtcDaliAnimationDownCast(void); +extern int UtcDaliAnimationSetDuration(void); +extern int UtcDaliAnimationGetDuration(void); +extern int UtcDaliAnimationSetLooping(void); +extern int UtcDaliAnimationIsLooping(void); +extern int UtcDaliAnimationSetEndAction(void); +extern int UtcDaliAnimationGetEndAction(void); +extern int UtcDaliAnimationGetDestroyAction(void); +extern int UtcDaliAnimationSetDefaultAlphaFunction(void); +extern int UtcDaliAnimationGetDefaultAlphaFunction(void); +extern int UtcDaliAnimationPlay(void); +extern int UtcDaliAnimationPlayOffStage(void); +extern int UtcDaliAnimationPlayDiscardHandle(void); +extern int UtcDaliAnimationPlayStopDiscardHandle(void); +extern int UtcDaliAnimationPause(void); +extern int UtcDaliAnimationStop(void); +extern int UtcDaliAnimationStopSetPosition(void); +extern int UtcDaliAnimationClear(void); +extern int UtcDaliAnimationSignalFinish(void); +extern int UtcDaliAnimationAnimateByBoolean(void); +extern int UtcDaliAnimationAnimateByBooleanAlphaFunction(void); +extern int UtcDaliAnimationAnimateByBooleanTimePeriod(void); +extern int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriod(void); +extern int UtcDaliAnimationAnimateByFloat(void); +extern int UtcDaliAnimationAnimateByFloatAlphaFunction(void); +extern int UtcDaliAnimationAnimateByFloatTimePeriod(void); +extern int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriod(void); +extern int UtcDaliAnimationAnimateByVector2(void); +extern int UtcDaliAnimationAnimateByVector2AlphaFunction(void); +extern int UtcDaliAnimationAnimateByVector2TimePeriod(void); +extern int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriod(void); +extern int UtcDaliAnimationAnimateByVector3(void); +extern int UtcDaliAnimationAnimateByVector3AlphaFunction(void); +extern int UtcDaliAnimationAnimateByVector3TimePeriod(void); +extern int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriod(void); +extern int UtcDaliAnimationAnimateByVector4(void); +extern int UtcDaliAnimationAnimateByVector4AlphaFunction(void); +extern int UtcDaliAnimationAnimateByVector4TimePeriod(void); +extern int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriod(void); +extern int UtcDaliAnimationAnimateByActorPosition(void); +extern int UtcDaliAnimationAnimateByActorPositionAlphaFunction(void); +extern int UtcDaliAnimationAnimateByActorPositionTimePeriod(void); +extern int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriod(void); +extern int UtcDaliAnimationAnimateToBoolean(void); +extern int UtcDaliAnimationAnimateToBooleanAlphaFunction(void); +extern int UtcDaliAnimationAnimateToBooleanTimePeriod(void); +extern int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriod(void); +extern int UtcDaliAnimationAnimateToFloat(void); +extern int UtcDaliAnimationAnimateToFloatAlphaFunction(void); +extern int UtcDaliAnimationAnimateToFloatTimePeriod(void); +extern int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriod(void); +extern int UtcDaliAnimationAnimateToVector2(void); +extern int UtcDaliAnimationAnimateToVector2AlphaFunction(void); +extern int UtcDaliAnimationAnimateToVector2TimePeriod(void); +extern int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriod(void); +extern int UtcDaliAnimationAnimateToVector3(void); +extern int UtcDaliAnimationAnimateToVector3AlphaFunction(void); +extern int UtcDaliAnimationAnimateToVector3TimePeriod(void); +extern int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriod(void); +extern int UtcDaliAnimationAnimateToVector3Component(void); +extern int UtcDaliAnimationAnimateToVector4(void); +extern int UtcDaliAnimationAnimateToVector4AlphaFunction(void); +extern int UtcDaliAnimationAnimateToVector4TimePeriod(void); +extern int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriod(void); +extern int UtcDaliAnimationAnimateToActorParentOrigin(void); +extern int UtcDaliAnimationAnimateToActorParentOriginX(void); +extern int UtcDaliAnimationAnimateToActorParentOriginY(void); +extern int UtcDaliAnimationAnimateToActorParentOriginZ(void); +extern int UtcDaliAnimationAnimateToActorAnchorPoint(void); +extern int UtcDaliAnimationAnimateToActorAnchorPointX(void); +extern int UtcDaliAnimationAnimateToActorAnchorPointY(void); +extern int UtcDaliAnimationAnimateToActorAnchorPointZ(void); +extern int UtcDaliAnimationAnimateToActorSize(void); +extern int UtcDaliAnimationAnimateToActorSizeWidth(void); +extern int UtcDaliAnimationAnimateToActorSizeHeight(void); +extern int UtcDaliAnimationAnimateToActorSizeDepth(void); +extern int UtcDaliAnimationAnimateToActorPosition(void); +extern int UtcDaliAnimationAnimateToActorPositionX(void); +extern int UtcDaliAnimationAnimateToActorPositionY(void); +extern int UtcDaliAnimationAnimateToActorPositionZ(void); +extern int UtcDaliAnimationAnimateToActorPositionAlphaFunction(void); +extern int UtcDaliAnimationAnimateToActorPositionTimePeriod(void); +extern int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriod(void); +extern int UtcDaliAnimationAnimateToActorRotationAngleAxis(void); +extern int UtcDaliAnimationAnimateToActorRotationQuaternion(void); +extern int UtcDaliAnimationAnimateToActorRotationAlphaFunction(void); +extern int UtcDaliAnimationAnimateToActorRotationTimePeriod(void); +extern int UtcDaliAnimationAnimateToActorRotationAlphaFunctionTimePeriod(void); +extern int UtcDaliAnimationAnimateToActorScale(void); +extern int UtcDaliAnimationAnimateToActorScaleX(void); +extern int UtcDaliAnimationAnimateToActorScaleY(void); +extern int UtcDaliAnimationAnimateToActorScaleZ(void); +extern int UtcDaliAnimationAnimateToActorColor(void); +extern int UtcDaliAnimationAnimateToActorColorRed(void); +extern int UtcDaliAnimationAnimateToActorColorGreen(void); +extern int UtcDaliAnimationAnimateToActorColorBlue(void); +extern int UtcDaliAnimationAnimateToActorColorAlpha(void); +extern int UtcDaliAnimationKeyFrames01(void); +extern int UtcDaliAnimationKeyFrames02(void); +extern int UtcDaliAnimationKeyFrames03(void); +extern int UtcDaliAnimationKeyFrames04(void); +extern int UtcDaliAnimationKeyFrames05(void); +extern int UtcDaliAnimationKeyFrames06(void); +extern int UtcDaliAnimationAnimateBetweenActorColorAlpha(void); +extern int UtcDaliAnimationAnimateBetweenActorColor(void); +extern int UtcDaliAnimationAnimateBetweenActorVisible01(void); +extern int UtcDaliAnimationAnimateBetweenActorRotation02(void); +extern int UtcDaliAnimationMoveByFloat3(void); +extern int UtcDaliAnimationMoveByVector3Alpha(void); +extern int UtcDaliAnimationMoveByVector3AlphaFloat2(void); +extern int UtcDaliAnimationMoveToFloat3(void); +extern int UtcDaliAnimationMoveToVector3Alpha(void); +extern int UtcDaliAnimationMoveToVector3AlphaFloat2(void); +extern int UtcDaliAnimationMove(void); +extern int UtcDaliAnimationRotateByDegreeVector3(void); +extern int UtcDaliAnimationRotateByRadianVector3(void); +extern int UtcDaliAnimationRotateByDegreeVector3Alpha(void); +extern int UtcDaliAnimationRotateByRadianVector3Alpha(void); +extern int UtcDaliAnimationRotateByDegreeVector3AlphaFloat2(void); +extern int UtcDaliAnimationRotateByRadianVector3AlphaFloat2(void); +extern int UtcDaliAnimationRotateToDegreeVector3(void); +extern int UtcDaliAnimationRotateToRadianVector3(void); +extern int UtcDaliAnimationRotateToQuaternion(void); +extern int UtcDaliAnimationRotateToDegreeVector3Alpha(void); +extern int UtcDaliAnimationRotateToRadianVector3Alpha(void); +extern int UtcDaliAnimationRotateToQuaternionAlpha(void); +extern int UtcDaliAnimationRotateToDegreeVector3AlphaFloat2(void); +extern int UtcDaliAnimationRotateToRadianVector3AlphaFloat2(void); +extern int UtcDaliAnimationRotateToQuaternionAlphaFloat2(void); +extern int UtcDaliAnimationRotate(void); +extern int UtcDaliAnimationScaleBy(void); +extern int UtcDaliAnimationScaleTo(void); +extern int UtcDaliAnimationShow(void); +extern int UtcDaliAnimationHide(void); +extern int UtcDaliAnimationShowHideAtEnd(void); +extern int UtcDaliAnimationOpacityBy(void); +extern int UtcDaliAnimationOpacityTo(void); +extern int UtcDaliAnimationColorBy(void); +extern int UtcDaliAnimationColorTo(void); +extern int UtcDaliAnimationResize(void); +extern int UtcDaliAnimationAnimateBool(void); +extern int UtcDaliAnimationAnimateFloat(void); +extern int UtcDaliAnimationAnimateVector2(void); +extern int UtcDaliAnimationAnimateVector3(void); +extern int UtcDaliAnimationAnimateVector4(void); +extern int UtcDaliAnimationAnimateQuaternion(void); +extern int UtcDaliKeyFramesCreateDestroy(void); +extern int UtcDaliKeyFramesDownCast(void); +extern int UtcDaliAnimationResizeByXY(void); +extern int UtcDaliAnimationAnimateBetweenActorColorTimePeriod(void); +extern int UtcDaliAnimationAnimateBetweenActorColorFunction(void); +extern int UtcDaliAnimationAnimateBetweenActorColorFunctionTimePeriod(void); +extern int UtcDaliAnimationAnimateVector3Func(void); +extern int UtcDaliAnimationCreateDestroy(void); +extern int UtcDaliAnyConstructors(void); +extern int UtcDaliAnyAssignmentOperators(void); +extern int UtcDaliAnyNegativeAssignmentOperators(void); +extern int UtcDaliAnyGetType(void); +extern int UtcDaliAnyGet(void); +extern int UtcDaliAnyNegativeGet(void); +extern int UtcDaliBaseHandleConstructorVoid(void); +extern int UtcDaliBaseHandleCopyConstructor(void); +extern int UtcDaliBaseHandleAssignmentOperator(void); +extern int UtcDaliBaseHandleGetBaseObject(void); +extern int UtcDaliBaseHandleReset(void); +extern int UtcDaliBaseHandleEqualityOperator01(void); +extern int UtcDaliBaseHandleEqualityOperator02(void); +extern int UtcDaliBaseHandleInequalityOperator01(void); +extern int UtcDaliBaseHandleInequalityOperator02(void); +extern int UtcDaliBaseHandleStlVector(void); +extern int UtcDaliBaseHandleDoAction(void); +extern int UtcDaliBaseHandleConnectSignal(void); +extern int UtcDaliBaseHandleGetTypeName(void); +extern int UtcDaliBaseHandleGetObjectPtr(void); +extern int UtcDaliBaseHandleBooleanCast(void); +extern int UtcDaliBitmapImageNew01(void); +extern int UtcDaliBitmapImageNew02(void); +extern int UtcDaliBitmapImageNewWithPolicy01(void); +extern int UtcDaliBitmapImageNewWithPolicy02(void); +extern int UtcDaliBitmapImageDownCast(void); +extern int UtcDaliBitmapImageDownCast2(void); +extern int UtcDaliBitmapImageWHITE(void); +extern int UtcDaliBitmapImageGetBuffer(void); +extern int UtcDaliBitmapImageGetBufferSize(void); +extern int UtcDaliBitmapImageGetBufferStride(void); +extern int UtcDaliBitmapImageIsDataExternal(void); +extern int UtcDaliBitmapImageUpdate01(void); +extern int UtcDaliBitmapImageUpdate02(void); +extern int UtcDaliBitmapImageUploadedSignal01(void); +extern int UtcDaliBitmapImageUploadedSignal02(void); +extern int UtcDaliCameraActorConstructorVoid(void); +extern int UtcDaliCameraActorNew(void); +extern int UtcDaliCameraActorDownCast(void); +extern int UtcDaliCameraActorDownCast2(void); +extern int UtcDaliCameraActorSetCameraOffStage(void); +extern int UtcDaliCameraActorSetCameraOnStage(void); +extern int UtcDaliCameraActorGetCamera(void); +extern int UtcDaliCameraActorDefaultProperties(void); +extern int UtcDaliCameraActorSetTarget(void); +extern int UtcDaliCameraActorSetType01(void); +extern int UtcDaliCameraActorSetType02(void); +extern int UtcDaliCameraActorSetFieldOfView(void); +extern int UtcDaliCameraActorSetAspectRatio(void); +extern int UtcDaliCameraActorSetNearClippingPlane(void); +extern int UtcDaliCameraActorSetFarClippingPlane(void); +extern int UtcDaliCameraActorSetTargetPosition(void); +extern int UtcDaliCameraActorSetInvertYAxis(void); +extern int UtcDaliCameraActorModelView(void); +extern int UtcDaliCameraActorSetPerspectiveProjection(void); +extern int UtcDaliCameraActorSetOrthographicProjection01(void); +extern int UtcDaliCameraActorSetOrthographicProjection02(void); +extern int UtcDaliCameraActorSetOrthographicProjection03(void); +extern int UtcDaliCameraActorReadProjectionMatrix(void); +extern int UtcDaliCameraActorAnimatedProperties(void); +extern int UtcDaliCameraActorPropertyIndices(void); +extern int UtcDaliCameraActorCheckLookAtAndFreeLookViews01(void); +extern int UtcDaliCameraActorCheckLookAtAndFreeLookViews02(void); +extern int UtcDaliCameraActorCheckLookAtAndFreeLookViews03(void); +extern int UtcDaliCharacterCopyConstructor(void); +extern int UtcDaliCharacterComparissonOperators(void); +extern int UtcDaliCharacterAssignmentOperator(void); +extern int UtcDaliCharacterIsLeftToRight(void); +extern int UtcDaliGetCharacterDirection(void); +extern int UtcDaliCharacterIsWhiteSpace(void); +extern int UtcDaliCharacterIsNewLine(void); +extern int UtcDaliConstraintNewBoolean(void); +extern int UtcDaliConstraintNewFloat(void); +extern int UtcDaliConstraintNewVector2(void); +extern int UtcDaliConstraintNewVector3(void); +extern int UtcDaliConstraintNewVector4(void); +extern int UtcDaliConstraintNewMatrix(void); +extern int UtcDaliConstraintNewMatrix3(void); +extern int UtcDaliConstraintNewQuaternion(void); +extern int UtcDaliConstraintNewOffStageBoolean(void); +extern int UtcDaliConstraintNewOffStageFloat(void); +extern int UtcDaliConstraintNewOffStageVector2(void); +extern int UtcDaliConstraintNewOffStageVector3(void); +extern int UtcDaliConstraintNewOffStageVector4(void); +extern int UtcDaliConstraintNewOffStageQuaternion(void); +extern int UtcDaliConstraintNewLocalInput(void); +extern int UtcDaliConstraintNewParentInput(void); +extern int UtcDaliConstraintNewInput1(void); +extern int UtcDaliConstraintNewInput2(void); +extern int UtcDaliConstraintNewInput3(void); +extern int UtcDaliConstraintNewInput4(void); +extern int UtcDaliConstraintNewInput5(void); +extern int UtcDaliConstraintNewInput6(void); +extern int UtcDaliConstraintDownCast(void); +extern int UtcDaliConstraintSetApplyTime(void); +extern int UtcDaliConstraintGetApplyTime(void); +extern int UtcDaliConstraintSetRemoveTime(void); +extern int UtcDaliConstraintGetRemoveTime(void); +extern int UtcDaliConstraintSetAlphaFunction(void); +extern int UtcDaliConstraintGetAlphaFunction(void); +extern int UtcDaliConstraintSetRemoveAction(void); +extern int UtcDaliConstraintGetRemoveAction(void); +extern int UtcDaliConstraintRemoveDuringApply(void); +extern int UtcDaliConstraintImmediateRemoveDuringApply(void); +extern int UtcDaliConstraintActorSize(void); +extern int UtcDaliConstraintActorSizeWidth(void); +extern int UtcDaliConstraintActorSizeHeight(void); +extern int UtcDaliConstraintActorSizeDepth(void); +extern int UtcDaliConstraintInputWorldPosition(void); +extern int UtcDaliConstraintInputWorldRotation(void); +extern int UtcDaliConstraintInputWorldScale(void); +extern int UtcDaliConstraintInputWorldColor(void); +extern int UtcDaliConstraintInvalidInputProperty(void); +extern int UtcDaliBuiltinConstraintParentSize(void); +extern int UtcDaliBuiltinConstraintParentSizeRelative(void); +extern int UtcDaliBuiltinConstraintScaleToFitConstraint(void); +extern int UtcDaliBuiltinConstraintScaleToFitKeepAspectRatio(void); +extern int UtcDaliBuiltinConstraintScaleToFillKeepAspectRatio(void); +extern int UtcDaliBuiltinConstraintScaleToFillXYKeepAspectRatio(void); +extern int UtcDaliBuiltinConstraintShrinkInsideKeepAspectRatioConstraint(void); +extern int UtcDaliBuiltinConstraintMultiplyConstraint(void); +extern int UtcDaliBuiltinConstraintDivideConstraint(void); +extern int UtcDaliBuiltinConstraintEqualToConstraint(void); +extern int UtcDaliBuiltinConstraintRelativeToConstraint(void); +extern int UtcDaliBuiltinConstraintInverseOfConstraint(void); +extern int UtcDaliBuiltinConstraintFunctions(void); +extern int UtcDaliCustomActorDestructor(void); +extern int UtcDaliCustomActorImplDestructor(void); +extern int UtcDaliCustomActorDownCast(void); +extern int UtcDaliCustomActorDownCastNegative(void); +extern int UtcDaliCustomActorOnStageConnectionDisconnection(void); +extern int UtcDaliCustomActorOnStageConnectionOrder(void); +extern int UtcDaliCustomActorOnStageDisconnectionOrder(void); +extern int UtcDaliCustomActorAddDuringOnStageConnection(void); +extern int UtcDaliCustomActorRemoveDuringOnStageConnection(void); +extern int UtcDaliCustomActorAddDuringOnStageDisconnection(void); +extern int UtcDaliCustomActorRemoveDuringOnStageDisconnection(void); +extern int UtcDaliCustomActorRemoveParentDuringOnStageConnection(void); +extern int UtcDaliCustomActorAddParentDuringOnStageDisconnection(void); +extern int UtcDaliCustomActorOnChildAddRemove(void); +extern int UtcDaliCustomActorReparentDuringOnChildAdd(void); +extern int UtcDaliCustomActorRemoveDuringOnChildRemove(void); +extern int UtcDaliCustomActorOnPropertySet(void); +extern int UtcDaliCustomActorOnSizeSet(void); +extern int UtcDaliCustomActorOnSizeAnimation(void); +extern int UtcDaliCustomActorOnTouchEvent(void); +extern int UtcDaliCustomActorOnMouseWheelEvent(void); +extern int UtcDaliCustomActorFindChildByAlias(void); +extern int UtcDaliCustomActorImplOnPropertySet(void); +extern int UtcDaliCustomActorGetImplementation(void); +extern int UtcDaliDegreeConstructors01(void); +extern int UtcDaliDegreeComparison01(void); +extern int UtcDaliDegreeCastOperators01(void); +extern int UtcDaliDegreeCastOperatorEquals(void); +extern int UtcDaliDegreeCastOperatorNotEquals(void); +extern int UtcDaliDegreeCastOperatorLessThan(void); +extern int UtcDaliInvalidEvent(void); +extern int UtcDaliInvalidGesture(void); +extern int UtcDaliFontNew01(void); +extern int UtcDaliFontNew02(void); +extern int UtcDaliFontNew03(void); +extern int UtcDaliFontNew04(void); +extern int UtcDaliFontNew05(void); +extern int UtcDaliFontNew06(void); +extern int UtcDaliFontDownCast(void); +extern int UtcDaliFontGetPixelSize(void); +extern int UtcDaliFontGetPointSize(void); +extern int UtcDaliFontPointsToPixels(void); +extern int UtcFontMeasureTextWidth(void); +extern int UtcFontMeasureTextHeight(void); +extern int UtcFontMeasureText(void); +extern int UtcFontGetFamilyForText(void); +extern int UtcFontGetFontLineHeightFromCapsHeight(void); +extern int UtcFontAllGlyphsSupported(void); +extern int UtcFontGetMetrics(void); +extern int UtcFontIsDefault(void); +extern int UtcFontGetInstalledFonts(void); +extern int UtcFontMetricsDefaultConstructor(void); +extern int UtcFontMetricsCopyConstructor(void); +extern int UtcFontMetricsAssignmentOperator(void); +extern int UtcDaliFontParamsDefaultConstructor(void); +extern int UtcDaliFontParamsPointSizeConstructor(void); +extern int UtcDaliFontParamsPixelSizeConstructor(void); +extern int UtcDaliFontParamsCopyConstructor(void); +extern int UtcDaliFontParamsAssignmentOperator(void); +extern int UtcDaliFontParamsPointSizeEqualityOperator(void); +extern int UtcDaliFrameBufferImageNew01(void); +extern int UtcDaliFrameBufferImageDownCast(void); +extern int UtcDaliGestureConstructor(void); +extern int UtcDaliGestureAssignment(void); +extern int UtcDaliGestureDetectorConstructorNegative(void); +extern int UtcDaliGestureDetectorConstructorPositive(void); +extern int UtcDaliGestureDetectorDownCast(void); +extern int UtcDaliGestureDetectorAttachPositive(void); +extern int UtcDaliGestureDetectorAttachNegative(void); +extern int UtcDaliGestureDetectorDetachPositive(void); +extern int UtcDaliGestureDetectorDetachNegative01(void); +extern int UtcDaliGestureDetectorDetachNegative02(void); +extern int UtcDaliGestureDetectorDetachNegative03(void); +extern int UtcDaliGestureDetectorDetachAll(void); +extern int UtcDaliGestureDetectorDetachAllNegative(void); +extern int UtcDaliGestureDetectorGetAttachedActors(void); +extern int UtcDaliHandleConstructorVoid(void); +extern int UtcDaliHandleCopyConstructor(void); +extern int UtcDaliHandleAssignmentOperator(void); +extern int UtcDaliHandleSupports(void); +extern int UtcDaliHandleGetPropertyCount(void); +extern int UtcDaliHandleGetPropertyName(void); +extern int UtcDaliHandleGetPropertyIndex(void); +extern int UtcDaliHandleIsPropertyWritable(void); +extern int UtcDaliHandleIsPropertyAnimatable(void); +extern int UtcDaliHandleGetPropertyType(void); +extern int UtcDaliHandleNonAnimtableProperties(void); +extern int UtcDaliHandleNonAnimtableCompositeProperties(void); +extern int UtcDaliHandleSetProperty01(void); +extern int UtcDaliHandleSetProperty02(void); +extern int UtcDaliHandleRegisterProperty(void); +extern int UtcDaliHandleGetProperty(void); +extern int UtcDaliHandleDownCast(void); +extern int UtcDaliHandleCreateProperty(void); +extern int UtcDaliHandleGetPropertyGet(void); +extern int UtcDaliHandleGetPropertyIndices(void); +extern int UtcDaliImageNew01(void); +extern int UtcDaliImageNew02(void); +extern int UtcDaliImageNew03(void); +extern int UtcDaliImageNewWithPolicies01(void); +extern int UtcDaliImageNewWithPolicies02(void); +extern int UtcDaliImageNewWithPolicies03(void); +extern int UtcDaliImageNewWithPolicies04(void); +extern int UtcDaliImageNewDistanceField(void); +extern int UtcDaliImageNewDistanceFieldWithPolicies01(void); +extern int UtcDaliImageNewDistanceFieldWithPolicies02(void); +extern int UtcDaliImageNewDistanceFieldWithPolicies03(void); +extern int UtcDaliImageNewDistanceFieldWithPolicies04(void); +extern int UtcDaliImageNewDistanceFieldWithAttributes(void); +extern int UtcDaliImageNewDistanceFieldWithAttrandPol(void); +extern int UtcDaliImageDownCast(void); +extern int UtcDaliImageGetImageSize(void); +extern int UtcDaliImageGetFilename(void); +extern int UtcDaliImageGetLoadingState01(void); +extern int UtcDaliImageGetLoadingState02(void); +extern int UtcDaliImageGetReleasePolicy(void); +extern int UtcDaliImageGetLoadPolicy(void); +extern int UtcDaliImageSignalLoadingFinished(void); +extern int UtcDaliImageSignalUploaded(void); +extern int UtcDaliImageDiscard01(void); +extern int UtcDaliImageDiscard02(void); +extern int UtcDaliImageDiscard03(void); +extern int UtcDaliImageActorConstructorVoid(void); +extern int UtcDaliImageActorDestructor(void); +extern int UtcDaliImageActorNew01(void); +extern int UtcDaliImageActorNew02(void); +extern int UtcDaliImageActorDownCast(void); +extern int UtcDaliImageActorDownCast2(void); +extern int UtcDaliImageActor9Patch(void); +extern int UtcDaliImageActorPixelArea(void); +extern int UtcDaliImageActorGetCurrentImageSize01(void); +extern int UtcDaliImageActorGetCurrentImageSize02(void); +extern int UtcDaliImageActorGetCurrentImageSize03(void); +extern int UtcDaliImageActorGetCurrentImageSize04(void); +extern int UtcDaliImageActorGetCurrentImageSize05(void); +extern int UtcDaliImageActorNaturalPixelAreaSize01(void); +extern int UtcDaliImageActorNaturalPixelAreaSize02(void); +extern int UtcDaliImageActorDefaultProperties(void); +extern int UtcDaliImageActorUseImageAlpha01(void); +extern int UtcDaliImageActorUseImageAlpha02(void); +extern int UtcDaliImageActorUseImageAlpha03(void); +extern int UtcDaliImageActorUseImageAlpha04(void); +extern int UtcDaliImageActorUseImageAlpha05(void); +extern int UtcDaliImageActorClearPixelArea(void); +extern int UtcDaliImageGetStyle(void); +extern int UtcDaliImageSetNinePatchBorder(void); +extern int UtcDaliImageSetFadeIn(void); +extern int UtcDaliImageSetFadeInDuration(void); +extern int UtcDaliImageActorNewNull(void); +extern int UtcDaliImageActorNewNullWithArea(void); +extern int UtcDaliImageActorSetImage(void); +extern int UtcDaliImageActorPropertyIndices(void); +extern int UtcDaliImageAttributesConstructor(void); +extern int UtcDaliImageAttributesLessThan(void); +extern int UtcDaliImageAttributesEquality(void); +extern int UtcDaliImageAttributesInEquality(void); +extern int UtcDaliKeyEventConstructor(void); +extern int UtcDaliKeyEventIsShiftModifier(void); +extern int UtcDaliKeyEventIsCtrlModifier(void); +extern int UtcDaliKeyEventIsAltModifier(void); +extern int UtcDaliKeyEventIsNotShiftModifier(void); +extern int UtcDaliKeyEventIsNotCtrlModifier(void); +extern int UtcDaliKeyEventIsNotAltModifier(void); +extern int UtcDaliKeyEventANDModifer(void); +extern int UtcDaliKeyEventORModifer(void); +extern int UtcDaliKeyEventState(void); +extern int UtcDaliIntegrationKeyEvent(void); +extern int UtcDaliLayerNew(void); +extern int UtcDaliLayerDownCast(void); +extern int UtcDaliLayerDownCast2(void); +extern int UtcDaliLayerGetDepth(void); +extern int UtcDaliLayerRaise(void); +extern int UtcDaliLayerLower(void); +extern int UtcDaliLayerRaiseToTop(void); +extern int UtcDaliLayerLowerToBottom(void); +extern int UtcDaliLayerSetClipping(void); +extern int UtcDaliLayerIsClipping(void); +extern int UtcDaliLayerSetClippingBox(void); +extern int UtcDaliLayerGetClippingBox(void); +extern int UtcDaliLayerSetSortFunction(void); +extern int UtcDaliLayerRaiseAbove(void); +extern int UtcDaliLayerRaiseBelow(void); +extern int UtcDaliLayerMoveAbove(void); +extern int UtcDaliLayerMoveBelow(void); +extern int UtcDaliLayerDefaultProperties(void); +extern int UtcDaliLayerSetDepthTestDisabled(void); +extern int UtcDaliLayerCreateDestroy(void); +extern int UtcDaliLayerPropertyIndices(void); +extern int UtcDaliLongPressGestureConstructor(void); +extern int UtcDaliLongPressGestureAssignment(void); +extern int UtcDaliLongPressGestureDetectorConstructor(void); +extern int UtcDaliLongPressGestureDetectorNew(void); +extern int UtcDaliLongPressGestureDetectorDownCast(void); +extern int UtcDaliLongPressGestureSetTouchesRequired01(void); +extern int UtcDaliLongPressGestureSetTouchesRequired02(void); +extern int UtcDaliLongPressGestureGetMinimumTouchesRequired(void); +extern int UtcDaliLongPressGestureGetMaximumTouchesRequired(void); +extern int UtcDaliLongPressGestureSignalReceptionNegative(void); +extern int UtcDaliLongPressGestureSignalReceptionPositive(void); +extern int UtcDaliLongPressGestureSignalReceptionDetach(void); +extern int UtcDaliLongPressGestureSignalReceptionActorDestroyedDuringLongPress(void); +extern int UtcDaliLongPressGestureSignalReceptionRotatedActor(void); +extern int UtcDaliLongPressGestureSignalReceptionChildHit(void); +extern int UtcDaliLongPressGestureSignalReceptionAttachDetachMany(void); +extern int UtcDaliLongPressGestureSignalReceptionActorBecomesUntouchable(void); +extern int UtcDaliLongPressGestureSignalReceptionMultipleGestureDetectors(void); +extern int UtcDaliLongPressGestureSignalReceptionMultipleDetectorsOnActor(void); +extern int UtcDaliLongPressGestureSignalReceptionDifferentPossible(void); +extern int UtcDaliLongPressGestureEmitIncorrecteStateClear(void); +extern int UtcDaliLongPressGestureEmitIncorrectStateContinuing(void); +extern int UtcDaliLongPressGestureRepeatedState(void); +extern int UtcDaliLongPressGesturePossibleCancelled(void); +extern int UtcDaliLongPressGestureDetachAfterStarted(void); +extern int UtcDaliLongPressGestureActorUnstaged(void); +extern int UtcDaliLongPressGestureActorStagedAndDestroyed(void); +extern int UtcDaliLongPressGestureSystemOverlay(void); +extern int UtcDaliMaterialNew01(void); +extern int UtcDaliMaterialDownCast(void); +extern int UtcDaliMaterialSettersAndGetters(void); +extern int UtcDaliMaterialStage01(void); +extern int UtcDaliMaterialStage01MemCheck(void); +extern int UtcDaliMaterialStage02(void); +extern int UtcDaliMathUtilsNextPowerOfTwo(void); +extern int UtcDaliMathUtilsIsPowerOfTwo(void); +extern int UtcDaliMathUtilsGetRangedEpsilon(void); +extern int UtcDaliMathUtilsRound(void); +extern int UtcDaliMathUtilsClamp(void); +extern int UtcDaliMathUtilsWrapInDomain(void); +extern int UtcDaliMathUtilsShortestDistanceInDomain(void); +extern int UtcDaliMathUtilsEquals(void); +extern int UtcDaliMatrixCtor(void); +extern int UtcDaliMatrixOrthoNormalize0(void); +extern int UtcDaliMatrixOrthoNormalize1(void); +extern int UtcDaliMatrixInvert01(void); +extern int UtcDaliMatrixInvert02(void); +extern int UtcDaliMatrixInvertTransform01(void); +extern int UtcDaliMatrixInvertTransform02(void); +extern int UtcDaliMatrixGetXAxis(void); +extern int UtcDaliMatrixGetYAxis(void); +extern int UtcDaliMatrixGetZAxis(void); +extern int UtcDaliMatrixGetTranslation(void); +extern int UtcDaliMatrixGetTranslation3(void); +extern int UtcDaliMatrixSetIdentity(void); +extern int UtcDaliMatrixSetIdentityAndScale(void); +extern int UtcDaliMatrixSetXAxis(void); +extern int UtcDaliMatrixSetYAxis(void); +extern int UtcDaliMatrixSetZAxis(void); +extern int UtcDaliMatrixSetTranslation(void); +extern int UtcDaliMatrixSetTranslation3(void); +extern int UtcDaliMatrixTranspose(void); +extern int UtcDaliMatrixOStreamOperator(void); +extern int UtcDaliMatrixMultiply(void); +extern int UtcDaliMatrixOperatorMultiply(void); +extern int UtcDaliMatrixOperatorMultiply02(void); +extern int UtcDaliMatrixOperatorEquals(void); +extern int UtcDaliMatrixOperatorNotEquals(void); +extern int UtcDaliMatrixGetTransformComponents01(void); +extern int UtcDaliMatrixGetTransformComponents02(void); +extern int UtcDaliMatrixSetTransformComponents01(void); +extern int UtcDaliMatrixSetInverseTransformComponent01(void); +extern int UtcDaliMatrixSetInverseTransformComponent02(void); +extern int UtcDaliMatrix3FromMatrix(void); +extern int UtcDaliMatrix3OperatorAssign01(void); +extern int UtcDaliMatrix3OperatorAssign02(void); +extern int UtcDaliMatrix3AsFloat(void); +extern int UtcDaliMatrix3Invert(void); +extern int UtcDaliMatrix3Transpose(void); +extern int UtcDaliMatrix3SetIdentity(void); +extern int UtcDaliMatrix3Scale(void); +extern int UtcDaliMatrix3Magnitude(void); +extern int UtcDaliMatrix3ScaleInverseTranspose(void); +extern int UtcDaliMatrix3OStreamOperator(void); +extern int UtcDaliMatrix3Multiply(void); +extern int UtcDaliMatrix3EqualityOperator(void); +extern int UtcDaliMatrix3InequalityOperator(void); +extern int UtcDaliMeshActorConstructorVoid(void); +extern int UtcDaliMeshActorNew01(void); +extern int UtcDaliMeshActorIndices(void); +extern int UtcDaliPanGestureConstructor(void); +extern int UtcDaliPanGestureAssignment(void); +extern int UtcDaliPanGestureGetSpeed(void); +extern int UtcDaliPanGestureGetDistance(void); +extern int UtcDaliPanGestureGetScreenSpeed(void); +extern int UtcDaliPanGestureGetScreenDistance(void); +extern int UtcDaliPanGestureDetectorConstructor(void); +extern int UtcDaliPanGestureDetectorNew(void); +extern int UtcDaliPanGestureDetectorDownCast(void); +extern int UtcDaliPanGestureSetMinimumTouchesRequired(void); +extern int UtcDaliPanGestureSetMaximumTouchesRequired(void); +extern int UtcDaliPanGestureGetMinimumTouchesRequired(void); +extern int UtcDaliPanGestureGetMaximumTouchesRequired(void); +extern int UtcDaliPanGestureSignalReceptionNegative(void); +extern int UtcDaliPanGestureSignalReceptionDownMotionLeave(void); +extern int UtcDaliPanGestureSignalReceptionDownMotionUp(void); +extern int UtcDaliPanGestureSignalReceptionCancelled(void); +extern int UtcDaliPanGestureSignalReceptionDetach(void); +extern int UtcDaliPanGestureSignalReceptionDetachWhilePanning(void); +extern int UtcDaliPanGestureSignalReceptionActorDestroyedWhilePanning(void); +extern int UtcDaliPanGestureSignalReceptionRotatedActor(void); +extern int UtcDaliPanGestureSignalReceptionChildHit(void); +extern int UtcDaliPanGestureSignalReceptionAttachDetachMany(void); +extern int UtcDaliPanGestureSignalReceptionActorBecomesUntouchable(void); +extern int UtcDaliPanGestureSignalReceptionMultipleGestureDetectors(void); +extern int UtcDaliPanGestureSignalReceptionMultipleDetectorsOnActor(void); +extern int UtcDaliPanGestureSignalReceptionMultipleStarted(void); +extern int UtcDaliPanGestureSignalReceptionEnsureCorrectSignalling(void); +extern int UtcDaliPanGestureSignalReceptionDifferentPossible(void); +extern int UtcDaliPanGestureEmitIncorrectState(void); +extern int UtcDaliPanGestureActorUnstaged(void); +extern int UtcDaliPanGestureActorStagedAndDestroyed(void); +extern int UtcDaliPanGestureSystemOverlay(void); +extern int UtcDaliPanGestureAngleHandling(void); +extern int UtcDaliPanGestureAngleOutOfRange(void); +extern int UtcDaliPanGestureAngleProcessing(void); +extern int UtcDaliPanGestureDirectionHandling(void); +extern int UtcDaliPanGestureDirectionProcessing(void); +extern int UtcDaliPanGestureSetProperties(void); +extern int UtcDaliPanGestureSetPropertiesAlreadyPanning(void); +extern int UtcDaliPanGesturePropertyIndices(void); +extern int UtcDaliPinchGestureConstructor(void); +extern int UtcDaliPinchGestureAssignment(void); +extern int UtcDaliPinchGestureDetectorConstructor(void); +extern int UtcDaliPinchGestureDetectorNew(void); +extern int UtcDaliPinchGestureDetectorDownCast(void); +extern int UtcDaliPinchGestureSignalReceptionNegative(void); +extern int UtcDaliPinchGestureSignalReceptionDownMotionLeave(void); +extern int UtcDaliPinchGestureSignalReceptionDownMotionUp(void); +extern int UtcDaliPinchGestureSignalReceptionCancelled(void); +extern int UtcDaliPinchGestureSignalReceptionDetach(void); +extern int UtcDaliPinchGestureSignalReceptionDetachWhilePinching(void); +extern int UtcDaliPinchGestureSignalReceptionActorDestroyedWhilePinching(void); +extern int UtcDaliPinchGestureSignalReceptionRotatedActor(void); +extern int UtcDaliPinchGestureSignalReceptionChildHit(void); +extern int UtcDaliPinchGestureSignalReceptionAttachDetachMany(void); +extern int UtcDaliPinchGestureSignalReceptionActorBecomesUntouchable(void); +extern int UtcDaliPinchGestureSignalReceptionMultipleDetectorsOnActor(void); +extern int UtcDaliPinchGestureSignalReceptionMultipleStarted(void); +extern int UtcDaliPinchGestureSignalReceptionEnsureCorrectSignalling(void); +extern int UtcDaliPinchGestureEmitIncorrectStateClear(void); +extern int UtcDaliPinchGestureEmitIncorrectStatePossible(void); +extern int UtcDaliPinchGestureActorUnstaged(void); +extern int UtcDaliPinchGestureActorStagedAndDestroyed(void); +extern int UtcDaliPinchGestureSystemOverlay(void); +extern int UtcDaliPixelHasAlpha(void); +extern int UtcDaliPixelGetBytesPerPixel(void); +extern int UtcDaliPixelGetAlphaOffsetAndMask(void); +extern int UtcDaliPropertyNotificationDownCast(void); +extern int UtcDaliPropertyNotificationDownCastNegative(void); +extern int UtcDaliAddPropertyNotification(void); +extern int UtcDaliAddPropertyNotificationCallback(void); +extern int UtcDaliAddPropertyNotificationTypeProperty(void); +extern int UtcDaliPropertyNotificationGetCondition(void); +extern int UtcDaliPropertyNotificationGetConditionConst(void); +extern int UtcDaliPropertyNotificationGetTarget(void); +extern int UtcDaliPropertyNotificationGetProperty(void); +extern int UtcDaliPropertyNotificationGetNotifyMode(void); +extern int UtcDaliPropertyNotificationGreaterThan(void); +extern int UtcDaliPropertyNotificationLessThan(void); +extern int UtcDaliPropertyNotificationInside(void); +extern int UtcDaliPropertyNotificationOutside(void); +extern int UtcDaliPropertyNotificationVectorComponentGreaterThan(void); +extern int UtcDaliPropertyNotificationVectorComponentLessThan(void); +extern int UtcDaliPropertyNotificationVectorComponentInside(void); +extern int UtcDaliPropertyNotificationVectorComponentOutside(void); +extern int UtcDaliPropertyConditionGetArguments(void); +extern int UtcDaliPropertyConditionGetArgumentsConst(void); +extern int UtcDaliPropertyNotificationStep(void); +extern int UtcDaliPropertyNotificationVariableStep(void); +extern int UtcDaliQuaternionCtor01(void); +extern int UtcDaliQuaternionCtor02(void); +extern int UtcDaliQuaternionCtor03(void); +extern int UtcDaliQuaternionFromAxisAngle(void); +extern int UtcDaliQuaternionToAxisAngle01(void); +extern int UtcDaliQuaternionToAxisAngle02(void); +extern int UtcDaliQuaternionToAxisAngle03(void); +extern int UtcDaliQuaternionToAxisAngle04(void); +extern int UtcDaliQuaternionEulerAngles(void); +extern int UtcDaliQuaternionToMatrix01(void); +extern int UtcDaliQuaternionToMatrix02(void); +extern int UtcDaliQuaternionFromMatrix01(void); +extern int UtcDaliQuaternionFromMatrix02(void); +extern int UtcDaliQuaternionFromAxes01(void); +extern int UtcDaliQuaternionFromAxes02(void); +extern int UtcDaliQuaternionOperatorAddition(void); +extern int UtcDaliQuaternionOperatorSubtraction(void); +extern int UtcDaliQuaternionConjugate(void); +extern int UtcDaliQuaternionOperatorMultiplication01(void); +extern int UtcDaliQuaternionOperatorDivision(void); +extern int UtcDaliQuaternionOperatorScale01(void); +extern int UtcDaliQuaternionOperatorScale02(void); +extern int UtcDaliQuaternionOperatorNegation(void); +extern int UtcDaliQuaternionOperatorAddAssign(void); +extern int UtcDaliQuaternionOperatorSubtractAssign(void); +extern int UtcDaliQuaternionOperatorMultiplyAssign(void); +extern int UtcDaliQuaternionOperatorScaleAssign01(void); +extern int UtcDaliQuaternionOperatorScaleAssign02(void); +extern int UtcDaliQuaternionOperatorEquality(void); +extern int UtcDaliQuaternionOperatorInequality(void); +extern int UtcDaliQuaternionLength(void); +extern int UtcDaliQuaternionLengthSquared(void); +extern int UtcDaliQuaternionNormalize(void); +extern int UtcDaliQuaternionNormalized(void); +extern int UtcDaliQuaternionInvert(void); +extern int UtcDaliQuaternionDot(void); +extern int UtcDaliQuaternionOperatorMultiplication02(void); +extern int UtcDaliQuaternionRotate01(void); +extern int UtcDaliQuaternionRotate02(void); +extern int UtcDaliQuaternionExp01(void); +extern int UtcDaliQuaternionExp02(void); +extern int UtcDaliQuaternionExp03(void); +extern int UtcDaliQuaternionLog01(void); +extern int UtcDaliQuaternionLog02(void); +extern int UtcDaliQuaternionLerp(void); +extern int UtcDaliQuaternionSlerp01(void); +extern int UtcDaliQuaternionSlerp02(void); +extern int UtcDaliQuaternionSlerp03(void); +extern int UtcDaliQuaternionSlerp04(void); +extern int UtcDaliQuaternionSlerpNoInvert01(void); +extern int UtcDaliQuaternionSlerpNoInvert02(void); +extern int UtcDaliQuaternionSquad(void); +extern int UtcDaliAngleBetween(void); +extern int UtcDaliQuaternionOStreamOperator(void); +extern int UtcDaliRadianConstructors01(void); +extern int UtcDaliRadianComparison01(void); +extern int UtcDaliRadianCastOperators01(void); +extern int UtcDaliRadianCastOperatorEquals(void); +extern int UtcDaliRadianCastOperatorNotEquals(void); +extern int UtcDaliRadianCastOperatorLessThan(void); +extern int UtcDaliRectCons01(void); +extern int UtcDaliRectCons02(void); +extern int UtcDaliRectCons03(void); +extern int UtcDaliRectCons04(void); +extern int UtcDaliRectSet(void); +extern int UtcDaliRectIsEmpty(void); +extern int UtcDaliRectRight(void); +extern int UtcDaliRectBottom(void); +extern int UtcDaliRectArea(void); +extern int UtcDaliRectIntersects(void); +extern int UtcDaliRectContains(void); +extern int UtcDaliRectOperatorNotEquals(void); +extern int UtcDaliRectOperatorEquals(void); +extern int UtcDaliRenderTaskDownCast(void); +extern int UtcDaliRenderTaskSetSourceActor(void); +extern int UtcDaliRenderTaskSetSourceActorOffStage(void); +extern int UtcDaliRenderTaskSetSourceActorEmpty(void); +extern int UtcDaliRenderTaskGetSourceActor(void); +extern int UtcDaliRenderTaskSetExclusive(void); +extern int UtcDaliRenderTaskIsExclusive(void); +extern int UtcDaliRenderTaskSetInputEnabled(void); +extern int UtcDaliRenderTaskGetInputEnabled(void); +extern int UtcDaliRenderTaskSetCameraActor(void); +extern int UtcDaliRenderTaskGetCameraActor(void); +extern int UtcDaliRenderTaskSetTargetFrameBuffer(void); +extern int UtcDaliRenderTaskGetTargetFrameBuffer(void); +extern int UtcDaliRenderTaskSetScreenToFrameBufferFunction(void); +extern int UtcDaliRenderTaskGetScreenToFrameBufferFunction(void); +extern int UtcDaliRenderTaskGetScreenToFrameBufferMappingActor(void); +extern int UtcDaliRenderTaskSetViewport(void); +extern int UtcDaliRenderTaskGetViewport(void); +extern int UtcDaliRenderTaskSetViewportPosition(void); +extern int UtcDaliRenderTaskSetViewportSize(void); +extern int UtcDaliRenderTaskSetClearColor(void); +extern int UtcDaliRenderTaskGetClearColor(void); +extern int UtcDaliRenderTaskSetClearEnabled(void); +extern int UtcDaliRenderTaskGetClearEnabled(void); +extern int UtcDaliRenderTaskSetRefreshRate(void); +extern int UtcDaliRenderTaskGetRefreshRate(void); +extern int UtcDaliRenderTaskSignalFinished(void); +extern int UtcDaliRenderTaskContinuous01(void); +extern int UtcDaliRenderTaskContinuous02(void); +extern int UtcDaliRenderTaskContinuous03(void); +extern int UtcDaliRenderTaskContinuous04(void); +extern int UtcDaliRenderTaskContinuous05(void); +extern int UtcDaliRenderTaskContinuous06(void); +extern int UtcDaliRenderTaskOnce01(void); +extern int UtcDaliRenderTaskOnce02(void); +extern int UtcDaliRenderTaskOnce03(void); +extern int UtcDaliRenderTaskOnce05(void); +extern int UtcDaliRenderTaskOnce06(void); +extern int UtcDaliRenderTaskOnce07(void); +extern int UtcDaliRenderTaskOnce08(void); +extern int UtcDaliRenderTaskOnceNoSync01(void); +extern int UtcDaliRenderTaskOnceNoSync02(void); +extern int UtcDaliRenderTaskOnceNoSync03(void); +extern int UtcDaliRenderTaskOnceNoSync05(void); +extern int UtcDaliRenderTaskOnceNoSync06(void); +extern int UtcDaliRenderTaskOnceNoSync07(void); +extern int UtcDaliRenderTaskOnceNoSync08(void); +extern int UtcDaliRenderTaskOnceChain01(void); +extern int UtcDaliRenderTaskProperties(void); +extern int UtcDaliRenderTaskListDefaultConstructor(void); +extern int UtcDaliRenderTaskListDownCast(void); +extern int UtcDaliRenderTaskListCreateTask(void); +extern int UtcDaliRenderTaskListRemoveTask(void); +extern int UtcDaliRenderTaskListGetTaskCount(void); +extern int UtcDaliRenderTaskListGetTask(void); +extern int UtcDaliRenderableActorDownCast(void); +extern int UtcDaliRenderableActorSetSortModifier(void); +extern int UtcDaliRenderableActorGetSortModifier(void); +extern int UtcDaliRenderableActorSetGetBlendMode(void); +extern int UtcDaliRenderableActorSetCullFace(void); +extern int UtcDaliRenderableActorGetCullFace(void); +extern int UtcDaliRenderableActorSetGetBlendFunc(void); +extern int UtcDaliRenderableActorSetGetBlendEquation(void); +extern int UtcDaliRenderableActorSetGetBlendColor(void); +extern int UtcDaliRenderableActorSetGetAlpha(void); +extern int UtcDaliRenderableActorCreateDestroy(void); +extern int UtcDaliShaderEffectMethodNew01(void); +extern int UtcDaliShaderEffectMethodNew02(void); +extern int UtcDaliShaderEffectMethodNew03(void); +extern int UtcDaliShaderEffectMethodNew04(void); +extern int UtcDaliShaderEffectMethodNew05(void); +extern int UtcDaliShaderEffectMethodNew06(void); +extern int UtcDaliShaderEffectMethodDownCast(void); +extern int UtcDaliShaderEffectMethodDelete01(void); +extern int UtcDaliShaderEffectMethodSetUniformFloat(void); +extern int UtcDaliShaderEffectMethodSetUniformVector2(void); +extern int UtcDaliShaderEffectMethodSetUniformVector3(void); +extern int UtcDaliShaderEffectMethodSetUniformVector4(void); +extern int UtcDaliShaderEffectMethodSetUniformMatrix(void); +extern int UtcDaliShaderEffectMethodSetUniformMatrix3(void); +extern int UtcDaliShaderEffectMethodSetUniformViewport(void); +extern int UtcDaliShaderEffectMethodSetEffectImage(void); +extern int UtcDaliShaderEffectMethodSetEffectImageAndDelete(void); +extern int UtcDaliShaderEffectMethodApplyConstraint(void); +extern int UtcDaliShaderEffectMethodApplyConstraintFromActor(void); +extern int UtcDaliShaderEffectMethodApplyConstraintFromActor2(void); +extern int UtcDaliShaderEffectMethodApplyConstraintCallback(void); +extern int UtcDaliShaderEffectMethodRemoveConstraints(void); +extern int UtcDaliShaderEffectMethodRemoveConstraints2(void); +extern int UtcDaliShaderEffectMethodCreateExtension(void); +extern int UtcDaliShaderEffectMethodCreateExtension2(void); +extern int UtcDaliShaderEffectMethodNoExtension(void); +extern int UtcDaliShaderEffectPropertyIndices(void); +extern int UtcDaliSignalFunctorsEmptyCheck(void); +extern int UtcDaliSignalFunctorsEmit(void); +extern int UtcDaliSignalFunctorsEmitReturn(void); +extern int UtcDaliSignalFunctorsDisconnectBeforeEmit(void); +extern int UtcDaliSignalFunctorsDestroySignal(void); +extern int UtcDaliSignalConnectVoidFunctor(void); +extern int UtcDaliSignalEmptyCheck(void); +extern int UtcDaliSignalEmptyCheckSlotDestruction(void); +extern int UtcDaliSignalConnectAndEmit(void); +extern int UtcDaliSignalDisconnect(void); +extern int UtcDaliSignalDisconnect2(void); +extern int UtcDaliSignalDisconnect3(void); +extern int UtcDaliSignalCustomConnectionTracker(void); +extern int UtcDaliSignalMultipleConnections(void); +extern int UtcDaliSignalMultipleConnections2(void); +extern int UtcDaliSignalMultipleConnections3(void); +extern int UtcDaliSignalDisconnectStatic(void); +extern int UtcDaliSignalDisconnectDuringCallback(void); +extern int UtcDaliSignalDisconnectDuringCallback2(void); +extern int UtcDaliSignalEmitDuringCallback(void); +extern int UtcDaliSignalTestApp01(void); +extern int UtcDaliSignalTestApp02(void); +extern int UtcDaliSignalTestApp03(void); +extern int UtcDaliSignalTestApp04(void); +extern int UtcDaliSignalTestApp05(void); +extern int UtcDaliSignalTestApp06(void); +extern int UtcDaliSlotDelegateConnection(void); +extern int UtcDaliSignalSlotDelegateDestruction(void); +extern int UtcDaliSlotHandlerDisconnect(void); +extern int UtcDaliStageDefaultConstructor(void); +extern int UtcDaliStageDestructor(void); +extern int UtcDaliStageGetCurrent(void); +extern int UtcDaliStageIsInstalled(void); +extern int UtcDaliStageAdd(void); +extern int UtcDaliStageRemove(void); +extern int UtcDaliStageGetSize(void); +extern int UtcDaliStageGetDpi01(void); +extern int UtcDaliStageGetDpi02(void); +extern int UtcDaliStageGetDpi03(void); +extern int UtcDaliStageGetLayerCount(void); +extern int UtcDaliStageGetLayer(void); +extern int UtcDaliStageGetRootLayer(void); +extern int UtcDaliStageSetBackgroundColor(void); +extern int UtcDaliStageGetBackgroundColor(void); +extern int UtcDaliStageKeepRendering(void); +extern int UtcDaliStageEventProcessingFinished(void); +extern int UtcDaliStageSignalKeyEvent(void); +extern int UtcDaliStageTouchedSignal(void); +extern int UtcDaliTapGestureConstructor(void); +extern int UtcDaliTapGestureAssignment(void); +extern int UtcDaliTapGestureDetectorConstructor(void); +extern int UtcDaliTapGestureDetectorNew(void); +extern int UtcDaliTapGestureDetectorDownCast(void); +extern int UtcDaliTapGestureSetTapsRequired(void); +extern int UtcDaliTapGestureGetTapsRequired(void); +extern int UtcDaliTapGestureSetTouchesRequired(void); +extern int UtcDaliTapGestureGetTouchesRequired(void); +extern int UtcDaliTapGestureSignalReceptionNegative(void); +extern int UtcDaliTapGestureSignalReceptionPositive(void); +extern int UtcDaliTapGestureSignalReceptionDetach(void); +extern int UtcDaliTapGestureSignalReceptionActorDestroyedWhileTapping(void); +extern int UtcDaliTapGestureSignalReceptionRotatedActor(void); +extern int UtcDaliTapGestureSignalReceptionChildHit(void); +extern int UtcDaliTapGestureSignalReceptionAttachDetachMany(void); +extern int UtcDaliTapGestureSignalReceptionActorBecomesUntouchable(void); +extern int UtcDaliTapGestureSignalReceptionMultipleGestureDetectors(void); +extern int UtcDaliTapGestureSignalReceptionMultipleDetectorsOnActor(void); +extern int UtcDaliTapGestureSignalReceptionDifferentPossible(void); +extern int UtcDaliTapGestureEmitIncorrectStateClear(void); +extern int UtcDaliTapGestureEmitIncorrectStateContinuing(void); +extern int UtcDaliTapGestureEmitIncorrectStateFinished(void); +extern int UtcDaliTapGestureActorUnstaged(void); +extern int UtcDaliTapGestureRepeatedState(void); +extern int UtcDaliTapGesturePossibleCancelled(void); +extern int UtcDaliTapGestureDetectorRemovedWhilePossible(void); +extern int UtcDaliTapGestureActorRemovedWhilePossible(void); +extern int UtcDaliTapGestureSystemOverlay(void); +extern int UtcDaliTextConstructor(void); +extern int UtcDaliTextCopyConstructor(void); +extern int UtcDaliTextAssignmentOperator(void); +extern int UtcDaliTextSetGetText(void); +extern int UtcDaliTextAccessOperator01(void); +extern int UtcDaliTextAccessOperator02(void); +extern int UtcDaliTextIsEmpty(void); +extern int UtcDaliTextGetLength(void); +extern int UtcDaliTextAppend(void); +extern int UtcDaliTextRemove01(void); +extern int UtcDaliTextRemove02(void); +extern int UtcDaliTextActorConstructorVoid(void); +extern int UtcDaliTextActorNew01(void); +extern int UtcDaliTextActorNew02(void); +extern int UtcDaliTextActorNew03(void); +extern int UtcDaliTextActorNew04(void); +extern int UtcDaliTextActorNew05(void); +extern int UtcDaliTextActorNew06(void); +extern int UtcDaliTextActorNew07(void); +extern int UtcDaliTextActorDownCast(void); +extern int UtcDaliTextActorDownCast2(void); +extern int UtcDaliTextActorSetText(void); +extern int UtcDaliTextActorSetFont(void); +extern int UtcDaliTextActorSetFontDetection(void); +extern int UtcDaliTextActorSetTextIndividualStyles(void); +extern int UtcDaliTextActorChangingText(void); +extern int UtcDaliTextActorGetLoadingState(void); +extern int UtcDaliTextActorSetItalics(void); +extern int UtcDaliTextActorSetUnderline(void); +extern int UtcDaliTextActorSetWeight(void); +extern int UtcDaliTextActorSetStyle(void); +extern int UtcDaliTextActorDefaultProperties(void); +extern int UtcDaliTextActorSetGradientColor(void); +extern int UtcDaliTextActorSetGradientStartPoint(void); +extern int UtcDaliTextActorSetGradientEndPoint(void); +extern int UtcDaliTextActorSynchronousGlyphLoading(void); +extern int UtcDaliTextActorAutomaticSizeSet(void); +extern int UtcDaliTextActorAutomaticSizeSetAnimation(void); +extern int UtcDaliTextActorPropertyIndices(void); +extern int UtcDaliTextStyleDefaultConstructor(void); +extern int UtcDaliTextStyleCopyConstructor(void); +extern int UtcDaliTextStyleComparisonOperator(void); +extern int UtcDaliTextStyleCopy(void); +extern int UtcDaliTextStyleSetGetFontName(void); +extern int UtcDaliTextStyleSetGetFontStyle(void); +extern int UtcDaliTextStyleSetGetFontPointSize(void); +extern int UtcDaliTextStyleSetGetWeight(void); +extern int UtcDaliTextStyleSetGetTextColor(void); +extern int UtcDaliTextStyleSetGetItalics(void); +extern int UtcDaliTextStyleSetGetItalicsAngle(void); +extern int UtcDaliTextStyleSetGetUnderline(void); +extern int UtcDaliTextStyleSetGetShadow(void); +extern int UtcDaliTextStyleSetGetGlow(void); +extern int UtcDaliTextStyleSetGetOutline(void); +extern int UtcDaliTextStyleSetGetSmoothEdge(void); +extern int UtcDaliTouchEventCombinerConstructors(void); +extern int UtcDaliTouchEventCombinerConstructorsNegative(void); +extern int UtcDaliTouchEventCombinerSettersAndGetters(void); +extern int UtcDaliTouchEventCombinerSettersNegative(void); +extern int UtcDaliTouchEventCombinerSingleTouchNormal(void); +extern int UtcDaliTouchEventCombinerSingleTouchMotionWithoutDown(void); +extern int UtcDaliTouchEventCombinerSingleTouchTwoDowns(void); +extern int UtcDaliTouchEventCombinerSingleTouchUpWithoutDown(void); +extern int UtcDaliTouchEventCombinerSingleTouchTwoUps(void); +extern int UtcDaliTouchEventCombinerSingleTouchUpWithDifferentId(void); +extern int UtcDaliTouchEventCombinerSingleTouchMotionWithDifferentId(void); +extern int UtcDaliTouchEventCombinerMultiTouchNormal(void); +extern int UtcDaliTouchEventCombinerSeveralPoints(void); +extern int UtcDaliTouchEventCombinerReset(void); +extern int UtcDaliTouchEventCombinerSingleTouchInterrupted(void); +extern int UtcDaliTouchEventCombinerMultiTouchInterrupted(void); +extern int UtcDaliTouchEventCombinerInvalidState(void); +extern int UtcDaliTouchNormalProcessing(void); +extern int UtcDaliTouchOutsideCameraNearFarPlanes(void); +extern int UtcDaliTouchEmitEmpty(void); +extern int UtcDaliTouchInterrupted(void); +extern int UtcDaliTouchParentConsumer(void); +extern int UtcDaliTouchInterruptedParentConsumer(void); +extern int UtcDaliTouchLeave(void); +extern int UtcDaliTouchLeaveParentConsumer(void); +extern int UtcDaliTouchActorBecomesInsensitive(void); +extern int UtcDaliTouchActorBecomesInsensitiveParentConsumer(void); +extern int UtcDaliTouchMultipleLayers(void); +extern int UtcDaliTouchMultipleRenderTasks(void); +extern int UtcDaliTouchMultipleRenderTasksWithChildLayer(void); +extern int UtcDaliTouchOffscreenRenderTasks(void); +extern int UtcDaliTouchMultipleRenderableActors(void); +extern int UtcDaliTouchActorRemovedInSignal(void); +extern int UtcDaliTouchActorSignalNotConsumed(void); +extern int UtcDaliTouchActorUnStaged(void); +extern int UtcDaliTouchSystemOverlayActor(void); +extern int UtcDaliVector2Cons(void); +extern int UtcDaliVector2FitInside(void); +extern int UtcDaliVector2FitScaleToFill(void); +extern int UtcDaliVector2ShrinkInside(void); +extern int UtcDaliVector2Add(void); +extern int UtcDaliVector2Subtract(void); +extern int UtcDaliVector2Negate(void); +extern int UtcDaliVector2Multiply(void); +extern int UtcDaliVector2Divide(void); +extern int UtcDaliVector2Scale(void); +extern int UtcDaliVector2Equals(void); +extern int UtcDaliVector2Length(void); +extern int UtcDaliVector2LengthSquared(void); +extern int UtcDaliVector2Max(void); +extern int UtcDaliVector2Min(void); +extern int UtcDaliVector2Clamp(void); +extern int UtcDaliVector2ClampVector2(void); +extern int UtcDaliVector2Normalize(void); +extern int UtcDaliVector2OperatorSubscript(void); +extern int UtcDaliVector2OStreamOperator(void); +extern int UtcDaliVector3Cons(void); +extern int UtcDaliVector3Assign(void); +extern int UtcDaliVector3Add(void); +extern int UtcDaliVector3Constants(void); +extern int UtcDaliVector3Cross(void); +extern int UtcDaliVector3Dot(void); +extern int UtcDaliVector3Equals(void); +extern int UtcDaliVector3Length(void); +extern int UtcDaliVector3LengthSquared(void); +extern int UtcDaliVector3Max(void); +extern int UtcDaliVector3Min(void); +extern int UtcDaliVector3Clamp(void); +extern int UtcDaliVector3ClampVector3(void); +extern int UtcDaliVector3Multiply(void); +extern int UtcDaliVector3Divide(void); +extern int UtcDaliVector3Scale(void); +extern int UtcDaliVector3Normalize(void); +extern int UtcDaliVector3Subtract(void); +extern int UtcDaliVector3OperatorSubscript(void); +extern int UtcDaliVector3OStreamOperator(void); +extern int UtcDaliVector3Rotate(void); +extern int UtcDaliVector3AsFloat(void); +extern int UtcDaliVector3AsVectorXY(void); +extern int UtcDaliVector3FitKeepAspectRatio(void); +extern int UtcDaliVector3FillKeepAspectRatio(void); +extern int UtcDaliVector3FillXYKeepAspectRatio(void); +extern int UtcDaliVector3ShrinkInsideKeepAspectRatio(void); +extern int UtcDaliVector4Vector4(void); +extern int UtcDaliVector4Add(void); +extern int UtcDaliVector4Constants(void); +extern int UtcDaliVector4Cross(void); +extern int UtcDaliVector4Dot(void); +extern int UtcDaliVector4DotVector3(void); +extern int UtcDaliVector4Dot4(void); +extern int UtcDaliVector4Equals(void); +extern int UtcDaliVector4Length(void); +extern int UtcDaliVector4LengthSquared(void); +extern int UtcDaliVector4Max(void); +extern int UtcDaliVector4Min(void); +extern int UtcDaliVector4Clamp(void); +extern int UtcDaliVector4ClampVector4(void); +extern int UtcDaliVector4Multiply(void); +extern int UtcDaliVector4Divide(void); +extern int UtcDaliVector4Scale(void); +extern int UtcDaliVector4Normalize(void); +extern int UtcDaliVector4Subtract(void); +extern int UtcDaliVector4OperatorSubscript(void); +extern int UtcDaliVector4OStreamOperator(void); +extern int UtcDaliVector4AsFloat(void); + +testcase tc_array[] = { + {"UtcDaliConstraintGetTargetObject", UtcDaliConstraintGetTargetObject, utc_dali_active_constraint_startup, utc_dali_active_constraint_cleanup}, + {"UtcDaliConstraintGetTargetProperty", UtcDaliConstraintGetTargetProperty, utc_dali_active_constraint_startup, utc_dali_active_constraint_cleanup}, + {"UtcDaliConstraintSetWeight", UtcDaliConstraintSetWeight, utc_dali_active_constraint_startup, utc_dali_active_constraint_cleanup}, + {"UtcDaliConstraintGetCurrentWeight", UtcDaliConstraintGetCurrentWeight, utc_dali_active_constraint_startup, utc_dali_active_constraint_cleanup}, + {"UtcDaliConstraintSignalApplied", UtcDaliConstraintSignalApplied, utc_dali_active_constraint_startup, utc_dali_active_constraint_cleanup}, + {"UtcDaliConstraintRemove", UtcDaliConstraintRemove, utc_dali_active_constraint_startup, utc_dali_active_constraint_cleanup}, + {"UtcDaliConstraintCallback", UtcDaliConstraintCallback, utc_dali_active_constraint_startup, utc_dali_active_constraint_cleanup}, + {"UtcDaliConstraintProperties", UtcDaliConstraintProperties, utc_dali_active_constraint_startup, utc_dali_active_constraint_cleanup}, + {"UtcDaliActorNew", UtcDaliActorNew, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorDownCast", UtcDaliActorDownCast, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorDownCast2", UtcDaliActorDownCast2, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetName", UtcDaliActorGetName, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetName", UtcDaliActorSetName, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetId", UtcDaliActorGetId, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorIsRoot", UtcDaliActorIsRoot, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorOnStage", UtcDaliActorOnStage, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorIsLayer", UtcDaliActorIsLayer, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetLayer", UtcDaliActorGetLayer, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorAdd", UtcDaliActorAdd, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorRemove01", UtcDaliActorRemove01, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorRemove02", UtcDaliActorRemove02, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetChildCount", UtcDaliActorGetChildCount, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetChildren01", UtcDaliActorGetChildren01, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetChildren02", UtcDaliActorGetChildren02, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetParent01", UtcDaliActorGetParent01, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetParent02", UtcDaliActorGetParent02, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetParentOrigin", UtcDaliActorSetParentOrigin, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetCurrentParentOrigin", UtcDaliActorGetCurrentParentOrigin, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetAnchorPoint", UtcDaliActorSetAnchorPoint, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetCurrentAnchorPoint", UtcDaliActorGetCurrentAnchorPoint, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetSize01", UtcDaliActorSetSize01, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetSize02", UtcDaliActorSetSize02, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetSize03", UtcDaliActorSetSize03, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetSize04", UtcDaliActorSetSize04, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetCurrentSize", UtcDaliActorGetCurrentSize, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetPosition01", UtcDaliActorSetPosition01, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetPosition02", UtcDaliActorSetPosition02, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetPosition03", UtcDaliActorSetPosition03, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetX", UtcDaliActorSetX, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetY", UtcDaliActorSetY, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetZ", UtcDaliActorSetZ, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorMoveBy", UtcDaliActorMoveBy, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetCurrentPosition", UtcDaliActorGetCurrentPosition, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetCurrentWorldPosition", UtcDaliActorGetCurrentWorldPosition, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorInheritPosition", UtcDaliActorInheritPosition, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetRotation01", UtcDaliActorSetRotation01, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetRotation02", UtcDaliActorSetRotation02, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorRotateBy01", UtcDaliActorRotateBy01, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorRotateBy02", UtcDaliActorRotateBy02, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetCurrentRotation", UtcDaliActorGetCurrentRotation, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetCurrentWorldRotation", UtcDaliActorGetCurrentWorldRotation, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetScale01", UtcDaliActorSetScale01, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetScale02", UtcDaliActorSetScale02, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetScale03", UtcDaliActorSetScale03, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorScaleBy", UtcDaliActorScaleBy, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetCurrentScale", UtcDaliActorGetCurrentScale, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetCurrentWorldScale", UtcDaliActorGetCurrentWorldScale, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorInheritScale", UtcDaliActorInheritScale, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetVisible", UtcDaliActorSetVisible, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorIsVisible", UtcDaliActorIsVisible, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetOpacity", UtcDaliActorSetOpacity, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetCurrentOpacity", UtcDaliActorGetCurrentOpacity, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetSensitive", UtcDaliActorSetSensitive, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorIsSensitive", UtcDaliActorIsSensitive, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetInheritShaderEffect", UtcDaliActorSetInheritShaderEffect, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetInheritShaderEffect", UtcDaliActorGetInheritShaderEffect, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetShaderEffect", UtcDaliActorSetShaderEffect, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetShaderEffect", UtcDaliActorGetShaderEffect, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorRemoveShaderEffect01", UtcDaliActorRemoveShaderEffect01, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorRemoveShaderEffect02", UtcDaliActorRemoveShaderEffect02, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetColor", UtcDaliActorSetColor, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetCurrentColor", UtcDaliActorGetCurrentColor, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetCurrentWorldColor", UtcDaliActorGetCurrentWorldColor, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetColorMode", UtcDaliActorSetColorMode, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorScreenToLocal", UtcDaliActorScreenToLocal, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetLeaveRequired", UtcDaliActorSetLeaveRequired, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetLeaveRequired", UtcDaliActorGetLeaveRequired, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetKeyboardFocusable", UtcDaliActorSetKeyboardFocusable, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorIsKeyboardFocusable", UtcDaliActorIsKeyboardFocusable, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorApplyConstraint", UtcDaliActorApplyConstraint, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorApplyConstraintAppliedCallback", UtcDaliActorApplyConstraintAppliedCallback, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorRemoveConstraints", UtcDaliActorRemoveConstraints, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorRemoveConstraint", UtcDaliActorRemoveConstraint, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorTouchedSignal", UtcDaliActorTouchedSignal, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetSizeSignal", UtcDaliActorSetSizeSignal, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorOnOffStageSignal", UtcDaliActorOnOffStageSignal, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorFindChildByName", UtcDaliActorFindChildByName, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorFindChildByAlias", UtcDaliActorFindChildByAlias, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorFindChildById", UtcDaliActorFindChildById, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorHitTest", UtcDaliActorHitTest, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetDrawMode", UtcDaliActorSetDrawMode, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetDrawModeOverlayRender", UtcDaliActorSetDrawModeOverlayRender, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetDrawModeOverlayHitTest", UtcDaliActorSetDrawModeOverlayHitTest, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetCurrentWorldMatrix", UtcDaliActorGetCurrentWorldMatrix, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorConstrainedToWorldMatrix", UtcDaliActorConstrainedToWorldMatrix, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorUnparent", UtcDaliActorUnparent, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorGetChildAt", UtcDaliActorGetChildAt, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorSetGetOverlay", UtcDaliActorSetGetOverlay, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorDynamics", UtcDaliActorDynamics, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliActorCreateDestroy", UtcDaliActorCreateDestroy, utc_dali_actor_startup, utc_dali_actor_cleanup}, + {"UtcDaliAlphaFunctionsDefault", UtcDaliAlphaFunctionsDefault, utc_dali_alpha_functions_startup, utc_dali_alpha_functions_cleanup}, + {"UtcDaliAlphaFunctionsLinear", UtcDaliAlphaFunctionsLinear, utc_dali_alpha_functions_startup, utc_dali_alpha_functions_cleanup}, + {"UtcDaliAlphaFunctionsReverse", UtcDaliAlphaFunctionsReverse, utc_dali_alpha_functions_startup, utc_dali_alpha_functions_cleanup}, + {"UtcDaliAlphaFunctionsEaseIn", UtcDaliAlphaFunctionsEaseIn, utc_dali_alpha_functions_startup, utc_dali_alpha_functions_cleanup}, + {"UtcDaliAlphaFunctionsEaseOut", UtcDaliAlphaFunctionsEaseOut, utc_dali_alpha_functions_startup, utc_dali_alpha_functions_cleanup}, + {"UtcDaliAlphaFunctionsEaseInOut", UtcDaliAlphaFunctionsEaseInOut, utc_dali_alpha_functions_startup, utc_dali_alpha_functions_cleanup}, + {"UtcDaliAlphaFunctionsEaseInSine", UtcDaliAlphaFunctionsEaseInSine, utc_dali_alpha_functions_startup, utc_dali_alpha_functions_cleanup}, + {"UtcDaliAlphaFunctionsEaseOutSine", UtcDaliAlphaFunctionsEaseOutSine, utc_dali_alpha_functions_startup, utc_dali_alpha_functions_cleanup}, + {"UtcDaliAlphaFunctionsEaseInOutSine", UtcDaliAlphaFunctionsEaseInOutSine, utc_dali_alpha_functions_startup, utc_dali_alpha_functions_cleanup}, + {"UtcDaliAlphaFunctionsBounce", UtcDaliAlphaFunctionsBounce, utc_dali_alpha_functions_startup, utc_dali_alpha_functions_cleanup}, + {"UtcDaliAlphaFunctionsBounceBack", UtcDaliAlphaFunctionsBounceBack, utc_dali_alpha_functions_startup, utc_dali_alpha_functions_cleanup}, + {"UtcDaliAlphaFunctionsEaseOutBack", UtcDaliAlphaFunctionsEaseOutBack, utc_dali_alpha_functions_startup, utc_dali_alpha_functions_cleanup}, + {"UtcDaliAlphaFunctionsSin", UtcDaliAlphaFunctionsSin, utc_dali_alpha_functions_startup, utc_dali_alpha_functions_cleanup}, + {"UtcDaliAlphaFunctionsSin2x", UtcDaliAlphaFunctionsSin2x, utc_dali_alpha_functions_startup, utc_dali_alpha_functions_cleanup}, + {"UtcDaliAlphaFunctionsSquare", UtcDaliAlphaFunctionsSquare, utc_dali_alpha_functions_startup, utc_dali_alpha_functions_cleanup}, + {"UtcDaliAlphaFunctionsEaseInSine33", UtcDaliAlphaFunctionsEaseInSine33, utc_dali_alpha_functions_startup, utc_dali_alpha_functions_cleanup}, + {"UtcDaliAlphaFunctionsEaseOutSine33", UtcDaliAlphaFunctionsEaseOutSine33, utc_dali_alpha_functions_startup, utc_dali_alpha_functions_cleanup}, + {"UtcDaliAlphaFunctionsEaseInOutSineXX", UtcDaliAlphaFunctionsEaseInOutSineXX, utc_dali_alpha_functions_startup, utc_dali_alpha_functions_cleanup}, + {"UtcDaliAlphaFunctionsDoubleEaseInOutSine60", UtcDaliAlphaFunctionsDoubleEaseInOutSine60, utc_dali_alpha_functions_startup, utc_dali_alpha_functions_cleanup}, + {"UtcDaliAlphaFunctionsEaseOutQuint50", UtcDaliAlphaFunctionsEaseOutQuint50, utc_dali_alpha_functions_startup, utc_dali_alpha_functions_cleanup}, + {"UtcDaliAlphaFunctionsEaseOutQuint80", UtcDaliAlphaFunctionsEaseOutQuint80, utc_dali_alpha_functions_startup, utc_dali_alpha_functions_cleanup}, + {"UtcDaliAlphaFunctionsEaseInBack", UtcDaliAlphaFunctionsEaseInBack, utc_dali_alpha_functions_startup, utc_dali_alpha_functions_cleanup}, + {"UtcDaliAlphaFunctionsEaseInOutBack", UtcDaliAlphaFunctionsEaseInOutBack, utc_dali_alpha_functions_startup, utc_dali_alpha_functions_cleanup}, + {"UtcDaliAngleAxisNew01", UtcDaliAngleAxisNew01, utc_dali_angle_axis_startup, utc_dali_angle_axis_cleanup}, + {"UtcDaliAngleAxisNew02", UtcDaliAngleAxisNew02, utc_dali_angle_axis_startup, utc_dali_angle_axis_cleanup}, + {"UtcDaliAngleAxisNew03", UtcDaliAngleAxisNew03, utc_dali_angle_axis_startup, utc_dali_angle_axis_cleanup}, + {"UtcDaliAngleAxisAssign", UtcDaliAngleAxisAssign, utc_dali_angle_axis_startup, utc_dali_angle_axis_cleanup}, + {"UtcDaliAngleAxisCopy", UtcDaliAngleAxisCopy, utc_dali_angle_axis_startup, utc_dali_angle_axis_cleanup}, + {"UtcDaliAnimatableMeshConstructor01", UtcDaliAnimatableMeshConstructor01, utc_dali_animatable_mesh_startup, utc_dali_animatable_mesh_cleanup}, + {"UtcDaliAnimatableMeshConstructor02", UtcDaliAnimatableMeshConstructor02, utc_dali_animatable_mesh_startup, utc_dali_animatable_mesh_cleanup}, + {"UtcDaliAnimatableMeshConstructor03", UtcDaliAnimatableMeshConstructor03, utc_dali_animatable_mesh_startup, utc_dali_animatable_mesh_cleanup}, + {"UtcDaliAnimatableMeshNew01", UtcDaliAnimatableMeshNew01, utc_dali_animatable_mesh_startup, utc_dali_animatable_mesh_cleanup}, + {"UtcDaliAnimatableMeshNew02", UtcDaliAnimatableMeshNew02, utc_dali_animatable_mesh_startup, utc_dali_animatable_mesh_cleanup}, + {"UtcDaliAnimatableMeshNew03", UtcDaliAnimatableMeshNew03, utc_dali_animatable_mesh_startup, utc_dali_animatable_mesh_cleanup}, + {"UtcDaliAnimatableMeshNew04", UtcDaliAnimatableMeshNew04, utc_dali_animatable_mesh_startup, utc_dali_animatable_mesh_cleanup}, + {"UtcDaliAnimatableMeshNew05", UtcDaliAnimatableMeshNew05, utc_dali_animatable_mesh_startup, utc_dali_animatable_mesh_cleanup}, + {"UtcDaliAnimatableMeshNew06", UtcDaliAnimatableMeshNew06, utc_dali_animatable_mesh_startup, utc_dali_animatable_mesh_cleanup}, + {"UtcDaliAnimatableMeshDownCast01", UtcDaliAnimatableMeshDownCast01, utc_dali_animatable_mesh_startup, utc_dali_animatable_mesh_cleanup}, + {"UtcDaliAnimatableMeshGetPropertyIndex01", UtcDaliAnimatableMeshGetPropertyIndex01, utc_dali_animatable_mesh_startup, utc_dali_animatable_mesh_cleanup}, + {"UtcDaliAnimatableMeshGetPropertyIndex02", UtcDaliAnimatableMeshGetPropertyIndex02, utc_dali_animatable_mesh_startup, utc_dali_animatable_mesh_cleanup}, + {"UtcDaliAnimatableMeshGetPropertyIndex03", UtcDaliAnimatableMeshGetPropertyIndex03, utc_dali_animatable_mesh_startup, utc_dali_animatable_mesh_cleanup}, + {"UtcDaliAnimatableMeshGetPropertyIndex04", UtcDaliAnimatableMeshGetPropertyIndex04, utc_dali_animatable_mesh_startup, utc_dali_animatable_mesh_cleanup}, + {"UtcDaliAnimatableMeshOperatorArray01", UtcDaliAnimatableMeshOperatorArray01, utc_dali_animatable_mesh_startup, utc_dali_animatable_mesh_cleanup}, + {"UtcDaliAnimatableMeshOperatorArray02", UtcDaliAnimatableMeshOperatorArray02, utc_dali_animatable_mesh_startup, utc_dali_animatable_mesh_cleanup}, + {"UtcDaliAnimatableMeshAnimateVertex01", UtcDaliAnimatableMeshAnimateVertex01, utc_dali_animatable_mesh_startup, utc_dali_animatable_mesh_cleanup}, + {"UtcDaliAnimatableVertexSettersAndGetters", UtcDaliAnimatableVertexSettersAndGetters, utc_dali_animatable_mesh_startup, utc_dali_animatable_mesh_cleanup}, + {"UtcDaliAnimatableMeshProperties", UtcDaliAnimatableMeshProperties, utc_dali_animatable_mesh_startup, utc_dali_animatable_mesh_cleanup}, + {"UtcDaliAnimatableMeshExceedVertices", UtcDaliAnimatableMeshExceedVertices, utc_dali_animatable_mesh_startup, utc_dali_animatable_mesh_cleanup}, + {"UtcDaliAnimationNew01", UtcDaliAnimationNew01, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationNew02", UtcDaliAnimationNew02, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationDownCast", UtcDaliAnimationDownCast, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationSetDuration", UtcDaliAnimationSetDuration, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationGetDuration", UtcDaliAnimationGetDuration, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationSetLooping", UtcDaliAnimationSetLooping, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationIsLooping", UtcDaliAnimationIsLooping, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationSetEndAction", UtcDaliAnimationSetEndAction, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationGetEndAction", UtcDaliAnimationGetEndAction, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationGetDestroyAction", UtcDaliAnimationGetDestroyAction, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationSetDefaultAlphaFunction", UtcDaliAnimationSetDefaultAlphaFunction, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationGetDefaultAlphaFunction", UtcDaliAnimationGetDefaultAlphaFunction, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationPlay", UtcDaliAnimationPlay, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationPlayOffStage", UtcDaliAnimationPlayOffStage, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationPlayDiscardHandle", UtcDaliAnimationPlayDiscardHandle, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationPlayStopDiscardHandle", UtcDaliAnimationPlayStopDiscardHandle, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationPause", UtcDaliAnimationPause, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationStop", UtcDaliAnimationStop, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationStopSetPosition", UtcDaliAnimationStopSetPosition, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationClear", UtcDaliAnimationClear, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationSignalFinish", UtcDaliAnimationSignalFinish, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateByBoolean", UtcDaliAnimationAnimateByBoolean, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateByBooleanAlphaFunction", UtcDaliAnimationAnimateByBooleanAlphaFunction, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateByBooleanTimePeriod", UtcDaliAnimationAnimateByBooleanTimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriod", UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateByFloat", UtcDaliAnimationAnimateByFloat, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateByFloatAlphaFunction", UtcDaliAnimationAnimateByFloatAlphaFunction, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateByFloatTimePeriod", UtcDaliAnimationAnimateByFloatTimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriod", UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateByVector2", UtcDaliAnimationAnimateByVector2, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateByVector2AlphaFunction", UtcDaliAnimationAnimateByVector2AlphaFunction, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateByVector2TimePeriod", UtcDaliAnimationAnimateByVector2TimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriod", UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateByVector3", UtcDaliAnimationAnimateByVector3, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateByVector3AlphaFunction", UtcDaliAnimationAnimateByVector3AlphaFunction, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateByVector3TimePeriod", UtcDaliAnimationAnimateByVector3TimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriod", UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateByVector4", UtcDaliAnimationAnimateByVector4, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateByVector4AlphaFunction", UtcDaliAnimationAnimateByVector4AlphaFunction, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateByVector4TimePeriod", UtcDaliAnimationAnimateByVector4TimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriod", UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateByActorPosition", UtcDaliAnimationAnimateByActorPosition, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateByActorPositionAlphaFunction", UtcDaliAnimationAnimateByActorPositionAlphaFunction, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateByActorPositionTimePeriod", UtcDaliAnimationAnimateByActorPositionTimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriod", UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToBoolean", UtcDaliAnimationAnimateToBoolean, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToBooleanAlphaFunction", UtcDaliAnimationAnimateToBooleanAlphaFunction, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToBooleanTimePeriod", UtcDaliAnimationAnimateToBooleanTimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriod", UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToFloat", UtcDaliAnimationAnimateToFloat, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToFloatAlphaFunction", UtcDaliAnimationAnimateToFloatAlphaFunction, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToFloatTimePeriod", UtcDaliAnimationAnimateToFloatTimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriod", UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToVector2", UtcDaliAnimationAnimateToVector2, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToVector2AlphaFunction", UtcDaliAnimationAnimateToVector2AlphaFunction, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToVector2TimePeriod", UtcDaliAnimationAnimateToVector2TimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriod", UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToVector3", UtcDaliAnimationAnimateToVector3, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToVector3AlphaFunction", UtcDaliAnimationAnimateToVector3AlphaFunction, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToVector3TimePeriod", UtcDaliAnimationAnimateToVector3TimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriod", UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToVector3Component", UtcDaliAnimationAnimateToVector3Component, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToVector4", UtcDaliAnimationAnimateToVector4, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToVector4AlphaFunction", UtcDaliAnimationAnimateToVector4AlphaFunction, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToVector4TimePeriod", UtcDaliAnimationAnimateToVector4TimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriod", UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorParentOrigin", UtcDaliAnimationAnimateToActorParentOrigin, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorParentOriginX", UtcDaliAnimationAnimateToActorParentOriginX, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorParentOriginY", UtcDaliAnimationAnimateToActorParentOriginY, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorParentOriginZ", UtcDaliAnimationAnimateToActorParentOriginZ, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorAnchorPoint", UtcDaliAnimationAnimateToActorAnchorPoint, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorAnchorPointX", UtcDaliAnimationAnimateToActorAnchorPointX, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorAnchorPointY", UtcDaliAnimationAnimateToActorAnchorPointY, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorAnchorPointZ", UtcDaliAnimationAnimateToActorAnchorPointZ, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorSize", UtcDaliAnimationAnimateToActorSize, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorSizeWidth", UtcDaliAnimationAnimateToActorSizeWidth, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorSizeHeight", UtcDaliAnimationAnimateToActorSizeHeight, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorSizeDepth", UtcDaliAnimationAnimateToActorSizeDepth, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorPosition", UtcDaliAnimationAnimateToActorPosition, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorPositionX", UtcDaliAnimationAnimateToActorPositionX, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorPositionY", UtcDaliAnimationAnimateToActorPositionY, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorPositionZ", UtcDaliAnimationAnimateToActorPositionZ, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorPositionAlphaFunction", UtcDaliAnimationAnimateToActorPositionAlphaFunction, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorPositionTimePeriod", UtcDaliAnimationAnimateToActorPositionTimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriod", UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorRotationAngleAxis", UtcDaliAnimationAnimateToActorRotationAngleAxis, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorRotationQuaternion", UtcDaliAnimationAnimateToActorRotationQuaternion, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorRotationAlphaFunction", UtcDaliAnimationAnimateToActorRotationAlphaFunction, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorRotationTimePeriod", UtcDaliAnimationAnimateToActorRotationTimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorRotationAlphaFunctionTimePeriod", UtcDaliAnimationAnimateToActorRotationAlphaFunctionTimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorScale", UtcDaliAnimationAnimateToActorScale, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorScaleX", UtcDaliAnimationAnimateToActorScaleX, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorScaleY", UtcDaliAnimationAnimateToActorScaleY, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorScaleZ", UtcDaliAnimationAnimateToActorScaleZ, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorColor", UtcDaliAnimationAnimateToActorColor, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorColorRed", UtcDaliAnimationAnimateToActorColorRed, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorColorGreen", UtcDaliAnimationAnimateToActorColorGreen, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorColorBlue", UtcDaliAnimationAnimateToActorColorBlue, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateToActorColorAlpha", UtcDaliAnimationAnimateToActorColorAlpha, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationKeyFrames01", UtcDaliAnimationKeyFrames01, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationKeyFrames02", UtcDaliAnimationKeyFrames02, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationKeyFrames03", UtcDaliAnimationKeyFrames03, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationKeyFrames04", UtcDaliAnimationKeyFrames04, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationKeyFrames05", UtcDaliAnimationKeyFrames05, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationKeyFrames06", UtcDaliAnimationKeyFrames06, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateBetweenActorColorAlpha", UtcDaliAnimationAnimateBetweenActorColorAlpha, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateBetweenActorColor", UtcDaliAnimationAnimateBetweenActorColor, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateBetweenActorVisible01", UtcDaliAnimationAnimateBetweenActorVisible01, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateBetweenActorRotation02", UtcDaliAnimationAnimateBetweenActorRotation02, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationMoveByFloat3", UtcDaliAnimationMoveByFloat3, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationMoveByVector3Alpha", UtcDaliAnimationMoveByVector3Alpha, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationMoveByVector3AlphaFloat2", UtcDaliAnimationMoveByVector3AlphaFloat2, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationMoveToFloat3", UtcDaliAnimationMoveToFloat3, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationMoveToVector3Alpha", UtcDaliAnimationMoveToVector3Alpha, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationMoveToVector3AlphaFloat2", UtcDaliAnimationMoveToVector3AlphaFloat2, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationMove", UtcDaliAnimationMove, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationRotateByDegreeVector3", UtcDaliAnimationRotateByDegreeVector3, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationRotateByRadianVector3", UtcDaliAnimationRotateByRadianVector3, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationRotateByDegreeVector3Alpha", UtcDaliAnimationRotateByDegreeVector3Alpha, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationRotateByRadianVector3Alpha", UtcDaliAnimationRotateByRadianVector3Alpha, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationRotateByDegreeVector3AlphaFloat2", UtcDaliAnimationRotateByDegreeVector3AlphaFloat2, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationRotateByRadianVector3AlphaFloat2", UtcDaliAnimationRotateByRadianVector3AlphaFloat2, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationRotateToDegreeVector3", UtcDaliAnimationRotateToDegreeVector3, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationRotateToRadianVector3", UtcDaliAnimationRotateToRadianVector3, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationRotateToQuaternion", UtcDaliAnimationRotateToQuaternion, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationRotateToDegreeVector3Alpha", UtcDaliAnimationRotateToDegreeVector3Alpha, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationRotateToRadianVector3Alpha", UtcDaliAnimationRotateToRadianVector3Alpha, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationRotateToQuaternionAlpha", UtcDaliAnimationRotateToQuaternionAlpha, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationRotateToDegreeVector3AlphaFloat2", UtcDaliAnimationRotateToDegreeVector3AlphaFloat2, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationRotateToRadianVector3AlphaFloat2", UtcDaliAnimationRotateToRadianVector3AlphaFloat2, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationRotateToQuaternionAlphaFloat2", UtcDaliAnimationRotateToQuaternionAlphaFloat2, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationRotate", UtcDaliAnimationRotate, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationScaleBy", UtcDaliAnimationScaleBy, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationScaleTo", UtcDaliAnimationScaleTo, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationShow", UtcDaliAnimationShow, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationHide", UtcDaliAnimationHide, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationShowHideAtEnd", UtcDaliAnimationShowHideAtEnd, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationOpacityBy", UtcDaliAnimationOpacityBy, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationOpacityTo", UtcDaliAnimationOpacityTo, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationColorBy", UtcDaliAnimationColorBy, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationColorTo", UtcDaliAnimationColorTo, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationResize", UtcDaliAnimationResize, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateBool", UtcDaliAnimationAnimateBool, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateFloat", UtcDaliAnimationAnimateFloat, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateVector2", UtcDaliAnimationAnimateVector2, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateVector3", UtcDaliAnimationAnimateVector3, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateVector4", UtcDaliAnimationAnimateVector4, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateQuaternion", UtcDaliAnimationAnimateQuaternion, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliKeyFramesCreateDestroy", UtcDaliKeyFramesCreateDestroy, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliKeyFramesDownCast", UtcDaliKeyFramesDownCast, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationResizeByXY", UtcDaliAnimationResizeByXY, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateBetweenActorColorTimePeriod", UtcDaliAnimationAnimateBetweenActorColorTimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateBetweenActorColorFunction", UtcDaliAnimationAnimateBetweenActorColorFunction, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateBetweenActorColorFunctionTimePeriod", UtcDaliAnimationAnimateBetweenActorColorFunctionTimePeriod, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationAnimateVector3Func", UtcDaliAnimationAnimateVector3Func, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnimationCreateDestroy", UtcDaliAnimationCreateDestroy, utc_dali_animation_startup, utc_dali_animation_cleanup}, + {"UtcDaliAnyConstructors", UtcDaliAnyConstructors, utc_dali_any_startup, utc_dali_any_cleanup}, + {"UtcDaliAnyAssignmentOperators", UtcDaliAnyAssignmentOperators, utc_dali_any_startup, utc_dali_any_cleanup}, + {"UtcDaliAnyNegativeAssignmentOperators", UtcDaliAnyNegativeAssignmentOperators, utc_dali_any_startup, utc_dali_any_cleanup}, + {"UtcDaliAnyGetType", UtcDaliAnyGetType, utc_dali_any_startup, utc_dali_any_cleanup}, + {"UtcDaliAnyGet", UtcDaliAnyGet, utc_dali_any_startup, utc_dali_any_cleanup}, + {"UtcDaliAnyNegativeGet", UtcDaliAnyNegativeGet, utc_dali_any_startup, utc_dali_any_cleanup}, + {"UtcDaliBaseHandleConstructorVoid", UtcDaliBaseHandleConstructorVoid, utc_base_handle_startup, utc_base_handle_cleanup}, + {"UtcDaliBaseHandleCopyConstructor", UtcDaliBaseHandleCopyConstructor, utc_base_handle_startup, utc_base_handle_cleanup}, + {"UtcDaliBaseHandleAssignmentOperator", UtcDaliBaseHandleAssignmentOperator, utc_base_handle_startup, utc_base_handle_cleanup}, + {"UtcDaliBaseHandleGetBaseObject", UtcDaliBaseHandleGetBaseObject, utc_base_handle_startup, utc_base_handle_cleanup}, + {"UtcDaliBaseHandleReset", UtcDaliBaseHandleReset, utc_base_handle_startup, utc_base_handle_cleanup}, + {"UtcDaliBaseHandleEqualityOperator01", UtcDaliBaseHandleEqualityOperator01, utc_base_handle_startup, utc_base_handle_cleanup}, + {"UtcDaliBaseHandleEqualityOperator02", UtcDaliBaseHandleEqualityOperator02, utc_base_handle_startup, utc_base_handle_cleanup}, + {"UtcDaliBaseHandleInequalityOperator01", UtcDaliBaseHandleInequalityOperator01, utc_base_handle_startup, utc_base_handle_cleanup}, + {"UtcDaliBaseHandleInequalityOperator02", UtcDaliBaseHandleInequalityOperator02, utc_base_handle_startup, utc_base_handle_cleanup}, + {"UtcDaliBaseHandleStlVector", UtcDaliBaseHandleStlVector, utc_base_handle_startup, utc_base_handle_cleanup}, + {"UtcDaliBaseHandleDoAction", UtcDaliBaseHandleDoAction, utc_base_handle_startup, utc_base_handle_cleanup}, + {"UtcDaliBaseHandleConnectSignal", UtcDaliBaseHandleConnectSignal, utc_base_handle_startup, utc_base_handle_cleanup}, + {"UtcDaliBaseHandleGetTypeName", UtcDaliBaseHandleGetTypeName, utc_base_handle_startup, utc_base_handle_cleanup}, + {"UtcDaliBaseHandleGetObjectPtr", UtcDaliBaseHandleGetObjectPtr, utc_base_handle_startup, utc_base_handle_cleanup}, + {"UtcDaliBaseHandleBooleanCast", UtcDaliBaseHandleBooleanCast, utc_base_handle_startup, utc_base_handle_cleanup}, + {"UtcDaliBitmapImageNew01", UtcDaliBitmapImageNew01, utc_dali_bitmap_image_startup, utc_dali_bitmap_image_cleanup}, + {"UtcDaliBitmapImageNew02", UtcDaliBitmapImageNew02, utc_dali_bitmap_image_startup, utc_dali_bitmap_image_cleanup}, + {"UtcDaliBitmapImageNewWithPolicy01", UtcDaliBitmapImageNewWithPolicy01, utc_dali_bitmap_image_startup, utc_dali_bitmap_image_cleanup}, + {"UtcDaliBitmapImageNewWithPolicy02", UtcDaliBitmapImageNewWithPolicy02, utc_dali_bitmap_image_startup, utc_dali_bitmap_image_cleanup}, + {"UtcDaliBitmapImageDownCast", UtcDaliBitmapImageDownCast, utc_dali_bitmap_image_startup, utc_dali_bitmap_image_cleanup}, + {"UtcDaliBitmapImageDownCast2", UtcDaliBitmapImageDownCast2, utc_dali_bitmap_image_startup, utc_dali_bitmap_image_cleanup}, + {"UtcDaliBitmapImageWHITE", UtcDaliBitmapImageWHITE, utc_dali_bitmap_image_startup, utc_dali_bitmap_image_cleanup}, + {"UtcDaliBitmapImageGetBuffer", UtcDaliBitmapImageGetBuffer, utc_dali_bitmap_image_startup, utc_dali_bitmap_image_cleanup}, + {"UtcDaliBitmapImageGetBufferSize", UtcDaliBitmapImageGetBufferSize, utc_dali_bitmap_image_startup, utc_dali_bitmap_image_cleanup}, + {"UtcDaliBitmapImageGetBufferStride", UtcDaliBitmapImageGetBufferStride, utc_dali_bitmap_image_startup, utc_dali_bitmap_image_cleanup}, + {"UtcDaliBitmapImageIsDataExternal", UtcDaliBitmapImageIsDataExternal, utc_dali_bitmap_image_startup, utc_dali_bitmap_image_cleanup}, + {"UtcDaliBitmapImageUpdate01", UtcDaliBitmapImageUpdate01, utc_dali_bitmap_image_startup, utc_dali_bitmap_image_cleanup}, + {"UtcDaliBitmapImageUpdate02", UtcDaliBitmapImageUpdate02, utc_dali_bitmap_image_startup, utc_dali_bitmap_image_cleanup}, + {"UtcDaliBitmapImageUploadedSignal01", UtcDaliBitmapImageUploadedSignal01, utc_dali_bitmap_image_startup, utc_dali_bitmap_image_cleanup}, + {"UtcDaliBitmapImageUploadedSignal02", UtcDaliBitmapImageUploadedSignal02, utc_dali_bitmap_image_startup, utc_dali_bitmap_image_cleanup}, + {"UtcDaliCameraActorConstructorVoid", UtcDaliCameraActorConstructorVoid, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorNew", UtcDaliCameraActorNew, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorDownCast", UtcDaliCameraActorDownCast, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorDownCast2", UtcDaliCameraActorDownCast2, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorSetCameraOffStage", UtcDaliCameraActorSetCameraOffStage, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorSetCameraOnStage", UtcDaliCameraActorSetCameraOnStage, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorGetCamera", UtcDaliCameraActorGetCamera, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorDefaultProperties", UtcDaliCameraActorDefaultProperties, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorSetTarget", UtcDaliCameraActorSetTarget, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorSetType01", UtcDaliCameraActorSetType01, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorSetType02", UtcDaliCameraActorSetType02, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorSetFieldOfView", UtcDaliCameraActorSetFieldOfView, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorSetAspectRatio", UtcDaliCameraActorSetAspectRatio, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorSetNearClippingPlane", UtcDaliCameraActorSetNearClippingPlane, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorSetFarClippingPlane", UtcDaliCameraActorSetFarClippingPlane, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorSetTargetPosition", UtcDaliCameraActorSetTargetPosition, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorSetInvertYAxis", UtcDaliCameraActorSetInvertYAxis, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorModelView", UtcDaliCameraActorModelView, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorSetPerspectiveProjection", UtcDaliCameraActorSetPerspectiveProjection, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorSetOrthographicProjection01", UtcDaliCameraActorSetOrthographicProjection01, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorSetOrthographicProjection02", UtcDaliCameraActorSetOrthographicProjection02, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorSetOrthographicProjection03", UtcDaliCameraActorSetOrthographicProjection03, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorReadProjectionMatrix", UtcDaliCameraActorReadProjectionMatrix, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorAnimatedProperties", UtcDaliCameraActorAnimatedProperties, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorPropertyIndices", UtcDaliCameraActorPropertyIndices, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorCheckLookAtAndFreeLookViews01", UtcDaliCameraActorCheckLookAtAndFreeLookViews01, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorCheckLookAtAndFreeLookViews02", UtcDaliCameraActorCheckLookAtAndFreeLookViews02, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCameraActorCheckLookAtAndFreeLookViews03", UtcDaliCameraActorCheckLookAtAndFreeLookViews03, camera_actor_test_startup, camera_actor_test_cleanup}, + {"UtcDaliCharacterCopyConstructor", UtcDaliCharacterCopyConstructor, utc_dali_character_startup, utc_dali_character_cleanup}, + {"UtcDaliCharacterComparissonOperators", UtcDaliCharacterComparissonOperators, utc_dali_character_startup, utc_dali_character_cleanup}, + {"UtcDaliCharacterAssignmentOperator", UtcDaliCharacterAssignmentOperator, utc_dali_character_startup, utc_dali_character_cleanup}, + {"UtcDaliCharacterIsLeftToRight", UtcDaliCharacterIsLeftToRight, utc_dali_character_startup, utc_dali_character_cleanup}, + {"UtcDaliGetCharacterDirection", UtcDaliGetCharacterDirection, utc_dali_character_startup, utc_dali_character_cleanup}, + {"UtcDaliCharacterIsWhiteSpace", UtcDaliCharacterIsWhiteSpace, utc_dali_character_startup, utc_dali_character_cleanup}, + {"UtcDaliCharacterIsNewLine", UtcDaliCharacterIsNewLine, utc_dali_character_startup, utc_dali_character_cleanup}, + {"UtcDaliConstraintNewBoolean", UtcDaliConstraintNewBoolean, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintNewFloat", UtcDaliConstraintNewFloat, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintNewVector2", UtcDaliConstraintNewVector2, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintNewVector3", UtcDaliConstraintNewVector3, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintNewVector4", UtcDaliConstraintNewVector4, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintNewMatrix", UtcDaliConstraintNewMatrix, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintNewMatrix3", UtcDaliConstraintNewMatrix3, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintNewQuaternion", UtcDaliConstraintNewQuaternion, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintNewOffStageBoolean", UtcDaliConstraintNewOffStageBoolean, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintNewOffStageFloat", UtcDaliConstraintNewOffStageFloat, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintNewOffStageVector2", UtcDaliConstraintNewOffStageVector2, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintNewOffStageVector3", UtcDaliConstraintNewOffStageVector3, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintNewOffStageVector4", UtcDaliConstraintNewOffStageVector4, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintNewOffStageQuaternion", UtcDaliConstraintNewOffStageQuaternion, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintNewLocalInput", UtcDaliConstraintNewLocalInput, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintNewParentInput", UtcDaliConstraintNewParentInput, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintNewInput1", UtcDaliConstraintNewInput1, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintNewInput2", UtcDaliConstraintNewInput2, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintNewInput3", UtcDaliConstraintNewInput3, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintNewInput4", UtcDaliConstraintNewInput4, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintNewInput5", UtcDaliConstraintNewInput5, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintNewInput6", UtcDaliConstraintNewInput6, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintDownCast", UtcDaliConstraintDownCast, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintSetApplyTime", UtcDaliConstraintSetApplyTime, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintGetApplyTime", UtcDaliConstraintGetApplyTime, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintSetRemoveTime", UtcDaliConstraintSetRemoveTime, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintGetRemoveTime", UtcDaliConstraintGetRemoveTime, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintSetAlphaFunction", UtcDaliConstraintSetAlphaFunction, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintGetAlphaFunction", UtcDaliConstraintGetAlphaFunction, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintSetRemoveAction", UtcDaliConstraintSetRemoveAction, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintGetRemoveAction", UtcDaliConstraintGetRemoveAction, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintRemoveDuringApply", UtcDaliConstraintRemoveDuringApply, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintImmediateRemoveDuringApply", UtcDaliConstraintImmediateRemoveDuringApply, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintActorSize", UtcDaliConstraintActorSize, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintActorSizeWidth", UtcDaliConstraintActorSizeWidth, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintActorSizeHeight", UtcDaliConstraintActorSizeHeight, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintActorSizeDepth", UtcDaliConstraintActorSizeDepth, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintInputWorldPosition", UtcDaliConstraintInputWorldPosition, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintInputWorldRotation", UtcDaliConstraintInputWorldRotation, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintInputWorldScale", UtcDaliConstraintInputWorldScale, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintInputWorldColor", UtcDaliConstraintInputWorldColor, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliConstraintInvalidInputProperty", UtcDaliConstraintInvalidInputProperty, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliBuiltinConstraintParentSize", UtcDaliBuiltinConstraintParentSize, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliBuiltinConstraintParentSizeRelative", UtcDaliBuiltinConstraintParentSizeRelative, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliBuiltinConstraintScaleToFitConstraint", UtcDaliBuiltinConstraintScaleToFitConstraint, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliBuiltinConstraintScaleToFitKeepAspectRatio", UtcDaliBuiltinConstraintScaleToFitKeepAspectRatio, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliBuiltinConstraintScaleToFillKeepAspectRatio", UtcDaliBuiltinConstraintScaleToFillKeepAspectRatio, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliBuiltinConstraintScaleToFillXYKeepAspectRatio", UtcDaliBuiltinConstraintScaleToFillXYKeepAspectRatio, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliBuiltinConstraintShrinkInsideKeepAspectRatioConstraint", UtcDaliBuiltinConstraintShrinkInsideKeepAspectRatioConstraint, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliBuiltinConstraintMultiplyConstraint", UtcDaliBuiltinConstraintMultiplyConstraint, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliBuiltinConstraintDivideConstraint", UtcDaliBuiltinConstraintDivideConstraint, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliBuiltinConstraintEqualToConstraint", UtcDaliBuiltinConstraintEqualToConstraint, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliBuiltinConstraintRelativeToConstraint", UtcDaliBuiltinConstraintRelativeToConstraint, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliBuiltinConstraintInverseOfConstraint", UtcDaliBuiltinConstraintInverseOfConstraint, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliBuiltinConstraintFunctions", UtcDaliBuiltinConstraintFunctions, utc_dali_constraint_startup, utc_dali_constraint_cleanup}, + {"UtcDaliCustomActorDestructor", UtcDaliCustomActorDestructor, custom_actor_test_startup, custom_actor_test_cleanup}, + {"UtcDaliCustomActorImplDestructor", UtcDaliCustomActorImplDestructor, custom_actor_test_startup, custom_actor_test_cleanup}, + {"UtcDaliCustomActorDownCast", UtcDaliCustomActorDownCast, custom_actor_test_startup, custom_actor_test_cleanup}, + {"UtcDaliCustomActorDownCastNegative", UtcDaliCustomActorDownCastNegative, custom_actor_test_startup, custom_actor_test_cleanup}, + {"UtcDaliCustomActorOnStageConnectionDisconnection", UtcDaliCustomActorOnStageConnectionDisconnection, custom_actor_test_startup, custom_actor_test_cleanup}, + {"UtcDaliCustomActorOnStageConnectionOrder", UtcDaliCustomActorOnStageConnectionOrder, custom_actor_test_startup, custom_actor_test_cleanup}, + {"UtcDaliCustomActorOnStageDisconnectionOrder", UtcDaliCustomActorOnStageDisconnectionOrder, custom_actor_test_startup, custom_actor_test_cleanup}, + {"UtcDaliCustomActorAddDuringOnStageConnection", UtcDaliCustomActorAddDuringOnStageConnection, custom_actor_test_startup, custom_actor_test_cleanup}, + {"UtcDaliCustomActorRemoveDuringOnStageConnection", UtcDaliCustomActorRemoveDuringOnStageConnection, custom_actor_test_startup, custom_actor_test_cleanup}, + {"UtcDaliCustomActorAddDuringOnStageDisconnection", UtcDaliCustomActorAddDuringOnStageDisconnection, custom_actor_test_startup, custom_actor_test_cleanup}, + {"UtcDaliCustomActorRemoveDuringOnStageDisconnection", UtcDaliCustomActorRemoveDuringOnStageDisconnection, custom_actor_test_startup, custom_actor_test_cleanup}, + {"UtcDaliCustomActorRemoveParentDuringOnStageConnection", UtcDaliCustomActorRemoveParentDuringOnStageConnection, custom_actor_test_startup, custom_actor_test_cleanup}, + {"UtcDaliCustomActorAddParentDuringOnStageDisconnection", UtcDaliCustomActorAddParentDuringOnStageDisconnection, custom_actor_test_startup, custom_actor_test_cleanup}, + {"UtcDaliCustomActorOnChildAddRemove", UtcDaliCustomActorOnChildAddRemove, custom_actor_test_startup, custom_actor_test_cleanup}, + {"UtcDaliCustomActorReparentDuringOnChildAdd", UtcDaliCustomActorReparentDuringOnChildAdd, custom_actor_test_startup, custom_actor_test_cleanup}, + {"UtcDaliCustomActorRemoveDuringOnChildRemove", UtcDaliCustomActorRemoveDuringOnChildRemove, custom_actor_test_startup, custom_actor_test_cleanup}, + {"UtcDaliCustomActorOnPropertySet", UtcDaliCustomActorOnPropertySet, custom_actor_test_startup, custom_actor_test_cleanup}, + {"UtcDaliCustomActorOnSizeSet", UtcDaliCustomActorOnSizeSet, custom_actor_test_startup, custom_actor_test_cleanup}, + {"UtcDaliCustomActorOnSizeAnimation", UtcDaliCustomActorOnSizeAnimation, custom_actor_test_startup, custom_actor_test_cleanup}, + {"UtcDaliCustomActorOnTouchEvent", UtcDaliCustomActorOnTouchEvent, custom_actor_test_startup, custom_actor_test_cleanup}, + {"UtcDaliCustomActorOnMouseWheelEvent", UtcDaliCustomActorOnMouseWheelEvent, custom_actor_test_startup, custom_actor_test_cleanup}, + {"UtcDaliCustomActorFindChildByAlias", UtcDaliCustomActorFindChildByAlias, custom_actor_test_startup, custom_actor_test_cleanup}, + {"UtcDaliCustomActorImplOnPropertySet", UtcDaliCustomActorImplOnPropertySet, custom_actor_test_startup, custom_actor_test_cleanup}, + {"UtcDaliCustomActorGetImplementation", UtcDaliCustomActorGetImplementation, custom_actor_test_startup, custom_actor_test_cleanup}, + {"UtcDaliDegreeConstructors01", UtcDaliDegreeConstructors01, utc_dali_degree_startup, utc_dali_degree_cleanup}, + {"UtcDaliDegreeComparison01", UtcDaliDegreeComparison01, utc_dali_degree_startup, utc_dali_degree_cleanup}, + {"UtcDaliDegreeCastOperators01", UtcDaliDegreeCastOperators01, utc_dali_degree_startup, utc_dali_degree_cleanup}, + {"UtcDaliDegreeCastOperatorEquals", UtcDaliDegreeCastOperatorEquals, utc_dali_degree_startup, utc_dali_degree_cleanup}, + {"UtcDaliDegreeCastOperatorNotEquals", UtcDaliDegreeCastOperatorNotEquals, utc_dali_degree_startup, utc_dali_degree_cleanup}, + {"UtcDaliDegreeCastOperatorLessThan", UtcDaliDegreeCastOperatorLessThan, utc_dali_degree_startup, utc_dali_degree_cleanup}, + {"UtcDaliInvalidEvent", UtcDaliInvalidEvent, utc_dali_event_processing_startup, utc_dali_event_processing_cleanup}, + {"UtcDaliInvalidGesture", UtcDaliInvalidGesture, utc_dali_event_processing_startup, utc_dali_event_processing_cleanup}, + {"UtcDaliFontNew01", UtcDaliFontNew01, utc_dali_font_startup, utc_dali_font_cleanup}, + {"UtcDaliFontNew02", UtcDaliFontNew02, utc_dali_font_startup, utc_dali_font_cleanup}, + {"UtcDaliFontNew03", UtcDaliFontNew03, utc_dali_font_startup, utc_dali_font_cleanup}, + {"UtcDaliFontNew04", UtcDaliFontNew04, utc_dali_font_startup, utc_dali_font_cleanup}, + {"UtcDaliFontNew05", UtcDaliFontNew05, utc_dali_font_startup, utc_dali_font_cleanup}, + {"UtcDaliFontNew06", UtcDaliFontNew06, utc_dali_font_startup, utc_dali_font_cleanup}, + {"UtcDaliFontDownCast", UtcDaliFontDownCast, utc_dali_font_startup, utc_dali_font_cleanup}, + {"UtcDaliFontGetPixelSize", UtcDaliFontGetPixelSize, utc_dali_font_startup, utc_dali_font_cleanup}, + {"UtcDaliFontGetPointSize", UtcDaliFontGetPointSize, utc_dali_font_startup, utc_dali_font_cleanup}, + {"UtcDaliFontPointsToPixels", UtcDaliFontPointsToPixels, utc_dali_font_startup, utc_dali_font_cleanup}, + {"UtcFontMeasureTextWidth", UtcFontMeasureTextWidth, utc_dali_font_startup, utc_dali_font_cleanup}, + {"UtcFontMeasureTextHeight", UtcFontMeasureTextHeight, utc_dali_font_startup, utc_dali_font_cleanup}, + {"UtcFontMeasureText", UtcFontMeasureText, utc_dali_font_startup, utc_dali_font_cleanup}, + {"UtcFontGetFamilyForText", UtcFontGetFamilyForText, utc_dali_font_startup, utc_dali_font_cleanup}, + {"UtcFontGetFontLineHeightFromCapsHeight", UtcFontGetFontLineHeightFromCapsHeight, utc_dali_font_startup, utc_dali_font_cleanup}, + {"UtcFontAllGlyphsSupported", UtcFontAllGlyphsSupported, utc_dali_font_startup, utc_dali_font_cleanup}, + {"UtcFontGetMetrics", UtcFontGetMetrics, utc_dali_font_startup, utc_dali_font_cleanup}, + {"UtcFontIsDefault", UtcFontIsDefault, utc_dali_font_startup, utc_dali_font_cleanup}, + {"UtcFontGetInstalledFonts", UtcFontGetInstalledFonts, utc_dali_font_startup, utc_dali_font_cleanup}, + {"UtcFontMetricsDefaultConstructor", UtcFontMetricsDefaultConstructor, utc_dali_font_startup, utc_dali_font_cleanup}, + {"UtcFontMetricsCopyConstructor", UtcFontMetricsCopyConstructor, utc_dali_font_startup, utc_dali_font_cleanup}, + {"UtcFontMetricsAssignmentOperator", UtcFontMetricsAssignmentOperator, utc_dali_font_startup, utc_dali_font_cleanup}, + {"UtcDaliFontParamsDefaultConstructor", UtcDaliFontParamsDefaultConstructor, utc_dali_font_parameters_startup, utc_dali_font_parameters_cleanup}, + {"UtcDaliFontParamsPointSizeConstructor", UtcDaliFontParamsPointSizeConstructor, utc_dali_font_parameters_startup, utc_dali_font_parameters_cleanup}, + {"UtcDaliFontParamsPixelSizeConstructor", UtcDaliFontParamsPixelSizeConstructor, utc_dali_font_parameters_startup, utc_dali_font_parameters_cleanup}, + {"UtcDaliFontParamsCopyConstructor", UtcDaliFontParamsCopyConstructor, utc_dali_font_parameters_startup, utc_dali_font_parameters_cleanup}, + {"UtcDaliFontParamsAssignmentOperator", UtcDaliFontParamsAssignmentOperator, utc_dali_font_parameters_startup, utc_dali_font_parameters_cleanup}, + {"UtcDaliFontParamsPointSizeEqualityOperator", UtcDaliFontParamsPointSizeEqualityOperator, utc_dali_font_parameters_startup, utc_dali_font_parameters_cleanup}, + {"UtcDaliFrameBufferImageNew01", UtcDaliFrameBufferImageNew01, utc_dali_framebuffer_startup, utc_dali_framebuffer_cleanup}, + {"UtcDaliFrameBufferImageDownCast", UtcDaliFrameBufferImageDownCast, utc_dali_framebuffer_startup, utc_dali_framebuffer_cleanup}, + {"UtcDaliGestureConstructor", UtcDaliGestureConstructor, utc_dali_gesture_startup, utc_dali_gesture_cleanup}, + {"UtcDaliGestureAssignment", UtcDaliGestureAssignment, utc_dali_gesture_startup, utc_dali_gesture_cleanup}, + {"UtcDaliGestureDetectorConstructorNegative", UtcDaliGestureDetectorConstructorNegative, utc_dali_gesture_detector_startup, utc_dali_gesture_detector_cleanup}, + {"UtcDaliGestureDetectorConstructorPositive", UtcDaliGestureDetectorConstructorPositive, utc_dali_gesture_detector_startup, utc_dali_gesture_detector_cleanup}, + {"UtcDaliGestureDetectorDownCast", UtcDaliGestureDetectorDownCast, utc_dali_gesture_detector_startup, utc_dali_gesture_detector_cleanup}, + {"UtcDaliGestureDetectorAttachPositive", UtcDaliGestureDetectorAttachPositive, utc_dali_gesture_detector_startup, utc_dali_gesture_detector_cleanup}, + {"UtcDaliGestureDetectorAttachNegative", UtcDaliGestureDetectorAttachNegative, utc_dali_gesture_detector_startup, utc_dali_gesture_detector_cleanup}, + {"UtcDaliGestureDetectorDetachPositive", UtcDaliGestureDetectorDetachPositive, utc_dali_gesture_detector_startup, utc_dali_gesture_detector_cleanup}, + {"UtcDaliGestureDetectorDetachNegative01", UtcDaliGestureDetectorDetachNegative01, utc_dali_gesture_detector_startup, utc_dali_gesture_detector_cleanup}, + {"UtcDaliGestureDetectorDetachNegative02", UtcDaliGestureDetectorDetachNegative02, utc_dali_gesture_detector_startup, utc_dali_gesture_detector_cleanup}, + {"UtcDaliGestureDetectorDetachNegative03", UtcDaliGestureDetectorDetachNegative03, utc_dali_gesture_detector_startup, utc_dali_gesture_detector_cleanup}, + {"UtcDaliGestureDetectorDetachAll", UtcDaliGestureDetectorDetachAll, utc_dali_gesture_detector_startup, utc_dali_gesture_detector_cleanup}, + {"UtcDaliGestureDetectorDetachAllNegative", UtcDaliGestureDetectorDetachAllNegative, utc_dali_gesture_detector_startup, utc_dali_gesture_detector_cleanup}, + {"UtcDaliGestureDetectorGetAttachedActors", UtcDaliGestureDetectorGetAttachedActors, utc_dali_gesture_detector_startup, utc_dali_gesture_detector_cleanup}, + {"UtcDaliHandleConstructorVoid", UtcDaliHandleConstructorVoid, handle_test_startup, handle_test_cleanup}, + {"UtcDaliHandleCopyConstructor", UtcDaliHandleCopyConstructor, handle_test_startup, handle_test_cleanup}, + {"UtcDaliHandleAssignmentOperator", UtcDaliHandleAssignmentOperator, handle_test_startup, handle_test_cleanup}, + {"UtcDaliHandleSupports", UtcDaliHandleSupports, handle_test_startup, handle_test_cleanup}, + {"UtcDaliHandleGetPropertyCount", UtcDaliHandleGetPropertyCount, handle_test_startup, handle_test_cleanup}, + {"UtcDaliHandleGetPropertyName", UtcDaliHandleGetPropertyName, handle_test_startup, handle_test_cleanup}, + {"UtcDaliHandleGetPropertyIndex", UtcDaliHandleGetPropertyIndex, handle_test_startup, handle_test_cleanup}, + {"UtcDaliHandleIsPropertyWritable", UtcDaliHandleIsPropertyWritable, handle_test_startup, handle_test_cleanup}, + {"UtcDaliHandleIsPropertyAnimatable", UtcDaliHandleIsPropertyAnimatable, handle_test_startup, handle_test_cleanup}, + {"UtcDaliHandleGetPropertyType", UtcDaliHandleGetPropertyType, handle_test_startup, handle_test_cleanup}, + {"UtcDaliHandleNonAnimtableProperties", UtcDaliHandleNonAnimtableProperties, handle_test_startup, handle_test_cleanup}, + {"UtcDaliHandleNonAnimtableCompositeProperties", UtcDaliHandleNonAnimtableCompositeProperties, handle_test_startup, handle_test_cleanup}, + {"UtcDaliHandleSetProperty01", UtcDaliHandleSetProperty01, handle_test_startup, handle_test_cleanup}, + {"UtcDaliHandleSetProperty02", UtcDaliHandleSetProperty02, handle_test_startup, handle_test_cleanup}, + {"UtcDaliHandleRegisterProperty", UtcDaliHandleRegisterProperty, handle_test_startup, handle_test_cleanup}, + {"UtcDaliHandleGetProperty", UtcDaliHandleGetProperty, handle_test_startup, handle_test_cleanup}, + {"UtcDaliHandleDownCast", UtcDaliHandleDownCast, handle_test_startup, handle_test_cleanup}, + {"UtcDaliHandleCreateProperty", UtcDaliHandleCreateProperty, handle_test_startup, handle_test_cleanup}, + {"UtcDaliHandleGetPropertyGet", UtcDaliHandleGetPropertyGet, handle_test_startup, handle_test_cleanup}, + {"UtcDaliHandleGetPropertyIndices", UtcDaliHandleGetPropertyIndices, handle_test_startup, handle_test_cleanup}, + {"UtcDaliImageNew01", UtcDaliImageNew01, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageNew02", UtcDaliImageNew02, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageNew03", UtcDaliImageNew03, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageNewWithPolicies01", UtcDaliImageNewWithPolicies01, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageNewWithPolicies02", UtcDaliImageNewWithPolicies02, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageNewWithPolicies03", UtcDaliImageNewWithPolicies03, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageNewWithPolicies04", UtcDaliImageNewWithPolicies04, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageNewDistanceField", UtcDaliImageNewDistanceField, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageNewDistanceFieldWithPolicies01", UtcDaliImageNewDistanceFieldWithPolicies01, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageNewDistanceFieldWithPolicies02", UtcDaliImageNewDistanceFieldWithPolicies02, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageNewDistanceFieldWithPolicies03", UtcDaliImageNewDistanceFieldWithPolicies03, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageNewDistanceFieldWithPolicies04", UtcDaliImageNewDistanceFieldWithPolicies04, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageNewDistanceFieldWithAttributes", UtcDaliImageNewDistanceFieldWithAttributes, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageNewDistanceFieldWithAttrandPol", UtcDaliImageNewDistanceFieldWithAttrandPol, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageDownCast", UtcDaliImageDownCast, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageGetImageSize", UtcDaliImageGetImageSize, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageGetFilename", UtcDaliImageGetFilename, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageGetLoadingState01", UtcDaliImageGetLoadingState01, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageGetLoadingState02", UtcDaliImageGetLoadingState02, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageGetReleasePolicy", UtcDaliImageGetReleasePolicy, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageGetLoadPolicy", UtcDaliImageGetLoadPolicy, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageSignalLoadingFinished", UtcDaliImageSignalLoadingFinished, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageSignalUploaded", UtcDaliImageSignalUploaded, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageDiscard01", UtcDaliImageDiscard01, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageDiscard02", UtcDaliImageDiscard02, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageDiscard03", UtcDaliImageDiscard03, utc_dali_image_startup, utc_dali_image_cleanup}, + {"UtcDaliImageActorConstructorVoid", UtcDaliImageActorConstructorVoid, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActorDestructor", UtcDaliImageActorDestructor, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActorNew01", UtcDaliImageActorNew01, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActorNew02", UtcDaliImageActorNew02, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActorDownCast", UtcDaliImageActorDownCast, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActorDownCast2", UtcDaliImageActorDownCast2, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActor9Patch", UtcDaliImageActor9Patch, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActorPixelArea", UtcDaliImageActorPixelArea, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActorGetCurrentImageSize01", UtcDaliImageActorGetCurrentImageSize01, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActorGetCurrentImageSize02", UtcDaliImageActorGetCurrentImageSize02, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActorGetCurrentImageSize03", UtcDaliImageActorGetCurrentImageSize03, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActorGetCurrentImageSize04", UtcDaliImageActorGetCurrentImageSize04, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActorGetCurrentImageSize05", UtcDaliImageActorGetCurrentImageSize05, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActorNaturalPixelAreaSize01", UtcDaliImageActorNaturalPixelAreaSize01, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActorNaturalPixelAreaSize02", UtcDaliImageActorNaturalPixelAreaSize02, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActorDefaultProperties", UtcDaliImageActorDefaultProperties, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActorUseImageAlpha01", UtcDaliImageActorUseImageAlpha01, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActorUseImageAlpha02", UtcDaliImageActorUseImageAlpha02, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActorUseImageAlpha03", UtcDaliImageActorUseImageAlpha03, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActorUseImageAlpha04", UtcDaliImageActorUseImageAlpha04, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActorUseImageAlpha05", UtcDaliImageActorUseImageAlpha05, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActorClearPixelArea", UtcDaliImageActorClearPixelArea, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageGetStyle", UtcDaliImageGetStyle, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageSetNinePatchBorder", UtcDaliImageSetNinePatchBorder, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageSetFadeIn", UtcDaliImageSetFadeIn, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageSetFadeInDuration", UtcDaliImageSetFadeInDuration, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActorNewNull", UtcDaliImageActorNewNull, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActorNewNullWithArea", UtcDaliImageActorNewNullWithArea, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActorSetImage", UtcDaliImageActorSetImage, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageActorPropertyIndices", UtcDaliImageActorPropertyIndices, image_actor_test_startup, image_actor_test_cleanup}, + {"UtcDaliImageAttributesConstructor", UtcDaliImageAttributesConstructor, utc_dali_image_attributes_startup, utc_dali_image_attributes_cleanup}, + {"UtcDaliImageAttributesLessThan", UtcDaliImageAttributesLessThan, utc_dali_image_attributes_startup, utc_dali_image_attributes_cleanup}, + {"UtcDaliImageAttributesEquality", UtcDaliImageAttributesEquality, utc_dali_image_attributes_startup, utc_dali_image_attributes_cleanup}, + {"UtcDaliImageAttributesInEquality", UtcDaliImageAttributesInEquality, utc_dali_image_attributes_startup, utc_dali_image_attributes_cleanup}, + {"UtcDaliKeyEventConstructor", UtcDaliKeyEventConstructor, utc_dali_key_event_startup, utc_dali_key_event_cleanup}, + {"UtcDaliKeyEventIsShiftModifier", UtcDaliKeyEventIsShiftModifier, utc_dali_key_event_startup, utc_dali_key_event_cleanup}, + {"UtcDaliKeyEventIsCtrlModifier", UtcDaliKeyEventIsCtrlModifier, utc_dali_key_event_startup, utc_dali_key_event_cleanup}, + {"UtcDaliKeyEventIsAltModifier", UtcDaliKeyEventIsAltModifier, utc_dali_key_event_startup, utc_dali_key_event_cleanup}, + {"UtcDaliKeyEventIsNotShiftModifier", UtcDaliKeyEventIsNotShiftModifier, utc_dali_key_event_startup, utc_dali_key_event_cleanup}, + {"UtcDaliKeyEventIsNotCtrlModifier", UtcDaliKeyEventIsNotCtrlModifier, utc_dali_key_event_startup, utc_dali_key_event_cleanup}, + {"UtcDaliKeyEventIsNotAltModifier", UtcDaliKeyEventIsNotAltModifier, utc_dali_key_event_startup, utc_dali_key_event_cleanup}, + {"UtcDaliKeyEventANDModifer", UtcDaliKeyEventANDModifer, utc_dali_key_event_startup, utc_dali_key_event_cleanup}, + {"UtcDaliKeyEventORModifer", UtcDaliKeyEventORModifer, utc_dali_key_event_startup, utc_dali_key_event_cleanup}, + {"UtcDaliKeyEventState", UtcDaliKeyEventState, utc_dali_key_event_startup, utc_dali_key_event_cleanup}, + {"UtcDaliIntegrationKeyEvent", UtcDaliIntegrationKeyEvent, utc_dali_key_event_startup, utc_dali_key_event_cleanup}, + {"UtcDaliLayerNew", UtcDaliLayerNew, layer_test_startup, layer_test_cleanup}, + {"UtcDaliLayerDownCast", UtcDaliLayerDownCast, layer_test_startup, layer_test_cleanup}, + {"UtcDaliLayerDownCast2", UtcDaliLayerDownCast2, layer_test_startup, layer_test_cleanup}, + {"UtcDaliLayerGetDepth", UtcDaliLayerGetDepth, layer_test_startup, layer_test_cleanup}, + {"UtcDaliLayerRaise", UtcDaliLayerRaise, layer_test_startup, layer_test_cleanup}, + {"UtcDaliLayerLower", UtcDaliLayerLower, layer_test_startup, layer_test_cleanup}, + {"UtcDaliLayerRaiseToTop", UtcDaliLayerRaiseToTop, layer_test_startup, layer_test_cleanup}, + {"UtcDaliLayerLowerToBottom", UtcDaliLayerLowerToBottom, layer_test_startup, layer_test_cleanup}, + {"UtcDaliLayerSetClipping", UtcDaliLayerSetClipping, layer_test_startup, layer_test_cleanup}, + {"UtcDaliLayerIsClipping", UtcDaliLayerIsClipping, layer_test_startup, layer_test_cleanup}, + {"UtcDaliLayerSetClippingBox", UtcDaliLayerSetClippingBox, layer_test_startup, layer_test_cleanup}, + {"UtcDaliLayerGetClippingBox", UtcDaliLayerGetClippingBox, layer_test_startup, layer_test_cleanup}, + {"UtcDaliLayerSetSortFunction", UtcDaliLayerSetSortFunction, layer_test_startup, layer_test_cleanup}, + {"UtcDaliLayerRaiseAbove", UtcDaliLayerRaiseAbove, layer_test_startup, layer_test_cleanup}, + {"UtcDaliLayerRaiseBelow", UtcDaliLayerRaiseBelow, layer_test_startup, layer_test_cleanup}, + {"UtcDaliLayerMoveAbove", UtcDaliLayerMoveAbove, layer_test_startup, layer_test_cleanup}, + {"UtcDaliLayerMoveBelow", UtcDaliLayerMoveBelow, layer_test_startup, layer_test_cleanup}, + {"UtcDaliLayerDefaultProperties", UtcDaliLayerDefaultProperties, layer_test_startup, layer_test_cleanup}, + {"UtcDaliLayerSetDepthTestDisabled", UtcDaliLayerSetDepthTestDisabled, layer_test_startup, layer_test_cleanup}, + {"UtcDaliLayerCreateDestroy", UtcDaliLayerCreateDestroy, layer_test_startup, layer_test_cleanup}, + {"UtcDaliLayerPropertyIndices", UtcDaliLayerPropertyIndices, layer_test_startup, layer_test_cleanup}, + {"UtcDaliLongPressGestureConstructor", UtcDaliLongPressGestureConstructor, utc_dali_long_press_gesture_startup, utc_dali_long_press_gesture_cleanup}, + {"UtcDaliLongPressGestureAssignment", UtcDaliLongPressGestureAssignment, utc_dali_long_press_gesture_startup, utc_dali_long_press_gesture_cleanup}, + {"UtcDaliLongPressGestureDetectorConstructor", UtcDaliLongPressGestureDetectorConstructor, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGestureDetectorNew", UtcDaliLongPressGestureDetectorNew, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGestureDetectorDownCast", UtcDaliLongPressGestureDetectorDownCast, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGestureSetTouchesRequired01", UtcDaliLongPressGestureSetTouchesRequired01, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGestureSetTouchesRequired02", UtcDaliLongPressGestureSetTouchesRequired02, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGestureGetMinimumTouchesRequired", UtcDaliLongPressGestureGetMinimumTouchesRequired, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGestureGetMaximumTouchesRequired", UtcDaliLongPressGestureGetMaximumTouchesRequired, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGestureSignalReceptionNegative", UtcDaliLongPressGestureSignalReceptionNegative, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGestureSignalReceptionPositive", UtcDaliLongPressGestureSignalReceptionPositive, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGestureSignalReceptionDetach", UtcDaliLongPressGestureSignalReceptionDetach, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGestureSignalReceptionActorDestroyedDuringLongPress", UtcDaliLongPressGestureSignalReceptionActorDestroyedDuringLongPress, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGestureSignalReceptionRotatedActor", UtcDaliLongPressGestureSignalReceptionRotatedActor, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGestureSignalReceptionChildHit", UtcDaliLongPressGestureSignalReceptionChildHit, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGestureSignalReceptionAttachDetachMany", UtcDaliLongPressGestureSignalReceptionAttachDetachMany, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGestureSignalReceptionActorBecomesUntouchable", UtcDaliLongPressGestureSignalReceptionActorBecomesUntouchable, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGestureSignalReceptionMultipleGestureDetectors", UtcDaliLongPressGestureSignalReceptionMultipleGestureDetectors, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGestureSignalReceptionMultipleDetectorsOnActor", UtcDaliLongPressGestureSignalReceptionMultipleDetectorsOnActor, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGestureSignalReceptionDifferentPossible", UtcDaliLongPressGestureSignalReceptionDifferentPossible, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGestureEmitIncorrecteStateClear", UtcDaliLongPressGestureEmitIncorrecteStateClear, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGestureEmitIncorrectStateContinuing", UtcDaliLongPressGestureEmitIncorrectStateContinuing, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGestureRepeatedState", UtcDaliLongPressGestureRepeatedState, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGesturePossibleCancelled", UtcDaliLongPressGesturePossibleCancelled, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGestureDetachAfterStarted", UtcDaliLongPressGestureDetachAfterStarted, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGestureActorUnstaged", UtcDaliLongPressGestureActorUnstaged, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGestureActorStagedAndDestroyed", UtcDaliLongPressGestureActorStagedAndDestroyed, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliLongPressGestureSystemOverlay", UtcDaliLongPressGestureSystemOverlay, utc_dali_long_press_gesture_detector_startup, utc_dali_long_press_gesture_detector_cleanup}, + {"UtcDaliMaterialNew01", UtcDaliMaterialNew01, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliMaterialDownCast", UtcDaliMaterialDownCast, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliMaterialSettersAndGetters", UtcDaliMaterialSettersAndGetters, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliMaterialStage01", UtcDaliMaterialStage01, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliMaterialStage01MemCheck", UtcDaliMaterialStage01MemCheck, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliMaterialStage02", UtcDaliMaterialStage02, utc_dali_material_startup, utc_dali_material_cleanup}, + {"UtcDaliMathUtilsNextPowerOfTwo", UtcDaliMathUtilsNextPowerOfTwo, utc_dali_math_utils_startup, utc_dali_math_utils_cleanup}, + {"UtcDaliMathUtilsIsPowerOfTwo", UtcDaliMathUtilsIsPowerOfTwo, utc_dali_math_utils_startup, utc_dali_math_utils_cleanup}, + {"UtcDaliMathUtilsGetRangedEpsilon", UtcDaliMathUtilsGetRangedEpsilon, utc_dali_math_utils_startup, utc_dali_math_utils_cleanup}, + {"UtcDaliMathUtilsRound", UtcDaliMathUtilsRound, utc_dali_math_utils_startup, utc_dali_math_utils_cleanup}, + {"UtcDaliMathUtilsClamp", UtcDaliMathUtilsClamp, utc_dali_math_utils_startup, utc_dali_math_utils_cleanup}, + {"UtcDaliMathUtilsWrapInDomain", UtcDaliMathUtilsWrapInDomain, utc_dali_math_utils_startup, utc_dali_math_utils_cleanup}, + {"UtcDaliMathUtilsShortestDistanceInDomain", UtcDaliMathUtilsShortestDistanceInDomain, utc_dali_math_utils_startup, utc_dali_math_utils_cleanup}, + {"UtcDaliMathUtilsEquals", UtcDaliMathUtilsEquals, utc_dali_math_utils_startup, utc_dali_math_utils_cleanup}, + {"UtcDaliMatrixCtor", UtcDaliMatrixCtor, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixOrthoNormalize0", UtcDaliMatrixOrthoNormalize0, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixOrthoNormalize1", UtcDaliMatrixOrthoNormalize1, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixInvert01", UtcDaliMatrixInvert01, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixInvert02", UtcDaliMatrixInvert02, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixInvertTransform01", UtcDaliMatrixInvertTransform01, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixInvertTransform02", UtcDaliMatrixInvertTransform02, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixGetXAxis", UtcDaliMatrixGetXAxis, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixGetYAxis", UtcDaliMatrixGetYAxis, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixGetZAxis", UtcDaliMatrixGetZAxis, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixGetTranslation", UtcDaliMatrixGetTranslation, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixGetTranslation3", UtcDaliMatrixGetTranslation3, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixSetIdentity", UtcDaliMatrixSetIdentity, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixSetIdentityAndScale", UtcDaliMatrixSetIdentityAndScale, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixSetXAxis", UtcDaliMatrixSetXAxis, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixSetYAxis", UtcDaliMatrixSetYAxis, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixSetZAxis", UtcDaliMatrixSetZAxis, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixSetTranslation", UtcDaliMatrixSetTranslation, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixSetTranslation3", UtcDaliMatrixSetTranslation3, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixTranspose", UtcDaliMatrixTranspose, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixOStreamOperator", UtcDaliMatrixOStreamOperator, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixMultiply", UtcDaliMatrixMultiply, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixOperatorMultiply", UtcDaliMatrixOperatorMultiply, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixOperatorMultiply02", UtcDaliMatrixOperatorMultiply02, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixOperatorEquals", UtcDaliMatrixOperatorEquals, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixOperatorNotEquals", UtcDaliMatrixOperatorNotEquals, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixGetTransformComponents01", UtcDaliMatrixGetTransformComponents01, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixGetTransformComponents02", UtcDaliMatrixGetTransformComponents02, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixSetTransformComponents01", UtcDaliMatrixSetTransformComponents01, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixSetInverseTransformComponent01", UtcDaliMatrixSetInverseTransformComponent01, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrixSetInverseTransformComponent02", UtcDaliMatrixSetInverseTransformComponent02, utc_dali_matrix_startup, utc_dali_matrix_cleanup}, + {"UtcDaliMatrix3FromMatrix", UtcDaliMatrix3FromMatrix, utc_dali_matrix3_startup, utc_dali_matrix3_cleanup}, + {"UtcDaliMatrix3OperatorAssign01", UtcDaliMatrix3OperatorAssign01, utc_dali_matrix3_startup, utc_dali_matrix3_cleanup}, + {"UtcDaliMatrix3OperatorAssign02", UtcDaliMatrix3OperatorAssign02, utc_dali_matrix3_startup, utc_dali_matrix3_cleanup}, + {"UtcDaliMatrix3AsFloat", UtcDaliMatrix3AsFloat, utc_dali_matrix3_startup, utc_dali_matrix3_cleanup}, + {"UtcDaliMatrix3Invert", UtcDaliMatrix3Invert, utc_dali_matrix3_startup, utc_dali_matrix3_cleanup}, + {"UtcDaliMatrix3Transpose", UtcDaliMatrix3Transpose, utc_dali_matrix3_startup, utc_dali_matrix3_cleanup}, + {"UtcDaliMatrix3SetIdentity", UtcDaliMatrix3SetIdentity, utc_dali_matrix3_startup, utc_dali_matrix3_cleanup}, + {"UtcDaliMatrix3Scale", UtcDaliMatrix3Scale, utc_dali_matrix3_startup, utc_dali_matrix3_cleanup}, + {"UtcDaliMatrix3Magnitude", UtcDaliMatrix3Magnitude, utc_dali_matrix3_startup, utc_dali_matrix3_cleanup}, + {"UtcDaliMatrix3ScaleInverseTranspose", UtcDaliMatrix3ScaleInverseTranspose, utc_dali_matrix3_startup, utc_dali_matrix3_cleanup}, + {"UtcDaliMatrix3OStreamOperator", UtcDaliMatrix3OStreamOperator, utc_dali_matrix3_startup, utc_dali_matrix3_cleanup}, + {"UtcDaliMatrix3Multiply", UtcDaliMatrix3Multiply, utc_dali_matrix3_startup, utc_dali_matrix3_cleanup}, + {"UtcDaliMatrix3EqualityOperator", UtcDaliMatrix3EqualityOperator, utc_dali_matrix3_startup, utc_dali_matrix3_cleanup}, + {"UtcDaliMatrix3InequalityOperator", UtcDaliMatrix3InequalityOperator, utc_dali_matrix3_startup, utc_dali_matrix3_cleanup}, + {"UtcDaliMeshActorConstructorVoid", UtcDaliMeshActorConstructorVoid, mesh_actor_test_startup, mesh_actor_test_cleanup}, + {"UtcDaliMeshActorNew01", UtcDaliMeshActorNew01, mesh_actor_test_startup, mesh_actor_test_cleanup}, + {"UtcDaliMeshActorIndices", UtcDaliMeshActorIndices, mesh_actor_test_startup, mesh_actor_test_cleanup}, + {"UtcDaliPanGestureConstructor", UtcDaliPanGestureConstructor, utc_dali_pan_gesture_startup, utc_dali_pan_gesture_cleanup}, + {"UtcDaliPanGestureAssignment", UtcDaliPanGestureAssignment, utc_dali_pan_gesture_startup, utc_dali_pan_gesture_cleanup}, + {"UtcDaliPanGestureGetSpeed", UtcDaliPanGestureGetSpeed, utc_dali_pan_gesture_startup, utc_dali_pan_gesture_cleanup}, + {"UtcDaliPanGestureGetDistance", UtcDaliPanGestureGetDistance, utc_dali_pan_gesture_startup, utc_dali_pan_gesture_cleanup}, + {"UtcDaliPanGestureGetScreenSpeed", UtcDaliPanGestureGetScreenSpeed, utc_dali_pan_gesture_startup, utc_dali_pan_gesture_cleanup}, + {"UtcDaliPanGestureGetScreenDistance", UtcDaliPanGestureGetScreenDistance, utc_dali_pan_gesture_startup, utc_dali_pan_gesture_cleanup}, + {"UtcDaliPanGestureDetectorConstructor", UtcDaliPanGestureDetectorConstructor, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureDetectorNew", UtcDaliPanGestureDetectorNew, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureDetectorDownCast", UtcDaliPanGestureDetectorDownCast, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureSetMinimumTouchesRequired", UtcDaliPanGestureSetMinimumTouchesRequired, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureSetMaximumTouchesRequired", UtcDaliPanGestureSetMaximumTouchesRequired, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureGetMinimumTouchesRequired", UtcDaliPanGestureGetMinimumTouchesRequired, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureGetMaximumTouchesRequired", UtcDaliPanGestureGetMaximumTouchesRequired, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureSignalReceptionNegative", UtcDaliPanGestureSignalReceptionNegative, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureSignalReceptionDownMotionLeave", UtcDaliPanGestureSignalReceptionDownMotionLeave, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureSignalReceptionDownMotionUp", UtcDaliPanGestureSignalReceptionDownMotionUp, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureSignalReceptionCancelled", UtcDaliPanGestureSignalReceptionCancelled, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureSignalReceptionDetach", UtcDaliPanGestureSignalReceptionDetach, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureSignalReceptionDetachWhilePanning", UtcDaliPanGestureSignalReceptionDetachWhilePanning, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureSignalReceptionActorDestroyedWhilePanning", UtcDaliPanGestureSignalReceptionActorDestroyedWhilePanning, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureSignalReceptionRotatedActor", UtcDaliPanGestureSignalReceptionRotatedActor, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureSignalReceptionChildHit", UtcDaliPanGestureSignalReceptionChildHit, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureSignalReceptionAttachDetachMany", UtcDaliPanGestureSignalReceptionAttachDetachMany, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureSignalReceptionActorBecomesUntouchable", UtcDaliPanGestureSignalReceptionActorBecomesUntouchable, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureSignalReceptionMultipleGestureDetectors", UtcDaliPanGestureSignalReceptionMultipleGestureDetectors, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureSignalReceptionMultipleDetectorsOnActor", UtcDaliPanGestureSignalReceptionMultipleDetectorsOnActor, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureSignalReceptionMultipleStarted", UtcDaliPanGestureSignalReceptionMultipleStarted, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureSignalReceptionEnsureCorrectSignalling", UtcDaliPanGestureSignalReceptionEnsureCorrectSignalling, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureSignalReceptionDifferentPossible", UtcDaliPanGestureSignalReceptionDifferentPossible, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureEmitIncorrectState", UtcDaliPanGestureEmitIncorrectState, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureActorUnstaged", UtcDaliPanGestureActorUnstaged, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureActorStagedAndDestroyed", UtcDaliPanGestureActorStagedAndDestroyed, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureSystemOverlay", UtcDaliPanGestureSystemOverlay, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureAngleHandling", UtcDaliPanGestureAngleHandling, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureAngleOutOfRange", UtcDaliPanGestureAngleOutOfRange, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureAngleProcessing", UtcDaliPanGestureAngleProcessing, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureDirectionHandling", UtcDaliPanGestureDirectionHandling, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureDirectionProcessing", UtcDaliPanGestureDirectionProcessing, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureSetProperties", UtcDaliPanGestureSetProperties, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGestureSetPropertiesAlreadyPanning", UtcDaliPanGestureSetPropertiesAlreadyPanning, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPanGesturePropertyIndices", UtcDaliPanGesturePropertyIndices, utc_dali_pan_gesture_detector_startup, utc_dali_pan_gesture_detector_cleanup}, + {"UtcDaliPinchGestureConstructor", UtcDaliPinchGestureConstructor, utc_dali_pinch_gesture_startup, utc_dali_pinch_gesture_cleanup}, + {"UtcDaliPinchGestureAssignment", UtcDaliPinchGestureAssignment, utc_dali_pinch_gesture_startup, utc_dali_pinch_gesture_cleanup}, + {"UtcDaliPinchGestureDetectorConstructor", UtcDaliPinchGestureDetectorConstructor, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup}, + {"UtcDaliPinchGestureDetectorNew", UtcDaliPinchGestureDetectorNew, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup}, + {"UtcDaliPinchGestureDetectorDownCast", UtcDaliPinchGestureDetectorDownCast, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup}, + {"UtcDaliPinchGestureSignalReceptionNegative", UtcDaliPinchGestureSignalReceptionNegative, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup}, + {"UtcDaliPinchGestureSignalReceptionDownMotionLeave", UtcDaliPinchGestureSignalReceptionDownMotionLeave, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup}, + {"UtcDaliPinchGestureSignalReceptionDownMotionUp", UtcDaliPinchGestureSignalReceptionDownMotionUp, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup}, + {"UtcDaliPinchGestureSignalReceptionCancelled", UtcDaliPinchGestureSignalReceptionCancelled, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup}, + {"UtcDaliPinchGestureSignalReceptionDetach", UtcDaliPinchGestureSignalReceptionDetach, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup}, + {"UtcDaliPinchGestureSignalReceptionDetachWhilePinching", UtcDaliPinchGestureSignalReceptionDetachWhilePinching, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup}, + {"UtcDaliPinchGestureSignalReceptionActorDestroyedWhilePinching", UtcDaliPinchGestureSignalReceptionActorDestroyedWhilePinching, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup}, + {"UtcDaliPinchGestureSignalReceptionRotatedActor", UtcDaliPinchGestureSignalReceptionRotatedActor, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup}, + {"UtcDaliPinchGestureSignalReceptionChildHit", UtcDaliPinchGestureSignalReceptionChildHit, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup}, + {"UtcDaliPinchGestureSignalReceptionAttachDetachMany", UtcDaliPinchGestureSignalReceptionAttachDetachMany, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup}, + {"UtcDaliPinchGestureSignalReceptionActorBecomesUntouchable", UtcDaliPinchGestureSignalReceptionActorBecomesUntouchable, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup}, + {"UtcDaliPinchGestureSignalReceptionMultipleDetectorsOnActor", UtcDaliPinchGestureSignalReceptionMultipleDetectorsOnActor, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup}, + {"UtcDaliPinchGestureSignalReceptionMultipleStarted", UtcDaliPinchGestureSignalReceptionMultipleStarted, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup}, + {"UtcDaliPinchGestureSignalReceptionEnsureCorrectSignalling", UtcDaliPinchGestureSignalReceptionEnsureCorrectSignalling, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup}, + {"UtcDaliPinchGestureEmitIncorrectStateClear", UtcDaliPinchGestureEmitIncorrectStateClear, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup}, + {"UtcDaliPinchGestureEmitIncorrectStatePossible", UtcDaliPinchGestureEmitIncorrectStatePossible, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup}, + {"UtcDaliPinchGestureActorUnstaged", UtcDaliPinchGestureActorUnstaged, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup}, + {"UtcDaliPinchGestureActorStagedAndDestroyed", UtcDaliPinchGestureActorStagedAndDestroyed, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup}, + {"UtcDaliPinchGestureSystemOverlay", UtcDaliPinchGestureSystemOverlay, utc_dali_pinch_gesture_detector_startup, utc_dali_pinch_gesture_detector_cleanup}, + {"UtcDaliPixelHasAlpha", UtcDaliPixelHasAlpha, utc_dali_pixel_startup, utc_dali_pixel_cleanup}, + {"UtcDaliPixelGetBytesPerPixel", UtcDaliPixelGetBytesPerPixel, utc_dali_pixel_startup, utc_dali_pixel_cleanup}, + {"UtcDaliPixelGetAlphaOffsetAndMask", UtcDaliPixelGetAlphaOffsetAndMask, utc_dali_pixel_startup, utc_dali_pixel_cleanup}, + {"UtcDaliPropertyNotificationDownCast", UtcDaliPropertyNotificationDownCast, utc_dali_property_notification_startup, utc_dali_property_notification_cleanup}, + {"UtcDaliPropertyNotificationDownCastNegative", UtcDaliPropertyNotificationDownCastNegative, utc_dali_property_notification_startup, utc_dali_property_notification_cleanup}, + {"UtcDaliAddPropertyNotification", UtcDaliAddPropertyNotification, utc_dali_property_notification_startup, utc_dali_property_notification_cleanup}, + {"UtcDaliAddPropertyNotificationCallback", UtcDaliAddPropertyNotificationCallback, utc_dali_property_notification_startup, utc_dali_property_notification_cleanup}, + {"UtcDaliAddPropertyNotificationTypeProperty", UtcDaliAddPropertyNotificationTypeProperty, utc_dali_property_notification_startup, utc_dali_property_notification_cleanup}, + {"UtcDaliPropertyNotificationGetCondition", UtcDaliPropertyNotificationGetCondition, utc_dali_property_notification_startup, utc_dali_property_notification_cleanup}, + {"UtcDaliPropertyNotificationGetConditionConst", UtcDaliPropertyNotificationGetConditionConst, utc_dali_property_notification_startup, utc_dali_property_notification_cleanup}, + {"UtcDaliPropertyNotificationGetTarget", UtcDaliPropertyNotificationGetTarget, utc_dali_property_notification_startup, utc_dali_property_notification_cleanup}, + {"UtcDaliPropertyNotificationGetProperty", UtcDaliPropertyNotificationGetProperty, utc_dali_property_notification_startup, utc_dali_property_notification_cleanup}, + {"UtcDaliPropertyNotificationGetNotifyMode", UtcDaliPropertyNotificationGetNotifyMode, utc_dali_property_notification_startup, utc_dali_property_notification_cleanup}, + {"UtcDaliPropertyNotificationGreaterThan", UtcDaliPropertyNotificationGreaterThan, utc_dali_property_notification_startup, utc_dali_property_notification_cleanup}, + {"UtcDaliPropertyNotificationLessThan", UtcDaliPropertyNotificationLessThan, utc_dali_property_notification_startup, utc_dali_property_notification_cleanup}, + {"UtcDaliPropertyNotificationInside", UtcDaliPropertyNotificationInside, utc_dali_property_notification_startup, utc_dali_property_notification_cleanup}, + {"UtcDaliPropertyNotificationOutside", UtcDaliPropertyNotificationOutside, utc_dali_property_notification_startup, utc_dali_property_notification_cleanup}, + {"UtcDaliPropertyNotificationVectorComponentGreaterThan", UtcDaliPropertyNotificationVectorComponentGreaterThan, utc_dali_property_notification_startup, utc_dali_property_notification_cleanup}, + {"UtcDaliPropertyNotificationVectorComponentLessThan", UtcDaliPropertyNotificationVectorComponentLessThan, utc_dali_property_notification_startup, utc_dali_property_notification_cleanup}, + {"UtcDaliPropertyNotificationVectorComponentInside", UtcDaliPropertyNotificationVectorComponentInside, utc_dali_property_notification_startup, utc_dali_property_notification_cleanup}, + {"UtcDaliPropertyNotificationVectorComponentOutside", UtcDaliPropertyNotificationVectorComponentOutside, utc_dali_property_notification_startup, utc_dali_property_notification_cleanup}, + {"UtcDaliPropertyConditionGetArguments", UtcDaliPropertyConditionGetArguments, utc_dali_property_notification_startup, utc_dali_property_notification_cleanup}, + {"UtcDaliPropertyConditionGetArgumentsConst", UtcDaliPropertyConditionGetArgumentsConst, utc_dali_property_notification_startup, utc_dali_property_notification_cleanup}, + {"UtcDaliPropertyNotificationStep", UtcDaliPropertyNotificationStep, utc_dali_property_notification_startup, utc_dali_property_notification_cleanup}, + {"UtcDaliPropertyNotificationVariableStep", UtcDaliPropertyNotificationVariableStep, utc_dali_property_notification_startup, utc_dali_property_notification_cleanup}, + {"UtcDaliQuaternionCtor01", UtcDaliQuaternionCtor01, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionCtor02", UtcDaliQuaternionCtor02, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionCtor03", UtcDaliQuaternionCtor03, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionFromAxisAngle", UtcDaliQuaternionFromAxisAngle, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionToAxisAngle01", UtcDaliQuaternionToAxisAngle01, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionToAxisAngle02", UtcDaliQuaternionToAxisAngle02, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionToAxisAngle03", UtcDaliQuaternionToAxisAngle03, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionToAxisAngle04", UtcDaliQuaternionToAxisAngle04, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionEulerAngles", UtcDaliQuaternionEulerAngles, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionToMatrix01", UtcDaliQuaternionToMatrix01, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionToMatrix02", UtcDaliQuaternionToMatrix02, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionFromMatrix01", UtcDaliQuaternionFromMatrix01, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionFromMatrix02", UtcDaliQuaternionFromMatrix02, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionFromAxes01", UtcDaliQuaternionFromAxes01, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionFromAxes02", UtcDaliQuaternionFromAxes02, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionOperatorAddition", UtcDaliQuaternionOperatorAddition, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionOperatorSubtraction", UtcDaliQuaternionOperatorSubtraction, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionConjugate", UtcDaliQuaternionConjugate, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionOperatorMultiplication01", UtcDaliQuaternionOperatorMultiplication01, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionOperatorDivision", UtcDaliQuaternionOperatorDivision, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionOperatorScale01", UtcDaliQuaternionOperatorScale01, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionOperatorScale02", UtcDaliQuaternionOperatorScale02, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionOperatorNegation", UtcDaliQuaternionOperatorNegation, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionOperatorAddAssign", UtcDaliQuaternionOperatorAddAssign, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionOperatorSubtractAssign", UtcDaliQuaternionOperatorSubtractAssign, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionOperatorMultiplyAssign", UtcDaliQuaternionOperatorMultiplyAssign, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionOperatorScaleAssign01", UtcDaliQuaternionOperatorScaleAssign01, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionOperatorScaleAssign02", UtcDaliQuaternionOperatorScaleAssign02, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionOperatorEquality", UtcDaliQuaternionOperatorEquality, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionOperatorInequality", UtcDaliQuaternionOperatorInequality, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionLength", UtcDaliQuaternionLength, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionLengthSquared", UtcDaliQuaternionLengthSquared, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionNormalize", UtcDaliQuaternionNormalize, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionNormalized", UtcDaliQuaternionNormalized, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionInvert", UtcDaliQuaternionInvert, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionDot", UtcDaliQuaternionDot, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionOperatorMultiplication02", UtcDaliQuaternionOperatorMultiplication02, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionRotate01", UtcDaliQuaternionRotate01, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionRotate02", UtcDaliQuaternionRotate02, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionExp01", UtcDaliQuaternionExp01, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionExp02", UtcDaliQuaternionExp02, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionExp03", UtcDaliQuaternionExp03, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionLog01", UtcDaliQuaternionLog01, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionLog02", UtcDaliQuaternionLog02, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionLerp", UtcDaliQuaternionLerp, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionSlerp01", UtcDaliQuaternionSlerp01, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionSlerp02", UtcDaliQuaternionSlerp02, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionSlerp03", UtcDaliQuaternionSlerp03, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionSlerp04", UtcDaliQuaternionSlerp04, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionSlerpNoInvert01", UtcDaliQuaternionSlerpNoInvert01, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionSlerpNoInvert02", UtcDaliQuaternionSlerpNoInvert02, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionSquad", UtcDaliQuaternionSquad, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliAngleBetween", UtcDaliAngleBetween, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliQuaternionOStreamOperator", UtcDaliQuaternionOStreamOperator, utc_dali_quaternion_startup, utc_dali_quaternion_cleanup}, + {"UtcDaliRadianConstructors01", UtcDaliRadianConstructors01, utc_dali_radian_startup, utc_dali_radian_cleanup}, + {"UtcDaliRadianComparison01", UtcDaliRadianComparison01, utc_dali_radian_startup, utc_dali_radian_cleanup}, + {"UtcDaliRadianCastOperators01", UtcDaliRadianCastOperators01, utc_dali_radian_startup, utc_dali_radian_cleanup}, + {"UtcDaliRadianCastOperatorEquals", UtcDaliRadianCastOperatorEquals, utc_dali_radian_startup, utc_dali_radian_cleanup}, + {"UtcDaliRadianCastOperatorNotEquals", UtcDaliRadianCastOperatorNotEquals, utc_dali_radian_startup, utc_dali_radian_cleanup}, + {"UtcDaliRadianCastOperatorLessThan", UtcDaliRadianCastOperatorLessThan, utc_dali_radian_startup, utc_dali_radian_cleanup}, + {"UtcDaliRectCons01", UtcDaliRectCons01, utc_dali_rect_startup, utc_dali_rect_cleanup}, + {"UtcDaliRectCons02", UtcDaliRectCons02, utc_dali_rect_startup, utc_dali_rect_cleanup}, + {"UtcDaliRectCons03", UtcDaliRectCons03, utc_dali_rect_startup, utc_dali_rect_cleanup}, + {"UtcDaliRectCons04", UtcDaliRectCons04, utc_dali_rect_startup, utc_dali_rect_cleanup}, + {"UtcDaliRectSet", UtcDaliRectSet, utc_dali_rect_startup, utc_dali_rect_cleanup}, + {"UtcDaliRectIsEmpty", UtcDaliRectIsEmpty, utc_dali_rect_startup, utc_dali_rect_cleanup}, + {"UtcDaliRectRight", UtcDaliRectRight, utc_dali_rect_startup, utc_dali_rect_cleanup}, + {"UtcDaliRectBottom", UtcDaliRectBottom, utc_dali_rect_startup, utc_dali_rect_cleanup}, + {"UtcDaliRectArea", UtcDaliRectArea, utc_dali_rect_startup, utc_dali_rect_cleanup}, + {"UtcDaliRectIntersects", UtcDaliRectIntersects, utc_dali_rect_startup, utc_dali_rect_cleanup}, + {"UtcDaliRectContains", UtcDaliRectContains, utc_dali_rect_startup, utc_dali_rect_cleanup}, + {"UtcDaliRectOperatorNotEquals", UtcDaliRectOperatorNotEquals, utc_dali_rect_startup, utc_dali_rect_cleanup}, + {"UtcDaliRectOperatorEquals", UtcDaliRectOperatorEquals, utc_dali_rect_startup, utc_dali_rect_cleanup}, + {"UtcDaliRenderTaskDownCast", UtcDaliRenderTaskDownCast, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskSetSourceActor", UtcDaliRenderTaskSetSourceActor, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskSetSourceActorOffStage", UtcDaliRenderTaskSetSourceActorOffStage, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskSetSourceActorEmpty", UtcDaliRenderTaskSetSourceActorEmpty, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskGetSourceActor", UtcDaliRenderTaskGetSourceActor, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskSetExclusive", UtcDaliRenderTaskSetExclusive, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskIsExclusive", UtcDaliRenderTaskIsExclusive, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskSetInputEnabled", UtcDaliRenderTaskSetInputEnabled, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskGetInputEnabled", UtcDaliRenderTaskGetInputEnabled, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskSetCameraActor", UtcDaliRenderTaskSetCameraActor, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskGetCameraActor", UtcDaliRenderTaskGetCameraActor, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskSetTargetFrameBuffer", UtcDaliRenderTaskSetTargetFrameBuffer, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskGetTargetFrameBuffer", UtcDaliRenderTaskGetTargetFrameBuffer, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskSetScreenToFrameBufferFunction", UtcDaliRenderTaskSetScreenToFrameBufferFunction, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskGetScreenToFrameBufferFunction", UtcDaliRenderTaskGetScreenToFrameBufferFunction, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskGetScreenToFrameBufferMappingActor", UtcDaliRenderTaskGetScreenToFrameBufferMappingActor, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskSetViewport", UtcDaliRenderTaskSetViewport, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskGetViewport", UtcDaliRenderTaskGetViewport, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskSetViewportPosition", UtcDaliRenderTaskSetViewportPosition, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskSetViewportSize", UtcDaliRenderTaskSetViewportSize, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskSetClearColor", UtcDaliRenderTaskSetClearColor, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskGetClearColor", UtcDaliRenderTaskGetClearColor, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskSetClearEnabled", UtcDaliRenderTaskSetClearEnabled, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskGetClearEnabled", UtcDaliRenderTaskGetClearEnabled, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskSetRefreshRate", UtcDaliRenderTaskSetRefreshRate, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskGetRefreshRate", UtcDaliRenderTaskGetRefreshRate, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskSignalFinished", UtcDaliRenderTaskSignalFinished, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskContinuous01", UtcDaliRenderTaskContinuous01, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskContinuous02", UtcDaliRenderTaskContinuous02, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskContinuous03", UtcDaliRenderTaskContinuous03, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskContinuous04", UtcDaliRenderTaskContinuous04, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskContinuous05", UtcDaliRenderTaskContinuous05, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskContinuous06", UtcDaliRenderTaskContinuous06, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskOnce01", UtcDaliRenderTaskOnce01, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskOnce02", UtcDaliRenderTaskOnce02, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskOnce03", UtcDaliRenderTaskOnce03, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskOnce05", UtcDaliRenderTaskOnce05, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskOnce06", UtcDaliRenderTaskOnce06, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskOnce07", UtcDaliRenderTaskOnce07, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskOnce08", UtcDaliRenderTaskOnce08, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskOnceNoSync01", UtcDaliRenderTaskOnceNoSync01, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskOnceNoSync02", UtcDaliRenderTaskOnceNoSync02, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskOnceNoSync03", UtcDaliRenderTaskOnceNoSync03, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskOnceNoSync05", UtcDaliRenderTaskOnceNoSync05, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskOnceNoSync06", UtcDaliRenderTaskOnceNoSync06, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskOnceNoSync07", UtcDaliRenderTaskOnceNoSync07, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskOnceNoSync08", UtcDaliRenderTaskOnceNoSync08, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskOnceChain01", UtcDaliRenderTaskOnceChain01, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskProperties", UtcDaliRenderTaskProperties, utc_dali_render_task_startup, utc_dali_render_task_cleanup}, + {"UtcDaliRenderTaskListDefaultConstructor", UtcDaliRenderTaskListDefaultConstructor, utc_dali_render_task_list_startup, utc_dali_render_task_list_cleanup}, + {"UtcDaliRenderTaskListDownCast", UtcDaliRenderTaskListDownCast, utc_dali_render_task_list_startup, utc_dali_render_task_list_cleanup}, + {"UtcDaliRenderTaskListCreateTask", UtcDaliRenderTaskListCreateTask, utc_dali_render_task_list_startup, utc_dali_render_task_list_cleanup}, + {"UtcDaliRenderTaskListRemoveTask", UtcDaliRenderTaskListRemoveTask, utc_dali_render_task_list_startup, utc_dali_render_task_list_cleanup}, + {"UtcDaliRenderTaskListGetTaskCount", UtcDaliRenderTaskListGetTaskCount, utc_dali_render_task_list_startup, utc_dali_render_task_list_cleanup}, + {"UtcDaliRenderTaskListGetTask", UtcDaliRenderTaskListGetTask, utc_dali_render_task_list_startup, utc_dali_render_task_list_cleanup}, + {"UtcDaliRenderableActorDownCast", UtcDaliRenderableActorDownCast, renderable_actor_startup, renderable_actor_cleanup}, + {"UtcDaliRenderableActorSetSortModifier", UtcDaliRenderableActorSetSortModifier, renderable_actor_startup, renderable_actor_cleanup}, + {"UtcDaliRenderableActorGetSortModifier", UtcDaliRenderableActorGetSortModifier, renderable_actor_startup, renderable_actor_cleanup}, + {"UtcDaliRenderableActorSetGetBlendMode", UtcDaliRenderableActorSetGetBlendMode, renderable_actor_startup, renderable_actor_cleanup}, + {"UtcDaliRenderableActorSetCullFace", UtcDaliRenderableActorSetCullFace, renderable_actor_startup, renderable_actor_cleanup}, + {"UtcDaliRenderableActorGetCullFace", UtcDaliRenderableActorGetCullFace, renderable_actor_startup, renderable_actor_cleanup}, + {"UtcDaliRenderableActorSetGetBlendFunc", UtcDaliRenderableActorSetGetBlendFunc, renderable_actor_startup, renderable_actor_cleanup}, + {"UtcDaliRenderableActorSetGetBlendEquation", UtcDaliRenderableActorSetGetBlendEquation, renderable_actor_startup, renderable_actor_cleanup}, + {"UtcDaliRenderableActorSetGetBlendColor", UtcDaliRenderableActorSetGetBlendColor, renderable_actor_startup, renderable_actor_cleanup}, + {"UtcDaliRenderableActorSetGetAlpha", UtcDaliRenderableActorSetGetAlpha, renderable_actor_startup, renderable_actor_cleanup}, + {"UtcDaliRenderableActorCreateDestroy", UtcDaliRenderableActorCreateDestroy, renderable_actor_startup, renderable_actor_cleanup}, + {"UtcDaliShaderEffectMethodNew01", UtcDaliShaderEffectMethodNew01, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodNew02", UtcDaliShaderEffectMethodNew02, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodNew03", UtcDaliShaderEffectMethodNew03, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodNew04", UtcDaliShaderEffectMethodNew04, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodNew05", UtcDaliShaderEffectMethodNew05, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodNew06", UtcDaliShaderEffectMethodNew06, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodDownCast", UtcDaliShaderEffectMethodDownCast, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodDelete01", UtcDaliShaderEffectMethodDelete01, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodSetUniformFloat", UtcDaliShaderEffectMethodSetUniformFloat, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodSetUniformVector2", UtcDaliShaderEffectMethodSetUniformVector2, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodSetUniformVector3", UtcDaliShaderEffectMethodSetUniformVector3, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodSetUniformVector4", UtcDaliShaderEffectMethodSetUniformVector4, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodSetUniformMatrix", UtcDaliShaderEffectMethodSetUniformMatrix, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodSetUniformMatrix3", UtcDaliShaderEffectMethodSetUniformMatrix3, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodSetUniformViewport", UtcDaliShaderEffectMethodSetUniformViewport, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodSetEffectImage", UtcDaliShaderEffectMethodSetEffectImage, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodSetEffectImageAndDelete", UtcDaliShaderEffectMethodSetEffectImageAndDelete, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodApplyConstraint", UtcDaliShaderEffectMethodApplyConstraint, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodApplyConstraintFromActor", UtcDaliShaderEffectMethodApplyConstraintFromActor, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodApplyConstraintFromActor2", UtcDaliShaderEffectMethodApplyConstraintFromActor2, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodApplyConstraintCallback", UtcDaliShaderEffectMethodApplyConstraintCallback, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodRemoveConstraints", UtcDaliShaderEffectMethodRemoveConstraints, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodRemoveConstraints2", UtcDaliShaderEffectMethodRemoveConstraints2, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodCreateExtension", UtcDaliShaderEffectMethodCreateExtension, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodCreateExtension2", UtcDaliShaderEffectMethodCreateExtension2, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectMethodNoExtension", UtcDaliShaderEffectMethodNoExtension, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliShaderEffectPropertyIndices", UtcDaliShaderEffectPropertyIndices, utc_dali_shader_effect_startup, utc_dali_shader_effect_cleanup}, + {"UtcDaliSignalFunctorsEmptyCheck", UtcDaliSignalFunctorsEmptyCheck, utc_dali_signal_templates_functors_startup, utc_dali_signal_templates_functors_cleanup}, + {"UtcDaliSignalFunctorsEmit", UtcDaliSignalFunctorsEmit, utc_dali_signal_templates_functors_startup, utc_dali_signal_templates_functors_cleanup}, + {"UtcDaliSignalFunctorsEmitReturn", UtcDaliSignalFunctorsEmitReturn, utc_dali_signal_templates_functors_startup, utc_dali_signal_templates_functors_cleanup}, + {"UtcDaliSignalFunctorsDisconnectBeforeEmit", UtcDaliSignalFunctorsDisconnectBeforeEmit, utc_dali_signal_templates_functors_startup, utc_dali_signal_templates_functors_cleanup}, + {"UtcDaliSignalFunctorsDestroySignal", UtcDaliSignalFunctorsDestroySignal, utc_dali_signal_templates_functors_startup, utc_dali_signal_templates_functors_cleanup}, + {"UtcDaliSignalConnectVoidFunctor", UtcDaliSignalConnectVoidFunctor, utc_dali_signal_templates_functors_startup, utc_dali_signal_templates_functors_cleanup}, + {"UtcDaliSignalEmptyCheck", UtcDaliSignalEmptyCheck, utc_dali_signal_templates_startup, utc_dali_signal_templates_cleanup}, + {"UtcDaliSignalEmptyCheckSlotDestruction", UtcDaliSignalEmptyCheckSlotDestruction, utc_dali_signal_templates_startup, utc_dali_signal_templates_cleanup}, + {"UtcDaliSignalConnectAndEmit", UtcDaliSignalConnectAndEmit, utc_dali_signal_templates_startup, utc_dali_signal_templates_cleanup}, + {"UtcDaliSignalDisconnect", UtcDaliSignalDisconnect, utc_dali_signal_templates_startup, utc_dali_signal_templates_cleanup}, + {"UtcDaliSignalDisconnect2", UtcDaliSignalDisconnect2, utc_dali_signal_templates_startup, utc_dali_signal_templates_cleanup}, + {"UtcDaliSignalDisconnect3", UtcDaliSignalDisconnect3, utc_dali_signal_templates_startup, utc_dali_signal_templates_cleanup}, + {"UtcDaliSignalCustomConnectionTracker", UtcDaliSignalCustomConnectionTracker, utc_dali_signal_templates_startup, utc_dali_signal_templates_cleanup}, + {"UtcDaliSignalMultipleConnections", UtcDaliSignalMultipleConnections, utc_dali_signal_templates_startup, utc_dali_signal_templates_cleanup}, + {"UtcDaliSignalMultipleConnections2", UtcDaliSignalMultipleConnections2, utc_dali_signal_templates_startup, utc_dali_signal_templates_cleanup}, + {"UtcDaliSignalMultipleConnections3", UtcDaliSignalMultipleConnections3, utc_dali_signal_templates_startup, utc_dali_signal_templates_cleanup}, + {"UtcDaliSignalDisconnectStatic", UtcDaliSignalDisconnectStatic, utc_dali_signal_templates_startup, utc_dali_signal_templates_cleanup}, + {"UtcDaliSignalDisconnectDuringCallback", UtcDaliSignalDisconnectDuringCallback, utc_dali_signal_templates_startup, utc_dali_signal_templates_cleanup}, + {"UtcDaliSignalDisconnectDuringCallback2", UtcDaliSignalDisconnectDuringCallback2, utc_dali_signal_templates_startup, utc_dali_signal_templates_cleanup}, + {"UtcDaliSignalEmitDuringCallback", UtcDaliSignalEmitDuringCallback, utc_dali_signal_templates_startup, utc_dali_signal_templates_cleanup}, + {"UtcDaliSignalTestApp01", UtcDaliSignalTestApp01, utc_dali_signal_templates_startup, utc_dali_signal_templates_cleanup}, + {"UtcDaliSignalTestApp02", UtcDaliSignalTestApp02, utc_dali_signal_templates_startup, utc_dali_signal_templates_cleanup}, + {"UtcDaliSignalTestApp03", UtcDaliSignalTestApp03, utc_dali_signal_templates_startup, utc_dali_signal_templates_cleanup}, + {"UtcDaliSignalTestApp04", UtcDaliSignalTestApp04, utc_dali_signal_templates_startup, utc_dali_signal_templates_cleanup}, + {"UtcDaliSignalTestApp05", UtcDaliSignalTestApp05, utc_dali_signal_templates_startup, utc_dali_signal_templates_cleanup}, + {"UtcDaliSignalTestApp06", UtcDaliSignalTestApp06, utc_dali_signal_templates_startup, utc_dali_signal_templates_cleanup}, + {"UtcDaliSlotDelegateConnection", UtcDaliSlotDelegateConnection, utc_dali_signal_templates_startup, utc_dali_signal_templates_cleanup}, + {"UtcDaliSignalSlotDelegateDestruction", UtcDaliSignalSlotDelegateDestruction, utc_dali_signal_templates_startup, utc_dali_signal_templates_cleanup}, + {"UtcDaliSlotHandlerDisconnect", UtcDaliSlotHandlerDisconnect, utc_dali_signal_templates_startup, utc_dali_signal_templates_cleanup}, + {"UtcDaliStageDefaultConstructor", UtcDaliStageDefaultConstructor, stage_test_startup, stage_test_cleanup}, + {"UtcDaliStageDestructor", UtcDaliStageDestructor, stage_test_startup, stage_test_cleanup}, + {"UtcDaliStageGetCurrent", UtcDaliStageGetCurrent, stage_test_startup, stage_test_cleanup}, + {"UtcDaliStageIsInstalled", UtcDaliStageIsInstalled, stage_test_startup, stage_test_cleanup}, + {"UtcDaliStageAdd", UtcDaliStageAdd, stage_test_startup, stage_test_cleanup}, + {"UtcDaliStageRemove", UtcDaliStageRemove, stage_test_startup, stage_test_cleanup}, + {"UtcDaliStageGetSize", UtcDaliStageGetSize, stage_test_startup, stage_test_cleanup}, + {"UtcDaliStageGetDpi01", UtcDaliStageGetDpi01, stage_test_startup, stage_test_cleanup}, + {"UtcDaliStageGetDpi02", UtcDaliStageGetDpi02, stage_test_startup, stage_test_cleanup}, + {"UtcDaliStageGetDpi03", UtcDaliStageGetDpi03, stage_test_startup, stage_test_cleanup}, + {"UtcDaliStageGetLayerCount", UtcDaliStageGetLayerCount, stage_test_startup, stage_test_cleanup}, + {"UtcDaliStageGetLayer", UtcDaliStageGetLayer, stage_test_startup, stage_test_cleanup}, + {"UtcDaliStageGetRootLayer", UtcDaliStageGetRootLayer, stage_test_startup, stage_test_cleanup}, + {"UtcDaliStageSetBackgroundColor", UtcDaliStageSetBackgroundColor, stage_test_startup, stage_test_cleanup}, + {"UtcDaliStageGetBackgroundColor", UtcDaliStageGetBackgroundColor, stage_test_startup, stage_test_cleanup}, + {"UtcDaliStageKeepRendering", UtcDaliStageKeepRendering, stage_test_startup, stage_test_cleanup}, + {"UtcDaliStageEventProcessingFinished", UtcDaliStageEventProcessingFinished, stage_test_startup, stage_test_cleanup}, + {"UtcDaliStageSignalKeyEvent", UtcDaliStageSignalKeyEvent, stage_test_startup, stage_test_cleanup}, + {"UtcDaliStageTouchedSignal", UtcDaliStageTouchedSignal, stage_test_startup, stage_test_cleanup}, + {"UtcDaliTapGestureConstructor", UtcDaliTapGestureConstructor, utc_dali_tap_gesture_startup, utc_dali_tap_gesture_cleanup}, + {"UtcDaliTapGestureAssignment", UtcDaliTapGestureAssignment, utc_dali_tap_gesture_startup, utc_dali_tap_gesture_cleanup}, + {"UtcDaliTapGestureDetectorConstructor", UtcDaliTapGestureDetectorConstructor, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureDetectorNew", UtcDaliTapGestureDetectorNew, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureDetectorDownCast", UtcDaliTapGestureDetectorDownCast, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureSetTapsRequired", UtcDaliTapGestureSetTapsRequired, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureGetTapsRequired", UtcDaliTapGestureGetTapsRequired, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureSetTouchesRequired", UtcDaliTapGestureSetTouchesRequired, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureGetTouchesRequired", UtcDaliTapGestureGetTouchesRequired, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureSignalReceptionNegative", UtcDaliTapGestureSignalReceptionNegative, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureSignalReceptionPositive", UtcDaliTapGestureSignalReceptionPositive, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureSignalReceptionDetach", UtcDaliTapGestureSignalReceptionDetach, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureSignalReceptionActorDestroyedWhileTapping", UtcDaliTapGestureSignalReceptionActorDestroyedWhileTapping, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureSignalReceptionRotatedActor", UtcDaliTapGestureSignalReceptionRotatedActor, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureSignalReceptionChildHit", UtcDaliTapGestureSignalReceptionChildHit, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureSignalReceptionAttachDetachMany", UtcDaliTapGestureSignalReceptionAttachDetachMany, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureSignalReceptionActorBecomesUntouchable", UtcDaliTapGestureSignalReceptionActorBecomesUntouchable, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureSignalReceptionMultipleGestureDetectors", UtcDaliTapGestureSignalReceptionMultipleGestureDetectors, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureSignalReceptionMultipleDetectorsOnActor", UtcDaliTapGestureSignalReceptionMultipleDetectorsOnActor, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureSignalReceptionDifferentPossible", UtcDaliTapGestureSignalReceptionDifferentPossible, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureEmitIncorrectStateClear", UtcDaliTapGestureEmitIncorrectStateClear, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureEmitIncorrectStateContinuing", UtcDaliTapGestureEmitIncorrectStateContinuing, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureEmitIncorrectStateFinished", UtcDaliTapGestureEmitIncorrectStateFinished, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureActorUnstaged", UtcDaliTapGestureActorUnstaged, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureRepeatedState", UtcDaliTapGestureRepeatedState, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGesturePossibleCancelled", UtcDaliTapGesturePossibleCancelled, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureDetectorRemovedWhilePossible", UtcDaliTapGestureDetectorRemovedWhilePossible, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureActorRemovedWhilePossible", UtcDaliTapGestureActorRemovedWhilePossible, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTapGestureSystemOverlay", UtcDaliTapGestureSystemOverlay, utc_dali_tap_gesture_detector_startup, utc_dali_tap_gesture_detector_cleanup}, + {"UtcDaliTextConstructor", UtcDaliTextConstructor, utc_dali_text_startup, utc_dali_text_cleanup}, + {"UtcDaliTextCopyConstructor", UtcDaliTextCopyConstructor, utc_dali_text_startup, utc_dali_text_cleanup}, + {"UtcDaliTextAssignmentOperator", UtcDaliTextAssignmentOperator, utc_dali_text_startup, utc_dali_text_cleanup}, + {"UtcDaliTextSetGetText", UtcDaliTextSetGetText, utc_dali_text_startup, utc_dali_text_cleanup}, + {"UtcDaliTextAccessOperator01", UtcDaliTextAccessOperator01, utc_dali_text_startup, utc_dali_text_cleanup}, + {"UtcDaliTextAccessOperator02", UtcDaliTextAccessOperator02, utc_dali_text_startup, utc_dali_text_cleanup}, + {"UtcDaliTextIsEmpty", UtcDaliTextIsEmpty, utc_dali_text_startup, utc_dali_text_cleanup}, + {"UtcDaliTextGetLength", UtcDaliTextGetLength, utc_dali_text_startup, utc_dali_text_cleanup}, + {"UtcDaliTextAppend", UtcDaliTextAppend, utc_dali_text_startup, utc_dali_text_cleanup}, + {"UtcDaliTextRemove01", UtcDaliTextRemove01, utc_dali_text_startup, utc_dali_text_cleanup}, + {"UtcDaliTextRemove02", UtcDaliTextRemove02, utc_dali_text_startup, utc_dali_text_cleanup}, + {"UtcDaliTextActorConstructorVoid", UtcDaliTextActorConstructorVoid, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorNew01", UtcDaliTextActorNew01, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorNew02", UtcDaliTextActorNew02, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorNew03", UtcDaliTextActorNew03, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorNew04", UtcDaliTextActorNew04, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorNew05", UtcDaliTextActorNew05, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorNew06", UtcDaliTextActorNew06, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorNew07", UtcDaliTextActorNew07, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorDownCast", UtcDaliTextActorDownCast, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorDownCast2", UtcDaliTextActorDownCast2, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorSetText", UtcDaliTextActorSetText, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorSetFont", UtcDaliTextActorSetFont, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorSetFontDetection", UtcDaliTextActorSetFontDetection, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorSetTextIndividualStyles", UtcDaliTextActorSetTextIndividualStyles, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorChangingText", UtcDaliTextActorChangingText, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorGetLoadingState", UtcDaliTextActorGetLoadingState, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorSetItalics", UtcDaliTextActorSetItalics, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorSetUnderline", UtcDaliTextActorSetUnderline, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorSetWeight", UtcDaliTextActorSetWeight, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorSetStyle", UtcDaliTextActorSetStyle, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorDefaultProperties", UtcDaliTextActorDefaultProperties, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorSetGradientColor", UtcDaliTextActorSetGradientColor, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorSetGradientStartPoint", UtcDaliTextActorSetGradientStartPoint, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorSetGradientEndPoint", UtcDaliTextActorSetGradientEndPoint, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorSynchronousGlyphLoading", UtcDaliTextActorSynchronousGlyphLoading, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorAutomaticSizeSet", UtcDaliTextActorAutomaticSizeSet, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorAutomaticSizeSetAnimation", UtcDaliTextActorAutomaticSizeSetAnimation, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextActorPropertyIndices", UtcDaliTextActorPropertyIndices, text_actor_test_startup, text_actor_test_cleanup}, + {"UtcDaliTextStyleDefaultConstructor", UtcDaliTextStyleDefaultConstructor, utc_dali_text_style_startup, utc_dali_text_style_cleanup}, + {"UtcDaliTextStyleCopyConstructor", UtcDaliTextStyleCopyConstructor, utc_dali_text_style_startup, utc_dali_text_style_cleanup}, + {"UtcDaliTextStyleComparisonOperator", UtcDaliTextStyleComparisonOperator, utc_dali_text_style_startup, utc_dali_text_style_cleanup}, + {"UtcDaliTextStyleCopy", UtcDaliTextStyleCopy, utc_dali_text_style_startup, utc_dali_text_style_cleanup}, + {"UtcDaliTextStyleSetGetFontName", UtcDaliTextStyleSetGetFontName, utc_dali_text_style_startup, utc_dali_text_style_cleanup}, + {"UtcDaliTextStyleSetGetFontStyle", UtcDaliTextStyleSetGetFontStyle, utc_dali_text_style_startup, utc_dali_text_style_cleanup}, + {"UtcDaliTextStyleSetGetFontPointSize", UtcDaliTextStyleSetGetFontPointSize, utc_dali_text_style_startup, utc_dali_text_style_cleanup}, + {"UtcDaliTextStyleSetGetWeight", UtcDaliTextStyleSetGetWeight, utc_dali_text_style_startup, utc_dali_text_style_cleanup}, + {"UtcDaliTextStyleSetGetTextColor", UtcDaliTextStyleSetGetTextColor, utc_dali_text_style_startup, utc_dali_text_style_cleanup}, + {"UtcDaliTextStyleSetGetItalics", UtcDaliTextStyleSetGetItalics, utc_dali_text_style_startup, utc_dali_text_style_cleanup}, + {"UtcDaliTextStyleSetGetItalicsAngle", UtcDaliTextStyleSetGetItalicsAngle, utc_dali_text_style_startup, utc_dali_text_style_cleanup}, + {"UtcDaliTextStyleSetGetUnderline", UtcDaliTextStyleSetGetUnderline, utc_dali_text_style_startup, utc_dali_text_style_cleanup}, + {"UtcDaliTextStyleSetGetShadow", UtcDaliTextStyleSetGetShadow, utc_dali_text_style_startup, utc_dali_text_style_cleanup}, + {"UtcDaliTextStyleSetGetGlow", UtcDaliTextStyleSetGetGlow, utc_dali_text_style_startup, utc_dali_text_style_cleanup}, + {"UtcDaliTextStyleSetGetOutline", UtcDaliTextStyleSetGetOutline, utc_dali_text_style_startup, utc_dali_text_style_cleanup}, + {"UtcDaliTextStyleSetGetSmoothEdge", UtcDaliTextStyleSetGetSmoothEdge, utc_dali_text_style_startup, utc_dali_text_style_cleanup}, + {"UtcDaliTouchEventCombinerConstructors", UtcDaliTouchEventCombinerConstructors, utc_dali_touch_event_combiner_startup, utc_dali_touch_event_combiner_cleanup}, + {"UtcDaliTouchEventCombinerConstructorsNegative", UtcDaliTouchEventCombinerConstructorsNegative, utc_dali_touch_event_combiner_startup, utc_dali_touch_event_combiner_cleanup}, + {"UtcDaliTouchEventCombinerSettersAndGetters", UtcDaliTouchEventCombinerSettersAndGetters, utc_dali_touch_event_combiner_startup, utc_dali_touch_event_combiner_cleanup}, + {"UtcDaliTouchEventCombinerSettersNegative", UtcDaliTouchEventCombinerSettersNegative, utc_dali_touch_event_combiner_startup, utc_dali_touch_event_combiner_cleanup}, + {"UtcDaliTouchEventCombinerSingleTouchNormal", UtcDaliTouchEventCombinerSingleTouchNormal, utc_dali_touch_event_combiner_startup, utc_dali_touch_event_combiner_cleanup}, + {"UtcDaliTouchEventCombinerSingleTouchMotionWithoutDown", UtcDaliTouchEventCombinerSingleTouchMotionWithoutDown, utc_dali_touch_event_combiner_startup, utc_dali_touch_event_combiner_cleanup}, + {"UtcDaliTouchEventCombinerSingleTouchTwoDowns", UtcDaliTouchEventCombinerSingleTouchTwoDowns, utc_dali_touch_event_combiner_startup, utc_dali_touch_event_combiner_cleanup}, + {"UtcDaliTouchEventCombinerSingleTouchUpWithoutDown", UtcDaliTouchEventCombinerSingleTouchUpWithoutDown, utc_dali_touch_event_combiner_startup, utc_dali_touch_event_combiner_cleanup}, + {"UtcDaliTouchEventCombinerSingleTouchTwoUps", UtcDaliTouchEventCombinerSingleTouchTwoUps, utc_dali_touch_event_combiner_startup, utc_dali_touch_event_combiner_cleanup}, + {"UtcDaliTouchEventCombinerSingleTouchUpWithDifferentId", UtcDaliTouchEventCombinerSingleTouchUpWithDifferentId, utc_dali_touch_event_combiner_startup, utc_dali_touch_event_combiner_cleanup}, + {"UtcDaliTouchEventCombinerSingleTouchMotionWithDifferentId", UtcDaliTouchEventCombinerSingleTouchMotionWithDifferentId, utc_dali_touch_event_combiner_startup, utc_dali_touch_event_combiner_cleanup}, + {"UtcDaliTouchEventCombinerMultiTouchNormal", UtcDaliTouchEventCombinerMultiTouchNormal, utc_dali_touch_event_combiner_startup, utc_dali_touch_event_combiner_cleanup}, + {"UtcDaliTouchEventCombinerSeveralPoints", UtcDaliTouchEventCombinerSeveralPoints, utc_dali_touch_event_combiner_startup, utc_dali_touch_event_combiner_cleanup}, + {"UtcDaliTouchEventCombinerReset", UtcDaliTouchEventCombinerReset, utc_dali_touch_event_combiner_startup, utc_dali_touch_event_combiner_cleanup}, + {"UtcDaliTouchEventCombinerSingleTouchInterrupted", UtcDaliTouchEventCombinerSingleTouchInterrupted, utc_dali_touch_event_combiner_startup, utc_dali_touch_event_combiner_cleanup}, + {"UtcDaliTouchEventCombinerMultiTouchInterrupted", UtcDaliTouchEventCombinerMultiTouchInterrupted, utc_dali_touch_event_combiner_startup, utc_dali_touch_event_combiner_cleanup}, + {"UtcDaliTouchEventCombinerInvalidState", UtcDaliTouchEventCombinerInvalidState, utc_dali_touch_event_combiner_startup, utc_dali_touch_event_combiner_cleanup}, + {"UtcDaliTouchNormalProcessing", UtcDaliTouchNormalProcessing, utc_dali_touch_processing_startup, utc_dali_touch_processing_cleanup}, + {"UtcDaliTouchOutsideCameraNearFarPlanes", UtcDaliTouchOutsideCameraNearFarPlanes, utc_dali_touch_processing_startup, utc_dali_touch_processing_cleanup}, + {"UtcDaliTouchEmitEmpty", UtcDaliTouchEmitEmpty, utc_dali_touch_processing_startup, utc_dali_touch_processing_cleanup}, + {"UtcDaliTouchInterrupted", UtcDaliTouchInterrupted, utc_dali_touch_processing_startup, utc_dali_touch_processing_cleanup}, + {"UtcDaliTouchParentConsumer", UtcDaliTouchParentConsumer, utc_dali_touch_processing_startup, utc_dali_touch_processing_cleanup}, + {"UtcDaliTouchInterruptedParentConsumer", UtcDaliTouchInterruptedParentConsumer, utc_dali_touch_processing_startup, utc_dali_touch_processing_cleanup}, + {"UtcDaliTouchLeave", UtcDaliTouchLeave, utc_dali_touch_processing_startup, utc_dali_touch_processing_cleanup}, + {"UtcDaliTouchLeaveParentConsumer", UtcDaliTouchLeaveParentConsumer, utc_dali_touch_processing_startup, utc_dali_touch_processing_cleanup}, + {"UtcDaliTouchActorBecomesInsensitive", UtcDaliTouchActorBecomesInsensitive, utc_dali_touch_processing_startup, utc_dali_touch_processing_cleanup}, + {"UtcDaliTouchActorBecomesInsensitiveParentConsumer", UtcDaliTouchActorBecomesInsensitiveParentConsumer, utc_dali_touch_processing_startup, utc_dali_touch_processing_cleanup}, + {"UtcDaliTouchMultipleLayers", UtcDaliTouchMultipleLayers, utc_dali_touch_processing_startup, utc_dali_touch_processing_cleanup}, + {"UtcDaliTouchMultipleRenderTasks", UtcDaliTouchMultipleRenderTasks, utc_dali_touch_processing_startup, utc_dali_touch_processing_cleanup}, + {"UtcDaliTouchMultipleRenderTasksWithChildLayer", UtcDaliTouchMultipleRenderTasksWithChildLayer, utc_dali_touch_processing_startup, utc_dali_touch_processing_cleanup}, + {"UtcDaliTouchOffscreenRenderTasks", UtcDaliTouchOffscreenRenderTasks, utc_dali_touch_processing_startup, utc_dali_touch_processing_cleanup}, + {"UtcDaliTouchMultipleRenderableActors", UtcDaliTouchMultipleRenderableActors, utc_dali_touch_processing_startup, utc_dali_touch_processing_cleanup}, + {"UtcDaliTouchActorRemovedInSignal", UtcDaliTouchActorRemovedInSignal, utc_dali_touch_processing_startup, utc_dali_touch_processing_cleanup}, + {"UtcDaliTouchActorSignalNotConsumed", UtcDaliTouchActorSignalNotConsumed, utc_dali_touch_processing_startup, utc_dali_touch_processing_cleanup}, + {"UtcDaliTouchActorUnStaged", UtcDaliTouchActorUnStaged, utc_dali_touch_processing_startup, utc_dali_touch_processing_cleanup}, + {"UtcDaliTouchSystemOverlayActor", UtcDaliTouchSystemOverlayActor, utc_dali_touch_processing_startup, utc_dali_touch_processing_cleanup}, + {"UtcDaliVector2Cons", UtcDaliVector2Cons, utc_dali_vector2_startup, utc_dali_vector2_cleanup}, + {"UtcDaliVector2FitInside", UtcDaliVector2FitInside, utc_dali_vector2_startup, utc_dali_vector2_cleanup}, + {"UtcDaliVector2FitScaleToFill", UtcDaliVector2FitScaleToFill, utc_dali_vector2_startup, utc_dali_vector2_cleanup}, + {"UtcDaliVector2ShrinkInside", UtcDaliVector2ShrinkInside, utc_dali_vector2_startup, utc_dali_vector2_cleanup}, + {"UtcDaliVector2Add", UtcDaliVector2Add, utc_dali_vector2_startup, utc_dali_vector2_cleanup}, + {"UtcDaliVector2Subtract", UtcDaliVector2Subtract, utc_dali_vector2_startup, utc_dali_vector2_cleanup}, + {"UtcDaliVector2Negate", UtcDaliVector2Negate, utc_dali_vector2_startup, utc_dali_vector2_cleanup}, + {"UtcDaliVector2Multiply", UtcDaliVector2Multiply, utc_dali_vector2_startup, utc_dali_vector2_cleanup}, + {"UtcDaliVector2Divide", UtcDaliVector2Divide, utc_dali_vector2_startup, utc_dali_vector2_cleanup}, + {"UtcDaliVector2Scale", UtcDaliVector2Scale, utc_dali_vector2_startup, utc_dali_vector2_cleanup}, + {"UtcDaliVector2Equals", UtcDaliVector2Equals, utc_dali_vector2_startup, utc_dali_vector2_cleanup}, + {"UtcDaliVector2Length", UtcDaliVector2Length, utc_dali_vector2_startup, utc_dali_vector2_cleanup}, + {"UtcDaliVector2LengthSquared", UtcDaliVector2LengthSquared, utc_dali_vector2_startup, utc_dali_vector2_cleanup}, + {"UtcDaliVector2Max", UtcDaliVector2Max, utc_dali_vector2_startup, utc_dali_vector2_cleanup}, + {"UtcDaliVector2Min", UtcDaliVector2Min, utc_dali_vector2_startup, utc_dali_vector2_cleanup}, + {"UtcDaliVector2Clamp", UtcDaliVector2Clamp, utc_dali_vector2_startup, utc_dali_vector2_cleanup}, + {"UtcDaliVector2ClampVector2", UtcDaliVector2ClampVector2, utc_dali_vector2_startup, utc_dali_vector2_cleanup}, + {"UtcDaliVector2Normalize", UtcDaliVector2Normalize, utc_dali_vector2_startup, utc_dali_vector2_cleanup}, + {"UtcDaliVector2OperatorSubscript", UtcDaliVector2OperatorSubscript, utc_dali_vector2_startup, utc_dali_vector2_cleanup}, + {"UtcDaliVector2OStreamOperator", UtcDaliVector2OStreamOperator, utc_dali_vector2_startup, utc_dali_vector2_cleanup}, + {"UtcDaliVector3Cons", UtcDaliVector3Cons, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3Assign", UtcDaliVector3Assign, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3Add", UtcDaliVector3Add, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3Constants", UtcDaliVector3Constants, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3Cross", UtcDaliVector3Cross, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3Dot", UtcDaliVector3Dot, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3Equals", UtcDaliVector3Equals, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3Length", UtcDaliVector3Length, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3LengthSquared", UtcDaliVector3LengthSquared, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3Max", UtcDaliVector3Max, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3Min", UtcDaliVector3Min, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3Clamp", UtcDaliVector3Clamp, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3ClampVector3", UtcDaliVector3ClampVector3, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3Multiply", UtcDaliVector3Multiply, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3Divide", UtcDaliVector3Divide, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3Scale", UtcDaliVector3Scale, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3Normalize", UtcDaliVector3Normalize, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3Subtract", UtcDaliVector3Subtract, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3OperatorSubscript", UtcDaliVector3OperatorSubscript, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3OStreamOperator", UtcDaliVector3OStreamOperator, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3Rotate", UtcDaliVector3Rotate, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3AsFloat", UtcDaliVector3AsFloat, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3AsVectorXY", UtcDaliVector3AsVectorXY, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3FitKeepAspectRatio", UtcDaliVector3FitKeepAspectRatio, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3FillKeepAspectRatio", UtcDaliVector3FillKeepAspectRatio, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3FillXYKeepAspectRatio", UtcDaliVector3FillXYKeepAspectRatio, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector3ShrinkInsideKeepAspectRatio", UtcDaliVector3ShrinkInsideKeepAspectRatio, utc_dali_vector3_startup, utc_dali_vector3_cleanup}, + {"UtcDaliVector4Vector4", UtcDaliVector4Vector4, utc_dali_vector4_startup, utc_dali_vector4_cleanup}, + {"UtcDaliVector4Add", UtcDaliVector4Add, utc_dali_vector4_startup, utc_dali_vector4_cleanup}, + {"UtcDaliVector4Constants", UtcDaliVector4Constants, utc_dali_vector4_startup, utc_dali_vector4_cleanup}, + {"UtcDaliVector4Cross", UtcDaliVector4Cross, utc_dali_vector4_startup, utc_dali_vector4_cleanup}, + {"UtcDaliVector4Dot", UtcDaliVector4Dot, utc_dali_vector4_startup, utc_dali_vector4_cleanup}, + {"UtcDaliVector4DotVector3", UtcDaliVector4DotVector3, utc_dali_vector4_startup, utc_dali_vector4_cleanup}, + {"UtcDaliVector4Dot4", UtcDaliVector4Dot4, utc_dali_vector4_startup, utc_dali_vector4_cleanup}, + {"UtcDaliVector4Equals", UtcDaliVector4Equals, utc_dali_vector4_startup, utc_dali_vector4_cleanup}, + {"UtcDaliVector4Length", UtcDaliVector4Length, utc_dali_vector4_startup, utc_dali_vector4_cleanup}, + {"UtcDaliVector4LengthSquared", UtcDaliVector4LengthSquared, utc_dali_vector4_startup, utc_dali_vector4_cleanup}, + {"UtcDaliVector4Max", UtcDaliVector4Max, utc_dali_vector4_startup, utc_dali_vector4_cleanup}, + {"UtcDaliVector4Min", UtcDaliVector4Min, utc_dali_vector4_startup, utc_dali_vector4_cleanup}, + {"UtcDaliVector4Clamp", UtcDaliVector4Clamp, utc_dali_vector4_startup, utc_dali_vector4_cleanup}, + {"UtcDaliVector4ClampVector4", UtcDaliVector4ClampVector4, utc_dali_vector4_startup, utc_dali_vector4_cleanup}, + {"UtcDaliVector4Multiply", UtcDaliVector4Multiply, utc_dali_vector4_startup, utc_dali_vector4_cleanup}, + {"UtcDaliVector4Divide", UtcDaliVector4Divide, utc_dali_vector4_startup, utc_dali_vector4_cleanup}, + {"UtcDaliVector4Scale", UtcDaliVector4Scale, utc_dali_vector4_startup, utc_dali_vector4_cleanup}, + {"UtcDaliVector4Normalize", UtcDaliVector4Normalize, utc_dali_vector4_startup, utc_dali_vector4_cleanup}, + {"UtcDaliVector4Subtract", UtcDaliVector4Subtract, utc_dali_vector4_startup, utc_dali_vector4_cleanup}, + {"UtcDaliVector4OperatorSubscript", UtcDaliVector4OperatorSubscript, utc_dali_vector4_startup, utc_dali_vector4_cleanup}, + {"UtcDaliVector4OStreamOperator", UtcDaliVector4OStreamOperator, utc_dali_vector4_startup, utc_dali_vector4_cleanup}, + {"UtcDaliVector4AsFloat", UtcDaliVector4AsFloat, utc_dali_vector4_startup, utc_dali_vector4_cleanup}, + {NULL, NULL} +}; + +#endif // __TCT_DALI_CORE_H__ diff --git a/automated-tests/src/dali/utc-Dali-ActiveConstraint.cpp b/automated-tests/src/dali/utc-Dali-ActiveConstraint.cpp new file mode 100644 index 0000000..7327533 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-ActiveConstraint.cpp @@ -0,0 +1,335 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +using namespace Dali; + +void utc_dali_active_constraint_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_active_constraint_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ + +static const Vector3 TEST_CONSTRAINT_TARGET = Vector3( 10.0f, 10.0f, 10.0f ); + +struct TestConstraintVector3 +{ + Vector3 operator()( const Vector3& current ) + { + return TEST_CONSTRAINT_TARGET; + } +}; + +static bool constraintSignalled=false; +static void ConstraintCallback( ActiveConstraint& constraint ) +{ + constraintSignalled = true; +} + +} // anon namespace + +int UtcDaliConstraintGetTargetObject(void) +{ + TestApplication application; + + // Apply a constraint to an actor + + Constraint constraint = Constraint::New( Actor::SIZE, TestConstraintVector3() ); + + Actor actor = Actor::New(); + + ActiveConstraint active = actor.ApplyConstraint( constraint ); + + // Retrieve the actor back from the active-constraint + + Handle object = active.GetTargetObject(); + + DALI_TEST_CHECK( object ); + + DALI_TEST_CHECK( object.GetObjectPtr() == actor.GetObjectPtr() ); + + // Throw-away the actor, and check GetTargetObject returns NULL + + object.Reset(); + actor.Reset(); + + object = active.GetTargetObject(); + + DALI_TEST_CHECK( !object ); + END_TEST; +} + +int UtcDaliConstraintGetTargetProperty(void) +{ + TestApplication application; + + // Apply a constraint to an actor + + Constraint constraint = Constraint::New( Actor::SIZE, TestConstraintVector3() ); + + Actor actor = Actor::New(); + + ActiveConstraint active = actor.ApplyConstraint( constraint ); + + // Check the property index + + Property::Index index = active.GetTargetProperty(); + + DALI_TEST_CHECK( Actor::SIZE == index ); + END_TEST; +} + +int UtcDaliConstraintSetWeight(void) +{ + TestApplication application; + + // Apply a constraint to an actor + + Constraint constraint = Constraint::New( Actor::SIZE, TestConstraintVector3() ); + + Actor actor = Actor::New(); + Stage::GetCurrent().Add( actor ); + + ActiveConstraint active = actor.ApplyConstraint( constraint ); + + // Apply the constraint manually + + active.SetWeight( 0.0f ); // start at zero + + application.SendNotification(); + application.Render(static_cast(1000.0f)); // 1 elapsed second + + DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + + float weight( 0.25f ); + active.SetWeight( weight ); + application.SendNotification(); + application.Render(static_cast(1000.0f)); // 1 elapsed second + DALI_TEST_EQUALS( actor.GetCurrentSize(), TEST_CONSTRAINT_TARGET * weight, TEST_LOCATION ); + + weight = 0.5f; + active.SetWeight( weight ); + application.SendNotification(); + application.Render(static_cast(1000.0f)); // 2 elapsed seconds + DALI_TEST_EQUALS( actor.GetCurrentSize(), TEST_CONSTRAINT_TARGET * weight, TEST_LOCATION ); + + weight = 0.75f; + active.SetWeight( weight ); + application.SendNotification(); + application.Render(static_cast(1000.0f)); // 2 elapsed seconds + DALI_TEST_EQUALS( actor.GetCurrentSize(), TEST_CONSTRAINT_TARGET * weight, TEST_LOCATION ); + + weight = 1.0f; + active.SetWeight( weight ); + application.SendNotification(); + application.Render(static_cast(1000.0f)); // 2 elapsed seconds + DALI_TEST_EQUALS( actor.GetCurrentSize(), TEST_CONSTRAINT_TARGET, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintGetCurrentWeight(void) +{ + TestApplication application; + + // Apply a constraint to an actor + + Constraint constraint = Constraint::New( Actor::SIZE, TestConstraintVector3() ); + + Actor actor = Actor::New(); + + ActiveConstraint active = actor.ApplyConstraint( constraint ); + + // Check default weight + + DALI_TEST_CHECK( ActiveConstraint::DEFAULT_WEIGHT == active.GetCurrentWeight() ); + END_TEST; +} + +int UtcDaliConstraintSignalApplied(void) +{ + TestApplication application; + + // Apply a constraint to an actor + + Constraint constraint = Constraint::New( Actor::SIZE, TestConstraintVector3() ); + + float duration( 10.0f ); + constraint.SetApplyTime( duration ); + + Actor actor = Actor::New(); + Stage::GetCurrent().Add( actor ); + + ActiveConstraint active = actor.ApplyConstraint( constraint ); + + // Check signal is received after duration + + bool constraintCheck( false ); + ConstraintAppliedCheck appliedCheck( constraintCheck ); + + active.AppliedSignal().Connect( &application, appliedCheck ); + + application.SendNotification(); + application.Render(static_cast(1000.0f)); // 1 elapsed second + + // Check signal has not fired + application.SendNotification(); + appliedCheck.CheckSignalNotReceived(); + + application.Render(static_cast(4000.0f)); // 5 elapsed seconds + + // Check signal has not fired + application.SendNotification(); + appliedCheck.CheckSignalNotReceived(); + + application.Render(static_cast(5000.0f - 1.0f)); // <10 elapsed seconds + + // Check signal has not fired + application.SendNotification(); + appliedCheck.CheckSignalNotReceived(); + + application.Render(static_cast(2.0f)); // >10 elapsed seconds + + // Signal should have fired + application.SendNotification(); + appliedCheck.CheckSignalReceived(); + END_TEST; +} + +int UtcDaliConstraintRemove(void) +{ + TestApplication application; + + // Apply a constraint to an actor + + Constraint constraint = Constraint::New( Actor::SIZE, TestConstraintVector3() ); + + float duration( 1.0f ); + constraint.SetApplyTime( duration ); + + Actor actor = Actor::New(); + const Vector3 startSize( 1, 2, 3 ); + actor.SetSize( startSize ); + Stage::GetCurrent().Add( actor ); + + ActiveConstraint active = actor.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(static_cast(0.0f)); // 0 elapsed seconds + + DALI_TEST_CHECK( 0 == active.GetCurrentWeight() ); + DALI_TEST_CHECK( startSize == actor.GetCurrentSize() ); + + bool constraintCheck( false ); + ConstraintAppliedCheck appliedCheck( constraintCheck ); + + active.AppliedSignal().Connect( &application, appliedCheck ); + + application.SendNotification(); + application.Render(static_cast(2000.0f)); // 2 elapsed seconds + + application.SendNotification(); + appliedCheck.CheckSignalReceived(); + + DALI_TEST_CHECK( ActiveConstraint::DEFAULT_WEIGHT == active.GetCurrentWeight() ); + DALI_TEST_CHECK( TEST_CONSTRAINT_TARGET == actor.GetCurrentSize() ); + + // This should be NOOP while constraint is applied + actor.SetSize( startSize ); + application.SendNotification(); + application.Render(static_cast(1000.0f)); + DALI_TEST_CHECK( ActiveConstraint::DEFAULT_WEIGHT == active.GetCurrentWeight() ); + DALI_TEST_CHECK( TEST_CONSTRAINT_TARGET == actor.GetCurrentSize() ); + + // Remove constraint & try again + actor.RemoveConstraint( active ); + actor.SetSize( startSize ); + application.SendNotification(); + application.Render(static_cast(1000.0f)); + DALI_TEST_CHECK( ActiveConstraint::DEFAULT_WEIGHT == active.GetCurrentWeight() ); + DALI_TEST_CHECK( startSize == actor.GetCurrentSize() ); + + // Try setting the weight after removal + active.SetProperty( ActiveConstraint::WEIGHT, 0.5f ); + application.SendNotification(); + application.Render(static_cast(1000.0f)); + DALI_TEST_CHECK( 0.5f == active.GetCurrentWeight() ); + + // Quick check for operator = override on constrainables (needs rhs as a Handle!!) and destructor from heap + Constrainable* constrainable = new Constrainable; + Constrainable constrainable2; + Handle& handle = dynamic_cast< Handle& > ( *constrainable ); + constrainable2 = handle; + delete constrainable; + END_TEST; +} + +int UtcDaliConstraintCallback(void) +{ + TestApplication application; + Constraint constraint = Constraint::New( Actor::SIZE, TestConstraintVector3() ); + constraint.SetApplyTime(2.0f); + Actor actor = Actor::New(); + ActiveConstraint active = actor.ApplyConstraint( constraint ); + active.AppliedSignal().Connect( ConstraintCallback ); + application.SendNotification(); + application.Render(0); + application.Render(1000); + application.SendNotification(); + DALI_TEST_CHECK( ! constraintSignalled ); + application.Render(1016); + application.SendNotification(); + + DALI_TEST_CHECK( constraintSignalled ); + END_TEST; +} + +int UtcDaliConstraintProperties(void) +{ + TestApplication application; + + Constraint constraint = Constraint::New( Actor::SIZE, TestConstraintVector3() ); + Actor actor = Actor::New(); + ActiveConstraint active = actor.ApplyConstraint( constraint ); + + Property::IndexContainer indices; + active.GetPropertyIndices( indices ); + DALI_TEST_CHECK( ! indices.empty() ); + DALI_TEST_EQUALS( indices.size(), active.GetPropertyCount(), TEST_LOCATION ); + + // Valid property + DALI_TEST_EQUALS( active.GetPropertyName( 0 ), "weight", TEST_LOCATION ); + DALI_TEST_EQUALS( active.GetPropertyIndex( "weight" ), 0, TEST_LOCATION ); + DALI_TEST_CHECK( active.IsPropertyWritable( 0 ) ); + DALI_TEST_CHECK( active.IsPropertyAnimatable( 0 ) ); + DALI_TEST_EQUALS( active.GetPropertyType( 0 ), Property::FLOAT, TEST_LOCATION ); + DALI_TEST_CHECK( active.GetCurrentWeight() != 21312.0f ); + active.SetProperty( 0, 21312.0f ); + DALI_TEST_EQUALS( active.GetCurrentWeight(), 21312.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( active.GetProperty< float >( 0 ), 21312.0f, TEST_LOCATION ); + + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp new file mode 100644 index 0000000..284ea19 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -0,0 +1,2853 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 "assert.h" +#include +#include +#include +#include + +//& set: DaliActor + +using std::string; +using namespace Dali; + + +void utc_dali_actor_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_actor_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ + +const char* vertexSource = +"void main()\n" +"{\n" +" gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\n" +" vTexCoord = aTexCoord;\n" +"}\n"; + +const char* fragmentSource = +"void main()\n" +"{\n" +" gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n" +"}\n"; + +bool gTouchCallBackCalled=false; +bool gTouchCallBack2Called=false; + +/** + * Simulates a Down Touch at 25.0, 25.0. + * @param[in] app Test Application instance. + */ +int SimulateTouchForSetOverlayHitTest(TestApplication& app) +{ + app.SendNotification(); + app.Render(1); + app.SendNotification(); + app.Render(1); + + gTouchCallBackCalled = false; + gTouchCallBack2Called = false; + + // simulate a touch event + Dali::TouchPoint point( 0, TouchPoint::Down, 25.0f, 25.0f ); + Dali::Integration::TouchEvent event; + event.AddPoint( point ); + app.ProcessEvent( event ); + + app.SendNotification(); + app.Render(1); + app.SendNotification(); + app.Render(1); + END_TEST; +} + + +static bool gTestConstraintCalled; + +struct TestConstraint +{ + Vector4 operator()(const Vector4& color) + { + gTestConstraintCalled = true; + return Vector4(color.x, color.y, color.z, 0.1f); + } +}; + +/** + * TestConstraint reference. + * When constraint is called, the resultRef is updated + * with the value supplied. + */ +template +struct TestConstraintRef +{ + TestConstraintRef(unsigned int& resultRef, unsigned int value) + : mResultRef(resultRef), + mValue(value) + { + } + + T operator()(const T& current) + { + mResultRef = mValue; + return current; + } + + unsigned int& mResultRef; + unsigned int mValue; +}; + +bool wasConstraintCallbackCalled1 = false; +void TestConstraintCallback1( ActiveConstraint& constraint ) +{ + wasConstraintCallbackCalled1 = true; +} + +bool wasConstraintCallbackCalled2 = false; +void TestConstraintCallback2( ActiveConstraint& constraint ) +{ + wasConstraintCallbackCalled2 = true; +} + +bool wasConstraintCallbackCalled3 = false; +void TestConstraintCallback3( ActiveConstraint& constraint ) +{ + wasConstraintCallbackCalled3 = true; +} + +static bool TestCallback(Actor actor, const TouchEvent& event) +{ + gTouchCallBackCalled = true; + return false; + END_TEST; +} + +static bool TestCallback2(Actor actor, const TouchEvent& event) +{ + gTouchCallBack2Called = true; + return false; + END_TEST; +} + +static Vector3 gSetSize; +static bool gSetSizeCallBackCalled; +void SetSizeCallback( Actor actor, const Vector3& size ) +{ + gSetSizeCallBackCalled = true; + gSetSize = size; +} +// validation stuff for onstage & offstage signals +static std::vector< std::string > gActorNamesOnOffStage; +static int gOnStageCallBackCalled; +void OnStageCallback( Actor actor ) +{ + ++gOnStageCallBackCalled; + gActorNamesOnOffStage.push_back( actor.GetName() ); + DALI_TEST_CHECK( actor.OnStage() == true ); +} +static int gOffStageCallBackCalled; +void OffStageCallback( Actor actor ) +{ + ++gOffStageCallBackCalled; + gActorNamesOnOffStage.push_back( actor.GetName() ); + DALI_TEST_CHECK( actor.OnStage() == false ); +} + +struct PositionComponentConstraint +{ + PositionComponentConstraint(){} + + Vector3 operator()(const Vector3& current, const PropertyInput& property) + { + const Matrix& m = property.GetMatrix(); + Vector3 pos; + Vector3 scale; + Quaternion rot; + m.GetTransformComponents(pos, rot, scale); + return pos; + } +}; + + + +} // anonymous namespace + + +//& purpose: Testing New API +int UtcDaliActorNew(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + DALI_TEST_CHECK(actor); + END_TEST; +} + +//& purpose: Testing Dali::Actor::DownCast() +int UtcDaliActorDownCast(void) +{ + TestApplication application; + tet_infoline("Testing Dali::Actor::DownCast()"); + + Actor actor = Actor::New(); + BaseHandle object(actor); + Actor actor2 = Actor::DownCast(object); + DALI_TEST_CHECK(actor2); + END_TEST; +} + +//& purpose: Testing Dali::Actor::DownCast() +int UtcDaliActorDownCast2(void) +{ + TestApplication application; + tet_infoline("Testing Dali::Actor::DownCast()"); + + BaseHandle unInitializedObject; + Actor actor = Actor::DownCast(unInitializedObject); + DALI_TEST_CHECK(!actor); + END_TEST; +} + +//& purpose: Testing Dali::Actor::GetName() +int UtcDaliActorGetName(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + DALI_TEST_CHECK(actor.GetName().empty()); + END_TEST; +} + +//& purpose: Testing Dali::Actor::SetName() +int UtcDaliActorSetName(void) +{ + TestApplication application; + + string str("ActorName"); + Actor actor = Actor::New(); + + actor.SetName(str); + DALI_TEST_CHECK(actor.GetName() == str); + END_TEST; +} + +int UtcDaliActorGetId(void) +{ + tet_infoline("Testing Dali::Actor::UtcDaliActorGetId()"); + TestApplication application; + + Actor first = Actor::New(); + Actor second = Actor::New(); + Actor third = Actor::New(); + + DALI_TEST_CHECK(first.GetId() != second.GetId()); + DALI_TEST_CHECK(second.GetId() != third.GetId()); + END_TEST; +} + +int UtcDaliActorIsRoot(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + DALI_TEST_CHECK(!actor.IsRoot()); + + // get the root layer + actor = Stage::GetCurrent().GetLayer( 0 ); + DALI_TEST_CHECK( actor.IsRoot() ); + END_TEST; +} + +int UtcDaliActorOnStage(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + DALI_TEST_CHECK( !actor.OnStage() ); + + // get the root layer + actor = Stage::GetCurrent().GetLayer( 0 ); + DALI_TEST_CHECK( actor.OnStage() ); + END_TEST; +} + +int UtcDaliActorIsLayer(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + DALI_TEST_CHECK( !actor.IsLayer() ); + + // get the root layer + actor = Stage::GetCurrent().GetLayer( 0 ); + DALI_TEST_CHECK( actor.IsLayer() ); + END_TEST; +} + +int UtcDaliActorGetLayer(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + Layer layer = actor.GetLayer(); + + DALI_TEST_CHECK(layer); + + // get the root layers layer + actor = Stage::GetCurrent().GetLayer( 0 ); + DALI_TEST_CHECK( actor.GetLayer() ); + END_TEST; +} + +int UtcDaliActorAdd(void) +{ + tet_infoline("Testing Actor::Add"); + TestApplication application; + + Actor parent = Actor::New(); + Actor child = Actor::New(); + + DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION ); + + parent.Add(child); + + DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION ); + + Actor parent2 = Actor::New(); + parent2.Add( child ); + + DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION ); + + // try Adding to same parent again, works + parent2.Add( child ); + DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION ); + + // try reparenting an orphaned child + { + Actor temporaryParent = Actor::New(); + temporaryParent.Add( child ); + DALI_TEST_EQUALS( parent2.GetChildCount(), 0u, TEST_LOCATION ); + } + // temporaryParent has now died, reparent the orphaned child + parent2.Add( child ); + DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION ); + + // try illegal Add + try + { + parent2.Add( parent2 ); + tet_printf("Assertion test failed - no Exception\n" ); + tet_result(TET_FAIL); + } + catch(Dali::DaliException& e) + { + tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION); + DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION ); + } + catch(...) + { + tet_printf("Assertion test failed - wrong Exception\n" ); + tet_result(TET_FAIL); + } + + // try reparenting root + try + { + parent2.Add( Stage::GetCurrent().GetLayer( 0 ) ); + tet_printf("Assertion test failed - no Exception\n" ); + tet_result(TET_FAIL); + } + catch(Dali::DaliException& e) + { + tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "!child.IsRoot()", TEST_LOCATION); + DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION ); + } + catch(...) + { + tet_printf("Assertion test failed - wrong Exception\n" ); + tet_result(TET_FAIL); + } + + // try Add empty + try + { + Actor empty; + parent2.Add( empty ); + tet_printf("Assertion test failed - no Exception\n" ); + tet_result(TET_FAIL); + } + catch(Dali::DaliException& e) + { + tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "actor", TEST_LOCATION); + DALI_TEST_EQUALS( parent2.GetChildCount(), 1u, TEST_LOCATION ); + } + catch(...) + { + tet_printf("Assertion test failed - wrong Exception\n" ); + tet_result(TET_FAIL); + } + END_TEST; +} + +int UtcDaliActorRemove01(void) +{ + tet_infoline("Testing Actor::Remove"); + TestApplication application; + + Actor parent = Actor::New(); + Actor child = Actor::New(); + DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION ); + + parent.Add(child); + DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION ); + + parent.Remove(child); + DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION ); + + // remove again, no problem + parent.Remove(child); + DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION ); + + // add child back + parent.Add(child); + // try illegal Remove + try + { + parent.Remove( parent ); + tet_printf("Assertion test failed - no Exception\n" ); + tet_result(TET_FAIL); + } + catch(Dali::DaliException& e) + { + tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "this != &child", TEST_LOCATION); + DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION ); + } + catch(...) + { + tet_printf("Assertion test failed - wrong Exception\n" ); + tet_result(TET_FAIL); + } + + // try Remove empty + try + { + Actor empty; + parent.Remove( empty ); + tet_printf("Assertion test failed - no Exception\n" ); + tet_result(TET_FAIL); + } + catch(Dali::DaliException& e) + { + tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "actor", TEST_LOCATION); + DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION ); + } + catch(...) + { + tet_printf("Assertion test failed - wrong Exception\n" ); + tet_result(TET_FAIL); + } + END_TEST; +} + +int UtcDaliActorRemove02(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Actor child = Actor::New(); + Actor random = Actor::New(); + + Stage::GetCurrent().Add( parent ); + + DALI_TEST_CHECK(parent.GetChildCount() == 0); + + parent.Add(child); + + DALI_TEST_CHECK(parent.GetChildCount() == 1); + + parent.Remove(random); + + DALI_TEST_CHECK(parent.GetChildCount() == 1); + + Stage::GetCurrent().Remove( parent ); + + DALI_TEST_CHECK(parent.GetChildCount() == 1); + END_TEST; +} + +int UtcDaliActorGetChildCount(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Actor child = Actor::New(); + + DALI_TEST_CHECK(parent.GetChildCount() == 0); + + parent.Add(child); + + DALI_TEST_CHECK(parent.GetChildCount() == 1); + END_TEST; +} + +int UtcDaliActorGetChildren01(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Actor first = Actor::New(); + Actor second = Actor::New(); + Actor third = Actor::New(); + + parent.Add(first); + parent.Add(second); + parent.Add(third); + + DALI_TEST_CHECK(parent.GetChildAt(0) == first); + DALI_TEST_CHECK(parent.GetChildAt(1) == second); + DALI_TEST_CHECK(parent.GetChildAt(2) == third); + END_TEST; +} + +int UtcDaliActorGetChildren02(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Actor first = Actor::New(); + Actor second = Actor::New(); + Actor third = Actor::New(); + + parent.Add(first); + parent.Add(second); + parent.Add(third); + + const Actor& constParent = parent; + + DALI_TEST_CHECK(constParent.GetChildAt(0) == first); + DALI_TEST_CHECK(constParent.GetChildAt(1) == second); + DALI_TEST_CHECK(constParent.GetChildAt(2) == third); + END_TEST; +} + +int UtcDaliActorGetParent01(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Actor child = Actor::New(); + + parent.Add(child); + + DALI_TEST_CHECK(child.GetParent() == parent); + END_TEST; +} + +int UtcDaliActorGetParent02(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + DALI_TEST_CHECK(!actor.GetParent()); + END_TEST; +} + +int UtcDaliActorSetParentOrigin(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + Vector3 vector(0.7f, 0.8f, 0.9f); + DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin()); + + actor.SetParentOrigin(vector); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin()); + + Stage::GetCurrent().Add( actor ); + + actor.SetParentOrigin( Vector3( 0.1f, 0.2f, 0.3f ) ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentParentOrigin(), TEST_LOCATION ); + + Stage::GetCurrent().Remove( actor ); + END_TEST; +} + +int UtcDaliActorGetCurrentParentOrigin(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + Vector3 vector(0.7f, 0.8f, 0.9f); + DALI_TEST_CHECK(vector != actor.GetCurrentParentOrigin()); + + actor.SetParentOrigin(vector); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(vector == actor.GetCurrentParentOrigin()); + END_TEST; +} + +int UtcDaliActorSetAnchorPoint(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + Vector3 vector(0.7f, 0.8f, 0.9f); + DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint()); + + actor.SetAnchorPoint(vector); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint()); + + Stage::GetCurrent().Add( actor ); + + actor.SetAnchorPoint( Vector3( 0.1f, 0.2f, 0.3f ) ); + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentAnchorPoint(), TEST_LOCATION ); + + Stage::GetCurrent().Remove( actor ); + END_TEST; +} + +int UtcDaliActorGetCurrentAnchorPoint(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + Vector3 vector(0.7f, 0.8f, 0.9f); + DALI_TEST_CHECK(vector != actor.GetCurrentAnchorPoint()); + + actor.SetAnchorPoint(vector); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(vector == actor.GetCurrentAnchorPoint()); + END_TEST; +} + +// SetSize(float width, float height) +int UtcDaliActorSetSize01(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Vector3 vector(100.0f, 100.0f, 100.0f); + + DALI_TEST_CHECK(vector != actor.GetCurrentSize()); + + actor.SetSize(vector.x, vector.y); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(vector == actor.GetCurrentSize()); + END_TEST; +} + +// SetSize(float width, float height, float depth) +int UtcDaliActorSetSize02(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Vector3 vector(100.0f, 100.0f, 100.0f); + + DALI_TEST_CHECK(vector != actor.GetCurrentSize()); + + actor.SetSize(vector.x, vector.y, vector.z); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(vector == actor.GetCurrentSize()); + END_TEST; +} + +// SetSize(Vector2 size) +int UtcDaliActorSetSize03(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Vector3 vector(100.0f, 100.0f, 100.0f); + + DALI_TEST_CHECK(vector != actor.GetCurrentSize()); + + actor.SetSize(Vector2(vector.x, vector.y)); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(vector == actor.GetCurrentSize()); + END_TEST; +} + +// SetSize(Vector3 size) +int UtcDaliActorSetSize04(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Vector3 vector(100.0f, 100.0f, 100.0f); + + DALI_TEST_CHECK(vector != actor.GetCurrentSize()); + + actor.SetSize(vector); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(vector == actor.GetCurrentSize()); + + Stage::GetCurrent().Add( actor ); + actor.SetSize( Vector3( 0.1f, 0.2f, 0.3f ) ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentSize(), TEST_LOCATION ); + Stage::GetCurrent().Remove( actor ); + END_TEST; +} + +int UtcDaliActorGetCurrentSize(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Vector3 vector(100.0f, 100.0f, 20.0f); + + DALI_TEST_CHECK(vector != actor.GetCurrentSize()); + + actor.SetSize(vector); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(vector == actor.GetCurrentSize()); + END_TEST; +} + +// SetPosition(float x, float y) +int UtcDaliActorSetPosition01(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Set to random to start off with + actor.SetPosition(Vector3(120.0f, 120.0f, 0.0f)); + + Vector3 vector(100.0f, 100.0f, 0.0f); + + DALI_TEST_CHECK(vector != actor.GetCurrentPosition()); + + actor.SetPosition(vector.x, vector.y); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK(vector == actor.GetCurrentPosition()); + + Stage::GetCurrent().Add( actor ); + actor.SetPosition( Vector3( 0.1f, 0.2f, 0.3f ) ); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), actor.GetCurrentPosition(), TEST_LOCATION ); + + actor.SetX( 1.0f ); + actor.SetY( 1.1f ); + actor.SetZ( 1.2f ); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( Vector3( 1.0f, 1.1f, 1.2f ), actor.GetCurrentPosition(), TEST_LOCATION ); + + actor.MoveBy( Vector3( 0.1f, 0.1f, 0.1f ) ); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( Vector3( 1.1f, 1.2f, 1.3f ), actor.GetCurrentPosition(), Math::MACHINE_EPSILON_10000, TEST_LOCATION ); + + Stage::GetCurrent().Remove( actor ); + END_TEST; +} + +// SetPosition(float x, float y, float z) +int UtcDaliActorSetPosition02(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Set to random to start off with + actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f)); + + Vector3 vector(100.0f, 100.0f, 100.0f); + + DALI_TEST_CHECK(vector != actor.GetCurrentPosition()); + + actor.SetPosition(vector.x, vector.y, vector.z); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(vector == actor.GetCurrentPosition()); + END_TEST; +} + +// SetPosition(Vector3 position) +int UtcDaliActorSetPosition03(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Set to random to start off with + actor.SetPosition(Vector3(120.0f, 120.0f, 120.0f)); + + Vector3 vector(100.0f, 100.0f, 100.0f); + + DALI_TEST_CHECK(vector != actor.GetCurrentPosition()); + + actor.SetPosition(vector); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(vector == actor.GetCurrentPosition()); + END_TEST; +} + +int UtcDaliActorSetX(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + Vector3 vector(100.0f, 0.0f, 0.0f); + + DALI_TEST_CHECK(vector != actor.GetCurrentPosition()); + + actor.SetX(100.0f); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(vector == actor.GetCurrentPosition()); + END_TEST; +} + +int UtcDaliActorSetY(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + Vector3 vector(0.0f, 100.0f, 0.0f); + + DALI_TEST_CHECK(vector != actor.GetCurrentPosition()); + + actor.SetY(100.0f); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(vector == actor.GetCurrentPosition()); + END_TEST; +} + +int UtcDaliActorSetZ(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + Vector3 vector(0.0f, 0.0f, 100.0f); + + DALI_TEST_CHECK(vector != actor.GetCurrentPosition()); + + actor.SetZ(100.0f); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(vector == actor.GetCurrentPosition()); + END_TEST; +} + +int UtcDaliActorMoveBy(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Vector3 vector(100.0f, 100.0f, 100.0f); + + DALI_TEST_CHECK(vector != actor.GetCurrentPosition()); + + actor.SetPosition(vector); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(vector == actor.GetCurrentPosition()); + + actor.MoveBy(vector); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(vector*2.0f == actor.GetCurrentPosition()); + END_TEST; +} + +int UtcDaliActorGetCurrentPosition(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Vector3 setVector(100.0f, 100.0f, 0.0f); + actor.SetPosition(setVector); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(actor.GetCurrentPosition() == setVector); + END_TEST; +} + +int UtcDaliActorGetCurrentWorldPosition(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Vector3 parentPosition( 1.0f, 2.0f, 3.0f ); + parent.SetPosition( parentPosition ); + parent.SetParentOrigin( ParentOrigin::CENTER ); + parent.SetAnchorPoint( AnchorPoint::CENTER ); + Stage::GetCurrent().Add( parent ); + + Actor child = Actor::New(); + child.SetParentOrigin( ParentOrigin::CENTER ); + child.SetAnchorPoint( AnchorPoint::CENTER ); + Vector3 childPosition( 6.0f, 6.0f, 6.0f ); + child.SetPosition( childPosition ); + parent.Add( child ); + + // The actors should not have a world position yet + DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION ); + + // The actors should have a world position now + DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliActorInheritPosition(void) +{ + tet_infoline("Testing Actor::SetPositionInheritanceMode"); + TestApplication application; + + Actor parent = Actor::New(); + Vector3 parentPosition( 1.0f, 2.0f, 3.0f ); + parent.SetPosition( parentPosition ); + parent.SetParentOrigin( ParentOrigin::CENTER ); + parent.SetAnchorPoint( AnchorPoint::CENTER ); + Stage::GetCurrent().Add( parent ); + + Actor child = Actor::New(); + child.SetParentOrigin( ParentOrigin::CENTER ); + child.SetAnchorPoint( AnchorPoint::CENTER ); + Vector3 childPosition( 10.0f, 11.0f, 12.0f ); + child.SetPosition( childPosition ); + parent.Add( child ); + + // The actors should not have a world position yet + DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION ); + + // first test default, which is INHERIT_PARENT_POSITION + DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::INHERIT_PARENT_POSITION, TEST_LOCATION ); + application.SendNotification(); + application.Render(0); // should only really call Update as Render is not required to update scene + DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childPosition, TEST_LOCATION ); + + // Change inheritance mode to use parent + child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); + DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION, TEST_LOCATION ); + application.SendNotification(); + application.Render(0); // should only really call Update as Render is not required to update scene + DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION ); + + // Change inheritance mode to use parent + offset + child.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION ); + Vector3 childOffset( -1.0f, 1.0f, 0.0f ); + child.SetPosition( childOffset ); + DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION, TEST_LOCATION ); + application.SendNotification(); + application.Render(0); // should only really call Update as Render is not required to update scene + DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION ); + DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), parentPosition + childOffset, TEST_LOCATION ); + + // Change inheritance mode to not inherit + child.SetPositionInheritanceMode( Dali::DONT_INHERIT_POSITION ); + DALI_TEST_EQUALS( child.GetPositionInheritanceMode(), Dali::DONT_INHERIT_POSITION, TEST_LOCATION ); + application.SendNotification(); + application.Render(0); // should only really call Update as Render is not required to update scene + DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentPosition(), childOffset, TEST_LOCATION ); + DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), childOffset, TEST_LOCATION ); + END_TEST; +} + +// SetRotation(float angleRadians, Vector3 axis) +int UtcDaliActorSetRotation01(void) +{ + TestApplication application; + + Quaternion rotation(0.785f, Vector3(1.0f, 1.0f, 0.0f)); + Actor actor = Actor::New(); + + actor.SetRotation(rotation); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION); + END_TEST; +} + +int UtcDaliActorSetRotation02(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + float angle = 0.785f; + Vector3 axis(1.0f, 1.0f, 0.0f); + + actor.SetRotation(Radian( angle ), axis); + Quaternion rotation( angle, axis ); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION); + + Stage::GetCurrent().Add( actor ); + actor.RotateBy( Degree( 360 ), axis); + DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION); + + actor.SetRotation( Degree( 0 ), Vector3( 1.0f, 0.0f, 0.0f ) ); + Quaternion result( 0, Vector3( 1.0f, 0.0f, 0.0f ) ); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( result, actor.GetCurrentRotation(), 0.001, TEST_LOCATION); + + actor.SetRotation(Radian( angle ), axis); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION); + + Stage::GetCurrent().Remove( actor ); + END_TEST; +} + +// RotateBy(float angleRadians, Vector3 axis) +int UtcDaliActorRotateBy01(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + float angle = M_PI * 0.25f; + actor.RotateBy(Radian( angle ), Vector3::ZAXIS); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(Quaternion(M_PI*0.25f, Vector3::ZAXIS), actor.GetCurrentRotation(), 0.001, TEST_LOCATION); + + Stage::GetCurrent().Add( actor ); + + actor.RotateBy(Radian( angle ), Vector3::ZAXIS); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(Quaternion(M_PI*0.5f, Vector3::ZAXIS), actor.GetCurrentRotation(), 0.001, TEST_LOCATION); + + Stage::GetCurrent().Remove( actor ); + END_TEST; +} + +// RotateBy(Quaternion relativeRotation) +int UtcDaliActorRotateBy02(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + Quaternion rotation(M_PI*0.25f, Vector3::ZAXIS); + actor.RotateBy(rotation); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION); + + actor.RotateBy(rotation); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(Quaternion(M_PI*0.5f, Vector3::ZAXIS), actor.GetCurrentRotation(), 0.001, TEST_LOCATION); + END_TEST; +} + +int UtcDaliActorGetCurrentRotation(void) +{ + TestApplication application; + Actor actor = Actor::New(); + + Quaternion rotation(0.785f, Vector3(1.0f, 1.0f, 0.0f)); + actor.SetRotation(rotation); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(rotation, actor.GetCurrentRotation(), 0.001, TEST_LOCATION); + END_TEST; +} + +int UtcDaliActorGetCurrentWorldRotation(void) +{ + tet_infoline("Testing Actor::GetCurrentWorldRotation"); + TestApplication application; + + Actor parent = Actor::New(); + Radian rotationAngle( Degree(90.0f) ); + Quaternion rotation( rotationAngle, Vector3::YAXIS ); + parent.SetRotation( rotation ); + Stage::GetCurrent().Add( parent ); + + Actor child = Actor::New(); + child.SetRotation( rotation ); + parent.Add( child ); + + // The actors should not have a world rotation yet + DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( parent.GetCurrentRotation(), rotation, 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentRotation(), rotation, 0.001, TEST_LOCATION ); + + // The actors should have a world rotation now + DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION ); + + // turn off child rotation inheritance + child.SetInheritRotation( false ); + DALI_TEST_EQUALS( child.IsRotationInherited(), false, TEST_LOCATION ); + application.SendNotification(); + application.Render(0); + + // The actors should have a world rotation now + DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), rotation, 0.001, TEST_LOCATION ); + END_TEST; +} + +// SetScale(float scale) +int UtcDaliActorSetScale01(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Set to random value first - GetCurrentScale() asserts if called before SetScale() + actor.SetScale(0.25f); + + Vector3 scale(10.0f, 10.0f, 10.0f); + DALI_TEST_CHECK(actor.GetCurrentScale() != scale); + + actor.SetScale(scale.x); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(actor.GetCurrentScale() == scale); + END_TEST; +} + +// SetScale(float scaleX, float scaleY, float scaleZ) +int UtcDaliActorSetScale02(void) +{ + TestApplication application; + Vector3 scale(10.0f, 10.0f, 10.0f); + + Actor actor = Actor::New(); + + // Set to random value first - GetCurrentScale() asserts if called before SetScale() + actor.SetScale(Vector3(12.0f, 1.0f, 2.0f)); + + DALI_TEST_CHECK(actor.GetCurrentScale() != scale); + + actor.SetScale(scale.x, scale.y, scale.z); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK(actor.GetCurrentScale() == scale); + + // add to stage and test + Stage::GetCurrent().Add( actor ); + actor.SetScale( 2.0f, 2.0f, 2.0f ); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( Vector3( 2.0f, 2.0f, 2.0f ), actor.GetCurrentScale(), 0.001, TEST_LOCATION); + + Stage::GetCurrent().Remove( actor ); + + END_TEST; +} + +// SetScale(Vector3 scale) +int UtcDaliActorSetScale03(void) +{ + TestApplication application; + Vector3 scale(10.0f, 10.0f, 10.0f); + + Actor actor = Actor::New(); + + // Set to random value first - GetCurrentScale() asserts if called before SetScale() + actor.SetScale(Vector3(12.0f, 1.0f, 2.0f)); + + DALI_TEST_CHECK(actor.GetCurrentScale() != scale); + + actor.SetScale(scale); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(actor.GetCurrentScale() == scale); + END_TEST; +} + +int UtcDaliActorScaleBy(void) +{ + TestApplication application; + Actor actor = Actor::New(); + Vector3 vector(100.0f, 100.0f, 100.0f); + + DALI_TEST_CHECK(vector != actor.GetCurrentScale()); + + actor.SetScale(vector); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(vector == actor.GetCurrentScale()); + + actor.ScaleBy(vector); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(vector*100.0f == actor.GetCurrentScale()); + END_TEST; +} + +int UtcDaliActorGetCurrentScale(void) +{ + TestApplication application; + Vector3 scale(12.0f, 1.0f, 2.0f); + + Actor actor = Actor::New(); + + actor.SetScale(scale); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(actor.GetCurrentScale() == scale); + END_TEST; +} + +int UtcDaliActorGetCurrentWorldScale(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Vector3 parentScale( 1.0f, 2.0f, 3.0f ); + parent.SetScale( parentScale ); + Stage::GetCurrent().Add( parent ); + + Actor child = Actor::New(); + Vector3 childScale( 2.0f, 2.0f, 2.0f ); + child.SetScale( childScale ); + parent.Add( child ); + + // The actors should not have a scale yet + DALI_TEST_EQUALS( parent.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + + // The actors should not have a world scale yet + DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION ); + + // The actors should have a world scale now + DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliActorInheritScale(void) +{ + tet_infoline("Testing Actor::SetInheritScale"); + TestApplication application; + + Actor parent = Actor::New(); + Vector3 parentScale( 1.0f, 2.0f, 3.0f ); + parent.SetScale( parentScale ); + Stage::GetCurrent().Add( parent ); + + Actor child = Actor::New(); + Vector3 childScale( 2.0f, 2.0f, 2.0f ); + child.SetScale( childScale ); + parent.Add( child ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( child.IsScaleInherited(), true, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldScale(), parentScale * childScale, TEST_LOCATION ); + + child.SetInheritScale( false ); + DALI_TEST_EQUALS( child.IsScaleInherited(), false, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( child.GetCurrentWorldScale(), childScale, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliActorSetVisible(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetVisible(false); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK(actor.IsVisible() == false); + + actor.SetVisible(true); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK(actor.IsVisible() == true); + + // put actor on stage + Stage::GetCurrent().Add( actor ); + actor.SetVisible(false); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK(actor.IsVisible() == false); + END_TEST; +} + +int UtcDaliActorIsVisible(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + DALI_TEST_CHECK(actor.IsVisible() == true); + END_TEST; +} + +int UtcDaliActorSetOpacity(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + // initial opacity is 1 + DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION ); + + actor.SetOpacity( 0.4f); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.4f, TEST_LOCATION ); + + // change opacity, actor is on stage to change is not immediate + actor.OpacityBy( 0.1f ); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION ); + + // put actor on stage + Stage::GetCurrent().Add( actor ); + + // change opacity, actor is on stage to change is not immediate + actor.SetOpacity( 0.9f ); + DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.5f, TEST_LOCATION ); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.9f, TEST_LOCATION ); + + // change opacity, actor is on stage to change is not immediate + actor.OpacityBy( -0.9f ); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(actor.GetCurrentOpacity(), 0.0f, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliActorGetCurrentOpacity(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + DALI_TEST_CHECK(actor.GetCurrentOpacity() != 0.5f); + + actor.SetOpacity(0.5f); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK(actor.GetCurrentOpacity() == 0.5f); + END_TEST; +} + +int UtcDaliActorSetSensitive(void) +{ + TestApplication application; + Actor actor = Actor::New(); + + bool sensitive = !actor.IsSensitive(); + + actor.SetSensitive(sensitive); + + DALI_TEST_CHECK(sensitive == actor.IsSensitive()); + END_TEST; +} + +int UtcDaliActorIsSensitive(void) +{ + TestApplication application; + Actor actor = Actor::New(); + actor.SetSensitive(false); + + DALI_TEST_CHECK(false == actor.IsSensitive()); + END_TEST; +} + +int UtcDaliActorSetInheritShaderEffect(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + actor.SetInheritShaderEffect(false); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK(actor.GetInheritShaderEffect() == false); + + actor.SetInheritShaderEffect(true); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK(actor.GetInheritShaderEffect() == true); + END_TEST; +} + +int UtcDaliActorGetInheritShaderEffect(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + DALI_TEST_CHECK(actor.GetInheritShaderEffect() == true); + END_TEST; +} + +int UtcDaliActorSetShaderEffect(void) +{ + TestApplication application; + Actor actor = Actor::New(); + + ShaderEffect effect = ShaderEffect::New(vertexSource, fragmentSource); + + DALI_TEST_CHECK(effect != actor.GetShaderEffect()); + + actor.SetShaderEffect(effect); + + DALI_TEST_CHECK(effect == actor.GetShaderEffect()); + END_TEST; +} + +int UtcDaliActorGetShaderEffect(void) +{ + TestApplication application; + Actor actor = Actor::New(); + + ShaderEffect effect = ShaderEffect::New(vertexSource, fragmentSource); + actor.SetShaderEffect(effect); + + DALI_TEST_CHECK(effect == actor.GetShaderEffect()); + END_TEST; +} + +int UtcDaliActorRemoveShaderEffect01(void) +{ + TestApplication application; + Actor actor = Actor::New(); + + ShaderEffect defaultEffect = actor.GetShaderEffect(); + + ShaderEffect effect = ShaderEffect::New(vertexSource, fragmentSource); + actor.SetShaderEffect(effect); + + DALI_TEST_CHECK(effect == actor.GetShaderEffect()); + + actor.RemoveShaderEffect(); + + DALI_TEST_CHECK(defaultEffect == actor.GetShaderEffect()); + END_TEST; +} + +int UtcDaliActorRemoveShaderEffect02(void) +{ + TestApplication application; + Actor actor = Actor::New(); + + ShaderEffect defaultEffect = actor.GetShaderEffect(); + + actor.RemoveShaderEffect(); + + DALI_TEST_CHECK(defaultEffect == actor.GetShaderEffect()); + END_TEST; +} + +int UtcDaliActorSetColor(void) +{ + TestApplication application; + Actor actor = Actor::New(); + Vector4 color(1.0f, 1.0f, 1.0f, 0.5f); + + DALI_TEST_CHECK(color != actor.GetCurrentColor()); + + actor.SetColor(color); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK(color == actor.GetCurrentColor()); + + actor.ColorBy( Vector4( -0.4f, -0.5f, -0.6f, -0.4f ) ); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( Vector4( 0.6f, 0.5f, 0.4f, 0.1f ), actor.GetCurrentColor(), TEST_LOCATION ); + + Stage::GetCurrent().Add( actor ); + actor.SetColor( color ); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( color, actor.GetCurrentColor(), TEST_LOCATION ); + + actor.ColorBy( Vector4( 1.1f, 1.1f, 1.1f, 1.1f ) ); + // flush the queue and render once + application.SendNotification(); + application.Render(); + // Actor color is not clamped + DALI_TEST_EQUALS( Vector4( 2.1f, 2.1f, 2.1f, 1.6f ), actor.GetCurrentColor(), TEST_LOCATION ); + // world color is clamped + DALI_TEST_EQUALS( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), actor.GetCurrentWorldColor(), TEST_LOCATION ); + + Stage::GetCurrent().Remove( actor ); + END_TEST; +} + +int UtcDaliActorGetCurrentColor(void) +{ + TestApplication application; + Actor actor = Actor::New(); + Vector4 color(1.0f, 1.0f, 1.0f, 0.5f); + + actor.SetColor(color); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK(color == actor.GetCurrentColor()); + END_TEST; +} + +int UtcDaliActorGetCurrentWorldColor(void) +{ + tet_infoline("Actor::GetCurrentWorldColor"); + TestApplication application; + + Actor parent = Actor::New(); + Vector4 parentColor( 1.0f, 0.5f, 0.0f, 0.8f ); + parent.SetColor( parentColor ); + Stage::GetCurrent().Add( parent ); + + Actor child = Actor::New(); + Vector4 childColor( 0.5f, 0.6f, 0.5f, 1.0f ); + child.SetColor( childColor ); + parent.Add( child ); + + DALI_TEST_EQUALS( parent.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); + + // verify the default color mode + DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, child.GetColorMode(), TEST_LOCATION ); + + // The actors should not have a world color yet + DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION ); + + // The actors should have a world color now + DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Vector4( childColor.r, childColor.g, childColor.b, childColor.a * parentColor.a), TEST_LOCATION ); + + // use own color + child.SetColorMode( USE_OWN_COLOR ); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( child.GetCurrentWorldColor(), childColor, TEST_LOCATION ); + + // use parent color + child.SetColorMode( USE_PARENT_COLOR ); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldColor(), parentColor, TEST_LOCATION ); + + // use parent alpha + child.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA ); + application.SendNotification(); + application.Render(0); + Vector4 expectedColor( childColor ); + expectedColor.a *= parentColor.a; + DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldColor(), expectedColor, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliActorSetColorMode(void) +{ + tet_infoline("Actor::SetColorMode"); + TestApplication application; + Actor actor = Actor::New(); + Actor child = Actor::New(); + actor.Add( child ); + + actor.SetColorMode( USE_OWN_COLOR ); + DALI_TEST_EQUALS( USE_OWN_COLOR, actor.GetColorMode(), TEST_LOCATION ); + + actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR ); + DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION ); + + actor.SetColorMode( USE_PARENT_COLOR ); + DALI_TEST_EQUALS( USE_PARENT_COLOR, actor.GetColorMode(), TEST_LOCATION ); + + actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_ALPHA ); + DALI_TEST_EQUALS( USE_OWN_MULTIPLY_PARENT_ALPHA, actor.GetColorMode(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliActorScreenToLocal(void) +{ + TestApplication application; + Actor actor = Actor::New(); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + actor.SetSize(100.0f, 100.0f); + actor.SetPosition(10.0f, 10.0f); + Stage::GetCurrent().Add(actor); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + float localX; + float localY; + + DALI_TEST_CHECK( actor.ScreenToLocal(localX, localY, 50.0f, 50.0f) ); + + DALI_TEST_EQUALS(localX, 40.0f, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(localY, 40.0f, 0.01f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliActorSetLeaveRequired(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + actor.SetLeaveRequired(false); + DALI_TEST_CHECK(actor.GetLeaveRequired() == false); + + actor.SetLeaveRequired(true); + DALI_TEST_CHECK(actor.GetLeaveRequired() == true); + END_TEST; +} + +int UtcDaliActorGetLeaveRequired(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + DALI_TEST_CHECK(actor.GetLeaveRequired() == false); + END_TEST; +} + +int UtcDaliActorSetKeyboardFocusable(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + actor.SetKeyboardFocusable(true); + DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true); + + actor.SetKeyboardFocusable(false); + DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false); + END_TEST; +} + +int UtcDaliActorIsKeyboardFocusable(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false); + END_TEST; +} + + +int UtcDaliActorApplyConstraint(void) +{ + TestApplication application; + + gTestConstraintCalled = false; + + Actor actor = Actor::New(); + + Constraint constraint = Constraint::New( Actor::COLOR, TestConstraint() ); + actor.ApplyConstraint(constraint); + + DALI_TEST_CHECK( gTestConstraintCalled == false ); + // add to stage + Stage::GetCurrent().Add( actor ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( gTestConstraintCalled == true ); + END_TEST; +} + + +int UtcDaliActorApplyConstraintAppliedCallback(void) +{ + TestApplication application; + + // Build a reusable constraint + + Actor parent = Actor::New(); + Vector3 parentSize( 100.0f, 100.0f, 100.0f ); + parent.SetSize( parentSize ); + Stage::GetCurrent().Add( parent ); + + Constraint constraint = Constraint::New( Actor::SIZE, + Source( parent, Actor::SIZE ), + EqualToConstraint() ); + + // Create some child actors + + Actor child1 = Actor::New(); + parent.Add( child1 ); + + Actor child2 = Actor::New(); + parent.Add( child2 ); + + Actor child3 = Actor::New(); + parent.Add( child3 ); + + // Apply constraint with different timings - everything should be finished after 10 seconds + + wasConstraintCallbackCalled1 = false; + wasConstraintCallbackCalled2 = false; + wasConstraintCallbackCalled3 = false; + + constraint.SetApplyTime( 5.0f ); + ActiveConstraint activeConstraint1 = child1.ApplyConstraint( constraint ); + activeConstraint1.AppliedSignal().Connect( TestConstraintCallback1 ); + + constraint.SetApplyTime( 10.0f ); + ActiveConstraint activeConstraint2 = child2.ApplyConstraint( constraint ); + activeConstraint2.AppliedSignal().Connect( TestConstraintCallback2 ); + + constraint.SetApplyTime( TimePeriod( 2.0f/*delay*/, 5.0f/*duration*/ ) ); + ActiveConstraint activeConstraint3 = child3.ApplyConstraint( constraint ); + activeConstraint3.AppliedSignal().Connect( TestConstraintCallback3 ); + + DALI_TEST_EQUALS( child1.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( child2.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( child3.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + + application.SendNotification(); + + application.Render(static_cast(1000.0f)); // 1 elapsed second + DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // 1 / 5 * 100 = 20% + DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.10f, TEST_LOCATION ); // 1 / 10 * 100 = 10% + DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.00f, TEST_LOCATION ); // 0% + + // Check signals have not fired + application.SendNotification(); + DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION ); + DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION ); + DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION ); + + application.Render(static_cast(1000.0f)); // 2 elapsed seconds + DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // 2 / 5 * 100 = 40% + DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // 2 / 10 * 100 = 20% + DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.00f, TEST_LOCATION ); // 0% + + // Check signals have not fired + application.SendNotification(); + DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION ); + DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION ); + DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION ); + + application.Render(static_cast(1000.0f)); // 3 elapsed seconds + DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // 3 / 5 * 100 = 60% + DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.30f, TEST_LOCATION ); // 3 / 10 * 100 = 30% + DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.20f, TEST_LOCATION ); // (3 - 2) / 5 * 100 = 20% + + // Check signals have not fired + application.SendNotification(); + DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION ); + DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION ); + DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION ); + + application.Render(static_cast(1000.0f)); // 4 elapsed seconds + DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // 4 / 5 * 100 = 80% + DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // 4 / 10 * 100 = 40% + DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.40f, TEST_LOCATION ); // (4 - 2) / 5 * 100 = 40% + + // Check signals have not fired + application.SendNotification(); + DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION ); + DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION ); + DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION ); + + application.Render(static_cast(1000.0f)); // 5 elapsed seconds + DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // 5 / 5 * 100 = 100% + DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.50f, TEST_LOCATION ); // 5 / 10 * 100 = 50% + DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // (5 - 2) / 5 * 100 = 60% + + // Check signals have not fired + application.SendNotification(); + DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION ); + DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION ); + DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION ); + + application.Render(static_cast(1000.0f)); // 6 elapsed seconds + DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 1 should fire) + DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.60f, TEST_LOCATION ); // 6 / 10 * 100 = 60% + DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // (6 - 2) / 5 * 100 = 80% + + // 1st signal should have fired + application.SendNotification(); + DALI_TEST_EQUALS( wasConstraintCallbackCalled1, true, TEST_LOCATION ); + wasConstraintCallbackCalled1 = false; + DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION ); + DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION ); + + application.Render(static_cast(1000.0f)); // 7 elapsed seconds + DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% + DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.70f, TEST_LOCATION ); // 7 / 10 * 100 = 70% + DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // (7 - 2) / 5 * 100 = 100% + + // Check signals have not fired + application.SendNotification(); + DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION ); + DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION ); + DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION ); + + application.Render(static_cast(1000.0f)); // 8 elapsed seconds + DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% + DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.80f, TEST_LOCATION ); // 8 / 10 * 100 = 80% + DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 3 should fire) + + // 3rd signal should have fired + application.SendNotification(); + + DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION ); + DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION ); + DALI_TEST_EQUALS( wasConstraintCallbackCalled3, true, TEST_LOCATION ); + wasConstraintCallbackCalled3 = false; + + application.Render(static_cast(1000.0f)); // 9 elapsed seconds + DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% + DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize*0.90f, TEST_LOCATION ); // 9 / 10 * 100 = 90% + DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% + + // Check signals have not fired + application.SendNotification(); + DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION ); + DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION ); + DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION ); + + application.Render(static_cast(1000.0f + 1.0f)); // over 10 elapsed seconds + DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% + DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% (signal 2 should fire) + DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); // Past 100% + + // 2nd signal should have fired + application.SendNotification(); + DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION ); + DALI_TEST_EQUALS( wasConstraintCallbackCalled2, true, TEST_LOCATION ); + wasConstraintCallbackCalled2 = false; + DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + + application.Render(0); + DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); + DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION ); + DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); + + application.SendNotification(); + DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION ); + DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION ); + DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION ); + + application.Render(0); + DALI_TEST_EQUALS( child1.GetCurrentSize(), parentSize, TEST_LOCATION ); + DALI_TEST_EQUALS( child2.GetCurrentSize(), parentSize, TEST_LOCATION ); + DALI_TEST_EQUALS( child3.GetCurrentSize(), parentSize, TEST_LOCATION ); + + application.SendNotification(); + DALI_TEST_EQUALS( wasConstraintCallbackCalled1, false, TEST_LOCATION ); + DALI_TEST_EQUALS( wasConstraintCallbackCalled2, false, TEST_LOCATION ); + DALI_TEST_EQUALS( wasConstraintCallbackCalled3, false, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliActorRemoveConstraints(void) +{ + tet_infoline(" UtcDaliActorRemoveConstraints"); + TestApplication application; + + gTestConstraintCalled = false; + + Actor actor = Actor::New(); + + Constraint constraint = Constraint::New( Actor::COLOR, TestConstraint() ); + actor.ApplyConstraint(constraint); + actor.RemoveConstraints(); + + DALI_TEST_CHECK( gTestConstraintCalled == false ); + + Stage::GetCurrent().Add( actor ); + actor.ApplyConstraint(constraint); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + actor.RemoveConstraints(); + + DALI_TEST_CHECK( gTestConstraintCalled == true ); + END_TEST; +} + +int UtcDaliActorRemoveConstraint(void) +{ + tet_infoline(" UtcDaliActorRemoveConstraint"); + TestApplication application; + + Actor actor = Actor::New(); + + // 1. Apply Constraint1 and Constraint2, and test... + unsigned int result1 = 0u; + unsigned int result2 = 0u; + ActiveConstraint activeConstraint1 = actor.ApplyConstraint( Constraint::New( Actor::COLOR, TestConstraintRef(result1, 1) ) ); + ActiveConstraint activeConstraint2 = actor.ApplyConstraint( Constraint::New( Actor::COLOR, TestConstraintRef(result2, 2) ) ); + + Stage::GetCurrent().Add( actor ); + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION ); + + // 2. Remove Constraint1 and test... + result1 = 0; + result2 = 0; + actor.RemoveConstraint(activeConstraint1); + // make color property dirty, which will trigger constraints to be reapplied. + actor.SetColor( Color::WHITE ); + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now. + DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION ); + + // 3. Re-Apply Constraint1 and test... + result1 = 0; + result2 = 0; + activeConstraint1 = actor.ApplyConstraint( Constraint::New( Actor::COLOR, TestConstraintRef(result1, 1) ) ); + // make color property dirty, which will trigger constraints to be reapplied. + actor.SetColor( Color::WHITE ); + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( result2, 2u, TEST_LOCATION ); + + // 2. Remove Constraint2 and test... + result1 = 0; + result2 = 0; + actor.RemoveConstraint(activeConstraint2); + // make color property dirty, which will trigger constraints to be reapplied. + actor.SetColor( Color::WHITE ); + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( result1, 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now. + + // 2. Remove Constraint1 as well and test... + result1 = 0; + result2 = 0; + actor.RemoveConstraint(activeConstraint1); + // make color property dirty, which will trigger constraints to be reapplied. + actor.SetColor( Color::WHITE ); + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( result1, 0u, TEST_LOCATION ); ///< constraint 1 should not apply now. + DALI_TEST_EQUALS( result2, 0u, TEST_LOCATION ); ///< constraint 2 should not apply now. + END_TEST; +} + + +int UtcDaliActorTouchedSignal(void) +{ + TestApplication application; + + gTouchCallBackCalled = false; + + // get the root layer + Actor actor = Stage::GetCurrent().GetRootLayer(); + DALI_TEST_CHECK( gTouchCallBackCalled == false ); + + application.SendNotification(); + application.Render(); + + // connect to its touch signal + actor.TouchedSignal().Connect( TestCallback ); + + // simulate a touch event in the middle of the screen + Vector2 touchPoint( Stage::GetCurrent().GetSize() * 0.5 ); + Dali::TouchPoint point( 1, TouchPoint::Down, touchPoint.x, touchPoint.y ); + Dali::Integration::TouchEvent event; + event.AddPoint( point ); + application.ProcessEvent( event ); + + DALI_TEST_CHECK( gTouchCallBackCalled == true ); + END_TEST; +} + + +int UtcDaliActorSetSizeSignal(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSizeSignal().Connect( SetSizeCallback ); + + gSetSize.x = gSetSize.y = gSetSize.z = 0.0f; + gSetSizeCallBackCalled = false; + Vector2 size2d( 1.0f, 2.0f ); + actor.SetSize( size2d ); + DALI_TEST_CHECK( gSetSizeCallBackCalled == true ); + // SetSize with Vector2 sets depth to be the minimum of width & height + DALI_TEST_EQUALS( Vector3( 1.0f, 2.0f, 1.0f ), gSetSize, TEST_LOCATION ); + + gSetSize.x = gSetSize.y = gSetSize.z = 0.0f; + gSetSizeCallBackCalled = false; + actor.SetSize( 22.0f, 11.0f ); + DALI_TEST_CHECK( gSetSizeCallBackCalled == true ); + // SetSize with Vector2 sets depth to be the minimum of width & height + DALI_TEST_EQUALS( Vector3( 22.0f, 11.0f, 11.0f ), gSetSize, TEST_LOCATION ); + + gSetSize.x = gSetSize.y = gSetSize.z = 0.0f; + gSetSizeCallBackCalled = false; + Vector3 size( 3.0f, 4.0f, 5.0f ); + actor.SetSize( size ); + DALI_TEST_CHECK( gSetSizeCallBackCalled == true ); + DALI_TEST_EQUALS( size, gSetSize, TEST_LOCATION ); + + // add actor to stage to see that signal still works + Stage::GetCurrent().Add( actor ); + + gSetSize.x = gSetSize.y = gSetSize.z = 0.0f; + gSetSizeCallBackCalled = false; + actor.SetSize( -1.0f, -2.0f, -3.0f ); + DALI_TEST_CHECK( gSetSizeCallBackCalled == true ); + DALI_TEST_EQUALS( Vector3( -1.0f, -2.0f, -3.0f ), gSetSize, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliActorOnOffStageSignal(void) +{ + tet_infoline("Testing Dali::Actor::OnStageSignal() and OffStageSignal()"); + + TestApplication application; + + // clean test data + gOnStageCallBackCalled = gOffStageCallBackCalled = 0; + gActorNamesOnOffStage.clear(); + + Actor parent = Actor::New(); + parent.SetName( "parent" ); + parent.OnStageSignal().Connect( OnStageCallback ); + parent.OffStageSignal().Connect( OffStageCallback ); + // sanity check + DALI_TEST_CHECK( gOnStageCallBackCalled == 0 ); + DALI_TEST_CHECK( gOffStageCallBackCalled == 0 ); + + // add parent to stage + Stage::GetCurrent().Add( parent ); + // onstage emitted, offstage not + DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION ); + DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION ); + + // test adding a child, should get onstage emitted + // clean test data + gOnStageCallBackCalled = gOffStageCallBackCalled = 0; + gActorNamesOnOffStage.clear(); + + Actor child = Actor::New(); + child.SetName( "child" ); + child.OnStageSignal().Connect( OnStageCallback ); + child.OffStageSignal().Connect( OffStageCallback ); + parent.Add( child ); // add child + // onstage emitted, offstage not + DALI_TEST_EQUALS( gOnStageCallBackCalled, 1, TEST_LOCATION ); + DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION ); + + // test removing parent from stage + // clean test data + gOnStageCallBackCalled = gOffStageCallBackCalled = 0; + gActorNamesOnOffStage.clear(); + + Stage::GetCurrent().Remove( parent ); + // onstage not emitted, offstage is + DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( gOffStageCallBackCalled, 2, TEST_LOCATION ); + DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 1 ], TEST_LOCATION ); + + // test adding parent back to stage + // clean test data + gOnStageCallBackCalled = gOffStageCallBackCalled = 0; + gActorNamesOnOffStage.clear(); + + Stage::GetCurrent().Add( parent ); + // onstage emitted, offstage not + DALI_TEST_EQUALS( gOnStageCallBackCalled, 2, TEST_LOCATION ); + DALI_TEST_EQUALS( gOffStageCallBackCalled, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 1 ], TEST_LOCATION ); + + // test removing child + // clean test data + gOnStageCallBackCalled = gOffStageCallBackCalled = 0; + gActorNamesOnOffStage.clear(); + + parent.Remove( child ); + // onstage not emitted, offstage is + DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION ); + DALI_TEST_EQUALS( "child", gActorNamesOnOffStage[ 0 ], TEST_LOCATION ); + + // test removing parent + // clean test data + gOnStageCallBackCalled = gOffStageCallBackCalled = 0; + gActorNamesOnOffStage.clear(); + + Stage::GetCurrent().Remove( parent ); + // onstage not emitted, offstage is + DALI_TEST_EQUALS( gOnStageCallBackCalled, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( gOffStageCallBackCalled, 1, TEST_LOCATION ); + DALI_TEST_EQUALS( "parent", gActorNamesOnOffStage[ 0 ], TEST_LOCATION ); + END_TEST; +} + +int UtcDaliActorFindChildByName(void) +{ + tet_infoline("Testing Dali::Actor::FindChildByName()"); + TestApplication application; + + Actor parent = Actor::New(); + parent.SetName( "parent" ); + Actor first = Actor::New(); + first .SetName( "first" ); + Actor second = Actor::New(); + second.SetName( "second" ); + + parent.Add(first); + first.Add(second); + + Actor found = parent.FindChildByName( "foo" ); + DALI_TEST_CHECK( !found ); + + found = parent.FindChildByName( "parent" ); + DALI_TEST_CHECK( found == parent ); + + found = parent.FindChildByName( "first" ); + DALI_TEST_CHECK( found == first ); + + found = parent.FindChildByName( "second" ); + DALI_TEST_CHECK( found == second ); + END_TEST; +} + +int UtcDaliActorFindChildByAlias(void) +{ + tet_infoline("Testing Dali::Actor::FindChildByAlias()"); + TestApplication application; + + Actor parent = Actor::New(); + parent.SetName( "parent" ); + Actor first = Actor::New(); + first .SetName( "first" ); + Actor second = Actor::New(); + second.SetName( "second" ); + + parent.Add(first); + first.Add(second); + + Actor found = parent.FindChildByAlias( "foo" ); + DALI_TEST_CHECK( !found ); + + found = parent.FindChildByAlias( "parent" ); + DALI_TEST_CHECK( found == parent ); + + found = parent.FindChildByAlias( "first" ); + DALI_TEST_CHECK( found == first ); + + found = parent.FindChildByAlias( "second" ); + DALI_TEST_CHECK( found == second ); + END_TEST; +} + +int UtcDaliActorFindChildById(void) +{ + tet_infoline("Testing Dali::Actor::UtcDaliActorFindChildById()"); + TestApplication application; + + Actor parent = Actor::New(); + Actor first = Actor::New(); + Actor second = Actor::New(); + + parent.Add(first); + first.Add(second); + + Actor found = parent.FindChildById( 100000 ); + DALI_TEST_CHECK( !found ); + + found = parent.FindChildById( parent.GetId() ); + DALI_TEST_CHECK( found == parent ); + + found = parent.FindChildById( first.GetId() ); + DALI_TEST_CHECK( found == first ); + + found = parent.FindChildById( second.GetId() ); + DALI_TEST_CHECK( found == second ); + END_TEST; +} + +int UtcDaliActorHitTest(void) +{ + struct HitTestData + { + public: + HitTestData( const Vector3& scale, const Vector2& touchPoint, bool result ) + : mScale( scale ), + mTouchPoint( touchPoint ), + mResult( result ) + {} + + Vector3 mScale; + Vector2 mTouchPoint; + bool mResult; + }; + + TestApplication application; + tet_infoline(" UtcDaliActorHitTest"); + + // Fill a vector with different hit tests. + struct HitTestData* hitTestData[] = { + // scale touch point result + new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 289.f, 400.f ), true ), // touch point close to the right edge (inside) + new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), false ), // touch point close to the right edge (outside) + new HitTestData( Vector3( 110.f, 100.f, 1.f ), Vector2( 291.f, 400.f ), true ), // same point as above with a wider scale. Should be inside. + new HitTestData( Vector3( 100.f, 100.f, 1.f ), Vector2( 200.f, 451.f ), false ), // touch point close to the down edge (outside) + new HitTestData( Vector3( 100.f, 110.f, 1.f ), Vector2( 200.f, 451.f ), true ), // same point as above with a wider scale. Should be inside. + NULL, + }; + + // get the root layer + Actor actor = Actor::New(); + actor.SetAnchorPoint( AnchorPoint::CENTER ); + actor.SetParentOrigin( ParentOrigin::CENTER ); + + Stage::GetCurrent().Add( actor ); + + gTouchCallBackCalled = false; + + unsigned int index = 0; + while( NULL != hitTestData[index] ) + { + actor.SetSize( 1.f, 1.f ); + actor.SetScale( hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( !gTouchCallBackCalled ); + + // connect to its touch signal + actor.TouchedSignal().Connect(TestCallback); + + Dali::TouchPoint point( 0, TouchPoint::Down, hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y ); + Dali::Integration::TouchEvent event; + event.AddPoint( point ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + application.ProcessEvent( event ); + + DALI_TEST_CHECK( gTouchCallBackCalled == hitTestData[index]->mResult ); + + if( gTouchCallBackCalled != hitTestData[index]->mResult ) + tet_printf("Test failed:\nScale %f %f %f\nTouchPoint %f, %f\nResult %d\n", + hitTestData[index]->mScale.x, hitTestData[index]->mScale.y, hitTestData[index]->mScale.z, + hitTestData[index]->mTouchPoint.x, hitTestData[index]->mTouchPoint.y, + hitTestData[index]->mResult ); + + gTouchCallBackCalled = false; + ++index; + } + END_TEST; +} + +int UtcDaliActorSetDrawMode(void) +{ + TestApplication app; + tet_infoline(" UtcDaliActorSetDrawModeOverlay"); + + Actor a = Actor::New(); + + Stage::GetCurrent().Add(a); + app.SendNotification(); + app.Render(0); + app.SendNotification(); + app.Render(1); + + DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Ensure overlay is off by default + + a.SetDrawMode( DrawMode::OVERLAY ); + app.SendNotification(); + app.Render(1); + + DALI_TEST_CHECK( DrawMode::OVERLAY == a.GetDrawMode() ); // Check Actor is overlay + + a.SetDrawMode( DrawMode::STENCIL ); + app.SendNotification(); + app.Render(1); + + DALI_TEST_CHECK( DrawMode::STENCIL == a.GetDrawMode() ); // Check Actor is stencil, not overlay + + a.SetDrawMode( DrawMode::NORMAL ); + app.SendNotification(); + app.Render(1); + + DALI_TEST_CHECK( DrawMode::NORMAL == a.GetDrawMode() ); // Check Actor is not stencil + END_TEST; +} + +int UtcDaliActorSetDrawModeOverlayRender(void) +{ + TestApplication app; + tet_infoline(" UtcDaliActorSetDrawModeOverlayRender"); + + app.SendNotification(); + app.Render(1); + + std::vector ids; + ids.push_back( 8 ); // first rendered actor + ids.push_back( 9 ); // second rendered actor + ids.push_back( 10 ); // third rendered actor + app.GetGlAbstraction().SetNextTextureIds( ids ); + + BitmapImage imageA = BitmapImage::New(16, 16); + BitmapImage imageB = BitmapImage::New(16, 16); + BitmapImage imageC = BitmapImage::New(16, 16); + ImageActor a = ImageActor::New( imageA ); + ImageActor b = ImageActor::New( imageB ); + ImageActor c = ImageActor::New( imageC ); + + // Render a,b,c as regular non-overlays. so order will be: + // a (8) + // b (9) + // c (10) + Stage::GetCurrent().Add(a); + Stage::GetCurrent().Add(b); + Stage::GetCurrent().Add(c); + + app.SendNotification(); + app.Render(1); + + // Should be 3 textures changes. + const std::vector& boundTextures = app.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 ); + typedef std::vector::size_type TextureSize; + DALI_TEST_EQUALS( boundTextures.size(), static_cast( 3 ), TEST_LOCATION ); + if( boundTextures.size() == 3 ) + { + DALI_TEST_CHECK( boundTextures[0] == 8u ); + DALI_TEST_CHECK( boundTextures[1] == 9u ); + DALI_TEST_CHECK( boundTextures[2] == 10u ); + } + + // Now texture ids have been set, we can monitor their render order. + // render a as an overlay (last), so order will be: + // b (9) + // c (10) + // a (8) + a.SetDrawMode( DrawMode::OVERLAY ); + app.GetGlAbstraction().ClearBoundTextures(); + + app.SendNotification(); + app.Render(1); + + // Should be 3 texture changes. + DALI_TEST_EQUALS( boundTextures.size(), static_cast(3), TEST_LOCATION ); + if( boundTextures.size() == 3 ) + { + DALI_TEST_CHECK( boundTextures[0] == 9u ); + DALI_TEST_CHECK( boundTextures[1] == 10u ); + DALI_TEST_CHECK( boundTextures[2] == 8u ); + } + END_TEST; +} + + +int UtcDaliActorSetDrawModeOverlayHitTest(void) +{ + TestApplication app; + tet_infoline(" UtcDaliActorSetDrawModeOverlayHitTest"); + + BitmapImage imageA = BitmapImage::New(16, 16); + BitmapImage imageB = BitmapImage::New(16, 16); + ImageActor a = ImageActor::New( imageA ); + ImageActor b = ImageActor::New( imageB ); + + // Render a,b as regular non-overlays. so order will be: + Stage::GetCurrent().Add(a); + Stage::GetCurrent().Add(b); + + a.SetSize(Vector2(100.0f, 100.0f)); + b.SetSize(Vector2(100.0f, 100.0f)); + + // position b overlapping a. (regular non-overlays) + // hit test at point 'x' + // -------- + // | | + // | a | + // | -------- + // | |x | + // | | | + // ----| | + // | b | + // | | + // -------- + // note: b is on top, because it's Z position is higher. + a.SetPosition(Vector3(0.0f, 0.0f, 0.0f)); + b.SetPosition(Vector3(50.0f, 50.0f, 1.0f)); + + // connect to their touch signals + a.TouchedSignal().Connect(TestCallback); + b.TouchedSignal().Connect(TestCallback2); + + a.SetDrawMode( DrawMode::NORMAL ); + b.SetDrawMode( DrawMode::NORMAL ); + SimulateTouchForSetOverlayHitTest(app); + + DALI_TEST_CHECK( gTouchCallBackCalled == false ); + DALI_TEST_CHECK( gTouchCallBack2Called == true ); + // Make Actor a an overlay. + // -------- + // | | + // | a | + // | |---- + // | x | | + // | | | + // -------- | + // | b | + // | | + // -------- + // note: a is on top, because it is an overlay. + a.SetDrawMode( DrawMode::OVERLAY ); + b.SetDrawMode( DrawMode::NORMAL ); + SimulateTouchForSetOverlayHitTest(app); + + DALI_TEST_CHECK( gTouchCallBackCalled == true ); + DALI_TEST_CHECK( gTouchCallBack2Called == false ); + // Make both Actors as overlays + // -------- + // | | + // | a | + // | -------- + // | |x | + // | | | + // ----| | + // | b | + // | | + // -------- + // note: b is on top, because it is the 2nd child in the hierarchy. + a.SetDrawMode( DrawMode::OVERLAY ); + b.SetDrawMode( DrawMode::OVERLAY ); + SimulateTouchForSetOverlayHitTest(app); + + DALI_TEST_CHECK( gTouchCallBackCalled == false ); + DALI_TEST_CHECK( gTouchCallBack2Called == true ); + END_TEST; +} + +int UtcDaliActorGetCurrentWorldMatrix(void) +{ + TestApplication app; + tet_infoline(" UtcDaliActorGetCurrentWorldMatrix"); + + Actor parent = Actor::New(); + parent.SetParentOrigin(ParentOrigin::CENTER); + parent.SetAnchorPoint(AnchorPoint::CENTER); + Vector3 parentPosition( 10.0f, 20.0f, 30.0f); + Radian rotationAngle(Degree(85.0f)); + Quaternion parentRotation(rotationAngle, Vector3::ZAXIS); + Vector3 parentScale( 1.0f, 2.0f, 3.0f ); + parent.SetPosition( parentPosition ); + parent.SetRotation( parentRotation ); + parent.SetScale( parentScale ); + Stage::GetCurrent().Add( parent ); + + Actor child = Actor::New(); + child.SetParentOrigin(ParentOrigin::CENTER); + Vector3 childPosition( 0.0f, 0.0f, 100.0f ); + Radian childRotationAngle(Degree(23.0f)); + Quaternion childRotation( childRotationAngle, Vector3::YAXIS ); + Vector3 childScale( 2.0f, 2.0f, 2.0f ); + child.SetPosition( childPosition ); + child.SetRotation( childRotation ); + child.SetScale( childScale ); + parent.Add( child ); + + // The actors should not have a world matrix yet + DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION ); + + app.SendNotification(); + app.Render(0); + app.Render(); + app.SendNotification(); + + Matrix parentMatrix(false); + parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition); + + Vector3 childWorldPosition = parentPosition + parentRotation * parentScale * childPosition; + Quaternion childWorldRotation = parentRotation * childRotation; + Vector3 childWorldScale = parentScale * childScale; + + Matrix childWorldMatrix(false); + childWorldMatrix.SetTransformComponents(childWorldScale, childWorldRotation, childWorldPosition); + + DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), childWorldMatrix, 0.001, TEST_LOCATION ); + END_TEST; +} + + + +int UtcDaliActorConstrainedToWorldMatrix(void) +{ + TestApplication app; + tet_infoline(" UtcDaliActorConstrainedToWorldMatrix"); + + Actor parent = Actor::New(); + parent.SetParentOrigin(ParentOrigin::CENTER); + parent.SetAnchorPoint(AnchorPoint::CENTER); + Vector3 parentPosition( 10.0f, 20.0f, 30.0f); + Radian rotationAngle(Degree(85.0f)); + Quaternion parentRotation(rotationAngle, Vector3::ZAXIS); + Vector3 parentScale( 1.0f, 2.0f, 3.0f ); + parent.SetPosition( parentPosition ); + parent.SetRotation( parentRotation ); + parent.SetScale( parentScale ); + Stage::GetCurrent().Add( parent ); + + Actor child = Actor::New(); + child.SetParentOrigin(ParentOrigin::CENTER); + Constraint posConstraint = Constraint::New( Actor::POSITION, Source( parent, Actor::WORLD_MATRIX), PositionComponentConstraint() ); + child.ApplyConstraint(posConstraint); + + Stage::GetCurrent().Add( child ); + + // The actors should not have a world matrix yet + DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldMatrix(), Matrix::IDENTITY, 0.001, TEST_LOCATION ); + + app.SendNotification(); + app.Render(0); + app.Render(); + app.SendNotification(); + + Matrix parentMatrix(false); + parentMatrix.SetTransformComponents(parentScale, parentRotation, parentPosition); + + DALI_TEST_EQUALS( parent.GetCurrentWorldMatrix(), parentMatrix, 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentPosition(), parent.GetCurrentPosition(), 0.001, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliActorUnparent(void) +{ + TestApplication app; + tet_infoline(" UtcDaliActorUnparent"); + + Actor parent = Actor::New(); + Stage::GetCurrent().Add( parent ); + + Actor child = Actor::New(); + + DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION ); + DALI_TEST_CHECK( !child.GetParent() ); + + // Test that calling Unparent with no parent is a NOOP + child.Unparent(); + + DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION ); + DALI_TEST_CHECK( !child.GetParent() ); + + // Test that Unparent works + parent.Add( child ); + + DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION ); + DALI_TEST_CHECK( parent == child.GetParent() ); + + child.Unparent(); + + DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION ); + DALI_TEST_CHECK( !child.GetParent() ); + + // Test that UnparentAndReset works + parent.Add( child ); + + DALI_TEST_EQUALS( parent.GetChildCount(), 1u, TEST_LOCATION ); + DALI_TEST_CHECK( parent == child.GetParent() ); + + UnparentAndReset( child ); + + DALI_TEST_EQUALS( parent.GetChildCount(), 0u, TEST_LOCATION ); + DALI_TEST_CHECK( !child ); + + // Test that UnparentAndReset is a NOOP with empty handle + UnparentAndReset( child ); + + DALI_TEST_CHECK( !child ); + END_TEST; +} + +int UtcDaliActorGetChildAt(void) +{ + TestApplication app; + tet_infoline(" UtcDaliActorGetChildAt"); + + Actor parent = Actor::New(); + Stage::GetCurrent().Add( parent ); + + Actor child0 = Actor::New(); + parent.Add( child0 ); + + Actor child1 = Actor::New(); + parent.Add( child1 ); + + Actor child2 = Actor::New(); + parent.Add( child2 ); + + DALI_TEST_EQUALS( parent.GetChildAt( 0 ), child0, TEST_LOCATION ); + DALI_TEST_EQUALS( parent.GetChildAt( 1 ), child1, TEST_LOCATION ); + DALI_TEST_EQUALS( parent.GetChildAt( 2 ), child2, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliActorSetGetOverlay(void) +{ + TestApplication app; + tet_infoline(" UtcDaliActorSetGetOverlay"); + + Actor parent = Actor::New(); + parent.SetDrawMode(DrawMode::OVERLAY ); + DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY ); + END_TEST; +} + + +// Current Dynamics functions are crashing, so testing these sections are futile + +int UtcDaliActorDynamics(void) +{ + DALI_TEST_CHECK( true ); + END_TEST; +} + +int UtcDaliActorCreateDestroy(void) +{ + Actor* actor = new Actor; + DALI_TEST_CHECK( actor ); + delete actor; + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-AlphaFunctions.cpp b/automated-tests/src/dali/utc-Dali-AlphaFunctions.cpp new file mode 100644 index 0000000..375e45f --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-AlphaFunctions.cpp @@ -0,0 +1,370 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +using namespace Dali; + +void utc_dali_alpha_functions_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_alpha_functions_cleanup(void) +{ + test_return_value = TET_PASS; +} + + +// Positive test case for a method +int UtcDaliAlphaFunctionsDefault(void) +{ + TestApplication application; + + DALI_TEST_EQUALS( AlphaFunctions::Default( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Default( 0.25f ), 0.25f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Default( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Default( 0.75f ), 0.75f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Default( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliAlphaFunctionsLinear(void) +{ + TestApplication application; + + DALI_TEST_EQUALS( AlphaFunctions::Linear( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Linear( 0.25f ), 0.25f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Linear( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Linear( 0.75f ), 0.75f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Linear( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliAlphaFunctionsReverse(void) +{ + TestApplication application; + + DALI_TEST_EQUALS( AlphaFunctions::Reverse( 0.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Reverse( 0.25f ), 0.75f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Reverse( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Reverse( 0.75f ), 0.25f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Reverse( 1.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliAlphaFunctionsEaseIn(void) +{ + TestApplication application; + + DALI_TEST_EQUALS( AlphaFunctions::EaseIn( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseIn( 0.25f ), 0.015625f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseIn( 0.5f ), 0.125f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseIn( 0.75f ), 0.421875f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseIn( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliAlphaFunctionsEaseOut(void) +{ + TestApplication application; + + DALI_TEST_EQUALS( AlphaFunctions::EaseOut( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseOut( 0.25f ), 0.578125f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseOut( 0.5f ), 0.875f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseOut( 0.75f ), 0.984375f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseOut( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliAlphaFunctionsEaseInOut(void) +{ + TestApplication application; + + DALI_TEST_EQUALS( AlphaFunctions::EaseInOut( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOut( 0.25f ), 0.0625f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOut( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOut( 0.75f ), 0.9375f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOut( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliAlphaFunctionsEaseInSine(void) +{ + TestApplication application; + + DALI_TEST_EQUALS( AlphaFunctions::EaseInSine( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInSine( 0.25f ), 0.07612f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInSine( 0.5f ), 0.292893f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInSine( 0.75f ), 0.617317f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInSine( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliAlphaFunctionsEaseOutSine(void) +{ + TestApplication application; + + DALI_TEST_EQUALS( AlphaFunctions::EaseOutSine( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseOutSine( 0.25f ), 0.382683f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseOutSine( 0.5f ), 0.707107f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseOutSine( 0.75f ), 0.92388f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseOutSine( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliAlphaFunctionsEaseInOutSine(void) +{ + TestApplication application; + + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine( 0.25f ), 0.146447f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine( 0.75f ), 0.853553f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliAlphaFunctionsBounce(void) +{ + TestApplication application; + + DALI_TEST_EQUALS( AlphaFunctions::Bounce( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Bounce( 0.25f ), 0.707107f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Bounce( 0.5f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Bounce( 0.75f ), 0.707107f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Bounce( 1.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliAlphaFunctionsBounceBack(void) +{ + TestApplication application; + + DALI_TEST_EQUALS( AlphaFunctions::BounceBack( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::BounceBack( 0.25f ), 0.900316f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::BounceBack( 0.5f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::BounceBack( 0.75f ), -0.300105f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::BounceBack( 1.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliAlphaFunctionsEaseOutBack(void) +{ + TestApplication application; + + DALI_TEST_EQUALS( AlphaFunctions::EaseOutBack( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseOutBack( 0.25f ), 0.817410f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseOutBack( 0.5f ), 1.087698f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseOutBack( 0.75f ), 1.064137f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseOutBack( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliAlphaFunctionsSin(void) +{ + TestApplication application; + + DALI_TEST_EQUALS( AlphaFunctions::Sin( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Sin( 0.25f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Sin( 0.5f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Sin( 0.75f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Sin( 1.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliAlphaFunctionsSin2x(void) +{ + TestApplication application; + + DALI_TEST_EQUALS( AlphaFunctions::Sin2x( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Sin2x( 0.25f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Sin2x( 0.5f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Sin2x( 0.75f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Sin2x( 1.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliAlphaFunctionsSquare(void) +{ + TestApplication application; + + DALI_TEST_EQUALS( AlphaFunctions::Square( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Square( 0.25f ), 0.0625f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Square( 0.5f ), 0.25f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Square( 0.75f ), 0.5625f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::Square( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliAlphaFunctionsEaseInSine33(void) +{ + TestApplication application; + + DALI_TEST_EQUALS( AlphaFunctions::EaseInSine33( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInSine33( 0.25f ), 0.064146f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInSine33( 0.5f ), 0.255256f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInSine33( 0.75f ), 0.569374f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInSine33( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliAlphaFunctionsEaseOutSine33(void) +{ + TestApplication application; + + DALI_TEST_EQUALS( AlphaFunctions::EaseOutSine33( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseOutSine33( 0.25f ), 0.430626f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseOutSine33( 0.5f ), 0.744744f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseOutSine33( 0.75f ), 0.935854f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseOutSine33( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliAlphaFunctionsEaseInOutSineXX(void) +{ + TestApplication application; + + { + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine33( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine33( 0.25f ), 0.239263f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine33( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine33( 0.75f ), 0.760737f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine33( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + } + { + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine50( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine50( 0.25f ), 0.224156f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine50( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine50( 0.75f ), 0.775844f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine50( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + } + { + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine60( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine60( 0.25f ), 0.211325f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine60( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine60( 0.75f ), 0.788675f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine60( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + } + { + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine70( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine70( 0.25f ), 0.194806f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine70( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine70( 0.75f ), 0.805194f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine70( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + } + { + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine80( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine80( 0.25f ), 0.173648f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine80( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine80( 0.75f ), 0.826352f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine80( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + } + { + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine90( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine90( 0.25f ), 0.146447f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine90( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine90( 0.75f ), 0.853553f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine90( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + } + END_TEST; +} + +// Positive test case for a method +int UtcDaliAlphaFunctionsDoubleEaseInOutSine60(void) +{ + TestApplication application; + + DALI_TEST_EQUALS( AlphaFunctions::DoubleEaseInOutSine60( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::DoubleEaseInOutSine60( 0.25f ), 0.25f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::DoubleEaseInOutSine60( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::DoubleEaseInOutSine60( 0.75f ), 0.75f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::DoubleEaseInOutSine60( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliAlphaFunctionsEaseOutQuint50(void) +{ + TestApplication application; + + DALI_TEST_EQUALS( AlphaFunctions::EaseOutQuint50( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseOutQuint50( 0.25f ), 0.386797f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseOutQuint50( 0.5f ), 0.692214f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseOutQuint50( 0.75f ), 0.905268f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseOutQuint50( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliAlphaFunctionsEaseOutQuint80(void) +{ + TestApplication application; + + DALI_TEST_EQUALS( AlphaFunctions::EaseOutQuint80( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseOutQuint80( 0.25f ), 0.484010f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseOutQuint80( 0.5f ), 0.796937f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseOutQuint80( 0.75f ), 0.958765f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseOutQuint80( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliAlphaFunctionsEaseInBack(void) +{ + TestApplication application; + + DALI_TEST_EQUALS( AlphaFunctions::EaseInBack( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInBack( 0.25f ), -0.064137f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInBack( 0.5f ), -0.087698f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInBack( 0.75f ), 0.182590f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInBack( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliAlphaFunctionsEaseInOutBack(void) +{ + TestApplication application; + + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutBack( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutBack( 0.25f ), -0.043849f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutBack( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutBack( 0.75f ), 1.043849f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS( AlphaFunctions::EaseInOutBack( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-AngleAxis.cpp b/automated-tests/src/dali/utc-Dali-AngleAxis.cpp new file mode 100644 index 0000000..06d0a0f --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-AngleAxis.cpp @@ -0,0 +1,99 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +void utc_dali_angle_axis_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_angle_axis_cleanup(void) +{ + test_return_value = TET_PASS; +} + + + +int UtcDaliAngleAxisNew01(void) +{ + TestApplication application; + + AngleAxis a; + DALI_TEST_EQUALS(float(a.angle), 0.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(a.axis, Vector3(0.0f, 0.0f, 0.0f), 0.001f, TEST_LOCATION); + END_TEST; +} + + + +int UtcDaliAngleAxisNew02(void) +{ + TestApplication application; + + Degree d(75.0f); + AngleAxis a(d, Vector3::XAXIS); + + DALI_TEST_EQUALS(a.angle, d, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(a.axis, Vector3::XAXIS, 0.001f, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliAngleAxisNew03(void) +{ + TestApplication application; + + Radian r(Math::PI_2); + AngleAxis a(r, Vector3::ZAXIS); + + // AngleAxis stores its angle as a degree, so should only do degree comparison. + DALI_TEST_EQUALS(a.angle, Degree(Radian(Math::PI_2)), 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(a.axis, Vector3::ZAXIS, 0.001f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliAngleAxisAssign(void) +{ + TestApplication application; + + Radian r(Math::PI_2); + AngleAxis a(r, Vector3::ZAXIS); + + AngleAxis b = a; + + // AngleAxis stores its angle as a degree, so should only do degree comparison. + DALI_TEST_EQUALS(b.angle, Degree(Radian(Math::PI_2)), 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(b.axis, Vector3::ZAXIS, 0.001f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliAngleAxisCopy(void) +{ + TestApplication application; + + Radian r(Math::PI_2); + AngleAxis a(r, Vector3::ZAXIS); + AngleAxis b(a); + + // AngleAxis stores its angle as a degree, so should only do degree comparison. + DALI_TEST_EQUALS(b.angle, Degree(Radian(Math::PI_2)), 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(b.axis, Vector3::ZAXIS, 0.001f, TEST_LOCATION); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-AnimatableMesh.cpp b/automated-tests/src/dali/utc-Dali-AnimatableMesh.cpp new file mode 100644 index 0000000..f161055 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-AnimatableMesh.cpp @@ -0,0 +1,444 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +using namespace Dali; + + +void utc_dali_animatable_mesh_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_animatable_mesh_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ + +void CreateFaces(Dali::AnimatableMesh::Faces& faces, int numVerts) +{ + for(int i=0; i 0", TEST_LOCATION); + } + END_TEST; +} + +// Negative test case for a method +int UtcDaliAnimatableMeshNew04(void) +{ + TestApplication application; + + Dali::AnimatableMesh::Faces faces; + + try + { + AnimatableMesh mesh = AnimatableMesh::New(10, faces); + DALI_TEST_CHECK( !mesh ); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "faceIndices.size() > 0", TEST_LOCATION); + } + END_TEST; +} + +// Negative test case for a method +int UtcDaliAnimatableMeshNew05(void) +{ + TestApplication application; + + Dali::AnimatableMesh::Faces faces; + CreateOutOfRangeFaces(faces, 10); + + try + { + AnimatableMesh mesh = AnimatableMesh::New(10, faces); + DALI_TEST_CHECK( !mesh ); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "faceIndex < numVertices", TEST_LOCATION); + } + END_TEST; +} + +// Negative test case for a method +int UtcDaliAnimatableMeshNew06(void) +{ + TestApplication application; + + Dali::AnimatableMesh::Faces faces; + CreateFaces(faces, 10); + + try + { + AnimatableMesh mesh = AnimatableMesh::New(10, faces, Dali::Material() ); + DALI_TEST_CHECK( !mesh ); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "material", TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliAnimatableMeshDownCast01(void) +{ + TestApplication application; + tet_infoline("Testing Dali::AnimatableMesh::DownCast()"); + + Dali::AnimatableMesh::Faces faces; + CreateFaces(faces, 10); + + AnimatableMesh mesh = AnimatableMesh::New(10, faces); + BaseHandle* bh = &mesh; + + AnimatableMesh mesh2 = AnimatableMesh::DownCast(*bh); + DALI_TEST_CHECK( mesh2 ); + END_TEST; +} + +int UtcDaliAnimatableMeshGetPropertyIndex01(void) +{ + TestApplication application; + tet_infoline("Testing Dali::AnimatableMesh::operator[]"); + AnimatableMesh mesh = CreateMesh(); + + Property::Index i = mesh.GetPropertyIndex(0, AnimatableVertex::POSITION ); + DALI_TEST_EQUALS( i, 0*3+0, TEST_LOCATION ); + + i = mesh.GetPropertyIndex(5, AnimatableVertex::POSITION ); + DALI_TEST_EQUALS( i, 5*3+0, TEST_LOCATION ); + + i = mesh.GetPropertyIndex(7, AnimatableVertex::COLOR ); + DALI_TEST_EQUALS( i, 7*3+1, TEST_LOCATION ); + + i = mesh.GetPropertyIndex(9, AnimatableVertex::TEXTURE_COORDS ); + DALI_TEST_EQUALS( i, 9*3+2, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimatableMeshGetPropertyIndex02(void) +{ + TestApplication application; + tet_infoline("Testing Dali::AnimatableMesh::GetPropertyIndex"); + + AnimatableMesh mesh = CreateMesh(); + try + { + Property::Index i = mesh.GetPropertyIndex(12, AnimatableVertex::POSITION ); + DALI_TEST_CHECK( i==0 ); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "index < GetNumberOfVertices()", TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliAnimatableMeshGetPropertyIndex03(void) +{ + TestApplication application; + tet_infoline("Testing Dali::AnimatableMesh::GetPropertyIndex"); + + AnimatableMesh mesh = CreateMesh(); + try + { + Property::Index i = mesh.GetPropertyIndex(12, AnimatableVertex::COLOR ); + DALI_TEST_CHECK( i==0 ); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "index < GetNumberOfVertices()", TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliAnimatableMeshGetPropertyIndex04(void) +{ + TestApplication application; + tet_infoline("Testing Dali::AnimatableMesh::GetPropertyIndexa"); + + AnimatableMesh mesh = CreateMesh(); + try + { + Property::Index i = mesh.GetPropertyIndex(12342343, AnimatableVertex::TEXTURE_COORDS ); + DALI_TEST_CHECK( i==0 ); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "index < GetNumberOfVertices()", TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliAnimatableMeshOperatorArray01(void) +{ + TestApplication application; + tet_infoline("Testing Dali::AnimatableMesh::operator[]"); + + AnimatableMesh mesh = CreateMesh(); + { + Vector3 initialPos1(0.0f, 200.0f, 0.0f); + Vector3 initialPos2(100.0f, 300.0f, 0.0f); + + mesh[1].SetPosition(initialPos1); + mesh[3].SetPosition(initialPos2); + + application.Render(0); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + DALI_TEST_EQUALS( mesh[1].GetCurrentPosition(), initialPos1, TEST_LOCATION ); + + Vector3 pos = mesh[3].GetCurrentPosition(); + DALI_TEST_EQUALS( pos, initialPos2, TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliAnimatableMeshOperatorArray02(void) +{ + TestApplication application; + tet_infoline("Testing Dali::AnimatableMesh::operator[]"); + + AnimatableMesh mesh = CreateMesh(); + try + { + mesh[20].SetPosition(Vector3(0.0f, 0.0f, 0.0f)); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "index < GetNumberOfVertices()", TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliAnimatableMeshAnimateVertex01(void) +{ + TestApplication application; + tet_infoline("Testing Dali::AnimatableMesh Animating properties"); + + AnimatableMesh mesh = CreateMesh(); + MeshActor meshActor = MeshActor::New(mesh); + Stage::GetCurrent().Add(meshActor); + { + mesh[0].SetPosition(Vector3(0.0f, 200.0f, 0.0f)); + mesh[1].SetPosition(Vector3(100.0f, 300.0f, 0.0f)); + + Animation anim = Animation::New(1); + anim.AnimateBy(mesh.GetVertexProperty(0, AnimatableVertex::POSITION), Vector3( 0.0f, 100.0f, 0.0f)); + anim.AnimateTo(mesh.GetVertexProperty(1, AnimatableVertex::POSITION), Vector3(100.0f, 0.0f, 0.0f)); + anim.Play(); + + application.SendNotification(); + application.Render(0); + application.Render(500); + application.SendNotification(); + + // 50% progress + DALI_TEST_EQUALS( mesh[0].GetCurrentPosition(), Vector3( 0.0f, 250.0f, 0.0f), TEST_LOCATION ); + DALI_TEST_EQUALS( mesh[1].GetCurrentPosition(), Vector3(100.0f, 150.0f, 0.0f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(501); + application.SendNotification(); + + DALI_TEST_EQUALS( mesh[0].GetCurrentPosition(), Vector3( 0.0f, 300.0f, 0.0f), TEST_LOCATION ); + DALI_TEST_EQUALS( mesh[1].GetCurrentPosition(), Vector3(100.0f, 0.0f, 0.0f), TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliAnimatableVertexSettersAndGetters(void) +{ + TestApplication application; + tet_infoline("Testing Dali::AnimatableVertex constructors"); + AnimatableMesh mesh = CreateMesh(); + Vector3 v1Pos(0.0f, 200.0f, 0.0f); + Vector3 v2Pos(100.0f, 300.0f, 0.0f); + Vector2 uvs(0.1f, 0.2f); + mesh[0].SetPosition(v1Pos); + mesh[1].SetPosition(v2Pos); + mesh[2].SetColor(Color::BLACK); + mesh[3].SetTextureCoords(uvs); + + application.SendNotification(); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + + DALI_TEST_EQUALS(mesh[0].GetCurrentPosition(), v1Pos, TEST_LOCATION); + DALI_TEST_EQUALS(mesh[1].GetCurrentPosition(), v2Pos, TEST_LOCATION); + DALI_TEST_EQUALS(mesh[2].GetCurrentColor(), Color::BLACK, TEST_LOCATION); + DALI_TEST_EQUALS(mesh[3].GetCurrentTextureCoords(), uvs, TEST_LOCATION); + END_TEST; +} + +int UtcDaliAnimatableMeshProperties(void) +{ + TestApplication application; + AnimatableMesh mesh = CreateMesh(); + + Property::IndexContainer indices; + mesh.GetPropertyIndices( indices ); + DALI_TEST_CHECK( ! indices.empty() ); + DALI_TEST_EQUALS( indices.size(), mesh.GetPropertyCount(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimatableMeshExceedVertices(void) +{ + TestApplication application; + + AnimatableMesh::Faces faces; + CreateFaces(faces, 10); + + try + { + AnimatableMesh mesh = AnimatableMesh::New(3333334, faces); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT_CONDITION_STARTS_WITH_SUBSTRING( e, "( numVertices * 3 ) < DEFAULT_PROPERTY_MAX_COUNT", TEST_LOCATION ); + } + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Animation.cpp b/automated-tests/src/dali/utc-Dali-Animation.cpp new file mode 100644 index 0000000..df58d2f --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-Animation.cpp @@ -0,0 +1,8867 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 std::max; +using namespace Dali; + +void utc_dali_animation_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_animation_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ + +static const float ROTATION_EPSILON = 0.0001f; +static const float VECTOR4_EPSILON = 0.0001f; + +// Functor to test whether a Finish signal is emitted +struct AnimationFinishCheck +{ + AnimationFinishCheck(bool& signalReceived) + : mSignalReceived(signalReceived) + { + } + + void operator()(Animation& animation) + { + mSignalReceived = true; + } + + void Reset() + { + mSignalReceived = false; + } + + void CheckSignalReceived() + { + if (!mSignalReceived) + { + tet_printf("Expected Finish signal was not received\n"); + tet_result(TET_FAIL); + } + else + { + tet_result(TET_PASS); + } + } + + void CheckSignalNotReceived() + { + if (mSignalReceived) + { + tet_printf("Unexpected Finish signal was received\n"); + tet_result(TET_FAIL); + } + else + { + tet_result(TET_PASS); + } + } + + bool& mSignalReceived; // owned by individual tests +}; + +static bool ReturnFalseAfterProgressOne( float alpha, const bool& current ) +{ + return alpha < 1.0f; +} + +struct AnimateFloatTestFunctor +{ + AnimateFloatTestFunctor( float start, float end ) + : mStart( start ), + mEnd( end ) + { + } + + float operator()( float alpha, const float& current ) + { + return mStart + ((mEnd - mStart) * alpha ); + } + + float mStart; + float mEnd; +}; + +struct AnimateVector2TestFunctor +{ + AnimateVector2TestFunctor( Vector2 start, Vector2 end ) + : mStart( start ), + mEnd( end ) + { + } + + Vector2 operator()( float alpha, const Vector2& current ) + { + return mStart + ((mEnd - mStart) * alpha ); + } + + Vector2 mStart; + Vector2 mEnd; +}; + +struct AnimateVector4TestFunctor +{ + AnimateVector4TestFunctor( Vector4 start, Vector4 end ) + : mStart( start ), + mEnd( end ) + { + } + + Vector4 operator()( float alpha, const Vector4& current ) + { + return mStart + ((mEnd - mStart) * alpha ); + } + + Vector4 mStart; + Vector4 mEnd; +}; + +struct AnimateQuaternionTestFunctor +{ + AnimateQuaternionTestFunctor( Quaternion start, Quaternion end ) + : mStart( start ), + mEnd( end ) + { + } + + Quaternion operator()( float alpha, const Quaternion& current ) + { + return Quaternion::Slerp(mStart, mEnd, alpha); + } + + Quaternion mStart; + Quaternion mEnd; +}; + +struct BounceFunc +{ + BounceFunc(float x, float y, float z) + : mDistance(Vector3(x, y, z)) + { + } + Vector3 operator()(float alpha, const Vector3& current) + { + if (alpha>0.001f && alpha<1.0f) + { + const float flip = 0.5f - cosf(alpha * Math::PI * 2.0f) * 0.5f; + Vector3 newTranslation(current); + newTranslation += mDistance * flip; + return newTranslation; + } + return current; + } + Vector3 mDistance; +}; + + +struct TumbleFunc +{ + TumbleFunc(Vector3 axis) : tumbleAxis(axis){} + Quaternion operator()(float alpha, const Quaternion& current) + { + if (alpha>0.001f && alpha<1.0f) + { + Quaternion tumbleRotation(alpha * Math::PI * 2.0f, tumbleAxis); + return tumbleRotation * current; + } + return current; + } + Vector3 tumbleAxis; +}; + +} // anon namespace + +int UtcDaliAnimationNew01(void) +{ + TestApplication application; + + Animation animation; + DALI_TEST_CHECK(!animation); + + animation = Animation::New(1.0f); + + DALI_TEST_CHECK(animation); + END_TEST; +} + +int UtcDaliAnimationNew02(void) +{ + TestApplication application; + + Animation animation; + DALI_TEST_CHECK(!animation); + try + { + animation = Animation::New(0.0f); + } + catch (Dali::DaliException& e) + { + // TODO: Determine why catch doesn't. + // + + // Tests that a negative test of an assertion succeeds + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_EQUALS(e.mCondition, "durationSeconds > 0.0f", TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliAnimationDownCast(void) +{ + TestApplication application; + tet_infoline("Testing Dali::Animation::DownCast()"); + + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + + BaseHandle object(animation); + + Animation animation2 = Animation::DownCast(object); + DALI_TEST_CHECK(animation2); + + Animation animation3 = DownCast< Animation >(object); + DALI_TEST_CHECK(animation3); + + BaseHandle unInitializedObject; + Animation animation4 = Animation::DownCast(unInitializedObject); + DALI_TEST_CHECK(!animation4); + + Animation animation5 = DownCast< Animation >(unInitializedObject); + DALI_TEST_CHECK(!animation5); + END_TEST; +} + +int UtcDaliAnimationSetDuration(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION); + + // Start the animation + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + application.Render(2u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + + // Restart the animation, with a different duration + finishCheck.Reset(); + actor.SetPosition(Vector3::ZERO); + durationSeconds = 3.5f; + animation.SetDuration(durationSeconds); + DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + application.Render(2u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationGetDuration(void) +{ + TestApplication application; + + Animation animation = Animation::New(1.0f); + DALI_TEST_EQUALS(animation.GetDuration(), 1.0f, TEST_LOCATION); + + animation.SetDuration(2.0f); + DALI_TEST_EQUALS(animation.GetDuration(), 2.0f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliAnimationSetLooping(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + + // Start the animation + animation.SetLooping(true); + DALI_TEST_CHECK(animation.IsLooping()); + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + + // Loop 5 times + float intervalSeconds = 0.25f; + float progress = 0.0f; + for (int iterations = 0; iterations < 5;) + { + application.Render(static_cast(durationSeconds*intervalSeconds*1000.0f)); + + progress += intervalSeconds; + DALI_TEST_EQUALS( targetPosition*progress, actor.GetCurrentPosition(), 0.001f, TEST_LOCATION ); + + if (progress >= 1.0f) + { + progress = progress - 1.0f; + ++iterations; + } + } + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + animation.SetLooping(false); + DALI_TEST_CHECK(!animation.IsLooping()); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationIsLooping(void) +{ + TestApplication application; + + Animation animation = Animation::New(1.0f); + DALI_TEST_CHECK(!animation.IsLooping()); + + animation.SetLooping(true); + DALI_TEST_CHECK(animation.IsLooping()); + END_TEST; +} + +int UtcDaliAnimationSetEndAction(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake); + + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + + // Go back to the start + actor.SetPosition(Vector3::ZERO); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION ); + + // Animate again, but don't bake this time + finishCheck.Reset(); + animation.SetEndAction(Animation::Discard); + DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + + // The position should be discarded in the next frame + application.Render(0); + DALI_TEST_EQUALS( Vector3::ZERO/*discarded*/, actor.GetCurrentPosition(), TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentPosition(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationGetEndAction(void) +{ + TestApplication application; + + Animation animation = Animation::New(1.0f); + DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake); + + animation.SetEndAction(Animation::Discard); + DALI_TEST_CHECK(animation.GetEndAction() == Animation::Discard); + END_TEST; +} + +int UtcDaliAnimationGetDestroyAction(void) +{ + TestApplication application; + Animation animation = Animation::New(1.0f); + DALI_TEST_CHECK(animation.GetDestroyAction() == Animation::Bake); // default! + + animation.SetDestroyAction(Animation::Discard); + DALI_TEST_CHECK(animation.GetDestroyAction() == Animation::Discard); + + END_TEST; +} + +int UtcDaliAnimationSetDefaultAlphaFunction(void) +{ + TestApplication application; + + Animation animation = Animation::New(1.0f); + AlphaFunction func = animation.GetDefaultAlphaFunction(); + DALI_TEST_EQUALS(func(0.1f), AlphaFunctions::Linear(0.1f), TEST_LOCATION); + + animation.SetDefaultAlphaFunction(AlphaFunctions::EaseIn); + AlphaFunction func2 = animation.GetDefaultAlphaFunction(); + DALI_TEST_CHECK(func2(0.1f) < AlphaFunctions::Linear(0.1f)); // less progress when easing-in + END_TEST; +} + +int UtcDaliAnimationGetDefaultAlphaFunction(void) +{ + TestApplication application; + + Animation animation = Animation::New(1.0f); + AlphaFunction func = animation.GetDefaultAlphaFunction(); + + // Test that the default is linear + DALI_TEST_EQUALS(func(0.1f), AlphaFunctions::Linear(0.1f), TEST_LOCATION); + END_TEST; +} + +int UtcDaliAnimationPlay(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 20% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION ); + + animation.Play(); // Test that calling play has no effect, when animation is already playing + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 40% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION ); + + animation.Play(); // Test that calling play has no effect, when animation is already playing + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 60% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION ); + + animation.Play(); // Test that calling play has no effect, when animation is already playing + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 80% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION ); + + animation.Play(); // Test that calling play has no effect, when animation is already playing + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationPlayOffStage(void) +{ + // Test that an animation can be played, when the actor is off-stage. + // When the actor is added to the stage, it should appear at the current position + // i.e. where it would have been anyway, if on-stage from the beginning. + + TestApplication application; + + Actor actor = Actor::New(); + Vector3 basePosition(Vector3::ZERO); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), basePosition, TEST_LOCATION ); + // Not added to the stage! + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 20% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*off-stage*/, TEST_LOCATION ); + + // Add to the stage + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 40% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + Vector3 expectedPosition(basePosition + (targetPosition - basePosition)*0.4f); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition/*on-stage*/, TEST_LOCATION ); + + // Remove from the stage + Stage::GetCurrent().Remove(actor); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 60% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*back to start position*/, TEST_LOCATION ); + + // Add to the stage + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 80% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + expectedPosition = Vector3(basePosition + (targetPosition - basePosition)*0.8f); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationPlayDiscardHandle(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + // Start the animation + animation.Play(); + + // This is a test of the "Fire and Forget" behaviour + // Discard the animation handle! + animation.Reset(); + DALI_TEST_CHECK( !animation ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 20% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 40% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.4f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 60% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.6f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 80% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.8f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationPlayStopDiscardHandle(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 20% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION ); + + // This is a test of the "Fire and Forget" behaviour + // Stop the animation, and Discard the animation handle! + animation.Stop(); + animation.Reset(); + DALI_TEST_CHECK( !animation ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 40% progress */); + + // We expect the animation to finish at 20% progress + application.SendNotification(); + finishCheck.CheckSignalReceived(); + finishCheck.Reset(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 60% progress */); + + // Check that nothing has changed + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 80% progress */); + + // Check that nothing has changed + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 100% progress */); + + // Check that nothing has changed + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), (targetPosition * 0.2f), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationPause(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + + Vector3 fiftyPercentProgress(targetPosition * 0.5f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION ); + + // Pause the animation + animation.Pause(); + application.SendNotification(); + + // Loop 5 times + for (int i=0; i<5; ++i) + { + application.Render(static_cast(durationSeconds*500.0f)); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when paused */, TEST_LOCATION ); + } + + // Keep going + animation.Play(); + application.SendNotification(); + application.Render(static_cast(durationSeconds*490.0f)/*slightly less than the animation duration*/); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationStop(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + + Vector3 fiftyPercentProgress(targetPosition * 0.5f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION ); + + // Stop the animation + animation.Stop(); + application.SendNotification(); + + // Loop 5 times + for (int i=0; i<5; ++i) + { + application.Render(static_cast(durationSeconds*500.0f)); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress when stopped */, TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliAnimationStopSetPosition(void) +{ + // Test that Animation::Stop & Actor::SetPosition can be used in conjunction + // i.e. to check that the animation does not interfere with the position set. + + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + + Vector3 fiftyPercentProgress(targetPosition * 0.5f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION ); + + // Stop the animation + animation.Stop(); + Vector3 positionSet(2.0f, 3.0f, 4.0f); + actor.SetPosition(positionSet); + application.SendNotification(); + + // Loop 5 times + for (int i=0; i<5; ++i) + { + application.Render(static_cast(durationSeconds*500.0f)); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), positionSet/*Animation should not interfere with this*/, TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliAnimationClear(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + + Vector3 fiftyPercentProgress(targetPosition * 0.5f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress, TEST_LOCATION ); + + // Clear the animation + animation.Clear(); + application.SendNotification(); + + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We don't expect the animation to finish now + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercentProgress/* Still 50% progress since the animator was destroyed */, TEST_LOCATION ); + + // Restart as a scale animation; this should not move the actor's position + finishCheck.Reset(); + actor.SetPosition(Vector3::ZERO); + Vector3 targetScale(3.0f, 3.0f, 3.0f); + animation.ScaleTo(actor, targetScale, AlphaFunctions::Linear); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3(2.0f, 2.0f, 2.0f), TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*Check move-animator was destroyed*/, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationSignalFinish(void) +{ + TestApplication application; + + // Start the empty animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*1000.0f) + 1u/*beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + END_TEST; +} + +int UtcDaliAnimationAnimateByBoolean(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a boolean property + bool startValue(false); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + // Build the animation + float durationSeconds(2.0f); + Animation animation = Animation::New(durationSeconds); + const bool relativeValue(true); + const bool finalValue( false || relativeValue ); + animation.AnimateBy(Property(actor, index), relativeValue); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + // Repeat with relative value "false" - this should be an NOOP + animation = Animation::New(durationSeconds); + bool noOpValue(false); + animation.AnimateBy(Property(actor, index), noOpValue); + + // Start the animation + animation.Play(); + + finishCheck.Reset(); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + END_TEST; +} + +int UtcDaliAnimationAnimateByBooleanAlphaFunction(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a boolean property + bool startValue(false); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + // Build the animation + float durationSeconds(2.0f); + Animation animation = Animation::New(durationSeconds); + bool relativeValue(true); + bool finalValue( false || relativeValue ); + animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseIn); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + // Repeat with relative value "false" - this should be an NOOP + animation = Animation::New(durationSeconds); + bool noOpValue(false); + animation.AnimateBy(Property(actor, index), noOpValue, AlphaFunctions::EaseIn); + + // Start the animation + animation.Play(); + + finishCheck.Reset(); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + END_TEST; +} + +int UtcDaliAnimationAnimateByBooleanTimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a boolean property + bool startValue(false); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + // Build the animation + float durationSeconds(2.0f); + Animation animation = Animation::New(durationSeconds); + bool relativeValue(true); + bool finalValue( false || relativeValue ); + float animatorDurationSeconds(durationSeconds * 0.5f); + animation.AnimateBy( Property(actor, index), + relativeValue, + TimePeriod( animatorDurationSeconds ) ); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(animatorDurationSeconds*950.0f)/* 95% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + application.SendNotification(); + application.Render(static_cast(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/); + + // We didn't expect the animation to finish yet... + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // ...however we should have reached the final value + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + application.SendNotification(); + application.Render(static_cast(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + END_TEST; +} + +int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a boolean property + bool startValue(false); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + // Build the animation + float durationSeconds(2.0f); + Animation animation = Animation::New(durationSeconds); + bool relativeValue(true); + bool finalValue( false || relativeValue ); + float animatorDurationSeconds(durationSeconds * 0.5f); + animation.AnimateBy( Property(actor, index), + relativeValue, + AlphaFunctions::EaseInOut, + TimePeriod( animatorDurationSeconds ) ); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(animatorDurationSeconds*950.0f)/* 95% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + application.SendNotification(); + application.Render(static_cast(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/); + + // We didn't expect the animation to finish yet... + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // ...however we should have reached the final value + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + application.SendNotification(); + application.Render(static_cast(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + END_TEST; +} + +int UtcDaliAnimationAnimateByFloat(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a float property + float startValue(10.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(2.0f); + Animation animation = Animation::New(durationSeconds); + float targetValue(50.0f); + float relativeValue(targetValue - startValue); + animation.AnimateBy(Property(actor, index), relativeValue); + + float ninetyFivePercentProgress(startValue + relativeValue*0.95f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateByFloatAlphaFunction(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a float property + float startValue(10.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetValue(90.0f); + float relativeValue(targetValue - startValue); + animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut); + + float ninetyFivePercentProgress(startValue + relativeValue*0.95f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // The position should have moved more, than with a linear alpha function + float current(actor.GetProperty(index)); + DALI_TEST_CHECK( current > ninetyFivePercentProgress ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateByFloatTimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a float property + float startValue(10.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetValue(30.0f); + float relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateBy(Property(actor, index), + relativeValue, + TimePeriod(delay, durationSeconds - delay)); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a float property + float startValue(10.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetValue(30.0f); + float relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateBy(Property(actor, index), + relativeValue, + AlphaFunctions::Linear, + TimePeriod(delay, durationSeconds - delay)); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateByVector2(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector2 property + Vector2 startValue(10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(2.0f); + Animation animation = Animation::New(durationSeconds); + Vector2 targetValue(60.0f, 60.0f); + Vector2 relativeValue(targetValue - startValue); + animation.AnimateBy(Property(actor, index), relativeValue); + + Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateByVector2AlphaFunction(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector2 property + Vector2 startValue(100.0f, 100.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector2 targetValue(20.0f, 20.0f); + Vector2 relativeValue(targetValue - startValue); + animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut); + + Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // The position should have moved more, than with a linear alpha function + Vector2 current(actor.GetProperty(index)); + DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x ); + DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateByVector2TimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector2 property + Vector2 startValue(10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector2 targetValue(30.0f, 30.0f); + Vector2 relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateBy(Property(actor, index), + relativeValue, + TimePeriod(delay, durationSeconds - delay)); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector2 property + Vector2 startValue(5.0f, 5.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector2 targetValue(10.0f, 10.0f); + Vector2 relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateBy(Property(actor, index), + relativeValue, + AlphaFunctions::Linear, + TimePeriod(delay, durationSeconds - delay)); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateByVector3(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector3 property + Vector3 startValue(10.0f, 10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(2.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetValue(60.0f, 60.0f, 60.0f); + Vector3 relativeValue(targetValue - startValue); + animation.AnimateBy(Property(actor, index), relativeValue); + + Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateByVector3AlphaFunction(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector3 property + Vector3 startValue(100.0f, 100.0f, 100.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetValue(20.0f, 20.0f, 20.0f); + Vector3 relativeValue(targetValue - startValue); + animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut); + + Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // The position should have moved more, than with a linear alpha function + Vector3 current(actor.GetProperty(index)); + DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x ); + DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y ); + DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateByVector3TimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector3 property + Vector3 startValue(10.0f, 10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetValue(30.0f, 30.0f, 30.0f); + Vector3 relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateBy(Property(actor, index), + relativeValue, + TimePeriod(delay, durationSeconds - delay)); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector3 property + Vector3 startValue(5.0f, 5.0f, 5.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetValue(10.0f, 10.0f, 10.0f); + Vector3 relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateBy(Property(actor, index), + relativeValue, + AlphaFunctions::Linear, + TimePeriod(delay, durationSeconds - delay)); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateByVector4(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector4 property + Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(2.0f); + Animation animation = Animation::New(durationSeconds); + Vector4 targetValue(60.0f, 60.0f, 60.0f, 60.0f); + Vector4 relativeValue(targetValue - startValue); + animation.AnimateBy(Property(actor, index), relativeValue); + + Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateByVector4AlphaFunction(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector4 property + Vector4 startValue(100.0f, 100.0f, 100.0f, 100.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector4 targetValue(20.0f, 20.0f, 20.0f, 20.0f); + Vector4 relativeValue(targetValue - startValue); + animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut); + + Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // The position should have moved more, than with a linear alpha function + Vector4 current(actor.GetProperty(index)); + DALI_TEST_CHECK( current.x < ninetyFivePercentProgress.x ); + DALI_TEST_CHECK( current.y < ninetyFivePercentProgress.y ); + DALI_TEST_CHECK( current.z < ninetyFivePercentProgress.z ); + DALI_TEST_CHECK( current.w < ninetyFivePercentProgress.w ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateByVector4TimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector4 property + Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f); + Vector4 relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateBy(Property(actor, index), + relativeValue, + TimePeriod(delay, durationSeconds - delay)); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector4 property + Vector4 startValue(5.0f, 5.0f, 5.0f, 5.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector4 targetValue(10.0f, 10.0f, 10.0f, 10.0f); + Vector4 relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateBy(Property(actor, index), + relativeValue, + AlphaFunctions::Linear, + TimePeriod(delay, durationSeconds - delay)); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateByActorPosition(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Vector3 startPosition(10.0f, 10.0f, 10.0f); + actor.SetPosition(startPosition); + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(20.0f, 20.0f, 20.0f); + Vector3 relativePosition(targetPosition - startPosition); + animation.AnimateBy(Property(actor, Actor::POSITION), relativePosition); + + Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateByActorPositionAlphaFunction(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Vector3 startPosition(10.0f, 10.0f, 10.0f); + actor.SetPosition(startPosition); + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(20.0f, 20.0f, 20.0f); + Vector3 relativePosition(targetPosition - startPosition); + animation.AnimateBy(Property(actor, Actor::POSITION), relativePosition, AlphaFunctions::EaseOut); + + Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // The position should have moved more, than with a linear alpha function + Vector3 current(actor.GetCurrentPosition()); + DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x ); + DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y ); + DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateByActorPositionTimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Vector3 startPosition(10.0f, 10.0f, 10.0f); + actor.SetPosition(startPosition); + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(20.0f, 20.0f, 20.0f); + Vector3 relativePosition(targetPosition - startPosition); + float delay = 0.5f; + animation.AnimateBy(Property(actor, Actor::POSITION), + relativePosition, + TimePeriod(delay, durationSeconds - delay)); + + Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Vector3 startPosition(10.0f, 10.0f, 10.0f); + actor.SetPosition(startPosition); + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(20.0f, 20.0f, 20.0f); + Vector3 relativePosition(targetPosition - startPosition); + float delay = 0.5f; + animation.AnimateBy(Property(actor, Actor::POSITION), + relativePosition, + AlphaFunctions::Linear, + TimePeriod(delay, durationSeconds - delay)); + + Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToBoolean(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a boolean property + const bool startValue(false); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + // Build the animation + float durationSeconds(2.0f); + Animation animation = Animation::New(durationSeconds); + const bool targetValue( !startValue ); + animation.AnimateTo(Property(actor, index), targetValue); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); + + // Repeat with target value "false" + animation = Animation::New(durationSeconds); + const bool finalValue( !targetValue ); + animation.AnimateTo(Property(actor, index), finalValue); + + // Start the animation + animation.Play(); + + finishCheck.Reset(); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + END_TEST; +} + +int UtcDaliAnimationAnimateToBooleanAlphaFunction(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a boolean property + const bool startValue(false); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + // Build the animation + float durationSeconds(2.0f); + Animation animation = Animation::New(durationSeconds); + const bool targetValue( !startValue ); + animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunctions::EaseOut); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); + + // Repeat with target value "false" + animation = Animation::New(durationSeconds); + const bool finalValue( !targetValue ); + animation.AnimateTo(Property(actor, index), finalValue, AlphaFunctions::EaseOut); + + // Start the animation + animation.Play(); + + finishCheck.Reset(); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == targetValue ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + END_TEST; +} + +int UtcDaliAnimationAnimateToBooleanTimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a boolean property + bool startValue(false); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + // Build the animation + float durationSeconds(2.0f); + Animation animation = Animation::New(durationSeconds); + bool finalValue( !startValue ); + float animatorDurationSeconds(durationSeconds * 0.5f); + animation.AnimateTo( Property(actor, index), + finalValue, + TimePeriod( animatorDurationSeconds ) ); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(animatorDurationSeconds*950.0f)/* 95% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + application.SendNotification(); + application.Render(static_cast(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/); + + // We didn't expect the animation to finish yet... + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // ...however we should have reached the final value + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + application.SendNotification(); + application.Render(static_cast(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + END_TEST; +} + +int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a boolean property + bool startValue(false); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + // Build the animation + float durationSeconds(2.0f); + Animation animation = Animation::New(durationSeconds); + bool finalValue( !startValue ); + float animatorDurationSeconds(durationSeconds * 0.5f); + animation.AnimateTo( Property(actor, index), + finalValue, + AlphaFunctions::Linear, + TimePeriod( animatorDurationSeconds ) ); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(animatorDurationSeconds*950.0f)/* 95% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + application.SendNotification(); + application.Render(static_cast(animatorDurationSeconds*50.0f) + 1u/*just beyond the animator duration*/); + + // We didn't expect the animation to finish yet... + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // ...however we should have reached the final value + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + application.SendNotification(); + application.Render(static_cast(animatorDurationSeconds*1000.0f)/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == finalValue ); + END_TEST; +} + +int UtcDaliAnimationAnimateToFloat(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a float property + float startValue(10.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(2.0f); + Animation animation = Animation::New(durationSeconds); + float targetValue(50.0f); + float relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, "test-property"), targetValue); + + float ninetyFivePercentProgress(startValue + relativeValue*0.95f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToFloatAlphaFunction(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a float property + float startValue(10.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetValue(90.0f); + float relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut); + + float ninetyFivePercentProgress(startValue + relativeValue*0.95f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // The position should have moved more, than with a linear alpha function + float current(actor.GetProperty(index)); + DALI_TEST_CHECK( current > ninetyFivePercentProgress ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToFloatTimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a float property + float startValue(10.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetValue(30.0f); + float relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateTo(Property(actor, index), + targetValue, + TimePeriod(delay, durationSeconds - delay)); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a float property + float startValue(10.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetValue(30.0f); + float relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateTo(Property(actor, index), + targetValue, + AlphaFunctions::Linear, + TimePeriod(delay, durationSeconds - delay)); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToVector2(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector2 property + Vector2 startValue(-50.0f, -50.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(2.0f); + Animation animation = Animation::New(durationSeconds); + Vector2 targetValue(50.0f, 50.0f); + Vector2 relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, index), targetValue); + + Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToVector2AlphaFunction(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector2 property + Vector2 startValue(1000.0f, 1000.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector2 targetValue(9000.0f, 9000.0f); + Vector2 relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunctions::EaseOut); + + Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // The position should have moved more, than with a linear alpha function + Vector2 current(actor.GetProperty(index)); + DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x ); + DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToVector2TimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector2 property + Vector2 startValue(10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector2 targetValue(-10.0f, 20.0f); + Vector2 relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateTo(Property(actor, index), + targetValue, + TimePeriod(delay, durationSeconds - delay)); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector2 property + Vector2 startValue(10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector2 targetValue(30.0f, 30.0f); + Vector2 relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateTo(Property(actor, index), + targetValue, + AlphaFunctions::Linear, + TimePeriod(delay, durationSeconds - delay)); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToVector3(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector3 property + Vector3 startValue(-50.0f, -50.0f, -50.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(2.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetValue(50.0f, 50.0f, 50.0f); + Vector3 relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, index), targetValue); + + Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToVector3AlphaFunction(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector3 property + Vector3 startValue(1000.0f, 1000.0f, 1000.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetValue(9000.0f, 9000.0f, 9000.0f); + Vector3 relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut); + + Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // The position should have moved more, than with a linear alpha function + Vector3 current(actor.GetProperty(index)); + DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x ); + DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y ); + DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToVector3TimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector3 property + Vector3 startValue(10.0f, 10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetValue(-10.0f, 20.0f, 100.0f); + Vector3 relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateTo(Property(actor, index), + targetValue, + TimePeriod(delay, durationSeconds - delay)); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector3 property + Vector3 startValue(10.0f, 10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetValue(30.0f, 30.0f, 30.0f); + Vector3 relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateTo(Property(actor, "test-property"), + targetValue, + AlphaFunctions::Linear, + TimePeriod(delay, durationSeconds - delay)); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToVector3Component(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector3 property + Vector3 startValue(10.0f, 10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetValue(30.0f, 30.0f, 10.0f); + Vector3 relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateTo(Property(actor, "test-property", 0), + 30.0f, + AlphaFunctions::Linear, + TimePeriod(delay, durationSeconds - delay)); + animation.AnimateTo(Property(actor, index, 1), + 30.0f, + AlphaFunctions::Linear, + TimePeriod(delay, durationSeconds - delay)); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToVector4(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector4 property + Vector4 startValue(-50.0f, -40.0f, -30.0f, -20.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(2.0f); + Animation animation = Animation::New(durationSeconds); + Vector4 targetValue(50.0f, 50.0f, 50.0f, 50.0f); + Vector4 relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, index), targetValue); + + Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), ninetyFivePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToVector4AlphaFunction(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector4 property + Vector4 startValue(1000.0f, 1000.0f, 1000.0f, 1000.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector4 targetValue(9000.0f, 9000.0f, 9000.0f, 9000.0f); + Vector4 relativeValue(targetValue - startValue); + animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut); + + Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // The position should have moved more, than with a linear alpha function + Vector4 current(actor.GetProperty(index)); + DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x ); + DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y ); + DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z ); + DALI_TEST_CHECK( current.w > ninetyFivePercentProgress.w ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToVector4TimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector4 property + Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, VECTOR4_EPSILON, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector4 targetValue(-10.0f, 20.0f, 100.0f, 100.0f); + Vector4 relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateTo(Property(actor, index), + targetValue, + TimePeriod(delay, durationSeconds - delay)); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, VECTOR4_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), VECTOR4_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, VECTOR4_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector4 property + Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector4 targetValue(30.0f, 30.0f, 30.0f, 30.0f); + Vector4 relativeValue(targetValue - startValue); + float delay = 0.5f; + animation.AnimateTo(Property(actor, index), + targetValue, + AlphaFunctions::Linear, + TimePeriod(delay, durationSeconds - delay)); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% animation progress, 50% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue+(relativeValue*0.5f), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorParentOrigin(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentParentOrigin(), ParentOrigin::TOP_LEFT, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetParentOrigin(ParentOrigin::BOTTOM_RIGHT); + + try + { + animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN), targetParentOrigin ); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliAnimationAnimateToActorParentOriginX(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + float startValue(0.0f); + DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().x, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::PARENT_ORIGIN_X), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetX(1.0f); + + try + { + animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_X), targetX ); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliAnimationAnimateToActorParentOriginY(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + float startValue(0.0f); + DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().y, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::PARENT_ORIGIN_Y), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetY(1.0f); + + try + { + animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_Y), targetY ); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliAnimationAnimateToActorParentOriginZ(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + float startValue(0.5f); + DALI_TEST_EQUALS( actor.GetCurrentParentOrigin().z, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::PARENT_ORIGIN_Z), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetZ(1.0f); + + try + { + animation.AnimateTo( Property(actor, Actor::PARENT_ORIGIN_Z), targetZ ); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliAnimationAnimateToActorAnchorPoint(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint(), AnchorPoint::CENTER, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetAnchorPoint(AnchorPoint::TOP_LEFT); + + try + { + animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT), targetAnchorPoint); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliAnimationAnimateToActorAnchorPointX(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + float startValue(0.5f); + DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().x, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::ANCHOR_POINT_X), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetX(1.0f); + + try + { + animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_X), targetX ); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliAnimationAnimateToActorAnchorPointY(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + float startValue(0.5f); + DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().y, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::ANCHOR_POINT_Y), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetY(0.0f); + + try + { + animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_Y), targetY ); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliAnimationAnimateToActorAnchorPointZ(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + float startValue(0.5f); + DALI_TEST_EQUALS( actor.GetCurrentAnchorPoint().z, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::ANCHOR_POINT_Z), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetZ(100.0f); + + try + { + animation.AnimateTo( Property(actor, Actor::ANCHOR_POINT_Z), targetZ ); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "IsPropertyAnimatable(index)", TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliAnimationAnimateToActorSize(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetSize(100.0f, 100.0f, 100.0f); + animation.AnimateTo( Property(actor, Actor::SIZE), targetSize ); + + Vector3 ninetyNinePercentProgress(targetSize * 0.99f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetSize(Vector3::ZERO); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + + // Repeat with a different (ease-in) alpha function + animation = Animation::New(durationSeconds); + animation.AnimateTo( Property(actor, Actor::SIZE), targetSize, AlphaFunctions::EaseIn); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // The size should have travelled less, than with a linear alpha function + Vector3 current(actor.GetCurrentSize()); + DALI_TEST_CHECK( current.x > 0.0f ); + DALI_TEST_CHECK( current.y > 0.0f ); + DALI_TEST_CHECK( current.z > 0.0f ); + DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x ); + DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y ); + DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetSize(Vector3::ZERO); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + + // Repeat with a delay + float delay = 0.5f; + animation = Animation::New(durationSeconds); + animation.AnimateTo( Property(actor, Actor::SIZE), targetSize, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay)); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorSizeWidth(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + float startValue(0.0f); + DALI_TEST_EQUALS( actor.GetCurrentSize().width, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SIZE_WIDTH), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetWidth(10.0f); + animation.AnimateTo( Property(actor, Actor::SIZE_WIDTH), targetWidth ); + + float fiftyPercentProgress(startValue + (targetWidth - startValue)*0.5f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentSize().width, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SIZE_WIDTH), fiftyPercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentSize().width, targetWidth, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SIZE_WIDTH), targetWidth, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorSizeHeight(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + float startValue(0.0f); + DALI_TEST_EQUALS( actor.GetCurrentSize().height, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SIZE_HEIGHT), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetHeight(-10.0f); + animation.AnimateTo( Property(actor, Actor::SIZE_HEIGHT), targetHeight ); + + float fiftyPercentProgress(startValue + (targetHeight - startValue)*0.5f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentSize().height, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SIZE_HEIGHT), fiftyPercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentSize().height, targetHeight, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SIZE_HEIGHT), targetHeight, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorSizeDepth(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + float startValue(0.0f); + DALI_TEST_EQUALS( actor.GetCurrentSize().depth, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SIZE_DEPTH), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetDepth(-10.0f); + animation.AnimateTo( Property(actor, Actor::SIZE_DEPTH), targetDepth ); + + float fiftyPercentProgress(startValue + (targetDepth - startValue)*0.5f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentSize().depth, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SIZE_DEPTH), fiftyPercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentSize().depth, targetDepth, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SIZE_DEPTH), targetDepth, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorPosition(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(200.0f, 200.0f, 200.0f); + animation.AnimateTo(Property(actor, Actor::POSITION), targetPosition); + + Vector3 seventyFivePercentProgress(targetPosition * 0.75f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*750.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorPositionX(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + float startValue(0.0f); + DALI_TEST_EQUALS( actor.GetCurrentPosition().x, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Z), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetX(1.0f); + animation.AnimateTo( Property(actor, Actor::POSITION_X), targetX ); + + float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition().x, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_X), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Z), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition().x, targetX, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_X), targetX, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Z), startValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorPositionY(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + float startValue(0.0f); + DALI_TEST_EQUALS( actor.GetCurrentPosition().y, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Z), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetY(10.0f); + animation.AnimateTo( Property(actor, Actor::POSITION_Y), targetY ); + + float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition().y, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Y), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Z), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition().y, targetY, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Y), targetY, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Z), startValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorPositionZ(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + float startValue(0.0f); + DALI_TEST_EQUALS( actor.GetCurrentPosition().z, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Z), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetZ(-5.0f); + animation.AnimateTo( Property(actor, Actor::POSITION_Z), targetZ ); + + float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition().z, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Z), fiftyPercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition().z, targetZ, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::POSITION_Z), targetZ, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorPositionAlphaFunction(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(200.0f, 200.0f, 200.0f); + animation.AnimateTo(Property(actor, Actor::POSITION), targetPosition, AlphaFunctions::EaseIn); + + Vector3 seventyFivePercentProgress(targetPosition * 0.75f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*750.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // The position should have moved less, than with a linear alpha function + Vector3 current(actor.GetCurrentPosition()); + DALI_TEST_CHECK( current.x > Vector3::ZERO.x ); + DALI_TEST_CHECK( current.y > Vector3::ZERO.y ); + DALI_TEST_CHECK( current.z > Vector3::ZERO.z ); + DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x ); + DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y ); + DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorPositionTimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(200.0f, 200.0f, 200.0f); + float delay = 0.5f; + animation.AnimateTo( Property(actor, Actor::POSITION), + targetPosition, + TimePeriod( delay, durationSeconds - delay ) ); + + Vector3 seventyFivePercentProgress(targetPosition * 0.75f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(200.0f, 200.0f, 200.0f); + float delay = 0.5f; + animation.AnimateTo( Property(actor, Actor::POSITION), + targetPosition, + AlphaFunctions::Linear, + TimePeriod( delay, durationSeconds - delay ) ); + + Vector3 seventyFivePercentProgress(targetPosition * 0.75f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorRotationAngleAxis(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Degree targetRotationDegrees(90.0f); + Radian targetRotationRadians(targetRotationDegrees); + animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationRadians, Vector3::YAXIS) ); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorRotationQuaternion(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Degree targetRotationDegrees(90.0f); + Radian targetRotationRadians(targetRotationDegrees); + Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS); + animation.AnimateTo( Property(actor, Actor::ROTATION), targetRotation ); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorRotationAlphaFunction(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Degree targetRotationDegrees(90.0f); + Radian targetRotationRadians(targetRotationDegrees); + animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorRotationTimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Degree targetRotationDegrees(90.0f); + Radian targetRotationRadians(targetRotationDegrees); + float delay(0.1f); + animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), TimePeriod(delay, durationSeconds - delay)); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + float progress = max(0.0f, 0.25f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + progress = max(0.0f, 0.5f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + progress = max(0.0f, 0.75f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorRotationAlphaFunctionTimePeriod(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Degree targetRotationDegrees(90.0f); + Radian targetRotationRadians(targetRotationDegrees); + float delay(0.1f); + animation.AnimateTo( Property(actor, Actor::ROTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn, TimePeriod(delay, durationSeconds - delay)); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + float progress = max(0.0f, 0.25f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + progress = max(0.0f, 0.5f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + progress = max(0.0f, 0.75f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorScale(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetScale(2.0f, 2.0f, 2.0f); + animation.AnimateTo( Property(actor, Actor::SCALE), targetScale ); + + Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetScale(Vector3::ONE); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + + // Repeat with a different (ease-in) alpha function + animation = Animation::New(durationSeconds); + animation.AnimateTo( Property(actor, Actor::SCALE), targetScale, AlphaFunctions::EaseIn); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // The scale should have grown less, than with a linear alpha function + Vector3 current(actor.GetCurrentScale()); + DALI_TEST_CHECK( current.x > 1.0f ); + DALI_TEST_CHECK( current.y > 1.0f ); + DALI_TEST_CHECK( current.z > 1.0f ); + DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x ); + DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y ); + DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetScale(Vector3::ONE); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + + // Repeat with a delay + float delay = 0.5f; + animation = Animation::New(durationSeconds); + animation.AnimateTo( Property(actor, Actor::SCALE), targetScale, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay)); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorScaleX(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + float startValue(1.0f); + DALI_TEST_EQUALS( actor.GetCurrentScale().x, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Z), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetX(10.0f); + animation.AnimateTo( Property(actor, Actor::SCALE_X), targetX ); + + float fiftyPercentProgress(startValue + (targetX - startValue)*0.5f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale().x, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_X), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Z), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale().x, targetX, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_X), targetX, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Z), startValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorScaleY(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + float startValue(1.0f); + DALI_TEST_EQUALS( actor.GetCurrentScale().y, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Z), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetY(1000.0f); + animation.AnimateTo( Property(actor, Actor::SCALE_Y), targetY ); + + float fiftyPercentProgress(startValue + (targetY - startValue)*0.5f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale().y, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Y), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Z), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale().y, targetY, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Y), targetY, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Z), startValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorScaleZ(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + float startValue(1.0f); + DALI_TEST_EQUALS( actor.GetCurrentScale().z, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Z), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetZ(-1000.0f); + animation.AnimateTo( Property(actor, Actor::SCALE_Z), targetZ ); + + float fiftyPercentProgress(startValue + (targetZ - startValue)*0.5f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale().z, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Z), fiftyPercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale().z, targetZ, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_X), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Y), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::SCALE_Z), targetZ, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorColor(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector4 targetColor(Color::RED); + animation.AnimateTo( Property(actor, Actor::COLOR), targetColor ); + + Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f)); + Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f)); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*100.0f)/* 10% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetColor(Color::WHITE); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); + + // Repeat with a different (ease-in) alpha function + animation = Animation::New(durationSeconds); + animation.AnimateTo( Property(actor, Actor::COLOR), targetColor, AlphaFunctions::EaseIn); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*100.0f)/* 10% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // The color should have changed less, than with a linear alpha function + Vector4 current(actor.GetCurrentColor()); + DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change + DALI_TEST_CHECK( current.y < 1.0f ); + DALI_TEST_CHECK( current.y > tenPercentProgress.y ); + DALI_TEST_CHECK( current.z < 1.0f ); + DALI_TEST_CHECK( current.z > tenPercentProgress.z ); + DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change + + application.SendNotification(); + application.Render(static_cast(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetColor(Color::WHITE); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); + + // Repeat with a shorter animator duration + float animatorDuration = 0.5f; + animation = Animation::New(durationSeconds); + animation.AnimateTo( Property(actor, Actor::COLOR), targetColor, AlphaFunctions::Linear, TimePeriod(animatorDuration)); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorColorRed(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + float startValue(1.0f); + DALI_TEST_EQUALS( actor.GetCurrentColor().r, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetRed(0.5f); + animation.AnimateTo( Property(actor, Actor::COLOR_RED), targetRed ); + + float fiftyPercentProgress(startValue + (targetRed - startValue)*0.5f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor().r, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor().r, targetRed, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), targetRed, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorColorGreen(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + float startValue(1.0f); + DALI_TEST_EQUALS( actor.GetCurrentColor().g, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetGreen(0.5f); + animation.AnimateTo( Property(actor, Actor::COLOR_GREEN), targetGreen ); + + float fiftyPercentProgress(startValue + (targetGreen - startValue)*0.5f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor().g, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor().g, targetGreen, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), targetGreen, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorColorBlue(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + float startValue(1.0f); + DALI_TEST_EQUALS( actor.GetCurrentColor().b, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetBlue(0.5f); + animation.AnimateTo( Property(actor, Actor::COLOR_BLUE), targetBlue ); + + float fiftyPercentProgress(startValue + (targetBlue - startValue)*0.5f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor().b, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor().b, targetBlue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), targetBlue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateToActorColorAlpha(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + float startValue(1.0f); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetAlpha(0.5f); + animation.AnimateTo( Property(actor, Actor::COLOR_ALPHA), targetAlpha ); + + float fiftyPercentProgress(startValue + (targetAlpha - startValue)*0.5f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, fiftyPercentProgress, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), fiftyPercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, targetAlpha, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), targetAlpha, TEST_LOCATION ); + END_TEST; +} + + + +int UtcDaliAnimationKeyFrames01(void) +{ + TestApplication application; + + KeyFrames keyFrames = KeyFrames::New(); + DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION); + + keyFrames.Add(0.0f, 0.1f); + keyFrames.Add(0.2f, 0.5f); + keyFrames.Add(0.4f, 0.0f); + keyFrames.Add(0.6f, 1.0f); + keyFrames.Add(0.8f, 0.7f); + keyFrames.Add(1.0f, 0.9f); + + DALI_TEST_EQUALS(keyFrames.GetType(), Property::FLOAT, TEST_LOCATION); + + try + { + keyFrames.Add(1.9f, false); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliAnimationKeyFrames02(void) +{ + TestApplication application; + + KeyFrames keyFrames = KeyFrames::New(); + DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION); + + keyFrames.Add(0.0f, true); + keyFrames.Add(0.2f, false); + keyFrames.Add(0.4f, false); + keyFrames.Add(0.6f, true); + keyFrames.Add(0.8f, true); + keyFrames.Add(1.0f, false); + + DALI_TEST_EQUALS(keyFrames.GetType(), Property::BOOLEAN, TEST_LOCATION); + + try + { + keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f)); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION); + } + END_TEST; +} + + +int UtcDaliAnimationKeyFrames03(void) +{ + TestApplication application; + + KeyFrames keyFrames = KeyFrames::New(); + DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION); + + keyFrames.Add(0.0f, Vector2(0.0f, 0.0f)); + keyFrames.Add(0.2f, Vector2(1.0f, 1.0f)); + keyFrames.Add(0.4f, Vector2(2.0f, 2.0f)); + keyFrames.Add(0.6f, Vector2(3.0f, 5.0f)); + keyFrames.Add(0.8f, Vector2(4.0f, 3.0f)); + keyFrames.Add(1.0f, Vector2(6.0f, 2.0f)); + + DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR2, TEST_LOCATION); + + try + { + keyFrames.Add(0.7f, Vector3(1.0f, 1.0f, 1.0f)); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION); + } + END_TEST; +} + + +int UtcDaliAnimationKeyFrames04(void) +{ + TestApplication application; + + KeyFrames keyFrames = KeyFrames::New(); + DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION); + + keyFrames.Add(0.0f, Vector3(0.0f, 4.0f, 0.0f)); + keyFrames.Add(0.2f, Vector3(1.0f, 3.0f, 1.0f)); + keyFrames.Add(0.4f, Vector3(2.0f, 2.0f, 2.0f)); + keyFrames.Add(0.6f, Vector3(3.0f, 2.0f, 5.0f)); + keyFrames.Add(0.8f, Vector3(4.0f, 4.0f, 3.0f)); + keyFrames.Add(1.0f, Vector3(6.0f, 8.0f, 2.0f)); + + DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR3, TEST_LOCATION); + + try + { + keyFrames.Add(0.7f, 1.0f); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliAnimationKeyFrames05(void) +{ + TestApplication application; + + KeyFrames keyFrames = KeyFrames::New(); + DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION); + + keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.0f)); + keyFrames.Add(0.2f, Vector4(1.0f, 1.0f, 1.0f, 1.0f)); + keyFrames.Add(0.4f, Vector4(2.0f, 2.0f, 2.0f, 2.0f)); + keyFrames.Add(0.6f, Vector4(3.0f, 5.0f, 3.0f, 5.0f)); + keyFrames.Add(0.8f, Vector4(4.0f, 3.0f, 4.0f, 3.0f)); + keyFrames.Add(1.0f, Vector4(6.0f, 2.0f, 6.0f, 2.0f)); + + DALI_TEST_EQUALS(keyFrames.GetType(), Property::VECTOR4, TEST_LOCATION); + + try + { + keyFrames.Add(0.7f, Quaternion(1.717f, Vector3::XAXIS)); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION); + } + END_TEST; +} + + +int UtcDaliAnimationKeyFrames06(void) +{ + TestApplication application; + + KeyFrames keyFrames = KeyFrames::New(); + DALI_TEST_EQUALS(keyFrames.GetType(), Property::NONE, TEST_LOCATION); + + keyFrames.Add(0.0f, Quaternion(1.717f, Vector3::XAXIS)); + keyFrames.Add(0.2f, Quaternion(2.0f, Vector3::XAXIS)); + keyFrames.Add(0.4f, Quaternion(3.0f, Vector3::ZAXIS)); + keyFrames.Add(0.6f, Quaternion(4.0f, Vector3(1.0f, 1.0f, 1.0f))); + keyFrames.Add(0.8f, AngleAxis(Degree(90), Vector3::XAXIS)); + keyFrames.Add(1.0f, Quaternion(3.0f, Vector3::YAXIS)); + + DALI_TEST_EQUALS(keyFrames.GetType(), Property::ROTATION, TEST_LOCATION); + + try + { + keyFrames.Add(0.7f, 1.1f); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "mType == value.GetType()", TEST_LOCATION); + } + END_TEST; +} + + + + + +int UtcDaliAnimationAnimateBetweenActorColorAlpha(void) +{ + TestApplication application; + + float startValue(1.0f); + Actor actor = Actor::New(); + actor.SetColor(Vector4(startValue, startValue, startValue, startValue)); + Stage::GetCurrent().Add(actor); + + DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + + KeyFrames keyFrames = KeyFrames::New(); + keyFrames.Add(0.0f, 0.1f); + keyFrames.Add(0.2f, 0.5f); + keyFrames.Add(0.4f, 0.0f); + keyFrames.Add(0.6f, 1.0f); + keyFrames.Add(0.8f, 0.7f); + keyFrames.Add(1.0f, 0.9f); + + animation.AnimateBetween( Property(actor, Actor::COLOR_ALPHA), keyFrames ); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + application.SendNotification(); + application.Render(0); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.1f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*100.0f)/* 10% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.3f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.3f, 0.01f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*200.0f)/* 30% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.25f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.25f, 0.01f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*100.0f)/* 40% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.0f, 0.01f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*400.0f)/* 80% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.7f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.7f, 0.01f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*100.0f)/* 90% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.8f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.8f, 0.01f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*100.0f)+1/* 100% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.9f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentColor().a, 0.9f, 0.01f, TEST_LOCATION ); + + // We did expect the animation to finish + + finishCheck.CheckSignalReceived(); + END_TEST; +} + + +int UtcDaliAnimationAnimateBetweenActorColor(void) +{ + TestApplication application; + + float startValue(1.0f); + Actor actor = Actor::New(); + actor.SetColor(Vector4(startValue, startValue, startValue, startValue)); + Stage::GetCurrent().Add(actor); + + DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + + KeyFrames keyFrames = KeyFrames::New(); + keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f)); + keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f)); + keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f)); + + animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames ); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + application.SendNotification(); + application.Render(0); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)+1/* 100% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION ); + + // We did expect the animation to finish + + finishCheck.CheckSignalReceived(); + END_TEST; +} + +int UtcDaliAnimationAnimateBetweenActorVisible01(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + AngleAxis aa(Degree(90), Vector3::XAXIS); + actor.SetRotation(aa.angle, aa.axis); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + + KeyFrames keyFrames = KeyFrames::New(); + keyFrames.Add(0.0f, false); + keyFrames.Add(0.2f, true); + keyFrames.Add(0.4f, true); + keyFrames.Add(0.8f, false); + keyFrames.Add(1.0f, true); + + animation.AnimateBetween( Property(actor, Actor::VISIBLE), keyFrames ); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + application.SendNotification(); + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)+1); + application.SendNotification(); + + DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION); + finishCheck.CheckSignalReceived(); + END_TEST; +} + +#if 0 +// Valid test case, but no fix in dali-core yet. +//int UtcDaliAnimationAnimateBetweenActorRotation01(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + AngleAxis aa(Degree(90), Vector3::XAXIS); + actor.SetRotation(aa.angle, aa.axis); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(0); + Quaternion start(Radian(aa.angle), aa.axis); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), start, 0.001f, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + + KeyFrames keyFrames = KeyFrames::New(); + keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::ZAXIS)); + + animation.AnimateBetween( Property(actor, Actor::ROTATION), keyFrames ); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + application.SendNotification(); + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)); + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)+1); + application.SendNotification(); + + Quaternion check = Quaternion::FromAxisAngle(Vector4::ZAXIS, Radian(Degree(60))); + // THIS CHECK IS CURRENTLY FAILING!!!! + DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION ); + finishCheck.CheckSignalReceived(); + END_TEST; +} +#endif + +int UtcDaliAnimationAnimateBetweenActorRotation02(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + AngleAxis aa(Degree(90), Vector3::XAXIS); + actor.SetRotation(aa.angle, aa.axis); + application.SendNotification(); + application.Render(0); + Stage::GetCurrent().Add(actor); + + Quaternion start(Radian(aa.angle), aa.axis); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), start, 0.001f, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + + KeyFrames keyFrames = KeyFrames::New(); + keyFrames.Add(0.0f, AngleAxis(Degree(60), Vector3::XAXIS)); + keyFrames.Add(0.5f, AngleAxis(Degree(120), Vector3::XAXIS)); + keyFrames.Add(1.0f, AngleAxis(Degree(120), Vector3::YAXIS)); + + animation.AnimateBetween( Property(actor, Actor::ROTATION), keyFrames ); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + application.SendNotification(); + application.Render(0); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + Quaternion check(Radian(Degree(60)), Vector3::XAXIS); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + application.SendNotification(); + check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(90))); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + application.SendNotification(); + check = Quaternion::FromAxisAngle(Vector4::XAXIS, Radian(Degree(120))); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + application.SendNotification(); + check = Quaternion::FromAxisAngle(Vector4(0.5f, 0.5f, 0.0f, 0.0f), Radian(Degree(101.5))); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)+1/* 100% progress */); + application.SendNotification(); + check = Quaternion::FromAxisAngle(Vector4::YAXIS, Radian(Degree(120))); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), check, 0.001f, TEST_LOCATION ); + + // We did expect the animation to finish + + finishCheck.CheckSignalReceived(); + END_TEST; +} + +int UtcDaliAnimationMoveByFloat3(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Vector3 startPosition(10.0f, 10.0f, 10.0f); + actor.SetPosition(startPosition); + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(20.0f, 20.0f, 20.0f); + Vector3 relativePosition(targetPosition - startPosition); + animation.MoveBy(actor, relativePosition.x, relativePosition.y, relativePosition.z); + + Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), ninetyFivePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationMoveByVector3Alpha(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Vector3 startPosition(10.0f, 10.0f, 10.0f); + actor.SetPosition(startPosition); + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(20.0f, 20.0f, 20.0f); + Vector3 relativePosition(targetPosition - startPosition); + animation.MoveBy(actor, relativePosition, AlphaFunctions::EaseOut); + + Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*950.0f)/* 95% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // The position should have moved more, than with a linear alpha function + Vector3 current(actor.GetCurrentPosition()); + DALI_TEST_CHECK( current.x > ninetyFivePercentProgress.x ); + DALI_TEST_CHECK( current.y > ninetyFivePercentProgress.y ); + DALI_TEST_CHECK( current.z > ninetyFivePercentProgress.z ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*50.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationMoveByVector3AlphaFloat2(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Vector3 startPosition(10.0f, 10.0f, 10.0f); + actor.SetPosition(startPosition); + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(20.0f, 20.0f, 20.0f); + Vector3 relativePosition(targetPosition - startPosition); + float delay = 0.5f; + animation.MoveBy(actor, relativePosition, AlphaFunctions::Linear, delay, durationSeconds - delay); + + Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), startPosition, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationMoveToFloat3(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(200.0f, 200.0f, 200.0f); + animation.MoveTo(actor, targetPosition.x, targetPosition.y, targetPosition.z); + + Vector3 seventyFivePercentProgress(targetPosition * 0.75f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*750.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationMoveToVector3Alpha(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(200.0f, 200.0f, 200.0f); + animation.MoveTo(actor, targetPosition, AlphaFunctions::EaseIn); + + Vector3 seventyFivePercentProgress(targetPosition * 0.75f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*750.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // The position should have moved less, than with a linear alpha function + Vector3 current(actor.GetCurrentPosition()); + DALI_TEST_CHECK( current.x > Vector3::ZERO.x ); + DALI_TEST_CHECK( current.y > Vector3::ZERO.y ); + DALI_TEST_CHECK( current.z > Vector3::ZERO.z ); + DALI_TEST_CHECK( current.x < seventyFivePercentProgress.x ); + DALI_TEST_CHECK( current.y < seventyFivePercentProgress.y ); + DALI_TEST_CHECK( current.z < seventyFivePercentProgress.z ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationMoveToVector3AlphaFloat2(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(200.0f, 200.0f, 200.0f); + float delay = 0.5f; + animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear, delay, durationSeconds - delay); + + Vector3 seventyFivePercentProgress(targetPosition * 0.75f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), seventyFivePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationMove(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Vector3 initialPosition(Vector3::ZERO); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION ); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(10.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(200.0f, 200.0f, 200.0f); + BounceFunc func(0.0f, 0.0f, -100.0f); + animation.Move(actor, func, AlphaFunctions::Linear, 0.0f, durationSeconds); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationRotateByDegreeVector3(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Degree relativeRotationDegrees(360.0f); + Radian relativeRotationRadians(relativeRotationDegrees); + animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationRotateByRadianVector3(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Degree relativeRotationDegrees(360.0f); + Radian relativeRotationRadians(relativeRotationDegrees); + animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationRotateByDegreeVector3Alpha(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Degree relativeRotationDegrees(360.0f); + Radian relativeRotationRadians(relativeRotationDegrees); + animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationRotateByRadianVector3Alpha(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Degree relativeRotationDegrees(360.0f); + Radian relativeRotationRadians(relativeRotationDegrees); + animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationRotateByDegreeVector3AlphaFloat2(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Degree relativeRotationDegrees(360.0f); + Radian relativeRotationRadians(relativeRotationDegrees); + float delay = 0.3f; + animation.RotateBy(actor, relativeRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + float progress = max(0.0f, 0.25f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + progress = max(0.0f, 0.5f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + progress = max(0.0f, 0.75f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + + +int UtcDaliAnimationRotateByRadianVector3AlphaFloat2(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Degree relativeRotationDegrees(360.0f); + Radian relativeRotationRadians(relativeRotationDegrees); + float delay = 0.3f; + animation.RotateBy(actor, relativeRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + float progress = max(0.0f, 0.25f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + progress = max(0.0f, 0.5f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + progress = max(0.0f, 0.75f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(relativeRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationRotateToDegreeVector3(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Degree targetRotationDegrees(90.0f); + Radian targetRotationRadians(targetRotationDegrees); + animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationRotateToRadianVector3(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Degree targetRotationDegrees(90.0f); + Radian targetRotationRadians(targetRotationDegrees); + animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationRotateToQuaternion(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Degree targetRotationDegrees(90.0f); + Radian targetRotationRadians(targetRotationDegrees); + Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS); + animation.RotateTo(actor, targetRotation/*Quaternion version*/); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * 0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationRotateToDegreeVector3Alpha(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Degree targetRotationDegrees(90.0f); + Radian targetRotationRadians(targetRotationDegrees); + animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationRotateToRadianVector3Alpha(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Degree targetRotationDegrees(90.0f); + Radian targetRotationRadians(targetRotationDegrees); + animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationRotateToQuaternionAlpha(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Degree targetRotationDegrees(90.0f); + Radian targetRotationRadians(targetRotationDegrees); + Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS); + animation.RotateTo(actor, targetRotation/*Quaternion version*/, AlphaFunctions::EaseIn); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationRotateToDegreeVector3AlphaFloat2(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Degree targetRotationDegrees(90.0f); + Radian targetRotationRadians(targetRotationDegrees); + float delay(0.1f); + animation.RotateTo(actor, targetRotationDegrees/*Degree version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + float progress = max(0.0f, 0.25f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + progress = max(0.0f, 0.5f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + progress = max(0.0f, 0.75f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationRotateToRadianVector3AlphaFloat2(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Degree targetRotationDegrees(90.0f); + Radian targetRotationRadians(targetRotationDegrees); + float delay(0.1f); + animation.RotateTo(actor, targetRotationRadians/*Radian version*/, Vector3::YAXIS, AlphaFunctions::EaseIn, delay, durationSeconds - delay); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + float progress = max(0.0f, 0.25f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + progress = max(0.0f, 0.5f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + progress = max(0.0f, 0.75f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationRotateToQuaternionAlphaFloat2(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Degree targetRotationDegrees(90.0f); + Radian targetRotationRadians(targetRotationDegrees); + float delay(0.1f); + Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS); + animation.RotateTo(actor, targetRotation/*Quaternion version*/, AlphaFunctions::EaseIn, delay, durationSeconds - delay); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + float progress = max(0.0f, 0.25f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + progress = max(0.0f, 0.5f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + progress = max(0.0f, 0.75f - delay) / (1.0f - delay); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(targetRotationRadians, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationRotate(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Quaternion initialRotation(0.0f, Vector3::YAXIS); + actor.SetRotation(initialRotation); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), initialRotation, ROTATION_EPSILON, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + TumbleFunc func(Vector3::YAXIS); + animation.Rotate(actor, func, AlphaFunctions::Linear, 0.0f, durationSeconds); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.25f, initialRotation), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.5f, initialRotation), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(0.75f, initialRotation), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), func(1.0f, initialRotation), ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationScaleBy(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetScale(2.0f, 2.0f, 2.0f); + Vector3 relativeScale(targetScale - Vector3::ONE); + animation.ScaleBy(actor, relativeScale.x, relativeScale.y, relativeScale.z); + + Vector3 ninetyNinePercentProgress(Vector3::ONE + relativeScale*0.99f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetScale(Vector3::ONE); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + + // Repeat with a different (ease-in) alpha function + animation = Animation::New(durationSeconds); + animation.ScaleBy(actor, relativeScale, AlphaFunctions::EaseIn); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // The scale should have grown less, than with a linear alpha function + Vector3 current(actor.GetCurrentScale()); + DALI_TEST_CHECK( current.x > 1.0f ); + DALI_TEST_CHECK( current.y > 1.0f ); + DALI_TEST_CHECK( current.z > 1.0f ); + DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x ); + DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y ); + DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetScale(Vector3::ONE); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + + // Repeat with a delay + float delay = 0.5f; + animation = Animation::New(durationSeconds); + animation.ScaleBy(actor, relativeScale, AlphaFunctions::Linear, delay, durationSeconds - delay); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationScaleTo(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetScale(2.0f, 2.0f, 2.0f); + animation.ScaleTo(actor, targetScale.x, targetScale.y, targetScale.z); + + Vector3 ninetyNinePercentProgress(Vector3::ONE + (targetScale - Vector3::ONE)*0.99f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale(), ninetyNinePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetScale(Vector3::ONE); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + + // Repeat with a different (ease-in) alpha function + animation = Animation::New(durationSeconds); + animation.ScaleTo(actor, targetScale, AlphaFunctions::EaseIn); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // The scale should have grown less, than with a linear alpha function + Vector3 current(actor.GetCurrentScale()); + DALI_TEST_CHECK( current.x > 1.0f ); + DALI_TEST_CHECK( current.y > 1.0f ); + DALI_TEST_CHECK( current.z > 1.0f ); + DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x ); + DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y ); + DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetScale(Vector3::ONE); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + + // Repeat with a delay + float delay = 0.5f; + animation = Animation::New(durationSeconds); + animation.ScaleTo(actor, targetScale, AlphaFunctions::Linear, delay, durationSeconds - delay); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentScale(), targetScale, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationShow(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetVisible(false); + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( !actor.IsVisible() ); + Stage::GetCurrent().Add(actor); + + // Start the animation + float durationSeconds(10.0f); + Animation animation = Animation::New(durationSeconds); + animation.Show(actor, durationSeconds*0.5f); + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*490.0f)); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK( !actor.IsVisible() ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*10.0f)/*Should be shown now*/); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK( actor.IsVisible() ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( actor.IsVisible() ); + END_TEST; +} + +int UtcDaliAnimationHide(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + DALI_TEST_CHECK( actor.IsVisible() ); + Stage::GetCurrent().Add(actor); + + // Start the animation + float durationSeconds(10.0f); + Animation animation = Animation::New(durationSeconds); + animation.Hide(actor, durationSeconds*0.5f); + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*490.0f)); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK( actor.IsVisible() ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*10.0f)/*Should be hidden now*/); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_CHECK( !actor.IsVisible() ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( !actor.IsVisible() ); + END_TEST; +} + +int UtcDaliAnimationShowHideAtEnd(void) +{ + // Test that show/hide delay can be the same as animation duration + // i.e. to show/hide at the end of the animation + + TestApplication application; + + Actor actor = Actor::New(); + DALI_TEST_CHECK( actor.IsVisible() ); + Stage::GetCurrent().Add(actor); + + // Start Hide animation + float durationSeconds(10.0f); + Animation animation = Animation::New(durationSeconds); + animation.Hide(actor, durationSeconds/*Hide at end*/); + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( !actor.IsVisible() ); + + // Start Show animation + animation = Animation::New(durationSeconds); + animation.Show(actor, durationSeconds/*Show at end*/); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*1000.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_CHECK( actor.IsVisible() ); + END_TEST; +} + +int UtcDaliAnimationOpacityBy(void) +{ + TestApplication application; + Actor actor = Actor::New(); + float startingOpacity(0.5f); + actor.SetOpacity(startingOpacity); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION ); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float relativeOpacity(-0.5f); // target of zero + animation.OpacityBy(actor, relativeOpacity); + + float seventyFivePercentProgress((1.0f - 0.75f) * startingOpacity); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*750.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOpacity(), seventyFivePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetOpacity(startingOpacity); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION ); + + // Repeat with a different (ease-in) alpha function + animation = Animation::New(durationSeconds); + animation.OpacityBy(actor, relativeOpacity, AlphaFunctions::EaseIn); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*750.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // The opacity should reduce less, than with a linear alpha function + float current(actor.GetCurrentOpacity()); + DALI_TEST_CHECK( current < 1.0f ); + DALI_TEST_CHECK( current > seventyFivePercentProgress ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetOpacity(startingOpacity); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION ); + + // Repeat with a delay + float delay = 0.5f; + animation = Animation::New(durationSeconds); + animation.OpacityBy(actor, relativeOpacity, AlphaFunctions::Linear, delay, durationSeconds - delay); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f*0.75)/* 7/8 animation progress, 3/4 animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOpacity(), seventyFivePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f*0.25) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOpacity(), startingOpacity+relativeOpacity, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationOpacityTo(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetOpacity(0.0f); + animation.OpacityTo(actor, targetOpacity); + + float ninetyNinePercentProgress(0.01f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOpacity(), ninetyNinePercentProgress, 0.001f, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetOpacity(1.0f); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION ); + + // Repeat with a different (ease-in) alpha function + animation = Animation::New(durationSeconds); + animation.OpacityTo(actor, targetOpacity, AlphaFunctions::EaseIn); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // The opacity should reduce less, than with a linear alpha function + float current(actor.GetCurrentOpacity()); + DALI_TEST_CHECK( current < 1.0f ); + DALI_TEST_CHECK( current > ninetyNinePercentProgress ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetOpacity(1.0f); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION ); + + // Repeat with a delay + float delay = 0.5f; + animation = Animation::New(durationSeconds); + animation.OpacityTo(actor, targetOpacity, AlphaFunctions::Linear, delay, durationSeconds - delay); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOpacity(), 1.0f, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentOpacity(), targetOpacity, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationColorBy(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetColor(Color::BLACK); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::BLACK, TEST_LOCATION ); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector4 targetColor(Color::GREEN); + Vector4 relativeColor(Color::GREEN); // Note the alpha is automatically clamped <= 1.0f in world color + animation.ColorBy(actor, relativeColor); + + Vector4 tenPercentProgress(Vector4(0.0f, 0.1f, 0.0f, 1.0f)); + Vector4 twentyPercentProgress(Vector4(0.0f, 0.2f, 0.0f, 1.0f)); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*100.0f)/* 10% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), tenPercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetColor(Color::BLACK); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), Color::BLACK, TEST_LOCATION ); + + // Repeat with a different (ease-in) alpha function + animation = Animation::New(durationSeconds); + animation.ColorBy(actor, relativeColor, AlphaFunctions::EaseIn); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*100.0f)/* 10% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // The color should have changed less, than with a linear alpha function + Vector4 current(actor.GetCurrentWorldColor()); + DALI_TEST_CHECK( current.x == 0.0f ); // doesn't change + DALI_TEST_CHECK( current.y > 0.0f ); + DALI_TEST_CHECK( current.y < tenPercentProgress.y ); + DALI_TEST_CHECK( current.z == 0.0f ); // doesn't change + DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change + + application.SendNotification(); + application.Render(static_cast(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetColor(Color::BLACK); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), Color::BLACK, TEST_LOCATION ); + + // Repeat with a shorter animator duration + float animatorDuration = 0.5f; + animation = Animation::New(durationSeconds); + animation.ColorBy(actor, relativeColor, AlphaFunctions::Linear, 0, animatorDuration); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), twentyPercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentWorldColor(), targetColor, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationColorTo(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector4 targetColor(Color::RED); + animation.ColorTo(actor, targetColor); + + Vector4 tenPercentProgress(Vector4(1.0f, 0.9f, 0.9f, 1.0f)); + Vector4 twentyPercentProgress(Vector4(1.0f, 0.8f, 0.8f, 1.0f)); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*100.0f)/* 10% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor(), tenPercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetColor(Color::WHITE); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); + + // Repeat with a different (ease-in) alpha function + animation = Animation::New(durationSeconds); + animation.ColorTo(actor, targetColor, AlphaFunctions::EaseIn); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*100.0f)/* 10% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // The color should have changed less, than with a linear alpha function + Vector4 current(actor.GetCurrentColor()); + DALI_TEST_CHECK( current.x == 1.0f ); // doesn't change + DALI_TEST_CHECK( current.y < 1.0f ); + DALI_TEST_CHECK( current.y > tenPercentProgress.y ); + DALI_TEST_CHECK( current.z < 1.0f ); + DALI_TEST_CHECK( current.z > tenPercentProgress.z ); + DALI_TEST_CHECK( current.w == 1.0f ); // doesn't change + + application.SendNotification(); + application.Render(static_cast(durationSeconds*900.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetColor(Color::WHITE); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); + + // Repeat with a shorter animator duration + float animatorDuration = 0.5f; + animation = Animation::New(durationSeconds); + animation.ColorTo(actor, targetColor, AlphaFunctions::Linear, 0, animatorDuration); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*100.0f)/* 10% animation progress, 20% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*400.0f)/* 50% animation progress, 100% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationResize(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetSize(100.0f, 100.0f, 100.0f); + animation.Resize(actor, targetSize); + + Vector3 ninetyNinePercentProgress(targetSize * 0.99f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetSize(Vector3::ZERO); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + + // Repeat with a different (ease-in) alpha function + animation = Animation::New(durationSeconds); + animation.Resize(actor, targetSize, AlphaFunctions::EaseIn); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // The size should have travelled less, than with a linear alpha function + Vector3 current(actor.GetCurrentSize()); + DALI_TEST_CHECK( current.x > 0.0f ); + DALI_TEST_CHECK( current.y > 0.0f ); + DALI_TEST_CHECK( current.z > 0.0f ); + DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x ); + DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y ); + DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetSize(Vector3::ZERO); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + + // Repeat with a delay + float delay = 0.5f; + animation = Animation::New(durationSeconds); + animation.Resize(actor, targetSize, AlphaFunctions::Linear, delay, durationSeconds - delay); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateBool(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION ); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(10.0f); + Animation animation = Animation::New(durationSeconds); + animation.Animate( Property(actor, Actor::VISIBLE), ReturnFalseAfterProgressOne, TimePeriod(durationSeconds*0.25f/*delay*/, durationSeconds*0.1f) ); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // Should still be visible + DALI_TEST_EQUALS( actor.IsVisible(), true, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // Now animate functor should have hidden the actor + DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.IsVisible(), false, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateFloat(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Register a float property + float startValue(10.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(10.0f); + Animation animation = Animation::New(durationSeconds); + float targetPosition(0.0f); + AnimateFloatTestFunctor func( 100, targetPosition ); + animation.Animate( Property(actor, index), func ); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), 75.0f, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), 50.0f, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), 25.0f, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetPosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateVector2(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Register a Vector2 property + Vector2 startValue(10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(10.0f); + Animation animation = Animation::New(durationSeconds); + Vector2 targetPosition(0.0f, 0.0f); + AnimateVector2TestFunctor func( Vector2(100,100), targetPosition ); + animation.Animate( Property(actor, index), func ); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), Vector2(75,75), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), Vector2(50,50), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), Vector2(25,25), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetPosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateVector3(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Vector3 initialPosition(Vector3::ZERO); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION ); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(10.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(200.0f, 200.0f, 200.0f); + BounceFunc func(0.0f, 0.0f, -100.0f); + animation.Animate( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear, durationSeconds ); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateVector4(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + // Register a Vector4 property + Vector4 startValue(10.0f, 10.0f, 10.0f, 10.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(10.0f); + Animation animation = Animation::New(durationSeconds); + Vector4 targetPosition(200,400,0,-1000); + AnimateVector4TestFunctor func( Vector4(1000,1000,1000,1000), targetPosition ); + animation.Animate( Property(actor, index), func ); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), Vector4(800,850,750,500), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), Vector4(600,700,500,0), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), Vector4(400,550,250,-500), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetPosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationAnimateQuaternion(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetRotation(Quaternion(0.0f, Vector3::YAXIS)); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + + Degree sourceRotationDegrees(90.0f); + Radian sourceRotationRadians(sourceRotationDegrees); + Quaternion sourceRotation(sourceRotationRadians, Vector3::YAXIS); + + Degree targetRotationDegrees(150.0f); + Radian targetRotationRadians(targetRotationDegrees); + Quaternion targetRotation(targetRotationRadians, Vector3::YAXIS); + + AnimateQuaternionTestFunctor func( sourceRotation, targetRotation ); + animation.Animate( Property(actor, Actor::ROTATION), func ); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(105)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(120)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), Quaternion(Radian(Degree(135)), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentRotation(), targetRotation, ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliKeyFramesCreateDestroy(void) +{ + tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()"); + + KeyFrames* keyFrames = new KeyFrames; + delete keyFrames; + DALI_TEST_CHECK( true ); + END_TEST; +} + +int UtcDaliKeyFramesDownCast(void) +{ + TestApplication application; + tet_infoline("Testing Dali::Animation::KeyFramesDownCast()"); + + KeyFrames keyFrames = KeyFrames::New(); + BaseHandle object(keyFrames); + + KeyFrames keyFrames2 = KeyFrames::DownCast(object); + DALI_TEST_CHECK(keyFrames2); + + KeyFrames keyFrames3 = DownCast< KeyFrames >(object); + DALI_TEST_CHECK(keyFrames3); + + BaseHandle unInitializedObject; + KeyFrames keyFrames4 = KeyFrames::DownCast(unInitializedObject); + DALI_TEST_CHECK(!keyFrames4); + + KeyFrames keyFrames5 = DownCast< KeyFrames >(unInitializedObject); + DALI_TEST_CHECK(!keyFrames5); + END_TEST; +} + +int UtcDaliAnimationResizeByXY(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetSize(100.0f, 100.0f, 100.0f); + animation.Resize(actor, targetSize); + + Vector3 ninetyNinePercentProgress(targetSize * 0.99f); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentSize(), ninetyNinePercentProgress, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetSize(Vector3::ZERO); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + + // Repeat with a different (ease-in) alpha function + animation = Animation::New(durationSeconds); + animation.Resize(actor, targetSize.x, targetSize.y, AlphaFunctions::EaseIn); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*990.0f)/* 99% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + // The size should have travelled less, than with a linear alpha function + Vector3 current(actor.GetCurrentSize()); + DALI_TEST_CHECK( current.x > 0.0f ); + DALI_TEST_CHECK( current.y > 0.0f ); + DALI_TEST_CHECK( current.z > 0.0f ); + DALI_TEST_CHECK( current.x < ninetyNinePercentProgress.x ); + DALI_TEST_CHECK( current.y < ninetyNinePercentProgress.y ); + DALI_TEST_CHECK( current.z < ninetyNinePercentProgress.z ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*10.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION ); + + // Reset everything + finishCheck.Reset(); + actor.SetSize(Vector3::ZERO); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + + // Repeat with a delay + float delay = 0.5f; + animation = Animation::New(durationSeconds); + animation.Resize(actor, targetSize.x, targetSize.y, AlphaFunctions::Linear, delay, durationSeconds - delay); + animation.FinishedSignal().Connect(&application, finishCheck); + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f)/* 50% animation progress, 0% animator progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*500.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentSize(), targetSize, TEST_LOCATION ); + END_TEST; +} + + +int UtcDaliAnimationAnimateBetweenActorColorTimePeriod(void) +{ + TestApplication application; + + float startValue(1.0f); + Actor actor = Actor::New(); + actor.SetColor(Vector4(startValue, startValue, startValue, startValue)); + Stage::GetCurrent().Add(actor); + + DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + + KeyFrames keyFrames = KeyFrames::New(); + keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f)); + keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f)); + keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f)); + + animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, TimePeriod( 1.0f) ); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + application.SendNotification(); + application.Render(0); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)+1/* 100% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION ); + + // We did expect the animation to finish + + finishCheck.CheckSignalReceived(); + END_TEST; +} + +int UtcDaliAnimationAnimateBetweenActorColorFunction(void) +{ + TestApplication application; + + float startValue(1.0f); + Actor actor = Actor::New(); + actor.SetColor(Vector4(startValue, startValue, startValue, startValue)); + Stage::GetCurrent().Add(actor); + + DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + + KeyFrames keyFrames = KeyFrames::New(); + keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f)); + keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f)); + keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f)); + + animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, AlphaFunctions::Linear ); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + application.SendNotification(); + application.Render(0); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)+1/* 100% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION ); + + // We did expect the animation to finish + + finishCheck.CheckSignalReceived(); + END_TEST; +} + +int UtcDaliAnimationAnimateBetweenActorColorFunctionTimePeriod(void) +{ + TestApplication application; + + float startValue(1.0f); + Actor actor = Actor::New(); + actor.SetColor(Vector4(startValue, startValue, startValue, startValue)); + Stage::GetCurrent().Add(actor); + + DALI_TEST_EQUALS( actor.GetCurrentColor().a, startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), startValue, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + + KeyFrames keyFrames = KeyFrames::New(); + keyFrames.Add(0.0f, Vector4(0.1f, 0.2f, 0.3f, 0.4f)); + keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f)); + keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f)); + + animation.AnimateBetween( Property(actor, Actor::COLOR), keyFrames, AlphaFunctions::Linear, TimePeriod( 1.0f) ); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + application.SendNotification(); + application.Render(0); + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.1f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.2f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.3f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.4f, 0.01f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.5f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.5f, 0.01f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.9f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.8f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.7f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.6f, 0.01f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 0.95f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 0.90f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 0.85f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 0.80f, 0.01f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)+1/* 100% progress */); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_RED), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_GREEN), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_BLUE), 1.0f, 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty(Actor::COLOR_ALPHA), 1.0f, 0.01f, TEST_LOCATION ); + + // We did expect the animation to finish + + finishCheck.CheckSignalReceived(); + END_TEST; +} + +int UtcDaliAnimationAnimateVector3Func(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Vector3 initialPosition(Vector3::ZERO); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION ); + Stage::GetCurrent().Add(actor); + + // Build the animation + float durationSeconds(10.0f); + Animation animation = Animation::New(durationSeconds); + Vector3 targetPosition(200.0f, 200.0f, 200.0f); + BounceFunc func(0.0f, 0.0f, -100.0f); + animation.Animate( Property(actor, Actor::POSITION), func, AlphaFunctions::Linear ); + + // Start the animation + animation.Play(); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.25f, initialPosition), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.5f, initialPosition), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), func(0.75f, initialPosition), TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), initialPosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnimationCreateDestroy(void) +{ + TestApplication application; + Animation* animation = new Animation; + DALI_TEST_CHECK( animation ); + delete animation; + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Any.cpp b/automated-tests/src/dali/utc-Dali-Any.cpp new file mode 100644 index 0000000..a126ae0 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-Any.cpp @@ -0,0 +1,244 @@ +/// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +// Temp include +#include + +using namespace Dali; + +void utc_dali_any_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_any_cleanup(void) +{ + test_return_value = TET_PASS; +} + +int UtcDaliAnyConstructors(void) +{ + TestApplication application; + + tet_infoline("Test Any constructors."); + + // Test default constructor. + Any value; + + DALI_TEST_CHECK( typeid( void ) == value.GetType() ); + + // Test constructor Any( const Type& ) + Any value1 = 4u; + + // Test constructor Any( const Any& ) + Any value2 = value1; + + // Test constructor Any( const Any& ) with a non initialized Any + Any value3 = value; + + DALI_TEST_CHECK( typeid( unsigned int ) == value1.GetType() ); + DALI_TEST_CHECK( typeid( unsigned int ) == value2.GetType() ); + DALI_TEST_CHECK( typeid( void ) == value3.GetType() ); + + unsigned int uiValue1 = 0u; + unsigned int uiValue2 = 0u; + value1.Get( uiValue1 ); + value2.Get( uiValue2 ); + + DALI_TEST_EQUALS( uiValue1, uiValue2, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnyAssignmentOperators(void) +{ + TestApplication application; + + tet_infoline("Test assignment operators."); + + float fValue = 0.f; + + Any value1; + + value1 = 4.f; // Test operator=( const Type& ) when current object is not initialized. + + value1.Get( fValue ); + + DALI_TEST_EQUALS( fValue, 4.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + + Any value2 = 0.f; + + value2 = 9.f; // Test operator=( const Type& ). + + value2.Get( fValue ); + + DALI_TEST_EQUALS( fValue, 9.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + + Any value3 = 5.f; + + value1 = value3; // Test operator=( const Any& ). + + value1.Get( fValue ); + + DALI_TEST_EQUALS( fValue, 5.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + + Any value4; + + value4 = value3; // Test operator=( const Any& ) when current object is not initialized. + + value4.Get( fValue ); + + DALI_TEST_EQUALS( fValue, 5.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + + // Test assign a value to value3 doesn't modify value1. + value3 = 3.f; + + value1.Get( fValue ); + + DALI_TEST_EQUALS( fValue, 5.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + + value3.Get( fValue ); + + DALI_TEST_EQUALS( fValue, 3.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + + // Test the branch when copying the same object. + Any value5 = 3.f; + Any& value6( value5 ); + + value6 = value5; + + value6.Get( fValue ); + DALI_TEST_EQUALS( fValue, 3.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnyNegativeAssignmentOperators(void) +{ + TestApplication application; + + tet_infoline("Test assignment operators."); + + Any value1 = 4.f; + Any value2 = 5u; + + bool assert = false; + + try + { + value1 = value2; // Test operator=( const Any& ); + } + catch( Dali::DaliException& e ) + { + tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); + assert = true; + } + + if( assert ) + { + tet_result( TET_PASS ); + } + else + { + tet_result( TET_FAIL ); + } + END_TEST; +} + +int UtcDaliAnyGetType(void) +{ + TestApplication application; + + tet_infoline("Test GetType()."); + + Any value; + + DALI_TEST_CHECK( typeid( void ) == value.GetType() ); + + value = 5.f; + + DALI_TEST_CHECK( typeid( float ) == value.GetType() ); + END_TEST; +} + +int UtcDaliAnyGet(void) +{ + TestApplication application; + + tet_infoline("Test Get()."); + + Any value1( 5.f ); + + float fValue = value1.Get(); + + DALI_TEST_EQUALS( fValue, 5.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + + fValue = 0.f; + value1.Get( fValue ); + DALI_TEST_EQUALS( fValue, 5.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliAnyNegativeGet(void) +{ + TestApplication application; + tet_infoline("Test Get()."); + + Any value1; + Any value2( 5.f ); + + bool assert1 = false; + bool assert2 = false; + + unsigned int uiValue = 0u; + + try + { + uiValue = value1.Get< unsigned int >(); + } + + catch( Dali::DaliException& e ) + { + tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); + assert1 = true; + } + + try + { + uiValue = value2.Get< unsigned int >(); + } + + catch( Dali::DaliException& e ) + { + tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); + assert2 = true; + } + + if( assert1 && assert2 ) + { + tet_result( TET_PASS ); + } + else + { + tet_result( TET_FAIL ); + } + uiValue++; // supresss warning from unused variable + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-BaseHandle.cpp b/automated-tests/src/dali/utc-Dali-BaseHandle.cpp new file mode 100644 index 0000000..d430d88 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-BaseHandle.cpp @@ -0,0 +1,460 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 "dali-test-suite-utils/dali-test-suite-utils.h" + +using namespace Dali; + + +void utc_base_handle_startup(void) +{ + test_return_value = TET_UNDEF; +} + +// Called after each test +void utc_base_handle_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ + +// Functor to test whether an animation finish signal is emitted +struct AnimationFinishCheck +{ + AnimationFinishCheck(bool& signalReceived) + : mSignalReceived(signalReceived) + { + } + + void operator()(Animation& animation) + { + mSignalReceived = true; + } + + void Reset() + { + mSignalReceived = false; + } + + void CheckSignalReceived() + { + if (!mSignalReceived) + { + tet_printf("Expected Finish signal was not received\n"); + tet_result(TET_FAIL); + } + else + { + tet_result(TET_PASS); + } + } + + bool& mSignalReceived; // owned by individual tests +}; + +BaseHandle ImplicitCopyConstructor(BaseHandle passedByValue) +{ + // object + copy + passedByValue, ref count == 3 + DALI_TEST_CHECK(passedByValue); + if (passedByValue) + { + DALI_TEST_EQUALS(3, passedByValue.GetBaseObject().ReferenceCount(), TEST_LOCATION); + } + + return passedByValue; +} + +static bool gTouchCallBackCalled; + +struct TestCallback +{ + void operator()() + { + gTouchCallBackCalled = true; + } +}; + +} // anon namespace + +int UtcDaliBaseHandleConstructorVoid(void) +{ + TestApplication application; + tet_infoline("Testing Dali::BaseHandle::BaseHandle()"); + + BaseHandle object; + + DALI_TEST_CHECK(!object); + END_TEST; +} + + +int UtcDaliBaseHandleCopyConstructor(void) +{ + TestApplication application; + tet_infoline("Testing Dali::BaseHandle::BaseHandle(const BaseHandle&)"); + + // Initialize an object, ref count == 1 + BaseHandle object = Actor::New(); + + DALI_TEST_EQUALS(1, object.GetBaseObject().ReferenceCount(), TEST_LOCATION); + + // Copy the object, ref count == 2 + BaseHandle copy(object); + DALI_TEST_CHECK(copy); + if (copy) + { + DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION); + } + + { + // Pass by value, and return another copy, ref count == 3 + BaseHandle anotherCopy = ImplicitCopyConstructor(copy); + + DALI_TEST_CHECK(anotherCopy); + if (anotherCopy) + { + DALI_TEST_EQUALS(3, anotherCopy.GetBaseObject().ReferenceCount(), TEST_LOCATION); + } + } + + // anotherCopy out of scope, ref count == 2 + DALI_TEST_CHECK(copy); + if (copy) + { + DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliBaseHandleAssignmentOperator(void) +{ + TestApplication application; + tet_infoline("Testing Dali::BaseHandle::operator="); + + BaseHandle object = Actor::New(); + + DALI_TEST_CHECK(object); + if (object) + { + DALI_TEST_EQUALS(1, object.GetBaseObject().ReferenceCount(), TEST_LOCATION); + } + + BaseHandle copy = object; + + DALI_TEST_CHECK(copy); + if (copy) + { + DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliBaseHandleGetBaseObject(void) +{ + TestApplication application; + tet_infoline("Testing Dali::BaseHandle::GetBaseObject()"); + + BaseHandle object = Actor::New(); + + BaseObject& handle = object.GetBaseObject(); + + DALI_TEST_EQUALS(1, handle.ReferenceCount(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliBaseHandleReset(void) +{ + TestApplication application; + tet_infoline("Testing Dali::BaseHandle::Reset()"); + + // Initialize an object, ref count == 1 + BaseHandle object = Actor::New(); + + DALI_TEST_EQUALS(1, object.GetBaseObject().ReferenceCount(), TEST_LOCATION); + + object.Reset(); + + DALI_TEST_CHECK(!object); + END_TEST; +} + +int UtcDaliBaseHandleEqualityOperator01(void) +{ + TestApplication application; + tet_infoline("Positive Test Dali::BaseHandle::operator=="); + + BaseHandle object = Actor::New(); + + DALI_TEST_CHECK(object); + + BaseHandle theSameBaseHandle = object; + + DALI_TEST_CHECK(object == theSameBaseHandle); + END_TEST; +} + +int UtcDaliBaseHandleEqualityOperator02(void) +{ + TestApplication application; + tet_infoline("Negative Test Dali::BaseHandle::operator=="); + + BaseHandle object = Actor::New(); + + DALI_TEST_CHECK(object); + + BaseHandle aDifferentBaseHandle = Actor::New(); + + DALI_TEST_CHECK(!(object == aDifferentBaseHandle)); + END_TEST; +} + +int UtcDaliBaseHandleInequalityOperator01(void) +{ + TestApplication application; + tet_infoline("Positive Test Dali::BaseHandle::operator!="); + + BaseHandle object = Actor::New(); + + DALI_TEST_CHECK(object); + + BaseHandle aDifferentBaseHandle = Actor::New(); + + DALI_TEST_CHECK(object != aDifferentBaseHandle); + END_TEST; +} + +int UtcDaliBaseHandleInequalityOperator02(void) +{ + TestApplication application; + tet_infoline("Negative Test Dali::BaseHandle::operator!="); + + BaseHandle object = Actor::New(); + + DALI_TEST_CHECK(object); + + BaseHandle theSameBaseHandle = object; + + DALI_TEST_CHECK(!(object != theSameBaseHandle)); + END_TEST; +} + +int UtcDaliBaseHandleStlVector(void) +{ + TestApplication application; + tet_infoline("Testing Dali::BaseHandle compatibility with std::vector"); + + const int TargetVectorSize(5); + + std::vector myVector; + + for (int i=0; i(myVector.size()), TEST_LOCATION); + + DALI_TEST_CHECK(myVector[0].GetName() == "Actor 1"); + DALI_TEST_CHECK(myVector[1].GetName() == "Actor 2"); + DALI_TEST_CHECK(myVector[2].GetName() == "Actor 3"); + DALI_TEST_CHECK(myVector[3].GetName() == "Actor 4"); + DALI_TEST_CHECK(myVector[4].GetName() == "Actor 5"); + END_TEST; +} + +int UtcDaliBaseHandleDoAction(void) +{ + TestApplication application; + tet_infoline("Positive Test Dali::BaseHandle::UtcDaliBaseHandleDoAction"); + + Actor actor = Actor::New(); + BaseHandle actorObject = actor; + + DALI_TEST_CHECK(actorObject); + + // Check that an invalid command is not performed + std::vector attributes; + DALI_TEST_CHECK(actorObject.DoAction("invalidCommand", attributes) == false); + + // Check that the actor is visible + actor.SetVisible(true); + DALI_TEST_CHECK(actor.IsVisible() == true); + + // Check the actor performed an action to hide itself + DALI_TEST_CHECK(actorObject.DoAction("hide", attributes) == true); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + // Check that the actor is now invisible + DALI_TEST_CHECK(actor.IsVisible() == false); + + // Check the actor performed an action to show itself + DALI_TEST_CHECK(actorObject.DoAction("show", attributes) == true); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + // Check that the actor is now visible + DALI_TEST_CHECK(actor.IsVisible() == true); + + Stage::GetCurrent().Add(actor); + + // Build an animation with initial duration of 1 second + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + BaseHandle animationObject = animation; + + DALI_TEST_CHECK(animationObject); + + // Check the current animation duration is 1 second + DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION); + + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + + // Set the new duration to be 2 seconds + float newDurationSeconds(2.0f); + Property::Value newDurationSecondsValue = Property::Value( newDurationSeconds ); + attributes.push_back(newDurationSecondsValue); + + // Check the animation performed an action to play itself with the specified duration of 2 seconds + animationObject.DoAction("play", attributes); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(newDurationSeconds * 1000.0f) + 1u/*just beyond the animation duration*/); + + // We expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + + // Check the new animation duration is 2 seconds + DALI_TEST_EQUALS(animation.GetDuration(), newDurationSeconds, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliBaseHandleConnectSignal(void) +{ + TestApplication application; + tet_infoline("Testing Dali::BaseHandle::ConnectSignal"); + + gTouchCallBackCalled = false; + + // get the root layer + Actor actor = Actor::New(); + actor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + actor.SetParentOrigin( ParentOrigin::TOP_LEFT ); + actor.SetPosition( 240, 400 ); + actor.SetSize( 100, 100 ); + + Stage::GetCurrent().Add( actor ); + + DALI_TEST_CHECK( gTouchCallBackCalled == false ); + + // connect to its touch signal + actor.ConnectSignal( &application, "touched", TestCallback() ); + + application.SendNotification(); + application.Render(1000); + application.SendNotification(); + application.Render(1000); + + // simulate a touch event + Dali::TouchPoint point( 0, TouchPoint::Down, 240, 400 ); + Dali::Integration::TouchEvent event; + event.AddPoint( point ); + application.ProcessEvent( event ); + + application.SendNotification(); + application.Render(1000); + application.SendNotification(); + application.Render(1000); + + DALI_TEST_CHECK( application.GetConnectionCount() > 0 ); + DALI_TEST_CHECK( gTouchCallBackCalled == true ); + + gTouchCallBackCalled = false; + application.DisconnectAll(); + + // simulate another touch event + application.ProcessEvent( event ); + + DALI_TEST_CHECK( gTouchCallBackCalled == false ); + END_TEST; +} + +int UtcDaliBaseHandleGetTypeName(void) +{ + TestApplication application; + tet_infoline("Testing Dali::BaseHandle::GetTypeName"); + + // get the root layer + Actor actor = Actor::New(); + + std::string typeName = actor.GetTypeName(); + + DALI_TEST_CHECK( typeName.size() ); + DALI_TEST_CHECK( typeName == std::string("Actor") ); + END_TEST; +} + +int UtcDaliBaseHandleGetObjectPtr(void) +{ + TestApplication application; + tet_infoline("Testing Dali::BaseHandle::GetObjectPtr"); + + // get the root layer + Actor actor = Actor::New(); + + Dali::RefObject* p = actor.GetObjectPtr(); + + DALI_TEST_CHECK( p != NULL ); + END_TEST; +} + +int UtcDaliBaseHandleBooleanCast(void) +{ + TestApplication application; + tet_infoline("Testing Dali::BaseHandle::BooleanType"); + + // get the root layer + BaseHandle handle = Actor::New(); + + DALI_TEST_CHECK( static_cast( handle ) ); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-BitmapImage.cpp b/automated-tests/src/dali/utc-Dali-BitmapImage.cpp new file mode 100644 index 0000000..c94fb99 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-BitmapImage.cpp @@ -0,0 +1,511 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 std::max; +using namespace Dali; + +void utc_dali_bitmap_image_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_bitmap_image_cleanup(void) +{ + test_return_value = TET_PASS; +} + +int UtcDaliBitmapImageNew01(void) +{ + TestApplication application; + + tet_infoline("UtcDaliBitmapImageNew01 - BitmapImage::New(unsigned int, unsigned int, Pixel::Format)"); + + // invoke default handle constructor + BitmapImage image; + + // initialise handle + image = BitmapImage::New(16, 16); + application.SendNotification(); + application.Render(16); + application.Render(16); + application.SendNotification(); + + ImageAttributes attributes = image.GetAttributes(); + + DALI_TEST_CHECK( attributes.GetWidth() == 16); + END_TEST; +} + +int UtcDaliBitmapImageNew02(void) +{ + TestApplication application; + + tet_infoline("UtcDaliBitmapImageNew02 - BitmapImage::New(PixelBuffer*, unsigned int, unsigned int, Pixel::Format, unsigned int)"); + + PixelBuffer* buffer = new PixelBuffer[16 * 16]; + BitmapImage image = BitmapImage::New(buffer, 16, 16, Pixel::A8); + application.SendNotification(); + application.Render(16); + application.Render(16); + application.SendNotification(); + + Dali::ImageAttributes attributes = image.GetAttributes(); + + DALI_TEST_CHECK( attributes.GetWidth() == 16); + + delete [] buffer; + END_TEST; +} + +int UtcDaliBitmapImageNewWithPolicy01(void) +{ + TestApplication application; + + tet_infoline("UtcDaliBitmapImageNewWithPolicy01 - BitmapImage::New(unsigned int, unsigned int, Pixel::Format, LoadPolicy, ReleasePolicy)"); + + // Force texture id's + std::vector ids; + ids.push_back( 23 ); + application.GetGlAbstraction().SetNextTextureIds( ids ); + + // invoke default handle constructor + BitmapImage image; + + // initialise handle + image = BitmapImage::New(16, 16, Pixel::A8, Image::OnDemand, Image::Unused); + application.SendNotification(); + application.Render(16); + application.Render(16); + application.SendNotification(); + + ImageAttributes attributes = image.GetAttributes(); + DALI_TEST_CHECK( attributes.GetWidth() == 16); + /// @todo: how to test OnDemand? - resource id would be 0 if buffer only allocated on first call to ::GetBuffer() + + ImageActor actor = ImageActor::New(image); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(16); + // testing ReleasePolicy::Unused + // fake loading image + application.Render(16); + application.SendNotification(); + + DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) ); + + // discard texture when actor comes off stage + Stage::GetCurrent().Remove(actor); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + DALI_TEST_CHECK ( application.GetGlAbstraction().CheckTextureDeleted(23) ); + END_TEST; +} + +int UtcDaliBitmapImageNewWithPolicy02(void) +{ + TestApplication application; + + tet_infoline("UtcDaliBitmapImageNewWithPolicy02 - BitmapImage::New(PixelBuffer*, unsigned int, unsigned int, Pixel::Format, unsigned int, ReleasePolicy)"); + + // Force texture id's + std::vector ids; + ids.push_back( 23 ); + application.GetGlAbstraction().SetNextTextureIds( ids ); + + PixelBuffer* buffer = new PixelBuffer[16 * 16]; + BitmapImage image = BitmapImage::New(buffer, 16, 16, Pixel::A8, 16, Image::Unused); + application.SendNotification(); + application.Render(16); + application.Render(16); + application.SendNotification(); + + ImageAttributes attributes = image.GetAttributes(); + DALI_TEST_CHECK( attributes.GetWidth() == 16); + /// @todo: how to test OnDemand? - resource id would be 0 if buffer only allocated on first call to ::GetBuffer() + + ImageActor actor = ImageActor::New(image); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(16); + // testing ReleasePolicy::Unused + // fake loading image + application.Render(16); + application.SendNotification(); + + DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) ); + + // discard texture when actor comes off stage + Stage::GetCurrent().Remove(actor); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + DALI_TEST_CHECK ( application.GetGlAbstraction().CheckTextureDeleted(23) ); + END_TEST; +} + +int UtcDaliBitmapImageDownCast(void) +{ + TestApplication application; + tet_infoline("Testing Dali::BitmapImage::DownCast()"); + + BitmapImage bitmap = BitmapImage::New(1, 1, Dali::Pixel::BGRA8888); + ImageActor imageActor = ImageActor::New(bitmap); + application.SendNotification(); + application.Render(16); + application.Render(16); + application.SendNotification(); + + Image image = imageActor.GetImage(); + BitmapImage bitmapImage = BitmapImage::DownCast( image ); + + DALI_TEST_CHECK(bitmapImage); + END_TEST; +} + +int UtcDaliBitmapImageDownCast2(void) +{ + TestApplication application; + tet_infoline("Testing Dali::BitmapImage::DownCast()"); + + Image image = Image::New("IncorrectImageName"); + ImageActor imageActor = ImageActor::New(image); + application.SendNotification(); + application.Render(16); + application.Render(16); + application.SendNotification(); + + Image image1 = imageActor.GetImage(); + + BitmapImage bitmapImage = BitmapImage::DownCast( image1 ); + DALI_TEST_CHECK(!bitmapImage); + + Actor unInitialzedActor; + bitmapImage = BitmapImage::DownCast( unInitialzedActor ); + DALI_TEST_CHECK(!bitmapImage); + END_TEST; +} + +int UtcDaliBitmapImageWHITE(void) +{ + TestApplication application; + + tet_infoline("UtcDaliBitmapImageWHITE - BitmapImage::WHITE()"); + + BitmapImage image = BitmapImage::WHITE(); // creates a 1x1 RGBA white pixel + application.SendNotification(); + application.Render(16); + application.Render(16); + application.SendNotification(); + + Dali::ImageAttributes attributes = image.GetAttributes(); + PixelBuffer* buffer = image.GetBuffer(); + + DALI_TEST_CHECK( attributes.GetWidth() == 1 && // 1 pixel wide + buffer != NULL && // valid buffer + *buffer == 0xff); // r component is 255 + END_TEST; +} + +int UtcDaliBitmapImageGetBuffer(void) +{ + TestApplication application; + + tet_infoline("UtcDaliBitmapImageGetBuffer"); + + BitmapImage image = BitmapImage::WHITE(); // creates a 1x1 RGBA white pixel + + PixelBuffer* buffer = image.GetBuffer(); + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + + ImageAttributes attributes = image.GetAttributes(); + DALI_TEST_CHECK( attributes.GetWidth() == 1 && // 1 pixel wide + buffer != NULL && // valid buffer + *((unsigned int*)buffer) == 0xffffffff); // all component are 255 + END_TEST; +} + +int UtcDaliBitmapImageGetBufferSize(void) +{ + TestApplication application; + + tet_infoline("UtcDaliBitmapImageGetBufferSize"); + + BitmapImage image = BitmapImage::WHITE(); // creates a 1x1 RGBA white pixel + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + + Dali::ImageAttributes attributes = image.GetAttributes(); + PixelBuffer* buffer = image.GetBuffer(); + unsigned int bufferSize = image.GetBufferSize(); + unsigned int pixelSize = Pixel::GetBytesPerPixel(attributes.GetPixelFormat()); + + DALI_TEST_CHECK( attributes.GetWidth() == 1 && // 1 pixel wide + buffer != NULL && // valid buffer + bufferSize == pixelSize); // r component is 255 + END_TEST; +} + +int UtcDaliBitmapImageGetBufferStride(void) +{ + TestApplication application; + + tet_infoline("UtcDaliBitmapImageGetBufferStride"); + + BitmapImage image = BitmapImage::WHITE(); // creates a 1x1 RGBA white pixel + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + + Dali::ImageAttributes attributes = image.GetAttributes(); + unsigned int pixelSize = Pixel::GetBytesPerPixel(attributes.GetPixelFormat()); + unsigned int bufferStride = image.GetBufferStride(); + DALI_TEST_CHECK( bufferStride == pixelSize ); + DALI_TEST_CHECK( !image.IsDataExternal() ); + + PixelBuffer* buffer = new PixelBuffer[20 * 16]; + image = BitmapImage::New(buffer, 16, 16, Pixel::A8, 20); + application.SendNotification(); + application.Render(16); + application.Render(16); + application.SendNotification(); + + bufferStride = image.GetBufferStride(); + + DALI_TEST_CHECK( bufferStride == 20); + DALI_TEST_CHECK( image.IsDataExternal() ); + + delete [] buffer; + END_TEST; +} + + +int UtcDaliBitmapImageIsDataExternal(void) +{ + TestApplication application; + + tet_infoline("UtcDaliBitmapImageIsDataExternal - BitmapImage::IsDataExternal()"); + + PixelBuffer* buffer = new PixelBuffer[16 * 16]; + BitmapImage image = BitmapImage::New(buffer, 16, 16, Pixel::A8); + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + + DALI_TEST_CHECK( image.IsDataExternal() ); + END_TEST; +} + +namespace +{ + +static bool SignalReceived; +static void ImageUploaded(Image image) +{ + tet_infoline("Received image uploaded signal"); + SignalReceived = true; +} +} + +int UtcDaliBitmapImageUpdate01(void) +{ + TestApplication application; + + tet_infoline("UtcDaliBitmapImageUpdate01 - single empty rect"); + + PixelBuffer* buffer = new PixelBuffer[16 * 16]; + + BitmapImage image = BitmapImage::New(buffer, 16, 16, Pixel::A8); + ImageActor actor = ImageActor::New(image); + Stage::GetCurrent().Add(actor); + actor.SetVisible(true); + + SignalReceived = false; + image.UploadedSignal().Connect( ImageUploaded ); + + std::vector ids; + ids.push_back(200); + ids.push_back(201); + ids.push_back(202); + application.GetGlAbstraction().SetNextTextureIds(ids); + + // Allow actor to be staged and rendered + application.SendNotification(); + application.Render(0); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + + DALI_TEST_CHECK( image.IsDataExternal() ); + application.GetGlAbstraction().EnableTextureCallTrace(true); + + image.Update();//(RectArea()); // notify Core that the image has been updated + application.SendNotification(); + application.Render(16); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + + const TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace(); + DALI_TEST_EQUALS( callStack.TestMethodAndParams(0, "TexSubImage2D", "0, 0, 16, 16"), true, TEST_LOCATION); + + DALI_TEST_CHECK( SignalReceived == true ); + SignalReceived = false; + END_TEST; +} + +int UtcDaliBitmapImageUpdate02(void) +{ + TestApplication application; + + tet_infoline("UtcDaliBitmapImageUpdate02 - Multiple rects"); + + PixelBuffer* buffer = new PixelBuffer[16 * 16]; + BitmapImage image = BitmapImage::New(buffer, 16, 16, Pixel::A8); + ImageActor actor = ImageActor::New(image); + Stage::GetCurrent().Add(actor); + actor.SetVisible(true); + + SignalReceived = false; + image.UploadedSignal().Connect( ImageUploaded ); + + std::vector ids; + ids.push_back(200); + ids.push_back(201); + ids.push_back(202); + application.GetGlAbstraction().SetNextTextureIds(ids); + + application.SendNotification(); + application.Render(0); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + + DALI_TEST_CHECK( image.IsDataExternal() ); + application.GetGlAbstraction().EnableTextureCallTrace(true); + + image.Update(RectArea(9,9,5,5)); // notify Core that the image has been updated + + application.SendNotification(); + application.Render(16); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + + const TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace(); + DALI_TEST_EQUALS( callStack.TestMethodAndParams(0, "TexSubImage2D", "9, 9, 5, 1"), true, TEST_LOCATION); + DALI_TEST_EQUALS( callStack.TestMethodAndParams(1, "TexSubImage2D", "9, 10, 5, 1"), true, TEST_LOCATION); + DALI_TEST_EQUALS( callStack.TestMethodAndParams(2, "TexSubImage2D", "9, 11, 5, 1"), true, TEST_LOCATION); + DALI_TEST_EQUALS( callStack.TestMethodAndParams(3, "TexSubImage2D", "9, 12, 5, 1"), true, TEST_LOCATION); + DALI_TEST_EQUALS( callStack.TestMethodAndParams(4, "TexSubImage2D", "9, 13, 5, 1"), true, TEST_LOCATION); + + DALI_TEST_CHECK( SignalReceived == true ); + SignalReceived = false; + END_TEST; +} + +int UtcDaliBitmapImageUploadedSignal01(void) +{ + TestApplication application; + + tet_infoline("UtcDaliBitmapImageUploadedSignal - Test that Uploaded signal is sent when image is staged"); + + PixelBuffer* buffer = new PixelBuffer[16 * 16]; + BitmapImage image = BitmapImage::New(buffer, 16, 16, Pixel::A8); + SignalReceived = false; + image.UploadedSignal().Connect( ImageUploaded ); + + application.SendNotification(); + application.Render(16); + application.Render(16); + application.SendNotification(); + + Dali::ImageActor imageActor = ImageActor::New(image); + Stage::GetCurrent().Add(imageActor); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + + DALI_TEST_CHECK( SignalReceived == true ); + END_TEST; +} + +int UtcDaliBitmapImageUploadedSignal02(void) +{ + TestApplication application; + + tet_infoline("UtcDaliBitmapImageUploadedSignal - Test that Uploaded signal is sent after Update"); + + PixelBuffer* buffer = new PixelBuffer[16 * 16]; + BitmapImage image = BitmapImage::New(buffer, 16, 16, Pixel::A8); + SignalReceived = false; + //ScopedConnection connection = + image.UploadedSignal().Connect( ImageUploaded ); + + application.SendNotification(); + application.Render(16); + application.Render(16); + application.SendNotification(); + + Dali::ImageActor imageActor = ImageActor::New(image); + Stage::GetCurrent().Add(imageActor); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + DALI_TEST_CHECK( SignalReceived == true ); + SignalReceived = false; + + image.Update(RectArea()); // notify Core that the whole image has been updated + application.SendNotification(); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + DALI_TEST_CHECK( SignalReceived == true ); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-CameraActor.cpp b/automated-tests/src/dali/utc-Dali-CameraActor.cpp new file mode 100644 index 0000000..2e02ce9 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-CameraActor.cpp @@ -0,0 +1,986 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 "dali-test-suite-utils/dali-test-suite-utils.h" + +using namespace Dali; + +void camera_actor_test_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void camera_actor_test_cleanup(void) +{ + test_return_value = TET_PASS; +} + + +namespace +{ +const float FLOAT_EPSILON = 0.001f; +const float TEST_ASPECT_RATIO = 0.123f; +const float TEST_FIELD_OF_VIEW = Radian(Degree(40.0f)); +const float TEST_NEAR_PLANE_DISTANCE = 0.23f; +const float TEST_FAR_PLANE_DISTANCE = 0.973f; + +const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME( "uLightCameraProjectionMatrix" ); +const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME( "uLightCameraViewMatrix" ); +const char* const RENDER_SHADOW_VERTEX_SOURCE = + " uniform mediump mat4 uLightCameraProjectionMatrix;\n" + " uniform mediump mat4 uLightCameraViewMatrix;\n" + "\n" + "void main()\n" + "{\n" + " gl_Position = uProjection * uModelView * vec4(aPosition,1.0);\n" + " vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix * vec4(aPosition,1.0);\n" + " vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n" + "}\n"; + +const char* const RENDER_SHADOW_FRAGMENT_SOURCE = + "uniform lowp vec4 uShadowColor;\n" + "void main()\n" + "{\n" + " lowp float alpha;\n" + " alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n" + " gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n" + "}\n"; + + +} // anon namespace + + +int UtcDaliCameraActorConstructorVoid(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CameraActor::CameraActor()"); + + CameraActor actor; + + DALI_TEST_CHECK(!actor); + END_TEST; +} + +int UtcDaliCameraActorNew(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CameraActor::New()"); + + CameraActor actor = CameraActor::New(); + + DALI_TEST_CHECK(actor); + + actor = NULL; + + DALI_TEST_CHECK(!actor); + END_TEST; +} + +int UtcDaliCameraActorDownCast(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CameraActor::DownCast()"); + + CameraActor camera = CameraActor::New(); + Actor anActor = Actor::New(); + anActor.Add( camera ); + + Actor child = anActor.GetChildAt(0); + CameraActor cameraActor = CameraActor::DownCast( child ); + DALI_TEST_CHECK( cameraActor ); + + cameraActor = NULL; + DALI_TEST_CHECK( !cameraActor ); + + cameraActor = DownCast< CameraActor >( child ); + DALI_TEST_CHECK( cameraActor ); + END_TEST; +} + +int UtcDaliCameraActorDownCast2(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CameraActor::DownCast()"); + + Actor actor1 = Actor::New(); + Actor anActor = Actor::New(); + anActor.Add(actor1); + + Actor child = anActor.GetChildAt(0); + CameraActor cameraActor = CameraActor::DownCast( child ); + DALI_TEST_CHECK( !cameraActor ); + + Actor unInitialzedActor; + cameraActor = CameraActor::DownCast( unInitialzedActor ); + DALI_TEST_CHECK( !cameraActor ); + + cameraActor = DownCast< CameraActor >( unInitialzedActor ); + DALI_TEST_CHECK( !cameraActor ); + END_TEST; +} + + +int UtcDaliCameraActorSetCameraOffStage(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CameraActor::SetCamera()"); + + CameraActor actor = CameraActor::New(); + + actor.SetType(Camera::FREE_LOOK); + actor.SetFieldOfView(TEST_FIELD_OF_VIEW); + actor.SetAspectRatio(TEST_ASPECT_RATIO); + actor.SetNearClippingPlane(TEST_NEAR_PLANE_DISTANCE); + actor.SetFarClippingPlane(TEST_FAR_PLANE_DISTANCE); + actor.SetProjectionMode(Camera::PERSPECTIVE_PROJECTION); + + actor.SetInvertYAxis(false); + + DALI_TEST_EQUALS(TEST_ASPECT_RATIO, actor.GetAspectRatio(), FLOAT_EPSILON, TEST_LOCATION); + DALI_TEST_EQUALS(TEST_FIELD_OF_VIEW, actor.GetFieldOfView(), FLOAT_EPSILON, TEST_LOCATION); + DALI_TEST_EQUALS(TEST_NEAR_PLANE_DISTANCE, actor.GetNearClippingPlane(), FLOAT_EPSILON, TEST_LOCATION); + DALI_TEST_EQUALS(TEST_FAR_PLANE_DISTANCE, actor.GetFarClippingPlane(), FLOAT_EPSILON, TEST_LOCATION); + DALI_TEST_EQUALS(Camera::PERSPECTIVE_PROJECTION, actor.GetProjectionMode(), TEST_LOCATION); + DALI_TEST_EQUALS(false, actor.GetInvertYAxis(), TEST_LOCATION); + + float value; + std::string sValue; + actor.GetProperty(CameraActor::ASPECT_RATIO).Get(value); + DALI_TEST_EQUALS(TEST_ASPECT_RATIO, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::FIELD_OF_VIEW).Get(value); + DALI_TEST_EQUALS(TEST_FIELD_OF_VIEW, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::NEAR_PLANE_DISTANCE).Get(value); + DALI_TEST_EQUALS(TEST_NEAR_PLANE_DISTANCE, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::FAR_PLANE_DISTANCE).Get(value); + DALI_TEST_EQUALS(TEST_FAR_PLANE_DISTANCE, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::PROJECTION_MODE).Get(sValue); + DALI_TEST_EQUALS("PERSPECTIVE_PROJECTION", sValue, TEST_LOCATION); + bool bValue; + actor.GetProperty(CameraActor::INVERT_Y_AXIS).Get(bValue); + DALI_TEST_EQUALS(false, bValue, TEST_LOCATION); + END_TEST; +} + +int UtcDaliCameraActorSetCameraOnStage(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CameraActor::SetCamera()"); + + CameraActor actor = CameraActor::New(); + Stage::GetCurrent().Add(actor); + application.Render(0); + application.SendNotification(); + + actor.SetType(Camera::LOOK_AT_TARGET); + actor.SetFieldOfView(TEST_FIELD_OF_VIEW); + actor.SetAspectRatio(TEST_ASPECT_RATIO); + actor.SetNearClippingPlane(TEST_NEAR_PLANE_DISTANCE); + actor.SetFarClippingPlane(TEST_FAR_PLANE_DISTANCE); + actor.SetInvertYAxis(false); + + DALI_TEST_EQUALS(false, actor.GetInvertYAxis(), TEST_LOCATION); + + // Will need 2 frames to ensure both buffers are set to same values: + application.Render(); + application.SendNotification(); + application.Render(); + application.SendNotification(); + + DALI_TEST_EQUALS(TEST_ASPECT_RATIO, actor.GetAspectRatio(), FLOAT_EPSILON, TEST_LOCATION); + DALI_TEST_EQUALS(TEST_FIELD_OF_VIEW, actor.GetFieldOfView(), FLOAT_EPSILON, TEST_LOCATION); + DALI_TEST_EQUALS(TEST_NEAR_PLANE_DISTANCE, actor.GetNearClippingPlane(), FLOAT_EPSILON, TEST_LOCATION); + DALI_TEST_EQUALS(TEST_FAR_PLANE_DISTANCE, actor.GetFarClippingPlane(), FLOAT_EPSILON, TEST_LOCATION); + DALI_TEST_EQUALS(false, actor.GetInvertYAxis(), TEST_LOCATION); + + std::string sValue; + actor.GetProperty(CameraActor::TYPE).Get(sValue); + DALI_TEST_EQUALS(sValue, "LOOK_AT_TARGET", TEST_LOCATION); + + float value; + actor.GetProperty(CameraActor::ASPECT_RATIO).Get(value); + DALI_TEST_EQUALS(TEST_ASPECT_RATIO, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::FIELD_OF_VIEW).Get(value); + DALI_TEST_EQUALS(TEST_FIELD_OF_VIEW, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::NEAR_PLANE_DISTANCE).Get(value); + DALI_TEST_EQUALS(TEST_NEAR_PLANE_DISTANCE, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::FAR_PLANE_DISTANCE).Get(value); + DALI_TEST_EQUALS(TEST_FAR_PLANE_DISTANCE, value, FLOAT_EPSILON, TEST_LOCATION); + + bool bValue; + actor.GetProperty(CameraActor::INVERT_Y_AXIS).Get(bValue); + DALI_TEST_EQUALS(false, bValue, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliCameraActorGetCamera(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CameraActor::GetCamera()"); + + CameraActor actor = CameraActor::New(); + + actor.SetAspectRatio(TEST_ASPECT_RATIO); + + DALI_TEST_EQUALS(actor.GetAspectRatio(), TEST_ASPECT_RATIO, FLOAT_EPSILON, TEST_LOCATION); + + actor.SetProperty(CameraActor::TYPE, "FREE_LOOK"); + actor.SetProperty(CameraActor::ASPECT_RATIO, TEST_ASPECT_RATIO); + actor.SetProperty(CameraActor::FIELD_OF_VIEW, TEST_FIELD_OF_VIEW); + actor.SetProperty(CameraActor::NEAR_PLANE_DISTANCE, TEST_NEAR_PLANE_DISTANCE); + actor.SetProperty(CameraActor::FAR_PLANE_DISTANCE, TEST_FAR_PLANE_DISTANCE); + + DALI_TEST_EQUALS(Camera::FREE_LOOK, actor.GetType(), TEST_LOCATION); + DALI_TEST_EQUALS(TEST_ASPECT_RATIO, actor.GetAspectRatio(), FLOAT_EPSILON, TEST_LOCATION); + DALI_TEST_EQUALS(TEST_FIELD_OF_VIEW, actor.GetFieldOfView(), FLOAT_EPSILON, TEST_LOCATION); + DALI_TEST_EQUALS(TEST_NEAR_PLANE_DISTANCE, actor.GetNearClippingPlane(), FLOAT_EPSILON, TEST_LOCATION); + DALI_TEST_EQUALS(TEST_FAR_PLANE_DISTANCE, actor.GetFarClippingPlane(), FLOAT_EPSILON, TEST_LOCATION); + END_TEST; +} + +int UtcDaliCameraActorDefaultProperties(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CameraActor DefaultProperties"); + + CameraActor actor = CameraActor::New(); + + actor.SetAspectRatio(TEST_ASPECT_RATIO); + Stage::GetCurrent().Add(actor); + application.Render(0); + application.SendNotification(); + bool bValue; + actor.GetProperty(CameraActor::INVERT_Y_AXIS).Get(bValue); + DALI_TEST_EQUALS(false, bValue, TEST_LOCATION); + + std::vector indices ; + indices.push_back(CameraActor::TYPE); + indices.push_back(CameraActor::PROJECTION_MODE); + indices.push_back(CameraActor::FIELD_OF_VIEW ); + indices.push_back(CameraActor::ASPECT_RATIO ); + indices.push_back(CameraActor::NEAR_PLANE_DISTANCE ); + indices.push_back(CameraActor::FAR_PLANE_DISTANCE ); + indices.push_back(CameraActor::LEFT_PLANE_DISTANCE ); + indices.push_back(CameraActor::RIGHT_PLANE_DISTANCE ); + indices.push_back(CameraActor::TOP_PLANE_DISTANCE ); + indices.push_back(CameraActor::BOTTOM_PLANE_DISTANCE ); + indices.push_back(CameraActor::TARGET_POSITION ); + indices.push_back(CameraActor::PROJECTION_MATRIX ); + indices.push_back(CameraActor::VIEW_MATRIX); + indices.push_back(CameraActor::INVERT_Y_AXIS ); + + DALI_TEST_CHECK(actor.GetPropertyCount() == ( Actor::New().GetPropertyCount() + indices.size() ) ); + + for(std::vector::iterator iter = indices.begin(); iter != indices.end(); ++iter) + { + DALI_TEST_EQUALS( *iter, actor.GetPropertyIndex(actor.GetPropertyName(*iter)), TEST_LOCATION); + DALI_TEST_CHECK( ! actor.IsPropertyAnimatable(*iter) ); + + switch(*iter) + { + if ( ( *iter == CameraActor::PROJECTION_MATRIX ) || + ( *iter == CameraActor::VIEW_MATRIX ) ) + { + DALI_TEST_CHECK( ! actor.IsPropertyWritable(*iter) ); + } + else + { + DALI_TEST_CHECK( actor.IsPropertyWritable(*iter) ); + } + } + + DALI_TEST_CHECK( actor.GetPropertyType(*iter) == actor.GetPropertyType(*iter) ); // just checking call succeeds + } + + // set/get one of them + const float newAspect = TEST_ASPECT_RATIO * 2.f; + + actor.SetProperty( CameraActor::ASPECT_RATIO, Property::Value(newAspect) ); + application.Render(); + application.SendNotification(); + application.Render(); + application.SendNotification(); + + DALI_TEST_EQUALS(actor.GetAspectRatio(), newAspect, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliCameraActorSetTarget(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CameraActor Get/Set Target Position"); + + CameraActor actor = CameraActor::New(); + DALI_TEST_EQUALS( actor.GetTargetPosition(), Vector3::ZERO, TEST_LOCATION ); + + Vector3 target( 10.0f, 20.0f, 30.0f); + actor.SetTargetPosition( target ); + + DALI_TEST_EQUALS( actor.GetTargetPosition(), target, TEST_LOCATION ); + + Vector3 value; + actor.GetProperty(CameraActor::TARGET_POSITION).Get(value); + DALI_TEST_EQUALS(target, value, FLOAT_EPSILON, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliCameraActorSetType01(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CameraActor Get/Set Type"); + + CameraActor actor = CameraActor::New(); + DALI_TEST_EQUALS( actor.GetType(), Dali::Camera::LOOK_AT_TARGET, TEST_LOCATION ); + + actor.SetType(Dali::Camera::FREE_LOOK); + DALI_TEST_EQUALS( actor.GetType(), Dali::Camera::FREE_LOOK, TEST_LOCATION ); + + std::string sValue; + actor.GetProperty(CameraActor::TYPE).Get(sValue); + std::string result("FREE_LOOK"); + DALI_TEST_EQUALS(result, sValue, TEST_LOCATION); + END_TEST; +} + +int UtcDaliCameraActorSetType02(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CameraActor Get/Set Type"); + + CameraActor actor; + + Dali::Camera::Type cameraType = Dali::Camera::FREE_LOOK ; + try + { + cameraType = actor.GetType(); + } + catch ( Dali::DaliException& e ) + { + tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "camera", TEST_LOCATION); + } + + const CameraActor aConstActor; + + try + { + cameraType = aConstActor.GetType(); + } + catch ( Dali::DaliException& e ) + { + tet_printf("Assertion %s test at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "camera", TEST_LOCATION); + } + + DALI_TEST_EQUALS((int)cameraType, (int)Dali::Camera::FREE_LOOK, TEST_LOCATION); + END_TEST; +} + +int UtcDaliCameraActorSetFieldOfView(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CameraActor Get/Set Field of view"); + + CameraActor defaultCamera = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) ); + const float defaultFov = defaultCamera.GetFieldOfView(); + + CameraActor actor = CameraActor::New(); + DALI_TEST_EQUALS( actor.GetFieldOfView(), defaultFov, TEST_LOCATION ); + + float fov = Math::PI/3.0f; + actor.SetFieldOfView(fov); + DALI_TEST_EQUALS( actor.GetFieldOfView(), fov, TEST_LOCATION ); + + float value; + actor.GetProperty(CameraActor::FIELD_OF_VIEW).Get(value); + DALI_TEST_EQUALS(fov, value, FLOAT_EPSILON, TEST_LOCATION); + END_TEST; +} + +int UtcDaliCameraActorSetAspectRatio(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CameraActor Get/Set Aspect Ratio"); + + CameraActor actor = CameraActor::New(); + DALI_TEST_EQUALS( actor.GetAspectRatio(), static_cast( TestApplication::DEFAULT_SURFACE_WIDTH ) / static_cast( TestApplication::DEFAULT_SURFACE_HEIGHT ), TEST_LOCATION ); + + float aspect = 16.0f/9.0f; + actor.SetAspectRatio(aspect); + DALI_TEST_EQUALS( actor.GetAspectRatio(), aspect, TEST_LOCATION ); + + float value; + actor.GetProperty(CameraActor::ASPECT_RATIO).Get(value); + DALI_TEST_EQUALS(aspect, value, FLOAT_EPSILON, TEST_LOCATION); + END_TEST; +} + +int UtcDaliCameraActorSetNearClippingPlane(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CameraActor Get/Set Near clipping plane"); + + CameraActor actor = CameraActor::New(); + DALI_TEST_EQUALS( actor.GetNearClippingPlane(), 800.0f, TEST_LOCATION ); + + actor.SetNearClippingPlane(400.0f); + DALI_TEST_EQUALS( actor.GetNearClippingPlane(), 400.0f, TEST_LOCATION ); + + float value; + actor.GetProperty(CameraActor::NEAR_PLANE_DISTANCE).Get(value); + DALI_TEST_EQUALS(400.0f, value, FLOAT_EPSILON, TEST_LOCATION); + END_TEST; +} + +int UtcDaliCameraActorSetFarClippingPlane(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CameraActor Get/Set Far clipping plane"); + + CameraActor actor = CameraActor::New(); + DALI_TEST_EQUALS( actor.GetFarClippingPlane(), 800.0f + (0xFFFF>>4), TEST_LOCATION ); + + actor.SetFarClippingPlane(4000.0f); + DALI_TEST_EQUALS( actor.GetFarClippingPlane(), 4000.0f, TEST_LOCATION ); + + float value; + actor.GetProperty(CameraActor::FAR_PLANE_DISTANCE).Get(value); + DALI_TEST_EQUALS(4000.0f, value, FLOAT_EPSILON, TEST_LOCATION); + END_TEST; +} + +int UtcDaliCameraActorSetTargetPosition(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CameraActor Get/Set Target Position"); + + CameraActor actor = CameraActor::New(); + DALI_TEST_EQUALS( actor.GetTargetPosition(), Vector3::ZERO, TEST_LOCATION ); + + Vector3 target( 10.0f, 20.0f, 30.0f); + actor.SetTargetPosition( target ); + + DALI_TEST_EQUALS( actor.GetTargetPosition(), target, TEST_LOCATION ); + + Vector3 value; + actor.GetProperty(CameraActor::TARGET_POSITION).Get(value); + DALI_TEST_EQUALS(target, value, FLOAT_EPSILON, TEST_LOCATION); + END_TEST; +} + +int UtcDaliCameraActorSetInvertYAxis(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CameraActor Get/Set InvertYAxis"); + + CameraActor actor = CameraActor::New(); + DALI_TEST_EQUALS( actor.GetInvertYAxis(), false, TEST_LOCATION ); + + actor.SetInvertYAxis(true); + + DALI_TEST_EQUALS( actor.GetInvertYAxis(), true, TEST_LOCATION ); + + bool bValue; + actor.GetProperty(CameraActor::INVERT_Y_AXIS).Get(bValue); + DALI_TEST_EQUALS(true, bValue, TEST_LOCATION); + END_TEST; +} + +int UtcDaliCameraActorModelView(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CameraActor Test view application"); + + BitmapImage image = CreateBitmapImage(); + + ImageActor actor = ImageActor::New( image ); + actor.SetSize( 100.0f, 100.0f ); + actor.SetPosition(20.0f, 30.0f, 40.0f); + actor.SetParentOrigin(ParentOrigin::CENTER); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(0); + application.Render(); + application.SendNotification(); + + Matrix resultMatrix(true); + resultMatrix.SetTransformComponents( Vector3::ONE, Quaternion::IDENTITY, actor.GetCurrentPosition()); + + RenderTask task = Stage::GetCurrent().GetRenderTaskList().GetTask(0); + CameraActor cameraActor = task.GetCameraActor(); + + Matrix viewMatrix(false); + cameraActor.GetProperty(CameraActor::VIEW_MATRIX).Get( viewMatrix ); + Matrix::Multiply(resultMatrix, resultMatrix, viewMatrix); + + DALI_TEST_CHECK( application.GetGlAbstraction().CheckUniformValue( "uModelView", resultMatrix ) ); + END_TEST; +} + +int UtcDaliCameraActorSetPerspectiveProjection(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CameraActor::SetPerspectiveProjection( const Size& size )"); + + CameraActor actor = CameraActor::New(); + actor.SetPerspectiveProjection( Size( 100.f, 150.f ) ); + + DALI_TEST_CHECK(actor); + + float value; + actor.GetProperty(CameraActor::ASPECT_RATIO).Get(value); + DALI_TEST_EQUALS(0.666666f, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::FIELD_OF_VIEW).Get(value); + DALI_TEST_EQUALS(0.489957f, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::NEAR_PLANE_DISTANCE).Get(value); + DALI_TEST_EQUALS(150.f, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::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); + + std::string stringValue; + actor.GetProperty(CameraActor::PROJECTION_MODE).Get(stringValue); + DALI_TEST_EQUALS(stringValue, "PERSPECTIVE_PROJECTION", TEST_LOCATION); + END_TEST; +} + +int UtcDaliCameraActorSetOrthographicProjection01(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CameraActor::SetOrthographicProjection01()"); + + CameraActor actor = CameraActor::New(Size(1080.0f, 1920.0f)); + DALI_TEST_CHECK(actor); + + Stage::GetCurrent().Add( actor ); + + actor.SetOrthographicProjection( Size( 1080.0f, 1920.0f ) ); + application.SendNotification(); + application.Render(0); + application.Render(); + application.SendNotification(); + + float defaultAspectRatio; + float defaultFieldOfView; + float defaultNearPlaneDistance; + float defaultFarPlaneDistance; + actor.GetProperty(CameraActor::ASPECT_RATIO).Get(defaultAspectRatio); + actor.GetProperty(CameraActor::FIELD_OF_VIEW).Get(defaultFieldOfView); + actor.GetProperty(CameraActor::NEAR_PLANE_DISTANCE).Get(defaultNearPlaneDistance); + actor.GetProperty(CameraActor::FAR_PLANE_DISTANCE).Get(defaultFarPlaneDistance); + Vector3 defaultPos = actor.GetCurrentPosition(); + + actor.SetOrthographicProjection( Size( 1080.0f, 1920.0f ) ); + + application.SendNotification(); + application.Render(0); + application.Render(); + application.SendNotification(); + + float value; + actor.GetProperty(CameraActor::ASPECT_RATIO).Get(value); + DALI_TEST_EQUALS(defaultAspectRatio, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::FIELD_OF_VIEW).Get(value); + DALI_TEST_EQUALS(defaultFieldOfView, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::NEAR_PLANE_DISTANCE).Get(value); + DALI_TEST_EQUALS(defaultNearPlaneDistance, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::FAR_PLANE_DISTANCE).Get(value); + DALI_TEST_EQUALS(defaultFarPlaneDistance, value, FLOAT_EPSILON, TEST_LOCATION); + + actor.GetProperty(CameraActor::LEFT_PLANE_DISTANCE).Get(value); + DALI_TEST_EQUALS(-540.0f, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::RIGHT_PLANE_DISTANCE).Get(value); + DALI_TEST_EQUALS( 540.0f, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::TOP_PLANE_DISTANCE).Get(value); + DALI_TEST_EQUALS(960.0f, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::BOTTOM_PLANE_DISTANCE).Get(value); + DALI_TEST_EQUALS(-960.0f, value, FLOAT_EPSILON, TEST_LOCATION); + + 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); + END_TEST; +} + + +int UtcDaliCameraActorSetOrthographicProjection02(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CameraActor::SetOrthographicProjection02()"); + + CameraActor actor = CameraActor::New(); + DALI_TEST_CHECK(actor); + + float defaultAspectRatio; + float defaultFieldOfView; + float defaultNearPlaneDistance; + float defaultFarPlaneDistance; + actor.GetProperty(CameraActor::ASPECT_RATIO).Get(defaultAspectRatio); + actor.GetProperty(CameraActor::FIELD_OF_VIEW).Get(defaultFieldOfView); + actor.GetProperty(CameraActor::NEAR_PLANE_DISTANCE).Get(defaultNearPlaneDistance); + actor.GetProperty(CameraActor::FAR_PLANE_DISTANCE).Get(defaultFarPlaneDistance); + + actor.SetOrthographicProjection( -100.0f, 200.0f, -300.0f, 500.0f, 400.0f, 4000.0f ); + + float value; + actor.GetProperty(CameraActor::ASPECT_RATIO).Get(value); + DALI_TEST_EQUALS(defaultAspectRatio, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::FIELD_OF_VIEW).Get(value); + DALI_TEST_EQUALS(defaultFieldOfView, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::NEAR_PLANE_DISTANCE).Get(value); + DALI_TEST_EQUALS(400.0f, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::FAR_PLANE_DISTANCE).Get(value); + DALI_TEST_EQUALS(4000.0f, value, FLOAT_EPSILON, TEST_LOCATION); + + actor.GetProperty(CameraActor::LEFT_PLANE_DISTANCE).Get(value); + DALI_TEST_EQUALS(-100.0f, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::RIGHT_PLANE_DISTANCE).Get(value); + DALI_TEST_EQUALS( 200.0f, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::TOP_PLANE_DISTANCE).Get(value); + DALI_TEST_EQUALS(-300.0f, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::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); + + END_TEST; +} + + +int UtcDaliCameraActorSetOrthographicProjection03(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CameraActor::SetOrthographicProjection03()"); + + CameraActor actor = CameraActor::New(); + DALI_TEST_CHECK(actor); + + float defaultAspectRatio; + float defaultFieldOfView; + float defaultNearPlaneDistance; + float defaultFarPlaneDistance; + actor.GetProperty(CameraActor::ASPECT_RATIO).Get(defaultAspectRatio); + actor.GetProperty(CameraActor::FIELD_OF_VIEW).Get(defaultFieldOfView); + actor.GetProperty(CameraActor::NEAR_PLANE_DISTANCE).Get(defaultNearPlaneDistance); + actor.GetProperty(CameraActor::FAR_PLANE_DISTANCE).Get(defaultFarPlaneDistance); + + actor.SetProjectionMode(Dali::Camera::ORTHOGRAPHIC_PROJECTION); + + actor.SetProperty(CameraActor::LEFT_PLANE_DISTANCE, -100.0f); + actor.SetProperty(CameraActor::RIGHT_PLANE_DISTANCE, 200.0f); + actor.SetProperty(CameraActor::TOP_PLANE_DISTANCE, -300.0f); + actor.SetProperty(CameraActor::BOTTOM_PLANE_DISTANCE, 500.0f); + actor.SetNearClippingPlane( 400.0f ); + actor.SetFarClippingPlane( 4000.0f ); + + float value; + actor.GetProperty(CameraActor::ASPECT_RATIO).Get(value); + DALI_TEST_EQUALS(defaultAspectRatio, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::FIELD_OF_VIEW).Get(value); + DALI_TEST_EQUALS(defaultFieldOfView, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::NEAR_PLANE_DISTANCE).Get(value); + DALI_TEST_EQUALS(400.0f, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::FAR_PLANE_DISTANCE).Get(value); + DALI_TEST_EQUALS(4000.0f, value, FLOAT_EPSILON, TEST_LOCATION); + + actor.GetProperty(CameraActor::LEFT_PLANE_DISTANCE).Get(value); + DALI_TEST_EQUALS(-100.0f, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::RIGHT_PLANE_DISTANCE).Get(value); + DALI_TEST_EQUALS( 200.0f, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::TOP_PLANE_DISTANCE).Get(value); + DALI_TEST_EQUALS(-300.0f, value, FLOAT_EPSILON, TEST_LOCATION); + actor.GetProperty(CameraActor::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); + std::string stringValue; + actor.GetProperty(CameraActor::PROJECTION_MODE).Get(stringValue); + DALI_TEST_EQUALS(stringValue, "ORTHOGRAPHIC_PROJECTION", TEST_LOCATION); + END_TEST; +} + + + +int UtcDaliCameraActorReadProjectionMatrix(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CameraActor::ReadProjectionMatrix()"); + + CameraActor camera = Stage::GetCurrent().GetRenderTaskList().GetTask(0u).GetCameraActor(); + application.SendNotification(); + application.Render(0); + application.Render(); + application.SendNotification(); + Image image = CreateBitmapImage(); + ImageActor imageActor = ImageActor::New( image ); + imageActor.SetSize(100.0f, 100.0f); + Stage::GetCurrent().Add(imageActor); + + Matrix projectionMatrix; + Matrix viewMatrix; + + camera.GetProperty(CameraActor::CameraActor::PROJECTION_MATRIX).Get(projectionMatrix); + camera.GetProperty(CameraActor::CameraActor::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 ); + + 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( projectionMatrixPropertyIndex, Source( camera, CameraActor::PROJECTION_MATRIX ), EqualToConstraint()); + Constraint viewMatrixConstraint = Constraint::New( viewMatrixPropertyIndex, Source( camera, CameraActor::VIEW_MATRIX ), EqualToConstraint()); + + shaderEffect.ApplyConstraint(projectionMatrixConstraint); + shaderEffect.ApplyConstraint(viewMatrixConstraint); + + application.SendNotification(); + application.Render(); + + // Test effects of Constraint. + DALI_TEST_CHECK(application.GetGlAbstraction().CheckUniformValue(SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME.c_str(), projectionMatrix)); + + DALI_TEST_CHECK(application.GetGlAbstraction().CheckUniformValue(SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME.c_str(), viewMatrix)); + END_TEST; +} + +int UtcDaliCameraActorAnimatedProperties(void) +{ + TestApplication application; + tet_infoline("Testing Dali::Internal::CameraActor::GetSceneObjectAnimatableProperty()"); + + CameraActor camera = Stage::GetCurrent().GetRenderTaskList().GetTask(0u).GetCameraActor(); + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + Stage::GetCurrent().Add(actor); + + actor.ApplyConstraint(Constraint::New( Actor::POSITION, Source( camera, Actor::POSITION), EqualToConstraint())); + + camera.SetPosition(100.0f, 200.0f, 300.0f); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(100.0f, 200.0f, 300.0f), TEST_LOCATION); + END_TEST; +} + +int UtcDaliCameraActorPropertyIndices(void) +{ + TestApplication application; + CameraActor camera = Stage::GetCurrent().GetRenderTaskList().GetTask(0u).GetCameraActor(); + + Actor basicActor = Actor::New(); + Property::IndexContainer indices; + camera.GetPropertyIndices( indices ); + DALI_TEST_CHECK( indices.size() > basicActor.GetPropertyCount() ); + DALI_TEST_EQUALS( indices.size(), camera.GetPropertyCount(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliCameraActorCheckLookAtAndFreeLookViews01(void) +{ + TestApplication application; + Stage stage = Stage::GetCurrent(); + Vector2 stageSize = stage.GetSize(); + + CameraActor freeLookCameraActor = CameraActor::New(stageSize); + freeLookCameraActor.SetParentOrigin(ParentOrigin::CENTER); + freeLookCameraActor.SetType(Camera::FREE_LOOK); + + Vector3 targetPosition(30.0f, 240.0f, -256.0f); + Actor target = Actor::New(); + target.SetParentOrigin(ParentOrigin::CENTER); + target.SetPosition(targetPosition); + + Constraint cameraOrientationConstraint = + Constraint::New ( Actor::ROTATION, + Source( target, Actor::WORLD_POSITION ), + Source( freeLookCameraActor, Actor::WORLD_POSITION ), + Source( target, Actor::WORLD_ROTATION ), + &LookAt ); + freeLookCameraActor.ApplyConstraint( cameraOrientationConstraint ); + + CameraActor lookAtCameraActor = CameraActor::New(stageSize); + lookAtCameraActor.SetType(Camera::LOOK_AT_TARGET); + lookAtCameraActor.SetTargetPosition(targetPosition); + lookAtCameraActor.SetParentOrigin(ParentOrigin::CENTER); + + stage.Add(target); + stage.Add(freeLookCameraActor); + stage.Add(lookAtCameraActor); + + // Create an arbitrary vector + for( float x=-1.0f; x<=1.0f; x+=0.1f ) + { + for( float y=-1.0f; y<1.0f; y+=0.1f ) + { + for( float z=-1.0f; z<1.0f; z+=0.1f ) + { + Vector3 position(x, y, z); + position.Normalize(); + position *= 200.0f; + + freeLookCameraActor.SetPosition(position); + lookAtCameraActor.SetPosition(position); + + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + Matrix freeLookViewMatrix; + Matrix lookAtViewMatrix; + freeLookCameraActor.GetProperty(CameraActor::CameraActor::VIEW_MATRIX).Get(freeLookViewMatrix); + lookAtCameraActor.GetProperty(CameraActor::CameraActor::VIEW_MATRIX).Get(lookAtViewMatrix); + + DALI_TEST_EQUALS( freeLookViewMatrix, lookAtViewMatrix, 0.01, TEST_LOCATION ); + } + } + } + END_TEST; +} + +int UtcDaliCameraActorCheckLookAtAndFreeLookViews02(void) +{ + TestApplication application; + Stage stage = Stage::GetCurrent(); + Vector2 stageSize = stage.GetSize(); + + CameraActor freeLookCameraActor = CameraActor::New(stageSize); + freeLookCameraActor.SetParentOrigin(ParentOrigin::CENTER); + freeLookCameraActor.SetType(Camera::FREE_LOOK); + + Vector3 targetPosition(30.0f, 240.0f, -256.0f); + Actor target = Actor::New(); + target.SetParentOrigin(ParentOrigin::CENTER); + target.SetPosition(targetPosition); + + Constraint cameraOrientationConstraint = + Constraint::New ( Actor::ROTATION, + Source( target, Actor::WORLD_POSITION ), + Source( freeLookCameraActor, Actor::WORLD_POSITION ), + Source( target, Actor::WORLD_ROTATION ), + &LookAt ); + freeLookCameraActor.ApplyConstraint( cameraOrientationConstraint ); + + CameraActor lookAtCameraActor = CameraActor::New(stageSize); + lookAtCameraActor.SetType(Camera::LOOK_AT_TARGET); + lookAtCameraActor.SetTargetPosition(targetPosition); + lookAtCameraActor.SetParentOrigin(ParentOrigin::CENTER); + + stage.Add(target); + stage.Add(freeLookCameraActor); + stage.Add(lookAtCameraActor); + + // Create an arbitrary vector + for( float x=-1.0f; x<=1.0f; x+=0.1f ) + { + for( float y=-1.0f; y<1.0f; y+=0.1f ) + { + for( float z=-1.0f; z<1.0f; z+=0.1f ) + { + Vector3 position(x, y, z); + position.Normalize(); + position *= 200.0f; + + freeLookCameraActor.SetPosition(position); + lookAtCameraActor.SetPosition(position); + + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + Matrix freeLookViewMatrix; + Matrix lookAtViewMatrix; + freeLookCameraActor.GetProperty(CameraActor::CameraActor::VIEW_MATRIX).Get(freeLookViewMatrix); + lookAtCameraActor.GetProperty(CameraActor::CameraActor::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; +} + +int UtcDaliCameraActorCheckLookAtAndFreeLookViews03(void) +{ + TestApplication application; + Stage stage = Stage::GetCurrent(); + Vector2 stageSize = stage.GetSize(); + + Vector3 targetPosition(Vector3::ZERO); + + CameraActor lookAtCameraActor = CameraActor::New(stageSize); + lookAtCameraActor.SetType(Camera::LOOK_AT_TARGET); + lookAtCameraActor.SetTargetPosition(targetPosition); + lookAtCameraActor.SetParentOrigin(ParentOrigin::CENTER); + stage.Add(lookAtCameraActor); + + Vector3 cameraOffset( 0.f, 0.f, 100.f ); + + CameraActor freeLookCameraActor = CameraActor::New(stageSize); + freeLookCameraActor.SetType(Camera::FREE_LOOK); + freeLookCameraActor.SetParentOrigin(ParentOrigin::CENTER); + + Quaternion cameraOrientation( Radian(Degree(180.f)), Vector3::YAXIS ); + freeLookCameraActor.SetPosition(cameraOffset); + freeLookCameraActor.SetRotation(cameraOrientation); + + Actor cameraAnchor = Actor::New(); + cameraAnchor.Add(lookAtCameraActor); + stage.Add(cameraAnchor); + + + for( float angle = 1.f; angle <= 180.f; angle += 1.f ) + { + Quaternion rotation(Radian(Degree(angle)), Vector3::YAXIS); + + lookAtCameraActor.SetPosition( rotation.Rotate( cameraOffset ) ); + cameraAnchor.SetRotation( rotation ); + + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + + Matrix freeLookViewMatrix; + freeLookCameraActor.GetProperty(CameraActor::CameraActor::VIEW_MATRIX).Get(freeLookViewMatrix); + + Matrix freeLookWorld = freeLookCameraActor.GetCurrentWorldMatrix(); + + Matrix freeLookTest(false); + Matrix::Multiply( freeLookTest, freeLookViewMatrix, freeLookWorld); + DALI_TEST_EQUALS( freeLookTest, Matrix::IDENTITY, 0.01f, TEST_LOCATION); + } + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Character.cpp b/automated-tests/src/dali/utc-Dali-Character.cpp new file mode 100644 index 0000000..afcca3b --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-Character.cpp @@ -0,0 +1,161 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +using namespace Dali; + +void utc_dali_character_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_character_cleanup(void) +{ + test_return_value = TET_PASS; +} + +int UtcDaliCharacterCopyConstructor(void) +{ + tet_infoline("UtcDaliCharacterCopyConstructor "); + TestApplication application; + + Text text( std::string("12") ); + + Character c1 = text[0]; + Character c2 = text[1]; + + Character c3( c1 ); + Character c4 = c2; + + DALI_TEST_CHECK( (c1==c3) && (c2==c4) ); + END_TEST; +} + +int UtcDaliCharacterComparissonOperators(void) +{ + tet_infoline("UtcDaliCharacterComparissonOperators "); + TestApplication application; + + Text text( std::string("12") ); + + Character c1 = text[0]; + Character c2 = text[1]; + + Character c3( c1 ); + Character c4 = c2; + + DALI_TEST_CHECK( (c1==c3) && (c2==c4) && (c1!=c2) && (c1!=c4) ); + END_TEST; +} + +int UtcDaliCharacterAssignmentOperator(void) +{ + tet_infoline("UtcDaliCharacterAssignmentOperator "); + TestApplication application; + + Text text( std::string("12") ); + Character c1 = text[0]; + Character c2 = text[1]; + c1 = c2; //assign + DALI_TEST_CHECK( c1 == c1); + + // this should do nothing + c1 = c1; + DALI_TEST_CHECK( c1 == c2); + + END_TEST; +} + +int UtcDaliCharacterIsLeftToRight(void) +{ + tet_infoline("UtcDaliCharacterIsLeftToRight "); + TestApplication application; + + Text text( std::string("12בא") ); + + Character c1 = text[0]; + Character c2 = text[1]; + Character c3 = text[2]; + Character c4 = text[3]; + + DALI_TEST_CHECK( c1.GetCharacterDirection() != Character::RightToLeft && + c2.GetCharacterDirection() != Character::RightToLeft && + c3.GetCharacterDirection() == Character::RightToLeft && + c4.GetCharacterDirection() == Character::RightToLeft ); + END_TEST; +} + +int UtcDaliGetCharacterDirection(void) +{ + tet_infoline("UtcDaliGetCharacterDirection "); + TestApplication application; + + Text text( std::string("Aבא ") ); + + Character c1 = text[0]; + Character c2 = text[1]; + Character c3 = text[2]; + Character c4 = text[3]; + + DALI_TEST_EQUALS( c1.GetCharacterDirection(), Character::LeftToRight, TEST_LOCATION ); + DALI_TEST_EQUALS( c2.GetCharacterDirection(), Character::RightToLeft, TEST_LOCATION ); + DALI_TEST_EQUALS( c3.GetCharacterDirection(), Character::RightToLeft, TEST_LOCATION ); + DALI_TEST_EQUALS( c4.GetCharacterDirection(), Character::Neutral, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliCharacterIsWhiteSpace(void) +{ + tet_infoline("UtcDaliCharacterIsWhiteSpace "); + TestApplication application; + + Text text( std::string("ab c\n\tdef") ); + + DALI_TEST_CHECK(!text[0].IsWhiteSpace()); // 'a' + DALI_TEST_CHECK(!text[1].IsWhiteSpace()); // 'b' + DALI_TEST_CHECK(text[2].IsWhiteSpace()); // ' ' + DALI_TEST_CHECK(!text[3].IsWhiteSpace()); // 'c' + DALI_TEST_CHECK(text[4].IsWhiteSpace()); // '\n' + DALI_TEST_CHECK(text[5].IsWhiteSpace()); // '\t' + DALI_TEST_CHECK(!text[6].IsWhiteSpace()); // 'd' + DALI_TEST_CHECK(!text[7].IsWhiteSpace()); // 'e' + DALI_TEST_CHECK(!text[8].IsWhiteSpace()); // 'f' + END_TEST; +} + +int UtcDaliCharacterIsNewLine(void) +{ + tet_infoline("UtcDaliCharacterIsWhiteSpace "); + TestApplication application; + + Text text( std::string("ab c\n\tdef") ); + + DALI_TEST_CHECK(!text[0].IsNewLine()); // 'a' + DALI_TEST_CHECK(!text[1].IsNewLine()); // 'b' + DALI_TEST_CHECK(!text[2].IsNewLine()); // ' ' + DALI_TEST_CHECK(!text[3].IsNewLine()); // 'c' + DALI_TEST_CHECK( text[4].IsNewLine()); // '\n' + DALI_TEST_CHECK(!text[5].IsNewLine()); // '\t' + DALI_TEST_CHECK(!text[6].IsNewLine()); // 'd' + DALI_TEST_CHECK(!text[7].IsNewLine()); // 'e' + DALI_TEST_CHECK(!text[8].IsNewLine()); // 'f' + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Constraint.cpp b/automated-tests/src/dali/utc-Dali-Constraint.cpp new file mode 100644 index 0000000..978941f --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-Constraint.cpp @@ -0,0 +1,4028 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +using namespace Dali; + +void utc_dali_constraint_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_constraint_cleanup(void) +{ + test_return_value = TET_PASS; +} + + +namespace +{ + +struct EqualToQuaternion +{ + EqualToQuaternion() + { + } + + Quaternion operator()( const Quaternion& current, const PropertyInput& property ) + { + return property.GetQuaternion(); + } +}; + +struct EqualToVector4 +{ + EqualToVector4() + { + } + + Vector4 operator()( const Vector4& current, const PropertyInput& property ) + { + return property.GetVector4(); + } +}; + +class PropertyInputAbstraction : public Dali::PropertyInput +{ +public: + PropertyInputAbstraction(const bool& val) : mType(Dali::Property::BOOLEAN), mBoolData( val ) {} + PropertyInputAbstraction(const float& val) : mType(Dali::Property::FLOAT), mFloatData( val ) {} + PropertyInputAbstraction(const Vector2& val) : mType(Dali::Property::VECTOR2), mVector2Data( val ) {} + PropertyInputAbstraction(const Vector3& val) : mType(Dali::Property::VECTOR3), mVector3Data( val ) {} + PropertyInputAbstraction(const Vector4& val) : mType(Dali::Property::VECTOR4), mVector4Data( val ) {} + PropertyInputAbstraction(const Matrix3& val) : mType(Dali::Property::MATRIX3), mMatrix3Data( val ) {} + PropertyInputAbstraction(const Matrix& val) : mType(Dali::Property::MATRIX), mMatrixData( val ) {} + PropertyInputAbstraction(const Quaternion& val) : mType(Dali::Property::ROTATION), mQuaternionData( val ) {} + + ~PropertyInputAbstraction() {} + + Dali::Property::Type GetType() const { return mType; } + + const bool& GetBoolean() const { return mBoolData; } + + const float& GetFloat() const { return mFloatData; } + + const Vector2& GetVector2() const { return mVector2Data; } + const Vector3& GetVector3() const { return mVector3Data; } + const Vector4& GetVector4() const { return mVector4Data; } + + const Matrix3& GetMatrix3() const { return mMatrix3Data; } + const Matrix& GetMatrix() const { return mMatrixData; } + + const Quaternion& GetQuaternion() const { return mQuaternionData; } + +private: + Dali::Property::Type mType; + bool mBoolData; + float mFloatData; + Vector2 mVector2Data; + Vector3 mVector3Data; + Vector4 mVector4Data; + Matrix3 mMatrix3Data; + Matrix mMatrixData; + Quaternion mQuaternionData; +}; + +static const float POSITION_EPSILON = 0.0001f; +static const float ROTATION_EPSILON = 0.0001f; + +struct TestConstraint +{ + Vector4 operator()(const Vector4& color) + { + return Vector4(color.x, color.y, color.z, 0.1f); + } +}; + +struct TestConstraintToVector3 +{ + TestConstraintToVector3(Vector3 target) + : mTarget(target) + { + } + + Vector3 operator()(const Vector3& current) + { + return mTarget; + } + + Vector3 mTarget; +}; + +struct TestColorConstraint +{ + TestColorConstraint(Vector4 target) + : mTarget(target) + { + } + + Vector4 operator()(const Vector4& color) + { + return mTarget; + } + + Vector4 mTarget; +}; + +struct TestPositionConstraint +{ + TestPositionConstraint(Vector3 target) + : mTarget(target) + { + } + + Vector3 operator()(const Vector3& position) + { + return mTarget; + } + + Vector3 mTarget; +}; + + +struct TestAlwaysTrueConstraint +{ + bool operator()( const bool& current ) + { + return true; + } +}; + +struct TestAlwaysEqualOrGreaterThanConstraint +{ + TestAlwaysEqualOrGreaterThanConstraint( float value ) + : mValue( value ) + { + } + + float operator()( const float& current ) + { + return ( current < mValue ) ? mValue : current; + } + + float mValue; +}; + +struct TestAlwaysEqualOrGreaterThanConstraintVector2 +{ + TestAlwaysEqualOrGreaterThanConstraintVector2( Vector2 value ) + : mValue( value ) + { + } + + Vector2 operator()( const Vector2& current ) + { + return Vector2( ( current.x < mValue.x ) ? mValue.x : current.x, + ( current.y < mValue.y ) ? mValue.y : current.y + ); + } + + Vector2 mValue; +}; + +struct TestAlwaysEqualOrGreaterThanConstraintVector3 +{ + TestAlwaysEqualOrGreaterThanConstraintVector3( Vector3 value ) + : mValue( value ) + { + } + + Vector3 operator()( const Vector3& current ) + { + return Vector3( ( current.x < mValue.x ) ? mValue.x : current.x, + ( current.y < mValue.y ) ? mValue.y : current.y, + ( current.z < mValue.z ) ? mValue.z : current.z + ); + } + + Vector3 mValue; +}; + +struct TestAlwaysEqualOrGreaterThanConstraintVector4 +{ + TestAlwaysEqualOrGreaterThanConstraintVector4( Vector4 value ) + : mValue( value ) + { + } + + Vector4 operator()( const Vector4& current ) + { + return Vector4( ( current.x < mValue.x ) ? mValue.x : current.x, + ( current.y < mValue.y ) ? mValue.y : current.y, + ( current.z < mValue.z ) ? mValue.z : current.z, + ( current.w < mValue.w ) ? mValue.w : current.w + ); + } + + Vector4 mValue; +}; + +struct TestConstraintFloat +{ + TestConstraintFloat( float value ) + : mValue( value ) + { + } + + float operator()( const float& current ) + { + return mValue; + } + + float mValue; +}; + +struct TestConstraintVector2 +{ + TestConstraintVector2( Vector2 value ) + : mValue( value ) + { + } + + Vector2 operator()( const Vector2& current ) + { + return mValue; + } + + Vector2 mValue; +}; + +struct TestConstraintVector3 +{ + TestConstraintVector3( Vector3 value ) + : mValue( value ) + { + } + + Vector3 operator()( const Vector3& current ) + { + return mValue; + } + + Vector3 mValue; +}; + +struct TestConstraintVector4 +{ + TestConstraintVector4( Vector4 value ) + : mValue( value ) + { + } + + Vector4 operator()( const Vector4& current ) + { + return mValue; + } + + Vector4 mValue; +}; + +struct TestConstraintRotation +{ + TestConstraintRotation( Quaternion rotation ) + : mRotation( rotation ) + { + } + + Quaternion operator()( const Quaternion& current ) + { + return mRotation; + } + + Quaternion mRotation; +}; + +struct TestConstraintMatrix3 +{ + TestConstraintMatrix3(Matrix3 matrix3) + : mMatrix3( matrix3 ) + { + } + + Matrix3 operator()( const Matrix3& current ) + { + return mMatrix3; + } + + Matrix3 mMatrix3; +}; + +struct TestConstraintMatrix +{ + TestConstraintMatrix(Matrix matrix) + : mMatrix( matrix ) + { + } + + Matrix operator()( const Matrix& current ) + { + return mMatrix; + } + + Matrix mMatrix; +}; + +struct MoveAwayWithFadeConstraint +{ + MoveAwayWithFadeConstraint( float distance ) + : mDistance( distance ) + { + } + + Vector3 operator()( const Vector3& current, + const PropertyInput& color ) + { + return Vector3( current.x, + current.y, + -mDistance * (1.0f - color.GetVector4().a) ); + } + + float mDistance; +}; + +struct TestBottomRightAlignConstraint +{ + Vector3 operator()( const Vector3& current, + const PropertyInput& parentSize ) + { + return Vector3( parentSize.GetVector3().x, parentSize.GetVector3().y, 0.0f ); + } +}; + +struct MeanPositionConstraint1 +{ + Vector3 operator()( const Vector3& current, + const PropertyInput& position1 ) + { + return Vector3( position1.GetVector3() ); + } +}; + +struct MeanPositionConstraint2 +{ + Vector3 operator()( const Vector3& current, + const PropertyInput& position1, + const PropertyInput& position2 ) + { + Vector3 meanValue = position1.GetVector3() + + position2.GetVector3(); + + return meanValue * 0.5f; // div 2 + } +}; + +struct MeanPositionConstraint3 +{ + Vector3 operator()( const Vector3& current, + const PropertyInput& position1, + const PropertyInput& position2, + const PropertyInput& position3 ) + { + Vector3 meanValue = position1.GetVector3() + + position2.GetVector3() + + position3.GetVector3(); + + return meanValue * (1.0f / 3.0f); // div 3 + } +}; + +struct MeanPositionConstraint4 +{ + Vector3 operator()( const Vector3& current, + const PropertyInput& position1, + const PropertyInput& position2, + const PropertyInput& position3, + const PropertyInput& position4 ) + { + Vector3 meanValue = position1.GetVector3() + + position2.GetVector3() + + position3.GetVector3() + + position4.GetVector3(); + + return meanValue * 0.25f; // div 4 + } +}; + +struct MeanPositionConstraint5 +{ + Vector3 operator()( const Vector3& current, + const PropertyInput& position1, + const PropertyInput& position2, + const PropertyInput& position3, + const PropertyInput& position4, + const PropertyInput& position5 ) + { + Vector3 meanValue = position1.GetVector3() + + position2.GetVector3() + + position3.GetVector3() + + position4.GetVector3() + + position5.GetVector3(); + + return meanValue * 0.2f; // div 5 + } +}; + +struct MeanPositionConstraint6 +{ + Vector3 operator()( const Vector3& current, + const PropertyInput& position1, + const PropertyInput& position2, + const PropertyInput& position3, + const PropertyInput& position4, + const PropertyInput& position5, + const PropertyInput& position6 ) + { + Vector3 meanValue = position1.GetVector3() + + position2.GetVector3() + + position3.GetVector3() + + position4.GetVector3() + + position5.GetVector3() + + position6.GetVector3(); + + return meanValue * (1.0f / 6.0f); // div 6 + } +}; + +struct TestRelativeConstraintFloat +{ + TestRelativeConstraintFloat(float scale) + : mScale(scale) + { + } + + float operator()( const float& current, const PropertyInput& relative ) + { + return relative.GetFloat() * mScale; + } + + float mScale; +}; + +struct TestRelativeConstraintVector3 +{ + TestRelativeConstraintVector3(float scale) + : mScale(scale) + { + } + + Vector3 operator()( const Vector3& current, const PropertyInput& relative ) + { + return relative.GetVector3() * mScale; + } + + float mScale; +}; + +} // anonymous namespace + + + + + + +int UtcDaliConstraintNewBoolean(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a boolean property + bool startValue(false); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + /** + * Test that the Constraint is correctly applied on a clean Node + */ + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + // Apply constraint + + Constraint constraint = Constraint::New( index, TestAlwaysTrueConstraint() ); + + actor.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( actor.GetProperty(index), false, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + DALI_TEST_EQUALS( actor.GetProperty(index), true, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), true, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), true, TEST_LOCATION ); + + // Try to fight with the constraint - this shouldn't work! + actor.SetProperty( index, false ); + + application.SendNotification(); + application.Render(0); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), true, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), true, TEST_LOCATION ); + + // Remove the constraint, then set new value + actor.RemoveConstraints(); + actor.SetProperty( index, false ); + + // Constraint should have been removed + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), false, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), false, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintNewFloat(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a float property + float startValue(1.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + /** + * Test that the Constraint is correctly applied on a clean Node + */ + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + // Apply constraint + + float minValue( 2.0f ); + Constraint constraint = Constraint::New( index, TestAlwaysEqualOrGreaterThanConstraint( minValue ) ); + + actor.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + + // Set to greater than 2.0f, the constraint will allow this + actor.SetProperty( index, 3.0f ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( actor.GetProperty(index), 3.0f, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), 3.0f, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), 3.0f, TEST_LOCATION ); + + // Set to less than 2.0f, the constraint will NOT allow this + actor.SetProperty( index, 1.0f ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( actor.GetProperty(index), minValue/*not 1.0f*/, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + + // Remove the constraint, then set new value + actor.RemoveConstraints(); + actor.SetProperty( index, 1.0f ); + + // Constraint should have been removed + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), 1.0f, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), 1.0f, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintNewVector2(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector2 property + Vector2 startValue( 1.0f, 1.0f ); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + /** + * Test that the Constraint is correctly applied on a clean Node + */ + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + // Apply constraint + + Vector2 minValue( 2.0f, 2.0f ); + Constraint constraint = Constraint::New( index, TestAlwaysEqualOrGreaterThanConstraintVector2( minValue ) ); + + actor.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + + // Set to greater than 2.0f, the constraint will allow this + Vector2 greaterValue( 3.0f, 3.0f ); + actor.SetProperty( index, greaterValue ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( actor.GetProperty(index), greaterValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), greaterValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), greaterValue, TEST_LOCATION ); + + // Set to less than 2.0f, the constraint will NOT allow this + Vector2 lesserValue( 1.0f, 1.0f ); + actor.SetProperty( index, lesserValue ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( actor.GetProperty(index), minValue/*not lesserValue*/, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + + // Remove the constraint, then set new value + actor.RemoveConstraints(); + actor.SetProperty( index, lesserValue ); + + // Constraint should have been removed + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), lesserValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), lesserValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintNewVector3(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector3 property + Vector3 startValue(1.0f, 1.0f, 1.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + /** + * Test that the Constraint is correctly applied on a clean Node + */ + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + // Apply constraint + + Vector3 minValue( 2.0f, 2.0f, 2.0f ); + Constraint constraint = Constraint::New( index, TestAlwaysEqualOrGreaterThanConstraintVector3( minValue ) ); + + actor.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + + // Set to greater than 2.0f, the constraint will allow this + Vector3 greaterValue( 3.0f, 3.0f, 3.0f ); + actor.SetProperty( index, greaterValue ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( actor.GetProperty(index), greaterValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), greaterValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), greaterValue, TEST_LOCATION ); + + // Set to less than 2.0f, the constraint will NOT allow this + Vector3 lesserValue( 1.0f, 1.0f, 1.0f ); + actor.SetProperty( index, lesserValue ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( actor.GetProperty(index), minValue/*not lesserValue*/, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + + // Remove the constraint, then set new value + actor.RemoveConstraints(); + actor.SetProperty( index, lesserValue ); + + // Constraint should have been removed + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), lesserValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), lesserValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintNewVector4(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector4 property + Vector4 startValue( 1.0f, 1.0f, 1.0f, 1.0f ); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + /** + * Test that the Constraint is correctly applied on a clean Node + */ + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + application.Render(0); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + // Apply constraint + + Vector4 minValue( 2.0f, 2.0f, 2.0f, 2.0f ); + Constraint constraint = Constraint::New( index, TestAlwaysEqualOrGreaterThanConstraintVector4( minValue ) ); + + actor.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + + // Set to greater than 2.0f, the constraint will allow this + Vector4 greaterValue( 3.0f, 3.0f, 3.0f, 3.0f ); + actor.SetProperty( index, greaterValue ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( actor.GetProperty(index), greaterValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), greaterValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), greaterValue, TEST_LOCATION ); + + // Set to less than 2.0f, the constraint will NOT allow this + Vector4 lesserValue( 1.0f, 1.0f, 1.0f, 1.0f ); + actor.SetProperty( index, lesserValue ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( actor.GetProperty(index), minValue/*not lesserValue*/, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), minValue, TEST_LOCATION ); + + // Remove the constraint, then set new value + actor.RemoveConstraints(); + actor.SetProperty( index, lesserValue ); + + // Constraint should have been removed + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), lesserValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), lesserValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintNewMatrix(void) +{ + try + { + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Matrix property + Matrix startValue = Matrix::IDENTITY; + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + DALI_TEST_CHECK( index != Property::INVALID_INDEX ); + if (index != Property::INVALID_INDEX) + { + Stage::GetCurrent().Add(actor); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + // Apply constraint + Matrix constraintLimit; + constraintLimit.SetTransformComponents(Vector3::ONE, Quaternion(Radian(Degree(30.0f)), Vector3::YAXIS), Vector3::ZAXIS ); + Constraint constraint = Constraint::New( index, TestConstraintMatrix(constraintLimit)); + actor.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( actor.GetProperty(index), constraintLimit, TEST_LOCATION ); + } + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_CHECK(0); + } + END_TEST; +} + +int UtcDaliConstraintNewMatrix3(void) +{ + try + { + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Matrix3 property + Matrix3 startValue(1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + DALI_TEST_CHECK( index != Property::INVALID_INDEX ); + if (index != Property::INVALID_INDEX) + { + Stage::GetCurrent().Add(actor); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + // Apply constraint + Matrix3 constraintLimit(42.0f, 0.0f, 0.0f, 0.0f, 42.0f, 0.0f, 0.0f, 0.0f, 1.0f); + Constraint constraint = Constraint::New( index, TestConstraintMatrix3(constraintLimit)); + actor.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, 0.001f, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( actor.GetProperty(index), constraintLimit, 0.001f, TEST_LOCATION ); + } + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); + DALI_TEST_CHECK(0); + } + END_TEST; +} + +int UtcDaliConstraintNewQuaternion(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Quaternion property + Quaternion startValue( 0.0f, Vector3::YAXIS ); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, ROTATION_EPSILON, TEST_LOCATION ); + + /** + * Test that the Constraint is correctly applied on a clean Node + */ + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, ROTATION_EPSILON, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, ROTATION_EPSILON, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, ROTATION_EPSILON, TEST_LOCATION ); + + // Apply constraint + + Quaternion constrainedRotation( M_PI*0.25f, Vector3::YAXIS ); + Constraint constraint = Constraint::New( index, TestConstraintRotation( constrainedRotation ) ); + + actor.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, ROTATION_EPSILON, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION ); + + // Set to a different rotation, the constraint will NOT allow this + Quaternion differentRotation( M_PI*0.5f, Vector3::YAXIS ); + actor.SetProperty( index, differentRotation ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedRotation/*not differentRotation*/, ROTATION_EPSILON, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION ); + + // Remove the constraint, then set new value + actor.RemoveConstraints(); + actor.SetProperty( index, differentRotation ); + + // Constraint should have been removed + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), differentRotation, ROTATION_EPSILON, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), differentRotation, ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintNewOffStageBoolean(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a boolean property + bool startValue(false); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + // Apply constraint to off-stage Actor + Constraint constraint = Constraint::New( index, TestAlwaysTrueConstraint() ); + actor.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), false, TEST_LOCATION ); + + // Add actor to stage + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + DALI_TEST_EQUALS( actor.GetProperty(index), true, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), true, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), true, TEST_LOCATION ); + + // Take the actor off-stage + Stage::GetCurrent().Remove(actor); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), true, TEST_LOCATION ); + + // Set a new value; the constraint will not prevent this + actor.SetProperty( index, false ); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), false, TEST_LOCATION ); + + // Add actor to stage (2nd time) + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied (2nd time) + DALI_TEST_EQUALS( actor.GetProperty(index), true, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), true, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), true, TEST_LOCATION ); + + // Take the actor off-stage (2nd-time) + Stage::GetCurrent().Remove(actor); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), true, TEST_LOCATION ); + + // Remove the constraint, and set a new value + actor.RemoveConstraints(); + actor.SetProperty( index, false ); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), false, TEST_LOCATION ); + + // Add actor to stage (3rd time) + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + + // Constraint should be gone + DALI_TEST_EQUALS( actor.GetProperty(index), false, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), false, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), false, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintNewOffStageFloat(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a float property + float startValue(1.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + // Apply constraint to off-stage Actor + float constrainedValue( 2.0f ); + Constraint constraint = Constraint::New( index, TestConstraintFloat( constrainedValue ) ); + actor.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Add actor to stage + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Take the actor off-stage + Stage::GetCurrent().Remove(actor); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Set back to startValue; the constraint will not prevent this + actor.SetProperty( index, startValue ); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Add actor to stage (2nd time) + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied (2nd time) + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Take the actor off-stage (2nd-time) + Stage::GetCurrent().Remove(actor); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Remove the constraint, and set back to startValue + actor.RemoveConstraints(); + actor.SetProperty( index, startValue ); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Add actor to stage (3rd time) + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + + // Constraint should be gone + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintNewOffStageVector2(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector2 property + Vector2 startValue(1.0f, 1.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + // Apply constraint to off-stage Actor + Vector2 constrainedValue( 2.0f, 2.0f ); + Constraint constraint = Constraint::New( index, TestConstraintVector2( constrainedValue ) ); + actor.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Add actor to stage + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Take the actor off-stage + Stage::GetCurrent().Remove(actor); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Set back to startValue; the constraint will not prevent this + actor.SetProperty( index, startValue ); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Add actor to stage (2nd time) + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied (2nd time) + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Take the actor off-stage (2nd-time) + Stage::GetCurrent().Remove(actor); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Remove the constraint, and set back to startValue + actor.RemoveConstraints(); + actor.SetProperty( index, startValue ); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Add actor to stage (3rd time) + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + + // Constraint should be gone + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintNewOffStageVector3(void) +{ + TestApplication application; + Vector3 startValue(1.0f, 1.0f, 1.0f); + Vector3 constrainedValue = Vector3( 2.0f, 3.0f, 4.0f ); + + Actor actor = Actor::New(); + // Register a Vector3 property + + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + // Apply constraint to off-stage Actor + Constraint constraint = Constraint::New( index, TestConstraintVector3( constrainedValue ) ); + actor.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Add actor to stage + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(); + + // Constraint should be fully applied + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + application.Render(); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Take the actor off-stage + Stage::GetCurrent().Remove(actor); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Set back to startValue; the constraint will not prevent this + Vector3 intermediateValue(5.0f, 6.0f, 7.0f); + actor.SetProperty( index, intermediateValue ); + application.SendNotification(); + application.Render(); + application.Render(); // ensure both buffers are set to intermediateValue + DALI_TEST_EQUALS( actor.GetProperty(index), intermediateValue, TEST_LOCATION ); + + // Add actor to stage (2nd time) + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(); + + // Constraint should be fully applied (2nd time) + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + application.Render(); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Take the actor off-stage (2nd-time) + Stage::GetCurrent().Remove(actor); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Remove the constraint, and set back to startValue + actor.RemoveConstraints(); + actor.SetProperty( index, startValue ); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Add actor to stage (3rd time) + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(); + + // Constraint should be gone + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + application.Render(); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintNewOffStageVector4(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Vector4 property + Vector4 startValue(1.0f, 1.0f, 1.0f, 1.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); + + // Apply constraint to off-stage Actor + Vector4 constrainedValue( 2.0f, 2.0f, 2.0f, 2.0f ); + Constraint constraint = Constraint::New( index, TestConstraintVector4( constrainedValue ) ); + actor.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Add actor to stage + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Take the actor off-stage + Stage::GetCurrent().Remove(actor); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Set back to startValue; the constraint will not prevent this + actor.SetProperty( index, startValue ); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Add actor to stage (2nd time) + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied (2nd time) + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Take the actor off-stage (2nd-time) + Stage::GetCurrent().Remove(actor); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedValue, TEST_LOCATION ); + + // Remove the constraint, and set back to startValue + actor.RemoveConstraints(); + actor.SetProperty( index, startValue ); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Add actor to stage (3rd time) + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + + // Constraint should be gone + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintNewOffStageQuaternion(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a Quaternion property + Quaternion startValue( 0.0f, Vector3::YAXIS ); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, ROTATION_EPSILON, TEST_LOCATION ); + + // Apply constraint to off-stage Actor + Quaternion constrainedRotation( M_PI*0.25f, Vector3::YAXIS ); + Constraint constraint = Constraint::New( index, TestConstraintRotation( constrainedRotation ) ); + actor.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, ROTATION_EPSILON, TEST_LOCATION ); + + // Add actor to stage + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION ); + + // Take the actor off-stage + Stage::GetCurrent().Remove(actor); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION ); + + // Set back to startValue; the constraint will not prevent this + actor.SetProperty( index, startValue ); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, ROTATION_EPSILON, TEST_LOCATION ); + + // Add actor to stage (2nd time) + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied (2nd time) + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION ); + + // Take the actor off-stage (2nd-time) + Stage::GetCurrent().Remove(actor); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), constrainedRotation, ROTATION_EPSILON, TEST_LOCATION ); + + // Remove the constraint, and set back to startValue + actor.RemoveConstraints(); + actor.SetProperty( index, startValue ); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, ROTATION_EPSILON, TEST_LOCATION ); + + // Add actor to stage (3rd time) + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(0); + + // Constraint should be gone + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, ROTATION_EPSILON, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, ROTATION_EPSILON, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, ROTATION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintNewLocalInput(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + Vector3 startValue( 0.0f, 0.0f, 0.0f ); + float distanceWhenFullyTransparent( 100.0f ); + + /** + * Test that the Constraint is correctly applied on a clean Node + */ + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + + // Apply constraint with a local input property + + Constraint constraint = Constraint::New( Actor::POSITION, + LocalSource( Actor::COLOR ), + MoveAwayWithFadeConstraint(distanceWhenFullyTransparent) ); + + actor.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + + // Gradually set the color to fully-transparent; the actor should move back + + for ( float progress = 0.0f; progress < 1.1f; progress += 0.1f ) + { + actor.SetOpacity( 1.0f - progress ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), ( startValue - Vector3(0.0f, 0.0f, progress*distanceWhenFullyTransparent) ), POSITION_EPSILON, TEST_LOCATION ); + } + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), ( startValue - Vector3(0.0f, 0.0f, distanceWhenFullyTransparent) ), POSITION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintNewParentInput(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Vector3 parentStartSize( 100.0f, 100.0f, 0.0f ); + parent.SetSize( parentStartSize ); + Stage::GetCurrent().Add( parent ); + + Actor actor = Actor::New(); + parent.Add( actor ); + + Vector3 startValue( 0.0f, 0.0f, 0.0f ); + + /** + * Test that the Constraint is correctly applied on a clean Node + */ + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + + // Apply constraint with a parent input property + + Constraint constraint = Constraint::New( Actor::POSITION, + ParentSource( Actor::SIZE ), + TestBottomRightAlignConstraint() ); + + actor.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), parentStartSize, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), parent.GetCurrentSize(), TEST_LOCATION ); + + // Gradually shrink the parent; the actor should move inwards + + for ( float progress = 0.0f; progress < 1.1f; progress += 0.1f ) + { + Vector3 size( parentStartSize * std::max(0.0f, 1.0f - progress) ); + parent.SetSize( size ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), size, POSITION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), parent.GetCurrentSize(), POSITION_EPSILON, TEST_LOCATION ); + } + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), Vector3::ZERO, POSITION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintNewInput1(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Vector3 parentStartSize( 100.0f, 100.0f, 0.0f ); + parent.SetSize( parentStartSize ); + Stage::GetCurrent().Add( parent ); + + Actor actor = Actor::New(); + parent.Add( actor ); + + Actor sibling1 = Actor::New(); + sibling1.SetPosition( Vector3(1.0f, 2.0f, 3.0f) ); + parent.Add( sibling1 ); + + Vector3 startValue( 0.0f, 0.0f, 0.0f ); + + /** + * Test that the Constraint is correctly applied on a clean Node + */ + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + + // Apply constraint with a parent input property + + Constraint constraint = Constraint::New( Actor::POSITION, + Source( sibling1, Actor::POSITION ), + MeanPositionConstraint1() ); + + actor.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), sibling1.GetCurrentPosition(), TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), sibling1.GetCurrentPosition(), TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), sibling1.GetCurrentPosition(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintNewInput2(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Vector3 parentStartSize( 100.0f, 100.0f, 0.0f ); + parent.SetSize( parentStartSize ); + Stage::GetCurrent().Add( parent ); + + Actor actor = Actor::New(); + parent.Add( actor ); + + Actor sibling1 = Actor::New(); + sibling1.SetPosition( Vector3(1.0f, 2.0f, 3.0f) ); + parent.Add( sibling1 ); + + Actor sibling2 = Actor::New(); + sibling2.SetPosition( Vector3(300.0f, 300.0f, 300.0f) ); + parent.Add( sibling2 ); + + application.SendNotification(); + application.Render(0); + + Vector3 startValue( 0.0f, 0.0f, 0.0f ); + Vector3 meanValue = sibling1.GetCurrentPosition() + + sibling2.GetCurrentPosition(); + meanValue *= (1.0f / 2.0f); // divide by number of siblings + + /** + * Test that the Constraint is correctly applied on a clean Node + */ + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + + // Apply constraint with a parent input property + + Constraint constraint = Constraint::New( Actor::POSITION, + Source( sibling1, Actor::POSITION ), + Source( sibling2, Actor::POSITION ), + MeanPositionConstraint2() ); + + actor.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintNewInput3(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Vector3 parentStartSize( 100.0f, 100.0f, 0.0f ); + parent.SetSize( parentStartSize ); + Stage::GetCurrent().Add( parent ); + + Actor actor = Actor::New(); + parent.Add( actor ); + + Actor sibling1 = Actor::New(); + sibling1.SetPosition( Vector3(1.0f, 2.0f, 3.0f) ); + parent.Add( sibling1 ); + + Actor sibling2 = Actor::New(); + sibling2.SetPosition( Vector3(300.0f, 300.0f, 300.0f) ); + parent.Add( sibling2 ); + + Actor sibling3 = Actor::New(); + sibling3.SetPosition( Vector3(-100.0f, -10.0f, -1.0f) ); + parent.Add( sibling3 ); + + application.SendNotification(); + application.Render(0); + + Vector3 startValue( 0.0f, 0.0f, 0.0f ); + Vector3 meanValue = sibling1.GetCurrentPosition() + + sibling2.GetCurrentPosition() + + sibling3.GetCurrentPosition(); + meanValue *= (1.0f / 3.0f); // divide by number of siblings + + /** + * Test that the Constraint is correctly applied on a clean Node + */ + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + + // Apply constraint with a parent input property + + Constraint constraint = Constraint::New( Actor::POSITION, + Source( sibling1, Actor::POSITION ), + Source( sibling2, Actor::POSITION ), + Source( sibling3, Actor::POSITION ), + MeanPositionConstraint3() ); + + actor.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintNewInput4(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Vector3 parentStartSize( 100.0f, 100.0f, 0.0f ); + parent.SetSize( parentStartSize ); + parent.SetPosition( 10.0f, 10.0f, 10.0f ); + Stage::GetCurrent().Add( parent ); + + Actor actor = Actor::New(); + parent.Add( actor ); + + Actor sibling1 = Actor::New(); + sibling1.SetPosition( Vector3(1.0f, 2.0f, 3.0f) ); + parent.Add( sibling1 ); + + Actor sibling2 = Actor::New(); + sibling2.SetPosition( Vector3(300.0f, 300.0f, 300.0f) ); + parent.Add( sibling2 ); + + Actor sibling3 = Actor::New(); + sibling3.SetPosition( Vector3(-100.0f, -10.0f, -1.0f) ); + parent.Add( sibling3 ); + + application.SendNotification(); + application.Render(0); + + Vector3 startValue( 0.0f, 0.0f, 0.0f ); + Vector3 meanValue = parent.GetCurrentPosition() + + sibling1.GetCurrentPosition() + + sibling2.GetCurrentPosition() + + sibling3.GetCurrentPosition(); + meanValue *= (1.0f / 4.0f); // divide by number of positions + + /** + * Test that the Constraint is correctly applied on a clean Node + */ + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + + // Apply constraint with a parent input property + + Constraint constraint = Constraint::New( Actor::POSITION, + Source( sibling1, Actor::POSITION ), + Source( sibling2, Actor::POSITION ), + ParentSource( Actor::POSITION ), + Source( sibling3, Actor::POSITION ), + MeanPositionConstraint4() ); + + actor.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintNewInput5(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Vector3 parentStartSize( 100.0f, 100.0f, 0.0f ); + parent.SetSize( parentStartSize ); + parent.SetPosition( 10.0f, 10.0f, 10.0f ); + Stage::GetCurrent().Add( parent ); + + Actor actor = Actor::New(); + parent.Add( actor ); + + Actor sibling1 = Actor::New(); + sibling1.SetPosition( Vector3(1.0f, 2.0f, 3.0f) ); + parent.Add( sibling1 ); + + Actor sibling2 = Actor::New(); + sibling2.SetPosition( Vector3(300.0f, 300.0f, 300.0f) ); + parent.Add( sibling2 ); + + Actor sibling3 = Actor::New(); + sibling3.SetPosition( Vector3(-100.0f, -10.0f, -1.0f) ); + parent.Add( sibling3 ); + + Actor sibling4 = Actor::New(); + sibling4.SetPosition( Vector3(-1.0f, 1.0f, 2.0f) ); + parent.Add( sibling4 ); + + application.SendNotification(); + application.Render(0); + + Vector3 startValue( 0.0f, 0.0f, 0.0f ); + Vector3 meanValue = parent.GetCurrentPosition() + + sibling1.GetCurrentPosition() + + sibling2.GetCurrentPosition() + + sibling3.GetCurrentPosition() + + sibling4.GetCurrentPosition(); + meanValue *= (1.0f / 5.0f); // divide by number of positions + + /** + * Test that the Constraint is correctly applied on a clean Node + */ + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + + // Apply constraint with a parent input property + + Constraint constraint = Constraint::New( Actor::POSITION, + Source( sibling1, Actor::POSITION ), + Source( sibling2, Actor::POSITION ), + ParentSource( Actor::POSITION ), + Source( sibling3, Actor::POSITION ), + Source( sibling4, Actor::POSITION ), + MeanPositionConstraint5() ); + + actor.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintNewInput6(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Vector3 parentStartSize( 100.0f, 100.0f, 0.0f ); + parent.SetSize( parentStartSize ); + parent.SetPosition( 10.0f, 10.0f, 10.0f ); + Stage::GetCurrent().Add( parent ); + + Actor actor = Actor::New(); + parent.Add( actor ); + + Actor child = Actor::New(); + child.SetPosition( Vector3(7.0f, 7.0f, 7.0f) ); + actor.Add( child ); + + Actor sibling1 = Actor::New(); + sibling1.SetPosition( Vector3(1.0f, 2.0f, 3.0f) ); + parent.Add( sibling1 ); + + Actor sibling2 = Actor::New(); + sibling2.SetPosition( Vector3(300.0f, 300.0f, 300.0f) ); + parent.Add( sibling2 ); + + Actor sibling3 = Actor::New(); + sibling3.SetPosition( Vector3(-100.0f, -10.0f, -1.0f) ); + parent.Add( sibling3 ); + + Actor sibling4 = Actor::New(); + sibling4.SetPosition( Vector3(-1.0f, 1.0f, 2.0f) ); + parent.Add( sibling4 ); + + application.SendNotification(); + application.Render(0); + + Vector3 startValue( 0.0f, 0.0f, 0.0f ); + Vector3 meanValue = parent.GetCurrentPosition() + + child.GetCurrentPosition() + + sibling1.GetCurrentPosition() + + sibling2.GetCurrentPosition() + + sibling3.GetCurrentPosition() + + sibling4.GetCurrentPosition(); + meanValue *= (1.0f / 6.0f); // divide by number of positions + + /** + * Test that the Constraint is correctly applied on a clean Node + */ + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + + // Apply constraint with a parent input property + + Constraint constraint = Constraint::New( Actor::POSITION, + Source( child, Actor::POSITION ), + Source( sibling1, Actor::POSITION ), + Source( sibling2, Actor::POSITION ), + ParentSource( Actor::POSITION ), + Source( sibling3, Actor::POSITION ), + Source( sibling4, Actor::POSITION ), + MeanPositionConstraint6() ); + + actor.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), meanValue, POSITION_EPSILON, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintDownCast(void) +{ + TestApplication application; + tet_infoline("Testing Dali::Constraint::DownCast()"); + + Actor actor = Actor::New(); + + // Register a boolean property + bool startValue(false); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Constraint constraint = Constraint::New( index, TestAlwaysTrueConstraint() ); + + BaseHandle object(constraint); + + Constraint constraint2 = Constraint::DownCast(object); + DALI_TEST_CHECK(constraint2); + + Constraint constraint3 = DownCast< Constraint >(object); + DALI_TEST_CHECK(constraint3); + + BaseHandle unInitializedObject; + Constraint constraint4 = Constraint::DownCast(unInitializedObject); + DALI_TEST_CHECK(!constraint4); + + Constraint constraint5 = DownCast< Constraint >(unInitializedObject); + DALI_TEST_CHECK(!constraint5); + END_TEST; +} + +int UtcDaliConstraintSetApplyTime(void) +{ + TestApplication application; + + // Build constraint + + Vector4 targetColor(Color::BLACK); + Constraint constraint = Constraint::New( Actor::COLOR, TestColorConstraint(targetColor) ); + DALI_TEST_EQUALS(constraint.GetApplyTime(), TimePeriod(0.0f), TEST_LOCATION); + + float applySeconds(7.0f); + constraint.SetApplyTime(applySeconds); + DALI_TEST_EQUALS(constraint.GetApplyTime(), TimePeriod(applySeconds), TEST_LOCATION); + + // Apply to an actor + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + actor.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(applySeconds*200.0f)/* 20% progress */); + + // Constraint shouldn't be fully applied yet + Vector4 twentyPercentColor( Color::WHITE.x*0.8f, Color::WHITE.y*0.8f, Color::WHITE.z*0.8f, Color::WHITE.a ); + DALI_TEST_EQUALS( actor.GetCurrentColor(), twentyPercentColor, TEST_LOCATION ); + + // Constraint shouldn't be fully applied yet + application.Render(static_cast(applySeconds*200.0f)/* 40% progress */); + Vector4 fourtyPercentColor( Color::WHITE.x*0.6f, Color::WHITE.y*0.6f, Color::WHITE.z*0.6f, Color::WHITE.a ); + DALI_TEST_EQUALS( actor.GetCurrentColor(), fourtyPercentColor, TEST_LOCATION ); + + // Constraint shouldn't be fully applied yet + application.Render(static_cast(applySeconds*200.0f)/* 60% progress */); + Vector4 sixtyPercentColor( Color::WHITE.x*0.4f, Color::WHITE.y*0.4f, Color::WHITE.z*0.4f, Color::WHITE.a ); + DALI_TEST_EQUALS( actor.GetCurrentColor(), sixtyPercentColor, TEST_LOCATION ); + + // Constraint shouldn't be fully applied yet + application.Render(static_cast(applySeconds*200.0f)/* 80% progress */); + Vector4 eightyPercentColor( Color::WHITE.x*0.2f, Color::WHITE.y*0.2f, Color::WHITE.z*0.2f, Color::WHITE.a ); + DALI_TEST_EQUALS( actor.GetCurrentColor(), eightyPercentColor, TEST_LOCATION ); + + // Constraint should be fully applied + application.Render(static_cast(applySeconds*200.0f)/* 100% progress */); + DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); + + // Constraint should still be fully applied + application.Render(static_cast(applySeconds*200.0f)/* Still 100% progress */); + DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentColor(), targetColor, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintGetApplyTime(void) +{ + TestApplication application; + + Constraint constraint = Constraint::New( Actor::COLOR, TestConstraint() ); + DALI_TEST_EQUALS(constraint.GetApplyTime(), TimePeriod(0.0f), TEST_LOCATION); + + float applySeconds(7.0f); + constraint.SetApplyTime(applySeconds); + DALI_TEST_EQUALS(constraint.GetApplyTime(), TimePeriod(applySeconds), TEST_LOCATION); + + constraint.SetApplyTime(applySeconds - 3.0f); + DALI_TEST_EQUALS(constraint.GetApplyTime(), TimePeriod(applySeconds - 3.0f), TEST_LOCATION); + END_TEST; +} + +int UtcDaliConstraintSetRemoveTime(void) +{ + TestApplication application; + + Vector3 sourcePosition(0.0f, 0.0f, 0.0f); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + + // Build constraint + + Constraint constraint = Constraint::New( Actor::POSITION, TestPositionConstraint(targetPosition) ); + DALI_TEST_EQUALS(constraint.GetRemoveTime(), TimePeriod(0.0f), TEST_LOCATION); + + float removeSeconds(8.0f); + constraint.SetRemoveTime(removeSeconds); + DALI_TEST_EQUALS(constraint.GetRemoveTime(), TimePeriod(removeSeconds), TEST_LOCATION); + + // Apply to an actor + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + actor.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION ); + + application.SendNotification(); + application.Render(100u/*0.1 seconds*/); + + // Constraint should be fully applied + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + + // Remove from the actor, and set to alternative position + + actor.RemoveConstraints(); + + Vector3 thirdPosition(200.0f, 200.0f, 200.0f); + actor.SetPosition(thirdPosition); // Go back to 3rd position + + application.SendNotification(); + application.Render(static_cast(removeSeconds*200.0f)/* 20% removal progress */); + + // Constraint shouldn't be fully removed yet + Vector3 twentyPercentBack( targetPosition + (thirdPosition - targetPosition)*0.2f ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), twentyPercentBack, TEST_LOCATION ); + + application.Render(static_cast(removeSeconds*200.0f)/* 40% removal progress */); + + // Constraint shouldn't be fully removed yet + Vector3 fourtyPercentBack( targetPosition + (thirdPosition - targetPosition)*0.4f ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), fourtyPercentBack, TEST_LOCATION ); + + application.Render(static_cast(removeSeconds*200.0f)/* 60% removal progress */); + + // Constraint shouldn't be fully removed yet + Vector3 sixtyPercentBack( targetPosition + (thirdPosition - targetPosition)*0.6f ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), sixtyPercentBack, TEST_LOCATION ); + + application.Render(static_cast(removeSeconds*200.0f)/* 80% removal progress */); + + // Constraint shouldn't be fully removed yet + Vector3 eightyPercentBack( targetPosition + (thirdPosition - targetPosition)*0.8f ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), eightyPercentBack, TEST_LOCATION ); + + // Constraint should be fully removed + application.Render(static_cast(removeSeconds*200.0f)/* 100% removal progress */); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), thirdPosition, TEST_LOCATION ); + + // Constraint should still be fully applied + application.Render(static_cast(removeSeconds*200.0f)/* Still 100% removal progress */); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), thirdPosition, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), thirdPosition, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), thirdPosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintGetRemoveTime(void) +{ + TestApplication application; + + Constraint constraint = Constraint::New( Actor::COLOR, TestConstraint() ); + DALI_TEST_EQUALS(constraint.GetRemoveTime(), TimePeriod(0.0f), TEST_LOCATION); + END_TEST; +} + +int UtcDaliConstraintSetAlphaFunction(void) +{ + TestApplication application; + + Vector3 startValue( Vector3::ZERO ); + Vector3 targetValue(100.0f, 100.0f, 100.0f); + + Constraint constraint = Constraint::New( Actor::POSITION, + TestConstraintVector3( targetValue ) ); + + // Test the alpha-function itself + + AlphaFunction func = constraint.GetAlphaFunction(); + DALI_TEST_EQUALS(func(0.1f), 0.1f, TEST_LOCATION); // Default is Linear + + // Test that the alpha-function is used correctly + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(static_cast(1000.0f/*1 second*/)); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + application.Render(static_cast(1000.0f/*1 second*/)); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + application.Render(static_cast(1000.0f/*1 second*/)); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + + constraint.SetApplyTime( 10.0f ); + actor.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(static_cast(1000.0f/*1 second*/)); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), (targetValue - startValue) * 0.1f, TEST_LOCATION ); + application.Render(static_cast(1000.0f/*1 second*/)); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), (targetValue - startValue) * 0.2f, TEST_LOCATION ); + application.Render(static_cast(1000.0f/*1 second*/)); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), (targetValue - startValue) * 0.3f, TEST_LOCATION ); + application.Render(static_cast(1000.0f/*1 second*/)); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), (targetValue - startValue) * 0.4f, TEST_LOCATION ); + application.Render(static_cast(1000.0f/*1 second*/)); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), (targetValue - startValue) * 0.5f, TEST_LOCATION ); + application.Render(static_cast(1000.0f/*1 second*/)); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), (targetValue - startValue) * 0.6f, TEST_LOCATION ); + application.Render(static_cast(1000.0f/*1 second*/)); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), (targetValue - startValue) * 0.7f, TEST_LOCATION ); + application.Render(static_cast(1000.0f/*1 second*/)); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), (targetValue - startValue) * 0.8f, TEST_LOCATION ); + application.Render(static_cast(1000.0f/*1 second*/)); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), (targetValue - startValue) * 0.9f, TEST_LOCATION ); + application.Render(static_cast(1000.0f/*1 second*/)); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), (targetValue - startValue), TEST_LOCATION ); + + // Check that the constrained value is stable + application.Render(static_cast(1000.0f/*1 second*/)); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), (targetValue - startValue), TEST_LOCATION ); + application.Render(static_cast(1000.0f/*1 second*/)); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), (targetValue - startValue), TEST_LOCATION ); + + // Remove the constraint + + actor.RemoveConstraints(); + actor.SetPosition( startValue ); + + application.SendNotification(); + application.Render(static_cast(1000.0f/*1 second*/)); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + application.Render(static_cast(1000.0f/*1 second*/)); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + application.Render(static_cast(1000.0f/*1 second*/)); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), startValue, TEST_LOCATION ); + + // Change to non-linear alpha and retest + + constraint.SetAlphaFunction(AlphaFunctions::EaseIn); + func = constraint.GetAlphaFunction(); + DALI_TEST_CHECK(func(0.1f) < 0.09f); + + actor.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(static_cast(1000.0f/*1 second*/)); + + DALI_TEST_CHECK( actor.GetProperty( Actor::POSITION ).x > startValue.x ); + DALI_TEST_CHECK( actor.GetProperty( Actor::POSITION ).y > startValue.y ); + DALI_TEST_CHECK( actor.GetProperty( Actor::POSITION ).z > startValue.z ); + + Vector3 lessThanTenPercentProgress( (targetValue - startValue) * 0.09f ); + DALI_TEST_CHECK( actor.GetProperty( Actor::POSITION ).x < lessThanTenPercentProgress.x ); + DALI_TEST_CHECK( actor.GetProperty( Actor::POSITION ).y < lessThanTenPercentProgress.y ); + DALI_TEST_CHECK( actor.GetProperty( Actor::POSITION ).z < lessThanTenPercentProgress.z ); + + application.Render(static_cast(9000.0f/*9 seconds*/)); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), (targetValue - startValue), TEST_LOCATION ); + + // Check that the constrained value is stable + application.Render(static_cast(1000.0f/*1 second*/)); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), (targetValue - startValue), TEST_LOCATION ); + application.Render(static_cast(1000.0f/*1 second*/)); + DALI_TEST_EQUALS( actor.GetProperty( Actor::POSITION ), (targetValue - startValue), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintGetAlphaFunction(void) +{ + TestApplication application; + + Constraint constraint = Constraint::New( Actor::COLOR, TestConstraint() ); + + AlphaFunction func = constraint.GetAlphaFunction(); + DALI_TEST_EQUALS(func(0.5f), 0.5f, TEST_LOCATION); // Default is Linear + END_TEST; +} + +int UtcDaliConstraintSetRemoveAction(void) +{ + TestApplication application; + + Vector3 sourcePosition(0.0f, 0.0f, 0.0f); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + + // Build constraint, with "Discard" remove action + + Constraint constraint = Constraint::New( Actor::POSITION, TestPositionConstraint(targetPosition) ); + DALI_TEST_EQUALS((unsigned int)constraint.GetRemoveAction(), (unsigned int)Constraint::Bake, TEST_LOCATION); + + constraint.SetRemoveAction(Constraint::Discard); + DALI_TEST_EQUALS((unsigned int)constraint.GetRemoveAction(), (unsigned int)Constraint::Discard, TEST_LOCATION); + + float removeSeconds(8.0f); + constraint.SetRemoveTime(removeSeconds); + DALI_TEST_EQUALS(constraint.GetRemoveTime(), TimePeriod(removeSeconds), TEST_LOCATION); + + // Apply to an actor + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + actor.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION ); + + application.SendNotification(); + application.Render(100u/*0.1 seconds*/); + + // Constraint should be fully applied + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + + // Remove from the actor + + actor.RemoveConstraints(); // should go back to source position + + application.SendNotification(); + application.Render(static_cast(removeSeconds*200.0f)/* 20% removal progress */); + + // Constraint shouldn't be fully removed yet + Vector3 twentyPercentBack( targetPosition * 0.8f ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), twentyPercentBack, TEST_LOCATION ); + + application.Render(static_cast(removeSeconds*200.0f)/* 40% removal progress */); + + // Constraint shouldn't be fully removed yet + Vector3 fourtyPercentBack( targetPosition * 0.6f ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), fourtyPercentBack, TEST_LOCATION ); + + application.Render(static_cast(removeSeconds*200.0f)/* 60% removal progress */); + + // Constraint shouldn't be fully removed yet + Vector3 sixtyPercentBack( targetPosition * 0.4f ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), sixtyPercentBack, TEST_LOCATION ); + + application.Render(static_cast(removeSeconds*200.0f)/* 80% removal progress */); + + // Constraint shouldn't be fully removed yet + Vector3 eightyPercentBack( targetPosition * 0.2f ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), eightyPercentBack, TEST_LOCATION ); + + // Constraint should be fully removed + application.Render(static_cast(removeSeconds*200.0f)/* 100% removal progress */); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION ); + + // Constraint should still be fully applied + application.Render(static_cast(removeSeconds*200.0f)/* Still 100% removal progress */); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintGetRemoveAction(void) +{ + TestApplication application; + + Constraint constraint = Constraint::New( Actor::COLOR, TestConstraint() ); + DALI_TEST_EQUALS((unsigned int)constraint.GetRemoveAction(), (unsigned int)Constraint::Bake, TEST_LOCATION); + + constraint.SetRemoveAction(Constraint::Discard); + DALI_TEST_EQUALS((unsigned int)constraint.GetRemoveAction(), (unsigned int)Constraint::Discard, TEST_LOCATION); + + constraint.SetRemoveAction(Constraint::Bake); + DALI_TEST_EQUALS((unsigned int)constraint.GetRemoveAction(), (unsigned int)Constraint::Bake, TEST_LOCATION); + END_TEST; +} + +/** + * Test a constraint with non-zero apply-time and remove-time, where the constraint is removed during the apply-time + */ +int UtcDaliConstraintRemoveDuringApply(void) +{ + TestApplication application; + + Vector3 sourcePosition(0.0f, 0.0f, 0.0f); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + Vector3 halfwayPosition(targetPosition * 0.5f); + + // Build constraint + + Constraint constraint = Constraint::New( Actor::POSITION, TestPositionConstraint(targetPosition) ); + DALI_TEST_EQUALS((unsigned int)constraint.GetRemoveAction(), (unsigned int)Constraint::Bake, TEST_LOCATION); + + float applySeconds(4.0f); + constraint.SetApplyTime(applySeconds); + DALI_TEST_EQUALS(constraint.GetApplyTime(), TimePeriod(applySeconds), TEST_LOCATION); + + float removeSeconds(8.0f); + constraint.SetRemoveTime(removeSeconds); + DALI_TEST_EQUALS(constraint.GetRemoveTime(), TimePeriod(removeSeconds), TEST_LOCATION); + + // Apply to an actor + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + actor.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(applySeconds*250.0f)/* 25% progress */); + + // Constraint shouldn't be fully applied yet + Vector3 twentyFivePercent( targetPosition * 0.25f ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), twentyFivePercent, TEST_LOCATION ); + + application.Render(static_cast(applySeconds*250.0f)/* 50% progress */); + + // Constraint shouldn't be fully applied yet + Vector3 fiftyPercent( targetPosition * 0.5f ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercent, TEST_LOCATION ); + + // Remove from the actor + + actor.RemoveConstraints(); // should go back to source position + + application.SendNotification(); + application.Render(static_cast(removeSeconds*100.0f)/* 50% - 5% = 45% progress */); + + // Constraint shouldn't be fully removed yet + Vector3 fourtyFivePercent( targetPosition * 0.45f ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), fourtyFivePercent, TEST_LOCATION ); + + application.Render(static_cast(removeSeconds*400.0f)/* 50% - 25% = 25% progress */); + + // Constraint shouldn't be fully removed yet + DALI_TEST_EQUALS( actor.GetCurrentPosition(), twentyFivePercent, TEST_LOCATION ); + + // Constraint should be fully removed + application.Render(static_cast(removeSeconds*500.0f)/* 0% progress */); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION ); + + // Constraint should still be fully applied + application.Render(static_cast(removeSeconds*200.0f)/* Still 0% progress */); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION ); + END_TEST; +} + +/** + * Test a constraint with non-zero apply-time & zero (immediate) remove-time, where the constraint is removed during the apply-time + */ +int UtcDaliConstraintImmediateRemoveDuringApply(void) +{ + TestApplication application; + + Vector3 sourcePosition(0.0f, 0.0f, 0.0f); + Vector3 targetPosition(100.0f, 100.0f, 100.0f); + + // Build constraint + + Constraint constraint = Constraint::New( Actor::POSITION, TestPositionConstraint(targetPosition) ); + DALI_TEST_EQUALS((unsigned int)constraint.GetRemoveAction(), (unsigned int)Constraint::Bake, TEST_LOCATION); + + float applySeconds(4.0f); + constraint.SetApplyTime(applySeconds); + DALI_TEST_EQUALS(constraint.GetApplyTime(), TimePeriod(applySeconds), TEST_LOCATION); + DALI_TEST_EQUALS(constraint.GetRemoveTime(), TimePeriod(0.0f), TEST_LOCATION); + + // Apply to an actor + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + actor.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(applySeconds*250.0f)/* 25% progress */); + + // Constraint shouldn't be fully applied yet + Vector3 twentyFivePercent( targetPosition * 0.25f ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), twentyFivePercent, TEST_LOCATION ); + + application.Render(static_cast(applySeconds*250.0f)/* 50% progress */); + + // Constraint shouldn't be fully applied yet + Vector3 fiftyPercent( targetPosition * 0.5f ); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), fiftyPercent, TEST_LOCATION ); + + // Remove from the actor + + actor.RemoveConstraints(); // should go back to source position + application.SendNotification(); + + // Constraint should be fully removed + application.Render(static_cast(200.0f /*0.2 seconds*/)); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION ); + + // Constraint should still be fully applied + application.Render(static_cast(200.0f /*0.2 seconds*/)); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentPosition(), sourcePosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintActorSize(void) +{ + TestApplication application; + + // Build constraint, to make child 20% of parent size + + Constraint constraint = Constraint::New( Actor::SIZE, + ParentSource( Actor::SIZE ), + TestRelativeConstraintVector3(0.2f) ); + // Apply to a child actor + + Actor parent = Actor::New(); + Stage::GetCurrent().Add(parent); + + Actor child = Actor::New(); + parent.Add(child); + + child.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( child.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + + // Animate the parent between two sizes + + Vector3 targetParentSize(100.0f, 100.0f, 100.0f); + + float durationSeconds(10.0f); + Animation animation = Animation::New(durationSeconds); + animation.AnimateTo( Property(parent, Actor::SIZE), targetParentSize ); + animation.Play(); + + application.SendNotification(); + + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.25f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize(), targetParentSize*0.25f * 0.2f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.5f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize(), targetParentSize*0.5f * 0.2f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.75f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize(), targetParentSize*0.75f * 0.2f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 100% progress */); + DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize(), targetParentSize * 0.2f, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize(), targetParentSize * 0.2f, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize(), targetParentSize * 0.2f, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintActorSizeWidth(void) +{ + TestApplication application; + + // Build constraint, to make child 20% of parent width + + Constraint constraint = Constraint::New( Actor::SIZE_WIDTH, + ParentSource( Actor::SIZE_WIDTH ), + TestRelativeConstraintFloat(0.2f) ); + // Apply to a child actor + + Actor parent = Actor::New(); + Stage::GetCurrent().Add(parent); + + Actor child = Actor::New(); + parent.Add(child); + + child.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( child.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + + // Animate the parent between two sizes + + Vector3 targetParentSize(80.0f, 90.0f, 100.0f); + + float durationSeconds(10.0f); + Animation animation = Animation::New(durationSeconds); + animation.AnimateTo( Property(parent, Actor::SIZE), targetParentSize ); + animation.Play(); + + application.SendNotification(); + + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.25f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().width, targetParentSize.width*0.25f * 0.2f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().depth, 0.0f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.5f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().width, targetParentSize.width*0.5f * 0.2f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().depth, 0.0f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.75f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().width, targetParentSize.width*0.75f * 0.2f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().depth, 0.0f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 100% progress */); + DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().width, targetParentSize.width * 0.2f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().depth, 0.0f, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().width, targetParentSize.width * 0.2f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().depth, 0.0f, TEST_LOCATION ); + + application.Render(0); + DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().width, targetParentSize.width * 0.2f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().depth, 0.0f, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintActorSizeHeight(void) +{ + TestApplication application; + + // Build constraint, to make child 20% of parent height + + Constraint constraint = Constraint::New( Actor::SIZE_HEIGHT, + ParentSource( Actor::SIZE_HEIGHT ), + TestRelativeConstraintFloat(0.2f) ); + // Apply to a child actor + + Actor parent = Actor::New(); + Stage::GetCurrent().Add(parent); + + Actor child = Actor::New(); + parent.Add(child); + + child.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( child.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + + // Animate the parent between two sizes + + Vector3 targetParentSize(80.0f, 90.0f, 100.0f); + + float durationSeconds(10.0f); + Animation animation = Animation::New(durationSeconds); + animation.AnimateTo( Property(parent, Actor::SIZE), targetParentSize ); + animation.Play(); + + application.SendNotification(); + + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.25f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().width, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().height, targetParentSize.height*0.25f * 0.2f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().depth, 0.0f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.5f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().width, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().height, targetParentSize.height*0.5f * 0.2f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().depth, 0.0f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.75f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().width, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().height, targetParentSize.height*0.75f * 0.2f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().depth, 0.0f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 100% progress */); + DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().width, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().height, targetParentSize.height * 0.2f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().depth, 0.0f, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().width, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().height, targetParentSize.height * 0.2f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().depth, 0.0f, TEST_LOCATION ); + + application.Render(0); + DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().width, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().height, targetParentSize.height * 0.2f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().depth, 0.0f, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintActorSizeDepth(void) +{ + TestApplication application; + + // Build constraint, to make child 20% of parent height + + Constraint constraint = Constraint::New( Actor::SIZE_DEPTH, + ParentSource( Actor::SIZE_DEPTH ), + TestRelativeConstraintFloat(0.2f) ); + // Apply to a child actor + + Actor parent = Actor::New(); + Stage::GetCurrent().Add(parent); + + Actor child = Actor::New(); + parent.Add(child); + + child.ApplyConstraint( constraint ); + DALI_TEST_EQUALS( child.GetCurrentSize(), Vector3::ZERO, TEST_LOCATION ); + + // Animate the parent between two sizes + + Vector3 targetParentSize(80.0f, 90.0f, 100.0f); + + float durationSeconds(10.0f); + Animation animation = Animation::New(durationSeconds); + animation.AnimateTo( Property(parent, Actor::SIZE), targetParentSize ); + animation.Play(); + + application.SendNotification(); + + application.Render(static_cast(durationSeconds*250.0f)/* 25% progress */); + DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.25f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().width, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().depth, targetParentSize.depth*0.25f * 0.2f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); + DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.5f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().width, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().depth, targetParentSize.depth*0.5f * 0.2f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); + DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize*0.75f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().width, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().depth, targetParentSize.depth*0.75f * 0.2f, TEST_LOCATION ); + + application.Render(static_cast(durationSeconds*250.0f)/* 100% progress */); + DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().width, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().depth, targetParentSize.depth * 0.2f, TEST_LOCATION ); + + // Check that nothing has changed after a couple of buffer swaps + application.Render(0); + DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().width, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().depth, targetParentSize.depth * 0.2f, TEST_LOCATION ); + + application.Render(0); + DALI_TEST_EQUALS( parent.GetCurrentSize(), targetParentSize, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().width, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().height, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentSize().depth, targetParentSize.depth * 0.2f, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintInputWorldPosition(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Vector3 parentPosition( 10.0f, 10.0f, 10.0f ); + parent.SetPosition( parentPosition ); + parent.SetParentOrigin( ParentOrigin::CENTER ); + parent.SetAnchorPoint( AnchorPoint::CENTER ); + Stage::GetCurrent().Add( parent ); + + Actor child = Actor::New(); + child.SetParentOrigin( ParentOrigin::CENTER ); + child.SetAnchorPoint( AnchorPoint::CENTER ); + Vector3 childPosition( 10.0f, 10.0f, 10.0f ); + child.SetPosition( childPosition ); + parent.Add( child ); + + Actor trackingActor = Actor::New(); + trackingActor.SetParentOrigin( ParentOrigin::CENTER ); + trackingActor.SetAnchorPoint( AnchorPoint::CENTER ); + Stage::GetCurrent().Add( trackingActor ); + + // The actors should not have a world position yet + DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( trackingActor.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( trackingActor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION ); + + DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition, TEST_LOCATION ); + Vector3 previousPosition( parentPosition + childPosition ); + DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), previousPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( trackingActor.GetCurrentWorldPosition(), Vector3::ZERO, TEST_LOCATION ); + + // Build constraint, to make actor track the world-position of another actor + // Note that the world-position is always from the previous frame, so the tracking actor will lag behind + + Constraint constraint = Constraint::New( Actor::POSITION, + Source( child, Actor::WORLD_POSITION ), + EqualToConstraint() ); + + trackingActor.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( trackingActor.GetCurrentPosition(), previousPosition, TEST_LOCATION ); + + // Move the actors and try again + Vector3 relativePosition( 5, 5, 5 ); + parent.MoveBy( relativePosition ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition + relativePosition, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION ); + + // The tracking actor lags behind + DALI_TEST_EQUALS( trackingActor.GetCurrentPosition(), previousPosition, TEST_LOCATION ); + + DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition + relativePosition, TEST_LOCATION ); + previousPosition = Vector3( parentPosition + childPosition + relativePosition ); + DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), previousPosition, TEST_LOCATION ); + + // Allow the tracking actor to catch up + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( parent.GetCurrentPosition(), parentPosition + relativePosition, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentPosition(), childPosition, TEST_LOCATION ); + + // The tracking actor catches up! + DALI_TEST_EQUALS( trackingActor.GetCurrentPosition(), previousPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( parent.GetCurrentWorldPosition(), parentPosition + relativePosition, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldPosition(), previousPosition, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintInputWorldRotation(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Radian rotationAngle( Degree(90.0f) ); + Quaternion rotation( rotationAngle, Vector3::YAXIS ); + parent.SetRotation( rotation ); + Stage::GetCurrent().Add( parent ); + + Actor child = Actor::New(); + child.SetRotation( rotation ); + parent.Add( child ); + + Actor trackingActor = Actor::New(); + Stage::GetCurrent().Add( trackingActor ); + + // The actors should not have a world rotation yet + DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( parent.GetCurrentRotation(), rotation, 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentRotation(), rotation, 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( trackingActor.GetCurrentRotation(), Quaternion(0.0f, Vector3::YAXIS), 0.001, TEST_LOCATION ); + + DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion( rotationAngle, Vector3::YAXIS ), 0.001, TEST_LOCATION ); + Quaternion previousRotation( rotationAngle * 2.0f, Vector3::YAXIS ); + DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), previousRotation, 0.001, TEST_LOCATION ); + + // Build constraint, to make actor track the world-rotation of another actor + // Note that the world-rotation is always from the previous frame, so the tracking actor will lag behind + + Constraint constraint = Constraint::New( Actor::ROTATION, + Source( child, Actor::WORLD_ROTATION ), + EqualToQuaternion() ); + + trackingActor.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( trackingActor.GetCurrentRotation(), previousRotation, 0.001, TEST_LOCATION ); + + // Rotate the actors and try again + parent.RotateBy( rotation ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( parent.GetCurrentRotation(), rotation * rotation, 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentRotation(), rotation, 0.001, TEST_LOCATION ); + + // The tracking actor lags behind + DALI_TEST_EQUALS( trackingActor.GetCurrentRotation(), previousRotation, 0.001, TEST_LOCATION ); + + DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION ); + previousRotation = Quaternion( rotationAngle * 3.0f, Vector3::YAXIS ); + DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), previousRotation, 0.001, TEST_LOCATION ); + + // Allow the tracking actor to catch up + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( parent.GetCurrentRotation(), rotation * rotation, 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentRotation(), rotation, 0.001, TEST_LOCATION ); + + // The tracking actor catches up! + DALI_TEST_EQUALS( trackingActor.GetCurrentRotation(), previousRotation, 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( parent.GetCurrentWorldRotation(), Quaternion( rotationAngle * 2.0f, Vector3::YAXIS ), 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldRotation(), previousRotation, 0.001, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintInputWorldScale(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Vector3 parentScale( 2.0f, 2.0f, 2.0f ); + parent.SetScale( parentScale ); + Stage::GetCurrent().Add( parent ); + + Actor child = Actor::New(); + Vector3 childScale( 1.0f, 2.0f, 3.0f ); + child.SetScale( childScale ); + parent.Add( child ); + + Actor trackingActor = Actor::New(); + Stage::GetCurrent().Add( trackingActor ); + + // The actors should not have a world scale yet + DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION ); + DALI_TEST_EQUALS( trackingActor.GetCurrentWorldScale(), Vector3::ONE, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION ); + DALI_TEST_EQUALS( trackingActor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + + DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale, TEST_LOCATION ); + Vector3 previousScale( parentScale * childScale ); + DALI_TEST_EQUALS( child.GetCurrentWorldScale(), previousScale, TEST_LOCATION ); + DALI_TEST_EQUALS( trackingActor.GetCurrentScale(), Vector3::ONE, TEST_LOCATION ); + + // Build constraint, to make actor track the world-scale of another actor + // Note that the world-scale is always from the previous frame, so the tracking actor will lag behind + + Constraint constraint = Constraint::New( Actor::SCALE, + Source( child, Actor::WORLD_SCALE ), + EqualToConstraint() ); + + trackingActor.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( trackingActor.GetCurrentScale(), previousScale, TEST_LOCATION ); + + // Scale the actors and try again + Vector3 relativeScale( 3, 3, 3 ); + parent.ScaleBy( relativeScale ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale * relativeScale, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION ); + + // The tracking actor lags behind + DALI_TEST_EQUALS( trackingActor.GetCurrentScale(), previousScale, TEST_LOCATION ); + + DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale * relativeScale, TEST_LOCATION ); + previousScale = Vector3( parentScale * childScale * relativeScale ); + DALI_TEST_EQUALS( child.GetCurrentWorldScale(), previousScale, TEST_LOCATION ); + + // Allow the tracking actor to catch up + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( parent.GetCurrentScale(), parentScale * relativeScale, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentScale(), childScale, TEST_LOCATION ); + + // The tracking actor catches up! + DALI_TEST_EQUALS( trackingActor.GetCurrentScale(), previousScale, TEST_LOCATION ); + DALI_TEST_EQUALS( parent.GetCurrentWorldScale(), parentScale * relativeScale, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldScale(), previousScale, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintInputWorldColor(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Vector4 parentColor( 1.0f, 0.5f, 0.0f, 1.0f ); + parent.SetColor( parentColor ); + Stage::GetCurrent().Add( parent ); + + Actor child = Actor::New(); + Vector4 childColor( 0.5f, 0.5f, 0.5f, 1.0f ); + child.SetColor( childColor ); + parent.Add( child ); + + Actor trackingActor = Actor::New(); + Stage::GetCurrent().Add( trackingActor ); + + // The actors should not have a world color yet + DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldColor(), Color::WHITE, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentColor(), childColor, TEST_LOCATION ); + DALI_TEST_EQUALS( trackingActor.GetCurrentColor(), Color::WHITE, TEST_LOCATION ); + + DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION ); + Vector4 previousColor( childColor ); + previousColor.a *= parentColor.a; + DALI_TEST_EQUALS( child.GetCurrentWorldColor(), previousColor, TEST_LOCATION ); + + // Build constraint, to make actor track the world-color of another actor + // Note that the world-color is always from the previous frame, so the tracking actor will lag behind + + Constraint constraint = Constraint::New( Actor::COLOR, + Source( child, Actor::WORLD_COLOR ), + EqualToVector4() ); + + trackingActor.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( trackingActor.GetCurrentColor(), previousColor, TEST_LOCATION ); + + // Set the color and try again + Vector4 newChildColor( 0.75f, 0.75f, 0.75f, 1.0f ); + child.SetColor( newChildColor ); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentColor(), newChildColor, TEST_LOCATION ); + + // The tracking actor lags behind + DALI_TEST_EQUALS( trackingActor.GetCurrentColor(), previousColor, TEST_LOCATION ); + + DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION ); + previousColor = Vector3( newChildColor ); + DALI_TEST_EQUALS( child.GetCurrentWorldColor(), previousColor, TEST_LOCATION ); + + // Allow the tracking actor to catch up + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( parent.GetCurrentColor(), parentColor, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentColor(), newChildColor, TEST_LOCATION ); + + // The tracking actor catches up! + DALI_TEST_EQUALS( trackingActor.GetCurrentColor(), previousColor, TEST_LOCATION ); + DALI_TEST_EQUALS( parent.GetCurrentWorldColor(), parentColor, TEST_LOCATION ); + DALI_TEST_EQUALS( child.GetCurrentWorldColor(), previousColor, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliConstraintInvalidInputProperty(void) +{ + TestApplication application; + Actor actor = Actor::New(); + Constraint constraint = Constraint::New( Actor::POSITION, LocalSource( PROPERTY_REGISTRATION_START_INDEX ), MultiplyConstraint() ); + + Stage::GetCurrent().Add( actor ); + + // Cannot use type registered properties as input to constraints + try + { + actor.ApplyConstraint( constraint ); + tet_result( TET_FAIL ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT( e, "mTargetProxy->IsPropertyAConstraintInput( source.propertyIndex )", TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliBuiltinConstraintParentSize(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Vector3 parentSize(9,9,9); + parent.SetSize( parentSize ); + Stage::GetCurrent().Add( parent ); + + Actor actor = Actor::New(); + parent.Add( actor ); + + Vector3 startValue( Vector3::ZERO ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor.GetCurrentSize() == startValue ); + + // Apply constraint + + Constraint constraint = Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ); + actor.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + DALI_TEST_EQUALS( actor.GetCurrentSize(), parentSize, TEST_LOCATION ); + + // This should be ignored + actor.SetSize( startValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentSize(), parentSize, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentSize(), parentSize, TEST_LOCATION ); + + // Remove the constraint, then set new value + actor.RemoveConstraints(); + actor.SetSize( startValue ); + + // Constraint should have been removed + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentSize(), startValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentSize(), startValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliBuiltinConstraintParentSizeRelative(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Vector3 parentSize(9,9,9); + parent.SetSize( parentSize ); + Stage::GetCurrent().Add( parent ); + + Actor actor = Actor::New(); + parent.Add( actor ); + + Vector3 startValue( Vector3::ZERO ); + Vector3 scale(2,3,4); + Vector3 endValue( parentSize * scale ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor.GetCurrentSize() == startValue ); + + // Apply constraint + + Constraint constraint = Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), RelativeToConstraint( scale ) ); + actor.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + DALI_TEST_EQUALS( actor.GetCurrentSize(), endValue, TEST_LOCATION ); + + // This should be ignored + actor.SetSize( startValue ); + + // Check that nothing has changed after a couple of buffer swaps + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentSize(), endValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentSize(), endValue, TEST_LOCATION ); + + // Remove the constraint, then set new value + actor.RemoveConstraints(); + actor.SetSize( startValue ); + + // Constraint should have been removed + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentSize(), startValue, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentSize(), startValue, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliBuiltinConstraintScaleToFitConstraint(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Vector3 startParentSize( 10, 10, 10 ); + parent.SetSize( startParentSize ); + Stage::GetCurrent().Add( parent ); + + Actor actor = Actor::New(); + Vector3 startChildSize( 5, 5, 5 ); + actor.SetSize( startChildSize ); + parent.Add( actor ); + + Vector3 endChildSize( 8, 8, 8 ); + Vector3 endParentSize( 4, 4, 4 ); + Vector3 startChildScale( 2, 2, 2 ); // startParentSize / startChildSize + Vector3 intermediateChildScale( 1.25, 1.25, 1.25 ); // startParentSize / endChildSize + Vector3 endChildScale( 0.5, 0.5, 0.5 ); // endParentSize / endChildSize + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor.GetCurrentSize() == startChildSize ); + + // Apply constraint + + Constraint constraint = Constraint::New( Actor::SCALE, + LocalSource( Actor::SIZE ), + ParentSource( Actor::SIZE ), + ScaleToFitConstraint() ); + actor.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied, but parent size is larger than child + DALI_TEST_EQUALS( actor.GetCurrentSize(), startChildSize, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), startChildScale, TEST_LOCATION ); + + // This should be allowed (still less than parent size) + actor.SetSize( endChildSize ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentSize(), endChildSize, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), intermediateChildScale, TEST_LOCATION ); + + // Reduce the parent size + parent.SetSize( endParentSize ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + DALI_TEST_EQUALS( actor.GetCurrentSize(), endChildSize, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), endChildScale, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor.GetCurrentSize(), endChildSize, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), endChildScale, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliBuiltinConstraintScaleToFitKeepAspectRatio(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Vector3 parentSize1( 10, 10, 10 ); + parent.SetSize( parentSize1 ); + Stage::GetCurrent().Add( parent ); + + Actor actor = Actor::New(); + Vector3 childSize( 4, 5, 5 ); + actor.SetSize( childSize ); + parent.Add( actor ); + + application.SendNotification(); + application.Render(0); + Vector3 childScale1( 1.0f, 1.0f, 1.0f ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale1, TEST_LOCATION ); + + // Apply constraint + + Constraint constraint = Constraint::New( Actor::SCALE, + LocalSource( Actor::SIZE ), + ParentSource( Actor::SIZE ), + ScaleToFitKeepAspectRatioConstraint() ); + actor.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied, but parent size is larger than child + Vector3 childScale2( 2.0f, 2.0f, 2.0f ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale2, TEST_LOCATION ); + + // change parent size + Vector3 parentSize2( 40, 50, 50 ); + parent.SetSize( parentSize2 ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied, but parent size is larger than child + Vector3 childScale3( 10.0f, 10.0f, 10.0f ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale3, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliBuiltinConstraintScaleToFillKeepAspectRatio(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Vector3 parentSize1( 10, 10, 10 ); + parent.SetSize( parentSize1 ); + Stage::GetCurrent().Add( parent ); + + Actor actor = Actor::New(); + Vector3 childSize( 4, 5, 5 ); + actor.SetSize( childSize ); + parent.Add( actor ); + + application.SendNotification(); + application.Render(0); + Vector3 childScale1( 1.0f, 1.0f, 1.0f ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale1, TEST_LOCATION ); + + // Apply constraint + + Constraint constraint = Constraint::New( Actor::SCALE, + LocalSource( Actor::SIZE ), + ParentSource( Actor::SIZE ), + ScaleToFillKeepAspectRatioConstraint() ); + actor.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied, but parent size is larger than child + float val = 10.f / 4.f; + Vector3 childScale2( val, val, val ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale2, TEST_LOCATION ); + + // change parent size + Vector3 parentSize2( 40, 50, 50 ); + parent.SetSize( parentSize2 ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied, but parent size is larger than child + Vector3 childScale3( 10.0f, 10.0f, 10.0f ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale3, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliBuiltinConstraintScaleToFillXYKeepAspectRatio(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Vector3 parentSize1( 10, 10, 10 ); + parent.SetSize( parentSize1 ); + Stage::GetCurrent().Add( parent ); + + Actor actor = Actor::New(); + Vector3 childSize( 4, 5, 5 ); + actor.SetSize( childSize ); + parent.Add( actor ); + + application.SendNotification(); + application.Render(0); + Vector3 childScale1( 1.0f, 1.0f, 1.0f ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale1, TEST_LOCATION ); + + // Apply constraint + + Constraint constraint = Constraint::New( Actor::SCALE, + LocalSource( Actor::SIZE ), + ParentSource( Actor::SIZE ), + ScaleToFillXYKeepAspectRatioConstraint() ); + actor.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied, but parent size is larger than child + float val = 10.f / 4.f; + Vector3 childScale2( val, val, val ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale2, TEST_LOCATION ); + + // change parent size + Vector3 parentSize2( 40, 50, 50 ); + parent.SetSize( parentSize2 ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied, but parent size is larger than child + Vector3 childScale3( 10.0f, 10.0f, 10.0f ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale3, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliBuiltinConstraintShrinkInsideKeepAspectRatioConstraint(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Vector3 parentSize1( 10, 10, 10 ); + parent.SetSize( parentSize1 ); + Stage::GetCurrent().Add( parent ); + + Actor actor = Actor::New(); + Vector3 childSize( 4, 5, 5 ); + actor.SetSize( childSize ); + parent.Add( actor ); + + application.SendNotification(); + application.Render(0); + Vector3 childScale1( 1.0f, 1.0f, 1.0f ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale1, TEST_LOCATION ); + + // Apply constraint + + Constraint constraint = Constraint::New( Actor::SCALE, + LocalSource( Actor::SIZE ), + ParentSource( Actor::SIZE ), + ShrinkInsideKeepAspectRatioConstraint() ); + actor.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied, but parent size is larger than child + Vector3 childScale2( 1.0f, 1.0f, 1.0f ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale2, TEST_LOCATION ); + + // change parent size + Vector3 parentSize2( 40, 50, 50 ); + parent.SetSize( parentSize2 ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied, but parent size is larger than child + Vector3 childScale3( 1.0f, 1.0f, 1.0f ); + DALI_TEST_EQUALS( actor.GetCurrentScale(), childScale3, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliBuiltinConstraintMultiplyConstraint(void) +{ + TestApplication application; + + Actor actor1 = Actor::New(); + Vector3 startPosition( 10, 10, 10 ); + actor1.SetPosition( startPosition ); + Stage::GetCurrent().Add( actor1 ); + + Actor actor2 = Actor::New(); + Vector3 startSize( 100, 100, 100 ); + actor2.SetSize( startSize ); + Stage::GetCurrent().Add( actor2 ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor1.GetCurrentPosition() == startPosition ); + DALI_TEST_CHECK( actor2.GetCurrentSize() == startSize ); + + // Apply constraint - multiply actor1 size by actor2 position + + Constraint constraint = Constraint::New( Actor::SIZE, + Source( actor1, Actor::POSITION ), + MultiplyConstraint() ); + constraint.SetRemoveAction( Constraint::Discard ); + actor2.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + Vector3 size( startSize * startPosition ); + DALI_TEST_EQUALS( actor2.GetCurrentSize(), size, TEST_LOCATION ); + + // Change the multiply input + Vector3 endPosition( 2, 2, 2 ); + actor1.SetPosition( endPosition ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + size = Vector3( startSize * endPosition ); + DALI_TEST_EQUALS( actor2.GetCurrentSize(), size, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor2.GetCurrentSize(), size, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliBuiltinConstraintDivideConstraint(void) +{ + TestApplication application; + + Actor actor1 = Actor::New(); + Vector3 startPosition( 10, 10, 10 ); + actor1.SetPosition( startPosition ); + Stage::GetCurrent().Add( actor1 ); + + Actor actor2 = Actor::New(); + Vector3 startSize( 100, 100, 100 ); + actor2.SetSize( startSize ); + Stage::GetCurrent().Add( actor2 ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor1.GetCurrentPosition() == startPosition ); + DALI_TEST_CHECK( actor2.GetCurrentSize() == startSize ); + + // Apply constraint - divide actor1 size by actor2 position + + Constraint constraint = Constraint::New( Actor::SIZE, + Source( actor1, Actor::POSITION ), + DivideConstraint() ); + constraint.SetRemoveAction( Constraint::Discard ); + actor2.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + Vector3 size( 10, 10, 10 ); // startSize / startPosition + DALI_TEST_EQUALS( actor2.GetCurrentSize(), size, TEST_LOCATION ); + + // Change the divide input + Vector3 endPosition( 2, 2, 2 ); + actor1.SetPosition( endPosition ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + size = Vector3( 50, 50, 50 ); // startSize / endPosition + DALI_TEST_EQUALS( actor2.GetCurrentSize(), size, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor2.GetCurrentSize(), size, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliBuiltinConstraintEqualToConstraint(void) +{ + TestApplication application; + + Actor actor1 = Actor::New(); + Vector3 startPosition( 10, 10, 10 ); + actor1.SetPosition( startPosition ); + Stage::GetCurrent().Add( actor1 ); + + Actor actor2 = Actor::New(); + Vector3 startSize( 100, 100, 100 ); + actor2.SetSize( startSize ); + Stage::GetCurrent().Add( actor2 ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor1.GetCurrentPosition() == startPosition ); + DALI_TEST_CHECK( actor2.GetCurrentSize() == startSize ); + + // Apply constraint - actor1 size == actor2 position + + Constraint constraint = Constraint::New( Actor::SIZE, + Source( actor1, Actor::POSITION ), + EqualToConstraint() ); + constraint.SetRemoveAction( Constraint::Discard ); + actor2.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + DALI_TEST_EQUALS( actor2.GetCurrentSize(), startPosition, TEST_LOCATION ); + + // Change the input + Vector3 endPosition( 2, 2, 2 ); + actor1.SetPosition( endPosition ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + DALI_TEST_EQUALS( actor2.GetCurrentSize(), endPosition, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor2.GetCurrentSize(), endPosition, TEST_LOCATION ); + + // + // Check float variant of constraint + // + float startOpacity(1.0f); + float endOpacity(0.2f); + actor1.SetOpacity( startOpacity ); + actor2.SetOpacity( startOpacity ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor1.GetCurrentOpacity(), startOpacity, TEST_LOCATION ); + DALI_TEST_EQUALS( actor2.GetCurrentOpacity(), startOpacity, TEST_LOCATION ); + + Constraint constraint2 = Constraint::New( Actor::COLOR_ALPHA, + Source( actor1, Actor::COLOR_ALPHA ), + EqualToConstraint() ); + constraint2.SetRemoveAction( Constraint::Discard ); + actor2.ApplyConstraint( constraint2 ); + + actor1.SetOpacity(endOpacity); + + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( actor2.GetCurrentOpacity(), endOpacity, 0.000001f, TEST_LOCATION ); + + // + // Check Vector4 variant of constraint + // + actor1.SetColor( Color::GREEN ); + actor2.SetColor( Color::RED ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor1.GetCurrentColor() == Color::GREEN ); + DALI_TEST_CHECK( actor2.GetCurrentColor() == Color::RED ); + + Constraint constraint3 = Constraint::New( Actor::COLOR, + Source( actor1, Actor::COLOR ), + EqualToConstraint() ); + constraint3.SetRemoveAction( Constraint::Discard ); + actor2.ApplyConstraint( constraint3 ); + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor2.GetCurrentColor() == Color::GREEN ); + + // + // Check Quaternion variant of constraint + // + Quaternion q1 = Quaternion( Math::PI_2, Vector3::XAXIS ); + Quaternion q2 = Quaternion( Math::PI_4, Vector3::YAXIS ); + actor1.SetRotation( q1 ); + actor2.SetRotation( q2 ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor1.GetCurrentRotation(), q1, 0.01, TEST_LOCATION ); + DALI_TEST_EQUALS( actor2.GetCurrentRotation(), q2, 0.01, TEST_LOCATION ); + + Constraint constraint4 = Constraint::New( Actor::ROTATION, + Source( actor1, Actor::ROTATION ), + EqualToConstraint() ); + constraint4.SetRemoveAction( Constraint::Discard ); + actor2.ApplyConstraint( constraint4 ); + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor2.GetCurrentRotation(), q1, 0.01, TEST_LOCATION ); + + // + // Check Matrix3 variant + // + EqualToConstraint equalToConstraint; + + Matrix3 a; + a.AsFloat()[0] = 1.f; + Matrix3 b; + b.AsFloat()[0] = 2.f; + PropertyInputAbstraction pi(b); + + Matrix3 c = equalToConstraint(a,pi); + DALI_TEST_EQUALS( c.AsFloat()[0], b.AsFloat()[0], 0.01, TEST_LOCATION); + END_TEST; +} + +int UtcDaliBuiltinConstraintRelativeToConstraint(void) +{ + TestApplication application; + + Actor actor1 = Actor::New(); + Vector3 startPosition( 10, 10, 10 ); + actor1.SetPosition( startPosition ); + Stage::GetCurrent().Add( actor1 ); + + Actor actor2 = Actor::New(); + Vector3 startSize( 100, 100, 100 ); + actor2.SetSize( startSize ); + Stage::GetCurrent().Add( actor2 ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor1.GetCurrentPosition() == startPosition ); + DALI_TEST_CHECK( actor2.GetCurrentSize() == startSize ); + + // Apply constraint - actor1 size == actor2 position + + RelativeToConstraint( 0.f ); + Vector3 scale( 0.5, 0.6, 0.7 ); + Constraint constraint = Constraint::New( Actor::SIZE, + Source( actor1, Actor::POSITION ), + RelativeToConstraint( scale ) ); + constraint.SetRemoveAction( Constraint::Discard ); + actor2.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + DALI_TEST_EQUALS( actor2.GetCurrentSize(), scale * startPosition, TEST_LOCATION ); + + // Change the input + Vector3 endPosition( 2, 2, 2 ); + actor1.SetPosition( endPosition ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + DALI_TEST_EQUALS( actor2.GetCurrentSize(), scale * endPosition, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor2.GetCurrentSize(), scale * endPosition, TEST_LOCATION ); + + // + // Check float variant of constraint + // + float scale2( 0.5f ); + float startOpacity(1.0f); + actor1.SetOpacity( startOpacity ); + actor2.SetOpacity( startOpacity ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_EQUALS( actor1.GetCurrentOpacity(), startOpacity, TEST_LOCATION ); + DALI_TEST_EQUALS( actor2.GetCurrentOpacity(), startOpacity, TEST_LOCATION ); + + Constraint constraint2 = Constraint::New( Actor::COLOR_ALPHA, + Source( actor1, Actor::COLOR_ALPHA ), + RelativeToConstraintFloat(scale2) ); + constraint2.SetRemoveAction( Constraint::Discard ); + actor2.ApplyConstraint(constraint2); + application.SendNotification(); + application.Render(0); + + DALI_TEST_EQUALS( actor2.GetCurrentOpacity(), startOpacity * scale2, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliBuiltinConstraintInverseOfConstraint(void) +{ + TestApplication application; + + Actor actor1 = Actor::New(); + Vector3 startPosition( 10, 10, 10 ); + actor1.SetPosition( startPosition ); + Stage::GetCurrent().Add( actor1 ); + + Actor actor2 = Actor::New(); + Vector3 startSize( 100, 100, 100 ); + actor2.SetSize( startSize ); + Stage::GetCurrent().Add( actor2 ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor1.GetCurrentPosition() == startPosition ); + DALI_TEST_CHECK( actor2.GetCurrentSize() == startSize ); + + // Apply constraint - actor1 size == ( 1 / actor2 position ) + + Constraint constraint = Constraint::New( Actor::SIZE, + Source( actor1, Actor::POSITION ), + InverseOfConstraint() ); + constraint.SetRemoveAction( Constraint::Discard ); + actor2.ApplyConstraint( constraint ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + Vector3 size( 0.1, 0.1, 0.1 ); // 1 / startPosition + DALI_TEST_EQUALS( actor2.GetCurrentSize(), size, 0.00001f, TEST_LOCATION ); + + // Change the input + Vector3 endPosition( 2, 2, 2 ); + actor1.SetPosition( endPosition ); + + application.SendNotification(); + application.Render(0); + + // Constraint should be fully applied + size = Vector3( 0.5, 0.5, 0.5 ); // 1 / endPosition + DALI_TEST_EQUALS( actor2.GetCurrentSize(), size, TEST_LOCATION ); + application.Render(0); + DALI_TEST_EQUALS( actor2.GetCurrentSize(), size, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliBuiltinConstraintFunctions(void) +{ + TestApplication application; + + { + SourceWidthFixedHeight sourceWidthFixedHeight( 10.f ); + Vector3 current; + { + Vector3 reference(1, 10, 0); + Vector3 value = sourceWidthFixedHeight( current, PropertyInputAbstraction(Vector3::ONE) ); + DALI_TEST_EQUALS( reference, value, TEST_LOCATION ); + } + { + Vector3 reference(10, 10, 0); + Vector3 value = sourceWidthFixedHeight( current, PropertyInputAbstraction(Vector3::ONE*10.f) ); + DALI_TEST_EQUALS( reference, value, TEST_LOCATION ); + } + { + Vector3 reference(10,10,0); + Vector3 value = sourceWidthFixedHeight( current, PropertyInputAbstraction(Vector3::ONE*10.f) ); + DALI_TEST_EQUALS( reference, value, TEST_LOCATION ); + } + } + + { + SourceHeightFixedWidth sourceHeightFixedWidth( 10.f ); + Vector3 current; + { + Vector3 reference(10,1,0); + Vector3 value = sourceHeightFixedWidth( current, PropertyInputAbstraction(Vector3::ONE) ); + DALI_TEST_EQUALS( reference, value, TEST_LOCATION ); + } + { + Vector3 reference(10,10,0); + Vector3 value = sourceHeightFixedWidth( current, PropertyInputAbstraction(Vector3::ONE*10.f) ); + DALI_TEST_EQUALS( reference, value, TEST_LOCATION ); + } + { + Vector3 reference(10,100,0); + Vector3 value = sourceHeightFixedWidth( current, PropertyInputAbstraction(Vector3::ONE*100.f) ); + DALI_TEST_EQUALS( reference, value, TEST_LOCATION ); + } + } + + { // LookAt + Quaternion current(0, Vector3::YAXIS); + PropertyInputAbstraction target(Vector3::ZAXIS); + PropertyInputAbstraction targetRotation(Vector3::YAXIS); + PropertyInputAbstraction camera(Vector3::ZERO); + + { + Quaternion reference(1., 0., 0., 0.); + Quaternion value = LookAt( current, target, camera, targetRotation ); + DALI_TEST_EQUALS( reference, value, 0.001, TEST_LOCATION ); + } + + { + OrientedLookAt orientedLookAt(90.f); + Quaternion reference(.525322, 0., 0., 0.850904); + Quaternion value = orientedLookAt( current, target, camera, targetRotation ); + DALI_TEST_EQUALS( reference, value, 0.001, TEST_LOCATION ); + } + } + + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-CustomActor.cpp b/automated-tests/src/dali/utc-Dali-CustomActor.cpp new file mode 100644 index 0000000..e822573 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-CustomActor.cpp @@ -0,0 +1,1577 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 +#include + +#include "dali-test-suite-utils/dali-test-suite-utils.h" + +using namespace Dali; + + +void custom_actor_test_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void custom_actor_test_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ + +std::vector< std::string > MasterCallStack; + +} // anon namespace + +// TypeRegistry needs custom actor Implementations to have the same name (namespaces are ignored so we use one here) +namespace Impl +{ + +struct TestCustomActor : public CustomActorImpl +{ + /** + * Constructor + */ + TestCustomActor() + : CustomActorImpl( true ), // requires touch + mDaliProperty( Property::INVALID_INDEX ), + mSizeSet( Vector3::ZERO ), + mTargetSize( Vector3::ZERO ) + { + SetRequiresMouseWheelEvents(true); + } + + /** + * Destructor + */ + virtual ~TestCustomActor() + { + } + + void Initialize( const char* name = NULL ) + { + mDaliProperty = Self().RegisterProperty( "Dali", std::string("no"), Property::READ_WRITE); + + OnInitialize( name ); + } + + virtual void OnInitialize( const char* name ) {} + + /** + * Resets the call stack + */ + void ResetCallStack() + { + mSizeSet = Vector3(); + mTargetSize = Vector3(); + mMethodsCalled.clear(); + } + + void AddToCallStacks( const char* method ) + { + mMethodsCalled.push_back( method ); + + // Combine Actor name with method string + std::string nameAndMethod( Self().GetName() ); + if ( 0 == nameAndMethod.size() ) + { + nameAndMethod = "Unknown: "; + } + else + { + nameAndMethod += ": "; + } + nameAndMethod += method; + + MasterCallStack.push_back( nameAndMethod ); + } + + // From CustomActorImpl + virtual void OnStageConnection() + { + AddToCallStacks("OnStageConnection"); + } + virtual void OnStageDisconnection() + { + AddToCallStacks("OnStageDisconnection"); + } + virtual void OnChildAdd(Actor& child) + { + AddToCallStacks("OnChildAdd"); + } + virtual void OnChildRemove(Actor& child) + { + AddToCallStacks("OnChildRemove"); + } + virtual void OnPropertySet( Property::Index index, Property::Value propertyValue ) + { + AddToCallStacks("OnPropertySet"); + } + virtual void OnSizeSet(const Vector3& targetSize) + { + mSizeSet = targetSize; + AddToCallStacks("OnSizeSet"); + } + virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize) + { + mTargetSize = targetSize; + AddToCallStacks("OnSizeAnimation"); + } + virtual bool OnTouchEvent(const TouchEvent& event) + { + AddToCallStacks("OnTouchEvent"); + return true; + } + virtual bool OnMouseWheelEvent(const MouseWheelEvent& event) + { + AddToCallStacks("OnMouseWheelEvent"); + return true; + } + virtual bool OnKeyEvent(const KeyEvent& event) + { + AddToCallStacks("OnKeyEvent"); + return true; + } + virtual void OnKeyInputFocusGained() + { + AddToCallStacks("OnKeyInputFocusGained"); + } + virtual void OnKeyInputFocusLost() + { + AddToCallStacks("OnKeyInputFocusLost"); + } + virtual Actor GetChildByAlias(const std::string& actorAlias) + { + AddToCallStacks("GetChildByAlias"); + + if ("found" == actorAlias) + { + return Actor::New(); + } + else + { + return Actor(); + } + } + + void SetDaliProperty(std::string s) + { + Self().SetProperty(mDaliProperty, s) ; + } + + Property::Index mDaliProperty; + std::vector< std::string > mMethodsCalled; + Vector3 mSizeSet; + Vector3 mTargetSize; +}; + +/** + * Variant which adds a new child during OnStageConnection + */ +struct TestCustomActorVariant1 : public TestCustomActor +{ + /** + * Constructor + */ + TestCustomActorVariant1( Actor childToAdd ) + : mChildToAdd( childToAdd ) + { + } + + // From CustomActorImpl + virtual void OnStageConnection() + { + // Chain up first + TestCustomActor::OnStageConnection(); + + // Add the child + Self().Add( mChildToAdd ); + } + + Actor mChildToAdd; +}; + +/** + * Variant which removes children during OnStageConnection + */ +struct TestCustomActorVariant2 : public TestCustomActor +{ + /** + * Constructor + */ + TestCustomActorVariant2() + { + } + + // From CustomActorImpl + virtual void OnStageConnection() + { + // Chain up first + TestCustomActor::OnStageConnection(); + + // Remove all the children + for( unsigned int i=0, num=Self().GetChildCount(); iInitialize(); + + return custom; + } + + static TestCustomActor NewVariant1( Actor childToAdd ) + { + Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant1( childToAdd ); + TestCustomActor custom( *impl ); // takes ownership + + impl->Initialize(); + + return custom; + } + + static TestCustomActor NewVariant2() + { + Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant2(); + TestCustomActor custom( *impl ); // takes ownership + + impl->Initialize(); + + return custom; + } + + static TestCustomActor NewVariant3( Actor childToAdd ) + { + Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant3( childToAdd ); + TestCustomActor custom( *impl ); // takes ownership + + impl->Initialize(); + + return custom; + } + + static TestCustomActor NewVariant4() + { + Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant4(); + TestCustomActor custom( *impl ); // takes ownership + + impl->Initialize(); + + return custom; + } + + static TestCustomActor NewVariant5() + { + Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant5(); + TestCustomActor custom( *impl ); // takes ownership + + impl->Initialize(); + + return custom; + } + + static TestCustomActor NewVariant6() + { + Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant6(); + TestCustomActor custom( *impl ); // takes ownership + + impl->Initialize(); + + return custom; + } + + static TestCustomActor NewVariant7( const char* name ) + { + Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant7(); + TestCustomActor custom( *impl ); // takes ownership + + impl->Initialize( name ); + + return custom; + } + + static TestCustomActor NewVariant8( Actor rival ) + { + Impl::TestCustomActor* impl = new Impl::TestCustomActorVariant8( rival ); + TestCustomActor custom( *impl ); // takes ownership + + impl->Initialize(); + + return custom; + } + + virtual ~TestCustomActor() + { + } + + Impl::TestCustomActor& GetImpl() + { + return static_cast(GetImplementation()); + } + + std::vector< std::string >& GetMethodsCalled() + { + return GetImpl().mMethodsCalled; + } + + void ResetCallStack() + { + GetImpl().ResetCallStack(); + } + + void SetDaliProperty(std::string s) + { + GetImpl().SetDaliProperty(s); + } + + Vector3 GetSize() + { + return GetImpl().mSizeSet; + } + + Vector3 GetTargetSize() + { + return GetImpl().mTargetSize; + } + +private: + + TestCustomActor( Impl::TestCustomActor& impl ) : CustomActor( impl ) + { + } +}; + + +BaseHandle CreateActor() +{ + return TestCustomActor::New(); +} + +} // anon namespace + + +int UtcDaliCustomActorDestructor(void) +{ + TestApplication application; + + CustomActor* actor = new CustomActor(); + delete actor; + + DALI_TEST_CHECK( true ); + END_TEST; +} + +int UtcDaliCustomActorImplDestructor(void) +{ + TestApplication application; + CustomActorImpl* actor = new Impl::TestCustomActor(); + delete actor; + + DALI_TEST_CHECK( true ); + END_TEST; +} + +// Positive test case for a method +int UtcDaliCustomActorDownCast(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CustomActor::DownCast()"); + + TestCustomActor custom = TestCustomActor::New(); + + Actor anActor = Actor::New(); + anActor.Add( custom ); + + Actor child = anActor.GetChildAt(0); + CustomActor customActor = CustomActor::DownCast( child ); + DALI_TEST_CHECK( customActor ); + + customActor = NULL; + DALI_TEST_CHECK( !customActor ); + + customActor = DownCast< CustomActor >( child ); + DALI_TEST_CHECK( customActor ); + END_TEST; +} + +// Negative test case for a method +int UtcDaliCustomActorDownCastNegative(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CustomActor::DownCast()"); + + Actor actor1 = Actor::New(); + Actor anActor = Actor::New(); + anActor.Add(actor1); + + Actor child = anActor.GetChildAt(0); + CustomActor customActor = CustomActor::DownCast( child ); + DALI_TEST_CHECK( !customActor ); + + Actor unInitialzedActor; + customActor = CustomActor::DownCast( unInitialzedActor ); + DALI_TEST_CHECK( !customActor ); + + customActor = DownCast< CustomActor >( unInitialzedActor ); + DALI_TEST_CHECK( !customActor ); + END_TEST; +} + +int UtcDaliCustomActorOnStageConnectionDisconnection(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CustomActor::OnStageConnection() & OnStageDisconnection"); + + TestCustomActor custom = TestCustomActor::New(); + DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION ); + + // add the custom actor to stage + Stage::GetCurrent().Add( custom ); + + DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageConnection", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + + Stage::GetCurrent().Remove( custom ); + + DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageDisconnection", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION ); + + // Excercise the message passing to Update thread + + application.SendNotification(); + application.Render(); + application.Render(); + END_TEST; +} + +int UtcDaliCustomActorOnStageConnectionOrder(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CustomActor::OnStageConnection() order"); + + MasterCallStack.clear(); + + /* Build tree of actors: + * + * A (parent) + * / \ + * B C + * / \ \ + * D E F + * + * OnStageConnection should be received for A, B, D, E, C, and finally F + */ + + TestCustomActor actorA = TestCustomActor::New(); + actorA.SetName( "ActorA" ); + + TestCustomActor actorB = TestCustomActor::New(); + actorB.SetName( "ActorB" ); + actorA.Add( actorB ); + + TestCustomActor actorC = TestCustomActor::New(); + actorC.SetName( "ActorC" ); + actorA.Add( actorC ); + + TestCustomActor actorD = TestCustomActor::New(); + actorD.SetName( "ActorD" ); + actorB.Add( actorD ); + + TestCustomActor actorE = TestCustomActor::New(); + actorE.SetName( "ActorE" ); + actorB.Add( actorE ); + + TestCustomActor actorF = TestCustomActor::New(); + actorF.SetName( "ActorF" ); + actorC.Add( actorF ); + + // add the custom actor to stage + Stage::GetCurrent().Add( actorA ); + + DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); + + DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION ); + + DALI_TEST_EQUALS( 2, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnChildAdd", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageConnection", actorC.GetMethodsCalled()[ 1 ], TEST_LOCATION ); + + DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageConnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + + DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageConnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + + DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageConnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + + // Check sequence is correct in MasterCallStack + + DALI_TEST_EQUALS( 3+3+2+1+1+1, (int)(MasterCallStack.size()), TEST_LOCATION ); + + DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 3 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorC: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION ); + + DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 5 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 6 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorD: OnStageConnection", MasterCallStack[ 7 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorE: OnStageConnection", MasterCallStack[ 8 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorC: OnStageConnection", MasterCallStack[ 9 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorF: OnStageConnection", MasterCallStack[ 10 ], TEST_LOCATION ); + + // Excercise the message passing to Update thread + + application.SendNotification(); + application.Render(); + application.Render(); + END_TEST; +} + +int UtcDaliCustomActorOnStageDisconnectionOrder(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CustomActor::OnStageDisconnection() order"); + + Stage stage = Stage::GetCurrent(); + + /* Build tree of actors: + * + * A (parent) + * / \ + * B C + * / \ \ + * D E F + * + * OnStageDisconnection should be received for D, E, B, F, C, and finally A. + */ + + TestCustomActor actorA = TestCustomActor::New(); + actorA.SetName( "ActorA" ); + stage.Add( actorA ); + + TestCustomActor actorB = TestCustomActor::New(); + actorB.SetName( "ActorB" ); + actorA.Add( actorB ); + + TestCustomActor actorC = TestCustomActor::New(); + actorC.SetName( "ActorC" ); + actorA.Add( actorC ); + + TestCustomActor actorD = TestCustomActor::New(); + actorD.SetName( "ActorD" ); + actorB.Add( actorD ); + + TestCustomActor actorE = TestCustomActor::New(); + actorE.SetName( "ActorE" ); + actorB.Add( actorE ); + + TestCustomActor actorF = TestCustomActor::New(); + actorF.SetName( "ActorF" ); + actorC.Add( actorF ); + + // Excercise the message passing to Update thread + + application.SendNotification(); + application.Render(); + application.Render(); + + // Clear call stacks before disconnection + actorA.ResetCallStack(); + actorB.ResetCallStack(); + actorC.ResetCallStack(); + actorD.ResetCallStack(); + actorE.ResetCallStack(); + actorF.ResetCallStack(); + MasterCallStack.clear(); + + stage.Remove( actorA ); + + DALI_TEST_EQUALS( 1, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + + DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + + DALI_TEST_EQUALS( 1, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageDisconnection", actorC.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + + DALI_TEST_EQUALS( 1, (int)(actorD.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageDisconnection", actorD.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + + DALI_TEST_EQUALS( 1, (int)(actorE.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageDisconnection", actorE.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + + DALI_TEST_EQUALS( 1, (int)(actorF.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageDisconnection", actorF.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + + // Check sequence is correct in MasterCallStack + + DALI_TEST_EQUALS( 6, (int)(MasterCallStack.size()), TEST_LOCATION ); + + DALI_TEST_EQUALS( "ActorD: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorE: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 2 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorF: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorC: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 5 ], TEST_LOCATION ); + + // Excercise the message passing to Update thread + + application.SendNotification(); + application.Render(); + application.Render(); + END_TEST; +} + +int UtcDaliCustomActorAddDuringOnStageConnection(void) +{ + TestApplication application; + tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageConnection() callback"); + + Stage stage = Stage::GetCurrent(); + + MasterCallStack.clear(); + + /* The actorA is a special variant which adds a child to itself during OnStageConnection() + * The actorB is provided as the child + */ + + TestCustomActor actorB = TestCustomActor::New(); + actorB.SetName( "ActorB" ); + + TestCustomActor actorA = TestCustomActor::NewVariant1( actorB ); + actorA.SetName( "ActorA" ); + stage.Add( actorA ); + + // Check callback sequence + + DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION ); // Called from within OnStageConnection() + + DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + + DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION ); + + DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION ); // Occurs during Actor::Add from within from within OnStageConnection() + DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION ); // Occurs after Actor::Add from within from within OnStageConnection() + + // Excercise the message passing to Update thread + + application.SendNotification(); + application.Render(); + application.Render(); + + // Check everything is ok after Actors are removed + + stage.Remove( actorA ); + application.SendNotification(); + application.Render(); + application.Render(); + END_TEST; +} + +int UtcDaliCustomActorRemoveDuringOnStageConnection(void) +{ + TestApplication application; + tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageConnection() callback"); + + Stage stage = Stage::GetCurrent(); + + MasterCallStack.clear(); + + /* The actorA is a special variant which removes its children during OnStageConnection() + * Actors B & C are provided as the children + */ + + TestCustomActor actorA = TestCustomActor::NewVariant2(); + actorA.SetName( "ActorA" ); + + TestCustomActor actorB = TestCustomActor::New(); + actorB.SetName( "ActorB" ); + actorA.Add( actorB ); + + TestCustomActor actorC = TestCustomActor::New(); + actorC.SetName( "ActorC" ); + actorA.Add( actorC ); + + stage.Add( actorA ); + + // Check callback sequence + + DALI_TEST_EQUALS( 5, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION ); // Called from within OnStageConnection() + DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 4 ], TEST_LOCATION ); // Called from within OnStageConnection() + + DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION ); + + DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 3 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 4 ], TEST_LOCATION ); + + /* Actors B & C should be removed before the point where they could receive an OnStageConnection callback + * Therefore they shouldn't receive either OnStageConnection or OnStageDisconnection + */ + DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( 0, (int)(actorC.GetMethodsCalled().size()), TEST_LOCATION ); + + // Excercise the message passing to Update thread + + application.SendNotification(); + application.Render(); + application.Render(); + + // Check everything is ok after last actor is removed + + stage.Remove( actorA ); + application.SendNotification(); + application.Render(); + application.Render(); + END_TEST; +} + +int UtcDaliCustomActorAddDuringOnStageDisconnection(void) +{ + TestApplication application; + tet_infoline("Testing Actor::Add behaviour during Dali::CustomActor::OnStageDisonnection() callback"); + + Stage stage = Stage::GetCurrent(); + + /* The actorA is a special variant which adds a child to itself during OnStageDisconnection() + * The actorB is provided as the child + */ + + TestCustomActor actorB = TestCustomActor::New(); + actorB.SetName( "ActorB" ); + + TestCustomActor actorA = TestCustomActor::NewVariant3( actorB ); + actorA.SetName( "ActorA" ); + stage.Add( actorA ); + + // Excercise the message passing to Update thread + + application.SendNotification(); + application.Render(); + application.Render(); + + // Clear call stacks before disconnection + actorA.ResetCallStack(); + actorB.ResetCallStack(); + MasterCallStack.clear(); + + stage.Remove( actorA ); + + // Check callback sequence + + DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION ); + + // Child was added after parent disconnection, so should not receive OnStageConnection() + DALI_TEST_EQUALS( 0, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION ); + + DALI_TEST_EQUALS( 2, (int)(MasterCallStack.size()), TEST_LOCATION ); + + DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 1 ], TEST_LOCATION ); + + // Excercise the message passing to Update thread + + application.SendNotification(); + application.Render(); + application.Render(); + END_TEST; +} + +int UtcDaliCustomActorRemoveDuringOnStageDisconnection(void) +{ + TestApplication application; + tet_infoline("Testing Actor::Remove behaviour during Dali::CustomActor::OnStageDisconnection() callback"); + + Stage stage = Stage::GetCurrent(); + + /* The actorA is a special variant which removes its children during OnStageDisconnection() + * The actorB is provided as the child + */ + + TestCustomActor actorA = TestCustomActor::NewVariant4(); + actorA.SetName( "ActorA" ); + stage.Add( actorA ); + + TestCustomActor actorB = TestCustomActor::New(); + actorB.SetName( "ActorB" ); + actorA.Add( actorB ); + + // Excercise the message passing to Update thread + + application.SendNotification(); + application.Render(); + application.Render(); + + // Clear call stacks before disconnection + actorA.ResetCallStack(); + actorB.ResetCallStack(); + MasterCallStack.clear(); + + stage.Remove( actorA ); + + // Check callback sequence + + DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION ); + + DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + + DALI_TEST_EQUALS( 3, (int)(MasterCallStack.size()), TEST_LOCATION ); + + DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 1 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 2 ], TEST_LOCATION ); + + // Excercise the message passing to Update thread + + application.SendNotification(); + application.Render(); + application.Render(); + END_TEST; +} + +int UtcDaliCustomActorRemoveParentDuringOnStageConnection(void) +{ + TestApplication application; + tet_infoline("Weird test where child removes its own parent from Stage during Dali::CustomActor::OnStageConnection() callback"); + + Stage stage = Stage::GetCurrent(); + + MasterCallStack.clear(); + + /* The actorA is the parent of actorB + * The actorB is a special variant which removes its own parent during OnStageConnection() + * The child actor is interrupting the parent's connection to stage, therefore the parent should not get an OnStageDisconnection() + */ + + TestCustomActor actorA = TestCustomActor::New(); + actorA.SetName( "ActorA" ); + + TestCustomActor actorB = TestCustomActor::NewVariant5(); + actorB.SetName( "ActorB" ); + actorA.Add( actorB ); + + stage.Add( actorA ); + + // Check callback sequence + + DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageDisconnection", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); + + DALI_TEST_EQUALS( 1, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + + DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION ); + + DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorA: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION ); + + // Excercise the message passing to Update thread + + application.SendNotification(); + application.Render(); + application.Render(); + END_TEST; +} + +int UtcDaliCustomActorAddParentDuringOnStageDisconnection(void) +{ + TestApplication application; + tet_infoline("Weird test where child adds its own parent to Stage during Dali::CustomActor::OnStageDisconnection() callback"); + + Stage stage = Stage::GetCurrent(); + + MasterCallStack.clear(); + + /* The actorA is the parent of actorB + * The actorB is a special variant which (weirdly) adds its own parent during OnStageDisconnection() + * The child actor is interrupting the disconnection, such that parent should not get a OnStageDisconnection() + */ + + TestCustomActor actorA = TestCustomActor::New(); + actorA.SetName( "ActorA" ); + stage.Add( actorA ); + + TestCustomActor actorB = TestCustomActor::NewVariant6(); + actorB.SetName( "ActorB" ); + actorA.Add( actorB ); + + stage.Remove( actorA ); + + // Check callback sequence + + DALI_TEST_EQUALS( 2, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION ); + + DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION ); + // Disconnect was interrupted, so we should only get one OnStageConnection() for actorB + + DALI_TEST_EQUALS( 4, (int)(MasterCallStack.size()), TEST_LOCATION ); + + DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 3 ], TEST_LOCATION ); + + // Excercise the message passing to Update thread + + application.SendNotification(); + application.Render(); + application.Render(); + END_TEST; +} + +int UtcDaliCustomActorOnChildAddRemove(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CustomActor::OnChildAdd() & OnChildRemove()"); + + TestCustomActor custom = TestCustomActor::New(); + DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION ); + + Actor aChild = Actor::New(); + custom.Add( aChild ); + + DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnChildAdd", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + + custom.Remove( aChild ); + + DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnChildRemove", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION ); + END_TEST; +} + +int UtcDaliCustomActorReparentDuringOnChildAdd(void) +{ + TestApplication application; + tet_infoline("Testing Actor:Add (reparenting) behaviour during Dali::CustomActor::OnChildAdd() callback"); + + Stage stage = Stage::GetCurrent(); + + MasterCallStack.clear(); + + /* The actorA is a special variant which reparents children added into a separate container child + * The actorB is the child of actorA + */ + + TestCustomActor actorA = TestCustomActor::NewVariant7( "ActorA" ); + stage.Add( actorA ); + + TestCustomActor actorB = TestCustomActor::New(); + actorB.SetName( "ActorB" ); + actorA.Add( actorB ); + + // Check hierarchy is as follows: + // A + // | + // Container + // | + // B + + DALI_TEST_EQUALS( 1, (int)(actorA.GetChildCount()), TEST_LOCATION ); + + Actor container = actorA.GetChildAt(0); + Actor containerChild; + + DALI_TEST_CHECK( container ); + if ( container ) + { + DALI_TEST_EQUALS( "Container", container.GetName(), TEST_LOCATION ); + DALI_TEST_EQUALS( 1, (int)(container.GetChildCount()), TEST_LOCATION ); + containerChild = container.GetChildAt(0); + } + + DALI_TEST_CHECK( containerChild ); + if ( containerChild ) + { + DALI_TEST_EQUALS( "ActorB", containerChild.GetName(), TEST_LOCATION ); + DALI_TEST_EQUALS( 0, (int)(containerChild.GetChildCount()), TEST_LOCATION ); + } + + // Check callback sequence + + DALI_TEST_EQUALS( 4, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA + DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA + DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 3 ], TEST_LOCATION ); + // mContainer will then receive OnChildAdd + + DALI_TEST_EQUALS( 3, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageDisconnection", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 2 ], TEST_LOCATION ); + + DALI_TEST_EQUALS( 7, (int)(MasterCallStack.size()), TEST_LOCATION ); + + DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 2 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 3 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorB: OnStageDisconnection", MasterCallStack[ 4 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 5 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 6 ], TEST_LOCATION ); + + // Excercise the message passing to Update thread + + application.SendNotification(); + application.Render(); + application.Render(); + END_TEST; +} + +/** + * Test that Remove can be called (a NOOP) during the OnChildRemove + * triggered when reparenting an actor + */ +int UtcDaliCustomActorRemoveDuringOnChildRemove(void) +{ + TestApplication application; + tet_infoline("Testing Actor:Remove behaviour during OnChildRemove() callback triggered when reparenting"); + + Stage stage = Stage::GetCurrent(); + + MasterCallStack.clear(); + + /* The childActor will be reparented from actorA to actorB + * The actorA is a special variant which attempts to remove a child from actorB, during the OnChildRemove callback() + * This should be a NOOP since the reparenting has not occured yet + */ + + TestCustomActor actorB = TestCustomActor::New(); + actorB.SetName( "ActorB" ); + stage.Add( actorB ); + + TestCustomActor actorA = TestCustomActor::NewVariant8( actorB ); + actorA.SetName( "ActorA" ); + stage.Add( actorA ); + + Actor childActor = Actor::New(); + childActor.SetName( "Child" ); + // Reparent from actorA to actorB + actorA.Add( childActor ); + actorB.Add( childActor ); + + // Check hierarchy is as follows: + // A B + // | + // Child + + DALI_TEST_EQUALS( 0, (int)(actorA.GetChildCount()), TEST_LOCATION ); + DALI_TEST_EQUALS( 1, (int)(actorB.GetChildCount()), TEST_LOCATION ); + DALI_TEST_EQUALS( 0, (int)(childActor.GetChildCount()), TEST_LOCATION ); + + Actor child = actorB.GetChildAt(0); + + DALI_TEST_CHECK( child ); + if ( child ) + { + DALI_TEST_EQUALS( "Child", child.GetName(), TEST_LOCATION ); + } + + // Check callback sequence + + DALI_TEST_EQUALS( 3, (int)(actorA.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageConnection", actorA.GetMethodsCalled()[ 0 ], TEST_LOCATION ); // The mContainer added to actorA + DALI_TEST_EQUALS( "OnChildAdd", actorA.GetMethodsCalled()[ 1 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "OnChildRemove", actorA.GetMethodsCalled()[ 2 ], TEST_LOCATION ); // The actorB added to actorA + // mContainer will then receive OnChildAdd + + DALI_TEST_EQUALS( 2, (int)(actorB.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnStageConnection", actorB.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "OnChildAdd", actorB.GetMethodsCalled()[ 1 ], TEST_LOCATION ); + + DALI_TEST_EQUALS( 5, (int)(MasterCallStack.size()), TEST_LOCATION ); + + DALI_TEST_EQUALS( "ActorB: OnStageConnection", MasterCallStack[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorA: OnStageConnection", MasterCallStack[ 1 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorA: OnChildAdd", MasterCallStack[ 2 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorA: OnChildRemove", MasterCallStack[ 3 ], TEST_LOCATION ); + DALI_TEST_EQUALS( "ActorB: OnChildAdd", MasterCallStack[ 4 ], TEST_LOCATION ); + + // Excercise the message passing to Update thread + + application.SendNotification(); + application.Render(); + application.Render(); + END_TEST; +} + +int UtcDaliCustomActorOnPropertySet(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CustomActor::OnPropertySet()"); + + TestCustomActor custom = TestCustomActor::New(); + DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION ); + + custom.SetDaliProperty("yes") ; + + DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnPropertySet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + END_TEST; +} + +int UtcDaliCustomActorOnSizeSet(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CustomActor::OnSizeSet()"); + + TestCustomActor custom = TestCustomActor::New(); + DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION ); + + custom.SetSize( Vector2( 9.0f, 10.0f ) ); + DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( 9.0f, custom.GetSize().width, TEST_LOCATION ); + DALI_TEST_EQUALS( 10.0f, custom.GetSize().height, TEST_LOCATION ); + + custom.SetSize( Vector3( 4.0f, 5.0f, 6.0f ) ); + DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnSizeSet", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION ); + DALI_TEST_EQUALS( 4.0f, custom.GetSize().width, TEST_LOCATION ); + DALI_TEST_EQUALS( 5.0f, custom.GetSize().height, TEST_LOCATION ); + DALI_TEST_EQUALS( 6.0f, custom.GetSize().depth, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliCustomActorOnSizeAnimation(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CustomActor::OnSizeAnimation()"); + + TestCustomActor custom = TestCustomActor::New(); + DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION ); + + Animation anim = Animation::New( 1.0f ); + anim.Resize( custom, Vector3( 8.0f, 9.0f, 10.0f ) ); + DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + DALI_TEST_EQUALS( 8.0f, custom.GetTargetSize().width, TEST_LOCATION ); + DALI_TEST_EQUALS( 9.0f, custom.GetTargetSize().height, TEST_LOCATION ); + DALI_TEST_EQUALS( 10.0f, custom.GetTargetSize().depth, TEST_LOCATION ); + + anim.Resize( custom, 1.0f, 2.0f ); + DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION ); + DALI_TEST_EQUALS( 1.0f, custom.GetTargetSize().width, TEST_LOCATION ); + DALI_TEST_EQUALS( 2.0f, custom.GetTargetSize().height, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliCustomActorOnTouchEvent(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CustomActor::OnTouchEvent()"); + + TestCustomActor custom = TestCustomActor::New(); + DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION ); + + // set size for custom actor + custom.SetSize( 100, 100 ); + // add the custom actor to stage + Stage::GetCurrent().Add( custom ); + custom.ResetCallStack(); + + // Render and notify a couple of times + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + + // simulate a touch event + Dali::TouchPoint point( 0, TouchPoint::Down, 1, 1 ); + Dali::Integration::TouchEvent event; + event.AddPoint( point ); + application.ProcessEvent( event ); + + DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnTouchEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + END_TEST; +} + +int UtcDaliCustomActorOnMouseWheelEvent(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CustomActor::OnMouseWheelEvent()"); + + TestCustomActor custom = TestCustomActor::New(); + DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION ); + + // set size for custom actor + custom.SetSize( 100, 100 ); + // add the custom actor to stage + Stage::GetCurrent().Add( custom ); + custom.ResetCallStack(); + + // Render and notify a couple of times + application.SendNotification(); + application.Render(); + application.SendNotification(); + application.Render(); + + // simulate a mouse wheel event + Vector2 screenCoordinates( 10.0f, 10.0f ); + Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u); + application.ProcessEvent( event ); + + DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "OnMouseWheelEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION ); + END_TEST; +} + +int UtcDaliCustomActorFindChildByAlias(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CustomActor::GetChildByAlias()"); + + TestCustomActor custom = TestCustomActor::New(); + DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION ); + + custom.Add(Actor::New()); + + DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION ); + + DALI_TEST_CHECK( !custom.FindChildByAlias("not-found") ); + + DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION ); + DALI_TEST_EQUALS( "GetChildByAlias", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION ); + + DALI_TEST_CHECK( custom.FindChildByAlias("found") ); + END_TEST; +} + +int UtcDaliCustomActorImplOnPropertySet(void) +{ + TestApplication application; + CustomActorImpl* impl = new Impl::SimpleTestCustomActor(); + + impl->OnPropertySet( 0, 0 ); + + DALI_TEST_CHECK( true ); + + delete impl; + END_TEST; +} + +int UtcDaliCustomActorGetImplementation(void) +{ + TestApplication application; + + TestCustomActor custom = TestCustomActor::New(); + CustomActorImpl& impl = custom.GetImplementation(); + impl.GetOwner(); // Test + + const TestCustomActor constCustom = TestCustomActor::New(); + const CustomActorImpl& constImpl = constCustom.GetImplementation(); + constImpl.GetOwner(); // Test + + DALI_TEST_CHECK( true ); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Degree.cpp b/automated-tests/src/dali/utc-Dali-Degree.cpp new file mode 100644 index 0000000..c4e0817 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-Degree.cpp @@ -0,0 +1,151 @@ +#include + +#include +#include +#include + +using namespace Dali; + +void utc_dali_degree_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_degree_cleanup(void) +{ + test_return_value = TET_PASS; +} + + +// Positive test case for constructors +int UtcDaliDegreeConstructors01(void) +{ + TestApplication application; + + // Default constructor, does not initialise the value + Degree degree0( 0.0f ); + + // Test float assignment operator + degree0 = 180.0f; + DALI_TEST_EQUALS( float(degree0), 180.0f, 0.001f, TEST_LOCATION ); + + // Constructor from float value + Degree degree1( 180.0f ); + DALI_TEST_EQUALS( float(degree1), 180.0f, 0.001f, TEST_LOCATION ); + + // Constructor from a Radian + Degree degree2( Radian( Math::PI ) ); + DALI_TEST_EQUALS( float(degree2), 180.0f, 0.001f, TEST_LOCATION ); + + // Assignment from Radian + Degree degree3( 0.0f ); + degree3 = Radian( Math::PI ); + DALI_TEST_EQUALS( float(degree3), 180.0f, 0.001f, TEST_LOCATION ); + END_TEST; +} + +// Positive test case for comparison +int UtcDaliDegreeComparison01(void) +{ + TestApplication application; + + // Comparison between radians + Degree degree0( 90.0f ); + Degree degree1( 90.0f ); + Degree degree2( 180.0f ); + + DALI_TEST_CHECK( degree0 == degree1 ); + DALI_TEST_CHECK( degree0 != degree2 ); + + // Comparison between radian to degree + Degree degree3( 180.0f ); + Degree degree4( 90.0f ); + Radian radian0( Math::PI ); + + DALI_TEST_CHECK( degree3 == radian0 ); + DALI_TEST_CHECK( degree4 != radian0 ); + + // Comparison with float + Degree degree5( 90.0f ); + + DALI_TEST_CHECK( degree5 == 90.0f ); + DALI_TEST_CHECK( degree5 != 180.0f ); + + END_TEST; +} + + +// test case for cast operators +int UtcDaliDegreeCastOperators01(void) +{ + TestApplication application; // Exceptions require TestApplication + + Degree degree0( 180.0f ); + + const float& value0( degree0 ); + DALI_TEST_EQUALS( value0, 180.0f, 0.001f, TEST_LOCATION ); + + degree0 = 90.0f; + DALI_TEST_EQUALS( value0, 90.0f, 0.001f, TEST_LOCATION ); + + float& value1( degree0 ); + DALI_TEST_EQUALS( value1, 90.0f, 0.001f, TEST_LOCATION ); + + value1 = 180.0f; + DALI_TEST_EQUALS( float(degree0), 180.0f, 0.001f, TEST_LOCATION ); + END_TEST; +} + + + +int UtcDaliDegreeCastOperatorEquals(void) +{ + TestApplication application; + + Degree a(90.0f); + Degree b(90.0f); + Degree c(180.0f); + + DALI_TEST_EQUALS(a == a, true, TEST_LOCATION); + DALI_TEST_EQUALS(a == b, true, TEST_LOCATION); + DALI_TEST_EQUALS(a == c, false, TEST_LOCATION); + END_TEST; +} + +int UtcDaliDegreeCastOperatorNotEquals(void) +{ + TestApplication application; + + Degree a(90.0f); + Degree b(90.0f); + Degree c(180.0f); + + DALI_TEST_EQUALS(a != a, false, TEST_LOCATION); + DALI_TEST_EQUALS(a != b, false, TEST_LOCATION); + DALI_TEST_EQUALS(a != c, true, TEST_LOCATION); + END_TEST; +} + +int UtcDaliDegreeCastOperatorLessThan(void) +{ + TestApplication application; + + Degree a(45.0f); + Degree b(90.0f); + Degree c(180.0f); + Degree d(360.0f); + Degree e(-180.0f); + + DALI_TEST_EQUALS(a < a, false, TEST_LOCATION); + DALI_TEST_EQUALS(a < b, true, TEST_LOCATION); + DALI_TEST_EQUALS(a < c, true, TEST_LOCATION); + DALI_TEST_EQUALS(a < d, true, TEST_LOCATION); + DALI_TEST_EQUALS(a < e, false, TEST_LOCATION); + + DALI_TEST_EQUALS(b < a, false, TEST_LOCATION); + DALI_TEST_EQUALS(b < b, false, TEST_LOCATION); + DALI_TEST_EQUALS(c < b, false, TEST_LOCATION); + DALI_TEST_EQUALS(d < b, false, TEST_LOCATION); + DALI_TEST_EQUALS(e < b, true, TEST_LOCATION); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-EventProcessing.cpp b/automated-tests/src/dali/utc-Dali-EventProcessing.cpp new file mode 100644 index 0000000..62e6bf96 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-EventProcessing.cpp @@ -0,0 +1,86 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 +#include + +using namespace Dali; + +void utc_dali_event_processing_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_event_processing_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ + +struct InvalidEvent : public Integration::Event +{ + InvalidEvent() : Event( Event::Type(-1000) ) {} + ~InvalidEvent() {} +}; + +struct InvalidGesture : public Integration::GestureEvent +{ + InvalidGesture() : GestureEvent( Gesture::Type(-1000), Gesture::Clear ) {} + ~InvalidGesture() {} +}; + +} // anon namespace + +int UtcDaliInvalidEvent(void) +{ + TestApplication application; + + try + { + InvalidEvent event; + application.ProcessEvent( event ); + tet_result( TET_FAIL ); + } + catch ( Dali::DaliException& e ) + { + DALI_TEST_ASSERT( e, "false", TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliInvalidGesture(void) +{ + TestApplication application; + + try + { + InvalidGesture event; + application.ProcessEvent( event ); + tet_result( TET_FAIL ); + } + catch ( Dali::DaliException& e ) + { + DALI_TEST_ASSERT( e, "false", TEST_LOCATION ); + } + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Font.cpp b/automated-tests/src/dali/utc-Dali-Font.cpp new file mode 100644 index 0000000..eb12005 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-Font.cpp @@ -0,0 +1,546 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; + +void utc_dali_font_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_font_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ + +const std::string FAMILY_NAME = "Arial"; +const std::string STYLE = "Bold"; +const unsigned int PIXEL_SIZE = 20; +const unsigned int POINT_SIZE = 11.f; + +static Font CreateFont( PointSize size ) +{ + // Don't use a font which could be cached otherwise cached values will be used making measure text test to fail. + return Font::New(FontParameters("TET-FreeSans", "Book", size)); +} + +static Font CreateFont( PixelSize size ) +{ + // Don't use a font which could be cached otherwise cached values will be used making measure text test to fail. + return Font::New(FontParameters("TET-FreeSans", "Book", size)); +} + +static Font CreateFont( CapsHeight size ) +{ + // Don't use a font which could be cached otherwise cached values will be used making measure text test to fail. + return Font::New(FontParameters("TET-FreeSans", "Book", size)); +} + +} //anon namespace + +int UtcDaliFontNew01(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::Font::New() - with specific font family and pixel size"); + + Font font; // invoke default constructor (creates an empty handle) + font = CreateFont(PixelSize(25.0f)); // This does not call platform abstraction until some text is displayed or measured + + DALI_TEST_CHECK(font); + + tet_infoline("Testing Dali::Font::New() - with default font name and pixel size"); + + Font font2 = Font::New(FontParameters("", "", PixelSize(0.0f))); + + DALI_TEST_CHECK(font2); + + Font* ptrFont = new Font; + *ptrFont = Font::New(FontParameters("", "", PixelSize(0.0f))); + delete ptrFont; + END_TEST; +} + +int UtcDaliFontNew02(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::Font::New() - with specific font family and point size"); + + Font font = CreateFont(PointSize(8)); + + DALI_TEST_CHECK(font); + + tet_infoline("Testing Dali::Font::New() - with default font family and point size"); + + Font font2; + font2 = Font::New(FontParameters("", "", PointSize(0))); + + DALI_TEST_CHECK(font2); + END_TEST; +} + +int UtcDaliFontNew03(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::Font::New() - with specific font family and caps-height"); + + Font font = CreateFont(CapsHeight(8)); + + DALI_TEST_CHECK(font); + DALI_TEST_CHECK(font.GetPixelSize() > 8.0f); // Pixel size should be bigger than requested CapsHeight + + tet_infoline("Testing Dali::Font::New() - with default font family and point size"); + + Font font2 = Font::New(FontParameters("", "", CapsHeight(0))); + + DALI_TEST_CHECK(font2); + END_TEST; +} + +int UtcDaliFontNew04(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::Font::New() - with wrong font family or font style"); + + Font font = Font::New(FontParameters("gfagag", "fgafgafga",PointSize(0))); + + DALI_TEST_CHECK(font); + END_TEST; +} + +int UtcDaliFontNew05(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::Font::New() - with pixel size and weight"); + + PixelSize pixelSize(PIXEL_SIZE); + FontParameters fontParams(FAMILY_NAME, "", pixelSize); + Font font = Font::New( fontParams ); + + DALI_TEST_CHECK( font ); + DALI_TEST_CHECK( font.GetName() == FAMILY_NAME ); + DALI_TEST_CHECK( font.GetStyle().empty() ); + END_TEST; +} + +int UtcDaliFontNew06(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::Font::New() - with caps height"); + + CapsHeight capsHeight(10.f); + FontParameters fontParams(FAMILY_NAME, "", capsHeight); + Font font = Font::New( fontParams ); + + DALI_TEST_CHECK( font ); + DALI_TEST_CHECK( font.GetName() == FAMILY_NAME ); + DALI_TEST_CHECK( font.GetStyle().empty() ); + END_TEST; +} + + +int UtcDaliFontDownCast(void) +{ + TestApplication application; + tet_infoline("Testing Dali::Font::DownCast()"); + + Font font = CreateFont(PixelSize(25.0f)); + + BaseHandle object(font); + + Font font2 = Font::DownCast(object); + DALI_TEST_CHECK(font2); + + Font font3 = DownCast< Font >(object); + DALI_TEST_CHECK(font3); + + BaseHandle unInitializedObject; + Font font4 = Font::DownCast(unInitializedObject); + DALI_TEST_CHECK(!font4); + + Font font5 = DownCast< Font >(unInitializedObject); + DALI_TEST_CHECK(!font5); + END_TEST; +} + +int UtcDaliFontGetPixelSize(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::Font::GetPixelSize()"); + + Font font = CreateFont(PixelSize(32)); + + DALI_TEST_CHECK(32 == font.GetPixelSize()); + END_TEST; +} + +int UtcDaliFontGetPointSize(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::Font::GetPointSize)"); + + Font font = CreateFont(PointSize(8.0f)); + + DALI_TEST_EQUALS(8.f, font.GetPointSize(), Math::MACHINE_EPSILON_1000, TEST_LOCATION); + END_TEST; +} + +int UtcDaliFontPointsToPixels(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::Font::PointsToPixels)"); + + unsigned int points= Font::PointsToPixels( 12.0f ); + + DALI_TEST_CHECK( points == 36 ); + END_TEST; +} + +int UtcFontMeasureTextWidth(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::Font::MeasureTextWidth()"); + + TraceCallStack& trace = application.GetPlatform().GetTrace(); + trace.Enable(true); + + Font font = CreateFont(PointSize(8)); + + float width = font.MeasureTextWidth("test me", 24.0f); + + // No cache + + DALI_TEST_CHECK(trace.FindMethod("ReadMetricsFromCacheFile")); + DALI_TEST_CHECK(trace.FindMethod("WriteMetricsToCacheFile")); + DALI_TEST_CHECK(trace.FindMethod("GetGlyphData")); + trace.Reset(); + + DALI_TEST_EQUALS(width, 168.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + width = font.MeasureTextWidth(Text(std::string("test me")), 24.0f); + + // Should now be cached in memory + DALI_TEST_CHECK( ! trace.FindMethod("ReadMetricsFromCacheFile")); + DALI_TEST_CHECK( ! trace.FindMethod("WriteMetricsToCacheFile")); + DALI_TEST_CHECK( ! trace.FindMethod("GetGlyphData")); + + DALI_TEST_EQUALS(width, 168.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + + Text text = Text(std::string("t"))[0]; + Character c = text[0]; + width = font.MeasureTextWidth(c, 24.0f); + DALI_TEST_EQUALS(width, 24.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + + END_TEST; +} + +int UtcFontMeasureTextHeight(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::Font::MeasureTextHeight()"); + + TraceCallStack& trace = application.GetPlatform().GetTrace(); + trace.Enable(true); + + Font font = CreateFont(PointSize(8)); + + float height = font.MeasureTextHeight("test me", 48.0f); + + DALI_TEST_CHECK(trace.FindMethod("ReadMetricsFromCacheFile")); + DALI_TEST_CHECK(trace.FindMethod("WriteMetricsToCacheFile")); + DALI_TEST_CHECK(trace.FindMethod("GetGlyphData")); + trace.Reset(); + + DALI_TEST_EQUALS(height, 6.8571f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + + height = font.MeasureTextHeight(Text(std::string("test me")), 48.0f); + + DALI_TEST_CHECK( ! trace.FindMethod("ReadMetricsFromCacheFile")); + DALI_TEST_CHECK( ! trace.FindMethod("WriteMetricsToCacheFile")); + DALI_TEST_CHECK( ! trace.FindMethod("GetGlyphData")); + + DALI_TEST_EQUALS(height, 6.8571f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + + Text text = Text(std::string("t"))[0]; + Character c = text[0]; + height = font.MeasureTextHeight(c, 24.0f); + DALI_TEST_EQUALS(height, 24.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + + END_TEST; +} + +int UtcFontMeasureText(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::Font::MeasureText()"); + + TraceCallStack& trace = application.GetPlatform().GetTrace(); + trace.Enable(true); + + Font font = CreateFont(PointSize(8)); + + Vector3 size = font.MeasureText("test me"); + + DALI_TEST_CHECK(trace.FindMethod("ReadMetricsFromCacheFile")); + DALI_TEST_CHECK(trace.FindMethod("WriteMetricsToCacheFile")); + DALI_TEST_CHECK(trace.FindMethod("GetGlyphData")); + trace.Reset(); + + DALI_TEST_EQUALS(size.width, 53.1076f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + DALI_TEST_EQUALS(size.height, 7.5868f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + + size = font.MeasureText(Text(std::string("test me"))); + + DALI_TEST_CHECK( ! trace.FindMethod("ReadMetricsFromCacheFile")); + DALI_TEST_CHECK( ! trace.FindMethod("WriteMetricsToCacheFile")); + DALI_TEST_CHECK( ! trace.FindMethod("GetGlyphData")); + + DALI_TEST_EQUALS(size.width, 53.1076f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + DALI_TEST_EQUALS(size.height, 7.5868f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + + + Text text = Text(std::string("t"))[0]; + Character c = text[0]; + size = font.MeasureText(c); + + // character size is square + DALI_TEST_EQUALS(size.width, 7.5868f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + DALI_TEST_EQUALS(size.height, 7.5868f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); + + END_TEST; +} + +int UtcFontGetFamilyForText(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::Font::GetFamilyForText()"); + + std::string latinFont = Font::GetFamilyForText("Hello world"); + DALI_TEST_CHECK( latinFont.size() != 0 ); + + latinFont = Font::GetFamilyForText( Text(std::string("Hello world")) ); + DALI_TEST_CHECK( latinFont.size() != 0 ); + + std::string asianFont = Font::GetFamilyForText("繁體中文"); + DALI_TEST_CHECK( asianFont.size() != 0 ); + + asianFont = Font::GetFamilyForText(Text(std::string("繁體中文"))); + DALI_TEST_CHECK( asianFont.size() != 0 ); + + Text text = Text(std::string("繁體中文"))[0]; + Character c = text[0]; + + asianFont = Font::GetFamilyForText(c ); + DALI_TEST_CHECK( asianFont.size() != 0 ); + + END_TEST; +} + +int UtcFontGetFontLineHeightFromCapsHeight(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::Font::GetLineHeightFromCapsHeight()"); + + CapsHeight capsHeight(10); + PixelSize pixelSize = Font::GetLineHeightFromCapsHeight("", "", capsHeight); + DALI_TEST_CHECK( capsHeight < pixelSize ); + + pixelSize = Font::GetLineHeightFromCapsHeight(Font::GetFamilyForText("Hello world"), "", capsHeight); + DALI_TEST_CHECK( capsHeight < pixelSize ); + + pixelSize = Font::GetLineHeightFromCapsHeight(Font::GetFamilyForText(Text(std::string("Hello world"))), "", capsHeight); + DALI_TEST_CHECK( capsHeight < pixelSize ); + END_TEST; +} + +int UtcFontAllGlyphsSupported(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::Font::AllGlyphsSupported()"); + + Font font = Font::New(); + + font.AllGlyphsSupported("Hello World\n"); + + DALI_TEST_CHECK(application.GetPlatform().WasCalled(TestPlatformAbstraction::AllGlyphsSupportedFunc)); + application.GetPlatform().ResetTrace(); + + font.AllGlyphsSupported(Text(std::string("Hello World\n"))); + + DALI_TEST_CHECK(application.GetPlatform().WasCalled(TestPlatformAbstraction::AllGlyphsSupportedFunc)); + + application.GetPlatform().ResetTrace(); + + Text text = Text(std::string("t"))[0]; + Character c = text[0]; + font.AllGlyphsSupported(c); + + DALI_TEST_CHECK(application.GetPlatform().WasCalled(TestPlatformAbstraction::AllGlyphsSupportedFunc)); + END_TEST; +} + +int UtcFontGetMetrics(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::Font::UtcFontGetMetrics()"); + + Font font = Font::New(); + font.MeasureText(Text(std::string("Hello World"))); // Builds fake metrics in TestPlatformAbstraction. + + float lineHeight = font.GetLineHeight(); + float ascender = font.GetAscender(); + float underlineThickness = font.GetUnderlineThickness(); + float underlinePosition = font.GetUnderlinePosition(); + Font::Metrics metrics = font.GetMetrics( Text("H")[0] ); + + // TODO VCC This TET case fails if there are some metrics cached. + + DALI_TEST_EQUALS( lineHeight, 11.380209f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + DALI_TEST_EQUALS( ascender, 10.242188f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + DALI_TEST_EQUALS( underlineThickness, 2.276042f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + DALI_TEST_EQUALS( underlinePosition, 9.104167f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + DALI_TEST_EQUALS( metrics.GetAdvance(), 11.380209f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + DALI_TEST_EQUALS( metrics.GetBearing(), 10.242188f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + DALI_TEST_EQUALS( metrics.GetWidth(), 11.380209f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); + END_TEST; +} + +int UtcFontIsDefault(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::Font::UtcFontIsDefault()"); + + FontParameters fontParams("FreeSans", "", PointSize(10.f)); + Font font1 = Font::New(fontParams); + + DALI_TEST_CHECK( !font1.IsDefaultSystemFont() ); + DALI_TEST_CHECK( !font1.IsDefaultSystemSize() ); + + DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::ValidateFontFamilyNameFunc ) ); + application.GetPlatform().ResetTrace(); + + Font font2 = Font::New(); + + DALI_TEST_CHECK( !font2.IsDefaultSystemFont() ); + DALI_TEST_CHECK( font2.IsDefaultSystemSize() ); + + DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::ValidateFontFamilyNameFunc ) ); + END_TEST; +} + + +int UtcFontGetInstalledFonts(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::Font::GetInstalledFonts()"); + + // the default should only get installed and downloaded fonts + std::vector fontList; + + fontList = Font::GetInstalledFonts(Font::LIST_SYSTEM_FONTS); + DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::ValidateGetFontListFunc ) ); + DALI_TEST_CHECK( application.GetPlatform().GetLastFontListMode() == Dali::Integration::PlatformAbstraction::LIST_SYSTEM_FONTS ); + + fontList = Font::GetInstalledFonts(Font::LIST_ALL_FONTS); + DALI_TEST_CHECK( application.GetPlatform().GetLastFontListMode() == Dali::Integration::PlatformAbstraction::LIST_ALL_FONTS ); + + fontList = Font::GetInstalledFonts(Font::LIST_APPLICATION_FONTS); + DALI_TEST_CHECK( application.GetPlatform().GetLastFontListMode() == Dali::Integration::PlatformAbstraction::LIST_APPLICATION_FONTS ); + + END_TEST; +} + +int UtcFontMetricsDefaultConstructor(void) +{ + TestApplication application; + + tet_infoline("Testing UtcFontMetricsDefaultConstructor"); + + Font::Metrics metrics; + + DALI_TEST_EQUALS( metrics.GetAdvance() , 0.f , Math::MACHINE_EPSILON_10000, TEST_LOCATION ); + DALI_TEST_EQUALS( metrics.GetBearing() , 0.f , Math::MACHINE_EPSILON_10000, TEST_LOCATION ); + DALI_TEST_EQUALS( metrics.GetWidth() , 0.f , Math::MACHINE_EPSILON_10000, TEST_LOCATION ); + DALI_TEST_EQUALS( metrics.GetHeight() , 0.f , Math::MACHINE_EPSILON_10000, TEST_LOCATION ); + + END_TEST; +} + +int UtcFontMetricsCopyConstructor(void) +{ + TestApplication application; + + tet_infoline("Testing UtcFontMetricsCopyConstructor"); + + Font font = Font::New(); + font.MeasureText(Text(std::string("Hello World"))); // Builds fake metrics in TestPlatformAbstraction. + Font::Metrics metrics = font.GetMetrics( Text("H")[0] ); + Font::Metrics metrics2( metrics ); + + DALI_TEST_EQUALS( metrics.GetAdvance() , metrics2.GetAdvance() , Math::MACHINE_EPSILON_10000, TEST_LOCATION ); + DALI_TEST_EQUALS( metrics.GetBearing() , metrics2.GetBearing(), Math::MACHINE_EPSILON_10000, TEST_LOCATION ); + DALI_TEST_EQUALS( metrics.GetWidth() , metrics2.GetWidth() , Math::MACHINE_EPSILON_10000, TEST_LOCATION ); + DALI_TEST_EQUALS( metrics.GetHeight() , metrics2.GetHeight(), Math::MACHINE_EPSILON_10000, TEST_LOCATION ); + + END_TEST; +} + +int UtcFontMetricsAssignmentOperator(void) +{ + TestApplication application; + + tet_infoline("Testing UtcFontMetricsAssignmentOperator"); + + Font font = Font::New(); + font.MeasureText(Text(std::string("Hello World"))); // Builds fake metrics in TestPlatformAbstraction. + Font::Metrics metrics = font.GetMetrics( Text("H")[0] ); + Font::Metrics metrics2; + + metrics2 = metrics; + + DALI_TEST_EQUALS( metrics.GetAdvance() , metrics2.GetAdvance() , Math::MACHINE_EPSILON_10000, TEST_LOCATION ); + DALI_TEST_EQUALS( metrics.GetBearing() , metrics2.GetBearing(), Math::MACHINE_EPSILON_10000, TEST_LOCATION ); + DALI_TEST_EQUALS( metrics.GetWidth() , metrics2.GetWidth() , Math::MACHINE_EPSILON_10000, TEST_LOCATION ); + DALI_TEST_EQUALS( metrics.GetHeight() , metrics2.GetHeight(), Math::MACHINE_EPSILON_10000, TEST_LOCATION ); + + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-FontParameters.cpp b/automated-tests/src/dali/utc-Dali-FontParameters.cpp new file mode 100644 index 0000000..b1eae9c --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-FontParameters.cpp @@ -0,0 +1,135 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; + +void utc_dali_font_parameters_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_font_parameters_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ + +const std::string FAMILY_NAME = "Arial"; +const std::string STYLE = "Bold"; +const unsigned int PIXEL_SIZE = 20; +const unsigned int POINT_SIZE = 11.f; + +} // anon namespace + + +int UtcDaliFontParamsDefaultConstructor(void) +{ + TestApplication application; + tet_infoline("Testing UtcDaliFontParamsDefaultConstructor"); + FontParameters params; + + DALI_TEST_CHECK(params.GetFamilyName() == "" ); + DALI_TEST_CHECK(params.GetStyle() == "" ); + DALI_TEST_EQUALS( float(params.GetSize()) , 0.f , Math::MACHINE_EPSILON_10000, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliFontParamsPointSizeConstructor(void) +{ + TestApplication application; + tet_infoline("Testing UtcDaliFontParamsPointSizeConstructor"); + + PointSize pointSize( POINT_SIZE ); + FontParameters params( FAMILY_NAME, STYLE, pointSize); + + DALI_TEST_CHECK(params.GetFamilyName() == FAMILY_NAME ); + DALI_TEST_CHECK(params.GetStyle() == STYLE ); + DALI_TEST_EQUALS( float(params.GetSize()), float(pointSize), Math::MACHINE_EPSILON_10000, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliFontParamsPixelSizeConstructor(void) +{ + TestApplication application; + tet_infoline("Testing UtcDaliFontParamsPixelSizeConstructor"); + + PixelSize pixelSize( PIXEL_SIZE ); + FontParameters params( FAMILY_NAME, STYLE, pixelSize); + + DALI_TEST_CHECK(params.GetFamilyName() == FAMILY_NAME ); + DALI_TEST_CHECK(params.GetStyle() == STYLE ); + DALI_TEST_EQUALS( float(params.GetSize()), Font::PixelsToPoints( PIXEL_SIZE ) , Math::MACHINE_EPSILON_10000, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliFontParamsCopyConstructor(void) +{ + TestApplication application; + tet_infoline("Testing UtcDaliFontParamsCopyConstructor"); + PixelSize pixelSize( PIXEL_SIZE ); + FontParameters params( FAMILY_NAME, STYLE, pixelSize); + + + FontParameters params2( params ); + DALI_TEST_CHECK(params2.GetFamilyName() == FAMILY_NAME ); + DALI_TEST_CHECK(params2.GetStyle() == STYLE ); + DALI_TEST_EQUALS( float(params2.GetSize()), Font::PixelsToPoints( PIXEL_SIZE ) , Math::MACHINE_EPSILON_10000, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliFontParamsAssignmentOperator(void) +{ + TestApplication application; + tet_infoline("Testing UtcDaliFontParamsAssignmentOperator"); + PixelSize pixelSize( PIXEL_SIZE ); + FontParameters params( FAMILY_NAME, STYLE, pixelSize); + + FontParameters params2; + params2 = params; + DALI_TEST_CHECK(params2.GetFamilyName() == FAMILY_NAME ); + DALI_TEST_CHECK(params2.GetStyle() == STYLE ); + DALI_TEST_EQUALS( float(params2.GetSize()) ,Font::PixelsToPoints( PIXEL_SIZE ) , Math::MACHINE_EPSILON_10000, TEST_LOCATION ); + + // for coverage self assignment + params2 = params2; + DALI_TEST_CHECK(params2.GetFamilyName() == FAMILY_NAME ); + + END_TEST; +} + +int UtcDaliFontParamsPointSizeEqualityOperator(void) +{ + TestApplication application; + tet_infoline("Testing UtcDaliFontParamsPixelSizeConstructor"); + PointSize pointSize1(1.f); + PointSize pointSize2(2.f); + DALI_TEST_CHECK( pointSize1 != pointSize2 ); + + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-FrameBufferImage.cpp b/automated-tests/src/dali/utc-Dali-FrameBufferImage.cpp new file mode 100644 index 0000000..7563c57 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-FrameBufferImage.cpp @@ -0,0 +1,109 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 std::max; +using namespace Dali; + +void utc_dali_framebuffer_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_framebuffer_cleanup(void) +{ + test_return_value = TET_PASS; +} + +static const float ROTATION_EPSILON = 0.0001f; + + +int UtcDaliFrameBufferImageNew01(void) +{ + TestApplication application; + + tet_infoline("UtcDaliFrameBufferImageNew01 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format)"); + + // invoke default handle constructor + FrameBufferImage image; + Dali::ImageAttributes attributes; + Vector2 stageSize = Stage::GetCurrent().GetSize(); + + // initialise handle + image = FrameBufferImage::New(); // create framebuffer with the same dimensions as the stage + ImageActor actor=ImageActor::New(image); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + + attributes = image.GetAttributes(); + + DALI_TEST_CHECK( image ); + DALI_TEST_EQUALS((float)attributes.GetWidth(), stageSize.width, TEST_LOCATION); + DALI_TEST_EQUALS((float)attributes.GetHeight(), stageSize.height, TEST_LOCATION); + + image = FrameBufferImage::New(16, 16); // create framebuffer with dimensions of 16x16 + actor.SetImage(image); + + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + + attributes = image.GetAttributes(); + + DALI_TEST_CHECK( image ); + DALI_TEST_EQUALS(attributes.GetWidth(), 16u, TEST_LOCATION); + DALI_TEST_EQUALS(attributes.GetHeight(), 16u, TEST_LOCATION); + END_TEST; +} + +int UtcDaliFrameBufferImageDownCast(void) +{ + TestApplication application; + tet_infoline("Testing Dali::FrameBufferImage::DownCast()"); + + FrameBufferImage image = FrameBufferImage::New(); + + BaseHandle object(image); + + FrameBufferImage image2 = FrameBufferImage::DownCast(object); + DALI_TEST_CHECK(image2); + + FrameBufferImage image3 = DownCast< FrameBufferImage >(object); + DALI_TEST_CHECK(image3); + + BaseHandle unInitializedObject; + FrameBufferImage image4 = FrameBufferImage::DownCast(unInitializedObject); + DALI_TEST_CHECK(!image4); + + FrameBufferImage image5 = DownCast< FrameBufferImage >(unInitializedObject); + DALI_TEST_CHECK(!image5); + + Image image6 = FrameBufferImage::New(); + FrameBufferImage image7 = FrameBufferImage::DownCast(image6); + DALI_TEST_CHECK(image7); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Gesture.cpp b/automated-tests/src/dali/utc-Dali-Gesture.cpp new file mode 100644 index 0000000..c54e793 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-Gesture.cpp @@ -0,0 +1,84 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +using namespace Dali; + +void utc_dali_gesture_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_gesture_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ + +// TestGesture Struct (Gesture constructor is protected) +struct TestGesture : public Gesture +{ +public: + TestGesture(Gesture::Type type, Gesture::State state) + : Gesture(type, state) {} + + virtual ~TestGesture() {} +}; + +} // anon namespace + +int UtcDaliGestureConstructor(void) +{ + TestApplication application; // Reset all test adapter return codes + + TestGesture pan(Gesture::Pan, Gesture::Started); + DALI_TEST_EQUALS(Gesture::Pan, pan.type, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, pan.state, TEST_LOCATION); + + TestGesture pinch(Gesture::Pinch, Gesture::Clear); + DALI_TEST_EQUALS(Gesture::Pinch, pinch.type, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Clear, pinch.state, TEST_LOCATION); + + // Test copy constructor + TestGesture pan2(pan); + DALI_TEST_EQUALS(Gesture::Pan, pan2.type, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, pan2.state, TEST_LOCATION); + END_TEST; +} + +int UtcDaliGestureAssignment(void) +{ + // Test Assignment operator + TestGesture pan(Gesture::Pan, Gesture::Finished); + DALI_TEST_EQUALS(Gesture::Pan, pan.type, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Finished, pan.state, TEST_LOCATION); + + TestGesture test(Gesture::Pinch, Gesture::Started); + DALI_TEST_EQUALS(Gesture::Pinch, test.type, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, test.state, TEST_LOCATION); + + test = pan; + DALI_TEST_EQUALS(Gesture::Pan, test.type, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Finished, test.state, TEST_LOCATION); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-GestureDetector.cpp b/automated-tests/src/dali/utc-Dali-GestureDetector.cpp new file mode 100644 index 0000000..342e50c --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-GestureDetector.cpp @@ -0,0 +1,405 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 std; + +void utc_dali_gesture_detector_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_gesture_detector_cleanup(void) +{ + test_return_value = TET_PASS; +} + + +int UtcDaliGestureDetectorConstructorNegative(void) +{ + TestApplication application; + + GestureDetector detector; + + Actor actor = Actor::New(); + + try + { + detector.Attach(actor); + tet_result(TET_FAIL); + } + catch (DaliException& exception) + { + if ( exception.mCondition.find("detector") != string::npos ) + { + tet_result(TET_PASS); + } + } + END_TEST; +} + +int UtcDaliGestureDetectorConstructorPositive(void) +{ + TestApplication application; + + // Use pan gesture as GestureDetector cannot be created. + GestureDetector detector = PanGestureDetector::New(); + + Actor actor = Actor::New(); + + try + { + detector.Attach(actor); + tet_result(TET_PASS); + } + catch (DaliException& exception) + { + tet_result(TET_FAIL); + } + END_TEST; +} + +int UtcDaliGestureDetectorDownCast(void) +{ + TestApplication application; + tet_infoline("Testing Dali::GestureDetector::DownCast()"); + + GestureDetector detector = PanGestureDetector::New(); + + BaseHandle object(detector); + + GestureDetector detector2 = GestureDetector::DownCast(object); + DALI_TEST_CHECK(detector2); + + GestureDetector detector3 = DownCast< GestureDetector >(object); + DALI_TEST_CHECK(detector3); + + BaseHandle unInitializedObject; + GestureDetector detector4 = GestureDetector::DownCast(unInitializedObject); + DALI_TEST_CHECK(!detector4); + + GestureDetector detector5 = DownCast< GestureDetector >(unInitializedObject); + DALI_TEST_CHECK(!detector5); + END_TEST; +} + +int UtcDaliGestureDetectorAttachPositive(void) +{ + TestApplication application; + + // Use pan gesture as GestureDetector cannot be created. + GestureDetector detector = PanGestureDetector::New(); + + Actor actor = Actor::New(); + + detector.Attach(actor); + + vector actors = detector.GetAttachedActors(); + + if (find(actors.begin(), actors.end(), actor) != actors.end()) + { + tet_result(TET_PASS); + } + else + { + tet_result(TET_FAIL); + } + + // Scoped gesture detector. GestureDetectors connect to a destroy signal of the actor. If the + // actor is still alive when the gesture detector is destroyed, then it should disconnect from + // this signal. If it does not, then when this function ends, there will be a segmentation fault + // thus, a TET case failure. + { + GestureDetector detector2 = PanGestureDetector::New(); + detector2.Attach(actor); + } + END_TEST; +} + +int UtcDaliGestureDetectorAttachNegative(void) +{ + TestApplication application; + + // Use pan gesture as GestureDetector cannot be created. + GestureDetector detector = PanGestureDetector::New(); + + // Do not initialise actor + Actor actor; + + try + { + detector.Attach(actor); + tet_result(TET_FAIL); + } + catch (DaliException& exception) + { + if ( exception.mCondition.find("actor") != string::npos ) + { + tet_result(TET_PASS); + } + } + END_TEST; +} + +int UtcDaliGestureDetectorDetachPositive(void) +{ + TestApplication application; + + // Use pan gesture as GestureDetector cannot be created. + GestureDetector detector = PanGestureDetector::New(); + + Actor actor = Actor::New(); + detector.Attach(actor); + vector actors = detector.GetAttachedActors(); + + if (find(actors.begin(), actors.end(), actor) != actors.end()) + { + tet_result(TET_PASS); + } + else + { + tet_result(TET_FAIL); + } + + // Detach and retrive attached actors again, the vector should be empty. + detector.Detach(actor); + + actors = detector.GetAttachedActors(); + if (actors.empty()) + { + tet_result(TET_PASS); + } + else + { + tet_result(TET_FAIL); + } + END_TEST; +} + +int UtcDaliGestureDetectorDetachNegative01(void) +{ + TestApplication application; + + // Use pan gesture as GestureDetector cannot be created. + GestureDetector detector = PanGestureDetector::New(); + + // Do not initialise actor + Actor actor; + + try + { + detector.Detach(actor); + tet_result(TET_FAIL); + } + catch (DaliException& exception) + { + if ( exception.mCondition.find("actor") != string::npos ) + { + tet_result(TET_PASS); + } + } + END_TEST; +} + +int UtcDaliGestureDetectorDetachNegative02(void) +{ + TestApplication application; + + // Use pan gesture as GestureDetector cannot be created. + GestureDetector detector = PanGestureDetector::New(); + + Actor actor = Actor::New(); + detector.Attach(actor); + + // Detach an actor that hasn't been attached. This should not cause an exception, it's a no-op. + try + { + Actor actor2 = Actor::New(); + detector.Detach(actor2); + tet_result(TET_PASS); + } + catch (DaliException& exception) + { + tet_result(TET_FAIL); + } + END_TEST; +} + +int UtcDaliGestureDetectorDetachNegative03(void) +{ + TestApplication application; + TestGestureManager& gestureManager = application.GetGestureManager(); + + // Use pan gesture as GestureDetector cannot be created. + GestureDetector detector = PanGestureDetector::New(); + + Actor actor = Actor::New(); + detector.Attach(actor); + + // Detach an actor twice - no exception should happen. + try + { + detector.Detach(actor); + DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION); + + gestureManager.Initialize(); // Reset values + detector.Detach(actor); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION); + } + catch (DaliException& exception) + { + tet_result(TET_FAIL); + } + END_TEST; +} + +int UtcDaliGestureDetectorDetachAll(void) +{ + TestApplication application; + + // Use pan gesture as GestureDetector cannot be created. + GestureDetector detector = PanGestureDetector::New(); + + const unsigned int actorsToAdd = 5; + vector myActors; + + for (unsigned int i = 0; i < actorsToAdd; ++i) + { + Actor actor = Actor::New(); + myActors.push_back(actor); + detector.Attach(actor); + } + + vector attachedActors = detector.GetAttachedActors(); + DALI_TEST_EQUALS(actorsToAdd, attachedActors.size(), TEST_LOCATION); + + // Detach and retrieve attached actors again, the vector should be empty. + detector.DetachAll(); + + attachedActors = detector.GetAttachedActors(); + DALI_TEST_EQUALS(true, attachedActors.empty(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliGestureDetectorDetachAllNegative(void) +{ + TestApplication application; + TestGestureManager& gestureManager = application.GetGestureManager(); + + // Use pan gesture as GestureDetector cannot be created. + GestureDetector detector = PanGestureDetector::New(); + + const unsigned int actorsToAdd = 5; + vector myActors; + + for (unsigned int i = 0; i < actorsToAdd; ++i) + { + Actor actor = Actor::New(); + myActors.push_back(actor); + detector.Attach(actor); + } + + vector attachedActors = detector.GetAttachedActors(); + DALI_TEST_EQUALS(actorsToAdd, attachedActors.size(), TEST_LOCATION); + + // Detach and retrieve attached actors again, the vector should be empty. + detector.DetachAll(); + + attachedActors = detector.GetAttachedActors(); + DALI_TEST_EQUALS(true, attachedActors.empty(), TEST_LOCATION); + DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION); + + // Call DetachAll again, there should not be any exception + try + { + gestureManager.Initialize(); // Reset values + detector.DetachAll(); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION); + } + catch (DaliException& exception) + { + tet_result(TET_FAIL); + } + END_TEST; +} + +int UtcDaliGestureDetectorGetAttachedActors(void) +{ + TestApplication application; + + // Use pan gesture as GestureDetector cannot be created. + GestureDetector detector = PanGestureDetector::New(); + + // Initially there should not be any actors. + DALI_TEST_EQUALS(0u, detector.GetAttachedActors().size(), TEST_LOCATION); + + // Attach one actor + Actor actor1 = Actor::New(); + detector.Attach(actor1); + DALI_TEST_EQUALS(1u, detector.GetAttachedActors().size(), TEST_LOCATION); + + // Attach another actor + Actor actor2 = Actor::New(); + detector.Attach(actor2); + DALI_TEST_EQUALS(2u, detector.GetAttachedActors().size(), TEST_LOCATION); + + // Attach another five actors + vector myActors; + for (unsigned int i = 0; i < 5; ++i) + { + Actor actor = Actor::New(); + myActors.push_back(actor); + detector.Attach(actor); + } + DALI_TEST_EQUALS(7u, detector.GetAttachedActors().size(), TEST_LOCATION); + + // Detach actor2 + detector.Detach(actor2); + DALI_TEST_EQUALS(6u, detector.GetAttachedActors().size(), TEST_LOCATION); + + // Attach actor1 again, count should not increase. + detector.Attach(actor1); + DALI_TEST_EQUALS(6u, detector.GetAttachedActors().size(), TEST_LOCATION); + + // Detach actor2 again, count should not decrease. + detector.Detach(actor2); + DALI_TEST_EQUALS(6u, detector.GetAttachedActors().size(), TEST_LOCATION); + + // Detach actor1. + detector.Detach(actor1); + DALI_TEST_EQUALS(5u, detector.GetAttachedActors().size(), TEST_LOCATION); + + // Create scoped actor, actor should be automatically removed from the detector when it goes out + // of scope. + { + Actor scopedActor = Actor::New(); + detector.Attach(scopedActor); + DALI_TEST_EQUALS(6u, detector.GetAttachedActors().size(), TEST_LOCATION); + } + DALI_TEST_EQUALS(5u, detector.GetAttachedActors().size(), TEST_LOCATION); + + // Detach all so nothing remains. + detector.DetachAll(); + DALI_TEST_EQUALS(0u, detector.GetAttachedActors().size(), TEST_LOCATION); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Handle.cpp b/automated-tests/src/dali/utc-Dali-Handle.cpp new file mode 100644 index 0000000..fdc0143 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-Handle.cpp @@ -0,0 +1,909 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 "dali-test-suite-utils/dali-test-suite-utils.h" + +using namespace Dali; + +void handle_test_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void handle_test_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ + +Handle ImplicitCopyConstructor(Handle passedByValue) +{ + // object + copy + passedByValue, ref count == 3 + DALI_TEST_CHECK(passedByValue); + if (passedByValue) + { + DALI_TEST_EQUALS(3, passedByValue.GetBaseObject().ReferenceCount(), TEST_LOCATION); + } + + return passedByValue; +} + +void CheckTypeName(const Property::Type& type) +{ + switch(type) + { + case Property::NONE: + { + DALI_TEST_CHECK( "NONE" == std::string(PropertyTypes::GetName( type ) ) ); + break; + } + case Property::BOOLEAN: + { + DALI_TEST_CHECK( "BOOLEAN" == std::string(PropertyTypes::GetName( type ) ) ); + break; + } + case Property::FLOAT: + { + DALI_TEST_CHECK( "FLOAT" == std::string(PropertyTypes::GetName( type ) ) ); + break; + } + case Property::INTEGER: + { + DALI_TEST_CHECK( "INTEGER" == std::string(PropertyTypes::GetName( type ) ) ); + break; + } + case Property::UNSIGNED_INTEGER: + { + DALI_TEST_CHECK( "UNSIGNED_INTEGER" == std::string(PropertyTypes::GetName( type ) ) ); + break; + } + case Property::VECTOR2: + { + DALI_TEST_CHECK( "VECTOR2" == std::string(PropertyTypes::GetName( type ) ) ); + break; + } + case Property::VECTOR3: + { + DALI_TEST_CHECK( "VECTOR3" == std::string(PropertyTypes::GetName( type ) ) ); + break; + } + case Property::VECTOR4: + { + DALI_TEST_CHECK( "VECTOR4" == std::string(PropertyTypes::GetName( type ) ) ); + break; + } + case Property::MATRIX3: + { + DALI_TEST_CHECK( "MATRIX3" == std::string(PropertyTypes::GetName( type ) ) ); + break; + } + case Property::MATRIX: + { + DALI_TEST_CHECK( "MATRIX" == std::string(PropertyTypes::GetName( type ) ) ); + break; + } + case Property::RECTANGLE: + { + DALI_TEST_CHECK( "RECTANGLE" == std::string(PropertyTypes::GetName( type ) ) ); + break; + } + case Property::ROTATION: + { + DALI_TEST_CHECK( "ROTATION" == std::string(PropertyTypes::GetName( type ) ) ); + break; + } + case Property::STRING: + { + DALI_TEST_CHECK( "STRING" == std::string(PropertyTypes::GetName( type ) ) ); + break; + } + case Property::ARRAY: + { + DALI_TEST_CHECK( "ARRAY" == std::string(PropertyTypes::GetName( type ) ) ); + break; + } + case Property::MAP: + { + DALI_TEST_CHECK( "MAP" == std::string(PropertyTypes::GetName( type ) ) ); + break; + } + case Property::TYPE_COUNT: + { + DALI_TEST_CHECK( "NONE" == std::string(PropertyTypes::GetName( type ) ) ); + break; + } + } // switch(type) + +} // CheckTypeName + +} // anon namespace + + +int UtcDaliHandleConstructorVoid(void) +{ + TestApplication application; + tet_infoline("Testing Dali::Handle::Handle()"); + + Handle object; + + DALI_TEST_CHECK(!object); + END_TEST; +} + +int UtcDaliHandleCopyConstructor(void) +{ + TestApplication application; + tet_infoline("Testing Dali::Handle::Handle(const Handle&)"); + + // Initialize an object, ref count == 1 + Handle object = Actor::New(); + + DALI_TEST_EQUALS(1, object.GetBaseObject().ReferenceCount(), TEST_LOCATION); + + // Copy the object, ref count == 2 + Handle copy(object); + DALI_TEST_CHECK(copy); + if (copy) + { + DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION); + } + + { + // Pass by value, and return another copy, ref count == 3 + Handle anotherCopy = ImplicitCopyConstructor(copy); + + DALI_TEST_CHECK(anotherCopy); + if (anotherCopy) + { + DALI_TEST_EQUALS(3, anotherCopy.GetBaseObject().ReferenceCount(), TEST_LOCATION); + } + } + + // anotherCopy out of scope, ref count == 2 + DALI_TEST_CHECK(copy); + if (copy) + { + DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliHandleAssignmentOperator(void) +{ + TestApplication application; + tet_infoline("Testing Dali::Handle::operator="); + + Handle object = Actor::New(); + + DALI_TEST_CHECK(object); + DALI_TEST_EQUALS(1, object.GetBaseObject().ReferenceCount(), TEST_LOCATION); + + Handle copy; + DALI_TEST_CHECK(!copy); + + copy = object; + DALI_TEST_CHECK(copy); + DALI_TEST_EQUALS(2, copy.GetBaseObject().ReferenceCount(), TEST_LOCATION); + DALI_TEST_CHECK(&(copy.GetBaseObject()) == &(object.GetBaseObject())); + END_TEST; +} + +int UtcDaliHandleSupports(void) +{ + tet_infoline("Positive Test Dali::Handle::Supports()"); + TestApplication application; + + Actor actor = Actor::New(); + DALI_TEST_CHECK( true == actor.Supports( Handle::DYNAMIC_PROPERTIES ) ); + END_TEST; +} + +int UtcDaliHandleGetPropertyCount(void) +{ + tet_infoline("Positive Test Dali::Handle::GetPropertyCount()"); + TestApplication application; + + Actor actor = Actor::New(); + int defaultPropertyCount( actor.GetPropertyCount() ); + + // Register a dynamic property + actor.RegisterProperty( "test-property", float(123.0f) ); + DALI_TEST_CHECK( (defaultPropertyCount + 1u) == actor.GetPropertyCount() ); + END_TEST; +} + +int UtcDaliHandleGetPropertyName(void) +{ + tet_infoline("Positive Test Dali::Handle::GetPropertyName()"); + TestApplication application; + + Actor actor = Actor::New(); + DALI_TEST_CHECK( "parent-origin" == actor.GetPropertyName( Actor::PARENT_ORIGIN ) ); + + // Register a dynamic property + std::string name("this-name-should-match"); + Property::Index index = actor.RegisterProperty( name, float(123.0f) ); + DALI_TEST_CHECK( name == actor.GetPropertyName( index ) ); + + END_TEST; +} + +int UtcDaliHandleGetPropertyIndex(void) +{ + tet_infoline("Positive Test Dali::Handle::GetPropertyIndex()"); + TestApplication application; + + Actor actor = Actor::New(); + DALI_TEST_CHECK( Actor::PARENT_ORIGIN == actor.GetPropertyIndex("parent-origin") ); + + // Register a dynamic property + std::string name("this-name-should-match"); + Property::Index index = actor.RegisterProperty( name, float(123.0f) ); + DALI_TEST_CHECK( index == actor.GetPropertyIndex( name ) ); + END_TEST; +} + +int UtcDaliHandleIsPropertyWritable(void) +{ + tet_infoline("Positive Test Dali::Handle::IsPropertyWritable()"); + TestApplication application; + + Actor actor = Actor::New(); + + // Actor properties which are writable: + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::PARENT_ORIGIN ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::PARENT_ORIGIN_X ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::PARENT_ORIGIN_Y ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::PARENT_ORIGIN_Z ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::ANCHOR_POINT ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::ANCHOR_POINT_X ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::ANCHOR_POINT_Y ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::ANCHOR_POINT_Z ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::SIZE ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::SIZE_WIDTH ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::SIZE_HEIGHT ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::SIZE_DEPTH ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::POSITION ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::POSITION_X ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::POSITION_Y ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::POSITION_Z ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::ROTATION ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::SCALE ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::SCALE_X ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::SCALE_Y ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::SCALE_Z ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::VISIBLE ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::COLOR ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::COLOR_RED ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::COLOR_GREEN ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::COLOR_BLUE ) ); + DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::COLOR_ALPHA ) ); + + // World-properties are not writable: + DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::WORLD_POSITION ) ); + DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::WORLD_ROTATION ) ); + DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::WORLD_SCALE ) ); + DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::WORLD_COLOR ) ); + DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::WORLD_POSITION_X ) ); + DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::WORLD_POSITION_Y ) ); + DALI_TEST_CHECK( false == actor.IsPropertyWritable( Actor::WORLD_POSITION_Z ) ); + + END_TEST; +} + +int UtcDaliHandleIsPropertyAnimatable(void) +{ + tet_infoline("Positive Test Dali::Handle::IsPropertyAnimatable()"); + TestApplication application; + + Actor actor = Actor::New(); + + // Actor properties which are animatable: + DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::PARENT_ORIGIN ) ); + DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::PARENT_ORIGIN_X ) ); + DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::PARENT_ORIGIN_Y ) ); + DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::PARENT_ORIGIN_Z ) ); + DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::ANCHOR_POINT ) ); + DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::ANCHOR_POINT_X ) ); + DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::ANCHOR_POINT_Y ) ); + DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::ANCHOR_POINT_Z ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::SIZE ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::SIZE_WIDTH ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::SIZE_HEIGHT ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::SIZE_DEPTH ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::POSITION ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::POSITION_X ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::POSITION_Y ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::POSITION_Z ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::ROTATION ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::SCALE ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::SCALE_X ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::SCALE_Y ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::SCALE_Z ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::VISIBLE ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::COLOR ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::COLOR_RED ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::COLOR_GREEN ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::COLOR_BLUE ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAnimatable( Actor::COLOR_ALPHA ) ); + + // World-properties can not be animated + DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::WORLD_POSITION ) ); + DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::WORLD_ROTATION ) ); + DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::WORLD_SCALE ) ); + DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::WORLD_COLOR ) ); + DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::WORLD_POSITION_X ) ); + DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::WORLD_POSITION_Y ) ); + DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::WORLD_POSITION_Z ) ); + + END_TEST; +} + +int UtcDaliHandleGetPropertyType(void) +{ + tet_infoline("Positive Test Dali::Handle::GetPropertyType()"); + TestApplication application; + unsigned int unsingedIntTest = 33; + + Actor actor = Actor::New(); + DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::PARENT_ORIGIN ) ); + DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::ANCHOR_POINT ) ); + DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::SIZE ) ); + DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::POSITION ) ); + DALI_TEST_CHECK( Property::ROTATION == actor.GetPropertyType( Actor::ROTATION ) ); + DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( Actor::SCALE ) ); + DALI_TEST_CHECK( Property::BOOLEAN == actor.GetPropertyType( Actor::VISIBLE ) ); + DALI_TEST_CHECK( Property::VECTOR4 == actor.GetPropertyType( Actor::COLOR ) ); + + // Register some dynamic properties + Property::Index boolIndex = actor.RegisterProperty( "bool-property", bool(true) ); + Property::Index floatIndex = actor.RegisterProperty( "float-property", float(123.0f) ); + Property::Index vector2Index = actor.RegisterProperty( "vector2-property", Vector2(1.0f, 2.0f) ); + Property::Index vector3Index = actor.RegisterProperty( "vector3-property", Vector3(1.0f, 2.0f, 3.0f) ); + Property::Index vector4Index = actor.RegisterProperty( "vector4-property", Vector4(1.0f, 2.0f, 3.0f, 4.0f) ); + Property::Index rotationIndex = actor.RegisterProperty( "rotation-property", AngleAxis(Degree(180.0f), Vector3::YAXIS) ); + + DALI_TEST_CHECK( Property::BOOLEAN == actor.GetPropertyType( boolIndex ) ); + DALI_TEST_CHECK( Property::FLOAT == actor.GetPropertyType( floatIndex ) ); + DALI_TEST_CHECK( Property::VECTOR2 == actor.GetPropertyType( vector2Index ) ); + DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( vector3Index ) ); + DALI_TEST_CHECK( Property::VECTOR4 == actor.GetPropertyType( vector4Index ) ); + DALI_TEST_CHECK( Property::ROTATION == actor.GetPropertyType( rotationIndex ) ); + + // Non animatable properties + Property::Index nonAnimStringIndex = actor.RegisterProperty( "man-from-delmonte", std::string("yes"), Property::READ_WRITE); + Property::Index nonAnimV2Index = actor.RegisterProperty( "v2", Vector2(1.f, 2.f), Property::READ_WRITE); + Property::Index nonAnimV3Index = actor.RegisterProperty( "v3", Vector3(1.f, 2.f, 3.f), Property::READ_WRITE); + Property::Index nonAnimV4Index = actor.RegisterProperty( "v4", Vector4(1.f, 2.f, 3.f, 4.f), Property::READ_WRITE); + Property::Index nonAnimBooleanIndex = actor.RegisterProperty( "bool", true, Property::READ_WRITE); + Property::Index nonAnimFloatIndex = actor.RegisterProperty( "float", 0.f, Property::READ_WRITE); + Property::Index nonAnimUnsignedIntIndex = actor.RegisterProperty( "unsinged-int", unsingedIntTest, Property::READ_WRITE); + + DALI_TEST_CHECK( nonAnimStringIndex != Property::INVALID_INDEX ); + DALI_TEST_CHECK( nonAnimV2Index != Property::INVALID_INDEX ); + DALI_TEST_CHECK( nonAnimV3Index != Property::INVALID_INDEX ); + DALI_TEST_CHECK( nonAnimV4Index != Property::INVALID_INDEX ); + DALI_TEST_CHECK( nonAnimBooleanIndex != Property::INVALID_INDEX ); + DALI_TEST_CHECK( nonAnimFloatIndex != Property::INVALID_INDEX ); + DALI_TEST_CHECK( nonAnimUnsignedIntIndex != Property::INVALID_INDEX ); + + DALI_TEST_CHECK( Property::STRING == actor.GetPropertyType( nonAnimStringIndex ) ); + DALI_TEST_CHECK( Property::VECTOR2 == actor.GetPropertyType( nonAnimV2Index ) ); + DALI_TEST_CHECK( Property::VECTOR3 == actor.GetPropertyType( nonAnimV3Index ) ); + DALI_TEST_CHECK( Property::VECTOR4 == actor.GetPropertyType( nonAnimV4Index ) ); + DALI_TEST_CHECK( Property::BOOLEAN == actor.GetPropertyType( nonAnimBooleanIndex ) ); + DALI_TEST_CHECK( Property::FLOAT == actor.GetPropertyType( nonAnimFloatIndex ) ); + DALI_TEST_CHECK( Property::UNSIGNED_INTEGER == actor.GetPropertyType( nonAnimUnsignedIntIndex ) ); + + DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimStringIndex ) ); + DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV2Index ) ); + DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV3Index ) ); + DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimV4Index ) ); + DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimBooleanIndex ) ); + DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimFloatIndex ) ); + DALI_TEST_CHECK( !actor.IsPropertyAnimatable( nonAnimUnsignedIntIndex ) ); + + DALI_TEST_EQUALS( "yes" , actor.GetProperty( nonAnimStringIndex ).Get(), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2(1.f, 2.f) , actor.GetProperty( nonAnimV2Index ).Get(), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector3(1.f, 2.f, 3.f) , actor.GetProperty( nonAnimV3Index ).Get(), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector4(1.f, 2.f, 3.f, 4.f) , actor.GetProperty( nonAnimV4Index ).Get(), TEST_LOCATION ); + DALI_TEST_EQUALS( true, actor.GetProperty( nonAnimBooleanIndex ).Get(), TEST_LOCATION ); + DALI_TEST_EQUALS( 0.f, actor.GetProperty( nonAnimFloatIndex ).Get(), TEST_LOCATION ); + DALI_TEST_EQUALS( unsingedIntTest, actor.GetProperty( nonAnimUnsignedIntIndex ).Get(), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliHandleNonAnimtableProperties(void) +{ + tet_infoline("Test Non Animatable Properties"); + TestApplication application; + + Actor actor = Actor::New(); + + Property::Index nonAnimStringIndex = actor.RegisterProperty( "man-from-delmonte", std::string("no"), Property::READ_WRITE); + + //// modify writable? + try + { + actor.SetProperty( nonAnimStringIndex, Property::Value("yes") ); + } + catch (Dali::DaliException& e) + { + DALI_TEST_CHECK(!"exception"); + } + + DALI_TEST_CHECK( "yes" == actor.GetProperty( nonAnimStringIndex ).Get() ); + + //// cannot modify read only? + Property::Index readonly = actor.RegisterProperty( "float", 0.f, Property::READ_ONLY); + + DALI_TEST_CHECK(!actor.IsPropertyAnimatable(readonly)); + DALI_TEST_CHECK(!actor.IsPropertyWritable(readonly)); + + bool exception = false; + try + { + actor.SetProperty( readonly, Property::Value(1.f) ); + } + catch (Dali::DaliException& e) + { + exception = true; + } + + DALI_TEST_CHECK(exception); + + DALI_TEST_EQUALS( 0.f, actor.GetProperty( readonly ).Get(), TEST_LOCATION ); + + /// animatable can be set + Property::Index write_anim = actor.RegisterProperty( "write_float", 0.f, Property::ANIMATABLE); + + DALI_TEST_CHECK(actor.IsPropertyAnimatable(write_anim)); + DALI_TEST_CHECK(actor.IsPropertyWritable(write_anim)); + + exception = false; + try + { + actor.SetProperty( write_anim, Property::Value(1.f) ); + } + catch (Dali::DaliException& e) + { + exception = true; + } + + DALI_TEST_CHECK(!exception); + + //// animate a non animatable property is a noop? + float durationSeconds(2.0f); + Animation animation = Animation::New(durationSeconds); + bool relativeValue(true); + + exception = false; + + try + { + animation.AnimateBy(Property(actor, nonAnimStringIndex), relativeValue, AlphaFunctions::EaseIn); + animation.Play(); + application.SendNotification(); + application.Render(static_cast(durationSeconds*0100.0f)/* some progress */); + } + catch (Dali::DaliException& e) + { + exception = true; + } + + DALI_TEST_CHECK(!exception); + DALI_TEST_EQUALS( "yes", actor.GetProperty( nonAnimStringIndex ).Get(), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliHandleNonAnimtableCompositeProperties(void) +{ + tet_infoline("Test Non Animatable Composite Properties"); + TestApplication application; + + Actor actor = Actor::New(); + + Property::Value value(Property::ARRAY); + Property::Array anArray; + DALI_TEST_CHECK( Property::Value(anArray).GetType() == Property::ARRAY ); // 2nd constructor + + value.AppendItem( Property::Value( 0.f ) ); + value.AppendItem( "a string" ); + value.SetItem(0, Property::Value( 5.f )); // exercise SetItem + + int index = value.AppendItem( Vector3(1,2,3) ); + + DALI_TEST_EQUALS( 2, index, TEST_LOCATION); + DALI_TEST_EQUALS( 3, value.GetSize(), TEST_LOCATION); + + Property::Index propertyIndex = actor.RegisterProperty( "composite", value, Property::READ_WRITE); + + Property::Value out = actor.GetProperty( propertyIndex ); + + DALI_TEST_CHECK( Property::FLOAT == out.GetItem(0).GetType()); + DALI_TEST_CHECK( Property::STRING == out.GetItem(1).GetType()); + DALI_TEST_CHECK( Property::VECTOR3 == out.GetItem(2).GetType()); + + DALI_TEST_EQUALS( 5.f, out.GetItem(0).Get(), TEST_LOCATION); + DALI_TEST_EQUALS( "a string", out.GetItem(1).Get(), TEST_LOCATION); + DALI_TEST_EQUALS( Vector3(1,2,3), out.GetItem(2).Get(), TEST_LOCATION); + + // Property Maps + Property::Value valueMap(Property::MAP); + Property::Map aKindofMap; + DALI_TEST_CHECK( Property::Value(aKindofMap).GetType() == Property::MAP ); // 2nd constructor + + valueMap.SetValue("key", 5.f); + valueMap.SetValue("2key", "a string"); + + DALI_TEST_EQUALS( true, valueMap.HasKey("key"), TEST_LOCATION); + DALI_TEST_EQUALS( "key", valueMap.GetKey(0), TEST_LOCATION); + + DALI_TEST_EQUALS( true, valueMap.HasKey("2key"), TEST_LOCATION); + DALI_TEST_EQUALS( "2key", valueMap.GetKey(1), TEST_LOCATION); + + DALI_TEST_EQUALS( 5.f, valueMap.GetValue("key").Get(), TEST_LOCATION); + DALI_TEST_EQUALS( "a string", valueMap.GetValue("2key").Get(), TEST_LOCATION); + + valueMap.SetItem(0, Property::Value("a string")); + valueMap.SetItem(1, Property::Value(5.f)); + + DALI_TEST_EQUALS( 5.f, valueMap.GetValue("2key").Get(), TEST_LOCATION); + DALI_TEST_EQUALS( "a string", valueMap.GetValue("key").Get(), TEST_LOCATION); + + // ordered map + valueMap = Property::Value(Property::MAP); + + valueMap.SetValue("key", 5.f); + valueMap.SetValue("2key", "a string"); + + DALI_TEST_EQUALS( 5.f, valueMap.GetItem(0).Get(), TEST_LOCATION); + DALI_TEST_EQUALS( "a string", valueMap.GetItem(1).Get(), TEST_LOCATION); + + DALI_TEST_EQUALS( 2, valueMap.GetSize(), TEST_LOCATION); + + // composite types not animatable + bool exception = false; + try + { + /* Property::Index mapPropertyIndex = */ actor.RegisterProperty( "compositemap", value, Property::ANIMATABLE); + } + catch (Dali::DaliException& e) + { + exception = true; + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + } + + DALI_TEST_EQUALS(exception, true, TEST_LOCATION); + + // Map of maps + Property::Value mapOfMaps(Property::MAP); + + mapOfMaps.SetValue( "key", Property::Value(Property::MAP) ); + mapOfMaps.SetValue( "2key", "a string" ); + + DALI_TEST_EQUALS( "a string", mapOfMaps.GetValue("2key").Get(), TEST_LOCATION); + + mapOfMaps.GetValue("key").SetValue("subkey", 5.f); + + DALI_TEST_EQUALS( true, mapOfMaps.GetValue("key").HasKey("subkey"), TEST_LOCATION); + DALI_TEST_EQUALS( 5.f, mapOfMaps.GetValue("key").GetValue("subkey").Get(), TEST_LOCATION); + + // list of maps + Property::Value listOfMaps(Property::ARRAY); + + listOfMaps.AppendItem( Property::Value(Property::MAP) ); + listOfMaps.AppendItem( Property::Value(Property::MAP) ); + + listOfMaps.GetItem(0).SetValue("key", 5.f); + listOfMaps.GetItem(1).SetValue("key",10.f); + + DALI_TEST_EQUALS( 5.f, listOfMaps.GetItem(0).GetValue("key").Get(), TEST_LOCATION ); + DALI_TEST_EQUALS( 10.f, listOfMaps.GetItem(1).GetValue("key").Get(), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliHandleSetProperty01(void) +{ + tet_infoline("Positive Test Dali::Handle::SetProperty()"); + TestApplication application; + + Actor actor = Actor::New(); + DALI_TEST_CHECK( ParentOrigin::TOP_LEFT == actor.GetProperty( Actor::PARENT_ORIGIN ).Get() ); + + actor.SetProperty( Actor::PARENT_ORIGIN, ParentOrigin::CENTER ); + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK( ParentOrigin::CENTER == actor.GetProperty( Actor::PARENT_ORIGIN ).Get() ); + END_TEST; +} + +int UtcDaliHandleSetProperty02(void) +{ + tet_infoline("Positive Test Dali::Handle::SetProperty()"); + TestApplication application; + + Actor actor = Actor::New(); + + DALI_TEST_CHECK( !actor.IsPropertyWritable( Actor::WORLD_POSITION ) ); + + try + { + // World position is not writable + actor.SetProperty( Actor::WORLD_POSITION, Vector3(1,2,3) ); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "IsDefaultPropertyWritable(index) && \"Property is read-only\"", TEST_LOCATION); + } + + END_TEST; +} + +int UtcDaliHandleRegisterProperty(void) +{ + tet_infoline("Positive Test Dali::Handle::RegisterProperty()"); + TestApplication application; + + Actor actor = Actor::New(); + DALI_TEST_CHECK( ParentOrigin::TOP_LEFT == actor.GetProperty( Actor::PARENT_ORIGIN ).Get() ); + + END_TEST; +} + +int UtcDaliHandleGetProperty(void) +{ + tet_infoline("Positive Test Dali::Handle::GetProperty()"); + TestApplication application; + + Actor actor = Actor::New(); + + DALI_TEST_CHECK( ParentOrigin::TOP_LEFT == actor.GetProperty( Actor::PARENT_ORIGIN ).Get() ); + DALI_TEST_CHECK( AnchorPoint::CENTER == actor.GetProperty( Actor::ANCHOR_POINT ).Get() ); + DALI_TEST_CHECK( Vector3::ZERO == actor.GetProperty( Actor::SIZE ).Get() ); + DALI_TEST_CHECK( Vector3::ZERO == actor.GetProperty( Actor::POSITION ).Get() ); + DALI_TEST_CHECK( Vector3::ONE == actor.GetProperty( Actor::SCALE ).Get() ); + DALI_TEST_CHECK( true == actor.GetProperty( Actor::VISIBLE ).Get() ); + DALI_TEST_CHECK( Color::WHITE == actor.GetProperty( Actor::COLOR ).Get() ); + END_TEST; +} + +int UtcDaliHandleDownCast(void) +{ + TestApplication application; + tet_infoline("Testing Dali::Handle::DownCast()"); + + Actor actor = Actor::New(); + + BaseHandle baseHandle = actor; + + Handle handle = Handle::DownCast(baseHandle); + + DALI_TEST_CHECK( handle ); + + baseHandle = BaseHandle(); + + handle = Handle::DownCast(baseHandle); + + DALI_TEST_CHECK( !handle ); + + END_TEST; +} + +int UtcDaliHandleCreateProperty(void) +{ + TestApplication application; + tet_infoline("Testing PropertyTypes::GetName()"); + + Property::Type type = Property::NONE; + CheckTypeName(type); + // Value(Value&) ctor and Value(Type&) ctor + DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type ); + DALI_TEST_CHECK( Property::NONE == type ); + + // PropertyTypes + type = Property::BOOLEAN; + CheckTypeName(type); + DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type ); + DALI_TEST_CHECK( PropertyTypes::Get() == type ); + + type = Property::FLOAT; + CheckTypeName(type); + DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type ); + DALI_TEST_CHECK( PropertyTypes::Get() == type ); + + type = Property::INTEGER; + CheckTypeName(type); + DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type ); + DALI_TEST_CHECK( PropertyTypes::Get() == type ); + + type = Property::UNSIGNED_INTEGER; + CheckTypeName(type); + DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type ); + DALI_TEST_CHECK( PropertyTypes::Get() == type ); + + type = Property::VECTOR2; + CheckTypeName(type); + DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type ); + DALI_TEST_CHECK( PropertyTypes::Get() == type ); + + type = Property::VECTOR3; + CheckTypeName(type); + DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type ); + DALI_TEST_CHECK( PropertyTypes::Get() == type ); + + type = Property::VECTOR4; + CheckTypeName(type); + DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type ); + DALI_TEST_CHECK( PropertyTypes::Get() == type ); + + type = Property::MATRIX3; + CheckTypeName(type); + DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type ); + DALI_TEST_CHECK( PropertyTypes::Get() == type ); + + type = Property::MATRIX; + CheckTypeName(type); + DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type ); + DALI_TEST_CHECK( PropertyTypes::Get() == type ); + + typedef Dali::Rect Rectangle; + type = Property::RECTANGLE; + CheckTypeName(type); + DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type ); + DALI_TEST_CHECK( PropertyTypes::Get() == type ); + + type = Property::ROTATION; + CheckTypeName(type); + DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type ); + DALI_TEST_CHECK( PropertyTypes::Get() == type ); + + type = Property::ROTATION; + CheckTypeName(type); + DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type ); + DALI_TEST_CHECK( PropertyTypes::Get() == type ); + + type = Property::STRING; + CheckTypeName(type); + DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type ); + DALI_TEST_CHECK( PropertyTypes::Get() == type ); + + type = Property::ARRAY; + CheckTypeName(type); + DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type ); + DALI_TEST_CHECK( PropertyTypes::Get() == type ); + + type = Property::MAP; + CheckTypeName(type); + DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type ); + DALI_TEST_CHECK( PropertyTypes::Get() == type ); + END_TEST; +} + +int UtcDaliHandleGetPropertyGet(void) +{ + TestApplication application; + tet_infoline("Testing PropertyTypes::GetName()"); + + Property::Value value; + + bool b = false; + value = Property::Value(true); + value.Get(b); + DALI_TEST_CHECK( true == b ); + + float f = 5.f; + value = Property::Value(10.f); + value.Get(f); + DALI_TEST_CHECK( Dali::Equals(10.f, f) ); + + int i = 5; + value = Property::Value(10); + value.Get(i); + DALI_TEST_CHECK( 10 == i ); + + unsigned int ui = 5; + value = Property::Value(10U); + value.Get(ui); + DALI_TEST_CHECK( 10 == ui ); + + Vector2 v2 = Vector2(0,0); + value = Property::Value( Vector2(1,1) ); + value.Get(v2); + DALI_TEST_CHECK( Vector2(1,1) == v2 ); + + Vector3 v3 = Vector3(0.f,0.f,0.f); + value = Property::Value( Vector3(1.f,1.f,1.f) ); + value.Get(v3); + DALI_TEST_CHECK( Vector3(1.f,1.f,1.f) == v3 ); + + Vector4 v4 = Vector4(0,0,0,0); + value = Property::Value( Vector4(1,1,1,1) ); + value.Get(v4); + DALI_TEST_CHECK( Vector4(1,1,1,1) == v4 ); + + Matrix3 m3 = Matrix3(0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f); + value = Property::Value( Matrix3::IDENTITY ); + value.Get(m3); + DALI_TEST_CHECK( Matrix3::IDENTITY == m3 ); + + Matrix m = Matrix(true); + value = Property::Value( Matrix::IDENTITY ); + value.Get(m); + DALI_TEST_CHECK( Matrix::IDENTITY == m ); + + typedef Dali::Rect Rectangle; + Rectangle r = Rectangle(0,0,0,0); + value = Property::Value( Rectangle(1,1,1,1) ); + value.Get(r); + DALI_TEST_CHECK( Rectangle(1,1,1,1) == r ); + + Quaternion q = Quaternion(0,0,0,0); + value = Property::Value( Quaternion(1,1,1,1) ); + value.Get(q); + DALI_TEST_CHECK( Quaternion(1,1,1,1) == q ); + + AngleAxis aa = AngleAxis( Degree(0), Vector3(0.f,0.f,0.f) ); + value = Property::Value( AngleAxis( Radian(Math::PI_2), Vector3::XAXIS )); + value.Get(aa); + Quaternion r8(Radian(Degree(aa.angle)), aa.axis); + DALI_TEST_EQUALS(r8, Quaternion(Math::PI_2, Vector3::XAXIS), 0.001, TEST_LOCATION); + + std::string s = "no"; + value = Property::Value("yes"); + value.Get(s); + DALI_TEST_CHECK( "yes" == s ); + + Property::Array array; + value = Property::Value(Property::ARRAY); + value.AppendItem(10); + value.Get(array); + int getItem = 0; + array[0].Get(getItem); + DALI_TEST_CHECK( getItem == 10 ); + + Property::Map map; + value = Property::Value(Property::MAP); + value.SetValue("key", "value"); + value.Get(map); + DALI_TEST_CHECK( map[0].first == "key" ); + + END_TEST; +} + +int UtcDaliHandleGetPropertyIndices(void) +{ + TestApplication application; + Property::IndexContainer indices; + + // Actor + Actor actor = Actor::New(); + actor.GetPropertyIndices( indices ); + DALI_TEST_CHECK( ! indices.empty() ); + DALI_TEST_EQUALS( indices.size(), actor.GetPropertyCount(), TEST_LOCATION ); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Image.cpp b/automated-tests/src/dali/utc-Dali-Image.cpp new file mode 100644 index 0000000..5fc897f --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-Image.cpp @@ -0,0 +1,1094 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 +#include + +using namespace Dali; + +void utc_dali_image_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_image_cleanup(void) +{ + test_return_value = TET_PASS; +} + +static const char* gTestImageFilename = "icon_wrt.png"; + + +// 1.1 +int UtcDaliImageNew01(void) +{ + TestApplication application; + + tet_infoline("UtcDaliImageNew01 - Image::New(const std::string&)"); + + // invoke default handle constructor + Image image; + + DALI_TEST_CHECK( !image ); + + // initialise handle + image = Image::New(gTestImageFilename); + + DALI_TEST_CHECK( image ); + END_TEST; +} + +// 1.2 +int UtcDaliImageNew02(void) +{ + TestApplication application; + + tet_infoline("UtcDaliImageNew02 - Image::New(const std::string&, const ImageAttributes&)"); + + // invoke default handle constructor + Image image; + + DALI_TEST_CHECK( !image ); + + // initialise handle + Dali::ImageAttributes imageAttributes; + imageAttributes.SetSize(128, 256); + imageAttributes.SetScalingMode(Dali::ImageAttributes::FitHeight); + image = Image::New(gTestImageFilename, imageAttributes); + + DALI_TEST_CHECK( image ); + END_TEST; +} + +// 1.3 +int UtcDaliImageNew03(void) +{ + TestApplication application; + + tet_infoline("UtcDaliImageNew03 - Image::New(NativeImage&)"); + + // invoke default handle constructor + Image image; + TestNativeImagePointer nativeImage = TestNativeImage::New(16, 16); + + DALI_TEST_CHECK( !image ); + + // initialise handle + image = Image::New(*(nativeImage.Get())); + + DALI_TEST_CHECK( image ); + END_TEST; +} + +// 1.4 +int UtcDaliImageNewWithPolicies01(void) +{ + TestApplication application; + + // testing delayed loading + tet_infoline("UtcDaliImageNewWithPolicies01 - Load image with LoadPolicy::OnDemand, ReleasePolicy::Never"); + DALI_TEST_CHECK( !application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + Image image = Image::New(gTestImageFilename, Image::OnDemand, Image::Never); + + DALI_TEST_CHECK( image ); + + application.SendNotification(); + application.Render(16); + + // request file loading only when actor added to stage + DALI_TEST_CHECK( !application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + + ImageActor actor = ImageActor::New(image); + + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(16); + + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + + // testing ReleasePolicy::Never + // fake loading image + std::vector ids; + ids.push_back( 23 ); + application.GetGlAbstraction().SetNextTextureIds( ids ); + Integration::ResourceRequest* request = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true ); + Integration::ResourcePointer resource(bitmap); + bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80); + + if(request) + { + application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource); + } + application.Render(16); + application.SendNotification(); + + DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) ); + + // never discard texture + Stage::GetCurrent().Remove(actor); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) ); + END_TEST; +} + +// 1.5 +int UtcDaliImageNewWithPolicies02(void) +{ + TestApplication application; + + // testing resource deletion when taken off stage + tet_infoline("UtcDaliImageNewWithPolicies02 - Load image with LoadPolicy::OnDemand, ReleasePolicy::Unused"); + + Image image = Image::New(gTestImageFilename, Image::OnDemand, Image::Unused); + + DALI_TEST_CHECK( image ); + + application.SendNotification(); + application.Render(16); + + // request file loading only when actor added to stage + DALI_TEST_CHECK( !application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + + ImageActor actor = ImageActor::New(image); + + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(16); + + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + + // testing ReleasePolicy::Unused + // fake loading image + std::vector ids; + ids.push_back( 23 ); + application.GetGlAbstraction().SetNextTextureIds( ids ); + Integration::ResourceRequest* request = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true ); + Integration::ResourcePointer resource(bitmap); + bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80); + + if(request) + { + application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource); + } + application.Render(16); + application.SendNotification(); + + DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) ); + + // discard texture when actor comes off stage + Stage::GetCurrent().Remove(actor); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + DALI_TEST_CHECK ( application.GetGlAbstraction().CheckTextureDeleted(23) ); + END_TEST; +} + +// 1.6 +int UtcDaliImageNewWithPolicies03(void) +{ + TestApplication application; + + // load immediately -> resource deletion when taken off stage -> put actor back on stage -> load resource again + tet_infoline("UtcDaliImageNewWithPolicies03 - Load image with LoadPolicy::Immediate, ReleasePolicy::Unused"); + + Image image = Image::New(gTestImageFilename, Image::Immediate, Image::Unused); + + DALI_TEST_CHECK( image ); + + application.SendNotification(); + application.Render(16); + + // request file loading immediately + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + + ImageActor actor = ImageActor::New(image); + + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(16); + + // testing ReleasePolicy::Unused + // fake loading image + std::vector ids; + ids.push_back( 23 ); + application.GetGlAbstraction().SetNextTextureIds( ids ); + Integration::ResourceRequest* request = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true ); + Integration::ResourcePointer resource(bitmap); + bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80); + + if(request) + { + application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource); + } + application.Render(16); + application.SendNotification(); + + DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) ); + + // discard texture when actor comes off stage + Stage::GetCurrent().Remove(actor); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + DALI_TEST_CHECK ( application.GetGlAbstraction().CheckTextureDeleted(23) ); + + // check load request when actor added back to stage + application.GetPlatform().ResetTrace(); + + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(16); + application.SendNotification(); + application.Render(16); + + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + END_TEST; +} + +// 1.7 +int UtcDaliImageNewWithPolicies04(void) +{ + TestApplication application; + + // load immediately, don't release texture when off stage + tet_infoline("UtcDaliImageNewWithPolicies03 - Load image with LoadPolicy::Immediate, ReleasePolicy::Never"); + + Image image = Image::New(gTestImageFilename, Image::Immediate, Image::Never); + + DALI_TEST_CHECK( image ); + + application.SendNotification(); + application.Render(16); + + // request file loading immediately + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + + ImageActor actor = ImageActor::New(image); + + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(16); + + // testing ReleasePolicy::Never + // fake loading image + std::vector ids; + ids.push_back( 23 ); + application.GetGlAbstraction().SetNextTextureIds( ids ); + Integration::ResourceRequest* request = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true ); + Integration::ResourcePointer resource(bitmap); + bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80); + + if(request) + { + application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource); + } + application.Render(16); + application.SendNotification(); + + DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) ); + + // texture is not discarded + Stage::GetCurrent().Remove(actor); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) ); + + // no load request when actor added back to stage + application.GetPlatform().ResetTrace(); + + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(16); + application.SendNotification(); + application.Render(16); + + DALI_TEST_CHECK( !application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + END_TEST; +} + +// 1.8 +int UtcDaliImageNewDistanceField(void) +{ + TestApplication application; + + tet_infoline("UtcDaliImageNewDistanceField - Image::NewDistanceField(const std::string&)"); + + // invoke default handle constructor + Image image; + + DALI_TEST_CHECK( !image ); + + // initialise handle + image = Image::NewDistanceField(gTestImageFilename); + + DALI_TEST_CHECK( image ); + END_TEST; +} + +// 1.9 +int UtcDaliImageNewDistanceFieldWithPolicies01(void) +{ + TestApplication application; + + // testing delayed loading + tet_infoline("UtcDaliImageNewDistanceFieldWithPolicies01 - Load image with LoadPolicy::OnDemand, ReleasePolicy::Never"); + DALI_TEST_CHECK( !application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + Image image = Image::NewDistanceField(gTestImageFilename, Image::OnDemand, Image::Never); + + DALI_TEST_CHECK( image ); + + application.SendNotification(); + application.Render(16); + + // request file loading only when actor added to stage + DALI_TEST_CHECK( !application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + + ImageActor actor = ImageActor::New(image); + + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(16); + + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + + // testing ReleasePolicy::Never + // fake loading image + std::vector ids; + ids.push_back( 23 ); + application.GetGlAbstraction().SetNextTextureIds( ids ); + Integration::ResourceRequest* request = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true ); + Integration::ResourcePointer resource(bitmap); + bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80); + + if(request) + { + application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource); + } + application.Render(16); + application.SendNotification(); + + DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) ); + + // never discard texture + Stage::GetCurrent().Remove(actor); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) ); + END_TEST; +} + +// 1.10 +int UtcDaliImageNewDistanceFieldWithPolicies02(void) +{ + TestApplication application; + + // testing resource deletion when taken off stage + tet_infoline("UtcDaliImageNewDistanceFieldWithPolicies02 - Load image with LoadPolicy::OnDemand, ReleasePolicy::Unused"); + + Image image = Image::NewDistanceField(gTestImageFilename, Image::OnDemand, Image::Unused); + + DALI_TEST_CHECK( image ); + + application.SendNotification(); + application.Render(16); + + // request file loading only when actor added to stage + DALI_TEST_CHECK( !application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + + ImageActor actor = ImageActor::New(image); + + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(16); + + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + + // testing ReleasePolicy::Unused + // fake loading image + std::vector ids; + ids.push_back( 23 ); + application.GetGlAbstraction().SetNextTextureIds( ids ); + Integration::ResourceRequest* request = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true ); + Integration::ResourcePointer resource(bitmap); + bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80); + + if(request) + { + application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource); + } + application.Render(16); + application.SendNotification(); + + DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) ); + + // discard texture when actor comes off stage + Stage::GetCurrent().Remove(actor); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + DALI_TEST_CHECK ( application.GetGlAbstraction().CheckTextureDeleted(23) ); + END_TEST; +} + +// 1.11 +int UtcDaliImageNewDistanceFieldWithPolicies03(void) +{ + TestApplication application; + + // load immediately -> resource deletion when taken off stage -> put actor back on stage -> load resource again + tet_infoline("UtcDaliImageNewDistanceFieldWithPolicies03 - Load image with LoadPolicy::Immediate, ReleasePolicy::Unused"); + + Image image = Image::NewDistanceField(gTestImageFilename, Image::Immediate, Image::Unused); + + DALI_TEST_CHECK( image ); + + application.SendNotification(); + application.Render(16); + + // request file loading immediately + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + + ImageActor actor = ImageActor::New(image); + + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(16); + + // testing ReleasePolicy::Unused + // fake loading image + std::vector ids; + ids.push_back( 23 ); + application.GetGlAbstraction().SetNextTextureIds( ids ); + Integration::ResourceRequest* request = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true ); + Integration::ResourcePointer resource(bitmap); + bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80); + + if(request) + { + application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource); + } + application.Render(16); + application.SendNotification(); + + DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) ); + + // discard texture when actor comes off stage + Stage::GetCurrent().Remove(actor); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + DALI_TEST_CHECK ( application.GetGlAbstraction().CheckTextureDeleted(23) ); + + // check load request when actor added back to stage + application.GetPlatform().ResetTrace(); + + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(16); + application.SendNotification(); + application.Render(16); + + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + END_TEST; +} + +// 1.12 +int UtcDaliImageNewDistanceFieldWithPolicies04(void) +{ + TestApplication application; + + // load immediately, don't release texture when off stage + tet_infoline("UtcDaliImageNewDistanceFieldWithPolicies04 - Load image with LoadPolicy::Immediate, ReleasePolicy::Never"); + + Image image = Image::NewDistanceField(gTestImageFilename, Image::Immediate, Image::Never); + + DALI_TEST_CHECK( image ); + + application.SendNotification(); + application.Render(16); + + // request file loading immediately + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + + ImageActor actor = ImageActor::New(image); + + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(16); + + // testing ReleasePolicy::Never + // fake loading image + std::vector ids; + ids.push_back( 23 ); + application.GetGlAbstraction().SetNextTextureIds( ids ); + Integration::ResourceRequest* request = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true ); + Integration::ResourcePointer resource(bitmap); + bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80); + + if(request) + { + application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource); + } + application.Render(16); + application.SendNotification(); + + DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) ); + + // texture is not discarded + Stage::GetCurrent().Remove(actor); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) ); + + // no load request when actor added back to stage + application.GetPlatform().ResetTrace(); + + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(16); + application.SendNotification(); + application.Render(16); + + DALI_TEST_CHECK( !application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + END_TEST; +} + +// 1.13 +int UtcDaliImageNewDistanceFieldWithAttributes(void) +{ + TestApplication application; + + tet_infoline("UtcDaliImageNewDistanceFieldWithAttributes - Image::NewDistanceField(const std::string&, const ImageAttributes& attributes)"); + + // invoke default handle constructor + Image image; + Dali::ImageAttributes imageAttributes = Dali::ImageAttributes::NewDistanceField(6.0f, 12); + + DALI_TEST_CHECK( !image ); + + // initialise handle + image = Image::NewDistanceField(gTestImageFilename, imageAttributes); + + DALI_TEST_CHECK( image ); + END_TEST; +} + +// 1.14 +int UtcDaliImageNewDistanceFieldWithAttrandPol(void) +{ + TestApplication application; + + tet_infoline("UtcDaliImageNewDistanceFieldWithAttrandPol - Load image with LoadPolicy::OnDemand, ReleasePolicy::Unused"); + + Dali::ImageAttributes imageAttributes = Dali::ImageAttributes::NewDistanceField(6.0f, 12); + + Image image = Image::NewDistanceField(gTestImageFilename, imageAttributes, Image::OnDemand, Image::Unused); + + DALI_TEST_CHECK( image ); + + application.SendNotification(); + application.Render(16); + + // request file loading only when actor added to stage + DALI_TEST_CHECK( !application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + + ImageActor actor = ImageActor::New(image); + + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(16); + + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + + // testing ReleasePolicy::Unused + // fake loading image + std::vector ids; + ids.push_back( 23 ); + application.GetGlAbstraction().SetNextTextureIds( ids ); + Integration::ResourceRequest* request = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true ); + Integration::ResourcePointer resource(bitmap); + bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80); + + if(request) + { + application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource); + } + application.Render(16); + application.SendNotification(); + + DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) ); + + // discard texture when actor comes off stage + Stage::GetCurrent().Remove(actor); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + DALI_TEST_CHECK ( application.GetGlAbstraction().CheckTextureDeleted(23) ); + END_TEST; +} + +// 1.15 +int UtcDaliImageDownCast(void) +{ + TestApplication application; + tet_infoline("Testing Dali::Image::DownCast()"); + + Image image = Image::New(gTestImageFilename); + + BaseHandle object(image); + + Image image2 = Image::DownCast(object); + DALI_TEST_CHECK(image2); + + Image image3 = DownCast< Image >(object); + DALI_TEST_CHECK(image3); + + BaseHandle unInitializedObject; + Image image4 = Image::DownCast(unInitializedObject); + DALI_TEST_CHECK(!image4); + + Image image5 = DownCast< Image >(unInitializedObject); + DALI_TEST_CHECK(!image5); + END_TEST; +} + +// 1.16 +int UtcDaliImageGetImageSize(void) +{ + TestApplication application; + TestPlatformAbstraction& platform = application.GetPlatform(); + + tet_infoline("UtcDaliImageGetImageSize - Image::GetImageSize()"); + + Vector2 testSize(8.0f, 16.0f); + platform.SetClosestImageSize(testSize); + + Vector2 size = Image::GetImageSize(gTestImageFilename); + + DALI_TEST_CHECK( application.GetPlatform().GetTrace().FindMethod("GetClosestImageSize")); + DALI_TEST_EQUALS( size, testSize, TEST_LOCATION); + END_TEST; +} + +// 1.17 +int UtcDaliImageGetFilename(void) +{ + TestApplication application; + + tet_infoline("UtcDaliImageGetFilename"); + + // invoke default handle constructor + Image image; + + DALI_TEST_CHECK( !image ); + + // initialise handle + image = Image::New(gTestImageFilename); + + DALI_TEST_EQUALS( image.GetFilename(), gTestImageFilename, TEST_LOCATION); + END_TEST; +} + +// 1.18 +int UtcDaliImageGetLoadingState01(void) +{ + TestApplication application; + tet_infoline("UtcDaliImageGetLoadingState01"); + + Image image = Image::New(gTestImageFilename); + DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoading); + application.SendNotification(); + application.Render(16); + + // simulate load success + Integration::ResourceRequest* request = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true ); + Integration::ResourcePointer resource(bitmap); + bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80); + + if(request) + { + application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource); + } + application.Render(16); + application.SendNotification(); + + // Test state == ResourceLoadingSucceeded + DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoadingSucceeded); + END_TEST; +} + +// 1.19 +int UtcDaliImageGetLoadingState02(void) +{ + TestApplication application; + + tet_infoline("UtcDaliImageGetLoadingState02"); + + // invoke default handle constructor + Image image; + + DALI_TEST_CHECK( !image ); + + // initialise handle + image = Image::New(gTestImageFilename); + + // Test state == ResourceLoading + DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoading); + application.SendNotification(); + application.Render(16); + + // simulate load failure + Integration::ResourceRequest* request = application.GetPlatform().GetRequest(); + if(request) + { + application.GetPlatform().SetResourceLoadFailed(request->GetId(), Integration::FailureUnknown); + } + application.Render(16); + application.SendNotification(); + + // Test state == ResourceLoadingFailed + DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoadingFailed); + END_TEST; +} + +// 1.20 +int UtcDaliImageGetReleasePolicy(void) +{ + TestApplication application; + + tet_infoline("UtcDaliImageGetReleasePolicy"); + + Image image = Image::New(gTestImageFilename, Image::Immediate, Image::Unused); + + DALI_TEST_CHECK( image ); + + DALI_TEST_CHECK( Image::Unused == image.GetReleasePolicy() ); + + END_TEST; +} + +// 1.21 +int UtcDaliImageGetLoadPolicy(void) +{ + TestApplication application; + + tet_infoline("UtcDaliImageGetLoadPolicy"); + + Image image = Image::New(gTestImageFilename, Image::OnDemand, Image::Never); + + DALI_TEST_CHECK( image ); + + DALI_TEST_CHECK( Image::OnDemand == image.GetLoadPolicy()); + END_TEST; +} + +static bool SignalLoadFlag = false; + +static void SignalLoadHandler(Image image) +{ + tet_infoline("Received image load finished signal"); + + SignalLoadFlag = true; +} + +static bool SignalUploadedFlag = false; + +static void SignalUploadedHandler(Image image) +{ + tet_infoline("Received image uploaded signal"); + + SignalUploadedFlag = true; +} + +// 1.22 +int UtcDaliImageSignalLoadingFinished(void) +{ + TestApplication application; + + tet_infoline("UtcDaliImageSignalLoadingFinished"); + + SignalLoadFlag = false; + + Image image = Image::New(gTestImageFilename); + + image.LoadingFinishedSignal().Connect( SignalLoadHandler ); + application.SendNotification(); + application.Render(16); + + Integration::ResourceRequest* request = application.GetPlatform().GetRequest(); + if(request) + { + application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, Integration::ResourcePointer(Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true))); + } + + application.Render(16); + application.SendNotification(); + + DALI_TEST_CHECK( SignalLoadFlag == true ); + END_TEST; +} + +// 1.23 +int UtcDaliImageSignalUploaded(void) +{ + TestApplication application; + tet_infoline("UtcDaliImageSignalUploaded - Image::SignalUploaded()"); + + // set up image in fake platform abstraction + Vector2 testSize(80.0f, 80.0f); + application.GetPlatform().SetClosestImageSize(testSize); + + Image image = Image::New(gTestImageFilename); + image.LoadingFinishedSignal().Connect( SignalLoadHandler ); + + // Load image + application.SendNotification(); + application.Render(16); + std::vector ids; + ids.push_back( 23 ); + application.GetGlAbstraction().SetNextTextureIds( ids ); + Integration::ResourceRequest* request = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true ); + Integration::ResourcePointer resource(bitmap); + bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80); + if(request) + { + application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource); + } + application.Render(16); + application.SendNotification(); + + image.UploadedSignal().Connect( SignalUploadedHandler ); + + Dali::ImageActor imageActor = ImageActor::New(image); + Stage::GetCurrent().Add(imageActor); + imageActor.SetSize(80, 80); + imageActor.SetVisible(true); + + application.SendNotification(); + application.Render(0); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + + DALI_TEST_CHECK( SignalLoadFlag == true ); + DALI_TEST_CHECK( SignalUploadedFlag == true ); + SignalLoadFlag = false; + SignalUploadedFlag = false; + + image.Reload(); + bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 160, 160, 160, 160); + + application.SendNotification(); + application.Render(16); + application.Render(16); + application.SendNotification(); + DALI_TEST_CHECK( SignalLoadFlag == true ); + + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + DALI_TEST_CHECK( SignalUploadedFlag == true ); + END_TEST; +} + + +// 1.24 +int UtcDaliImageDiscard01(void) +{ + TestApplication application; + tet_infoline("UtcDaliImageDiscard01 - no actors"); + + { + Image image = Image::New(gTestImageFilename); + + // Load image + application.SendNotification(); + application.Render(16); + std::vector ids; + ids.push_back( 23 ); + application.GetGlAbstraction().SetNextTextureIds( ids ); + Integration::ResourceRequest* request = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true ); + Integration::ResourcePointer resource(bitmap); + bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80); + if(request) + { + application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource); + } + application.Render(16); + application.SendNotification(); + } // Drop image handle + + application.SendNotification(); + application.Render(16); + application.Render(16); + application.SendNotification(); + + // Shouldn't have been sent to GL... + const std::vector& texIds = application.GetGlAbstraction().GetNextTextureIds(); + DALI_TEST_CHECK( texIds.size() == 1 ); + DALI_TEST_CHECK( texIds[0] == 23 ); + END_TEST; +} + +// 1.25 +int UtcDaliImageDiscard02(void) +{ + TestApplication application; + tet_infoline("UtcDaliImageDiscard02 - one actor, tests TextureCache::DiscardTexture"); + + { + { + ImageActor actor; + { + Image image = Image::New(gTestImageFilename); + actor = ImageActor::New(image); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(16); + + std::vector ids; + ids.push_back( 23 ); + application.GetGlAbstraction().SetNextTextureIds( ids ); + + Integration::ResourceRequest* request = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true ); + Integration::ResourcePointer resource(bitmap); + bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80); + if(request) + { + application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource); + } + application.Render(16); + application.SendNotification(); + } // lose image handle, actor should still keep one + application.SendNotification(); + application.Render(16); + + Stage::GetCurrent().Remove(actor); + application.SendNotification(); + application.Render(16); + } // lose actor + application.SendNotification(); + application.Render(16); + } + + // Cleanup + application.SendNotification(); + application.Render(16); + application.Render(16); + application.SendNotification(); + + // texture should have been removed: + DALI_TEST_CHECK( application.GetGlAbstraction().CheckTextureDeleted( 23 )); + END_TEST; +} + +// 1.26 +int UtcDaliImageDiscard03(void) +{ + TestApplication application; + tet_infoline("UtcDaliImageDiscard03 - one actor, tests TextureCache::RemoveObserver"); + + Image image = Image::New(gTestImageFilename); + ImageActor actor = ImageActor::New(image); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(16); + + std::vector ids; + ids.push_back( 23 ); + application.GetGlAbstraction().SetNextTextureIds( ids ); + + Integration::ResourceRequest* request = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true ); + Integration::ResourcePointer resource(bitmap); + bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80); + if(request) + { + application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource); + } + application.Render(16); + application.SendNotification(); + application.SendNotification(); + application.Render(16); + + const std::vector& texIds = application.GetGlAbstraction().GetNextTextureIds(); + DALI_TEST_CHECK( texIds.size() == 0 ); + const std::vector& boundTexIds = application.GetGlAbstraction().GetBoundTextures(); + DALI_TEST_CHECK( boundTexIds[0] == 23 ); + + Stage::GetCurrent().Remove(actor); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + application.Render(16); // Should remove image renderer + + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-ImageActor.cpp b/automated-tests/src/dali/utc-Dali-ImageActor.cpp new file mode 100644 index 0000000..57bfda0 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-ImageActor.cpp @@ -0,0 +1,940 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 "dali-test-suite-utils/dali-test-suite-utils.h" + +using namespace Dali; + +static const char* TestImageFilename = "icon_wrt.png"; + +void image_actor_test_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void image_actor_test_cleanup(void) +{ + test_return_value = TET_PASS; +} + + +int UtcDaliImageActorConstructorVoid(void) +{ + TestApplication application; + tet_infoline("Testing Dali::ImageActor::ImageActor()"); + + ImageActor actor; + + DALI_TEST_CHECK(!actor); + END_TEST; +} + +int UtcDaliImageActorDestructor(void) +{ + TestApplication application; + + ImageActor* actor = new ImageActor(); + delete actor; + + DALI_TEST_CHECK( true ); + END_TEST; +} + +int UtcDaliImageActorNew01(void) +{ + TestApplication application; + tet_infoline("Positive test for Dali::ImageActor::New()"); + + Image image = Image::New(TestImageFilename); + ImageActor actor = ImageActor::New(image); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + + DALI_TEST_CHECK(application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc)); + + DALI_TEST_CHECK(actor); + END_TEST; +} + +int UtcDaliImageActorNew02(void) +{ + TestApplication application; + tet_infoline("Negative test for Dali::ImageActor::New()"); + + Image image = Image::New("hopefully-this-image-file-does-not-exist"); + ImageActor actor = ImageActor::New(image); + + DALI_TEST_CHECK(actor); + END_TEST; +} + +int UtcDaliImageActorDownCast(void) +{ + TestApplication application; + tet_infoline("Testing Dali::ImageActor::DownCast()"); + + Image image = Image::New("IncorrectImageName"); + ImageActor actor1 = ImageActor::New(image); + Actor anActor = Actor::New(); + anActor.Add(actor1); + + Actor child = anActor.GetChildAt(0); + ImageActor imageActor = DownCast< ImageActor >(child); + + DALI_TEST_CHECK(imageActor); + END_TEST; +} + +int UtcDaliImageActorDownCast2(void) +{ + TestApplication application; + tet_infoline("Testing Dali::ImageActor::DownCast()"); + + Actor actor1 = Actor::New(); + Actor anActor = Actor::New(); + anActor.Add(actor1); + + Actor child = anActor.GetChildAt(0); + ImageActor imageActor = ImageActor::DownCast(child); + DALI_TEST_CHECK(!imageActor); + + Actor unInitialzedActor; + imageActor = ImageActor::DownCast( unInitialzedActor ); + DALI_TEST_CHECK(!imageActor); + END_TEST; +} + +int UtcDaliImageActor9Patch(void) +{ + TestApplication application; + tet_infoline("Positive test for Dali::ImageActor:: 9 patch api"); + + Image image = Image::New(TestImageFilename); + ImageActor actor = ImageActor::New(image); + + actor.SetStyle(ImageActor::STYLE_NINE_PATCH); + Vector4 border(0.1,0.2,0.3,0.4); + actor.SetNinePatchBorder(border); + + DALI_TEST_EQUALS( 0.1f, actor.GetNinePatchBorder().x, TEST_LOCATION ); + DALI_TEST_EQUALS( 0.2f, actor.GetNinePatchBorder().y, TEST_LOCATION ); + DALI_TEST_EQUALS( 0.3f, actor.GetNinePatchBorder().z, TEST_LOCATION ); + DALI_TEST_EQUALS( 0.4f, actor.GetNinePatchBorder().w, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliImageActorPixelArea(void) +{ + TestApplication application; + tet_infoline("Positive test for Dali::ImageActor::UtcDaliImageActorPixelArea"); + + BitmapImage img = BitmapImage::New( 10, 10 ); + ImageActor actor = ImageActor::New( img ); + + DALI_TEST_CHECK( actor.IsPixelAreaSet() == false ); + + ImageActor::PixelArea area( 1, 2, 3, 4 ); + actor.SetPixelArea( area ); + + DALI_TEST_CHECK( actor.IsPixelAreaSet() == true ); + + DALI_TEST_EQUALS( 1, actor.GetPixelArea().x, TEST_LOCATION ); + DALI_TEST_EQUALS( 2, actor.GetPixelArea().y, TEST_LOCATION ); + DALI_TEST_EQUALS( 3, actor.GetPixelArea().width, TEST_LOCATION ); + DALI_TEST_EQUALS( 4, actor.GetPixelArea().height, TEST_LOCATION ); + + ImageActor actor2 = ImageActor::New( img, ImageActor::PixelArea( 5, 6, 7, 8 ) ); + DALI_TEST_CHECK( actor2.IsPixelAreaSet() == true ); + + DALI_TEST_EQUALS( 5, actor2.GetPixelArea().x, TEST_LOCATION ); + DALI_TEST_EQUALS( 6, actor2.GetPixelArea().y, TEST_LOCATION ); + DALI_TEST_EQUALS( 7, actor2.GetPixelArea().width, TEST_LOCATION ); + DALI_TEST_EQUALS( 8, actor2.GetPixelArea().height, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliImageActorGetCurrentImageSize01(void) +{ + TestApplication application; + tet_infoline("Positive test for Dali::ImageActor::GetCurrentImageSize"); + + Vector2 initialImageSize(100, 50); + BitmapImage image = BitmapImage::New( initialImageSize.width, initialImageSize.height ); + ImageActor actor = ImageActor::New( image ); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), initialImageSize, TEST_LOCATION ); + + Vector2 size(200.0f, 200.0f); + actor.SetSize(size); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), size, TEST_LOCATION ); + + size.x = 200.0f; + size.y = 200.0f; + actor.SetSize(size); + application.Render(8); + + // Test when a pixel area is set + ImageActor::PixelArea area(0, 0, 10, 10); + actor.SetPixelArea(area); + application.Render(9); + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), Vector2( area.width, area.height ), TEST_LOCATION ); + END_TEST; +} + + +int UtcDaliImageActorGetCurrentImageSize02(void) +{ + TestApplication application; + tet_infoline("Positive test for Dali::ImageActor::GetCurrentImageSize - Test that using an image resource sets the actor size with it's natural size immediately rather than on load"); + + Vector2 initialImageSize(100, 50); + + application.GetPlatform().SetClosestImageSize(initialImageSize); + + Image image = Image::New("image.jpg"); + ImageActor actor = ImageActor::New( image ); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); // Flush update messages + application.Render(); // Process resource request + application.SendNotification(); // Flush update messages + application.Render(); // Process resource request + + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), initialImageSize, TEST_LOCATION ); + + // Now complete the image load + Integration::ResourceRequest* req = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false ); + bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, initialImageSize.width,initialImageSize.height, initialImageSize.width,initialImageSize.height ); + + Integration::ResourcePointer resourcePtr(bitmap); // reference it + application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr); + application.Render(); // Process LoadComplete + application.SendNotification(); // Process event messages + application.GetPlatform().DiscardRequest(); // Ensure load request is discarded + application.GetPlatform().ClearReadyResources(); // + + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), initialImageSize, TEST_LOCATION ); + + Vector2 size(200.0f, 200.0f); + actor.SetSize(size); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), size, TEST_LOCATION ); + + actor.SetToNaturalSize(); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), initialImageSize, TEST_LOCATION ); + END_TEST; +} + + +int UtcDaliImageActorGetCurrentImageSize03(void) +{ + TestApplication application; + tet_infoline("Positive test for Dali::ImageActor::GetCurrentImageSize - Test that using an image resource with a requested size sets the actor size with it's nearest size immediately rather than on load"); + + Vector2 closestImageSize( 80, 45); + + application.GetPlatform().SetClosestImageSize(closestImageSize); + + ImageAttributes attrs; + attrs.SetSize(40, 30); + Image image = Image::New("image.jpg", attrs); + ImageActor actor = ImageActor::New( image ); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); // Flush update messages + application.Render(); // Process resource request + application.SendNotification(); // Flush update messages + application.Render(); // Process resource request + + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION ); + + // Now complete the image load + Integration::ResourceRequest* req = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false ); + bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, closestImageSize.width, closestImageSize.height, closestImageSize.width, closestImageSize.height ); + + Integration::ResourcePointer resourcePtr(bitmap); // reference it + application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr); + application.Render(); // Process LoadComplete + application.SendNotification(); // Process event messages + application.GetPlatform().DiscardRequest(); // Ensure load request is discarded + application.GetPlatform().ClearReadyResources(); // + + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION ); + + // Test that setting a size on the actor can be 'undone' with SetNaturalSize() + Vector2 size(200.0f, 200.0f); + actor.SetSize(size); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), size, TEST_LOCATION ); + + actor.SetToNaturalSize(); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION ); + END_TEST; +} + + +int UtcDaliImageActorGetCurrentImageSize04(void) +{ + TestApplication application; + tet_infoline("Positive test for Dali::ImageActor::GetCurrentImageSize - check a new image doesn't change a set actor size"); + + Vector2 closestImageSize( 80, 45); + application.GetPlatform().SetClosestImageSize(closestImageSize); + + ImageAttributes attrs; + attrs.SetSize(40, 30); // Request a really small size we won't get. + Image image = Image::New("image.jpg", attrs); + ImageActor actor = ImageActor::New( image ); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); // Flush update messages + application.Render(); // Process resource request + + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION ); + + // Now complete the image load + Integration::ResourceRequest* req = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false ); + bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, closestImageSize.width, closestImageSize.height, closestImageSize.width, closestImageSize.height ); + + Integration::ResourcePointer resourcePtr(bitmap); // reference it + application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr); + application.Render(); // Process LoadComplete + application.SendNotification(); // Process event messages + application.GetPlatform().DiscardRequest(); // Ensure load request is discarded + application.GetPlatform().ClearReadyResources(); // + + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION ); + + Vector2 size(200.0f, 200.0f); + actor.SetSize(size); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), size, TEST_LOCATION ); + + // Load a different image + + Vector2 image2ClosestSize = Vector2(240, 150); // The actual size image loader will return for the request below + application.GetPlatform().SetClosestImageSize(image2ClosestSize); + + attrs.SetSize(100, 100); + Image image2 = Image::New("image2.jpg", attrs); + actor.SetImage(image2); + + application.SendNotification(); // Flush update messages + application.Render(); // Process resource request + application.SendNotification(); // Flush update messages + application.Render(); // Process resource request + + // Ensure the actor size is kept + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), size, TEST_LOCATION ); + + // Now complete the image load + req = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap2 = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false ); + bitmap2->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, image2ClosestSize.width, image2ClosestSize.height, image2ClosestSize.width, image2ClosestSize.height ); + + Integration::ResourcePointer resourcePtr2(bitmap2); // reference it + application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr2); + application.Render(); // Process LoadComplete + application.SendNotification(); // Process event messages + application.GetPlatform().DiscardRequest(); // Ensure load request is discarded + application.GetPlatform().ClearReadyResources(); // + + // Ensure the actor size is kept + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), size, TEST_LOCATION ); + + actor.SetToNaturalSize(); + application.SendNotification(); + application.Render(); + // Ensure the actor size gets the new image's natural size + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), image2ClosestSize, TEST_LOCATION ); + END_TEST; +} + + +int UtcDaliImageActorGetCurrentImageSize05(void) +{ + TestApplication application; + tet_infoline("Positive test for Dali::ImageActor::GetCurrentImageSize - check a new image doens't change actor size until load complete"); + + Vector2 closestImageSize( 80, 45); + application.GetPlatform().SetClosestImageSize(closestImageSize); + + ImageAttributes attrs; + attrs.SetSize(40, 30); // Request a really small size we won't get. + Image image = Image::New("image.jpg", attrs); + ImageActor actor = ImageActor::New( image ); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); // Flush update messages + application.Render(); // Process resource request + + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION ); + + // Now complete the image load + Integration::ResourceRequest* req = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false ); + bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, closestImageSize.width, closestImageSize.height, closestImageSize.width, closestImageSize.height ); + + Integration::ResourcePointer resourcePtr(bitmap); // reference it + application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr); + application.Render(); // Process LoadComplete + application.SendNotification(); // Process event messages + application.GetPlatform().DiscardRequest(); // Ensure load request is discarded + application.GetPlatform().ClearReadyResources(); // + + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION ); + + // Load a different image + + Vector2 image2ClosestSize = Vector2(240, 150); + application.GetPlatform().SetClosestImageSize(image2ClosestSize); + + attrs.SetSize(100, 100); + Image image2 = Image::New("image2.jpg", attrs); + actor.SetImage(image2); + + application.SendNotification(); // Flush update messages + application.Render(); // Process resource request + application.SendNotification(); // Flush update messages + application.Render(); // Process resource request + + // Ensure the actor size is kept + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION ); + + // Now complete the image load + req = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap2 = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false ); + bitmap2->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, image2ClosestSize.width, image2ClosestSize.height, image2ClosestSize.width, image2ClosestSize.height ); + + Integration::ResourcePointer resourcePtr2(bitmap2); // reference it + application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr2); + application.Render(); // Process LoadComplete + application.SendNotification(); // Process event messages + application.GetPlatform().DiscardRequest(); // Ensure load request is discarded + application.GetPlatform().ClearReadyResources(); // + + application.SendNotification(); // Process event messages + application.Render(); // Process LoadComplete + + // Ensure the actor size gets the new image's natural size + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), image2ClosestSize, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliImageActorNaturalPixelAreaSize01(void) +{ + TestApplication application; + tet_infoline("Positive test for Dali::ImageActor::GetCurrentImageSize - check a new image doens't change actor size until load complete"); + +//If an image is loaded without setting size, then the actor gets the natural size of the image +//Setting the pixel area will change the actor size to match the pixel area +//Setting the actor size will not change pixel area, and will cause the partial image to stretch +//to the new size. +//Clearing the pixel area will not change actor size, and the actor will show the whole image. + + + Vector2 closestImageSize( 80, 45); + application.GetPlatform().SetClosestImageSize(closestImageSize); + + ImageAttributes attrs; + attrs.SetSize(40, 30); // Request a really small size we won't get. + Image image = Image::New("image.jpg", attrs); + ImageActor actor = ImageActor::New( image ); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); // Flush update messages + application.Render(); // Process resource request + + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), closestImageSize, TEST_LOCATION ); + + // Now complete the image load + Integration::ResourceRequest* req = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false ); + bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, closestImageSize.width, closestImageSize.height, closestImageSize.width, closestImageSize.height ); + + Integration::ResourcePointer resourcePtr(bitmap); // reference it + application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr); + application.Render(); // Process LoadComplete + application.SendNotification(); // Process event messages + application.GetPlatform().DiscardRequest(); // Ensure load request is discarded + application.GetPlatform().ClearReadyResources(); // + + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), closestImageSize, TEST_LOCATION ); + + // Set a pixel area on a naturally sized actor - expect the actor to take the + // pixel area as size + actor.SetPixelArea(ImageActor::PixelArea(0, 0, 30, 30)); + application.SendNotification(); // Process event messages + application.Render(); // Process LoadComplete + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), Vector2(30, 30), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(30, 30), TEST_LOCATION ); + + // Set a size. Expect the partial image to stretch to fill the new size + actor.SetSize(100, 100); + application.SendNotification(); // Process event messages + application.Render(); // Process LoadComplete + application.Render(); // Process LoadComplete + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), Vector2(30, 30), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(100, 100), TEST_LOCATION ); + + // Clear the pixel area. Expect the whole image to be shown, filling the set size. + actor.ClearPixelArea(); + application.SendNotification(); // Process event messages + application.Render(); // Process LoadComplete + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), Vector2(100, 100), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(100, 100), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliImageActorNaturalPixelAreaSize02(void) +{ + TestApplication application; + tet_infoline("Positive test for Dali::ImageActor::GetCurrentImageSize - check a new image doens't change actor size until load complete"); + +//If an image is loaded without setting size, then the actor gets the natural size of the image +//Setting the pixel area will change the actor size to match the pixel area +//Setting the actor size will not change pixel area, and will cause the partial image to stretch +//to the new size. +//Clearing the pixel area will not change actor size, and the actor will show the whole image. + + + Vector2 closestImageSize( 80, 45); + application.GetPlatform().SetClosestImageSize(closestImageSize); + + ImageAttributes attrs; + attrs.SetSize(40, 30); // Request a really small size we won't get. + Image image = Image::New("image.jpg", attrs); + ImageActor actor = ImageActor::New( image ); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); // Flush update messages + application.Render(); // Process resource request + + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), closestImageSize, TEST_LOCATION ); + + // Now complete the image load + Integration::ResourceRequest* req = application.GetPlatform().GetRequest(); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false ); + bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, closestImageSize.width, closestImageSize.height, closestImageSize.width, closestImageSize.height ); + + Integration::ResourcePointer resourcePtr(bitmap); // reference it + application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr); + application.Render(); // Process LoadComplete + application.SendNotification(); // Process event messages + application.GetPlatform().DiscardRequest(); // Ensure load request is discarded + application.GetPlatform().ClearReadyResources(); // + + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), closestImageSize, TEST_LOCATION ); + + // Set a pixel area on a naturally sized actor - expect the actor to take the + // pixel area as size + actor.SetPixelArea(ImageActor::PixelArea(0, 0, 30, 30)); + application.SendNotification(); // Process event messages + application.Render(); // Process LoadComplete + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), Vector2(30, 30), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(30, 30), TEST_LOCATION ); + + // Clear the pixel area. Expect the whole image to be shown, changing actor size + actor.ClearPixelArea(); + application.SendNotification(); // Process event messages + application.Render(); // Process LoadComplete + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), closestImageSize, TEST_LOCATION ); + + // Set a size. Expect the partial image to stretch to fill the new size + actor.SetSize(100, 100); + application.SendNotification(); // Process event messages + application.Render(); // Process LoadComplete + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), Vector2(100, 100), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(100, 100), TEST_LOCATION ); + + // Set a pixel area, don't expect size to change + actor.SetPixelArea(ImageActor::PixelArea(0, 0, 40, 40)); + application.SendNotification(); // Process event messages + application.Render(); // Process LoadComplete + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), Vector2(40, 40), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(100, 100), TEST_LOCATION ); + + // Use natural size - expect actor to change to pixel area + actor.SetToNaturalSize(); + application.SendNotification(); // Process event messages + application.Render(); // Process LoadComplete + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), Vector2(40, 40), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(40, 40), TEST_LOCATION ); + + // Clearing pixel area should change actor size to image size + actor.ClearPixelArea(); + application.SendNotification(); // Process event messages + application.Render(); // Process LoadComplete + DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), closestImageSize, TEST_LOCATION ); + END_TEST; +} + + + +int UtcDaliImageActorDefaultProperties(void) +{ + TestApplication application; + tet_infoline("Testing Dali::ImageActor DefaultProperties"); + + BitmapImage img = BitmapImage::New( 10, 10 ); + ImageActor actor = ImageActor::New( img ); + + std::vector indices; + indices.push_back(ImageActor::PIXEL_AREA ); + indices.push_back(ImageActor::FADE_IN ); + indices.push_back(ImageActor::FADE_IN_DURATION); + indices.push_back(ImageActor::STYLE ); + indices.push_back(ImageActor::BORDER ); + indices.push_back(ImageActor::IMAGE ); + + DALI_TEST_CHECK(actor.GetPropertyCount() == ( Actor::New().GetPropertyCount() + indices.size() ) ); + + for(std::vector::iterator iter = indices.begin(); iter != indices.end(); ++iter) + { + DALI_TEST_CHECK( *iter == actor.GetPropertyIndex(actor.GetPropertyName(*iter)) ); + DALI_TEST_CHECK( actor.IsPropertyWritable(*iter) ); + DALI_TEST_CHECK( !actor.IsPropertyAnimatable(*iter) ); + DALI_TEST_CHECK( actor.GetPropertyType(*iter) == actor.GetPropertyType(*iter) ); // just checking call succeeds + } + + // set/get one of them + actor.SetPixelArea(ImageActor::PixelArea( 0, 0, 0, 0 )); + + ImageActor::PixelArea area( 1, 2, 3, 4 ); + actor.SetProperty(ImageActor::PIXEL_AREA, Property::Value(Rect(area))); + + DALI_TEST_CHECK(Property::RECTANGLE == actor.GetPropertyType(ImageActor::PIXEL_AREA)); + + Property::Value v = actor.GetProperty(ImageActor::PIXEL_AREA); + + DALI_TEST_CHECK(v.Get >() == area); + + END_TEST; +} + +int UtcDaliImageActorUseImageAlpha01(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::RenderableActor::SetUseImageAlpha()"); + + BitmapImage image = BitmapImage::New( 100, 50 ); + ImageActor actor = ImageActor::New( image ); + actor.SetBlendMode( BlendingMode::ON ); + actor.SetSize(100, 50); + application.GetGlAbstraction().EnableCullFaceCallTrace(true); // For Enable(GL_BLEND) + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(); + + const TraceCallStack& callTrace = application.GetGlAbstraction().GetCullFaceTrace(); + DALI_TEST_EQUALS( BlendEnabled( callTrace), true, TEST_LOCATION ); + DALI_TEST_EQUALS( BlendDisabled( callTrace ), false, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliImageActorUseImageAlpha02(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::RenderableActor::SetUseImageAlpha()"); + + BitmapImage image = BitmapImage::New( 100, 50 ); + ImageActor actor = ImageActor::New( image ); + actor.SetBlendMode( BlendingMode::OFF ); + actor.SetSize(100, 50); + application.GetGlAbstraction().EnableCullFaceCallTrace(true); // For Enable(GL_BLEND) + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(); + + const TraceCallStack& callTrace = application.GetGlAbstraction().GetCullFaceTrace(); + DALI_TEST_EQUALS( BlendDisabled( callTrace ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( BlendEnabled( callTrace), false, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliImageActorUseImageAlpha03(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::RenderableActor::SetUseImageAlpha()"); + + BitmapImage image = BitmapImage::New( 100, 50 ); + ImageActor actor = ImageActor::New( image ); + actor.SetBlendMode( BlendingMode::AUTO ); + actor.SetColor(Vector4(1.0, 1.0, 1.0, 0.5)); + actor.SetSize(100, 50); + application.GetGlAbstraction().EnableCullFaceCallTrace(true); // For Enable(GL_BLEND) + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(); + + const TraceCallStack& callTrace = application.GetGlAbstraction().GetCullFaceTrace(); + DALI_TEST_EQUALS( BlendDisabled( callTrace ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( BlendEnabled( callTrace), true, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliImageActorUseImageAlpha04(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::RenderableActor::SetUseImageAlpha()"); + + FrameBufferImage image = FrameBufferImage::New( 100, 50, Pixel::RGBA8888 ); + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + RenderTask task = taskList.GetTask( 0u ); + task.SetTargetFrameBuffer( image ); // To ensure frame buffer is connected + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + application.SendNotification(); + application.Render(0); + + ImageActor actor = ImageActor::New( image ); + application.SendNotification(); + application.Render(0); + + actor.SetBlendMode( BlendingMode::ON ); + actor.SetColor(Vector4(1.0, 1.0, 1.0, 1.0)); + actor.SetSize(100, 50); + application.GetGlAbstraction().EnableCullFaceCallTrace(true); // For Enable(GL_BLEND) + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(); + + const TraceCallStack& callTrace = application.GetGlAbstraction().GetCullFaceTrace(); + DALI_TEST_EQUALS( BlendDisabled( callTrace ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( BlendEnabled( callTrace), true, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliImageActorUseImageAlpha05(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::RenderableActor::SetUseImageAlpha()"); + + BitmapImage image = BitmapImage::New( 100, 50, Pixel::RGB888 ); + ImageActor actor = ImageActor::New( image ); + actor.SetBlendMode( BlendingMode::AUTO ); + actor.SetColor(Vector4(1.0, 1.0, 1.0, 1.0)); + actor.SetSize(100, 50); + application.GetGlAbstraction().EnableCullFaceCallTrace(true); // For Enable(GL_BLEND) + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(); + + const TraceCallStack& callTrace = application.GetGlAbstraction().GetCullFaceTrace(); + DALI_TEST_EQUALS( BlendDisabled( callTrace ), false, TEST_LOCATION ); + DALI_TEST_EQUALS( BlendEnabled( callTrace), false, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliImageActorClearPixelArea(void) +{ + TestApplication application; + + BitmapImage img = BitmapImage::New( 10, 10 ); + ImageActor actor = ImageActor::New( img ); + + DALI_TEST_CHECK( actor.IsPixelAreaSet() == false ); + + ImageActor::PixelArea area( 1, 2, 3, 4 ); + actor.SetPixelArea( area ); + + DALI_TEST_CHECK( actor.IsPixelAreaSet() == true ); + + actor.ClearPixelArea(); + + DALI_TEST_CHECK( actor.IsPixelAreaSet() == false ); + END_TEST; +} + +int UtcDaliImageGetStyle(void) +{ + TestApplication application; + + Image image = Image::New(TestImageFilename); + ImageActor actor = ImageActor::New(image); + + actor.SetStyle(ImageActor::STYLE_NINE_PATCH); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( ImageActor::STYLE_NINE_PATCH, actor.GetStyle(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliImageSetNinePatchBorder(void) +{ + TestApplication application; + + Image image = Image::New(TestImageFilename); + ImageActor actor = ImageActor::New(image); + + actor.SetStyle(ImageActor::STYLE_NINE_PATCH); + actor.SetNinePatchBorder(Vector4( 1.0f, 2.0f, 3.0f, 4.0f)); + + DALI_TEST_EQUALS( 1.0f, actor.GetNinePatchBorder().x, TEST_LOCATION ); + DALI_TEST_EQUALS( 2.0f, actor.GetNinePatchBorder().y, TEST_LOCATION ); + DALI_TEST_EQUALS( 3.0f, actor.GetNinePatchBorder().z, TEST_LOCATION ); + DALI_TEST_EQUALS( 4.0f, actor.GetNinePatchBorder().w, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliImageSetFadeIn(void) +{ + TestApplication application; + + Image image = Image::New(TestImageFilename); + ImageActor actor = ImageActor::New(image); + + actor.SetFadeIn(true); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( true, actor.GetFadeIn(), TEST_LOCATION ); + + actor.SetFadeIn(false); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( false, actor.GetFadeIn(), TEST_LOCATION ); + END_TEST; +} + + +int UtcDaliImageSetFadeInDuration(void) +{ + TestApplication application; + + Image image = Image::New(TestImageFilename); + ImageActor actor = ImageActor::New(image); + + actor.SetFadeInDuration( 1.0f ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( 1.0f, actor.GetFadeInDuration(), TEST_LOCATION ); + + actor.SetFadeInDuration( 3.0f ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( 3.0f, actor.GetFadeInDuration(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliImageActorNewNull(void) +{ + TestApplication application; + + ImageActor actor = ImageActor::New(Image()); + + DALI_TEST_CHECK(actor); + END_TEST; +} + +int UtcDaliImageActorNewNullWithArea(void) +{ + TestApplication application; + + ImageActor::PixelArea area( 1, 2, 3, 4 ); + + ImageActor actor = ImageActor::New(Image(), area); + + DALI_TEST_CHECK(actor); + END_TEST; +} + +int UtcDaliImageActorSetImage(void) +{ + TestApplication application; + + ImageActor actor = ImageActor::New(Image()); + + DALI_TEST_CHECK(actor); + + actor.SetImage( Image() ); + + DALI_TEST_CHECK(!actor.GetImage()); + END_TEST; +} + +int UtcDaliImageActorPropertyIndices(void) +{ + TestApplication application; + Actor basicActor = Actor::New(); + ImageActor imageActor = ImageActor::New(); + + Property::IndexContainer indices; + imageActor.GetPropertyIndices( indices ); + DALI_TEST_CHECK( indices.size() > basicActor.GetPropertyCount() ); + DALI_TEST_EQUALS( indices.size(), imageActor.GetPropertyCount(), TEST_LOCATION ); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-ImageAttributes.cpp b/automated-tests/src/dali/utc-Dali-ImageAttributes.cpp new file mode 100644 index 0000000..3a461c9 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-ImageAttributes.cpp @@ -0,0 +1,112 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 std::max; +using namespace Dali; + +void utc_dali_image_attributes_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_image_attributes_cleanup(void) +{ + test_return_value = TET_PASS; +} + +int UtcDaliImageAttributesConstructor(void) +{ + TestApplication application; + + tet_infoline("UtcDaliImageAttributesConstructor"); + + // invoke default handle constructor + ImageAttributes imageAttributes; + + DALI_TEST_CHECK( imageAttributes.GetWidth() == 0); + END_TEST; +} + +int UtcDaliImageAttributesLessThan(void) +{ + TestApplication application; + + tet_infoline("UtcDaliImageAttributesLessThan"); + + // invoke default handle constructor + ImageAttributes imageAttributes; + + ImageAttributes imageAttributesWidth; + imageAttributesWidth.SetSize(2,1); + DALI_TEST_CHECK(imageAttributes < imageAttributesWidth); + + ImageAttributes imageAttributesHeight; + imageAttributesHeight.SetSize(1,2); + DALI_TEST_CHECK(imageAttributes < imageAttributesHeight); + + imageAttributesWidth.SetSize(Size(2,1)); + DALI_TEST_CHECK(imageAttributes < imageAttributesWidth); + + imageAttributesHeight.SetSize(Size(1,2)); + DALI_TEST_CHECK(imageAttributes < imageAttributesHeight); + + ImageAttributes imageAttributesCrop; + imageAttributesCrop.SetCrop(Rect(0.0f, 0.0f, 8.0f, 8.0f)); + DALI_TEST_CHECK(imageAttributes < imageAttributesCrop); + + ImageAttributes imageAttributesFormat; + imageAttributesFormat.SetPixelFormat(Pixel::BGRA8888); + DALI_TEST_CHECK(imageAttributes < imageAttributesFormat); + + ImageAttributes imageAttributesScaling; + imageAttributesScaling.SetScalingMode(ImageAttributes::FitHeight); + DALI_TEST_CHECK(imageAttributes < imageAttributesScaling); + END_TEST; +} + +int UtcDaliImageAttributesEquality(void) +{ + TestApplication application; + + tet_infoline("UtcDaliImageAttributesEquality"); + + // invoke default handle constructor + ImageAttributes imageAttributes01; + ImageAttributes imageAttributes02; + + DALI_TEST_CHECK(imageAttributes02 == imageAttributes01); + END_TEST; +} + +int UtcDaliImageAttributesInEquality(void) +{ + TestApplication application; + + tet_infoline("UtcDaliImageAttributesInEquality"); + + // invoke default handle constructor + ImageAttributes imageAttributes01; + ImageAttributes imageAttributes02; + + DALI_TEST_CHECK((imageAttributes02 != imageAttributes01) == false); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-KeyEvent.cpp b/automated-tests/src/dali/utc-Dali-KeyEvent.cpp new file mode 100644 index 0000000..10b7bce --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-KeyEvent.cpp @@ -0,0 +1,270 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; + +void utc_dali_key_event_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_key_event_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ + +// Key Event Test references +const static int SHIFT_MODIFIER = 0x1; +const static int CTRL_MODIFIER = 0x2; +const static int ALT_MODIFIER = 0x4; +const static int SHIFT_AND_CTRL_MODIFIER = SHIFT_MODIFIER | CTRL_MODIFIER; +const static int SHIFT_AND_ALT_MODIFIER = SHIFT_MODIFIER | ALT_MODIFIER; +const static int CTRL_AND_ALT_MODIFIER = CTRL_MODIFIER | ALT_MODIFIER; + +const static char* TEST_STRING_1 = "alpha"; + + +// Stores data that is populated in the callback and will be read by the TET cases +struct SignalData +{ + SignalData() + : functorCalled(false) + {} + + void Reset() + { + functorCalled = false; + + receivedKeyEvent.keyModifier = 0; + receivedKeyEvent.keyPressedName.clear(); + receivedKeyEvent.keyPressed.clear(); + + keyedActor = NULL; + } + + bool functorCalled; + KeyEvent receivedKeyEvent; + Actor keyedActor; +}; + +// Functor that sets the data when called +struct KeyEventReceivedFunctor +{ + KeyEventReceivedFunctor( SignalData& data ) : signalData( data ) { } + + bool operator()( Actor actor, const KeyEvent& keyEvent ) + { + signalData.functorCalled = true; + signalData.receivedKeyEvent = keyEvent; + signalData.keyedActor = actor; + + return true; + } + + SignalData& signalData; +}; + +} // anon namespace + +int UtcDaliKeyEventConstructor(void) +{ + TestApplication application; // Reset all test adapter return codes + + KeyEvent event(TEST_STRING_1,"i", 99, SHIFT_MODIFIER, 0, KeyEvent::Down); // set name to test, key string to i and modifier to shift + + DALI_TEST_EQUALS(TEST_STRING_1, event.keyPressedName, TEST_LOCATION); // check key name + DALI_TEST_EQUALS("i", event.keyPressed, TEST_LOCATION); // check key string + DALI_TEST_EQUALS(99, event.keyCode, TEST_LOCATION); // check keyCode + DALI_TEST_EQUALS(SHIFT_MODIFIER, event.keyModifier, TEST_LOCATION); // check modifier + DALI_TEST_EQUALS(KeyEvent::Down, event.state, TEST_LOCATION); // check state + END_TEST; +} + +// Positive test case for a method +int UtcDaliKeyEventIsShiftModifier(void) +{ + TestApplication application; // Reset all test adapter return codes + + KeyEvent event; + DALI_TEST_EQUALS(0, event.keyModifier, TEST_LOCATION); + + event.keyModifier = SHIFT_MODIFIER; // Set to Shift Modifier + + DALI_TEST_EQUALS(SHIFT_MODIFIER, event.keyModifier, TEST_LOCATION); // check able to set + + DALI_TEST_EQUALS(true, event.IsShiftModifier(), TEST_LOCATION); // check IsShiftModifier + + END_TEST; +} + +// Positive test case for a method +int UtcDaliKeyEventIsCtrlModifier(void) +{ + TestApplication application; // Reset all test adapter return codes + + KeyEvent event; + DALI_TEST_EQUALS(0, event.keyModifier, TEST_LOCATION); + + event.keyModifier = CTRL_MODIFIER; // Set to Ctrl Modifier + + DALI_TEST_EQUALS(CTRL_MODIFIER, event.keyModifier, TEST_LOCATION); // check able to set + + DALI_TEST_EQUALS(true, event.IsCtrlModifier(), TEST_LOCATION); // check IsCtrlModifier + END_TEST; +} + +// Positive test case for a method +int UtcDaliKeyEventIsAltModifier(void) +{ + TestApplication application; // Reset all test adapter return codes + + KeyEvent event; + DALI_TEST_EQUALS(0, event.keyModifier, TEST_LOCATION); + + event.keyModifier = ALT_MODIFIER; // Set to Alt Modifier + + DALI_TEST_EQUALS(ALT_MODIFIER, event.keyModifier, TEST_LOCATION); // check able to set + + DALI_TEST_EQUALS(true, event.IsAltModifier(), TEST_LOCATION); // IsAltModifier + END_TEST; +} + +// Positive fail test case for a method +int UtcDaliKeyEventIsNotShiftModifier(void) +{ + TestApplication application; // Reset all test adapter return codes + + KeyEvent event("i","i", 0, CTRL_MODIFIER, 0, KeyEvent::Down); + + DALI_TEST_EQUALS(CTRL_MODIFIER, event.keyModifier, TEST_LOCATION); // check different modifier used + + DALI_TEST_EQUALS(false, event.IsShiftModifier(), TEST_LOCATION); + END_TEST; +} + +// Positive fail test case for a method +int UtcDaliKeyEventIsNotCtrlModifier(void) +{ + TestApplication application; // Reset all test adapter return codes + + KeyEvent event("i","i", 0, ALT_MODIFIER, 0, KeyEvent::Up); + + DALI_TEST_EQUALS(ALT_MODIFIER, event.keyModifier, TEST_LOCATION); // check different modifier used + + DALI_TEST_EQUALS(false, event.IsCtrlModifier(), TEST_LOCATION); + END_TEST; +} + +// Positive fail test case for a method +int UtcDaliKeyEventIsNotAltModifier(void) +{ + TestApplication application; // Reset all test adapter return codes + + KeyEvent event("i","i", 0, SHIFT_MODIFIER, 0, KeyEvent::Up); + + DALI_TEST_EQUALS(SHIFT_MODIFIER, event.keyModifier, TEST_LOCATION); // check different modifier used + + DALI_TEST_EQUALS(false, event.IsAltModifier(), TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliKeyEventANDModifer(void) +{ + TestApplication application; // Reset all test adapter return codes + + KeyEvent event("i","i", 0, SHIFT_AND_CTRL_MODIFIER, 0, KeyEvent::Down); + DALI_TEST_EQUALS(true, event.IsCtrlModifier() & event.IsShiftModifier(), TEST_LOCATION); + + event.keyModifier = SHIFT_MODIFIER; + + DALI_TEST_EQUALS(false, event.IsCtrlModifier() & event.IsShiftModifier(), TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliKeyEventORModifer(void) +{ + TestApplication application; // Reset all test adapter return codes + + KeyEvent event("i","i", 0, SHIFT_AND_CTRL_MODIFIER, 0, KeyEvent::Down); + DALI_TEST_EQUALS(true, event.IsCtrlModifier() | event.IsAltModifier(), TEST_LOCATION); + + event.keyModifier = SHIFT_MODIFIER; + + DALI_TEST_EQUALS(false, event.IsCtrlModifier() & event.IsAltModifier(), TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliKeyEventState(void) +{ + TestApplication application; // Reset all test adapter return codes + + KeyEvent event("i","i", 0, SHIFT_AND_CTRL_MODIFIER, 0, KeyEvent::Down); + DALI_TEST_EQUALS(true, event.IsCtrlModifier() | event.IsAltModifier(), TEST_LOCATION); + + event.keyModifier = SHIFT_MODIFIER; + + DALI_TEST_EQUALS(false, event.IsCtrlModifier() & event.IsAltModifier(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliIntegrationKeyEvent(void) +{ + TestApplication application; + + { + Integration::KeyEvent keyEvent; + DALI_TEST_EQUALS( keyEvent.type, Integration::Event::Key, TEST_LOCATION ); + DALI_TEST_CHECK( keyEvent.keyName == std::string() ); + DALI_TEST_CHECK( keyEvent.keyString == std::string() ); + DALI_TEST_EQUALS( keyEvent.keyCode, -1, TEST_LOCATION ); + DALI_TEST_EQUALS( keyEvent.keyModifier, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( keyEvent.time, 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( keyEvent.state, Integration::KeyEvent::Down, TEST_LOCATION); + } + + { + const std::string keyName("keyName"); + const std::string keyString("keyString"); + const int keyCode(333); + const int keyModifier(312); + const unsigned long timeStamp(132); + const Integration::KeyEvent::State keyState(Integration::KeyEvent::Up); + + Integration::KeyEvent keyEvent(keyName, keyString, keyCode, keyModifier, timeStamp, keyState); + DALI_TEST_EQUALS( keyEvent.type, Integration::Event::Key, TEST_LOCATION ); + DALI_TEST_CHECK( keyEvent.keyName == keyName ); + DALI_TEST_CHECK( keyEvent.keyString == keyString ); + DALI_TEST_EQUALS( keyEvent.keyCode, keyCode, TEST_LOCATION ); + DALI_TEST_EQUALS( keyEvent.keyModifier, keyModifier, TEST_LOCATION ); + DALI_TEST_EQUALS( keyEvent.time, timeStamp, TEST_LOCATION ); + DALI_TEST_EQUALS( keyEvent.state, keyState, TEST_LOCATION); + } + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Layer.cpp b/automated-tests/src/dali/utc-Dali-Layer.cpp new file mode 100644 index 0000000..0573eda --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-Layer.cpp @@ -0,0 +1,513 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +using namespace Dali; + +void layer_test_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void layer_test_cleanup(void) +{ + test_return_value = TET_PASS; +} + + +int UtcDaliLayerNew(void) +{ + TestApplication application; + Layer layer = Layer::New(); + + DALI_TEST_CHECK(layer); + END_TEST; +} + +int UtcDaliLayerDownCast(void) +{ + TestApplication application; + tet_infoline("Testing Dali::Layer::DownCast()"); + + Layer actor1 = Layer::New(); + Actor anActor = Actor::New(); + anActor.Add(actor1); + + Actor child = anActor.GetChildAt(0); + Layer layer = DownCast< Layer >(child); + + DALI_TEST_CHECK(layer); + END_TEST; +} + +int UtcDaliLayerDownCast2(void) +{ + TestApplication application; + tet_infoline("Testing Dali::Layer::DownCast()"); + + Actor actor1 = Actor::New(); + Actor anActor = Actor::New(); + anActor.Add(actor1); + + Actor child = anActor.GetChildAt(0); + Layer layer = DownCast< Layer >(child); + DALI_TEST_CHECK(!layer); + + Actor unInitialzedActor; + layer = Layer::DownCast( unInitialzedActor ); + DALI_TEST_CHECK(!layer); + END_TEST; +} + + +int UtcDaliLayerGetDepth(void) +{ + tet_infoline("Testing Dali::Layer::GetDepth()"); + TestApplication application; + Layer layer1 = Layer::New(); + Layer layer2 = Layer::New(); + + // layers are not on stage + DALI_TEST_EQUALS(layer1.GetDepth(), 0u, TEST_LOCATION); + DALI_TEST_EQUALS(layer2.GetDepth(), 0u, TEST_LOCATION); + + // root depth is 0 + Layer root = Stage::GetCurrent().GetLayer( 0 ); + DALI_TEST_EQUALS(root.GetDepth(), 0u, TEST_LOCATION); + + Stage::GetCurrent().Add(layer1); + Stage::GetCurrent().Add(layer2); + + DALI_TEST_EQUALS( root.GetDepth(), 0u, TEST_LOCATION); + DALI_TEST_EQUALS(layer1.GetDepth(), 1u, TEST_LOCATION); + DALI_TEST_EQUALS(layer2.GetDepth(), 2u, TEST_LOCATION); + END_TEST; +} + +int UtcDaliLayerRaise(void) +{ + tet_infoline("Testing Dali::Layer::Raise()"); + TestApplication application; + Layer layer1 = Layer::New(); + Layer layer2 = Layer::New(); + + Stage::GetCurrent().Add(layer1); + Stage::GetCurrent().Add(layer2); + DALI_TEST_EQUALS(layer1.GetDepth(), 1u, TEST_LOCATION); + + layer1.Raise(); + DALI_TEST_EQUALS(layer1.GetDepth(), 2u, TEST_LOCATION); + + // get root + Layer root = Stage::GetCurrent().GetLayer( 0 ); + DALI_TEST_EQUALS( root.GetDepth(), 0u, TEST_LOCATION); + root.Raise(); + DALI_TEST_EQUALS( root.GetDepth(), 1u, TEST_LOCATION); + DALI_TEST_EQUALS(layer1.GetDepth(), 2u, TEST_LOCATION); + DALI_TEST_EQUALS(layer2.GetDepth(), 0u, TEST_LOCATION); + END_TEST; +} + +int UtcDaliLayerLower(void) +{ + tet_infoline("Testing Dali::Layer::Lower()"); + TestApplication application; + Layer layer1 = Layer::New(); + Layer layer2 = Layer::New(); + + Stage::GetCurrent().Add(layer1); + Stage::GetCurrent().Add(layer2); + DALI_TEST_EQUALS(layer2.GetDepth(), 2u, TEST_LOCATION); + + layer2.Lower(); + DALI_TEST_EQUALS(layer2.GetDepth(), 1u, TEST_LOCATION); + + // get root + Layer root = Stage::GetCurrent().GetLayer( 0 ); + root.Lower(); + DALI_TEST_EQUALS( root.GetDepth(), 0u, TEST_LOCATION); + layer2.Lower(); + DALI_TEST_EQUALS( root.GetDepth(), 1u, TEST_LOCATION); + DALI_TEST_EQUALS(layer2.GetDepth(), 0u, TEST_LOCATION); + END_TEST; +} + +int UtcDaliLayerRaiseToTop(void) +{ + tet_infoline("Testing Dali::Layer::RaiseToTop()"); + TestApplication application; + Layer layer1 = Layer::New(); + Layer layer2 = Layer::New(); + Layer layer3 = Layer::New(); + + Stage::GetCurrent().Add(layer1); + Stage::GetCurrent().Add(layer2); + Stage::GetCurrent().Add(layer3); + Layer root = Stage::GetCurrent().GetLayer( 0 ); + + DALI_TEST_EQUALS( root.GetDepth(), 0u, TEST_LOCATION); + DALI_TEST_EQUALS(layer1.GetDepth(), 1u, TEST_LOCATION); + DALI_TEST_EQUALS(layer2.GetDepth(), 2u, TEST_LOCATION); + DALI_TEST_EQUALS(layer3.GetDepth(), 3u, TEST_LOCATION); + + layer1.RaiseToTop(); + DALI_TEST_EQUALS(layer1.GetDepth(), 3u, TEST_LOCATION); + + root.RaiseToTop(); + DALI_TEST_EQUALS( root.GetDepth(), 3u, TEST_LOCATION); + END_TEST; +} + +int UtcDaliLayerLowerToBottom(void) +{ + tet_infoline("Testing Dali::Layer::LowerToBottom()"); + TestApplication application; + Layer layer1 = Layer::New(); + Layer layer2 = Layer::New(); + Layer layer3 = Layer::New(); + + Stage::GetCurrent().Add(layer1); + Stage::GetCurrent().Add(layer2); + Stage::GetCurrent().Add(layer3); + + DALI_TEST_EQUALS(layer1.GetDepth(), 1u, TEST_LOCATION); + DALI_TEST_EQUALS(layer2.GetDepth(), 2u, TEST_LOCATION); + DALI_TEST_EQUALS(layer3.GetDepth(), 3u, TEST_LOCATION); + + layer3.LowerToBottom(); + DALI_TEST_EQUALS(layer3.GetDepth(), 0u, TEST_LOCATION); + END_TEST; +} + +int UtcDaliLayerSetClipping(void) +{ + tet_infoline("Testing Dali::Layer::SetClipping()"); + TestApplication application; + + Layer layer = Layer::New(); + DALI_TEST_CHECK(!layer.IsClipping()); + + layer.SetClipping(true); + DALI_TEST_CHECK(layer.IsClipping()); + END_TEST; +} + +int UtcDaliLayerIsClipping(void) +{ + tet_infoline("Testing Dali::Layer::IsClipping()"); + TestApplication application; + + Layer layer = Layer::New(); + DALI_TEST_CHECK(!layer.IsClipping()); + END_TEST; +} + +int UtcDaliLayerSetClippingBox(void) +{ + tet_infoline("Testing Dali::Layer::SetClippingBox()"); + TestApplication application; + + ClippingBox testBox(5,6, 77,83); + + Layer layer = Layer::New(); + DALI_TEST_CHECK(layer.GetClippingBox() != testBox); + + layer.SetClippingBox(5,6, 77,83); + DALI_TEST_CHECK(layer.GetClippingBox() == testBox); + END_TEST; +} + +int UtcDaliLayerGetClippingBox(void) +{ + tet_infoline("Testing Dali::Layer::GetClippingBox()"); + TestApplication application; + + Layer layer = Layer::New(); + DALI_TEST_CHECK(layer.GetClippingBox() == ClippingBox(0,0,0,0)); + END_TEST; +} + +static int gTestSortFunctionCalled; + +static float TestSortFunction(const Vector3& /*position*/, float /*sortModifier*/) +{ + ++gTestSortFunctionCalled; + return 0.0f; +} + +int UtcDaliLayerSetSortFunction(void) +{ + tet_infoline("Testing Dali::Layer::SetSortFunction()"); + TestApplication application; + BitmapImage img = BitmapImage::New( 1,1 ); + // create two transparent actors so there is something to sort + ImageActor actor = ImageActor::New( img ); + ImageActor actor2 = ImageActor::New( img ); + actor.SetSize(1,1); + actor.SetColor( Vector4(1, 1, 1, 0.5f ) ); // 50% transparent + actor2.SetSize(1,1); + actor2.SetColor( Vector4(1, 1, 1, 0.5f ) ); // 50% transparent + + // add to stage + Stage::GetCurrent().Add( actor ); + Stage::GetCurrent().Add( actor2 ); + + Layer root = Stage::GetCurrent().GetLayer( 0 ); + gTestSortFunctionCalled = 0; + root.SetSortFunction(TestSortFunction); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( gTestSortFunctionCalled > 0 ); + END_TEST; +} + + +int UtcDaliLayerRaiseAbove(void) +{ + tet_infoline("Testing Dali::Layer::RaiseAbove()"); + TestApplication application; + Layer layer = Layer::New(); + // try to raise above root layer + Layer root = Stage::GetCurrent().GetLayer( 0 ); + layer.RaiseAbove( root ); + // layer depth is zero as its not on stage + DALI_TEST_EQUALS( layer.GetDepth(), 0u, TEST_LOCATION ); + // add to stage + Stage::GetCurrent().Add( layer ); + layer.RaiseAbove( root ); + DALI_TEST_EQUALS( layer.GetDepth(), 1u, TEST_LOCATION ); + root.RaiseAbove( layer ); + DALI_TEST_EQUALS( layer.GetDepth(), 0u, TEST_LOCATION ); + layer.RaiseAbove( layer ); + DALI_TEST_EQUALS( layer.GetDepth(), 0u, TEST_LOCATION ); + + // make another layer on the stage + Layer layer2 = Layer::New(); + Stage::GetCurrent().Add( layer2 ); + layer.RaiseAbove( layer2 ); + DALI_TEST_GREATER( layer.GetDepth(), layer2.GetDepth(), TEST_LOCATION ); + layer2.RaiseAbove( layer ); + DALI_TEST_GREATER( layer2.GetDepth(), layer.GetDepth(), TEST_LOCATION ); + root.RaiseAbove( layer2 ); + DALI_TEST_GREATER( root.GetDepth(), layer2.GetDepth(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliLayerRaiseBelow(void) +{ + tet_infoline("Testing Dali::Layer::RaiseBelow()"); + TestApplication application; + Layer layer = Layer::New(); + // try to lower below root layer + Layer root = Stage::GetCurrent().GetLayer( 0 ); + layer.LowerBelow( root ); + // layer depth is zero as its not on stage + DALI_TEST_EQUALS( layer.GetDepth(), 0u, TEST_LOCATION ); + // add to stage + Stage::GetCurrent().Add( layer ); + DALI_TEST_EQUALS( layer.GetDepth(), 1u, TEST_LOCATION ); + layer.LowerBelow( root ); + DALI_TEST_EQUALS( layer.GetDepth(), 0u, TEST_LOCATION ); + root.LowerBelow( layer ); + DALI_TEST_EQUALS( layer.GetDepth(), 1u, TEST_LOCATION ); + layer.LowerBelow( layer ); + DALI_TEST_EQUALS( layer.GetDepth(), 1u, TEST_LOCATION ); + + // make another layer on the stage + Layer layer2 = Layer::New(); + Stage::GetCurrent().Add( layer2 ); + layer.LowerBelow( layer2 ); + DALI_TEST_GREATER( layer2.GetDepth(), layer.GetDepth(), TEST_LOCATION ); + layer2.LowerBelow( layer ); + DALI_TEST_GREATER( layer.GetDepth(), layer2.GetDepth(), TEST_LOCATION ); + root.LowerBelow( layer2 ); + DALI_TEST_GREATER( layer2.GetDepth(), root.GetDepth(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliLayerMoveAbove(void) +{ + tet_infoline("Testing Dali::Layer::MoveAbove()"); + TestApplication application; + Layer layer = Layer::New(); + // try to raise above root layer + Layer root = Stage::GetCurrent().GetLayer( 0 ); + layer.MoveAbove( root ); + // layer depth is zero as its not on stage + DALI_TEST_EQUALS( layer.GetDepth(), 0u, TEST_LOCATION ); + root.MoveAbove( layer ); + // root depth is zero as layer is not on stage + DALI_TEST_EQUALS( layer.GetDepth(), 0u, TEST_LOCATION ); + // add to stage + Stage::GetCurrent().Add( layer ); + layer.MoveAbove( root ); + DALI_TEST_EQUALS( layer.GetDepth(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( root.GetDepth(), 0u, TEST_LOCATION ); + root.MoveAbove( layer ); + DALI_TEST_EQUALS( layer.GetDepth(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( root.GetDepth(), 1u, TEST_LOCATION ); + + // make another layer on the stage + Layer layer2 = Layer::New(); + Stage::GetCurrent().Add( layer2 ); + layer.MoveAbove( layer2 ); + DALI_TEST_EQUALS( layer.GetDepth(), layer2.GetDepth() + 1u, TEST_LOCATION ); + layer2.MoveAbove( root ); + DALI_TEST_EQUALS( layer2.GetDepth(), root.GetDepth() + 1u, TEST_LOCATION ); + root.MoveAbove( layer ); + DALI_TEST_EQUALS( root.GetDepth(), layer.GetDepth() + 1u, TEST_LOCATION ); + + Layer layer3 = Layer::New(); + Stage::GetCurrent().Add( layer3 ); + DALI_TEST_EQUALS( layer3.GetDepth(), 3u, TEST_LOCATION ); + root.MoveAbove( layer3 ); + DALI_TEST_EQUALS( root.GetDepth(), 3u, TEST_LOCATION ); + DALI_TEST_EQUALS( layer3.GetDepth(), 2u, TEST_LOCATION ); + DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer( 0 ).GetDepth(), 0u, TEST_LOCATION ); + layer3.MoveAbove( Stage::GetCurrent().GetLayer( 0 ) ); + DALI_TEST_EQUALS( layer3.GetDepth(), 1u, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliLayerMoveBelow(void) +{ + tet_infoline("Testing Dali::Layer::MoveBelow()"); + TestApplication application; + Layer layer = Layer::New(); + // try to raise above root layer + Layer root = Stage::GetCurrent().GetLayer( 0 ); + layer.MoveBelow( root ); + // layer depth is zero as its not on stage + DALI_TEST_EQUALS( layer.GetDepth(), 0u, TEST_LOCATION ); + root.MoveBelow( layer ); + // root depth is zero as layer is not on stage + DALI_TEST_EQUALS( layer.GetDepth(), 0u, TEST_LOCATION ); + // add to stage + Stage::GetCurrent().Add( layer ); + layer.MoveBelow( root ); + DALI_TEST_EQUALS( layer.GetDepth(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( root.GetDepth(), 1u, TEST_LOCATION ); + root.MoveBelow( layer ); + DALI_TEST_EQUALS( layer.GetDepth(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( root.GetDepth(), 0u, TEST_LOCATION ); + + // make another layer on the stage + Layer layer2 = Layer::New(); + Stage::GetCurrent().Add( layer2 ); + layer.MoveBelow( layer2 ); + DALI_TEST_EQUALS( layer.GetDepth(), layer2.GetDepth() - 1u, TEST_LOCATION ); + layer2.MoveBelow( root ); + DALI_TEST_EQUALS( layer2.GetDepth(), root.GetDepth() - 1u, TEST_LOCATION ); + root.MoveBelow( layer ); + DALI_TEST_EQUALS( root.GetDepth(), layer.GetDepth() - 1u, TEST_LOCATION ); + + Layer layer3 = Layer::New(); + Stage::GetCurrent().Add( layer3 ); + DALI_TEST_EQUALS( layer3.GetDepth(), 3u, TEST_LOCATION ); + root.MoveBelow( layer3 ); + DALI_TEST_EQUALS( root.GetDepth(), 2u, TEST_LOCATION ); + DALI_TEST_EQUALS( layer3.GetDepth(), 3u, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliLayerDefaultProperties(void) +{ + TestApplication application; + tet_infoline("Testing Dali::Layer DefaultProperties"); + + Layer actor = Layer::New(); + + std::vector indices ; + indices.push_back(Layer::CLIPPING_ENABLE ); + indices.push_back(Layer::CLIPPING_BOX ); + + DALI_TEST_CHECK(actor.GetPropertyCount() == ( Actor::New().GetPropertyCount() + indices.size() ) ); + + for(std::vector::iterator iter = indices.begin(); iter != indices.end(); ++iter) + { + DALI_TEST_CHECK( *iter == actor.GetPropertyIndex(actor.GetPropertyName(*iter)) ); + DALI_TEST_CHECK( actor.IsPropertyWritable(*iter) ); + DALI_TEST_CHECK( !actor.IsPropertyAnimatable(*iter) ); + DALI_TEST_CHECK( actor.GetPropertyType(*iter) == actor.GetPropertyType(*iter) ); // just checking call succeeds + } + + // set/get one of them + actor.SetClippingBox(0,0,0,0); + + ClippingBox testBox(10,20,30,40); + DALI_TEST_CHECK(actor.GetClippingBox() != testBox); + + actor.SetProperty(Layer::CLIPPING_BOX, Property::Value(Rect(testBox))); + + DALI_TEST_CHECK(Property::RECTANGLE == actor.GetPropertyType(Layer::CLIPPING_BOX)) ; + + Property::Value v = actor.GetProperty(Layer::CLIPPING_BOX); + + DALI_TEST_CHECK(v.Get >() == testBox); + + // set the same boundaries, but through a clipping box object + actor.SetClippingBox( testBox ); + + DALI_TEST_CHECK( actor.GetClippingBox() == testBox ); + + END_TEST; +} + +int UtcDaliLayerSetDepthTestDisabled(void) +{ + TestApplication application; + tet_infoline("Testing Dali::Layer::SetDepthTestDisabled() "); + + Layer actor = Layer::New(); + + DALI_TEST_CHECK( !actor.IsDepthTestDisabled() ); + + actor.SetDepthTestDisabled( true ); + DALI_TEST_CHECK( actor.IsDepthTestDisabled() ); + END_TEST; +} + +int UtcDaliLayerCreateDestroy(void) +{ + tet_infoline("Testing Dali::Layer::CreateDestroy() "); + Layer* layer = new Layer; + DALI_TEST_CHECK( layer ); + delete layer; + END_TEST; +} + +int UtcDaliLayerPropertyIndices(void) +{ + TestApplication application; + Actor basicActor = Actor::New(); + Layer layer = Layer::New(); + + Property::IndexContainer indices; + layer.GetPropertyIndices( indices ); + DALI_TEST_CHECK( indices.size() > basicActor.GetPropertyCount() ); + DALI_TEST_EQUALS( indices.size(), layer.GetPropertyCount(), TEST_LOCATION ); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-LongPressGesture.cpp b/automated-tests/src/dali/utc-Dali-LongPressGesture.cpp new file mode 100644 index 0000000..9e27395 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-LongPressGesture.cpp @@ -0,0 +1,71 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +using namespace Dali; + +void utc_dali_long_press_gesture_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_long_press_gesture_cleanup(void) +{ + test_return_value = TET_PASS; +} + + +// Positive test case for a method +int UtcDaliLongPressGestureConstructor(void) +{ + TestApplication application; // Reset all test adapter return codes + + LongPressGesture gesture( Gesture::Started ); + DALI_TEST_EQUALS(1u, gesture.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::LongPress, gesture.type, TEST_LOCATION); + + // Test Copy constructor + gesture.numberOfTouches = 5u; + + LongPressGesture gesture2(gesture); + DALI_TEST_EQUALS(5u, gesture2.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::LongPress, gesture2.type, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, gesture2.state, TEST_LOCATION); + END_TEST; +} + +int UtcDaliLongPressGestureAssignment(void) +{ + // Test Assignment operator + LongPressGesture gesture( Gesture::Started ); + DALI_TEST_EQUALS(1u, gesture.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::LongPress, gesture.type, TEST_LOCATION); + + gesture.numberOfTouches = 5u; + + LongPressGesture gesture2( Gesture::Finished ); + DALI_TEST_EQUALS(Gesture::Finished, gesture2.state, TEST_LOCATION); + gesture2 = gesture; + DALI_TEST_EQUALS(5u, gesture2.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::LongPress, gesture2.type, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, gesture2.state, TEST_LOCATION); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp new file mode 100644 index 0000000..f825c79 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp @@ -0,0 +1,1266 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 +#include +#include + +using namespace Dali; + +void utc_dali_long_press_gesture_detector_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_long_press_gesture_detector_cleanup(void) +{ + test_return_value = TET_PASS; +} + +/////////////////////////////////////////////////////////////////////////////// +namespace +{ + +// Stores data that is populated in the callback and will be read by the TET cases +struct SignalData +{ + SignalData() + : functorCalled( false ), + voidFunctorCalled( false ), + receivedGesture( Gesture::Clear ), + pressedActor() + {} + + void Reset() + { + functorCalled = false; + voidFunctorCalled = false; + + receivedGesture.numberOfTouches = 0u; + receivedGesture.screenPoint = Vector2(0.0f, 0.0f); + receivedGesture.localPoint = Vector2(0.0f, 0.0f); + + pressedActor = NULL; + } + + bool functorCalled; + bool voidFunctorCalled; + LongPressGesture receivedGesture; + Actor pressedActor; +}; + +// Functor that sets the data when called +struct GestureReceivedFunctor +{ + GestureReceivedFunctor(SignalData& data) : signalData(data) { } + + void operator()(Actor actor, LongPressGesture longPress) + { + signalData.functorCalled = true; + signalData.receivedGesture = longPress; + signalData.pressedActor = actor; + } + + void operator()() + { + signalData.voidFunctorCalled = true; + } + + SignalData& signalData; +}; + +// Functor that removes the gestured actor from stage +struct UnstageActorFunctor : public GestureReceivedFunctor +{ + UnstageActorFunctor( SignalData& data, Gesture::State& stateToUnstage ) + : GestureReceivedFunctor( data ), + stateToUnstage( stateToUnstage ) + { + } + + void operator()( Actor actor, LongPressGesture longPress ) + { + GestureReceivedFunctor::operator()( actor, longPress ); + + if ( longPress.state == stateToUnstage ) + { + Stage::GetCurrent().Remove( actor ); + } + } + + Gesture::State& stateToUnstage; +}; + +// Functor for receiving a touch event +struct TouchEventFunctor +{ + bool operator()(Actor actor, const TouchEvent& touch) + { + //For line coverage + unsigned int points = touch.GetPointCount(); + if( points > 0) + { + const TouchPoint& touchPoint = touch.GetPoint(0); + tet_printf("Touch Point state = %d\n", touchPoint.state); + } + return false; + } +}; + +// Generate a LongPressGestureEvent to send to Core +Integration::LongPressGestureEvent GenerateLongPress( + Gesture::State state, + unsigned int numberOfTouches, + Vector2 point) +{ + Integration::LongPressGestureEvent longPress( state ); + + longPress.numberOfTouches = numberOfTouches; + longPress.point = point; + + return longPress; +} + +} // anon namespace + +/////////////////////////////////////////////////////////////////////////////// + + +// Positive test case for a method +int UtcDaliLongPressGestureDetectorConstructor(void) +{ + TestApplication application; + + LongPressGestureDetector detector; + DALI_TEST_CHECK(!detector); + END_TEST; +} + + +int UtcDaliLongPressGestureDetectorNew(void) +{ + TestApplication application; + + LongPressGestureDetector detector = LongPressGestureDetector::New(); + DALI_TEST_CHECK(detector); + DALI_TEST_EQUALS(1u, detector.GetMinimumTouchesRequired(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, detector.GetMaximumTouchesRequired(), TEST_LOCATION); + + LongPressGestureDetector detector2 = LongPressGestureDetector::New(5u); + DALI_TEST_CHECK(detector2); + DALI_TEST_EQUALS(5u, detector2.GetMinimumTouchesRequired(), TEST_LOCATION); + DALI_TEST_EQUALS(5u, detector2.GetMaximumTouchesRequired(), TEST_LOCATION); + + LongPressGestureDetector detector3 = LongPressGestureDetector::New(5u, 7u); + DALI_TEST_CHECK(detector2); + DALI_TEST_EQUALS(5u, detector3.GetMinimumTouchesRequired(), TEST_LOCATION); + DALI_TEST_EQUALS(7u, detector3.GetMaximumTouchesRequired(), TEST_LOCATION); + + //Scoped test to test destructor + { + LongPressGestureDetector detector4 = LongPressGestureDetector::New(); + DALI_TEST_CHECK(detector4); + } + + // Attach an actor and emit a touch event on the actor to ensure complete line coverage + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + detector.Attach(actor); + + TouchEventFunctor touchFunctor; + actor.TouchedSignal().Connect(&application, touchFunctor); + + Integration::TouchEvent touchEvent(1); + TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f); + touchEvent.AddPoint(point); + application.ProcessEvent(touchEvent); + + // Render and notify + application.SendNotification(); + application.Render(); + + // For line coverage, Initialise default constructor + TouchEvent touchEvent2; + END_TEST; +} + +int UtcDaliLongPressGestureDetectorDownCast(void) +{ + TestApplication application; + tet_infoline("Testing Dali::LongPressGestureDetector::DownCast()"); + + LongPressGestureDetector detector = LongPressGestureDetector::New(); + + BaseHandle object(detector); + + LongPressGestureDetector detector2 = LongPressGestureDetector::DownCast(object); + DALI_TEST_CHECK(detector2); + + LongPressGestureDetector detector3 = DownCast< LongPressGestureDetector >(object); + DALI_TEST_CHECK(detector3); + + BaseHandle unInitializedObject; + LongPressGestureDetector detector4 = LongPressGestureDetector::DownCast(unInitializedObject); + DALI_TEST_CHECK(!detector4); + + LongPressGestureDetector detector5 = DownCast< LongPressGestureDetector >(unInitializedObject); + DALI_TEST_CHECK(!detector5); + + GestureDetector detector6 = LongPressGestureDetector::New(); + LongPressGestureDetector detector7 = LongPressGestureDetector::DownCast(detector6); + DALI_TEST_CHECK(detector7); + END_TEST; +} + +int UtcDaliLongPressGestureSetTouchesRequired01(void) +{ + TestApplication application; + + LongPressGestureDetector detector = LongPressGestureDetector::New(); + + unsigned int touches = 3; + + DALI_TEST_CHECK(touches != detector.GetMinimumTouchesRequired()); + DALI_TEST_CHECK(touches != detector.GetMaximumTouchesRequired()); + + detector.SetTouchesRequired(touches); + + DALI_TEST_EQUALS(touches, detector.GetMinimumTouchesRequired(), TEST_LOCATION); + DALI_TEST_EQUALS(touches, detector.GetMaximumTouchesRequired(), TEST_LOCATION); + + // Attach an actor and change the required touches + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + TestGestureManager& gestureManager = application.GetGestureManager(); + gestureManager.Initialize(); + + detector.SetTouchesRequired(4); + + // Gesture detection should have been updated only + DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION); + + // Reset values + gestureManager.Initialize(); + + // Create a second gesture detector that requires even less maximum touches + LongPressGestureDetector secondDetector = LongPressGestureDetector::New(); + secondDetector.Attach(actor); + + // Gesture detection should have been updated + DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION); + END_TEST; +} + +int UtcDaliLongPressGestureSetTouchesRequired02(void) +{ + TestApplication application; + + LongPressGestureDetector detector = LongPressGestureDetector::New(); + + unsigned int min = 3; + unsigned int max = 5; + + DALI_TEST_CHECK(min != detector.GetMinimumTouchesRequired()); + DALI_TEST_CHECK(max != detector.GetMaximumTouchesRequired()); + + detector.SetTouchesRequired(min, max); + + DALI_TEST_EQUALS(min, detector.GetMinimumTouchesRequired(), TEST_LOCATION); + DALI_TEST_EQUALS(max, detector.GetMaximumTouchesRequired(), TEST_LOCATION); + + // Attach an actor and change the maximum touches + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + TestGestureManager& gestureManager = application.GetGestureManager(); + gestureManager.Initialize(); + + detector.SetTouchesRequired(4, 5); + + // Gesture detection should have been updated only + DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION); + + // Reset values + gestureManager.Initialize(); + + // Create a second gesture detector that requires even less maximum touches + LongPressGestureDetector secondDetector = LongPressGestureDetector::New(); + secondDetector.Attach(actor); + + // Gesture detection should have been updated + DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION); + END_TEST; +} + +int UtcDaliLongPressGestureGetMinimumTouchesRequired(void) +{ + TestApplication application; + + LongPressGestureDetector detector = LongPressGestureDetector::New(); + DALI_TEST_EQUALS(1u, detector.GetMinimumTouchesRequired(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliLongPressGestureGetMaximumTouchesRequired(void) +{ + TestApplication application; + + LongPressGestureDetector detector = LongPressGestureDetector::New(); + DALI_TEST_EQUALS(1u, detector.GetMaximumTouchesRequired(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliLongPressGestureSignalReceptionNegative(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + LongPressGestureDetector detector = LongPressGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Do a long press outside actor's area + application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2(112.0f, 112.0f ) ) ); + application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2(112.0f, 112.0f ) ) ); + application.ProcessEvent( GenerateLongPress( Gesture::Finished, 1u, Vector2(112.0f, 112.0f ) ) ); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliLongPressGestureSignalReceptionPositive(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + LongPressGestureDetector detector = LongPressGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Do a long press inside actor's area + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 50.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 50.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 50.0f))); + END_TEST; +} + +int UtcDaliLongPressGestureSignalReceptionDetach(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + LongPressGestureDetector detector = LongPressGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Start long press within the actor's area + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(20.0f, 20.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(20.0f, 20.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS( Vector2(20.0f, 20.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(20.0f, 20.0f))); + + // repeat the long press within the actor's area - we should still receive the signal + data.Reset(); + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 50.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 50.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 50.0f))); + + // Detach actor + detector.DetachAll(); + + // Ensure we are no longer signalled + data.Reset(); + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(20.0f, 20.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(20.0f, 20.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 50.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliLongPressGestureSignalReceptionActorDestroyedDuringLongPress(void) +{ + TestApplication application; + + SignalData data; + GestureReceivedFunctor functor(data); + + LongPressGestureDetector detector = LongPressGestureDetector::New(); + detector.DetectedSignal().Connect(&application, functor); + + // Actor lifetime is scoped + { + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + detector.Attach(actor); + + // Start long press within the actor's area + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(20.0f, 20.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(20.0f, 20.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + + // Remove the actor from stage and reset the data + Stage::GetCurrent().Remove(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + } + + // Actor should now have been destroyed + + data.Reset(); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(20.0f, 20.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliLongPressGestureSignalReceptionRotatedActor(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetRotation(Dali::Degree(90.0f), Vector3::ZAXIS); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + LongPressGestureDetector detector = LongPressGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Do a long press + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(5.0f, 5.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(5.0f, 5.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(5.0f, 5.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION); + + // Rotate actor again and render + actor.SetRotation(Dali::Degree(180.0f), Vector3::ZAXIS); + application.SendNotification(); + application.Render(); + + // Do another long press, should still receive event + data.Reset(); + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(5.0f, 5.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(5.0f, 5.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(5.0f, 5.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION); + + // Rotate actor again and render + actor.SetRotation(Dali::Degree(90.0f), Vector3::YAXIS); + application.SendNotification(); + application.Render(); + + // Do a long press, inside where the actor used to be, Should not receive the event + data.Reset(); + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(70.0f, 70.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(70.0f, 70.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(70.0f, 70.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliLongPressGestureSignalReceptionChildHit(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + parent.SetSize(100.0f, 100.0f); + parent.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(parent); + + // Set child to completely cover parent. + // Change rotation of child to be different from parent so that we can check if our local coordinate + // conversion of the parent actor is correct. + Actor child = Actor::New(); + child.SetSize(100.0f, 100.0f); + child.SetAnchorPoint(AnchorPoint::CENTER); + child.SetParentOrigin(ParentOrigin::CENTER); + child.SetRotation(Dali::Degree(90.0f), Vector3::ZAXIS); + parent.Add(child); + + TouchEventFunctor touchFunctor; + child.TouchedSignal().Connect(&application, touchFunctor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + LongPressGestureDetector detector = LongPressGestureDetector::New(); + detector.Attach(parent); + detector.DetectedSignal().Connect(&application, functor); + + // Do long press - hits child area but parent should still receive it + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 50.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 50.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 50.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, parent == data.pressedActor, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(50.0f, 50.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION); + + // Attach child and generate same touch points + // (Also proves that you can detach and then re-attach another actor) + detector.Attach(child); + detector.Detach(parent); + + // Do an entire long press, only check finished value + data.Reset(); + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(51.0f, 51.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(51.0f, 51.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(51.0f, 51.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, child == data.pressedActor, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(51.0f, 51.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliLongPressGestureSignalReceptionAttachDetachMany(void) +{ + TestApplication application; + + Actor first = Actor::New(); + first.SetSize(100.0f, 100.0f); + first.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(first); + + Actor second = Actor::New(); + second.SetSize(100.0f, 100.0f); + second.SetX(100.0f); + second.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(second); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + LongPressGestureDetector detector = LongPressGestureDetector::New(); + detector.Attach(first); + detector.Attach(second); + detector.DetectedSignal().Connect(&application, functor); + + // LongPress within second actor's area + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(120.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(120.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(120.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, second == data.pressedActor, TEST_LOCATION); + + // LongPress within first actor's area + data.Reset(); + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(20.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(20.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, first == data.pressedActor, TEST_LOCATION); + + // Detach the second actor + detector.Detach(second); + + // second actor shouldn't receive event + data.Reset(); + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(120.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(120.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(120.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // first actor should continue receiving event + data.Reset(); + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(20.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(20.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliLongPressGestureSignalReceptionActorBecomesUntouchable(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + LongPressGestureDetector detector = LongPressGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // LongPress in actor's area + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + + // Actor becomes invisible - actor should not receive the next long press + actor.SetVisible(false); + + // Render and notify + application.SendNotification(); + application.Render(); + + // LongPress in the same area, shouldn't receive event + data.Reset(); + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliLongPressGestureSignalReceptionMultipleGestureDetectors(void) +{ + TestApplication application; + Dali::TestGestureManager& gestureManager = application.GetGestureManager(); + + Actor first = Actor::New(); + first.SetSize(100.0f, 100.0f); + first.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(first); + + Actor second = Actor::New(); + second.SetSize(100.0f, 100.0f); + second.SetAnchorPoint(AnchorPoint::TOP_LEFT); + second.SetX(100.0f); + first.Add(second); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + LongPressGestureDetector firstDetector = LongPressGestureDetector::New(); + firstDetector.Attach(first); + firstDetector.DetectedSignal().Connect(&application, functor); + + // secondDetector is scoped + { + // Reset gestureManager statistics + gestureManager.Initialize(); + + LongPressGestureDetector secondDetector = LongPressGestureDetector::New(); + secondDetector.SetTouchesRequired(2); + secondDetector.Attach(second); + secondDetector.DetectedSignal().Connect(&application, functor); + + DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION); + + // LongPress within second actor's area + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 2u, Vector2(150.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 2u, Vector2(150.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 2u, Vector2(150.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, second == data.pressedActor, TEST_LOCATION); + + // LongPress continues as single touch gesture - we should not receive any gesture + data.Reset(); + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(150.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(150.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(150.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Single touch long press starts - first actor should receive gesture + data.Reset(); + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, first == data.pressedActor, TEST_LOCATION); + + // long press changes to double-touch - we shouldn't receive event + data.Reset(); + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 2u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 2u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 2u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Reset gesture manager statistics + gestureManager.Initialize(); + } + + // secondDetector has now been deleted. Gesture detection should have been updated only + DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION); + END_TEST; +} + +int UtcDaliLongPressGestureSignalReceptionMultipleDetectorsOnActor(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Attach actor to one detector + SignalData firstData; + GestureReceivedFunctor firstFunctor(firstData); + LongPressGestureDetector firstDetector = LongPressGestureDetector::New(); + firstDetector.Attach(actor); + firstDetector.DetectedSignal().Connect(&application, firstFunctor); + + // Attach actor to another detector + SignalData secondData; + GestureReceivedFunctor secondFunctor(secondData); + LongPressGestureDetector secondDetector = LongPressGestureDetector::New(); + secondDetector.Attach(actor); + secondDetector.DetectedSignal().Connect(&application, secondFunctor); + + // LongPress in actor's area - both detector's functors should be called + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliLongPressGestureSignalReceptionDifferentPossible(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Attach actor to detector + SignalData data; + GestureReceivedFunctor functor( data ); + LongPressGestureDetector detector = LongPressGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + // LongPress possible in actor's area. + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Move actor somewhere else + actor.SetPosition( 100.0f, 100.0f ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Emit Started event, we should not receive the long press. + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // LongPress possible in empty area. + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Move actor in to the long press position. + actor.SetPosition( 0.0f, 0.0f ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Emit Started event, we should not receive the long press. + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Normal long press in actor's area for completeness. + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliLongPressGestureEmitIncorrecteStateClear(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Attach actor to detector + SignalData data; + GestureReceivedFunctor functor( data ); + LongPressGestureDetector detector = LongPressGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + // Try a Clear state + try + { + application.ProcessEvent(GenerateLongPress(Gesture::Clear, 1u, Vector2(50.0f, 10.0f))); + tet_result(TET_FAIL); + } + catch ( Dali::DaliException& e ) + { + DALI_TEST_ASSERT( e, "false", TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliLongPressGestureEmitIncorrectStateContinuing(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Attach actor to detector + SignalData data; + GestureReceivedFunctor functor( data ); + LongPressGestureDetector detector = LongPressGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + // Try a Continuing state + try + { + application.ProcessEvent(GenerateLongPress(Gesture::Continuing, 1u, Vector2(50.0f, 10.0f))); + tet_result(TET_FAIL); + } + catch ( Dali::DaliException& e ) + { + DALI_TEST_ASSERT( e, "false", TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliLongPressGestureRepeatedState(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Attach actor to detector + SignalData data; + GestureReceivedFunctor functor( data ); + LongPressGestureDetector detector = LongPressGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + // Two possibles + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // ... Send some finished states, still no signal + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Send two Started states, should be signalled + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + + // Send two cancelled states, should not be signalled + application.ProcessEvent(GenerateLongPress(Gesture::Cancelled, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + application.ProcessEvent(GenerateLongPress(Gesture::Cancelled, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliLongPressGesturePossibleCancelled(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Attach actor to detector + SignalData data; + GestureReceivedFunctor functor( data ); + LongPressGestureDetector detector = LongPressGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + // Send a possible followed by a cancel, we should not be signalled + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + application.ProcessEvent(GenerateLongPress(Gesture::Cancelled, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliLongPressGestureDetachAfterStarted(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Attach actor to detector + SignalData data; + GestureReceivedFunctor functor( data ); + LongPressGestureDetector detector = LongPressGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + // Emit initial signal + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + + // Detach actor + detector.Detach(actor); + + // Emit Finished, no signal + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliLongPressGestureActorUnstaged(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // State to remove actor in. + Gesture::State stateToUnstage( Gesture::Started ); + + // Attach actor to detector + SignalData data; + UnstageActorFunctor functor( data, stateToUnstage ); + LongPressGestureDetector detector = LongPressGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + // Emit signals + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Re-add actor to stage + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Change state to Gesture::Continuing to remove + stateToUnstage = Gesture::Finished; + + // Emit signals + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + tet_result( TET_PASS ); // If we get here then we have handled actor stage removal gracefully. + END_TEST; +} + +int UtcDaliLongPressGestureActorStagedAndDestroyed(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Create and add a second actor so that GestureDetector destruction does not come into play. + Actor dummyActor( Actor::New() ); + dummyActor.SetSize( 100.0f, 100.0f ); + dummyActor.SetPosition( 100.0f, 100.0f ); + dummyActor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(dummyActor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // State to remove actor in. + Gesture::State stateToUnstage( Gesture::Started ); + + // Attach actor to detector + SignalData data; + UnstageActorFunctor functor( data, stateToUnstage ); + LongPressGestureDetector detector = LongPressGestureDetector::New(); + detector.Attach(actor); + detector.Attach(dummyActor); + detector.DetectedSignal().Connect( &application, functor ); + + // Here we are testing a Started actor which is removed in the Started callback, but then added back + // before we get a finished state. As we were removed from the stage, even if we're at the same + // position, we should still not be signalled. + + // Emit signals + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Re add to the stage, we should not be signalled + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Continue signal emission + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + data.Reset(); + + // Here we delete an actor in started, we should not receive any subsequent signalling. + + // Emit signals + application.ProcessEvent(GenerateLongPress(Gesture::Possible, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateLongPress(Gesture::Started, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Delete actor as well + actor = NULL; + + // Render and notify + application.SendNotification(); + application.Render(); + + // Continue signal emission + application.ProcessEvent(GenerateLongPress(Gesture::Finished, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliLongPressGestureSystemOverlay(void) +{ + TestApplication application; + Dali::Integration::Core& core = application.GetCore(); + Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() ); + systemOverlay.GetOverlayRenderTasks().CreateTask(); + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + systemOverlay.Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + LongPressGestureDetector detector = LongPressGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Do a long press inside actor's area + Vector2 screenCoords( 50.0f, 50.0f ); + application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, screenCoords ) ); + application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, screenCoords ) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Material.cpp b/automated-tests/src/dali/utc-Dali-Material.cpp new file mode 100644 index 0000000..36ce22b --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-Material.cpp @@ -0,0 +1,331 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +using namespace Dali; + + +void utc_dali_material_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_material_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ + +static AnimatableMesh CreateMeshData(Material material) +{ + AnimatableMesh::Faces faces; + for(int i=0; i<10-3; i++) + { + faces.push_back(i); + faces.push_back(i+1); + faces.push_back(i+2); + } + return AnimatableMesh::New(10, faces, material); +} + +}// anonymous namespace + + +// Positive test case for a method +int UtcDaliMaterialNew01(void) +{ + TestApplication application; + tet_infoline("Testing constructors, New and destructors"); + + Material material; + DALI_TEST_CHECK( ! material ); + + material = Material::New("material"); + DALI_TEST_CHECK( material ); + + Material* material2 = new Material(); + DALI_TEST_CHECK( ! *material2 ); + delete material2; + + Material material3 = material; + Material material4; + material4 = material; + Material material5 = material; + END_TEST; +} + + +int UtcDaliMaterialDownCast(void) +{ + TestApplication application; + + Material material = Material::New("material"); + BaseHandle handle(material); + + Material mat2 = Material::DownCast( handle ); + DALI_TEST_CHECK( mat2 ); + END_TEST; +} + +int UtcDaliMaterialSettersAndGetters(void) +{ + TestApplication application; + Material material = Material::New("material"); + DALI_TEST_EQUALS( material.GetName(), "material", TEST_LOCATION ); + material.SetName( "AnotherMaterial" ); + DALI_TEST_EQUALS( material.GetName(), "AnotherMaterial", TEST_LOCATION ); + + DALI_TEST_EQUALS( material.GetOpacity(), Material::DEFAULT_OPACITY, 0.001, TEST_LOCATION); + material.SetOpacity(0.38f); + DALI_TEST_EQUALS( material.GetOpacity(), 0.38f, 0.001, TEST_LOCATION); + + DALI_TEST_EQUALS( material.GetShininess(), Material::DEFAULT_SHININESS, 0.001, TEST_LOCATION); + material.SetShininess(0.47f); + DALI_TEST_EQUALS( material.GetShininess(), 0.47f, 0.001, TEST_LOCATION); + + DALI_TEST_EQUALS( material.GetAmbientColor(), Material::DEFAULT_AMBIENT_COLOR, 0.001, TEST_LOCATION); + material.SetAmbientColor(Color::BLACK); + DALI_TEST_EQUALS( material.GetAmbientColor(), Color::BLACK, 0.001, TEST_LOCATION); + + DALI_TEST_EQUALS( material.GetDiffuseColor(), Material::DEFAULT_DIFFUSE_COLOR, 0.001, TEST_LOCATION); + material.SetDiffuseColor(Color::BLUE); + DALI_TEST_EQUALS( material.GetDiffuseColor(), Color::BLUE, 0.001, TEST_LOCATION); + + DALI_TEST_EQUALS( material.GetSpecularColor(), Material::DEFAULT_SPECULAR_COLOR, 0.001, TEST_LOCATION); + material.SetSpecularColor(Color::GREEN); + DALI_TEST_EQUALS( material.GetSpecularColor(), Color::GREEN, 0.001, TEST_LOCATION); + + DALI_TEST_EQUALS( material.GetEmissiveColor(), Material::DEFAULT_EMISSIVE_COLOR, 0.001, TEST_LOCATION); + material.SetEmissiveColor(Color::MAGENTA); + DALI_TEST_EQUALS( material.GetEmissiveColor(), Color::MAGENTA, 0.001, TEST_LOCATION); + + material.SetDiffuseTextureFileName("diffuse-texture.png"); + DALI_TEST_EQUALS( material.GetDiffuseFileName(), "diffuse-texture.png", TEST_LOCATION); + + material.SetOpacityTextureFileName("opacity-texture.png"); + DALI_TEST_EQUALS( material.GetOpacityTextureFileName(), "opacity-texture.png", TEST_LOCATION); + + material.SetNormalMapFileName("normal-map.png"); + DALI_TEST_EQUALS( material.GetNormalMapFileName(), "normal-map.png", TEST_LOCATION); + + Image diffuseTexture = Image::New("diffuse-texture.png"); + material.SetDiffuseTexture(diffuseTexture); + DALI_TEST_EQUALS( material.GetDiffuseTexture(), diffuseTexture, TEST_LOCATION ); + + Image opacityTexture = Image::New("opacity-texture.png"); + material.SetOpacityTexture(opacityTexture); + DALI_TEST_EQUALS( material.GetOpacityTexture(), opacityTexture, TEST_LOCATION); + + Image normalMap = Image::New("normal-map.png"); + material.SetNormalMap(normalMap); + DALI_TEST_EQUALS( material.GetNormalMap(), normalMap, TEST_LOCATION); + + DALI_TEST_EQUALS( material.GetMapU(), (unsigned int)Material::DEFAULT_MAPPING_MODE, TEST_LOCATION ); + DALI_TEST_EQUALS( material.GetMapV(), (unsigned int)Material::DEFAULT_MAPPING_MODE, TEST_LOCATION ); + material.SetMapU( Material::MAPPING_MODE_WRAP ); + material.SetMapV( Material::MAPPING_MODE_MIRROR ); + DALI_TEST_EQUALS( material.GetMapU(), (unsigned int)Material::MAPPING_MODE_WRAP, TEST_LOCATION ); + DALI_TEST_EQUALS( material.GetMapV(), (unsigned int)Material::MAPPING_MODE_MIRROR, TEST_LOCATION ); + + DALI_TEST_EQUALS( material.GetDiffuseUVIndex(), Material::DEFAULT_DIFFUSE_UV_INDEX, TEST_LOCATION ); + material.SetDiffuseUVIndex( 1u ); + DALI_TEST_EQUALS( material.GetDiffuseUVIndex(), 1u, TEST_LOCATION ); + + DALI_TEST_EQUALS( material.GetOpacityUVIndex(), Material::DEFAULT_OPACITY_UV_INDEX, TEST_LOCATION ); + material.SetOpacityUVIndex( 1u ); + DALI_TEST_EQUALS( material.GetOpacityUVIndex(), 1u, TEST_LOCATION ); + + DALI_TEST_EQUALS( material.GetNormalUVIndex(), Material::DEFAULT_NORMAL_UV_INDEX, TEST_LOCATION ); + material.SetNormalUVIndex( 1u ); + DALI_TEST_EQUALS( material.GetNormalUVIndex(), 1u, TEST_LOCATION ); + + DALI_TEST_EQUALS( material.GetHasHeightMap(), Material::DEFAULT_HAS_HEIGHT_MAP, TEST_LOCATION ); + material.SetHasHeightMap(true); + DALI_TEST_EQUALS( material.GetHasHeightMap(), true, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliMaterialStage01(void) +{ + TestApplication application; + TraceCallStack& textureTrace = application.GetGlAbstraction().GetTextureTrace(); + textureTrace.Enable(true); + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + + { + Material material = Material::New("material"); + Image image = Image::New( "image.png", Image::Immediate, Image::Never ); + DALI_TEST_CHECK(image); + application.SendNotification(); + application.Render(16); + + std::vector ids; + ids.push_back( 23 ); + application.GetGlAbstraction().SetNextTextureIds( ids ); + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true ); + Integration::ResourcePointer resource(bitmap); + bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80); + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + Integration::ResourceRequest* request = application.GetPlatform().GetRequest(); + DALI_TEST_CHECK( request != NULL ); + if(request) + { + application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource); + } + + material.SetDiffuseTexture(image); + application.SendNotification(); + application.Render(); + + AnimatableMesh mesh = CreateMeshData(material); + + application.SendNotification(); + application.Render(); + { + MeshActor meshActor = MeshActor::New(mesh); + meshActor.SetSize(100, 100); + meshActor.SetAffectedByLighting(false); + Stage::GetCurrent().Add(meshActor); + application.SendNotification(); + application.Render(); + + material.SetOpacity(0.5f); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( material.GetOpacity(), 0.5f, 0.001f, TEST_LOCATION ); + + Stage::GetCurrent().Remove(meshActor); + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( glAbstraction.CheckNoTexturesDeleted() ); + DALI_TEST_CHECK( ! textureTrace.FindMethod( "DeleteTextures" ) ); + } + application.SendNotification(); + application.Render(); + + // Mesh should be destroyed, reducing connection count on material to zero. + // This should also reduce connection count on image to zero + DALI_TEST_EQUALS( material.GetOpacity(), 0.5f, 0.001f, TEST_LOCATION ); + } + // SceneGraph::Material & SceneGraph::RenderMaterial should be destroyed + // Image should be destroyed + application.SendNotification(); + application.Render(); + + application.Render(); + DALI_TEST_CHECK( textureTrace.FindMethod( "DeleteTextures" ) ); + DALI_TEST_CHECK( glAbstraction.CheckTextureDeleted( 23 ) ); + END_TEST; +} + + +int UtcDaliMaterialStage01MemCheck(void) +{ + TestApplication application; + tet_result(TET_PASS); + END_TEST; +} + +int UtcDaliMaterialStage02(void) +{ + TestApplication application; + TraceCallStack& textureTrace = application.GetGlAbstraction().GetTextureTrace(); + textureTrace.Enable(true); + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + + { + Material material = Material::New("material"); + + Image image = Image::New( "image.png", Image::OnDemand, Image::Unused ); + DALI_TEST_CHECK(image); + application.SendNotification(); + application.Render(16); + DALI_TEST_CHECK( !application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + DALI_TEST_CHECK( application.GetPlatform().GetRequest() == NULL ); + + std::vector ids; + ids.push_back( 23 ); + application.GetGlAbstraction().SetNextTextureIds( ids ); + + material.SetDiffuseTexture(image); + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK( !application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + DALI_TEST_CHECK( application.GetPlatform().GetRequest() == NULL ); + + AnimatableMesh mesh = CreateMeshData(material); + + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK( !application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + DALI_TEST_CHECK( application.GetPlatform().GetRequest() == NULL ); + + { + MeshActor meshActor = MeshActor::New(mesh); + meshActor.SetSize(100, 100); + meshActor.SetAffectedByLighting(false); + Stage::GetCurrent().Add(meshActor); + application.SendNotification(); + application.Render(); + + // Image connection count should go to one - image should get loaded + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + Integration::ResourceRequest* request = application.GetPlatform().GetRequest(); + DALI_TEST_CHECK( request != NULL ); + + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true ); + Integration::ResourcePointer resource(bitmap); + bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80); + if(request) + { + application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource); + } + application.Render(); + + material.SetOpacity(0.5f); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( material.GetOpacity(), 0.5f, 0.001f, TEST_LOCATION ); + + Stage::GetCurrent().Remove(meshActor); + application.SendNotification(); + application.Render(); + + // This should reduce connection count on material to zero, freeing the texture: + DALI_TEST_CHECK( textureTrace.FindMethod( "DeleteTextures" ) ); + DALI_TEST_CHECK( glAbstraction.CheckTextureDeleted( 23 ) ); + } + application.SendNotification(); + application.Render(); + + // Mesh should be destroyed, reducing connection count on material to zero. + // This should also reduce connection count on image to zero, freeing it + DALI_TEST_EQUALS( material.GetOpacity(), 0.5f, 0.001f, TEST_LOCATION ); + } + application.SendNotification(); + application.Render(); + + // SceneGraph::Material & SceneGraph::RenderMaterial should be destroyed + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-MathUtils.cpp b/automated-tests/src/dali/utc-Dali-MathUtils.cpp new file mode 100644 index 0000000..b383e56 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-MathUtils.cpp @@ -0,0 +1,261 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +using namespace Dali; + +void utc_dali_math_utils_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_math_utils_cleanup(void) +{ + test_return_value = TET_PASS; +} + + +// Positive test case for a method +int UtcDaliMathUtilsNextPowerOfTwo(void) +{ + Dali::TestApplication testApp; + + DALI_TEST_EQUALS(NextPowerOfTwo(0), 1u, TEST_LOCATION); + DALI_TEST_EQUALS(NextPowerOfTwo(1), 1u, TEST_LOCATION); + DALI_TEST_EQUALS(NextPowerOfTwo(2), 2u, TEST_LOCATION); + DALI_TEST_EQUALS(NextPowerOfTwo(3), 4u, TEST_LOCATION); + DALI_TEST_EQUALS(NextPowerOfTwo(4), 4u, TEST_LOCATION); + DALI_TEST_EQUALS(NextPowerOfTwo(5), 8u, TEST_LOCATION); + DALI_TEST_EQUALS(NextPowerOfTwo(6), 8u, TEST_LOCATION); + DALI_TEST_EQUALS(NextPowerOfTwo(7), 8u, TEST_LOCATION); + DALI_TEST_EQUALS(NextPowerOfTwo(8), 8u, TEST_LOCATION); + DALI_TEST_EQUALS(NextPowerOfTwo(255), 256u, TEST_LOCATION); + DALI_TEST_EQUALS(NextPowerOfTwo(256), 256u, TEST_LOCATION); + DALI_TEST_EQUALS(NextPowerOfTwo(257), 512u, TEST_LOCATION); + DALI_TEST_EQUALS(NextPowerOfTwo(511), 512u, TEST_LOCATION); + DALI_TEST_EQUALS(NextPowerOfTwo(512), 512u, TEST_LOCATION); + DALI_TEST_EQUALS(NextPowerOfTwo(513), 1024u, TEST_LOCATION); + DALI_TEST_EQUALS(NextPowerOfTwo(768), 1024u, TEST_LOCATION); + DALI_TEST_EQUALS(NextPowerOfTwo(1023), 1024u, TEST_LOCATION); + DALI_TEST_EQUALS(NextPowerOfTwo(1024), 1024u, TEST_LOCATION); + DALI_TEST_EQUALS(NextPowerOfTwo(1025), 2048u, TEST_LOCATION); + END_TEST; +} + + +// Positive test case for a method +int UtcDaliMathUtilsIsPowerOfTwo(void) +{ + Dali::TestApplication testApp; + + DALI_TEST_EQUALS(IsPowerOfTwo(0), false, TEST_LOCATION); + + DALI_TEST_EQUALS(IsPowerOfTwo(1), true, TEST_LOCATION); + DALI_TEST_EQUALS(IsPowerOfTwo(2), true, TEST_LOCATION); + DALI_TEST_EQUALS(IsPowerOfTwo(3), false, TEST_LOCATION); + DALI_TEST_EQUALS(IsPowerOfTwo(4), true, TEST_LOCATION); + DALI_TEST_EQUALS(IsPowerOfTwo(5), false, TEST_LOCATION); + DALI_TEST_EQUALS(IsPowerOfTwo(6), false, TEST_LOCATION); + DALI_TEST_EQUALS(IsPowerOfTwo(7), false, TEST_LOCATION); + DALI_TEST_EQUALS(IsPowerOfTwo(8), true, TEST_LOCATION); + DALI_TEST_EQUALS(IsPowerOfTwo(255), false, TEST_LOCATION); + DALI_TEST_EQUALS(IsPowerOfTwo(256), true, TEST_LOCATION); + DALI_TEST_EQUALS(IsPowerOfTwo(257), false, TEST_LOCATION); + DALI_TEST_EQUALS(IsPowerOfTwo(511), false, TEST_LOCATION); + DALI_TEST_EQUALS(IsPowerOfTwo(512), true, TEST_LOCATION); + DALI_TEST_EQUALS(IsPowerOfTwo(513), false, TEST_LOCATION); + DALI_TEST_EQUALS(IsPowerOfTwo(768), false, TEST_LOCATION); + DALI_TEST_EQUALS(IsPowerOfTwo(1023), false, TEST_LOCATION); + DALI_TEST_EQUALS(IsPowerOfTwo(1024), true, TEST_LOCATION); + DALI_TEST_EQUALS(IsPowerOfTwo(1025), false, TEST_LOCATION); + END_TEST; +} + + + +// Positive test case for a method +int UtcDaliMathUtilsGetRangedEpsilon(void) +{ + Dali::TestApplication testApp; + + DALI_TEST_EQUALS(GetRangedEpsilon(0.05f, 0.02f), Dali::Math::MACHINE_EPSILON_0, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(0.05f, 0.02f), Dali::Math::MACHINE_EPSILON_0, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(0.05f, 0.099f), Dali::Math::MACHINE_EPSILON_0, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(0.099f, 0.02f), Dali::Math::MACHINE_EPSILON_0, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(0.05f, 0.5f), Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(0.99f, 0.5f), Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(0.99f, 0.98f), Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(1.05f, 0.99f), Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(1.99f, 1.05f), Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); + + DALI_TEST_EQUALS(GetRangedEpsilon(2.0f, 1.99f), Dali::Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(0.05f, 2.0f), Dali::Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(1.0f, 3.0f), Dali::Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(9.99f, 0.5f), Dali::Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(9.99f, 1.5f), Dali::Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(9.99f, 9.99f), Dali::Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(9.99f, 10.0f), Dali::Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(19.99f, 10.0f), Dali::Math::MACHINE_EPSILON_10, TEST_LOCATION); + + DALI_TEST_EQUALS(GetRangedEpsilon(20.0f, 10.0f), Dali::Math::MACHINE_EPSILON_100, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(20.0f, 30.0f), Dali::Math::MACHINE_EPSILON_100, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(80.0f, 90.0f), Dali::Math::MACHINE_EPSILON_100, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(180.0f, 190.0f), Dali::Math::MACHINE_EPSILON_100, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(185.0f, 190.0f), Dali::Math::MACHINE_EPSILON_100, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(199.0f, 199.0f), Dali::Math::MACHINE_EPSILON_100, TEST_LOCATION); + + DALI_TEST_EQUALS(GetRangedEpsilon(200.0f, 190.0f), Dali::Math::MACHINE_EPSILON_1000, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(0.005f, 1999.0f), Dali::Math::MACHINE_EPSILON_1000, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(2000.0f, 190.0f), Dali::Math::MACHINE_EPSILON_10000, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(0.005f, 19999.0f), Dali::Math::MACHINE_EPSILON_10000, TEST_LOCATION); + + DALI_TEST_EQUALS(GetRangedEpsilon(1e07f, 0.99e09f), Dali::Math::MACHINE_EPSILON_10000, TEST_LOCATION); + + + DALI_TEST_EQUALS(GetRangedEpsilon(-0.05f, -0.02f), Dali::Math::MACHINE_EPSILON_0, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(-0.05f, -0.02f), Dali::Math::MACHINE_EPSILON_0, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(-0.05f, -0.099f), Dali::Math::MACHINE_EPSILON_0, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(-0.099f, - 0.02f), Dali::Math::MACHINE_EPSILON_0, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(-0.05f, -0.5f), Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(-0.99f, -0.5f), Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(-0.99f, -0.98f), Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(-1.05f, -0.99f), Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(-1.99f, -1.05f), Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); + + DALI_TEST_EQUALS(GetRangedEpsilon(-2.0f, - 1.99f), Dali::Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(-0.05f, -2.0f), Dali::Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(-1.0f, - 3.0f), Dali::Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(-9.99f, -0.5f), Dali::Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(-9.99f, -1.5f), Dali::Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(-9.99f, -9.99f), Dali::Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(-9.99f, -10.0f), Dali::Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(-19.99f, -10.0f), Dali::Math::MACHINE_EPSILON_10, TEST_LOCATION); + + DALI_TEST_EQUALS(GetRangedEpsilon(-20.0f, -10.0f), Dali::Math::MACHINE_EPSILON_100, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(-20.0f, -30.0f), Dali::Math::MACHINE_EPSILON_100, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(-80.0f, -90.0f), Dali::Math::MACHINE_EPSILON_100, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(-180.0f, -190.0f), Dali::Math::MACHINE_EPSILON_100, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(-185.0f, -190.0f), Dali::Math::MACHINE_EPSILON_100, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(-199.0f, -199.0f), Dali::Math::MACHINE_EPSILON_100, TEST_LOCATION); + + DALI_TEST_EQUALS(GetRangedEpsilon(-200.0f, -190.0f), Dali::Math::MACHINE_EPSILON_1000, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(-0.005f, -1999.0f), Dali::Math::MACHINE_EPSILON_1000, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(-2000.0f, -190.0f), Dali::Math::MACHINE_EPSILON_10000, TEST_LOCATION); + DALI_TEST_EQUALS(GetRangedEpsilon(-0.005f, -19999.0f), Dali::Math::MACHINE_EPSILON_10000, TEST_LOCATION); + + DALI_TEST_EQUALS(GetRangedEpsilon(-1e07f, -0.99e09f), Dali::Math::MACHINE_EPSILON_10000, TEST_LOCATION); + + + END_TEST; +} + +// Positive test case for a method +int UtcDaliMathUtilsRound(void) +{ + Dali::TestApplication testApp; + + DALI_TEST_EQUALS(Round(1.00001, 4), 1.0f, TEST_LOCATION); + DALI_TEST_EQUALS(Round(0.99999f, 4), 1.0f, TEST_LOCATION); + DALI_TEST_EQUALS(Round(-1.00001, 4), -1.0f, TEST_LOCATION); + DALI_TEST_EQUALS(Round(-0.99999f, 4), -1.0f, TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliMathUtilsClamp(void) +{ + Dali::TestApplication testApp; + + //floats + DALI_TEST_EQUALS(Clamp(-1.0f, 0.0f, 1.0f), 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS(Clamp(0.0f, -1.0f, 1.0f), 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS(Clamp(1.0f, 0.0f, 1.0f), 1.0f, TEST_LOCATION); + DALI_TEST_EQUALS(Clamp(2.0f, 0.0f, 1.0f), 1.0f, TEST_LOCATION); + + // integers + DALI_TEST_EQUALS(Clamp(-10, 0, 10), 0, TEST_LOCATION); + DALI_TEST_EQUALS(Clamp(0, -10, 10), 0, TEST_LOCATION); + DALI_TEST_EQUALS(Clamp(20, 0, 10), 10, TEST_LOCATION); + + float value=-10.0f, min=-2.0f, max=4.0f; + ClampInPlace(value, min, max); + DALI_TEST_EQUALS(value, min, 0.001, TEST_LOCATION); + + value = 10.0f; + ClampInPlace(value, min, max); + DALI_TEST_EQUALS(value, max, 0.001, TEST_LOCATION); + + value = 3.0f; + ClampInPlace(value, min, max); + DALI_TEST_EQUALS(value, 3.0f, 0.001, TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliMathUtilsWrapInDomain(void) +{ + Dali::TestApplication testApp; + + DALI_TEST_EQUALS(WrapInDomain(0.0f, 0.0f, 0.0f), 0.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); + DALI_TEST_EQUALS(WrapInDomain(-5.0f, 0.0f, 0.0f), 0.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); + DALI_TEST_EQUALS(WrapInDomain(5.0f, 0.0f, 0.0f), 0.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); + DALI_TEST_EQUALS(WrapInDomain(0.0f, 0.0f, 10.0f), 0.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); + DALI_TEST_EQUALS(WrapInDomain(-5.0f, 0.0f, 10.0f), 5.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); + DALI_TEST_EQUALS(WrapInDomain(5.0f, 0.0f, 10.0f), 5.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); + DALI_TEST_EQUALS(WrapInDomain(-2.5f, 0.0f, 10.0f), 7.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); + DALI_TEST_EQUALS(WrapInDomain(2.5f, 0.0f, 10.0f), 2.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); + DALI_TEST_EQUALS(WrapInDomain(2.5f, 0.0f, 1.0f), 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); + DALI_TEST_EQUALS(WrapInDomain(2.5f, -2.0f, -1.0f), -1.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); + DALI_TEST_EQUALS(WrapInDomain(-2.9f, -2.0f, -1.0f), -1.9f, Dali::Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS(WrapInDomain(-1.1f, -2.0f, -1.0f), -1.1f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION); + END_TEST; +} + +// Positive test case for a method +int UtcDaliMathUtilsShortestDistanceInDomain(void) +{ + Dali::TestApplication testApp; + + DALI_TEST_EQUALS(ShortestDistanceInDomain(1.0f, 8.0f, 0.0f, 10.0f), -3.0f, Dali::Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS(ShortestDistanceInDomain(5.0f, 8.0f, 0.0f, 10.0f), 3.0f, Dali::Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS(ShortestDistanceInDomain(5.0f, 8.0f, 4.0f, 9.0f), -2.0f, Dali::Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS(ShortestDistanceInDomain(8.0f, 5.0f, 4.0f, 9.0f), 2.0f, Dali::Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS(ShortestDistanceInDomain(0.65f, 0.1f, -1.0f, 1.0f), -0.55f, Dali::Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS(ShortestDistanceInDomain(0.95f, -0.9f, -1.0f, 1.0f), 0.15f, Dali::Math::MACHINE_EPSILON_10, TEST_LOCATION); + DALI_TEST_EQUALS(ShortestDistanceInDomain(0.0f, -0.9f, -1.0f, 1.0f), -0.9f, Dali::Math::MACHINE_EPSILON_10, TEST_LOCATION); + END_TEST; +} + +int UtcDaliMathUtilsEquals(void) +{ + float v=0.0f; + + DALI_TEST_CHECK(EqualsZero(v)); + + v = Math::PI; + v -= (Math::PI_2 * 2.0f); + DALI_TEST_CHECK(EqualsZero(v)); + + float w=100.0f; + float x=w+1e-8f; + DALI_TEST_CHECK( Equals(w, x, GetRangedEpsilon( w, x )) ); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Matrix.cpp b/automated-tests/src/dali/utc-Dali-Matrix.cpp new file mode 100644 index 0000000..9608575 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-Matrix.cpp @@ -0,0 +1,742 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; + + +void utc_dali_matrix_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_matrix_cleanup(void) +{ + test_return_value = TET_PASS; +} + + +int UtcDaliMatrixCtor(void) +{ + // Test initialized startup + Matrix m1; + + float r1[] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}; + float r2[] = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; + Matrix mr1(r1); + Matrix mr2(r2); + + DALI_TEST_EQUALS(m1, mr1, 0.001f, TEST_LOCATION); + + // Test uninitialized startup + // Stack construct a matrix to non zero, then stack construct another matrix over the top of it. + float r3[] = { 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f}; + { + Matrix m3(r3); + } + { + Matrix m2(false); + + bool initialised = true; + { + float* els = m2.AsFloat(); + for(size_t idx=0; idx<16; ++idx, ++els) + { + if(*els != 0.0f) + initialised = false; + } + } + + DALI_TEST_EQUALS(initialised, false, TEST_LOCATION); + } + + Matrix m4(true); + DALI_TEST_EQUALS(m4, mr1, 0.001f, TEST_LOCATION); + + m4 = m4; + DALI_TEST_EQUALS(m4, mr1, 0.001f, TEST_LOCATION); + + Matrix m5(false); + m5.SetIdentity(); + Matrix m6 = m5; + DALI_TEST_EQUALS(m6, mr2, 0.001f, TEST_LOCATION); + END_TEST; +} + +// OrthoNormalise fixes floating point errors from matrix rotations +int UtcDaliMatrixOrthoNormalize0(void) +{ + Matrix m; + m.SetIdentity(); + + for (int i=0;i<1000;++i) + { + float f = i; + Vector4 axis(cosf(f*0.001f), cosf(f*0.02f), cosf(f*0.03f), 0.0f); + axis.Normalize(); + + m.SetTransformComponents( Vector3::ONE, Quaternion(1.0f, axis), Vector3::ZERO ); + m.OrthoNormalize(); + } + + bool success = true; + success &= fabsf(m.GetXAxis().Dot(m.GetYAxis())) < 0.001f; + success &= fabsf(m.GetYAxis().Dot(m.GetXAxis())) < 0.001f; + success &= fabsf(m.GetZAxis().Dot(m.GetYAxis())) < 0.001f; + + success &= fabsf(m.GetXAxis().Length() - 1.0f) < 0.001f; + success &= fabsf(m.GetYAxis().Length() - 1.0f) < 0.001f; + success &= fabsf(m.GetZAxis().Length() - 1.0f) < 0.001f; + + DALI_TEST_CHECK(success); + END_TEST; +} + +// OrthoNormalize is not flipping the axes and is maintaining the translation +int UtcDaliMatrixOrthoNormalize1(void) +{ + for (int i=0;i<1000;++i) + { + float f = i; + Vector4 axis(cosf(f*0.001f), cosf(f*0.02f), cosf(f*0.03f), 0.0f); + axis.Normalize(); + Vector3 center(10.0f, 15.0f, 5.0f); + + Matrix m0; + m0.SetIdentity(); + m0.SetTransformComponents( Vector3::ONE, Quaternion(1.0f, axis), center ); + + Matrix m1(m0); + m1.OrthoNormalize(); + + DALI_TEST_EQUALS(m0.GetXAxis(), m1.GetXAxis(), 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(m0.GetYAxis(), m1.GetYAxis(), 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(m0.GetZAxis(), m1.GetZAxis(), 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(m0.GetTranslation(), m1.GetTranslation(), 0.001f, TEST_LOCATION); + } + END_TEST; +} + +// Invert works +int UtcDaliMatrixInvert01(void) +{ + // We're going to invert a whole load of different matrices to make sure we don't + // fail on particular orientations. + for (int i=0;i<1000;++i) + { + float f = i; + Vector4 axis(cosf(f*0.001f), cosf(f*0.02f), cosf(f*0.03f), 0.0f); + axis.Normalize(); + Vector3 center(f, cosf(f) * 100.0f, cosf(f*0.5f) * 50.0f); + + Matrix m0; + m0.SetIdentity(); + m0.SetTransformComponents( Vector3::ONE, Quaternion(1.0f, axis), center ); + + Matrix m1(m0); + m1.Invert(); + + Matrix m2( false ); + Matrix::Multiply( m2, m0, m1 ); + + DALI_TEST_EQUALS(m2, Matrix::IDENTITY, 0.001f, TEST_LOCATION); + + m1.Invert(); // doube invert - should be back to m0 + + DALI_TEST_EQUALS(m0, m1, 0.001f, TEST_LOCATION); + } + END_TEST; +} + + +int UtcDaliMatrixInvert02(void) +{ + Matrix m1 = Matrix::IDENTITY; + m1.SetXAxis(Vector3(0.0f, 0.0f, 0.0f)); + DALI_TEST_EQUALS(m1.Invert(), false, TEST_LOCATION); + END_TEST; +} + + +// Invert transform works +int UtcDaliMatrixInvertTransform01(void) +{ + for (int i=0;i<1000;++i) + { + float f = i; + Vector4 axis(cosf(f*0.001f), cosf(f*0.02f), cosf(f*0.03f), 0.0f); + axis.Normalize(); + Vector3 center(f, cosf(f) * 100.0f, cosf(f*0.5f) * 50.0f); + + Matrix m0; + m0.SetIdentity(); + m0.SetTransformComponents( Vector3::ONE, Quaternion(1.0f, axis), center ); + + Matrix m1; + m0.InvertTransform(m1); + + Matrix m2( false ); + Matrix::Multiply( m2, m0, m1 ); + + DALI_TEST_EQUALS(m2, Matrix::IDENTITY, 0.001f, TEST_LOCATION); + } + END_TEST; +} + + +// Invert transform works +int UtcDaliMatrixInvertTransform02(void) +{ + std::string exceptionString( "EqualsZero( mMatrix[3] ) && EqualsZero( mMatrix[7] ) && EqualsZero( mMatrix[11] ) && Equals( mMatrix[15], 1.0f" ); + try + { + float els[] = { 0.0f, 1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, 7.0f, + 8.0f, 9.0f, 10.0f, 11.0f, + 12.0f, 13.0f, 14.0f, 15.0f }; + Matrix m(els); + + Matrix it; + m.InvertTransform(it); + tet_result(TET_FAIL); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT( e, exceptionString, TEST_LOCATION ); + } + + try + { + float els[] = { 0.0f, 1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, 7.0f, + 8.0f, 9.0f, 10.0f, 11.0f, + 12.0f, 13.0f, 14.0f, 15.0f }; + Matrix m(els); + + Matrix it; + m.InvertTransform(it); + tet_result(TET_FAIL); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT( e, exceptionString, TEST_LOCATION ); + } + + try + { + float els[] = { 0.0f, 1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, 7.0f, + 8.0f, 9.0f, 10.0f, 11.0f, + 12.0f, 13.0f, 14.0f, 15.0f }; + Matrix m(els); + + Matrix it; + m.InvertTransform(it); + tet_result(TET_FAIL); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT( e, exceptionString, TEST_LOCATION ); + } + + try + { + float els[] = { 0.0f, 1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, 7.0f, + 8.0f, 9.0f, 10.0f, 11.0f, + 12.0f, 13.0f, 14.0f, 15.0f }; + Matrix m(els); + + Matrix it; + m.InvertTransform(it); + tet_result(TET_FAIL); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT( e, exceptionString, TEST_LOCATION ); + } + END_TEST; +} + + +// GetXAxis +int UtcDaliMatrixGetXAxis(void) +{ + float els[] = { 0.0f, 1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, 7.0f, + 8.0f, 9.0f, 10.0f, 11.0f, + 12.0f, 13.0f, 14.0f, 15.0f }; + Matrix m(els); + + DALI_TEST_CHECK(m.GetXAxis() == Vector3(0.0f, 1.0f, 2.0f)); + END_TEST; +} + +// GetYAxis +int UtcDaliMatrixGetYAxis(void) +{ + float els[] = { 0.0f, 1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, 7.0f, + 8.0f, 9.0f, 10.0f, 11.0f, + 12.0f, 13.0f, 14.0f, 15.0f }; + Matrix m(els); + + DALI_TEST_CHECK(m.GetYAxis() == Vector3(4.0f, 5.0f, 6.0f)); + END_TEST; +} + +// GetZAxis +int UtcDaliMatrixGetZAxis(void) +{ + float els[] = { 0.0f, 1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, 7.0f, + 8.0f, 9.0f, 10.0f, 11.0f, + 12.0f, 13.0f, 14.0f, 15.0f }; + Matrix m(els); + + DALI_TEST_CHECK(m.GetZAxis() == Vector3(8.0f, 9.0f, 10.0f)); + END_TEST; +} + +// GetTranslation +int UtcDaliMatrixGetTranslation(void) +{ + float els[] = { 0.0f, 1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, 7.0f, + 8.0f, 9.0f, 10.0f, 11.0f, + 12.0f, 13.0f, 14.0f, 15.0f }; + Matrix m(els); + + DALI_TEST_EQUALS(m.GetTranslation(), Vector4(12.0f, 13.0f, 14.0f, 15.0f), TEST_LOCATION); + END_TEST; +} + +// GetTranslation +int UtcDaliMatrixGetTranslation3(void) +{ + float els[] = { 0.0f, 1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, 7.0f, + 8.0f, 9.0f, 10.0f, 11.0f, + 12.0f, 13.0f, 14.0f, 15.0f }; + Matrix m(els); + + DALI_TEST_EQUALS(m.GetTranslation3(), Vector3(12.0f, 13.0f, 14.0f), TEST_LOCATION); + END_TEST; +} + +// SetIdentity +int UtcDaliMatrixSetIdentity(void) +{ + float els[] = { 0.0f, 1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, 7.0f, + 8.0f, 9.0f, 10.0f, 11.0f, + 12.0f, 13.0f, 14.0f, 15.0f }; + Matrix m(els); + m.SetIdentity(); + + DALI_TEST_EQUALS(m, Matrix::IDENTITY, 0.001f, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliMatrixSetIdentityAndScale(void) +{ + float els[] = { 0.0f, 1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, 7.0f, + 8.0f, 9.0f, 10.0f, 11.0f, + 12.0f, 13.0f, 14.0f, 15.0f }; + Matrix m(els); + m.SetIdentityAndScale(Vector3(4.0f, 4.0f, 4.0f)); + + float els2[] = { 4.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 4.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 4.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f }; + Matrix r(els2); + + DALI_TEST_EQUALS(m, r, 0.001f, TEST_LOCATION); + END_TEST; +} + + +// SetXAxis +int UtcDaliMatrixSetXAxis(void) +{ + Matrix m; + Vector3 v(2.0f, 3.0f, 4.0f); + m.SetXAxis(v); + + DALI_TEST_CHECK(m.GetXAxis() == v); + END_TEST; +} + +// SetYAxis +int UtcDaliMatrixSetYAxis(void) +{ + Matrix m; + Vector3 v(2.0f, 3.0f, 4.0f); + m.SetYAxis(v); + + DALI_TEST_CHECK(m.GetYAxis() == v); + END_TEST; +} + +// SetZAxis +int UtcDaliMatrixSetZAxis(void) +{ + Matrix m; + Vector3 v(2.0f, 3.0f, 4.0f); + m.SetZAxis(v); + + DALI_TEST_CHECK(m.GetZAxis() == v); + END_TEST; +} + +// SetTranslation +int UtcDaliMatrixSetTranslation(void) +{ + Matrix m; + Vector4 v(2.0f, 3.0f, 4.0f, 5.0f); + m.SetTranslation(v); + + DALI_TEST_CHECK(m.GetTranslation() == v); + END_TEST; +} + +// SetTranslation +int UtcDaliMatrixSetTranslation3(void) +{ + Matrix m; + Vector3 v(2.0f, 3.0f, 4.0f); + m.SetTranslation(v); + + DALI_TEST_CHECK(m.GetTranslation3() == v); + END_TEST; +} + + + +// Transpose +int UtcDaliMatrixTranspose(void) +{ + float floats[] = + { 0.0f, 1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, 7.0f, + 8.0f, 9.0f, 10.0f, 11.0f, + 12.0f, 13.0f, 14.0f, 15.0f + }; + + Matrix m(floats); + m.Transpose(); + + bool success = true; + + for (int x=0;x<4;++x) + { + for (int y=0;y<4;++y) + { + success &= (m.AsFloat()[x+y*4] == floats[x*4+y]); + } + } + + DALI_TEST_CHECK(success); + END_TEST; +} + +int UtcDaliMatrixOStreamOperator(void) +{ + std::ostringstream oss; + + Matrix matrix; + matrix.SetIdentity(); + + oss << matrix; + + std::string expectedOutput = "[ [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1] ]"; + + DALI_TEST_EQUALS( oss.str(), expectedOutput, TEST_LOCATION); + END_TEST; +} + +int UtcDaliMatrixMultiply(void) +{ + Matrix m1 = Matrix::IDENTITY; + + float els[] = { 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.707f, 0.707f, 0.0f, + 0.0f, -0.707f, 0.707f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f }; + Matrix result(els); + + Quaternion q(Radian(Degree(45.0f)), Vector3::XAXIS); + Matrix m2(false); + Matrix::Multiply(m2, m1, q); + + DALI_TEST_EQUALS(m2, result, 0.01f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliMatrixOperatorMultiply(void) +{ + Vector4 v1(2.0f, 5.0f, 4.0f, 0.0f); + + float els[] = {2.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 3.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 4.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f }; + Matrix m1(els); + + Vector4 v2 = m1 * v1; + Vector4 r1(4.0f, 15.0f, 16.0f, 0.0f); + DALI_TEST_EQUALS(v2, r1, 0.01f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliMatrixOperatorMultiply02(void) +{ + TestApplication application; + + Vector3 position ( 30.f, 40.f, 50.f); + + Matrix m1(false); + m1.SetIdentity(); + m1.SetTranslation(-position); + + Vector4 positionV4(position); + positionV4.w=1.0f; + Vector4 output = m1 * positionV4; + + output.w = 0.0f; + DALI_TEST_EQUALS(output, Vector4::ZERO, 0.01f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliMatrixOperatorEquals(void) +{ + Matrix m1 = Matrix::IDENTITY; + + float els[] = { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; + Matrix r2(els); + DALI_TEST_EQUALS(m1 == r2, true, TEST_LOCATION); + + float *f = m1.AsFloat(); + for(size_t i=0; i<16; i++) + { + f[15-i] = 1.2f; + DALI_TEST_EQUALS(m1 == r2, false, TEST_LOCATION); + } + END_TEST; +} + + +int UtcDaliMatrixOperatorNotEquals(void) +{ + Matrix m1 = Matrix::IDENTITY; + float els[] = {2.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 3.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 4.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f }; + Matrix r1(els); + + DALI_TEST_CHECK(m1 != r1); + DALI_TEST_CHECK(!(m1 != m1)); + END_TEST; +} + +int UtcDaliMatrixGetTransformComponents01(void) +{ + Matrix m2(Matrix::IDENTITY.AsFloat()); + Vector3 pos2; + Vector3 scale2; + Quaternion q2; + m2.GetTransformComponents(pos2, q2, scale2); + DALI_TEST_EQUALS(Vector3(0.0f, 0.0f, 0.0f), pos2, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(Vector3(1.0f, 1.0f, 1.0f), scale2, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(Quaternion(), q2, 0.001, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliMatrixGetTransformComponents02(void) +{ + // Create an arbitrary vector + for( float x=-1.0f; x<=1.0f; x+=0.1f ) + { + for( float y=-1.0f; y<1.0f; y+=0.1f ) + { + for( float z=-1.0f; z<1.0f; z+=0.1f ) + { + Vector3 vForward(x, y, z); + vForward.Normalize(); + + for( float angle = 5.0f; angle <= 360.0f; angle += 15.0f) + { + Quaternion rotation1(Radian(Degree(angle)), vForward); + Vector3 scale1(2.0f, 3.0f, 4.0f); + Vector3 position1(1.0f, 2.0f, 3.0f); + + Matrix m1(false); + m1.SetTransformComponents(scale1, rotation1, position1); + + Vector3 position2; + Quaternion rotation2; + Vector3 scale2; + m1.GetTransformComponents(position2, rotation2, scale2); + + DALI_TEST_EQUALS(position1, position2, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(scale1, scale2, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(rotation1, rotation2, 0.001, TEST_LOCATION); + } + } + } + } + END_TEST; +} + +int UtcDaliMatrixSetTransformComponents01(void) +{ + // Create an arbitrary vector + for( float x=-1.0f; x<=1.0f; x+=0.1f ) + { + for( float y=-1.0f; y<1.0f; y+=0.1f ) + { + for( float z=-1.0f; z<1.0f; z+=0.1f ) + { + Vector3 vForward(x, y, z); + vForward.Normalize(); + + for( float angle = 5.0f; angle <= 360.0f; angle += 15.0f) + { + Quaternion rotation1(Radian(Degree(angle)), vForward); + + Matrix m1(rotation1); + Matrix result1(false); + Vector4 vForward4(vForward.x, vForward.y, vForward.z, 0.0f); + result1.SetTransformComponents( Vector3::ONE, Quaternion(Radian(Degree(angle)), vForward4), Vector3::ZERO ); + + DALI_TEST_EQUALS(m1, result1, 0.001, TEST_LOCATION); + + Matrix m2(false); + m2.SetTransformComponents(vForward, Quaternion::IDENTITY, Vector3::ZERO); + + Matrix result2a(Matrix::IDENTITY); + result2a.SetXAxis(result2a.GetXAxis() * vForward[0]); + result2a.SetYAxis(result2a.GetYAxis() * vForward[1]); + result2a.SetZAxis(result2a.GetZAxis() * vForward[2]); + + DALI_TEST_EQUALS(m2, result2a, 0.001, TEST_LOCATION); + + Matrix m3(false); + m3.SetTransformComponents(vForward, rotation1, Vector3::ZERO); + + Matrix result3(Matrix::IDENTITY); + result3.SetXAxis(result3.GetXAxis() * vForward[0]); + result3.SetYAxis(result3.GetYAxis() * vForward[1]); + result3.SetZAxis(result3.GetZAxis() * vForward[2]); + + Matrix::Multiply(result3, result3, m1); + DALI_TEST_EQUALS(m3, result3, 0.001, TEST_LOCATION); + } + } + } + } + END_TEST; +} + + +int UtcDaliMatrixSetInverseTransformComponent01(void) +{ + // Create an arbitrary vector + for( float x=-1.0f; x<=1.0f; x+=0.1f ) + { + for( float y=-1.0f; y<1.0f; y+=0.1f ) + { + for( float z=-1.0f; z<1.0f; z+=0.1f ) + { + Vector3 vForward(x, y, z); + vForward.Normalize(); + + for( float angle = 5.0f; angle <= 360.0f; angle += 15.0f) + { + Quaternion rotation1(Radian(Degree(angle)), vForward); + Vector3 scale1(2.0f, 3.0f, 4.0f); + Vector3 position1(1.0f, 2.0f, 3.0f); + + Matrix m1(false); + m1.SetTransformComponents(scale1, rotation1, position1); + + Matrix m2(false); + m2.SetInverseTransformComponents(scale1, rotation1, position1); + + Matrix result; + Matrix::Multiply(result, m1, m2); + + DALI_TEST_EQUALS(result, Matrix::IDENTITY, 0.001, TEST_LOCATION); + } + } + } + } + END_TEST; +} + +int UtcDaliMatrixSetInverseTransformComponent02(void) +{ + // Create an arbitrary vector + for( float x=-1.0f; x<=1.0f; x+=0.1f ) + { + for( float y=-1.0f; y<1.0f; y+=0.1f ) + { + for( float z=-1.0f; z<1.0f; z+=0.1f ) + { + Vector3 vForward(x, y, z); + vForward.Normalize(); + + for( float angle = 5.0f; angle <= 360.0f; angle += 15.0f) + { + Quaternion rotation1(Radian(Degree(angle)), vForward); + Matrix rotationMatrix(rotation1); // TEST RELIES ON THIS METHOD WORKING!!! + + Vector3 position1(5.0f, -6.0f, 7.0f); + + Matrix m1(false); + m1.SetTransformComponents( Vector3::ONE, rotation1, position1 ); + + Matrix m2(false); + m2.SetInverseTransformComponents( rotationMatrix.GetXAxis(), + rotationMatrix.GetYAxis(), + rotationMatrix.GetZAxis(), + position1 ); + + Matrix result; + Matrix::Multiply(result, m1, m2); + + DALI_TEST_EQUALS(result, Matrix::IDENTITY, 0.001, TEST_LOCATION); + } + } + } + } + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Matrix3.cpp b/automated-tests/src/dali/utc-Dali-Matrix3.cpp new file mode 100644 index 0000000..a642d1f --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-Matrix3.cpp @@ -0,0 +1,383 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + + +using namespace Dali; + +void utc_dali_matrix3_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_matrix3_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ + +Matrix3 m1( + -18.6f, 1.88e-09f, -6.85e-09f, + 0.0f,13.2f, 13.2f, + -1.36e-08f,13.2f, -13.2f); + +Matrix3 m2( + -18.6f,6.91e-06f, 6.76e-06f, + 8.04e-09f,13.2f, 13.2f, + 3.01e-06f,13.2f, -13.2f); + +Matrix3 m3( + 6.24f,-12.4f, -12.4f, + -17.6f,-4.46f, -4.37f, + -0.0641f,13.2f, -13.2f); + +Matrix3 m4( + -16.3f,6.42f, 6.38f, + 9.05f,11.6f, 11.4f, + -0.0371f,13.1f, -13.3f); + +Matrix3 m5( + -2.43f,13.2f, 12.9f, + 18.5f,1.92f, 1.51f, + -0.257f,13.0f, -13.4f); + +Matrix3 m6( + -2.43f, -13.2f, -200.9f, + 18.5f, 1.92f, 1.51f, + 0.257f, 13.0f, 13.4f); + + +Matrix3 i1( + -0.05, -0.00, 0.00, + -0.00, 0.04, 0.04, + 0.00, 0.04, -0.04); + +Matrix3 i2( + -0.05, 0.00, -0.00, + 0.00, 0.04, 0.04, + 0.00, 0.04, -0.04); + +Matrix3 i3( + 0.02, -0.05, -0.00, + -0.04, -0.01, 0.04, + -0.04, -0.01, -0.04); + +Matrix3 i4( + -0.05, 0.03, -0.00, + 0.02, 0.03, 0.04, + 0.02, 0.03, -0.04); + +Matrix3 i5( + -0.01, 0.05, -0.00, + 0.04, 0.01, 0.04, + 0.04, 0.00, -0.04); + + + +Matrix3 t1( + -18.6f, 0.0f, -1.36e-08f, + 1.88e-09f,13.2f, 13.2f, + -6.85e-09f,13.2f, -13.2f); + +Matrix3 t2( + -18.6f,8.04e-09f, 3.01e-06f, + 6.91e-06f,13.2f, 13.2f, + 6.76e-06f,13.2f, -13.2f); + +Matrix3 t3( + 6.24f,-17.6f, -0.0641f, + -12.4f,-4.46f, 13.2f, + -12.4f, -4.37f, -13.2f); + +Matrix3 t4( + -16.3f,9.05f, -0.0371f, + 6.42f, 11.6f, 13.1f, + 6.38f,11.4f, -13.3f); + +Matrix3 t5( + -2.43f,18.5f, -0.257f, + 13.2f, 1.92f, 13.0f, + 12.9f, 1.51f, -13.4f); + + + +Matrix3* matrices[5] = { &m1, &m2, &m3, &m4, &m5 }; +Matrix3* inverseMatrices[5] = { &i1, &i2, &i3, &i4, &i5 }; +Matrix3* transposeMatrices[5] = { &t1, &t2, &t3, &t4, &t5 }; + +} // anonymous namespace + +int UtcDaliMatrix3FromMatrix(void) +{ + float els0[] = { 0.0f, 1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, 7.0f, + 8.0f, 9.0f, 10.0f, 11.0f, + 12.0f, 13.0f, 14.0f, 15.0f}; + Matrix m0(els0); + Matrix3 m1(0.0f, 1.0f, 2.0f, + 4.0f, 5.0f, 6.0f, + 8.0f, 9.0f, 10.0f); + + Matrix3 m2(m0); + + DALI_TEST_EQUALS(m1, m2, 0.001, TEST_LOCATION); + END_TEST; +} + +int UtcDaliMatrix3OperatorAssign01(void) +{ + float els0[] = { 0.0f, 1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f, 7.0f, + 8.0f, 9.0f, 10.0f, 11.0f, + 12.0f, 13.0f, 14.0f, 15.0f}; + Matrix m0(els0); + + Matrix3 m1(0.0f, 1.0f, 2.0f, + 4.0f, 5.0f, 6.0f, + 8.0f, 9.0f, 10.0f); + + Matrix3 m2; + m2 = m0; + m2 = m2; // Test branch + + DALI_TEST_EQUALS(m1, m2, 0.001, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliMatrix3OperatorAssign02(void) +{ + Matrix3 m0(0.0f, 1.0f, 2.0f, + 4.0f, 5.0f, 6.0f, + 8.0f, 9.0f, 10.0f); + + Matrix3 m1(0.0f, 1.0f, 2.0f, + 4.0f, 5.0f, 6.0f, + 8.0f, 9.0f, 10.0f); + + Matrix3 m2; + m2 = m0; + + DALI_TEST_EQUALS(m1, m2, 0.001, TEST_LOCATION); + END_TEST; +} + + + +// AsFloat +int UtcDaliMatrix3AsFloat(void) +{ + float values[] = {0.0f, 1.0f, 2.0f, + 4.0f, 5.0f, 6.0f, + 8.0f, 9.0f, 10.0f }; + + Matrix3 m1(values[0], values[1], values[2], values[3],values[4], values[5], values[6], values[7],values[8]); + + for (int i=0;i<9;++i) + { + DALI_TEST_EQUALS(m1.AsFloat()[i], values[i], TEST_LOCATION); + } + END_TEST; +} + + +// Invert works +int UtcDaliMatrix3Invert(void) +{ + // We're going to invert a whole load of different matrices to make sure we don't + // fail on particular orientations. + for (int i=0;i<5;++i) + { + Matrix3 m = *matrices[i]; + Matrix3 inverseResult1 = *inverseMatrices[i]; + + // Convert to Mat4, perform inverse, and convert back to Mat3 + float* mf = m.AsFloat(); + float els[] = { mf[0], mf[1], mf[2], 0.0f, + mf[3], mf[4], mf[5], 0.0f, + mf[6], mf[7], mf[8], 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f }; + Matrix mat4(els); + mat4.Invert(); + Matrix3 inverseResult2 = mat4; + + Matrix3 mInv = m; + mInv.Invert(); + + DALI_TEST_EQUALS(mInv, inverseResult1, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(mInv, inverseResult2, 0.01f, TEST_LOCATION); + + Matrix3 m2 = mInv; + m2.Invert(); // double invert - should be back to m + + DALI_TEST_EQUALS(m, m2, 0.01f, TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliMatrix3Transpose(void) +{ + for (int i=0;i<5;++i) + { + Matrix3 m0 = *matrices[i]; + Matrix3 trans = *transposeMatrices[i]; + + Matrix3 m1 = m0; + m1.Transpose(); + + DALI_TEST_EQUALS(m1, trans, 0.001f, TEST_LOCATION); + + Matrix3 m2 = m1; + m2.Transpose(); + + DALI_TEST_EQUALS(m0, m2, 0.001f, TEST_LOCATION); + } + END_TEST; +} + +// SetIdentity +int UtcDaliMatrix3SetIdentity(void) +{ + Matrix3 m( 0.0f, 1.0f, 2.0f, + 4.0f, 5.0f, 6.0f, + 8.0f, 9.0f, 10.0f); + m.SetIdentity(); + + DALI_TEST_EQUALS(m, Matrix3::IDENTITY, 0.001f, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliMatrix3Scale(void) +{ + Matrix3 m1( 0.0f, 1.0f, 2.0f, + 4.0f, 5.0f, 6.0f, + 8.0f, 9.0f, 10.0f); + + Matrix3 m2( 0.0f, 3.0f, 6.0f, + 12.0f, 15.0f, 18.0f, + 24.0f, 27.0f, 30.0f); + + m1.Scale(3.0f); + + DALI_TEST_EQUALS(m1, m2, 0.001, TEST_LOCATION); + END_TEST; +} + +int UtcDaliMatrix3Magnitude(void) +{ + Matrix3 m1( 0.0f, 1.0f, -2.0f, + 3.0f, -4.0f, 5.0f, + -6.0f, 7.0f, 8.0f); + + DALI_TEST_EQUALS(Matrix3::IDENTITY.Magnitude(), 1.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(m1.Magnitude(), 12.0f, 0.001f, TEST_LOCATION); + END_TEST; +} + + + +int UtcDaliMatrix3ScaleInverseTranspose(void) +{ + Matrix3* matrices[6] = { &m1, &m2, &m3, &m4, &m5, &m6 }; + + + for (int i=0;i<6;++i) + { + Matrix3 m0 = *matrices[i]; + + Matrix3 m1 = m0; + m1.Invert(); + m1.Transpose(); + m1.Scale(3.0f/(m1.Magnitude())); + + Matrix3 m2 = m0; + m2.ScaledInverseTranspose(); + + DALI_TEST_EQUALS(m1, m2, 0.001f, TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliMatrix3OStreamOperator(void) +{ + std::ostringstream oss; + + Matrix3 matrix( 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f ); + + oss << matrix; + + std::string expectedOutput = "[ [1, 2, 3], [4, 5, 6], [7, 8, 9] ]"; + + DALI_TEST_EQUALS( oss.str(), expectedOutput, TEST_LOCATION); + END_TEST; +} + +int UtcDaliMatrix3Multiply(void) +{ + Matrix3 m1( 0.0f, 3.0f, 6.0f, + 12.0f, 15.0f, 18.0f, + 24.0f, 27.0f, 30.0f); + + Matrix3 m2( 0.0f, 1.0f, 0.0f, + -1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f); + + Matrix3 m3( -3.0f, 0.0f, 6.0f, + -15.0f, 12.0f, 18.0f, + -27.0f, 24.0f, 30.0f); + + Matrix3 result; + Matrix3::Multiply(result, m1, m2); + + DALI_TEST_EQUALS(m3, result, 0.01f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliMatrix3EqualityOperator(void) +{ + Matrix3 m1( 0.0f, 3.0f, 6.0f, + 12.0f, 15.0f, 18.0f, + 24.0f, 27.0f, 30.0f); + + Matrix3 m2( 0.0f, 3.0f, 6.0f, + 12.0f, 15.0f, 18.0f, + 24.0f, 27.0f, 30.0f); + + DALI_TEST_CHECK(m1 == m2); + END_TEST; +} + +int UtcDaliMatrix3InequalityOperator(void) +{ + Matrix3 m1( 1.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 1.0f); + + Matrix3 m2( 0.0f, 3.0f, 6.0f, + 12.0f, 15.0f, 18.0f, + 24.0f, 27.0f, 30.0f); + + DALI_TEST_CHECK(m1 != m2); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-MeshActor.cpp b/automated-tests/src/dali/utc-Dali-MeshActor.cpp new file mode 100644 index 0000000..50e7acd --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-MeshActor.cpp @@ -0,0 +1,95 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +using namespace Dali; + + +void mesh_actor_test_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void mesh_actor_test_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ + +static AnimatableMesh NewMesh() +{ + AnimatableMesh::Faces faces; + faces.push_back(0); + faces.push_back(1); + faces.push_back(2); + + Material customMaterial = Material::New("CustomMaterial"); + customMaterial.SetOpacity(.76f); + customMaterial.SetDiffuseColor(Vector4(0.8f, 0.0f, 0.4f, 1.0f)); + customMaterial.SetAmbientColor(Vector4(0.2f, 1.0f, 0.6f, 1.0f)); + customMaterial.SetSpecularColor(Vector4(0.5f, 0.6f, 0.7f, 1.0f)); + + AnimatableMesh mesh = AnimatableMesh::New( 10u, faces, customMaterial ); + return mesh; +} +} // anonymous namespace + +int UtcDaliMeshActorConstructorVoid(void) +{ + TestApplication application; + tet_infoline("Testing Dali::MeshActor::MeshActor()"); + + MeshActor actor; + DALI_TEST_CHECK(!actor); + END_TEST; +} + +int UtcDaliMeshActorNew01(void) +{ + TestApplication application; + tet_infoline("Testing Dali::MeshActor::New()"); + + AnimatableMesh mesh = NewMesh(); + MeshActor actor = MeshActor::New(mesh); + application.SendNotification(); + application.Render(); + application.Render(); + application.SendNotification(); + + DALI_TEST_CHECK(actor); + END_TEST; +} + +int UtcDaliMeshActorIndices(void) +{ + TestApplication application; + Actor basicActor = Actor::New(); + AnimatableMesh mesh = NewMesh(); + MeshActor meshActor = MeshActor::New(mesh); + + Property::IndexContainer indices; + meshActor.GetPropertyIndices( indices ); + DALI_TEST_CHECK( indices.size() == basicActor.GetPropertyCount() ); // Mesh Actor does not have any properties + DALI_TEST_EQUALS( indices.size(), meshActor.GetPropertyCount(), TEST_LOCATION ); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-PanGesture.cpp b/automated-tests/src/dali/utc-Dali-PanGesture.cpp new file mode 100644 index 0000000..04fa638 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-PanGesture.cpp @@ -0,0 +1,130 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +using namespace Dali; + +void utc_dali_pan_gesture_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_pan_gesture_cleanup(void) +{ + test_return_value = TET_PASS; +} + + + +int UtcDaliPanGestureConstructor(void) +{ + TestApplication application; // Reset all test adapter return codes + + PanGesture gesture(Gesture::Started); + DALI_TEST_EQUALS(Gesture::Started, gesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(1u, gesture.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pan, gesture.type, TEST_LOCATION); + + PanGesture gesture2(Gesture::Continuing); + DALI_TEST_EQUALS(Gesture::Continuing, gesture2.state, TEST_LOCATION); + DALI_TEST_EQUALS(1u, gesture2.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pan, gesture2.type, TEST_LOCATION); + + PanGesture gesture3(Gesture::Finished); + DALI_TEST_EQUALS(Gesture::Finished, gesture3.state, TEST_LOCATION); + DALI_TEST_EQUALS(1u, gesture3.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pan, gesture3.type, TEST_LOCATION); + + // Test copy constructor + gesture3.numberOfTouches = 3u; + + PanGesture pan(gesture3); + DALI_TEST_EQUALS(Gesture::Finished, pan.state, TEST_LOCATION); + DALI_TEST_EQUALS(3u, pan.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pan, pan.type, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureAssignment(void) +{ + // Test Assignment operator + PanGesture gesture(Gesture::Started); + DALI_TEST_EQUALS(Gesture::Started, gesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(1u, gesture.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pan, gesture.type, TEST_LOCATION); + + PanGesture gesture2(Gesture::Continuing); + DALI_TEST_EQUALS(Gesture::Continuing, gesture2.state, TEST_LOCATION); + DALI_TEST_EQUALS(1u, gesture2.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pan, gesture2.type, TEST_LOCATION); + + gesture2.numberOfTouches = 3u; + + gesture = gesture2; + DALI_TEST_EQUALS(Gesture::Continuing, gesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(3u, gesture.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pan, gesture.type, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureGetSpeed(void) +{ + PanGesture gesture(Gesture::Started); + DALI_TEST_EQUALS(0.0f, gesture.GetSpeed(), TEST_LOCATION); + + gesture.velocity = Vector2(3.0f, -4.0f); + + DALI_TEST_EQUALS(5.0f, gesture.GetSpeed(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureGetDistance(void) +{ + PanGesture gesture(Gesture::Started); + DALI_TEST_EQUALS(0.0f, gesture.GetDistance(), TEST_LOCATION); + + gesture.displacement = Vector2(-30.0f, -40.0f); + + DALI_TEST_EQUALS(50.0f, gesture.GetDistance(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureGetScreenSpeed(void) +{ + PanGesture gesture(Gesture::Started); + DALI_TEST_EQUALS(0.0f, gesture.GetScreenSpeed(), TEST_LOCATION); + + gesture.screenVelocity = Vector2(3.0f, -4.0f); + + DALI_TEST_EQUALS(5.0f, gesture.GetScreenSpeed(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureGetScreenDistance(void) +{ + PanGesture gesture(Gesture::Started); + DALI_TEST_EQUALS(0.0f, gesture.GetScreenDistance(), TEST_LOCATION); + + gesture.screenDisplacement = Vector2(-30.0f, -40.0f); + + DALI_TEST_EQUALS(50.0f, gesture.GetScreenDistance(), TEST_LOCATION); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp new file mode 100644 index 0000000..e91e71d --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp @@ -0,0 +1,1999 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 +#include +#include + +using namespace Dali; + +void utc_dali_pan_gesture_detector_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_pan_gesture_detector_cleanup(void) +{ + test_return_value = TET_PASS; +} + +/////////////////////////////////////////////////////////////////////////////// +namespace +{ +typedef Dali::PanGestureDetector::AngleContainer::size_type AngleSizeType; + + +// Stores data that is populated in the callback and will be read by the TET cases +struct SignalData +{ + SignalData() + : functorCalled(false), + voidFunctorCalled(false), + receivedGesture(Gesture::Clear) + {} + + void Reset() + { + functorCalled = false; + voidFunctorCalled = false; + + receivedGesture.state = Gesture::Clear; + receivedGesture.velocity = Vector2(0.0f, 0.0f); + receivedGesture.displacement = Vector2(0.0f, 0.0f); + receivedGesture.position = Vector2(0.0f, 0.0f); + receivedGesture.screenPosition = Vector2(0.0f, 0.0f); + receivedGesture.numberOfTouches = 0; + + pannedActor = NULL; + } + + bool functorCalled; + bool voidFunctorCalled; + PanGesture receivedGesture; + Actor pannedActor; +}; + +// Functor that sets the data when called +struct GestureReceivedFunctor +{ + GestureReceivedFunctor(SignalData& data) : signalData(data) { } + + void operator()(Actor actor, PanGesture pan) + { + signalData.functorCalled = true; + signalData.receivedGesture = pan; + signalData.pannedActor = actor; + } + + void operator()() + { + signalData.voidFunctorCalled = true; + } + + SignalData& signalData; +}; + +// Functor that removes the gestured actor from stage +struct UnstageActorFunctor : public GestureReceivedFunctor +{ + UnstageActorFunctor( SignalData& data, Gesture::State& stateToUnstage ) + : GestureReceivedFunctor( data ), + stateToUnstage( stateToUnstage ) + { + } + + void operator()( Actor actor, PanGesture pan ) + { + GestureReceivedFunctor::operator()( actor, pan ); + + if ( pan.state == stateToUnstage ) + { + Stage::GetCurrent().Remove( actor ); + } + } + + Gesture::State& stateToUnstage; +}; + +// Functor for receiving a touch event +struct TouchEventFunctor +{ + bool operator()(Actor actor, const TouchEvent& touch) + { + return false; + } +}; + +// Data for constraints +struct ConstraintData +{ + ConstraintData() + : called(false) + { + } + + Vector2 screenPosition; + Vector2 screenDisplacement; + Vector2 localPosition; + Vector2 localDisplacement; + bool called; + + void Reset() + { + screenPosition = screenDisplacement = localPosition = localDisplacement = Vector2::ZERO; + called = false; + } +}; + +// Constraint used with panning properties +struct PanConstraint +{ + PanConstraint( ConstraintData& data ) : constraintData(data) { } + + Vector3 operator()(const Vector3& current, + const PropertyInput& screenPositionProperty, + const PropertyInput& screenDisplacementProperty, + const PropertyInput& localPositionProperty, + const PropertyInput& localDisplacementProperty) + { + constraintData.screenPosition = screenPositionProperty.GetVector2(); + constraintData.screenDisplacement = screenDisplacementProperty.GetVector2(); + constraintData.localPosition = localPositionProperty.GetVector2(); + constraintData.localDisplacement = localDisplacementProperty.GetVector2(); + constraintData.called = true; + return Vector3::ZERO; + } + + ConstraintData& constraintData; +}; + +// Generate a PanGestureEvent to send to Core +Integration::PanGestureEvent GeneratePan( + Gesture::State state, + Vector2 previousPosition, + Vector2 currentPosition, + unsigned long timeDelta, + unsigned int numberOfTouches = 1, + unsigned int time = 1u) +{ + Integration::PanGestureEvent pan(state); + + pan.previousPosition = previousPosition; + pan.currentPosition = currentPosition; + pan.timeDelta = timeDelta; + pan.numberOfTouches = numberOfTouches; + pan.time = time; + + return pan; +} + +// Generate a PanGesture +PanGesture GeneratePan( unsigned int time, + Gesture::State state, + Vector2 screenPosition, + Vector2 localPosition, + Vector2 screenDisplacement = Vector2::ONE, + Vector2 localDisplacement = Vector2::ONE, + Vector2 velocity = Vector2::ONE, + unsigned int numberOfTouches = 1 ) +{ + PanGesture pan( state ); + + pan.time = time; + + pan.screenPosition = screenPosition; + pan.position = localPosition; + + pan.screenDisplacement = screenDisplacement; + pan.displacement = localDisplacement; + + pan.screenVelocity = pan.velocity = velocity; + pan.numberOfTouches = numberOfTouches; + + return pan; +} + +} // anon namespace + +/////////////////////////////////////////////////////////////////////////////// + +// Positive test case for a method +int UtcDaliPanGestureDetectorConstructor(void) +{ + TestApplication application; + + PanGestureDetector detector; + DALI_TEST_CHECK(!detector); + END_TEST; +} + + +// Negative test case for a method +int UtcDaliPanGestureDetectorNew(void) +{ + TestApplication application; + + PanGestureDetector detector = PanGestureDetector::New(); + + DALI_TEST_CHECK(detector); + + DALI_TEST_EQUALS(1u, detector.GetMinimumTouchesRequired(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, detector.GetMaximumTouchesRequired(), TEST_LOCATION); + + // Attach an actor and emit a touch event on the actor to ensure complete line coverage + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + detector.Attach(actor); + + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + Integration::TouchEvent touchEvent(1); + TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f); + touchEvent.AddPoint(point); + application.ProcessEvent(touchEvent); + END_TEST; +} + +int UtcDaliPanGestureDetectorDownCast(void) +{ + TestApplication application; + tet_infoline("Testing Dali::GestureDetector::DownCast()"); + + PanGestureDetector detector = PanGestureDetector::New(); + + BaseHandle object(detector); + + PanGestureDetector detector2 = PanGestureDetector::DownCast(object); + DALI_TEST_CHECK(detector2); + + PanGestureDetector detector3 = DownCast< PanGestureDetector >(object); + DALI_TEST_CHECK(detector3); + + BaseHandle unInitializedObject; + PanGestureDetector detector4 = PanGestureDetector::DownCast(unInitializedObject); + DALI_TEST_CHECK(!detector4); + + PanGestureDetector detector5 = DownCast< PanGestureDetector >(unInitializedObject); + DALI_TEST_CHECK(!detector5); + + GestureDetector detector6 = PanGestureDetector::New(); + PanGestureDetector detector7 = PanGestureDetector::DownCast(detector6); + DALI_TEST_CHECK(detector7); + END_TEST; +} + +int UtcDaliPanGestureSetMinimumTouchesRequired(void) +{ + TestApplication application; + + PanGestureDetector detector = PanGestureDetector::New(); + + unsigned int min = 2; + + DALI_TEST_CHECK(min != detector.GetMinimumTouchesRequired()); + + detector.SetMinimumTouchesRequired(min); + + DALI_TEST_EQUALS(min, detector.GetMinimumTouchesRequired(), TEST_LOCATION); + + // Attach an actor and change the minimum touches + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + TestGestureManager& gestureManager = application.GetGestureManager(); + gestureManager.Initialize(); + + detector.SetMinimumTouchesRequired(3); + + // Gesture detection should have been updated only + DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION); + + // Reset values + gestureManager.Initialize(); + + // Create a second gesture detector that requires even less minimum touches + PanGestureDetector secondDetector = PanGestureDetector::New(); + secondDetector.Attach(actor); + + // Gesture detection should have been updated only + DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureSetMaximumTouchesRequired(void) +{ + TestApplication application; + + PanGestureDetector detector = PanGestureDetector::New(); + + unsigned int max = 3; + + DALI_TEST_CHECK(max != detector.GetMaximumTouchesRequired()); + + detector.SetMaximumTouchesRequired(max); + + DALI_TEST_EQUALS(max, detector.GetMaximumTouchesRequired(), TEST_LOCATION); + + // Attach an actor and change the maximum touches + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + TestGestureManager& gestureManager = application.GetGestureManager(); + gestureManager.Initialize(); + + detector.SetMaximumTouchesRequired(4); + + // Gesture detection should have been updated only + DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION); + + // Reset values + gestureManager.Initialize(); + + // Create a second gesture detector that requires even less maximum touches + PanGestureDetector secondDetector = PanGestureDetector::New(); + secondDetector.Attach(actor); + + // Gesture detection should NOT have been updated + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureGetMinimumTouchesRequired(void) +{ + TestApplication application; + + PanGestureDetector detector = PanGestureDetector::New(); + DALI_TEST_EQUALS(1u, detector.GetMinimumTouchesRequired(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureGetMaximumTouchesRequired(void) +{ + TestApplication application; + + PanGestureDetector detector = PanGestureDetector::New(); + DALI_TEST_EQUALS(1u, detector.GetMaximumTouchesRequired(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureSignalReceptionNegative(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PanGestureDetector detector = PanGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Do a pan outside actor's area + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(110.0f, 110.0f), Vector2(112.0f, 112.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(110.0f, 110.0f), Vector2(112.0f, 112.0f), 10)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Continue pan into actor's area - we should still not receive the signal + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(112.0f, 112.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Stop panning - we should still not receive the signal + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 20.0f), Vector2(12.0f, 12.0f), 10)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureSignalReceptionDownMotionLeave(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PanGestureDetector detector = PanGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Start pan within the actor's area + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(10.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(1.0f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(10.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + + // Continue the pan within the actor's area - we should still receive the signal + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(0.0f, -10.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(0.0f, -1.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(10.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + + // Pan Gesture leaves actor's area - we should still receive the signal + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 10.0f), Vector2(320.0f, 10.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(300.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(30.0f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(300.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(30.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + + // Gesture ends - we would receive a finished state + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(320.0f, 10.0f), Vector2(310.0f, 10.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(-10.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(-1.0f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(10.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureSignalReceptionDownMotionUp(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PanGestureDetector detector = PanGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Start pan within the actor's area + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(10.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(1.0f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(10.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + + // Continue the pan within the actor's area - we should still receive the signal + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(0.0f, -10.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(0.0f, -1.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(10.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + + // Gesture ends within actor's area - we would receive a finished state + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(-10.0f, 0.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(-1.0f, 0.0f), data.receivedGesture.velocity, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(10.0f, data.receivedGesture.GetDistance(), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(1.0f, data.receivedGesture.GetSpeed(), 0.01f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureSignalReceptionCancelled(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PanGestureDetector detector = PanGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Start pan within the actor's area + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); + + // Continue the pan within the actor's area - we should still receive the signal + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); + + // The gesture is cancelled + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Cancelled, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Cancelled, data.receivedGesture.state, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureSignalReceptionDetach(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PanGestureDetector detector = PanGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Start pan within the actor's area + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + + // Continue the pan within the actor's area - we should still receive the signal + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + + // Gesture ends within actor's area + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + + // Detach actor + detector.DetachAll(); + + // Ensure we are no longer signalled + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureSignalReceptionDetachWhilePanning(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PanGestureDetector detector = PanGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Start pan within the actor's area + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + + // Continue the pan within the actor's area - we should still receive the signal + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + + // Detach actor during the pan, we should not receive the next event + detector.DetachAll(); + + // Gesture ends within actor's area + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureSignalReceptionActorDestroyedWhilePanning(void) +{ + TestApplication application; + + SignalData data; + GestureReceivedFunctor functor(data); + + PanGestureDetector detector = PanGestureDetector::New(); + detector.DetectedSignal().Connect(&application, functor); + + // Attach a temporary actor to stop detector being removed from PanGestureProcessor when main actor + // is destroyed. + Actor tempActor = Actor::New(); + tempActor.SetSize(100.0f, 100.0f); + tempActor.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT); + Stage::GetCurrent().Add(tempActor); + detector.Attach(tempActor); + + // Actor lifetime is scoped + { + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + detector.Attach(actor); + + // Start pan within the actor's area + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + + // Continue the pan within the actor's area - we should still receive the signal + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + + // Remove the actor from stage and reset the data + Stage::GetCurrent().Remove(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + } + + // Actor should now have been destroyed + + // Gesture ends within the area where the actor used to be + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureSignalReceptionRotatedActor(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetRotation(Dali::Degree(90.0f), Vector3::ZAXIS); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PanGestureDetector detector = PanGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Do an entire pan, only check finished value + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10)); + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(22.0f, 12.0f), Vector2(27.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(8.0f, -5.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative + + // Rotate actor again and render a couple of times + actor.SetRotation(Dali::Degree(180.0f), Vector3::ZAXIS); + application.SendNotification(); + application.Render(); + + // Do an entire pan, only check finished value + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10)); + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(22.0f, 12.0f), Vector2(27.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(-5.0f, -8.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative + + // Rotate actor again and render a couple of times + actor.SetRotation(Dali::Degree(270.0f), Vector3::ZAXIS); + application.SendNotification(); + application.Render(); + + // Do an entire pan, only check finished value + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10)); + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(22.0f, 12.0f), Vector2(27.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(-8.0f, 5.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative + END_TEST; +} + +int UtcDaliPanGestureSignalReceptionChildHit(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + parent.SetSize(100.0f, 100.0f); + parent.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(parent); + + // Set child to completely cover parent. + // Change rotation of child to be different from parent so that we can check if our local coordinate + // conversion of the parent actor is correct. + Actor child = Actor::New(); + child.SetSize(100.0f, 100.0f); + child.SetAnchorPoint(AnchorPoint::CENTER); + child.SetParentOrigin(ParentOrigin::CENTER); + child.SetRotation(Dali::Degree(90.0f), Vector3::ZAXIS); + parent.Add(child); + + TouchEventFunctor touchFunctor; + child.TouchedSignal().Connect(&application, touchFunctor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PanGestureDetector detector = PanGestureDetector::New(); + detector.Attach(parent); + detector.DetectedSignal().Connect(&application, functor); + + // Do an entire pan, only check finished value - hits child area but parent should still receive it + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10)); + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(22.0f, 12.0f), Vector2(27.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, parent == data.pannedActor, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(5.0f, 8.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative + + // Attach child and generate same touch points to yield a different displacement + // (Also proves that you can detach and then re-attach another actor) + detector.Attach(child); + detector.Detach(parent); + + // Do an entire pan, only check finished value + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(11.0f, 12.0f), Vector2(22.0f, 12.0f), 10)); + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(22.0f, 12.0f), Vector2(27.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, child == data.pannedActor, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(8.0f, -5.0f), data.receivedGesture.displacement, 0.01f, TEST_LOCATION); // Actor relative + END_TEST; +} + +int UtcDaliPanGestureSignalReceptionAttachDetachMany(void) +{ + TestApplication application; + + Actor first = Actor::New(); + first.SetSize(100.0f, 100.0f); + first.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(first); + + Actor second = Actor::New(); + second.SetSize(100.0f, 100.0f); + second.SetX(100.0f); + second.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(second); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PanGestureDetector detector = PanGestureDetector::New(); + detector.Attach(first); + detector.Attach(second); + detector.DetectedSignal().Connect(&application, functor); + + // Start pan within second actor's area + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(110.0f, 20.0f), Vector2(120.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(110.0f, 20.0f), Vector2(120.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, second == data.pannedActor, TEST_LOCATION); + + // Pan moves into first actor's area - second actor should receive the pan + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(120.0f, 20.0f), Vector2(20.0f, 10.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, second == data.pannedActor, TEST_LOCATION); + + // Detach the second actor during the pan, we should not receive the next event + detector.Detach(second); + + // Gesture ends within actor's area + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureSignalReceptionActorBecomesUntouchable(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PanGestureDetector detector = PanGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Start pan in actor's area + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + + // Pan continues within actor's area + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + + // Actor become invisible - actor should not receive the next pan + actor.SetVisible(false); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Gesture ends within actor's area + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 10.0f), Vector2(10.0f, 10.0f), 10)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureSignalReceptionMultipleGestureDetectors(void) +{ + TestApplication application; + Dali::TestGestureManager& gestureManager = application.GetGestureManager(); + + Actor first = Actor::New(); + first.SetSize(100.0f, 100.0f); + first.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(first); + + Actor second = Actor::New(); + second.SetSize(100.0f, 100.0f); + second.SetAnchorPoint(AnchorPoint::TOP_LEFT); + first.Add(second); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PanGestureDetector firstDetector = PanGestureDetector::New(); + firstDetector.Attach(first); + firstDetector.DetectedSignal().Connect(&application, functor); + + // secondDetector is scoped + { + // Reset gestureManager statistics + gestureManager.Initialize(); + + PanGestureDetector secondDetector = PanGestureDetector::New(); + secondDetector.SetMinimumTouchesRequired(2); + secondDetector.SetMaximumTouchesRequired(2); + secondDetector.Attach(second); + secondDetector.DetectedSignal().Connect(&application, functor); + + DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION); + + // Start pan within second actor's area + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10, 2)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10, 2)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, second == data.pannedActor, TEST_LOCATION); + + // Two touch pan changes to single touch - we should receive a finished state + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(true, second == data.pannedActor, TEST_LOCATION); + + // Pan continues as single touch gesture - we should not receive any gesture + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 10.0f), Vector2(30.0f, 10.0f), 10)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Pan ends - still no signal + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(30.0f, 10.0f), Vector2(30.0f, 20.0f), 10)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Single touch pan starts - first actor should be panned + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, first == data.pannedActor, TEST_LOCATION); + + // Pan changes to double-touch - we should receive a finished state + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10, 2)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(true, first == data.pannedActor, TEST_LOCATION); + + // Pan continues as double touch gesture - we should not receive any gesture + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 10.0f), Vector2(30.0f, 10.0f), 10)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Pan ends - still no signal + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(30.0f, 10.0f), Vector2(30.0f, 20.0f), 10)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Reset gesture manager statistics + gestureManager.Initialize(); + } + + // secondDetector has now been deleted. Gesture detection should have been updated only + DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureSignalReceptionMultipleDetectorsOnActor(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + Actor actor2 = Actor::New(); + actor2.SetSize(100.0f, 100.0f); + actor2.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT); + Stage::GetCurrent().Add(actor2); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Attach actor to one detector + SignalData firstData; + GestureReceivedFunctor firstFunctor(firstData); + PanGestureDetector firstDetector = PanGestureDetector::New(); + firstDetector.Attach(actor); + firstDetector.DetectedSignal().Connect(&application, firstFunctor); + + // Attach actor to another detector + SignalData secondData; + GestureReceivedFunctor secondFunctor(secondData); + PanGestureDetector secondDetector = PanGestureDetector::New(); + secondDetector.Attach(actor); + secondDetector.DetectedSignal().Connect(&application, secondFunctor); + + // Add second actor to second detector, when we remove the actor, this will make sure that this + // gesture detector is not removed from the GestureDetectorProcessor. In this scenario, the + // functor should still not be called (which is what we're also testing). + secondDetector.Attach(actor2); + + // Pan in actor's area - both detector's functors should be called + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION); + + // Pan continues in actor's area - both detector's functors should be called + firstData.Reset(); + secondData.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(10.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION); + + // Detach actor from firstDetector and emit pan on actor, only secondDetector's functor should be called. + firstDetector.Detach(actor); + firstData.Reset(); + secondData.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(20.0f, 20.0f), Vector2(10.0f, 20.0f), 10)); + DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION); + + // New pan on actor, only secondDetector has actor attached + firstData.Reset(); + secondData.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION); + + // Detach actor from secondDetector + secondDetector.Detach(actor); + firstData.Reset(); + secondData.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(20.0f, 20.0f), Vector2(10.0f, 20.0f), 10)); + DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(false, secondData.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureSignalReceptionMultipleStarted(void) +{ + // Should handle two started events gracefully. + + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + SignalData data; + GestureReceivedFunctor functor(data); + + PanGestureDetector detector = PanGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Start pan in actor's area + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + + // Send another start in actor's area + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + + // Add a child actor to overlap actor and send another start in actor's area + Actor child = Actor::New(); + child.SetSize(100.0f, 100.0f); + child.SetAnchorPoint(AnchorPoint::CENTER); + child.SetParentOrigin(ParentOrigin::CENTER); + actor.Add(child); + + TouchEventFunctor touchFunctor; + child.TouchedSignal().Connect(&application, touchFunctor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Send another possible and start in actor's area + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + + // Send another start in actor's area + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureSignalReceptionEnsureCorrectSignalling(void) +{ + TestApplication application; + + Actor actor1 = Actor::New(); + actor1.SetSize(100.0f, 100.0f); + actor1.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor1); + SignalData data1; + GestureReceivedFunctor functor1(data1); + PanGestureDetector detector1 = PanGestureDetector::New(); + detector1.Attach(actor1); + detector1.DetectedSignal().Connect(&application, functor1); + + Actor actor2 = Actor::New(); + actor2.SetSize(100.0f, 100.0f); + actor2.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT); + actor2.SetParentOrigin(ParentOrigin::BOTTOM_RIGHT); + Stage::GetCurrent().Add(actor2); + SignalData data2; + GestureReceivedFunctor functor2(data2); + PanGestureDetector detector2 = PanGestureDetector::New(); + detector2.Attach(actor2); + detector2.DetectedSignal().Connect(&application, functor2); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Start pan in actor1's area, only data1 should be set + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data1.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(false, data2.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureSignalReceptionDifferentPossible(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Attach actor to detector + SignalData data; + GestureReceivedFunctor functor( data ); + PanGestureDetector detector = PanGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + // Gesture possible in actor's area. + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Move actor somewhere else + actor.SetPosition( 100.0f, 100.0f ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Emit Started event, we should not receive the long press. + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // LongPress possible in empty area. + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Move actor in to the long press position. + actor.SetPosition( 0.0f, 0.0f ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Emit Started event, we should not receive the long press. + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Normal long press in actor's area for completeness. + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureEmitIncorrectState(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Attach actor to detector + SignalData data; + GestureReceivedFunctor functor( data ); + PanGestureDetector detector = PanGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + // Try a Clear state + try + { + application.ProcessEvent(GeneratePan(Gesture::Clear, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + tet_result(TET_FAIL); + } + catch ( Dali::DaliException& e ) + { + DALI_TEST_ASSERT( e, "false", TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliPanGestureActorUnstaged(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // State to remove actor in. + Gesture::State stateToUnstage( Gesture::Started ); + + // Attach actor to detector + SignalData data; + UnstageActorFunctor functor( data, stateToUnstage ); + PanGestureDetector detector = PanGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + // Emit signals + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + data.Reset(); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Re-add actor to stage + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Change state to Gesture::Continuing to remove + stateToUnstage = Gesture::Continuing; + + // Emit signals + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + data.Reset(); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Re-add actor to stage + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Change state to Gesture::Finished to remove + stateToUnstage = Gesture::Finished; + + // Emit signals + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + tet_result( TET_PASS ); // If we get here then we have handled actor stage removal gracefully. + END_TEST; +} + +int UtcDaliPanGestureActorStagedAndDestroyed(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Create and add a second actor so that GestureDetector destruction does not come into play. + Actor dummyActor( Actor::New() ); + dummyActor.SetSize( 100.0f, 100.0f ); + dummyActor.SetPosition( 100.0f, 100.0f ); + dummyActor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(dummyActor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // State to remove actor in. + Gesture::State stateToUnstage( Gesture::Started ); + + // Attach actor to detector + SignalData data; + UnstageActorFunctor functor( data, stateToUnstage ); + PanGestureDetector detector = PanGestureDetector::New(); + detector.Attach(actor); + detector.Attach(dummyActor); + detector.DetectedSignal().Connect( &application, functor ); + + // Here we are testing a Started actor which is removed in the Started callback, but then added back + // before we get a continuing state. As we were removed from the stage, even if we're at the same + // position, we should still not be signalled. + + // Emit signals + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Re add to the stage, we should not be signalled + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Continue signal emission + application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + data.Reset(); + + // Here we delete an actor in started, we should not receive any subsequent signalling. + + // Emit signals + application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Delete actor as well + actor = NULL; + + // Render and notify + application.SendNotification(); + application.Render(); + + // Continue signal emission + application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + data.Reset(); + application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(10.0f, 20.0f), Vector2(20.0f, 20.0f), 10)); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPanGestureSystemOverlay(void) +{ + TestApplication application; + Dali::Integration::Core& core = application.GetCore(); + Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() ); + systemOverlay.GetOverlayRenderTasks().CreateTask(); + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + systemOverlay.Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PanGestureDetector detector = PanGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + Vector2 screenCoordsStart( 10.0f, 20.0f ); + Vector2 screenCoordsEnd( 20.0f, 20.0f ); + + // Start pan within the actor's area + application.ProcessEvent( GeneratePan( Gesture::Possible, screenCoordsStart, screenCoordsEnd, 10 ) ); + application.ProcessEvent( GeneratePan( Gesture::Started, screenCoordsStart, screenCoordsEnd, 10 ) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliPanGestureAngleHandling(void) +{ + TestApplication application; + + PanGestureDetector detector = PanGestureDetector::New(); + const PanGestureDetector::AngleContainer& angles( detector.GetAngles() ); + DALI_TEST_EQUALS( angles.empty(), true, TEST_LOCATION ); + + detector.AddAngle( PanGestureDetector::DIRECTION_LEFT, Radian( Math::PI * 0.25 ) ); + DALI_TEST_EQUALS( angles.size(), static_cast(1), TEST_LOCATION ); + for ( PanGestureDetector::AngleContainer::const_iterator iter = angles.begin(), endIter = angles.end(); iter != endIter; ++iter ) + { + if ( iter->first == PanGestureDetector::DIRECTION_LEFT ) + { + tet_result( TET_PASS ); + break; + } + + if ( iter == endIter ) + { + tet_printf("%s, angle not added\n", TEST_LOCATION ); + tet_result( TET_FAIL ); + } + } + + detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Radian( Math::PI * 0.25 ) ); + DALI_TEST_EQUALS( angles.size(), static_cast(2), TEST_LOCATION ); + + // Remove something not in the container. + detector.RemoveAngle( PanGestureDetector::DIRECTION_UP ); + DALI_TEST_EQUALS( angles.size(), static_cast(2), TEST_LOCATION ); + + detector.RemoveAngle( PanGestureDetector::DIRECTION_RIGHT ); + DALI_TEST_EQUALS( angles.size(), static_cast(1), TEST_LOCATION ); + for ( PanGestureDetector::AngleContainer::const_iterator iter = angles.begin(), endIter = angles.end(); iter != endIter; ++iter ) + { + if ( iter->first == PanGestureDetector::DIRECTION_RIGHT ) + { + tet_printf("%s, angle not removed\n", TEST_LOCATION ); + tet_result( TET_FAIL ); + break; + } + } + + detector.ClearAngles(); + DALI_TEST_EQUALS( angles.size(), static_cast(0), TEST_LOCATION ); + END_TEST; +} + +inline float RadiansToDegrees( float radian ) +{ + return radian * 180.0f / Math::PI; +} + +int UtcDaliPanGestureAngleOutOfRange(void) +{ + TestApplication application; + + PanGestureDetector detector = PanGestureDetector::New(); + const PanGestureDetector::AngleContainer& angles( detector.GetAngles() ); + DALI_TEST_EQUALS( angles.empty(), true, TEST_LOCATION ); + + // + // Angle + // + + detector.AddAngle( Degree(180.0f) ); + DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(-180.0f) ), 0.000001, TEST_LOCATION ); + detector.ClearAngles(); + + detector.AddAngle( Degree(190.0f) ); + DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(-170.0f) ), 0.000001, TEST_LOCATION ); + detector.ClearAngles(); + + detector.AddAngle( Degree(-190.0f) ); + DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(170.0f) ), 0.000001, TEST_LOCATION ); + detector.ClearAngles(); + + detector.AddAngle( Degree(350.0f) ); + DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(-10.0f) ), 0.000001, TEST_LOCATION ); + detector.ClearAngles(); + + detector.AddAngle( Degree(-350.0f) ); + DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(10.0f) ), 0.000001, TEST_LOCATION ); + detector.ClearAngles(); + + detector.AddAngle( Degree(370.0f) ); + DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(10.0f) ), 0.000001, TEST_LOCATION ); + detector.ClearAngles(); + + detector.AddAngle( Degree(-370.0f) ); + DALI_TEST_EQUALS( angles.begin()->first, Radian( Degree(-10.0f) ), 0.000001, TEST_LOCATION ); + detector.ClearAngles(); + + // + // Threshold + // + + detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Degree( 0.0f ) ); + DALI_TEST_EQUALS( angles.begin()->second, Radian( Degree(0.0f) ), 0.000001, TEST_LOCATION ); + detector.ClearAngles(); + + detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Degree( -10.0f ) ); + DALI_TEST_EQUALS( angles.begin()->second, Radian( Degree(10.0f) ), 0.000001, TEST_LOCATION ); + detector.ClearAngles(); + + detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Degree( -181.0f ) ); + DALI_TEST_EQUALS( angles.begin()->second, Radian( Degree(180.0f) ), 0.000001, TEST_LOCATION ); + detector.ClearAngles(); + + detector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Degree( 181.0f ) ); + DALI_TEST_EQUALS( angles.begin()->second, Radian( Degree(180.0f) ), 0.000001, TEST_LOCATION ); + detector.ClearAngles(); + END_TEST; +} + +int UtcDaliPanGestureAngleProcessing(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + parent.SetSize(100.0f, 100.0f); + parent.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(parent); + + Actor child = Actor::New(); + child.SetSize(100.0f, 100.0f); + child.SetAnchorPoint(AnchorPoint::TOP_LEFT); + parent.Add(child); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Parent detector only requires up pans + PanGestureDetector parentDetector = PanGestureDetector::New(); + parentDetector.Attach( parent ); + parentDetector.AddAngle( PanGestureDetector::DIRECTION_UP, Degree( 30.0f ) ); + SignalData parentData; + GestureReceivedFunctor parentFunctor(parentData); + parentDetector.DetectedSignal().Connect(&application, parentFunctor); + + // Child detector only requires right pans + PanGestureDetector childDetector = PanGestureDetector::New(); + childDetector.Attach( child ); + childDetector.AddAngle( PanGestureDetector::DIRECTION_RIGHT, Degree( 30.0f ) ); + SignalData childData; + GestureReceivedFunctor childFunctor(childData); + childDetector.DetectedSignal().Connect(&application, childFunctor); + + // Generate an Up pan gesture, only parent should receive it. + application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) ); + application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10 ) ); + DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION ); + application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) ); + parentData.Reset(); + childData.Reset(); + + // Generate a Right pan gesture, only child should receive it. + application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) ); + application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(30.0f, 20.0f), 10 ) ); + DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( true, childData.functorCalled, TEST_LOCATION ); + application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) ); + parentData.Reset(); + childData.Reset(); + + // Generate a Down pan gesture, no one should receive it. + application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) ); + application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(20.0f, 30.0f), 10 ) ); + DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION ); + application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) ); + parentData.Reset(); + childData.Reset(); + + // Generate a Left pan gesture, no one should receive it. + application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) ); + application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(10.0f, 20.0f), 10 ) ); + DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION ); + application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) ); + parentData.Reset(); + childData.Reset(); + END_TEST; +} + +int UtcDaliPanGestureDirectionHandling(void) +{ + TestApplication application; + + PanGestureDetector detector = PanGestureDetector::New(); + const PanGestureDetector::AngleContainer& angles( detector.GetAngles() ); + DALI_TEST_EQUALS( angles.empty(), true, TEST_LOCATION ); + + detector.AddDirection( PanGestureDetector::DIRECTION_LEFT, Radian( Math::PI * 0.25 ) ); + DALI_TEST_EQUALS( angles.size(), static_cast(2), TEST_LOCATION ); + for ( PanGestureDetector::AngleContainer::const_iterator iter = angles.begin(), endIter = angles.end(); iter != endIter; ++iter ) + { + if ( iter->first == PanGestureDetector::DIRECTION_LEFT ) + { + tet_result( TET_PASS ); + break; + } + + if ( iter == endIter ) + { + tet_printf("%s, angle not added\n", TEST_LOCATION ); + tet_result( TET_FAIL ); + } + } + + for ( PanGestureDetector::AngleContainer::const_iterator iter = angles.begin(), endIter = angles.end(); iter != endIter; ++iter ) + { + if ( iter->first == PanGestureDetector::DIRECTION_RIGHT ) + { + tet_result( TET_PASS ); + break; + } + + if ( iter == endIter ) + { + tet_printf("%s, angle not added\n", TEST_LOCATION ); + tet_result( TET_FAIL ); + } + } + + // Remove something not in the container. + detector.RemoveDirection( PanGestureDetector::DIRECTION_UP ); + DALI_TEST_EQUALS( angles.size(), static_cast(2), TEST_LOCATION ); + + detector.RemoveDirection( PanGestureDetector::DIRECTION_RIGHT ); + DALI_TEST_EQUALS( angles.size(), static_cast(0), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliPanGestureDirectionProcessing(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + parent.SetSize(100.0f, 100.0f); + parent.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(parent); + + Actor child = Actor::New(); + child.SetSize(100.0f, 100.0f); + child.SetAnchorPoint(AnchorPoint::TOP_LEFT); + parent.Add(child); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Parent detector only requires vertical panning + PanGestureDetector parentDetector = PanGestureDetector::New(); + parentDetector.Attach( parent ); + parentDetector.AddDirection( PanGestureDetector::DIRECTION_VERTICAL, Degree( 30.0f ) ); + SignalData parentData; + GestureReceivedFunctor parentFunctor(parentData); + parentDetector.DetectedSignal().Connect(&application, parentFunctor); + + // Child detector only requires horizontal panning + PanGestureDetector childDetector = PanGestureDetector::New(); + childDetector.Attach( child ); + childDetector.AddDirection( PanGestureDetector::DIRECTION_HORIZONTAL, Degree( 30.0f ) ); + SignalData childData; + GestureReceivedFunctor childFunctor(childData); + childDetector.DetectedSignal().Connect(&application, childFunctor); + + // Generate an Up pan gesture, only parent should receive it. + application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) ); + application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(20.0f, 10.0f), 10 ) ); + DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION ); + application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) ); + parentData.Reset(); + childData.Reset(); + + // Generate a Right pan gesture, only child should receive it. + application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) ); + application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(30.0f, 20.0f), 10 ) ); + DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( true, childData.functorCalled, TEST_LOCATION ); + application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) ); + parentData.Reset(); + childData.Reset(); + + // Generate a Down pan gesture, only parent should receive it. + application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) ); + application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(20.0f, 30.0f), 10 ) ); + DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION ); + application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) ); + parentData.Reset(); + childData.Reset(); + + // Generate a Left pan gesture, only child should receive it. + application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) ); + application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(10.0f, 20.0f), 10 ) ); + DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( true, childData.functorCalled, TEST_LOCATION ); + application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) ); + parentData.Reset(); + childData.Reset(); + + // Generate a pan at -45 degrees, no one should receive it. + application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) ); + application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(10.0f, 30.0f), 10 ) ); + DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION ); + application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) ); + parentData.Reset(); + childData.Reset(); + + // Generate a pan at 45 degrees, no one should receive it. + application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) ); + application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(30.0f, 30.0f), 10 ) ); + DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION ); + application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) ); + parentData.Reset(); + childData.Reset(); + + // Generate a pan at 135 degrees, no one should receive it. + application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) ); + application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(10.0f, 30.0f), 10 ) ); + DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION ); + application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) ); + parentData.Reset(); + childData.Reset(); + + // Generate a pan at -135 degrees, no one should receive it. + application.ProcessEvent( GeneratePan( Gesture::Possible, Vector2(20.0f, 20.0f), Vector2(20.0f, 20.0f), 10 ) ); + application.ProcessEvent( GeneratePan( Gesture::Started, Vector2(20.0f, 20.0f), Vector2(10.0f, 10.0f), 10 ) ); + DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION ); + application.ProcessEvent( GeneratePan( Gesture::Finished, Vector2(20.0f, 30.0f), Vector2(20.0f, 20.0f), 10 ) ); + parentData.Reset(); + childData.Reset(); + END_TEST; +} + +int UtcDaliPanGestureSetProperties(void) +{ + TestApplication application; + TestRenderController& renderController( application.GetRenderController() ); + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Add a pan detector + PanGestureDetector detector = PanGestureDetector::New(); + detector.Attach( actor ); + SignalData data; + GestureReceivedFunctor functor( data ); + detector.DetectedSignal().Connect( &application, functor ); + + Property::Index property = actor.RegisterProperty( "Dummy Property", Vector3::ZERO ); + + ConstraintData constraintData; + actor.ApplyConstraint( Constraint::New( property, Source( detector, PanGestureDetector::SCREEN_POSITION ), + Source( detector, PanGestureDetector::SCREEN_DISPLACEMENT ), + Source( detector, PanGestureDetector::LOCAL_POSITION ), + Source( detector, PanGestureDetector::LOCAL_DISPLACEMENT ), + PanConstraint( constraintData ) ) ); + + // Render and notify + application.SendNotification(); + application.Render(); + + renderController.Initialize(); + DALI_TEST_EQUALS( renderController.WasCalled( TestRenderController::RequestUpdateFunc ), false, TEST_LOCATION ); + + Vector2 screenPosition( 20.0f, 20.0f ); + Vector2 screenDisplacement( 1.0f, 1.0f ); + Vector2 localPosition( 21.0f, 21.0f ); + Vector2 localDisplacement( 0.5f, 0.5f ); + + PanGestureDetector::SetPanGestureProperties( GeneratePan( 1u, Gesture::Started, screenPosition, localPosition, screenDisplacement, localDisplacement ) ); + DALI_TEST_EQUALS( renderController.WasCalled( TestRenderController::RequestUpdateFunc ), true, TEST_LOCATION ); + + // Render and notify + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( constraintData.called, true, TEST_LOCATION ); + DALI_TEST_EQUALS( constraintData.screenPosition, screenPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( constraintData.localPosition, localPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( constraintData.screenDisplacement, screenDisplacement, TEST_LOCATION ); + DALI_TEST_EQUALS( constraintData.localDisplacement, localDisplacement, TEST_LOCATION ); + constraintData.Reset(); + END_TEST; +} + +int UtcDaliPanGestureSetPropertiesAlreadyPanning(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Add a pan detector + PanGestureDetector detector = PanGestureDetector::New(); + detector.Attach( actor ); + SignalData data; + GestureReceivedFunctor functor( data ); + detector.DetectedSignal().Connect( &application, functor ); + + Property::Index property = actor.RegisterProperty( "Dummy Property", Vector3::ZERO ); + + ConstraintData constraintData; + actor.ApplyConstraint( Constraint::New( property, Source( detector, PanGestureDetector::SCREEN_POSITION ), + Source( detector, PanGestureDetector::SCREEN_DISPLACEMENT ), + Source( detector, PanGestureDetector::LOCAL_POSITION ), + Source( detector, PanGestureDetector::LOCAL_DISPLACEMENT ), + PanConstraint( constraintData ) ) ); + + // Render and notify + application.SendNotification(); + application.Render(); + + Vector2 previousPosition( 20.0f, 20.0f ); + Vector2 currentPosition( 20.0f, 10.0f ); + application.ProcessEvent( GeneratePan( Gesture::Possible, previousPosition, previousPosition, 10 ) ); + application.ProcessEvent( GeneratePan( Gesture::Started, previousPosition, currentPosition, 10 ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + + Vector2 screenPosition( 100.0f, 20.0f ); + Vector2 localPosition( 110.0f, 110.0f ); + + PanGestureDetector::SetPanGestureProperties( GeneratePan( 1u, Gesture::Started, screenPosition, localPosition ) ); + + // Render and notify + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( constraintData.called, true, TEST_LOCATION ); + DALI_TEST_EQUALS( constraintData.screenPosition, currentPosition, 0.1, TEST_LOCATION ); + DALI_TEST_EQUALS( constraintData.localPosition, currentPosition, 0.1f, TEST_LOCATION ); + constraintData.Reset(); + END_TEST; +} + +int UtcDaliPanGesturePropertyIndices(void) +{ + TestApplication application; + PanGestureDetector detector = PanGestureDetector::New(); + + Property::IndexContainer indices; + detector.GetPropertyIndices( indices ); + DALI_TEST_CHECK( ! indices.empty() ); + DALI_TEST_EQUALS( indices.size(), detector.GetPropertyCount(), TEST_LOCATION ); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-PinchGesture.cpp b/automated-tests/src/dali/utc-Dali-PinchGesture.cpp new file mode 100644 index 0000000..ee38c86 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-PinchGesture.cpp @@ -0,0 +1,94 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +using namespace Dali; + +void utc_dali_pinch_gesture_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_pinch_gesture_cleanup(void) +{ + test_return_value = TET_PASS; +} + +// Positive test case for a method +int UtcDaliPinchGestureConstructor(void) +{ + TestApplication application; // Reset all test adapter return codes + + PinchGesture gesture(Gesture::Started); + DALI_TEST_EQUALS(Gesture::Started, gesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture.scale, TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture.speed, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pinch, gesture.type, TEST_LOCATION); + + PinchGesture gesture2(Gesture::Continuing); + DALI_TEST_EQUALS(Gesture::Continuing, gesture2.state, TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture2.scale, TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture2.speed, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pinch, gesture2.type, TEST_LOCATION); + + PinchGesture gesture3(Gesture::Finished); + DALI_TEST_EQUALS(Gesture::Finished, gesture3.state, TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture3.scale, TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture3.speed, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pinch, gesture3.type, TEST_LOCATION); + + // Test copy constructor + gesture3.scale = 3.0f; + gesture3.speed = 5.0f; + + PinchGesture pinch(gesture3); + DALI_TEST_EQUALS(Gesture::Finished, pinch.state, TEST_LOCATION); + DALI_TEST_EQUALS(3.0f, pinch.scale, TEST_LOCATION); + DALI_TEST_EQUALS(5.0f, pinch.speed, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pinch, pinch.type, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPinchGestureAssignment(void) +{ + // Test Assignment operator + PinchGesture gesture(Gesture::Started); + DALI_TEST_EQUALS(Gesture::Started, gesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture.scale, TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture.speed, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pinch, gesture.type, TEST_LOCATION); + + PinchGesture gesture2(Gesture::Continuing); + DALI_TEST_EQUALS(Gesture::Continuing, gesture2.state, TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture2.scale, TEST_LOCATION); + DALI_TEST_EQUALS(0.0f, gesture2.speed, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pinch, gesture2.type, TEST_LOCATION); + + gesture2.scale = 3.0f; + gesture2.speed = 5.0f; + + gesture = gesture2; + DALI_TEST_EQUALS(Gesture::Continuing, gesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(3.0f, gesture.scale, TEST_LOCATION); + DALI_TEST_EQUALS(5.0f, gesture.speed, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Pinch, gesture.type, TEST_LOCATION); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp new file mode 100644 index 0000000..af87180 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp @@ -0,0 +1,1185 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 +#include +#include + +using namespace Dali; + +void utc_dali_pinch_gesture_detector_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_pinch_gesture_detector_cleanup(void) +{ + test_return_value = TET_PASS; +} + +/////////////////////////////////////////////////////////////////////////////// +namespace +{ + +// Stores data that is populated in the callback and will be read by the TET cases +struct SignalData +{ + SignalData() + : functorCalled(false), + voidFunctorCalled(false), + receivedGesture(Gesture::Started) + {} + + void Reset() + { + functorCalled = false; + voidFunctorCalled = false; + + receivedGesture.state = Gesture::Started; + receivedGesture.scale = 0.0f; + receivedGesture.speed = 0.0f; + receivedGesture.screenCenterPoint = Vector2(0.0f, 0.0f); + receivedGesture.localCenterPoint = Vector2(0.0f, 0.0f); + + pinchedActor = NULL; + } + + bool functorCalled; + bool voidFunctorCalled; + PinchGesture receivedGesture; + Actor pinchedActor; +}; + +// Functor that sets the data when called +struct GestureReceivedFunctor +{ + GestureReceivedFunctor(SignalData& data) : signalData(data) { } + + void operator()(Actor actor, PinchGesture pinch) + { + signalData.functorCalled = true; + signalData.receivedGesture = pinch; + signalData.pinchedActor = actor; + } + + void operator()() + { + signalData.voidFunctorCalled = true; + } + + SignalData& signalData; +}; + +// Functor that removes the gestured actor from stage +struct UnstageActorFunctor : public GestureReceivedFunctor +{ + UnstageActorFunctor( SignalData& data, Gesture::State& stateToUnstage ) + : GestureReceivedFunctor( data ), + stateToUnstage( stateToUnstage ) + { + } + + void operator()( Actor actor, PinchGesture pinch ) + { + GestureReceivedFunctor::operator()( actor, pinch ); + + if ( pinch.state == stateToUnstage ) + { + Stage::GetCurrent().Remove( actor ); + } + } + + Gesture::State& stateToUnstage; +}; + +// Functor for receiving a touch event +struct TouchEventFunctor +{ + bool operator()(Actor actor, const TouchEvent& touch) + { + return false; + } +}; + +// Generate a PinchGestureEvent to send to Core +Integration::PinchGestureEvent GeneratePinch( + Gesture::State state, + float scale, + float speed, + Vector2 centerpoint) +{ + Integration::PinchGestureEvent pinch(state); + + pinch.scale = scale; + pinch.speed = speed; + pinch.centerPoint = centerpoint; + + return pinch; +} + +} // anon namespace + +/////////////////////////////////////////////////////////////////////////////// + +int UtcDaliPinchGestureDetectorConstructor(void) +{ + TestApplication application; + + PinchGestureDetector detector; + DALI_TEST_CHECK(!detector); + END_TEST; +} + +int UtcDaliPinchGestureDetectorNew(void) +{ + TestApplication application; + + PinchGestureDetector detector = PinchGestureDetector::New(); + + DALI_TEST_CHECK(detector); + + // Attach an actor and emit a touch event on the actor to ensure complete line coverage + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + detector.Attach(actor); + + Integration::TouchEvent touchEvent(1); + TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f); + touchEvent.AddPoint(point); + application.ProcessEvent(touchEvent); + + TouchPoint point2(1, TouchPoint::Down, 20.0f, 20.0f, 20.0f, 20.0f); + touchEvent.AddPoint(point2); + application.ProcessEvent(touchEvent); + END_TEST; +} + +int UtcDaliPinchGestureDetectorDownCast(void) +{ + TestApplication application; + tet_infoline("Testing Dali::PinchGestureDetector::DownCast()"); + + PinchGestureDetector detector = PinchGestureDetector::New(); + + BaseHandle object(detector); + + PinchGestureDetector detector2 = PinchGestureDetector::DownCast(object); + DALI_TEST_CHECK(detector2); + + PinchGestureDetector detector3 = DownCast< PinchGestureDetector >(object); + DALI_TEST_CHECK(detector3); + + BaseHandle unInitializedObject; + PinchGestureDetector detector4 = PinchGestureDetector::DownCast(unInitializedObject); + DALI_TEST_CHECK(!detector4); + + PinchGestureDetector detector5 = DownCast< PinchGestureDetector >(unInitializedObject); + DALI_TEST_CHECK(!detector5); + + GestureDetector detector6 = PinchGestureDetector::New(); + PinchGestureDetector detector7 = PinchGestureDetector::DownCast(detector6); + DALI_TEST_CHECK(detector7); + END_TEST; +} + +// Negative test case for a method +int UtcDaliPinchGestureSignalReceptionNegative(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PinchGestureDetector detector = PinchGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Do a pinch outside actor's area + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 45.0f, Vector2(112.0f, 112.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Continue pinch into actor's area - we should still not receive the signal + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Continuing, 4.5f, 95.0f, Vector2(20.0f, 20.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Stop pinching - we should still not receive the signal + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(12.0f, 12.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPinchGestureSignalReceptionDownMotionLeave(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PinchGestureDetector detector = PinchGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Start pan within the actor's area + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + + // Continue the pan within the actor's area - we should still receive the signal + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 90.0f, Vector2(21.0f, 20.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(90.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + + // Pan Gesture leaves actor's area - we should still receive the signal + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 15.5f, Vector2(320.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(15.5f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + + // Gesture ends - we would receive a finished state + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Finished, 15.2f, 12.1f, Vector2(310.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(15.2f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(12.1f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPinchGestureSignalReceptionDownMotionUp(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PinchGestureDetector detector = PinchGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Start pinch within the actor's area + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + + // Continue the pinch within the actor's area - we should still receive the signal + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(25.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + + // Gesture ends within actor's area - we would receive a finished state + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION); + DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(25.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPinchGestureSignalReceptionCancelled(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PinchGestureDetector detector = PinchGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Start pinch within the actor's area + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); + + + // Continue the pinch within the actor's area - we should still receive the signal + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); + + // The gesture is cancelled + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Cancelled, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Cancelled, data.receivedGesture.state, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPinchGestureSignalReceptionDetach(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PinchGestureDetector detector = PinchGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Start pinch within the actor's area + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); + + + // Continue the pinch within the actor's area - we should still receive the signal + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); + + // Gesture ends within actor's area + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION); + + // Detach actor + detector.DetachAll(); + + // Ensure we are no longer signalled + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f))); + application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPinchGestureSignalReceptionDetachWhilePinching(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PinchGestureDetector detector = PinchGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Start pinch within the actor's area + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); + + // Continue the pinch within the actor's area - we should still receive the signal + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); + + // Detach actor during the pinch, we should not receive the next event + detector.DetachAll(); + + // Gesture ends within actor's area + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPinchGestureSignalReceptionActorDestroyedWhilePinching(void) +{ + TestApplication application; + + SignalData data; + GestureReceivedFunctor functor(data); + + PinchGestureDetector detector = PinchGestureDetector::New(); + detector.DetectedSignal().Connect(&application, functor); + + // Attach a temporary actor to stop detector being removed from PinchGestureProcessor when main actor + // is destroyed. + Actor tempActor = Actor::New(); + tempActor.SetSize(100.0f, 100.0f); + tempActor.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT); + Stage::GetCurrent().Add(tempActor); + detector.Attach(tempActor); + + // Actor lifetime is scoped + { + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + detector.Attach(actor); + + // Start pinch within the actor's area + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION); + + // Continue the pinch within the actor's area - we should still receive the signal + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION); + + // Remove the actor from stage and reset the data + Stage::GetCurrent().Remove(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + } + + // Actor should now have been destroyed + + // Gesture ends within the area where the actor used to be + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPinchGestureSignalReceptionRotatedActor(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetRotation(Dali::Degree(90.0f), Vector3::ZAXIS); + Stage::GetCurrent().Add(actor); + + // Render and notify a couple of times + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PinchGestureDetector detector = PinchGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Do an entire pinch, only check finished value + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + + // Rotate actor again and render and notify + actor.SetRotation(Dali::Degree(180.0f), Vector3::ZAXIS); + application.SendNotification(); + application.Render(); + + // Do an entire pinch, only check finished value + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + + // Rotate actor again and render and notify + actor.SetRotation(Dali::Degree(270.0f), Vector3::ZAXIS); + application.SendNotification(); + application.Render(); + + // Do an entire pinch, only check finished value + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPinchGestureSignalReceptionChildHit(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + parent.SetSize(100.0f, 100.0f); + parent.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(parent); + + // Set child to completely cover parent. + // Change rotation of child to be different from parent so that we can check if our local coordinate + // conversion of the parent actor is correct. + Actor child = Actor::New(); + child.SetSize(100.0f, 100.0f); + child.SetAnchorPoint(AnchorPoint::CENTER); + child.SetParentOrigin(ParentOrigin::CENTER); + child.SetRotation(Dali::Degree(90.0f), Vector3::ZAXIS); + parent.Add(child); + + TouchEventFunctor touchFunctor; + child.TouchedSignal().Connect(&application, touchFunctor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PinchGestureDetector detector = PinchGestureDetector::New(); + detector.Attach(parent); + detector.DetectedSignal().Connect(&application, functor); + + // Do an entire pan, only check finished value - hits child area but parent should still receive it + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 50.0f, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, parent == data.pinchedActor, TEST_LOCATION); + DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + + // Attach child and generate same touch points to yield same results + // (Also proves that you can detach and then re-attach another actor) + detector.Attach(child); + detector.Detach(parent); + + // Do an entire pan, only check finished value + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 50.0f, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, child == data.pinchedActor, TEST_LOCATION); + DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPinchGestureSignalReceptionAttachDetachMany(void) +{ + TestApplication application; + + Actor first = Actor::New(); + first.SetSize(100.0f, 100.0f); + first.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(first); + + Actor second = Actor::New(); + second.SetSize(100.0f, 100.0f); + second.SetX(100.0f); + second.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(second); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PinchGestureDetector detector = PinchGestureDetector::New(); + detector.Attach(first); + detector.Attach(second); + detector.DetectedSignal().Connect(&application, functor); + + // Start pinch within second actor's area + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(120.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, second == data.pinchedActor, TEST_LOCATION); + + // Pinch moves into first actor's area - second actor should receive the pinch + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, second == data.pinchedActor, TEST_LOCATION); + + // Detach the second actor during the pinch, we should not receive the next event + detector.Detach(second); + + // Gesture ends within actor's area + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(120.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPinchGestureSignalReceptionActorBecomesUntouchable(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PinchGestureDetector detector = PinchGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Start pinch in actor's area + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + + // Pan continues within actor's area + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Started, 5.0f, 50.0f, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + + // Actor become invisible - actor should not receive the next pinch + actor.SetVisible(false); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Gesture ends within actor's area + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 50.0f, Vector2(10.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPinchGestureSignalReceptionMultipleDetectorsOnActor(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + Actor actor2 = Actor::New(); + actor2.SetSize(100.0f, 100.0f); + actor2.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT); + Stage::GetCurrent().Add(actor2); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Attach actor to one detector + SignalData firstData; + GestureReceivedFunctor firstFunctor(firstData); + PinchGestureDetector firstDetector = PinchGestureDetector::New(); + firstDetector.Attach(actor); + firstDetector.DetectedSignal().Connect(&application, firstFunctor); + + // Attach actor to another detector + SignalData secondData; + GestureReceivedFunctor secondFunctor(secondData); + PinchGestureDetector secondDetector = PinchGestureDetector::New(); + secondDetector.Attach(actor); + secondDetector.DetectedSignal().Connect(&application, secondFunctor); + + // Add second actor to second detector, when we remove the actor, this will make sure that this + // gesture detector is not removed from the GestureDetectorProcessor. In this scenario, the + // functor should still not be called (which is what we're also testing). + secondDetector.Attach(actor2); + + // Pinch in actor's area - both detector's functors should be called + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION); + + // Pinch continues in actor's area - both detector's functors should be called + firstData.Reset(); + secondData.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION); + + // Detach actor from firstDetector and emit pinch on actor, only secondDetector's functor should be called. + firstDetector.Detach(actor); + firstData.Reset(); + secondData.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION); + + // New pinch on actor, only secondDetector has actor attached + firstData.Reset(); + secondData.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION); + + // Detach actor from secondDetector + secondDetector.Detach(actor); + firstData.Reset(); + secondData.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(false, secondData.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPinchGestureSignalReceptionMultipleStarted(void) +{ + // Should handle two started events gracefully. + + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + SignalData data; + GestureReceivedFunctor functor(data); + + PinchGestureDetector detector = PinchGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Start pan in actor's area + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + + // Send another start in actor's area + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + + // Add a child actor to overlap actor and send another start in actor's area + Actor child = Actor::New(); + child.SetSize(100.0f, 100.0f); + child.SetAnchorPoint(AnchorPoint::CENTER); + child.SetParentOrigin(ParentOrigin::CENTER); + actor.Add(child); + + TouchEventFunctor touchFunctor; + child.TouchedSignal().Connect(&application, touchFunctor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Send another start in actor's area + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + + // Send another start in actor's area + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPinchGestureSignalReceptionEnsureCorrectSignalling(void) +{ + TestApplication application; + + Actor actor1 = Actor::New(); + actor1.SetSize(100.0f, 100.0f); + actor1.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor1); + SignalData data1; + GestureReceivedFunctor functor1(data1); + PinchGestureDetector detector1 = PinchGestureDetector::New(); + detector1.Attach(actor1); + detector1.DetectedSignal().Connect(&application, functor1); + + Actor actor2 = Actor::New(); + actor2.SetSize(100.0f, 100.0f); + actor2.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT); + actor2.SetParentOrigin(ParentOrigin::BOTTOM_RIGHT); + Stage::GetCurrent().Add(actor2); + SignalData data2; + GestureReceivedFunctor functor2(data2); + PinchGestureDetector detector2 = PinchGestureDetector::New(); + detector2.Attach(actor2); + detector2.DetectedSignal().Connect(&application, functor2); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Start pan in actor1's area, only data1 should be set + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(true, data1.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(false, data2.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPinchGestureEmitIncorrectStateClear(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Attach actor to detector + SignalData data; + GestureReceivedFunctor functor( data ); + PinchGestureDetector detector = PinchGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + // Try a Clear state + try + { + application.ProcessEvent(GeneratePinch(Gesture::Clear, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + tet_result(TET_FAIL); + } + catch ( Dali::DaliException& e ) + { + DALI_TEST_ASSERT( e, "false", TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliPinchGestureEmitIncorrectStatePossible(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Attach actor to detector + SignalData data; + GestureReceivedFunctor functor( data ); + PinchGestureDetector detector = PinchGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + // Try a Possible state + try + { + application.ProcessEvent(GeneratePinch(Gesture::Possible, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + tet_result(TET_FAIL); + } + catch ( Dali::DaliException& e ) + { + DALI_TEST_ASSERT( e, "false", TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliPinchGestureActorUnstaged(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // State to remove actor in. + Gesture::State stateToUnstage( Gesture::Started ); + + // Attach actor to detector + SignalData data; + UnstageActorFunctor functor( data, stateToUnstage ); + PinchGestureDetector detector = PinchGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + // Emit signals + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + data.Reset(); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Re-add actor to stage + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Change state to Gesture::Continuing to remove + stateToUnstage = Gesture::Continuing; + + // Emit signals + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + data.Reset(); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Re-add actor to stage + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Change state to Gesture::Continuing to remove + stateToUnstage = Gesture::Finished; + + // Emit signals + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + tet_result( TET_PASS ); // If we get here then we have handled actor stage removal gracefully. + END_TEST; +} + +int UtcDaliPinchGestureActorStagedAndDestroyed(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Create and add a second actor so that GestureDetector destruction does not come into play. + Actor dummyActor( Actor::New() ); + dummyActor.SetSize( 100.0f, 100.0f ); + dummyActor.SetPosition( 100.0f, 100.0f ); + dummyActor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(dummyActor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // State to remove actor in. + Gesture::State stateToUnstage( Gesture::Started ); + + // Attach actor to detector + SignalData data; + UnstageActorFunctor functor( data, stateToUnstage ); + PinchGestureDetector detector = PinchGestureDetector::New(); + detector.Attach(actor); + detector.Attach(dummyActor); + detector.DetectedSignal().Connect( &application, functor ); + + // Here we are testing a Started actor which is removed in the Started callback, but then added back + // before we get a continuing state. As we were removed from the stage, even if we're at the same + // position, we should still not be signalled. + + // Emit signals + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Re add to the stage, we should not be signalled + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Continue signal emission + application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + data.Reset(); + + // Here we delete an actor in started, we should not receive any subsequent signalling. + + // Emit signals + application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Delete actor as well + actor = NULL; + + // Render and notify + application.SendNotification(); + application.Render(); + + // Continue signal emission + application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + data.Reset(); + application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliPinchGestureSystemOverlay(void) +{ + TestApplication application; + Dali::Integration::Core& core = application.GetCore(); + Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() ); + systemOverlay.GetOverlayRenderTasks().CreateTask(); + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + systemOverlay.Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + PinchGestureDetector detector = PinchGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + Vector2 screenCoords( 50.0f, 50.0f ); + float scale ( 10.0f ); + float speed ( 50.0f ); + + // Start pan within the actor's area + application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Pixel.cpp b/automated-tests/src/dali/utc-Dali-Pixel.cpp new file mode 100644 index 0000000..2e19437 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-Pixel.cpp @@ -0,0 +1,179 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 std::max; +using namespace Dali; + + +static const float ROTATION_EPSILON = 0.0001f; + +void utc_dali_pixel_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_pixel_cleanup(void) +{ + test_return_value = TET_PASS; +} + +static void TestPixelEnumSize(const int size) +{ + DALI_TEST_CHECK( (static_cast( Pixel::LAST_VALID_PIXEL_FORMAT ) - static_cast( Pixel::FIRST_VALID_PIXEL_FORMAT ) + 1 ) == size && + "The Pixel::Format enum may have had new formats added. Expand the test cases to include them."); +} + +int UtcDaliPixelHasAlpha(void) +{ + TestApplication application; + + tet_infoline("UtcDaliPixelHasAlpha"); + + TestPixelEnumSize( 26 ); + + DALI_TEST_CHECK( Pixel::HasAlpha(Pixel::L8) == false); + DALI_TEST_CHECK( Pixel::HasAlpha(Pixel::RGB565) == false); + DALI_TEST_CHECK( Pixel::HasAlpha(Pixel::RGB888) == false); + DALI_TEST_CHECK( Pixel::HasAlpha(Pixel::RGB8888) == false); + DALI_TEST_CHECK( Pixel::HasAlpha(Pixel::BGR8888) == false); + DALI_TEST_CHECK( Pixel::HasAlpha(Pixel::BGR565) == false); + DALI_TEST_CHECK( Pixel::HasAlpha(Pixel::COMPRESSED_R11_EAC) == false); + DALI_TEST_CHECK( Pixel::HasAlpha(Pixel::COMPRESSED_SIGNED_R11_EAC) == false); + DALI_TEST_CHECK( Pixel::HasAlpha(Pixel::COMPRESSED_RG11_EAC) == false); + DALI_TEST_CHECK( Pixel::HasAlpha(Pixel::COMPRESSED_SIGNED_RG11_EAC) == false); + DALI_TEST_CHECK( Pixel::HasAlpha(Pixel::COMPRESSED_RGB8_ETC2) == false); + DALI_TEST_CHECK( Pixel::HasAlpha(Pixel::COMPRESSED_SRGB8_ETC2) == false); + DALI_TEST_CHECK( Pixel::HasAlpha(Pixel::COMPRESSED_RGB8_ETC1) == false); + DALI_TEST_CHECK( Pixel::HasAlpha(Pixel::COMPRESSED_RGB_PVRTC_4BPPV1) == false); + + DALI_TEST_CHECK( Pixel::HasAlpha(Pixel::A8) == true); + DALI_TEST_CHECK( Pixel::HasAlpha(Pixel::LA88) == true); + DALI_TEST_CHECK( Pixel::HasAlpha(Pixel::RGBA5551) == true); + DALI_TEST_CHECK( Pixel::HasAlpha(Pixel::RGBA4444) == true); + DALI_TEST_CHECK( Pixel::HasAlpha(Pixel::RGBA8888) == true); + DALI_TEST_CHECK( Pixel::HasAlpha(Pixel::BGRA8888) == true); + DALI_TEST_CHECK( Pixel::HasAlpha(Pixel::BGRA5551) == true); + DALI_TEST_CHECK( Pixel::HasAlpha(Pixel::BGRA4444) == true); + DALI_TEST_CHECK( Pixel::HasAlpha( Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 ) == true ); + DALI_TEST_CHECK( Pixel::HasAlpha( Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 ) == true ); + DALI_TEST_CHECK( Pixel::HasAlpha( Pixel::COMPRESSED_RGBA8_ETC2_EAC ) == true ); + DALI_TEST_CHECK( Pixel::HasAlpha( Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC) == true ); + END_TEST; +} + +int UtcDaliPixelGetBytesPerPixel(void) +{ + TestApplication application; + + tet_infoline("UtcDaliPixelGetBytesPerPixel"); + + DALI_TEST_CHECK( Pixel::GetBytesPerPixel(Pixel::L8) == 1); + DALI_TEST_CHECK( Pixel::GetBytesPerPixel(Pixel::A8) == 1); + + DALI_TEST_CHECK( Pixel::GetBytesPerPixel(Pixel::LA88) == 2); + DALI_TEST_CHECK( Pixel::GetBytesPerPixel(Pixel::RGB565) == 2); + DALI_TEST_CHECK( Pixel::GetBytesPerPixel(Pixel::RGBA5551) == 2); + DALI_TEST_CHECK( Pixel::GetBytesPerPixel(Pixel::RGBA4444) == 2); + DALI_TEST_CHECK( Pixel::GetBytesPerPixel(Pixel::BGR565) == 2); + DALI_TEST_CHECK( Pixel::GetBytesPerPixel(Pixel::BGRA5551) == 2); + DALI_TEST_CHECK( Pixel::GetBytesPerPixel(Pixel::BGRA4444) == 2); + + DALI_TEST_CHECK( Pixel::GetBytesPerPixel(Pixel::RGB888) == 3); + + DALI_TEST_CHECK( Pixel::GetBytesPerPixel(Pixel::RGB8888) == 4); + DALI_TEST_CHECK( Pixel::GetBytesPerPixel(Pixel::BGR8888) == 4); + DALI_TEST_CHECK( Pixel::GetBytesPerPixel(Pixel::RGBA8888) == 4); + DALI_TEST_CHECK( Pixel::GetBytesPerPixel(Pixel::BGRA8888) == 4); + + DALI_TEST_CHECK( Pixel::GetBytesPerPixel(Pixel::L8) == 1); + END_TEST; +} + +int UtcDaliPixelGetAlphaOffsetAndMask(void) +{ + TestApplication application; + + tet_infoline("UtcDaliPixelGetAlphaOffsetAndMask"); + + int byteOffset = 0; + int bitMask = 0; + + // Be sure that the number of cases tested below is correct: + TestPixelEnumSize( 26 ); + + Pixel::GetAlphaOffsetAndMask(Pixel::L8, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0); + Pixel::GetAlphaOffsetAndMask(Pixel::A8, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0xff); + Pixel::GetAlphaOffsetAndMask(Pixel::RGB888, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0); + Pixel::GetAlphaOffsetAndMask(Pixel::RGB565, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0); + Pixel::GetAlphaOffsetAndMask(Pixel::RGB8888, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0); + Pixel::GetAlphaOffsetAndMask(Pixel::BGR8888, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0); + Pixel::GetAlphaOffsetAndMask(Pixel::LA88, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 1 && bitMask == 0xff); + Pixel::GetAlphaOffsetAndMask(Pixel::RGBA4444, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 1 && bitMask == 0x0f); + Pixel::GetAlphaOffsetAndMask(Pixel::RGBA5551, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 1 && bitMask == 0x01); + Pixel::GetAlphaOffsetAndMask(Pixel::RGBA8888, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 3 && bitMask == 0xff); + Pixel::GetAlphaOffsetAndMask(Pixel::BGRA8888, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 3 && bitMask == 0xff); + Pixel::GetAlphaOffsetAndMask(Pixel::BGR565, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0); + Pixel::GetAlphaOffsetAndMask(Pixel::BGRA4444, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 1 && bitMask == 0x0f); + Pixel::GetAlphaOffsetAndMask(Pixel::BGRA5551, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 1 && bitMask == 0x01); + + // Compressed formats with no meaningful result: + Pixel::GetAlphaOffsetAndMask(Pixel::COMPRESSED_R11_EAC, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0); + Pixel::GetAlphaOffsetAndMask(Pixel::COMPRESSED_SIGNED_R11_EAC, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0); + Pixel::GetAlphaOffsetAndMask(Pixel::COMPRESSED_RG11_EAC, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0); + Pixel::GetAlphaOffsetAndMask(Pixel::COMPRESSED_SIGNED_RG11_EAC, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0); + Pixel::GetAlphaOffsetAndMask(Pixel::COMPRESSED_RGB8_ETC2, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0); + Pixel::GetAlphaOffsetAndMask(Pixel::COMPRESSED_SRGB8_ETC2, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0); + Pixel::GetAlphaOffsetAndMask(Pixel::COMPRESSED_RGB8_ETC1, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0); + Pixel::GetAlphaOffsetAndMask(Pixel::COMPRESSED_RGB_PVRTC_4BPPV1, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0); + Pixel::GetAlphaOffsetAndMask(Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0); + Pixel::GetAlphaOffsetAndMask(Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0); + Pixel::GetAlphaOffsetAndMask(Pixel::COMPRESSED_RGBA8_ETC2_EAC, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0); + Pixel::GetAlphaOffsetAndMask(Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, byteOffset, bitMask); + DALI_TEST_CHECK( byteOffset == 0 && bitMask == 0); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-PropertyNotification.cpp b/automated-tests/src/dali/utc-Dali-PropertyNotification.cpp new file mode 100644 index 0000000..8142f6a --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-PropertyNotification.cpp @@ -0,0 +1,843 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; + +void utc_dali_property_notification_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_property_notification_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace { + +static bool gCallBackCalled; + +static void TestCallback(PropertyNotification& source) +{ + gCallBackCalled = true; +} + +const int RENDER_FRAME_INTERVAL(16); ///< Duration of each frame in ms. (at approx 60FPS) +const int DEFAULT_WAIT_PERIOD(100); ///< Default waiting period for check. + + +class TestClass : public ConnectionTracker +{ +public: + + TestClass() + { + } + + ~TestClass() + { + } + + void Initialize() + { + mActor = Actor::New(); + Stage::GetCurrent().Add( mActor ); + mNotification = mActor.AddPropertyNotification( Actor::POSITION_X, GreaterThanCondition(100.0f) ); + mNotification.NotifySignal().Connect( this, &TestClass::OnPropertyNotify ); + } + + void RemovePropertyNotification() + { + mActor.RemovePropertyNotification( mNotification ); + } + + void RemovePropertyNotifications() + { + mActor.RemovePropertyNotifications(); + } + + void Terminate() + { + Stage::GetCurrent().Remove( mActor ); + mActor.Reset(); + mNotification.Reset(); + } + + void OnPropertyNotify( PropertyNotification& source ) + { + tet_infoline(" OnPropertyNotify"); + gCallBackCalled = true; + } + + Actor mActor; + PropertyNotification mNotification; +}; + + +/* + * Simulate time passed by. + * + * @note this will always process at least 1 frame (1/60 sec) + * + * @param application Test application instance + * @param duration Time to pass in milliseconds. + * @return The actual time passed in milliseconds + */ +int Wait(TestApplication& application, int duration = 0) +{ + int time = 0; + + for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++) + { + application.SendNotification(); + application.Render(RENDER_FRAME_INTERVAL); + time += RENDER_FRAME_INTERVAL; + } + + return time; +} + +} // unnamed namespace + + +// Positive test case for a method +int UtcDaliPropertyNotificationDownCast(void) +{ + TestApplication application; + tet_infoline(" UtcDaliPropertyNotificationDownCast"); + + Actor actor = Actor::New(); + PropertyNotification notification = actor.AddPropertyNotification(Actor::POSITION_X, GreaterThanCondition(100.0f)); + BaseHandle handle = notification; + PropertyNotification notificationHandle; + + DALI_TEST_CHECK(notification); + DALI_TEST_CHECK(handle); + DALI_TEST_CHECK(!notificationHandle); + + notificationHandle = PropertyNotification::DownCast( handle ); + DALI_TEST_CHECK(notificationHandle); + END_TEST; +} + + +// Negative test case for a method +int UtcDaliPropertyNotificationDownCastNegative(void) +{ + TestApplication application; + tet_infoline(" UtcDaliPropertyNotificationDownCastNegative"); + + // Create something derived from BaseHandle other than a PropertyNotification. + Actor somethingElse = Actor::New(); + + Actor actor = Actor::New(); + actor.AddPropertyNotification(Actor::POSITION_X, GreaterThanCondition(100.0f)); + BaseHandle handle = somethingElse; + PropertyNotification notificationHandle; + + notificationHandle = PropertyNotification::DownCast( handle ); + DALI_TEST_CHECK(!notificationHandle); + END_TEST; +} + +int UtcDaliAddPropertyNotification(void) +{ + TestApplication application; // Reset all test adapter return codes + tet_infoline(" UtcDaliAddPropertyNotification"); + + Actor actor = Actor::New(); + + PropertyNotification notification = actor.AddPropertyNotification(Actor::POSITION_X, GreaterThanCondition(100.0f)); + DALI_TEST_CHECK( notification ); + END_TEST; +} + +int UtcDaliAddPropertyNotificationCallback(void) +{ + TestApplication application; // Reset all test adapter return codes + + TestClass* object = new TestClass; + + object->Initialize(); + application.Render(RENDER_FRAME_INTERVAL); + application.SendNotification(); + + gCallBackCalled = false; + + tet_infoline(" UtcDaliAddPropertyNotificationCallback - Forcing notification condition true, should receive a notification"); + object->mActor.SetPosition(Vector3(200.0f, 0.0f, 0.0f)); + application.Render(RENDER_FRAME_INTERVAL); + application.SendNotification(); + application.Render(RENDER_FRAME_INTERVAL); + application.SendNotification(); + DALI_TEST_CHECK( gCallBackCalled ); + gCallBackCalled = false; + + tet_infoline(" UtcDaliAddPropertyNotificationCallback - Forcing notification condition false, should not receive a notification"); + object->mActor.SetPosition(Vector3(0.0f, 0.0f, 0.0f)); + application.Render(RENDER_FRAME_INTERVAL); + application.SendNotification(); + application.Render(RENDER_FRAME_INTERVAL); + application.SendNotification(); + DALI_TEST_CHECK( !gCallBackCalled ); + gCallBackCalled = false; + + tet_infoline(" UtcDaliAddPropertyNotificationCallback - Deleting notification and it's owning object, should not receive a notification"); + object->mActor.SetPosition(Vector3(200.0f, 0.0f, 0.0f)); + application.Render(RENDER_FRAME_INTERVAL); + application.SendNotification(); + object->Terminate(); + application.Render(RENDER_FRAME_INTERVAL); + application.SendNotification(); + DALI_TEST_CHECK( !gCallBackCalled ); + + tet_infoline(" UtcDaliAddPropertyNotificationCallback - Removing notification and it's owning object, should not receive a notification"); + object->Initialize(); + application.Render(RENDER_FRAME_INTERVAL); + application.SendNotification(); + gCallBackCalled = false; + + object->RemovePropertyNotification(); + + object->mActor.SetPosition(Vector3(200.0f, 0.0f, 0.0f)); + application.Render(RENDER_FRAME_INTERVAL); + application.SendNotification(); + application.Render(RENDER_FRAME_INTERVAL); + application.SendNotification(); + DALI_TEST_CHECK( !gCallBackCalled ); + + tet_infoline(" UtcDaliAddPropertyNotificationCallback - Removing all notifications and it's owning object, should not receive a notification"); + object->Initialize(); + application.Render(RENDER_FRAME_INTERVAL); + application.SendNotification(); + gCallBackCalled = false; + + object->RemovePropertyNotifications(); + + object->mActor.SetPosition(Vector3(200.0f, 0.0f, 0.0f)); + application.Render(RENDER_FRAME_INTERVAL); + application.SendNotification(); + application.Render(RENDER_FRAME_INTERVAL); + application.SendNotification(); + DALI_TEST_CHECK( !gCallBackCalled ); + + + delete object; + END_TEST; +} + +int UtcDaliAddPropertyNotificationTypeProperty(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Currently, Type registry properties cannot be animated + try + { + actor.AddPropertyNotification( PROPERTY_REGISTRATION_START_INDEX, GreaterThanCondition( 100.0f ) ); + } + catch ( DaliException& e ) + { + DALI_TEST_ASSERT_CONDITION_STARTS_WITH_SUBSTRING( e, "false && \"Property notification added to non animatable property", TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliPropertyNotificationGetCondition(void) +{ + TestApplication application; + tet_infoline(" UtcDaliPropertyNotificationGetCondition"); + + Actor actor = Actor::New(); + + PropertyCondition condition = GreaterThanCondition(100.0f); + PropertyNotification notification = actor.AddPropertyNotification(Actor::POSITION_X, condition); + DALI_TEST_CHECK( condition == notification.GetCondition() ); + END_TEST; +} + +class PropertyNotificationConstWrapper +{ +public: + + PropertyNotificationConstWrapper(PropertyNotification propertyNotification) + :mPropertyNotification(propertyNotification) + { + + } + + /** + * Returns const reference to property notification. + * @return const reference. + */ + const PropertyCondition& GetCondition() const + { + return mPropertyNotification.GetCondition(); + } + + PropertyNotification mPropertyNotification; +}; + +int UtcDaliPropertyNotificationGetConditionConst(void) +{ + TestApplication application; + tet_infoline(" UtcDaliPropertyNotificationGetConditionConst"); + + Actor actor = Actor::New(); + + PropertyCondition condition = GreaterThanCondition(100.0f); + PropertyNotification notification = actor.AddPropertyNotification(Actor::POSITION_X, condition); + PropertyNotificationConstWrapper notificationConst(notification); + const PropertyCondition& conditionReference1 = notificationConst.GetCondition(); + const PropertyCondition& conditionReference2 = notificationConst.GetCondition(); + + DALI_TEST_CHECK( (&conditionReference1) == (&conditionReference2) ); + DALI_TEST_CHECK( conditionReference1 == condition ); + END_TEST; +} + +int UtcDaliPropertyNotificationGetTarget(void) +{ + TestApplication application; + tet_infoline(" UtcDaliPropertyNotificationGetTarget"); + + Actor actor = Actor::New(); + Actor actor2 = Actor::New(); + + PropertyNotification notification = actor.AddPropertyNotification(Actor::POSITION_X, + GreaterThanCondition(100.0f)); + Actor targetActor = Actor::DownCast( notification.GetTarget() ); + + DALI_TEST_CHECK( targetActor == actor ); + END_TEST; +} + +int UtcDaliPropertyNotificationGetProperty(void) +{ + TestApplication application; + tet_infoline(" UtcDaliPropertyNotificationGetProperty"); + + Actor actor = Actor::New(); + + PropertyNotification notification = actor.AddPropertyNotification(Actor::POSITION_X, + GreaterThanCondition(100.0f)); + Property::Index targetProperty = notification.GetTargetProperty(); + + DALI_TEST_EQUALS( targetProperty, Actor::POSITION_X, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliPropertyNotificationGetNotifyMode(void) +{ + TestApplication application; + tet_infoline(" UtcDaliPropertyNotificationGetNotifyMode"); + + Actor actor = Actor::New(); + + PropertyNotification notification = actor.AddPropertyNotification(Actor::POSITION_X, + GreaterThanCondition(100.0f)); + notification.SetNotifyMode(PropertyNotification::NotifyOnChanged); + PropertyNotification::NotifyMode notifyMode = notification.GetNotifyMode(); + + DALI_TEST_EQUALS( notifyMode, PropertyNotification::NotifyOnChanged, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliPropertyNotificationGreaterThan(void) +{ + TestApplication application; + tet_infoline(" UtcDaliPropertyNotificationGreaterThan"); + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + PropertyNotification notification = actor.AddPropertyNotification( Actor::POSITION_X, GreaterThanCondition(100.0f) ); + notification.NotifySignal().Connect( &TestCallback ); + + actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + + // Move right to satisfy condition + gCallBackCalled = false; + actor.SetPosition(Vector3(200.0f, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + + // Move left to un-satisfy condition + gCallBackCalled = false; + actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( !gCallBackCalled ); + + // Move right to satisfy condition again. + gCallBackCalled = false; + Wait(application, DEFAULT_WAIT_PERIOD); + actor.SetPosition(Vector3(200.0f, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + END_TEST; +} + +int UtcDaliPropertyNotificationLessThan(void) +{ + TestApplication application; + tet_infoline(" UtcDaliPropertyNotificationLessThan"); + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + PropertyNotification notification = actor.AddPropertyNotification( Actor::POSITION_X, LessThanCondition(100.0f ) ); + notification.NotifySignal().Connect( &TestCallback ); + + actor.SetPosition(Vector3(200.0f, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + + // Move left to satisfy condition + gCallBackCalled = false; + actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + + // Move right to un-satisfy condition + gCallBackCalled = false; + actor.SetPosition(Vector3(200.0f, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( !gCallBackCalled ); + + // Move left to satisfy condition again. + gCallBackCalled = false; + Wait(application, DEFAULT_WAIT_PERIOD); + actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + END_TEST; +} + +int UtcDaliPropertyNotificationInside(void) +{ + TestApplication application; + tet_infoline(" UtcDaliPropertyNotificationInside"); + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + PropertyNotification notification = actor.AddPropertyNotification( Actor::POSITION_X, InsideCondition(100.0f, 200.0f) ); + notification.NotifySignal().Connect( &TestCallback ); + + actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + + // Move inside to satisfy condition + gCallBackCalled = false; + actor.SetPosition(Vector3(150.0f, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + + // Move outside (right) to un-satisfy condition + gCallBackCalled = false; + actor.SetPosition(Vector3(300.0f, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( !gCallBackCalled ); + + // Move inside to satisfy condition again. + gCallBackCalled = false; + Wait(application, DEFAULT_WAIT_PERIOD); + actor.SetPosition(Vector3(150.0f, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + END_TEST; +} + +int UtcDaliPropertyNotificationOutside(void) +{ + TestApplication application; + tet_infoline(" UtcDaliPropertyNotificationOutside"); + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + PropertyNotification notification = actor.AddPropertyNotification( Actor::POSITION_X, OutsideCondition(100.0f, 200.0f) ); + notification.NotifySignal().Connect( &TestCallback ); + + actor.SetPosition(Vector3(150.0f, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + + // Move outside (left) to satisfy condition + gCallBackCalled = false; + actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + + // Move inside to un-satisfy condition + gCallBackCalled = false; + actor.SetPosition(Vector3(150.0f, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( !gCallBackCalled ); + + // Move outside (right) to satisfy condition again. + gCallBackCalled = false; + Wait(application, DEFAULT_WAIT_PERIOD); + actor.SetPosition(Vector3(300.0f, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + END_TEST; +} + +int UtcDaliPropertyNotificationVectorComponentGreaterThan(void) +{ + TestApplication application; + tet_infoline(" UtcDaliPropertyNotificationGreaterThan"); + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + PropertyNotification notification = actor.AddPropertyNotification( Actor::POSITION, 0, GreaterThanCondition(100.0f) ); + notification.NotifySignal().Connect( &TestCallback ); + notification = actor.AddPropertyNotification( Actor::POSITION, 1, GreaterThanCondition(100.0f) ); + notification.NotifySignal().Connect( &TestCallback ); + notification = actor.AddPropertyNotification( Actor::POSITION, 2, GreaterThanCondition(100.0f) ); + notification.NotifySignal().Connect( &TestCallback ); + notification = actor.AddPropertyNotification( Actor::COLOR, 3, GreaterThanCondition(0.5f) ); + notification.NotifySignal().Connect( &TestCallback ); + + actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f)); + actor.SetColor(Vector4(0.0f, 0.0f, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + + // Move right to satisfy XAxis condition + gCallBackCalled = false; + actor.SetPosition(Vector3(200.0f, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + + // Move down to satisfy YAxis condition + gCallBackCalled = false; + actor.SetPosition(Vector3(200.0f, 200.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + + // Move forward to satisfy ZAxis + gCallBackCalled = false; + Wait(application, DEFAULT_WAIT_PERIOD); + actor.SetPosition(Vector3(200.0f, 200.0f, 200.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + + // Change alpha Colour to satisfy w/alpha component condition + gCallBackCalled = false; + Wait(application, DEFAULT_WAIT_PERIOD); + actor.SetColor(Vector4(0.0f, 0.0f, 0.0f, 1.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + END_TEST; +} + +int UtcDaliPropertyNotificationVectorComponentLessThan(void) +{ + TestApplication application; + tet_infoline(" UtcDaliPropertyNotificationLessThan"); + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + PropertyNotification notification = actor.AddPropertyNotification( Actor::POSITION, 0, LessThanCondition(-100.0f) ); + notification.NotifySignal().Connect( &TestCallback ); + notification = actor.AddPropertyNotification( Actor::POSITION, 1, LessThanCondition(-100.0f) ); + notification.NotifySignal().Connect( &TestCallback ); + notification = actor.AddPropertyNotification( Actor::POSITION, 2, LessThanCondition(-100.0f) ); + notification.NotifySignal().Connect( &TestCallback ); + notification = actor.AddPropertyNotification( Actor::COLOR, 3, LessThanCondition(0.5f) ); + notification.NotifySignal().Connect( &TestCallback ); + + actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f)); + actor.SetColor(Vector4(0.0f, 0.0f, 0.0f, 1.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + + // Move left to satisfy XAxis condition + gCallBackCalled = false; + actor.SetPosition(Vector3(-200.0f, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + + // Move up to satisfy YAxis condition + gCallBackCalled = false; + actor.SetPosition(Vector3(-200.0f, -200.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + + // Move back to satisfy ZAxis + gCallBackCalled = false; + Wait(application, DEFAULT_WAIT_PERIOD); + actor.SetPosition(Vector3(-200.0f, -200.0f, -200.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + + // Change alpha Colour to satisfy w/alpha component condition + gCallBackCalled = false; + Wait(application, DEFAULT_WAIT_PERIOD); + actor.SetColor(Vector4(0.0f, 0.0f, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + END_TEST; +} + +int UtcDaliPropertyNotificationVectorComponentInside(void) +{ + TestApplication application; + tet_infoline(" UtcDaliPropertyNotificationInside"); + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + PropertyNotification notification = actor.AddPropertyNotification( Actor::POSITION, 0, InsideCondition(-100.0f, 100.0f) ); + notification.NotifySignal().Connect( &TestCallback ); + notification = actor.AddPropertyNotification( Actor::POSITION, 1, InsideCondition(-100.0f, 100.0f) ); + notification.NotifySignal().Connect( &TestCallback ); + notification = actor.AddPropertyNotification( Actor::POSITION, 2, InsideCondition(-100.0f, 100.0f) ); + notification.NotifySignal().Connect( &TestCallback ); + notification = actor.AddPropertyNotification( Actor::COLOR, 3, InsideCondition(0.25f, 0.75f) ); + notification.NotifySignal().Connect( &TestCallback ); + + // set outside all conditions + actor.SetPosition(Vector3(200.0f, 200.0f, 200.0f)); + actor.SetColor(Vector4(0.0f, 0.0f, 0.0f, 1.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + + // Move x to inside condition + gCallBackCalled = false; + actor.SetPosition(Vector3(0.0f, 200.0f, 200.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + + // Move y to inside condition + gCallBackCalled = false; + actor.SetPosition(Vector3(0.0f, 0.0f, 200.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + + // Move z to inside condition + gCallBackCalled = false; + Wait(application, DEFAULT_WAIT_PERIOD); + actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + + // change alpha to inside condition + gCallBackCalled = false; + Wait(application, DEFAULT_WAIT_PERIOD); + actor.SetColor(Vector4(0.0f, 0.0f, 0.0f, 0.5f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + END_TEST; +} + +int UtcDaliPropertyNotificationVectorComponentOutside(void) +{ + TestApplication application; + tet_infoline(" UtcDaliPropertyNotificationOutside"); + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + PropertyNotification notification = actor.AddPropertyNotification( Actor::POSITION, 0, OutsideCondition(-100.0f, 100.0f) ); + notification.NotifySignal().Connect( &TestCallback ); + notification = actor.AddPropertyNotification( Actor::POSITION, 1, OutsideCondition(-100.0f, 100.0f) ); + notification.NotifySignal().Connect( &TestCallback ); + notification = actor.AddPropertyNotification( Actor::POSITION, 2, OutsideCondition(-100.0f, 100.0f) ); + notification.NotifySignal().Connect( &TestCallback ); + notification = actor.AddPropertyNotification( Actor::COLOR, 3, OutsideCondition(0.25f, 0.75f) ); + notification.NotifySignal().Connect( &TestCallback ); + + // set inside all conditions + actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f)); + actor.SetColor(Vector4(0.0f, 0.0f, 0.0f, 0.5f)); + Wait(application, DEFAULT_WAIT_PERIOD); + + // Move x to outside condition + gCallBackCalled = false; + actor.SetPosition(Vector3(200.0f, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + + // Move y to outside condition + gCallBackCalled = false; + actor.SetPosition(Vector3(200.0f, 200.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + + // Move z to outside condition + gCallBackCalled = false; + Wait(application, DEFAULT_WAIT_PERIOD); + actor.SetPosition(Vector3(200.0f, 200.0f, 200.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + + // change alpha to outside condition + gCallBackCalled = false; + Wait(application, DEFAULT_WAIT_PERIOD); + actor.SetColor(Vector4(0.0f, 0.0f, 0.0f, 1.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + END_TEST; +} + +int UtcDaliPropertyConditionGetArguments(void) +{ + TestApplication application; + tet_infoline(" UtcDaliPropertyConditionGetArguments"); + + PropertyCondition condition = GreaterThanCondition( 50.0f ); + PropertyCondition::ArgumentContainer arguments = condition.GetArguments(); + + DALI_TEST_EQUALS( arguments.size(), 1u, TEST_LOCATION ); + Property::Value value = arguments[0]; + DALI_TEST_EQUALS( value.Get(), 50.0f, TEST_LOCATION ); + + condition = InsideCondition( 125.0f, 250.0f ); + arguments = condition.GetArguments(); + + DALI_TEST_EQUALS( arguments.size(), 2u, TEST_LOCATION ); + Property::Value value1 = arguments[0]; + Property::Value value2 = arguments[1]; + DALI_TEST_EQUALS( value1.Get(), 125.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( value2.Get(), 250.0f, TEST_LOCATION ); + END_TEST; +} + +namespace +{ + +class PropertyConditionConstWrapper +{ +public: + + PropertyConditionConstWrapper(PropertyCondition propertyCondition) + :mPropertyCondition(propertyCondition) + { + + } + + /** + * Returns const reference to property arguments. + * @return const reference. + */ + const PropertyCondition::ArgumentContainer& GetArguments() const + { + return mPropertyCondition.GetArguments(); + } + + PropertyCondition mPropertyCondition; +}; +} // anon namespace + +int UtcDaliPropertyConditionGetArgumentsConst(void) +{ + TestApplication application; + tet_infoline(" UtcDaliPropertyConditionGetArgumentsConst"); + + PropertyCondition condition = GreaterThanCondition( 50.0f ); + PropertyConditionConstWrapper conditionConst(condition); + const PropertyCondition::ArgumentContainer& argumentsRef1 = conditionConst.GetArguments(); + const PropertyCondition::ArgumentContainer& argumentsRef2 = conditionConst.GetArguments(); + + DALI_TEST_CHECK( (&argumentsRef1) == (&argumentsRef2) ); + DALI_TEST_EQUALS( argumentsRef1.size(), 1u, TEST_LOCATION ); + Property::Value value = argumentsRef1[0]; + DALI_TEST_EQUALS( value.Get(), 50.0f, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliPropertyNotificationStep(void) +{ + TestApplication application; + tet_infoline(" UtcDaliPropertyNotificationStep"); + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + const float step = 100.0f; + // float + PropertyNotification notification = actor.AddPropertyNotification( Actor::POSITION, 0, StepCondition(step, 50.0f) ); + notification.NotifySignal().Connect( &TestCallback ); + + // set initial position + actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + + // test both directions + for( int i = 1 ; i < 10 ; ++i ) + { + // Move x to negative position + gCallBackCalled = false; + actor.SetPosition(Vector3((i * step), 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + } + + for( int i = 1 ; i < 10 ; ++i ) + { + // Move x to negative position + gCallBackCalled = false; + actor.SetPosition(Vector3(-(i * step), 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + } + END_TEST; +} + +int UtcDaliPropertyNotificationVariableStep(void) +{ + TestApplication application; + tet_infoline(" UtcDaliPropertyNotificationStep"); + + Actor actor = Actor::New(); + Stage::GetCurrent().Add(actor); + + std::vector values; + + const float averageStep = 100.0f; + + for( int i = 1 ; i < 10 ; i++ ) + { + values.push_back(i * averageStep + (i % 2 == 0 ? -(averageStep * 0.2f) : (averageStep * 0.2f))); + } + // float + PropertyNotification notification = actor.AddPropertyNotification( Actor::POSITION, 0, VariableStepCondition(values) ); + notification.NotifySignal().Connect( &TestCallback ); + + // set initial position lower than first position in list + actor.SetPosition(Vector3(values[0] - averageStep, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + + for( unsigned int i = 0 ; i < values.size() - 1 ; ++i ) + { + gCallBackCalled = false; + // set position half way between the current values + float position = values[i] + (0.5f * (values[i + 1] - values[i])); + actor.SetPosition(Vector3(position, 0.0f, 0.0f)); + Wait(application, DEFAULT_WAIT_PERIOD); + DALI_TEST_CHECK( gCallBackCalled ); + } + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Quaternion.cpp b/automated-tests/src/dali/utc-Dali-Quaternion.cpp new file mode 100644 index 0000000..8391302 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-Quaternion.cpp @@ -0,0 +1,1090 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; + + +void utc_dali_quaternion_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_quaternion_cleanup(void) +{ + test_return_value = TET_PASS; +} + + +int UtcDaliQuaternionCtor01(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion r; + DALI_TEST_EQUALS(r.AsVector().w, 1.0f, TEST_LOCATION); + DALI_TEST_EQUALS(r.AsVector().x, 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS(r.AsVector().y, 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS(r.AsVector().z, 0.0f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionCtor02(void) +{ + TestApplication application; // Reset all test adapter return codes + + Quaternion r(M_PI/2.0f, Vector4(1.0f, 2.0f, 3.0f, M_PI/3.0f)); + + // This will be normalised: + DALI_TEST_EQUALS(r.AsVector().w, 0.707f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(r.AsVector().x, 0.189f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(r.AsVector().y, 0.378f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(r.AsVector().z, 0.567f, 0.001, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliQuaternionCtor03(void) +{ + TestApplication application; // Reset all test adapter return codes + + // Test from euler angles + Quaternion e1(Radian(Degree(45)), 0.0f, 0.0f); + Vector4 r1(0.383f, 0.0f, 0.0f, 0.924f); + + Quaternion e2(0.0f, Radian(Degree(75)), 0.0f); + Vector4 r2(0.0f, 0.609f, 0.0f, 0.793f); + + Quaternion e3(0.0f, 0.0f, Radian(Degree(135))); + Vector4 r3(0.0f, 0.0f, 0.924f, 0.383f); + + Quaternion e4(Radian(Degree(71)), Radian(Degree(36)), Radian(Degree(27))); + Vector4 r4(0.478f, 0.374f, 0.006f, 0.795f); + + Quaternion e5(Radian(Degree(-31)), Radian(Degree(-91)), Radian(Degree(-173))); + Vector4 r5(-0.697f, 0.145f, -0.686f, -0.149f); + + DALI_TEST_EQUALS(e1.AsVector(), r1, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(e2.AsVector(), r2, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(e3.AsVector(), r3, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(e4.AsVector(), r4, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(e5.AsVector(), r5, 0.001, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliQuaternionFromAxisAngle(void) +{ + TestApplication application; // Reset all test adapter return codes + + Quaternion q = Quaternion::FromAxisAngle(Vector4(1.0f, 2.0f, 3.0f, M_PI/3.0f), M_PI/2.0f); + + Quaternion r(0.707f, 0.189f, 0.378f, 0.567f); + + DALI_TEST_EQUALS(q, r, 0.001, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionToAxisAngle01(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q(0.932f, 1.1f, 3.4f, 2.7f); + float angle; + Vector3 axis; + bool converted = q.ToAxisAngle(axis, angle); + DALI_TEST_EQUALS(converted, true, TEST_LOCATION); + DALI_TEST_EQUALS(angle, 0.74f, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(axis.x, 3.03f, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(axis.y, 9.38f, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(axis.z, 7.45f, 0.01f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionToAxisAngle02(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q(0.932f, 1.1f, 3.4f, 2.7f); + float angle; + Vector4 axis; + bool converted = q.ToAxisAngle(axis, angle); + DALI_TEST_EQUALS(converted, true, TEST_LOCATION); + DALI_TEST_EQUALS(angle, 0.74f, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(axis.x, 3.03f, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(axis.y, 9.38f, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(axis.z, 7.45f, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(axis.w, 0.0f, 0.01f, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliQuaternionToAxisAngle03(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q(1, 2, 3, 4); + float angle; + Vector3 axis; + bool converted = q.ToAxisAngle(axis, angle); + DALI_TEST_EQUALS(converted, false, TEST_LOCATION); + DALI_TEST_EQUALS(angle, 0.0f, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(axis.x, 0.0f, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(axis.y, 0.0f, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(axis.z, 0.0f, 0.01f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionToAxisAngle04(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q(1, 2, 3, 4); + float angle; + Vector4 axis; + bool converted = q.ToAxisAngle(axis, angle); + DALI_TEST_EQUALS(converted, false, TEST_LOCATION); + DALI_TEST_EQUALS(angle, 0.0f, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(axis.x, 0.0f, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(axis.y, 0.0f, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(axis.z, 0.0f, 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(axis.w, 0.0f, 0.01f, TEST_LOCATION); + END_TEST; +} + + + +int UtcDaliQuaternionEulerAngles(void) +{ + TestApplication application; // Reset all test adapter return codes + + Quaternion q1(0.924f, 0.383f, 0.0f, 0.0f); + Vector4 r1(Radian(Degree(45)), 0.0f, 0.0f, 0.0f); + + Quaternion q2(0.793f, 0.0f, 0.609f, 0.0f); + Vector4 r2(0.0f, Radian(Degree(75)), 0.0f, 0.0f); + + Quaternion q3(0.383f, 0.0f, 0.0f, 0.924f); + Vector4 r3(0.0f, 0.0f, Radian(Degree(135)), 0.0f); + + Quaternion q4(0.795f, 0.478f, 0.374f, 0.006f); + Vector4 r4(Radian(Degree(71)), Radian(Degree(36)), Radian(Degree(27)), 0.0f); + + Quaternion q5( -0.149f, -0.697f, 0.145f, -0.686f); + Vector4 r5(Radian(Degree(148.0)), Radian(Degree(-88.2)), Radian(Degree(8.0)), 0.0f); + + DALI_TEST_EQUALS(q1.EulerAngles(), r1, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(q2.EulerAngles(), r2, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(q3.EulerAngles(), r3, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(q4.EulerAngles(), r4, 0.01, TEST_LOCATION); + DALI_TEST_EQUALS(q5.EulerAngles(), r5, 0.01, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliQuaternionToMatrix01(void) +{ + TestApplication application; // Reset all test adapter return codes + + Quaternion q(0.69813, Vector4(1.0f, 0.0f, 0.0f, 0.0f)); // 40 degree rotation around X axis + + // Result calculated using a different maths library (with appropriate row/col ordering) + + float els[] = { 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.766f, 0.643f, 0.0f, + 0.0f, -0.643f, 0.766f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f }; + Matrix mRes(els); + Matrix m(q); + + DALI_TEST_EQUALS(m, mRes, 0.01, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionToMatrix02(void) +{ + TestApplication application; // Reset all test adapter return codes + + // rotation around arbitrary axis + Quaternion q2(-1.23918f, Vector4(7.0f, -13.0f, 11.0f, 0.0f)); + + float els[] = { 0.423f, -0.746f, -0.514f, 0.00f, + 0.384f, 0.662f, -0.644f, 0.00f, + 0.821f, 0.075f, 0.566f, 0.00f, + 0.000f, 0.000f, 0.000f, 1.00f }; + Matrix mRes2(els); + + Matrix m2(q2); + + DALI_TEST_EQUALS(m2, mRes2, 0.01, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliQuaternionFromMatrix01(void) +{ + TestApplication application; // Reset all test adapter return codes + + // IDENTITY rotation + Quaternion q; + + Matrix m(q); // Convert to matrix + + Quaternion q2(m); // and back to a quaternion + + DALI_TEST_EQUALS(q, q2, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(m, Matrix::IDENTITY, 0.001f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionFromMatrix02(void) +{ + TestApplication application; // Reset all test adapter return codes + + // Create an arbitrary forward vector + for( float x=-1.0f; x<=1.0f; x+=0.1f ) + { + for( float y=-1.0f; y<1.0f; y+=0.1f ) + { + for( float z=-1.0f; z<1.0f; z+=0.1f ) + { + Vector3 vForward(x, y, z); + vForward.Normalize(); + + // Construct an up vector from a sideways move + Vector3 vSide; + Vector3 vUp = vForward.Cross(Vector3(vForward.x+1.0f, vForward.y, vForward.z)); + if(vUp.Length() > 0.01 ) + { + vUp.Normalize(); + vSide = vUp.Cross(vForward); + vSide.Normalize(); + } + else + { + vSide = vForward.Cross(Vector3(vForward.x, vForward.y+1.0f, vForward.z)); + vSide.Normalize(); + vUp = vForward.Cross(vSide); + vUp.Normalize(); + } + + // Generate a matrix, and then a quaternion from it + Matrix rotMatrix(Matrix::IDENTITY); + rotMatrix.SetXAxis(vSide); + rotMatrix.SetYAxis(vUp); + rotMatrix.SetZAxis(vForward); + Quaternion q( rotMatrix ); + + // Generate a matrix from the quaternion, check they are the same + Matrix resultMatrix(q); + DALI_TEST_EQUALS(resultMatrix, rotMatrix, 0.001f, TEST_LOCATION); + + // Rotate an arbitrary vector by both quaternion and rotation matrix, + // check the result is the same + + Vector4 aVector(-2.983f, -3.213f, 8.2239f, 1.0f); + Vector3 aVectorRotatedByQ = q.Rotate(Vector3(aVector)); + Vector4 aVectorRotatedByR = rotMatrix*aVector; + DALI_TEST_EQUALS(aVectorRotatedByQ, Vector3(aVectorRotatedByR), 0.001f, TEST_LOCATION); + } + } + } + END_TEST; +} + +int UtcDaliQuaternionFromAxes01(void) +{ + TestApplication application; // Reset all test adapter return codes + + Vector3 xAxis( Vector3::XAXIS ); + Vector3 yAxis( Vector3::YAXIS ); + Vector3 zAxis( Vector3::ZAXIS ); + + Quaternion q1( xAxis, yAxis, zAxis); + + DALI_TEST_EQUALS( q1, Quaternion::IDENTITY, TEST_LOCATION ); + + xAxis = Vector3( 1.0f, 1.0f, 0.0f ); + xAxis.Normalize(); + yAxis = Vector3( -1.0f, 1.0f, 0.0f ); // 45 degrees anticlockwise (+ve) around z + yAxis.Normalize(); + zAxis = xAxis.Cross(yAxis); + zAxis.Normalize(); + Quaternion q2( xAxis, yAxis, zAxis ); + + DALI_TEST_EQUALS( q2, Quaternion(Radian(Degree(45)), Vector3::ZAXIS), 0.001f, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliQuaternionFromAxes02(void) +{ + TestApplication application; // Reset all test adapter return codes + + // Create an arbitrary forward vector + for( float x=-1.0f; x<=1.0f; x+=0.1f ) + { + for( float y=-1.0f; y<1.0f; y+=0.1f ) + { + for( float z=-1.0f; z<1.0f; z+=0.1f ) + { + Vector3 vForward(x, y, z); + vForward.Normalize(); + + // Construct an up vector from a sideways move + Vector3 vSide; + Vector3 vUp = vForward.Cross(Vector3(vForward.x+1.0f, vForward.y, vForward.z)); + if(vUp.Length() > 0.01 ) + { + vUp.Normalize(); + vSide = vUp.Cross(vForward); + vSide.Normalize(); + } + else + { + vSide = vForward.Cross(Vector3(vForward.x, vForward.y+1.0f, vForward.z)); + vSide.Normalize(); + vUp = vForward.Cross(vSide); + vUp.Normalize(); + } + + // Generate a quaternion + Quaternion q( vSide, vUp, vForward ); + + Matrix rotMatrix; + rotMatrix.SetXAxis(vSide); + rotMatrix.SetYAxis(vUp); + rotMatrix.SetZAxis(vForward); + + // Generate a matrix from the quaternion, check they are the same + Matrix m(q); + DALI_TEST_EQUALS(m.GetXAxis(), vSide, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(m.GetYAxis(), vUp, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(m.GetZAxis(), vForward, 0.001f, TEST_LOCATION); + + // Rotate an arbitrary vector by both quaternion and rotation matrix, + // check the result is the same + + Vector4 aVector(2.043f, 12.8f, -3.872f, 1.0f); + Vector3 aVectorRotatedByQ = q.Rotate(Vector3(aVector)); + Vector4 aVectorRotatedByR = rotMatrix*aVector; + DALI_TEST_EQUALS(aVectorRotatedByQ, Vector3(aVectorRotatedByR), 0.001f, TEST_LOCATION); + } + } + } + END_TEST; +} + +int UtcDaliQuaternionOperatorAddition(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q1(0.383f, 0.0f, 0.0f, 0.924f); + Quaternion q2(0.0f, 0.609f, 0.0f, 0.793f); + + Quaternion r1(0.383f, 0.609f, 0.0f, 1.717f); + + DALI_TEST_EQUALS(q1+q2, r1, 0.001f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionOperatorSubtraction(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q1(0.383f, 0.450f, 0.123f, 0.924f); + Quaternion q2(0.383f, 0.690f, 0.234f, 1.917f); + + Quaternion r1(0.0f, 0.240f, 0.111f, 0.993f); + + DALI_TEST_EQUALS(q2-q1, r1, 0.001f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionConjugate(void) +{ + TestApplication application; // Reset all test adapter return codes + float s1=0.784f; Vector3 v1(0.045f, 0.443f, 0.432f); + float s2=0.697f; Vector3 v2(0.612, 0.344, -0.144); + + Quaternion q1(s1, v1.x, v1.y, v1.z); + Quaternion q2(s2, v2.x, v2.y, v2.z); + q1.Conjugate(); + q2.Conjugate(); + + Quaternion r1(s1, -v1.x, -v1.y, -v1.z); + Quaternion r2(s2, -v2.x, -v2.y, -v2.z); + + DALI_TEST_EQUALS(q1, r1, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(q2, r2, 0.001f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionOperatorMultiplication01(void) +{ + TestApplication application; // Reset all test adapter return codes + float s1=0.784f; Vector3 v1(0.045f, 0.443f, 0.432f); + float s2=0.697f; Vector3 v2(0.612, 0.344, -0.144); + + Quaternion q1(s1, v1.x, v1.y, v1.z); + Quaternion q2(s2, v2.x, v2.y, v2.z); + + Vector3 vp = v1.Cross(v2) + v2*s1 + v1*s2; + Quaternion r1(s1*s2-v1.Dot(v2), vp.x, vp.y, vp.z); + + DALI_TEST_EQUALS(q1*q2, r1, 0.001f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionOperatorDivision(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q1(0.383f, 0.0f, 0.0f, 0.924f); + Quaternion q2(0.0f, 0.609f, 0.0f, 0.793f); + + // q1 / q2 = q1 * q2^-1 + // q2^-1 = q2* / ||q2||^2 + // = Conjugate of q2 / Square of Norm of q2 + + Quaternion r1 = q2; + r1.Conjugate(); + r1 *= 1.0f/q2.LengthSquared(); + Quaternion r2 = q1 * r1; + + DALI_TEST_EQUALS(q1 / q2, r2, 0.001f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionOperatorScale01(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q1(0.383f, 0.0f, 0.0f, 0.924f); + Quaternion r1(2.0f* 0.383f, 0.0f, 0.0f, 2.0f * 0.924f); + + DALI_TEST_EQUALS(q1 * 2.0f, r1, 0.001f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionOperatorScale02(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q1(0.383f, 0.0f, 0.0f, 0.924f); + Quaternion r1(0.5f* 0.383f, 0.0f, 0.0f, 0.5f * 0.924f); + + DALI_TEST_EQUALS(q1 / 2.0f, r1, 0.001f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionOperatorNegation(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q1(0.383f, 0.0f, 0.0f, 0.924f); + Quaternion r1(-0.383f, -0.0f, -0.0f, -0.924f); + + DALI_TEST_EQUALS(-q1, r1, 0.001f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionOperatorAddAssign(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q1(0.383f, 0.0f, 0.0f, 0.924f); + Quaternion q2(0.0f, 0.609f, 0.0f, 0.793f); + + Quaternion r1(0.383f, 0.609f, 0.0f, 1.717f); + + q1 += q2; + DALI_TEST_EQUALS(q1, r1, 0.001f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionOperatorSubtractAssign(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q1(0.383f, 0.450f, 0.123f, 0.924f); + Quaternion q2(0.383f, 0.690f, 0.234f, 1.917f); + + Quaternion r1(0.0f, 0.240f, 0.111f, 0.993f); + q2 -= q1; + DALI_TEST_EQUALS(q2, r1, 0.001f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionOperatorMultiplyAssign(void) +{ + TestApplication application; // Reset all test adapter return codes + float s1=0.784f; Vector3 v1(0.045f, 0.443f, 0.432f); + float s2=0.697f; Vector3 v2(0.612, 0.344, -0.144); + + Quaternion q1(s1, v1.x, v1.y, v1.z); + Quaternion q2(s2, v2.x, v2.y, v2.z); + + Quaternion r3 = q2 * q1; + q2 *= q1; + DALI_TEST_EQUALS(q2, r3, 0.001f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionOperatorScaleAssign01(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q1(0.383f, 0.450f, 0.123f, 0.924f); + float scale = 2.5f; + Quaternion r1(scale*0.383f, scale*0.450f, scale*0.123f, scale*0.924f); + q1 *= scale; + DALI_TEST_EQUALS(q1, r1, 0.001f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionOperatorScaleAssign02(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q1(0.383f, 0.450f, 0.123f, 0.924f); + float scale = 2.5f; + Quaternion r1(0.383f/scale, 0.450f/scale, 0.123f/scale, 0.924f/scale); + q1 /= scale; + DALI_TEST_EQUALS(q1, r1, 0.001f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionOperatorEquality(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q1(0.383f, 0.450f, 0.123f, 0.924f); + Quaternion q2(0.383f, 0.450f, 0.123f, 0.924f); + Quaternion q3(0.383f, 0.450f, 0.123f, 0.800f); + Quaternion q4(0.383f, 0.450f, 0.100f, 0.800f); + Quaternion q5(0.383f, 0.100f, 0.100f, 0.800f); + Quaternion q6(0.100f, 0.100f, 0.100f, 0.800f); + + Quaternion q7(-0.383f, -0.450f, -0.123f, -0.924f); + Quaternion q8(-0.383f, -0.450f, -0.123f, 0.924f); + Quaternion q9(-0.383f, -0.450f, 0.123f, 0.924f); + Quaternion q10(-0.383f, 0.450f, 0.123f, 0.924f); + + DALI_TEST_CHECK( q1 == q2 ); + DALI_TEST_CHECK( !(q1 == q3) ); + DALI_TEST_CHECK( !(q1 == q4) ); + DALI_TEST_CHECK( !(q1 == q5) ); + DALI_TEST_CHECK( !(q1 == q6) ); + DALI_TEST_CHECK( (q1 == q7) ); + DALI_TEST_CHECK( !(q1 == q8) ); + DALI_TEST_CHECK( !(q1 == q9) ); + DALI_TEST_CHECK( !(q1 == q10) ); + END_TEST; +} + +int UtcDaliQuaternionOperatorInequality(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q1(0.383f, 0.450f, 0.123f, 0.924f); + Quaternion q2(0.383f, 0.450f, 0.123f, 0.924f); + Quaternion q3(-0.383f, -0.0f, -0.0f, -0.924f); + DALI_TEST_CHECK( !(q1 != q2) ); + DALI_TEST_CHECK( q1 != q3 ); + END_TEST; +} + +int UtcDaliQuaternionLength(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q1(0.383f, 0.450f, 0.123f, 0.924f); + float length = sqrtf(0.383f*0.383f + 0.450f*0.450f + 0.123f*0.123f + 0.924f*0.924f); + DALI_TEST_EQUALS(q1.Length(), length, 0.01f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionLengthSquared(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q1(0.383f, 0.450f, 0.123f, 0.924f); + float lengthSquared = 0.383f*0.383f + 0.450f*0.450f + 0.123f*0.123f + 0.924f*0.924f; + DALI_TEST_EQUALS(q1.LengthSquared(), lengthSquared, 0.01f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionNormalize(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q1(0.118f, 0.692f, -0.127f, 0.701f); + Quaternion q2 = q1; + q2 *= 5.0f; + q2.Normalize(); + DALI_TEST_EQUALS(q1, q2, 0.001f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionNormalized(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q1(0.118f, 0.692f, -0.127f, 0.701f); + Quaternion q2 = q1; + q2 *= 5.0f; + DALI_TEST_EQUALS(q1, q2.Normalized(), 0.001f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionInvert(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q1(0.383f, 0.0f, 0.0f, 0.924f); + + // q1^-1 = q1* / ||q1||^2 + // = Conjugate of q1 / Square of Norm of q1 + + Quaternion r1 = q1; + r1.Conjugate(); + r1 *= 1.0f/q1.LengthSquared(); + + Quaternion q2 = q1; + q2.Invert(); + DALI_TEST_EQUALS(q2, r1, 0.001f, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliQuaternionDot(void) +{ + TestApplication application; // Reset all test adapter return codes + // q.q' = s*s' + v dot v' + float s1=0.784f; Vector3 v1(0.045f, 0.443f, 0.432f); + float s2=0.697f; Vector3 v2(0.612, 0.344, -0.144); + + Quaternion q1(s1, v1.x, v1.y, v1.z); + Quaternion q2(s2, v2.x, v2.y, v2.z); + + float r1 = s1*s2 + v1.Dot(v2); + + DALI_TEST_EQUALS(Quaternion::Dot(q1, q2), r1, TEST_LOCATION); + END_TEST; +} + + +// Quaternion * vector == Vector rotation +int UtcDaliQuaternionOperatorMultiplication02(void) +{ + TestApplication application; // Reset all test adapter return codes + // Rotation of vector p = (x,y,z) by Quaternion q == q [0,p] q^-1 + Vector3 v(2, 3, 4); + Quaternion q(Radian(Degree(72)), Vector3::ZAXIS); + Quaternion qI = q; + qI.Invert(); + Quaternion qv(0.0f, v.x, v.y, v.z); + Quaternion r1 = (q * qv) * qI; + + Vector3 r2 = q * v; + + DALI_TEST_EQUALS(r1.mVector.x, r2.x, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(r1.mVector.y, r2.y, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(r1.mVector.z, r2.z, 0.001, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionRotate01(void) +{ + TestApplication application; // Reset all test adapter return codes + // Rotation of vector p = (x,y,z) by Quaternion q == q [0,p] q^-1 + Vector3 v(2, 3, 4); + Quaternion q(Radian(Degree(72)), Vector3::ZAXIS); + Quaternion qI = q; + qI.Invert(); + Quaternion qv(0.0f, v.x, v.y, v.z); + Quaternion r1 = q * qv * qI; + + Vector3 r2 = q.Rotate(v); + + DALI_TEST_EQUALS(r1.mVector.x, r2.x, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(r1.mVector.y, r2.y, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(r1.mVector.z, r2.z, 0.001f, TEST_LOCATION); + + DALI_TEST_EQUALS(q.Rotate(v), q*v, 0.001f, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliQuaternionRotate02(void) +{ + TestApplication application; // Reset all test adapter return codes + // Rotation of vector p = (x,y,z) by Quaternion q == q [0,p] q^-1 + Vector4 v(2, 3, 4, 5); + Quaternion q(Radian(Degree(72)), Vector3::ZAXIS); + Quaternion qI = q; + qI.Invert(); + Quaternion qv(0.0f, v.x, v.y, v.z); + Quaternion r1 = q * qv * qI; + + Vector4 r2 = q.Rotate(v); + + DALI_TEST_EQUALS(r1.mVector.x, r2.x, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(r1.mVector.y, r2.y, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(r1.mVector.z, r2.z, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(r1.mVector.w, 0.0f, 0.001f, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliQuaternionExp01(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q1(0.0f, 1.0f, 1.2f, 1.3f); + Quaternion q2 = q1.Exp(); + Quaternion r2(-0.4452, 0.4406, 0.5287, 0.5728); + + DALI_TEST_EQUALS(q2.Length(), 1.0f, 0.01f, TEST_LOCATION); + + DALI_TEST_EQUALS(q2, r2, 0.001f, TEST_LOCATION); + + // Note, this trick only works when |v| < pi, which it is! + Quaternion q3 = q2.Log(); + DALI_TEST_EQUALS(q1, q3, 0.01f, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliQuaternionExp02(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q1(0.0f, 0.0f, 0.0f, 0.0f); + Quaternion q2 = q1.Exp(); + Quaternion r2(1.0f, 0.0f, 0.0f, 0.0f); + + DALI_TEST_EQUALS(q2.Length(), 1.0f, 0.01f, TEST_LOCATION); + + DALI_TEST_EQUALS(q2, r2, 0.001f, TEST_LOCATION); + + // Note, this trick only works when |v| < pi, which it is! + Quaternion q3 = q2.Log(); + DALI_TEST_EQUALS(q1, q3, 0.01f, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliQuaternionExp03(void) +{ + TestApplication app; + + Quaternion q(0.0f, Vector3(5.0f, 6.0f, 7.0f)); + + // q.w is non-zero. Should assert. + try + { + q.Exp(); + DALI_TEST_CHECK(false); + } + catch(DaliException& e) + { + DALI_TEST_CHECK(true); + } + END_TEST; +} + + +int UtcDaliQuaternionLog01(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q(Math::PI*0.73f, Vector3(2,3,4)); + Quaternion q2 = q; + q2.Normalize(); + + Quaternion r = q2.Log(); + DALI_TEST_EQUALS(r.mVector.w, 0.0f, 0.01f, TEST_LOCATION); + + Quaternion r2 = r.Exp(); + DALI_TEST_EQUALS(r2, q2, 0.01f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionLog02(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q1(1.0f, 0.0f, 0.0f, 0.0f); + Quaternion r1(0.0f, 0.0f, 0.0f, 0.0f); + + Quaternion q2 = q1.Log(); + + DALI_TEST_EQUALS(q2, r1, 0.01f, TEST_LOCATION); + + Quaternion q3 = q2.Exp(); + DALI_TEST_EQUALS(q1, q3, 0.01f, TEST_LOCATION); + END_TEST; +} + + + +int UtcDaliQuaternionLerp(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q1(Radian(Degree(-80)), Vector3(0.0f, 0.0f, 1.0f)); + Quaternion q2(Radian(Degree( 80)), Vector3(0.0f, 0.0f, 1.0f)); + + Quaternion p = Quaternion::Lerp(q1, q2, 0.0f); + DALI_TEST_EQUALS(p, q1, 0.001f, TEST_LOCATION); + + p = Quaternion::Lerp(q1, q2, 1.0f); + DALI_TEST_EQUALS(p, q2, 0.001f, TEST_LOCATION); + + p = Quaternion::Lerp(q1, q2, 0.5f); + Quaternion r1 = (q1 + q2) * 0.5f; + r1.Normalize(); + DALI_TEST_EQUALS(p, r1, 0.001f, TEST_LOCATION); + END_TEST; +} + + + +int UtcDaliQuaternionSlerp01(void) +{ + TestApplication application; + + Quaternion q1(M_PI/4.0f, Vector4(0.0f, 0.0f, 1.0f, 0.0f)); + Quaternion q2(-M_PI/4.0f, Vector4(0.0f, 0.0f, 1.0f, 0.0f)); + + Quaternion q = Quaternion::Slerp(q1, q2, 0.0f); + DALI_TEST_EQUALS(q, q1, 0.001, TEST_LOCATION); + + q = Quaternion::Slerp(q1, q2, 1.0f); + DALI_TEST_EQUALS(q, q2, 0.001, TEST_LOCATION); + + // @ 25%, will be at M_PI/8 + q = Quaternion::Slerp(q1, q2, 0.25f); + Vector4 axis; + float angle; + bool converted = q.ToAxisAngle(axis, angle); + DALI_TEST_EQUALS(converted, true, TEST_LOCATION); + DALI_TEST_EQUALS(angle, Math::PI/8.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(axis.x, 0.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(axis.y, 0.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(axis.z, 1.0f, 0.001, TEST_LOCATION); + END_TEST; +} + + + +int UtcDaliQuaternionSlerp02(void) +{ + TestApplication application; + + Quaternion q1(M_PI/6, Vector3(0.0f, 0.0f, 1.0f)); + Quaternion q2(M_PI/2, Vector3(0.0f, 0.0f, 1.0f)); + + Quaternion q = Quaternion::Slerp(q1, q2, 0.0f); + + DALI_TEST_EQUALS(q, q1, 0.001, TEST_LOCATION); + + q = Quaternion::Slerp(q1, q2, 1.0f); + + DALI_TEST_EQUALS(q, q2, 0.001, TEST_LOCATION); + + // @ 50%, will be at M_PI/3 around z + q = Quaternion::Slerp(q1, q2, 0.5f); + + Quaternion r( M_PI/3, Vector3( 0.0f, 0.0f, 1.0f)); + DALI_TEST_EQUALS( q, r, 0.001, TEST_LOCATION ); + END_TEST; +} + + +int UtcDaliQuaternionSlerp03(void) +{ + TestApplication application; + + Quaternion q1(Radian(Degree(125)), Vector3(0.0f, 0.0f, 1.0f)); + Quaternion q2(Radian(Degree(-125)), Vector3(0.002f, 0.001f, 1.001f)); + + Quaternion q = Quaternion::Slerp(q1, q2, 0.0f); + DALI_TEST_EQUALS(q, q1, 0.001, TEST_LOCATION); + + q = Quaternion::Slerp(q1, q2, 1.0f); + DALI_TEST_EQUALS(q, q2, 0.001, TEST_LOCATION); + + q = Quaternion::Slerp(q1, q2, 0.05f); + Vector4 axis; + float angle; + bool converted = q.ToAxisAngle(axis, angle); + DALI_TEST_EQUALS(converted, true, TEST_LOCATION); + + DALI_TEST_EQUALS(axis.x, 0.0f, 0.01, TEST_LOCATION); + DALI_TEST_EQUALS(axis.y, 0.0f, 0.01, TEST_LOCATION); + DALI_TEST_EQUALS(axis.z, 1.0f, 0.01, TEST_LOCATION); + END_TEST; +} + + + +int UtcDaliQuaternionSlerp04(void) +{ + TestApplication application; + + Quaternion q1(Radian(Degree(120)), Vector3(0.0f, 0.0f, 1.0f)); + Quaternion q2(Radian(Degree(130)), Vector3(0.0f, 0.0f, 1.0f)); + + Quaternion q = Quaternion::Slerp(q1, q2, 0.0f); + DALI_TEST_EQUALS(q, q1, 0.001, TEST_LOCATION); + + q = Quaternion::Slerp(q1, q2, 1.0f); + DALI_TEST_EQUALS(q, q2, 0.001, TEST_LOCATION); + + q = Quaternion::Slerp(q1, q2, 0.5f); + Vector4 axis; + float angle; + bool converted = q.ToAxisAngle(axis, angle); + DALI_TEST_EQUALS(converted, true, TEST_LOCATION); + DALI_TEST_EQUALS(angle, float(Radian(Degree(125))), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(axis.x, 0.0f, 0.01, TEST_LOCATION); + DALI_TEST_EQUALS(axis.y, 0.0f, 0.01, TEST_LOCATION); + DALI_TEST_EQUALS(axis.z, 1.0f, 0.01, TEST_LOCATION); + END_TEST; +} + + + +int UtcDaliQuaternionSlerpNoInvert01(void) +{ + TestApplication application; + + Quaternion q1(M_PI/4.0f, Vector4(0.0f, 0.0f, 1.0f, 0.0f)); + Quaternion q2(-M_PI/4.0f, Vector4(0.0f, 0.0f, 1.0f, 0.0f)); + + Quaternion q = Quaternion::SlerpNoInvert(q1, q2, 0.0f); + DALI_TEST_EQUALS(q, q1, 0.001, TEST_LOCATION); + + q = Quaternion::SlerpNoInvert(q1, q2, 1.0f); + DALI_TEST_EQUALS(q, q2, 0.001, TEST_LOCATION); + + // @ 25%, will be at M_PI/8 + q = Quaternion::SlerpNoInvert(q1, q2, 0.25f); + Vector4 axis; + float angle; + bool converted = q.ToAxisAngle(axis, angle); + DALI_TEST_EQUALS(converted, true, TEST_LOCATION); + DALI_TEST_EQUALS(angle, Math::PI/8.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(axis.x, 0.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(axis.y, 0.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(axis.z, 1.0f, 0.001, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliQuaternionSlerpNoInvert02(void) +{ + TestApplication application; + + Quaternion q1(Radian(Degree(120)), Vector3(0.0f, 0.0f, 1.0f)); + Quaternion q2(Radian(Degree(130)), Vector3(0.0f, 0.0f, 1.0f)); + + Quaternion q = Quaternion::SlerpNoInvert(q1, q2, 0.0f); + DALI_TEST_EQUALS(q, q1, 0.001, TEST_LOCATION); + + q = Quaternion::SlerpNoInvert(q1, q2, 1.0f); + DALI_TEST_EQUALS(q, q2, 0.001, TEST_LOCATION); + + q = Quaternion::SlerpNoInvert(q1, q2, 0.5f); + Vector4 axis; + float angle; + bool converted = q.ToAxisAngle(axis, angle); + DALI_TEST_EQUALS(converted, true, TEST_LOCATION); + DALI_TEST_EQUALS(angle, float(Radian(Degree(125))), 0.01f, TEST_LOCATION); + DALI_TEST_EQUALS(axis.x, 0.0f, 0.01, TEST_LOCATION); + DALI_TEST_EQUALS(axis.y, 0.0f, 0.01, TEST_LOCATION); + DALI_TEST_EQUALS(axis.z, 1.0f, 0.01, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliQuaternionSquad(void) +{ + TestApplication application; // Reset all test adapter return codes + Quaternion q1(Radian(Degree(45)), Vector3(0.0f, 0.0f, 1.0f)); + Quaternion q1out(Radian(Degree(40)), Vector3(0.0f, 1.0f, 2.0f)); + Quaternion q2in(Radian(Degree(35)), Vector3(0.0f, 2.0f, 3.0f)); + Quaternion q2(Radian(Degree(30)), Vector3(0.0f, 1.0f, 3.0f)); + + Quaternion q = Quaternion::Squad(q1, q2, q1out, q2in, 0.0f); + DALI_TEST_EQUALS(q, q1, 0.001f, TEST_LOCATION); + + q = Quaternion::Squad(q1, q2, q1out, q2in, 1.0f); + DALI_TEST_EQUALS(q, q2, 0.001f, TEST_LOCATION); + + // Don't know what actual value should be, but can make some informed guesses. + q = Quaternion::Squad(q1, q2, q1out, q2in, 0.5f); + float angle; + Vector3 axis; + q.Normalize(); + q.ToAxisAngle(axis, angle); + + if(angle < 0.0f) + { + q = -q; // Might get negative quat + q.ToAxisAngle(axis, angle); + } + float deg = Degree(Radian(angle)); + DALI_TEST_CHECK(deg >= 0 && deg <= 90); + DALI_TEST_CHECK(axis.y > 0); + DALI_TEST_CHECK(axis.z > 0); + END_TEST; +} + +int UtcDaliAngleBetween(void) +{ + TestApplication application; // Reset all test adapter return codes + + Quaternion q1(Radian(Degree(45)), 0.0f, 0.0f); + Quaternion q2(Radian(Degree(47)), 0.0f, 0.0f); + DALI_TEST_EQUALS(Quaternion::AngleBetween(q1, q2), fabsf(Radian(Degree(45)) - Radian(Degree(47))), 0.001f, TEST_LOCATION); + + Quaternion q3(Radian(Degree(80)), Vector3::YAXIS); + Quaternion q4(Radian(Degree(90)), Vector3::YAXIS); + DALI_TEST_EQUALS(Quaternion::AngleBetween(q3, q4), fabsf(Radian(Degree(80)) - Radian(Degree(90))), 0.001f, TEST_LOCATION); + + Quaternion q5(Radian(Degree(0)), Vector3::YAXIS); + Quaternion q6(Radian(Degree(90)), Vector3::XAXIS); + DALI_TEST_EQUALS(Quaternion::AngleBetween(q5, q6), fabsf(Radian(Degree(0)) - Radian(Degree(90))), 0.001f, TEST_LOCATION); + + Quaternion q7(Radian(Degree(0)), Vector3::YAXIS); + Quaternion q8(Radian(Degree(0)), Vector3::XAXIS); + DALI_TEST_EQUALS(Quaternion::AngleBetween(q7, q8), fabsf(Radian(Degree(0)) - Radian(Degree(0))), 0.001f, TEST_LOCATION); + + Quaternion q9(Radian(Degree(0)), Vector3::XAXIS); + Quaternion q10(Radian(Degree(180)), Vector3::XAXIS); + DALI_TEST_EQUALS(Quaternion::AngleBetween(q9, q10), fabsf(Radian(Degree(0)) - Radian(Degree(180))), 0.001f, TEST_LOCATION); + + Quaternion q11(Radian(Degree(1)), Vector3::YAXIS); + Quaternion q12(Radian(Degree(240)), Vector3::YAXIS); + DALI_TEST_EQUALS(Quaternion::AngleBetween(q11, q12), fabsf(Radian( Degree(1 - 240 + 360) )), 0.001f, TEST_LOCATION); + + Quaternion q13(Radian(Degree(240)), Vector3::YAXIS); + Quaternion q14(Radian(Degree(1)), Vector3::YAXIS); + DALI_TEST_EQUALS(Quaternion::AngleBetween(q13, q14), fabsf(Radian( Degree(240 - 1 - 360) )), 0.001f, TEST_LOCATION); + + Quaternion q15(Radian(Degree(240)), Vector3::YAXIS); + Quaternion q16(Radian(Degree(1)), Vector3::ZAXIS); + DALI_TEST_EQUALS(Quaternion::AngleBetween(q15, q16), Quaternion::AngleBetween(q16, q15), 0.001f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliQuaternionOStreamOperator(void) +{ + TestApplication application; // Reset all test adapter return codes + + std::ostringstream oss; + + Quaternion quaternion(M_PI, Vector3::YAXIS); + + oss << quaternion; + + std::string expectedOutput = "[ Axis: [0, 1, 0], Angle: 180 degrees ]"; + + DALI_TEST_EQUALS( oss.str(), expectedOutput, TEST_LOCATION); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Radian.cpp b/automated-tests/src/dali/utc-Dali-Radian.cpp new file mode 100644 index 0000000..954089a --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-Radian.cpp @@ -0,0 +1,155 @@ +#include + +#include +#include +#include + +using namespace Dali; + + +void utc_dali_radian_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_radian_cleanup(void) +{ + test_return_value = TET_PASS; +} + + +// Positive test case for constructors +int UtcDaliRadianConstructors01(void) +{ + TestApplication application; + + // Default constructor, does not initialise the value + Radian radian0( 0.0f ); + + // Test float assignment operator + radian0 = Math::PI; + DALI_TEST_EQUALS( float(radian0), Math::PI, 0.001f, TEST_LOCATION ); + + // Constructor from float value + Radian radian1( Math::PI ); + DALI_TEST_EQUALS( float(radian1), Math::PI, 0.001f, TEST_LOCATION ); + + // Constructor from a Degree + Radian radian2( Degree( 180.0f ) ); + DALI_TEST_EQUALS( float(radian2), Math::PI, 0.001f, TEST_LOCATION ); + + // Assignment from Degree + Radian radian3( 0.0f ); + radian3 = Degree( 180.0f ); + DALI_TEST_EQUALS( float(radian3), Math::PI, 0.001f, TEST_LOCATION ); + END_TEST; +} + +// Positive test case for comparison +int UtcDaliRadianComparison01(void) +{ + TestApplication application; + + // Comparison between radians + Radian radian0( Math::PI_2 ); + Radian radian1( Math::PI_2 ); + Radian radian2( Math::PI ); + + DALI_TEST_CHECK( radian0 == radian1 ); + DALI_TEST_CHECK( radian0 != radian2 ); + + // Comparison between radian to degree + Radian radian3( Math::PI ); + Radian radian4( Math::PI_2 ); + Degree degree0( 180.0f ); + + DALI_TEST_CHECK( radian3 == degree0 ); + DALI_TEST_CHECK( radian4 != degree0 ); + + // Comparison with float + Radian radian5( Math::PI_2 ); + + DALI_TEST_CHECK( radian5 == Math::PI_2 ); + DALI_TEST_CHECK( radian5 != Math::PI ); + + END_TEST; +} + + +// test case for cast operators +int UtcDaliRadianCastOperators01(void) +{ + TestApplication application; // Exceptions require TestApplication + + Radian radian0( Math::PI ); + + const float& value0( radian0 ); + DALI_TEST_EQUALS( value0, Math::PI, 0.001f, TEST_LOCATION ); + + radian0 = Math::PI_2; + DALI_TEST_EQUALS( value0, Math::PI_2, 0.001f, TEST_LOCATION ); + + float& value1( radian0 ); + DALI_TEST_EQUALS( value1, Math::PI_2, 0.001f, TEST_LOCATION ); + + value1 = Math::PI; + DALI_TEST_EQUALS( float(radian0), Math::PI, 0.001f, TEST_LOCATION ); + END_TEST; +} + + +int UtcDaliRadianCastOperatorEquals(void) +{ + TestApplication application; + + Radian a(Math::PI_2); + Radian b(Math::PI_2); + Radian c(Math::PI); + + DALI_TEST_EQUALS(a == a, true, TEST_LOCATION); + DALI_TEST_EQUALS(a == b, true, TEST_LOCATION); + DALI_TEST_EQUALS(a == c, false, TEST_LOCATION); + END_TEST; +} + +int UtcDaliRadianCastOperatorNotEquals(void) +{ + TestApplication application; + + Radian a(Math::PI_2); + Radian b(Math::PI_2); + Radian c(Math::PI); + + DALI_TEST_EQUALS(a != a, false, TEST_LOCATION); + DALI_TEST_EQUALS(a != b, false, TEST_LOCATION); + DALI_TEST_EQUALS(a != c, true, TEST_LOCATION); + END_TEST; +} + +int UtcDaliRadianCastOperatorLessThan(void) +{ + TestApplication application; + + Radian a(Math::PI_4); + Radian b(Math::PI_2); + Radian c(Math::PI); + Radian d(2.0f*Math::PI); + Radian e(-Math::PI); + + DALI_TEST_EQUALS(a < a, false, TEST_LOCATION); + DALI_TEST_EQUALS(a < b, true, TEST_LOCATION); + DALI_TEST_EQUALS(a < c, true, TEST_LOCATION); + DALI_TEST_EQUALS(a < d, true, TEST_LOCATION); + DALI_TEST_EQUALS(a < e, false, TEST_LOCATION); + + DALI_TEST_EQUALS(b < a, false, TEST_LOCATION); + DALI_TEST_EQUALS(b < b, false, TEST_LOCATION); + DALI_TEST_EQUALS(c < b, false, TEST_LOCATION); + DALI_TEST_EQUALS(d < b, false, TEST_LOCATION); + DALI_TEST_EQUALS(e < b, true, TEST_LOCATION); + + DALI_TEST_EQUALS(Radian(Math::PI_2) < Degree(180.0f), true, TEST_LOCATION); + DALI_TEST_EQUALS(Radian(Math::PI_2) < Degree(90.0f), false, TEST_LOCATION); + DALI_TEST_EQUALS(Radian(Math::PI_2) < Degree(45.0f), false, TEST_LOCATION); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Rect.cpp b/automated-tests/src/dali/utc-Dali-Rect.cpp new file mode 100644 index 0000000..028d183 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-Rect.cpp @@ -0,0 +1,277 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +using namespace Dali; + +void utc_dali_rect_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_rect_cleanup(void) +{ + test_return_value = TET_PASS; +} + + +// Positive test case for a method +int UtcDaliRectCons01(void) +{ + TestApplication application; + + Rect rect; + DALI_TEST_EQUALS(rect.x, 0.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(rect.y, 0.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(rect.width, 0.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(rect.height, 0.0f, 0.001, TEST_LOCATION); + END_TEST; +} + +int UtcDaliRectCons02(void) +{ + TestApplication application; + + Rect rect(10.0f, 20.0f, 400.0f, 200.0f); + DALI_TEST_EQUALS(rect.x, 10.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(rect.y, 20.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(rect.width, 400.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(rect.height, 200.0f, 0.001, TEST_LOCATION); + END_TEST; +} + +int UtcDaliRectCons03(void) +{ + TestApplication application; + + Rect rect(10.0f, 20.0f, 400.0f, 200.0f); + + Rect r2 = rect; + + DALI_TEST_EQUALS(r2.x, 10.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(r2.y, 20.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(r2.width, 400.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(r2.height, 200.0f, 0.001, TEST_LOCATION); + END_TEST; +} + +int UtcDaliRectCons04(void) +{ + TestApplication application; + + Rect rect(10.0f, 20.0f, 400.0f, 200.0f); + + Rect r2(rect); + + DALI_TEST_EQUALS(r2.x, 10.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(r2.y, 20.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(r2.width, 400.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(r2.height, 200.0f, 0.001, TEST_LOCATION); + END_TEST; +} + +int UtcDaliRectSet(void) +{ + TestApplication application; + + Rect rect(10.0f, 20.0f, 400.0f, 200.0f); + + rect.Set(1.0f, 2.0f, 3.0f, 4.0f); + + DALI_TEST_EQUALS(rect.x, 1.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(rect.y, 2.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(rect.width, 3.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(rect.height, 4.0f, 0.001, TEST_LOCATION); + END_TEST; +} + +int UtcDaliRectIsEmpty(void) +{ + TestApplication application; + + Rect ri; + Rect rf(10.0f, 20.0f, 400.0f, 200.0f); + Rect rf2; + Rect rf3(10.0f, 20.0f, 0.0f, 200.0f); + Rect rf4(10.0f, 20.0f, 400.0f, 0.0f); + Rect rd(10.0, 20.0, 0.0, 200.0); + Rect ru(0u, 0u, 4u, 0u); + + DALI_TEST_CHECK(!rf.IsEmpty()); + DALI_TEST_CHECK(rf2.IsEmpty()); + DALI_TEST_CHECK(rf3.IsEmpty()); + DALI_TEST_CHECK(rf4.IsEmpty()); + DALI_TEST_CHECK(ri.IsEmpty()); + DALI_TEST_CHECK(rd.IsEmpty()); + DALI_TEST_CHECK(ru.IsEmpty()); + END_TEST; +} + +int UtcDaliRectRight(void) +{ + TestApplication application; + + Rect rf(10.0f, 20.0f, 400.0f, 200.0f); + + DALI_TEST_EQUALS(rf.Right(), 410.0f, 0.001, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliRectBottom(void) +{ + TestApplication application; + + Rect rf(10.0f, 20.0f, 400.0f, 200.0f); + + DALI_TEST_EQUALS(rf.Bottom(), 220.0f, 0.001, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliRectArea(void) +{ + TestApplication application; + + Rect rf(10.0f, 20.0f, 400.0f, 200.0f); + + DALI_TEST_EQUALS(rf.Area(), 80000.0f, 0.001, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliRectIntersects(void) +{ + TestApplication application; + + Rect rf1( 10.0f, 20.0f, 200.0f, 200.0f); + Rect rf2( 10.0f, 120.0f, 200.0f, 200.0f); + Rect rf3( 10.0f, -80.0f, 200.0f, 200.0f); + Rect rf4(110.0f, 20.0f, 200.0f, 200.0f); + Rect rf5(-90.0f, 20.0f, 200.0f, 200.0f); + Rect rf6(1000.0f, 1200.0f, 10.0f, 10.0f); + + DALI_TEST_CHECK(rf1.Intersects(rf2)); + DALI_TEST_CHECK(rf1.Intersects(rf3)); + DALI_TEST_CHECK(rf1.Intersects(rf4)); + DALI_TEST_CHECK(rf1.Intersects(rf5)); + DALI_TEST_CHECK(!rf1.Intersects(rf6)); + END_TEST; +} + + + +int UtcDaliRectContains(void) +{ + TestApplication application; + + Rect rf1( 10.0f, 20.0f, 200.0f, 200.0f); + + Rect rf2( 10.0f, 120.0f, 200.0f, 200.0f); + Rect rf3( 10.0f, -80.0f, 200.0f, 200.0f); + Rect rf4(110.0f, 20.0f, 200.0f, 200.0f); + Rect rf5(-90.0f, 20.0f, 200.0f, 200.0f); + Rect rf6(1000.0f, 1200.0f, 10.0f, 10.0f); + + Rect rf7( 50.0f, 70.0f, 50.0f, 50.0f); + + Rect rf8( 10.0f, 20.0f, 100.0f, 100.0f); + Rect rf9( 110.0f, 20.0f, 100.0f, 100.0f); + Rect rf10( 110.0f, 120.0f, 100.0f, 100.0f); + Rect rf11( 10.0f, 120.0f, 100.0f, 100.0f); + + DALI_TEST_CHECK(rf1.Contains(rf1)); + DALI_TEST_CHECK(!rf1.Contains(rf2)); + DALI_TEST_CHECK(!rf1.Contains(rf3)); + DALI_TEST_CHECK(!rf1.Contains(rf4)); + DALI_TEST_CHECK(!rf1.Contains(rf5)); + DALI_TEST_CHECK(!rf1.Contains(rf6)); + + DALI_TEST_CHECK(rf1.Contains(rf7)); + + DALI_TEST_CHECK(rf1.Contains(rf8)); + DALI_TEST_CHECK(rf1.Contains(rf9)); + DALI_TEST_CHECK(rf1.Contains(rf10)); + DALI_TEST_CHECK(rf1.Contains(rf11)); + END_TEST; +} + + +int UtcDaliRectOperatorNotEquals(void) +{ + TestApplication application; + + Rect rf1( 10.0f, 20.0f, 200.0f, 200.0f); + Rect rf2( 10.0f, 120.0f, 200.0f, 200.0f); + Rect rf3( 10.0f, -80.0f, 200.0f, 200.0f); + Rect rf4(110.0f, 20.0f, 200.0f, 200.0f); + Rect rf5(-90.0f, 20.0f, 200.0f, 200.0f); + Rect rf6(1000.0f, 1200.0f, 10.0f, 10.0f); + Rect rf7( 50.0f, 70.0f, 50.0f, 50.0f); + Rect rf8( 10.0f, 20.0f, 100.0f, 100.0f); + Rect rf9( 110.0f, 20.0f, 100.0f, 100.0f); + Rect rf10( 110.0f, 120.0f, 100.0f, 100.0f); + Rect rf11( 10.0f, 120.0f, 100.0f, 100.0f); + + DALI_TEST_CHECK(rf1 != rf2); + DALI_TEST_CHECK(rf1 != rf3); + DALI_TEST_CHECK(rf1 != rf4); + DALI_TEST_CHECK(rf1 != rf5); + DALI_TEST_CHECK(rf1 != rf6); + DALI_TEST_CHECK(rf1 != rf7); + DALI_TEST_CHECK(rf1 != rf8); + DALI_TEST_CHECK(rf1 != rf9); + DALI_TEST_CHECK(rf1 != rf10); + DALI_TEST_CHECK(rf1 != rf11); + END_TEST; +} + + +int UtcDaliRectOperatorEquals(void) +{ + TestApplication application; + + Rect rf1( 10.0f, 20.0f, 200.0f, 200.0f); + Rect rf1p( 10.0f, 20.0f, 200.0f, 200.0f); + + Rect rf2(110.0f, 20.0f, 200.0f, 200.0f); + Rect rf3( 10.0f, 120.0f, 200.0f, 200.0f); + Rect rf4( 10.0f, 20.0f, 300.0f, 200.0f); + Rect rf5( 10.0f, 20.0f, 200.0f, 500.0f); + + Rect rf6( 0.0f, 0.0f, 9.0f, 10.0f); + + DALI_TEST_CHECK(rf1 == rf1p); + DALI_TEST_CHECK(rf1 == rf1); + DALI_TEST_CHECK(!(rf1 == rf2)); + DALI_TEST_CHECK(!(rf1 == rf3)); + DALI_TEST_CHECK(!(rf1 == rf4)); + DALI_TEST_CHECK(!(rf1 == rf5)); + DALI_TEST_CHECK(!(rf1 == rf6)); + + + // integers + Rect ri1( 10, 20, 200, 200 ); + Rect ri1p( 10, 20, 200, 200 ); + + DALI_TEST_CHECK(ri1 == ri1p); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-RenderTask.cpp b/automated-tests/src/dali/utc-Dali-RenderTask.cpp new file mode 100644 index 0000000..d7d32d7 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-RenderTask.cpp @@ -0,0 +1,2555 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; + +void utc_dali_render_task_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_render_task_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace // unnamed namespace +{ + +class TestNativeImage : public NativeImage +{ +public: + int mWidth; + int mHeight; + TestNativeImage(int width, int height) + : mWidth(width), + mHeight(height) + {} + + virtual bool GlExtensionCreate() {return true;}; + + /** + * Destroy the GL resource for the NativeImage. + * e.g. For the EglImageKHR extension, this corresponds to calling eglDestroyImageKHR() + * @pre There is a GL context for the current thread. + */ + virtual void GlExtensionDestroy() {}; + + /** + * Use the NativeImage as a texture for rendering + * @pre There is a GL context for the current thread. + * @return A GL error code + */ + virtual unsigned int TargetTexture() {return 0;}; + + /** + * Called in each NativeTexture::Bind() call to allow implementation specific operations. + * The correct texture sampler has already been bound before the function gets called. + * @pre glAbstraction is being used by context in current thread + */ + virtual void PrepareTexture() {} + + /** + * Returns the width of the NativeImage + * @return width + */ + virtual unsigned int GetWidth() const {return mWidth;} + + /** + * Returns the height of the NativeImage + * @return height + */ + virtual unsigned int GetHeight() const {return mHeight;} + + /** + * Returns the internal pixel NativeImage::PixelFormat of the NativeImage + * @return pixel format + */ + virtual Pixel::Format GetPixelFormat() const { return Pixel::RGBA8888; } +protected: + ~TestNativeImage(){} +}; + + +const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS) + +/* + * Simulate time passed by. + * + * @note this will always process at least 1 frame (1/60 sec) + * + * @param application Test application instance + * @param duration Time to pass in milliseconds. + * @return The actual time passed in milliseconds + */ +int Wait(TestApplication& application, int duration = 0) +{ + int time = 0; + + for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++) + { + application.SendNotification(); + application.Render(RENDER_FRAME_INTERVAL); + time += RENDER_FRAME_INTERVAL; + } + + return time; +} + +struct RenderTaskFinished +{ + RenderTaskFinished( bool& finished ) + : finished( finished ) + { + } + + void operator()( RenderTask& renderTask ) + { + finished = true; + } + + bool& finished; +}; + +struct RenderTaskFinishedRemoveSource +{ + RenderTaskFinishedRemoveSource( bool& finished ) + : finished( finished ), + finishedOnce(false) + { + } + + void operator()( RenderTask& renderTask ) + { + DALI_TEST_CHECK(finishedOnce == false); + finished = true; + finishedOnce = true; + Actor srcActor = renderTask.GetSourceActor(); + UnparentAndReset(srcActor); + } + + bool& finished; + bool finishedOnce; +}; + +struct RenderTaskFinishedRenderAgain +{ + RenderTaskFinishedRenderAgain( bool& finished ) + : finished( finished ), + finishedOnce(false) + { + } + + void operator()( RenderTask& renderTask ) + { + DALI_TEST_CHECK(finishedOnce == false); + finished = true; + finishedOnce = true; + renderTask.SetRefreshRate(RenderTask::REFRESH_ONCE); + } + + bool& finished; + bool finishedOnce; +}; + + +bool TestScreenToFrameBufferFunction( Vector2& coordinates ) +{ + coordinates = coordinates + Vector2( 1, 2 ); + + return true; +} + +ImageActor CreateLoadingImage(TestApplication& application, std::string filename, Image::LoadPolicy loadPolicy, Image::ReleasePolicy releasePolicy) +{ + Image image = Image::New(filename, loadPolicy, releasePolicy); + DALI_TEST_CHECK( image ); + application.SendNotification(); + application.Render(16); + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); + ImageActor actor = ImageActor::New(image); + actor.SetSize( 80, 80 ); + application.SendNotification(); + application.Render(16); + return actor; +} + +void CompleteImageLoad(TestApplication& application, Integration::ResourceId resourceId, Integration::ResourceTypeId requestType) +{ + std::vector ids; + ids.push_back( 23 ); + application.GetGlAbstraction().SetNextTextureIds( ids ); + + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true ); + Integration::ResourcePointer resource(bitmap); + bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80); + + application.GetPlatform().SetResourceLoaded(resourceId, requestType, resource); +} + +void FailImageLoad(TestApplication& application, Integration::ResourceId resourceId ) +{ + application.GetPlatform().SetResourceLoadFailed(resourceId, Integration::FailureUnknown); +} + +void ReloadImage(TestApplication& application, Image image) +{ + application.GetPlatform().ClearReadyResources(); + application.GetPlatform().DiscardRequest(); + application.GetPlatform().ResetTrace(); + application.GetPlatform().SetClosestImageSize(Vector2(80.0f, 80.0f)); // Ensure reload is called. + image.Reload(); +} + +RenderTask CreateRenderTask(TestApplication& application, + CameraActor offscreenCamera, + Actor rootActor, // Reset default render task to point at this actor + Actor secondRootActor, // Source actor + unsigned int refreshRate, + bool glSync) +{ + // Change main render task to use a different root + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + taskList.GetTask(0u).SetSourceActor( rootActor ); + + FrameBufferImage frameBufferImage; + if( glSync ) + { + NativeImagePtr testNativeImagePtr = new TestNativeImage(10, 10); + frameBufferImage= FrameBufferImage::New( *testNativeImagePtr.Get() ); + } + else + { + frameBufferImage = FrameBufferImage::New( 10, 10 ); + } + + // Don't draw output framebuffer + + RenderTask newTask = taskList.CreateTask(); + newTask.SetCameraActor( offscreenCamera ); + newTask.SetSourceActor( secondRootActor ); + newTask.SetInputEnabled( false ); + newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) ); + newTask.SetClearEnabled( true ); + newTask.SetExclusive( true ); + newTask.SetRefreshRate( refreshRate ); + newTask.SetTargetFrameBuffer( frameBufferImage ); + return newTask; +} + + +bool UpdateRender(TestApplication& application, TraceCallStack& callStack, bool testDrawn, bool& finishedSig, bool testFinished ) +{ + finishedSig = false; + callStack.Reset(); + application.Render(16); + application.SendNotification(); + + bool sigPassed = false; + if( testFinished ) + { + sigPassed = finishedSig; + } + else + { + sigPassed = ! finishedSig; + } + + bool drawPassed = false; + if( testDrawn ) + { + drawPassed = callStack.FindMethod("DrawElements") || callStack.FindMethod("DrawArrays"); + } + else + { + drawPassed = ! callStack.FindMethod("DrawElements") && ! callStack.FindMethod("DrawArrays") ; + } + + tet_printf("UpdateRender: drawPassed:%s sigPassed:%s (Expected: %s %s)\n", drawPassed?"T":"F", sigPassed?"T":"F", testDrawn?"T":"F", testFinished?"T":"F"); + + return (sigPassed && drawPassed); +} + +} // unnamed namespace + + +/****************************************************************************************************/ +/****************************************************************************************************/ +/******************************** TEST CASES BELOW **********************************************/ +/****************************************************************************************************/ +/****************************************************************************************************/ + +int UtcDaliRenderTaskDownCast(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::DownCast()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + + BaseHandle base = taskList.GetTask( 0u ); + DALI_TEST_CHECK( base ); + + RenderTask task = RenderTask::DownCast( base ); + DALI_TEST_CHECK( task ); + + // Try calling a method + DALI_TEST_CHECK( task.GetSourceActor() ); + END_TEST; +} + +int UtcDaliRenderTaskSetSourceActor(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::SetSourceActor()"); + + Stage stage = Stage::GetCurrent(); + + const std::vector& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 ); + + RenderTaskList taskList = stage.GetRenderTaskList(); + + RenderTask task = taskList.GetTask( 0u ); + + Actor actor = task.GetSourceActor(); + DALI_TEST_CHECK( actor ); + + std::vector ids; + ids.push_back( 7 ); + application.GetGlAbstraction().SetNextTextureIds( ids ); + + BitmapImage img = BitmapImage::New( 1,1 ); + ImageActor newActor = ImageActor::New( img ); + newActor.SetSize(1,1); + stage.Add( newActor ); + + Actor nonRenderableActor = Actor::New(); + stage.Add( nonRenderableActor ); + + // Stop the newActor from being rendered by changing the source actor + DALI_TEST_CHECK( nonRenderableActor ); + task.SetSourceActor( nonRenderableActor ); + DALI_TEST_CHECK( task.GetSourceActor() != actor ); + DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor ); + + // Update & Render nothing! + application.GetGlAbstraction().ClearBoundTextures(); + application.SendNotification(); + application.Render(); + + // Check that nothing was rendered + DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION ); + + // Set newActor as the new source Actor + task.SetSourceActor( newActor ); + DALI_TEST_CHECK( task.GetSourceActor() != actor ); + DALI_TEST_CHECK( task.GetSourceActor() == newActor ); + + // Update & Render the newActor + application.GetGlAbstraction().ClearBoundTextures(); + application.SendNotification(); + application.Render(); + + // Check that the newActor was rendered + DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION ); + if ( boundTextures.size() ) + { + DALI_TEST_EQUALS( boundTextures[0], 7u, TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliRenderTaskSetSourceActorOffStage(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::SetSourceActor (on/off stage testing)"); + + Stage stage = Stage::GetCurrent(); + + const std::vector& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 ); + + RenderTaskList taskList = stage.GetRenderTaskList(); + + RenderTask task = taskList.GetTask( 0u ); + + Actor actor = task.GetSourceActor(); + DALI_TEST_CHECK( actor ); + + std::vector ids; + GLuint expectedTextureId( 3 ); + ids.push_back( expectedTextureId ); + application.GetGlAbstraction().SetNextTextureIds( ids ); + + BitmapImage img = BitmapImage::New( 1,1 ); + ImageActor newActor = ImageActor::New( img ); + newActor.SetSize(1,1); + task.SetSourceActor( newActor ); + // Don't add newActor to stage yet + + // Update & Render with the actor initially off-stage + application.GetGlAbstraction().ClearBoundTextures(); + application.SendNotification(); + application.Render(); + + // Check that nothing was rendered + DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION ); + + // Now add to stage + stage.Add( newActor ); + + // Update & Render with the actor on-stage + application.GetGlAbstraction().ClearBoundTextures(); + application.SendNotification(); + application.Render(); + + // Check that the newActor was rendered + DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION ); + if ( boundTextures.size() ) + { + DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION ); + } + + // Now remove from stage + stage.Remove( newActor ); + + // Update & Render with the actor off-stage + application.GetGlAbstraction().ClearBoundTextures(); + application.SendNotification(); + application.Render(); + END_TEST; +} + +int UtcDaliRenderTaskSetSourceActorEmpty(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::SetSourceActor (empty handle case)"); + + Stage stage = Stage::GetCurrent(); + + const std::vector& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 ); + + RenderTaskList taskList = stage.GetRenderTaskList(); + + RenderTask task = taskList.GetTask( 0u ); + + Actor actor = task.GetSourceActor(); + DALI_TEST_CHECK( actor ); + + std::vector ids; + GLuint expectedTextureId( 5 ); + ids.push_back( expectedTextureId ); + application.GetGlAbstraction().SetNextTextureIds( ids ); + + BitmapImage img = BitmapImage::New( 1,1 ); + ImageActor newActor = ImageActor::New( img ); + newActor.SetSize(1,1); + stage.Add( newActor ); + + Actor nonRenderableActor = Actor::New(); + stage.Add( nonRenderableActor ); + + // Set with empty handle + task.SetSourceActor( Actor() ); + DALI_TEST_CHECK( ! task.GetSourceActor() ); + + // Update & Render nothing! + application.GetGlAbstraction().ClearBoundTextures(); + application.SendNotification(); + application.Render(); + + // Check that nothing was rendered + DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION ); + + // Set with non-empty handle + task.SetSourceActor( newActor ); + DALI_TEST_CHECK( task.GetSourceActor() == newActor ); + + // Update & Render the newActor + application.GetGlAbstraction().ClearBoundTextures(); + application.SendNotification(); + application.Render(); + + // Check that the newActor was rendered + DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION ); + if ( boundTextures.size() ) + { + DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliRenderTaskGetSourceActor(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::GetSourceActor()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + + RenderTask task = taskList.GetTask( 0u ); + + Actor actor = task.GetSourceActor(); + DALI_TEST_CHECK( actor ); + + // By default the entire scene should be rendered + Actor root = Stage::GetCurrent().GetLayer( 0 ); + DALI_TEST_CHECK( root == actor ); + END_TEST; +} + +int UtcDaliRenderTaskSetExclusive(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::SetExclusive()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + + // Manipulate the GenTextures behaviour, to identify different ImageActors + + std::vector ids; + ids.push_back( 8 ); // 8 = actor1 + ids.push_back( 9 ); // 9 = actor2 + ids.push_back( 10 ); // 10 = actor3 + application.GetGlAbstraction().SetNextTextureIds( ids ); + + BitmapImage img1 = BitmapImage::New( 1,1 ); + ImageActor actor1 = ImageActor::New( img1 ); + actor1.SetSize(1,1); + Stage::GetCurrent().Add( actor1 ); + + // Update & Render actor1 + application.SendNotification(); + application.Render(); + + // Check that the actor1 was rendered + const std::vector& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 ); + DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION ); + + if ( boundTextures.size() ) + { + DALI_TEST_EQUALS( boundTextures[0], 8u/*unique to actor1*/, TEST_LOCATION ); + } + + BitmapImage img2 = BitmapImage::New( 1,1 ); + ImageActor actor2 = ImageActor::New( img2 ); + actor2.SetSize(1,1); + + // Force actor2 to be rendered before actor1 + Layer layer = Layer::New(); + Stage::GetCurrent().Add( layer ); + layer.Add( actor2 ); + layer.LowerToBottom(); + + // Update & Render + application.GetGlAbstraction().ClearBoundTextures(); + application.SendNotification(); + application.Render(); + + // Check that the actors were rendered + DALI_TEST_EQUALS( boundTextures.size(), 2u, TEST_LOCATION ); + + if ( boundTextures.size() ) + { + DALI_TEST_EQUALS( boundTextures[0], 9u/*unique to actor2*/, TEST_LOCATION ); + DALI_TEST_EQUALS( boundTextures[1], 8u/*unique to actor1*/, TEST_LOCATION ); + } + + BitmapImage img3 = BitmapImage::New( 1,1 ); + ImageActor actor3 = ImageActor::New( img3 ); + actor3.SetSize(1,1); + + // Force actor3 to be rendered before actor2 + layer = Layer::New(); + Stage::GetCurrent().Add( layer ); + layer.Add( actor3 ); + layer.LowerToBottom(); + + // Update & Render all actors + application.GetGlAbstraction().ClearBoundTextures(); + application.SendNotification(); + application.Render(); + + // Check that the actors were rendered + DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION ); + + if ( boundTextures.size() ) + { + DALI_TEST_EQUALS( boundTextures[0], 10u/*unique to actor3*/, TEST_LOCATION ); + DALI_TEST_EQUALS( boundTextures[1], 9u/*unique to actor2*/, TEST_LOCATION ); + DALI_TEST_EQUALS( boundTextures[2], 8u/*unique to actor1*/, TEST_LOCATION ); + } + + // Both actors are now connected to the root node + // Setup 2 render-tasks - the first will render from the root-node, and the second from actor2 + + // Not exclusive is the default + RenderTask task1 = taskList.GetTask( 0u ); + DALI_TEST_CHECK( false == task1.IsExclusive() ); + + RenderTask task2 = taskList.CreateTask(); + DALI_TEST_CHECK( false == task2.IsExclusive() ); + task2.SetSourceActor( actor2 ); + + // Task1 should render all actors, and task 2 should render only actor2 + + application.GetGlAbstraction().ClearBoundTextures(); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( boundTextures.size(), 4u, TEST_LOCATION ); + + if ( boundTextures.size() == 4 ) + { + // Test that task 1 renders actor3, then actor2 & then actor1 + DALI_TEST_CHECK( boundTextures[0] == 10u ); + DALI_TEST_CHECK( boundTextures[1] == 9u ); + DALI_TEST_CHECK( boundTextures[2] == 8u ); + + // Test that task 2 renders actor2 + DALI_TEST_EQUALS( boundTextures[3], 9u, TEST_LOCATION ); + } + + // Make actor2 exclusive to task2 + + task2.SetExclusive( true ); + DALI_TEST_CHECK( true == task2.IsExclusive() ); + + // Task1 should render only actor1, and task 2 should render only actor2 + + application.GetGlAbstraction().ClearBoundTextures(); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( boundTextures.size(), 3u, TEST_LOCATION ); + if ( boundTextures.size() == 3 ) + { + // Test that task 1 renders actor3 & actor1 + DALI_TEST_CHECK( boundTextures[0] == 10u ); + DALI_TEST_CHECK( boundTextures[1] == 8u ); + + // Test that task 2 renders actor2 + DALI_TEST_CHECK( boundTextures[2] == 9u ); + } + END_TEST; +} + +int UtcDaliRenderTaskIsExclusive(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::IsExclusive()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + + // Not exclusive is the default + RenderTask task = taskList.GetTask( 0u ); + DALI_TEST_CHECK( false == task.IsExclusive() ); + + RenderTask newTask = taskList.CreateTask(); + DALI_TEST_CHECK( false == newTask.IsExclusive() ); + END_TEST; +} + +int UtcDaliRenderTaskSetInputEnabled(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::SetInputEnabled()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + + // Input is enabled by default + RenderTask task = taskList.GetTask( 0u ); + DALI_TEST_CHECK( true == task.GetInputEnabled() ); + + task.SetInputEnabled( false ); + DALI_TEST_CHECK( false == task.GetInputEnabled() ); + + task.SetInputEnabled( true ); + DALI_TEST_CHECK( true == task.GetInputEnabled() ); + END_TEST; +} + +int UtcDaliRenderTaskGetInputEnabled(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::GetInputEnabled()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + + // Input is enabled by default + RenderTask task = taskList.GetTask( 0u ); + DALI_TEST_CHECK( true == task.GetInputEnabled() ); + + RenderTask newTask = taskList.CreateTask(); + DALI_TEST_CHECK( true == newTask.GetInputEnabled() ); + END_TEST; +} + +int UtcDaliRenderTaskSetCameraActor(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::SetCameraActor()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + + RenderTask task = taskList.GetTask( 0u ); + + Actor actor = task.GetCameraActor(); + DALI_TEST_CHECK( actor ); + + CameraActor newActor = CameraActor::New(); + DALI_TEST_CHECK( newActor ); + + task.SetCameraActor( newActor ); + DALI_TEST_CHECK( task.GetCameraActor() != actor ); + DALI_TEST_CHECK( task.GetCameraActor() == newActor ); + END_TEST; +} + +int UtcDaliRenderTaskGetCameraActor(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::GetCameraActor()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + + RenderTask task = taskList.GetTask( 0u ); + + Actor actor = task.GetCameraActor(); + DALI_TEST_CHECK( actor ); + + RenderTask newTask = taskList.CreateTask(); + DALI_TEST_CHECK( actor == newTask.GetCameraActor() ); + END_TEST; +} + +int UtcDaliRenderTaskSetTargetFrameBuffer(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::SetTargetFrameBuffer()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + + RenderTask task = taskList.GetTask( 0u ); + + // By default render-tasks do not render off-screen + FrameBufferImage image = task.GetTargetFrameBuffer(); + DALI_TEST_CHECK( !image ); + + FrameBufferImage newImage = FrameBufferImage::New(); + + task.SetTargetFrameBuffer( newImage ); + DALI_TEST_CHECK( task.GetTargetFrameBuffer() == newImage ); + END_TEST; +} + +int UtcDaliRenderTaskGetTargetFrameBuffer(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::GetTargetFrameBuffer()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + + RenderTask task = taskList.GetTask( 0u ); + + // By default render-tasks do not render off-screen + FrameBufferImage image = task.GetTargetFrameBuffer(); + DALI_TEST_CHECK( !image ); + + RenderTask newTask = taskList.CreateTask(); + DALI_TEST_CHECK( !newTask.GetTargetFrameBuffer() ); + END_TEST; +} + +int UtcDaliRenderTaskSetScreenToFrameBufferFunction(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::SetScreenToFrameBufferFunction()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + + RenderTask task = taskList.GetTask( 0u ); + + task.SetScreenToFrameBufferFunction( TestScreenToFrameBufferFunction ); + + Vector2 coordinates( 5, 10 ); + Vector2 convertedCoordinates( 6, 12 ); // + Vector(1, 2) + + RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction(); + DALI_TEST_CHECK( func( coordinates ) ); + DALI_TEST_CHECK( coordinates == convertedCoordinates ); + + task.SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION ); + func = task.GetScreenToFrameBufferFunction(); + DALI_TEST_CHECK( func( coordinates ) ); + + task.SetScreenToFrameBufferFunction( RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION ); + func = task.GetScreenToFrameBufferFunction(); + DALI_TEST_CHECK( ! func( coordinates ) ); + END_TEST; +} + +int UtcDaliRenderTaskGetScreenToFrameBufferFunction(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::GetScreenToFrameBufferFunction()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + + RenderTask task = taskList.GetTask( 0u ); + + Vector2 originalCoordinates( 5, 10 ); + Vector2 coordinates( 5, 10 ); + + RenderTask::ScreenToFrameBufferFunction func = task.GetScreenToFrameBufferFunction(); + DALI_TEST_CHECK( !func( coordinates ) ); // conversion should fail by default + DALI_TEST_CHECK( coordinates == originalCoordinates ); // coordinates should not be modified + END_TEST; +} + + +int UtcDaliRenderTaskGetScreenToFrameBufferMappingActor(void) +{ + TestApplication application; + tet_infoline("Testing RenderTask::GetScreenToFrameBufferMappingActor "); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + RenderTask renderTask = taskList.CreateTask(); + Actor mappingActor = Actor::New(); + renderTask.SetScreenToFrameBufferMappingActor(mappingActor); + + DALI_TEST_CHECK( mappingActor == renderTask.GetScreenToFrameBufferMappingActor() ); + END_TEST; +} + +int UtcDaliRenderTaskSetViewport(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::SetViewport()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + + RenderTask task = taskList.GetTask( 0u ); + + Viewport viewport = task.GetViewport(); + + // By default the viewport should match the stage width/height + + Vector2 stageSize = Stage::GetCurrent().GetSize(); + Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height ); + DALI_TEST_CHECK( viewport == expectedViewport ); + + Viewport newViewport( 0, 0, stageSize.width * 0.5f, stageSize.height * 0.5f ); + task.SetViewport( newViewport ); + + // Update (viewport is a property) + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( task.GetViewport() == newViewport ); + END_TEST; +} + +int UtcDaliRenderTaskGetViewport(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::GetViewport()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + + RenderTask task = taskList.GetTask( 0u ); + + Viewport viewport = task.GetViewport(); + + // By default the viewport should match the stage width/height + + Vector2 stageSize = Stage::GetCurrent().GetSize(); + Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height ); + DALI_TEST_CHECK( viewport == expectedViewport ); + + RenderTask newTask = taskList.CreateTask(); + DALI_TEST_CHECK( newTask.GetViewport() == expectedViewport ); + END_TEST; +} + +int UtcDaliRenderTaskSetViewportPosition(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::SetViewportPosition()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + + RenderTask task = taskList.GetTask( 0u ); + + Viewport viewport = task.GetViewport(); + + // By default the viewport should match the stage width/height + + Vector2 stageSize = Stage::GetCurrent().GetSize(); + Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height ); + DALI_TEST_CHECK( viewport == expectedViewport ); + + // 'Setter' test + Vector2 newPosition(25.0f, 50.0f); + task.SetViewportPosition( newPosition ); + + // Update (viewport is a property) + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + + // Set by Property test + Vector2 newPosition2(32.0f, 32.0f); + task.SetProperty( RenderTask::VIEWPORT_POSITION, newPosition2 ); + + // Update + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition2, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + + Vector2 newPosition3(64.0f, 0.0f); + Animation animation = Animation::New(1.0f); + animation.AnimateTo( Property( task, RenderTask::VIEWPORT_POSITION ), newPosition3, AlphaFunctions::Linear ); + animation.Play(); + + // Perform 1000ms worth of updates at which point animation should have completed. + Wait(application, 1000); + DALI_TEST_EQUALS( task.GetCurrentViewportPosition(), newPosition3, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliRenderTaskSetViewportSize(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::SetViewportSize()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + + RenderTask task = taskList.GetTask( 0u ); + + Viewport viewport = task.GetViewport(); + + // By default the viewport should match the stage width/height + + Vector2 stageSize = Stage::GetCurrent().GetSize(); + Viewport expectedViewport( 0, 0, stageSize.width, stageSize.height ); + DALI_TEST_CHECK( viewport == expectedViewport ); + + Vector2 newSize(128.0f, 64.0f); + task.SetViewportSize( newSize ); + + // Update (viewport is a property) + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + + // Set by Property test + Vector2 newSize2(50.0f, 50.0f); + task.SetProperty( RenderTask::VIEWPORT_SIZE, newSize2 ); + + // Update + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize2, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + + Vector2 newSize3(10.0f, 10.0f); + Animation animation = Animation::New(1.0f); + animation.AnimateTo( Property( task, RenderTask::VIEWPORT_SIZE ), newSize3, AlphaFunctions::Linear ); + animation.Play(); + + // Perform 1000ms worth of updates at which point animation should have completed. + Wait(application, 1000); + DALI_TEST_EQUALS( task.GetCurrentViewportSize(), newSize3, Math::MACHINE_EPSILON_1, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliRenderTaskSetClearColor(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::SetClearColor()"); + + Vector4 testColor( 1.0f, 2.0f, 3.0f, 4.0f ); + Vector4 testColor2( 5.0f, 6.0f, 7.0f, 8.0f ); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + + RenderTask task = taskList.GetTask( 0u ); + DALI_TEST_CHECK( task.GetClearColor() != testColor ); + + task.SetClearColor( testColor ); + + // Wait a frame. + Wait(application); + + DALI_TEST_EQUALS( task.GetClearColor(), testColor, TEST_LOCATION ); + + task.SetProperty( RenderTask::CLEAR_COLOR, testColor2 ); + + // Wait a frame. + Wait(application); + + DALI_TEST_EQUALS( task.GetClearColor(), testColor2, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliRenderTaskGetClearColor(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::GetClearColor()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + RenderTask task = taskList.GetTask( 0u ); + DALI_TEST_EQUALS( task.GetClearColor(), RenderTask::DEFAULT_CLEAR_COLOR, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliRenderTaskSetClearEnabled(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::SetClearEnabled()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + + RenderTask task = taskList.GetTask( 0u ); + DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false + + task.SetClearEnabled( true ); + DALI_TEST_EQUALS( task.GetClearEnabled(), true, TEST_LOCATION ); + + task.SetClearEnabled( false ); + DALI_TEST_EQUALS( task.GetClearEnabled(), false, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliRenderTaskGetClearEnabled(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::GetClearEnabled()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + + RenderTask task = taskList.GetTask( 0u ); + DALI_TEST_CHECK( !task.GetClearEnabled() ); // defaults to false + END_TEST; +} + +int UtcDaliRenderTaskSetRefreshRate(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::SetRefreshRate()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + + // By default tasks will be processed every frame + RenderTask task = taskList.GetTask( 0u ); + DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() ); + + task.SetRefreshRate( 2u ); // every-other frame + DALI_TEST_CHECK( 2u == task.GetRefreshRate() ); + + task.SetRefreshRate( RenderTask::REFRESH_ALWAYS ); + DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() ); + END_TEST; +} + +int UtcDaliRenderTaskGetRefreshRate(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::GetRefreshRate()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + + // By default tasks will be processed every frame + RenderTask task = taskList.GetTask( 0u ); + DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == task.GetRefreshRate() ); + + RenderTask newTask = taskList.CreateTask(); + DALI_TEST_CHECK( RenderTask::REFRESH_ALWAYS == newTask.GetRefreshRate() ); + END_TEST; +} + +int UtcDaliRenderTaskSignalFinished(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask::SignalFinished()"); + + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction(); + + CameraActor offscreenCameraActor = CameraActor::New(); + + Stage::GetCurrent().Add( offscreenCameraActor ); + + BitmapImage image = BitmapImage::New( 10, 10 ); + ImageActor rootActor = ImageActor::New( image ); + rootActor.SetSize( 10, 10 ); + Stage::GetCurrent().Add( rootActor ); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + NativeImagePtr testNativeImagePtr = new TestNativeImage(10, 10); + FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() ); + + // Flush all outstanding messages + application.SendNotification(); + application.Render(); + + RenderTask newTask = taskList.CreateTask(); + newTask.SetCameraActor( offscreenCameraActor ); + newTask.SetSourceActor( rootActor ); + newTask.SetInputEnabled( false ); + newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) ); + newTask.SetClearEnabled( true ); + newTask.SetExclusive( true ); + newTask.SetRefreshRate( RenderTask::REFRESH_ONCE ); + newTask.SetTargetFrameBuffer( frameBufferImage ); + + // Framebuffer doesn't actually get created until Connected, i.e. by previous line + + bool finished = false; + RenderTaskFinished renderTaskFinished( finished ); + newTask.FinishedSignal().Connect( &application, renderTaskFinished ); + + // Flush the queue and render. + application.SendNotification(); + + // 1 render to process render task, then wait for sync before finished msg is sent + // from update to the event thread. + + application.Render(); + application.SendNotification(); + DALI_TEST_CHECK( !finished ); + + Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject(); + DALI_TEST_CHECK( lastSyncObj != NULL ); + + application.Render(); + DALI_TEST_EQUALS( (application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION ); + application.SendNotification(); + DALI_TEST_CHECK( !finished ); + + application.Render(); + DALI_TEST_EQUALS( (application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION ); + application.SendNotification(); + DALI_TEST_CHECK( ! finished ); + + sync.SetObjectSynced( lastSyncObj, true ); + + application.Render(); + application.SendNotification(); + DALI_TEST_CHECK( !finished ); + + application.Render(); + application.SendNotification(); + DALI_TEST_CHECK( finished ); + finished = false; + + application.Render(); // Double check no more finished signal + application.SendNotification(); + DALI_TEST_CHECK( ! finished ); + END_TEST; +} + + +int UtcDaliRenderTaskContinuous01(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not staged)\nPOST:continuous renders, no Finished signal"); + + // SETUP AN OFFSCREEN RENDER TASK + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + CameraActor offscreenCameraActor = CameraActor::New(); + Stage::GetCurrent().Add( offscreenCameraActor ); + + ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", Image::Immediate, Image::Unused); + Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); + Integration::ResourceId imageRequestId = imageRequest->GetId(); + Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true); + bool finished = false; + RenderTaskFinished renderTaskFinished( finished ); + newTask.FinishedSignal().Connect( &application, renderTaskFinished ); + CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete + application.SendNotification(); + + // START PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + // ADD SOURCE ACTOR TO STAGE - expect continuous renders to start, no finished signal + Stage::GetCurrent().Add(secondRootActor); + application.SendNotification(); + + // CONTINUE PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + END_TEST; +} + + +int UtcDaliRenderTaskContinuous02(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (source actor not visible)\nPOST:continuous renders, no Finished signal"); + + // SETUP AN OFFSCREEN RENDER TASK + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + CameraActor offscreenCameraActor = CameraActor::New(); + Stage::GetCurrent().Add( offscreenCameraActor ); + + ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", Image::Immediate, Image::Unused); + Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); + Integration::ResourceId imageRequestId = imageRequest->GetId(); + Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + Stage::GetCurrent().Add(secondRootActor); + secondRootActor.SetVisible(false); + + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true); + bool finished = false; + RenderTaskFinished renderTaskFinished( finished ); + newTask.FinishedSignal().Connect( &application, renderTaskFinished ); + CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete + application.SendNotification(); + + // START PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + // MAKE SOURCE ACTOR VISIBLE - expect continuous renders to start, no finished signal + secondRootActor.SetVisible(true); + application.SendNotification(); + + // CONTINUE PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + END_TEST; +} + +int UtcDaliRenderTaskContinuous03(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: render task not ready (camera actor not staged)\nPOST:continuous renders, no Finished signal"); + + // SETUP AN OFFSCREEN RENDER TASK + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + CameraActor offscreenCameraActor = CameraActor::New(); + ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", Image::Immediate, Image::Unused); + Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); + Integration::ResourceId imageRequestId = imageRequest->GetId(); + Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + Stage::GetCurrent().Add(secondRootActor); + + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true); + bool finished = false; + RenderTaskFinished renderTaskFinished( finished ); + newTask.FinishedSignal().Connect( &application, renderTaskFinished ); + CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete + application.SendNotification(); + + // START PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + // ADD CAMERA ACTOR TO STAGE - expect continuous renders to start, no finished signal + Stage::GetCurrent().Add( offscreenCameraActor ); + application.SendNotification(); + + // CONTINUE PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + END_TEST; +} + + +int UtcDaliRenderTaskContinuous04(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: Resource not ready\nPOST:continuous renders, no Finished signal"); + + // SETUP AN OFFSCREEN RENDER TASK + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + CameraActor offscreenCameraActor = CameraActor::New(); + Stage::GetCurrent().Add( offscreenCameraActor ); + ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", Image::Immediate, Image::Unused); + Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); + Integration::ResourceId imageRequestId = imageRequest->GetId(); + Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + Stage::GetCurrent().Add(secondRootActor); + + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true); + bool finished = false; + RenderTaskFinished renderTaskFinished( finished ); + newTask.FinishedSignal().Connect( &application, renderTaskFinished ); + application.SendNotification(); + + // START PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + // FINISH RESOURCE LOADING - expect continuous renders to start, no finished signal + CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + + // CONTINUE PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + END_TEST; +} + +int UtcDaliRenderTaskContinuous05(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask Render Continuous, every 3 frames using loading image\nPRE: Resources not ready\nPOST:continuous renders, no Finished signal"); + + // SETUP AN OFFSCREEN RENDER TASK + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + CameraActor offscreenCameraActor = CameraActor::New(); + Stage::GetCurrent().Add( offscreenCameraActor ); + ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", Image::Immediate, Image::Unused); + Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); + Integration::ResourceId imageRequestId = imageRequest->GetId(); + Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + Stage::GetCurrent().Add(secondRootActor); + + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, 3, true); + bool finished = false; + RenderTaskFinished renderTaskFinished( finished ); + newTask.FinishedSignal().Connect( &application, renderTaskFinished ); + application.SendNotification(); + + // START PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + // FINISH RESOURCE LOADING - expect continuous renders to start, no finished signal + CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + END_TEST; +} + +int UtcDaliRenderTaskContinuous06(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask Render Continuous, every 3 frames using loading image\nPRE: Render Always, Resources not ready\nPOST:continuous renders at reduced freq, no Finished signal"); + + // SETUP AN OFFSCREEN RENDER TASK + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + CameraActor offscreenCameraActor = CameraActor::New(); + Stage::GetCurrent().Add( offscreenCameraActor ); + ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", Image::Immediate, Image::Unused); + Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); + Integration::ResourceId imageRequestId = imageRequest->GetId(); + Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + Stage::GetCurrent().Add(secondRootActor); + + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true); + bool finished = false; + RenderTaskFinished renderTaskFinished( finished ); + newTask.FinishedSignal().Connect( &application, renderTaskFinished ); + application.SendNotification(); + + // START PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + // FINISH RESOURCE LOADING - expect continuous renders to start, no finished signal + CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + + // CHANGE FREQUENCY + newTask.SetRefreshRate(3); // Input, Expected Input, Expected + application.SendNotification(); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + newTask.SetRefreshRate(RenderTask::REFRESH_ALWAYS); // Should render every frame immediately + application.SendNotification(); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + END_TEST; +} + + +int UtcDaliRenderTaskOnce01(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask Render Once GlSync, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only"); + + // SETUP AN OFFSCREEN RENDER TASK + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction(); + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + CameraActor offscreenCameraActor = CameraActor::New(); + Stage::GetCurrent().Add( offscreenCameraActor ); + ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", Image::Immediate, Image::Unused); + Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); + Integration::ResourceId imageRequestId = imageRequest->GetId(); + Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + + Stage::GetCurrent().Add(secondRootActor); + secondRootActor.SetVisible(false); + + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true); + bool finished = false; + RenderTaskFinished renderTaskFinished( finished ); + newTask.FinishedSignal().Connect( &application, renderTaskFinished ); + application.SendNotification(); + + // START PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + // MAKE SOURCE VISIBLE + secondRootActor.SetVisible(true); + application.SendNotification(); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + // FINISH RESOURCE LOADING - expect no rendering yet + CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject(); + DALI_TEST_CHECK( lastSyncObj != NULL ); + + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + sync.SetObjectSynced( lastSyncObj, true ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true ) ); + + // Finished rendering - expect no more renders, no more signals: + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + END_TEST; +} + +int UtcDaliRenderTaskOnce02(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask Render Once GlSync, using loading image. Switch from render always after ready to render once\n" + "PRE: Render task ready, Image not loaded\n" + "POST: Finished signal sent only once"); + + // SETUP A CONTINUOUS OFFSCREEN RENDER TASK + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction(); + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + CameraActor offscreenCameraActor = CameraActor::New(); + Stage::GetCurrent().Add( offscreenCameraActor ); + ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", Image::Immediate, Image::Unused); + Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); + Integration::ResourceId imageRequestId = imageRequest->GetId(); + Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + Stage::GetCurrent().Add(secondRootActor); + + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true); + bool finished = false; + RenderTaskFinished renderTaskFinished( finished ); + newTask.FinishedSignal().Connect( &application, renderTaskFinished ); + application.SendNotification(); + + // START PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + // FINISH RESOURCE LOADING + CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + + newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); + application.SendNotification(); // Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject(); + DALI_TEST_CHECK( lastSyncObj != NULL ); + + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + sync.SetObjectSynced( lastSyncObj, true ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true ) ); + + // Finished rendering - expect no more renders, no more signals: + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + END_TEST; +} + + +int UtcDaliRenderTaskOnce03(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask Render Once GlSync\n" + "Switch from Render always after ready to render once with resources unready\n" + "PRE: Everything ready to render\n" + "POST: Finished signal sent once"); + + // SETUP A CONTINUOUS OFFSCREEN RENDER TASK + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction(); + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + CameraActor offscreenCameraActor = CameraActor::New(); + Stage::GetCurrent().Add( offscreenCameraActor ); + ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", Image::Immediate, Image::Unused); + Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); + Integration::ResourceId imageRequestId = imageRequest->GetId(); + Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + Stage::GetCurrent().Add(secondRootActor); + + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true); + bool finished = false; + RenderTaskFinished renderTaskFinished( finished ); + newTask.FinishedSignal().Connect( &application, renderTaskFinished ); + application.SendNotification(); + + // START PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + // CHANGE TO RENDER ONCE + newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); + application.SendNotification(); // Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + // FINISH RESOURCE LOADING + CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject(); + DALI_TEST_CHECK( lastSyncObj != NULL ); + + sync.SetObjectSynced( lastSyncObj, true ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true ) ); + + // Finished rendering - expect no more renders, no more signals: + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + END_TEST; +} + +#if 0 +//int UtcDaliRenderTaskOnce04(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask Render Once GlSync\n" + "During RenderOnce, make ready resources unready before sending first finished signal\n" + "PRE: Everything ready.\n" + "POST: Finished signal sent only once"); + + // SETUP A CONTINUOUS OFFSCREEN RENDER TASK + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction(); + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + CameraActor offscreenCameraActor = CameraActor::New(); + Stage::GetCurrent().Add( offscreenCameraActor ); + ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", Image::Immediate, Image::Unused); + Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); + Integration::ResourceId imageRequestId = imageRequest->GetId(); + Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete + application.Render(); + + Stage::GetCurrent().Add(secondRootActor); + + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true); + bool finished = false; + RenderTaskFinished renderTaskFinished( finished ); + newTask.FinishedSignal().Connect( &application, renderTaskFinished ); + application.SendNotification(); + + // START PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + + // CHANGE TO RENDER ONCE, RESOURCES BECOME NOT READY + newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); + + // Doesn't work... + ReloadImage(application, secondRootActor.GetImage()); + application.SendNotification(); // Input, Expected Input, Expected + + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_EQUALS( secondRootActor.GetImage().GetLoadingState(), Dali::ResourceLoading, TEST_LOCATION); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + // FINISH RESOURCE LOADING + CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject(); + DALI_TEST_CHECK( lastSyncObj != NULL ); + + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + sync.SetObjectSynced( lastSyncObj, true ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true ) ); + + // Finished rendering - expect no more renders, no more signals: + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + END_TEST; +} +#endif + +int UtcDaliRenderTaskOnce05(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask Render Once GLSync\n" + "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n" + "PRE: Everything ready\n" + "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)"); + + // SETUP A CONTINUOUS OFFSCREEN RENDER TASK + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction(); + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + CameraActor offscreenCameraActor = CameraActor::New(); + Stage::GetCurrent().Add( offscreenCameraActor ); + ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", Image::Immediate, Image::Unused); + Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); + Integration::ResourceId imageRequestId = imageRequest->GetId(); + Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete + application.Render(); + + Stage::GetCurrent().Add(secondRootActor); + + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true); + bool finished = false; + RenderTaskFinished renderTaskFinished( finished ); + newTask.FinishedSignal().Connect( &application, renderTaskFinished ); + application.SendNotification(); + + // START PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + + // CHANGE TO RENDER ONCE, + newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); + application.SendNotification(); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject(); + DALI_TEST_CHECK( lastSyncObj != NULL ); + + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + sync.SetObjectSynced( lastSyncObj, true ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); + application.SendNotification(); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + lastSyncObj = sync.GetLastSyncObject(); + DALI_TEST_CHECK( lastSyncObj != NULL ); + + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + sync.SetObjectSynced( lastSyncObj, true ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + END_TEST; +} + +int UtcDaliRenderTaskOnce06(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask Render Once GLSync\n" + "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers " + "another render & another finished signal\n" + "PRE: Everything ready\n" + "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)"); + + + // SETUP A CONTINUOUS OFFSCREEN RENDER TASK + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction(); + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + CameraActor offscreenCameraActor = CameraActor::New(); + Stage::GetCurrent().Add( offscreenCameraActor ); + ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", Image::Immediate, Image::Unused); + Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); + Integration::ResourceId imageRequestId = imageRequest->GetId(); + Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete + application.Render(); + + Stage::GetCurrent().Add(secondRootActor); + + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true); + bool finished = false; + + ConnectionTracker connectionTracker; + RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished ); + newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain ); + + application.SendNotification(); + + // START PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject(); + DALI_TEST_CHECK( lastSyncObj == NULL ); + + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + + // CHANGE TO RENDER ONCE, + newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); + application.SendNotification(); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + lastSyncObj = sync.GetLastSyncObject(); + DALI_TEST_CHECK( lastSyncObj != NULL ); + + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + sync.SetObjectSynced( lastSyncObj, true ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true ) ); + application.SendNotification(); + + // Expect SetRefreshRate to have been called again + // Prevent next finished signal calling refresh once again + RenderTaskFinished renderTaskFinished( finished ); + connectionTracker.DisconnectAll(); + newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + lastSyncObj = sync.GetLastSyncObject(); + DALI_TEST_CHECK( lastSyncObj != NULL ); + + sync.SetObjectSynced( lastSyncObj, true ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true ) ); + + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + END_TEST; +} + + +int UtcDaliRenderTaskOnce07(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask Render Once GlSync\n" + "SetRefreshRate(ONCE) again before first finished signal has been sent.\n" + "PRE: resources ready\n" + "POST: Only 1 finished signal sent."); + + // SETUP A CONTINUOUS OFFSCREEN RENDER TASK + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction(); + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + CameraActor offscreenCameraActor = CameraActor::New(); + Stage::GetCurrent().Add( offscreenCameraActor ); + ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", Image::Immediate, Image::Unused); + Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); + Integration::ResourceId imageRequestId = imageRequest->GetId(); + Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete + application.Render(); + + Stage::GetCurrent().Add(secondRootActor); + + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true); + bool finished = false; + RenderTaskFinished renderTaskFinished( finished ); + newTask.FinishedSignal().Connect( &application, renderTaskFinished ); + application.SendNotification(); + + // START PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + + // CHANGE TO RENDER ONCE, + newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); + application.SendNotification(); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); + application.SendNotification(); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject(); + DALI_TEST_CHECK( lastSyncObj != NULL ); + + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + sync.SetObjectSynced( lastSyncObj, true ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true ) ); + + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + END_TEST; +} + + + +int UtcDaliRenderTaskOnce08(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask Render Once GlSync\n" + "SetRefreshRate(ONCE), resource load failed completes render task.\n" + "PRE: resources not ready\n" + "POST: Only 1 finished signal sent."); + + // SETUP A CONTINUOUS OFFSCREEN RENDER TASK + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction(); + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + CameraActor offscreenCameraActor = CameraActor::New(); + Stage::GetCurrent().Add( offscreenCameraActor ); + ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", Image::Immediate, Image::Unused); + Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); + Integration::ResourceId imageRequestId = imageRequest->GetId(); + Stage::GetCurrent().Add(secondRootActor); + + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true); + bool finished = false; + RenderTaskFinished renderTaskFinished( finished ); + newTask.FinishedSignal().Connect( &application, renderTaskFinished ); + application.SendNotification(); + + // START PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + // CHANGE TO RENDER ONCE, + newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); + application.SendNotification(); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); // nothing to draw + Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject(); + DALI_TEST_CHECK( lastSyncObj != NULL ); + + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + sync.SetObjectSynced( lastSyncObj, true ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true ) ); + + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + END_TEST; +} + + + +int UtcDaliRenderTaskOnceNoSync01(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask Render Once, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only"); + + // SETUP AN OFFSCREEN RENDER TASK + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + CameraActor offscreenCameraActor = CameraActor::New(); + Stage::GetCurrent().Add( offscreenCameraActor ); + ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", Image::Immediate, Image::Unused); + Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); + Integration::ResourceId imageRequestId = imageRequest->GetId(); + Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + + Stage::GetCurrent().Add(secondRootActor); + secondRootActor.SetVisible(false); + + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false); + bool finished = false; + RenderTaskFinished renderTaskFinished( finished ); + newTask.FinishedSignal().Connect( &application, renderTaskFinished ); + application.SendNotification(); + + // START PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + // MAKE SOURCE VISIBLE + secondRootActor.SetVisible(true); + application.SendNotification(); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + // FINISH RESOURCE LOADING - expect immediate rendering yet + CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + END_TEST; +} + +int UtcDaliRenderTaskOnceNoSync02(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask Render Once, using loading image. Switch from render always after ready to render once\n" + "PRE: Render task ready, Image not loaded\n" + "POST: Finished signal sent only once"); + + // SETUP A CONTINUOUS OFFSCREEN RENDER TASK + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + CameraActor offscreenCameraActor = CameraActor::New(); + Stage::GetCurrent().Add( offscreenCameraActor ); + ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", Image::Immediate, Image::Unused); + Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); + Integration::ResourceId imageRequestId = imageRequest->GetId(); + Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + Stage::GetCurrent().Add(secondRootActor); + + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false); + bool finished = false; + RenderTaskFinished renderTaskFinished( finished ); + newTask.FinishedSignal().Connect( &application, renderTaskFinished ); + application.SendNotification(); + + // START PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + // FINISH RESOURCE LOADING + CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + + newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); + application.SendNotification(); // Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + END_TEST; +} + + +int UtcDaliRenderTaskOnceNoSync03(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask Render Once\n" + "Switch from Render always after ready to render once with resources unready\n" + "PRE: Everything ready to render\n" + "POST: Finished signal sent once"); + + // SETUP A CONTINUOUS OFFSCREEN RENDER TASK + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + CameraActor offscreenCameraActor = CameraActor::New(); + Stage::GetCurrent().Add( offscreenCameraActor ); + ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", Image::Immediate, Image::Unused); + Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); + Integration::ResourceId imageRequestId = imageRequest->GetId(); + Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + Stage::GetCurrent().Add(secondRootActor); + + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false); + bool finished = false; + RenderTaskFinished renderTaskFinished( finished ); + newTask.FinishedSignal().Connect( &application, renderTaskFinished ); + application.SendNotification(); + + // START PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + // CHANGE TO RENDER ONCE + newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); + application.SendNotification(); // Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + // FINISH RESOURCE LOADING + CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + END_TEST; +} + +#if 0 +//int UtcDaliRenderTaskOnceNoSync04(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask Render Once\n" + "During RenderOnce, make ready resources unready before sending first finished signal\n" + "PRE: Everything ready.\n" + "POST: Finished signal sent only once"); + + // SETUP A CONTINUOUS OFFSCREEN RENDER TASK + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + CameraActor offscreenCameraActor = CameraActor::New(); + Stage::GetCurrent().Add( offscreenCameraActor ); + ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", Image::Immediate, Image::Unused); + Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); + Integration::ResourceId imageRequestId = imageRequest->GetId(); + Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete + application.Render(); + + Stage::GetCurrent().Add(secondRootActor); + + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false); + bool finished = false; + RenderTaskFinished renderTaskFinished( finished ); + newTask.FinishedSignal().Connect( &application, renderTaskFinished ); + application.SendNotification(); + + // START PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + + // CHANGE TO RENDER ONCE, RESOURCES BECOME NOT READY + newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); + + // Doesn't work... + ReloadImage(application, secondRootActor.GetImage()); + application.SendNotification(); // Input, Expected Input, Expected + + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_EQUALS( secondRootActor.GetImage().GetLoadingState(), Dali::ResourceLoading, TEST_LOCATION); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + // FINISH RESOURCE LOADING + CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, true ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + END_TEST; +} +#endif + +int UtcDaliRenderTaskOnceNoSync05(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask Render Once\n" + "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n" + "PRE: Everything ready\n" + "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)"); + + // SETUP A CONTINUOUS OFFSCREEN RENDER TASK + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + CameraActor offscreenCameraActor = CameraActor::New(); + Stage::GetCurrent().Add( offscreenCameraActor ); + ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", Image::Immediate, Image::Unused); + Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); + Integration::ResourceId imageRequestId = imageRequest->GetId(); + Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete + application.Render(); + + Stage::GetCurrent().Add(secondRootActor); + + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false); + bool finished = false; + RenderTaskFinished renderTaskFinished( finished ); + newTask.FinishedSignal().Connect( &application, renderTaskFinished ); + application.SendNotification(); + + // START PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + + // CHANGE TO RENDER ONCE, + newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); + application.SendNotification(); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); + application.SendNotification(); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + END_TEST; +} + +int UtcDaliRenderTaskOnceNoSync06(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask Render Once\n" + "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers\n" + "another render & another finished signal\n" + "PRE: Everything ready\n" + "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)"); + + + // SETUP A CONTINUOUS OFFSCREEN RENDER TASK + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + CameraActor offscreenCameraActor = CameraActor::New(); + Stage::GetCurrent().Add( offscreenCameraActor ); + ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", Image::Immediate, Image::Unused); + Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); + Integration::ResourceId imageRequestId = imageRequest->GetId(); + Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete + application.Render(); + + Stage::GetCurrent().Add(secondRootActor); + + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false); + bool finished = false; + + ConnectionTracker connectionTracker; + RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished ); + newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain ); + + application.SendNotification(); + + // START PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + + // CHANGE TO RENDER ONCE, + newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); + application.SendNotification(); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true ) ); + + // Expect SetRefreshRate to have been called again + // Prevent next finished signal calling refresh once again + RenderTaskFinished renderTaskFinished( finished ); + connectionTracker.DisconnectAll(); + newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished ); + + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + END_TEST; +} + + +int UtcDaliRenderTaskOnceNoSync07(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask Render Once\n" + "SetRefreshRate(ONCE) again before first finished signal has been sent.\n" + "PRE: resources ready\n" + "POST: Only 1 finished signal sent."); + + // SETUP A CONTINUOUS OFFSCREEN RENDER TASK + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + CameraActor offscreenCameraActor = CameraActor::New(); + Stage::GetCurrent().Add( offscreenCameraActor ); + ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", Image::Immediate, Image::Unused); + Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); + Integration::ResourceId imageRequestId = imageRequest->GetId(); + Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete + application.Render(); + + Stage::GetCurrent().Add(secondRootActor); + + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false); + bool finished = false; + RenderTaskFinished renderTaskFinished( finished ); + newTask.FinishedSignal().Connect( &application, renderTaskFinished ); + application.SendNotification(); + + // START PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + + // CHANGE TO RENDER ONCE, + newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); + application.SendNotification(); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); + application.SendNotification(); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + END_TEST; +} + +int UtcDaliRenderTaskOnceNoSync08(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask Render Once\n" + "SetRefreshRate(ONCE), resource load failed, completes render task.\n" + "PRE: resources not ready\n" + "POST: Only 1 finished signal sent."); + + // SETUP A CONTINUOUS OFFSCREEN RENDER TASK + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + CameraActor offscreenCameraActor = CameraActor::New(); + Stage::GetCurrent().Add( offscreenCameraActor ); + ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", Image::Immediate, Image::Unused); + Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); + Integration::ResourceId imageRequestId = imageRequest->GetId(); + Stage::GetCurrent().Add(secondRootActor); + + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false); + bool finished = false; + RenderTaskFinished renderTaskFinished( finished ); + newTask.FinishedSignal().Connect( &application, renderTaskFinished ); + application.SendNotification(); + + // START PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + // CHANGE TO RENDER ONCE, + newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); + application.SendNotification(); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + + FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); // nothing to draw + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false ) ); + END_TEST; +} + + + +int UtcDaliRenderTaskOnceChain01(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTask Render Once Chained render tasks\n" + "SetRefreshRate(ONCE), resource load completes, both render tasks render.\n" + "PRE: resources not ready\n" + "POST: 2 finished signals sent."); + + // SETUP A CONTINUOUS OFFSCREEN RENDER TASK + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + + Actor defaultRootActor = Actor::New(); // Root for default RT + Stage::GetCurrent().Add( defaultRootActor ); + + CameraActor offscreenCameraActor = CameraActor::New(); + Stage::GetCurrent().Add( offscreenCameraActor ); + ImageActor firstRootActor = CreateLoadingImage(application, "aFile.jpg", Image::Immediate, Image::Unused); + Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); + Integration::ResourceId imageRequestId = imageRequest->GetId(); + Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + Stage::GetCurrent().Add(firstRootActor); + + // first render task + RenderTask firstTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, firstRootActor, RenderTask::REFRESH_ONCE, false); + bool firstFinished = false; + RenderTaskFinished renderTask1Finished( firstFinished ); + firstTask.FinishedSignal().Connect( &application, renderTask1Finished ); + + // Second render task + FrameBufferImage fbo = firstTask.GetTargetFrameBuffer(); + ImageActor secondRootActor = ImageActor::New( fbo ); + Stage::GetCurrent().Add(secondRootActor); + RenderTask secondTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, secondRootActor, RenderTask::REFRESH_ONCE, false); + bool secondFinished = false; + RenderTaskFinished renderTask2Finished( secondFinished ); + secondTask.FinishedSignal().Connect( &application, renderTask2Finished ); + + application.SendNotification(); + + // START PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false ) ); + DALI_TEST_CHECK( secondFinished == false ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false ) ); + DALI_TEST_CHECK( secondFinished == false ); + + CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false ) ); + DALI_TEST_CHECK( secondFinished == false ); + application.GetPlatform().ClearReadyResources(); + + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, firstFinished, true ) ); + DALI_TEST_CHECK( secondFinished == true ); + + secondFinished = false; + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, firstFinished, false ) ); + DALI_TEST_CHECK( secondFinished == false ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, firstFinished, false ) ); + DALI_TEST_CHECK( secondFinished == false ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, firstFinished, false ) ); + DALI_TEST_CHECK( secondFinished == false ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, firstFinished, false ) ); + DALI_TEST_CHECK( secondFinished == false ); + + END_TEST; +} + +int UtcDaliRenderTaskProperties(void) +{ + TestApplication application; + + RenderTask task = Stage::GetCurrent().GetRenderTaskList().CreateTask(); + + Property::IndexContainer indices; + task.GetPropertyIndices( indices ); + DALI_TEST_CHECK( ! indices.empty() ); + DALI_TEST_EQUALS( indices.size(), task.GetPropertyCount(), TEST_LOCATION ); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-RenderTaskList.cpp b/automated-tests/src/dali/utc-Dali-RenderTaskList.cpp new file mode 100644 index 0000000..99f4147 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-RenderTaskList.cpp @@ -0,0 +1,138 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +using namespace Dali; + +void utc_dali_render_task_list_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_render_task_list_cleanup(void) +{ + test_return_value = TET_PASS; +} + +int UtcDaliRenderTaskListDefaultConstructor(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTaskList::RenderTaskList()"); + + RenderTaskList taskList; + + DALI_TEST_CHECK( ! taskList ); + END_TEST; +} + +int UtcDaliRenderTaskListDownCast(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTaskList::DownCast()"); + + BaseHandle base = Stage::GetCurrent().GetRenderTaskList(); + + RenderTaskList taskList = RenderTaskList::DownCast( base ); + + DALI_TEST_CHECK( taskList ); + + // Try calling a method + DALI_TEST_CHECK( 1u == taskList.GetTaskCount() ); + END_TEST; +} + +int UtcDaliRenderTaskListCreateTask(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTaskList::CreateTask()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + DALI_TEST_CHECK( 1u == taskList.GetTaskCount() ); + + taskList.CreateTask(); + DALI_TEST_CHECK( 2u == taskList.GetTaskCount() ); + END_TEST; +} + +int UtcDaliRenderTaskListRemoveTask(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTaskList::RemoveTask()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + DALI_TEST_CHECK( 1u == taskList.GetTaskCount() ); + + RenderTask newTask = taskList.CreateTask(); + DALI_TEST_CHECK( 2u == taskList.GetTaskCount() ); + + taskList.RemoveTask( newTask ); + DALI_TEST_CHECK( 1u == taskList.GetTaskCount() ); + END_TEST; +} + +int UtcDaliRenderTaskListGetTaskCount(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTaskList::GetTaskCount()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + DALI_TEST_CHECK( 1u == taskList.GetTaskCount() ); + + taskList.RemoveTask( taskList.GetTask(0u) ); + DALI_TEST_CHECK( 0u == taskList.GetTaskCount() ); + END_TEST; +} + +int UtcDaliRenderTaskListGetTask(void) +{ + TestApplication application; + + tet_infoline("Testing RenderTaskList::GetTask()"); + + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); + RenderTask defaultTask = taskList.GetTask( 0u ); + DALI_TEST_CHECK( 1u == taskList.GetTaskCount() ); + DALI_TEST_CHECK( defaultTask ); + DALI_TEST_CHECK( defaultTask == taskList.GetTask( 0u ) ); + + RenderTask newTask = taskList.CreateTask(); + DALI_TEST_CHECK( 2u == taskList.GetTaskCount() ); + + RenderTask temp = taskList.GetTask( 0u ); + RenderTask temp2 = taskList.GetTask( 1u ); + + DALI_TEST_CHECK( newTask ); + DALI_TEST_CHECK( defaultTask != newTask ); + DALI_TEST_CHECK( taskList.GetTask( 0u ) == defaultTask ); + DALI_TEST_CHECK( taskList.GetTask( 1u ) == newTask ); + DALI_TEST_CHECK( taskList.GetTask( 1u ) != defaultTask ); + + taskList.RemoveTask( taskList.GetTask(0u) ); + DALI_TEST_CHECK( 1u == taskList.GetTaskCount() ); + DALI_TEST_CHECK( taskList.GetTask( 0u ) != defaultTask ); + DALI_TEST_CHECK( taskList.GetTask( 0u ) == newTask ); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-RenderableActor.cpp b/automated-tests/src/dali/utc-Dali-RenderableActor.cpp new file mode 100644 index 0000000..6e5ac19 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-RenderableActor.cpp @@ -0,0 +1,503 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 std; + +void renderable_actor_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void renderable_actor_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ + +static const char* TestTextHelloWorld = "Hello World"; +static bool gIsActor1SortModifierCorrect; +static bool gIsActor2SortModifierCorrect; +const float gActor1SortModifierValue = 96.0f; +const float gActor2SortModifierValue = 53.0f; + +static float TestSortFunction(const Vector3& position, float sortModifier) +{ + if ( fabs(sortModifier - gActor1SortModifierValue) < 0.01) + gIsActor1SortModifierCorrect = true; + + if ( fabs(sortModifier - gActor2SortModifierValue) < 0.01) + gIsActor2SortModifierCorrect = true; + + return 0.0f; +} + +} // anon namespace + +int UtcDaliRenderableActorDownCast(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::RenderableActor::DownCast()"); + + TextActor textActor = TextActor::New(TestTextHelloWorld); + + Actor anActor = Actor::New(); + anActor.Add( textActor ); + + Actor child = anActor.GetChildAt(0); + RenderableActor renderableActor = RenderableActor::DownCast( child ); + DALI_TEST_CHECK( renderableActor ); + + renderableActor = NULL; + DALI_TEST_CHECK( !renderableActor ); + + renderableActor = DownCast< RenderableActor >( child ); + DALI_TEST_CHECK( renderableActor ); + + renderableActor = DownCast< RenderableActor >( anActor ); + DALI_TEST_CHECK( !renderableActor ); + + Actor unInitialzedActor; + renderableActor = RenderableActor::DownCast( unInitialzedActor ); + DALI_TEST_CHECK( !renderableActor ); + + renderableActor = DownCast< RenderableActor >( unInitialzedActor ); + DALI_TEST_CHECK( !renderableActor ); + END_TEST; +} + +int UtcDaliRenderableActorSetSortModifier(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::RenderableActor::SetSortModifier()"); + + float val = -500.0f; + + TextActor actor = TextActor::New(TestTextHelloWorld); + Stage::GetCurrent().Add(actor); + + actor.SetSortModifier( val ); + + float returnValue = actor.GetSortModifier(); + + //Verify through actor api + DALI_TEST_EQUALS(returnValue, val, TEST_LOCATION); + + Stage::GetCurrent().Remove(actor); + + + //Verify through layer SetSortFunction + gIsActor1SortModifierCorrect = false; + gIsActor2SortModifierCorrect = false; + BitmapImage img = BitmapImage::New( 1,1 ); + // create two transparent actors so there is something to sort + ImageActor actor1 = ImageActor::New( img ); + ImageActor actor2 = ImageActor::New( img ); + actor1.SetSize(1,1); + actor1.SetPosition( 0, 0, 0); + actor1.SetSortModifier( gActor1SortModifierValue ); + actor1.SetColor( Vector4(1, 1, 1, 0.5f ) ); // 50% transparent + actor2.SetSize(1,1); + actor2.SetPosition( 0, 0, 1); + actor2.SetSortModifier( gActor2SortModifierValue ); + actor2.SetColor( Vector4(1, 1, 1, 0.5f ) ); // 50% transparent + + // add to stage + Stage::GetCurrent().Add( actor1 ); + Stage::GetCurrent().Add( actor2 ); + + Layer root = Stage::GetCurrent().GetLayer( 0 ); + root.SetSortFunction( TestSortFunction ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( gIsActor1SortModifierCorrect && gIsActor2SortModifierCorrect ); + END_TEST; + +} + +int UtcDaliRenderableActorGetSortModifier(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::RenderableActor::GetSortModifier()"); + + TextActor actor = TextActor::New(TestTextHelloWorld); + Stage::GetCurrent().Add(actor); + + DALI_TEST_EQUALS(actor.GetSortModifier(), 0.0f, TEST_LOCATION); + + Stage::GetCurrent().Remove(actor); + END_TEST; +} + +int UtcDaliRenderableActorSetGetBlendMode(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::RenderableActor::SetBlendMode() / Dali::RenderableActor::GetBlendMode()"); + + TextActor actor = TextActor::New(TestTextHelloWorld); + + actor.SetBlendMode( BlendingMode::OFF ); + DALI_TEST_CHECK( BlendingMode::OFF == actor.GetBlendMode() ); + + actor.SetBlendMode( BlendingMode::AUTO ); + DALI_TEST_CHECK( BlendingMode::AUTO == actor.GetBlendMode() ); + + actor.SetBlendMode( BlendingMode::ON ); + DALI_TEST_CHECK( BlendingMode::ON == actor.GetBlendMode() ); + END_TEST; +} + +int UtcDaliRenderableActorSetCullFace(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::RenderableActor::SetCullFace()"); + + BitmapImage img = BitmapImage::New( 1,1 ); + ImageActor actor = ImageActor::New( img ); + ImageActor actor2 = ImageActor::New( img ); + + actor.SetSize(100.0f, 100.0f); + actor.SetParentOrigin(ParentOrigin::CENTER); + actor.SetAnchorPoint(AnchorPoint::CENTER); + + actor2.SetSize(100.0f, 100.0f); + actor2.SetParentOrigin(ParentOrigin::CENTER); + actor2.SetAnchorPoint(AnchorPoint::CENTER); + + Stage::GetCurrent().Add(actor); + Stage::GetCurrent().Add(actor2); + + //Verify whether the correct GL calls are made when actor is face culled in front and back, and + // face culling is disabled for actor2 + TraceCallStack& cullFaceTrace = application.GetGlAbstraction().GetCullFaceTrace(); + cullFaceTrace.Enable(true); + actor.SetCullFace( CullFrontAndBack ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + cullFaceTrace.Enable(false); + std::stringstream out; + + //Verify actor gl state + out.str(""); + out << GL_BLEND; + DALI_TEST_EQUALS( cullFaceTrace.TestMethodAndParams(0, "Enable", out.str()), true, TEST_LOCATION); + + out.str(""); + out << GL_CULL_FACE; + DALI_TEST_EQUALS( cullFaceTrace.TestMethodAndParams(1, "Enable", out.str()), true, TEST_LOCATION); + + out.str(""); + out << GL_FRONT_AND_BACK; + DALI_TEST_EQUALS( cullFaceTrace.TestMethodAndParams(2, "CullFace", out.str()), true, TEST_LOCATION); + + //Verify actor2 gl state + out.str(""); + out << GL_CULL_FACE; + DALI_TEST_EQUALS( cullFaceTrace.TestMethodAndParams(3, "Disable", out.str()), true, TEST_LOCATION); + + //Verify state through the actor api + DALI_TEST_CHECK( CullFrontAndBack == actor.GetCullFace() ); + DALI_TEST_CHECK( CullNone == actor2.GetCullFace() ); + + /**************************************************************/ + + //Verify whether the correct GL calls are made when actor2 is face culled in the front + cullFaceTrace.Reset(); + cullFaceTrace.Enable(true); + actor2.SetCullFace( CullFront ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + cullFaceTrace.Enable(false); + + //Verify actor gl state + out.str(""); + out << GL_CULL_FACE; + DALI_TEST_EQUALS( cullFaceTrace.TestMethodAndParams(0, "Enable", out.str()), true, TEST_LOCATION); + + out.str(""); + out << GL_FRONT_AND_BACK; + DALI_TEST_EQUALS( cullFaceTrace.TestMethodAndParams(1, "CullFace", out.str()), true, TEST_LOCATION); + + //Verify actor2 gl state + out.str(""); + out << GL_CULL_FACE; + DALI_TEST_EQUALS( cullFaceTrace.TestMethodAndParams(2, "Enable", out.str()), true, TEST_LOCATION); + + out.str(""); + out << GL_FRONT; + DALI_TEST_EQUALS( cullFaceTrace.TestMethodAndParams(3, "CullFace", out.str()), true, TEST_LOCATION); + + //Verify state through the actor api + DALI_TEST_CHECK( CullFrontAndBack == actor.GetCullFace() ); + DALI_TEST_CHECK( CullFront == actor2.GetCullFace() ); + + /**************************************************************/ + //Verify whether the correct GL calls are made when face culling is disabled for both actors + cullFaceTrace.Reset(); + cullFaceTrace.Enable(true); + actor.SetCullFace( CullNone ); + actor2.SetCullFace( CullNone ); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + cullFaceTrace.Enable(false); + + out.str(""); + out << GL_CULL_FACE; + DALI_TEST_EQUALS( cullFaceTrace.TestMethodAndParams(0, "Disable", out.str()), true, TEST_LOCATION); + + //Verify state through the actor api + DALI_TEST_CHECK( CullNone == actor.GetCullFace() ); + DALI_TEST_CHECK( CullNone == actor2.GetCullFace() ); + + Stage::GetCurrent().Remove(actor); + Stage::GetCurrent().Remove(actor2); + END_TEST; +} + +int UtcDaliRenderableActorGetCullFace(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::RenderableActor::GetCullFace()"); + + TextActor textActor = TextActor::New(TestTextHelloWorld); + + DALI_TEST_CHECK( CullNone == textActor.GetCullFace() ); + + ImageActor imageActor = ImageActor::New(); + + DALI_TEST_CHECK( CullNone == imageActor.GetCullFace() ); + + MeshActor meshActor = MeshActor::New(); + + DALI_TEST_CHECK( CullBack == meshActor.GetCullFace() ); + END_TEST; +} + +int UtcDaliRenderableActorSetGetBlendFunc(void) +{ + TestApplication application; + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + + tet_infoline("Testing Dali::RenderableActor::UtcDaliRenderableActorSetGetBlendFunc()"); + + BitmapImage img = BitmapImage::New( 1,1 ); + ImageActor actor = ImageActor::New( img ); + Stage::GetCurrent().Add( actor ); + application.SendNotification(); + application.Render(); + + // Test the defaults as documented int blending.h + { + BlendingFactor::Type srcFactorRgb( BlendingFactor::ZERO ); + BlendingFactor::Type destFactorRgb( BlendingFactor::ZERO ); + BlendingFactor::Type srcFactorAlpha( BlendingFactor::ZERO ); + BlendingFactor::Type destFactorAlpha( BlendingFactor::ZERO ); + actor.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha ); + DALI_TEST_EQUALS( BlendingFactor::SRC_ALPHA, srcFactorRgb, TEST_LOCATION ); + DALI_TEST_EQUALS( BlendingFactor::ONE_MINUS_SRC_ALPHA, destFactorRgb, TEST_LOCATION ); + DALI_TEST_EQUALS( BlendingFactor::ONE, srcFactorAlpha, TEST_LOCATION ); + DALI_TEST_EQUALS( BlendingFactor::ONE_MINUS_SRC_ALPHA, destFactorAlpha, TEST_LOCATION ); + } + + // Set to non-default values + actor.SetBlendFunc( BlendingFactor::ONE_MINUS_SRC_COLOR, BlendingFactor::SRC_ALPHA_SATURATE ); + + // Test that Set was successful + { + BlendingFactor::Type srcFactorRgb( BlendingFactor::ZERO ); + BlendingFactor::Type destFactorRgb( BlendingFactor::ZERO ); + BlendingFactor::Type srcFactorAlpha( BlendingFactor::ZERO ); + BlendingFactor::Type destFactorAlpha( BlendingFactor::ZERO ); + actor.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha ); + DALI_TEST_EQUALS( BlendingFactor::ONE_MINUS_SRC_COLOR, srcFactorRgb, TEST_LOCATION ); + DALI_TEST_EQUALS( BlendingFactor::SRC_ALPHA_SATURATE, destFactorRgb, TEST_LOCATION ); + DALI_TEST_EQUALS( BlendingFactor::ONE_MINUS_SRC_COLOR, srcFactorAlpha, TEST_LOCATION ); + DALI_TEST_EQUALS( BlendingFactor::SRC_ALPHA_SATURATE, destFactorAlpha, TEST_LOCATION ); + } + + // Render & check GL commands + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION ); + DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION ); + DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION ); + DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION ); + + // Set using separate alpha settings + actor.SetBlendFunc( BlendingFactor::CONSTANT_COLOR, BlendingFactor::ONE_MINUS_CONSTANT_COLOR, + BlendingFactor::CONSTANT_ALPHA, BlendingFactor::ONE_MINUS_CONSTANT_ALPHA ); + + // Test that Set was successful + { + BlendingFactor::Type srcFactorRgb( BlendingFactor::ZERO ); + BlendingFactor::Type destFactorRgb( BlendingFactor::ZERO ); + BlendingFactor::Type srcFactorAlpha( BlendingFactor::ZERO ); + BlendingFactor::Type destFactorAlpha( BlendingFactor::ZERO ); + actor.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha ); + DALI_TEST_EQUALS( BlendingFactor::CONSTANT_COLOR, srcFactorRgb, TEST_LOCATION ); + DALI_TEST_EQUALS( BlendingFactor::ONE_MINUS_CONSTANT_COLOR, destFactorRgb, TEST_LOCATION ); + DALI_TEST_EQUALS( BlendingFactor::CONSTANT_ALPHA, srcFactorAlpha, TEST_LOCATION ); + DALI_TEST_EQUALS( BlendingFactor::ONE_MINUS_CONSTANT_ALPHA, destFactorAlpha, TEST_LOCATION ); + } + + // Render & check GL commands + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( (GLenum)GL_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION ); + DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION ); + DALI_TEST_EQUALS( (GLenum)GL_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION ); + DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliRenderableActorSetGetBlendEquation(void) +{ + TestApplication application; + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + + tet_infoline("Testing Dali::RenderableActor::SetBlendEquation()"); + + BitmapImage img = BitmapImage::New( 1,1 ); + ImageActor actor = ImageActor::New( img ); + Stage::GetCurrent().Add( actor ); + application.SendNotification(); + application.Render(); + + // Test the defaults as documented int blending.h + { + BlendingEquation::Type equationRgb( BlendingEquation::SUBTRACT ); + BlendingEquation::Type equationAlpha( BlendingEquation::SUBTRACT ); + actor.GetBlendEquation( equationRgb, equationAlpha ); + DALI_TEST_EQUALS( BlendingEquation::ADD, equationRgb, TEST_LOCATION ); + DALI_TEST_EQUALS( BlendingEquation::ADD, equationAlpha, TEST_LOCATION ); + } + + // Test the single blending equation setting + { + actor.SetBlendEquation( BlendingEquation::REVERSE_SUBTRACT ); + BlendingEquation::Type equationRgba( BlendingEquation::SUBTRACT ); + actor.GetBlendEquation( equationRgba, equationRgba ); + DALI_TEST_EQUALS( BlendingEquation::REVERSE_SUBTRACT, equationRgba, TEST_LOCATION ); + } + + actor.SetBlendEquation( BlendingEquation::REVERSE_SUBTRACT, BlendingEquation::REVERSE_SUBTRACT ); + + // Test that Set was successful + { + BlendingEquation::Type equationRgb( BlendingEquation::SUBTRACT ); + BlendingEquation::Type equationAlpha( BlendingEquation::SUBTRACT ); + actor.GetBlendEquation( equationRgb, equationAlpha ); + DALI_TEST_EQUALS( BlendingEquation::REVERSE_SUBTRACT, equationRgb, TEST_LOCATION ); + DALI_TEST_EQUALS( BlendingEquation::REVERSE_SUBTRACT, equationAlpha, TEST_LOCATION ); + } + + // Render & check GL commands + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( (GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationRgb(), TEST_LOCATION ); + DALI_TEST_EQUALS( (GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationAlpha(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliRenderableActorSetGetBlendColor(void) +{ + TestApplication application; + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + + tet_infoline("Testing Dali::RenderableActor::SetBlendColor()"); + + BitmapImage img = BitmapImage::New( 1,1 ); + ImageActor actor = ImageActor::New( img ); + Stage::GetCurrent().Add( actor ); + application.SendNotification(); + application.Render(); + + // Test the defaults as documented int blending.h + DALI_TEST_EQUALS( Vector4::ZERO, actor.GetBlendColor(), TEST_LOCATION ); + + actor.SetBlendColor( Color::RED ); + + // Test that Set was successful + DALI_TEST_EQUALS( Color::RED, actor.GetBlendColor(), TEST_LOCATION ); + + // Render & check GL commands + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS( Color::RED, glAbstraction.GetLastBlendColor(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliRenderableActorSetGetAlpha(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::RenderableActor::SetGetAlpha()"); + + BitmapImage img = BitmapImage::New( 1,1 ); + ImageActor actor = ImageActor::New( img ); + Stage::GetCurrent().Add( actor ); + application.SendNotification(); + application.Render(); + + // use the image alpha on actor + actor.SetBlendMode(BlendingMode::ON); + + // Test that Set was successful + DALI_TEST_EQUALS( BlendingMode::ON, actor.GetBlendMode(), TEST_LOCATION ); + + // Now test that it can be set to false + actor.SetBlendMode(BlendingMode::OFF); + DALI_TEST_EQUALS(BlendingMode::OFF, actor.GetBlendMode(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliRenderableActorCreateDestroy(void) +{ + tet_infoline("Testing Dali::RenderableActor::CreateDestroy()"); + RenderableActor* ractor = new RenderableActor; + RenderableActor ractor2( *ractor ); + DALI_TEST_CHECK( ractor ); + delete ractor; + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-ShaderEffect.cpp b/automated-tests/src/dali/utc-Dali-ShaderEffect.cpp new file mode 100644 index 0000000..c012648 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-ShaderEffect.cpp @@ -0,0 +1,1011 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +using namespace Dali; + +void utc_dali_shader_effect_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_shader_effect_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ + +static const char* VertexSource = +"void main()\n" +"{\n" +" gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\n" +" vTexCoord = aTexCoord;\n" +"}\n"; + +static const char* FragmentSource = +"void main()\n" +"{\n" +" gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n" +"}\n"; + +static const char* FragmentSourceUsingExtensions = +"void main()\n" +"{\n" +" float floatValue = 0.5f;\n" +" float test = fwidth(floatValue);\n" +" gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n" +" gl_FragColor.a *= test;\n" +"}\n"; + +const int GETSOURCE_BUFFER_SIZE = 0x10000; + + +struct TestConstraintToVector3 +{ + TestConstraintToVector3(Vector3 target) + : mTarget(target) + { + } + + Vector3 operator()(const Vector3& current) + { + return mTarget; + } + + Vector3 mTarget; +}; + +struct TestConstraintFromPositionToVector3 +{ + TestConstraintFromPositionToVector3() + { + } + + Vector3 operator()(const Vector3& current, const PropertyInput& position) + { + + return position.GetVector3(); + } +}; + +struct TestConstraintToVector3Double +{ + TestConstraintToVector3Double(Vector3 target) + : mTarget(target) + { + } + + Vector3 operator()(const Vector3& current) + { + return mTarget * 2.0f; + } + + Vector3 mTarget; +}; + +class ShaderEffectExtension : public ShaderEffect::Extension {}; + + +class TestExtension : public ShaderEffect::Extension +{ +public: + TestExtension( bool& deleted ) + : mDeleted(deleted) + { + mDeleted = false; + } + ~TestExtension() + { + mDeleted = true; + } + bool IsAlive() const + { + return !mDeleted; + } +private: + bool& mDeleted; +}; + +} // anon namespace + + +int UtcDaliShaderEffectMethodNew01(void) +{ + TestApplication application; + + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); + DALI_TEST_CHECK(effect); + END_TEST; +} + +int UtcDaliShaderEffectMethodNew02(void) +{ + TestApplication application; + + ShaderEffect effect; + + try + { + // New must be called to create a ShaderEffect or it wont be valid. + effect.SetUniform( "uUniform", 0 ); + DALI_TEST_CHECK( false ); + } + catch (Dali::DaliException& e) + { + // Tests that a negative test of an assertion succeeds + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_CHECK( !effect ); + } + END_TEST; +} + +int UtcDaliShaderEffectMethodNew03(void) +{ + TestApplication application; + + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource, VertexSource, FragmentSource, ShaderEffect::HINT_NONE ); + DALI_TEST_CHECK(effect); + END_TEST; +} + +int UtcDaliShaderEffectMethodNew04(void) +{ + TestApplication application; + tet_infoline("Testing prefixed version of Dali::ShaderEffect::New()"); + + std::string fragmentShaderPrefix = "#define TEST_FS 1\n#extension GL_OES_standard_derivatives : enable"; + std::string vertexShaderPrefix = "#define TEST_VS 1"; + + try + { + // Call render to compile default shaders. + application.SendNotification(); + application.Render(); + application.Render(); + application.Render(); + + GLuint lastShaderCompiledBefore = application.GetGlAbstraction().GetLastShaderCompiled(); + ShaderEffect effect = ShaderEffect::NewWithPrefix( vertexShaderPrefix, VertexSource, + fragmentShaderPrefix, FragmentSourceUsingExtensions, + GEOMETRY_TYPE_IMAGE, ShaderEffect::HINT_NONE ); + + BitmapImage image = CreateBitmapImage(); + ImageActor actor = ImageActor::New( image ); + actor.SetSize( 100.0f, 100.0f ); + actor.SetName("TestImageFilenameActor"); + actor.SetShaderEffect(effect); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(); + GLuint lastShaderCompiledAfter = application.GetGlAbstraction().GetLastShaderCompiled(); + bool testResult = false; + + // we should have compiled 4 shaders. + if (lastShaderCompiledAfter - lastShaderCompiledBefore == 4) + { + char testVertexSourceResult[GETSOURCE_BUFFER_SIZE]; + char testFragmentSourceResult[GETSOURCE_BUFFER_SIZE]; + + // we are interested in the first two. + GLuint vertexShaderId = lastShaderCompiledBefore + 1; + GLuint fragmentShaderId = lastShaderCompiledBefore + 2; + + GLsizei lengthVertexResult; + GLsizei lengthFragmentResult; + + application.GetGlAbstraction().GetShaderSource(vertexShaderId, GETSOURCE_BUFFER_SIZE, &lengthVertexResult, testVertexSourceResult); + application.GetGlAbstraction().GetShaderSource(fragmentShaderId, GETSOURCE_BUFFER_SIZE, &lengthFragmentResult, testFragmentSourceResult); + + int vertexShaderHasPrefix = strncmp(testVertexSourceResult, "#define ", strlen("#define ")); + int fragmentShaderHasPrefix = strncmp(testFragmentSourceResult, "#define ", strlen("#define ")); + testResult = (vertexShaderHasPrefix == 0) && (fragmentShaderHasPrefix == 0); + } + + DALI_TEST_CHECK(testResult); + } + catch(Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + tet_result( TET_FAIL ); + } + END_TEST; +} + +int UtcDaliShaderEffectMethodNew05(void) +{ + TestApplication application; + + // heap constructor / destructor + DefaultFunctionCoverage shaderEffect; + DefaultFunctionCoverage shaderEffectExtension; + + END_TEST; +} + +int UtcDaliShaderEffectMethodNew06(void) +{ + TestApplication application; + tet_infoline("Testing Dali::ShaderEffect::New() with shader sources for different geometry types"); + + ShaderEffect effect = ShaderEffect::New( "imageVertexShader", "imageFragmentShader", + "textVertexShader", "textFragmentShader", + "texturedMeshVertexShader", "texturedMeshFragmentShader", + "meshVertexShader", "meshFragmentShader", + ShaderEffect::HINT_NONE ); + DALI_TEST_CHECK(effect); + END_TEST; +} + + +int UtcDaliShaderEffectMethodDownCast(void) +{ + TestApplication application; + tet_infoline("Testing Dali::ShaderEffect::DownCast()"); + + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); + + BaseHandle object(effect); + + ShaderEffect effect2 = ShaderEffect::DownCast(object); + DALI_TEST_CHECK(effect2); + + ShaderEffect effect3 = DownCast< ShaderEffect >(object); + DALI_TEST_CHECK(effect3); + + BaseHandle unInitializedObject; + ShaderEffect effect4 = ShaderEffect::DownCast(unInitializedObject); + DALI_TEST_CHECK(!effect4); + + ShaderEffect effect5 = DownCast< ShaderEffect >(unInitializedObject); + DALI_TEST_CHECK(!effect5); + END_TEST; +} + +int UtcDaliShaderEffectMethodDelete01(void) +{ + TestApplication application; + + // Only want to test the first few characters + std::string customFontPrefixVertShader = + "\n" + " attribute mediump vec3 aPosition;\n" + " attribute mediump vec2 aTexCoord;\n"; + + + // get the default shaders built, this is not required but makes it + // easier to debug the TET case and isolate the custom shader compilation. + application.SendNotification(); + application.Render(); + + application.SendNotification(); + application.Render(); + + // create a new shader effect + // the vertex and fragment shader will be cached in the ShaderFactory + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource); + + // destroy the shader effect + effect.Reset(); + + // Create the same shader effect again, this should now use the cached version + // held in the shader factory + effect= ShaderEffect::New( VertexSource, FragmentSource ); + + // Compile the shader effect + application.SendNotification(); + application.Render(); + + GLuint lastShaderCompiled = application.GetGlAbstraction().GetLastShaderCompiled(); + + // get the vertex shader (compiled before fragment shader). + // this last shaders compiled is for text. + GLuint vertexShaderId = lastShaderCompiled-1; + GLsizei lengthVertexResult; + + char testVertexSourceResult[GETSOURCE_BUFFER_SIZE]; + application.GetGlAbstraction().GetShaderSource(vertexShaderId, GETSOURCE_BUFFER_SIZE, &lengthVertexResult, testVertexSourceResult); + + // compare the first 40 bytes of the vertex shader sent to be compiled, with + // the shader string that ended up being compiled (in the render task) + // this is to confirm the string hasn't been deleted / corrupted. + int testPassed = strncmp( testVertexSourceResult , customFontPrefixVertShader.c_str(), 40 ) ; + + DALI_TEST_CHECK( testPassed == 0 ); + END_TEST; + +} + +int UtcDaliShaderEffectMethodSetUniformFloat(void) +{ + TestApplication application; + + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); + DALI_TEST_CHECK( effect ); + + BitmapImage image = CreateBitmapImage(); + + effect.SetUniform( "uFloat", 1.0f ); + + ImageActor actor = ImageActor::New( image ); + actor.SetSize( 100.0f, 100.0f ); + actor.SetName("TestImageFilenameActor"); + actor.SetShaderEffect(effect); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( + application.GetGlAbstraction().CheckUniformValue( + "uFloat", 1.0f ) ); + END_TEST; +} + +int UtcDaliShaderEffectMethodSetUniformVector2(void) +{ + TestApplication application; + + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); + DALI_TEST_CHECK( effect ); + + BitmapImage image = CreateBitmapImage(); + + effect.SetUniform( "uVec2", Vector2( 2.0f, 3.0f ) ); + + ImageActor actor = ImageActor::New( image ); + actor.SetSize( 100.0f, 100.0f ); + actor.SetName("TestImageFilenameActor"); + actor.SetShaderEffect(effect); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( + application.GetGlAbstraction().CheckUniformValue( + "uVec2", Vector2( 2.0f, 3.0f ) ) ); + END_TEST; +} + +int UtcDaliShaderEffectMethodSetUniformVector3(void) +{ + TestApplication application; + + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); + DALI_TEST_CHECK( effect ); + + BitmapImage image = CreateBitmapImage(); + + effect.SetUniform( "uVec3", Vector3( 4.0f, 5.0f, 6.0f ) ); + + ImageActor actor = ImageActor::New( image ); + actor.SetSize( 100.0f, 100.0f ); + actor.SetName("TestImageFilenameActor"); + actor.SetShaderEffect(effect); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( + application.GetGlAbstraction().CheckUniformValue( + "uVec3", Vector3( 4.0f, 5.0f, 6.0f ) ) ); + END_TEST; +} + +int UtcDaliShaderEffectMethodSetUniformVector4(void) +{ + TestApplication application; + + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); + DALI_TEST_CHECK( effect ); + + BitmapImage image = CreateBitmapImage(); + + effect.SetUniform( "uVec4", Vector4( 7.0f, 8.0f, 9.0f, 10.0f ) ); + + ImageActor actor = ImageActor::New( image ); + actor.SetSize( 100.0f, 100.0f ); + actor.SetName("TestImageFilenameActor"); + actor.SetShaderEffect(effect); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( + application.GetGlAbstraction().CheckUniformValue( + "uVec4", Vector4( 7.0f, 8.0f, 9.0f, 10.0f ) ) ); + END_TEST; +} + +int UtcDaliShaderEffectMethodSetUniformMatrix(void) +{ + TestApplication application; + + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); + DALI_TEST_CHECK( effect ); + + BitmapImage image = CreateBitmapImage(); + + effect.SetUniform( "uModelView", Matrix::IDENTITY ); + + ImageActor actor = ImageActor::New( image ); + actor.SetSize( 100.0f, 100.0f ); + actor.SetName("TestImageFilenameActor"); + actor.SetShaderEffect(effect); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( + application.GetGlAbstraction().CheckUniformValue( + "uModelView", Matrix::IDENTITY ) ); + END_TEST; +} + +int UtcDaliShaderEffectMethodSetUniformMatrix3(void) +{ + TestApplication application; + + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); + DALI_TEST_CHECK( effect ); + + BitmapImage image = CreateBitmapImage(); + + Matrix3 matIdentity(1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f); + effect.SetUniform( "uMatrix3", matIdentity ); + + ImageActor actor = ImageActor::New( image ); + actor.SetSize( 100.0f, 100.0f ); + actor.SetName("TestImageFilenameActor"); + actor.SetShaderEffect(effect); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( application.GetGlAbstraction().CheckUniformValue("uMatrix3", matIdentity) ); + END_TEST; +} + +int UtcDaliShaderEffectMethodSetUniformViewport(void) +{ + TestApplication application; + + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); + DALI_TEST_CHECK( effect ); + + BitmapImage image = CreateBitmapImage(); + + ImageActor actor = ImageActor::New( image ); + actor.SetSize( 100.0f, 100.0f ); + actor.SetName("TestImageFilenameActor"); + actor.SetShaderEffect(effect); + Stage::GetCurrent().Add(actor); + + effect.SetUniform( "uVec2", Vector2( 0.0f, 0.0f ), ShaderEffect::COORDINATE_TYPE_VIEWPORT_POSITION ); + effect.SetUniform( "uVec2Dir", Vector2( 1.0f, 2.0f ), ShaderEffect::COORDINATE_TYPE_VIEWPORT_DIRECTION ); + + application.SendNotification(); + application.Render(); + + const Vector2& stageSize(Stage::GetCurrent().GetSize()); + + DALI_TEST_CHECK( + application.GetGlAbstraction().CheckUniformValue( + "uVec2", Vector2( stageSize.x/2, -stageSize.y/2 ) ) ); + + DALI_TEST_CHECK( + application.GetGlAbstraction().CheckUniformValue( + "uVec2Dir", Vector2( -1.0f, 2.0f ) ) ); + END_TEST; +} + +int UtcDaliShaderEffectMethodSetEffectImage(void) +{ + TestApplication application; + + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); + DALI_TEST_CHECK( effect ); + + BitmapImage image = CreateBitmapImage(); + + effect.SetEffectImage(image); + + ImageActor actor = ImageActor::New( image ); + actor.SetSize( 100.0f, 100.0f ); + actor.SetName("TestImageFilenameActor"); + actor.SetShaderEffect(effect); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + + DALI_TEST_CHECK( application.GetGlAbstraction().CheckUniformValue( "sEffect", 1 ) ); + END_TEST; +} + +int UtcDaliShaderEffectMethodSetEffectImageAndDelete(void) +{ + TestApplication application; + + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); + + BitmapImage effectImage = CreateBitmapImage(); + effect.SetEffectImage(effectImage); + + ImageActor actor = ImageActor::New(); + + actor.SetShaderEffect(effect); + effect.Reset(); + + Stage::GetCurrent().Add(actor); + + // do an update / render cycle + application.SendNotification(); + application.Render(16); + application.SendNotification(); + application.Render(16); + application.SendNotification(); + application.Render(16); + + printf("removing image actor from stage and Reseting handle\n"); + Stage::GetCurrent().Remove(actor); + actor.Reset(); + + tet_printf("### Update & Render \n"); + + application.SendNotification(); + application.Render(16); + + tet_printf("#### Update Only \n"); + + tet_printf("effectImage.Reset \n"); + + // this releases the effect texture resource, + // Update will send a DispatchDiscardTexture message to render + effectImage.Reset(); + application.SendNotification(); + application.UpdateOnly(16); + + tet_printf("#### Update Only \n"); + + // at this point shader is deleted, during clear discard queue + // and it sends a Shader:: DispatchRemoveObserver message to render thread + application.UpdateOnly(16); + + tet_printf("#### Render Only \n"); + // This is where it used to crash, there is a message in the queue to perform DispatchDiscardTexture + // which tries to call observer->TextureDiscarded, where observer == shader that was deleted + // in previous update. + application.RenderOnly(); + + + // process the discard texture message + application.RenderOnly(); + application.SendNotification(); + application.Render(16); + + tet_result(TET_PASS); + + END_TEST; +} + +int UtcDaliShaderEffectMethodApplyConstraint(void) +{ + // Test whether Shader's uniform can be constrained to a stationary constraint. + TestApplication application; + + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); + DALI_TEST_CHECK( effect ); + + BitmapImage image = CreateBitmapImage(); + + effect.SetUniform( "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) ); + + ImageActor actor = ImageActor::New( image ); + actor.SetSize( 100.0f, 100.0f ); + actor.SetName("TestImageFilenameActor"); + actor.SetShaderEffect(effect); + Stage::GetCurrent().Add(actor); + + Property::Index uVecProperty = effect.GetPropertyIndex("uVec3"); + + application.SendNotification(); + application.Render(); + + // Test effects of SetUniform... + DALI_TEST_CHECK( + application.GetGlAbstraction().CheckUniformValue( + "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) ) ); + + Constraint constraint = Constraint::New( uVecProperty, + TestConstraintToVector3(Vector3(4.0f, 9.0f, 16.0f)) ); + + effect.ApplyConstraint(constraint); + + application.SendNotification(); + application.Render(); + + // Test effects of Constraint. + DALI_TEST_CHECK( + application.GetGlAbstraction().CheckUniformValue( + "uVec3", Vector3( 4.0f, 9.0f, 16.0f ) ) ); + END_TEST; +} + + +int UtcDaliShaderEffectMethodApplyConstraintFromActor(void) +{ + // Test whether Shader's uniform can be constrained to Actor's position. + TestApplication application; + + const Vector3 targetPosition = Vector3( 100.0f, 70.0f, 20.0f); + + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); + DALI_TEST_CHECK( effect ); + + BitmapImage image = CreateBitmapImage(); + + effect.SetUniform( "uVec3", Vector3( 50.0f, 25.0f, 0.0f ) ); + + ImageActor actor = ImageActor::New( image ); + actor.SetPosition(targetPosition); + actor.SetSize( 100.0f, 100.0f ); + actor.SetName("TestImageFilenameActor"); + actor.SetShaderEffect(effect); + Stage::GetCurrent().Add(actor); + + Property::Index uVecProperty = effect.GetPropertyIndex("uVec3"); + + Constraint constraint = Constraint::New( uVecProperty, + Source(actor, Actor::POSITION), + TestConstraintFromPositionToVector3() ); + + effect.ApplyConstraint(constraint); + + application.SendNotification(); + application.Render(); + + // Test effects of Constraint. + DALI_TEST_CHECK( + application.GetGlAbstraction().CheckUniformValue( + "uVec3", targetPosition ) ); + END_TEST; +} + +int UtcDaliShaderEffectMethodApplyConstraintFromActor2(void) +{ + // Test whether Shader's uniform can be constrained to Actor's position. + // While Actor's position is constrained to another point * 2.0f + TestApplication application; + + const Vector3 targetPosition = Vector3( 25.0f, 36.0f, 49.0f ); + + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); + DALI_TEST_CHECK( effect ); + + BitmapImage image = CreateBitmapImage(); + + effect.SetUniform( "uVec3", Vector3( 50.0f, 25.0f, 0.0f ) ); + + ImageActor actor = ImageActor::New( image ); + actor.SetPosition(Vector3( 100.0f, 70.0f, 20.0f)); + actor.SetSize( 100.0f, 100.0f ); + actor.SetName("TestImageFilenameActor"); + actor.SetShaderEffect(effect); + Stage::GetCurrent().Add(actor); + + Property::Index uVecProperty = effect.GetPropertyIndex("uVec3"); + + Constraint shaderConstraint = Constraint::New( uVecProperty, + Source(actor, Actor::POSITION), + TestConstraintFromPositionToVector3() ); + + effect.ApplyConstraint(shaderConstraint); + + Constraint actorConstraint = Constraint::New( Actor::POSITION, + TestConstraintToVector3Double(targetPosition) ); + + actor.ApplyConstraint(actorConstraint); + + application.SendNotification(); + application.Render(); + + // Test effects of Constraint. + DALI_TEST_CHECK( + application.GetGlAbstraction().CheckUniformValue( + "uVec3", targetPosition * 2.0f ) ); + END_TEST; +} + +int UtcDaliShaderEffectMethodApplyConstraintCallback(void) +{ + // Test whether Shader's uniform can be constrained to a stationary constraint. + TestApplication application; + + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); + DALI_TEST_CHECK( effect ); + + BitmapImage image = CreateBitmapImage(); + + effect.SetUniform( "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) ); + + ImageActor actor = ImageActor::New( image ); + actor.SetSize( 100.0f, 100.0f ); + actor.SetName("TestImageFilenameActor"); + actor.SetShaderEffect(effect); + Stage::GetCurrent().Add(actor); + + Property::Index uVecProperty = effect.GetPropertyIndex("uVec3"); + + application.SendNotification(); + application.Render(); + + // Test effects of SetUniform... + DALI_TEST_CHECK( + application.GetGlAbstraction().CheckUniformValue( + "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) ) ); + + Constraint constraint = Constraint::New( uVecProperty, + TestConstraintToVector3(Vector3(4.0f, 9.0f, 16.0f)) ); + + constraint.SetApplyTime( 10.0f ); + + bool constraintCheck( false ); + ConstraintAppliedCheck appliedCheck( constraintCheck ); + + // We should receive the "Applied" signal after 10 seconds + ActiveConstraint active = effect.ApplyConstraint(constraint); + active.AppliedSignal().Connect( &application, appliedCheck ); + + application.SendNotification(); + application.Render(static_cast(1000.0f)); // 1 elapsed second + + // Check signal has not fired + application.SendNotification(); + appliedCheck.CheckSignalNotReceived(); + + application.Render(static_cast(4000.0f)); // 5 elapsed seconds + + // Check signal has not fired + application.SendNotification(); + appliedCheck.CheckSignalNotReceived(); + + application.Render(static_cast(5000.0f - 1.0f)); // <10 elapsed seconds + + // Check signal has not fired + application.SendNotification(); + appliedCheck.CheckSignalNotReceived(); + + application.Render(static_cast(2.0f)); // >10 elapsed seconds + + // Signal should have fired + application.SendNotification(); + appliedCheck.CheckSignalReceived(); + + // Test effects of Constraint. + DALI_TEST_CHECK( + application.GetGlAbstraction().CheckUniformValue( + "uVec3", Vector3( 4.0f, 9.0f, 16.0f ) ) ); + END_TEST; +} + +int UtcDaliShaderEffectMethodRemoveConstraints(void) +{ + // Test if constrains can be removed before they are ever applyed. + TestApplication application; + + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); + DALI_TEST_CHECK( effect ); + + BitmapImage image = CreateBitmapImage(); + + effect.SetUniform( "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) ); + + ImageActor actor = ImageActor::New( image ); + actor.SetSize( 100.0f, 100.0f ); + actor.SetName("TestImageFilenameActor"); + actor.SetShaderEffect(effect); + Stage::GetCurrent().Add(actor); + + Property::Index uVecProperty = effect.GetPropertyIndex("uVec3"); + + application.SendNotification(); + application.Render(); + + // Test effects of SetUniform... + DALI_TEST_CHECK( + application.GetGlAbstraction().CheckUniformValue( + "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) ) ); + + Constraint constraint = Constraint::New( uVecProperty, + TestConstraintToVector3(Vector3(4.0f, 9.0f, 16.0f)) ); + + effect.ApplyConstraint(constraint); + + // Remove the constraints + effect.RemoveConstraints(); + + application.SendNotification(); + application.Render(); + + // Test effects of Constraint. + DALI_TEST_CHECK( + application.GetGlAbstraction().CheckUniformValue( + "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) ) ); + END_TEST; +} + +int UtcDaliShaderEffectMethodRemoveConstraints2(void) +{ + // Test whether Shader's uniform constrains can be removed after they are applyed. + TestApplication application; + + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); + DALI_TEST_CHECK( effect ); + + BitmapImage image = CreateBitmapImage(); + + effect.SetUniform( "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) ); + + ImageActor actor = ImageActor::New( image ); + actor.SetSize( 100.0f, 100.0f ); + actor.SetName("TestImageFilenameActor"); + actor.SetShaderEffect(effect); + Stage::GetCurrent().Add(actor); + + Property::Index uVecProperty = effect.GetPropertyIndex("uVec3"); + + application.SendNotification(); + application.Render(); + + // Test effects of SetUniform... + DALI_TEST_CHECK( + application.GetGlAbstraction().CheckUniformValue( + "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) ) ); + + Constraint constraint = Constraint::New( uVecProperty, + TestConstraintToVector3(Vector3(4.0f, 9.0f, 16.0f)) ); + + effect.ApplyConstraint(constraint); + + application.SendNotification(); + application.Render(); + + // Reset the value and remove the constraints + effect.SetUniform( "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) ); + effect.RemoveConstraints(); + + application.SendNotification(); + application.Render(); + + // Test effects of Constraint. + DALI_TEST_CHECK( + application.GetGlAbstraction().CheckUniformValue( + "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) ) ); + END_TEST; +} + +int UtcDaliShaderEffectMethodCreateExtension(void) +{ + // Test creation of a shader extension + TestApplication aplication; + + bool deleted; + { + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); + DALI_TEST_CHECK( effect ); + + TestExtension* extension = new TestExtension ( deleted ); + + effect.AttachExtension( extension ); + + DALI_TEST_CHECK( static_cast(effect.GetExtension()).IsAlive() ); + } + + DALI_TEST_CHECK( deleted ); + END_TEST; +} + +int UtcDaliShaderEffectMethodCreateExtension2(void) +{ + // Test creation of a shader extension + bool deleted; + { + TestApplication application; + + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); + DALI_TEST_CHECK( effect ); + + BitmapImage image = CreateBitmapImage(); + + effect.SetUniform( "uFloat", 1.0f ); + + ImageActor actor = ImageActor::New( image ); + actor.SetSize( 100.0f, 100.0f ); + actor.SetName("TestImageFilenameActor"); + actor.SetShaderEffect(effect); + Stage::GetCurrent().Add(actor); + + application.SendNotification(); + application.Render(); + + TestExtension* extension = new TestExtension ( deleted ); + + effect.AttachExtension( extension ); + + const ShaderEffect& constEffect(effect); + const TestExtension& ext( static_cast(constEffect.GetExtension()) ); + + DALI_TEST_CHECK( ext.IsAlive() ); + } + + DALI_TEST_CHECK( deleted ); + END_TEST; +} + +int UtcDaliShaderEffectMethodNoExtension(void) +{ + TestApplication application; + + ShaderEffect effect; + + try + { + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); + DALI_TEST_CHECK( effect ); + + // Don't attach extension + ShaderEffect::Extension& extension = effect.GetExtension(); + (void) extension; + + DALI_TEST_CHECK( false ); + } + catch (Dali::DaliException& e) + { + // Tests that a negative test of an assertion succeeds + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_CHECK( !effect ); + } + END_TEST; +} + + +int UtcDaliShaderEffectPropertyIndices(void) +{ + TestApplication application; + ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); + + Property::IndexContainer indices; + effect.GetPropertyIndices( indices ); + DALI_TEST_CHECK( ! indices.empty() ); + DALI_TEST_EQUALS( indices.size(), effect.GetPropertyCount(), TEST_LOCATION ); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-SignalTemplatesFunctors.cpp b/automated-tests/src/dali/utc-Dali-SignalTemplatesFunctors.cpp new file mode 100644 index 0000000..4c98209 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-SignalTemplatesFunctors.cpp @@ -0,0 +1,512 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +// EXTERNAL INCLUDES +#include +#include + +// INTERNAL INCLUDES +#include +#include + +using namespace Dali; + +void utc_dali_signal_templates_functors_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_signal_templates_functors_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ + +class TestSignals +{ +public: + + typedef SignalV2 VoidSignalVoid; + typedef SignalV2 VoidSignalFloat; + + typedef SignalV2 FloatSignalVoid; + typedef SignalV2 FloatSignalFloat; + + TestSignals() + { + } + + void CheckNoConnections() + { + DALI_TEST_EQUALS( mVoidSignalVoid.GetConnectionCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( mVoidSignalFloat.GetConnectionCount(), 0u, TEST_LOCATION ); + + DALI_TEST_EQUALS( mFloatSignalVoid.GetConnectionCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( mFloatSignalFloat.GetConnectionCount(), 0u, TEST_LOCATION ); + } + + VoidSignalVoid mVoidSignalVoid; + VoidSignalFloat mVoidSignalFloat; + + FloatSignalVoid mFloatSignalVoid; + FloatSignalFloat mFloatSignalFloat; +}; + +class TestConnectionTracker : public ConnectionTracker +{ +public: + + TestConnectionTracker() + { + } +}; + +struct VoidFunctorVoid +{ + VoidFunctorVoid() + { + ++mTotalInstanceCount; + ++mCurrentInstanceCount; + } + + VoidFunctorVoid( const VoidFunctorVoid& copyMe ) + { + ++mTotalInstanceCount; + ++mCurrentInstanceCount; + } + + ~VoidFunctorVoid() + { + --mCurrentInstanceCount; + } + + void operator()() + { + ++mCallbackCount; + } + + static int mTotalInstanceCount; + static int mCurrentInstanceCount; + static int mCallbackCount; +}; + +struct VoidFunctorFloat +{ + VoidFunctorFloat( float* lastReceivedValue ) + : mLastReceivedValue( lastReceivedValue ) + { + ++mTotalInstanceCount; + ++mCurrentInstanceCount; + } + + VoidFunctorFloat( const VoidFunctorFloat& copyMe ) + : mLastReceivedValue( copyMe.mLastReceivedValue ) + { + ++mTotalInstanceCount; + ++mCurrentInstanceCount; + } + + ~VoidFunctorFloat() + { + --mCurrentInstanceCount; + } + + void operator()(float value) + { + ++mCallbackCount; + + if( mLastReceivedValue ) + { + *mLastReceivedValue = value; + } + } + + float* mLastReceivedValue; + + static int mTotalInstanceCount; + static int mCurrentInstanceCount; + static int mCallbackCount; +}; + +struct FloatFunctorVoid +{ + static float DEFAULT_RETURN_VALUE; + + FloatFunctorVoid() + { + ++mTotalInstanceCount; + ++mCurrentInstanceCount; + } + + FloatFunctorVoid( const FloatFunctorVoid& copyMe ) + { + ++mTotalInstanceCount; + ++mCurrentInstanceCount; + } + + ~FloatFunctorVoid() + { + --mCurrentInstanceCount; + } + + float operator()() + { + ++mCallbackCount; + + return DEFAULT_RETURN_VALUE; + } + + static int mTotalInstanceCount; + static int mCurrentInstanceCount; + static int mCallbackCount; +}; + +float FloatFunctorVoid::DEFAULT_RETURN_VALUE = 5.0f; + +struct FloatFunctorFloat +{ + FloatFunctorFloat() + : mLastReceivedValue() + { + ++mTotalInstanceCount; + ++mCurrentInstanceCount; + } + + FloatFunctorFloat( const FloatFunctorFloat& copyMe ) + { + ++mTotalInstanceCount; + ++mCurrentInstanceCount; + } + + ~FloatFunctorFloat() + { + --mCurrentInstanceCount; + } + + float operator()(float value) + { + ++mCallbackCount; + + return value + 1.0f; + } + + float* mLastReceivedValue; + + static int mTotalInstanceCount; + static int mCurrentInstanceCount; + static int mCallbackCount; +}; + +static void ResetFunctorCounts() +{ + VoidFunctorVoid::mTotalInstanceCount = 0; + VoidFunctorVoid::mCurrentInstanceCount = 0; + VoidFunctorVoid::mCallbackCount = 0; + + VoidFunctorFloat::mTotalInstanceCount = 0; + VoidFunctorFloat::mCurrentInstanceCount = 0; + VoidFunctorFloat::mCallbackCount = 0; + + FloatFunctorVoid::mTotalInstanceCount = 0; + FloatFunctorVoid::mCurrentInstanceCount = 0; + FloatFunctorVoid::mCallbackCount = 0; + + FloatFunctorFloat::mTotalInstanceCount = 0; + FloatFunctorFloat::mCurrentInstanceCount = 0; + FloatFunctorFloat::mCallbackCount = 0; +} + +int VoidFunctorVoid::mTotalInstanceCount = 0; +int VoidFunctorVoid::mCurrentInstanceCount = 0; +int VoidFunctorVoid::mCallbackCount = 0; + +int VoidFunctorFloat::mTotalInstanceCount = 0; +int VoidFunctorFloat::mCurrentInstanceCount = 0; +int VoidFunctorFloat::mCallbackCount = 0; + +int FloatFunctorVoid::mTotalInstanceCount = 0; +int FloatFunctorVoid::mCurrentInstanceCount = 0; +int FloatFunctorVoid::mCallbackCount = 0; + +int FloatFunctorFloat::mTotalInstanceCount = 0; +int FloatFunctorFloat::mCurrentInstanceCount = 0; +int FloatFunctorFloat::mCallbackCount = 0; + +} // anon namespace + + +int UtcDaliSignalFunctorsEmptyCheck(void) +{ + // Test that Empty() check works before & after signal connection + + ResetFunctorCounts(); + + { + TestSignals::VoidSignalVoid signal; + DALI_TEST_CHECK( signal.Empty() ); + DALI_TEST_EQUALS( VoidFunctorVoid::mTotalInstanceCount, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorVoid::mCurrentInstanceCount, 0, TEST_LOCATION ); + TestConnectionTracker tracker; + signal.Connect( &tracker, VoidFunctorVoid() ); + DALI_TEST_CHECK( ! signal.Empty() ); + DALI_TEST_EQUALS( VoidFunctorVoid::mTotalInstanceCount, 2/*temporary copy + signal copy*/, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorVoid::mCurrentInstanceCount, 1, TEST_LOCATION ); + } + // TestConnectionTracker should auto-disconnect + DALI_TEST_EQUALS( VoidFunctorVoid::mTotalInstanceCount, 2/*temporary copy + signal copy*/, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorVoid::mCurrentInstanceCount, 0, TEST_LOCATION ); + + { + TestSignals::VoidSignalFloat signal; + DALI_TEST_CHECK( signal.Empty() ); + DALI_TEST_EQUALS( VoidFunctorFloat::mTotalInstanceCount, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorFloat::mCurrentInstanceCount, 0, TEST_LOCATION ); + TestConnectionTracker tracker; + signal.Connect( &tracker, VoidFunctorFloat(NULL) ); + DALI_TEST_CHECK( ! signal.Empty() ); + DALI_TEST_EQUALS( VoidFunctorFloat::mTotalInstanceCount, 2/*temporary copy + signal copy*/, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorFloat::mCurrentInstanceCount, 1, TEST_LOCATION ); + } + // TestConnectionTracker should auto-disconnect + DALI_TEST_EQUALS( VoidFunctorFloat::mTotalInstanceCount, 2/*temporary copy + signal copy*/, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorFloat::mCurrentInstanceCount, 0, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliSignalFunctorsEmit(void) +{ + // Test basic signal emission for each functor type + + ResetFunctorCounts(); + + TestSignals signals; + + { + TestConnectionTracker tracker; + + DALI_TEST_EQUALS( VoidFunctorVoid::mTotalInstanceCount, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorVoid::mCurrentInstanceCount, 0, TEST_LOCATION ); + + signals.mVoidSignalVoid.Connect( &tracker, VoidFunctorVoid() ); + DALI_TEST_EQUALS( VoidFunctorVoid::mTotalInstanceCount, 2/*temporary copy + signal copy*/, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorVoid::mCurrentInstanceCount, 1, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorVoid::mCallbackCount, 0, TEST_LOCATION ); + + signals.mVoidSignalVoid.Emit(); + DALI_TEST_EQUALS( VoidFunctorVoid::mCallbackCount, 1, TEST_LOCATION ); + + // Test double emission + signals.mVoidSignalVoid.Emit(); + DALI_TEST_EQUALS( VoidFunctorVoid::mCallbackCount, 2, TEST_LOCATION ); + } + // TestConnectionTracker should auto-disconnect + DALI_TEST_EQUALS( VoidFunctorVoid::mTotalInstanceCount, 2/*temporary copy + signal copy*/, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorVoid::mCurrentInstanceCount, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorVoid::mCallbackCount, 2, TEST_LOCATION ); + signals.CheckNoConnections(); + + { + TestConnectionTracker tracker; + float lastReceivedValue( 0.0f ); + + DALI_TEST_EQUALS( VoidFunctorFloat::mTotalInstanceCount, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorFloat::mCurrentInstanceCount, 0, TEST_LOCATION ); + + signals.mVoidSignalFloat.Connect( &tracker, VoidFunctorFloat(&lastReceivedValue) ); + DALI_TEST_EQUALS( VoidFunctorFloat::mTotalInstanceCount, 2/*temporary copy + signal copy*/, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorFloat::mCurrentInstanceCount, 1, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorFloat::mCallbackCount, 0, TEST_LOCATION ); + + signals.mVoidSignalFloat.Emit( 3.5f ); + DALI_TEST_EQUALS( VoidFunctorFloat::mCallbackCount, 1, TEST_LOCATION ); + DALI_TEST_EQUALS( lastReceivedValue, 3.5f, TEST_LOCATION ); + + // Test double emission + signals.mVoidSignalFloat.Emit( 7.0f ); + DALI_TEST_EQUALS( VoidFunctorFloat::mCallbackCount, 2, TEST_LOCATION ); + DALI_TEST_EQUALS( lastReceivedValue, 7.0f, TEST_LOCATION ); + } + // TestConnectionTracker should auto-disconnect + DALI_TEST_EQUALS( VoidFunctorFloat::mTotalInstanceCount, 2/*temporary copy + signal copy*/, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorFloat::mCurrentInstanceCount, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorFloat::mCallbackCount, 2, TEST_LOCATION ); + signals.CheckNoConnections(); + END_TEST; +} + +int UtcDaliSignalFunctorsEmitReturn(void) +{ + // Test signals with return values + + ResetFunctorCounts(); + + TestSignals signals; + + { + TestConnectionTracker tracker; + + DALI_TEST_EQUALS( FloatFunctorVoid::mTotalInstanceCount, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( FloatFunctorVoid::mCurrentInstanceCount, 0, TEST_LOCATION ); + + signals.mFloatSignalVoid.Connect( &tracker, FloatFunctorVoid() ); + DALI_TEST_EQUALS( FloatFunctorVoid::mTotalInstanceCount, 2/*temporary copy + signal copy*/, TEST_LOCATION ); + DALI_TEST_EQUALS( FloatFunctorVoid::mCurrentInstanceCount, 1, TEST_LOCATION ); + DALI_TEST_EQUALS( FloatFunctorVoid::mCallbackCount, 0, TEST_LOCATION ); + + float returnValue = signals.mFloatSignalVoid.Emit(); + DALI_TEST_EQUALS( FloatFunctorVoid::mCallbackCount, 1, TEST_LOCATION ); + DALI_TEST_EQUALS( returnValue, FloatFunctorVoid::DEFAULT_RETURN_VALUE, TEST_LOCATION ); + + // Test double emission + returnValue = 0.0f; + returnValue = signals.mFloatSignalVoid.Emit(); + DALI_TEST_EQUALS( FloatFunctorVoid::mCallbackCount, 2, TEST_LOCATION ); + DALI_TEST_EQUALS( returnValue, FloatFunctorVoid::DEFAULT_RETURN_VALUE, TEST_LOCATION ); + } + // TestConnectionTracker should auto-disconnect + DALI_TEST_EQUALS( FloatFunctorVoid::mTotalInstanceCount, 2/*temporary copy + signal copy*/, TEST_LOCATION ); + DALI_TEST_EQUALS( FloatFunctorVoid::mCurrentInstanceCount, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( FloatFunctorVoid::mCallbackCount, 2, TEST_LOCATION ); + signals.CheckNoConnections(); + + { + TestConnectionTracker tracker; + + DALI_TEST_EQUALS( FloatFunctorFloat::mTotalInstanceCount, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( FloatFunctorFloat::mCurrentInstanceCount, 0, TEST_LOCATION ); + + signals.mFloatSignalFloat.Connect( &tracker, FloatFunctorFloat() ); + DALI_TEST_EQUALS( FloatFunctorFloat::mTotalInstanceCount, 2/*temporary copy + signal copy*/, TEST_LOCATION ); + DALI_TEST_EQUALS( FloatFunctorFloat::mCurrentInstanceCount, 1, TEST_LOCATION ); + DALI_TEST_EQUALS( FloatFunctorFloat::mCallbackCount, 0, TEST_LOCATION ); + + float returnValue = signals.mFloatSignalFloat.Emit( 0.1f ); + DALI_TEST_EQUALS( FloatFunctorFloat::mCallbackCount, 1, TEST_LOCATION ); + DALI_TEST_EQUALS( returnValue, 1.0f + 0.1f, TEST_LOCATION ); + + // Test double emission + returnValue = signals.mFloatSignalFloat.Emit( 0.2f ); + DALI_TEST_EQUALS( FloatFunctorFloat::mCallbackCount, 2, TEST_LOCATION ); + DALI_TEST_EQUALS( returnValue, 1.0f + 0.2f, TEST_LOCATION ); + } + // TestConnectionTracker should auto-disconnect + DALI_TEST_EQUALS( FloatFunctorFloat::mTotalInstanceCount, 2/*temporary copy + signal copy*/, TEST_LOCATION ); + DALI_TEST_EQUALS( FloatFunctorFloat::mCurrentInstanceCount, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( FloatFunctorFloat::mCallbackCount, 2, TEST_LOCATION ); + signals.CheckNoConnections(); + END_TEST; +} + +int UtcDaliSignalFunctorsDisconnectBeforeEmit(void) +{ + // Test explicit disconnect using ConnectionTracker + + ResetFunctorCounts(); + + TestSignals signals; + + { + TestConnectionTracker tracker; + + DALI_TEST_EQUALS( VoidFunctorVoid::mTotalInstanceCount, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorVoid::mCurrentInstanceCount, 0, TEST_LOCATION ); + + signals.mVoidSignalVoid.Connect( &tracker, VoidFunctorVoid() ); + DALI_TEST_EQUALS( VoidFunctorVoid::mTotalInstanceCount, 2/*temporary copy + signal copy*/, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorVoid::mCurrentInstanceCount, 1, TEST_LOCATION ); + + tracker.DisconnectAll(); + DALI_TEST_EQUALS( VoidFunctorVoid::mTotalInstanceCount, 2/*temporary copy + signal copy*/, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorVoid::mCurrentInstanceCount, 0, TEST_LOCATION ); + + signals.mVoidSignalVoid.Emit(); + DALI_TEST_EQUALS( VoidFunctorVoid::mCallbackCount, 0, TEST_LOCATION ); + + // Test double emission + signals.mVoidSignalVoid.Emit(); + DALI_TEST_EQUALS( VoidFunctorVoid::mCallbackCount, 0, TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliSignalFunctorsDestroySignal(void) +{ + // Test destruction of signal before slot + + ResetFunctorCounts(); + + TestConnectionTracker tracker; + + { + TestSignals signals; + + DALI_TEST_EQUALS( VoidFunctorVoid::mTotalInstanceCount, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorVoid::mCurrentInstanceCount, 0, TEST_LOCATION ); + + signals.mVoidSignalVoid.Connect( &tracker, VoidFunctorVoid() ); + DALI_TEST_EQUALS( VoidFunctorVoid::mTotalInstanceCount, 2/*temporary copy + signal copy*/, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorVoid::mCurrentInstanceCount, 1, TEST_LOCATION ); + + signals.mVoidSignalVoid.Emit(); + DALI_TEST_EQUALS( VoidFunctorVoid::mCallbackCount,1, TEST_LOCATION ); + + DALI_TEST_EQUALS( tracker.GetConnectionCount(), 1u, TEST_LOCATION ); + } + + // Functor should have been deleted with signal + DALI_TEST_EQUALS( VoidFunctorVoid::mTotalInstanceCount, 2/*temporary copy + signal copy*/, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorVoid::mCurrentInstanceCount, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorVoid::mCallbackCount, 1, TEST_LOCATION ); + + DALI_TEST_EQUALS( tracker.GetConnectionCount(), 0u, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliSignalConnectVoidFunctor(void) +{ + // Test connecting a functor using the VoidFunctor wrapper + + ResetFunctorCounts(); + + TestSignals signals; + + { + TestConnectionTracker tracker; + + DALI_TEST_EQUALS( VoidFunctorVoid::mTotalInstanceCount, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorVoid::mCurrentInstanceCount, 0, TEST_LOCATION ); + + signals.mVoidSignalVoid.Connect( &tracker, FunctorDelegate::New( VoidFunctorVoid() ) ); + DALI_TEST_EQUALS( VoidFunctorVoid::mTotalInstanceCount, 2/*temporary copy + signal copy*/, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorVoid::mCurrentInstanceCount, 1, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorVoid::mCallbackCount, 0, TEST_LOCATION ); + + signals.mVoidSignalVoid.Emit(); + DALI_TEST_EQUALS( VoidFunctorVoid::mCallbackCount, 1, TEST_LOCATION ); + + // Test double emission + signals.mVoidSignalVoid.Emit(); + DALI_TEST_EQUALS( VoidFunctorVoid::mCallbackCount, 2, TEST_LOCATION ); + } + // TestConnectionTracker should auto-disconnect + DALI_TEST_EQUALS( VoidFunctorVoid::mTotalInstanceCount, 2/*temporary copy + signal copy*/, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorVoid::mCurrentInstanceCount, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( VoidFunctorVoid::mCallbackCount, 2, TEST_LOCATION ); + signals.CheckNoConnections(); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-SignalTemplatesV2.cpp b/automated-tests/src/dali/utc-Dali-SignalTemplatesV2.cpp new file mode 100644 index 0000000..5dd2207 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-SignalTemplatesV2.cpp @@ -0,0 +1,2618 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +// EXTERNAL INCLUDES +#include +#include + +// INTERNAL INCLUDES +#include +#include + +using namespace Dali; + +void utc_dali_signal_templates_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_signal_templates_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace { + +class TestButton +{ +public: + + TestButton( unsigned int id ) + : mId(id) + { + } + + void Press() + { + mPanelDown.Emit( *this ); + } + + void Release() + { + mPanelUp.Emit( *this ); + } + + typedef SignalV2< void (TestButton&) > PanelDownSignal; + typedef SignalV2< void (TestButton&) > PanelUpSignal; + + PanelDownSignal& DownSignal() + { + return mPanelDown; + } + + PanelUpSignal& SignalUp() + { + return mPanelUp; + } + + int GetId() + { + return mId; + } + +private: + + int mId; + PanelDownSignal mPanelDown; + PanelUpSignal mPanelUp; +}; + +class TestApp : public ConnectionTracker +{ +public: + + TestApp() + : mButtonPressed( false ), + mVoidFunctionCalled( false ) + { + } + + void OnButtonPress( TestButton& button ) + { + mButtonPressed = true; + mButtonId = button.GetId(); + } + + void OnButtonRelease( TestButton& button ) + { + mButtonPressed = false; + mButtonId = button.GetId(); + } + + int GetButtonPressedId() + { + return mButtonId; + } + + bool BoolReturnTestFalse() + { + return false; + } + + bool BoolReturnTestTrue() + { + return true; + } + + void VoidFunction() + { + mVoidFunctionCalled = true; + } + + bool mButtonPressed; + bool mVoidFunctionCalled; + int mButtonId; +}; + +class TestSignals +{ +public: + + // Void return, no parameters + typedef SignalV2 VoidRetNoParamSignal; + + // Void return, 1 value parameter + typedef SignalV2 VoidRet1ValueParamSignal; + + // Void return, 1 reference parameter + typedef SignalV2< void (int&)> VoidRet1RefParamSignal; + + // Void return, 2 value parameters + typedef SignalV2 VoidRet2ValueParamSignal; + + // bool return, 1 value parameter + typedef SignalV2< bool (float)> BoolRet1ValueParamSignal; + + // bool return, 2 value parameter + typedef SignalV2 BoolRet2ValueParamSignal; + + // int return, 2 value parameter + typedef SignalV2 IntRet2ValueParamSignal; + + // float return, 0 parameters + typedef SignalV2< float () > FloatRet0ParamSignal; + + // float return, 2 value parameters + typedef SignalV2 FloatRet2ValueParamSignal; + + // void return, 3 value parameters + typedef SignalV2 VoidSignalTypeFloatValue3; + + // float return, 3 value parameters + typedef SignalV2 FloatSignalTypeFloatValue3; + + VoidRetNoParamSignal& SignalVoidNone() { return mSignalVoid0; } + VoidRet1RefParamSignal& SignalVoid1Ref() { return mSignalVoid1R; } + VoidRet1ValueParamSignal& SignalVoid1Value() { return mSignalVoid1V; } + VoidRet2ValueParamSignal& SignalVoid2Value() { return mSignalVoid2V; } + + BoolRet1ValueParamSignal& SignalBool1Value() { return mSignalBool1V; } + BoolRet2ValueParamSignal& SignalBool2Value() { return mSignalBool2V; } + IntRet2ValueParamSignal& SignalInt2Value() { return mSignalInt2V; } + FloatRet0ParamSignal& SignalFloat0() { return mSignalFloat0; } + FloatRet2ValueParamSignal& SignalFloat2Value() { return mSignalFloat2V; } + + VoidSignalTypeFloatValue3& VoidSignalFloatValue3() { return mVoidSignalFloatValue3; } + FloatSignalTypeFloatValue3& FloatSignalFloatValue3() { return mFloatSignalFloatValue3; } + + TestSignals() + { + } + + void CheckNoConnections() + { + DALI_TEST_EQUALS( mSignalVoid0.GetConnectionCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( mSignalVoid1R.GetConnectionCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( mSignalVoid1V.GetConnectionCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( mSignalVoid2V.GetConnectionCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( mSignalBool1V.GetConnectionCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( mSignalBool2V.GetConnectionCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( mSignalInt2V.GetConnectionCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( mSignalFloat0.GetConnectionCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( mSignalFloat2V.GetConnectionCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( mVoidSignalFloatValue3.GetConnectionCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( mFloatSignalFloatValue3.GetConnectionCount(), 0u, TEST_LOCATION ); + } + + void EmitVoidSignalVoid() + { + mSignalVoid0.Emit(); + } + + void EmitVoidSignalIntRef(int& ref) + { + mSignalVoid1R.Emit(ref); + } + + void EmitVoidSignalIntValue(int p1) + { + mSignalVoid1V.Emit(p1); + } + + void EmitVoidSignalIntValueIntValue(int p1, int p2) + { + mSignalVoid2V.Emit(p1,p2); + } + + bool EmitBoolSignalFloatValue(float p1) + { + return mSignalBool1V.Emit(p1); + } + + bool EmitBoolSignalFloatValueIntValue(float p1, int p2) + { + return mSignalBool2V.Emit(p1, p2); + } + + int EmitIntSignalFloatValueIntValue(float p1, int p2) + { + return mSignalInt2V.Emit(p1, p2); + } + + float EmitFloat2VSignal(float p1, float p2) + { + return mSignalFloat2V.Emit(p1, p2); + } + + float EmitFloat0Signal() + { + return mSignalFloat0.Emit(); + } + + void EmitVoidSignalFloatValue3(float p1, float p2, float p3) + { + mVoidSignalFloatValue3.Emit(p1, p2, p3); + } + + float EmitFloatSignalFloatValue3(float p1, float p2, float p3) + { + return mFloatSignalFloatValue3.Emit(p1, p2, p3); + } + +private: + + VoidRetNoParamSignal mSignalVoid0; + VoidRet1RefParamSignal mSignalVoid1R; + VoidRet1ValueParamSignal mSignalVoid1V; + VoidRet2ValueParamSignal mSignalVoid2V; + BoolRet1ValueParamSignal mSignalBool1V; + BoolRet2ValueParamSignal mSignalBool2V; + IntRet2ValueParamSignal mSignalInt2V; + FloatRet0ParamSignal mSignalFloat0; + FloatRet2ValueParamSignal mSignalFloat2V; + VoidSignalTypeFloatValue3 mVoidSignalFloatValue3; + FloatSignalTypeFloatValue3 mFloatSignalFloatValue3; +}; + +/** + * A helper class with various slots + */ +class TestSlotHandler : public ConnectionTracker +{ +public: + + TestSlotHandler() + : mIntParam1( 0 ), + mIntParam2( 0 ), + mIntParam3( 0 ), + mFloatParam1( 0.0f ), + mFloatParam2( 0.0f ), + mFloatParam3( 0.0f ), + mBoolReturn( false ), + mIntReturn( 0 ), + mFloatReturn( 0.0f ), + mHandled( false ), + mHandledCount( 0 ) + { + } + + void Reset() + { + mIntParam1 = 0; + mIntParam2 = 0; + mIntParam3 = 0; + mFloatParam1 = 0.0f; + mFloatParam2 = 0.0f; + mFloatParam3 = 0.0f; + mBoolReturn = false; + mIntReturn = 0; + mFloatReturn = 0.0f; + mHandled = false; + } + + void VoidSlotVoid() + { + mHandled = true; + ++mHandledCount; + } + + void VoidSlotIntRef( int& p1 ) + { + mIntParam1 = p1; + mHandled = true; + ++mHandledCount; + } + + void VoidSlotIntValue( int p1 ) + { + mIntParam1 = p1; + mHandled = true; + ++mHandledCount; + } + + void VoidDuplicateSlotIntValue( int p1 ) + { + mIntParam2 = p1; + mHandled = true; + ++mHandledCount; + } + + void VoidSlotIntValueIntValue( int p1, int p2 ) + { + mIntParam1 = p1; + mIntParam2 = p2; + mHandled = true; + ++mHandledCount; + } + + bool BoolSlotFloatValue( float p1 ) + { + mFloatParam1 = p1; + mHandled = true; + ++mHandledCount; + return mBoolReturn; + } + + bool BoolSlotFloatValueIntValue( float p1, int p2 ) + { + mFloatParam1 = p1; + mIntParam2 = p2; + mHandled = true; + ++mHandledCount; + return mBoolReturn; + } + + int IntSlotFloatValueIntValue( float p1, int p2 ) + { + mFloatParam1 = p1; + mIntParam2 = p2; + mHandled = true; + ++mHandledCount; + return mIntReturn; + } + + float FloatSlotVoid() + { + mHandled = true; + ++mHandledCount; + return mFloatReturn; + } + + float FloatSlotFloatValueFloatValue( float p1, float p2 ) + { + mFloatParam1 = p1; + mFloatParam2 = p2; + mHandled = true; + ++mHandledCount; + return mFloatReturn; + } + + void VoidSlotFloatValue3( float p1, float p2, float p3 ) + { + mFloatParam1 = p1; + mFloatParam2 = p2; + mFloatParam3 = p3; + mHandled = true; + ++mHandledCount; + } + + float FloatSlotFloatValue3( float p1, float p2, float p3 ) + { + mFloatParam1 = p1; + mFloatParam2 = p2; + mFloatParam3 = p3; + mHandled = true; + ++mHandledCount; + return mFloatReturn; + } + + int mIntParam1, mIntParam2, mIntParam3; + float mFloatParam1, mFloatParam2, mFloatParam3; + bool mBoolReturn; + int mIntReturn; + float mFloatReturn; + bool mHandled; + int mHandledCount; +}; + +/** + * A version of TestSlotHandler which disconnects during the callback + */ +class TestSlotDisconnector : public ConnectionTracker +{ +public: + + TestSlotDisconnector() + : mIntParam1( 0 ), + mIntParam2( 0 ), + mIntParam3( 0 ), + mFloatParam1( 0.0f ), + mFloatParam2( 0.0f ), + mBoolReturn( false ), + mIntReturn( 0 ), + mFloatReturn( 0.0f ), + mHandled( false ) + { + } + + void Reset() + { + mIntParam1 = 0; + mIntParam2 = 0; + mIntParam3 = 0; + mFloatParam1 = 0.0f; + mFloatParam2 = 0.0f; + mBoolReturn = false; + mIntReturn = 0; + mFloatReturn = 0.0f; + mHandled = false; + } + + void VoidConnectVoid( TestSignals::VoidRetNoParamSignal& signal ) + { + mVoidSignalVoid = &signal; + signal.Connect( this, &TestSlotDisconnector::VoidSlotVoid ); + } + + void VoidSlotVoid() + { + mVoidSignalVoid->Disconnect( this, &TestSlotDisconnector::VoidSlotVoid ); + mHandled = true; + } + + void VoidConnectIntRef( TestSignals::VoidRet1RefParamSignal& signal ) + { + mVoidSignalIntRef = &signal; + signal.Connect( this, &TestSlotDisconnector::VoidSlotIntRef ); + } + + void VoidSlotIntRef( int& p1 ) + { + mVoidSignalIntRef->Disconnect( this, &TestSlotDisconnector::VoidSlotIntRef ); + mIntParam1 = p1; + mHandled = true; + } + + void VoidSlotIntValue( int p1 ) + { + mIntParam1 = p1; + mHandled = true; + } + + void VoidSlotIntValueIntValue( int p1, int p2 ) + { + mIntParam1 = p1; + mIntParam2 = p2; + mHandled = true; + } + + bool BoolSlotFloatValue( float p1 ) + { + mFloatParam1 = p1; + mHandled = true; + return mBoolReturn; + } + + bool BoolSlotFloatValueIntValue( float p1, int p2 ) + { + mFloatParam1 = p1; + mIntParam2 = p2; + mHandled = true; + return mBoolReturn; + } + + int IntSlotFloatValueIntValue( float p1, int p2 ) + { + mFloatParam1 = p1; + mIntParam2 = p2; + mHandled = true; + return mIntReturn; + } + + float FloatSlotVoid() + { + mHandled = true; + return mFloatReturn; + } + + float FloatSlotFloatValueFloatValue( float p1, float p2 ) + { + mFloatParam1 = p1; + mFloatParam2 = p2; + mHandled = true; + return mFloatReturn; + } + + TestSignals::VoidRetNoParamSignal* mVoidSignalVoid; + TestSignals::VoidRet1RefParamSignal* mVoidSignalIntRef; + + int mIntParam1, mIntParam2, mIntParam3; + float mFloatParam1, mFloatParam2; + bool mBoolReturn; + int mIntReturn; + float mFloatReturn; + bool mHandled; +}; + +/** + * A more complicated version of TestSlotDisconnector, which disconnects some but not all callbacks + */ +class TestSlotMultiDisconnector : public ConnectionTracker +{ +public: + + static const int NUM_SLOTS = 10; + + TestSlotMultiDisconnector() + : mVoidSignalVoid( NULL ) + { + Reset(); + } + + void Reset() + { + for( int i=0; iDisconnect( this, &TestSlotMultiDisconnector::Slot1 ); + mVoidSignalVoid->Disconnect( this, &TestSlotMultiDisconnector::Slot3 ); + mVoidSignalVoid->Disconnect( this, &TestSlotMultiDisconnector::Slot5 ); + mVoidSignalVoid->Disconnect( this, &TestSlotMultiDisconnector::Slot7 ); + mVoidSignalVoid->Disconnect( this, &TestSlotMultiDisconnector::Slot9 ); + } + + void Slot4() + { + mSlotHandled[4] = true; + } + + void Slot5() + { + mSlotHandled[5] = true; + } + + void Slot6() + { + mSlotHandled[6] = true; + } + + void Slot7() + { + mSlotHandled[7] = true; + } + + void Slot8() + { + mSlotHandled[8] = true; + } + + void Slot9() + { + mSlotHandled[9] = true; + } + + TestSignals::VoidRetNoParamSignal* mVoidSignalVoid; + + bool mSlotHandled[NUM_SLOTS]; +}; + + +/** + * A version of TestSlotHandler which disconnects during the callback + */ +class TestEmitDuringCallback : public ConnectionTracker +{ +public: + + TestEmitDuringCallback() + : mVoidSignalVoid( NULL ), + mHandled( false ) + { + } + + void VoidConnectVoid( TestSignals::VoidRetNoParamSignal& signal ) + { + mVoidSignalVoid = &signal; + signal.Connect( this, &TestEmitDuringCallback::VoidSlotVoid ); + } + + void VoidSlotVoid() + { + // Emitting during Emit is very bad! + mVoidSignalVoid->Emit(); + + mHandled = true; + } + + TestSignals::VoidRetNoParamSignal* mVoidSignalVoid; + + bool mHandled; +}; + + +/** + * A version of TestSlotHandler which uses SlotDelegate + */ +class TestSlotDelegateHandler // This does not inherit from ConnectionTrackerInterface! +{ +public: + + TestSlotDelegateHandler() + : mSlotDelegate( this ), + mIntParam1( 0 ), + mIntParam2( 0 ), + mIntParam3( 0 ), + mFloatParam1( 0.0f ), + mFloatParam2( 0.0f ), + mFloatParam3( 0.0f ), + mBoolReturn( false ), + mIntReturn( 0 ), + mFloatReturn( 0.0f ), + mHandled( false ), + mHandledCount( 0 ) + { + } + + void Reset() + { + mIntParam1 = 0; + mIntParam2 = 0; + mIntParam3 = 0; + mFloatParam1 = 0.0f; + mFloatParam2 = 0.0f; + mFloatParam3 = 0.0f; + mBoolReturn = false; + mIntReturn = 0; + mFloatReturn = 0.0f; + mHandled = false; + } + + void VoidSlotVoid() + { + mHandled = true; + ++mHandledCount; + } + + void VoidSlotIntRef( int& p1 ) + { + mIntParam1 = p1; + mHandled = true; + ++mHandledCount; + } + + void VoidSlotIntValue( int p1 ) + { + mIntParam1 = p1; + mHandled = true; + ++mHandledCount; + } + + void VoidDuplicateSlotIntValue( int p1 ) + { + mIntParam2 = p1; + mHandled = true; + ++mHandledCount; + } + + void VoidSlotIntValueIntValue( int p1, int p2 ) + { + mIntParam1 = p1; + mIntParam2 = p2; + mHandled = true; + ++mHandledCount; + } + + bool BoolSlotFloatValue( float p1 ) + { + mFloatParam1 = p1; + mHandled = true; + ++mHandledCount; + return mBoolReturn; + } + + bool BoolSlotFloatValueIntValue( float p1, int p2 ) + { + mFloatParam1 = p1; + mIntParam2 = p2; + mHandled = true; + ++mHandledCount; + return mBoolReturn; + } + + int IntSlotFloatValueIntValue( float p1, int p2 ) + { + mFloatParam1 = p1; + mIntParam2 = p2; + mHandled = true; + ++mHandledCount; + return mIntReturn; + } + + float FloatSlotVoid() + { + mHandled = true; + ++mHandledCount; + return mFloatReturn; + } + + float FloatSlotFloatValueFloatValue( float p1, float p2 ) + { + mFloatParam1 = p1; + mFloatParam2 = p2; + mHandled = true; + ++mHandledCount; + return mFloatReturn; + } + + void VoidSlotFloatValue3( float p1, float p2, float p3 ) + { + mFloatParam1 = p1; + mFloatParam2 = p2; + mFloatParam3 = p3; + mHandled = true; + ++mHandledCount; + } + + float FloatSlotFloatValue3( float p1, float p2, float p3 ) + { + mFloatParam1 = p1; + mFloatParam2 = p2; + mFloatParam3 = p3; + mHandled = true; + ++mHandledCount; + return mFloatReturn; + } + + SlotDelegate mSlotDelegate; + + int mIntParam1, mIntParam2, mIntParam3; + float mFloatParam1, mFloatParam2, mFloatParam3; + bool mBoolReturn; + int mIntReturn; + float mFloatReturn; + bool mHandled; + int mHandledCount; +}; + +/** + * Test that reimplmenting ConnectionTrackerInterface actually works. + * This basic connection tracker only allows one callback to be connected. + */ +class TestBasicConnectionTrackerInterface : public ConnectionTrackerInterface +{ +public: + + TestBasicConnectionTrackerInterface() + : mCallbackHandled( false ), + mCallback( NULL ), + mSlotObserver( NULL ) + { + } + + ~TestBasicConnectionTrackerInterface() + { + if( mCallback ) + { + // Notify signal since the slot has been destroyed + mSlotObserver->SlotDisconnected( mCallback ); + delete mCallback; + } + } + + /** + * An example slot + */ + void VoidSlotVoid() + { + mCallbackHandled = true; + } + + /** + * @copydoc ConnectionTrackerInterface::GetConnectionCount + */ + virtual std::size_t GetConnectionCount() const + { + if( mCallback ) + { + return 1u; + } + + return 0u; + } + + /** + * @copydoc ConnectionTrackerInterface::SignalConnected + */ + virtual void SignalConnected( SlotObserver* slotObserver, CallbackBase* callback ) + { + DALI_ASSERT_ALWAYS( NULL == mCallback && "Only one connection supported!" ); + + mCallback = callback; + mSlotObserver = slotObserver; + } + + /** + * @copydoc ConnectionTrackerInterface::SignalDisconnected + */ + virtual void SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback ) + { + if( mSlotObserver == slotObserver ) + { + mSlotObserver = NULL; + + delete mCallback; + mCallback = NULL; + } + } + +private: + + TestBasicConnectionTrackerInterface( const TestBasicConnectionTrackerInterface& ); ///< undefined copy constructor + TestBasicConnectionTrackerInterface& operator=( const TestBasicConnectionTrackerInterface& ); ///< undefined assignment operator + +public: + + bool mCallbackHandled; + +private: + + CallbackBase* mCallback; ///< callback, has ownership + SlotObserver* mSlotObserver; ///< a pointer to the slot observer (not owned) +}; + + +bool wasStaticVoidCallbackVoidCalled = false; +bool wasStaticFloatCallbackVoidCalled = false; +bool wasStaticVoidCallbackIntValueCalled = false; +int staticIntValue = 0; +bool wasStaticFloatCallbackFloatValueFloatValueCalled = false; +float staticFloatValue1 = 0.0f; +float staticFloatValue2 = 0.0f; + +static void StaticVoidCallbackVoid() +{ + wasStaticVoidCallbackVoidCalled = true; +} + +static float StaticFloatCallbackVoid() +{ + wasStaticFloatCallbackVoidCalled = true; + return 7.0f; +} + +static void StaticVoidCallbackIntValue( int value ) +{ + wasStaticVoidCallbackIntValueCalled = true; + staticIntValue = value; +} + +static float StaticFloatCallbackFloatValueFloatValue( float value1, float value2 ) +{ + wasStaticFloatCallbackFloatValueFloatValueCalled = true; + staticFloatValue1 = value1; + staticFloatValue2 = value2; + return value1 + value2; +} + +} // anon namespace + + +int UtcDaliSignalEmptyCheck(void) +{ + // Test that Empty() check works before & after signal connection + + { + TestSignals::VoidRetNoParamSignal signal; + DALI_TEST_CHECK( signal.Empty() ); + TestSlotHandler handler; + signal.Connect( &handler, &TestSlotHandler::VoidSlotVoid ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + + { + TestSignals::VoidRet1ValueParamSignal signal; + DALI_TEST_CHECK( signal.Empty() ); + TestSlotHandler handler; + signal.Connect( &handler, &TestSlotHandler::VoidSlotIntValue ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + + { + TestSignals::VoidRet1RefParamSignal signal; + DALI_TEST_CHECK( signal.Empty() ); + TestSlotHandler handler; + signal.Connect( &handler, &TestSlotHandler::VoidSlotIntRef ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + + { + TestSignals::VoidRet2ValueParamSignal signal; + DALI_TEST_CHECK( signal.Empty() ); + TestSlotHandler handler; + signal.Connect( &handler, &TestSlotHandler::VoidSlotIntValueIntValue ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + + { + TestSignals::BoolRet1ValueParamSignal signal; + DALI_TEST_CHECK( signal.Empty() ); + TestSlotHandler handler; + signal.Connect( &handler, &TestSlotHandler::BoolSlotFloatValue ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + + { + TestSignals::BoolRet2ValueParamSignal signal; + DALI_TEST_CHECK( signal.Empty() ); + TestSlotHandler handler; + signal.Connect( &handler, &TestSlotHandler::BoolSlotFloatValueIntValue ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + + { + TestSignals::IntRet2ValueParamSignal signal; + DALI_TEST_CHECK( signal.Empty() ); + TestSlotHandler handler; + signal.Connect( &handler, &TestSlotHandler::IntSlotFloatValueIntValue ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + + { + TestSignals::FloatRet0ParamSignal signal; + DALI_TEST_CHECK( signal.Empty() ); + TestSlotHandler handler; + signal.Connect( &handler, &TestSlotHandler::FloatSlotVoid ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + + { + TestSignals::FloatRet2ValueParamSignal signal; + DALI_TEST_CHECK( signal.Empty() ); + TestSlotHandler handler; + signal.Connect(&handler, &TestSlotHandler::FloatSlotFloatValueFloatValue); + DALI_TEST_CHECK( ! signal.Empty() ); + } + END_TEST; +} + +int UtcDaliSignalEmptyCheckSlotDestruction(void) +{ + // Test that signal disconnect works when slot is destroyed (goes out of scope) + + { + TestSignals::VoidRetNoParamSignal signal; + { + DALI_TEST_CHECK( signal.Empty() ); + TestSlotHandler handler; + signal.Connect( &handler, &TestSlotHandler::VoidSlotVoid ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + // End of slot lifetime + DALI_TEST_CHECK( signal.Empty() ); + + // Signal emission should be a NOOP + signal.Emit(); + } + + { + TestSignals::VoidRet1ValueParamSignal signal; + { + DALI_TEST_CHECK( signal.Empty() ); + TestSlotHandler handler; + signal.Connect( &handler, &TestSlotHandler::VoidSlotIntValue ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + // End of slot lifetime + DALI_TEST_CHECK( signal.Empty() ); + + // Signal emission should be a NOOP + signal.Emit( 10 ); + } + + { + TestSignals::VoidRet1RefParamSignal signal; + { + DALI_TEST_CHECK( signal.Empty() ); + TestSlotHandler handler; + signal.Connect( &handler, &TestSlotHandler::VoidSlotIntRef ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + // End of slot lifetime + DALI_TEST_CHECK( signal.Empty() ); + + // Signal emission should be a NOOP + int temp( 5 ); + signal.Emit( temp ); + } + + { + TestSignals::VoidRet2ValueParamSignal signal; + { + DALI_TEST_CHECK( signal.Empty() ); + TestSlotHandler handler; + signal.Connect( &handler, &TestSlotHandler::VoidSlotIntValueIntValue ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + // End of slot lifetime + DALI_TEST_CHECK( signal.Empty() ); + + // Signal emission should be a NOOP + signal.Emit( 1, 2 ); + } + + { + TestSignals::BoolRet1ValueParamSignal signal; + { + DALI_TEST_CHECK( signal.Empty() ); + TestSlotHandler handler; + signal.Connect( &handler, &TestSlotHandler::BoolSlotFloatValue ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + // End of slot lifetime + DALI_TEST_CHECK( signal.Empty() ); + + // Signal emission should be a NOOP + bool blah = signal.Emit( 1.0f ); + DALI_TEST_CHECK( ! blah ); + } + + { + TestSignals::BoolRet2ValueParamSignal signal; + { + DALI_TEST_CHECK( signal.Empty() ); + TestSlotHandler handler; + signal.Connect( &handler, &TestSlotHandler::BoolSlotFloatValueIntValue ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + // End of slot lifetime + DALI_TEST_CHECK( signal.Empty() ); + + // Signal emission should be a NOOP + bool blah = signal.Emit( 1.0f, 2 ); + DALI_TEST_CHECK( ! blah ); + } + + { + TestSignals::IntRet2ValueParamSignal signal; + { + DALI_TEST_CHECK( signal.Empty() ); + TestSlotHandler handler; + signal.Connect( &handler, &TestSlotHandler::IntSlotFloatValueIntValue ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + // End of slot lifetime + DALI_TEST_CHECK( signal.Empty() ); + + // Signal emission should be a NOOP + int blah = signal.Emit( 10.0f, 100 ); + DALI_TEST_CHECK( 0 == blah ); + } + + { + TestSignals::FloatRet0ParamSignal signal; + { + DALI_TEST_CHECK( signal.Empty() ); + TestSlotHandler handler; + signal.Connect( &handler, &TestSlotHandler::FloatSlotVoid ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + // End of slot lifetime + DALI_TEST_CHECK( signal.Empty() ); + + // Signal emission should be a NOOP + float blah = signal.Emit(); + DALI_TEST_CHECK( 0.0f == blah ); + } + + { + TestSignals::FloatRet2ValueParamSignal signal; + { + DALI_TEST_CHECK( signal.Empty() ); + TestSlotHandler handler; + signal.Connect(&handler, &TestSlotHandler::FloatSlotFloatValueFloatValue); + DALI_TEST_CHECK( ! signal.Empty() ); + } + // End of slot lifetime + DALI_TEST_CHECK( signal.Empty() ); + + // Signal emission should be a NOOP + float blah = signal.Emit( 3.0f, 4.0f ); + DALI_TEST_CHECK( 0.0f == blah ); + } + END_TEST; +} + +// Positive test case for a method +int UtcDaliSignalConnectAndEmit(void) +{ + // Test basic signal emission for each slot type + + TestSignals signals; + + { + TestSlotHandler handlers; + signals.SignalVoidNone().Connect(&handlers, &TestSlotHandler::VoidSlotVoid); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + signals.EmitVoidSignalVoid(); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + + // Test double emission + handlers.mHandled = false; + signals.EmitVoidSignalVoid(); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + } + signals.CheckNoConnections(); + + { + TestSlotHandler handlers; + signals.SignalVoid1Ref().Connect(&handlers, &TestSlotHandler::VoidSlotIntRef); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + int x = 7; + signals.EmitVoidSignalIntRef(x); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam1, 7, TEST_LOCATION ); + } + signals.CheckNoConnections(); + + { + TestSlotHandler handlers; + signals.SignalVoid1Value().Connect(&handlers, &TestSlotHandler::VoidSlotIntValue); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + signals.EmitVoidSignalIntValue(5); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam1, 5, TEST_LOCATION ); + } + signals.CheckNoConnections(); + + { + TestSlotHandler handlers; + signals.SignalVoid2Value().Connect(&handlers, &TestSlotHandler::VoidSlotIntValueIntValue); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + signals.EmitVoidSignalIntValueIntValue(6, 7); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam1, 6, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam2, 7, TEST_LOCATION ); + } + signals.CheckNoConnections(); + + { + TestSlotHandler handlers; + signals.SignalBool1Value().Connect(&handlers, &TestSlotHandler::BoolSlotFloatValue); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + + handlers.mBoolReturn = true; + DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValue(5.0f), true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION ); + + // repeat with opposite return value + handlers.mBoolReturn = false; + handlers.mHandled = false; + DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValue(6.0f), false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 6.0f, TEST_LOCATION ); + } + signals.CheckNoConnections(); + + { + TestSlotHandler handlers; + signals.SignalBool2Value().Connect(&handlers, &TestSlotHandler::BoolSlotFloatValueIntValue); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + handlers.mBoolReturn = true; + DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValueIntValue(5.0f, 10), true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam2, 10, TEST_LOCATION ); + } + signals.CheckNoConnections(); + + { + TestSlotHandler handlers; + signals.SignalInt2Value().Connect(&handlers, &TestSlotHandler::IntSlotFloatValueIntValue); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + handlers.mIntReturn = 27; + int x = signals.EmitIntSignalFloatValueIntValue(33.5f, 5); + DALI_TEST_EQUALS( x, 27, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 33.5f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam2, 5, TEST_LOCATION ); + } + signals.CheckNoConnections(); + + { + TestSlotHandler handlers; + signals.SignalFloat0().Connect(&handlers, &TestSlotHandler::FloatSlotVoid); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + handlers.mFloatReturn = 27.0f; + float f = signals.EmitFloat0Signal(); + DALI_TEST_EQUALS( f, 27.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION ); + } + signals.CheckNoConnections(); + + { + TestSlotHandler handlers; + signals.SignalFloat2Value().Connect(&handlers, &TestSlotHandler::FloatSlotFloatValueFloatValue); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + handlers.mFloatReturn = 27.0f; + float f = signals.EmitFloat2VSignal(5, 33.0f); + DALI_TEST_EQUALS( f, 27.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam2, 33.0f, 0.001f, TEST_LOCATION ); + } + signals.CheckNoConnections(); + + { + TestSlotHandler handlers; + signals.VoidSignalFloatValue3().Connect(&handlers, &TestSlotHandler::VoidSlotFloatValue3); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + signals.EmitVoidSignalFloatValue3(5, 33.0f, 100.0f); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam2, 33.0f, 0.001f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam3, 100.0f, 0.001f, TEST_LOCATION ); + } + signals.CheckNoConnections(); + + { + TestSlotHandler handlers; + signals.FloatSignalFloatValue3().Connect(&handlers, &TestSlotHandler::FloatSlotFloatValue3); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + handlers.mFloatReturn = 27.0f; + float returnValue = signals.EmitFloatSignalFloatValue3(5, 33.0f, 100.0f); + DALI_TEST_EQUALS( returnValue, 27.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam2, 33.0f, 0.001f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam3, 100.0f, 0.001f, TEST_LOCATION ); + } + signals.CheckNoConnections(); + END_TEST; +} + +int UtcDaliSignalDisconnect(void) +{ + // Test that callbacks don't occur if a signal is disconnected before emission + + TestSignals signals; + + { + TestSlotHandler handlers; + signals.SignalVoidNone().Connect(&handlers, &TestSlotHandler::VoidSlotVoid); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + signals.SignalVoidNone().Disconnect(&handlers, &TestSlotHandler::VoidSlotVoid); + signals.EmitVoidSignalVoid(); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + } + + { + TestSlotHandler handlers; + signals.SignalVoid1Ref().Connect(&handlers, &TestSlotHandler::VoidSlotIntRef); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + int r = 7; + handlers.mIntReturn = 5; + signals.SignalVoid1Ref().Disconnect(&handlers, &TestSlotHandler::VoidSlotIntRef); + signals.EmitVoidSignalIntRef(r); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( r, 7, TEST_LOCATION ); + } + + { + TestSlotHandler handlers; + signals.SignalVoid1Value().Connect(&handlers, &TestSlotHandler::VoidSlotIntValue); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + signals.SignalVoid1Value().Disconnect(&handlers, &TestSlotHandler::VoidSlotIntValue); + signals.EmitVoidSignalIntValue(5); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION ); + } + + { + TestSlotHandler handlers; + signals.SignalVoid2Value().Connect(&handlers, &TestSlotHandler::VoidSlotIntValueIntValue); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + signals.SignalVoid2Value().Disconnect(&handlers, &TestSlotHandler::VoidSlotIntValueIntValue); + signals.EmitVoidSignalIntValueIntValue(5, 10); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam2, 0, TEST_LOCATION ); + } + + { + TestSlotHandler handlers; + signals.SignalBool1Value().Connect(&handlers, &TestSlotHandler::BoolSlotFloatValue); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + handlers.mBoolReturn = true; + signals.SignalBool1Value().Disconnect(&handlers, &TestSlotHandler::BoolSlotFloatValue); + DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValue(5.0f), false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, TEST_LOCATION ); + } + + { + TestSlotHandler handlers; + signals.SignalBool2Value().Connect(&handlers, &TestSlotHandler::BoolSlotFloatValueIntValue); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + handlers.mBoolReturn = true; + signals.SignalBool2Value().Disconnect(&handlers, &TestSlotHandler::BoolSlotFloatValueIntValue); + DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValueIntValue(5.0f, 10), false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam2, 0, TEST_LOCATION ); + } + + { + TestSlotHandler handlers; + signals.SignalInt2Value().Connect(&handlers, &TestSlotHandler::IntSlotFloatValueIntValue); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + handlers.mIntReturn = 27; + signals.SignalInt2Value().Disconnect(&handlers, &TestSlotHandler::IntSlotFloatValueIntValue); + signals.EmitIntSignalFloatValueIntValue(5, 33.0f); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION ); + } + + { + TestSlotHandler handlers; + signals.SignalFloat0().Connect(&handlers, &TestSlotHandler::FloatSlotVoid); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + handlers.mFloatReturn = 27.0f; + signals.SignalFloat0().Disconnect(&handlers, &TestSlotHandler::FloatSlotVoid); + signals.EmitFloat0Signal(); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, 0.001f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION ); + } + + { + TestSlotHandler handlers; + signals.SignalFloat2Value().Connect(&handlers, &TestSlotHandler::FloatSlotFloatValueFloatValue); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + handlers.mFloatReturn = 27.0f; + signals.SignalFloat2Value().Disconnect(&handlers, &TestSlotHandler::FloatSlotFloatValueFloatValue); + signals.EmitFloat2VSignal(5, 33.0f); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, 0.001f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliSignalDisconnect2(void) +{ + // Test that nothing happens when attempting to disconnect an unconnected slot + + TestSignals signals; + { + TestSlotHandler handlers; + signals.SignalVoidNone().Disconnect(&handlers, &TestSlotHandler::VoidSlotVoid); + signals.EmitVoidSignalVoid(); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + } + + { + TestSlotHandler handlers; + int r = 7; + signals.SignalVoid1Ref().Disconnect(&handlers, &TestSlotHandler::VoidSlotIntRef); + signals.EmitVoidSignalIntRef(r); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( r, 7, TEST_LOCATION ); + } + + { + TestSlotHandler handlers; + signals.SignalVoid1Value().Disconnect(&handlers, &TestSlotHandler::VoidSlotIntValue); + signals.EmitVoidSignalIntValue(5); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION ); + } + + { + TestSlotHandler handlers; + signals.SignalVoid2Value().Disconnect(&handlers, &TestSlotHandler::VoidSlotIntValueIntValue); + signals.EmitVoidSignalIntValueIntValue(5, 10); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam2, 0, TEST_LOCATION ); + } + + { + TestSlotHandler handlers; + handlers.mBoolReturn = true; + signals.SignalBool1Value().Disconnect(&handlers, &TestSlotHandler::BoolSlotFloatValue); + DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValue(5.0f), false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, TEST_LOCATION ); + } + + { + TestSlotHandler handlers; + handlers.mBoolReturn = true; + signals.SignalBool2Value().Disconnect(&handlers, &TestSlotHandler::BoolSlotFloatValueIntValue); + DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValueIntValue(5.0f, 10), false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam2, 0, TEST_LOCATION ); + } + + { + TestSlotHandler handlers; + handlers.mIntReturn = 27; + signals.SignalInt2Value().Disconnect(&handlers, &TestSlotHandler::IntSlotFloatValueIntValue); + signals.EmitIntSignalFloatValueIntValue(5, 33.0f); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION ); + } + + { + TestSlotHandler handlers; + handlers.mFloatReturn = 27.0f; + signals.SignalFloat2Value().Disconnect(&handlers, &TestSlotHandler::FloatSlotFloatValueFloatValue); + signals.EmitFloat2VSignal(5, 33.0f); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, 0.001f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION ); + } + + { + TestSlotHandler handlers; + handlers.mFloatReturn = 27.0f; + signals.SignalFloat0().Disconnect(&handlers, &TestSlotHandler::FloatSlotVoid); + signals.EmitFloat0Signal(); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, 0.001f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliSignalDisconnect3(void) +{ + // Test that callbacks stop after a signal is disconnected + + TestSignals signals; + + { + TestSlotHandler handlers; + signals.SignalVoidNone().Connect(&handlers, &TestSlotHandler::VoidSlotVoid); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + + // Emit first + signals.EmitVoidSignalVoid(); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + + // Disconnect and emit again + handlers.mHandled = false; + signals.SignalVoidNone().Disconnect(&handlers, &TestSlotHandler::VoidSlotVoid); + signals.EmitVoidSignalVoid(); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + } + + { + TestSlotHandler handlers; + signals.SignalVoid1Ref().Connect(&handlers, &TestSlotHandler::VoidSlotIntRef); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + int r = 7; + + // Emit first + signals.EmitVoidSignalIntRef(r); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam1, 7, TEST_LOCATION ); + + // Disconnect and emit again + handlers.mHandled = false; + handlers.mIntParam1 = 0; + signals.SignalVoid1Ref().Disconnect(&handlers, &TestSlotHandler::VoidSlotIntRef); + signals.EmitVoidSignalIntRef(r); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( r, 7, TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliSignalCustomConnectionTracker(void) +{ + // Test slot destruction + { + TestSignals::VoidRetNoParamSignal signal; + { + DALI_TEST_CHECK( signal.Empty() ); + TestBasicConnectionTrackerInterface customTracker; + signal.Connect( &customTracker, &TestBasicConnectionTrackerInterface::VoidSlotVoid ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + // End of slot lifetime + DALI_TEST_CHECK( signal.Empty() ); + + // Signal emission should be a NOOP + signal.Emit(); + } + + TestBasicConnectionTrackerInterface customTracker2; + + // Test signal emission & destruction + { + TestSignals::VoidRetNoParamSignal signal; + DALI_TEST_CHECK( signal.Empty() ); + DALI_TEST_EQUALS( 0u, customTracker2.GetConnectionCount(), TEST_LOCATION ); + + signal.Connect( &customTracker2, &TestBasicConnectionTrackerInterface::VoidSlotVoid ); + DALI_TEST_CHECK( ! signal.Empty() ); + DALI_TEST_EQUALS( 1u, customTracker2.GetConnectionCount(), TEST_LOCATION ); + + DALI_TEST_EQUALS( customTracker2.mCallbackHandled, false, TEST_LOCATION ); + signal.Emit(); + DALI_TEST_EQUALS( customTracker2.mCallbackHandled, true, TEST_LOCATION ); + } + DALI_TEST_EQUALS( 0u, customTracker2.GetConnectionCount(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliSignalMultipleConnections(void) +{ + // Test that multiple callbacks can be connected to the same signal + + TestSignals signals; + + { + TestSlotHandler handler1; + signals.SignalVoidNone().Connect( &handler1, &TestSlotHandler::VoidSlotVoid ); + DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION ); + + TestSlotHandler handler2; + signals.SignalVoidNone().Connect( &handler2, &TestSlotHandler::VoidSlotVoid ); + DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION ); + + signals.EmitVoidSignalVoid(); + DALI_TEST_EQUALS( handler1.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handler2.mHandled, true, TEST_LOCATION ); + + // Remove first connection and repeat + handler1.Reset(); + handler2.Reset(); + signals.SignalVoidNone().Disconnect( &handler1, &TestSlotHandler::VoidSlotVoid ); + + signals.EmitVoidSignalVoid(); + DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handler2.mHandled, true, TEST_LOCATION ); + } + + { + TestSlotHandler handler1; + signals.SignalVoid1Ref().Connect( &handler1, &TestSlotHandler::VoidSlotIntRef ); + DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION ); + + TestSlotHandler handler2; + signals.SignalVoid1Ref().Connect( &handler2, &TestSlotHandler::VoidSlotIntRef ); + DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION ); + + int x = 7; + signals.EmitVoidSignalIntRef(x); + DALI_TEST_EQUALS( handler1.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handler2.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handler1.mIntParam1, 7, TEST_LOCATION ); + DALI_TEST_EQUALS( handler2.mIntParam1, 7, TEST_LOCATION ); + + // Remove second connection and repeat + handler1.Reset(); + handler2.Reset(); + x = 8; + signals.SignalVoid1Ref().Disconnect( &handler2, &TestSlotHandler::VoidSlotIntRef ); + + signals.EmitVoidSignalIntRef(x); + DALI_TEST_EQUALS( handler1.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handler1.mIntParam1, 8, TEST_LOCATION ); + DALI_TEST_EQUALS( handler2.mIntParam1, 0, TEST_LOCATION ); + } + + { + TestSlotHandler handler1; + signals.SignalVoid1Value().Connect( &handler1, &TestSlotHandler::VoidSlotIntValue ); + DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION ); + + TestSlotHandler handler2; + signals.SignalVoid1Value().Connect( &handler2, &TestSlotHandler::VoidSlotIntValue ); + DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION ); + + TestSlotHandler handler3; + signals.SignalVoid1Value().Connect( &handler3, &TestSlotHandler::VoidSlotIntValue ); + DALI_TEST_EQUALS( handler3.mHandled, false, TEST_LOCATION ); + + signals.EmitVoidSignalIntValue( 5 ); + DALI_TEST_EQUALS( handler1.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handler1.mIntParam1, 5, TEST_LOCATION ); + DALI_TEST_EQUALS( handler2.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handler2.mIntParam1, 5, TEST_LOCATION ); + DALI_TEST_EQUALS( handler3.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handler3.mIntParam1, 5, TEST_LOCATION ); + + // Remove middle connection and repeat + handler1.Reset(); + handler2.Reset(); + handler3.Reset(); + signals.SignalVoid1Value().Disconnect( &handler2, &TestSlotHandler::VoidSlotIntValue ); + + signals.EmitVoidSignalIntValue( 6 ); + DALI_TEST_EQUALS( handler1.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handler1.mIntParam1, 6, TEST_LOCATION ); + DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handler2.mIntParam1, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( handler3.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handler3.mIntParam1, 6, TEST_LOCATION ); + } + + // Test that multiple callbacks are disconnected when a signal is destroyed + + TestSlotHandler handler4; + TestSlotHandler handler5; + TestSlotHandler handler6; + + { + TestSignals::VoidRet1ValueParamSignal tempSignal; + + DALI_TEST_EQUALS( handler4.GetConnectionCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( handler5.GetConnectionCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( handler6.GetConnectionCount(), 0u, TEST_LOCATION ); + + tempSignal.Connect( &handler4, &TestSlotHandler::VoidSlotIntValue ); + tempSignal.Connect( &handler5, &TestSlotHandler::VoidSlotIntValue ); + tempSignal.Connect( &handler6, &TestSlotHandler::VoidSlotIntValue ); + + DALI_TEST_EQUALS( handler4.GetConnectionCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( handler5.GetConnectionCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( handler6.GetConnectionCount(), 1u, TEST_LOCATION ); + } + // End of tempSignal lifetime + + DALI_TEST_EQUALS( handler4.GetConnectionCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( handler5.GetConnectionCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( handler6.GetConnectionCount(), 0u, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliSignalMultipleConnections2(void) +{ + TestSignals signals; + + // Test that connecting the same callback twice is a NOOP + { + TestSlotHandler handler1; + + // Note the double connection is intentional + signals.SignalVoid1Value().Connect( &handler1, &TestSlotHandler::VoidSlotIntValue ); + signals.SignalVoid1Value().Connect( &handler1, &TestSlotHandler::VoidSlotIntValue ); + DALI_TEST_EQUALS( handler1.mHandledCount, 0, TEST_LOCATION ); + + signals.EmitVoidSignalIntValue( 6 ); + DALI_TEST_EQUALS( handler1.mHandledCount, 1, TEST_LOCATION ); + DALI_TEST_EQUALS( handler1.mIntParam1, 6, TEST_LOCATION ); + + // Calling Disconnect once should be enough + signals.SignalVoid1Value().Disconnect( &handler1, &TestSlotHandler::VoidSlotIntValue ); + DALI_TEST_CHECK( signals.SignalVoid1Value().Empty() ); + handler1.mIntParam1 = 0; + + signals.EmitVoidSignalIntValue( 7 ); + DALI_TEST_EQUALS( handler1.mHandledCount, 1/*not incremented since last check*/, TEST_LOCATION ); + DALI_TEST_EQUALS( handler1.mIntParam1, 0, TEST_LOCATION ); + } + + // Test automatic disconnect after multiple Connect() calls + { + TestSlotHandler handler2; + signals.SignalVoid1Value().Connect( &handler2, &TestSlotHandler::VoidSlotIntValue ); + signals.SignalVoid1Value().Connect( &handler2, &TestSlotHandler::VoidSlotIntValue ); + + TestSlotHandler handler3; + signals.SignalBool1Value().Connect( &handler3, &TestSlotHandler::BoolSlotFloatValue ); + signals.SignalBool1Value().Connect( &handler3, &TestSlotHandler::BoolSlotFloatValue ); + + DALI_TEST_EQUALS( handler2.mHandledCount, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( handler3.mHandledCount, 0, TEST_LOCATION ); + DALI_TEST_CHECK( ! signals.SignalVoid1Value().Empty() ); + DALI_TEST_CHECK( ! signals.SignalBool1Value().Empty() ); + } + DALI_TEST_CHECK( signals.SignalVoid1Value().Empty() ); + DALI_TEST_CHECK( signals.SignalBool1Value().Empty() ); + + // Should be NOOP + signals.EmitVoidSignalIntValue( 1 ); + signals.EmitBoolSignalFloatValue( 1.0f ); + + // Test that connecting the same callback 10 times is a NOOP + TestSlotHandler handler4; + DALI_TEST_EQUALS( handler4.mHandledCount, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( handler4.mFloatParam1, 0.0f, TEST_LOCATION ); + + signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue ); + signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue ); + signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue ); + signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue ); + signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue ); + signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue ); + signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue ); + signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue ); + signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue ); + signals.SignalBool1Value().Connect( &handler4, &TestSlotHandler::BoolSlotFloatValue ); + + signals.EmitBoolSignalFloatValue( 2.0f ); + DALI_TEST_EQUALS( handler4.mHandledCount, 1, TEST_LOCATION ); + DALI_TEST_EQUALS( handler4.mFloatParam1, 2.0f, TEST_LOCATION ); + + // Calling Disconnect once should be enough + signals.SignalBool1Value().Disconnect( &handler4, &TestSlotHandler::BoolSlotFloatValue ); + DALI_TEST_CHECK( signals.SignalBool1Value().Empty() ); + + signals.EmitBoolSignalFloatValue( 3.0f ); + DALI_TEST_EQUALS( handler4.mHandledCount, 1/*not incremented since last check*/, TEST_LOCATION ); + DALI_TEST_EQUALS( handler4.mFloatParam1, 2.0f, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliSignalMultipleConnections3(void) +{ + TestSignals signals; + + // Test connecting two difference callbacks for the same ConnectionTracker + + TestSlotHandler handler1; + + { + TestSignals::VoidRet1ValueParamSignal tempSignal; + + DALI_TEST_EQUALS( handler1.GetConnectionCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( handler1.mHandledCount, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( handler1.mIntParam1, 0, TEST_LOCATION ); + + // Note that the duplicate connection is deliberate + tempSignal.Connect( &handler1, &TestSlotHandler::VoidSlotIntValue ); + tempSignal.Connect( &handler1, &TestSlotHandler::VoidDuplicateSlotIntValue ); + + DALI_TEST_EQUALS( handler1.GetConnectionCount(), 2u, TEST_LOCATION ); + DALI_TEST_EQUALS( handler1.mHandledCount, 0, TEST_LOCATION ); + + tempSignal.Emit( 10 ); + + DALI_TEST_EQUALS( handler1.mHandledCount, 2, TEST_LOCATION ); + DALI_TEST_EQUALS( handler1.mIntParam1, 10, TEST_LOCATION ); + DALI_TEST_EQUALS( handler1.mIntParam2, 10, TEST_LOCATION ); + } + // End of tempSignal lifetime + + DALI_TEST_EQUALS( handler1.GetConnectionCount(), 0u, TEST_LOCATION ); + END_TEST; +} + + +int UtcDaliSignalDisconnectStatic(void) +{ + // void Func() + + { + TestSignals::VoidRetNoParamSignal signal; + DALI_TEST_CHECK( signal.Empty() ); + + signal.Connect( StaticVoidCallbackVoid ); + DALI_TEST_CHECK( ! signal.Empty() ); + + wasStaticVoidCallbackVoidCalled = false; + signal.Emit(); + DALI_TEST_EQUALS( wasStaticVoidCallbackVoidCalled, true, TEST_LOCATION ); + + signal.Disconnect( StaticVoidCallbackVoid ); + DALI_TEST_CHECK( signal.Empty() ); + + wasStaticVoidCallbackVoidCalled = false; + signal.Emit(); + DALI_TEST_EQUALS( wasStaticVoidCallbackVoidCalled, false, TEST_LOCATION ); + } + + // float Func() + + { + TestSignals::FloatRet0ParamSignal signal; + DALI_TEST_CHECK( signal.Empty() ); + + signal.Connect( StaticFloatCallbackVoid ); + DALI_TEST_CHECK( ! signal.Empty() ); + + wasStaticFloatCallbackVoidCalled = false; + float result = signal.Emit(); + DALI_TEST_EQUALS( wasStaticFloatCallbackVoidCalled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( result, 7.0f, TEST_LOCATION ); + + signal.Disconnect( StaticFloatCallbackVoid ); + DALI_TEST_CHECK( signal.Empty() ); + + wasStaticFloatCallbackVoidCalled = false; + result = signal.Emit(); + DALI_TEST_EQUALS( wasStaticFloatCallbackVoidCalled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( result, 0.0f, TEST_LOCATION ); + } + + // void Func( int ) + + { + TestSignals::VoidRet1ValueParamSignal signal; + DALI_TEST_CHECK( signal.Empty() ); + + signal.Connect( StaticVoidCallbackIntValue ); + DALI_TEST_CHECK( ! signal.Empty() ); + + wasStaticVoidCallbackIntValueCalled = false; + staticIntValue = 0; + signal.Emit( 10 ); + DALI_TEST_EQUALS( wasStaticVoidCallbackIntValueCalled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( staticIntValue, 10, TEST_LOCATION ); + + signal.Disconnect( StaticVoidCallbackIntValue ); + DALI_TEST_CHECK( signal.Empty() ); + + wasStaticVoidCallbackIntValueCalled = false; + staticIntValue = 0; + signal.Emit( 11 ); + DALI_TEST_EQUALS( wasStaticVoidCallbackIntValueCalled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( staticIntValue, 0, TEST_LOCATION ); + } + + // float Func( float, float ) + + { + TestSignals::FloatRet2ValueParamSignal signal; + DALI_TEST_CHECK( signal.Empty() ); + + signal.Connect( StaticFloatCallbackFloatValueFloatValue ); + DALI_TEST_CHECK( ! signal.Empty() ); + + wasStaticFloatCallbackFloatValueFloatValueCalled = false; + staticFloatValue1 = 0.0f; + staticFloatValue2 = 0.0f; + float result = signal.Emit( 5.0f, 6.0f ); + DALI_TEST_EQUALS( wasStaticFloatCallbackFloatValueFloatValueCalled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( staticFloatValue1, 5.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( staticFloatValue2, 6.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( result, 5.0f+6.0f, TEST_LOCATION ); + + signal.Disconnect( StaticFloatCallbackFloatValueFloatValue ); + DALI_TEST_CHECK( signal.Empty() ); + + wasStaticFloatCallbackFloatValueFloatValueCalled = false; + staticFloatValue1 = 0.0f; + staticFloatValue2 = 0.0f; + result = signal.Emit( 7.0f, 8.0f ); + DALI_TEST_EQUALS( wasStaticFloatCallbackFloatValueFloatValueCalled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( staticFloatValue1, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( staticFloatValue2, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( result, 0.0f, TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliSignalDisconnectDuringCallback(void) +{ + // Test disconnection during each callback + + TestSignals::VoidRetNoParamSignal signal; + DALI_TEST_CHECK( signal.Empty() ); + + TestSlotDisconnector handler1; + handler1.VoidConnectVoid( signal ); + DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION ); + DALI_TEST_CHECK( ! signal.Empty() ); + + signal.Emit(); + DALI_TEST_EQUALS( handler1.mHandled, true, TEST_LOCATION ); + DALI_TEST_CHECK( signal.Empty() ); + + // Repeat with 2 callbacks + + handler1.mHandled = false; + + TestSlotDisconnector handler2; + handler1.VoidConnectVoid( signal ); + handler2.VoidConnectVoid( signal ); + DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION ); + DALI_TEST_CHECK( ! signal.Empty() ); + + signal.Emit(); + DALI_TEST_EQUALS( handler1.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handler2.mHandled, true, TEST_LOCATION ); + DALI_TEST_CHECK( signal.Empty() ); + + // Repeat with no callbacks + + handler1.mHandled = false; + handler2.mHandled = false; + + signal.Emit(); + DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION ); + + // Repeat with 3 callbacks + + TestSlotDisconnector handler3; + handler1.VoidConnectVoid( signal ); + handler2.VoidConnectVoid( signal ); + handler3.VoidConnectVoid( signal ); + DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handler3.mHandled, false, TEST_LOCATION ); + DALI_TEST_CHECK( ! signal.Empty() ); + + signal.Emit(); + DALI_TEST_EQUALS( handler1.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handler2.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handler3.mHandled, true, TEST_LOCATION ); + DALI_TEST_CHECK( signal.Empty() ); + + // Repeat with no callbacks + + handler1.mHandled = false; + handler2.mHandled = false; + handler3.mHandled = false; + + signal.Emit(); + DALI_TEST_EQUALS( handler1.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handler2.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handler3.mHandled, false, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliSignalDisconnectDuringCallback2(void) +{ + // Test disconnection of some (but not all) callbacks during sigmal emission + + TestSignals::VoidRetNoParamSignal signal; + DALI_TEST_CHECK( signal.Empty() ); + + TestSlotMultiDisconnector handler; + handler.ConnectAll( signal ); + DALI_TEST_EQUALS( handler.mSlotHandled[0], false, TEST_LOCATION ); + DALI_TEST_EQUALS( handler.mSlotHandled[1], false, TEST_LOCATION ); + DALI_TEST_EQUALS( handler.mSlotHandled[2], false, TEST_LOCATION ); + DALI_TEST_EQUALS( handler.mSlotHandled[3], false, TEST_LOCATION ); + DALI_TEST_EQUALS( handler.mSlotHandled[4], false, TEST_LOCATION ); + DALI_TEST_EQUALS( handler.mSlotHandled[5], false, TEST_LOCATION ); + DALI_TEST_EQUALS( handler.mSlotHandled[6], false, TEST_LOCATION ); + DALI_TEST_EQUALS( handler.mSlotHandled[7], false, TEST_LOCATION ); + DALI_TEST_EQUALS( handler.mSlotHandled[8], false, TEST_LOCATION ); + DALI_TEST_EQUALS( handler.mSlotHandled[9], false, TEST_LOCATION ); + DALI_TEST_CHECK( ! signal.Empty() ); + + signal.Emit(); + + // Slots 5, 7, & 9 should be disconnected before being called + DALI_TEST_EQUALS( handler.mSlotHandled[0], true, TEST_LOCATION ); + DALI_TEST_EQUALS( handler.mSlotHandled[1], true, TEST_LOCATION ); + DALI_TEST_EQUALS( handler.mSlotHandled[2], true, TEST_LOCATION ); + DALI_TEST_EQUALS( handler.mSlotHandled[3], true, TEST_LOCATION ); + DALI_TEST_EQUALS( handler.mSlotHandled[4], true, TEST_LOCATION ); + DALI_TEST_EQUALS( handler.mSlotHandled[5], false, TEST_LOCATION ); + DALI_TEST_EQUALS( handler.mSlotHandled[6], true, TEST_LOCATION ); + DALI_TEST_EQUALS( handler.mSlotHandled[7], false, TEST_LOCATION ); + DALI_TEST_EQUALS( handler.mSlotHandled[8], true, TEST_LOCATION ); + DALI_TEST_EQUALS( handler.mSlotHandled[9], false, TEST_LOCATION ); + DALI_TEST_CHECK( ! signal.Empty() ); + + // Odd slots are disconnected + DALI_TEST_EQUALS( handler.GetConnectionCount(), 5u, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliSignalEmitDuringCallback(void) +{ + TestApplication app; // Create core for debug logging + + TestSignals::VoidRetNoParamSignal signal; + DALI_TEST_CHECK( signal.Empty() ); + + TestEmitDuringCallback handler1; + handler1.VoidConnectVoid( signal ); + + // Test that this does not result in an infinite loop! + signal.Emit(); + END_TEST; +} + +int UtcDaliSignalTestApp01(void) +{ + // Test 1 signal connected to 1 Slot. + // Signal dies first. + + TestButton* button = new TestButton(1); + TestApp app; + button->DownSignal().Connect(&app,&TestApp::OnButtonPress); + + // check we have both the button, and the app have 1 connection + DALI_TEST_EQUALS( app.GetConnectionCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( button->DownSignal().GetConnectionCount(), 1u, TEST_LOCATION ); + + delete button; // should automatically destroy the connection + + // check we have a 0 connections + DALI_TEST_EQUALS( app.GetConnectionCount(), 0u, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliSignalTestApp02(void) +{ + // Test 1 signal connected to 1 Slot. + // Slot owning object dies first. + + TestButton button(1); + TestApp *app = new TestApp; + button.DownSignal().Connect( app, &TestApp::OnButtonPress); + + // check we have a 1 connection + DALI_TEST_EQUALS( app->GetConnectionCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( button.DownSignal().GetConnectionCount(), 1u, TEST_LOCATION ); + + delete app; // should automatically destroy the connection + + // check we have a 0 connections + DALI_TEST_EQUALS( button.DownSignal().GetConnectionCount(), 0u, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliSignalTestApp03(void) +{ + // Test 1 Signal connect to 2 slots + // 1 of the slot owners dies. Then the second slot owner dies + + TestButton button(1); + TestApp *app1 = new TestApp; + TestApp *app2 = new TestApp; + + button.DownSignal().Connect( app1, &TestApp::OnButtonPress); + button.DownSignal().Connect( app2, &TestApp::OnButtonPress); + + // check we have a 2 connections to the signal + DALI_TEST_EQUALS( button.DownSignal().GetConnectionCount(), 2u, TEST_LOCATION ); + + // kill the first slot + delete app1; // should automatically destroy the connection + + // check we have 1 connection left + DALI_TEST_EQUALS( button.DownSignal().GetConnectionCount(), 1u, TEST_LOCATION ); + + button.Press(); // emit the signal (to ensure it doesn't seg fault) + + // kill the second slot + delete app2; // should automatically destroy the connection + + // check we have 1 connection left + DALI_TEST_EQUALS( button.DownSignal().GetConnectionCount(), 0u, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliSignalTestApp04(void) +{ + // Test 1 Signal connected to 2 slots (with different owners) + // The Signal dies, check the 2 slots disconnect automatically + + TestButton* button = new TestButton(1); + TestApp app1; + TestApp app2; + + button->DownSignal().Connect(&app1,&TestApp::OnButtonPress); + button->DownSignal().Connect(&app2,&TestApp::OnButtonPress); + + // check the connection counts + DALI_TEST_EQUALS( app1.GetConnectionCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( app2.GetConnectionCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( button->DownSignal().GetConnectionCount(), 2u, TEST_LOCATION ); + + delete button; // should automatically destroy the connection + + // check both slot owners have zero connections + DALI_TEST_EQUALS( app1.GetConnectionCount(), 0u, TEST_LOCATION ); + DALI_TEST_EQUALS( app2.GetConnectionCount(), 0u, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliSignalTestApp05(void) +{ + // Test 2 Signals (with different owners) connected to 1 slots + // 1 Signal dies, check that the remaining connection is valid + + TestButton* button1 = new TestButton(1); // use for signal 1 + TestButton* button2 = new TestButton(2); // use for signal 2 + + TestApp app; + + button1->DownSignal().Connect(&app,&TestApp::OnButtonPress); + button2->DownSignal().Connect(&app,&TestApp::OnButtonPress); + + // check the connection counts + DALI_TEST_EQUALS( app.GetConnectionCount(), 2u, TEST_LOCATION ); + DALI_TEST_EQUALS( button1->DownSignal().GetConnectionCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( button2->DownSignal().GetConnectionCount(), 1u, TEST_LOCATION ); + + // make sure both signals emit ok + button2->Press(); + DALI_TEST_EQUALS( app.GetButtonPressedId() , 2 , TEST_LOCATION ); + + button1->Press(); + DALI_TEST_EQUALS( app.GetButtonPressedId() , 1 , TEST_LOCATION ); + + delete button1; // should automatically destroy 1 connection + + // check both slot owners have zero connections + DALI_TEST_EQUALS( app.GetConnectionCount(), 1u, TEST_LOCATION ); + + // check remaining connection still works + button2->Press(); + DALI_TEST_EQUALS( app.GetButtonPressedId() , 2 , TEST_LOCATION ); + + // kill the last signal + delete button2; + DALI_TEST_EQUALS( app.GetConnectionCount(), 0u, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliSignalTestApp06(void) +{ + SignalV2< bool () > boolSignal; + TestApp app; + bool result(false); + + // connect a slot which will return false + boolSignal.Connect( &app, &TestApp::BoolReturnTestFalse); + result = boolSignal.Emit(); + DALI_TEST_EQUALS( result, false, TEST_LOCATION ); + + // disconnect last slot, and connect a slot which returns true + boolSignal.Disconnect( &app, &TestApp::BoolReturnTestFalse); + boolSignal.Connect( &app, &TestApp::BoolReturnTestTrue); + result = boolSignal.Emit(); + DALI_TEST_EQUALS( result, true, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliSlotDelegateConnection(void) +{ + TestSignals signals; + + { + TestSlotDelegateHandler handlers; + signals.SignalVoidNone().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotVoid ); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + signals.EmitVoidSignalVoid(); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + + // Test double emission + handlers.mHandled = false; + signals.EmitVoidSignalVoid(); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + } + signals.CheckNoConnections(); + + { + TestSlotDelegateHandler handlers; + signals.SignalVoid1Ref().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntRef ); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + int x = 7; + signals.EmitVoidSignalIntRef(x); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam1, 7, TEST_LOCATION ); + } + signals.CheckNoConnections(); + + { + TestSlotDelegateHandler handlers; + signals.SignalVoid1Value().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntValue ); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + signals.EmitVoidSignalIntValue(5); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam1, 5, TEST_LOCATION ); + } + signals.CheckNoConnections(); + + { + TestSlotDelegateHandler handlers; + signals.SignalVoid2Value().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntValueIntValue ); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + signals.EmitVoidSignalIntValueIntValue(6, 7); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam1, 6, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam2, 7, TEST_LOCATION ); + } + signals.CheckNoConnections(); + + { + TestSlotDelegateHandler handlers; + signals.SignalBool1Value().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::BoolSlotFloatValue ); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + + handlers.mBoolReturn = true; + DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValue(5.0f), true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION ); + + // repeat with opposite return value + handlers.mBoolReturn = false; + handlers.mHandled = false; + DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValue(6.0f), false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 6.0f, TEST_LOCATION ); + } + signals.CheckNoConnections(); + + { + TestSlotDelegateHandler handlers; + signals.SignalBool2Value().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::BoolSlotFloatValueIntValue ); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + handlers.mBoolReturn = true; + DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValueIntValue(5.0f, 10), true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam2, 10, TEST_LOCATION ); + } + signals.CheckNoConnections(); + + { + TestSlotDelegateHandler handlers; + signals.SignalInt2Value().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::IntSlotFloatValueIntValue ); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + handlers.mIntReturn = 27; + int x = signals.EmitIntSignalFloatValueIntValue(33.5f, 5); + DALI_TEST_EQUALS( x, 27, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 33.5f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam2, 5, TEST_LOCATION ); + } + signals.CheckNoConnections(); + + { + TestSlotDelegateHandler handlers; + signals.SignalFloat0().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotVoid ); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + handlers.mFloatReturn = 27.0f; + float f = signals.EmitFloat0Signal(); + DALI_TEST_EQUALS( f, 27.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION ); + } + signals.CheckNoConnections(); + + { + TestSlotDelegateHandler handlers; + signals.SignalFloat2Value().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotFloatValueFloatValue ); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + handlers.mFloatReturn = 27.0f; + float f = signals.EmitFloat2VSignal(5, 33.0f); + DALI_TEST_EQUALS( f, 27.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam2, 33.0f, 0.001f, TEST_LOCATION ); + } + signals.CheckNoConnections(); + + { + TestSlotDelegateHandler handlers; + signals.VoidSignalFloatValue3().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotFloatValue3 ); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + signals.EmitVoidSignalFloatValue3(5, 33.0f, 100.0f); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam2, 33.0f, 0.001f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam3, 100.0f, 0.001f, TEST_LOCATION ); + } + signals.CheckNoConnections(); + + { + TestSlotDelegateHandler handlers; + signals.FloatSignalFloatValue3().Connect( handlers.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotFloatValue3 ); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + handlers.mFloatReturn = 27.0f; + float returnValue = signals.EmitFloatSignalFloatValue3(5, 33.0f, 100.0f); + DALI_TEST_EQUALS( returnValue, 27.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mHandled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 5.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam2, 33.0f, 0.001f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam3, 100.0f, 0.001f, TEST_LOCATION ); + } + signals.CheckNoConnections(); + END_TEST; +} + +int UtcDaliSignalSlotDelegateDestruction(void) +{ + // Test that signal disconnect works when slot-delegate is destroyed (goes out of scope) + + { + TestSignals::VoidRetNoParamSignal signal; + { + DALI_TEST_CHECK( signal.Empty() ); + TestSlotDelegateHandler handler; + signal.Connect( handler.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotVoid ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + // End of slot lifetime + DALI_TEST_CHECK( signal.Empty() ); + + // Signal emission should be a NOOP + signal.Emit(); + } + + { + TestSignals::VoidRet1ValueParamSignal signal; + { + DALI_TEST_CHECK( signal.Empty() ); + TestSlotDelegateHandler handler; + signal.Connect( handler.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntValue ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + // End of slot lifetime + DALI_TEST_CHECK( signal.Empty() ); + + // Signal emission should be a NOOP + signal.Emit( 10 ); + } + + { + TestSignals::VoidRet1RefParamSignal signal; + { + DALI_TEST_CHECK( signal.Empty() ); + TestSlotDelegateHandler handler; + signal.Connect( handler.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntRef ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + // End of slot lifetime + DALI_TEST_CHECK( signal.Empty() ); + + // Signal emission should be a NOOP + int temp( 5 ); + signal.Emit( temp ); + } + + { + TestSignals::VoidRet2ValueParamSignal signal; + { + DALI_TEST_CHECK( signal.Empty() ); + TestSlotDelegateHandler handler; + signal.Connect( handler.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntValueIntValue ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + // End of slot lifetime + DALI_TEST_CHECK( signal.Empty() ); + + // Signal emission should be a NOOP + signal.Emit( 1, 2 ); + } + + { + TestSignals::BoolRet1ValueParamSignal signal; + { + DALI_TEST_CHECK( signal.Empty() ); + TestSlotDelegateHandler handler; + signal.Connect( handler.mSlotDelegate, &TestSlotDelegateHandler::BoolSlotFloatValue ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + // End of slot lifetime + DALI_TEST_CHECK( signal.Empty() ); + + // Signal emission should be a NOOP + bool blah = signal.Emit( 1.0f ); + DALI_TEST_CHECK( ! blah ); + } + + { + TestSignals::BoolRet2ValueParamSignal signal; + { + DALI_TEST_CHECK( signal.Empty() ); + TestSlotDelegateHandler handler; + signal.Connect( handler.mSlotDelegate, &TestSlotDelegateHandler::BoolSlotFloatValueIntValue ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + // End of slot lifetime + DALI_TEST_CHECK( signal.Empty() ); + + // Signal emission should be a NOOP + bool blah = signal.Emit( 1.0f, 2 ); + DALI_TEST_CHECK( ! blah ); + } + + { + TestSignals::IntRet2ValueParamSignal signal; + { + DALI_TEST_CHECK( signal.Empty() ); + TestSlotDelegateHandler handler; + signal.Connect( handler.mSlotDelegate, &TestSlotDelegateHandler::IntSlotFloatValueIntValue ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + // End of slot lifetime + DALI_TEST_CHECK( signal.Empty() ); + + // Signal emission should be a NOOP + int blah = signal.Emit( 10.0f, 100 ); + DALI_TEST_CHECK( 0 == blah ); + } + + { + TestSignals::FloatRet0ParamSignal signal; + { + DALI_TEST_CHECK( signal.Empty() ); + TestSlotDelegateHandler handler; + signal.Connect( handler.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotVoid ); + DALI_TEST_CHECK( ! signal.Empty() ); + } + // End of slot lifetime + DALI_TEST_CHECK( signal.Empty() ); + + // Signal emission should be a NOOP + float blah = signal.Emit(); + DALI_TEST_CHECK( 0.0f == blah ); + } + + { + TestSignals::FloatRet2ValueParamSignal signal; + { + DALI_TEST_CHECK( signal.Empty() ); + TestSlotDelegateHandler handler; + signal.Connect(handler.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotFloatValueFloatValue); + DALI_TEST_CHECK( ! signal.Empty() ); + } + // End of slot lifetime + DALI_TEST_CHECK( signal.Empty() ); + + // Signal emission should be a NOOP + float blah = signal.Emit( 3.0f, 4.0f ); + DALI_TEST_CHECK( 0.0f == blah ); + } + END_TEST; +} + +int UtcDaliSlotHandlerDisconnect(void) +{ + // Test that callbacks don't occur if a signal is disconnected before emission + + TestSignals signals; + + { + TestSlotDelegateHandler handlers; + signals.SignalVoidNone().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotVoid); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + signals.SignalVoidNone().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotVoid); + signals.EmitVoidSignalVoid(); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + } + + { + TestSlotDelegateHandler handlers; + signals.SignalVoid1Ref().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntRef); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + int r = 7; + handlers.mIntReturn = 5; + signals.SignalVoid1Ref().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntRef); + signals.EmitVoidSignalIntRef(r); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( r, 7, TEST_LOCATION ); + } + + { + TestSlotDelegateHandler handlers; + signals.SignalVoid1Value().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntValue); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + signals.SignalVoid1Value().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntValue); + signals.EmitVoidSignalIntValue(5); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION ); + } + + { + TestSlotDelegateHandler handlers; + signals.SignalVoid2Value().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntValueIntValue); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + signals.SignalVoid2Value().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::VoidSlotIntValueIntValue); + signals.EmitVoidSignalIntValueIntValue(5, 10); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam2, 0, TEST_LOCATION ); + } + + { + TestSlotDelegateHandler handlers; + signals.SignalBool1Value().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::BoolSlotFloatValue); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + handlers.mBoolReturn = true; + signals.SignalBool1Value().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::BoolSlotFloatValue); + DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValue(5.0f), false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, TEST_LOCATION ); + } + + { + TestSlotDelegateHandler handlers; + signals.SignalBool2Value().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::BoolSlotFloatValueIntValue); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + handlers.mBoolReturn = true; + signals.SignalBool2Value().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::BoolSlotFloatValueIntValue); + DALI_TEST_EQUALS( signals.EmitBoolSignalFloatValueIntValue(5.0f, 10), false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam2, 0, TEST_LOCATION ); + } + + { + TestSlotDelegateHandler handlers; + signals.SignalInt2Value().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::IntSlotFloatValueIntValue); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + handlers.mIntReturn = 27; + signals.SignalInt2Value().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::IntSlotFloatValueIntValue); + signals.EmitIntSignalFloatValueIntValue(5, 33.0f); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mIntParam1, 0, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION ); + } + + { + TestSlotDelegateHandler handlers; + signals.SignalFloat0().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotVoid); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + handlers.mFloatReturn = 27.0f; + signals.SignalFloat0().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotVoid); + signals.EmitFloat0Signal(); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, 0.001f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION ); + } + + { + TestSlotDelegateHandler handlers; + signals.SignalFloat2Value().Connect(handlers.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotFloatValueFloatValue); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + handlers.mFloatReturn = 27.0f; + signals.SignalFloat2Value().Disconnect(handlers.mSlotDelegate, &TestSlotDelegateHandler::FloatSlotFloatValueFloatValue); + signals.EmitFloat2VSignal(5, 33.0f); + DALI_TEST_EQUALS( handlers.mHandled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam1, 0.0f, 0.001f, TEST_LOCATION ); + DALI_TEST_EQUALS( handlers.mFloatParam2, 0.0f, 0.001f, TEST_LOCATION ); + } + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Stage.cpp b/automated-tests/src/dali/utc-Dali-Stage.cpp new file mode 100644 index 0000000..7a94312 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-Stage.cpp @@ -0,0 +1,596 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +#include + +using namespace Dali; +using namespace std; + +void stage_test_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void stage_test_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ + +/** + * Functor for EventProcessingFinished signal + */ +struct EventProcessingFinishedFunctor +{ + /** + * @param[in] eventProcessingFinished reference to a boolean variable used to check if signal has been called. + */ + EventProcessingFinishedFunctor( bool& eventProcessingFinished ) + : mEventProcessingFinished( eventProcessingFinished ) + {} + + void operator()() + { + mEventProcessingFinished = true; + } + + bool& mEventProcessingFinished; +}; + +// Stores data that is populated in the key-event callback and will be read by the TET cases +struct KeyEventSignalData +{ + KeyEventSignalData() + : functorCalled(false) + {} + + void Reset() + { + functorCalled = false; + + receivedKeyEvent.keyModifier = 0; + receivedKeyEvent.keyPressedName.clear(); + receivedKeyEvent.keyPressed.clear(); + } + + bool functorCalled; + KeyEvent receivedKeyEvent; +}; + +// Functor that sets the data when called +struct KeyEventReceivedFunctor +{ + KeyEventReceivedFunctor( KeyEventSignalData& data ) : signalData( data ) { } + + bool operator()( const KeyEvent& keyEvent ) + { + signalData.functorCalled = true; + signalData.receivedKeyEvent = keyEvent; + + return true; + } + + KeyEventSignalData& signalData; +}; + +// Stores data that is populated in the touched signal callback and will be read by the TET cases +struct TouchedSignalData +{ + TouchedSignalData() + : functorCalled(false) + {} + + void Reset() + { + functorCalled = false; + + receivedTouchEvent.points.clear(); + receivedTouchEvent.time = 0; + } + + bool functorCalled; + TouchEvent receivedTouchEvent; +}; + +// Functor that sets the data when touched signal is received +struct TouchedFunctor +{ + TouchedFunctor( TouchedSignalData& data ) : signalData( data ) { } + + void operator()( const TouchEvent& touch ) + { + signalData.functorCalled = true; + signalData.receivedTouchEvent = touch; + } + + TouchedSignalData& signalData; +}; + +bool DummyTouchCallback( Actor actor, const TouchEvent& touch ) +{ + return true; +} + +} // unnamed namespace + + +int UtcDaliStageDefaultConstructor(void) +{ + TestApplication application; + Stage stage; + + DALI_TEST_CHECK(!stage); + END_TEST; +} + +int UtcDaliStageDestructor(void) +{ + TestApplication application; + Stage* stage = new Stage(); + delete stage; + stage = NULL; + + DALI_TEST_CHECK( true ); + END_TEST; +} + +int UtcDaliStageGetCurrent(void) +{ + TestApplication application; + Stage stage = Stage::GetCurrent(); + + DALI_TEST_CHECK(stage); + END_TEST; +} + +int UtcDaliStageIsInstalled(void) +{ + DALI_TEST_CHECK(!Stage::IsInstalled()); + + TestApplication application; + + Stage::GetCurrent(); + + DALI_TEST_CHECK(Stage::IsInstalled()); + END_TEST; +} + +int UtcDaliStageAdd(void) +{ + TestApplication application; + + Stage stage = Stage::GetCurrent(); + + Actor actor = Actor::New(); + DALI_TEST_CHECK(!actor.OnStage()); + + stage.Add(actor); + DALI_TEST_CHECK(actor.OnStage()); + END_TEST; +} + +int UtcDaliStageRemove(void) +{ + TestApplication application; + + Stage stage = Stage::GetCurrent(); + + Actor actor = Actor::New(); + DALI_TEST_CHECK(!actor.OnStage()); + + stage.Add(actor); + DALI_TEST_CHECK(actor.OnStage()); + + stage.Remove(actor); + DALI_TEST_CHECK(!actor.OnStage()); + END_TEST; +} + +int UtcDaliStageGetSize(void) +{ + TestApplication application; + + Stage stage = Stage::GetCurrent(); + + Vector2 size = stage.GetSize(); + + DALI_TEST_EQUALS(size.width, static_cast(TestApplication::DEFAULT_SURFACE_WIDTH), TEST_LOCATION); + DALI_TEST_EQUALS(size.height, static_cast(TestApplication::DEFAULT_SURFACE_HEIGHT), TEST_LOCATION); + END_TEST; +} + +int UtcDaliStageGetDpi01(void) +{ + TestApplication application; // Initializes core DPI to default values + + Stage stage = Stage::GetCurrent(); + + // Test the default DPI. + Vector2 dpi = stage.GetDpi(); + DALI_TEST_EQUALS(dpi.x, static_cast(TestApplication::DEFAULT_HORIZONTAL_DPI), TEST_LOCATION); + DALI_TEST_EQUALS(dpi.y, static_cast(TestApplication::DEFAULT_VERTICAL_DPI), TEST_LOCATION); + END_TEST; +} + +int UtcDaliStageGetDpi02(void) +{ + TestApplication application; // Initializes core DPI to default values + + // Test that setting core DPI explicitly also sets up the Stage's DPI. + application.GetCore().SetDpi(200, 180); + + Stage stage = Stage::GetCurrent(); + Vector2 dpi = stage.GetDpi(); + DALI_TEST_EQUALS(dpi.x, 200.0f, TEST_LOCATION); + DALI_TEST_EQUALS(dpi.y, 180.0f, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliStageGetDpi03(void) +{ + TestApplication application(480, 800, 72.0f, 120.0f); // Initializes core DPI with specific values + + Stage stage = Stage::GetCurrent(); + + // Test that setting core DPI explicitly also sets up the Stage's DPI. + Vector2 dpi = stage.GetDpi(); + DALI_TEST_EQUALS(dpi.x, 72.0f, TEST_LOCATION); + DALI_TEST_EQUALS(dpi.y, 120.0f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliStageGetLayerCount(void) +{ + TestApplication application; + + Stage stage = Stage::GetCurrent(); + + // Initially we have a default layer + DALI_TEST_EQUALS(stage.GetLayerCount(), 1u, TEST_LOCATION); + + Layer layer = Layer::New(); + stage.Add(layer); + + DALI_TEST_EQUALS(stage.GetLayerCount(), 2u, TEST_LOCATION); + END_TEST; +} + +int UtcDaliStageGetLayer(void) +{ + TestApplication application; + + Stage stage = Stage::GetCurrent(); + + Layer rootLayer = stage.GetLayer(0); + DALI_TEST_CHECK(rootLayer); + + Layer layer = Layer::New(); + stage.Add(layer); + + Layer sameLayer = stage.GetLayer(1); + DALI_TEST_CHECK(layer == sameLayer); + END_TEST; +} + + +int UtcDaliStageGetRootLayer(void) +{ + TestApplication application; + + Stage stage = Stage::GetCurrent(); + + Layer rootLayer = stage.GetLayer(0); + DALI_TEST_CHECK( rootLayer ); + + Layer layer = Layer::New(); + stage.Add( layer ); + layer.LowerToBottom(); + + DALI_TEST_CHECK( stage.GetRootLayer() == rootLayer ); + END_TEST; +} + +int UtcDaliStageSetBackgroundColor(void) +{ + TestApplication application; + + Stage stage = Stage::GetCurrent(); + + Vector4 testColor(0.1f, 0.2f, 0.3f, 1.0f); + stage.SetBackgroundColor(testColor); + + DALI_TEST_EQUALS(testColor, stage.GetBackgroundColor(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliStageGetBackgroundColor(void) +{ + TestApplication application; + + Stage stage = Stage::GetCurrent(); + + DALI_TEST_EQUALS(Stage::DEFAULT_BACKGROUND_COLOR, stage.GetBackgroundColor(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliStageKeepRendering(void) +{ + TestApplication application; + + Stage stage = Stage::GetCurrent(); + + // Run core until it wants to sleep + bool keepUpdating( true ); + while ( keepUpdating ) + { + application.SendNotification(); + keepUpdating = application.Render(1000.0f /*1 second*/); + } + + // Force rendering for the next 5 seconds + stage.KeepRendering( 5.0f ); + + application.SendNotification(); + + // Test that core wants to sleep after 10 seconds + keepUpdating = application.Render(1000.0f /*1 second*/); + DALI_TEST_CHECK( keepUpdating ); + keepUpdating = application.Render(1000.0f /*2 seconds*/); + DALI_TEST_CHECK( keepUpdating ); + keepUpdating = application.Render(1000.0f /*3 seconds*/); + DALI_TEST_CHECK( keepUpdating ); + keepUpdating = application.Render(1000.0f /*4 seconds*/); + DALI_TEST_CHECK( keepUpdating ); + keepUpdating = application.Render(1000.0f /*5 seconds*/); + DALI_TEST_CHECK( !keepUpdating ); + END_TEST; +} + +int UtcDaliStageEventProcessingFinished(void) +{ + TestApplication application; + Stage stage = Stage::GetCurrent(); + + bool eventProcessingFinished = false; + EventProcessingFinishedFunctor functor( eventProcessingFinished ); + stage.EventProcessingFinishedSignal().Connect( &application, functor ); + + Actor actor( Actor::New() ); + stage.Add( actor ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( eventProcessingFinished ); + + END_TEST; +} + +int UtcDaliStageSignalKeyEvent(void) +{ + TestApplication application; + Stage stage = Stage::GetCurrent(); + + KeyEventSignalData data; + KeyEventReceivedFunctor functor( data ); + stage.KeyEventSignal().Connect( &application, functor ); + + Integration::KeyEvent event( "i","i", 0, 0, 0, Integration::KeyEvent::Down ); + application.ProcessEvent( event ); + + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_CHECK( event.keyModifier == data.receivedKeyEvent.keyModifier ); + DALI_TEST_CHECK( event.keyName == data.receivedKeyEvent.keyPressedName ); + DALI_TEST_CHECK( event.keyString == data.receivedKeyEvent.keyPressed ); + DALI_TEST_CHECK( event.state == static_cast(data.receivedKeyEvent.state) ); + + data.Reset(); + + Integration::KeyEvent event2( "i","i", 0, 0, 0, Integration::KeyEvent::Up ); + application.ProcessEvent( event2 ); + + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_CHECK( event2.keyModifier == data.receivedKeyEvent.keyModifier ); + DALI_TEST_CHECK( event2.keyName == data.receivedKeyEvent.keyPressedName ); + DALI_TEST_CHECK( event2.keyString == data.receivedKeyEvent.keyPressed ); + DALI_TEST_CHECK( event2.state == static_cast(data.receivedKeyEvent.state) ); + + data.Reset(); + + Integration::KeyEvent event3( "a","a", 0, 0, 0, Integration::KeyEvent::Down ); + application.ProcessEvent( event3 ); + + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_CHECK( event3.keyModifier == data.receivedKeyEvent.keyModifier ); + DALI_TEST_CHECK( event3.keyName == data.receivedKeyEvent.keyPressedName ); + DALI_TEST_CHECK( event3.keyString == data.receivedKeyEvent.keyPressed ); + DALI_TEST_CHECK( event3.state == static_cast(data.receivedKeyEvent.state) ); + + data.Reset(); + + Integration::KeyEvent event4( "a","a", 0, 0, 0, Integration::KeyEvent::Up ); + application.ProcessEvent( event4 ); + + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_CHECK( event4.keyModifier == data.receivedKeyEvent.keyModifier ); + DALI_TEST_CHECK( event4.keyName == data.receivedKeyEvent.keyPressedName ); + DALI_TEST_CHECK( event4.keyString == data.receivedKeyEvent.keyPressed ); + DALI_TEST_CHECK( event4.state == static_cast(data.receivedKeyEvent.state) ); + END_TEST; +} + +int UtcDaliStageTouchedSignal(void) +{ + TestApplication application; + Stage stage = Stage::GetCurrent(); + + TouchedSignalData data; + TouchedFunctor functor( data ); + stage.TouchedSignal().Connect( &application, functor ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // NO ACTORS, SINGLE TOUCH, DOWN, MOTION THEN UP + { + Integration::TouchEvent touchEvent; + touchEvent.points.push_back( TouchPoint( 0, TouchPoint::Down, 10.0f, 10.0f ) ); + application.ProcessEvent( touchEvent ); + + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0 ); + DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor ); + data.Reset(); + + touchEvent.points[0].state = TouchPoint::Motion; + touchEvent.points[0].screen.x = 12.0f; // Some motion + application.ProcessEvent( touchEvent ); + + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + data.Reset(); + + touchEvent.points[0].state = TouchPoint::Up; + application.ProcessEvent( touchEvent ); + + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0 ); + DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor ); + data.Reset(); + } + + // Add an actor to the scene + + Actor actor = Actor::New(); + actor.SetSize( 100.0f, 100.0f ); + actor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + actor.SetParentOrigin( ParentOrigin::TOP_LEFT ); + actor.TouchedSignal().Connect( &DummyTouchCallback ); + stage.Add( actor ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // ACTOR ON SCENE, SINGLE TOUCH, DOWN IN ACTOR, MOTION THEN UP OUTSIDE ACTOR + { + Integration::TouchEvent touchEvent; + touchEvent.points.push_back( TouchPoint( 0, TouchPoint::Down, 10.0f, 10.0f ) ); + application.ProcessEvent( touchEvent ); + + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0 ); + DALI_TEST_CHECK( data.receivedTouchEvent.points[0].hitActor == actor ); + data.Reset(); + + touchEvent.points[0].state = TouchPoint::Motion; + touchEvent.points[0].screen.x = 150.0f; // Some motion + application.ProcessEvent( touchEvent ); + + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + data.Reset(); + + touchEvent.points[0].state = TouchPoint::Up; + application.ProcessEvent( touchEvent ); + + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0 ); + DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor ); + data.Reset(); + } + + // INTERRUPTED BEFORE DOWN AND INTERRUPTED AFTER DOWN + { + Integration::TouchEvent touchEvent; + touchEvent.points.push_back( TouchPoint( 0, TouchPoint::Interrupted, 10.0f, 10.0f ) ); + application.ProcessEvent( touchEvent ); + + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0 ); + DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor ); + DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Interrupted ); + data.Reset(); + + touchEvent.points[0].state = TouchPoint::Down; + application.ProcessEvent( touchEvent ); + + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0 ); + DALI_TEST_CHECK( data.receivedTouchEvent.points[0].hitActor == actor ); + DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Down ); + data.Reset(); + + touchEvent.points[0].state = TouchPoint::Interrupted; + application.ProcessEvent( touchEvent ); + + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_CHECK( data.receivedTouchEvent.GetPointCount() != 0 ); + DALI_TEST_CHECK( !data.receivedTouchEvent.points[0].hitActor ); + DALI_TEST_CHECK( data.receivedTouchEvent.points[0].state == TouchPoint::Interrupted ); + data.Reset(); + } + + // MULTIPLE TOUCH, SHOULD ONLY RECEIVE TOUCH ON FIRST DOWN AND LAST UP + { + Integration::TouchEvent touchEvent; + + // 1st point + touchEvent.points.push_back( TouchPoint( 0, TouchPoint::Down, 10.0f, 10.0f ) ); + application.ProcessEvent( touchEvent ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + data.Reset(); + + // 2nd point + touchEvent.points[0].state = TouchPoint::Stationary; + touchEvent.points.push_back( TouchPoint( 1, TouchPoint::Down, 50.0f, 50.0f ) ); + application.ProcessEvent( touchEvent ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + data.Reset(); + + // Primary point is up + touchEvent.points[0].state = TouchPoint::Up; + touchEvent.points[1].state = TouchPoint::Stationary; + application.ProcessEvent( touchEvent ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + data.Reset(); + + // Remove 1st point now, 2nd point is now in motion + touchEvent.points.erase( touchEvent.points.begin() ); + touchEvent.points[0].state = TouchPoint::Motion; + touchEvent.points[0].screen.x = 150.0f; + application.ProcessEvent( touchEvent ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + data.Reset(); + + // Final point Up + touchEvent.points[0].state = TouchPoint::Up; + application.ProcessEvent( touchEvent ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + data.Reset(); + } + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-TapGesture.cpp b/automated-tests/src/dali/utc-Dali-TapGesture.cpp new file mode 100644 index 0000000..60fa435 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-TapGesture.cpp @@ -0,0 +1,74 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +using namespace Dali; + +void utc_dali_tap_gesture_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_tap_gesture_cleanup(void) +{ + test_return_value = TET_PASS; +} + + +// Positive test case for a method +int UtcDaliTapGestureConstructor(void) +{ + TestApplication application; // Reset all test adapter return codes + + TapGesture gesture; + DALI_TEST_EQUALS(1u, gesture.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS(1u, gesture.numberOfTaps, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Tap, gesture.type, TEST_LOCATION); + + // Test Copy constructor + gesture.numberOfTouches = 5u; + gesture.numberOfTaps = 2u; + + TapGesture gesture2(gesture); + DALI_TEST_EQUALS(5u, gesture2.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS(2u, gesture2.numberOfTaps, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Tap, gesture2.type, TEST_LOCATION); + END_TEST; +} + +int UtcDaliTapGestureAssignment(void) +{ + // Test Assignment operator + TapGesture gesture; + DALI_TEST_EQUALS(1u, gesture.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS(1u, gesture.numberOfTaps, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Tap, gesture.type, TEST_LOCATION); + + gesture.numberOfTouches = 5u; + gesture.numberOfTaps = 2u; + + TapGesture gesture2; + gesture2 = gesture; + DALI_TEST_EQUALS(5u, gesture2.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS(2u, gesture2.numberOfTaps, TEST_LOCATION); + DALI_TEST_EQUALS(Gesture::Tap, gesture2.type, TEST_LOCATION); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp new file mode 100644 index 0000000..e26588e --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp @@ -0,0 +1,1172 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 +#include +#include + +using namespace Dali; + +void utc_dali_tap_gesture_detector_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_tap_gesture_detector_cleanup(void) +{ + test_return_value = TET_PASS; +} + +/////////////////////////////////////////////////////////////////////////////// +namespace +{ + +// Stores data that is populated in the callback and will be read by the TET cases +struct SignalData +{ + SignalData() + : functorCalled(false), + voidFunctorCalled(false) + {} + + void Reset() + { + functorCalled = false; + voidFunctorCalled = false; + + receivedGesture.numberOfTaps = 0u; + receivedGesture.numberOfTouches = 0u; + receivedGesture.screenPoint = Vector2(0.0f, 0.0f); + receivedGesture.localPoint = Vector2(0.0f, 0.0f); + + tappedActor = NULL; + } + + bool functorCalled; + bool voidFunctorCalled; + TapGesture receivedGesture; + Actor tappedActor; +}; + +// Functor that sets the data when called +struct GestureReceivedFunctor +{ + GestureReceivedFunctor(SignalData& data) : signalData(data) { } + + void operator()(Actor actor, TapGesture tap) + { + signalData.functorCalled = true; + signalData.receivedGesture = tap; + signalData.tappedActor = actor; + } + + void operator()() + { + signalData.voidFunctorCalled = true; + } + + SignalData& signalData; +}; + +// Functor that removes the gestured actor from stage +struct UnstageActorFunctor : public GestureReceivedFunctor +{ + UnstageActorFunctor( SignalData& data ) : GestureReceivedFunctor( data ) { } + + void operator()(Actor actor, TapGesture tap) + { + GestureReceivedFunctor::operator()( actor, tap ); + Stage::GetCurrent().Remove( actor ); + } +}; + +// Functor for receiving a touch event +struct TouchEventFunctor +{ + bool operator()(Actor actor, const TouchEvent& touch) + { + //For line coverage + unsigned int points = touch.GetPointCount(); + if( points > 0) + { + const TouchPoint& touchPoint = touch.GetPoint(0); + tet_printf("Touch Point state = %d\n", touchPoint.state); + } + return false; + } +}; + +// Generate a TapGestureEvent to send to Core +Integration::TapGestureEvent GenerateTap( + Gesture::State state, + unsigned int numberOfTaps, + unsigned int numberOfTouches, + Vector2 point) +{ + Integration::TapGestureEvent tap( state ); + + tap.numberOfTaps = numberOfTaps; + tap.numberOfTouches = numberOfTouches; + tap.point = point; + + return tap; +} + +} // anon namespace + +/////////////////////////////////////////////////////////////////////////////// + + +// Positive test case for a method +int UtcDaliTapGestureDetectorConstructor(void) +{ + TestApplication application; + + TapGestureDetector detector; + DALI_TEST_CHECK(!detector); + END_TEST; +} + + +int UtcDaliTapGestureDetectorNew(void) +{ + TestApplication application; + + TapGestureDetector detector = TapGestureDetector::New(); + DALI_TEST_CHECK(detector); + DALI_TEST_EQUALS(1u, detector.GetTapsRequired(), TEST_LOCATION); + DALI_TEST_EQUALS(1u, detector.GetTouchesRequired(), TEST_LOCATION); + + TapGestureDetector detector2 = TapGestureDetector::New(5u, 5u); + DALI_TEST_CHECK(detector2); + DALI_TEST_EQUALS(5u, detector2.GetTapsRequired(), TEST_LOCATION); + DALI_TEST_EQUALS(5u, detector2.GetTouchesRequired(), TEST_LOCATION); + + //Scoped test to test destructor + { + TapGestureDetector detector3 = TapGestureDetector::New(); + DALI_TEST_CHECK(detector3); + } + + // Attach an actor and emit a touch event on the actor to ensure complete line coverage + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + detector.Attach(actor); + + TouchEventFunctor touchFunctor; + actor.TouchedSignal().Connect( &application, touchFunctor ); + + Integration::TouchEvent touchEvent(1); + TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f); + touchEvent.AddPoint(point); + application.ProcessEvent(touchEvent); + + // Render and notify + application.SendNotification(); + application.Render(); + + // For line coverage, Initialise default constructor + TouchEvent touchEvent2; + END_TEST; +} + +int UtcDaliTapGestureDetectorDownCast(void) +{ + TestApplication application; + tet_infoline("Testing Dali::TapGestureDetector::DownCast()"); + + TapGestureDetector detector = TapGestureDetector::New(); + + BaseHandle object(detector); + + TapGestureDetector detector2 = TapGestureDetector::DownCast(object); + DALI_TEST_CHECK(detector2); + + TapGestureDetector detector3 = DownCast< TapGestureDetector >(object); + DALI_TEST_CHECK(detector3); + + BaseHandle unInitializedObject; + TapGestureDetector detector4 = TapGestureDetector::DownCast(unInitializedObject); + DALI_TEST_CHECK(!detector4); + + TapGestureDetector detector5 = DownCast< TapGestureDetector >(unInitializedObject); + DALI_TEST_CHECK(!detector5); + + GestureDetector detector6 = TapGestureDetector::New(); + TapGestureDetector detector7 = TapGestureDetector::DownCast(detector6); + DALI_TEST_CHECK(detector7); + END_TEST; +} + +int UtcDaliTapGestureSetTapsRequired(void) +{ + TestApplication application; + + TapGestureDetector detector = TapGestureDetector::New(); + + unsigned int taps = 3; + + DALI_TEST_CHECK(taps != detector.GetTapsRequired()); + + detector.SetTapsRequired(taps); + + DALI_TEST_EQUALS(taps, detector.GetTapsRequired(), TEST_LOCATION); + + // Attach an actor and change the required touches + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + TestGestureManager& gestureManager = application.GetGestureManager(); + gestureManager.Initialize(); + + detector.SetTapsRequired(4); + + // Gesture detection should have been updated only + DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION); + + // Reset values + gestureManager.Initialize(); + + // Create a second gesture detector that requires even less maximum touches + TapGestureDetector secondDetector = TapGestureDetector::New(); + secondDetector.Attach(actor); + + // Gesture detection should have been updated + DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION); + END_TEST; +} + +int UtcDaliTapGestureGetTapsRequired(void) +{ + TestApplication application; + + TapGestureDetector detector = TapGestureDetector::New(); + DALI_TEST_EQUALS(1u, detector.GetTapsRequired(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliTapGestureSetTouchesRequired(void) +{ + TestApplication application; + + TapGestureDetector detector = TapGestureDetector::New(); + + unsigned int max = 3; + + DALI_TEST_CHECK(max != detector.GetTouchesRequired()); + + detector.SetTouchesRequired(max); + + DALI_TEST_EQUALS(max, detector.GetTouchesRequired(), TEST_LOCATION); + + // Attach an actor and change the maximum touches + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + TestGestureManager& gestureManager = application.GetGestureManager(); + gestureManager.Initialize(); + + detector.SetTouchesRequired(4); + + // Gesture detection should have been updated only + DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION); + + // Reset values + gestureManager.Initialize(); + + // Create a second gesture detector that requires even less maximum touches + TapGestureDetector secondDetector = TapGestureDetector::New(); + secondDetector.Attach(actor); + + // Gesture detection should have been updated + DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION); + END_TEST; +} + +int UtcDaliTapGestureGetTouchesRequired(void) +{ + TestApplication application; + + TapGestureDetector detector = TapGestureDetector::New(); + DALI_TEST_EQUALS(1u, detector.GetTouchesRequired(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliTapGestureSignalReceptionNegative(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + TapGestureDetector detector = TapGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + // Do a tap outside actor's area + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(112.0f, 112.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(112.0f, 112.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliTapGestureSignalReceptionPositive(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + TapGestureDetector detector = TapGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + // Do a tap inside actor's area + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION); + END_TEST; +} + +int UtcDaliTapGestureSignalReceptionDetach(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + TapGestureDetector detector = TapGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Start tap within the actor's area + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 20.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 20.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS( Vector2(20.0f, 20.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION); + + // repeat the tap within the actor's area - we should still receive the signal + data.Reset(); + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION); + + // Detach actor + detector.DetachAll(); + + // Ensure we are no longer signalled + data.Reset(); + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 20.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 20.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliTapGestureSignalReceptionActorDestroyedWhileTapping(void) +{ + TestApplication application; + + SignalData data; + GestureReceivedFunctor functor(data); + + TapGestureDetector detector = TapGestureDetector::New(); + detector.DetectedSignal().Connect(&application, functor); + + // Actor lifetime is scoped + { + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + detector.Attach(actor); + + // Start tap within the actor's area + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 20.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 20.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + + // Remove the actor from stage and reset the data + Stage::GetCurrent().Remove(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + } + + // Actor should now have been destroyed + + data.Reset(); + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 20.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 20.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliTapGestureSignalReceptionRotatedActor(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetRotation(Dali::Degree(90.0f), Vector3::ZAXIS); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + TapGestureDetector detector = TapGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Do tap, only check finished value + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(5.0f, 5.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(5.0f, 5.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION); + + // Rotate actor again and render + actor.SetRotation(Dali::Degree(180.0f), Vector3::ZAXIS); + application.SendNotification(); + application.Render(); + + // Do tap, should still receive event + data.Reset(); + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(5.0f, 5.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(5.0f, 5.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTaps, TEST_LOCATION); + DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION); + DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION); + + // Rotate actor again and render + actor.SetRotation(Dali::Degree(90.0f), Vector3::YAXIS); + application.SendNotification(); + application.Render(); + + // Do tap, inside the actor's area (area if it is not rotated), Should not receive the event + data.Reset(); + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(70.0f, 70.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(70.0f, 70.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliTapGestureSignalReceptionChildHit(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + parent.SetSize(100.0f, 100.0f); + parent.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(parent); + + // Set child to completely cover parent. + // Change rotation of child to be different from parent so that we can check if our local coordinate + // conversion of the parent actor is correct. + Actor child = Actor::New(); + child.SetSize(100.0f, 100.0f); + child.SetAnchorPoint(AnchorPoint::CENTER); + child.SetParentOrigin(ParentOrigin::CENTER); + child.SetRotation(Dali::Degree(90.0f), Vector3::ZAXIS); + parent.Add(child); + + TouchEventFunctor touchFunctor; + child.TouchedSignal().Connect(&application, touchFunctor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + TapGestureDetector detector = TapGestureDetector::New(); + detector.Attach(parent); + detector.DetectedSignal().Connect(&application, functor); + + // Do tap - hits child area but parent should still receive it + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, parent == data.tappedActor, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(50.0f, 50.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION); + + // Attach child and generate same touch points + // (Also proves that you can detach and then re-attach another actor) + detector.Attach(child); + detector.Detach(parent); + + // Do an entire tap, only check finished value + data.Reset(); + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(51.0f, 51.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(51.0f, 51.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, child == data.tappedActor, TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(51.0f, 51.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliTapGestureSignalReceptionAttachDetachMany(void) +{ + TestApplication application; + + Actor first = Actor::New(); + first.SetSize(100.0f, 100.0f); + first.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(first); + + Actor second = Actor::New(); + second.SetSize(100.0f, 100.0f); + second.SetX(100.0f); + second.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(second); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + TapGestureDetector detector = TapGestureDetector::New(); + detector.Attach(first); + detector.Attach(second); + detector.DetectedSignal().Connect(&application, functor); + + // Tap within second actor's area + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(120.0f, 10.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(120.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, second == data.tappedActor, TEST_LOCATION); + + // Tap within first actor's area + data.Reset(); + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 10.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, first == data.tappedActor, TEST_LOCATION); + + // Detach the second actor + detector.Detach(second); + + // second actor shouldn't receive event + data.Reset(); + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(120.0f, 10.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(120.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // first actor should continue receiving event + data.Reset(); + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(20.0f, 10.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(20.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliTapGestureSignalReceptionActorBecomesUntouchable(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + TapGestureDetector detector = TapGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Tap in actor's area + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + + // Actor become invisible - actor should not receive the next pan + actor.SetVisible(false); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Tap in the same area, shouldn't receive event + data.Reset(); + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliTapGestureSignalReceptionMultipleGestureDetectors(void) +{ + TestApplication application; + Dali::TestGestureManager& gestureManager = application.GetGestureManager(); + + Actor first = Actor::New(); + first.SetSize(100.0f, 100.0f); + first.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(first); + + Actor second = Actor::New(); + second.SetSize(100.0f, 100.0f); + second.SetAnchorPoint(AnchorPoint::TOP_LEFT); + second.SetX(100.0f); + first.Add(second); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + TapGestureDetector firstDetector = TapGestureDetector::New(); + firstDetector.Attach(first); + firstDetector.DetectedSignal().Connect(&application, functor); + + // secondDetector is scoped + { + // Reset gestureManager statistics + gestureManager.Initialize(); + + TapGestureDetector secondDetector = TapGestureDetector::New(); + secondDetector.SetTapsRequired(2); + secondDetector.SetTouchesRequired(2); + secondDetector.Attach(second); + secondDetector.DetectedSignal().Connect(&application, functor); + + DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION); + + // Tap within second actor's area + application.ProcessEvent(GenerateTap(Gesture::Possible, 2u, 2u, Vector2(150.0f, 10.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 2u, 2u, Vector2(150.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, second == data.tappedActor, TEST_LOCATION); + + // Tap continues as single touch gesture - we should not receive any gesture + data.Reset(); + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(150.0f, 10.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(150.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Single touch tap starts - first actor should be panned + data.Reset(); + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, first == data.tappedActor, TEST_LOCATION); + + // Pan changes to double-touch - we shouldn't receive event + data.Reset(); + application.ProcessEvent(GenerateTap(Gesture::Possible, 2u, 2u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 2u, 2u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Reset gesture manager statistics + gestureManager.Initialize(); + } + + // secondDetector has now been deleted. Gesture detection should have been updated only + DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION); + DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION); + END_TEST; +} + +int UtcDaliTapGestureSignalReceptionMultipleDetectorsOnActor(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Attach actor to one detector + SignalData firstData; + GestureReceivedFunctor firstFunctor(firstData); + TapGestureDetector firstDetector = TapGestureDetector::New(); + firstDetector.Attach(actor); + firstDetector.DetectedSignal().Connect(&application, firstFunctor); + + // Attach actor to another detector + SignalData secondData; + GestureReceivedFunctor secondFunctor(secondData); + TapGestureDetector secondDetector = TapGestureDetector::New(); + secondDetector.Attach(actor); + secondDetector.DetectedSignal().Connect(&application, secondFunctor); + + // Tap in actor's area - both detector's functors should be called + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliTapGestureSignalReceptionDifferentPossible(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Attach actor to detector + SignalData data; + GestureReceivedFunctor functor( data ); + TapGestureDetector detector = TapGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + // Gesture possible in actor's area. + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Move actor somewhere else + actor.SetPosition( 100.0f, 100.0f ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Emit Started event, we should not receive the long press. + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // LongPress possible in empty area. + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Move actor in to the long press position. + actor.SetPosition( 0.0f, 0.0f ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Emit Started event, we should not receive the long press. + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Normal long press in actor's area for completeness. + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliTapGestureEmitIncorrectStateClear(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Attach actor to detector + SignalData data; + GestureReceivedFunctor functor( data ); + TapGestureDetector detector = TapGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + // Try a Clear state + try + { + application.ProcessEvent(GenerateTap(Gesture::Clear, 1u, 1u, Vector2(50.0f, 10.0f))); + tet_result(TET_FAIL); + } + catch ( Dali::DaliException& e ) + { + DALI_TEST_ASSERT( e, "false", TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliTapGestureEmitIncorrectStateContinuing(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Attach actor to detector + SignalData data; + GestureReceivedFunctor functor( data ); + TapGestureDetector detector = TapGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + // Try a Continuing state + try + { + application.ProcessEvent(GenerateTap(Gesture::Continuing, 1u, 1u, Vector2(50.0f, 10.0f))); + tet_result(TET_FAIL); + } + catch ( Dali::DaliException& e ) + { + DALI_TEST_ASSERT( e, "false", TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliTapGestureEmitIncorrectStateFinished(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Attach actor to detector + SignalData data; + GestureReceivedFunctor functor( data ); + TapGestureDetector detector = TapGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + // Try a Finished state + try + { + application.ProcessEvent(GenerateTap(Gesture::Finished, 1u, 1u, Vector2(50.0f, 10.0f))); + tet_result(TET_FAIL); + } + catch ( Dali::DaliException& e ) + { + DALI_TEST_ASSERT( e, "false", TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliTapGestureActorUnstaged(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Attach actor to detector + SignalData data; + UnstageActorFunctor functor( data ); + TapGestureDetector detector = TapGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + // Tap in Actor's area, actor removed in signal handler, should be handled gracefully. + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + tet_result( TET_PASS ); // If we get here, then the actor removal on signal handler was handled gracefully. + END_TEST; +} + +int UtcDaliTapGestureRepeatedState(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Attach actor to detector + SignalData data; + GestureReceivedFunctor functor( data ); + TapGestureDetector detector = TapGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + // Emit two possibles + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Send a couple of Started states, only first one should be received. + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + // Send a couple of cancelled states, no reception + application.ProcessEvent(GenerateTap(Gesture::Cancelled, 1u, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateTap(Gesture::Cancelled, 1u, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliTapGesturePossibleCancelled(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Attach actor to detector + SignalData data; + GestureReceivedFunctor functor( data ); + TapGestureDetector detector = TapGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + // Emit a possible and then a cancelled, no reception + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f))); + application.ProcessEvent(GenerateTap(Gesture::Cancelled, 1u, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliTapGestureDetectorRemovedWhilePossible(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Attach actor to detector + SignalData data; + GestureReceivedFunctor functor( data ); + TapGestureDetector detector = TapGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + // Emit a possible + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f))); + + // Detach actor and send a Started state, no signal. + detector.DetachAll(); + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliTapGestureActorRemovedWhilePossible(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Attach actor to detector + SignalData data; + GestureReceivedFunctor functor( data ); + TapGestureDetector detector = TapGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect( &application, functor ); + + // Emit a possible + application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f))); + + // Remove, render and delete actor + Stage::GetCurrent().Remove(actor); + application.SendNotification(); + application.Render(); + actor = NULL; + + // Send a Started state, no signal. + application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f))); + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + END_TEST; +} + +int UtcDaliTapGestureSystemOverlay(void) +{ + TestApplication application; + Dali::Integration::Core& core = application.GetCore(); + Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() ); + systemOverlay.GetOverlayRenderTasks().CreateTask(); + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + systemOverlay.Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + TapGestureDetector detector = TapGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + Vector2 screenCoords( 50.0f, 50.0f ); + + // Do a tap inside actor's area + application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, screenCoords ) ); + application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, screenCoords ) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Text.cpp b/automated-tests/src/dali/utc-Dali-Text.cpp new file mode 100644 index 0000000..df26717 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-Text.cpp @@ -0,0 +1,305 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +using namespace Dali; + +void utc_dali_text_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_text_cleanup(void) +{ + test_return_value = TET_PASS; +} + +int UtcDaliTextConstructor(void) +{ + TestApplication application; + + Text text; + + DALI_TEST_CHECK( text.IsEmpty() ); + + Text someText( std::string( "Some text" ) ); + + DALI_TEST_CHECK( !someText.IsEmpty() ); + + Character c = someText[0]; + + Text cText( c ); + + DALI_TEST_CHECK( !cText.IsEmpty() ); + END_TEST; +} + +int UtcDaliTextCopyConstructor(void) +{ + TestApplication application; + + Text someText1( std::string( "Some text1" ) ); + Text someText2( std::string( "Some text2" ) ); + + Text someText3( someText1 ); + Text someText4 = someText2; + + DALI_TEST_CHECK( (someText1.GetText()==someText3.GetText()) && (someText2.GetText()==someText4.GetText()) ); + END_TEST; +} + +int UtcDaliTextAssignmentOperator(void) +{ + TestApplication application; + + // check for assignment when current is NULL + + Text someText1( std::string( "Some text1" ) ); + Text someText2; + someText2 = someText1; + + DALI_TEST_CHECK( (someText1.GetText()==someText2.GetText()) ); + + // check for assignment when current object already has text + Text someText3( std::string( "Some text3" ) ); + someText2 = someText3; + DALI_TEST_CHECK( (someText3.GetText()==someText2.GetText()) ); + + Text someText4; + + printf(" is text empty ? ...... %d \n", someText4.IsEmpty()); + // check for assignment of empty text + someText2 = someText4; + DALI_TEST_CHECK( someText2.IsEmpty() ); + + // check for self assignment + someText3 = someText3; + DALI_TEST_CHECK( ! someText3.IsEmpty() ); + + + END_TEST; +} + +int UtcDaliTextSetGetText(void) +{ + TestApplication application; + + const std::string someText( "Some text"); + + Text text; + text.SetText( someText ); + + DALI_TEST_CHECK( someText == text.GetText() ); + + Character c = text[0]; + text.SetText( c ); + + DALI_TEST_CHECK( std::string("S") == text.GetText() ); + + Text text2; + text2.SetText( text ); + + DALI_TEST_CHECK( text2.GetText() == text.GetText() ); + END_TEST; +} + +int UtcDaliTextAccessOperator01(void) +{ + TestApplication application; + + std::string someText; + + Text text; + text.SetText( someText ); + + bool assert1 = false; + bool assert2 = false; + try + { + Character c = text[0]; + } + catch( DaliException& e ) + { + tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); + DALI_TEST_EQUALS( e.mCondition, "NULL != mImpl && \"Text::operator[]: Text is uninitialized\"", TEST_LOCATION ); + + assert1 = true; + } + + someText = std::string( "some text" ); + text.SetText( someText ); + + try + { + Character c = text[100]; + } + catch( DaliException& e ) + { + tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); + DALI_TEST_EQUALS( e.mCondition, "position < mString.size() && \"Text::operator[]: Character position is out of bounds\"", TEST_LOCATION ); + + assert2 = true; + } + + if( assert1 && assert2 ) + { + tet_result( TET_PASS ); + } + else + { + tet_result( TET_FAIL ); + } + END_TEST; +} + +int UtcDaliTextAccessOperator02(void) +{ + TestApplication application; + + const std::string someText( "Some text"); + + Text text; + text.SetText( someText ); + + DALI_TEST_CHECK( someText == text.GetText() ); + + Character c = text[0]; + text.SetText( c ); + + DALI_TEST_CHECK( std::string("S") == text.GetText() ); + END_TEST; +} + +int UtcDaliTextIsEmpty(void) +{ + TestApplication application; + + Text text; + + DALI_TEST_CHECK( text.IsEmpty() ); + + text.SetText( std::string( "Some text") ); + + DALI_TEST_CHECK( !text.IsEmpty() ); + END_TEST; +} + +int UtcDaliTextGetLength(void) +{ + TestApplication application; + + const std::string someText( "Some text"); + + Text text( someText ); + + DALI_TEST_CHECK( someText.size() == text.GetLength() ); + END_TEST; +} + +int UtcDaliTextAppend(void) +{ + TestApplication application; + + Text text( std::string( "Some text") ); + + text.Append( std::string( "A" ) ); + + DALI_TEST_CHECK( std::string( "Some textA" ) == text.GetText() ); + + Character c = text[0]; + text.Append( c ); + + DALI_TEST_CHECK( std::string( "Some textAS" ) == text.GetText() ); + + Text text2( std::string("B") ); + text.Append( text2 ); + + DALI_TEST_CHECK( std::string( "Some textASB" ) == text.GetText() ); + + // append to a null text + + Text emptyText; + emptyText.Append( text2 ); + DALI_TEST_CHECK( text2.GetText() == emptyText.GetText() ); + + END_TEST; +} + +int UtcDaliTextRemove01(void) +{ + TestApplication application; + + Text text( std::string( "Some text") ); + + bool assert1 = false; + bool assert2 = false; + try + { + text.Remove( 100, 3 ); + } + catch( DaliException& e ) + { + tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); + DALI_TEST_EQUALS( e.mCondition, "position < mString.size() && \"Text::Remove: Character position is out of bounds\"", TEST_LOCATION ); + assert1 = true; + } + + try + { + text.Remove( 1, 300 ); + } + catch( DaliException& e ) + { + tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); + DALI_TEST_EQUALS( e.mCondition, "position + numberOfCharacters <= mString.size() && \"Text::Remove: Character position + numberOfCharacters is out of bounds\"", TEST_LOCATION ); + assert2 = true; + } + + if( assert1 && assert2 ) + { + tet_result( TET_PASS ); + } + else + { + tet_result( TET_FAIL ); + } + END_TEST; +} + +int UtcDaliTextRemove02(void) +{ + TestApplication application; + + Text text01( std::string( "Some text") ); + Text text02( std::string( "Somext") ); + Text text03( std::string( "") ); + + text01.Remove( 3, 3 ); + + DALI_TEST_EQUALS( text01.GetLength(), text02.GetLength(), TEST_LOCATION ); + DALI_TEST_EQUALS( text01.GetText(), text02.GetText(), TEST_LOCATION ); + + text01.Remove( 0, 6 ); + + DALI_TEST_EQUALS( text01.GetLength(), text03.GetLength(), TEST_LOCATION ); + DALI_TEST_EQUALS( text01.GetText(), text03.GetText(), TEST_LOCATION ); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-TextActor.cpp b/automated-tests/src/dali/utc-Dali-TextActor.cpp new file mode 100644 index 0000000..fc7d1a6 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-TextActor.cpp @@ -0,0 +1,822 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +using namespace Dali; + +void text_actor_test_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void text_actor_test_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ +static const char* TestTextHello = "Hello"; +static const char* TestTextHelloWorld = "Hello World"; +static const char* LongTestText = "This is a very long piece of text, and is sure not to fit into any box presented to it"; + +const std::string FAMILY_NAME = "Arial"; +const std::string STYLE = "Bold"; +const unsigned int POINT_SIZE = 11.f; +static const Vector4 FONT_TEXT_COLOR = Color::RED; +static const Degree FONT_ITALICS_ANGLE(10.f); +static const Radian FONT_ITALICS_RADIAN_ANGLE(0.4f); +static const bool FONT_ITALICS = true; +static const bool FONT_UNDERLINE = true; +static const bool FONT_SHADOW = true; +static const bool FONT_GLOW = true; +static const bool FONT_OUTLINE = true; +static const float FONT_UNDERLINE_THICKNESS = 5.0f; +static const float FONT_UNDERLINE_POSITION = 60.0f; +static const Vector4 FONT_SHADOW_COLOR = Color::BLUE; +static const Vector2 FONT_SHADOW_OFFSET(2.f, 2.f ); +static const float FONT_SHADOW_SIZE = 55.f; +static const Vector4 FONT_TEXT_GLOW_COLOR = Color::BLACK; +static const float FONT_GLOW_INTENSITY = 10.0f; +static const float FONT_SMOOTH_EDGE = 5.0f; +static const Vector4 FONT_OUTLINE_COLOR = Color::MAGENTA; +static const Vector2 FONT_OUTLINE_THICKNESS(15.f, 14.f ); + +} // anon namespace + +int UtcDaliTextActorConstructorVoid(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::TextActor::TextActor()"); + + TextActor actor; + + DALI_TEST_CHECK(!actor); + END_TEST; +} + +int UtcDaliTextActorNew01(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::TextActor::New()"); + + TextActor actor = TextActor::New(TestTextHello); + + DALI_TEST_CHECK(actor); + + actor = TextActor::New(Text(std::string(TestTextHello))); + + DALI_TEST_CHECK(actor); + END_TEST; +} + + +int UtcDaliTextActorNew02(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::TextActor::New()"); + + TextActor actor = TextActor::New(TestTextHello, false); + + DALI_TEST_CHECK(actor); + + actor = TextActor::New(Text(std::string(TestTextHello)), false); + + DALI_TEST_CHECK(actor); + END_TEST; +} + +int UtcDaliTextActorNew03(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::TextActor::New()"); + + TextActor actor = TextActor::New(TestTextHello, false, false); + + DALI_TEST_CHECK(actor); + + actor = TextActor::New(Text(std::string(TestTextHello)), false, false); + + DALI_TEST_CHECK(actor); + END_TEST; +} + + +int UtcDaliTextActorNew04(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::TextActor::New()"); + + FontParameters parameters( "FreeSerif", "Book", PointSize(8) ); + Font freeSerif = Font::New( parameters ); + + TextActor actor = TextActor::New(TestTextHello, freeSerif); + + DALI_TEST_CHECK(actor); + + actor = TextActor::New(Text(std::string(TestTextHello)), freeSerif); + + DALI_TEST_CHECK(actor); + END_TEST; +} + +int UtcDaliTextActorNew05(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::TextActor::New()"); + + FontParameters parameters( "FreeSerif", "Book", PointSize(8) ); + Font freeSerif = Font::New( parameters ); + + TextActor actor = TextActor::New(TestTextHello, freeSerif, false); + + DALI_TEST_CHECK(actor); + + actor = TextActor::New(Text(std::string(TestTextHello)), freeSerif, false); + + DALI_TEST_CHECK(actor); + END_TEST; +} + +int UtcDaliTextActorNew06(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::TextActor::New()"); + + FontParameters parameters( "FreeSerif", "Book", PointSize(8) ); + Font freeSerif = Font::New( parameters ); + + TextActor actor = TextActor::New(TestTextHello, freeSerif, false, false); + + DALI_TEST_CHECK(actor); + + actor = TextActor::New(Text(std::string(TestTextHello)), freeSerif, false, false); + + DALI_TEST_CHECK(actor); + END_TEST; +} + +int UtcDaliTextActorNew07(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::TextActor::New()"); + + TextStyle style; + + TextActor actor = TextActor::New(Text(TestTextHello), style, false, false); + + DALI_TEST_CHECK(actor); + END_TEST; +} + + +int UtcDaliTextActorDownCast(void) +{ + TestApplication application; + tet_infoline("Testing Dali::TextActor::DownCast()"); + + TextActor actor1 = TextActor::New("Hello, World!"); + Actor anActor = Actor::New(); + anActor.Add(actor1); + + Actor child = anActor.GetChildAt(0); + TextActor textActor = TextActor::DownCast(child); + + DALI_TEST_CHECK(textActor); + DALI_TEST_CHECK(!textActor.GetText().compare("Hello, World!")); + END_TEST; +} + +int UtcDaliTextActorDownCast2(void) +{ + TestApplication application; + tet_infoline("Testing Dali::TextActor::DownCast()"); + + Actor actor1 = Actor::New(); + Actor anActor = Actor::New(); + anActor.Add(actor1); + + Actor child = anActor.GetChildAt(0); + TextActor textActor = TextActor::DownCast(child); + DALI_TEST_CHECK(!textActor); + + Actor unInitialzedActor; + textActor = DownCast< TextActor >( unInitialzedActor ); + DALI_TEST_CHECK(!textActor); + END_TEST; +} + +int UtcDaliTextActorSetText(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::TextActor::SetText()"); + + TextActor actor01 = TextActor::New(TestTextHello); + + actor01.SetText(TestTextHelloWorld); + + std::string text = actor01.GetText(); + + DALI_TEST_EQUALS(text, TestTextHelloWorld, TEST_LOCATION); + + actor01.SetText(Text(std::string(TestTextHelloWorld))); + + text = actor01.GetText(); + + DALI_TEST_EQUALS(text, TestTextHelloWorld, TEST_LOCATION); + + actor01.SetText(""); + + text = actor01.GetText(); + + DALI_TEST_EQUALS(text, "", TEST_LOCATION); + + TextActor actor02 = TextActor::New(""); + + actor02.SetText( std::string() ); + + text = actor02.GetText(); + + DALI_TEST_EQUALS(text, "", TEST_LOCATION); + + actor02.SetText(TestTextHelloWorld); + actor02.SetText( std::string() ); + + text = actor02.GetText(); + + DALI_TEST_EQUALS(text, "", TEST_LOCATION); + + TextActor actor03 = TextActor::New(""); + const Text voidText; + actor03.SetText(voidText); + + text = actor03.GetText(); + + DALI_TEST_EQUALS(text, "", TEST_LOCATION); + + actor03.SetText(TestTextHelloWorld); + actor03.SetText(voidText); + + text = actor03.GetText(); + + DALI_TEST_EQUALS(text, "", TEST_LOCATION); + END_TEST; +} + +int UtcDaliTextActorSetFont(void) +{ + TestApplication application; + + TextActor actor = TextActor::New(TestTextHello); + + PointSize pointSize( POINT_SIZE ); + FontParameters params( FAMILY_NAME, STYLE, pointSize); + + Font font = Font::New( params ); + + actor.SetFont( font ); + + DALI_TEST_CHECK( actor.GetFont().GetName() == FAMILY_NAME ); + END_TEST; +} + +int UtcDaliTextActorSetFontDetection(void) +{ + TestApplication application; + + TextActor actor = TextActor::New(TestTextHello); + + actor.SetFontDetectionAutomatic( true ); + + DALI_TEST_CHECK( true == actor.IsFontDetectionAutomatic() ); + + END_TEST; +} + +int UtcDaliTextActorSetTextIndividualStyles(void) +{ + TestApplication application; + + TextActor actor = TextActor::New(TestTextHello); + + actor.SetTextColor( FONT_TEXT_COLOR); + + DALI_TEST_CHECK( actor.GetTextColor() == FONT_TEXT_COLOR ); + + actor.SetSmoothEdge( FONT_SMOOTH_EDGE ); + + actor.SetOutline( FONT_OUTLINE, FONT_OUTLINE_COLOR, FONT_OUTLINE_THICKNESS ); + + actor.SetShadow( FONT_SHADOW, FONT_SHADOW_COLOR, FONT_SHADOW_OFFSET, FONT_SHADOW_SIZE ); + + actor.SetItalics( FONT_ITALICS, FONT_ITALICS_ANGLE ); + + actor.SetGlow( FONT_GLOW, FONT_TEXT_GLOW_COLOR, FONT_GLOW_INTENSITY ); + + TextStyle style = actor.GetTextStyle(); + + DALI_TEST_CHECK( FONT_TEXT_COLOR == style.GetTextColor() ); + + DALI_TEST_CHECK( FONT_SMOOTH_EDGE == style.GetSmoothEdge() ); + + DALI_TEST_CHECK( FONT_OUTLINE == style.GetOutline() ); + DALI_TEST_CHECK( FONT_OUTLINE_COLOR == style.GetOutlineColor() ); + DALI_TEST_CHECK( FONT_OUTLINE_THICKNESS == style.GetOutlineThickness() ); + + + DALI_TEST_CHECK( FONT_SHADOW == style.GetShadow() ); + DALI_TEST_CHECK( FONT_SHADOW_COLOR == style.GetShadowColor() ); + DALI_TEST_CHECK( FONT_SHADOW_OFFSET == style.GetShadowOffset() ); + DALI_TEST_CHECK( FONT_SHADOW_SIZE == style.GetShadowSize() ); + + DALI_TEST_CHECK( FONT_ITALICS == style.GetItalics() ); + DALI_TEST_CHECK( FONT_ITALICS_ANGLE == style.GetItalicsAngle() ); + + DALI_TEST_CHECK( FONT_GLOW == style.GetGlow() ); + DALI_TEST_CHECK( FONT_OUTLINE == style.GetOutline() ); + DALI_TEST_CHECK( FONT_TEXT_GLOW_COLOR == style.GetGlowColor() ); + DALI_TEST_CHECK( FONT_GLOW_INTENSITY == style.GetGlowIntensity() ); + + + actor.SetItalics( FONT_ITALICS, FONT_ITALICS_RADIAN_ANGLE ); + style = actor.GetTextStyle(); + DALI_TEST_CHECK( FONT_ITALICS_RADIAN_ANGLE == style.GetItalicsAngle() ); + + + END_TEST; +} + +int UtcDaliTextActorChangingText(void) +{ + TestApplication application; + + TextActor actor = TextActor::New(TestTextHello); + actor.SetSize(Vector3(200, 20, 0.0f)); + actor.SetPosition(20.0f, 400.0f, 40.0f); + Stage::GetCurrent().Add(actor); + + tet_infoline("Testing Dali::TextActor::SetText() & Dali::TextActor::GetText()"); + actor.SetText(LongTestText); + std::string text = actor.GetText(); + DALI_TEST_EQUALS(text, LongTestText, TEST_LOCATION); + + // do a render + application.SendNotification(); + application.Render(); + + // check that the size did not change + DALI_TEST_EQUALS( Vector3(200, 20, 0.0f), actor.GetCurrentSize(), TEST_LOCATION); + END_TEST; +} + +int UtcDaliTextActorGetLoadingState(void) +{ + TestApplication application; + + TextActor actor = TextActor::New(TestTextHello); + + DALI_TEST_CHECK( ResourceLoading == actor.GetLoadingState()); + + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( ResourceLoadingSucceeded == actor.GetLoadingState()); + + END_TEST; +} + +int UtcDaliTextActorSetItalics(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::TextActor::New()"); + + TextActor actor = TextActor::New(TestTextHello); + + DALI_TEST_CHECK(actor); + + actor.SetItalics( true ); + + DALI_TEST_CHECK( actor.GetItalics() ); + + DALI_TEST_EQUALS( static_cast( Degree( actor.GetItalicsAngle() ) ), static_cast(TextStyle::DEFAULT_ITALICS_ANGLE), 0.0001f, TEST_LOCATION ); + + actor.SetItalics( false ); + + DALI_TEST_CHECK( ! actor.GetItalics() ); + + // TODO: Implement a why on the glAbstraction to check if the geometry was created correctly + END_TEST; +} + +int UtcDaliTextActorSetUnderline(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::TextActor::SetUnderline()"); + + TextActor actor = TextActor::New(TestTextHello); + + DALI_TEST_CHECK(actor); + + actor.SetUnderline( true ); + + DALI_TEST_CHECK( actor.GetUnderline() ); + + actor.SetUnderline( false ); + + DALI_TEST_CHECK( ! actor.GetUnderline() ); + + // TODO: Implement a why on the glAbstraction to check if the geometry was created correctly + END_TEST; +} + +int UtcDaliTextActorSetWeight(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::TextActor::SetWeight()"); + + TextActor actor = TextActor::New(TestTextHello); + + DALI_TEST_CHECK(actor); + + actor.SetWeight( TextStyle::EXTRABOLD ); + + DALI_TEST_CHECK( TextStyle::EXTRABOLD == actor.GetWeight() ); + + actor.SetWeight( TextStyle::BOLD ); + + DALI_TEST_CHECK( TextStyle::BOLD == actor.GetWeight() ); + END_TEST; +} + +int UtcDaliTextActorSetStyle(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::TextActor::SetTextStyle()"); + + TextActor actor = TextActor::New(TestTextHello); + + TextStyle defaultStyle = actor.GetTextStyle(); + DALI_TEST_CHECK( defaultStyle.GetFontName().empty() ); + DALI_TEST_CHECK( TextStyle::REGULAR == defaultStyle.GetWeight() ); + DALI_TEST_CHECK( Color::WHITE == defaultStyle.GetTextColor() ); + DALI_TEST_CHECK( !defaultStyle.GetItalics() ); + DALI_TEST_CHECK( !defaultStyle.GetUnderline() ); + + TextStyle style; + style.SetFontPointSize(PointSize( 16.f )); + style.SetWeight(TextStyle::EXTRABLACK); + style.SetTextColor(Color::BLUE); + style.SetItalics(true); + style.SetUnderline(true); + style.SetShadow(false); + style.SetGlow(false); + style.SetOutline(false); + + actor.SetTextStyle( style ); + // This is necessary since SetColor (via TextStyle) is asynchronous + application.SendNotification(); + application.Render(); + style = actor.GetTextStyle(); + + DALI_TEST_CHECK( style.GetFontName().empty() ); + DALI_TEST_CHECK( style.GetFontStyle().empty() ); + DALI_TEST_EQUALS( static_cast( PointSize( 16.f ) ), + static_cast( style.GetFontPointSize() ), + GetRangedEpsilon( PointSize( 16.f ), style.GetFontPointSize() ), + TEST_LOCATION ); + DALI_TEST_CHECK( TextStyle::EXTRABLACK == style.GetWeight() ); + DALI_TEST_EQUALS( Vector4( 0.f, 0.f, 1.f, 1.f ), style.GetTextColor(), TEST_LOCATION ); + DALI_TEST_CHECK( style.GetItalics() ); + DALI_TEST_CHECK( style.GetUnderline() ); + END_TEST; +} + +int UtcDaliTextActorDefaultProperties(void) +{ + TestApplication application; + tet_infoline("Testing Dali::TextActor DefaultProperties"); + + TextActor actor = TextActor::New("@"); + + std::vector indices ; + indices.push_back(TextActor::TEXT ); + indices.push_back(TextActor::FONT ); + indices.push_back(TextActor::FONT_STYLE ); + indices.push_back(TextActor::OUTLINE_ENABLE ); + indices.push_back(TextActor::OUTLINE_COLOR ); + indices.push_back(TextActor::OUTLINE_THICKNESS_WIDTH ); + indices.push_back(TextActor::SMOOTH_EDGE ); + indices.push_back(TextActor::GLOW_ENABLE ); + indices.push_back(TextActor::GLOW_COLOR ); + indices.push_back(TextActor::GLOW_INTENSITY ); + indices.push_back(TextActor::SHADOW_ENABLE ); + indices.push_back(TextActor::SHADOW_COLOR ); + indices.push_back(TextActor::SHADOW_OFFSET ); + indices.push_back(TextActor::ITALICS_ANGLE ); + indices.push_back(TextActor::UNDERLINE ); + indices.push_back(TextActor::WEIGHT ); + indices.push_back(TextActor::FONT_DETECTION_AUTOMATIC ); + indices.push_back(TextActor::GRADIENT_COLOR ); + indices.push_back(TextActor::GRADIENT_START_POINT ); + indices.push_back(TextActor::GRADIENT_END_POINT ); + indices.push_back(TextActor::SHADOW_SIZE ); + indices.push_back(TextActor::TEXT_COLOR ); + + DALI_TEST_CHECK(actor.GetPropertyCount() == ( Actor::New().GetPropertyCount() + indices.size() ) ); + + for(std::vector::iterator iter = indices.begin(); iter != indices.end(); ++iter) + { + DALI_TEST_CHECK( *iter == actor.GetPropertyIndex(actor.GetPropertyName(*iter)) ); + DALI_TEST_CHECK( actor.IsPropertyWritable(*iter) ); + DALI_TEST_CHECK( !actor.IsPropertyAnimatable(*iter) ); + DALI_TEST_CHECK( actor.GetPropertyType(*iter) == actor.GetPropertyType(*iter) ); // just checking call succeeds + } + + // set/get one of them + actor.SetUnderline(false); + DALI_TEST_CHECK(actor.GetUnderline() != true); + + actor.SetProperty(TextActor::UNDERLINE, Property::Value(true)); + Property::Value v = actor.GetProperty(TextActor::UNDERLINE); + DALI_TEST_CHECK(v.GetType() == Property::BOOLEAN); + + DALI_TEST_CHECK(v.Get() == true); + END_TEST; +} + +int UtcDaliTextActorSetGradientColor(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::TextActor::SetGradientColor()"); + + TextActor actor = TextActor::New(TestTextHello); + + DALI_TEST_CHECK(actor); + + actor.SetGradientColor( Color::RED ); + DALI_TEST_EQUALS( actor.GetGradientColor(), Color::RED, TEST_LOCATION ); + + actor.SetGradientColor( Color::BLUE ); + DALI_TEST_EQUALS( actor.GetGradientColor(), Color::BLUE, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliTextActorSetGradientStartPoint(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::TextActor::SetGradientStartPoint()"); + + TextActor actor = TextActor::New(TestTextHello); + + DALI_TEST_CHECK(actor); + + actor.SetGradientStartPoint( Vector2(0.5f, 0.5f) ); + DALI_TEST_EQUALS( actor.GetGradientStartPoint(), Vector2(0.5f, 0.5f), TEST_LOCATION ); + + actor.SetGradientStartPoint( Vector2(1.0f, 0.0f) ); + DALI_TEST_EQUALS( actor.GetGradientStartPoint(), Vector2(1.0f, 0.0f), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliTextActorSetGradientEndPoint(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::TextActor::SetGradientEndPoint()"); + + TextActor actor = TextActor::New(TestTextHello); + + DALI_TEST_CHECK(actor); + + actor.SetGradientEndPoint( Vector2(0.25f, 0.25f) ); + DALI_TEST_EQUALS( actor.GetGradientEndPoint(), Vector2(0.25f, 0.25f), TEST_LOCATION ); + + actor.SetGradientEndPoint( Vector2(0.0f, 1.0f) ); + DALI_TEST_EQUALS( actor.GetGradientEndPoint(), Vector2(0.0f, 1.0f), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliTextActorSynchronousGlyphLoading(void) +{ + TestApplication application; + + tet_infoline( "Testing synchronous loading of glyphs"); + + // All numerals 0 through 9 are 'fake' cached in the test abstraction glyphcache + + // create text actor containg "Hello" + TextActor actor = TextActor::New(TestTextHello); + + // no glyphs will be cached + + // so..GetGlyphData should have been called to gather metrics + DALI_TEST_CHECK( application.GetPlatform().GetTrace().FindMethodAndParams( "GetGlyphData", "getBitmap:false" ) ); + // ..but not to load glyph bitmap data + DALI_TEST_CHECK( ! application.GetPlatform().GetTrace().FindMethodAndParams( "GetGlyphData", "getBitmap:true" ) ); + // ..also, cached high quality glyphs will not have been requested yet + DALI_TEST_CHECK( ! application.GetPlatform().WasCalled(TestPlatformAbstraction::GetCachedGlyphDataFunc) ); + + // reset PlatformAbstraction function call traces + application.GetPlatform().ResetTrace(); + + // Invoke Core::ProcessEvent and tick the update/render threads + application.SendNotification(); + application.Render(); + + // An attempt to load high quality glyphs will have been requested and loaded nothing + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::GetCachedGlyphDataFunc) ); + // low quality glyphs bitmap data will have now been generated + DALI_TEST_CHECK( application.GetPlatform().GetTrace().FindMethodAndParams( "GetGlyphData", "getBitmap:true" ) ); + + // request numerals + actor.SetText( "0123456789" ); + + // reset PlatformAbstraction function call traces + application.GetPlatform().ResetTrace(); + + application.SendNotification(); + application.Render(); + + // An attempt to load high quality glyphs will have been requested and loaded all the numerals + DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::GetCachedGlyphDataFunc) ); + // ..therefore no low quality glyphs bitmap data will have been requested + DALI_TEST_CHECK( !application.GetPlatform().GetTrace().FindMethodAndParams( "GetGlyphData", "getBitmap:true" ) ); + END_TEST; +} + +int UtcDaliTextActorAutomaticSizeSet(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::TextActor getting size based on text automatically"); + + // create empty text actor + TextActor actor = TextActor::New(); + Stage::GetCurrent().Add(actor); + + // initial size is zero + DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentSize(), TEST_LOCATION ); + + // set some text + actor.SetText( "a" ); + // render a frame + application.SendNotification(); + application.Render(); + + // dont care about the actual size as that is too hard to figure out, just want to validate that the size was changed to bigger + Vector3 currentSize = actor.GetCurrentSize(); + DALI_TEST_GREATER( currentSize.width, 0.0f, TEST_LOCATION ); + DALI_TEST_GREATER( currentSize.height, 0.0f, TEST_LOCATION ); + + // set some more text + actor.SetText( "abba" ); + // render a frame + application.SendNotification(); + application.Render(); + + Vector3 biggerSize = actor.GetCurrentSize(); + DALI_TEST_GREATER( biggerSize.width, currentSize.width, TEST_LOCATION ); + + // set some shorter text + actor.SetText( "i" ); + // render a frame + application.SendNotification(); + application.Render(); + + // actor has shrunk + DALI_TEST_GREATER( biggerSize.width, actor.GetCurrentSize().width, TEST_LOCATION ); + + // set a size from application side, from this point onwards text actor no longer uses the "natural" size of the text + actor.SetSize( Vector2( 10.0f, 11.0f ) ); + // render a frame + application.SendNotification(); + application.Render(); + // actor has the user set size + DALI_TEST_EQUALS( Vector2( 10.0f, 11.0f ), actor.GetCurrentSize().GetVectorXY(), TEST_LOCATION ); + + // set some different text + std::string longText( "jabba dabba duu" ); + actor.SetText( longText ); + // render a frame + application.SendNotification(); + application.Render(); + // actor still has the user set size + DALI_TEST_EQUALS( Vector2( 10.0f, 11.0f ), actor.GetCurrentSize().GetVectorXY(), TEST_LOCATION ); + + // set text to its natural size + actor.SetToNaturalSize(); + // render a frame + application.SendNotification(); + application.Render(); + // actor has the natural size + Font defaultFont = Font::New(); + Vector3 naturalSize = defaultFont.MeasureText( longText ); + DALI_TEST_EQUALS( naturalSize.GetVectorXY(), actor.GetCurrentSize().GetVectorXY(), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliTextActorAutomaticSizeSetAnimation(void) +{ + TestApplication application; + + tet_infoline("Testing Dali::TextActor getting size based on text automatically with animation"); + + // create empty text actor + TextActor actor = TextActor::New(); + Stage::GetCurrent().Add(actor); + + // initial size is zero + DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentSize(), TEST_LOCATION ); + + // set some text + actor.SetText( "a" ); + // render a frame + application.SendNotification(); + application.Render(); + + // dont care about the actual size as that is too hard to figure out, just want to validate that the size was changed to bigger + Vector3 currentSize = actor.GetCurrentSize(); + DALI_TEST_GREATER( currentSize.width, 0.0f, TEST_LOCATION ); + DALI_TEST_GREATER( currentSize.height, 0.0f, TEST_LOCATION ); + + // animate size, from this point onwards text actor no longer uses the "natural" size of the text + Animation sizeAnim = Animation::New( 0.1f ); // 0.1 seconds + Vector3 animationTargetSize( 20.0f, 30.0f, 0.0f ); + sizeAnim.AnimateTo( Property( actor, Actor::SIZE ), animationTargetSize ); + sizeAnim.Play(); + + // set some more text + actor.SetText( "abba" ); + // render a frame + application.SendNotification(); + application.Render( 1000 ); // 1 second to complete the animation + + DALI_TEST_EQUALS( animationTargetSize, actor.GetCurrentSize(), TEST_LOCATION ); + + // set some more text + std::string moreText( "something else" ); + actor.SetText( moreText ); + // render a frame + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( animationTargetSize, actor.GetCurrentSize(), TEST_LOCATION ); + + // set text to its natural size + actor.SetToNaturalSize(); + // render a frame + application.SendNotification(); + application.Render(); + // actor has the natural size + Font defaultFont = Font::New(); + Vector3 naturalSize = defaultFont.MeasureText( moreText ); + DALI_TEST_EQUALS( naturalSize.GetVectorXY(), actor.GetCurrentSize().GetVectorXY(), TEST_LOCATION ); + END_TEST; +} + + +int UtcDaliTextActorPropertyIndices(void) +{ + TestApplication application; + Actor basicActor = Actor::New(); + TextActor textActor = TextActor::New("Text"); + + Property::IndexContainer indices; + textActor.GetPropertyIndices( indices ); + DALI_TEST_CHECK( indices.size() > basicActor.GetPropertyCount() ); + DALI_TEST_EQUALS( indices.size(), textActor.GetPropertyCount(), TEST_LOCATION ); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-TextStyle.cpp b/automated-tests/src/dali/utc-Dali-TextStyle.cpp new file mode 100644 index 0000000..dc98928 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-TextStyle.cpp @@ -0,0 +1,511 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 + +using namespace Dali; + +void utc_dali_text_style_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_text_style_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ + +static const std::string FONT_FAMILY="Arial"; +static const std::string FONT_STYLE="Bold"; +static const PointSize FONT_POINT=PointSize(12.f); +static const TextStyle::Weight FONT_TEXT_STYLE_WEIGHT = TextStyle::EXTRALIGHT; + +static const Vector4 FONT_TEXT_COLOR = Color::RED; +static const Degree FONT_ITALICS_ANGLE(10.f); +static const bool FONT_ITALICS = true; +static const bool FONT_UNDERLINE = true; +static const bool FONT_SHADOW = true; +static const bool FONT_GLOW = true; +static const bool FONT_OUTLINE = true; +static const float FONT_UNDERLINE_THICKNESS = 5.0f; +static const float FONT_UNDERLINE_POSITION = 60.0f; +static const Vector4 FONT_SHADOW_COLOR = Color::BLUE; +static const Vector2 FONT_SHADOW_OFFSET(2.f, 2.f ); +static const float FONT_SHADOW_SIZE = 55.f; +static const Vector4 FONT_TEXT_GLOW_COLOR = Color::BLACK; +static const float FONT_GLOW_INTENSITY = 10.0f; +static const float FONT_SMOOTH_EDGE = 5.0f; +static const Vector4 FONT_OUTLINE_COLOR = Color::MAGENTA; +static const Vector2 FONT_OUTLINE_THICKNESS(15.f, 14.f ); + +} // anon namespace + +int UtcDaliTextStyleDefaultConstructor(void) +{ + tet_infoline(" UtcDaliTextStyleDefaultConstructor "); + + TestApplication application; + + TextStyle defaultStyle; + + DALI_TEST_CHECK( defaultStyle.GetFontName().empty() ); + DALI_TEST_CHECK( PointSize( 0.f ) == defaultStyle.GetFontPointSize() ); + DALI_TEST_CHECK( TextStyle::REGULAR == defaultStyle.GetWeight() ); + DALI_TEST_CHECK( Color::WHITE == defaultStyle.GetTextColor() ); + DALI_TEST_CHECK( !defaultStyle.GetItalics() ); + + DALI_TEST_CHECK( !defaultStyle.GetUnderline() ); + DALI_TEST_CHECK( fabs( TextStyle::DEFAULT_UNDERLINE_THICKNESS - defaultStyle.GetUnderlineThickness() ) < GetRangedEpsilon( TextStyle::DEFAULT_UNDERLINE_THICKNESS, defaultStyle.GetUnderlineThickness() ) ); + DALI_TEST_CHECK( fabs( TextStyle::DEFAULT_UNDERLINE_POSITION - defaultStyle.GetUnderlinePosition() ) < GetRangedEpsilon( TextStyle::DEFAULT_UNDERLINE_POSITION, defaultStyle.GetUnderlinePosition() ) ); + + DALI_TEST_CHECK( TextStyle::DEFAULT_ITALICS_ANGLE == defaultStyle.GetItalicsAngle() ); + DALI_TEST_CHECK( TextStyle::DEFAULT_SHADOW_COLOR == defaultStyle.GetShadowColor() ); + DALI_TEST_CHECK( TextStyle::DEFAULT_GLOW_COLOR == defaultStyle.GetGlowColor() ); + DALI_TEST_CHECK( TextStyle::DEFAULT_OUTLINE_COLOR == defaultStyle.GetOutlineColor() ); + + DALI_TEST_CHECK( TextStyle::DEFAULT_SHADOW_OFFSET == defaultStyle.GetShadowOffset() ); + DALI_TEST_CHECK( TextStyle::DEFAULT_OUTLINE_THICKNESS == defaultStyle.GetOutlineThickness() ); + DALI_TEST_CHECK( fabs( TextStyle::DEFAULT_GLOW_INTENSITY - defaultStyle.GetGlowIntensity() ) < GetRangedEpsilon( TextStyle::DEFAULT_GLOW_INTENSITY, defaultStyle.GetGlowIntensity() ) ); + DALI_TEST_CHECK( fabs( TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD - defaultStyle.GetSmoothEdge() ) < GetRangedEpsilon( TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, defaultStyle.GetSmoothEdge() ) ); + END_TEST; +} + +int UtcDaliTextStyleCopyConstructor(void) +{ + tet_infoline(" UtcDaliTextStyleCopyConstructor "); + + TestApplication application; + + const std::string fontName( "Arial" ); + const std::string fontStyle( "Book" ); + + TextStyle style; + style.SetFontName( fontName ); + style.SetFontStyle( fontStyle ); + style.SetFontPointSize( PointSize( 16.f ) ); + style.SetWeight( TextStyle::EXTRABLACK ); + style.SetTextColor( Color::BLUE ); + style.SetItalics( true ); + style.SetUnderline( true ); + style.SetItalicsAngle( Degree( 15.f ) ); + style.SetUnderlineThickness( 3.5f ); + style.SetUnderlinePosition( 12.f ); + style.SetShadow( true, Color::RED, Vector2( 0.5f, 0.5f ), TextStyle::DEFAULT_SHADOW_SIZE ); + style.SetGlow( true, Color::GREEN, 0.75f ); + style.SetSmoothEdge( 0.8f ); + style.SetOutline( true, Color::BLUE, Vector2( 0.9f, 0.9f ) ); + + TextStyle style1( style ); + TextStyle style2 = style; + + DALI_TEST_CHECK( fontName == style1.GetFontName() ); + DALI_TEST_CHECK( fontStyle == style.GetFontStyle() ); + DALI_TEST_CHECK( PointSize( 16.f ) == style1.GetFontPointSize() ); + DALI_TEST_CHECK( TextStyle::EXTRABLACK == style1.GetWeight() ); + DALI_TEST_CHECK( Vector4( 0.f, 0.f, 1.f, 1.f ) == style1.GetTextColor() ); + DALI_TEST_CHECK( style1.GetItalics() ); + DALI_TEST_CHECK( style1.GetUnderline() ); + + DALI_TEST_CHECK( Degree( 15.f ) == style1.GetItalicsAngle() ); + DALI_TEST_CHECK( Color::RED == style1.GetShadowColor() ); + DALI_TEST_CHECK( Color::GREEN == style1.GetGlowColor() ); + DALI_TEST_CHECK( Color::BLUE == style1.GetOutlineColor() ); + + DALI_TEST_CHECK( Vector2( 0.5f, 0.5f ) == style1.GetShadowOffset() ); + DALI_TEST_CHECK( Vector2( 0.9f, 0.9f ) == style1.GetOutlineThickness() ); + DALI_TEST_CHECK( fabs( 0.75f - style1.GetGlowIntensity() ) < GetRangedEpsilon( 0.75f, style1.GetGlowIntensity() ) ); + DALI_TEST_CHECK( fabs( 0.8f - style1.GetSmoothEdge() ) < GetRangedEpsilon( 0.8f, style1.GetSmoothEdge() ) ); + + DALI_TEST_CHECK( fontName == style2.GetFontName() ); + DALI_TEST_CHECK( PointSize( 16.f ) == style2.GetFontPointSize() ); + DALI_TEST_CHECK( TextStyle::EXTRABLACK == style2.GetWeight() ); + DALI_TEST_CHECK( Vector4( 0.f, 0.f, 1.f, 1.f ) == style2.GetTextColor() ); + DALI_TEST_CHECK( style2.GetItalics() ); + + DALI_TEST_CHECK( style2.GetUnderline() ); + DALI_TEST_CHECK( fabs( 3.5f - style2.GetUnderlineThickness() ) < GetRangedEpsilon( 3.5f, style2.GetUnderlineThickness() ) ); + DALI_TEST_CHECK( fabs( 12.f - style2.GetUnderlinePosition() ) < GetRangedEpsilon( 12.f, style2.GetUnderlinePosition() ) ); + + DALI_TEST_CHECK( Color::RED == style2.GetShadowColor() ); + DALI_TEST_CHECK( Color::GREEN == style2.GetGlowColor() ); + DALI_TEST_CHECK( Color::BLUE == style2.GetOutlineColor() ); + + DALI_TEST_CHECK( Vector2( 0.5f, 0.5f ) == style2.GetShadowOffset() ); + DALI_TEST_CHECK( Vector2( 0.9f, 0.9f ) == style2.GetOutlineThickness() ); + DALI_TEST_CHECK( fabs( 0.75f - style2.GetGlowIntensity() ) < GetRangedEpsilon( 0.75f, style2.GetGlowIntensity() ) ); + DALI_TEST_CHECK( fabs( 0.8f - style2.GetSmoothEdge() ) < GetRangedEpsilon( 0.8f, style2.GetSmoothEdge() ) ); + END_TEST; +} + +int UtcDaliTextStyleComparisonOperator(void) +{ + tet_infoline(" UtcDaliTextStyleComparisonOperator "); + + TestApplication application; + + TextStyle style1; + TextStyle style2; + + const std::string fontName( "Arial" ); + + style1.SetFontName( fontName ); + DALI_TEST_CHECK( style1 != style2 ); + + style2.SetFontName( fontName ); + DALI_TEST_CHECK( style1 == style2 ); + END_TEST; +} + +int UtcDaliTextStyleCopy(void) +{ + tet_infoline(" UtcDaliTextStyleCopy "); + + TestApplication application; + + TextStyle style; + + // Set a style different than default. + TextStyle style2; + style2.SetFontName( "Arial" ); + style2.SetFontStyle( "Bold" ); + style2.SetFontPointSize( PointSize( 24.f ) ); + style2.SetWeight( TextStyle::BOLD ); + style2.SetTextColor( Color::RED ); + style2.SetItalics( true ); + style2.SetUnderline( true ); + style2.SetItalicsAngle( Degree( 15.f ) ); + style2.SetUnderlineThickness( 3.5f ); + style2.SetUnderlinePosition( 12.f ); + style2.SetShadow( true, Color::GREEN, Vector2( 0.5f, 0.5f ), 0.5f ); + style2.SetGlow( true, Color::BLUE, 0.5f ); + style2.SetSmoothEdge( 0.5f ); + style2.SetOutline( true, Color::WHITE, Vector2( 0.05f, 0.5f ) ); + + // Test mask. + + // All values are copied. + style.Copy( style2 ); + + DALI_TEST_CHECK( style == style2 ); + + // Test FONT + style = TextStyle(); + + style.Copy( style2, TextStyle::FONT ); + + DALI_TEST_CHECK( style.GetFontName() != "" ); + + // Test STYLE + style = TextStyle(); + + style.Copy( style2, TextStyle::STYLE ); + + DALI_TEST_CHECK( style.GetFontStyle() != "" ); + + // Test SIZE + style = TextStyle(); + + style.Copy( style2, TextStyle::SIZE ); + + DALI_TEST_CHECK( style.GetFontPointSize() > 0.f ); + + // Test WEIGHT + style = TextStyle(); + + style.Copy( style2, TextStyle::WEIGHT ); + + DALI_TEST_CHECK( style.GetWeight() != TextStyle::REGULAR ); + DALI_TEST_CHECK( fabsf( style.GetSmoothEdge() - TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD ) > Math::MACHINE_EPSILON_1000 ); + + // Test COLOR + style = TextStyle(); + + style.Copy( style2, TextStyle::COLOR ); + + DALI_TEST_CHECK( style.GetTextColor() != TextStyle::DEFAULT_TEXT_COLOR ); + + // Test ITALICS + style = TextStyle(); + + style.Copy( style2, TextStyle::ITALICS ); + + DALI_TEST_CHECK( style.GetItalics() ); + DALI_TEST_CHECK( Degree( 15.f ) == style.GetItalicsAngle() ); + + // Test UNDERLINE + style = TextStyle(); + + style.Copy( style2, TextStyle::UNDERLINE ); + + DALI_TEST_CHECK( style.GetUnderline() ); + DALI_TEST_CHECK( fabs( 3.5f - style.GetUnderlineThickness() ) < GetRangedEpsilon( 3.5f, style.GetUnderlineThickness() ) ); + DALI_TEST_CHECK( fabs( 12.f - style.GetUnderlinePosition() ) < GetRangedEpsilon( 12.f, style.GetUnderlinePosition() ) ); + + // Test SHADOW + style = TextStyle(); + + style.Copy( style2, TextStyle::SHADOW ); + + DALI_TEST_CHECK( style.GetShadow() ); + DALI_TEST_CHECK( style.GetShadowColor() != TextStyle::DEFAULT_SHADOW_COLOR ); + DALI_TEST_CHECK( style.GetShadowOffset() != TextStyle::DEFAULT_SHADOW_OFFSET ); + DALI_TEST_CHECK( fabsf( style.GetShadowSize() - TextStyle::DEFAULT_SHADOW_SIZE ) > Math::MACHINE_EPSILON_1000 ); + + // Test GLOW + style = TextStyle(); + + style.Copy( style2, TextStyle::GLOW ); + + DALI_TEST_CHECK( style.GetGlow() ); + DALI_TEST_CHECK( style.GetGlowColor() != TextStyle::DEFAULT_GLOW_COLOR ); + DALI_TEST_CHECK( fabsf( style.GetGlowIntensity() - TextStyle::DEFAULT_GLOW_INTENSITY ) > Math::MACHINE_EPSILON_1000 ); + + // Test OUTLINE + style = TextStyle(); + + style.Copy( style2, TextStyle::OUTLINE ); + + DALI_TEST_CHECK( style.GetOutline() ); + DALI_TEST_CHECK( style.GetOutlineColor() != TextStyle::DEFAULT_OUTLINE_COLOR ); + DALI_TEST_CHECK( style.GetOutlineThickness() != TextStyle::DEFAULT_OUTLINE_THICKNESS ); + END_TEST; +} + +int UtcDaliTextStyleSetGetFontName(void) +{ + tet_infoline(" UtcDaliTextStyleSetGetFontName "); + + TestApplication application; + + TextStyle style; + + const std::string fontName( "Arial" ); + style.SetFontName( fontName ); + + DALI_TEST_CHECK( fontName == style.GetFontName() ); + END_TEST; +} + +int UtcDaliTextStyleSetGetFontStyle(void) +{ + tet_infoline(" UtcDaliTextStyleSetGetFontStyle "); + + TestApplication application; + + TextStyle style; + + const std::string fontStyle( "Book" ); + style.SetFontStyle( fontStyle ); + + DALI_TEST_CHECK( fontStyle == style.GetFontStyle() ); + END_TEST; +} + +int UtcDaliTextStyleSetGetFontPointSize(void) +{ + tet_infoline(" UtcDaliTextStyleSetGetFontPointSize "); + + TestApplication application; + + TextStyle style; + + style.SetFontPointSize( PointSize( 16.f ) ); + + DALI_TEST_CHECK( PointSize( 16.f ) == style.GetFontPointSize() ); + END_TEST; +} + +int UtcDaliTextStyleSetGetWeight(void) +{ + tet_infoline(" UtcDaliTextStyleSetGetWeight "); + + TestApplication application; + + TextStyle style; + + style.SetWeight( TextStyle::EXTRABLACK ); + + DALI_TEST_CHECK( TextStyle::EXTRABLACK == style.GetWeight() ); + END_TEST; +} + +int UtcDaliTextStyleSetGetTextColor(void) +{ + tet_infoline(" UtcDaliTextStyleSetGetTextColor "); + + TestApplication application; + + TextStyle style; + + style.SetTextColor( Color::GREEN ); + + DALI_TEST_CHECK( Vector4( 0.f, 1.f, 0.f, 1.f ) == style.GetTextColor() ); + END_TEST; +} + +int UtcDaliTextStyleSetGetItalics(void) +{ + tet_infoline(" UtcDaliTextStyleSetGetItalics "); + + TestApplication application; + + TextStyle style; + + style.SetItalics( true ); + + DALI_TEST_CHECK( style.GetItalics() ); + + style.SetItalics( false ); + + DALI_TEST_CHECK( !style.GetItalics() ); + END_TEST; +} + +int UtcDaliTextStyleSetGetItalicsAngle(void) +{ + tet_infoline(" UtcDaliTextStyleSetGetItalicsAngle "); + + TestApplication application; + + TextStyle style; + + DALI_TEST_CHECK( TextStyle::DEFAULT_ITALICS_ANGLE == style.GetItalicsAngle() ); + + style.SetItalicsAngle( Degree( 15.f ) ); + + DALI_TEST_CHECK( Degree( 15.f ) == style.GetItalicsAngle() ); + END_TEST; +} + +int UtcDaliTextStyleSetGetUnderline(void) +{ + tet_infoline(" UtcDaliTextStyleSetGetUnderline "); + + TestApplication application; + + TextStyle style; + + style.SetUnderline( true ); + + DALI_TEST_CHECK( style.GetUnderline() ); + + style.SetUnderline( false ); + + DALI_TEST_CHECK( !style.GetUnderline() ); + + style.SetUnderlineThickness( 3.5f ); + style.SetUnderlinePosition( 12.f ); + + DALI_TEST_CHECK( fabs( 3.5f - style.GetUnderlineThickness() ) < GetRangedEpsilon( 3.5f, style.GetUnderlineThickness() ) ); + DALI_TEST_CHECK( fabs( 12.f - style.GetUnderlinePosition() ) < GetRangedEpsilon( 12.f, style.GetUnderlinePosition() ) ); + END_TEST; +} + +int UtcDaliTextStyleSetGetShadow(void) +{ + tet_infoline(" UtcDaliTextStyleSetGetShadow "); + + TestApplication application; + + TextStyle style; + + DALI_TEST_CHECK( !style.GetShadow() ); + + style.SetShadow( true ); + + DALI_TEST_CHECK( style.GetShadow() ); + + style.SetShadow( true, Color::RED, Vector2( 0.5f, 0.5f ) ); + + DALI_TEST_EQUALS( style.GetShadowColor(), Color::RED, TEST_LOCATION ); + DALI_TEST_CHECK( Vector2( 0.5f, 0.5f ) == style.GetShadowOffset() ); + + style.SetShadow( false ); + + DALI_TEST_CHECK( !style.GetShadow() ); + END_TEST; +} + +int UtcDaliTextStyleSetGetGlow(void) +{ + tet_infoline(" UtcDaliTextStyleSetGetGlow "); + + TestApplication application; + + TextStyle style; + + DALI_TEST_CHECK( !style.GetGlow() ); + + style.SetGlow( true ); + + DALI_TEST_CHECK( style.GetGlow() ); + + style.SetGlow( true, Color::RED, 0.75f ); + + DALI_TEST_EQUALS( style.GetGlowColor(), Color::RED, TEST_LOCATION ); + DALI_TEST_CHECK( fabs( 0.75f - style.GetGlowIntensity() ) < GetRangedEpsilon( 0.75f, style.GetGlowIntensity() ) ); + + style.SetGlow( false ); + + DALI_TEST_CHECK( !style.GetGlow() ); + END_TEST; +} + +int UtcDaliTextStyleSetGetOutline(void) +{ + tet_infoline(" UtcDaliTextStyleSetGetGlow "); + + TestApplication application; + + TextStyle style; + + DALI_TEST_CHECK( !style.GetOutline() ); + + style.SetOutline( true ); + + DALI_TEST_CHECK( style.GetOutline() ); + + style.SetOutline( true, Color::RED, Vector2( 0.9f, 0.9f ) ); + + DALI_TEST_EQUALS( style.GetOutlineColor(), Color::RED, TEST_LOCATION ); + DALI_TEST_CHECK( Vector2( 0.9f, 0.9f ) == style.GetOutlineThickness() ); + + style.SetOutline( false ); + + DALI_TEST_CHECK( !style.GetOutline() ); + END_TEST; +} + +int UtcDaliTextStyleSetGetSmoothEdge(void) +{ + tet_infoline(" UtcDaliTextStyleSetGetGlow "); + + TestApplication application; + + TextStyle style; + + style.SetSmoothEdge( 0.5f ); + + DALI_TEST_CHECK( fabs( 0.5f - style.GetSmoothEdge() ) < GetRangedEpsilon( 0.5f, style.GetSmoothEdge() ) ); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-TouchEventCombiner.cpp b/automated-tests/src/dali/utc-Dali-TouchEventCombiner.cpp new file mode 100644 index 0000000..427d62c --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-TouchEventCombiner.cpp @@ -0,0 +1,774 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 +#include + +using namespace Dali; +using namespace Dali::Integration; + +void utc_dali_touch_event_combiner_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_touch_event_combiner_cleanup(void) +{ + test_return_value = TET_PASS; +} + + +int UtcDaliTouchEventCombinerConstructors(void) +{ + TouchEventCombiner combiner1; + DALI_TEST_EQUALS( combiner1.GetMinimumMotionTimeThreshold(), static_cast(1), TEST_LOCATION ); + DALI_TEST_EQUALS( combiner1.GetMinimumMotionDistanceThreshold(), Vector2( 1.0f, 1.0f ), TEST_LOCATION ); + + TouchEventCombiner combiner2( 10, 20.0f, 31.0f ); + DALI_TEST_EQUALS( combiner2.GetMinimumMotionTimeThreshold(), static_cast(10), TEST_LOCATION ); + DALI_TEST_EQUALS( combiner2.GetMinimumMotionDistanceThreshold(), Vector2( 20.0f, 31.0f ), TEST_LOCATION ); + + TouchEventCombiner combiner3( 10, Vector2( 20.0f, 31.0f ) ); + DALI_TEST_EQUALS( combiner3.GetMinimumMotionTimeThreshold(), static_cast(10), TEST_LOCATION ); + DALI_TEST_EQUALS( combiner3.GetMinimumMotionDistanceThreshold(), Vector2( 20.0f, 31.0f ), TEST_LOCATION ); + + // Boundary Checks + + TouchEventCombiner combiner4( 10, 0.0f, 0.0f ); + DALI_TEST_EQUALS( combiner4.GetMinimumMotionDistanceThreshold(), Vector2( 0.0f, 0.0f ), TEST_LOCATION ); + + TouchEventCombiner combiner5( 10, Vector2( 0.0f, 0.0f ) ); + DALI_TEST_EQUALS( combiner5.GetMinimumMotionDistanceThreshold(), Vector2( 0.0f, 0.0f ), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliTouchEventCombinerConstructorsNegative(void) +{ + try + { + TouchEventCombiner combiner( 10, -20.0f, 31.0f ); + tet_printf( "%s: Should have asserted\n", TEST_LOCATION ); + tet_result( TET_FAIL ); + } + catch ( Dali::DaliException& e ) + { + tet_result( TET_PASS ); + } + + try + { + TouchEventCombiner combiner( 10, 20.0f, -31.0f ); + tet_printf( "%s: Should have asserted\n", TEST_LOCATION ); + tet_result( TET_FAIL ); + } + catch ( Dali::DaliException& e ) + { + tet_result( TET_PASS ); + } + + try + { + TouchEventCombiner combiner( 10, Vector2( -20.0f, 31.0f ) ); + tet_printf( "%s: Should have asserted\n", TEST_LOCATION ); + tet_result( TET_FAIL ); + } + catch ( Dali::DaliException& e ) + { + tet_result( TET_PASS ); + } + + try + { + TouchEventCombiner combiner( 10, Vector2( 20.0f, -31.0f ) ); + tet_printf( "%s: Should have asserted\n", TEST_LOCATION ); + tet_result( TET_FAIL ); + } + catch ( Dali::DaliException& e ) + { + tet_result( TET_PASS ); + } + END_TEST; +} + +int UtcDaliTouchEventCombinerSettersAndGetters(void) +{ + TouchEventCombiner combiner; + unsigned long time( 10u ); + Vector2 distance( 40.0f, 30.0f ); + + DALI_TEST_CHECK( combiner.GetMinimumMotionTimeThreshold() != time ); + DALI_TEST_CHECK( combiner.GetMinimumMotionDistanceThreshold() != distance ); + + combiner.SetMinimumMotionTimeThreshold( time ); + DALI_TEST_EQUALS( combiner.GetMinimumMotionTimeThreshold(), time, TEST_LOCATION ); + + combiner.SetMinimumMotionDistanceThreshold( distance.x ); + DALI_TEST_EQUALS( combiner.GetMinimumMotionDistanceThreshold(), Vector2( distance.x, distance.x ), TEST_LOCATION ); + + distance.x = 20.0f; + distance.y = 50.0f; + combiner.SetMinimumMotionDistanceThreshold( distance.x, distance.y ); + DALI_TEST_EQUALS( combiner.GetMinimumMotionDistanceThreshold(), distance, TEST_LOCATION ); + + distance.x = 100.0f; + distance.y = 20.0f; + combiner.SetMinimumMotionDistanceThreshold( distance ); + DALI_TEST_EQUALS( combiner.GetMinimumMotionDistanceThreshold(), distance, TEST_LOCATION ); + + // Boundary Checks + + combiner.SetMinimumMotionDistanceThreshold( 0.0f ); + DALI_TEST_EQUALS( combiner.GetMinimumMotionDistanceThreshold(), Vector2::ZERO, TEST_LOCATION ); + + combiner.SetMinimumMotionDistanceThreshold( 0.0f, 0.0f ); + DALI_TEST_EQUALS( combiner.GetMinimumMotionDistanceThreshold(), Vector2::ZERO, TEST_LOCATION ); + + combiner.SetMinimumMotionDistanceThreshold( Vector2::ZERO ); + DALI_TEST_EQUALS( combiner.GetMinimumMotionDistanceThreshold(), Vector2::ZERO, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliTouchEventCombinerSettersNegative(void) +{ + TouchEventCombiner combiner; + + try + { + combiner.SetMinimumMotionDistanceThreshold( -100.0f ); + tet_printf( "%s: Should have asserted\n", TEST_LOCATION ); + tet_result( TET_FAIL ); + } + catch ( Dali::DaliException& e ) + { + tet_result( TET_PASS ); + } + + try + { + combiner.SetMinimumMotionDistanceThreshold( -100.0f, 20.0f ); + tet_printf( "%s: Should have asserted\n", TEST_LOCATION ); + tet_result( TET_FAIL ); + } + catch ( Dali::DaliException& e ) + { + tet_result( TET_PASS ); + } + + try + { + combiner.SetMinimumMotionDistanceThreshold( 100.0f, -20.0f ); + tet_printf( "%s: Should have asserted\n", TEST_LOCATION ); + tet_result( TET_FAIL ); + } + catch ( Dali::DaliException& e ) + { + tet_result( TET_PASS ); + } + + try + { + combiner.SetMinimumMotionDistanceThreshold( Vector2( -100.0f, 20.0f ) ); + tet_printf( "%s: Should have asserted\n", TEST_LOCATION ); + tet_result( TET_FAIL ); + } + catch ( Dali::DaliException& e ) + { + tet_result( TET_PASS ); + } + + try + { + combiner.SetMinimumMotionDistanceThreshold( Vector2( 100.0f, -20.0f ) ); + tet_printf( "%s: Should have asserted\n", TEST_LOCATION ); + tet_result( TET_FAIL ); + } + catch ( Dali::DaliException& e ) + { + tet_result( TET_PASS ); + } + END_TEST; +} + +int UtcDaliTouchEventCombinerSingleTouchNormal(void) +{ + TouchEventCombiner combiner; + unsigned long time( 0u ); + + // Down event + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + } + + time++; + + // Motion in X direction + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Motion, 101.0f, 100.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + } + + time++; + + // Motion in Y direction + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Motion, 101.0f, 101.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + } + + // Motion event, but same time + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Motion, 102.0f, 102.0f ); + + DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + } + + time++; + + // Motion event, both X and Y movement + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Motion, 102.0f, 102.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + } + + time++; + + // Motion event, no movement + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Motion, 102.0f, 102.0f ); + + DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + } + + // Up event, no time diff, no movement + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Up, 102.0f, 102.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliTouchEventCombinerSingleTouchMotionWithoutDown(void) +{ + TouchEventCombiner combiner; + unsigned long time( 0u ); + + // Motion event + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Motion, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + } + + time++; + + // Motion event + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Motion, 102.0f, 102.0f ); + + DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliTouchEventCombinerSingleTouchTwoDowns(void) +{ + TouchEventCombiner combiner; + unsigned long time( 0u ); + + // Down event + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + } + + time++; + + // Another down with the same ID + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliTouchEventCombinerSingleTouchUpWithoutDown(void) +{ + TouchEventCombiner combiner; + unsigned long time( 0u ); + + // Up event + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + } + + time++; + + // Up event + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Up, 102.0f, 102.0f ); + + DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliTouchEventCombinerSingleTouchTwoUps(void) +{ + TouchEventCombiner combiner; + unsigned long time( 0u ); + + // Down event + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + } + + time++; + + // Up event + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + } + + time++; + + // Another up event + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliTouchEventCombinerSingleTouchUpWithDifferentId(void) +{ + TouchEventCombiner combiner; + unsigned long time( 0u ); + + // Down event + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + } + + time++; + + // Up event with different ID + { + Integration::TouchEvent touchEvent; + TouchPoint point( 2, TouchPoint::Up, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + } + + time++; + + // Up event + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliTouchEventCombinerSingleTouchMotionWithDifferentId(void) +{ + TouchEventCombiner combiner; + unsigned long time( 0u ); + + // Down event + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + } + + time++; + + // Motion event with different ID + { + Integration::TouchEvent touchEvent; + TouchPoint point( 2, TouchPoint::Motion, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + } + + time++; + + // Motion event + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Motion, 102.0f, 102.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliTouchEventCombinerMultiTouchNormal(void) +{ + TouchEventCombiner combiner; + unsigned long time( 0u ); + + // 1st point down + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + } + + time++; + + // 2nd point down + { + Integration::TouchEvent touchEvent; + TouchPoint point( 2, TouchPoint::Down, 200.0f, 200.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), 2u, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[1].deviceId, point.deviceId, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].state, TouchPoint::Stationary, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[1].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[1].screen, point.screen, TEST_LOCATION ); + } + + time++; + + // 1st point motion + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Motion, 101.0f, 100.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), 2u, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[1].state, TouchPoint::Stationary, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + } + + // 2nd point motion, no time diff + { + Integration::TouchEvent touchEvent; + TouchPoint point( 2, TouchPoint::Motion, 200.0f, 200.0f ); + + DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + } + + time++; + + // 2nd point motion + { + Integration::TouchEvent touchEvent; + TouchPoint point( 2, TouchPoint::Motion, 201.0f, 201.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), 2u, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[1].deviceId, point.deviceId, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].state, TouchPoint::Stationary, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[1].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[1].screen, point.screen, TEST_LOCATION ); + } + + time++; + + // 1st point up + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Up, 101.0f, 100.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), 2u, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[1].state, TouchPoint::Stationary, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + } + + time++; + + // 2nd point motion + { + Integration::TouchEvent touchEvent; + TouchPoint point( 2, TouchPoint::Motion, 202.0f, 202.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + } + + time++; + + // 2nd point up + { + Integration::TouchEvent touchEvent; + TouchPoint point( 2, TouchPoint::Up, 202.0f, 202.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliTouchEventCombinerSeveralPoints(void) +{ + TouchEventCombiner combiner; + unsigned long time( 0u ); + unsigned int const maximum( 200u ); + + // Several downs + for ( unsigned int pointCount = 1u; pointCount < maximum; ++pointCount ) + { + Integration::TouchEvent touchEvent; + TouchPoint point( pointCount, TouchPoint::Down, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time++, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), pointCount, TEST_LOCATION ); + } + + // Several Ups + for ( unsigned int pointCount = maximum - 1; pointCount > 0; --pointCount ) + { + Integration::TouchEvent touchEvent; + TouchPoint point( pointCount, TouchPoint::Up, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time++, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), pointCount, TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliTouchEventCombinerReset(void) +{ + TouchEventCombiner combiner; + unsigned long time( 0u ); + + // Down event + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + } + + time++; + + // Reset combiner, no more events should be sent to core. + combiner.Reset(); + + // Up event + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliTouchEventCombinerSingleTouchInterrupted(void) +{ + TouchEventCombiner combiner; + unsigned long time( 0u ); + + // Down event + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION ); + } + + time++; + + // Interrupted event + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Interrupted, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); + } + + // Send up, should not be able to send as combiner has been reset. + // Up event + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliTouchEventCombinerMultiTouchInterrupted(void) +{ + TouchEventCombiner combiner; + unsigned long time( 0u ); + unsigned int const maximum( 200u ); + + // Several downs + for ( unsigned int pointCount = 1u; pointCount < maximum; ++pointCount ) + { + Integration::TouchEvent touchEvent; + TouchPoint point( pointCount, TouchPoint::Down, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time++, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), pointCount, TEST_LOCATION ); + } + + // Interrupted event + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Interrupted, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION ); + } + + // Send up, should not be able to send as combiner has been reset. + // Up event + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliTouchEventCombinerInvalidState(void) +{ + TouchEventCombiner combiner; + unsigned long time( 0u ); + + // Stationary event + { + Integration::TouchEvent touchEvent; + TouchPoint point( 1, TouchPoint::Stationary, 100.0f, 100.0f ); + + DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION ); + } + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-TouchProcessing.cpp b/automated-tests/src/dali/utc-Dali-TouchProcessing.cpp new file mode 100644 index 0000000..7135bc2 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-TouchProcessing.cpp @@ -0,0 +1,1193 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 +#include + +using namespace Dali; + +void utc_dali_touch_processing_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_touch_processing_cleanup(void) +{ + test_return_value = TET_PASS; +} + +/////////////////////////////////////////////////////////////////////////////// + +namespace +{ + +// Stores data that is populated in the callback and will be read by the TET cases +struct SignalData +{ + SignalData() + : functorCalled( false ), + touchEvent(), + touchedActor() + { + } + + void Reset() + { + functorCalled = false; + + touchEvent.time = 0u; + touchEvent.points.clear(); + + touchedActor = NULL; + } + + bool functorCalled; + TouchEvent touchEvent; + Actor touchedActor; +}; + +// Functor that sets the data when called +struct TouchEventFunctor +{ + /** + * Constructor. + * @param[in] data Reference to the data to store callback information. + * @param[in] returnValue What the functor should return. + */ + TouchEventFunctor( SignalData& data, bool returnValue = true ) + : signalData( data ), + returnValue( returnValue ) + { + } + + bool operator()( Actor actor, const TouchEvent& touchEvent ) + { + signalData.functorCalled = true; + signalData.touchedActor = actor; + signalData.touchEvent = touchEvent; + + return returnValue; + } + + SignalData& signalData; + bool returnValue; +}; + +// Functor that removes the actor when called. +struct RemoveActorFunctor : public TouchEventFunctor +{ + /** + * Constructor. + * @param[in] data Reference to the data to store callback information. + * @param[in] returnValue What the functor should return. + */ + RemoveActorFunctor( SignalData& data, bool returnValue = true ) + : TouchEventFunctor( data, returnValue ) + { + } + + bool operator()( Actor actor, const TouchEvent& touchEvent ) + { + Actor parent( actor.GetParent() ); + if ( parent ) + { + parent.Remove( actor ); + } + + return TouchEventFunctor::operator()( actor, touchEvent ); + } +}; + +Integration::TouchEvent GenerateSingleTouch( TouchPoint::State state, Vector2 screenPosition ) +{ + Integration::TouchEvent touchEvent; + touchEvent.points.push_back( TouchPoint ( 0, state, screenPosition.x, screenPosition.y ) ); + return touchEvent; +} + +} // anon namespace + +/////////////////////////////////////////////////////////////////////////////// + +int UtcDaliTouchNormalProcessing(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to actor's touched signal + SignalData data; + TouchEventFunctor functor( data ); + actor.TouchedSignal().Connect( &application, functor ); + + Vector2 screenCoordinates( 10.0f, 10.0f ); + Vector2 localCoordinates; + actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y ); + + // Emit a down signal + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION ); + DALI_TEST_EQUALS( localCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION ); + data.Reset(); + + // Emit a motion signal + screenCoordinates.x = screenCoordinates.y = 11.0f; + actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y ); + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, screenCoordinates ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Motion, data.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION ); + DALI_TEST_EQUALS( localCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION ); + data.Reset(); + + // Emit an up signal + screenCoordinates.x = screenCoordinates.y = 12.0f; + actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y ); + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Up, screenCoordinates ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Up, data.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION ); + DALI_TEST_EQUALS( localCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION ); + data.Reset(); + + // Emit a down signal where the actor is not present + screenCoordinates.x = screenCoordinates.y = 200.0f; + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliTouchOutsideCameraNearFarPlanes(void) +{ + TestApplication application; + + Stage stage = Stage::GetCurrent(); + Vector2 stageSize = stage.GetSize(); + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::CENTER); + actor.SetParentOrigin(ParentOrigin::CENTER); + stage.Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Get the camera's near and far planes + RenderTaskList taskList = stage.GetRenderTaskList(); + Dali::RenderTask task = taskList.GetTask(0); + CameraActor camera = task.GetCameraActor(); + float nearPlane = camera.GetNearClippingPlane(); + float farPlane = camera.GetFarClippingPlane(); + + // Calculate the current distance of the actor from the camera + float tanHalfFov = tanf(camera.GetFieldOfView() * 0.5f); + float distance = (stageSize.y * 0.5f) / tanHalfFov; + + // Connect to actor's touched signal + SignalData data; + TouchEventFunctor functor( data ); + actor.TouchedSignal().Connect( &application, functor ); + + Vector2 screenCoordinates( stageSize.x * 0.5f, stageSize.y * 0.5f ); + + // Emit a down signal + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + data.Reset(); + + // Emit a down signal where actor is just at the camera's near plane + actor.SetZ(distance - nearPlane); + + // Render and notify + application.SendNotification(); + application.Render(); + + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + data.Reset(); + + // Emit a down signal where actor is closer than the camera's near plane + actor.SetZ((distance - nearPlane) + 1.0f); + + // Render and notify + application.SendNotification(); + application.Render(); + + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + data.Reset(); + + // Emit a down signal where actor is just at the camera's far plane + actor.SetZ(distance - farPlane); + + // Render and notify + application.SendNotification(); + application.Render(); + + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + data.Reset(); + + // Emit a down signal where actor is further than the camera's far plane + actor.SetZ((distance - farPlane) - 1.0f); + + // Render and notify + application.SendNotification(); + application.Render(); + + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + data.Reset(); + END_TEST; +} + +int UtcDaliTouchEmitEmpty(void) +{ + TestApplication application; + + try + { + // Emit an empty TouchEvent + Integration::TouchEvent event; + application.ProcessEvent( event ); + tet_result( TET_FAIL ); + } + catch ( Dali::DaliException& e ) + { + DALI_TEST_ASSERT( e, "!event.points.empty()", TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliTouchInterrupted(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to actor's touched signal + SignalData data; + TouchEventFunctor functor( data ); + actor.TouchedSignal().Connect( &application, functor ); + + // Emit a down signal + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION ); + data.Reset(); + + // Emit an interrupted signal, we should be signalled regardless of whether there is a hit or not. + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION ); + data.Reset(); + + // Emit another interrupted signal, our signal handler should not be called. + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f ) ) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliTouchParentConsumer(void) +{ + TestApplication application; + Actor rootActor( Stage::GetCurrent().GetRootLayer() ); + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to actor's touched signal + SignalData data; + TouchEventFunctor functor( data, false ); + actor.TouchedSignal().Connect( &application, functor ); + + // Connect to root actor's touched signal + SignalData rootData; + TouchEventFunctor rootFunctor( rootData ); // Consumes signal + rootActor.TouchedSignal().Connect( &application, rootFunctor ); + + Vector2 screenCoordinates( 10.0f, 10.0f ); + Vector2 actorCoordinates, rootCoordinates; + actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y ); + rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y ); + + // Emit a down signal + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION ); + DALI_TEST_EQUALS( 1u, rootData.touchEvent.GetPointCount(), TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION ); + DALI_TEST_EQUALS( screenCoordinates, rootData.touchEvent.points[0].screen, TEST_LOCATION ); + DALI_TEST_EQUALS( actorCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION ); + DALI_TEST_EQUALS( rootCoordinates, rootData.touchEvent.points[0].local, 0.1f, TEST_LOCATION ); + DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor ); + DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor ); + data.Reset(); + rootData.Reset(); + + // Emit a motion signal + screenCoordinates.x = screenCoordinates.y = 11.0f; + actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y ); + rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y ); + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, screenCoordinates ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION ); + DALI_TEST_EQUALS( 1u, rootData.touchEvent.GetPointCount(), TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Motion, data.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Motion, rootData.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION ); + DALI_TEST_EQUALS( screenCoordinates, rootData.touchEvent.points[0].screen, TEST_LOCATION ); + DALI_TEST_EQUALS( actorCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION ); + DALI_TEST_EQUALS( rootCoordinates, rootData.touchEvent.points[0].local, 0.1f, TEST_LOCATION ); + DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor ); + DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor ); + data.Reset(); + rootData.Reset(); + + // Emit an up signal + screenCoordinates.x = screenCoordinates.y = 12.0f; + actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y ); + rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y ); + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Up, screenCoordinates ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION ); + DALI_TEST_EQUALS( 1u, rootData.touchEvent.GetPointCount(), TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Up, data.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Up, rootData.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION ); + DALI_TEST_EQUALS( screenCoordinates, rootData.touchEvent.points[0].screen, TEST_LOCATION ); + DALI_TEST_EQUALS( actorCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION ); + DALI_TEST_EQUALS( rootCoordinates, rootData.touchEvent.points[0].local, 0.1f, TEST_LOCATION ); + DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor ); + DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor ); + data.Reset(); + rootData.Reset(); + + // Emit a down signal where the actor is not present, will hit the root actor though + screenCoordinates.x = screenCoordinates.y = 200.0f; + rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y ); + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( 1u, rootData.touchEvent.GetPointCount(), TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( screenCoordinates, rootData.touchEvent.points[0].screen, TEST_LOCATION ); + DALI_TEST_EQUALS( rootCoordinates, rootData.touchEvent.points[0].local, 0.1f, TEST_LOCATION ); + DALI_TEST_CHECK( rootActor == rootData.touchEvent.points[0].hitActor ); + END_TEST; +} + +int UtcDaliTouchInterruptedParentConsumer(void) +{ + TestApplication application; + Actor rootActor( Stage::GetCurrent().GetRootLayer() ); + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to actor's touched signal + SignalData data; + TouchEventFunctor functor( data, false ); + actor.TouchedSignal().Connect( &application, functor ); + + // Connect to root actor's touched signal + SignalData rootData; + TouchEventFunctor rootFunctor( rootData ); // Consumes signal + rootActor.TouchedSignal().Connect( &application, rootFunctor ); + + // Emit a down signal + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor ); + DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor ); + data.Reset(); + rootData.Reset(); + + // Emit an interrupted signal + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Interrupted, rootData.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor ); + DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor ); + data.Reset(); + rootData.Reset(); + + // Emit another down signal + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION ); + data.Reset(); + rootData.Reset(); + + // Remove actor from Stage + Stage::GetCurrent().Remove( actor ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Emit an interrupted signal, only root actor's signal should be called. + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Interrupted, rootData.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_CHECK( rootActor == rootData.touchEvent.points[0].hitActor ); + data.Reset(); + rootData.Reset(); + + // Emit another interrupted state, none of the signal's should be called. + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f ) ) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( false, rootData.functorCalled, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliTouchLeave(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to actor's touched signal + SignalData data; + TouchEventFunctor functor( data ); + actor.TouchedSignal().Connect( &application, functor ); + + // Set actor to require leave events + actor.SetLeaveRequired( true ); + + // Emit a down signal + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION ); + data.Reset(); + + // Emit a motion signal outside of actor, should be signalled with a Leave + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Leave, data.touchEvent.points[0].state, TEST_LOCATION ); + data.Reset(); + + // Another motion outside of actor, no signalling + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 201.0f, 201.0f )) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + data.Reset(); + + // Another motion event inside actor, signalled with motion + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 10.0f, 10.0f )) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Motion, data.touchEvent.points[0].state, TEST_LOCATION ); + data.Reset(); + + // We do not want to listen to leave events anymore + actor.SetLeaveRequired( false ); + + // Another motion event outside of actor, no signalling + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + data.Reset(); + END_TEST; +} + +int UtcDaliTouchLeaveParentConsumer(void) +{ + TestApplication application; + Actor rootActor( Stage::GetCurrent().GetRootLayer() ); + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to actor's touched signal + SignalData data; + TouchEventFunctor functor( data, false ); + actor.TouchedSignal().Connect( &application, functor ); + + // Connect to root actor's touched signal + SignalData rootData; + TouchEventFunctor rootFunctor( rootData ); // Consumes signal + rootActor.TouchedSignal().Connect( &application, rootFunctor ); + + // Set actor to require leave events + actor.SetLeaveRequired( true ); + rootActor.SetLeaveRequired( true ); + + // Emit a down signal + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor ); + DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor ); + data.Reset(); + rootData.Reset(); + + // Emit a motion signal outside of actor, should be signalled with a Leave + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Leave, data.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Leave, rootData.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor ); + DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor ); + data.Reset(); + rootData.Reset(); + + // Another motion outside of actor, only rootActor signalled + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 201.0f, 201.0f )) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Motion, rootData.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_CHECK( rootActor == rootData.touchEvent.points[0].hitActor ); + data.Reset(); + rootData.Reset(); + + // Another motion event inside actor, signalled with motion + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 10.0f, 10.0f )) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Motion, data.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Motion, rootData.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor ); + DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor ); + data.Reset(); + rootData.Reset(); + + // We do not want to listen to leave events of actor anymore + actor.SetLeaveRequired( false ); + + // Another motion event outside of root actor, only root signalled + Vector2 stageSize( Stage::GetCurrent().GetSize() ); + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( stageSize.width + 10.0f, stageSize.height + 10.0f )) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Leave, rootData.touchEvent.points[0].state, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliTouchActorBecomesInsensitive(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to actor's touched signal + SignalData data; + TouchEventFunctor functor( data ); + actor.TouchedSignal().Connect( &application, functor ); + + // Emit a down signal + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION ); + data.Reset(); + + // Change actor to insensitive + actor.SetSensitive( false ); + + // Emit a motion signal, signalled with an interrupted + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION ); + data.Reset(); + END_TEST; +} + +int UtcDaliTouchActorBecomesInsensitiveParentConsumer(void) +{ + TestApplication application; + Actor rootActor( Stage::GetCurrent().GetRootLayer() ); + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to actor's touched signal + SignalData data; + TouchEventFunctor functor( data, false ); + actor.TouchedSignal().Connect( &application, functor ); + + // Connect to root actor's touched signal + SignalData rootData; + TouchEventFunctor rootFunctor( rootData ); // Consumes signal + rootActor.TouchedSignal().Connect( &application, rootFunctor ); + + // Emit a down signal + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION ); + DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor ); + DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor ); + data.Reset(); + rootData.Reset(); + + // Remove actor from Stage + Stage::GetCurrent().Remove( actor ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Make root actor insensitive + rootActor.SetSensitive( false ); + + // Emit a motion signal, signalled with an interrupted (should get interrupted even if within root actor) + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION ); + DALI_TEST_EQUALS( TouchPoint::Interrupted, rootData.touchEvent.points[0].state, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliTouchMultipleLayers(void) +{ + TestApplication application; + Actor rootActor( Stage::GetCurrent().GetRootLayer() ); + + // Connect to actor's touched signal + SignalData data; + TouchEventFunctor functor( data ); + + Layer layer1 ( Layer::New() ); + layer1.SetSize(100.0f, 100.0f); + layer1.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add( layer1 ); + + Actor actor1 ( Actor::New() ); + actor1.SetSize( 100.0f, 100.0f ); + actor1.SetAnchorPoint(AnchorPoint::TOP_LEFT); + actor1.SetZ( 1.0f ); // Should hit actor1 in this layer + layer1.Add( actor1 ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to layer1 and actor1 + layer1.TouchedSignal().Connect( &application, functor ); + actor1.TouchedSignal().Connect( &application, functor ); + + // Hit in hittable area, actor1 should be hit + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_CHECK( data.touchedActor == actor1 ); + data.Reset(); + + // Make layer1 insensitive, nothing should be hit + layer1.SetSensitive( false ); + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + data.Reset(); + + // Make layer1 sensitive again, again actor1 will be hit + layer1.SetSensitive( true ); + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_CHECK( data.touchedActor == actor1 ); + data.Reset(); + + // Make rootActor insensitive, nothing should be hit + rootActor.SetSensitive( false ); + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + data.Reset(); + + // Make rootActor sensitive + rootActor.SetSensitive( true ); + + // Add another layer + Layer layer2 ( Layer::New() ); + layer2.SetSize(100.0f, 100.0f ); + layer2.SetAnchorPoint(AnchorPoint::TOP_LEFT); + layer2.SetZ( 10.0f ); // Should hit layer2 in this layer rather than actor2 + Stage::GetCurrent().Add( layer2 ); + + Actor actor2 ( Actor::New() ); + actor2.SetSize(100.0f, 100.0f); + actor2.SetAnchorPoint(AnchorPoint::TOP_LEFT); + layer2.Add( actor2 ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to layer2 and actor2 + layer2.TouchedSignal().Connect( &application, functor ); + actor2.TouchedSignal().Connect( &application, functor ); + + // Emit an event, should hit layer2 + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack! + data.Reset(); + + // Make layer2 insensitive, should hit actor1 + layer2.SetSensitive( false ); + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_CHECK( data.touchedActor == actor1 ); + data.Reset(); + + // Make layer2 sensitive again, should hit layer2 + layer2.SetSensitive( true ); + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack! + data.Reset(); + + // Make layer2 invisible, render and notify + layer2.SetVisible( false ); + application.SendNotification(); + application.Render(); + + // Should hit actor1 + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_CHECK( data.touchedActor == actor1 ); + data.Reset(); + + // Make rootActor invisible, render and notify + rootActor.SetVisible( false ); + application.SendNotification(); + application.Render(); + + // Should not hit anything + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + data.Reset(); + END_TEST; +} + +int UtcDaliTouchMultipleRenderTasks(void) +{ + TestApplication application; + Stage stage ( Stage::GetCurrent() ); + Vector2 stageSize ( stage.GetSize() ); + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + stage.Add(actor); + + // Create render task + Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f ); + RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() ); + renderTask.SetViewport( viewport ); + renderTask.SetInputEnabled( true ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to actor's touched signal + SignalData data; + TouchEventFunctor functor( data ); + actor.TouchedSignal().Connect( &application, functor ); + + // Emit a down signal + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + data.Reset(); + + // Ensure renderTask actor can be hit too. + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + data.Reset(); + + // Disable input on renderTask, should not be hittable + renderTask.SetInputEnabled( false ); + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + data.Reset(); + END_TEST; +} + +int UtcDaliTouchMultipleRenderTasksWithChildLayer(void) +{ + TestApplication application; + Stage stage ( Stage::GetCurrent() ); + Vector2 stageSize ( stage.GetSize() ); + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + stage.Add(actor); + + Layer layer = Layer::New(); + layer.SetSize(100.0f, 100.0f); + layer.SetAnchorPoint(AnchorPoint::TOP_LEFT); + actor.Add(layer); + + // Create render task + Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f ); + RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() ); + renderTask.SetViewport( viewport ); + renderTask.SetInputEnabled( true ); + renderTask.SetSourceActor( actor ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to layer's touched signal + SignalData data; + TouchEventFunctor functor( data ); + actor.TouchedSignal().Connect( &application, functor ); + layer.TouchedSignal().Connect( &application, functor ); + + // Emit a down signal + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + data.Reset(); + + // Ensure renderTask actor can be hit too. + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + data.Reset(); + + // Disable input on renderTask, should not be hittable + renderTask.SetInputEnabled( false ); + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + data.Reset(); + END_TEST; +} + +int UtcDaliTouchOffscreenRenderTasks(void) +{ + TestApplication application; + Stage stage ( Stage::GetCurrent() ); + Vector2 stageSize ( stage.GetSize() ); + + // FrameBufferImage for offscreen RenderTask + FrameBufferImage frameBufferImage( FrameBufferImage::New( stageSize.width, stageSize.height, Pixel::RGBA8888 ) ); + + // Create an image actor to display the FrameBufferImage + ImageActor imageActor ( ImageActor::New( frameBufferImage ) ); + imageActor.SetParentOrigin(ParentOrigin::CENTER); + imageActor.SetSize( stageSize.x, stageSize.y ); + imageActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME + stage.Add( imageActor ); + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + stage.Add( actor ); + application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); // Ensure framebuffer connects + + stage.GetRenderTaskList().GetTask( 0u ).SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION ); + + // Create a RenderTask + RenderTask renderTask = stage.GetRenderTaskList().CreateTask(); + renderTask.SetSourceActor( actor ); + renderTask.SetTargetFrameBuffer( frameBufferImage ); + renderTask.SetInputEnabled( true ); + + // Create another RenderTask + RenderTask renderTask2( stage.GetRenderTaskList().CreateTask() ); + renderTask2.SetInputEnabled( true ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to actor's touched signal + SignalData data; + TouchEventFunctor functor( data ); + actor.TouchedSignal().Connect( &application, functor ); + + // Emit a down signal + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + data.Reset(); + END_TEST; +} + +int UtcDaliTouchMultipleRenderableActors(void) +{ + TestApplication application; + Stage stage ( Stage::GetCurrent() ); + Vector2 stageSize ( stage.GetSize() ); + + Actor parent = ImageActor::New(); + parent.SetSize(100.0f, 100.0f); + parent.SetAnchorPoint(AnchorPoint::TOP_LEFT); + stage.Add(parent); + + Actor actor = ImageActor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + parent.Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to layer's touched signal + SignalData data; + TouchEventFunctor functor( data ); + parent.TouchedSignal().Connect( &application, functor ); + actor.TouchedSignal().Connect( &application, functor ); + + // Emit a down signal + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_CHECK( actor == data.touchedActor ); + END_TEST; +} + +int UtcDaliTouchActorRemovedInSignal(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to actor's touched signal + SignalData data; + RemoveActorFunctor functor( data ); + actor.TouchedSignal().Connect( &application, functor ); + + // Register for leave events + actor.SetLeaveRequired( true ); + + // Emit a down signal + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + data.Reset(); + + // Re-add, render and notify + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(); + + // Emit another signal outside of actor's area, should not get anything as the scene has changed. + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + data.Reset(); + + // Emit a down signal + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + data.Reset(); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Emit another signal outside of actor's area, should not get anything as the scene has changed. + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + data.Reset(); + + // Re-add actor back to stage, render and notify + Stage::GetCurrent().Add(actor); + application.SendNotification(); + application.Render(); + + // Emit another down event + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + data.Reset(); + + // Completely delete the actor + actor = NULL; + + // Emit event, should not crash and should not receive an event. + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliTouchActorSignalNotConsumed(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to actor's touched signal + SignalData data; + TouchEventFunctor functor( data, false ); + actor.TouchedSignal().Connect( &application, functor ); + + // Emit a down signal + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliTouchActorUnStaged(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to actor's touched signal + SignalData data; + TouchEventFunctor functor( data ); + actor.TouchedSignal().Connect( &application, functor ); + + // Emit a down signal + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + data.Reset(); + + // Remove actor from stage + Stage::GetCurrent().Remove( actor ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Emit a move at the same point, we should not be signalled. + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); + data.Reset(); + END_TEST; +} + +int UtcDaliTouchSystemOverlayActor(void) +{ + TestApplication application; + Dali::Integration::Core& core( application.GetCore() ); + Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() ); + systemOverlay.GetOverlayRenderTasks().CreateTask(); + + // Create an actor and add it to the system overlay. + Actor systemActor = Actor::New(); + systemActor.SetSize(100.0f, 100.0f); + systemActor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + systemOverlay.Add( systemActor ); + + // Create an actor and add it to the stage as per normal, same position and size as systemActor + Actor actor = Actor::New(); + actor.SetSize(100.0f, 100.0f); + actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); + Stage::GetCurrent().Add(actor); + + // Connect to the touch signals. + SignalData data; + TouchEventFunctor functor( data ); + systemActor.TouchedSignal().Connect( &application, functor ); + actor.TouchedSignal().Connect( &application, functor ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Emit a down signal, the system overlay is drawn last so is at the top, should hit the systemActor. + application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) ); + DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); + DALI_TEST_CHECK( systemActor == data.touchedActor ); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Vector2.cpp b/automated-tests/src/dali/utc-Dali-Vector2.cpp new file mode 100644 index 0000000..c33c8ed --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-Vector2.cpp @@ -0,0 +1,405 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; + +void utc_dali_vector2_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_vector2_cleanup(void) +{ + test_return_value = TET_PASS; +} + +int UtcDaliVector2Cons(void) +{ + Vector3 v3(1.0f, 2.0f, 3.0f); + Vector2 va; + Vector2 vb(v3); + Vector2 vc(11.0f, 123.0f); + + DALI_TEST_EQUALS(va.x, 0.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(va.y, 0.0f, 0.001f, TEST_LOCATION); + + DALI_TEST_EQUALS(vb.width, 1.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(vb.height, 2.0f, 0.001f, TEST_LOCATION); + + DALI_TEST_EQUALS(vc.width, 11.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(vc.y, 123.0f, 0.001f, TEST_LOCATION); + + Vector4 vec4(5.0f,6.0f,7.0f,8.0f); + Vector2 vec2; + vec2 = vec4; + DALI_TEST_EQUALS(vec2.x, 5.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(vec2.y, 6.0f, 0.001, TEST_LOCATION); + + Vector3 vec3(5.0f,6.0f,7.0f); + vec2 = vec3; + DALI_TEST_EQUALS(vec2.x, 5.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(vec2.y, 6.0f, 0.001, TEST_LOCATION); + + Vector2 vec2b(vec4); + DALI_TEST_EQUALS(vec2.x, 5.0f, 0.001, TEST_LOCATION); + DALI_TEST_EQUALS(vec2.y, 6.0f, 0.001, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliVector2FitInside(void) +{ + DALI_TEST_EQUALS( Vector2( 1.0f, 2.0f ), FitInside( Vector2( 1.0f, 2.0f ), Vector2( 10.0f, 20.0f ) ), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2( 1.0f, 0.5f ), FitInside( Vector2( 1.0f, 2.0f ), Vector2( 20.0f, 10.0f ) ), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2( 10.0f, 20.0f ), FitInside( Vector2( 10.0f, 20.0f ), Vector2( 1.0f, 2.0f ) ), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2( 10.0f, 10.0f ), FitInside( Vector2( 100.0f, 10.0f ), Vector2( 10.0f, 10.0f ) ), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2( 20.0f, 10.0f ), FitInside( Vector2( 20.0f, 20.0f ), Vector2( 10.0f, 5.0f ) ), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2( 10.0f, 20.0f ), FitInside( Vector2( 20.0f, 20.0f ), Vector2( 5.0f, 10.0f ) ), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliVector2FitScaleToFill(void) +{ + DALI_TEST_EQUALS( Vector2( 1.0f, 2.0f ), FitScaleToFill( Vector2( 1.0f, 2.0f ), Vector2( 10.0f, 20.0f ) ), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2( 1.0f, 2.0f ), FitScaleToFill( Vector2( 10.0f, 20.0f ), Vector2( 1.0f, 2.0f ) ), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2( 10.0f, 1.0f ), FitScaleToFill( Vector2( 100.0f, 10.0f ), Vector2( 10.0f, 10.0f ) ), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2( 5.0f, 5.0f ), FitScaleToFill( Vector2( 20.0f, 20.0f ), Vector2( 10.0f, 5.0f ) ), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2( 5.0f, 5.0f ), FitScaleToFill( Vector2( 20.0f, 20.0f ), Vector2( 5.0f, 10.0f ) ), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2( 20.0f, 40.0f ), FitScaleToFill( Vector2( 20.0f, 0.0f ), Vector2( 5.0f, 10.0f ) ), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2( 10.0f, 20.0f ), FitScaleToFill( Vector2( 0.0f, 20.0f ), Vector2( 5.0f, 10.0f ) ), TEST_LOCATION ); + END_TEST; +} + +int UtcDaliVector2ShrinkInside(void) +{ + DALI_TEST_EQUALS( Vector2( 1.0f, 2.0f ), ShrinkInside( Vector2( 1.0f, 2.0f ), Vector2( 10.0f, 20.0f ) ), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2( 1.0f, 2.0f ), ShrinkInside( Vector2( 10.0f, 20.0f ), Vector2( 1.0f, 2.0f ) ), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2( 10.0f, 10.0f ), ShrinkInside( Vector2( 100.0f, 10.0f ), Vector2( 10.0f, 10.0f ) ), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2( 10.0f, 5.0f ), ShrinkInside( Vector2( 20.0f, 20.0f ), Vector2( 10.0f, 5.0f ) ), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2( 5.0f, 10.0f ), ShrinkInside( Vector2( 20.0f, 20.0f ), Vector2( 5.0f, 10.0f ) ), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2( 5.0f, 10.0f ), ShrinkInside( Vector2( 10.0f, 10.0f ), Vector2( 10.0f, 20.0f ) ), TEST_LOCATION ); + DALI_TEST_EQUALS( Vector2( 10.0f, 5.0f ), ShrinkInside( Vector2( 10.0f, 10.0f ), Vector2( 20.0f, 10.0f ) ), TEST_LOCATION ); + END_TEST; +} + + + + +int UtcDaliVector2Add(void) +{ + Vector2 v0(1.0f, 2.0f); + Vector2 v1(10.0f, 20.0f); + Vector2 r0(11.0f, 22.0f); + + Vector2 v2 = v0+v1; + DALI_TEST_EQUALS(v2, r0, TEST_LOCATION); + + v0 += v1; + DALI_TEST_EQUALS(v0, r0, TEST_LOCATION); + END_TEST; +} + + +// Subtract +int UtcDaliVector2Subtract(void) +{ + Vector2 v0(11.0f, 22.0f); + Vector2 v1(10.0f, 20.0f); + Vector2 r0(1.0f, 2.0f); + + Vector2 v2 = v0-v1; + DALI_TEST_EQUALS(v2, r0, TEST_LOCATION); + + v0 -= v1; + DALI_TEST_EQUALS(v0, r0, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliVector2Negate(void) +{ + Vector2 v1(10.0f, 20.0f); + Vector2 r0(-10.0f, -20.0f); + + Vector2 v2 = -v1; + DALI_TEST_EQUALS(v2, r0, TEST_LOCATION); + END_TEST; +} + + +// Multiply +int UtcDaliVector2Multiply(void) +{ + Vector2 v0(2.0f, 3.0f); + Vector2 v1(10.0f, 20.0f); + Vector2 r0(20.0f, 60.0f); + + Vector2 v2 = v0 * v1; + DALI_TEST_EQUALS(v2, r0, TEST_LOCATION); + + v0 *= v1; + DALI_TEST_EQUALS(v0, r0, TEST_LOCATION); + END_TEST; +} + +// Divide +int UtcDaliVector2Divide(void) +{ + Vector2 v0(1.0f, 1.0f); + Vector2 v1(2.0f, 3.0f); + Vector2 v2(4.0f, 9.0f); + + DALI_TEST_EQUALS( v0/v0, v0, TEST_LOCATION); + DALI_TEST_EQUALS( v1/v0, v1, TEST_LOCATION); + DALI_TEST_EQUALS( v1/v1, v0, TEST_LOCATION); + DALI_TEST_EQUALS( v2/v1, v1, TEST_LOCATION); + + Vector2 v4(v0); + v4 /= v0; + DALI_TEST_EQUALS(v4, v0, TEST_LOCATION); + + Vector2 v5(v1); + v5 /= v0; + DALI_TEST_EQUALS(v5, v1, TEST_LOCATION); + + Vector2 v6(v1); + v6 /= v6; + DALI_TEST_EQUALS(v6, v0, TEST_LOCATION); + + v2 /= v1; + DALI_TEST_EQUALS(v2, v1, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliVector2Scale(void) +{ + Vector2 v0(2.0f, 4.0f); + const Vector2 r0(20.0f, 40.0f); + const Vector2 r1(10.0f, 20.0f); + const Vector2 r2( 1.0f, 2.0f); + const Vector2 r3(2.0f, 4.0f); + + Vector2 v2 = v0 * 10.0f; + DALI_TEST_EQUALS(v2, r0, TEST_LOCATION); + + v0 *= 5.0f; + DALI_TEST_EQUALS(v0, r1, TEST_LOCATION); + + v2 = r0 / 10.0f; + DALI_TEST_EQUALS(v2, r3, TEST_LOCATION); + + v2 = r1; + v2 /= 10.0f; + DALI_TEST_EQUALS(v2, r2, TEST_LOCATION); + END_TEST; +} + +// Equals +int UtcDaliVector2Equals(void) +{ + Vector2 v0(1.0f, 2.0f); + Vector2 v1(1.0f, 2.0f); + + DALI_TEST_CHECK(v0 == v1); + + Vector2 v2 = Vector2(0.0f, 2.0f); + DALI_TEST_CHECK(v0 != v2); + + v2 = Vector2(1.0f, 0.0f); + DALI_TEST_CHECK(v0 != v2); + + v2 = Vector2(1.0f, 77.0f); + DALI_TEST_CHECK(v0 != v2); + + v2 = Vector2(33.0f, 44.0f); + DALI_TEST_CHECK(v0 != v2); + END_TEST; +} + +// Length +int UtcDaliVector2Length(void) +{ + Vector2 v(1.0f, 2.0f); + DALI_TEST_EQUALS(v.Length(), sqrtf(v.x*v.x + v.y*v.y), 0.001f, TEST_LOCATION); + + Vector2 v1(0.0f, 0.0f); + DALI_TEST_EQUALS(v1.Length(), 0.0f, TEST_LOCATION); + END_TEST; +} + +// Length squared +int UtcDaliVector2LengthSquared(void) +{ + Vector2 v(1.0f, 2.0f); + DALI_TEST_EQUALS(v.LengthSquared(), v.x*v.x + v.y*v.y, 0.001f, TEST_LOCATION); + + Vector2 v1(0.0f, 0.0f); + DALI_TEST_EQUALS(v1.LengthSquared(), 0.0f, TEST_LOCATION); + END_TEST; +} + +// Max +int UtcDaliVector2Max(void) +{ + Vector2 v0(2.0f, 1.0f); + Vector2 v1(1.0f, 2.0f); + + DALI_TEST_EQUALS(Max(v0, v1), Vector2(2.0f, 2.0f), 0.01f, TEST_LOCATION); + END_TEST; +} + +// Min +int UtcDaliVector2Min(void) +{ + Vector2 v0(2.0f, 1.0f); + Vector2 v1(1.0f, 2.0f); + + DALI_TEST_EQUALS(Min(v0, v1), Vector2(1.0f, 1.0f), 0.01f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliVector2Clamp(void) +{ + tet_infoline("Testing Dali::Vector2::Clamp( const Vector2& v, const float& min, const float& max )"); + + Vector2 v0(2.0f, 0.8f); + Vector2 v1(-1.0f, 2.0f); + + DALI_TEST_EQUALS( Clamp( v0, 0.9f, 1.1f ), Vector2(1.1f, 0.9f), 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( Clamp( v1, 1.0f, 1.0f ), Vector2(1.0f, 1.0f), 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( Clamp( v1, 0.0f, 3.0f ), Vector2(0.0f, 2.0f), 0.01f, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliVector2ClampVector2(void) +{ + tet_infoline("Testing Dali::Vector2::Clamp( const Vector2& v, const Vector2& min, const Vector2& max )"); + + Vector2 v0(2.0f, 0.8f); + Vector2 v1(-1.0f, 2.0f); + Vector2 v2(10.0f, 5.0f); + Vector2 v3(8.0f, 10.0f); + Vector2 v4(4.9f, 5.1f); + Vector2 min(1.0f, 4.0f); + Vector2 max(9.0f, 6.0f); + + v0.Clamp( min, max ); + v1.Clamp( min, max ); + v2.Clamp( min, max ); + v3.Clamp( min, max ); + v4.Clamp( min, max ); + + DALI_TEST_EQUALS( v0, Vector2(2.0f, 4.0f), 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( v1, Vector2(1.0f, 4.0f), 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( v2, Vector2(9.0f, 5.0f), 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( v3, Vector2(8.0f, 6.0f), 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( v4, Vector2(4.9f, 5.1f), 0.01f, TEST_LOCATION ); + END_TEST; +} + +// Normalize +int UtcDaliVector2Normalize(void) +{ + for (float f=0.0f; f<6.0f; f+=1.0f) + { + Vector2 v(cosf(f)*10.0f, cosf(f+1.0f)*10.0f); + v.Normalize(); + DALI_TEST_EQUALS(v.LengthSquared(), 1.0f, 0.001f, TEST_LOCATION); + } + + Vector4 v(0.0f, 0.0f, 0.0f, 1.0f); + v.Normalize(); + DALI_TEST_EQUALS(v.LengthSquared(), 0.0f, 0.00001f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliVector2OperatorSubscript(void) +{ + tet_infoline("Testing Dali::Vector2::operator[]()"); + + Vector2 testVector(1.0f, 2.0f); + + // read array subscripts + DALI_TEST_EQUALS( testVector[0], 1.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( testVector[1], 2.0f, TEST_LOCATION ); + + // write array subscripts/read struct memebers + testVector[0] = 3.0f; + testVector[1] = 4.0f; + + DALI_TEST_EQUALS( testVector.x, 3.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( testVector.y, 4.0f, TEST_LOCATION ); + + // write struct members/read array subscripts + testVector.x = 5.0f; + testVector.y = 6.0f; + + const Vector2 testVector2(3.0f, 4.0f); + const float& x = testVector2[0]; + const float& y = testVector2[1]; + DALI_TEST_EQUALS( x, 3.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( y, 4.0f, TEST_LOCATION ); + + + try + { + float& w = testVector[4]; + if(w==0.0f); + tet_result(TET_FAIL); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT( e, "index < 2", TEST_LOCATION); + } + + try + { + const float& w = testVector2[4]; + if(w==0.0f); + tet_result(TET_FAIL); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT( e, "index < 2" , TEST_LOCATION); + } + + + END_TEST; +} + +int UtcDaliVector2OStreamOperator(void) +{ + std::ostringstream oss; + + Vector2 vector(1, 2); + + oss << vector; + + std::string expectedOutput = "[1, 2]"; + + DALI_TEST_EQUALS( oss.str(), expectedOutput, TEST_LOCATION); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Vector3.cpp b/automated-tests/src/dali/utc-Dali-Vector3.cpp new file mode 100644 index 0000000..38d33f1 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-Vector3.cpp @@ -0,0 +1,601 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; + +void utc_dali_vector3_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_vector3_cleanup(void) +{ + test_return_value = TET_PASS; +} + +int UtcDaliVector3Cons(void) +{ + Vector3 va; + Vector3 vb(Vector2(1.0f, 2.0f)); + Vector3 vc(Vector4(5.63f, 2.31f, 9.83f, 11.23f)); + float array[] = {1.0f, 2.0f, 3.0f}; + Vector3 vd(array); + + DALI_TEST_EQUALS(va.x, 0.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(va.y, 0.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(va.z, 0.0f, 0.001f, TEST_LOCATION); + + DALI_TEST_EQUALS(vb.x, 1.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(vb.y, 2.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(vb.z, 0.0f, 0.001f, TEST_LOCATION); + + DALI_TEST_EQUALS(vc.x, 5.63f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(vc.y, 2.31f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(vc.z, 9.83f, 0.001f, TEST_LOCATION); + + DALI_TEST_EQUALS(vd.x, 1.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(vd.y, 2.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(vd.z, 3.0f, 0.001f, TEST_LOCATION); + + Vector3* vecPtr = new Vector3(1.0f, 2.0f, 3.0f); + DALI_TEST_CHECK( vecPtr != NULL ); + DALI_TEST_EQUALS(vecPtr->x, 1.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(vecPtr->y, 2.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(vecPtr->z, 3.0f, 0.001f, TEST_LOCATION); + + Vector3 vec3; + vec3 = *vecPtr; + delete vecPtr; + + Vector3 vec3b(vd); + DALI_TEST_EQUALS(vec3b.x, 1.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(vec3b.y, 2.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(vec3b.z, 3.0f, 0.001f, TEST_LOCATION); + + Vector3 vec3c = vd; + DALI_TEST_EQUALS(vec3c.x, 1.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(vec3c.y, 2.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(vec3c.z, 3.0f, 0.001f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliVector3Assign(void) +{ + Vector3 v0; + const float array[] = { 1.0f, 2.0f, 3.0f }; + v0 = (const float*)array; + + DALI_TEST_EQUALS(v0.x, 1.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(v0.y, 2.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(v0.z, 3.0f, 0.001f, TEST_LOCATION); + + Vector2 vec2_q(1.0f, 2.0f); + Vector3 vec3a; + vec3a = vec2_q; + + DALI_TEST_EQUALS(vec3a.x, 1.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(vec3a.y, 2.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(vec3a.z, 0.0f, 0.001f, TEST_LOCATION); + + Vector4 vec4_q(4.0f, 3.0f, 2.0f, 1.0f); + Vector3 vec3b; + vec3b = vec4_q; + + DALI_TEST_EQUALS(vec3b.x, 4.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(vec3b.y, 3.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(vec3b.z, 2.0f, 0.001f, TEST_LOCATION); + END_TEST; +} + + +// Add +int UtcDaliVector3Add(void) +{ + Vector3 v0(1.0f, 2.0f, 3.0f); + Vector3 v1(10.0f, 20.0f, 30.0f); + Vector3 r0(11.0f, 22.0f, 33.0f); + + Vector3 v2 = v0+v1; + DALI_TEST_EQUALS(v2, r0, TEST_LOCATION); + + v0 += v1; + DALI_TEST_EQUALS(v0, r0, TEST_LOCATION); + END_TEST; +} + +// Constants +int UtcDaliVector3Constants(void) +{ + Vector3 va = Vector3::ZERO; + Vector3 vb = Vector3::ONE; + Vector3 vc = Vector3::XAXIS; + + DALI_TEST_EQUALS(va.x, 0.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(va.y, 0.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(va.z, 0.0f, 0.001f, TEST_LOCATION); + + DALI_TEST_EQUALS(vb.x, 1.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(vb.y, 1.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(vb.z, 1.0f, 0.001f, TEST_LOCATION); + + DALI_TEST_EQUALS(vc.x, 1.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(vc.y, 0.0f, 0.001f, TEST_LOCATION); + DALI_TEST_EQUALS(vc.z, 0.0f, 0.001f, TEST_LOCATION); + END_TEST; +} + +// Cross +int UtcDaliVector3Cross(void) +{ + DALI_TEST_EQUALS(Vector3::XAXIS.Cross(Vector3::YAXIS), Vector3::ZAXIS, 0.0001f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector3::YAXIS.Cross(Vector3::ZAXIS), Vector3::XAXIS, 0.0001f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector3::ZAXIS.Cross(Vector3::XAXIS), Vector3::YAXIS, 0.0001f, TEST_LOCATION); + + DALI_TEST_EQUALS(Vector3::XAXIS.Cross(Vector3::ZAXIS), -Vector3::YAXIS, 0.0001f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector3::YAXIS.Cross(Vector3::XAXIS), -Vector3::ZAXIS, 0.0001f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector3::ZAXIS.Cross(Vector3::YAXIS), -Vector3::XAXIS, 0.0001f, TEST_LOCATION); + + Vector3 v0(2.0f, 3.0f, 4.0f); + Vector3 v1(10.0f, 20.0f, 30.0f); + Vector3 result( (v0.y * v1.z) - (v0.z * v1.y), + (v0.z * v1.x) - (v0.x * v1.z), + (v0.x * v1.y) - (v0.y * v1.x) ); + + + DALI_TEST_EQUALS(v0.Cross(v1), result, 0.001f, TEST_LOCATION); + END_TEST; +} + +// Dot +int UtcDaliVector3Dot(void) +{ + DALI_TEST_EQUALS(Vector3::XAXIS.Dot(Vector3::YAXIS), 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector3::XAXIS.Dot(Vector3::ZAXIS), 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector3::XAXIS.Dot(Vector3::XAXIS), 1.0f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector3::YAXIS.Dot(Vector3::YAXIS), 1.0f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector3::ZAXIS.Dot(Vector3::ZAXIS), 1.0f, TEST_LOCATION); + + DALI_TEST_EQUALS(Vector3(1.0f, 0.0f, 0.0f).Dot(Vector3(1.0f, 0.0f, 0.0f)), 1.0f, TEST_LOCATION); + + for (float x = 0; x<6.0f; x+=1.0f) + { + Vector3 v0(cosf(x), sinf(x), 0.0f); + Vector3 v1(sinf(x), -cosf(x), 0.0f); + DALI_TEST_EQUALS(v0.Dot(v1), 0.0f, 0.0001f, TEST_LOCATION); + DALI_TEST_EQUALS(v0.Dot(v0), 1.0f, 0.0001f, TEST_LOCATION); + + v0 = Vector3(cosf(x), 0.0f, sinf(x)); + v1 = Vector3(sinf(x), 0.0f, -cosf(x)); + DALI_TEST_EQUALS(v0.Dot(v0), 1.0f, 0.0001f, TEST_LOCATION); + } + + Vector3 v0 = Vector3(12.0f, 7.0f, 9.0f); + v0.Normalize(); + + Vector3 v1 = v0 * 2.0f; + DALI_TEST_EQUALS(v0.Dot(v1), 2.0f, 0.001f, TEST_LOCATION); + END_TEST; +} + + +// Equals +int UtcDaliVector3Equals(void) +{ + Vector3 v0(1.0f, 2.0f, 3.0f); + Vector3 v1(1.0f, 2.0f, 3.0f); + + DALI_TEST_CHECK(v0 == v1); + + Vector3 v2 = Vector3(0.0f, 2.0f, 3.0f); + DALI_TEST_CHECK(v0 != v2); + + v2 = Vector3(1.0f, 0.0f, 3.0f); + DALI_TEST_CHECK(v0 != v2); + + v2 = Vector3(1.0f, 2.0f, 0.0f); + DALI_TEST_CHECK(v0 != v2); + + v2 = Vector3(11.0f, 22.0f, 33.0f); + DALI_TEST_CHECK(v0 != v2); + END_TEST; +} + + +// Length +int UtcDaliVector3Length(void) +{ + Vector3 v(1.0f, 2.0f, 3.0f); + DALI_TEST_EQUALS(v.Length(), sqrtf(v.x*v.x + v.y*v.y + v.z*v.z), 0.001f, TEST_LOCATION); + + Vector3 v1(0.0f, 0.0f, 0.0f); + DALI_TEST_EQUALS(v1.Length(), 0.0f, TEST_LOCATION); + END_TEST; +} + +// Length squared +int UtcDaliVector3LengthSquared(void) +{ + Vector3 v(1.0f, 2.0f, 3.0f); + DALI_TEST_EQUALS(v.LengthSquared(), v.x*v.x + v.y*v.y + v.z*v.z, 0.001f, TEST_LOCATION); + + Vector3 v1(0.0f, 0.0f, 0.0f); + DALI_TEST_EQUALS(v1.LengthSquared(), 0.0f, TEST_LOCATION); + END_TEST; +} + +// Max +int UtcDaliVector3Max(void) +{ + Vector3 v0(2.0f, 1.0f, 3.0f); + Vector3 v1(1.0f, 2.0f, 3.0f); + + DALI_TEST_EQUALS(Max(v0, v1), Vector3(2.0f, 2.0f, 3.0f), 0.01f, TEST_LOCATION); + END_TEST; +} + +// Min +int UtcDaliVector3Min(void) +{ + Vector3 v0(2.0f, 2.0f, 1.0f); + Vector3 v1(1.0f, 1.0f, 2.0f); + + DALI_TEST_EQUALS(Min(v0, v1), Vector3(1.0f, 1.0f, 1.0f), 0.01f, TEST_LOCATION); + END_TEST; +} + +int UtcDaliVector3Clamp(void) +{ + tet_infoline("Testing Dali::Vector3::Clamp()"); + + Vector3 v0( 2.0f, 1.0f, 0.0f ); + Vector3 v1( -1.0f, 2.0f, 1.0f ); + + DALI_TEST_EQUALS( Clamp( v0, 0.9f, 1.1f ), Vector3(1.1f, 1.0f, 0.9f), 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( Clamp( v1, 1.0f, 1.0f ), Vector3(1.0f, 1.0f, 1.0f), 0.01f, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliVector3ClampVector3(void) +{ + tet_infoline("Testing Dali::Vector3::Clamp( const Vector3& v, const Vector3& min, const Vector3& max )"); + + Vector3 v0(2.0f, 0.8f, 0.0f); + Vector3 v1(-1.0f, 2.0f, 10.0f); + Vector3 v2(10.0f, 5.0f, 0.0f); + Vector3 v3(8.0f, 10.0f, 5.0f); + Vector3 v4(4.9f, 5.1f, 10.0f); + Vector3 min(1.0f, 4.0f, 1.5f); + Vector3 max(9.0f, 6.0f, 8.0f); + + v0.Clamp( min, max ); + v1.Clamp( min, max ); + v2.Clamp( min, max ); + v3.Clamp( min, max ); + v4.Clamp( min, max ); + + DALI_TEST_EQUALS( v0, Vector3(2.0f, 4.0f, 1.5f), 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( v1, Vector3(1.0f, 4.0f, 8.0f), 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( v2, Vector3(9.0f, 5.0f, 1.5f), 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( v3, Vector3(8.0f, 6.0f, 5.0f), 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( v4, Vector3(4.9f, 5.1f, 8.0f), 0.01f, TEST_LOCATION ); + END_TEST; +} + +// Multiply +int UtcDaliVector3Multiply(void) +{ + Vector3 v0(2.0f, 3.0f, 4.0f); + Vector3 v1(10.0f, 20.0f, 30.0f); + Vector3 r0(20.0f, 60.0f, 120.0f); + + Vector3 v2 = v0 * v1; + DALI_TEST_EQUALS(v2, r0, TEST_LOCATION); + + v0 *= v1; + DALI_TEST_EQUALS(v0, r0, TEST_LOCATION); + END_TEST; +} + + +// Divide +int UtcDaliVector3Divide(void) +{ + Vector3 v0(1.0f, 1.0f, 1.0f); + Vector3 v1(2.0f, 3.0f, 5.0f); + Vector3 v2(4.0f, 9.0f, 25.0f); + + DALI_TEST_EQUALS( v0/v0, v0, TEST_LOCATION); + DALI_TEST_EQUALS( v1/v0, v1, TEST_LOCATION); + DALI_TEST_EQUALS( v1/v1, v0, TEST_LOCATION); + DALI_TEST_EQUALS( v2/v1, v1, TEST_LOCATION); + + Vector3 v4(v0); + v4 /= v0; + DALI_TEST_EQUALS(v4, v0, TEST_LOCATION); + + Vector3 v5(v1); + v5 /= v0; + DALI_TEST_EQUALS(v5, v1, TEST_LOCATION); + + Vector3 v6(v1); + v6 /= v6; + DALI_TEST_EQUALS(v6, v0, TEST_LOCATION); + + v2 /= v1; + DALI_TEST_EQUALS(v2, v1, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliVector3Scale(void) +{ + Vector3 v0(2.0f, 4.0f, 8.0f); + const Vector3 r0(20.0f, 40.0f, 80.0f); + const Vector3 r1(10.0f, 20.0f, 40.0f); + const Vector3 r2( 1.0f, 2.0f, 4.0f); + const Vector3 r3(2.0f, 4.0f, 8.0f); + + Vector3 v2 = v0 * 10.0f; + DALI_TEST_EQUALS(v2, r0, TEST_LOCATION); + + v0 *= 5.0f; + DALI_TEST_EQUALS(v0, r1, TEST_LOCATION); + + v2 = r0 / 10.0f; + DALI_TEST_EQUALS(v2, r3, TEST_LOCATION); + + v2 = r1; + v2 /= 10.0f; + DALI_TEST_EQUALS(v2, r2, TEST_LOCATION); + END_TEST; +} + + + +// Normalize +int UtcDaliVector3Normalize(void) +{ + for (float f=0.0f; f<6.0f; f+=1.0f) + { + Vector3 v(cosf(f)*10.0f, cosf(f+1.0f)*10.0f, cosf(f+2.0f)*10.0f); + v.Normalize(); + DALI_TEST_EQUALS(v.LengthSquared(), 1.0f, 0.001f, TEST_LOCATION); + } + + Vector3 v(0.0f, 0.0f, 0.0f); + v.Normalize(); + DALI_TEST_EQUALS(v.LengthSquared(), 0.0f, 0.00001f, TEST_LOCATION); + END_TEST; +} + +// Subtract +int UtcDaliVector3Subtract(void) +{ + Vector3 v0(11.0f, 22.0f, 33.0f); + Vector3 v1(10.0f, 20.0f, 30.0f); + Vector3 r0(1.0f, 2.0f, 3.0f); + + Vector3 v2 = v0-v1; + DALI_TEST_EQUALS(v2, r0, TEST_LOCATION); + + v0 -= v1; + DALI_TEST_EQUALS(v0, r0, TEST_LOCATION); + END_TEST; +} + +int UtcDaliVector3OperatorSubscript(void) +{ + Vector3 testVector(1.0f, 2.0f, 3.0f); + + // read array subscripts + DALI_TEST_EQUALS( testVector[0], 1.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( testVector[1], 2.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( testVector[2], 3.0f, TEST_LOCATION ); + + // write array subscripts/read struct memebers + testVector[0] = 4.0f; + testVector[1] = 5.0f; + testVector[2] = 6.0f; + + DALI_TEST_EQUALS( testVector.x, 4.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( testVector.y, 5.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( testVector.z, 6.0f, TEST_LOCATION ); + + // write struct members/read array subscripts + testVector.x = 7.0f; + testVector.y = 8.0f; + testVector.z = 9.0f; + + DALI_TEST_EQUALS( testVector[0], 7.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( testVector[1], 8.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( testVector[2], 9.0f, TEST_LOCATION ); + + // write struct members/read array subscripts + const Vector3 testVector2(1.0f, 2.0f, 3.0f); + const float& x = testVector2[0]; + const float& y = testVector2[1]; + const float& z ( testVector2[2] ); + + DALI_TEST_EQUALS( x, 1.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( y, 2.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( z, 3.0f, TEST_LOCATION ); + + try + { + float& w = testVector[4]; + if(w==0.0f); + tet_result(TET_FAIL); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT( e, "index < 3", TEST_LOCATION ); + } + + try + { + const float& w = testVector2[4]; + if(w==0.0f); + tet_result(TET_FAIL); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT(e, "index < 3", TEST_LOCATION); + } + + END_TEST; +} + +int UtcDaliVector3OStreamOperator(void) +{ + std::ostringstream oss; + + Vector3 vector(1, 2, 3); + + oss << vector; + + std::string expectedOutput = "[1, 2, 3]"; + + DALI_TEST_EQUALS( oss.str(), expectedOutput, TEST_LOCATION); + END_TEST; +} + +int UtcDaliVector3Rotate(void) +{ + TestApplication application; + + Vector3 vec3(Vector3::YAXIS); + Quaternion rotation(Math::PI_2, Vector3::ZAXIS); + Vector3 result(-Vector3::XAXIS); + vec3 *= rotation; + DALI_TEST_EQUALS( vec3, result, 0.001, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliVector3AsFloat(void) +{ + float values[] = {0.0f, 1.0f, 2.0f}; + Vector3 v0(values); + + for (int i=0;i<3;++i) + { + DALI_TEST_EQUALS(v0.AsFloat()[i], values[i], TEST_LOCATION); + } + + const Vector3 v1(values); + for (int i=0;i<3;++i) + { + DALI_TEST_EQUALS(v1.AsFloat()[i], values[i], TEST_LOCATION); + } + END_TEST; +} + +int UtcDaliVector3AsVectorXY(void) +{ + float values[] = {0.0f, 1.0f, 2.0f}; + Vector3 v0(values); + const Vector3 v1(5.0f, 10.0f, 15.0f); + // X = 0.0 + // Y = 1.0 + // Z = 2.0 + + DALI_TEST_EQUALS(v0.GetVectorXY().x, values[0], TEST_LOCATION); + DALI_TEST_EQUALS(v0.GetVectorXY().y, values[1], TEST_LOCATION); + + v0.GetVectorXY() = v1.GetVectorYZ(); + // X = y + // Y = z + // Z = 2.0 + DALI_TEST_EQUALS(v0.GetVectorXY().x, v1.y, TEST_LOCATION); + DALI_TEST_EQUALS(v0.GetVectorXY().y, v1.z, TEST_LOCATION); + DALI_TEST_EQUALS(v0.z, values[2], TEST_LOCATION); + + v0.GetVectorYZ() = v1.GetVectorXY(); + // X = y + // Y = x + // Z = y + DALI_TEST_EQUALS(v0.x, v1.y, TEST_LOCATION); + DALI_TEST_EQUALS(v0.y, v1.x, TEST_LOCATION); + DALI_TEST_EQUALS(v0.z, v1.y, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliVector3FitKeepAspectRatio(void) +{ + TestApplication application; + Vector3 target(10.0f, 20.0f, 30.0f); + Vector3 source1(1.0f, 2.0f, 3.0f); + Vector3 source2(1.0f, 1.0f, 1.0f); + + DALI_TEST_EQUALS( FitKeepAspectRatio( target, target ), Vector3(1.0f, 1.0f, 1.0f), 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( FitKeepAspectRatio( target, source1 ), Vector3(10.0f, 10.0f, 10.0f), 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( FitKeepAspectRatio( target, source2 ), Vector3(10.0f, 10.0f, 10.0f), 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( FitKeepAspectRatio( source2, target ), Vector3(0.0333f, 0.0333f, 0.0333f), 0.001, TEST_LOCATION ); + END_TEST; +} + +int UtcDaliVector3FillKeepAspectRatio(void) +{ + TestApplication application; + Vector3 target(10.0f, 20.0f, 30.0f); + Vector3 source1(1.0f, 2.0f, 3.0f); + Vector3 source2(1.0f, 1.0f, 1.0f); + + DALI_TEST_EQUALS( FillKeepAspectRatio( target, target ), Vector3(1.0f, 1.0f, 1.0f), 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( FillKeepAspectRatio( target, source1 ), Vector3(10.0f, 10.0f, 10.0f), 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( FillKeepAspectRatio( target, source2 ), Vector3(30.0f, 30.0f, 30.0f), 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( FillKeepAspectRatio( source2, target ), Vector3(0.1f, 0.1f, 0.1f), 0.001, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliVector3FillXYKeepAspectRatio(void) +{ + TestApplication application; + Vector3 target(10.0f, 20.0f, 30.0f); + Vector3 source1(1.0f, 2.0f, 3.0f); + Vector3 source2(1.0f, 1.0f, 1.0f); + + DALI_TEST_EQUALS( FillXYKeepAspectRatio( target, target ), Vector3(1.0f, 1.0f, 1.0f), 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( FillXYKeepAspectRatio( target, source1 ), Vector3(10.0f, 10.0f, 10.0f), 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( FillXYKeepAspectRatio( target, source2 ), Vector3(20.0f, 20.0f, 20.0f), 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( FillXYKeepAspectRatio( source2, target ), Vector3(0.1f, 0.1f, 0.1f), 0.001, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliVector3ShrinkInsideKeepAspectRatio(void) +{ + TestApplication application; + Vector3 target(1.0f, 2.0f, 3.0f); + Vector3 source1(10.0f, 20.0f, 30.0f); + Vector3 source2(10.0f, 10.0f, 10.0f); + + DALI_TEST_EQUALS( ShrinkInsideKeepAspectRatio( target, target ), Vector3(1.0f, 1.0f, 1.0f), 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( ShrinkInsideKeepAspectRatio( target, source1 ), Vector3(0.1f, 0.1f, 0.1f), 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( ShrinkInsideKeepAspectRatio( target, source2 ), Vector3(0.1f, 0.1f, 0.1f), 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( ShrinkInsideKeepAspectRatio( source2, target ), Vector3::ONE, 0.001, TEST_LOCATION ); + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Vector4.cpp b/automated-tests/src/dali/utc-Dali-Vector4.cpp new file mode 100644 index 0000000..5763cf8 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-Vector4.cpp @@ -0,0 +1,532 @@ +// +// Copyright (c) 2014 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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; + +void utc_dali_vector4_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_vector4_cleanup(void) +{ + test_return_value = TET_PASS; +} + + + +// Constructor +int UtcDaliVector4Vector4(void) +{ + float f[] = {2.0f, 3.0f, 4.0f, 5.0f}; + Vector2 vec2(1.0f, 2.0f); + Vector3 vec3(1.0f, 2.0f, 3.0f); + Vector4 v0(f); + Vector4 v1(f[0], f[1], f[2], f[3]); + Vector4 v2(v0); + Vector4 v3; + v3 = (const float*) f; + Vector4 v4(vec2); + Vector4 v5(vec3); + + DALI_TEST_EQUALS(v0, v1, TEST_LOCATION); + DALI_TEST_EQUALS(v0, v2, TEST_LOCATION); + DALI_TEST_EQUALS(v3, v0, TEST_LOCATION); + DALI_TEST_EQUALS(v4, Vector4(1.0f, 2.0f, 0.0f, 0.0f), TEST_LOCATION); + DALI_TEST_EQUALS(v5, Vector4(1.0f, 2.0f, 3.0f, 0.0f), TEST_LOCATION); + DALI_TEST_CHECK(v0 == v1); + + v1 = vec2; + v2 = vec3; + DALI_TEST_EQUALS(v1.x, 1.0f, TEST_LOCATION); + DALI_TEST_EQUALS(v1.y, 2.0f, TEST_LOCATION); + DALI_TEST_EQUALS(v2.x, 1.0f, TEST_LOCATION); + DALI_TEST_EQUALS(v2.y, 2.0f, TEST_LOCATION); + DALI_TEST_EQUALS(v2.z, 3.0f, TEST_LOCATION); + END_TEST; +} + +// Add +int UtcDaliVector4Add(void) +{ + Vector4 v0(1.0f, 2.0f, 3.0f, 4.0f); + Vector4 v1(10.0f, 20.0f, 30.0f, 40.0f); + Vector4 r0(11.0f, 22.0f, 33.0f, 44.0f); + + Vector4 v2 = v0+v1; + DALI_TEST_EQUALS(v2, r0, TEST_LOCATION); + + v0 += v1; + DALI_TEST_EQUALS(v0, r0, TEST_LOCATION); + END_TEST; +} + +// Constants +int UtcDaliVector4Constants(void) +{ + float f[] = {2.0f, 3.0f, 4.0f, 5.0f}; + Vector4 v0(f); + Vector4 v1(f[0], f[1], f[2], f[3]); + Vector4 v2(v0); + + DALI_TEST_EQUALS(v0, v1, TEST_LOCATION); + DALI_TEST_EQUALS(v0, v2, TEST_LOCATION); + DALI_TEST_CHECK(v0 == v1); + END_TEST; +} + +// Cross +int UtcDaliVector4Cross(void) +{ + DALI_TEST_EQUALS(Vector4::XAXIS.Cross(Vector4::YAXIS), Vector4::ZAXIS, 0.0001f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector4::YAXIS.Cross(Vector4::ZAXIS), Vector4::XAXIS, 0.0001f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector4::ZAXIS.Cross(Vector4::XAXIS), Vector4::YAXIS, 0.0001f, TEST_LOCATION); + + DALI_TEST_EQUALS(Vector4::XAXIS.Cross(Vector4::ZAXIS), -Vector4::YAXIS, 0.0001f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector4::YAXIS.Cross(Vector4::XAXIS), -Vector4::ZAXIS, 0.0001f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector4::ZAXIS.Cross(Vector4::YAXIS), -Vector4::XAXIS, 0.0001f, TEST_LOCATION); + + Vector4 v0(2.0f, 3.0f, 4.0f, 5.0f); + Vector4 v1(10.0f, 20.0f, 30.0f, 40.0f); + Vector4 result( (v0.y * v1.z) - (v0.z * v1.y), + (v0.z * v1.x) - (v0.x * v1.z), + (v0.x * v1.y) - (v0.y * v1.x), + 0.0f); + + DALI_TEST_EQUALS(v0.Cross(v1), result, 0.001f, TEST_LOCATION); + END_TEST; +} + +// Dot +int UtcDaliVector4Dot(void) +{ + DALI_TEST_EQUALS(Vector4::XAXIS.Dot(Vector4::YAXIS), 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector4::XAXIS.Dot(Vector4::ZAXIS), 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector4::XAXIS.Dot(Vector4::XAXIS), 1.0f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector4::YAXIS.Dot(Vector4::YAXIS), 1.0f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector4::ZAXIS.Dot(Vector4::ZAXIS), 1.0f, TEST_LOCATION); + + DALI_TEST_EQUALS(Vector4(1.0f, 0.0f, 0.0f, 1.0f).Dot(Vector4(1.0f, 0.0f, 0.0f, 1.0f)), 1.0f, TEST_LOCATION); + + // Test v0 . v0 and v0 . v1 (v1 is always 90 degrees out of phase with v0) + for (float x = 0; x<6.0f; x+=1.0f) + { + // vectors rotating in the XY plane. + Vector4 v0(cosf(x), sinf(x), 0.0f, 1.0f); + Vector4 v1(sinf(x), -cosf(x), 0.0f, 1.0f); + DALI_TEST_EQUALS(v0.Dot(v1), 0.0f, 0.0001f, TEST_LOCATION); + DALI_TEST_EQUALS(v0.Dot(v0), 1.0f, 0.0001f, TEST_LOCATION); + + // vectors rotating in the XZ plane. + v0 = Vector4(cosf(x), 0.0f, sinf(x), 0.0f); + v1 = Vector4(sinf(x), 0.0f, -cosf(x), 0.0f); + DALI_TEST_EQUALS(v0.Dot(v1), 0.0f, 0.0001f, TEST_LOCATION); + DALI_TEST_EQUALS(v0.Dot(v0), 1.0f, 0.0001f, TEST_LOCATION); + } + + Vector4 v0 = Vector4(12.0f, 7.0f, 9.0f, 14.0f); + v0.Normalize(); + + Vector4 v1 = v0 * 2.0f; + DALI_TEST_EQUALS(v0.Dot(v1), 2.0f, 0.001f, TEST_LOCATION); + END_TEST; +} + +// Dot (with vector3) +int UtcDaliVector4DotVector3(void) +{ + DALI_TEST_EQUALS(Vector4::XAXIS.Dot(Vector3::YAXIS), 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector4::XAXIS.Dot(Vector3::ZAXIS), 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector4::XAXIS.Dot(Vector3::XAXIS), 1.0f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector4::YAXIS.Dot(Vector3::YAXIS), 1.0f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector4::ZAXIS.Dot(Vector3::ZAXIS), 1.0f, TEST_LOCATION); + + DALI_TEST_EQUALS(Vector4(1.0f, 0.0f, 0.0f, 1.0f).Dot(Vector3(1.0f, 0.0f, 0.0f)), 1.0f, TEST_LOCATION); + + // Test v0 . v0b and v0 . v1 (v1 is always 90 degrees out of phase with v0) + for (float x = 0; x<6.0f; x+=1.0f) + { + // vectors rotating in the XY plane. + Vector4 v0(cosf(x), sinf(x), 0.0f, 1.0f); + Vector3 v0b(cosf(x), sinf(x), 0.0f); + Vector3 v1(sinf(x), -cosf(x), 0.0f); + DALI_TEST_EQUALS(v0.Dot(v1), 0.0f, 0.0001f, TEST_LOCATION); + DALI_TEST_EQUALS(v0.Dot(v0b), 1.0f, 0.0001f, TEST_LOCATION); + + // vectors rotating in the XZ plane. + v0 = Vector4(cosf(x), 0.0f, sinf(x), 0.0f); + v0b = Vector3(cosf(x), 0.0f, sinf(x)); + v1 = Vector3(sinf(x), 0.0f, -cosf(x)); + DALI_TEST_EQUALS(v0.Dot(v1), 0.0f, 0.0001f, TEST_LOCATION); + DALI_TEST_EQUALS(v0.Dot(v0b), 1.0f, 0.0001f, TEST_LOCATION); + } + + Vector4 v0 = Vector4(12.0f, 7.0f, 9.0f, 14.0f); + v0.Normalize(); + + Vector3 v1(v0 * 2.0f); + DALI_TEST_EQUALS(v0.Dot(v1), 2.0f, 0.001f, TEST_LOCATION); + END_TEST; +} + +// Dot4 +int UtcDaliVector4Dot4(void) +{ + DALI_TEST_EQUALS(Vector4::XAXIS.Dot4(Vector4::YAXIS), 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector4::XAXIS.Dot4(Vector4::ZAXIS), 0.0f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector4::YAXIS.Dot4(Vector4::ZAXIS), 0.0f, TEST_LOCATION); + + DALI_TEST_EQUALS(Vector4::XAXIS.Dot4(Vector4::XAXIS), 1.0f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector4::YAXIS.Dot4(Vector4::YAXIS), 1.0f, TEST_LOCATION); + DALI_TEST_EQUALS(Vector4::ZAXIS.Dot4(Vector4::ZAXIS), 1.0f, TEST_LOCATION); + + DALI_TEST_EQUALS(Vector4(1.0f, 0.0f, 0.0f, 1.0f).Dot4(Vector4(1.0f, 0.0f, 0.0f, 1.0f)), 2.0f, TEST_LOCATION); + + for (float x = 0; x<6.0f; x+=1.0f) + { + Vector4 v0(cosf(x), sinf(x), 0.0f, 1.0f); + Vector4 v1(sinf(x), -cosf(x), 0.0f, 1.0f); + DALI_TEST_EQUALS(v0.Dot4(v1), 1.0f, 0.0001f, TEST_LOCATION); + DALI_TEST_EQUALS(v0.Dot4(v0), 2.0f, 0.0001f, TEST_LOCATION); + + v0 = Vector4(cosf(x), 0.0f, sinf(x), 0.0f); + v1 = Vector4(sinf(x), 0.0f, -cosf(x), 0.0f); + DALI_TEST_EQUALS(v0.Dot4(v1), 0.0f, 0.0001f, TEST_LOCATION); + DALI_TEST_EQUALS(v0.Dot4(v0), 1.0f, 0.0001f, TEST_LOCATION); + } + + Vector4 v0(12.0f, 7.0f, 9.0f, 3.0f); + v0.Normalize(); + + Vector4 v1 = v0 * 2.0f; + DALI_TEST_EQUALS(v0.Dot4(v1), 2.0f + 3.0f*6.0f, 0.001f, TEST_LOCATION); + END_TEST; +} + +// Equals +int UtcDaliVector4Equals(void) +{ + Vector4 v0(1.0f, 2.0f, 3.0f, 4.0f); + Vector4 v1(1.0f, 2.0f, 3.0f, 4.0f); + + DALI_TEST_CHECK(v0 == v1); + + Vector4 v2 = Vector4(0.0f, 2.0f, 3.0f, 4.0f); + DALI_TEST_CHECK(v0 != v2); + + v2 = Vector4(1.0f, 0.0f, 3.0f, 4.0f); + DALI_TEST_CHECK(v0 != v2); + + v2 = Vector4(1.0f, 2.0f, 0.0f, 4.0f); + DALI_TEST_CHECK(v0 != v2); + + v2 = Vector4(1.0f, 2.0f, 3.0f, 0.0f); + DALI_TEST_CHECK(v0 != v2); + END_TEST; +} + +// Length +int UtcDaliVector4Length(void) +{ + Vector4 v(1.0f, 2.0f, 3.0f, 4.0f); + DALI_TEST_EQUALS(v.Length(), sqrtf(v.x*v.x + v.y*v.y + v.z*v.z), 0.001f, TEST_LOCATION); + + Vector4 v1(0.0f, 0.0f, 0.0f, 0.0f); + DALI_TEST_EQUALS(v1.Length(), 0.0f, TEST_LOCATION); + END_TEST; +} + +// Length squared +int UtcDaliVector4LengthSquared(void) +{ + Vector4 v(1.0f, 2.0f, 3.0f, 4.0f); + DALI_TEST_EQUALS(v.LengthSquared(), v.x*v.x + v.y*v.y + v.z*v.z, 0.001f, TEST_LOCATION); + + Vector4 v1(0.0f, 0.0f, 0.0f, 0.0f); + DALI_TEST_EQUALS(v1.LengthSquared(), 0.0f, TEST_LOCATION); + END_TEST; +} + +// Max +int UtcDaliVector4Max(void) +{ + Vector4 v0(2.0f, 2.0f, 1.0f, 1.0f); + Vector4 v1(1.0f, 1.0f, 2.0f, 2.0f); + + DALI_TEST_EQUALS(Max(v0, v1), Vector4(2.0f, 2.0f, 2.0f, 2.0f), 0.01f, TEST_LOCATION); + END_TEST; +} + +// Min +int UtcDaliVector4Min(void) +{ + Vector4 v0(2.0f, 2.0f, 1.0f, 1.0f); + Vector4 v1(1.0f, 1.0f, 2.0f, 2.0f); + + DALI_TEST_EQUALS(Min(v0, v1), Vector4(1.0f, 1.0f, 1.0f, 1.0f), 0.01f, TEST_LOCATION); + END_TEST; +} + +// Clamp +int UtcDaliVector4Clamp(void) +{ + tet_infoline("Testing Dali::Vector4::Clamp()"); + + Vector4 v0(2.0f, 2.0f, -2.0f, -2.0f); + DALI_TEST_EQUALS(Clamp(v0, -1.0f, 1.0f), Vector4(1.0f, 1.0f, -1.0f, -1.0f), 0.01f, TEST_LOCATION); + + Vector4 v1(1.0f, 0.0f, 0.0f, -1.0f); + DALI_TEST_EQUALS(Clamp(v1, -1.0f, 1.0f), v1, 0.01f, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliVector4ClampVector4(void) +{ + tet_infoline("Testing Dali::Vector4::Clamp( const Vector4& v, const Vector4& min, const Vector4& max )"); + + Vector4 v0(2.0f, 0.8f, 0.0f, 5.0f); + Vector4 v1(-1.0f, 2.0f, 10.0f, -10.0f); + Vector4 v2(10.0f, 5.0f, 0.0f, 10.0f); + Vector4 v3(8.0f, 10.0f, 5.0f, -20.0f); + Vector4 v4(4.9f, 5.1f, 10.0f, 0.0f); + + Vector4 min(1.0f, -2.0f, -8.0f, -16.0f); + Vector4 max(2.0f, 4.0f, 4.0f, -8.0f); + + v0.Clamp( min, max ); + v1.Clamp( min, max ); + v2.Clamp( min, max ); + v3.Clamp( min, max ); + v4.Clamp( min, max ); + + DALI_TEST_EQUALS( v0, Vector4( 2.0f, 0.8f, 0.0f, -8.0f), 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( v1, Vector4( 1.0f, 2.0f, 4.0f, -10.0f), 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( v2, Vector4( 2.0f, 4.0f, 0.0f, -8.0f), 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( v3, Vector4( 2.0f, 4.0f, 4.0f, -16.0f), 0.01f, TEST_LOCATION ); + DALI_TEST_EQUALS( v4, Vector4( 2.0f, 4.0f, 4.0f, -8.0f), 0.01f, TEST_LOCATION ); + END_TEST; +} + +// Multiply +int UtcDaliVector4Multiply(void) +{ + Vector4 v0(2.0f, 3.0f, 4.0f, 5.0f); + Vector4 v1(10.0f, 20.0f, 30.0f, 40.0f); + Vector4 r0(20.0f, 60.0f, 120.0f, 200.0f); + + Vector4 v2 = v0 * v1; + DALI_TEST_EQUALS(v2, r0, TEST_LOCATION); + + v0 *= v1; + DALI_TEST_EQUALS(v0, r0, TEST_LOCATION); + END_TEST; +} + +// Divide +int UtcDaliVector4Divide(void) +{ + Vector4 v0(1.0f, 1.0f, 1.0f, 1.0f); + Vector4 v1(2.0f, 3.0f, 5.0f, 7.0f); + Vector4 v2(4.0f, 9.0f, 25.0f, 49.0f); + + DALI_TEST_EQUALS( v0/v0, v0, TEST_LOCATION); + DALI_TEST_EQUALS( v1/v0, v1, TEST_LOCATION); + DALI_TEST_EQUALS( v1/v1, v0, TEST_LOCATION); + DALI_TEST_EQUALS( v2/v1, v1, TEST_LOCATION); + + Vector4 v4(v0); + v4 /= v0; + DALI_TEST_EQUALS(v4, v0, TEST_LOCATION); + + Vector4 v5(v1); + v5 /= v0; + DALI_TEST_EQUALS(v5, v1, TEST_LOCATION); + + Vector4 v6(v1); + v6 /= v6; + DALI_TEST_EQUALS(v6, v0, TEST_LOCATION); + + v2 /= v1; + DALI_TEST_EQUALS(v2, v1, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliVector4Scale(void) +{ + Vector4 v0(2.0f, 4.0f, 8.0f, 16.0f); + const Vector4 r0(20.0f, 40.0f, 80.0f, 160.0f); + const Vector4 r1(10.0f, 20.0f, 40.0f, 80.0f); + const Vector4 r2( 1.0f, 2.0f, 4.0f, 8.0f); + const Vector4 r3(2.0f, 4.0f, 8.0f, 16.0f); + + Vector4 v2 = v0 * 10.0f; + DALI_TEST_EQUALS(v2, r0, TEST_LOCATION); + + v0 *= 5.0f; + DALI_TEST_EQUALS(v0, r1, TEST_LOCATION); + + v2 = r0 / 10.0f; + DALI_TEST_EQUALS(v2, r3, TEST_LOCATION); + + v2 = r1; + v2 /= 10.0f; + DALI_TEST_EQUALS(v2, r2, TEST_LOCATION); + END_TEST; +} + + +// Normalize +int UtcDaliVector4Normalize(void) +{ + for (float f=0.0f; f<6.0f; f+=1.0f) + { + Vector4 v(cosf(f)*10.0f, cosf(f+1.0f)*10.0f, cosf(f+2.0f)*10.0f, 1.0f); + v.Normalize(); + DALI_TEST_EQUALS(v.LengthSquared(), 1.0f, 0.001f, TEST_LOCATION); + } + + Vector4 v(0.0f, 0.0f, 0.0f, 1.0f); + v.Normalize(); + DALI_TEST_EQUALS(v.LengthSquared(), 0.0f, 0.00001f, TEST_LOCATION); + END_TEST; +} + +// Subtract +int UtcDaliVector4Subtract(void) +{ + Vector4 v0(11.0f, 22.0f, 33.0f, 44.0f); + Vector4 v1(10.0f, 20.0f, 30.0f, 40.0f); + Vector4 r0(1.0f, 2.0f, 3.0f, 4.0f); + + Vector4 v2 = v0-v1; + DALI_TEST_EQUALS(v2, r0, TEST_LOCATION); + + v0 -= v1; + DALI_TEST_EQUALS(v0, r0, TEST_LOCATION); + END_TEST; +} + +int UtcDaliVector4OperatorSubscript(void) +{ + Vector4 testVector(1.0f, 2.0f, 3.0f, 4.0f); + + // read array subscripts + DALI_TEST_EQUALS( testVector[0], 1.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( testVector[1], 2.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( testVector[2], 3.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( testVector[3], 4.0f, TEST_LOCATION ); + + // write array subscripts/read struct memebers + testVector[0] = 5.0f; + testVector[1] = 6.0f; + testVector[2] = 7.0f; + testVector[3] = 8.0f; + + DALI_TEST_EQUALS( testVector.x, 5.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( testVector.y, 6.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( testVector.z, 7.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( testVector.w, 8.0f, TEST_LOCATION ); + + // write struct members/read array subscripts + testVector.x = 9.0f; + testVector.y = 10.0f; + testVector.z = 11.0f; + testVector.w = 12.0f; + + DALI_TEST_EQUALS( testVector[0], 9.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( testVector[1], 10.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( testVector[2], 11.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( testVector[3], 12.0f, TEST_LOCATION ); + + + // write struct members/read array subscripts + const Vector4 testVector2(1.0f, 2.0f, 3.0f, 4.0f); + const float& x = testVector2[0]; + const float& y = testVector2[1]; + const float& z ( testVector2[2] ); + const float& w ( testVector2[3] ); + + DALI_TEST_EQUALS( x, 1.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( y, 2.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( z, 3.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( w, 4.0f, TEST_LOCATION ); + + try + { + float& w = testVector[4]; + if(w==0.0f); + tet_result(TET_FAIL); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT( e, "index < 4", TEST_LOCATION ); + } + + try + { + const float& w = testVector2[4]; + if(w==0.0f); + tet_result(TET_FAIL); + } + catch (Dali::DaliException& e) + { + tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str()); + DALI_TEST_ASSERT( e, "index < 4", TEST_LOCATION ); + } + END_TEST; +} + +int UtcDaliVector4OStreamOperator(void) +{ + std::ostringstream oss; + + Vector4 vector(1.0f, 2.0f, 3.0f, 4.0f); + + oss << vector; + + std::string expectedOutput = "[1, 2, 3, 4]"; + + DALI_TEST_EQUALS( oss.str(), expectedOutput, TEST_LOCATION); + END_TEST; +} + +int UtcDaliVector4AsFloat(void) +{ + float values[] = {0.0f, 1.0f, 2.0f, 3.0f}; + Vector4 v0(values); + + for (int i=0;i<4;++i) + { + DALI_TEST_EQUALS(v0.AsFloat()[i], values[i], TEST_LOCATION); + } + + const Vector4 v1(values); + for (int i=0;i<4;++i) + { + DALI_TEST_EQUALS(v1.AsFloat()[i], values[i], TEST_LOCATION); + } + END_TEST; +} diff --git a/automated-tests/style/application.js b/automated-tests/style/application.js new file mode 100644 index 0000000..147094f --- /dev/null +++ b/automated-tests/style/application.js @@ -0,0 +1,194 @@ +function getScrollTop() { + return f_scrollTop(); +} + +function f_scrollTop() { + return f_filterResults($(window) ? $(window).scrollTop() : 0, + document.documentElement ? document.documentElement.scrollTop : 0, + document.body ? document.body.scrollTop : 0); +} +function f_filterResults(n_win, n_docel, n_body) { + var n_result = n_win ? n_win : 0; + if (n_docel && (!n_result || (n_result > n_docel))) + n_result = n_docel; + return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result; +} + +function setScrollTop() { + $(window) ? $(window).scrollTop(0) : 0; + document.documentElement ? document.documentElement.scrollTop = 0 : 0; + document.body ? document.body.scrollTop = 0 : 0; +} + +function goTopEx() { + $node = $('#goTopBtn'); + if (getScrollTop() > 0) { + $node.show(); + } else { + $node.hide(); + } + + $(window).scroll(function() { + if (getScrollTop() > 0) { + $node.show(); + } else { + $node.hide(); + } + }); + + $node.click(function() { + setScrollTop(); + }); +} + +function drawRatio() { + $('.suite_item').each(function(i, node) { + drawSuiteRatio(node) + }); +} + +$(".see_all").click(function(){ + $("#see_all").show(); + $("#see_fail").hide(); + $("#see_block").hide(); + $("#see_na").hide(); + updateToggles(); + return false; +}); + +$(".see_failed").click(function(){ + $("#see_all").hide(); + $("#see_fail").show(); + $("#see_block").hide(); + $("#see_na").hide(); + updateToggles(); + return false; +}); + +$(".see_blocked").click(function(){ + $("#see_all").hide(); + $("#see_fail").hide(); + $("#see_block").show(); + $("#see_na").hide(); + updateToggles(); + return false; +}); + +$(".see_na").click(function(){ + $("#see_all").hide(); + $("#see_fail").hide(); + $("#see_block").hide(); + $("#see_na").show(); + updateToggles(); + return false; +}); + +$("a.test_case_popup").click(function(){ + var $this = $(this); + Popup.show($this.attr('id')); + return false; +}); + +$(".see_capabilities").click(function(){ + if ($('#capability_table').css('display') == 'none') { + $("#capability_table").show(); + }else{ + $("#capability_table").hide(); + } + return false; +}); + +function drawSuiteRatio(node) { + arrTitle = new Array("Passed", "Failed", "Blocked", "Not Executed"); + var $node = $(node); + var $total = $node.find('.total'); + var $pass = $node.find('.pass'); + var $fail = $node.find('.fail'); + var $block = $node.find('.block'); + var $na = $node.find('.na'); + var $div = $node.find('.RatioGraphic'); + + var total_int = parseInt($total.text()); + var pass_int = parseInt($pass.text()); + var fail_int = parseInt($fail.text()); + var block_int = parseInt($block.text()); + var na_int = parseInt($na.text()); + + var pass_rate = pass_int * 100 / total_int; + var fail_rate = fail_int * 100 / total_int; + var block_rate = block_int * 100 / total_int; + var na_rate = na_int * 100 / total_int; + + var areaWidth = 380; + + var pass_width = areaWidth * pass_rate / 100; + var fail_width = areaWidth * fail_rate / 100; + var block_width = areaWidth * block_rate / 100; + var na_width = areaWidth * na_rate / 100; + + pass_rate = pass_rate.toFixed(2); + fail_rate = fail_rate.toFixed(2); + block_rate = block_rate.toFixed(2); + na_rate = na_rate.toFixed(2); + + var pass_style = "padding:3px 0px 0px 0px;font-size:9pt;height:17px;text-align:center;color:white;font-weight:bold;background:url("./style/blue.jpg");" + var fail_style = "padding:3px 0px 0px 0px;font-size:9pt;height:17px;text-align:center;color:white;font-weight:bold;background:url("./style/red.jpg");" + var block_style = "padding:3px 0px 0px 0px;font-size:9pt;height:17px;text-align:center;color:white;font-weight:bold;background:url("./style/orange.jpg");" + var na_style = "padding:3px 0px 0px 0px;font-size:9pt;height:17px;text-align:center;color:white;font-weight:bold;background:url("./style/gray.jpg");" + + var html = ""; + if (pass_width > 0){ + html += ""; + } + if (fail_width > 0){ + html += ""; + } + if (block_width > 0){ + html += ""; + } + if (na_width > 0){ + html += ""; + } + html += "
"; + if (pass_width > 20){ + html += pass_rate + "%" + } + html += ""; + if (fail_width > 20){ + html += fail_rate + "%" + } + html += ""; + if (block_width > 20){ + html += block_rate + "%" + } + html += ""; + if (na_width > 20){ + html += na_rate + "%" + } + html += "
"; + $div.html(html); +} diff --git a/automated-tests/style/back_top.png b/automated-tests/style/back_top.png new file mode 100644 index 0000000000000000000000000000000000000000..19cbd763108a85a2a7c2954c0172b580a7ccb3b3 GIT binary patch literal 1122 zcmV-o1fBbdP)r0015c0ssI2d=e3600001b5ch_0Itp) z=>Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D1NTWpK~!i%?ODH1 z+dvd{+C)SOk|P+hp$yOgm6jPqnTZ7I)Gcc=!k+>oS=pEnNXbkQnJGvNz!0%z0L2wZ zMoHzq^PTPU`E1|$a1~W&Wgzjp_uhTq`*labaU4TG(~7`{X?0Bdg%Hs6Om!S+dNe&# zjlfhpR}dWy9<9Q;9okCWbT-PlZmxGRYz)9cX@6&K*AzANaPz!$H3sR{X6o*f- z4b*pEk}JU4uwK_a%~5TJF*!IJ;>H6{=Ny#NbHyhHA$=!8ayEz&r+zXFgmpvfhqI?w|FUEqarP39Cc>f-quc3jEdu+U@+o)4zI3^xJNqzVuyjX!~+ej2wH~ z!#?9@^sW!Wb4xOgtua!P|?@BCZTN@<*r+%(Pxu0eDfun^ZQju zN7LD^EJhIPU3jryH{Y7jCsuOOy7#FG2=cVzO?_1 zlUSm)i8WXLUKd>&D<`V6w9Fo>i_18DN0a+_FQn-SR4r6UeIN$n?O7At&)G*bY)h>= zu2H-L&wm;uiKSmp^?}Eaeo3F#ad`p_g zkaTccl`IJj#%&VJotuA|7HL``L^*eEN#;^7^gJj%uZS@*os`d9+Ec76WDhY%&DLh+ zk~gPu{7RB6cX^W=C|O+bb10mksqr3fuC*y~*&4DVsdKGL=1E#fs&zGbAaCd)4J^Z) z7R;>36Esb7Ig3c*^kNl;p$CS#b-#ql94e#c+#y@;{KUk8jLy$r=fXIkvq!3R;o_DW zp;~~4fZ~5Q)UroYk~0FDo}2+zQ?Kb!!!PI6y7%M^u$p?EJ!<&nyjs(fGr(%NP!T_~pF%FN1_9_w2rCUjP6A07*qoM6N<$f@q*1S^xk5 literal 0 HcmV?d00001 diff --git a/automated-tests/style/blue.jpg b/automated-tests/style/blue.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d1db8f724fa76eb1f4efb914d24be05c187109d8 GIT binary patch literal 954 zcmex=eAA-4QK!nlZm zfsvIF3>ct*k%^gwm5rT)lZ%^?ff*tPBq6d$k^&4&jLghTEX=H|EG$4{YJqYLEP|{; ziiVDC!hwnGN`)dujT0AgC_8ODC>nI}gNkudQ4=SZn7D+bl&YG#hNhN@shPQjrIoXb ztDC!rr&n-DXjpheWK?oWYFc_mW>#@YX<2ziWmR)aYg>CqXV;|3Q>IRvK4a#rMT?g# zUABD1%2k^-Z`rzS`;MKv4jn#n^w{weCr@3veC6u3>o;!Rdidz^lc&#~zj*oTTk@SCu%S(U=?B5(qa)L@X*7#m8DOl#UiAmVu=Tcr^qMLDWl0zutf1t zBi|CmOpYi9pn9eTp$4HD$1WIZ_T(D&E;DSK>FjIRYjVusvPR}AiOW61}+8- zMh!;Ip3DVF!4kKUr80XGmjzt*N%l4DF*zlb)n;;8;#Ml}g5=B|uVf*RYM?(BumIgA z)*$QQbO~sVEYxs0nBhm2+=B!b0qtV}TDGM@LtqO7&{>=goIc4J5^Xb%%|f!ps7)#v aXp7m5W0y5@nSs8&EHMS7nw6pc|4jgm*fB5w literal 0 HcmV?d00001 diff --git a/automated-tests/style/gray.jpg b/automated-tests/style/gray.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f1acfdbe94c05b638ac06a84edf7c7bbb1125f3e GIT binary patch literal 866 zcmex=wkpZ3brsCPqdOf&yk%W)NUwVPR%vXJcmvVGd4iP7V$(4t91fUM?^_0R}-120_L^W=16jCP7AKLB{__7~~lk7+Hbd0r?0D z7@3$^SlNJ1;^GD>*eU>YJ~J~D(6Ov6EI`$@KzRlhK~^C}Lq|5@z(jVXLJ_0Ji3>TD zoi-j64Z8S2#W<;`iIYoATtZSxRZU$(Q_IBE%-q7#%Gt%$&E3P(D>x)HEIcAIDmf)J zEj=SMtGJ}Jth}PKs=1}Lt-YhOYtrN?Q>RUzF>}_U#Y>hhTfSoDs!f}>Y~8kf$Ie}c z4j(ys?D&b3r!HN-a`oEv8#iw~eDwIq(`V0LynOZX)8{W=zkUDl^B2fpj10^WZ^38f2KE_o9%~}YXK;@p{B?_ghnW!=dCY3JE*Eh+R}GQb@{A;m&0YWe@)1OTom7e@d9 literal 0 HcmV?d00001 diff --git a/automated-tests/style/jquery.min.js b/automated-tests/style/jquery.min.js new file mode 100644 index 0000000..198b3ff --- /dev/null +++ b/automated-tests/style/jquery.min.js @@ -0,0 +1,4 @@ +/*! jQuery v1.7.1 jquery.com | jquery.org/license */ +(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cv(a){if(!ck[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){cl||(cl=c.createElement("iframe"),cl.frameBorder=cl.width=cl.height=0),b.appendChild(cl);if(!cm||!cl.createElement)cm=(cl.contentWindow||cl.contentDocument).document,cm.write((c.compatMode==="CSS1Compat"?"":"")+""),cm.close();d=cm.createElement(a),cm.body.appendChild(d),e=f.css(d,"display"),b.removeChild(cl)}ck[a]=e}return ck[a]}function cu(a,b){var c={};f.each(cq.concat.apply([],cq.slice(0,b)),function(){c[this]=a});return c}function ct(){cr=b}function cs(){setTimeout(ct,0);return cr=f.now()}function cj(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ci(){try{return new a.XMLHttpRequest}catch(b){}}function cc(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){if(c!=="border")for(;g=0===c})}function S(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function K(){return!0}function J(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?parseFloat(d):j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=/-([a-z]|[0-9])/ig,w=/^-ms-/,x=function(a,b){return(b+"").toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=m.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7.1",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.add(a);return this},eq:function(a){a=+a;return a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;A.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").off("ready")}},bindReady:function(){if(!A){A=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||D.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,"ms-").replace(v,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;c
a",d=q.getElementsByTagName("*"),e=q.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=q.getElementsByTagName("input")[0],b={leadingWhitespace:q.firstChild.nodeType===3,tbody:!q.getElementsByTagName("tbody").length,htmlSerialize:!!q.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:q.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete q.test}catch(s){b.deleteExpando=!1}!q.addEventListener&&q.attachEvent&&q.fireEvent&&(q.attachEvent("onclick",function(){b.noCloneEvent=!1}),q.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),q.appendChild(i),k=c.createDocumentFragment(),k.appendChild(q.lastChild),b.checkClone=k.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,k.removeChild(i),k.appendChild(q),q.innerHTML="",a.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",q.style.width="2px",q.appendChild(j),b.reliableMarginRight=(parseInt((a.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0);if(q.attachEvent)for(o in{submit:1,change:1,focusin:1})n="on"+o,p=n in q,p||(q.setAttribute(n,"return;"),p=typeof q[n]=="function"),b[o+"Bubbles"]=p;k.removeChild(q),k=g=h=j=q=i=null,f(function(){var a,d,e,g,h,i,j,k,m,n,o,r=c.getElementsByTagName("body")[0];!r||(j=1,k="position:absolute;top:0;left:0;width:1px;height:1px;margin:0;",m="visibility:hidden;border:0;",n="style='"+k+"border:5px solid #000;padding:0;'",o="
"+""+"
",a=c.createElement("div"),a.style.cssText=m+"width:0;height:0;position:static;top:0;margin-top:"+j+"px",r.insertBefore(a,r.firstChild),q=c.createElement("div"),a.appendChild(q),q.innerHTML="
t
",l=q.getElementsByTagName("td"),p=l[0].offsetHeight===0,l[0].style.display="",l[1].style.display="none",b.reliableHiddenOffsets=p&&l[0].offsetHeight===0,q.innerHTML="",q.style.width=q.style.paddingLeft="1px",f.boxModel=b.boxModel=q.offsetWidth===2,typeof q.style.zoom!="undefined"&&(q.style.display="inline",q.style.zoom=1,b.inlineBlockNeedsLayout=q.offsetWidth===2,q.style.display="",q.innerHTML="
",b.shrinkWrapBlocks=q.offsetWidth!==2),q.style.cssText=k+m,q.innerHTML=o,d=q.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,i={doesNotAddBorder:e.offsetTop!==5,doesAddBorderForTableAndCells:h.offsetTop===5},e.style.position="fixed",e.style.top="20px",i.fixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",i.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,i.doesNotIncludeMarginInBodyOffset=r.offsetTop!==j,r.removeChild(a),q=a=null,f.extend(b,i))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.nodeName.toLowerCase()]||f.valHooks[g.type];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;h=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/\bhover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function(a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")}; +f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;le&&i.push({elem:this,matches:d.slice(e)});for(j=0;j0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h0)for(h=g;h=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var V="abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div
","
"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function() +{for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||!bc.test("<"+a.nodeName)?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!_.test(k))k=b.createTextNode(k);else{k=k.replace(Y,"<$1>");var l=(Z.exec(k)||["",""])[1].toLowerCase(),m=bg[l]||bg._default,n=m[0],o=b.createElement("div");b===c?bh.appendChild(o):U(b).appendChild(o),o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=$.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]===""&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&X.test(k)&&o.insertBefore(b.createTextNode(X.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return br.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bq,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bq.test(g)?g.replace(bq,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bz(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bA=function(a,b){var c,d,e;b=b.replace(bs,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b)));return c}),c.documentElement.currentStyle&&(bB=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f===null&&g&&(e=g[b])&&(f=e),!bt.test(f)&&bu.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f||0,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),bz=bA||bB,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bD=/%20/g,bE=/\[\]$/,bF=/\r?\n/g,bG=/#.*$/,bH=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bI=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bJ=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bK=/^(?:GET|HEAD)$/,bL=/^\/\//,bM=/\?/,bN=/)<[^<]*)*<\/script>/gi,bO=/^(?:select|textarea)/i,bP=/\s+/,bQ=/([?&])_=[^&]*/,bR=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bS=f.fn.load,bT={},bU={},bV,bW,bX=["*/"]+["*"];try{bV=e.href}catch(bY){bV=c.createElement("a"),bV.href="",bV=bV.href}bW=bR.exec(bV.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bS)return bS.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bN,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bO.test(this.nodeName)||bI.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bF,"\r\n")}}):{name:b.name,value:c.replace(bF,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.on(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?b_(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),b_(a,b);return a},ajaxSettings:{url:bV,isLocal:bJ.test(bW[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bX},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bZ(bT),ajaxTransport:bZ(bU),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?cb(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=cc(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bH.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bG,"").replace(bL,bW[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bP),d.crossDomain==null&&(r=bR.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bW[1]&&r[2]==bW[2]&&(r[3]||(r[1]==="http:"?80:443))==(bW[3]||(bW[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),b$(bT,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bK.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bM.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bQ,"$1_="+x);d.url=y+(y===d.url?(bM.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bX+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=b$(bU,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){if(s<2)w(-1,z);else throw z}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)ca(g,a[g],c,e);return d.join("&").replace(bD,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cd=f.now(),ce=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cd++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(ce.test(b.url)||e&&ce.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ce,l),b.url===j&&(e&&(k=k.replace(ce,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cf=a.ActiveXObject?function(){for(var a in ch)ch[a](0,1)}:!1,cg=0,ch;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ci()||cj()}:ci,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cf&&delete ch[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cg,cf&&(ch||(ch={},f(a).unload(cf)),ch[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var ck={},cl,cm,cn=/^(?:toggle|show|hide)$/,co=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cp,cq=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cr;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cu("show",3),a,b,c);for(var g=0,h=this.length;g=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cx.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cx.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cy(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cy(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,d,"padding")):this[d]():null},f.fn["outer"+c]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,d,a?"margin":"border")):this[d]():null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c],h=e.document.body;return e.document.compatMode==="CSS1Compat"&&g||h&&h["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var i=f.css(e,d),j=parseFloat(i);return f.isNumeric(j)?j:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return f})})(window); \ No newline at end of file diff --git a/automated-tests/style/orange.jpg b/automated-tests/style/orange.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ac4c7493f8b541b2d97af3982860fdfce378d658 GIT binary patch literal 934 zcmex=eAA-4QK!nlZm zfsvIF3>ct*k%^gwm5rT)lZ%^?ff*tPBq6d$k^&4&jLghTEX=H|EG$4{YJqYLEP|{; ziiVDC!hwnGN`)dujT0AgC_8ODC>nI}gNkudQ4=SZn7D+bl&YG#hNhN@shPQjrIoXb ztDC!rr&n-DXjpheWK?oWYFc_mW>#@YX<2ziWmR)aYg>CqXV;|3Q>IRvK4a#rMT?g# zUABD1%2k^-Z`rzS`;MKv4jn#n^w{weCr@3veC6u3>o;!Rdidz^lc&#~zj*oTqL?A@(1V@JrB8&TV2R?P3GG}?A^{LuY(jg0VkSov zg9gI_rUsz~p&3UOuq-pwkhqmB?UNK>xaFA1Wr}B8g@Ex zLJT$oT9usHlWW+!ASoDRpTiNL#f+LgUJ%CstzcM?1Tucn1imF64;_Hc1{xpe0W_I^ z0npHgAQm^!hfbG3j^|?VVt_diXl^FN7g9hL$o$JbKrt^ihznR5L>L0t|K9`v=nx~$ literal 0 HcmV?d00001 diff --git a/automated-tests/style/popup.js b/automated-tests/style/popup.js new file mode 100644 index 0000000..5f994f4 --- /dev/null +++ b/automated-tests/style/popup.js @@ -0,0 +1,1215 @@ +/** + * Copyright (c)2005-2009 Matt Kruse (javascripttoolbox.com) + * + * Dual licensed under the MIT and GPL licenses. + * This basically means you can use this code however you want for + * free, but don't claim to have written it yourself! + * Donations always accepted: http://www.JavascriptToolbox.com/donate/ + * + * Please do not link to the .js files on javascripttoolbox.com from + * your site. Copy the files locally to your server instead. + * + */ +/* ******************************************************************* */ +/* UTIL FUNCTIONS */ +/* ******************************************************************* */ +var Util = {'$VERSION':1.06}; + +// Util functions - these are GLOBAL so they +// look like built-in functions. + +// Determine if an object is an array +function isArray(o) { + return (o!=null && typeof(o)=="object" && typeof(o.length)=="number" && (o.length==0 || defined(o[0]))); +}; + +// Determine if an object is an Object +function isObject(o) { + return (o!=null && typeof(o)=="object" && defined(o.constructor) && o.constructor==Object && !defined(o.nodeName)); +}; + +// Determine if a reference is defined +function defined(o) { + return (typeof(o)!="undefined"); +}; + +// Iterate over an array, object, or list of items and run code against each item +// Similar functionality to Perl's map() function +function map(func) { + var i,j,o; + var results = []; + if (typeof(func)=="string") { + func = new Function('$_',func); + } + for (i=1; i>>=4; + } + while(hex.length<6) { hex='0'+hex; } + return "#" + hex; + }; + + // Convert hyphen style names like border-width to camel case like borderWidth + css.hyphen2camel = function(property) { + if (!defined(property) || property==null) { return null; } + if (property.indexOf("-")<0) { return property; } + var str = ""; + var c = null; + var l = property.length; + for (var i=0; i0) { + return bodies[0]; + } + } + return null; + }; + + // Get the amount that the main document has scrolled from top + // -------------------------------------------------------------------- + screen.getScrollTop = function() { + if (document.documentElement && defined(document.documentElement.scrollTop) && document.documentElement.scrollTop>0) { + return document.documentElement.scrollTop; + } + if (document.body && defined(document.body.scrollTop)) { + return document.body.scrollTop; + } + return null; + }; + + // Get the amount that the main document has scrolled from left + // -------------------------------------------------------------------- + screen.getScrollLeft = function() { + if (document.documentElement && defined(document.documentElement.scrollLeft) && document.documentElement.scrollLeft>0) { + return document.documentElement.scrollLeft; + } + if (document.body && defined(document.body.scrollLeft)) { + return document.body.scrollLeft; + } + return null; + }; + + // Util function to default a bad number to 0 + // -------------------------------------------------------------------- + screen.zero = function(n) { + return (!defined(n) || isNaN(n))?0:n; + }; + + // Get the width of the entire document + // -------------------------------------------------------------------- + screen.getDocumentWidth = function() { + var width = 0; + var body = screen.getBody(); + if (document.documentElement && (!document.compatMode || document.compatMode=="CSS1Compat")) { + var rightMargin = parseInt(CSS.get(body,'marginRight'),10) || 0; + var leftMargin = parseInt(CSS.get(body,'marginLeft'), 10) || 0; + width = Math.max(body.offsetWidth + leftMargin + rightMargin, document.documentElement.clientWidth); + } + else { + width = Math.max(body.clientWidth, body.scrollWidth); + } + if (isNaN(width) || width==0) { + width = screen.zero(self.innerWidth); + } + return width; + }; + + // Get the height of the entire document + // -------------------------------------------------------------------- + screen.getDocumentHeight = function() { + var body = screen.getBody(); + var innerHeight = (defined(self.innerHeight)&&!isNaN(self.innerHeight))?self.innerHeight:0; + if (document.documentElement && (!document.compatMode || document.compatMode=="CSS1Compat")) { + var topMargin = parseInt(CSS.get(body,'marginTop'),10) || 0; + var bottomMargin = parseInt(CSS.get(body,'marginBottom'), 10) || 0; + return Math.max(body.offsetHeight + topMargin + bottomMargin, document.documentElement.clientHeight, document.documentElement.scrollHeight, screen.zero(self.innerHeight)); + } + return Math.max(body.scrollHeight, body.clientHeight, screen.zero(self.innerHeight)); + }; + + // Get the width of the viewport (viewable area) in the browser window + // -------------------------------------------------------------------- + screen.getViewportWidth = function() { + if (document.documentElement && (!document.compatMode || document.compatMode=="CSS1Compat")) { + return document.documentElement.clientWidth; + } + else if (document.compatMode && document.body) { + return document.body.clientWidth; + } + return screen.zero(self.innerWidth); + }; + + // Get the height of the viewport (viewable area) in the browser window + // -------------------------------------------------------------------- + screen.getViewportHeight = function() { + if (!window.opera && document.documentElement && (!document.compatMode || document.compatMode=="CSS1Compat")) { + return document.documentElement.clientHeight; + } + else if (document.compatMode && !window.opera && document.body) { + return document.body.clientHeight; + } + return screen.zero(self.innerHeight); + }; + + return screen; +})();var Sort = (function(){ + var sort = {}; + sort.AlphaNumeric = function(a,b) { + if (a==b) { return 0; } + if (a0 && document.anchors[0].x) { + for (var i=0; i0) { + top -= el.scrollTop; + } + if (el.scrollLeft && el.scrollLeft>0) { + left -= el.scrollLeft; + } + } + } + // If this node is also the offsetParent, add on the offsets and reset to the new offsetParent + if (el == offsetParent) { + left += o.offsetLeft; + if (el.clientLeft && el.nodeName!="TABLE") { + left += el.clientLeft; + } + top += o.offsetTop; + if (el.clientTop && el.nodeName!="TABLE") { + top += el.clientTop; + } + o = el; + if (o.offsetParent==null) { + if (o.offsetLeft) { + left += o.offsetLeft; + } + if (o.offsetTop) { + top += o.offsetTop; + } + } + offsetParent = o.offsetParent; + } + } + + + if (originalObject.offsetWidth) { + width = originalObject.offsetWidth; + } + if (originalObject.offsetHeight) { + height = originalObject.offsetHeight; + } + + return {'left':left, 'top':top, 'width':width, 'height':height + }; + }; + + // Retrieve the position of an object's center point + // ================================================= + pos.getCenter = function(o) { + var c = this.get(o); + if (c==null) { return null; } + c.left = c.left + (c.width/2); + c.top = c.top + (c.height/2); + return c; + }; + + return pos; +})();// CLASS CONSTRUCTOR +// -------------------------------------------------------------------- +var Popup = function(div, options) { + this.div = defined(div)?div:null; + this.index = Popup.maxIndex++; + this.ref = "Popup.objects["+this.index+"]"; + Popup.objects[this.index] = this; + // Store a reference to the DIV by id, also + if (typeof(this.div)=="string") { + Popup.objectsById[this.div] = this; + } + if (defined(this.div) && this.div!=null && defined(this.div.id)) { + Popup.objectsById[this.div.id] = this.div.id; + } + // Apply passed-in options + if (defined(options) && options!=null && typeof(options)=="object") { + for (var i in options) { + this[i] = options[i]; + } + } + return this; +}; + +// CLASS PROPERTIES +// -------------------------------------------------------------------- +// Index of popup objects, to maintain a global reference if necessary +Popup.maxIndex = 0; +Popup.objects = {}; +Popup.objectsById = {}; + +// The z-index value that popups will start at +Popup.minZIndex = 101; + +// Class names to assign to other objects +Popup.screenClass = "PopupScreen"; +Popup.iframeClass = "PopupIframe"; +Popup.screenIframeClass = "PopupScreenIframe"; + +// CLASS METHODS +// -------------------------------------------------------------------- + +// Hide all currently-visible non-modal dialogs +Popup.hideAll = function() { + for (var i in Popup.objects) { + var p = Popup.objects[i]; + if (!p.modal && p.autoHide) { + p.hide(); + } + } +}; +// Catch global events as a trigger to hide auto-hide popups +Event.add(document, "mouseup", Popup.hideAll, false); + +// A simple class method to show a popup without creating an instance +Popup.show = function(divObject, referenceObject, position, options, modal) { + var popup; + if (defined(divObject)) { + popup = new Popup(divObject); + } + else { + popup = new Popup(); + popup.destroyDivOnHide = true; + } + if (defined(referenceObject)) { popup.reference = DOM.resolve(referenceObject); } + if (defined(position)) { popup.position = position; } + if (defined(options) && options!=null && typeof(options)=="object") { + for (var i in options) { + popup[i] = options[i]; + } + } + if (typeof(modal)=="boolean") { + popup.modal = modal; + } + popup.destroyObjectsOnHide = true; + popup.show(); + return popup; +}; + +// A simple class method to show a modal popup +Popup.showModal = function(divObject, referenceObject, position, options) { + Popup.show(divObject, referenceObject, position, options, true); +}; + +// A method to retrieve a popup object based on a div ID +Popup.get = function(divId) { + if (defined(Popup.objectsById[divId])) { + return Popup.objectsById[divId]; + } + return null; +}; + +// A method to hide a popup based on a div id +Popup.hide = function(divId) { + var popup = Popup.get(divId); + if (popup!=null) { + popup.hide(); + } +}; + +// PROTOTYPE PROPERTIES +// -------------------------------------------------------------------- +Popup.prototype.content = null; +Popup.prototype.className = "PopupDiv"; +Popup.prototype.style = null; // Styles to be applied to the DIV +Popup.prototype.width = null; +Popup.prototype.height = null; +Popup.prototype.top = null; +Popup.prototype.left = null; +Popup.prototype.offsetLeft = 0; +Popup.prototype.offsetTop = 0; +Popup.prototype.constrainToScreen = true; +Popup.prototype.autoHide = true; +Popup.prototype.useIframeShim = false; /*@cc_on @*/ /*@if (@_win32) {Popup.prototype.useIframeShim = true;} @end @*/ +Popup.prototype.iframe = null; +Popup.prototype.position = null; // vertical: "above top center bottom below", horizontal: "adjacent-left,left,center,right,adjacent-right" +Popup.prototype.reference = null; +Popup.prototype.modal = false; +Popup.prototype.destroyDivOnHide = false; +Popup.prototype.destroyObjectsOnHide = false; +Popup.prototype.screen = null; +Popup.prototype.screenIframeShim = null; +Popup.prototype.screenOpacity=.4; +Popup.prototype.screenColor="#cccccc"; + +// INSTANCE METHODS +// -------------------------------------------------------------------- + +// Show the popup +// -------------------------------------------------------------------- +Popup.prototype.show = function(options, modal) { + this.modal = this.modal || (typeof(modal)=="boolean" && modal); + if (defined(options) && options!=null && typeof(options)=="object") { + for (var i in options) { + this[i] = options[i]; + } + } + this.div = DOM.resolve(this.div); + CSS.setStyle(this.div,'position','absolute'); + + // If there is no div pre-defined to use, create one + if (this.div==null) { + this.div = this.createDiv(); + } + if (this.content!=null) { + this.div.innerHTML = this.content; + this.content = null; + } + if (this.className!=null) { + this.div.className = this.className; + } + if (this.style!=null) { + this.applyStyle(); + } + if (this.width!=null) { + this.div.style.width = this.width+"px"; + this.div.style.overflowX="auto"; + } + if (this.height!=null) { + this.div.style.height = this.height+"px"; + this.div.style.overflowY="auto"; + } + + // Do the actual display - this is a separate method so display transitions can be implemented + this.transition(); + + // Make sure clicks on the DIV don't bubble up to the document + this.div.onclick = function(e) { + Event.cancelBubble(Event.resolve(e)); + }; + this.div.onmouseup = this.div.onclick; + + // Focus to the DIV if possible + if (this.modal && this.div.focus) { + this.div.focus(); + } +}; + +// Show the popup but make it modal +// -------------------------------------------------------------------- +Popup.prototype.transition = function() { + if (this.modal) { + this.addScreen(); + } + + // Make the DIV displayed but hidden so its size can be measured + CSS.setStyle(this.div,'visibility','hidden'); + CSS.setStyle(this.div,'display','block'); + + // Position the popup + this.setPosition(); + + // Add the shim if necessary + if (this.useIframeShim) { + this.addIframeShim(); + } + + // Make sure the DIV is higher than the shim + this.div.style.zIndex = Popup.minZIndex++; + + CSS.setStyle(this.div,'display','block'); + CSS.setStyle(this.div,'visibility','visible'); +}; + +// Show the popup but make it modal +// -------------------------------------------------------------------- +Popup.prototype.showModal = function(options) { + this.show(options,true); +}; + +// Apply user styles to the DIV +// -------------------------------------------------------------------- +Popup.prototype.applyStyle = function() { + if (this.div!=null && this.style!=null && typeof(this.style)=="object") { + for (var i in this.style) { + this.div.style[i] = this.style[i]; + } + } +}; + +// Hide the popup +// -------------------------------------------------------------------- +Popup.prototype.hide = function() { + // If this was a temp object creating on-the-fly, then remove objects from the DOM so + // The document doesn't get littered with extra objects + if (this.destroyDivOnHide) { + DOM.removeNode(this.div); + this.div = null; + delete Popup.objects[this.id]; + } + else if (this.div!=null) { + CSS.setStyle(this.div,'display','none'); + } + + if (this.destroyObjectsOnHide) { + DOM.removeNode(this.iframe); + DOM.removeNode(this.screen); + DOM.removeNode(this.screenIframeShim); + } + else { + if (this.iframe!=null) { + this.iframe.style.display = "none"; + } + if (this.screen!=null) { + this.screen.style.display = "none"; + } + if (this.screenIframeShim!=null) { + this.screenIframeShim.style.display = "none"; + } + } +}; + +// Util funcs for position +// -------------------------------------------------------------------- +Popup.prototype.setTop = function(top) { + this.div.style.top = top+"px"; +}; +Popup.prototype.setLeft = function(left) { + this.div.style.left = left+"px"; +}; +Popup.prototype.getTop = function() { + return parseInt(CSS.getStyle(this.div,"top"),10); +}; +Popup.prototype.getLeft = function() { + return parseInt(CSS.getStyle(this.div,"left"),10); +}; + +// All the logic to position the popup based on various criteria +// -------------------------------------------------------------------- +Popup.prototype.setPosition = function() { + if (this.position!=null) { + var m = this.position.match(/^(\S+)\s+(\S+)/); + if (m!=null && m.length==3) { + var v = m[1]; + var h = m[2]; + + var ref = this.reference; + if (ref==null) { ref = Screen.getBody(); } + var p = Position.get(ref); + var refTop = p.top; + var refLeft = p.left; + var refWidth = DOM.getOuterWidth(ref); + var refHeight = DOM.getOuterHeight(ref); + + var width = DOM.getOuterWidth(this.div); + var height = DOM.getOuterHeight(this.div); + + var scrollLeft = Screen.getScrollLeft(); + var scrollTop = Screen.getScrollTop(); + + // Set vertical position relative to reference object + if (v=="above") { this.setTop(refTop-height+this.offsetTop); } + else if (v=="top") { this.setTop(refTop+this.offsetTop); } + else if (v=="center") { this.setTop(refTop+(refHeight/2)-(height/2)+this.offsetTop); } + else if (v=="bottom") { this.setTop(refTop+refHeight-height+this.offsetTop); } + else if (v=="below") { this.setTop(refTop+refHeight+this.offsetTop); } + + // Set horizontal position relative to reference object + if (h=="adjacent-left") { this.setLeft(refLeft-width+this.offsetLeft); } + else if (h=="left") { this.setLeft(refLeft+this.offsetLeft); } + else if (h=="center") { this.setLeft(refLeft+(refWidth/2)-(width/2)+this.offsetLeft); } + else if (h=="right") { this.setLeft(refLeft+refWidth-width+this.offsetLeft); } + else if (h=="adjacent-right") { this.setLeft(refLeft+refWidth+this.offsetLeft); } + } + } + else if (this.top==null && this.left==null) { + this.center(); + } + else { + if (this.top==null) { this.top=0; } + if (this.left==null) { this.left=0; } + this.div.style.top = this.top+this.offsetTop+"px"; + this.div.style.left = this.left+this.offsetLeft+"px"; + } + + // Re-position to make sure it stays on the screen + if (this.constrainToScreen) { + this.fitToScreen(); + } +}; + +// Append an object to the body +// -------------------------------------------------------------------- +Popup.prototype.appendToBody = function(o) { + var body = Screen.getBody(); + if (body && body.appendChild) { + body.appendChild(o); + } +}; + +// Create a new DIV object to be used for a popup +// -------------------------------------------------------------------- +Popup.prototype.createDiv = function() { + if (document.createElement) { + var d = document.createElement("DIV"); + d.style.position="absolute"; + d.style.display="block"; + d.style.visibility="hidden"; + this.appendToBody(d); + return d; + } + alert("ERROR: Couldn't create DIV element in Popup.prototype.createDiv()"); + return null; +}; + +// Create a new IFRAME object to be used behind the popup +// -------------------------------------------------------------------- +Popup.prototype.createIframe = function() { + if (document.createElement) { + var i= document.createElement("IFRAME"); + i.style.position="absolute"; + i.style.display="block"; + i.style.visibility="hidden"; + i.style.background="none"; + this.appendToBody(i); + return i; + } + else { + alert("ERROR: Couldn't create IFRAME object in Popup.prototype.createIframe()"); + } +}; + +// Add an IFRAME shim for the DIV +// -------------------------------------------------------------------- +Popup.prototype.addIframeShim = function() { + if (this.iframe==null) { + this.iframe = this.createIframe(); + } + this.iframe.className = Popup.iframeClass; + CSS.setStyle(this.iframe,'top',this.getTop()+"px"); + CSS.setStyle(this.iframe,'left',this.getLeft()+"px"); + CSS.setStyle(this.iframe,'width',DOM.getOuterWidth(this.div) + "px"); + CSS.setStyle(this.iframe,'height',DOM.getOuterHeight(this.div) + "px"); + CSS.setStyle(this.iframe,'zIndex',Popup.minZIndex++); + CSS.setStyle(this.iframe,'opacity',0); + CSS.setStyle(this.iframe,'visibility','visible'); + CSS.setStyle(this.iframe,'display','block'); +}; + +// Create a "screen" to make a popup modal +// -------------------------------------------------------------------- +Popup.prototype.addScreen = function() { + if (this.screen==null) { + this.screen = this.createDiv(); + this.screen.style.top="0px"; + this.screen.style.left="0px"; + this.screen.style.backgroundColor = this.screenColor; + this.screen.className=Popup.screenClass;; + CSS.setStyle(this.screen,"opacity",this.screenOpacity); + this.screen.onclick = function(e) { Event.cancelBubble(Event.resolve(e)); } + } + if (this.screenIframeShim==null) { + this.screenIframeShim = this.createIframe(); + this.screenIframeShim.style.top="0px"; + this.screenIframeShim.style.left="0px"; + this.screenIframeShim.className=Popup.screenIframeClass; + CSS.setStyle(this.screenIframeShim,"opacity",0); + } + this.screen.style.width = Screen.getDocumentWidth()+"px"; + this.screen.style.height = Screen.getDocumentHeight()+"px"; + this.screenIframeShim.style.width = Screen.getDocumentWidth()+"px"; + this.screenIframeShim.style.height = Screen.getDocumentHeight()+"px"; + this.screenIframeShim.style.zIndex = Popup.minZIndex++; + this.screenIframeShim.style.visibility="visible"; + this.screenIframeShim.style.display="block"; + this.screen.style.zIndex = Popup.minZIndex++; + this.screen.style.visibility="visible"; + this.screen.style.display="block"; +}; + +// Re-position the DIV so it stays on the screen +// -------------------------------------------------------------------- +Popup.prototype.fitToScreen = function() { + var width = DOM.getOuterWidth(this.div); + var height = DOM.getOuterHeight(this.div); + var top = this.getTop(); + var left = this.getLeft(); + + var clientWidth = Screen.getViewportWidth(); + var clientHeight = Screen.getViewportHeight(); + + var scrollLeft = Screen.getScrollLeft(); + var scrollTop = Screen.getScrollTop(); + + if (top-scrollTop+height>clientHeight) { + top = top - ((top+height) - (scrollTop+clientHeight)); + this.div.style.top = top + "px"; + } + if (left-scrollLeft+width>clientWidth) { + left = left - ((left+width) - (scrollLeft+clientWidth)); + this.div.style.left = left + "px"; + } + if (topeAA-4QK!nlZm zfsvIF3>ct*k%^gwm5rT)lZ%^?ff*tPBq6d$k^&4&jLghTEX=H|EG$4{YJqYLEP|{; ziiVDC!hwnGN`)dujT0AgC_8ODC>nI}gNkudQ4=SZn7D+bl&YG#hNhN@shPQjrIoXb ztDC!rr&n-DXjpheWK?oWYFc_mW>#@YX<2ziWmR)aYg>CqXV;|3Q>IRvK4a#rMT?g# zUABD1%2k^-Z`rzS`;MKv4jn#n^w{weCr@3veC6u3>o;!Rdidz^lc&#~zj*oT6sAHsIig>XiL))b}k321|c8>nspdx@(iG{%BBu(K&!4Y9QI+mEHH&37-Vju zLldT>k$fT&#Q10e(7~!v)3CT7ZvHIBwv~*6t02B`<~5MYY`B#y*2w8_bb+G-D>Ii9 JS3>>&n*dJ776JeO literal 0 HcmV?d00001 diff --git a/automated-tests/style/summary.xsl b/automated-tests/style/summary.xsl new file mode 100644 index 0000000..c034df8 --- /dev/null +++ b/automated-tests/style/summary.xsl @@ -0,0 +1,352 @@ + + + + + + + + + + + + + + + \n + + + + +
+ + + +
+ + + +
+
+
diff --git a/automated-tests/style/testresult.xsl b/automated-tests/style/testresult.xsl new file mode 100644 index 0000000..019b445 --- /dev/null +++ b/automated-tests/style/testresult.xsl @@ -0,0 +1,571 @@ + + + + + + + + + + + + + + + \n + + + + +
+ + + +
+ + + +
+
+
diff --git a/automated-tests/style/tests.css b/automated-tests/style/tests.css new file mode 100644 index 0000000..2fda634 --- /dev/null +++ b/automated-tests/style/tests.css @@ -0,0 +1,195 @@ +@charset "UTF-8"; +/* CSS Document */ +#testcasepage div,#testcasepage h1,#testcasepage p,#testcasepage table,#testcasepage tr,#testcasepage th,#testcasepage td + { + margin: 0; + padding: 0; + border: 0; + font-weight: inherit; + font-style: inherit; + font-size: 0.96em; + font-family: arial; + vertical-align: baseline; +} + +#title td, #btc td{ + margin: 0; + padding: 0; + border: 0; + font-weight: inherit; + font-style: inherit; + font-size: 0.96em; + font-family: arial; + vertical-align: baseline; +} + +td.Ratio { + text-align: left; + font-weight: normal; + padding: 4px 10px 4px 5px; + vertical-align: middle; +} + +th.Ratio { + width: 400px; +} + +#testcasepage p { + text-align: left; +} + +#suite_title { + text-align: left; +} + +#btc { + text-align: right; +} + +#btc table { + position: absolute; + right: 0px; + width: 600px; +} + +#testcasepage table { + border-collapse: separate; + border-spacing: 0; + margin-bottom: 1.4em; + vertical-align: middle; +} + +#testcasepage th,#testcasepage td { + text-align: left; + font-weight: normal; + padding: 4px 10px 4px 5px; + vertical-align: middle; +} + +#cases table { + width: 101%; +} + +#cases td { + border-left: 0px; + font-weight: normal; + border-bottom: 0px; +} + +#suite_summary table { + width: 100%; +} + + +#overview table { + width: 101%; +} + +#overview table, #overview td, #overview tr { + border-left: none; + border-bottom: none; + border-right: none; + vertical-align: top; +} + +#overview td{ + width: 50%; +} + +#capability table { + width: 50%; +} + +#fail_cases table { + width: 101%; +} + +#title table { + width: 101%; +} + +#device table { + width: 100%; +} + +#summary table { + width: 100%; +} + +#testcasepage th { + border-bottom: 1px solid #000; + background-color: #AAAAAA; + border-left: 1px solid #000; + border-top: 1px solid #000; + color: #000; + font-weight: bold; + vertical-align: bottom; +} + +#summary th:last-child,#summary td:last-child, #device th:last-child,#device td:last-child, #suite_summary th:last-child,#suite_summary td:last-child,#cases th:last-child,#cases td:last-child,#capability th:last-child,#capability td:last-child { + border-right: 1px solid #000; +} + +#testcasepage td { + font-weight: normal; +} + +#summary td, #device td, #capability td, #suite_summary td, #cases td{ + border-left: 1px solid; + font-weight: normal; + border-bottom: 1px solid; +} + +#testcasepage td.yellow_rate { + background-color: #ffcc00; +} + +#testcasepage td.green_rate { + background-color: #1E90FF; +} + +#testcasepage td.dgreen_rate { + background-color: #339933; +} + +#testcasepage td.red_rate { + background-color: #FF3333; +} + +#testcasepage td.orange_rate { + background-color: #FFA500; +} + +#testcasepage td.gray_rate { + background-color: #AAAAAA; +} + +#title table,#title tr,#title td { + border-left: none; + border-bottom: none; + text-align: center; +} + +#title td:last-child { + border-right: none; +} + +#testcasepage h1 { + font-size: 2em; + font-family: Arial, sans-serif; + font-weight: bold; + line-height: 1; + color: #000; + margin-bottom: 0.75em; + padding-top: 0.25em; + font-weight: bold; +} + +#goTopBtn { + right: 0px; + bottom: 0px; + position: fixed; + + position: absolute; + top: expression(parseInt(document.body.scrollTop)+document.body.clientHeight-40 + ); +} diff --git a/automated-tests/tcbuild b/automated-tests/tcbuild new file mode 120000 index 0000000..89c2de7 --- /dev/null +++ b/automated-tests/tcbuild @@ -0,0 +1 @@ +scripts/tcbuild.sh \ No newline at end of file diff --git a/build/slp/Makefile.am b/build/slp/Makefile.am index 039421e..ce7bd6b 100644 --- a/build/slp/Makefile.am +++ b/build/slp/Makefile.am @@ -20,8 +20,8 @@ SUBDIRS = dali-core pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = dali-core.pc dali-test-suite-utils.pc -automated_tests_src_dir = ../../automated-tests -include ../../automated-tests/file.list +automated_tests_src_dir = ../../automated-tests/TET +include ../../automated-tests/TET/file.list dalitestsuitedir = $(includedir)/dali/test-suite-utils dalitestsuite_HEADERS = $(test_suite_utils_header_files) diff --git a/build/slp/configure.ac b/build/slp/configure.ac index d91962b..46187aa 100644 --- a/build/slp/configure.ac +++ b/build/slp/configure.ac @@ -99,7 +99,7 @@ AC_CONFIG_FILES([ dali-core/Makefile dali-core.pc dali-test-suite-utils.pc - ../../automated-tests/rules.mk + ../../automated-tests/TET/rules.mk ]) AC_OUTPUT diff --git a/build/slp/dali-core/Makefile.am b/build/slp/dali-core/Makefile.am index cf4c8d2..24e4425 100644 --- a/build/slp/dali-core/Makefile.am +++ b/build/slp/dali-core/Makefile.am @@ -179,11 +179,11 @@ CLEANFILES = dali-shaders.cpp \ noinst_PROGRAMS = linker.test -linker_test_SOURCES = linker-test.cpp ../../../automated-tests/dali-test-suite-utils/test-application.cpp +linker_test_SOURCES = linker-test.cpp ../../../automated-tests/TET/dali-test-suite-utils/test-application.cpp linker_test_CXXFLAGS = \ -Werror -Wall -Wfloat-equal \ - -I../../../automated-tests/dali-test-suite-utils \ + -I../../../automated-tests/TET/dali-test-suite-utils \ $(dali_core_includes) \ $(DALI_CFLAGS) \ $(OPENGLES20_CFLAGS) -- 2.7.4