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