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 Vector3 actualValue(Vector4::ZERO);
335 TestGlAbstraction& gl = application.GetGlAbstraction();
336 DALI_TEST_CHECK( gl.GetUniformValue<Vector3>( "mixColor", actualValue ) );
337 DALI_TEST_CHECK( gl.GetUniformValue<float>( "opacity", opacity ) );
338 DALI_TEST_EQUALS( actualValue, Vector3(testColor), TEST_LOCATION );
339 DALI_TEST_EQUALS( opacity, testColor.a, TEST_LOCATION );
344 int UtcDaliVisualFactoryGetColorVisual2(void)
346 ToolkitTestApplication application;
347 tet_infoline( "UtcDaliVisualFactoryGetColorVisual2: Request color visual with a Vector4" );
349 VisualFactory factory = VisualFactory::Get();
350 DALI_TEST_CHECK( factory );
352 Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
353 Dali::Property::Map map;
354 map[ Visual::Property::TYPE ] = Visual::COLOR;
355 map[ ColorVisual::Property::MIX_COLOR ] = testColor;
356 Visual::Base visual = factory.CreateVisual( map );
357 DALI_TEST_CHECK( visual );
359 DummyControl actor = DummyControl::New();
360 TestVisualRender( application, actor, visual );
364 TestGlAbstraction& gl = application.GetGlAbstraction();
365 DALI_TEST_CHECK( gl.GetUniformValue<Vector3>( "mixColor", actualValue ) );
366 DALI_TEST_CHECK( gl.GetUniformValue<float>( "opacity", opacity ) );
367 DALI_TEST_EQUALS( actualValue, Vector3(testColor), TEST_LOCATION );
368 DALI_TEST_EQUALS( opacity, testColor.a, TEST_LOCATION );
370 Stage::GetCurrent().Remove(actor);
371 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
376 int UtcDaliVisualFactoryGetBorderVisual1(void)
378 ToolkitTestApplication application;
379 tet_infoline( "UtcDaliVisualFactoryGetBorderVisual1: Request border visual with a Property::Map" );
381 VisualFactory factory = VisualFactory::Get();
382 DALI_TEST_CHECK( factory );
384 Property::Map propertyMap;
385 Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
386 float testSize = 5.f;
387 propertyMap.Insert(Visual::Property::TYPE, Visual::BORDER);
388 propertyMap.Insert(BorderVisual::Property::COLOR, testColor);
389 propertyMap.Insert(BorderVisual::Property::SIZE, testSize);
391 Visual::Base visual = factory.CreateVisual(propertyMap);
392 DALI_TEST_CHECK( visual );
394 DummyControl actor = DummyControl::New();
395 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
396 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
397 actor.SetSize(200.f, 200.f);
398 Stage::GetCurrent().Add( actor );
399 visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f));
401 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
402 int blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLEND_MODE );
403 DALI_TEST_EQUALS( static_cast<BlendMode::Type>(blendMode), BlendMode::ON, TEST_LOCATION );
405 TestGlAbstraction& gl = application.GetGlAbstraction();
407 application.SendNotification();
408 application.Render(0);
410 Vector4 actualColor(Vector4::ZERO);
411 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "borderColor", actualColor ) );
412 DALI_TEST_EQUALS( actualColor, testColor, TEST_LOCATION );
414 float actualSize = 0.f;
415 DALI_TEST_CHECK( gl.GetUniformValue<float>( "borderSize", actualSize ) );
416 DALI_TEST_EQUALS( actualSize, testSize, TEST_LOCATION );
419 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
424 int UtcDaliVisualFactoryGetBorderVisual2(void)
426 ToolkitTestApplication application;
427 tet_infoline( "UtcDaliVisualFactoryGetBorderVisual2: Request border visual with a borderSize and a borderColor" );
429 VisualFactory factory = VisualFactory::Get();
430 DALI_TEST_CHECK( factory );
432 Vector4 testColor( 1.f, 0.5f, 0.3f, 1.f );
433 float testSize = 5.f;
435 Dali::Property::Map propertyMap;
436 propertyMap[ Visual::Property::TYPE ] = Visual::BORDER;
437 propertyMap[ BorderVisual::Property::COLOR ] = testColor;
438 propertyMap[ BorderVisual::Property::SIZE ] = testSize;
439 Visual::Base visual = factory.CreateVisual( propertyMap );
440 DALI_TEST_CHECK( visual );
442 DummyControl actor = DummyControl::New();
443 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
444 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
445 actor.SetSize(200.f, 200.f);
446 Stage::GetCurrent().Add( actor );
447 visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f));
449 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
451 TestGlAbstraction& gl = application.GetGlAbstraction();
453 application.SendNotification();
454 application.Render(0);
456 int blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLEND_MODE );
457 DALI_TEST_EQUALS( static_cast<BlendMode::Type>(blendMode), BlendMode::AUTO, TEST_LOCATION );
459 Vector4 actualColor(Vector4::ZERO);
460 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "borderColor", actualColor ) );
461 DALI_TEST_EQUALS( actualColor, testColor, TEST_LOCATION );
463 float actualSize = 0.f;
464 DALI_TEST_CHECK( gl.GetUniformValue<float>( "borderSize", actualSize ) );
465 DALI_TEST_EQUALS( actualSize, testSize, TEST_LOCATION );
469 // enable the anti-aliasing
470 Dali::Property::Map map;
471 map[ Visual::Property::TYPE ] = Visual::BORDER;
472 map[ BorderVisual::Property::COLOR ] = testColor;
473 map[ BorderVisual::Property::SIZE ] = testSize;
474 map[ BorderVisual::Property::ANTI_ALIASING ] = true;
475 visual = factory.CreateVisual( map );
477 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
478 Stage::GetCurrent().Add( actor );
480 blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLEND_MODE );
481 DALI_TEST_EQUALS( static_cast<BlendMode::Type>(blendMode), BlendMode::ON, TEST_LOCATION );
486 int UtcDaliVisualFactoryGetLinearGradientVisual(void)
488 ToolkitTestApplication application;
489 tet_infoline("UtcDaliVisualFactoryGetRadialGradientVisual");
491 VisualFactory factory = VisualFactory::Get();
492 DALI_TEST_CHECK( factory );
494 Property::Map propertyMap;
495 propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
497 Vector2 start(-1.f, -1.f);
498 Vector2 end(1.f, 1.f);
499 propertyMap.Insert(GradientVisual::Property::START_POSITION, start);
500 propertyMap.Insert(GradientVisual::Property::END_POSITION, end);
501 propertyMap.Insert(GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT);
503 Property::Array stopOffsets;
504 stopOffsets.PushBack( 0.2f );
505 stopOffsets.PushBack( 0.8f );
506 propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, stopOffsets);
508 Property::Array stopColors;
509 stopColors.PushBack( Color::RED );
510 stopColors.PushBack( Color::GREEN );
511 propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
513 Visual::Base visual = factory.CreateVisual(propertyMap);
514 DALI_TEST_CHECK( visual );
516 // A lookup texture is generated and pass to shader as sampler
517 DummyControl actor = DummyControl::New();
518 TestVisualRender( application, actor, visual, 1u);
523 int UtcDaliVisualFactoryGetRadialGradientVisual(void)
525 ToolkitTestApplication application;
526 tet_infoline("UtcDaliVisualFactoryGetRadialGradientVisual");
528 VisualFactory factory = VisualFactory::Get();
529 DALI_TEST_CHECK( factory );
531 Property::Map propertyMap;
532 propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
534 Vector2 center(100.f, 100.f);
535 float radius = 100.f;
536 propertyMap.Insert(GradientVisual::Property::UNITS, GradientVisual::Units::USER_SPACE);
537 propertyMap.Insert(GradientVisual::Property::CENTER, center);
538 propertyMap.Insert(GradientVisual::Property::RADIUS, radius);
540 Property::Array stopOffsets;
541 stopOffsets.PushBack( 0.0f );
542 stopOffsets.PushBack( 1.f );
543 propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, stopOffsets);
545 Property::Array stopColors;
546 stopColors.PushBack( Color::RED );
547 stopColors.PushBack( Color::GREEN );
548 propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
550 Visual::Base visual = factory.CreateVisual(propertyMap);
551 DALI_TEST_CHECK( visual );
553 // A lookup texture is generated and pass to shader as sampler
554 DummyControl actor = DummyControl::New();
555 TestVisualRender( application, actor, visual, 1u );
557 Matrix3 alignMatrix( radius, 0.f, 0.f, 0.f, radius, 0.f, center.x, center.y, 1.f );
558 alignMatrix.Invert();
560 Matrix3 actualValue( Matrix3::IDENTITY );
561 TestGlAbstraction& gl = application.GetGlAbstraction();
562 DALI_TEST_CHECK( gl.GetUniformValue<Matrix3>( "uAlignmentMatrix", actualValue ) );
563 DALI_TEST_EQUALS( actualValue, alignMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
568 int UtcDaliVisualFactoryDefaultOffsetsGradientVisual(void)
570 ToolkitTestApplication application;
571 tet_infoline("UtcDaliVisualFactoryGetRadialGradientVisual");
573 VisualFactory factory = VisualFactory::Get();
574 DALI_TEST_CHECK( factory );
576 Property::Map propertyMap;
577 propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
579 Vector2 start(-1.f, -1.f);
580 Vector2 end(1.f, 1.f);
581 propertyMap.Insert(GradientVisual::Property::START_POSITION, start);
582 propertyMap.Insert(GradientVisual::Property::END_POSITION, end);
583 propertyMap.Insert(GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT);
585 Property::Array stopColors;
586 stopColors.PushBack( Color::RED );
587 stopColors.PushBack( Color::GREEN );
588 propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
590 Visual::Base visual = factory.CreateVisual(propertyMap);
591 DALI_TEST_CHECK( visual );
593 // A lookup texture is generated and pass to shader as sampler
594 DummyControl actor = DummyControl::New();
595 TestVisualRender( application, actor, visual, 1u );
597 Stage::GetCurrent().Remove( actor );
598 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
603 int UtcDaliVisualFactoryGetImageVisual1(void)
605 ToolkitTestApplication application;
606 tet_infoline( "UtcDaliVisualFactoryGetImageVisual1: Request image visual with a Property::Map" );
608 VisualFactory factory = VisualFactory::Get();
609 DALI_TEST_CHECK( factory );
611 Property::Map propertyMap;
612 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
613 propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
615 Visual::Base visual = factory.CreateVisual( propertyMap );
616 DALI_TEST_CHECK( visual );
618 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
619 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
622 const int height=513;
623 TestGlAbstraction& gl = application.GetGlAbstraction();
624 TraceCallStack& textureTrace = gl.GetTextureTrace();
625 textureTrace.Enable(true);
627 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
628 bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, width, height,width, height );
630 DummyControl actor = DummyControl::New();
631 TestVisualRender( application, actor, visual, 1u,
632 ImageDimensions(width, height),
633 Integration::ResourcePointer( bitmap ) );
635 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
637 Stage::GetCurrent().Remove( actor );
638 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
643 int UtcDaliVisualFactoryGetImageVisual2(void)
645 ToolkitTestApplication application;
646 tet_infoline( "UtcDaliVisualFactoryGetImageVisual2: Request image visual with an image handle" );
648 VisualFactory factory = VisualFactory::Get();
649 DALI_TEST_CHECK( factory );
651 Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME);
652 Visual::Base visual = factory.CreateVisual( image );
654 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
655 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
658 const int height=513;
660 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
661 bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, width, height,width, height );
663 TestGlAbstraction& gl = application.GetGlAbstraction();
664 TraceCallStack& textureTrace = gl.GetTextureTrace();
665 textureTrace.Enable(true);
667 DummyControl actor = DummyControl::New();
668 TestVisualRender( application, actor, visual, 1u,
669 ImageDimensions(width, height),
670 Integration::ResourcePointer(bitmap) );
672 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
676 int UtcDaliVisualFactoryGetImageVisual3(void)
678 ToolkitTestApplication application;
679 tet_infoline( "UtcDaliVisualFactoryGetImageVisual3: Request image visual with a Property::Map, test custom wrap mode and pixel area with atlasing" );
681 VisualFactory factory = VisualFactory::Get();
682 DALI_TEST_CHECK( factory );
684 // Test wrap mode with atlasing. Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
687 const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
689 Property::Map propertyMap;
690 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
691 propertyMap.Insert( ImageVisual::Property::URL, gImage_34_RGBA );
692 propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, width );
693 propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, height );
694 propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true );
695 propertyMap.Insert( ImageVisual::Property::PIXEL_AREA, pixelArea );
696 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT );
697 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT );
699 Visual::Base visual = factory.CreateVisual( propertyMap );
700 DALI_TEST_CHECK( visual );
702 TestGlAbstraction& gl = application.GetGlAbstraction();
703 TraceCallStack& textureTrace = gl.GetTextureTrace();
704 textureTrace.Enable(true);
705 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
706 texParameterTrace.Enable( true );
708 DummyControl actor = DummyControl::New();
709 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
710 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
711 actor.SetSize(2000, 2000);
712 actor.SetParentOrigin(ParentOrigin::CENTER);
713 Stage::GetCurrent().Add( actor );
716 application.SendNotification();
717 application.Render();
718 application.Render();
719 application.SendNotification();
720 BitmapLoader loader = BitmapLoader::GetLatestCreated();
721 DALI_TEST_CHECK( loader );
722 loader.WaitForLoading();// waiting until the image to be loaded
723 DALI_TEST_CHECK( loader.IsLoaded() );
725 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
727 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
729 // WITH atlasing, the wrapping is handled manually in shader, so the following gl function should not be called
730 std::stringstream out;
731 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
732 DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
734 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
735 DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
737 // test the uniforms which used to handle the wrap mode
738 Renderer renderer = actor.GetRendererAt( 0u );
739 DALI_TEST_CHECK( renderer );
741 Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
742 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION );
743 Vector4 pixelAreaUniform;
744 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
745 DALI_TEST_EQUALS( pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
747 Property::Value wrapModeValue = renderer.GetProperty( renderer.GetPropertyIndex( "wrapMode" ) );
748 Vector2 wrapMode( WrapMode::MIRRORED_REPEAT-1, WrapMode::REPEAT-1 );
749 DALI_TEST_EQUALS( wrapModeValue.Get<Vector2>(), wrapMode, TEST_LOCATION );
750 Vector2 wrapModeUniform;
751 DALI_TEST_CHECK( gl.GetUniformValue<Vector2>( "wrapMode", wrapModeUniform ) );
752 DALI_TEST_EQUALS( wrapMode, wrapModeUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
755 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
760 int UtcDaliVisualFactoryGetImageVisual4(void)
762 ToolkitTestApplication application;
763 tet_infoline( "UtcDaliVisualFactoryGetImageVisual4: Request image visual with a Property::Map, test custom wrap mode and pixel area without atlasing" );
765 VisualFactory factory = VisualFactory::Get();
766 DALI_TEST_CHECK( factory );
768 // Test wrap mode without atlasing. Image with a size bigger than 512*512 will NOT be uploaded as a part of the atlas.
770 const int height=600;
771 const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
773 Property::Map propertyMap;
774 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
775 propertyMap.Insert( ImageVisual::Property::URL, gImage_600_RGB );
776 propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, width );
777 propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, height );
778 propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true );
779 propertyMap.Insert( ImageVisual::Property::PIXEL_AREA, pixelArea );
780 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT );
781 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT );
783 Visual::Base visual = factory.CreateVisual( propertyMap );
784 DALI_TEST_CHECK( visual );
786 TestGlAbstraction& gl = application.GetGlAbstraction();
787 TraceCallStack& textureTrace = gl.GetTextureTrace();
788 textureTrace.Enable(true);
789 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
790 texParameterTrace.Enable( true );
792 DummyControl actor = DummyControl::New();
793 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
794 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
795 actor.SetSize(2000, 2000);
796 actor.SetParentOrigin(ParentOrigin::CENTER);
797 Stage::GetCurrent().Add( actor );
800 application.SendNotification();
801 application.Render();
802 application.Render();
803 application.SendNotification();
804 BitmapLoader loader = BitmapLoader::GetLatestCreated();
805 DALI_TEST_CHECK( loader );
806 loader.WaitForLoading();// waiting until the image to be loaded
807 DALI_TEST_CHECK( loader.IsLoaded() );
809 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
811 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
813 // WITHOUT atlasing, the wrapping is handled by setting gl texture parameters
814 std::stringstream out;
815 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
816 DALI_TEST_CHECK( texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
818 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
819 DALI_TEST_CHECK( texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
821 // test the uniforms which used to handle the wrap mode
822 Renderer renderer = actor.GetRendererAt( 0u );
823 DALI_TEST_CHECK( renderer );
825 Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
826 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION );
827 Vector4 pixelAreaUniform;
828 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
829 DALI_TEST_EQUALS( pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
831 Property::Index wrapModeIndex = renderer.GetPropertyIndex( "wrapMode" );
832 DALI_TEST_CHECK(wrapModeIndex == Property::INVALID_INDEX);
835 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
840 int UtcDaliVisualFactoryGetNPatchVisual1(void)
842 ToolkitTestApplication application;
843 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual1: Request 9-patch visual with a Property::Map" );
845 VisualFactory factory = VisualFactory::Get();
846 DALI_TEST_CHECK( factory );
848 const unsigned int ninePatchImageHeight = 18;
849 const unsigned int ninePatchImageWidth = 28;
850 StretchRanges stretchRangesX;
851 stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
852 StretchRanges stretchRangesY;
853 stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
854 Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
856 Property::Map propertyMap;
857 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
858 propertyMap.Insert( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME );
860 tet_infoline( "whole grid" );
861 Visual::Base visual = factory.CreateVisual( propertyMap );
862 DALI_TEST_CHECK( visual );
865 TestGlAbstraction& gl = application.GetGlAbstraction();
866 TraceCallStack& textureTrace = gl.GetTextureTrace();
867 textureTrace.Enable(true);
869 DummyControl actor = DummyControl::New();
870 TestVisualRender( application, actor, visual, 1u,
871 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
874 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
877 propertyMap.Insert( ImageVisual::Property::BORDER_ONLY, true );
879 tet_infoline( "border only" );
880 Visual::Base visual = factory.CreateVisual( propertyMap );
881 DALI_TEST_CHECK( visual );
883 TestGlAbstraction& gl = application.GetGlAbstraction();
884 TraceCallStack& textureTrace = gl.GetTextureTrace();
885 textureTrace.Enable(true);
887 DummyControl actor = DummyControl::New();
888 TestVisualRender( application, actor, visual, 1u,
889 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
892 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
898 int UtcDaliVisualFactoryGetNPatchVisual2(void)
900 ToolkitTestApplication application;
901 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual2: Request n-patch visual with a Property::Map" );
903 VisualFactory factory = VisualFactory::Get();
904 DALI_TEST_CHECK( factory );
906 const unsigned int ninePatchImageWidth = 18;
907 const unsigned int ninePatchImageHeight = 28;
908 StretchRanges stretchRangesX;
909 stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
910 stretchRangesX.PushBack( Uint16Pair( 5, 7 ) );
911 stretchRangesX.PushBack( Uint16Pair( 12, 15 ) );
912 StretchRanges stretchRangesY;
913 stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
914 stretchRangesY.PushBack( Uint16Pair( 8, 12 ) );
915 stretchRangesY.PushBack( Uint16Pair( 15, 16 ) );
916 stretchRangesY.PushBack( Uint16Pair( 25, 27 ) );
917 Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
919 Property::Map propertyMap;
920 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
921 propertyMap.Insert( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME );
923 Visual::Base visual = factory.CreateVisual( propertyMap );
924 DALI_TEST_CHECK( visual );
926 TestGlAbstraction& gl = application.GetGlAbstraction();
927 TraceCallStack& textureTrace = gl.GetTextureTrace();
928 textureTrace.Enable(true);
930 DummyControl actor = DummyControl::New();
931 TestVisualRender( application, actor, visual, 1u,
932 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
935 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
937 Stage::GetCurrent().Remove( actor );
938 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
941 propertyMap.Insert( ImageVisual::Property::BORDER_ONLY, true );
943 tet_infoline( "border only" );
944 Visual::Base visual = factory.CreateVisual( propertyMap );
945 DALI_TEST_CHECK( visual );
947 TestGlAbstraction& gl = application.GetGlAbstraction();
948 TraceCallStack& textureTrace = gl.GetTextureTrace();
949 textureTrace.Enable(true);
950 DummyControl actor = DummyControl::New();
951 TestVisualRender( application, actor, visual, 1u,
952 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
956 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
958 Stage::GetCurrent().Remove( actor );
959 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
965 int UtcDaliVisualFactoryGetNPatchVisual3(void)
967 ToolkitTestApplication application;
968 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual3: Request 9-patch visual with an image url" );
970 VisualFactory factory = VisualFactory::Get();
971 DALI_TEST_CHECK( factory );
973 const unsigned int ninePatchImageHeight = 18;
974 const unsigned int ninePatchImageWidth = 28;
975 StretchRanges stretchRangesX;
976 stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
977 StretchRanges stretchRangesY;
978 stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
979 Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
981 Visual::Base visual = factory.CreateVisual( TEST_NPATCH_FILE_NAME, ImageDimensions() );
982 DALI_TEST_CHECK( visual );
984 TestGlAbstraction& gl = application.GetGlAbstraction();
985 TraceCallStack& textureTrace = gl.GetTextureTrace();
986 textureTrace.Enable(true);
988 DummyControl actor = DummyControl::New();
989 TestVisualRender( application, actor, visual, 1u,
990 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
993 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
996 ResourceImage image = ResourceImage::New(TEST_NPATCH_FILE_NAME);
997 Visual::Base nPatchVisual = factory.CreateVisual( image );
998 Vector2 controlSize( 20.f, 30.f ), naturalSize(0,0);
999 nPatchVisual.SetTransformAndSize(DefaultTransform(), controlSize );
1000 nPatchVisual.GetNaturalSize( naturalSize );
1001 DALI_TEST_EQUALS( naturalSize, Vector2( ninePatchImageWidth-2, ninePatchImageHeight-2 ), TEST_LOCATION );
1006 int UtcDaliVisualFactoryGetNPatchVisual4(void)
1008 ToolkitTestApplication application;
1009 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual4: Request n-patch visual with an image url" );
1011 VisualFactory factory = VisualFactory::Get();
1012 DALI_TEST_CHECK( factory );
1014 const unsigned int ninePatchImageHeight = 18;
1015 const unsigned int ninePatchImageWidth = 28;
1016 StretchRanges stretchRangesX;
1017 stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
1018 stretchRangesX.PushBack( Uint16Pair( 5, 7 ) );
1019 stretchRangesX.PushBack( Uint16Pair( 12, 15 ) );
1020 StretchRanges stretchRangesY;
1021 stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
1022 stretchRangesY.PushBack( Uint16Pair( 8, 12 ) );
1023 stretchRangesY.PushBack( Uint16Pair( 15, 16 ) );
1024 stretchRangesY.PushBack( Uint16Pair( 25, 27 ) );
1025 Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
1027 Visual::Base visual = factory.CreateVisual( TEST_NPATCH_FILE_NAME, ImageDimensions() );
1028 DALI_TEST_CHECK( visual );
1030 TestGlAbstraction& gl = application.GetGlAbstraction();
1031 TraceCallStack& textureTrace = gl.GetTextureTrace();
1032 textureTrace.Enable(true);
1034 DummyControl actor = DummyControl::New();
1035 TestVisualRender( application, actor, visual, 1u,
1036 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
1037 ninePatchResource );
1039 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1044 int UtcDaliVisualFactoryGetNPatchVisualN1(void)
1046 //This should still load but display an error image
1048 ToolkitTestApplication application;
1049 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid image url" );
1051 VisualFactory factory = VisualFactory::Get();
1052 DALI_TEST_CHECK( factory );
1054 Visual::Base visual = factory.CreateVisual( "ERROR.9.jpg", ImageDimensions() );
1055 DALI_TEST_CHECK( visual );
1057 //The testkit still has to load a bitmap for the broken renderer image
1058 Integration::Bitmap* bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
1059 bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 100, 100, 100, 100 );
1061 TestGlAbstraction& gl = application.GetGlAbstraction();
1062 TraceCallStack& textureTrace = gl.GetTextureTrace();
1063 textureTrace.Enable(true);
1065 DummyControl actor = DummyControl::New();
1066 TestVisualRender( application, actor, visual, 1u,
1068 Integration::ResourcePointer(bitmap) );
1070 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1075 int UtcDaliVisualFactoryGetNPatchVisualN2(void)
1077 //This should still load but display an error image
1079 ToolkitTestApplication application;
1080 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid URL" );
1082 VisualFactory factory = VisualFactory::Get();
1083 DALI_TEST_CHECK( factory );
1085 Property::Map propertyMap;
1086 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
1087 propertyMap.Insert( ImageVisual::Property::URL, "ERROR.9.jpg" );
1089 Visual::Base visual = factory.CreateVisual( propertyMap );
1090 DALI_TEST_CHECK( visual );
1092 //The testkit still has to load a bitmap for the broken renderer image
1093 Integration::Bitmap* bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
1094 bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 100, 100, 100, 100 );
1096 TestGlAbstraction& gl = application.GetGlAbstraction();
1097 TraceCallStack& textureTrace = gl.GetTextureTrace();
1098 textureTrace.Enable(true);
1099 TraceCallStack& drawTrace = gl.GetDrawTrace();
1100 drawTrace.Enable(true);
1102 DummyControl actor = DummyControl::New();
1103 TestVisualRender( application, actor, visual, 1u,
1105 Integration::ResourcePointer(bitmap) );
1107 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1112 int UtcDaliVisualFactoryGetNPatchVisualN3(void)
1114 // Passing in an invalid visual type so we should not get a visual
1116 ToolkitTestApplication application;
1117 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid visual type" );
1119 VisualFactory factory = VisualFactory::Get();
1120 DALI_TEST_CHECK( factory );
1122 Property::Map propertyMap;
1123 propertyMap.Insert( Visual::Property::TYPE, 111 );
1124 propertyMap.Insert( ImageVisual::Property::URL, "ERROR.9.jpg" );
1126 Visual::Base visual = factory.CreateVisual( propertyMap );
1127 DALI_TEST_CHECK( !visual );
1132 int UtcDaliVisualFactoryGetSvgVisual(void)
1134 ToolkitTestApplication application;
1135 tet_infoline( "UtcDaliVisualFactoryGetSvgVisual: Request svg visual with a svg url" );
1137 VisualFactory factory = VisualFactory::Get();
1138 Visual::Base visual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions() );
1139 DALI_TEST_CHECK( visual );
1141 TestGlAbstraction& gl = application.GetGlAbstraction();
1142 TraceCallStack& textureTrace = gl.GetTextureTrace();
1143 textureTrace.Enable(true);
1145 DummyControl actor = DummyControl::New();
1146 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1147 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1148 actor.SetSize( 200.f, 200.f );
1149 Stage::GetCurrent().Add( actor );
1150 visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f) );
1152 application.SendNotification();
1153 application.Render();
1155 // renderer is not added to actor until the rasterization is completed.
1156 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1158 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1160 // renderer is added to actor
1161 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
1163 // waiting for the resource uploading
1164 application.SendNotification();
1165 application.Render();
1167 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1172 int UtcDaliVisualFactoryGetSvgVisualLarge(void)
1174 ToolkitTestApplication application;
1175 tet_infoline( "UtcDaliVisualFactoryGetSvgVisual: Request svg visual with a svg url" );
1177 VisualFactory factory = VisualFactory::Get();
1178 Visual::Base visual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions( 2000, 2000 ) );
1179 DALI_TEST_CHECK( visual );
1181 TestGlAbstraction& gl = application.GetGlAbstraction();
1182 TraceCallStack& textureTrace = gl.GetTextureTrace();
1183 textureTrace.Enable(true);
1185 DummyControl actor = DummyControl::New(true);
1186 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1187 actor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); // Only rasterizes when it knows control size.
1188 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1189 Stage::GetCurrent().Add( actor );
1191 application.SendNotification();
1192 application.Render();
1194 // renderer is not added to actor until the rasterization is completed.
1195 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1197 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1199 // renderer is added to actor
1200 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
1202 // waiting for the resource uploading
1203 application.SendNotification();
1204 application.Render();
1206 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1211 //Creates a mesh visual from the given propertyMap and tries to load it on stage in the given application.
1212 //This is expected to succeed, which will then pass the test.
1213 void MeshVisualLoadsCorrectlyTest( Property::Map& propertyMap, ToolkitTestApplication& application )
1215 VisualFactory factory = VisualFactory::Get();
1216 DALI_TEST_CHECK( factory );
1218 //Create a mesh visual.
1219 Visual::Base visual = factory.CreateVisual( propertyMap );
1220 DALI_TEST_CHECK( visual );
1222 //Create an actor on stage to house the visual.
1223 DummyControl actor = DummyControl::New();
1224 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1225 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1226 actor.SetSize( 200.f, 200.f );
1227 Stage::GetCurrent().Add( actor );
1228 visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.f, 200.f ) );
1230 //Ensure set on stage.
1231 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1233 //Attempt to render to queue resource load requests.
1234 application.SendNotification();
1235 application.Render( 0 );
1237 //Tell the platform abstraction that the required resources have been loaded.
1238 TestPlatformAbstraction& platform = application.GetPlatform();
1239 platform.SetAllResourceRequestsAsLoaded();
1241 //Render again to upload the now-loaded textures.
1242 application.SendNotification();
1243 application.Render( 0 );
1245 Matrix testScaleMatrix;
1246 testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
1247 Matrix actualScaleMatrix;
1249 //Test to see if the object has been successfully loaded.
1250 DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
1251 DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1253 //Finish by setting off stage, and ensuring this was successful.
1255 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1258 //Creates a mesh visual from the given propertyMap and tries to load it on stage in the given application.
1259 //This is expected to fail, which will then pass the test.
1260 void MeshVisualDoesNotLoadCorrectlyTest( Property::Map& propertyMap, ToolkitTestApplication& application )
1262 VisualFactory factory = VisualFactory::Get();
1263 DALI_TEST_CHECK( factory );
1265 //Create a mesh visual.
1266 Visual::Base visual = factory.CreateVisual( propertyMap );
1267 DALI_TEST_CHECK( visual );
1269 //Create an actor on stage to house the visual.
1270 DummyControl actor = DummyControl::New();
1271 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1272 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1273 actor.SetSize( 200.f, 200.f );
1274 Stage::GetCurrent().Add( actor );
1275 visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.f, 200.f ) );
1277 //Ensure set on stage.
1278 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1280 //Attempt to render to queue resource load requests.
1281 application.SendNotification();
1282 application.Render( 0 );
1284 //Tell the platform abstraction that the required resources have been loaded.
1285 TestPlatformAbstraction& platform = application.GetPlatform();
1286 platform.SetAllResourceRequestsAsLoaded();
1288 //Render again to upload the now-loaded textures.
1289 application.SendNotification();
1290 application.Render( 0 );
1292 //Test to see if the object has not been loaded, as expected.
1294 DALI_TEST_CHECK( !application.GetGlAbstraction().GetUniformValue<Matrix>( "uObjectMatrix", scaleMatrix ) );
1296 //Finish by setting off stage, and ensuring this was successful.
1298 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1301 //Test if mesh loads correctly when supplied with only the bare minimum requirements, an object file.
1302 int UtcDaliVisualFactoryGetMeshVisual1(void)
1304 //Set up test application first, so everything else can be handled.
1305 ToolkitTestApplication application;
1307 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual1: Request mesh visual with a valid object file only" );
1310 //Set up visual properties.
1311 Property::Map propertyMap;
1312 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1313 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1315 //Test to see if mesh loads correctly.
1316 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1322 //Test if mesh loads correctly when supplied with an object file as well as a blank material file and images directory.
1323 int UtcDaliVisualFactoryGetMeshVisual2(void)
1325 //Set up test application first, so everything else can be handled.
1326 ToolkitTestApplication application;
1328 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual2: Request mesh visual with blank material file and images directory" );
1330 //Set up visual properties.
1331 Property::Map propertyMap;
1332 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1333 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1334 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, "" );
1335 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, "" );
1337 //Test to see if mesh loads correctly.
1338 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1343 //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
1344 int UtcDaliVisualFactoryGetMeshVisual3b(void)
1346 //Set up test application first, so everything else can be handled.
1347 ToolkitTestApplication application;
1349 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual3: Request mesh visual with all parameters correct" );
1351 //Set up visual properties.
1352 Property::Map propertyMap;
1353 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1354 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1355 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1356 propertyMap.Insert( MeshVisual::Property::USE_MIPMAPPING, Color::GREEN ); // Test that wrong property types don't prevent the object load
1357 propertyMap.Insert( MeshVisual::Property::USE_SOFT_NORMALS, 1.0f );
1358 propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, 1.0f );
1359 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1361 //Test to see if mesh loads correctly.
1362 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1367 //Test if mesh loads correctly when supplied with all main parameters, an object file, a material file and a directory location.
1368 int UtcDaliVisualFactoryGetMeshVisual3(void)
1370 //Set up test application first, so everything else can be handled.
1371 ToolkitTestApplication application;
1373 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual3: Request mesh visual with all parameters correct" );
1375 //Set up visual properties.
1376 Property::Map propertyMap;
1377 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1378 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1379 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1380 propertyMap.Insert( MeshVisual::Property::USE_MIPMAPPING, false );
1381 propertyMap.Insert( MeshVisual::Property::USE_SOFT_NORMALS, false );
1382 propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3::XAXIS );
1383 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1385 //Test to see if mesh loads correctly.
1386 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1391 //Test if mesh visual can load a correctly supplied mesh without a normal map or gloss map in the material file.
1392 int UtcDaliVisualFactoryGetMeshVisual4(void)
1394 //Set up test application first, so everything else can be handled.
1395 ToolkitTestApplication application;
1397 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual4: Request mesh visual with diffuse texture but not normal or gloss." );
1400 //Set up visual properties.
1401 Property::Map propertyMap;
1402 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1403 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1404 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_SIMPLE_MTL_FILE_NAME );
1405 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1407 //Test to see if mesh loads correctly.
1408 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1413 //Test if mesh visual can load when made to use diffuse textures only.
1414 int UtcDaliVisualFactoryGetMeshVisual5(void)
1416 //Set up test application first, so everything else can be handled.
1417 ToolkitTestApplication application;
1419 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual5: Request mesh visual and make it only use diffuse textures." );
1421 //Set up visual properties.
1422 Property::Map propertyMap;
1423 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1424 propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME );
1425 propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME );
1426 propertyMap.Insert( "texturesPath", TEST_RESOURCE_DIR "/" );
1427 propertyMap.Insert( "useMipmapping", false );
1428 propertyMap.Insert( "useSoftNormals", false );
1429 propertyMap.Insert( "lightPosition", Vector3::ZAXIS );
1430 propertyMap.Insert( "shadingMode", MeshVisual::ShadingMode::TEXTURED_WITH_SPECULAR_LIGHTING );
1432 //Test to see if mesh loads correctly.
1433 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1439 //Test if mesh visual can load when made to not use the supplied textures.
1440 int UtcDaliVisualFactoryGetMeshVisual6(void)
1442 //Set up test application first, so everything else can be handled.
1443 ToolkitTestApplication application;
1445 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual6: Request mesh visual and make it not use any textures." );
1447 //Set up visual properties.
1448 Property::Map propertyMap;
1449 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1450 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1451 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1452 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1453 propertyMap.Insert( MeshVisual::Property::SHADING_MODE, MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING );
1455 //Test to see if mesh loads correctly.
1456 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1460 //Test if mesh visual loads correctly when light position is manually set.
1461 int UtcDaliVisualFactoryGetMeshVisual7(void)
1463 //Set up test application first, so everything else can be handled.
1464 ToolkitTestApplication application;
1467 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual7: Request mesh visual with custom light position." );
1469 //Set up visual properties.
1470 Property::Map propertyMap;
1471 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1472 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1473 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1474 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1475 propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.0, 1.0, 2.0 ) );
1477 //Test to see if mesh loads correctly.
1478 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1483 //Test if mesh visual loads correctly when supplied an object file without face normals or texture points.
1484 //Note that this notably tests object loader functionality.
1485 int UtcDaliVisualFactoryGetMeshVisual8(void)
1487 //Set up test application first, so everything else can be handled.
1488 ToolkitTestApplication application;
1490 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual5: Request mesh visual with normal-less object file." );
1492 //Set up visual properties.
1493 Property::Map propertyMap;
1494 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1495 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_SIMPLE_OBJ_FILE_NAME );
1496 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1497 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1499 //Test to see if mesh loads correctly.
1500 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1505 //Test if mesh visual handles the case of lacking an object file.
1506 int UtcDaliVisualFactoryGetMeshVisualN1(void)
1508 //Set up test application first, so everything else can be handled.
1509 ToolkitTestApplication application;
1511 tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN1: Request mesh visual without object file" );
1513 //Set up visual properties.
1514 Property::Map propertyMap;
1515 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1516 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1517 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1519 //Test to see if mesh doesn't load with these properties, as expected.
1520 MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
1526 //Test if mesh visual handles the case of being passed invalid material and images urls.
1527 int UtcDaliVisualFactoryGetMeshVisualN2(void)
1529 //Set up test application first, so everything else can be handled.
1530 ToolkitTestApplication application;
1532 tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN2: Request mesh visual with invalid material and images urls" );
1534 //Set up visual properties.
1535 Property::Map propertyMap;
1536 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1537 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1538 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, "invalid" );
1539 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, "also invalid" );
1541 //Test to see if mesh doesn't load with these properties, as expected.
1542 MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
1548 //Test if mesh visual handles the case of being passed an invalid object url
1549 int UtcDaliVisualFactoryGetMeshVisualN3(void)
1551 //Set up test application first, so everything else can be handled.
1552 ToolkitTestApplication application;
1553 tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN3: Request mesh visual with invalid object url" );
1556 //Set up visual properties.
1557 Property::Map propertyMap;
1558 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1559 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, "invalid" );
1560 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1561 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1563 //Test to see if mesh doesn't load with these properties, as expected.
1564 MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
1569 //Creates a primitive visual with the given property map and tests to see if it correctly loads in the given application.
1570 void TestPrimitiveVisualWithProperties( Property::Map& propertyMap, ToolkitTestApplication& application )
1572 VisualFactory factory = VisualFactory::Get();
1573 DALI_TEST_CHECK( factory );
1575 //Create a primitive visual.
1576 Visual::Base visual = factory.CreateVisual( propertyMap );
1577 DALI_TEST_CHECK( visual );
1579 //Create an actor on stage to house the visual.
1580 DummyControl actor = DummyControl::New();
1581 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1582 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1584 actor.SetSize( 200.f, 200.f );
1585 Stage::GetCurrent().Add( actor );
1586 visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.f, 200.f ) );
1588 //Ensure set on stage.
1589 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1591 //Tell test application to load the visual.
1592 application.SendNotification();
1593 application.Render(0);
1595 Matrix testScaleMatrix;
1596 testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
1597 Matrix actualScaleMatrix;
1599 //Test to see if the object has been successfully loaded.
1600 DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
1601 DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1603 //Finish by setting off stage, and ensuring this was successful.
1605 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1608 //Test if primitive shape loads correctly when supplied with only the bare minimum requirements, the shape to use.
1609 int UtcDaliVisualFactoryGetPrimitiveVisual1(void)
1611 //Set up test application first, so everything else can be handled.
1612 ToolkitTestApplication application;
1614 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual1: Request primitive visual with a shape only" );
1616 //Set up visual properties.
1617 Property::Map propertyMap;
1618 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1619 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
1621 //Test to see if shape loads correctly.
1622 TestPrimitiveVisualWithProperties( propertyMap, application );
1627 //Test if primitive shape loads correctly when supplied with all possible parameters
1628 int UtcDaliVisualFactoryGetPrimitiveVisual2(void)
1630 //Set up test application first, so everything else can be handled.
1631 ToolkitTestApplication application;
1633 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual2: Request primitive visual with everything" );
1635 //Set up visual properties.
1636 Property::Map propertyMap;
1637 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1638 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
1639 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1640 propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1641 propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
1642 propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
1643 propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f );
1644 propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
1645 propertyMap.Insert( PrimitiveVisual::Property::SCALE_RADIUS, 60.0f );
1646 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.7f );
1647 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, 0.8f );
1648 propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.9, 1.0, 1.1 ) );
1650 //Test to see if shape loads correctly.
1651 TestPrimitiveVisualWithProperties( propertyMap, application );
1656 //Test if primitive shape loads a sphere correctly.
1657 int UtcDaliVisualFactoryGetPrimitiveVisual3(void)
1659 //Set up test application first, so everything else can be handled.
1660 ToolkitTestApplication application;
1662 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual3: Request primitive visual to display a sphere" );
1664 //Set up visual properties.
1665 Property::Map propertyMap;
1666 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1667 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1668 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1669 propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1670 propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
1672 //Test to see if shape loads correctly.
1673 TestPrimitiveVisualWithProperties( propertyMap, application );
1678 //Test if primitive shape loads a conic section correctly.
1679 int UtcDaliVisualFactoryGetPrimitiveVisual4(void)
1681 //Set up test application first, so everything else can be handled.
1682 ToolkitTestApplication application;
1684 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual4: Request primitive visual to display a conic section" );
1686 //Set up visual properties.
1687 Property::Map propertyMap;
1688 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1689 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONICAL_FRUSTRUM );
1690 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1691 propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1692 propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
1693 propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f );
1694 propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
1696 //Test to see if shape loads correctly.
1697 TestPrimitiveVisualWithProperties( propertyMap, application );
1702 //Test if primitive shape loads a bevelled cube correctly.
1703 int UtcDaliVisualFactoryGetPrimitiveVisual5(void)
1705 //Set up test application first, so everything else can be handled.
1706 ToolkitTestApplication application;
1708 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual5: Request primitive visual to display a bevelled cube" );
1710 //Set up visual properties.
1711 Property::Map propertyMap;
1712 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1713 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::BEVELLED_CUBE );
1714 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1715 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.7f );
1717 //Test to see if shape loads correctly.
1718 TestPrimitiveVisualWithProperties( propertyMap, application );
1723 //Test if primitive shape loads an octahedron correctly.
1724 int UtcDaliVisualFactoryGetPrimitiveVisual6(void)
1726 //Set up test application first, so everything else can be handled.
1727 ToolkitTestApplication application;
1729 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual6: Request primitive visual to display an octahedron" );
1731 //Set up visual properties.
1732 Property::Map propertyMap;
1733 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1734 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::OCTAHEDRON );
1735 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1737 //Test to see if shape loads correctly.
1738 TestPrimitiveVisualWithProperties( propertyMap, application );
1743 //Test if primitive shape loads a cone correctly.
1744 int UtcDaliVisualFactoryGetPrimitiveVisual7(void)
1746 //Set up test application first, so everything else can be handled.
1747 ToolkitTestApplication application;
1749 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual7: Request primitive visual to display a cone" );
1751 //Set up visual properties.
1752 Property::Map propertyMap;
1753 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1754 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONE );
1755 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1756 propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1757 propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
1758 propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
1760 //Test to see if shape loads correctly.
1761 TestPrimitiveVisualWithProperties( propertyMap, application );
1766 //Test if primitive shape loads correctly when light position is manually set.
1767 int UtcDaliVisualFactoryGetPrimitiveVisual8(void)
1769 //Set up test application first, so everything else can be handled.
1770 ToolkitTestApplication application;
1772 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual8: Request primitive visual with set light position" );
1774 //Set up visual properties.
1775 Property::Map propertyMap;
1776 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1777 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1778 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1779 propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.0, 1.0, 2.0 ) );
1781 //Test to see if shape loads correctly.
1782 TestPrimitiveVisualWithProperties( propertyMap, application );
1787 //Test if primitive shape loads correctly when told to use too many slices.
1788 int UtcDaliVisualFactoryGetPrimitiveVisual9(void)
1790 //Set up test application first, so everything else can be handled.
1791 ToolkitTestApplication application;
1793 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual9: Request primitive visual with above-cap slices." );
1795 //Set up visual properties.
1796 Property::Map propertyMap;
1797 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1798 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1799 propertyMap.Insert( PrimitiveVisual::Property::SLICES, Property::Value( 1000000 ) );
1801 //Test to see if shape loads correctly.
1802 TestPrimitiveVisualWithProperties( propertyMap, application );
1807 //Test if primitive shape loads correctly when told to use too few slices. (2 slices or less.)
1808 int UtcDaliVisualFactoryGetPrimitiveVisual10(void)
1810 //Set up test application first, so everything else can be handled.
1811 ToolkitTestApplication application;
1813 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual10: Request primitive visual with too few slices." );
1815 //Set up visual properties.
1816 Property::Map propertyMap;
1817 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1818 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1819 propertyMap.Insert( PrimitiveVisual::Property::SLICES, Property::Value( 2 ) );
1821 //Test to see if shape loads correctly.
1822 TestPrimitiveVisualWithProperties( propertyMap, application );
1827 //Test if primitive shape loads correctly when told to use too many stacks.
1828 int UtcDaliVisualFactoryGetPrimitiveVisual11(void)
1830 //Set up test application first, so everything else can be handled.
1831 ToolkitTestApplication application;
1833 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual11: Request primitive visual with too many stacks." );
1835 //Set up visual properties.
1836 Property::Map propertyMap;
1837 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1838 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1839 propertyMap.Insert( PrimitiveVisual::Property::STACKS, Property::Value( 1000000 ) );
1841 //Test to see if shape loads correctly.
1842 TestPrimitiveVisualWithProperties( propertyMap, application );
1847 //Test if primitive shape loads correctly when told to use too few stacks. (1 stack or less.)
1848 int UtcDaliVisualFactoryGetPrimitiveVisual12(void)
1850 //Set up test application first, so everything else can be handled.
1851 ToolkitTestApplication application;
1853 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual12: Request primitive visual with too few stacks." );
1855 //Set up visual properties.
1856 Property::Map propertyMap;
1857 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1858 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1859 propertyMap.Insert( PrimitiveVisual::Property::STACKS, Property::Value( 1 ) );
1861 //Test to see if shape loads correctly.
1862 TestPrimitiveVisualWithProperties( propertyMap, application );
1867 //Test if primitive shape loads correctly when told to use invalid (zero or negative) dimensions.
1868 int UtcDaliVisualFactoryGetPrimitiveVisual13(void)
1870 //Set up test application first, so everything else can be handled.
1871 ToolkitTestApplication application;
1873 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual13: Request primitive visual with invalid scale dimensions." );
1875 //Set up visual properties.
1876 Property::Map propertyMap;
1877 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1878 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1879 propertyMap.Insert( PrimitiveVisual::Property::SCALE_DIMENSIONS, Vector3::ZERO );
1881 //Test to see if shape loads correctly.
1882 TestPrimitiveVisualWithProperties( propertyMap, application );
1887 //Test if primitive shape loads correctly when told to use too low a bevel percentage.
1888 int UtcDaliVisualFactoryGetPrimitiveVisual14(void)
1890 //Set up test application first, so everything else can be handled.
1891 ToolkitTestApplication application;
1893 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual14: Request primitive visual with too low a bevel percentage." );
1895 //Set up visual properties.
1896 Property::Map propertyMap;
1897 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1898 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1899 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, Property::Value( -1.0f ) );
1901 //Test to see if shape loads correctly.
1902 TestPrimitiveVisualWithProperties( propertyMap, application );
1907 //Test if primitive shape loads correctly when told to use too high a bevel percentage.
1908 int UtcDaliVisualFactoryGetPrimitiveVisual15(void)
1910 //Set up test application first, so everything else can be handled.
1911 ToolkitTestApplication application;
1913 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual15: Request primitive visual with too high a bevel percentage." );
1915 //Set up visual properties.
1916 Property::Map propertyMap;
1917 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1918 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1919 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, Property::Value( 2.0f ) );
1921 //Test to see if shape loads correctly.
1922 TestPrimitiveVisualWithProperties( propertyMap, application );
1927 //Test if primitive shape loads correctly when told to use too low a bevel smoothness.
1928 int UtcDaliVisualFactoryGetPrimitiveVisual16(void)
1930 //Set up test application first, so everything else can be handled.
1931 ToolkitTestApplication application;
1933 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual16: Request primitive visual with too low a bevel smoothness." );
1935 //Set up visual properties.
1936 Property::Map propertyMap;
1937 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1938 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1939 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, Property::Value( -1.0f ) );
1941 //Test to see if shape loads correctly.
1942 TestPrimitiveVisualWithProperties( propertyMap, application );
1947 //Test if primitive shape loads correctly when told to use too high a bevel smoothness.
1948 int UtcDaliVisualFactoryGetPrimitiveVisual17(void)
1950 //Set up test application first, so everything else can be handled.
1951 ToolkitTestApplication application;
1953 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual17: Request primitive visual with too high a bevel smoothness." );
1955 //Set up visual properties.
1956 Property::Map propertyMap;
1957 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1958 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1959 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, Property::Value( 2.0f ) );
1961 //Test to see if shape loads correctly.
1962 TestPrimitiveVisualWithProperties( propertyMap, application );
1967 //Test if primitive shape visual handles the case of not being passed a specific shape to use.
1968 int UtcDaliVisualFactoryGetPrimitiveVisualN1(void)
1970 //Set up test application first, so everything else can be handled.
1971 ToolkitTestApplication application;
1973 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisualN1: Request primitive visual without shape" );
1975 //Set up visual properties, without supplying shape.
1976 Property::Map propertyMap;
1977 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1979 //Test to see if shape loads regardless of missing input.
1980 TestPrimitiveVisualWithProperties( propertyMap, application );
1985 int UtcDaliVisualFactoryGetAnimatedImageVisual1(void)
1987 ToolkitTestApplication application;
1988 tet_infoline( "UtcDaliVisualFactoryGetAnimatedImageVisual1: Request animated image visual with a gif url" );
1990 VisualFactory factory = VisualFactory::Get();
1991 Visual::Base visual = factory.CreateVisual( TEST_GIF_FILE_NAME, ImageDimensions() );
1992 DALI_TEST_CHECK( visual );
1994 TestGlAbstraction& gl = application.GetGlAbstraction();
1995 TraceCallStack& textureTrace = gl.GetTextureTrace();
1996 textureTrace.Enable(true);
1998 DummyControl actor = DummyControl::New();
1999 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2000 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
2001 actor.SetSize( 200.0f, 200.0f );
2002 Stage::GetCurrent().Add( actor );
2004 application.SendNotification();
2005 application.Render();
2007 // renderer is added to actor
2008 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
2010 // test the uniforms which used to handle the atlas rect
2011 // the four frames should be located inside atlas as follows: atlas size 100*100
2020 Renderer renderer = actor.GetRendererAt( 0u );
2021 DALI_TEST_CHECK( renderer );
2023 Property::Value atlasRectValue = renderer.GetProperty( renderer.GetPropertyIndex( "uAtlasRect" ) );
2024 // take into consideration the half pixel correction
2025 DALI_TEST_EQUALS( atlasRectValue.Get<Vector4>(), Vector4(0.5f, 0.5f, 49.5f, 49.5f)/100.f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2027 // waiting for the resource uploading
2028 application.SendNotification();
2029 application.Render();
2031 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
2033 // Force the timer used by the animatedImageVisual to tick,
2034 Dali::Timer timer = Timer::New( 0 );
2035 timer.MockEmitSignal();
2036 application.SendNotification();
2037 application.Render();
2038 atlasRectValue = renderer.GetProperty( renderer.GetPropertyIndex( "uAtlasRect" ) );
2039 // take into consideration the half pixel correction
2040 DALI_TEST_EQUALS( atlasRectValue.Get<Vector4>(), Vector4(50.5f, 0.5f, 99.5f, 49.5f)/100.f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2042 // Force the timer used by the animatedImageVisual to tick,
2043 timer.MockEmitSignal();
2044 application.SendNotification();
2045 application.Render();
2046 atlasRectValue = renderer.GetProperty( renderer.GetPropertyIndex( "uAtlasRect" ) );
2047 // take into consideration the half pixel correction
2048 DALI_TEST_EQUALS( atlasRectValue.Get<Vector4>(), Vector4(0.5f, 50.5f, 49.5f, 99.5f)/100.f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2050 // Force the timer used by the animatedImageVisual to tick,
2051 timer.MockEmitSignal();
2052 application.SendNotification();
2053 application.Render();
2054 atlasRectValue = renderer.GetProperty( renderer.GetPropertyIndex( "uAtlasRect" ) );
2055 // take into consideration the half pixel correction
2056 DALI_TEST_EQUALS( atlasRectValue.Get<Vector4>(), Vector4(50.5f, 50.5f, 99.5f, 99.5f)/100.f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2058 // Test SetOffStage().
2060 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
2065 int UtcDaliVisualFactoryGetAnimatedImageVisual2(void)
2067 ToolkitTestApplication application;
2068 tet_infoline( "UtcDaliVisualFactoryGetAnimatedImageVisual2: Request animated image visual with a Property::Map, test custom wrap mode and pixel area" );
2070 const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
2071 Property::Map propertyMap;
2072 propertyMap.Add( Visual::Property::TYPE, Visual::IMAGE )
2073 .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
2074 .Add( ImageVisual::Property::PIXEL_AREA, pixelArea )
2075 .Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT )
2076 .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT );
2078 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
2079 DALI_TEST_CHECK( visual );
2081 TestGlAbstraction& gl = application.GetGlAbstraction();
2082 TraceCallStack& textureTrace = gl.GetTextureTrace();
2083 textureTrace.Enable(true);
2084 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
2085 texParameterTrace.Enable( true );
2087 DummyControl actor = DummyControl::New();
2088 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2089 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
2090 actor.SetSize( 200.0f, 200.0f );
2091 Stage::GetCurrent().Add( actor );
2093 application.SendNotification();
2094 application.Render();
2096 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
2098 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
2100 // For animated image visual, the wrapping is handled manually in shader, so the following gl function should not be called
2101 std::stringstream out;
2102 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
2103 DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
2105 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
2106 DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
2108 // test the uniforms which used to handle the wrap mode
2109 Renderer renderer = actor.GetRendererAt( 0u );
2110 DALI_TEST_CHECK( renderer );
2112 Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
2113 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION );
2114 Vector4 pixelAreaUniform;
2115 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
2116 DALI_TEST_EQUALS( pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2118 Property::Value wrapModeValue = renderer.GetProperty( renderer.GetPropertyIndex( "wrapMode" ) );
2119 Vector2 wrapMode( WrapMode::MIRRORED_REPEAT-1, WrapMode::REPEAT-1 );
2120 DALI_TEST_EQUALS( wrapModeValue.Get<Vector2>(), wrapMode, TEST_LOCATION );
2121 Vector2 wrapModeUniform;
2122 DALI_TEST_CHECK( gl.GetUniformValue<Vector2>( "wrapMode", wrapModeUniform ) );
2123 DALI_TEST_EQUALS( wrapMode, wrapModeUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2126 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );