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