From 3eab0e56f89fd85151929cbd3b248b7659569d3b Mon Sep 17 00:00:00 2001 From: David Steele Date: Wed, 9 Apr 2014 15:52:27 +0100 Subject: [PATCH] Resynced test cases and removed TET framework [Issue#] N/A [Problem] Test cases not quite up-to-date [Cause] Time [Solution] Migrated remaining test cases, removed TET framework Change-Id: I2811ac5c197d75f0971ac0a20ebb2883bb79b9ee [Verification] Build Repo, build and execute tests on desktop. Signed-off-by: David Steele --- automated-tests/TET/.gitignore | 8 - automated-tests/TET/_export_desktop.sh | 33 - automated-tests/TET/_export_env.sh | 17 - automated-tests/TET/_export_sbs.sh | 17 - automated-tests/TET/_export_target_env.sh | 17 - automated-tests/TET/build.sh | 68 - automated-tests/TET/build_out.sh | 3 - automated-tests/TET/coverage.mk | 1 - automated-tests/TET/coverage.sh | 22 - .../image-factory/.gitignore | 1 - .../image-factory/Makefile | 1 - .../image-factory/file.list | 2 - .../dali-internal-test-suite/image-factory/tslist | 1 - .../image-factory/utc-Dali-ImageFactory.cpp | 611 -- .../dali-internal-test-suite/master-makefile.mk | 40 - .../dali-internal-test-suite/material/.gitignore | 1 - .../TET/dali-internal-test-suite/material/Makefile | 1 - .../dali-internal-test-suite/material/file.list | 2 - .../TET/dali-internal-test-suite/material/tslist | 1 - .../material/utc-Dali-Material.cpp | 748 -- .../resource-manager/.gitignore | 1 - .../resource-manager/Makefile | 1 - .../resource-manager/file.list | 2 - .../resource-manager/tslist | 2 - .../utc-DaliInternal-ResourceClient.cpp | 1438 ---- .../TET/dali-internal-test-suite/tc-gen.sh | 1 - .../TET/dali-internal-test-suite/text/.gitignore | 2 - .../TET/dali-internal-test-suite/text/Makefile | 1 - .../TET/dali-internal-test-suite/text/file.list | 3 - .../TET/dali-internal-test-suite/text/tslist | 1 - .../text/utc-DaliInternal-Font.cpp | 163 - .../utc-MODULE-CLASS.cpp.in | 94 - .../dali-test-suite-internal-utils.h | 105 - .../dali-test-suite-utils/dali-test-suite-utils.h | 589 -- .../TET/dali-test-suite-utils/mesh-builder.h | 232 - .../TET/dali-test-suite-utils/test-application.cpp | 21 - .../TET/dali-test-suite-utils/test-application.h | 241 - .../dali-test-suite-utils/test-gesture-manager.h | 139 - .../dali-test-suite-utils/test-gl-abstraction.h | 1860 ----- .../test-gl-sync-abstraction.h | 169 - .../TET/dali-test-suite-utils/test-native-image.h | 50 - .../test-platform-abstraction.h | 750 -- .../dali-test-suite-utils/test-render-controller.h | 78 - .../dali-test-suite-utils/test-trace-call-stack.h | 126 - .../TET/dali-test-suite/actors/.gitignore | 19 - .../TET/dali-test-suite/actors/Makefile | 1 - .../TET/dali-test-suite/actors/file.list | 15 - automated-tests/TET/dali-test-suite/actors/tslist | 14 - .../TET/dali-test-suite/actors/tslist-renderables | 4 - .../TET/dali-test-suite/actors/tslist-text-actor | 1 - .../TET/dali-test-suite/actors/utc-Dali-Actor.cpp | 2952 ------- .../dali-test-suite/actors/utc-Dali-BaseHandle.cpp | 489 -- .../actors/utc-Dali-CameraActor.cpp | 1045 --- .../actors/utc-Dali-Constrainable.cpp | 114 - .../actors/utc-Dali-CustomActor.cpp | 1641 ---- .../TET/dali-test-suite/actors/utc-Dali-Handle.cpp | 1002 --- .../dali-test-suite/actors/utc-Dali-ImageActor.cpp | 990 --- .../TET/dali-test-suite/actors/utc-Dali-Layer.cpp | 533 -- .../dali-test-suite/actors/utc-Dali-LightActor.cpp | 346 - .../dali-test-suite/actors/utc-Dali-MeshActor.cpp | 929 --- .../TET/dali-test-suite/actors/utc-Dali-Model.cpp | 679 -- .../actors/utc-Dali-RenderableActor.cpp | 522 -- .../TET/dali-test-suite/actors/utc-Dali-Stage.cpp | 651 -- .../dali-test-suite/actors/utc-Dali-TextActor.cpp | 856 -- .../TET/dali-test-suite/animation/.gitignore | 4 - .../TET/dali-test-suite/animation/Makefile | 1 - .../TET/dali-test-suite/animation/file.list | 5 - .../TET/dali-test-suite/animation/tslist | 4 - .../animation/utc-Dali-ActiveConstraint.cpp | 408 - .../animation/utc-Dali-AlphaFunctions.cpp | 391 - .../animation/utc-Dali-Animation.cpp | 8786 -------------------- .../animation/utc-Dali-Constraint.cpp | 4038 --------- .../TET/dali-test-suite/common/.gitignore | 3 - .../TET/dali-test-suite/common/Makefile | 1 - .../TET/dali-test-suite/common/file.list | 4 - .../TET/dali-test-suite/common/tc-gen.sh | 58 - automated-tests/TET/dali-test-suite/common/tslist | 3 - .../TET/dali-test-suite/common/utc-Dali-Any.cpp | 264 - .../common/utc-Dali-LocklessBuffer.cpp | 144 - .../TET/dali-test-suite/common/utc-Dali-Vector.cpp | 817 -- .../TET/dali-test-suite/context/.gitignore | 1 - .../TET/dali-test-suite/context/Makefile | 1 - .../TET/dali-test-suite/context/file.list | 2 - automated-tests/TET/dali-test-suite/context/tslist | 1 - .../dali-test-suite/context/utc-Dali-Context.cpp | 274 - .../TET/dali-test-suite/dynamics/.gitignore | 6 - .../TET/dali-test-suite/dynamics/Makefile | 40 - .../TET/dali-test-suite/dynamics/file.list | 7 - .../TET/dali-test-suite/dynamics/tslist | 6 - .../dynamics/utc-Dali-DynamicsBody.cpp | 564 -- .../dynamics/utc-Dali-DynamicsBodyConfig.cpp | 657 -- .../dynamics/utc-Dali-DynamicsJoint.cpp | 387 - .../dynamics/utc-Dali-DynamicsShape.cpp | 297 - .../dynamics/utc-Dali-DynamicsWorld.cpp | 188 - .../dynamics/utc-Dali-DynamicsWorldConfig.cpp | 123 - .../TET/dali-test-suite/effects/.gitignore | 2 - .../TET/dali-test-suite/effects/Makefile | 1 - .../TET/dali-test-suite/effects/file.list | 3 - automated-tests/TET/dali-test-suite/effects/tslist | 2 - .../effects/utc-Dali-ShaderEffect.cpp | 1193 --- .../TET/dali-test-suite/events/.gitignore | 16 - .../TET/dali-test-suite/events/Makefile | 1 - .../TET/dali-test-suite/events/file.list | 17 - automated-tests/TET/dali-test-suite/events/tslist | 16 - .../events/utc-Dali-EventProcessing.cpp | 104 - .../dali-test-suite/events/utc-Dali-Gesture.cpp | 102 - .../events/utc-Dali-GestureDetector.cpp | 427 - .../events/utc-Dali-HitTestAlgorithm.cpp | 430 - .../dali-test-suite/events/utc-Dali-KeyEvent.cpp | 286 - .../events/utc-Dali-LongPressGesture.cpp | 94 - .../events/utc-Dali-LongPressGestureDetector.cpp | 1322 --- .../events/utc-Dali-MouseWheelEvent.cpp | 301 - .../dali-test-suite/events/utc-Dali-PanGesture.cpp | 151 - .../events/utc-Dali-PanGestureDetector.cpp | 2055 ----- .../events/utc-Dali-PinchGesture.cpp | 122 - .../events/utc-Dali-PinchGestureDetector.cpp | 1239 --- .../dali-test-suite/events/utc-Dali-TapGesture.cpp | 97 - .../events/utc-Dali-TapGestureDetector.cpp | 1217 --- .../events/utc-Dali-TouchEventCombiner.cpp | 796 -- .../events/utc-Dali-TouchProcessing.cpp | 1209 --- .../TET/dali-test-suite/geometry/.gitignore | 3 - .../TET/dali-test-suite/geometry/Makefile | 1 - .../TET/dali-test-suite/geometry/file.list | 4 - .../TET/dali-test-suite/geometry/tslist | 3 - .../geometry/utc-Dali-AnimatableMesh.cpp | 477 -- .../dali-test-suite/geometry/utc-Dali-MeshData.cpp | 363 - .../dali-test-suite/geometry/utc-Dali-Spline.cpp | 690 -- .../TET/dali-test-suite/images/.gitignore | 9 - .../TET/dali-test-suite/images/Makefile | 1 - .../TET/dali-test-suite/images/file.list | 9 - automated-tests/TET/dali-test-suite/images/tslist | 8 - .../images/utc-Dali-BitmapImage.cpp | 548 -- .../images/utc-Dali-DistanceField.cpp | 97 - .../images/utc-Dali-EncodedBufferImage.cpp | 896 -- .../images/utc-Dali-FrameBufferImage.cpp | 134 - .../TET/dali-test-suite/images/utc-Dali-Image.cpp | 1119 --- .../images/utc-Dali-ImageAttributes.cpp | 145 - .../TET/dali-test-suite/images/utc-Dali-Pixel.cpp | 206 - .../dali-test-suite/images/utc-MODULE-CLASS.cpp.in | 82 - .../TET/dali-test-suite/master-makefile.mk | 41 - .../TET/dali-test-suite/material/.gitignore | 1 - .../TET/dali-test-suite/material/Makefile | 1 - .../TET/dali-test-suite/material/file.list | 2 - .../TET/dali-test-suite/material/tslist | 1 - .../dali-test-suite/material/utc-Dali-Material.cpp | 361 - .../TET/dali-test-suite/math/.gitignore | 14 - automated-tests/TET/dali-test-suite/math/Makefile | 1 - automated-tests/TET/dali-test-suite/math/file.list | 13 - automated-tests/TET/dali-test-suite/math/tslist | 13 - .../dali-test-suite/math/utc-Dali-AngleAxis.cpp | 132 - .../TET/dali-test-suite/math/utc-Dali-Degree.cpp | 174 - .../dali-test-suite/math/utc-Dali-MathUtils.cpp | 284 - .../TET/dali-test-suite/math/utc-Dali-Matrix.cpp | 766 -- .../TET/dali-test-suite/math/utc-Dali-Matrix3.cpp | 420 - .../dali-test-suite/math/utc-Dali-Quaternion.cpp | 1115 --- .../TET/dali-test-suite/math/utc-Dali-Radian.cpp | 178 - .../TET/dali-test-suite/math/utc-Dali-Random.cpp | 133 - .../TET/dali-test-suite/math/utc-Dali-Rect.cpp | 320 - .../TET/dali-test-suite/math/utc-Dali-Vector2.cpp | 459 - .../TET/dali-test-suite/math/utc-Dali-Vector3.cpp | 624 -- .../TET/dali-test-suite/math/utc-Dali-Vector4.cpp | 568 -- .../TET/dali-test-suite/object-registry/.gitignore | 1 - .../TET/dali-test-suite/object-registry/Makefile | 1 - .../TET/dali-test-suite/object-registry/file.list | 2 - .../TET/dali-test-suite/object-registry/tslist | 1 - .../object-registry/utc-Dali-ObjectRegistry.cpp | 564 -- .../property-notification/.gitignore | 1 - .../dali-test-suite/property-notification/Makefile | 1 - .../property-notification/file.list | 2 - .../dali-test-suite/property-notification/tslist | 1 - .../utc-Dali-PropertyNotification.cpp | 860 -- .../TET/dali-test-suite/render-tasks/.gitignore | 2 - .../TET/dali-test-suite/render-tasks/Makefile | 1 - .../TET/dali-test-suite/render-tasks/file.list | 3 - .../TET/dali-test-suite/render-tasks/tslist | 2 - .../render-tasks/utc-Dali-RenderTask.cpp | 2772 ------ .../render-tasks/utc-Dali-RenderTaskList.cpp | 170 - .../TET/dali-test-suite/scripting/.gitignore | 1 - .../TET/dali-test-suite/scripting/Makefile | 1 - .../TET/dali-test-suite/scripting/file.list | 2 - .../TET/dali-test-suite/scripting/tslist | 1 - .../scripting/utc-Dali-Scripting.cpp | 1056 --- .../TET/dali-test-suite/signals/.gitignore | 4 - .../TET/dali-test-suite/signals/Makefile | 1 - .../TET/dali-test-suite/signals/file.list | 3 - automated-tests/TET/dali-test-suite/signals/tslist | 2 - .../signals/utc-Dali-SignalTemplatesFunctors.cpp | 528 -- .../signals/utc-Dali-SignalTemplatesV2.cpp | 2633 ------ automated-tests/TET/dali-test-suite/tc-gen.sh | 58 - .../TET/dali-test-suite/text/.gitignore | 6 - automated-tests/TET/dali-test-suite/text/Makefile | 1 - automated-tests/TET/dali-test-suite/text/file.list | 7 - automated-tests/TET/dali-test-suite/text/tslist | 6 - .../dali-test-suite/text/utc-Dali-Character.cpp | 196 - .../TET/dali-test-suite/text/utc-Dali-Font.cpp | 561 -- .../text/utc-Dali-FontParameters.cpp | 151 - .../TET/dali-test-suite/text/utc-Dali-Text.cpp | 374 - .../dali-test-suite/text/utc-Dali-TextStyle.cpp | 530 -- .../TET/dali-test-suite/text/utc-Dali-Utf8.cpp | 75 - .../TET/dali-test-suite/type-registry/.gitignore | 1 - .../TET/dali-test-suite/type-registry/Makefile | 1 - .../TET/dali-test-suite/type-registry/file.list | 2 - .../TET/dali-test-suite/type-registry/tslist | 1 - .../type-registry/utc-Dali-TypeRegistry.cpp | 859 -- .../TET/dali-test-suite/utc-MODULE-CLASS.cpp.in | 90 - automated-tests/TET/debug.sh | 53 - automated-tests/TET/debug_target.sh | 52 - automated-tests/TET/execute.sh | 42 - automated-tests/TET/execute_target.sh | 39 - automated-tests/TET/file.list | 4 - automated-tests/TET/rules.mk.in | 13 - automated-tests/TET/tbp.pl | 339 - automated-tests/TET/tet_scen | 117 - automated-tests/TET/tetbuild.cfg | 5 - automated-tests/TET/tetclean.cfg | 5 - automated-tests/TET/tetexec.cfg | 5 - automated-tests/scripts/summarize.pl | 5 + automated-tests/src/dali-internal/CMakeLists.txt | 12 +- .../src/dali-internal/tct-dali-internal-core.h | 30 +- ...nternal-Font.cpp => utc-Dali-Internal-Font.cpp} | 0 .../dali-internal/utc-Dali-Internal-Handles.cpp | 106 + ...tory.cpp => utc-Dali-Internal-ImageFactory.cpp} | 0 ...Material.cpp => utc-Dali-Internal-Material.cpp} | 0 ...nt.cpp => utc-Dali-Internal-ResourceClient.cpp} | 0 .../src/dali-internal/utc-Dali-Internal-Text.cpp | 85 + automated-tests/src/dali-unmanaged/CMakeLists.txt | 2 +- .../src/dali-unmanaged/tct-dali-unmanaged-core.h | 2 - .../src/dali-unmanaged/utc-Dali-AnimatableMesh.cpp | 39 + .../dali-unmanaged}/utc-Dali-GlyphImage.cpp | 50 +- .../src/dali-unmanaged/utc-Dali-ShaderEffect.cpp | 12 - automated-tests/src/dali/CMakeLists.txt | 2 +- .../dali-test-suite-utils/dali-test-suite-utils.h | 3 +- .../dali-test-suite-utils/test-gl-abstraction.h | 4 +- .../test-gl-sync-abstraction.h | 1 - automated-tests/src/dali/tct-dali-core.h | 18 +- automated-tests/src/dali/utc-Dali-Actor.cpp | 75 + automated-tests/src/dali/utc-Dali-Animation.cpp | 7 +- automated-tests/src/dali/utc-Dali-Handle.cpp | 57 + automated-tests/src/dali/utc-Dali-ImageActor.cpp | 17 + .../src/dali/utc-Dali-LongPressGestureDetector.cpp | 2 +- automated-tests/src/dali/utc-Dali-Matrix.cpp | 2 +- automated-tests/src/dali/utc-Dali-MeshActor.cpp | 18 + build/slp/Makefile.am | 3 - build/slp/configure.ac | 1 - build/slp/dali-core/Makefile.am | 12 +- build/slp/dali-core/linker-test.cpp | 17 +- packaging/dali.spec | 16 - 247 files changed, 489 insertions(+), 71889 deletions(-) delete mode 100644 automated-tests/TET/.gitignore delete mode 100644 automated-tests/TET/_export_desktop.sh delete mode 100755 automated-tests/TET/_export_env.sh delete mode 100644 automated-tests/TET/_export_sbs.sh delete mode 100755 automated-tests/TET/_export_target_env.sh delete mode 100755 automated-tests/TET/build.sh delete mode 100755 automated-tests/TET/build_out.sh delete mode 100644 automated-tests/TET/coverage.mk delete mode 100755 automated-tests/TET/coverage.sh delete mode 100644 automated-tests/TET/dali-internal-test-suite/image-factory/.gitignore delete mode 120000 automated-tests/TET/dali-internal-test-suite/image-factory/Makefile delete mode 100644 automated-tests/TET/dali-internal-test-suite/image-factory/file.list delete mode 100644 automated-tests/TET/dali-internal-test-suite/image-factory/tslist delete mode 100644 automated-tests/TET/dali-internal-test-suite/image-factory/utc-Dali-ImageFactory.cpp delete mode 100644 automated-tests/TET/dali-internal-test-suite/master-makefile.mk delete mode 100644 automated-tests/TET/dali-internal-test-suite/material/.gitignore delete mode 120000 automated-tests/TET/dali-internal-test-suite/material/Makefile delete mode 100644 automated-tests/TET/dali-internal-test-suite/material/file.list delete mode 100644 automated-tests/TET/dali-internal-test-suite/material/tslist delete mode 100644 automated-tests/TET/dali-internal-test-suite/material/utc-Dali-Material.cpp delete mode 100644 automated-tests/TET/dali-internal-test-suite/resource-manager/.gitignore delete mode 120000 automated-tests/TET/dali-internal-test-suite/resource-manager/Makefile delete mode 100644 automated-tests/TET/dali-internal-test-suite/resource-manager/file.list delete mode 100644 automated-tests/TET/dali-internal-test-suite/resource-manager/tslist delete mode 100644 automated-tests/TET/dali-internal-test-suite/resource-manager/utc-DaliInternal-ResourceClient.cpp delete mode 120000 automated-tests/TET/dali-internal-test-suite/tc-gen.sh delete mode 100644 automated-tests/TET/dali-internal-test-suite/text/.gitignore delete mode 120000 automated-tests/TET/dali-internal-test-suite/text/Makefile delete mode 100644 automated-tests/TET/dali-internal-test-suite/text/file.list delete mode 100644 automated-tests/TET/dali-internal-test-suite/text/tslist delete mode 100644 automated-tests/TET/dali-internal-test-suite/text/utc-DaliInternal-Font.cpp delete mode 100644 automated-tests/TET/dali-internal-test-suite/utc-MODULE-CLASS.cpp.in delete mode 100644 automated-tests/TET/dali-test-suite-utils/dali-test-suite-internal-utils.h delete mode 100644 automated-tests/TET/dali-test-suite-utils/dali-test-suite-utils.h delete mode 100644 automated-tests/TET/dali-test-suite-utils/mesh-builder.h delete mode 100644 automated-tests/TET/dali-test-suite-utils/test-application.cpp delete mode 100644 automated-tests/TET/dali-test-suite-utils/test-application.h delete mode 100644 automated-tests/TET/dali-test-suite-utils/test-gesture-manager.h delete mode 100644 automated-tests/TET/dali-test-suite-utils/test-gl-abstraction.h delete mode 100644 automated-tests/TET/dali-test-suite-utils/test-gl-sync-abstraction.h delete mode 100644 automated-tests/TET/dali-test-suite-utils/test-native-image.h delete mode 100644 automated-tests/TET/dali-test-suite-utils/test-platform-abstraction.h delete mode 100644 automated-tests/TET/dali-test-suite-utils/test-render-controller.h delete mode 100644 automated-tests/TET/dali-test-suite-utils/test-trace-call-stack.h delete mode 100644 automated-tests/TET/dali-test-suite/actors/.gitignore delete mode 120000 automated-tests/TET/dali-test-suite/actors/Makefile delete mode 100644 automated-tests/TET/dali-test-suite/actors/file.list delete mode 100644 automated-tests/TET/dali-test-suite/actors/tslist delete mode 100644 automated-tests/TET/dali-test-suite/actors/tslist-renderables delete mode 100644 automated-tests/TET/dali-test-suite/actors/tslist-text-actor delete mode 100644 automated-tests/TET/dali-test-suite/actors/utc-Dali-Actor.cpp delete mode 100644 automated-tests/TET/dali-test-suite/actors/utc-Dali-BaseHandle.cpp delete mode 100644 automated-tests/TET/dali-test-suite/actors/utc-Dali-CameraActor.cpp delete mode 100644 automated-tests/TET/dali-test-suite/actors/utc-Dali-Constrainable.cpp delete mode 100644 automated-tests/TET/dali-test-suite/actors/utc-Dali-CustomActor.cpp delete mode 100644 automated-tests/TET/dali-test-suite/actors/utc-Dali-Handle.cpp delete mode 100644 automated-tests/TET/dali-test-suite/actors/utc-Dali-ImageActor.cpp delete mode 100644 automated-tests/TET/dali-test-suite/actors/utc-Dali-Layer.cpp delete mode 100644 automated-tests/TET/dali-test-suite/actors/utc-Dali-LightActor.cpp delete mode 100644 automated-tests/TET/dali-test-suite/actors/utc-Dali-MeshActor.cpp delete mode 100644 automated-tests/TET/dali-test-suite/actors/utc-Dali-Model.cpp delete mode 100644 automated-tests/TET/dali-test-suite/actors/utc-Dali-RenderableActor.cpp delete mode 100644 automated-tests/TET/dali-test-suite/actors/utc-Dali-Stage.cpp delete mode 100644 automated-tests/TET/dali-test-suite/actors/utc-Dali-TextActor.cpp delete mode 100644 automated-tests/TET/dali-test-suite/animation/.gitignore delete mode 120000 automated-tests/TET/dali-test-suite/animation/Makefile delete mode 100644 automated-tests/TET/dali-test-suite/animation/file.list delete mode 100644 automated-tests/TET/dali-test-suite/animation/tslist delete mode 100644 automated-tests/TET/dali-test-suite/animation/utc-Dali-ActiveConstraint.cpp delete mode 100644 automated-tests/TET/dali-test-suite/animation/utc-Dali-AlphaFunctions.cpp delete mode 100644 automated-tests/TET/dali-test-suite/animation/utc-Dali-Animation.cpp delete mode 100644 automated-tests/TET/dali-test-suite/animation/utc-Dali-Constraint.cpp delete mode 100644 automated-tests/TET/dali-test-suite/common/.gitignore delete mode 120000 automated-tests/TET/dali-test-suite/common/Makefile delete mode 100644 automated-tests/TET/dali-test-suite/common/file.list delete mode 100755 automated-tests/TET/dali-test-suite/common/tc-gen.sh delete mode 100644 automated-tests/TET/dali-test-suite/common/tslist delete mode 100644 automated-tests/TET/dali-test-suite/common/utc-Dali-Any.cpp delete mode 100644 automated-tests/TET/dali-test-suite/common/utc-Dali-LocklessBuffer.cpp delete mode 100644 automated-tests/TET/dali-test-suite/common/utc-Dali-Vector.cpp delete mode 100644 automated-tests/TET/dali-test-suite/context/.gitignore delete mode 120000 automated-tests/TET/dali-test-suite/context/Makefile delete mode 100644 automated-tests/TET/dali-test-suite/context/file.list delete mode 100644 automated-tests/TET/dali-test-suite/context/tslist delete mode 100644 automated-tests/TET/dali-test-suite/context/utc-Dali-Context.cpp delete mode 100644 automated-tests/TET/dali-test-suite/dynamics/.gitignore delete mode 100644 automated-tests/TET/dali-test-suite/dynamics/Makefile delete mode 100644 automated-tests/TET/dali-test-suite/dynamics/file.list delete mode 100644 automated-tests/TET/dali-test-suite/dynamics/tslist delete mode 100644 automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsBody.cpp delete mode 100644 automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsBodyConfig.cpp delete mode 100644 automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsJoint.cpp delete mode 100644 automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsShape.cpp delete mode 100644 automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsWorld.cpp delete mode 100644 automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsWorldConfig.cpp delete mode 100644 automated-tests/TET/dali-test-suite/effects/.gitignore delete mode 120000 automated-tests/TET/dali-test-suite/effects/Makefile delete mode 100644 automated-tests/TET/dali-test-suite/effects/file.list delete mode 100644 automated-tests/TET/dali-test-suite/effects/tslist delete mode 100644 automated-tests/TET/dali-test-suite/effects/utc-Dali-ShaderEffect.cpp delete mode 100644 automated-tests/TET/dali-test-suite/events/.gitignore delete mode 120000 automated-tests/TET/dali-test-suite/events/Makefile delete mode 100644 automated-tests/TET/dali-test-suite/events/file.list delete mode 100644 automated-tests/TET/dali-test-suite/events/tslist delete mode 100644 automated-tests/TET/dali-test-suite/events/utc-Dali-EventProcessing.cpp delete mode 100644 automated-tests/TET/dali-test-suite/events/utc-Dali-Gesture.cpp delete mode 100644 automated-tests/TET/dali-test-suite/events/utc-Dali-GestureDetector.cpp delete mode 100644 automated-tests/TET/dali-test-suite/events/utc-Dali-HitTestAlgorithm.cpp delete mode 100644 automated-tests/TET/dali-test-suite/events/utc-Dali-KeyEvent.cpp delete mode 100644 automated-tests/TET/dali-test-suite/events/utc-Dali-LongPressGesture.cpp delete mode 100644 automated-tests/TET/dali-test-suite/events/utc-Dali-LongPressGestureDetector.cpp delete mode 100644 automated-tests/TET/dali-test-suite/events/utc-Dali-MouseWheelEvent.cpp delete mode 100644 automated-tests/TET/dali-test-suite/events/utc-Dali-PanGesture.cpp delete mode 100644 automated-tests/TET/dali-test-suite/events/utc-Dali-PanGestureDetector.cpp delete mode 100644 automated-tests/TET/dali-test-suite/events/utc-Dali-PinchGesture.cpp delete mode 100644 automated-tests/TET/dali-test-suite/events/utc-Dali-PinchGestureDetector.cpp delete mode 100644 automated-tests/TET/dali-test-suite/events/utc-Dali-TapGesture.cpp delete mode 100644 automated-tests/TET/dali-test-suite/events/utc-Dali-TapGestureDetector.cpp delete mode 100644 automated-tests/TET/dali-test-suite/events/utc-Dali-TouchEventCombiner.cpp delete mode 100644 automated-tests/TET/dali-test-suite/events/utc-Dali-TouchProcessing.cpp delete mode 100644 automated-tests/TET/dali-test-suite/geometry/.gitignore delete mode 120000 automated-tests/TET/dali-test-suite/geometry/Makefile delete mode 100644 automated-tests/TET/dali-test-suite/geometry/file.list delete mode 100644 automated-tests/TET/dali-test-suite/geometry/tslist delete mode 100644 automated-tests/TET/dali-test-suite/geometry/utc-Dali-AnimatableMesh.cpp delete mode 100644 automated-tests/TET/dali-test-suite/geometry/utc-Dali-MeshData.cpp delete mode 100644 automated-tests/TET/dali-test-suite/geometry/utc-Dali-Spline.cpp delete mode 100644 automated-tests/TET/dali-test-suite/images/.gitignore delete mode 120000 automated-tests/TET/dali-test-suite/images/Makefile delete mode 100644 automated-tests/TET/dali-test-suite/images/file.list delete mode 100644 automated-tests/TET/dali-test-suite/images/tslist delete mode 100644 automated-tests/TET/dali-test-suite/images/utc-Dali-BitmapImage.cpp delete mode 100644 automated-tests/TET/dali-test-suite/images/utc-Dali-DistanceField.cpp delete mode 100644 automated-tests/TET/dali-test-suite/images/utc-Dali-EncodedBufferImage.cpp delete mode 100644 automated-tests/TET/dali-test-suite/images/utc-Dali-FrameBufferImage.cpp delete mode 100644 automated-tests/TET/dali-test-suite/images/utc-Dali-Image.cpp delete mode 100644 automated-tests/TET/dali-test-suite/images/utc-Dali-ImageAttributes.cpp delete mode 100644 automated-tests/TET/dali-test-suite/images/utc-Dali-Pixel.cpp delete mode 100644 automated-tests/TET/dali-test-suite/images/utc-MODULE-CLASS.cpp.in delete mode 100644 automated-tests/TET/dali-test-suite/master-makefile.mk delete mode 100644 automated-tests/TET/dali-test-suite/material/.gitignore delete mode 120000 automated-tests/TET/dali-test-suite/material/Makefile delete mode 100644 automated-tests/TET/dali-test-suite/material/file.list delete mode 100644 automated-tests/TET/dali-test-suite/material/tslist delete mode 100644 automated-tests/TET/dali-test-suite/material/utc-Dali-Material.cpp delete mode 100644 automated-tests/TET/dali-test-suite/math/.gitignore delete mode 120000 automated-tests/TET/dali-test-suite/math/Makefile delete mode 100644 automated-tests/TET/dali-test-suite/math/file.list delete mode 100644 automated-tests/TET/dali-test-suite/math/tslist delete mode 100644 automated-tests/TET/dali-test-suite/math/utc-Dali-AngleAxis.cpp delete mode 100644 automated-tests/TET/dali-test-suite/math/utc-Dali-Degree.cpp delete mode 100644 automated-tests/TET/dali-test-suite/math/utc-Dali-MathUtils.cpp delete mode 100644 automated-tests/TET/dali-test-suite/math/utc-Dali-Matrix.cpp delete mode 100644 automated-tests/TET/dali-test-suite/math/utc-Dali-Matrix3.cpp delete mode 100644 automated-tests/TET/dali-test-suite/math/utc-Dali-Quaternion.cpp delete mode 100644 automated-tests/TET/dali-test-suite/math/utc-Dali-Radian.cpp delete mode 100644 automated-tests/TET/dali-test-suite/math/utc-Dali-Random.cpp delete mode 100644 automated-tests/TET/dali-test-suite/math/utc-Dali-Rect.cpp delete mode 100644 automated-tests/TET/dali-test-suite/math/utc-Dali-Vector2.cpp delete mode 100644 automated-tests/TET/dali-test-suite/math/utc-Dali-Vector3.cpp delete mode 100644 automated-tests/TET/dali-test-suite/math/utc-Dali-Vector4.cpp delete mode 100644 automated-tests/TET/dali-test-suite/object-registry/.gitignore delete mode 120000 automated-tests/TET/dali-test-suite/object-registry/Makefile delete mode 100644 automated-tests/TET/dali-test-suite/object-registry/file.list delete mode 100644 automated-tests/TET/dali-test-suite/object-registry/tslist delete mode 100644 automated-tests/TET/dali-test-suite/object-registry/utc-Dali-ObjectRegistry.cpp delete mode 100644 automated-tests/TET/dali-test-suite/property-notification/.gitignore delete mode 120000 automated-tests/TET/dali-test-suite/property-notification/Makefile delete mode 100644 automated-tests/TET/dali-test-suite/property-notification/file.list delete mode 100644 automated-tests/TET/dali-test-suite/property-notification/tslist delete mode 100644 automated-tests/TET/dali-test-suite/property-notification/utc-Dali-PropertyNotification.cpp delete mode 100644 automated-tests/TET/dali-test-suite/render-tasks/.gitignore delete mode 120000 automated-tests/TET/dali-test-suite/render-tasks/Makefile delete mode 100644 automated-tests/TET/dali-test-suite/render-tasks/file.list delete mode 100644 automated-tests/TET/dali-test-suite/render-tasks/tslist delete mode 100644 automated-tests/TET/dali-test-suite/render-tasks/utc-Dali-RenderTask.cpp delete mode 100644 automated-tests/TET/dali-test-suite/render-tasks/utc-Dali-RenderTaskList.cpp delete mode 100644 automated-tests/TET/dali-test-suite/scripting/.gitignore delete mode 120000 automated-tests/TET/dali-test-suite/scripting/Makefile delete mode 100644 automated-tests/TET/dali-test-suite/scripting/file.list delete mode 100644 automated-tests/TET/dali-test-suite/scripting/tslist delete mode 100644 automated-tests/TET/dali-test-suite/scripting/utc-Dali-Scripting.cpp delete mode 100644 automated-tests/TET/dali-test-suite/signals/.gitignore delete mode 120000 automated-tests/TET/dali-test-suite/signals/Makefile delete mode 100644 automated-tests/TET/dali-test-suite/signals/file.list delete mode 100644 automated-tests/TET/dali-test-suite/signals/tslist delete mode 100644 automated-tests/TET/dali-test-suite/signals/utc-Dali-SignalTemplatesFunctors.cpp delete mode 100644 automated-tests/TET/dali-test-suite/signals/utc-Dali-SignalTemplatesV2.cpp delete mode 100755 automated-tests/TET/dali-test-suite/tc-gen.sh delete mode 100644 automated-tests/TET/dali-test-suite/text/.gitignore delete mode 120000 automated-tests/TET/dali-test-suite/text/Makefile delete mode 100644 automated-tests/TET/dali-test-suite/text/file.list delete mode 100644 automated-tests/TET/dali-test-suite/text/tslist delete mode 100644 automated-tests/TET/dali-test-suite/text/utc-Dali-Character.cpp delete mode 100644 automated-tests/TET/dali-test-suite/text/utc-Dali-Font.cpp delete mode 100644 automated-tests/TET/dali-test-suite/text/utc-Dali-FontParameters.cpp delete mode 100644 automated-tests/TET/dali-test-suite/text/utc-Dali-Text.cpp delete mode 100644 automated-tests/TET/dali-test-suite/text/utc-Dali-TextStyle.cpp delete mode 100644 automated-tests/TET/dali-test-suite/text/utc-Dali-Utf8.cpp delete mode 100644 automated-tests/TET/dali-test-suite/type-registry/.gitignore delete mode 120000 automated-tests/TET/dali-test-suite/type-registry/Makefile delete mode 100644 automated-tests/TET/dali-test-suite/type-registry/file.list delete mode 100644 automated-tests/TET/dali-test-suite/type-registry/tslist delete mode 100644 automated-tests/TET/dali-test-suite/type-registry/utc-Dali-TypeRegistry.cpp delete mode 100644 automated-tests/TET/dali-test-suite/utc-MODULE-CLASS.cpp.in delete mode 100755 automated-tests/TET/debug.sh delete mode 100644 automated-tests/TET/debug_target.sh delete mode 100755 automated-tests/TET/execute.sh delete mode 100755 automated-tests/TET/execute_target.sh delete mode 100644 automated-tests/TET/file.list delete mode 100644 automated-tests/TET/rules.mk.in delete mode 100755 automated-tests/TET/tbp.pl delete mode 100644 automated-tests/TET/tet_scen delete mode 100644 automated-tests/TET/tetbuild.cfg delete mode 100644 automated-tests/TET/tetclean.cfg delete mode 100644 automated-tests/TET/tetexec.cfg rename automated-tests/src/dali-internal/{utc-DaliInternal-Font.cpp => utc-Dali-Internal-Font.cpp} (100%) create mode 100644 automated-tests/src/dali-internal/utc-Dali-Internal-Handles.cpp rename automated-tests/src/dali-internal/{utc-Dali-ImageFactory.cpp => utc-Dali-Internal-ImageFactory.cpp} (100%) rename automated-tests/src/dali-internal/{utc-Dali-Material.cpp => utc-Dali-Internal-Material.cpp} (100%) rename automated-tests/src/dali-internal/{utc-DaliInternal-ResourceClient.cpp => utc-Dali-Internal-ResourceClient.cpp} (100%) create mode 100644 automated-tests/src/dali-internal/utc-Dali-Internal-Text.cpp create mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-AnimatableMesh.cpp rename automated-tests/{TET/dali-test-suite/images => src/dali-unmanaged}/utc-Dali-GlyphImage.cpp (70%) diff --git a/automated-tests/TET/.gitignore b/automated-tests/TET/.gitignore deleted file mode 100644 index 8af138b..0000000 --- a/automated-tests/TET/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -!Makefile -tet_captured -results-desktop -results-target -results -/dali-test-suite-utils.pc -rules.mk -dali.info diff --git a/automated-tests/TET/_export_desktop.sh b/automated-tests/TET/_export_desktop.sh deleted file mode 100644 index eeea3ed..0000000 --- a/automated-tests/TET/_export_desktop.sh +++ /dev/null @@ -1,33 +0,0 @@ -export ARCH=desktop - - -if [ -z "$DESKTOP_PREFIX" ] ; then - if [ -z "$PREFIX" ] ; then - echo "####################################################" - echo "# DESKTOP_PREFIX is not set. Recommend running #" - echo "# dali_env -s to create setenv script #" - echo "####################################################" - else - echo "####################################################" - echo "# DESKTOP_PREFIX is not set. Using PREFIX instead. #" - echo "# #" - echo "# Warning, PREFIX is deprecated, please use #" - echo "# dali_env to set up your environment. #" - echo "####################################################" - export DESKTOP_PREFIX=$PREFIX - fi -fi - -export TET_INSTALL_PATH=$HOME/Packages/tetware-desktop # Your tetware root path -export PATH=$TET_INSTALL_PATH/bin:$PATH -export LD_LIBRARY_PATH=$TET_INSTALL_PATH/lib/tet3:$LD_LIBRARY_PATH -export TET_ROOT=$TET_INSTALL_PATH -export DALI_IMAGE_DIR=$DESKTOP_PREFIX/share/app.dalimenu/images/ -export DALI_MODEL_DIR=$DESKTOP_PREFIX/share/app.dalimenu/models/ -export DALI_STYLE_DIR=$DESKTOP_PREFIX/share/themes/dali/ - -set $(pwd) -export TET_SUITE_ROOT=$1 - -set $(date +%s) -FILE_NAME_EXTENSION=$1 diff --git a/automated-tests/TET/_export_env.sh b/automated-tests/TET/_export_env.sh deleted file mode 100755 index 4e2dc90..0000000 --- a/automated-tests/TET/_export_env.sh +++ /dev/null @@ -1,17 +0,0 @@ -export ARCH=target - -export TET_INSTALL_PATH=/scratchbox/TETware # tetware root path -export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target # tetware target path -export PATH=$TET_TARGET_PATH/bin:$PATH -export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH -export DALI_IMAGE_DIR=/opt/share/app.dalimenu/images/ -export DALI_MODEL_DIR=/opt/share/app.dalimenu/models/ -export DALI_STYLE_DIR=/opt/share/themes/dali/ - -export TET_ROOT=$TET_TARGET_PATH - -set $(pwd) -export TET_SUITE_ROOT=$1 - -set $(date +%s) -FILE_NAME_EXTENSION=$1 diff --git a/automated-tests/TET/_export_sbs.sh b/automated-tests/TET/_export_sbs.sh deleted file mode 100644 index bc5a4af..0000000 --- a/automated-tests/TET/_export_sbs.sh +++ /dev/null @@ -1,17 +0,0 @@ -export ARCH=target - -export TET_INSTALL_PATH=$HOME/git/TETware # tetware root path -export TET_TARGET_PATH=$TET_INSTALL_PATH -export PATH=$TET_TARGET_PATH/bin:$PATH -export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH -export DALI_IMAGE_DIR=/opt/share/app.dalimenu/images/ -export DALI_MODEL_DIR=/opt/share/app.dalimenu/models/ -export DALI_STYLE_DIR=/opt/share/themes/dali/ - -export TET_ROOT=$TET_TARGET_PATH - -set $(pwd) -export TET_SUITE_ROOT=$1 - -set $(date +%s) -FILE_NAME_EXTENSION=$1 diff --git a/automated-tests/TET/_export_target_env.sh b/automated-tests/TET/_export_target_env.sh deleted file mode 100755 index 4c1b135..0000000 --- a/automated-tests/TET/_export_target_env.sh +++ /dev/null @@ -1,17 +0,0 @@ -export ARCH=target - -export TET_INSTALL_PATH=/mnt/nfs/git/TETware # path to mount -export TET_TARGET_PATH=$TET_INSTALL_PATH -export PATH=$TET_TARGET_PATH/bin:$PATH -export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH -export DALI_IMAGE_DIR=/opt/share/app.dalimenu/images/ -export DALI_MODEL_DIR=/opt/share/app.dalimenu/models/ -export DALI_STYLE_DIR=/opt/share/themes/dali/ - -export TET_ROOT=$TET_TARGET_PATH - -set $(pwd) -export TET_SUITE_ROOT=$1 - -set $(date +%s) -FILE_NAME_EXTENSION=$1 diff --git a/automated-tests/TET/build.sh b/automated-tests/TET/build.sh deleted file mode 100755 index 0aa030f..0000000 --- a/automated-tests/TET/build.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/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/TET/build_out.sh b/automated-tests/TET/build_out.sh deleted file mode 100755 index efb93a1..0000000 --- a/automated-tests/TET/build_out.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -./build.sh -v $* diff --git a/automated-tests/TET/coverage.mk b/automated-tests/TET/coverage.mk deleted file mode 100644 index 5012fd4..0000000 --- a/automated-tests/TET/coverage.mk +++ /dev/null @@ -1 +0,0 @@ -LDFLAGS += --coverage diff --git a/automated-tests/TET/coverage.sh b/automated-tests/TET/coverage.sh deleted file mode 100755 index 98798db..0000000 --- a/automated-tests/TET/coverage.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/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/TET/dali-internal-test-suite/image-factory/.gitignore b/automated-tests/TET/dali-internal-test-suite/image-factory/.gitignore deleted file mode 100644 index 627892f..0000000 --- a/automated-tests/TET/dali-internal-test-suite/image-factory/.gitignore +++ /dev/null @@ -1 +0,0 @@ -utc-Dali-ImageFactory diff --git a/automated-tests/TET/dali-internal-test-suite/image-factory/Makefile b/automated-tests/TET/dali-internal-test-suite/image-factory/Makefile deleted file mode 120000 index c88d5a7..0000000 --- a/automated-tests/TET/dali-internal-test-suite/image-factory/Makefile +++ /dev/null @@ -1 +0,0 @@ -../master-makefile.mk \ No newline at end of file diff --git a/automated-tests/TET/dali-internal-test-suite/image-factory/file.list b/automated-tests/TET/dali-internal-test-suite/image-factory/file.list deleted file mode 100644 index a15dfe3..0000000 --- a/automated-tests/TET/dali-internal-test-suite/image-factory/file.list +++ /dev/null @@ -1,2 +0,0 @@ -TARGETS += \ - utc-Dali-ImageFactory \ diff --git a/automated-tests/TET/dali-internal-test-suite/image-factory/tslist b/automated-tests/TET/dali-internal-test-suite/image-factory/tslist deleted file mode 100644 index 4159046..0000000 --- a/automated-tests/TET/dali-internal-test-suite/image-factory/tslist +++ /dev/null @@ -1 +0,0 @@ -/dali-internal-test-suite/image-factory/utc-Dali-ImageFactory diff --git a/automated-tests/TET/dali-internal-test-suite/image-factory/utc-Dali-ImageFactory.cpp b/automated-tests/TET/dali-internal-test-suite/image-factory/utc-Dali-ImageFactory.cpp deleted file mode 100644 index 66a7595..0000000 --- a/automated-tests/TET/dali-internal-test-suite/image-factory/utc-Dali-ImageFactory.cpp +++ /dev/null @@ -1,611 +0,0 @@ -// -// 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; - -using Internal::ResourceTicketPtr; -using Internal::ImageFactory; -using Internal::ImageFactoryCache::RequestPtr; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static const char* gTestImageFilename = "icon_wrt.png"; - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) - -TEST_FUNCTION( UtcDaliImageFactoryUseCachedRequest01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageFactoryUseCachedRequest02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageFactoryUseCachedRequest03, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageFactoryUseCachedRequest04, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageFactoryCompatibleResource01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageFactoryCompatibleResource02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageFactoryCompatibleResource03, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageFactoryReload01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageFactoryReload02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageFactoryReload03, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageFactoryReload04, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageFactoryReload05, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageFactoryReload06, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -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(); -} - -// High-level test for image factory request cache -static void UtcDaliImageFactoryUseCachedRequest01() -{ - 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 ) ); -} - -// High-level test for image factory request cache -static void UtcDaliImageFactoryUseCachedRequest02() -{ - 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 ) ); -} - -// Low-level test for image factory request cache -static void UtcDaliImageFactoryUseCachedRequest03() -{ - 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 ); -} - -// Low-level test for image factory request cache -static void UtcDaliImageFactoryUseCachedRequest04() -{ - 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 ); -} - -// Different requests, compatible resource -static void UtcDaliImageFactoryCompatibleResource01() -{ - 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 -} - -// Different requests, compatible resource -static void UtcDaliImageFactoryCompatibleResource02() -{ - 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 -} - -// Different requests, compatible resource -static void UtcDaliImageFactoryCompatibleResource03() -{ - 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 -} - -// Test for reloading image -static void UtcDaliImageFactoryReload01() -{ - 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 ); -} - -// Testing file system access when reloading image -static void UtcDaliImageFactoryReload02() -{ - 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 ) ); -} - -// Test for reloading changed image -static void UtcDaliImageFactoryReload03() -{ - 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 ); -} - -// Testing file system access when reloading image -static void UtcDaliImageFactoryReload04() -{ - 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 ) ); -} - -// Testing OnDemand + Reload -// Reload should have no effect if OnDemand Image is not loaded yet, as stated in the API documentation -static void UtcDaliImageFactoryReload05() -{ - 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 ) ); -} - -// Initally two different requests map to same resource. -// After overwriting the file, they load different image resources. -static void UtcDaliImageFactoryReload06() -{ - 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 -} diff --git a/automated-tests/TET/dali-internal-test-suite/master-makefile.mk b/automated-tests/TET/dali-internal-test-suite/master-makefile.mk deleted file mode 100644 index 3bb53d5..0000000 --- a/automated-tests/TET/dali-internal-test-suite/master-makefile.mk +++ /dev/null @@ -1,40 +0,0 @@ -# -# 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. -# - -CC = g++ - -TARGETS = -include file.list - -PKGS = dali-core -include ../../rules.mk -include ../../coverage.mk - -all: $(TARGETS) - -%: %.cpp - $(CC) -o $@ $< ../../dali-test-suite-utils/test-application.cpp $(CXXFLAGS) $(LDFLAGS) - -clean: - @rm -f $(notdir $(TARGETS)) - @rm -f tet_captured - @rm -f *~ - @rm -f *.gcda *.gcno - -coverage: - @lcov --directory . -c -o dali.info - @lcov --remove dali.info "*boost*" "/usr/include/*" "*/automated-tests/*" -o dali.info diff --git a/automated-tests/TET/dali-internal-test-suite/material/.gitignore b/automated-tests/TET/dali-internal-test-suite/material/.gitignore deleted file mode 100644 index d0e475b..0000000 --- a/automated-tests/TET/dali-internal-test-suite/material/.gitignore +++ /dev/null @@ -1 +0,0 @@ -utc-Dali-Material diff --git a/automated-tests/TET/dali-internal-test-suite/material/Makefile b/automated-tests/TET/dali-internal-test-suite/material/Makefile deleted file mode 120000 index c88d5a7..0000000 --- a/automated-tests/TET/dali-internal-test-suite/material/Makefile +++ /dev/null @@ -1 +0,0 @@ -../master-makefile.mk \ No newline at end of file diff --git a/automated-tests/TET/dali-internal-test-suite/material/file.list b/automated-tests/TET/dali-internal-test-suite/material/file.list deleted file mode 100644 index aa20a08..0000000 --- a/automated-tests/TET/dali-internal-test-suite/material/file.list +++ /dev/null @@ -1,2 +0,0 @@ -TARGETS += \ - utc-Dali-Material \ diff --git a/automated-tests/TET/dali-internal-test-suite/material/tslist b/automated-tests/TET/dali-internal-test-suite/material/tslist deleted file mode 100644 index 3d47968..0000000 --- a/automated-tests/TET/dali-internal-test-suite/material/tslist +++ /dev/null @@ -1 +0,0 @@ -/dali-internal-test-suite/material/utc-Dali-Material diff --git a/automated-tests/TET/dali-internal-test-suite/material/utc-Dali-Material.cpp b/automated-tests/TET/dali-internal-test-suite/material/utc-Dali-Material.cpp deleted file mode 100644 index 75f42d1..0000000 --- a/automated-tests/TET/dali-internal-test-suite/material/utc-Dali-Material.cpp +++ /dev/null @@ -1,748 +0,0 @@ -// -// 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 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliMaterialMethodNew01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMaterialMethodNew02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMaterialReadyTextureOffstage, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMaterialUnreadyTextureOffstage, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMaterialStaging01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMaterialStaging02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMaterialSetPropsWhilstStaged, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMaterialSetTextureWhilstStaged, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMaterialSetUnreadyTextureWhilstStaged, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMaterialIsOpaqueWithoutTexture, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMaterialIsOpaqueWithTexture, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMaterialIsOpaqueWithProps, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMaterialRender, POSITIVE_TC_IDX ); - - -Dali::Internal::MaterialProperties TEST_PROPS; - -// Called only once before first test is run. -static void Startup() -{ - 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; -} - -// Called only once after last test is run -static void Cleanup() -{ -} - - -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, 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, 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; -} - - - -// Test new with no parameters sets up default object -static void UtcDaliMaterialMethodNew01() -{ - 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()); -} - -// Test new with event object sets up parameters appropriately -static void UtcDaliMaterialMethodNew02() -{ - 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()); -} - -// Test setting ready texture off stage -static void UtcDaliMaterialReadyTextureOffstage() -{ - 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 ); -} - -// Test setting unready texture offstage, becoming ready -static void UtcDaliMaterialUnreadyTextureOffstage() -{ - 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 ); -} - -// Test staging creates render material -static void UtcDaliMaterialStaging01() -{ - 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 ); -} - -// Test staging creates render material -static void UtcDaliMaterialStaging02() -{ - 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 ); -} - - - -// Test setting properties on stage -static void UtcDaliMaterialSetPropsWhilstStaged() -{ - 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 ); -} - -// Test setting ready texture on stage -static void UtcDaliMaterialSetTextureWhilstStaged() -{ - 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 ) ); -} - -// Test setting unready texture on stage, becoming ready -static void UtcDaliMaterialSetUnreadyTextureWhilstStaged() -{ - 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 ) ); -} - -// Test IsOpaque without texture, with unready texture, with ready texture - -static void UtcDaliMaterialIsOpaqueWithoutTexture() -{ - 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() ); -} - -static void UtcDaliMaterialIsOpaqueWithTexture() -{ - 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() ); -} - - -static void UtcDaliMaterialIsOpaqueWithProps() -{ - 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() ); -} - -static void UtcDaliMaterialRender() -{ - 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() ); -} diff --git a/automated-tests/TET/dali-internal-test-suite/resource-manager/.gitignore b/automated-tests/TET/dali-internal-test-suite/resource-manager/.gitignore deleted file mode 100644 index 9b1ba5d..0000000 --- a/automated-tests/TET/dali-internal-test-suite/resource-manager/.gitignore +++ /dev/null @@ -1 +0,0 @@ -utc-DaliInternal-ResourceClient diff --git a/automated-tests/TET/dali-internal-test-suite/resource-manager/Makefile b/automated-tests/TET/dali-internal-test-suite/resource-manager/Makefile deleted file mode 120000 index c88d5a7..0000000 --- a/automated-tests/TET/dali-internal-test-suite/resource-manager/Makefile +++ /dev/null @@ -1 +0,0 @@ -../master-makefile.mk \ No newline at end of file diff --git a/automated-tests/TET/dali-internal-test-suite/resource-manager/file.list b/automated-tests/TET/dali-internal-test-suite/resource-manager/file.list deleted file mode 100644 index 2d14ee6..0000000 --- a/automated-tests/TET/dali-internal-test-suite/resource-manager/file.list +++ /dev/null @@ -1,2 +0,0 @@ -TARGETS += \ - DaliInternal/utc-DaliInternal-ResourceClient \ diff --git a/automated-tests/TET/dali-internal-test-suite/resource-manager/tslist b/automated-tests/TET/dali-internal-test-suite/resource-manager/tslist deleted file mode 100644 index 26881c8..0000000 --- a/automated-tests/TET/dali-internal-test-suite/resource-manager/tslist +++ /dev/null @@ -1,2 +0,0 @@ -/dali-internal-test-suite/resource-manager/utc-DaliInternal-ResourceClient - diff --git a/automated-tests/TET/dali-internal-test-suite/resource-manager/utc-DaliInternal-ResourceClient.cpp b/automated-tests/TET/dali-internal-test-suite/resource-manager/utc-DaliInternal-ResourceClient.cpp deleted file mode 100644 index fea9d2b..0000000 --- a/automated-tests/TET/dali-internal-test-suite/resource-manager/utc-DaliInternal-ResourceClient.cpp +++ /dev/null @@ -1,1438 +0,0 @@ -// -// 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 - -// Internal headers are allowed here - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -using namespace Dali; -#include - -static void Startup(); -static void Cleanup(); - -extern "C" -{ - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliInternalRequestResourceBitmapRequests01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalRequestResourceBitmapRequests02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalRequestResourceBitmapRequests03, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalRequestReloadBitmapRequests01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalRequestReloadBitmapRequests02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalRequestReloadBitmapRequests03, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalSaveResource01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalSaveResource02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalSaveResource03, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalSaveResource04, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalSaveResource05, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalRequestResourceTicket01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalRequestResourceTicket02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalLoadShaderRequest01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalLoadShaderRequest02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalAllocateBitmapImage01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalAddBitmapImage01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalAddBitmapImage02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalAddBitmapImage03, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalGetBitmapImage01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalGetBitmapImage02, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalGetBitmapImage03, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalAllocateTexture01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalAddNativeImage, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalAddFrameBufferImage, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInternalAllocateMesh01, POSITIVE_TC_IDX ); - - -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; - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -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, 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, 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; -} - - -// Load a bitmap resource successfully, then discard it's ticket -static void UtcDaliInternalRequestResourceBitmapRequests01() -{ - 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 ); -} - -// Starting Loading a bitmap resource, then discard it's ticket before loading complete. -static void UtcDaliInternalRequestResourceBitmapRequests02() -{ - 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 ); -} - -// start loading a bitmap resource that doesn't exist, then discard it's ticket after failure -static void UtcDaliInternalRequestResourceBitmapRequests03() -{ - 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)); -} - - - -// Load a bitmap resource successfully, then reload it -static void UtcDaliInternalRequestReloadBitmapRequests01() -{ - 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 ); -} - - -static void UtcDaliInternalRequestReloadBitmapRequests02() -{ - 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 -} - - -static void UtcDaliInternalRequestReloadBitmapRequests03() -{ - 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 ); - } -} - - -static void UtcDaliInternalSaveResource01() -{ - 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 ) -; -} - - -static void UtcDaliInternalSaveResource02() -{ - 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 ); -} - -static void UtcDaliInternalSaveResource03() -{ - 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 ); -} - - -static void UtcDaliInternalSaveResource04() -{ - 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 ) -; -} - -static void UtcDaliInternalSaveResource05() -{ - 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 ) ); -} - -static void UtcDaliInternalRequestResourceTicket01() -{ - 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 ); -} - -static void UtcDaliInternalRequestResourceTicket02() -{ - 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 ); -} - -static void UtcDaliInternalLoadShaderRequest01() -{ - 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 ) ); -} - -static void UtcDaliInternalLoadShaderRequest02() -{ - 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() ); -} - -static void UtcDaliInternalAllocateBitmapImage01() -{ - 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 ); -} - -static void UtcDaliInternalAddBitmapImage01() -{ - 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 ); -} - -static void UtcDaliInternalAddBitmapImage02() -{ - 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. -} - - -static void UtcDaliInternalAddBitmapImage03() -{ - 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 ); -} - -static void UtcDaliInternalGetBitmapImage01() -{ - 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 ); -} - -static void UtcDaliInternalGetBitmapImage02() -{ - 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 ); -} - -static void UtcDaliInternalGetBitmapImage03() -{ - 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 ); -} - -static void UtcDaliInternalAllocateTexture01() -{ - 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 ); -} - -static void UtcDaliInternalAddNativeImage() -{ - 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 ); -} - -static void UtcDaliInternalAddFrameBufferImage() -{ - 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 ); -} - -static void UtcDaliInternalAllocateMesh01() -{ - 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 ); -} diff --git a/automated-tests/TET/dali-internal-test-suite/tc-gen.sh b/automated-tests/TET/dali-internal-test-suite/tc-gen.sh deleted file mode 120000 index b8e6201..0000000 --- a/automated-tests/TET/dali-internal-test-suite/tc-gen.sh +++ /dev/null @@ -1 +0,0 @@ -../dali-test-suite/tc-gen.sh \ No newline at end of file diff --git a/automated-tests/TET/dali-internal-test-suite/text/.gitignore b/automated-tests/TET/dali-internal-test-suite/text/.gitignore deleted file mode 100644 index 11422ec..0000000 --- a/automated-tests/TET/dali-internal-test-suite/text/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -utc-DaliInternal-Font -utc-DaliInternal-TextUtilities diff --git a/automated-tests/TET/dali-internal-test-suite/text/Makefile b/automated-tests/TET/dali-internal-test-suite/text/Makefile deleted file mode 120000 index c88d5a7..0000000 --- a/automated-tests/TET/dali-internal-test-suite/text/Makefile +++ /dev/null @@ -1 +0,0 @@ -../master-makefile.mk \ No newline at end of file diff --git a/automated-tests/TET/dali-internal-test-suite/text/file.list b/automated-tests/TET/dali-internal-test-suite/text/file.list deleted file mode 100644 index 31fe775..0000000 --- a/automated-tests/TET/dali-internal-test-suite/text/file.list +++ /dev/null @@ -1,3 +0,0 @@ -TARGETS += \ - DaliInternal/utc-DaliInternal-Font - diff --git a/automated-tests/TET/dali-internal-test-suite/text/tslist b/automated-tests/TET/dali-internal-test-suite/text/tslist deleted file mode 100644 index dba7e28..0000000 --- a/automated-tests/TET/dali-internal-test-suite/text/tslist +++ /dev/null @@ -1 +0,0 @@ -/dali-internal-test-suite/text/utc-DaliInternal-Font diff --git a/automated-tests/TET/dali-internal-test-suite/text/utc-DaliInternal-Font.cpp b/automated-tests/TET/dali-internal-test-suite/text/utc-DaliInternal-Font.cpp deleted file mode 100644 index 69fc47f..0000000 --- a/automated-tests/TET/dali-internal-test-suite/text/utc-DaliInternal-Font.cpp +++ /dev/null @@ -1,163 +0,0 @@ -// -// 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 - -// Internal headers are allowed here - -#include -#include -#include - -using namespace Dali; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void UtcDaliFontMeasureTextWidth(); -static void UtcDaliFontMeasureTextWidthNegative(); -static void UtcDaliFontMeasureTextHeight(); -static void UtcDaliFontMeasureTextHeightNegative(); - -static const char* TestText = "Some text"; - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -// Add test functionality for all APIs in the class (Positive and Negative) -extern "C" { - struct tet_testlist tet_testlist[] = { - { UtcDaliFontMeasureTextWidth, POSITIVE_TC_IDX }, - { UtcDaliFontMeasureTextWidthNegative, POSITIVE_TC_IDX }, - { UtcDaliFontMeasureTextHeight, POSITIVE_TC_IDX }, - { UtcDaliFontMeasureTextHeightNegative, POSITIVE_TC_IDX }, - { NULL, 0 } - }; -} - -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; -} - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -static void UtcDaliFontMeasureTextWidth() -{ - 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); -} - -static void UtcDaliFontMeasureTextWidthNegative() -{ - 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); -} - -static void UtcDaliFontMeasureTextHeight() -{ - 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); -} - -static void UtcDaliFontMeasureTextHeightNegative() -{ - 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); -} diff --git a/automated-tests/TET/dali-internal-test-suite/utc-MODULE-CLASS.cpp.in b/automated-tests/TET/dali-internal-test-suite/utc-MODULE-CLASS.cpp.in deleted file mode 100644 index bf03ce4..0000000 --- a/automated-tests/TET/dali-internal-test-suite/utc-MODULE-CLASS.cpp.in +++ /dev/null @@ -1,94 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void Utc@MODULE@@CLASS@Method01(); -static void Utc@MODULE@@CLASS@Method02(); - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -// Add test functionality for all APIs in the class (Positive and Negative) -extern "C" { - struct tet_testlist tet_testlist[] = { - { Utc@MODULE@@CLASS@Method01, POSITIVE_TC_IDX }, - { Utc@MODULE@@CLASS@Method02, NEGATIVE_TC_IDX }, - { NULL, 0 } - }; -} - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - - -// Positive test case for a method -static void Utc@MODULE@@CLASS@Method01() -{ - TestApplication application; - - tet_infoline("Journaled printf Output"); - tet_result(TET_FAIL); -#if 0 - tet_result(TET_PASS); -#endif -} - - -// Negative test case for a method -static void Utc@MODULE@@CLASS@Method02() -{ - TestApplication application; // Exceptions require TestApplication - - try - { - /* My test code and results */ - DALI_TEST_EQUALS(myVar, expectedValue, TEST_LOCATION); - } - 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(e, "assert conditional", TEST_LOCATION); - } -} - diff --git a/automated-tests/TET/dali-test-suite-utils/dali-test-suite-internal-utils.h b/automated-tests/TET/dali-test-suite-utils/dali-test-suite-internal-utils.h deleted file mode 100644 index c31802c..0000000 --- a/automated-tests/TET/dali-test-suite-utils/dali-test-suite-internal-utils.h +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef __DALI_TEST_SUITE_INTERNAL_UTILS_H__ -#define __DALI_TEST_SUITE_INTERNAL_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 "dali-test-suite-utils.h" - -#include - -namespace Dali -{ - - -/** - * 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 Matrix3& matrix1, const Matrix3& matrix2, const char* location) -{ - const float* m1 = matrix1.AsFloat(); - const float* m2 = matrix2.AsFloat(); - bool identical = true; - - for (int i=0;i<9;++i) - { - identical &= (m1[i] != m2[i]); - } - - if (!identical) - { - tet_printf("%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); - } -} - - -/** - * 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 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]) - -#include - -#include - -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__) ) ) ) - -/** - * Helper code to wrap each test function with an exception handler - */ - -int numberOfTETTestFunctions; /// Counter for the number of functions added so far - -/** - * This structure is used to initialize the list of functions. - * Creating an object of this type will add the function to the list. - */ -struct AddFunction { - AddFunction( void (*function)(), int type ) - { - tet_testlist[numberOfTETTestFunctions].testfunc = function; - tet_testlist[numberOfTETTestFunctions].icref = type; - ++numberOfTETTestFunctions; - } -}; - -#define TEST_FUNCTION( FUNCTION_NAME, TEST_TYPE ) \ -static void FUNCTION_NAME(); \ -static void check ## FUNCTION_NAME () \ -{ \ - tet_printf( "START OF TEST " #FUNCTION_NAME "\n" ); \ - try { \ - FUNCTION_NAME(); \ - } catch (...) { \ - tet_printf( "Unhandled exception in function " #FUNCTION_NAME ".\n" ); \ - tet_result( TET_FAIL ); \ - } \ - tet_printf( "END OF TEST " #FUNCTION_NAME "\n" ); \ -} \ -AddFunction add ## FUNCTION_NAME ( check ## FUNCTION_NAME, TEST_TYPE ); - - -/** - * 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 \ -{ \ - tet_printf("%s Failed in %s at line %d\n", __PRETTY_FUNCTION__, __FILE__, __LINE__); \ - tet_result(TET_FAIL); \ -} - -template -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 <> -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 <> -bool CompareType(Vector2 vector1, Vector2 vector2, float epsilon) -{ - return fabsf(vector1.x - vector2.x) -bool CompareType(Vector3 vector1, Vector3 vector2, float epsilon) -{ - return fabsf(vector1.x - vector2.x) -bool CompareType(Vector4 vector1, Vector4 vector2, float epsilon) -{ - return fabsf(vector1.x - vector2.x) -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 <> -bool CompareType(Radian q1, Radian q2, float epsilon) -{ - return CompareType(float(q1), float(q2), epsilon); -} - -template <> -bool CompareType(Degree q1, Degree q2, float epsilon) -{ - return CompareType(float(q1), float(q2), epsilon); -} - -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 << ")"; -} - -/** - * 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 -void DALI_TEST_EQUALS(TypeA value1, TypeB value2, const char* location) -{ - if (!(value1 == value2)) - { - std::ostringstream o; - o << value1 << " == " << value2 << std::endl; - tet_printf("%s, checking %s", location, o.str().c_str()); - tet_result(TET_FAIL); - } - else - { - tet_result(TET_PASS); - } -} - -template -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; - tet_printf("%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<> -void DALI_TEST_EQUALS( TimePeriod value1, TimePeriod value2, float epsilon, const char* location) -{ - if ((fabs(value1.durationSeconds - value2.durationSeconds) > epsilon)) - { - tet_printf("%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)) - { - tet_printf("%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 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 - */ -template <> -void DALI_TEST_EQUALS( const Matrix& matrix1, const Matrix& matrix2, const char* location) -{ - const float* m1 = matrix1.AsFloat(); - const float* m2 = matrix2.AsFloat(); - bool identical = true; - - int i; - for (i=0;i<16;++i) - { - if(m1[i] != m2[i]) - { - identical = false; - break; - } - } - - if (!identical) - { - tet_printf("%s, checking\n" - "(%f, %f, %f, %f) (%f, %f, %f, %f)\n" - "(%f, %f, %f, %f) == (%f, %f, %f, %f)\n" - "(%f, %f, %f, %f) (%f, %f, %f, %f)\n" - "(%f, %f, %f, %f) (%f, %f, %f, %f)\n", location, - m1[0], m1[1], m1[2], m1[3], m2[0], m2[1], m2[2], m2[3], - m1[4], m1[5], m1[6], m1[7], m2[4], m2[5], m2[6], m2[7], - m1[8], m1[9], m1[10], m1[11], m2[8], m2[9], m2[10], m2[11], - m1[12], m1[13], m1[14], m1[15], m2[12], m2[13], m2[14], m2[15]); - - tet_result(TET_FAIL); - } - else - { - tet_result(TET_PASS); - } -} - -/** - * 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 - */ -template <> -void DALI_TEST_EQUALS( const Matrix& matrix1, const Matrix& matrix2, float epsilon, const char* location) -{ - const float* m1 = matrix1.AsFloat(); - const float* m2 = matrix2.AsFloat(); - bool equivalent = true; - - for (int i=0;i<16;++i) - { - equivalent &= (fabsf(m1[i] - m2[i]) -void DALI_TEST_EQUALS( Matrix matrix1, Matrix matrix2, float epsilon, const char* location) -{ - const float* m1 = matrix1.AsFloat(); - const float* m2 = matrix2.AsFloat(); - bool equivalent = true; - - for (int i=0;i<16;++i) - { - equivalent &= (fabsf(m1[i] - m2[i]) -void DALI_TEST_EQUALS( const char* str1, const char* str2, const char* location) -{ - if (strcmp(str1, str2)) - { - tet_printf("%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<> -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) -{ - DALI_TEST_EQUALS(str1.c_str(), str2, 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) -{ - DALI_TEST_EQUALS(str1, str2.c_str(), 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<> -void DALI_TEST_EQUALS( const TextArray& str1, const TextArray& str2, const char* location) -{ - if (!std::equal(str1.begin(), str1.end(), str2.begin())) - { - tet_printf("%s, checking '", location); - - for( unsigned int i = 0; i < str1.size(); ++i) - { - tet_printf("%c", str1[i]); - } - - tet_printf("' == '"); - - for( unsigned int i = 0; i < str2.size(); ++i) - { - tet_printf("%c", str2[i]); - } - - tet_printf("'\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) -{ - if (!(value1 > value2)) - { - tet_printf("%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)) - { - tet_printf("%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 )) - { - tet_printf("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 -struct ConstraintAppliedCheck -{ - ConstraintAppliedCheck( bool& signalReceived ) - : mSignalReceived( signalReceived ) - { - } - - void operator()( ActiveConstraint& constraint ) - { - mSignalReceived = true; - } - - void Reset() - { - mSignalReceived = false; - } - - void CheckSignalReceived() - { - if ( !mSignalReceived ) - { - tet_printf( "Expected Applied signal was not received\n" ); - tet_result( TET_FAIL ); - } - else - { - tet_result( TET_PASS ); - } - } - - void CheckSignalNotReceived() - { - if ( mSignalReceived ) - { - tet_printf( "Unexpected Applied signal was received\n" ); - tet_result( TET_FAIL ); - } - else - { - tet_result( TET_PASS ); - } - } - - 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; - } -}; - -} // namespace Dali - -#endif // __DALI_TEST_SUITE_UTILS_H__ diff --git a/automated-tests/TET/dali-test-suite-utils/mesh-builder.h b/automated-tests/TET/dali-test-suite-utils/mesh-builder.h deleted file mode 100644 index 3a7c673..0000000 --- a/automated-tests/TET/dali-test-suite-utils/mesh-builder.h +++ /dev/null @@ -1,232 +0,0 @@ -// -// 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. -// - -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; -} diff --git a/automated-tests/TET/dali-test-suite-utils/test-application.cpp b/automated-tests/TET/dali-test-suite-utils/test-application.cpp deleted file mode 100644 index fe27b07..0000000 --- a/automated-tests/TET/dali-test-suite-utils/test-application.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#define tet_infoline printf -#define tet_printf printf -#include "test-application.h" - -bool BlendEnabled(const TraceCallStack& callStack) -{ - std::stringstream out; - out << GL_BLEND; - bool blendEnabled = callStack.FindMethodAndParams("Enable", out.str()); - return blendEnabled; -} - -bool BlendDisabled(const TraceCallStack& callStack) -{ - std::stringstream out; - out << GL_BLEND; - bool blendEnabled = callStack.FindMethodAndParams("Disable", out.str()); - return blendEnabled; -} - - diff --git a/automated-tests/TET/dali-test-suite-utils/test-application.h b/automated-tests/TET/dali-test-suite-utils/test-application.h deleted file mode 100644 index 720248a..0000000 --- a/automated-tests/TET/dali-test-suite-utils/test-application.h +++ /dev/null @@ -1,241 +0,0 @@ -#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 "test-platform-abstraction.h" -#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 ) - : mCore( NULL ), - mSurfaceWidth( surfaceWidth ), - mSurfaceHeight( surfaceHeight ), - mFrame( 0u ), - mDpi( horizontalDpi, verticalDpi ) - { - Initialize(); - } - - 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 ) - : mCore( NULL ), - mSurfaceWidth( surfaceWidth ), - mSurfaceHeight( surfaceHeight ), - mFrame( 0u ), - mDpi( horizontalDpi, verticalDpi ) - { - if ( initialize ) - { - Initialize(); - } - } - - void 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); - } - - virtual ~TestApplication() - { - Dali::Integration::Log::UninstallLogFunction(); - delete mCore; - } - - static void LogMessage(Dali::Integration::Log::DebugPriority level, std::string& message) - { - switch(level) - { - case Dali::Integration::Log::DebugInfo: - tet_printf("INFO: %s", message.c_str()); - break; - case Dali::Integration::Log::DebugWarning: - tet_printf("WARN: %s", message.c_str()); - break; - case Dali::Integration::Log::DebugError: - tet_printf("ERROR: %s", message.c_str()); - break; - default: - tet_printf("DEFAULT: %s", message.c_str()); - break; - } - } - - Dali::Integration::Core& GetCore() - { - return *mCore; - } - - TestPlatformAbstraction& GetPlatform() - { - return mPlatformAbstraction; - } - - TestRenderController& GetRenderController() - { - return mRenderController; - } - - TestGlAbstraction& GetGlAbstraction() - { - return mGlAbstraction; - } - - TestGlSyncAbstraction& GetGlSyncAbstraction() - { - return mGlSyncAbstraction; - } - - TestGestureManager& GetGestureManager() - { - return mGestureManager; - } - - void ProcessEvent(const Integration::Event& event) - { - mCore->QueueEvent(event); - mCore->ProcessEvents(); - } - - void SendNotification() - { - mCore->ProcessEvents(); - } - - void SetSurfaceWidth( unsigned int width, unsigned height ) - { - mSurfaceWidth = width; - mSurfaceHeight = height; - - mCore->SurfaceResized( mSurfaceWidth, mSurfaceHeight ); - } - - bool Render( unsigned int intervalMilliseconds = DEFAULT_RENDER_INTERVAL ) - { - // 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 GetUpdateStatus() - { - return mStatus.KeepUpdating(); - } - - bool UpdateOnly( unsigned int intervalMilliseconds = DEFAULT_RENDER_INTERVAL ) - { - // 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 RenderOnly( ) - { - // Update Time values - mCore->Render( mRenderStatus ); - - mFrame++; - - return mRenderStatus.NeedsUpdate(); - } - - void ResetContext() - { - mCore->ContextToBeDestroyed(); - mCore->ContextCreated(); - } - -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/TET/dali-test-suite-utils/test-gesture-manager.h b/automated-tests/TET/dali-test-suite-utils/test-gesture-manager.h deleted file mode 100644 index 14e5d63..0000000 --- a/automated-tests/TET/dali-test-suite-utils/test-gesture-manager.h +++ /dev/null @@ -1,139 +0,0 @@ -#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() - { - Initialize(); - } - - /** - * Destructor - */ - virtual ~TestGestureManager() - { - } - - /** - * @copydoc Dali::Integration::GestureManager::Register(Gesture::Type) - */ - virtual void Register(const Integration::GestureRequest& request) - { - mFunctionsCalled.Register = true; - } - - /** - * @copydoc Dali::Integration::GestureManager::Unregister(Gesture::Type) - */ - virtual void Unregister(const Integration::GestureRequest& request) - { - mFunctionsCalled.Unregister = true; - } - - /** - * @copydoc Dali::Integration::GestureManager::Update(Gesture::Type) - */ - virtual void Update(const Integration::GestureRequest& request) - { - mFunctionsCalled.Update = true; - } - -public: // TEST FUNCTIONS - - // Enumeration of Gesture Manager methods - enum TestFuncEnum - { - RegisterType, - UnregisterType, - UpdateType, - }; - - /** Call this every test */ - void Initialize() - { - mFunctionsCalled.Reset(); - } - - bool WasCalled(TestFuncEnum func) - { - switch(func) - { - case RegisterType: return mFunctionsCalled.Register; - case UnregisterType: return mFunctionsCalled.Unregister; - case UpdateType: return mFunctionsCalled.Update; - } - return false; - } - - void ResetCallStatistics(TestFuncEnum func) - { - switch(func) - { - case RegisterType: mFunctionsCalled.Register = false; break; - case UnregisterType: mFunctionsCalled.Unregister = false; break; - case UpdateType: mFunctionsCalled.Update = false; break; - } - } - -private: - - struct TestFunctions - { - TestFunctions() - : Register(false), - Unregister(false), - Update(false) - { - } - - void Reset() - { - Register = false; - Unregister = false; - Update = false; - } - - bool Register; - bool Unregister; - bool Update; - }; - - TestFunctions mFunctionsCalled; -}; - -} // Dali - -#endif // __DALI_TEST_GESTURE_MANAGER_H__ diff --git a/automated-tests/TET/dali-test-suite-utils/test-gl-abstraction.h b/automated-tests/TET/dali-test-suite-utils/test-gl-abstraction.h deleted file mode 100644 index 27adc61..0000000 --- a/automated-tests/TET/dali-test-suite-utils/test-gl-abstraction.h +++ /dev/null @@ -1,1860 +0,0 @@ -#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 - -// INTERNAL INCLUDES -#include - -#include -#include -#include - -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() - { - Initialize(); - } - - ~TestGlAbstraction() {} - - void 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(); - } - - /* OpenGL ES 2.0 */ - - void ActiveTexture( GLenum textureUnit ) - { - mActiveTextureUnit = textureUnit - GL_TEXTURE0; - } - - GLenum GetActiveTextureUnit() const - { - return mActiveTextureUnit + GL_TEXTURE0; - } - - void AttachShader( GLuint program, GLuint shader ) - { - std::stringstream out; - out << program << ", " << shader; - mShaderTrace.PushCall("AttachShader", out.str()); - } - - void BindAttribLocation( GLuint program, GLuint index, const char* name ) - { - } - - void BindBuffer( GLenum target, GLuint buffer ) - { - } - - void BindFramebuffer( GLenum target, GLuint framebuffer ) - { - } - - 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. - */ - 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. - */ - 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. - */ - 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; - } - - void ClearDeletedTextures() - { - mDeletedTextureIds.clear(); - } - - void DepthFunc(GLenum func) - { - } - - void DepthMask(GLboolean flag) - { - } - - void DepthRangef(GLclampf zNear, GLclampf zFar) - { - } - - void DetachShader(GLuint program, GLuint shader) - { - std::stringstream out; - out << program << ", " << shader; - mShaderTrace.PushCall("DetachShader", out.str()); - } - - void Disable(GLenum cap) - { - std::stringstream out; - out << cap; - mCullFaceTrace.PushCall("Disable", out.str()); - } - - void DisableVertexAttribArray(GLuint index) - { - SetVertexAttribArray( index, false ); - } - - void DrawArrays(GLenum mode, GLint first, GLsizei count) - { - std::stringstream out; - out << mode << ", " << first << ", " << count; - mDrawTrace.PushCall("DrawArrays", out.str()); - } - - void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) - { - std::stringstream out; - out << mode << ", " << count << ", " << type << ", indices"; - mDrawTrace.PushCall("DrawElements", out.str()); - } - - void Enable(GLenum cap) - { - std::stringstream out; - out << cap; - mCullFaceTrace.PushCall("Enable", out.str()); - } - - void EnableVertexAttribArray(GLuint index) - { - SetVertexAttribArray( index, true); - } - - void Finish(void) - { - } - - void Flush(void) - { - } - - void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) - { - } - - void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) - { - } - - void FrontFace(GLenum mode) - { - } - - void GenBuffers(GLsizei n, GLuint* buffers) - { - // avoids an assert in GpuBuffers - *buffers = 1u; - } - - void GenerateMipmap(GLenum target) - { - } - - void GenFramebuffers(GLsizei n, GLuint* framebuffers) - { - } - - 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 - */ - void SetNextTextureIds( const std::vector& ids ) - { - mNextTextureIds = ids; - } - - const std::vector& GetNextTextureIds() - { - return mNextTextureIds; - } - - 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; - } - - void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) - { - } - - void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params) - { - } - - void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer) - { - } - - void Hint(GLenum target, GLenum mode) - { - } - - GLboolean IsBuffer(GLuint buffer) - { - return mIsBufferResult; - } - - GLboolean IsEnabled(GLenum cap) - { - return mIsEnabledResult; - } - - GLboolean IsFramebuffer(GLuint framebuffer) - { - return mIsFramebufferResult; - } - - GLboolean IsProgram(GLuint program) - { - return mIsProgramResult; - } - - GLboolean IsRenderbuffer(GLuint renderbuffer) - { - return mIsRenderbufferResult; - } - - GLboolean IsShader(GLuint shader) - { - return mIsShaderResult; - } - - GLboolean IsTexture(GLuint texture) - { - return mIsTextureResult; - } - - void LineWidth(GLfloat width) - { - } - - void LinkProgram(GLuint program) - { - std::stringstream out; - out << program; - mShaderTrace.PushCall("LinkProgram", out.str()); - } - - void PixelStorei(GLenum pname, GLint param) - { - } - - void PolygonOffset(GLfloat factor, GLfloat units) - { - } - - void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) - { - } - - void ReleaseShaderCompiler(void) - { - } - - void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) - { - } - - void SampleCoverage(GLclampf value, GLboolean invert) - { - } - - void Scissor(GLint x, GLint y, GLsizei width, GLsizei height) - { - } - - void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) - { - } - - 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; - } - - 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; - } - } - - void StencilFunc(GLenum func, GLint ref, GLuint mask) - { - } - - void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) - { - } - - void StencilMask(GLuint mask) - { - } - - void StencilMaskSeparate(GLenum face, GLuint mask) - { - } - - void StencilOp(GLenum fail, GLenum zfail, GLenum zpass) - { - } - - void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) - { - } - - 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()); - } - - void TexParameterf(GLenum target, GLenum pname, GLfloat param) - { - } - - void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params) - { - } - - void TexParameteri(GLenum target, GLenum pname, GLint param) - { - } - - void TexParameteriv(GLenum target, GLenum pname, const GLint* params) - { - } - - 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()); - } - - void Uniform1f(GLint location, GLfloat x) - { - if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, x ) ) - { - mGetErrorResult = GL_INVALID_OPERATION; - } - } - - 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; - } - } - } - - void Uniform1i(GLint location, GLint x) - { - if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram, location, x ) ) - { - mGetErrorResult = GL_INVALID_OPERATION; - } - } - - 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; - } - } - } - - void Uniform2f(GLint location, GLfloat x, GLfloat y) - { - if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram, - location, - Vector2( x, y ) ) ) - { - mGetErrorResult = GL_INVALID_OPERATION; - } - } - - 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; - } - } - } - - void Uniform2i(GLint location, GLint x, GLint y) - { - } - - void Uniform2iv(GLint location, GLsizei count, const GLint* v) - { - } - - void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) - { - if( ! mProgramUniforms3f.SetUniformValue( mCurrentProgram, - location, - Vector3( x, y, z ) ) ) - { - mGetErrorResult = GL_INVALID_OPERATION; - } - } - - 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; - } - } - } - - void Uniform3i(GLint location, GLint x, GLint y, GLint z) - { - } - - void Uniform3iv(GLint location, GLsizei count, const GLint* v) - { - } - - 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; - } - } - - 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; - } - } - } - - void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) - { - } - - void Uniform4iv(GLint location, GLsizei count, const GLint* v) - { - } - - void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) - { - } - - 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; - } - } - } - - 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; - } - } - } - - void UseProgram(GLuint program) - { - mCurrentProgram = program; - } - - void ValidateProgram(GLuint program) - { - } - - void VertexAttrib1f(GLuint indx, GLfloat x) - { - } - - void VertexAttrib1fv(GLuint indx, const GLfloat* values) - { - } - - void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) - { - } - - void VertexAttrib2fv(GLuint indx, const GLfloat* values) - { - } - - void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) - { - } - - void VertexAttrib3fv(GLuint indx, const GLfloat* values) - { - } - - void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) - { - } - - void VertexAttrib4fv(GLuint indx, const GLfloat* values) - { - } - - void VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) - { - } - - void Viewport(GLint x, GLint y, GLsizei width, GLsizei height) - { - } - - /* OpenGL ES 3.0 */ - - void ReadBuffer(GLenum mode) - { - } - - void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) - { - } - - void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) - { - } - - 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) - { - } - - void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) - { - } - - void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) - { - } - - 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) - { - } - - void GenQueries(GLsizei n, GLuint* ids) - { - } - - void DeleteQueries(GLsizei n, const GLuint* ids) - { - } - - GLboolean IsQuery(GLuint id) - { - return false; - } - - void BeginQuery(GLenum target, GLuint id) - { - } - - void EndQuery(GLenum target) - { - } - - void GetQueryiv(GLenum target, GLenum pname, GLint* params) - { - } - - void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) - { - } - - GLboolean UnmapBuffer(GLenum target) - { - return false; - } - - void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) - { - } - - void DrawBuffers(GLsizei n, const GLenum* bufs) - { - } - - void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) - { - } - - void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) - { - } - - void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) - { - } - - void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) - { - } - - void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) - { - } - - void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) - { - } - - void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) - { - } - - void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) - { - } - - void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) - { - } - - GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) - { - return NULL; - } - - void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) - { - } - - void BindVertexArray(GLuint array) - { - } - - void DeleteVertexArrays(GLsizei n, const GLuint* arrays) - { - } - - void GenVertexArrays(GLsizei n, GLuint* arrays) - { - } - - GLboolean IsVertexArray(GLuint array) - { - return false; - } - - void GetIntegeri_v(GLenum target, GLuint index, GLint* data) - { - } - - void BeginTransformFeedback(GLenum primitiveMode) - { - } - - void EndTransformFeedback(void) - { - } - - void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) - { - } - - void BindBufferBase(GLenum target, GLuint index, GLuint buffer) - { - } - - void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) - { - } - - void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) - { - } - - void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) - { - } - - void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) - { - } - - void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) - { - } - - void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) - { - } - - void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) - { - } - - void VertexAttribI4iv(GLuint index, const GLint* v) - { - } - - void VertexAttribI4uiv(GLuint index, const GLuint* v) - { - } - - void GetUniformuiv(GLuint program, GLint location, GLuint* params) - { - } - - GLint GetFragDataLocation(GLuint program, const GLchar *name) - { - return -1; - } - - void Uniform1ui(GLint location, GLuint v0) - { - } - - void Uniform2ui(GLint location, GLuint v0, GLuint v1) - { - } - - void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) - { - } - - void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) - { - } - - void Uniform1uiv(GLint location, GLsizei count, const GLuint* value) - { - } - - void Uniform2uiv(GLint location, GLsizei count, const GLuint* value) - { - } - - void Uniform3uiv(GLint location, GLsizei count, const GLuint* value) - { - } - - void Uniform4uiv(GLint location, GLsizei count, const GLuint* value) - { - } - - void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) - { - } - - void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) - { - } - - void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) - { - } - - void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) - { - } - - const GLubyte* GetStringi(GLenum name, GLuint index) - { - return NULL; - } - - void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) - { - } - - void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) - { - } - - void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) - { - } - - GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) - { - return GL_INVALID_INDEX; - } - - void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) - { - } - - void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) - { - } - - void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) - { - } - - void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) - { - } - - void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) - { - } - - GLsync FenceSync(GLenum condition, GLbitfield flags) - { - return NULL; - } - - GLboolean IsSync(GLsync sync) - { - return false; - } - - void DeleteSync(GLsync sync) - { - } - - GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) - { - return 0; - } - - void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) - { - } - - void GetInteger64v(GLenum pname, GLint64* params) - { - } - - void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) - { - } - - void GetInteger64i_v(GLenum target, GLuint index, GLint64* data) - { - } - - void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) - { - } - - void GenSamplers(GLsizei count, GLuint* samplers) - { - } - - void DeleteSamplers(GLsizei count, const GLuint* samplers) - { - } - - GLboolean IsSampler(GLuint sampler) - { - return false; - } - - void BindSampler(GLuint unit, GLuint sampler) - { - } - - void SamplerParameteri(GLuint sampler, GLenum pname, GLint param) - { - } - - void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) - { - } - - void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) - { - } - - void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) - { - } - - void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) - { - } - - void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) - { - } - - void VertexAttribDivisor(GLuint index, GLuint divisor) - { - } - - void BindTransformFeedback(GLenum target, GLuint id) - { - } - - void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids) - { - } - - void GenTransformFeedbacks(GLsizei n, GLuint* ids) - { - } - - GLboolean IsTransformFeedback(GLuint id) - { - return false; - } - - void PauseTransformFeedback(void) - { - } - - void ResumeTransformFeedback(void) - { - } - - void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) - { - } - - void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) - { - } - - void ProgramParameteri(GLuint program, GLenum pname, GLint value) - { - } - - void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) - { - } - - void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) - { - } - - void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) - { - } - - void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) - { - } - - void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) - { - } - -public: // TEST FUNCTIONS - void SetCompileStatus( GLuint value ) { mCompileStatus = value; } - void SetLinkStatus( GLuint value ) { mLinkStatus = value; } - void SetGetAttribLocationResult( int result) { mGetAttribLocationResult = result; } - void SetGetErrorResult( GLenum result) { mGetErrorResult = result; } - void SetGetStringResult( GLubyte* result) { mGetStringResult = result; } - void SetIsBufferResult( GLboolean result) { mIsBufferResult = result; } - void SetIsEnabledResult( GLboolean result) { mIsEnabledResult = result; } - void SetIsFramebufferResult( GLboolean result) { mIsFramebufferResult = result; } - void SetIsProgramResult( GLboolean result) { mIsProgramResult = result; } - void SetIsRenderbufferResult( GLboolean result) { mIsRenderbufferResult = result; } - void SetIsShaderResult( GLboolean result) { mIsShaderResult = result; } - void SetIsTextureResult( GLboolean result) { mIsTextureResult = result; } - void SetCheckFramebufferStatusResult( GLenum result) { mCheckFramebufferStatusResult = result; } - void SetNumBinaryFormats( GLint numFormats ) { mNumBinaryFormats = numFormats; } - void SetBinaryFormats( GLint binaryFormats ) { mBinaryFormats = binaryFormats; } - void SetProgramBinaryLength( GLint length ) { mProgramBinaryLength = length; } - - bool GetVertexAttribArrayState(GLuint index) - { - if( index >= MAX_ATTRIBUTE_CACHE_SIZE ) - { - // out of range - return false; - } - return mVertexAttribArrayState[ index ]; - } - void ClearVertexAttribArrayChanged() { mVertexAttribArrayChanged = false; } - bool GetVertexAttribArrayChanged() { return mVertexAttribArrayChanged; } - - //Methods for CullFace verification - void EnableCullFaceCallTrace(bool enable) { mCullFaceTrace.Enable(enable); } - void ResetCullFaceCallStack() { mCullFaceTrace.Reset(); } - TraceCallStack& GetCullFaceTrace() { return mCullFaceTrace; } - - //Methods for Shader verification - void EnableShaderCallTrace(bool enable) { mShaderTrace.Enable(enable); } - void ResetShaderCallStack() { mShaderTrace.Reset(); } - TraceCallStack& GetShaderTrace() { return mShaderTrace; } - - //Methods for Texture verification - void EnableTextureCallTrace(bool enable) { mTextureTrace.Enable(enable); } - void ResetTextureCallStack() { mTextureTrace.Reset(); } - TraceCallStack& GetTextureTrace() { return mTextureTrace; } - - //Methods for Draw verification - void EnableDrawCallTrace(bool enable) { mDrawTrace.Enable(enable); } - void ResetDrawCallStack() { mDrawTrace.Reset(); } - TraceCallStack& GetDrawTrace() { return mDrawTrace; } - - template - 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; - } - } - } - - std::stringstream notFound; - notFound << "Not found " << value << " printing possible values:"; - tet_printf( "%s", notFound.str().c_str() ); - 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; - tet_printf( "%s", out.str().c_str() ); - } - } - } - return false; - } - - template - bool GetUniformValue( GLuint programId, GLuint uniformId, T& outValue) const - { - const ProgramUniformValue &mProgramUniforms = GetProgramUniformsForType( outValue ); - return mProgramUniforms.GetUniformValue( programId, uniformId, outValue ); - } - - GLuint GetLastShaderCompiled() const - { - return mLastShaderCompiled; - } - - 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; - - const ProgramUniformValue& GetProgramUniformsForType( const int ) const - { - return mProgramUniforms1i; - } - const ProgramUniformValue& GetProgramUniformsForType( const float ) const - { - return mProgramUniforms1f; - } - const ProgramUniformValue& GetProgramUniformsForType( const Vector2& ) const - { - return mProgramUniforms2f; - } - const ProgramUniformValue& GetProgramUniformsForType( const Vector3& ) const - { - return mProgramUniforms3f; - } - const ProgramUniformValue& GetProgramUniformsForType( const Vector4& ) const - { - return mProgramUniforms4f; - } - const ProgramUniformValue& GetProgramUniformsForType( const Matrix& ) const - { - return mProgramUniformsMat4; - } - const ProgramUniformValue& GetProgramUniformsForType( const Matrix3& ) const - { - return mProgramUniformsMat3; - } - 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 - -extern bool BlendEnabled(const TraceCallStack& callStack); -extern bool BlendDisabled(const TraceCallStack& callStack); - - -#endif // header diff --git a/automated-tests/TET/dali-test-suite-utils/test-gl-sync-abstraction.h b/automated-tests/TET/dali-test-suite-utils/test-gl-sync-abstraction.h deleted file mode 100644 index 6de1407..0000000 --- a/automated-tests/TET/dali-test-suite-utils/test-gl-sync-abstraction.h +++ /dev/null @@ -1,169 +0,0 @@ -#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 - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include - -namespace Dali -{ - -class DALI_IMPORT_API TestSyncObject : public Integration::GlSyncAbstraction::SyncObject -{ -public: - TestSyncObject(TraceCallStack& trace) - : synced(false), - mTrace(trace) - { - } - - virtual ~TestSyncObject() - { - } - - virtual bool IsSynced() - { - mTrace.PushCall("SyncObject::IsSynced", ""); // Trace the method - return synced; - } - bool synced; - TraceCallStack& mTrace; -}; - -/** - * Class to emulate the GL sync functions with tracing - */ -class DALI_IMPORT_API TestGlSyncAbstraction: public Integration::GlSyncAbstraction -{ -public: - /** - * Constructor - */ - TestGlSyncAbstraction() - { - Initialize(); - } - - /** - * Destructor - */ - ~TestGlSyncAbstraction() - { - for( SyncIter iter=mSyncObjects.begin(), end=mSyncObjects.end(); iter != end; ++iter ) - { - delete *iter; - } - } - - /** - * Initialize the sync objects - clear down the map - */ - void Initialize() - { - mSyncObjects.clear(); - } - - /** - * Create a sync object - * @return the sync object - */ - virtual Integration::GlSyncAbstraction::SyncObject* 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 - */ - virtual void 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; - } - } - } - - -public: // TEST FUNCTIONS - Integration::GlSyncAbstraction::SyncObject* 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 SetObjectSynced( Integration::GlSyncAbstraction::SyncObject* syncObject, bool sync ) - { - TestSyncObject* testSyncObject = static_cast(syncObject); - testSyncObject->synced = sync; - } - - /** - * Turn trace on - */ - void EnableTrace(bool enable) { mTrace.Enable(enable); } - - /** - * Reset the trace callstack - */ - void ResetTrace() { mTrace.Reset(); } - - /** - * Get the trace object (allows test case to find methods on it) - */ - TraceCallStack& GetTrace() { return mTrace; } - -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/TET/dali-test-suite-utils/test-native-image.h b/automated-tests/TET/dali-test-suite-utils/test-native-image.h deleted file mode 100644 index 21147a3..0000000 --- a/automated-tests/TET/dali-test-suite-utils/test-native-image.h +++ /dev/null @@ -1,50 +0,0 @@ -#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) {return new TestNativeImage(width, height);}; - virtual bool GlExtensionCreate() {return true;}; - virtual void GlExtensionDestroy() {}; - virtual GLenum TargetTexture() {return 1;}; - virtual void PrepareTexture() {}; - virtual unsigned int GetWidth() const {return mWidth;}; - virtual unsigned int GetHeight() const {return mHeight;}; - virtual Pixel::Format GetPixelFormat() const {return Pixel::RGBA8888;}; - -private: - TestNativeImage(int width, int height) : mWidth(width), mHeight(height) {}; - virtual ~TestNativeImage() {}; - - int mWidth; - int mHeight; -}; - -} // Dali - -#endif diff --git a/automated-tests/TET/dali-test-suite-utils/test-platform-abstraction.h b/automated-tests/TET/dali-test-suite-utils/test-platform-abstraction.h deleted file mode 100644 index 64d6d22..0000000 --- a/automated-tests/TET/dali-test-suite-utils/test-platform-abstraction.h +++ /dev/null @@ -1,750 +0,0 @@ -#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 -#include -#include - -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 - { - LoadFileResult() - : loadResult(false) - { - - } - - bool loadResult; - std::vector< unsigned char> buffer; - }; - - - /** - * Constructor - */ - TestPlatformAbstraction() : mRequest(0) - { - Initialize(); - } - - /** - * Destructor - */ - virtual ~TestPlatformAbstraction() - { - } - - /** - * @copydoc PlatformAbstraction::GetTimeMicroseconds() - */ - virtual void GetTimeMicroseconds(unsigned int& seconds, unsigned int& microSeconds) - { - seconds = mSeconds; - microSeconds = mMicroSeconds; - mTrace.PushCall("GetTimeMicroseconds", ""); - } - - /** - * @copydoc PlatformAbstraction::Suspend() - */ - virtual void Suspend() - { - mTrace.PushCall("Suspend", ""); - } - - /** - * @copydoc PlatformAbstraction::Resume() - */ - virtual void Resume() - { - mTrace.PushCall("Resume", ""); - } - - virtual void GetClosestImageSize( const std::string& filename, - const ImageAttributes& attributes, - Vector2& closestSize) - { - closestSize = mClosestSize; - mTrace.PushCall("GetClosestImageSize", ""); - } - - virtual void GetClosestImageSize( Integration::ResourcePointer resourceBuffer, - const ImageAttributes& attributes, - Vector2& closestSize) - { - closestSize = mClosestSize; - mTrace.PushCall("GetClosestImageSize", ""); - } - - - /** - * @copydoc PlatformAbstraction::LoadResource() - */ - virtual void 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); - } - - virtual Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath) - { - mTrace.PushCall("LoadResourceSynchronously", ""); - return mResources.loadedResource; - } - - /** - * @copydoc PlatformAbstraction::SaveResource() - */ - virtual void 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() - */ - virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId) - { - mTrace.PushCall("CancelLoad", ""); - } - - /** - * @copydoc PlatformAbstraction::GetResources() - */ - virtual void 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() - */ - virtual bool IsLoading() - { - mTrace.PushCall("IsLoading", ""); - return mIsLoadingResult; - } - - /** - * @copydoc PlatformAbstraction::GetDefaultFontFamily() - */ - virtual std::string GetDefaultFontFamily() const - { - mTrace.PushCall("GetDefaultFontFamily", ""); - return mGetDefaultFontFamilyResult; - } - - /** - * @copydoc PlatformAbstraction::GetDefaultFontSize() - */ - virtual const float GetDefaultFontSize() const - { - mTrace.PushCall("GetDefaultFontSize", ""); - return mGetDefaultFontSizeResult; - } - - virtual const PixelSize 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() - */ - - virtual Integration::GlyphSet* 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); - Integration::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() - */ - - virtual Integration::GlyphSet* 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); - Integration::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() - */ - virtual void 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() - */ - virtual std::string GetFontPath(const std::string& family, bool bold, bool italic) const - { - mTrace.PushCall("GetFontPath", ""); - return mGetFontPathResult; - - // Do nothing with arguments - } - - /** - * @copydoc PlatformAbstraction::SetDpi() - */ - virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical) - { - mTrace.PushCall("SetDpi", ""); - } - - /** - * @copydoc PlatformAbstraction::GetFontFamilyForChars() - */ - virtual std::string GetFontFamilyForChars(const TextArray& charsRequested) const - { - mTrace.PushCall("GetFontFamilyForChars", ""); - return mGetDefaultFontFamilyResult; - } - - /** - * @copydoc PlatformAbstraction::AllGlyphsSupported() - */ - virtual bool AllGlyphsSupported(const std::string& name, const std::string& fontStyle, const TextArray& text) const - { - mTrace.PushCall("AllGlyphsSupported", ""); - return true; - } - - /** - * @copydoc PlatformAbstraction::ValidateFontFamilyName() - */ - virtual bool 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() - */ - virtual std::vector GetFontList( FontListMode mode ) const - { - mFontListMode = mode; - mTrace.PushCall("ValidateGetFontList", ""); - std::vector fontList; - return fontList; - } - - /** - * @copydoc PlatformAbstraction::LoadFile() - */ - virtual bool 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() - */ - virtual bool SaveFile(const std::string& filename, std::vector< unsigned char >& buffer) const - { - mTrace.PushCall("SaveFile", ""); - return false; - } - - virtual void JoinLoaderThreads() - { - mTrace.PushCall("JoinLoaderThreads", ""); - } - - virtual void UpdateDefaultsFromDevice() - { - mTrace.PushCall("UpdateDefaultsFromDevice", ""); - mGetDefaultFontFamilyResult+=1.0f; - } - - virtual Integration::DynamicsFactory* GetDynamicsFactory() - { - mTrace.PushCall("GetDynamicsFactory", ""); - return NULL; - } - - virtual bool 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) - } - - virtual void 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", ""); - } - - virtual bool 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) - } - - virtual void 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" ) ); - } - - virtual Integration::BitmapPtr 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; - } - -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, - GetGlyphImageFunc - } TestFuncEnum; - - /** Call this every test */ - void 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; - } - } - - void EnableTrace(bool enable) { mTrace.Enable(enable); } - void ResetTrace() { mTrace.Reset(); } - TraceCallStack& GetTrace() { return mTrace; } - - bool 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"); - case GetGlyphImageFunc: return mTrace.FindMethod("GetGlyphImage"); - } - return false; - } - - void SetGetTimeMicrosecondsResult(size_t sec, size_t usec) - { - mSeconds = sec; - mMicroSeconds = usec; - } - - void IncrementGetTimeResult(size_t milliseconds) - { - mMicroSeconds += milliseconds * 1000u; - unsigned int additionalSeconds = mMicroSeconds / 1000000u; - - mSeconds += additionalSeconds; - mMicroSeconds -= additionalSeconds * 1000000u; - } - - void SetIsLoadingResult(bool result) - { - mIsLoadingResult = result; - } - - void SetGetDefaultFontFamilyResult(std::string result) - { - mGetDefaultFontFamilyResult = result; - } - - void SetGetDefaultFontSizeResult(float result) - { - mGetDefaultFontSizeResult = result; - } - - void SetGetFontPathResult(std::string& result) - { - mGetFontPathResult = result; - } - - void ClearReadyResources() - { - memset(&mResources, 0, sizeof(Resources)); - } - - void SetResourceLoaded(Integration::ResourceId loadedId, - Integration::ResourceTypeId loadedType, - Integration::ResourcePointer loadedResource) - { - mResources.loaded = true; - mResources.loadedId = loadedId; - mResources.loadedType = loadedType; - mResources.loadedResource = loadedResource; - } - - void SetResourceLoadFailed(Integration::ResourceId id, - Integration::ResourceFailure failure) - { - mResources.loadFailed = true; - mResources.loadFailedId = id; - mResources.loadFailure = failure; - } - - void SetResourceSaved(Integration::ResourceId savedId, - Integration::ResourceTypeId savedType) - { - mResources.saved = true; - mResources.savedId = savedId; - mResources.savedType = savedType; - } - - void SetResourceSaveFailed(Integration::ResourceId id, - Integration::ResourceFailure failure) - { - mResources.saveFailed = true; - mResources.saveFailedId = id; - mResources.saveFailure = failure; - } - - Integration::ResourceRequest* GetRequest() - { - return mRequest; - } - - void DiscardRequest() - { - delete mRequest; - mRequest = NULL; - } - - void SetClosestImageSize(const Vector2& size) - { - mClosestSize = size; - } - - void SetLoadFileResult( bool result, std::vector< unsigned char >& buffer ) - { - mLoadFileResult.loadResult = result; - if( result ) - { - mLoadFileResult.buffer = buffer; - } - } - - void SetSaveFileResult( bool result ) - { - mSaveFileResult = result; - } - - FontListMode GetLastFontListMode( ) - { - return mFontListMode; - } - - void SetReadGlobalMetricsResult( bool success, Integration::GlobalMetrics& globalMetrics ) - { - mReadGlobalMetricsResult = success; - mReadGlobalMetrics = globalMetrics; - } - - void SetReadMetricsResult( bool success, std::vector& glyphMetricsContainer ) - { - mReadMetricsResult = success; - mReadMetrics = glyphMetricsContainer; // copy - } - -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/TET/dali-test-suite-utils/test-render-controller.h b/automated-tests/TET/dali-test-suite-utils/test-render-controller.h deleted file mode 100644 index 62c43f4..0000000 --- a/automated-tests/TET/dali-test-suite-utils/test-render-controller.h +++ /dev/null @@ -1,78 +0,0 @@ -#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 - -namespace Dali -{ - -class DALI_IMPORT_API TestRenderController : public Dali::Integration::RenderController -{ -public: - TestRenderController() - { - Initialize(); - } - - ~TestRenderController() - { - } - - virtual void RequestUpdate() - { - mRequestUpdateCalled = true; - } - - virtual void RequestProcessEventsOnIdle() - { - mRequestProcessEventsOnIdle = true; - } - - typedef enum - { - RequestUpdateFunc, - RequestNotificationEventOnIdleFunc, - } TestRenderControllerFuncEnum; - - bool WasCalled(TestRenderControllerFuncEnum func) - { - switch(func) - { - case RequestUpdateFunc: return mRequestUpdateCalled; - case RequestNotificationEventOnIdleFunc: return mRequestProcessEventsOnIdle; - } - - return false; - } - - void Initialize() - { - mRequestUpdateCalled = false; - mRequestProcessEventsOnIdle = false; - } - -private: - bool mRequestUpdateCalled; - bool mRequestProcessEventsOnIdle; -}; - -} // Dali - -#endif diff --git a/automated-tests/TET/dali-test-suite-utils/test-trace-call-stack.h b/automated-tests/TET/dali-test-suite-utils/test-trace-call-stack.h deleted file mode 100644 index 5f55cdf..0000000 --- a/automated-tests/TET/dali-test-suite-utils/test-trace-call-stack.h +++ /dev/null @@ -1,126 +0,0 @@ -#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. -// - -/** - * Helper class to track method calls in the abstraction and search for them in test cases - */ -class TraceCallStack -{ -public: - /** - * Constructor - */ - TraceCallStack() : mTraceActive(false) { } - - /** - * Destructor - */ - ~TraceCallStack() { } - - /** - * Turn on / off tracing - */ - void 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 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 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 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 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 Reset() - { - mCallStack.clear(); - } - - /** - * Get the call stack - * @return The call stack object (Vector of vector[2] of method/paramlist strings) - */ - 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 -}; - -#endif //__TEST_TRACE_CALL_STACK_H__ diff --git a/automated-tests/TET/dali-test-suite/actors/.gitignore b/automated-tests/TET/dali-test-suite/actors/.gitignore deleted file mode 100644 index 2002e7a..0000000 --- a/automated-tests/TET/dali-test-suite/actors/.gitignore +++ /dev/null @@ -1,19 +0,0 @@ -utc-Dali-ImageActor -utc-Dali-Object -utc-Dali-MetaObject -utc-Dali-Property -utc-Dali-MetaProperty -utc-Dali-ResizingLayout -utc-Dali-TextActor -utc-Dali-Actor -utc-Dali-Model -utc-Dali-MeshActor -utc-Dali-CameraActor -utc-Dali-LightActor -utc-Dali-Layer -utc-Dali-Stage -utc-Dali-CustomActor -utc-Dali-Constrainable -utc-Dali-RenderableActor -utc-Dali-BaseHandle -utc-Dali-Handle diff --git a/automated-tests/TET/dali-test-suite/actors/Makefile b/automated-tests/TET/dali-test-suite/actors/Makefile deleted file mode 120000 index c88d5a7..0000000 --- a/automated-tests/TET/dali-test-suite/actors/Makefile +++ /dev/null @@ -1 +0,0 @@ -../master-makefile.mk \ No newline at end of file diff --git a/automated-tests/TET/dali-test-suite/actors/file.list b/automated-tests/TET/dali-test-suite/actors/file.list deleted file mode 100644 index e4c750c..0000000 --- a/automated-tests/TET/dali-test-suite/actors/file.list +++ /dev/null @@ -1,15 +0,0 @@ -TARGETS += \ - utc-Dali-Actor \ - utc-Dali-CameraActor \ - utc-Dali-ImageActor \ - utc-Dali-Layer \ - utc-Dali-LightActor \ - utc-Dali-Model \ - utc-Dali-MeshActor \ - utc-Dali-RenderableActor \ - utc-Dali-Stage \ - utc-Dali-TextActor \ - utc-Dali-CustomActor \ - utc-Dali-Constrainable \ - utc-Dali-BaseHandle \ - utc-Dali-Handle \ diff --git a/automated-tests/TET/dali-test-suite/actors/tslist b/automated-tests/TET/dali-test-suite/actors/tslist deleted file mode 100644 index 12b42e9..0000000 --- a/automated-tests/TET/dali-test-suite/actors/tslist +++ /dev/null @@ -1,14 +0,0 @@ -/dali-test-suite/actors/utc-Dali-Actor -/dali-test-suite/actors/utc-Dali-CameraActor -/dali-test-suite/actors/utc-Dali-ImageActor -/dali-test-suite/actors/utc-Dali-Layer -/dali-test-suite/actors/utc-Dali-LightActor -/dali-test-suite/actors/utc-Dali-Model -/dali-test-suite/actors/utc-Dali-MeshActor -/dali-test-suite/actors/utc-Dali-Stage -/dali-test-suite/actors/utc-Dali-TextActor -/dali-test-suite/actors/utc-Dali-CustomActor -/dali-test-suite/actors/utc-Dali-Constrainable -/dali-test-suite/actors/utc-Dali-RenderableActor -/dali-test-suite/actors/utc-Dali-BaseHandle -/dali-test-suite/actors/utc-Dali-Handle diff --git a/automated-tests/TET/dali-test-suite/actors/tslist-renderables b/automated-tests/TET/dali-test-suite/actors/tslist-renderables deleted file mode 100644 index 94c1767..0000000 --- a/automated-tests/TET/dali-test-suite/actors/tslist-renderables +++ /dev/null @@ -1,4 +0,0 @@ -/dali-test-suite/actors/utc-Dali-RenderableActor -/dali-test-suite/actors/utc-Dali-ImageActor -/dali-test-suite/actors/utc-Dali-MeshActor -/dali-test-suite/actors/utc-Dali-TextActor diff --git a/automated-tests/TET/dali-test-suite/actors/tslist-text-actor b/automated-tests/TET/dali-test-suite/actors/tslist-text-actor deleted file mode 100644 index 0ad71a9..0000000 --- a/automated-tests/TET/dali-test-suite/actors/tslist-text-actor +++ /dev/null @@ -1 +0,0 @@ -/dali-test-suite/actors/utc-Dali-TextActor diff --git a/automated-tests/TET/dali-test-suite/actors/utc-Dali-Actor.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-Actor.cpp deleted file mode 100644 index 78bb185..0000000 --- a/automated-tests/TET/dali-test-suite/actors/utc-Dali-Actor.cpp +++ /dev/null @@ -1,2952 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliActorNew, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorDownCast2, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorGetName, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorSetName, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorGetId, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliActorIsRoot, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorOnStage, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorIsLayer, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorGetLayer, POSITIVE_TC_IDX ); // 10 - -TEST_FUNCTION( UtcDaliActorAdd, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorRemove01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorRemove02, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorGetChildCount, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorGetChildren01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorGetChildren02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorGetParent01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorGetParent02, NEGATIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliActorSetParentOrigin, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorGetCurrentParentOrigin, POSITIVE_TC_IDX ); // 20 -TEST_FUNCTION( UtcDaliActorSetAnchorPoint, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorGetCurrentAnchorPoint, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliActorSetSize01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorSetSize02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorSetSize03, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorSetSize04, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorGetCurrentSize, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliActorSetPosition01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorSetPosition02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorSetPosition03, POSITIVE_TC_IDX ); // 30 -TEST_FUNCTION( UtcDaliActorSetX, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorSetY, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorSetZ, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorMoveBy, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorGetCurrentPosition, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorGetCurrentWorldPosition, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorInheritPosition, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliActorSetRotation01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorSetRotation02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorRotateBy01, POSITIVE_TC_IDX ); // 40 -TEST_FUNCTION( UtcDaliActorRotateBy02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorGetCurrentRotation, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorGetCurrentWorldRotation, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliActorSetScale01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorSetScale02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorSetScale03, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorScaleBy, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorGetCurrentScale, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorGetCurrentWorldScale, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorInheritScale, POSITIVE_TC_IDX ); // 50 - -TEST_FUNCTION( UtcDaliActorSetVisible, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorIsVisible, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorSetOpacity, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorGetCurrentOpacity, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliActorSetSensitive, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorIsSensitive, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliActorSetInheritShaderEffect, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorGetInheritShaderEffect, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliActorSetShaderEffect, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorGetShaderEffect, POSITIVE_TC_IDX ); // 60 -TEST_FUNCTION( UtcDaliActorRemoveShaderEffect01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorRemoveShaderEffect02, NEGATIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliActorSetColor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorGetCurrentColor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorSetColorMode, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorGetCurrentWorldColor, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliActorScreenToLocal, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorSetLeaveRequired, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorGetLeaveRequired, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliActorSetKeyboardFocusable, POSITIVE_TC_IDX ); // 70 -TEST_FUNCTION( UtcDaliActorIsKeyboardFocusable, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliActorApplyConstraint, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorApplyConstraintAppliedCallback, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorRemoveConstraints, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorRemoveConstraint, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliActorTouchedSignal, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorSetSizeSignal, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorOnOffStageSignal, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliActorFindChildByName, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorFindChildByAlias, POSITIVE_TC_IDX ); // 80 -TEST_FUNCTION( UtcDaliActorFindChildById, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliActorHitTest, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliActorSetDrawMode, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorSetDrawModeOverlayRender, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorSetDrawModeOverlayHitTest, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliActorGetCurrentWorldMatrix, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorConstrainedToWorldMatrix, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliActorUnparent, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliActorGetChildAt, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliActorSetGetOverlay, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliActorDynamics, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorCreateDestroy, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliActorProperties, POSITIVE_TC_IDX ); - -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"; - -// Called only once before first test is run. -static void Startup() -{ - // THERE IS NO MAINLOOP IN THE TEST APPLICATION -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -static void UtcDaliActorNew() -{ - TestApplication application; - - Actor actor = Actor::New(); - - DALI_TEST_CHECK(actor); -} - -static void UtcDaliActorDownCast() -{ - TestApplication application; - tet_infoline("Testing Dali::Actor::DownCast()"); - - Actor actor = Actor::New(); - BaseHandle object(actor); - Actor actor2 = Actor::DownCast(object); - DALI_TEST_CHECK(actor2); -} - -static void UtcDaliActorDownCast2() -{ - TestApplication application; - tet_infoline("Testing Dali::Actor::DownCast()"); - - BaseHandle unInitializedObject; - Actor actor = Actor::DownCast(unInitializedObject); - DALI_TEST_CHECK(!actor); -} - -static void UtcDaliActorGetName() -{ - TestApplication application; - - Actor actor = Actor::New(); - - DALI_TEST_CHECK(actor.GetName().empty()); -} - -static void UtcDaliActorSetName() -{ - TestApplication application; - - string str("ActorName"); - Actor actor = Actor::New(); - - actor.SetName(str); - DALI_TEST_CHECK(actor.GetName() == str); -} - -static void UtcDaliActorGetId() -{ - 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()); -} - -static void UtcDaliActorIsRoot() -{ - 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() ); -} - -static void UtcDaliActorOnStage() -{ - 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() ); -} - -static void UtcDaliActorIsLayer() -{ - 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() ); -} - -static void UtcDaliActorGetLayer() -{ - 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() ); -} - -static void UtcDaliActorAdd() -{ - 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); - } -} - -static void UtcDaliActorRemove01() -{ - 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); - } -} - -static void UtcDaliActorRemove02() -{ - 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); -} - -static void UtcDaliActorGetChildCount() -{ - 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); -} - -static void UtcDaliActorGetChildren01() -{ - 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); -} - -static void UtcDaliActorGetChildren02() -{ - 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); -} - -static void UtcDaliActorGetParent01() -{ - TestApplication application; - - Actor parent = Actor::New(); - Actor child = Actor::New(); - - parent.Add(child); - - DALI_TEST_CHECK(child.GetParent() == parent); -} - -static void UtcDaliActorGetParent02() -{ - TestApplication application; - - Actor actor = Actor::New(); - - DALI_TEST_CHECK(!actor.GetParent()); -} - -static void UtcDaliActorSetParentOrigin() -{ - 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 ); -} - -static void UtcDaliActorGetCurrentParentOrigin() -{ - 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()); -} - -static void UtcDaliActorSetAnchorPoint() -{ - 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 ); -} - -static void UtcDaliActorGetCurrentAnchorPoint() -{ - 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()); -} - -// SetSize(float width, float height) -static void UtcDaliActorSetSize01() -{ - 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()); -} - -// SetSize(float width, float height, float depth) -static void UtcDaliActorSetSize02() -{ - 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()); -} - -// SetSize(Vector2 size) -static void UtcDaliActorSetSize03() -{ - 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()); -} - -// SetSize(Vector3 size) -static void UtcDaliActorSetSize04() -{ - 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 ); -} - -static void UtcDaliActorGetCurrentSize() -{ - 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()); -} - -// SetPosition(float x, float y) -static void UtcDaliActorSetPosition01() -{ - 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 ); -} - -// SetPosition(float x, float y, float z) -static void UtcDaliActorSetPosition02() -{ - 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()); -} - -// SetPosition(Vector3 position) -static void UtcDaliActorSetPosition03() -{ - 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()); -} - -static void UtcDaliActorSetX() -{ - 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()); -} - -static void UtcDaliActorSetY() -{ - 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()); -} - -static void UtcDaliActorSetZ() -{ - 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()); -} - -static void UtcDaliActorMoveBy() -{ - 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()); -} - -static void UtcDaliActorGetCurrentPosition() -{ - 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); -} - -static void UtcDaliActorGetCurrentWorldPosition() -{ - 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 ); -} - -static void UtcDaliActorInheritPosition() -{ - 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 ); -} - -// SetRotation(float angleRadians, Vector3 axis) -static void UtcDaliActorSetRotation01() -{ - 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); -} - -static void UtcDaliActorSetRotation02() -{ - 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 ); -} - -// RotateBy(float angleRadians, Vector3 axis) -static void UtcDaliActorRotateBy01() -{ - 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 ); -} - -// RotateBy(Quaternion relativeRotation) -static void UtcDaliActorRotateBy02() -{ - 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); -} - -static void UtcDaliActorGetCurrentRotation() -{ - 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); -} - -static void UtcDaliActorGetCurrentWorldRotation() -{ - 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 ); -} - -// SetScale(float scale) -static void UtcDaliActorSetScale01() -{ - 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); -} - -// SetScale(float scaleX, float scaleY, float scaleZ) -static void UtcDaliActorSetScale02() -{ - 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 ); - -} - -// SetScale(Vector3 scale) -static void UtcDaliActorSetScale03() -{ - 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); -} - -static void UtcDaliActorScaleBy() -{ - 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()); -} - -static void UtcDaliActorGetCurrentScale() -{ - 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); -} - -static void UtcDaliActorGetCurrentWorldScale() -{ - 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 ); -} - -static void UtcDaliActorInheritScale() -{ - 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 ); -} - -static void UtcDaliActorSetVisible() -{ - 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); -} - -static void UtcDaliActorIsVisible() -{ - TestApplication application; - - Actor actor = Actor::New(); - - DALI_TEST_CHECK(actor.IsVisible() == true); -} - -static void UtcDaliActorSetOpacity() -{ - 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 ); -} - -static void UtcDaliActorGetCurrentOpacity() -{ - 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); -} - -static void UtcDaliActorSetSensitive() -{ - TestApplication application; - Actor actor = Actor::New(); - - bool sensitive = !actor.IsSensitive(); - - actor.SetSensitive(sensitive); - - DALI_TEST_CHECK(sensitive == actor.IsSensitive()); -} - -static void UtcDaliActorIsSensitive() -{ - TestApplication application; - Actor actor = Actor::New(); - actor.SetSensitive(false); - - DALI_TEST_CHECK(false == actor.IsSensitive()); -} - -static void UtcDaliActorSetInheritShaderEffect() -{ - 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); -} - -static void UtcDaliActorGetInheritShaderEffect() -{ - TestApplication application; - - Actor actor = Actor::New(); - - DALI_TEST_CHECK(actor.GetInheritShaderEffect() == true); -} - -static void UtcDaliActorSetShaderEffect() -{ - 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()); -} - -static void UtcDaliActorGetShaderEffect() -{ - TestApplication application; - Actor actor = Actor::New(); - - ShaderEffect effect = ShaderEffect::New(vertexSource, fragmentSource); - actor.SetShaderEffect(effect); - - DALI_TEST_CHECK(effect == actor.GetShaderEffect()); -} - -static void UtcDaliActorRemoveShaderEffect01() -{ - 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()); -} - -static void UtcDaliActorRemoveShaderEffect02() -{ - TestApplication application; - Actor actor = Actor::New(); - - ShaderEffect defaultEffect = actor.GetShaderEffect(); - - actor.RemoveShaderEffect(); - - DALI_TEST_CHECK(defaultEffect == actor.GetShaderEffect()); -} - -static void UtcDaliActorSetColor() -{ - 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 ); -} - -static void UtcDaliActorGetCurrentColor() -{ - 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()); -} - -static void UtcDaliActorGetCurrentWorldColor() -{ - 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 ); -} - -static void UtcDaliActorSetColorMode() -{ - 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 ); -} - -static void UtcDaliActorScreenToLocal() -{ - 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); -} - -static void UtcDaliActorSetLeaveRequired() -{ - TestApplication application; - - Actor actor = Actor::New(); - - actor.SetLeaveRequired(false); - DALI_TEST_CHECK(actor.GetLeaveRequired() == false); - - actor.SetLeaveRequired(true); - DALI_TEST_CHECK(actor.GetLeaveRequired() == true); -} - -static void UtcDaliActorGetLeaveRequired() -{ - TestApplication application; - - Actor actor = Actor::New(); - - DALI_TEST_CHECK(actor.GetLeaveRequired() == false); -} - -static void UtcDaliActorSetKeyboardFocusable() -{ - TestApplication application; - - Actor actor = Actor::New(); - - actor.SetKeyboardFocusable(true); - DALI_TEST_CHECK(actor.IsKeyboardFocusable() == true); - - actor.SetKeyboardFocusable(false); - DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false); -} - -static void UtcDaliActorIsKeyboardFocusable() -{ - TestApplication application; - - Actor actor = Actor::New(); - - DALI_TEST_CHECK(actor.IsKeyboardFocusable() == false); -} - -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; -}; - -static void UtcDaliActorApplyConstraint() -{ - 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 ); -} - -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 void UtcDaliActorApplyConstraintAppliedCallback() -{ - 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 ); -} - -static void UtcDaliActorRemoveConstraints() -{ - 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 ); -} - -static void UtcDaliActorRemoveConstraint() -{ - 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. -} - -static bool gTouchCallBackCalled; -static bool gTouchCallBack2Called; - -static bool TestCallback(Actor actor, const TouchEvent& event) -{ - gTouchCallBackCalled = true; - return false; -} - -static bool TestCallback2(Actor actor, const TouchEvent& event) -{ - gTouchCallBack2Called = true; - return false; -} - - -static void UtcDaliActorTouchedSignal() -{ - 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 ); -} - -static Vector3 gSetSize; -static bool gSetSizeCallBackCalled; -static void SetSizeCallback( Actor actor, const Vector3& size ) -{ - gSetSizeCallBackCalled = true; - gSetSize = size; -} - -static void UtcDaliActorSetSizeSignal() -{ - 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 ); -} - -// validation stuff for onstage & offstage signals -static std::vector< std::string > gActorNamesOnOffStage; -static int gOnStageCallBackCalled; -static void OnStageCallback( Actor actor ) -{ - ++gOnStageCallBackCalled; - gActorNamesOnOffStage.push_back( actor.GetName() ); - DALI_TEST_CHECK( actor.OnStage() == true ); -} -static int gOffStageCallBackCalled; -static void OffStageCallback( Actor actor ) -{ - ++gOffStageCallBackCalled; - gActorNamesOnOffStage.push_back( actor.GetName() ); - DALI_TEST_CHECK( actor.OnStage() == false ); -} - -static void UtcDaliActorOnOffStageSignal() -{ - 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 ); -} - -static void UtcDaliActorFindChildByName() -{ - 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 ); -} - -static void UtcDaliActorFindChildByAlias() -{ - 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 ); -} - -static void UtcDaliActorFindChildById() -{ - 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 ); -} - -static void UtcDaliActorHitTest() -{ - 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; - } -} - -static void UtcDaliActorSetDrawMode() -{ - 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 -} - -static void UtcDaliActorSetDrawModeOverlayRender() -{ - 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 ); - } -} - -/** - * Simulates a Down Touch at 25.0, 25.0. - * @param[in] app Test Application instance. - */ -static void 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); -} - -static void UtcDaliActorSetDrawModeOverlayHitTest() -{ - 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 ); -} - -static void UtcDaliActorGetCurrentWorldMatrix() -{ - 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 ); -} - - -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; - } -}; - - -static void UtcDaliActorConstrainedToWorldMatrix() -{ - 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 ); -} - -static void UtcDaliActorUnparent() -{ - 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 ); -} - -static void UtcDaliActorGetChildAt() -{ - 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 ); -} - -static void UtcDaliActorSetGetOverlay() -{ - TestApplication app; - tet_infoline(" UtcDaliActorSetGetOverlay"); - - Actor parent = Actor::New(); - parent.SetDrawMode(DrawMode::OVERLAY ); - DALI_TEST_CHECK( parent.GetDrawMode() == DrawMode::OVERLAY ); -} - - -// Current Dynamics functions are crashing, so testing these sections are futile - -static void UtcDaliActorDynamics() -{ - DALI_TEST_CHECK( true ); -} - -static void UtcDaliActorCreateDestroy() -{ - Actor* actor = new Actor; - DALI_TEST_CHECK( actor ); - delete actor; -} - -struct PropertyStringIndex -{ - const char * const name; - const Property::Index index; - const Property::Type type; -}; - -const PropertyStringIndex PROPERTY_TABLE[] = -{ - { "parent-origin", Actor::PARENT_ORIGIN, Property::VECTOR3 }, - { "parent-origin-x", Actor::PARENT_ORIGIN_X, Property::FLOAT }, - { "parent-origin-y", Actor::PARENT_ORIGIN_Y, Property::FLOAT }, - { "parent-origin-z", Actor::PARENT_ORIGIN_Z, Property::FLOAT }, - { "anchor-point", Actor::ANCHOR_POINT, Property::VECTOR3 }, - { "anchor-point-x", Actor::ANCHOR_POINT_X, Property::FLOAT }, - { "anchor-point-y", Actor::ANCHOR_POINT_Y, Property::FLOAT }, - { "anchor-point-z", Actor::ANCHOR_POINT_Z, Property::FLOAT }, - { "size", Actor::SIZE, Property::VECTOR3 }, - { "size-width", Actor::SIZE_WIDTH, Property::FLOAT }, - { "size-height", Actor::SIZE_HEIGHT, Property::FLOAT }, - { "size-depth", Actor::SIZE_DEPTH, Property::FLOAT }, - { "position", Actor::POSITION, Property::VECTOR3 }, - { "position-x", Actor::POSITION_X, Property::FLOAT }, - { "position-y", Actor::POSITION_Y, Property::FLOAT }, - { "position-z", Actor::POSITION_Z, Property::FLOAT }, - { "world-position", Actor::WORLD_POSITION, Property::VECTOR3 }, - { "world-position-x", Actor::WORLD_POSITION_X, Property::FLOAT }, - { "world-position-y", Actor::WORLD_POSITION_Y, Property::FLOAT }, - { "world-position-z", Actor::WORLD_POSITION_Z, Property::FLOAT }, - { "rotation", Actor::ROTATION, Property::ROTATION }, - { "world-rotation", Actor::WORLD_ROTATION, Property::ROTATION }, - { "scale", Actor::SCALE, Property::VECTOR3 }, - { "scale-x", Actor::SCALE_X, Property::FLOAT }, - { "scale-y", Actor::SCALE_Y, Property::FLOAT }, - { "scale-z", Actor::SCALE_Z, Property::FLOAT }, - { "world-scale", Actor::WORLD_SCALE, Property::VECTOR3 }, - { "visible", Actor::VISIBLE, Property::BOOLEAN }, - { "color", Actor::COLOR, Property::VECTOR4 }, - { "color-red", Actor::COLOR_RED, Property::FLOAT }, - { "color-green", Actor::COLOR_GREEN, Property::FLOAT }, - { "color-blue", Actor::COLOR_BLUE, Property::FLOAT }, - { "color-alpha", Actor::COLOR_ALPHA, Property::FLOAT }, - { "world-color", Actor::WORLD_COLOR, Property::VECTOR4 }, - { "world-matrix", Actor::WORLD_MATRIX, Property::MATRIX }, - { "name", Actor::NAME, Property::STRING }, - { "sensitive", Actor::SENSITIVE, Property::BOOLEAN }, - { "leave-required", Actor::LEAVE_REQUIRED, Property::BOOLEAN }, - { "inherit-shader-effect", Actor::INHERIT_SHADER_EFFECT, Property::BOOLEAN }, - { "inherit-rotation", Actor::INHERIT_ROTATION, Property::BOOLEAN }, - { "inherit-scale", Actor::INHERIT_SCALE, Property::BOOLEAN }, - { "color-mode", Actor::COLOR_MODE, Property::STRING }, - { "position-inheritance", Actor::POSITION_INHERITANCE, Property::STRING }, - { "draw-mode", Actor::DRAW_MODE, Property::STRING }, -}; -const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] ); - -void UtcDaliActorProperties() -{ - TestApplication app; - - Actor actor = Actor::New(); - - for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i ) - { - tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index ); - DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION ); - } -} diff --git a/automated-tests/TET/dali-test-suite/actors/utc-Dali-BaseHandle.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-BaseHandle.cpp deleted file mode 100644 index 1aa14d3..0000000 --- a/automated-tests/TET/dali-test-suite/actors/utc-Dali-BaseHandle.cpp +++ /dev/null @@ -1,489 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void UtcDaliBaseHandleConstructorVoid(); -static void UtcDaliBaseHandleCopyConstructor(); -static void UtcDaliBaseHandleAssignmentOperator(); -static void UtcDaliBaseHandleGetBaseObject(); -static void UtcDaliBaseHandleReset(); -static void UtcDaliBaseHandleEqualityOperator01(); -static void UtcDaliBaseHandleEqualityOperator02(); -static void UtcDaliBaseHandleInequalityOperator01(); -static void UtcDaliBaseHandleInequalityOperator02(); -static void UtcDaliBaseHandleStlVector(); -static void UtcDaliBaseHandleDoAction(); -static void UtcDaliBaseHandleConnectSignal(); -static void UtcDaliBaseHandleGetTypeName(); -static void UtcDaliBaseHandleGetObjectPtr(); -static void UtcDaliBaseHandleBooleanCast(); - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -// Add test functionality for all APIs in the class (Positive and Negative) -extern "C" { - struct tet_testlist tet_testlist[] = { - { UtcDaliBaseHandleConstructorVoid, POSITIVE_TC_IDX }, - { UtcDaliBaseHandleCopyConstructor, POSITIVE_TC_IDX }, - { UtcDaliBaseHandleAssignmentOperator, POSITIVE_TC_IDX }, - { UtcDaliBaseHandleGetBaseObject, POSITIVE_TC_IDX }, - { UtcDaliBaseHandleReset, POSITIVE_TC_IDX }, - { UtcDaliBaseHandleEqualityOperator01, POSITIVE_TC_IDX }, - { UtcDaliBaseHandleEqualityOperator02, NEGATIVE_TC_IDX }, - { UtcDaliBaseHandleInequalityOperator01, POSITIVE_TC_IDX }, - { UtcDaliBaseHandleInequalityOperator02, NEGATIVE_TC_IDX }, - { UtcDaliBaseHandleStlVector, POSITIVE_TC_IDX }, - { UtcDaliBaseHandleDoAction, POSITIVE_TC_IDX }, - { UtcDaliBaseHandleConnectSignal, POSITIVE_TC_IDX }, - { UtcDaliBaseHandleGetTypeName, POSITIVE_TC_IDX }, - { UtcDaliBaseHandleGetObjectPtr, POSITIVE_TC_IDX }, - { UtcDaliBaseHandleBooleanCast, POSITIVE_TC_IDX }, - { NULL, 0 } - }; -} - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -// 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 -}; - -static void UtcDaliBaseHandleConstructorVoid() -{ - TestApplication application; - tet_infoline("Testing Dali::BaseHandle::BaseHandle()"); - - BaseHandle object; - - DALI_TEST_CHECK(!object); -} - -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 void UtcDaliBaseHandleCopyConstructor() -{ - 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); - } -} - -static void UtcDaliBaseHandleAssignmentOperator() -{ - 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); - } -} - -static void UtcDaliBaseHandleGetBaseObject() -{ - TestApplication application; - tet_infoline("Testing Dali::BaseHandle::GetBaseObject()"); - - BaseHandle object = Actor::New(); - - BaseObject& handle = object.GetBaseObject(); - - DALI_TEST_EQUALS(1, handle.ReferenceCount(), TEST_LOCATION); -} - -static void UtcDaliBaseHandleReset() -{ - 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); -} - -static void UtcDaliBaseHandleEqualityOperator01() -{ - 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); -} - -static void UtcDaliBaseHandleEqualityOperator02() -{ - 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)); -} - -static void UtcDaliBaseHandleInequalityOperator01() -{ - 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); -} - -static void UtcDaliBaseHandleInequalityOperator02() -{ - 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)) -} - -static void UtcDaliBaseHandleStlVector() -{ - 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"); -} - -static void UtcDaliBaseHandleDoAction() -{ - 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); -} - -static bool gTouchCallBackCalled; - -struct TestCallback -{ - void operator()() - { - gTouchCallBackCalled = true; - } -}; - -static void UtcDaliBaseHandleConnectSignal() -{ - 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 ); -} - -static void UtcDaliBaseHandleGetTypeName() -{ - 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") ); -} - -static void UtcDaliBaseHandleGetObjectPtr() -{ - 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 ); -} - -static void UtcDaliBaseHandleBooleanCast() -{ - TestApplication application; - tet_infoline("Testing Dali::BaseHandle::BooleanType"); - - // get the root layer - BaseHandle handle = Actor::New(); - - DALI_TEST_CHECK( static_cast( handle ) ); -} diff --git a/automated-tests/TET/dali-test-suite/actors/utc-Dali-CameraActor.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-CameraActor.cpp deleted file mode 100644 index 26640cf..0000000 --- a/automated-tests/TET/dali-test-suite/actors/utc-Dali-CameraActor.cpp +++ /dev/null @@ -1,1045 +0,0 @@ - // -// 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 - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( UtcDaliCameraActorConstructorVoid, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorConstructorRefObject, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorNew, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorDownCast2, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorSetCameraOffStage, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorSetCameraOnStage, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorGetCamera, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorDefaultProperties, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorSetTarget, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorSetType01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorSetType02, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorSetFieldOfView, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorSetAspectRatio, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorSetNearClippingPlane, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorSetFarClippingPlane, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorSetTargetPosition, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorSetInvertYAxis, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorModelView, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorSetPerspectiveProjection, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorSetOrthographicProjection01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorSetOrthographicProjection02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorSetOrthographicProjection03, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorReadProjectionMatrix, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorAnimatedProperties, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorPropertyIndices, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorCheckLookAtAndFreeLookViews01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorCheckLookAtAndFreeLookViews02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCameraActorCheckLookAtAndFreeLookViews03, POSITIVE_TC_IDX ); - - -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; -} - - -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; -} - - -// Called only once before first test is run. -static void Startup() -{ - // TODO - add a model loader to the test harness -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -static void UtcDaliCameraActorConstructorVoid() -{ - TestApplication application; - tet_infoline("Testing Dali::CameraActor::CameraActor()"); - - CameraActor actor; - - DALI_TEST_CHECK(!actor); -} - -static void UtcDaliCameraActorConstructorRefObject() -{ - TestApplication application; - tet_infoline("Testing Dali::CameraActor::CameraActor(Internal::CameraActor*)"); - - CameraActor actor(NULL); - - DALI_TEST_CHECK(!actor); -} - -static void UtcDaliCameraActorNew() -{ - TestApplication application; - tet_infoline("Testing Dali::CameraActor::New()"); - - CameraActor actor = CameraActor::New(); - - DALI_TEST_CHECK(actor); - - actor = NULL; - - DALI_TEST_CHECK(!actor); -} - -static void UtcDaliCameraActorDownCast() -{ - 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 ); -} - -static void UtcDaliCameraActorDownCast2() -{ - 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 ); -} - - -static void UtcDaliCameraActorSetCameraOffStage() -{ - 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); -} - -static void UtcDaliCameraActorSetCameraOnStage() -{ - 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); -} - - -static void UtcDaliCameraActorGetCamera() -{ - 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); -} - -static void UtcDaliCameraActorDefaultProperties() -{ - 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 ); -} - -static void UtcDaliCameraActorSetTarget() -{ - 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); -} - - -static void UtcDaliCameraActorSetType01() -{ - 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); -} - -static void UtcDaliCameraActorSetType02() -{ - 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); -} - -static void UtcDaliCameraActorSetFieldOfView() -{ - 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); -} - -static void UtcDaliCameraActorSetAspectRatio() -{ - 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); -} - -static void UtcDaliCameraActorSetNearClippingPlane() -{ - 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); -} - -static void UtcDaliCameraActorSetFarClippingPlane() -{ - 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); -} - -static void UtcDaliCameraActorSetTargetPosition() -{ - 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); -} - -static void UtcDaliCameraActorSetInvertYAxis() -{ - 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); -} - -static void UtcDaliCameraActorModelView() -{ - 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 ) ); -} - -static void UtcDaliCameraActorSetPerspectiveProjection() -{ - 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); -} - -static void UtcDaliCameraActorSetOrthographicProjection01() -{ - 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); -} - - -static void UtcDaliCameraActorSetOrthographicProjection02() -{ - 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); - -} - - -static void UtcDaliCameraActorSetOrthographicProjection03() -{ - 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); -} - - -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"; - - -static void UtcDaliCameraActorReadProjectionMatrix() -{ - 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); - - Dali::Internal::CameraActor& internalCamera = GetImplementation(camera); - const Matrix& projectionMatrix2 = internalCamera.GetProjectionMatrix(); - const Matrix& viewMatrix2 = internalCamera.GetViewMatrix(); - DALI_TEST_EQUALS(projectionMatrix, projectionMatrix2, TEST_LOCATION); - DALI_TEST_EQUALS(viewMatrix, viewMatrix2, TEST_LOCATION); - - 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)); -} - -static void UtcDaliCameraActorAnimatedProperties() -{ - 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); -} - -void UtcDaliCameraActorPropertyIndices() -{ - 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 ); -} - -static void UtcDaliCameraActorCheckLookAtAndFreeLookViews01() -{ - 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 ); - } - } - } -} - -static void UtcDaliCameraActorCheckLookAtAndFreeLookViews02() -{ - 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 ); - } - } - } -} - -static void UtcDaliCameraActorCheckLookAtAndFreeLookViews03() -{ - 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); - } -} - diff --git a/automated-tests/TET/dali-test-suite/actors/utc-Dali-Constrainable.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-Constrainable.cpp deleted file mode 100644 index 48bd659..0000000 --- a/automated-tests/TET/dali-test-suite/actors/utc-Dali-Constrainable.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" -{ - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum -{ - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliConstrainableDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstrainableDownCastNegative, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstrainableCustomProperty, POSITIVE_TC_IDX ); - - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -static void UtcDaliConstrainableDownCast() -{ - TestApplication application; - - Handle handle = Constrainable::New(); - - Constrainable customHandle1 = Constrainable::DownCast( handle ); - DALI_TEST_CHECK( customHandle1 ); - - Constrainable customHandle2 = DownCast< Constrainable >( handle ); - DALI_TEST_CHECK( customHandle2 ); -} - -static void UtcDaliConstrainableDownCastNegative() -{ - 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 ); -} - -static void UtcDaliConstrainableCustomProperty() -{ - 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 ); -} - diff --git a/automated-tests/TET/dali-test-suite/actors/utc-Dali-CustomActor.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-CustomActor.cpp deleted file mode 100644 index 11464ff..0000000 --- a/automated-tests/TET/dali-test-suite/actors/utc-Dali-CustomActor.cpp +++ /dev/null @@ -1,1641 +0,0 @@ -// -// 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 - -using namespace Dali; - -static void Startup(); -static void Cleanup(); - -extern "C" -{ - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum -{ - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliCustomActorDestructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCustomActorImplDestructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCustomActorDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCustomActorDownCastNegative, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCustomActorOnStageConnectionDisconnection, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCustomActorOnStageConnectionOrder, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCustomActorOnStageDisconnectionOrder, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCustomActorAddDuringOnStageConnection, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCustomActorRemoveDuringOnStageConnection, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCustomActorAddDuringOnStageDisconnection, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCustomActorRemoveDuringOnStageDisconnection, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCustomActorRemoveParentDuringOnStageConnection, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCustomActorAddParentDuringOnStageDisconnection, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCustomActorOnChildAddRemove, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCustomActorReparentDuringOnChildAdd, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCustomActorRemoveDuringOnChildRemove, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCustomActorOnPropertySet, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCustomActorOnSizeSet, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCustomActorOnSizeAnimation, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCustomActorOnTouchEvent, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCustomActorOnMouseWheelEvent, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliActorFindChildByAlias, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCustomActorDoAction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCustomActorImplOnPropertySet, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCustomActorGetImplementation, POSITIVE_TC_IDX ); - - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -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; -}; - -/** - * 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 ) - { - } -}; - -namespace -{ - -using namespace Dali; - -BaseHandle CreateActor() -{ - return TestCustomActor::New(); -} - -TypeRegistration mType( typeid(TestCustomActor), typeid(Dali::CustomActor), CreateActor ); - -} - - -static void UtcDaliCustomActorDestructor() -{ - TestApplication application; - - CustomActor* actor = new CustomActor(); - delete actor; - - DALI_TEST_CHECK( true ); -} - -static void UtcDaliCustomActorImplDestructor() -{ - TestApplication application; - CustomActorImpl* actor = new Impl::TestCustomActor(); - delete actor; - - DALI_TEST_CHECK( true ); -} - -// Positive test case for a method -static void UtcDaliCustomActorDownCast() -{ - 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 ); -} - -// Negative test case for a method -static void UtcDaliCustomActorDownCastNegative() -{ - 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 ); -} - -static void UtcDaliCustomActorOnStageConnectionDisconnection() -{ - 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(); -} - -static void UtcDaliCustomActorOnStageConnectionOrder() -{ - 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(); -} - -static void UtcDaliCustomActorOnStageDisconnectionOrder() -{ - 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(); -} - -static void UtcDaliCustomActorAddDuringOnStageConnection() -{ - 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(); -} - -static void UtcDaliCustomActorRemoveDuringOnStageConnection() -{ - 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(); -} - -static void UtcDaliCustomActorAddDuringOnStageDisconnection() -{ - 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(); -} - -static void UtcDaliCustomActorRemoveDuringOnStageDisconnection() -{ - 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(); -} - -static void UtcDaliCustomActorRemoveParentDuringOnStageConnection() -{ - 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(); -} - -static void UtcDaliCustomActorAddParentDuringOnStageDisconnection() -{ - 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(); -} - -static void UtcDaliCustomActorOnChildAddRemove() -{ - 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 ); -} - -static void UtcDaliCustomActorReparentDuringOnChildAdd() -{ - 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(); -} - -/** - * Test that Remove can be called (a NOOP) during the OnChildRemove - * triggered when reparenting an actor - */ -static void UtcDaliCustomActorRemoveDuringOnChildRemove() -{ - 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(); -} - -static void UtcDaliCustomActorOnPropertySet() -{ - 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 ); -} - -static void UtcDaliCustomActorOnSizeSet() -{ - 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 ); -} - -static void UtcDaliCustomActorOnSizeAnimation() -{ - 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 ); -} - -static void UtcDaliCustomActorOnTouchEvent() -{ - 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 ); -} - -static void UtcDaliCustomActorOnMouseWheelEvent() -{ - 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 ); -} - -static void UtcDaliActorFindChildByAlias() -{ - 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") ); -} - -static void UtcDaliCustomActorDoAction() -{ - 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); -} - -static void UtcDaliCustomActorImplOnPropertySet() -{ - TestApplication application; - CustomActorImpl* impl = new Impl::SimpleTestCustomActor(); - - impl->OnPropertySet( 0, 0 ); - - DALI_TEST_CHECK( true ); - - delete impl; -} - -static void UtcDaliCustomActorGetImplementation() -{ - 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 ); -} diff --git a/automated-tests/TET/dali-test-suite/actors/utc-Dali-Handle.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-Handle.cpp deleted file mode 100644 index 9aa45a4..0000000 --- a/automated-tests/TET/dali-test-suite/actors/utc-Dali-Handle.cpp +++ /dev/null @@ -1,1002 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( UtcDaliHandleConstructorVoid, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliHandleCopyConstructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliHandleAssignmentOperator, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliHandleSupports, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliHandleGetPropertyCount, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliHandleGetPropertyName, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliHandleGetPropertyIndex, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliHandleIsPropertyWritable, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliHandleIsPropertyAnimatable, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliHandleIsPropertyAConstraintInput, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliHandleGetPropertyType, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliHandleNonAnimtableProperties, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliHandleNonAnimtableCompositeProperties, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliHandleSetProperty01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliHandleSetProperty02, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliHandleRegisterProperty, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliHandleGetProperty, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliHandleDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliHandleCreateProperty, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliHandleGetPropertyGet, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliHandleGetPropertyIndices, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -void UtcDaliHandleConstructorVoid() -{ - TestApplication application; - tet_infoline("Testing Dali::Handle::Handle()"); - - Handle object; - - DALI_TEST_CHECK(!object); -} - -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 UtcDaliHandleCopyConstructor() -{ - 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); - } -} - -static void UtcDaliHandleAssignmentOperator() -{ - 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())); -} - -void UtcDaliHandleSupports() -{ - tet_infoline("Positive Test Dali::Handle::Supports()"); - TestApplication application; - - Actor actor = Actor::New(); - DALI_TEST_CHECK( true == actor.Supports( Handle::DYNAMIC_PROPERTIES ) ); -} - -void UtcDaliHandleGetPropertyCount() -{ - 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() ); -} - -void UtcDaliHandleGetPropertyName() -{ - 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 ) ); - -} - -void UtcDaliHandleGetPropertyIndex() -{ - 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 ) ); -} - -void UtcDaliHandleIsPropertyWritable() -{ - 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 ) ); - DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::SENSITIVE ) ); - DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::LEAVE_REQUIRED ) ); - DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::INHERIT_SHADER_EFFECT ) ); - DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::INHERIT_ROTATION ) ); - DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::INHERIT_SCALE ) ); - DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::COLOR_MODE ) ); - DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::POSITION_INHERITANCE ) ); - DALI_TEST_CHECK( true == actor.IsPropertyWritable( Actor::DRAW_MODE ) ); - - // 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 ) ); - -} - -void UtcDaliHandleIsPropertyAnimatable() -{ - 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 ) ); - - // Event-thread only properties can not be animated - DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::SENSITIVE ) ); - DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::LEAVE_REQUIRED ) ); - DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::INHERIT_SHADER_EFFECT ) ); - DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::INHERIT_ROTATION ) ); - DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::INHERIT_SCALE ) ); - DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::COLOR_MODE ) ); - DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::POSITION_INHERITANCE ) ); - DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( Actor::DRAW_MODE ) ); - - // Type registered properties are not animatable - DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( PROPERTY_REGISTRATION_START_INDEX ) ); // START - DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( PROPERTY_REGISTRATION_START_INDEX + ( ( PROPERTY_REGISTRATION_MAX_INDEX - PROPERTY_REGISTRATION_START_INDEX ) * 0.5 ) ) ); // MIDDLE - DALI_TEST_CHECK( false == actor.IsPropertyAnimatable( PROPERTY_REGISTRATION_MAX_INDEX ) ); // MAX -} - -void UtcDaliHandleIsPropertyAConstraintInput() -{ - TestApplication application; - - Actor actor = Actor::New(); - - // Actor properties which can be used as a constraint input: - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::PARENT_ORIGIN ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::PARENT_ORIGIN_X ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::PARENT_ORIGIN_Y ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::PARENT_ORIGIN_Z ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::ANCHOR_POINT ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::ANCHOR_POINT_X ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::ANCHOR_POINT_Y ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::ANCHOR_POINT_Z ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SIZE ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SIZE_WIDTH ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SIZE_HEIGHT ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SIZE_DEPTH ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::POSITION ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::POSITION_X ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::POSITION_Y ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::POSITION_Z ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::ROTATION ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SCALE ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SCALE_X ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SCALE_Y ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SCALE_Z ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::VISIBLE ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::COLOR ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::COLOR_RED ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::COLOR_GREEN ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::COLOR_BLUE ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::COLOR_ALPHA ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_POSITION ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_ROTATION ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_SCALE ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_COLOR ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_POSITION_X ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_POSITION_Y ) ); - DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_POSITION_Z ) ); - - // Actor properties that cannot be used as a constraint input - DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::NAME ) ); - DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::SENSITIVE ) ); - DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::LEAVE_REQUIRED ) ); - DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::INHERIT_SHADER_EFFECT ) ); - DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::INHERIT_ROTATION ) ); - DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::INHERIT_SCALE ) ); - DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::COLOR_MODE ) ); - DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::POSITION_INHERITANCE ) ); - DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::DRAW_MODE ) ); -} - -void UtcDaliHandleGetPropertyType() -{ - 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 ); - -} - -void UtcDaliHandleNonAnimtableProperties() -{ - 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 ); - -} - -void UtcDaliHandleNonAnimtableCompositeProperties() -{ - 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 ); - -} - -void UtcDaliHandleSetProperty01() -{ - 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() ); -} - -void UtcDaliHandleSetProperty02() -{ - 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); - } - -} - -void UtcDaliHandleRegisterProperty() -{ - 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() ); - -} - -void UtcDaliHandleGetProperty() -{ - 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() ); -} - -void UtcDaliHandleDownCast() -{ - 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 ); - -} - -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 - -void UtcDaliHandleCreateProperty() -{ - 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 ); -} - -void UtcDaliHandleGetPropertyGet() -{ - 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" ); - -} - -void UtcDaliHandleGetPropertyIndices() -{ - 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 ); -} diff --git a/automated-tests/TET/dali-test-suite/actors/utc-Dali-ImageActor.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-ImageActor.cpp deleted file mode 100644 index b374f17..0000000 --- a/automated-tests/TET/dali-test-suite/actors/utc-Dali-ImageActor.cpp +++ /dev/null @@ -1,990 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static const char* TestImageFilename = "icon_wrt.png"; - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliImageActorConstructorVoid, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorDestructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorConstructorRefObject, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorNew01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorNew02, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorDownCast2, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActor9Patch, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorPixelArea, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorGetCurrentImageSize01,POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorGetCurrentImageSize02,POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorGetCurrentImageSize03,POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorGetCurrentImageSize04,POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorGetCurrentImageSize05,POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorNaturalPixelAreaSize01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorNaturalPixelAreaSize02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorDefaultProperties, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorUseImageAlpha01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorUseImageAlpha02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorUseImageAlpha03, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorUseImageAlpha04, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorUseImageAlpha05, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorClearPixelArea, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageGetStyle, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageSetNinePatchBorder, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageSetFadeIn, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageSetFadeInDuration, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorNewNull, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorNewNullWithArea, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorSetImage, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorPropertyIndices, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliImageActorImageProperty, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -static void UtcDaliImageActorConstructorVoid() -{ - TestApplication application; - tet_infoline("Testing Dali::ImageActor::ImageActor()"); - - ImageActor actor; - - DALI_TEST_CHECK(!actor); -} - -static void UtcDaliImageActorDestructor() -{ - TestApplication application; - - ImageActor* actor = new ImageActor(); - delete actor; - - DALI_TEST_CHECK( true ); -} - -static void UtcDaliImageActorConstructorRefObject() -{ - TestApplication application; - tet_infoline("Testing Dali::ImageActor::ImageActor(Internal::ImageActor*)"); - - ImageActor actor(NULL); - - DALI_TEST_CHECK(!actor); -} - -static void UtcDaliImageActorNew01() -{ - 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); -} - -static void UtcDaliImageActorNew02() -{ - 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); -} - -static void UtcDaliImageActorDownCast() -{ - 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); -} - -static void UtcDaliImageActorDownCast2() -{ - 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); -} - -static void UtcDaliImageActor9Patch() -{ - 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 ); -} - -static void UtcDaliImageActorPixelArea() -{ - 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 ); -} - -static void UtcDaliImageActorGetCurrentImageSize01() -{ - 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 ); -} - - -static void UtcDaliImageActorGetCurrentImageSize02() -{ - 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 ); -} - - -static void UtcDaliImageActorGetCurrentImageSize03() -{ - 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 ); -} - - -static void UtcDaliImageActorGetCurrentImageSize04() -{ - 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 ); -} - - -static void UtcDaliImageActorGetCurrentImageSize05() -{ - 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 ); -} - -static void UtcDaliImageActorNaturalPixelAreaSize01() -{ - 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 ); -} - -static void UtcDaliImageActorNaturalPixelAreaSize02() -{ - 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 ); -} - - - -static void UtcDaliImageActorDefaultProperties() -{ - 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); - -} - -static void UtcDaliImageActorUseImageAlpha01() -{ - 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 ); -} - -static void UtcDaliImageActorUseImageAlpha02() -{ - 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 ); -} - -static void UtcDaliImageActorUseImageAlpha03() -{ - 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 ); -} - -static void UtcDaliImageActorUseImageAlpha04() -{ - 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 ); -} - -static void UtcDaliImageActorUseImageAlpha05() -{ - 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 ); -} - -static void UtcDaliImageActorClearPixelArea() -{ - 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 ); -} - -static void UtcDaliImageGetStyle() -{ - 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 ); -} - -static void UtcDaliImageSetNinePatchBorder() -{ - 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 ); -} - -static void UtcDaliImageSetFadeIn() -{ - 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 ); -} - - -static void UtcDaliImageSetFadeInDuration() -{ - 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 ); -} - -static void UtcDaliImageActorNewNull() -{ - TestApplication application; - - ImageActor actor = ImageActor::New(Image()); - - DALI_TEST_CHECK(actor); -} - -static void UtcDaliImageActorNewNullWithArea() -{ - TestApplication application; - - ImageActor::PixelArea area( 1, 2, 3, 4 ); - - ImageActor actor = ImageActor::New(Image(), area); - - DALI_TEST_CHECK(actor); -} - -static void UtcDaliImageActorSetImage() -{ - TestApplication application; - - ImageActor actor = ImageActor::New(Image()); - - DALI_TEST_CHECK(actor); - - actor.SetImage( Image() ); - - DALI_TEST_CHECK(!actor.GetImage()); -} - -void UtcDaliImageActorPropertyIndices() -{ - 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 ); -} - -void UtcDaliImageActorImageProperty() -{ - TestApplication application; - Image image = Image::New( "MY_PATH" ); - ImageActor imageActor = ImageActor::New( image ); - - Stage::GetCurrent().Add( imageActor ); - application.SendNotification(); - application.Render(); - - Property::Value imageMap = imageActor.GetProperty( ImageActor::IMAGE ); - DALI_TEST_CHECK( imageMap.HasKey( "filename" ) ); - DALI_TEST_EQUALS( imageMap.GetValue( "filename" ).Get< std::string >(), "MY_PATH", TEST_LOCATION ); -} diff --git a/automated-tests/TET/dali-test-suite/actors/utc-Dali-Layer.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-Layer.cpp deleted file mode 100644 index 629bec5..0000000 --- a/automated-tests/TET/dali-test-suite/actors/utc-Dali-Layer.cpp +++ /dev/null @@ -1,533 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliLayerNew, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLayerCreateDestroy, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLayerDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLayerDownCast2, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLayerGetDepth, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLayerRaise, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLayerLower, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLayerRaiseToTop, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLayerLowerToBottom, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLayerSetClipping, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLayerIsClipping, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLayerSetClippingBox, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLayerGetClippingBox, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLayerSetSortFunction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLayerRaiseAbove, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLayerRaiseBelow, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLayerMoveAbove, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLayerMoveBelow, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLayerDefaultProperties, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLayerSetDepthTestDisabled, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLayerPropertyIndices, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -static void UtcDaliLayerNew() -{ - TestApplication application; - Layer layer = Layer::New(); - - DALI_TEST_CHECK(layer); -} - -static void UtcDaliLayerDownCast() -{ - 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); -} - -static void UtcDaliLayerDownCast2() -{ - 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); -} - - -static void UtcDaliLayerGetDepth() -{ - 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); -} - -static void UtcDaliLayerRaise() -{ - 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); -} - -static void UtcDaliLayerLower() -{ - 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); -} - -static void UtcDaliLayerRaiseToTop() -{ - 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); -} - -static void UtcDaliLayerLowerToBottom() -{ - 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); -} - -static void UtcDaliLayerSetClipping() -{ - 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()); -} - -static void UtcDaliLayerIsClipping() -{ - tet_infoline("Testing Dali::Layer::IsClipping()"); - TestApplication application; - - Layer layer = Layer::New(); - DALI_TEST_CHECK(!layer.IsClipping()); -} - -static void UtcDaliLayerSetClippingBox() -{ - 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); -} - -static void UtcDaliLayerGetClippingBox() -{ - tet_infoline("Testing Dali::Layer::GetClippingBox()"); - TestApplication application; - - Layer layer = Layer::New(); - DALI_TEST_CHECK(layer.GetClippingBox() == ClippingBox(0,0,0,0)); -} - -static int gTestSortFunctionCalled; - -static float TestSortFunction(const Vector3& /*position*/, float /*sortModifier*/) -{ - ++gTestSortFunctionCalled; - return 0.0f; -} - -static void UtcDaliLayerSetSortFunction() -{ - 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 ); -} - - -static void UtcDaliLayerRaiseAbove() -{ - 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 ); -} - -static void UtcDaliLayerRaiseBelow() -{ - 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 ); -} - -static void UtcDaliLayerMoveAbove() -{ - 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 ); -} - -static void UtcDaliLayerMoveBelow() -{ - 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 ); -} - -static void UtcDaliLayerDefaultProperties() -{ - 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 ); - -} - -static void UtcDaliLayerSetDepthTestDisabled() -{ - 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() ); -} - -static void UtcDaliLayerCreateDestroy() -{ - tet_infoline("Testing Dali::Layer::CreateDestroy() "); - Layer* layer = new Layer; - DALI_TEST_CHECK( layer ); - delete layer; -} - -void UtcDaliLayerPropertyIndices() -{ - 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 ); -} diff --git a/automated-tests/TET/dali-test-suite/actors/utc-Dali-LightActor.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-LightActor.cpp deleted file mode 100644 index 0651ec1..0000000 --- a/automated-tests/TET/dali-test-suite/actors/utc-Dali-LightActor.cpp +++ /dev/null @@ -1,346 +0,0 @@ -// -// 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 - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliLightActorConstructorVoid, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLightActorConstructorRefObject, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLightActorDestructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLightActorNew, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLightActorDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLightActorDownCast2, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLightActorSetGetLight, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLightActorSetGetActive, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLightActorMeshTest, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLightActorDefaultProperties, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLightActorPropertyIndices, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ - // THERE IS NO MAINLOOP IN THE TEST APPLICATION -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -static void UtcDaliLightActorConstructorVoid() -{ - TestApplication application; - tet_infoline("Testing Dali::LightActor::LightActor() UtcDaliLightActorConstructorVoid"); - - LightActor actor; - - DALI_TEST_CHECK(!actor); -} - -static void UtcDaliLightActorConstructorRefObject() -{ - TestApplication application; - tet_infoline("Testing Dali::LightActor::LightActor(Internal::LightActor*) UtcDaliLightActorConstructorRefObject"); - - LightActor actor(NULL); - - DALI_TEST_CHECK(!actor); -} - -static void UtcDaliLightActorDestructor() -{ - // 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 ); -} - -static void UtcDaliLightActorNew() -{ - TestApplication application; - tet_infoline("Testing Dali::LightActor::New() UtcDaliLightActorNew"); - - LightActor actor = LightActor::New(); - - DALI_TEST_CHECK(actor); -} - -static void UtcDaliLightActorDownCast() -{ - 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 ) ); -} - -static void UtcDaliLightActorDownCast2() -{ - 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); -} - -static void UtcDaliLightActorSetGetLight() -{ - 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); - } -} - -static void UtcDaliLightActorSetGetActive() -{ - 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); - } -} - - -static void UtcDaliLightActorMeshTest() -{ - 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 ); -} - -static void UtcDaliLightActorDefaultProperties() -{ - 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); - -} - -void UtcDaliLightActorPropertyIndices() -{ - 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 ); -} diff --git a/automated-tests/TET/dali-test-suite/actors/utc-Dali-MeshActor.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-MeshActor.cpp deleted file mode 100644 index 481cda2..0000000 --- a/automated-tests/TET/dali-test-suite/actors/utc-Dali-MeshActor.cpp +++ /dev/null @@ -1,929 +0,0 @@ -// -// 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 -#include -#include - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliMeshActorConstructorVoid, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorConstructorRefObject, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorNew01, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorNew02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorNew03, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorDownCast2, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorCreateNoMeshData, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorCreateSetData01, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorCreateSetData02, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorCreateSetData03, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorCreateSetData04, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorSetMaterial01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorSetMaterial01b, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorSetMaterial02, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorSetMaterial02b, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorSetMaterial03, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorSetMaterial03b, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorGetMaterial01, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorGetMaterial02, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorSetLighting01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorSetLighting02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorBlend01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorBlend02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorBlend03, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorBlend04, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorBlend05, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorBlend06, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorBlend07, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorBlend08, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorBlend09, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorBoneUpdate01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshActorIndices, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - - -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; -} - -static void UtcDaliMeshActorConstructorVoid() -{ - TestApplication application; - tet_infoline("Testing Dali::MeshActor::MeshActor()"); - - MeshActor actor; - DALI_TEST_CHECK(!actor); -} - -static void UtcDaliMeshActorConstructorRefObject() -{ - TestApplication application; - tet_infoline("Testing Dali::MeshActor::MeshActor(Internal::MeshActor*)"); - - MeshActor actor(NULL); - DALI_TEST_CHECK(!actor); - - MeshActor* actorPtr = new MeshActor(); - DALI_TEST_CHECK( ! *actorPtr ); - delete actorPtr; -} - -static void UtcDaliMeshActorNew01() -{ - TestApplication application; - tet_infoline("Testing Dali::MeshActor::New()"); - - 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 actor = MeshActor::New(mesh); - application.SendNotification(); - application.Render(); - application.Render(); - application.SendNotification(); - - DALI_TEST_CHECK(actor); -} - -static void UtcDaliMeshActorNew02() -{ - 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) -} - - -static void UtcDaliMeshActorNew03() -{ - TestApplication application; - tet_infoline("Testing Dali::Mesh::New() - Create with no mesh"); - - MeshActor actor = MeshActor::New(); // Shouldn't assert - tet_result(TET_PASS); -} - -static void UtcDaliMeshActorCreateNoMeshData() -{ - 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); - } -} - - -static void UtcDaliMeshActorCreateSetData01() -{ - 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 ); - } -} - -static void UtcDaliMeshActorCreateSetData02() -{ - 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 ); - } -} - -static void UtcDaliMeshActorCreateSetData03() -{ - 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 ); - } -} - -static void UtcDaliMeshActorCreateSetData04() -{ - 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); -} - - -static void UtcDaliMeshActorDownCast() -{ - 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); -} - -static void UtcDaliMeshActorDownCast2() -{ - 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); -} - -static void UtcDaliMeshActorSetMaterial01() -{ - 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 ); -} - -static void UtcDaliMeshActorSetMaterial01b() -{ - 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 ); -} - - -static void UtcDaliMeshActorSetMaterial02() -{ - 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 ); -} - -static void UtcDaliMeshActorSetMaterial02b() -{ - 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 ); -} - - -static void UtcDaliMeshActorSetMaterial03() -{ - 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 ); -} - -static void UtcDaliMeshActorSetMaterial03b() -{ - 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 ); -} - - - -static void UtcDaliMeshActorGetMaterial01() -{ - 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 ); -} - - -static void UtcDaliMeshActorGetMaterial02() -{ - 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 ); -} - -static void UtcDaliMeshActorSetLighting01() -{ - 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); -} - -static void UtcDaliMeshActorSetLighting02() -{ - 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); -} - - -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 ); -} - - -static void UtcDaliMeshActorBlend01() -{ - // 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 ); -} - - -static void UtcDaliMeshActorBlend02() -{ - // 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 ); -} - -static void UtcDaliMeshActorBlend03() -{ - // 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 ); -} - - -static void UtcDaliMeshActorBlend04() -{ - // 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 ); -} - -static void UtcDaliMeshActorBlend05() -{ - // 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 ); -} - - -static void UtcDaliMeshActorBlend06() -{ - // 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 ); -} - -static void UtcDaliMeshActorBlend07() -{ - // 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 ); -} - -static void UtcDaliMeshActorBlend08() -{ - // 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 ); -} - -static void UtcDaliMeshActorBlend09() -{ - // 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 ); -} - -static void UtcDaliMeshActorBoneUpdate01() -{ - 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 = Actor::New(); - 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 ) - - const Internal::SceneGraph::Node *twigNode = static_cast(GetImplementation(twig).GetSceneObject()); - Matrix worldMatrix = twigNode->GetWorldMatrix(0); - - DALI_TEST_CHECK( worldMatrix != Matrix::IDENTITY ); - - Matrix calcWorldMatrix = twig.GetCurrentWorldMatrix(); - DALI_TEST_CHECK( worldMatrix == calcWorldMatrix ); - - // Non-bones have moved. Check that their world matrix is identity: - const Internal::SceneGraph::Node *bugNode = static_cast(GetImplementation(bug).GetSceneObject()); - Matrix bugWorldMatrix = bugNode->GetWorldMatrix(0); - DALI_TEST_CHECK( bugWorldMatrix == Matrix::IDENTITY ); - - // But also check that property is calculated as needed: - calcWorldMatrix = bug.GetCurrentWorldMatrix(); - DALI_TEST_CHECK( bugWorldMatrix != calcWorldMatrix ); - -} - -void UtcDaliMeshActorIndices() -{ - 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 ); -} diff --git a/automated-tests/TET/dali-test-suite/actors/utc-Dali-Model.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-Model.cpp deleted file mode 100644 index d873bf6..0000000 --- a/automated-tests/TET/dali-test-suite/actors/utc-Dali-Model.cpp +++ /dev/null @@ -1,679 +0,0 @@ -// -// 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 - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( UtcDaliModelConstructorVoid, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliModelConstructorRefObject, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliModelNew, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliModelDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliModelGetLoadingState01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliModelGetLoadingState02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliModelGetLoadingState03, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliModelActorFactory, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliModelActorFactoryTwoMesh, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliModelNumberOfAnimations, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliModelBuildAnimation01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliModelBuildAnimation02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliModelBuildAnimation03, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliModelBuildAnimation04, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliModelBuildAnimation05, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliModelBuildAnimation06, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliModelBuildAnimation07, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliModelBuildAnimation08, NEGATIVE_TC_IDX ); - -static std::string gModelFile = "blah"; - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -// 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 void UtcDaliModelConstructorVoid() -{ - TestApplication application; - tet_infoline("Testing Dali::Model::Model()"); - - Model model; - - DALI_TEST_CHECK(!model); -} - -static void UtcDaliModelConstructorRefObject() -{ - TestApplication application; - tet_infoline("Testing Dali::Model::Model(Internal::Model*)"); - - Model model(NULL); - - DALI_TEST_CHECK(!model); -} - -static void UtcDaliModelNew() -{ - 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); -} - -static void UtcDaliModelDownCast() -{ - 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); -} - - -static void UtcDaliModelGetLoadingState01() -{ - 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); -} - -static void UtcDaliModelGetLoadingState02() -{ - 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); -} - -static void UtcDaliModelGetLoadingState03() -{ - 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); -} - - -// Could probably test the signals, too! - -static void UtcDaliModelNumberOfAnimations() -{ - 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 ); -} - -static void UtcDaliModelActorFactory() -{ - 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); -} - -static void UtcDaliModelActorFactoryTwoMesh() -{ - 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 ); - } -} - -static void UtcDaliModelBuildAnimation01() -{ - 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(); -} - - - -static void UtcDaliModelBuildAnimation02() -{ - 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); -} - - -static void UtcDaliModelBuildAnimation03() -{ - 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); -} - - -static void UtcDaliModelBuildAnimation04() -{ - 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); -} - - -static void UtcDaliModelBuildAnimation05() -{ - 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); -} - - -static void UtcDaliModelBuildAnimation06() -{ - 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); -} - - -static void UtcDaliModelBuildAnimation07() -{ - 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); -} - -static void UtcDaliModelBuildAnimation08() -{ - 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); -} diff --git a/automated-tests/TET/dali-test-suite/actors/utc-Dali-RenderableActor.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-RenderableActor.cpp deleted file mode 100644 index c72600d..0000000 --- a/automated-tests/TET/dali-test-suite/actors/utc-Dali-RenderableActor.cpp +++ /dev/null @@ -1,522 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static const char* TestTextHelloWorld = "Hello World"; - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliRenderableActorDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderableActorSetSortModifier, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderableActorGetSortModifier, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderableActorSetGetBlendMode, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderableActorSetCullFace, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderableActorGetCullFace, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderableActorSetGetBlendFunc, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderableActorSetGetBlendEquation, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderableActorSetGetBlendColor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderableActorSetGetAlpha, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderableActorCreateDestroy, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ - // THERE IS NO MAINLOOP IN THE TEST APPLICATION -} - -// Called only once after last test is run -static void Cleanup() -{ -} - - -static void UtcDaliRenderableActorDownCast() -{ - 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 ); -} - -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; -} - -static void UtcDaliRenderableActorSetSortModifier() -{ - 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 ); -} - -static void UtcDaliRenderableActorGetSortModifier() -{ - 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); -} - -static void UtcDaliRenderableActorSetGetBlendMode() -{ - 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() ); -} - -static void UtcDaliRenderableActorSetCullFace() -{ - 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); -} - -static void UtcDaliRenderableActorGetCullFace() -{ - 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() ); -} - -static void UtcDaliRenderableActorSetGetBlendFunc() -{ - 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 ); -} - -static void UtcDaliRenderableActorSetGetBlendEquation() -{ - 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 ); -} - -static void UtcDaliRenderableActorSetGetBlendColor() -{ - 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 ); -} - -static void UtcDaliRenderableActorSetGetAlpha() -{ - 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 ); -} - -static void UtcDaliRenderableActorCreateDestroy() -{ - tet_infoline("Testing Dali::RenderableActor::CreateDestroy()"); - RenderableActor* ractor = new RenderableActor; - RenderableActor ractor2( *ractor ); - DALI_TEST_CHECK( ractor ); - delete ractor; -} diff --git a/automated-tests/TET/dali-test-suite/actors/utc-Dali-Stage.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-Stage.cpp deleted file mode 100644 index 6b61d5e..0000000 --- a/automated-tests/TET/dali-test-suite/actors/utc-Dali-Stage.cpp +++ /dev/null @@ -1,651 +0,0 @@ -// -// 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; -using namespace std; - -static void Startup(); -static void Cleanup(); - -extern "C" -{ - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum -{ - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliStageDefaultConstructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliStageDestructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliStageGetCurrent, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliStageIsInstalled, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliStageAdd, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliStageRemove, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliStageGetSize, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliStageGetLayerCount, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliStageGetLayer, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliStageGetRootLayer, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliStageSetBackgroundColor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliStageGetBackgroundColor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliStageGetDpi01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliStageGetDpi02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliStageGetDpi03, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliStageInitializeDynamics, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliStageGetDynamicsWorld, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliStageTerminateDynamics, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliStageKeepRendering, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliStageEventProcessingFinished, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliStageSignalKeyEvent, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliStageTouchedSignal, POSITIVE_TC_IDX ); - -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 - -// Called only once before first test is run. -static void Startup() -{ - // THERE IS NO MAINLOOP IN THE TEST APPLICATION -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -static void UtcDaliStageDefaultConstructor() -{ - TestApplication application; - Stage stage; - - DALI_TEST_CHECK(!stage); -} - -static void UtcDaliStageDestructor() -{ - TestApplication application; - Stage* stage = new Stage(); - delete stage; - stage = NULL; - - DALI_TEST_CHECK( true ); -} - -static void UtcDaliStageGetCurrent() -{ - TestApplication application; - Stage stage = Stage::GetCurrent(); - - DALI_TEST_CHECK(stage); -} - -static void UtcDaliStageIsInstalled() -{ - DALI_TEST_CHECK(!Stage::IsInstalled()); - - TestApplication application; - - Stage::GetCurrent(); - - DALI_TEST_CHECK(Stage::IsInstalled()); -} - -static void UtcDaliStageAdd() -{ - TestApplication application; - - Stage stage = Stage::GetCurrent(); - - Actor actor = Actor::New(); - DALI_TEST_CHECK(!actor.OnStage()); - - stage.Add(actor); - DALI_TEST_CHECK(actor.OnStage()); -} - -static void UtcDaliStageRemove() -{ - 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()); -} - -static void UtcDaliStageGetSize() -{ - 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); -} - -static void UtcDaliStageGetDpi01() -{ - 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); -} - -static void UtcDaliStageGetDpi02() -{ - 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); -} - - -static void UtcDaliStageGetDpi03() -{ - 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); -} - -static void UtcDaliStageInitializeDynamics() -{ - TestApplication application; - - Stage stage = Stage::GetCurrent(); - - DALI_TEST_CHECK( !stage.InitializeDynamics( DynamicsWorldConfig::New() ) ); -} - -static void UtcDaliStageGetDynamicsWorld() -{ - TestApplication application; - - Stage stage = Stage::GetCurrent(); - - DALI_TEST_CHECK( !stage.GetDynamicsWorld() ); -} - -static void UtcDaliStageTerminateDynamics() -{ - TestApplication application; - - Stage stage = Stage::GetCurrent(); - - stage.TerminateDynamics(); - - DALI_TEST_CHECK( !stage.GetDynamicsWorld() ); -} - -static void UtcDaliStageGetLayerCount() -{ - 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); -} - -static void UtcDaliStageGetLayer() -{ - 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); -} - - -static void UtcDaliStageGetRootLayer() -{ - 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 ); -} - -static void UtcDaliStageSetBackgroundColor() -{ - 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); -} - -static void UtcDaliStageGetBackgroundColor() -{ - TestApplication application; - - Stage stage = Stage::GetCurrent(); - - DALI_TEST_EQUALS(Stage::DEFAULT_BACKGROUND_COLOR, stage.GetBackgroundColor(), TEST_LOCATION); -} - -static void UtcDaliStageKeepRendering() -{ - 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 ); -} - -static void UtcDaliStageEventProcessingFinished() -{ - 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 ); - -} - -static void UtcDaliStageSignalKeyEvent() -{ - 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) ); -} - -void UtcDaliStageTouchedSignal() -{ - 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(); - } -} diff --git a/automated-tests/TET/dali-test-suite/actors/utc-Dali-TextActor.cpp b/automated-tests/TET/dali-test-suite/actors/utc-Dali-TextActor.cpp deleted file mode 100644 index 3b6a4af..0000000 --- a/automated-tests/TET/dali-test-suite/actors/utc-Dali-TextActor.cpp +++ /dev/null @@ -1,856 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -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 ); - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliTextActorConstructorVoid, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextActorConstructorRefObject, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextActorNew01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextActorNew02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextActorNew03, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextActorNew04, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextActorNew05, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextActorNew06, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextActorNew07, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextActorDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextActorDownCast2, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextActorSetText, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextActorSetTextIndividualStyles, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliTextActorSetFont, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextActorSetFontDetection, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextActorChangingText, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextActorGetLoadingState, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextActorSetItalics, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextActorSetUnderline, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextActorSetWeight, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextActorSetStyle, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextActorDefaultProperties, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextActorSetGradientColor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextActorSetGradientStartPoint, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextActorSetGradientEndPoint, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliTextActorSynchronousGlyphLoading, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliTextActorAutomaticSizeSet, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextActorAutomaticSizeSetAnimation, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliTextActorPropertyIndices, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -static void UtcDaliTextActorConstructorVoid() -{ - TestApplication application; - - tet_infoline("Testing Dali::TextActor::TextActor()"); - - TextActor actor; - - DALI_TEST_CHECK(!actor); -} - -static void UtcDaliTextActorConstructorRefObject() -{ - TestApplication application; - - tet_infoline("Testing Dali::TextActor::TextActor(Internal::TextActor*)"); - - TextActor actor(NULL); - - DALI_TEST_CHECK(!actor); -} - -static void UtcDaliTextActorNew01() -{ - 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); -} - - -static void UtcDaliTextActorNew02() -{ - 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); -} - -static void UtcDaliTextActorNew03() -{ - 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); -} - - -static void UtcDaliTextActorNew04() -{ - 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); -} - -static void UtcDaliTextActorNew05() -{ - 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); -} - -static void UtcDaliTextActorNew06() -{ - 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); -} - -static void UtcDaliTextActorNew07() -{ - TestApplication application; - - tet_infoline("Testing Dali::TextActor::New()"); - - TextStyle style; - - TextActor actor = TextActor::New(Text(TestTextHello), style, false, false); - - DALI_TEST_CHECK(actor); -} - - -static void UtcDaliTextActorDownCast() -{ - 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!")); -} - -static void UtcDaliTextActorDownCast2() -{ - 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); -} - -static void UtcDaliTextActorSetText() -{ - 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); -} - -static void UtcDaliTextActorSetFont() -{ - 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 ); -} - -static void UtcDaliTextActorSetFontDetection() -{ - TestApplication application; - - TextActor actor = TextActor::New(TestTextHello); - - actor.SetFontDetectionAutomatic( true ); - - DALI_TEST_CHECK( true == actor.IsFontDetectionAutomatic() ); - -} - -static void UtcDaliTextActorSetTextIndividualStyles() -{ - 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() ); - - -} - -static void UtcDaliTextActorChangingText() -{ - 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); -} - -static void UtcDaliTextActorGetLoadingState() -{ - TestApplication application; - - TextActor actor = TextActor::New(TestTextHello); - - DALI_TEST_CHECK( ResourceLoading == actor.GetLoadingState()); - - application.SendNotification(); - application.Render(); - - DALI_TEST_CHECK( ResourceLoadingSucceeded == actor.GetLoadingState()); - -} - -static void UtcDaliTextActorSetItalics() -{ - 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 -} - -static void UtcDaliTextActorSetUnderline() -{ - 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 -} - -static void UtcDaliTextActorSetWeight() -{ - 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() ); -} - -static void UtcDaliTextActorSetStyle() -{ - 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() ); -} - -static void UtcDaliTextActorDefaultProperties() -{ - 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); -} - -static void UtcDaliTextActorSetGradientColor() -{ - 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 ); -} - -static void UtcDaliTextActorSetGradientStartPoint() -{ - 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 ); -} - -static void UtcDaliTextActorSetGradientEndPoint() -{ - 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 ); -} - -static void UtcDaliTextActorSynchronousGlyphLoading() -{ - 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" ) ); -} - -static void UtcDaliTextActorAutomaticSizeSet() -{ - 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 ); -} - -static void UtcDaliTextActorAutomaticSizeSetAnimation() -{ - 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 ); -} - -void UtcDaliTextActorPropertyIndices() -{ - 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 ); -} diff --git a/automated-tests/TET/dali-test-suite/animation/.gitignore b/automated-tests/TET/dali-test-suite/animation/.gitignore deleted file mode 100644 index d4fcbb7..0000000 --- a/automated-tests/TET/dali-test-suite/animation/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -utc-Dali-Constraint -utc-Dali-Animation -utc-Dali-AlphaFunctions -utc-Dali-ActiveConstraint diff --git a/automated-tests/TET/dali-test-suite/animation/Makefile b/automated-tests/TET/dali-test-suite/animation/Makefile deleted file mode 120000 index c88d5a7..0000000 --- a/automated-tests/TET/dali-test-suite/animation/Makefile +++ /dev/null @@ -1 +0,0 @@ -../master-makefile.mk \ No newline at end of file diff --git a/automated-tests/TET/dali-test-suite/animation/file.list b/automated-tests/TET/dali-test-suite/animation/file.list deleted file mode 100644 index f2841c5..0000000 --- a/automated-tests/TET/dali-test-suite/animation/file.list +++ /dev/null @@ -1,5 +0,0 @@ -TARGETS += \ - utc-Dali-ActiveConstraint \ - utc-Dali-AlphaFunctions \ - utc-Dali-Animation \ - utc-Dali-Constraint \ diff --git a/automated-tests/TET/dali-test-suite/animation/tslist b/automated-tests/TET/dali-test-suite/animation/tslist deleted file mode 100644 index 909e49c..0000000 --- a/automated-tests/TET/dali-test-suite/animation/tslist +++ /dev/null @@ -1,4 +0,0 @@ -/dali-test-suite/animation/utc-Dali-ActiveConstraint -/dali-test-suite/animation/utc-Dali-Animation -/dali-test-suite/animation/utc-Dali-Constraint -/dali-test-suite/animation/utc-Dali-AlphaFunctions diff --git a/automated-tests/TET/dali-test-suite/animation/utc-Dali-ActiveConstraint.cpp b/automated-tests/TET/dali-test-suite/animation/utc-Dali-ActiveConstraint.cpp deleted file mode 100644 index 97d2402..0000000 --- a/automated-tests/TET/dali-test-suite/animation/utc-Dali-ActiveConstraint.cpp +++ /dev/null @@ -1,408 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void UtcDaliConstraintGetTargetObject(); -static void UtcDaliConstraintGetTargetProperty(); -static void UtcDaliConstraintSetWeight(); -static void UtcDaliConstraintGetCurrentWeight(); -static void UtcDaliConstraintSignalApplied(); - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliConstraintGetTargetObject, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintGetTargetProperty, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintSetWeight, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintGetCurrentWeight, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintSignalApplied, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintRemove, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintCallback, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintProperties, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -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 void UtcDaliConstraintGetTargetObject() -{ - 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 ); -} - -static void UtcDaliConstraintGetTargetProperty() -{ - 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 ); -} - -static void UtcDaliConstraintSetWeight() -{ - 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 ); -} - -static void UtcDaliConstraintGetCurrentWeight() -{ - 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() ); -} - -static void UtcDaliConstraintSignalApplied() -{ - 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(); -} - -static void UtcDaliConstraintRemove() -{ - 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; -} - -static bool constraintSignalled=false; -static void ConstraintCallback( ActiveConstraint& constraint ) -{ - constraintSignalled = true; -} - -static void UtcDaliConstraintCallback() -{ - 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 ); -} - -void UtcDaliConstraintProperties() -{ - 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 ); - - // Invalid Property - try - { - active.GetPropertyName( PROPERTY_REGISTRATION_START_INDEX ); - tet_result( TET_FAIL ); - } - catch ( DaliException& e ) - { - DALI_TEST_ASSERT_CONDITION_STARTS_WITH_SUBSTRING( e, "! \"Cannot find property index", TEST_LOCATION ); - } - DALI_TEST_EQUALS( active.GetPropertyIndex( "invalid-property-name"), Property::INVALID_INDEX, TEST_LOCATION ); - try - { - active.IsPropertyWritable( PROPERTY_REGISTRATION_START_INDEX ); - tet_result( TET_FAIL ); - } - catch ( DaliException& e ) - { - DALI_TEST_ASSERT_CONDITION_STARTS_WITH_SUBSTRING( e, "! \"Cannot find property index", TEST_LOCATION ); - } - DALI_TEST_CHECK( ! active.IsPropertyAnimatable( PROPERTY_REGISTRATION_START_INDEX ) ); - try - { - active.GetPropertyType( PROPERTY_REGISTRATION_START_INDEX ); - tet_result( TET_FAIL ); - } - catch ( DaliException& e ) - { - DALI_TEST_ASSERT_CONDITION_STARTS_WITH_SUBSTRING( e, "! \"Cannot find property index", TEST_LOCATION ); - } - try - { - active.SetProperty( PROPERTY_REGISTRATION_START_INDEX, true ); - tet_result( TET_FAIL ); - } - catch ( DaliException& e ) - { - DALI_TEST_ASSERT_CONDITION_STARTS_WITH_SUBSTRING( e, "! \"Cannot find property index", TEST_LOCATION ); - } - try - { - active.GetProperty< bool >( PROPERTY_REGISTRATION_START_INDEX ); - tet_result( TET_FAIL ); - } - catch ( DaliException& e ) - { - DALI_TEST_ASSERT_CONDITION_STARTS_WITH_SUBSTRING( e, "! \"Cannot find property index", TEST_LOCATION ); - } -} diff --git a/automated-tests/TET/dali-test-suite/animation/utc-Dali-AlphaFunctions.cpp b/automated-tests/TET/dali-test-suite/animation/utc-Dali-AlphaFunctions.cpp deleted file mode 100644 index bcf95de..0000000 --- a/automated-tests/TET/dali-test-suite/animation/utc-Dali-AlphaFunctions.cpp +++ /dev/null @@ -1,391 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( UtcDaliAlphaFunctionsDefault, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAlphaFunctionsLinear, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAlphaFunctionsReverse, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAlphaFunctionsEaseIn, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAlphaFunctionsEaseOut, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAlphaFunctionsEaseInOut, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAlphaFunctionsEaseInSine, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAlphaFunctionsEaseOutSine, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAlphaFunctionsEaseInOutSine, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAlphaFunctionsEaseInSine33, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAlphaFunctionsEaseOutSine33, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAlphaFunctionsEaseInOutSineXX, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAlphaFunctionsDoubleEaseInOutSine60, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAlphaFunctionsEaseOutQuint50, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAlphaFunctionsEaseOutQuint80, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAlphaFunctionsBounce, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAlphaFunctionsBounceBack, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAlphaFunctionsEaseOutBack, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAlphaFunctionsSin, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAlphaFunctionsSin2x, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAlphaFunctionsSquare, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAlphaFunctionsEaseInBack, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAlphaFunctionsEaseInOutBack, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -// Positive test case for a method -static void UtcDaliAlphaFunctionsDefault() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliAlphaFunctionsLinear() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliAlphaFunctionsReverse() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliAlphaFunctionsEaseIn() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliAlphaFunctionsEaseOut() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliAlphaFunctionsEaseInOut() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliAlphaFunctionsEaseInSine() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliAlphaFunctionsEaseOutSine() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliAlphaFunctionsEaseInOutSine() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliAlphaFunctionsBounce() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliAlphaFunctionsBounceBack() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliAlphaFunctionsEaseOutBack() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliAlphaFunctionsSin() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliAlphaFunctionsSin2x() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliAlphaFunctionsSquare() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliAlphaFunctionsEaseInSine33() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliAlphaFunctionsEaseOutSine33() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliAlphaFunctionsEaseInOutSineXX() -{ - 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); - } -} - -// Positive test case for a method -static void UtcDaliAlphaFunctionsDoubleEaseInOutSine60() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliAlphaFunctionsEaseOutQuint50() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliAlphaFunctionsEaseOutQuint80() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliAlphaFunctionsEaseInBack() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliAlphaFunctionsEaseInOutBack() -{ - 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); -} diff --git a/automated-tests/TET/dali-test-suite/animation/utc-Dali-Animation.cpp b/automated-tests/TET/dali-test-suite/animation/utc-Dali-Animation.cpp deleted file mode 100644 index ca98409..0000000 --- a/automated-tests/TET/dali-test-suite/animation/utc-Dali-Animation.cpp +++ /dev/null @@ -1,8786 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -static const float ROTATION_EPSILON = 0.0001f; -static const float VECTOR4_EPSILON = 0.0001f; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( UtcDaliAnimationNew01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationNew02, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationSetDuration, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationGetDuration, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationSetLooping, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationIsLooping, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationSetEndAction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationGetEndAction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationSetDefaultAlphaFunction, POSITIVE_TC_IDX ); // 10 -TEST_FUNCTION( UtcDaliAnimationGetDefaultAlphaFunction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationPlay, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationPlayOffStage, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationPlayDiscardHandle, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationPlayStopDiscardHandle, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationPause, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationStop, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationStopSetPosition, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationClear, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationSignalFinish, POSITIVE_TC_IDX ); // 20 -TEST_FUNCTION( UtcDaliAnimationAnimateByBoolean, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateByBooleanAlphaFunction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateByBooleanTimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateByFloat, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateByFloatAlphaFunction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateByFloatTimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateByVector2, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateByVector2AlphaFunction, POSITIVE_TC_IDX ); // 30 -TEST_FUNCTION( UtcDaliAnimationAnimateByVector2TimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateByVector3, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateByVector3AlphaFunction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateByVector3TimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateByVector4, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateByVector4AlphaFunction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateByVector4TimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriod, POSITIVE_TC_IDX ); // 40 -TEST_FUNCTION( UtcDaliAnimationAnimateByActorPosition, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateByActorPositionAlphaFunction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateByActorPositionTimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToBoolean, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToBooleanAlphaFunction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToBooleanTimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToFloat, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToFloatAlphaFunction, POSITIVE_TC_IDX ); // 50 -TEST_FUNCTION( UtcDaliAnimationAnimateToFloatTimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToVector2, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToVector2AlphaFunction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToVector2TimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToVector3, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToVector3AlphaFunction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToVector3TimePeriod, POSITIVE_TC_IDX ); // 60 -TEST_FUNCTION( UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToVector4, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToVector4AlphaFunction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToVector4TimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorParentOrigin, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorParentOriginX, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorParentOriginY, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorParentOriginZ, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorAnchorPoint, POSITIVE_TC_IDX ); // 70 -TEST_FUNCTION( UtcDaliAnimationAnimateToActorAnchorPointX, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorAnchorPointY, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorAnchorPointZ, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorSize, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorSizeWidth, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorSizeHeight, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorSizeDepth, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorPosition, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorPositionX, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorPositionY, POSITIVE_TC_IDX ); // 80 -TEST_FUNCTION( UtcDaliAnimationAnimateToActorPositionZ, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorPositionAlphaFunction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorPositionTimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorRotationAngleAxis, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorRotationQuaternion, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorRotationAlphaFunction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorRotationTimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorRotationAlphaFunctionTimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorScale, POSITIVE_TC_IDX ); // 90 -TEST_FUNCTION( UtcDaliAnimationAnimateToActorScaleX, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorScaleY, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorScaleZ, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorColor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorColorRed, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorColorGreen, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorColorBlue, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateToActorColorAlpha, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationKeyFrames01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationKeyFrames02, POSITIVE_TC_IDX ); // 100 -TEST_FUNCTION( UtcDaliAnimationKeyFrames03, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationKeyFrames04, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationKeyFrames05, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationKeyFrames06, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateBetweenActorColorAlpha, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateBetweenActorColor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateBetweenActorRotation01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateBetweenActorRotation02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateBetweenActorVisible01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateBool, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateFloat, POSITIVE_TC_IDX ); // 110 -TEST_FUNCTION( UtcDaliAnimationAnimateVector2, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateVector3, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateVector4, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateQuaternion, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationMoveByFloat3, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationMoveByVector3Alpha, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationMoveByVector3AlphaFloat2, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationMoveToFloat3, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationMoveToVector3Alpha, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationMoveToVector3AlphaFloat2, POSITIVE_TC_IDX ); // 120 -TEST_FUNCTION( UtcDaliAnimationMove, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationRotateByDegreeVector3, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationRotateByRadianVector3, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationRotateByDegreeVector3Alpha, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationRotateByRadianVector3Alpha, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationRotateByDegreeVector3AlphaFloat2, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationRotateByRadianVector3AlphaFloat2, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationRotateToDegreeVector3, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationRotateToRadianVector3, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationRotateToQuaternion, POSITIVE_TC_IDX ); // 130 -TEST_FUNCTION( UtcDaliAnimationRotateToDegreeVector3Alpha, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationRotateToRadianVector3Alpha, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationRotateToQuaternionAlpha, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationRotateToDegreeVector3AlphaFloat2, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationRotateToRadianVector3AlphaFloat2, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationRotateToQuaternionAlphaFloat2, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationRotate, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationScaleBy, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationScaleTo, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationShow, POSITIVE_TC_IDX ); // 140 -TEST_FUNCTION( UtcDaliAnimationHide, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationShowHideAtEnd, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationOpacityBy, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationOpacityTo, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationColorBy, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationColorTo, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationResize, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliKeyFramesCreateDestroy, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliKeyFramesDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationGetDestroyAction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationResizeByXY, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateBetweenActorColorTimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateBetweenActorColorFunction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateBetweenActorColorFunctionTimePeriod, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationAnimateVector3Func, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimationCreateDestroy, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -// 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; -}; - -static void UtcDaliAnimationNew01() -{ - TestApplication application; - - Animation animation; - DALI_TEST_CHECK(!animation); - - animation = Animation::New(1.0f); - - DALI_TEST_CHECK(animation); -} - -static void UtcDaliAnimationNew02() -{ - 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); - } -} - -static void UtcDaliAnimationDownCast() -{ - 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); -} - -static void UtcDaliAnimationSetDuration() -{ - 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 ); -} - -static void UtcDaliAnimationGetDuration() -{ - 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); -} - -static void UtcDaliAnimationSetLooping() -{ - 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 ); -} - -static void UtcDaliAnimationIsLooping() -{ - TestApplication application; - - Animation animation = Animation::New(1.0f); - DALI_TEST_CHECK(!animation.IsLooping()); - - animation.SetLooping(true); - DALI_TEST_CHECK(animation.IsLooping()); -} - -static void UtcDaliAnimationSetEndAction() -{ - 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 ); -} - -static void UtcDaliAnimationGetEndAction() -{ - 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); -} - -static void UtcDaliAnimationGetDestroyAction() -{ - 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); - -} - -static void UtcDaliAnimationSetDefaultAlphaFunction() -{ - 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 -} - -static void UtcDaliAnimationGetDefaultAlphaFunction() -{ - 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); -} - -static void UtcDaliAnimationPlay() -{ - 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 ); -} - -static void UtcDaliAnimationPlayOffStage() -{ - // 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 ); -} - -static void UtcDaliAnimationPlayDiscardHandle() -{ - 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 ); -} - -static void UtcDaliAnimationPlayStopDiscardHandle() -{ - 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 ); -} - -static void UtcDaliAnimationPause() -{ - 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 ); -} - -static void UtcDaliAnimationStop() -{ - 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 ); - } -} - -static void UtcDaliAnimationStopSetPosition() -{ - // 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 ); - } -} - -static void UtcDaliAnimationClear() -{ - 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 ); -} - -static void UtcDaliAnimationSignalFinish() -{ - 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(); -} - -static void UtcDaliAnimationAnimateByBoolean() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateByBooleanAlphaFunction() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateByBooleanTimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateByFloat() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateByFloatAlphaFunction() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateByFloatTimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateByVector2() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateByVector2AlphaFunction() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateByVector2TimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateByVector3() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateByVector3AlphaFunction() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateByVector3TimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateByVector4() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateByVector4AlphaFunction() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateByVector4TimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateByActorPosition() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateByActorPositionAlphaFunction() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateByActorPositionTimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToBoolean() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToBooleanAlphaFunction() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToBooleanTimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToFloat() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToFloatAlphaFunction() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToFloatTimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToVector2() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToVector2AlphaFunction() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToVector2TimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToVector3() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToVector3AlphaFunction() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToVector3TimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToVector4() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToVector4AlphaFunction() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToVector4TimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorParentOrigin() -{ - 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); - } -} - -static void UtcDaliAnimationAnimateToActorParentOriginX() -{ - 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); - } -} - -static void UtcDaliAnimationAnimateToActorParentOriginY() -{ - 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); - } -} - -static void UtcDaliAnimationAnimateToActorParentOriginZ() -{ - 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); - } -} - -static void UtcDaliAnimationAnimateToActorAnchorPoint() -{ - 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); - } -} - -static void UtcDaliAnimationAnimateToActorAnchorPointX() -{ - 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); - } -} - -static void UtcDaliAnimationAnimateToActorAnchorPointY() -{ - 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); - } -} - -static void UtcDaliAnimationAnimateToActorAnchorPointZ() -{ - 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); - } -} - -static void UtcDaliAnimationAnimateToActorSize() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorSizeWidth() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorSizeHeight() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorSizeDepth() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorPosition() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorPositionX() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorPositionY() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorPositionZ() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorPositionAlphaFunction() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorPositionTimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorRotationAngleAxis() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorRotationQuaternion() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorRotationAlphaFunction() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorRotationTimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorRotationAlphaFunctionTimePeriod() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorScale() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorScaleX() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorScaleY() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorScaleZ() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorColor() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorColorRed() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorColorGreen() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorColorBlue() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateToActorColorAlpha() -{ - 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 ); -} - - - -static void UtcDaliAnimationKeyFrames01() -{ - 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); - } -} - -static void UtcDaliAnimationKeyFrames02() -{ - 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); - } -} - - -static void UtcDaliAnimationKeyFrames03() -{ - 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); - } -} - - -static void UtcDaliAnimationKeyFrames04() -{ - 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); - } -} - -static void UtcDaliAnimationKeyFrames05() -{ - 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); - } -} - - -static void UtcDaliAnimationKeyFrames06() -{ - 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); - } -} - - - - - -static void UtcDaliAnimationAnimateBetweenActorColorAlpha() -{ - 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(); -} - - -static void UtcDaliAnimationAnimateBetweenActorColor() -{ - 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(); -} - -static void UtcDaliAnimationAnimateBetweenActorVisible01() -{ - 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(); -} - -static void UtcDaliAnimationAnimateBetweenActorRotation01() -{ - 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(); -} - - -static void UtcDaliAnimationAnimateBetweenActorRotation02() -{ - 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(); -} - -static void UtcDaliAnimationMoveByFloat3() -{ - 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 ); -} - -static void UtcDaliAnimationMoveByVector3Alpha() -{ - 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 ); -} - -static void UtcDaliAnimationMoveByVector3AlphaFloat2() -{ - 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 ); -} - -static void UtcDaliAnimationMoveToFloat3() -{ - 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 ); -} - -static void UtcDaliAnimationMoveToVector3Alpha() -{ - 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 ); -} - -static void UtcDaliAnimationMoveToVector3AlphaFloat2() -{ - 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 ); -} - -static void UtcDaliAnimationMove() -{ - 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); - AnimatorFunctions::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 ); -} - -static void UtcDaliAnimationRotateByDegreeVector3() -{ - 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 ); -} - -static void UtcDaliAnimationRotateByRadianVector3() -{ - 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 ); -} - -static void UtcDaliAnimationRotateByDegreeVector3Alpha() -{ - 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 ); -} - -static void UtcDaliAnimationRotateByRadianVector3Alpha() -{ - 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 ); -} - -static void UtcDaliAnimationRotateByDegreeVector3AlphaFloat2() -{ - 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 ); -} - - -static void UtcDaliAnimationRotateByRadianVector3AlphaFloat2() -{ - 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 ); -} - -static void UtcDaliAnimationRotateToDegreeVector3() -{ - 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 ); -} - -static void UtcDaliAnimationRotateToRadianVector3() -{ - 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 ); -} - -static void UtcDaliAnimationRotateToQuaternion() -{ - 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 ); -} - -static void UtcDaliAnimationRotateToDegreeVector3Alpha() -{ - 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 ); -} - -static void UtcDaliAnimationRotateToRadianVector3Alpha() -{ - 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 ); -} - -static void UtcDaliAnimationRotateToQuaternionAlpha() -{ - 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 ); -} - -static void UtcDaliAnimationRotateToDegreeVector3AlphaFloat2() -{ - 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 ); -} - -static void UtcDaliAnimationRotateToRadianVector3AlphaFloat2() -{ - 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 ); -} - -static void UtcDaliAnimationRotateToQuaternionAlphaFloat2() -{ - 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 ); -} - -static void UtcDaliAnimationRotate() -{ - 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); - AnimatorFunctions::TumbleFunc func(AnimatorFunctions::TumbleFunc::GetRandom()); - 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 ); -} - -static void UtcDaliAnimationScaleBy() -{ - 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 ); -} - -static void UtcDaliAnimationScaleTo() -{ - 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 ); -} - -static void UtcDaliAnimationShow() -{ - 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() ); -} - -static void UtcDaliAnimationHide() -{ - 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() ); -} - -static void UtcDaliAnimationShowHideAtEnd() -{ - // 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() ); -} - -static void UtcDaliAnimationOpacityBy() -{ - 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 ); -} - -static void UtcDaliAnimationOpacityTo() -{ - 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 ); -} - -static void UtcDaliAnimationColorBy() -{ - 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 ); -} - -static void UtcDaliAnimationColorTo() -{ - 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 ); -} - -static void UtcDaliAnimationResize() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateBool() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateFloat() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateVector2() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateVector3() -{ - 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); - AnimatorFunctions::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 ); -} - -static void UtcDaliAnimationAnimateVector4() -{ - 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 ); -} - -static void UtcDaliAnimationAnimateQuaternion() -{ - 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 ); -} - -static void UtcDaliKeyFramesCreateDestroy() -{ - tet_infoline("Testing Dali::Animation::UtcDaliKeyFramesCreateDestroy()"); - - KeyFrames* keyFrames = new KeyFrames; - delete keyFrames; - DALI_TEST_CHECK( true ); -} - -static void UtcDaliKeyFramesDownCast() -{ - 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); -} - -static void UtcDaliAnimationResizeByXY() -{ - 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 ); -} - - -static void UtcDaliAnimationAnimateBetweenActorColorTimePeriod() -{ - 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(); -} - -static void UtcDaliAnimationAnimateBetweenActorColorFunction() -{ - 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(); -} - -static void UtcDaliAnimationAnimateBetweenActorColorFunctionTimePeriod() -{ - 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(); -} - -static void UtcDaliAnimationAnimateVector3Func() -{ - 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); - AnimatorFunctions::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 ); -} - -static void UtcDaliAnimationCreateDestroy() -{ - TestApplication application; - Animation* animation = new Animation; - DALI_TEST_CHECK( animation ); - delete animation; -} diff --git a/automated-tests/TET/dali-test-suite/animation/utc-Dali-Constraint.cpp b/automated-tests/TET/dali-test-suite/animation/utc-Dali-Constraint.cpp deleted file mode 100644 index ed52316..0000000 --- a/automated-tests/TET/dali-test-suite/animation/utc-Dali-Constraint.cpp +++ /dev/null @@ -1,4038 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliConstraintNewBoolean, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintNewFloat, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintNewVector2, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintNewVector3, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintNewVector4, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintNewQuaternion, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintNewMatrix, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintNewMatrix3, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintNewOffStageBoolean, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintNewOffStageFloat, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintNewOffStageVector2, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintNewOffStageVector3, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintNewOffStageVector4, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintNewOffStageQuaternion, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintNewLocalInput, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintNewParentInput, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintNewInput1, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintNewInput2, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintNewInput3, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintNewInput4, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintNewInput5, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintNewInput6, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintSetApplyTime, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintGetApplyTime, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintSetRemoveTime, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintGetRemoveTime, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintSetAlphaFunction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintGetAlphaFunction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintSetRemoveAction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintGetRemoveAction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintRemoveDuringApply, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintImmediateRemoveDuringApply, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintActorSize, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintActorSizeWidth, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintActorSizeHeight, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintActorSizeDepth, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintInputWorldPosition, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintInputWorldRotation, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintInputWorldScale, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintInputWorldColor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliConstraintInvalidInputProperty, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliBuiltinConstraintParentSize, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliBuiltinConstraintParentSizeRelative, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliBuiltinConstraintScaleToFitConstraint, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliBuiltinConstraintScaleToFitKeepAspectRatio, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliBuiltinConstraintScaleToFillKeepAspectRatio, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliBuiltinConstraintScaleToFillXYKeepAspectRatio, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliBuiltinConstraintShrinkInsideKeepAspectRatioConstraint, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliBuiltinConstraintMultiplyConstraint, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliBuiltinConstraintDivideConstraint, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliBuiltinConstraintEqualToConstraint, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliBuiltinConstraintRelativeToConstraint, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliBuiltinConstraintInverseOfConstraint, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliBuiltinConstraintFunctions, POSITIVE_TC_IDX ); - -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; -}; - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -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; -}; - -static void UtcDaliConstraintNewBoolean() -{ - 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 ); -} - -static void UtcDaliConstraintNewFloat() -{ - 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 ); -} - -static void UtcDaliConstraintNewVector2() -{ - 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 ); -} - -static void UtcDaliConstraintNewVector3() -{ - 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 ); -} - -static void UtcDaliConstraintNewVector4() -{ - 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 ); -} - -static void UtcDaliConstraintNewMatrix() -{ - 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_EQUALS(e.mCondition, "segmentIndex+1 < mKnots.size() && segmentIndex < mKnots.size()", TEST_LOCATION); - } -} - -static void UtcDaliConstraintNewMatrix3() -{ - 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, 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_EQUALS(e.mCondition, "UtcDaliConstraintNewMatrix3", TEST_LOCATION); - } -} - -static void UtcDaliConstraintNewQuaternion() -{ - 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 ); -} - -static void UtcDaliConstraintNewOffStageBoolean() -{ - 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 ); -} - -static void UtcDaliConstraintNewOffStageFloat() -{ - 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 ); -} - -static void UtcDaliConstraintNewOffStageVector2() -{ - 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 ); -} - -static void UtcDaliConstraintNewOffStageVector3() -{ - 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 ); - DALI_TEST_CHECK( actor.GetProperty(index) == startValue ); - - // Apply constraint to off-stage Actor - Vector3 constrainedValue( 2.0f, 2.0f, 2.0f ); - 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(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 ); -} - -static void UtcDaliConstraintNewOffStageVector4() -{ - 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 ); -} - -static void UtcDaliConstraintNewOffStageQuaternion() -{ - 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 ); -} - -static void UtcDaliConstraintNewLocalInput() -{ - 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 ); -} - -static void UtcDaliConstraintNewParentInput() -{ - 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 ); -} - -static void UtcDaliConstraintNewInput1() -{ - 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 ); -} - -static void UtcDaliConstraintNewInput2() -{ - 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 ); -} - -static void UtcDaliConstraintNewInput3() -{ - 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 ); -} - -static void UtcDaliConstraintNewInput4() -{ - 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 ); -} - -static void UtcDaliConstraintNewInput5() -{ - 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 ); -} - -static void UtcDaliConstraintNewInput6() -{ - 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 ); -} - -static void UtcDaliConstraintDownCast() -{ - 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); -} - -static void UtcDaliConstraintSetApplyTime() -{ - 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 ); -} - -static void UtcDaliConstraintGetApplyTime() -{ - 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); -} - -static void UtcDaliConstraintSetRemoveTime() -{ - 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 ); -} - -static void UtcDaliConstraintGetRemoveTime() -{ - TestApplication application; - - Constraint constraint = Constraint::New( Actor::COLOR, TestConstraint() ); - DALI_TEST_EQUALS(constraint.GetRemoveTime(), TimePeriod(0.0f), TEST_LOCATION); -} - -static void UtcDaliConstraintSetAlphaFunction() -{ - 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 ); -} - -static void UtcDaliConstraintGetAlphaFunction() -{ - 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 -} - -static void UtcDaliConstraintSetRemoveAction() -{ - 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 ); -} - -static void UtcDaliConstraintGetRemoveAction() -{ - 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); -} - -/** - * Test a constraint with non-zero apply-time and remove-time, where the constraint is removed during the apply-time - */ -static void UtcDaliConstraintRemoveDuringApply() -{ - 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 ); -} - -/** - * Test a constraint with non-zero apply-time & zero (immediate) remove-time, where the constraint is removed during the apply-time - */ -static void UtcDaliConstraintImmediateRemoveDuringApply() -{ - 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 ); -} - -static void UtcDaliConstraintActorSize() -{ - 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 ); -} - -static void UtcDaliConstraintActorSizeWidth() -{ - 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 ); -} - -static void UtcDaliConstraintActorSizeHeight() -{ - 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 ); -} - -static void UtcDaliConstraintActorSizeDepth() -{ - 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 ); -} - -static void UtcDaliConstraintInputWorldPosition() -{ - 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 ); -} - -static void UtcDaliConstraintInputWorldRotation() -{ - 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 ); -} - -static void UtcDaliConstraintInputWorldScale() -{ - 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 ); -} - -static void UtcDaliConstraintInputWorldColor() -{ - 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 ); -} - -void UtcDaliConstraintInvalidInputProperty() -{ - 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 ); - } -} - -static void UtcDaliBuiltinConstraintParentSize() -{ - 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 ); -} - -static void UtcDaliBuiltinConstraintParentSizeRelative() -{ - 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 ); -} - -static void UtcDaliBuiltinConstraintScaleToFitConstraint() -{ - 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 ); -} - -static void UtcDaliBuiltinConstraintScaleToFitKeepAspectRatio() -{ - 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 ); -} - -static void UtcDaliBuiltinConstraintScaleToFillKeepAspectRatio() -{ - 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 ); -} - -static void UtcDaliBuiltinConstraintScaleToFillXYKeepAspectRatio() -{ - 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 ); -} - -static void UtcDaliBuiltinConstraintShrinkInsideKeepAspectRatioConstraint() -{ - 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 ); -} - -static void UtcDaliBuiltinConstraintMultiplyConstraint() -{ - 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 ); -} - -static void UtcDaliBuiltinConstraintDivideConstraint() -{ - 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 ); -} - -static void UtcDaliBuiltinConstraintEqualToConstraint() -{ - 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); -} - -static void UtcDaliBuiltinConstraintRelativeToConstraint() -{ - 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 ); -} - -static void UtcDaliBuiltinConstraintInverseOfConstraint() -{ - 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 ); -} - -static void UtcDaliBuiltinConstraintFunctions() -{ - 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 ); - } - } - -} diff --git a/automated-tests/TET/dali-test-suite/common/.gitignore b/automated-tests/TET/dali-test-suite/common/.gitignore deleted file mode 100644 index 1766cee..0000000 --- a/automated-tests/TET/dali-test-suite/common/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -utc-Dali-LocklessBuffer -utc-Dali-Vector -utc-Dali-Any diff --git a/automated-tests/TET/dali-test-suite/common/Makefile b/automated-tests/TET/dali-test-suite/common/Makefile deleted file mode 120000 index c88d5a7..0000000 --- a/automated-tests/TET/dali-test-suite/common/Makefile +++ /dev/null @@ -1 +0,0 @@ -../master-makefile.mk \ No newline at end of file diff --git a/automated-tests/TET/dali-test-suite/common/file.list b/automated-tests/TET/dali-test-suite/common/file.list deleted file mode 100644 index b5ebacf..0000000 --- a/automated-tests/TET/dali-test-suite/common/file.list +++ /dev/null @@ -1,4 +0,0 @@ -TARGETS += \ - utc-Dali-LocklessBuffer \ - utc-Dali-Vector \ - utc-Dali-Any \ diff --git a/automated-tests/TET/dali-test-suite/common/tc-gen.sh b/automated-tests/TET/dali-test-suite/common/tc-gen.sh deleted file mode 100755 index 178f24d..0000000 --- a/automated-tests/TET/dali-test-suite/common/tc-gen.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh - -TMPSTR=$0 -SCRIPT=${TMPSTR##*/} - -if [ $# -ne 1 ]; then - echo "Usage) $SCRIPT ClassName" - exit 1 -fi - -MODULE="Dali" -SECTION=${PWD##*/} -CLASS=$1 - -TESTSUITEPATH=`dirname $PWD` -TESTSUITENAME=${TESTSUITEPATH##*/} - -TEMPLATE=../utc-MODULE-CLASS.cpp.in -TESTCASE=utc-${MODULE}-${CLASS} - -# Create .cpp file -if [ ! -e "$TESTCASE.cpp" ]; then - sed -e ' - s^@CLASS@^'"$CLASS"'^g - s^@MODULE@^'"$MODULE"'^g - ' $TEMPLATE > $TESTCASE.cpp -fi - -if [ ! -e "$TESTCASE.cpp" ]; then - echo "Failed" - exit 1 -fi - - -# file.list -if ! [ -f file.list ]; then - touch file.list - echo "TARGETS += \\" >> file.list -fi -echo " $TESTCASE \\" >> file.list - -# tslist -if ! [ -f tslist ]; then - touch tslist -fi -echo "/$TESTSUITENAME/$SECTION/$TESTCASE" >> tslist - -# Makefile -if ! [ -f Makefile ]; then - ln -s ../master-makefile.mk Makefile -fi - -echo "$TESTCASE" >> .gitignore - -echo "Testcase file is $TESTCASE.cpp" -echo "$TESTCASE is added to tslist" -echo "$TESTCASE is added to file.list" -echo "Done" diff --git a/automated-tests/TET/dali-test-suite/common/tslist b/automated-tests/TET/dali-test-suite/common/tslist deleted file mode 100644 index 81d0d6d..0000000 --- a/automated-tests/TET/dali-test-suite/common/tslist +++ /dev/null @@ -1,3 +0,0 @@ -/dali-test-suite/common/utc-Dali-LocklessBuffer -/dali-test-suite/common/utc-Dali-Vector -/dali-test-suite/common/utc-Dali-Any diff --git a/automated-tests/TET/dali-test-suite/common/utc-Dali-Any.cpp b/automated-tests/TET/dali-test-suite/common/utc-Dali-Any.cpp deleted file mode 100644 index b5d7442..0000000 --- a/automated-tests/TET/dali-test-suite/common/utc-Dali-Any.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( UtcDaliAnyConstructors, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnyAssignmentOperators, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnyNegativeAssignmentOperators, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnyGetType, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnyGet, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnyNegativeGet, NEGATIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -static void UtcDaliAnyConstructors() -{ - 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 ); -} - -static void UtcDaliAnyAssignmentOperators() -{ - 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 ); -} - -static void UtcDaliAnyNegativeAssignmentOperators() -{ - 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 ); - } -} - -static void UtcDaliAnyGetType() -{ - 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() ); -} - -static void UtcDaliAnyGet() -{ - 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 ); -} - -static void UtcDaliAnyNegativeGet() -{ - 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 -} - diff --git a/automated-tests/TET/dali-test-suite/common/utc-Dali-LocklessBuffer.cpp b/automated-tests/TET/dali-test-suite/common/utc-Dali-LocklessBuffer.cpp deleted file mode 100644 index 4acca0e..0000000 --- a/automated-tests/TET/dali-test-suite/common/utc-Dali-LocklessBuffer.cpp +++ /dev/null @@ -1,144 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( UtcDaliLocklessBufferWriteRead01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLocklessBufferMultipleWrites01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLocklessBufferGetSize01, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -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 - -#include - -using namespace Dali; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( UtcDaliEmptyVectorInt, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVectorInt, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVectorIntCopy, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVectorIntResize, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVectorIntErase, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVectorDoubleRemove, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVectorIntSwap, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVectorIterate, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVectorPair, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVectorAsserts, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVectorAcidTest, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVectorComplex, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -const Dali::VectorBase::SizeType ZERO(0); - -static void UtcDaliEmptyVectorInt() -{ - 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 ); -} - -static void UtcDaliVectorInt() -{ - 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 ); -} - -static void UtcDaliVectorIntCopy() -{ - 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 ); -} - -static void UtcDaliVectorIntResize() -{ - 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 ); -} - -static void UtcDaliVectorIntErase() -{ - 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 ); -} - - -static void UtcDaliVectorDoubleRemove() -{ - 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); - } - -} - -static void UtcDaliVectorIntSwap() -{ - 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 ); -} - -static void UtcDaliVectorIterate() -{ - 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 ); -} - -static void UtcDaliVectorPair() -{ - 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 ); - } -} - -static void UtcDaliVectorAsserts() -{ - 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); - } - -} - -static void UtcDaliVectorAcidTest() -{ - 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 ); - -} - - -bool gConstructorCalled = false; -bool gDestructorCalled = false; - -struct ComplexType -{ - ComplexType() - { - gConstructorCalled = true; - } - ~ComplexType() - { - gDestructorCalled = true; - } -}; - -static void UtcDaliVectorComplex() -{ - 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 -} diff --git a/automated-tests/TET/dali-test-suite/context/.gitignore b/automated-tests/TET/dali-test-suite/context/.gitignore deleted file mode 100644 index 45dc619..0000000 --- a/automated-tests/TET/dali-test-suite/context/.gitignore +++ /dev/null @@ -1 +0,0 @@ -utc-Dali-Context diff --git a/automated-tests/TET/dali-test-suite/context/Makefile b/automated-tests/TET/dali-test-suite/context/Makefile deleted file mode 120000 index c88d5a7..0000000 --- a/automated-tests/TET/dali-test-suite/context/Makefile +++ /dev/null @@ -1 +0,0 @@ -../master-makefile.mk \ No newline at end of file diff --git a/automated-tests/TET/dali-test-suite/context/file.list b/automated-tests/TET/dali-test-suite/context/file.list deleted file mode 100644 index 65a5f87..0000000 --- a/automated-tests/TET/dali-test-suite/context/file.list +++ /dev/null @@ -1,2 +0,0 @@ -TARGETS += \ - utc-Dali-Context \ diff --git a/automated-tests/TET/dali-test-suite/context/tslist b/automated-tests/TET/dali-test-suite/context/tslist deleted file mode 100644 index 7f411e8..0000000 --- a/automated-tests/TET/dali-test-suite/context/tslist +++ /dev/null @@ -1 +0,0 @@ -/dali-test-suite/context/utc-Dali-Context diff --git a/automated-tests/TET/dali-test-suite/context/utc-Dali-Context.cpp b/automated-tests/TET/dali-test-suite/context/utc-Dali-Context.cpp deleted file mode 100644 index b4272cf..0000000 --- a/automated-tests/TET/dali-test-suite/context/utc-Dali-Context.cpp +++ /dev/null @@ -1,274 +0,0 @@ -// -// 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 - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void UtcDaliContextVertexAttribStartup(); -static void UtcDaliContextVertexAttribImageRendering(); -static void UtcDaliContextVertexAttribImageAndModelRendering(); - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -// Add test functionality for all APIs in the class (Positive and Negative) -extern "C" { - struct tet_testlist tet_testlist[] = { - { UtcDaliContextVertexAttribStartup, POSITIVE_TC_IDX }, - { UtcDaliContextVertexAttribImageRendering, POSITIVE_TC_IDX}, - { UtcDaliContextVertexAttribImageAndModelRendering, POSITIVE_TC_IDX}, - { NULL, 0 } - }; -} - -// Called only once before first test is run. -static void Startup() -{ -} -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 -}; - -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -// 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; -} - -// Positive test case for a method -static void UtcDaliContextVertexAttribStartup() -{ - 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); -} - -// Tests to make the attribs only get set once when continually rendering an image actor -static void UtcDaliContextVertexAttribImageRendering() -{ - 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); -} - -// test to make sure the attribs change when rendering both image and mode actors -static void UtcDaliContextVertexAttribImageAndModelRendering() -{ - 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); - -} diff --git a/automated-tests/TET/dali-test-suite/dynamics/.gitignore b/automated-tests/TET/dali-test-suite/dynamics/.gitignore deleted file mode 100644 index fb8bfb0..0000000 --- a/automated-tests/TET/dali-test-suite/dynamics/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -utc-Dali-DynamicsBody -utc-Dali-DynamicsBodyConfig -utc-Dali-DynamicsJoint -utc-Dali-DynamicsShape -utc-Dali-DynamicsWorld -utc-Dali-DynamicsWorldConfig diff --git a/automated-tests/TET/dali-test-suite/dynamics/Makefile b/automated-tests/TET/dali-test-suite/dynamics/Makefile deleted file mode 100644 index 607c176..0000000 --- a/automated-tests/TET/dali-test-suite/dynamics/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -# -# 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. -# - -CC = g++ - -TARGETS = -include file.list - -PKGS = dali-core -include ../../rules.mk -include ../../coverage.mk - -all: $(TARGETS) - -%: %.cpp - $(CC) -o $@ $< $(CXXFLAGS) $(LDFLAGS) - -clean: - @rm -f $(notdir $(TARGETS)) - @rm -f tet_captured - @rm -f *~ - @rm -f *.gcda *.gcno - -coverage: - @lcov --directory . -c -o dali.info - @lcov -remove dali.info "*boost*" "/usr/include/*" "*/automated-tests/*" -o dali.info diff --git a/automated-tests/TET/dali-test-suite/dynamics/file.list b/automated-tests/TET/dali-test-suite/dynamics/file.list deleted file mode 100644 index 5648c89..0000000 --- a/automated-tests/TET/dali-test-suite/dynamics/file.list +++ /dev/null @@ -1,7 +0,0 @@ -TARGETS += \ - utc-Dali-DynamicsBody \ - utc-Dali-DynamicsBodyConfig \ - utc-Dali-DynamicsJoint \ - utc-Dali-DynamicsShape \ - utc-Dali-DynamicsWorld \ - utc-Dali-DynamicsWorldConfig diff --git a/automated-tests/TET/dali-test-suite/dynamics/tslist b/automated-tests/TET/dali-test-suite/dynamics/tslist deleted file mode 100644 index e4a8125..0000000 --- a/automated-tests/TET/dali-test-suite/dynamics/tslist +++ /dev/null @@ -1,6 +0,0 @@ -/dali-test-suite/dynamics/utc-Dali-DynamicsBody -/dali-test-suite/dynamics/utc-Dali-DynamicsBodyConfig -/dali-test-suite/dynamics/utc-Dali-DynamicsJoint -/dali-test-suite/dynamics/utc-Dali-DynamicsShape -/dali-test-suite/dynamics/utc-Dali-DynamicsWorld -/dali-test-suite/dynamics/utc-Dali-DynamicsWorldConfig diff --git a/automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsBody.cpp b/automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsBody.cpp deleted file mode 100644 index f772299..0000000 --- a/automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsBody.cpp +++ /dev/null @@ -1,564 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void UtcDaliDynamicsBodyConstructor(); -static void UtcDaliDynamicsBodyGetMass(); -static void UtcDaliDynamicsBodyGetElasticity(); -static void UtcDaliDynamicsBodySetLinearVelocity(); -static void UtcDaliDynamicsBodySetAngularVelocity(); -static void UtcDaliDynamicsBodySetKinematic(); -static void UtcDaliDynamicsBodyIsKinematic(); -static void UtcDaliDynamicsBodySetSleepEnabled(); -static void UtcDaliDynamicsBodyGetSleepEnabled(); -static void UtcDaliDynamicsBodyWakeUp(); -static void UtcDaliDynamicsBodyAddAnchor(); -static void UtcDaliDynamicsBodyConserveVolume(); -static void UtcDaliDynamicsBodyConserveShape(); - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -// Add test functionality for all APIs in the class (Positive and Negative) -extern "C" { - struct tet_testlist tet_testlist[] = - { - { UtcDaliDynamicsBodyConstructor, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyGetMass, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyGetElasticity, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodySetLinearVelocity, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodySetAngularVelocity, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodySetKinematic, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyIsKinematic, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodySetSleepEnabled, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyGetSleepEnabled, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyWakeUp, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyAddAnchor, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyConserveVolume, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyConserveShape, POSITIVE_TC_IDX }, - { NULL, 0 } - }; -} - -// Called only once before first test is run. -void Startup() -{ -} - -// Called only once after last test is run -void Cleanup() -{ -} - -void UtcDaliDynamicsBodyConstructor() -{ - 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 ); - return; - } - - 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 ); -} - -void UtcDaliDynamicsBodyGetMass() -{ - 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 ); - return; - } - - 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 ); -} - -void UtcDaliDynamicsBodyGetElasticity() -{ - 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 ); - return; - } - - 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 ); -} - -void UtcDaliDynamicsBodySetLinearVelocity() -{ - tet_infoline("UtcDaliDynamicsBodySetLinearVelocity - DynamicsBody::SetLinearVelocity"); - - 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 ); - return; - } - - 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( true ); -} - -void UtcDaliDynamicsBodySetAngularVelocity() -{ - tet_infoline("UtcDaliDynamicsBodySetAngularVelocity - DynamicsBody::SetAngularVelocity"); - - 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 ); - return; - } - - 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( true ); -} - -void UtcDaliDynamicsBodySetKinematic() -{ - 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 ); - return; - } - - 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 ); -} - -void UtcDaliDynamicsBodyIsKinematic() -{ - 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 ); - return; - } - - 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() ); -} - -void UtcDaliDynamicsBodySetSleepEnabled() -{ - tet_infoline("UtcDaliDynamicsBodySetSleepEnabled"); - - 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 ); - return; - } - - 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() ); -} - -void UtcDaliDynamicsBodyGetSleepEnabled() -{ - 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 ); - return; - } - - 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() ); -} - -void UtcDaliDynamicsBodyWakeUp() -{ - tet_infoline("UtcDaliDynamicsBodyWakeUp"); - - 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 ); - return; - } - - 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( true ); -} - -void UtcDaliDynamicsBodyAddAnchor() -{ - 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 ); - return; - } - - 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(); -} - -void UtcDaliDynamicsBodyConserveVolume() -{ - 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 ); - return; - } - - 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 ); -} - -void UtcDaliDynamicsBodyConserveShape() -{ - 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 ); - return; - } - - 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 ); -} - diff --git a/automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsBodyConfig.cpp b/automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsBodyConfig.cpp deleted file mode 100644 index 61f1e6d..0000000 --- a/automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsBodyConfig.cpp +++ /dev/null @@ -1,657 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void UtcDaliDynamicsBodyConfigNew(); -static void UtcDaliDynamicsBodyConfigConstructor(); -static void UtcDaliDynamicsBodyConfigType(); -static void UtcDaliDynamicsBodyConfigSetShape01(); -static void UtcDaliDynamicsBodyConfigSetShape02(); -static void UtcDaliDynamicsBodyConfigGetShape(); -static void UtcDaliDynamicsBodyConfigMass(); -static void UtcDaliDynamicsBodyConfigElasticity(); -static void UtcDaliDynamicsBodyConfigFriction(); -static void UtcDaliDynamicsBodyConfigLinearDamping(); -static void UtcDaliDynamicsBodyConfigAngularDamping(); -static void UtcDaliDynamicsBodyConfigLinearSleepVelocity(); -static void UtcDaliDynamicsBodyConfigAngularSleepVelocity(); -static void UtcDaliDynamicsBodyConfigCollisionGroup(); -static void UtcDaliDynamicsBodyConfigCollisionMask(); -static void UtcDaliDynamicsBodyConfigAnchorHardness(); -static void UtcDaliDynamicsBodyConfigVolumeConservation(); -static void UtcDaliDynamicsBodyConfigShapeConservation(); - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -// Add test functionality for all APIs in the class (Positive and Negative) -extern "C" { - struct tet_testlist tet_testlist[] = - { - { UtcDaliDynamicsBodyConfigNew, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyConfigConstructor, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyConfigType, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyConfigSetShape01, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyConfigSetShape02, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyConfigGetShape, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyConfigMass, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyConfigElasticity, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyConfigFriction, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyConfigLinearDamping, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyConfigAngularDamping, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyConfigLinearSleepVelocity, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyConfigAngularSleepVelocity,POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyConfigCollisionGroup, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyConfigCollisionMask, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyConfigAnchorHardness, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyConfigVolumeConservation, POSITIVE_TC_IDX }, - { UtcDaliDynamicsBodyConfigShapeConservation, POSITIVE_TC_IDX }, - { NULL, 0 } - }; -} - -// Called only once before first test is run. -void Startup() -{ -} - -// Called only once after last test is run -void Cleanup() -{ -} - -void UtcDaliDynamicsBodyConfigNew() -{ - 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 ); - return; - } - - DynamicsBodyConfig config(DynamicsBodyConfig::New()); - - DALI_TEST_CHECK( config ); -} - -void UtcDaliDynamicsBodyConfigConstructor() -{ - 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 ); - return; - } - - // initialize handle - config = DynamicsBodyConfig::New(); - - DALI_TEST_CHECK( config ); -} - -void UtcDaliDynamicsBodyConfigType() -{ - 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 ); - return; - } - - 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() ); -} - -void UtcDaliDynamicsBodyConfigSetShape01() -{ - 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 ); - return; - } - - 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() ); -} - -void UtcDaliDynamicsBodyConfigSetShape02() -{ - 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 ); - return; - } - - 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() ); -} - -void UtcDaliDynamicsBodyConfigGetShape() -{ - 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 ); - return; - } - - DynamicsBodyConfig config(DynamicsBodyConfig::New()); - - DALI_TEST_CHECK( DynamicsShape::CUBE == config.GetShape().GetType() ); -} - -void UtcDaliDynamicsBodyConfigMass() -{ - 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 ); - return; - } - - 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 ); -} - -void UtcDaliDynamicsBodyConfigElasticity() -{ - 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 ); - return; - } - - 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 ); -} - -void UtcDaliDynamicsBodyConfigFriction() -{ - 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 ); - return; - } - - 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 ); -} - -void UtcDaliDynamicsBodyConfigLinearDamping() -{ - 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 ); - return; - } - - 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 ); -} - -void UtcDaliDynamicsBodyConfigAngularDamping() -{ - 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 ); - return; - } - - 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 ); -} - -void UtcDaliDynamicsBodyConfigLinearSleepVelocity() -{ - 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 ); - return; - } - - 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 ); -} - -void UtcDaliDynamicsBodyConfigAngularSleepVelocity() -{ - 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 ); - return; - } - - 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 ); -} - -void UtcDaliDynamicsBodyConfigCollisionGroup() -{ - TestApplication application; - - // start up - application.SendNotification(); - application.Render(); - application.Render(); - - const 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 ); - return; - } - - DynamicsBodyConfig config(DynamicsBodyConfig::New()); - config.SetCollisionGroup(testGroup); - - tet_infoline("UtcDaliDynamicsBodyConfigCollisionGroup- DynamicsBodyConfig::GetCollisionGroup"); - DALI_TEST_EQUALS( testGroup, config.GetCollisionGroup(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); - - tet_infoline("UtcDaliDynamicsBodyConfigCollisionGroup - DynamicsBodyConfig::SetCollisionGroup"); - const int group = config.GetCollisionGroup() + 1; - config.SetCollisionGroup(group); - DALI_TEST_EQUALS( group, config.GetCollisionGroup(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); -} - -void UtcDaliDynamicsBodyConfigCollisionMask() -{ - TestApplication application; - - // start up - application.SendNotification(); - application.Render(); - application.Render(); - - const 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 ); - return; - } - - DynamicsBodyConfig config(DynamicsBodyConfig::New()); - config.SetCollisionMask(testMask); - - tet_infoline("UtcDaliDynamicsBodyConfigCollisionMask- DynamicsBodyConfig::GetCollisionMask"); - DALI_TEST_EQUALS( testMask, config.GetCollisionMask(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); - - tet_infoline("UtcDaliDynamicsBodyConfigCollisionMask - DynamicsBodyConfig::SetCollisionMask"); - const int mask = config.GetCollisionMask() + 1; - config.SetCollisionMask(mask); - DALI_TEST_EQUALS( mask, config.GetCollisionMask(), Math::MACHINE_EPSILON_0, TEST_LOCATION ); -} - -void UtcDaliDynamicsBodyConfigAnchorHardness() -{ - 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 ); - return; - } - - 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 ); -} - -void UtcDaliDynamicsBodyConfigVolumeConservation() -{ - 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 ); - return; - } - - 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 ); -} - -void UtcDaliDynamicsBodyConfigShapeConservation() -{ - 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 ); - return; - } - - 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 ); -} diff --git a/automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsJoint.cpp b/automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsJoint.cpp deleted file mode 100644 index b994651..0000000 --- a/automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsJoint.cpp +++ /dev/null @@ -1,387 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void UtcDaliDynamicsJointConstructor(); -static void UtcDaliDynamicsJointLinearLimit(); -static void UtcDaliDynamicsJointAngularLimit(); -static void UtcDaliDynamicsJointEnableSpring(); -static void UtcDaliDynamicsJointSetSpringStiffness(); -static void UtcDaliDynamicsJointSetSpringCenterPoint(); -static void UtcDaliDynamicsJointEnableMotor(); -static void UtcDaliDynamicsJointSetMotorVelocity(); -static void UtcDaliDynamicsJointSetMotorForce(); -static void UtcDaliDynamicsJointGetActor(); - - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -// Add test functionality for all APIs in the class (Positive and Negative) -extern "C" { - struct tet_testlist tet_testlist[] = - { - { UtcDaliDynamicsJointConstructor, POSITIVE_TC_IDX }, - { UtcDaliDynamicsJointLinearLimit, POSITIVE_TC_IDX }, - { UtcDaliDynamicsJointAngularLimit, POSITIVE_TC_IDX }, - { UtcDaliDynamicsJointEnableSpring, POSITIVE_TC_IDX }, - { UtcDaliDynamicsJointSetSpringStiffness, POSITIVE_TC_IDX }, - { UtcDaliDynamicsJointSetSpringCenterPoint, POSITIVE_TC_IDX }, - { UtcDaliDynamicsJointEnableMotor, POSITIVE_TC_IDX }, - { UtcDaliDynamicsJointSetMotorVelocity, POSITIVE_TC_IDX }, - { UtcDaliDynamicsJointSetMotorForce, POSITIVE_TC_IDX }, - { UtcDaliDynamicsJointGetActor, POSITIVE_TC_IDX }, - { NULL, 0 } - }; -} - -// Called only once before first test is run. -void Startup() -{ -} - -// Called only once after last test is run -void Cleanup() -{ -} - -void UtcDaliDynamicsJointConstructor() -{ - tet_infoline("UtcDaliDynamicsJointConstructor - DynamicsJoint::DynamicsJoint"); - - TestApplication application; - - // start up - application.SendNotification(); - application.Render(); - application.Render(); - - DynamicsJoint joint; - - DALI_TEST_CHECK( !joint ); -} - -void UtcDaliDynamicsJointLinearLimit() -{ - 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 ); - return; - } - - 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 ); -} - -void UtcDaliDynamicsJointAngularLimit() -{ - 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 ); - return; - } - - 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 ); -} - -void UtcDaliDynamicsJointEnableSpring() -{ - 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 ); - return; - } - - 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 ); -} - -void UtcDaliDynamicsJointSetSpringStiffness() -{ - 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 ); - return; - } - - 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 ); -} - -void UtcDaliDynamicsJointSetSpringCenterPoint() -{ - 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 ); - return; - } - - 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 ); -} - -void UtcDaliDynamicsJointEnableMotor() -{ - 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 ); - return; - } - - 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 ); -} - -void UtcDaliDynamicsJointSetMotorVelocity() -{ - 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 ); - return; - } - - 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 ); -} - -void UtcDaliDynamicsJointSetMotorForce() -{ - 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 ); - return; - } - - 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 ); -} - -void UtcDaliDynamicsJointGetActor() -{ - 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 ); - return; - } - - 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 ); -} diff --git a/automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsShape.cpp b/automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsShape.cpp deleted file mode 100644 index ff64348..0000000 --- a/automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsShape.cpp +++ /dev/null @@ -1,297 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void UtcDaliDynamicsShapeConstructor(); -static void UtcDaliDynamicsShapeNewCapsule(); -static void UtcDaliDynamicsShapeNewCone(); -static void UtcDaliDynamicsShapeNewCube(); -static void UtcDaliDynamicsShapeNewCylinder(); -static void UtcDaliDynamicsShapeNewMesh(); -static void UtcDaliDynamicsShapeNewSphere(); -static void UtcDaliDynamicsShapeGetType(); - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -// Add test functionality for all APIs in the class (Positive and Negative) -extern "C" { - struct tet_testlist tet_testlist[] = - { - { UtcDaliDynamicsShapeConstructor, POSITIVE_TC_IDX }, - { UtcDaliDynamicsShapeNewCapsule, POSITIVE_TC_IDX }, - { UtcDaliDynamicsShapeNewCone, POSITIVE_TC_IDX }, - { UtcDaliDynamicsShapeNewCube, POSITIVE_TC_IDX }, - { UtcDaliDynamicsShapeNewCylinder, POSITIVE_TC_IDX }, - { UtcDaliDynamicsShapeNewMesh, POSITIVE_TC_IDX }, - { UtcDaliDynamicsShapeNewSphere, POSITIVE_TC_IDX }, - { UtcDaliDynamicsShapeGetType, POSITIVE_TC_IDX }, - { NULL, 0 } - }; -} - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -void UtcDaliDynamicsShapeConstructor() -{ - 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 ) - { - // cannot create dynamics world, log failure and exit - DALI_TEST_CHECK( false ); - return; - } - - // Default constructor - create an uninitialized handle - DynamicsShape shape; - DALI_TEST_CHECK( !shape ); - - // initialize handle - shape = DynamicsShape::NewCube(Vector3::ONE); - - DALI_TEST_CHECK( shape ); -} - -void UtcDaliDynamicsShapeNewCapsule() -{ - 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 ) - { - // cannot create dynamics world, log failure and exit - DALI_TEST_CHECK( false ); - return; - } - - DynamicsShape shape( DynamicsShape::NewCapsule( 1.0f, 2.0f ) ); - - DALI_TEST_CHECK( shape ); - DALI_TEST_CHECK( DynamicsShape::CAPSULE == shape.GetType() ); -} - -void UtcDaliDynamicsShapeNewCone() -{ - 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 ) - { - // cannot create dynamics world, log failure and exit - DALI_TEST_CHECK( false ); - return; - } - - DynamicsShape shape( DynamicsShape::NewCone( 1.0f, 2.0f ) ); - - DALI_TEST_CHECK( shape ); - DALI_TEST_CHECK( DynamicsShape::CONE == shape.GetType() ); -} - -void UtcDaliDynamicsShapeNewCube() -{ - 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 ) - { - // cannot create dynamics world, log failure and exit - DALI_TEST_CHECK( false ); - return; - } - - DynamicsShape shape( DynamicsShape::NewCube( Vector3::ONE ) ); - - DALI_TEST_CHECK( shape ); - DALI_TEST_CHECK( DynamicsShape::CUBE == shape.GetType() ); -} - -void UtcDaliDynamicsShapeNewCylinder() -{ - 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 ) - { - // cannot create dynamics world, log failure and exit - DALI_TEST_CHECK( false ); - return; - } - - DynamicsShape shape( DynamicsShape::NewCylinder( 1.0f, 2.0f ) ); - - DALI_TEST_CHECK( shape ); - DALI_TEST_CHECK( DynamicsShape::CYLINDER == shape.GetType() ); -} - -void UtcDaliDynamicsShapeNewMesh() -{ - 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 ) - { - // cannot create dynamics world, log failure and exit - DALI_TEST_CHECK( false ); - return; - } - - DynamicsShape shape( DynamicsShape::NewMesh( Mesh::NewPlane(10.0f, 10.0f, 10, 10)) ); - - DALI_TEST_CHECK( shape ); - DALI_TEST_CHECK( DynamicsShape::MESH == shape.GetType() ); -} - -void UtcDaliDynamicsShapeNewSphere() -{ - 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 ) - { - // cannot create dynamics world, log failure and exit - DALI_TEST_CHECK( false ); - return; - } - - DynamicsShape shape( DynamicsShape::NewSphere( 1.0f ) ); - - DALI_TEST_CHECK( shape ); - DALI_TEST_CHECK( DynamicsShape::SPHERE == shape.GetType() ); -} - -void UtcDaliDynamicsShapeGetType() -{ - 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 ) - { - // cannot create dynamics world, log failure and exit - DALI_TEST_CHECK( false ); - return; - } - - DynamicsShape shape( DynamicsShape::NewSphere( 1.0f ) ); - - DALI_TEST_CHECK( shape ); - DALI_TEST_CHECK( DynamicsShape::SPHERE == shape.GetType() ); -} - - diff --git a/automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsWorld.cpp b/automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsWorld.cpp deleted file mode 100644 index 9198f51..0000000 --- a/automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsWorld.cpp +++ /dev/null @@ -1,188 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void UtcDaliDynamicsWorldConstructor(); -static void UtcDaliDynamicsWorldGravity(); -static void UtcDaliDynamicsWorldDebugDrawMode(); -static void UtcDaliDynamicsWorldRootActor(); -static void UtcDaliDynamicsWorldSignalCollision(); - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -// Add test functionality for all APIs in the class (Positive and Negative) -extern "C" { - struct tet_testlist tet_testlist[] = - { - { UtcDaliDynamicsWorldConstructor, POSITIVE_TC_IDX }, - { UtcDaliDynamicsWorldGravity, POSITIVE_TC_IDX }, - { UtcDaliDynamicsWorldDebugDrawMode, POSITIVE_TC_IDX }, - { UtcDaliDynamicsWorldRootActor, POSITIVE_TC_IDX }, - { UtcDaliDynamicsWorldSignalCollision, POSITIVE_TC_IDX }, - { NULL, 0 } - }; -} - -// Called only once before first test is run. -void Startup() -{ -} - -// Called only once after last test is run -void Cleanup() -{ -} - -void UtcDaliDynamicsWorldConstructor() -{ - 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 ); -} - -void UtcDaliDynamicsWorldGravity() -{ - 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 ); - return; - } - - tet_infoline("UtcDaliDynamicsWorldGravity - DynamicsWorld::SetGravity"); - world.SetGravity(gravity); - DALI_TEST_CHECK(true); - - tet_infoline("UtcDaliDynamicsWorldGravity - DynamicsWorld::GetGravity"); - DALI_TEST_EQUALS(gravity, world.GetGravity(), TEST_LOCATION); -} - -void UtcDaliDynamicsWorldDebugDrawMode() -{ - 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 ); - return; - } - - const int mode(DynamicsWorld::DEBUG_MODE_WIREFRAME | DynamicsWorld::DEBUG_MODE_AABB); - - tet_infoline("UtcDaliDynamicsWorldDebugDrawMode - DynamicsWorld::SetDebugDrawMode"); - world.SetDebugDrawMode(mode); - DALI_TEST_CHECK(true); - - tet_infoline("UtcDaliDynamicsWorldDebugDrawMode - DynamicsWorld::GetDebugDrawMode"); - DALI_TEST_CHECK(mode == world.GetDebugDrawMode()); -} - -void UtcDaliDynamicsWorldRootActor() -{ - 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 ); - return; - } - - 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()); -} - -void UtcDaliDynamicsWorldSignalCollision() -{ - // TBD - tet_result(TET_PASS); -} - diff --git a/automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsWorldConfig.cpp b/automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsWorldConfig.cpp deleted file mode 100644 index 8a9284a..0000000 --- a/automated-tests/TET/dali-test-suite/dynamics/utc-Dali-DynamicsWorldConfig.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void UtcDaliDynamicsWorldConfigConstructor(); -static void UtcDaliDynamicsWorldConfigNew(); -static void UtcDaliDynamicsWorldConfigType(); - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -// Add test functionality for all APIs in the class (Positive and Negative) -extern "C" { - struct tet_testlist tet_testlist[] = - { - { UtcDaliDynamicsWorldConfigConstructor, POSITIVE_TC_IDX }, - { UtcDaliDynamicsWorldConfigNew, POSITIVE_TC_IDX }, - { UtcDaliDynamicsWorldConfigType, POSITIVE_TC_IDX }, - { NULL, 0 } - }; -} - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -static void UtcDaliDynamicsWorldConfigConstructor() -{ - 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 ); -} - -static void UtcDaliDynamicsWorldConfigNew() -{ - 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 ); -} - -static void UtcDaliDynamicsWorldConfigType() -{ - 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()); -} diff --git a/automated-tests/TET/dali-test-suite/effects/.gitignore b/automated-tests/TET/dali-test-suite/effects/.gitignore deleted file mode 100644 index ea7ee23..0000000 --- a/automated-tests/TET/dali-test-suite/effects/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -utc-Dali-ShaderEffect -utc-Dali-ShadowEffect diff --git a/automated-tests/TET/dali-test-suite/effects/Makefile b/automated-tests/TET/dali-test-suite/effects/Makefile deleted file mode 120000 index c88d5a7..0000000 --- a/automated-tests/TET/dali-test-suite/effects/Makefile +++ /dev/null @@ -1 +0,0 @@ -../master-makefile.mk \ No newline at end of file diff --git a/automated-tests/TET/dali-test-suite/effects/file.list b/automated-tests/TET/dali-test-suite/effects/file.list deleted file mode 100644 index 26bb784..0000000 --- a/automated-tests/TET/dali-test-suite/effects/file.list +++ /dev/null @@ -1,3 +0,0 @@ -TARGETS += \ - utc-Dali-ShaderEffect \ - diff --git a/automated-tests/TET/dali-test-suite/effects/tslist b/automated-tests/TET/dali-test-suite/effects/tslist deleted file mode 100644 index c9c2df2..0000000 --- a/automated-tests/TET/dali-test-suite/effects/tslist +++ /dev/null @@ -1,2 +0,0 @@ -/dali-test-suite/effects/utc-Dali-ShaderEffect - diff --git a/automated-tests/TET/dali-test-suite/effects/utc-Dali-ShaderEffect.cpp b/automated-tests/TET/dali-test-suite/effects/utc-Dali-ShaderEffect.cpp deleted file mode 100644 index 03d5054..0000000 --- a/automated-tests/TET/dali-test-suite/effects/utc-Dali-ShaderEffect.cpp +++ /dev/null @@ -1,1193 +0,0 @@ -// -// 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 "../../../build/slp/dali-core/dali-shaders.h" - -using namespace Dali; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -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; - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -static const char* TestImageFilename = "icon_wrt.png"; - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliShaderEffectMethodNew01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectMethodNew02, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectMethodNew03, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectMethodNew04, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectMethodNew05, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectMethodNew06, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectMethodDelete01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectMethodDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectMethodSetUniformFloat, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectMethodSetUniformVector2, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectMethodSetUniformVector3, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectMethodSetUniformVector4, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectMethodSetUniformMatrix, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliShaderEffectMethodSetUniformMatrix3, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectMethodSetUniformViewport, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectMethodSetEffectImage, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectMethodSetEffectImageAndDelete, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectMethodApplyConstraint, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectMethodApplyConstraintFromActor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectMethodApplyConstraintFromActor2, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectMethodApplyConstraintCallback, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectMethodRemoveConstraints, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectMethodRemoveConstraints2, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliShaderEffectMethodCreateExtension, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectMethodCreateExtension2, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectMethodNoExtension, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectFromProperties01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectFromProperties02, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliShaderEffectFromProperties03, NEGATIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliShaderEffectPropertyIndices, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -// Create bitmap image -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; -} - -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; -}; - -static void UtcDaliShaderEffectMethodNew01() -{ - TestApplication application; - - ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); - DALI_TEST_CHECK(effect); -} - -static void UtcDaliShaderEffectMethodNew02() -{ - 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 ); - } -} - -static void UtcDaliShaderEffectMethodNew03() -{ - TestApplication application; - - ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource, VertexSource, FragmentSource, ShaderEffect::HINT_NONE ); - DALI_TEST_CHECK(effect); -} - -static void UtcDaliShaderEffectMethodNew04() -{ - 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 ); - } -} - -class ShaderEffectExtension : public ShaderEffect::Extension {}; -static void UtcDaliShaderEffectMethodNew05() -{ - TestApplication application; - - // heap constructor / destructor - DefaultFunctionCoverage shaderEffect; - DefaultFunctionCoverage shaderEffectExtension; - -} - -static void UtcDaliShaderEffectMethodNew06() -{ - 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); -} - - -static void UtcDaliShaderEffectMethodDownCast() -{ - 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); -} - -static void UtcDaliShaderEffectMethodDelete01() -{ - TestApplication application; - - // 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 10 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 , Dali::Internal::CustomFontPrefixVertex.c_str(), 10 ) ; - - DALI_TEST_CHECK( testPassed == 0 ); -} - -static void UtcDaliShaderEffectMethodSetUniformFloat() -{ - 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 ) ); -} - -static void UtcDaliShaderEffectMethodSetUniformVector2() -{ - 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 ) ) ); -} - -static void UtcDaliShaderEffectMethodSetUniformVector3() -{ - 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 ) ) ); -} - -static void UtcDaliShaderEffectMethodSetUniformVector4() -{ - 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 ) ) ); -} - -static void UtcDaliShaderEffectMethodSetUniformMatrix() -{ - 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 ) ); -} - -static void UtcDaliShaderEffectMethodSetUniformMatrix3() -{ - 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) ); -} - -static void UtcDaliShaderEffectMethodSetUniformViewport() -{ - 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 ) ) ); -} - -static void UtcDaliShaderEffectMethodSetEffectImage() -{ - 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 ) ); -} - -static void UtcDaliShaderEffectMethodSetEffectImageAndDelete() -{ - TestApplication application; - - ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource ); - - BitmapImage effectImage = CreateBitmapImage(); - effect.SetEffectImage(effectImage); - - Integration::ResourceId imageId = GetImplementation(effectImage).GetResourceId(); - tet_printf("Effect Image id %d \n ",imageId); - - - 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); - -} -static void UtcDaliShaderEffectMethodApplyConstraint() -{ - // 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 ) ) ); -} - - -static void UtcDaliShaderEffectMethodApplyConstraintFromActor() -{ - // 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 ) ); -} - -static void UtcDaliShaderEffectMethodApplyConstraintFromActor2() -{ - // 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 ) ); -} - -static void UtcDaliShaderEffectMethodApplyConstraintCallback() -{ - // 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 ) ) ); -} - -static void UtcDaliShaderEffectMethodRemoveConstraints() -{ - // 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 ) ) ); -} - -static void UtcDaliShaderEffectMethodRemoveConstraints2() -{ - // 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 ) ) ); -} - - -class TestExtension : public ShaderEffect::Extension -{ -public: - TestExtension( bool& deleted ) - : mDeleted(deleted) - { - mDeleted = false; - } - ~TestExtension() - { - mDeleted = true; - } - bool IsAlive() const - { - return !mDeleted; - } -private: - bool& mDeleted; -}; - -static void UtcDaliShaderEffectMethodCreateExtension() -{ - // 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 ); -} - -static void UtcDaliShaderEffectMethodCreateExtension2() -{ - // 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 ); -} - -static void UtcDaliShaderEffectMethodNoExtension() -{ - 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 ); - } -} - -static void UtcDaliShaderEffectFromProperties01() -{ - 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); - -} - -static void UtcDaliShaderEffectFromProperties02() -{ - 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()); - } -} - -static void UtcDaliShaderEffectFromProperties03() -{ - 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()); - } -} - -void UtcDaliShaderEffectPropertyIndices() -{ - 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 ); -} diff --git a/automated-tests/TET/dali-test-suite/events/.gitignore b/automated-tests/TET/dali-test-suite/events/.gitignore deleted file mode 100644 index ae233c1..0000000 --- a/automated-tests/TET/dali-test-suite/events/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -utc-Dali-PanGesture -utc-Dali-Gesture -utc-Dali-PanGestureDetector -utc-Dali-KeyEvent -utc-Dali-GestureDetector -utc-Dali-PinchGesture -utc-Dali-PinchGestureDetector -utc-Dali-TapGesture -utc-Dali-TapGestureDetector -utc-Dali-LongPressGesture -utc-Dali-LongPressGestureDetector -utc-Dali-EventProcessing -utc-Dali-TouchProcessing -utc-Dali-TouchEventCombiner -utc-Dali-HitTestAlgorithm -utc-Dali-MouseWheelEvent diff --git a/automated-tests/TET/dali-test-suite/events/Makefile b/automated-tests/TET/dali-test-suite/events/Makefile deleted file mode 120000 index c88d5a7..0000000 --- a/automated-tests/TET/dali-test-suite/events/Makefile +++ /dev/null @@ -1 +0,0 @@ -../master-makefile.mk \ No newline at end of file diff --git a/automated-tests/TET/dali-test-suite/events/file.list b/automated-tests/TET/dali-test-suite/events/file.list deleted file mode 100644 index 8b75d6c..0000000 --- a/automated-tests/TET/dali-test-suite/events/file.list +++ /dev/null @@ -1,17 +0,0 @@ -TARGETS += \ - utc-Dali-PanGesture \ - utc-Dali-Gesture \ - utc-Dali-PanGestureDetector \ - utc-Dali-KeyEvent \ - utc-Dali-GestureDetector \ - utc-Dali-PinchGesture \ - utc-Dali-PinchGestureDetector \ - utc-Dali-TapGesture \ - utc-Dali-TapGestureDetector \ - utc-Dali-LongPressGesture \ - utc-Dali-LongPressGestureDetector \ - utc-Dali-EventProcessing \ - utc-Dali-TouchProcessing \ - utc-Dali-TouchEventCombiner \ - utc-Dali-HitTestAlgorithm \ - utc-Dali-MouseWheelEvent \ diff --git a/automated-tests/TET/dali-test-suite/events/tslist b/automated-tests/TET/dali-test-suite/events/tslist deleted file mode 100644 index da85884..0000000 --- a/automated-tests/TET/dali-test-suite/events/tslist +++ /dev/null @@ -1,16 +0,0 @@ -/dali-test-suite/events/utc-Dali-PanGesture -/dali-test-suite/events/utc-Dali-Gesture -/dali-test-suite/events/utc-Dali-PanGestureDetector -/dali-test-suite/events/utc-Dali-KeyEvent -/dali-test-suite/events/utc-Dali-GestureDetector -/dali-test-suite/events/utc-Dali-PinchGesture -/dali-test-suite/events/utc-Dali-PinchGestureDetector -/dali-test-suite/events/utc-Dali-TapGesture -/dali-test-suite/events/utc-Dali-TapGestureDetector -/dali-test-suite/events/utc-Dali-LongPressGesture -/dali-test-suite/events/utc-Dali-LongPressGestureDetector -/dali-test-suite/events/utc-Dali-EventProcessing -/dali-test-suite/events/utc-Dali-TouchProcessing -/dali-test-suite/events/utc-Dali-TouchEventCombiner -/dali-test-suite/events/utc-Dali-HitTestAlgorithm -/dali-test-suite/events/utc-Dali-MouseWheelEvent diff --git a/automated-tests/TET/dali-test-suite/events/utc-Dali-EventProcessing.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-EventProcessing.cpp deleted file mode 100644 index 72a4ec0..0000000 --- a/automated-tests/TET/dali-test-suite/events/utc-Dali-EventProcessing.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( UtcDaliInvalidEvent, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliInvalidGesture, NEGATIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -struct InvalidEvent : public Integration::Event -{ - InvalidEvent() : Event( Event::Type(-1000) ) {} - ~InvalidEvent() {} -}; - -struct InvalidGesture : public Integration::GestureEvent -{ - InvalidGesture() : GestureEvent( Gesture::Type(-1000), Gesture::Clear ) {} - ~InvalidGesture() {} -}; - -void UtcDaliInvalidEvent() -{ - TestApplication application; - - try - { - InvalidEvent event; - application.ProcessEvent( event ); - tet_result( TET_FAIL ); - } - catch ( Dali::DaliException& e ) - { - DALI_TEST_ASSERT( e, "false", TEST_LOCATION ); - } -} - -void UtcDaliInvalidGesture() -{ - TestApplication application; - - try - { - InvalidGesture event; - application.ProcessEvent( event ); - tet_result( TET_FAIL ); - } - catch ( Dali::DaliException& e ) - { - DALI_TEST_ASSERT( e, "false", TEST_LOCATION ); - } -} - diff --git a/automated-tests/TET/dali-test-suite/events/utc-Dali-Gesture.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-Gesture.cpp deleted file mode 100644 index e3e863c..0000000 --- a/automated-tests/TET/dali-test-suite/events/utc-Dali-Gesture.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliGestureConstructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliGestureAssignment, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -// TestGesture Struct (Gesture constructor is protected) -struct TestGesture : public Gesture -{ -public: - TestGesture(Gesture::Type type, Gesture::State state) - : Gesture(type, state) {} - - virtual ~TestGesture() {} -}; - -static void UtcDaliGestureConstructor() -{ - 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); -} - -static void UtcDaliGestureAssignment() -{ - // 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); -} diff --git a/automated-tests/TET/dali-test-suite/events/utc-Dali-GestureDetector.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-GestureDetector.cpp deleted file mode 100644 index f5b8b6a..0000000 --- a/automated-tests/TET/dali-test-suite/events/utc-Dali-GestureDetector.cpp +++ /dev/null @@ -1,427 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliGestureDetectorConstructorNegative, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliGestureDetectorConstructorPositive, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliGestureDetectorDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliGestureDetectorAttachPositive, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliGestureDetectorAttachNegative, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliGestureDetectorDetachPositive, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliGestureDetectorDetachNegative01, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliGestureDetectorDetachNegative02, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliGestureDetectorDetachNegative03, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliGestureDetectorDetachAll, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliGestureDetectorDetachAllNegative, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliGestureDetectorGetAttachedActors, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -static void UtcDaliGestureDetectorConstructorNegative() -{ - 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); - } - } -} - -static void UtcDaliGestureDetectorConstructorPositive() -{ - 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); - } -} - -static void UtcDaliGestureDetectorDownCast() -{ - 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); -} - -static void UtcDaliGestureDetectorAttachPositive() -{ - 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); - } -} - -static void UtcDaliGestureDetectorAttachNegative() -{ - 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); - } - } -} - -static void UtcDaliGestureDetectorDetachPositive() -{ - 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); - } -} - -static void UtcDaliGestureDetectorDetachNegative01() -{ - 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); - } - } -} - -static void UtcDaliGestureDetectorDetachNegative02() -{ - 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); - } -} - -static void UtcDaliGestureDetectorDetachNegative03() -{ - 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); - } -} - -static void UtcDaliGestureDetectorDetachAll() -{ - 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); -} - -static void UtcDaliGestureDetectorDetachAllNegative() -{ - 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); - } -} - -static void UtcDaliGestureDetectorGetAttachedActors() -{ - 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); -} diff --git a/automated-tests/TET/dali-test-suite/events/utc-Dali-HitTestAlgorithm.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-HitTestAlgorithm.cpp deleted file mode 100644 index c12913c..0000000 --- a/automated-tests/TET/dali-test-suite/events/utc-Dali-HitTestAlgorithm.cpp +++ /dev/null @@ -1,430 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( UtcDaliHitTestAlgorithmWithFunctor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliHitTestAlgorithmWithFunctorOnRenderTask, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliHitTestAlgorithmOrtho01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliHitTestAlgorithmOrtho02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliHitTestAlgorithmStencil, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -/** - * 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; -}; - - -// Positive test case for a method -static void UtcDaliHitTestAlgorithmWithFunctor() -{ - 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 ); -} - -static void UtcDaliHitTestAlgorithmWithFunctorOnRenderTask() -{ - 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 ); -} - - -static void UtcDaliHitTestAlgorithmOrtho01() -{ - 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 ); -} - - -static void UtcDaliHitTestAlgorithmOrtho02() -{ - 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 ); -} - -static void UtcDaliHitTestAlgorithmStencil() -{ - 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" ) ); - } -} diff --git a/automated-tests/TET/dali-test-suite/events/utc-Dali-KeyEvent.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-KeyEvent.cpp deleted file mode 100644 index 4de264f..0000000 --- a/automated-tests/TET/dali-test-suite/events/utc-Dali-KeyEvent.cpp +++ /dev/null @@ -1,286 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -// 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"; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliKeyEventConstructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliKeyEventIsShiftModifier, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliKeyEventIsCtrlModifier, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliKeyEventIsAltModifier, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliKeyEventIsNotShiftModifier, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliKeyEventIsNotCtrlModifier, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliKeyEventIsNotAltModifier, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliKeyEventANDModifer, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliKeyEventORModifer, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliKeyEventState, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliIntegrationKeyEvent, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -// 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; -}; - -static void UtcDaliKeyEventConstructor() -{ - 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 -} - -// Positive test case for a method -static void UtcDaliKeyEventIsShiftModifier() -{ - 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 - -} - -// Positive test case for a method -static void UtcDaliKeyEventIsCtrlModifier() -{ - 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 -} - -// Positive test case for a method -static void UtcDaliKeyEventIsAltModifier() -{ - 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 -} - -// Positive fail test case for a method -static void UtcDaliKeyEventIsNotShiftModifier() -{ - 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); -} - -// Positive fail test case for a method -static void UtcDaliKeyEventIsNotCtrlModifier() -{ - 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); -} - -// Positive fail test case for a method -static void UtcDaliKeyEventIsNotAltModifier() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliKeyEventANDModifer() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliKeyEventORModifer() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliKeyEventState() -{ - 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); -} - -static void UtcDaliIntegrationKeyEvent() -{ - 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); - } -} diff --git a/automated-tests/TET/dali-test-suite/events/utc-Dali-LongPressGesture.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-LongPressGesture.cpp deleted file mode 100644 index eb617b4..0000000 --- a/automated-tests/TET/dali-test-suite/events/utc-Dali-LongPressGesture.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliLongPressGestureConstructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureAssignment, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - - -// Positive test case for a method -static void UtcDaliLongPressGestureConstructor() -{ - 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); -} - -static void UtcDaliLongPressGestureAssignment() -{ - // 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); -} diff --git a/automated-tests/TET/dali-test-suite/events/utc-Dali-LongPressGestureDetector.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-LongPressGestureDetector.cpp deleted file mode 100644 index fc06ce2..0000000 --- a/automated-tests/TET/dali-test-suite/events/utc-Dali-LongPressGestureDetector.cpp +++ /dev/null @@ -1,1322 +0,0 @@ -// -// 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 - -using namespace Dali; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliLongPressGestureDetectorConstructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureDetectorNew, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureDetectorDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureSetTouchesRequired01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureSetTouchesRequired02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureGetMinimumTouchesRequired, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureGetMaximumTouchesRequired, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureSignalReceptionNegative, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureSignalReceptionPositive, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureSignalReceptionDetach, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureSignalReceptionActorDestroyedDuringLongPress, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureSignalReceptionRotatedActor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureSignalReceptionChildHit, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureSignalReceptionAttachDetachMany, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureSignalReceptionActorBecomesUntouchable, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureSignalReceptionMultipleGestureDetectors, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureSignalReceptionMultipleDetectorsOnActor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureSignalReceptionDifferentPossible, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureEmitIncorrectStateClear, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureEmitIncorrectStateContinuing, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureDetectorTypeRegistry, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureRepeatedState, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGesturePossibleCancelled, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureDetachAfterStarted, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureActorUnstaged, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureActorStagedAndDestroyed, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliLongPressGestureSystemOverlay, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -/////////////////////////////////////////////////////////////////////////////// - -// 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; -} - -/////////////////////////////////////////////////////////////////////////////// - - -// Positive test case for a method -static void UtcDaliLongPressGestureDetectorConstructor() -{ - TestApplication application; - - LongPressGestureDetector detector; - DALI_TEST_CHECK(!detector); -} - - -static void UtcDaliLongPressGestureDetectorNew() -{ - 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; -} - -static void UtcDaliLongPressGestureDetectorDownCast() -{ - 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); -} - -static void UtcDaliLongPressGestureSetTouchesRequired01() -{ - 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); -} - -static void UtcDaliLongPressGestureSetTouchesRequired02() -{ - 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); -} - -static void UtcDaliLongPressGestureGetMinimumTouchesRequired() -{ - TestApplication application; - - LongPressGestureDetector detector = LongPressGestureDetector::New(); - DALI_TEST_EQUALS(1u, detector.GetMinimumTouchesRequired(), TEST_LOCATION); -} - -static void UtcDaliLongPressGestureGetMaximumTouchesRequired() -{ - TestApplication application; - - LongPressGestureDetector detector = LongPressGestureDetector::New(); - DALI_TEST_EQUALS(1u, detector.GetMaximumTouchesRequired(), TEST_LOCATION); -} - -static void UtcDaliLongPressGestureSignalReceptionNegative() -{ - 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); -} - -static void UtcDaliLongPressGestureSignalReceptionPositive() -{ - 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))); -} - -static void UtcDaliLongPressGestureSignalReceptionDetach() -{ - 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); -} - -static void UtcDaliLongPressGestureSignalReceptionActorDestroyedDuringLongPress() -{ - 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); -} - -static void UtcDaliLongPressGestureSignalReceptionRotatedActor() -{ - 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); -} - -static void UtcDaliLongPressGestureSignalReceptionChildHit() -{ - 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); -} - -static void UtcDaliLongPressGestureSignalReceptionAttachDetachMany() -{ - 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); -} - -static void UtcDaliLongPressGestureSignalReceptionActorBecomesUntouchable() -{ - 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); -} - -static void UtcDaliLongPressGestureSignalReceptionMultipleGestureDetectors() -{ - 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); -} - -void UtcDaliLongPressGestureSignalReceptionMultipleDetectorsOnActor() -{ - 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); -} - -void UtcDaliLongPressGestureSignalReceptionDifferentPossible() -{ - 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); -} - -void UtcDaliLongPressGestureEmitIncorrectStateClear() -{ - 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 ); - } -} - -void UtcDaliLongPressGestureEmitIncorrectStateContinuing() -{ - 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 ); - } -} - -void UtcDaliLongPressGestureDetectorTypeRegistry() -{ - 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); -} - -void UtcDaliLongPressGestureRepeatedState() -{ - 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); -} - -void UtcDaliLongPressGesturePossibleCancelled() -{ - 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); -} - -void UtcDaliLongPressGestureDetachAfterStarted() -{ - 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); -} - -void UtcDaliLongPressGestureActorUnstaged() -{ - 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. -} - -void UtcDaliLongPressGestureActorStagedAndDestroyed() -{ - 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); -} - -void UtcDaliLongPressGestureSystemOverlay() -{ - TestApplication application; - Dali::Integration::SystemOverlay& systemOverlay( application.GetCore().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 ); -} diff --git a/automated-tests/TET/dali-test-suite/events/utc-Dali-MouseWheelEvent.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-MouseWheelEvent.cpp deleted file mode 100644 index 22ba7a9..0000000 --- a/automated-tests/TET/dali-test-suite/events/utc-Dali-MouseWheelEvent.cpp +++ /dev/null @@ -1,301 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -// 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; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( UtcDaliMouseWheelEventConstructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMouseWheelEventIsShiftModifier, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMouseWheelEventIsCtrlModifier, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMouseWheelEventIsAltModifier, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMouseWheelEventIsNotShiftModifier, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMouseWheelEventIsNotCtrlModifier, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMouseWheelEventIsNotAltModifier, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMouseWheelEventANDModifer, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMouseWheelEventORModifer, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMouseWheelEventSignalling, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -// 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; -}; - - -static void UtcDaliMouseWheelEventConstructor() -{ - 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 -} - -// Positive test case for a method -static void UtcDaliMouseWheelEventIsShiftModifier() -{ - 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 - -} - -// Positive test case for a method -static void UtcDaliMouseWheelEventIsCtrlModifier() -{ - 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 -} - -// Positive test case for a method -static void UtcDaliMouseWheelEventIsAltModifier() -{ - 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 -} - -// Positive fail test case for a method -static void UtcDaliMouseWheelEventIsNotShiftModifier() -{ - 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); -} - -// Positive fail test case for a method -static void UtcDaliMouseWheelEventIsNotCtrlModifier() -{ - 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); -} - -// Positive fail test case for a method -static void UtcDaliMouseWheelEventIsNotAltModifier() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliMouseWheelEventANDModifer() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliMouseWheelEventORModifer() -{ - 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); -} - -void UtcDaliMouseWheelEventSignalling() -{ - 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(); -} diff --git a/automated-tests/TET/dali-test-suite/events/utc-Dali-PanGesture.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-PanGesture.cpp deleted file mode 100644 index a1bcb03..0000000 --- a/automated-tests/TET/dali-test-suite/events/utc-Dali-PanGesture.cpp +++ /dev/null @@ -1,151 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliPanGestureConstructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureAssignment, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureGetSpeed, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureGetDistance, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureGetScreenSpeed, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureGetScreenDistance, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -static void UtcDaliPanGestureConstructor() -{ - 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); -} - -static void UtcDaliPanGestureAssignment() -{ - // 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); -} - -static void UtcDaliPanGestureGetSpeed() -{ - 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); -} - -static void UtcDaliPanGestureGetDistance() -{ - 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); -} - -static void UtcDaliPanGestureGetScreenSpeed() -{ - 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); -} - -static void UtcDaliPanGestureGetScreenDistance() -{ - 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); -} diff --git a/automated-tests/TET/dali-test-suite/events/utc-Dali-PanGestureDetector.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-PanGestureDetector.cpp deleted file mode 100644 index 2c7d683..0000000 --- a/automated-tests/TET/dali-test-suite/events/utc-Dali-PanGestureDetector.cpp +++ /dev/null @@ -1,2055 +0,0 @@ -// -// 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 - -using namespace Dali; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliPanGestureDetectorConstructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureDetectorNew, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureDetectorDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureSetMinimumTouchesRequired, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureSetMaximumTouchesRequired, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureGetMinimumTouchesRequired, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureGetMaximumTouchesRequired, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureSignalReceptionNegative, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureSignalReceptionDownMotionLeave, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureSignalReceptionDownMotionUp, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureSignalReceptionCancelled, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureSignalReceptionDetach, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureSignalReceptionDetachWhilePanning, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureSignalReceptionActorDestroyedWhilePanning, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureSignalReceptionRotatedActor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureSignalReceptionChildHit, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureSignalReceptionAttachDetachMany, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureSignalReceptionActorBecomesUntouchable, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureSignalReceptionMultipleGestureDetectors, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureSignalReceptionMultipleDetectorsOnActor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureSignalReceptionMultipleStarted, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureSignalReceptionEnsureCorrectSignalling, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureSignalReceptionDifferentPossible, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureEmitIncorrectState, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureDetectorTypeRegistry, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureActorUnstaged, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureActorStagedAndDestroyed, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureSystemOverlay, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureAngleHandling, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureAngleOutOfRange, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureAngleProcessing, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureDirectionHandling, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureDirectionProcessing, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureSetProperties, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGestureSetPropertiesAlreadyPanning, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPanGesturePropertyIndices, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -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; -} - -/////////////////////////////////////////////////////////////////////////////// - -// Positive test case for a method -static void UtcDaliPanGestureDetectorConstructor() -{ - TestApplication application; - - PanGestureDetector detector; - DALI_TEST_CHECK(!detector); -} - - -// Negative test case for a method -static void UtcDaliPanGestureDetectorNew() -{ - 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); -} - -static void UtcDaliPanGestureDetectorDownCast() -{ - 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); -} - -static void UtcDaliPanGestureSetMinimumTouchesRequired() -{ - 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); -} - -static void UtcDaliPanGestureSetMaximumTouchesRequired() -{ - 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); -} - -static void UtcDaliPanGestureGetMinimumTouchesRequired() -{ - TestApplication application; - - PanGestureDetector detector = PanGestureDetector::New(); - DALI_TEST_EQUALS(1u, detector.GetMinimumTouchesRequired(), TEST_LOCATION); -} - -static void UtcDaliPanGestureGetMaximumTouchesRequired() -{ - TestApplication application; - - PanGestureDetector detector = PanGestureDetector::New(); - DALI_TEST_EQUALS(1u, detector.GetMaximumTouchesRequired(), TEST_LOCATION); -} - -static void UtcDaliPanGestureSignalReceptionNegative() -{ - 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); -} - -static void UtcDaliPanGestureSignalReceptionDownMotionLeave() -{ - 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); -} - -static void UtcDaliPanGestureSignalReceptionDownMotionUp() -{ - 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); -} - -static void UtcDaliPanGestureSignalReceptionCancelled() -{ - 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); -} - -static void UtcDaliPanGestureSignalReceptionDetach() -{ - 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); -} - -static void UtcDaliPanGestureSignalReceptionDetachWhilePanning() -{ - 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); -} - -static void UtcDaliPanGestureSignalReceptionActorDestroyedWhilePanning() -{ - 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); -} - -static void UtcDaliPanGestureSignalReceptionRotatedActor() -{ - 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 -} - -static void UtcDaliPanGestureSignalReceptionChildHit() -{ - 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 -} - -static void UtcDaliPanGestureSignalReceptionAttachDetachMany() -{ - 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); -} - -static void UtcDaliPanGestureSignalReceptionActorBecomesUntouchable() -{ - 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); -} - -static void UtcDaliPanGestureSignalReceptionMultipleGestureDetectors() -{ - 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); -} - -void UtcDaliPanGestureSignalReceptionMultipleDetectorsOnActor() -{ - 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); -} - -void UtcDaliPanGestureSignalReceptionMultipleStarted() -{ - // 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); -} - -void UtcDaliPanGestureSignalReceptionEnsureCorrectSignalling() -{ - 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); -} - -void UtcDaliPanGestureSignalReceptionDifferentPossible() -{ - 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); -} - -void UtcDaliPanGestureEmitIncorrectState() -{ - 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 ); - } -} - -void UtcDaliPanGestureDetectorTypeRegistry() -{ - 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); -} - -void UtcDaliPanGestureActorUnstaged() -{ - 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. -} - -void UtcDaliPanGestureActorStagedAndDestroyed() -{ - 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); -} - -void UtcDaliPanGestureSystemOverlay() -{ - TestApplication application; - Dali::Integration::SystemOverlay& systemOverlay( application.GetCore().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 ); -} - -void UtcDaliPanGestureAngleHandling() -{ - 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 ); -} - -inline float RadiansToDegrees( float radian ) -{ - return radian * 180.0f / Math::PI; -} - -void UtcDaliPanGestureAngleOutOfRange() -{ - 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(); -} - -void UtcDaliPanGestureAngleProcessing() -{ - 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(); -} - -void UtcDaliPanGestureDirectionHandling() -{ - 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 ); -} - -void UtcDaliPanGestureDirectionProcessing() -{ - 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(); -} - -void UtcDaliPanGestureSetProperties() -{ - 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(); -} - -void UtcDaliPanGestureSetPropertiesAlreadyPanning() -{ - 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(); -} - -void UtcDaliPanGesturePropertyIndices() -{ - 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 ); -} diff --git a/automated-tests/TET/dali-test-suite/events/utc-Dali-PinchGesture.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-PinchGesture.cpp deleted file mode 100644 index ba8d2d6..0000000 --- a/automated-tests/TET/dali-test-suite/events/utc-Dali-PinchGesture.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliPinchGestureConstructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPinchGestureAssignment, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - - -// Positive test case for a method -static void UtcDaliPinchGestureConstructor() -{ - 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); -} - -static void UtcDaliPinchGestureAssignment() -{ - // 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); -} - - - - diff --git a/automated-tests/TET/dali-test-suite/events/utc-Dali-PinchGestureDetector.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-PinchGestureDetector.cpp deleted file mode 100644 index 3810ff8..0000000 --- a/automated-tests/TET/dali-test-suite/events/utc-Dali-PinchGestureDetector.cpp +++ /dev/null @@ -1,1239 +0,0 @@ -// -// 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 - -using namespace Dali; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliPinchGestureDetectorConstructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPinchGestureDetectorNew, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPinchGestureDetectorDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPinchGestureSignalReceptionNegative, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPinchGestureSignalReceptionDownMotionLeave, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPinchGestureSignalReceptionDownMotionUp, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPinchGestureSignalReceptionCancelled, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPinchGestureSignalReceptionDetach, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPinchGestureSignalReceptionDetachWhilePinching, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPinchGestureSignalReceptionActorDestroyedWhilePinching, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPinchGestureSignalReceptionRotatedActor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPinchGestureSignalReceptionChildHit, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPinchGestureSignalReceptionAttachDetachMany, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPinchGestureSignalReceptionActorBecomesUntouchable, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPinchGestureSignalReceptionMultipleDetectorsOnActor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPinchGestureSignalReceptionMultipleStarted, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPinchGestureSignalReceptionEnsureCorrectSignalling, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPinchGestureEmitIncorrectStateClear, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPinchGestureEmitIncorrectStatePossible, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPinchGestureDetectorTypeRegistry, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPinchGestureActorUnstaged, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPinchGestureActorStagedAndDestroyed, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPinchGestureSystemOverlay, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -/////////////////////////////////////////////////////////////////////////////// - -// 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; -} - -/////////////////////////////////////////////////////////////////////////////// - -static void UtcDaliPinchGestureDetectorConstructor() -{ - TestApplication application; - - PinchGestureDetector detector; - DALI_TEST_CHECK(!detector); -} - -static void UtcDaliPinchGestureDetectorNew() -{ - 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); -} - -static void UtcDaliPinchGestureDetectorDownCast() -{ - 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); -} - -// Negative test case for a method -static void UtcDaliPinchGestureSignalReceptionNegative() -{ - 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); -} - -static void UtcDaliPinchGestureSignalReceptionDownMotionLeave() -{ - 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); -} - -static void UtcDaliPinchGestureSignalReceptionDownMotionUp() -{ - 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); -} - -static void UtcDaliPinchGestureSignalReceptionCancelled() -{ - 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); -} - -static void UtcDaliPinchGestureSignalReceptionDetach() -{ - 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); -} - -static void UtcDaliPinchGestureSignalReceptionDetachWhilePinching() -{ - 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); -} - -static void UtcDaliPinchGestureSignalReceptionActorDestroyedWhilePinching() -{ - 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); -} - -static void UtcDaliPinchGestureSignalReceptionRotatedActor() -{ - 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); -} - -static void UtcDaliPinchGestureSignalReceptionChildHit() -{ - 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); -} - -static void UtcDaliPinchGestureSignalReceptionAttachDetachMany() -{ - 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); -} - -static void UtcDaliPinchGestureSignalReceptionActorBecomesUntouchable() -{ - 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); -} - -void UtcDaliPinchGestureSignalReceptionMultipleDetectorsOnActor() -{ - 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); -} - -void UtcDaliPinchGestureSignalReceptionMultipleStarted() -{ - // 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); -} - -void UtcDaliPinchGestureSignalReceptionEnsureCorrectSignalling() -{ - 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); -} - -void UtcDaliPinchGestureEmitIncorrectStateClear() -{ - 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 ); - } -} - -void UtcDaliPinchGestureEmitIncorrectStatePossible() -{ - 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 ); - } -} - -void UtcDaliPinchGestureDetectorTypeRegistry() -{ - 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); -} - -void UtcDaliPinchGestureActorUnstaged() -{ - 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. -} - -void UtcDaliPinchGestureActorStagedAndDestroyed() -{ - 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); -} - -void UtcDaliPinchGestureSystemOverlay() -{ - TestApplication application; - Dali::Integration::SystemOverlay& systemOverlay( application.GetCore().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 ); -} diff --git a/automated-tests/TET/dali-test-suite/events/utc-Dali-TapGesture.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-TapGesture.cpp deleted file mode 100644 index 4ac7e20..0000000 --- a/automated-tests/TET/dali-test-suite/events/utc-Dali-TapGesture.cpp +++ /dev/null @@ -1,97 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliTapGestureConstructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureAssignment, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - - -// Positive test case for a method -static void UtcDaliTapGestureConstructor() -{ - 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); -} - -static void UtcDaliTapGestureAssignment() -{ - // 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); -} diff --git a/automated-tests/TET/dali-test-suite/events/utc-Dali-TapGestureDetector.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-TapGestureDetector.cpp deleted file mode 100644 index 21acd54..0000000 --- a/automated-tests/TET/dali-test-suite/events/utc-Dali-TapGestureDetector.cpp +++ /dev/null @@ -1,1217 +0,0 @@ -// -// 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 - -using namespace Dali; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliTapGestureDetectorConstructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureDetectorNew, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureDetectorDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureSetTapsRequired, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureGetTapsRequired, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureSetTouchesRequired, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureGetTouchesRequired, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureSignalReceptionNegative, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureSignalReceptionPositive, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureSignalReceptionDetach, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureSignalReceptionActorDestroyedWhileTapping, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureSignalReceptionRotatedActor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureSignalReceptionChildHit, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureSignalReceptionAttachDetachMany, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureSignalReceptionActorBecomesUntouchable, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureSignalReceptionMultipleGestureDetectors, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureSignalReceptionMultipleDetectorsOnActor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureSignalReceptionDifferentPossible, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureEmitIncorrectStateClear, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureEmitIncorrectStateContinuing, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureEmitIncorrectStateFinished, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureDetectorTypeRegistry, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureActorUnstaged, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureRepeatedState, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGesturePossibleCancelled, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureDetectorRemovedWhilePossible, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureActorRemovedWhilePossible, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTapGestureSystemOverlay, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -/////////////////////////////////////////////////////////////////////////////// - -// 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; -} - -/////////////////////////////////////////////////////////////////////////////// - - -// Positive test case for a method -static void UtcDaliTapGestureDetectorConstructor() -{ - TestApplication application; - - TapGestureDetector detector; - DALI_TEST_CHECK(!detector); -} - - -static void UtcDaliTapGestureDetectorNew() -{ - 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; -} - -static void UtcDaliTapGestureDetectorDownCast() -{ - 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); -} - -static void UtcDaliTapGestureSetTapsRequired() -{ - 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); -} -static void UtcDaliTapGestureGetTapsRequired() -{ - TestApplication application; - - TapGestureDetector detector = TapGestureDetector::New(); - DALI_TEST_EQUALS(1u, detector.GetTapsRequired(), TEST_LOCATION); -} -static void UtcDaliTapGestureSetTouchesRequired() -{ - 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); -} -static void UtcDaliTapGestureGetTouchesRequired() -{ - TestApplication application; - - TapGestureDetector detector = TapGestureDetector::New(); - DALI_TEST_EQUALS(1u, detector.GetTouchesRequired(), TEST_LOCATION); -} -static void UtcDaliTapGestureSignalReceptionNegative() -{ - 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); -} -static void UtcDaliTapGestureSignalReceptionPositive() -{ - 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); -} - -static void UtcDaliTapGestureSignalReceptionDetach() -{ - 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); -} -static void UtcDaliTapGestureSignalReceptionActorDestroyedWhileTapping() -{ - 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); -} -static void UtcDaliTapGestureSignalReceptionRotatedActor() -{ - 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); -} -static void UtcDaliTapGestureSignalReceptionChildHit() -{ - 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); -} -static void UtcDaliTapGestureSignalReceptionAttachDetachMany() -{ - 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); -} -static void UtcDaliTapGestureSignalReceptionActorBecomesUntouchable() -{ - 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); -} - -static void UtcDaliTapGestureSignalReceptionMultipleGestureDetectors() -{ - 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); -} - -void UtcDaliTapGestureSignalReceptionMultipleDetectorsOnActor() -{ - 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); -} - -void UtcDaliTapGestureSignalReceptionDifferentPossible() -{ - 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); -} - -void UtcDaliTapGestureEmitIncorrectStateClear() -{ - 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 ); - } -} - -void UtcDaliTapGestureEmitIncorrectStateContinuing() -{ - 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 ); - } -} - -void UtcDaliTapGestureEmitIncorrectStateFinished() -{ - 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 ); - } -} - -void UtcDaliTapGestureDetectorTypeRegistry() -{ - 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); -} - -void UtcDaliTapGestureActorUnstaged() -{ - 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. -} - -void UtcDaliTapGestureRepeatedState() -{ - 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); -} - -void UtcDaliTapGesturePossibleCancelled() -{ - 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); -} - -void UtcDaliTapGestureDetectorRemovedWhilePossible() -{ - 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); -} - -void UtcDaliTapGestureActorRemovedWhilePossible() -{ - 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); -} - -void UtcDaliTapGestureSystemOverlay() -{ - TestApplication application; - Dali::Integration::SystemOverlay& systemOverlay( application.GetCore().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 ); -} diff --git a/automated-tests/TET/dali-test-suite/events/utc-Dali-TouchEventCombiner.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-TouchEventCombiner.cpp deleted file mode 100644 index 21f8506..0000000 --- a/automated-tests/TET/dali-test-suite/events/utc-Dali-TouchEventCombiner.cpp +++ /dev/null @@ -1,796 +0,0 @@ -// -// 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; -using namespace Dali::Integration; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( UtcDaliTouchEventCombinerConstructors, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchEventCombinerConstructorsNegative, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchEventCombinerSettersAndGetters, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchEventCombinerSettersNegative, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchEventCombinerSingleTouchNormal, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchEventCombinerSingleTouchMotionWithoutDown, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchEventCombinerSingleTouchTwoDowns, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchEventCombinerSingleTouchUpWithoutDown, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchEventCombinerSingleTouchTwoUps, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchEventCombinerSingleTouchUpWithDifferentId, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchEventCombinerSingleTouchMotionWithDifferentId, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchEventCombinerMultiTouchNormal, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchEventCombinerSeveralPoints, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchEventCombinerReset, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchEventCombinerSingleTouchInterrupted, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchEventCombinerMultiTouchInterrupted, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchEventCombinerInvalidState, NEGATIVE_TC_IDX ); - -// Called only once before first test is run. -void Startup() -{ -} - -// Called only once after last test is run -void Cleanup() -{ -} - - -void UtcDaliTouchEventCombinerConstructors() -{ - 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 ); -} - -void UtcDaliTouchEventCombinerConstructorsNegative() -{ - 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 ); - } -} - -void UtcDaliTouchEventCombinerSettersAndGetters() -{ - 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 ); -} - -void UtcDaliTouchEventCombinerSettersNegative() -{ - 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 ); - } -} - -void UtcDaliTouchEventCombinerSingleTouchNormal() -{ - 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 ); - } -} - -void UtcDaliTouchEventCombinerSingleTouchMotionWithoutDown() -{ - 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 ); - } -} - -void UtcDaliTouchEventCombinerSingleTouchTwoDowns() -{ - 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 ); - } -} - -void UtcDaliTouchEventCombinerSingleTouchUpWithoutDown() -{ - 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 ); - } -} - -void UtcDaliTouchEventCombinerSingleTouchTwoUps() -{ - 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 ); - } -} - -void UtcDaliTouchEventCombinerSingleTouchUpWithDifferentId() -{ - 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 ); - } -} - -void UtcDaliTouchEventCombinerSingleTouchMotionWithDifferentId() -{ - 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 ); - } -} - -void UtcDaliTouchEventCombinerMultiTouchNormal() -{ - 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 ); - } -} - -void UtcDaliTouchEventCombinerSeveralPoints() -{ - 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 ); - } -} - -void UtcDaliTouchEventCombinerReset() -{ - 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 ); - } -} - -void UtcDaliTouchEventCombinerSingleTouchInterrupted() -{ - 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 ); - } -} - -void UtcDaliTouchEventCombinerMultiTouchInterrupted() -{ - 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 ); - } -} - -void UtcDaliTouchEventCombinerInvalidState() -{ - 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 ); - } -} diff --git a/automated-tests/TET/dali-test-suite/events/utc-Dali-TouchProcessing.cpp b/automated-tests/TET/dali-test-suite/events/utc-Dali-TouchProcessing.cpp deleted file mode 100644 index afea2c8..0000000 --- a/automated-tests/TET/dali-test-suite/events/utc-Dali-TouchProcessing.cpp +++ /dev/null @@ -1,1209 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( UtcDaliTouchNormalProcessing, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchOutsideCameraNearFarPlanes, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchEmitEmpty, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchInterrupted, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchParentConsumer, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchInterruptedParentConsumer, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchLeave, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchLeaveParentConsumer, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchActorBecomesInsensitive, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchActorBecomesInsensitiveParentConsumer, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchMultipleLayers, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchMultipleRenderTasks, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchMultipleRenderTasksWithChildLayer, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchOffscreenRenderTasks, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchMultipleRenderableActors, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchActorRemovedInSignal, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchActorSignalNotConsumed, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchActorUnStaged, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTouchSystemOverlayActor, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -/////////////////////////////////////////////////////////////////////////////// - -// 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; -} - -/////////////////////////////////////////////////////////////////////////////// - -void UtcDaliTouchNormalProcessing() -{ - 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 ); -} - -void UtcDaliTouchOutsideCameraNearFarPlanes() -{ - 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(); -} - -void UtcDaliTouchEmitEmpty() -{ - 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 ); - } -} - -void UtcDaliTouchInterrupted() -{ - 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 ); -} - -void UtcDaliTouchParentConsumer() -{ - 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 ); -} - -void UtcDaliTouchInterruptedParentConsumer() -{ - 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 ); -} - -void UtcDaliTouchLeave() -{ - 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(); -} - -void UtcDaliTouchLeaveParentConsumer() -{ - 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 ); -} - -void UtcDaliTouchActorBecomesInsensitive() -{ - 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(); -} - -void UtcDaliTouchActorBecomesInsensitiveParentConsumer() -{ - 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 ); -} - -void UtcDaliTouchMultipleLayers() -{ - 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(); -} - -void UtcDaliTouchMultipleRenderTasks() -{ - 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(); -} - -void UtcDaliTouchMultipleRenderTasksWithChildLayer() -{ - 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(); -} - -void UtcDaliTouchOffscreenRenderTasks() -{ - 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(); -} - -void UtcDaliTouchMultipleRenderableActors() -{ - 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 ); -} - -void UtcDaliTouchActorRemovedInSignal() -{ - 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 ); -} - -void UtcDaliTouchActorSignalNotConsumed() -{ - 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 ); -} - -void UtcDaliTouchActorUnStaged() -{ - 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(); -} - -void UtcDaliTouchSystemOverlayActor() -{ - TestApplication application; - Dali::Integration::SystemOverlay& systemOverlay( application.GetCore().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 ); -} diff --git a/automated-tests/TET/dali-test-suite/geometry/.gitignore b/automated-tests/TET/dali-test-suite/geometry/.gitignore deleted file mode 100644 index 4855874..0000000 --- a/automated-tests/TET/dali-test-suite/geometry/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -utc-Dali-Spline -utc-Dali-MeshData -utc-Dali-AnimatableMesh diff --git a/automated-tests/TET/dali-test-suite/geometry/Makefile b/automated-tests/TET/dali-test-suite/geometry/Makefile deleted file mode 120000 index c88d5a7..0000000 --- a/automated-tests/TET/dali-test-suite/geometry/Makefile +++ /dev/null @@ -1 +0,0 @@ -../master-makefile.mk \ No newline at end of file diff --git a/automated-tests/TET/dali-test-suite/geometry/file.list b/automated-tests/TET/dali-test-suite/geometry/file.list deleted file mode 100644 index 2e1595a..0000000 --- a/automated-tests/TET/dali-test-suite/geometry/file.list +++ /dev/null @@ -1,4 +0,0 @@ -TARGETS += \ - utc-Dali-Spline \ - utc-Dali-MeshData \ - utc-Dali-AnimatableMesh \ diff --git a/automated-tests/TET/dali-test-suite/geometry/tslist b/automated-tests/TET/dali-test-suite/geometry/tslist deleted file mode 100644 index 9c25b49..0000000 --- a/automated-tests/TET/dali-test-suite/geometry/tslist +++ /dev/null @@ -1,3 +0,0 @@ -/dali-test-suite/geometry/utc-Dali-Spline -/dali-test-suite/geometry/utc-Dali-MeshData -/dali-test-suite/geometry/utc-Dali-AnimatableMesh diff --git a/automated-tests/TET/dali-test-suite/geometry/utc-Dali-AnimatableMesh.cpp b/automated-tests/TET/dali-test-suite/geometry/utc-Dali-AnimatableMesh.cpp deleted file mode 100644 index 968eb4d..0000000 --- a/automated-tests/TET/dali-test-suite/geometry/utc-Dali-AnimatableMesh.cpp +++ /dev/null @@ -1,477 +0,0 @@ -// -// 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 - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( UtcDaliAnimatableMeshConstructor01, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimatableMeshConstructor02, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimatableMeshConstructor03, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimatableMeshNew01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimatableMeshNew02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimatableMeshNew03, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimatableMeshNew04, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimatableMeshNew05, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimatableMeshNew06, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimatableMeshDownCast01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimatableMeshDownCast02, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimatableMeshGetPropertyIndex01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimatableMeshGetPropertyIndex02, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimatableMeshGetPropertyIndex03, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimatableMeshGetPropertyIndex04, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimatableMeshOperatorArray01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimatableMeshOperatorArray02, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimatableMeshAnimateVertex01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimatableVertexSettersAndGetters, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimatableMeshProperties, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAnimatableMeshExceedVertices, NEGATIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -void CreateFaces(Dali::AnimatableMesh::Faces& faces, int numVerts) -{ - for(int i=0; i 0", TEST_LOCATION); - } -} - -// Negative test case for a method -static void UtcDaliAnimatableMeshNew04() -{ - 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); - } -} - -// Negative test case for a method -static void UtcDaliAnimatableMeshNew05() -{ - 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); - } -} - -// Negative test case for a method -static void UtcDaliAnimatableMeshNew06() -{ - 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); - } -} - -static void UtcDaliAnimatableMeshDownCast01() -{ - 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 ); -} - -static void UtcDaliAnimatableMeshDownCast02() -{ - TestApplication application; - tet_infoline("Testing Dali::AnimatableMesh::DownCast()"); - - MeshData meshData; - CreateMeshData(meshData); - Mesh mesh = Mesh::New(meshData); - BaseHandle* bh = &mesh; - - AnimatableMesh mesh2 = AnimatableMesh::DownCast(*bh); - DALI_TEST_CHECK( ! mesh2 ); -} - -static void UtcDaliAnimatableMeshGetPropertyIndex01() -{ - 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 ); -} - -static void UtcDaliAnimatableMeshGetPropertyIndex02() -{ - TestApplication application; - tet_infoline("Testing Dali::AnimatableMesh::GetPropertyIndexa"); - - 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); - } -} - -static void UtcDaliAnimatableMeshGetPropertyIndex03() -{ - TestApplication application; - tet_infoline("Testing Dali::AnimatableMesh::GetPropertyIndexa"); - - 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); - } -} - -static void UtcDaliAnimatableMeshGetPropertyIndex04() -{ - 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); - } -} - -static void UtcDaliAnimatableMeshOperatorArray01() -{ - 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 ); - } -} - -static void UtcDaliAnimatableMeshOperatorArray02() -{ - 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); - } -} - -static void UtcDaliAnimatableMeshAnimateVertex01() -{ - 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 ); - } -} - -static void UtcDaliAnimatableVertexSettersAndGetters() -{ - 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); -} - -void UtcDaliAnimatableMeshProperties() -{ - 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 ); -} - -void UtcDaliAnimatableMeshExceedVertices() -{ - 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 ); - } -} diff --git a/automated-tests/TET/dali-test-suite/geometry/utc-Dali-MeshData.cpp b/automated-tests/TET/dali-test-suite/geometry/utc-Dali-MeshData.cpp deleted file mode 100644 index e325f17..0000000 --- a/automated-tests/TET/dali-test-suite/geometry/utc-Dali-MeshData.cpp +++ /dev/null @@ -1,363 +0,0 @@ -// -// 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 - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliMeshDataNew, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshDataSetData, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshDataAddToBoundingVolume, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshDataBoundingBox, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshDataGetVertexCount, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshDataGetVertices, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshDataGetFaceCount, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshDataGetFaces, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshDataTextureCoords, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshDataNormals, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshDataGetMaterial, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshDataSetMaterial, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshDataGetBoneCount, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMeshDataGetBones, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - - - -static void UtcDaliMeshDataNew() -{ - TestApplication application; - MeshData meshData; - - DALI_TEST_EQUALS(meshData.HasNormals(), false, TEST_LOCATION); - DALI_TEST_EQUALS(meshData.HasTextureCoords(), false, TEST_LOCATION); -} - - -static void UtcDaliMeshDataSetData() -{ - 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); -} - -static void UtcDaliMeshDataAddToBoundingVolume() -{ - 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); -} - -static void UtcDaliMeshDataBoundingBox() -{ - 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); -} - -static void UtcDaliMeshDataGetVertexCount () -{ - 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); - -} - -static void UtcDaliMeshDataGetVertices () -{ - 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()); -} - -static void UtcDaliMeshDataGetFaceCount () -{ - 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); -} - -static void UtcDaliMeshDataGetFaces () -{ - 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); -} - -static void UtcDaliMeshDataTextureCoords () -{ - TestApplication application; - MeshData meshData; - DALI_TEST_EQUALS(meshData.HasTextureCoords(), false, TEST_LOCATION); - meshData.SetHasTextureCoords(true); - DALI_TEST_EQUALS(meshData.HasTextureCoords(), true, TEST_LOCATION); -} - -static void UtcDaliMeshDataNormals () -{ - TestApplication application; - MeshData meshData; - DALI_TEST_EQUALS(meshData.HasNormals(), false, TEST_LOCATION); - meshData.SetHasNormals(true); - DALI_TEST_EQUALS(meshData.HasNormals(), true, TEST_LOCATION); -} - -static void UtcDaliMeshDataGetMaterial () -{ - 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); -} - -static void UtcDaliMeshDataSetMaterial () -{ - 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); - -} - -static void UtcDaliMeshDataGetBoneCount () -{ - 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); -} - - -static void UtcDaliMeshDataGetBones () -{ - 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() ); -} diff --git a/automated-tests/TET/dali-test-suite/geometry/utc-Dali-Spline.cpp b/automated-tests/TET/dali-test-suite/geometry/utc-Dali-Spline.cpp deleted file mode 100644 index 1474500..0000000 --- a/automated-tests/TET/dali-test-suite/geometry/utc-Dali-Spline.cpp +++ /dev/null @@ -1,690 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void utcDaliSplineGetKnot01(); -static void utcDaliSplineGetKnot02(); -static void utcDaliSplineGetKnot03(); -static void utcDaliSplineGetOutTangent01(); -static void utcDaliSplineGetOutTangent02(); -static void utcDaliSplineGetOutTangent03(); -static void utcDaliSplineGetInTangent01(); -static void utcDaliSplineGetInTangent02(); -static void utcDaliSplineGetInTangent03(); -static void utcDaliSplineGenerateControlPoints01(); -static void utcDaliSplineGenerateControlPoints02(); -static void utcDaliSplineGenerateControlPoints03(); - -static void UtcDaliSplineGetYFromMonotonicX(); -static void UtcDaliSplineGetY01(); -static void UtcDaliSplineGetY02(); -static void UtcDaliSplineGetY02b(); -static void UtcDaliSplineGetY03(); -static void UtcDaliSplineGetY04(); -static void UtcDaliSplineGetY04b(); -static void UtcDaliSplineGetPoint01(); -static void UtcDaliSplineGetPoint02(); -static void UtcDaliSplineGetPoint03(); -static void UtcDaliSplineGetPoint04(); -static void UtcDaliSplineGetPoint05(); -static void UtcDaliSplineGetPoint06(); - - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -// Add test functionality for all APIs in the class (Positive and Negative) -extern "C" { - struct tet_testlist tet_testlist[] = { - { utcDaliSplineGetKnot01, POSITIVE_TC_IDX }, - { utcDaliSplineGetKnot02, NEGATIVE_TC_IDX }, - { utcDaliSplineGetKnot03, NEGATIVE_TC_IDX }, - { utcDaliSplineGetOutTangent01, POSITIVE_TC_IDX }, - { utcDaliSplineGetOutTangent02, NEGATIVE_TC_IDX }, - { utcDaliSplineGetOutTangent03, NEGATIVE_TC_IDX }, - { utcDaliSplineGetInTangent01, POSITIVE_TC_IDX }, - { utcDaliSplineGetInTangent02, NEGATIVE_TC_IDX }, - { utcDaliSplineGetInTangent03, NEGATIVE_TC_IDX }, - { utcDaliSplineGenerateControlPoints01, POSITIVE_TC_IDX }, - { utcDaliSplineGenerateControlPoints02, NEGATIVE_TC_IDX }, - { utcDaliSplineGenerateControlPoints03, NEGATIVE_TC_IDX }, - { UtcDaliSplineGetYFromMonotonicX, POSITIVE_TC_IDX }, - { UtcDaliSplineGetY01, POSITIVE_TC_IDX }, - { UtcDaliSplineGetY02, NEGATIVE_TC_IDX }, - { UtcDaliSplineGetY02b, NEGATIVE_TC_IDX }, - { UtcDaliSplineGetY03, NEGATIVE_TC_IDX }, - { UtcDaliSplineGetY04, NEGATIVE_TC_IDX }, - { UtcDaliSplineGetY04b,NEGATIVE_TC_IDX }, - { UtcDaliSplineGetPoint01, POSITIVE_TC_IDX }, - { UtcDaliSplineGetPoint02, POSITIVE_TC_IDX }, - { UtcDaliSplineGetPoint03, NEGATIVE_TC_IDX }, - { UtcDaliSplineGetPoint04, NEGATIVE_TC_IDX }, - { UtcDaliSplineGetPoint05, NEGATIVE_TC_IDX }, - { UtcDaliSplineGetPoint06, NEGATIVE_TC_IDX }, - { NULL, 0 } - }; -} - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -// 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}, -}; - - -// Positive test case for a method -static void UtcDaliSplineGetYFromMonotonicX() -{ - TestApplication application; - - Spline *bezierSpline = SetupBezierSpline1(); - - - for(unsigned int i=0; iGetYFromMonotonicX(test[i].x), - (float)test[i].y, 0.1f, - TEST_LOCATION); - } - - delete bezierSpline; -} - -static void utcDaliSplineGetKnot01() -{ - 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); -} - -static void utcDaliSplineGetKnot02() -{ - 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); - } -} - -static void utcDaliSplineGetKnot03() -{ - 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); - } -} - -static void utcDaliSplineGetInTangent01() -{ - 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); -} - - - -static void utcDaliSplineGetInTangent02() -{ - 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); - } -} - - -static void utcDaliSplineGetInTangent03() -{ - 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); - } -} - - -static void utcDaliSplineGetOutTangent01() -{ - 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); -} - - - -static void utcDaliSplineGetOutTangent02() -{ - 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); - } -} - - -static void utcDaliSplineGetOutTangent03() -{ - 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); - } -} - - -static void utcDaliSplineGenerateControlPoints01() -{ - 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. -} - -static void utcDaliSplineGenerateControlPoints02() -{ - 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); - } -} - - -static void utcDaliSplineGenerateControlPoints03() -{ - 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); - } -} - - -static void UtcDaliSplineGetY01() -{ - 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; -} - -// Test segments outside range (should assert and fail tetcase!) -static void UtcDaliSplineGetY02() -{ - 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); - } -} - -// Test segments outside range (should assert and fail tetcase!) -static void UtcDaliSplineGetY02b() -{ - 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); - } -} - - -// Test parameter ouside 0-1 - should return 0. -static void UtcDaliSplineGetY03() -{ - 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; -} - -// Test on empty spline - should assert -static void UtcDaliSplineGetY04() -{ - 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); - } -} - - -// Test on empty spline - should assert -static void UtcDaliSplineGetY04b() -{ - 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); - } -} - - - -static void UtcDaliSplineGetPoint01() -{ - 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; -} - - -static void UtcDaliSplineGetPoint02() -{ - 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; -} - - -// Test on segment index out of bounds - should assert and fail tet case -static void UtcDaliSplineGetPoint03() -{ - 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); - } -} - -// Test on segment index out of bounds - should assert and fail tet case -static void UtcDaliSplineGetPoint04() -{ - 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); - } -} - - -// Test on parameter out of bounds - should return 0,0 -static void UtcDaliSplineGetPoint05() -{ - 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); -} - -// Test on empty spline - should assert and fail tet case -static void UtcDaliSplineGetPoint06() -{ - 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); - } -} - - diff --git a/automated-tests/TET/dali-test-suite/images/.gitignore b/automated-tests/TET/dali-test-suite/images/.gitignore deleted file mode 100644 index 2734cd2..0000000 --- a/automated-tests/TET/dali-test-suite/images/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -utc-Dali-BitmapImage -utc-Dali-DistanceField -utc-Dali-FrameBufferImage -utc-Dali-Image -utc-Dali-ImageAtlas -utc-Dali-ImageAttributes -utc-Dali-Pixel -utc-Dali-EncodedBufferImage -utc-Dali-GlyphImage diff --git a/automated-tests/TET/dali-test-suite/images/Makefile b/automated-tests/TET/dali-test-suite/images/Makefile deleted file mode 120000 index c88d5a7..0000000 --- a/automated-tests/TET/dali-test-suite/images/Makefile +++ /dev/null @@ -1 +0,0 @@ -../master-makefile.mk \ No newline at end of file diff --git a/automated-tests/TET/dali-test-suite/images/file.list b/automated-tests/TET/dali-test-suite/images/file.list deleted file mode 100644 index 9c665d1..0000000 --- a/automated-tests/TET/dali-test-suite/images/file.list +++ /dev/null @@ -1,9 +0,0 @@ -TARGETS += \ - utc-Dali-EncodedBufferImage \ - utc-Dali-BitmapImage \ - utc-Dali-DistanceField \ - utc-Dali-FrameBufferImage \ - utc-Dali-GlyphImage \ - utc-Dali-Image \ - utc-Dali-ImageAttributes \ - utc-Dali-Pixel diff --git a/automated-tests/TET/dali-test-suite/images/tslist b/automated-tests/TET/dali-test-suite/images/tslist deleted file mode 100644 index 4315d5e..0000000 --- a/automated-tests/TET/dali-test-suite/images/tslist +++ /dev/null @@ -1,8 +0,0 @@ -/dali-test-suite/images/utc-Dali-BitmapImage -/dali-test-suite/images/utc-Dali-DistanceField -/dali-test-suite/images/utc-Dali-FrameBufferImage -/dali-test-suite/images/utc-Dali-Image -/dali-test-suite/images/utc-Dali-ImageAttributes -/dali-test-suite/images/utc-Dali-Pixel -/dali-test-suite/images/utc-Dali-EncodedBufferImage -/dali-test-suite/images/utc-Dali-GlyphImage diff --git a/automated-tests/TET/dali-test-suite/images/utc-Dali-BitmapImage.cpp b/automated-tests/TET/dali-test-suite/images/utc-Dali-BitmapImage.cpp deleted file mode 100644 index c465fc7..0000000 --- a/automated-tests/TET/dali-test-suite/images/utc-Dali-BitmapImage.cpp +++ /dev/null @@ -1,548 +0,0 @@ -// -// 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 std::max; -using namespace Dali; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void UtcDaliBitmapImageNew01(); -static void UtcDaliBitmapImageNew02(); -static void UtcDaliBitmapImageNewWithPolicy01(); -static void UtcDaliBitmapImageNewWithPolicy02(); -static void UtcDaliBitmapImageDownCast(); -static void UtcDaliBitmapImageDownCast2(); -static void UtcDaliBitmapImageWHITE(); -static void UtcDaliBitmapImageGetBuffer(); -static void UtcDaliBitmapImageGetBufferSize(); -static void UtcDaliBitmapImageGetBufferStride(); -static void UtcDaliBitmapImageIsDataExternal(); -static void UtcDaliBitmapImageUpdate01(); -static void UtcDaliBitmapImageUpdate02(); -static void UtcDaliBitmapImageUploadedSignal01(); -static void UtcDaliBitmapImageUploadedSignal02(); - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -static const float ROTATION_EPSILON = 0.0001f; - -// Add test functionality for all APIs in the class (Positive and Negative) -extern "C" { - struct tet_testlist tet_testlist[] = { - { UtcDaliBitmapImageNew01, POSITIVE_TC_IDX }, // 1 - { UtcDaliBitmapImageNew02, POSITIVE_TC_IDX }, // 2 - { UtcDaliBitmapImageNewWithPolicy01, POSITIVE_TC_IDX }, // 3 - { UtcDaliBitmapImageNewWithPolicy02, POSITIVE_TC_IDX }, // 4 - { UtcDaliBitmapImageDownCast, POSITIVE_TC_IDX }, // 5 - { UtcDaliBitmapImageDownCast2, POSITIVE_TC_IDX }, // 6 - { UtcDaliBitmapImageWHITE, POSITIVE_TC_IDX }, // 7 - { UtcDaliBitmapImageGetBuffer, POSITIVE_TC_IDX }, // 8 - { UtcDaliBitmapImageGetBufferSize, POSITIVE_TC_IDX }, // 9 - { UtcDaliBitmapImageGetBufferStride, POSITIVE_TC_IDX }, // 10 - { UtcDaliBitmapImageIsDataExternal, POSITIVE_TC_IDX }, // 11 - { UtcDaliBitmapImageUpdate01, POSITIVE_TC_IDX }, // 11 - { UtcDaliBitmapImageUpdate02, POSITIVE_TC_IDX }, // 12 - { UtcDaliBitmapImageUploadedSignal01, POSITIVE_TC_IDX }, // 13 - { UtcDaliBitmapImageUploadedSignal02, POSITIVE_TC_IDX }, // 14 - { NULL, 0 } - }; -} - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -static void UtcDaliBitmapImageNew01() -{ - 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); -} - -static void UtcDaliBitmapImageNew02() -{ - 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; -} - -static void UtcDaliBitmapImageNewWithPolicy01() -{ - 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) ); -} - -static void UtcDaliBitmapImageNewWithPolicy02() -{ - 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) ); -} - -static void UtcDaliBitmapImageDownCast() -{ - 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); -} - -static void UtcDaliBitmapImageDownCast2() -{ - 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); -} - -static void UtcDaliBitmapImageWHITE() -{ - 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 -} - -static void UtcDaliBitmapImageGetBuffer() -{ - 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 -} - -static void UtcDaliBitmapImageGetBufferSize() -{ - 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 -} - -static void UtcDaliBitmapImageGetBufferStride() -{ - 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; -} - - -static void UtcDaliBitmapImageIsDataExternal() -{ - 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() ); -} - -static bool SignalReceived; -static void ImageUploaded(Image image) -{ - tet_infoline("Received image uploaded signal"); - SignalReceived = true; -} - -static void UtcDaliBitmapImageUpdate01() -{ - 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; -} - -static void UtcDaliBitmapImageUpdate02() -{ - 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; -} - -static void UtcDaliBitmapImageUploadedSignal01() -{ - 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 ); -} - -static void UtcDaliBitmapImageUploadedSignal02() -{ - 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 ); -} diff --git a/automated-tests/TET/dali-test-suite/images/utc-Dali-DistanceField.cpp b/automated-tests/TET/dali-test-suite/images/utc-Dali-DistanceField.cpp deleted file mode 100644 index 509099c..0000000 --- a/automated-tests/TET/dali-test-suite/images/utc-Dali-DistanceField.cpp +++ /dev/null @@ -1,97 +0,0 @@ -// -// 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 std::max; -using namespace Dali; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void UtcDaliGenerateDistanceField(); - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -static const float ROTATION_EPSILON = 0.0001f; - -// Add test functionality for all APIs in the class (Positive and Negative) -extern "C" { - struct tet_testlist tet_testlist[] = { - { UtcDaliGenerateDistanceField, POSITIVE_TC_IDX }, - { NULL, 0 } - }; -} - -static TestApplication* gApplication = NULL; - -// Called only once before first test is run. -static void Startup() -{ - gApplication = new TestApplication(); -} - -// Called only once after last test is run -static void Cleanup() -{ - delete gApplication; -} - -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 -}; - -static void UtcDaliGenerateDistanceField() -{ - 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); - } -} diff --git a/automated-tests/TET/dali-test-suite/images/utc-Dali-EncodedBufferImage.cpp b/automated-tests/TET/dali-test-suite/images/utc-Dali-EncodedBufferImage.cpp deleted file mode 100644 index c951a55..0000000 --- a/automated-tests/TET/dali-test-suite/images/utc-Dali-EncodedBufferImage.cpp +++ /dev/null @@ -1,896 +0,0 @@ -// -// 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 - -/** - * \file - * Unit tests for the EncodedBufferImage image subclass. - * The only new API it adds is a constructor so that is what we - * test. - */ - -using namespace Dali; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -/// A list of test cases in the array tet_testlist[] -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -/** PNG image in memory buffer. */ -namespace -{ -extern const unsigned char sEncodedBufferImageDataPNG[]; -static const unsigned int sEncodedBufferImageDataPNGLength = 8675; -} - -TEST_FUNCTION( UtcDaliEncodedBufferImageNew01, POSITIVE_TC_IDX ); -// Nagative outcomes expected -TEST_FUNCTION( UtcDaliEncodedBufferImageNew02, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliEncodedBufferImageNew03, NEGATIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -// Positive test case for constructors: -static void UtcDaliEncodedBufferImageNew01() -{ - 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 ); -} - -// Negative test case for constructor - null pointer: -static void UtcDaliEncodedBufferImageNew02() -{ - 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); - } -} - -// Negative test case for constructor - zero-length input buffer: -static void UtcDaliEncodedBufferImageNew03() -{ - 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); - } -} - -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 -}; -} diff --git a/automated-tests/TET/dali-test-suite/images/utc-Dali-FrameBufferImage.cpp b/automated-tests/TET/dali-test-suite/images/utc-Dali-FrameBufferImage.cpp deleted file mode 100644 index 618f824..0000000 --- a/automated-tests/TET/dali-test-suite/images/utc-Dali-FrameBufferImage.cpp +++ /dev/null @@ -1,134 +0,0 @@ -// -// 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 std::max; -using namespace Dali; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void UtcDaliFrameBufferImageNew01(); -static void UtcDaliFrameBufferImageDownCast(); - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -static const float ROTATION_EPSILON = 0.0001f; - -// Add test functionality for all APIs in the class (Positive and Negative) -extern "C" { - struct tet_testlist tet_testlist[] = { - { UtcDaliFrameBufferImageNew01, POSITIVE_TC_IDX }, - { UtcDaliFrameBufferImageDownCast, POSITIVE_TC_IDX }, - { NULL, 0 } - }; -} - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -static void UtcDaliFrameBufferImageNew01() -{ - 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); -} - -static void UtcDaliFrameBufferImageDownCast() -{ - 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); -} diff --git a/automated-tests/TET/dali-test-suite/images/utc-Dali-Image.cpp b/automated-tests/TET/dali-test-suite/images/utc-Dali-Image.cpp deleted file mode 100644 index 119ed7e..0000000 --- a/automated-tests/TET/dali-test-suite/images/utc-Dali-Image.cpp +++ /dev/null @@ -1,1119 +0,0 @@ -// -// 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 - -using namespace Dali; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static const char* gTestImageFilename = "icon_wrt.png"; - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( UtcDaliImageNew01, POSITIVE_TC_IDX ); // 01 -TEST_FUNCTION( UtcDaliImageNew02, POSITIVE_TC_IDX ); // 02 -TEST_FUNCTION( UtcDaliImageNew03, POSITIVE_TC_IDX ); // 03 -TEST_FUNCTION( UtcDaliImageNewWithPolicies01, POSITIVE_TC_IDX ); // 04 -TEST_FUNCTION( UtcDaliImageNewWithPolicies02, POSITIVE_TC_IDX ); // 05 -TEST_FUNCTION( UtcDaliImageNewWithPolicies03, POSITIVE_TC_IDX ); // 06 -TEST_FUNCTION( UtcDaliImageNewWithPolicies04, POSITIVE_TC_IDX ); // 07 -TEST_FUNCTION( UtcDaliImageNewDistanceField, POSITIVE_TC_IDX ); // 08 -TEST_FUNCTION( UtcDaliImageNewDistanceFieldWithPolicies01, POSITIVE_TC_IDX ); // 09 -TEST_FUNCTION( UtcDaliImageNewDistanceFieldWithPolicies02, POSITIVE_TC_IDX ); // 10 -TEST_FUNCTION( UtcDaliImageNewDistanceFieldWithPolicies03, POSITIVE_TC_IDX ); // 11 -TEST_FUNCTION( UtcDaliImageNewDistanceFieldWithPolicies04, POSITIVE_TC_IDX ); // 12 -TEST_FUNCTION( UtcDaliImageNewDistanceFieldWithAttributes, POSITIVE_TC_IDX ); // 13 -TEST_FUNCTION( UtcDaliImageNewDistanceFieldWithAttrandPol, POSITIVE_TC_IDX ); // 14 -TEST_FUNCTION( UtcDaliImageDownCast, POSITIVE_TC_IDX ); // 15 -TEST_FUNCTION( UtcDaliImageGetImageSize, POSITIVE_TC_IDX ); // 16 -TEST_FUNCTION( UtcDaliImageGetFilename, POSITIVE_TC_IDX ); // 17 -TEST_FUNCTION( UtcDaliImageGetLoadingState01, POSITIVE_TC_IDX ); // 18 -TEST_FUNCTION( UtcDaliImageGetLoadingState02, POSITIVE_TC_IDX ); // 19 -TEST_FUNCTION( UtcDaliImageGetReleasePolicy, POSITIVE_TC_IDX ); // 20 -TEST_FUNCTION( UtcDaliImageGetLoadPolicy, POSITIVE_TC_IDX ); // 21 -TEST_FUNCTION( UtcDaliImageSignalLoadingFinished, POSITIVE_TC_IDX ); // 22 -TEST_FUNCTION( UtcDaliImageSignalUploaded, POSITIVE_TC_IDX ); // 23 -TEST_FUNCTION( UtcDaliImageDiscard01, POSITIVE_TC_IDX ); // 24 -TEST_FUNCTION( UtcDaliImageDiscard02, POSITIVE_TC_IDX ); // 25 -TEST_FUNCTION( UtcDaliImageDiscard03, POSITIVE_TC_IDX ); // 26 - - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -// 1.1 -static void UtcDaliImageNew01() -{ - 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 ); -} - -// 1.2 -static void UtcDaliImageNew02() -{ - 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 ); -} - -// 1.3 -static void UtcDaliImageNew03() -{ - 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 ); -} - -// 1.4 -static void UtcDaliImageNewWithPolicies01() -{ - 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) ); -} - -// 1.5 -static void UtcDaliImageNewWithPolicies02() -{ - 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) ); -} - -// 1.6 -static void UtcDaliImageNewWithPolicies03() -{ - 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) ); -} - -// 1.7 -static void UtcDaliImageNewWithPolicies04() -{ - 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) ); -} - -// 1.8 -static void UtcDaliImageNewDistanceField() -{ - 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 ); -} - -// 1.9 -static void UtcDaliImageNewDistanceFieldWithPolicies01() -{ - 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) ); -} - -// 1.10 -static void UtcDaliImageNewDistanceFieldWithPolicies02() -{ - 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) ); -} - -// 1.11 -static void UtcDaliImageNewDistanceFieldWithPolicies03() -{ - 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) ); -} - -// 1.12 -static void UtcDaliImageNewDistanceFieldWithPolicies04() -{ - 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) ); -} - -// 1.13 -static void UtcDaliImageNewDistanceFieldWithAttributes() -{ - 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 ); -} - -// 1.14 -static void UtcDaliImageNewDistanceFieldWithAttrandPol() -{ - 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) ); -} - -// 1.15 -static void UtcDaliImageDownCast() -{ - 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); -} - -// 1.16 -static void UtcDaliImageGetImageSize() -{ - 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); -} - -// 1.17 -static void UtcDaliImageGetFilename() -{ - 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); -} - -// 1.18 -static void UtcDaliImageGetLoadingState01() -{ - 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); -} - -// 1.19 -static void UtcDaliImageGetLoadingState02() -{ - 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); -} - -// 1.20 -static void UtcDaliImageGetReleasePolicy() -{ - 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() ); - -} - -// 1.21 -static void UtcDaliImageGetLoadPolicy() -{ - 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()); -} - -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 -static void UtcDaliImageSignalLoadingFinished() -{ - 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 ); -} - -// 1.23 -static void UtcDaliImageSignalUploaded() -{ - 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 ); -} - - -// 1.24 -static void UtcDaliImageDiscard01() -{ - 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 ); -} - -// 1.25 -static void UtcDaliImageDiscard02() -{ - 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 )); -} - -// 1.26 -static void UtcDaliImageDiscard03() -{ - 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 - - // Test what?! -} diff --git a/automated-tests/TET/dali-test-suite/images/utc-Dali-ImageAttributes.cpp b/automated-tests/TET/dali-test-suite/images/utc-Dali-ImageAttributes.cpp deleted file mode 100644 index b29fae5..0000000 --- a/automated-tests/TET/dali-test-suite/images/utc-Dali-ImageAttributes.cpp +++ /dev/null @@ -1,145 +0,0 @@ -// -// 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 std::max; -using namespace Dali; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void UtcDaliImageAttributesConstructor(); -static void UtcDaliImageAttributesLessThan(); -static void UtcDaliImageAttributesEquality(); -static void UtcDaliImageAttributesInEquality(); - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -static const float ROTATION_EPSILON = 0.0001f; - -// Add test functionality for all APIs in the class (Positive and Negative) -extern "C" { - struct tet_testlist tet_testlist[] = { - { UtcDaliImageAttributesConstructor, POSITIVE_TC_IDX }, - { UtcDaliImageAttributesLessThan, POSITIVE_TC_IDX }, - { UtcDaliImageAttributesEquality, POSITIVE_TC_IDX }, - { UtcDaliImageAttributesInEquality, POSITIVE_TC_IDX }, - { NULL, 0 } - }; -} - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -static void UtcDaliImageAttributesConstructor() -{ - TestApplication application; - - tet_infoline("UtcDaliImageAttributesConstructor"); - - // invoke default handle constructor - ImageAttributes imageAttributes; - - DALI_TEST_CHECK( imageAttributes.GetWidth() == 0); -} - -static void UtcDaliImageAttributesLessThan() -{ - 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); -} - -static void UtcDaliImageAttributesEquality() -{ - TestApplication application; - - tet_infoline("UtcDaliImageAttributesEquality"); - - // invoke default handle constructor - ImageAttributes imageAttributes01; - ImageAttributes imageAttributes02; - - DALI_TEST_CHECK(imageAttributes02 == imageAttributes01); -} - -static void UtcDaliImageAttributesInEquality() -{ - TestApplication application; - - tet_infoline("UtcDaliImageAttributesInEquality"); - - // invoke default handle constructor - ImageAttributes imageAttributes01; - ImageAttributes imageAttributes02; - - DALI_TEST_CHECK((imageAttributes02 != imageAttributes01) == false); -} - - diff --git a/automated-tests/TET/dali-test-suite/images/utc-Dali-Pixel.cpp b/automated-tests/TET/dali-test-suite/images/utc-Dali-Pixel.cpp deleted file mode 100644 index 883d343..0000000 --- a/automated-tests/TET/dali-test-suite/images/utc-Dali-Pixel.cpp +++ /dev/null @@ -1,206 +0,0 @@ -// -// 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 std::max; -using namespace Dali; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void UtcDaliPixelHasAlpha(); -static void UtcDaliPixelGetBytesPerPixel(); -static void UtcDaliPixelGetAlphaOffsetAndMask(); - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -static const float ROTATION_EPSILON = 0.0001f; - -// Add test functionality for all APIs in the class (Positive and Negative) -extern "C" { - struct tet_testlist tet_testlist[] = { - { UtcDaliPixelHasAlpha, POSITIVE_TC_IDX }, - { UtcDaliPixelGetBytesPerPixel, POSITIVE_TC_IDX }, - { UtcDaliPixelGetAlphaOffsetAndMask, POSITIVE_TC_IDX }, - { NULL, 0 } - }; -} - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -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."); -} - -static void UtcDaliPixelHasAlpha() -{ - 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 ); -} - -static void UtcDaliPixelGetBytesPerPixel() -{ - 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); -} - -static void UtcDaliPixelGetAlphaOffsetAndMask() -{ - 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 == 0); - 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); -} - diff --git a/automated-tests/TET/dali-test-suite/images/utc-MODULE-CLASS.cpp.in b/automated-tests/TET/dali-test-suite/images/utc-MODULE-CLASS.cpp.in deleted file mode 100644 index 5e3ecb7..0000000 --- a/automated-tests/TET/dali-test-suite/images/utc-MODULE-CLASS.cpp.in +++ /dev/null @@ -1,82 +0,0 @@ -#include - -#include -#include - -#include - -#include - -using namespace Dali; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void Utc@MODULE@@CLASS@Method01(); -static void Utc@MODULE@@CLASS@Method02(); - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -// Add test functionality for all APIs in the class (Positive and Negative) -extern "C" { - struct tet_testlist tet_testlist[] = { - { Utc@MODULE@@CLASS@Method01, POSITIVE_TC_IDX }, - { Utc@MODULE@@CLASS@Method02, NEGATIVE_TC_IDX }, - { NULL, 0 } - }; -} - -static Dali::TestApplication* gApplication = NULL; - -// Called only once before first test is run. -static void Startup() -{ - gApplication = new Dali::TestApplication(); -} - -// Called only once after last test is run -static void Cleanup() -{ - delete gApplication; -} - - -// Positive test case for a method -static void Utc@MODULE@@CLASS@Method01() -{ - gApplication->Initialize(); // Reset all test adapter return codes - - tet_infoline("Journaled printf Output"); - tet_result(TET_FAIL); -#if 0 - tet_result(TET_PASS); -#endif -} - - -// Negative test case for a method -static void Utc@MODULE@@CLASS@Method02() -{ - gApplication->Initialize(); // Reset all test adapter return codes - - try - { - /* My test code and results */ - DALI_TEST_EQUALS(myVar, expectedValue, TEST_LOCATION); - } - 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(e, "assert conditional", TEST_LOCATION); - } -} - diff --git a/automated-tests/TET/dali-test-suite/master-makefile.mk b/automated-tests/TET/dali-test-suite/master-makefile.mk deleted file mode 100644 index 41064f7..0000000 --- a/automated-tests/TET/dali-test-suite/master-makefile.mk +++ /dev/null @@ -1,41 +0,0 @@ -# -# 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. -# - -CC = g++ - -TARGETS = -include file.list - -PKGS = dali-core -include ../../rules.mk -include ../../coverage.mk - -all: $(TARGETS) - -%: %.cpp - $(CC) -o $@ $< ../../dali-test-suite-utils/test-application.cpp $(CXXFLAGS) $(LDFLAGS) - - -clean: - @rm -f $(notdir $(TARGETS)) - @rm -f tet_captured - @rm -f *~ - @rm -f *.gcda *.gcno - -coverage: - @lcov --directory . -c -o dali.info - @lcov --remove dali.info "*boost*" "/usr/include/*" "*/automated-tests/*" -o dali.info diff --git a/automated-tests/TET/dali-test-suite/material/.gitignore b/automated-tests/TET/dali-test-suite/material/.gitignore deleted file mode 100644 index d0e475b..0000000 --- a/automated-tests/TET/dali-test-suite/material/.gitignore +++ /dev/null @@ -1 +0,0 @@ -utc-Dali-Material diff --git a/automated-tests/TET/dali-test-suite/material/Makefile b/automated-tests/TET/dali-test-suite/material/Makefile deleted file mode 120000 index c88d5a7..0000000 --- a/automated-tests/TET/dali-test-suite/material/Makefile +++ /dev/null @@ -1 +0,0 @@ -../master-makefile.mk \ No newline at end of file diff --git a/automated-tests/TET/dali-test-suite/material/file.list b/automated-tests/TET/dali-test-suite/material/file.list deleted file mode 100644 index aa20a08..0000000 --- a/automated-tests/TET/dali-test-suite/material/file.list +++ /dev/null @@ -1,2 +0,0 @@ -TARGETS += \ - utc-Dali-Material \ diff --git a/automated-tests/TET/dali-test-suite/material/tslist b/automated-tests/TET/dali-test-suite/material/tslist deleted file mode 100644 index a0eee2a..0000000 --- a/automated-tests/TET/dali-test-suite/material/tslist +++ /dev/null @@ -1 +0,0 @@ -/dali-test-suite/material/utc-Dali-Material diff --git a/automated-tests/TET/dali-test-suite/material/utc-Dali-Material.cpp b/automated-tests/TET/dali-test-suite/material/utc-Dali-Material.cpp deleted file mode 100644 index dbffbd7..0000000 --- a/automated-tests/TET/dali-test-suite/material/utc-Dali-Material.cpp +++ /dev/null @@ -1,361 +0,0 @@ -// -// 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 - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( UtcDaliMaterialNew01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMaterialDownCast, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMaterialSettersAndGetters, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMaterialStage01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMaterialStage01MemCheck, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMaterialStage02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMaterialStage02MemCheck, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - - -// Positive test case for a method -static void UtcDaliMaterialNew01() -{ - 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; -} - - -static void UtcDaliMaterialDownCast() -{ - TestApplication application; - - Material material = Material::New("material"); - BaseHandle handle(material); - - Material mat2 = Material::DownCast( handle ); - DALI_TEST_CHECK( mat2 ); -} - -static void UtcDaliMaterialSettersAndGetters() -{ - 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 ); -} - -static void CreateMeshData(MeshData& meshData, Material material) -{ - 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); - meshData.SetData(vertices, faces, bones, material); - meshData.SetHasNormals(true); - meshData.SetHasTextureCoords(true); -} - - -static void UtcDaliMaterialStage01() -{ - 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(); - - MeshData meshData; - CreateMeshData(meshData, material); - Mesh mesh = Mesh::New(meshData); - 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 ) ); -} - - -static void UtcDaliMaterialStage01MemCheck() -{ - TestApplication application; - tet_result(TET_PASS); -} - -static void UtcDaliMaterialStage02() -{ - 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 ); - - MeshData meshData; - CreateMeshData(meshData, material); - Mesh mesh = Mesh::New(meshData); - 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 -} - - -static void UtcDaliMaterialStage02MemCheck() -{ - TestApplication application; - tet_result(TET_PASS); -} diff --git a/automated-tests/TET/dali-test-suite/math/.gitignore b/automated-tests/TET/dali-test-suite/math/.gitignore deleted file mode 100644 index fc02edf..0000000 --- a/automated-tests/TET/dali-test-suite/math/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -utc-Dali-Rotation -utc-Dali-Quaternion -utc-Dali-Random -utc-Dali-Vector2 -utc-Dali-Vector3 -utc-Dali-Vector4 -utc-Dali-Matrix -utc-Dali-Matrix3 -utc-Dali-MathUtils -utc-Dali-Radian -utc-Dali-Degree -utc-Dali-Rect -utc-Dali-AngleAxis - diff --git a/automated-tests/TET/dali-test-suite/math/Makefile b/automated-tests/TET/dali-test-suite/math/Makefile deleted file mode 120000 index c88d5a7..0000000 --- a/automated-tests/TET/dali-test-suite/math/Makefile +++ /dev/null @@ -1 +0,0 @@ -../master-makefile.mk \ No newline at end of file diff --git a/automated-tests/TET/dali-test-suite/math/file.list b/automated-tests/TET/dali-test-suite/math/file.list deleted file mode 100644 index 7ed1995..0000000 --- a/automated-tests/TET/dali-test-suite/math/file.list +++ /dev/null @@ -1,13 +0,0 @@ -TARGETS += \ - utc-Dali-Matrix \ - utc-Dali-Matrix3 \ - utc-Dali-Quaternion \ - utc-Dali-Random \ - utc-Dali-Vector2 \ - utc-Dali-Vector3 \ - utc-Dali-Vector4 \ - utc-Dali-MathUtils \ - utc-Dali-Radian \ - utc-Dali-Degree \ - utc-Dali-Rect \ - utc-Dali-AngleAxis \ diff --git a/automated-tests/TET/dali-test-suite/math/tslist b/automated-tests/TET/dali-test-suite/math/tslist deleted file mode 100644 index 20efbd4..0000000 --- a/automated-tests/TET/dali-test-suite/math/tslist +++ /dev/null @@ -1,13 +0,0 @@ -/dali-test-suite/math/utc-Dali-Vector2 -/dali-test-suite/math/utc-Dali-Vector3 -/dali-test-suite/math/utc-Dali-Vector4 -/dali-test-suite/math/utc-Dali-Matrix -/dali-test-suite/math/utc-Dali-Matrix3 -/dali-test-suite/math/utc-Dali-Quaternion -/dali-test-suite/math/utc-Dali-Random -/dali-test-suite/math/utc-Dali-MathUtils -/dali-test-suite/math/utc-Dali-Radian -/dali-test-suite/math/utc-Dali-Degree -/dali-test-suite/math/utc-Dali-Rect -/dali-test-suite/math/utc-Dali-AngleAxis - diff --git a/automated-tests/TET/dali-test-suite/math/utc-Dali-AngleAxis.cpp b/automated-tests/TET/dali-test-suite/math/utc-Dali-AngleAxis.cpp deleted file mode 100644 index 561794d..0000000 --- a/automated-tests/TET/dali-test-suite/math/utc-Dali-AngleAxis.cpp +++ /dev/null @@ -1,132 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void UtcDaliAngleAxisNew01(); -static void UtcDaliAngleAxisNew02(); -static void UtcDaliAngleAxisNew03(); -static void UtcDaliAngleAxisCopy(); -static void UtcDaliAngleAxisAssign(); - - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -// Add test functionality for all APIs in the class (Positive and Negative) -extern "C" { - struct tet_testlist tet_testlist[] = { - { UtcDaliAngleAxisNew01, POSITIVE_TC_IDX }, - { UtcDaliAngleAxisNew02, POSITIVE_TC_IDX }, - { UtcDaliAngleAxisNew03, POSITIVE_TC_IDX }, - { UtcDaliAngleAxisAssign, POSITIVE_TC_IDX }, - { UtcDaliAngleAxisCopy, POSITIVE_TC_IDX }, - { NULL, 0 } - }; -} - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - - - -static void UtcDaliAngleAxisNew01() -{ - 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); -} - - - -static void UtcDaliAngleAxisNew02() -{ - 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); -} - - -static void UtcDaliAngleAxisNew03() -{ - 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); -} - -static void UtcDaliAngleAxisAssign() -{ - 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); -} - -static void UtcDaliAngleAxisCopy() -{ - 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); -} diff --git a/automated-tests/TET/dali-test-suite/math/utc-Dali-Degree.cpp b/automated-tests/TET/dali-test-suite/math/utc-Dali-Degree.cpp deleted file mode 100644 index ebab1d2..0000000 --- a/automated-tests/TET/dali-test-suite/math/utc-Dali-Degree.cpp +++ /dev/null @@ -1,174 +0,0 @@ -#include - -#include -#include - -#include - -#include - -using namespace Dali; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliDegreeConstructors01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliDegreeComparison01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliDegreeCastOperators01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliDegreeCastOperatorEquals, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliDegreeCastOperatorNotEquals, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliDegreeCastOperatorLessThan, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - - -// Positive test case for constructors -static void UtcDaliDegreeConstructors01() -{ - 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 ); -} - -// Positive test case for comparison -static void UtcDaliDegreeComparison01() -{ - 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 ); - -} - - -// test case for cast operators -static void UtcDaliDegreeCastOperators01() -{ - 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 ); -} - - - -static void UtcDaliDegreeCastOperatorEquals() -{ - 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); -} - -static void UtcDaliDegreeCastOperatorNotEquals() -{ - 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); -} - -static void UtcDaliDegreeCastOperatorLessThan() -{ - 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); -} diff --git a/automated-tests/TET/dali-test-suite/math/utc-Dali-MathUtils.cpp b/automated-tests/TET/dali-test-suite/math/utc-Dali-MathUtils.cpp deleted file mode 100644 index 5054bab..0000000 --- a/automated-tests/TET/dali-test-suite/math/utc-Dali-MathUtils.cpp +++ /dev/null @@ -1,284 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -// Add test functionality for all APIs in the class (Positive and Negative) -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( UtcDaliMathUtilsNextPowerOfTwo, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMathUtilsIsPowerOfTwo, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMathUtilsGetRangedEpsilon, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMathUtilsRound, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMathUtilsClamp, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMathUtilsWrapInDomain, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMathUtilsShortestDistanceInDomain, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMathUtilsEquals, POSITIVE_TC_IDX ); - - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -// Positive test case for a method -static void UtcDaliMathUtilsNextPowerOfTwo() -{ - 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); -} - - -// Positive test case for a method -static void UtcDaliMathUtilsIsPowerOfTwo() -{ - 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); -} - - - -// Positive test case for a method -static void UtcDaliMathUtilsGetRangedEpsilon() -{ - 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); - - -} - -// Positive test case for a method -static void UtcDaliMathUtilsRound() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliMathUtilsClamp() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliMathUtilsWrapInDomain() -{ - 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); -} - -// Positive test case for a method -static void UtcDaliMathUtilsShortestDistanceInDomain() -{ - 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); -} - -static void UtcDaliMathUtilsEquals() -{ - 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 )) ); -} diff --git a/automated-tests/TET/dali-test-suite/math/utc-Dali-Matrix.cpp b/automated-tests/TET/dali-test-suite/math/utc-Dali-Matrix.cpp deleted file mode 100644 index 9a692fe..0000000 --- a/automated-tests/TET/dali-test-suite/math/utc-Dali-Matrix.cpp +++ /dev/null @@ -1,766 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliMatrixCtor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixGetXAxis, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixGetYAxis, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixGetZAxis, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixGetTranslation, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixGetTranslation3, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixInvert01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixInvert02, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixInvertTransform01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixInvertTransform02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixOrthoNormalize0, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixOrthoNormalize1, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixSetIdentity, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixSetIdentityAndScale, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixSetXAxis, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixSetYAxis, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixSetZAxis, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixSetTranslation, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixSetTranslation3, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixTranspose, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixOStreamOperator, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixMultiply, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixOperatorMultiply01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixOperatorMultiply02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixOperatorEquals, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixOperatorNotEquals, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixGetTransformComponents01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixGetTransformComponents02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixSetTransformComponents01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixSetInverseTransformComponent01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliMatrixSetInverseTransformComponent02, POSITIVE_TC_IDX ); - - - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -static void UtcDaliMatrixCtor() -{ - // 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); -} - -// OrthoNormalise fixes floating point errors from matrix rotations -static void UtcDaliMatrixOrthoNormalize0() -{ - 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); -} - -// OrthoNormalize is not flipping the axes and is maintaining the translation -static void UtcDaliMatrixOrthoNormalize1() -{ - 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); - } -} - -// Invert works -static void UtcDaliMatrixInvert01() -{ - // 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); - } -} - - -static void UtcDaliMatrixInvert02() -{ - Matrix m1 = Matrix::IDENTITY; - m1.SetXAxis(Vector3(0.0f, 0.0f, 0.0f)); - DALI_TEST_EQUALS(m1.Invert(), false, TEST_LOCATION); -} - - -// Invert transform works -static void UtcDaliMatrixInvertTransform01() -{ - 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); - } -} - - -// Invert transform works -static void UtcDaliMatrixInvertTransform02() -{ - 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 ); - } -} - - -// GetXAxis -static void UtcDaliMatrixGetXAxis() -{ - 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)); -} - -// GetYAxis -static void UtcDaliMatrixGetYAxis() -{ - 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)); -} - -// GetZAxis -static void UtcDaliMatrixGetZAxis() -{ - 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)); -} - -// GetTranslation -static void UtcDaliMatrixGetTranslation() -{ - 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); -} - -// GetTranslation -static void UtcDaliMatrixGetTranslation3() -{ - 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); -} - -// SetIdentity -static void UtcDaliMatrixSetIdentity() -{ - 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); -} - - -static void UtcDaliMatrixSetIdentityAndScale() -{ - 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); -} - - -// SetXAxis -static void UtcDaliMatrixSetXAxis() -{ - Matrix m; - Vector3 v(2.0f, 3.0f, 4.0f); - m.SetXAxis(v); - - DALI_TEST_CHECK(m.GetXAxis() == v); -} - -// SetYAxis -static void UtcDaliMatrixSetYAxis() -{ - Matrix m; - Vector3 v(2.0f, 3.0f, 4.0f); - m.SetYAxis(v); - - DALI_TEST_CHECK(m.GetYAxis() == v); -} - -// SetZAxis -static void UtcDaliMatrixSetZAxis() -{ - Matrix m; - Vector3 v(2.0f, 3.0f, 4.0f); - m.SetZAxis(v); - - DALI_TEST_CHECK(m.GetZAxis() == v); -} - -// SetTranslation -static void UtcDaliMatrixSetTranslation() -{ - Matrix m; - Vector4 v(2.0f, 3.0f, 4.0f, 5.0f); - m.SetTranslation(v); - - DALI_TEST_CHECK(m.GetTranslation() == v); -} - -// SetTranslation -static void UtcDaliMatrixSetTranslation3() -{ - Matrix m; - Vector3 v(2.0f, 3.0f, 4.0f); - m.SetTranslation(v); - - DALI_TEST_CHECK(m.GetTranslation3() == v); -} - - - -// Transpose -static void UtcDaliMatrixTranspose() -{ - 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); -} - -static void UtcDaliMatrixOStreamOperator() -{ - 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); -} - -static void UtcDaliMatrixMultiply() -{ - 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 r1(els); - - Quaternion q(Radian(Degree(45.0f)), Vector3::XAXIS); - Matrix m2(false); - Matrix::Multiply(m2, m1, q); - DALI_TEST_EQUALS(m2, r1, 0.01f, TEST_LOCATION); -} - -static void UtcDaliMatrixOperatorMultiply01() -{ - TestApplication application; - 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); -} - -static void UtcDaliMatrixOperatorMultiply02() -{ - 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); -} - - -static void UtcDaliMatrixOperatorEquals() -{ - 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); - } -} - - -static void UtcDaliMatrixOperatorNotEquals() -{ - 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)); -} - -static void UtcDaliMatrixGetTransformComponents01() -{ - 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); -} - - -static void UtcDaliMatrixGetTransformComponents02() -{ - // 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); - } - } - } - } -} - -static void UtcDaliMatrixSetTransformComponents01() -{ - // 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); - } - } - } - } -} - - -static void UtcDaliMatrixSetInverseTransformComponent01() -{ - // 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); - } - } - } - } -} - -static void UtcDaliMatrixSetInverseTransformComponent02() -{ - // 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); - } - } - } - } -} diff --git a/automated-tests/TET/dali-test-suite/math/utc-Dali-Matrix3.cpp b/automated-tests/TET/dali-test-suite/math/utc-Dali-Matrix3.cpp deleted file mode 100644 index 67840bf..0000000 --- a/automated-tests/TET/dali-test-suite/math/utc-Dali-Matrix3.cpp +++ /dev/null @@ -1,420 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void UtcDaliMatrix3FromMatrix(); -static void UtcDaliMatrix3OperatorAssign01(); -static void UtcDaliMatrix3OperatorAssign02(); -static void UtcDaliMatrix3AsFloat(); -static void UtcDaliMatrix3Invert(); -static void UtcDaliMatrix3Transpose(); -static void UtcDaliMatrix3Scale(); -static void UtcDaliMatrix3SetIdentity(); -static void UtcDaliMatrix3Magnitude(); -static void UtcDaliMatrix3ScaleInverseTranspose(); -static void UtcDaliMatrix3OStreamOperator(); -static void UtcDaliMatrix3Multiply(); -static void UtcDaliMatrix3EqualityOperator(); -static void UtcDaliMatrix3InequalityOperator(); - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -// Add test functionality for all APIs in the class (Positive and Negative) -extern "C" { - struct tet_testlist tet_testlist[] = { - { UtcDaliMatrix3FromMatrix, POSITIVE_TC_IDX }, - { UtcDaliMatrix3OperatorAssign01, POSITIVE_TC_IDX }, - { UtcDaliMatrix3OperatorAssign02, POSITIVE_TC_IDX }, - { UtcDaliMatrix3AsFloat, POSITIVE_TC_IDX }, - { UtcDaliMatrix3Invert, POSITIVE_TC_IDX }, - { UtcDaliMatrix3Transpose, POSITIVE_TC_IDX }, - { UtcDaliMatrix3Scale, POSITIVE_TC_IDX }, - { UtcDaliMatrix3Magnitude, POSITIVE_TC_IDX }, - { UtcDaliMatrix3SetIdentity, POSITIVE_TC_IDX }, - { UtcDaliMatrix3ScaleInverseTranspose, POSITIVE_TC_IDX }, - { UtcDaliMatrix3OStreamOperator, POSITIVE_TC_IDX }, - { UtcDaliMatrix3Multiply, POSITIVE_TC_IDX }, - { UtcDaliMatrix3EqualityOperator, POSITIVE_TC_IDX }, - { UtcDaliMatrix3InequalityOperator, POSITIVE_TC_IDX }, - { NULL, 0 } - }; -} - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - - -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 }; - - -static void UtcDaliMatrix3FromMatrix() -{ - 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); -} - -static void UtcDaliMatrix3OperatorAssign01() -{ - 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); -} - - -static void UtcDaliMatrix3OperatorAssign02() -{ - 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); -} - - - -// AsFloat -static void UtcDaliMatrix3AsFloat() -{ - 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); - } -} - - -// Invert works -static void UtcDaliMatrix3Invert() -{ - // 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 inv1 = *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 m4(els); - m4.Invert(); - Matrix inv2(m4); - - Matrix3 mInv = m; - mInv.Invert(); - - DALI_TEST_EQUALS(mInv, inv1, 0.01f, TEST_LOCATION); - DALI_TEST_EQUALS(mInv, inv2, 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); - } -} - -static void UtcDaliMatrix3Transpose() -{ - 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); - } -} - -// SetIdentity -static void UtcDaliMatrix3SetIdentity() -{ - 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); -} - - -static void UtcDaliMatrix3Scale() -{ - 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); -} - -static void UtcDaliMatrix3Magnitude() -{ - 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); -} - - - -static void UtcDaliMatrix3ScaleInverseTranspose() -{ - 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); - } -} - -static void UtcDaliMatrix3OStreamOperator() -{ - 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); -} - -static void UtcDaliMatrix3Multiply() -{ - 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); -} - -static void UtcDaliMatrix3EqualityOperator() -{ - 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); -} - -static void UtcDaliMatrix3InequalityOperator() -{ - 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); -} - diff --git a/automated-tests/TET/dali-test-suite/math/utc-Dali-Quaternion.cpp b/automated-tests/TET/dali-test-suite/math/utc-Dali-Quaternion.cpp deleted file mode 100644 index ab4f81f..0000000 --- a/automated-tests/TET/dali-test-suite/math/utc-Dali-Quaternion.cpp +++ /dev/null @@ -1,1115 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void UtcDaliQuaternionOStreamOperator(); - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliQuaternionCtor01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionCtor02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionCtor03, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionFromAxisAngle, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionToAxisAngle01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionToAxisAngle02, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionToAxisAngle03, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionToAxisAngle04, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionEulerAngles, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionLength, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionLengthSquared, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionNormalize, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionNormalized, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionConjugate, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionInvert, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionToMatrix01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionToMatrix02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionFromMatrix01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionFromMatrix02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionFromAxes01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionFromAxes02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionOperatorAddition, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionOperatorSubtraction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionOperatorMultiplication01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionOperatorMultiplication02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionOperatorScale01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionOperatorScale02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionOperatorNegation, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionOperatorAddAssign, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionOperatorSubtractAssign, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionOperatorMultiplyAssign, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionOperatorScaleAssign01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionOperatorScaleAssign02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionOperatorDivision, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionOperatorEquality, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionOperatorInequality, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionDot, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionExp01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionExp02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionExp03, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionLog01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionLog02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionRotate01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionRotate02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionLerp, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionSlerp01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionSlerp02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionSlerp03, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionSlerp04, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionSlerpNoInvert01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionSlerpNoInvert02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionSquad, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAngleBetween, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliQuaternionOStreamOperator, POSITIVE_TC_IDX ); - - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - - -static void UtcDaliQuaternionCtor01() -{ - 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); -} - -static void UtcDaliQuaternionCtor02() -{ - 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); -} - - -static void UtcDaliQuaternionCtor03() -{ - 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); -} - - -static void UtcDaliQuaternionFromAxisAngle() -{ - 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); -} - -static void UtcDaliQuaternionToAxisAngle01() -{ - 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); -} - -static void UtcDaliQuaternionToAxisAngle02() -{ - 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); -} - - -static void UtcDaliQuaternionToAxisAngle03() -{ - 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); -} - -static void UtcDaliQuaternionToAxisAngle04() -{ - 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); -} - - - -static void UtcDaliQuaternionEulerAngles() -{ - 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); -} - - -static void UtcDaliQuaternionToMatrix01() -{ - 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); -} - -static void UtcDaliQuaternionToMatrix02() -{ - 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); -} - - -static void UtcDaliQuaternionFromMatrix01() -{ - 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); -} - -static void UtcDaliQuaternionFromMatrix02() -{ - 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); - } - } - } -} - -static void UtcDaliQuaternionFromAxes01() -{ - 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); -} - - -static void UtcDaliQuaternionFromAxes02() -{ - 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); - } - } - } -} - -static void UtcDaliQuaternionOperatorAddition() -{ - 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); -} - -static void UtcDaliQuaternionOperatorSubtraction() -{ - 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); -} - -static void UtcDaliQuaternionConjugate() -{ - 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); -} - -static void UtcDaliQuaternionOperatorMultiplication01() -{ - 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); -} - -static void UtcDaliQuaternionOperatorDivision() -{ - 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); -} - -static void UtcDaliQuaternionOperatorScale01() -{ - 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); -} - -static void UtcDaliQuaternionOperatorScale02() -{ - 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); -} - -static void UtcDaliQuaternionOperatorNegation() -{ - 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); -} - -static void UtcDaliQuaternionOperatorAddAssign() -{ - 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); -} - -static void UtcDaliQuaternionOperatorSubtractAssign() -{ - 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); -} - -static void UtcDaliQuaternionOperatorMultiplyAssign() -{ - 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); -} - -static void UtcDaliQuaternionOperatorScaleAssign01() -{ - 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); -} - -static void UtcDaliQuaternionOperatorScaleAssign02() -{ - 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); -} - -static void UtcDaliQuaternionOperatorEquality() -{ - 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) ); -} - -static void UtcDaliQuaternionOperatorInequality() -{ - 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 ); -} - -static void UtcDaliQuaternionLength() -{ - 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); -} - -static void UtcDaliQuaternionLengthSquared() -{ - 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); -} - -static void UtcDaliQuaternionNormalize() -{ - 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); -} - -static void UtcDaliQuaternionNormalized() -{ - 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); -} - -static void UtcDaliQuaternionInvert() -{ - 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); -} - - -static void UtcDaliQuaternionDot() -{ - 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); -} - - -// Quaternion * vector == Vector rotation -static void UtcDaliQuaternionOperatorMultiplication02() -{ - 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); -} - -static void UtcDaliQuaternionRotate01() -{ - 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); -} - - -static void UtcDaliQuaternionRotate02() -{ - 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); -} - - -static void UtcDaliQuaternionExp01() -{ - 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); -} - - -static void UtcDaliQuaternionExp02() -{ - 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); -} - - -static void UtcDaliQuaternionExp03() -{ - 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); - } -} - - -static void UtcDaliQuaternionLog01() -{ - 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); -} - -static void UtcDaliQuaternionLog02() -{ - 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); -} - - - -static void UtcDaliQuaternionLerp() -{ - 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); -} - - - -static void UtcDaliQuaternionSlerp01() -{ - 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); -} - - - -static void UtcDaliQuaternionSlerp02() -{ - 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 ); -} - - -static void UtcDaliQuaternionSlerp03() -{ - 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); -} - - - -static void UtcDaliQuaternionSlerp04() -{ - 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); -} - - - -static void UtcDaliQuaternionSlerpNoInvert01() -{ - 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); -} - - -static void UtcDaliQuaternionSlerpNoInvert02() -{ - 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); -} - - -static void UtcDaliQuaternionSquad() -{ - 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); -} - -static void UtcDaliAngleBetween() -{ - 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); -} - -static void UtcDaliQuaternionOStreamOperator() -{ - 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); -} diff --git a/automated-tests/TET/dali-test-suite/math/utc-Dali-Radian.cpp b/automated-tests/TET/dali-test-suite/math/utc-Dali-Radian.cpp deleted file mode 100644 index 941b26a..0000000 --- a/automated-tests/TET/dali-test-suite/math/utc-Dali-Radian.cpp +++ /dev/null @@ -1,178 +0,0 @@ -#include - -#include -#include - -#include - -#include - -using namespace Dali; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliRadianConstructors01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRadianComparison01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRadianCastOperators01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRadianCastOperatorEquals, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRadianCastOperatorNotEquals, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRadianCastOperatorLessThan, POSITIVE_TC_IDX ); - - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - - -// Positive test case for constructors -static void UtcDaliRadianConstructors01() -{ - 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 ); -} - -// Positive test case for comparison -static void UtcDaliRadianComparison01() -{ - 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 ); - -} - - -// test case for cast operators -static void UtcDaliRadianCastOperators01() -{ - 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 ); -} - - -static void UtcDaliRadianCastOperatorEquals() -{ - 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); -} - -static void UtcDaliRadianCastOperatorNotEquals() -{ - 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); -} - -static void UtcDaliRadianCastOperatorLessThan() -{ - 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); -} diff --git a/automated-tests/TET/dali-test-suite/math/utc-Dali-Random.cpp b/automated-tests/TET/dali-test-suite/math/utc-Dali-Random.cpp deleted file mode 100644 index 0f2b514..0000000 --- a/automated-tests/TET/dali-test-suite/math/utc-Dali-Random.cpp +++ /dev/null @@ -1,133 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void UtcDaliRandomRangeMethod(); -static void UtcDaliRandomAxisMethod(); -static void UtcDaliRandomChanceMethod(); - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -// Add test functionality for all APIs in the class (Positive and Negative) -extern "C" { - struct tet_testlist tet_testlist[] = { - { UtcDaliRandomRangeMethod, POSITIVE_TC_IDX }, - { UtcDaliRandomAxisMethod, POSITIVE_TC_IDX }, - { UtcDaliRandomChanceMethod, POSITIVE_TC_IDX }, - { NULL, 0 } - }; -} - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - - -static void UtcDaliRandomRangeMethod() -{ - 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); - } -} - - -static void UtcDaliRandomAxisMethod() -{ - 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); - } -} - -static void UtcDaliRandomChanceMethod() -{ - 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); -} diff --git a/automated-tests/TET/dali-test-suite/math/utc-Dali-Rect.cpp b/automated-tests/TET/dali-test-suite/math/utc-Dali-Rect.cpp deleted file mode 100644 index 15e75e4..0000000 --- a/automated-tests/TET/dali-test-suite/math/utc-Dali-Rect.cpp +++ /dev/null @@ -1,320 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void UtcDaliRectCons01(); -static void UtcDaliRectCons02(); -static void UtcDaliRectCons03(); -static void UtcDaliRectCons04(); -static void UtcDaliRectSet(); -static void UtcDaliRectIsEmpty(); -static void UtcDaliRectRight(); -static void UtcDaliRectBottom(); -static void UtcDaliRectArea(); -static void UtcDaliRectIntersects(); -static void UtcDaliRectContains(); -static void UtcDaliRectOperatorNotEquals(); -static void UtcDaliRectOperatorEquals(); - - -enum { - POSITIVE_IDX = 0x01, - NEGATIVE_IDX, -}; - -// Add test functionality for all APIs in the class (Positive and Negative) -extern "C" { - struct tet_testlist tet_testlist[] = { - { UtcDaliRectCons01 , POSITIVE_IDX}, - { UtcDaliRectCons02 , POSITIVE_IDX}, - { UtcDaliRectCons03 , POSITIVE_IDX}, - { UtcDaliRectCons04 , POSITIVE_IDX}, - { UtcDaliRectSet , POSITIVE_IDX}, - { UtcDaliRectIsEmpty , POSITIVE_IDX}, - { UtcDaliRectRight , POSITIVE_IDX}, - { UtcDaliRectBottom , POSITIVE_IDX}, - { UtcDaliRectArea , POSITIVE_IDX}, - { UtcDaliRectIntersects , POSITIVE_IDX}, - { UtcDaliRectContains , POSITIVE_IDX}, - { UtcDaliRectOperatorNotEquals, POSITIVE_IDX}, - { UtcDaliRectOperatorEquals, POSITIVE_IDX}, - { NULL, 0 } - }; -} - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - - -// Positive test case for a method -static void UtcDaliRectCons01() -{ - 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); -} - -static void UtcDaliRectCons02() -{ - 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); -} - -static void UtcDaliRectCons03() -{ - 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); -} - -static void UtcDaliRectCons04() -{ - 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); -} - -static void UtcDaliRectSet() -{ - 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); -} - -static void UtcDaliRectIsEmpty() -{ - 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()); -} - -static void UtcDaliRectRight() -{ - TestApplication application; - - Rect rf(10.0f, 20.0f, 400.0f, 200.0f); - - DALI_TEST_EQUALS(rf.Right(), 410.0f, 0.001, TEST_LOCATION); -} - - -static void UtcDaliRectBottom() -{ - TestApplication application; - - Rect rf(10.0f, 20.0f, 400.0f, 200.0f); - - DALI_TEST_EQUALS(rf.Bottom(), 220.0f, 0.001, TEST_LOCATION); -} - - -static void UtcDaliRectArea() -{ - TestApplication application; - - Rect rf(10.0f, 20.0f, 400.0f, 200.0f); - - DALI_TEST_EQUALS(rf.Area(), 80000.0f, 0.001, TEST_LOCATION); -} - - -static void UtcDaliRectIntersects() -{ - 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)); -} - - - -static void UtcDaliRectContains() -{ - 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)); -} - - -static void UtcDaliRectOperatorNotEquals() -{ - 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); -} - - -static void UtcDaliRectOperatorEquals() -{ - 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); -} - - - - - diff --git a/automated-tests/TET/dali-test-suite/math/utc-Dali-Vector2.cpp b/automated-tests/TET/dali-test-suite/math/utc-Dali-Vector2.cpp deleted file mode 100644 index f9a9f6b..0000000 --- a/automated-tests/TET/dali-test-suite/math/utc-Dali-Vector2.cpp +++ /dev/null @@ -1,459 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void UtcDaliVector2Cons(); - -static void UtcDaliVector2FitInside(); -static void UtcDaliVector2FitScaleToFill(); -static void UtcDaliVector2ShrinkInside(); - -static void UtcDaliVector2Add(); -static void UtcDaliVector2Subtract(); -static void UtcDaliVector2Negate(); -static void UtcDaliVector2Multiply(); -static void UtcDaliVector2Divide(); -static void UtcDaliVector2Scale(); -static void UtcDaliVector2Equals(); -static void UtcDaliVector2Length(); -static void UtcDaliVector2LengthSquared(); -static void UtcDaliVector2Max(); -static void UtcDaliVector2Min(); -static void UtcDaliVector2Clamp(); -static void UtcDaliVector2ClampVector2(); -static void UtcDaliVector2Normalize(); - -static void UtcDaliVector2OperatorSubscript(); - -static void UtcDaliVector2OStreamOperator(); - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -// Add test functionality for all APIs in the class (Positive and Negative) -extern "C" { - struct tet_testlist tet_testlist[] = { - { UtcDaliVector2Cons, POSITIVE_TC_IDX }, - - { UtcDaliVector2FitInside, POSITIVE_TC_IDX }, - { UtcDaliVector2FitScaleToFill, POSITIVE_TC_IDX }, - { UtcDaliVector2ShrinkInside, POSITIVE_TC_IDX }, - - { UtcDaliVector2Add, POSITIVE_TC_IDX }, - { UtcDaliVector2Subtract, POSITIVE_TC_IDX }, - { UtcDaliVector2Negate, POSITIVE_TC_IDX }, - { UtcDaliVector2Multiply, POSITIVE_TC_IDX }, - { UtcDaliVector2Divide, POSITIVE_TC_IDX }, - { UtcDaliVector2Scale, POSITIVE_TC_IDX }, - { UtcDaliVector2Equals, POSITIVE_TC_IDX }, - { UtcDaliVector2Length, POSITIVE_TC_IDX }, - { UtcDaliVector2LengthSquared, POSITIVE_TC_IDX }, - { UtcDaliVector2Max, POSITIVE_TC_IDX }, - { UtcDaliVector2Min, POSITIVE_TC_IDX }, - { UtcDaliVector2Clamp, POSITIVE_TC_IDX }, - { UtcDaliVector2ClampVector2, POSITIVE_TC_IDX }, - { UtcDaliVector2Normalize, POSITIVE_TC_IDX }, - - { UtcDaliVector2OperatorSubscript, POSITIVE_TC_IDX }, - - { UtcDaliVector2OStreamOperator, POSITIVE_TC_IDX }, - - { NULL, 0 } - }; -} - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - - -static void UtcDaliVector2Cons() -{ - 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); -} - - -static void UtcDaliVector2FitInside() -{ - 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 ); -} - -static void UtcDaliVector2FitScaleToFill() -{ - 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 ); -} - -static void UtcDaliVector2ShrinkInside() -{ - 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 ); -} - - - - -static void UtcDaliVector2Add() -{ - 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); -} - - -// Subtract -static void UtcDaliVector2Subtract() -{ - 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); -} - - -static void UtcDaliVector2Negate() -{ - Vector2 v1(10.0f, 20.0f); - Vector2 r0(-10.0f, -20.0f); - - Vector2 v2 = -v1; - DALI_TEST_EQUALS(v2, r0, TEST_LOCATION); -} - - -// Multiply -static void UtcDaliVector2Multiply() -{ - 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); -} - -// Divide -static void UtcDaliVector2Divide() -{ - 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); - -} - -static void UtcDaliVector2Scale() -{ - 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); -} - -// Equals -static void UtcDaliVector2Equals() -{ - 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); -} - -// Length -static void UtcDaliVector2Length() -{ - 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); -} - -// Length squared -static void UtcDaliVector2LengthSquared() -{ - 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); -} - -// Max -static void UtcDaliVector2Max() -{ - 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); -} - -// Min -static void UtcDaliVector2Min() -{ - 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); -} - -static void UtcDaliVector2Clamp() -{ - 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 ); -} - -static void UtcDaliVector2ClampVector2() -{ - 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 ); -} - -// Normalize -static void UtcDaliVector2Normalize() -{ - 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); -} - -static void UtcDaliVector2OperatorSubscript() -{ - 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); - } - - -} - -static void UtcDaliVector2OStreamOperator() -{ - std::ostringstream oss; - - Vector2 vector(1, 2); - - oss << vector; - - std::string expectedOutput = "[1, 2]"; - - DALI_TEST_EQUALS( oss.str(), expectedOutput, TEST_LOCATION); -} diff --git a/automated-tests/TET/dali-test-suite/math/utc-Dali-Vector3.cpp b/automated-tests/TET/dali-test-suite/math/utc-Dali-Vector3.cpp deleted file mode 100644 index c4dc223..0000000 --- a/automated-tests/TET/dali-test-suite/math/utc-Dali-Vector3.cpp +++ /dev/null @@ -1,624 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliVector3Cons, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3Assign, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3Add, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3Constants, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3Cross, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3Dot, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3Equals, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3Length, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3LengthSquared, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3Max, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3Min, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3Clamp, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3ClampVector3, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3Multiply, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3Divide, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3Scale, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3Normalize, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3Subtract, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3OperatorSubscript, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3OStreamOperator, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3Rotate, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3AsFloat, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3AsVectorXY, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3FitKeepAspectRatio, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3FillKeepAspectRatio, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3FillXYKeepAspectRatio, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector3ShrinkInsideKeepAspectRatio, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -static void UtcDaliVector3Cons() -{ - 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); -} - -static void UtcDaliVector3Assign() -{ - 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); -} - - -// Add -static void UtcDaliVector3Add() -{ - 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); -} - -// Constants -static void UtcDaliVector3Constants() -{ - 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); -} - -// Cross -static void UtcDaliVector3Cross() -{ - 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); -} - -// Dot -static void UtcDaliVector3Dot() -{ - 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); -} - - -// Equals -static void UtcDaliVector3Equals() -{ - 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); -} - - -// Length -static void UtcDaliVector3Length() -{ - 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); -} - -// Length squared -static void UtcDaliVector3LengthSquared() -{ - 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); -} - -// Max -static void UtcDaliVector3Max() -{ - 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); -} - -// Min -static void UtcDaliVector3Min() -{ - 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); -} - -static void UtcDaliVector3Clamp() -{ - 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 ); -} - -static void UtcDaliVector3ClampVector3() -{ - 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 ); -} - -// Multiply -static void UtcDaliVector3Multiply() -{ - 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); -} - - -// Divide -static void UtcDaliVector3Divide() -{ - 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); - -} - -static void UtcDaliVector3Scale() -{ - 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); -} - - - -// Normalize -static void UtcDaliVector3Normalize() -{ - 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); -} - -// Subtract -static void UtcDaliVector3Subtract() -{ - 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); -} - -static void UtcDaliVector3OperatorSubscript() -{ - 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); - } - -} - -static void UtcDaliVector3OStreamOperator() -{ - std::ostringstream oss; - - Vector3 vector(1, 2, 3); - - oss << vector; - - std::string expectedOutput = "[1, 2, 3]"; - - DALI_TEST_EQUALS( oss.str(), expectedOutput, TEST_LOCATION); -} - -static void UtcDaliVector3Rotate() -{ - 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 ); -} - -static void UtcDaliVector3AsFloat() -{ - 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); - } -} - -static void UtcDaliVector3AsVectorXY() -{ - 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); -} - - -static void UtcDaliVector3FitKeepAspectRatio() -{ - 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 ); -} - -static void UtcDaliVector3FillKeepAspectRatio() -{ - 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 ); - -} - -static void UtcDaliVector3FillXYKeepAspectRatio() -{ - 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 ); - -} - -static void UtcDaliVector3ShrinkInsideKeepAspectRatio() -{ - 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 ); -} diff --git a/automated-tests/TET/dali-test-suite/math/utc-Dali-Vector4.cpp b/automated-tests/TET/dali-test-suite/math/utc-Dali-Vector4.cpp deleted file mode 100644 index c06ef99..0000000 --- a/automated-tests/TET/dali-test-suite/math/utc-Dali-Vector4.cpp +++ /dev/null @@ -1,568 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliVector4Vector4, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector4Add, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector4Constants, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector4Cross, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector4Dot, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector4DotVector3, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector4Dot4, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector4Equals, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector4Length, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector4LengthSquared, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector4Max, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector4Min, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector4Clamp, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector4ClampVector4, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector4Multiply, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector4Divide, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector4Scale, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector4Normalize, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector4Subtract, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector4OperatorSubscript, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector4OStreamOperator, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliVector4AsFloat, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - - -// Constructor -static void UtcDaliVector4Vector4() -{ - 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); -} - -// Add -static void UtcDaliVector4Add() -{ - 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); -} - -// Constants -static void UtcDaliVector4Constants() -{ - 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); -} - -// Cross -static void UtcDaliVector4Cross() -{ - 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); -} - -// Dot -static void UtcDaliVector4Dot() -{ - 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); -} - -// Dot (with vector3) -static void UtcDaliVector4DotVector3() -{ - 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); -} - -// Dot4 -static void UtcDaliVector4Dot4() -{ - 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); -} - -// Equals -static void UtcDaliVector4Equals() -{ - 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); -} - -#if 0 -// Equals -static void UtcDaliVector4IsEquivalent() -{ - Vector4 v0(1.0f, 2.0f, 3.0f, 4.0f); - - DALI_TEST_CHECK(v0.IsEquivalent(v0)); - DALI_TEST_CHECK(!v0.IsEquivalent(Vector4(1.1f, 2.0f, 3.0f, 4.0f))); - DALI_TEST_CHECK(!v0.IsEquivalent(Vector4(1.0f, 2.1f, 3.0f, 4.0f))); - DALI_TEST_CHECK(!v0.IsEquivalent(Vector4(1.0f, 2.0f, 3.1f, 4.0f))); - DALI_TEST_CHECK(!v0.IsEquivalent(Vector4(1.0f, 2.0f, 3.0f, 4.1f))); -} -#endif - -// Length -static void UtcDaliVector4Length() -{ - 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); -} - -// Length squared -static void UtcDaliVector4LengthSquared() -{ - 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); -} - -// Max -static void UtcDaliVector4Max() -{ - 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); -} - -// Min -static void UtcDaliVector4Min() -{ - 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); -} - -// Clamp -static void UtcDaliVector4Clamp() -{ - 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); - -} - -static void UtcDaliVector4ClampVector4() -{ - 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 ); -} - -// Multiply -static void UtcDaliVector4Multiply() -{ - 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); -} - -// Divide -static void UtcDaliVector4Divide() -{ - 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); - -} - -static void UtcDaliVector4Scale() -{ - 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); -} - - -// Normalize -static void UtcDaliVector4Normalize() -{ - 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); -} - -// Subtract -static void UtcDaliVector4Subtract() -{ - 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); -} - -static void UtcDaliVector4OperatorSubscript() -{ - 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 ); - } -} - -static void UtcDaliVector4OStreamOperator() -{ - 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); -} - -static void UtcDaliVector4AsFloat() -{ - 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); - } -} diff --git a/automated-tests/TET/dali-test-suite/object-registry/.gitignore b/automated-tests/TET/dali-test-suite/object-registry/.gitignore deleted file mode 100644 index ecec14c..0000000 --- a/automated-tests/TET/dali-test-suite/object-registry/.gitignore +++ /dev/null @@ -1 +0,0 @@ -utc-Dali-ObjectRegistry diff --git a/automated-tests/TET/dali-test-suite/object-registry/Makefile b/automated-tests/TET/dali-test-suite/object-registry/Makefile deleted file mode 120000 index c88d5a7..0000000 --- a/automated-tests/TET/dali-test-suite/object-registry/Makefile +++ /dev/null @@ -1 +0,0 @@ -../master-makefile.mk \ No newline at end of file diff --git a/automated-tests/TET/dali-test-suite/object-registry/file.list b/automated-tests/TET/dali-test-suite/object-registry/file.list deleted file mode 100644 index 16dea0c..0000000 --- a/automated-tests/TET/dali-test-suite/object-registry/file.list +++ /dev/null @@ -1,2 +0,0 @@ -TARGETS += \ - utc-Dali-ObjectRegistry \ diff --git a/automated-tests/TET/dali-test-suite/object-registry/tslist b/automated-tests/TET/dali-test-suite/object-registry/tslist deleted file mode 100644 index 1ad0679..0000000 --- a/automated-tests/TET/dali-test-suite/object-registry/tslist +++ /dev/null @@ -1 +0,0 @@ -/dali-test-suite/object-registry/utc-Dali-ObjectRegistry diff --git a/automated-tests/TET/dali-test-suite/object-registry/utc-Dali-ObjectRegistry.cpp b/automated-tests/TET/dali-test-suite/object-registry/utc-Dali-ObjectRegistry.cpp deleted file mode 100644 index 4bfe3e4..0000000 --- a/automated-tests/TET/dali-test-suite/object-registry/utc-Dali-ObjectRegistry.cpp +++ /dev/null @@ -1,564 +0,0 @@ -// -// 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 - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void UtcDaliObjectRegistryGet(); -static void UtcDaliObjectRegistrySignalActorCreated(); -static void UtcDaliObjectRegistrySignalCameraCreated(); -static void UtcDaliObjectRegistrySignalImageActorCreated(); -static void UtcDaliObjectRegistrySignalLayerCreated(); -static void UtcDaliObjectRegistrySignalLightActorCreated(); -static void UtcDaliObjectRegistrySignalMeshActorCreated(); -static void UtcDaliObjectRegistrySignalModelCreated(); -static void UtcDaliObjectRegistrySignalTextActorCreated(); -static void UtcDaliObjectRegistrySignalAnimationCreated(); -static void UtcDaliObjectRegistrySignalShaderEffectCreated(); - - - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -// Add test functionality for all APIs in the class (Positive and Negative) -extern "C" { - struct tet_testlist tet_testlist[] = { - { UtcDaliObjectRegistryGet, POSITIVE_TC_IDX }, - { UtcDaliObjectRegistrySignalActorCreated, POSITIVE_TC_IDX }, - { UtcDaliObjectRegistrySignalCameraCreated, POSITIVE_TC_IDX }, - { UtcDaliObjectRegistrySignalImageActorCreated, POSITIVE_TC_IDX }, - { UtcDaliObjectRegistrySignalLayerCreated, POSITIVE_TC_IDX }, - { UtcDaliObjectRegistrySignalLightActorCreated, POSITIVE_TC_IDX }, - { UtcDaliObjectRegistrySignalMeshActorCreated, POSITIVE_TC_IDX }, - { UtcDaliObjectRegistrySignalModelCreated, POSITIVE_TC_IDX }, - { UtcDaliObjectRegistrySignalTextActorCreated, POSITIVE_TC_IDX }, - { UtcDaliObjectRegistrySignalAnimationCreated, POSITIVE_TC_IDX }, - { UtcDaliObjectRegistrySignalShaderEffectCreated, POSITIVE_TC_IDX }, - { NULL, 0 } - }; -} - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -// 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; -}; - -static void UtcDaliObjectRegistryGet() -{ - TestApplication application; - - ObjectRegistry registry; // like this for ctor code coverage - registry= Stage::GetCurrent().GetObjectRegistry(); - - DALI_TEST_CHECK( registry ); -} - - - -static void UtcDaliObjectRegistrySignalActorCreated() -{ - 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 ); -} - -void UtcDaliObjectRegistrySignalCameraCreated() -{ - 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 ); -} - -void UtcDaliObjectRegistrySignalImageActorCreated() -{ - 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 ); -} - -void UtcDaliObjectRegistrySignalLayerCreated() -{ - 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 ); -} - -void UtcDaliObjectRegistrySignalLightActorCreated() -{ - 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 ); -} - -void UtcDaliObjectRegistrySignalMeshActorCreated() -{ - 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 ); -} - -void UtcDaliObjectRegistrySignalModelCreated() -{ - 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 ); -} - -void UtcDaliObjectRegistrySignalTextActorCreated() -{ - 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 ); -} - -void UtcDaliObjectRegistrySignalAnimationCreated() -{ - 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 ); -} - -void UtcDaliObjectRegistrySignalShaderEffectCreated() -{ - 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 ); -} diff --git a/automated-tests/TET/dali-test-suite/property-notification/.gitignore b/automated-tests/TET/dali-test-suite/property-notification/.gitignore deleted file mode 100644 index b4cf8a2..0000000 --- a/automated-tests/TET/dali-test-suite/property-notification/.gitignore +++ /dev/null @@ -1 +0,0 @@ -utc-Dali-PropertyNotification diff --git a/automated-tests/TET/dali-test-suite/property-notification/Makefile b/automated-tests/TET/dali-test-suite/property-notification/Makefile deleted file mode 120000 index c88d5a7..0000000 --- a/automated-tests/TET/dali-test-suite/property-notification/Makefile +++ /dev/null @@ -1 +0,0 @@ -../master-makefile.mk \ No newline at end of file diff --git a/automated-tests/TET/dali-test-suite/property-notification/file.list b/automated-tests/TET/dali-test-suite/property-notification/file.list deleted file mode 100644 index de8022d..0000000 --- a/automated-tests/TET/dali-test-suite/property-notification/file.list +++ /dev/null @@ -1,2 +0,0 @@ -TARGETS += \ - utc-Dali-PropertyNotification \ diff --git a/automated-tests/TET/dali-test-suite/property-notification/tslist b/automated-tests/TET/dali-test-suite/property-notification/tslist deleted file mode 100644 index 100374b..0000000 --- a/automated-tests/TET/dali-test-suite/property-notification/tslist +++ /dev/null @@ -1 +0,0 @@ -/dali-test-suite/property-notification/utc-Dali-PropertyNotification diff --git a/automated-tests/TET/dali-test-suite/property-notification/utc-Dali-PropertyNotification.cpp b/automated-tests/TET/dali-test-suite/property-notification/utc-Dali-PropertyNotification.cpp deleted file mode 100644 index d4bb938..0000000 --- a/automated-tests/TET/dali-test-suite/property-notification/utc-Dali-PropertyNotification.cpp +++ /dev/null @@ -1,860 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -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. - -} // unnamed namespace - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliPropertyNotificationDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyNotificationDownCastNegative, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAddPropertyNotification, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAddPropertyNotificationCallback, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliAddPropertyNotificationTypeProperty, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyNotificationGetCondition, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyNotificationGetConditionConst, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyNotificationGetTarget, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyNotificationGetProperty, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyNotificationGetNotifyMode, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyNotificationGreaterThan, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyNotificationLessThan, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyNotificationInside, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyNotificationOutside, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyNotificationVectorComponentGreaterThan, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyNotificationVectorComponentLessThan, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyNotificationVectorComponentInside, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyNotificationVectorComponentOutside, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyConditionGetArguments, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyConditionGetArgumentsConst, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyNotificationStep, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyNotificationVariableStep, POSITIVE_TC_IDX ); - -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; -} - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -// Positive test case for a method -static void UtcDaliPropertyNotificationDownCast() -{ - 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); -} - - -// Negative test case for a method -static void UtcDaliPropertyNotificationDownCastNegative() -{ - 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); -} - -static void UtcDaliAddPropertyNotification() -{ - 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 ); -} - -static void UtcDaliAddPropertyNotificationCallback() -{ - 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; -} - -void UtcDaliAddPropertyNotificationTypeProperty() -{ - 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 ); - } -} - -static void UtcDaliPropertyNotificationGetCondition() -{ - 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() ); -} - -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; -}; - -static void UtcDaliPropertyNotificationGetConditionConst() -{ - 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 ); -} - -static void UtcDaliPropertyNotificationGetTarget() -{ - 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 ); -} - -static void UtcDaliPropertyNotificationGetProperty() -{ - 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 ); -} - -static void UtcDaliPropertyNotificationGetNotifyMode() -{ - 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 ); -} - -static void UtcDaliPropertyNotificationGreaterThan() -{ - 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 ); -} - -static void UtcDaliPropertyNotificationLessThan() -{ - 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 ); -} - -static void UtcDaliPropertyNotificationInside() -{ - 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 ); -} - -static void UtcDaliPropertyNotificationOutside() -{ - 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 ); -} - -static void UtcDaliPropertyNotificationVectorComponentGreaterThan() -{ - 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 ); -} - -static void UtcDaliPropertyNotificationVectorComponentLessThan() -{ - 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 ); -} - -static void UtcDaliPropertyNotificationVectorComponentInside() -{ - 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 ); -} - -static void UtcDaliPropertyNotificationVectorComponentOutside() -{ - 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 ); -} - -static void UtcDaliPropertyConditionGetArguments() -{ - 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 ); -} - -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; -}; - -static void UtcDaliPropertyConditionGetArgumentsConst() -{ - 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 ); -} - -static void UtcDaliPropertyNotificationStep() -{ - 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 ); - } -} - -static void UtcDaliPropertyNotificationVariableStep() -{ - 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( 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 ); - } -} diff --git a/automated-tests/TET/dali-test-suite/render-tasks/.gitignore b/automated-tests/TET/dali-test-suite/render-tasks/.gitignore deleted file mode 100644 index 18e5fcc..0000000 --- a/automated-tests/TET/dali-test-suite/render-tasks/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -utc-Dali-RenderTaskList -utc-Dali-RenderTask diff --git a/automated-tests/TET/dali-test-suite/render-tasks/Makefile b/automated-tests/TET/dali-test-suite/render-tasks/Makefile deleted file mode 120000 index c88d5a7..0000000 --- a/automated-tests/TET/dali-test-suite/render-tasks/Makefile +++ /dev/null @@ -1 +0,0 @@ -../master-makefile.mk \ No newline at end of file diff --git a/automated-tests/TET/dali-test-suite/render-tasks/file.list b/automated-tests/TET/dali-test-suite/render-tasks/file.list deleted file mode 100644 index d3c0346..0000000 --- a/automated-tests/TET/dali-test-suite/render-tasks/file.list +++ /dev/null @@ -1,3 +0,0 @@ -TARGETS += \ - utc-Dali-RenderTaskList \ - utc-Dali-RenderTask \ diff --git a/automated-tests/TET/dali-test-suite/render-tasks/tslist b/automated-tests/TET/dali-test-suite/render-tasks/tslist deleted file mode 100644 index f56cab7..0000000 --- a/automated-tests/TET/dali-test-suite/render-tasks/tslist +++ /dev/null @@ -1,2 +0,0 @@ -/dali-test-suite/render-tasks/utc-Dali-RenderTaskList -/dali-test-suite/render-tasks/utc-Dali-RenderTask diff --git a/automated-tests/TET/dali-test-suite/render-tasks/utc-Dali-RenderTask.cpp b/automated-tests/TET/dali-test-suite/render-tasks/utc-Dali-RenderTask.cpp deleted file mode 100644 index cdd7be4..0000000 --- a/automated-tests/TET/dali-test-suite/render-tasks/utc-Dali-RenderTask.cpp +++ /dev/null @@ -1,2772 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliRenderTaskDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskSetSourceActor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskSetSourceActorOffStage, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskSetSourceActorEmpty, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskGetSourceActor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskSetExclusive, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskIsExclusive, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskSetInputEnabled, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskGetInputEnabled, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskSetCameraActor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskGetCameraActor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskSetTargetFrameBuffer, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskGetTargetFrameBuffer, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskSetScreenToFrameBufferFunction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskGetScreenToFrameBufferFunction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskSetScreenToFrameBufferMappingActor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskGetScreenToFrameBufferMappingActor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskSetViewport, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskGetViewport, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskSetClearColor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskGetClearColor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskSetClearEnabled, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskGetClearEnabled, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskSetRefreshRate, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskGetRefreshRate, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskSetViewportPosition, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskSetViewportSize, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskSignalFinished, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskContinuous01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskContinuous02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskContinuous03, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskContinuous04, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskContinuous05, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskContinuous06, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskOnce01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskOnce02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskOnce03, POSITIVE_TC_IDX ); -//TEST_FUNCTION( UtcDaliRenderTaskOnce04, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskOnce05, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskOnce06, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskOnce07, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskOnce08, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskOnceNoSync01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskOnceNoSync02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskOnceNoSync03, POSITIVE_TC_IDX ); -//TEST_FUNCTION( UtcDaliRenderTaskOnceNoSync04, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskOnceNoSync05, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskOnceNoSync06, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskOnceNoSync07, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskOnceNoSync08, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskOnceChain01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliRenderTaskProperties, POSITIVE_TC_IDX ); - -// TODO - work out how to reload images in test harness - - -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(){} -}; - - - -namespace // unnamed namespace -{ - -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; -}; - -} // unnamed namespace - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -bool TestScreenToFrameBufferFunction( Vector2& coordinates ) -{ - coordinates = coordinates + Vector2( 1, 2 ); - - return true; -} - -// 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; -}; - - -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(); -} - -/** - * Get the last request ID - it does this by loading a new image and - * reading the request ID. The last ID is therefore the ID previous to this. - */ -unsigned int GetLastResourceId(TestApplication& application) -{ - static int index=0; - index++; - char imageName[40]; - sprintf(imageName, "anImage%04d\n", index); // Generate a unique image name - - Internal::ImagePtr image = Internal::Image::New(imageName); - 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 - unsigned int id = req->GetId(); - - 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(); - // Image goes out of scope - will then get destroyed. - return id-1; -} - -RenderTask CreateRenderTask(TestApplication& application, - CameraActor offscreenCamera, - Actor rootActor, // Reset default render task to point at this actor - Actor secondRootActor, // Source actor - unsigned int refreshRate, - unsigned int& offscreenResourceId, - 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 ); - - // Framebuffer doesn't actually get created until Connected, i.e. by previous line - offscreenResourceId = GetLastResourceId(application); - - 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); -} - - -/****************************************************************************************************/ -/****************************************************************************************************/ -/******************************** TEST CASES BELOW **********************************************/ -/****************************************************************************************************/ -/****************************************************************************************************/ - -static void UtcDaliRenderTaskDownCast() -{ - 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() ); -} - -static void UtcDaliRenderTaskSetSourceActor() -{ - 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 ); - } -} - -static void UtcDaliRenderTaskSetSourceActorOffStage() -{ - 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(); -} - -static void UtcDaliRenderTaskSetSourceActorEmpty() -{ - 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 ); - } -} - -static void UtcDaliRenderTaskGetSourceActor() -{ - 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 ); -} - -static void UtcDaliRenderTaskSetExclusive() -{ - 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 ); - } -} - -static void UtcDaliRenderTaskIsExclusive() -{ - 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() ); -} - -static void UtcDaliRenderTaskSetInputEnabled() -{ - 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() ); -} - -static void UtcDaliRenderTaskGetInputEnabled() -{ - 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() ); -} - -static void UtcDaliRenderTaskSetCameraActor() -{ - 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 ); -} - -static void UtcDaliRenderTaskGetCameraActor() -{ - 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() ); -} - -static void UtcDaliRenderTaskSetTargetFrameBuffer() -{ - 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 ); -} - -static void UtcDaliRenderTaskGetTargetFrameBuffer() -{ - 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() ); -} - -static void UtcDaliRenderTaskSetScreenToFrameBufferFunction() -{ - 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 ) ); -} - -static void UtcDaliRenderTaskGetScreenToFrameBufferFunction() -{ - 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 -} - -static void UtcDaliRenderTaskSetScreenToFrameBufferMappingActor() -{ - 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 ); -} - -static void UtcDaliRenderTaskGetScreenToFrameBufferMappingActor() -{ - 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() ); -} - -static void UtcDaliRenderTaskSetViewport() -{ - 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 ); -} - -static void UtcDaliRenderTaskGetViewport() -{ - 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 ); -} - -static void UtcDaliRenderTaskSetViewportPosition() -{ - 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 ); -} - -static void UtcDaliRenderTaskSetViewportSize() -{ - 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 ); - -} - -static void UtcDaliRenderTaskSetClearColor() -{ - 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 ); -} - -static void UtcDaliRenderTaskGetClearColor() -{ - 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 ); -} - -static void UtcDaliRenderTaskSetClearEnabled() -{ - 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 ); -} - -static void UtcDaliRenderTaskGetClearEnabled() -{ - 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 -} - -static void UtcDaliRenderTaskSetRefreshRate() -{ - 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() ); -} - -static void UtcDaliRenderTaskGetRefreshRate() -{ - 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() ); -} - -static void UtcDaliRenderTaskSignalFinished() -{ - TestApplication application; - extern Debug::Filter* gRenderTaskLogFilter; - DALI_LOG_FILTER_SET_LEVEL(gRenderTaskLogFilter, Debug::General); - DALI_LOG_FILTER_ENABLE_TRACE(gRenderTaskLogFilter); - - 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 ); -} - - -static void UtcDaliRenderTaskContinuous01() -{ - TestApplication application; - extern Debug::Filter* gRenderTaskLogFilter; - DALI_LOG_FILTER_SET_LEVEL(gRenderTaskLogFilter, Debug::General); - DALI_LOG_FILTER_ENABLE_TRACE(gRenderTaskLogFilter); - - 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; - - unsigned int offscreenFramebufferId; - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, offscreenFramebufferId, 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 ) ); -} - - -static void UtcDaliRenderTaskContinuous02() -{ - TestApplication application; - extern Debug::Filter* gRenderTaskLogFilter; - DALI_LOG_FILTER_SET_LEVEL(gRenderTaskLogFilter, Debug::General); - DALI_LOG_FILTER_ENABLE_TRACE(gRenderTaskLogFilter); - - 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); - - unsigned int offscreenFramebufferId; - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, offscreenFramebufferId, 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 ) ); -} - -static void UtcDaliRenderTaskContinuous03() -{ - TestApplication application; - extern Debug::Filter* gRenderTaskLogFilter; - DALI_LOG_FILTER_SET_LEVEL(gRenderTaskLogFilter, Debug::General); - DALI_LOG_FILTER_ENABLE_TRACE(gRenderTaskLogFilter); - - 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); - - unsigned int offscreenFramebufferId; - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, offscreenFramebufferId, 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 ) ); -} - - -static void UtcDaliRenderTaskContinuous04() -{ - TestApplication application; - extern Debug::Filter* gRenderTaskLogFilter; - DALI_LOG_FILTER_SET_LEVEL(gRenderTaskLogFilter, Debug::General); - DALI_LOG_FILTER_ENABLE_TRACE(gRenderTaskLogFilter); - - 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); - - unsigned int offscreenFramebufferId; - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, offscreenFramebufferId, 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 ) ); -} - -static void UtcDaliRenderTaskContinuous05() -{ - TestApplication application; - extern Debug::Filter* gRenderTaskLogFilter; - DALI_LOG_FILTER_SET_LEVEL(gRenderTaskLogFilter, Debug::General); - DALI_LOG_FILTER_ENABLE_TRACE(gRenderTaskLogFilter); - - 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); - - unsigned int offscreenFramebufferId; - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, 3, offscreenFramebufferId, 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 ) ); -} - -static void UtcDaliRenderTaskContinuous06() -{ - TestApplication application; - extern Debug::Filter* gRenderTaskLogFilter; - DALI_LOG_FILTER_SET_LEVEL(gRenderTaskLogFilter, Debug::General); - DALI_LOG_FILTER_ENABLE_TRACE(gRenderTaskLogFilter); - - 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); - - unsigned int offscreenFramebufferId; - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, offscreenFramebufferId, 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 ) ); -} - - -static void UtcDaliRenderTaskOnce01() -{ - TestApplication application; - extern Debug::Filter* gRenderTaskLogFilter; - DALI_LOG_FILTER_SET_LEVEL(gRenderTaskLogFilter, Debug::General); - DALI_LOG_FILTER_ENABLE_TRACE(gRenderTaskLogFilter); - - 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); - - unsigned int offscreenFramebufferId; - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, offscreenFramebufferId, 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 ) ); -} - -static void UtcDaliRenderTaskOnce02() -{ - TestApplication application; - extern Debug::Filter* gRenderTaskLogFilter; - DALI_LOG_FILTER_SET_LEVEL(gRenderTaskLogFilter, Debug::General); - DALI_LOG_FILTER_ENABLE_TRACE(gRenderTaskLogFilter); - - 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); - - unsigned int offscreenFramebufferId; - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, offscreenFramebufferId, 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 ) ); -} - - -static void UtcDaliRenderTaskOnce03() -{ - 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); - - unsigned int offscreenFramebufferId; - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, offscreenFramebufferId, 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 ) ); -} - - -static void UtcDaliRenderTaskOnce04() -{ - 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); - - unsigned int offscreenFramebufferId; - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, offscreenFramebufferId, 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 ) ); -} - - -static void UtcDaliRenderTaskOnce05() -{ - 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); - - unsigned int offscreenFramebufferId; - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, offscreenFramebufferId, 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 ) ); -} - -static void UtcDaliRenderTaskOnce06() -{ - 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); - - unsigned int offscreenFramebufferId; - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, offscreenFramebufferId, 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 ) ); -} - - -static void UtcDaliRenderTaskOnce07() -{ - 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); - - unsigned int offscreenFramebufferId; - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, offscreenFramebufferId, 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 ) ); -} - - - -static void UtcDaliRenderTaskOnce08() -{ - 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); - - unsigned int offscreenFramebufferId; - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, offscreenFramebufferId, 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 ) ); -} - - - -static void UtcDaliRenderTaskOnceNoSync01() -{ - TestApplication application; - extern Debug::Filter* gRenderTaskLogFilter; - DALI_LOG_FILTER_SET_LEVEL(gRenderTaskLogFilter, Debug::General); - DALI_LOG_FILTER_ENABLE_TRACE(gRenderTaskLogFilter); - - 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); - - unsigned int offscreenFramebufferId; - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, offscreenFramebufferId, 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 ) ); -} - -static void UtcDaliRenderTaskOnceNoSync02() -{ - TestApplication application; - extern Debug::Filter* gRenderTaskLogFilter; - DALI_LOG_FILTER_SET_LEVEL(gRenderTaskLogFilter, Debug::General); - DALI_LOG_FILTER_ENABLE_TRACE(gRenderTaskLogFilter); - - 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); - - unsigned int offscreenFramebufferId; - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, offscreenFramebufferId, 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 ) ); -} - - -static void UtcDaliRenderTaskOnceNoSync03() -{ - 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); - - unsigned int offscreenFramebufferId; - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, offscreenFramebufferId, 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 ) ); -} - - -static void UtcDaliRenderTaskOnceNoSync04() -{ - 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); - - unsigned int offscreenFramebufferId; - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, offscreenFramebufferId, 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 ) ); -} - - -static void UtcDaliRenderTaskOnceNoSync05() -{ - 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); - - unsigned int offscreenFramebufferId; - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, offscreenFramebufferId, 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 ) ); -} - -static void UtcDaliRenderTaskOnceNoSync06() -{ - 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); - - unsigned int offscreenFramebufferId; - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, offscreenFramebufferId, 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 ) ); -} - - -static void UtcDaliRenderTaskOnceNoSync07() -{ - 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); - - unsigned int offscreenFramebufferId; - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, offscreenFramebufferId, 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 ) ); -} - -static void UtcDaliRenderTaskOnceNoSync08() -{ - 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); - - unsigned int offscreenFramebufferId; - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, offscreenFramebufferId, 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 ) ); -} - - -static void UtcDaliRenderTaskOnceChain01() -{ - 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 - unsigned int offscreenFramebufferId; - RenderTask firstTask = CreateRenderTask(application, offscreenCameraActor, defaultRootActor, firstRootActor, RenderTask::REFRESH_ONCE, offscreenFramebufferId, 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, offscreenFramebufferId, 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 ); -} - -void UtcDaliRenderTaskProperties() -{ - 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 ); -} diff --git a/automated-tests/TET/dali-test-suite/render-tasks/utc-Dali-RenderTaskList.cpp b/automated-tests/TET/dali-test-suite/render-tasks/utc-Dali-RenderTaskList.cpp deleted file mode 100644 index 0a574ed..0000000 --- a/automated-tests/TET/dali-test-suite/render-tasks/utc-Dali-RenderTaskList.cpp +++ /dev/null @@ -1,170 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -static void UtcDaliRenderTaskListDefaultConstructor(); -static void UtcDaliRenderTaskListDownCast(); -static void UtcDaliRenderTaskListCreateTask(); -static void UtcDaliRenderTaskListRemoveTask(); -static void UtcDaliRenderTaskListGetTaskCount(); -static void UtcDaliRenderTaskListGetTask(); - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -// Add test functionality for all APIs in the class (Positive and Negative) -extern "C" { - struct tet_testlist tet_testlist[] = - { - { UtcDaliRenderTaskListDefaultConstructor, POSITIVE_TC_IDX }, - { UtcDaliRenderTaskListDownCast, POSITIVE_TC_IDX }, - { UtcDaliRenderTaskListCreateTask, POSITIVE_TC_IDX }, - { UtcDaliRenderTaskListRemoveTask, POSITIVE_TC_IDX }, - { UtcDaliRenderTaskListGetTaskCount, POSITIVE_TC_IDX }, - { UtcDaliRenderTaskListGetTask, POSITIVE_TC_IDX }, - - { NULL, 0 } - }; -} - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -static void UtcDaliRenderTaskListDefaultConstructor() -{ - TestApplication application; - - tet_infoline("Testing RenderTaskList::RenderTaskList()"); - - RenderTaskList taskList; - - DALI_TEST_CHECK( ! taskList ); -} - -static void UtcDaliRenderTaskListDownCast() -{ - 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() ); -} - -static void UtcDaliRenderTaskListCreateTask() -{ - 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() ); -} - -static void UtcDaliRenderTaskListRemoveTask() -{ - 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() ); -} - -static void UtcDaliRenderTaskListGetTaskCount() -{ - 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() ); -} - -static void UtcDaliRenderTaskListGetTask() -{ - 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 ); -} diff --git a/automated-tests/TET/dali-test-suite/scripting/.gitignore b/automated-tests/TET/dali-test-suite/scripting/.gitignore deleted file mode 100644 index 06b4f2d..0000000 --- a/automated-tests/TET/dali-test-suite/scripting/.gitignore +++ /dev/null @@ -1 +0,0 @@ -utc-Dali-Scripting diff --git a/automated-tests/TET/dali-test-suite/scripting/Makefile b/automated-tests/TET/dali-test-suite/scripting/Makefile deleted file mode 120000 index c88d5a7..0000000 --- a/automated-tests/TET/dali-test-suite/scripting/Makefile +++ /dev/null @@ -1 +0,0 @@ -../master-makefile.mk \ No newline at end of file diff --git a/automated-tests/TET/dali-test-suite/scripting/file.list b/automated-tests/TET/dali-test-suite/scripting/file.list deleted file mode 100644 index 653ef99..0000000 --- a/automated-tests/TET/dali-test-suite/scripting/file.list +++ /dev/null @@ -1,2 +0,0 @@ -TARGETS += \ - utc-Dali-Scripting \ diff --git a/automated-tests/TET/dali-test-suite/scripting/tslist b/automated-tests/TET/dali-test-suite/scripting/tslist deleted file mode 100644 index c2678b8..0000000 --- a/automated-tests/TET/dali-test-suite/scripting/tslist +++ /dev/null @@ -1 +0,0 @@ -/dali-test-suite/scripting/utc-Dali-Scripting diff --git a/automated-tests/TET/dali-test-suite/scripting/utc-Dali-Scripting.cpp b/automated-tests/TET/dali-test-suite/scripting/utc-Dali-Scripting.cpp deleted file mode 100644 index 6008a1d..0000000 --- a/automated-tests/TET/dali-test-suite/scripting/utc-Dali-Scripting.cpp +++ /dev/null @@ -1,1056 +0,0 @@ -// -// 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::Scripting; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( UtcDaliScriptingGetColorMode, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliScriptingGetPositionInheritanceMode, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliScriptingGetDrawMode, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliScriptingGetAnchorConstant, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliScriptingNewImageNegative, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliScriptingNewImage, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliScriptingNewShaderEffect, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliScriptingNewActorNegative, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliScriptingNewActorProperties, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliScriptingNewActorChildren, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliScriptingCreatePropertyMapActor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliScriptingCreatePropertyMapImage, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -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] ); - -void UtcDaliScriptingGetColorMode() -{ - 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 ); - } -} - -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] ); - -void UtcDaliScriptingGetPositionInheritanceMode() -{ - 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 ); - } -} - -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] ); - -void UtcDaliScriptingGetDrawMode() -{ - 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 ); - } -} - -void UtcDaliScriptingGetAnchorConstant() -{ - 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 ); - } -} - -void UtcDaliScriptingNewImageNegative() -{ - 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 ); - } - } -} - -////////////////////////////////////////////////////////////////////////////// -// 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(); -} - -////////////////////////////////////////////////////////////////////////////// - -void UtcDaliScriptingNewImage() -{ - 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 ) ); - } -} - -void UtcDaliScriptingNewShaderEffect() -{ - 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 ); -} - -void UtcDaliScriptingNewActorNegative() -{ - 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() ); - } -} - -void UtcDaliScriptingNewActorProperties() -{ - 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 ); - } -} - -void UtcDaliScriptingNewActorChildren() -{ - 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 ); -} - -////////////////////////////////////////////////////////////////////////////// -// 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 ); - } -} - -////////////////////////////////////////////////////////////////////////////// - -void UtcDaliScriptingCreatePropertyMapActor() -{ - 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 ); - } -} - -void UtcDaliScriptingCreatePropertyMapImage() -{ - 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 ); - } -} diff --git a/automated-tests/TET/dali-test-suite/signals/.gitignore b/automated-tests/TET/dali-test-suite/signals/.gitignore deleted file mode 100644 index 3210a0d..0000000 --- a/automated-tests/TET/dali-test-suite/signals/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -utc-Dali-ScopedConnectionContainer -utc-Dali-SignalTemplates -utc-Dali-SignalTemplatesV2 -utc-Dali-SignalTemplatesFunctors diff --git a/automated-tests/TET/dali-test-suite/signals/Makefile b/automated-tests/TET/dali-test-suite/signals/Makefile deleted file mode 120000 index c88d5a7..0000000 --- a/automated-tests/TET/dali-test-suite/signals/Makefile +++ /dev/null @@ -1 +0,0 @@ -../master-makefile.mk \ No newline at end of file diff --git a/automated-tests/TET/dali-test-suite/signals/file.list b/automated-tests/TET/dali-test-suite/signals/file.list deleted file mode 100644 index 6a5013f..0000000 --- a/automated-tests/TET/dali-test-suite/signals/file.list +++ /dev/null @@ -1,3 +0,0 @@ -TARGETS += \ - utc-Dali-SignalTemplatesV2 \ - utc-Dali-SignalTemplatesFunctors \ diff --git a/automated-tests/TET/dali-test-suite/signals/tslist b/automated-tests/TET/dali-test-suite/signals/tslist deleted file mode 100644 index 2d7310b..0000000 --- a/automated-tests/TET/dali-test-suite/signals/tslist +++ /dev/null @@ -1,2 +0,0 @@ -/dali-test-suite/signals/utc-Dali-SignalTemplatesV2 -/dali-test-suite/signals/utc-Dali-SignalTemplatesFunctors diff --git a/automated-tests/TET/dali-test-suite/signals/utc-Dali-SignalTemplatesFunctors.cpp b/automated-tests/TET/dali-test-suite/signals/utc-Dali-SignalTemplatesFunctors.cpp deleted file mode 100644 index 66cbec4..0000000 --- a/automated-tests/TET/dali-test-suite/signals/utc-Dali-SignalTemplatesFunctors.cpp +++ /dev/null @@ -1,528 +0,0 @@ -// -// 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 - -using namespace Dali; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( UtcDaliSignalFunctorsEmptyCheck, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSignalFunctorsEmit, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSignalFunctorsEmitReturn, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSignalFunctorsDisconnectBeforeEmit, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSignalFunctorsDestroySignal, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSignalConnectVoidFunctor, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -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; - -static void UtcDaliSignalFunctorsEmptyCheck() -{ - // 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 ); -} - -static void UtcDaliSignalFunctorsEmit() -{ - // 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(); -} - -static void UtcDaliSignalFunctorsEmitReturn() -{ - // 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(); -} - -static void UtcDaliSignalFunctorsDisconnectBeforeEmit() -{ - // 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 ); - } -} - -static void UtcDaliSignalFunctorsDestroySignal() -{ - // 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 ); -} - -static void UtcDaliSignalConnectVoidFunctor() -{ - // 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(); -} diff --git a/automated-tests/TET/dali-test-suite/signals/utc-Dali-SignalTemplatesV2.cpp b/automated-tests/TET/dali-test-suite/signals/utc-Dali-SignalTemplatesV2.cpp deleted file mode 100644 index b71e027..0000000 --- a/automated-tests/TET/dali-test-suite/signals/utc-Dali-SignalTemplatesV2.cpp +++ /dev/null @@ -1,2633 +0,0 @@ -// -// 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 - -using namespace Dali; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( UtcDaliSignalEmptyCheck, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSignalEmptyCheckSlotDestruction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSignalConnectAndEmit, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSignalDisconnect, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSignalDisconnect2, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSignalDisconnect3, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSignalCustomConnectionTracker, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSignalMultipleConnections, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSignalMultipleConnections2, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSignalMultipleConnections3, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliSignalDisconnectStatic, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSignalDisconnectDuringCallback, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSignalDisconnectDuringCallback2, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSignalEmitDuringCallback, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSignalTestApp01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSignalTestApp02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSignalTestApp03, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSignalTestApp04, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSignalTestApp05, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSignalTestApp06, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSlotDelegateConnection, POSITIVE_TC_IDX ); - -TEST_FUNCTION( UtcDaliSignalSlotDelegateDestruction, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliSlotHandlerDisconnect, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -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) -}; - -static void UtcDaliSignalEmptyCheck() -{ - // 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() ); - } -} - -static void UtcDaliSignalEmptyCheckSlotDestruction() -{ - // 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 ); - } -} - -// Positive test case for a method -static void UtcDaliSignalConnectAndEmit() -{ - // 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(); -} - -static void UtcDaliSignalDisconnect() -{ - // 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 ); - } -} - -static void UtcDaliSignalDisconnect2() -{ - // 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 ); - } -} - -static void UtcDaliSignalDisconnect3() -{ - // 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 ); - } -} - -static void UtcDaliSignalCustomConnectionTracker() -{ - // 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 ); -} - -static void UtcDaliSignalMultipleConnections() -{ - // 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 ); -} - -static void UtcDaliSignalMultipleConnections2() -{ - 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 ); -} - -static void UtcDaliSignalMultipleConnections3() -{ - 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 ); -} - -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; -} - -static void UtcDaliSignalDisconnectStatic() -{ - // 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 ); - } -} - -static void UtcDaliSignalDisconnectDuringCallback() -{ - // 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 ); -} - -static void UtcDaliSignalDisconnectDuringCallback2() -{ - // 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 ); -} - -static void UtcDaliSignalEmitDuringCallback() -{ - 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(); -} - -static void UtcDaliSignalTestApp01() -{ - // 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 ); - -} -static void UtcDaliSignalTestApp02() -{ - // 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 ); -} - -static void UtcDaliSignalTestApp03() -{ - // 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 ); - -} -static void UtcDaliSignalTestApp04() -{ - // 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 ); -} - -static void UtcDaliSignalTestApp05() -{ - // 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 ); -} - -static void UtcDaliSignalTestApp06() -{ - 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 ); -} - -static void UtcDaliSlotDelegateConnection() -{ - 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(); -} - -static void UtcDaliSignalSlotDelegateDestruction() -{ - // 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 ); - } -} - -static void UtcDaliSlotHandlerDisconnect() -{ - // 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 ); - } -} diff --git a/automated-tests/TET/dali-test-suite/tc-gen.sh b/automated-tests/TET/dali-test-suite/tc-gen.sh deleted file mode 100755 index 178f24d..0000000 --- a/automated-tests/TET/dali-test-suite/tc-gen.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh - -TMPSTR=$0 -SCRIPT=${TMPSTR##*/} - -if [ $# -ne 1 ]; then - echo "Usage) $SCRIPT ClassName" - exit 1 -fi - -MODULE="Dali" -SECTION=${PWD##*/} -CLASS=$1 - -TESTSUITEPATH=`dirname $PWD` -TESTSUITENAME=${TESTSUITEPATH##*/} - -TEMPLATE=../utc-MODULE-CLASS.cpp.in -TESTCASE=utc-${MODULE}-${CLASS} - -# Create .cpp file -if [ ! -e "$TESTCASE.cpp" ]; then - sed -e ' - s^@CLASS@^'"$CLASS"'^g - s^@MODULE@^'"$MODULE"'^g - ' $TEMPLATE > $TESTCASE.cpp -fi - -if [ ! -e "$TESTCASE.cpp" ]; then - echo "Failed" - exit 1 -fi - - -# file.list -if ! [ -f file.list ]; then - touch file.list - echo "TARGETS += \\" >> file.list -fi -echo " $TESTCASE \\" >> file.list - -# tslist -if ! [ -f tslist ]; then - touch tslist -fi -echo "/$TESTSUITENAME/$SECTION/$TESTCASE" >> tslist - -# Makefile -if ! [ -f Makefile ]; then - ln -s ../master-makefile.mk Makefile -fi - -echo "$TESTCASE" >> .gitignore - -echo "Testcase file is $TESTCASE.cpp" -echo "$TESTCASE is added to tslist" -echo "$TESTCASE is added to file.list" -echo "Done" diff --git a/automated-tests/TET/dali-test-suite/text/.gitignore b/automated-tests/TET/dali-test-suite/text/.gitignore deleted file mode 100644 index a916f10..0000000 --- a/automated-tests/TET/dali-test-suite/text/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -utc-Dali-Font -utc-Dali-Character -utc-Dali-Text -utc-Dali-TextStyle -utc-Dali-Utf8 -utc-Dali-FontParameters diff --git a/automated-tests/TET/dali-test-suite/text/Makefile b/automated-tests/TET/dali-test-suite/text/Makefile deleted file mode 120000 index c88d5a7..0000000 --- a/automated-tests/TET/dali-test-suite/text/Makefile +++ /dev/null @@ -1 +0,0 @@ -../master-makefile.mk \ No newline at end of file diff --git a/automated-tests/TET/dali-test-suite/text/file.list b/automated-tests/TET/dali-test-suite/text/file.list deleted file mode 100644 index 136f3f5..0000000 --- a/automated-tests/TET/dali-test-suite/text/file.list +++ /dev/null @@ -1,7 +0,0 @@ -TARGETS += \ - utc-Dali-Font \ - utc-Dali-FontParameters \ - utc-Dali-Text \ - utc-Dali-Character \ - utc-Dali-TextStyle \ - utc-Dali-Utf8 \ diff --git a/automated-tests/TET/dali-test-suite/text/tslist b/automated-tests/TET/dali-test-suite/text/tslist deleted file mode 100644 index 958e839..0000000 --- a/automated-tests/TET/dali-test-suite/text/tslist +++ /dev/null @@ -1,6 +0,0 @@ -/dali-test-suite/text/utc-Dali-Font -/dali-test-suite/text/utc-Dali-FontParameters -/dali-test-suite/text/utc-Dali-Text -/dali-test-suite/text/utc-Dali-Character -/dali-test-suite/text/utc-Dali-TextStyle -/dali-test-suite/text/utc-Dali-Utf8 diff --git a/automated-tests/TET/dali-test-suite/text/utc-Dali-Character.cpp b/automated-tests/TET/dali-test-suite/text/utc-Dali-Character.cpp deleted file mode 100644 index a8749ce..0000000 --- a/automated-tests/TET/dali-test-suite/text/utc-Dali-Character.cpp +++ /dev/null @@ -1,196 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliCharacterCopyConstructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCharacterComparissonOperators, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCharacterAssignmentOperator, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCharacterIsLeftToRight, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliGetCharacterDirection, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCharacterIsWhiteSpace, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCharacterIsNewLine, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliCharacterGetImplementation,POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -static void UtcDaliCharacterCopyConstructor() -{ - 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) ); -} - -static void UtcDaliCharacterComparissonOperators() -{ - 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) ); -} - -static void UtcDaliCharacterAssignmentOperator() -{ - 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); - -} - -static void UtcDaliCharacterIsLeftToRight() -{ - 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 ); -} - -static void UtcDaliGetCharacterDirection() -{ - 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 ); -} - -static void UtcDaliCharacterIsWhiteSpace() -{ - 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' -} - -static void UtcDaliCharacterIsNewLine() -{ - 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' -} - -static void UtcDaliCharacterGetImplementation() -{ - tet_infoline("UtcDaliCharacterIsWhiteSpace "); - TestApplication application; - - Text text( std::string("a") ); - Character c1 = text[0]; - const Dali::Internal::Character& impl = c1.GetImplementation(); - DALI_TEST_CHECK( impl.GetCharacter() == 'a' ); -} diff --git a/automated-tests/TET/dali-test-suite/text/utc-Dali-Font.cpp b/automated-tests/TET/dali-test-suite/text/utc-Dali-Font.cpp deleted file mode 100644 index 3f1ca3d..0000000 --- a/automated-tests/TET/dali-test-suite/text/utc-Dali-Font.cpp +++ /dev/null @@ -1,561 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliFontNew01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliFontNew02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliFontNew03, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliFontNew04, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliFontNew05, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliFontNew06, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliFontDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliFontGetPixelSize, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliFontGetPointSize, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliFontPointsToPixels, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcFontMeasureTextWidth, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcFontMeasureTextHeight, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcFontMeasureText, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcFontGetFamilyForText, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcFontGetFontLineHeightFromCapsHeight, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcFontAllGlyphsSupported, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcFontGetMetrics, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcFontIsDefault, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcFontGetInstalledFonts, POSITIVE_TC_IDX ); -// Metrics -TEST_FUNCTION( UtcFontMetricsDefaultConstructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcFontMetricsCopyConstructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcFontMetricsAssignmentOperator, POSITIVE_TC_IDX ); - -const std::string FAMILY_NAME = "Arial"; -const std::string STYLE = "Bold"; -const unsigned int PIXEL_SIZE = 20; -const unsigned int POINT_SIZE = 11.f; -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -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)); -} - -static void UtcDaliFontNew01() -{ - 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; -} - -static void UtcDaliFontNew02() -{ - 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); -} - -static void UtcDaliFontNew03() -{ - 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); -} - -static void UtcDaliFontNew04() -{ - 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); -} - -static void UtcDaliFontNew05() -{ - 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() ); -} - -static void UtcDaliFontNew06() -{ - 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() ); -} - - -static void UtcDaliFontDownCast() -{ - 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); -} - -static void UtcDaliFontGetPixelSize() -{ - TestApplication application; - - tet_infoline("Testing Dali::Font::GetPixelSize()"); - - Font font = CreateFont(PixelSize(32)); - - DALI_TEST_CHECK(32 == font.GetPixelSize()); -} - -static void UtcDaliFontGetPointSize() -{ - 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); -} - -static void UtcDaliFontPointsToPixels() -{ - TestApplication application; - - tet_infoline("Testing Dali::Font::PointsToPixels)"); - - unsigned int points= Font::PointsToPixels( 12.0f ); - - DALI_TEST_CHECK( points == 36 ); -} - -static void UtcFontMeasureTextWidth() -{ - 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); - -} - -static void UtcFontMeasureTextHeight() -{ - 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); - -} - -static void UtcFontMeasureText() -{ - 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); - -} - -static void UtcFontGetFamilyForText() -{ - 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 ); - -} - -static void UtcFontGetFontLineHeightFromCapsHeight() -{ - 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 ); -} - -static void UtcFontAllGlyphsSupported() -{ - 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)); -} - -static void UtcFontGetMetrics() -{ - 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 ); -} - -static void UtcFontIsDefault() -{ - 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 ) ); -} - - -static void UtcFontGetInstalledFonts() -{ - 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 ); - -} - -static void UtcFontMetricsDefaultConstructor() -{ - 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 ); - -} -static void UtcFontMetricsCopyConstructor() -{ - 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 ); - -} -static void UtcFontMetricsAssignmentOperator() -{ - 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 ); - -} diff --git a/automated-tests/TET/dali-test-suite/text/utc-Dali-FontParameters.cpp b/automated-tests/TET/dali-test-suite/text/utc-Dali-FontParameters.cpp deleted file mode 100644 index 9176be8..0000000 --- a/automated-tests/TET/dali-test-suite/text/utc-Dali-FontParameters.cpp +++ /dev/null @@ -1,151 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliFontParamsDefaultConstructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliFontParamsPointSizeConstructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliFontParamsPixelSizeConstructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliFontParamsCopyConstructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliFontParamsAssignmentOperator, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliFontParamsPointSizeEqualityOperator, POSITIVE_TC_IDX ); - - -const std::string FAMILY_NAME = "Arial"; -const std::string STYLE = "Bold"; -const unsigned int PIXEL_SIZE = 20; -const unsigned int POINT_SIZE = 11.f; - - - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -static void UtcDaliFontParamsDefaultConstructor() -{ - 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 ); - -} -static void UtcDaliFontParamsPointSizeConstructor() -{ - 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 ); -} - -static void UtcDaliFontParamsPixelSizeConstructor() -{ - 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 ); - -} - -static void UtcDaliFontParamsCopyConstructor() -{ - 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 ); - -} - -static void UtcDaliFontParamsAssignmentOperator() -{ - 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 ); - -} -static void UtcDaliFontParamsPointSizeEqualityOperator() -{ - TestApplication application; - tet_infoline("Testing UtcDaliFontParamsPixelSizeConstructor"); - PointSize pointSize1(1.f); - PointSize pointSize2(2.f); - DALI_TEST_CHECK( pointSize1 != pointSize2 ); - -} diff --git a/automated-tests/TET/dali-test-suite/text/utc-Dali-Text.cpp b/automated-tests/TET/dali-test-suite/text/utc-Dali-Text.cpp deleted file mode 100644 index fcf85f7..0000000 --- a/automated-tests/TET/dali-test-suite/text/utc-Dali-Text.cpp +++ /dev/null @@ -1,374 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -// Add test functionality for all APIs in the class (Positive and Negative) -TEST_FUNCTION( UtcDaliTextConstructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextCopyConstructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextAssignmentOperator, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextGetImplementation, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextSetGetText, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextAccessOperator01, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextAccessOperator02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextIsEmpty, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextGetLength, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextAppend, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextRemove01, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextRemove02, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -static void UtcDaliTextConstructor() -{ - 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() ); -} - -static void UtcDaliTextCopyConstructor() -{ - 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()) ); -} - -static void UtcDaliTextAssignmentOperator() -{ - 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() ); - - -} - -static void UtcDaliTextGetImplementation() -{ - TestApplication application; - - Text text; - - bool assert1 = false; - bool assert2 = false; - - try // const GetImpl - { - const Internal::Text& impl = text.GetImplementation(); - (void)impl; // Avoid unused variable warning - } - 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::GetImplementation: Text is uninitialized\"", TEST_LOCATION ); - - assert1 = true; - } - - try // non const getImp - { - Internal::Text& impl = text.GetImplementation(); - (void)impl; // Avoid unused variable warning - } - 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::GetImplementation: Text is uninitialized\"", TEST_LOCATION ); - - assert2 = true; - } - - if( assert1 && assert2 ) - { - tet_result( TET_PASS ); - } - else - { - tet_result( TET_FAIL ); - } -} - -static void UtcDaliTextSetGetText() -{ - 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() ); -} - -static void UtcDaliTextAccessOperator01() -{ - 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 ); - } -} - -static void UtcDaliTextAccessOperator02() -{ - 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() ); -} - -static void UtcDaliTextIsEmpty() -{ - TestApplication application; - - Text text; - - DALI_TEST_CHECK( text.IsEmpty() ); - - text.SetText( std::string( "Some text") ); - - DALI_TEST_CHECK( !text.IsEmpty() ); -} - -static void UtcDaliTextGetLength() -{ - TestApplication application; - - const std::string someText( "Some text"); - - Text text( someText ); - - DALI_TEST_CHECK( someText.size() == text.GetLength() ); -} - -static void UtcDaliTextAppend() -{ - 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() ); - -} - -static void UtcDaliTextRemove01() -{ - 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 ); - } -} - -static void UtcDaliTextRemove02() -{ - 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 ); -} diff --git a/automated-tests/TET/dali-test-suite/text/utc-Dali-TextStyle.cpp b/automated-tests/TET/dali-test-suite/text/utc-Dali-TextStyle.cpp deleted file mode 100644 index 796910e..0000000 --- a/automated-tests/TET/dali-test-suite/text/utc-Dali-TextStyle.cpp +++ /dev/null @@ -1,530 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( UtcDaliTextStyleDefaultConstructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextStyleCopyConstructor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextStyleComparisonOperator, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextStyleCopy, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextStyleSetGetFontName, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextStyleSetGetFontStyle, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextStyleSetGetFontPointSize, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextStyleSetGetWeight, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextStyleSetGetTextColor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextStyleSetGetItalics, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextStyleSetGetItalicsAngle, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextStyleSetGetUnderline, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextStyleSetGetShadow, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextStyleSetGetGlow, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextStyleSetGetOutline, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTextStyleSetGetSmoothEdge, POSITIVE_TC_IDX ); - - -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 ); - - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -static void UtcDaliTextStyleDefaultConstructor() -{ - 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() ) ); -} - -static void UtcDaliTextStyleCopyConstructor() -{ - 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() ) ); -} - -static void UtcDaliTextStyleComparisonOperator() -{ - 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 ); -} - -static void UtcDaliTextStyleCopy() -{ - 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 ); -} - -static void UtcDaliTextStyleSetGetFontName() -{ - tet_infoline(" UtcDaliTextStyleSetGetFontName "); - - TestApplication application; - - TextStyle style; - - const std::string fontName( "Arial" ); - style.SetFontName( fontName ); - - DALI_TEST_CHECK( fontName == style.GetFontName() ); -} - -static void UtcDaliTextStyleSetGetFontStyle() -{ - tet_infoline(" UtcDaliTextStyleSetGetFontStyle "); - - TestApplication application; - - TextStyle style; - - const std::string fontStyle( "Book" ); - style.SetFontStyle( fontStyle ); - - DALI_TEST_CHECK( fontStyle == style.GetFontStyle() ); -} - -static void UtcDaliTextStyleSetGetFontPointSize() -{ - tet_infoline(" UtcDaliTextStyleSetGetFontPointSize "); - - TestApplication application; - - TextStyle style; - - style.SetFontPointSize( PointSize( 16.f ) ); - - DALI_TEST_CHECK( PointSize( 16.f ) == style.GetFontPointSize() ); -} - -static void UtcDaliTextStyleSetGetWeight() -{ - tet_infoline(" UtcDaliTextStyleSetGetWeight "); - - TestApplication application; - - TextStyle style; - - style.SetWeight( TextStyle::EXTRABLACK ); - - DALI_TEST_CHECK( TextStyle::EXTRABLACK == style.GetWeight() ); -} - -static void UtcDaliTextStyleSetGetTextColor() -{ - 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() ); -} - -static void UtcDaliTextStyleSetGetItalics() -{ - tet_infoline(" UtcDaliTextStyleSetGetItalics "); - - TestApplication application; - - TextStyle style; - - style.SetItalics( true ); - - DALI_TEST_CHECK( style.GetItalics() ); - - style.SetItalics( false ); - - DALI_TEST_CHECK( !style.GetItalics() ); -} - -static void UtcDaliTextStyleSetGetItalicsAngle() -{ - 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() ); -} - -static void UtcDaliTextStyleSetGetUnderline() -{ - 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() ) ); -} - -static void UtcDaliTextStyleSetGetShadow() -{ - 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() ); -} - -static void UtcDaliTextStyleSetGetGlow() -{ - 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() ); -} - -static void UtcDaliTextStyleSetGetOutline() -{ - 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() ); -} - -static void UtcDaliTextStyleSetGetSmoothEdge() -{ - tet_infoline(" UtcDaliTextStyleSetGetGlow "); - - TestApplication application; - - TextStyle style; - - style.SetSmoothEdge( 0.5f ); - - DALI_TEST_CHECK( fabs( 0.5f - style.GetSmoothEdge() ) < GetRangedEpsilon( 0.5f, style.GetSmoothEdge() ) ); -} diff --git a/automated-tests/TET/dali-test-suite/text/utc-Dali-Utf8.cpp b/automated-tests/TET/dali-test-suite/text/utc-Dali-Utf8.cpp deleted file mode 100644 index 4efd8c3..0000000 --- a/automated-tests/TET/dali-test-suite/text/utc-Dali-Utf8.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( UtcDaliUtf8SequenceLength, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - - -// Positive test case for a method -static void UtcDaliUtf8SequenceLength() -{ - 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 ); -} diff --git a/automated-tests/TET/dali-test-suite/type-registry/.gitignore b/automated-tests/TET/dali-test-suite/type-registry/.gitignore deleted file mode 100644 index 065606c..0000000 --- a/automated-tests/TET/dali-test-suite/type-registry/.gitignore +++ /dev/null @@ -1 +0,0 @@ -utc-Dali-TypeRegistry diff --git a/automated-tests/TET/dali-test-suite/type-registry/Makefile b/automated-tests/TET/dali-test-suite/type-registry/Makefile deleted file mode 120000 index c88d5a7..0000000 --- a/automated-tests/TET/dali-test-suite/type-registry/Makefile +++ /dev/null @@ -1 +0,0 @@ -../master-makefile.mk \ No newline at end of file diff --git a/automated-tests/TET/dali-test-suite/type-registry/file.list b/automated-tests/TET/dali-test-suite/type-registry/file.list deleted file mode 100644 index e40e66a..0000000 --- a/automated-tests/TET/dali-test-suite/type-registry/file.list +++ /dev/null @@ -1,2 +0,0 @@ -TARGETS += \ - utc-Dali-TypeRegistry \ No newline at end of file diff --git a/automated-tests/TET/dali-test-suite/type-registry/tslist b/automated-tests/TET/dali-test-suite/type-registry/tslist deleted file mode 100644 index aa2e6e0..0000000 --- a/automated-tests/TET/dali-test-suite/type-registry/tslist +++ /dev/null @@ -1 +0,0 @@ -/dali-test-suite/type-registry/utc-Dali-TypeRegistry diff --git a/automated-tests/TET/dali-test-suite/type-registry/utc-Dali-TypeRegistry.cpp b/automated-tests/TET/dali-test-suite/type-registry/utc-Dali-TypeRegistry.cpp deleted file mode 100644 index 380859e..0000000 --- a/automated-tests/TET/dali-test-suite/type-registry/utc-Dali-TypeRegistry.cpp +++ /dev/null @@ -1,859 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( UtcDaliTypeRegistryCreateDaliObjects, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTypeRegistryActionViaBaseHandle, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTypeRegistryNames, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTypeRegistryNameEquivalence, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTypeRegistryCustomActor, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTypeRegistryCustomSignalFailure, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTypeRegistryInitFunctions, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliTypeRegistryNameInitFunctions, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyRegistration, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyRegistrationIndexOutOfBounds, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyRegistrationFunctions, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyRegistrationAddSameIndex, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyRegistrationPropertyWritable, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyRegistrationPropertyAnimatable, NEGATIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliPropertyRegistrationInvalidGetAndSet, NEGATIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -// Positive test case for a method -static void UtcDaliTypeRegistryCreateDaliObjects() -{ - 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(); - -} - -/******************************************************************************* - * - * Action through the base handle - * - ******************************************************************************/ -static void UtcDaliTypeRegistryActionViaBaseHandle() -{ - 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)); -} - -static void UtcDaliTypeRegistryNames() -{ - 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 ); - } - -} - -// Check named and typeid are equivalent -static void UtcDaliTypeRegistryNameEquivalence() -{ - 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() ); - -} - -/******************************************************************************* - * - * 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 ) - { - } -}; - -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() - { - } -}; - -static void UtcDaliTypeRegistryCustomActor() -{ - 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" ); -} - -static void UtcDaliTypeRegistryCustomSignalFailure() -{ - // 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 ); -} - -// -// Create function as Init function called -// -static bool CreateCustomInitCalled = false; -BaseHandle CreateCustomInit(void) -{ - CreateCustomInitCalled = true; - return BaseHandle(); -} - -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 ); - -static void UtcDaliTypeRegistryInitFunctions() -{ - TestApplication application; - - DALI_TEST_CHECK( "MyTestCustomActor2" == customTypeInit.RegisteredName() ); - - DALI_TEST_CHECK( true == CreateCustomInitCalled ); - TypeInfo type = TypeRegistry::Get().GetTypeInfo( "MyTestCustomActor2" ); - DALI_TEST_CHECK( type ); -} - - -static bool CreateCustomNamedInitCalled = false; -BaseHandle CreateCustomNamedInit(void) -{ - CreateCustomNamedInitCalled = true; - return BaseHandle(); -} - -const std::string scriptedName("PopupStyle"); -static TypeRegistration scriptedType( scriptedName, typeid(Dali::CustomActor), CreateCustomNamedInit ); - -static void UtcDaliTypeRegistryNameInitFunctions() -{ - 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 ); -} - -// 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 ); -} - -void UtcDaliPropertyRegistration() -{ - 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 -} - -void UtcDaliPropertyRegistrationIndexOutOfBounds() -{ - 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 ); - } -} - -void UtcDaliPropertyRegistrationFunctions() -{ - 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 ); - } -} - -void UtcDaliPropertyRegistrationAddSameIndex() -{ - 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 ); - } -} - -void UtcDaliPropertyRegistrationPropertyWritable() -{ - 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 ) ); -} - -void UtcDaliPropertyRegistrationPropertyAnimatable() -{ - 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 ) ); -} - -void UtcDaliPropertyRegistrationInvalidGetAndSet() -{ - 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 ); - } -} diff --git a/automated-tests/TET/dali-test-suite/utc-MODULE-CLASS.cpp.in b/automated-tests/TET/dali-test-suite/utc-MODULE-CLASS.cpp.in deleted file mode 100644 index 110b148..0000000 --- a/automated-tests/TET/dali-test-suite/utc-MODULE-CLASS.cpp.in +++ /dev/null @@ -1,90 +0,0 @@ -// -// 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; - -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( Utc@MODULE@@CLASS@Method01, POSITIVE_TC_IDX ); -TEST_FUNCTION( Utc@MODULE@@CLASS@Method02, NEGATIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - - -// Positive test case for a method -static void Utc@MODULE@@CLASS@Method01() -{ - TestApplication application; - - tet_infoline("Journaled printf Output"); - tet_result(TET_FAIL); -#if 0 - tet_result(TET_PASS); -#endif -} - - -// Negative test case for a method -static void Utc@MODULE@@CLASS@Method02() -{ - TestApplication application; // Exceptions require TestApplication - - try - { - /* My test code and results */ - DALI_TEST_EQUALS(myVar, expectedValue, TEST_LOCATION); - } - 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(e, "assert conditional", TEST_LOCATION); - } -} - diff --git a/automated-tests/TET/debug.sh b/automated-tests/TET/debug.sh deleted file mode 100755 index c01d55a..0000000 --- a/automated-tests/TET/debug.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/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 - -tmp_script=/tmp/tetexec$$ - -cat > $tmp_script <&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 - -tmp_script=/tmp/tetexec$$ - -cat > $tmp_script <&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/TET/execute_target.sh b/automated-tests/TET/execute_target.sh deleted file mode 100755 index 7aaed5f..0000000 --- a/automated-tests/TET/execute_target.sh +++ /dev/null @@ -1,39 +0,0 @@ -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_target_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 -grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT diff --git a/automated-tests/TET/file.list b/automated-tests/TET/file.list deleted file mode 100644 index dd5d6a3..0000000 --- a/automated-tests/TET/file.list +++ /dev/null @@ -1,4 +0,0 @@ -# Add test suite util header files here - -test_suite_utils_header_files = \ - $(automated_tests_src_dir)/dali-test-suite-utils/*.h diff --git a/automated-tests/TET/rules.mk.in b/automated-tests/TET/rules.mk.in deleted file mode 100644 index d138d37..0000000 --- a/automated-tests/TET/rules.mk.in +++ /dev/null @@ -1,13 +0,0 @@ - -LDFLAGS = `pkg-config --libs $(PKGS)` -LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o -LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s -LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s - -CXXFLAGS = -I. -I../../.. -I../../../capi -I../../dali-test-suite-utils `pkg-config --cflags $(PKGS)` -CXXFLAGS += -I$(TET_ROOT)/inc/tet3 -CXXFLAGS += -Wall -g -O0 -Wno-write-strings -CXXFLAGS += -DDALI_DATA_RO_DIR="\"@dataReadOnlyDir@\"" -CXXFLAGS += -DDALI_DATA_RW_DIR="\"@dataReadWriteDir@\"" -CXXFLAGS += -DDALI_GLYPH_CACHE_DIR="\"@dataReadWriteDir@/glyphcache\"" -CXXFLAGS += @DALI_CFLAGS@ diff --git a/automated-tests/TET/tbp.pl b/automated-tests/TET/tbp.pl deleted file mode 100755 index f69a4d3..0000000 --- a/automated-tests/TET/tbp.pl +++ /dev/null @@ -1,339 +0,0 @@ -#!/usr/bin/perl - -use strict; - -my $num; -my $scen; -my $ref; -my $part; -my $timestamp; -my $testcase; -my $built=0; -my $build_failed=0; -my $build_count=0; -my $build_failure_count=0; -my $ic=0; -my $ic2=0; -my $x=0; -my $tc=0; -my $v; -my $test; -my $time; -my $date; -my %build_tests; -my %build_summary; - -my $executed_testcases=0; -my $execute_no_file=0; -my $executed=0; -my %execute; -my %execute_summary; - -sub parse_file -{ - while(<>) - { - ($num, $scen, $ref) = split(m!\|!, $_); - chomp $ref; - - if($num == 0) - { - ($v, $time, $date) = split(/\s/, $scen); - } -# Execution - elsif($num == 10) # 10|0 /dali-test-suite/actors/utc-Dali-Actor 16:58:27|TC Start, scenario ref 2-0 - { - ($part, $testcase, $timestamp) = split(/\s/, $scen); - $executed_testcases++; - } - elsif($num == 50) # 50||(exec.c, 131): can't exec /home/SERILOCAL/david.steele/Git/HQ-Dali/dali-core/automated-tests/./tet_tmp_dir/24242aa/dali-test-suite/geometry/utc-Dali-MeshData, reply code = ER_NOENT - { - $execute_no_file++; - } - elsif($num == 80) # 80|19 0 16:58:47|TC End, scenario ref 21-0 - { - } - elsif($num == 400) #400|13 1 142 16:58:40|IC Start - { - ($test, $ic, $x, $timestamp) = split(/\s/, $scen); - } - elsif($num == 410) #410|19 1 9 16:58:46|IC End - { - } - elsif($num == 200) #200|13 1 16:58:40|TP Start - { - $execute_summary{"Total"}++; - } - elsif($num == 220) - { - ($test, $tc, $ic2, $timestamp) = split(/\s/, $scen); - $execute{$testcase}->{$ic}->{$tc} = $ref; - $execute_summary{$ref}++; - $executed++; - } - -# Build - elsif($num == 110) # Build - { - ($part, $testcase, $timestamp) = split(/\s/, $scen); - $build_failed=0; - $build_count++; - $build_summary{"Total"}++; - } - - elsif($num == 100) - { - if( ( $ref =~ /utc-/ && $ref =~ m!error!i ) - || - ($ref =~ /^Makefile/ && $ref =~ m!Stop!i ) - || - ($ref =~ /^make/ && ($ref =~ m!Stop!i || $ref =~ m!Error 1! ) ) ) - { - $build_failed = 1; - } - } - - elsif($num == 130) - { - if($build_failed) - { - $build_failure_count++; - $build_summary{"Failure"}++; - } - else - { - $build_summary{"Success"}++; - } - $build_tests{$testcase} = !$build_failed; - } - } - $built = $build_count - $build_failure_count; -} - - -sub heading -{ - print < - - -TETware Test Run Report - - -

-

-TETware Test Run Report

-

- - - - - - - - -
Date of test run:$date
Start time:$time

-
-EOH -} - -sub summary -{ - my $heading = shift; - my $summary_ref = shift; - - print < - -
$heading

-

- - - - -EOS1 - - my ($success_string, @blah) = grep(/(Success|PASS)/, keys(%$summary_ref)); - my $successes = $summary_ref->{$success_string}; - print < - - - -EOS2 - - foreach my $key (sort(grep(!/(Success|PASS|Total)/, keys(%$summary_ref)))) - { - my $fails = $summary_ref->{$key}; - print < - - - -EOS3 - } - - my $total = $summary_ref->{"Total"}; - print < - - - -
ResultCount
$success_string$successes
$key$fails
Total$total

-EOS4 -} - - -sub build_breakdown -{ - print < -

-
-Build mode result breakdown

-

- - - - -EOB - - foreach my $key (sort(keys(%build_tests))) - { - my $success = $build_tests{$key}; - my $class = $success?"success":"failure"; - my $Class = $success?"Success":"Failure"; - my $color = $success?"#33cc33":"#ff5555"; - print("\n"); - print("\n"); - } - print("
TestcaseResult
$key$Class

"); -} - - -sub execute_breakdown -{ - print < -

-
-Execute mode result breakdown

-EOE - - #Constructed with: - #$execute{$testcase}->{$ic}->{$tc} = $ref; - - my %results; - foreach my $testcase (sort(keys(%execute))) - { - #print STDOUT "$testcase\n"; - foreach my $ic (sort(keys(%{$execute{$testcase}}))) - { - my $ic_ref = $execute{$testcase}->{$ic}; - foreach my $tc (sort { $a <=> $b } (keys(%{$ic_ref}))) - { - my $result = $execute{$testcase}->{$ic}->{$tc}; - chomp($result); - $results{$result}->{$testcase} .= ", $ic.$tc"; - #print STDOUT "$testcase $ic.$tc $result\n"; - #print STDOUT "STRUCT:" . "\$results\{" . $result . "\}->\{$testcase\} => " . $results{$result}->{$testcase} . "\n"; - } - } - } - - foreach my $result ( "PASS", (sort(grep(!/PASS/, keys(%results))))) - { - print "

$result

\n"; - print < - - - - -EOE2 - - my $bgcolor = "#ff5555"; - if ($result =~ /PASS/) - { - $bgcolor = "#33cc33"; - } - - #print STDOUT "Result: $result OUT:" . $results{$result} . "\n"; - foreach my $testcase (sort(keys(%{$results{$result}}))) - { - #print STDOUT "$testcase\n"; - my $tests = substr($results{$result}->{$testcase}, 2); - print < - - - -EOE3 - } - print "
TestcaseTest purposes (IC.TP)
$testcase$tests
"; - } -} - - -sub footer -{ - print "
\n\n\n"; -} - -sub report -{ - my $file = shift; - open(my $fh, ">", $file) || die "Can't create $file"; - select $fh; - heading; - - if($build_count) - { - summary("Build mode summary", \%build_summary); - build_breakdown; - } - if(scalar(keys(%execute))) - { - summary("Execute mode summary", \%execute_summary); - execute_breakdown; - } - footer; - select STDOUT; - close $fh; -} - - -## MAIN - -die "No args" if scalar(@ARGV) == 0; -my $htmlname = $ARGV[0]; -$htmlname =~ s/.journal/.html/; - -parse_file(); -report($htmlname); - - -if($build_count) -{ - foreach my $key (sort(keys(%build_tests))) - { - if(!$build_tests{$key}) - { - print STDOUT "$key: Failed\n"; - } - } - print STDOUT "Built $built of $build_count\n"; -} - -if($executed) -{ - my $num_exes=$executed_testcases-$execute_no_file; - print STDOUT "Executed $num_exes of $executed_testcases testcases\n"; - my $passed = $execute_summary{"PASS"}; - my $total = $execute_summary{"Total"}; - my $passRate = ($num_exes / $executed_testcases ) * ( $passed / $total )*100; - print STDOUT "Passed $passed of $total - Pass rate=" . sprintf("%4.1f%%", $passRate) ."\n"; -} - -print "Report output: $htmlname\n"; diff --git a/automated-tests/TET/tet_scen b/automated-tests/TET/tet_scen deleted file mode 100644 index b640d24..0000000 --- a/automated-tests/TET/tet_scen +++ /dev/null @@ -1,117 +0,0 @@ -all - "Starting Full Test Suite" - ^TEST - "Completed Full Test Suite" - -##### All PUBLIC and INTERNAL Tests ##### - -# Test scenario -TEST - ^PUBLIC - ^INTERNAL - -##### PUBLIC Tests ##### - -PUBLIC - ^actors - ^animation - ^common - ^context - ^effects - ^events - ^geometry - ^images - ^material - ^math - ^object-registry - ^property-notification - ^render-tasks - ^signals - ^text - ^type-registry - ^scripting - -actors - :include:/dali-test-suite/actors/tslist - -renderables - :include:/dali-test-suite/actors/tslist-renderables - -text-actor - :include:/dali-test-suite/actors/tslist-text-actor - -animation - :include:/dali-test-suite/animation/tslist - -effects - :include:/dali-test-suite/effects/tslist - -events - :include:/dali-test-suite/events/tslist - -geometry - :include:/dali-test-suite/geometry/tslist - -images - :include:/dali-test-suite/images/tslist - -material - :include:/dali-test-suite/material/tslist - -math - :include:/dali-test-suite/math/tslist - -text - :include:/dali-test-suite/text/tslist - -render-tasks - :include:/dali-test-suite/render-tasks/tslist - -signals - :include:/dali-test-suite/signals/tslist - -object-registry - :include:/dali-test-suite/object-registry/tslist - -type-registry - :include:/dali-test-suite/type-registry/tslist - -property-notification - :include:/dali-test-suite/property-notification/tslist - -context - :include:/dali-test-suite/context/tslist - -common - :include:/dali-test-suite/common/tslist - -scripting - :include:/dali-test-suite/scripting/tslist - -##### INTERNAL Tests ##### - -INTERNAL - ^resource-manager - ^internal-text - ^internal-material - ^image-factory - -resource-manager - :include:/dali-internal-test-suite/resource-manager/tslist - -internal-text - :include:/dali-internal-test-suite/text/tslist - -internal-material - :include:/dali-internal-test-suite/material/tslist - -image-factory - :include:/dali-internal-test-suite/image-factory/tslist - -##### DEBUG ##### -# If you just want to compile/execute only certain TET cases, then you can do as shown below. -# Try not to check in your changes to the debug section. -debug - /dali-test-suite/actors/utc-Dali-ImageActor - -# EOF diff --git a/automated-tests/TET/tetbuild.cfg b/automated-tests/TET/tetbuild.cfg deleted file mode 100644 index 6a05af6..0000000 --- a/automated-tests/TET/tetbuild.cfg +++ /dev/null @@ -1,5 +0,0 @@ -TET_OUTPUT_CAPTURE=True # capture option for build operation checking -TET_BUILD_TOOL=make # build with using make command -TET_BUILD_FILE=-f Makefile # execution file (Makefile) for build -TET_API_COMPLIANT=False # use TET API in Test Case ? -TET_PASS_TC_NAME=True # report passed TC name in Journal file? diff --git a/automated-tests/TET/tetclean.cfg b/automated-tests/TET/tetclean.cfg deleted file mode 100644 index 2a0477a..0000000 --- a/automated-tests/TET/tetclean.cfg +++ /dev/null @@ -1,5 +0,0 @@ -TET_OUTPUT_CAPTURE=True # capture option -TET_CLEAN_TOOL= make clean # clean tool -TET_CLEAN_FILE= Makefile # file for clean -TET_API_COMPLIANT=True # TET API useage -TET_PASS_TC_NAME=True # showing name , passed TC diff --git a/automated-tests/TET/tetexec.cfg b/automated-tests/TET/tetexec.cfg deleted file mode 100644 index ef3e452..0000000 --- a/automated-tests/TET/tetexec.cfg +++ /dev/null @@ -1,5 +0,0 @@ -TET_OUTPUT_CAPTURE=True # capturing execution or not -TET_EXEC_TOOL= # ex) exec : execution tool set up/ Optional -TET_EXEC_FILE= # ex) exectool : execution file/ Optional -TET_API_COMPLIANT=True # Test case or Tool usesTET API? -TET_PASS_TC_NAME=True # showing Passed TC name ? diff --git a/automated-tests/scripts/summarize.pl b/automated-tests/scripts/summarize.pl index 4a96d36..c90eb89 100755 --- a/automated-tests/scripts/summarize.pl +++ b/automated-tests/scripts/summarize.pl @@ -67,6 +67,7 @@ print SUMMARY << "EOS"; EOS +print "\n\nSummary of all tests:\n"; my $output_files = `ls tct*core-tests.xml`; my $file; foreach $file (split /\s+/, $output_files ) @@ -85,6 +86,8 @@ foreach $file (split /\s+/, $output_files ) my $suite_name = $file; $suite_name =~ s/\.xml$//; + print "$suite_name: $num_passes tests passed out of $num_tests ( $pass_rate% )\n"; + print SUMMARY << "EOS2"; $num_tests @@ -102,3 +105,5 @@ EOS2 print SUMMARY "\n"; close SUMMARY; + +print "Summary of results written to summary.xml\n"; diff --git a/automated-tests/src/dali-internal/CMakeLists.txt b/automated-tests/src/dali-internal/CMakeLists.txt index fd77142..c0c886f 100644 --- a/automated-tests/src/dali-internal/CMakeLists.txt +++ b/automated-tests/src/dali-internal/CMakeLists.txt @@ -6,10 +6,12 @@ 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 + utc-Dali-Internal-Font.cpp + utc-Dali-Internal-Handles.cpp + utc-Dali-Internal-ImageFactory.cpp + utc-Dali-Internal-Material.cpp + utc-Dali-Internal-Text.cpp + utc-Dali-Internal-ResourceClient.cpp ) LIST(APPEND TC_SOURCES @@ -29,7 +31,7 @@ PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED dali-core ) -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -ggdb --coverage") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -ggdb --coverage -Wall -Werror=return-type") FOREACH(directory ${${CAPI_LIB}_LIBRARY_DIRS}) SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -L${directory}") diff --git a/automated-tests/src/dali-internal/tct-dali-internal-core.h b/automated-tests/src/dali-internal/tct-dali-internal-core.h index 74b4696..5559789 100644 --- a/automated-tests/src/dali-internal/tct-dali-internal-core.h +++ b/automated-tests/src/dali-internal/tct-dali-internal-core.h @@ -6,6 +6,16 @@ extern void utc_dali_material_startup(void); extern void utc_dali_material_cleanup(void); +extern int UtcDaliFontMeasureTextWidth(void); +extern int UtcDaliFontMeasureTextWidthNegative(void); +extern int UtcDaliFontMeasureTextHeight(void); +extern int UtcDaliFontMeasureTextHeightNegative(void); +extern int UtcDaliCameraActorConstructorRefObject(void); +extern int UtcDaliImageActorConstructorRefObject(void); +extern int UtcDaliLightActorConstructorRefObject(void); +extern int UtcDaliMeshActorConstructorRefObject(void); +extern int UtcDaliModelConstructorRefObject(void); +extern int UtcDaliTextActorConstructorRefObject(void); extern int UtcDaliImageFactoryUseCachedRequest01(void); extern int UtcDaliImageFactoryUseCachedRequest02(void); extern int UtcDaliImageFactoryUseCachedRequest03(void); @@ -32,10 +42,7 @@ 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 UtcDaliTextGetImplementation(void); extern int UtcDaliInternalRequestResourceBitmapRequests01(void); extern int UtcDaliInternalRequestResourceBitmapRequests02(void); extern int UtcDaliInternalRequestResourceBitmapRequests03(void); @@ -64,6 +71,16 @@ extern int UtcDaliInternalAddFrameBufferImage(void); extern int UtcDaliInternalAllocateMesh01(void); testcase tc_array[] = { + {"UtcDaliFontMeasureTextWidth", UtcDaliFontMeasureTextWidth, NULL, NULL}, + {"UtcDaliFontMeasureTextWidthNegative", UtcDaliFontMeasureTextWidthNegative, NULL, NULL}, + {"UtcDaliFontMeasureTextHeight", UtcDaliFontMeasureTextHeight, NULL, NULL}, + {"UtcDaliFontMeasureTextHeightNegative", UtcDaliFontMeasureTextHeightNegative, NULL, NULL}, + {"UtcDaliCameraActorConstructorRefObject", UtcDaliCameraActorConstructorRefObject, NULL, NULL}, + {"UtcDaliImageActorConstructorRefObject", UtcDaliImageActorConstructorRefObject, NULL, NULL}, + {"UtcDaliLightActorConstructorRefObject", UtcDaliLightActorConstructorRefObject, NULL, NULL}, + {"UtcDaliMeshActorConstructorRefObject", UtcDaliMeshActorConstructorRefObject, NULL, NULL}, + {"UtcDaliModelConstructorRefObject", UtcDaliModelConstructorRefObject, NULL, NULL}, + {"UtcDaliTextActorConstructorRefObject", UtcDaliTextActorConstructorRefObject, NULL, NULL}, {"UtcDaliImageFactoryUseCachedRequest01", UtcDaliImageFactoryUseCachedRequest01, NULL, NULL}, {"UtcDaliImageFactoryUseCachedRequest02", UtcDaliImageFactoryUseCachedRequest02, NULL, NULL}, {"UtcDaliImageFactoryUseCachedRequest03", UtcDaliImageFactoryUseCachedRequest03, NULL, NULL}, @@ -90,10 +107,7 @@ testcase tc_array[] = { {"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}, + {"UtcDaliTextGetImplementation", UtcDaliTextGetImplementation, 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}, diff --git a/automated-tests/src/dali-internal/utc-DaliInternal-Font.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-Font.cpp similarity index 100% rename from automated-tests/src/dali-internal/utc-DaliInternal-Font.cpp rename to automated-tests/src/dali-internal/utc-Dali-Internal-Font.cpp diff --git a/automated-tests/src/dali-internal/utc-Dali-Internal-Handles.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-Handles.cpp new file mode 100644 index 0000000..3e2c4fd --- /dev/null +++ b/automated-tests/src/dali-internal/utc-Dali-Internal-Handles.cpp @@ -0,0 +1,106 @@ +// +// 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 + + +using namespace Dali; + +void utc_dali_internal_handles_startup() +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_internal_handles_cleanup() +{ + test_return_value = TET_PASS; +} + + +int UtcDaliCameraActorConstructorRefObject(void) +{ + TestApplication application; + tet_infoline("Testing Dali::CameraActor::CameraActor(Internal::CameraActor*)"); + + CameraActor actor(NULL); + + DALI_TEST_CHECK(!actor); + END_TEST; +} + +int UtcDaliImageActorConstructorRefObject(void) +{ + TestApplication application; + tet_infoline("Testing Dali::ImageActor::ImageActor(Internal::ImageActor*)"); + + ImageActor actor(NULL); + + DALI_TEST_CHECK(!actor); + END_TEST; +} + +int UtcDaliLightActorConstructorRefObject(void) +{ + TestApplication application; + tet_infoline("Testing Dali::LightActor::LightActor(Internal::LightActor*) UtcDaliLightActorConstructorRefObject"); + + LightActor actor(NULL); + + DALI_TEST_CHECK(!actor); + END_TEST; +} + +int UtcDaliMeshActorConstructorRefObject(void) +{ + TestApplication application; + tet_infoline("Testing Dali::MeshActor::MeshActor(Internal::MeshActor*)"); + + MeshActor actor(NULL); + DALI_TEST_CHECK(!actor); + + MeshActor* actorPtr = new MeshActor(); + DALI_TEST_CHECK( ! *actorPtr ); + delete actorPtr; + END_TEST; +} + +int UtcDaliModelConstructorRefObject(void) +{ + TestApplication application; + tet_infoline("Testing Dali::Model::Model(Internal::Model*)"); + + Model model(NULL); + + DALI_TEST_CHECK(!model); + END_TEST; +} + +int UtcDaliTextActorConstructorRefObject(void) +{ + TestApplication application; + tet_infoline("Testing Dali::TextActor::TextActor(Internal::TextActor*)"); + TextActor actor(NULL); + DALI_TEST_CHECK(!actor); + END_TEST; +} diff --git a/automated-tests/src/dali-internal/utc-Dali-ImageFactory.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-ImageFactory.cpp similarity index 100% rename from automated-tests/src/dali-internal/utc-Dali-ImageFactory.cpp rename to automated-tests/src/dali-internal/utc-Dali-Internal-ImageFactory.cpp diff --git a/automated-tests/src/dali-internal/utc-Dali-Material.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-Material.cpp similarity index 100% rename from automated-tests/src/dali-internal/utc-Dali-Material.cpp rename to automated-tests/src/dali-internal/utc-Dali-Internal-Material.cpp diff --git a/automated-tests/src/dali-internal/utc-DaliInternal-ResourceClient.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-ResourceClient.cpp similarity index 100% rename from automated-tests/src/dali-internal/utc-DaliInternal-ResourceClient.cpp rename to automated-tests/src/dali-internal/utc-Dali-Internal-ResourceClient.cpp diff --git a/automated-tests/src/dali-internal/utc-Dali-Internal-Text.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-Text.cpp new file mode 100644 index 0000000..5470ec8 --- /dev/null +++ b/automated-tests/src/dali-internal/utc-Dali-Internal-Text.cpp @@ -0,0 +1,85 @@ +// +// 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 + +using namespace Dali; + +void utc_dali_internal_text_startup() +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_internal_text_cleanup() +{ + test_return_value = TET_PASS; +} + + +int UtcDaliTextGetImplementation(void) +{ + TestApplication application; + + Text text; + + bool assert1 = false; + bool assert2 = false; + + try // const GetImpl + { + const Internal::Text& impl = text.GetImplementation(); + (void)impl; // Avoid unused variable warning + } + 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::GetImplementation: Text is uninitialized\"", TEST_LOCATION ); + + assert1 = true; + } + + try // non const getImp + { + Internal::Text& impl = text.GetImplementation(); + (void)impl; // Avoid unused variable warning + } + 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::GetImplementation: Text is uninitialized\"", TEST_LOCATION ); + + assert2 = true; + } + + if( assert1 && assert2 ) + { + tet_result( TET_PASS ); + } + else + { + tet_result( TET_FAIL ); + } + END_TEST; +} diff --git a/automated-tests/src/dali-unmanaged/CMakeLists.txt b/automated-tests/src/dali-unmanaged/CMakeLists.txt index 93b4936..3966425 100644 --- a/automated-tests/src/dali-unmanaged/CMakeLists.txt +++ b/automated-tests/src/dali-unmanaged/CMakeLists.txt @@ -53,7 +53,7 @@ PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED dali-core ) -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -ggdb --coverage -DDEBUG_ENABLED") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -ggdb --coverage -DDEBUG_ENABLED -Wall -Werror=return-type") FOREACH(directory ${${CAPI_LIB}_LIBRARY_DIRS}) SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -L${directory}") diff --git a/automated-tests/src/dali-unmanaged/tct-dali-unmanaged-core.h b/automated-tests/src/dali-unmanaged/tct-dali-unmanaged-core.h index 32e2714..69003fe 100644 --- a/automated-tests/src/dali-unmanaged/tct-dali-unmanaged-core.h +++ b/automated-tests/src/dali-unmanaged/tct-dali-unmanaged-core.h @@ -182,7 +182,6 @@ 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); @@ -430,7 +429,6 @@ testcase tc_array[] = { {"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}, diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-AnimatableMesh.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-AnimatableMesh.cpp new file mode 100644 index 0000000..18bbbd7 --- /dev/null +++ b/automated-tests/src/dali-unmanaged/utc-Dali-AnimatableMesh.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 +#include + +#include +#include +#include + +using namespace Dali; + +int UtcDaliAnimatableMeshDownCast02(void) +{ + TestApplication application; + tet_infoline("Testing Dali::AnimatableMesh::DownCast()"); + + MeshData meshData; + CreateMeshData(meshData); + Mesh mesh = Mesh::New(meshData); + BaseHandle* bh = &mesh; + + AnimatableMesh mesh2 = AnimatableMesh::DownCast(*bh); + DALI_TEST_CHECK( ! mesh2 ); + END_TEST; +} diff --git a/automated-tests/TET/dali-test-suite/images/utc-Dali-GlyphImage.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-GlyphImage.cpp similarity index 70% rename from automated-tests/TET/dali-test-suite/images/utc-Dali-GlyphImage.cpp rename to automated-tests/src/dali-unmanaged/utc-Dali-GlyphImage.cpp index 24f5afb..7a0a3c8 100644 --- a/automated-tests/TET/dali-test-suite/images/utc-Dali-GlyphImage.cpp +++ b/automated-tests/src/dali-unmanaged/utc-Dali-GlyphImage.cpp @@ -17,48 +17,12 @@ #include #include -#include - -#include - +#include #include using namespace Dali; -static void Startup(); -static void Cleanup(); - -extern "C" { - void (*tet_startup)() = Startup; - void (*tet_cleanup)() = Cleanup; -} - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -#define MAX_NUMBER_OF_TESTS 10000 -extern "C" { - struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS]; -} - -TEST_FUNCTION( UtcDaliGlyphImageNew01, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliGlyphImageNew02, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliGlyphImageDownCast, POSITIVE_TC_IDX ); -TEST_FUNCTION( UtcDaliGlyphImageIsColorGlyph, POSITIVE_TC_IDX ); - -// Called only once before first test is run. -static void Startup() -{ -} - -// Called only once after last test is run -static void Cleanup() -{ -} - -static void UtcDaliGlyphImageNew01() +int UtcDaliGlyphImageNew01(void) { TestApplication application; @@ -72,9 +36,10 @@ static void UtcDaliGlyphImageNew01() DALI_TEST_CHECK( image ); DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::GetGlyphImageFunc ) ); + END_TEST; } -static void UtcDaliGlyphImageNew02() +int UtcDaliGlyphImageNew02(void) { TestApplication application; @@ -89,9 +54,10 @@ static void UtcDaliGlyphImageNew02() DALI_TEST_CHECK( image ); DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::GetGlyphImageFunc ) ); + END_TEST; } -static void UtcDaliGlyphImageDownCast() +int UtcDaliGlyphImageDownCast(void) { TestApplication application; @@ -115,9 +81,10 @@ static void UtcDaliGlyphImageDownCast() GlyphImage image5 = DownCast< GlyphImage >(unInitializedObject); DALI_TEST_CHECK(!image5); + END_TEST; } -static void UtcDaliGlyphImageIsColorGlyph() +int UtcDaliGlyphImageIsColorGlyph(void) { TestApplication application; @@ -126,4 +93,5 @@ static void UtcDaliGlyphImageIsColorGlyph() Character character = Text( std::string( "\xf0\x9f\x98\x81" ) )[0]; DALI_TEST_CHECK( GlyphImage::IsColorGlyph( character ) ); + END_TEST; } diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-ShaderEffect.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-ShaderEffect.cpp index e9d368a..b0559ac 100644 --- a/automated-tests/src/dali-unmanaged/utc-Dali-ShaderEffect.cpp +++ b/automated-tests/src/dali-unmanaged/utc-Dali-ShaderEffect.cpp @@ -201,15 +201,3 @@ int UtcDaliShaderEffectFromProperties03(void) } 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/CMakeLists.txt b/automated-tests/src/dali/CMakeLists.txt index a4cfac3..8da4347 100644 --- a/automated-tests/src/dali/CMakeLists.txt +++ b/automated-tests/src/dali/CMakeLists.txt @@ -83,7 +83,7 @@ PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED dali-core ) -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -ggdb --coverage") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -ggdb --coverage -Wall -Werror=return-type") FOREACH(directory ${${CAPI_LIB}_LIBRARY_DIRS}) SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -L${directory}") 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 index 134597e..06c296d 100644 --- 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 @@ -18,7 +18,8 @@ // // INTERNAL INCLUDES -#include +#include +#include #include void tet_infoline(const char*str); 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 index 0479c6b..c4c1304 100644 --- 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 @@ -23,8 +23,8 @@ #include // INTERNAL INCLUDES -#include - +#include +#include #include #include #include "test-trace-call-stack.h" 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 index 9dba4cc..15f6450 100644 --- 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 @@ -23,7 +23,6 @@ #include // INTERNAL INCLUDES -#include #include #include #include "test-trace-call-stack.h" diff --git a/automated-tests/src/dali/tct-dali-core.h b/automated-tests/src/dali/tct-dali-core.h index 88f558e..6c3544e 100644 --- a/automated-tests/src/dali/tct-dali-core.h +++ b/automated-tests/src/dali/tct-dali-core.h @@ -222,6 +222,7 @@ extern int UtcDaliActorGetChildAt(void); extern int UtcDaliActorSetGetOverlay(void); extern int UtcDaliActorDynamics(void); extern int UtcDaliActorCreateDestroy(void); +extern int UtcDaliActorProperties(void); extern int UtcDaliAlphaFunctionsDefault(void); extern int UtcDaliAlphaFunctionsLinear(void); extern int UtcDaliAlphaFunctionsReverse(void); @@ -378,6 +379,7 @@ extern int UtcDaliAnimationKeyFrames06(void); extern int UtcDaliAnimationAnimateBetweenActorColorAlpha(void); extern int UtcDaliAnimationAnimateBetweenActorColor(void); extern int UtcDaliAnimationAnimateBetweenActorVisible01(void); +extern int UtcDaliAnimationAnimateBetweenActorRotation01(void); extern int UtcDaliAnimationAnimateBetweenActorRotation02(void); extern int UtcDaliAnimationMoveByFloat3(void); extern int UtcDaliAnimationMoveByVector3Alpha(void); @@ -637,6 +639,7 @@ extern int UtcDaliHandleGetPropertyName(void); extern int UtcDaliHandleGetPropertyIndex(void); extern int UtcDaliHandleIsPropertyWritable(void); extern int UtcDaliHandleIsPropertyAnimatable(void); +extern int UtcDaliHandleIsPropertyAConstraintInput(void); extern int UtcDaliHandleGetPropertyType(void); extern int UtcDaliHandleNonAnimtableProperties(void); extern int UtcDaliHandleNonAnimtableCompositeProperties(void); @@ -704,6 +707,7 @@ extern int UtcDaliImageActorNewNull(void); extern int UtcDaliImageActorNewNullWithArea(void); extern int UtcDaliImageActorSetImage(void); extern int UtcDaliImageActorPropertyIndices(void); +extern int UtcDaliImageActorImageProperty(void); extern int UtcDaliImageAttributesConstructor(void); extern int UtcDaliImageAttributesLessThan(void); extern int UtcDaliImageAttributesEquality(void); @@ -760,7 +764,7 @@ extern int UtcDaliLongPressGestureSignalReceptionActorBecomesUntouchable(void); extern int UtcDaliLongPressGestureSignalReceptionMultipleGestureDetectors(void); extern int UtcDaliLongPressGestureSignalReceptionMultipleDetectorsOnActor(void); extern int UtcDaliLongPressGestureSignalReceptionDifferentPossible(void); -extern int UtcDaliLongPressGestureEmitIncorrecteStateClear(void); +extern int UtcDaliLongPressGestureEmitIncorrectStateClear(void); extern int UtcDaliLongPressGestureEmitIncorrectStateContinuing(void); extern int UtcDaliLongPressGestureRepeatedState(void); extern int UtcDaliLongPressGesturePossibleCancelled(void); @@ -804,7 +808,7 @@ extern int UtcDaliMatrixSetTranslation3(void); extern int UtcDaliMatrixTranspose(void); extern int UtcDaliMatrixOStreamOperator(void); extern int UtcDaliMatrixMultiply(void); -extern int UtcDaliMatrixOperatorMultiply(void); +extern int UtcDaliMatrixOperatorMultiply01(void); extern int UtcDaliMatrixOperatorMultiply02(void); extern int UtcDaliMatrixOperatorEquals(void); extern int UtcDaliMatrixOperatorNotEquals(void); @@ -829,6 +833,7 @@ extern int UtcDaliMatrix3EqualityOperator(void); extern int UtcDaliMatrix3InequalityOperator(void); extern int UtcDaliMeshActorConstructorVoid(void); extern int UtcDaliMeshActorNew01(void); +extern int UtcDaliMeshActorNew03(void); extern int UtcDaliMeshActorIndices(void); extern int UtcDaliPanGestureConstructor(void); extern int UtcDaliPanGestureAssignment(void); @@ -1425,6 +1430,7 @@ testcase tc_array[] = { {"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}, + {"UtcDaliActorProperties", UtcDaliActorProperties, 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}, @@ -1581,6 +1587,7 @@ testcase tc_array[] = { {"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}, + {"UtcDaliAnimationAnimateBetweenActorRotation01", UtcDaliAnimationAnimateBetweenActorRotation01, 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}, @@ -1840,6 +1847,7 @@ testcase tc_array[] = { {"UtcDaliHandleGetPropertyIndex", UtcDaliHandleGetPropertyIndex, handle_test_startup, handle_test_cleanup}, {"UtcDaliHandleIsPropertyWritable", UtcDaliHandleIsPropertyWritable, handle_test_startup, handle_test_cleanup}, {"UtcDaliHandleIsPropertyAnimatable", UtcDaliHandleIsPropertyAnimatable, handle_test_startup, handle_test_cleanup}, + {"UtcDaliHandleIsPropertyAConstraintInput", UtcDaliHandleIsPropertyAConstraintInput, 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}, @@ -1907,6 +1915,7 @@ testcase tc_array[] = { {"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}, + {"UtcDaliImageActorImageProperty", UtcDaliImageActorImageProperty, 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}, @@ -1963,7 +1972,7 @@ testcase tc_array[] = { {"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}, + {"UtcDaliLongPressGestureEmitIncorrectStateClear", UtcDaliLongPressGestureEmitIncorrectStateClear, 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}, @@ -2007,7 +2016,7 @@ testcase tc_array[] = { {"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}, + {"UtcDaliMatrixOperatorMultiply01", UtcDaliMatrixOperatorMultiply01, 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}, @@ -2032,6 +2041,7 @@ testcase tc_array[] = { {"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}, + {"UtcDaliMeshActorNew03", UtcDaliMeshActorNew03, 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}, diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp index 284ea19..dca5d0a 100644 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -2851,3 +2851,78 @@ int UtcDaliActorCreateDestroy(void) delete actor; END_TEST; } + +namespace +{ +struct PropertyStringIndex +{ + const char * const name; + const Property::Index index; + const Property::Type type; +}; + +const PropertyStringIndex PROPERTY_TABLE[] = +{ + { "parent-origin", Actor::PARENT_ORIGIN, Property::VECTOR3 }, + { "parent-origin-x", Actor::PARENT_ORIGIN_X, Property::FLOAT }, + { "parent-origin-y", Actor::PARENT_ORIGIN_Y, Property::FLOAT }, + { "parent-origin-z", Actor::PARENT_ORIGIN_Z, Property::FLOAT }, + { "anchor-point", Actor::ANCHOR_POINT, Property::VECTOR3 }, + { "anchor-point-x", Actor::ANCHOR_POINT_X, Property::FLOAT }, + { "anchor-point-y", Actor::ANCHOR_POINT_Y, Property::FLOAT }, + { "anchor-point-z", Actor::ANCHOR_POINT_Z, Property::FLOAT }, + { "size", Actor::SIZE, Property::VECTOR3 }, + { "size-width", Actor::SIZE_WIDTH, Property::FLOAT }, + { "size-height", Actor::SIZE_HEIGHT, Property::FLOAT }, + { "size-depth", Actor::SIZE_DEPTH, Property::FLOAT }, + { "position", Actor::POSITION, Property::VECTOR3 }, + { "position-x", Actor::POSITION_X, Property::FLOAT }, + { "position-y", Actor::POSITION_Y, Property::FLOAT }, + { "position-z", Actor::POSITION_Z, Property::FLOAT }, + { "world-position", Actor::WORLD_POSITION, Property::VECTOR3 }, + { "world-position-x", Actor::WORLD_POSITION_X, Property::FLOAT }, + { "world-position-y", Actor::WORLD_POSITION_Y, Property::FLOAT }, + { "world-position-z", Actor::WORLD_POSITION_Z, Property::FLOAT }, + { "rotation", Actor::ROTATION, Property::ROTATION }, + { "world-rotation", Actor::WORLD_ROTATION, Property::ROTATION }, + { "scale", Actor::SCALE, Property::VECTOR3 }, + { "scale-x", Actor::SCALE_X, Property::FLOAT }, + { "scale-y", Actor::SCALE_Y, Property::FLOAT }, + { "scale-z", Actor::SCALE_Z, Property::FLOAT }, + { "world-scale", Actor::WORLD_SCALE, Property::VECTOR3 }, + { "visible", Actor::VISIBLE, Property::BOOLEAN }, + { "color", Actor::COLOR, Property::VECTOR4 }, + { "color-red", Actor::COLOR_RED, Property::FLOAT }, + { "color-green", Actor::COLOR_GREEN, Property::FLOAT }, + { "color-blue", Actor::COLOR_BLUE, Property::FLOAT }, + { "color-alpha", Actor::COLOR_ALPHA, Property::FLOAT }, + { "world-color", Actor::WORLD_COLOR, Property::VECTOR4 }, + { "world-matrix", Actor::WORLD_MATRIX, Property::MATRIX }, + { "name", Actor::NAME, Property::STRING }, + { "sensitive", Actor::SENSITIVE, Property::BOOLEAN }, + { "leave-required", Actor::LEAVE_REQUIRED, Property::BOOLEAN }, + { "inherit-shader-effect", Actor::INHERIT_SHADER_EFFECT, Property::BOOLEAN }, + { "inherit-rotation", Actor::INHERIT_ROTATION, Property::BOOLEAN }, + { "inherit-scale", Actor::INHERIT_SCALE, Property::BOOLEAN }, + { "color-mode", Actor::COLOR_MODE, Property::STRING }, + { "position-inheritance", Actor::POSITION_INHERITANCE, Property::STRING }, + { "draw-mode", Actor::DRAW_MODE, Property::STRING }, +}; +const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] ); +} // unnamed namespace + +int UtcDaliActorProperties(void) +{ + TestApplication app; + + Actor actor = Actor::New(); + + for ( unsigned int i = 0; i < PROPERTY_TABLE_COUNT; ++i ) + { + tet_printf( "Checking %s == %d\n", PROPERTY_TABLE[i].name, PROPERTY_TABLE[i].index ); + DALI_TEST_EQUALS( actor.GetPropertyName( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].name, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetPropertyIndex( PROPERTY_TABLE[i].name ), PROPERTY_TABLE[i].index, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetPropertyType( PROPERTY_TABLE[i].index ), PROPERTY_TABLE[i].type, TEST_LOCATION ); + } + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Animation.cpp b/automated-tests/src/dali/utc-Dali-Animation.cpp index df58d2f..ec260cf 100644 --- a/automated-tests/src/dali/utc-Dali-Animation.cpp +++ b/automated-tests/src/dali/utc-Dali-Animation.cpp @@ -5776,9 +5776,7 @@ int UtcDaliAnimationAnimateBetweenActorVisible01(void) END_TEST; } -#if 0 -// Valid test case, but no fix in dali-core yet. -//int UtcDaliAnimationAnimateBetweenActorRotation01(void) +int UtcDaliAnimationAnimateBetweenActorRotation01(void) { TestApplication application; @@ -5815,12 +5813,11 @@ int UtcDaliAnimationAnimateBetweenActorVisible01(void) 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) { diff --git a/automated-tests/src/dali/utc-Dali-Handle.cpp b/automated-tests/src/dali/utc-Dali-Handle.cpp index fdc0143..50448e6 100644 --- a/automated-tests/src/dali/utc-Dali-Handle.cpp +++ b/automated-tests/src/dali/utc-Dali-Handle.cpp @@ -358,6 +358,63 @@ int UtcDaliHandleIsPropertyAnimatable(void) END_TEST; } +int UtcDaliHandleIsPropertyAConstraintInput(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Actor properties which can be used as a constraint input: + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::PARENT_ORIGIN ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::PARENT_ORIGIN_X ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::PARENT_ORIGIN_Y ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::PARENT_ORIGIN_Z ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::ANCHOR_POINT ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::ANCHOR_POINT_X ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::ANCHOR_POINT_Y ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::ANCHOR_POINT_Z ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SIZE ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SIZE_WIDTH ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SIZE_HEIGHT ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SIZE_DEPTH ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::POSITION ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::POSITION_X ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::POSITION_Y ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::POSITION_Z ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::ROTATION ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SCALE ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SCALE_X ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SCALE_Y ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::SCALE_Z ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::VISIBLE ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::COLOR ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::COLOR_RED ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::COLOR_GREEN ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::COLOR_BLUE ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::COLOR_ALPHA ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_POSITION ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_ROTATION ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_SCALE ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_COLOR ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_POSITION_X ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_POSITION_Y ) ); + DALI_TEST_CHECK( true == actor.IsPropertyAConstraintInput( Actor::WORLD_POSITION_Z ) ); + + // Actor properties that cannot be used as a constraint input + DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::NAME ) ); + DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::SENSITIVE ) ); + DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::LEAVE_REQUIRED ) ); + DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::INHERIT_SHADER_EFFECT ) ); + DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::INHERIT_ROTATION ) ); + DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::INHERIT_SCALE ) ); + DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::COLOR_MODE ) ); + DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::POSITION_INHERITANCE ) ); + DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::DRAW_MODE ) ); + + END_TEST; +} + + int UtcDaliHandleGetPropertyType(void) { tet_infoline("Positive Test Dali::Handle::GetPropertyType()"); diff --git a/automated-tests/src/dali/utc-Dali-ImageActor.cpp b/automated-tests/src/dali/utc-Dali-ImageActor.cpp index 57bfda0..a46d7c5 100644 --- a/automated-tests/src/dali/utc-Dali-ImageActor.cpp +++ b/automated-tests/src/dali/utc-Dali-ImageActor.cpp @@ -938,3 +938,20 @@ int UtcDaliImageActorPropertyIndices(void) DALI_TEST_EQUALS( indices.size(), imageActor.GetPropertyCount(), TEST_LOCATION ); END_TEST; } + +int UtcDaliImageActorImageProperty(void) +{ + TestApplication application; + Image image = Image::New( "MY_PATH" ); + ImageActor imageActor = ImageActor::New( image ); + + Stage::GetCurrent().Add( imageActor ); + application.SendNotification(); + application.Render(); + + Property::Value imageMap = imageActor.GetProperty( ImageActor::IMAGE ); + DALI_TEST_CHECK( imageMap.HasKey( "filename" ) ); + DALI_TEST_EQUALS( imageMap.GetValue( "filename" ).Get< std::string >(), "MY_PATH", TEST_LOCATION ); + END_TEST; +} + diff --git a/automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp index f825c79..f462950 100644 --- a/automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp @@ -914,7 +914,7 @@ int UtcDaliLongPressGestureSignalReceptionDifferentPossible(void) END_TEST; } -int UtcDaliLongPressGestureEmitIncorrecteStateClear(void) +int UtcDaliLongPressGestureEmitIncorrectStateClear(void) { TestApplication application; diff --git a/automated-tests/src/dali/utc-Dali-Matrix.cpp b/automated-tests/src/dali/utc-Dali-Matrix.cpp index 9608575..0a6f5e2 100644 --- a/automated-tests/src/dali/utc-Dali-Matrix.cpp +++ b/automated-tests/src/dali/utc-Dali-Matrix.cpp @@ -499,7 +499,7 @@ int UtcDaliMatrixMultiply(void) END_TEST; } -int UtcDaliMatrixOperatorMultiply(void) +int UtcDaliMatrixOperatorMultiply01(void) { Vector4 v1(2.0f, 5.0f, 4.0f, 0.0f); diff --git a/automated-tests/src/dali/utc-Dali-MeshActor.cpp b/automated-tests/src/dali/utc-Dali-MeshActor.cpp index 50e7acd..e054aa1 100644 --- a/automated-tests/src/dali/utc-Dali-MeshActor.cpp +++ b/automated-tests/src/dali/utc-Dali-MeshActor.cpp @@ -80,6 +80,24 @@ int UtcDaliMeshActorNew01(void) END_TEST; } +int UtcDaliMeshActorNew03(void) +{ + TestApplication application; + tet_infoline("Testing Dali::Mesh::New() - Create with no mesh"); + + try + { + MeshActor actor = MeshActor::New(); // Shouldn't assert + tet_result(TET_PASS); + } + catch (Dali::DaliException& e) + { + tet_result(TET_FAIL); + } + + END_TEST; +} + int UtcDaliMeshActorIndices(void) { TestApplication application; diff --git a/build/slp/Makefile.am b/build/slp/Makefile.am index ce7bd6b..cf9ae63 100644 --- a/build/slp/Makefile.am +++ b/build/slp/Makefile.am @@ -20,9 +20,6 @@ SUBDIRS = dali-core pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = dali-core.pc dali-test-suite-utils.pc -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 46187aa..3b18801 100644 --- a/build/slp/configure.ac +++ b/build/slp/configure.ac @@ -99,7 +99,6 @@ AC_CONFIG_FILES([ dali-core/Makefile dali-core.pc dali-test-suite-utils.pc - ../../automated-tests/TET/rules.mk ]) AC_OUTPUT diff --git a/build/slp/dali-core/Makefile.am b/build/slp/dali-core/Makefile.am index 24e4425..2aebc6c 100644 --- a/build/slp/dali-core/Makefile.am +++ b/build/slp/dali-core/Makefile.am @@ -179,11 +179,19 @@ CLEANFILES = dali-shaders.cpp \ noinst_PROGRAMS = linker.test -linker_test_SOURCES = linker-test.cpp ../../../automated-tests/TET/dali-test-suite-utils/test-application.cpp +linker_test_SOURCES = linker-test.cpp \ + ../../../automated-tests/src/dali/dali-test-suite-utils/test-application.cpp \ + ../../../automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.cpp \ + ../../../automated-tests/src/dali/dali-test-suite-utils/test-render-controller.cpp \ + ../../../automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.cpp \ + ../../../automated-tests/src/dali/dali-test-suite-utils/test-gesture-manager.cpp \ + ../../../automated-tests/src/dali/dali-test-suite-utils/test-gl-sync-abstraction.cpp \ + ../../../automated-tests/src/dali/dali-test-suite-utils/test-trace-call-stack.cpp + linker_test_CXXFLAGS = \ -Werror -Wall -Wfloat-equal \ - -I../../../automated-tests/TET/dali-test-suite-utils \ + -I../../../automated-tests/src/dali/dali-test-suite-utils \ $(dali_core_includes) \ $(DALI_CFLAGS) \ $(OPENGLES20_CFLAGS) diff --git a/build/slp/dali-core/linker-test.cpp b/build/slp/dali-core/linker-test.cpp index 62b3d78..7bf32f8 100644 --- a/build/slp/dali-core/linker-test.cpp +++ b/build/slp/dali-core/linker-test.cpp @@ -17,10 +17,23 @@ #include "dali/public-api/dali-core.h" #include +#include // Link with TET Test application, need to redefine TET functions -#define tet_infoline printf -#define tet_printf printf +void tet_infoline(const char* str) +{ + puts(str); +} + +void tet_printf(const char* str, ...) +{ + va_list args; + va_start(args, str); + vprintf(str, args); + va_end(args); +} + + #include "test-application.h" /***************************************************************************** diff --git a/packaging/dali.spec b/packaging/dali.spec index 81246f2..f08ab6f 100644 --- a/packaging/dali.spec +++ b/packaging/dali.spec @@ -49,17 +49,6 @@ Requires: %{name} = %{version}-%{release} Integration development package for the OpenGLES Canvas ############################## -# test-suite-utils -############################## -%package test-suite-utils -Summary: Automated Test Suite Framework for OpenGLES Canvas Library -Group: Development/Libs -Requires: %{name} = %{version}-%{release} - -%description test-suite-utils -Automated Test Suite Framework for OpenGLES Canvas Library - -############################## # Preparation ############################## %prep @@ -153,8 +142,3 @@ exit 0 %files integration-devel %defattr(-,root,root,-) %{_includedir}/%{name}/integration-api/* - -%files test-suite-utils -%defattr(-,root,root,-) -%{_libdir}/pkgconfig/%{name}-test-suite-utils.pc -%{_includedir}/%{name}/test-suite-utils/* -- 2.7.4