2 * Copyright (c) 2014-2016 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.
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <dali-toolkit/devel-api/builder/builder.h>
22 #include <dali/integration-api/events/touch-event-integ.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <test-button.h>
25 #include <test-animation-data.h>
27 #define STRINGIFY(A)#A
30 using namespace Toolkit;
32 namespace BuilderControlProperty
37 INTEGER_PROPERTY = Toolkit::Control::CONTROL_PROPERTY_END_INDEX + 1,
48 return Toolkit::Control::New();
51 int gSetPropertyCalledCount = 0;
53 void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
55 ++gSetPropertyCalledCount;
58 Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex )
60 return Property::Value();
63 } // unnamed namespace
66 Dali::TypeRegistration typeRegistration( "BuilderControl", typeid( Toolkit::Control ), Create );
68 Dali::PropertyRegistration propertyInteger( typeRegistration, "integerProperty", INTEGER_PROPERTY, Property::INTEGER, &SetProperty, &GetProperty );
69 Dali::PropertyRegistration propertyMatrix3( typeRegistration, "matrix3Property", MATRIX3_PROPERTY, Property::MATRIX3, &SetProperty, &GetProperty );
70 Dali::PropertyRegistration propertyMatrix( typeRegistration, "matrixProperty", MATRIX_PROPERTY, Property::MATRIX, &SetProperty, &GetProperty );
71 Dali::PropertyRegistration propertyNone( typeRegistration, "noneProperty", NONE_PROPERTY, Property::NONE, &SetProperty, &GetProperty );
78 std::string ReplaceQuotes(const std::string &in_s)
81 // wrong as no embedded quote but had regex link problems
82 std::replace(s.begin(), s.end(), '\'', '"');
88 BuilderFunctor( bool& called ) : mCalled( called )
105 void builder_startup(void)
107 test_return_value = TET_UNDEF;
110 void builder_cleanup(void)
112 test_return_value = TET_PASS;
115 int UtcDaliBuilderQuitSignal(void)
117 ToolkitTestApplication application;
119 // JSON with a quit event when the actor is touched
124 "\"type\": \"Layer\","
125 "\"size\": [100,100,1],"
126 "\"parentOrigin\": \"TOP_LEFT\","
127 "\"anchorPoint\": \"TOP_LEFT\","
128 "\"maximumSize\": [100,100],"
129 "\"orientation\": [10,10,10,10],"
130 "\"clippingBox\": [10,10,10,10],"
132 "\"name\": \"touch\","
133 "\"action\": \"quit\""
138 Builder builder = Builder::New();
139 builder.LoadFromString( json );
140 builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
142 // Connect to builder's quit signal
143 bool functorCalled( false );
144 builder.QuitSignal().Connect( &application, BuilderFunctor( functorCalled ) );
147 application.SendNotification();
148 application.Render();
150 // Emit touch event and check that our quit method is called
151 Integration::TouchEvent touchEvent;
152 Integration::Point point;
153 point.SetState( PointState::DOWN );
154 point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
155 touchEvent.points.push_back( point );
156 application.ProcessEvent( touchEvent );
157 DALI_TEST_CHECK( functorCalled );
163 int UtcDaliBuilderAnimationP(void)
165 ToolkitTestApplication application;
167 // JSON with a quit event when the actor is touched
172 " \"ALPHA_FUNCTION\":\"EASE_IN_OUT\""
178 " \"points\":[ [-150, -50, 0], [0.0,70.0,0.0], [190.0,-150.0,0.0] ],"
179 " \"curvature\":0.35"
185 " \"endAction\": \"BAKE\","
186 " \"disconnectAction\": \"BAKE\","
189 " \"actor\": \"greeting\","
190 " \"property\": \"position\","
191 " \"value\": [300, 300, -1000],"
192 " \"alphaFunction\": \"{ALPHA_FUNCTION}\","
193 " \"relative\": true,"
200 " \"actor\": \"greeting\","
201 " \"property\": \"visible\","
202 " \"alphaFunction\": \"LINEAR\","
206 " \"actor\": \"greeting\","
207 " \"property\": \"sizeWidth\","
208 " \"alphaFunction\": \"REVERSE\","
212 " \"actor\": \"greeting\","
213 " \"property\": \"orientation\","
214 " \"alphaFunction\": \"EASE_IN\","
215 " \"value\": [10.0,20.0,30.0]"
218 " \"actor\": \"greeting\","
219 " \"property\": \"orientation\","
220 " \"alphaFunction\": \"EASE_OUT\","
221 " \"value\": [0.0, 0.0, 0.0, 1.0]"
224 " \"actor\": \"greeting\","
225 " \"property\": \"orientation\","
226 " \"alphaFunction\": \"EASE_IN_OUT\","
227 " \"value\": [0.0, 0.0, 0.0, 1.0]"
230 " \"actor\": \"greeting\","
231 " \"property\": \"orientation\","
232 " \"alphaFunction\": \"EASE_IN_SINE\","
233 " \"value\": [0.0, 0.0, 0.0, 1.0]"
236 " \"actor\": \"greeting\","
237 " \"property\": \"orientation\","
238 " \"alphaFunction\": \"EASE_OUT_SINE\","
239 " \"value\": [0.0, 0.0, 0.0, 1.0]"
242 " \"actor\": \"greeting\","
243 " \"property\": \"orientation\","
244 " \"alphaFunction\": \"EASE_IN_OUT_SINE\","
245 " \"value\": [0.0, 0.0, 0.0, 1.0]"
248 " \"actor\": \"greeting\","
249 " \"property\": \"orientation\","
250 " \"alphaFunction\": \"BOUNCE\","
251 " \"value\": [0.0, 0.0, 0.0, 1.0]"
254 " \"actor\": \"greeting\","
255 " \"property\": \"orientation\","
256 " \"alphaFunction\": \"SIN\","
257 " \"value\": [0.0, 0.0, 0.0, 1.0]"
260 " \"actor\": \"greeting\","
261 " \"property\": \"orientation\","
262 " \"alphaFunction\": \"EASE_OUT_BACK\","
263 " \"value\": [0.0, 0.0, 0.0, 1.0]"
267 " \"pathAnimation\": {"
268 " \"duration\": 3.0,"
269 " \"endAction\": \"DISCARD\","
270 " \"disconnectAction\": \"BAKE_FINAL\","
271 " \"properties\": [{"
272 " \"actor\": \"greeting\","
273 " \"path\":\"path0\","
274 " \"forward\":[1,0,0],"
275 " \"alphaFunction\": \"EASE_IN_OUT\","
284 " \"name\": \"greeting\","
285 " \"type\": \"TextLabel\","
286 " \"text\": \"Touch me\","
287 " \"styles\": [\"basicText\"],"
288 " \"position\": [0, -120, 0],"
289 " \"size\": [200, 200, 1],"
290 " \"orientation\": [0, 0, 30],"
292 " \"name\": \"touch\","
293 " \"action\": \"play\","
294 " \"animation\": \"animate\""
299 Builder builder = Builder::New();
300 builder.LoadFromString( json );
301 builder.AddActors( Stage::GetCurrent().GetRootLayer() );
303 Animation anim = builder.CreateAnimation("animate");
305 DALI_TEST_CHECK( anim );
308 map["ALPHA_FUNCTION"] = "EASE_IN_SQUARE";
309 anim = builder.CreateAnimation("animate", map);
311 DALI_TEST_CHECK( anim );
313 anim = builder.CreateAnimation("pathAnimation");
315 DALI_TEST_CHECK( anim );
318 // Emit touch event and check that our quit method is called
319 Integration::TouchEvent touchEvent;
320 Integration::Point point;
321 point.SetState( PointState::DOWN );
322 point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
323 touchEvent.points.push_back( point );
324 application.ProcessEvent( touchEvent );
327 application.SendNotification();
328 application.Render();
334 int UtcDaliBuilderAnimationN(void)
336 ToolkitTestApplication application;
338 // JSON with a quit event when the actor is touched
343 " \"TEXT\": \"Touch Me\","
344 " \"NAME\": \"greeting\" "
350 " \"points\":[ [-150, -50, 0], [0.0,70.0,0.0], [190.0,-150.0,0.0] ],"
351 " \"curvature\":0.35"
357 " \"endAction\": \"BAKE\","
358 " \"disconnectAction\": \"BAKE\","
361 " \"actor\": \"{NAME}\","
362 " \"property\": \"positioninvalid\","
363 " \"value\": [300, 300, -1000],"
364 " \"alphaFunction\": \"EASE_IN_OUT\","
365 " \"relative\": true,"
375 " \"endAction\": \"BAKE\","
376 " \"disconnectAction\": \"BAKE\","
379 " \"actor\": \"{NAME}\","
380 " \"property\": \"positioninvalid\","
381 " \"value\": [300, 300, -1000],"
382 " \"alphaFunction\": \"EGGS_OVER_EASY\","
383 " \"relative\": true,"
391 " \"pathAnimation\": {"
392 " \"duration\": 3.0,"
393 " \"endAction\": \"DISCARD\","
394 " \"disconnectAction\": \"BAKE_FINAL\","
395 " \"properties\": [{"
396 " \"actor\": \"greeting\","
397 " \"path\":\"pathDoesntExist\","
398 " \"forward\":[1,0,0],"
399 " \"alphaFunction\": \"EASE_IN_OUT\","
408 " \"name\": \"greeting\","
409 " \"type\": \"TextLabel\","
410 " \"text\": \"Touch me\","
411 " \"styles\": [\"basicText\"],"
412 " \"position\": [0, -120, 0],"
413 " \"size\": [200, 200, 1],"
414 " \"orientation\": [0, 0, 30],"
416 " \"name\": \"touch\","
417 " \"action\": \"play\","
418 " \"animation\": \"animate\""
422 " \"name\": \"greeting2\","
423 " \"type\": \"TextLabel\","
424 " \"text\": \"Touch me\""
429 Builder builder = Builder::New();
430 builder.LoadFromString( json );
431 builder.AddActors( Stage::GetCurrent().GetRootLayer() );
433 Animation anim = builder.CreateAnimation("animate");
435 // log warning line coverage
436 anim = builder.CreateAnimation("pathAnimation");
437 DALI_TEST_CHECK(anim);
439 anim = builder.CreateAnimation("animate");
440 DALI_TEST_CHECK(anim);
442 anim = builder.CreateAnimation("animate2");
443 DALI_TEST_CHECK(anim);
445 // create referencing a different actor aka animation templates
447 map["NAME"] = "greeting2";
448 anim = builder.CreateAnimation("animate2", map);
449 DALI_TEST_CHECK(anim);
451 // alternative actor to use for FindChildByName
452 anim = builder.CreateAnimation("animate2", Dali::Stage::GetCurrent().GetRootLayer());
453 DALI_TEST_CHECK(anim);
455 // alternative actor to use for FindChildByName
456 anim = builder.CreateAnimation("animate2", map, Dali::Stage::GetCurrent().GetRootLayer());
457 DALI_TEST_CHECK(anim);
464 int UtcDaliBuilderConstantsP(void)
466 ToolkitTestApplication application;
468 // JSON with a quit event when the actor is touched
473 " \"IMAGE_PATH\": \"apath\","
475 " \"ANCHOR\": \"TOP_LEFT\","
476 " \"PADDING\": [1,2,3,4]"
480 " \"type\": \"ImageView\","
481 " \"name\": \"{NAME}\","
482 " \"size\": [100,100,1],"
483 " \"parentOrigin\": \"TOP_LEFT\","
484 " \"anchorPoint\": \"{ANCHOR}\","
485 " \"padding\": \"{PADDING}\","
486 " \"image\": { \"url\": \"dir/{IMAGE_PATH}\" },"
487 " \"sizeWidth\": \"{WIDTH}\","
489 " \"name\": \"touch\","
490 " \"action\": \"quit\""
496 Builder builder = Builder::New();
497 builder.LoadFromString( json );
499 builder.AddConstant( "NAME", "image" );
501 Property::Map map = builder.GetConstants();
503 Dali::Property::Value* pValue = map.Find( "NAME" );
505 DALI_TEST_CHECK( pValue );
507 pValue = map.Find( "IMAGE_PATH" );
509 DALI_TEST_CHECK( pValue );
511 Dali::Property::Value value = builder.GetConstant( "WIDTH" );
513 DALI_TEST_CHECK( value.GetType() != Property::NONE );
515 builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
516 DALI_TEST_CHECK( builder );
518 Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("image");
519 DALI_TEST_CHECK( actor );
524 int UtcDaliBuilderTemplatesAndStylesP(void)
526 ToolkitTestApplication application;
528 // JSON with a quit event when the actor is touched
533 " \"SIZE\": [10,20,30]"
537 " \"imageStyle\": \n"
539 " \"color\": [1,0,0,1],\n"
541 " \"childImage\": {\n"
542 " \"color\": \"34\"\n"
549 " \"imageViewTemplate\": { \n"
550 " \"type\": \"ImageView\",\n"
551 " \"styles\": [\"imageStyle\"]\n"
553 " \"imageTree\": { \n"
554 " \"type\": \"ImageView\",\n"
555 " \"styles\": [\"imageStyle\"],\n"
556 " \"name\": \"image\",\n"
557 " \"size\": \"{SIZE}\",\n"
559 " \"name\": \"touch\",\n"
560 " \"action\": \"quit\"\n"
564 " \"type\":\"ImageView\",\n"
565 " \"name\":\"childImage\", \n"
575 " \"type\":\"imageViewTemplate\",\n"
576 " \"name\":\"childImage2\"\n"
583 " \"type\": \"imageTree\","
584 " \"size\": [100,100,1]"
589 std::string stylejson(
591 " \"color\": [1,0,0,1],\n"
593 " \"childImage\": {\n"
594 " \"color\": \"#344353\"\n"
600 std::string templatejson(
602 " \"type\": \"ImageView\",\n"
603 " \"styles\": [\"imageStyle\"],\n"
604 " \"name\": \"image\",\n"
605 " \"size\": \"{SIZE}\",\n"
607 " \"name\": \"touch\",\n"
608 " \"action\": \"quit\"\n"
612 " \"type\":\"ImageView\",\n"
613 " \"name\":\"childImage\" \n"
619 Builder builder = Builder::New();
620 builder.LoadFromString( json );
622 ImageView actor = ImageView::DownCast( builder.Create( "imageTree" ) );
623 DALI_TEST_CHECK( actor );
625 Dali::Property::Map map;
626 map["SIZE"] = Vector3(100,100,1);
627 actor = ImageView::DownCast( builder.Create( "imageTree", map ) );
628 DALI_TEST_CHECK( actor );
630 // create from json snippet
631 actor = ImageView::DownCast( builder.CreateFromJson( templatejson ) );
632 DALI_TEST_CHECK( actor );
635 // NB: already applied in create
636 DALI_TEST_CHECK( builder.ApplyStyle( "imageStyle", actor ) );
638 // apply from json snippet
639 DALI_TEST_CHECK( builder.ApplyFromJson( actor, stylejson ) );
644 int UtcDaliBuilderRenderTasksP(void)
646 ToolkitTestApplication application;
648 // JSON with a quit event when the actor is touched
654 " \"sourceActor\": \"image\",\n"
655 " \"cameraActor\": \"camera\" \n"
661 " \"type\": \"CameraActor\",\n"
662 " \"name\": \"camera\"\n"
665 " \"type\": \"ImageView\",\n"
666 " \"name\": \"image\",\n"
667 " \"size\": [100,100,1],\n"
669 " \"name\": \"touch\",\n"
670 " \"action\": \"quit\"\n"
674 " \"type\":\"ImageView\",\n"
675 " \"name\":\"childImage\" \n"
683 Builder builder = Builder::New();
684 builder.LoadFromString( json );
686 unsigned int count = Stage::GetCurrent().GetRenderTaskList().GetTaskCount();
689 builder.CreateRenderTask( "task0" );
691 DALI_TEST_CHECK( count <
692 Stage::GetCurrent().GetRenderTaskList().GetTaskCount() );
697 int UtcDaliBuilderChildActionP(void)
699 ToolkitTestApplication application;
701 // JSON with a quit event when the actor is touched
706 " \"type\": \"Actor\",\n"
707 " \"name\": \"actor\",\n"
708 " \"size\": [100,100,1],\n"
709 " \"parentOrigin\": \"TOP_LEFT\",\n"
710 " \"anchorPoint\": \"TOP_LEFT\",\n"
712 " \"type\": \"Actor\",\n"
713 " \"name\": \"subActor\"\n"
716 " \"name\": \"touch\",\n"
717 " \"action\": \"hide\",\n"
718 " \"actor\": \"actor\",\n"
719 " \"childActor\": \"subActor\"\n"
725 Builder builder = Builder::New();
726 builder.LoadFromString( json );
727 builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
730 application.SendNotification();
731 application.Render();
733 // Emit touch event and check that our quit method is called
734 Integration::TouchEvent touchEvent;
735 Integration::Point point;
736 point.SetState( PointState::DOWN );
737 point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
738 touchEvent.points.push_back( point );
739 application.ProcessEvent( touchEvent );
742 application.SendNotification();
743 application.Render();
745 Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("subActor");
746 DALI_TEST_CHECK( actor );
748 DALI_TEST_CHECK( !actor.IsVisible() );
753 int UtcDaliBuilderSetPropertyActionP(void)
755 ToolkitTestApplication application;
757 // JSON with a quit event when the actor is touched
762 " \"type\": \"Actor\",\n"
763 " \"name\": \"actor\",\n"
764 " \"size\": [100,100,1],\n"
765 " \"parentOrigin\": \"TOP_LEFT\",\n"
766 " \"anchorPoint\": \"TOP_LEFT\",\n"
768 " \"type\": \"Actor\",\n"
769 " \"name\": \"subActor\"\n"
772 " \"name\": \"touch\",\n"
773 " \"action\": \"set\",\n"
774 " \"actor\": \"subActor\",\n"
775 " \"property\": \"visible\",\n"
776 " \"value\": false\n"
782 Builder builder = Builder::New();
783 builder.LoadFromString( json );
784 builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
787 application.SendNotification();
788 application.Render();
790 // Emit touch event and check that our quit method is called
791 Integration::TouchEvent touchEvent;
792 Integration::Point point;
793 point.SetState( PointState::DOWN );
794 point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
795 touchEvent.points.push_back( point );
796 application.ProcessEvent( touchEvent );
799 application.SendNotification();
800 application.Render();
802 Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("subActor");
803 DALI_TEST_CHECK( actor );
805 DALI_TEST_CHECK( !actor.IsVisible() );
810 int UtcDaliBuilderGenericActionP(void)
812 ToolkitTestApplication application;
814 // JSON with a quit event when the actor is touched
819 " \"type\": \"Actor\",\n"
820 " \"name\": \"actor\",\n"
821 " \"size\": [100,100,1],\n"
822 " \"parentOrigin\": \"TOP_LEFT\",\n"
823 " \"anchorPoint\": \"TOP_LEFT\",\n"
825 " \"type\": \"Actor\",\n"
826 " \"name\": \"subActor\"\n"
829 " \"name\": \"touch\",\n"
830 " \"action\": \"hide\"\n"
836 Builder builder = Builder::New();
837 builder.LoadFromString( json );
838 builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
841 application.SendNotification();
842 application.Render();
844 // Emit touch event and check that our quit method is called
845 Integration::TouchEvent touchEvent;
846 Integration::Point point;
847 point.SetState( PointState::DOWN );
848 point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
849 touchEvent.points.push_back( point );
850 application.ProcessEvent( touchEvent );
853 application.SendNotification();
854 application.Render();
856 Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("actor");
857 DALI_TEST_CHECK( actor );
859 DALI_TEST_CHECK( !actor.IsVisible() );
864 int UtcDaliBuilderPropertyNotificationP(void)
866 ToolkitTestApplication application;
868 // JSON with a quit event when the actor is touched
873 " \"type\": \"Actor\",\n"
874 " \"name\": \"actor\",\n"
875 " \"size\": [100,100,1],\n"
876 " \"parentOrigin\": \"TOP_LEFT\",\n"
877 " \"anchorPoint\": \"TOP_LEFT\",\n"
879 " \"type\": \"Actor\",\n"
880 " \"name\": \"subActor\"\n"
883 " \"name\": \"touch\",\n"
884 " \"action\": \"hide\"\n"
886 " \"notifications\": [{\n"
887 " \"property\": \"visible\",\n"
888 " \"condition\": \"False\",\n"
889 " \"action\": \"show\"\n"
892 " \"property\": \"positionX\",\n"
893 " \"condition\": \"LessThan\",\n"
895 " \"action\": \"show\"\n"
898 " \"property\": \"positionY\",\n"
899 " \"condition\": \"GreaterThan\",\n"
900 " \"arg0\": 200.0,\n"
901 " \"action\": \"show\"\n"
904 " \"property\": \"positionZ\",\n"
905 " \"condition\": \"Inside\",\n"
908 " \"action\": \"show\"\n"
911 " \"property\": \"positionZ\",\n"
912 " \"condition\": \"Outside\",\n"
915 " \"action\": \"show\"\n"
921 Builder builder = Builder::New();
922 builder.LoadFromString( json );
923 builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
926 application.SendNotification();
927 application.Render();
929 // Emit touch event and check that our quit method is called
930 Integration::TouchEvent touchEvent;
931 Integration::Point point;
932 point.SetState( PointState::DOWN );
933 point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
934 touchEvent.points.push_back( point );
935 application.ProcessEvent( touchEvent );
938 application.SendNotification();
939 application.Render();
942 application.SendNotification();
943 application.Render();
945 Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("actor");
946 DALI_TEST_CHECK( actor );
948 DALI_TEST_CHECK( actor.IsVisible() );
953 int UtcDaliBuilderPropertyNotificationN(void)
955 ToolkitTestApplication application;
957 // JSON with a quit event when the actor is touched
962 " \"type\": \"Actor\",\n"
963 " \"notifications\": [{\n"
964 " \"property\": \"visible\",\n"
965 " \"condition\": \"ErrorCondition\",\n"
966 " \"action\": \"show\"\n"
974 Builder builder = Builder::New();
975 builder.LoadFromString( json );
976 builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
977 DALI_TEST_CHECK( false );
981 DALI_TEST_CHECK( true );
989 int UtcDaliBuilderCustomPropertyP(void)
991 ToolkitTestApplication application;
993 // JSON with a quit event when the actor is touched
998 " \"imageTree\": { \n"
999 " \"type\": \"ImageView\",\n"
1000 " \"name\": \"image\",\n"
1001 " \"size\": [100,100,1],\n"
1002 " \"signals\": [{\n"
1003 " \"name\": \"touch\",\n"
1004 " \"action\": \"quit\"\n"
1006 " \"properties\": {\n"
1007 " \"newproperty\": true\n"
1009 " \"animatableProperties\": {\n"
1010 " \"newAnimatableproperty\": 3\n"
1014 " \"type\":\"ImageView\",\n"
1015 " \"name\":\"childImage\" \n"
1023 Builder builder = Builder::New();
1024 builder.LoadFromString( json );
1026 ImageView actor = ImageView::DownCast( builder.Create( "imageTree" ) );
1027 DALI_TEST_CHECK( actor );
1029 // NB: already applied in create
1030 Property::Index index = actor.GetPropertyIndex("newproperty");
1031 DALI_TEST_CHECK( Property::INVALID_INDEX != index );
1032 Property::Value value = actor.GetProperty(index);
1033 DALI_TEST_CHECK( value.Get<bool>() == true );
1035 index = actor.GetPropertyIndex("newAnimatableproperty");
1036 DALI_TEST_CHECK( Property::INVALID_INDEX != index );
1037 value = actor.GetProperty(index);
1038 DALI_TEST_CHECK( value.Get<int>() == 3 );
1043 int UtcDaliBuilderCustomShaderP(void)
1045 ToolkitTestApplication application;
1047 // JSON with a quit event when the actor is touched
1052 " \"type\": \"ImageView\",\n"
1053 " \"name\": \"Image1\",\n"
1054 " \"position\": [\n"
1055 " 0.40461349487305,\n"
1059 " \"parentOrigin\": [0.5, 0.5, 0.5],\n"
1060 " \"size\": [200, 200, 0],\n"
1061 " \"effect\": \"Ripple2D\",\n"
1063 " \"url\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\",\n"
1064 " \"desiredWidth\": 200,\n"
1065 " \"desiredHeight\": 80,\n"
1067 " \"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"
1070 " \"customAnimatableProperties\": {\n"
1071 " \"uAmplitude\": 0.02,\n"
1076 " \"name\": \"onStage\",\n"
1077 " \"action\": \"play\",\n"
1078 " \"animation\": \"Animation_1\"\n"
1083 " \"animations\": {\n"
1084 " \"Animation_1\": {\n"
1086 " \"properties\": [\n"
1088 " \"actor\": \"Image1\",\n"
1089 " \"property\": \"uTime\",\n"
1090 " \"value\": 10.0,\n"
1091 " \"alphaFunction\": \"LINEAR\",\n"
1092 " \"timePeriod\": {\n"
1094 " \"duration\": 10.0\n"
1104 Builder builder = Builder::New();
1105 builder.LoadFromString( json );
1107 builder.AddActors ( "stage", Stage::GetCurrent().GetRootLayer() );
1109 // Render and notify
1110 application.SendNotification();
1111 application.Render();
1113 Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("Image1");
1116 DALI_TEST_CHECK( actor );
1122 int UtcDaliBuilderLoadFromStringN(void)
1124 ToolkitTestApplication application;
1126 // JSON with a quit event when the actor is touched
1128 "asdfsadf dsf asdf asdf {"
1131 "\"type\": \"Actor\","
1132 "\"size\": [100,100,1],"
1133 "\"parentOrigin\": \"TOP_LEFT\","
1134 "\"anchorPoint\": \"TOP_LEFT\","
1136 "\"name\": \"touch\","
1137 "\"action\": \"quit\""
1142 Builder builder = Builder::New();
1144 bool assert1 = false;
1148 builder.LoadFromString( json );
1150 catch( Dali::DaliException& e )
1152 DALI_TEST_PRINT_ASSERT( e );
1153 DALI_TEST_EQUALS(e.condition, "!\"Cannot parse JSON\"", TEST_LOCATION);
1157 DALI_TEST_CHECK( assert1 );
1163 int UtcDaliBuilderAddActorsP(void)
1165 ToolkitTestApplication application;
1167 // JSON with a quit event when the actor is touched
1170 " \"arbitarysection\":\n"
1172 " \"type\": \"Actor\",\n"
1173 " \"name\": \"actor\",\n"
1174 " \"size\": [100,100,1],\n"
1175 " \"parentOrigin\": \"TOP_LEFT\",\n"
1176 " \"anchorPoint\": \"TOP_LEFT\",\n"
1178 " \"type\": \"Actor\",\n"
1179 " \"name\": \"subActor\",\n"
1180 " \"visible\": false\n"
1182 " \"signals\": [{\n"
1183 " \"name\": \"touch\",\n"
1184 " \"action\": \"hide\",\n"
1185 " \"actor\": \"actor\",\n"
1186 " \"childActor\": \"subActor\"\n"
1192 Builder builder = Builder::New();
1193 builder.LoadFromString( json );
1194 builder.AddActors ( "arbitarysection", Stage::GetCurrent().GetRootLayer() );
1196 // Render and notify
1197 application.SendNotification();
1198 application.Render();
1200 Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("subActor");
1201 DALI_TEST_CHECK( actor );
1203 DALI_TEST_CHECK( !actor.IsVisible() );
1208 int UtcDaliBuilderFrameBufferP(void)
1210 ToolkitTestApplication application;
1212 // JSON with a quit event when the actor is touched
1217 " \"FB_WIDTH\": 200.0,\n"
1218 " \"FB_HEIGHT\": 200.0,\n"
1219 " \"FB_SIZE\": [200,200],\n"
1220 " \"FB_ASPECT_RATIO\": 1\n"
1224 " \"type\": \"ImageView\",\n"
1225 " \"name\": \"fbOnStage\",\n"
1226 " \"position\": [\n"
1227 " 0.40461349487305,\n"
1231 " \"parentOrigin\": [0.5, 0.5, 0.5],\n"
1232 " \"size\": [300, 300, 0],\n"
1233 " \"image\": \"fb0\",\n"
1234 " \"clearColor\": [1,0,0,1]\n"
1237 " \"type\": \"ImageView\",\n"
1238 " \"name\": \"Image1\",\n"
1239 " \"size\": [200, 200, 0],\n"
1240 " \"parentOrigin\": [0.5, 0.5, 0.5],\n"
1241 " \"effect\": \"Ripple2D\",\n"
1243 " \"url\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\"\n"
1247 " \"name\": \"onStage\",\n"
1248 " \"action\": \"play\",\n"
1249 " \"animation\": \"Animation_1\"\n"
1254 " \"type\":\"CameraActor\",\n"
1255 " \"name\":\"fbCam\",\n"
1256 " \"aspectRatio\": \"{FB_ASPECT_RATIO}\",\n"
1257 " \"projectionMode\": \"PERSPECTIVE_PROJECTION\",\n"
1258 " \"fieldOfView\": 0.785,\n"
1259 " \"invertYAxis\": true\n"
1262 " \"frameBufferImages\":\n"
1266 " \"type\": \"FrameBufferImage\",\n"
1267 " \"width\": { \"typeCast\":\"float\", \"value\":\"{FB_WIDTH}\" },\n"
1268 " \"height\": { \"typeCast\":\"float\", \"value\":\"{FB_HEIGHT}\" }\n"
1271 " \"renderTasks\":\n"
1276 " \"sourceActor\": \"fbOnStage\"\n"
1279 " \"sourceActor\": \"Image1\",\n"
1280 " \"targetFrameBuffer\": \"fb0\",\n"
1281 " \"viewportSize\":\"{FB_SIZE}\",\n"
1282 " \"cameraActor\":\"fbCam\"\n"
1287 " \"animations\": {\n"
1288 " \"Animation_1\": {\n"
1290 " \"properties\": [\n"
1292 " \"actor\": \"Image1\",\n"
1293 " \"property\": \"uTime\",\n"
1294 " \"value\": 10.0,\n"
1295 " \"alphaFunction\": \"LINEAR\",\n"
1296 " \"timePeriod\": {\n"
1298 " \"duration\": 10.0\n"
1300 " \"gui-builder-timeline-color\": \"#8dc0da\"\n"
1305 " \"shaderEffects\": {\n"
1306 " \"Ripple2D\": {\n"
1308 " \"vertexPrefix\": \"\",\n"
1309 " \"vertex\": \"void main(void)\\n{\\n gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\\n vTexCoord = aTexCoord;\\n}\\n\\n\",\n"
1310 " \"fragmentPrefix\": \"\",\n"
1311 " \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n highp vec2 textureSize = sTextureRect.zw - sTextureRect.xy;\\n highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n highp float len = length(pos);\\n highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n"
1312 " \"geometryType\": \"GEOMETRY_TYPE_IMAGE\"\n"
1314 " \"geometryHints\": \"HINT_NONE\",\n"
1315 " \"gridDensity\": 0,\n"
1316 " \"loop\": true,\n"
1317 " \"uAmplitude\": 0.02,\n"
1323 Builder builder = Builder::New();
1325 // frame buffer coverage
1326 builder.LoadFromString( json );
1328 // Render and notify
1329 application.SendNotification();
1330 application.Render();
1332 Dali::FrameBufferImage frameBuffer = builder.GetFrameBufferImage( "fb0" );
1333 DALI_TEST_CHECK( frameBuffer );
1335 Dali::FrameBufferImage frameBuffer2 = builder.GetFrameBufferImage( "fb0" );
1336 DALI_TEST_CHECK( frameBuffer2 );
1337 DALI_TEST_CHECK( frameBuffer == frameBuffer2 );
1339 DALI_TEST_CHECK( true );
1344 int UtcDaliBuilderPathConstraintsP(void)
1346 ToolkitTestApplication application;
1348 // JSON with a quit event when the actor is touched
1353 " \"FB_WIDTH\": 200.0,\n"
1354 " \"FB_HEIGHT\": 200.0,\n"
1355 " \"FB_SIZE\": [200,200],\n"
1356 " \"FB_ASPECT_RATIO\": 1\n"
1360 " \"type\": \"ImageView\",\n"
1361 " \"name\": \"Image1\",\n"
1362 " \"size\": [200, 200, 0],\n"
1363 " \"parentOrigin\": [0.5, 0.5, 0.5],\n"
1364 " \"effect\": \"Ripple2D\",\n"
1366 " \"url\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\"\n"
1370 " \"name\": \"onStage\",\n"
1371 " \"action\": \"play\",\n"
1372 " \"animation\": \"pathAnimation\"\n"
1375 " \"name\": \"onStage\",\n"
1376 " \"action\": \"applyConstraint\",\n"
1377 " \"constrainer\": \"constrainer0\",\n"
1378 " \"properties\":\n"
1381 " \"source\": \"Image1\",\n"
1382 " \"sourceProperty\": \"positionX\",\n"
1383 " \"target\": \"Image1\",\n"
1384 " \"targetProperty\": \"colorRed\",\n"
1385 " \"range\": [-300,300]\n"
1390 " \"name\": \"onStage\",\n"
1391 " \"action\": \"applyConstraint\",\n"
1392 " \"constrainer\": \"constrainer1\",\n"
1393 " \"properties\":\n"
1396 " \"source\": \"Image1\",\n"
1397 " \"sourceProperty\": \"positionX\",\n"
1398 " \"target\": \"Image1\",\n"
1399 " \"targetProperty\": \"colorBlue\",\n"
1400 " \"range\": [-300,300]\n"
1405 " \"name\": \"offStage\",\n"
1406 " \"action\": \"removeConstraints\",\n"
1407 " \"constrainer\": \"constrainer0\",\n"
1408 " \"properties\":\n"
1411 " \"source\": \"Image1\",\n"
1412 " \"sourceProperty\": \"positionX\",\n"
1413 " \"target\": \"Image1\",\n"
1414 " \"targetProperty\": \"colorRed\",\n"
1415 " \"range\": [-300,300]\n"
1420 " \"name\": \"offStage\",\n"
1421 " \"action\": \"removeConstraints\",\n"
1422 " \"constrainer\": \"constrainer1\",\n"
1423 " \"properties\":\n"
1426 " \"source\": \"Image1\",\n"
1427 " \"sourceProperty\": \"positionX\",\n"
1428 " \"target\": \"Image1\",\n"
1429 " \"targetProperty\": \"colorBlue\",\n"
1430 " \"range\": [-300,300]\n"
1441 " \"points\":[ [-150, -50, 0], [0.0,70.0,0.0], [190.0,-150.0,0.0] ],\n"
1442 " \"curvature\":0.35\n"
1445 " \"constrainers\":\n"
1447 " \"constrainer0\":\n"
1449 " \"type\": \"PathConstrainer\",\n"
1450 " \"points\": [ [0, 0, 0], [0,0,0], [0,0,0] ],\n"
1451 " \"controlPoints\": [ [0, 0, 0], [0,0,0], [0,0,0] ]\n"
1453 " \"constrainer1\":\n"
1455 " \"type\": \"LinearConstrainer\",\n"
1456 " \"value\": [ 0, 0, 0 ]\n"
1459 " \"animations\": {\n"
1460 " \"pathAnimation\": {\n"
1461 " \"duration\": 3.0,\n"
1462 " \"properties\":\n"
1464 " \"actor\": \"Image1\",\n"
1465 " \"path\":\"path0\",\n"
1466 " \"forward\":[1,0,0],\n"
1467 " \"alphaFunction\": \"EASE_IN_OUT\",\n"
1468 " \"timePeriod\": {\n"
1470 " \"duration\": 3\n"
1474 " \"actor\": \"Image1\",\n"
1475 " \"property\": \"uTime\",\n"
1476 " \"value\": 10.0,\n"
1477 " \"alphaFunction\": \"LINEAR\",\n"
1478 " \"timePeriod\": {\n"
1480 " \"duration\": 10.0\n"
1482 " \"gui-builder-timeline-color\": \"#8dc0da\"\n"
1485 " \"Animation_1\": {\n"
1487 " \"properties\": [\n"
1489 " \"actor\": \"Image1\",\n"
1490 " \"property\": \"uTime\",\n"
1491 " \"value\": 10.0,\n"
1492 " \"alphaFunction\": \"LINEAR\",\n"
1493 " \"timePeriod\": {\n"
1495 " \"duration\": 10.0\n"
1497 " \"gui-builder-timeline-color\": \"#8dc0da\"\n"
1502 " \"shaderEffects\": {\n"
1503 " \"Ripple2D\": {\n"
1505 " \"vertexPrefix\": \"\",\n"
1506 " \"vertex\": \"void main(void)\\n{\\n gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\\n vTexCoord = aTexCoord;\\n}\\n\\n\",\n"
1507 " \"fragmentPrefix\": \"\",\n"
1508 " \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n highp vec2 textureSize = sTextureRect.zw - sTextureRect.xy;\\n highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n highp float len = length(pos);\\n highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n"
1509 " \"geometryType\": \"GEOMETRY_TYPE_IMAGE\"\n"
1511 " \"geometryHints\": \"HINT_NONE\",\n"
1512 " \"gridDensity\": 0,\n"
1513 " \"loop\": true,\n"
1514 " \"uAmplitude\": 0.02,\n"
1520 Builder builder = Builder::New();
1522 // frame buffer coverage
1523 builder.LoadFromString( json );
1525 // Render and notify
1526 application.SendNotification();
1527 application.Render();
1529 Dali::Path path = builder.GetPath( "path0" );
1530 DALI_TEST_CHECK( path );
1532 Dali::Path path2 = builder.GetPath( "path0" );
1533 DALI_TEST_CHECK( path2 );
1534 DALI_TEST_CHECK( path == path2 );
1536 Dali::PathConstrainer constrainer0 = builder.GetPathConstrainer( "constrainer0" );
1537 DALI_TEST_CHECK( constrainer0 );
1539 Dali::PathConstrainer constrainer0_2 = builder.GetPathConstrainer( "constrainer0" );
1540 DALI_TEST_CHECK( constrainer0_2 );
1541 DALI_TEST_CHECK( constrainer0 == constrainer0_2 );
1543 Dali::LinearConstrainer constrainer1 = builder.GetLinearConstrainer( "constrainer1" );
1544 DALI_TEST_CHECK( constrainer1 );
1546 Dali::LinearConstrainer constrainer1_2 = builder.GetLinearConstrainer( "constrainer1" );
1547 DALI_TEST_CHECK( constrainer1 == constrainer1_2 );
1551 Actor actor = Actor::New();
1552 Stage::GetCurrent().Add( actor );
1553 builder.AddActors( actor );
1555 // Render and notify
1556 application.SendNotification();
1557 application.Render();
1559 actor.GetChildAt( 0 ).Unparent();
1564 #define CHECK_MAP_ELEMENT( xMap, xKey, xType, xPropType, xExpected, xLocation ) \
1566 Property::Value* value = xMap->Find( xKey ); \
1567 DALI_TEST_EQUALS( value==NULL, false, xLocation); \
1568 if( value != NULL ) \
1570 DALI_TEST_EQUALS( value->GetType(), xPropType, xLocation ); \
1572 value->Get(result); \
1573 DALI_TEST_EQUALS( result, xExpected, TEST_LOCATION ); \
1574 std::ostringstream oss; \
1575 oss << "Animation element " << xKey << "= " << result << std::endl; \
1576 tet_printf( oss.str().c_str() ); \
1580 tet_printf("Can't find map element " xKey "\n"); \
1585 int UtcDaliBuilderMapping01(void)
1587 ToolkitTestApplication application;
1593 " \"buttonPressFadeOut\":{\n"
1594 " \"alphaFunction\":\"EASE_OUT\",\n"
1595 " \"timePeriod\":{\n"
1597 " \"duration\":0.4\n"
1600 " \"buttonPressFadeIn\":{\n"
1601 " \"alphaFunction\":\"EASE_IN\",\n"
1602 " \"timePeriod\":{\n"
1604 " \"duration\":0.5\n"
1607 " \"transition:buttonPressed\":\n"
1610 " \"target\": \"unselectedBackgroundRenderer\",\n"
1611 " \"property\": \"opacity\",\n"
1613 " \"animator\":\"<buttonPressFadeOut>\"\n"
1616 " \"transition:buttonReleased\":\n"
1619 " \"target\": \"unselectedBackgroundRenderer\",\n"
1620 " \"property\": \"opacity\",\n"
1622 " \"animator\":\"<buttonPressFadeIn>\"\n"
1625 " \"target\": \"unselectedForegroundRenderer\",\n"
1626 " \"property\": \"scale\",\n"
1627 " \"value\": [ 1, 1, 1 ],\n"
1628 " \"animator\":\"<buttonPressFadeIn>\"\n"
1631 " \"target\": \"selectedBackgroundRenderer\",\n"
1632 " \"property\": \"opacity\",\n"
1634 " \"animator\": \"<buttonPressFadeOut>\"\n"
1637 " \"target\": \"selectedForegroundRenderer\",\n"
1638 " \"property\": \"scale\",\n"
1639 " \"value\": [ 0, 0, 0 ],\n"
1640 " \"animator\":\"<buttonPressFadeOut>\"\n"
1646 " \"testbutton\":\n"
1648 " \"pressTransition\":\"<transition:buttonPressed>\",\n"
1649 " \"releaseTransition\":\"<transition:buttonReleased>\"\n"
1654 Builder builder = Builder::New();
1655 builder.LoadFromString( json );
1657 Test::TestButton testButton = Test::TestButton::New();
1658 Stage::GetCurrent().Add( testButton );
1660 // Render and notify
1661 application.SendNotification();
1662 application.Render();
1664 DALI_TEST_CHECK( builder.ApplyStyle( "testbutton", testButton ) );
1666 // Now check that it has loaded the transition correctly:
1667 Property::Value transition = testButton.GetProperty(Test::TestButton::Property::PRESS_TRANSITION);
1668 DALI_TEST_EQUALS( transition.GetType(), Property::ARRAY, TEST_LOCATION );
1669 Property::Array* array = transition.GetArray();
1671 DALI_TEST_EQUALS( array->Size(), 1, TEST_LOCATION );
1672 Property::Value element = array->GetElementAt(0);
1673 DALI_TEST_CHECK( element.GetType() == Property::MAP );
1674 Property::Map* map = element.GetMap();
1676 CHECK_MAP_ELEMENT(map, "target", std::string, Property::STRING, "unselectedBackgroundRenderer", TEST_LOCATION);
1677 CHECK_MAP_ELEMENT(map, "property", std::string, Property::STRING, "opacity", TEST_LOCATION);
1678 CHECK_MAP_ELEMENT(map, "alphaFunction", int, Property::INTEGER, (int)Dali::AlphaFunction::EASE_OUT, TEST_LOCATION);
1679 CHECK_MAP_ELEMENT(map, "timePeriodDelay", float, Property::FLOAT, 0.0f, TEST_LOCATION);
1680 CHECK_MAP_ELEMENT(map, "timePeriodDuration", float, Property::FLOAT, 0.4f, TEST_LOCATION);
1686 int UtcDaliBuilderMappingCycleCheck(void)
1688 ToolkitTestApplication application;
1694 " \"cyclicKey1\":\"<cyclicKey1>\",\n"
1695 " \"cyclicKey2\":\"<cyclicKey3>\",\n"
1696 " \"cyclicKey3\":\"<cyclicKey2>\",\n"
1698 " \"alphaFunction\":\"EASE_IN\",\n"
1699 " \"timePeriod\":{\n"
1700 " \"delay\":\"<cyclicKey3>\",\n"
1701 " \"duration\":0.6\n"
1704 " \"transition:buttonPressed\":\n"
1707 " \"target\": \"<cyclicKey1>\",\n"
1708 " \"property\": \"<cyclicKey2>\",\n"
1710 " \"animator\":\"<FadeOut>\"\n"
1716 " \"testbutton\":\n"
1718 " \"pressTransition\":\"<transition:buttonPressed>\",\n"
1719 " \"releaseTransition\":\"<cyclicKey2>\",\n"
1720 " \"disabledTransition\":\"<cyclicKey3>\",\n"
1721 " \"enabledTransition\":\"<unknownKey>\"\n"
1726 Builder builder = Builder::New();
1727 builder.LoadFromString( json );
1729 Test::TestButton testButton = Test::TestButton::New();
1730 Stage::GetCurrent().Add( testButton );
1732 // Render and notify
1733 application.SendNotification();
1734 application.Render();
1736 DALI_TEST_CHECK( builder.ApplyStyle( "testbutton", testButton ) );
1738 // Now check that it has loaded the transition correctly:
1739 Property::Value transition = testButton.GetProperty(Test::TestButton::Property::PRESS_TRANSITION);
1740 DALI_TEST_EQUALS( transition.GetType(), Property::ARRAY, TEST_LOCATION );
1741 Property::Array* array = transition.GetArray();
1743 DALI_TEST_EQUALS( array->Size(), 1, TEST_LOCATION );
1744 Property::Value element = array->GetElementAt(0);
1745 DALI_TEST_CHECK( element.GetType() == Property::MAP );
1746 Property::Map* map = element.GetMap();
1748 CHECK_MAP_ELEMENT(map, "target", std::string, Property::STRING, "", TEST_LOCATION);
1749 CHECK_MAP_ELEMENT(map, "property", std::string, Property::STRING, "", TEST_LOCATION);
1750 CHECK_MAP_ELEMENT(map, "timePeriodDuration", float, Property::FLOAT, 0.6f, TEST_LOCATION);
1755 int UtcDaliBuilderTypeCasts(void)
1757 ToolkitTestApplication application;
1763 "\"type\": \"Layer\","
1764 "\"maximumSize\": { \"typeCast\":\"vector2\", \"value\":[100,15] },"
1765 "\"position\": { \"typeCast\":\"vector3\", \"value\":[100,10,1] },"
1766 "\"color\": { \"typeCast\":\"vector4\", \"value\":[0.5,0.5,0.5,1] },"
1767 "\"sensitive\": { \"typeCast\":\"boolean\", \"value\":false },"
1768 "\"orientation\": { \"typeCast\":\"rotation\", \"value\":[10,10,10,10] },"
1769 "\"colorMode\": { \"typeCast\":\"string\", \"value\":\"USE_OWN_MULTIPLY_PARENT_COLOR\" },"
1770 "\"clippingBox\": { \"typeCast\":\"rect\", \"value\":[10,10,10,10] }"
1775 Actor rootActor = Actor::New();
1776 Stage::GetCurrent().Add( rootActor );
1778 Builder builder = Builder::New();
1779 builder.LoadFromString( json );
1780 builder.AddActors( rootActor );
1782 application.SendNotification();
1783 application.Render();
1785 Actor createdActor = rootActor.GetChildAt( 0 );
1786 DALI_TEST_EQUALS( createdActor.GetMaximumSize(), Vector2(100.0f,15.0f), TEST_LOCATION );
1787 DALI_TEST_EQUALS( createdActor.GetCurrentPosition(), Vector3(100.0f,10.0f,1.0f), TEST_LOCATION );
1788 DALI_TEST_EQUALS( createdActor.GetCurrentColor(), Vector4(0.5f,0.5f,0.5f,1.0f), TEST_LOCATION );
1789 DALI_TEST_EQUALS( createdActor.IsSensitive(), false, TEST_LOCATION );
1790 DALI_TEST_EQUALS( createdActor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
1795 int UtcDaliBuilderBuilderControl(void)
1797 ToolkitTestApplication application;
1803 "\"type\": \"BuilderControl\","
1804 "\"integerProperty\": 10,"
1805 "\"matrix3Property\": [ 1,2,3,4,5,6,7,8,9 ],"
1806 "\"matrixProperty\": [ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 ],"
1807 "\"noneProperty\": 10"
1812 Actor rootActor = Actor::New();
1813 Stage::GetCurrent().Add( rootActor );
1815 Builder builder = Builder::New();
1816 builder.LoadFromString( json );
1817 builder.AddActors( rootActor );
1819 application.SendNotification();
1820 application.Render();
1822 DALI_TEST_EQUALS( BuilderControlProperty::gSetPropertyCalledCount, 4, TEST_LOCATION );
1827 int UtcDaliBuilderActionsWithParams(void)
1829 ToolkitTestApplication application;
1831 // JSON with a quit event when the actor is touched
1837 " \"type\": \"ImageView\",\n"
1838 " \"name\": \"image\",\n"
1839 " \"size\": [100,100,1],\n"
1840 " \"signals\": [{\n"
1841 " \"name\": \"touch\",\n"
1842 " \"action\": \"show\",\n"
1843 " \"parameters\": {\n"
1844 " \"property1\" : 10,\n"
1845 " \"property2\" : [1,2],\n"
1846 " \"property3\" : [1,2,3],\n"
1847 " \"property4\" : [1,2,3,4]\n"
1855 Builder builder = Builder::New();
1856 builder.LoadFromString( json );
1857 builder.AddActors( Stage::GetCurrent().GetRootLayer() );
1859 DALI_TEST_CHECK( true ); // For Coverage