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