[dali_1.9.13] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-Builder.cpp
1 /*
2  * Copyright (c) 2018 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 <iterator>
20 #include <vector>
21 #include <algorithm>
22 #include <cstdlib>
23
24 #include <dali-toolkit-test-suite-utils.h>
25 #include <dali-toolkit/devel-api/builder/builder.h>
26 #include <dali-toolkit/devel-api/builder/base64-encoding.h>
27 #include <dali/integration-api/events/touch-event-integ.h>
28 #include <dali-toolkit/dali-toolkit.h>
29 #include <test-button.h>
30 #include <test-animation-data.h>
31 #include <dummy-control.h>
32
33
34 #define STRINGIFY(A)#A
35
36 using namespace Dali;
37 using namespace Toolkit;
38
39 namespace BuilderControlProperty
40 {
41
42 enum
43 {
44   INTEGER_PROPERTY = Toolkit::Control::CONTROL_PROPERTY_END_INDEX + 1,
45   MATRIX3_PROPERTY,
46   MATRIX_PROPERTY,
47   NONE_PROPERTY
48 };
49
50 namespace
51 {
52
53 BaseHandle Create()
54 {
55   return Toolkit::Control::New();
56 }
57
58 int gSetPropertyCalledCount = 0;
59
60 void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
61 {
62   ++gSetPropertyCalledCount;
63 }
64
65 Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex )
66 {
67   return Property::Value();
68 }
69
70 } // unnamed namespace
71
72 // Properties
73 Dali::TypeRegistration typeRegistration( "BuilderControl", typeid( Toolkit::Control ), Create );
74
75 Dali::PropertyRegistration propertyInteger( typeRegistration, "integerProperty", INTEGER_PROPERTY, Property::INTEGER, &SetProperty, &GetProperty );
76 Dali::PropertyRegistration propertyMatrix3( typeRegistration, "matrix3Property", MATRIX3_PROPERTY, Property::MATRIX3, &SetProperty, &GetProperty );
77 Dali::PropertyRegistration propertyMatrix(  typeRegistration, "matrixProperty",  MATRIX_PROPERTY,  Property::MATRIX,  &SetProperty, &GetProperty );
78 Dali::PropertyRegistration propertyNone(    typeRegistration, "noneProperty",    NONE_PROPERTY,    Property::NONE,    &SetProperty, &GetProperty );
79
80 }
81
82 namespace
83 {
84
85 struct BuilderFunctor
86 {
87   BuilderFunctor( bool& called ) : mCalled( called )
88   {
89     mCalled = false;
90   }
91
92   void operator()()
93   {
94     mCalled = true;
95   }
96
97   bool& mCalled;
98 };
99
100 } // namespace
101
102
103
104 void builder_startup(void)
105 {
106   test_return_value = TET_UNDEF;
107 }
108
109 void builder_cleanup(void)
110 {
111   test_return_value = TET_PASS;
112 }
113
114 int UtcDaliBuilderQuitSignal(void)
115 {
116   ToolkitTestApplication application;
117
118   // JSON with a quit event when the actor is touched
119   std::string json(
120       "{"
121          "\"stage\":"
122          "[{"
123            "\"type\": \"Layer\","
124            "\"size\": [100,100,1],"
125            "\"parentOrigin\": \"TOP_LEFT\","
126            "\"anchorPoint\": \"TOP_LEFT\","
127            "\"maximumSize\": [100,100],"
128            "\"orientation\": [10,10,10,10],"
129            "\"clippingBox\": [10,10,10,10],"
130            "\"signals\": [{"
131              "\"name\": \"touch\","
132              "\"action\": \"quit\""
133            "}]"
134          "}]"
135       "}"
136   );
137   Builder builder = Builder::New();
138   builder.LoadFromString( json );
139   builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
140
141   // Connect to builder's quit signal
142   bool functorCalled( false );
143   builder.QuitSignal().Connect( &application, BuilderFunctor( functorCalled ) );
144
145   // Render and notify
146   application.SendNotification();
147   application.Render();
148
149   // Emit touch event and check that our quit method is called
150   Integration::TouchEvent touchEvent;
151   Integration::Point point;
152   point.SetState( PointState::DOWN );
153   point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
154   touchEvent.points.push_back( point );
155   application.ProcessEvent( touchEvent );
156   DALI_TEST_CHECK( functorCalled );
157
158   END_TEST;
159 }
160
161
162 int UtcDaliBuilderAnimationP(void)
163 {
164   ToolkitTestApplication application;
165
166   // JSON with a quit event when the actor is touched
167   std::string json(
168         "{"
169         "   \"constants\":"
170         "   {"
171         "     \"ALPHA_FUNCTION\":\"EASE_IN_OUT\""
172         "   },"
173         "   \"paths\":"
174         "   {"
175         "     \"path0\":"
176         "     {"
177         "       \"points\":[ [-150, -50, 0], [0.0,70.0,0.0], [190.0,-150.0,0.0] ],"
178         "       \"curvature\":0.35"
179         "     }"
180         "   },"
181         "  \"animations\": {"
182         "    \"animate\": {"
183         "      \"loop\": true,"
184         "      \"endAction\": \"BAKE\","
185         "      \"disconnectAction\": \"BAKE\","
186         "      \"properties\":"
187         "      [{"
188         "        \"actor\": \"greeting\","
189         "        \"property\": \"position\","
190         "        \"value\": [300, 300, -1000],"
191         "        \"alphaFunction\": \"{ALPHA_FUNCTION}\","
192         "        \"relative\": true,"
193         "        \"timePeriod\": {"
194         "          \"delay\": 0,"
195         "          \"duration\": 3"
196         "        }"
197         "      },"
198         "       {"
199         "         \"actor\": \"greeting\","
200         "         \"property\": \"visible\","
201         "         \"alphaFunction\": \"LINEAR\","
202         "         \"value\": true"
203         "       },"
204         "       {"
205         "         \"actor\": \"greeting\","
206         "         \"property\": \"sizeWidth\","
207         "         \"alphaFunction\": \"REVERSE\","
208         "         \"value\": 10.0"
209         "       },"
210         "       {"
211         "         \"actor\": \"greeting\","
212         "         \"property\": \"orientation\","
213         "         \"alphaFunction\": \"EASE_IN\","
214         "         \"value\": [10.0,20.0,30.0]"
215         "       },"
216         "       {"
217         "         \"actor\": \"greeting\","
218         "         \"property\": \"orientation\","
219         "         \"alphaFunction\": \"EASE_OUT\","
220         "         \"value\": [0.0, 0.0, 0.0, 1.0]"
221         "       },"
222         "       {"
223         "         \"actor\": \"greeting\","
224         "         \"property\": \"orientation\","
225         "         \"alphaFunction\": \"EASE_IN_OUT\","
226         "         \"value\": [0.0, 0.0, 0.0, 1.0]"
227         "       },"
228         "       {"
229         "         \"actor\": \"greeting\","
230         "         \"property\": \"orientation\","
231         "         \"alphaFunction\": \"EASE_IN_SINE\","
232         "         \"value\": [0.0, 0.0, 0.0, 1.0]"
233         "       },"
234         "       {"
235         "         \"actor\": \"greeting\","
236         "         \"property\": \"orientation\","
237         "         \"alphaFunction\": \"EASE_OUT_SINE\","
238         "         \"value\": [0.0, 0.0, 0.0, 1.0]"
239         "       },"
240         "       {"
241         "         \"actor\": \"greeting\","
242         "         \"property\": \"orientation\","
243         "         \"alphaFunction\": \"EASE_IN_OUT_SINE\","
244         "         \"value\": [0.0, 0.0, 0.0, 1.0]"
245         "       },"
246         "       {"
247         "         \"actor\": \"greeting\","
248         "         \"property\": \"orientation\","
249         "         \"alphaFunction\": \"BOUNCE\","
250         "         \"value\": [0.0, 0.0, 0.0, 1.0]"
251         "       },"
252         "       {"
253         "         \"actor\": \"greeting\","
254         "         \"property\": \"orientation\","
255         "         \"alphaFunction\": \"SIN\","
256         "         \"value\": [0.0, 0.0, 0.0, 1.0]"
257         "       },"
258         "       {"
259         "         \"actor\": \"greeting\","
260         "         \"property\": \"orientation\","
261         "         \"alphaFunction\": \"EASE_OUT_BACK\","
262         "         \"value\": [0.0, 0.0, 0.0, 1.0]"
263         "       }"
264         "      ]"
265         "    },"
266         "    \"pathAnimation\": {"
267         "      \"duration\": 3.0,"
268         "      \"endAction\": \"DISCARD\","
269         "      \"disconnectAction\": \"BAKE_FINAL\","
270         "      \"properties\": [{"
271         "        \"actor\": \"greeting\","
272         "        \"path\":\"path0\","
273         "        \"forward\":[1,0,0],"
274         "        \"alphaFunction\": \"EASE_IN_OUT\","
275         "        \"timePeriod\": {"
276         "          \"delay\": 0,"
277         "          \"duration\": 3"
278         "        }"
279         "      }]"
280         "    }"
281         "  },"
282         "  \"stage\": [{"
283         "    \"name\": \"greeting\","
284         "    \"type\": \"TextLabel\","
285         "    \"text\": \"Touch me\","
286         "    \"inherit\": [\"basicText\"],"
287         "    \"position\": [0, -120, 0],"
288         "    \"size\": [200, 200, 1],"
289         "    \"orientation\": [0, 0, 30],"
290         "    \"signals\": [{"
291         "      \"name\": \"touch\","
292         "      \"action\": \"play\","
293         "      \"animation\": \"animate\""
294         "    }]"
295         "  }]"
296         "}");
297
298   Builder builder = Builder::New();
299   builder.LoadFromString( json );
300   builder.AddActors( Stage::GetCurrent().GetRootLayer() );
301
302   Animation anim = builder.CreateAnimation("animate");
303
304   DALI_TEST_CHECK( anim );
305
306   Property::Map map;
307   map["ALPHA_FUNCTION"] = "EASE_IN_SQUARE";
308   anim = builder.CreateAnimation("animate", map);
309
310   DALI_TEST_CHECK( anim );
311
312   anim = builder.CreateAnimation("pathAnimation");
313
314   DALI_TEST_CHECK( anim );
315
316   // trigger play
317   // Emit touch event and check that our quit method is called
318   Integration::TouchEvent touchEvent;
319   Integration::Point point;
320   point.SetState( PointState::DOWN );
321   point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
322   touchEvent.points.push_back( point );
323   application.ProcessEvent( touchEvent );
324
325   // Render and notify
326   application.SendNotification();
327   application.Render();
328
329
330   END_TEST;
331 }
332
333 int UtcDaliBuilderAnimationN(void)
334 {
335   ToolkitTestApplication application;
336
337   // JSON with a quit event when the actor is touched
338   std::string json(
339         "{"
340         "   \"constants\":"
341         "   {"
342         "     \"TEXT\": \"Touch Me\","
343         "     \"NAME\": \"greeting\" "
344         "   },"
345         "   \"paths\":"
346         "   {"
347         "     \"path0\":"
348         "     {"
349         "       \"points\":[ [-150, -50, 0], [0.0,70.0,0.0], [190.0,-150.0,0.0] ],"
350         "       \"curvature\":0.35"
351         "     }"
352         "   },"
353         "  \"animations\": {"
354         "    \"animate\": {"
355         "      \"loop\": true,"
356         "      \"endAction\": \"BAKE\","
357         "      \"disconnectAction\": \"BAKE\","
358         "      \"properties\":"
359         "      [{"
360         "        \"actor\": \"{NAME}\","
361         "        \"property\": \"positioninvalid\","
362         "        \"value\": [300, 300, -1000],"
363         "        \"alphaFunction\": \"EASE_IN_OUT\","
364         "        \"relative\": true,"
365         "        \"timePeriod\": {"
366         "          \"delay\": 0,"
367         "          \"duration\": 3"
368         "        }"
369         "      }"
370         "      ]"
371         "    },"
372         "    \"animate2\": {"
373         "      \"loop\": true,"
374         "      \"endAction\": \"BAKE\","
375         "      \"disconnectAction\": \"BAKE\","
376         "      \"properties\":"
377         "      [{"
378         "        \"actor\": \"{NAME}\","
379         "        \"property\": \"positioninvalid\","
380         "        \"value\": [300, 300, -1000],"
381         "        \"alphaFunction\": \"EGGS_OVER_EASY\","
382         "        \"relative\": true,"
383         "        \"timePeriod\": {"
384         "          \"delay\": 0,"
385         "          \"duration\": 3"
386         "        }"
387         "      }"
388         "      ]"
389         "    },"
390         "    \"pathAnimation\": {"
391         "      \"duration\": 3.0,"
392         "      \"endAction\": \"DISCARD\","
393         "      \"disconnectAction\": \"BAKE_FINAL\","
394         "      \"properties\": [{"
395         "        \"actor\": \"greeting\","
396         "        \"path\":\"pathDoesntExist\","
397         "        \"forward\":[1,0,0],"
398         "        \"alphaFunction\": \"EASE_IN_OUT\","
399         "        \"timePeriod\": {"
400         "          \"delay\": 0,"
401         "          \"duration\": 3"
402         "        }"
403         "      }]"
404         "    }"
405         "  },"
406         "  \"stage\": [{"
407         "    \"name\": \"greeting\","
408         "    \"type\": \"TextLabel\","
409         "    \"text\": \"Touch me\","
410         "    \"inherit\": [\"basicText\"],"
411         "    \"position\": [0, -120, 0],"
412         "    \"size\": [200, 200, 1],"
413         "    \"orientation\": [0, 0, 30],"
414         "    \"signals\": [{"
415         "      \"name\": \"touch\","
416         "      \"action\": \"play\","
417         "      \"animation\": \"animate\""
418         "    }]"
419         "  },"
420         "  {"
421         "    \"name\": \"greeting2\","
422         "    \"type\": \"TextLabel\","
423         "    \"text\": \"Touch me\""
424         "  }]"
425         "}");
426
427
428   Builder builder = Builder::New();
429   builder.LoadFromString( json );
430   builder.AddActors( Stage::GetCurrent().GetRootLayer() );
431
432   Animation anim = builder.CreateAnimation("animate");
433
434   // log warning line coverage
435   anim = builder.CreateAnimation("pathAnimation");
436   DALI_TEST_CHECK(anim);
437
438   anim = builder.CreateAnimation("animate");
439   DALI_TEST_CHECK(anim);
440
441   anim = builder.CreateAnimation("animate2");
442   DALI_TEST_CHECK(anim);
443
444   // create referencing a different actor aka animation templates
445   Property::Map map;
446   map["NAME"] = "greeting2";
447   anim = builder.CreateAnimation("animate2", map);
448   DALI_TEST_CHECK(anim);
449
450   // alternative actor to use for FindChildByName
451   anim = builder.CreateAnimation("animate2", Dali::Stage::GetCurrent().GetRootLayer());
452   DALI_TEST_CHECK(anim);
453
454   // alternative actor to use for FindChildByName
455   anim = builder.CreateAnimation("animate2", map, Dali::Stage::GetCurrent().GetRootLayer());
456   DALI_TEST_CHECK(anim);
457
458
459   END_TEST;
460
461 }
462
463 int UtcDaliBuilderConstantsP(void)
464 {
465   ToolkitTestApplication application;
466
467   // JSON with a quit event when the actor is touched
468   std::string json(
469       "{"
470       "\"constants\":"
471       "{"
472       "  \"IMAGE_PATH\": \"apath\","
473       "  \"WIDTH\": 22.3,"
474       "  \"ANCHOR\": \"TOP_LEFT\","
475       "  \"PADDING\": [1,2,3,4]"
476       "},"
477       "\"stage\":"
478       "[{"
479       "  \"type\": \"ImageView\","
480       "  \"name\": \"{NAME}\","
481       "  \"size\": [100,100,1],"
482       "  \"parentOrigin\": \"TOP_LEFT\","
483       "  \"anchorPoint\": \"{ANCHOR}\","
484       "  \"padding\": \"{PADDING}\","
485       "  \"image\": { \"url\": \"dir/{IMAGE_PATH}\" },"
486       "  \"sizeWidth\": \"{WIDTH}\","
487       "  \"signals\": [{"
488       "    \"name\": \"touch\","
489       "    \"action\": \"quit\""
490       "  }]"
491       "}]"
492       "}"
493   );
494
495   Builder builder = Builder::New();
496   builder.LoadFromString( json );
497
498   builder.AddConstant( "NAME", "image" );
499
500   Property::Map map = builder.GetConstants();
501
502   Dali::Property::Value* pValue = map.Find( "NAME" );
503
504   DALI_TEST_CHECK( pValue );
505
506   pValue = map.Find( "IMAGE_PATH" );
507
508   DALI_TEST_CHECK( pValue );
509
510   Dali::Property::Value value = builder.GetConstant( "WIDTH" );
511
512   DALI_TEST_CHECK( value.GetType() != Property::NONE );
513
514   builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
515   DALI_TEST_CHECK( builder );
516
517   Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("image");
518   DALI_TEST_CHECK( actor );
519
520   END_TEST;
521 }
522
523 int UtcDaliBuilderTemplatesAndStylesP(void)
524 {
525   ToolkitTestApplication application;
526
527   // JSON with a quit event when the actor is touched
528   std::string json(
529       "{\n"
530       "\"constants\":"
531       "{"
532       "  \"SIZE\": [10,20,30]"
533       "},"
534       "\"styles\":\n"
535       "{\n"
536       "  \"imageStyle\": \n"
537       "  {\n"
538       "    \"color\": [1,0,0,1],\n"
539       "    \"actors\": {\n"
540       "      \"childImage\": {\n"
541       "        \"color\": \"34\"\n"
542       "      }\n"
543       "    }\n"
544       "  }\n"
545       "},\n"
546       "\"templates\":\n"
547       "{\n"
548       "  \"imageViewTemplate\": { \n"
549       "    \"type\": \"ImageView\",\n"
550       "    \"styles\": [\"imageStyle\"]\n"
551       "  },\n"
552       "  \"imageTree\": { \n"
553       "    \"type\": \"ImageView\",\n"
554       "    \"styles\": [\"imageStyle\"],\n"
555       "    \"name\": \"image\",\n"
556       "    \"size\": \"{SIZE}\",\n"
557       "    \"signals\": [{\n"
558       "      \"name\": \"touch\",\n"
559       "      \"action\": \"quit\"\n"
560       "    }],\n"
561       "    \"actors\": [\n"
562       "      {\n"
563       "        \"type\":\"ImageView\",\n"
564       "        \"name\":\"childImage\", \n"
565       "        \"color\": \n"
566       "          {\n"
567       "            \"r\": 10,\n"
568       "            \"g\": 10,\n"
569       "            \"b\": 10,\n"
570       "            \"a\": 100\n"
571       "          }\n"
572       "      },\n"
573       "      {\n"
574       "        \"type\":\"imageViewTemplate\",\n"
575       "        \"name\":\"childImage2\"\n"
576       "      }\n"
577       "    ]\n"
578       "  }\n"
579       "},\n"
580       "\"stage\":"
581       "[{"
582       "  \"type\": \"imageTree\","
583       "  \"size\": [100,100,1]"
584       "}]"
585       "}\n"
586   );
587
588   std::string stylejson(
589     "{\n"
590     " \"color\": [1,0,0,1],\n"
591     " \"actors\": {\n"
592     "   \"childImage\": {\n"
593     "     \"color\": \"#344353\"\n"
594     "   }\n"
595     " }\n"
596     "}\n"
597     );
598
599   std::string templatejson(
600     "{ \n"
601     "  \"type\": \"ImageView\",\n"
602     "  \"styles\": [\"imageStyle\"],\n"
603     "  \"name\": \"image\",\n"
604     "  \"size\": \"{SIZE}\",\n"
605     "  \"signals\": [{\n"
606     "    \"name\": \"touch\",\n"
607     "    \"action\": \"quit\"\n"
608     "  }],\n"
609     "  \"actors\": [\n"
610     "    {\n"
611     "      \"type\":\"ImageView\",\n"
612     "      \"name\":\"childImage\" \n"
613     "    }\n"
614     "  ]\n"
615     "}\n"
616     );
617
618   Builder builder = Builder::New();
619   builder.LoadFromString( json );
620
621   ImageView actor = ImageView::DownCast( builder.Create( "imageTree" ) );
622   DALI_TEST_CHECK( actor );
623
624   Dali::Property::Map map;
625   map["SIZE"] = Vector3(100,100,1);
626   actor = ImageView::DownCast( builder.Create( "imageTree",  map ) );
627   DALI_TEST_CHECK( actor );
628
629   // create from json snippet
630   actor = ImageView::DownCast( builder.CreateFromJson( templatejson ) );
631   DALI_TEST_CHECK( actor );
632
633
634   // NB: already applied in create
635   DALI_TEST_CHECK( builder.ApplyStyle( "imageStyle",  actor ) );
636
637   // apply from json snippet
638   DALI_TEST_CHECK( builder.ApplyFromJson( actor, stylejson ) );
639
640   END_TEST;
641 }
642
643 int UtcDaliBuilderRenderTasksP(void)
644 {
645   ToolkitTestApplication application;
646
647   // JSON with a quit event when the actor is touched
648   std::string json(
649       "{\n"
650       "\"renderTasks\":\n"
651       "{\n"
652       "  \"task0\": {\n"
653       "    \"sourceActor\": \"image\",\n"
654       "    \"cameraActor\": \"camera\" \n"
655       "  }\n"
656       "},\n"
657       "\"stage\":\n"
658       "[\n"
659       "  { \n"
660       "    \"type\": \"CameraActor\",\n"
661       "    \"name\": \"camera\"\n"
662       "  }, \n"
663       "  { \n"
664       "    \"type\": \"ImageView\",\n"
665       "    \"name\": \"image\",\n"
666       "    \"size\": [100,100,1],\n"
667       "    \"signals\": [{\n"
668       "      \"name\": \"touch\",\n"
669       "      \"action\": \"quit\"\n"
670       "    }],\n"
671       "    \"actors\": [\n"
672       "      {\n"
673       "        \"type\":\"ImageView\",\n"
674       "        \"name\":\"childImage\" \n"
675       "      }\n"
676       "    ]\n"
677       "  }\n"
678       "]\n"
679       "}\n"
680   );
681
682   Builder builder = Builder::New();
683   builder.LoadFromString( json );
684
685   unsigned int count = Stage::GetCurrent().GetRenderTaskList().GetTaskCount();
686
687   // coverage
688   builder.CreateRenderTask( "task0" );
689
690   DALI_TEST_CHECK( count <
691                    Stage::GetCurrent().GetRenderTaskList().GetTaskCount() );
692
693   END_TEST;
694 }
695
696 int UtcDaliBuilderChildActionP(void)
697 {
698   ToolkitTestApplication application;
699
700   // JSON with a quit event when the actor is touched
701   std::string json(
702       "{\n"
703       "  \"stage\":\n"
704       "  [{\n"
705       "    \"type\": \"Actor\",\n"
706       "    \"name\": \"actor\",\n"
707       "    \"size\": [100,100,1],\n"
708       "    \"parentOrigin\": \"TOP_LEFT\",\n"
709       "    \"anchorPoint\": \"TOP_LEFT\",\n"
710       "    \"actors\": [{\n"
711       "      \"type\": \"Actor\",\n"
712       "      \"name\": \"subActor\"\n"
713       "    }],\n"
714       "    \"signals\": [{\n"
715       "      \"name\": \"touch\",\n"
716       "      \"action\": \"hide\",\n"
717       "      \"actor\": \"actor\",\n"
718       "      \"childActor\": \"subActor\"\n"
719       "    }]\n"
720       "  }]\n"
721       "}\n"
722   );
723
724   Builder builder = Builder::New();
725   builder.LoadFromString( json );
726   builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
727
728   // Render and notify
729   application.SendNotification();
730   application.Render();
731
732   // Emit touch event and check that our quit method is called
733   Integration::TouchEvent touchEvent;
734   Integration::Point point;
735   point.SetState( PointState::DOWN );
736   point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
737   touchEvent.points.push_back( point );
738   application.ProcessEvent( touchEvent );
739
740   // Render and notify
741   application.SendNotification();
742   application.Render();
743
744   Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("subActor");
745   DALI_TEST_CHECK( actor );
746
747   DALI_TEST_CHECK( !actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) );
748
749   END_TEST;
750 }
751
752 int UtcDaliBuilderSetPropertyActionP(void)
753 {
754   ToolkitTestApplication application;
755
756   // JSON with a quit event when the actor is touched
757   std::string json(
758       "{\n"
759       "  \"stage\":\n"
760       "  [{\n"
761       "    \"type\": \"Actor\",\n"
762       "    \"name\": \"actor\",\n"
763       "    \"size\": [100,100,1],\n"
764       "    \"parentOrigin\": \"TOP_LEFT\",\n"
765       "    \"anchorPoint\": \"TOP_LEFT\",\n"
766       "    \"actors\": [{\n"
767       "      \"type\": \"Actor\",\n"
768       "      \"name\": \"subActor\"\n"
769       "    }],\n"
770       "    \"signals\": [{\n"
771       "      \"name\": \"touch\",\n"
772       "      \"action\": \"set\",\n"
773       "      \"actor\": \"subActor\",\n"
774       "      \"property\": \"visible\",\n"
775       "      \"value\": false\n"
776       "    }]\n"
777       "  }]\n"
778       "}\n"
779   );
780
781   Builder builder = Builder::New();
782   builder.LoadFromString( json );
783   builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
784
785   // Render and notify
786   application.SendNotification();
787   application.Render();
788
789   // Emit touch event and check that our quit method is called
790   Integration::TouchEvent touchEvent;
791   Integration::Point point;
792   point.SetState( PointState::DOWN );
793   point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
794   touchEvent.points.push_back( point );
795   application.ProcessEvent( touchEvent );
796
797   // Render and notify
798   application.SendNotification();
799   application.Render();
800
801   Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("subActor");
802   DALI_TEST_CHECK( actor );
803
804   DALI_TEST_CHECK( !actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) );
805
806   END_TEST;
807 }
808
809 int UtcDaliBuilderGenericActionP(void)
810 {
811   ToolkitTestApplication application;
812
813   // JSON with a quit event when the actor is touched
814   std::string json(
815       "{\n"
816       "  \"stage\":\n"
817       "  [{\n"
818       "    \"type\": \"Actor\",\n"
819       "    \"name\": \"actor\",\n"
820       "    \"size\": [100,100,1],\n"
821       "    \"parentOrigin\": \"TOP_LEFT\",\n"
822       "    \"anchorPoint\": \"TOP_LEFT\",\n"
823       "    \"actors\": [{\n"
824       "      \"type\": \"Actor\",\n"
825       "      \"name\": \"subActor\"\n"
826       "    }],\n"
827       "    \"signals\": [{\n"
828       "      \"name\": \"touch\",\n"
829       "      \"action\": \"hide\"\n"
830       "    }]\n"
831       "  }]\n"
832       "}\n"
833   );
834
835   Builder builder = Builder::New();
836   builder.LoadFromString( json );
837   builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
838
839   // Render and notify
840   application.SendNotification();
841   application.Render();
842
843   // Emit touch event and check that our quit method is called
844   Integration::TouchEvent touchEvent;
845   Integration::Point point;
846   point.SetState( PointState::DOWN );
847   point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
848   touchEvent.points.push_back( point );
849   application.ProcessEvent( touchEvent );
850
851   // Render and notify
852   application.SendNotification();
853   application.Render();
854
855   Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("actor");
856   DALI_TEST_CHECK( actor );
857
858   DALI_TEST_CHECK( !actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) );
859
860   END_TEST;
861 }
862
863 int UtcDaliBuilderPropertyNotificationP(void)
864 {
865   ToolkitTestApplication application;
866
867   // JSON with a quit event when the actor is touched
868   std::string json(
869       "{\n"
870       "  \"stage\":\n"
871       "  [{\n"
872       "    \"type\": \"Actor\",\n"
873       "    \"name\": \"actor\",\n"
874       "    \"size\": [100,100,1],\n"
875       "    \"parentOrigin\": \"TOP_LEFT\",\n"
876       "    \"anchorPoint\": \"TOP_LEFT\",\n"
877       "    \"actors\": [{\n"
878       "      \"type\": \"Actor\",\n"
879       "      \"name\": \"subActor\"\n"
880       "    }],\n"
881       "    \"signals\": [{\n"
882       "      \"name\": \"touch\",\n"
883       "      \"action\": \"hide\"\n"
884       "    }],\n"
885       "    \"notifications\": [{\n"
886       "      \"property\": \"visible\",\n"
887       "      \"condition\": \"False\",\n"
888       "      \"action\": \"show\"\n"
889       "    },\n"
890       "    {\n"
891       "      \"property\": \"positionX\",\n"
892       "      \"condition\": \"LessThan\",\n"
893       "      \"arg0\": 0.0,\n"
894       "      \"action\": \"show\"\n"
895       "    },\n"
896       "    {\n"
897       "      \"property\": \"positionY\",\n"
898       "      \"condition\": \"GreaterThan\",\n"
899       "      \"arg0\": 200.0,\n"
900       "      \"action\": \"show\"\n"
901       "    },\n"
902       "    {\n"
903       "      \"property\": \"positionZ\",\n"
904       "      \"condition\": \"Inside\",\n"
905       "      \"arg0\": 0.0,\n"
906       "      \"arg1\": 10.0,\n"
907       "      \"action\": \"show\"\n"
908       "    },\n"
909       "    {\n"
910       "      \"property\": \"positionZ\",\n"
911       "      \"condition\": \"Outside\",\n"
912       "      \"arg0\": 40.0,\n"
913       "      \"arg1\": 50.0,\n"
914       "      \"action\": \"show\"\n"
915       "    }]\n"
916       "  }]\n"
917       "}\n"
918   );
919
920   Builder builder = Builder::New();
921   builder.LoadFromString( json );
922   builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
923
924   // Render and notify
925   application.SendNotification();
926   application.Render();
927
928   // Emit touch event and check that our quit method is called
929   Integration::TouchEvent touchEvent;
930   Integration::Point point;
931   point.SetState( PointState::DOWN );
932   point.SetScreenPosition( Vector2( 10.0f, 10.0f ) );
933   touchEvent.points.push_back( point );
934   application.ProcessEvent( touchEvent );
935
936   // Render and notify
937   application.SendNotification();
938   application.Render();
939
940   // Render and notify
941   application.SendNotification();
942   application.Render();
943
944   Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("actor");
945   DALI_TEST_CHECK( actor );
946
947   DALI_TEST_CHECK( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) );
948
949   END_TEST;
950 }
951
952 int UtcDaliBuilderPropertyNotificationN(void)
953 {
954   ToolkitTestApplication application;
955
956   // JSON with a quit event when the actor is touched
957   std::string json(
958       "{\n"
959       "  \"stage\":\n"
960       "  [{\n"
961       "    \"type\": \"Actor\",\n"
962       "    \"notifications\": [{\n"
963       "      \"property\": \"visible\",\n"
964       "      \"condition\": \"ErrorCondition\",\n"
965       "      \"action\": \"show\"\n"
966       "    }]\n"
967       "  }]\n"
968       "}\n"
969   );
970
971   try
972   {
973     Builder builder = Builder::New();
974     builder.LoadFromString( json );
975     builder.AddActors ( Stage::GetCurrent().GetRootLayer() );
976     DALI_TEST_CHECK( false );
977   }
978   catch(...)
979   {
980     DALI_TEST_CHECK( true );
981   }
982
983   END_TEST;
984 }
985
986
987
988 int UtcDaliBuilderCustomPropertyP(void)
989 {
990   ToolkitTestApplication application;
991
992   // JSON with a quit event when the actor is touched
993   std::string json(
994       "{\n"
995       "\"templates\":\n"
996       "{\n"
997       "  \"imageTree\": { \n"
998       "    \"type\": \"ImageView\",\n"
999       "    \"name\": \"image\",\n"
1000       "    \"size\": [100,100,1],\n"
1001       "    \"signals\": [{\n"
1002       "      \"name\": \"touch\",\n"
1003       "      \"action\": \"quit\"\n"
1004       "    }],\n"
1005       "    \"properties\": {\n"
1006       "      \"newproperty\": true\n"
1007       "    },\n"
1008       "    \"animatableProperties\": {\n"
1009       "      \"newAnimatableproperty\": 3\n"
1010       "    },\n"
1011       "    \"actors\": [\n"
1012       "      {\n"
1013       "        \"type\":\"ImageView\",\n"
1014       "        \"name\":\"childImage\" \n"
1015       "      }\n"
1016       "    ]\n"
1017       "  }\n"
1018       "}\n"
1019       "}\n"
1020   );
1021
1022   Builder builder = Builder::New();
1023   builder.LoadFromString( json );
1024
1025   ImageView actor = ImageView::DownCast( builder.Create( "imageTree" ) );
1026   DALI_TEST_CHECK( actor );
1027
1028   // NB: already applied in create
1029   Property::Index index = actor.GetPropertyIndex("newproperty");
1030   DALI_TEST_CHECK( Property::INVALID_INDEX != index );
1031   Property::Value value = actor.GetProperty(index);
1032   DALI_TEST_CHECK( value.Get<bool>() == true );
1033
1034   index = actor.GetPropertyIndex("newAnimatableproperty");
1035   DALI_TEST_CHECK( Property::INVALID_INDEX != index );
1036   value = actor.GetProperty(index);
1037   DALI_TEST_CHECK( value.Get<int>() == 3 );
1038
1039   END_TEST;
1040 }
1041
1042 int UtcDaliBuilderCustomShaderP(void)
1043 {
1044   ToolkitTestApplication application;
1045
1046   // JSON with a quit event when the actor is touched
1047   std::string json(
1048     "{\n"
1049     "  \"stage\": [\n"
1050     "    {\n"
1051     "      \"type\": \"ImageView\",\n"
1052     "      \"name\": \"Image1\",\n"
1053     "      \"position\": [\n"
1054     "        0.40461349487305,\n"
1055     "        0.9150390625,\n"
1056     "        0.0\n"
1057     "      ],\n"
1058     "      \"parentOrigin\": [0.5, 0.5, 0.5],\n"
1059     "      \"size\": [200, 200, 0],\n"
1060     "      \"effect\": \"Ripple2D\",\n"
1061     "      \"image\": {\n"
1062     "        \"url\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\",\n"
1063     "        \"desiredWidth\": 200,\n"
1064     "        \"desiredHeight\": 80,\n"
1065     "        \"shader\": {\n"
1066     "           \"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"
1067     "        }\n"
1068     "      },\n"
1069     "      \"customAnimatableProperties\": {\n"
1070     "         \"uAmplitude\": 0.02,\n"
1071     "         \"uTime\": 0.0\n"
1072     "      },\n"
1073     "      \"signals\": [\n"
1074     "        {\n"
1075     "          \"name\": \"onStage\",\n"
1076     "          \"action\": \"play\",\n"
1077     "          \"animation\": \"Animation_1\"\n"
1078     "        }\n"
1079     "      ]\n"
1080     "    }\n"
1081     "  ],\n"
1082     "  \"animations\": {\n"
1083     "    \"Animation_1\": {\n"
1084     "      \"loop\":true,\n"
1085     "      \"properties\": [\n"
1086     "        {\n"
1087     "          \"actor\": \"Image1\",\n"
1088     "          \"property\": \"uTime\",\n"
1089     "          \"value\": 10.0,\n"
1090     "          \"alphaFunction\": \"LINEAR\",\n"
1091     "          \"timePeriod\": {\n"
1092     "            \"delay\": 0,\n"
1093     "            \"duration\": 10.0\n"
1094     "          }\n"
1095     "        }\n"
1096     "      ]\n"
1097     "    }\n"
1098     "  }\n"
1099     "}\n"
1100
1101   );
1102
1103   Builder builder = Builder::New();
1104   builder.LoadFromString( json );
1105
1106   builder.AddActors ( "stage", Stage::GetCurrent().GetRootLayer() );
1107
1108   // Render and notify
1109   application.SendNotification();
1110   application.Render();
1111
1112   Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("Image1");
1113
1114   // coverage
1115   DALI_TEST_CHECK( actor );
1116
1117   END_TEST;
1118 }
1119
1120
1121 int UtcDaliBuilderLoadFromStringN(void)
1122 {
1123   ToolkitTestApplication application;
1124
1125   // JSON with a quit event when the actor is touched
1126   std::string json(
1127       "asdfsadf dsf asdf asdf {"
1128          "\"stage\":"
1129          "[{"
1130            "\"type\": \"Actor\","
1131            "\"size\": [100,100,1],"
1132            "\"parentOrigin\": \"TOP_LEFT\","
1133            "\"anchorPoint\": \"TOP_LEFT\","
1134            "\"signals\": [{"
1135              "\"name\": \"touch\","
1136              "\"action\": \"quit\""
1137            "}]"
1138          "}]"
1139       "}"
1140   );
1141   Builder builder = Builder::New();
1142
1143   bool assert1 = false;
1144
1145   try
1146   {
1147     builder.LoadFromString( json );
1148   }
1149   catch( Dali::DaliException& e )
1150   {
1151     DALI_TEST_PRINT_ASSERT( e );
1152     DALI_TEST_EQUALS(e.condition, "!\"Cannot parse JSON\"", TEST_LOCATION);
1153     assert1 = true;
1154   }
1155
1156   DALI_TEST_CHECK( assert1 );
1157
1158   END_TEST;
1159 }
1160
1161
1162 int UtcDaliBuilderAddActorsP(void)
1163 {
1164   ToolkitTestApplication application;
1165
1166   // JSON with a quit event when the actor is touched
1167   std::string json(
1168       "{\n"
1169       "  \"arbitarysection\":\n"
1170       "  [{\n"
1171       "    \"type\": \"Actor\",\n"
1172       "    \"name\": \"actor\",\n"
1173       "    \"size\": [100,100,1],\n"
1174       "    \"parentOrigin\": \"TOP_LEFT\",\n"
1175       "    \"anchorPoint\": \"TOP_LEFT\",\n"
1176       "    \"actors\": [{\n"
1177       "      \"type\": \"Actor\",\n"
1178       "      \"name\": \"subActor\",\n"
1179       "      \"visible\": false\n"
1180       "    }],\n"
1181       "    \"signals\": [{\n"
1182       "      \"name\": \"touch\",\n"
1183       "      \"action\": \"hide\",\n"
1184       "      \"actor\": \"actor\",\n"
1185       "      \"childActor\": \"subActor\"\n"
1186       "    }]\n"
1187       "  }]\n"
1188       "}\n"
1189   );
1190
1191   Builder builder = Builder::New();
1192   builder.LoadFromString( json );
1193   builder.AddActors ( "arbitarysection", Stage::GetCurrent().GetRootLayer() );
1194
1195   // Render and notify
1196   application.SendNotification();
1197   application.Render();
1198
1199   Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("subActor");
1200   DALI_TEST_CHECK( actor );
1201
1202   DALI_TEST_CHECK( !actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) );
1203
1204   END_TEST;
1205 }
1206
1207 int UtcDaliBuilderPathConstraintsP(void)
1208 {
1209   ToolkitTestApplication application;
1210
1211   // JSON with a quit event when the actor is touched
1212   std::string json(
1213     "{\n"
1214     "  \"constants\":\n"
1215     "  {\n"
1216     "    \"FB_WIDTH\": 200.0,\n"
1217     "    \"FB_HEIGHT\": 200.0,\n"
1218     "    \"FB_SIZE\": [200,200],\n"
1219     "    \"FB_ASPECT_RATIO\": 1\n"
1220     "  },\n"
1221     "  \"stage\": [\n"
1222     "    {\n"
1223     "      \"type\": \"ImageView\",\n"
1224     "      \"name\": \"Image1\",\n"
1225     "      \"size\": [200, 200, 0],\n"
1226     "      \"parentOrigin\": [0.5, 0.5, 0.5],\n"
1227     "      \"effect\": \"Ripple2D\",\n"
1228     "      \"image\": {\n"
1229     "        \"url\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\"\n"
1230     "      },\n"
1231     "      \"signals\": [\n"
1232     "        {\n"
1233     "          \"name\": \"onStage\",\n"
1234     "          \"action\": \"play\",\n"
1235     "          \"animation\": \"pathAnimation\"\n"
1236     "        },\n"
1237     "        {\n"
1238     "          \"name\": \"onStage\",\n"
1239     "          \"action\": \"applyConstraint\",\n"
1240     "          \"constrainer\": \"constrainer0\",\n"
1241     "          \"properties\":\n"
1242     "          [\n"
1243     "            {\n"
1244     "              \"source\": \"Image1\",\n"
1245     "              \"sourceProperty\": \"positionX\",\n"
1246     "              \"target\": \"Image1\",\n"
1247     "              \"targetProperty\": \"colorRed\",\n"
1248     "              \"range\": [-300,300]\n"
1249     "            }\n"
1250     "          ]\n"
1251     "        },\n"
1252     "        {\n"
1253     "          \"name\": \"onStage\",\n"
1254     "          \"action\": \"applyConstraint\",\n"
1255     "          \"constrainer\": \"constrainer1\",\n"
1256     "          \"properties\":\n"
1257     "          [\n"
1258     "            {\n"
1259     "              \"source\": \"Image1\",\n"
1260     "              \"sourceProperty\": \"positionX\",\n"
1261     "              \"target\": \"Image1\",\n"
1262     "              \"targetProperty\": \"colorBlue\",\n"
1263     "              \"range\": [-300,300]\n"
1264     "            }\n"
1265     "          ]\n"
1266     "        },\n"
1267     "        {\n"
1268     "          \"name\": \"offStage\",\n"
1269     "          \"action\": \"removeConstraints\",\n"
1270     "          \"constrainer\": \"constrainer0\",\n"
1271     "          \"properties\":\n"
1272     "          [\n"
1273     "            {\n"
1274     "              \"source\": \"Image1\",\n"
1275     "              \"sourceProperty\": \"positionX\",\n"
1276     "              \"target\": \"Image1\",\n"
1277     "              \"targetProperty\": \"colorRed\",\n"
1278     "              \"range\": [-300,300]\n"
1279     "            }\n"
1280     "          ]\n"
1281     "        },\n"
1282     "        {\n"
1283     "          \"name\": \"offStage\",\n"
1284     "          \"action\": \"removeConstraints\",\n"
1285     "          \"constrainer\": \"constrainer1\",\n"
1286     "          \"properties\":\n"
1287     "          [\n"
1288     "            {\n"
1289     "              \"source\": \"Image1\",\n"
1290     "              \"sourceProperty\": \"positionX\",\n"
1291     "              \"target\": \"Image1\",\n"
1292     "              \"targetProperty\": \"colorBlue\",\n"
1293     "              \"range\": [-300,300]\n"
1294     "            }\n"
1295     "          ]\n"
1296     "        }\n"
1297     "      ]\n"
1298     "    }\n"
1299     "  ],\n"
1300     "  \"paths\":\n"
1301     "  {\n"
1302     "    \"path0\":\n"
1303     "    {\n"
1304     "      \"points\":[ [-150, -50, 0], [0.0,70.0,0.0], [190.0,-150.0,0.0] ],\n"
1305     "      \"curvature\":0.35\n"
1306     "    }\n"
1307     "  },\n"
1308     "  \"constrainers\":\n"
1309     "  {\n"
1310     "    \"constrainer0\":\n"
1311     "    {\n"
1312     "      \"type\": \"PathConstrainer\",\n"
1313     "      \"points\": [ [0, 0, 0], [0,0,0], [0,0,0] ],\n"
1314     "      \"controlPoints\": [ [0, 0, 0], [0,0,0], [0,0,0] ]\n"
1315     "    },\n"
1316     "    \"constrainer1\":\n"
1317     "    {\n"
1318     "      \"type\": \"LinearConstrainer\",\n"
1319     "      \"value\": [ 0, 0, 0 ]\n"
1320     "    }\n"
1321     "  },\n"
1322     "  \"animations\": {\n"
1323     "    \"pathAnimation\": {\n"
1324     "      \"duration\": 3.0,\n"
1325     "      \"properties\":\n"
1326     "      [{\n"
1327     "        \"actor\": \"Image1\",\n"
1328     "        \"path\":\"path0\",\n"
1329     "        \"forward\":[1,0,0],\n"
1330     "        \"alphaFunction\": \"EASE_IN_OUT\",\n"
1331     "        \"timePeriod\": {\n"
1332     "          \"delay\": 0,\n"
1333     "          \"duration\": 3\n"
1334     "        }\n"
1335     "      },\n"
1336     "       {\n"
1337     "         \"actor\": \"Image1\",\n"
1338     "         \"property\": \"uTime\",\n"
1339     "         \"value\": 10.0,\n"
1340     "         \"alphaFunction\": \"LINEAR\",\n"
1341     "         \"timePeriod\": {\n"
1342     "           \"delay\": 0,\n"
1343     "           \"duration\": 10.0\n"
1344     "         },\n"
1345     "         \"gui-builder-timeline-color\": \"#8dc0da\"\n"
1346     "       }]\n"
1347     "    },\n"
1348     "    \"Animation_1\": {\n"
1349     "      \"loop\":true,\n"
1350     "      \"properties\": [\n"
1351     "        {\n"
1352     "          \"actor\": \"Image1\",\n"
1353     "          \"property\": \"uTime\",\n"
1354     "          \"value\": 10.0,\n"
1355     "          \"alphaFunction\": \"LINEAR\",\n"
1356     "          \"timePeriod\": {\n"
1357     "            \"delay\": 0,\n"
1358     "            \"duration\": 10.0\n"
1359     "          },\n"
1360     "          \"gui-builder-timeline-color\": \"#8dc0da\"\n"
1361     "        }\n"
1362     "      ]\n"
1363     "    }\n"
1364     "  }\n"
1365     "}\n");
1366
1367   Builder builder = Builder::New();
1368
1369   // frame buffer coverage
1370   builder.LoadFromString( json );
1371
1372   // Render and notify
1373   application.SendNotification();
1374   application.Render();
1375
1376   Dali::Path path =  builder.GetPath( "path0" );
1377   DALI_TEST_CHECK( path );
1378
1379   Dali::Path path2 =  builder.GetPath( "path0" );
1380   DALI_TEST_CHECK( path2 );
1381   DALI_TEST_CHECK( path == path2 );
1382
1383   Dali::PathConstrainer constrainer0 = builder.GetPathConstrainer( "constrainer0" );
1384   DALI_TEST_CHECK( constrainer0 );
1385
1386   Dali::PathConstrainer constrainer0_2 = builder.GetPathConstrainer( "constrainer0" );
1387   DALI_TEST_CHECK( constrainer0_2 );
1388   DALI_TEST_CHECK( constrainer0 == constrainer0_2 );
1389
1390   Dali::LinearConstrainer constrainer1 = builder.GetLinearConstrainer( "constrainer1" );
1391   DALI_TEST_CHECK( constrainer1 );
1392
1393   Dali::LinearConstrainer constrainer1_2 = builder.GetLinearConstrainer( "constrainer1" );
1394   DALI_TEST_CHECK( constrainer1 == constrainer1_2 );
1395
1396   // For coverage
1397
1398   Actor actor = Actor::New();
1399   Stage::GetCurrent().Add( actor );
1400   builder.AddActors( actor );
1401
1402   // Render and notify
1403   application.SendNotification();
1404   application.Render();
1405
1406   actor.GetChildAt( 0 ).Unparent();
1407
1408   END_TEST;
1409 }
1410
1411 #define CHECK_MAP_ELEMENT( xMap, xKey, xType, xPropType, xExpected, xLocation ) \
1412   {                                                                       \
1413     Property::Value* value = xMap->Find( xKey );                          \
1414     DALI_TEST_EQUALS( value==NULL, false, xLocation);                     \
1415     if( value != NULL )                                                   \
1416     {                                                                     \
1417       DALI_TEST_EQUALS( value->GetType(), xPropType, xLocation );         \
1418       xType result;                                                       \
1419       value->Get(result);                                                 \
1420       DALI_TEST_EQUALS( result, xExpected, TEST_LOCATION );               \
1421       std::ostringstream oss;                                             \
1422       oss << "Animation element " << xKey << "= " << result << std::endl; \
1423       tet_printf( oss.str().c_str() );                                    \
1424     }                                                                     \
1425     else                                                                  \
1426     {                                                                     \
1427       tet_printf("Can't find map element " xKey "\n");                    \
1428     }                                                                     \
1429   }
1430
1431
1432 int UtcDaliBuilderMapping01(void)
1433 {
1434   ToolkitTestApplication application;
1435
1436   const char* json =
1437     "{\n"
1438     "  \"mappings\":\n"
1439     "  {\n"
1440     "    \"buttonPressFadeOut\":{\n"
1441     "      \"alphaFunction\":\"EASE_OUT\",\n"
1442     "      \"timePeriod\":{\n"
1443     "        \"delay\":0.0,\n"
1444     "        \"duration\":0.4\n"
1445     "      }\n"
1446     "    },\n"
1447     "    \"buttonPressFadeIn\":{\n"
1448     "      \"alphaFunction\":\"EASE_IN\",\n"
1449     "      \"timePeriod\":{\n"
1450     "        \"delay\":0.4,\n"
1451     "        \"duration\":0.5\n"
1452     "      }\n"
1453     "    },\n"
1454     "    \"transition:buttonPressed\":\n"
1455     "    [\n"
1456     "      {\n"
1457     "        \"target\": \"unselectedBackgroundRenderer\",\n"
1458     "        \"property\": \"opacity\",\n"
1459     "        \"value\": 0,\n"
1460     "        \"animator\":\"<buttonPressFadeOut>\"\n"
1461     "      }\n"
1462     "    ],\n"
1463     "    \"transition:buttonReleased\":\n"
1464     "    [\n"
1465     "      {\n"
1466     "        \"target\": \"unselectedBackgroundRenderer\",\n"
1467     "        \"property\": \"opacity\",\n"
1468     "        \"value\": 1,\n"
1469     "        \"animator\":\"<buttonPressFadeIn>\"\n"
1470     "      },\n"
1471     "      {\n"
1472     "        \"target\": \"unselectedForegroundRenderer\",\n"
1473     "        \"property\": \"scale\",\n"
1474     "        \"value\": [ 1, 1, 1 ],\n"
1475     "        \"animator\":\"<buttonPressFadeIn>\"\n"
1476     "      },\n"
1477     "      {\n"
1478     "        \"target\": \"selectedBackgroundRenderer\",\n"
1479     "        \"property\": \"opacity\",\n"
1480     "        \"value\": 0,\n"
1481     "        \"animator\": \"<buttonPressFadeOut>\"\n"
1482     "      },\n"
1483     "      {\n"
1484     "        \"target\": \"selectedForegroundRenderer\",\n"
1485     "        \"property\": \"scale\",\n"
1486     "        \"value\": [ 0, 0, 0 ],\n"
1487     "        \"animator\":\"<buttonPressFadeOut>\"\n"
1488     "      }\n"
1489     "    ]\n"
1490     "  },\n"
1491     "  \"styles\":\n"
1492     "  {\n"
1493     "    \"testbutton\":\n"
1494     "    {\n"
1495     "      \"pressTransition\":\"<transition:buttonPressed>\",\n"
1496     "      \"releaseTransition\":\"<transition:buttonReleased>\"\n"
1497     "    }\n"
1498     "  }\n"
1499     "}\n";
1500
1501   Builder builder = Builder::New();
1502   builder.LoadFromString( json );
1503
1504   Test::TestButton testButton = Test::TestButton::New();
1505   Stage::GetCurrent().Add( testButton );
1506
1507   // Render and notify
1508   application.SendNotification();
1509   application.Render();
1510
1511   DALI_TEST_CHECK( builder.ApplyStyle( "testbutton", testButton ) );
1512
1513   // Now check that it has loaded the transition correctly:
1514   Property::Value transition = testButton.GetProperty(Test::TestButton::Property::PRESS_TRANSITION);
1515   DALI_TEST_EQUALS( transition.GetType(), Property::ARRAY, TEST_LOCATION );
1516   Property::Array* array = transition.GetArray();
1517
1518   DALI_TEST_EQUALS( array->Size(), 1, TEST_LOCATION );
1519   Property::Value element = array->GetElementAt(0);
1520   DALI_TEST_CHECK( element.GetType() == Property::MAP );
1521   Property::Map* map = element.GetMap();
1522
1523   CHECK_MAP_ELEMENT(map, "target", std::string, Property::STRING, "unselectedBackgroundRenderer", TEST_LOCATION);
1524   CHECK_MAP_ELEMENT(map, "property", std::string, Property::STRING, "opacity", TEST_LOCATION);
1525   CHECK_MAP_ELEMENT(map, "alphaFunction", int, Property::INTEGER, (int)Dali::AlphaFunction::EASE_OUT, TEST_LOCATION);
1526   CHECK_MAP_ELEMENT(map, "timePeriodDelay", float, Property::FLOAT, 0.0f, TEST_LOCATION);
1527   CHECK_MAP_ELEMENT(map, "timePeriodDuration", float, Property::FLOAT, 0.4f, TEST_LOCATION);
1528
1529   END_TEST;
1530 }
1531
1532
1533 int UtcDaliBuilderMappingCycleCheck(void)
1534 {
1535   ToolkitTestApplication application;
1536
1537   std::string json(
1538     "{\n"
1539     "  \"mappings\":\n"
1540     "  {\n"
1541     "    \"cyclicKey1\":\"<cyclicKey1>\",\n"
1542     "    \"cyclicKey2\":\"<cyclicKey3>\",\n"
1543     "    \"cyclicKey3\":\"<cyclicKey2>\",\n"
1544     "    \"FadeOut\":{\n"
1545     "      \"alphaFunction\":\"EASE_IN\",\n"
1546     "      \"timePeriod\":{\n"
1547     "        \"delay\":\"<cyclicKey3>\",\n"
1548     "        \"duration\":0.6\n"
1549     "      }\n"
1550     "    },\n"
1551     "    \"transition:buttonPressed\":\n"
1552     "    [\n"
1553     "      {\n"
1554     "        \"target\": \"<cyclicKey1>\",\n"
1555     "        \"property\": \"<cyclicKey2>\",\n"
1556     "        \"value\": 0,\n"
1557     "        \"animator\":\"<FadeOut>\"\n"
1558     "      }\n"
1559     "    ]\n"
1560     "  },\n"
1561     "  \"styles\":\n"
1562     "  {\n"
1563     "    \"testbutton\":\n"
1564     "    {\n"
1565     "      \"pressTransition\":\"<transition:buttonPressed>\",\n"
1566     "      \"releaseTransition\":\"<cyclicKey2>\",\n"
1567     "      \"disabledTransition\":\"<cyclicKey3>\",\n"
1568     "      \"enabledTransition\":\"<unknownKey>\"\n"
1569     "    }\n"
1570     "  }\n"
1571     "}\n");
1572
1573   Builder builder = Builder::New();
1574   builder.LoadFromString( json );
1575
1576   Test::TestButton testButton = Test::TestButton::New();
1577   Stage::GetCurrent().Add( testButton );
1578
1579   // Render and notify
1580   application.SendNotification();
1581   application.Render();
1582
1583   DALI_TEST_CHECK( builder.ApplyStyle( "testbutton", testButton ) );
1584
1585   // Now check that it has loaded the transition correctly:
1586   Property::Value transition = testButton.GetProperty(Test::TestButton::Property::PRESS_TRANSITION);
1587   DALI_TEST_EQUALS( transition.GetType(), Property::ARRAY, TEST_LOCATION );
1588   Property::Array* array = transition.GetArray();
1589
1590   DALI_TEST_EQUALS( array->Size(), 1, TEST_LOCATION );
1591   Property::Value element = array->GetElementAt(0);
1592   DALI_TEST_CHECK( element.GetType() == Property::MAP );
1593   Property::Map* map = element.GetMap();
1594
1595   CHECK_MAP_ELEMENT(map, "target", std::string, Property::STRING, "", TEST_LOCATION);
1596   CHECK_MAP_ELEMENT(map, "property", std::string, Property::STRING, "", TEST_LOCATION);
1597   CHECK_MAP_ELEMENT(map, "timePeriodDuration", float, Property::FLOAT, 0.6f, TEST_LOCATION);
1598
1599   END_TEST;
1600 }
1601
1602 int UtcDaliBuilderTypeCasts(void)
1603 {
1604   ToolkitTestApplication application;
1605
1606   std::string json(
1607     "{"
1608        "\"stage\":"
1609        "[{"
1610          "\"type\": \"Layer\","
1611          "\"maximumSize\": { \"typeCast\":\"vector2\", \"value\":[100,15] },"
1612          "\"position\":    { \"typeCast\":\"vector3\", \"value\":[100,10,1] },"
1613          "\"color\":       { \"typeCast\":\"vector4\", \"value\":[0.5,0.5,0.5,1] },"
1614          "\"sensitive\":   { \"typeCast\":\"boolean\", \"value\":false },"
1615          "\"orientation\": { \"typeCast\":\"rotation\", \"value\":[10,10,10,10] },"
1616          "\"colorMode\":   { \"typeCast\":\"string\", \"value\":\"USE_OWN_MULTIPLY_PARENT_COLOR\" },"
1617          "\"clippingBox\": { \"typeCast\":\"rect\", \"value\":[10,10,10,10] },"
1618          "\"padding\":     { \"typeCast\":\"extents\", \"value\":[10,10,10,10] }"
1619       "}]"
1620     "}"
1621   );
1622
1623   Actor rootActor = Actor::New();
1624   Stage::GetCurrent().Add( rootActor );
1625
1626   Builder builder = Builder::New();
1627   builder.LoadFromString( json );
1628   builder.AddActors( rootActor );
1629
1630   application.SendNotification();
1631   application.Render();
1632
1633   Actor createdActor = rootActor.GetChildAt( 0 );
1634   DALI_TEST_EQUALS( createdActor.GetProperty< Vector2 >( Actor::Property::MAXIMUM_SIZE ), Vector2(100.0f,15.0f), TEST_LOCATION );
1635   DALI_TEST_EQUALS( createdActor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3(100.0f,10.0f,1.0f), TEST_LOCATION );
1636   DALI_TEST_EQUALS( createdActor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Vector4(0.5f,0.5f,0.5f,1.0f), TEST_LOCATION );
1637   DALI_TEST_EQUALS( createdActor.GetProperty< bool >( Actor::Property::SENSITIVE ), false, TEST_LOCATION );
1638   DALI_TEST_EQUALS( createdActor.GetColorMode(), USE_OWN_MULTIPLY_PARENT_COLOR, TEST_LOCATION );
1639
1640   END_TEST;
1641 }
1642
1643 int UtcDaliBuilderBuilderControl(void)
1644 {
1645   ToolkitTestApplication application;
1646
1647   std::string json(
1648     "{"
1649        "\"stage\":"
1650        "[{"
1651          "\"type\": \"BuilderControl\","
1652          "\"integerProperty\": 10,"
1653          "\"matrix3Property\": [ 1,2,3,4,5,6,7,8,9 ],"
1654          "\"matrixProperty\":  [ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 ],"
1655          "\"noneProperty\": 10"
1656       "}]"
1657     "}"
1658   );
1659
1660   Actor rootActor = Actor::New();
1661   Stage::GetCurrent().Add( rootActor );
1662
1663   Builder builder = Builder::New();
1664   builder.LoadFromString( json );
1665   builder.AddActors( rootActor );
1666
1667   application.SendNotification();
1668   application.Render();
1669
1670   DALI_TEST_EQUALS( BuilderControlProperty::gSetPropertyCalledCount, 4, TEST_LOCATION );
1671
1672   END_TEST;
1673 }
1674
1675 int UtcDaliBuilderCustomControl(void)
1676 {
1677   ToolkitTestApplication application;
1678
1679   std::string json(
1680     "{"
1681        "\"stage\":"
1682        "[{"
1683          "\"type\": \"DummyControl\","
1684          "\"name\": \"I can haz custom Control\""
1685       "}]"
1686     "}"
1687   );
1688
1689   Actor rootActor = Actor::New();
1690   Stage::GetCurrent().Add( rootActor );
1691
1692   Builder builder = Builder::New();
1693   builder.LoadFromString( json );
1694   builder.AddActors( rootActor );
1695
1696   application.SendNotification();
1697   application.Render();
1698
1699   Actor customControl = rootActor.FindChildByName( "I can haz custom Control" );
1700
1701   // Test that we have the correct type of custom control
1702   DummyControl dummyControl = DummyControl::DownCast( customControl );
1703   DALI_TEST_CHECK( dummyControl );
1704   if( dummyControl )
1705   {
1706     DALI_TEST_CHECK( typeid(dummyControl.GetImplementation()) == typeid(DummyControlImpl) );
1707   }
1708
1709   END_TEST;
1710 }
1711
1712 int UtcDaliBuilderActionsWithParams(void)
1713 {
1714   ToolkitTestApplication application;
1715
1716   // JSON with a quit event when the actor is touched
1717   std::string json(
1718       "{\n"
1719       "\"stage\":\n"
1720       "[\n"
1721       "  { \n"
1722       "    \"type\": \"ImageView\",\n"
1723       "    \"name\": \"image\",\n"
1724       "    \"size\": [100,100,1],\n"
1725       "    \"signals\": [{\n"
1726       "      \"name\": \"touch\",\n"
1727       "      \"action\": \"show\",\n"
1728       "      \"parameters\": {\n"
1729       "        \"property1\" : 10,\n"
1730       "        \"property2\" : [1,2],\n"
1731       "        \"property3\" : [1,2,3],\n"
1732       "        \"property4\" : [1,2,3,4]\n"
1733       "      }\n"
1734       "    }]\n"
1735       "  }\n"
1736       "]\n"
1737       "}\n"
1738   );
1739
1740   Builder builder = Builder::New();
1741   builder.LoadFromString( json );
1742   builder.AddActors( Stage::GetCurrent().GetRootLayer() );
1743
1744   DALI_TEST_CHECK( true ); // For Coverage
1745
1746   END_TEST;
1747 }
1748
1749 int UtcDaliBuilderConfigurationP(void)
1750 {
1751   ToolkitTestApplication application;
1752
1753   // JSON with a quit event when the actor is touched
1754   std::string json(
1755       "{\n"
1756       "  \"config\":\n"
1757       "  {\n"
1758       "    \"alwaysShowFocus\":true\n"
1759       "  }\n"
1760       "}\n"
1761   );
1762
1763   Builder builder = Builder::New();
1764   builder.LoadFromString( json );
1765
1766   Property::Map map = builder.GetConfigurations();
1767
1768   Dali::Property::Value* pValue = map.Find( "alwaysShowFocus" );
1769
1770   DALI_TEST_CHECK( pValue );
1771
1772   bool value = pValue->Get<bool>();
1773
1774   DALI_TEST_CHECK( value );
1775
1776   END_TEST;
1777 }
1778
1779
1780 int UtcDaliBase64EncodingP(void)
1781 {
1782   std::vector<uint32_t> data = { 0, 1, 2, 3, 4, 5, std::numeric_limits<uint32_t>::min(), std::numeric_limits<uint32_t>::max()  };
1783
1784   Property::Value value;
1785   EncodeBase64PropertyData( value, data );
1786
1787   std::cout << "Max uint32_t:" << std::numeric_limits<uint32_t>::max() << std::endl;
1788   std::cout << "Input data:  ";
1789   std::ostream_iterator<uint32_t> out_it (std::cout,", ");
1790   std::copy ( data.begin(), data.end(), out_it );
1791   std::cout << std::endl;
1792
1793   std::string output;
1794   DALI_TEST_CHECK( value.Get( output ) );
1795   DALI_TEST_EQUALS( output, "AAAAAAEAAAACAAAAAwAAAAQAAAAFAAAAAAAAAP////8", TEST_LOCATION );
1796
1797   std::cout << "Output data:  " << output << std::endl;
1798
1799   END_TEST;
1800 }
1801
1802 int UtcDaliBase64EncodingN(void)
1803 {
1804   tet_infoline( "Test encoding an empty vector returns empty string" );
1805   std::vector<uint32_t> data;
1806
1807   Property::Value value;
1808   EncodeBase64PropertyData( value, data );
1809
1810   std::string output;
1811   DALI_TEST_CHECK( value.Get( output ) );
1812   DALI_TEST_EQUALS( output.empty(), true, TEST_LOCATION );
1813
1814   END_TEST;
1815 }
1816
1817 template <typename T>
1818 int b64l(std::vector<T>&data)
1819 {
1820   auto lengthInBytes = 4*data.size();
1821   return ceil( lengthInBytes * 1.33333f );
1822 }
1823
1824 int UtcDaliBase64EncodingP02(void)
1825 {
1826   tet_infoline( "Test encoding vectors of lengths m .. m+4 encode and decode back to the same length vectors" );
1827
1828   std::vector<uint32_t> testData;
1829   for(int i=0; i<8; ++i ) // 8 chosen to stay within single string output
1830   {
1831     testData.push_back(i);
1832   }
1833   Property::Value value;
1834   EncodeBase64PropertyData( value, testData );
1835
1836   std::string output;
1837   DALI_TEST_CHECK( value.Get( output ) );
1838   DALI_TEST_EQUALS( output.empty(), false, TEST_LOCATION);
1839   DALI_TEST_EQUALS( output.length(), b64l(testData), TEST_LOCATION );
1840
1841   std::vector<uint32_t> outData;
1842   DecodeBase64PropertyData( value, outData );
1843   DALI_TEST_EQUALS( testData.size(), outData.size(), TEST_LOCATION );
1844   DALI_TEST_EQUALS( std::equal( testData.begin(), testData.end(), outData.begin()), true, TEST_LOCATION );
1845
1846   // n+1
1847   testData.push_back( 12345 );
1848   EncodeBase64PropertyData( value, testData );
1849
1850   DALI_TEST_CHECK( value.Get( output ) );
1851   DALI_TEST_EQUALS( output.empty(), false, TEST_LOCATION);
1852   DALI_TEST_EQUALS( output.length(), b64l(testData), TEST_LOCATION );
1853
1854   outData.clear();
1855   DecodeBase64PropertyData( value, outData );
1856   DALI_TEST_EQUALS( testData.size(), outData.size(), TEST_LOCATION );
1857   DALI_TEST_EQUALS( std::equal( testData.begin(), testData.end(), outData.begin()), true, TEST_LOCATION );
1858
1859   // n+2
1860   testData.push_back( 67890 );
1861   EncodeBase64PropertyData( value, testData );
1862
1863   DALI_TEST_CHECK( value.Get( output ) );
1864   DALI_TEST_EQUALS( output.empty(), false, TEST_LOCATION);
1865   DALI_TEST_EQUALS( output.length(), b64l(testData), TEST_LOCATION );
1866
1867   outData.clear();
1868   DecodeBase64PropertyData( value, outData );
1869   DALI_TEST_EQUALS( testData.size(), outData.size(), TEST_LOCATION );
1870   DALI_TEST_EQUALS( std::equal( testData.begin(), testData.end(), outData.begin()), true, TEST_LOCATION );
1871
1872   // n+3
1873   testData.push_back( -1 );
1874   EncodeBase64PropertyData( value, testData );
1875
1876   DALI_TEST_CHECK( value.Get( output ) );
1877   DALI_TEST_EQUALS( output.empty(), false, TEST_LOCATION);
1878   DALI_TEST_EQUALS( output.length(), b64l(testData), TEST_LOCATION );
1879
1880   outData.clear();
1881   DecodeBase64PropertyData( value, outData );
1882   DALI_TEST_EQUALS( testData.size(), outData.size(), TEST_LOCATION );
1883   DALI_TEST_EQUALS( std::equal( testData.begin(), testData.end(), outData.begin()), true, TEST_LOCATION );
1884
1885
1886   END_TEST;
1887 }
1888
1889
1890 int UtcDaliBase64EncodingP03(void)
1891 {
1892   tet_infoline( "Test encoding a vector of length 12 has output within single string" );
1893
1894   std::vector<uint32_t> testData;
1895   for(int i=0; i<12; ++i )
1896   {
1897     testData.push_back(i);
1898   }
1899   Property::Value value;
1900   EncodeBase64PropertyData( value, testData );
1901
1902   std::string output;
1903   DALI_TEST_CHECK( value.Get( output ) );
1904   DALI_TEST_EQUALS( output.empty(), false, TEST_LOCATION);
1905   DALI_TEST_EQUALS( output.length(), b64l(testData), TEST_LOCATION );
1906
1907   std::vector<uint32_t> outData;
1908   DecodeBase64PropertyData( value, outData );
1909   DALI_TEST_EQUALS( testData.size(), outData.size(), TEST_LOCATION );
1910
1911   END_TEST;
1912 }
1913
1914
1915 int UtcDaliBase64EncodingP04(void)
1916 {
1917   tet_infoline( "Test encoding a vector of length 13 has output split over 2 strings" );
1918
1919   std::vector<uint32_t> testData;
1920   for(int i=0; i<13; ++i )
1921   {
1922     testData.push_back(i);
1923   }
1924   Property::Value value;
1925   EncodeBase64PropertyData( value, testData );
1926
1927   auto array = value.GetArray();
1928   DALI_TEST_CHECK( array );
1929
1930   DALI_TEST_EQUALS( array->Count(), 2, TEST_LOCATION );
1931
1932   std::vector<uint32_t> outData;
1933   DecodeBase64PropertyData( value, outData );
1934   DALI_TEST_EQUALS( testData.size(), outData.size(), TEST_LOCATION );
1935
1936   END_TEST;
1937 }
1938
1939
1940 int UtcDaliBase64EncodingP05(void)
1941 {
1942   tet_infoline( "Test encoding a vector of length 24 has output split over 2 strings" );
1943
1944   std::vector<uint32_t> testData;
1945   for(int i=0; i<24; ++i )
1946   {
1947     testData.push_back(i);
1948   }
1949   Property::Value value;
1950   EncodeBase64PropertyData( value, testData );
1951
1952   auto array = value.GetArray();
1953   DALI_TEST_CHECK( array );
1954
1955   DALI_TEST_EQUALS( array->Count(), 2, TEST_LOCATION );
1956
1957   std::vector<uint32_t> outData;
1958   DecodeBase64PropertyData( value, outData );
1959   DALI_TEST_EQUALS( testData.size(), outData.size(), TEST_LOCATION );
1960
1961   END_TEST;
1962 }
1963
1964
1965 int UtcDaliBase64EncodingP06(void)
1966 {
1967   tet_infoline( "Test encoding a vector of arbitrary length decodes OK." );
1968
1969   std::vector<uint32_t> testData;
1970   for(int i=0; i<97; ++i )
1971   {
1972     testData.push_back(i);
1973   }
1974   Property::Value value;
1975   EncodeBase64PropertyData( value, testData );
1976
1977   auto array = value.GetArray();
1978   DALI_TEST_CHECK( array );
1979
1980   std::vector<uint32_t> outData;
1981   DecodeBase64PropertyData( value, outData );
1982   DALI_TEST_EQUALS( testData.size(), outData.size(), TEST_LOCATION );
1983
1984   END_TEST;
1985 }
1986
1987
1988 int UtcDaliBase64DecodingN01(void)
1989 {
1990   tet_infoline( "Test decoding empty string results in empty data" );
1991
1992   Property::Value value("");
1993   std::vector<uint32_t> outputData;
1994   DecodeBase64PropertyData( value, outputData);
1995   DALI_TEST_EQUALS( outputData.size(), 0, TEST_LOCATION );
1996   END_TEST;
1997 }
1998
1999
2000 int UtcDaliBase64DecodingN02(void)
2001 {
2002   tet_infoline( "Test decoding array with non-string values results in empty data" );
2003
2004   Property::Array array;
2005   array.Resize(2);
2006   array[0] = "Stuff, things";
2007   array[1] = 1;
2008   Property::Value value(array);
2009
2010   std::vector<uint32_t> outputData;
2011   DecodeBase64PropertyData( value, outputData);
2012   DALI_TEST_EQUALS( outputData.size(), 0, TEST_LOCATION );
2013   END_TEST;
2014 }
2015
2016 int UtcDaliBase64DecodingP01(void)
2017 {
2018   tet_infoline( "Test decoding string of known data gives expected result");
2019
2020   std::string testInput("//////7+/v4DAgEA");
2021   std::vector<uint32_t> expectedResults = { 0xffffffff, 0xfefefefe, 0x00010203 };
2022
2023   std::vector<uint32_t> outputData;
2024   DecodeBase64PropertyData(Property::Value(testInput), outputData);
2025
2026   DALI_TEST_EQUALS( std::equal( expectedResults.begin(), expectedResults.end(), outputData.begin() ), true,
2027                     TEST_LOCATION );
2028
2029   END_TEST;
2030 }