[dali_1.9.14] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Scripting.cpp
1 /*
2  * Copyright (c) 2019 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
20 #include <stdlib.h>
21 #include <dali/public-api/dali-core.h>
22 #include <dali/devel-api/scripting/scripting.h>
23 #include <dali-test-suite-utils.h>
24
25 using namespace Dali;
26 using namespace Dali::Scripting;
27
28 namespace
29 {
30
31 const StringEnum COLOR_MODE_VALUES[] =
32 {
33     { "USE_OWN_COLOR", USE_OWN_COLOR },
34     { "USE_PARENT_COLOR", USE_PARENT_COLOR },
35     { "USE_OWN_MULTIPLY_PARENT_COLOR", USE_OWN_MULTIPLY_PARENT_COLOR },
36     { "USE_OWN_MULTIPLY_PARENT_ALPHA", USE_OWN_MULTIPLY_PARENT_ALPHA },
37 };
38 const unsigned int COLOR_MODE_VALUES_COUNT = sizeof( COLOR_MODE_VALUES ) / sizeof( COLOR_MODE_VALUES[0] );
39
40 const StringEnum DRAW_MODE_VALUES[] =
41 {
42     { "NORMAL", DrawMode::NORMAL },
43     { "OVERLAY_2D", DrawMode::OVERLAY_2D }
44 };
45 const unsigned int DRAW_MODE_VALUES_COUNT = sizeof( DRAW_MODE_VALUES ) / sizeof( DRAW_MODE_VALUES[0] );
46
47
48 ////////////////////////////////////////////////////////////////////////////////
49 // Helpers for string to enum comparisons for Image and Image loading parameters
50 ////////////////////////////////////////////////////////////////////////////////
51
52 /**
53  * Template to check enumerations of type T, with a class of type X
54  */
55 template< typename T, typename X >
56 void TestEnumStrings(
57   Property::Map& map,                       // The map used to create instance of type X
58   const char * const keyName,               // the name of the key to iterate through
59   const StringEnum* values,                 // An array of string values
60   unsigned int num,                         // Number of items in the array
61   T ( X::*method )() const,                 // The member method of X to call to get the enum
62   X ( *creator ) ( const Property::Value& ) // The method which creates an instance of type X
63 )
64 {
65   // get the key reference so we can change its value
66   Property::Value* value = map.Find( keyName );
67   for ( unsigned int i = 0; i < num; ++i )
68   {
69     *value = values[i].string;
70     tet_printf("Checking: %s: %s\n", keyName, values[i].string );
71     X instance = creator( map );
72     DALI_TEST_EQUALS( values[i].value, (int)( instance.*method )(), TEST_LOCATION );
73   }
74 }
75
76 /// Helper method to create BufferImage using property
77 BufferImage NewBufferImage( const Property::Value& map )
78 {
79   BufferImage image = BufferImage::DownCast( NewImage( map ) );
80   return image;
81 }
82
83 //////////////////////////////////////////////////////////////////////////////
84 // Helpers for string to enum comparisons for Actor to Property::Map
85 //////////////////////////////////////////////////////////////////////////////
86
87 /**
88  * Template to check enumerations of type T
89  */
90 template< typename T >
91 void TestEnumStrings(
92   const char * const keyName,               // The name of the key to check
93   TestApplication& application,             // Reference to the application class
94   const StringEnum* values,                 // An array of string values
95   unsigned int num,                         // Number of items in the array
96   void ( Actor::*method )( T )              // The Actor member method to set the enumeration
97 )
98 {
99   for ( unsigned int i = 0; i < num; ++i )
100   {
101     tet_printf("Checking: %s: %s\n", keyName, values[i].string );
102
103     Actor actor = Actor::New();
104     (actor.*method)( ( T ) values[i].value );
105
106     Stage::GetCurrent().Add( actor );
107     application.SendNotification();
108     application.Render();
109
110     Property::Map map;
111     CreatePropertyMap( actor, map );
112
113     DALI_TEST_CHECK( 0 < map.Count() );
114     DALI_TEST_CHECK( NULL != map.Find( keyName ) );
115     DALI_TEST_EQUALS( map.Find( keyName )->Get< std::string >(), values[i].string, TEST_LOCATION );
116
117     Stage::GetCurrent().Remove( actor );
118   }
119 }
120
121 //////////////////////////////////////////////////////////////////////////////
122
123
124 } // anon namespace
125
126 int UtcDaliValueFromEnum(void)
127 {
128   enum class T {
129     None, V1 = 1, V2 = 2
130   };
131
132   Property::Value v1 = T::V1;
133   Property::Value v2 = T::V2;
134
135   T t = T::None;
136   DALI_TEST_CHECK( v1.Get<T>() == T::V1 );
137   DALI_TEST_CHECK( v2.Get<T>() == T::V2 );
138   DALI_TEST_CHECK( v1.Get(t) && t == T::V1 );
139   DALI_TEST_CHECK( v2.Get(t) && t == T::V2 );
140
141   END_TEST;
142 }
143
144 int UtcDaliScriptingNewImageNegative01(void)
145 {
146   // Invalid filename
147   Property::Map map;
148   map[ "filename" ] = Vector3::ZERO;
149   // will give us an empty image handle
150   Image image = NewImage( map );
151   DALI_TEST_CHECK( !image );
152   END_TEST;
153 }
154
155 int UtcDaliScriptingNewImageNegative06(void)
156 {
157   TestApplication application; // Image needs application
158   // Invalid width and height
159   Property::Map map;
160   map[ "filename" ] = "TEST_FILE";
161   map[ "width" ] = "Invalid";
162   map[ "height" ] = 100;
163   // will give us a valid image
164   PrepareResourceImage( application, 0u, 100u, Pixel::RGBA8888 );
165   Image image = NewImage( map );
166   DALI_TEST_CHECK( image );
167   ResourceImage resImage = ResourceImage::DownCast( image );
168   DALI_TEST_CHECK( resImage );
169   DALI_TEST_EQUALS( resImage.GetWidth(), 0u, TEST_LOCATION );
170   DALI_TEST_EQUALS( resImage.GetHeight(), 100u, TEST_LOCATION );
171   END_TEST;
172 }
173
174 int UtcDaliScriptingNewImageNegative07(void)
175 {
176   TestApplication application; // Image needs application
177   // Invalid height
178   Property::Map map;
179   map[ "filename" ] = "TEST_FILE";
180   map[ "width" ] = 10;
181   map[ "height" ] = "Invalid";
182   // will give us a valid image
183   PrepareResourceImage( application, 10u, 0u, Pixel::RGBA8888 );
184   Image image = NewImage( map );
185   DALI_TEST_CHECK( image );
186   ResourceImage resImage = ResourceImage::DownCast( image );
187   DALI_TEST_CHECK( resImage );
188   DALI_TEST_EQUALS( resImage.GetWidth(), 10u, TEST_LOCATION );
189   DALI_TEST_EQUALS( resImage.GetHeight(), 0u, TEST_LOCATION );
190   END_TEST;
191 }
192
193 int UtcDaliScriptingNewImageNegative08(void)
194 {
195   TestApplication application; // Image needs application
196   // Invalid fitting-mode
197   Property::Map map;
198   map[ "filename" ] = "TEST_FILE";
199   map[ "fittingMode" ] = Vector3::ZERO;
200   // will give us a valid image
201   Image image = NewImage( map );
202   DALI_TEST_CHECK( image );
203   ResourceImage resImage = ResourceImage::DownCast( image );
204   DALI_TEST_CHECK( resImage );
205   END_TEST;
206 }
207
208 int UtcDaliScriptingNewImageNegative09(void)
209 {
210   TestApplication application; // Image needs application
211   // Invalid value
212   Property::Map map;
213   map[ "filename" ] = "TEST_FILE";
214   map[ "fittingMode" ] = "INVALID";
215   // will give us a valid image
216   Image image = NewImage( map );
217   DALI_TEST_CHECK( image );
218   ResourceImage resImage = ResourceImage::DownCast( image );
219   DALI_TEST_CHECK( resImage );
220   END_TEST;
221 }
222
223 int UtcDaliScriptingNewImageNegative10(void)
224 {
225   TestApplication application; // Image needs application
226   // Invalid scaling-mode
227   Property::Map map;
228   map[ "filename" ] = "TEST_FILE";
229   map[ "samplingMode" ] = Vector3::ZERO;
230   // will give us a valid image
231   Image image = NewImage( map );
232   DALI_TEST_CHECK( image );
233   ResourceImage resImage = ResourceImage::DownCast( image );
234   DALI_TEST_CHECK( resImage );
235   END_TEST;
236 }
237
238 int UtcDaliScriptingNewImageNegative12(void)
239 {
240   TestApplication application; // Image needs application
241   // Invalid orientation-correction
242   Property::Map map;
243   map[ "filename" ] = "TEST_FILE";
244   map[ "orientation" ] = Vector3::ZERO;
245   // will give us a valid image
246   Image image = NewImage( map );
247   DALI_TEST_CHECK( image );
248   ResourceImage resImage = ResourceImage::DownCast( image );
249   DALI_TEST_CHECK( resImage );
250   END_TEST;
251 }
252
253 int UtcDaliScriptingNewImageNegative13(void)
254 {
255   TestApplication application; // Image needs application
256   // Invalid type
257   Property::Map map;
258   map[ "filename" ] = "TEST_FILE";
259   map[ "type" ] = Vector3::ZERO;
260   // will give us a valid image
261   Image image = NewImage( map );
262   DALI_TEST_CHECK( image );
263   ResourceImage resImage = ResourceImage::DownCast( image );
264   DALI_TEST_CHECK( resImage );
265   END_TEST;
266 }
267
268 int UtcDaliScriptingNewImageNegative14(void)
269 {
270   // Invalid value
271   Property::Map map;
272   map[ "type" ] = "INVALID";
273   Image image = NewImage( map );
274   DALI_TEST_CHECK( !image );
275   END_TEST;
276 }
277
278 int UtcDaliScriptingNewImageNegative15(void)
279 {
280   // Invalid pixel-format
281   Property::Map map;
282   map[ "pixelFormat" ] = Vector3::ZERO;
283   Image image = NewImage( map );
284   DALI_TEST_CHECK( !image );
285   END_TEST;
286 }
287
288 int UtcDaliScriptingNewImageNegative16(void)
289 {
290   // Invalid value
291   Property::Map map;
292   map[ "pixelFormat" ] = "INVALID";
293   Image image = NewImage( map );
294   DALI_TEST_CHECK( !image );
295   END_TEST;
296 }
297
298 int UtcDaliScriptingNewImage01P(void)
299 {
300   TestApplication application; // Image needs application
301
302   Property::Map map;
303   map[ "filename" ] = "TEST_FILE";
304
305   // Filename only
306   ResourceImage image = ResourceImage::DownCast( NewImage( map ) );
307   DALI_TEST_EQUALS( "TEST_FILE", image.GetUrl(), TEST_LOCATION );
308   END_TEST;
309 }
310
311 int UtcDaliScriptingNewImage04P(void)
312 {
313   TestApplication application;
314
315   Property::Map map;
316   map[ "filename" ] = "TEST_FILE";
317
318   // float width and height
319   map[ "width" ] = (float) 10.0f;
320   map[ "height" ] = (float) 20.0f;
321   PrepareResourceImage( application, 10u, 20u, Pixel::RGBA8888 );
322   Image image = NewImage( map );
323   DALI_TEST_EQUALS( image.GetWidth(), 10u, TEST_LOCATION );
324   DALI_TEST_EQUALS( image.GetHeight(), 20u, TEST_LOCATION );
325   END_TEST;
326 }
327
328 int UtcDaliScriptingNewImage05P(void)
329 {
330   TestApplication application;
331
332   Property::Map map;
333   map[ "filename" ] = "TEST_FILE";
334
335   // width and height
336   map[ "width"] = 50;
337   map[ "height" ] = 70;
338   PrepareResourceImage( application, 50u, 70u, Pixel::RGBA8888 );
339   Image image = NewImage( map );
340   DALI_TEST_EQUALS( image.GetWidth(), 50u, TEST_LOCATION );
341   DALI_TEST_EQUALS( image.GetHeight(), 70u, TEST_LOCATION );
342   END_TEST;
343 }
344
345 int UtcDaliScriptingNewImage06P(void)
346 {
347   TestApplication application;
348
349   Property::Map map;
350   // type FrameBufferImage
351   map[ "type" ] = "FrameBufferImage";
352   // width and height
353   map[ "width"] = 50;
354   map[ "height" ] = 70;
355   Image image = NewImage( map );
356   DALI_TEST_CHECK( image );
357   DALI_TEST_CHECK( FrameBufferImage::DownCast( image ) );
358   END_TEST;
359 }
360
361 int UtcDaliScriptingNewImage07P(void)
362 {
363   TestApplication application;
364
365   Property::Map map;
366   // type BufferImage
367   map[ "type" ] = "BufferImage";
368   // width and height
369   map[ "width"] = 50;
370   map[ "height" ] = 70;
371   Image image = NewImage( map );
372   DALI_TEST_CHECK( image );
373   DALI_TEST_CHECK( BufferImage::DownCast( image ) );
374   DALI_TEST_EQUALS( (BufferImage::DownCast( image )).GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION );
375   END_TEST;
376 }
377
378 int UtcDaliScriptingNewImage08P(void)
379 {
380   TestApplication application;
381
382   Property::Map map;
383   map[ "type" ] = "BufferImage";
384   // width and height
385   map[ "width"] = 66;
386   map[ "height" ] = 99;
387   // pixel-format
388   map[ "pixelFormat" ] = "";
389   const StringEnum values[] =
390   {
391     { "A8", Pixel::A8 },
392     { "L8", Pixel::L8 },
393     { "LA88", Pixel::LA88 },
394     { "RGB565", Pixel::RGB565 },
395     { "BGR565", Pixel::BGR565 },
396     { "RGBA4444", Pixel::RGBA4444 },
397     { "BGRA4444", Pixel::BGRA4444 },
398     { "RGBA5551", Pixel::RGBA5551 },
399     { "BGRA5551", Pixel::BGRA5551 },
400     { "RGB888", Pixel::RGB888 },
401     { "RGB8888", Pixel::RGB8888 },
402     { "BGR8888", Pixel::BGR8888 },
403     { "RGBA8888", Pixel::RGBA8888 },
404     { "BGRA8888", Pixel::BGRA8888 },
405     // BufferImage does not support compressed formats
406   };
407   TestEnumStrings< Pixel::Format, BufferImage >( map, "pixelFormat",  values, ( sizeof( values ) / sizeof ( values[0] ) ), &BufferImage::GetPixelFormat, &NewBufferImage );
408
409   END_TEST;
410 }
411
412 int UtcDaliScriptingNewImage09P(void)
413 {
414   TestApplication application;
415
416   Property::Map map;
417   // type Image
418   map[ "type" ] = "ResourceImage";
419   map[ "filename" ] = "TEST_FILE";
420
421   {
422     Image image = NewImage( map );
423     DALI_TEST_CHECK( ResourceImage::DownCast( image ) );
424     DALI_TEST_CHECK( !FrameBufferImage::DownCast( image ) );
425     DALI_TEST_CHECK( !BufferImage::DownCast( image ) );
426   }
427   END_TEST;
428 }
429
430 int UtcDaliScriptingNewImage10P(void)
431 {
432   TestApplication application;
433
434   Property::Map map;
435   // type FrameBufferImage, empty size gives us stage size
436   map[ "type" ] = "FrameBufferImage";
437   Image image = NewImage( map );
438   DALI_TEST_CHECK( image );
439   END_TEST;
440 }
441
442 int UtcDaliScriptingNewActorNegative(void)
443 {
444   TestApplication application;
445
446   // Empty map
447   {
448     Actor handle = NewActor( Property::Map() );
449     DALI_TEST_CHECK( !handle );
450   }
451
452   // Map with only properties
453   {
454     Property::Map map;
455     map[ "parentOrigin" ] = ParentOrigin::TOP_CENTER;
456     map[ "anchorPoint" ] = AnchorPoint::TOP_CENTER;
457     Actor handle = NewActor( map );
458     DALI_TEST_CHECK( !handle );
459   }
460
461   // Add some signals to the map, we should have no signal connections as its not yet supported
462   {
463     Property::Map map;
464     map[ "type" ] = "Actor";
465     map[ "signals" ] = Property::MAP;
466     Actor handle = NewActor( map );
467     DALI_TEST_CHECK( handle );
468     DALI_TEST_CHECK( !handle.WheelEventSignal().GetConnectionCount() );
469     DALI_TEST_CHECK( !handle.OffStageSignal().GetConnectionCount() );
470     DALI_TEST_CHECK( !handle.OnStageSignal().GetConnectionCount() );
471     DALI_TEST_CHECK( !handle.TouchedSignal().GetConnectionCount() );
472   }
473   END_TEST;
474 }
475
476 int UtcDaliScriptingNewActorProperties(void)
477 {
478   TestApplication application;
479
480   Property::Map map;
481   map[ "type" ] = "Actor";
482   map[ "size" ] = Vector3::ONE;
483   map[ "position" ] = Vector3::XAXIS;
484   map[ "scale" ] = Vector3::ONE;
485   map[ "visible" ] = false;
486   map[ "color" ] = Color::MAGENTA;
487   map[ "name" ] = "MyActor";
488   map[ "colorMode" ] = "USE_PARENT_COLOR";
489   map[ "sensitive" ] = false;
490   map[ "leaveRequired" ] = true;
491   map[ "drawMode" ] = "OVERLAY_2D";
492   map[ "inheritOrientation" ] = false;
493   map[ "inheritScale" ] = false;
494
495   // Default properties
496   {
497     Actor handle = NewActor( map );
498     DALI_TEST_CHECK( handle );
499
500     Stage::GetCurrent().Add( handle );
501     application.SendNotification();
502     application.Render();
503
504     DALI_TEST_EQUALS( handle.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ), Vector3::ONE, TEST_LOCATION );
505     DALI_TEST_EQUALS( handle.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::XAXIS, TEST_LOCATION );
506     DALI_TEST_EQUALS( handle.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ), Vector3::ONE, TEST_LOCATION );
507     DALI_TEST_EQUALS( handle.GetCurrentProperty< bool >( Actor::Property::VISIBLE ), false, TEST_LOCATION );
508     DALI_TEST_EQUALS( handle.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::MAGENTA, TEST_LOCATION );
509     DALI_TEST_EQUALS( handle.GetProperty< std::string >( Actor::Property::NAME ), "MyActor", TEST_LOCATION );
510     DALI_TEST_EQUALS( handle.GetProperty< ColorMode >( Actor::Property::COLOR_MODE ), USE_PARENT_COLOR, TEST_LOCATION );
511     DALI_TEST_EQUALS( handle.GetProperty< bool >( Actor::Property::SENSITIVE ), false, TEST_LOCATION );
512     DALI_TEST_EQUALS( handle.GetProperty< bool >( Actor::Property::LEAVE_REQUIRED ), true, TEST_LOCATION );
513     DALI_TEST_EQUALS( handle.GetProperty< DrawMode::Type >( Actor::Property::DRAW_MODE ), DrawMode::OVERLAY_2D, TEST_LOCATION );
514     DALI_TEST_EQUALS( handle.GetProperty< bool >( Actor::Property::INHERIT_ORIENTATION ), false, TEST_LOCATION );
515     DALI_TEST_EQUALS( handle.GetProperty< bool >( Actor::Property::INHERIT_SCALE ), false, TEST_LOCATION );
516
517     Stage::GetCurrent().Remove( handle );
518   }
519
520   // Check Anchor point and parent origin vector3s
521   map[ "parentOrigin" ] = ParentOrigin::TOP_CENTER;
522   map[ "anchorPoint" ] = AnchorPoint::TOP_LEFT;
523   {
524     Actor handle = NewActor( map );
525     DALI_TEST_CHECK( handle );
526
527     Stage::GetCurrent().Add( handle );
528     application.SendNotification();
529     application.Render();
530
531     DALI_TEST_EQUALS( handle.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::TOP_CENTER, TEST_LOCATION );
532     DALI_TEST_EQUALS( handle.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), AnchorPoint::TOP_LEFT, TEST_LOCATION );
533
534     Stage::GetCurrent().Remove( handle );
535   }
536
537   // Check Anchor point and parent origin STRINGS
538   map[ "parentOrigin" ] = "TOP_LEFT";
539   map[ "anchorPoint" ] = "CENTER_LEFT";
540   {
541     Actor handle = NewActor( map );
542     DALI_TEST_CHECK( handle );
543
544     Stage::GetCurrent().Add( handle );
545     application.SendNotification();
546     application.Render();
547
548     DALI_TEST_EQUALS( handle.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ), ParentOrigin::TOP_LEFT, TEST_LOCATION );
549     DALI_TEST_EQUALS( handle.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ), AnchorPoint::CENTER_LEFT, TEST_LOCATION );
550
551     Stage::GetCurrent().Remove( handle );
552   }
553   END_TEST;
554 }
555
556 int UtcDaliScriptingNewAnimation(void)
557 {
558   TestApplication application;
559
560   Property::Map map;
561   map["actor"] = "Actor1";
562   map["property"] = "color";
563   map["value"] = Color::MAGENTA;
564   map["alphaFunction"] = "EASE_IN_OUT";
565
566   Property::Map timePeriod;
567   timePeriod["delay"] = 0.5f;
568   timePeriod["duration"] = 1.0f;
569   map["timePeriod"] = timePeriod;
570
571   Dali::AnimationData data;
572   Scripting::NewAnimation( map, data );
573
574   Actor actor = Actor::New();
575   actor.SetProperty( Actor::Property::NAME,"Actor1");
576   actor.SetProperty( Actor::Property::COLOR,Color::CYAN);
577   Stage::GetCurrent().Add(actor);
578
579   Animation anim = data.CreateAnimation( actor, 0.5f );
580   anim.Play();
581
582   application.SendNotification();
583   application.Render(0);
584   application.Render(500); // Start animation
585   application.Render(500); // Halfway thru anim
586   application.SendNotification();
587   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), (Color::MAGENTA+Color::CYAN)*0.5f, TEST_LOCATION);
588
589   application.Render(500); // Halfway thru anim
590   application.SendNotification();
591   DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::MAGENTA, TEST_LOCATION );
592
593   END_TEST;
594 }
595
596 int UtcDaliScriptingNewActorChildren(void)
597 {
598   TestApplication application;
599
600   Property::Map map;
601   map[ "type" ] = "Actor";
602   map[ "position" ] = Vector3::XAXIS;
603
604   Property::Map child1Map;
605   child1Map[ "type" ] = "Layer";
606   child1Map[ "position" ] = Vector3::YAXIS;
607
608   Property::Array childArray;
609   childArray.PushBack( child1Map );
610   map[ "actors" ] = childArray;
611
612   // Create
613   Actor handle = NewActor( map );
614   DALI_TEST_CHECK( handle );
615
616   Stage::GetCurrent().Add( handle );
617   application.SendNotification();
618   application.Render();
619
620   DALI_TEST_EQUALS( handle.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::XAXIS, TEST_LOCATION );
621   DALI_TEST_EQUALS( handle.GetChildCount(), 1u, TEST_LOCATION );
622
623   Actor child1 = handle.GetChildAt(0);
624   DALI_TEST_CHECK( child1 );
625   DALI_TEST_CHECK( Layer::DownCast( child1 ) );
626   DALI_TEST_EQUALS( child1.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), Vector3::YAXIS, TEST_LOCATION );
627   DALI_TEST_EQUALS( child1.GetChildCount(), 0u, TEST_LOCATION );
628
629   Stage::GetCurrent().Remove( handle );
630   END_TEST;
631 }
632
633
634 int UtcDaliScriptingCreatePropertyMapActor(void)
635 {
636   TestApplication application;
637
638   // Actor Type
639   {
640     Actor actor = Actor::New();
641
642     Property::Map map;
643     CreatePropertyMap( actor, map );
644     DALI_TEST_CHECK( !map.Empty() );
645     DALI_TEST_CHECK( NULL != map.Find( "type" ) );
646     DALI_TEST_EQUALS( map.Find( "type")->Get< std::string >(), "Actor", TEST_LOCATION );
647
648     Stage::GetCurrent().Remove( actor );
649   }
650
651   // Layer Type
652   {
653     Actor actor = Layer::New();
654
655     Property::Map map;
656     CreatePropertyMap( actor, map );
657     DALI_TEST_CHECK( !map.Empty() );
658     DALI_TEST_CHECK( NULL != map.Find( "type" ) );
659     DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "Layer", TEST_LOCATION );
660
661     Stage::GetCurrent().Remove( actor );
662   }
663
664   // Default properties
665   {
666     Actor actor = Actor::New();
667     actor.SetSize( Vector3::ONE );
668     actor.SetPosition( Vector3::XAXIS );
669     actor.SetScale( Vector3::ZAXIS );
670     actor.SetProperty( Actor::Property::VISIBLE, false );
671     actor.SetProperty( Actor::Property::COLOR, Color::MAGENTA );
672     actor.SetProperty( Actor::Property::NAME, "MyActor" );
673     actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
674     actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT );
675     actor.SetProperty( Actor::Property::SENSITIVE, false );
676     actor.SetProperty( Actor::Property::LEAVE_REQUIRED, true );
677     actor.SetProperty( Actor::Property::INHERIT_ORIENTATION, false );
678     actor.SetProperty( Actor::Property::INHERIT_SCALE, false );
679     actor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, Vector3::ONE );
680
681     Stage::GetCurrent().Add( actor );
682     application.SendNotification();
683     application.Render();
684
685     Property::Map map;
686     CreatePropertyMap( actor, map );
687
688     DALI_TEST_CHECK( !map.Empty() );
689     DALI_TEST_CHECK( NULL != map.Find( "size" ) );
690     DALI_TEST_EQUALS( map.Find( "size" )->Get< Vector3 >(), Vector3::ONE, TEST_LOCATION );
691     DALI_TEST_CHECK( NULL != map.Find( "position" ) );
692     DALI_TEST_EQUALS( map.Find( "position" )->Get< Vector3 >(), Vector3::XAXIS, TEST_LOCATION );
693     DALI_TEST_CHECK( NULL != map.Find( "scale" ) );
694     DALI_TEST_EQUALS( map.Find( "scale" )->Get< Vector3 >(), Vector3::ZAXIS, TEST_LOCATION );
695     DALI_TEST_CHECK( NULL != map.Find( "visible" ) );
696     DALI_TEST_EQUALS( map.Find( "visible" )->Get< bool >(), false, TEST_LOCATION );
697     DALI_TEST_CHECK( NULL != map.Find( "color" ) );
698     DALI_TEST_EQUALS( map.Find( "color" )->Get< Vector4 >(), Color::MAGENTA, TEST_LOCATION );
699     DALI_TEST_CHECK( NULL != map.Find( "name" ) );
700     DALI_TEST_EQUALS( map.Find( "name")->Get< std::string >(), "MyActor", TEST_LOCATION );
701     DALI_TEST_CHECK( NULL != map.Find( "anchorPoint" ) );
702     DALI_TEST_EQUALS( map.Find( "anchorPoint" )->Get< Vector3 >(), AnchorPoint::CENTER_LEFT, TEST_LOCATION );
703     DALI_TEST_CHECK( NULL != map.Find( "parentOrigin" ) );
704     DALI_TEST_EQUALS( map.Find( "parentOrigin" )->Get< Vector3 >(), ParentOrigin::TOP_RIGHT, TEST_LOCATION );
705     DALI_TEST_CHECK( NULL != map.Find( "sensitive" ) );
706     DALI_TEST_EQUALS( map.Find( "sensitive" )->Get< bool >(), false, TEST_LOCATION );
707     DALI_TEST_CHECK( NULL != map.Find( "leaveRequired" ) );
708     DALI_TEST_EQUALS( map.Find( "leaveRequired" )->Get< bool >(), true, TEST_LOCATION );
709     DALI_TEST_CHECK( NULL != map.Find( "inheritOrientation" ) );
710     DALI_TEST_EQUALS( map.Find( "inheritOrientation" )->Get< bool >(), false, TEST_LOCATION );
711     DALI_TEST_CHECK( NULL != map.Find( "inheritScale" ) );
712     DALI_TEST_EQUALS( map.Find( "inheritScale" )->Get< bool >(), false, TEST_LOCATION );
713     DALI_TEST_CHECK( NULL != map.Find( "sizeModeFactor" ) );
714     DALI_TEST_EQUALS( map.Find( "sizeModeFactor" )->Get< Vector3 >(), Vector3::ONE, TEST_LOCATION );
715
716     Stage::GetCurrent().Remove( actor );
717   }
718
719   // Children
720   {
721     Actor actor = Actor::New();
722     Actor child = Layer::New();
723     actor.Add( child );
724
725     Stage::GetCurrent().Add( actor );
726     application.SendNotification();
727     application.Render();
728
729     Property::Map map;
730     CreatePropertyMap( actor, map );
731     DALI_TEST_CHECK( !map.Empty() );
732
733     DALI_TEST_CHECK( NULL != map.Find( "type" ) );
734     DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "Actor", TEST_LOCATION );
735
736     DALI_TEST_CHECK( NULL != map.Find( "actors" ) );
737     Property::Array children( map.Find( "actors")->Get< Property::Array >() );
738     DALI_TEST_CHECK( !children.Empty() );
739     Property::Map childMap( children[0].Get< Property::Map >() );
740     DALI_TEST_CHECK( !childMap.Empty() );
741     DALI_TEST_CHECK( childMap.Find( "type" ) );
742     DALI_TEST_EQUALS( childMap.Find( "type" )->Get< std::string >(), "Layer", TEST_LOCATION );
743
744     Stage::GetCurrent().Remove( actor );
745   }
746   END_TEST;
747 }
748
749 int UtcDaliScriptingCreatePropertyMapImage(void)
750 {
751   TestApplication application;
752
753   // Empty
754   {
755     Image image;
756     Property::Map map;
757     CreatePropertyMap( image, map );
758     DALI_TEST_CHECK( map.Empty() );
759   }
760
761   // Default
762   {
763     Image image = ResourceImage::New( "MY_PATH" );
764
765     Property::Map map;
766     CreatePropertyMap( image, map );
767     DALI_TEST_CHECK( !map.Empty() );
768
769     DALI_TEST_CHECK( NULL != map.Find( "type" ) );
770     DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "ResourceImage", TEST_LOCATION );
771     DALI_TEST_CHECK( NULL != map.Find( "filename" ) );
772     DALI_TEST_EQUALS( map.Find( "filename" )->Get< std::string >(), "MY_PATH", TEST_LOCATION );
773     DALI_TEST_CHECK( NULL == map.Find( "width" ) );
774     DALI_TEST_CHECK( NULL == map.Find( "height" ) );
775   }
776
777   // Change values
778   {
779     PrepareResourceImage( application, 300, 400, Pixel::RGBA8888 );
780     ResourceImage image = ResourceImage::New( "MY_PATH", ImageDimensions( 300, 400 ), FittingMode::FIT_WIDTH );
781
782     Property::Map map;
783     CreatePropertyMap( image, map );
784     DALI_TEST_CHECK( !map.Empty() );
785
786     DALI_TEST_CHECK( NULL != map.Find( "type" ) );
787     DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "ResourceImage", TEST_LOCATION );
788     DALI_TEST_CHECK( NULL != map.Find( "filename" ) );
789     DALI_TEST_EQUALS( map.Find( "filename" )->Get< std::string >(), "MY_PATH", TEST_LOCATION );
790     DALI_TEST_CHECK( NULL != map.Find( "width" ) );
791     DALI_TEST_EQUALS( map.Find( "width" )->Get< int >(), 300, TEST_LOCATION );
792     DALI_TEST_CHECK( NULL != map.Find( "height" ) );
793     DALI_TEST_EQUALS( map.Find( "height" )->Get< int >(), 400, TEST_LOCATION );
794   }
795
796   // BufferImage
797   {
798     Image image = BufferImage::New( 200, 300, Pixel::A8 );
799     Property::Map map;
800     CreatePropertyMap( image, map );
801     DALI_TEST_CHECK( NULL != map.Find( "type" ) );
802     DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "BufferImage", TEST_LOCATION );
803     DALI_TEST_CHECK( NULL != map.Find( "pixelFormat") );
804     DALI_TEST_EQUALS( map.Find( "pixelFormat" )->Get< std::string >(), "A8", TEST_LOCATION );
805   }
806
807   // FrameBufferImage
808   {
809     Image image = FrameBufferImage::New( 200, 300, Pixel::RGBA8888 );
810     Property::Map map;
811     CreatePropertyMap( image, map );
812     DALI_TEST_CHECK( NULL != map.Find( "type" ) );
813     DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "FrameBufferImage", TEST_LOCATION );
814   }
815   END_TEST;
816 }
817
818 int UtcDaliScriptingGetEnumerationTemplates(void)
819 {
820   const Scripting::StringEnum myTable[] =
821   {
822     { "ONE",    1 },
823     { "TWO",    2 },
824     { "THREE",  3 },
825     { "FOUR",   4 },
826     { "FIVE",   5 },
827   };
828   const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
829
830   for ( unsigned int i = 0; i < myTableCount; ++i )
831   {
832     tet_printf("Checking: %s\n", myTable[ i ].string );
833     int value;
834     DALI_TEST_CHECK( GetEnumeration<int>( myTable[ i ].string, myTable, myTableCount, value ) );
835     DALI_TEST_EQUALS( myTable[ i ].value, value, TEST_LOCATION );
836   }
837
838   for ( unsigned int i = 0; i < myTableCount; ++i )
839   {
840     tet_printf("Checking: %d\n", myTable[ i ].value );
841     DALI_TEST_EQUALS( myTable[ i ].string, GetEnumerationName( myTable[ i ].value, myTable, myTableCount ), TEST_LOCATION );
842   }
843
844   END_TEST;
845 }
846
847 int UtcDaliScriptingGetEnumerationNameN(void)
848 {
849   const char* value = GetEnumerationName( 10, NULL, 0 );
850   DALI_TEST_CHECK( NULL == value );
851
852   value = GetEnumerationName( 10, NULL, 1 );
853   DALI_TEST_CHECK( NULL == value );
854
855   END_TEST;
856 }
857
858 int UtcDaliScriptingGetLinearEnumerationNameN(void)
859 {
860   const char* value = GetLinearEnumerationName( 10, NULL, 0 );
861   DALI_TEST_CHECK( NULL == value );
862
863   value = GetLinearEnumerationName( 10, NULL, 1 );
864   DALI_TEST_CHECK( NULL == value );
865
866   END_TEST;
867 }
868
869 int UtcDaliScriptingGetEnumerationProperty(void)
870 {
871   /*
872    * This test function performs the following checks:
873    *  - An enum can be looked up from a Property::Value of type INTEGER.
874    *  - An enum can be looked up from a Property::Value of type STRING.
875    *  - An enum can NOT be looked up for other Property::Value types.
876    *  - The return value is "true" if the property can be successfully converted AND it has changed.
877    *  - The return value is "false" if the property can be successfully converted BUT it has NOT changed.
878    *  - The return value is "false" if the property can not be successfully converted.
879    *  - The result value is only updated if the return value is "true" (IE. successful conversion and property value has changed).
880    */
881
882   // String to Enum property table to test with (equivalent to ones used within DALi).
883   const Dali::Scripting::StringEnum  testTable[] = {
884       { "NONE",           FaceCullingMode::NONE },
885       { "FRONT",          FaceCullingMode::FRONT },
886       { "BACK",           FaceCullingMode::BACK },
887       { "FRONT_AND_BACK", FaceCullingMode::FRONT_AND_BACK }
888   }; const unsigned int testTableCount = sizeof( testTable ) / sizeof( testTable[0] );
889
890   // TEST: An enum can be looked up from a Property::Value of type INTEGER.
891   // Initialise to first element.
892   FaceCullingMode::Type result = FaceCullingMode::NONE;
893   // Set the input property value to a different value (to emulate a change).
894   Property::Value propertyValueInteger( FaceCullingMode::FRONT );
895
896   // Perform the lookup.
897   bool returnValue = GetEnumerationProperty< FaceCullingMode::Type >( propertyValueInteger, testTable, testTableCount, result );
898
899   // TEST: The return value is "true" if the property can be successfully converted AND it has changed
900   // Check the property could be converted.
901   DALI_TEST_CHECK( returnValue );
902
903   DALI_TEST_EQUALS( static_cast<int>( result ), static_cast<int>( FaceCullingMode::FRONT ), TEST_LOCATION );
904
905   // Now emulate a property-set with the same value. false should be returned.
906   returnValue = GetEnumerationProperty< FaceCullingMode::Type >( propertyValueInteger, testTable, testTableCount, result );
907
908   // TEST: The return value is "false" if the property can be successfully converted BUT it has NOT changed.
909   DALI_TEST_CHECK( !returnValue );
910
911   // The result should remain the same.
912   DALI_TEST_EQUALS( static_cast<int>( result ), static_cast<int>( FaceCullingMode::FRONT ), TEST_LOCATION );
913
914   // TEST: An enum can be looked up from a Property::Value of type STRING.
915   // Set the input property value to a different value (to emulate a change).
916   Property::Value propertyValueString( "BACK" );
917
918   returnValue = GetEnumerationProperty< FaceCullingMode::Type >( propertyValueString, testTable, testTableCount, result );
919
920   DALI_TEST_CHECK( returnValue );
921
922   // The result should remain the same.
923   DALI_TEST_EQUALS( static_cast<int>( result ), static_cast<int>( FaceCullingMode::BACK ), TEST_LOCATION );
924
925   returnValue = GetEnumerationProperty< FaceCullingMode::Type >( propertyValueString, testTable, testTableCount, result );
926
927   DALI_TEST_CHECK( !returnValue );
928
929   // The result should remain the same.
930   DALI_TEST_EQUALS( static_cast<int>( result ), static_cast<int>( FaceCullingMode::BACK ), TEST_LOCATION );
931
932   // TEST: An enum can NOT be looked up for other Property::Value types.
933   Property::Value propertyValueBoolean( true );
934
935   returnValue = GetEnumerationProperty< FaceCullingMode::Type >( propertyValueBoolean, testTable, testTableCount, result );
936
937   // TEST: The return value is "false" if the property can not be successfully converted.
938   // Return value should be false as Property::Value was of an unsupported type for enum properties.
939   DALI_TEST_CHECK( !returnValue );
940
941   // TEST: The result value is only updated if the return value is "true" (IE. successful conversion and property value has changed).
942   // The result should remain the same.
943   DALI_TEST_EQUALS( static_cast<int>( result ), static_cast<int>( FaceCullingMode::BACK ), TEST_LOCATION );
944
945   END_TEST;
946 }
947
948 int UtcDaliScriptingGetBitmaskEnumerationProperty(void)
949 {
950   /*
951    * This test function performs the following checks:
952    *  - An enum can be looked up from a Property::Value of type INTEGER.
953    *  - An enum can be looked up from a Property::Value of type STRING.
954    *  - An enum can NOT be looked up from other Property::Value types.
955    *  - The return value is "true" if the property can be successfully converted AND it has changed.
956    *  - The return value is "false" if the property can not be successfully converted.
957    *  - The result value is only updated if the return value is "true" (IE. successful conversion and property value has changed).
958    *  PropertyArrays:
959    *  - The return value when checking an array with 2 INTEGERS is "true" if the properties can be successfully converted.
960    *  - The result value when checking an array with 2 INTEGERS is the ORd value of the 2 integers.
961    *  - The return value when checking an array with 2 STRINGS is "true" if the properties can be successfully converted.
962    *  - The result value when checking an array with 2 STRINGS is the ORd value of the 2 integer equivalents of the strings.
963    *  - The return value when checking an array with an INTEGER and a STRING is "true" if the properties can be successfully converted.
964    *  - The result value when checking an array with an INTEGER and a STRING is the ORd value of the 2 integer equivalents of the strings.
965    *  - The return value when checking an array with an INTEGER and a Vector3 is "false" as the properties can not be successfully converted.
966    *  - The result value when checking an array with an INTEGER and a Vector3 is unchanged.
967    */
968
969   // String to Enum property table to test with (equivalent to ones used within DALi).
970   const Dali::Scripting::StringEnum  testTable[] = {
971       { "NONE",           FaceCullingMode::NONE },
972       { "FRONT",          FaceCullingMode::FRONT },
973       { "BACK",           FaceCullingMode::BACK },
974       { "FRONT_AND_BACK", FaceCullingMode::FRONT_AND_BACK }
975   }; const unsigned int testTableCount = sizeof( testTable ) / sizeof( testTable[0] );
976
977   // TEST: An enum can be looked up from a Property::Value of type INTEGER.
978   // Initialise to first element.
979   FaceCullingMode::Type result = FaceCullingMode::NONE;
980   // Set the input property value to a different value (to emulate a change).
981   Property::Value propertyValueInteger( FaceCullingMode::FRONT );
982
983   // Perform the lookup.
984   bool returnValue = GetBitmaskEnumerationProperty< FaceCullingMode::Type >( propertyValueInteger, testTable, testTableCount, result );
985
986   // TEST: The return value is "true" if the property can be successfully converted AND it has changed
987   // Check the property could be converted.
988   DALI_TEST_CHECK( returnValue );
989
990   DALI_TEST_EQUALS( static_cast<int>( result ), static_cast<int>( FaceCullingMode::FRONT ), TEST_LOCATION );
991
992   // TEST: An enum can be looked up from a Property::Value of type STRING.
993   // Set the input property value to a different value (to emulate a change).
994   Property::Value propertyValueString( "BACK" );
995
996   returnValue = GetBitmaskEnumerationProperty< FaceCullingMode::Type >( propertyValueString, testTable, testTableCount, result );
997
998   DALI_TEST_CHECK( returnValue );
999
1000   DALI_TEST_EQUALS( static_cast<int>( result ), static_cast<int>( FaceCullingMode::BACK ), TEST_LOCATION );
1001
1002   // TEST: An enum can NOT be looked up from other Property::Value types.
1003   Property::Value propertyValueVector( Vector3::ZERO );
1004
1005   returnValue = GetBitmaskEnumerationProperty< FaceCullingMode::Type >( propertyValueVector, testTable, testTableCount, result );
1006
1007   // TEST: The return value is "false" if the property can not be successfully converted.
1008   // Return value should be false as Property::Value was of an unsupported type for enum properties.
1009   DALI_TEST_CHECK( !returnValue );
1010
1011   // TEST: The result value is only updated if the return value is "true" (IE. successful conversion and property value has changed).
1012   // The result should remain the same.
1013   DALI_TEST_EQUALS( static_cast<int>( result ), static_cast<int>( FaceCullingMode::BACK ), TEST_LOCATION );
1014
1015   // Test PropertyArrays:
1016
1017   // Property array of 2 integers.
1018   Property::Array propertyArrayIntegers;
1019   propertyArrayIntegers.PushBack( FaceCullingMode::FRONT );
1020   propertyArrayIntegers.PushBack( FaceCullingMode::BACK );
1021   result = FaceCullingMode::NONE;
1022
1023   returnValue = GetBitmaskEnumerationProperty< FaceCullingMode::Type >( propertyArrayIntegers, testTable, testTableCount, result );
1024
1025   // TEST: The return value when checking an array with 2 INTEGERS is "true" if the properties can be successfully converted.
1026   DALI_TEST_CHECK( returnValue );
1027   // TEST: The result value when checking an array with 2 INTEGERS is the ORd value of the 2 integers.
1028   DALI_TEST_CHECK( result == ( FaceCullingMode::FRONT | FaceCullingMode::BACK ) );
1029
1030   // Property array of 2 strings.
1031   Property::Array propertyArrayStrings;
1032   propertyArrayStrings.PushBack( "FRONT" );
1033   propertyArrayStrings.PushBack( "BACK" );
1034   result = FaceCullingMode::NONE;
1035
1036   returnValue = GetBitmaskEnumerationProperty< FaceCullingMode::Type >( propertyArrayStrings, testTable, testTableCount, result );
1037
1038   // TEST: The return value when checking an array with 2 STRINGS is "true" if the properties can be successfully converted.
1039   DALI_TEST_CHECK( returnValue );
1040   // TEST: The result value when checking an array with 2 STRINGS is the ORd value of the 2 integer equivalents of the strings.
1041   DALI_TEST_CHECK( result == ( FaceCullingMode::FRONT | FaceCullingMode::BACK ) );
1042
1043   // Property array of an int and a string.
1044   Property::Array propertyArrayMixed;
1045   propertyArrayMixed.PushBack( FaceCullingMode::FRONT );
1046   propertyArrayMixed.PushBack( "BACK" );
1047   result = FaceCullingMode::NONE;
1048
1049   returnValue = GetBitmaskEnumerationProperty< FaceCullingMode::Type >( propertyArrayMixed, testTable, testTableCount, result );
1050
1051   // TEST: The return value when checking an array with an INTEGER and a STRING is "true" if the properties can be successfully converted.
1052   DALI_TEST_CHECK( returnValue );
1053   // TEST: The result value when checking an array with an INTEGER and a STRING is the ORd value of the 2 integer equivalents of the strings.
1054   DALI_TEST_CHECK( result == ( FaceCullingMode::FRONT | FaceCullingMode::BACK ) );
1055
1056   // Property array of an int and a string.
1057   Property::Array propertyArrayInvalid;
1058   propertyArrayInvalid.PushBack( FaceCullingMode::FRONT );
1059   propertyArrayInvalid.PushBack( Vector3::ZERO );
1060
1061   // Set the initial value to non-zero, so we can test it does not change.
1062   result = FaceCullingMode::FRONT_AND_BACK;
1063
1064   returnValue = GetBitmaskEnumerationProperty< FaceCullingMode::Type >( propertyArrayInvalid, testTable, testTableCount, result );
1065
1066   // TEST: The return value when checking an array with an INTEGER and a Vector3 is "false" as the properties can not be successfully converted.
1067   DALI_TEST_CHECK( !returnValue );
1068   // TEST: The result value when checking an array with an INTEGER and a Vector3 is unchanged.
1069   DALI_TEST_CHECK( result == FaceCullingMode::FRONT_AND_BACK );
1070
1071   END_TEST;
1072 }
1073
1074 int UtcDaliScriptingFindEnumIndexN(void)
1075 {
1076   const Scripting::StringEnum myTable[] =
1077     {
1078       { "ONE",    (1<<1) },
1079       { "TWO",    (1<<2) },
1080       { "THREE",  (1<<3) },
1081       { "FOUR",   (1<<4) },
1082       { "FIVE",   (1<<5) },
1083     };
1084   const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
1085   DALI_TEST_EQUALS( myTableCount, FindEnumIndex( "Foo", myTable, myTableCount ), TEST_LOCATION );
1086
1087   END_TEST;
1088 }
1089
1090 int UtcDaliScriptingEnumStringToIntegerP(void)
1091 {
1092   const Scripting::StringEnum myTable[] =
1093     {
1094       { "ONE",    (1<<1) },
1095       { "TWO",    (1<<2) },
1096       { "THREE",  (1<<3) },
1097       { "FOUR",   (1<<4) },
1098       { "FIVE",   (1<<5) },
1099     };
1100   const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
1101
1102   int integerEnum = 0;
1103   DALI_TEST_CHECK( EnumStringToInteger( "ONE", myTable, myTableCount, integerEnum ) );
1104
1105   DALI_TEST_EQUALS( integerEnum, (1<<1), TEST_LOCATION );
1106
1107   integerEnum = 0;
1108   DALI_TEST_CHECK( EnumStringToInteger( "ONE,TWO", myTable, myTableCount, integerEnum ) );
1109   DALI_TEST_EQUALS( integerEnum, (1<<1) | (1<<2), TEST_LOCATION );
1110
1111   DALI_TEST_CHECK( EnumStringToInteger( "ONE,,TWO", myTable, myTableCount, integerEnum ) );
1112   DALI_TEST_EQUALS( integerEnum, (1<<1) | (1<<2), TEST_LOCATION );
1113
1114   DALI_TEST_CHECK( EnumStringToInteger( "ONE,TWO,THREE", myTable, myTableCount, integerEnum ) );
1115   DALI_TEST_EQUALS( integerEnum, (1<<1) | (1<<2) | (1<<3), TEST_LOCATION );
1116
1117   DALI_TEST_CHECK( EnumStringToInteger( "ONE,TWO,THREE,FOUR,FIVE", myTable, myTableCount, integerEnum ) );
1118   DALI_TEST_EQUALS( integerEnum, (1<<1) | (1<<2) | (1<<3) | (1<<4) | (1<<5), TEST_LOCATION );
1119
1120   DALI_TEST_CHECK( EnumStringToInteger( "TWO,ONE", myTable, myTableCount, integerEnum ) );
1121   DALI_TEST_EQUALS( integerEnum, (1<<1) | (1<<2), TEST_LOCATION );
1122
1123   DALI_TEST_CHECK( EnumStringToInteger( "TWO,ONE,FOUR,THREE,FIVE", myTable, myTableCount, integerEnum ) );
1124   DALI_TEST_EQUALS( integerEnum, (1<<1) | (1<<2) | (1<<3) | (1<<4) | (1<<5), TEST_LOCATION );
1125
1126   DALI_TEST_CHECK( EnumStringToInteger( "ONE,SEVEN", myTable, myTableCount, integerEnum ) );
1127   DALI_TEST_EQUALS( integerEnum, (1<<1), TEST_LOCATION );
1128
1129   DALI_TEST_CHECK( EnumStringToInteger( "ONE,", myTable, myTableCount, integerEnum ) );
1130   DALI_TEST_EQUALS( integerEnum, (1<<1), TEST_LOCATION );
1131
1132
1133   END_TEST;
1134 }
1135
1136 int UtcDaliScriptingEnumStringToIntegerN(void)
1137 {
1138   const Scripting::StringEnum myTable[] =
1139   {
1140     { "ONE",    1 },
1141     { "TWO",    2 },
1142     { "THREE",  3 },
1143     { "FOUR",   4 },
1144     { "FIVE",   5 },
1145   };
1146   const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
1147
1148   int integerEnum = 0;
1149   DALI_TEST_CHECK( !EnumStringToInteger( "Foo", myTable, myTableCount, integerEnum ) );
1150
1151   DALI_TEST_CHECK( !EnumStringToInteger( "", myTable, myTableCount, integerEnum ) );
1152
1153   DALI_TEST_CHECK( !EnumStringToInteger( ",", myTable, myTableCount, integerEnum ) );
1154
1155   DALI_TEST_CHECK( !EnumStringToInteger( ",ONE,SEVEN", myTable, myTableCount, integerEnum ) );
1156
1157   DALI_TEST_CHECK( !EnumStringToInteger( ",", myTable, myTableCount, integerEnum ) );
1158
1159   DALI_TEST_CHECK( !EnumStringToInteger( "ONE", myTable, 0, integerEnum ) );
1160
1161   DALI_TEST_EQUALS( integerEnum, 0, TEST_LOCATION );
1162
1163   END_TEST;
1164 }
1165
1166 int UtcDaliScriptingEnumStringToIntegerInvalidEnumP(void)
1167 {
1168   const Scripting::StringEnum myTable[] =
1169   {
1170     { "",    1 },
1171     { "",    2 },
1172     { "",    3 },
1173   };
1174
1175   const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
1176
1177   int integerEnum = 0;
1178   DALI_TEST_CHECK( EnumStringToInteger( "", myTable, myTableCount, integerEnum ) );
1179   DALI_TEST_EQUALS( integerEnum, 1, TEST_LOCATION );
1180
1181   END_TEST;
1182 }
1183
1184 int UtcDaliScriptingEnumStringToIntegerInvalidEnumN(void)
1185 {
1186   const Scripting::StringEnum myTable[] =
1187   {
1188     { "",    1 },
1189     { "",    1 },
1190     { "",    1 },
1191   };
1192
1193   const unsigned int myTableCount = sizeof( myTable ) / sizeof( myTable[0] );
1194
1195   int integerEnum = 0;
1196   DALI_TEST_CHECK( !EnumStringToInteger( NULL, NULL, 0, integerEnum ) );
1197
1198   DALI_TEST_CHECK( !EnumStringToInteger( "ONE", NULL, 0, integerEnum ) );
1199
1200   DALI_TEST_CHECK( !EnumStringToInteger( NULL, myTable, 0, integerEnum ) );
1201
1202   DALI_TEST_CHECK( !EnumStringToInteger( NULL, myTable, myTableCount, integerEnum ) );
1203
1204   DALI_TEST_CHECK( !EnumStringToInteger( "ONE", NULL, myTableCount, integerEnum ) );
1205
1206   DALI_TEST_EQUALS( integerEnum, 0, TEST_LOCATION );
1207
1208   END_TEST;
1209 }