2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <dali-toolkit-test-suite-utils.h>
25 #include <dali-toolkit/devel-api/builder/builder.h>
26 #include <dali-toolkit/devel-api/builder/base64-encoding.h>
27 #include <dali/integration-api/events/touch-event-integ.h>
28 #include <dali-toolkit/dali-toolkit.h>
29 #include <test-button.h>
30 #include <test-animation-data.h>
33 #define STRINGIFY(A)#A
36 using namespace Toolkit;
38 namespace BuilderControlProperty
43 INTEGER_PROPERTY = Toolkit::Control::CONTROL_PROPERTY_END_INDEX + 1,
54 return Toolkit::Control::New();
57 int gSetPropertyCalledCount = 0;
59 void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
61 ++gSetPropertyCalledCount;
64 Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex )
66 return Property::Value();
69 } // unnamed namespace
72 Dali::TypeRegistration typeRegistration( "BuilderControl", typeid( Toolkit::Control ), Create );
74 Dali::PropertyRegistration propertyInteger( typeRegistration, "integerProperty", INTEGER_PROPERTY, Property::INTEGER, &SetProperty, &GetProperty );
75 Dali::PropertyRegistration propertyMatrix3( typeRegistration, "matrix3Property", MATRIX3_PROPERTY, Property::MATRIX3, &SetProperty, &GetProperty );
76 Dali::PropertyRegistration propertyMatrix( typeRegistration, "matrixProperty", MATRIX_PROPERTY, Property::MATRIX, &SetProperty, &GetProperty );
77 Dali::PropertyRegistration propertyNone( typeRegistration, "noneProperty", NONE_PROPERTY, Property::NONE, &SetProperty, &GetProperty );
86 BuilderFunctor( bool& called ) : mCalled( called )
103 void builder_startup(void)
105 test_return_value = TET_UNDEF;
108 void builder_cleanup(void)
110 test_return_value = TET_PASS;
113 int UtcDaliBuilderQuitSignal(void)
115 ToolkitTestApplication application;
117 // JSON with a quit event when the actor is touched
122 "\"type\": \"Layer\","
123 "\"size\": [100,100,1],"
124 "\"parentOrigin\": \"TOP_LEFT\","
125 "\"anchorPoint\": \"TOP_LEFT\","
126 "\"maximumSize\": [100,100],"
127 "\"orientation\": [10,10,10,10],"
128 "\"clippingBox\": [10,10,10,10],"
130 "\"name\": \"touch\","
131 "\"action\": \"quit\""
136 Builder builder = Builder::New();
137 builder.LoadFromString( json );
138 builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
140 // Connect to builder's quit signal
141 bool functorCalled( false );
142 builder.QuitSignal().Connect( &application, BuilderFunctor( functorCalled ) );
145 application.SendNotification();
146 application.Render();
148 // Emit touch event and check that our quit method is called
149 Integration::TouchEvent touchEvent;
150 Integration::Point point;
151 point.SetState( PointState::DOWN );
152 point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
153 touchEvent.points.push_back( point );
154 application.ProcessEvent( touchEvent );
155 DALI_TEST_CHECK( functorCalled );
161 int UtcDaliBuilderAnimationP(void)
163 ToolkitTestApplication application;
165 // JSON with a quit event when the actor is touched
170 " \"ALPHA_FUNCTION\":\"EASE_IN_OUT\""
176 " \"points\":[ [-150, -50, 0], [0.0,70.0,0.0], [190.0,-150.0,0.0] ],"
177 " \"curvature\":0.35"
183 " \"endAction\": \"BAKE\","
184 " \"disconnectAction\": \"BAKE\","
187 " \"actor\": \"greeting\","
188 " \"property\": \"position\","
189 " \"value\": [300, 300, -1000],"
190 " \"alphaFunction\": \"{ALPHA_FUNCTION}\","
191 " \"relative\": true,"
198 " \"actor\": \"greeting\","
199 " \"property\": \"visible\","
200 " \"alphaFunction\": \"LINEAR\","
204 " \"actor\": \"greeting\","
205 " \"property\": \"sizeWidth\","
206 " \"alphaFunction\": \"REVERSE\","
210 " \"actor\": \"greeting\","
211 " \"property\": \"orientation\","
212 " \"alphaFunction\": \"EASE_IN\","
213 " \"value\": [10.0,20.0,30.0]"
216 " \"actor\": \"greeting\","
217 " \"property\": \"orientation\","
218 " \"alphaFunction\": \"EASE_OUT\","
219 " \"value\": [0.0, 0.0, 0.0, 1.0]"
222 " \"actor\": \"greeting\","
223 " \"property\": \"orientation\","
224 " \"alphaFunction\": \"EASE_IN_OUT\","
225 " \"value\": [0.0, 0.0, 0.0, 1.0]"
228 " \"actor\": \"greeting\","
229 " \"property\": \"orientation\","
230 " \"alphaFunction\": \"EASE_IN_SINE\","
231 " \"value\": [0.0, 0.0, 0.0, 1.0]"
234 " \"actor\": \"greeting\","
235 " \"property\": \"orientation\","
236 " \"alphaFunction\": \"EASE_OUT_SINE\","
237 " \"value\": [0.0, 0.0, 0.0, 1.0]"
240 " \"actor\": \"greeting\","
241 " \"property\": \"orientation\","
242 " \"alphaFunction\": \"EASE_IN_OUT_SINE\","
243 " \"value\": [0.0, 0.0, 0.0, 1.0]"
246 " \"actor\": \"greeting\","
247 " \"property\": \"orientation\","
248 " \"alphaFunction\": \"BOUNCE\","
249 " \"value\": [0.0, 0.0, 0.0, 1.0]"
252 " \"actor\": \"greeting\","
253 " \"property\": \"orientation\","
254 " \"alphaFunction\": \"SIN\","
255 " \"value\": [0.0, 0.0, 0.0, 1.0]"
258 " \"actor\": \"greeting\","
259 " \"property\": \"orientation\","
260 " \"alphaFunction\": \"EASE_OUT_BACK\","
261 " \"value\": [0.0, 0.0, 0.0, 1.0]"
265 " \"pathAnimation\": {"
266 " \"duration\": 3.0,"
267 " \"endAction\": \"DISCARD\","
268 " \"disconnectAction\": \"BAKE_FINAL\","
269 " \"properties\": [{"
270 " \"actor\": \"greeting\","
271 " \"path\":\"path0\","
272 " \"forward\":[1,0,0],"
273 " \"alphaFunction\": \"EASE_IN_OUT\","
282 " \"name\": \"greeting\","
283 " \"type\": \"TextLabel\","
284 " \"text\": \"Touch me\","
285 " \"inherit\": [\"basicText\"],"
286 " \"position\": [0, -120, 0],"
287 " \"size\": [200, 200, 1],"
288 " \"orientation\": [0, 0, 30],"
290 " \"name\": \"touch\","
291 " \"action\": \"play\","
292 " \"animation\": \"animate\""
297 Builder builder = Builder::New();
298 builder.LoadFromString( json );
299 builder.AddActors( Stage::GetCurrent().GetRootLayer() );
301 Animation anim = builder.CreateAnimation("animate");
303 DALI_TEST_CHECK( anim );
306 map["ALPHA_FUNCTION"] = "EASE_IN_SQUARE";
307 anim = builder.CreateAnimation("animate", map);
309 DALI_TEST_CHECK( anim );
311 anim = builder.CreateAnimation("pathAnimation");
313 DALI_TEST_CHECK( anim );
316 // Emit touch event and check that our quit method is called
317 Integration::TouchEvent touchEvent;
318 Integration::Point point;
319 point.SetState( PointState::DOWN );
320 point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
321 touchEvent.points.push_back( point );
322 application.ProcessEvent( touchEvent );
325 application.SendNotification();
326 application.Render();
332 int UtcDaliBuilderAnimationN(void)
334 ToolkitTestApplication application;
336 // JSON with a quit event when the actor is touched
341 " \"TEXT\": \"Touch Me\","
342 " \"NAME\": \"greeting\" "
348 " \"points\":[ [-150, -50, 0], [0.0,70.0,0.0], [190.0,-150.0,0.0] ],"
349 " \"curvature\":0.35"
355 " \"endAction\": \"BAKE\","
356 " \"disconnectAction\": \"BAKE\","
359 " \"actor\": \"{NAME}\","
360 " \"property\": \"positioninvalid\","
361 " \"value\": [300, 300, -1000],"
362 " \"alphaFunction\": \"EASE_IN_OUT\","
363 " \"relative\": true,"
373 " \"endAction\": \"BAKE\","
374 " \"disconnectAction\": \"BAKE\","
377 " \"actor\": \"{NAME}\","
378 " \"property\": \"positioninvalid\","
379 " \"value\": [300, 300, -1000],"
380 " \"alphaFunction\": \"EGGS_OVER_EASY\","
381 " \"relative\": true,"
389 " \"pathAnimation\": {"
390 " \"duration\": 3.0,"
391 " \"endAction\": \"DISCARD\","
392 " \"disconnectAction\": \"BAKE_FINAL\","
393 " \"properties\": [{"
394 " \"actor\": \"greeting\","
395 " \"path\":\"pathDoesntExist\","
396 " \"forward\":[1,0,0],"
397 " \"alphaFunction\": \"EASE_IN_OUT\","
406 " \"name\": \"greeting\","
407 " \"type\": \"TextLabel\","
408 " \"text\": \"Touch me\","
409 " \"inherit\": [\"basicText\"],"
410 " \"position\": [0, -120, 0],"
411 " \"size\": [200, 200, 1],"
412 " \"orientation\": [0, 0, 30],"
414 " \"name\": \"touch\","
415 " \"action\": \"play\","
416 " \"animation\": \"animate\""
420 " \"name\": \"greeting2\","
421 " \"type\": \"TextLabel\","
422 " \"text\": \"Touch me\""
427 Builder builder = Builder::New();
428 builder.LoadFromString( json );
429 builder.AddActors( Stage::GetCurrent().GetRootLayer() );
431 Animation anim = builder.CreateAnimation("animate");
433 // log warning line coverage
434 anim = builder.CreateAnimation("pathAnimation");
435 DALI_TEST_CHECK(anim);
437 anim = builder.CreateAnimation("animate");
438 DALI_TEST_CHECK(anim);
440 anim = builder.CreateAnimation("animate2");
441 DALI_TEST_CHECK(anim);
443 // create referencing a different actor aka animation templates
445 map["NAME"] = "greeting2";
446 anim = builder.CreateAnimation("animate2", map);
447 DALI_TEST_CHECK(anim);
449 // alternative actor to use for FindChildByName
450 anim = builder.CreateAnimation("animate2", Dali::Stage::GetCurrent().GetRootLayer());
451 DALI_TEST_CHECK(anim);
453 // alternative actor to use for FindChildByName
454 anim = builder.CreateAnimation("animate2", map, Dali::Stage::GetCurrent().GetRootLayer());
455 DALI_TEST_CHECK(anim);
462 int UtcDaliBuilderConstantsP(void)
464 ToolkitTestApplication application;
466 // JSON with a quit event when the actor is touched
471 " \"IMAGE_PATH\": \"apath\","
473 " \"ANCHOR\": \"TOP_LEFT\","
474 " \"PADDING\": [1,2,3,4]"
478 " \"type\": \"ImageView\","
479 " \"name\": \"{NAME}\","
480 " \"size\": [100,100,1],"
481 " \"parentOrigin\": \"TOP_LEFT\","
482 " \"anchorPoint\": \"{ANCHOR}\","
483 " \"padding\": \"{PADDING}\","
484 " \"image\": { \"url\": \"dir/{IMAGE_PATH}\" },"
485 " \"sizeWidth\": \"{WIDTH}\","
487 " \"name\": \"touch\","
488 " \"action\": \"quit\""
494 Builder builder = Builder::New();
495 builder.LoadFromString( json );
497 builder.AddConstant( "NAME", "image" );
499 Property::Map map = builder.GetConstants();
501 Dali::Property::Value* pValue = map.Find( "NAME" );
503 DALI_TEST_CHECK( pValue );
505 pValue = map.Find( "IMAGE_PATH" );
507 DALI_TEST_CHECK( pValue );
509 Dali::Property::Value value = builder.GetConstant( "WIDTH" );
511 DALI_TEST_CHECK( value.GetType() != Property::NONE );
513 builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
514 DALI_TEST_CHECK( builder );
516 Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("image");
517 DALI_TEST_CHECK( actor );
522 int UtcDaliBuilderTemplatesAndStylesP(void)
524 ToolkitTestApplication application;
526 // JSON with a quit event when the actor is touched
531 " \"SIZE\": [10,20,30]"
535 " \"imageStyle\": \n"
537 " \"color\": [1,0,0,1],\n"
539 " \"childImage\": {\n"
540 " \"color\": \"34\"\n"
547 " \"imageViewTemplate\": { \n"
548 " \"type\": \"ImageView\",\n"
549 " \"styles\": [\"imageStyle\"]\n"
551 " \"imageTree\": { \n"
552 " \"type\": \"ImageView\",\n"
553 " \"styles\": [\"imageStyle\"],\n"
554 " \"name\": \"image\",\n"
555 " \"size\": \"{SIZE}\",\n"
557 " \"name\": \"touch\",\n"
558 " \"action\": \"quit\"\n"
562 " \"type\":\"ImageView\",\n"
563 " \"name\":\"childImage\", \n"
573 " \"type\":\"imageViewTemplate\",\n"
574 " \"name\":\"childImage2\"\n"
581 " \"type\": \"imageTree\","
582 " \"size\": [100,100,1]"
587 std::string stylejson(
589 " \"color\": [1,0,0,1],\n"
591 " \"childImage\": {\n"
592 " \"color\": \"#344353\"\n"
598 std::string templatejson(
600 " \"type\": \"ImageView\",\n"
601 " \"styles\": [\"imageStyle\"],\n"
602 " \"name\": \"image\",\n"
603 " \"size\": \"{SIZE}\",\n"
605 " \"name\": \"touch\",\n"
606 " \"action\": \"quit\"\n"
610 " \"type\":\"ImageView\",\n"
611 " \"name\":\"childImage\" \n"
617 Builder builder = Builder::New();
618 builder.LoadFromString( json );
620 ImageView actor = ImageView::DownCast( builder.Create( "imageTree" ) );
621 DALI_TEST_CHECK( actor );
623 Dali::Property::Map map;
624 map["SIZE"] = Vector3(100,100,1);
625 actor = ImageView::DownCast( builder.Create( "imageTree", map ) );
626 DALI_TEST_CHECK( actor );
628 // create from json snippet
629 actor = ImageView::DownCast( builder.CreateFromJson( templatejson ) );
630 DALI_TEST_CHECK( actor );
633 // NB: already applied in create
634 DALI_TEST_CHECK( builder.ApplyStyle( "imageStyle", actor ) );
636 // apply from json snippet
637 DALI_TEST_CHECK( builder.ApplyFromJson( actor, stylejson ) );
642 int UtcDaliBuilderRenderTasksP(void)
644 ToolkitTestApplication application;
646 // JSON with a quit event when the actor is touched
652 " \"sourceActor\": \"image\",\n"
653 " \"cameraActor\": \"camera\" \n"
659 " \"type\": \"CameraActor\",\n"
660 " \"name\": \"camera\"\n"
663 " \"type\": \"ImageView\",\n"
664 " \"name\": \"image\",\n"
665 " \"size\": [100,100,1],\n"
667 " \"name\": \"touch\",\n"
668 " \"action\": \"quit\"\n"
672 " \"type\":\"ImageView\",\n"
673 " \"name\":\"childImage\" \n"
681 Builder builder = Builder::New();
682 builder.LoadFromString( json );
684 unsigned int count = Stage::GetCurrent().GetRenderTaskList().GetTaskCount();
687 builder.CreateRenderTask( "task0" );
689 DALI_TEST_CHECK( count <
690 Stage::GetCurrent().GetRenderTaskList().GetTaskCount() );
695 int UtcDaliBuilderChildActionP(void)
697 ToolkitTestApplication application;
699 // JSON with a quit event when the actor is touched
704 " \"type\": \"Actor\",\n"
705 " \"name\": \"actor\",\n"
706 " \"size\": [100,100,1],\n"
707 " \"parentOrigin\": \"TOP_LEFT\",\n"
708 " \"anchorPoint\": \"TOP_LEFT\",\n"
710 " \"type\": \"Actor\",\n"
711 " \"name\": \"subActor\"\n"
714 " \"name\": \"touch\",\n"
715 " \"action\": \"hide\",\n"
716 " \"actor\": \"actor\",\n"
717 " \"childActor\": \"subActor\"\n"
723 Builder builder = Builder::New();
724 builder.LoadFromString( json );
725 builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
728 application.SendNotification();
729 application.Render();
731 // Emit touch event and check that our quit method is called
732 Integration::TouchEvent touchEvent;
733 Integration::Point point;
734 point.SetState( PointState::DOWN );
735 point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
736 touchEvent.points.push_back( point );
737 application.ProcessEvent( touchEvent );
740 application.SendNotification();
741 application.Render();
743 Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("subActor");
744 DALI_TEST_CHECK( actor );
746 DALI_TEST_CHECK( !actor.IsVisible() );
751 int UtcDaliBuilderSetPropertyActionP(void)
753 ToolkitTestApplication application;
755 // JSON with a quit event when the actor is touched
760 " \"type\": \"Actor\",\n"
761 " \"name\": \"actor\",\n"
762 " \"size\": [100,100,1],\n"
763 " \"parentOrigin\": \"TOP_LEFT\",\n"
764 " \"anchorPoint\": \"TOP_LEFT\",\n"
766 " \"type\": \"Actor\",\n"
767 " \"name\": \"subActor\"\n"
770 " \"name\": \"touch\",\n"
771 " \"action\": \"set\",\n"
772 " \"actor\": \"subActor\",\n"
773 " \"property\": \"visible\",\n"
774 " \"value\": false\n"
780 Builder builder = Builder::New();
781 builder.LoadFromString( json );
782 builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
785 application.SendNotification();
786 application.Render();
788 // Emit touch event and check that our quit method is called
789 Integration::TouchEvent touchEvent;
790 Integration::Point point;
791 point.SetState( PointState::DOWN );
792 point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
793 touchEvent.points.push_back( point );
794 application.ProcessEvent( touchEvent );
797 application.SendNotification();
798 application.Render();
800 Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("subActor");
801 DALI_TEST_CHECK( actor );
803 DALI_TEST_CHECK( !actor.IsVisible() );
808 int UtcDaliBuilderGenericActionP(void)
810 ToolkitTestApplication application;
812 // JSON with a quit event when the actor is touched
817 " \"type\": \"Actor\",\n"
818 " \"name\": \"actor\",\n"
819 " \"size\": [100,100,1],\n"
820 " \"parentOrigin\": \"TOP_LEFT\",\n"
821 " \"anchorPoint\": \"TOP_LEFT\",\n"
823 " \"type\": \"Actor\",\n"
824 " \"name\": \"subActor\"\n"
827 " \"name\": \"touch\",\n"
828 " \"action\": \"hide\"\n"
834 Builder builder = Builder::New();
835 builder.LoadFromString( json );
836 builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
839 application.SendNotification();
840 application.Render();
842 // Emit touch event and check that our quit method is called
843 Integration::TouchEvent touchEvent;
844 Integration::Point point;
845 point.SetState( PointState::DOWN );
846 point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
847 touchEvent.points.push_back( point );
848 application.ProcessEvent( touchEvent );
851 application.SendNotification();
852 application.Render();
854 Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("actor");
855 DALI_TEST_CHECK( actor );
857 DALI_TEST_CHECK( !actor.IsVisible() );
862 int UtcDaliBuilderPropertyNotificationP(void)
864 ToolkitTestApplication application;
866 // JSON with a quit event when the actor is touched
871 " \"type\": \"Actor\",\n"
872 " \"name\": \"actor\",\n"
873 " \"size\": [100,100,1],\n"
874 " \"parentOrigin\": \"TOP_LEFT\",\n"
875 " \"anchorPoint\": \"TOP_LEFT\",\n"
877 " \"type\": \"Actor\",\n"
878 " \"name\": \"subActor\"\n"
881 " \"name\": \"touch\",\n"
882 " \"action\": \"hide\"\n"
884 " \"notifications\": [{\n"
885 " \"property\": \"visible\",\n"
886 " \"condition\": \"False\",\n"
887 " \"action\": \"show\"\n"
890 " \"property\": \"positionX\",\n"
891 " \"condition\": \"LessThan\",\n"
893 " \"action\": \"show\"\n"
896 " \"property\": \"positionY\",\n"
897 " \"condition\": \"GreaterThan\",\n"
898 " \"arg0\": 200.0,\n"
899 " \"action\": \"show\"\n"
902 " \"property\": \"positionZ\",\n"
903 " \"condition\": \"Inside\",\n"
906 " \"action\": \"show\"\n"
909 " \"property\": \"positionZ\",\n"
910 " \"condition\": \"Outside\",\n"
913 " \"action\": \"show\"\n"
919 Builder builder = Builder::New();
920 builder.LoadFromString( json );
921 builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
924 application.SendNotification();
925 application.Render();
927 // Emit touch event and check that our quit method is called
928 Integration::TouchEvent touchEvent;
929 Integration::Point point;
930 point.SetState( PointState::DOWN );
931 point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
932 touchEvent.points.push_back( point );
933 application.ProcessEvent( touchEvent );
936 application.SendNotification();
937 application.Render();
940 application.SendNotification();
941 application.Render();
943 Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("actor");
944 DALI_TEST_CHECK( actor );
946 DALI_TEST_CHECK( actor.IsVisible() );
951 int UtcDaliBuilderPropertyNotificationN(void)
953 ToolkitTestApplication application;
955 // JSON with a quit event when the actor is touched
960 " \"type\": \"Actor\",\n"
961 " \"notifications\": [{\n"
962 " \"property\": \"visible\",\n"
963 " \"condition\": \"ErrorCondition\",\n"
964 " \"action\": \"show\"\n"
972 Builder builder = Builder::New();
973 builder.LoadFromString( json );
974 builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
975 DALI_TEST_CHECK( false );
979 DALI_TEST_CHECK( true );
987 int UtcDaliBuilderCustomPropertyP(void)
989 ToolkitTestApplication application;
991 // JSON with a quit event when the actor is touched
996 " \"imageTree\": { \n"
997 " \"type\": \"ImageView\",\n"
998 " \"name\": \"image\",\n"
999 " \"size\": [100,100,1],\n"
1000 " \"signals\": [{\n"
1001 " \"name\": \"touch\",\n"
1002 " \"action\": \"quit\"\n"
1004 " \"properties\": {\n"
1005 " \"newproperty\": true\n"
1007 " \"animatableProperties\": {\n"
1008 " \"newAnimatableproperty\": 3\n"
1012 " \"type\":\"ImageView\",\n"
1013 " \"name\":\"childImage\" \n"
1021 Builder builder = Builder::New();
1022 builder.LoadFromString( json );
1024 ImageView actor = ImageView::DownCast( builder.Create( "imageTree" ) );
1025 DALI_TEST_CHECK( actor );
1027 // NB: already applied in create
1028 Property::Index index = actor.GetPropertyIndex("newproperty");
1029 DALI_TEST_CHECK( Property::INVALID_INDEX != index );
1030 Property::Value value = actor.GetProperty(index);
1031 DALI_TEST_CHECK( value.Get<bool>() == true );
1033 index = actor.GetPropertyIndex("newAnimatableproperty");
1034 DALI_TEST_CHECK( Property::INVALID_INDEX != index );
1035 value = actor.GetProperty(index);
1036 DALI_TEST_CHECK( value.Get<int>() == 3 );
1041 int UtcDaliBuilderCustomShaderP(void)
1043 ToolkitTestApplication application;
1045 // JSON with a quit event when the actor is touched
1050 " \"type\": \"ImageView\",\n"
1051 " \"name\": \"Image1\",\n"
1052 " \"position\": [\n"
1053 " 0.40461349487305,\n"
1057 " \"parentOrigin\": [0.5, 0.5, 0.5],\n"
1058 " \"size\": [200, 200, 0],\n"
1059 " \"effect\": \"Ripple2D\",\n"
1061 " \"url\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\",\n"
1062 " \"desiredWidth\": 200,\n"
1063 " \"desiredHeight\": 80,\n"
1065 " \"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"
1068 " \"customAnimatableProperties\": {\n"
1069 " \"uAmplitude\": 0.02,\n"
1074 " \"name\": \"onStage\",\n"
1075 " \"action\": \"play\",\n"
1076 " \"animation\": \"Animation_1\"\n"
1081 " \"animations\": {\n"
1082 " \"Animation_1\": {\n"
1084 " \"properties\": [\n"
1086 " \"actor\": \"Image1\",\n"
1087 " \"property\": \"uTime\",\n"
1088 " \"value\": 10.0,\n"
1089 " \"alphaFunction\": \"LINEAR\",\n"
1090 " \"timePeriod\": {\n"
1092 " \"duration\": 10.0\n"
1102 Builder builder = Builder::New();
1103 builder.LoadFromString( json );
1105 builder.AddActors ( "stage", Stage::GetCurrent().GetRootLayer() );
1107 // Render and notify
1108 application.SendNotification();
1109 application.Render();
1111 Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("Image1");
1114 DALI_TEST_CHECK( actor );
1120 int UtcDaliBuilderLoadFromStringN(void)
1122 ToolkitTestApplication application;
1124 // JSON with a quit event when the actor is touched
1126 "asdfsadf dsf asdf asdf {"
1129 "\"type\": \"Actor\","
1130 "\"size\": [100,100,1],"
1131 "\"parentOrigin\": \"TOP_LEFT\","
1132 "\"anchorPoint\": \"TOP_LEFT\","
1134 "\"name\": \"touch\","
1135 "\"action\": \"quit\""
1140 Builder builder = Builder::New();
1142 bool assert1 = false;
1146 builder.LoadFromString( json );
1148 catch( Dali::DaliException& e )
1150 DALI_TEST_PRINT_ASSERT( e );
1151 DALI_TEST_EQUALS(e.condition, "!\"Cannot parse JSON\"", TEST_LOCATION);
1155 DALI_TEST_CHECK( assert1 );
1161 int UtcDaliBuilderAddActorsP(void)
1163 ToolkitTestApplication application;
1165 // JSON with a quit event when the actor is touched
1168 " \"arbitarysection\":\n"
1170 " \"type\": \"Actor\",\n"
1171 " \"name\": \"actor\",\n"
1172 " \"size\": [100,100,1],\n"
1173 " \"parentOrigin\": \"TOP_LEFT\",\n"
1174 " \"anchorPoint\": \"TOP_LEFT\",\n"
1176 " \"type\": \"Actor\",\n"
1177 " \"name\": \"subActor\",\n"
1178 " \"visible\": false\n"
1180 " \"signals\": [{\n"
1181 " \"name\": \"touch\",\n"
1182 " \"action\": \"hide\",\n"
1183 " \"actor\": \"actor\",\n"
1184 " \"childActor\": \"subActor\"\n"
1190 Builder builder = Builder::New();
1191 builder.LoadFromString( json );
1192 builder.AddActors ( "arbitarysection", Stage::GetCurrent().GetRootLayer() );
1194 // Render and notify
1195 application.SendNotification();
1196 application.Render();
1198 Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("subActor");
1199 DALI_TEST_CHECK( actor );
1201 DALI_TEST_CHECK( !actor.IsVisible() );
1206 int UtcDaliBuilderFrameBufferP(void)
1208 ToolkitTestApplication application;
1210 // JSON with a quit event when the actor is touched
1215 " \"FB_WIDTH\": 200.0,\n"
1216 " \"FB_HEIGHT\": 200.0,\n"
1217 " \"FB_SIZE\": [200,200],\n"
1218 " \"FB_ASPECT_RATIO\": 1\n"
1222 " \"type\": \"ImageView\",\n"
1223 " \"name\": \"fbOnStage\",\n"
1224 " \"position\": [\n"
1225 " 0.40461349487305,\n"
1229 " \"parentOrigin\": [0.5, 0.5, 0.5],\n"
1230 " \"size\": [300, 300, 0],\n"
1231 " \"image\": \"fb0\",\n"
1232 " \"clearColor\": [1,0,0,1]\n"
1235 " \"type\": \"ImageView\",\n"
1236 " \"name\": \"Image1\",\n"
1237 " \"size\": [200, 200, 0],\n"
1238 " \"parentOrigin\": [0.5, 0.5, 0.5],\n"
1239 " \"effect\": \"Ripple2D\",\n"
1241 " \"url\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\"\n"
1245 " \"name\": \"onStage\",\n"
1246 " \"action\": \"play\",\n"
1247 " \"animation\": \"Animation_1\"\n"
1252 " \"type\":\"CameraActor\",\n"
1253 " \"name\":\"fbCam\",\n"
1254 " \"aspectRatio\": \"{FB_ASPECT_RATIO}\",\n"
1255 " \"projectionMode\": \"PERSPECTIVE_PROJECTION\",\n"
1256 " \"fieldOfView\": 0.785,\n"
1257 " \"invertYAxis\": true\n"
1260 " \"frameBufferImages\":\n"
1264 " \"type\": \"FrameBufferImage\",\n"
1265 " \"width\": { \"typeCast\":\"float\", \"value\":\"{FB_WIDTH}\" },\n"
1266 " \"height\": { \"typeCast\":\"float\", \"value\":\"{FB_HEIGHT}\" }\n"
1269 " \"renderTasks\":\n"
1274 " \"sourceActor\": \"fbOnStage\"\n"
1277 " \"sourceActor\": \"Image1\",\n"
1278 " \"targetFrameBuffer\": \"fb0\",\n"
1279 " \"viewportSize\":\"{FB_SIZE}\",\n"
1280 " \"cameraActor\":\"fbCam\"\n"
1285 " \"animations\": {\n"
1286 " \"Animation_1\": {\n"
1288 " \"properties\": [\n"
1290 " \"actor\": \"Image1\",\n"
1291 " \"property\": \"uTime\",\n"
1292 " \"value\": 10.0,\n"
1293 " \"alphaFunction\": \"LINEAR\",\n"
1294 " \"timePeriod\": {\n"
1296 " \"duration\": 10.0\n"
1298 " \"gui-builder-timeline-color\": \"#8dc0da\"\n"
1305 Builder builder = Builder::New();
1307 // frame buffer coverage
1308 builder.LoadFromString( json );
1310 // Render and notify
1311 application.SendNotification();
1312 application.Render();
1314 Dali::FrameBufferImage frameBuffer = builder.GetFrameBufferImage( "fb0" );
1315 DALI_TEST_CHECK( frameBuffer );
1317 Dali::FrameBufferImage frameBuffer2 = builder.GetFrameBufferImage( "fb0" );
1318 DALI_TEST_CHECK( frameBuffer2 );
1319 DALI_TEST_CHECK( frameBuffer == frameBuffer2 );
1321 DALI_TEST_CHECK( true );
1326 int UtcDaliBuilderPathConstraintsP(void)
1328 ToolkitTestApplication application;
1330 // JSON with a quit event when the actor is touched
1335 " \"FB_WIDTH\": 200.0,\n"
1336 " \"FB_HEIGHT\": 200.0,\n"
1337 " \"FB_SIZE\": [200,200],\n"
1338 " \"FB_ASPECT_RATIO\": 1\n"
1342 " \"type\": \"ImageView\",\n"
1343 " \"name\": \"Image1\",\n"
1344 " \"size\": [200, 200, 0],\n"
1345 " \"parentOrigin\": [0.5, 0.5, 0.5],\n"
1346 " \"effect\": \"Ripple2D\",\n"
1348 " \"url\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\"\n"
1352 " \"name\": \"onStage\",\n"
1353 " \"action\": \"play\",\n"
1354 " \"animation\": \"pathAnimation\"\n"
1357 " \"name\": \"onStage\",\n"
1358 " \"action\": \"applyConstraint\",\n"
1359 " \"constrainer\": \"constrainer0\",\n"
1360 " \"properties\":\n"
1363 " \"source\": \"Image1\",\n"
1364 " \"sourceProperty\": \"positionX\",\n"
1365 " \"target\": \"Image1\",\n"
1366 " \"targetProperty\": \"colorRed\",\n"
1367 " \"range\": [-300,300]\n"
1372 " \"name\": \"onStage\",\n"
1373 " \"action\": \"applyConstraint\",\n"
1374 " \"constrainer\": \"constrainer1\",\n"
1375 " \"properties\":\n"
1378 " \"source\": \"Image1\",\n"
1379 " \"sourceProperty\": \"positionX\",\n"
1380 " \"target\": \"Image1\",\n"
1381 " \"targetProperty\": \"colorBlue\",\n"
1382 " \"range\": [-300,300]\n"
1387 " \"name\": \"offStage\",\n"
1388 " \"action\": \"removeConstraints\",\n"
1389 " \"constrainer\": \"constrainer0\",\n"
1390 " \"properties\":\n"
1393 " \"source\": \"Image1\",\n"
1394 " \"sourceProperty\": \"positionX\",\n"
1395 " \"target\": \"Image1\",\n"
1396 " \"targetProperty\": \"colorRed\",\n"
1397 " \"range\": [-300,300]\n"
1402 " \"name\": \"offStage\",\n"
1403 " \"action\": \"removeConstraints\",\n"
1404 " \"constrainer\": \"constrainer1\",\n"
1405 " \"properties\":\n"
1408 " \"source\": \"Image1\",\n"
1409 " \"sourceProperty\": \"positionX\",\n"
1410 " \"target\": \"Image1\",\n"
1411 " \"targetProperty\": \"colorBlue\",\n"
1412 " \"range\": [-300,300]\n"
1423 " \"points\":[ [-150, -50, 0], [0.0,70.0,0.0], [190.0,-150.0,0.0] ],\n"
1424 " \"curvature\":0.35\n"
1427 " \"constrainers\":\n"
1429 " \"constrainer0\":\n"
1431 " \"type\": \"PathConstrainer\",\n"
1432 " \"points\": [ [0, 0, 0], [0,0,0], [0,0,0] ],\n"
1433 " \"controlPoints\": [ [0, 0, 0], [0,0,0], [0,0,0] ]\n"
1435 " \"constrainer1\":\n"
1437 " \"type\": \"LinearConstrainer\",\n"
1438 " \"value\": [ 0, 0, 0 ]\n"
1441 " \"animations\": {\n"
1442 " \"pathAnimation\": {\n"
1443 " \"duration\": 3.0,\n"
1444 " \"properties\":\n"
1446 " \"actor\": \"Image1\",\n"
1447 " \"path\":\"path0\",\n"
1448 " \"forward\":[1,0,0],\n"
1449 " \"alphaFunction\": \"EASE_IN_OUT\",\n"
1450 " \"timePeriod\": {\n"
1452 " \"duration\": 3\n"
1456 " \"actor\": \"Image1\",\n"
1457 " \"property\": \"uTime\",\n"
1458 " \"value\": 10.0,\n"
1459 " \"alphaFunction\": \"LINEAR\",\n"
1460 " \"timePeriod\": {\n"
1462 " \"duration\": 10.0\n"
1464 " \"gui-builder-timeline-color\": \"#8dc0da\"\n"
1467 " \"Animation_1\": {\n"
1469 " \"properties\": [\n"
1471 " \"actor\": \"Image1\",\n"
1472 " \"property\": \"uTime\",\n"
1473 " \"value\": 10.0,\n"
1474 " \"alphaFunction\": \"LINEAR\",\n"
1475 " \"timePeriod\": {\n"
1477 " \"duration\": 10.0\n"
1479 " \"gui-builder-timeline-color\": \"#8dc0da\"\n"
1486 Builder builder = Builder::New();
1488 // frame buffer coverage
1489 builder.LoadFromString( json );
1491 // Render and notify
1492 application.SendNotification();
1493 application.Render();
1495 Dali::Path path = builder.GetPath( "path0" );
1496 DALI_TEST_CHECK( path );
1498 Dali::Path path2 = builder.GetPath( "path0" );
1499 DALI_TEST_CHECK( path2 );
1500 DALI_TEST_CHECK( path == path2 );
1502 Dali::PathConstrainer constrainer0 = builder.GetPathConstrainer( "constrainer0" );
1503 DALI_TEST_CHECK( constrainer0 );
1505 Dali::PathConstrainer constrainer0_2 = builder.GetPathConstrainer( "constrainer0" );
1506 DALI_TEST_CHECK( constrainer0_2 );
1507 DALI_TEST_CHECK( constrainer0 == constrainer0_2 );
1509 Dali::LinearConstrainer constrainer1 = builder.GetLinearConstrainer( "constrainer1" );
1510 DALI_TEST_CHECK( constrainer1 );
1512 Dali::LinearConstrainer constrainer1_2 = builder.GetLinearConstrainer( "constrainer1" );
1513 DALI_TEST_CHECK( constrainer1 == constrainer1_2 );
1517 Actor actor = Actor::New();
1518 Stage::GetCurrent().Add( actor );
1519 builder.AddActors( actor );
1521 // Render and notify
1522 application.SendNotification();
1523 application.Render();
1525 actor.GetChildAt( 0 ).Unparent();
1530 #define CHECK_MAP_ELEMENT( xMap, xKey, xType, xPropType, xExpected, xLocation ) \
1532 Property::Value* value = xMap->Find( xKey ); \
1533 DALI_TEST_EQUALS( value==NULL, false, xLocation); \
1534 if( value != NULL ) \
1536 DALI_TEST_EQUALS( value->GetType(), xPropType, xLocation ); \
1538 value->Get(result); \
1539 DALI_TEST_EQUALS( result, xExpected, TEST_LOCATION ); \
1540 std::ostringstream oss; \
1541 oss << "Animation element " << xKey << "= " << result << std::endl; \
1542 tet_printf( oss.str().c_str() ); \
1546 tet_printf("Can't find map element " xKey "\n"); \
1551 int UtcDaliBuilderMapping01(void)
1553 ToolkitTestApplication application;
1559 " \"buttonPressFadeOut\":{\n"
1560 " \"alphaFunction\":\"EASE_OUT\",\n"
1561 " \"timePeriod\":{\n"
1563 " \"duration\":0.4\n"
1566 " \"buttonPressFadeIn\":{\n"
1567 " \"alphaFunction\":\"EASE_IN\",\n"
1568 " \"timePeriod\":{\n"
1570 " \"duration\":0.5\n"
1573 " \"transition:buttonPressed\":\n"
1576 " \"target\": \"unselectedBackgroundRenderer\",\n"
1577 " \"property\": \"opacity\",\n"
1579 " \"animator\":\"<buttonPressFadeOut>\"\n"
1582 " \"transition:buttonReleased\":\n"
1585 " \"target\": \"unselectedBackgroundRenderer\",\n"
1586 " \"property\": \"opacity\",\n"
1588 " \"animator\":\"<buttonPressFadeIn>\"\n"
1591 " \"target\": \"unselectedForegroundRenderer\",\n"
1592 " \"property\": \"scale\",\n"
1593 " \"value\": [ 1, 1, 1 ],\n"
1594 " \"animator\":\"<buttonPressFadeIn>\"\n"
1597 " \"target\": \"selectedBackgroundRenderer\",\n"
1598 " \"property\": \"opacity\",\n"
1600 " \"animator\": \"<buttonPressFadeOut>\"\n"
1603 " \"target\": \"selectedForegroundRenderer\",\n"
1604 " \"property\": \"scale\",\n"
1605 " \"value\": [ 0, 0, 0 ],\n"
1606 " \"animator\":\"<buttonPressFadeOut>\"\n"
1612 " \"testbutton\":\n"
1614 " \"pressTransition\":\"<transition:buttonPressed>\",\n"
1615 " \"releaseTransition\":\"<transition:buttonReleased>\"\n"
1620 Builder builder = Builder::New();
1621 builder.LoadFromString( json );
1623 Test::TestButton testButton = Test::TestButton::New();
1624 Stage::GetCurrent().Add( testButton );
1626 // Render and notify
1627 application.SendNotification();
1628 application.Render();
1630 DALI_TEST_CHECK( builder.ApplyStyle( "testbutton", testButton ) );
1632 // Now check that it has loaded the transition correctly:
1633 Property::Value transition = testButton.GetProperty(Test::TestButton::Property::PRESS_TRANSITION);
1634 DALI_TEST_EQUALS( transition.GetType(), Property::ARRAY, TEST_LOCATION );
1635 Property::Array* array = transition.GetArray();
1637 DALI_TEST_EQUALS( array->Size(), 1, TEST_LOCATION );
1638 Property::Value element = array->GetElementAt(0);
1639 DALI_TEST_CHECK( element.GetType() == Property::MAP );
1640 Property::Map* map = element.GetMap();
1642 CHECK_MAP_ELEMENT(map, "target", std::string, Property::STRING, "unselectedBackgroundRenderer", TEST_LOCATION);
1643 CHECK_MAP_ELEMENT(map, "property", std::string, Property::STRING, "opacity", TEST_LOCATION);
1644 CHECK_MAP_ELEMENT(map, "alphaFunction", int, Property::INTEGER, (int)Dali::AlphaFunction::EASE_OUT, TEST_LOCATION);
1645 CHECK_MAP_ELEMENT(map, "timePeriodDelay", float, Property::FLOAT, 0.0f, TEST_LOCATION);
1646 CHECK_MAP_ELEMENT(map, "timePeriodDuration", float, Property::FLOAT, 0.4f, TEST_LOCATION);
1652 int UtcDaliBuilderMappingCycleCheck(void)
1654 ToolkitTestApplication application;
1660 " \"cyclicKey1\":\"<cyclicKey1>\",\n"
1661 " \"cyclicKey2\":\"<cyclicKey3>\",\n"
1662 " \"cyclicKey3\":\"<cyclicKey2>\",\n"
1664 " \"alphaFunction\":\"EASE_IN\",\n"
1665 " \"timePeriod\":{\n"
1666 " \"delay\":\"<cyclicKey3>\",\n"
1667 " \"duration\":0.6\n"
1670 " \"transition:buttonPressed\":\n"
1673 " \"target\": \"<cyclicKey1>\",\n"
1674 " \"property\": \"<cyclicKey2>\",\n"
1676 " \"animator\":\"<FadeOut>\"\n"
1682 " \"testbutton\":\n"
1684 " \"pressTransition\":\"<transition:buttonPressed>\",\n"
1685 " \"releaseTransition\":\"<cyclicKey2>\",\n"
1686 " \"disabledTransition\":\"<cyclicKey3>\",\n"
1687 " \"enabledTransition\":\"<unknownKey>\"\n"
1692 Builder builder = Builder::New();
1693 builder.LoadFromString( json );
1695 Test::TestButton testButton = Test::TestButton::New();
1696 Stage::GetCurrent().Add( testButton );
1698 // Render and notify
1699 application.SendNotification();
1700 application.Render();
1702 DALI_TEST_CHECK( builder.ApplyStyle( "testbutton", testButton ) );
1704 // Now check that it has loaded the transition correctly:
1705 Property::Value transition = testButton.GetProperty(Test::TestButton::Property::PRESS_TRANSITION);
1706 DALI_TEST_EQUALS( transition.GetType(), Property::ARRAY, TEST_LOCATION );
1707 Property::Array* array = transition.GetArray();
1709 DALI_TEST_EQUALS( array->Size(), 1, TEST_LOCATION );
1710 Property::Value element = array->GetElementAt(0);
1711 DALI_TEST_CHECK( element.GetType() == Property::MAP );
1712 Property::Map* map = element.GetMap();
1714 CHECK_MAP_ELEMENT(map, "target", std::string, Property::STRING, "", TEST_LOCATION);
1715 CHECK_MAP_ELEMENT(map, "property", std::string, Property::STRING, "", TEST_LOCATION);
1716 CHECK_MAP_ELEMENT(map, "timePeriodDuration", float, Property::FLOAT, 0.6f, TEST_LOCATION);
1721 int UtcDaliBuilderTypeCasts(void)
1723 ToolkitTestApplication application;
1729 "\"type\": \"Layer\","
1730 "\"maximumSize\": { \"typeCast\":\"vector2\", \"value\":[100,15] },"
1731 "\"position\": { \"typeCast\":\"vector3\", \"value\":[100,10,1] },"
1732 "\"color\": { \"typeCast\":\"vector4\", \"value\":[0.5,0.5,0.5,1] },"
1733 "\"sensitive\": { \"typeCast\":\"boolean\", \"value\":false },"
1734 "\"orientation\": { \"typeCast\":\"rotation\", \"value\":[10,10,10,10] },"
1735 "\"colorMode\": { \"typeCast\":\"string\", \"value\":\"USE_OWN_MULTIPLY_PARENT_COLOR\" },"
1736 "\"clippingBox\": { \"typeCast\":\"rect\", \"value\":[10,10,10,10] },"
1737 "\"padding\": { \"typeCast\":\"extents\", \"value\":[10,10,10,10] }"
1742 Actor rootActor = Actor::New();
1743 Stage::GetCurrent().Add( rootActor );
1745 Builder builder = Builder::New();
1746 builder.LoadFromString( json );
1747 builder.AddActors( rootActor );
1749 application.SendNotification();
1750 application.Render();
1752 Actor createdActor = rootActor.GetChildAt( 0 );
1753 DALI_TEST_EQUALS( createdActor.GetMaximumSize(), Vector2(100.0f,15.0f), TEST_LOCATION );
1754 DALI_TEST_EQUALS( createdActor.GetCurrentPosition(), Vector3(100.0f,10.0f,1.0f), TEST_LOCATION );
1755 DALI_TEST_EQUALS( createdActor.GetCurrentColor(), Vector4(0.5f,0.5f,0.5f,1.0f), TEST_LOCATION );
1756 DALI_TEST_EQUALS( createdActor.IsSensitive(), false, TEST_LOCATION );
1757 DALI_TEST_EQUALS( createdActor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
1762 int UtcDaliBuilderBuilderControl(void)
1764 ToolkitTestApplication application;
1770 "\"type\": \"BuilderControl\","
1771 "\"integerProperty\": 10,"
1772 "\"matrix3Property\": [ 1,2,3,4,5,6,7,8,9 ],"
1773 "\"matrixProperty\": [ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 ],"
1774 "\"noneProperty\": 10"
1779 Actor rootActor = Actor::New();
1780 Stage::GetCurrent().Add( rootActor );
1782 Builder builder = Builder::New();
1783 builder.LoadFromString( json );
1784 builder.AddActors( rootActor );
1786 application.SendNotification();
1787 application.Render();
1789 DALI_TEST_EQUALS( BuilderControlProperty::gSetPropertyCalledCount, 4, TEST_LOCATION );
1794 int UtcDaliBuilderActionsWithParams(void)
1796 ToolkitTestApplication application;
1798 // JSON with a quit event when the actor is touched
1804 " \"type\": \"ImageView\",\n"
1805 " \"name\": \"image\",\n"
1806 " \"size\": [100,100,1],\n"
1807 " \"signals\": [{\n"
1808 " \"name\": \"touch\",\n"
1809 " \"action\": \"show\",\n"
1810 " \"parameters\": {\n"
1811 " \"property1\" : 10,\n"
1812 " \"property2\" : [1,2],\n"
1813 " \"property3\" : [1,2,3],\n"
1814 " \"property4\" : [1,2,3,4]\n"
1822 Builder builder = Builder::New();
1823 builder.LoadFromString( json );
1824 builder.AddActors( Stage::GetCurrent().GetRootLayer() );
1826 DALI_TEST_CHECK( true ); // For Coverage
1831 int UtcDaliBuilderConfigurationP(void)
1833 ToolkitTestApplication application;
1835 // JSON with a quit event when the actor is touched
1840 " \"alwaysShowFocus\":true\n"
1845 Builder builder = Builder::New();
1846 builder.LoadFromString( json );
1848 Property::Map map = builder.GetConfigurations();
1850 Dali::Property::Value* pValue = map.Find( "alwaysShowFocus" );
1852 DALI_TEST_CHECK( pValue );
1854 bool value = pValue->Get<bool>();
1856 DALI_TEST_CHECK( value );
1862 int UtcDaliBase64EncodingP(void)
1864 std::vector<uint32_t> data = { 0, 1, 2, 3, 4, 5, std::numeric_limits<uint32_t>::min(), std::numeric_limits<uint32_t>::max() };
1866 Property::Value value;
1867 EncodeBase64PropertyData( value, data );
1869 std::cout << "Max uint32_t:" << std::numeric_limits<uint32_t>::max() << std::endl;
1870 std::cout << "Input data: ";
1871 std::ostream_iterator<uint32_t> out_it (std::cout,", ");
1872 std::copy ( data.begin(), data.end(), out_it );
1873 std::cout << std::endl;
1876 DALI_TEST_CHECK( value.Get( output ) );
1877 DALI_TEST_EQUALS( output, "AAAAAAEAAAACAAAAAwAAAAQAAAAFAAAAAAAAAP////8", TEST_LOCATION );
1879 std::cout << "Output data: " << output << std::endl;
1884 int UtcDaliBase64EncodingN(void)
1886 tet_infoline( "Test encoding an empty vector returns empty string" );
1887 std::vector<uint32_t> data;
1889 Property::Value value;
1890 EncodeBase64PropertyData( value, data );
1893 DALI_TEST_CHECK( value.Get( output ) );
1894 DALI_TEST_EQUALS( output.empty(), true, TEST_LOCATION );
1899 template <typename T>
1900 int b64l(std::vector<T>&data)
1902 auto lengthInBytes = 4*data.size();
1903 return ceil( lengthInBytes * 1.33333f );
1906 int UtcDaliBase64EncodingP02(void)
1908 tet_infoline( "Test encoding vectors of lengths m .. m+4 encode and decode back to the same length vectors" );
1910 std::vector<uint32_t> testData;
1911 for(int i=0; i<8; ++i ) // 8 chosen to stay within single string output
1913 testData.push_back(i);
1915 Property::Value value;
1916 EncodeBase64PropertyData( value, testData );
1919 DALI_TEST_CHECK( value.Get( output ) );
1920 DALI_TEST_EQUALS( output.empty(), false, TEST_LOCATION);
1921 DALI_TEST_EQUALS( output.length(), b64l(testData), TEST_LOCATION );
1923 std::vector<uint32_t> outData;
1924 DecodeBase64PropertyData( value, outData );
1925 DALI_TEST_EQUALS( testData.size(), outData.size(), TEST_LOCATION );
1926 DALI_TEST_EQUALS( std::equal( testData.begin(), testData.end(), outData.begin()), true, TEST_LOCATION );
1929 testData.push_back( 12345 );
1930 EncodeBase64PropertyData( value, testData );
1932 DALI_TEST_CHECK( value.Get( output ) );
1933 DALI_TEST_EQUALS( output.empty(), false, TEST_LOCATION);
1934 DALI_TEST_EQUALS( output.length(), b64l(testData), TEST_LOCATION );
1937 DecodeBase64PropertyData( value, outData );
1938 DALI_TEST_EQUALS( testData.size(), outData.size(), TEST_LOCATION );
1939 DALI_TEST_EQUALS( std::equal( testData.begin(), testData.end(), outData.begin()), true, TEST_LOCATION );
1942 testData.push_back( 67890 );
1943 EncodeBase64PropertyData( value, testData );
1945 DALI_TEST_CHECK( value.Get( output ) );
1946 DALI_TEST_EQUALS( output.empty(), false, TEST_LOCATION);
1947 DALI_TEST_EQUALS( output.length(), b64l(testData), TEST_LOCATION );
1950 DecodeBase64PropertyData( value, outData );
1951 DALI_TEST_EQUALS( testData.size(), outData.size(), TEST_LOCATION );
1952 DALI_TEST_EQUALS( std::equal( testData.begin(), testData.end(), outData.begin()), true, TEST_LOCATION );
1955 testData.push_back( -1 );
1956 EncodeBase64PropertyData( value, testData );
1958 DALI_TEST_CHECK( value.Get( output ) );
1959 DALI_TEST_EQUALS( output.empty(), false, TEST_LOCATION);
1960 DALI_TEST_EQUALS( output.length(), b64l(testData), TEST_LOCATION );
1963 DecodeBase64PropertyData( value, outData );
1964 DALI_TEST_EQUALS( testData.size(), outData.size(), TEST_LOCATION );
1965 DALI_TEST_EQUALS( std::equal( testData.begin(), testData.end(), outData.begin()), true, TEST_LOCATION );
1972 int UtcDaliBase64EncodingP03(void)
1974 tet_infoline( "Test encoding a vector of length 12 has output within single string" );
1976 std::vector<uint32_t> testData;
1977 for(int i=0; i<12; ++i )
1979 testData.push_back(i);
1981 Property::Value value;
1982 EncodeBase64PropertyData( value, testData );
1985 DALI_TEST_CHECK( value.Get( output ) );
1986 DALI_TEST_EQUALS( output.empty(), false, TEST_LOCATION);
1987 DALI_TEST_EQUALS( output.length(), b64l(testData), TEST_LOCATION );
1989 std::vector<uint32_t> outData;
1990 DecodeBase64PropertyData( value, outData );
1991 DALI_TEST_EQUALS( testData.size(), outData.size(), TEST_LOCATION );
1997 int UtcDaliBase64EncodingP04(void)
1999 tet_infoline( "Test encoding a vector of length 13 has output split over 2 strings" );
2001 std::vector<uint32_t> testData;
2002 for(int i=0; i<13; ++i )
2004 testData.push_back(i);
2006 Property::Value value;
2007 EncodeBase64PropertyData( value, testData );
2009 auto array = value.GetArray();
2010 DALI_TEST_CHECK( array );
2012 DALI_TEST_EQUALS( array->Count(), 2, TEST_LOCATION );
2014 std::vector<uint32_t> outData;
2015 DecodeBase64PropertyData( value, outData );
2016 DALI_TEST_EQUALS( testData.size(), outData.size(), TEST_LOCATION );
2022 int UtcDaliBase64EncodingP05(void)
2024 tet_infoline( "Test encoding a vector of length 24 has output split over 2 strings" );
2026 std::vector<uint32_t> testData;
2027 for(int i=0; i<24; ++i )
2029 testData.push_back(i);
2031 Property::Value value;
2032 EncodeBase64PropertyData( value, testData );
2034 auto array = value.GetArray();
2035 DALI_TEST_CHECK( array );
2037 DALI_TEST_EQUALS( array->Count(), 2, TEST_LOCATION );
2039 std::vector<uint32_t> outData;
2040 DecodeBase64PropertyData( value, outData );
2041 DALI_TEST_EQUALS( testData.size(), outData.size(), TEST_LOCATION );
2047 int UtcDaliBase64EncodingP06(void)
2049 tet_infoline( "Test encoding a vector of arbitrary length decodes OK." );
2051 std::vector<uint32_t> testData;
2052 for(int i=0; i<97; ++i )
2054 testData.push_back(i);
2056 Property::Value value;
2057 EncodeBase64PropertyData( value, testData );
2059 auto array = value.GetArray();
2060 DALI_TEST_CHECK( array );
2062 std::vector<uint32_t> outData;
2063 DecodeBase64PropertyData( value, outData );
2064 DALI_TEST_EQUALS( testData.size(), outData.size(), TEST_LOCATION );
2070 int UtcDaliBase64DecodingN01(void)
2072 tet_infoline( "Test decoding empty string results in empty data" );
2074 Property::Value value("");
2075 std::vector<uint32_t> outputData;
2076 DecodeBase64PropertyData( value, outputData);
2077 DALI_TEST_EQUALS( outputData.size(), 0, TEST_LOCATION );
2082 int UtcDaliBase64DecodingN02(void)
2084 tet_infoline( "Test decoding array with non-string values results in empty data" );
2086 Property::Array array;
2088 array[0] = "Stuff, things";
2090 Property::Value value(array);
2092 std::vector<uint32_t> outputData;
2093 DecodeBase64PropertyData( value, outputData);
2094 DALI_TEST_EQUALS( outputData.size(), 0, TEST_LOCATION );
2098 int UtcDaliBase64DecodingP01(void)
2100 tet_infoline( "Test decoding string of known data gives expected result");
2102 std::string testInput("//////7+/v4DAgEA");
2103 std::vector<uint32_t> expectedResults = { 0xffffffff, 0xfefefefe, 0x00010203 };
2105 std::vector<uint32_t> outputData;
2106 DecodeBase64PropertyData(Property::Value(testInput), outputData);
2108 DALI_TEST_EQUALS( std::equal( expectedResults.begin(), expectedResults.end(), outputData.begin() ), true,