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