Merge "[4.0] Check line is empty or not before getting line of character" into tizen_4.0
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-Visual.cpp
1 /*
2  * Copyright (c) 2017 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 #include <iostream>
18 #include <stdlib.h>
19 #include <unistd.h>
20
21 #include <dali-toolkit-test-suite-utils.h>
22 #include <toolkit-event-thread-callback.h>
23 #include <dali/devel-api/object/handle-devel.h>
24 #include <dali-toolkit/devel-api/controls/control-devel.h>
25 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
26 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
27 #include <dali-toolkit/devel-api/visual-factory/transition-data.h>
28 #include <dali-toolkit/devel-api/visuals/color-visual-properties-devel.h>
29 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
30 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
31 #include <dali-toolkit/devel-api/visuals/text-visual-properties-devel.h>
32 #include <dali-toolkit/devel-api/visuals/animated-gradient-visual-properties-devel.h>
33 #include <dali-toolkit/dali-toolkit.h>
34
35 #include "dummy-control.h"
36
37 using namespace Dali;
38 using namespace Dali::Toolkit;
39
40 namespace
41 {
42 const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
43 const char* TEST_IMAGE_FILE_NAME =  TEST_RESOURCE_DIR "/gallery-small-1.jpg";
44 const char* TEST_NPATCH_FILE_NAME =  TEST_RESOURCE_DIR "/button-up.9.png";
45 const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
46 const char* TEST_OBJ_FILE_NAME = TEST_RESOURCE_DIR "/Cube.obj";
47 const char* TEST_MTL_FILE_NAME = TEST_RESOURCE_DIR "/ToyRobot-Metal.mtl";
48 const char* TEST_RESOURCE_LOCATION = TEST_RESOURCE_DIR "/";
49
50
51 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
52
53 Property::Map DefaultTransform()
54 {
55   Property::Map transformMap;
56   transformMap
57     .Add( Toolkit::Visual::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
58     .Add( Toolkit::Visual::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
59     .Add( Toolkit::Visual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN )
60     .Add( Toolkit::Visual::Transform::Property::ANCHOR_POINT, Toolkit::Align::TOP_BEGIN )
61     .Add( Toolkit::Visual::Transform::Property::OFFSET_POLICY, Vector2( Toolkit::Visual::Transform::Policy::RELATIVE, Toolkit::Visual::Transform::Policy::RELATIVE ) )
62     .Add( Toolkit::Visual::Transform::Property::SIZE_POLICY, Vector2( Toolkit::Visual::Transform::Policy::RELATIVE, Toolkit::Visual::Transform::Policy::RELATIVE ) );
63   return transformMap;
64 }
65
66 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
67 {
68   if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
69   {
70     for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
71     {
72       const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
73
74       Property::Value* valueSet = NULL;
75       if ( valueGet.first.type == Property::Key::INDEX )
76       {
77         valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
78       }
79       else
80       {
81         // Get Key is a string so searching Set Map for a string key
82         valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
83       }
84
85       if( NULL != valueSet )
86       {
87         if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
88         {
89           tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
90           return false;
91         }
92         else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
93         {
94           tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
95           return false;
96         }
97         else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
98         {
99           tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
100           return false;
101         }
102         else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
103         {
104           tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
105           return false;
106         }
107         else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
108         {
109           Vector2 vector2Get = valueGet.second.Get<Vector2>();
110           Vector2 vector2Set = valueSet->Get<Vector2>();
111           tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
112           return false;
113         }
114         else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
115         {
116           Vector4 vector4Get = valueGet.second.Get<Vector4>();
117           Vector4 vector4Set = valueSet->Get<Vector4>();
118           tet_printf( "Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a );
119           return false;
120         }
121       }
122       else
123       {
124         if ( valueGet.first.type == Property::Key::INDEX )
125         {
126           tet_printf( "  The key %d doesn't exist.", valueGet.first.indexKey );
127         }
128         else
129         {
130           tet_printf( "  The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
131         }
132         return false;
133       }
134     }
135   }
136
137   return true;
138 }
139
140 void PrepareResourceImage( ToolkitTestApplication& application, unsigned int imageWidth, unsigned int imageHeight, Pixel::Format pixelFormat )
141 {
142   TestPlatformAbstraction& platform = application.GetPlatform();
143   platform.SetClosestImageSize(Vector2( imageWidth, imageHeight));
144
145   Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
146   Integration::PixelBuffer* pixbuffer = bitmap->GetPackedPixelsProfile()->ReserveBuffer( pixelFormat, imageWidth, imageHeight, imageWidth, imageHeight );
147   unsigned int bytesPerPixel = GetBytesPerPixel(  pixelFormat );
148   unsigned int initialColor = 0xFF;
149   memset( pixbuffer, initialColor, imageHeight*imageWidth*bytesPerPixel);
150
151   Integration::ResourcePointer resourcePtr(bitmap);
152   platform.SetSynchronouslyLoadedResource( resourcePtr );
153 }
154 } //namespace
155
156 void dali_visual_startup(void)
157 {
158   test_return_value = TET_UNDEF;
159 }
160
161 void dali_visual_cleanup(void)
162 {
163   test_return_value = TET_PASS;
164 }
165
166
167 static void TestMixColor( Visual::Base visual, Property::Index mixColorIndex, const Vector4& testColor )
168 {
169   Property::Map map;
170   visual.CreatePropertyMap(map);
171   Property::Value* value = map.Find( mixColorIndex );
172   DALI_TEST_CHECK( value );
173   Vector3 mixColor1;
174   DALI_TEST_CHECK( value->Get( mixColor1 ) );
175   DALI_TEST_EQUALS( mixColor1, Vector3(testColor), 0.001, TEST_LOCATION );
176
177   value = map.Find( Visual::Property::MIX_COLOR );
178   DALI_TEST_CHECK( value );
179   Vector4 mixColor2;
180   DALI_TEST_CHECK( value->Get( mixColor2 ) );
181   DALI_TEST_EQUALS( mixColor2, testColor, 0.001, TEST_LOCATION );
182
183   value = map.Find( Visual::Property::OPACITY );
184   DALI_TEST_CHECK( value );
185   float opacity;
186   DALI_TEST_CHECK( value->Get( opacity ) );
187   DALI_TEST_EQUALS( opacity, testColor.a, 0.001, TEST_LOCATION );
188 }
189
190
191 int UtcDaliVisualCopyAndAssignment(void)
192 {
193   ToolkitTestApplication application;
194   tet_infoline( "UtcDaliVisualCopyAndAssignment" );
195
196   VisualFactory factory = VisualFactory::Get();
197   Property::Map propertyMap;
198   propertyMap.Insert(Visual::Property::TYPE,  Visual::COLOR);
199   propertyMap.Insert(ColorVisual::Property::MIX_COLOR,  Color::BLUE);
200   Visual::Base visual = factory.CreateVisual( propertyMap );
201
202   Visual::Base visualCopy( visual );
203   DALI_TEST_CHECK(visual == visualCopy);
204
205   Visual::Base emptyVisual;
206   Visual::Base emptyVisualCopy( emptyVisual );
207   DALI_TEST_CHECK(emptyVisual == emptyVisualCopy);
208
209   Visual::Base visualEquals;
210   visualEquals = visual;
211   DALI_TEST_CHECK(visual == visualEquals);
212
213   Visual::Base emptyVisualEquals;
214   emptyVisualEquals = emptyVisual;
215   DALI_TEST_CHECK( emptyVisual == emptyVisualEquals );
216
217   //self assignment
218   visual = visual;
219   DALI_TEST_CHECK( visual = visualCopy );
220
221   END_TEST;
222 }
223
224 int UtcDaliVisualSetName01(void)
225 {
226   ToolkitTestApplication application;
227   tet_infoline( "UtcDaliVisualSetName" );
228
229   VisualFactory factory = VisualFactory::Get();
230   Property::Map propertyMap;
231   propertyMap.Insert(Visual::Property::TYPE,  Visual::COLOR);
232   propertyMap.Insert(ColorVisual::Property::MIX_COLOR,  Color::BLUE);
233   Visual::Base visual = factory.CreateVisual( propertyMap );
234
235   const char* visualName = "backgroundVisual";
236   visual.SetName( visualName );
237
238   DALI_TEST_EQUALS( visual.GetName(), visualName, TEST_LOCATION );
239
240   END_TEST;
241 }
242
243 int UtcDaliVisualSetGetDepthIndex(void)
244 {
245   ToolkitTestApplication application;
246   tet_infoline( "UtcDaliVisualSetDepthIndex" );
247
248   VisualFactory factory = VisualFactory::Get();
249   Property::Map propertyMap;
250   propertyMap.Insert(Visual::Property::TYPE,  Visual::COLOR);
251   propertyMap.Insert(ColorVisual::Property::MIX_COLOR,  Color::BLUE);
252   Visual::Base visual = factory.CreateVisual( propertyMap );
253
254   visual.SetDepthIndex( 1 );
255
256   DummyControl dummyControl = DummyControl::New(true);
257   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
258   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
259
260   dummyControl.SetSize(200.f, 200.f);
261   Stage::GetCurrent().Add( dummyControl );
262
263
264   int depthIndex = dummyControl.GetRendererAt(0u).GetProperty<int>( Renderer::Property::DEPTH_INDEX );
265   DALI_TEST_EQUALS( depthIndex, 1, TEST_LOCATION );
266   DALI_TEST_EQUALS( visual.GetDepthIndex(), 1, TEST_LOCATION );
267
268   visual.SetDepthIndex( -1 );
269   depthIndex = dummyControl.GetRendererAt(0u).GetProperty<int>( Renderer::Property::DEPTH_INDEX );
270   DALI_TEST_EQUALS( depthIndex, -1, TEST_LOCATION );
271   DALI_TEST_EQUALS( visual.GetDepthIndex(), -1, TEST_LOCATION );
272
273   END_TEST;
274 }
275
276 int UtcDaliVisualSize(void)
277 {
278   ToolkitTestApplication application;
279   tet_infoline( "UtcDaliVisualGetNaturalSize" );
280
281   VisualFactory factory = VisualFactory::Get();
282   Vector2 controlSize( 20.f, 30.f );
283   Vector2 naturalSize;
284
285   // color colorVisual
286   Dali::Property::Map map;
287   map[ Toolkit::Visual::Property::TYPE ] = Visual::COLOR;
288   map[ ColorVisual::Property::MIX_COLOR ] = Color::MAGENTA;
289
290   Visual::Base colorVisual = factory.CreateVisual( map );
291   colorVisual.SetTransformAndSize(DefaultTransform(), controlSize );
292
293   colorVisual.GetNaturalSize(naturalSize);
294   DALI_TEST_EQUALS( naturalSize, Vector2::ZERO, TEST_LOCATION );
295
296   // image visual
297   PrepareResourceImage( application, 100u, 200u, Pixel::RGBA8888 );
298   Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
299   Visual::Base imageVisual = factory.CreateVisual( image );
300   imageVisual.SetTransformAndSize(DefaultTransform(), controlSize );
301
302   imageVisual.GetNaturalSize(naturalSize);
303   DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 200.f), TEST_LOCATION );
304
305   // n patch visual is tested in the utc-Dali-VisualFactory.cpp
306
307   // border visual
308   float borderSize = 5.f;
309   map.Clear();
310   map[ Toolkit::Visual::Property::TYPE ] = Visual::BORDER;
311   map[ BorderVisual::Property::COLOR  ] = Color::RED;
312   map[ BorderVisual::Property::SIZE   ] = borderSize;
313   Visual::Base borderVisual = factory.CreateVisual( map );
314   borderVisual.SetTransformAndSize(DefaultTransform(), controlSize );
315   borderVisual.GetNaturalSize(naturalSize);
316   DALI_TEST_EQUALS( naturalSize, Vector2::ZERO, TEST_LOCATION );
317
318   // gradient gradientVisual
319   Property::Map propertyMap;
320   propertyMap.Insert(Visual::Property::TYPE,  Visual::GRADIENT);
321   Vector2 start(-1.f, -1.f);
322   Vector2 end(1.f, 1.f);
323   propertyMap.Insert( "mixColor", Color::MAGENTA );
324   propertyMap.Insert( GradientVisual::Property::START_POSITION,   start) ;
325   propertyMap.Insert( GradientVisual::Property::END_POSITION,   end );
326   propertyMap.Insert( GradientVisual::Property::STOP_OFFSET,   Vector2(0.f, 1.f) );
327   propertyMap.Insert( GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT) ;
328   Property::Array stopColors;
329   stopColors.PushBack( Color::RED );
330   stopColors.PushBack( Color::GREEN );
331   propertyMap.Insert(GradientVisual::Property::STOP_COLOR,   stopColors);
332   Visual::Base gradientVisual = factory.CreateVisual(propertyMap);
333   gradientVisual.SetTransformAndSize(DefaultTransform(), controlSize );
334   gradientVisual.GetNaturalSize(naturalSize);
335   DALI_TEST_EQUALS( naturalSize, Vector2::ZERO,TEST_LOCATION );
336
337   // animated gradient visual
338   Vector2 animated_gradient_visual_size(10.f, 10.f);
339   propertyMap.Clear();
340   propertyMap.Insert( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_GRADIENT );
341   Visual::Base animatedGradientVisual = factory.CreateVisual( propertyMap );
342   animatedGradientVisual.GetNaturalSize(naturalSize);
343   animatedGradientVisual.SetTransformAndSize(DefaultTransform(), controlSize );
344   DALI_TEST_EQUALS( naturalSize, Vector2::ZERO, TEST_LOCATION );
345
346   // svg visual
347   Visual::Base svgVisual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions() );
348   svgVisual.SetTransformAndSize(DefaultTransform(), controlSize );
349   svgVisual.GetNaturalSize(naturalSize);
350   // TEST_SVG_FILE:
351   //  <svg width="100" height="100">
352   //  <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
353   //  </svg>
354   DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 100.f), TEST_LOCATION );
355
356   // svg visual with a size
357   Visual::Base svgVisual2 = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions(200, 200) );
358   svgVisual2.GetNaturalSize(naturalSize);
359   DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 100.f), TEST_LOCATION ); // Natural size should still be 100, 100
360
361   // Text visual.
362
363   // Load some fonts to get the same metrics on different platforms.
364   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
365   fontClient.SetDpi( 96u, 96u );
366
367   char* pathNamePtr = get_current_dir_name();
368   const std::string pathName( pathNamePtr );
369   free( pathNamePtr );
370
371   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf" );
372
373   propertyMap.Clear();
374   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::TEXT );
375   propertyMap.Insert( TextVisual::Property::ENABLE_MARKUP, true );
376   propertyMap.Insert( TextVisual::Property::TEXT, "<font family='TizenSans' size='12'>Hello world</font>" );
377   propertyMap.Insert( TextVisual::Property::MULTI_LINE, true );
378
379   Visual::Base textVisual = factory.CreateVisual( propertyMap );
380   textVisual.GetNaturalSize( naturalSize );
381   DALI_TEST_EQUALS( naturalSize, Size( 80.f, 20.f ), TEST_LOCATION );
382
383   const float height = textVisual.GetHeightForWidth( 40.f );
384   DALI_TEST_EQUALS( height, 40.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
385
386   //AnimatedImageVisual
387   Visual::Base animatedImageVisual = factory.CreateVisual( TEST_GIF_FILE_NAME, ImageDimensions() );
388   animatedImageVisual.SetTransformAndSize(DefaultTransform(), controlSize );
389   animatedImageVisual.GetNaturalSize(naturalSize);
390   // TEST_GIF_FILE: anim.gif
391   // resolution: 50*50, frame count: 4, frame delay: 0.2 second for each frame
392   DALI_TEST_EQUALS( naturalSize, Vector2(50.f, 50.f), TEST_LOCATION );
393
394   END_TEST;
395 }
396
397 int UtcDaliVisualSetOnOffStage(void)
398 {
399   ToolkitTestApplication application;
400   tet_infoline( "UtcDaliVisualSetDepthIndex" );
401
402   VisualFactory factory = VisualFactory::Get();
403   Property::Map propertyMap;
404   propertyMap.Insert(Visual::Property::TYPE,  Visual::COLOR);
405   propertyMap.Insert(ColorVisual::Property::MIX_COLOR,  Color::BLUE);
406   Visual::Base visual = factory.CreateVisual( propertyMap );
407
408   DummyControl actor = DummyControl::New(true);
409   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
410   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
411
412   actor.SetSize(200.f, 200.f);
413
414   application.SendNotification();
415   application.Render(0);
416   DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
417
418   Stage::GetCurrent().Add( actor );
419
420   application.SendNotification();
421   application.Render(0);
422   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
423
424   Stage::GetCurrent().Remove( actor );
425
426   application.SendNotification();
427   application.Render(0);
428   DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
429
430   END_TEST;
431 }
432
433 int UtcDaliVisualGetPropertyMap1(void)
434 {
435   ToolkitTestApplication application;
436   tet_infoline( "UtcDaliVisualGetPropertyMap1: ColorVisual (With base MixColor" );
437
438   VisualFactory factory = VisualFactory::Get();
439   Property::Map propertyMap;
440   propertyMap.Insert(Visual::Property::TYPE,  Visual::COLOR);
441   propertyMap.Insert(Visual::Property::MIX_COLOR,  Color::BLUE);
442   Visual::Base colorVisual = factory.CreateVisual( propertyMap );
443
444   Property::Map resultMap;
445   colorVisual.CreatePropertyMap( resultMap );
446
447   Property::Value* typeValue = resultMap.Find( Toolkit::Visual::Property::TYPE,  Property::INTEGER );
448   DALI_TEST_CHECK( typeValue );
449   DALI_TEST_CHECK( typeValue->Get<int>() == Visual::COLOR );
450
451   Property::Value* colorValue = resultMap.Find( ColorVisual::Property::MIX_COLOR,  Property::VECTOR4 );
452   DALI_TEST_CHECK( colorValue );
453   DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::BLUE );
454
455   // change the blend color
456   propertyMap[ColorVisual::Property::MIX_COLOR] = Color::CYAN;
457   colorVisual = factory.CreateVisual( propertyMap  );
458   colorVisual.CreatePropertyMap( resultMap );
459
460   colorValue = resultMap.Find( ColorVisual::Property::MIX_COLOR,  Property::VECTOR4 );
461   DALI_TEST_CHECK( colorValue );
462   DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::CYAN );
463
464   END_TEST;
465 }
466
467 int UtcDaliVisualGetPropertyMap2(void)
468 {
469   ToolkitTestApplication application;
470   tet_infoline( "UtcDaliVisualGetPropertyMap2: BorderVisual" );
471
472   VisualFactory factory = VisualFactory::Get();
473   Property::Map propertyMap;
474   propertyMap.Insert(Visual::Property::TYPE,  Visual::BORDER);
475   propertyMap.Insert("mixColor", Vector4(1.0f, 0.0f, 1.0f, 0.5f) );
476   propertyMap.Insert("borderColor",  Color::BLUE);
477   propertyMap.Insert("borderSize",  5.f);
478   propertyMap.Insert("antiAliasing",  true);
479   Visual::Base borderVisual = factory.CreateVisual( propertyMap );
480
481   Property::Map resultMap;
482   borderVisual.CreatePropertyMap( resultMap );
483
484   // check the property values from the returned map from visual
485   Property::Value* typeValue = resultMap.Find( Toolkit::Visual::Property::TYPE,  Property::INTEGER );
486   DALI_TEST_CHECK( typeValue );
487   DALI_TEST_CHECK( typeValue->Get<int>() == Visual::BORDER );
488
489   Property::Value* colorValue = resultMap.Find( BorderVisual::Property::COLOR,  Property::VECTOR4 );
490   DALI_TEST_CHECK( colorValue );
491   DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::BLUE );
492
493   Property::Value* sizeValue = resultMap.Find( BorderVisual::Property::SIZE,  Property::FLOAT );
494   DALI_TEST_CHECK( sizeValue );
495   DALI_TEST_CHECK( sizeValue->Get<float>() == 5.f );
496
497   Property::Value* AAValue = resultMap.Find( BorderVisual::Property::ANTI_ALIASING, Property::BOOLEAN );
498   DALI_TEST_CHECK( AAValue );
499   DALI_TEST_CHECK( AAValue->Get<bool>() == true );
500
501   Property::Map propertyMap1;
502   propertyMap1[ Toolkit::Visual::Property::TYPE ] = Visual::BORDER;
503   propertyMap1[ BorderVisual::Property::COLOR  ] = Color::CYAN;
504   propertyMap1[ BorderVisual::Property::SIZE   ] = 10.0f;
505   borderVisual = factory.CreateVisual( propertyMap1 );
506   borderVisual.CreatePropertyMap( resultMap );
507
508   typeValue = resultMap.Find( Toolkit::Visual::Property::TYPE,  Property::INTEGER );
509   DALI_TEST_CHECK( typeValue );
510   DALI_TEST_CHECK( typeValue->Get<int>() == Visual::BORDER );
511
512   colorValue = resultMap.Find( BorderVisual::Property::COLOR,  Property::VECTOR4 );
513   DALI_TEST_CHECK( colorValue );
514   DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::CYAN );
515
516   colorValue = resultMap.Find( BorderVisual::Property::SIZE,  Property::FLOAT );
517   DALI_TEST_CHECK( colorValue );
518   DALI_TEST_CHECK( colorValue->Get<float>() == 10.f );
519
520
521   END_TEST;
522 }
523
524 int UtcDaliVisualGetPropertyMap2N(void)
525 {
526   ToolkitTestApplication application;
527   tet_infoline( "UtcDaliVisualGetPropertyMap2N: BorderVisual with no setup properties" );
528
529   VisualFactory factory = VisualFactory::Get();
530   Property::Map propertyMap;
531   propertyMap.Insert(Visual::Property::TYPE,  Visual::BORDER);
532   Visual::Base borderVisual = factory.CreateVisual( propertyMap );
533
534   tet_infoline( "Test that the visual is created, with a default renderer" );
535   DALI_TEST_CHECK( borderVisual );
536
537   DummyControl dummyControl = DummyControl::New(true);
538   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
539   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, borderVisual );
540   Stage::GetCurrent().Add( dummyControl );
541
542   DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 1, TEST_LOCATION );
543
544   END_TEST;
545 }
546
547
548 int UtcDaliVisualGetPropertyMap3(void)
549 {
550   ToolkitTestApplication application;
551   tet_infoline( "UtcDaliVisualGetPropertyMap3: linear GradientVisual" );
552
553   VisualFactory factory = VisualFactory::Get();
554   DALI_TEST_CHECK( factory );
555
556   Property::Map propertyMap;
557   propertyMap.Insert(Visual::Property::TYPE,  Visual::GRADIENT);
558
559   Vector2 start(-1.f, -1.f);
560   Vector2 end(1.f, 1.f);
561   propertyMap.Insert( "startPosition", start);
562   propertyMap.Insert( "endPosition", end);
563   propertyMap.Insert( "spreadMethod", GradientVisual::SpreadMethod::REPEAT);
564
565   propertyMap.Insert(GradientVisual::Property::STOP_OFFSET,   Vector2(0.2f, 0.8f));
566
567   Property::Array stopColors;
568   stopColors.PushBack( Color::RED );
569   stopColors.PushBack( Color::GREEN );
570   propertyMap.Insert(GradientVisual::Property::STOP_COLOR,   stopColors);
571
572   Visual::Base gradientVisual = factory.CreateVisual(propertyMap);
573
574   Property::Map resultMap;
575   gradientVisual.CreatePropertyMap( resultMap );
576
577   // check the property values from the returned map from visual
578   Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE,  Property::INTEGER );
579   DALI_TEST_CHECK( value );
580   DALI_TEST_CHECK( value->Get<int>() == Visual::GRADIENT );
581
582   value = resultMap.Find( GradientVisual::Property::UNITS,  Property::INTEGER );
583   DALI_TEST_CHECK( value );
584   DALI_TEST_CHECK( value->Get<int>() == GradientVisual::Units::OBJECT_BOUNDING_BOX );
585
586   value = resultMap.Find( GradientVisual::Property::SPREAD_METHOD,   Property::INTEGER );
587   DALI_TEST_CHECK( value );
588   DALI_TEST_CHECK( value->Get<int>() == GradientVisual::SpreadMethod::REPEAT );
589
590   value = resultMap.Find( GradientVisual::Property::START_POSITION,   Property::VECTOR2 );
591   DALI_TEST_CHECK( value );
592   DALI_TEST_EQUALS( value->Get<Vector2>(), start , Math::MACHINE_EPSILON_100, TEST_LOCATION );
593
594   value = resultMap.Find( GradientVisual::Property::END_POSITION,   Property::VECTOR2 );
595   DALI_TEST_CHECK( value );
596   DALI_TEST_EQUALS( value->Get<Vector2>(), end , Math::MACHINE_EPSILON_100, TEST_LOCATION );
597
598   value = resultMap.Find( GradientVisual::Property::STOP_OFFSET,   Property::ARRAY );
599   DALI_TEST_CHECK( value );
600   Property::Array* offsetArray = value->GetArray();
601   DALI_TEST_CHECK( offsetArray->Count() == 2 );
602   DALI_TEST_EQUALS( offsetArray->GetElementAt(0).Get<float>(), 0.2f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
603   DALI_TEST_EQUALS( offsetArray->GetElementAt(1).Get<float>(), 0.8f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
604
605   value = resultMap.Find( GradientVisual::Property::STOP_COLOR,   Property::ARRAY );
606   DALI_TEST_CHECK( value );
607   Property::Array* colorArray = value->GetArray();
608   DALI_TEST_CHECK( colorArray->Count() == 2 );
609   DALI_TEST_EQUALS( colorArray->GetElementAt(0).Get<Vector4>(), Color::RED , Math::MACHINE_EPSILON_100, TEST_LOCATION );
610   DALI_TEST_EQUALS( colorArray->GetElementAt(1).Get<Vector4>(), Color::GREEN , Math::MACHINE_EPSILON_100, TEST_LOCATION );
611
612   END_TEST;
613 }
614
615 int UtcDaliVisualGetPropertyMap4(void)
616 {
617   ToolkitTestApplication application;
618   tet_infoline( "UtcDaliVisualGetPropertyMap4: radial GradientVisual" );
619
620   VisualFactory factory = VisualFactory::Get();
621   DALI_TEST_CHECK( factory );
622
623   Property::Map propertyMap;
624   propertyMap.Insert(Visual::Property::TYPE,  Visual::GRADIENT);
625
626   Vector2 center(100.f, 100.f);
627   float radius = 100.f;
628   propertyMap.Insert(GradientVisual::Property::UNITS,  GradientVisual::Units::USER_SPACE);
629   propertyMap.Insert(GradientVisual::Property::CENTER,  center);
630   propertyMap.Insert(GradientVisual::Property::RADIUS,  radius);
631   propertyMap.Insert(GradientVisual::Property::STOP_OFFSET,   Vector3(0.1f, 0.3f, 1.1f));
632
633   Property::Array stopColors;
634   stopColors.PushBack( Color::RED );
635   stopColors.PushBack( Color::BLACK );
636   stopColors.PushBack( Color::GREEN );
637   propertyMap.Insert(GradientVisual::Property::STOP_COLOR,   stopColors);
638
639   Visual::Base gradientVisual = factory.CreateVisual(propertyMap);
640   DALI_TEST_CHECK( gradientVisual );
641
642   Property::Map resultMap;
643   gradientVisual.CreatePropertyMap( resultMap );
644
645   // check the property values from the returned map from visual
646   Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE,  Property::INTEGER );
647   DALI_TEST_CHECK( value );
648   DALI_TEST_CHECK( value->Get<int>() == Visual::GRADIENT );
649
650   value = resultMap.Find( GradientVisual::Property::UNITS,  Property::INTEGER );
651   DALI_TEST_CHECK( value );
652   DALI_TEST_CHECK( value->Get<int>() == GradientVisual::Units::USER_SPACE );
653
654   value = resultMap.Find( GradientVisual::Property::SPREAD_METHOD,   Property::INTEGER );
655   DALI_TEST_CHECK( value );
656   DALI_TEST_CHECK( value->Get<int>() == GradientVisual::SpreadMethod::PAD );
657
658   value = resultMap.Find( GradientVisual::Property::CENTER,  Property::VECTOR2 );
659   DALI_TEST_CHECK( value );
660   DALI_TEST_EQUALS( value->Get<Vector2>(), center , Math::MACHINE_EPSILON_100, TEST_LOCATION );
661
662   value = resultMap.Find( GradientVisual::Property::RADIUS,  Property::FLOAT );
663   DALI_TEST_CHECK( value );
664   DALI_TEST_EQUALS( value->Get<float>(), radius , Math::MACHINE_EPSILON_100, TEST_LOCATION );
665
666   value = resultMap.Find( GradientVisual::Property::STOP_OFFSET,   Property::ARRAY );
667   DALI_TEST_CHECK( value );
668   Property::Array* offsetArray = value->GetArray();
669   DALI_TEST_CHECK( offsetArray->Count() == 3 );
670   DALI_TEST_EQUALS( offsetArray->GetElementAt(0).Get<float>(), 0.1f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
671   DALI_TEST_EQUALS( offsetArray->GetElementAt(1).Get<float>(), 0.3f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
672   // any stop value will be clamped to [0.0, 1.0];
673   DALI_TEST_EQUALS( offsetArray->GetElementAt(2).Get<float>(), 1.0f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
674
675   value = resultMap.Find( GradientVisual::Property::STOP_COLOR,   Property::ARRAY );
676   DALI_TEST_CHECK( value );
677   Property::Array* colorArray = value->GetArray();
678   DALI_TEST_CHECK( colorArray->Count() == 3 );
679   DALI_TEST_EQUALS( colorArray->GetElementAt(0).Get<Vector4>(), Color::RED , Math::MACHINE_EPSILON_100, TEST_LOCATION );
680   DALI_TEST_EQUALS( colorArray->GetElementAt(1).Get<Vector4>(), Color::BLACK , Math::MACHINE_EPSILON_100, TEST_LOCATION );
681   DALI_TEST_EQUALS( colorArray->GetElementAt(2).Get<Vector4>(), Color::GREEN , Math::MACHINE_EPSILON_100, TEST_LOCATION );
682
683   END_TEST;
684 }
685
686 int UtcDaliVisualGetPropertyMap5(void)
687 {
688   ToolkitTestApplication application;
689   tet_infoline( "UtcDaliVisualGetPropertyMap5: ImageVisual" );
690
691   VisualFactory factory = VisualFactory::Get();
692   Property::Map propertyMap;
693   propertyMap.Insert( Toolkit::Visual::Property::TYPE,  Visual::IMAGE );
694   propertyMap.Insert( Visual::Property::MIX_COLOR, Color::MAGENTA );
695   propertyMap.Insert( ImageVisual::Property::URL,  TEST_IMAGE_FILE_NAME );
696   propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH,   20 );
697   propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT,   30 );
698   propertyMap.Insert( "fittingMode",   FittingMode::FIT_HEIGHT );
699   propertyMap.Insert( "samplingMode",   SamplingMode::BOX_THEN_NEAREST );
700   propertyMap.Insert( "pixelArea", Vector4( 0.25f, 0.25f, 0.5f, 0.5f ) );
701   propertyMap.Insert( "wrapModeU", WrapMode::REPEAT );
702   propertyMap.Insert( "wrapModeV", WrapMode::MIRRORED_REPEAT );
703   propertyMap.Insert( "synchronousLoading",   true );
704
705   Visual::Base imageVisual = factory.CreateVisual(propertyMap);
706   DALI_TEST_CHECK( imageVisual );
707
708   Property::Map resultMap;
709   imageVisual.CreatePropertyMap( resultMap );
710
711   // check the property values from the returned map from visual
712   Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE,  Property::INTEGER );
713   DALI_TEST_CHECK( value );
714   DALI_TEST_CHECK( value->Get<int>() == Visual::IMAGE );
715
716   value = resultMap.Find( ImageVisual::Property::URL,  Property::STRING );
717   DALI_TEST_CHECK( value );
718   DALI_TEST_CHECK( value->Get<std::string>() == TEST_IMAGE_FILE_NAME );
719
720   value = resultMap.Find( Visual::Property::MIX_COLOR,  Property::VECTOR4 );
721   DALI_TEST_CHECK( value );
722   DALI_TEST_CHECK( value->Get<Vector4>() == Color::MAGENTA );
723
724   value = resultMap.Find( ImageVisual::Property::FITTING_MODE,   Property::INTEGER );
725   DALI_TEST_CHECK( value );
726   DALI_TEST_CHECK( value->Get<int>() == FittingMode::FIT_HEIGHT );
727
728   value = resultMap.Find( ImageVisual::Property::SAMPLING_MODE,   Property::INTEGER );
729   DALI_TEST_CHECK( value );
730   DALI_TEST_CHECK( value->Get<int>() == SamplingMode::BOX_THEN_NEAREST );
731
732   value = resultMap.Find( ImageVisual::Property::DESIRED_WIDTH,   Property::INTEGER );
733   DALI_TEST_CHECK( value );
734   DALI_TEST_CHECK( value->Get<int>() == 20 );
735
736   value = resultMap.Find( ImageVisual::Property::DESIRED_HEIGHT,   Property::INTEGER );
737   DALI_TEST_CHECK( value );
738   DALI_TEST_CHECK( value->Get<int>() == 30 );
739
740   value = resultMap.Find( ImageVisual::Property::PIXEL_AREA, Property::VECTOR4 );
741   DALI_TEST_CHECK( value );
742   DALI_TEST_EQUALS( value->Get<Vector4>(), Vector4( 0.25f, 0.25f, 0.5f, 0.5f ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
743
744   value = resultMap.Find( ImageVisual::Property::WRAP_MODE_U, Property::INTEGER );
745   DALI_TEST_CHECK( value );
746   DALI_TEST_CHECK(  value->Get<int>() == WrapMode::REPEAT);
747
748   value = resultMap.Find( ImageVisual::Property::WRAP_MODE_V, Property::INTEGER );
749   DALI_TEST_CHECK( value );
750   DALI_TEST_CHECK(  value->Get<int>() == WrapMode::MIRRORED_REPEAT);
751
752   value = resultMap.Find( "synchronousLoading",   Property::BOOLEAN );
753   DALI_TEST_CHECK( value );
754   DALI_TEST_CHECK( value->Get<bool>() == true );
755
756   // Get an image visual with an image handle, and test the default property values
757   PrepareResourceImage( application, 100u, 200u, Pixel::RGBA8888 );
758   Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
759   imageVisual = factory.CreateVisual(image);
760   imageVisual.CreatePropertyMap( resultMap );
761
762   value = resultMap.Find( Toolkit::Visual::Property::TYPE,  Property::INTEGER );
763   DALI_TEST_CHECK( value );
764   DALI_TEST_CHECK( value->Get<int>() == Visual::IMAGE );
765
766   value = resultMap.Find( ImageVisual::Property::URL,  Property::STRING );
767   DALI_TEST_CHECK( value );
768   DALI_TEST_CHECK( value->Get<std::string>() == TEST_IMAGE_FILE_NAME );
769
770   value = resultMap.Find( ImageVisual::Property::FITTING_MODE,   Property::INTEGER );
771   DALI_TEST_CHECK( value );
772   DALI_TEST_CHECK( value->Get<int>() == FittingMode::SHRINK_TO_FIT );
773
774   value = resultMap.Find( ImageVisual::Property::SAMPLING_MODE,   Property::INTEGER );
775   DALI_TEST_CHECK( value );
776   DALI_TEST_CHECK( value->Get<int>() == SamplingMode::BOX );
777
778   value = resultMap.Find( ImageVisual::Property::DESIRED_WIDTH,   Property::INTEGER );
779   DALI_TEST_CHECK( value );
780   DALI_TEST_CHECK( value->Get<int>() == 100 );
781
782   value = resultMap.Find( ImageVisual::Property::DESIRED_HEIGHT,   Property::INTEGER );
783   DALI_TEST_CHECK( value );
784   DALI_TEST_CHECK( value->Get<int>() == 200 );
785
786   value = resultMap.Find( ImageVisual::Property::PIXEL_AREA, Property::VECTOR4 );
787   DALI_TEST_CHECK( value );
788   DALI_TEST_EQUALS( value->Get<Vector4>(), Vector4( 0.f, 0.f, 1.f, 1.f ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
789
790   value = resultMap.Find( ImageVisual::Property::WRAP_MODE_U, Property::INTEGER );
791   DALI_TEST_CHECK( value );
792   DALI_TEST_CHECK(  value->Get<int>() == WrapMode::DEFAULT);
793
794   value = resultMap.Find( ImageVisual::Property::WRAP_MODE_V, Property::INTEGER );
795   DALI_TEST_CHECK( value );
796   DALI_TEST_CHECK(  value->Get<int>() == WrapMode::DEFAULT);
797
798   value = resultMap.Find( "synchronousLoading",   Property::BOOLEAN );
799   DALI_TEST_CHECK( value );
800   DALI_TEST_CHECK( value->Get<bool>() == false );
801
802   END_TEST;
803 }
804
805 int UtcDaliVisualGetPropertyMap6(void)
806 {
807   ToolkitTestApplication application;
808   tet_infoline( "UtcDaliVisualGetPropertyMap6: NPatchVisual" );
809
810   Rect< int > border( 1, 1, 1, 1 );
811
812   VisualFactory factory = VisualFactory::Get();
813   Property::Map propertyMap;
814   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::N_PATCH );
815   propertyMap.Insert( "mixColor",  Color::MAGENTA );
816   propertyMap.Insert( ImageVisual::Property::URL,  TEST_NPATCH_FILE_NAME );
817   propertyMap.Insert( ImageVisual::Property::BORDER_ONLY,  true );
818   propertyMap.Insert( ImageVisual::Property::BORDER, border );
819   propertyMap.Insert( DevelImageVisual::Property::AUXILIARY_IMAGE, "application-icon-30.png" );
820   propertyMap.Insert( DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA, 0.9f );
821   Visual::Base nPatchVisual = factory.CreateVisual( propertyMap );
822
823   Property::Map resultMap;
824   nPatchVisual.CreatePropertyMap( resultMap );
825
826   // check the property values from the returned map from visual
827   Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE,  Property::INTEGER );
828   DALI_TEST_CHECK( value );
829   DALI_TEST_CHECK( value->Get<int>() == Visual::N_PATCH );
830
831   value = resultMap.Find( Visual::Property::MIX_COLOR,  Property::VECTOR4 );
832   DALI_TEST_CHECK( value );
833   DALI_TEST_CHECK( value->Get<Vector4>() == Color::MAGENTA );
834
835   value = resultMap.Find( ImageVisual::Property::URL,  Property::STRING );
836   DALI_TEST_CHECK( value );
837   DALI_TEST_CHECK( value->Get<std::string>() == TEST_NPATCH_FILE_NAME );
838
839   value = resultMap.Find( ImageVisual::Property::BORDER_ONLY,  Property::BOOLEAN );
840   DALI_TEST_CHECK( value );
841   DALI_TEST_CHECK( value->Get<bool>() );
842
843   value = resultMap.Find( ImageVisual::Property::BORDER,  Property::RECTANGLE );
844   DALI_TEST_CHECK( value );
845   DALI_TEST_CHECK( value->Get< Rect< int > >() == border );
846
847   value = resultMap.Find( DevelImageVisual::Property::AUXILIARY_IMAGE, Property::STRING );
848   DALI_TEST_CHECK( value );
849   DALI_TEST_CHECK( value->Get<std::string>() == "application-icon-30.png" );
850
851   value = resultMap.Find( DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA, Property::FLOAT );
852   DALI_TEST_CHECK( value );
853   DALI_TEST_CHECK( value->Get<float>() == 0.9f );
854
855   Vector4 border1( 1.0f, 1.0f, 1.0f, 1.0f );
856
857   Property::Map propertyMap1;
858   propertyMap1.Insert( Toolkit::Visual::Property::TYPE, Visual::N_PATCH );
859   propertyMap1.Insert( "mixColor",  Color::MAGENTA );
860   propertyMap1.Insert( ImageVisual::Property::URL,  TEST_NPATCH_FILE_NAME );
861   propertyMap1.Insert( ImageVisual::Property::BORDER_ONLY,  true );
862   propertyMap1.Insert( ImageVisual::Property::BORDER, border1 );
863   nPatchVisual = factory.CreateVisual( propertyMap1 );
864
865   nPatchVisual.CreatePropertyMap( resultMap );
866
867   // check the property values from the returned map from visual
868   value = resultMap.Find( Toolkit::Visual::Property::TYPE,  Property::INTEGER );
869   DALI_TEST_CHECK( value );
870   DALI_TEST_CHECK( value->Get<int>() == Visual::N_PATCH );
871
872   value = resultMap.Find( Visual::Property::MIX_COLOR,  Property::VECTOR4 );
873   DALI_TEST_CHECK( value );
874   DALI_TEST_CHECK( value->Get<Vector4>() == Color::MAGENTA );
875
876   value = resultMap.Find( ImageVisual::Property::URL,  Property::STRING );
877   DALI_TEST_CHECK( value );
878   DALI_TEST_CHECK( value->Get<std::string>() == TEST_NPATCH_FILE_NAME );
879
880   value = resultMap.Find( ImageVisual::Property::BORDER_ONLY,  Property::BOOLEAN );
881   DALI_TEST_CHECK( value );
882   DALI_TEST_CHECK( value->Get<bool>() );
883
884   value = resultMap.Find( ImageVisual::Property::BORDER,  Property::RECTANGLE );
885   DALI_TEST_CHECK( value );
886   DALI_TEST_CHECK( value->Get< Rect< int > >() == border );
887
888   END_TEST;
889 }
890
891 int UtcDaliVisualGetPropertyMap7(void)
892 {
893   ToolkitTestApplication application;
894   tet_infoline( "UtcDaliVisualGetPropertyMap7: SvgVisual" );
895
896   // request SvgVisual with a property map
897   VisualFactory factory = VisualFactory::Get();
898   Property::Map propertyMap;
899   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::SVG );
900   propertyMap.Insert( Visual::Property::MIX_COLOR, Color::WHITE );
901   propertyMap.Insert( ImageVisual::Property::URL, TEST_SVG_FILE_NAME );
902   propertyMap.Insert( ImageVisual::Property::ATLASING, false );
903   Visual::Base svgVisual = factory.CreateVisual( propertyMap );
904
905   Property::Map resultMap;
906   svgVisual.CreatePropertyMap( resultMap );
907   // check the property values from the returned map from a visual
908   Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE,  Property::INTEGER );
909   DALI_TEST_CHECK( value );
910   DALI_TEST_CHECK( value->Get<int>() == Visual::SVG );
911
912   value = resultMap.Find( ImageVisual::Property::URL,  Property::STRING );
913   DALI_TEST_CHECK( value );
914   DALI_TEST_CHECK( value->Get<std::string>() == TEST_SVG_FILE_NAME );
915
916   value = resultMap.Find( ImageVisual::Property::ATLASING, Property::BOOLEAN );
917   DALI_TEST_CHECK( value );
918   DALI_TEST_CHECK( value->Get<bool>() == false );
919
920   // request SvgVisual with a property map 2
921   propertyMap.Clear();
922   propertyMap[ "visualType" ] = Visual::SVG;
923   propertyMap[ "mixColor" ] = Color::WHITE;
924   propertyMap[ "url" ] = TEST_SVG_FILE_NAME;
925   propertyMap[ "atlasing" ] = true;
926   Visual::Base svgVisual1 = factory.CreateVisual( propertyMap );
927
928   resultMap.Clear();
929   svgVisual1.CreatePropertyMap( resultMap );
930   // check the property values from the returned map from a visual
931   value = resultMap.Find( Toolkit::Visual::Property::TYPE,  Property::INTEGER );
932   DALI_TEST_CHECK( value );
933   DALI_TEST_CHECK( value->Get<int>() == Visual::SVG );
934
935   value = resultMap.Find( ImageVisual::Property::URL,  Property::STRING );
936   DALI_TEST_CHECK( value );
937   DALI_TEST_CHECK( value->Get<std::string>() == TEST_SVG_FILE_NAME );
938
939   value = resultMap.Find( ImageVisual::Property::ATLASING, Property::BOOLEAN );
940   DALI_TEST_CHECK( value );
941   DALI_TEST_CHECK( value->Get<bool>() == true );
942
943   // request SvgVisual with an URL
944   Visual::Base svgVisual2 = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions() );
945   resultMap.Clear();
946   svgVisual2.CreatePropertyMap( resultMap );
947   // check the property values from the returned map from a visual
948   value = resultMap.Find( Toolkit::Visual::Property::TYPE,  Property::INTEGER );
949   DALI_TEST_CHECK( value );
950   DALI_TEST_CHECK( value->Get<int>() == Visual::SVG );
951
952   value = resultMap.Find( ImageVisual::Property::URL,  Property::STRING );
953   DALI_TEST_CHECK( value );
954   DALI_TEST_CHECK( value->Get<std::string>() == TEST_SVG_FILE_NAME );
955
956   END_TEST;
957 }
958
959 //Mesh visual
960 int UtcDaliVisualGetPropertyMap8(void)
961 {
962   ToolkitTestApplication application;
963   tet_infoline( "UtcDaliVisualGetPropertyMap8: MeshVisual" );
964
965   //Request MeshVisual using a property map.
966   VisualFactory factory = VisualFactory::Get();
967   Property::Map propertyMap;
968   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::MESH );
969   propertyMap.Insert( Visual::Property::MIX_COLOR, Color::BLUE );
970   propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
971   propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
972   propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_LOCATION );
973   propertyMap.Insert( MeshVisual::Property::SHADING_MODE, MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING );
974   propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 5.0f, 10.0f, 15.0f) );
975   Visual::Base meshVisual = factory.CreateVisual( propertyMap );
976
977   Property::Map resultMap;
978   meshVisual.CreatePropertyMap( resultMap );
979   TestMixColor( meshVisual, Visual::Property::MIX_COLOR, Color::BLUE );
980
981   //Check values in the result map are identical to the initial map's values.
982   Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
983   DALI_TEST_CHECK( value );
984   DALI_TEST_EQUALS( value->Get<int>(), (int)Visual::MESH, TEST_LOCATION );
985
986   value = resultMap.Find( MeshVisual::Property::OBJECT_URL, Property::STRING );
987   DALI_TEST_CHECK( value );
988   DALI_TEST_EQUALS( value->Get<std::string>(), TEST_OBJ_FILE_NAME, TEST_LOCATION );
989
990   value = resultMap.Find( MeshVisual::Property::MATERIAL_URL, Property::STRING );
991   DALI_TEST_CHECK( value );
992   DALI_TEST_EQUALS( value->Get<std::string>(), TEST_MTL_FILE_NAME, TEST_LOCATION );
993
994   value = resultMap.Find( MeshVisual::Property::TEXTURES_PATH, Property::STRING );
995   DALI_TEST_CHECK( value );
996   DALI_TEST_EQUALS( value->Get<std::string>(), TEST_RESOURCE_LOCATION, TEST_LOCATION );
997
998   value = resultMap.Find( MeshVisual::Property::SHADING_MODE, Property::INTEGER );
999   DALI_TEST_CHECK( value );
1000   DALI_TEST_EQUALS( value->Get<int>(), (int)MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING, TEST_LOCATION );
1001
1002   value = resultMap.Find( MeshVisual::Property::LIGHT_POSITION, Property::VECTOR3 );
1003   DALI_TEST_CHECK( value );
1004   DALI_TEST_EQUALS( value->Get<Vector3>(), Vector3( 5.0f, 10.0f, 15.0f), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1005
1006  END_TEST;
1007 }
1008
1009 //Primitive shape visual
1010 int UtcDaliVisualGetPropertyMap9(void)
1011 {
1012   ToolkitTestApplication application;
1013   tet_infoline( "UtcDaliVisualGetPropertyMap9: PrimitiveVisual" );
1014
1015   Vector4 color = Vector4( 1.0, 0.8, 0.6, 1.0);
1016   Vector3 dimensions = Vector3( 1.0, 2.0, 3.0 );
1017
1018   //Request PrimitiveVisual using a property map.
1019   VisualFactory factory = VisualFactory::Get();
1020   Property::Map propertyMap;
1021   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
1022   propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
1023   propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, color );
1024   propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1025   propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
1026   propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
1027   propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f );
1028   propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
1029   propertyMap.Insert( PrimitiveVisual::Property::SCALE_RADIUS, 60.0f );
1030   propertyMap.Insert( PrimitiveVisual::Property::SCALE_DIMENSIONS, dimensions );
1031   propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.3f );
1032   propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, 0.6f );
1033   propertyMap.Insert( PrimitiveVisual::Property::LIGHT_POSITION, Vector3( 5.0f, 10.0f, 15.0f) );
1034   Visual::Base primitiveVisual = factory.CreateVisual( propertyMap );
1035
1036   Property::Map resultMap;
1037   primitiveVisual.CreatePropertyMap( resultMap );
1038
1039   //Check values in the result map are identical to the initial map's values.
1040   Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
1041   DALI_TEST_CHECK( value );
1042   DALI_TEST_EQUALS( value->Get<int>(), (int)Visual::PRIMITIVE, TEST_LOCATION );
1043
1044   value = resultMap.Find( PrimitiveVisual::Property::SHAPE, Property::INTEGER );
1045   DALI_TEST_CHECK( value );
1046   DALI_TEST_EQUALS( value->Get<int>(), (int)PrimitiveVisual::Shape::CUBE, TEST_LOCATION );
1047
1048   value = resultMap.Find( PrimitiveVisual::Property::MIX_COLOR, Property::VECTOR4 );
1049   DALI_TEST_CHECK( value );
1050   DALI_TEST_CHECK( value->Get<Vector4>() == color );
1051   DALI_TEST_EQUALS( value->Get<Vector4>(), color, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1052
1053   value = resultMap.Find( PrimitiveVisual::Property::SLICES, Property::INTEGER );
1054   DALI_TEST_CHECK( value );
1055   DALI_TEST_EQUALS( value->Get<int>(), 10, TEST_LOCATION );
1056
1057   value = resultMap.Find( PrimitiveVisual::Property::STACKS, Property::INTEGER );
1058   DALI_TEST_CHECK( value );
1059   DALI_TEST_EQUALS( value->Get<int>(), 20, TEST_LOCATION );
1060
1061   value = resultMap.Find( PrimitiveVisual::Property::SCALE_TOP_RADIUS, Property::FLOAT );
1062   DALI_TEST_CHECK( value );
1063   DALI_TEST_EQUALS( value->Get<float>(), 30.0f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1064
1065   value = resultMap.Find( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, Property::FLOAT );
1066   DALI_TEST_CHECK( value );
1067   DALI_TEST_EQUALS( value->Get<float>(), 40.0f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1068
1069   value = resultMap.Find( PrimitiveVisual::Property::SCALE_HEIGHT, Property::FLOAT );
1070   DALI_TEST_CHECK( value );
1071   DALI_TEST_EQUALS( value->Get<float>(), 50.0f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1072
1073   value = resultMap.Find( PrimitiveVisual::Property::SCALE_RADIUS, Property::FLOAT );
1074   DALI_TEST_CHECK( value );
1075   DALI_TEST_EQUALS( value->Get<float>(), 60.0f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1076
1077   value = resultMap.Find( PrimitiveVisual::Property::SCALE_DIMENSIONS, Property::VECTOR3 );
1078   DALI_TEST_CHECK( value );
1079   DALI_TEST_EQUALS( value->Get<Vector3>(), dimensions, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1080
1081   value = resultMap.Find( PrimitiveVisual::Property::BEVEL_PERCENTAGE, Property::FLOAT );
1082   DALI_TEST_CHECK( value );
1083   DALI_TEST_EQUALS( value->Get<float>(), 0.3f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1084
1085   value = resultMap.Find( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, Property::FLOAT );
1086   DALI_TEST_CHECK( value );
1087   DALI_TEST_EQUALS( value->Get<float>(), 0.6f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1088
1089   value = resultMap.Find( PrimitiveVisual::Property::LIGHT_POSITION, Property::VECTOR3 );
1090   DALI_TEST_CHECK( value );
1091   DALI_TEST_EQUALS( value->Get<Vector3>(), Vector3( 5.0f, 10.0f, 15.0f), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1092
1093   END_TEST;
1094 }
1095
1096 //Text shape visual
1097 int UtcDaliVisualGetPropertyMap10(void)
1098 {
1099   ToolkitTestApplication application;
1100   tet_infoline( "UtcDaliVisualGetPropertyMap10: TextVisual" );
1101
1102   //Request PrimitiveVisual using a property map.
1103   VisualFactory factory = VisualFactory::Get();
1104
1105   Property::Map propertyMap;
1106   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::TEXT );
1107   propertyMap.Insert( Visual::Property::MIX_COLOR, Color::BLACK );
1108   propertyMap.Insert( "renderingBackend", static_cast<int>( Toolkit::Text::DEFAULT_RENDERING_BACKEND ) );
1109   propertyMap.Insert( "enableMarkup", false );
1110   propertyMap.Insert( "text", "Hello world" );
1111   propertyMap.Insert( "fontFamily", "TizenSans" );
1112
1113   Property::Map fontStyleMapSet;
1114   fontStyleMapSet.Insert( "weight", "bold" );
1115   propertyMap.Insert( "fontStyle", fontStyleMapSet );
1116
1117   propertyMap.Insert( "pointSize", 12.f );
1118   propertyMap.Insert( "multiLine", true );
1119   propertyMap.Insert( "horizontalAlignment", "CENTER" );
1120   propertyMap.Insert( "verticalAlignment", "CENTER" );
1121   propertyMap.Insert( "textColor", Color::RED );
1122
1123   Property::Map shadowMapSet;
1124   propertyMap.Insert( "shadow", shadowMapSet.Add("color", Color::RED).Add("offset", Vector2(2.0f, 2.0f)).Add("blurRadius", 3.0f) );
1125
1126   Property::Map underlineMapSet;
1127   propertyMap.Insert( "underline", underlineMapSet.Add("enable", "true").Add("color", "green").Add("height", "1") );
1128
1129   Property::Map outlineMapSet;
1130   propertyMap.Insert( "outline", outlineMapSet.Add("color", Color::YELLOW).Add("width", 1) );
1131
1132   Visual::Base textVisual = factory.CreateVisual( propertyMap );
1133
1134   Property::Map resultMap;
1135   textVisual.CreatePropertyMap( resultMap );
1136
1137   //Check values in the result map are identical to the initial map's values.
1138   Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
1139   DALI_TEST_CHECK( value );
1140   DALI_TEST_EQUALS( value->Get<int>(), (int)Visual::TEXT, TEST_LOCATION );
1141
1142   value = resultMap.Find( Visual::Property::MIX_COLOR, Property::VECTOR4 );
1143   DALI_TEST_CHECK( value );
1144   DALI_TEST_EQUALS( value->Get<Vector4>(), Color::BLACK, 0.001f, TEST_LOCATION );
1145
1146   value = resultMap.Find( TextVisual::Property::TEXT, Property::STRING );
1147   DALI_TEST_CHECK( value );
1148   DALI_TEST_EQUALS( value->Get<std::string>(), "Hello world", TEST_LOCATION );
1149
1150   value = resultMap.Find( TextVisual::Property::FONT_FAMILY, Property::STRING );
1151   DALI_TEST_CHECK( value );
1152   DALI_TEST_EQUALS( value->Get<std::string>(), "TizenSans", TEST_LOCATION );
1153
1154   value = resultMap.Find( TextVisual::Property::FONT_STYLE, Property::MAP );
1155   DALI_TEST_CHECK( value );
1156
1157   Property::Map fontStyleMapGet = value->Get<Property::Map>();
1158   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1159   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1160
1161   value = resultMap.Find( TextVisual::Property::POINT_SIZE, Property::FLOAT );
1162   DALI_TEST_CHECK( value );
1163   DALI_TEST_EQUALS( value->Get<float>(), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1164
1165   value = resultMap.Find( TextVisual::Property::MULTI_LINE, Property::BOOLEAN );
1166   DALI_TEST_CHECK( value );
1167   DALI_TEST_CHECK( value->Get<bool>() );
1168
1169   value = resultMap.Find( TextVisual::Property::HORIZONTAL_ALIGNMENT, Property::INTEGER );
1170   DALI_TEST_CHECK( value );
1171   DALI_TEST_EQUALS( value->Get<int>(), (int)Text::HorizontalAlignment::CENTER, TEST_LOCATION );
1172
1173   value = resultMap.Find( TextVisual::Property::VERTICAL_ALIGNMENT, Property::INTEGER );
1174   DALI_TEST_CHECK( value );
1175   DALI_TEST_EQUALS( value->Get<int>(), (int)Text::VerticalAlignment::CENTER, TEST_LOCATION );
1176
1177   value = resultMap.Find( TextVisual::Property::TEXT_COLOR, Property::VECTOR4 );
1178   DALI_TEST_CHECK( value );
1179   DALI_TEST_EQUALS( value->Get<Vector4>(), Color::RED, TEST_LOCATION );
1180
1181   value = resultMap.Find( TextVisual::Property::ENABLE_MARKUP, Property::BOOLEAN );
1182   DALI_TEST_CHECK( value );
1183   DALI_TEST_CHECK( !value->Get<bool>() );
1184
1185   value = resultMap.Find( TextVisual::Property::SHADOW, Property::MAP );
1186   DALI_TEST_CHECK( value );
1187
1188   Property::Map shadowMapGet = value->Get<Property::Map>();
1189   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
1190   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
1191
1192   value = resultMap.Find( TextVisual::Property::UNDERLINE, Property::MAP );
1193   DALI_TEST_CHECK( value );
1194
1195   Property::Map underlineMapGet = value->Get<Property::Map>();
1196   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
1197   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
1198
1199   value = resultMap.Find( DevelTextVisual::Property::OUTLINE, Property::MAP );
1200   DALI_TEST_CHECK( value );
1201
1202   Property::Map outlineMapGet = value->Get<Property::Map>();
1203   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
1204   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
1205
1206   END_TEST;
1207 }
1208
1209 int UtcDaliVisualGetPropertyMap11(void)
1210 {
1211   ToolkitTestApplication application;
1212   tet_infoline( "UtcDaliVisualGetPropertyMap11: AnimatedGradientVisual" );
1213
1214   VisualFactory factory = VisualFactory::Get();
1215   DALI_TEST_CHECK( factory );
1216
1217   Property::Map propertyMap;
1218   propertyMap.Insert(Visual::Property::TYPE,  DevelVisual::ANIMATED_GRADIENT);
1219
1220   Vector2 start(-0.5f, 0.5f);
1221   Vector2 end  (0.5f, -0.0f);
1222   Vector4 start_color(1.0f, 0.7f, 0.5f, 1.0f);
1223   Vector4 end_color  (0.7f, 0.5f, 1.0f, 1.0f);
1224   Vector2 rotate_center(0.0f, 0.4f);
1225   float rotate_amount = 1.57f;
1226   float offset = 100.f;
1227
1228   propertyMap.Insert(DevelAnimatedGradientVisual::Property::GRADIENT_TYPE,  DevelAnimatedGradientVisual::GradientType::RADIAL);
1229   propertyMap.Insert(DevelAnimatedGradientVisual::Property::UNIT_TYPE,  DevelAnimatedGradientVisual::UnitType::USER_SPACE);
1230   propertyMap.Insert(DevelAnimatedGradientVisual::Property::SPREAD_TYPE,  DevelAnimatedGradientVisual::SpreadType::CLAMP);
1231
1232   propertyMap.Insert(DevelAnimatedGradientVisual::Property::START_POSITION,  start);
1233   propertyMap.Insert(DevelAnimatedGradientVisual::Property::END_POSITION,  end);
1234   propertyMap.Insert(DevelAnimatedGradientVisual::Property::START_COLOR,  start_color);
1235   propertyMap.Insert(DevelAnimatedGradientVisual::Property::END_COLOR,  end_color);
1236   propertyMap.Insert(DevelAnimatedGradientVisual::Property::ROTATE_CENTER,  rotate_center);
1237   propertyMap.Insert(DevelAnimatedGradientVisual::Property::ROTATE_AMOUNT,  rotate_amount);
1238   propertyMap.Insert(DevelAnimatedGradientVisual::Property::OFFSET,  offset);
1239
1240   Visual::Base animatedGradientVisual = factory.CreateVisual(propertyMap);
1241   DALI_TEST_CHECK( animatedGradientVisual );
1242
1243   Property::Map resultMap;
1244   animatedGradientVisual.CreatePropertyMap( resultMap );
1245
1246   // check the property values from the returned map from visual
1247   Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE,  Property::INTEGER );
1248   DALI_TEST_CHECK( value );
1249   DALI_TEST_CHECK( value->Get<int>() == DevelVisual::ANIMATED_GRADIENT );
1250
1251   value = resultMap.Find( DevelAnimatedGradientVisual::Property::GRADIENT_TYPE,  Property::INTEGER );
1252   DALI_TEST_CHECK( value );
1253   DALI_TEST_CHECK( value->Get<int>() == DevelAnimatedGradientVisual::GradientType::RADIAL );
1254
1255   value = resultMap.Find( DevelAnimatedGradientVisual::Property::UNIT_TYPE,  Property::INTEGER );
1256   DALI_TEST_CHECK( value );
1257   DALI_TEST_CHECK( value->Get<int>() == DevelAnimatedGradientVisual::UnitType::USER_SPACE );
1258
1259   value = resultMap.Find( DevelAnimatedGradientVisual::Property::SPREAD_TYPE,  Property::INTEGER );
1260   DALI_TEST_CHECK( value );
1261   DALI_TEST_CHECK( value->Get<int>() == DevelAnimatedGradientVisual::SpreadType::CLAMP );
1262
1263
1264   value = resultMap.Find( DevelAnimatedGradientVisual::Property::START_POSITION,  Property::VECTOR2 );
1265   DALI_TEST_CHECK( value );
1266   DALI_TEST_EQUALS( value->Get<Vector2>(), start , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1267
1268   value = resultMap.Find( DevelAnimatedGradientVisual::Property::END_POSITION,  Property::VECTOR2 );
1269   DALI_TEST_CHECK( value );
1270   DALI_TEST_EQUALS( value->Get<Vector2>(), end , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1271
1272   value = resultMap.Find( DevelAnimatedGradientVisual::Property::START_COLOR,  Property::VECTOR4 );
1273   DALI_TEST_CHECK( value );
1274   DALI_TEST_EQUALS( value->Get<Vector4>(), start_color , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1275
1276   value = resultMap.Find( DevelAnimatedGradientVisual::Property::END_COLOR,  Property::VECTOR4 );
1277   DALI_TEST_CHECK( value );
1278   DALI_TEST_EQUALS( value->Get<Vector4>(), end_color , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1279
1280   value = resultMap.Find( DevelAnimatedGradientVisual::Property::ROTATE_CENTER,  Property::VECTOR2 );
1281   DALI_TEST_CHECK( value );
1282   DALI_TEST_EQUALS( value->Get<Vector2>(), rotate_center , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1283
1284   value = resultMap.Find( DevelAnimatedGradientVisual::Property::ROTATE_AMOUNT,  Property::FLOAT );
1285   DALI_TEST_CHECK( value );
1286   DALI_TEST_EQUALS( value->Get<float>(), rotate_amount , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1287
1288   value = resultMap.Find( DevelAnimatedGradientVisual::Property::OFFSET,  Property::FLOAT );
1289   DALI_TEST_CHECK( value );
1290   DALI_TEST_EQUALS( value->Get<float>(), offset , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1291
1292   END_TEST;
1293 }
1294
1295 int UtcDaliVisualGetPropertyMap12(void)
1296 {
1297   ToolkitTestApplication application;
1298   tet_infoline( "UtcDaliVisualGetPropertyMap12: AnimatedGradientVisual with animation param" );
1299
1300   // Case 1 : Set values by index
1301   {
1302     tet_printf( " - Set Values by Index\n" );
1303     // NOTE : PropertyMap doesn't optimized even delay < -loop_count * (duration + repeat_delay) so this animation will not run
1304     // _delay = -10.0f is this case. It will progress (10.0f / 1.5f) amount. and 10.0f / 1.5f > 5.
1305     for(float _delay = -10.0f; _delay <= 5.0f; _delay += 5.0f)
1306     {
1307       tet_printf( "test with delay [%f]\n", _delay );
1308       VisualFactory factory = VisualFactory::Get();
1309       DALI_TEST_CHECK( factory );
1310
1311       Property::Map propertyMap;
1312       Property::Map animationMap;
1313       propertyMap.Insert(Visual::Property::TYPE,  DevelVisual::ANIMATED_GRADIENT);
1314
1315       float duration = 1.1f;
1316       float delay = _delay;
1317       float repeat_delay = 0.4f;
1318
1319       int direction = DevelAnimatedGradientVisual::AnimationParameter::DirectionType::BACKWARD;
1320       int loop_count = 5;
1321       int motion = DevelAnimatedGradientVisual::AnimationParameter::MotionType::MIRROR;
1322       int easing = DevelAnimatedGradientVisual::AnimationParameter::EasingType::OUT;
1323
1324       auto buildAnimatedMap = [&animationMap, &direction, &duration, &delay, &loop_count, &repeat_delay, &motion, &easing](const Property::Value &start, const Property::Value &target)->Property::Map&
1325       {
1326         animationMap.Clear();
1327         animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::START, start);
1328         animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::TARGET, target);
1329         animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::DIRECTION, direction);
1330         animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::DURATION, duration);
1331         animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::DELAY, delay);
1332         animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::REPEAT, loop_count);
1333         animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::REPEAT_DELAY, repeat_delay);
1334         animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::MOTION_TYPE, motion);
1335         animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::EASING_TYPE, easing);
1336
1337         return animationMap;
1338       };
1339
1340       Vector2 start1(-0.5f, 0.5f);
1341       Vector2 end1  (0.5f, -0.5f);
1342       Vector4 start_color1(1.0f, 0.7f, 0.5f, 1.0f);
1343       Vector4 end_color1  (0.7f, 0.5f, 1.0f, 1.0f);
1344       Vector2 rotate_center1(0.0f, 0.4f);
1345       float rotate_amount1 = 0.0f;
1346       float offset1 = 0.f;
1347
1348       Vector2 start2(-0.5f, -0.5f);
1349       Vector2 end2  (0.5f, 0.5f);
1350       Vector4 start_color2(0.0f, 0.1f, 0.8f, 1.0f);
1351       Vector4 end_color2  (0.3f, 1.0f, 0.1f, 0.0f);
1352       Vector2 rotate_center2(0.0f, -0.4f);
1353       float rotate_amount2 = 6.2832f;
1354       float offset2 = 2.f;
1355
1356       propertyMap.Insert(DevelAnimatedGradientVisual::Property::GRADIENT_TYPE,  DevelAnimatedGradientVisual::GradientType::LINEAR);
1357       propertyMap.Insert(DevelAnimatedGradientVisual::Property::UNIT_TYPE,  DevelAnimatedGradientVisual::UnitType::OBJECT_BOUNDING_BOX);
1358       propertyMap.Insert(DevelAnimatedGradientVisual::Property::SPREAD_TYPE,  DevelAnimatedGradientVisual::SpreadType::REPEAT);
1359
1360       propertyMap.Insert(DevelAnimatedGradientVisual::Property::START_POSITION, buildAnimatedMap(start1        , start2        ));
1361       propertyMap.Insert(DevelAnimatedGradientVisual::Property::END_POSITION,   buildAnimatedMap(end1          , end2          ));
1362       propertyMap.Insert(DevelAnimatedGradientVisual::Property::START_COLOR,    buildAnimatedMap(start_color1  , start_color2  ));
1363       propertyMap.Insert(DevelAnimatedGradientVisual::Property::END_COLOR,      buildAnimatedMap(end_color1    , end_color2    ));
1364       propertyMap.Insert(DevelAnimatedGradientVisual::Property::ROTATE_CENTER,  buildAnimatedMap(rotate_center1, rotate_center2));
1365       propertyMap.Insert(DevelAnimatedGradientVisual::Property::ROTATE_AMOUNT,  buildAnimatedMap(rotate_amount1, rotate_amount2));
1366       propertyMap.Insert(DevelAnimatedGradientVisual::Property::OFFSET,         buildAnimatedMap(offset1       , offset2       ));
1367
1368       Visual::Base animatedGradientVisual = factory.CreateVisual(propertyMap);
1369       DALI_TEST_CHECK( animatedGradientVisual );
1370
1371       Property::Map resultMap;
1372       animatedGradientVisual.CreatePropertyMap( resultMap );
1373
1374       // check the property values from the returned map from visual
1375       Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE,  Property::INTEGER );
1376       DALI_TEST_CHECK( value );
1377       DALI_TEST_CHECK( value->Get<int>() == DevelVisual::ANIMATED_GRADIENT );
1378
1379       value = resultMap.Find( DevelAnimatedGradientVisual::Property::GRADIENT_TYPE,  Property::INTEGER );
1380       DALI_TEST_CHECK( value );
1381       DALI_TEST_CHECK( value->Get<int>() == DevelAnimatedGradientVisual::GradientType::LINEAR );
1382
1383       value = resultMap.Find( DevelAnimatedGradientVisual::Property::UNIT_TYPE,  Property::INTEGER );
1384       DALI_TEST_CHECK( value );
1385       DALI_TEST_CHECK( value->Get<int>() == DevelAnimatedGradientVisual::UnitType::OBJECT_BOUNDING_BOX );
1386
1387       value = resultMap.Find( DevelAnimatedGradientVisual::Property::SPREAD_TYPE,  Property::INTEGER );
1388       DALI_TEST_CHECK( value );
1389       DALI_TEST_CHECK( value->Get<int>() == DevelAnimatedGradientVisual::SpreadType::REPEAT );
1390
1391       auto checkAnimatedMap = [&value, &resultMap, &direction, &duration, &delay, &loop_count, &repeat_delay, &motion, &easing](const Property::Index &index, const Property::Value &start, const Property::Value &target, int line_num)->void
1392       {
1393         tet_printf("Check value at %d\n", line_num);
1394         value = resultMap.Find( index, Property::MAP );
1395         DALI_TEST_CHECK( value );
1396         DALI_TEST_CHECK( value->GetType() == Property::MAP );
1397         Property::Map *temp_map = value->GetMap();
1398         DALI_TEST_CHECK( temp_map );
1399
1400         auto checkMapValue = [&temp_map](const Property::Index index)->Property::Value
1401         {
1402           Property::Value *res = temp_map->Find( index );
1403           DALI_TEST_CHECK( res );
1404           return *res;
1405         };
1406
1407         DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::START)       , start, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1408         DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::TARGET)      , target, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1409         DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::DIRECTION)   , Property::Value( direction ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1410         DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::DURATION)    , Property::Value( duration ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1411         DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::DELAY)       , Property::Value( delay ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1412         DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::REPEAT)      , Property::Value( loop_count ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1413         DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::REPEAT_DELAY), Property::Value( repeat_delay ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1414         DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::MOTION_TYPE) , Property::Value( motion ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1415         DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::EASING_TYPE) , Property::Value( easing ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1416       };
1417
1418       // check the animation map data is good
1419       checkAnimatedMap(DevelAnimatedGradientVisual::Property::START_POSITION, start1        , start2        , __LINE__);
1420       checkAnimatedMap(DevelAnimatedGradientVisual::Property::END_POSITION  , end1          , end2          , __LINE__);
1421       checkAnimatedMap(DevelAnimatedGradientVisual::Property::START_COLOR   , start_color1  , start_color2  , __LINE__);
1422       checkAnimatedMap(DevelAnimatedGradientVisual::Property::END_COLOR     , end_color1    , end_color2    , __LINE__);
1423       checkAnimatedMap(DevelAnimatedGradientVisual::Property::ROTATE_CENTER , rotate_center1, rotate_center2, __LINE__);
1424       checkAnimatedMap(DevelAnimatedGradientVisual::Property::ROTATE_AMOUNT , rotate_amount1, rotate_amount2, __LINE__);
1425       checkAnimatedMap(DevelAnimatedGradientVisual::Property::OFFSET        , offset1       , offset2       , __LINE__);
1426     }
1427   }
1428
1429   // Case 2 : Set values by string
1430   {
1431     tet_printf( " - Set Values by String\n" );
1432     // NOTE : PropertyMap doesn't optimized even delay < -loop_count * (duration + repeat_delay) so this animation will not run
1433     // _delay = -10.0f is this case. It will progress (10.0f / 1.5f) amount. and 10.0f / 1.5f > 5.
1434     for(float _delay = -10.0f; _delay <= 5.0f; _delay += 5.0f)
1435     {
1436       tet_printf( "test with delay [%f]\n", _delay );
1437       VisualFactory factory = VisualFactory::Get();
1438       DALI_TEST_CHECK( factory );
1439
1440       Property::Map propertyMap;
1441       Property::Map animationMap;
1442       propertyMap.Insert("visualType", "ANIMATED_GRADIENT");
1443
1444       float duration = 1.1f;
1445       float delay = _delay;
1446       float repeat_delay = 0.4f;
1447
1448       int direction = DevelAnimatedGradientVisual::AnimationParameter::DirectionType::BACKWARD;
1449       int loop_count = 5;
1450       int motion = DevelAnimatedGradientVisual::AnimationParameter::MotionType::MIRROR;
1451       int easing = DevelAnimatedGradientVisual::AnimationParameter::EasingType::IN_OUT;
1452
1453       auto buildAnimatedMap = [&animationMap, &duration, &delay, &loop_count, &repeat_delay](const Property::Value &start, const Property::Value &target)->Property::Map&
1454       {
1455         animationMap.Clear();
1456         animationMap.Insert("startValue"   , start);
1457         animationMap.Insert("targetValue"  , target);
1458         animationMap.Insert("directionType", "BACKWARD");
1459         animationMap.Insert("duration"     , duration);
1460         animationMap.Insert("delay"        , delay);
1461         animationMap.Insert("repeat"       , loop_count);
1462         animationMap.Insert("repeatDelay"  , repeat_delay);
1463         animationMap.Insert("motionType"   , "MIRROR");
1464         animationMap.Insert("easingType"   , "IN_OUT");
1465
1466         return animationMap;
1467       };
1468
1469       Vector2 start1(-0.5f, 0.5f);
1470       Vector2 end1  (0.5f, -0.5f);
1471       Vector4 start_color1(1.0f, 0.7f, 0.5f, 1.0f);
1472       Vector4 end_color1  (0.7f, 0.5f, 1.0f, 1.0f);
1473       Vector2 rotate_center1(0.0f, 0.4f);
1474       float rotate_amount1 = 0.0f;
1475       float offset1 = 0.f;
1476
1477       Vector2 start2(-0.5f, -0.5f);
1478       Vector2 end2  (0.5f, 0.5f);
1479       Vector4 start_color2(0.0f, 0.1f, 0.8f, 1.0f);
1480       Vector4 end_color2  (0.3f, 1.0f, 0.1f, 0.0f);
1481       Vector2 rotate_center2(0.0f, -0.4f);
1482       float rotate_amount2 = 6.2832f;
1483       float offset2 = 2.f;
1484
1485       // For test mix the type string/index key and string/index value works well.
1486       propertyMap.Insert(DevelAnimatedGradientVisual::Property::GRADIENT_TYPE,  "RADIAL");
1487       propertyMap.Insert(DevelAnimatedGradientVisual::Property::UNIT_TYPE,  DevelAnimatedGradientVisual::UnitType::USER_SPACE);
1488       propertyMap.Insert("spreadType"  , DevelAnimatedGradientVisual::SpreadType::REFLECT);
1489
1490       propertyMap.Insert("startPosition", buildAnimatedMap(start1        , start2        ));
1491       propertyMap.Insert("endPosition"  , buildAnimatedMap(end1          , end2          ));
1492       propertyMap.Insert("startColor"   , buildAnimatedMap(start_color1  , start_color2  ));
1493       propertyMap.Insert("endColor"     , buildAnimatedMap(end_color1    , end_color2    ));
1494       propertyMap.Insert("rotateCenter" , buildAnimatedMap(rotate_center1, rotate_center2));
1495       propertyMap.Insert("rotateAmount" , buildAnimatedMap(rotate_amount1, rotate_amount2));
1496       propertyMap.Insert("offset"       , buildAnimatedMap(offset1       , offset2       ));
1497
1498       Visual::Base animatedGradientVisual = factory.CreateVisual(propertyMap);
1499       DALI_TEST_CHECK( animatedGradientVisual );
1500
1501       Property::Map resultMap;
1502       animatedGradientVisual.CreatePropertyMap( resultMap );
1503
1504       // check the property values from the returned map from visual
1505       // Note : resultMap from CreatePropertyMap only contain indexKey
1506       Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE,  Property::INTEGER );
1507       DALI_TEST_CHECK( value );
1508       DALI_TEST_CHECK( value->Get<int>() == DevelVisual::ANIMATED_GRADIENT );
1509
1510       value = resultMap.Find( DevelAnimatedGradientVisual::Property::GRADIENT_TYPE,  Property::INTEGER );
1511       DALI_TEST_CHECK( value );
1512       DALI_TEST_CHECK( value->Get<int>() == DevelAnimatedGradientVisual::GradientType::RADIAL );
1513
1514       value = resultMap.Find( DevelAnimatedGradientVisual::Property::UNIT_TYPE,  Property::INTEGER );
1515       DALI_TEST_CHECK( value );
1516       DALI_TEST_CHECK( value->Get<int>() == DevelAnimatedGradientVisual::UnitType::USER_SPACE );
1517
1518       value = resultMap.Find( DevelAnimatedGradientVisual::Property::SPREAD_TYPE,  Property::INTEGER );
1519       DALI_TEST_CHECK( value );
1520       DALI_TEST_CHECK( value->Get<int>() == DevelAnimatedGradientVisual::SpreadType::REFLECT );
1521
1522       auto checkAnimatedMap = [&value, &resultMap, &direction, &duration, &delay, &loop_count, &repeat_delay, &motion, &easing](const Property::Index &index, const Property::Value &start, const Property::Value &target, int line_num)->void
1523       {
1524         tet_printf("Check value at %d\n", line_num);
1525         value = resultMap.Find( index, Property::MAP );
1526         DALI_TEST_CHECK( value );
1527         DALI_TEST_CHECK( value->GetType() == Property::MAP );
1528         Property::Map *temp_map = value->GetMap();
1529         DALI_TEST_CHECK( temp_map );
1530
1531         auto checkMapValue = [&temp_map](const Property::Index index)->Property::Value
1532         {
1533           Property::Value *res = temp_map->Find( index );
1534           DALI_TEST_CHECK( res );
1535           return *res;
1536         };
1537
1538         DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::START)       , start, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1539         DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::TARGET)      , target, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1540         DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::DIRECTION)   , Property::Value( direction ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1541         DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::DURATION)    , Property::Value( duration ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1542         DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::DELAY)       , Property::Value( delay ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1543         DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::REPEAT)      , Property::Value( loop_count ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1544         DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::REPEAT_DELAY), Property::Value( repeat_delay ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1545         DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::MOTION_TYPE) , Property::Value( motion ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1546         DALI_TEST_EQUALS( checkMapValue(DevelAnimatedGradientVisual::AnimationParameter::Property::EASING_TYPE) , Property::Value( easing ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
1547       };
1548
1549       // check the animation map data is good
1550       checkAnimatedMap(DevelAnimatedGradientVisual::Property::START_POSITION, start1        , start2        , __LINE__);
1551       checkAnimatedMap(DevelAnimatedGradientVisual::Property::END_POSITION  , end1          , end2          , __LINE__);
1552       checkAnimatedMap(DevelAnimatedGradientVisual::Property::START_COLOR   , start_color1  , start_color2  , __LINE__);
1553       checkAnimatedMap(DevelAnimatedGradientVisual::Property::END_COLOR     , end_color1    , end_color2    , __LINE__);
1554       checkAnimatedMap(DevelAnimatedGradientVisual::Property::ROTATE_CENTER , rotate_center1, rotate_center2, __LINE__);
1555       checkAnimatedMap(DevelAnimatedGradientVisual::Property::ROTATE_AMOUNT , rotate_amount1, rotate_amount2, __LINE__);
1556       checkAnimatedMap(DevelAnimatedGradientVisual::Property::OFFSET        , offset1       , offset2       , __LINE__);
1557     }
1558   }
1559
1560   END_TEST;
1561 }
1562 int UtcDaliVisualGetPropertyMap13(void)
1563 {
1564   ToolkitTestApplication application;
1565   tet_infoline( "UtcDaliVisualGetPropertyMap13: AnimatedGradientVisual when repeat = 0" );
1566
1567   for(int _direction = 0; _direction <= 1; ++_direction)
1568   {
1569     for(float _delay = -10.0f; _delay <= 10.0f; _delay += 10.0f)
1570     {
1571       tet_printf( ((_direction == 0) ? "Forward test with delay [%f]\n" : "Backward test with delay [%f]\n") , _delay );
1572       VisualFactory factory = VisualFactory::Get();
1573       DALI_TEST_CHECK( factory );
1574
1575       Property::Map propertyMap;
1576       Property::Map animationMap;
1577       propertyMap.Insert(Visual::Property::TYPE,  DevelVisual::ANIMATED_GRADIENT);
1578
1579       float duration = 1.0f;
1580       float delay = _delay;
1581       float repeat_delay = 0.5f;
1582
1583       int direction = _direction;
1584       int loop_count = 0; // When loop_count is 0, Animation will not be created.
1585       int motion = DevelAnimatedGradientVisual::AnimationParameter::MotionType::LOOP;
1586       int easing = DevelAnimatedGradientVisual::AnimationParameter::EasingType::IN;
1587
1588       auto buildAnimatedMap = [&animationMap, &direction, &duration, &delay, &loop_count, &repeat_delay, &motion, &easing](const Property::Value &start, const Property::Value &target)->Property::Map&
1589       {
1590         animationMap.Clear();
1591         animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::START, start);
1592         animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::TARGET, target);
1593         if(direction == 0)animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::DIRECTION, DevelAnimatedGradientVisual::AnimationParameter::DirectionType::FORWARD);
1594         else animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::DIRECTION, DevelAnimatedGradientVisual::AnimationParameter::DirectionType::BACKWARD);
1595         animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::DIRECTION, direction);
1596         animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::DURATION, duration);
1597         animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::DELAY, delay);
1598         animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::REPEAT, loop_count);
1599         animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::REPEAT_DELAY, repeat_delay);
1600         animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::MOTION_TYPE, motion);
1601         animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::EASING_TYPE, easing);
1602
1603         return animationMap;
1604       };
1605
1606       Vector2 start1(-0.5f, 0.5f);
1607       Vector2 end1  (0.5f, -0.5f);
1608       Vector4 start_color1(1.0f, 0.7f, 0.5f, 1.0f);
1609       Vector4 end_color1  (0.7f, 0.5f, 1.0f, 1.0f);
1610       Vector2 rotate_center1(1.0f, 0.4f);
1611       float rotate_amount1 = 2.0f;
1612       float offset1 = 1.f;
1613
1614       Vector2 start2(-0.5f, -0.5f);
1615       Vector2 end2  (0.5f, 0.5f);
1616       Vector4 start_color2(0.0f, 0.1f, 0.8f, 1.0f);
1617       Vector4 end_color2  (0.3f, 1.0f, 0.1f, 0.0f);
1618       Vector2 rotate_center2(1.0f, -0.4f);
1619       float rotate_amount2 = 1.0f;
1620       float offset2 = 3.f;
1621
1622       propertyMap.Insert(DevelAnimatedGradientVisual::Property::GRADIENT_TYPE,  DevelAnimatedGradientVisual::GradientType::LINEAR);
1623       propertyMap.Insert(DevelAnimatedGradientVisual::Property::UNIT_TYPE,  DevelAnimatedGradientVisual::UnitType::OBJECT_BOUNDING_BOX);
1624       propertyMap.Insert(DevelAnimatedGradientVisual::Property::SPREAD_TYPE,  DevelAnimatedGradientVisual::SpreadType::REFLECT);
1625
1626       propertyMap.Insert(DevelAnimatedGradientVisual::Property::START_POSITION, buildAnimatedMap(start1        , start2        ));
1627       propertyMap.Insert(DevelAnimatedGradientVisual::Property::END_POSITION,   buildAnimatedMap(end1          , end2          ));
1628       propertyMap.Insert(DevelAnimatedGradientVisual::Property::START_COLOR,    buildAnimatedMap(start_color1  , start_color2  ));
1629       propertyMap.Insert(DevelAnimatedGradientVisual::Property::END_COLOR,      buildAnimatedMap(end_color1    , end_color2    ));
1630       propertyMap.Insert(DevelAnimatedGradientVisual::Property::ROTATE_CENTER,  buildAnimatedMap(rotate_center1, rotate_center2));
1631       propertyMap.Insert(DevelAnimatedGradientVisual::Property::ROTATE_AMOUNT,  buildAnimatedMap(rotate_amount1, rotate_amount2));
1632       propertyMap.Insert(DevelAnimatedGradientVisual::Property::OFFSET,         buildAnimatedMap(offset1       , offset2       ));
1633
1634       Visual::Base animatedGradientVisual = factory.CreateVisual(propertyMap);
1635       DALI_TEST_CHECK( animatedGradientVisual );
1636
1637       Property::Map resultMap;
1638       animatedGradientVisual.CreatePropertyMap( resultMap );
1639
1640       // check the property values from the returned map from visual
1641       Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE,  Property::INTEGER );
1642       DALI_TEST_CHECK( value );
1643       DALI_TEST_CHECK( value->Get<int>() == DevelVisual::ANIMATED_GRADIENT );
1644
1645       value = resultMap.Find( DevelAnimatedGradientVisual::Property::GRADIENT_TYPE,  Property::INTEGER );
1646       DALI_TEST_CHECK( value );
1647       DALI_TEST_CHECK( value->Get<int>() == DevelAnimatedGradientVisual::GradientType::LINEAR );
1648
1649       value = resultMap.Find( DevelAnimatedGradientVisual::Property::UNIT_TYPE,  Property::INTEGER );
1650       DALI_TEST_CHECK( value );
1651       DALI_TEST_CHECK( value->Get<int>() == DevelAnimatedGradientVisual::UnitType::OBJECT_BOUNDING_BOX );
1652
1653       value = resultMap.Find( DevelAnimatedGradientVisual::Property::SPREAD_TYPE,  Property::INTEGER );
1654       DALI_TEST_CHECK( value );
1655       DALI_TEST_CHECK( value->Get<int>() == DevelAnimatedGradientVisual::SpreadType::REFLECT );
1656
1657       // If loop_count = 0, Animation doesn't created.
1658       // Optimized resultMap only have one value, which is target value
1659       // Note: target value will be changed by direction option.
1660       value = resultMap.Find( DevelAnimatedGradientVisual::Property::START_POSITION,  Property::VECTOR2 );
1661       DALI_TEST_CHECK( value );
1662       DALI_TEST_EQUALS( value->Get<Vector2>(), direction ? start1 : start2 , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1663
1664       value = resultMap.Find( DevelAnimatedGradientVisual::Property::END_POSITION,  Property::VECTOR2 );
1665       DALI_TEST_CHECK( value );
1666       DALI_TEST_EQUALS( value->Get<Vector2>(), direction ? end1 : end2 , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1667
1668       value = resultMap.Find( DevelAnimatedGradientVisual::Property::START_COLOR,  Property::VECTOR4 );
1669       DALI_TEST_CHECK( value );
1670       DALI_TEST_EQUALS( value->Get<Vector4>(), direction ? start_color1 : start_color2 , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1671
1672       value = resultMap.Find( DevelAnimatedGradientVisual::Property::END_COLOR,  Property::VECTOR4 );
1673       DALI_TEST_CHECK( value );
1674       DALI_TEST_EQUALS( value->Get<Vector4>(), direction ? end_color1 : end_color2 , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1675
1676       value = resultMap.Find( DevelAnimatedGradientVisual::Property::ROTATE_CENTER,  Property::VECTOR2 );
1677       DALI_TEST_CHECK( value );
1678       DALI_TEST_EQUALS( value->Get<Vector2>(), direction ? rotate_center1 : rotate_center2 , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1679
1680       value = resultMap.Find( DevelAnimatedGradientVisual::Property::ROTATE_AMOUNT,  Property::FLOAT );
1681       DALI_TEST_CHECK( value );
1682       DALI_TEST_EQUALS( value->Get<float>(), direction ? rotate_amount1 : rotate_amount2 , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1683
1684       value = resultMap.Find( DevelAnimatedGradientVisual::Property::OFFSET,  Property::FLOAT );
1685       DALI_TEST_CHECK( value );
1686       DALI_TEST_EQUALS( value->Get<float>(), direction ? offset1 : offset2 , Math::MACHINE_EPSILON_100, TEST_LOCATION );
1687     }
1688   }
1689
1690   END_TEST;
1691 }
1692
1693 int UtcDaliVisualAnimateBorderVisual01(void)
1694 {
1695   ToolkitTestApplication application;
1696   tet_infoline( "UtcDaliAnimateBorderVisual Color" );
1697
1698   VisualFactory factory = VisualFactory::Get();
1699   Property::Map propertyMap;
1700   propertyMap.Insert(Visual::Property::TYPE,  Visual::BORDER);
1701   propertyMap.Insert(Visual::Property::MIX_COLOR, Vector4(1, 1, 1, 0.8f));
1702   propertyMap.Insert(BorderVisual::Property::COLOR,  Color::BLUE);
1703   propertyMap.Insert(BorderVisual::Property::SIZE,  5.f);
1704   Visual::Base borderVisual = factory.CreateVisual( propertyMap );
1705
1706   Property::Map map;
1707   map["target"] = "testVisual";
1708   map["property"] = "mixColor";
1709   map["targetValue"] = Vector4(1,1,1,0);
1710   map["animator"] = Property::Map()
1711     .Add("alphaFunction", "LINEAR")
1712     .Add("timePeriod", Property::Map()
1713          .Add("delay", 0.0f)
1714          .Add("duration", 4.0f));
1715
1716   Dali::Toolkit::TransitionData transition = TransitionData::New( map );
1717
1718   DummyControl actor = DummyControl::New(true);
1719   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1720   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, borderVisual );
1721   actor.SetSize(2000, 2000);
1722   actor.SetParentOrigin(ParentOrigin::CENTER);
1723   Stage::GetCurrent().Add(actor);
1724
1725   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
1726
1727   Renderer renderer = actor.GetRendererAt(0);
1728   Property::Index borderColorIndex = DevelHandle::GetPropertyIndex( renderer, BorderVisual::Property::COLOR );
1729   Property::Index mixColorIndex = DevelHandle::GetPropertyIndex( renderer, Visual::Property::MIX_COLOR );
1730
1731   Animation animation = dummyImpl.CreateTransition( transition );
1732
1733   // Animate the mix color through the transition, and the border color through
1734   // programmatic method.
1735   animation.AnimateTo( Property(renderer, borderColorIndex), Color::WHITE );
1736   animation.Play();
1737
1738   application.SendNotification();
1739   application.Render(0);
1740   application.Render(2000u); // halfway point between blue and white
1741
1742   Vector4 color = renderer.GetCurrentProperty< Vector4 >( borderColorIndex );
1743   Vector4 testColor = (Color::BLUE + Color::WHITE)*0.5f;
1744   DALI_TEST_EQUALS( color, testColor, TEST_LOCATION );
1745   DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("borderColor", testColor ), true, TEST_LOCATION );
1746
1747   color = renderer.GetCurrentProperty< Vector3 >( mixColorIndex );
1748   testColor = Vector4( 1,1,1,0.4f );
1749   DALI_TEST_EQUALS( Vector3(color), Vector3(testColor), 0.0001f, TEST_LOCATION );
1750   DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", Vector3(testColor) ), true, TEST_LOCATION );
1751   DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<float>("opacity", testColor.a ) , true, TEST_LOCATION );
1752
1753   application.Render(2000u);
1754
1755   color = renderer.GetCurrentProperty< Vector4 >( borderColorIndex );
1756   DALI_TEST_EQUALS( color, Color::WHITE, TEST_LOCATION );
1757   DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("borderColor", Color::WHITE ), true, TEST_LOCATION );
1758
1759   color = renderer.GetCurrentProperty< Vector4 >( mixColorIndex );
1760   testColor = Vector4(1,1,1,0);
1761   DALI_TEST_EQUALS( color, testColor, TEST_LOCATION );
1762   DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", Vector3(testColor) ), true, TEST_LOCATION );
1763   DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<float>("opacity", testColor.a ), true, TEST_LOCATION );
1764
1765   END_TEST;
1766 }
1767
1768
1769 int UtcDaliVisualAnimateBorderVisual02(void)
1770 {
1771   ToolkitTestApplication application;
1772   tet_infoline( "UtcDaliAnimateBorderVisual Size" );
1773
1774   VisualFactory factory = VisualFactory::Get();
1775   Property::Map propertyMap;
1776   propertyMap.Insert(Visual::Property::TYPE,  Visual::BORDER);
1777   propertyMap.Insert(BorderVisual::Property::COLOR,  Color::BLUE);
1778   propertyMap.Insert(BorderVisual::Property::SIZE,  5.f);
1779   Visual::Base borderVisual = factory.CreateVisual( propertyMap );
1780
1781   DummyControl actor = DummyControl::New(true);
1782   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1783   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, borderVisual );
1784   actor.SetSize(2000, 2000);
1785   actor.SetParentOrigin(ParentOrigin::CENTER);
1786   Stage::GetCurrent().Add(actor);
1787
1788   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
1789
1790   Renderer renderer = actor.GetRendererAt(0);
1791   Property::Index index = DevelHandle::GetPropertyIndex( renderer, BorderVisual::Property::SIZE );
1792
1793   Animation animation = Animation::New(4.0f);
1794   animation.AnimateTo( Property(renderer, index), 9.0f );
1795   animation.Play();
1796
1797   application.SendNotification();
1798   application.Render(0);
1799   application.Render(2000u); // halfway point
1800
1801   float size = renderer.GetCurrentProperty< float >( index );
1802   DALI_TEST_EQUALS( size, 7.0f, 0.0001f, TEST_LOCATION );
1803   DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<float>("borderSize", 7.0f ), true, TEST_LOCATION );
1804
1805   application.Render(2000u); // halfway point between blue and white
1806
1807   size = renderer.GetCurrentProperty< float >( index );
1808   DALI_TEST_EQUALS( size, 9.0f, 0.0001f, TEST_LOCATION );
1809   DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<float>("borderSize", 9.0f ), true, TEST_LOCATION );
1810
1811   END_TEST;
1812 }
1813
1814 int UtcDaliVisualAnimateColorVisual(void)
1815 {
1816   ToolkitTestApplication application;
1817   tet_infoline( "UtcDaliAnimateColorVisual mixColor" );
1818
1819   VisualFactory factory = VisualFactory::Get();
1820   Property::Map propertyMap;
1821   propertyMap.Insert(Visual::Property::TYPE,  Visual::COLOR);
1822   propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
1823   Visual::Base borderVisual = factory.CreateVisual( propertyMap );
1824
1825   DummyControl actor = DummyControl::New(true);
1826   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1827   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, borderVisual );
1828   actor.SetSize(2000, 2000);
1829   actor.SetParentOrigin(ParentOrigin::CENTER);
1830   Stage::GetCurrent().Add(actor);
1831
1832   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
1833
1834   Renderer renderer = actor.GetRendererAt(0);
1835   Property::Index mixColorIndex = DevelHandle::GetPropertyIndex( renderer, ColorVisual::Property::MIX_COLOR );
1836
1837   Property::Value blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
1838   DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::AUTO, TEST_LOCATION );
1839
1840   Animation animation = Animation::New(4.0f);
1841   animation.AnimateTo( Property(renderer, mixColorIndex), Vector3(Color::WHITE) );
1842   animation.Play();
1843
1844   application.SendNotification();
1845   application.Render(0);
1846   application.Render(2000u); // halfway point
1847
1848   Vector3 color = renderer.GetCurrentProperty< Vector3 >( mixColorIndex );
1849   Vector3 testColor = Vector3(Color::BLUE + Color::WHITE)*0.5f;
1850   DALI_TEST_EQUALS( color, testColor, TEST_LOCATION );
1851
1852   DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", testColor ), true, TEST_LOCATION );
1853
1854   application.Render(2000u); // halfway point between blue and white
1855
1856   color = renderer.GetCurrentProperty< Vector3 >( mixColorIndex );
1857   DALI_TEST_EQUALS( color, Vector3(Color::WHITE), TEST_LOCATION );
1858
1859   DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", Vector3(Color::WHITE) ), true, TEST_LOCATION );
1860
1861   blendModeValue = renderer.GetCurrentProperty( Renderer::Property::BLEND_MODE );
1862   DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::AUTO, TEST_LOCATION );
1863
1864   END_TEST;
1865 }
1866
1867 int UtcDaliVisualAnimatePrimitiveVisual(void)
1868 {
1869   ToolkitTestApplication application;
1870   tet_infoline( "UtcDaliAnimatePrimitiveVisual color" );
1871
1872   {
1873     VisualFactory factory = VisualFactory::Get();
1874     Property::Map propertyMap;
1875     propertyMap.Insert(Visual::Property::TYPE,  Visual::PRIMITIVE);
1876     propertyMap.Insert(PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE);
1877     propertyMap.Insert(PrimitiveVisual::Property::MIX_COLOR, Color::BLUE);
1878     Visual::Base visual = factory.CreateVisual( propertyMap );
1879
1880     DummyControl actor = DummyControl::New(true);
1881     Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1882     dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
1883     actor.SetSize(2000, 2000);
1884     actor.SetParentOrigin(ParentOrigin::CENTER);
1885     actor.SetColor(Color::BLACK);
1886     Stage::GetCurrent().Add(actor);
1887
1888     DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
1889
1890     Renderer renderer = actor.GetRendererAt(0);
1891     Property::Index index = DevelHandle::GetPropertyIndex( renderer, PrimitiveVisual::Property::MIX_COLOR );
1892
1893     tet_infoline("Test that the renderer has the Primitive mix color");
1894     DALI_TEST_CHECK( index != Property::INVALID_INDEX );
1895
1896     const Vector4 INITIAL_MIX_COLOR( 1.0f,0.0f,1.0f,0.5f ); // Magenta with half alpha
1897     const Vector4 TARGET_MIX_COLOR( Color::RED );
1898
1899     Property::Map map;
1900     map["target"] = "testVisual";
1901     map["property"] = "mixColor";
1902     map["initialValue"] = INITIAL_MIX_COLOR;
1903     map["targetValue"] = TARGET_MIX_COLOR;
1904     map["animator"] = Property::Map()
1905       .Add("alphaFunction", "LINEAR")
1906       .Add("timePeriod", Property::Map()
1907            .Add("delay", 0.0f)
1908            .Add("duration", 4.0f));
1909
1910     Dali::Toolkit::TransitionData transition = TransitionData::New( map );
1911
1912     Animation animation = dummyImpl.CreateTransition( transition );
1913     Property::Value blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
1914     DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::ON, TEST_LOCATION );
1915
1916     animation.AnimateTo( Property(actor, Actor::Property::COLOR), Color::WHITE );
1917     animation.Play();
1918
1919     application.SendNotification();
1920     application.Render(0);
1921     application.Render(2000u); // halfway point
1922     application.SendNotification();
1923
1924     DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("uColor", Vector4(0.5f, 0.5f, 0.5f, 1.0f )), true, TEST_LOCATION );
1925
1926     Vector4 halfwayColor = (INITIAL_MIX_COLOR + TARGET_MIX_COLOR)*0.5;
1927     DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", Vector3(halfwayColor) ), true, TEST_LOCATION );
1928     DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<float>("opacity", halfwayColor.a ), true, TEST_LOCATION );
1929
1930     application.Render(2001u); // go past end
1931     application.SendNotification(); // Trigger signals
1932
1933     DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
1934     DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("uColor", Color::WHITE ), true, TEST_LOCATION );
1935     DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", Vector3(TARGET_MIX_COLOR) ), true, TEST_LOCATION );
1936     DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<float>("opacity", TARGET_MIX_COLOR.a ), true, TEST_LOCATION );
1937
1938     blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
1939     DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::AUTO, TEST_LOCATION );
1940
1941     actor.Unparent();
1942   }
1943
1944   END_TEST;
1945 }
1946
1947 int UtcDaliVisualAnimatedGradientVisual01(void)
1948 {
1949   ToolkitTestApplication application;
1950   tet_infoline( "UtcDaliAnimatedGradientVisual with default" );
1951
1952   {
1953     VisualFactory factory = VisualFactory::Get();
1954     Property::Map propertyMap;
1955     propertyMap.Insert(Visual::Property::TYPE,  DevelVisual::ANIMATED_GRADIENT);
1956     Visual::Base visual = factory.CreateVisual( propertyMap );
1957
1958     DummyControl actor = DummyControl::New(true);
1959     Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1960     dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
1961     actor.SetSize(2000, 2000);
1962     actor.SetParentOrigin(ParentOrigin::CENTER);
1963     actor.SetColor(Color::BLACK);
1964     Stage::GetCurrent().Add(actor);
1965
1966     application.SendNotification();
1967     application.Render(0);
1968     application.SendNotification();
1969
1970     DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
1971
1972     for(int step_iter = 0; step_iter < 3; step_iter++)
1973     {
1974       application.SendNotification();
1975       application.Render(0);
1976       application.Render(750u); // step i/4
1977       application.SendNotification();
1978
1979       DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector2>( "start_point"  , Vector2( -0.5f, 0.0f ) ), true, TEST_LOCATION );
1980       DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector2>( "end_point"    , Vector2( 0.5f, 0.0f ) ), true, TEST_LOCATION );
1981       DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>( "start_color"  , Vector4( 143.0f, 170.0f, 220.0f, 255.0f ) / 255.0f ), true, TEST_LOCATION );
1982       DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>( "end_color"    , Vector4( 255.0f, 163.0f, 163.0f, 255.0f ) / 255.0f ), true, TEST_LOCATION );
1983       DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector2>( "rotate_center", Vector2( 0.0f, 0.0f ) ), true, TEST_LOCATION );
1984       DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<float>( "rotate_angle"   , 0.0f ), true, TEST_LOCATION );
1985       DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<float>( "gradient_offset", 0.5f * step_iter + 0.5f ), true, TEST_LOCATION );
1986     }
1987
1988     //Not check here. cause gradient_offset value can be 2.0f or 0.0f
1989     application.Render(750u); // go to end
1990     application.SendNotification();
1991
1992     application.Render(10u); // finish
1993     application.SendNotification();
1994
1995     actor.Unparent();
1996     application.SendNotification();
1997     application.Render(0u);
1998     application.SendNotification();
1999   }
2000
2001   END_TEST;
2002 }
2003
2004 int UtcDaliVisualAnimatedGradientVisual02(void)
2005 {
2006   ToolkitTestApplication application;
2007   tet_infoline( "UtcDaliAnimatedGradientVisual with full-option" );
2008
2009   {
2010     float _delay[4] = {0.0f, -1.35f, 0.15f, -0.4f}; // fract(_delay) must NOT be 1/4, 2/4, 3/4. cause we don't know progress is 1.0f or 0.0f
2011     int _direction[2] = {0, 1};
2012     int _loop_count[3] = {-1, 0, 1};
2013     int _motion[2] = {0, 1};
2014     int _easing[4] = {0, 1, 2, 3};
2015
2016     int test_case_max = 4 * 2 * 3 * 2 * 4;
2017     int test_case = 0;
2018     int test_case_d = 7; // 7 is the number of animated properties.
2019
2020     float _duration = 0.4f;
2021     float _repeat_delay = _duration * 0.25f; // < _duration. cause real_duration = _duration - _repeat_delay;
2022     float noise_maker = 0.0f;
2023     // total testing time = ceil((4*2*3*2*4) / 7) * (_duration(=0.4) * 2 + 0.01) = 22.68 seconds
2024     for( test_case = 0; test_case < test_case_max + test_case_d; test_case += test_case_d )
2025     {
2026       tet_printf( "test [%d ~ %d / %d]\n" , test_case, test_case + test_case_d - 1, test_case_max);
2027
2028       VisualFactory factory = VisualFactory::Get();
2029       Property::Map propertyMap;
2030       Property::Map animationMap;
2031       propertyMap.Insert(Visual::Property::TYPE,  DevelVisual::ANIMATED_GRADIENT);
2032
2033       int gradient_type = DevelAnimatedGradientVisual::GradientType::LINEAR;
2034       int unit_type = DevelAnimatedGradientVisual::UnitType::USER_SPACE;
2035       int spread_type = DevelAnimatedGradientVisual::SpreadType::REPEAT;
2036
2037       auto buildAnimatedMap = [&animationMap, &_direction, &_duration, &_delay, &_loop_count, &_repeat_delay, &_motion, &_easing, &test_case](const Property::Value &start, const Property::Value &target, int tc_offset)->Property::Map&
2038       {
2039         int tc = (test_case + tc_offset);
2040         int idx_easing = tc % 4; tc /= 4;
2041         int idx_motion = tc % 2; tc /= 2;
2042         int idx_loop_count = tc % 3; tc /= 3;
2043         int idx_direction = tc % 2; tc /= 2;
2044         int idx_delay = tc % 4; tc /= 4;
2045
2046         float duration = _duration - _repeat_delay;
2047         float repeat_delay = _repeat_delay;
2048         float delay = _delay[idx_delay] * _duration;
2049         int direction = _direction[idx_direction];
2050         int loop_count = _loop_count[idx_loop_count];
2051         int motion = _motion[idx_motion];
2052         int easing = _easing[idx_easing];
2053
2054         animationMap.Clear();
2055         animationMap.Insert( DevelAnimatedGradientVisual::AnimationParameter::Property::START, start );
2056         animationMap.Insert( DevelAnimatedGradientVisual::AnimationParameter::Property::TARGET, target );
2057         if( direction == 0 )
2058         {
2059           animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::DIRECTION, DevelAnimatedGradientVisual::AnimationParameter::DirectionType::FORWARD);
2060         }
2061         else
2062         {
2063           animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::DIRECTION, DevelAnimatedGradientVisual::AnimationParameter::DirectionType::BACKWARD);
2064         }
2065         animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::DURATION, duration);
2066         animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::DELAY, delay);
2067         animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::REPEAT, loop_count);
2068         animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::REPEAT_DELAY, repeat_delay);
2069         if( motion == 0 )
2070         {
2071           animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::MOTION_TYPE, DevelAnimatedGradientVisual::AnimationParameter::MotionType::LOOP);
2072         }
2073         else
2074         {
2075           animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::MOTION_TYPE, DevelAnimatedGradientVisual::AnimationParameter::MotionType::MIRROR);
2076         }
2077         if( easing == 0 )
2078         {
2079           animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::EASING_TYPE, DevelAnimatedGradientVisual::AnimationParameter::EasingType::LINEAR);
2080         }
2081         else if( easing == 1 )
2082         {
2083           animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::EASING_TYPE, DevelAnimatedGradientVisual::AnimationParameter::EasingType::IN);
2084         }
2085         else if( easing == 2 )
2086         {
2087           animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::EASING_TYPE, DevelAnimatedGradientVisual::AnimationParameter::EasingType::OUT);
2088         }
2089         else
2090         {
2091           animationMap.Insert(DevelAnimatedGradientVisual::AnimationParameter::Property::EASING_TYPE, DevelAnimatedGradientVisual::AnimationParameter::EasingType::IN_OUT);
2092         }
2093
2094         return animationMap;
2095       };
2096
2097       // Give different values for debuging
2098       noise_maker += 1.0f;
2099       Vector2 start1(-0.5f + noise_maker * 0.1f, 0.5f + noise_maker * 0.1f);
2100       Vector2 end1  (0.5f + noise_maker * 0.1f, -0.5f + noise_maker * 0.1f);
2101       Vector4 start_color1(1.0f, 0.7f, 0.5f, 1.0f);
2102       Vector4 end_color1  (0.7f, 0.5f, 1.0f, 1.0f);
2103       Vector2 rotate_center1(0.0f + noise_maker * 0.1f, 0.4f + noise_maker * 0.1f);
2104       float rotate_amount1 = 0.0f + noise_maker * 0.1f;
2105       float offset1 = 0.f + noise_maker * 0.1f;
2106
2107       Vector2 start2(0.2f + noise_maker * 0.1f, -0.7f + noise_maker * 0.1f);
2108       Vector2 end2  (0.5f + noise_maker * 0.1f, 0.5f + noise_maker * 0.1f);
2109       Vector4 start_color2(0.0f, 0.1f, 0.8f, 1.0f);
2110       Vector4 end_color2  (0.3f, 1.0f, 0.1f, 0.0f);
2111       Vector2 rotate_center2(0.0f + noise_maker * 0.1f, -0.4f + noise_maker * 0.1f);
2112       float rotate_amount2 = 7.0f + noise_maker * 0.1f;
2113       float offset2 = 2.f + noise_maker * 0.1f;
2114
2115       propertyMap.Insert(DevelAnimatedGradientVisual::Property::GRADIENT_TYPE, gradient_type);
2116       propertyMap.Insert(DevelAnimatedGradientVisual::Property::UNIT_TYPE,     unit_type);
2117       propertyMap.Insert(DevelAnimatedGradientVisual::Property::SPREAD_TYPE,   spread_type);
2118
2119       propertyMap.Insert(DevelAnimatedGradientVisual::Property::START_POSITION, buildAnimatedMap(start1        , start2        ,0));
2120       propertyMap.Insert(DevelAnimatedGradientVisual::Property::END_POSITION,   buildAnimatedMap(end1          , end2          ,1));
2121       propertyMap.Insert(DevelAnimatedGradientVisual::Property::START_COLOR,    buildAnimatedMap(start_color1  , start_color2  ,2));
2122       propertyMap.Insert(DevelAnimatedGradientVisual::Property::END_COLOR,      buildAnimatedMap(end_color1    , end_color2    ,3));
2123       propertyMap.Insert(DevelAnimatedGradientVisual::Property::ROTATE_CENTER,  buildAnimatedMap(rotate_center1, rotate_center2,4));
2124       propertyMap.Insert(DevelAnimatedGradientVisual::Property::ROTATE_AMOUNT,  buildAnimatedMap(rotate_amount1, rotate_amount2,5));
2125       propertyMap.Insert(DevelAnimatedGradientVisual::Property::OFFSET,         buildAnimatedMap(offset1       , offset2       ,6));
2126
2127       Visual::Base visual = factory.CreateVisual( propertyMap );
2128
2129       DummyControl actor = DummyControl::New( true );
2130       Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>( actor.GetImplementation() );
2131       dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
2132       actor.SetSize( 2000, 2000 );
2133       actor.SetParentOrigin(ParentOrigin::CENTER);
2134       actor.SetColor(Color::BLACK);
2135       Stage::GetCurrent().Add(actor);
2136
2137       application.SendNotification();
2138       application.Render( 0 );
2139       application.SendNotification();
2140
2141       DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
2142
2143       application.SendNotification();
2144
2145       //Compare between CPU calculated value and Shader Visual calculated value
2146       auto testProperty = [&application, &_direction, &_duration, &_delay, &_loop_count, &_repeat_delay, &_motion, &_easing, &test_case](const char* name, const Property::Value& start, const Property::Value& target, int tc_offset, int value_type, float progress)->void
2147       {
2148         int tc = (test_case + tc_offset);
2149         int idx_easing = tc % 4; tc /= 4;
2150         int idx_motion = tc % 2; tc /= 2;
2151         int idx_loop_count = tc % 3; tc /= 3;
2152         int idx_direction = tc % 2; tc /= 2;
2153         int idx_delay = tc % 4; tc /= 4;
2154
2155         float duration = _duration - _repeat_delay;
2156         float repeat_delay = _repeat_delay;
2157         float delay = _delay[idx_delay] * _duration;
2158         int direction = _direction[idx_direction];
2159         int loop_count = _loop_count[idx_loop_count];
2160         int motion = _motion[idx_motion];
2161         int easing = _easing[idx_easing];
2162
2163         progress -= delay / _duration;
2164
2165         Property::Value s = start;
2166         Property::Value t = target;
2167         if( direction == 1 )
2168         {
2169           s = target;
2170           t = start;
2171         }
2172         float x; ///< Animator progress value
2173         if( loop_count == 0 )
2174         {
2175           x = 1.0f;
2176         }
2177         else if( loop_count > 0 && progress + 0.01f > loop_count )
2178         {
2179           x = ( motion == 0 ) ? 1.0f : 0.0f;
2180         }
2181         else
2182         {
2183           if( progress < 0.0f )
2184           {
2185             progress = 0.0f;
2186           }
2187           progress = fmodf( progress, 1.0f );
2188           progress = Dali::Clamp( (progress * (duration + repeat_delay) - repeat_delay) / duration, 0.0f, 1.0f );
2189
2190           x = progress;
2191           if( motion == 1 )
2192           {
2193             x = progress * 2.0f;
2194             if( x > 1.0f )
2195             {
2196               x = 2.0f - x;
2197             }
2198           }
2199
2200           if( easing == 1 ) // EASE_IN
2201           {
2202             x = x*x;
2203           }
2204           else if( easing == 2 ) // EASE_OUT
2205           {
2206             x = 2.0f*x - x*x;
2207           }
2208           else if( easing == 3 ) // EASE_IN_OUT
2209           {
2210             x = x * x * (3.0f - 2.0f * x);
2211           }
2212         }
2213         if( value_type == 0 ) // result type is Float
2214         {
2215           float res;
2216           float cur;
2217           res = s.Get<float>() * (1.0f - x) + t.Get<float>() * (x);
2218           DALI_TEST_EQUALS( application.GetGlAbstraction().GetUniformValue<float>(name, cur), true, TEST_LOCATION );
2219           DALI_TEST_EQUALS( res, cur, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2220         }
2221         else if( value_type == 1 ) // result type is Vector2
2222         {
2223           Vector2 res;
2224           Vector2 cur;
2225           res = s.Get<Vector2>() * (1.0f - x) + t.Get<Vector2>() * (x);
2226           DALI_TEST_EQUALS( application.GetGlAbstraction().GetUniformValue<Vector2>(name, cur), true, TEST_LOCATION );
2227           DALI_TEST_EQUALS( res, cur, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2228         }
2229         else if( value_type == 2 ) // result type is Vector3
2230         {
2231           Vector3 res;
2232           Vector3 cur;
2233           res = s.Get<Vector3>() * (1.0f - x) + t.Get<Vector3>() * (x);
2234           DALI_TEST_EQUALS( application.GetGlAbstraction().GetUniformValue<Vector3>(name, cur), true, TEST_LOCATION );
2235           DALI_TEST_EQUALS( res, cur, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2236         }
2237         else // result type is Vector4
2238         {
2239           Vector4 res;
2240           Vector4 cur;
2241           res = s.Get<Vector4>() * (1.0f - x) + t.Get<Vector4>() * (x);
2242           DALI_TEST_EQUALS( application.GetGlAbstraction().GetUniformValue<Vector4>(name, cur), true, TEST_LOCATION );
2243           DALI_TEST_EQUALS( res, cur, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2244         }
2245       };
2246
2247       float step = 0.0f;
2248       for( int iter = 0; iter < 2; iter++ ) // test 2*duration seconds
2249       {
2250         for( int step_iter = 0; step_iter < 3; step_iter++ )
2251         {
2252           application.SendNotification();
2253           application.Render( _duration * 250.f );  // step i/4
2254           application.SendNotification();
2255           step += 0.25f;
2256
2257           testProperty( "start_point"    , Property::Value( start1 )        , Property::Value( start2 )        , 0, 1, step );
2258           testProperty( "end_point"      , Property::Value( end1 )          , Property::Value( end2 )          , 1, 1, step );
2259           testProperty( "start_color"    , Property::Value( start_color1 )  , Property::Value( start_color2 )  , 2, 3, step );
2260           testProperty( "end_color"      , Property::Value( end_color1 )    , Property::Value( end_color2 )    , 3, 3, step );
2261           testProperty( "rotate_center"  , Property::Value( rotate_center1 ), Property::Value( rotate_center2 ), 4, 1, step );
2262           testProperty( "rotate_angle"   , Property::Value( rotate_amount1 ), Property::Value( rotate_amount2 ), 5, 0, step );
2263           testProperty( "gradient_offset", Property::Value( offset1 )       , Property::Value( offset2 )       , 6, 0, step );
2264         }
2265         application.SendNotification();
2266         application.Render(_duration * 250.f);  // step 4/4 will not test
2267         application.SendNotification();
2268         step += 0.25f;
2269       }
2270
2271       application.SendNotification();
2272       actor.Unparent();
2273       application.SendNotification();
2274       application.Render(10.f);  // tempral time
2275       application.SendNotification();
2276     }
2277   }
2278
2279   END_TEST;
2280 }
2281
2282 int UtcDaliVisualAnimatedGradientVisual03(void)
2283 {
2284   ToolkitTestApplication application;
2285   tet_infoline( "UtcDaliAnimatedGradientVisual with full-option use string key" );
2286
2287   {
2288     float _delay[4] = {0.0f, -1.35f, 0.15f, -0.4f}; // fract(_delay) must NOT be 1/4, 2/4, 3/4. cause we don't know progress is 1.0f or 0.0f
2289     int _direction[2] = {0, 1};
2290     int _loop_count[3] = {-1, 0, 1};
2291     int _motion[2] = {0, 1};
2292     int _easing[4] = {0, 1, 2, 3};
2293
2294     int test_case_max = 4 * 2 * 3 * 2 * 4;
2295     int test_case = 0;
2296     int test_case_d = 7; // 7 is the number of animated properties.
2297
2298     float _duration = 0.4f;
2299     float _repeat_delay = _duration * 0.25f; // < _duration. cause real_duration = _duration - _repeat_delay;
2300     float noise_maker = 0.2f;
2301     // total testing time = ceil((4*2*3*2*4) / 7) * (_duration(=0.4) * 2 + 0.01) = 22.68 seconds
2302     for( test_case = 0; test_case < test_case_max + test_case_d; test_case += test_case_d )
2303     {
2304       tet_printf( "test [%d ~ %d / %d]\n" , test_case, test_case + test_case_d - 1, test_case_max);
2305
2306       VisualFactory factory = VisualFactory::Get();
2307       Property::Map propertyMap;
2308       Property::Map animationMap;
2309       propertyMap.Insert(Visual::Property::TYPE,  DevelVisual::ANIMATED_GRADIENT);
2310
2311       auto buildAnimatedMap = [&animationMap, &_direction, &_duration, &_delay, &_loop_count, &_repeat_delay, &_motion, &_easing, &test_case](const Property::Value &start, const Property::Value &target, int tc_offset)->Property::Map&
2312       {
2313         int tc = (test_case + tc_offset);
2314         int idx_easing = tc % 4; tc /= 4;
2315         int idx_motion = tc % 2; tc /= 2;
2316         int idx_loop_count = tc % 3; tc /= 3;
2317         int idx_direction = tc % 2; tc /= 2;
2318         int idx_delay = tc % 4; tc /= 4;
2319
2320         float duration = _duration - _repeat_delay;
2321         float repeat_delay = _repeat_delay;
2322         float delay = _delay[idx_delay] * _duration;
2323         int direction = _direction[idx_direction];
2324         int loop_count = _loop_count[idx_loop_count];
2325         int motion = _motion[idx_motion];
2326         int easing = _easing[idx_easing];
2327
2328         animationMap.Clear();
2329         animationMap.Insert( "startValue", start );
2330         animationMap.Insert( "targetValue", target );
2331         if( direction == 0 )
2332         {
2333           animationMap.Insert("directionType", "FORWARD");
2334         }
2335         else
2336         {
2337           animationMap.Insert("directionType", "BACKWARD");
2338         }
2339         animationMap.Insert("duration", duration);
2340         animationMap.Insert("delay", delay);
2341         animationMap.Insert("repeat", loop_count);
2342         animationMap.Insert("repeatDelay", repeat_delay);
2343         if( motion == 0 )
2344         {
2345           animationMap.Insert("motionType", "LOOP");
2346         }
2347         else
2348         {
2349           animationMap.Insert("motionType", "MIRROR");
2350         }
2351         if( easing == 0 )
2352         {
2353           animationMap.Insert("easingType", "LINEAR");
2354         }
2355         else if( easing == 1 )
2356         {
2357           animationMap.Insert("easingType", "IN");
2358         }
2359         else if( easing == 2 )
2360         {
2361           animationMap.Insert("easingType", "OUT");
2362         }
2363         else
2364         {
2365           animationMap.Insert("easingType", "IN_OUT");
2366         }
2367
2368         return animationMap;
2369       };
2370
2371       // Give different values for debuging
2372       noise_maker += 0.8f;
2373       Vector2 start1(-0.5f + noise_maker * 0.1f, 0.5f + noise_maker * 0.1f);
2374       Vector2 end1  (0.5f + noise_maker * 0.1f, -0.5f + noise_maker * 0.1f);
2375       Vector4 start_color1(1.0f, 0.7f, 0.5f, 1.0f);
2376       Vector4 end_color1  (0.7f, 0.5f, 1.0f, 1.0f);
2377       Vector2 rotate_center1(0.0f + noise_maker * 0.1f, 0.4f + noise_maker * 0.1f);
2378       float rotate_amount1 = 0.0f + noise_maker * 0.1f;
2379       float offset1 = 0.f + noise_maker * 0.1f;
2380
2381       Vector2 start2(0.2f + noise_maker * 0.1f, -0.7f + noise_maker * 0.1f);
2382       Vector2 end2  (0.5f + noise_maker * 0.1f, 0.5f + noise_maker * 0.1f);
2383       Vector4 start_color2(0.0f, 0.1f, 0.8f, 1.0f);
2384       Vector4 end_color2  (0.3f, 1.0f, 0.1f, 0.0f);
2385       Vector2 rotate_center2(0.0f + noise_maker * 0.1f, -0.4f + noise_maker * 0.1f);
2386       float rotate_amount2 = 7.0f + noise_maker * 0.1f;
2387       float offset2 = 2.f + noise_maker * 0.1f;
2388
2389       propertyMap.Insert("gradientType", "LINEAR");
2390       propertyMap.Insert("unitType",     "USER_SPACE");
2391       propertyMap.Insert("spreadType",   "CLAMP");
2392
2393       propertyMap.Insert("startPosition", buildAnimatedMap(start1        , start2        ,0));
2394       propertyMap.Insert("endPosition",   buildAnimatedMap(end1          , end2          ,1));
2395       propertyMap.Insert("startColor",    buildAnimatedMap(start_color1  , start_color2  ,2));
2396       propertyMap.Insert("endColor",      buildAnimatedMap(end_color1    , end_color2    ,3));
2397       propertyMap.Insert("rotateCenter",  buildAnimatedMap(rotate_center1, rotate_center2,4));
2398       propertyMap.Insert("rotateAmount",  buildAnimatedMap(rotate_amount1, rotate_amount2,5));
2399       propertyMap.Insert("offset",        buildAnimatedMap(offset1       , offset2       ,6));
2400
2401       Visual::Base visual = factory.CreateVisual( propertyMap );
2402
2403       DummyControl actor = DummyControl::New( true );
2404       Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>( actor.GetImplementation() );
2405       dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
2406       actor.SetSize( 2000, 2000 );
2407       actor.SetParentOrigin(ParentOrigin::CENTER);
2408       actor.SetColor(Color::BLACK);
2409       Stage::GetCurrent().Add(actor);
2410
2411       application.SendNotification();
2412       application.Render( 0 );
2413       application.SendNotification();
2414
2415       DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
2416
2417       application.SendNotification();
2418
2419       //Compare between CPU calculated value and Shader Visual calculated value
2420       auto testProperty = [&application, &_direction, &_duration, &_delay, &_loop_count, &_repeat_delay, &_motion, &_easing, &test_case](const char* name, const Property::Value& start, const Property::Value& target, int tc_offset, int value_type, float progress)->void
2421       {
2422         int tc = (test_case + tc_offset);
2423         int idx_easing = tc % 4; tc /= 4;
2424         int idx_motion = tc % 2; tc /= 2;
2425         int idx_loop_count = tc % 3; tc /= 3;
2426         int idx_direction = tc % 2; tc /= 2;
2427         int idx_delay = tc % 4; tc /= 4;
2428
2429         float duration = _duration - _repeat_delay;
2430         float repeat_delay = _repeat_delay;
2431         float delay = _delay[idx_delay] * _duration;
2432         int direction = _direction[idx_direction];
2433         int loop_count = _loop_count[idx_loop_count];
2434         int motion = _motion[idx_motion];
2435         int easing = _easing[idx_easing];
2436
2437         progress -= delay / _duration;
2438
2439         Property::Value s = start;
2440         Property::Value t = target;
2441         if( direction == 1 )
2442         {
2443           s = target;
2444           t = start;
2445         }
2446         float x; ///< Animator progress value
2447         if( loop_count == 0 )
2448         {
2449           x = 1.0f;
2450         }
2451         else if( loop_count > 0 && progress + 0.01f > loop_count )
2452         {
2453           x = ( motion == 0 ) ? 1.0f : 0.0f;
2454         }
2455         else
2456         {
2457           if( progress < 0.0f )
2458           {
2459             progress = 0.0f;
2460           }
2461           progress = fmodf( progress, 1.0f );
2462           progress = Dali::Clamp( (progress * (duration + repeat_delay) - repeat_delay) / duration, 0.0f, 1.0f );
2463
2464           x = progress;
2465           if( motion == 1 )
2466           {
2467             x = progress * 2.0f;
2468             if( x > 1.0f )
2469             {
2470               x = 2.0f - x;
2471             }
2472           }
2473
2474           if( easing == 1 ) // EASE_IN
2475           {
2476             x = x*x;
2477           }
2478           else if( easing == 2 ) // EASE_OUT
2479           {
2480             x = 2.0f*x - x*x;
2481           }
2482           else if( easing == 3 ) // EASE_IN_OUT
2483           {
2484             x = x * x * (3.0f - 2.0f * x);
2485           }
2486         }
2487         if( value_type == 0 ) // result type is Float
2488         {
2489           float res;
2490           float cur;
2491           res = s.Get<float>() * (1.0f - x) + t.Get<float>() * (x);
2492           DALI_TEST_EQUALS( application.GetGlAbstraction().GetUniformValue<float>(name, cur), true, TEST_LOCATION );
2493           DALI_TEST_EQUALS( res, cur, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2494         }
2495         else if( value_type == 1 ) // result type is Vector2
2496         {
2497           Vector2 res;
2498           Vector2 cur;
2499           res = s.Get<Vector2>() * (1.0f - x) + t.Get<Vector2>() * (x);
2500           DALI_TEST_EQUALS( application.GetGlAbstraction().GetUniformValue<Vector2>(name, cur), true, TEST_LOCATION );
2501           DALI_TEST_EQUALS( res, cur, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2502         }
2503         else if( value_type == 2 ) // result type is Vector3
2504         {
2505           Vector3 res;
2506           Vector3 cur;
2507           res = s.Get<Vector3>() * (1.0f - x) + t.Get<Vector3>() * (x);
2508           DALI_TEST_EQUALS( application.GetGlAbstraction().GetUniformValue<Vector3>(name, cur), true, TEST_LOCATION );
2509           DALI_TEST_EQUALS( res, cur, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2510         }
2511         else // result type is Vector4
2512         {
2513           Vector4 res;
2514           Vector4 cur;
2515           res = s.Get<Vector4>() * (1.0f - x) + t.Get<Vector4>() * (x);
2516           DALI_TEST_EQUALS( application.GetGlAbstraction().GetUniformValue<Vector4>(name, cur), true, TEST_LOCATION );
2517           DALI_TEST_EQUALS( res, cur, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2518         }
2519       };
2520
2521       float step = 0.0f;
2522       for( int iter = 0; iter < 2; iter++ ) // test 2*duration seconds
2523       {
2524         for( int step_iter = 0; step_iter < 3; step_iter++ )
2525         {
2526           application.SendNotification();
2527           application.Render( _duration * 250.f );  // step i/4
2528           application.SendNotification();
2529           step += 0.25f;
2530
2531           testProperty( "start_point"    , Property::Value( start1 )        , Property::Value( start2 )        , 0, 1, step );
2532           testProperty( "end_point"      , Property::Value( end1 )          , Property::Value( end2 )          , 1, 1, step );
2533           testProperty( "start_color"    , Property::Value( start_color1 )  , Property::Value( start_color2 )  , 2, 3, step );
2534           testProperty( "end_color"      , Property::Value( end_color1 )    , Property::Value( end_color2 )    , 3, 3, step );
2535           testProperty( "rotate_center"  , Property::Value( rotate_center1 ), Property::Value( rotate_center2 ), 4, 1, step );
2536           testProperty( "rotate_angle"   , Property::Value( rotate_amount1 ), Property::Value( rotate_amount2 ), 5, 0, step );
2537           testProperty( "gradient_offset", Property::Value( offset1 )       , Property::Value( offset2 )       , 6, 0, step );
2538         }
2539         application.SendNotification();
2540         application.Render(_duration * 250.f);  // step 4/4 will not test
2541         application.SendNotification();
2542         step += 0.25f;
2543       }
2544
2545       application.SendNotification();
2546       actor.Unparent();
2547       application.SendNotification();
2548       application.Render(10.f);  // tempral time
2549       application.SendNotification();
2550     }
2551   }
2552
2553   END_TEST;
2554 }
2555
2556 int UtcDaliVisualWireframeVisual(void)
2557 {
2558   ToolkitTestApplication application;
2559
2560   VisualFactory factory = VisualFactory::Get();
2561   Property::Map propertyMap;
2562   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::WIREFRAME );
2563
2564   // Create the visual.
2565   Visual::Base visual = factory.CreateVisual( propertyMap );
2566
2567   DALI_TEST_CHECK( visual );
2568
2569   Property::Map resultMap;
2570   visual.CreatePropertyMap( resultMap );
2571
2572   // Check the property values from the returned map from visual
2573   Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
2574   DALI_TEST_CHECK( value );
2575   DALI_TEST_CHECK( value->Get<int>() == Visual::WIREFRAME );
2576
2577   END_TEST;
2578 }
2579
2580 int UtcDaliVisualGetTransform(void)
2581 {
2582   ToolkitTestApplication application;
2583   tet_infoline( "UtcDaliVisualGetTransform: ColorVisual" );
2584
2585   VisualFactory factory = VisualFactory::Get();
2586   Property::Map propertyMap;
2587   propertyMap.Insert(Visual::Property::TYPE,  Visual::COLOR);
2588   propertyMap.Insert(ColorVisual::Property::MIX_COLOR,  Color::BLUE);
2589   Visual::Base colorVisual = factory.CreateVisual( propertyMap );
2590
2591   Dali::Property::Map visualMap;
2592   colorVisual.CreatePropertyMap( visualMap );
2593   Property::Value* value = visualMap.Find( Dali::Toolkit::Visual::Property::TRANSFORM );
2594   Dali::Property::Map* map = value->GetMap();
2595   DALI_TEST_CHECK( map );
2596
2597   //Test default values
2598   {
2599     Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2600     DALI_TEST_CHECK( typeValue );
2601     DALI_TEST_CHECK( typeValue->Get<Vector2>() == Vector2(0.0f,0.0f) );
2602   }
2603   {
2604     Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2605     DALI_TEST_CHECK( typeValue );
2606     DALI_TEST_CHECK( typeValue->Get<Vector2>() == Vector2(1.0f,1.0f) );
2607   }
2608   {
2609     Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::OFFSET_POLICY );
2610     DALI_TEST_CHECK( typeValue );
2611     DALI_TEST_CHECK( typeValue->Get< Vector2 >() == Vector2( Toolkit::Visual::Transform::Policy::RELATIVE, Toolkit::Visual::Transform::Policy::RELATIVE ) );
2612   }
2613   {
2614     Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2615     DALI_TEST_CHECK( typeValue );
2616     DALI_TEST_CHECK( typeValue->Get< Vector2 >() == Vector2( Toolkit::Visual::Transform::Policy::RELATIVE, Toolkit::Visual::Transform::Policy::RELATIVE ) );
2617   }
2618   {
2619     Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::ORIGIN );
2620     DALI_TEST_CHECK( typeValue );
2621     DALI_TEST_CHECK( (Toolkit::Align::Type)typeValue->Get<int>() == Toolkit::Align::TOP_BEGIN );
2622   }
2623   {
2624     Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::ANCHOR_POINT );
2625     DALI_TEST_CHECK( typeValue );
2626     DALI_TEST_CHECK( (Toolkit::Align::Type)typeValue->Get<int>() == Toolkit::Align::TOP_BEGIN );
2627   }
2628
2629   END_TEST;
2630 }
2631
2632 static void TestTransform( ToolkitTestApplication& application, Visual::Base visual )
2633 {
2634   Property::Map transform;
2635   transform.Insert( Visual::Transform::Property::OFFSET, Vector2(10.0f, 10.0f) );
2636   transform.Insert( Visual::Transform::Property::SIZE, Vector2(0.2f, 0.2f) );
2637   transform.Insert( Visual::Transform::Property::OFFSET_POLICY, Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) );
2638   transform.Insert( Visual::Transform::Property::ORIGIN, "CENTER" );
2639   transform.Insert( Visual::Transform::Property::ANCHOR_POINT, Toolkit::Align::BOTTOM_END );
2640
2641   visual.SetTransformAndSize( transform, Vector2(100, 100) );
2642
2643   Dali::Property::Map visualMap;
2644   visual.CreatePropertyMap( visualMap );
2645   Property::Value* value = visualMap.Find( Dali::Toolkit::Visual::Property::TRANSFORM );
2646   Dali::Property::Map* map = value->GetMap();
2647   DALI_TEST_CHECK( map );
2648
2649   {
2650     Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::OFFSET );
2651     DALI_TEST_CHECK( typeValue );
2652     DALI_TEST_EQUALS( typeValue->Get<Vector2>(),Vector2(10.0f,10.0f), TEST_LOCATION );
2653   }
2654   {
2655     Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::SIZE );
2656     DALI_TEST_CHECK( typeValue );
2657     DALI_TEST_EQUALS( typeValue->Get<Vector2>(), Vector2(0.2f,0.2f), TEST_LOCATION );
2658   }
2659   {
2660     Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::OFFSET_POLICY );
2661     DALI_TEST_CHECK( typeValue );
2662     DALI_TEST_EQUALS( typeValue->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2663   }
2664   {
2665     Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2666     DALI_TEST_CHECK( typeValue );
2667     DALI_TEST_EQUALS( typeValue->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::RELATIVE, Toolkit::Visual::Transform::Policy::RELATIVE ), TEST_LOCATION );
2668   }
2669   {
2670     Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::ORIGIN );
2671     DALI_TEST_CHECK( typeValue );
2672     DALI_TEST_EQUALS( (Toolkit::Align::Type)typeValue->Get<int>(), Toolkit::Align::CENTER, TEST_LOCATION );
2673   }
2674   {
2675     Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::ANCHOR_POINT );
2676     DALI_TEST_CHECK( typeValue );
2677     DALI_TEST_EQUALS( (Toolkit::Align::Type)typeValue->Get<int>(), Toolkit::Align::BOTTOM_END, TEST_LOCATION );
2678   }
2679
2680   //Put the visual on the stage
2681   DummyControl actor = DummyControl::New(true);
2682   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2683   actor.SetSize(2000, 2000);
2684   actor.SetParentOrigin(ParentOrigin::CENTER);
2685   Stage::GetCurrent().Add(actor);
2686
2687   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
2688   dummyImpl.SetLayout( DummyControl::Property::TEST_VISUAL, transform );
2689
2690   application.SendNotification();
2691   application.Render(0);
2692   Renderer renderer( actor.GetRendererAt(0) );
2693
2694   //Check that the properties have been registered on the Renderer
2695   Property::Index index = renderer.GetPropertyIndex( "offset" );
2696   DALI_TEST_CHECK( index != Property::INVALID_INDEX );
2697   Vector2 offset = renderer.GetProperty<Vector2>( index );
2698   DALI_TEST_EQUALS( offset, Vector2(10.0f,10.0f), TEST_LOCATION );
2699
2700   index = renderer.GetPropertyIndex( "size" );
2701   DALI_TEST_CHECK( index != Property::INVALID_INDEX );
2702   Vector2 size = renderer.GetProperty<Vector2>( index );
2703   DALI_TEST_EQUALS( size, Vector2(0.2f,0.2f), TEST_LOCATION );
2704
2705   index = renderer.GetPropertyIndex( "offsetSizeMode" );
2706   DALI_TEST_CHECK( index != Property::INVALID_INDEX );
2707   Vector4 offsetSizeMode = renderer.GetProperty<Vector4>( index );
2708   DALI_TEST_EQUALS( offsetSizeMode, Vector4(1.0f,1.0f,0.0f,0.0f), TEST_LOCATION );
2709
2710   index = renderer.GetPropertyIndex( "origin" );
2711   DALI_TEST_CHECK( index != Property::INVALID_INDEX );
2712   Vector2 parentOrigin = renderer.GetProperty<Vector2>( index );
2713   DALI_TEST_EQUALS( parentOrigin, Vector2(0.0f,0.0f), TEST_LOCATION );
2714
2715   index = renderer.GetPropertyIndex( "anchorPoint" );
2716   DALI_TEST_CHECK( index != Property::INVALID_INDEX );
2717   Vector2 anchorPoint = renderer.GetProperty<Vector2>( index );
2718   DALI_TEST_EQUALS( anchorPoint, Vector2(-0.5f,-0.5f), TEST_LOCATION );
2719
2720   //Set a new transform
2721   transform.Clear();
2722   transform = DefaultTransform();
2723   transform.Insert( Visual::Transform::Property::OFFSET, Vector2(20.0f, 20.0f) );
2724   transform.Insert( Visual::Transform::Property::SIZE, Vector2(100.0f, 100.0f) );
2725   transform.Insert( Visual::Transform::Property::SIZE_POLICY, Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) );
2726   visual.SetTransformAndSize( transform, Vector2(100, 100) );
2727   application.SendNotification();
2728   application.Render(0);
2729
2730   //Check that the values have changed in the renderer
2731   offset = renderer.GetProperty<Vector2>( renderer.GetPropertyIndex( "offset" ) );
2732   DALI_TEST_EQUALS( offset, Vector2(20.0f,20.0f), TEST_LOCATION );
2733
2734   size = renderer.GetProperty<Vector2>( renderer.GetPropertyIndex( "size" ) );
2735   DALI_TEST_EQUALS( size, Vector2(100.0f,100.0f), TEST_LOCATION );
2736
2737   offsetSizeMode = renderer.GetProperty<Vector4>( renderer.GetPropertyIndex( "offsetSizeMode" ) );
2738   DALI_TEST_EQUALS( offsetSizeMode, Vector4(0.0f,0.0f,1.0f,1.0f), TEST_LOCATION );
2739
2740   //Parent origin and anchor point should have the default values
2741   parentOrigin = renderer.GetProperty<Vector2>( renderer.GetPropertyIndex( "origin" ) );
2742   DALI_TEST_EQUALS( parentOrigin, Vector2(-0.5f,-0.5f), TEST_LOCATION );
2743
2744   anchorPoint = renderer.GetProperty<Vector2>( renderer.GetPropertyIndex( "anchorPoint" ) );
2745   DALI_TEST_EQUALS( anchorPoint, Vector2(0.5f,0.5f), TEST_LOCATION );
2746 }
2747
2748 int UtcDaliVisualSetTransform0(void)
2749 {
2750   ToolkitTestApplication application;
2751   tet_infoline( "UtcDaliVisualSetTransform: ColorVisual" );
2752
2753   VisualFactory factory = VisualFactory::Get();
2754   Property::Map propertyMap;
2755   propertyMap.Insert(Visual::Property::TYPE,  Visual::COLOR);
2756   propertyMap.Insert(ColorVisual::Property::MIX_COLOR,  Color::BLUE);
2757   Visual::Base visual = factory.CreateVisual( propertyMap );
2758   TestTransform( application, visual );
2759   TestMixColor( visual, ColorVisual::Property::MIX_COLOR, Color::BLUE );
2760
2761   END_TEST;
2762 }
2763
2764 int UtcDaliVisualSetTransform1(void)
2765 {
2766   ToolkitTestApplication application;
2767   tet_infoline( "UtcDaliVisualSetTransform: PrimitiveVisual" );
2768
2769   VisualFactory factory = VisualFactory::Get();
2770   Property::Map propertyMap;
2771   propertyMap[ Toolkit::Visual::Property::TYPE           ] = Visual::PRIMITIVE;
2772   propertyMap[ PrimitiveVisual::Property::MIX_COLOR ] = Color::WHITE;
2773   propertyMap[ PrimitiveVisual::Property::SHAPE  ] = PrimitiveVisual::Shape::SPHERE;
2774   propertyMap[ PrimitiveVisual::Property::SLICES ] = 10;
2775   propertyMap[ PrimitiveVisual::Property::STACKS ] = 10;
2776   Visual::Base visual = factory.CreateVisual( propertyMap );
2777   TestTransform( application, visual );
2778   TestMixColor( visual, PrimitiveVisual::Property::MIX_COLOR, Color::WHITE );
2779
2780   END_TEST;
2781 }
2782
2783 int UtcDaliVisualSetTransform2(void)
2784 {
2785   ToolkitTestApplication application;
2786   tet_infoline( "UtcDaliVisualSetTransform: GradientVisual" );
2787
2788   VisualFactory factory = VisualFactory::Get();
2789   Property::Map propertyMap;
2790   propertyMap.Insert( Toolkit::Visual::Property::TYPE,  Visual::GRADIENT );
2791   propertyMap.Insert( Visual::Property::MIX_COLOR,  Color::GREEN );
2792
2793   Property::Array stopOffsets;
2794   stopOffsets.PushBack( 0.0f );
2795   stopOffsets.PushBack( 0.3f );
2796   stopOffsets.PushBack( 0.6f );
2797   stopOffsets.PushBack( 0.8f );
2798   stopOffsets.PushBack( 1.0f );
2799   propertyMap.Insert( GradientVisual::Property::STOP_OFFSET, stopOffsets );
2800
2801   Property::Array stopColors;
2802   stopColors.PushBack( Vector4( 129.f, 198.f, 193.f, 255.f )/255.f );
2803   stopColors.PushBack( Vector4( 196.f, 198.f, 71.f, 122.f )/255.f );
2804   stopColors.PushBack( Vector4( 214.f, 37.f, 139.f, 191.f )/255.f );
2805   stopColors.PushBack( Vector4( 129.f, 198.f, 193.f, 150.f )/255.f );
2806   stopColors.PushBack( Color::YELLOW );
2807   propertyMap.Insert( GradientVisual::Property::STOP_COLOR, stopColors );
2808   propertyMap.Insert( GradientVisual::Property::CENTER, Vector2( 0.5f, 0.5f ) );
2809   propertyMap.Insert( GradientVisual::Property::RADIUS, 1.414f );
2810   Visual::Base visual = factory.CreateVisual( propertyMap );
2811   TestTransform( application, visual );
2812   TestMixColor( visual, Visual::Property::MIX_COLOR, Color::GREEN );
2813
2814   END_TEST;
2815 }
2816
2817 int UtcDaliVisualSetTransform3(void)
2818 {
2819   ToolkitTestApplication application;
2820   tet_infoline( "UtcDaliVisualSetTransform: BorderVisual" );
2821
2822   VisualFactory factory = VisualFactory::Get();
2823   Property::Map propertyMap;
2824   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::BORDER );
2825   propertyMap.Insert( Visual::Property::MIX_COLOR, Color::MAGENTA );
2826   propertyMap.Insert( BorderVisual::Property::COLOR, Vector4(0.f, 1.f, 0.f, 0.6f) );
2827   propertyMap.Insert( BorderVisual::Property::SIZE, 3.0f );
2828   Visual::Base visual = factory.CreateVisual( propertyMap );
2829   TestTransform( application, visual );
2830   TestMixColor( visual, Visual::Property::MIX_COLOR, Color::MAGENTA );
2831
2832   END_TEST;
2833 }
2834
2835 int UtcDaliVisualSetTransform4(void)
2836 {
2837   ToolkitTestApplication application;
2838   tet_infoline( "UtcDaliVisualSetTransform: MeshVisual" );
2839
2840   VisualFactory factory = VisualFactory::Get();
2841   Property::Map propertyMap;
2842   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::MESH );
2843   propertyMap.Insert( Visual::Property::MIX_COLOR, Color::CYAN );
2844
2845   propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME );
2846   propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME );
2847   propertyMap.Insert( "texturesPath", TEST_RESOURCE_LOCATION );
2848   propertyMap.Insert( "shadingMode", MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING );
2849   propertyMap.Insert( "lightPosition", Vector3( 5.0f, 10.0f, 15.0f) );
2850   Visual::Base visual = factory.CreateVisual( propertyMap );
2851   TestTransform( application, visual );
2852   TestMixColor( visual, Visual::Property::MIX_COLOR, Color::CYAN );
2853
2854   END_TEST;
2855 }
2856
2857 int UtcDaliVisualSetTransform5(void)
2858 {
2859   ToolkitTestApplication application;
2860   tet_infoline( "UtcDaliVisualSetTransform: ImageVisual from Image" );
2861
2862   VisualFactory factory = VisualFactory::Get();
2863   Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
2864   Visual::Base visual = factory.CreateVisual(image);
2865   TestTransform( application, visual );
2866   TestMixColor( visual, Visual::Property::MIX_COLOR, Color::WHITE );
2867
2868   END_TEST;
2869 }
2870
2871 int UtcDaliVisualSetTransform6(void)
2872 {
2873   ToolkitTestApplication application;
2874   tet_infoline( "UtcDaliVisualSetTransform: ImageVisual for URL " );
2875
2876   VisualFactory factory = VisualFactory::Get();
2877   Property::Map propertyMap;
2878   propertyMap[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
2879   propertyMap[Visual::Property::MIX_COLOR] = Color::YELLOW;
2880   propertyMap[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2881   propertyMap[Toolkit::ImageVisual::Property::DESIRED_WIDTH] = 100.0f;
2882   propertyMap[Toolkit::ImageVisual::Property::DESIRED_HEIGHT] = 100.0f;
2883   propertyMap[Toolkit::ImageVisual::Property::FITTING_MODE] = FittingMode::SCALE_TO_FILL;
2884   propertyMap[Toolkit::ImageVisual::Property::SAMPLING_MODE] = SamplingMode::BOX_THEN_LINEAR;
2885   propertyMap[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = true;
2886   Visual::Base visual = factory.CreateVisual(propertyMap);
2887   TestTransform( application, visual );
2888   TestMixColor( visual, Visual::Property::MIX_COLOR, Color::YELLOW );
2889
2890   END_TEST;
2891 }
2892
2893 int UtcDaliVisualSetTransform7(void)
2894 {
2895   ToolkitTestApplication application;
2896   tet_infoline( "UtcDaliVisualSetTransform: NPatch visual" );
2897
2898   VisualFactory factory = VisualFactory::Get();
2899   Image image = ResourceImage::New(TEST_NPATCH_FILE_NAME, ImageDimensions(100, 200));
2900   Visual::Base visual = factory.CreateVisual(image);
2901   TestTransform( application, visual );
2902   TestMixColor( visual, Visual::Property::MIX_COLOR, Color::WHITE );
2903
2904   END_TEST;
2905 }
2906
2907 int UtcDaliVisualTestTransformPoliciesAsStrings(void)
2908 {
2909   ToolkitTestApplication application;
2910   tet_infoline( "UtcDaliVisualTestTransformPoliciesAsStrings: Use a ColorVisual and test the offset and size policies as strings" );
2911
2912   VisualFactory factory = VisualFactory::Get();
2913   Property::Map propertyMap;
2914   propertyMap.Insert(Visual::Property::TYPE,  Visual::COLOR);
2915   propertyMap.Insert(ColorVisual::Property::MIX_COLOR,  Color::BLUE);
2916   Visual::Base visual = factory.CreateVisual( propertyMap );
2917
2918   Property::Map transform;
2919   transform[ "offsetPolicy" ] = Property::Array().Add( "ABSOLUTE" )
2920                                                  .Add( "RELATIVE" );
2921   transform[ "sizePolicy"   ] = Property::Array().Add( "RELATIVE" )
2922                                                  .Add( "ABSOLUTE" );
2923   visual.SetTransformAndSize( transform, Vector2(100, 100) );
2924
2925   Dali::Property::Map visualMap;
2926   visual.CreatePropertyMap( visualMap );
2927   Property::Value* value = visualMap.Find( Dali::Toolkit::Visual::Property::TRANSFORM );
2928   Dali::Property::Map* map = value->GetMap();
2929   DALI_TEST_CHECK( map );
2930
2931   {
2932     Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::OFFSET_POLICY );
2933     DALI_TEST_CHECK( typeValue );
2934     DALI_TEST_EQUALS( typeValue->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::RELATIVE ), TEST_LOCATION );
2935   }
2936   {
2937     Property::Value* typeValue = map->Find( Toolkit::Visual::Transform::Property::SIZE_POLICY );
2938     DALI_TEST_CHECK( typeValue );
2939     DALI_TEST_EQUALS( typeValue->Get< Vector2 >(), Vector2( Toolkit::Visual::Transform::Policy::RELATIVE, Toolkit::Visual::Transform::Policy::ABSOLUTE ), TEST_LOCATION );
2940   }
2941
2942   END_TEST;
2943 }
2944
2945 int UtcDaliNPatchVisualCustomShader(void)
2946 {
2947   ToolkitTestApplication application;
2948   tet_infoline( "NPatchVisual with custom shader" );
2949
2950   VisualFactory factory = VisualFactory::Get();
2951   Property::Map properties;
2952   Property::Map shader;
2953   const std::string vertexShader = "Foobar";
2954   const std::string fragmentShader = "Foobar";
2955   shader[Dali::Toolkit::Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2956   shader[Dali::Toolkit::Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2957
2958   Property::Map transformMap;
2959   transformMap["size"] = Vector2( 0.5f, 0.5f ) ;
2960   transformMap["offset"] = Vector2( 20.0f, 0.0f ) ;
2961   transformMap["offsetPolicy"] = Vector2( Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE );
2962   transformMap["anchorPoint"] = Align::CENTER;
2963   transformMap["origin"] = Align::CENTER;
2964   properties[Visual::Property::TRANSFORM] = transformMap;
2965
2966   properties[Visual::Property::TYPE] = Visual::IMAGE;
2967   properties[Visual::Property::MIX_COLOR] = Color::BLUE;
2968   properties[Visual::Property::SHADER]=shader;
2969   properties[ImageVisual::Property::URL] = TEST_NPATCH_FILE_NAME;
2970
2971   Visual::Base visual = factory.CreateVisual( properties );
2972   TestMixColor( visual, Visual::Property::MIX_COLOR, Color::BLUE );
2973
2974   // trigger creation through setting on stage
2975   DummyControl dummy = DummyControl::New(true);
2976   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
2977   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
2978   dummyImpl.SetLayout( DummyControl::Property::TEST_VISUAL, transformMap );
2979   dummy.SetSize(2000, 2000);
2980   dummy.SetParentOrigin(ParentOrigin::CENTER);
2981   Stage::GetCurrent().Add(dummy);
2982   application.SendNotification();
2983
2984   Renderer renderer = dummy.GetRendererAt( 0 );
2985   Shader shader2 = renderer.GetShader();
2986   Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2987   Property::Map* map = value.GetMap();
2988   DALI_TEST_CHECK( map );
2989
2990   Property::Index index = renderer.GetPropertyIndex("size");
2991   DALI_TEST_EQUALS( renderer.GetProperty( index ), Property::Value(Vector2(0.5, 0.5)), 0.001, TEST_LOCATION );
2992
2993   Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2994   DALI_TEST_EQUALS( fragmentShader, fragment->Get<std::string>(), TEST_LOCATION );
2995
2996   Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2997   DALI_TEST_EQUALS( vertexShader, vertex->Get<std::string>(), TEST_LOCATION );
2998
2999   END_TEST;
3000 }
3001
3002 int UtcDaliSvgVisualCustomShader(void)
3003 {
3004   ToolkitTestApplication application;
3005   tet_infoline( "SvgVisual with custom shader" );
3006
3007   // Vertex & fragment shader
3008   const std::string vertexShader = "Foobar";
3009   const std::string fragmentShader = "Foobar";
3010   Property::Map properties;
3011   Property::Map shaderProperty1;
3012   shaderProperty1[Dali::Toolkit::Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
3013   shaderProperty1[Dali::Toolkit::Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
3014
3015   properties[Visual::Property::TYPE] = Visual::SVG;
3016   properties[Visual::Property::SHADER] = shaderProperty1;
3017   properties[ImageVisual::Property::URL] = TEST_SVG_FILE_NAME;
3018
3019   VisualFactory factory = VisualFactory::Get();
3020   Visual::Base visual = factory.CreateVisual( properties );
3021
3022   // trigger creation through setting on stage
3023   DummyControl dummy = DummyControl::New( true );
3024   Impl::DummyControl& dummyImpl1 = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
3025
3026   dummyImpl1.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
3027   dummy.SetSize( 200, 200 );
3028   Stage::GetCurrent().Add( dummy );
3029
3030   visual.SetTransformAndSize( DefaultTransform(), Vector2( 100, 100 ) );
3031
3032   application.SendNotification();
3033
3034   // Wait for image to load
3035   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
3036
3037   application.SendNotification();
3038   application.Render();
3039
3040   Renderer renderer = dummy.GetRendererAt( 0 );
3041   Shader shader = renderer.GetShader();
3042   Property::Value value = shader.GetProperty( Shader::Property::PROGRAM );
3043   Property::Map* map = value.GetMap();
3044   DALI_TEST_CHECK( map );
3045
3046   Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
3047   DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
3048
3049   Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
3050   DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
3051
3052   // Vertex shader only
3053   Property::Map shaderProperty2;
3054   shaderProperty2[Dali::Toolkit::Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
3055
3056   properties[Visual::Property::TYPE] = Visual::SVG;
3057   properties[Visual::Property::SHADER] = shaderProperty2;
3058   properties[ImageVisual::Property::URL] = TEST_SVG_FILE_NAME;
3059
3060   visual = factory.CreateVisual( properties );
3061
3062   // trigger creation through setting on stage
3063   dummy = DummyControl::New( true );
3064   Impl::DummyControl& dummyImpl2 = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
3065
3066   dummyImpl2.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
3067   dummy.SetSize( 200, 200 );
3068   Stage::GetCurrent().Add( dummy );
3069
3070   visual.SetTransformAndSize( DefaultTransform(), Vector2( 100, 100 ) );
3071
3072   application.SendNotification();
3073
3074   // Wait for image to load
3075   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
3076
3077   application.SendNotification();
3078   application.Render();
3079
3080   renderer = dummy.GetRendererAt( 0 );
3081   shader = renderer.GetShader();
3082   value = shader.GetProperty( Shader::Property::PROGRAM );
3083   map = value.GetMap();
3084   DALI_TEST_CHECK( map );
3085
3086   vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
3087   DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
3088
3089   // Fragment shader only
3090   Property::Map shaderProperty3;
3091   shaderProperty3[Dali::Toolkit::Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
3092
3093   properties[Visual::Property::TYPE] = Visual::SVG;
3094   properties[Visual::Property::SHADER] = shaderProperty3;
3095   properties[ImageVisual::Property::URL] = TEST_SVG_FILE_NAME;
3096
3097   visual = factory.CreateVisual( properties );
3098
3099   // trigger creation through setting on stage
3100   dummy = DummyControl::New( true );
3101   Impl::DummyControl& dummyImpl3 = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
3102
3103   dummyImpl3.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
3104   dummy.SetSize( 200, 200 );
3105   Stage::GetCurrent().Add( dummy );
3106
3107   visual.SetTransformAndSize( DefaultTransform(), Vector2( 100, 100 ) );
3108
3109   application.SendNotification();
3110
3111   // Wait for image to load
3112   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
3113
3114   application.SendNotification();
3115   application.Render();
3116
3117   renderer = dummy.GetRendererAt( 0 );
3118   shader = renderer.GetShader();
3119   value = shader.GetProperty( Shader::Property::PROGRAM );
3120   map = value.GetMap();
3121   DALI_TEST_CHECK( map );
3122
3123   fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
3124   DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
3125
3126   END_TEST;
3127 }
3128
3129 int UtcDaliGradientVisualBlendMode(void)
3130 {
3131   ToolkitTestApplication application;
3132   VisualFactory factory = VisualFactory::Get();
3133
3134   Visual::Base opaqueGradientVisual = factory.CreateVisual(
3135       Property::Map().Add( Toolkit::Visual::Property::TYPE, Visual::GRADIENT )
3136                      .Add( GradientVisual::Property::START_POSITION, Vector2( -0.5f, -0.5f ) )
3137                      .Add( GradientVisual::Property::END_POSITION, Vector2( 0.5f, 0.5f ) )
3138                      .Add( GradientVisual::Property::STOP_COLOR, Property::Array().Add( Color::RED )
3139                                                                                   .Add( Color::GREEN ) ) );
3140
3141   Visual::Base alphaGradientVisual = factory.CreateVisual(
3142       Property::Map().Add( Toolkit::Visual::Property::TYPE, Visual::GRADIENT )
3143                      .Add( GradientVisual::Property::START_POSITION, Vector2( -0.5f, -0.5f ) )
3144                      .Add( GradientVisual::Property::END_POSITION, Vector2( 0.5f, 0.5f ) )
3145                      .Add( GradientVisual::Property::STOP_COLOR, Property::Array().Add( Color::RED )
3146                                                                                   .Add( Vector4( 1.0f, 1.0f, 1.0f, 0.5f ) ) ) );
3147
3148   DummyControl control = DummyControl::New(true);
3149   control.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
3150   Stage::GetCurrent().Add( control );
3151
3152   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>( control.GetImplementation() );
3153   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL,  opaqueGradientVisual );
3154   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, alphaGradientVisual );
3155
3156   application.SendNotification();
3157   application.Render();
3158
3159   // Control should have two renderers, the first one is opaque so our blending mode should be off, the second one has some alpha so should be set to automatic
3160   DALI_TEST_EQUALS( 2u, control.GetRendererCount(), TEST_LOCATION );
3161   DALI_TEST_EQUALS( control.GetRendererAt( 0 ).GetProperty( Renderer::Property::BLEND_MODE ).Get<int>(), (int)BlendMode::OFF, TEST_LOCATION );
3162   DALI_TEST_EQUALS( control.GetRendererAt( 1 ).GetProperty( Renderer::Property::BLEND_MODE ).Get<int>(), (int)BlendMode::AUTO, TEST_LOCATION );
3163
3164   END_TEST;
3165 }
3166
3167 int UtcDaliVisualRendererRemovalAndReAddition(void)
3168 {
3169   ToolkitTestApplication application;
3170   tet_infoline( "UtcDaliVisualRendererRemoval" );
3171
3172   VisualFactory factory = VisualFactory::Get();
3173   Property::Map propertyMap;
3174   propertyMap.Insert(Visual::Property::TYPE,  Visual::COLOR);
3175   propertyMap.Insert(ColorVisual::Property::MIX_COLOR,  Color::BLUE);
3176   Visual::Base visual = factory.CreateVisual( propertyMap );
3177
3178   visual.SetDepthIndex( 1 );
3179
3180   DummyControl dummyControl = DummyControl::New(true);
3181   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
3182   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
3183   DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION );
3184
3185   dummyControl.SetSize(200.f, 200.f);
3186   tet_infoline( "Add control with visual to stage and check renderer count is 1" );
3187
3188   Stage::GetCurrent().Add( dummyControl );
3189
3190   application.SendNotification();
3191   application.Render();
3192
3193   DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 1, TEST_LOCATION );
3194
3195   tet_infoline( "Remove control with visual from stage and check renderer count is 0" );
3196   Stage::GetCurrent().Remove( dummyControl );
3197   application.SendNotification();
3198   application.Render();
3199
3200   DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION );
3201
3202   tet_infoline( "Re-add control with visual to stage and check renderer count is still 1" );
3203
3204   Stage::GetCurrent().Add( dummyControl );
3205
3206   application.SendNotification();
3207   application.Render();
3208
3209   DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 1, TEST_LOCATION );
3210
3211   END_TEST;
3212 }
3213
3214
3215
3216 int UtcDaliVisualTextVisualRender(void)
3217 {
3218   ToolkitTestApplication application;
3219   tet_infoline( "UtcDaliVisualTextVisualRender" );
3220
3221   VisualFactory factory = VisualFactory::Get();
3222   Property::Map propertyMap;
3223   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::TEXT );
3224   propertyMap.Insert( "mixColor", Color::WHITE );
3225   propertyMap.Insert( "renderingBackend", static_cast<int>( Toolkit::Text::DEFAULT_RENDERING_BACKEND ) );
3226   propertyMap.Insert( "enableMarkup", false );
3227   propertyMap.Insert( "text", "Hello world" );
3228   propertyMap.Insert( "fontFamily", "TizenSans" );
3229
3230   Property::Map fontStyleMapSet;
3231   fontStyleMapSet.Insert( "weight", "bold" );
3232   propertyMap.Insert( "fontStyle", fontStyleMapSet );
3233
3234   propertyMap.Insert( "pointSize", 12.f );
3235   propertyMap.Insert( "multiLine", true );
3236   propertyMap.Insert( "horizontalAlignment", "CENTER" );
3237   propertyMap.Insert( "verticalAlignment", "CENTER" );
3238   propertyMap.Insert( "textColor", Color::RED );
3239   Visual::Base textVisual = factory.CreateVisual( propertyMap );
3240   textVisual.SetDepthIndex( 1 );
3241
3242   DummyControl dummyControl = DummyControl::New(true);
3243   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
3244   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, textVisual );
3245   DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION );
3246
3247   dummyControl.SetSize(200.f, 200.f);
3248   dummyControl.SetParentOrigin( ParentOrigin::CENTER );
3249
3250   Stage::GetCurrent().Add( dummyControl );
3251   application.SendNotification();
3252   application.Render();
3253
3254
3255   // Create a texture bigger than the maximum allowed by the image atlas. Used to increase coverage.
3256   propertyMap.Clear();
3257   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::TEXT );
3258   propertyMap.Insert( TextVisual::Property::ENABLE_MARKUP, true );
3259   propertyMap.Insert( TextVisual::Property::TEXT, "<font family='TizenSans' size='12'>Hello world</font>" );
3260   propertyMap.Insert( TextVisual::Property::MULTI_LINE, true );
3261
3262   Property::Map transformMap;
3263   transformMap.Insert( "size", Vector2( 0.5f, 0.5f ) );
3264   propertyMap.Insert( Visual::Property::TRANSFORM, transformMap );
3265
3266   textVisual = factory.CreateVisual( propertyMap );
3267   textVisual.SetDepthIndex( 1 );
3268
3269   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, textVisual );
3270   dummyControl.SetSize( 720.f, 640.f );
3271
3272   application.SendNotification(); // force process events to ensure text visual
3273   // adds renderer to the dummy control in OnRelayout
3274   application.Render();
3275
3276   Renderer renderer = dummyControl.GetRendererAt(0u);
3277   Property::Index index = renderer.GetPropertyIndex("size");
3278
3279   tet_infoline( "Test that the TextVisual has NOT overridden what was set by developer" );
3280   DALI_TEST_EQUALS( renderer.GetProperty<Vector2>(index), Vector2( 0.5f, 0.5f ), 0.001f, TEST_LOCATION );
3281
3282   END_TEST;
3283 }
3284
3285 int UtcDaliVisualTextVisualDisableEnable(void)
3286 {
3287   ToolkitTestApplication application;
3288   tet_infoline( "UtcDaliVisualTextVisualDisableEnable Ensure Text visible can be re-enabled" );
3289
3290   VisualFactory factory = VisualFactory::Get();
3291   Property::Map propertyMap;
3292   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::TEXT );
3293   propertyMap.Insert( "mixColor", Color::WHITE );
3294   propertyMap.Insert( "renderingBackend", static_cast<int>( Toolkit::Text::DEFAULT_RENDERING_BACKEND ) );
3295   propertyMap.Insert( "enableMarkup", false );
3296   propertyMap.Insert( "text", "Hello world" );
3297   propertyMap.Insert( "fontFamily", "TizenSans" );
3298
3299   Property::Map fontStyleMapSet;
3300   fontStyleMapSet.Insert( "weight", "bold" );
3301   propertyMap.Insert( "fontStyle", fontStyleMapSet );
3302
3303   propertyMap.Insert( "pointSize", 12.f );
3304   propertyMap.Insert( "multiLine", true );
3305   propertyMap.Insert( "horizontalAlignment", "CENTER" );
3306   propertyMap.Insert( "verticalAlignment", "CENTER" );
3307   propertyMap.Insert( "textColor", Color::RED );
3308   Visual::Base textVisual = factory.CreateVisual( propertyMap );
3309   textVisual.SetDepthIndex( 1 );
3310
3311   DummyControl dummyControl = DummyControl::New(true);
3312   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
3313   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, textVisual );
3314   DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION );
3315
3316   dummyControl.SetSize(200.f, 200.f);
3317   dummyControl.SetParentOrigin( ParentOrigin::CENTER );
3318
3319   Stage::GetCurrent().Add( dummyControl );
3320   application.SendNotification();
3321   application.Render();
3322
3323   DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 1, TEST_LOCATION );
3324
3325   dummyImpl.EnableVisual( DummyControl::Property::TEST_VISUAL, false );
3326
3327   DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION );
3328
3329   dummyImpl.EnableVisual( DummyControl::Property::TEST_VISUAL, true );
3330
3331   DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 1, TEST_LOCATION );
3332
3333   END_TEST;
3334 }
3335
3336 int UtcDaliVisualPremultipliedAlpha(void)
3337 {
3338   ToolkitTestApplication application;
3339   tet_infoline( "UtcDaliVisualPremultipliedAlpha" );
3340
3341   VisualFactory factory = VisualFactory::Get();
3342
3343   // image visual, test default value ( false )
3344   {
3345     Visual::Base imageVisual = factory.CreateVisual(
3346           Property::Map()
3347           .Add( Toolkit::Visual::Property::TYPE, Visual::IMAGE )
3348           .Add( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ) );
3349
3350     Dali::Property::Map visualMap;
3351     imageVisual.CreatePropertyMap( visualMap );
3352     Property::Value* value = visualMap.Find( Visual::Property::PREMULTIPLIED_ALPHA );
3353
3354     // test values
3355     DALI_TEST_CHECK( value );
3356     DALI_TEST_EQUALS( value->Get<bool>(), false, TEST_LOCATION );
3357   }
3358
3359   // image visual, override premultiplied
3360   {
3361     Visual::Base imageVisual = factory.CreateVisual(
3362           Property::Map()
3363           .Add( Toolkit::Visual::Property::TYPE, Visual::IMAGE )
3364           .Add( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME )
3365           .Add( Visual::Property::PREMULTIPLIED_ALPHA, true ) );
3366
3367     Dali::Property::Map visualMap;
3368     imageVisual.CreatePropertyMap( visualMap );
3369     Property::Value* value = visualMap.Find( Visual::Property::PREMULTIPLIED_ALPHA );
3370
3371     // test values
3372     DALI_TEST_CHECK( value );
3373     DALI_TEST_EQUALS( value->Get<bool>(), true, TEST_LOCATION);
3374   }
3375
3376   // svg visual ( premultiplied alpha by default is true )
3377   {
3378     Visual::Base imageVisual = factory.CreateVisual(
3379           Property::Map()
3380           .Add( Toolkit::Visual::Property::TYPE, Visual::IMAGE )
3381           .Add( ImageVisual::Property::URL, TEST_SVG_FILE_NAME ) );
3382
3383     Dali::Property::Map visualMap;
3384     imageVisual.CreatePropertyMap( visualMap );
3385     Property::Value* value = visualMap.Find( Visual::Property::PREMULTIPLIED_ALPHA );
3386
3387     // test values
3388     DALI_TEST_CHECK( value );
3389     DALI_TEST_EQUALS( value->Get<bool>(), true, TEST_LOCATION );
3390   }
3391
3392   END_TEST;
3393 }
3394
3395 int UtcDaliRegisterVisualOrder(void)
3396 {
3397   ToolkitTestApplication application;
3398   tet_infoline( "Register Visual Order" );
3399
3400   DummyControl dummyControl = DummyControl::New(true);
3401   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
3402
3403   VisualFactory factory = VisualFactory::Get();
3404   Property::Map propertyMap;
3405   propertyMap.Insert(Visual::Property::TYPE,  Visual::COLOR);
3406   propertyMap.Insert(ColorVisual::Property::MIX_COLOR,  Color::BLUE);
3407
3408   tet_infoline( "Register visual, should have depth index of 0.0f" );
3409   Visual::Base testVisual = factory.CreateVisual( propertyMap );
3410   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, testVisual );
3411   DALI_TEST_EQUALS( testVisual.GetDepthIndex(), 0, TEST_LOCATION );
3412
3413   tet_infoline( "Register more visuals, each added one should have a depth index greater than previous" );
3414
3415   Visual::Base testVisual2 = factory.CreateVisual( propertyMap );
3416   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, testVisual2 );
3417   DALI_TEST_CHECK( testVisual2.GetDepthIndex() > testVisual.GetDepthIndex() );
3418
3419   Visual::Base foregroundVisual = factory.CreateVisual( propertyMap );
3420   dummyImpl.RegisterVisual( DummyControl::Property::FOREGROUND_VISUAL, foregroundVisual );
3421   DALI_TEST_CHECK( foregroundVisual.GetDepthIndex() > testVisual2.GetDepthIndex() );
3422
3423   Visual::Base focusVisual = factory.CreateVisual( propertyMap );
3424   dummyImpl.RegisterVisual( DummyControl::Property::FOCUS_VISUAL, focusVisual );
3425   DALI_TEST_CHECK( focusVisual.GetDepthIndex() > foregroundVisual.GetDepthIndex() );
3426
3427   tet_infoline( "Set depth index on a new visual before registering, the depth index should not have been changed" );
3428   Visual::Base labelVisual = factory.CreateVisual( propertyMap );
3429   labelVisual.SetDepthIndex( -2000 );
3430   dummyImpl.RegisterVisual( DummyControl::Property::LABEL_VISUAL, labelVisual );
3431   DALI_TEST_EQUALS( labelVisual.GetDepthIndex(), -2000, TEST_LOCATION );
3432
3433   tet_infoline( "Replace visual, the depth index should be the same as what was previously set" );
3434   const int testVisual2DepthIndex = testVisual2.GetDepthIndex();
3435   Visual::Base testVisual2Replacement = factory.CreateVisual( propertyMap );
3436   DALI_TEST_CHECK( testVisual2Replacement.GetDepthIndex() != testVisual2DepthIndex );
3437   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, testVisual2Replacement );
3438   DALI_TEST_EQUALS( testVisual2Replacement.GetDepthIndex(), testVisual2DepthIndex, TEST_LOCATION );
3439
3440   tet_infoline( "Replace visual and set a depth index on the replacement, the depth index of the replacement should be honoured" );
3441   Visual::Base anotherTestVisual2Replacement = factory.CreateVisual( propertyMap );
3442   anotherTestVisual2Replacement.SetDepthIndex( 2000 );
3443   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, anotherTestVisual2Replacement );
3444   DALI_TEST_EQUALS( anotherTestVisual2Replacement.GetDepthIndex(), 2000, TEST_LOCATION );
3445
3446   dummyControl.SetSize(200.f, 200.f);
3447   Stage::GetCurrent().Add( dummyControl );
3448
3449   END_TEST;
3450 }
3451
3452 int UtcDaliRegisterVisualOrder02(void)
3453 {
3454   ToolkitTestApplication application;
3455   tet_infoline( "Register Visual Order with Background Set" );
3456
3457   DummyControl dummyControl = DummyControl::New(true);
3458   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
3459
3460   const int backgroundDepthIndex = Toolkit::DepthIndex::BACKGROUND;
3461
3462   VisualFactory factory = VisualFactory::Get();
3463   Property::Map propertyMap;
3464   propertyMap.Insert(Visual::Property::TYPE,  Visual::COLOR);
3465   propertyMap.Insert(ColorVisual::Property::MIX_COLOR,  Color::BLUE);
3466
3467   tet_printf( "Register a control background visual, should have depth index of %d\n", backgroundDepthIndex );
3468
3469   dummyControl.SetProperty( Control::Property::BACKGROUND, propertyMap );
3470
3471   const int TEST_VISUAL_1_DEPTH_INDEX = 0;
3472   tet_printf( "Register visual, should have depth index of %d\n", TEST_VISUAL_1_DEPTH_INDEX );
3473   Visual::Base testVisual1 = factory.CreateVisual( propertyMap );
3474   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, testVisual1 );
3475   DALI_TEST_EQUALS( testVisual1.GetDepthIndex(), TEST_VISUAL_1_DEPTH_INDEX , TEST_LOCATION );
3476
3477   tet_printf( "Register another visual, should have a depth index greater than previous(%d)\n", TEST_VISUAL_1_DEPTH_INDEX );
3478   Visual::Base testVisual2 = factory.CreateVisual( propertyMap );
3479   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, testVisual2 );
3480   DALI_TEST_CHECK( testVisual2.GetDepthIndex() >  testVisual1.GetDepthIndex() );
3481
3482   dummyControl.SetSize(200.f, 200.f);
3483   Stage::GetCurrent().Add( dummyControl );
3484
3485   END_TEST;
3486 }
3487
3488 int UtcDaliRegisterVisualWithDepthIndex(void)
3489 {
3490   ToolkitTestApplication application;
3491   tet_infoline( "Register a Visual With Depth Index" );
3492
3493   DummyControl dummyControl = DummyControl::New(true);
3494   Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
3495
3496   VisualFactory factory = VisualFactory::Get();
3497   Property::Map propertyMap;
3498   propertyMap.Insert(Visual::Property::TYPE,  Visual::COLOR);
3499   propertyMap.Insert(ColorVisual::Property::MIX_COLOR,  Color::BLUE);
3500
3501   tet_infoline( "Register a visual with a depth index, it should be enabled by default too" );
3502   Visual::Base testVisual = factory.CreateVisual( propertyMap );
3503   DevelControl::RegisterVisual( dummyImpl, DummyControl::Property::TEST_VISUAL, testVisual, 203 );
3504   DALI_TEST_EQUALS( testVisual.GetDepthIndex(), 203, TEST_LOCATION );
3505   DALI_TEST_EQUALS( DevelControl::IsVisualEnabled( dummyImpl, DummyControl::Property::TEST_VISUAL ), true, TEST_LOCATION );
3506
3507   tet_infoline( "Register another visual with a depth index and it disabled" );
3508   Visual::Base testVisual2 = factory.CreateVisual( propertyMap );
3509   DevelControl::RegisterVisual( dummyImpl, DummyControl::Property::TEST_VISUAL2, testVisual2, false, 450 );
3510   DALI_TEST_EQUALS( testVisual2.GetDepthIndex(), 450, TEST_LOCATION );
3511   DALI_TEST_EQUALS( DevelControl::IsVisualEnabled( dummyImpl, DummyControl::Property::TEST_VISUAL2 ), false, TEST_LOCATION );
3512
3513   tet_infoline( "Register another visual with a depth index and it enabled using the enabled API" );
3514   Visual::Base testVisual3 = factory.CreateVisual( propertyMap );
3515   DevelControl::RegisterVisual( dummyImpl, DummyControl::Property::TEST_VISUAL2, testVisual3, true, 300 );
3516   DALI_TEST_EQUALS( testVisual3.GetDepthIndex(), 300, TEST_LOCATION );
3517   DALI_TEST_EQUALS( DevelControl::IsVisualEnabled( dummyImpl, DummyControl::Property::TEST_VISUAL2 ), true, TEST_LOCATION );
3518
3519   dummyControl.SetSize(200.f, 200.f);
3520   Stage::GetCurrent().Add( dummyControl );
3521
3522   END_TEST;
3523 }
3524
3525 int UtcDaliColorVisualRenderIfTransparentProperty(void)
3526 {
3527   ToolkitTestApplication application;
3528   tet_infoline( "Test the renderIfTransparent property of ColorVisual" );
3529
3530   VisualFactory factory = VisualFactory::Get();
3531   Property::Map propertyMap;
3532   propertyMap.Insert( Visual::Property::TYPE,  Visual::COLOR );
3533   propertyMap.Insert( ColorVisual::Property::MIX_COLOR, Color::BLUE );
3534
3535   tet_infoline( "Check default value" );
3536   {
3537     Visual::Base testVisual = factory.CreateVisual( propertyMap );
3538     Property::Map returnedMap;
3539     testVisual.CreatePropertyMap( returnedMap );
3540
3541     Property::Value* renderIfTransparentProperty = returnedMap.Find( DevelColorVisual::Property::RENDER_IF_TRANSPARENT );
3542     DALI_TEST_CHECK( renderIfTransparentProperty );
3543     DALI_TEST_EQUALS( renderIfTransparentProperty->Get< bool >(), false, TEST_LOCATION );
3544   }
3545
3546   propertyMap.Insert( DevelColorVisual::Property::RENDER_IF_TRANSPARENT, true );
3547
3548   tet_infoline( "Ensure set to value required" );
3549   {
3550     Visual::Base testVisual = factory.CreateVisual( propertyMap );
3551     Property::Map returnedMap;
3552     testVisual.CreatePropertyMap( returnedMap );
3553
3554     Property::Value* renderIfTransparentProperty = returnedMap.Find( DevelColorVisual::Property::RENDER_IF_TRANSPARENT );
3555     DALI_TEST_CHECK( renderIfTransparentProperty );
3556     DALI_TEST_EQUALS( renderIfTransparentProperty->Get< bool >(), true, TEST_LOCATION );
3557   }
3558
3559   propertyMap[ DevelColorVisual::Property::RENDER_IF_TRANSPARENT ] = Color::BLUE;
3560
3561   tet_infoline( "Ensure it returns default value if set to wrong type" );
3562   {
3563     Visual::Base testVisual = factory.CreateVisual( propertyMap );
3564     Property::Map returnedMap;
3565     testVisual.CreatePropertyMap( returnedMap );
3566
3567     Property::Value* renderIfTransparentProperty = returnedMap.Find( DevelColorVisual::Property::RENDER_IF_TRANSPARENT );
3568     DALI_TEST_CHECK( renderIfTransparentProperty );
3569     DALI_TEST_EQUALS( renderIfTransparentProperty->Get< bool >(), false, TEST_LOCATION );
3570   }
3571
3572   END_TEST;
3573 }