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