#include <iostream>
#include <stdlib.h>
#include <dali-toolkit-test-suite-utils.h>
-#include <dali-toolkit/public-api/builder/builder.h>
+#include <dali-toolkit/devel-api/builder/builder.h>
#include <dali/integration-api/events/touch-event-integ.h>
+#define STRINGIFY(A)#A
+
using namespace Dali;
using namespace Toolkit;
namespace
{
-//
-// Note: To avoid escaping double quotes single quotes are used and then replaced
-// before parsing. JSON uses double quotes
-//
-
- std::string JSON_TEXT_ACTOR("\
-{ \
- 'templates': \
- { \
- 'basic-text': \
- { \
- 'type':'TextActor', \
- 'text':'Template Hello', \
- 'size': [150,170,1], \
- 'position':[-10,10,0] \
- } \
- }, \
- 'styles': \
- { \
- 'basic-text': \
- { \
- 'text':'Hello', \
- 'font':'', \
- 'parent-origin':[0.0,0.0,0], \
- 'anchor-point' :[0.5,0.5,0], \
- 'size': [150,170,1], \
- 'position':[-10,10,0] \
- } \
- }, \
- 'animations': \
- { \
- 'rotate': \
- { \
- 'duration': 10, \
- 'properties': \
- [ \
- { \
- 'actor':'text', \
- 'property':'orientation', \
- 'value':[0, 3, 0, 0], \
- 'alpha-function': 'EASE_IN_OUT', \
- 'time-period': {'delay': 0, 'duration': 3 } \
- } \
- ] \
- } \
- }, \
- 'stage': \
- [ \
- { \
- 'name':'text', \
- 'type':'basic-text', \
- 'text':'Hello' \
- }, \
- { \
- 'name':'text2', \
- 'type':'basic-text', \
- 'text':'Hello', \
- 'signals': \
- [ \
- { 'name': 'on-stage', 'action':'set', 'actor':'text2', 'property':'text', 'value':'Jaylo' } \
- ] \
- } \
- ], \
- 'other': \
- [ \
- { \
- 'name':'other-text', \
- 'type':'basic-text', \
- 'text':'Hello' \
- } \
- ] \
-} \
-");
-
-
- std::string JSON_CORE_ACTOR_TREE("\
-{ \
- 'templates': \
- { \
- 'my-camera': { \
- 'type':'CameraActor', \
- 'camera-type':'FreeLook', \
- 'field-of-view': 0.125, \
- 'aspect-ratio':5.0, \
- 'near-plane-distance': 100, \
- 'far-plane-distance': 200 \
- }, \
- 'basic-text': { \
- 'type':'TextActor', \
- 'text':'Hello', \
- 'font':'Freesans', \
- 'smooth-edge':0.2, \
- 'position': [-10.0, 10.0, -1000.0], \
- 'size': [300.0, 250.0, 0.0] \
- } \
- }, \
- 'styles': \
- { \
- 'theme2-text': { \
- 'type':'TextActor', \
- 'text':'Hello', \
- 'font':'Freesans', \
- 'smooth-edge':0.8 \
- } \
- }, \
- 'stage': \
- [ \
- {'name':'txt1', \
- 'type':'TextActor', \
- 'text':'Hello World', \
- 'font':'freesans', \
- 'parent-origin':'CENTER', \
- 'actors': \
- [ \
- { 'type':'basic-text', 'text':'Hello', 'position-y':50 }, \
- { 'type':'basic-text', 'text':'Hello', 'position-y':100 }, \
- { 'type':'basic-text', 'text':'Hello', 'position-y':150 }, \
- { 'type':'basic-text', 'text':'Hello', 'position-y':200 }, \
- { 'type':'basic-text', 'text':'Hello', 'position-y':250 } \
- ] \
- } \
- ] \
-} \
-");
-
std::string ReplaceQuotes(const std::string &in_s)
{
test_return_value = TET_PASS;
}
-int UtcDaliBuilderTextActorCreate(void)
+int UtcDaliBuilderQuitSignal(void)
{
ToolkitTestApplication application;
- Stage stage = Stage::GetCurrent();
-
- tet_infoline(" UtcDaliBuilderTextActorCreate");
+ // JSON with a quit event when the actor is touched
+ std::string json(
+ "{"
+ "\"stage\":"
+ "[{"
+ "\"type\": \"Actor\","
+ "\"size\": [100,100,1],"
+ "\"parent-origin\": \"TOP_LEFT\","
+ "\"anchor-point\": \"TOP_LEFT\","
+ "\"signals\": [{"
+ "\"name\": \"touched\","
+ "\"action\": \"quit\""
+ "}]"
+ "}]"
+ "}"
+ );
Builder builder = Builder::New();
+ builder.LoadFromString( json );
+ builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
- builder.LoadFromString(ReplaceQuotes(JSON_TEXT_ACTOR));
+ // Connect to builder's quit signal
+ bool functorCalled( false );
+ builder.QuitSignal().Connect( &application, BuilderFunctor( functorCalled ) );
- TextActor actor( TextActor::DownCast( builder.Create("basic-text") ) );
+ // Render and notify
+ application.SendNotification();
+ application.Render();
- DALI_TEST_CHECK( actor );
+ // Emit touch event and check that our quit method is called
+ Integration::TouchEvent touchEvent;
+ touchEvent.points.push_back( TouchPoint ( 0, TouchPoint::Down, 10.0f, 10.0f ) );
+ application.ProcessEvent( touchEvent );
+ DALI_TEST_CHECK( functorCalled );
- stage.GetRootLayer().Add( actor );
+ END_TEST;
+}
- application.SendNotification();
- application.Render();
- Vector3 v;
+int UtcDaliBuilderAnimationP(void)
+{
+ ToolkitTestApplication application;
+
+ // JSON with a quit event when the actor is touched
+ std::string json(
+ "{"
+ " \"constants\":"
+ " {"
+ " \"ALPHA_FUNCTION\":\"EASE_IN_OUT\""
+ " },"
+ " \"paths\":"
+ " {"
+ " \"path0\":"
+ " {"
+ " \"points\":[ [-150, -50, 0], [0.0,70.0,0.0], [190.0,-150.0,0.0] ],"
+ " \"curvature\":0.35"
+ " }"
+ " },"
+ " \"animations\": {"
+ " \"animate\": {"
+ " \"loop\": true,"
+ " \"end-action\": \"BAKE\","
+ " \"disconnect-action\": \"BAKE\","
+ " \"properties\":"
+ " [{"
+ " \"actor\": \"greeting\","
+ " \"property\": \"position\","
+ " \"value\": [300, 300, -1000],"
+ " \"alpha-function\": \"{ALPHA_FUNCTION}\","
+ " \"relative\": true,"
+ " \"time-period\": {"
+ " \"delay\": 0,"
+ " \"duration\": 3"
+ " }"
+ " },"
+ " {"
+ " \"actor\": \"greeting\","
+ " \"property\": \"visible\","
+ " \"alpha-function\": \"LINEAR\","
+ " \"value\": true"
+ " },"
+ " {"
+ " \"actor\": \"greeting\","
+ " \"property\": \"size-width\","
+ " \"alpha-function\": \"REVERSE\","
+ " \"value\": 10.0"
+ " },"
+ " {"
+ " \"actor\": \"greeting\","
+ " \"property\": \"orientation\","
+ " \"alpha-function\": \"EASE_IN\","
+ " \"value\": [10.0,20.0,30.0]"
+ " },"
+ " {"
+ " \"actor\": \"greeting\","
+ " \"property\": \"orientation\","
+ " \"alpha-function\": \"EASE_OUT\","
+ " \"value\": [0.0, 0.0, 0.0, 1.0]"
+ " },"
+ " {"
+ " \"actor\": \"greeting\","
+ " \"property\": \"orientation\","
+ " \"alpha-function\": \"EASE_IN_OUT\","
+ " \"value\": [0.0, 0.0, 0.0, 1.0]"
+ " },"
+ " {"
+ " \"actor\": \"greeting\","
+ " \"property\": \"orientation\","
+ " \"alpha-function\": \"EASE_IN_SINE\","
+ " \"value\": [0.0, 0.0, 0.0, 1.0]"
+ " },"
+ " {"
+ " \"actor\": \"greeting\","
+ " \"property\": \"orientation\","
+ " \"alpha-function\": \"EASE_OUT_SINE\","
+ " \"value\": [0.0, 0.0, 0.0, 1.0]"
+ " },"
+ " {"
+ " \"actor\": \"greeting\","
+ " \"property\": \"orientation\","
+ " \"alpha-function\": \"EASE_IN_OUT_SINE\","
+ " \"value\": [0.0, 0.0, 0.0, 1.0]"
+ " },"
+ " {"
+ " \"actor\": \"greeting\","
+ " \"property\": \"orientation\","
+ " \"alpha-function\": \"BOUNCE\","
+ " \"value\": [0.0, 0.0, 0.0, 1.0]"
+ " },"
+ " {"
+ " \"actor\": \"greeting\","
+ " \"property\": \"orientation\","
+ " \"alpha-function\": \"SIN\","
+ " \"value\": [0.0, 0.0, 0.0, 1.0]"
+ " },"
+ " {"
+ " \"actor\": \"greeting\","
+ " \"property\": \"orientation\","
+ " \"alpha-function\": \"EASE_OUT_BACK\","
+ " \"value\": [0.0, 0.0, 0.0, 1.0]"
+ " }"
+ " ]"
+ " },"
+ " \"path-animation\": {"
+ " \"duration\": 3.0,"
+ " \"end-action\": \"DISCARD\","
+ " \"disconnect-action\": \"BAKE_FINAL\","
+ " \"properties\": [{"
+ " \"actor\": \"greeting\","
+ " \"path\":\"path0\","
+ " \"forward\":[1,0,0],"
+ " \"alpha-function\": \"EASE_IN_OUT\","
+ " \"time-period\": {"
+ " \"delay\": 0,"
+ " \"duration\": 3"
+ " }"
+ " }]"
+ " }"
+ " },"
+ " \"stage\": [{"
+ " \"name\": \"greeting\","
+ " \"type\": \"TextLabel\","
+ " \"text\": \"Touch me\","
+ " \"styles\": [\"basic-text\"],"
+ " \"position\": [0, -120, 0],"
+ " \"size\": [200, 200, 1],"
+ " \"orientation\": [0, 0, 30],"
+ " \"signals\": [{"
+ " \"name\": \"touched\","
+ " \"action\": \"play\","
+ " \"animation\": \"animate\""
+ " }]"
+ " }]"
+ "}");
- v = actor.GetCurrentPosition();
- DALI_TEST_CHECK(v.x == -10.0);
- DALI_TEST_CHECK(v.y == 10.0);
- DALI_TEST_CHECK(v.z == 0.0);
+ Builder builder = Builder::New();
+ builder.LoadFromString( json );
+ builder.AddActors( Stage::GetCurrent().GetRootLayer() );
- v = actor.GetCurrentSize();
- DALI_TEST_CHECK(v.x == 150.0);
- DALI_TEST_CHECK(v.y == 170.0);
- DALI_TEST_CHECK(v.z == 1.0);
+ Animation anim = builder.CreateAnimation("animate");
- DALI_TEST_CHECK(actor.GetText() == "Template Hello");
+ DALI_TEST_CHECK( anim );
+
+ Property::Map map;
+ map["ALPHA_FUNCTION"] = "EASE_IN_SQUARE";
+ anim = builder.CreateAnimation("animate", map);
+
+ DALI_TEST_CHECK( anim );
+
+ anim = builder.CreateAnimation("path-animation");
+
+ DALI_TEST_CHECK( anim );
+
+ // trigger play
+ // Emit touch event and check that our quit method is called
+ Integration::TouchEvent touchEvent;
+ touchEvent.points.push_back( TouchPoint ( 0, TouchPoint::Down, 10.0f, 10.0f ) );
+ application.ProcessEvent( touchEvent );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
- actor = TextActor::DownCast( builder.Create("*(&^") );
- DALI_TEST_CHECK(!actor);
END_TEST;
}
-int UtcDaliBuilderTextActorCreateAnimation(void)
+int UtcDaliBuilderAnimationN(void)
{
ToolkitTestApplication application;
- tet_infoline(" UtcDaliBuilderTextActorCreateAnimation");
+ // JSON with a quit event when the actor is touched
+ std::string json(
+ "{"
+ " \"constants\":"
+ " {"
+ " \"TEXT\": \"Touch Me\","
+ " \"NAME\": \"greeting\" "
+ " },"
+ " \"paths\":"
+ " {"
+ " \"path0\":"
+ " {"
+ " \"points\":[ [-150, -50, 0], [0.0,70.0,0.0], [190.0,-150.0,0.0] ],"
+ " \"curvature\":0.35"
+ " }"
+ " },"
+ " \"animations\": {"
+ " \"animate\": {"
+ " \"loop\": true,"
+ " \"end-action\": \"BAKE\","
+ " \"disconnect-action\": \"BAKE\","
+ " \"properties\":"
+ " [{"
+ " \"actor\": \"{NAME}\","
+ " \"property\": \"positioninvalid\","
+ " \"value\": [300, 300, -1000],"
+ " \"alpha-function\": \"EASE_IN_OUT\","
+ " \"relative\": true,"
+ " \"time-period\": {"
+ " \"delay\": 0,"
+ " \"duration\": 3"
+ " }"
+ " }"
+ " ]"
+ " },"
+ " \"animate2\": {"
+ " \"loop\": true,"
+ " \"end-action\": \"BAKE\","
+ " \"disconnect-action\": \"BAKE\","
+ " \"properties\":"
+ " [{"
+ " \"actor\": \"{NAME}\","
+ " \"property\": \"positioninvalid\","
+ " \"value\": [300, 300, -1000],"
+ " \"alpha-function\": \"EGGS_OVER_EASY\","
+ " \"relative\": true,"
+ " \"time-period\": {"
+ " \"delay\": 0,"
+ " \"duration\": 3"
+ " }"
+ " }"
+ " ]"
+ " },"
+ " \"path-animation\": {"
+ " \"duration\": 3.0,"
+ " \"end-action\": \"DISCARD\","
+ " \"disconnect-action\": \"BAKE_FINAL\","
+ " \"properties\": [{"
+ " \"actor\": \"greeting\","
+ " \"path\":\"pathDoesntExist\","
+ " \"forward\":[1,0,0],"
+ " \"alpha-function\": \"EASE_IN_OUT\","
+ " \"time-period\": {"
+ " \"delay\": 0,"
+ " \"duration\": 3"
+ " }"
+ " }]"
+ " }"
+ " },"
+ " \"stage\": [{"
+ " \"name\": \"greeting\","
+ " \"type\": \"TextLabel\","
+ " \"text\": \"Touch me\","
+ " \"styles\": [\"basic-text\"],"
+ " \"position\": [0, -120, 0],"
+ " \"size\": [200, 200, 1],"
+ " \"orientation\": [0, 0, 30],"
+ " \"signals\": [{"
+ " \"name\": \"touched\","
+ " \"action\": \"play\","
+ " \"animation\": \"animate\""
+ " }]"
+ " },"
+ " {"
+ " \"name\": \"greeting2\","
+ " \"type\": \"TextLabel\","
+ " \"text\": \"Touch me\""
+ " }]"
+ "}");
+
Builder builder = Builder::New();
+ builder.LoadFromString( json );
+ builder.AddActors( Stage::GetCurrent().GetRootLayer() );
- builder.LoadFromString(ReplaceQuotes(JSON_TEXT_ACTOR));
+ Animation anim = builder.CreateAnimation("animate");
- builder.AddActors( Stage::GetCurrent().GetRootLayer() );
+ // log warning line coverage
+ anim = builder.CreateAnimation("path-animation");
+ DALI_TEST_CHECK(anim);
- Animation anim = builder.CreateAnimation("rotate");
- DALI_TEST_CHECK( anim );
+ anim = builder.CreateAnimation("animate");
+ DALI_TEST_CHECK(anim);
+
+ anim = builder.CreateAnimation("animate2");
+ DALI_TEST_CHECK(anim);
+
+ // create referencing a different actor aka animation templates
+ Property::Map map;
+ map["NAME"] = "greeting2";
+ anim = builder.CreateAnimation("animate2", map);
+ DALI_TEST_CHECK(anim);
+
+ // alternative actor to use for FindChildByName
+ anim = builder.CreateAnimation("animate2", Dali::Stage::GetCurrent().GetRootLayer());
+ DALI_TEST_CHECK(anim);
+
+ // alternative actor to use for FindChildByName
+ anim = builder.CreateAnimation("animate2", map, Dali::Stage::GetCurrent().GetRootLayer());
+ DALI_TEST_CHECK(anim);
- DALI_TEST_CHECK( 10.0f == anim.GetDuration() );
END_TEST;
+
}
-int UtcDaliBuilderTextActorApplyFromStyle(void)
+int UtcDaliBuilderConstantsP(void)
{
ToolkitTestApplication application;
- tet_infoline(" UtcDaliBuilderTextActorApplyFromStyle");
+ // JSON with a quit event when the actor is touched
+ std::string json(
+ "{"
+ "\"constants\":"
+ "{"
+ " \"IMAGE_PATH\": \"apath\","
+ " \"WIDTH\": 22.3,"
+ " \"ANCHOR\": \"TOP_LEFT\","
+ " \"PADDING\": [1,2,3,4]"
+ "},"
+ "\"stage\":"
+ "[{"
+ " \"type\": \"ImageActor\","
+ " \"name\": \"{NAME}\","
+ " \"size\": [100,100,1],"
+ " \"parent-origin\": \"TOP_LEFT\","
+ " \"anchor-point\": \"{ANCHOR}\","
+ " \"padding\": \"{PADDING}\","
+ " \"image\": { \"filename\": \"dir/{IMAGE_PATH}\" },"
+ " \"size-width\": \"{WIDTH}\","
+ " \"signals\": [{"
+ " \"name\": \"touched\","
+ " \"action\": \"quit\""
+ " }]"
+ "}]"
+ "}"
+ );
Builder builder = Builder::New();
+ builder.LoadFromString( json );
- builder.LoadFromString(ReplaceQuotes(JSON_TEXT_ACTOR));
+ builder.AddConstant( "NAME", "image" );
- TextActor actor = TextActor::New("a");
+ Property::Map map = builder.GetConstants();
- builder.ApplyStyle("basic-text", actor);
+ Dali::Property::Value* pValue = map.Find( "NAME" );
- DALI_TEST_CHECK( actor );
+ DALI_TEST_CHECK( pValue );
- Stage::GetCurrent().GetRootLayer().Add( actor );
+ pValue = map.Find( "IMAGE_PATH" );
- application.SendNotification();
- application.Render();
+ DALI_TEST_CHECK( pValue );
- Vector3 v;
+ Dali::Property::Value value = builder.GetConstant( "WIDTH" );
- v = actor.GetCurrentPosition();
- DALI_TEST_CHECK(v.x == -10.0);
- DALI_TEST_CHECK(v.y == 10.0);
- DALI_TEST_CHECK(v.z == 0.0);
+ DALI_TEST_CHECK( value.GetType() != Property::NONE );
- v = actor.GetCurrentSize();
- DALI_TEST_CHECK(v.x == 150.0);
- DALI_TEST_CHECK(v.y == 170.0);
- DALI_TEST_CHECK(v.z == 1.0);
+ builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
+ DALI_TEST_CHECK( builder );
- DALI_TEST_CHECK(actor.GetText() == "Hello");
+ Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("image");
+ DALI_TEST_CHECK( actor );
END_TEST;
}
-int UtcDaliBuilderAddActors(void)
+int UtcDaliBuilderTemplatesAndStylesP(void)
{
ToolkitTestApplication application;
- tet_infoline(" UtcDaliBuilderAddActors");
+ // JSON with a quit event when the actor is touched
+ std::string json(
+ "{\n"
+ "\"constants\":"
+ "{"
+ " \"SIZE\": [10,20,30]"
+ "},"
+ "\"styles\":\n"
+ "{\n"
+ " \"image-style\": \n"
+ " {\n"
+ " \"color\": [1,0,0,1],\n"
+ " \"actors\": {\n"
+ " \"child-image\": {\n"
+ " \"color\": [0,1,0,1]\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "},\n"
+ "\"templates\":\n"
+ "{\n"
+ " \"image-tree\": { \n"
+ " \"type\": \"ImageActor\",\n"
+ " \"styles\": [\"image-style\"],\n"
+ " \"name\": \"image\",\n"
+ " \"size\": \"{SIZE}\",\n"
+ " \"signals\": [{\n"
+ " \"name\": \"touched\",\n"
+ " \"action\": \"quit\"\n"
+ " }],\n"
+ " \"actors\": [\n"
+ " {\n"
+ " \"type\":\"ImageActor\",\n"
+ " \"name\":\"child-image\" \n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ "},\n"
+ "\"stage\":"
+ "[{"
+ " \"type\": \"image-tree\","
+ " \"size\": [100,100,1]"
+ "}]"
+ "}\n"
+ );
+
+ std::string stylejson(
+ "{\n"
+ " \"color\": [1,0,0,1],\n"
+ " \"actors\": {\n"
+ " \"child-image\": {\n"
+ " \"color\": [0,1,0,1]\n"
+ " }\n"
+ " }\n"
+ "}\n"
+ );
+
+ std::string templatejson(
+ "{ \n"
+ " \"type\": \"ImageActor\",\n"
+ " \"styles\": [\"image-style\"],\n"
+ " \"name\": \"image\",\n"
+ " \"size\": \"{SIZE}\",\n"
+ " \"signals\": [{\n"
+ " \"name\": \"touched\",\n"
+ " \"action\": \"quit\"\n"
+ " }],\n"
+ " \"actors\": [\n"
+ " {\n"
+ " \"type\":\"ImageActor\",\n"
+ " \"name\":\"child-image\" \n"
+ " }\n"
+ " ]\n"
+ "}\n"
+ );
Builder builder = Builder::New();
+ builder.LoadFromString( json );
- builder.LoadFromString(ReplaceQuotes(JSON_TEXT_ACTOR));
+ ImageActor actor = ImageActor::DownCast( builder.Create( "image-tree" ) );
+ DALI_TEST_CHECK( actor );
- builder.AddActors( Stage::GetCurrent().GetRootLayer() );
+ Dali::Property::Map map;
+ map["SIZE"] = Vector3(100,100,1);
+ actor = ImageActor::DownCast( builder.Create( "image-tree", map ) );
+ DALI_TEST_CHECK( actor );
- application.SendNotification();
- application.Render();
+ // create from json snippet
+ actor = ImageActor::DownCast( builder.CreateFromJson( templatejson ) );
+ DALI_TEST_CHECK( actor );
- TextActor actor = TextActor::DownCast( Stage::GetCurrent().GetRootLayer().FindChildByName("text") );
- DALI_TEST_CHECK( actor );
- DALI_TEST_CHECK(actor.GetText() == "Hello");
+ // NB: already applied in create
+ DALI_TEST_CHECK( builder.ApplyStyle( "image-style", actor ) );
+
+ // apply from json snippet
+ DALI_TEST_CHECK( builder.ApplyFromJson( actor, stylejson ) );
END_TEST;
}
-int UtcDaliBuilderAddActorsOther(void)
+int UtcDaliBuilderRenderTasksP(void)
{
ToolkitTestApplication application;
- tet_infoline(" UtcDaliBuilderAddActorsOther");
-
- Actor rootActor = Stage::GetCurrent().GetRootLayer();
+ // JSON with a quit event when the actor is touched
+ std::string json(
+ "{\n"
+ "\"render-tasks\":\n"
+ "{\n"
+ " \"task0\": {\n"
+ " \"source-actor\": \"image\",\n"
+ " \"camera-actor\": \"camera\" \n"
+ " }\n"
+ "},\n"
+ "\"stage\":\n"
+ "[\n"
+ " { \n"
+ " \"type\": \"CameraActor\",\n"
+ " \"name\": \"image\"\n"
+ " }, \n"
+ " { \n"
+ " \"type\": \"ImageActor\",\n"
+ " \"name\": \"image\",\n"
+ " \"size\": [100,100,1],\n"
+ " \"signals\": [{\n"
+ " \"name\": \"touched\",\n"
+ " \"action\": \"quit\"\n"
+ " }],\n"
+ " \"actors\": [\n"
+ " {\n"
+ " \"type\":\"ImageActor\",\n"
+ " \"name\":\"child-image\" \n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ "]\n"
+ "}\n"
+ );
Builder builder = Builder::New();
+ builder.LoadFromString( json );
- builder.LoadFromString(ReplaceQuotes(JSON_TEXT_ACTOR));
+ unsigned int count = Stage::GetCurrent().GetRenderTaskList().GetTaskCount();
- builder.AddActors( "other", rootActor );
+ // coverage
+ builder.CreateRenderTask( "task0" );
- application.SendNotification();
- application.Render();
-
- TextActor actor = TextActor::DownCast( Stage::GetCurrent().GetRootLayer().FindChildByName("other-text") );
-
- DALI_TEST_CHECK( actor );
- DALI_TEST_CHECK(actor.GetText() == "Hello");
+ DALI_TEST_CHECK( count <
+ Stage::GetCurrent().GetRenderTaskList().GetTaskCount() );
END_TEST;
}
-
-int UtcDaliBuilderStyles(void)
+int UtcDaliBuilderChildActionP(void)
{
ToolkitTestApplication application;
- tet_infoline(" UtcDaliBuilderStyles");
+ // JSON with a quit event when the actor is touched
+ std::string json(
+ "{\n"
+ " \"stage\":\n"
+ " [{\n"
+ " \"type\": \"Actor\",\n"
+ " \"name\": \"actor\",\n"
+ " \"size\": [100,100,1],\n"
+ " \"parent-origin\": \"TOP_LEFT\",\n"
+ " \"anchor-point\": \"TOP_LEFT\",\n"
+ " \"actors\": [{\n"
+ " \"type\": \"Actor\",\n"
+ " \"name\": \"sub-actor\"\n"
+ " }],\n"
+ " \"signals\": [{\n"
+ " \"name\": \"touched\",\n"
+ " \"action\": \"hide\",\n"
+ " \"actor\": \"actor\",\n"
+ " \"child-actor\": \"sub-actor\"\n"
+ " }]\n"
+ " }]\n"
+ "}\n"
+ );
Builder builder = Builder::New();
+ builder.LoadFromString( json );
+ builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Emit touch event and check that our quit method is called
+ Integration::TouchEvent touchEvent;
+ touchEvent.points.push_back( TouchPoint ( 0, TouchPoint::Down, 10.0f, 10.0f ) );
+ application.ProcessEvent( touchEvent );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
- builder.LoadFromString(ReplaceQuotes(JSON_CORE_ACTOR_TREE));
+ Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("sub-actor");
+ DALI_TEST_CHECK( actor );
- BaseHandle handle = builder.Create("my-camera");
- CameraActor camera = CameraActor::DownCast(handle);
+ DALI_TEST_CHECK( !actor.IsVisible() );
- DALI_TEST_CHECK(camera);
+ END_TEST;
+}
- Property::Value v;
+int UtcDaliBuilderSetPropertyActionP(void)
+{
+ ToolkitTestApplication application;
- v = camera.GetProperty( camera.GetPropertyIndex("field-of-view") );
- DALI_TEST_CHECK( 0.125f == v.Get<float>() );
+ // JSON with a quit event when the actor is touched
+ std::string json(
+ "{\n"
+ " \"stage\":\n"
+ " [{\n"
+ " \"type\": \"Actor\",\n"
+ " \"name\": \"actor\",\n"
+ " \"size\": [100,100,1],\n"
+ " \"parent-origin\": \"TOP_LEFT\",\n"
+ " \"anchor-point\": \"TOP_LEFT\",\n"
+ " \"actors\": [{\n"
+ " \"type\": \"Actor\",\n"
+ " \"name\": \"sub-actor\"\n"
+ " }],\n"
+ " \"signals\": [{\n"
+ " \"name\": \"touched\",\n"
+ " \"action\": \"set\",\n"
+ " \"actor\": \"sub-actor\",\n"
+ " \"property\": \"visible\",\n"
+ " \"value\": false\n"
+ " }]\n"
+ " }]\n"
+ "}\n"
+ );
- v = camera.GetProperty( camera.GetPropertyIndex("aspect-ratio") );
- DALI_TEST_CHECK( 5.0f == v.Get<float>() );
+ Builder builder = Builder::New();
+ builder.LoadFromString( json );
+ builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
- handle = builder.Create("basic-text");
- TextActor textActor = TextActor::DownCast(handle);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
- v = textActor.GetProperty( textActor.GetPropertyIndex("smooth-edge") );
+ // Emit touch event and check that our quit method is called
+ Integration::TouchEvent touchEvent;
+ touchEvent.points.push_back( TouchPoint ( 0, TouchPoint::Down, 10.0f, 10.0f ) );
+ application.ProcessEvent( touchEvent );
- DALI_TEST_CHECK( 0.2f == v.Get<float>() );
+ // Render and notify
+ application.SendNotification();
+ application.Render();
- // test ApplyStyle another
- builder.ApplyStyle("theme2-text", textActor);
+ Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("sub-actor");
+ DALI_TEST_CHECK( actor );
- v = textActor.GetProperty( textActor.GetPropertyIndex("smooth-edge") );
- DALI_TEST_CHECK( 0.8f == v.Get<float>() );
+ DALI_TEST_CHECK( !actor.IsVisible() );
END_TEST;
}
-int UtcDaliBuilderSetProperty(void)
+int UtcDaliBuilderGenericActionP(void)
{
ToolkitTestApplication application;
- tet_infoline(" UtcDaliBuilderSetProperty");
+ // JSON with a quit event when the actor is touched
+ std::string json(
+ "{\n"
+ " \"stage\":\n"
+ " [{\n"
+ " \"type\": \"Actor\",\n"
+ " \"name\": \"actor\",\n"
+ " \"size\": [100,100,1],\n"
+ " \"parent-origin\": \"TOP_LEFT\",\n"
+ " \"anchor-point\": \"TOP_LEFT\",\n"
+ " \"actors\": [{\n"
+ " \"type\": \"Actor\",\n"
+ " \"name\": \"sub-actor\"\n"
+ " }],\n"
+ " \"signals\": [{\n"
+ " \"name\": \"touched\",\n"
+ " \"action\": \"hide\"\n"
+ " }]\n"
+ " }]\n"
+ "}\n"
+ );
Builder builder = Builder::New();
+ builder.LoadFromString( json );
+ builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
- builder.LoadFromString(ReplaceQuotes(JSON_TEXT_ACTOR));
+ // Render and notify
+ application.SendNotification();
+ application.Render();
- builder.AddActors( Stage::GetCurrent().GetRootLayer() );
+ // Emit touch event and check that our quit method is called
+ Integration::TouchEvent touchEvent;
+ touchEvent.points.push_back( TouchPoint ( 0, TouchPoint::Down, 10.0f, 10.0f ) );
+ application.ProcessEvent( touchEvent );
+ // Render and notify
application.SendNotification();
application.Render();
- TextActor actor = TextActor::DownCast( Stage::GetCurrent().GetRootLayer().FindChildByName("text2") );
-
+ Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("actor");
DALI_TEST_CHECK( actor );
- DALI_TEST_CHECK( actor.GetText() == "Jaylo" );
+
+ DALI_TEST_CHECK( !actor.IsVisible() );
END_TEST;
}
-int UtcDaliBuilderCreateFromJson(void)
+int UtcDaliBuilderPropertyNotificationP(void)
{
ToolkitTestApplication application;
- tet_infoline(" UtcDaliBuilderCreateFromJson");
+ // JSON with a quit event when the actor is touched
+ std::string json(
+ "{\n"
+ " \"stage\":\n"
+ " [{\n"
+ " \"type\": \"Actor\",\n"
+ " \"name\": \"actor\",\n"
+ " \"size\": [100,100,1],\n"
+ " \"parent-origin\": \"TOP_LEFT\",\n"
+ " \"anchor-point\": \"TOP_LEFT\",\n"
+ " \"actors\": [{\n"
+ " \"type\": \"Actor\",\n"
+ " \"name\": \"sub-actor\"\n"
+ " }],\n"
+ " \"signals\": [{\n"
+ " \"name\": \"touched\",\n"
+ " \"action\": \"hide\"\n"
+ " }],\n"
+ " \"notifications\": [{\n"
+ " \"property\": \"visible\",\n"
+ " \"condition\": \"False\",\n"
+ " \"action\": \"show\"\n"
+ " }]\n"
+ " }]\n"
+ "}\n"
+ );
Builder builder = Builder::New();
+ builder.LoadFromString( json );
+ builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
- TextActor actor = TextActor::DownCast( builder.CreateFromJson("foobar") );
+ // Emit touch event and check that our quit method is called
+ Integration::TouchEvent touchEvent;
+ touchEvent.points.push_back( TouchPoint ( 0, TouchPoint::Down, 10.0f, 10.0f ) );
+ application.ProcessEvent( touchEvent );
- DALI_TEST_CHECK( !actor );
+ // Render and notify
+ application.SendNotification();
+ application.Render();
- actor = TextActor::DownCast(
- builder.CreateFromJson(
- ReplaceQuotes("{'type':'TextActor','text':'Hi'}") ) );
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+ Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("actor");
DALI_TEST_CHECK( actor );
- DALI_TEST_CHECK( actor.GetText() == "Hi" );
+ DALI_TEST_CHECK( actor.IsVisible() );
END_TEST;
}
-int UtcDaliBuilderApplyFromJson(void)
+int UtcDaliBuilderCustomPropertyP(void)
{
ToolkitTestApplication application;
- tet_infoline(" UtcDaliBuilderApplyFromJson");
+ // JSON with a quit event when the actor is touched
+ std::string json(
+ "{\n"
+ "\"templates\":\n"
+ "{\n"
+ " \"image-tree\": { \n"
+ " \"type\": \"ImageActor\",\n"
+ " \"name\": \"image\",\n"
+ " \"size\": [100,100,1],\n"
+ " \"signals\": [{\n"
+ " \"name\": \"touched\",\n"
+ " \"action\": \"quit\"\n"
+ " }],\n"
+ " \"custom-properties\": {\n"
+ " \"newproperty\": true\n"
+ " },\n"
+ " \"actors\": [\n"
+ " {\n"
+ " \"type\":\"ImageActor\",\n"
+ " \"name\":\"child-image\" \n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ "}\n"
+ "}\n"
+ );
Builder builder = Builder::New();
+ builder.LoadFromString( json );
- TextActor actor = TextActor::DownCast(
- builder.CreateFromJson(
- ReplaceQuotes("{'type':'TextActor','text':'Hi'}") ) );
-
+ ImageActor actor = ImageActor::DownCast( builder.Create( "image-tree" ) );
DALI_TEST_CHECK( actor );
- DALI_TEST_CHECK( actor.GetText() == "Hi" );
+ // NB: already applied in create
+ Property::Index index = actor.GetPropertyIndex("newproperty");
+ DALI_TEST_CHECK( Property::INVALID_INDEX != index );
+ Property::Value value = actor.GetProperty(index);
+ DALI_TEST_CHECK( value.Get<bool>() == true );
- DALI_TEST_CHECK( !builder.ApplyFromJson(actor, ReplaceQuotes("foobar") ) );
+ END_TEST;
+}
- builder.ApplyFromJson(actor, ReplaceQuotes("{'text':'low'}") );
+int UtcDaliBuilderShaderEffectP(void)
+{
+ ToolkitTestApplication application;
+
+ // JSON with a quit event when the actor is touched
+ std::string json(
+ "{\n"
+ " \"stage\": [\n"
+ " {\n"
+ " \"type\": \"ImageActor\",\n"
+ " \"name\": \"Image1\",\n"
+ " \"position\": [\n"
+ " 0.40461349487305,\n"
+ " 0.9150390625,\n"
+ " 0.0\n"
+ " ],\n"
+ " \"parent-origin\": [0.5, 0.5, 0.5],\n"
+ " \"size\": [200, 200, 0],\n"
+ " \"effect\": \"Ripple2D\",\n"
+ " \"image\": {\n"
+ " \"filename\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\",\n"
+ " \"width\": 200,\n"
+ " \"height\": 80,\n"
+ " \"load-policy\": \"IMMEDIATE\",\n"
+ " \"release-policy\": \"NEVER\"\n"
+ " },\n"
+ " \"signals\": [\n"
+ " {\n"
+ " \"name\": \"on-stage\",\n"
+ " \"action\": \"play\",\n"
+ " \"animation\": \"Animation_1\"\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ " ],\n"
+ " \"paths\": {},\n"
+ " \"animations\": {\n"
+ " \"Animation_1\": {\n"
+ " \"loop\":true,\n"
+ " \"properties\": [\n"
+ " {\n"
+ " \"actor\": \"Image1\",\n"
+ " \"property\": \"uTime\",\n"
+ " \"value\": 10.0,\n"
+ " \"alpha-function\": \"LINEAR\",\n"
+ " \"time-period\": {\n"
+ " \"delay\": 0,\n"
+ " \"duration\": 10.0\n"
+ " },\n"
+ " \"gui-builder-timeline-color\": \"#8dc0da\"\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ " },\n"
+ " \"shader-effects\": {\n"
+ " \"Ripple2D\": {\n"
+ " \"program\": {\n"
+ " \"vertexPrefix\": \"\",\n"
+ " \"vertex\": \"void main(void)\\n{\\n gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\\n vTexCoord = aTexCoord;\\n}\\n\\n\",\n"
+ " \"fragmentPrefix\": \"\",\n"
+ " \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n highp vec2 textureSize = sTextureRect.zw - sTextureRect.xy;\\n highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n highp float len = length(pos);\\n highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n"
+ " \"geometry-type\": \"GEOMETRY_TYPE_IMAGE\"\n"
+ " },\n"
+ " \"geometry-hints\": \"HINT_NONE\",\n"
+ " \"grid-density\": 0,\n"
+ " \"loop\": true,\n"
+ " \"uAmplitude\": 0.02,\n"
+ " \"uTime\": 0.0\n"
+ " }\n"
+ " }\n"
+ "}\n"
+
+ );
+
+ Builder builder = Builder::New();
+ builder.LoadFromString( json );
- DALI_TEST_CHECK( actor.GetText() == "low" );
+ ShaderEffect effect = builder.GetShaderEffect("Ripple2D");
+
+ // coverage
+ DALI_TEST_CHECK( effect );
END_TEST;
}
-int UtcDaliBuilderQuitSignal(void)
+
+int UtcDaliBuilderLoadFromStringN(void)
{
ToolkitTestApplication application;
// JSON with a quit event when the actor is touched
std::string json(
- "{"
+ "asdfsadf dsf asdf asdf {"
"\"stage\":"
"[{"
"\"type\": \"Actor\","
"}"
);
Builder builder = Builder::New();
+
+ bool assert1 = false;
+
+ try
+ {
+ builder.LoadFromString( json );
+ }
+ catch( Dali::DaliException& e )
+ {
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_EQUALS(e.condition, "!\"Cannot parse JSON\"", TEST_LOCATION);
+ assert1 = true;
+ }
+
+ DALI_TEST_CHECK( assert1 );
+
+ END_TEST;
+}
+
+int UtcDaliBuilderShaderEffect2P(void)
+{
+ ToolkitTestApplication application;
+
+ // JSON with a quit event when the actor is touched
+ std::string json(
+ "{\n"
+ "\"templates\":\n"
+ "{\n"
+ " \"image-tree\": { \n"
+ " \"type\": \"ImageActor\",\n"
+ " \"size\": [100,100,1],\n"
+ " \"parent-origin\": [0.5, 0.5, 0.5],\n"
+ " \"position\": [\n"
+ " 0.40461349487305,\n"
+ " 0.9150390625,\n"
+ " 0.0\n"
+ " ],\n"
+ " \"signals\": [{\n"
+ " \"name\": \"touched\",\n"
+ " \"action\": \"quit\"\n"
+ " }],\n"
+ " \"actors\": [\n"
+ " {\n"
+ " \"type\":\"ImageActor\",\n"
+ " \"name\":\"child-image\" \n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ "},\n"
+ " \"stage\": [\n"
+ " {\n"
+ " \"type\": \"image-tree\",\n"
+ " \"name\": \"Image1\",\n"
+ " \"effect\": \"Ripple2D\",\n"
+ " \"image\": \"offscreen\""
+ " }\n"
+ " ],\n"
+ " \"shader-effects\": {\n"
+ " \"Ripple2D\": {\n"
+ " \"program\": {\n"
+ " \"vertexPrefix\": \"\",\n"
+ " \"vertex\": \"void main(void)\\n{\\n gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\\n vTexCoord = aTexCoord;\\n}\\n\\n\",\n"
+ " \"fragmentPrefix\": \"\",\n"
+ " \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n highp vec2 textureSize = sTextureRect.zw - sTextureRect.xy;\\n highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n highp float len = length(pos);\\n highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n"
+ " \"geometry-type\": \"GEOMETRY_TYPE_IMAGE\"\n"
+ " },\n"
+ " \"geometry-hints\": \"HINT_NONE\",\n"
+ " \"grid-density\": 0,\n"
+ " \"loop\": true,\n"
+ " \"uAmplitude\": 0.02,\n"
+ " \"uTime\": 0.0\n"
+ " }\n"
+ " },\n"
+ " \"frame-buffer-images\": {\n"
+ " \"offscreen\": {\n"
+ " \"type\": \"FrameBufferImage\","
+ " \"pixel-format\":\"RGBA8888\","
+ " \"width\": 400,"
+ " \"height\": 400"
+ " }"
+ " }"
+ "}\n"
+
+ );
+
+ Builder builder = Builder::New();
builder.LoadFromString( json );
- builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
- // Connect to builder's quit signal
- bool functorCalled( false );
- builder.QuitSignal().Connect( &application, BuilderFunctor( functorCalled ) );
+ // coverage
+ DALI_TEST_CHECK( true );
+
+ END_TEST;
+}
+
+int UtcDaliBuilderAddActorsP(void)
+{
+ ToolkitTestApplication application;
+
+ // JSON with a quit event when the actor is touched
+ std::string json(
+ "{\n"
+ " \"arbitarysection\":\n"
+ " [{\n"
+ " \"type\": \"Actor\",\n"
+ " \"name\": \"actor\",\n"
+ " \"size\": [100,100,1],\n"
+ " \"parent-origin\": \"TOP_LEFT\",\n"
+ " \"anchor-point\": \"TOP_LEFT\",\n"
+ " \"actors\": [{\n"
+ " \"type\": \"Actor\",\n"
+ " \"name\": \"sub-actor\",\n"
+ " \"visible\": false\n"
+ " }],\n"
+ " \"signals\": [{\n"
+ " \"name\": \"touched\",\n"
+ " \"action\": \"hide\",\n"
+ " \"actor\": \"actor\",\n"
+ " \"child-actor\": \"sub-actor\"\n"
+ " }]\n"
+ " }]\n"
+ "}\n"
+ );
+
+ Builder builder = Builder::New();
+ builder.LoadFromString( json );
+ builder.AddActors ( "arbitarysection", Stage::GetCurrent().GetRootLayer() );
// Render and notify
application.SendNotification();
application.Render();
- // Emit touch event and check that our quit method is called
- Integration::TouchEvent touchEvent;
- touchEvent.points.push_back( TouchPoint ( 0, TouchPoint::Down, 10.0f, 10.0f ) );
- application.ProcessEvent( touchEvent );
- DALI_TEST_CHECK( functorCalled );
+ Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("sub-actor");
+ DALI_TEST_CHECK( actor );
+
+ DALI_TEST_CHECK( !actor.IsVisible() );
+
+ END_TEST;
+}
+
+int UtcDaliBuilderFrameBufferP(void)
+{
+ ToolkitTestApplication application;
+
+ // JSON with a quit event when the actor is touched
+ std::string json(
+ "{\n"
+ " \"constants\":\n"
+ " {\n"
+ " \"FB_WIDTH\": 200.0,\n"
+ " \"FB_HEIGHT\": 200.0,\n"
+ " \"FB_SIZE\": [200,200],\n"
+ " \"FB_ASPECT_RATIO\": 1\n"
+ " },\n"
+ " \"stage\": [\n"
+ " {\n"
+ " \"type\": \"ImageActor\",\n"
+ " \"name\": \"fbOnStage\",\n"
+ " \"position\": [\n"
+ " 0.40461349487305,\n"
+ " 0.9150390625,\n"
+ " 0.0\n"
+ " ],\n"
+ " \"parent-origin\": [0.5, 0.5, 0.5],\n"
+ " \"size\": [300, 300, 0],\n"
+ " \"image\": \"fb0\",\n"
+ " \"clear-color\": [1,0,0,1]\n"
+ " },\n"
+ " {\n"
+ " \"type\": \"ImageActor\",\n"
+ " \"name\": \"Image1\",\n"
+ " \"size\": [200, 200, 0],\n"
+ " \"parent-origin\": [0.5, 0.5, 0.5],\n"
+ " \"effect\": \"Ripple2D\",\n"
+ " \"image\": {\n"
+ " \"filename\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\",\n"
+ " \"width\": 200,\n"
+ " \"height\": 80,\n"
+ " \"load-policy\": \"IMMEDIATE\",\n"
+ " \"release-policy\": \"NEVER\"\n"
+ " },\n"
+ " \"signals\": [\n"
+ " {\n"
+ " \"name\": \"on-stage\",\n"
+ " \"action\": \"play\",\n"
+ " \"animation\": \"Animation_1\"\n"
+ " }\n"
+ " ]\n"
+ " },\n"
+ " {\n"
+ " \"type\":\"CameraActor\",\n"
+ " \"name\":\"fbCam\",\n"
+ " \"aspect-ratio\": \"{FB_ASPECT_RATIO}\",\n"
+ " \"projection-mode\": \"PERSPECTIVE_PROJECTION\",\n"
+ " \"field-of-view\": 0.785,\n"
+ " \"invert-y-axis\": true\n"
+ " }\n"
+ " ],\n"
+ " \"frame-buffer-images\":\n"
+ " {\n"
+ " \"fb0\":\n"
+ " {\n"
+ " \"type\": \"FrameBufferImage\",\n"
+ " \"width\": { \"type-cast\":\"float\", \"value\":\"{FB_WIDTH}\" },\n"
+ " \"height\": { \"type-cast\":\"float\", \"value\":\"{FB_HEIGHT}\" }\n"
+ " }\n"
+ " },\n"
+ " \"render-tasks\":\n"
+ " {\n"
+ " \"stage\":\n"
+ " [\n"
+ " {\n"
+ " \"source-actor\": \"fbOnStage\"\n"
+ " },\n"
+ " {\n"
+ " \"source-actor\": \"Image1\",\n"
+ " \"target-frame-buffer\": \"fb0\",\n"
+ " \"viewport-size\":\"{FB_SIZE}\",\n"
+ " \"camera-actor\":\"fbCam\"\n"
+ " }\n"
+ " ]\n"
+ " },\n"
+ " \"paths\": {},\n"
+ " \"animations\": {\n"
+ " \"Animation_1\": {\n"
+ " \"loop\":true,\n"
+ " \"properties\": [\n"
+ " {\n"
+ " \"actor\": \"Image1\",\n"
+ " \"property\": \"uTime\",\n"
+ " \"value\": 10.0,\n"
+ " \"alpha-function\": \"LINEAR\",\n"
+ " \"time-period\": {\n"
+ " \"delay\": 0,\n"
+ " \"duration\": 10.0\n"
+ " },\n"
+ " \"gui-builder-timeline-color\": \"#8dc0da\"\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ " },\n"
+ " \"shader-effects\": {\n"
+ " \"Ripple2D\": {\n"
+ " \"program\": {\n"
+ " \"vertexPrefix\": \"\",\n"
+ " \"vertex\": \"void main(void)\\n{\\n gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\\n vTexCoord = aTexCoord;\\n}\\n\\n\",\n"
+ " \"fragmentPrefix\": \"\",\n"
+ " \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n highp vec2 textureSize = sTextureRect.zw - sTextureRect.xy;\\n highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n highp float len = length(pos);\\n highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n"
+ " \"geometry-type\": \"GEOMETRY_TYPE_IMAGE\"\n"
+ " },\n"
+ " \"geometry-hints\": \"HINT_NONE\",\n"
+ " \"grid-density\": 0,\n"
+ " \"loop\": true,\n"
+ " \"uAmplitude\": 0.02,\n"
+ " \"uTime\": 0.0\n"
+ " }\n"
+ " }\n"
+ "}\n");
+
+ Builder builder = Builder::New();
+
+ // frame buffer coverage
+ builder.LoadFromString( json );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ Dali::FrameBufferImage frameBuffer = builder.GetFrameBufferImage( "fb0" );
+ DALI_TEST_CHECK( frameBuffer );
+
+ Dali::FrameBufferImage frameBuffer2 = builder.GetFrameBufferImage( "fb0" );
+ DALI_TEST_CHECK( frameBuffer2 );
+ DALI_TEST_CHECK( frameBuffer == frameBuffer2 );
+
+ DALI_TEST_CHECK( true );
+
+ END_TEST;
+}
+
+int UtcDaliBuilderPathConstraintsP(void)
+{
+ ToolkitTestApplication application;
+
+ // JSON with a quit event when the actor is touched
+ std::string json(
+ "{\n"
+ " \"constants\":\n"
+ " {\n"
+ " \"FB_WIDTH\": 200.0,\n"
+ " \"FB_HEIGHT\": 200.0,\n"
+ " \"FB_SIZE\": [200,200],\n"
+ " \"FB_ASPECT_RATIO\": 1\n"
+ " },\n"
+ " \"stage\": [\n"
+ " {\n"
+ " \"type\": \"ImageActor\",\n"
+ " \"name\": \"Image1\",\n"
+ " \"size\": [200, 200, 0],\n"
+ " \"parent-origin\": [0.5, 0.5, 0.5],\n"
+ " \"effect\": \"Ripple2D\",\n"
+ " \"image\": {\n"
+ " \"filename\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\",\n"
+ " \"width\": 200,\n"
+ " \"height\": 80,\n"
+ " \"load-policy\": \"IMMEDIATE\",\n"
+ " \"release-policy\": \"NEVER\"\n"
+ " },\n"
+ " \"signals\": [\n"
+ " {\n"
+ " \"name\": \"on-stage\",\n"
+ " \"action\": \"play\",\n"
+ " \"animation\": \"path-animation\"\n"
+ " },\n"
+ " {\n"
+ " \"name\": \"on-stage\",\n"
+ " \"action\": \"applyConstraint\",\n"
+ " \"constrainer\": \"constrainer0\",\n"
+ " \"properties\":\n"
+ " [\n"
+ " {\n"
+ " \"source\": \"Image1\",\n"
+ " \"sourceProperty\": \"position-x\",\n"
+ " \"target\": \"Image1\",\n"
+ " \"targetProperty\": \"color-red\",\n"
+ " \"range\": [-300,300]\n"
+ " }\n"
+ " ]\n"
+ " },\n"
+ " {\n"
+ " \"name\": \"on-stage\",\n"
+ " \"action\": \"applyConstraint\",\n"
+ " \"constrainer\": \"constrainer1\",\n"
+ " \"properties\":\n"
+ " [\n"
+ " {\n"
+ " \"source\": \"Image1\",\n"
+ " \"sourceProperty\": \"position-x\",\n"
+ " \"target\": \"Image1\",\n"
+ " \"targetProperty\": \"color-blue\",\n"
+ " \"range\": [-300,300]\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ " ],\n"
+ " \"paths\":\n"
+ " {\n"
+ " \"path0\":\n"
+ " {\n"
+ " \"points\":[ [-150, -50, 0], [0.0,70.0,0.0], [190.0,-150.0,0.0] ],\n"
+ " \"curvature\":0.35\n"
+ " }\n"
+ " },\n"
+ " \"constrainers\":\n"
+ " {\n"
+ " \"constrainer0\":\n"
+ " {\n"
+ " \"type\": \"PathConstrainer\",\n"
+ " \"points\": [ [0, 0, 0], [0,0,0], [0,0,0] ],\n"
+ " \"control-points\": [ [0, 0, 0], [0,0,0], [0,0,0] ]\n"
+ " },\n"
+ " \"constrainer1\":\n"
+ " {\n"
+ " \"type\": \"LinearConstrainer\",\n"
+ " \"value\": [ 0, 0, 0 ]\n"
+ " }\n"
+ " },\n"
+ " \"animations\": {\n"
+ " \"path-animation\": {\n"
+ " \"duration\": 3.0,\n"
+ " \"properties\":\n"
+ " [{\n"
+ " \"actor\": \"Image1\",\n"
+ " \"path\":\"path0\",\n"
+ " \"forward\":[1,0,0],\n"
+ " \"alpha-function\": \"EASE_IN_OUT\",\n"
+ " \"time-period\": {\n"
+ " \"delay\": 0,\n"
+ " \"duration\": 3\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"actor\": \"Image1\",\n"
+ " \"property\": \"uTime\",\n"
+ " \"value\": 10.0,\n"
+ " \"alpha-function\": \"LINEAR\",\n"
+ " \"time-period\": {\n"
+ " \"delay\": 0,\n"
+ " \"duration\": 10.0\n"
+ " },\n"
+ " \"gui-builder-timeline-color\": \"#8dc0da\"\n"
+ " }]\n"
+ " },\n"
+ " \"Animation_1\": {\n"
+ " \"loop\":true,\n"
+ " \"properties\": [\n"
+ " {\n"
+ " \"actor\": \"Image1\",\n"
+ " \"property\": \"uTime\",\n"
+ " \"value\": 10.0,\n"
+ " \"alpha-function\": \"LINEAR\",\n"
+ " \"time-period\": {\n"
+ " \"delay\": 0,\n"
+ " \"duration\": 10.0\n"
+ " },\n"
+ " \"gui-builder-timeline-color\": \"#8dc0da\"\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ " },\n"
+ " \"shader-effects\": {\n"
+ " \"Ripple2D\": {\n"
+ " \"program\": {\n"
+ " \"vertexPrefix\": \"\",\n"
+ " \"vertex\": \"void main(void)\\n{\\n gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\\n vTexCoord = aTexCoord;\\n}\\n\\n\",\n"
+ " \"fragmentPrefix\": \"\",\n"
+ " \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n highp vec2 textureSize = sTextureRect.zw - sTextureRect.xy;\\n highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n highp float len = length(pos);\\n highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n"
+ " \"geometry-type\": \"GEOMETRY_TYPE_IMAGE\"\n"
+ " },\n"
+ " \"geometry-hints\": \"HINT_NONE\",\n"
+ " \"grid-density\": 0,\n"
+ " \"loop\": true,\n"
+ " \"uAmplitude\": 0.02,\n"
+ " \"uTime\": 0.0\n"
+ " }\n"
+ " }\n"
+ "}\n");
+
+ Builder builder = Builder::New();
+
+ // frame buffer coverage
+ builder.LoadFromString( json );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ Dali::Path path = builder.GetPath( "path0" );
+ DALI_TEST_CHECK( path );
+
+ Dali::Path path2 = builder.GetPath( "path0" );
+ DALI_TEST_CHECK( path2 );
+ DALI_TEST_CHECK( path == path2 );
+
+ Dali::PathConstrainer constrainer0 = builder.GetPathConstrainer( "constrainer0" );
+ DALI_TEST_CHECK( constrainer0 );
+
+ Dali::PathConstrainer constrainer0_2 = builder.GetPathConstrainer( "constrainer0" );
+ DALI_TEST_CHECK( constrainer0_2 );
+ DALI_TEST_CHECK( constrainer0 == constrainer0_2 );
+
+ Dali::LinearConstrainer constrainer1 = builder.GetLinearConstrainer( "constrainer1" );
+ DALI_TEST_CHECK( constrainer1 );
+
+ Dali::LinearConstrainer constrainer1_2 = builder.GetLinearConstrainer( "constrainer1" );
+ DALI_TEST_CHECK( constrainer1 == constrainer1_2 );
END_TEST;
}