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