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=653325caf91f723234cc2dfca193762c4970b946;hp=6d8ddffdda6f11830f45fbb4e658c43fef8e665d;hb=f3da11c2818c6d17706fbb2417f21b602b3190f5;hpb=5cf3fe5c50e9c6bd3e52898af024cb29f6881d8c diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp index 6d8ddff..653325c 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp @@ -77,8 +77,8 @@ int UtcDaliBuilderQuitSignal(void) "[{" "\"type\": \"Actor\"," "\"size\": [100,100,1]," - "\"parent-origin\": \"TOP_LEFT\"," - "\"anchor-point\": \"TOP_LEFT\"," + "\"parentOrigin\": \"TOP_LEFT\"," + "\"anchorPoint\": \"TOP_LEFT\"," "\"signals\": [{" "\"name\": \"touched\"," "\"action\": \"quit\"" @@ -115,6 +115,10 @@ int UtcDaliBuilderAnimationP(void) // JSON with a quit event when the actor is touched std::string json( "{" + " \"constants\":" + " {" + " \"ALPHA_FUNCTION\":\"EASE_IN_OUT\"" + " }," " \"paths\":" " {" " \"path0\":" @@ -126,16 +130,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\": \"EASE_IN_OUT\"," + " \"alphaFunction\": \"{ALPHA_FUNCTION}\"," " \"relative\": true," - " \"time-period\": {" + " \"timePeriod\": {" " \"delay\": 0," " \"duration\": 3" " }" @@ -143,81 +147,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" " }" @@ -228,7 +232,7 @@ 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]," @@ -248,7 +252,13 @@ int UtcDaliBuilderAnimationP(void) DALI_TEST_CHECK( anim ); - anim = builder.CreateAnimation("path-animation"); + Property::Map map; + map["ALPHA_FUNCTION"] = "EASE_IN_SQUARE"; + anim = builder.CreateAnimation("animate", map); + + DALI_TEST_CHECK( anim ); + + anim = builder.CreateAnimation("pathAnimation"); DALI_TEST_CHECK( anim ); @@ -273,6 +283,11 @@ int UtcDaliBuilderAnimationN(void) // JSON with a quit event when the actor is touched std::string json( "{" + " \"constants\":" + " {" + " \"TEXT\": \"Touch Me\"," + " \"NAME\": \"greeting\" " + " }," " \"paths\":" " {" " \"path0\":" @@ -284,16 +299,16 @@ int UtcDaliBuilderAnimationN(void) " \"animations\": {" " \"animate\": {" " \"loop\": true," - " \"end-action\": \"BAKE\"," - " \"disconnect-action\": \"BAKE\"," + " \"endAction\": \"BAKE\"," + " \"disconnectAction\": \"BAKE\"," " \"properties\":" " [{" - " \"actor\": \"greeting\"," + " \"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" " }" @@ -302,32 +317,32 @@ int UtcDaliBuilderAnimationN(void) " }," " \"animate2\": {" " \"loop\": true," - " \"end-action\": \"BAKE\"," - " \"disconnect-action\": \"BAKE\"," + " \"endAction\": \"BAKE\"," + " \"disconnectAction\": \"BAKE\"," " \"properties\":" " [{" - " \"actor\": \"greeting\"," + " \"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" " }" @@ -338,7 +353,7 @@ 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]," @@ -347,6 +362,11 @@ int UtcDaliBuilderAnimationN(void) " \"action\": \"play\"," " \"animation\": \"animate\"" " }]" + " }," + " {" + " \"name\": \"greeting2\"," + " \"type\": \"TextLabel\"," + " \"text\": \"Touch me\"" " }]" "}"); @@ -358,13 +378,29 @@ 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"); + 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(true); END_TEST; @@ -387,12 +423,13 @@ int UtcDaliBuilderConstantsP(void) "\"stage\":" "[{" " \"type\": \"ImageActor\"," + " \"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}\"," + " \"sizeWidth\": \"{WIDTH}\"," " \"signals\": [{" " \"name\": \"touched\"," " \"action\": \"quit\"" @@ -403,9 +440,29 @@ int UtcDaliBuilderConstantsP(void) Builder builder = Builder::New(); builder.LoadFromString( json ); + + builder.AddConstant( "NAME", "image" ); + + Property::Map map = builder.GetConstants(); + + Dali::Property::Value* pValue = map.Find( "NAME" ); + + DALI_TEST_CHECK( pValue ); + + pValue = map.Find( "IMAGE_PATH" ); + + DALI_TEST_CHECK( pValue ); + + Dali::Property::Value value = builder.GetConstant( "WIDTH" ); + + DALI_TEST_CHECK( value.GetType() != Property::NONE ); + builder.AddActors ( Stage::GetCurrent().GetRootLayer() ); DALI_TEST_CHECK( builder ); + Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("image"); + DALI_TEST_CHECK( actor ); + END_TEST; } @@ -416,13 +473,17 @@ int UtcDaliBuilderTemplatesAndStylesP(void) // 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" + " \"imageStyle\": \n" " {\n" " \"color\": [1,0,0,1],\n" " \"actors\": {\n" - " \"child-image\": {\n" + " \"childImage\": {\n" " \"color\": [0,1,0,1]\n" " }\n" " }\n" @@ -430,11 +491,11 @@ int UtcDaliBuilderTemplatesAndStylesP(void) "},\n" "\"templates\":\n" "{\n" - " \"image-tree\": { \n" + " \"imageTree\": { \n" " \"type\": \"ImageActor\",\n" - " \"styles\": [\"image-style\"],\n" + " \"styles\": [\"imageStyle\"],\n" " \"name\": \"image\",\n" - " \"size\": [100,100,1],\n" + " \"size\": \"{SIZE}\",\n" " \"signals\": [{\n" " \"name\": \"touched\",\n" " \"action\": \"quit\"\n" @@ -442,22 +503,70 @@ int UtcDaliBuilderTemplatesAndStylesP(void) " \"actors\": [\n" " {\n" " \"type\":\"ImageActor\",\n" - " \"name\":\"child-image\" \n" + " \"name\":\"childImage\" \n" " }\n" " ]\n" " }\n" - "}\n" + "},\n" + "\"stage\":" + "[{" + " \"type\": \"imageTree\"," + " \"size\": [100,100,1]" + "}]" "}\n" ); + std::string stylejson( + "{\n" + " \"color\": [1,0,0,1],\n" + " \"actors\": {\n" + " \"childImage\": {\n" + " \"color\": [0,1,0,1]\n" + " }\n" + " }\n" + "}\n" + ); + + std::string templatejson( + "{ \n" + " \"type\": \"ImageActor\",\n" + " \"styles\": [\"imageStyle\"],\n" + " \"name\": \"image\",\n" + " \"size\": \"{SIZE}\",\n" + " \"signals\": [{\n" + " \"name\": \"touched\",\n" + " \"action\": \"quit\"\n" + " }],\n" + " \"actors\": [\n" + " {\n" + " \"type\":\"ImageActor\",\n" + " \"name\":\"childImage\" \n" + " }\n" + " ]\n" + "}\n" + ); + Builder builder = Builder::New(); builder.LoadFromString( json ); - ImageActor actor = ImageActor::DownCast( builder.Create( "image-tree" ) ); + ImageActor actor = ImageActor::DownCast( builder.Create( "imageTree" ) ); DALI_TEST_CHECK( actor ); + Dali::Property::Map map; + map["SIZE"] = Vector3(100,100,1); + actor = ImageActor::DownCast( builder.Create( "imageTree", map ) ); + DALI_TEST_CHECK( actor ); + + // create from json snippet + actor = ImageActor::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 ) ); END_TEST; } @@ -469,11 +578,11 @@ 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" @@ -493,7 +602,7 @@ int UtcDaliBuilderRenderTasksP(void) " \"actors\": [\n" " {\n" " \"type\":\"ImageActor\",\n" - " \"name\":\"child-image\" \n" + " \"name\":\"childImage\" \n" " }\n" " ]\n" " }\n" @@ -527,17 +636,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" " \"action\": \"hide\",\n" " \"actor\": \"actor\",\n" - " \"child-actor\": \"sub-actor\"\n" + " \"childActor\": \"subActor\"\n" " }]\n" " }]\n" "}\n" @@ -560,7 +669,7 @@ int UtcDaliBuilderChildActionP(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() ); @@ -580,16 +689,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" " \"action\": \"set\",\n" - " \"actor\": \"sub-actor\",\n" + " \"actor\": \"subActor\",\n" " \"property\": \"visible\",\n" " \"value\": false\n" " }]\n" @@ -614,7 +723,7 @@ int UtcDaliBuilderSetPropertyActionP(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() ); @@ -634,11 +743,11 @@ 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" @@ -685,11 +794,11 @@ 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" @@ -732,3 +841,617 @@ int UtcDaliBuilderPropertyNotificationP(void) END_TEST; } + +int UtcDaliBuilderCustomPropertyP(void) +{ + ToolkitTestApplication application; + + // JSON with a quit event when the actor is touched + std::string json( + "{\n" + "\"templates\":\n" + "{\n" + " \"imageTree\": { \n" + " \"type\": \"ImageActor\",\n" + " \"name\": \"image\",\n" + " \"size\": [100,100,1],\n" + " \"signals\": [{\n" + " \"name\": \"touched\",\n" + " \"action\": \"quit\"\n" + " }],\n" + " \"customProperties\": {\n" + " \"newproperty\": true\n" + " },\n" + " \"actors\": [\n" + " {\n" + " \"type\":\"ImageActor\",\n" + " \"name\":\"childImage\" \n" + " }\n" + " ]\n" + " }\n" + "}\n" + "}\n" + ); + + Builder builder = Builder::New(); + builder.LoadFromString( json ); + + ImageActor actor = ImageActor::DownCast( builder.Create( "imageTree" ) ); + DALI_TEST_CHECK( actor ); + + // 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() == true ); + + END_TEST; +} + +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" + " \"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" + " \"loadPolicy\": \"IMMEDIATE\",\n" + " \"releasePolicy\": \"NEVER\"\n" + " },\n" + " \"signals\": [\n" + " {\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" + " \"properties\": [\n" + " {\n" + " \"actor\": \"Image1\",\n" + " \"property\": \"uTime\",\n" + " \"value\": 10.0,\n" + " \"alphaFunction\": \"LINEAR\",\n" + " \"timePeriod\": {\n" + " \"delay\": 0,\n" + " \"duration\": 10.0\n" + " },\n" + " \"gui-builder-timeline-color\": \"#8dc0da\"\n" + " }\n" + " ]\n" + " }\n" + " },\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" + " \"geometryType\": \"GEOMETRY_TYPE_IMAGE\"\n" + " },\n" + " \"geometryHints\": \"HINT_NONE\",\n" + " \"gridDensity\": 0,\n" + " \"loop\": true,\n" + " \"uAmplitude\": 0.02,\n" + " \"uTime\": 0.0\n" + " }\n" + " }\n" + "}\n" + + ); + + Builder builder = Builder::New(); + builder.LoadFromString( json ); + + ShaderEffect effect = builder.GetShaderEffect("Ripple2D"); + + // coverage + DALI_TEST_CHECK( effect ); + + END_TEST; +} + + +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\"," + "\"size\": [100,100,1]," + "\"parentOrigin\": \"TOP_LEFT\"," + "\"anchorPoint\": \"TOP_LEFT\"," + "\"signals\": [{" + "\"name\": \"touched\"," + "\"action\": \"quit\"" + "}]" + "}]" + "}" + ); + 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" + " \"imageTree\": { \n" + " \"type\": \"ImageActor\",\n" + " \"size\": [100,100,1],\n" + " \"parentOrigin\": [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\":\"childImage\" \n" + " }\n" + " ]\n" + " }\n" + "},\n" + " \"stage\": [\n" + " {\n" + " \"type\": \"imageTree\",\n" + " \"name\": \"Image1\",\n" + " \"effect\": \"Ripple2D\",\n" + " \"image\": \"offscreen\"" + " }\n" + " ],\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" + " \"geometryType\": \"GEOMETRY_TYPE_IMAGE\"\n" + " },\n" + " \"geometryHints\": \"HINT_NONE\",\n" + " \"gridDensity\": 0,\n" + " \"loop\": true,\n" + " \"uAmplitude\": 0.02,\n" + " \"uTime\": 0.0\n" + " }\n" + " },\n" + " \"frameBufferImages\": {\n" + " \"offscreen\": {\n" + " \"type\": \"FrameBufferImage\"," + " \"pixelFormat\":\"RGBA8888\"," + " \"width\": 400," + " \"height\": 400" + " }" + " }" + "}\n" + + ); + + Builder builder = Builder::New(); + builder.LoadFromString( json ); + + // 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" + " \"parentOrigin\": \"TOP_LEFT\",\n" + " \"anchorPoint\": \"TOP_LEFT\",\n" + " \"actors\": [{\n" + " \"type\": \"Actor\",\n" + " \"name\": \"subActor\",\n" + " \"visible\": false\n" + " }],\n" + " \"signals\": [{\n" + " \"name\": \"touched\",\n" + " \"action\": \"hide\",\n" + " \"actor\": \"actor\",\n" + " \"childActor\": \"subActor\"\n" + " }]\n" + " }]\n" + "}\n" + ); + + Builder builder = Builder::New(); + builder.LoadFromString( json ); + builder.AddActors ( "arbitarysection", Stage::GetCurrent().GetRootLayer() ); + + // Render and notify + application.SendNotification(); + application.Render(); + + Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("subActor"); + 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" + " \"parentOrigin\": [0.5, 0.5, 0.5],\n" + " \"size\": [300, 300, 0],\n" + " \"image\": \"fb0\",\n" + " \"clearColor\": [1,0,0,1]\n" + " },\n" + " {\n" + " \"type\": \"ImageActor\",\n" + " \"name\": \"Image1\",\n" + " \"size\": [200, 200, 0],\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" + " \"loadPolicy\": \"IMMEDIATE\",\n" + " \"releasePolicy\": \"NEVER\"\n" + " },\n" + " \"signals\": [\n" + " {\n" + " \"name\": \"onStage\",\n" + " \"action\": \"play\",\n" + " \"animation\": \"Animation_1\"\n" + " }\n" + " ]\n" + " },\n" + " {\n" + " \"type\":\"CameraActor\",\n" + " \"name\":\"fbCam\",\n" + " \"aspectRatio\": \"{FB_ASPECT_RATIO}\",\n" + " \"projectionMode\": \"PERSPECTIVE_PROJECTION\",\n" + " \"fieldOfView\": 0.785,\n" + " \"invertYAxis\": true\n" + " }\n" + " ],\n" + " \"frameBufferImages\":\n" + " {\n" + " \"fb0\":\n" + " {\n" + " \"type\": \"FrameBufferImage\",\n" + " \"width\": { \"typeCast\":\"float\", \"value\":\"{FB_WIDTH}\" },\n" + " \"height\": { \"typeCast\":\"float\", \"value\":\"{FB_HEIGHT}\" }\n" + " }\n" + " },\n" + " \"renderTasks\":\n" + " {\n" + " \"stage\":\n" + " [\n" + " {\n" + " \"sourceActor\": \"fbOnStage\"\n" + " },\n" + " {\n" + " \"sourceActor\": \"Image1\",\n" + " \"targetFrameBuffer\": \"fb0\",\n" + " \"viewportSize\":\"{FB_SIZE}\",\n" + " \"cameraActor\":\"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" + " \"alphaFunction\": \"LINEAR\",\n" + " \"timePeriod\": {\n" + " \"delay\": 0,\n" + " \"duration\": 10.0\n" + " },\n" + " \"gui-builder-timeline-color\": \"#8dc0da\"\n" + " }\n" + " ]\n" + " }\n" + " },\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" + " \"geometryType\": \"GEOMETRY_TYPE_IMAGE\"\n" + " },\n" + " \"geometryHints\": \"HINT_NONE\",\n" + " \"gridDensity\": 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" + " \"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" + " \"loadPolicy\": \"IMMEDIATE\",\n" + " \"releasePolicy\": \"NEVER\"\n" + " },\n" + " \"signals\": [\n" + " {\n" + " \"name\": \"onStage\",\n" + " \"action\": \"play\",\n" + " \"animation\": \"pathAnimation\"\n" + " },\n" + " {\n" + " \"name\": \"onStage\",\n" + " \"action\": \"applyConstraint\",\n" + " \"constrainer\": \"constrainer0\",\n" + " \"properties\":\n" + " [\n" + " {\n" + " \"source\": \"Image1\",\n" + " \"sourceProperty\": \"positionX\",\n" + " \"target\": \"Image1\",\n" + " \"targetProperty\": \"colorRed\",\n" + " \"range\": [-300,300]\n" + " }\n" + " ]\n" + " },\n" + " {\n" + " \"name\": \"onStage\",\n" + " \"action\": \"applyConstraint\",\n" + " \"constrainer\": \"constrainer1\",\n" + " \"properties\":\n" + " [\n" + " {\n" + " \"source\": \"Image1\",\n" + " \"sourceProperty\": \"positionX\",\n" + " \"target\": \"Image1\",\n" + " \"targetProperty\": \"colorBlue\",\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" + " \"controlPoints\": [ [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" + " \"pathAnimation\": {\n" + " \"duration\": 3.0,\n" + " \"properties\":\n" + " [{\n" + " \"actor\": \"Image1\",\n" + " \"path\":\"path0\",\n" + " \"forward\":[1,0,0],\n" + " \"alphaFunction\": \"EASE_IN_OUT\",\n" + " \"timePeriod\": {\n" + " \"delay\": 0,\n" + " \"duration\": 3\n" + " }\n" + " },\n" + " {\n" + " \"actor\": \"Image1\",\n" + " \"property\": \"uTime\",\n" + " \"value\": 10.0,\n" + " \"alphaFunction\": \"LINEAR\",\n" + " \"timePeriod\": {\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" + " \"alphaFunction\": \"LINEAR\",\n" + " \"timePeriod\": {\n" + " \"delay\": 0,\n" + " \"duration\": 10.0\n" + " },\n" + " \"gui-builder-timeline-color\": \"#8dc0da\"\n" + " }\n" + " ]\n" + " }\n" + " },\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" + " \"geometryType\": \"GEOMETRY_TYPE_IMAGE\"\n" + " },\n" + " \"geometryHints\": \"HINT_NONE\",\n" + " \"gridDensity\": 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; +}