X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-Builder.cpp;h=32946a087f17c2e4841dbe7d0e1ad2359eca4947;hp=164ab9e39998c04b528e8787512a612010822cfe;hb=ab01efc8b47c89288c7fbc9948dead57d0411c1f;hpb=653e65df6f984c2c11fda4b961f1015d3da1aea0 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp index 164ab9e..32946a0 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2014-2016 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,9 @@ #include #include #include +#include +#include +#include #define STRINGIFY(A)#A @@ -75,12 +78,15 @@ int UtcDaliBuilderQuitSignal(void) "{" "\"stage\":" "[{" - "\"type\": \"Actor\"," + "\"type\": \"Layer\"," "\"size\": [100,100,1]," - "\"parent-origin\": \"TOP_LEFT\"," - "\"anchor-point\": \"TOP_LEFT\"," + "\"parentOrigin\": \"TOP_LEFT\"," + "\"anchorPoint\": \"TOP_LEFT\"," + "\"maximumSize\": [100,100]," + "\"orientation\": [10,10,10,10]," + "\"clippingBox\": [10,10,10,10]," "\"signals\": [{" - "\"name\": \"touched\"," + "\"name\": \"touch\"," "\"action\": \"quit\"" "}]" "}]" @@ -100,7 +106,10 @@ int UtcDaliBuilderQuitSignal(void) // 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 ) ); + Integration::Point point; + point.SetState( PointState::DOWN ); + point.SetScreenPosition( Vector2( 10.0f, 10.0f ) ); + touchEvent.points.push_back( point ); application.ProcessEvent( touchEvent ); DALI_TEST_CHECK( functorCalled ); @@ -130,16 +139,16 @@ int UtcDaliBuilderAnimationP(void) " \"animations\": {" " \"animate\": {" " \"loop\": true," - " \"end-action\": \"BAKE\"," - " \"disconnect-action\": \"BAKE\"," + " \"endAction\": \"BAKE\"," + " \"disconnectAction\": \"BAKE\"," " \"properties\":" " [{" " \"actor\": \"greeting\"," " \"property\": \"position\"," " \"value\": [300, 300, -1000]," - " \"alpha-function\": \"{ALPHA_FUNCTION}\"," + " \"alphaFunction\": \"{ALPHA_FUNCTION}\"," " \"relative\": true," - " \"time-period\": {" + " \"timePeriod\": {" " \"delay\": 0," " \"duration\": 3" " }" @@ -147,81 +156,81 @@ int UtcDaliBuilderAnimationP(void) " {" " \"actor\": \"greeting\"," " \"property\": \"visible\"," - " \"alpha-function\": \"LINEAR\"," + " \"alphaFunction\": \"LINEAR\"," " \"value\": true" " }," " {" " \"actor\": \"greeting\"," - " \"property\": \"size-width\"," - " \"alpha-function\": \"REVERSE\"," + " \"property\": \"sizeWidth\"," + " \"alphaFunction\": \"REVERSE\"," " \"value\": 10.0" " }," " {" " \"actor\": \"greeting\"," " \"property\": \"orientation\"," - " \"alpha-function\": \"EASE_IN\"," + " \"alphaFunction\": \"EASE_IN\"," " \"value\": [10.0,20.0,30.0]" " }," " {" " \"actor\": \"greeting\"," " \"property\": \"orientation\"," - " \"alpha-function\": \"EASE_OUT\"," + " \"alphaFunction\": \"EASE_OUT\"," " \"value\": [0.0, 0.0, 0.0, 1.0]" " }," " {" " \"actor\": \"greeting\"," " \"property\": \"orientation\"," - " \"alpha-function\": \"EASE_IN_OUT\"," + " \"alphaFunction\": \"EASE_IN_OUT\"," " \"value\": [0.0, 0.0, 0.0, 1.0]" " }," " {" " \"actor\": \"greeting\"," " \"property\": \"orientation\"," - " \"alpha-function\": \"EASE_IN_SINE\"," + " \"alphaFunction\": \"EASE_IN_SINE\"," " \"value\": [0.0, 0.0, 0.0, 1.0]" " }," " {" " \"actor\": \"greeting\"," " \"property\": \"orientation\"," - " \"alpha-function\": \"EASE_OUT_SINE\"," + " \"alphaFunction\": \"EASE_OUT_SINE\"," " \"value\": [0.0, 0.0, 0.0, 1.0]" " }," " {" " \"actor\": \"greeting\"," " \"property\": \"orientation\"," - " \"alpha-function\": \"EASE_IN_OUT_SINE\"," + " \"alphaFunction\": \"EASE_IN_OUT_SINE\"," " \"value\": [0.0, 0.0, 0.0, 1.0]" " }," " {" " \"actor\": \"greeting\"," " \"property\": \"orientation\"," - " \"alpha-function\": \"BOUNCE\"," + " \"alphaFunction\": \"BOUNCE\"," " \"value\": [0.0, 0.0, 0.0, 1.0]" " }," " {" " \"actor\": \"greeting\"," " \"property\": \"orientation\"," - " \"alpha-function\": \"SIN\"," + " \"alphaFunction\": \"SIN\"," " \"value\": [0.0, 0.0, 0.0, 1.0]" " }," " {" " \"actor\": \"greeting\"," " \"property\": \"orientation\"," - " \"alpha-function\": \"EASE_OUT_BACK\"," + " \"alphaFunction\": \"EASE_OUT_BACK\"," " \"value\": [0.0, 0.0, 0.0, 1.0]" " }" " ]" " }," - " \"path-animation\": {" + " \"pathAnimation\": {" " \"duration\": 3.0," - " \"end-action\": \"DISCARD\"," - " \"disconnect-action\": \"BAKE_FINAL\"," + " \"endAction\": \"DISCARD\"," + " \"disconnectAction\": \"BAKE_FINAL\"," " \"properties\": [{" " \"actor\": \"greeting\"," " \"path\":\"path0\"," " \"forward\":[1,0,0]," - " \"alpha-function\": \"EASE_IN_OUT\"," - " \"time-period\": {" + " \"alphaFunction\": \"EASE_IN_OUT\"," + " \"timePeriod\": {" " \"delay\": 0," " \"duration\": 3" " }" @@ -232,12 +241,12 @@ int UtcDaliBuilderAnimationP(void) " \"name\": \"greeting\"," " \"type\": \"TextLabel\"," " \"text\": \"Touch me\"," - " \"styles\": [\"basic-text\"]," + " \"styles\": [\"basicText\"]," " \"position\": [0, -120, 0]," " \"size\": [200, 200, 1]," " \"orientation\": [0, 0, 30]," " \"signals\": [{" - " \"name\": \"touched\"," + " \"name\": \"touch\"," " \"action\": \"play\"," " \"animation\": \"animate\"" " }]" @@ -258,14 +267,17 @@ int UtcDaliBuilderAnimationP(void) DALI_TEST_CHECK( anim ); - anim = builder.CreateAnimation("path-animation"); + anim = builder.CreateAnimation("pathAnimation"); 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 ) ); + Integration::Point point; + point.SetState( PointState::DOWN ); + point.SetScreenPosition( Vector2( 10.0f, 10.0f ) ); + touchEvent.points.push_back( point ); application.ProcessEvent( touchEvent ); // Render and notify @@ -299,16 +311,16 @@ int UtcDaliBuilderAnimationN(void) " \"animations\": {" " \"animate\": {" " \"loop\": true," - " \"end-action\": \"BAKE\"," - " \"disconnect-action\": \"BAKE\"," + " \"endAction\": \"BAKE\"," + " \"disconnectAction\": \"BAKE\"," " \"properties\":" " [{" " \"actor\": \"{NAME}\"," " \"property\": \"positioninvalid\"," " \"value\": [300, 300, -1000]," - " \"alpha-function\": \"EASE_IN_OUT\"," + " \"alphaFunction\": \"EASE_IN_OUT\"," " \"relative\": true," - " \"time-period\": {" + " \"timePeriod\": {" " \"delay\": 0," " \"duration\": 3" " }" @@ -317,32 +329,32 @@ int UtcDaliBuilderAnimationN(void) " }," " \"animate2\": {" " \"loop\": true," - " \"end-action\": \"BAKE\"," - " \"disconnect-action\": \"BAKE\"," + " \"endAction\": \"BAKE\"," + " \"disconnectAction\": \"BAKE\"," " \"properties\":" " [{" " \"actor\": \"{NAME}\"," " \"property\": \"positioninvalid\"," " \"value\": [300, 300, -1000]," - " \"alpha-function\": \"EGGS_OVER_EASY\"," + " \"alphaFunction\": \"EGGS_OVER_EASY\"," " \"relative\": true," - " \"time-period\": {" + " \"timePeriod\": {" " \"delay\": 0," " \"duration\": 3" " }" " }" " ]" " }," - " \"path-animation\": {" + " \"pathAnimation\": {" " \"duration\": 3.0," - " \"end-action\": \"DISCARD\"," - " \"disconnect-action\": \"BAKE_FINAL\"," + " \"endAction\": \"DISCARD\"," + " \"disconnectAction\": \"BAKE_FINAL\"," " \"properties\": [{" " \"actor\": \"greeting\"," " \"path\":\"pathDoesntExist\"," " \"forward\":[1,0,0]," - " \"alpha-function\": \"EASE_IN_OUT\"," - " \"time-period\": {" + " \"alphaFunction\": \"EASE_IN_OUT\"," + " \"timePeriod\": {" " \"delay\": 0," " \"duration\": 3" " }" @@ -353,12 +365,12 @@ int UtcDaliBuilderAnimationN(void) " \"name\": \"greeting\"," " \"type\": \"TextLabel\"," " \"text\": \"Touch me\"," - " \"styles\": [\"basic-text\"]," + " \"styles\": [\"basicText\"]," " \"position\": [0, -120, 0]," " \"size\": [200, 200, 1]," " \"orientation\": [0, 0, 30]," " \"signals\": [{" - " \"name\": \"touched\"," + " \"name\": \"touch\"," " \"action\": \"play\"," " \"animation\": \"animate\"" " }]" @@ -378,7 +390,7 @@ int UtcDaliBuilderAnimationN(void) Animation anim = builder.CreateAnimation("animate"); // log warning line coverage - anim = builder.CreateAnimation("path-animation"); + anim = builder.CreateAnimation("pathAnimation"); DALI_TEST_CHECK(anim); anim = builder.CreateAnimation("animate"); @@ -422,16 +434,16 @@ int UtcDaliBuilderConstantsP(void) "}," "\"stage\":" "[{" - " \"type\": \"ImageActor\"," + " \"type\": \"ImageView\"," " \"name\": \"{NAME}\"," " \"size\": [100,100,1]," - " \"parent-origin\": \"TOP_LEFT\"," - " \"anchor-point\": \"{ANCHOR}\"," + " \"parentOrigin\": \"TOP_LEFT\"," + " \"anchorPoint\": \"{ANCHOR}\"," " \"padding\": \"{PADDING}\"," - " \"image\": { \"filename\": \"dir/{IMAGE_PATH}\" }," - " \"size-width\": \"{WIDTH}\"," + " \"image\": { \"url\": \"dir/{IMAGE_PATH}\" }," + " \"sizeWidth\": \"{WIDTH}\"," " \"signals\": [{" - " \"name\": \"touched\"," + " \"name\": \"touch\"," " \"action\": \"quit\"" " }]" "}]" @@ -479,38 +491,53 @@ int UtcDaliBuilderTemplatesAndStylesP(void) "}," "\"styles\":\n" "{\n" - " \"image-style\": \n" + " \"imageStyle\": \n" " {\n" " \"color\": [1,0,0,1],\n" " \"actors\": {\n" - " \"child-image\": {\n" - " \"color\": [0,1,0,1]\n" + " \"childImage\": {\n" + " \"color\": \"34\"\n" " }\n" " }\n" " }\n" "},\n" "\"templates\":\n" "{\n" - " \"image-tree\": { \n" - " \"type\": \"ImageActor\",\n" - " \"styles\": [\"image-style\"],\n" + " \"imageViewTemplate\": { \n" + " \"type\": \"ImageView\",\n" + " \"styles\": [\"imageStyle\"]\n" + " },\n" + " \"imageTree\": { \n" + " \"type\": \"ImageView\",\n" + " \"styles\": [\"imageStyle\"],\n" " \"name\": \"image\",\n" " \"size\": \"{SIZE}\",\n" " \"signals\": [{\n" - " \"name\": \"touched\",\n" + " \"name\": \"touch\",\n" " \"action\": \"quit\"\n" " }],\n" " \"actors\": [\n" " {\n" - " \"type\":\"ImageActor\",\n" - " \"name\":\"child-image\" \n" + " \"type\":\"ImageView\",\n" + " \"name\":\"childImage\", \n" + " \"color\": \n" + " {\n" + " \"r\": 10,\n" + " \"g\": 10,\n" + " \"b\": 10,\n" + " \"a\": 100\n" + " }\n" + " },\n" + " {\n" + " \"type\":\"imageViewTemplate\",\n" + " \"name\":\"childImage2\"\n" " }\n" " ]\n" " }\n" "},\n" "\"stage\":" "[{" - " \"type\": \"image-tree\"," + " \"type\": \"imageTree\"," " \"size\": [100,100,1]" "}]" "}\n" @@ -520,8 +547,8 @@ int UtcDaliBuilderTemplatesAndStylesP(void) "{\n" " \"color\": [1,0,0,1],\n" " \"actors\": {\n" - " \"child-image\": {\n" - " \"color\": [0,1,0,1]\n" + " \"childImage\": {\n" + " \"color\": \"#344353\"\n" " }\n" " }\n" "}\n" @@ -529,18 +556,18 @@ int UtcDaliBuilderTemplatesAndStylesP(void) std::string templatejson( "{ \n" - " \"type\": \"ImageActor\",\n" - " \"styles\": [\"image-style\"],\n" + " \"type\": \"ImageView\",\n" + " \"styles\": [\"imageStyle\"],\n" " \"name\": \"image\",\n" " \"size\": \"{SIZE}\",\n" " \"signals\": [{\n" - " \"name\": \"touched\",\n" + " \"name\": \"touch\",\n" " \"action\": \"quit\"\n" " }],\n" " \"actors\": [\n" " {\n" - " \"type\":\"ImageActor\",\n" - " \"name\":\"child-image\" \n" + " \"type\":\"ImageView\",\n" + " \"name\":\"childImage\" \n" " }\n" " ]\n" "}\n" @@ -549,21 +576,21 @@ int UtcDaliBuilderTemplatesAndStylesP(void) Builder builder = Builder::New(); builder.LoadFromString( json ); - ImageActor actor = ImageActor::DownCast( builder.Create( "image-tree" ) ); + ImageView actor = ImageView::DownCast( builder.Create( "imageTree" ) ); DALI_TEST_CHECK( actor ); Dali::Property::Map map; map["SIZE"] = Vector3(100,100,1); - actor = ImageActor::DownCast( builder.Create( "image-tree", map ) ); + actor = ImageView::DownCast( builder.Create( "imageTree", map ) ); DALI_TEST_CHECK( actor ); // create from json snippet - actor = ImageActor::DownCast( builder.CreateFromJson( templatejson ) ); + actor = ImageView::DownCast( builder.CreateFromJson( templatejson ) ); DALI_TEST_CHECK( actor ); // NB: already applied in create - DALI_TEST_CHECK( builder.ApplyStyle( "image-style", actor ) ); + DALI_TEST_CHECK( builder.ApplyStyle( "imageStyle", actor ) ); // apply from json snippet DALI_TEST_CHECK( builder.ApplyFromJson( actor, stylejson ) ); @@ -578,31 +605,31 @@ int UtcDaliBuilderRenderTasksP(void) // JSON with a quit event when the actor is touched std::string json( "{\n" - "\"render-tasks\":\n" + "\"renderTasks\":\n" "{\n" " \"task0\": {\n" - " \"source-actor\": \"image\",\n" - " \"camera-actor\": \"camera\" \n" + " \"sourceActor\": \"image\",\n" + " \"cameraActor\": \"camera\" \n" " }\n" "},\n" "\"stage\":\n" "[\n" " { \n" " \"type\": \"CameraActor\",\n" - " \"name\": \"image\"\n" + " \"name\": \"camera\"\n" " }, \n" " { \n" - " \"type\": \"ImageActor\",\n" + " \"type\": \"ImageView\",\n" " \"name\": \"image\",\n" " \"size\": [100,100,1],\n" " \"signals\": [{\n" - " \"name\": \"touched\",\n" + " \"name\": \"touch\",\n" " \"action\": \"quit\"\n" " }],\n" " \"actors\": [\n" " {\n" - " \"type\":\"ImageActor\",\n" - " \"name\":\"child-image\" \n" + " \"type\":\"ImageView\",\n" + " \"name\":\"childImage\" \n" " }\n" " ]\n" " }\n" @@ -636,17 +663,17 @@ int UtcDaliBuilderChildActionP(void) " \"type\": \"Actor\",\n" " \"name\": \"actor\",\n" " \"size\": [100,100,1],\n" - " \"parent-origin\": \"TOP_LEFT\",\n" - " \"anchor-point\": \"TOP_LEFT\",\n" + " \"parentOrigin\": \"TOP_LEFT\",\n" + " \"anchorPoint\": \"TOP_LEFT\",\n" " \"actors\": [{\n" " \"type\": \"Actor\",\n" - " \"name\": \"sub-actor\"\n" + " \"name\": \"subActor\"\n" " }],\n" " \"signals\": [{\n" - " \"name\": \"touched\",\n" + " \"name\": \"touch\",\n" " \"action\": \"hide\",\n" " \"actor\": \"actor\",\n" - " \"child-actor\": \"sub-actor\"\n" + " \"childActor\": \"subActor\"\n" " }]\n" " }]\n" "}\n" @@ -662,14 +689,17 @@ int UtcDaliBuilderChildActionP(void) // 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 ) ); + Integration::Point point; + point.SetState( PointState::DOWN ); + point.SetScreenPosition( Vector2( 10.0f, 10.0f ) ); + touchEvent.points.push_back( point ); application.ProcessEvent( touchEvent ); // Render and notify application.SendNotification(); application.Render(); - Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("sub-actor"); + Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("subActor"); DALI_TEST_CHECK( actor ); DALI_TEST_CHECK( !actor.IsVisible() ); @@ -689,16 +719,16 @@ int UtcDaliBuilderSetPropertyActionP(void) " \"type\": \"Actor\",\n" " \"name\": \"actor\",\n" " \"size\": [100,100,1],\n" - " \"parent-origin\": \"TOP_LEFT\",\n" - " \"anchor-point\": \"TOP_LEFT\",\n" + " \"parentOrigin\": \"TOP_LEFT\",\n" + " \"anchorPoint\": \"TOP_LEFT\",\n" " \"actors\": [{\n" " \"type\": \"Actor\",\n" - " \"name\": \"sub-actor\"\n" + " \"name\": \"subActor\"\n" " }],\n" " \"signals\": [{\n" - " \"name\": \"touched\",\n" + " \"name\": \"touch\",\n" " \"action\": \"set\",\n" - " \"actor\": \"sub-actor\",\n" + " \"actor\": \"subActor\",\n" " \"property\": \"visible\",\n" " \"value\": false\n" " }]\n" @@ -716,14 +746,17 @@ int UtcDaliBuilderSetPropertyActionP(void) // 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 ) ); + Integration::Point point; + point.SetState( PointState::DOWN ); + point.SetScreenPosition( Vector2( 10.0f, 10.0f ) ); + touchEvent.points.push_back( point ); application.ProcessEvent( touchEvent ); // Render and notify application.SendNotification(); application.Render(); - Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("sub-actor"); + Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("subActor"); DALI_TEST_CHECK( actor ); DALI_TEST_CHECK( !actor.IsVisible() ); @@ -743,14 +776,14 @@ int UtcDaliBuilderGenericActionP(void) " \"type\": \"Actor\",\n" " \"name\": \"actor\",\n" " \"size\": [100,100,1],\n" - " \"parent-origin\": \"TOP_LEFT\",\n" - " \"anchor-point\": \"TOP_LEFT\",\n" + " \"parentOrigin\": \"TOP_LEFT\",\n" + " \"anchorPoint\": \"TOP_LEFT\",\n" " \"actors\": [{\n" " \"type\": \"Actor\",\n" - " \"name\": \"sub-actor\"\n" + " \"name\": \"subActor\"\n" " }],\n" " \"signals\": [{\n" - " \"name\": \"touched\",\n" + " \"name\": \"touch\",\n" " \"action\": \"hide\"\n" " }]\n" " }]\n" @@ -767,7 +800,10 @@ int UtcDaliBuilderGenericActionP(void) // 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 ) ); + Integration::Point point; + point.SetState( PointState::DOWN ); + point.SetScreenPosition( Vector2( 10.0f, 10.0f ) ); + touchEvent.points.push_back( point ); application.ProcessEvent( touchEvent ); // Render and notify @@ -794,14 +830,14 @@ int UtcDaliBuilderPropertyNotificationP(void) " \"type\": \"Actor\",\n" " \"name\": \"actor\",\n" " \"size\": [100,100,1],\n" - " \"parent-origin\": \"TOP_LEFT\",\n" - " \"anchor-point\": \"TOP_LEFT\",\n" + " \"parentOrigin\": \"TOP_LEFT\",\n" + " \"anchorPoint\": \"TOP_LEFT\",\n" " \"actors\": [{\n" " \"type\": \"Actor\",\n" - " \"name\": \"sub-actor\"\n" + " \"name\": \"subActor\"\n" " }],\n" " \"signals\": [{\n" - " \"name\": \"touched\",\n" + " \"name\": \"touch\",\n" " \"action\": \"hide\"\n" " }],\n" " \"notifications\": [{\n" @@ -823,7 +859,10 @@ int UtcDaliBuilderPropertyNotificationP(void) // 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 ) ); + Integration::Point point; + point.SetState( PointState::DOWN ); + point.SetScreenPosition( Vector2( 10.0f, 10.0f ) ); + touchEvent.points.push_back( point ); application.ProcessEvent( touchEvent ); // Render and notify @@ -851,21 +890,24 @@ int UtcDaliBuilderCustomPropertyP(void) "{\n" "\"templates\":\n" "{\n" - " \"image-tree\": { \n" - " \"type\": \"ImageActor\",\n" + " \"imageTree\": { \n" + " \"type\": \"ImageView\",\n" " \"name\": \"image\",\n" " \"size\": [100,100,1],\n" " \"signals\": [{\n" - " \"name\": \"touched\",\n" + " \"name\": \"touch\",\n" " \"action\": \"quit\"\n" " }],\n" - " \"custom-properties\": {\n" + " \"properties\": {\n" " \"newproperty\": true\n" " },\n" + " \"animatableProperties\": {\n" + " \"newAnimatableproperty\": 3\n" + " },\n" " \"actors\": [\n" " {\n" - " \"type\":\"ImageActor\",\n" - " \"name\":\"child-image\" \n" + " \"type\":\"ImageView\",\n" + " \"name\":\"childImage\" \n" " }\n" " ]\n" " }\n" @@ -876,7 +918,7 @@ int UtcDaliBuilderCustomPropertyP(void) Builder builder = Builder::New(); builder.LoadFromString( json ); - ImageActor actor = ImageActor::DownCast( builder.Create( "image-tree" ) ); + ImageView actor = ImageView::DownCast( builder.Create( "imageTree" ) ); DALI_TEST_CHECK( actor ); // NB: already applied in create @@ -885,10 +927,15 @@ int UtcDaliBuilderCustomPropertyP(void) Property::Value value = actor.GetProperty(index); DALI_TEST_CHECK( value.Get() == true ); + index = actor.GetPropertyIndex("newAnimatableproperty"); + DALI_TEST_CHECK( Property::INVALID_INDEX != index ); + value = actor.GetProperty(index); + DALI_TEST_CHECK( value.Get() == 3 ); + END_TEST; } -int UtcDaliBuilderShaderEffectP(void) +int UtcDaliBuilderCustomShaderP(void) { ToolkitTestApplication application; @@ -897,33 +944,37 @@ int UtcDaliBuilderShaderEffectP(void) "{\n" " \"stage\": [\n" " {\n" - " \"type\": \"ImageActor\",\n" + " \"type\": \"ImageView\",\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" + " \"parentOrigin\": [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" + " \"url\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\",\n" + " \"desiredWidth\": 200,\n" + " \"desiredHeight\": 80,\n" + " \"shader\": {\n" + " \"fragmentShader\": \"precision mediump float;\\nuniform sampler2D sTexture;\\nuniform vec4 uColor;\\nuniform float uAmplitude;\\nuniform float uTime;\\nvarying vec2 vTexCoord;\\nvoid main()\\n{\\n highp vec2 pos = -1.0 + 2.0 * vTexCoord;\\n highp float len = length(pos);\\n highp vec2 texCoord = vTexCoord + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude;\\n gl_FragColor = texture2D(sTexture, texCoord) * uColor;}\\n\\n\"\n" + " }\n" + " },\n" + " \"customAnimatableProperties\": {\n" + " \"uAmplitude\": 0.02,\n" + " \"uTime\": 0.0\n" " },\n" " \"signals\": [\n" " {\n" - " \"name\": \"on-stage\",\n" + " \"name\": \"onStage\",\n" " \"action\": \"play\",\n" " \"animation\": \"Animation_1\"\n" " }\n" " ]\n" " }\n" " ],\n" - " \"paths\": {},\n" " \"animations\": {\n" " \"Animation_1\": {\n" " \"loop\":true,\n" @@ -932,31 +983,14 @@ int UtcDaliBuilderShaderEffectP(void) " \"actor\": \"Image1\",\n" " \"property\": \"uTime\",\n" " \"value\": 10.0,\n" - " \"alpha-function\": \"LINEAR\",\n" - " \"time-period\": {\n" + " \"alphaFunction\": \"LINEAR\",\n" + " \"timePeriod\": {\n" " \"delay\": 0,\n" " \"duration\": 10.0\n" - " },\n" - " \"gui-builder-timeline-color\": \"#8dc0da\"\n" + " }\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" @@ -965,10 +999,16 @@ int UtcDaliBuilderShaderEffectP(void) Builder builder = Builder::New(); builder.LoadFromString( json ); - ShaderEffect effect = builder.GetShaderEffect("Ripple2D"); + builder.AddActors ( "stage", Stage::GetCurrent().GetRootLayer() ); + + // Render and notify + application.SendNotification(); + application.Render(); + + Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("Image1"); // coverage - DALI_TEST_CHECK( effect ); + DALI_TEST_CHECK( actor ); END_TEST; } @@ -985,10 +1025,10 @@ int UtcDaliBuilderLoadFromStringN(void) "[{" "\"type\": \"Actor\"," "\"size\": [100,100,1]," - "\"parent-origin\": \"TOP_LEFT\"," - "\"anchor-point\": \"TOP_LEFT\"," + "\"parentOrigin\": \"TOP_LEFT\"," + "\"anchorPoint\": \"TOP_LEFT\"," "\"signals\": [{" - "\"name\": \"touched\"," + "\"name\": \"touch\"," "\"action\": \"quit\"" "}]" "}]" @@ -1014,80 +1054,6 @@ int UtcDaliBuilderLoadFromStringN(void) 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 ); - - // coverage - DALI_TEST_CHECK( true ); - - END_TEST; -} int UtcDaliBuilderAddActorsP(void) { @@ -1101,18 +1067,18 @@ int UtcDaliBuilderAddActorsP(void) " \"type\": \"Actor\",\n" " \"name\": \"actor\",\n" " \"size\": [100,100,1],\n" - " \"parent-origin\": \"TOP_LEFT\",\n" - " \"anchor-point\": \"TOP_LEFT\",\n" + " \"parentOrigin\": \"TOP_LEFT\",\n" + " \"anchorPoint\": \"TOP_LEFT\",\n" " \"actors\": [{\n" " \"type\": \"Actor\",\n" - " \"name\": \"sub-actor\",\n" + " \"name\": \"subActor\",\n" " \"visible\": false\n" " }],\n" " \"signals\": [{\n" - " \"name\": \"touched\",\n" + " \"name\": \"touch\",\n" " \"action\": \"hide\",\n" " \"actor\": \"actor\",\n" - " \"child-actor\": \"sub-actor\"\n" + " \"childActor\": \"subActor\"\n" " }]\n" " }]\n" "}\n" @@ -1126,7 +1092,7 @@ int UtcDaliBuilderAddActorsP(void) application.SendNotification(); application.Render(); - Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("sub-actor"); + Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("subActor"); DALI_TEST_CHECK( actor ); DALI_TEST_CHECK( !actor.IsVisible() ); @@ -1150,34 +1116,30 @@ int UtcDaliBuilderFrameBufferP(void) " },\n" " \"stage\": [\n" " {\n" - " \"type\": \"ImageActor\",\n" + " \"type\": \"ImageView\",\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" + " \"parentOrigin\": [0.5, 0.5, 0.5],\n" " \"size\": [300, 300, 0],\n" " \"image\": \"fb0\",\n" - " \"clear-color\": [1,0,0,1]\n" + " \"clearColor\": [1,0,0,1]\n" " },\n" " {\n" - " \"type\": \"ImageActor\",\n" + " \"type\": \"ImageView\",\n" " \"name\": \"Image1\",\n" " \"size\": [200, 200, 0],\n" - " \"parent-origin\": [0.5, 0.5, 0.5],\n" + " \"parentOrigin\": [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" + " \"url\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\"\n" " },\n" " \"signals\": [\n" " {\n" - " \"name\": \"on-stage\",\n" + " \"name\": \"onStage\",\n" " \"action\": \"play\",\n" " \"animation\": \"Animation_1\"\n" " }\n" @@ -1186,33 +1148,33 @@ int UtcDaliBuilderFrameBufferP(void) " {\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" + " \"aspectRatio\": \"{FB_ASPECT_RATIO}\",\n" + " \"projectionMode\": \"PERSPECTIVE_PROJECTION\",\n" + " \"fieldOfView\": 0.785,\n" + " \"invertYAxis\": true\n" " }\n" " ],\n" - " \"frame-buffer-images\":\n" + " \"frameBufferImages\":\n" " {\n" " \"fb0\":\n" " {\n" " \"type\": \"FrameBufferImage\",\n" - " \"width\": { \"type-cast\":\"float\", \"value\":\"{FB_WIDTH}\" },\n" - " \"height\": { \"type-cast\":\"float\", \"value\":\"{FB_HEIGHT}\" }\n" + " \"width\": { \"typeCast\":\"float\", \"value\":\"{FB_WIDTH}\" },\n" + " \"height\": { \"typeCast\":\"float\", \"value\":\"{FB_HEIGHT}\" }\n" " }\n" " },\n" - " \"render-tasks\":\n" + " \"renderTasks\":\n" " {\n" " \"stage\":\n" " [\n" " {\n" - " \"source-actor\": \"fbOnStage\"\n" + " \"sourceActor\": \"fbOnStage\"\n" " },\n" " {\n" - " \"source-actor\": \"Image1\",\n" - " \"target-frame-buffer\": \"fb0\",\n" - " \"viewport-size\":\"{FB_SIZE}\",\n" - " \"camera-actor\":\"fbCam\"\n" + " \"sourceActor\": \"Image1\",\n" + " \"targetFrameBuffer\": \"fb0\",\n" + " \"viewportSize\":\"{FB_SIZE}\",\n" + " \"cameraActor\":\"fbCam\"\n" " }\n" " ]\n" " },\n" @@ -1225,8 +1187,8 @@ int UtcDaliBuilderFrameBufferP(void) " \"actor\": \"Image1\",\n" " \"property\": \"uTime\",\n" " \"value\": 10.0,\n" - " \"alpha-function\": \"LINEAR\",\n" - " \"time-period\": {\n" + " \"alphaFunction\": \"LINEAR\",\n" + " \"timePeriod\": {\n" " \"delay\": 0,\n" " \"duration\": 10.0\n" " },\n" @@ -1235,17 +1197,17 @@ int UtcDaliBuilderFrameBufferP(void) " ]\n" " }\n" " },\n" - " \"shader-effects\": {\n" + " \"shaderEffects\": {\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" + " \"geometryType\": \"GEOMETRY_TYPE_IMAGE\"\n" " },\n" - " \"geometry-hints\": \"HINT_NONE\",\n" - " \"grid-density\": 0,\n" + " \"geometryHints\": \"HINT_NONE\",\n" + " \"gridDensity\": 0,\n" " \"loop\": true,\n" " \"uAmplitude\": 0.02,\n" " \"uTime\": 0.0\n" @@ -1290,50 +1252,46 @@ int UtcDaliBuilderPathConstraintsP(void) " },\n" " \"stage\": [\n" " {\n" - " \"type\": \"ImageActor\",\n" + " \"type\": \"ImageView\",\n" " \"name\": \"Image1\",\n" " \"size\": [200, 200, 0],\n" - " \"parent-origin\": [0.5, 0.5, 0.5],\n" + " \"parentOrigin\": [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" + " \"url\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\"\n" " },\n" " \"signals\": [\n" " {\n" - " \"name\": \"on-stage\",\n" + " \"name\": \"onStage\",\n" " \"action\": \"play\",\n" - " \"animation\": \"path-animation\"\n" + " \"animation\": \"pathAnimation\"\n" " },\n" " {\n" - " \"name\": \"on-stage\",\n" + " \"name\": \"onStage\",\n" " \"action\": \"applyConstraint\",\n" " \"constrainer\": \"constrainer0\",\n" " \"properties\":\n" " [\n" " {\n" " \"source\": \"Image1\",\n" - " \"sourceProperty\": \"position-x\",\n" + " \"sourceProperty\": \"positionX\",\n" " \"target\": \"Image1\",\n" - " \"targetProperty\": \"color-red\",\n" + " \"targetProperty\": \"colorRed\",\n" " \"range\": [-300,300]\n" " }\n" " ]\n" " },\n" " {\n" - " \"name\": \"on-stage\",\n" + " \"name\": \"onStage\",\n" " \"action\": \"applyConstraint\",\n" " \"constrainer\": \"constrainer1\",\n" " \"properties\":\n" " [\n" " {\n" " \"source\": \"Image1\",\n" - " \"sourceProperty\": \"position-x\",\n" + " \"sourceProperty\": \"positionX\",\n" " \"target\": \"Image1\",\n" - " \"targetProperty\": \"color-blue\",\n" + " \"targetProperty\": \"colorBlue\",\n" " \"range\": [-300,300]\n" " }\n" " ]\n" @@ -1355,7 +1313,7 @@ int UtcDaliBuilderPathConstraintsP(void) " {\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" + " \"controlPoints\": [ [0, 0, 0], [0,0,0], [0,0,0] ]\n" " },\n" " \"constrainer1\":\n" " {\n" @@ -1364,15 +1322,15 @@ int UtcDaliBuilderPathConstraintsP(void) " }\n" " },\n" " \"animations\": {\n" - " \"path-animation\": {\n" + " \"pathAnimation\": {\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" + " \"alphaFunction\": \"EASE_IN_OUT\",\n" + " \"timePeriod\": {\n" " \"delay\": 0,\n" " \"duration\": 3\n" " }\n" @@ -1381,8 +1339,8 @@ int UtcDaliBuilderPathConstraintsP(void) " \"actor\": \"Image1\",\n" " \"property\": \"uTime\",\n" " \"value\": 10.0,\n" - " \"alpha-function\": \"LINEAR\",\n" - " \"time-period\": {\n" + " \"alphaFunction\": \"LINEAR\",\n" + " \"timePeriod\": {\n" " \"delay\": 0,\n" " \"duration\": 10.0\n" " },\n" @@ -1396,8 +1354,8 @@ int UtcDaliBuilderPathConstraintsP(void) " \"actor\": \"Image1\",\n" " \"property\": \"uTime\",\n" " \"value\": 10.0,\n" - " \"alpha-function\": \"LINEAR\",\n" - " \"time-period\": {\n" + " \"alphaFunction\": \"LINEAR\",\n" + " \"timePeriod\": {\n" " \"delay\": 0,\n" " \"duration\": 10.0\n" " },\n" @@ -1406,17 +1364,17 @@ int UtcDaliBuilderPathConstraintsP(void) " ]\n" " }\n" " },\n" - " \"shader-effects\": {\n" + " \"shaderEffects\": {\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" + " \"geometryType\": \"GEOMETRY_TYPE_IMAGE\"\n" " },\n" - " \"geometry-hints\": \"HINT_NONE\",\n" - " \"grid-density\": 0,\n" + " \"geometryHints\": \"HINT_NONE\",\n" + " \"gridDensity\": 0,\n" " \"loop\": true,\n" " \"uAmplitude\": 0.02,\n" " \"uTime\": 0.0\n" @@ -1455,3 +1413,194 @@ int UtcDaliBuilderPathConstraintsP(void) END_TEST; } + +#define CHECK_MAP_ELEMENT( xMap, xKey, xType, xPropType, xExpected, xLocation ) \ + { \ + Property::Value* value = xMap->Find( xKey ); \ + DALI_TEST_EQUALS( value==NULL, false, xLocation); \ + if( value != NULL ) \ + { \ + DALI_TEST_EQUALS( value->GetType(), xPropType, xLocation ); \ + xType result; \ + value->Get(result); \ + DALI_TEST_EQUALS( result, xExpected, TEST_LOCATION ); \ + std::ostringstream oss; \ + oss << "Animation element " << xKey << "= " << result << std::endl; \ + tet_printf( oss.str().c_str() ); \ + } \ + else \ + { \ + tet_printf("Can't find map element " xKey "\n"); \ + } \ + } + + +int UtcDaliBuilderMapping01(void) +{ + ToolkitTestApplication application; + + const char* json = + "{\n" + " \"mappings\":\n" + " {\n" + " \"buttonPressFadeOut\":{\n" + " \"alphaFunction\":\"EASE_OUT\",\n" + " \"timePeriod\":{\n" + " \"delay\":0.0,\n" + " \"duration\":0.4\n" + " }\n" + " },\n" + " \"buttonPressFadeIn\":{\n" + " \"alphaFunction\":\"EASE_IN\",\n" + " \"timePeriod\":{\n" + " \"delay\":0.4,\n" + " \"duration\":0.5\n" + " }\n" + " },\n" + " \"transition:buttonPressed\":\n" + " [\n" + " {\n" + " \"target\": \"unselectedBackgroundRenderer\",\n" + " \"property\": \"opacity\",\n" + " \"value\": 0,\n" + " \"animator\":\"\"\n" + " }\n" + " ],\n" + " \"transition:buttonReleased\":\n" + " [\n" + " {\n" + " \"target\": \"unselectedBackgroundRenderer\",\n" + " \"property\": \"opacity\",\n" + " \"value\": 1,\n" + " \"animator\":\"\"\n" + " },\n" + " {\n" + " \"target\": \"unselectedForegroundRenderer\",\n" + " \"property\": \"scale\",\n" + " \"value\": [ 1, 1, 1 ],\n" + " \"animator\":\"\"\n" + " },\n" + " {\n" + " \"target\": \"selectedBackgroundRenderer\",\n" + " \"property\": \"opacity\",\n" + " \"value\": 0,\n" + " \"animator\": \"\"\n" + " },\n" + " {\n" + " \"target\": \"selectedForegroundRenderer\",\n" + " \"property\": \"scale\",\n" + " \"value\": [ 0, 0, 0 ],\n" + " \"animator\":\"\"\n" + " }\n" + " ]\n" + " },\n" + " \"styles\":\n" + " {\n" + " \"testbutton\":\n" + " {\n" + " \"pressTransition\":\"\",\n" + " \"releaseTransition\":\"\"\n" + " }\n" + " }\n" + "}\n"; + + Builder builder = Builder::New(); + builder.LoadFromString( json ); + + Test::TestButton testButton = Test::TestButton::New(); + Stage::GetCurrent().Add( testButton ); + + // Render and notify + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( builder.ApplyStyle( "testbutton", testButton ) ); + + // Now check that it has loaded the transition correctly: + Property::Value transition = testButton.GetProperty(Test::TestButton::Property::PRESS_TRANSITION); + DALI_TEST_EQUALS( transition.GetType(), Property::ARRAY, TEST_LOCATION ); + Property::Array* array = transition.GetArray(); + + DALI_TEST_EQUALS( array->Size(), 1, TEST_LOCATION ); + Property::Value element = array->GetElementAt(0); + DALI_TEST_CHECK( element.GetType() == Property::MAP ); + Property::Map* map = element.GetMap(); + + CHECK_MAP_ELEMENT(map, "target", std::string, Property::STRING, "unselectedBackgroundRenderer", TEST_LOCATION); + CHECK_MAP_ELEMENT(map, "property", std::string, Property::STRING, "opacity", TEST_LOCATION); + CHECK_MAP_ELEMENT(map, "alphaFunction", int, Property::INTEGER, (int)Dali::AlphaFunction::EASE_OUT, TEST_LOCATION); + CHECK_MAP_ELEMENT(map, "timePeriodDelay", float, Property::FLOAT, 0.0f, TEST_LOCATION); + CHECK_MAP_ELEMENT(map, "timePeriodDuration", float, Property::FLOAT, 0.4f, TEST_LOCATION); + + END_TEST; +} + + +int UtcDaliBuilderMappingCycleCheck(void) +{ + ToolkitTestApplication application; + + std::string json( + "{\n" + " \"mappings\":\n" + " {\n" + " \"cyclicKey1\":\"\",\n" + " \"cyclicKey2\":\"\",\n" + " \"cyclicKey3\":\"\",\n" + " \"FadeOut\":{\n" + " \"alphaFunction\":\"EASE_IN\",\n" + " \"timePeriod\":{\n" + " \"delay\":\"\",\n" + " \"duration\":0.6\n" + " }\n" + " },\n" + " \"transition:buttonPressed\":\n" + " [\n" + " {\n" + " \"target\": \"\",\n" + " \"property\": \"\",\n" + " \"value\": 0,\n" + " \"animator\":\"\"\n" + " }\n" + " ]\n" + " },\n" + " \"styles\":\n" + " {\n" + " \"testbutton\":\n" + " {\n" + " \"pressTransition\":\"\",\n" + " \"releaseTransition\":\"\",\n" + " \"disabledTransition\":\"\",\n" + " \"enabledTransition\":\"\"\n" + " }\n" + " }\n" + "}\n"); + + Builder builder = Builder::New(); + builder.LoadFromString( json ); + + Test::TestButton testButton = Test::TestButton::New(); + Stage::GetCurrent().Add( testButton ); + + // Render and notify + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK( builder.ApplyStyle( "testbutton", testButton ) ); + + // Now check that it has loaded the transition correctly: + Property::Value transition = testButton.GetProperty(Test::TestButton::Property::PRESS_TRANSITION); + DALI_TEST_EQUALS( transition.GetType(), Property::ARRAY, TEST_LOCATION ); + Property::Array* array = transition.GetArray(); + + DALI_TEST_EQUALS( array->Size(), 1, TEST_LOCATION ); + Property::Value element = array->GetElementAt(0); + DALI_TEST_CHECK( element.GetType() == Property::MAP ); + Property::Map* map = element.GetMap(); + + CHECK_MAP_ELEMENT(map, "target", std::string, Property::STRING, "", TEST_LOCATION); + CHECK_MAP_ELEMENT(map, "property", std::string, Property::STRING, "", TEST_LOCATION); + CHECK_MAP_ELEMENT(map, "timePeriodDuration", float, Property::FLOAT, 0.6f, TEST_LOCATION); + + END_TEST; +}