2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali-toolkit-test-suite-utils.h>
20 #include <toolkit-timer.h>
21 #include <toolkit-bitmap-loader.h>
22 #include <toolkit-event-thread-callback.h>
23 #include <dali/public-api/rendering/renderer.h>
24 #include <dali/public-api/rendering/texture-set.h>
25 #include <dali/public-api/rendering/shader.h>
26 #include <dali/devel-api/images/nine-patch-image.h>
27 #include <dali-toolkit/devel-api/align-enums.h>
28 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
29 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
30 #include <dali-toolkit/dali-toolkit.h>
31 #include "dummy-control.h"
34 using namespace Dali::Toolkit;
38 typedef NinePatchImage::StretchRanges StretchRanges;
40 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
41 const char* TEST_NPATCH_FILE_NAME = "gallery_image_01.9.png";
42 const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
43 const char* TEST_OBJ_FILE_NAME = TEST_RESOURCE_DIR "/Cube.obj";
44 const char* TEST_MTL_FILE_NAME = TEST_RESOURCE_DIR "/ToyRobot-Metal.mtl";
45 const char* TEST_SIMPLE_OBJ_FILE_NAME = TEST_RESOURCE_DIR "/Cube-Points-Only.obj";
46 const char* TEST_SIMPLE_MTL_FILE_NAME = TEST_RESOURCE_DIR "/ToyRobot-Metal-Simple.mtl";
48 // resolution: 50*50, frame count: 4, frame delay: 0.2 second for each frame
49 const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
51 // resolution: 34*34, pixel format: RGBA8888
52 static const char* gImage_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png";
53 // resolution: 600*600, pixel format: RGB888
54 static const char* gImage_600_RGB = TEST_RESOURCE_DIR "/test-image-600.jpg";
56 Property::Map DefaultTransform()
58 Property::Map transformMap;
60 .Add( Toolkit::DevelVisual::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
61 .Add( Toolkit::DevelVisual::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
62 .Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
63 .Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
64 .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO );
68 Integration::Bitmap* CreateBitmap( unsigned int imageWidth, unsigned int imageHeight, unsigned int initialColor, Pixel::Format pixelFormat )
70 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
71 Integration::PixelBuffer* pixbuffer = bitmap->GetPackedPixelsProfile()->ReserveBuffer( pixelFormat, imageWidth, imageHeight, imageWidth, imageHeight );
72 unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
74 memset( pixbuffer, initialColor, imageHeight * imageWidth * bytesPerPixel );
79 void InitialiseRegionsToZeroAlpha( Integration::Bitmap* image, unsigned int imageWidth, unsigned int imageHeight, Pixel::Format pixelFormat )
81 PixelBuffer* pixbuffer = image->GetBuffer();
82 unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
84 for( unsigned int row = 0; row < imageWidth; ++row )
86 unsigned int pixelOffset = row * bytesPerPixel;
87 pixbuffer[ pixelOffset + 3 ] = 0x00;
88 pixelOffset += ( imageHeight - 1 ) * imageWidth * bytesPerPixel;
89 pixbuffer[ pixelOffset + 3 ] = 0x00;
92 for ( unsigned int column = 0; column < imageHeight; ++column )
94 unsigned int pixelOffset = column * imageWidth * bytesPerPixel;
95 pixbuffer[ pixelOffset + 3 ] = 0x00;
96 pixelOffset += ( imageWidth -1 ) * bytesPerPixel;
97 pixbuffer[ pixelOffset + 3 ] = 0x00;
101 void AddStretchRegionsToImage( Integration::Bitmap* image, unsigned int imageWidth, unsigned int imageHeight, const StretchRanges& stretchRangesX, const StretchRanges& stretchRangesY, Pixel::Format pixelFormat )
103 PixelBuffer* pixbuffer = image->GetBuffer();
104 unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
106 for(StretchRanges::ConstIterator it = stretchRangesX.Begin(); it != stretchRangesX.End(); ++it)
108 const Uint16Pair& range = *it;
109 //since the stretch range is in the cropped image space, we need to offset by 1 to get it to the uncropped image space
110 for( unsigned int column = range.GetX() + 1u; column < range.GetY() + 1u; ++column )
112 unsigned int pixelOffset = column * bytesPerPixel;
113 pixbuffer[ pixelOffset ] = 0x00;
114 pixbuffer[ pixelOffset + 1 ] = 0x00;
115 pixbuffer[ pixelOffset + 2 ] = 0x00;
116 pixbuffer[ pixelOffset + 3 ] = 0xFF;
121 for(StretchRanges::ConstIterator it = stretchRangesY.Begin(); it != stretchRangesY.End(); ++it)
123 const Uint16Pair& range = *it;
124 //since the stretch range is in the cropped image space, we need to offset by 1 to get it to the uncropped image space
125 for( unsigned int row = range.GetX() + 1u; row < range.GetY() + 1u; ++row )
127 unsigned int pixelOffset = row * imageWidth * bytesPerPixel;
128 pixbuffer[ pixelOffset ] = 0x00;
129 pixbuffer[ pixelOffset + 1 ] = 0x00;
130 pixbuffer[ pixelOffset + 2 ] = 0x00;
131 pixbuffer[ pixelOffset + 3 ] = 0xFF;
136 void AddChildRegionsToImage( Integration::Bitmap* image, unsigned int imageWidth, unsigned int imageHeight, const Vector4& requiredChildRegion, Pixel::Format pixelFormat )
138 PixelBuffer* pixbuffer = image->GetBuffer();
139 unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
141 Integration::Bitmap::PackedPixelsProfile* srcProfile = image->GetPackedPixelsProfile();
142 unsigned int bufferStride = srcProfile->GetBufferStride();
144 // Add bottom child region
145 for( unsigned int column = requiredChildRegion.x; column < imageWidth - requiredChildRegion.z; ++column )
147 unsigned int pixelOffset = column * bytesPerPixel;
148 pixelOffset += ( imageHeight - 1 ) * bufferStride;
149 pixbuffer[ pixelOffset ] = 0x00;
150 pixbuffer[ pixelOffset + 1 ] = 0x00;
151 pixbuffer[ pixelOffset + 2 ] = 0x00;
152 pixbuffer[ pixelOffset + 3 ] = 0xFF;
155 // Add right child region
156 for ( unsigned int row = requiredChildRegion.y; row < imageHeight - requiredChildRegion.w; ++row )
158 unsigned int pixelOffset = row * bufferStride + ( imageWidth - 1 ) * bytesPerPixel;
159 pixbuffer[ pixelOffset ] = 0x00;
160 pixbuffer[ pixelOffset + 1 ] = 0x00;
161 pixbuffer[ pixelOffset + 2 ] = 0x00;
162 pixbuffer[ pixelOffset + 3 ] = 0xFF;
166 Integration::ResourcePointer CustomizeNinePatch( TestApplication& application,
167 unsigned int ninePatchImageWidth,
168 unsigned int ninePatchImageHeight,
169 const StretchRanges& stretchRangesX,
170 const StretchRanges& stretchRangesY,
171 bool addChildRegion = false,
172 Vector4 requiredChildRegion = Vector4::ZERO )
174 TestPlatformAbstraction& platform = application.GetPlatform();
176 Pixel::Format pixelFormat = Pixel::RGBA8888;
178 tet_infoline("Create Bitmap");
179 platform.SetClosestImageSize(Vector2( ninePatchImageWidth, ninePatchImageHeight));
180 Integration::Bitmap* bitmap = CreateBitmap( ninePatchImageWidth, ninePatchImageHeight, 0xFF, pixelFormat );
182 tet_infoline("Clear border regions");
183 InitialiseRegionsToZeroAlpha( bitmap, ninePatchImageWidth, ninePatchImageHeight, pixelFormat );
185 tet_infoline("Add Stretch regions to Bitmap");
186 AddStretchRegionsToImage( bitmap, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY, pixelFormat );
190 tet_infoline("Add Child regions to Bitmap");
191 AddChildRegionsToImage( bitmap, ninePatchImageWidth, ninePatchImageHeight, requiredChildRegion, pixelFormat );
194 tet_infoline("Getting resource");
195 Integration::ResourcePointer resourcePtr(bitmap);
196 //platform.SetResourceLoaded( 0, Dali::Integration::ResourceBitmap, resourcePtr );
197 platform.SetSynchronouslyLoadedResource( resourcePtr);
202 void TestVisualRender( ToolkitTestApplication& application,
204 Visual::Base& visual,
205 std::size_t expectedSamplers = 0,
206 ImageDimensions imageDimensions = ImageDimensions(),
207 Integration::ResourcePointer resourcePtr = Integration::ResourcePointer())
209 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
210 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
214 // set the image size, for test case, this needs to be set before loading started
215 application.GetPlatform().SetClosestImageSize( Vector2(imageDimensions.GetWidth(), imageDimensions.GetHeight()) );
218 actor.SetSize( 200.f, 200.f );
219 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
221 Stage::GetCurrent().Add( actor );
223 application.SendNotification();
224 application.Render();
228 Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
231 application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resourcePtr );
235 application.Render();
236 application.SendNotification();
240 DALI_TEST_EQUALS( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ||
241 application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceSynchronouslyFunc ), true, TEST_LOCATION);
244 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
251 void dali_visual_factory_startup(void)
253 test_return_value = TET_UNDEF;
256 void dali_visual_factory_cleanup(void)
258 test_return_value = TET_PASS;
261 int UtcDaliVisualFactoryGet(void)
263 ToolkitTestApplication application;
264 tet_infoline( "UtcDaliVisualFactory" );
268 type = TypeRegistry::Get().GetTypeInfo( "VisualFactory" );
269 DALI_TEST_CHECK( type );
270 BaseHandle handle = type.CreateInstance();
271 DALI_TEST_CHECK( handle );
273 VisualFactory factory;
274 factory = VisualFactory::Get();
275 DALI_TEST_CHECK( factory );
277 VisualFactory newFactory = VisualFactory::Get();
278 DALI_TEST_CHECK( newFactory );
280 // Check that visual factory is a singleton
281 DALI_TEST_CHECK(factory == newFactory);
286 int UtcDaliVisualFactoryCopyAndAssignment(void)
288 ToolkitTestApplication application;
289 tet_infoline( "UtcDaliVisualFactoryCopyAndAssignment" );
290 VisualFactory factory = VisualFactory::Get();
292 VisualFactory factoryCopy( factory );
293 DALI_TEST_CHECK(factory == factoryCopy);
295 VisualFactory emptyFactory;
296 VisualFactory emptyFactoryCopy( emptyFactory );
297 DALI_TEST_CHECK(emptyFactory == emptyFactoryCopy);
299 VisualFactory factoryEquals;
300 factoryEquals = factory;
301 DALI_TEST_CHECK(factory == factoryEquals);
303 VisualFactory emptyFactoryEquals;
304 emptyFactoryEquals = emptyFactory;
305 DALI_TEST_CHECK( emptyFactory == emptyFactoryEquals );
309 DALI_TEST_CHECK( factory = factoryCopy );
314 int UtcDaliVisualFactoryGetColorVisual1(void)
316 ToolkitTestApplication application;
317 tet_infoline( "UtcDaliVisualFactoryGetColorVisual1: Request color visual with a Property::Map" );
319 VisualFactory factory = VisualFactory::Get();
320 DALI_TEST_CHECK( factory );
322 Property::Map propertyMap;
323 Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
324 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
325 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, testColor);
327 Visual::Base visual = factory.CreateVisual(propertyMap);
328 DALI_TEST_CHECK( visual );
330 DummyControl actor = DummyControl::New();
331 TestVisualRender( application, actor, visual );
333 Vector4 actualValue(Vector4::ZERO);
334 TestGlAbstraction& gl = application.GetGlAbstraction();
335 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "mixColor", actualValue ) );
336 DALI_TEST_EQUALS( actualValue, testColor, TEST_LOCATION );
341 int UtcDaliVisualFactoryGetColorVisual2(void)
343 ToolkitTestApplication application;
344 tet_infoline( "UtcDaliVisualFactoryGetColorVisual2: Request color visual with a Vector4" );
346 VisualFactory factory = VisualFactory::Get();
347 DALI_TEST_CHECK( factory );
349 Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
350 Dali::Property::Map map;
351 map[ Visual::Property::TYPE ] = Visual::COLOR;
352 map[ ColorVisual::Property::MIX_COLOR ] = testColor;
353 Visual::Base visual = factory.CreateVisual( map );
354 DALI_TEST_CHECK( visual );
356 DummyControl actor = DummyControl::New();
357 TestVisualRender( application, actor, visual );
359 Vector4 actualValue(Vector4::ZERO);
360 TestGlAbstraction& gl = application.GetGlAbstraction();
361 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "mixColor", actualValue ) );
362 DALI_TEST_EQUALS( actualValue, testColor, TEST_LOCATION );
364 Stage::GetCurrent().Remove(actor);
365 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
370 int UtcDaliVisualFactoryGetBorderVisual1(void)
372 ToolkitTestApplication application;
373 tet_infoline( "UtcDaliVisualFactoryGetBorderVisual1: Request border visual with a Property::Map" );
375 VisualFactory factory = VisualFactory::Get();
376 DALI_TEST_CHECK( factory );
378 Property::Map propertyMap;
379 Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
380 float testSize = 5.f;
381 propertyMap.Insert(Visual::Property::TYPE, Visual::BORDER);
382 propertyMap.Insert(BorderVisual::Property::COLOR, testColor);
383 propertyMap.Insert(BorderVisual::Property::SIZE, testSize);
385 Visual::Base visual = factory.CreateVisual(propertyMap);
386 DALI_TEST_CHECK( visual );
388 DummyControl actor = DummyControl::New();
389 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
390 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
391 actor.SetSize(200.f, 200.f);
392 Stage::GetCurrent().Add( actor );
393 visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f));
395 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
396 int blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLEND_MODE );
397 DALI_TEST_EQUALS( static_cast<BlendMode::Type>(blendMode), BlendMode::ON, TEST_LOCATION );
399 TestGlAbstraction& gl = application.GetGlAbstraction();
401 application.SendNotification();
402 application.Render(0);
404 Vector4 actualColor(Vector4::ZERO);
405 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "borderColor", actualColor ) );
406 DALI_TEST_EQUALS( actualColor, testColor, TEST_LOCATION );
408 float actualSize = 0.f;
409 DALI_TEST_CHECK( gl.GetUniformValue<float>( "borderSize", actualSize ) );
410 DALI_TEST_EQUALS( actualSize, testSize, TEST_LOCATION );
413 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
418 int UtcDaliVisualFactoryGetBorderVisual2(void)
420 ToolkitTestApplication application;
421 tet_infoline( "UtcDaliVisualFactoryGetBorderVisual2: Request border visual with a borderSize and a borderColor" );
423 VisualFactory factory = VisualFactory::Get();
424 DALI_TEST_CHECK( factory );
426 Vector4 testColor( 1.f, 0.5f, 0.3f, 1.f );
427 float testSize = 5.f;
429 Dali::Property::Map propertyMap;
430 propertyMap[ Visual::Property::TYPE ] = Visual::BORDER;
431 propertyMap[ BorderVisual::Property::COLOR ] = testColor;
432 propertyMap[ BorderVisual::Property::SIZE ] = testSize;
433 Visual::Base visual = factory.CreateVisual( propertyMap );
434 DALI_TEST_CHECK( visual );
436 DummyControl actor = DummyControl::New();
437 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
438 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
439 actor.SetSize(200.f, 200.f);
440 Stage::GetCurrent().Add( actor );
441 visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f));
443 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
445 TestGlAbstraction& gl = application.GetGlAbstraction();
447 application.SendNotification();
448 application.Render(0);
450 int blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLEND_MODE );
451 DALI_TEST_EQUALS( static_cast<BlendMode::Type>(blendMode), BlendMode::AUTO, TEST_LOCATION );
453 Vector4 actualColor(Vector4::ZERO);
454 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "borderColor", actualColor ) );
455 DALI_TEST_EQUALS( actualColor, testColor, TEST_LOCATION );
457 float actualSize = 0.f;
458 DALI_TEST_CHECK( gl.GetUniformValue<float>( "borderSize", actualSize ) );
459 DALI_TEST_EQUALS( actualSize, testSize, TEST_LOCATION );
463 // enable the anti-aliasing
464 Dali::Property::Map map;
465 map[ Visual::Property::TYPE ] = Visual::BORDER;
466 map[ BorderVisual::Property::COLOR ] = testColor;
467 map[ BorderVisual::Property::SIZE ] = testSize;
468 map[ BorderVisual::Property::ANTI_ALIASING ] = true;
469 visual = factory.CreateVisual( map );
471 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
472 Stage::GetCurrent().Add( actor );
474 blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLEND_MODE );
475 DALI_TEST_EQUALS( static_cast<BlendMode::Type>(blendMode), BlendMode::ON, TEST_LOCATION );
480 int UtcDaliVisualFactoryGetLinearGradientVisual(void)
482 ToolkitTestApplication application;
483 tet_infoline("UtcDaliVisualFactoryGetRadialGradientVisual");
485 VisualFactory factory = VisualFactory::Get();
486 DALI_TEST_CHECK( factory );
488 Property::Map propertyMap;
489 propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
491 Vector2 start(-1.f, -1.f);
492 Vector2 end(1.f, 1.f);
493 propertyMap.Insert(GradientVisual::Property::START_POSITION, start);
494 propertyMap.Insert(GradientVisual::Property::END_POSITION, end);
495 propertyMap.Insert(GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT);
497 Property::Array stopOffsets;
498 stopOffsets.PushBack( 0.2f );
499 stopOffsets.PushBack( 0.8f );
500 propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, stopOffsets);
502 Property::Array stopColors;
503 stopColors.PushBack( Color::RED );
504 stopColors.PushBack( Color::GREEN );
505 propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
507 Visual::Base visual = factory.CreateVisual(propertyMap);
508 DALI_TEST_CHECK( visual );
510 // A lookup texture is generated and pass to shader as sampler
511 DummyControl actor = DummyControl::New();
512 TestVisualRender( application, actor, visual, 1u);
517 int UtcDaliVisualFactoryGetRadialGradientVisual(void)
519 ToolkitTestApplication application;
520 tet_infoline("UtcDaliVisualFactoryGetRadialGradientVisual");
522 VisualFactory factory = VisualFactory::Get();
523 DALI_TEST_CHECK( factory );
525 Property::Map propertyMap;
526 propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
528 Vector2 center(100.f, 100.f);
529 float radius = 100.f;
530 propertyMap.Insert(GradientVisual::Property::UNITS, GradientVisual::Units::USER_SPACE);
531 propertyMap.Insert(GradientVisual::Property::CENTER, center);
532 propertyMap.Insert(GradientVisual::Property::RADIUS, radius);
534 Property::Array stopOffsets;
535 stopOffsets.PushBack( 0.0f );
536 stopOffsets.PushBack( 1.f );
537 propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, stopOffsets);
539 Property::Array stopColors;
540 stopColors.PushBack( Color::RED );
541 stopColors.PushBack( Color::GREEN );
542 propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
544 Visual::Base visual = factory.CreateVisual(propertyMap);
545 DALI_TEST_CHECK( visual );
547 // A lookup texture is generated and pass to shader as sampler
548 DummyControl actor = DummyControl::New();
549 TestVisualRender( application, actor, visual, 1u );
551 Matrix3 alignMatrix( radius, 0.f, 0.f, 0.f, radius, 0.f, center.x, center.y, 1.f );
552 alignMatrix.Invert();
554 Matrix3 actualValue( Matrix3::IDENTITY );
555 TestGlAbstraction& gl = application.GetGlAbstraction();
556 DALI_TEST_CHECK( gl.GetUniformValue<Matrix3>( "uAlignmentMatrix", actualValue ) );
557 DALI_TEST_EQUALS( actualValue, alignMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
562 int UtcDaliVisualFactoryDefaultOffsetsGradientVisual(void)
564 ToolkitTestApplication application;
565 tet_infoline("UtcDaliVisualFactoryGetRadialGradientVisual");
567 VisualFactory factory = VisualFactory::Get();
568 DALI_TEST_CHECK( factory );
570 Property::Map propertyMap;
571 propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
573 Vector2 start(-1.f, -1.f);
574 Vector2 end(1.f, 1.f);
575 propertyMap.Insert(GradientVisual::Property::START_POSITION, start);
576 propertyMap.Insert(GradientVisual::Property::END_POSITION, end);
577 propertyMap.Insert(GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT);
579 Property::Array stopColors;
580 stopColors.PushBack( Color::RED );
581 stopColors.PushBack( Color::GREEN );
582 propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
584 Visual::Base visual = factory.CreateVisual(propertyMap);
585 DALI_TEST_CHECK( visual );
587 // A lookup texture is generated and pass to shader as sampler
588 DummyControl actor = DummyControl::New();
589 TestVisualRender( application, actor, visual, 1u );
591 Stage::GetCurrent().Remove( actor );
592 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
597 int UtcDaliVisualFactoryGetImageVisual1(void)
599 ToolkitTestApplication application;
600 tet_infoline( "UtcDaliVisualFactoryGetImageVisual1: Request image visual with a Property::Map" );
602 VisualFactory factory = VisualFactory::Get();
603 DALI_TEST_CHECK( factory );
605 Property::Map propertyMap;
606 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
607 propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
609 Visual::Base visual = factory.CreateVisual( propertyMap );
610 DALI_TEST_CHECK( visual );
612 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
613 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
616 const int height=513;
617 TestGlAbstraction& gl = application.GetGlAbstraction();
618 TraceCallStack& textureTrace = gl.GetTextureTrace();
619 textureTrace.Enable(true);
621 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
622 bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, width, height,width, height );
624 DummyControl actor = DummyControl::New();
625 TestVisualRender( application, actor, visual, 1u,
626 ImageDimensions(width, height),
627 Integration::ResourcePointer( bitmap ) );
629 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
631 Stage::GetCurrent().Remove( actor );
632 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
637 int UtcDaliVisualFactoryGetImageVisual2(void)
639 ToolkitTestApplication application;
640 tet_infoline( "UtcDaliVisualFactoryGetImageVisual2: Request image visual with an image handle" );
642 VisualFactory factory = VisualFactory::Get();
643 DALI_TEST_CHECK( factory );
645 Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME);
646 Visual::Base visual = factory.CreateVisual( image );
648 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
649 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
652 const int height=513;
654 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
655 bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, width, height,width, height );
657 TestGlAbstraction& gl = application.GetGlAbstraction();
658 TraceCallStack& textureTrace = gl.GetTextureTrace();
659 textureTrace.Enable(true);
661 DummyControl actor = DummyControl::New();
662 TestVisualRender( application, actor, visual, 1u,
663 ImageDimensions(width, height),
664 Integration::ResourcePointer(bitmap) );
666 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
670 int UtcDaliVisualFactoryGetImageVisual3(void)
672 ToolkitTestApplication application;
673 tet_infoline( "UtcDaliVisualFactoryGetImageVisual3: Request image visual with a Property::Map, test custom wrap mode and pixel area with atlasing" );
675 VisualFactory factory = VisualFactory::Get();
676 DALI_TEST_CHECK( factory );
678 // Test wrap mode with atlasing. Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
681 const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
683 Property::Map propertyMap;
684 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
685 propertyMap.Insert( ImageVisual::Property::URL, gImage_34_RGBA );
686 propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, width );
687 propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, height );
688 propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true );
689 propertyMap.Insert( ImageVisual::Property::PIXEL_AREA, pixelArea );
690 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT );
691 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT );
693 Visual::Base visual = factory.CreateVisual( propertyMap );
694 DALI_TEST_CHECK( visual );
696 TestGlAbstraction& gl = application.GetGlAbstraction();
697 TraceCallStack& textureTrace = gl.GetTextureTrace();
698 textureTrace.Enable(true);
699 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
700 texParameterTrace.Enable( true );
702 DummyControl actor = DummyControl::New();
703 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
704 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
705 actor.SetSize(2000, 2000);
706 actor.SetParentOrigin(ParentOrigin::CENTER);
707 Stage::GetCurrent().Add( actor );
710 application.SendNotification();
711 application.Render();
712 application.Render();
713 application.SendNotification();
714 BitmapLoader loader = BitmapLoader::GetLatestCreated();
715 DALI_TEST_CHECK( loader );
716 loader.WaitForLoading();// waiting until the image to be loaded
717 DALI_TEST_CHECK( loader.IsLoaded() );
719 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
721 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
723 // WITH atlasing, the wrapping is handled manually in shader, so the following gl function should not be called
724 std::stringstream out;
725 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
726 DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
728 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
729 DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
731 // test the uniforms which used to handle the wrap mode
732 Renderer renderer = actor.GetRendererAt( 0u );
733 DALI_TEST_CHECK( renderer );
735 Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
736 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION );
737 Vector4 pixelAreaUniform;
738 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
739 DALI_TEST_EQUALS( pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
741 Property::Value wrapModeValue = renderer.GetProperty( renderer.GetPropertyIndex( "wrapMode" ) );
742 Vector2 wrapMode( WrapMode::MIRRORED_REPEAT-1, WrapMode::REPEAT-1 );
743 DALI_TEST_EQUALS( wrapModeValue.Get<Vector2>(), wrapMode, TEST_LOCATION );
744 Vector2 wrapModeUniform;
745 DALI_TEST_CHECK( gl.GetUniformValue<Vector2>( "wrapMode", wrapModeUniform ) );
746 DALI_TEST_EQUALS( wrapMode, wrapModeUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
749 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
754 int UtcDaliVisualFactoryGetImageVisual4(void)
756 ToolkitTestApplication application;
757 tet_infoline( "UtcDaliVisualFactoryGetImageVisual4: Request image visual with a Property::Map, test custom wrap mode and pixel area without atlasing" );
759 VisualFactory factory = VisualFactory::Get();
760 DALI_TEST_CHECK( factory );
762 // Test wrap mode without atlasing. Image with a size bigger than 512*512 will NOT be uploaded as a part of the atlas.
764 const int height=600;
765 const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
767 Property::Map propertyMap;
768 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
769 propertyMap.Insert( ImageVisual::Property::URL, gImage_600_RGB );
770 propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, width );
771 propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, height );
772 propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true );
773 propertyMap.Insert( ImageVisual::Property::PIXEL_AREA, pixelArea );
774 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT );
775 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT );
777 Visual::Base visual = factory.CreateVisual( propertyMap );
778 DALI_TEST_CHECK( visual );
780 TestGlAbstraction& gl = application.GetGlAbstraction();
781 TraceCallStack& textureTrace = gl.GetTextureTrace();
782 textureTrace.Enable(true);
783 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
784 texParameterTrace.Enable( true );
786 DummyControl actor = DummyControl::New();
787 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
788 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
789 actor.SetSize(2000, 2000);
790 actor.SetParentOrigin(ParentOrigin::CENTER);
791 Stage::GetCurrent().Add( actor );
794 application.SendNotification();
795 application.Render();
796 application.Render();
797 application.SendNotification();
798 BitmapLoader loader = BitmapLoader::GetLatestCreated();
799 DALI_TEST_CHECK( loader );
800 loader.WaitForLoading();// waiting until the image to be loaded
801 DALI_TEST_CHECK( loader.IsLoaded() );
803 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
805 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
807 // WITHOUT atlasing, the wrapping is handled by setting gl texture parameters
808 std::stringstream out;
809 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
810 DALI_TEST_CHECK( texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
812 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
813 DALI_TEST_CHECK( texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
815 // test the uniforms which used to handle the wrap mode
816 Renderer renderer = actor.GetRendererAt( 0u );
817 DALI_TEST_CHECK( renderer );
819 Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
820 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION );
821 Vector4 pixelAreaUniform;
822 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
823 DALI_TEST_EQUALS( pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
825 Property::Index wrapModeIndex = renderer.GetPropertyIndex( "wrapMode" );
826 DALI_TEST_CHECK(wrapModeIndex == Property::INVALID_INDEX);
829 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
834 int UtcDaliVisualFactoryGetNPatchVisual1(void)
836 ToolkitTestApplication application;
837 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual1: Request 9-patch visual with a Property::Map" );
839 VisualFactory factory = VisualFactory::Get();
840 DALI_TEST_CHECK( factory );
842 const unsigned int ninePatchImageHeight = 18;
843 const unsigned int ninePatchImageWidth = 28;
844 StretchRanges stretchRangesX;
845 stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
846 StretchRanges stretchRangesY;
847 stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
848 Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
850 Property::Map propertyMap;
851 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
852 propertyMap.Insert( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME );
854 tet_infoline( "whole grid" );
855 Visual::Base visual = factory.CreateVisual( propertyMap );
856 DALI_TEST_CHECK( visual );
859 TestGlAbstraction& gl = application.GetGlAbstraction();
860 TraceCallStack& textureTrace = gl.GetTextureTrace();
861 textureTrace.Enable(true);
863 DummyControl actor = DummyControl::New();
864 TestVisualRender( application, actor, visual, 1u,
865 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
868 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
871 propertyMap.Insert( ImageVisual::Property::BORDER_ONLY, true );
873 tet_infoline( "border only" );
874 Visual::Base visual = factory.CreateVisual( propertyMap );
875 DALI_TEST_CHECK( visual );
877 TestGlAbstraction& gl = application.GetGlAbstraction();
878 TraceCallStack& textureTrace = gl.GetTextureTrace();
879 textureTrace.Enable(true);
881 DummyControl actor = DummyControl::New();
882 TestVisualRender( application, actor, visual, 1u,
883 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
886 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
892 int UtcDaliVisualFactoryGetNPatchVisual2(void)
894 ToolkitTestApplication application;
895 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual2: Request n-patch visual with a Property::Map" );
897 VisualFactory factory = VisualFactory::Get();
898 DALI_TEST_CHECK( factory );
900 const unsigned int ninePatchImageWidth = 18;
901 const unsigned int ninePatchImageHeight = 28;
902 StretchRanges stretchRangesX;
903 stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
904 stretchRangesX.PushBack( Uint16Pair( 5, 7 ) );
905 stretchRangesX.PushBack( Uint16Pair( 12, 15 ) );
906 StretchRanges stretchRangesY;
907 stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
908 stretchRangesY.PushBack( Uint16Pair( 8, 12 ) );
909 stretchRangesY.PushBack( Uint16Pair( 15, 16 ) );
910 stretchRangesY.PushBack( Uint16Pair( 25, 27 ) );
911 Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
913 Property::Map propertyMap;
914 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
915 propertyMap.Insert( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME );
917 Visual::Base visual = factory.CreateVisual( propertyMap );
918 DALI_TEST_CHECK( visual );
920 TestGlAbstraction& gl = application.GetGlAbstraction();
921 TraceCallStack& textureTrace = gl.GetTextureTrace();
922 textureTrace.Enable(true);
924 DummyControl actor = DummyControl::New();
925 TestVisualRender( application, actor, visual, 1u,
926 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
929 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
931 Stage::GetCurrent().Remove( actor );
932 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
935 propertyMap.Insert( ImageVisual::Property::BORDER_ONLY, true );
937 tet_infoline( "border only" );
938 Visual::Base visual = factory.CreateVisual( propertyMap );
939 DALI_TEST_CHECK( visual );
941 TestGlAbstraction& gl = application.GetGlAbstraction();
942 TraceCallStack& textureTrace = gl.GetTextureTrace();
943 textureTrace.Enable(true);
944 DummyControl actor = DummyControl::New();
945 TestVisualRender( application, actor, visual, 1u,
946 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
950 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
952 Stage::GetCurrent().Remove( actor );
953 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
959 int UtcDaliVisualFactoryGetNPatchVisual3(void)
961 ToolkitTestApplication application;
962 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual3: Request 9-patch visual with an image url" );
964 VisualFactory factory = VisualFactory::Get();
965 DALI_TEST_CHECK( factory );
967 const unsigned int ninePatchImageHeight = 18;
968 const unsigned int ninePatchImageWidth = 28;
969 StretchRanges stretchRangesX;
970 stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
971 StretchRanges stretchRangesY;
972 stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
973 Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
975 Visual::Base visual = factory.CreateVisual( TEST_NPATCH_FILE_NAME, ImageDimensions() );
976 DALI_TEST_CHECK( visual );
978 TestGlAbstraction& gl = application.GetGlAbstraction();
979 TraceCallStack& textureTrace = gl.GetTextureTrace();
980 textureTrace.Enable(true);
982 DummyControl actor = DummyControl::New();
983 TestVisualRender( application, actor, visual, 1u,
984 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
987 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
990 ResourceImage image = ResourceImage::New(TEST_NPATCH_FILE_NAME);
991 Visual::Base nPatchVisual = factory.CreateVisual( image );
992 Vector2 controlSize( 20.f, 30.f ), naturalSize(0,0);
993 nPatchVisual.SetTransformAndSize(DefaultTransform(), controlSize );
994 nPatchVisual.GetNaturalSize( naturalSize );
995 DALI_TEST_EQUALS( naturalSize, Vector2( ninePatchImageWidth-2, ninePatchImageHeight-2 ), TEST_LOCATION );
1000 int UtcDaliVisualFactoryGetNPatchVisual4(void)
1002 ToolkitTestApplication application;
1003 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual4: Request n-patch visual with an image url" );
1005 VisualFactory factory = VisualFactory::Get();
1006 DALI_TEST_CHECK( factory );
1008 const unsigned int ninePatchImageHeight = 18;
1009 const unsigned int ninePatchImageWidth = 28;
1010 StretchRanges stretchRangesX;
1011 stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
1012 stretchRangesX.PushBack( Uint16Pair( 5, 7 ) );
1013 stretchRangesX.PushBack( Uint16Pair( 12, 15 ) );
1014 StretchRanges stretchRangesY;
1015 stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
1016 stretchRangesY.PushBack( Uint16Pair( 8, 12 ) );
1017 stretchRangesY.PushBack( Uint16Pair( 15, 16 ) );
1018 stretchRangesY.PushBack( Uint16Pair( 25, 27 ) );
1019 Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
1021 Visual::Base visual = factory.CreateVisual( TEST_NPATCH_FILE_NAME, ImageDimensions() );
1022 DALI_TEST_CHECK( visual );
1024 TestGlAbstraction& gl = application.GetGlAbstraction();
1025 TraceCallStack& textureTrace = gl.GetTextureTrace();
1026 textureTrace.Enable(true);
1028 DummyControl actor = DummyControl::New();
1029 TestVisualRender( application, actor, visual, 1u,
1030 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
1031 ninePatchResource );
1033 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1038 int UtcDaliVisualFactoryGetNPatchVisualN1(void)
1040 //This should still load but display an error image
1042 ToolkitTestApplication application;
1043 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid image url" );
1045 VisualFactory factory = VisualFactory::Get();
1046 DALI_TEST_CHECK( factory );
1048 Visual::Base visual = factory.CreateVisual( "ERROR.9.jpg", ImageDimensions() );
1049 DALI_TEST_CHECK( visual );
1051 //The testkit still has to load a bitmap for the broken renderer image
1052 Integration::Bitmap* bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
1053 bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 100, 100, 100, 100 );
1055 TestGlAbstraction& gl = application.GetGlAbstraction();
1056 TraceCallStack& textureTrace = gl.GetTextureTrace();
1057 textureTrace.Enable(true);
1059 DummyControl actor = DummyControl::New();
1060 TestVisualRender( application, actor, visual, 1u,
1062 Integration::ResourcePointer(bitmap) );
1064 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1069 int UtcDaliVisualFactoryGetNPatchVisualN2(void)
1071 //This should still load but display an error image
1073 ToolkitTestApplication application;
1074 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid URL" );
1076 VisualFactory factory = VisualFactory::Get();
1077 DALI_TEST_CHECK( factory );
1079 Property::Map propertyMap;
1080 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
1081 propertyMap.Insert( ImageVisual::Property::URL, "ERROR.9.jpg" );
1083 Visual::Base visual = factory.CreateVisual( propertyMap );
1084 DALI_TEST_CHECK( visual );
1086 //The testkit still has to load a bitmap for the broken renderer image
1087 Integration::Bitmap* bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
1088 bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 100, 100, 100, 100 );
1090 TestGlAbstraction& gl = application.GetGlAbstraction();
1091 TraceCallStack& textureTrace = gl.GetTextureTrace();
1092 textureTrace.Enable(true);
1093 TraceCallStack& drawTrace = gl.GetDrawTrace();
1094 drawTrace.Enable(true);
1096 DummyControl actor = DummyControl::New();
1097 TestVisualRender( application, actor, visual, 1u,
1099 Integration::ResourcePointer(bitmap) );
1101 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1106 int UtcDaliVisualFactoryGetNPatchVisualN3(void)
1108 // Passing in an invalid visual type so we should not get a visual
1110 ToolkitTestApplication application;
1111 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid visual type" );
1113 VisualFactory factory = VisualFactory::Get();
1114 DALI_TEST_CHECK( factory );
1116 Property::Map propertyMap;
1117 propertyMap.Insert( Visual::Property::TYPE, 111 );
1118 propertyMap.Insert( ImageVisual::Property::URL, "ERROR.9.jpg" );
1120 Visual::Base visual = factory.CreateVisual( propertyMap );
1121 DALI_TEST_CHECK( !visual );
1126 int UtcDaliVisualFactoryGetSvgVisual(void)
1128 ToolkitTestApplication application;
1129 tet_infoline( "UtcDaliVisualFactoryGetSvgVisual: Request svg visual with a svg url" );
1131 VisualFactory factory = VisualFactory::Get();
1132 Visual::Base visual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions() );
1133 DALI_TEST_CHECK( visual );
1135 TestGlAbstraction& gl = application.GetGlAbstraction();
1136 TraceCallStack& textureTrace = gl.GetTextureTrace();
1137 textureTrace.Enable(true);
1139 DummyControl actor = DummyControl::New();
1140 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1141 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1142 actor.SetSize( 200.f, 200.f );
1143 Stage::GetCurrent().Add( actor );
1144 visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f) );
1146 application.SendNotification();
1147 application.Render();
1149 // renderer is not added to actor until the rasterization is completed.
1150 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1152 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1154 // renderer is added to actor
1155 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
1157 // waiting for the resource uploading
1158 application.SendNotification();
1159 application.Render();
1161 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1166 int UtcDaliVisualFactoryGetSvgVisualLarge(void)
1168 ToolkitTestApplication application;
1169 tet_infoline( "UtcDaliVisualFactoryGetSvgVisual: Request svg visual with a svg url" );
1171 VisualFactory factory = VisualFactory::Get();
1172 Visual::Base visual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions( 2000, 2000 ) );
1173 DALI_TEST_CHECK( visual );
1175 TestGlAbstraction& gl = application.GetGlAbstraction();
1176 TraceCallStack& textureTrace = gl.GetTextureTrace();
1177 textureTrace.Enable(true);
1179 DummyControl actor = DummyControl::New(true);
1180 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1181 actor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); // Only rasterizes when it knows control size.
1182 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1183 Stage::GetCurrent().Add( actor );
1185 application.SendNotification();
1186 application.Render();
1188 // renderer is not added to actor until the rasterization is completed.
1189 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1191 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1193 // renderer is added to actor
1194 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
1196 // waiting for the resource uploading
1197 application.SendNotification();
1198 application.Render();
1200 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1205 //Creates a mesh visual from the given propertyMap and tries to load it on stage in the given application.
1206 //This is expected to succeed, which will then pass the test.
1207 void MeshVisualLoadsCorrectlyTest( Property::Map& propertyMap, ToolkitTestApplication& application )
1209 VisualFactory factory = VisualFactory::Get();
1210 DALI_TEST_CHECK( factory );
1212 //Create a mesh visual.
1213 Visual::Base visual = factory.CreateVisual( propertyMap );
1214 DALI_TEST_CHECK( visual );
1216 //Create an actor on stage to house the visual.
1217 DummyControl actor = DummyControl::New();
1218 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1219 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1220 actor.SetSize( 200.f, 200.f );
1221 Stage::GetCurrent().Add( actor );
1222 visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.f, 200.f ) );
1224 //Ensure set on stage.
1225 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1227 //Attempt to render to queue resource load requests.
1228 application.SendNotification();
1229 application.Render( 0 );
1231 //Tell the platform abstraction that the required resources have been loaded.
1232 TestPlatformAbstraction& platform = application.GetPlatform();
1233 platform.SetAllResourceRequestsAsLoaded();
1235 //Render again to upload the now-loaded textures.
1236 application.SendNotification();
1237 application.Render( 0 );
1239 Matrix testScaleMatrix;
1240 testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
1241 Matrix actualScaleMatrix;
1243 //Test to see if the object has been successfully loaded.
1244 DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
1245 DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1247 //Finish by setting off stage, and ensuring this was successful.
1249 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1252 //Creates a mesh visual from the given propertyMap and tries to load it on stage in the given application.
1253 //This is expected to fail, which will then pass the test.
1254 void MeshVisualDoesNotLoadCorrectlyTest( Property::Map& propertyMap, ToolkitTestApplication& application )
1256 VisualFactory factory = VisualFactory::Get();
1257 DALI_TEST_CHECK( factory );
1259 //Create a mesh visual.
1260 Visual::Base visual = factory.CreateVisual( propertyMap );
1261 DALI_TEST_CHECK( visual );
1263 //Create an actor on stage to house the visual.
1264 DummyControl actor = DummyControl::New();
1265 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1266 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1267 actor.SetSize( 200.f, 200.f );
1268 Stage::GetCurrent().Add( actor );
1269 visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.f, 200.f ) );
1271 //Ensure set on stage.
1272 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1274 //Attempt to render to queue resource load requests.
1275 application.SendNotification();
1276 application.Render( 0 );
1278 //Tell the platform abstraction that the required resources have been loaded.
1279 TestPlatformAbstraction& platform = application.GetPlatform();
1280 platform.SetAllResourceRequestsAsLoaded();
1282 //Render again to upload the now-loaded textures.
1283 application.SendNotification();
1284 application.Render( 0 );
1286 //Test to see if the object has not been loaded, as expected.
1288 DALI_TEST_CHECK( !application.GetGlAbstraction().GetUniformValue<Matrix>( "uObjectMatrix", scaleMatrix ) );
1290 //Finish by setting off stage, and ensuring this was successful.
1292 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1295 //Test if mesh loads correctly when supplied with only the bare minimum requirements, an object file.
1296 int UtcDaliVisualFactoryGetMeshVisual1(void)
1298 //Set up test application first, so everything else can be handled.
1299 ToolkitTestApplication application;
1301 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual1: Request mesh visual with a valid object file only" );
1304 //Set up visual properties.
1305 Property::Map propertyMap;
1306 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1307 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1309 //Test to see if mesh loads correctly.
1310 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1316 //Test if mesh loads correctly when supplied with an object file as well as a blank material file and images directory.
1317 int UtcDaliVisualFactoryGetMeshVisual2(void)
1319 //Set up test application first, so everything else can be handled.
1320 ToolkitTestApplication application;
1322 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual2: Request mesh visual with blank material file and images directory" );
1324 //Set up visual properties.
1325 Property::Map propertyMap;
1326 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1327 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1328 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, "" );
1329 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, "" );
1331 //Test to see if mesh loads correctly.
1332 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1337 //Test if mesh loads correctly when supplied with all main parameters, an object file, a material file and a directory location.
1338 int UtcDaliVisualFactoryGetMeshVisual3(void)
1340 //Set up test application first, so everything else can be handled.
1341 ToolkitTestApplication application;
1343 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual3: Request mesh visual with all parameters correct" );
1345 //Set up visual properties.
1346 Property::Map propertyMap;
1347 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1348 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1349 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1350 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1352 //Test to see if mesh loads correctly.
1353 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1358 //Test if mesh visual can load a correctly supplied mesh without a normal map or gloss map in the material file.
1359 int UtcDaliVisualFactoryGetMeshVisual4(void)
1361 //Set up test application first, so everything else can be handled.
1362 ToolkitTestApplication application;
1364 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual4: Request mesh visual with diffuse texture but not normal or gloss." );
1367 //Set up visual properties.
1368 Property::Map propertyMap;
1369 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1370 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1371 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_SIMPLE_MTL_FILE_NAME );
1372 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1374 //Test to see if mesh loads correctly.
1375 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1381 //Test if mesh visual can load when made to use diffuse textures only.
1382 int UtcDaliVisualFactoryGetMeshVisual5(void)
1384 //Set up test application first, so everything else can be handled.
1385 ToolkitTestApplication application;
1387 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual5: Request mesh visual and make it only use diffuse textures." );
1389 //Set up visual properties.
1390 Property::Map propertyMap;
1391 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1392 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1393 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1394 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1395 propertyMap.Insert( MeshVisual::Property::SHADING_MODE, MeshVisual::ShadingMode::TEXTURED_WITH_SPECULAR_LIGHTING );
1397 //Test to see if mesh loads correctly.
1398 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1404 //Test if mesh visual can load when made to not use the supplied textures.
1405 int UtcDaliVisualFactoryGetMeshVisual6(void)
1407 //Set up test application first, so everything else can be handled.
1408 ToolkitTestApplication application;
1410 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual6: Request mesh visual and make it not use any textures." );
1412 //Set up visual properties.
1413 Property::Map propertyMap;
1414 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1415 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1416 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1417 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1418 propertyMap.Insert( MeshVisual::Property::SHADING_MODE, MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING );
1420 //Test to see if mesh loads correctly.
1421 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1425 //Test if mesh visual loads correctly when light position is manually set.
1426 int UtcDaliVisualFactoryGetMeshVisual7(void)
1428 //Set up test application first, so everything else can be handled.
1429 ToolkitTestApplication application;
1432 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual7: Request mesh visual with custom light position." );
1434 //Set up visual properties.
1435 Property::Map propertyMap;
1436 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1437 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1438 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1439 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1440 propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.0, 1.0, 2.0 ) );
1442 //Test to see if mesh loads correctly.
1443 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1448 //Test if mesh visual loads correctly when supplied an object file without face normals or texture points.
1449 //Note that this notably tests object loader functionality.
1450 int UtcDaliVisualFactoryGetMeshVisual8(void)
1452 //Set up test application first, so everything else can be handled.
1453 ToolkitTestApplication application;
1455 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual5: Request mesh visual with normal-less object file." );
1457 //Set up visual properties.
1458 Property::Map propertyMap;
1459 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1460 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_SIMPLE_OBJ_FILE_NAME );
1461 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1462 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1464 //Test to see if mesh loads correctly.
1465 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1470 //Test if mesh visual handles the case of lacking an object file.
1471 int UtcDaliVisualFactoryGetMeshVisualN1(void)
1473 //Set up test application first, so everything else can be handled.
1474 ToolkitTestApplication application;
1476 tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN1: Request mesh visual without object file" );
1478 //Set up visual properties.
1479 Property::Map propertyMap;
1480 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1481 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1482 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1484 //Test to see if mesh doesn't load with these properties, as expected.
1485 MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
1491 //Test if mesh visual handles the case of being passed invalid material and images urls.
1492 int UtcDaliVisualFactoryGetMeshVisualN2(void)
1494 //Set up test application first, so everything else can be handled.
1495 ToolkitTestApplication application;
1497 tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN2: Request mesh visual with invalid material and images urls" );
1499 //Set up visual properties.
1500 Property::Map propertyMap;
1501 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1502 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1503 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, "invalid" );
1504 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, "also invalid" );
1506 //Test to see if mesh doesn't load with these properties, as expected.
1507 MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
1513 //Test if mesh visual handles the case of being passed an invalid object url
1514 int UtcDaliVisualFactoryGetMeshVisualN3(void)
1516 //Set up test application first, so everything else can be handled.
1517 ToolkitTestApplication application;
1518 tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN3: Request mesh visual with invalid object url" );
1521 //Set up visual properties.
1522 Property::Map propertyMap;
1523 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1524 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, "invalid" );
1525 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1526 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1528 //Test to see if mesh doesn't load with these properties, as expected.
1529 MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
1534 //Creates a primitive visual with the given property map and tests to see if it correctly loads in the given application.
1535 void TestPrimitiveVisualWithProperties( Property::Map& propertyMap, ToolkitTestApplication& application )
1537 VisualFactory factory = VisualFactory::Get();
1538 DALI_TEST_CHECK( factory );
1540 //Create a primitive visual.
1541 Visual::Base visual = factory.CreateVisual( propertyMap );
1542 DALI_TEST_CHECK( visual );
1544 //Create an actor on stage to house the visual.
1545 DummyControl actor = DummyControl::New();
1546 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1547 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1549 actor.SetSize( 200.f, 200.f );
1550 Stage::GetCurrent().Add( actor );
1551 visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.f, 200.f ) );
1553 //Ensure set on stage.
1554 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1556 //Tell test application to load the visual.
1557 application.SendNotification();
1558 application.Render(0);
1560 Matrix testScaleMatrix;
1561 testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
1562 Matrix actualScaleMatrix;
1564 //Test to see if the object has been successfully loaded.
1565 DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
1566 DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1568 //Finish by setting off stage, and ensuring this was successful.
1570 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1573 //Test if primitive shape loads correctly when supplied with only the bare minimum requirements, the shape to use.
1574 int UtcDaliVisualFactoryGetPrimitiveVisual1(void)
1576 //Set up test application first, so everything else can be handled.
1577 ToolkitTestApplication application;
1579 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual1: Request primitive visual with a shape only" );
1581 //Set up visual properties.
1582 Property::Map propertyMap;
1583 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1584 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
1586 //Test to see if shape loads correctly.
1587 TestPrimitiveVisualWithProperties( propertyMap, application );
1592 //Test if primitive shape loads correctly when supplied with all possible parameters
1593 int UtcDaliVisualFactoryGetPrimitiveVisual2(void)
1595 //Set up test application first, so everything else can be handled.
1596 ToolkitTestApplication application;
1598 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual2: Request primitive visual with everything" );
1600 //Set up visual properties.
1601 Property::Map propertyMap;
1602 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1603 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
1604 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1605 propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1606 propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
1607 propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
1608 propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f );
1609 propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
1610 propertyMap.Insert( PrimitiveVisual::Property::SCALE_RADIUS, 60.0f );
1611 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.7f );
1612 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, 0.8f );
1613 propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.9, 1.0, 1.1 ) );
1615 //Test to see if shape loads correctly.
1616 TestPrimitiveVisualWithProperties( propertyMap, application );
1621 //Test if primitive shape loads a sphere correctly.
1622 int UtcDaliVisualFactoryGetPrimitiveVisual3(void)
1624 //Set up test application first, so everything else can be handled.
1625 ToolkitTestApplication application;
1627 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual3: Request primitive visual to display a sphere" );
1629 //Set up visual properties.
1630 Property::Map propertyMap;
1631 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1632 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1633 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1634 propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1635 propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
1637 //Test to see if shape loads correctly.
1638 TestPrimitiveVisualWithProperties( propertyMap, application );
1643 //Test if primitive shape loads a conic section correctly.
1644 int UtcDaliVisualFactoryGetPrimitiveVisual4(void)
1646 //Set up test application first, so everything else can be handled.
1647 ToolkitTestApplication application;
1649 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual4: Request primitive visual to display a conic section" );
1651 //Set up visual properties.
1652 Property::Map propertyMap;
1653 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1654 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONICAL_FRUSTRUM );
1655 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1656 propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1657 propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
1658 propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f );
1659 propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
1661 //Test to see if shape loads correctly.
1662 TestPrimitiveVisualWithProperties( propertyMap, application );
1667 //Test if primitive shape loads a bevelled cube correctly.
1668 int UtcDaliVisualFactoryGetPrimitiveVisual5(void)
1670 //Set up test application first, so everything else can be handled.
1671 ToolkitTestApplication application;
1673 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual5: Request primitive visual to display a bevelled cube" );
1675 //Set up visual properties.
1676 Property::Map propertyMap;
1677 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1678 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::BEVELLED_CUBE );
1679 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1680 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.7f );
1682 //Test to see if shape loads correctly.
1683 TestPrimitiveVisualWithProperties( propertyMap, application );
1688 //Test if primitive shape loads an octahedron correctly.
1689 int UtcDaliVisualFactoryGetPrimitiveVisual6(void)
1691 //Set up test application first, so everything else can be handled.
1692 ToolkitTestApplication application;
1694 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual6: Request primitive visual to display an octahedron" );
1696 //Set up visual properties.
1697 Property::Map propertyMap;
1698 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1699 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::OCTAHEDRON );
1700 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1702 //Test to see if shape loads correctly.
1703 TestPrimitiveVisualWithProperties( propertyMap, application );
1708 //Test if primitive shape loads a cone correctly.
1709 int UtcDaliVisualFactoryGetPrimitiveVisual7(void)
1711 //Set up test application first, so everything else can be handled.
1712 ToolkitTestApplication application;
1714 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual7: Request primitive visual to display a cone" );
1716 //Set up visual properties.
1717 Property::Map propertyMap;
1718 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1719 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONE );
1720 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1721 propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1722 propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
1723 propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
1725 //Test to see if shape loads correctly.
1726 TestPrimitiveVisualWithProperties( propertyMap, application );
1731 //Test if primitive shape loads correctly when light position is manually set.
1732 int UtcDaliVisualFactoryGetPrimitiveVisual8(void)
1734 //Set up test application first, so everything else can be handled.
1735 ToolkitTestApplication application;
1737 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual8: Request primitive visual with set light position" );
1739 //Set up visual properties.
1740 Property::Map propertyMap;
1741 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1742 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1743 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1744 propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.0, 1.0, 2.0 ) );
1746 //Test to see if shape loads correctly.
1747 TestPrimitiveVisualWithProperties( propertyMap, application );
1752 //Test if primitive shape loads correctly when told to use too many slices.
1753 int UtcDaliVisualFactoryGetPrimitiveVisual9(void)
1755 //Set up test application first, so everything else can be handled.
1756 ToolkitTestApplication application;
1758 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual9: Request primitive visual with above-cap slices." );
1760 //Set up visual properties.
1761 Property::Map propertyMap;
1762 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1763 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1764 propertyMap.Insert( PrimitiveVisual::Property::SLICES, Property::Value( 1000000 ) );
1766 //Test to see if shape loads correctly.
1767 TestPrimitiveVisualWithProperties( propertyMap, application );
1772 //Test if primitive shape loads correctly when told to use too few slices. (2 slices or less.)
1773 int UtcDaliVisualFactoryGetPrimitiveVisual10(void)
1775 //Set up test application first, so everything else can be handled.
1776 ToolkitTestApplication application;
1778 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual10: Request primitive visual with too few slices." );
1780 //Set up visual properties.
1781 Property::Map propertyMap;
1782 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1783 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1784 propertyMap.Insert( PrimitiveVisual::Property::SLICES, Property::Value( 2 ) );
1786 //Test to see if shape loads correctly.
1787 TestPrimitiveVisualWithProperties( propertyMap, application );
1792 //Test if primitive shape loads correctly when told to use too many stacks.
1793 int UtcDaliVisualFactoryGetPrimitiveVisual11(void)
1795 //Set up test application first, so everything else can be handled.
1796 ToolkitTestApplication application;
1798 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual11: Request primitive visual with too many stacks." );
1800 //Set up visual properties.
1801 Property::Map propertyMap;
1802 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1803 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1804 propertyMap.Insert( PrimitiveVisual::Property::STACKS, Property::Value( 1000000 ) );
1806 //Test to see if shape loads correctly.
1807 TestPrimitiveVisualWithProperties( propertyMap, application );
1812 //Test if primitive shape loads correctly when told to use too few stacks. (1 stack or less.)
1813 int UtcDaliVisualFactoryGetPrimitiveVisual12(void)
1815 //Set up test application first, so everything else can be handled.
1816 ToolkitTestApplication application;
1818 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual12: Request primitive visual with too few stacks." );
1820 //Set up visual properties.
1821 Property::Map propertyMap;
1822 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1823 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1824 propertyMap.Insert( PrimitiveVisual::Property::STACKS, Property::Value( 1 ) );
1826 //Test to see if shape loads correctly.
1827 TestPrimitiveVisualWithProperties( propertyMap, application );
1832 //Test if primitive shape loads correctly when told to use invalid (zero or negative) dimensions.
1833 int UtcDaliVisualFactoryGetPrimitiveVisual13(void)
1835 //Set up test application first, so everything else can be handled.
1836 ToolkitTestApplication application;
1838 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual13: Request primitive visual with invalid scale dimensions." );
1840 //Set up visual properties.
1841 Property::Map propertyMap;
1842 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1843 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1844 propertyMap.Insert( PrimitiveVisual::Property::SCALE_DIMENSIONS, Vector3::ZERO );
1846 //Test to see if shape loads correctly.
1847 TestPrimitiveVisualWithProperties( propertyMap, application );
1852 //Test if primitive shape loads correctly when told to use too low a bevel percentage.
1853 int UtcDaliVisualFactoryGetPrimitiveVisual14(void)
1855 //Set up test application first, so everything else can be handled.
1856 ToolkitTestApplication application;
1858 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual14: Request primitive visual with too low a bevel percentage." );
1860 //Set up visual properties.
1861 Property::Map propertyMap;
1862 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1863 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1864 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, Property::Value( -1.0f ) );
1866 //Test to see if shape loads correctly.
1867 TestPrimitiveVisualWithProperties( propertyMap, application );
1872 //Test if primitive shape loads correctly when told to use too high a bevel percentage.
1873 int UtcDaliVisualFactoryGetPrimitiveVisual15(void)
1875 //Set up test application first, so everything else can be handled.
1876 ToolkitTestApplication application;
1878 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual15: Request primitive visual with too high a bevel percentage." );
1880 //Set up visual properties.
1881 Property::Map propertyMap;
1882 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1883 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1884 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, Property::Value( 2.0f ) );
1886 //Test to see if shape loads correctly.
1887 TestPrimitiveVisualWithProperties( propertyMap, application );
1892 //Test if primitive shape loads correctly when told to use too low a bevel smoothness.
1893 int UtcDaliVisualFactoryGetPrimitiveVisual16(void)
1895 //Set up test application first, so everything else can be handled.
1896 ToolkitTestApplication application;
1898 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual16: Request primitive visual with too low a bevel smoothness." );
1900 //Set up visual properties.
1901 Property::Map propertyMap;
1902 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1903 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1904 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, Property::Value( -1.0f ) );
1906 //Test to see if shape loads correctly.
1907 TestPrimitiveVisualWithProperties( propertyMap, application );
1912 //Test if primitive shape loads correctly when told to use too high a bevel smoothness.
1913 int UtcDaliVisualFactoryGetPrimitiveVisual17(void)
1915 //Set up test application first, so everything else can be handled.
1916 ToolkitTestApplication application;
1918 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual17: Request primitive visual with too high a bevel smoothness." );
1920 //Set up visual properties.
1921 Property::Map propertyMap;
1922 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1923 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1924 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, Property::Value( 2.0f ) );
1926 //Test to see if shape loads correctly.
1927 TestPrimitiveVisualWithProperties( propertyMap, application );
1932 //Test if primitive shape visual handles the case of not being passed a specific shape to use.
1933 int UtcDaliVisualFactoryGetPrimitiveVisualN1(void)
1935 //Set up test application first, so everything else can be handled.
1936 ToolkitTestApplication application;
1938 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisualN1: Request primitive visual without shape" );
1940 //Set up visual properties, without supplying shape.
1941 Property::Map propertyMap;
1942 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1944 //Test to see if shape loads regardless of missing input.
1945 TestPrimitiveVisualWithProperties( propertyMap, application );
1950 int UtcDaliVisualFactoryGetBatchImageVisual1(void)
1952 ToolkitTestApplication application;
1953 tet_infoline( "UtcDaliVisualFactoryGetBatchImageVisual1: Request a Batch Image visual with a Property::Map" );
1955 VisualFactory factory = VisualFactory::Get();
1956 DALI_TEST_CHECK( factory );
1958 Property::Map propertyMap;
1959 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
1960 propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
1961 propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
1963 Visual::Base visual = factory.CreateVisual( propertyMap );
1964 DALI_TEST_CHECK( visual );
1966 DummyControl actor = DummyControl::New();
1967 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1968 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1970 actor.SetSize( 200.0f, 200.0f );
1971 Stage::GetCurrent().Add( actor );
1972 visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.0f, 200.0f ) );
1974 // Test SetOnStage().
1975 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
1977 application.SendNotification();
1978 application.Render();
1980 // Test SetOffStage().
1982 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1987 int UtcDaliVisualFactoryGetBatchImageVisual2(void)
1989 ToolkitTestApplication application;
1990 tet_infoline( "UtcDaliVisualFactoryGetBatchImageVisual2: Request Batch Image visual from an Image Visual with batchingEnabled set" );
1992 VisualFactory factory = VisualFactory::Get();
1993 DALI_TEST_CHECK( factory );
1995 Property::Map propertyMap;
1996 // Create a normal Image Visual.
1997 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
1998 // Instruct the factory to change Image Visuals to Batch-Image Visuals.
1999 propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
2001 // Properties for the Batch-Image Visual.
2002 propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
2004 Visual::Base visual = factory.CreateVisual( propertyMap );
2005 DALI_TEST_CHECK( visual );
2007 // Check that a Batch-Image visual was created instead of an Image visual.
2008 Property::Map resultMap;
2009 visual.CreatePropertyMap( resultMap );
2011 Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
2012 DALI_TEST_CHECK( value );
2013 DALI_TEST_EQUALS( value->Get<int>(), (int)Visual::IMAGE, TEST_LOCATION );
2015 DummyControl actor = DummyControl::New();
2016 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2017 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
2019 actor.SetSize( 200.0f, 200.0f );
2020 Stage::GetCurrent().Add( actor );
2021 visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.0f, 200.0f ) );
2023 // Test SetOnStage().
2024 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
2026 application.SendNotification();
2027 application.Render();
2029 // Test SetOffStage().
2031 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
2036 int UtcDaliVisualFactoryGetBatchImageVisual3(void)
2038 ToolkitTestApplication application;
2039 tet_infoline( "UtcDaliVisualFactoryGetBatchImageVisual3: Create an ImageView that uses a batched visual internally" );
2041 VisualFactory factory = VisualFactory::Get();
2042 DALI_TEST_CHECK( factory );
2044 // Create a property-map that enables batching.
2045 Property::Map propertyMap;
2046 propertyMap.Insert( Dali::Toolkit::ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
2047 propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
2049 // Create an ImageView, passing the property-map in to instruct it to use batching.
2050 Toolkit::ImageView imageView = Toolkit::ImageView::New();
2051 imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, propertyMap );
2053 imageView.SetSize( 200.0f, 200.0f );
2054 Stage::GetCurrent().Add( imageView );
2059 int UtcDaliVisualFactoryGetAnimatedImageVisual(void)
2061 ToolkitTestApplication application;
2062 tet_infoline( "UtcDaliVisualFactoryGetAnimatedImageVisual: Request animated image visual with a gif url" );
2064 VisualFactory factory = VisualFactory::Get();
2065 Visual::Base visual = factory.CreateVisual( TEST_GIF_FILE_NAME, ImageDimensions() );
2066 DALI_TEST_CHECK( visual );
2068 TestGlAbstraction& gl = application.GetGlAbstraction();
2069 TraceCallStack& textureTrace = gl.GetTextureTrace();
2070 textureTrace.Enable(true);
2072 DummyControl actor = DummyControl::New();
2073 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2074 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
2075 Stage::GetCurrent().Add( actor );
2077 application.SendNotification();
2078 application.Render();
2080 // renderer is added to actor
2081 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
2083 // test the uniforms which used to handle the atlas rect
2084 // the four frames should be located inside atlas as follows: atlas size 100*100
2093 Renderer renderer = actor.GetRendererAt( 0u );
2094 DALI_TEST_CHECK( renderer );
2096 Property::Value atlasRectValue = renderer.GetProperty( renderer.GetPropertyIndex( "uAtlasRect" ) );
2097 // take into consideration the half pixel correction
2098 DALI_TEST_EQUALS( atlasRectValue.Get<Vector4>(), Vector4(0.5f, 0.5f, 49.5f, 49.5f)/100.f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2100 // waiting for the resource uploading
2101 application.SendNotification();
2102 application.Render();
2104 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
2106 // Force the timer used by the animatedImageVisual to tick,
2107 Dali::Timer timer = Timer::New( 0 );
2108 timer.MockEmitSignal();
2109 application.SendNotification();
2110 application.Render();
2111 atlasRectValue = renderer.GetProperty( renderer.GetPropertyIndex( "uAtlasRect" ) );
2112 // take into consideration the half pixel correction
2113 DALI_TEST_EQUALS( atlasRectValue.Get<Vector4>(), Vector4(50.5f, 0.5f, 99.5f, 49.5f)/100.f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2115 // Force the timer used by the animatedImageVisual to tick,
2116 timer.MockEmitSignal();
2117 application.SendNotification();
2118 application.Render();
2119 atlasRectValue = renderer.GetProperty( renderer.GetPropertyIndex( "uAtlasRect" ) );
2120 // take into consideration the half pixel correction
2121 DALI_TEST_EQUALS( atlasRectValue.Get<Vector4>(), Vector4(0.5f, 50.5f, 49.5f, 99.5f)/100.f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2123 // Force the timer used by the animatedImageVisual to tick,
2124 timer.MockEmitSignal();
2125 application.SendNotification();
2126 application.Render();
2127 atlasRectValue = renderer.GetProperty( renderer.GetPropertyIndex( "uAtlasRect" ) );
2128 // take into consideration the half pixel correction
2129 DALI_TEST_EQUALS( atlasRectValue.Get<Vector4>(), Vector4(50.5f, 50.5f, 99.5f, 99.5f)/100.f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2131 // Test SetOffStage().
2133 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );