[dali_1.2.65] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-VisualFactory.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 <dali-toolkit-test-suite-utils.h>
20 #include <toolkit-timer.h>
21 #include <toolkit-event-thread-callback.h>
22 #include <dali/devel-api/images/nine-patch-image.h>
23 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
24 #include <dali-toolkit/dali-toolkit.h>
25 #include "dummy-control.h"
26
27 using namespace Dali;
28 using namespace Dali::Toolkit;
29
30 namespace
31 {
32 typedef NinePatchImage::StretchRanges StretchRanges;
33
34 const char* TEST_NPATCH_FILE_NAME =  TEST_RESOURCE_DIR  "/button-up-1.9.png";
35 const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
36 const char* TEST_OBJ_FILE_NAME = TEST_RESOURCE_DIR "/Cube.obj";
37 const char* TEST_MTL_FILE_NAME = TEST_RESOURCE_DIR "/ToyRobot-Metal.mtl";
38 const char* TEST_SIMPLE_OBJ_FILE_NAME = TEST_RESOURCE_DIR "/Cube-Points-Only.obj";
39 const char* TEST_SIMPLE_MTL_FILE_NAME = TEST_RESOURCE_DIR "/ToyRobot-Metal-Simple.mtl";
40
41 // resolution: 50*50, frame count: 4, frame delay: 0.2 second for each frame
42 const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
43
44 // resolution: 34*34, pixel format: RGBA8888
45 static const char* gImage_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png";
46
47
48 Property::Map DefaultTransform()
49 {
50   Property::Map transformMap;
51   transformMap
52     .Add( Toolkit::Visual::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
53     .Add( Toolkit::Visual::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
54     .Add( Toolkit::Visual::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
55     .Add( Toolkit::Visual::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
56     .Add( Toolkit::Visual::Transform::Property::OFFSET_POLICY, Vector2( Toolkit::Visual::Transform::Policy::RELATIVE, Toolkit::Visual::Transform::Policy::RELATIVE ) )
57     .Add( Toolkit::Visual::Transform::Property::SIZE_POLICY, Vector2( Toolkit::Visual::Transform::Policy::RELATIVE, Toolkit::Visual::Transform::Policy::RELATIVE ) );
58   return transformMap;
59 }
60
61 Integration::Bitmap* CreateBitmap( unsigned int imageWidth, unsigned int imageHeight, unsigned int initialColor, Pixel::Format pixelFormat )
62 {
63   Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
64   Integration::PixelBuffer* pixbuffer = bitmap->GetPackedPixelsProfile()->ReserveBuffer( pixelFormat, imageWidth, imageHeight, imageWidth, imageHeight );
65   unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
66
67   memset( pixbuffer, initialColor, imageHeight * imageWidth * bytesPerPixel );
68
69   return bitmap;
70 }
71
72 void InitialiseRegionsToZeroAlpha( Integration::Bitmap* image, unsigned int imageWidth, unsigned int imageHeight, Pixel::Format pixelFormat )
73 {
74   PixelBuffer* pixbuffer = image->GetBuffer();
75   unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
76
77   for( unsigned int row = 0; row < imageWidth; ++row )
78   {
79     unsigned int pixelOffset = row * bytesPerPixel;
80     pixbuffer[ pixelOffset + 3 ] = 0x00;
81     pixelOffset += ( imageHeight - 1 ) * imageWidth * bytesPerPixel;
82     pixbuffer[ pixelOffset + 3 ] = 0x00;
83   }
84
85   for ( unsigned int column = 0; column < imageHeight; ++column )
86   {
87     unsigned int pixelOffset = column * imageWidth * bytesPerPixel;
88     pixbuffer[ pixelOffset + 3 ] = 0x00;
89     pixelOffset += ( imageWidth -1 ) * bytesPerPixel;
90     pixbuffer[ pixelOffset + 3 ] = 0x00;
91   }
92 }
93
94 void AddStretchRegionsToImage( Integration::Bitmap* image, unsigned int imageWidth, unsigned int imageHeight, const StretchRanges& stretchRangesX, const StretchRanges& stretchRangesY, Pixel::Format pixelFormat )
95 {
96   PixelBuffer* pixbuffer = image->GetBuffer();
97   unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
98
99   for(StretchRanges::ConstIterator it = stretchRangesX.Begin(); it != stretchRangesX.End(); ++it)
100   {
101     const Uint16Pair& range = *it;
102     //since the stretch range is in the cropped image space, we need to offset by 1 to get it to the uncropped image space
103     for( unsigned int column = range.GetX() + 1u; column < range.GetY() + 1u; ++column )
104     {
105       unsigned int pixelOffset = column * bytesPerPixel;
106       pixbuffer[ pixelOffset ] = 0x00;
107       pixbuffer[ pixelOffset + 1 ] = 0x00;
108       pixbuffer[ pixelOffset + 2 ] = 0x00;
109       pixbuffer[ pixelOffset + 3 ] = 0xFF;
110     }
111   }
112
113
114   for(StretchRanges::ConstIterator it = stretchRangesY.Begin(); it != stretchRangesY.End(); ++it)
115   {
116     const Uint16Pair& range = *it;
117     //since the stretch range is in the cropped image space, we need to offset by 1 to get it to the uncropped image space
118     for( unsigned int row = range.GetX() + 1u; row < range.GetY() + 1u; ++row )
119     {
120       unsigned int pixelOffset = row * imageWidth * bytesPerPixel;
121       pixbuffer[ pixelOffset ] = 0x00;
122       pixbuffer[ pixelOffset + 1 ] = 0x00;
123       pixbuffer[ pixelOffset + 2 ] = 0x00;
124       pixbuffer[ pixelOffset + 3 ] = 0xFF;
125     }
126   }
127 }
128
129 void AddChildRegionsToImage( Integration::Bitmap* image, unsigned int imageWidth, unsigned int imageHeight, const Vector4& requiredChildRegion, Pixel::Format pixelFormat )
130 {
131   PixelBuffer* pixbuffer = image->GetBuffer();
132   unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
133
134   Integration::Bitmap::PackedPixelsProfile* srcProfile = image->GetPackedPixelsProfile();
135   unsigned int bufferStride = srcProfile->GetBufferStride();
136
137   // Add bottom child region
138   for( unsigned int column = requiredChildRegion.x; column < imageWidth - requiredChildRegion.z; ++column )
139   {
140     unsigned int pixelOffset = column * bytesPerPixel;
141     pixelOffset += ( imageHeight - 1 ) * bufferStride;
142     pixbuffer[ pixelOffset ] = 0x00;
143     pixbuffer[ pixelOffset + 1 ] = 0x00;
144     pixbuffer[ pixelOffset + 2 ] = 0x00;
145     pixbuffer[ pixelOffset + 3 ] = 0xFF;
146   }
147
148   // Add right child region
149   for ( unsigned int row = requiredChildRegion.y; row < imageHeight - requiredChildRegion.w; ++row )
150   {
151     unsigned int pixelOffset = row * bufferStride + ( imageWidth - 1 ) * bytesPerPixel;
152     pixbuffer[ pixelOffset ] = 0x00;
153     pixbuffer[ pixelOffset + 1 ] = 0x00;
154     pixbuffer[ pixelOffset + 2 ] = 0x00;
155     pixbuffer[ pixelOffset + 3 ] = 0xFF;
156   }
157 }
158
159 Integration::ResourcePointer CustomizeNinePatch( TestApplication& application,
160                                                  unsigned int ninePatchImageWidth,
161                                                  unsigned int ninePatchImageHeight,
162                                                  const StretchRanges& stretchRangesX,
163                                                  const StretchRanges& stretchRangesY,
164                                                  bool addChildRegion = false,
165                                                  Vector4 requiredChildRegion = Vector4::ZERO )
166 {
167   TestPlatformAbstraction& platform = application.GetPlatform();
168
169   Pixel::Format pixelFormat = Pixel::RGBA8888;
170
171   tet_infoline("Create Bitmap");
172   platform.SetClosestImageSize(Vector2( ninePatchImageWidth, ninePatchImageHeight));
173   Integration::Bitmap* bitmap = CreateBitmap( ninePatchImageWidth, ninePatchImageHeight, 0xFF, pixelFormat );
174
175   tet_infoline("Clear border regions");
176   InitialiseRegionsToZeroAlpha( bitmap, ninePatchImageWidth, ninePatchImageHeight, pixelFormat );
177
178   tet_infoline("Add Stretch regions to Bitmap");
179   AddStretchRegionsToImage( bitmap, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY, pixelFormat );
180
181   if( addChildRegion )
182   {
183     tet_infoline("Add Child regions to Bitmap");
184     AddChildRegionsToImage( bitmap, ninePatchImageWidth, ninePatchImageHeight, requiredChildRegion, pixelFormat );
185   }
186
187   tet_infoline("Getting resource");
188   Integration::ResourcePointer resourcePtr(bitmap);
189   //platform.SetResourceLoaded( 0, Dali::Integration::ResourceBitmap, resourcePtr );
190   platform.SetSynchronouslyLoadedResource( resourcePtr);
191
192   return resourcePtr;
193 }
194
195 void TestVisualRender( ToolkitTestApplication& application,
196                        DummyControl& actor,
197                        Visual::Base& visual,
198                        std::size_t expectedSamplers = 0,
199                        ImageDimensions imageDimensions = ImageDimensions(),
200                        Integration::ResourcePointer resourcePtr = Integration::ResourcePointer())
201 {
202   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
203   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
204
205   if( resourcePtr )
206   {
207     // set the image size, for test case, this needs to be set before loading started
208     application.GetPlatform().SetClosestImageSize(  Vector2(imageDimensions.GetWidth(), imageDimensions.GetHeight()) );
209   }
210
211   actor.SetSize( 200.f, 200.f );
212   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
213
214   Stage::GetCurrent().Add( actor );
215
216   application.SendNotification();
217   application.Render();
218
219   application.Render();
220   application.SendNotification();
221
222   if( resourcePtr )
223   {
224     DALI_TEST_EQUALS( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceSynchronouslyFunc ), true, TEST_LOCATION);
225   }
226
227   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
228
229 }
230
231 } // namespace
232
233
234 void dali_visual_factory_startup(void)
235 {
236   test_return_value = TET_UNDEF;
237 }
238
239 void dali_visual_factory_cleanup(void)
240 {
241   test_return_value = TET_PASS;
242 }
243
244 int UtcDaliVisualFactoryGet(void)
245 {
246   ToolkitTestApplication application;
247   tet_infoline( "UtcDaliVisualFactory" );
248
249   //Register type
250   TypeInfo type;
251   type = TypeRegistry::Get().GetTypeInfo( "VisualFactory" );
252   DALI_TEST_CHECK( type );
253   BaseHandle handle = type.CreateInstance();
254   DALI_TEST_CHECK( handle );
255
256   VisualFactory factory;
257   factory = VisualFactory::Get();
258   DALI_TEST_CHECK( factory );
259
260   VisualFactory newFactory = VisualFactory::Get();
261   DALI_TEST_CHECK( newFactory );
262
263   // Check that visual factory is a singleton
264   DALI_TEST_CHECK(factory == newFactory);
265
266   END_TEST;
267 }
268
269 int UtcDaliVisualFactoryCopyAndAssignment(void)
270 {
271   ToolkitTestApplication application;
272   tet_infoline( "UtcDaliVisualFactoryCopyAndAssignment" );
273   VisualFactory factory = VisualFactory::Get();
274
275   VisualFactory factoryCopy( factory );
276   DALI_TEST_CHECK(factory == factoryCopy);
277
278   VisualFactory emptyFactory;
279   VisualFactory emptyFactoryCopy( emptyFactory );
280   DALI_TEST_CHECK(emptyFactory == emptyFactoryCopy);
281
282   VisualFactory factoryEquals;
283   factoryEquals = factory;
284   DALI_TEST_CHECK(factory == factoryEquals);
285
286   VisualFactory emptyFactoryEquals;
287   emptyFactoryEquals = emptyFactory;
288   DALI_TEST_CHECK( emptyFactory == emptyFactoryEquals );
289
290   //self assignment
291   factory = factory;
292   DALI_TEST_CHECK( factory = factoryCopy );
293
294   END_TEST;
295 }
296
297 int UtcDaliVisualFactoryGetColorVisual1(void)
298 {
299   ToolkitTestApplication application;
300   tet_infoline( "UtcDaliVisualFactoryGetColorVisual1:  Request color visual with a Property::Map" );
301
302   VisualFactory factory = VisualFactory::Get();
303   DALI_TEST_CHECK( factory );
304
305   Property::Map propertyMap;
306   Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
307   propertyMap.Insert(Visual::Property::TYPE,  Visual::COLOR);
308   propertyMap.Insert(ColorVisual::Property::MIX_COLOR,  testColor);
309
310   Visual::Base visual = factory.CreateVisual(propertyMap);
311   DALI_TEST_CHECK( visual );
312
313   DummyControl actor = DummyControl::New(true);
314   TestVisualRender( application, actor, visual );
315
316   Vector3 actualValue(Vector4::ZERO);
317   float opacity=0.0f;
318   TestGlAbstraction& gl = application.GetGlAbstraction();
319   DALI_TEST_CHECK( gl.GetUniformValue<Vector3>( "mixColor", actualValue ) );
320   DALI_TEST_CHECK( gl.GetUniformValue<float>( "opacity", opacity ) );
321   DALI_TEST_EQUALS( actualValue, Vector3(testColor), TEST_LOCATION );
322   DALI_TEST_EQUALS( opacity, testColor.a, TEST_LOCATION );
323
324   END_TEST;
325 }
326
327 int UtcDaliVisualFactoryGetColorVisual2(void)
328 {
329   ToolkitTestApplication application;
330   tet_infoline( "UtcDaliVisualFactoryGetColorVisual2: Request color visual with a Vector4" );
331
332   VisualFactory factory = VisualFactory::Get();
333   DALI_TEST_CHECK( factory );
334
335   Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
336   Dali::Property::Map map;
337   map[ Toolkit::Visual::Property::TYPE ] = Visual::COLOR;
338   map[ ColorVisual::Property::MIX_COLOR ] = testColor;
339   Visual::Base visual = factory.CreateVisual( map );
340   DALI_TEST_CHECK( visual );
341
342   DummyControl actor = DummyControl::New(true);
343   TestVisualRender( application, actor, visual );
344
345   Vector3 actualValue;
346   float opacity;
347   TestGlAbstraction& gl = application.GetGlAbstraction();
348   DALI_TEST_CHECK( gl.GetUniformValue<Vector3>( "mixColor", actualValue ) );
349   DALI_TEST_CHECK( gl.GetUniformValue<float>( "opacity", opacity ) );
350   DALI_TEST_EQUALS( actualValue, Vector3(testColor), TEST_LOCATION );
351   DALI_TEST_EQUALS( opacity, testColor.a, TEST_LOCATION );
352
353   Stage::GetCurrent().Remove(actor);
354   DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
355
356   END_TEST;
357 }
358
359 int UtcDaliVisualFactoryGetBorderVisual1(void)
360 {
361   ToolkitTestApplication application;
362   tet_infoline( "UtcDaliVisualFactoryGetBorderVisual1:  Request border visual with a Property::Map" );
363
364   VisualFactory factory = VisualFactory::Get();
365   DALI_TEST_CHECK( factory );
366
367   Property::Map propertyMap;
368   Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
369   float testSize = 5.f;
370   propertyMap.Insert(Visual::Property::TYPE,  Visual::BORDER);
371   propertyMap.Insert(BorderVisual::Property::COLOR,  testColor);
372   propertyMap.Insert(BorderVisual::Property::SIZE,  testSize);
373
374   Visual::Base visual = factory.CreateVisual(propertyMap);
375   DALI_TEST_CHECK( visual );
376
377   DummyControl actor = DummyControl::New(true);
378   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
379   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
380   actor.SetSize(200.f, 200.f);
381   Stage::GetCurrent().Add( actor );
382   visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f));
383
384   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
385   int blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLEND_MODE );
386   DALI_TEST_EQUALS( static_cast<BlendMode::Type>(blendMode), BlendMode::ON, TEST_LOCATION );
387
388   TestGlAbstraction& gl = application.GetGlAbstraction();
389
390   application.SendNotification();
391   application.Render(0);
392
393   Vector4 actualColor(Vector4::ZERO);
394   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "borderColor", actualColor ) );
395   DALI_TEST_EQUALS( actualColor, testColor, TEST_LOCATION );
396
397   float actualSize = 0.f;
398   DALI_TEST_CHECK( gl.GetUniformValue<float>( "borderSize", actualSize ) );
399   DALI_TEST_EQUALS( actualSize, testSize, TEST_LOCATION );
400
401   actor.Unparent();
402   DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
403
404   END_TEST;
405 }
406
407 int UtcDaliVisualFactoryGetBorderVisual2(void)
408 {
409   ToolkitTestApplication application;
410   tet_infoline( "UtcDaliVisualFactoryGetBorderVisual2:  Request border visual with a borderSize and a borderColor" );
411
412   VisualFactory factory = VisualFactory::Get();
413   DALI_TEST_CHECK( factory );
414
415   Vector4 testColor( 1.f, 0.5f, 0.3f, 1.f );
416   float testSize = 5.f;
417
418   Dali::Property::Map propertyMap;
419   propertyMap[ Toolkit::Visual::Property::TYPE ] = Visual::BORDER;
420   propertyMap[ BorderVisual::Property::COLOR  ] = testColor;
421   propertyMap[ BorderVisual::Property::SIZE   ] = testSize;
422   Visual::Base visual = factory.CreateVisual( propertyMap );
423   DALI_TEST_CHECK( visual );
424
425   DummyControl actor = DummyControl::New(true);
426   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
427   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
428   actor.SetSize(200.f, 200.f);
429   Stage::GetCurrent().Add( actor );
430   visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f));
431
432   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
433
434   TestGlAbstraction& gl = application.GetGlAbstraction();
435
436   application.SendNotification();
437   application.Render(0);
438
439   int blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLEND_MODE );
440   DALI_TEST_EQUALS( static_cast<BlendMode::Type>(blendMode), BlendMode::AUTO, TEST_LOCATION );
441
442   Vector4 actualColor(Vector4::ZERO);
443   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "borderColor", actualColor ) );
444   DALI_TEST_EQUALS( actualColor, testColor, TEST_LOCATION );
445
446   float actualSize = 0.f;
447   DALI_TEST_CHECK( gl.GetUniformValue<float>( "borderSize", actualSize ) );
448   DALI_TEST_EQUALS( actualSize, testSize, TEST_LOCATION );
449
450   actor.Unparent();
451
452   // enable the anti-aliasing
453   Dali::Property::Map map;
454   map[ Toolkit::Visual::Property::TYPE ] = Visual::BORDER;
455   map[ BorderVisual::Property::COLOR  ] = testColor;
456   map[ BorderVisual::Property::SIZE   ] = testSize;
457   map[ BorderVisual::Property::ANTI_ALIASING   ] = true;
458   visual = factory.CreateVisual( map );
459
460   dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
461   Stage::GetCurrent().Add( actor );
462
463   blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLEND_MODE );
464   DALI_TEST_EQUALS( static_cast<BlendMode::Type>(blendMode), BlendMode::ON, TEST_LOCATION );
465
466   END_TEST;
467 }
468
469 int UtcDaliVisualFactoryGetLinearGradientVisual(void)
470 {
471   ToolkitTestApplication application;
472   tet_infoline("UtcDaliVisualFactoryGetRadialGradientVisual");
473
474   VisualFactory factory = VisualFactory::Get();
475   DALI_TEST_CHECK( factory );
476
477   Property::Map propertyMap;
478   propertyMap.Insert(Visual::Property::TYPE,  Visual::GRADIENT);
479
480   Vector2 start(-1.f, -1.f);
481   Vector2 end(1.f, 1.f);
482   propertyMap.Insert(GradientVisual::Property::START_POSITION, start);
483   propertyMap.Insert(GradientVisual::Property::END_POSITION, end);
484   propertyMap.Insert(GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT);
485
486   Property::Array stopOffsets;
487   stopOffsets.PushBack( 0.2f );
488   stopOffsets.PushBack( 0.8f );
489   propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, stopOffsets);
490
491   Property::Array stopColors;
492   stopColors.PushBack( Color::RED );
493   stopColors.PushBack( Color::GREEN );
494   propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
495
496   Visual::Base visual = factory.CreateVisual(propertyMap);
497   DALI_TEST_CHECK( visual );
498
499   // A lookup texture is generated and pass to shader as sampler
500   DummyControl actor = DummyControl::New(true);
501   TestVisualRender( application, actor, visual, 1u);
502
503   END_TEST;
504 }
505
506 int UtcDaliVisualFactoryGetRadialGradientVisual(void)
507 {
508   ToolkitTestApplication application;
509   tet_infoline("UtcDaliVisualFactoryGetRadialGradientVisual");
510
511   VisualFactory factory = VisualFactory::Get();
512   DALI_TEST_CHECK( factory );
513
514   Property::Map propertyMap;
515   propertyMap.Insert(Visual::Property::TYPE,  Visual::GRADIENT);
516
517   Vector2 center(100.f, 100.f);
518   float radius = 100.f;
519   propertyMap.Insert(GradientVisual::Property::UNITS,  GradientVisual::Units::USER_SPACE);
520   propertyMap.Insert(GradientVisual::Property::CENTER,  center);
521   propertyMap.Insert(GradientVisual::Property::RADIUS,  radius);
522
523   Property::Array stopOffsets;
524   stopOffsets.PushBack( 0.0f );
525   stopOffsets.PushBack( 1.f );
526   propertyMap.Insert(GradientVisual::Property::STOP_OFFSET,   stopOffsets);
527
528   Property::Array stopColors;
529   stopColors.PushBack( Color::RED );
530   stopColors.PushBack( Color::GREEN );
531   propertyMap.Insert(GradientVisual::Property::STOP_COLOR,   stopColors);
532
533   Visual::Base visual = factory.CreateVisual(propertyMap);
534   DALI_TEST_CHECK( visual );
535
536   // A lookup texture is generated and pass to shader as sampler
537   DummyControl actor = DummyControl::New(true);
538   TestVisualRender( application, actor, visual, 1u );
539
540   Matrix3 alignMatrix( radius, 0.f, 0.f, 0.f, radius, 0.f, center.x, center.y, 1.f );
541   alignMatrix.Invert();
542
543   Matrix3 actualValue( Matrix3::IDENTITY );
544   TestGlAbstraction& gl = application.GetGlAbstraction();
545   DALI_TEST_CHECK( gl.GetUniformValue<Matrix3>( "uAlignmentMatrix", actualValue ) );
546   DALI_TEST_EQUALS( actualValue, alignMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
547
548   END_TEST;
549 }
550
551 int UtcDaliVisualFactoryDefaultOffsetsGradientVisual(void)
552 {
553   ToolkitTestApplication application;
554   tet_infoline("UtcDaliVisualFactoryGetRadialGradientVisual");
555
556   VisualFactory factory = VisualFactory::Get();
557   DALI_TEST_CHECK( factory );
558
559   Property::Map propertyMap;
560   propertyMap.Insert(Visual::Property::TYPE,  Visual::GRADIENT);
561
562   Vector2 start(-1.f, -1.f);
563   Vector2 end(1.f, 1.f);
564   propertyMap.Insert(GradientVisual::Property::START_POSITION, start);
565   propertyMap.Insert(GradientVisual::Property::END_POSITION, end);
566   propertyMap.Insert(GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT);
567
568   Property::Array stopColors;
569   stopColors.PushBack( Color::RED );
570   stopColors.PushBack( Color::GREEN );
571   propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
572
573   Visual::Base visual = factory.CreateVisual(propertyMap);
574   DALI_TEST_CHECK( visual );
575
576   // A lookup texture is generated and pass to shader as sampler
577   DummyControl actor = DummyControl::New(true);
578   TestVisualRender( application, actor, visual, 1u );
579
580   Stage::GetCurrent().Remove( actor );
581   DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
582
583   END_TEST;
584 }
585
586
587
588
589
590 int UtcDaliVisualFactoryGetNPatchVisual1(void)
591 {
592   ToolkitTestApplication application;
593   tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual1: Request 9-patch visual with a Property::Map" );
594
595   VisualFactory factory = VisualFactory::Get();
596   DALI_TEST_CHECK( factory );
597
598   const unsigned int ninePatchImageHeight = 18;
599   const unsigned int ninePatchImageWidth = 28;
600   StretchRanges stretchRangesX;
601   stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
602   StretchRanges stretchRangesY;
603   stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
604   Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
605
606   Property::Map propertyMap;
607   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::N_PATCH );
608   propertyMap.Insert( ImageVisual::Property::URL,  TEST_NPATCH_FILE_NAME );
609   {
610     tet_infoline( "whole grid" );
611     Visual::Base visual = factory.CreateVisual( propertyMap );
612     DALI_TEST_CHECK( visual );
613
614
615     TestGlAbstraction& gl = application.GetGlAbstraction();
616     TraceCallStack& textureTrace = gl.GetTextureTrace();
617     textureTrace.Enable(true);
618
619     DummyControl actor = DummyControl::New(true);
620     TestVisualRender( application, actor, visual, 1u,
621                       ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
622                       ninePatchResource );
623
624     DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
625   }
626
627   propertyMap.Insert( ImageVisual::Property::BORDER_ONLY,  true );
628   {
629     tet_infoline( "border only" );
630     Visual::Base visual = factory.CreateVisual( propertyMap );
631     DALI_TEST_CHECK( visual );
632
633     TestGlAbstraction& gl = application.GetGlAbstraction();
634     TraceCallStack& textureTrace = gl.GetTextureTrace();
635     textureTrace.Enable(true);
636
637     DummyControl actor = DummyControl::New(true);
638     TestVisualRender( application, actor, visual, 1u,
639                       ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
640                       ninePatchResource );
641
642     DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
643   }
644
645   END_TEST;
646 }
647
648 int UtcDaliVisualFactoryGetNPatchVisual2(void)
649 {
650   ToolkitTestApplication application;
651   tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual1: Request 9-patch visual with a Property::Map including border" );
652
653   VisualFactory factory = VisualFactory::Get();
654   DALI_TEST_CHECK( factory );
655
656   Property::Map propertyMap;
657   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::N_PATCH );
658   propertyMap.Insert( ImageVisual::Property::URL, gImage_34_RGBA );
659   propertyMap.Insert( ImageVisual::Property::BORDER, Rect< int >( 2, 2, 2, 2 ) );
660   {
661     tet_infoline( "whole grid" );
662     Visual::Base visual = factory.CreateVisual( propertyMap );
663     DALI_TEST_CHECK( visual );
664
665     TestGlAbstraction& gl = application.GetGlAbstraction();
666     TraceCallStack& textureTrace = gl.GetTextureTrace();
667     textureTrace.Enable(true);
668
669     DummyControl actor = DummyControl::New(true);
670     TestVisualRender( application, actor, visual, 1u );
671
672     DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
673   }
674
675   propertyMap.Insert( ImageVisual::Property::BORDER_ONLY,  true );
676   {
677     tet_infoline( "border only" );
678     Visual::Base visual = factory.CreateVisual( propertyMap );
679     DALI_TEST_CHECK( visual );
680
681     TestGlAbstraction& gl = application.GetGlAbstraction();
682     TraceCallStack& textureTrace = gl.GetTextureTrace();
683     textureTrace.Enable(true);
684
685     DummyControl actor = DummyControl::New(true);
686     TestVisualRender( application, actor, visual, 1u );
687
688     DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
689   }
690
691   propertyMap.Clear();
692   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::N_PATCH );
693   propertyMap.Insert( ImageVisual::Property::URL, gImage_34_RGBA );
694   propertyMap.Insert( ImageVisual::Property::BORDER, Rect< int >( 1, 1, 1, 1 ) );
695   {
696     tet_infoline( "whole grid" );
697     Visual::Base visual = factory.CreateVisual( propertyMap );
698     DALI_TEST_CHECK( visual );
699
700     TestGlAbstraction& gl = application.GetGlAbstraction();
701     TraceCallStack& textureTrace = gl.GetTextureTrace();
702     textureTrace.Enable(true);
703
704     DummyControl actor = DummyControl::New(true);
705     TestVisualRender( application, actor, visual, 1u );
706
707     DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
708   }
709
710   END_TEST;
711 }
712
713 int UtcDaliVisualFactoryGetNPatchVisual3(void)
714 {
715   ToolkitTestApplication application;
716   tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual2: Request n-patch visual with a Property::Map" );
717
718   VisualFactory factory = VisualFactory::Get();
719   DALI_TEST_CHECK( factory );
720
721   const unsigned int ninePatchImageWidth = 18;
722   const unsigned int ninePatchImageHeight = 28;
723   StretchRanges stretchRangesX;
724   stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
725   stretchRangesX.PushBack( Uint16Pair( 5, 7 ) );
726   stretchRangesX.PushBack( Uint16Pair( 12, 15 ) );
727   StretchRanges stretchRangesY;
728   stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
729   stretchRangesY.PushBack( Uint16Pair( 8, 12 ) );
730   stretchRangesY.PushBack( Uint16Pair( 15, 16 ) );
731   stretchRangesY.PushBack( Uint16Pair( 25, 27 ) );
732   Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
733
734   Property::Map propertyMap;
735   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::N_PATCH );
736   propertyMap.Insert( ImageVisual::Property::URL,  TEST_NPATCH_FILE_NAME );
737   {
738     Visual::Base visual = factory.CreateVisual( propertyMap );
739     DALI_TEST_CHECK( visual );
740
741     TestGlAbstraction& gl = application.GetGlAbstraction();
742     TraceCallStack& textureTrace = gl.GetTextureTrace();
743     textureTrace.Enable(true);
744
745     DummyControl actor = DummyControl::New(true);
746     TestVisualRender( application, actor, visual, 1u,
747                       ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
748                       ninePatchResource );
749
750     DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
751
752     Stage::GetCurrent().Remove( actor );
753     DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
754   }
755
756   propertyMap.Insert( ImageVisual::Property::BORDER_ONLY,  true );
757   {
758     tet_infoline( "border only" );
759     Visual::Base visual = factory.CreateVisual( propertyMap );
760     DALI_TEST_CHECK( visual );
761
762     TestGlAbstraction& gl = application.GetGlAbstraction();
763     TraceCallStack& textureTrace = gl.GetTextureTrace();
764     textureTrace.Enable(true);
765     DummyControl actor = DummyControl::New(true);
766     TestVisualRender( application, actor, visual, 1u,
767                       ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
768                       ninePatchResource );
769
770
771     DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
772
773     Stage::GetCurrent().Remove( actor );
774     DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
775   }
776
777   END_TEST;
778 }
779
780 int UtcDaliVisualFactoryGetNPatchVisual4(void)
781 {
782   ToolkitTestApplication application;
783   tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual3: Request 9-patch visual with an image url" );
784
785   VisualFactory factory = VisualFactory::Get();
786   DALI_TEST_CHECK( factory );
787
788   const unsigned int ninePatchImageHeight = 18;
789   const unsigned int ninePatchImageWidth = 28;
790   StretchRanges stretchRangesX;
791   stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
792   StretchRanges stretchRangesY;
793   stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
794   Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
795
796   Visual::Base visual = factory.CreateVisual( TEST_NPATCH_FILE_NAME, ImageDimensions() );
797   DALI_TEST_CHECK( visual );
798
799   TestGlAbstraction& gl = application.GetGlAbstraction();
800   TraceCallStack& textureTrace = gl.GetTextureTrace();
801   textureTrace.Enable(true);
802
803   DummyControl actor = DummyControl::New(true);
804   TestVisualRender( application, actor, visual, 1u,
805                     ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
806                     ninePatchResource );
807
808   DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
809
810
811   ResourceImage image = ResourceImage::New(TEST_NPATCH_FILE_NAME);
812   Visual::Base nPatchVisual = factory.CreateVisual( image );
813   Vector2 controlSize( 20.f, 30.f ), naturalSize(0,0);
814   nPatchVisual.SetTransformAndSize(DefaultTransform(), controlSize );
815   nPatchVisual.GetNaturalSize( naturalSize );
816   DALI_TEST_EQUALS( naturalSize, Vector2( ninePatchImageWidth-2, ninePatchImageHeight-2 ), TEST_LOCATION );
817
818   END_TEST;
819 }
820
821 int UtcDaliVisualFactoryGetNPatchVisual5(void)
822 {
823   ToolkitTestApplication application;
824   tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual4: Request n-patch visual with an image url" );
825
826   VisualFactory factory = VisualFactory::Get();
827   DALI_TEST_CHECK( factory );
828
829   const unsigned int ninePatchImageHeight = 18;
830   const unsigned int ninePatchImageWidth = 28;
831   StretchRanges stretchRangesX;
832   stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
833   stretchRangesX.PushBack( Uint16Pair( 5, 7 ) );
834   stretchRangesX.PushBack( Uint16Pair( 12, 15 ) );
835   StretchRanges stretchRangesY;
836   stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
837   stretchRangesY.PushBack( Uint16Pair( 8, 12 ) );
838   stretchRangesY.PushBack( Uint16Pair( 15, 16 ) );
839   stretchRangesY.PushBack( Uint16Pair( 25, 27 ) );
840   Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
841
842   Visual::Base visual = factory.CreateVisual( TEST_NPATCH_FILE_NAME, ImageDimensions() );
843   DALI_TEST_CHECK( visual );
844
845   TestGlAbstraction& gl = application.GetGlAbstraction();
846   TraceCallStack& textureTrace = gl.GetTextureTrace();
847   textureTrace.Enable(true);
848
849   DummyControl actor = DummyControl::New(true);
850   TestVisualRender( application, actor, visual, 1u,
851                     ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
852                     ninePatchResource );
853
854   DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
855
856   END_TEST;
857 }
858
859 int UtcDaliVisualFactoryGetNPatchVisualN1(void)
860 {
861   //This should still load but display an error image
862
863   ToolkitTestApplication application;
864   tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid image url" );
865
866   VisualFactory factory = VisualFactory::Get();
867   DALI_TEST_CHECK( factory );
868
869   Visual::Base visual = factory.CreateVisual( "ERROR.9.jpg", ImageDimensions() );
870   DALI_TEST_CHECK( visual );
871
872   //The testkit still has to load a bitmap for the broken renderer image
873   Integration::Bitmap* bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
874   bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 100, 100, 100, 100 );
875
876   TestGlAbstraction& gl = application.GetGlAbstraction();
877   TraceCallStack& textureTrace = gl.GetTextureTrace();
878   textureTrace.Enable(true);
879
880   DummyControl actor = DummyControl::New(true);
881   TestVisualRender( application, actor, visual, 1u,
882                     ImageDimensions(),
883                     Integration::ResourcePointer(bitmap) );
884
885   DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
886
887   END_TEST;
888 }
889
890 int UtcDaliVisualFactoryGetNPatchVisualN2(void)
891 {
892   //This should still load but display an error image
893
894   ToolkitTestApplication application;
895   tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid URL" );
896
897   VisualFactory factory = VisualFactory::Get();
898   DALI_TEST_CHECK( factory );
899
900   Property::Map propertyMap;
901   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::N_PATCH );
902   propertyMap.Insert( ImageVisual::Property::URL,  "ERROR.9.jpg" );
903
904   Visual::Base visual = factory.CreateVisual( propertyMap );
905   DALI_TEST_CHECK( visual );
906
907   //The testkit still has to load a bitmap for the broken renderer image
908   Integration::Bitmap* bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
909   bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 100, 100, 100, 100 );
910
911   TestGlAbstraction& gl = application.GetGlAbstraction();
912   TraceCallStack& textureTrace = gl.GetTextureTrace();
913   textureTrace.Enable(true);
914   TraceCallStack& drawTrace = gl.GetDrawTrace();
915   drawTrace.Enable(true);
916
917   DummyControl actor = DummyControl::New(true);
918   TestVisualRender( application, actor, visual, 1u,
919                     ImageDimensions(),
920                     Integration::ResourcePointer(bitmap) );
921
922   DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
923
924   END_TEST;
925 }
926
927 int UtcDaliVisualFactoryGetNPatchVisualN3(void)
928 {
929   // Passing in an invalid visual type so we should not get a visual
930
931   ToolkitTestApplication application;
932   tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid visual type" );
933
934   VisualFactory factory = VisualFactory::Get();
935   DALI_TEST_CHECK( factory );
936
937   Property::Map propertyMap;
938   propertyMap.Insert( Toolkit::Visual::Property::TYPE,  111 );
939   propertyMap.Insert( ImageVisual::Property::URL,  "ERROR.9.jpg" );
940
941   Visual::Base visual = factory.CreateVisual( propertyMap );
942   DALI_TEST_CHECK( !visual );
943
944   END_TEST;
945 }
946
947 int UtcDaliVisualFactoryGetSvgVisual(void)
948 {
949   ToolkitTestApplication application;
950   tet_infoline( "UtcDaliVisualFactoryGetSvgVisual: Request svg visual with a svg url" );
951
952   VisualFactory factory = VisualFactory::Get();
953   Visual::Base visual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions() );
954   DALI_TEST_CHECK( visual );
955
956   TestGlAbstraction& gl = application.GetGlAbstraction();
957   TraceCallStack& textureTrace = gl.GetTextureTrace();
958   textureTrace.Enable(true);
959
960   DummyControl actor = DummyControl::New(true);
961   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
962   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
963   actor.SetSize( 200.f, 200.f );
964   Stage::GetCurrent().Add( actor );
965   visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f) );
966
967   application.SendNotification();
968   application.Render();
969
970   // renderer is not added to actor until the rasterization is completed.
971   DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
972
973   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
974
975   // renderer is added to actor
976   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
977
978   // waiting for the resource uploading
979   application.SendNotification();
980   application.Render();
981
982   DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
983
984   END_TEST;
985 }
986
987 int UtcDaliVisualFactoryGetSvgVisualLarge(void)
988 {
989   ToolkitTestApplication application;
990   tet_infoline( "UtcDaliVisualFactoryGetSvgVisual: Request svg visual with a svg url" );
991
992   VisualFactory factory = VisualFactory::Get();
993   Visual::Base visual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions( 2000, 2000 ) );
994   DALI_TEST_CHECK( visual );
995
996   TestGlAbstraction& gl = application.GetGlAbstraction();
997   TraceCallStack& textureTrace = gl.GetTextureTrace();
998   textureTrace.Enable(true);
999
1000   DummyControl actor = DummyControl::New(true);
1001   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1002   actor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); // Only rasterizes when it knows control size.
1003   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
1004   Stage::GetCurrent().Add( actor );
1005
1006   application.SendNotification();
1007   application.Render();
1008
1009   // renderer is not added to actor until the rasterization is completed.
1010   DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1011
1012   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1013
1014   // renderer is added to actor
1015   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
1016
1017   // waiting for the resource uploading
1018   application.SendNotification();
1019   application.Render();
1020
1021   DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1022
1023   END_TEST;
1024 }
1025
1026 int UtcDaliVisualFactoryGetSvgVisualAtlas(void)
1027 {
1028   ToolkitTestApplication application;
1029   tet_infoline( "UtcDaliVisualFactoryGetSvgVisual: Request svg visual with enabled atlas" );
1030
1031   VisualFactory factory = VisualFactory::Get();
1032
1033   Property::Map propertyMap;
1034   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::SVG );
1035   propertyMap.Insert( ImageVisual::Property::URL, TEST_SVG_FILE_NAME );
1036   propertyMap.Insert( ImageVisual::Property::ATLASING, true );
1037
1038   Visual::Base visual = factory.CreateVisual( propertyMap );
1039   DALI_TEST_CHECK( visual );
1040
1041   TestGlAbstraction& gl = application.GetGlAbstraction();
1042   TraceCallStack& textureTrace = gl.GetTextureTrace();
1043   textureTrace.Enable(true);
1044
1045   DummyControl actor = DummyControl::New(true);
1046   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1047   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
1048   actor.SetSize( 200.f, 200.f );
1049   Stage::GetCurrent().Add( actor );
1050   visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f) );
1051
1052   application.SendNotification();
1053   application.Render();
1054
1055   // renderer is not added to actor until the rasterization is completed.
1056   DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1057
1058   DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1059
1060   // renderer is added to actor
1061   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
1062
1063   // waiting for the resource uploading
1064   application.SendNotification();
1065   application.Render();
1066
1067   DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1068
1069   END_TEST;
1070 }
1071
1072 //Creates a mesh visual from the given propertyMap and tries to load it on stage in the given application.
1073 //This is expected to succeed, which will then pass the test.
1074 void MeshVisualLoadsCorrectlyTest( Property::Map& propertyMap, ToolkitTestApplication& application )
1075 {
1076   VisualFactory factory = VisualFactory::Get();
1077   DALI_TEST_CHECK( factory );
1078
1079   //Create a mesh visual.
1080   Visual::Base visual = factory.CreateVisual( propertyMap );
1081   DALI_TEST_CHECK( visual );
1082
1083   //Create an actor on stage to house the visual.
1084   DummyControl actor = DummyControl::New(true);
1085   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1086   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
1087   actor.SetSize( 200.f, 200.f );
1088   Stage::GetCurrent().Add( actor );
1089   visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.f, 200.f ) );
1090
1091   //Ensure set on stage.
1092   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1093
1094   //Attempt to render to queue resource load requests.
1095   application.SendNotification();
1096   application.Render( 0 );
1097
1098   //Render again to upload the now-loaded textures.
1099   application.SendNotification();
1100   application.Render( 0 );
1101
1102   Matrix testScaleMatrix;
1103   testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
1104   Matrix actualScaleMatrix;
1105
1106   //Test to see if the object has been successfully loaded.
1107   DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
1108   DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1109
1110   //Finish by setting off stage, and ensuring this was successful.
1111   actor.Unparent();
1112   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1113 }
1114
1115 //Creates a mesh visual from the given propertyMap and tries to load it on stage in the given application.
1116 //This is expected to fail, which will then pass the test.
1117 void MeshVisualDoesNotLoadCorrectlyTest( Property::Map& propertyMap, ToolkitTestApplication& application )
1118 {
1119   VisualFactory factory = VisualFactory::Get();
1120   DALI_TEST_CHECK( factory );
1121
1122   //Create a mesh visual.
1123   Visual::Base visual = factory.CreateVisual( propertyMap );
1124   DALI_TEST_CHECK( visual );
1125
1126   //Create an actor on stage to house the visual.
1127   DummyControl actor = DummyControl::New(true);
1128   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1129   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
1130   actor.SetSize( 200.f, 200.f );
1131   Stage::GetCurrent().Add( actor );
1132   visual.SetTransformAndSize(DefaultTransform(),  Vector2( 200.f, 200.f ) );
1133
1134   //Ensure set on stage.
1135   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1136
1137   //Attempt to render to queue resource load requests.
1138   application.SendNotification();
1139   application.Render( 0 );
1140
1141   //Render again to upload the now-loaded textures.
1142   application.SendNotification();
1143   application.Render( 0 );
1144
1145   //Test to see if the object has not been loaded, as expected.
1146   Matrix scaleMatrix;
1147   DALI_TEST_CHECK( !application.GetGlAbstraction().GetUniformValue<Matrix>( "uObjectMatrix", scaleMatrix ) );
1148
1149   //Finish by setting off stage, and ensuring this was successful.
1150   actor.Unparent();
1151   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1152 }
1153
1154 //Test if mesh loads correctly when supplied with only the bare minimum requirements, an object file.
1155 int UtcDaliVisualFactoryGetMeshVisual1(void)
1156 {
1157   //Set up test application first, so everything else can be handled.
1158   ToolkitTestApplication application;
1159
1160   tet_infoline( "UtcDaliVisualFactoryGetMeshVisual1:  Request mesh visual with a valid object file only" );
1161
1162
1163   //Set up visual properties.
1164   Property::Map propertyMap;
1165   propertyMap.Insert( Toolkit::Visual::Property::TYPE,  Visual::MESH );
1166   propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1167
1168   //Test to see if mesh loads correctly.
1169   MeshVisualLoadsCorrectlyTest( propertyMap, application );
1170
1171   END_TEST;
1172 }
1173
1174
1175 //Test if mesh loads correctly when supplied with an object file as well as a blank material file and images directory.
1176 int UtcDaliVisualFactoryGetMeshVisual2(void)
1177 {
1178   //Set up test application first, so everything else can be handled.
1179   ToolkitTestApplication application;
1180
1181   tet_infoline( "UtcDaliVisualFactoryGetMeshVisual2:  Request mesh visual with blank material file and images directory" );
1182
1183   //Set up visual properties.
1184   Property::Map propertyMap;
1185   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::MESH );
1186   propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1187   propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, "" );
1188   propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, "" );
1189
1190   //Test to see if mesh loads correctly.
1191   MeshVisualLoadsCorrectlyTest( propertyMap, application );
1192
1193   END_TEST;
1194 }
1195
1196 //Test if mesh loads correctly when supplied with all main parameters, an object file, a material file and a directory location, but duff optional parameters
1197 int UtcDaliVisualFactoryGetMeshVisual3b(void)
1198 {
1199   //Set up test application first, so everything else can be handled.
1200   ToolkitTestApplication application;
1201
1202   tet_infoline( "UtcDaliVisualFactoryGetMeshVisual3:  Request mesh visual with all parameters correct" );
1203
1204   //Set up visual properties.
1205   Property::Map propertyMap;
1206   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::MESH );
1207   propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1208   propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1209   propertyMap.Insert( MeshVisual::Property::USE_MIPMAPPING, Color::GREEN ); // Test that wrong property types don't prevent the object load
1210   propertyMap.Insert( MeshVisual::Property::USE_SOFT_NORMALS, 1.0f );
1211   propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, 1.0f );
1212   propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1213
1214   //Test to see if mesh loads correctly.
1215   MeshVisualLoadsCorrectlyTest( propertyMap, application );
1216
1217   END_TEST;
1218 }
1219
1220 //Test if mesh loads correctly when supplied with all main parameters, an object file, a material file and a directory location.
1221 int UtcDaliVisualFactoryGetMeshVisual3(void)
1222 {
1223   //Set up test application first, so everything else can be handled.
1224   ToolkitTestApplication application;
1225
1226   tet_infoline( "UtcDaliVisualFactoryGetMeshVisual3:  Request mesh visual with all parameters correct" );
1227
1228   //Set up visual properties.
1229   Property::Map propertyMap;
1230   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::MESH );
1231   propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1232   propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1233   propertyMap.Insert( MeshVisual::Property::USE_MIPMAPPING, false );
1234   propertyMap.Insert( MeshVisual::Property::USE_SOFT_NORMALS, false );
1235   propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3::XAXIS );
1236   propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1237
1238   //Test to see if mesh loads correctly.
1239   MeshVisualLoadsCorrectlyTest( propertyMap, application );
1240
1241   END_TEST;
1242 }
1243
1244 //Test if mesh visual can load a correctly supplied mesh without a normal map or gloss map in the material file.
1245 int UtcDaliVisualFactoryGetMeshVisual4(void)
1246 {
1247   //Set up test application first, so everything else can be handled.
1248   ToolkitTestApplication application;
1249
1250   tet_infoline( "UtcDaliVisualFactoryGetMeshVisual4:  Request mesh visual with diffuse texture but not normal or gloss." );
1251
1252
1253   //Set up visual properties.
1254   Property::Map propertyMap;
1255   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::MESH );
1256   propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1257   propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_SIMPLE_MTL_FILE_NAME );
1258   propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1259
1260   //Test to see if mesh loads correctly.
1261   MeshVisualLoadsCorrectlyTest( propertyMap, application );
1262
1263   END_TEST;
1264 }
1265
1266 //Test if mesh visual can load when made to use diffuse textures only.
1267 int UtcDaliVisualFactoryGetMeshVisual5(void)
1268 {
1269   //Set up test application first, so everything else can be handled.
1270   ToolkitTestApplication application;
1271
1272   tet_infoline( "UtcDaliVisualFactoryGetMeshVisual5:  Request mesh visual and make it only use diffuse textures." );
1273
1274   //Set up visual properties.
1275   Property::Map propertyMap;
1276   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::MESH );
1277   propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME );
1278   propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME );
1279   propertyMap.Insert( "texturesPath", TEST_RESOURCE_DIR "/" );
1280   propertyMap.Insert( "useMipmapping", false );
1281   propertyMap.Insert( "useSoftNormals", false );
1282   propertyMap.Insert( "lightPosition", Vector3::ZAXIS );
1283   propertyMap.Insert( "shadingMode", MeshVisual::ShadingMode::TEXTURED_WITH_SPECULAR_LIGHTING );
1284
1285   //Test to see if mesh loads correctly.
1286   MeshVisualLoadsCorrectlyTest( propertyMap, application );
1287
1288
1289   END_TEST;
1290 }
1291
1292 //Test if mesh visual can load when made to not use the supplied textures.
1293 int UtcDaliVisualFactoryGetMeshVisual6(void)
1294 {
1295   //Set up test application first, so everything else can be handled.
1296   ToolkitTestApplication application;
1297
1298   tet_infoline( "UtcDaliVisualFactoryGetMeshVisual6:  Request mesh visual and make it not use any textures." );
1299
1300   //Set up visual properties.
1301   Property::Map propertyMap;
1302   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::MESH );
1303   propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1304   propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1305   propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1306   propertyMap.Insert( MeshVisual::Property::SHADING_MODE, MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING );
1307
1308   //Test to see if mesh loads correctly.
1309   MeshVisualLoadsCorrectlyTest( propertyMap, application );
1310
1311   END_TEST;
1312 }
1313 //Test if mesh visual loads correctly when light position is manually set.
1314 int UtcDaliVisualFactoryGetMeshVisual7(void)
1315 {
1316   //Set up test application first, so everything else can be handled.
1317   ToolkitTestApplication application;
1318
1319
1320   tet_infoline( "UtcDaliVisualFactoryGetMeshVisual7:  Request mesh visual with custom light position." );
1321
1322   //Set up visual properties.
1323   Property::Map propertyMap;
1324   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::MESH );
1325   propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1326   propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1327   propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1328   propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.0, 1.0, 2.0 ) );
1329
1330   //Test to see if mesh loads correctly.
1331   MeshVisualLoadsCorrectlyTest( propertyMap, application );
1332
1333   END_TEST;
1334 }
1335
1336 //Test if mesh visual loads correctly when supplied an object file without face normals or texture points.
1337 //Note that this notably tests object loader functionality.
1338 int UtcDaliVisualFactoryGetMeshVisual8(void)
1339 {
1340   //Set up test application first, so everything else can be handled.
1341   ToolkitTestApplication application;
1342
1343   tet_infoline( "UtcDaliVisualFactoryGetMeshVisual5:  Request mesh visual with normal-less object file." );
1344
1345   //Set up visual properties.
1346   Property::Map propertyMap;
1347   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::MESH );
1348   propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_SIMPLE_OBJ_FILE_NAME );
1349   propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1350   propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1351
1352   //Test to see if mesh loads correctly.
1353   MeshVisualLoadsCorrectlyTest( propertyMap, application );
1354
1355   END_TEST;
1356 }
1357
1358 //Test if mesh visual handles the case of lacking an object file.
1359 int UtcDaliVisualFactoryGetMeshVisualN1(void)
1360 {
1361   //Set up test application first, so everything else can be handled.
1362   ToolkitTestApplication application;
1363
1364   tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN1:  Request mesh visual without object file" );
1365
1366   //Set up visual properties.
1367   Property::Map propertyMap;
1368   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::MESH );
1369   propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1370   propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1371
1372   //Test to see if mesh doesn't load with these properties, as expected.
1373   MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
1374
1375
1376   END_TEST;
1377 }
1378
1379 //Test if mesh visual handles the case of being passed invalid material and images urls.
1380 int UtcDaliVisualFactoryGetMeshVisualN2(void)
1381 {
1382   //Set up test application first, so everything else can be handled.
1383   ToolkitTestApplication application;
1384
1385   tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN2:  Request mesh visual with invalid material and images urls" );
1386
1387   //Set up visual properties.
1388   Property::Map propertyMap;
1389   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::MESH );
1390   propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1391   propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, "invalid" );
1392   propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, "also invalid" );
1393
1394   //Test to see if mesh doesn't load with these properties, as expected.
1395   MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
1396
1397
1398   END_TEST;
1399 }
1400
1401 //Test if mesh visual handles the case of being passed an invalid object url
1402 int UtcDaliVisualFactoryGetMeshVisualN3(void)
1403 {
1404   //Set up test application first, so everything else can be handled.
1405   ToolkitTestApplication application;
1406   tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN3:  Request mesh visual with invalid object url" );
1407
1408
1409   //Set up visual properties.
1410   Property::Map propertyMap;
1411   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::MESH );
1412   propertyMap.Insert( MeshVisual::Property::OBJECT_URL, "invalid" );
1413   propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1414   propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1415
1416   //Test to see if mesh doesn't load with these properties, as expected.
1417   MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
1418
1419   END_TEST;
1420 }
1421
1422 //Creates a primitive visual with the given property map and tests to see if it correctly loads in the given application.
1423 void TestPrimitiveVisualWithProperties( Property::Map& propertyMap, ToolkitTestApplication& application )
1424 {
1425   VisualFactory factory = VisualFactory::Get();
1426   DALI_TEST_CHECK( factory );
1427
1428   //Create a primitive visual.
1429   Visual::Base visual = factory.CreateVisual( propertyMap );
1430   DALI_TEST_CHECK( visual );
1431
1432   //Create an actor on stage to house the visual.
1433   DummyControl actor = DummyControl::New(true);
1434   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1435   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
1436
1437   actor.SetSize( 200.f, 200.f );
1438   Stage::GetCurrent().Add( actor );
1439   visual.SetTransformAndSize(DefaultTransform(),  Vector2( 200.f, 200.f ) );
1440
1441   //Ensure set on stage.
1442   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1443
1444   //Tell test application to load the visual.
1445   application.SendNotification();
1446   application.Render(0);
1447
1448   Matrix testScaleMatrix;
1449   testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
1450   Matrix actualScaleMatrix;
1451
1452   //Test to see if the object has been successfully loaded.
1453   DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
1454   DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1455
1456   //Finish by setting off stage, and ensuring this was successful.
1457   actor.Unparent();
1458   DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1459 }
1460
1461 //Test if primitive shape loads correctly when supplied with only the bare minimum requirements, the shape to use.
1462 int UtcDaliVisualFactoryGetPrimitiveVisual1(void)
1463 {
1464   //Set up test application first, so everything else can be handled.
1465   ToolkitTestApplication application;
1466
1467   tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual1:  Request primitive visual with a shape only" );
1468
1469   //Set up visual properties.
1470   Property::Map propertyMap;
1471   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
1472   propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
1473
1474   //Test to see if shape loads correctly.
1475   TestPrimitiveVisualWithProperties( propertyMap, application );
1476
1477   END_TEST;
1478 }
1479
1480 //Test if primitive shape loads correctly when supplied with all possible parameters
1481 int UtcDaliVisualFactoryGetPrimitiveVisual2(void)
1482 {
1483   //Set up test application first, so everything else can be handled.
1484   ToolkitTestApplication application;
1485
1486   tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual2:  Request primitive visual with everything" );
1487
1488   //Set up visual properties.
1489   Property::Map propertyMap;
1490   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
1491   propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
1492   propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1493   propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1494   propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
1495   propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
1496   propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f );
1497   propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
1498   propertyMap.Insert( PrimitiveVisual::Property::SCALE_RADIUS, 60.0f );
1499   propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.7f );
1500   propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, 0.8f );
1501   propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.9, 1.0, 1.1 ) );
1502
1503   //Test to see if shape loads correctly.
1504   TestPrimitiveVisualWithProperties( propertyMap, application );
1505
1506   END_TEST;
1507 }
1508
1509 //Test if primitive shape loads a sphere correctly.
1510 int UtcDaliVisualFactoryGetPrimitiveVisual3(void)
1511 {
1512   //Set up test application first, so everything else can be handled.
1513   ToolkitTestApplication application;
1514
1515   tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual3:  Request primitive visual to display a sphere" );
1516
1517   //Set up visual properties.
1518   Property::Map propertyMap;
1519   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
1520   propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1521   propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1522   propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1523   propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
1524
1525   //Test to see if shape loads correctly.
1526   TestPrimitiveVisualWithProperties( propertyMap, application );
1527
1528   END_TEST;
1529 }
1530
1531 //Test if primitive shape loads a conic section correctly.
1532 int UtcDaliVisualFactoryGetPrimitiveVisual4(void)
1533 {
1534   //Set up test application first, so everything else can be handled.
1535   ToolkitTestApplication application;
1536
1537   tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual4:  Request primitive visual to display a conic section" );
1538
1539   //Set up visual properties.
1540   Property::Map propertyMap;
1541   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
1542   propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONICAL_FRUSTRUM );
1543   propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1544   propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1545   propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
1546   propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f );
1547   propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
1548
1549   //Test to see if shape loads correctly.
1550   TestPrimitiveVisualWithProperties( propertyMap, application );
1551
1552   END_TEST;
1553 }
1554
1555 //Test if primitive shape loads a bevelled cube correctly.
1556 int UtcDaliVisualFactoryGetPrimitiveVisual5(void)
1557 {
1558   //Set up test application first, so everything else can be handled.
1559   ToolkitTestApplication application;
1560
1561   tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual5:  Request primitive visual to display a bevelled cube" );
1562
1563   //Set up visual properties.
1564   Property::Map propertyMap;
1565   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
1566   propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::BEVELLED_CUBE );
1567   propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1568   propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.7f );
1569
1570   //Test to see if shape loads correctly.
1571   TestPrimitiveVisualWithProperties( propertyMap, application );
1572
1573   END_TEST;
1574 }
1575
1576 //Test if primitive shape loads an octahedron correctly.
1577 int UtcDaliVisualFactoryGetPrimitiveVisual6(void)
1578 {
1579   //Set up test application first, so everything else can be handled.
1580   ToolkitTestApplication application;
1581
1582   tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual6:  Request primitive visual to display an octahedron" );
1583
1584   //Set up visual properties.
1585   Property::Map propertyMap;
1586   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
1587   propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::OCTAHEDRON );
1588   propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1589
1590   //Test to see if shape loads correctly.
1591   TestPrimitiveVisualWithProperties( propertyMap, application );
1592
1593   END_TEST;
1594 }
1595
1596 //Test if primitive shape loads a cone correctly.
1597 int UtcDaliVisualFactoryGetPrimitiveVisual7(void)
1598 {
1599   //Set up test application first, so everything else can be handled.
1600   ToolkitTestApplication application;
1601
1602   tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual7:  Request primitive visual to display a cone" );
1603
1604   //Set up visual properties.
1605   Property::Map propertyMap;
1606   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
1607   propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONE );
1608   propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1609   propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1610   propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
1611   propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
1612
1613   //Test to see if shape loads correctly.
1614   TestPrimitiveVisualWithProperties( propertyMap, application );
1615
1616   END_TEST;
1617 }
1618
1619 //Test if primitive shape loads correctly when light position is manually set.
1620 int UtcDaliVisualFactoryGetPrimitiveVisual8(void)
1621 {
1622   //Set up test application first, so everything else can be handled.
1623   ToolkitTestApplication application;
1624
1625   tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual8:  Request primitive visual with set light position" );
1626
1627   //Set up visual properties.
1628   Property::Map propertyMap;
1629   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
1630   propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1631   propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1632   propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.0, 1.0, 2.0 ) );
1633
1634   //Test to see if shape loads correctly.
1635   TestPrimitiveVisualWithProperties( propertyMap, application );
1636
1637   END_TEST;
1638 }
1639
1640 //Test if primitive shape loads correctly when told to use too many slices.
1641 int UtcDaliVisualFactoryGetPrimitiveVisual9(void)
1642 {
1643   //Set up test application first, so everything else can be handled.
1644   ToolkitTestApplication application;
1645
1646   tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual9:  Request primitive visual with above-cap slices." );
1647
1648   //Set up visual properties.
1649   Property::Map propertyMap;
1650   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
1651   propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1652   propertyMap.Insert( PrimitiveVisual::Property::SLICES, Property::Value( 1000000 ) );
1653
1654   //Test to see if shape loads correctly.
1655   TestPrimitiveVisualWithProperties( propertyMap, application );
1656
1657   END_TEST;
1658 }
1659
1660 //Test if primitive shape loads correctly when told to use too few slices. (2 slices or less.)
1661 int UtcDaliVisualFactoryGetPrimitiveVisual10(void)
1662 {
1663   //Set up test application first, so everything else can be handled.
1664   ToolkitTestApplication application;
1665
1666   tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual10:  Request primitive visual with too few slices." );
1667
1668   //Set up visual properties.
1669   Property::Map propertyMap;
1670   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
1671   propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1672   propertyMap.Insert( PrimitiveVisual::Property::SLICES, Property::Value( 2 ) );
1673
1674   //Test to see if shape loads correctly.
1675   TestPrimitiveVisualWithProperties( propertyMap, application );
1676
1677   END_TEST;
1678 }
1679
1680 //Test if primitive shape loads correctly when told to use too many stacks.
1681 int UtcDaliVisualFactoryGetPrimitiveVisual11(void)
1682 {
1683   //Set up test application first, so everything else can be handled.
1684   ToolkitTestApplication application;
1685
1686   tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual11:  Request primitive visual with too many stacks." );
1687
1688   //Set up visual properties.
1689   Property::Map propertyMap;
1690   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
1691   propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1692   propertyMap.Insert( PrimitiveVisual::Property::STACKS, Property::Value( 1000000 ) );
1693
1694   //Test to see if shape loads correctly.
1695   TestPrimitiveVisualWithProperties( propertyMap, application );
1696
1697   END_TEST;
1698 }
1699
1700 //Test if primitive shape loads correctly when told to use too few stacks. (1 stack or less.)
1701 int UtcDaliVisualFactoryGetPrimitiveVisual12(void)
1702 {
1703   //Set up test application first, so everything else can be handled.
1704   ToolkitTestApplication application;
1705
1706   tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual12:  Request primitive visual with too few stacks." );
1707
1708   //Set up visual properties.
1709   Property::Map propertyMap;
1710   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
1711   propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1712   propertyMap.Insert( PrimitiveVisual::Property::STACKS, Property::Value( 1 ) );
1713
1714   //Test to see if shape loads correctly.
1715   TestPrimitiveVisualWithProperties( propertyMap, application );
1716
1717   END_TEST;
1718 }
1719
1720 //Test if primitive shape loads correctly when told to use invalid (zero or negative) dimensions.
1721 int UtcDaliVisualFactoryGetPrimitiveVisual13(void)
1722 {
1723   //Set up test application first, so everything else can be handled.
1724   ToolkitTestApplication application;
1725
1726   tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual13:  Request primitive visual with invalid scale dimensions." );
1727
1728   //Set up visual properties.
1729   Property::Map propertyMap;
1730   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
1731   propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1732   propertyMap.Insert( PrimitiveVisual::Property::SCALE_DIMENSIONS, Vector3::ZERO );
1733
1734   //Test to see if shape loads correctly.
1735   TestPrimitiveVisualWithProperties( propertyMap, application );
1736
1737   END_TEST;
1738 }
1739
1740 //Test if primitive shape loads correctly when told to use too low a bevel percentage.
1741 int UtcDaliVisualFactoryGetPrimitiveVisual14(void)
1742 {
1743   //Set up test application first, so everything else can be handled.
1744   ToolkitTestApplication application;
1745
1746   tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual14:  Request primitive visual with too low a bevel percentage." );
1747
1748   //Set up visual properties.
1749   Property::Map propertyMap;
1750   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
1751   propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1752   propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, Property::Value( -1.0f ) );
1753
1754   //Test to see if shape loads correctly.
1755   TestPrimitiveVisualWithProperties( propertyMap, application );
1756
1757   END_TEST;
1758 }
1759
1760 //Test if primitive shape loads correctly when told to use too high a bevel percentage.
1761 int UtcDaliVisualFactoryGetPrimitiveVisual15(void)
1762 {
1763   //Set up test application first, so everything else can be handled.
1764   ToolkitTestApplication application;
1765
1766   tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual15:  Request primitive visual with too high a bevel percentage." );
1767
1768   //Set up visual properties.
1769   Property::Map propertyMap;
1770   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
1771   propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1772   propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, Property::Value( 2.0f ) );
1773
1774   //Test to see if shape loads correctly.
1775   TestPrimitiveVisualWithProperties( propertyMap, application );
1776
1777   END_TEST;
1778 }
1779
1780 //Test if primitive shape loads correctly when told to use too low a bevel smoothness.
1781 int UtcDaliVisualFactoryGetPrimitiveVisual16(void)
1782 {
1783   //Set up test application first, so everything else can be handled.
1784   ToolkitTestApplication application;
1785
1786   tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual16:  Request primitive visual with too low a bevel smoothness." );
1787
1788   //Set up visual properties.
1789   Property::Map propertyMap;
1790   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
1791   propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1792   propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, Property::Value( -1.0f ) );
1793
1794   //Test to see if shape loads correctly.
1795   TestPrimitiveVisualWithProperties( propertyMap, application );
1796
1797   END_TEST;
1798 }
1799
1800 //Test if primitive shape loads correctly when told to use too high a bevel smoothness.
1801 int UtcDaliVisualFactoryGetPrimitiveVisual17(void)
1802 {
1803   //Set up test application first, so everything else can be handled.
1804   ToolkitTestApplication application;
1805
1806   tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual17:  Request primitive visual with too high a bevel smoothness." );
1807
1808   //Set up visual properties.
1809   Property::Map propertyMap;
1810   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
1811   propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1812   propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, Property::Value( 2.0f ) );
1813
1814   //Test to see if shape loads correctly.
1815   TestPrimitiveVisualWithProperties( propertyMap, application );
1816
1817   END_TEST;
1818 }
1819
1820 //Test if primitive shape visual handles the case of not being passed a specific shape to use.
1821 int UtcDaliVisualFactoryGetPrimitiveVisualN1(void)
1822 {
1823   //Set up test application first, so everything else can be handled.
1824   ToolkitTestApplication application;
1825
1826   tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisualN1:  Request primitive visual without shape" );
1827
1828   //Set up visual properties, without supplying shape.
1829   Property::Map propertyMap;
1830   propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
1831
1832   //Test to see if shape loads regardless of missing input.
1833   TestPrimitiveVisualWithProperties( propertyMap, application );
1834
1835   END_TEST;
1836 }
1837
1838 int UtcDaliVisualFactoryGetAnimatedImageVisual1(void)
1839 {
1840   ToolkitTestApplication application;
1841   tet_infoline( "UtcDaliVisualFactoryGetAnimatedImageVisual1: Request animated image visual with a gif url" );
1842
1843   VisualFactory factory = VisualFactory::Get();
1844   Visual::Base visual = factory.CreateVisual( TEST_GIF_FILE_NAME, ImageDimensions() );
1845   DALI_TEST_CHECK( visual );
1846
1847   TestGlAbstraction& gl = application.GetGlAbstraction();
1848   TraceCallStack& textureTrace = gl.GetTextureTrace();
1849   textureTrace.Enable(true);
1850
1851   DummyControl actor = DummyControl::New(true);
1852   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1853   dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
1854   actor.SetSize( 200.0f, 200.0f );
1855   Stage::GetCurrent().Add( actor );
1856
1857   application.SendNotification();
1858   application.Render();
1859
1860   // renderer is added to actor
1861   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
1862
1863   // test the uniforms which used to handle the atlas rect
1864   // the four frames should be located inside atlas as follows: atlas size 100*100
1865   // -------------
1866   // |     |     |
1867   // |  0  |  1  |
1868   // -------------
1869   // |     |     |
1870   // |  2  |  3  |
1871   // -------------
1872
1873   Renderer renderer = actor.GetRendererAt( 0u );
1874   DALI_TEST_CHECK( renderer );
1875
1876   Property::Value atlasRectValue = renderer.GetProperty( renderer.GetPropertyIndex( "uAtlasRect" ) );
1877   // take into consideration the half pixel correction
1878   DALI_TEST_EQUALS( atlasRectValue.Get<Vector4>(), Vector4(0.5f, 0.5f, 49.5f, 49.5f)/100.f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1879
1880   // waiting for the resource uploading
1881   application.SendNotification();
1882   application.Render();
1883
1884   DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1885
1886   // Force the timer used by the animatedImageVisual to tick,
1887   Dali::Timer timer = Timer::New( 0 );
1888   timer.MockEmitSignal();
1889   application.SendNotification();
1890   application.Render();
1891   atlasRectValue = renderer.GetProperty( renderer.GetPropertyIndex( "uAtlasRect" ) );
1892   // take into consideration the half pixel correction
1893   DALI_TEST_EQUALS( atlasRectValue.Get<Vector4>(), Vector4(50.5f, 0.5f, 99.5f, 49.5f)/100.f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1894
1895   // Force the timer used by the animatedImageVisual to tick,
1896   timer.MockEmitSignal();
1897   application.SendNotification();
1898   application.Render();
1899   atlasRectValue = renderer.GetProperty( renderer.GetPropertyIndex( "uAtlasRect" ) );
1900   // take into consideration the half pixel correction
1901   DALI_TEST_EQUALS( atlasRectValue.Get<Vector4>(), Vector4(0.5f, 50.5f, 49.5f, 99.5f)/100.f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1902
1903   // Force the timer used by the animatedImageVisual to tick,
1904   timer.MockEmitSignal();
1905   application.SendNotification();
1906   application.Render();
1907   atlasRectValue = renderer.GetProperty( renderer.GetPropertyIndex( "uAtlasRect" ) );
1908   // take into consideration the half pixel correction
1909   DALI_TEST_EQUALS( atlasRectValue.Get<Vector4>(), Vector4(50.5f, 50.5f, 99.5f, 99.5f)/100.f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1910
1911   // Test SetOffStage().
1912   actor.Unparent();
1913   DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1914
1915   END_TEST;
1916 }
1917
1918 int UtcDaliVisualFactoryGetAnimatedImageVisual2(void)
1919 {
1920   ToolkitTestApplication application;
1921   tet_infoline( "UtcDaliVisualFactoryGetAnimatedImageVisual2: Request animated image visual with a Property::Map, test custom wrap mode and pixel area" );
1922
1923   const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
1924   Property::Map propertyMap;
1925   propertyMap.Add( Toolkit::Visual::Property::TYPE,  Visual::IMAGE  )
1926              .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME  )
1927              .Add( ImageVisual::Property::PIXEL_AREA, pixelArea )
1928              .Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT )
1929              .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT );
1930
1931   Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
1932   DALI_TEST_CHECK( visual );
1933
1934   TestGlAbstraction& gl = application.GetGlAbstraction();
1935   TraceCallStack& textureTrace = gl.GetTextureTrace();
1936   textureTrace.Enable(true);
1937   TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
1938   texParameterTrace.Enable( true );
1939
1940   DummyControl actor = DummyControl::New(true);
1941   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1942   dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1943   actor.SetSize( 200.0f, 200.0f );
1944   Stage::GetCurrent().Add( actor );
1945
1946   application.SendNotification();
1947   application.Render();
1948
1949   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
1950
1951   DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1952
1953   // For animated image visual, the wrapping is handled manually in shader, so the following gl function should not be called
1954   std::stringstream out;
1955   out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
1956   DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
1957   out.str("");
1958   out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
1959   DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
1960
1961   // test the uniforms which used to handle the wrap mode
1962   Renderer renderer = actor.GetRendererAt( 0u );
1963   DALI_TEST_CHECK( renderer );
1964
1965   Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
1966   DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION );
1967   Vector4 pixelAreaUniform;
1968   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
1969   DALI_TEST_EQUALS( pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1970
1971   Property::Value wrapModeValue = renderer.GetProperty( renderer.GetPropertyIndex( "wrapMode" ) );
1972   Vector2 wrapMode( WrapMode::MIRRORED_REPEAT-1, WrapMode::REPEAT-1 );
1973   DALI_TEST_EQUALS( wrapModeValue.Get<Vector2>(), wrapMode, TEST_LOCATION );
1974   Vector2 wrapModeUniform;
1975   DALI_TEST_CHECK( gl.GetUniformValue<Vector2>( "wrapMode", wrapModeUniform ) );
1976   DALI_TEST_EQUALS( wrapMode, wrapModeUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1977
1978   actor.Unparent( );
1979   DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1980
1981   END_TEST;
1982 }