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=511d2ef7495d470b44187cde2458ff2e425bc999;hp=8b06fd10116a38173f9e86e4abc477c57588c34b;hb=5e351965bad7e1de2e94027548b022bac692603c;hpb=0695455c9e382f0b19d9e1062a384c32b91f0a38 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp index 8b06fd1..511d2ef 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-2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -30,17 +29,52 @@ using namespace Dali; using namespace Toolkit; +namespace BuilderControlProperty +{ + +enum +{ + INTEGER_PROPERTY = Toolkit::Control::CONTROL_PROPERTY_END_INDEX + 1, + MATRIX3_PROPERTY, + MATRIX_PROPERTY, + NONE_PROPERTY +}; + namespace { -std::string ReplaceQuotes(const std::string &in_s) +BaseHandle Create() { - std::string s(in_s); - // wrong as no embedded quote but had regex link problems - std::replace(s.begin(), s.end(), '\'', '"'); - return s; + return Toolkit::Control::New(); +} + +int gSetPropertyCalledCount = 0; + +void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value ) +{ + ++gSetPropertyCalledCount; +} + +Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex ) +{ + return Property::Value(); +} + +} // unnamed namespace + +// Properties +Dali::TypeRegistration typeRegistration( "BuilderControl", typeid( Toolkit::Control ), Create ); + +Dali::PropertyRegistration propertyInteger( typeRegistration, "integerProperty", INTEGER_PROPERTY, Property::INTEGER, &SetProperty, &GetProperty ); +Dali::PropertyRegistration propertyMatrix3( typeRegistration, "matrix3Property", MATRIX3_PROPERTY, Property::MATRIX3, &SetProperty, &GetProperty ); +Dali::PropertyRegistration propertyMatrix( typeRegistration, "matrixProperty", MATRIX_PROPERTY, Property::MATRIX, &SetProperty, &GetProperty ); +Dali::PropertyRegistration propertyNone( typeRegistration, "noneProperty", NONE_PROPERTY, Property::NONE, &SetProperty, &GetProperty ); + } +namespace +{ + struct BuilderFunctor { BuilderFunctor( bool& called ) : mCalled( called ) @@ -79,12 +113,15 @@ int UtcDaliBuilderQuitSignal(void) "{" "\"stage\":" "[{" - "\"type\": \"Actor\"," + "\"type\": \"Layer\"," "\"size\": [100,100,1]," "\"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\"" "}]" "}]" @@ -104,7 +141,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 ); @@ -236,12 +276,12 @@ int UtcDaliBuilderAnimationP(void) " \"name\": \"greeting\"," " \"type\": \"TextLabel\"," " \"text\": \"Touch me\"," - " \"styles\": [\"basicText\"]," + " \"inherit\": [\"basicText\"]," " \"position\": [0, -120, 0]," " \"size\": [200, 200, 1]," " \"orientation\": [0, 0, 30]," " \"signals\": [{" - " \"name\": \"touched\"," + " \"name\": \"touch\"," " \"action\": \"play\"," " \"animation\": \"animate\"" " }]" @@ -269,7 +309,10 @@ int UtcDaliBuilderAnimationP(void) // 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 @@ -357,12 +400,12 @@ int UtcDaliBuilderAnimationN(void) " \"name\": \"greeting\"," " \"type\": \"TextLabel\"," " \"text\": \"Touch me\"," - " \"styles\": [\"basicText\"]," + " \"inherit\": [\"basicText\"]," " \"position\": [0, -120, 0]," " \"size\": [200, 200, 1]," " \"orientation\": [0, 0, 30]," " \"signals\": [{" - " \"name\": \"touched\"," + " \"name\": \"touch\"," " \"action\": \"play\"," " \"animation\": \"animate\"" " }]" @@ -426,16 +469,16 @@ int UtcDaliBuilderConstantsP(void) "}," "\"stage\":" "[{" - " \"type\": \"ImageActor\"," + " \"type\": \"ImageView\"," " \"name\": \"{NAME}\"," " \"size\": [100,100,1]," " \"parentOrigin\": \"TOP_LEFT\"," " \"anchorPoint\": \"{ANCHOR}\"," " \"padding\": \"{PADDING}\"," - " \"image\": { \"filename\": \"dir/{IMAGE_PATH}\" }," + " \"image\": { \"url\": \"dir/{IMAGE_PATH}\" }," " \"sizeWidth\": \"{WIDTH}\"," " \"signals\": [{" - " \"name\": \"touched\"," + " \"name\": \"touch\"," " \"action\": \"quit\"" " }]" "}]" @@ -488,26 +531,41 @@ int UtcDaliBuilderTemplatesAndStylesP(void) " \"color\": [1,0,0,1],\n" " \"actors\": {\n" " \"childImage\": {\n" - " \"color\": [0,1,0,1]\n" + " \"color\": \"34\"\n" " }\n" " }\n" " }\n" "},\n" "\"templates\":\n" "{\n" + " \"imageViewTemplate\": { \n" + " \"type\": \"ImageView\",\n" + " \"styles\": [\"imageStyle\"]\n" + " },\n" " \"imageTree\": { \n" - " \"type\": \"ImageActor\",\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\":\"childImage\" \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" @@ -525,7 +583,7 @@ int UtcDaliBuilderTemplatesAndStylesP(void) " \"color\": [1,0,0,1],\n" " \"actors\": {\n" " \"childImage\": {\n" - " \"color\": [0,1,0,1]\n" + " \"color\": \"#344353\"\n" " }\n" " }\n" "}\n" @@ -533,17 +591,17 @@ int UtcDaliBuilderTemplatesAndStylesP(void) std::string templatejson( "{ \n" - " \"type\": \"ImageActor\",\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" + " \"type\":\"ImageView\",\n" " \"name\":\"childImage\" \n" " }\n" " ]\n" @@ -553,16 +611,16 @@ int UtcDaliBuilderTemplatesAndStylesP(void) Builder builder = Builder::New(); builder.LoadFromString( json ); - ImageActor actor = ImageActor::DownCast( builder.Create( "imageTree" ) ); + 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( "imageTree", 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 ); @@ -593,19 +651,19 @@ int UtcDaliBuilderRenderTasksP(void) "[\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" + " \"type\":\"ImageView\",\n" " \"name\":\"childImage\" \n" " }\n" " ]\n" @@ -647,7 +705,7 @@ int UtcDaliBuilderChildActionP(void) " \"name\": \"subActor\"\n" " }],\n" " \"signals\": [{\n" - " \"name\": \"touched\",\n" + " \"name\": \"touch\",\n" " \"action\": \"hide\",\n" " \"actor\": \"actor\",\n" " \"childActor\": \"subActor\"\n" @@ -666,7 +724,10 @@ 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 @@ -700,7 +761,7 @@ int UtcDaliBuilderSetPropertyActionP(void) " \"name\": \"subActor\"\n" " }],\n" " \"signals\": [{\n" - " \"name\": \"touched\",\n" + " \"name\": \"touch\",\n" " \"action\": \"set\",\n" " \"actor\": \"subActor\",\n" " \"property\": \"visible\",\n" @@ -720,7 +781,10 @@ 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 @@ -754,7 +818,7 @@ int UtcDaliBuilderGenericActionP(void) " \"name\": \"subActor\"\n" " }],\n" " \"signals\": [{\n" - " \"name\": \"touched\",\n" + " \"name\": \"touch\",\n" " \"action\": \"hide\"\n" " }]\n" " }]\n" @@ -771,7 +835,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 @@ -805,13 +872,39 @@ int UtcDaliBuilderPropertyNotificationP(void) " \"name\": \"subActor\"\n" " }],\n" " \"signals\": [{\n" - " \"name\": \"touched\",\n" + " \"name\": \"touch\",\n" " \"action\": \"hide\"\n" " }],\n" " \"notifications\": [{\n" " \"property\": \"visible\",\n" " \"condition\": \"False\",\n" " \"action\": \"show\"\n" + " },\n" + " {\n" + " \"property\": \"positionX\",\n" + " \"condition\": \"LessThan\",\n" + " \"arg0\": 0.0,\n" + " \"action\": \"show\"\n" + " },\n" + " {\n" + " \"property\": \"positionY\",\n" + " \"condition\": \"GreaterThan\",\n" + " \"arg0\": 200.0,\n" + " \"action\": \"show\"\n" + " },\n" + " {\n" + " \"property\": \"positionZ\",\n" + " \"condition\": \"Inside\",\n" + " \"arg0\": 0.0,\n" + " \"arg1\": 10.0,\n" + " \"action\": \"show\"\n" + " },\n" + " {\n" + " \"property\": \"positionZ\",\n" + " \"condition\": \"Outside\",\n" + " \"arg0\": 40.0,\n" + " \"arg1\": 50.0,\n" + " \"action\": \"show\"\n" " }]\n" " }]\n" "}\n" @@ -827,7 +920,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 @@ -846,6 +942,42 @@ int UtcDaliBuilderPropertyNotificationP(void) END_TEST; } +int UtcDaliBuilderPropertyNotificationN(void) +{ + ToolkitTestApplication application; + + // JSON with a quit event when the actor is touched + std::string json( + "{\n" + " \"stage\":\n" + " [{\n" + " \"type\": \"Actor\",\n" + " \"notifications\": [{\n" + " \"property\": \"visible\",\n" + " \"condition\": \"ErrorCondition\",\n" + " \"action\": \"show\"\n" + " }]\n" + " }]\n" + "}\n" + ); + + try + { + Builder builder = Builder::New(); + builder.LoadFromString( json ); + builder.AddActors ( Stage::GetCurrent().GetRootLayer() ); + DALI_TEST_CHECK( false ); + } + catch(...) + { + DALI_TEST_CHECK( true ); + } + + END_TEST; +} + + + int UtcDaliBuilderCustomPropertyP(void) { ToolkitTestApplication application; @@ -856,19 +988,22 @@ int UtcDaliBuilderCustomPropertyP(void) "\"templates\":\n" "{\n" " \"imageTree\": { \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" - " \"customProperties\": {\n" + " \"properties\": {\n" " \"newproperty\": true\n" " },\n" + " \"animatableProperties\": {\n" + " \"newAnimatableproperty\": 3\n" + " },\n" " \"actors\": [\n" " {\n" - " \"type\":\"ImageActor\",\n" + " \"type\":\"ImageView\",\n" " \"name\":\"childImage\" \n" " }\n" " ]\n" @@ -880,7 +1015,7 @@ int UtcDaliBuilderCustomPropertyP(void) Builder builder = Builder::New(); builder.LoadFromString( json ); - ImageActor actor = ImageActor::DownCast( builder.Create( "imageTree" ) ); + ImageView actor = ImageView::DownCast( builder.Create( "imageTree" ) ); DALI_TEST_CHECK( actor ); // NB: already applied in create @@ -889,10 +1024,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; @@ -901,7 +1041,7 @@ int UtcDaliBuilderShaderEffectP(void) "{\n" " \"stage\": [\n" " {\n" - " \"type\": \"ImageActor\",\n" + " \"type\": \"ImageView\",\n" " \"name\": \"Image1\",\n" " \"position\": [\n" " 0.40461349487305,\n" @@ -912,11 +1052,16 @@ int UtcDaliBuilderShaderEffectP(void) " \"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" + " \"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" @@ -927,7 +1072,6 @@ int UtcDaliBuilderShaderEffectP(void) " ]\n" " }\n" " ],\n" - " \"paths\": {},\n" " \"animations\": {\n" " \"Animation_1\": {\n" " \"loop\":true,\n" @@ -940,27 +1084,10 @@ int UtcDaliBuilderShaderEffectP(void) " \"timePeriod\": {\n" " \"delay\": 0,\n" " \"duration\": 10.0\n" - " },\n" - " \"gui-builder-timeline-color\": \"#8dc0da\"\n" + " }\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" @@ -969,10 +1096,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; } @@ -992,7 +1125,7 @@ int UtcDaliBuilderLoadFromStringN(void) "\"parentOrigin\": \"TOP_LEFT\"," "\"anchorPoint\": \"TOP_LEFT\"," "\"signals\": [{" - "\"name\": \"touched\"," + "\"name\": \"touch\"," "\"action\": \"quit\"" "}]" "}]" @@ -1018,80 +1151,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" - " \"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) { @@ -1113,7 +1172,7 @@ int UtcDaliBuilderAddActorsP(void) " \"visible\": false\n" " }],\n" " \"signals\": [{\n" - " \"name\": \"touched\",\n" + " \"name\": \"touch\",\n" " \"action\": \"hide\",\n" " \"actor\": \"actor\",\n" " \"childActor\": \"subActor\"\n" @@ -1154,7 +1213,7 @@ int UtcDaliBuilderFrameBufferP(void) " },\n" " \"stage\": [\n" " {\n" - " \"type\": \"ImageActor\",\n" + " \"type\": \"ImageView\",\n" " \"name\": \"fbOnStage\",\n" " \"position\": [\n" " 0.40461349487305,\n" @@ -1167,17 +1226,13 @@ int UtcDaliBuilderFrameBufferP(void) " \"clearColor\": [1,0,0,1]\n" " },\n" " {\n" - " \"type\": \"ImageActor\",\n" + " \"type\": \"ImageView\",\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" + " \"url\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\"\n" " },\n" " \"signals\": [\n" " {\n" @@ -1238,22 +1293,6 @@ int UtcDaliBuilderFrameBufferP(void) " }\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"); @@ -1294,17 +1333,13 @@ int UtcDaliBuilderPathConstraintsP(void) " },\n" " \"stage\": [\n" " {\n" - " \"type\": \"ImageActor\",\n" + " \"type\": \"ImageView\",\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" + " \"url\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\"\n" " },\n" " \"signals\": [\n" " {\n" @@ -1341,6 +1376,36 @@ int UtcDaliBuilderPathConstraintsP(void) " \"range\": [-300,300]\n" " }\n" " ]\n" + " },\n" + " {\n" + " \"name\": \"offStage\",\n" + " \"action\": \"removeConstraints\",\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\": \"offStage\",\n" + " \"action\": \"removeConstraints\",\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" @@ -1409,22 +1474,6 @@ int UtcDaliBuilderPathConstraintsP(void) " }\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"); @@ -1457,6 +1506,18 @@ int UtcDaliBuilderPathConstraintsP(void) Dali::LinearConstrainer constrainer1_2 = builder.GetLinearConstrainer( "constrainer1" ); DALI_TEST_CHECK( constrainer1 == constrainer1_2 ); + // For coverage + + Actor actor = Actor::New(); + Stage::GetCurrent().Add( actor ); + builder.AddActors( actor ); + + // Render and notify + application.SendNotification(); + application.Render(); + + actor.GetChildAt( 0 ).Unparent(); + END_TEST; } @@ -1650,3 +1711,143 @@ int UtcDaliBuilderMappingCycleCheck(void) END_TEST; } + +int UtcDaliBuilderTypeCasts(void) +{ + ToolkitTestApplication application; + + std::string json( + "{" + "\"stage\":" + "[{" + "\"type\": \"Layer\"," + "\"maximumSize\": { \"typeCast\":\"vector2\", \"value\":[100,15] }," + "\"position\": { \"typeCast\":\"vector3\", \"value\":[100,10,1] }," + "\"color\": { \"typeCast\":\"vector4\", \"value\":[0.5,0.5,0.5,1] }," + "\"sensitive\": { \"typeCast\":\"boolean\", \"value\":false }," + "\"orientation\": { \"typeCast\":\"rotation\", \"value\":[10,10,10,10] }," + "\"colorMode\": { \"typeCast\":\"string\", \"value\":\"USE_OWN_MULTIPLY_PARENT_COLOR\" }," + "\"clippingBox\": { \"typeCast\":\"rect\", \"value\":[10,10,10,10] }," + "\"padding\": { \"typeCast\":\"extents\", \"value\":[10,10,10,10] }" + "}]" + "}" + ); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + Builder builder = Builder::New(); + builder.LoadFromString( json ); + builder.AddActors( rootActor ); + + application.SendNotification(); + application.Render(); + + Actor createdActor = rootActor.GetChildAt( 0 ); + DALI_TEST_EQUALS( createdActor.GetMaximumSize(), Vector2(100.0f,15.0f), TEST_LOCATION ); + DALI_TEST_EQUALS( createdActor.GetCurrentPosition(), Vector3(100.0f,10.0f,1.0f), TEST_LOCATION ); + DALI_TEST_EQUALS( createdActor.GetCurrentColor(), Vector4(0.5f,0.5f,0.5f,1.0f), TEST_LOCATION ); + DALI_TEST_EQUALS( createdActor.IsSensitive(), false, TEST_LOCATION ); + DALI_TEST_EQUALS( createdActor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliBuilderBuilderControl(void) +{ + ToolkitTestApplication application; + + std::string json( + "{" + "\"stage\":" + "[{" + "\"type\": \"BuilderControl\"," + "\"integerProperty\": 10," + "\"matrix3Property\": [ 1,2,3,4,5,6,7,8,9 ]," + "\"matrixProperty\": [ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 ]," + "\"noneProperty\": 10" + "}]" + "}" + ); + + Actor rootActor = Actor::New(); + Stage::GetCurrent().Add( rootActor ); + + Builder builder = Builder::New(); + builder.LoadFromString( json ); + builder.AddActors( rootActor ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( BuilderControlProperty::gSetPropertyCalledCount, 4, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliBuilderActionsWithParams(void) +{ + ToolkitTestApplication application; + + // JSON with a quit event when the actor is touched + std::string json( + "{\n" + "\"stage\":\n" + "[\n" + " { \n" + " \"type\": \"ImageView\",\n" + " \"name\": \"image\",\n" + " \"size\": [100,100,1],\n" + " \"signals\": [{\n" + " \"name\": \"touch\",\n" + " \"action\": \"show\",\n" + " \"parameters\": {\n" + " \"property1\" : 10,\n" + " \"property2\" : [1,2],\n" + " \"property3\" : [1,2,3],\n" + " \"property4\" : [1,2,3,4]\n" + " }\n" + " }]\n" + " }\n" + "]\n" + "}\n" + ); + + Builder builder = Builder::New(); + builder.LoadFromString( json ); + builder.AddActors( Stage::GetCurrent().GetRootLayer() ); + + DALI_TEST_CHECK( true ); // For Coverage + + END_TEST; +} + +int UtcDaliBuilderConfigurationP(void) +{ + ToolkitTestApplication application; + + // JSON with a quit event when the actor is touched + std::string json( + "{\n" + " \"config\":\n" + " {\n" + " \"alwaysShowFocus\":true\n" + " }\n" + "}\n" + ); + + Builder builder = Builder::New(); + builder.LoadFromString( json ); + + Property::Map map = builder.GetConfigurations(); + + Dali::Property::Value* pValue = map.Find( "alwaysShowFocus" ); + + DALI_TEST_CHECK( pValue ); + + bool value = pValue->Get(); + + DALI_TEST_CHECK( value ); + + END_TEST; +}