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