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