2 * Copyright (c) 2014 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>
24 #define STRINGIFY(A)#A
27 using namespace Toolkit;
32 std::string ReplaceQuotes(const std::string &in_s)
35 // wrong as no embedded quote but had regex link problems
36 std::replace(s.begin(), s.end(), '\'', '"');
42 BuilderFunctor( bool& called ) : mCalled( called )
59 void builder_startup(void)
61 test_return_value = TET_UNDEF;
64 void builder_cleanup(void)
66 test_return_value = TET_PASS;
69 int UtcDaliBuilderQuitSignal(void)
71 ToolkitTestApplication application;
73 // JSON with a quit event when the actor is touched
78 "\"type\": \"Actor\","
79 "\"size\": [100,100,1],"
80 "\"parentOrigin\": \"TOP_LEFT\","
81 "\"anchorPoint\": \"TOP_LEFT\","
83 "\"name\": \"touched\","
84 "\"action\": \"quit\""
89 Builder builder = Builder::New();
90 builder.LoadFromString( json );
91 builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
93 // Connect to builder's quit signal
94 bool functorCalled( false );
95 builder.QuitSignal().Connect( &application, BuilderFunctor( functorCalled ) );
98 application.SendNotification();
101 // Emit touch event and check that our quit method is called
102 Integration::TouchEvent touchEvent;
103 touchEvent.points.push_back( TouchPoint ( 0, TouchPoint::Down, 10.0f, 10.0f ) );
104 application.ProcessEvent( touchEvent );
105 DALI_TEST_CHECK( functorCalled );
111 int UtcDaliBuilderAnimationP(void)
113 ToolkitTestApplication application;
115 // JSON with a quit event when the actor is touched
120 " \"ALPHA_FUNCTION\":\"EASE_IN_OUT\""
126 " \"points\":[ [-150, -50, 0], [0.0,70.0,0.0], [190.0,-150.0,0.0] ],"
127 " \"curvature\":0.35"
133 " \"endAction\": \"BAKE\","
134 " \"disconnectAction\": \"BAKE\","
137 " \"actor\": \"greeting\","
138 " \"property\": \"position\","
139 " \"value\": [300, 300, -1000],"
140 " \"alphaFunction\": \"{ALPHA_FUNCTION}\","
141 " \"relative\": true,"
148 " \"actor\": \"greeting\","
149 " \"property\": \"visible\","
150 " \"alphaFunction\": \"LINEAR\","
154 " \"actor\": \"greeting\","
155 " \"property\": \"sizeWidth\","
156 " \"alphaFunction\": \"REVERSE\","
160 " \"actor\": \"greeting\","
161 " \"property\": \"orientation\","
162 " \"alphaFunction\": \"EASE_IN\","
163 " \"value\": [10.0,20.0,30.0]"
166 " \"actor\": \"greeting\","
167 " \"property\": \"orientation\","
168 " \"alphaFunction\": \"EASE_OUT\","
169 " \"value\": [0.0, 0.0, 0.0, 1.0]"
172 " \"actor\": \"greeting\","
173 " \"property\": \"orientation\","
174 " \"alphaFunction\": \"EASE_IN_OUT\","
175 " \"value\": [0.0, 0.0, 0.0, 1.0]"
178 " \"actor\": \"greeting\","
179 " \"property\": \"orientation\","
180 " \"alphaFunction\": \"EASE_IN_SINE\","
181 " \"value\": [0.0, 0.0, 0.0, 1.0]"
184 " \"actor\": \"greeting\","
185 " \"property\": \"orientation\","
186 " \"alphaFunction\": \"EASE_OUT_SINE\","
187 " \"value\": [0.0, 0.0, 0.0, 1.0]"
190 " \"actor\": \"greeting\","
191 " \"property\": \"orientation\","
192 " \"alphaFunction\": \"EASE_IN_OUT_SINE\","
193 " \"value\": [0.0, 0.0, 0.0, 1.0]"
196 " \"actor\": \"greeting\","
197 " \"property\": \"orientation\","
198 " \"alphaFunction\": \"BOUNCE\","
199 " \"value\": [0.0, 0.0, 0.0, 1.0]"
202 " \"actor\": \"greeting\","
203 " \"property\": \"orientation\","
204 " \"alphaFunction\": \"SIN\","
205 " \"value\": [0.0, 0.0, 0.0, 1.0]"
208 " \"actor\": \"greeting\","
209 " \"property\": \"orientation\","
210 " \"alphaFunction\": \"EASE_OUT_BACK\","
211 " \"value\": [0.0, 0.0, 0.0, 1.0]"
215 " \"pathAnimation\": {"
216 " \"duration\": 3.0,"
217 " \"endAction\": \"DISCARD\","
218 " \"disconnectAction\": \"BAKE_FINAL\","
219 " \"properties\": [{"
220 " \"actor\": \"greeting\","
221 " \"path\":\"path0\","
222 " \"forward\":[1,0,0],"
223 " \"alphaFunction\": \"EASE_IN_OUT\","
232 " \"name\": \"greeting\","
233 " \"type\": \"TextLabel\","
234 " \"text\": \"Touch me\","
235 " \"styles\": [\"basicText\"],"
236 " \"position\": [0, -120, 0],"
237 " \"size\": [200, 200, 1],"
238 " \"orientation\": [0, 0, 30],"
240 " \"name\": \"touched\","
241 " \"action\": \"play\","
242 " \"animation\": \"animate\""
247 Builder builder = Builder::New();
248 builder.LoadFromString( json );
249 builder.AddActors( Stage::GetCurrent().GetRootLayer() );
251 Animation anim = builder.CreateAnimation("animate");
253 DALI_TEST_CHECK( anim );
256 map["ALPHA_FUNCTION"] = "EASE_IN_SQUARE";
257 anim = builder.CreateAnimation("animate", map);
259 DALI_TEST_CHECK( anim );
261 anim = builder.CreateAnimation("pathAnimation");
263 DALI_TEST_CHECK( anim );
266 // Emit touch event and check that our quit method is called
267 Integration::TouchEvent touchEvent;
268 touchEvent.points.push_back( TouchPoint ( 0, TouchPoint::Down, 10.0f, 10.0f ) );
269 application.ProcessEvent( touchEvent );
272 application.SendNotification();
273 application.Render();
279 int UtcDaliBuilderAnimationN(void)
281 ToolkitTestApplication application;
283 // JSON with a quit event when the actor is touched
288 " \"TEXT\": \"Touch Me\","
289 " \"NAME\": \"greeting\" "
295 " \"points\":[ [-150, -50, 0], [0.0,70.0,0.0], [190.0,-150.0,0.0] ],"
296 " \"curvature\":0.35"
302 " \"endAction\": \"BAKE\","
303 " \"disconnectAction\": \"BAKE\","
306 " \"actor\": \"{NAME}\","
307 " \"property\": \"positioninvalid\","
308 " \"value\": [300, 300, -1000],"
309 " \"alphaFunction\": \"EASE_IN_OUT\","
310 " \"relative\": true,"
320 " \"endAction\": \"BAKE\","
321 " \"disconnectAction\": \"BAKE\","
324 " \"actor\": \"{NAME}\","
325 " \"property\": \"positioninvalid\","
326 " \"value\": [300, 300, -1000],"
327 " \"alphaFunction\": \"EGGS_OVER_EASY\","
328 " \"relative\": true,"
336 " \"pathAnimation\": {"
337 " \"duration\": 3.0,"
338 " \"endAction\": \"DISCARD\","
339 " \"disconnectAction\": \"BAKE_FINAL\","
340 " \"properties\": [{"
341 " \"actor\": \"greeting\","
342 " \"path\":\"pathDoesntExist\","
343 " \"forward\":[1,0,0],"
344 " \"alphaFunction\": \"EASE_IN_OUT\","
353 " \"name\": \"greeting\","
354 " \"type\": \"TextLabel\","
355 " \"text\": \"Touch me\","
356 " \"styles\": [\"basicText\"],"
357 " \"position\": [0, -120, 0],"
358 " \"size\": [200, 200, 1],"
359 " \"orientation\": [0, 0, 30],"
361 " \"name\": \"touched\","
362 " \"action\": \"play\","
363 " \"animation\": \"animate\""
367 " \"name\": \"greeting2\","
368 " \"type\": \"TextLabel\","
369 " \"text\": \"Touch me\""
374 Builder builder = Builder::New();
375 builder.LoadFromString( json );
376 builder.AddActors( Stage::GetCurrent().GetRootLayer() );
378 Animation anim = builder.CreateAnimation("animate");
380 // log warning line coverage
381 anim = builder.CreateAnimation("pathAnimation");
382 DALI_TEST_CHECK(anim);
384 anim = builder.CreateAnimation("animate");
385 DALI_TEST_CHECK(anim);
387 anim = builder.CreateAnimation("animate2");
388 DALI_TEST_CHECK(anim);
390 // create referencing a different actor aka animation templates
392 map["NAME"] = "greeting2";
393 anim = builder.CreateAnimation("animate2", map);
394 DALI_TEST_CHECK(anim);
396 // alternative actor to use for FindChildByName
397 anim = builder.CreateAnimation("animate2", Dali::Stage::GetCurrent().GetRootLayer());
398 DALI_TEST_CHECK(anim);
400 // alternative actor to use for FindChildByName
401 anim = builder.CreateAnimation("animate2", map, Dali::Stage::GetCurrent().GetRootLayer());
402 DALI_TEST_CHECK(anim);
409 int UtcDaliBuilderConstantsP(void)
411 ToolkitTestApplication application;
413 // JSON with a quit event when the actor is touched
418 " \"IMAGE_PATH\": \"apath\","
420 " \"ANCHOR\": \"TOP_LEFT\","
421 " \"PADDING\": [1,2,3,4]"
425 " \"type\": \"ImageActor\","
426 " \"name\": \"{NAME}\","
427 " \"size\": [100,100,1],"
428 " \"parentOrigin\": \"TOP_LEFT\","
429 " \"anchorPoint\": \"{ANCHOR}\","
430 " \"padding\": \"{PADDING}\","
431 " \"image\": { \"filename\": \"dir/{IMAGE_PATH}\" },"
432 " \"sizeWidth\": \"{WIDTH}\","
434 " \"name\": \"touched\","
435 " \"action\": \"quit\""
441 Builder builder = Builder::New();
442 builder.LoadFromString( json );
444 builder.AddConstant( "NAME", "image" );
446 Property::Map map = builder.GetConstants();
448 Dali::Property::Value* pValue = map.Find( "NAME" );
450 DALI_TEST_CHECK( pValue );
452 pValue = map.Find( "IMAGE_PATH" );
454 DALI_TEST_CHECK( pValue );
456 Dali::Property::Value value = builder.GetConstant( "WIDTH" );
458 DALI_TEST_CHECK( value.GetType() != Property::NONE );
460 builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
461 DALI_TEST_CHECK( builder );
463 Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("image");
464 DALI_TEST_CHECK( actor );
469 int UtcDaliBuilderTemplatesAndStylesP(void)
471 ToolkitTestApplication application;
473 // JSON with a quit event when the actor is touched
478 " \"SIZE\": [10,20,30]"
482 " \"imageStyle\": \n"
484 " \"color\": [1,0,0,1],\n"
486 " \"childImage\": {\n"
487 " \"color\": [0,1,0,1]\n"
494 " \"imageTree\": { \n"
495 " \"type\": \"ImageActor\",\n"
496 " \"styles\": [\"imageStyle\"],\n"
497 " \"name\": \"image\",\n"
498 " \"size\": \"{SIZE}\",\n"
500 " \"name\": \"touched\",\n"
501 " \"action\": \"quit\"\n"
505 " \"type\":\"ImageActor\",\n"
506 " \"name\":\"childImage\" \n"
513 " \"type\": \"imageTree\","
514 " \"size\": [100,100,1]"
519 std::string stylejson(
521 " \"color\": [1,0,0,1],\n"
523 " \"childImage\": {\n"
524 " \"color\": [0,1,0,1]\n"
530 std::string templatejson(
532 " \"type\": \"ImageActor\",\n"
533 " \"styles\": [\"imageStyle\"],\n"
534 " \"name\": \"image\",\n"
535 " \"size\": \"{SIZE}\",\n"
537 " \"name\": \"touched\",\n"
538 " \"action\": \"quit\"\n"
542 " \"type\":\"ImageActor\",\n"
543 " \"name\":\"childImage\" \n"
549 Builder builder = Builder::New();
550 builder.LoadFromString( json );
552 ImageActor actor = ImageActor::DownCast( builder.Create( "imageTree" ) );
553 DALI_TEST_CHECK( actor );
555 Dali::Property::Map map;
556 map["SIZE"] = Vector3(100,100,1);
557 actor = ImageActor::DownCast( builder.Create( "imageTree", map ) );
558 DALI_TEST_CHECK( actor );
560 // create from json snippet
561 actor = ImageActor::DownCast( builder.CreateFromJson( templatejson ) );
562 DALI_TEST_CHECK( actor );
565 // NB: already applied in create
566 DALI_TEST_CHECK( builder.ApplyStyle( "imageStyle", actor ) );
568 // apply from json snippet
569 DALI_TEST_CHECK( builder.ApplyFromJson( actor, stylejson ) );
574 int UtcDaliBuilderRenderTasksP(void)
576 ToolkitTestApplication application;
578 // JSON with a quit event when the actor is touched
584 " \"sourceActor\": \"image\",\n"
585 " \"cameraActor\": \"camera\" \n"
591 " \"type\": \"CameraActor\",\n"
592 " \"name\": \"image\"\n"
595 " \"type\": \"ImageActor\",\n"
596 " \"name\": \"image\",\n"
597 " \"size\": [100,100,1],\n"
599 " \"name\": \"touched\",\n"
600 " \"action\": \"quit\"\n"
604 " \"type\":\"ImageActor\",\n"
605 " \"name\":\"childImage\" \n"
613 Builder builder = Builder::New();
614 builder.LoadFromString( json );
616 unsigned int count = Stage::GetCurrent().GetRenderTaskList().GetTaskCount();
619 builder.CreateRenderTask( "task0" );
621 DALI_TEST_CHECK( count <
622 Stage::GetCurrent().GetRenderTaskList().GetTaskCount() );
627 int UtcDaliBuilderChildActionP(void)
629 ToolkitTestApplication application;
631 // JSON with a quit event when the actor is touched
636 " \"type\": \"Actor\",\n"
637 " \"name\": \"actor\",\n"
638 " \"size\": [100,100,1],\n"
639 " \"parentOrigin\": \"TOP_LEFT\",\n"
640 " \"anchorPoint\": \"TOP_LEFT\",\n"
642 " \"type\": \"Actor\",\n"
643 " \"name\": \"subActor\"\n"
646 " \"name\": \"touched\",\n"
647 " \"action\": \"hide\",\n"
648 " \"actor\": \"actor\",\n"
649 " \"childActor\": \"subActor\"\n"
655 Builder builder = Builder::New();
656 builder.LoadFromString( json );
657 builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
660 application.SendNotification();
661 application.Render();
663 // Emit touch event and check that our quit method is called
664 Integration::TouchEvent touchEvent;
665 touchEvent.points.push_back( TouchPoint ( 0, TouchPoint::Down, 10.0f, 10.0f ) );
666 application.ProcessEvent( touchEvent );
669 application.SendNotification();
670 application.Render();
672 Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("subActor");
673 DALI_TEST_CHECK( actor );
675 DALI_TEST_CHECK( !actor.IsVisible() );
680 int UtcDaliBuilderSetPropertyActionP(void)
682 ToolkitTestApplication application;
684 // JSON with a quit event when the actor is touched
689 " \"type\": \"Actor\",\n"
690 " \"name\": \"actor\",\n"
691 " \"size\": [100,100,1],\n"
692 " \"parentOrigin\": \"TOP_LEFT\",\n"
693 " \"anchorPoint\": \"TOP_LEFT\",\n"
695 " \"type\": \"Actor\",\n"
696 " \"name\": \"subActor\"\n"
699 " \"name\": \"touched\",\n"
700 " \"action\": \"set\",\n"
701 " \"actor\": \"subActor\",\n"
702 " \"property\": \"visible\",\n"
703 " \"value\": false\n"
709 Builder builder = Builder::New();
710 builder.LoadFromString( json );
711 builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
714 application.SendNotification();
715 application.Render();
717 // Emit touch event and check that our quit method is called
718 Integration::TouchEvent touchEvent;
719 touchEvent.points.push_back( TouchPoint ( 0, TouchPoint::Down, 10.0f, 10.0f ) );
720 application.ProcessEvent( touchEvent );
723 application.SendNotification();
724 application.Render();
726 Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("subActor");
727 DALI_TEST_CHECK( actor );
729 DALI_TEST_CHECK( !actor.IsVisible() );
734 int UtcDaliBuilderGenericActionP(void)
736 ToolkitTestApplication application;
738 // JSON with a quit event when the actor is touched
743 " \"type\": \"Actor\",\n"
744 " \"name\": \"actor\",\n"
745 " \"size\": [100,100,1],\n"
746 " \"parentOrigin\": \"TOP_LEFT\",\n"
747 " \"anchorPoint\": \"TOP_LEFT\",\n"
749 " \"type\": \"Actor\",\n"
750 " \"name\": \"subActor\"\n"
753 " \"name\": \"touched\",\n"
754 " \"action\": \"hide\"\n"
760 Builder builder = Builder::New();
761 builder.LoadFromString( json );
762 builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
765 application.SendNotification();
766 application.Render();
768 // Emit touch event and check that our quit method is called
769 Integration::TouchEvent touchEvent;
770 touchEvent.points.push_back( TouchPoint ( 0, TouchPoint::Down, 10.0f, 10.0f ) );
771 application.ProcessEvent( touchEvent );
774 application.SendNotification();
775 application.Render();
777 Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("actor");
778 DALI_TEST_CHECK( actor );
780 DALI_TEST_CHECK( !actor.IsVisible() );
785 int UtcDaliBuilderPropertyNotificationP(void)
787 ToolkitTestApplication application;
789 // JSON with a quit event when the actor is touched
794 " \"type\": \"Actor\",\n"
795 " \"name\": \"actor\",\n"
796 " \"size\": [100,100,1],\n"
797 " \"parentOrigin\": \"TOP_LEFT\",\n"
798 " \"anchorPoint\": \"TOP_LEFT\",\n"
800 " \"type\": \"Actor\",\n"
801 " \"name\": \"subActor\"\n"
804 " \"name\": \"touched\",\n"
805 " \"action\": \"hide\"\n"
807 " \"notifications\": [{\n"
808 " \"property\": \"visible\",\n"
809 " \"condition\": \"False\",\n"
810 " \"action\": \"show\"\n"
816 Builder builder = Builder::New();
817 builder.LoadFromString( json );
818 builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
821 application.SendNotification();
822 application.Render();
824 // Emit touch event and check that our quit method is called
825 Integration::TouchEvent touchEvent;
826 touchEvent.points.push_back( TouchPoint ( 0, TouchPoint::Down, 10.0f, 10.0f ) );
827 application.ProcessEvent( touchEvent );
830 application.SendNotification();
831 application.Render();
834 application.SendNotification();
835 application.Render();
837 Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("actor");
838 DALI_TEST_CHECK( actor );
840 DALI_TEST_CHECK( actor.IsVisible() );
845 int UtcDaliBuilderCustomPropertyP(void)
847 ToolkitTestApplication application;
849 // JSON with a quit event when the actor is touched
854 " \"imageTree\": { \n"
855 " \"type\": \"ImageActor\",\n"
856 " \"name\": \"image\",\n"
857 " \"size\": [100,100,1],\n"
859 " \"name\": \"touched\",\n"
860 " \"action\": \"quit\"\n"
862 " \"customProperties\": {\n"
863 " \"newproperty\": true\n"
867 " \"type\":\"ImageActor\",\n"
868 " \"name\":\"childImage\" \n"
876 Builder builder = Builder::New();
877 builder.LoadFromString( json );
879 ImageActor actor = ImageActor::DownCast( builder.Create( "imageTree" ) );
880 DALI_TEST_CHECK( actor );
882 // NB: already applied in create
883 Property::Index index = actor.GetPropertyIndex("newproperty");
884 DALI_TEST_CHECK( Property::INVALID_INDEX != index );
885 Property::Value value = actor.GetProperty(index);
886 DALI_TEST_CHECK( value.Get<bool>() == true );
891 int UtcDaliBuilderShaderEffectP(void)
893 ToolkitTestApplication application;
895 // JSON with a quit event when the actor is touched
900 " \"type\": \"ImageActor\",\n"
901 " \"name\": \"Image1\",\n"
903 " 0.40461349487305,\n"
907 " \"parentOrigin\": [0.5, 0.5, 0.5],\n"
908 " \"size\": [200, 200, 0],\n"
909 " \"effect\": \"Ripple2D\",\n"
911 " \"filename\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\",\n"
914 " \"loadPolicy\": \"IMMEDIATE\",\n"
915 " \"releasePolicy\": \"NEVER\"\n"
919 " \"name\": \"onStage\",\n"
920 " \"action\": \"play\",\n"
921 " \"animation\": \"Animation_1\"\n"
927 " \"animations\": {\n"
928 " \"Animation_1\": {\n"
930 " \"properties\": [\n"
932 " \"actor\": \"Image1\",\n"
933 " \"property\": \"uTime\",\n"
934 " \"value\": 10.0,\n"
935 " \"alphaFunction\": \"LINEAR\",\n"
936 " \"timePeriod\": {\n"
938 " \"duration\": 10.0\n"
940 " \"gui-builder-timeline-color\": \"#8dc0da\"\n"
945 " \"shaderEffects\": {\n"
948 " \"vertexPrefix\": \"\",\n"
949 " \"vertex\": \"void main(void)\\n{\\n gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\\n vTexCoord = aTexCoord;\\n}\\n\\n\",\n"
950 " \"fragmentPrefix\": \"\",\n"
951 " \"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"
952 " \"geometryType\": \"GEOMETRY_TYPE_IMAGE\"\n"
954 " \"geometryHints\": \"HINT_NONE\",\n"
955 " \"gridDensity\": 0,\n"
957 " \"uAmplitude\": 0.02,\n"
965 Builder builder = Builder::New();
966 builder.LoadFromString( json );
968 ShaderEffect effect = builder.GetShaderEffect("Ripple2D");
971 DALI_TEST_CHECK( effect );
977 int UtcDaliBuilderLoadFromStringN(void)
979 ToolkitTestApplication application;
981 // JSON with a quit event when the actor is touched
983 "asdfsadf dsf asdf asdf {"
986 "\"type\": \"Actor\","
987 "\"size\": [100,100,1],"
988 "\"parentOrigin\": \"TOP_LEFT\","
989 "\"anchorPoint\": \"TOP_LEFT\","
991 "\"name\": \"touched\","
992 "\"action\": \"quit\""
997 Builder builder = Builder::New();
999 bool assert1 = false;
1003 builder.LoadFromString( json );
1005 catch( Dali::DaliException& e )
1007 DALI_TEST_PRINT_ASSERT( e );
1008 DALI_TEST_EQUALS(e.condition, "!\"Cannot parse JSON\"", TEST_LOCATION);
1012 DALI_TEST_CHECK( assert1 );
1017 int UtcDaliBuilderShaderEffect2P(void)
1019 ToolkitTestApplication application;
1021 // JSON with a quit event when the actor is touched
1026 " \"imageTree\": { \n"
1027 " \"type\": \"ImageActor\",\n"
1028 " \"size\": [100,100,1],\n"
1029 " \"parentOrigin\": [0.5, 0.5, 0.5],\n"
1030 " \"position\": [\n"
1031 " 0.40461349487305,\n"
1035 " \"signals\": [{\n"
1036 " \"name\": \"touched\",\n"
1037 " \"action\": \"quit\"\n"
1041 " \"type\":\"ImageActor\",\n"
1042 " \"name\":\"childImage\" \n"
1049 " \"type\": \"imageTree\",\n"
1050 " \"name\": \"Image1\",\n"
1051 " \"effect\": \"Ripple2D\",\n"
1052 " \"image\": \"offscreen\""
1055 " \"shaderEffects\": {\n"
1056 " \"Ripple2D\": {\n"
1058 " \"vertexPrefix\": \"\",\n"
1059 " \"vertex\": \"void main(void)\\n{\\n gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\\n vTexCoord = aTexCoord;\\n}\\n\\n\",\n"
1060 " \"fragmentPrefix\": \"\",\n"
1061 " \"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"
1062 " \"geometryType\": \"GEOMETRY_TYPE_IMAGE\"\n"
1064 " \"geometryHints\": \"HINT_NONE\",\n"
1065 " \"gridDensity\": 0,\n"
1066 " \"loop\": true,\n"
1067 " \"uAmplitude\": 0.02,\n"
1071 " \"frameBufferImages\": {\n"
1072 " \"offscreen\": {\n"
1073 " \"type\": \"FrameBufferImage\","
1074 " \"pixelFormat\":\"RGBA8888\","
1083 Builder builder = Builder::New();
1084 builder.LoadFromString( json );
1087 DALI_TEST_CHECK( true );
1092 int UtcDaliBuilderAddActorsP(void)
1094 ToolkitTestApplication application;
1096 // JSON with a quit event when the actor is touched
1099 " \"arbitarysection\":\n"
1101 " \"type\": \"Actor\",\n"
1102 " \"name\": \"actor\",\n"
1103 " \"size\": [100,100,1],\n"
1104 " \"parentOrigin\": \"TOP_LEFT\",\n"
1105 " \"anchorPoint\": \"TOP_LEFT\",\n"
1107 " \"type\": \"Actor\",\n"
1108 " \"name\": \"subActor\",\n"
1109 " \"visible\": false\n"
1111 " \"signals\": [{\n"
1112 " \"name\": \"touched\",\n"
1113 " \"action\": \"hide\",\n"
1114 " \"actor\": \"actor\",\n"
1115 " \"childActor\": \"subActor\"\n"
1121 Builder builder = Builder::New();
1122 builder.LoadFromString( json );
1123 builder.AddActors ( "arbitarysection", Stage::GetCurrent().GetRootLayer() );
1125 // Render and notify
1126 application.SendNotification();
1127 application.Render();
1129 Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("subActor");
1130 DALI_TEST_CHECK( actor );
1132 DALI_TEST_CHECK( !actor.IsVisible() );
1137 int UtcDaliBuilderFrameBufferP(void)
1139 ToolkitTestApplication application;
1141 // JSON with a quit event when the actor is touched
1146 " \"FB_WIDTH\": 200.0,\n"
1147 " \"FB_HEIGHT\": 200.0,\n"
1148 " \"FB_SIZE\": [200,200],\n"
1149 " \"FB_ASPECT_RATIO\": 1\n"
1153 " \"type\": \"ImageActor\",\n"
1154 " \"name\": \"fbOnStage\",\n"
1155 " \"position\": [\n"
1156 " 0.40461349487305,\n"
1160 " \"parentOrigin\": [0.5, 0.5, 0.5],\n"
1161 " \"size\": [300, 300, 0],\n"
1162 " \"image\": \"fb0\",\n"
1163 " \"clearColor\": [1,0,0,1]\n"
1166 " \"type\": \"ImageActor\",\n"
1167 " \"name\": \"Image1\",\n"
1168 " \"size\": [200, 200, 0],\n"
1169 " \"parentOrigin\": [0.5, 0.5, 0.5],\n"
1170 " \"effect\": \"Ripple2D\",\n"
1172 " \"filename\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\",\n"
1173 " \"width\": 200,\n"
1174 " \"height\": 80,\n"
1175 " \"loadPolicy\": \"IMMEDIATE\",\n"
1176 " \"releasePolicy\": \"NEVER\"\n"
1180 " \"name\": \"onStage\",\n"
1181 " \"action\": \"play\",\n"
1182 " \"animation\": \"Animation_1\"\n"
1187 " \"type\":\"CameraActor\",\n"
1188 " \"name\":\"fbCam\",\n"
1189 " \"aspectRatio\": \"{FB_ASPECT_RATIO}\",\n"
1190 " \"projectionMode\": \"PERSPECTIVE_PROJECTION\",\n"
1191 " \"fieldOfView\": 0.785,\n"
1192 " \"invertYAxis\": true\n"
1195 " \"frameBufferImages\":\n"
1199 " \"type\": \"FrameBufferImage\",\n"
1200 " \"width\": { \"typeCast\":\"float\", \"value\":\"{FB_WIDTH}\" },\n"
1201 " \"height\": { \"typeCast\":\"float\", \"value\":\"{FB_HEIGHT}\" }\n"
1204 " \"renderTasks\":\n"
1209 " \"sourceActor\": \"fbOnStage\"\n"
1212 " \"sourceActor\": \"Image1\",\n"
1213 " \"targetFrameBuffer\": \"fb0\",\n"
1214 " \"viewportSize\":\"{FB_SIZE}\",\n"
1215 " \"cameraActor\":\"fbCam\"\n"
1220 " \"animations\": {\n"
1221 " \"Animation_1\": {\n"
1223 " \"properties\": [\n"
1225 " \"actor\": \"Image1\",\n"
1226 " \"property\": \"uTime\",\n"
1227 " \"value\": 10.0,\n"
1228 " \"alphaFunction\": \"LINEAR\",\n"
1229 " \"timePeriod\": {\n"
1231 " \"duration\": 10.0\n"
1233 " \"gui-builder-timeline-color\": \"#8dc0da\"\n"
1238 " \"shaderEffects\": {\n"
1239 " \"Ripple2D\": {\n"
1241 " \"vertexPrefix\": \"\",\n"
1242 " \"vertex\": \"void main(void)\\n{\\n gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\\n vTexCoord = aTexCoord;\\n}\\n\\n\",\n"
1243 " \"fragmentPrefix\": \"\",\n"
1244 " \"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"
1245 " \"geometryType\": \"GEOMETRY_TYPE_IMAGE\"\n"
1247 " \"geometryHints\": \"HINT_NONE\",\n"
1248 " \"gridDensity\": 0,\n"
1249 " \"loop\": true,\n"
1250 " \"uAmplitude\": 0.02,\n"
1256 Builder builder = Builder::New();
1258 // frame buffer coverage
1259 builder.LoadFromString( json );
1261 // Render and notify
1262 application.SendNotification();
1263 application.Render();
1265 Dali::FrameBufferImage frameBuffer = builder.GetFrameBufferImage( "fb0" );
1266 DALI_TEST_CHECK( frameBuffer );
1268 Dali::FrameBufferImage frameBuffer2 = builder.GetFrameBufferImage( "fb0" );
1269 DALI_TEST_CHECK( frameBuffer2 );
1270 DALI_TEST_CHECK( frameBuffer == frameBuffer2 );
1272 DALI_TEST_CHECK( true );
1277 int UtcDaliBuilderPathConstraintsP(void)
1279 ToolkitTestApplication application;
1281 // JSON with a quit event when the actor is touched
1286 " \"FB_WIDTH\": 200.0,\n"
1287 " \"FB_HEIGHT\": 200.0,\n"
1288 " \"FB_SIZE\": [200,200],\n"
1289 " \"FB_ASPECT_RATIO\": 1\n"
1293 " \"type\": \"ImageActor\",\n"
1294 " \"name\": \"Image1\",\n"
1295 " \"size\": [200, 200, 0],\n"
1296 " \"parentOrigin\": [0.5, 0.5, 0.5],\n"
1297 " \"effect\": \"Ripple2D\",\n"
1299 " \"filename\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\",\n"
1300 " \"width\": 200,\n"
1301 " \"height\": 80,\n"
1302 " \"loadPolicy\": \"IMMEDIATE\",\n"
1303 " \"releasePolicy\": \"NEVER\"\n"
1307 " \"name\": \"onStage\",\n"
1308 " \"action\": \"play\",\n"
1309 " \"animation\": \"pathAnimation\"\n"
1312 " \"name\": \"onStage\",\n"
1313 " \"action\": \"applyConstraint\",\n"
1314 " \"constrainer\": \"constrainer0\",\n"
1315 " \"properties\":\n"
1318 " \"source\": \"Image1\",\n"
1319 " \"sourceProperty\": \"positionX\",\n"
1320 " \"target\": \"Image1\",\n"
1321 " \"targetProperty\": \"colorRed\",\n"
1322 " \"range\": [-300,300]\n"
1327 " \"name\": \"onStage\",\n"
1328 " \"action\": \"applyConstraint\",\n"
1329 " \"constrainer\": \"constrainer1\",\n"
1330 " \"properties\":\n"
1333 " \"source\": \"Image1\",\n"
1334 " \"sourceProperty\": \"positionX\",\n"
1335 " \"target\": \"Image1\",\n"
1336 " \"targetProperty\": \"colorBlue\",\n"
1337 " \"range\": [-300,300]\n"
1348 " \"points\":[ [-150, -50, 0], [0.0,70.0,0.0], [190.0,-150.0,0.0] ],\n"
1349 " \"curvature\":0.35\n"
1352 " \"constrainers\":\n"
1354 " \"constrainer0\":\n"
1356 " \"type\": \"PathConstrainer\",\n"
1357 " \"points\": [ [0, 0, 0], [0,0,0], [0,0,0] ],\n"
1358 " \"controlPoints\": [ [0, 0, 0], [0,0,0], [0,0,0] ]\n"
1360 " \"constrainer1\":\n"
1362 " \"type\": \"LinearConstrainer\",\n"
1363 " \"value\": [ 0, 0, 0 ]\n"
1366 " \"animations\": {\n"
1367 " \"pathAnimation\": {\n"
1368 " \"duration\": 3.0,\n"
1369 " \"properties\":\n"
1371 " \"actor\": \"Image1\",\n"
1372 " \"path\":\"path0\",\n"
1373 " \"forward\":[1,0,0],\n"
1374 " \"alphaFunction\": \"EASE_IN_OUT\",\n"
1375 " \"timePeriod\": {\n"
1377 " \"duration\": 3\n"
1381 " \"actor\": \"Image1\",\n"
1382 " \"property\": \"uTime\",\n"
1383 " \"value\": 10.0,\n"
1384 " \"alphaFunction\": \"LINEAR\",\n"
1385 " \"timePeriod\": {\n"
1387 " \"duration\": 10.0\n"
1389 " \"gui-builder-timeline-color\": \"#8dc0da\"\n"
1392 " \"Animation_1\": {\n"
1394 " \"properties\": [\n"
1396 " \"actor\": \"Image1\",\n"
1397 " \"property\": \"uTime\",\n"
1398 " \"value\": 10.0,\n"
1399 " \"alphaFunction\": \"LINEAR\",\n"
1400 " \"timePeriod\": {\n"
1402 " \"duration\": 10.0\n"
1404 " \"gui-builder-timeline-color\": \"#8dc0da\"\n"
1409 " \"shaderEffects\": {\n"
1410 " \"Ripple2D\": {\n"
1412 " \"vertexPrefix\": \"\",\n"
1413 " \"vertex\": \"void main(void)\\n{\\n gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\\n vTexCoord = aTexCoord;\\n}\\n\\n\",\n"
1414 " \"fragmentPrefix\": \"\",\n"
1415 " \"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"
1416 " \"geometryType\": \"GEOMETRY_TYPE_IMAGE\"\n"
1418 " \"geometryHints\": \"HINT_NONE\",\n"
1419 " \"gridDensity\": 0,\n"
1420 " \"loop\": true,\n"
1421 " \"uAmplitude\": 0.02,\n"
1427 Builder builder = Builder::New();
1429 // frame buffer coverage
1430 builder.LoadFromString( json );
1432 // Render and notify
1433 application.SendNotification();
1434 application.Render();
1436 Dali::Path path = builder.GetPath( "path0" );
1437 DALI_TEST_CHECK( path );
1439 Dali::Path path2 = builder.GetPath( "path0" );
1440 DALI_TEST_CHECK( path2 );
1441 DALI_TEST_CHECK( path == path2 );
1443 Dali::PathConstrainer constrainer0 = builder.GetPathConstrainer( "constrainer0" );
1444 DALI_TEST_CHECK( constrainer0 );
1446 Dali::PathConstrainer constrainer0_2 = builder.GetPathConstrainer( "constrainer0" );
1447 DALI_TEST_CHECK( constrainer0_2 );
1448 DALI_TEST_CHECK( constrainer0 == constrainer0_2 );
1450 Dali::LinearConstrainer constrainer1 = builder.GetLinearConstrainer( "constrainer1" );
1451 DALI_TEST_CHECK( constrainer1 );
1453 Dali::LinearConstrainer constrainer1_2 = builder.GetLinearConstrainer( "constrainer1" );
1454 DALI_TEST_CHECK( constrainer1 == constrainer1_2 );