#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':'rotation', \
- '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));
-
- TextActor actor( TextActor::DownCast( builder.Create("basic-text") ) );
-
- DALI_TEST_CHECK( actor );
-
- stage.GetRootLayer().Add( actor );
+ // Connect to builder's quit signal
+ bool functorCalled( false );
+ builder.QuitSignal().Connect( &application, BuilderFunctor( functorCalled ) );
+ // Render and notify
application.SendNotification();
application.Render();
- Vector3 v;
-
- v = actor.GetCurrentPosition();
- DALI_TEST_CHECK(v.x == -10.0);
- DALI_TEST_CHECK(v.y == 10.0);
- DALI_TEST_CHECK(v.z == 0.0);
-
- v = actor.GetCurrentSize();
- DALI_TEST_CHECK(v.x == 150.0);
- DALI_TEST_CHECK(v.y == 170.0);
- DALI_TEST_CHECK(v.z == 1.0);
-
- DALI_TEST_CHECK(actor.GetText() == "Template Hello");
-
- actor = TextActor::DownCast( builder.Create("*(&^") );
- 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 );
END_TEST;
}
-int UtcDaliBuilderTextActorCreateAnimation(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliBuilderTextActorCreateAnimation");
-
- Builder builder = Builder::New();
-
- builder.LoadFromString(ReplaceQuotes(JSON_TEXT_ACTOR));
-
- builder.AddActors( Stage::GetCurrent().GetRootLayer() );
-
- Animation anim = builder.CreateAnimation("rotate");
- DALI_TEST_CHECK( anim );
-
- DALI_TEST_CHECK( 10.0f == anim.GetDuration() );
-
- END_TEST;
-}
-int UtcDaliBuilderTextActorApplyFromStyle(void)
+int UtcDaliBuilderAnimationP(void)
{
ToolkitTestApplication application;
- tet_infoline(" UtcDaliBuilderTextActorApplyFromStyle");
+ // JSON with a quit event when the actor is touched
+ std::string json(
+ "{"
+ " \"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\": \"EASE_IN_OUT\","
+ " \"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\""
+ " }]"
+ " }]"
+ "}");
Builder builder = Builder::New();
+ builder.LoadFromString( json );
+ builder.AddActors( Stage::GetCurrent().GetRootLayer() );
- builder.LoadFromString(ReplaceQuotes(JSON_TEXT_ACTOR));
+ Animation anim = builder.CreateAnimation("animate");
- TextActor actor = TextActor::New("a");
+ DALI_TEST_CHECK( anim );
- builder.ApplyStyle("basic-text", actor);
+ anim = builder.CreateAnimation("path-animation");
- DALI_TEST_CHECK( actor );
+ DALI_TEST_CHECK( anim );
- Stage::GetCurrent().GetRootLayer().Add( actor );
+ // 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();
- Vector3 v;
-
- v = actor.GetCurrentPosition();
- DALI_TEST_CHECK(v.x == -10.0);
- DALI_TEST_CHECK(v.y == 10.0);
- DALI_TEST_CHECK(v.z == 0.0);
-
- v = actor.GetCurrentSize();
- DALI_TEST_CHECK(v.x == 150.0);
- DALI_TEST_CHECK(v.y == 170.0);
- DALI_TEST_CHECK(v.z == 1.0);
-
- DALI_TEST_CHECK(actor.GetText() == "Hello");
END_TEST;
}
-int UtcDaliBuilderAddActors(void)
+int UtcDaliBuilderAnimationN(void)
{
ToolkitTestApplication application;
- tet_infoline(" UtcDaliBuilderAddActors");
+ // JSON with a quit event when the actor is touched
+ std::string json(
+ "{"
+ " \"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\": \"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\": \"greeting\","
+ " \"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\""
+ " }]"
+ " }]"
+ "}");
+
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");
- application.SendNotification();
- application.Render();
+ anim = builder.CreateAnimation("animate");
- TextActor actor = TextActor::DownCast( Stage::GetCurrent().GetRootLayer().FindChildByName("text") );
+ anim = builder.CreateAnimation("animate2");
- DALI_TEST_CHECK( actor );
- DALI_TEST_CHECK(actor.GetText() == "Hello");
+ DALI_TEST_CHECK(true);
END_TEST;
+
}
-int UtcDaliBuilderAddActorsOther(void)
+int UtcDaliBuilderConstantsP(void)
{
ToolkitTestApplication application;
- tet_infoline(" UtcDaliBuilderAddActorsOther");
-
- Actor rootActor = Stage::GetCurrent().GetRootLayer();
+ // 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\","
+ " \"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(ReplaceQuotes(JSON_TEXT_ACTOR));
-
- builder.AddActors( "other", rootActor );
-
- application.SendNotification();
- application.Render();
-
- TextActor actor = TextActor::DownCast( Stage::GetCurrent().GetRootLayer().FindChildByName("other-text") );
-
- DALI_TEST_CHECK( actor );
- DALI_TEST_CHECK(actor.GetText() == "Hello");
+ builder.LoadFromString( json );
+ builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
+ DALI_TEST_CHECK( builder );
END_TEST;
}
-
-int UtcDaliBuilderStyles(void)
+int UtcDaliBuilderTemplatesAndStylesP(void)
{
ToolkitTestApplication application;
- tet_infoline(" UtcDaliBuilderStyles");
+ // JSON with a quit event when the actor is touched
+ std::string json(
+ "{\n"
+ "\"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\": [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_CORE_ACTOR_TREE));
-
- BaseHandle handle = builder.Create("my-camera");
- CameraActor camera = CameraActor::DownCast(handle);
-
- DALI_TEST_CHECK(camera);
+ ImageActor actor = ImageActor::DownCast( builder.Create( "image-tree" ) );
+ DALI_TEST_CHECK( actor );
- Property::Value v;
+ // NB: already applied in create
+ DALI_TEST_CHECK( builder.ApplyStyle( "image-style", actor ) );
- v = camera.GetProperty( camera.GetPropertyIndex("field-of-view") );
- DALI_TEST_CHECK( 0.125f == v.Get<float>() );
+ END_TEST;
+}
- v = camera.GetProperty( camera.GetPropertyIndex("aspect-ratio") );
- DALI_TEST_CHECK( 5.0f == v.Get<float>() );
+int UtcDaliBuilderRenderTasksP(void)
+{
+ ToolkitTestApplication application;
- handle = builder.Create("basic-text");
- TextActor textActor = TextActor::DownCast(handle);
+ // 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"
+ );
- v = textActor.GetProperty( textActor.GetPropertyIndex("smooth-edge") );
+ Builder builder = Builder::New();
+ builder.LoadFromString( json );
- DALI_TEST_CHECK( 0.2f == v.Get<float>() );
+ unsigned int count = Stage::GetCurrent().GetRenderTaskList().GetTaskCount();
- // test ApplyStyle another
- builder.ApplyStyle("theme2-text", textActor);
+ // coverage
+ builder.CreateRenderTask( "task0" );
- v = textActor.GetProperty( textActor.GetPropertyIndex("smooth-edge") );
- DALI_TEST_CHECK( 0.8f == v.Get<float>() );
+ DALI_TEST_CHECK( count <
+ Stage::GetCurrent().GetRenderTaskList().GetTaskCount() );
END_TEST;
}
-int UtcDaliBuilderSetProperty(void)
+int UtcDaliBuilderChildActionP(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"
+ " \"actor\": \"actor\",\n"
+ " \"child-actor\": \"sub-actor\"\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("sub-actor");
DALI_TEST_CHECK( actor );
- DALI_TEST_CHECK( actor.GetText() == "Jaylo" );
+
+ DALI_TEST_CHECK( !actor.IsVisible() );
END_TEST;
}
-int UtcDaliBuilderCreateFromJson(void)
+int UtcDaliBuilderSetPropertyActionP(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\": \"set\",\n"
+ " \"actor\": \"sub-actor\",\n"
+ " \"property\": \"visible\",\n"
+ " \"value\": false\n"
+ " }]\n"
+ " }]\n"
+ "}\n"
+ );
Builder builder = Builder::New();
+ builder.LoadFromString( json );
+ builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
- TextActor actor = TextActor::DownCast( builder.CreateFromJson("foobar") );
+ // 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 );
- actor = TextActor::DownCast(
- builder.CreateFromJson(
- ReplaceQuotes("{'type':'TextActor','text':'Hi'}") ) );
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+ Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("sub-actor");
DALI_TEST_CHECK( actor );
- DALI_TEST_CHECK( actor.GetText() == "Hi" );
+ DALI_TEST_CHECK( !actor.IsVisible() );
END_TEST;
}
-int UtcDaliBuilderApplyFromJson(void)
+int UtcDaliBuilderGenericActionP(void)
{
ToolkitTestApplication application;
- tet_infoline(" UtcDaliBuilderApplyFromJson");
+ // 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() );
- TextActor actor = TextActor::DownCast(
- builder.CreateFromJson(
- ReplaceQuotes("{'type':'TextActor','text':'Hi'}") ) );
-
- DALI_TEST_CHECK( actor );
+ // Render and notify
+ application.SendNotification();
+ application.Render();
- DALI_TEST_CHECK( actor.GetText() == "Hi" );
+ // 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( !builder.ApplyFromJson(actor, ReplaceQuotes("foobar") ) );
+ // Render and notify
+ application.SendNotification();
+ application.Render();
- builder.ApplyFromJson(actor, ReplaceQuotes("{'text':'low'}") );
+ Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("actor");
+ DALI_TEST_CHECK( actor );
- DALI_TEST_CHECK( actor.GetText() == "low" );
+ DALI_TEST_CHECK( !actor.IsVisible() );
END_TEST;
}
-int UtcDaliBuilderQuitSignal(void)
+int UtcDaliBuilderPropertyNotificationP(void)
{
ToolkitTestApplication application;
// 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\""
- "}]"
- "}]"
- "}"
+ "{\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() );
- // Connect to builder's quit signal
- bool functorCalled( false );
- builder.QuitSignal().Connect( &application, BuilderFunctor( functorCalled ) );
-
// Render and notify
application.SendNotification();
application.Render();
Integration::TouchEvent touchEvent;
touchEvent.points.push_back( TouchPoint ( 0, TouchPoint::Down, 10.0f, 10.0f ) );
application.ProcessEvent( touchEvent );
- DALI_TEST_CHECK( functorCalled );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("actor");
+ DALI_TEST_CHECK( actor );
+
+ DALI_TEST_CHECK( actor.IsVisible() );
END_TEST;
}