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=ca325225e07613b4bb380ed31ff63263d1113f25;hp=61bbc5c7173fdc1f36e4391e3e678352296450f5;hb=HEAD;hpb=29540fc153880d6949c85786b78b8583ae8f1d37 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp index 61bbc5c..f332890 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) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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. @@ -15,30 +15,28 @@ * */ +#include +#include #include #include #include -#include -#include #include -#include +#include #include +#include #include -#include -#include -#include #include +#include +#include - -#define STRINGIFY(A)#A +#define STRINGIFY(A) #A using namespace Dali; using namespace Toolkit; namespace BuilderControlProperty { - enum { INTEGER_PROPERTY = Toolkit::Control::CONTROL_PROPERTY_END_INDEX + 1, @@ -49,7 +47,6 @@ enum namespace { - BaseHandle Create() { return Toolkit::Control::New(); @@ -57,12 +54,12 @@ BaseHandle Create() int gSetPropertyCalledCount = 0; -void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value ) +void SetProperty(BaseObject* object, Property::Index propertyIndex, const Property::Value& value) { ++gSetPropertyCalledCount; } -Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex ) +Property::Value GetProperty(BaseObject* object, Property::Index propertyIndex) { return Property::Value(); } @@ -70,21 +67,21 @@ Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex ) } // unnamed namespace // Properties -Dali::TypeRegistration typeRegistration( "BuilderControl", typeid( Toolkit::Control ), Create ); +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 ); +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 BuilderControlProperty namespace { - struct BuilderFunctor { - BuilderFunctor( bool& called ) : mCalled( called ) + BuilderFunctor(bool& called) + : mCalled(called) { mCalled = false; } @@ -99,8 +96,6 @@ struct BuilderFunctor } // namespace - - void builder_startup(void) { test_return_value = TET_UNDEF; @@ -117,30 +112,29 @@ int UtcDaliBuilderQuitSignal(void) // JSON with a quit event when the actor is touched std::string json( - "{" - "\"stage\":" - "[{" - "\"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\": \"touch\"," - "\"action\": \"quit\"" - "}]" - "}]" - "}" - ); + "{" + "\"stage\":" + "[{" + "\"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\"," + "\"action\": \"quit\"" + "}]" + "}]" + "}"); Builder builder = Builder::New(); - builder.LoadFromString( json ); - builder.AddActors ( application.GetScene().GetRootLayer() ); + builder.LoadFromString(json); + builder.AddActors(application.GetScene().GetRootLayer()); // Connect to builder's quit signal - bool functorCalled( false ); - builder.QuitSignal().Connect( &application, BuilderFunctor( functorCalled ) ); + bool functorCalled(false); + builder.QuitSignal().Connect(&application, BuilderFunctor(functorCalled)); // Render and notify application.SendNotification(); @@ -148,185 +142,202 @@ int UtcDaliBuilderQuitSignal(void) // Emit touch event and check that our quit method is called Integration::TouchEvent touchEvent; - 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 ); + 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); END_TEST; } - int UtcDaliBuilderAnimationP(void) { ToolkitTestApplication application; // JSON with a quit event when the actor is touched std::string json( - "{" - " \"constants\":" - " {" - " \"ALPHA_FUNCTION\":\"EASE_IN_OUT\"" - " }," - " \"paths\":" - " {" - " \"path0\":" - " {" - " \"points\":[ [-150, -50, 0], [0.0,70.0,0.0], [190.0,-150.0,0.0] ]," - " \"curvature\":0.35" - " }" - " }," - " \"animations\": {" - " \"animate\": {" - " \"loop\": true," - " \"endAction\": \"BAKE\"," - " \"disconnectAction\": \"BAKE\"," - " \"properties\":" - " [{" - " \"actor\": \"greeting\"," - " \"property\": \"position\"," - " \"value\": [300, 300, -1000]," - " \"alphaFunction\": \"{ALPHA_FUNCTION}\"," - " \"relative\": true," - " \"timePeriod\": {" - " \"delay\": 0," - " \"duration\": 3" - " }" - " }," - " {" - " \"actor\": \"greeting\"," - " \"property\": \"visible\"," - " \"alphaFunction\": \"LINEAR\"," - " \"value\": true" - " }," - " {" - " \"actor\": \"greeting\"," - " \"property\": \"sizeWidth\"," - " \"alphaFunction\": \"REVERSE\"," - " \"value\": 10.0" - " }," - " {" - " \"actor\": \"greeting\"," - " \"property\": \"orientation\"," - " \"alphaFunction\": \"EASE_IN\"," - " \"value\": [10.0,20.0,30.0]" - " }," - " {" - " \"actor\": \"greeting\"," - " \"property\": \"orientation\"," - " \"alphaFunction\": \"EASE_OUT\"," - " \"value\": [0.0, 0.0, 0.0, 1.0]" - " }," - " {" - " \"actor\": \"greeting\"," - " \"property\": \"orientation\"," - " \"alphaFunction\": \"EASE_IN_OUT\"," - " \"value\": [0.0, 0.0, 0.0, 1.0]" - " }," - " {" - " \"actor\": \"greeting\"," - " \"property\": \"orientation\"," - " \"alphaFunction\": \"EASE_IN_SINE\"," - " \"value\": [0.0, 0.0, 0.0, 1.0]" - " }," - " {" - " \"actor\": \"greeting\"," - " \"property\": \"orientation\"," - " \"alphaFunction\": \"EASE_OUT_SINE\"," - " \"value\": [0.0, 0.0, 0.0, 1.0]" - " }," - " {" - " \"actor\": \"greeting\"," - " \"property\": \"orientation\"," - " \"alphaFunction\": \"EASE_IN_OUT_SINE\"," - " \"value\": [0.0, 0.0, 0.0, 1.0]" - " }," - " {" - " \"actor\": \"greeting\"," - " \"property\": \"orientation\"," - " \"alphaFunction\": \"BOUNCE\"," - " \"value\": [0.0, 0.0, 0.0, 1.0]" - " }," - " {" - " \"actor\": \"greeting\"," - " \"property\": \"orientation\"," - " \"alphaFunction\": \"SIN\"," - " \"value\": [0.0, 0.0, 0.0, 1.0]" - " }," - " {" - " \"actor\": \"greeting\"," - " \"property\": \"orientation\"," - " \"alphaFunction\": \"EASE_OUT_BACK\"," - " \"value\": [0.0, 0.0, 0.0, 1.0]" - " }" - " ]" - " }," - " \"pathAnimation\": {" - " \"duration\": 3.0," - " \"endAction\": \"DISCARD\"," - " \"disconnectAction\": \"BAKE_FINAL\"," - " \"properties\": [{" - " \"actor\": \"greeting\"," - " \"path\":\"path0\"," - " \"forward\":[1,0,0]," - " \"alphaFunction\": \"EASE_IN_OUT\"," - " \"timePeriod\": {" - " \"delay\": 0," - " \"duration\": 3" - " }" - " }]" - " }" - " }," - " \"stage\": [{" - " \"name\": \"greeting\"," - " \"type\": \"TextLabel\"," - " \"text\": \"Touch me\"," - " \"inherit\": [\"basicText\"]," - " \"position\": [0, -120, 0]," - " \"size\": [200, 200, 1]," - " \"orientation\": [0, 0, 30]," - " \"signals\": [{" - " \"name\": \"touch\"," - " \"action\": \"play\"," - " \"animation\": \"animate\"" - " }]" - " }]" - "}"); + "{" + " \"constants\":" + " {" + " \"ALPHA_FUNCTION\":\"EASE_IN_OUT\"" + " }," + " \"paths\":" + " {" + " \"path0\":" + " {" + " \"points\":[ [-150, -50, 0], [0.0,70.0,0.0], [190.0,-150.0,0.0] ]," + " \"curvature\":0.35" + " }" + " }," + " \"animations\": {" + " \"animate\": {" + " \"loop\": true," + " \"endAction\": \"BAKE\"," + " \"disconnectAction\": \"BAKE\"," + " \"properties\":" + " [{" + " \"actor\": \"greeting\"," + " \"property\": \"position\"," + " \"value\": [300, 300, -1000]," + " \"alphaFunction\": \"{ALPHA_FUNCTION}\"," + " \"relative\": true," + " \"timePeriod\": {" + " \"delay\": 0," + " \"duration\": 3" + " }" + " }," + " {" + " \"actor\": \"greeting\"," + " \"property\": \"visible\"," + " \"alphaFunction\": \"LINEAR\"," + " \"value\": true" + " }," + " {" + " \"actor\": \"greeting\"," + " \"property\": \"sizeWidth\"," + " \"alphaFunction\": \"REVERSE\"," + " \"value\": 10.0" + " }," + " {" + " \"actor\": \"greeting\"," + " \"property\": \"orientation\"," + " \"alphaFunction\": \"EASE_IN\"," + " \"value\": [10.0,20.0,30.0]" + " }," + " {" + " \"actor\": \"greeting\"," + " \"property\": \"orientation\"," + " \"alphaFunction\": \"EASE_OUT\"," + " \"value\": [0.0, 0.0, 0.0, 1.0]" + " }," + " {" + " \"actor\": \"greeting\"," + " \"property\": \"orientation\"," + " \"alphaFunction\": \"EASE_IN_OUT\"," + " \"value\": [0.0, 0.0, 0.0, 1.0]" + " }," + " {" + " \"actor\": \"greeting\"," + " \"property\": \"orientation\"," + " \"alphaFunction\": \"EASE_IN_SINE\"," + " \"value\": [0.0, 0.0, 0.0, 1.0]" + " }," + " {" + " \"actor\": \"greeting\"," + " \"property\": \"orientation\"," + " \"alphaFunction\": \"EASE_OUT_SINE\"," + " \"value\": [0.0, 0.0, 0.0, 1.0]" + " }," + " {" + " \"actor\": \"greeting\"," + " \"property\": \"orientation\"," + " \"alphaFunction\": \"EASE_IN_OUT_SINE\"," + " \"value\": [0.0, 0.0, 0.0, 1.0]" + " }," + " {" + " \"actor\": \"greeting\"," + " \"property\": \"orientation\"," + " \"alphaFunction\": \"BOUNCE\"," + " \"value\": [0.0, 0.0, 0.0, 1.0]" + " }," + " {" + " \"actor\": \"greeting\"," + " \"property\": \"orientation\"," + " \"alphaFunction\": \"SIN\"," + " \"value\": [0.0, 0.0, 0.0, 1.0]" + " }," + " {" + " \"actor\": \"greeting\"," + " \"property\": \"orientation\"," + " \"alphaFunction\": \"EASE_OUT_BACK\"," + " \"value\": [0.0, 0.0, 0.0, 1.0]" + " }" + " ]" + " }," + " \"pathAnimation\": {" + " \"duration\": 3.0," + " \"endAction\": \"DISCARD\"," + " \"disconnectAction\": \"BAKE_FINAL\"," + " \"properties\": [{" + " \"actor\": \"greeting\"," + " \"path\":\"path0\"," + " \"forward\":[1,0,0]," + " \"alphaFunction\": \"EASE_IN_OUT\"," + " \"timePeriod\": {" + " \"delay\": 0," + " \"duration\": 3" + " }" + " }]" + " }," + " \"pathAnimation2\": {" + " \"duration\": 3.0," + " \"endAction\": \"BAKE_FINAL\"," + " \"disconnectAction\": \"DISCARD\"," + " \"properties\": [{" + " \"actor\": \"greeting\"," + " \"path\":\"path0\"," + " \"forward\":[1,0,0]," + " \"alphaFunction\": \"EASE_IN_OUT\"," + " \"timePeriod\": {" + " \"delay\": 0," + " \"duration\": 3" + " }" + " }]" + " }" + " }," + " \"stage\": [{" + " \"name\": \"greeting\"," + " \"type\": \"TextLabel\"," + " \"text\": \"Touch me\"," + " \"inherit\": [\"basicText\"]," + " \"position\": [0, -120, 0]," + " \"size\": [200, 200, 1]," + " \"orientation\": [0, 0, 30]," + " \"signals\": [{" + " \"name\": \"touched\"," + " \"action\": \"play\"," + " \"animation\": \"animate\"" + " }]" + " }]" + "}"); Builder builder = Builder::New(); - builder.LoadFromString( json ); - builder.AddActors( application.GetScene().GetRootLayer() ); + builder.LoadFromString(json); + builder.AddActors(application.GetScene().GetRootLayer()); Animation anim = builder.CreateAnimation("animate"); - DALI_TEST_CHECK( anim ); + DALI_TEST_CHECK(anim); Property::Map map; map["ALPHA_FUNCTION"] = "EASE_IN_SQUARE"; - anim = builder.CreateAnimation("animate", map); + anim = builder.CreateAnimation("animate", map); - DALI_TEST_CHECK( anim ); + DALI_TEST_CHECK(anim); anim = builder.CreateAnimation("pathAnimation"); - DALI_TEST_CHECK( anim ); + DALI_TEST_CHECK(anim); + + anim = builder.CreateAnimation("pathAnimation2"); + + DALI_TEST_CHECK(anim); // trigger play // Emit touch event and check that our quit method is called Integration::TouchEvent touchEvent; - Integration::Point point; - point.SetState( PointState::DOWN ); - point.SetScreenPosition( Vector2( 10.0f, 10.0f ) ); - touchEvent.points.push_back( point ); - application.ProcessEvent( touchEvent ); + 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(); - END_TEST; } @@ -336,98 +347,97 @@ int UtcDaliBuilderAnimationN(void) // JSON with a quit event when the actor is touched std::string json( - "{" - " \"constants\":" - " {" - " \"TEXT\": \"Touch Me\"," - " \"NAME\": \"greeting\" " - " }," - " \"paths\":" - " {" - " \"path0\":" - " {" - " \"points\":[ [-150, -50, 0], [0.0,70.0,0.0], [190.0,-150.0,0.0] ]," - " \"curvature\":0.35" - " }" - " }," - " \"animations\": {" - " \"animate\": {" - " \"loop\": true," - " \"endAction\": \"BAKE\"," - " \"disconnectAction\": \"BAKE\"," - " \"properties\":" - " [{" - " \"actor\": \"{NAME}\"," - " \"property\": \"positioninvalid\"," - " \"value\": [300, 300, -1000]," - " \"alphaFunction\": \"EASE_IN_OUT\"," - " \"relative\": true," - " \"timePeriod\": {" - " \"delay\": 0," - " \"duration\": 3" - " }" - " }" - " ]" - " }," - " \"animate2\": {" - " \"loop\": true," - " \"endAction\": \"BAKE\"," - " \"disconnectAction\": \"BAKE\"," - " \"properties\":" - " [{" - " \"actor\": \"{NAME}\"," - " \"property\": \"positioninvalid\"," - " \"value\": [300, 300, -1000]," - " \"alphaFunction\": \"EGGS_OVER_EASY\"," - " \"relative\": true," - " \"timePeriod\": {" - " \"delay\": 0," - " \"duration\": 3" - " }" - " }" - " ]" - " }," - " \"pathAnimation\": {" - " \"duration\": 3.0," - " \"endAction\": \"DISCARD\"," - " \"disconnectAction\": \"BAKE_FINAL\"," - " \"properties\": [{" - " \"actor\": \"greeting\"," - " \"path\":\"pathDoesntExist\"," - " \"forward\":[1,0,0]," - " \"alphaFunction\": \"EASE_IN_OUT\"," - " \"timePeriod\": {" - " \"delay\": 0," - " \"duration\": 3" - " }" - " }]" - " }" - " }," - " \"stage\": [{" - " \"name\": \"greeting\"," - " \"type\": \"TextLabel\"," - " \"text\": \"Touch me\"," - " \"inherit\": [\"basicText\"]," - " \"position\": [0, -120, 0]," - " \"size\": [200, 200, 1]," - " \"orientation\": [0, 0, 30]," - " \"signals\": [{" - " \"name\": \"touch\"," - " \"action\": \"play\"," - " \"animation\": \"animate\"" - " }]" - " }," - " {" - " \"name\": \"greeting2\"," - " \"type\": \"TextLabel\"," - " \"text\": \"Touch me\"" - " }]" - "}"); - + "{" + " \"constants\":" + " {" + " \"TEXT\": \"Touch Me\"," + " \"NAME\": \"greeting\" " + " }," + " \"paths\":" + " {" + " \"path0\":" + " {" + " \"points\":[ [-150, -50, 0], [0.0,70.0,0.0], [190.0,-150.0,0.0] ]," + " \"curvature\":0.35" + " }" + " }," + " \"animations\": {" + " \"animate\": {" + " \"loop\": true," + " \"endAction\": \"BAKE\"," + " \"disconnectAction\": \"BAKE\"," + " \"properties\":" + " [{" + " \"actor\": \"{NAME}\"," + " \"property\": \"positioninvalid\"," + " \"value\": [300, 300, -1000]," + " \"alphaFunction\": \"EASE_IN_OUT\"," + " \"relative\": true," + " \"timePeriod\": {" + " \"delay\": 0," + " \"duration\": 3" + " }" + " }" + " ]" + " }," + " \"animate2\": {" + " \"loop\": true," + " \"endAction\": \"BAKE\"," + " \"disconnectAction\": \"BAKE\"," + " \"properties\":" + " [{" + " \"actor\": \"{NAME}\"," + " \"property\": \"positioninvalid\"," + " \"value\": [300, 300, -1000]," + " \"alphaFunction\": \"EGGS_OVER_EASY\"," + " \"relative\": true," + " \"timePeriod\": {" + " \"delay\": 0," + " \"duration\": 3" + " }" + " }" + " ]" + " }," + " \"pathAnimation\": {" + " \"duration\": 3.0," + " \"endAction\": \"DISCARD\"," + " \"disconnectAction\": \"BAKE_FINAL\"," + " \"properties\": [{" + " \"actor\": \"greeting\"," + " \"path\":\"pathDoesntExist\"," + " \"forward\":[1,0,0]," + " \"alphaFunction\": \"EASE_IN_OUT\"," + " \"timePeriod\": {" + " \"delay\": 0," + " \"duration\": 3" + " }" + " }]" + " }" + " }," + " \"stage\": [{" + " \"name\": \"greeting\"," + " \"type\": \"TextLabel\"," + " \"text\": \"Touch me\"," + " \"inherit\": [\"basicText\"]," + " \"position\": [0, -120, 0]," + " \"size\": [200, 200, 1]," + " \"orientation\": [0, 0, 30]," + " \"signals\": [{" + " \"name\": \"touched\"," + " \"action\": \"play\"," + " \"animation\": \"animate\"" + " }]" + " }," + " {" + " \"name\": \"greeting2\"," + " \"type\": \"TextLabel\"," + " \"text\": \"Touch me\"" + " }]" + "}"); Builder builder = Builder::New(); - builder.LoadFromString( json ); - builder.AddActors( application.GetScene().GetRootLayer() ); + builder.LoadFromString(json); + builder.AddActors(application.GetScene().GetRootLayer()); Animation anim = builder.CreateAnimation("animate"); @@ -444,7 +454,7 @@ int UtcDaliBuilderAnimationN(void) // create referencing a different actor aka animation templates Property::Map map; map["NAME"] = "greeting2"; - anim = builder.CreateAnimation("animate2", map); + anim = builder.CreateAnimation("animate2", map); DALI_TEST_CHECK(anim); // alternative actor to use for FindChildByName @@ -455,9 +465,7 @@ int UtcDaliBuilderAnimationN(void) anim = builder.CreateAnimation("animate2", map, application.GetScene().GetRootLayer()); DALI_TEST_CHECK(anim); - END_TEST; - } int UtcDaliBuilderConstantsP(void) @@ -466,56 +474,55 @@ int UtcDaliBuilderConstantsP(void) // JSON with a quit event when the actor is touched std::string json( - "{" - "\"constants\":" - "{" - " \"IMAGE_PATH\": \"apath\"," - " \"WIDTH\": 22.3," - " \"ANCHOR\": \"TOP_LEFT\"," - " \"PADDING\": [1,2,3,4]" - "}," - "\"stage\":" - "[{" - " \"type\": \"ImageView\"," - " \"name\": \"{NAME}\"," - " \"size\": [100,100,1]," - " \"parentOrigin\": \"TOP_LEFT\"," - " \"anchorPoint\": \"{ANCHOR}\"," - " \"padding\": \"{PADDING}\"," - " \"image\": { \"url\": \"dir/{IMAGE_PATH}\" }," - " \"sizeWidth\": \"{WIDTH}\"," - " \"signals\": [{" - " \"name\": \"touch\"," - " \"action\": \"quit\"" - " }]" - "}]" - "}" - ); + "{" + "\"constants\":" + "{" + " \"IMAGE_PATH\": \"apath\"," + " \"WIDTH\": 22.3," + " \"ANCHOR\": \"TOP_LEFT\"," + " \"PADDING\": [1,2,3,4]" + "}," + "\"stage\":" + "[{" + " \"type\": \"ImageView\"," + " \"name\": \"{NAME}\"," + " \"size\": [100,100,1]," + " \"parentOrigin\": \"TOP_LEFT\"," + " \"anchorPoint\": \"{ANCHOR}\"," + " \"padding\": \"{PADDING}\"," + " \"image\": { \"url\": \"dir/{IMAGE_PATH}\" }," + " \"sizeWidth\": \"{WIDTH}\"," + " \"signals\": [{" + " \"name\": \"touched\"," + " \"action\": \"quit\"" + " }]" + "}]" + "}"); Builder builder = Builder::New(); - builder.LoadFromString( json ); + builder.LoadFromString(json); - builder.AddConstant( "NAME", "image" ); + builder.AddConstant("NAME", "image"); Property::Map map = builder.GetConstants(); - Dali::Property::Value* pValue = map.Find( "NAME" ); + Dali::Property::Value* pValue = map.Find("NAME"); - DALI_TEST_CHECK( pValue ); + DALI_TEST_CHECK(pValue); - pValue = map.Find( "IMAGE_PATH" ); + pValue = map.Find("IMAGE_PATH"); - DALI_TEST_CHECK( pValue ); + DALI_TEST_CHECK(pValue); - Dali::Property::Value value = builder.GetConstant( "WIDTH" ); + Dali::Property::Value value = builder.GetConstant("WIDTH"); - DALI_TEST_CHECK( value.GetType() != Property::NONE ); + DALI_TEST_CHECK(value.GetType() != Property::NONE); - builder.AddActors ( application.GetScene().GetRootLayer() ); - DALI_TEST_CHECK( builder ); + builder.AddActors(application.GetScene().GetRootLayer()); + DALI_TEST_CHECK(builder); Actor actor = application.GetScene().GetRootLayer().FindChildByName("image"); - DALI_TEST_CHECK( actor ); + DALI_TEST_CHECK(actor); END_TEST; } @@ -526,64 +533,63 @@ 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" - " \"imageStyle\": \n" - " {\n" - " \"color\": [1,0,0,1],\n" - " \"actors\": {\n" - " \"childImage\": {\n" - " \"color\": \"34\"\n" - " }\n" - " }\n" - " }\n" - "},\n" - "\"templates\":\n" - "{\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\": \"touch\",\n" - " \"action\": \"quit\"\n" - " }],\n" - " \"actors\": [\n" - " {\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\": \"imageTree\"," - " \"size\": [100,100,1]" - "}]" - "}\n" - ); + "{\n" + "\"constants\":" + "{" + " \"SIZE\": [10,20,30]" + "}," + "\"styles\":\n" + "{\n" + " \"imageStyle\": \n" + " {\n" + " \"color\": [1,0,0,1],\n" + " \"actors\": {\n" + " \"childImage\": {\n" + " \"color\": \"34\"\n" + " }\n" + " }\n" + " }\n" + "},\n" + "\"templates\":\n" + "{\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" + " \"action\": \"quit\"\n" + " }],\n" + " \"actors\": [\n" + " {\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\": \"imageTree\"," + " \"size\": [100,100,1]" + "}]" + "}\n"); std::string stylejson( "{\n" @@ -593,8 +599,7 @@ int UtcDaliBuilderTemplatesAndStylesP(void) " \"color\": \"#344353\"\n" " }\n" " }\n" - "}\n" - ); + "}\n"); std::string templatejson( "{ \n" @@ -603,7 +608,7 @@ int UtcDaliBuilderTemplatesAndStylesP(void) " \"name\": \"image\",\n" " \"size\": \"{SIZE}\",\n" " \"signals\": [{\n" - " \"name\": \"touch\",\n" + " \"name\": \"touched\",\n" " \"action\": \"quit\"\n" " }],\n" " \"actors\": [\n" @@ -612,30 +617,28 @@ int UtcDaliBuilderTemplatesAndStylesP(void) " \"name\":\"childImage\" \n" " }\n" " ]\n" - "}\n" - ); + "}\n"); Builder builder = Builder::New(); - builder.LoadFromString( json ); + builder.LoadFromString(json); - ImageView actor = ImageView::DownCast( builder.Create( "imageTree" ) ); - DALI_TEST_CHECK( actor ); + ImageView actor = ImageView::DownCast(builder.Create("imageTree")); + DALI_TEST_CHECK(actor); Dali::Property::Map map; - map["SIZE"] = Vector3(100,100,1); - actor = ImageView::DownCast( builder.Create( "imageTree", map ) ); - DALI_TEST_CHECK( actor ); + map["SIZE"] = Vector3(100, 100, 1); + actor = ImageView::DownCast(builder.Create("imageTree", map)); + DALI_TEST_CHECK(actor); // create from json snippet - actor = ImageView::DownCast( builder.CreateFromJson( templatejson ) ); - DALI_TEST_CHECK( actor ); - + actor = ImageView::DownCast(builder.CreateFromJson(templatejson)); + DALI_TEST_CHECK(actor); // NB: already applied in create - DALI_TEST_CHECK( builder.ApplyStyle( "imageStyle", actor ) ); + DALI_TEST_CHECK(builder.ApplyStyle("imageStyle", actor)); // apply from json snippet - DALI_TEST_CHECK( builder.ApplyFromJson( actor, stylejson ) ); + DALI_TEST_CHECK(builder.ApplyFromJson(actor, stylejson)); END_TEST; } @@ -646,49 +649,48 @@ int UtcDaliBuilderRenderTasksP(void) // JSON with a quit event when the actor is touched std::string json( - "{\n" - "\"renderTasks\":\n" - "{\n" - " \"task0\": {\n" - " \"sourceActor\": \"image\",\n" - " \"cameraActor\": \"camera\" \n" - " }\n" - "},\n" - "\"stage\":\n" - "[\n" - " { \n" - " \"type\": \"CameraActor\",\n" - " \"name\": \"camera\"\n" - " }, \n" - " { \n" - " \"type\": \"ImageView\",\n" - " \"name\": \"image\",\n" - " \"size\": [100,100,1],\n" - " \"signals\": [{\n" - " \"name\": \"touch\",\n" - " \"action\": \"quit\"\n" - " }],\n" - " \"actors\": [\n" - " {\n" - " \"type\":\"ImageView\",\n" - " \"name\":\"childImage\" \n" - " }\n" - " ]\n" - " }\n" - "]\n" - "}\n" - ); + "{\n" + "\"renderTasks\":\n" + "{\n" + " \"task0\": {\n" + " \"sourceActor\": \"image\",\n" + " \"cameraActor\": \"camera\" \n" + " }\n" + "},\n" + "\"stage\":\n" + "[\n" + " { \n" + " \"type\": \"CameraActor\",\n" + " \"name\": \"camera\"\n" + " }, \n" + " { \n" + " \"type\": \"ImageView\",\n" + " \"name\": \"image\",\n" + " \"size\": [100,100,1],\n" + " \"signals\": [{\n" + " \"name\": \"touched\",\n" + " \"action\": \"quit\"\n" + " }],\n" + " \"actors\": [\n" + " {\n" + " \"type\":\"ImageView\",\n" + " \"name\":\"childImage\" \n" + " }\n" + " ]\n" + " }\n" + "]\n" + "}\n"); Builder builder = Builder::New(); - builder.LoadFromString( json ); + builder.LoadFromString(json); unsigned int count = application.GetScene().GetRenderTaskList().GetTaskCount(); // coverage - builder.CreateRenderTask( "task0" ); + builder.CreateRenderTask("task0"); - DALI_TEST_CHECK( count < - application.GetScene().GetRenderTaskList().GetTaskCount() ); + DALI_TEST_CHECK(count < + application.GetScene().GetRenderTaskList().GetTaskCount()); END_TEST; } @@ -699,31 +701,30 @@ int UtcDaliBuilderChildActionP(void) // JSON with a quit event when the actor is touched std::string json( - "{\n" - " \"stage\":\n" - " [{\n" - " \"type\": \"Actor\",\n" - " \"name\": \"actor\",\n" - " \"size\": [100,100,1],\n" - " \"parentOrigin\": \"TOP_LEFT\",\n" - " \"anchorPoint\": \"TOP_LEFT\",\n" - " \"actors\": [{\n" - " \"type\": \"Actor\",\n" - " \"name\": \"subActor\"\n" - " }],\n" - " \"signals\": [{\n" - " \"name\": \"touch\",\n" - " \"action\": \"hide\",\n" - " \"actor\": \"actor\",\n" - " \"childActor\": \"subActor\"\n" - " }]\n" - " }]\n" - "}\n" - ); + "{\n" + " \"stage\":\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" + " }],\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 ( application.GetScene().GetRootLayer() ); + builder.LoadFromString(json); + builder.AddActors(application.GetScene().GetRootLayer()); // Render and notify application.SendNotification(); @@ -731,20 +732,20 @@ int UtcDaliBuilderChildActionP(void) // Emit touch event and check that our quit method is called Integration::TouchEvent touchEvent; - Integration::Point point; - point.SetState( PointState::DOWN ); - point.SetScreenPosition( Vector2( 10.0f, 10.0f ) ); - touchEvent.points.push_back( point ); - application.ProcessEvent( touchEvent ); + 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 = application.GetScene().GetRootLayer().FindChildByName("subActor"); - DALI_TEST_CHECK( actor ); + DALI_TEST_CHECK(actor); - DALI_TEST_CHECK( !actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) ); + DALI_TEST_CHECK(!actor.GetCurrentProperty(Actor::Property::VISIBLE)); END_TEST; } @@ -755,32 +756,31 @@ int UtcDaliBuilderSetPropertyActionP(void) // JSON with a quit event when the actor is touched std::string json( - "{\n" - " \"stage\":\n" - " [{\n" - " \"type\": \"Actor\",\n" - " \"name\": \"actor\",\n" - " \"size\": [100,100,1],\n" - " \"parentOrigin\": \"TOP_LEFT\",\n" - " \"anchorPoint\": \"TOP_LEFT\",\n" - " \"actors\": [{\n" - " \"type\": \"Actor\",\n" - " \"name\": \"subActor\"\n" - " }],\n" - " \"signals\": [{\n" - " \"name\": \"touch\",\n" - " \"action\": \"set\",\n" - " \"actor\": \"subActor\",\n" - " \"property\": \"visible\",\n" - " \"value\": false\n" - " }]\n" - " }]\n" - "}\n" - ); + "{\n" + " \"stage\":\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" + " }],\n" + " \"signals\": [{\n" + " \"name\": \"touched\",\n" + " \"action\": \"set\",\n" + " \"actor\": \"subActor\",\n" + " \"property\": \"visible\",\n" + " \"value\": false\n" + " }]\n" + " }]\n" + "}\n"); Builder builder = Builder::New(); - builder.LoadFromString( json ); - builder.AddActors ( application.GetScene().GetRootLayer() ); + builder.LoadFromString(json); + builder.AddActors(application.GetScene().GetRootLayer()); // Render and notify application.SendNotification(); @@ -788,20 +788,20 @@ int UtcDaliBuilderSetPropertyActionP(void) // Emit touch event and check that our quit method is called Integration::TouchEvent touchEvent; - Integration::Point point; - point.SetState( PointState::DOWN ); - point.SetScreenPosition( Vector2( 10.0f, 10.0f ) ); - touchEvent.points.push_back( point ); - application.ProcessEvent( touchEvent ); + 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 = application.GetScene().GetRootLayer().FindChildByName("subActor"); - DALI_TEST_CHECK( actor ); + DALI_TEST_CHECK(actor); - DALI_TEST_CHECK( !actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) ); + DALI_TEST_CHECK(!actor.GetCurrentProperty(Actor::Property::VISIBLE)); END_TEST; } @@ -812,29 +812,28 @@ int UtcDaliBuilderGenericActionP(void) // JSON with a quit event when the actor is touched std::string json( - "{\n" - " \"stage\":\n" - " [{\n" - " \"type\": \"Actor\",\n" - " \"name\": \"actor\",\n" - " \"size\": [100,100,1],\n" - " \"parentOrigin\": \"TOP_LEFT\",\n" - " \"anchorPoint\": \"TOP_LEFT\",\n" - " \"actors\": [{\n" - " \"type\": \"Actor\",\n" - " \"name\": \"subActor\"\n" - " }],\n" - " \"signals\": [{\n" - " \"name\": \"touch\",\n" - " \"action\": \"hide\"\n" - " }]\n" - " }]\n" - "}\n" - ); + "{\n" + " \"stage\":\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" + " }],\n" + " \"signals\": [{\n" + " \"name\": \"touched\",\n" + " \"action\": \"hide\"\n" + " }]\n" + " }]\n" + "}\n"); Builder builder = Builder::New(); - builder.LoadFromString( json ); - builder.AddActors ( application.GetScene().GetRootLayer() ); + builder.LoadFromString(json); + builder.AddActors(application.GetScene().GetRootLayer()); // Render and notify application.SendNotification(); @@ -842,20 +841,20 @@ int UtcDaliBuilderGenericActionP(void) // Emit touch event and check that our quit method is called Integration::TouchEvent touchEvent; - Integration::Point point; - point.SetState( PointState::DOWN ); - point.SetScreenPosition( Vector2( 10.0f, 10.0f ) ); - touchEvent.points.push_back( point ); - application.ProcessEvent( touchEvent ); + 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 = application.GetScene().GetRootLayer().FindChildByName("actor"); - DALI_TEST_CHECK( actor ); + DALI_TEST_CHECK(actor); - DALI_TEST_CHECK( !actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) ); + DALI_TEST_CHECK(!actor.GetCurrentProperty(Actor::Property::VISIBLE)); END_TEST; } @@ -866,60 +865,59 @@ int UtcDaliBuilderPropertyNotificationP(void) // JSON with a quit event when the actor is touched std::string json( - "{\n" - " \"stage\":\n" - " [{\n" - " \"type\": \"Actor\",\n" - " \"name\": \"actor\",\n" - " \"size\": [100,100,1],\n" - " \"parentOrigin\": \"TOP_LEFT\",\n" - " \"anchorPoint\": \"TOP_LEFT\",\n" - " \"actors\": [{\n" - " \"type\": \"Actor\",\n" - " \"name\": \"subActor\"\n" - " }],\n" - " \"signals\": [{\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" - ); + "{\n" + " \"stage\":\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" + " }],\n" + " \"signals\": [{\n" + " \"name\": \"touched\",\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"); Builder builder = Builder::New(); - builder.LoadFromString( json ); - builder.AddActors ( application.GetScene().GetRootLayer() ); + builder.LoadFromString(json); + builder.AddActors(application.GetScene().GetRootLayer()); // Render and notify application.SendNotification(); @@ -927,11 +925,11 @@ int UtcDaliBuilderPropertyNotificationP(void) // Emit touch event and check that our quit method is called Integration::TouchEvent touchEvent; - Integration::Point point; - point.SetState( PointState::DOWN ); - point.SetScreenPosition( Vector2( 10.0f, 10.0f ) ); - touchEvent.points.push_back( point ); - application.ProcessEvent( touchEvent ); + 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(); @@ -942,9 +940,9 @@ int UtcDaliBuilderPropertyNotificationP(void) application.Render(); Actor actor = application.GetScene().GetRootLayer().FindChildByName("actor"); - DALI_TEST_CHECK( actor ); + DALI_TEST_CHECK(actor); - DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) ); + DALI_TEST_CHECK(actor.GetCurrentProperty(Actor::Property::VISIBLE)); END_TEST; } @@ -955,86 +953,82 @@ int UtcDaliBuilderPropertyNotificationN(void) // 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" - ); + "{\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 ( application.GetScene().GetRootLayer() ); - DALI_TEST_CHECK( false ); + builder.LoadFromString(json); + builder.AddActors(application.GetScene().GetRootLayer()); + DALI_TEST_CHECK(false); } catch(...) { - DALI_TEST_CHECK( true ); + DALI_TEST_CHECK(true); } 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\": \"ImageView\",\n" - " \"name\": \"image\",\n" - " \"size\": [100,100,1],\n" - " \"signals\": [{\n" - " \"name\": \"touch\",\n" - " \"action\": \"quit\"\n" - " }],\n" - " \"properties\": {\n" - " \"newproperty\": true\n" - " },\n" - " \"animatableProperties\": {\n" - " \"newAnimatableproperty\": 3\n" - " },\n" - " \"actors\": [\n" - " {\n" - " \"type\":\"ImageView\",\n" - " \"name\":\"childImage\" \n" - " }\n" - " ]\n" - " }\n" - "}\n" - "}\n" - ); + "{\n" + "\"templates\":\n" + "{\n" + " \"imageTree\": { \n" + " \"type\": \"ImageView\",\n" + " \"name\": \"image\",\n" + " \"size\": [100,100,1],\n" + " \"signals\": [{\n" + " \"name\": \"touched\",\n" + " \"action\": \"quit\"\n" + " }],\n" + " \"properties\": {\n" + " \"newproperty\": true\n" + " },\n" + " \"animatableProperties\": {\n" + " \"newAnimatableproperty\": 3\n" + " },\n" + " \"actors\": [\n" + " {\n" + " \"type\":\"ImageView\",\n" + " \"name\":\"childImage\" \n" + " }\n" + " ]\n" + " }\n" + "}\n" + "}\n"); Builder builder = Builder::New(); - builder.LoadFromString( json ); + builder.LoadFromString(json); - ImageView actor = ImageView::DownCast( builder.Create( "imageTree" ) ); - DALI_TEST_CHECK( actor ); + ImageView actor = ImageView::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 ); + DALI_TEST_CHECK(Property::INVALID_INDEX != index); Property::Value value = actor.GetProperty(index); - DALI_TEST_CHECK( value.Get() == true ); + DALI_TEST_CHECK(value.Get() == true); index = actor.GetPropertyIndex("newAnimatableproperty"); - DALI_TEST_CHECK( Property::INVALID_INDEX != index ); + DALI_TEST_CHECK(Property::INVALID_INDEX != index); value = actor.GetProperty(index); - DALI_TEST_CHECK( value.Get() == 3 ); + DALI_TEST_CHECK(value.Get() == 3); END_TEST; } @@ -1101,9 +1095,9 @@ int UtcDaliBuilderCustomShaderP(void) ); Builder builder = Builder::New(); - builder.LoadFromString( json ); + builder.LoadFromString(json); - builder.AddActors ( "stage", application.GetScene().GetRootLayer() ); + builder.AddActors("stage", application.GetScene().GetRootLayer()); // Render and notify application.SendNotification(); @@ -1112,94 +1106,90 @@ int UtcDaliBuilderCustomShaderP(void) Actor actor = application.GetScene().GetRootLayer().FindChildByName("Image1"); // coverage - DALI_TEST_CHECK( actor ); + DALI_TEST_CHECK(actor); 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\": \"touch\"," - "\"action\": \"quit\"" - "}]" - "}]" - "}" - ); + "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 ); + builder.LoadFromString(json); } - catch( Dali::DaliException& e ) + catch(Dali::DaliException& e) { - DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_PRINT_ASSERT(e); DALI_TEST_EQUALS(e.condition, "!\"Cannot parse JSON\"", TEST_LOCATION); assert1 = true; } - DALI_TEST_CHECK( assert1 ); + DALI_TEST_CHECK(assert1); 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\": \"touch\",\n" - " \"action\": \"hide\",\n" - " \"actor\": \"actor\",\n" - " \"childActor\": \"subActor\"\n" - " }]\n" - " }]\n" - "}\n" - ); + "{\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", application.GetScene().GetRootLayer() ); + builder.LoadFromString(json); + builder.AddActors("arbitarysection", application.GetScene().GetRootLayer()); // Render and notify application.SendNotification(); application.Render(); Actor actor = application.GetScene().GetRootLayer().FindChildByName("subActor"); - DALI_TEST_CHECK( actor ); + DALI_TEST_CHECK(actor); - DALI_TEST_CHECK( !actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) ); + DALI_TEST_CHECK(!actor.GetCurrentProperty(Actor::Property::VISIBLE)); END_TEST; } @@ -1367,68 +1357,67 @@ int UtcDaliBuilderPathConstraintsP(void) Builder builder = Builder::New(); // frame buffer coverage - builder.LoadFromString( json ); + builder.LoadFromString(json); // Render and notify application.SendNotification(); application.Render(); - Dali::Path path = builder.GetPath( "path0" ); - DALI_TEST_CHECK( path ); + 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::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 = 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::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 = builder.GetLinearConstrainer("constrainer1"); + DALI_TEST_CHECK(constrainer1); - Dali::LinearConstrainer constrainer1_2 = builder.GetLinearConstrainer( "constrainer1" ); - DALI_TEST_CHECK( constrainer1 == constrainer1_2 ); + Dali::LinearConstrainer constrainer1_2 = builder.GetLinearConstrainer("constrainer1"); + DALI_TEST_CHECK(constrainer1 == constrainer1_2); // For coverage Actor actor = Actor::New(); - application.GetScene().Add( actor ); - builder.AddActors( actor ); + application.GetScene().Add(actor); + builder.AddActors(actor); // Render and notify application.SendNotification(); application.Render(); - actor.GetChildAt( 0 ).Unparent(); + actor.GetChildAt(0).Unparent(); 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"); \ - } \ +#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; @@ -1499,25 +1488,25 @@ int UtcDaliBuilderMapping01(void) "}\n"; Builder builder = Builder::New(); - builder.LoadFromString( json ); + builder.LoadFromString(json); Test::TestButton testButton = Test::TestButton::New(); - application.GetScene().Add( testButton ); + application.GetScene().Add(testButton); // Render and notify application.SendNotification(); application.Render(); - DALI_TEST_CHECK( builder.ApplyStyle( "testbutton", testButton ) ); + 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 ); + DALI_TEST_EQUALS(transition.GetType(), Property::ARRAY, TEST_LOCATION); Property::Array* array = transition.GetArray(); - DALI_TEST_EQUALS( array->Size(), 1, TEST_LOCATION ); + DALI_TEST_EQUALS(array->Size(), 1, TEST_LOCATION); Property::Value element = array->GetElementAt(0); - DALI_TEST_CHECK( element.GetType() == Property::MAP ); + DALI_TEST_CHECK(element.GetType() == Property::MAP); Property::Map* map = element.GetMap(); CHECK_MAP_ELEMENT(map, "target", std::string, Property::STRING, "unselectedBackgroundRenderer", TEST_LOCATION); @@ -1529,7 +1518,6 @@ int UtcDaliBuilderMapping01(void) END_TEST; } - int UtcDaliBuilderMappingCycleCheck(void) { ToolkitTestApplication application; @@ -1571,25 +1559,25 @@ int UtcDaliBuilderMappingCycleCheck(void) "}\n"); Builder builder = Builder::New(); - builder.LoadFromString( json ); + builder.LoadFromString(json); Test::TestButton testButton = Test::TestButton::New(); - application.GetScene().Add( testButton ); + application.GetScene().Add(testButton); // Render and notify application.SendNotification(); application.Render(); - DALI_TEST_CHECK( builder.ApplyStyle( "testbutton", testButton ) ); + 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 ); + DALI_TEST_EQUALS(transition.GetType(), Property::ARRAY, TEST_LOCATION); Property::Array* array = transition.GetArray(); - DALI_TEST_EQUALS( array->Size(), 1, TEST_LOCATION ); + DALI_TEST_EQUALS(array->Size(), 1, TEST_LOCATION); Property::Value element = array->GetElementAt(0); - DALI_TEST_CHECK( element.GetType() == Property::MAP ); + DALI_TEST_CHECK(element.GetType() == Property::MAP); Property::Map* map = element.GetMap(); CHECK_MAP_ELEMENT(map, "target", std::string, Property::STRING, "", TEST_LOCATION); @@ -1605,37 +1593,36 @@ int UtcDaliBuilderTypeCasts(void) 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] }" - "}]" - "}" - ); + "\"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(); - application.GetScene().Add( rootActor ); + application.GetScene().Add(rootActor); Builder builder = Builder::New(); - builder.LoadFromString( json ); - builder.AddActors( rootActor ); + builder.LoadFromString(json); + builder.AddActors(rootActor); application.SendNotification(); application.Render(); - Actor createdActor = rootActor.GetChildAt( 0 ); - DALI_TEST_EQUALS( createdActor.GetProperty< Vector2 >( Actor::Property::MAXIMUM_SIZE ), Vector2(100.0f,15.0f), TEST_LOCATION ); - DALI_TEST_EQUALS( createdActor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3(100.0f,10.0f,1.0f), TEST_LOCATION ); - DALI_TEST_EQUALS( createdActor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Vector4(0.5f,0.5f,0.5f,1.0f), TEST_LOCATION ); - DALI_TEST_EQUALS( createdActor.GetProperty< bool >( Actor::Property::SENSITIVE ), false, TEST_LOCATION ); - DALI_TEST_EQUALS( createdActor.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION ); + Actor createdActor = rootActor.GetChildAt(0); + DALI_TEST_EQUALS(createdActor.GetProperty(Actor::Property::MAXIMUM_SIZE), Vector2(100.0f, 15.0f), TEST_LOCATION); + DALI_TEST_EQUALS(createdActor.GetCurrentProperty(Actor::Property::POSITION), Vector3(100.0f, 10.0f, 1.0f), TEST_LOCATION); + DALI_TEST_EQUALS(createdActor.GetCurrentProperty(Actor::Property::COLOR), Vector4(0.5f, 0.5f, 0.5f, 1.0f), TEST_LOCATION); + DALI_TEST_EQUALS(createdActor.GetProperty(Actor::Property::SENSITIVE), false, TEST_LOCATION); + DALI_TEST_EQUALS(createdActor.GetProperty(Actor::Property::COLOR_MODE), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION); END_TEST; } @@ -1646,28 +1633,27 @@ int UtcDaliBuilderBuilderControl(void) 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" - "}]" - "}" - ); + "\"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(); - application.GetScene().Add( rootActor ); + application.GetScene().Add(rootActor); Builder builder = Builder::New(); - builder.LoadFromString( json ); - builder.AddActors( rootActor ); + builder.LoadFromString(json); + builder.AddActors(rootActor); application.SendNotification(); application.Render(); - DALI_TEST_EQUALS( BuilderControlProperty::gSetPropertyCalledCount, 4, TEST_LOCATION ); + DALI_TEST_EQUALS(BuilderControlProperty::gSetPropertyCalledCount, 4, TEST_LOCATION); END_TEST; } @@ -1678,32 +1664,31 @@ int UtcDaliBuilderCustomControl(void) std::string json( "{" - "\"stage\":" - "[{" - "\"type\": \"DummyControl\"," - "\"name\": \"I can haz custom Control\"" - "}]" - "}" - ); + "\"stage\":" + "[{" + "\"type\": \"DummyControl\"," + "\"name\": \"I can haz custom Control\"" + "}]" + "}"); Actor rootActor = Actor::New(); - application.GetScene().Add( rootActor ); + application.GetScene().Add(rootActor); Builder builder = Builder::New(); - builder.LoadFromString( json ); - builder.AddActors( rootActor ); + builder.LoadFromString(json); + builder.AddActors(rootActor); application.SendNotification(); application.Render(); - Actor customControl = rootActor.FindChildByName( "I can haz custom Control" ); + Actor customControl = rootActor.FindChildByName("I can haz custom Control"); // Test that we have the correct type of custom control - DummyControl dummyControl = DummyControl::DownCast( customControl ); - DALI_TEST_CHECK( dummyControl ); - if( dummyControl ) + DummyControl dummyControl = DummyControl::DownCast(customControl); + DALI_TEST_CHECK(dummyControl); + if(dummyControl) { - DALI_TEST_CHECK( typeid(dummyControl.GetImplementation()) == typeid(DummyControlImpl) ); + DALI_TEST_CHECK(typeid(dummyControl.GetImplementation()) == typeid(DummyControlImpl)); } END_TEST; @@ -1715,33 +1700,32 @@ int UtcDaliBuilderActionsWithParams(void) // 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" - ); + "{\n" + "\"stage\":\n" + "[\n" + " { \n" + " \"type\": \"ImageView\",\n" + " \"name\": \"image\",\n" + " \"size\": [100,100,1],\n" + " \"signals\": [{\n" + " \"name\": \"touched\",\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( application.GetScene().GetRootLayer() ); + builder.LoadFromString(json); + builder.AddActors(application.GetScene().GetRootLayer()); - DALI_TEST_CHECK( true ); // For Coverage + DALI_TEST_CHECK(true); // For Coverage END_TEST; } @@ -1752,47 +1736,107 @@ int UtcDaliBuilderConfigurationP(void) // JSON with a quit event when the actor is touched std::string json( - "{\n" - " \"config\":\n" - " {\n" - " \"alwaysShowFocus\":true\n" - " }\n" - "}\n" - ); + "{\n" + " \"config\":\n" + " {\n" + " \"alwaysShowFocus\":true\n" + " }\n" + "}\n"); Builder builder = Builder::New(); - builder.LoadFromString( json ); + builder.LoadFromString(json); Property::Map map = builder.GetConfigurations(); - Dali::Property::Value* pValue = map.Find( "alwaysShowFocus" ); + Dali::Property::Value* pValue = map.Find("alwaysShowFocus"); - DALI_TEST_CHECK( pValue ); + DALI_TEST_CHECK(pValue); bool value = pValue->Get(); - DALI_TEST_CHECK( value ); + DALI_TEST_CHECK(value); END_TEST; } - int UtcDaliBase64EncodingP(void) { - std::vector data = { 0, 1, 2, 3, 4, 5, std::numeric_limits::min(), std::numeric_limits::max() }; + std::vector data = {0, 1, 2, 3, 4, 5, std::numeric_limits::min(), std::numeric_limits::max()}; Property::Value value; - EncodeBase64PropertyData( value, data ); + EncodeBase64PropertyData(value, data); std::cout << "Max uint32_t:" << std::numeric_limits::max() << std::endl; std::cout << "Input data: "; - std::ostream_iterator out_it (std::cout,", "); - std::copy ( data.begin(), data.end(), out_it ); + std::ostream_iterator out_it(std::cout, ", "); + std::copy(data.begin(), data.end(), out_it); std::cout << std::endl; std::string output; - DALI_TEST_CHECK( value.Get( output ) ); - DALI_TEST_EQUALS( output, "AAAAAAEAAAACAAAAAwAAAAQAAAAFAAAAAAAAAP////8", TEST_LOCATION ); + DALI_TEST_CHECK(value.Get(output)); + DALI_TEST_EQUALS(output, "AAAAAAEAAAACAAAAAwAAAAQAAAAFAAAAAAAAAP////8=", TEST_LOCATION); + + std::cout << "Output data: " << output << std::endl; + + END_TEST; +} + +int UtcDaliBase64EncodingP2(void) +{ + std::vector data = {0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, std::numeric_limits::min(), std::numeric_limits::min(), std::numeric_limits::min(), std::numeric_limits::min(), std::numeric_limits::max(), std::numeric_limits::max(), std::numeric_limits::max(), std::numeric_limits::max()}; + + Property::Value value; + EncodeBase64PropertyData(value, data); + + std::cout << "Input data: "; + std::ostream_iterator out_it(std::cout, ", "); + std::copy(data.begin(), data.end(), out_it); + std::cout << std::endl; + + std::string output; + DALI_TEST_CHECK(value.Get(output)); + DALI_TEST_EQUALS(output, "AAAAAAEAAAACAAAAAwAAAAQAAAAFAAAAAAAAAP////8=", TEST_LOCATION); + + std::cout << "Output data: " << output << std::endl; + + END_TEST; +} + +int UtcDaliBase64EncodingP3(void) +{ + std::string originalData = "Something Longer than 64 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/== length is 106"; + originalData.push_back(-4); + originalData.push_back(-7); // some kind of non-ascii. + originalData.push_back(0); + originalData.push_back(0); + originalData.push_back(2); + originalData.push_back(2); + originalData.push_back(2); + + std::vector data(originalData.begin(), originalData.end()); + + Dali::Property::Value value; + EncodeBase64PropertyData(value, data); + + std::cout << "Input data: "; + std::ostream_iterator out_it(std::cout, ", "); + std::copy(data.begin(), data.end(), out_it); + std::cout << std::endl; + + std::string output; + Dali::Property::Array array; + DALI_TEST_CHECK(value.GetArray()); + array = *value.GetArray(); + DALI_TEST_EQUALS(array.Count(), 3, TEST_LOCATION); + DALI_TEST_CHECK(array[0].Get(output)); + std::cout << "first string : " << output << std::endl; + DALI_TEST_EQUALS(output, "U29tZXRoaW5nIExvbmdlciB0aGFuIDY0IEFCQ0RFRkdISUpLTE1OT1BRUlNUVVZX", TEST_LOCATION); + DALI_TEST_CHECK(array[1].Get(output)); + std::cout << "second string : " << output << std::endl; + DALI_TEST_EQUALS(output, "WFlaYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5Ky89PSAgbGVu", TEST_LOCATION); + DALI_TEST_CHECK(array[2].Get(output)); + std::cout << "third string : " << output << std::endl; + DALI_TEST_EQUALS(output, "Z3RoIGlzIDEwNvz5AAACAgI=", TEST_LOCATION); std::cout << "Output data: " << output << std::endl; @@ -1801,205 +1845,210 @@ int UtcDaliBase64EncodingP(void) int UtcDaliBase64EncodingN(void) { - tet_infoline( "Test encoding an empty vector returns empty string" ); + tet_infoline("Test encoding an empty vector returns empty string"); std::vector data; Property::Value value; - EncodeBase64PropertyData( value, data ); + EncodeBase64PropertyData(value, data); std::string output; - DALI_TEST_CHECK( value.Get( output ) ); - DALI_TEST_EQUALS( output.empty(), true, TEST_LOCATION ); + DALI_TEST_CHECK(value.Get(output)); + DALI_TEST_EQUALS(output.empty(), true, TEST_LOCATION); + + std::vector data2; + EncodeBase64PropertyData(value, data2); + + DALI_TEST_CHECK(value.Get(output)); + DALI_TEST_EQUALS(output.empty(), true, TEST_LOCATION); END_TEST; } -template -int b64l(std::vector&data) +template +int b64l(std::vector& data) { - auto lengthInBytes = 4*data.size(); - return ceil( lengthInBytes * 1.33333f ); + auto lengthInBytes = sizeof(T) * data.size(); + // base64 encode each 3-byte as 4-byte. + // return ceil(lengthInBytes / 3) * 4 + return (lengthInBytes + 2) / 3 * 4; } int UtcDaliBase64EncodingP02(void) { - tet_infoline( "Test encoding vectors of lengths m .. m+4 encode and decode back to the same length vectors" ); + tet_infoline("Test encoding vectors of lengths m .. m+4 encode and decode back to the same length vectors"); std::vector testData; - for(int i=0; i<8; ++i ) // 8 chosen to stay within single string output + for(int i = 0; i < 8; ++i) // 8 chosen to stay within single string output { testData.push_back(i); } Property::Value value; - EncodeBase64PropertyData( value, testData ); + EncodeBase64PropertyData(value, testData); std::string output; - DALI_TEST_CHECK( value.Get( output ) ); - DALI_TEST_EQUALS( output.empty(), false, TEST_LOCATION); - DALI_TEST_EQUALS( output.length(), b64l(testData), TEST_LOCATION ); + DALI_TEST_CHECK(value.Get(output)); + DALI_TEST_EQUALS(output.empty(), false, TEST_LOCATION); + DALI_TEST_EQUALS(output.length(), b64l(testData), TEST_LOCATION); std::vector outData; - DecodeBase64PropertyData( value, outData ); - DALI_TEST_EQUALS( testData.size(), outData.size(), TEST_LOCATION ); - DALI_TEST_EQUALS( std::equal( testData.begin(), testData.end(), outData.begin()), true, TEST_LOCATION ); + DecodeBase64PropertyData(value, outData); + DALI_TEST_EQUALS(testData.size(), outData.size(), TEST_LOCATION); + DALI_TEST_EQUALS(std::equal(testData.begin(), testData.end(), outData.begin()), true, TEST_LOCATION); // n+1 - testData.push_back( 12345 ); - EncodeBase64PropertyData( value, testData ); + testData.push_back(12345); + EncodeBase64PropertyData(value, testData); - DALI_TEST_CHECK( value.Get( output ) ); - DALI_TEST_EQUALS( output.empty(), false, TEST_LOCATION); - DALI_TEST_EQUALS( output.length(), b64l(testData), TEST_LOCATION ); + DALI_TEST_CHECK(value.Get(output)); + DALI_TEST_EQUALS(output.empty(), false, TEST_LOCATION); + DALI_TEST_EQUALS(output.length(), b64l(testData), TEST_LOCATION); outData.clear(); - DecodeBase64PropertyData( value, outData ); - DALI_TEST_EQUALS( testData.size(), outData.size(), TEST_LOCATION ); - DALI_TEST_EQUALS( std::equal( testData.begin(), testData.end(), outData.begin()), true, TEST_LOCATION ); + DecodeBase64PropertyData(value, outData); + DALI_TEST_EQUALS(testData.size(), outData.size(), TEST_LOCATION); + DALI_TEST_EQUALS(std::equal(testData.begin(), testData.end(), outData.begin()), true, TEST_LOCATION); // n+2 - testData.push_back( 67890 ); - EncodeBase64PropertyData( value, testData ); + testData.push_back(67890); + EncodeBase64PropertyData(value, testData); - DALI_TEST_CHECK( value.Get( output ) ); - DALI_TEST_EQUALS( output.empty(), false, TEST_LOCATION); - DALI_TEST_EQUALS( output.length(), b64l(testData), TEST_LOCATION ); + DALI_TEST_CHECK(value.Get(output)); + DALI_TEST_EQUALS(output.empty(), false, TEST_LOCATION); + DALI_TEST_EQUALS(output.length(), b64l(testData), TEST_LOCATION); outData.clear(); - DecodeBase64PropertyData( value, outData ); - DALI_TEST_EQUALS( testData.size(), outData.size(), TEST_LOCATION ); - DALI_TEST_EQUALS( std::equal( testData.begin(), testData.end(), outData.begin()), true, TEST_LOCATION ); + DecodeBase64PropertyData(value, outData); + DALI_TEST_EQUALS(testData.size(), outData.size(), TEST_LOCATION); + DALI_TEST_EQUALS(std::equal(testData.begin(), testData.end(), outData.begin()), true, TEST_LOCATION); // n+3 - testData.push_back( -1 ); - EncodeBase64PropertyData( value, testData ); + testData.push_back(-1); + EncodeBase64PropertyData(value, testData); - DALI_TEST_CHECK( value.Get( output ) ); - DALI_TEST_EQUALS( output.empty(), false, TEST_LOCATION); - DALI_TEST_EQUALS( output.length(), b64l(testData), TEST_LOCATION ); + DALI_TEST_CHECK(value.Get(output)); + DALI_TEST_EQUALS(output.empty(), false, TEST_LOCATION); + DALI_TEST_EQUALS(output.length(), b64l(testData), TEST_LOCATION); outData.clear(); - DecodeBase64PropertyData( value, outData ); - DALI_TEST_EQUALS( testData.size(), outData.size(), TEST_LOCATION ); - DALI_TEST_EQUALS( std::equal( testData.begin(), testData.end(), outData.begin()), true, TEST_LOCATION ); - + DecodeBase64PropertyData(value, outData); + DALI_TEST_EQUALS(testData.size(), outData.size(), TEST_LOCATION); + DALI_TEST_EQUALS(std::equal(testData.begin(), testData.end(), outData.begin()), true, TEST_LOCATION); END_TEST; } - int UtcDaliBase64EncodingP03(void) { - tet_infoline( "Test encoding a vector of length 12 has output within single string" ); + tet_infoline("Test encoding a vector of length 12 has output within single string"); std::vector testData; - for(int i=0; i<12; ++i ) + for(int i = 0; i < 12; ++i) { testData.push_back(i); } Property::Value value; - EncodeBase64PropertyData( value, testData ); + EncodeBase64PropertyData(value, testData); std::string output; - DALI_TEST_CHECK( value.Get( output ) ); - DALI_TEST_EQUALS( output.empty(), false, TEST_LOCATION); - DALI_TEST_EQUALS( output.length(), b64l(testData), TEST_LOCATION ); + DALI_TEST_CHECK(value.Get(output)); + DALI_TEST_EQUALS(output.empty(), false, TEST_LOCATION); + DALI_TEST_EQUALS(output.length(), b64l(testData), TEST_LOCATION); std::vector outData; - DecodeBase64PropertyData( value, outData ); - DALI_TEST_EQUALS( testData.size(), outData.size(), TEST_LOCATION ); + DecodeBase64PropertyData(value, outData); + DALI_TEST_EQUALS(testData.size(), outData.size(), TEST_LOCATION); END_TEST; } - int UtcDaliBase64EncodingP04(void) { - tet_infoline( "Test encoding a vector of length 13 has output split over 2 strings" ); + tet_infoline("Test encoding a vector of length 13 has output split over 2 strings"); std::vector testData; - for(int i=0; i<13; ++i ) + for(int i = 0; i < 13; ++i) { testData.push_back(i); } Property::Value value; - EncodeBase64PropertyData( value, testData ); + EncodeBase64PropertyData(value, testData); auto array = value.GetArray(); - DALI_TEST_CHECK( array ); + DALI_TEST_CHECK(array); - DALI_TEST_EQUALS( array->Count(), 2, TEST_LOCATION ); + DALI_TEST_EQUALS(array->Count(), 2, TEST_LOCATION); std::vector outData; - DecodeBase64PropertyData( value, outData ); - DALI_TEST_EQUALS( testData.size(), outData.size(), TEST_LOCATION ); + DecodeBase64PropertyData(value, outData); + DALI_TEST_EQUALS(testData.size(), outData.size(), TEST_LOCATION); END_TEST; } - int UtcDaliBase64EncodingP05(void) { - tet_infoline( "Test encoding a vector of length 24 has output split over 2 strings" ); + tet_infoline("Test encoding a vector of length 24 has output split over 2 strings"); std::vector testData; - for(int i=0; i<24; ++i ) + for(int i = 0; i < 24; ++i) { testData.push_back(i); } Property::Value value; - EncodeBase64PropertyData( value, testData ); + EncodeBase64PropertyData(value, testData); auto array = value.GetArray(); - DALI_TEST_CHECK( array ); + DALI_TEST_CHECK(array); - DALI_TEST_EQUALS( array->Count(), 2, TEST_LOCATION ); + DALI_TEST_EQUALS(array->Count(), 2, TEST_LOCATION); std::vector outData; - DecodeBase64PropertyData( value, outData ); - DALI_TEST_EQUALS( testData.size(), outData.size(), TEST_LOCATION ); + DecodeBase64PropertyData(value, outData); + DALI_TEST_EQUALS(testData.size(), outData.size(), TEST_LOCATION); END_TEST; } - int UtcDaliBase64EncodingP06(void) { - tet_infoline( "Test encoding a vector of arbitrary length decodes OK." ); + tet_infoline("Test encoding a vector of arbitrary length decodes OK."); std::vector testData; - for(int i=0; i<97; ++i ) + for(int i = 0; i < 97; ++i) { testData.push_back(i); } Property::Value value; - EncodeBase64PropertyData( value, testData ); + EncodeBase64PropertyData(value, testData); auto array = value.GetArray(); - DALI_TEST_CHECK( array ); + DALI_TEST_CHECK(array); std::vector outData; - DecodeBase64PropertyData( value, outData ); - DALI_TEST_EQUALS( testData.size(), outData.size(), TEST_LOCATION ); + DecodeBase64PropertyData(value, outData); + DALI_TEST_EQUALS(testData.size(), outData.size(), TEST_LOCATION); END_TEST; } - int UtcDaliBase64DecodingN01(void) { - tet_infoline( "Test decoding empty string results in empty data" ); + tet_infoline("Test decoding empty string results in empty data"); - Property::Value value(""); + Property::Value value(""); std::vector outputData; - DecodeBase64PropertyData( value, outputData); - DALI_TEST_EQUALS( outputData.size(), 0, TEST_LOCATION ); + DecodeBase64PropertyData(value, outputData); + DALI_TEST_EQUALS(outputData.size(), 0, TEST_LOCATION); + + std::vector outputData2; + DecodeBase64PropertyData(value, outputData2); + DALI_TEST_EQUALS(outputData2.size(), 0, TEST_LOCATION); END_TEST; } - int UtcDaliBase64DecodingN02(void) { - tet_infoline( "Test decoding array with non-string values results in empty data" ); + tet_infoline("Test decoding array with non-string values results in empty data"); Property::Array array; array.Resize(2); @@ -2008,23 +2057,56 @@ int UtcDaliBase64DecodingN02(void) Property::Value value(array); std::vector outputData; - DecodeBase64PropertyData( value, outputData); - DALI_TEST_EQUALS( outputData.size(), 0, TEST_LOCATION ); + DecodeBase64PropertyData(value, outputData); + DALI_TEST_EQUALS(outputData.size(), 0, TEST_LOCATION); + + std::vector outputData2; + DecodeBase64PropertyData(value, outputData2); + DALI_TEST_EQUALS(outputData2.size(), 0, TEST_LOCATION); END_TEST; } int UtcDaliBase64DecodingP01(void) { - tet_infoline( "Test decoding string of known data gives expected result"); + tet_infoline("Test decoding string of known data gives expected result"); - std::string testInput("//////7+/v4DAgEA"); - std::vector expectedResults = { 0xffffffff, 0xfefefefe, 0x00010203 }; + std::string testInput("//////7+/v4DAgEA"); + std::vector expectedResults = {0xffffffff, 0xfefefefe, 0x00010203}; std::vector outputData; DecodeBase64PropertyData(Property::Value(testInput), outputData); - DALI_TEST_EQUALS( std::equal( expectedResults.begin(), expectedResults.end(), outputData.begin() ), true, - TEST_LOCATION ); + DALI_TEST_EQUALS(std::equal(expectedResults.begin(), expectedResults.end(), outputData.begin()), true, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliBase64DecodingP02(void) +{ + tet_infoline("Test decoding string of known data gives expected result"); + + std::string testInput("//////7+/v4DAgEA"); + std::vector expectedResults = {0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xfe, 0x03, 0x02, 0x01, 0x00}; + + std::vector outputData; + DecodeBase64PropertyData(Property::Value(testInput), outputData); + + DALI_TEST_EQUALS(std::equal(expectedResults.begin(), expectedResults.end(), outputData.begin()), true, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliBase64DecodingFromString(void) +{ + tet_infoline("Test decoding string of known data gives expected result"); + + std::string testInput("//////7+/v4DAgEA"); + std::vector expectedResults = {0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xfe, 0x03, 0x02, 0x01, 0x00}; + + std::vector outputData; + DecodeBase64FromString(testInput, outputData); + + DALI_TEST_EQUALS(std::equal(expectedResults.begin(), expectedResults.end(), outputData.begin()), true, TEST_LOCATION); END_TEST; }