Dali 3D User Interface Engine
utc-Dali-Builder.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 
18 #include <iostream>
19 #include <stdlib.h>
23 
24 #define STRINGIFY(A)#A
25 
26 using namespace Dali;
27 using namespace Toolkit;
28 
29 namespace
30 {
31 
32 std::string ReplaceQuotes(const std::string &in_s)
33 {
34  std::string s(in_s);
35  // wrong as no embedded quote but had regex link problems
36  std::replace(s.begin(), s.end(), '\'', '"');
37  return s;
38 }
39 
41 {
42  BuilderFunctor( bool& called ) : mCalled( called )
43  {
44  mCalled = false;
45  }
46 
47  void operator()()
48  {
49  mCalled = true;
50  }
51 
52  bool& mCalled;
53 };
54 
55 } // namespace
56 
57 
58 
59 void builder_startup(void)
60 {
62 }
63 
64 void builder_cleanup(void)
65 {
67 }
68 
70 {
71  ToolkitTestApplication application;
72 
73  // JSON with a quit event when the actor is touched
74  std::string json(
75  "{"
76  "\"stage\":"
77  "[{"
78  "\"type\": \"Actor\","
79  "\"size\": [100,100,1],"
80  "\"parentOrigin\": \"TOP_LEFT\","
81  "\"anchorPoint\": \"TOP_LEFT\","
82  "\"signals\": [{"
83  "\"name\": \"touched\","
84  "\"action\": \"quit\""
85  "}]"
86  "}]"
87  "}"
88  );
89  Builder builder = Builder::New();
90  builder.LoadFromString( json );
91  builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
92 
93  // Connect to builder's quit signal
94  bool functorCalled( false );
95  builder.QuitSignal().Connect( &application, BuilderFunctor( functorCalled ) );
96 
97  // Render and notify
98  application.SendNotification();
99  application.Render();
100 
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 );
106 
107  END_TEST;
108 }
109 
110 
112 {
113  ToolkitTestApplication application;
114 
115  // JSON with a quit event when the actor is touched
116  std::string json(
117  "{"
118  " \"constants\":"
119  " {"
120  " \"ALPHA_FUNCTION\":\"EASE_IN_OUT\""
121  " },"
122  " \"paths\":"
123  " {"
124  " \"path0\":"
125  " {"
126  " \"points\":[ [-150, -50, 0], [0.0,70.0,0.0], [190.0,-150.0,0.0] ],"
127  " \"curvature\":0.35"
128  " }"
129  " },"
130  " \"animations\": {"
131  " \"animate\": {"
132  " \"loop\": true,"
133  " \"endAction\": \"BAKE\","
134  " \"disconnectAction\": \"BAKE\","
135  " \"properties\":"
136  " [{"
137  " \"actor\": \"greeting\","
138  " \"property\": \"position\","
139  " \"value\": [300, 300, -1000],"
140  " \"alphaFunction\": \"{ALPHA_FUNCTION}\","
141  " \"relative\": true,"
142  " \"timePeriod\": {"
143  " \"delay\": 0,"
144  " \"duration\": 3"
145  " }"
146  " },"
147  " {"
148  " \"actor\": \"greeting\","
149  " \"property\": \"visible\","
150  " \"alphaFunction\": \"LINEAR\","
151  " \"value\": true"
152  " },"
153  " {"
154  " \"actor\": \"greeting\","
155  " \"property\": \"sizeWidth\","
156  " \"alphaFunction\": \"REVERSE\","
157  " \"value\": 10.0"
158  " },"
159  " {"
160  " \"actor\": \"greeting\","
161  " \"property\": \"orientation\","
162  " \"alphaFunction\": \"EASE_IN\","
163  " \"value\": [10.0,20.0,30.0]"
164  " },"
165  " {"
166  " \"actor\": \"greeting\","
167  " \"property\": \"orientation\","
168  " \"alphaFunction\": \"EASE_OUT\","
169  " \"value\": [0.0, 0.0, 0.0, 1.0]"
170  " },"
171  " {"
172  " \"actor\": \"greeting\","
173  " \"property\": \"orientation\","
174  " \"alphaFunction\": \"EASE_IN_OUT\","
175  " \"value\": [0.0, 0.0, 0.0, 1.0]"
176  " },"
177  " {"
178  " \"actor\": \"greeting\","
179  " \"property\": \"orientation\","
180  " \"alphaFunction\": \"EASE_IN_SINE\","
181  " \"value\": [0.0, 0.0, 0.0, 1.0]"
182  " },"
183  " {"
184  " \"actor\": \"greeting\","
185  " \"property\": \"orientation\","
186  " \"alphaFunction\": \"EASE_OUT_SINE\","
187  " \"value\": [0.0, 0.0, 0.0, 1.0]"
188  " },"
189  " {"
190  " \"actor\": \"greeting\","
191  " \"property\": \"orientation\","
192  " \"alphaFunction\": \"EASE_IN_OUT_SINE\","
193  " \"value\": [0.0, 0.0, 0.0, 1.0]"
194  " },"
195  " {"
196  " \"actor\": \"greeting\","
197  " \"property\": \"orientation\","
198  " \"alphaFunction\": \"BOUNCE\","
199  " \"value\": [0.0, 0.0, 0.0, 1.0]"
200  " },"
201  " {"
202  " \"actor\": \"greeting\","
203  " \"property\": \"orientation\","
204  " \"alphaFunction\": \"SIN\","
205  " \"value\": [0.0, 0.0, 0.0, 1.0]"
206  " },"
207  " {"
208  " \"actor\": \"greeting\","
209  " \"property\": \"orientation\","
210  " \"alphaFunction\": \"EASE_OUT_BACK\","
211  " \"value\": [0.0, 0.0, 0.0, 1.0]"
212  " }"
213  " ]"
214  " },"
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\","
224  " \"timePeriod\": {"
225  " \"delay\": 0,"
226  " \"duration\": 3"
227  " }"
228  " }]"
229  " }"
230  " },"
231  " \"stage\": [{"
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],"
239  " \"signals\": [{"
240  " \"name\": \"touched\","
241  " \"action\": \"play\","
242  " \"animation\": \"animate\""
243  " }]"
244  " }]"
245  "}");
246 
247  Builder builder = Builder::New();
248  builder.LoadFromString( json );
249  builder.AddActors( Stage::GetCurrent().GetRootLayer() );
250 
251  Animation anim = builder.CreateAnimation("animate");
252 
253  DALI_TEST_CHECK( anim );
254 
255  Property::Map map;
256  map["ALPHA_FUNCTION"] = "EASE_IN_SQUARE";
257  anim = builder.CreateAnimation("animate", map);
258 
259  DALI_TEST_CHECK( anim );
260 
261  anim = builder.CreateAnimation("pathAnimation");
262 
263  DALI_TEST_CHECK( anim );
264 
265  // trigger play
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 );
270 
271  // Render and notify
272  application.SendNotification();
273  application.Render();
274 
275 
276  END_TEST;
277 }
278 
280 {
281  ToolkitTestApplication application;
282 
283  // JSON with a quit event when the actor is touched
284  std::string json(
285  "{"
286  " \"constants\":"
287  " {"
288  " \"TEXT\": \"Touch Me\","
289  " \"NAME\": \"greeting\" "
290  " },"
291  " \"paths\":"
292  " {"
293  " \"path0\":"
294  " {"
295  " \"points\":[ [-150, -50, 0], [0.0,70.0,0.0], [190.0,-150.0,0.0] ],"
296  " \"curvature\":0.35"
297  " }"
298  " },"
299  " \"animations\": {"
300  " \"animate\": {"
301  " \"loop\": true,"
302  " \"endAction\": \"BAKE\","
303  " \"disconnectAction\": \"BAKE\","
304  " \"properties\":"
305  " [{"
306  " \"actor\": \"{NAME}\","
307  " \"property\": \"positioninvalid\","
308  " \"value\": [300, 300, -1000],"
309  " \"alphaFunction\": \"EASE_IN_OUT\","
310  " \"relative\": true,"
311  " \"timePeriod\": {"
312  " \"delay\": 0,"
313  " \"duration\": 3"
314  " }"
315  " }"
316  " ]"
317  " },"
318  " \"animate2\": {"
319  " \"loop\": true,"
320  " \"endAction\": \"BAKE\","
321  " \"disconnectAction\": \"BAKE\","
322  " \"properties\":"
323  " [{"
324  " \"actor\": \"{NAME}\","
325  " \"property\": \"positioninvalid\","
326  " \"value\": [300, 300, -1000],"
327  " \"alphaFunction\": \"EGGS_OVER_EASY\","
328  " \"relative\": true,"
329  " \"timePeriod\": {"
330  " \"delay\": 0,"
331  " \"duration\": 3"
332  " }"
333  " }"
334  " ]"
335  " },"
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\","
345  " \"timePeriod\": {"
346  " \"delay\": 0,"
347  " \"duration\": 3"
348  " }"
349  " }]"
350  " }"
351  " },"
352  " \"stage\": [{"
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],"
360  " \"signals\": [{"
361  " \"name\": \"touched\","
362  " \"action\": \"play\","
363  " \"animation\": \"animate\""
364  " }]"
365  " },"
366  " {"
367  " \"name\": \"greeting2\","
368  " \"type\": \"TextLabel\","
369  " \"text\": \"Touch me\""
370  " }]"
371  "}");
372 
373 
374  Builder builder = Builder::New();
375  builder.LoadFromString( json );
376  builder.AddActors( Stage::GetCurrent().GetRootLayer() );
377 
378  Animation anim = builder.CreateAnimation("animate");
379 
380  // log warning line coverage
381  anim = builder.CreateAnimation("pathAnimation");
382  DALI_TEST_CHECK(anim);
383 
384  anim = builder.CreateAnimation("animate");
385  DALI_TEST_CHECK(anim);
386 
387  anim = builder.CreateAnimation("animate2");
388  DALI_TEST_CHECK(anim);
389 
390  // create referencing a different actor aka animation templates
391  Property::Map map;
392  map["NAME"] = "greeting2";
393  anim = builder.CreateAnimation("animate2", map);
394  DALI_TEST_CHECK(anim);
395 
396  // alternative actor to use for FindChildByName
397  anim = builder.CreateAnimation("animate2", Dali::Stage::GetCurrent().GetRootLayer());
398  DALI_TEST_CHECK(anim);
399 
400  // alternative actor to use for FindChildByName
401  anim = builder.CreateAnimation("animate2", map, Dali::Stage::GetCurrent().GetRootLayer());
402  DALI_TEST_CHECK(anim);
403 
404 
405  END_TEST;
406 
407 }
408 
410 {
411  ToolkitTestApplication application;
412 
413  // JSON with a quit event when the actor is touched
414  std::string json(
415  "{"
416  "\"constants\":"
417  "{"
418  " \"IMAGE_PATH\": \"apath\","
419  " \"WIDTH\": 22.3,"
420  " \"ANCHOR\": \"TOP_LEFT\","
421  " \"PADDING\": [1,2,3,4]"
422  "},"
423  "\"stage\":"
424  "[{"
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}\","
433  " \"signals\": [{"
434  " \"name\": \"touched\","
435  " \"action\": \"quit\""
436  " }]"
437  "}]"
438  "}"
439  );
440 
441  Builder builder = Builder::New();
442  builder.LoadFromString( json );
443 
444  builder.AddConstant( "NAME", "image" );
445 
446  Property::Map map = builder.GetConstants();
447 
448  Dali::Property::Value* pValue = map.Find( "NAME" );
449 
450  DALI_TEST_CHECK( pValue );
451 
452  pValue = map.Find( "IMAGE_PATH" );
453 
454  DALI_TEST_CHECK( pValue );
455 
456  Dali::Property::Value value = builder.GetConstant( "WIDTH" );
457 
458  DALI_TEST_CHECK( value.GetType() != Property::NONE );
459 
460  builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
461  DALI_TEST_CHECK( builder );
462 
464  DALI_TEST_CHECK( actor );
465 
466  END_TEST;
467 }
468 
470 {
471  ToolkitTestApplication application;
472 
473  // JSON with a quit event when the actor is touched
474  std::string json(
475  "{\n"
476  "\"constants\":"
477  "{"
478  " \"SIZE\": [10,20,30]"
479  "},"
480  "\"styles\":\n"
481  "{\n"
482  " \"imageStyle\": \n"
483  " {\n"
484  " \"color\": [1,0,0,1],\n"
485  " \"actors\": {\n"
486  " \"childImage\": {\n"
487  " \"color\": [0,1,0,1]\n"
488  " }\n"
489  " }\n"
490  " }\n"
491  "},\n"
492  "\"templates\":\n"
493  "{\n"
494  " \"imageTree\": { \n"
495  " \"type\": \"ImageActor\",\n"
496  " \"styles\": [\"imageStyle\"],\n"
497  " \"name\": \"image\",\n"
498  " \"size\": \"{SIZE}\",\n"
499  " \"signals\": [{\n"
500  " \"name\": \"touched\",\n"
501  " \"action\": \"quit\"\n"
502  " }],\n"
503  " \"actors\": [\n"
504  " {\n"
505  " \"type\":\"ImageActor\",\n"
506  " \"name\":\"childImage\" \n"
507  " }\n"
508  " ]\n"
509  " }\n"
510  "},\n"
511  "\"stage\":"
512  "[{"
513  " \"type\": \"imageTree\","
514  " \"size\": [100,100,1]"
515  "}]"
516  "}\n"
517  );
518 
519  std::string stylejson(
520  "{\n"
521  " \"color\": [1,0,0,1],\n"
522  " \"actors\": {\n"
523  " \"childImage\": {\n"
524  " \"color\": [0,1,0,1]\n"
525  " }\n"
526  " }\n"
527  "}\n"
528  );
529 
530  std::string templatejson(
531  "{ \n"
532  " \"type\": \"ImageActor\",\n"
533  " \"styles\": [\"imageStyle\"],\n"
534  " \"name\": \"image\",\n"
535  " \"size\": \"{SIZE}\",\n"
536  " \"signals\": [{\n"
537  " \"name\": \"touched\",\n"
538  " \"action\": \"quit\"\n"
539  " }],\n"
540  " \"actors\": [\n"
541  " {\n"
542  " \"type\":\"ImageActor\",\n"
543  " \"name\":\"childImage\" \n"
544  " }\n"
545  " ]\n"
546  "}\n"
547  );
548 
549  Builder builder = Builder::New();
550  builder.LoadFromString( json );
551 
552  ImageActor actor = ImageActor::DownCast( builder.Create( "imageTree" ) );
553  DALI_TEST_CHECK( actor );
554 
556  map["SIZE"] = Vector3(100,100,1);
557  actor = ImageActor::DownCast( builder.Create( "imageTree", map ) );
558  DALI_TEST_CHECK( actor );
559 
560  // create from json snippet
561  actor = ImageActor::DownCast( builder.CreateFromJson( templatejson ) );
562  DALI_TEST_CHECK( actor );
563 
564 
565  // NB: already applied in create
566  DALI_TEST_CHECK( builder.ApplyStyle( "imageStyle", actor ) );
567 
568  // apply from json snippet
569  DALI_TEST_CHECK( builder.ApplyFromJson( actor, stylejson ) );
570 
571  END_TEST;
572 }
573 
575 {
576  ToolkitTestApplication application;
577 
578  // JSON with a quit event when the actor is touched
579  std::string json(
580  "{\n"
581  "\"renderTasks\":\n"
582  "{\n"
583  " \"task0\": {\n"
584  " \"sourceActor\": \"image\",\n"
585  " \"cameraActor\": \"camera\" \n"
586  " }\n"
587  "},\n"
588  "\"stage\":\n"
589  "[\n"
590  " { \n"
591  " \"type\": \"CameraActor\",\n"
592  " \"name\": \"image\"\n"
593  " }, \n"
594  " { \n"
595  " \"type\": \"ImageActor\",\n"
596  " \"name\": \"image\",\n"
597  " \"size\": [100,100,1],\n"
598  " \"signals\": [{\n"
599  " \"name\": \"touched\",\n"
600  " \"action\": \"quit\"\n"
601  " }],\n"
602  " \"actors\": [\n"
603  " {\n"
604  " \"type\":\"ImageActor\",\n"
605  " \"name\":\"childImage\" \n"
606  " }\n"
607  " ]\n"
608  " }\n"
609  "]\n"
610  "}\n"
611  );
612 
613  Builder builder = Builder::New();
614  builder.LoadFromString( json );
615 
616  unsigned int count = Stage::GetCurrent().GetRenderTaskList().GetTaskCount();
617 
618  // coverage
619  builder.CreateRenderTask( "task0" );
620 
621  DALI_TEST_CHECK( count <
622  Stage::GetCurrent().GetRenderTaskList().GetTaskCount() );
623 
624  END_TEST;
625 }
626 
628 {
629  ToolkitTestApplication application;
630 
631  // JSON with a quit event when the actor is touched
632  std::string json(
633  "{\n"
634  " \"stage\":\n"
635  " [{\n"
636  " \"type\": \"Actor\",\n"
637  " \"name\": \"actor\",\n"
638  " \"size\": [100,100,1],\n"
639  " \"parentOrigin\": \"TOP_LEFT\",\n"
640  " \"anchorPoint\": \"TOP_LEFT\",\n"
641  " \"actors\": [{\n"
642  " \"type\": \"Actor\",\n"
643  " \"name\": \"subActor\"\n"
644  " }],\n"
645  " \"signals\": [{\n"
646  " \"name\": \"touched\",\n"
647  " \"action\": \"hide\",\n"
648  " \"actor\": \"actor\",\n"
649  " \"childActor\": \"subActor\"\n"
650  " }]\n"
651  " }]\n"
652  "}\n"
653  );
654 
655  Builder builder = Builder::New();
656  builder.LoadFromString( json );
657  builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
658 
659  // Render and notify
660  application.SendNotification();
661  application.Render();
662 
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 );
667 
668  // Render and notify
669  application.SendNotification();
670  application.Render();
671 
672  Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("subActor");
673  DALI_TEST_CHECK( actor );
674 
675  DALI_TEST_CHECK( !actor.IsVisible() );
676 
677  END_TEST;
678 }
679 
681 {
682  ToolkitTestApplication application;
683 
684  // JSON with a quit event when the actor is touched
685  std::string json(
686  "{\n"
687  " \"stage\":\n"
688  " [{\n"
689  " \"type\": \"Actor\",\n"
690  " \"name\": \"actor\",\n"
691  " \"size\": [100,100,1],\n"
692  " \"parentOrigin\": \"TOP_LEFT\",\n"
693  " \"anchorPoint\": \"TOP_LEFT\",\n"
694  " \"actors\": [{\n"
695  " \"type\": \"Actor\",\n"
696  " \"name\": \"subActor\"\n"
697  " }],\n"
698  " \"signals\": [{\n"
699  " \"name\": \"touched\",\n"
700  " \"action\": \"set\",\n"
701  " \"actor\": \"subActor\",\n"
702  " \"property\": \"visible\",\n"
703  " \"value\": false\n"
704  " }]\n"
705  " }]\n"
706  "}\n"
707  );
708 
709  Builder builder = Builder::New();
710  builder.LoadFromString( json );
711  builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
712 
713  // Render and notify
714  application.SendNotification();
715  application.Render();
716 
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 );
721 
722  // Render and notify
723  application.SendNotification();
724  application.Render();
725 
726  Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("subActor");
727  DALI_TEST_CHECK( actor );
728 
729  DALI_TEST_CHECK( !actor.IsVisible() );
730 
731  END_TEST;
732 }
733 
735 {
736  ToolkitTestApplication application;
737 
738  // JSON with a quit event when the actor is touched
739  std::string json(
740  "{\n"
741  " \"stage\":\n"
742  " [{\n"
743  " \"type\": \"Actor\",\n"
744  " \"name\": \"actor\",\n"
745  " \"size\": [100,100,1],\n"
746  " \"parentOrigin\": \"TOP_LEFT\",\n"
747  " \"anchorPoint\": \"TOP_LEFT\",\n"
748  " \"actors\": [{\n"
749  " \"type\": \"Actor\",\n"
750  " \"name\": \"subActor\"\n"
751  " }],\n"
752  " \"signals\": [{\n"
753  " \"name\": \"touched\",\n"
754  " \"action\": \"hide\"\n"
755  " }]\n"
756  " }]\n"
757  "}\n"
758  );
759 
760  Builder builder = Builder::New();
761  builder.LoadFromString( json );
762  builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
763 
764  // Render and notify
765  application.SendNotification();
766  application.Render();
767 
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 );
772 
773  // Render and notify
774  application.SendNotification();
775  application.Render();
776 
778  DALI_TEST_CHECK( actor );
779 
780  DALI_TEST_CHECK( !actor.IsVisible() );
781 
782  END_TEST;
783 }
784 
786 {
787  ToolkitTestApplication application;
788 
789  // JSON with a quit event when the actor is touched
790  std::string json(
791  "{\n"
792  " \"stage\":\n"
793  " [{\n"
794  " \"type\": \"Actor\",\n"
795  " \"name\": \"actor\",\n"
796  " \"size\": [100,100,1],\n"
797  " \"parentOrigin\": \"TOP_LEFT\",\n"
798  " \"anchorPoint\": \"TOP_LEFT\",\n"
799  " \"actors\": [{\n"
800  " \"type\": \"Actor\",\n"
801  " \"name\": \"subActor\"\n"
802  " }],\n"
803  " \"signals\": [{\n"
804  " \"name\": \"touched\",\n"
805  " \"action\": \"hide\"\n"
806  " }],\n"
807  " \"notifications\": [{\n"
808  " \"property\": \"visible\",\n"
809  " \"condition\": \"False\",\n"
810  " \"action\": \"show\"\n"
811  " }]\n"
812  " }]\n"
813  "}\n"
814  );
815 
816  Builder builder = Builder::New();
817  builder.LoadFromString( json );
818  builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
819 
820  // Render and notify
821  application.SendNotification();
822  application.Render();
823 
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 );
828 
829  // Render and notify
830  application.SendNotification();
831  application.Render();
832 
833  // Render and notify
834  application.SendNotification();
835  application.Render();
836 
838  DALI_TEST_CHECK( actor );
839 
840  DALI_TEST_CHECK( actor.IsVisible() );
841 
842  END_TEST;
843 }
844 
846 {
847  ToolkitTestApplication application;
848 
849  // JSON with a quit event when the actor is touched
850  std::string json(
851  "{\n"
852  "\"templates\":\n"
853  "{\n"
854  " \"imageTree\": { \n"
855  " \"type\": \"ImageActor\",\n"
856  " \"name\": \"image\",\n"
857  " \"size\": [100,100,1],\n"
858  " \"signals\": [{\n"
859  " \"name\": \"touched\",\n"
860  " \"action\": \"quit\"\n"
861  " }],\n"
862  " \"customProperties\": {\n"
863  " \"newproperty\": true\n"
864  " },\n"
865  " \"actors\": [\n"
866  " {\n"
867  " \"type\":\"ImageActor\",\n"
868  " \"name\":\"childImage\" \n"
869  " }\n"
870  " ]\n"
871  " }\n"
872  "}\n"
873  "}\n"
874  );
875 
876  Builder builder = Builder::New();
877  builder.LoadFromString( json );
878 
879  ImageActor actor = ImageActor::DownCast( builder.Create( "imageTree" ) );
880  DALI_TEST_CHECK( actor );
881 
882  // NB: already applied in create
883  Property::Index index = actor.GetPropertyIndex("newproperty");
885  Property::Value value = actor.GetProperty(index);
886  DALI_TEST_CHECK( value.Get<bool>() == true );
887 
888  END_TEST;
889 }
890 
892 {
893  ToolkitTestApplication application;
894 
895  // JSON with a quit event when the actor is touched
896  std::string json(
897  "{\n"
898  " \"stage\": [\n"
899  " {\n"
900  " \"type\": \"ImageActor\",\n"
901  " \"name\": \"Image1\",\n"
902  " \"position\": [\n"
903  " 0.40461349487305,\n"
904  " 0.9150390625,\n"
905  " 0.0\n"
906  " ],\n"
907  " \"parentOrigin\": [0.5, 0.5, 0.5],\n"
908  " \"size\": [200, 200, 0],\n"
909  " \"effect\": \"Ripple2D\",\n"
910  " \"image\": {\n"
911  " \"filename\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\",\n"
912  " \"width\": 200,\n"
913  " \"height\": 80,\n"
914  " \"loadPolicy\": \"IMMEDIATE\",\n"
915  " \"releasePolicy\": \"NEVER\"\n"
916  " },\n"
917  " \"signals\": [\n"
918  " {\n"
919  " \"name\": \"onStage\",\n"
920  " \"action\": \"play\",\n"
921  " \"animation\": \"Animation_1\"\n"
922  " }\n"
923  " ]\n"
924  " }\n"
925  " ],\n"
926  " \"paths\": {},\n"
927  " \"animations\": {\n"
928  " \"Animation_1\": {\n"
929  " \"loop\":true,\n"
930  " \"properties\": [\n"
931  " {\n"
932  " \"actor\": \"Image1\",\n"
933  " \"property\": \"uTime\",\n"
934  " \"value\": 10.0,\n"
935  " \"alphaFunction\": \"LINEAR\",\n"
936  " \"timePeriod\": {\n"
937  " \"delay\": 0,\n"
938  " \"duration\": 10.0\n"
939  " },\n"
940  " \"gui-builder-timeline-color\": \"#8dc0da\"\n"
941  " }\n"
942  " ]\n"
943  " }\n"
944  " },\n"
945  " \"shaderEffects\": {\n"
946  " \"Ripple2D\": {\n"
947  " \"program\": {\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"
953  " },\n"
954  " \"geometryHints\": \"HINT_NONE\",\n"
955  " \"gridDensity\": 0,\n"
956  " \"loop\": true,\n"
957  " \"uAmplitude\": 0.02,\n"
958  " \"uTime\": 0.0\n"
959  " }\n"
960  " }\n"
961  "}\n"
962 
963  );
964 
965  Builder builder = Builder::New();
966  builder.LoadFromString( json );
967 
968  ShaderEffect effect = builder.GetShaderEffect("Ripple2D");
969 
970  // coverage
971  DALI_TEST_CHECK( effect );
972 
973  END_TEST;
974 }
975 
976 
978 {
979  ToolkitTestApplication application;
980 
981  // JSON with a quit event when the actor is touched
982  std::string json(
983  "asdfsadf dsf asdf asdf {"
984  "\"stage\":"
985  "[{"
986  "\"type\": \"Actor\","
987  "\"size\": [100,100,1],"
988  "\"parentOrigin\": \"TOP_LEFT\","
989  "\"anchorPoint\": \"TOP_LEFT\","
990  "\"signals\": [{"
991  "\"name\": \"touched\","
992  "\"action\": \"quit\""
993  "}]"
994  "}]"
995  "}"
996  );
997  Builder builder = Builder::New();
998 
999  bool assert1 = false;
1000 
1001  try
1002  {
1003  builder.LoadFromString( json );
1004  }
1005  catch( Dali::DaliException& e )
1006  {
1008  DALI_TEST_EQUALS(e.condition, "!\"Cannot parse JSON\"", TEST_LOCATION);
1009  assert1 = true;
1010  }
1011 
1012  DALI_TEST_CHECK( assert1 );
1013 
1014  END_TEST;
1015 }
1016 
1018 {
1019  ToolkitTestApplication application;
1020 
1021  // JSON with a quit event when the actor is touched
1022  std::string json(
1023  "{\n"
1024  "\"templates\":\n"
1025  "{\n"
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"
1032  " 0.9150390625,\n"
1033  " 0.0\n"
1034  " ],\n"
1035  " \"signals\": [{\n"
1036  " \"name\": \"touched\",\n"
1037  " \"action\": \"quit\"\n"
1038  " }],\n"
1039  " \"actors\": [\n"
1040  " {\n"
1041  " \"type\":\"ImageActor\",\n"
1042  " \"name\":\"childImage\" \n"
1043  " }\n"
1044  " ]\n"
1045  " }\n"
1046  "},\n"
1047  " \"stage\": [\n"
1048  " {\n"
1049  " \"type\": \"imageTree\",\n"
1050  " \"name\": \"Image1\",\n"
1051  " \"effect\": \"Ripple2D\",\n"
1052  " \"image\": \"offscreen\""
1053  " }\n"
1054  " ],\n"
1055  " \"shaderEffects\": {\n"
1056  " \"Ripple2D\": {\n"
1057  " \"program\": {\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"
1063  " },\n"
1064  " \"geometryHints\": \"HINT_NONE\",\n"
1065  " \"gridDensity\": 0,\n"
1066  " \"loop\": true,\n"
1067  " \"uAmplitude\": 0.02,\n"
1068  " \"uTime\": 0.0\n"
1069  " }\n"
1070  " },\n"
1071  " \"frameBufferImages\": {\n"
1072  " \"offscreen\": {\n"
1073  " \"type\": \"FrameBufferImage\","
1074  " \"pixelFormat\":\"RGBA8888\","
1075  " \"width\": 400,"
1076  " \"height\": 400"
1077  " }"
1078  " }"
1079  "}\n"
1080 
1081  );
1082 
1083  Builder builder = Builder::New();
1084  builder.LoadFromString( json );
1085 
1086  // coverage
1087  DALI_TEST_CHECK( true );
1088 
1089  END_TEST;
1090 }
1091 
1093 {
1094  ToolkitTestApplication application;
1095 
1096  // JSON with a quit event when the actor is touched
1097  std::string json(
1098  "{\n"
1099  " \"arbitarysection\":\n"
1100  " [{\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"
1106  " \"actors\": [{\n"
1107  " \"type\": \"Actor\",\n"
1108  " \"name\": \"subActor\",\n"
1109  " \"visible\": false\n"
1110  " }],\n"
1111  " \"signals\": [{\n"
1112  " \"name\": \"touched\",\n"
1113  " \"action\": \"hide\",\n"
1114  " \"actor\": \"actor\",\n"
1115  " \"childActor\": \"subActor\"\n"
1116  " }]\n"
1117  " }]\n"
1118  "}\n"
1119  );
1120 
1121  Builder builder = Builder::New();
1122  builder.LoadFromString( json );
1123  builder.AddActors ( "arbitarysection", Stage::GetCurrent().GetRootLayer() );
1124 
1125  // Render and notify
1126  application.SendNotification();
1127  application.Render();
1128 
1129  Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("subActor");
1130  DALI_TEST_CHECK( actor );
1131 
1132  DALI_TEST_CHECK( !actor.IsVisible() );
1133 
1134  END_TEST;
1135 }
1136 
1138 {
1139  ToolkitTestApplication application;
1140 
1141  // JSON with a quit event when the actor is touched
1142  std::string json(
1143  "{\n"
1144  " \"constants\":\n"
1145  " {\n"
1146  " \"FB_WIDTH\": 200.0,\n"
1147  " \"FB_HEIGHT\": 200.0,\n"
1148  " \"FB_SIZE\": [200,200],\n"
1149  " \"FB_ASPECT_RATIO\": 1\n"
1150  " },\n"
1151  " \"stage\": [\n"
1152  " {\n"
1153  " \"type\": \"ImageActor\",\n"
1154  " \"name\": \"fbOnStage\",\n"
1155  " \"position\": [\n"
1156  " 0.40461349487305,\n"
1157  " 0.9150390625,\n"
1158  " 0.0\n"
1159  " ],\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"
1164  " },\n"
1165  " {\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"
1171  " \"image\": {\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"
1177  " },\n"
1178  " \"signals\": [\n"
1179  " {\n"
1180  " \"name\": \"onStage\",\n"
1181  " \"action\": \"play\",\n"
1182  " \"animation\": \"Animation_1\"\n"
1183  " }\n"
1184  " ]\n"
1185  " },\n"
1186  " {\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"
1193  " }\n"
1194  " ],\n"
1195  " \"frameBufferImages\":\n"
1196  " {\n"
1197  " \"fb0\":\n"
1198  " {\n"
1199  " \"type\": \"FrameBufferImage\",\n"
1200  " \"width\": { \"typeCast\":\"float\", \"value\":\"{FB_WIDTH}\" },\n"
1201  " \"height\": { \"typeCast\":\"float\", \"value\":\"{FB_HEIGHT}\" }\n"
1202  " }\n"
1203  " },\n"
1204  " \"renderTasks\":\n"
1205  " {\n"
1206  " \"stage\":\n"
1207  " [\n"
1208  " {\n"
1209  " \"sourceActor\": \"fbOnStage\"\n"
1210  " },\n"
1211  " {\n"
1212  " \"sourceActor\": \"Image1\",\n"
1213  " \"targetFrameBuffer\": \"fb0\",\n"
1214  " \"viewportSize\":\"{FB_SIZE}\",\n"
1215  " \"cameraActor\":\"fbCam\"\n"
1216  " }\n"
1217  " ]\n"
1218  " },\n"
1219  " \"paths\": {},\n"
1220  " \"animations\": {\n"
1221  " \"Animation_1\": {\n"
1222  " \"loop\":true,\n"
1223  " \"properties\": [\n"
1224  " {\n"
1225  " \"actor\": \"Image1\",\n"
1226  " \"property\": \"uTime\",\n"
1227  " \"value\": 10.0,\n"
1228  " \"alphaFunction\": \"LINEAR\",\n"
1229  " \"timePeriod\": {\n"
1230  " \"delay\": 0,\n"
1231  " \"duration\": 10.0\n"
1232  " },\n"
1233  " \"gui-builder-timeline-color\": \"#8dc0da\"\n"
1234  " }\n"
1235  " ]\n"
1236  " }\n"
1237  " },\n"
1238  " \"shaderEffects\": {\n"
1239  " \"Ripple2D\": {\n"
1240  " \"program\": {\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"
1246  " },\n"
1247  " \"geometryHints\": \"HINT_NONE\",\n"
1248  " \"gridDensity\": 0,\n"
1249  " \"loop\": true,\n"
1250  " \"uAmplitude\": 0.02,\n"
1251  " \"uTime\": 0.0\n"
1252  " }\n"
1253  " }\n"
1254  "}\n");
1255 
1256  Builder builder = Builder::New();
1257 
1258  // frame buffer coverage
1259  builder.LoadFromString( json );
1260 
1261  // Render and notify
1262  application.SendNotification();
1263  application.Render();
1264 
1265  Dali::FrameBufferImage frameBuffer = builder.GetFrameBufferImage( "fb0" );
1266  DALI_TEST_CHECK( frameBuffer );
1267 
1268  Dali::FrameBufferImage frameBuffer2 = builder.GetFrameBufferImage( "fb0" );
1269  DALI_TEST_CHECK( frameBuffer2 );
1270  DALI_TEST_CHECK( frameBuffer == frameBuffer2 );
1271 
1272  DALI_TEST_CHECK( true );
1273 
1274  END_TEST;
1275 }
1276 
1278 {
1279  ToolkitTestApplication application;
1280 
1281  // JSON with a quit event when the actor is touched
1282  std::string json(
1283  "{\n"
1284  " \"constants\":\n"
1285  " {\n"
1286  " \"FB_WIDTH\": 200.0,\n"
1287  " \"FB_HEIGHT\": 200.0,\n"
1288  " \"FB_SIZE\": [200,200],\n"
1289  " \"FB_ASPECT_RATIO\": 1\n"
1290  " },\n"
1291  " \"stage\": [\n"
1292  " {\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"
1298  " \"image\": {\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"
1304  " },\n"
1305  " \"signals\": [\n"
1306  " {\n"
1307  " \"name\": \"onStage\",\n"
1308  " \"action\": \"play\",\n"
1309  " \"animation\": \"pathAnimation\"\n"
1310  " },\n"
1311  " {\n"
1312  " \"name\": \"onStage\",\n"
1313  " \"action\": \"applyConstraint\",\n"
1314  " \"constrainer\": \"constrainer0\",\n"
1315  " \"properties\":\n"
1316  " [\n"
1317  " {\n"
1318  " \"source\": \"Image1\",\n"
1319  " \"sourceProperty\": \"positionX\",\n"
1320  " \"target\": \"Image1\",\n"
1321  " \"targetProperty\": \"colorRed\",\n"
1322  " \"range\": [-300,300]\n"
1323  " }\n"
1324  " ]\n"
1325  " },\n"
1326  " {\n"
1327  " \"name\": \"onStage\",\n"
1328  " \"action\": \"applyConstraint\",\n"
1329  " \"constrainer\": \"constrainer1\",\n"
1330  " \"properties\":\n"
1331  " [\n"
1332  " {\n"
1333  " \"source\": \"Image1\",\n"
1334  " \"sourceProperty\": \"positionX\",\n"
1335  " \"target\": \"Image1\",\n"
1336  " \"targetProperty\": \"colorBlue\",\n"
1337  " \"range\": [-300,300]\n"
1338  " }\n"
1339  " ]\n"
1340  " }\n"
1341  " ]\n"
1342  " }\n"
1343  " ],\n"
1344  " \"paths\":\n"
1345  " {\n"
1346  " \"path0\":\n"
1347  " {\n"
1348  " \"points\":[ [-150, -50, 0], [0.0,70.0,0.0], [190.0,-150.0,0.0] ],\n"
1349  " \"curvature\":0.35\n"
1350  " }\n"
1351  " },\n"
1352  " \"constrainers\":\n"
1353  " {\n"
1354  " \"constrainer0\":\n"
1355  " {\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"
1359  " },\n"
1360  " \"constrainer1\":\n"
1361  " {\n"
1362  " \"type\": \"LinearConstrainer\",\n"
1363  " \"value\": [ 0, 0, 0 ]\n"
1364  " }\n"
1365  " },\n"
1366  " \"animations\": {\n"
1367  " \"pathAnimation\": {\n"
1368  " \"duration\": 3.0,\n"
1369  " \"properties\":\n"
1370  " [{\n"
1371  " \"actor\": \"Image1\",\n"
1372  " \"path\":\"path0\",\n"
1373  " \"forward\":[1,0,0],\n"
1374  " \"alphaFunction\": \"EASE_IN_OUT\",\n"
1375  " \"timePeriod\": {\n"
1376  " \"delay\": 0,\n"
1377  " \"duration\": 3\n"
1378  " }\n"
1379  " },\n"
1380  " {\n"
1381  " \"actor\": \"Image1\",\n"
1382  " \"property\": \"uTime\",\n"
1383  " \"value\": 10.0,\n"
1384  " \"alphaFunction\": \"LINEAR\",\n"
1385  " \"timePeriod\": {\n"
1386  " \"delay\": 0,\n"
1387  " \"duration\": 10.0\n"
1388  " },\n"
1389  " \"gui-builder-timeline-color\": \"#8dc0da\"\n"
1390  " }]\n"
1391  " },\n"
1392  " \"Animation_1\": {\n"
1393  " \"loop\":true,\n"
1394  " \"properties\": [\n"
1395  " {\n"
1396  " \"actor\": \"Image1\",\n"
1397  " \"property\": \"uTime\",\n"
1398  " \"value\": 10.0,\n"
1399  " \"alphaFunction\": \"LINEAR\",\n"
1400  " \"timePeriod\": {\n"
1401  " \"delay\": 0,\n"
1402  " \"duration\": 10.0\n"
1403  " },\n"
1404  " \"gui-builder-timeline-color\": \"#8dc0da\"\n"
1405  " }\n"
1406  " ]\n"
1407  " }\n"
1408  " },\n"
1409  " \"shaderEffects\": {\n"
1410  " \"Ripple2D\": {\n"
1411  " \"program\": {\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"
1417  " },\n"
1418  " \"geometryHints\": \"HINT_NONE\",\n"
1419  " \"gridDensity\": 0,\n"
1420  " \"loop\": true,\n"
1421  " \"uAmplitude\": 0.02,\n"
1422  " \"uTime\": 0.0\n"
1423  " }\n"
1424  " }\n"
1425  "}\n");
1426 
1427  Builder builder = Builder::New();
1428 
1429  // frame buffer coverage
1430  builder.LoadFromString( json );
1431 
1432  // Render and notify
1433  application.SendNotification();
1434  application.Render();
1435 
1436  Dali::Path path = builder.GetPath( "path0" );
1437  DALI_TEST_CHECK( path );
1438 
1439  Dali::Path path2 = builder.GetPath( "path0" );
1440  DALI_TEST_CHECK( path2 );
1441  DALI_TEST_CHECK( path == path2 );
1442 
1443  Dali::PathConstrainer constrainer0 = builder.GetPathConstrainer( "constrainer0" );
1444  DALI_TEST_CHECK( constrainer0 );
1445 
1446  Dali::PathConstrainer constrainer0_2 = builder.GetPathConstrainer( "constrainer0" );
1447  DALI_TEST_CHECK( constrainer0_2 );
1448  DALI_TEST_CHECK( constrainer0 == constrainer0_2 );
1449 
1450  Dali::LinearConstrainer constrainer1 = builder.GetLinearConstrainer( "constrainer1" );
1451  DALI_TEST_CHECK( constrainer1 );
1452 
1453  Dali::LinearConstrainer constrainer1_2 = builder.GetLinearConstrainer( "constrainer1" );
1454  DALI_TEST_CHECK( constrainer1 == constrainer1_2 );
1455 
1456  END_TEST;
1457 }
Dali Docs Home
Read more about Dali