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();
226 application.Render();
227 application.SendNotification();
231 DALI_TEST_EQUALS( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceSynchronouslyFunc ), true, TEST_LOCATION);
234 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
241 void dali_visual_factory_startup(void)
243 test_return_value = TET_UNDEF;
246 void dali_visual_factory_cleanup(void)
248 test_return_value = TET_PASS;
251 int UtcDaliVisualFactoryGet(void)
253 ToolkitTestApplication application;
254 tet_infoline( "UtcDaliVisualFactory" );
258 type = TypeRegistry::Get().GetTypeInfo( "VisualFactory" );
259 DALI_TEST_CHECK( type );
260 BaseHandle handle = type.CreateInstance();
261 DALI_TEST_CHECK( handle );
263 VisualFactory factory;
264 factory = VisualFactory::Get();
265 DALI_TEST_CHECK( factory );
267 VisualFactory newFactory = VisualFactory::Get();
268 DALI_TEST_CHECK( newFactory );
270 // Check that visual factory is a singleton
271 DALI_TEST_CHECK(factory == newFactory);
276 int UtcDaliVisualFactoryCopyAndAssignment(void)
278 ToolkitTestApplication application;
279 tet_infoline( "UtcDaliVisualFactoryCopyAndAssignment" );
280 VisualFactory factory = VisualFactory::Get();
282 VisualFactory factoryCopy( factory );
283 DALI_TEST_CHECK(factory == factoryCopy);
285 VisualFactory emptyFactory;
286 VisualFactory emptyFactoryCopy( emptyFactory );
287 DALI_TEST_CHECK(emptyFactory == emptyFactoryCopy);
289 VisualFactory factoryEquals;
290 factoryEquals = factory;
291 DALI_TEST_CHECK(factory == factoryEquals);
293 VisualFactory emptyFactoryEquals;
294 emptyFactoryEquals = emptyFactory;
295 DALI_TEST_CHECK( emptyFactory == emptyFactoryEquals );
299 DALI_TEST_CHECK( factory = factoryCopy );
304 int UtcDaliVisualFactoryGetColorVisual1(void)
306 ToolkitTestApplication application;
307 tet_infoline( "UtcDaliVisualFactoryGetColorVisual1: Request color visual with a Property::Map" );
309 VisualFactory factory = VisualFactory::Get();
310 DALI_TEST_CHECK( factory );
312 Property::Map propertyMap;
313 Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
314 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
315 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, testColor);
317 Visual::Base visual = factory.CreateVisual(propertyMap);
318 DALI_TEST_CHECK( visual );
320 DummyControl actor = DummyControl::New();
321 TestVisualRender( application, actor, visual );
323 Vector3 actualValue(Vector4::ZERO);
325 TestGlAbstraction& gl = application.GetGlAbstraction();
326 DALI_TEST_CHECK( gl.GetUniformValue<Vector3>( "mixColor", actualValue ) );
327 DALI_TEST_CHECK( gl.GetUniformValue<float>( "opacity", opacity ) );
328 DALI_TEST_EQUALS( actualValue, Vector3(testColor), TEST_LOCATION );
329 DALI_TEST_EQUALS( opacity, testColor.a, TEST_LOCATION );
334 int UtcDaliVisualFactoryGetColorVisual2(void)
336 ToolkitTestApplication application;
337 tet_infoline( "UtcDaliVisualFactoryGetColorVisual2: Request color visual with a Vector4" );
339 VisualFactory factory = VisualFactory::Get();
340 DALI_TEST_CHECK( factory );
342 Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
343 Dali::Property::Map map;
344 map[ Visual::Property::TYPE ] = Visual::COLOR;
345 map[ ColorVisual::Property::MIX_COLOR ] = testColor;
346 Visual::Base visual = factory.CreateVisual( map );
347 DALI_TEST_CHECK( visual );
349 DummyControl actor = DummyControl::New();
350 TestVisualRender( application, actor, visual );
354 TestGlAbstraction& gl = application.GetGlAbstraction();
355 DALI_TEST_CHECK( gl.GetUniformValue<Vector3>( "mixColor", actualValue ) );
356 DALI_TEST_CHECK( gl.GetUniformValue<float>( "opacity", opacity ) );
357 DALI_TEST_EQUALS( actualValue, Vector3(testColor), TEST_LOCATION );
358 DALI_TEST_EQUALS( opacity, testColor.a, TEST_LOCATION );
360 Stage::GetCurrent().Remove(actor);
361 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
366 int UtcDaliVisualFactoryGetBorderVisual1(void)
368 ToolkitTestApplication application;
369 tet_infoline( "UtcDaliVisualFactoryGetBorderVisual1: Request border visual with a Property::Map" );
371 VisualFactory factory = VisualFactory::Get();
372 DALI_TEST_CHECK( factory );
374 Property::Map propertyMap;
375 Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
376 float testSize = 5.f;
377 propertyMap.Insert(Visual::Property::TYPE, Visual::BORDER);
378 propertyMap.Insert(BorderVisual::Property::COLOR, testColor);
379 propertyMap.Insert(BorderVisual::Property::SIZE, testSize);
381 Visual::Base visual = factory.CreateVisual(propertyMap);
382 DALI_TEST_CHECK( visual );
384 DummyControl actor = DummyControl::New();
385 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
386 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
387 actor.SetSize(200.f, 200.f);
388 Stage::GetCurrent().Add( actor );
389 visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f));
391 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
392 int blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLEND_MODE );
393 DALI_TEST_EQUALS( static_cast<BlendMode::Type>(blendMode), BlendMode::ON, TEST_LOCATION );
395 TestGlAbstraction& gl = application.GetGlAbstraction();
397 application.SendNotification();
398 application.Render(0);
400 Vector4 actualColor(Vector4::ZERO);
401 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "borderColor", actualColor ) );
402 DALI_TEST_EQUALS( actualColor, testColor, TEST_LOCATION );
404 float actualSize = 0.f;
405 DALI_TEST_CHECK( gl.GetUniformValue<float>( "borderSize", actualSize ) );
406 DALI_TEST_EQUALS( actualSize, testSize, TEST_LOCATION );
409 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
414 int UtcDaliVisualFactoryGetBorderVisual2(void)
416 ToolkitTestApplication application;
417 tet_infoline( "UtcDaliVisualFactoryGetBorderVisual2: Request border visual with a borderSize and a borderColor" );
419 VisualFactory factory = VisualFactory::Get();
420 DALI_TEST_CHECK( factory );
422 Vector4 testColor( 1.f, 0.5f, 0.3f, 1.f );
423 float testSize = 5.f;
425 Dali::Property::Map propertyMap;
426 propertyMap[ Visual::Property::TYPE ] = Visual::BORDER;
427 propertyMap[ BorderVisual::Property::COLOR ] = testColor;
428 propertyMap[ BorderVisual::Property::SIZE ] = testSize;
429 Visual::Base visual = factory.CreateVisual( propertyMap );
430 DALI_TEST_CHECK( visual );
432 DummyControl actor = DummyControl::New();
433 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
434 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
435 actor.SetSize(200.f, 200.f);
436 Stage::GetCurrent().Add( actor );
437 visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f));
439 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
441 TestGlAbstraction& gl = application.GetGlAbstraction();
443 application.SendNotification();
444 application.Render(0);
446 int blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLEND_MODE );
447 DALI_TEST_EQUALS( static_cast<BlendMode::Type>(blendMode), BlendMode::AUTO, TEST_LOCATION );
449 Vector4 actualColor(Vector4::ZERO);
450 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "borderColor", actualColor ) );
451 DALI_TEST_EQUALS( actualColor, testColor, TEST_LOCATION );
453 float actualSize = 0.f;
454 DALI_TEST_CHECK( gl.GetUniformValue<float>( "borderSize", actualSize ) );
455 DALI_TEST_EQUALS( actualSize, testSize, TEST_LOCATION );
459 // enable the anti-aliasing
460 Dali::Property::Map map;
461 map[ Visual::Property::TYPE ] = Visual::BORDER;
462 map[ BorderVisual::Property::COLOR ] = testColor;
463 map[ BorderVisual::Property::SIZE ] = testSize;
464 map[ BorderVisual::Property::ANTI_ALIASING ] = true;
465 visual = factory.CreateVisual( map );
467 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
468 Stage::GetCurrent().Add( actor );
470 blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLEND_MODE );
471 DALI_TEST_EQUALS( static_cast<BlendMode::Type>(blendMode), BlendMode::ON, TEST_LOCATION );
476 int UtcDaliVisualFactoryGetLinearGradientVisual(void)
478 ToolkitTestApplication application;
479 tet_infoline("UtcDaliVisualFactoryGetRadialGradientVisual");
481 VisualFactory factory = VisualFactory::Get();
482 DALI_TEST_CHECK( factory );
484 Property::Map propertyMap;
485 propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
487 Vector2 start(-1.f, -1.f);
488 Vector2 end(1.f, 1.f);
489 propertyMap.Insert(GradientVisual::Property::START_POSITION, start);
490 propertyMap.Insert(GradientVisual::Property::END_POSITION, end);
491 propertyMap.Insert(GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT);
493 Property::Array stopOffsets;
494 stopOffsets.PushBack( 0.2f );
495 stopOffsets.PushBack( 0.8f );
496 propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, stopOffsets);
498 Property::Array stopColors;
499 stopColors.PushBack( Color::RED );
500 stopColors.PushBack( Color::GREEN );
501 propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
503 Visual::Base visual = factory.CreateVisual(propertyMap);
504 DALI_TEST_CHECK( visual );
506 // A lookup texture is generated and pass to shader as sampler
507 DummyControl actor = DummyControl::New();
508 TestVisualRender( application, actor, visual, 1u);
513 int UtcDaliVisualFactoryGetRadialGradientVisual(void)
515 ToolkitTestApplication application;
516 tet_infoline("UtcDaliVisualFactoryGetRadialGradientVisual");
518 VisualFactory factory = VisualFactory::Get();
519 DALI_TEST_CHECK( factory );
521 Property::Map propertyMap;
522 propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
524 Vector2 center(100.f, 100.f);
525 float radius = 100.f;
526 propertyMap.Insert(GradientVisual::Property::UNITS, GradientVisual::Units::USER_SPACE);
527 propertyMap.Insert(GradientVisual::Property::CENTER, center);
528 propertyMap.Insert(GradientVisual::Property::RADIUS, radius);
530 Property::Array stopOffsets;
531 stopOffsets.PushBack( 0.0f );
532 stopOffsets.PushBack( 1.f );
533 propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, stopOffsets);
535 Property::Array stopColors;
536 stopColors.PushBack( Color::RED );
537 stopColors.PushBack( Color::GREEN );
538 propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
540 Visual::Base visual = factory.CreateVisual(propertyMap);
541 DALI_TEST_CHECK( visual );
543 // A lookup texture is generated and pass to shader as sampler
544 DummyControl actor = DummyControl::New();
545 TestVisualRender( application, actor, visual, 1u );
547 Matrix3 alignMatrix( radius, 0.f, 0.f, 0.f, radius, 0.f, center.x, center.y, 1.f );
548 alignMatrix.Invert();
550 Matrix3 actualValue( Matrix3::IDENTITY );
551 TestGlAbstraction& gl = application.GetGlAbstraction();
552 DALI_TEST_CHECK( gl.GetUniformValue<Matrix3>( "uAlignmentMatrix", actualValue ) );
553 DALI_TEST_EQUALS( actualValue, alignMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
558 int UtcDaliVisualFactoryDefaultOffsetsGradientVisual(void)
560 ToolkitTestApplication application;
561 tet_infoline("UtcDaliVisualFactoryGetRadialGradientVisual");
563 VisualFactory factory = VisualFactory::Get();
564 DALI_TEST_CHECK( factory );
566 Property::Map propertyMap;
567 propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
569 Vector2 start(-1.f, -1.f);
570 Vector2 end(1.f, 1.f);
571 propertyMap.Insert(GradientVisual::Property::START_POSITION, start);
572 propertyMap.Insert(GradientVisual::Property::END_POSITION, end);
573 propertyMap.Insert(GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT);
575 Property::Array stopColors;
576 stopColors.PushBack( Color::RED );
577 stopColors.PushBack( Color::GREEN );
578 propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
580 Visual::Base visual = factory.CreateVisual(propertyMap);
581 DALI_TEST_CHECK( visual );
583 // A lookup texture is generated and pass to shader as sampler
584 DummyControl actor = DummyControl::New();
585 TestVisualRender( application, actor, visual, 1u );
587 Stage::GetCurrent().Remove( actor );
588 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
593 int UtcDaliVisualFactoryGetImageVisual1(void)
595 ToolkitTestApplication application;
596 tet_infoline( "UtcDaliVisualFactoryGetImageVisual1: Request image visual with a Property::Map" );
598 VisualFactory factory = VisualFactory::Get();
599 DALI_TEST_CHECK( factory );
601 Property::Map propertyMap;
602 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
603 propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
605 Visual::Base visual = factory.CreateVisual( propertyMap );
606 DALI_TEST_CHECK( visual );
608 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
609 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
612 const int height=513;
613 TestGlAbstraction& gl = application.GetGlAbstraction();
614 TraceCallStack& textureTrace = gl.GetTextureTrace();
615 textureTrace.Enable(true);
617 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
618 bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, width, height,width, height );
620 DummyControl actor = DummyControl::New();
621 TestVisualRender( application, actor, visual, 1u,
622 ImageDimensions(width, height),
623 Integration::ResourcePointer( bitmap ) );
625 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
627 Stage::GetCurrent().Remove( actor );
628 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
633 int UtcDaliVisualFactoryGetImageVisual2(void)
635 ToolkitTestApplication application;
636 tet_infoline( "UtcDaliVisualFactoryGetImageVisual2: Request image visual with an image handle" );
638 VisualFactory factory = VisualFactory::Get();
639 DALI_TEST_CHECK( factory );
641 Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME);
642 Visual::Base visual = factory.CreateVisual( image );
644 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
645 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
648 const int height=513;
650 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
651 bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, width, height,width, height );
653 TestGlAbstraction& gl = application.GetGlAbstraction();
654 TraceCallStack& textureTrace = gl.GetTextureTrace();
655 textureTrace.Enable(true);
657 DummyControl actor = DummyControl::New();
658 TestVisualRender( application, actor, visual, 1u,
659 ImageDimensions(width, height),
660 Integration::ResourcePointer(bitmap) );
662 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
666 int UtcDaliVisualFactoryGetImageVisual3(void)
668 ToolkitTestApplication application;
669 tet_infoline( "UtcDaliVisualFactoryGetImageVisual3: Request image visual with a Property::Map, test custom wrap mode and pixel area with atlasing" );
671 VisualFactory factory = VisualFactory::Get();
672 DALI_TEST_CHECK( factory );
674 // Test wrap mode with atlasing. Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
677 const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
679 Property::Map propertyMap;
680 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
681 propertyMap.Insert( ImageVisual::Property::URL, gImage_34_RGBA );
682 propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, width );
683 propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, height );
684 propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true );
685 propertyMap.Insert( ImageVisual::Property::PIXEL_AREA, pixelArea );
686 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT );
687 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT );
689 Visual::Base visual = factory.CreateVisual( propertyMap );
690 DALI_TEST_CHECK( visual );
692 TestGlAbstraction& gl = application.GetGlAbstraction();
693 TraceCallStack& textureTrace = gl.GetTextureTrace();
694 textureTrace.Enable(true);
695 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
696 texParameterTrace.Enable( true );
698 DummyControl actor = DummyControl::New();
699 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
700 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
701 actor.SetSize(2000, 2000);
702 actor.SetParentOrigin(ParentOrigin::CENTER);
703 Stage::GetCurrent().Add( actor );
706 application.SendNotification();
707 application.Render();
708 application.Render();
709 application.SendNotification();
710 BitmapLoader loader = BitmapLoader::GetLatestCreated();
711 DALI_TEST_CHECK( loader );
712 loader.WaitForLoading();// waiting until the image to be loaded
713 DALI_TEST_CHECK( loader.IsLoaded() );
715 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
717 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
719 // WITH atlasing, the wrapping is handled manually in shader, so the following gl function should not be called
720 std::stringstream out;
721 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
722 DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
724 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
725 DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
727 // test the uniforms which used to handle the wrap mode
728 Renderer renderer = actor.GetRendererAt( 0u );
729 DALI_TEST_CHECK( renderer );
731 Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
732 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION );
733 Vector4 pixelAreaUniform;
734 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
735 DALI_TEST_EQUALS( pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
737 Property::Value wrapModeValue = renderer.GetProperty( renderer.GetPropertyIndex( "wrapMode" ) );
738 Vector2 wrapMode( WrapMode::MIRRORED_REPEAT-1, WrapMode::REPEAT-1 );
739 DALI_TEST_EQUALS( wrapModeValue.Get<Vector2>(), wrapMode, TEST_LOCATION );
740 Vector2 wrapModeUniform;
741 DALI_TEST_CHECK( gl.GetUniformValue<Vector2>( "wrapMode", wrapModeUniform ) );
742 DALI_TEST_EQUALS( wrapMode, wrapModeUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
745 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
750 int UtcDaliVisualFactoryGetImageVisual4(void)
752 ToolkitTestApplication application;
753 tet_infoline( "UtcDaliVisualFactoryGetImageVisual4: Request image visual with a Property::Map, test custom wrap mode and pixel area without atlasing" );
755 VisualFactory factory = VisualFactory::Get();
756 DALI_TEST_CHECK( factory );
758 // Test wrap mode without atlasing. Image with a size bigger than 512*512 will NOT be uploaded as a part of the atlas.
760 const int height=600;
761 const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
763 Property::Map propertyMap;
764 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
765 propertyMap.Insert( ImageVisual::Property::URL, gImage_600_RGB );
766 propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, width );
767 propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, height );
768 propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true );
769 propertyMap.Insert( ImageVisual::Property::PIXEL_AREA, pixelArea );
770 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT );
771 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT );
773 Visual::Base visual = factory.CreateVisual( propertyMap );
774 DALI_TEST_CHECK( visual );
776 TestGlAbstraction& gl = application.GetGlAbstraction();
777 TraceCallStack& textureTrace = gl.GetTextureTrace();
778 textureTrace.Enable(true);
779 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
780 texParameterTrace.Enable( true );
782 DummyControl actor = DummyControl::New();
783 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
784 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
785 actor.SetSize(2000, 2000);
786 actor.SetParentOrigin(ParentOrigin::CENTER);
787 Stage::GetCurrent().Add( actor );
790 application.SendNotification();
791 application.Render();
792 application.Render();
793 application.SendNotification();
794 BitmapLoader loader = BitmapLoader::GetLatestCreated();
795 DALI_TEST_CHECK( loader );
796 loader.WaitForLoading();// waiting until the image to be loaded
797 DALI_TEST_CHECK( loader.IsLoaded() );
799 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
801 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
803 // WITHOUT atlasing, the wrapping is handled by setting gl texture parameters
804 std::stringstream out;
805 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
806 DALI_TEST_CHECK( texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
808 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
809 DALI_TEST_CHECK( texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
811 // test the uniforms which used to handle the wrap mode
812 Renderer renderer = actor.GetRendererAt( 0u );
813 DALI_TEST_CHECK( renderer );
815 Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
816 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION );
817 Vector4 pixelAreaUniform;
818 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
819 DALI_TEST_EQUALS( pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
821 Property::Index wrapModeIndex = renderer.GetPropertyIndex( "wrapMode" );
822 DALI_TEST_CHECK(wrapModeIndex == Property::INVALID_INDEX);
825 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
830 int UtcDaliVisualFactoryGetNPatchVisual1(void)
832 ToolkitTestApplication application;
833 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual1: Request 9-patch visual with a Property::Map" );
835 VisualFactory factory = VisualFactory::Get();
836 DALI_TEST_CHECK( factory );
838 const unsigned int ninePatchImageHeight = 18;
839 const unsigned int ninePatchImageWidth = 28;
840 StretchRanges stretchRangesX;
841 stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
842 StretchRanges stretchRangesY;
843 stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
844 Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
846 Property::Map propertyMap;
847 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
848 propertyMap.Insert( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME );
850 tet_infoline( "whole grid" );
851 Visual::Base visual = factory.CreateVisual( propertyMap );
852 DALI_TEST_CHECK( visual );
855 TestGlAbstraction& gl = application.GetGlAbstraction();
856 TraceCallStack& textureTrace = gl.GetTextureTrace();
857 textureTrace.Enable(true);
859 DummyControl actor = DummyControl::New();
860 TestVisualRender( application, actor, visual, 1u,
861 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
864 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
867 propertyMap.Insert( ImageVisual::Property::BORDER_ONLY, true );
869 tet_infoline( "border only" );
870 Visual::Base visual = factory.CreateVisual( propertyMap );
871 DALI_TEST_CHECK( visual );
873 TestGlAbstraction& gl = application.GetGlAbstraction();
874 TraceCallStack& textureTrace = gl.GetTextureTrace();
875 textureTrace.Enable(true);
877 DummyControl actor = DummyControl::New();
878 TestVisualRender( application, actor, visual, 1u,
879 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
882 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
888 int UtcDaliVisualFactoryGetNPatchVisual2(void)
890 ToolkitTestApplication application;
891 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual2: Request n-patch visual with a Property::Map" );
893 VisualFactory factory = VisualFactory::Get();
894 DALI_TEST_CHECK( factory );
896 const unsigned int ninePatchImageWidth = 18;
897 const unsigned int ninePatchImageHeight = 28;
898 StretchRanges stretchRangesX;
899 stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
900 stretchRangesX.PushBack( Uint16Pair( 5, 7 ) );
901 stretchRangesX.PushBack( Uint16Pair( 12, 15 ) );
902 StretchRanges stretchRangesY;
903 stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
904 stretchRangesY.PushBack( Uint16Pair( 8, 12 ) );
905 stretchRangesY.PushBack( Uint16Pair( 15, 16 ) );
906 stretchRangesY.PushBack( Uint16Pair( 25, 27 ) );
907 Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
909 Property::Map propertyMap;
910 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
911 propertyMap.Insert( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME );
913 Visual::Base visual = factory.CreateVisual( propertyMap );
914 DALI_TEST_CHECK( visual );
916 TestGlAbstraction& gl = application.GetGlAbstraction();
917 TraceCallStack& textureTrace = gl.GetTextureTrace();
918 textureTrace.Enable(true);
920 DummyControl actor = DummyControl::New();
921 TestVisualRender( application, actor, visual, 1u,
922 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
925 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
927 Stage::GetCurrent().Remove( actor );
928 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
931 propertyMap.Insert( ImageVisual::Property::BORDER_ONLY, true );
933 tet_infoline( "border only" );
934 Visual::Base visual = factory.CreateVisual( propertyMap );
935 DALI_TEST_CHECK( visual );
937 TestGlAbstraction& gl = application.GetGlAbstraction();
938 TraceCallStack& textureTrace = gl.GetTextureTrace();
939 textureTrace.Enable(true);
940 DummyControl actor = DummyControl::New();
941 TestVisualRender( application, actor, visual, 1u,
942 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
946 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
948 Stage::GetCurrent().Remove( actor );
949 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
955 int UtcDaliVisualFactoryGetNPatchVisual3(void)
957 ToolkitTestApplication application;
958 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual3: Request 9-patch visual with an image url" );
960 VisualFactory factory = VisualFactory::Get();
961 DALI_TEST_CHECK( factory );
963 const unsigned int ninePatchImageHeight = 18;
964 const unsigned int ninePatchImageWidth = 28;
965 StretchRanges stretchRangesX;
966 stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
967 StretchRanges stretchRangesY;
968 stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
969 Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
971 Visual::Base visual = factory.CreateVisual( TEST_NPATCH_FILE_NAME, ImageDimensions() );
972 DALI_TEST_CHECK( visual );
974 TestGlAbstraction& gl = application.GetGlAbstraction();
975 TraceCallStack& textureTrace = gl.GetTextureTrace();
976 textureTrace.Enable(true);
978 DummyControl actor = DummyControl::New();
979 TestVisualRender( application, actor, visual, 1u,
980 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
983 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
986 ResourceImage image = ResourceImage::New(TEST_NPATCH_FILE_NAME);
987 Visual::Base nPatchVisual = factory.CreateVisual( image );
988 Vector2 controlSize( 20.f, 30.f ), naturalSize(0,0);
989 nPatchVisual.SetTransformAndSize(DefaultTransform(), controlSize );
990 nPatchVisual.GetNaturalSize( naturalSize );
991 DALI_TEST_EQUALS( naturalSize, Vector2( ninePatchImageWidth-2, ninePatchImageHeight-2 ), TEST_LOCATION );
996 int UtcDaliVisualFactoryGetNPatchVisual4(void)
998 ToolkitTestApplication application;
999 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual4: Request n-patch visual with an image url" );
1001 VisualFactory factory = VisualFactory::Get();
1002 DALI_TEST_CHECK( factory );
1004 const unsigned int ninePatchImageHeight = 18;
1005 const unsigned int ninePatchImageWidth = 28;
1006 StretchRanges stretchRangesX;
1007 stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
1008 stretchRangesX.PushBack( Uint16Pair( 5, 7 ) );
1009 stretchRangesX.PushBack( Uint16Pair( 12, 15 ) );
1010 StretchRanges stretchRangesY;
1011 stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
1012 stretchRangesY.PushBack( Uint16Pair( 8, 12 ) );
1013 stretchRangesY.PushBack( Uint16Pair( 15, 16 ) );
1014 stretchRangesY.PushBack( Uint16Pair( 25, 27 ) );
1015 Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
1017 Visual::Base visual = factory.CreateVisual( TEST_NPATCH_FILE_NAME, ImageDimensions() );
1018 DALI_TEST_CHECK( visual );
1020 TestGlAbstraction& gl = application.GetGlAbstraction();
1021 TraceCallStack& textureTrace = gl.GetTextureTrace();
1022 textureTrace.Enable(true);
1024 DummyControl actor = DummyControl::New();
1025 TestVisualRender( application, actor, visual, 1u,
1026 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
1027 ninePatchResource );
1029 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1034 int UtcDaliVisualFactoryGetNPatchVisualN1(void)
1036 //This should still load but display an error image
1038 ToolkitTestApplication application;
1039 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid image url" );
1041 VisualFactory factory = VisualFactory::Get();
1042 DALI_TEST_CHECK( factory );
1044 Visual::Base visual = factory.CreateVisual( "ERROR.9.jpg", ImageDimensions() );
1045 DALI_TEST_CHECK( visual );
1047 //The testkit still has to load a bitmap for the broken renderer image
1048 Integration::Bitmap* bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
1049 bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 100, 100, 100, 100 );
1051 TestGlAbstraction& gl = application.GetGlAbstraction();
1052 TraceCallStack& textureTrace = gl.GetTextureTrace();
1053 textureTrace.Enable(true);
1055 DummyControl actor = DummyControl::New();
1056 TestVisualRender( application, actor, visual, 1u,
1058 Integration::ResourcePointer(bitmap) );
1060 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1065 int UtcDaliVisualFactoryGetNPatchVisualN2(void)
1067 //This should still load but display an error image
1069 ToolkitTestApplication application;
1070 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid URL" );
1072 VisualFactory factory = VisualFactory::Get();
1073 DALI_TEST_CHECK( factory );
1075 Property::Map propertyMap;
1076 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
1077 propertyMap.Insert( ImageVisual::Property::URL, "ERROR.9.jpg" );
1079 Visual::Base visual = factory.CreateVisual( propertyMap );
1080 DALI_TEST_CHECK( visual );
1082 //The testkit still has to load a bitmap for the broken renderer image
1083 Integration::Bitmap* bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
1084 bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 100, 100, 100, 100 );
1086 TestGlAbstraction& gl = application.GetGlAbstraction();
1087 TraceCallStack& textureTrace = gl.GetTextureTrace();
1088 textureTrace.Enable(true);
1089 TraceCallStack& drawTrace = gl.GetDrawTrace();
1090 drawTrace.Enable(true);
1092 DummyControl actor = DummyControl::New();
1093 TestVisualRender( application, actor, visual, 1u,
1095 Integration::ResourcePointer(bitmap) );
1097 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1102 int UtcDaliVisualFactoryGetNPatchVisualN3(void)
1104 // Passing in an invalid visual type so we should not get a visual
1106 ToolkitTestApplication application;
1107 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid visual type" );
1109 VisualFactory factory = VisualFactory::Get();
1110 DALI_TEST_CHECK( factory );
1112 Property::Map propertyMap;
1113 propertyMap.Insert( Visual::Property::TYPE, 111 );
1114 propertyMap.Insert( ImageVisual::Property::URL, "ERROR.9.jpg" );
1116 Visual::Base visual = factory.CreateVisual( propertyMap );
1117 DALI_TEST_CHECK( !visual );
1122 int UtcDaliVisualFactoryGetSvgVisual(void)
1124 ToolkitTestApplication application;
1125 tet_infoline( "UtcDaliVisualFactoryGetSvgVisual: Request svg visual with a svg url" );
1127 VisualFactory factory = VisualFactory::Get();
1128 Visual::Base visual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions() );
1129 DALI_TEST_CHECK( visual );
1131 TestGlAbstraction& gl = application.GetGlAbstraction();
1132 TraceCallStack& textureTrace = gl.GetTextureTrace();
1133 textureTrace.Enable(true);
1135 DummyControl actor = DummyControl::New();
1136 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1137 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1138 actor.SetSize( 200.f, 200.f );
1139 Stage::GetCurrent().Add( actor );
1140 visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f) );
1142 application.SendNotification();
1143 application.Render();
1145 // renderer is not added to actor until the rasterization is completed.
1146 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1148 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1150 // renderer is added to actor
1151 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
1153 // waiting for the resource uploading
1154 application.SendNotification();
1155 application.Render();
1157 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1162 int UtcDaliVisualFactoryGetSvgVisualLarge(void)
1164 ToolkitTestApplication application;
1165 tet_infoline( "UtcDaliVisualFactoryGetSvgVisual: Request svg visual with a svg url" );
1167 VisualFactory factory = VisualFactory::Get();
1168 Visual::Base visual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions( 2000, 2000 ) );
1169 DALI_TEST_CHECK( visual );
1171 TestGlAbstraction& gl = application.GetGlAbstraction();
1172 TraceCallStack& textureTrace = gl.GetTextureTrace();
1173 textureTrace.Enable(true);
1175 DummyControl actor = DummyControl::New(true);
1176 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1177 actor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); // Only rasterizes when it knows control size.
1178 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1179 Stage::GetCurrent().Add( actor );
1181 application.SendNotification();
1182 application.Render();
1184 // renderer is not added to actor until the rasterization is completed.
1185 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1187 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1189 // renderer is added to actor
1190 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
1192 // waiting for the resource uploading
1193 application.SendNotification();
1194 application.Render();
1196 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1201 //Creates a mesh visual from the given propertyMap and tries to load it on stage in the given application.
1202 //This is expected to succeed, which will then pass the test.
1203 void MeshVisualLoadsCorrectlyTest( Property::Map& propertyMap, ToolkitTestApplication& application )
1205 VisualFactory factory = VisualFactory::Get();
1206 DALI_TEST_CHECK( factory );
1208 //Create a mesh visual.
1209 Visual::Base visual = factory.CreateVisual( propertyMap );
1210 DALI_TEST_CHECK( visual );
1212 //Create an actor on stage to house the visual.
1213 DummyControl actor = DummyControl::New();
1214 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1215 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1216 actor.SetSize( 200.f, 200.f );
1217 Stage::GetCurrent().Add( actor );
1218 visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.f, 200.f ) );
1220 //Ensure set on stage.
1221 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1223 //Attempt to render to queue resource load requests.
1224 application.SendNotification();
1225 application.Render( 0 );
1227 //Render again to upload the now-loaded textures.
1228 application.SendNotification();
1229 application.Render( 0 );
1231 Matrix testScaleMatrix;
1232 testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
1233 Matrix actualScaleMatrix;
1235 //Test to see if the object has been successfully loaded.
1236 DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
1237 DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1239 //Finish by setting off stage, and ensuring this was successful.
1241 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1244 //Creates a mesh visual from the given propertyMap and tries to load it on stage in the given application.
1245 //This is expected to fail, which will then pass the test.
1246 void MeshVisualDoesNotLoadCorrectlyTest( Property::Map& propertyMap, ToolkitTestApplication& application )
1248 VisualFactory factory = VisualFactory::Get();
1249 DALI_TEST_CHECK( factory );
1251 //Create a mesh visual.
1252 Visual::Base visual = factory.CreateVisual( propertyMap );
1253 DALI_TEST_CHECK( visual );
1255 //Create an actor on stage to house the visual.
1256 DummyControl actor = DummyControl::New();
1257 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1258 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1259 actor.SetSize( 200.f, 200.f );
1260 Stage::GetCurrent().Add( actor );
1261 visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.f, 200.f ) );
1263 //Ensure set on stage.
1264 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1266 //Attempt to render to queue resource load requests.
1267 application.SendNotification();
1268 application.Render( 0 );
1270 //Render again to upload the now-loaded textures.
1271 application.SendNotification();
1272 application.Render( 0 );
1274 //Test to see if the object has not been loaded, as expected.
1276 DALI_TEST_CHECK( !application.GetGlAbstraction().GetUniformValue<Matrix>( "uObjectMatrix", scaleMatrix ) );
1278 //Finish by setting off stage, and ensuring this was successful.
1280 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1283 //Test if mesh loads correctly when supplied with only the bare minimum requirements, an object file.
1284 int UtcDaliVisualFactoryGetMeshVisual1(void)
1286 //Set up test application first, so everything else can be handled.
1287 ToolkitTestApplication application;
1289 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual1: Request mesh visual with a valid object file only" );
1292 //Set up visual properties.
1293 Property::Map propertyMap;
1294 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1295 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1297 //Test to see if mesh loads correctly.
1298 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1304 //Test if mesh loads correctly when supplied with an object file as well as a blank material file and images directory.
1305 int UtcDaliVisualFactoryGetMeshVisual2(void)
1307 //Set up test application first, so everything else can be handled.
1308 ToolkitTestApplication application;
1310 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual2: Request mesh visual with blank material file and images directory" );
1312 //Set up visual properties.
1313 Property::Map propertyMap;
1314 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1315 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1316 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, "" );
1317 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, "" );
1319 //Test to see if mesh loads correctly.
1320 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1325 //Test if mesh loads correctly when supplied with all main parameters, an object file, a material file and a directory location, but duff optional parameters
1326 int UtcDaliVisualFactoryGetMeshVisual3b(void)
1328 //Set up test application first, so everything else can be handled.
1329 ToolkitTestApplication application;
1331 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual3: Request mesh visual with all parameters correct" );
1333 //Set up visual properties.
1334 Property::Map propertyMap;
1335 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1336 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1337 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1338 propertyMap.Insert( MeshVisual::Property::USE_MIPMAPPING, Color::GREEN ); // Test that wrong property types don't prevent the object load
1339 propertyMap.Insert( MeshVisual::Property::USE_SOFT_NORMALS, 1.0f );
1340 propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, 1.0f );
1341 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1343 //Test to see if mesh loads correctly.
1344 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1349 //Test if mesh loads correctly when supplied with all main parameters, an object file, a material file and a directory location.
1350 int UtcDaliVisualFactoryGetMeshVisual3(void)
1352 //Set up test application first, so everything else can be handled.
1353 ToolkitTestApplication application;
1355 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual3: Request mesh visual with all parameters correct" );
1357 //Set up visual properties.
1358 Property::Map propertyMap;
1359 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1360 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1361 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1362 propertyMap.Insert( MeshVisual::Property::USE_MIPMAPPING, false );
1363 propertyMap.Insert( MeshVisual::Property::USE_SOFT_NORMALS, false );
1364 propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3::XAXIS );
1365 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1367 //Test to see if mesh loads correctly.
1368 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1373 //Test if mesh visual can load a correctly supplied mesh without a normal map or gloss map in the material file.
1374 int UtcDaliVisualFactoryGetMeshVisual4(void)
1376 //Set up test application first, so everything else can be handled.
1377 ToolkitTestApplication application;
1379 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual4: Request mesh visual with diffuse texture but not normal or gloss." );
1382 //Set up visual properties.
1383 Property::Map propertyMap;
1384 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1385 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1386 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_SIMPLE_MTL_FILE_NAME );
1387 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1389 //Test to see if mesh loads correctly.
1390 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1395 //Test if mesh visual can load when made to use diffuse textures only.
1396 int UtcDaliVisualFactoryGetMeshVisual5(void)
1398 //Set up test application first, so everything else can be handled.
1399 ToolkitTestApplication application;
1401 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual5: Request mesh visual and make it only use diffuse textures." );
1403 //Set up visual properties.
1404 Property::Map propertyMap;
1405 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1406 propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME );
1407 propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME );
1408 propertyMap.Insert( "texturesPath", TEST_RESOURCE_DIR "/" );
1409 propertyMap.Insert( "useMipmapping", false );
1410 propertyMap.Insert( "useSoftNormals", false );
1411 propertyMap.Insert( "lightPosition", Vector3::ZAXIS );
1412 propertyMap.Insert( "shadingMode", MeshVisual::ShadingMode::TEXTURED_WITH_SPECULAR_LIGHTING );
1414 //Test to see if mesh loads correctly.
1415 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1421 //Test if mesh visual can load when made to not use the supplied textures.
1422 int UtcDaliVisualFactoryGetMeshVisual6(void)
1424 //Set up test application first, so everything else can be handled.
1425 ToolkitTestApplication application;
1427 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual6: Request mesh visual and make it not use any textures." );
1429 //Set up visual properties.
1430 Property::Map propertyMap;
1431 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1432 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1433 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1434 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1435 propertyMap.Insert( MeshVisual::Property::SHADING_MODE, MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING );
1437 //Test to see if mesh loads correctly.
1438 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1442 //Test if mesh visual loads correctly when light position is manually set.
1443 int UtcDaliVisualFactoryGetMeshVisual7(void)
1445 //Set up test application first, so everything else can be handled.
1446 ToolkitTestApplication application;
1449 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual7: Request mesh visual with custom light position." );
1451 //Set up visual properties.
1452 Property::Map propertyMap;
1453 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1454 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1455 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1456 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1457 propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.0, 1.0, 2.0 ) );
1459 //Test to see if mesh loads correctly.
1460 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1465 //Test if mesh visual loads correctly when supplied an object file without face normals or texture points.
1466 //Note that this notably tests object loader functionality.
1467 int UtcDaliVisualFactoryGetMeshVisual8(void)
1469 //Set up test application first, so everything else can be handled.
1470 ToolkitTestApplication application;
1472 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual5: Request mesh visual with normal-less object file." );
1474 //Set up visual properties.
1475 Property::Map propertyMap;
1476 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1477 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_SIMPLE_OBJ_FILE_NAME );
1478 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1479 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1481 //Test to see if mesh loads correctly.
1482 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1487 //Test if mesh visual handles the case of lacking an object file.
1488 int UtcDaliVisualFactoryGetMeshVisualN1(void)
1490 //Set up test application first, so everything else can be handled.
1491 ToolkitTestApplication application;
1493 tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN1: Request mesh visual without object file" );
1495 //Set up visual properties.
1496 Property::Map propertyMap;
1497 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1498 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1499 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1501 //Test to see if mesh doesn't load with these properties, as expected.
1502 MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
1508 //Test if mesh visual handles the case of being passed invalid material and images urls.
1509 int UtcDaliVisualFactoryGetMeshVisualN2(void)
1511 //Set up test application first, so everything else can be handled.
1512 ToolkitTestApplication application;
1514 tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN2: Request mesh visual with invalid material and images urls" );
1516 //Set up visual properties.
1517 Property::Map propertyMap;
1518 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1519 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1520 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, "invalid" );
1521 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, "also invalid" );
1523 //Test to see if mesh doesn't load with these properties, as expected.
1524 MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
1530 //Test if mesh visual handles the case of being passed an invalid object url
1531 int UtcDaliVisualFactoryGetMeshVisualN3(void)
1533 //Set up test application first, so everything else can be handled.
1534 ToolkitTestApplication application;
1535 tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN3: Request mesh visual with invalid object url" );
1538 //Set up visual properties.
1539 Property::Map propertyMap;
1540 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1541 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, "invalid" );
1542 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1543 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1545 //Test to see if mesh doesn't load with these properties, as expected.
1546 MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
1551 //Creates a primitive visual with the given property map and tests to see if it correctly loads in the given application.
1552 void TestPrimitiveVisualWithProperties( Property::Map& propertyMap, ToolkitTestApplication& application )
1554 VisualFactory factory = VisualFactory::Get();
1555 DALI_TEST_CHECK( factory );
1557 //Create a primitive visual.
1558 Visual::Base visual = factory.CreateVisual( propertyMap );
1559 DALI_TEST_CHECK( visual );
1561 //Create an actor on stage to house the visual.
1562 DummyControl actor = DummyControl::New();
1563 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1564 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1566 actor.SetSize( 200.f, 200.f );
1567 Stage::GetCurrent().Add( actor );
1568 visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.f, 200.f ) );
1570 //Ensure set on stage.
1571 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1573 //Tell test application to load the visual.
1574 application.SendNotification();
1575 application.Render(0);
1577 Matrix testScaleMatrix;
1578 testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
1579 Matrix actualScaleMatrix;
1581 //Test to see if the object has been successfully loaded.
1582 DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
1583 DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1585 //Finish by setting off stage, and ensuring this was successful.
1587 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1590 //Test if primitive shape loads correctly when supplied with only the bare minimum requirements, the shape to use.
1591 int UtcDaliVisualFactoryGetPrimitiveVisual1(void)
1593 //Set up test application first, so everything else can be handled.
1594 ToolkitTestApplication application;
1596 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual1: Request primitive visual with a shape only" );
1598 //Set up visual properties.
1599 Property::Map propertyMap;
1600 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1601 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
1603 //Test to see if shape loads correctly.
1604 TestPrimitiveVisualWithProperties( propertyMap, application );
1609 //Test if primitive shape loads correctly when supplied with all possible parameters
1610 int UtcDaliVisualFactoryGetPrimitiveVisual2(void)
1612 //Set up test application first, so everything else can be handled.
1613 ToolkitTestApplication application;
1615 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual2: Request primitive visual with everything" );
1617 //Set up visual properties.
1618 Property::Map propertyMap;
1619 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1620 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
1621 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1622 propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1623 propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
1624 propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
1625 propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f );
1626 propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
1627 propertyMap.Insert( PrimitiveVisual::Property::SCALE_RADIUS, 60.0f );
1628 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.7f );
1629 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, 0.8f );
1630 propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.9, 1.0, 1.1 ) );
1632 //Test to see if shape loads correctly.
1633 TestPrimitiveVisualWithProperties( propertyMap, application );
1638 //Test if primitive shape loads a sphere correctly.
1639 int UtcDaliVisualFactoryGetPrimitiveVisual3(void)
1641 //Set up test application first, so everything else can be handled.
1642 ToolkitTestApplication application;
1644 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual3: Request primitive visual to display a sphere" );
1646 //Set up visual properties.
1647 Property::Map propertyMap;
1648 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1649 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1650 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1651 propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1652 propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
1654 //Test to see if shape loads correctly.
1655 TestPrimitiveVisualWithProperties( propertyMap, application );
1660 //Test if primitive shape loads a conic section correctly.
1661 int UtcDaliVisualFactoryGetPrimitiveVisual4(void)
1663 //Set up test application first, so everything else can be handled.
1664 ToolkitTestApplication application;
1666 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual4: Request primitive visual to display a conic section" );
1668 //Set up visual properties.
1669 Property::Map propertyMap;
1670 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1671 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONICAL_FRUSTRUM );
1672 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1673 propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1674 propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
1675 propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f );
1676 propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
1678 //Test to see if shape loads correctly.
1679 TestPrimitiveVisualWithProperties( propertyMap, application );
1684 //Test if primitive shape loads a bevelled cube correctly.
1685 int UtcDaliVisualFactoryGetPrimitiveVisual5(void)
1687 //Set up test application first, so everything else can be handled.
1688 ToolkitTestApplication application;
1690 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual5: Request primitive visual to display a bevelled cube" );
1692 //Set up visual properties.
1693 Property::Map propertyMap;
1694 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1695 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::BEVELLED_CUBE );
1696 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1697 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.7f );
1699 //Test to see if shape loads correctly.
1700 TestPrimitiveVisualWithProperties( propertyMap, application );
1705 //Test if primitive shape loads an octahedron correctly.
1706 int UtcDaliVisualFactoryGetPrimitiveVisual6(void)
1708 //Set up test application first, so everything else can be handled.
1709 ToolkitTestApplication application;
1711 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual6: Request primitive visual to display an octahedron" );
1713 //Set up visual properties.
1714 Property::Map propertyMap;
1715 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1716 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::OCTAHEDRON );
1717 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1719 //Test to see if shape loads correctly.
1720 TestPrimitiveVisualWithProperties( propertyMap, application );
1725 //Test if primitive shape loads a cone correctly.
1726 int UtcDaliVisualFactoryGetPrimitiveVisual7(void)
1728 //Set up test application first, so everything else can be handled.
1729 ToolkitTestApplication application;
1731 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual7: Request primitive visual to display a cone" );
1733 //Set up visual properties.
1734 Property::Map propertyMap;
1735 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1736 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONE );
1737 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1738 propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1739 propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
1740 propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
1742 //Test to see if shape loads correctly.
1743 TestPrimitiveVisualWithProperties( propertyMap, application );
1748 //Test if primitive shape loads correctly when light position is manually set.
1749 int UtcDaliVisualFactoryGetPrimitiveVisual8(void)
1751 //Set up test application first, so everything else can be handled.
1752 ToolkitTestApplication application;
1754 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual8: Request primitive visual with set light position" );
1756 //Set up visual properties.
1757 Property::Map propertyMap;
1758 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1759 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1760 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1761 propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.0, 1.0, 2.0 ) );
1763 //Test to see if shape loads correctly.
1764 TestPrimitiveVisualWithProperties( propertyMap, application );
1769 //Test if primitive shape loads correctly when told to use too many slices.
1770 int UtcDaliVisualFactoryGetPrimitiveVisual9(void)
1772 //Set up test application first, so everything else can be handled.
1773 ToolkitTestApplication application;
1775 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual9: Request primitive visual with above-cap slices." );
1777 //Set up visual properties.
1778 Property::Map propertyMap;
1779 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1780 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1781 propertyMap.Insert( PrimitiveVisual::Property::SLICES, Property::Value( 1000000 ) );
1783 //Test to see if shape loads correctly.
1784 TestPrimitiveVisualWithProperties( propertyMap, application );
1789 //Test if primitive shape loads correctly when told to use too few slices. (2 slices or less.)
1790 int UtcDaliVisualFactoryGetPrimitiveVisual10(void)
1792 //Set up test application first, so everything else can be handled.
1793 ToolkitTestApplication application;
1795 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual10: Request primitive visual with too few slices." );
1797 //Set up visual properties.
1798 Property::Map propertyMap;
1799 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1800 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1801 propertyMap.Insert( PrimitiveVisual::Property::SLICES, Property::Value( 2 ) );
1803 //Test to see if shape loads correctly.
1804 TestPrimitiveVisualWithProperties( propertyMap, application );
1809 //Test if primitive shape loads correctly when told to use too many stacks.
1810 int UtcDaliVisualFactoryGetPrimitiveVisual11(void)
1812 //Set up test application first, so everything else can be handled.
1813 ToolkitTestApplication application;
1815 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual11: Request primitive visual with too many stacks." );
1817 //Set up visual properties.
1818 Property::Map propertyMap;
1819 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1820 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1821 propertyMap.Insert( PrimitiveVisual::Property::STACKS, Property::Value( 1000000 ) );
1823 //Test to see if shape loads correctly.
1824 TestPrimitiveVisualWithProperties( propertyMap, application );
1829 //Test if primitive shape loads correctly when told to use too few stacks. (1 stack or less.)
1830 int UtcDaliVisualFactoryGetPrimitiveVisual12(void)
1832 //Set up test application first, so everything else can be handled.
1833 ToolkitTestApplication application;
1835 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual12: Request primitive visual with too few stacks." );
1837 //Set up visual properties.
1838 Property::Map propertyMap;
1839 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1840 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1841 propertyMap.Insert( PrimitiveVisual::Property::STACKS, Property::Value( 1 ) );
1843 //Test to see if shape loads correctly.
1844 TestPrimitiveVisualWithProperties( propertyMap, application );
1849 //Test if primitive shape loads correctly when told to use invalid (zero or negative) dimensions.
1850 int UtcDaliVisualFactoryGetPrimitiveVisual13(void)
1852 //Set up test application first, so everything else can be handled.
1853 ToolkitTestApplication application;
1855 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual13: Request primitive visual with invalid scale dimensions." );
1857 //Set up visual properties.
1858 Property::Map propertyMap;
1859 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1860 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1861 propertyMap.Insert( PrimitiveVisual::Property::SCALE_DIMENSIONS, Vector3::ZERO );
1863 //Test to see if shape loads correctly.
1864 TestPrimitiveVisualWithProperties( propertyMap, application );
1869 //Test if primitive shape loads correctly when told to use too low a bevel percentage.
1870 int UtcDaliVisualFactoryGetPrimitiveVisual14(void)
1872 //Set up test application first, so everything else can be handled.
1873 ToolkitTestApplication application;
1875 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual14: Request primitive visual with too low a bevel percentage." );
1877 //Set up visual properties.
1878 Property::Map propertyMap;
1879 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1880 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1881 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, Property::Value( -1.0f ) );
1883 //Test to see if shape loads correctly.
1884 TestPrimitiveVisualWithProperties( propertyMap, application );
1889 //Test if primitive shape loads correctly when told to use too high a bevel percentage.
1890 int UtcDaliVisualFactoryGetPrimitiveVisual15(void)
1892 //Set up test application first, so everything else can be handled.
1893 ToolkitTestApplication application;
1895 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual15: Request primitive visual with too high a bevel percentage." );
1897 //Set up visual properties.
1898 Property::Map propertyMap;
1899 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1900 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1901 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, Property::Value( 2.0f ) );
1903 //Test to see if shape loads correctly.
1904 TestPrimitiveVisualWithProperties( propertyMap, application );
1909 //Test if primitive shape loads correctly when told to use too low a bevel smoothness.
1910 int UtcDaliVisualFactoryGetPrimitiveVisual16(void)
1912 //Set up test application first, so everything else can be handled.
1913 ToolkitTestApplication application;
1915 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual16: Request primitive visual with too low a bevel smoothness." );
1917 //Set up visual properties.
1918 Property::Map propertyMap;
1919 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1920 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1921 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, Property::Value( -1.0f ) );
1923 //Test to see if shape loads correctly.
1924 TestPrimitiveVisualWithProperties( propertyMap, application );
1929 //Test if primitive shape loads correctly when told to use too high a bevel smoothness.
1930 int UtcDaliVisualFactoryGetPrimitiveVisual17(void)
1932 //Set up test application first, so everything else can be handled.
1933 ToolkitTestApplication application;
1935 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual17: Request primitive visual with too high a bevel smoothness." );
1937 //Set up visual properties.
1938 Property::Map propertyMap;
1939 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1940 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1941 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, Property::Value( 2.0f ) );
1943 //Test to see if shape loads correctly.
1944 TestPrimitiveVisualWithProperties( propertyMap, application );
1949 //Test if primitive shape visual handles the case of not being passed a specific shape to use.
1950 int UtcDaliVisualFactoryGetPrimitiveVisualN1(void)
1952 //Set up test application first, so everything else can be handled.
1953 ToolkitTestApplication application;
1955 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisualN1: Request primitive visual without shape" );
1957 //Set up visual properties, without supplying shape.
1958 Property::Map propertyMap;
1959 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1961 //Test to see if shape loads regardless of missing input.
1962 TestPrimitiveVisualWithProperties( propertyMap, application );
1967 int UtcDaliVisualFactoryGetAnimatedImageVisual1(void)
1969 ToolkitTestApplication application;
1970 tet_infoline( "UtcDaliVisualFactoryGetAnimatedImageVisual1: Request animated image visual with a gif url" );
1972 VisualFactory factory = VisualFactory::Get();
1973 Visual::Base visual = factory.CreateVisual( TEST_GIF_FILE_NAME, ImageDimensions() );
1974 DALI_TEST_CHECK( visual );
1976 TestGlAbstraction& gl = application.GetGlAbstraction();
1977 TraceCallStack& textureTrace = gl.GetTextureTrace();
1978 textureTrace.Enable(true);
1980 DummyControl actor = DummyControl::New();
1981 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1982 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1983 actor.SetSize( 200.0f, 200.0f );
1984 Stage::GetCurrent().Add( actor );
1986 application.SendNotification();
1987 application.Render();
1989 // renderer is added to actor
1990 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
1992 // test the uniforms which used to handle the atlas rect
1993 // the four frames should be located inside atlas as follows: atlas size 100*100
2002 Renderer renderer = actor.GetRendererAt( 0u );
2003 DALI_TEST_CHECK( renderer );
2005 Property::Value atlasRectValue = renderer.GetProperty( renderer.GetPropertyIndex( "uAtlasRect" ) );
2006 // take into consideration the half pixel correction
2007 DALI_TEST_EQUALS( atlasRectValue.Get<Vector4>(), Vector4(0.5f, 0.5f, 49.5f, 49.5f)/100.f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2009 // waiting for the resource uploading
2010 application.SendNotification();
2011 application.Render();
2013 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
2015 // Force the timer used by the animatedImageVisual to tick,
2016 Dali::Timer timer = Timer::New( 0 );
2017 timer.MockEmitSignal();
2018 application.SendNotification();
2019 application.Render();
2020 atlasRectValue = renderer.GetProperty( renderer.GetPropertyIndex( "uAtlasRect" ) );
2021 // take into consideration the half pixel correction
2022 DALI_TEST_EQUALS( atlasRectValue.Get<Vector4>(), Vector4(50.5f, 0.5f, 99.5f, 49.5f)/100.f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2024 // Force the timer used by the animatedImageVisual to tick,
2025 timer.MockEmitSignal();
2026 application.SendNotification();
2027 application.Render();
2028 atlasRectValue = renderer.GetProperty( renderer.GetPropertyIndex( "uAtlasRect" ) );
2029 // take into consideration the half pixel correction
2030 DALI_TEST_EQUALS( atlasRectValue.Get<Vector4>(), Vector4(0.5f, 50.5f, 49.5f, 99.5f)/100.f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2032 // Force the timer used by the animatedImageVisual to tick,
2033 timer.MockEmitSignal();
2034 application.SendNotification();
2035 application.Render();
2036 atlasRectValue = renderer.GetProperty( renderer.GetPropertyIndex( "uAtlasRect" ) );
2037 // take into consideration the half pixel correction
2038 DALI_TEST_EQUALS( atlasRectValue.Get<Vector4>(), Vector4(50.5f, 50.5f, 99.5f, 99.5f)/100.f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2040 // Test SetOffStage().
2042 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
2047 int UtcDaliVisualFactoryGetAnimatedImageVisual2(void)
2049 ToolkitTestApplication application;
2050 tet_infoline( "UtcDaliVisualFactoryGetAnimatedImageVisual2: Request animated image visual with a Property::Map, test custom wrap mode and pixel area" );
2052 const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
2053 Property::Map propertyMap;
2054 propertyMap.Add( Visual::Property::TYPE, Visual::IMAGE )
2055 .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
2056 .Add( ImageVisual::Property::PIXEL_AREA, pixelArea )
2057 .Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT )
2058 .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT );
2060 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
2061 DALI_TEST_CHECK( visual );
2063 TestGlAbstraction& gl = application.GetGlAbstraction();
2064 TraceCallStack& textureTrace = gl.GetTextureTrace();
2065 textureTrace.Enable(true);
2066 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
2067 texParameterTrace.Enable( true );
2069 DummyControl actor = DummyControl::New();
2070 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2071 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
2072 actor.SetSize( 200.0f, 200.0f );
2073 Stage::GetCurrent().Add( actor );
2075 application.SendNotification();
2076 application.Render();
2078 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
2080 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
2082 // For animated image visual, the wrapping is handled manually in shader, so the following gl function should not be called
2083 std::stringstream out;
2084 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
2085 DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
2087 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
2088 DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
2090 // test the uniforms which used to handle the wrap mode
2091 Renderer renderer = actor.GetRendererAt( 0u );
2092 DALI_TEST_CHECK( renderer );
2094 Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
2095 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION );
2096 Vector4 pixelAreaUniform;
2097 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
2098 DALI_TEST_EQUALS( pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2100 Property::Value wrapModeValue = renderer.GetProperty( renderer.GetPropertyIndex( "wrapMode" ) );
2101 Vector2 wrapMode( WrapMode::MIRRORED_REPEAT-1, WrapMode::REPEAT-1 );
2102 DALI_TEST_EQUALS( wrapModeValue.Get<Vector2>(), wrapMode, TEST_LOCATION );
2103 Vector2 wrapModeUniform;
2104 DALI_TEST_CHECK( gl.GetUniformValue<Vector2>( "wrapMode", wrapModeUniform ) );
2105 DALI_TEST_EQUALS( wrapMode, wrapModeUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2108 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );