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