2 * Copyright (c) 2017 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_POLICY, Vector2( Toolkit::DevelVisual::Transform::Policy::RELATIVE, Toolkit::DevelVisual::Transform::Policy::RELATIVE ) )
65 .Add( Toolkit::DevelVisual::Transform::Property::SIZE_POLICY, Vector2( Toolkit::DevelVisual::Transform::Policy::RELATIVE, Toolkit::DevelVisual::Transform::Policy::RELATIVE ) );
69 Integration::Bitmap* CreateBitmap( unsigned int imageWidth, unsigned int imageHeight, unsigned int initialColor, Pixel::Format pixelFormat )
71 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
72 Integration::PixelBuffer* pixbuffer = bitmap->GetPackedPixelsProfile()->ReserveBuffer( pixelFormat, imageWidth, imageHeight, imageWidth, imageHeight );
73 unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
75 memset( pixbuffer, initialColor, imageHeight * imageWidth * bytesPerPixel );
80 void InitialiseRegionsToZeroAlpha( Integration::Bitmap* image, unsigned int imageWidth, unsigned int imageHeight, Pixel::Format pixelFormat )
82 PixelBuffer* pixbuffer = image->GetBuffer();
83 unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
85 for( unsigned int row = 0; row < imageWidth; ++row )
87 unsigned int pixelOffset = row * bytesPerPixel;
88 pixbuffer[ pixelOffset + 3 ] = 0x00;
89 pixelOffset += ( imageHeight - 1 ) * imageWidth * bytesPerPixel;
90 pixbuffer[ pixelOffset + 3 ] = 0x00;
93 for ( unsigned int column = 0; column < imageHeight; ++column )
95 unsigned int pixelOffset = column * imageWidth * bytesPerPixel;
96 pixbuffer[ pixelOffset + 3 ] = 0x00;
97 pixelOffset += ( imageWidth -1 ) * bytesPerPixel;
98 pixbuffer[ pixelOffset + 3 ] = 0x00;
102 void AddStretchRegionsToImage( Integration::Bitmap* image, unsigned int imageWidth, unsigned int imageHeight, const StretchRanges& stretchRangesX, const StretchRanges& stretchRangesY, Pixel::Format pixelFormat )
104 PixelBuffer* pixbuffer = image->GetBuffer();
105 unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
107 for(StretchRanges::ConstIterator it = stretchRangesX.Begin(); it != stretchRangesX.End(); ++it)
109 const Uint16Pair& range = *it;
110 //since the stretch range is in the cropped image space, we need to offset by 1 to get it to the uncropped image space
111 for( unsigned int column = range.GetX() + 1u; column < range.GetY() + 1u; ++column )
113 unsigned int pixelOffset = column * bytesPerPixel;
114 pixbuffer[ pixelOffset ] = 0x00;
115 pixbuffer[ pixelOffset + 1 ] = 0x00;
116 pixbuffer[ pixelOffset + 2 ] = 0x00;
117 pixbuffer[ pixelOffset + 3 ] = 0xFF;
122 for(StretchRanges::ConstIterator it = stretchRangesY.Begin(); it != stretchRangesY.End(); ++it)
124 const Uint16Pair& range = *it;
125 //since the stretch range is in the cropped image space, we need to offset by 1 to get it to the uncropped image space
126 for( unsigned int row = range.GetX() + 1u; row < range.GetY() + 1u; ++row )
128 unsigned int pixelOffset = row * imageWidth * bytesPerPixel;
129 pixbuffer[ pixelOffset ] = 0x00;
130 pixbuffer[ pixelOffset + 1 ] = 0x00;
131 pixbuffer[ pixelOffset + 2 ] = 0x00;
132 pixbuffer[ pixelOffset + 3 ] = 0xFF;
137 void AddChildRegionsToImage( Integration::Bitmap* image, unsigned int imageWidth, unsigned int imageHeight, const Vector4& requiredChildRegion, Pixel::Format pixelFormat )
139 PixelBuffer* pixbuffer = image->GetBuffer();
140 unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
142 Integration::Bitmap::PackedPixelsProfile* srcProfile = image->GetPackedPixelsProfile();
143 unsigned int bufferStride = srcProfile->GetBufferStride();
145 // Add bottom child region
146 for( unsigned int column = requiredChildRegion.x; column < imageWidth - requiredChildRegion.z; ++column )
148 unsigned int pixelOffset = column * bytesPerPixel;
149 pixelOffset += ( imageHeight - 1 ) * bufferStride;
150 pixbuffer[ pixelOffset ] = 0x00;
151 pixbuffer[ pixelOffset + 1 ] = 0x00;
152 pixbuffer[ pixelOffset + 2 ] = 0x00;
153 pixbuffer[ pixelOffset + 3 ] = 0xFF;
156 // Add right child region
157 for ( unsigned int row = requiredChildRegion.y; row < imageHeight - requiredChildRegion.w; ++row )
159 unsigned int pixelOffset = row * bufferStride + ( imageWidth - 1 ) * bytesPerPixel;
160 pixbuffer[ pixelOffset ] = 0x00;
161 pixbuffer[ pixelOffset + 1 ] = 0x00;
162 pixbuffer[ pixelOffset + 2 ] = 0x00;
163 pixbuffer[ pixelOffset + 3 ] = 0xFF;
167 Integration::ResourcePointer CustomizeNinePatch( TestApplication& application,
168 unsigned int ninePatchImageWidth,
169 unsigned int ninePatchImageHeight,
170 const StretchRanges& stretchRangesX,
171 const StretchRanges& stretchRangesY,
172 bool addChildRegion = false,
173 Vector4 requiredChildRegion = Vector4::ZERO )
175 TestPlatformAbstraction& platform = application.GetPlatform();
177 Pixel::Format pixelFormat = Pixel::RGBA8888;
179 tet_infoline("Create Bitmap");
180 platform.SetClosestImageSize(Vector2( ninePatchImageWidth, ninePatchImageHeight));
181 Integration::Bitmap* bitmap = CreateBitmap( ninePatchImageWidth, ninePatchImageHeight, 0xFF, pixelFormat );
183 tet_infoline("Clear border regions");
184 InitialiseRegionsToZeroAlpha( bitmap, ninePatchImageWidth, ninePatchImageHeight, pixelFormat );
186 tet_infoline("Add Stretch regions to Bitmap");
187 AddStretchRegionsToImage( bitmap, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY, pixelFormat );
191 tet_infoline("Add Child regions to Bitmap");
192 AddChildRegionsToImage( bitmap, ninePatchImageWidth, ninePatchImageHeight, requiredChildRegion, pixelFormat );
195 tet_infoline("Getting resource");
196 Integration::ResourcePointer resourcePtr(bitmap);
197 //platform.SetResourceLoaded( 0, Dali::Integration::ResourceBitmap, resourcePtr );
198 platform.SetSynchronouslyLoadedResource( resourcePtr);
203 void TestVisualRender( ToolkitTestApplication& application,
205 Visual::Base& visual,
206 std::size_t expectedSamplers = 0,
207 ImageDimensions imageDimensions = ImageDimensions(),
208 Integration::ResourcePointer resourcePtr = Integration::ResourcePointer())
210 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
211 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
215 // set the image size, for test case, this needs to be set before loading started
216 application.GetPlatform().SetClosestImageSize( Vector2(imageDimensions.GetWidth(), imageDimensions.GetHeight()) );
219 actor.SetSize( 200.f, 200.f );
220 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
222 Stage::GetCurrent().Add( actor );
224 application.SendNotification();
225 application.Render();
227 application.Render();
228 application.SendNotification();
232 DALI_TEST_EQUALS( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceSynchronouslyFunc ), true, TEST_LOCATION);
235 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
242 void dali_visual_factory_startup(void)
244 test_return_value = TET_UNDEF;
247 void dali_visual_factory_cleanup(void)
249 test_return_value = TET_PASS;
252 int UtcDaliVisualFactoryGet(void)
254 ToolkitTestApplication application;
255 tet_infoline( "UtcDaliVisualFactory" );
259 type = TypeRegistry::Get().GetTypeInfo( "VisualFactory" );
260 DALI_TEST_CHECK( type );
261 BaseHandle handle = type.CreateInstance();
262 DALI_TEST_CHECK( handle );
264 VisualFactory factory;
265 factory = VisualFactory::Get();
266 DALI_TEST_CHECK( factory );
268 VisualFactory newFactory = VisualFactory::Get();
269 DALI_TEST_CHECK( newFactory );
271 // Check that visual factory is a singleton
272 DALI_TEST_CHECK(factory == newFactory);
277 int UtcDaliVisualFactoryCopyAndAssignment(void)
279 ToolkitTestApplication application;
280 tet_infoline( "UtcDaliVisualFactoryCopyAndAssignment" );
281 VisualFactory factory = VisualFactory::Get();
283 VisualFactory factoryCopy( factory );
284 DALI_TEST_CHECK(factory == factoryCopy);
286 VisualFactory emptyFactory;
287 VisualFactory emptyFactoryCopy( emptyFactory );
288 DALI_TEST_CHECK(emptyFactory == emptyFactoryCopy);
290 VisualFactory factoryEquals;
291 factoryEquals = factory;
292 DALI_TEST_CHECK(factory == factoryEquals);
294 VisualFactory emptyFactoryEquals;
295 emptyFactoryEquals = emptyFactory;
296 DALI_TEST_CHECK( emptyFactory == emptyFactoryEquals );
300 DALI_TEST_CHECK( factory = factoryCopy );
305 int UtcDaliVisualFactoryGetColorVisual1(void)
307 ToolkitTestApplication application;
308 tet_infoline( "UtcDaliVisualFactoryGetColorVisual1: Request color visual with a Property::Map" );
310 VisualFactory factory = VisualFactory::Get();
311 DALI_TEST_CHECK( factory );
313 Property::Map propertyMap;
314 Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
315 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
316 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, testColor);
318 Visual::Base visual = factory.CreateVisual(propertyMap);
319 DALI_TEST_CHECK( visual );
321 DummyControl actor = DummyControl::New();
322 TestVisualRender( application, actor, visual );
324 Vector3 actualValue(Vector4::ZERO);
326 TestGlAbstraction& gl = application.GetGlAbstraction();
327 DALI_TEST_CHECK( gl.GetUniformValue<Vector3>( "mixColor", actualValue ) );
328 DALI_TEST_CHECK( gl.GetUniformValue<float>( "opacity", opacity ) );
329 DALI_TEST_EQUALS( actualValue, Vector3(testColor), TEST_LOCATION );
330 DALI_TEST_EQUALS( opacity, testColor.a, TEST_LOCATION );
335 int UtcDaliVisualFactoryGetColorVisual2(void)
337 ToolkitTestApplication application;
338 tet_infoline( "UtcDaliVisualFactoryGetColorVisual2: Request color visual with a Vector4" );
340 VisualFactory factory = VisualFactory::Get();
341 DALI_TEST_CHECK( factory );
343 Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
344 Dali::Property::Map map;
345 map[ Visual::Property::TYPE ] = Visual::COLOR;
346 map[ ColorVisual::Property::MIX_COLOR ] = testColor;
347 Visual::Base visual = factory.CreateVisual( map );
348 DALI_TEST_CHECK( visual );
350 DummyControl actor = DummyControl::New();
351 TestVisualRender( application, actor, visual );
355 TestGlAbstraction& gl = application.GetGlAbstraction();
356 DALI_TEST_CHECK( gl.GetUniformValue<Vector3>( "mixColor", actualValue ) );
357 DALI_TEST_CHECK( gl.GetUniformValue<float>( "opacity", opacity ) );
358 DALI_TEST_EQUALS( actualValue, Vector3(testColor), TEST_LOCATION );
359 DALI_TEST_EQUALS( opacity, testColor.a, TEST_LOCATION );
361 Stage::GetCurrent().Remove(actor);
362 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
367 int UtcDaliVisualFactoryGetBorderVisual1(void)
369 ToolkitTestApplication application;
370 tet_infoline( "UtcDaliVisualFactoryGetBorderVisual1: Request border visual with a Property::Map" );
372 VisualFactory factory = VisualFactory::Get();
373 DALI_TEST_CHECK( factory );
375 Property::Map propertyMap;
376 Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
377 float testSize = 5.f;
378 propertyMap.Insert(Visual::Property::TYPE, Visual::BORDER);
379 propertyMap.Insert(BorderVisual::Property::COLOR, testColor);
380 propertyMap.Insert(BorderVisual::Property::SIZE, testSize);
382 Visual::Base visual = factory.CreateVisual(propertyMap);
383 DALI_TEST_CHECK( visual );
385 DummyControl actor = DummyControl::New();
386 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
387 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
388 actor.SetSize(200.f, 200.f);
389 Stage::GetCurrent().Add( actor );
390 visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f));
392 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
393 int blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLEND_MODE );
394 DALI_TEST_EQUALS( static_cast<BlendMode::Type>(blendMode), BlendMode::ON, TEST_LOCATION );
396 TestGlAbstraction& gl = application.GetGlAbstraction();
398 application.SendNotification();
399 application.Render(0);
401 Vector4 actualColor(Vector4::ZERO);
402 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "borderColor", actualColor ) );
403 DALI_TEST_EQUALS( actualColor, testColor, TEST_LOCATION );
405 float actualSize = 0.f;
406 DALI_TEST_CHECK( gl.GetUniformValue<float>( "borderSize", actualSize ) );
407 DALI_TEST_EQUALS( actualSize, testSize, TEST_LOCATION );
410 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
415 int UtcDaliVisualFactoryGetBorderVisual2(void)
417 ToolkitTestApplication application;
418 tet_infoline( "UtcDaliVisualFactoryGetBorderVisual2: Request border visual with a borderSize and a borderColor" );
420 VisualFactory factory = VisualFactory::Get();
421 DALI_TEST_CHECK( factory );
423 Vector4 testColor( 1.f, 0.5f, 0.3f, 1.f );
424 float testSize = 5.f;
426 Dali::Property::Map propertyMap;
427 propertyMap[ Visual::Property::TYPE ] = Visual::BORDER;
428 propertyMap[ BorderVisual::Property::COLOR ] = testColor;
429 propertyMap[ BorderVisual::Property::SIZE ] = testSize;
430 Visual::Base visual = factory.CreateVisual( propertyMap );
431 DALI_TEST_CHECK( visual );
433 DummyControl actor = DummyControl::New();
434 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
435 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
436 actor.SetSize(200.f, 200.f);
437 Stage::GetCurrent().Add( actor );
438 visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f));
440 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
442 TestGlAbstraction& gl = application.GetGlAbstraction();
444 application.SendNotification();
445 application.Render(0);
447 int blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLEND_MODE );
448 DALI_TEST_EQUALS( static_cast<BlendMode::Type>(blendMode), BlendMode::AUTO, TEST_LOCATION );
450 Vector4 actualColor(Vector4::ZERO);
451 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "borderColor", actualColor ) );
452 DALI_TEST_EQUALS( actualColor, testColor, TEST_LOCATION );
454 float actualSize = 0.f;
455 DALI_TEST_CHECK( gl.GetUniformValue<float>( "borderSize", actualSize ) );
456 DALI_TEST_EQUALS( actualSize, testSize, TEST_LOCATION );
460 // enable the anti-aliasing
461 Dali::Property::Map map;
462 map[ Visual::Property::TYPE ] = Visual::BORDER;
463 map[ BorderVisual::Property::COLOR ] = testColor;
464 map[ BorderVisual::Property::SIZE ] = testSize;
465 map[ BorderVisual::Property::ANTI_ALIASING ] = true;
466 visual = factory.CreateVisual( map );
468 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
469 Stage::GetCurrent().Add( actor );
471 blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLEND_MODE );
472 DALI_TEST_EQUALS( static_cast<BlendMode::Type>(blendMode), BlendMode::ON, TEST_LOCATION );
477 int UtcDaliVisualFactoryGetLinearGradientVisual(void)
479 ToolkitTestApplication application;
480 tet_infoline("UtcDaliVisualFactoryGetRadialGradientVisual");
482 VisualFactory factory = VisualFactory::Get();
483 DALI_TEST_CHECK( factory );
485 Property::Map propertyMap;
486 propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
488 Vector2 start(-1.f, -1.f);
489 Vector2 end(1.f, 1.f);
490 propertyMap.Insert(GradientVisual::Property::START_POSITION, start);
491 propertyMap.Insert(GradientVisual::Property::END_POSITION, end);
492 propertyMap.Insert(GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT);
494 Property::Array stopOffsets;
495 stopOffsets.PushBack( 0.2f );
496 stopOffsets.PushBack( 0.8f );
497 propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, stopOffsets);
499 Property::Array stopColors;
500 stopColors.PushBack( Color::RED );
501 stopColors.PushBack( Color::GREEN );
502 propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
504 Visual::Base visual = factory.CreateVisual(propertyMap);
505 DALI_TEST_CHECK( visual );
507 // A lookup texture is generated and pass to shader as sampler
508 DummyControl actor = DummyControl::New();
509 TestVisualRender( application, actor, visual, 1u);
514 int UtcDaliVisualFactoryGetRadialGradientVisual(void)
516 ToolkitTestApplication application;
517 tet_infoline("UtcDaliVisualFactoryGetRadialGradientVisual");
519 VisualFactory factory = VisualFactory::Get();
520 DALI_TEST_CHECK( factory );
522 Property::Map propertyMap;
523 propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
525 Vector2 center(100.f, 100.f);
526 float radius = 100.f;
527 propertyMap.Insert(GradientVisual::Property::UNITS, GradientVisual::Units::USER_SPACE);
528 propertyMap.Insert(GradientVisual::Property::CENTER, center);
529 propertyMap.Insert(GradientVisual::Property::RADIUS, radius);
531 Property::Array stopOffsets;
532 stopOffsets.PushBack( 0.0f );
533 stopOffsets.PushBack( 1.f );
534 propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, stopOffsets);
536 Property::Array stopColors;
537 stopColors.PushBack( Color::RED );
538 stopColors.PushBack( Color::GREEN );
539 propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
541 Visual::Base visual = factory.CreateVisual(propertyMap);
542 DALI_TEST_CHECK( visual );
544 // A lookup texture is generated and pass to shader as sampler
545 DummyControl actor = DummyControl::New();
546 TestVisualRender( application, actor, visual, 1u );
548 Matrix3 alignMatrix( radius, 0.f, 0.f, 0.f, radius, 0.f, center.x, center.y, 1.f );
549 alignMatrix.Invert();
551 Matrix3 actualValue( Matrix3::IDENTITY );
552 TestGlAbstraction& gl = application.GetGlAbstraction();
553 DALI_TEST_CHECK( gl.GetUniformValue<Matrix3>( "uAlignmentMatrix", actualValue ) );
554 DALI_TEST_EQUALS( actualValue, alignMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
559 int UtcDaliVisualFactoryDefaultOffsetsGradientVisual(void)
561 ToolkitTestApplication application;
562 tet_infoline("UtcDaliVisualFactoryGetRadialGradientVisual");
564 VisualFactory factory = VisualFactory::Get();
565 DALI_TEST_CHECK( factory );
567 Property::Map propertyMap;
568 propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
570 Vector2 start(-1.f, -1.f);
571 Vector2 end(1.f, 1.f);
572 propertyMap.Insert(GradientVisual::Property::START_POSITION, start);
573 propertyMap.Insert(GradientVisual::Property::END_POSITION, end);
574 propertyMap.Insert(GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT);
576 Property::Array stopColors;
577 stopColors.PushBack( Color::RED );
578 stopColors.PushBack( Color::GREEN );
579 propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
581 Visual::Base visual = factory.CreateVisual(propertyMap);
582 DALI_TEST_CHECK( visual );
584 // A lookup texture is generated and pass to shader as sampler
585 DummyControl actor = DummyControl::New();
586 TestVisualRender( application, actor, visual, 1u );
588 Stage::GetCurrent().Remove( actor );
589 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
594 int UtcDaliVisualFactoryGetImageVisual1(void)
596 ToolkitTestApplication application;
597 tet_infoline( "UtcDaliVisualFactoryGetImageVisual1: Request image visual with a Property::Map" );
599 VisualFactory factory = VisualFactory::Get();
600 DALI_TEST_CHECK( factory );
602 Property::Map propertyMap;
603 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
604 propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
606 Visual::Base visual = factory.CreateVisual( propertyMap );
607 DALI_TEST_CHECK( visual );
609 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
610 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
613 const int height=513;
614 TestGlAbstraction& gl = application.GetGlAbstraction();
615 TraceCallStack& textureTrace = gl.GetTextureTrace();
616 textureTrace.Enable(true);
618 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
619 bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, width, height,width, height );
621 DummyControl actor = DummyControl::New();
622 TestVisualRender( application, actor, visual, 1u,
623 ImageDimensions(width, height),
624 Integration::ResourcePointer( bitmap ) );
626 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
628 Stage::GetCurrent().Remove( actor );
629 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
634 int UtcDaliVisualFactoryGetImageVisual2(void)
636 ToolkitTestApplication application;
637 tet_infoline( "UtcDaliVisualFactoryGetImageVisual2: Request image visual with an image handle" );
639 VisualFactory factory = VisualFactory::Get();
640 DALI_TEST_CHECK( factory );
642 Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME);
643 Visual::Base visual = factory.CreateVisual( image );
645 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
646 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
649 const int height=513;
651 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
652 bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, width, height,width, height );
654 TestGlAbstraction& gl = application.GetGlAbstraction();
655 TraceCallStack& textureTrace = gl.GetTextureTrace();
656 textureTrace.Enable(true);
658 DummyControl actor = DummyControl::New();
659 TestVisualRender( application, actor, visual, 1u,
660 ImageDimensions(width, height),
661 Integration::ResourcePointer(bitmap) );
663 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
667 int UtcDaliVisualFactoryGetImageVisual3(void)
669 ToolkitTestApplication application;
670 tet_infoline( "UtcDaliVisualFactoryGetImageVisual3: Request image visual with a Property::Map, test custom wrap mode and pixel area with atlasing" );
672 VisualFactory factory = VisualFactory::Get();
673 DALI_TEST_CHECK( factory );
675 // Test wrap mode with atlasing. Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
678 const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
680 Property::Map propertyMap;
681 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
682 propertyMap.Insert( ImageVisual::Property::URL, gImage_34_RGBA );
683 propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, width );
684 propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, height );
685 propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true );
686 propertyMap.Insert( ImageVisual::Property::PIXEL_AREA, pixelArea );
687 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT );
688 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT );
690 Visual::Base visual = factory.CreateVisual( propertyMap );
691 DALI_TEST_CHECK( visual );
693 TestGlAbstraction& gl = application.GetGlAbstraction();
694 TraceCallStack& textureTrace = gl.GetTextureTrace();
695 textureTrace.Enable(true);
696 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
697 texParameterTrace.Enable( true );
699 DummyControl actor = DummyControl::New();
700 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
701 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
702 actor.SetSize(2000, 2000);
703 actor.SetParentOrigin(ParentOrigin::CENTER);
704 Stage::GetCurrent().Add( actor );
707 application.SendNotification();
708 application.Render();
709 application.Render();
710 application.SendNotification();
711 BitmapLoader loader = BitmapLoader::GetLatestCreated();
712 DALI_TEST_CHECK( loader );
713 loader.WaitForLoading();// waiting until the image to be loaded
714 DALI_TEST_CHECK( loader.IsLoaded() );
716 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
718 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
720 // WITH atlasing, the wrapping is handled manually in shader, so the following gl function should not be called
721 std::stringstream out;
722 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
723 DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
725 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
726 DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
728 // test the uniforms which used to handle the wrap mode
729 Renderer renderer = actor.GetRendererAt( 0u );
730 DALI_TEST_CHECK( renderer );
732 Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
733 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION );
734 Vector4 pixelAreaUniform;
735 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
736 DALI_TEST_EQUALS( pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
738 Property::Value wrapModeValue = renderer.GetProperty( renderer.GetPropertyIndex( "wrapMode" ) );
739 Vector2 wrapMode( WrapMode::MIRRORED_REPEAT-1, WrapMode::REPEAT-1 );
740 DALI_TEST_EQUALS( wrapModeValue.Get<Vector2>(), wrapMode, TEST_LOCATION );
741 Vector2 wrapModeUniform;
742 DALI_TEST_CHECK( gl.GetUniformValue<Vector2>( "wrapMode", wrapModeUniform ) );
743 DALI_TEST_EQUALS( wrapMode, wrapModeUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
746 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
751 int UtcDaliVisualFactoryGetImageVisual4(void)
753 ToolkitTestApplication application;
754 tet_infoline( "UtcDaliVisualFactoryGetImageVisual4: Request image visual with a Property::Map, test custom wrap mode and pixel area without atlasing" );
756 VisualFactory factory = VisualFactory::Get();
757 DALI_TEST_CHECK( factory );
759 // Test wrap mode without atlasing. Image with a size bigger than 512*512 will NOT be uploaded as a part of the atlas.
761 const int height=600;
762 const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
764 Property::Map propertyMap;
765 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
766 propertyMap.Insert( ImageVisual::Property::URL, gImage_600_RGB );
767 propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, width );
768 propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, height );
769 propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true );
770 propertyMap.Insert( ImageVisual::Property::PIXEL_AREA, pixelArea );
771 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT );
772 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT );
774 Visual::Base visual = factory.CreateVisual( propertyMap );
775 DALI_TEST_CHECK( visual );
777 TestGlAbstraction& gl = application.GetGlAbstraction();
778 TraceCallStack& textureTrace = gl.GetTextureTrace();
779 textureTrace.Enable(true);
780 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
781 texParameterTrace.Enable( true );
783 DummyControl actor = DummyControl::New();
784 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
785 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
786 actor.SetSize(2000, 2000);
787 actor.SetParentOrigin(ParentOrigin::CENTER);
788 Stage::GetCurrent().Add( actor );
791 application.SendNotification();
792 application.Render();
793 application.Render();
794 application.SendNotification();
795 BitmapLoader loader = BitmapLoader::GetLatestCreated();
796 DALI_TEST_CHECK( loader );
797 loader.WaitForLoading();// waiting until the image to be loaded
798 DALI_TEST_CHECK( loader.IsLoaded() );
800 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
802 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
804 // WITHOUT atlasing, the wrapping is handled by setting gl texture parameters
805 std::stringstream out;
806 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
807 DALI_TEST_CHECK( texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
809 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
810 DALI_TEST_CHECK( texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
812 // test the uniforms which used to handle the wrap mode
813 Renderer renderer = actor.GetRendererAt( 0u );
814 DALI_TEST_CHECK( renderer );
816 Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
817 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION );
818 Vector4 pixelAreaUniform;
819 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
820 DALI_TEST_EQUALS( pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
822 Property::Index wrapModeIndex = renderer.GetPropertyIndex( "wrapMode" );
823 DALI_TEST_CHECK(wrapModeIndex == Property::INVALID_INDEX);
826 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
831 int UtcDaliVisualFactoryGetNPatchVisual1(void)
833 ToolkitTestApplication application;
834 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual1: Request 9-patch visual with a Property::Map" );
836 VisualFactory factory = VisualFactory::Get();
837 DALI_TEST_CHECK( factory );
839 const unsigned int ninePatchImageHeight = 18;
840 const unsigned int ninePatchImageWidth = 28;
841 StretchRanges stretchRangesX;
842 stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
843 StretchRanges stretchRangesY;
844 stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
845 Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
847 Property::Map propertyMap;
848 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
849 propertyMap.Insert( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME );
851 tet_infoline( "whole grid" );
852 Visual::Base visual = factory.CreateVisual( propertyMap );
853 DALI_TEST_CHECK( visual );
856 TestGlAbstraction& gl = application.GetGlAbstraction();
857 TraceCallStack& textureTrace = gl.GetTextureTrace();
858 textureTrace.Enable(true);
860 DummyControl actor = DummyControl::New();
861 TestVisualRender( application, actor, visual, 1u,
862 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
865 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
868 propertyMap.Insert( ImageVisual::Property::BORDER_ONLY, true );
870 tet_infoline( "border only" );
871 Visual::Base visual = factory.CreateVisual( propertyMap );
872 DALI_TEST_CHECK( visual );
874 TestGlAbstraction& gl = application.GetGlAbstraction();
875 TraceCallStack& textureTrace = gl.GetTextureTrace();
876 textureTrace.Enable(true);
878 DummyControl actor = DummyControl::New();
879 TestVisualRender( application, actor, visual, 1u,
880 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
883 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
889 int UtcDaliVisualFactoryGetNPatchVisual2(void)
891 ToolkitTestApplication application;
892 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual2: Request n-patch visual with a Property::Map" );
894 VisualFactory factory = VisualFactory::Get();
895 DALI_TEST_CHECK( factory );
897 const unsigned int ninePatchImageWidth = 18;
898 const unsigned int ninePatchImageHeight = 28;
899 StretchRanges stretchRangesX;
900 stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
901 stretchRangesX.PushBack( Uint16Pair( 5, 7 ) );
902 stretchRangesX.PushBack( Uint16Pair( 12, 15 ) );
903 StretchRanges stretchRangesY;
904 stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
905 stretchRangesY.PushBack( Uint16Pair( 8, 12 ) );
906 stretchRangesY.PushBack( Uint16Pair( 15, 16 ) );
907 stretchRangesY.PushBack( Uint16Pair( 25, 27 ) );
908 Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
910 Property::Map propertyMap;
911 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
912 propertyMap.Insert( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME );
914 Visual::Base visual = factory.CreateVisual( propertyMap );
915 DALI_TEST_CHECK( visual );
917 TestGlAbstraction& gl = application.GetGlAbstraction();
918 TraceCallStack& textureTrace = gl.GetTextureTrace();
919 textureTrace.Enable(true);
921 DummyControl actor = DummyControl::New();
922 TestVisualRender( application, actor, visual, 1u,
923 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
926 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
928 Stage::GetCurrent().Remove( actor );
929 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
932 propertyMap.Insert( ImageVisual::Property::BORDER_ONLY, true );
934 tet_infoline( "border only" );
935 Visual::Base visual = factory.CreateVisual( propertyMap );
936 DALI_TEST_CHECK( visual );
938 TestGlAbstraction& gl = application.GetGlAbstraction();
939 TraceCallStack& textureTrace = gl.GetTextureTrace();
940 textureTrace.Enable(true);
941 DummyControl actor = DummyControl::New();
942 TestVisualRender( application, actor, visual, 1u,
943 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
947 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
949 Stage::GetCurrent().Remove( actor );
950 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
956 int UtcDaliVisualFactoryGetNPatchVisual3(void)
958 ToolkitTestApplication application;
959 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual3: Request 9-patch visual with an image url" );
961 VisualFactory factory = VisualFactory::Get();
962 DALI_TEST_CHECK( factory );
964 const unsigned int ninePatchImageHeight = 18;
965 const unsigned int ninePatchImageWidth = 28;
966 StretchRanges stretchRangesX;
967 stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
968 StretchRanges stretchRangesY;
969 stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
970 Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
972 Visual::Base visual = factory.CreateVisual( TEST_NPATCH_FILE_NAME, ImageDimensions() );
973 DALI_TEST_CHECK( visual );
975 TestGlAbstraction& gl = application.GetGlAbstraction();
976 TraceCallStack& textureTrace = gl.GetTextureTrace();
977 textureTrace.Enable(true);
979 DummyControl actor = DummyControl::New();
980 TestVisualRender( application, actor, visual, 1u,
981 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
984 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
987 ResourceImage image = ResourceImage::New(TEST_NPATCH_FILE_NAME);
988 Visual::Base nPatchVisual = factory.CreateVisual( image );
989 Vector2 controlSize( 20.f, 30.f ), naturalSize(0,0);
990 nPatchVisual.SetTransformAndSize(DefaultTransform(), controlSize );
991 nPatchVisual.GetNaturalSize( naturalSize );
992 DALI_TEST_EQUALS( naturalSize, Vector2( ninePatchImageWidth-2, ninePatchImageHeight-2 ), TEST_LOCATION );
997 int UtcDaliVisualFactoryGetNPatchVisual4(void)
999 ToolkitTestApplication application;
1000 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual4: Request n-patch visual with an image url" );
1002 VisualFactory factory = VisualFactory::Get();
1003 DALI_TEST_CHECK( factory );
1005 const unsigned int ninePatchImageHeight = 18;
1006 const unsigned int ninePatchImageWidth = 28;
1007 StretchRanges stretchRangesX;
1008 stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
1009 stretchRangesX.PushBack( Uint16Pair( 5, 7 ) );
1010 stretchRangesX.PushBack( Uint16Pair( 12, 15 ) );
1011 StretchRanges stretchRangesY;
1012 stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
1013 stretchRangesY.PushBack( Uint16Pair( 8, 12 ) );
1014 stretchRangesY.PushBack( Uint16Pair( 15, 16 ) );
1015 stretchRangesY.PushBack( Uint16Pair( 25, 27 ) );
1016 Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
1018 Visual::Base visual = factory.CreateVisual( TEST_NPATCH_FILE_NAME, ImageDimensions() );
1019 DALI_TEST_CHECK( visual );
1021 TestGlAbstraction& gl = application.GetGlAbstraction();
1022 TraceCallStack& textureTrace = gl.GetTextureTrace();
1023 textureTrace.Enable(true);
1025 DummyControl actor = DummyControl::New();
1026 TestVisualRender( application, actor, visual, 1u,
1027 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
1028 ninePatchResource );
1030 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1035 int UtcDaliVisualFactoryGetNPatchVisualN1(void)
1037 //This should still load but display an error image
1039 ToolkitTestApplication application;
1040 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid image url" );
1042 VisualFactory factory = VisualFactory::Get();
1043 DALI_TEST_CHECK( factory );
1045 Visual::Base visual = factory.CreateVisual( "ERROR.9.jpg", ImageDimensions() );
1046 DALI_TEST_CHECK( visual );
1048 //The testkit still has to load a bitmap for the broken renderer image
1049 Integration::Bitmap* bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
1050 bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 100, 100, 100, 100 );
1052 TestGlAbstraction& gl = application.GetGlAbstraction();
1053 TraceCallStack& textureTrace = gl.GetTextureTrace();
1054 textureTrace.Enable(true);
1056 DummyControl actor = DummyControl::New();
1057 TestVisualRender( application, actor, visual, 1u,
1059 Integration::ResourcePointer(bitmap) );
1061 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1066 int UtcDaliVisualFactoryGetNPatchVisualN2(void)
1068 //This should still load but display an error image
1070 ToolkitTestApplication application;
1071 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid URL" );
1073 VisualFactory factory = VisualFactory::Get();
1074 DALI_TEST_CHECK( factory );
1076 Property::Map propertyMap;
1077 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
1078 propertyMap.Insert( ImageVisual::Property::URL, "ERROR.9.jpg" );
1080 Visual::Base visual = factory.CreateVisual( propertyMap );
1081 DALI_TEST_CHECK( visual );
1083 //The testkit still has to load a bitmap for the broken renderer image
1084 Integration::Bitmap* bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
1085 bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 100, 100, 100, 100 );
1087 TestGlAbstraction& gl = application.GetGlAbstraction();
1088 TraceCallStack& textureTrace = gl.GetTextureTrace();
1089 textureTrace.Enable(true);
1090 TraceCallStack& drawTrace = gl.GetDrawTrace();
1091 drawTrace.Enable(true);
1093 DummyControl actor = DummyControl::New();
1094 TestVisualRender( application, actor, visual, 1u,
1096 Integration::ResourcePointer(bitmap) );
1098 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1103 int UtcDaliVisualFactoryGetNPatchVisualN3(void)
1105 // Passing in an invalid visual type so we should not get a visual
1107 ToolkitTestApplication application;
1108 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid visual type" );
1110 VisualFactory factory = VisualFactory::Get();
1111 DALI_TEST_CHECK( factory );
1113 Property::Map propertyMap;
1114 propertyMap.Insert( Visual::Property::TYPE, 111 );
1115 propertyMap.Insert( ImageVisual::Property::URL, "ERROR.9.jpg" );
1117 Visual::Base visual = factory.CreateVisual( propertyMap );
1118 DALI_TEST_CHECK( !visual );
1123 int UtcDaliVisualFactoryGetSvgVisual(void)
1125 ToolkitTestApplication application;
1126 tet_infoline( "UtcDaliVisualFactoryGetSvgVisual: Request svg visual with a svg url" );
1128 VisualFactory factory = VisualFactory::Get();
1129 Visual::Base visual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions() );
1130 DALI_TEST_CHECK( visual );
1132 TestGlAbstraction& gl = application.GetGlAbstraction();
1133 TraceCallStack& textureTrace = gl.GetTextureTrace();
1134 textureTrace.Enable(true);
1136 DummyControl actor = DummyControl::New();
1137 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1138 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1139 actor.SetSize( 200.f, 200.f );
1140 Stage::GetCurrent().Add( actor );
1141 visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f) );
1143 application.SendNotification();
1144 application.Render();
1146 // renderer is not added to actor until the rasterization is completed.
1147 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1149 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1151 // renderer is added to actor
1152 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
1154 // waiting for the resource uploading
1155 application.SendNotification();
1156 application.Render();
1158 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1163 int UtcDaliVisualFactoryGetSvgVisualLarge(void)
1165 ToolkitTestApplication application;
1166 tet_infoline( "UtcDaliVisualFactoryGetSvgVisual: Request svg visual with a svg url" );
1168 VisualFactory factory = VisualFactory::Get();
1169 Visual::Base visual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions( 2000, 2000 ) );
1170 DALI_TEST_CHECK( visual );
1172 TestGlAbstraction& gl = application.GetGlAbstraction();
1173 TraceCallStack& textureTrace = gl.GetTextureTrace();
1174 textureTrace.Enable(true);
1176 DummyControl actor = DummyControl::New(true);
1177 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1178 actor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); // Only rasterizes when it knows control size.
1179 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1180 Stage::GetCurrent().Add( actor );
1182 application.SendNotification();
1183 application.Render();
1185 // renderer is not added to actor until the rasterization is completed.
1186 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1188 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1190 // renderer is added to actor
1191 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
1193 // waiting for the resource uploading
1194 application.SendNotification();
1195 application.Render();
1197 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1202 //Creates a mesh visual from the given propertyMap and tries to load it on stage in the given application.
1203 //This is expected to succeed, which will then pass the test.
1204 void MeshVisualLoadsCorrectlyTest( Property::Map& propertyMap, ToolkitTestApplication& application )
1206 VisualFactory factory = VisualFactory::Get();
1207 DALI_TEST_CHECK( factory );
1209 //Create a mesh visual.
1210 Visual::Base visual = factory.CreateVisual( propertyMap );
1211 DALI_TEST_CHECK( visual );
1213 //Create an actor on stage to house the visual.
1214 DummyControl actor = DummyControl::New();
1215 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1216 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1217 actor.SetSize( 200.f, 200.f );
1218 Stage::GetCurrent().Add( actor );
1219 visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.f, 200.f ) );
1221 //Ensure set on stage.
1222 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1224 //Attempt to render to queue resource load requests.
1225 application.SendNotification();
1226 application.Render( 0 );
1228 //Render again to upload the now-loaded textures.
1229 application.SendNotification();
1230 application.Render( 0 );
1232 Matrix testScaleMatrix;
1233 testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
1234 Matrix actualScaleMatrix;
1236 //Test to see if the object has been successfully loaded.
1237 DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
1238 DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1240 //Finish by setting off stage, and ensuring this was successful.
1242 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1245 //Creates a mesh visual from the given propertyMap and tries to load it on stage in the given application.
1246 //This is expected to fail, which will then pass the test.
1247 void MeshVisualDoesNotLoadCorrectlyTest( Property::Map& propertyMap, ToolkitTestApplication& application )
1249 VisualFactory factory = VisualFactory::Get();
1250 DALI_TEST_CHECK( factory );
1252 //Create a mesh visual.
1253 Visual::Base visual = factory.CreateVisual( propertyMap );
1254 DALI_TEST_CHECK( visual );
1256 //Create an actor on stage to house the visual.
1257 DummyControl actor = DummyControl::New();
1258 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1259 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1260 actor.SetSize( 200.f, 200.f );
1261 Stage::GetCurrent().Add( actor );
1262 visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.f, 200.f ) );
1264 //Ensure set on stage.
1265 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1267 //Attempt to render to queue resource load requests.
1268 application.SendNotification();
1269 application.Render( 0 );
1271 //Render again to upload the now-loaded textures.
1272 application.SendNotification();
1273 application.Render( 0 );
1275 //Test to see if the object has not been loaded, as expected.
1277 DALI_TEST_CHECK( !application.GetGlAbstraction().GetUniformValue<Matrix>( "uObjectMatrix", scaleMatrix ) );
1279 //Finish by setting off stage, and ensuring this was successful.
1281 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1284 //Test if mesh loads correctly when supplied with only the bare minimum requirements, an object file.
1285 int UtcDaliVisualFactoryGetMeshVisual1(void)
1287 //Set up test application first, so everything else can be handled.
1288 ToolkitTestApplication application;
1290 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual1: Request mesh visual with a valid object file only" );
1293 //Set up visual properties.
1294 Property::Map propertyMap;
1295 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1296 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1298 //Test to see if mesh loads correctly.
1299 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1305 //Test if mesh loads correctly when supplied with an object file as well as a blank material file and images directory.
1306 int UtcDaliVisualFactoryGetMeshVisual2(void)
1308 //Set up test application first, so everything else can be handled.
1309 ToolkitTestApplication application;
1311 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual2: Request mesh visual with blank material file and images directory" );
1313 //Set up visual properties.
1314 Property::Map propertyMap;
1315 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1316 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1317 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, "" );
1318 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, "" );
1320 //Test to see if mesh loads correctly.
1321 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1326 //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
1327 int UtcDaliVisualFactoryGetMeshVisual3b(void)
1329 //Set up test application first, so everything else can be handled.
1330 ToolkitTestApplication application;
1332 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual3: Request mesh visual with all parameters correct" );
1334 //Set up visual properties.
1335 Property::Map propertyMap;
1336 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1337 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1338 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1339 propertyMap.Insert( MeshVisual::Property::USE_MIPMAPPING, Color::GREEN ); // Test that wrong property types don't prevent the object load
1340 propertyMap.Insert( MeshVisual::Property::USE_SOFT_NORMALS, 1.0f );
1341 propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, 1.0f );
1342 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1344 //Test to see if mesh loads correctly.
1345 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1350 //Test if mesh loads correctly when supplied with all main parameters, an object file, a material file and a directory location.
1351 int UtcDaliVisualFactoryGetMeshVisual3(void)
1353 //Set up test application first, so everything else can be handled.
1354 ToolkitTestApplication application;
1356 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual3: Request mesh visual with all parameters correct" );
1358 //Set up visual properties.
1359 Property::Map propertyMap;
1360 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1361 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1362 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1363 propertyMap.Insert( MeshVisual::Property::USE_MIPMAPPING, false );
1364 propertyMap.Insert( MeshVisual::Property::USE_SOFT_NORMALS, false );
1365 propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3::XAXIS );
1366 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1368 //Test to see if mesh loads correctly.
1369 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1374 //Test if mesh visual can load a correctly supplied mesh without a normal map or gloss map in the material file.
1375 int UtcDaliVisualFactoryGetMeshVisual4(void)
1377 //Set up test application first, so everything else can be handled.
1378 ToolkitTestApplication application;
1380 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual4: Request mesh visual with diffuse texture but not normal or gloss." );
1383 //Set up visual properties.
1384 Property::Map propertyMap;
1385 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1386 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1387 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_SIMPLE_MTL_FILE_NAME );
1388 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1390 //Test to see if mesh loads correctly.
1391 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1396 //Test if mesh visual can load when made to use diffuse textures only.
1397 int UtcDaliVisualFactoryGetMeshVisual5(void)
1399 //Set up test application first, so everything else can be handled.
1400 ToolkitTestApplication application;
1402 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual5: Request mesh visual and make it only use diffuse textures." );
1404 //Set up visual properties.
1405 Property::Map propertyMap;
1406 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1407 propertyMap.Insert( "objectUrl", TEST_OBJ_FILE_NAME );
1408 propertyMap.Insert( "materialUrl", TEST_MTL_FILE_NAME );
1409 propertyMap.Insert( "texturesPath", TEST_RESOURCE_DIR "/" );
1410 propertyMap.Insert( "useMipmapping", false );
1411 propertyMap.Insert( "useSoftNormals", false );
1412 propertyMap.Insert( "lightPosition", Vector3::ZAXIS );
1413 propertyMap.Insert( "shadingMode", MeshVisual::ShadingMode::TEXTURED_WITH_SPECULAR_LIGHTING );
1415 //Test to see if mesh loads correctly.
1416 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1422 //Test if mesh visual can load when made to not use the supplied textures.
1423 int UtcDaliVisualFactoryGetMeshVisual6(void)
1425 //Set up test application first, so everything else can be handled.
1426 ToolkitTestApplication application;
1428 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual6: Request mesh visual and make it not use any textures." );
1430 //Set up visual properties.
1431 Property::Map propertyMap;
1432 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1433 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1434 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1435 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1436 propertyMap.Insert( MeshVisual::Property::SHADING_MODE, MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING );
1438 //Test to see if mesh loads correctly.
1439 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1443 //Test if mesh visual loads correctly when light position is manually set.
1444 int UtcDaliVisualFactoryGetMeshVisual7(void)
1446 //Set up test application first, so everything else can be handled.
1447 ToolkitTestApplication application;
1450 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual7: Request mesh visual with custom light position." );
1452 //Set up visual properties.
1453 Property::Map propertyMap;
1454 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1455 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1456 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1457 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1458 propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.0, 1.0, 2.0 ) );
1460 //Test to see if mesh loads correctly.
1461 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1466 //Test if mesh visual loads correctly when supplied an object file without face normals or texture points.
1467 //Note that this notably tests object loader functionality.
1468 int UtcDaliVisualFactoryGetMeshVisual8(void)
1470 //Set up test application first, so everything else can be handled.
1471 ToolkitTestApplication application;
1473 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual5: Request mesh visual with normal-less object file." );
1475 //Set up visual properties.
1476 Property::Map propertyMap;
1477 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1478 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_SIMPLE_OBJ_FILE_NAME );
1479 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1480 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1482 //Test to see if mesh loads correctly.
1483 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1488 //Test if mesh visual handles the case of lacking an object file.
1489 int UtcDaliVisualFactoryGetMeshVisualN1(void)
1491 //Set up test application first, so everything else can be handled.
1492 ToolkitTestApplication application;
1494 tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN1: Request mesh visual without object file" );
1496 //Set up visual properties.
1497 Property::Map propertyMap;
1498 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1499 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1500 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1502 //Test to see if mesh doesn't load with these properties, as expected.
1503 MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
1509 //Test if mesh visual handles the case of being passed invalid material and images urls.
1510 int UtcDaliVisualFactoryGetMeshVisualN2(void)
1512 //Set up test application first, so everything else can be handled.
1513 ToolkitTestApplication application;
1515 tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN2: Request mesh visual with invalid material and images urls" );
1517 //Set up visual properties.
1518 Property::Map propertyMap;
1519 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1520 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1521 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, "invalid" );
1522 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, "also invalid" );
1524 //Test to see if mesh doesn't load with these properties, as expected.
1525 MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
1531 //Test if mesh visual handles the case of being passed an invalid object url
1532 int UtcDaliVisualFactoryGetMeshVisualN3(void)
1534 //Set up test application first, so everything else can be handled.
1535 ToolkitTestApplication application;
1536 tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN3: Request mesh visual with invalid object url" );
1539 //Set up visual properties.
1540 Property::Map propertyMap;
1541 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1542 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, "invalid" );
1543 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1544 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1546 //Test to see if mesh doesn't load with these properties, as expected.
1547 MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
1552 //Creates a primitive visual with the given property map and tests to see if it correctly loads in the given application.
1553 void TestPrimitiveVisualWithProperties( Property::Map& propertyMap, ToolkitTestApplication& application )
1555 VisualFactory factory = VisualFactory::Get();
1556 DALI_TEST_CHECK( factory );
1558 //Create a primitive visual.
1559 Visual::Base visual = factory.CreateVisual( propertyMap );
1560 DALI_TEST_CHECK( visual );
1562 //Create an actor on stage to house the visual.
1563 DummyControl actor = DummyControl::New();
1564 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1565 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1567 actor.SetSize( 200.f, 200.f );
1568 Stage::GetCurrent().Add( actor );
1569 visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.f, 200.f ) );
1571 //Ensure set on stage.
1572 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1574 //Tell test application to load the visual.
1575 application.SendNotification();
1576 application.Render(0);
1578 Matrix testScaleMatrix;
1579 testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
1580 Matrix actualScaleMatrix;
1582 //Test to see if the object has been successfully loaded.
1583 DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
1584 DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1586 //Finish by setting off stage, and ensuring this was successful.
1588 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1591 //Test if primitive shape loads correctly when supplied with only the bare minimum requirements, the shape to use.
1592 int UtcDaliVisualFactoryGetPrimitiveVisual1(void)
1594 //Set up test application first, so everything else can be handled.
1595 ToolkitTestApplication application;
1597 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual1: Request primitive visual with a shape only" );
1599 //Set up visual properties.
1600 Property::Map propertyMap;
1601 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1602 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
1604 //Test to see if shape loads correctly.
1605 TestPrimitiveVisualWithProperties( propertyMap, application );
1610 //Test if primitive shape loads correctly when supplied with all possible parameters
1611 int UtcDaliVisualFactoryGetPrimitiveVisual2(void)
1613 //Set up test application first, so everything else can be handled.
1614 ToolkitTestApplication application;
1616 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual2: Request primitive visual with everything" );
1618 //Set up visual properties.
1619 Property::Map propertyMap;
1620 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1621 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
1622 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1623 propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1624 propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
1625 propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
1626 propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f );
1627 propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
1628 propertyMap.Insert( PrimitiveVisual::Property::SCALE_RADIUS, 60.0f );
1629 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.7f );
1630 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, 0.8f );
1631 propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.9, 1.0, 1.1 ) );
1633 //Test to see if shape loads correctly.
1634 TestPrimitiveVisualWithProperties( propertyMap, application );
1639 //Test if primitive shape loads a sphere correctly.
1640 int UtcDaliVisualFactoryGetPrimitiveVisual3(void)
1642 //Set up test application first, so everything else can be handled.
1643 ToolkitTestApplication application;
1645 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual3: Request primitive visual to display a sphere" );
1647 //Set up visual properties.
1648 Property::Map propertyMap;
1649 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1650 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1651 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1652 propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1653 propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
1655 //Test to see if shape loads correctly.
1656 TestPrimitiveVisualWithProperties( propertyMap, application );
1661 //Test if primitive shape loads a conic section correctly.
1662 int UtcDaliVisualFactoryGetPrimitiveVisual4(void)
1664 //Set up test application first, so everything else can be handled.
1665 ToolkitTestApplication application;
1667 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual4: Request primitive visual to display a conic section" );
1669 //Set up visual properties.
1670 Property::Map propertyMap;
1671 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1672 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONICAL_FRUSTRUM );
1673 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1674 propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1675 propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
1676 propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f );
1677 propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
1679 //Test to see if shape loads correctly.
1680 TestPrimitiveVisualWithProperties( propertyMap, application );
1685 //Test if primitive shape loads a bevelled cube correctly.
1686 int UtcDaliVisualFactoryGetPrimitiveVisual5(void)
1688 //Set up test application first, so everything else can be handled.
1689 ToolkitTestApplication application;
1691 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual5: Request primitive visual to display a bevelled cube" );
1693 //Set up visual properties.
1694 Property::Map propertyMap;
1695 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1696 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::BEVELLED_CUBE );
1697 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1698 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.7f );
1700 //Test to see if shape loads correctly.
1701 TestPrimitiveVisualWithProperties( propertyMap, application );
1706 //Test if primitive shape loads an octahedron correctly.
1707 int UtcDaliVisualFactoryGetPrimitiveVisual6(void)
1709 //Set up test application first, so everything else can be handled.
1710 ToolkitTestApplication application;
1712 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual6: Request primitive visual to display an octahedron" );
1714 //Set up visual properties.
1715 Property::Map propertyMap;
1716 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1717 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::OCTAHEDRON );
1718 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1720 //Test to see if shape loads correctly.
1721 TestPrimitiveVisualWithProperties( propertyMap, application );
1726 //Test if primitive shape loads a cone correctly.
1727 int UtcDaliVisualFactoryGetPrimitiveVisual7(void)
1729 //Set up test application first, so everything else can be handled.
1730 ToolkitTestApplication application;
1732 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual7: Request primitive visual to display a cone" );
1734 //Set up visual properties.
1735 Property::Map propertyMap;
1736 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1737 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONE );
1738 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1739 propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1740 propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
1741 propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
1743 //Test to see if shape loads correctly.
1744 TestPrimitiveVisualWithProperties( propertyMap, application );
1749 //Test if primitive shape loads correctly when light position is manually set.
1750 int UtcDaliVisualFactoryGetPrimitiveVisual8(void)
1752 //Set up test application first, so everything else can be handled.
1753 ToolkitTestApplication application;
1755 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual8: Request primitive visual with set light position" );
1757 //Set up visual properties.
1758 Property::Map propertyMap;
1759 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1760 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1761 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1762 propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.0, 1.0, 2.0 ) );
1764 //Test to see if shape loads correctly.
1765 TestPrimitiveVisualWithProperties( propertyMap, application );
1770 //Test if primitive shape loads correctly when told to use too many slices.
1771 int UtcDaliVisualFactoryGetPrimitiveVisual9(void)
1773 //Set up test application first, so everything else can be handled.
1774 ToolkitTestApplication application;
1776 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual9: Request primitive visual with above-cap slices." );
1778 //Set up visual properties.
1779 Property::Map propertyMap;
1780 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1781 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1782 propertyMap.Insert( PrimitiveVisual::Property::SLICES, Property::Value( 1000000 ) );
1784 //Test to see if shape loads correctly.
1785 TestPrimitiveVisualWithProperties( propertyMap, application );
1790 //Test if primitive shape loads correctly when told to use too few slices. (2 slices or less.)
1791 int UtcDaliVisualFactoryGetPrimitiveVisual10(void)
1793 //Set up test application first, so everything else can be handled.
1794 ToolkitTestApplication application;
1796 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual10: Request primitive visual with too few slices." );
1798 //Set up visual properties.
1799 Property::Map propertyMap;
1800 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1801 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1802 propertyMap.Insert( PrimitiveVisual::Property::SLICES, Property::Value( 2 ) );
1804 //Test to see if shape loads correctly.
1805 TestPrimitiveVisualWithProperties( propertyMap, application );
1810 //Test if primitive shape loads correctly when told to use too many stacks.
1811 int UtcDaliVisualFactoryGetPrimitiveVisual11(void)
1813 //Set up test application first, so everything else can be handled.
1814 ToolkitTestApplication application;
1816 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual11: Request primitive visual with too many stacks." );
1818 //Set up visual properties.
1819 Property::Map propertyMap;
1820 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1821 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1822 propertyMap.Insert( PrimitiveVisual::Property::STACKS, Property::Value( 1000000 ) );
1824 //Test to see if shape loads correctly.
1825 TestPrimitiveVisualWithProperties( propertyMap, application );
1830 //Test if primitive shape loads correctly when told to use too few stacks. (1 stack or less.)
1831 int UtcDaliVisualFactoryGetPrimitiveVisual12(void)
1833 //Set up test application first, so everything else can be handled.
1834 ToolkitTestApplication application;
1836 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual12: Request primitive visual with too few stacks." );
1838 //Set up visual properties.
1839 Property::Map propertyMap;
1840 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1841 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1842 propertyMap.Insert( PrimitiveVisual::Property::STACKS, Property::Value( 1 ) );
1844 //Test to see if shape loads correctly.
1845 TestPrimitiveVisualWithProperties( propertyMap, application );
1850 //Test if primitive shape loads correctly when told to use invalid (zero or negative) dimensions.
1851 int UtcDaliVisualFactoryGetPrimitiveVisual13(void)
1853 //Set up test application first, so everything else can be handled.
1854 ToolkitTestApplication application;
1856 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual13: Request primitive visual with invalid scale dimensions." );
1858 //Set up visual properties.
1859 Property::Map propertyMap;
1860 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1861 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1862 propertyMap.Insert( PrimitiveVisual::Property::SCALE_DIMENSIONS, Vector3::ZERO );
1864 //Test to see if shape loads correctly.
1865 TestPrimitiveVisualWithProperties( propertyMap, application );
1870 //Test if primitive shape loads correctly when told to use too low a bevel percentage.
1871 int UtcDaliVisualFactoryGetPrimitiveVisual14(void)
1873 //Set up test application first, so everything else can be handled.
1874 ToolkitTestApplication application;
1876 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual14: Request primitive visual with too low a bevel percentage." );
1878 //Set up visual properties.
1879 Property::Map propertyMap;
1880 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1881 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1882 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, Property::Value( -1.0f ) );
1884 //Test to see if shape loads correctly.
1885 TestPrimitiveVisualWithProperties( propertyMap, application );
1890 //Test if primitive shape loads correctly when told to use too high a bevel percentage.
1891 int UtcDaliVisualFactoryGetPrimitiveVisual15(void)
1893 //Set up test application first, so everything else can be handled.
1894 ToolkitTestApplication application;
1896 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual15: Request primitive visual with too high a bevel percentage." );
1898 //Set up visual properties.
1899 Property::Map propertyMap;
1900 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1901 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1902 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, Property::Value( 2.0f ) );
1904 //Test to see if shape loads correctly.
1905 TestPrimitiveVisualWithProperties( propertyMap, application );
1910 //Test if primitive shape loads correctly when told to use too low a bevel smoothness.
1911 int UtcDaliVisualFactoryGetPrimitiveVisual16(void)
1913 //Set up test application first, so everything else can be handled.
1914 ToolkitTestApplication application;
1916 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual16: Request primitive visual with too low a bevel smoothness." );
1918 //Set up visual properties.
1919 Property::Map propertyMap;
1920 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1921 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1922 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, Property::Value( -1.0f ) );
1924 //Test to see if shape loads correctly.
1925 TestPrimitiveVisualWithProperties( propertyMap, application );
1930 //Test if primitive shape loads correctly when told to use too high a bevel smoothness.
1931 int UtcDaliVisualFactoryGetPrimitiveVisual17(void)
1933 //Set up test application first, so everything else can be handled.
1934 ToolkitTestApplication application;
1936 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual17: Request primitive visual with too high a bevel smoothness." );
1938 //Set up visual properties.
1939 Property::Map propertyMap;
1940 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1941 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1942 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, Property::Value( 2.0f ) );
1944 //Test to see if shape loads correctly.
1945 TestPrimitiveVisualWithProperties( propertyMap, application );
1950 //Test if primitive shape visual handles the case of not being passed a specific shape to use.
1951 int UtcDaliVisualFactoryGetPrimitiveVisualN1(void)
1953 //Set up test application first, so everything else can be handled.
1954 ToolkitTestApplication application;
1956 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisualN1: Request primitive visual without shape" );
1958 //Set up visual properties, without supplying shape.
1959 Property::Map propertyMap;
1960 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1962 //Test to see if shape loads regardless of missing input.
1963 TestPrimitiveVisualWithProperties( propertyMap, application );
1968 int UtcDaliVisualFactoryGetAnimatedImageVisual1(void)
1970 ToolkitTestApplication application;
1971 tet_infoline( "UtcDaliVisualFactoryGetAnimatedImageVisual1: Request animated image visual with a gif url" );
1973 VisualFactory factory = VisualFactory::Get();
1974 Visual::Base visual = factory.CreateVisual( TEST_GIF_FILE_NAME, ImageDimensions() );
1975 DALI_TEST_CHECK( visual );
1977 TestGlAbstraction& gl = application.GetGlAbstraction();
1978 TraceCallStack& textureTrace = gl.GetTextureTrace();
1979 textureTrace.Enable(true);
1981 DummyControl actor = DummyControl::New();
1982 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1983 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1984 actor.SetSize( 200.0f, 200.0f );
1985 Stage::GetCurrent().Add( actor );
1987 application.SendNotification();
1988 application.Render();
1990 // renderer is added to actor
1991 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
1993 // test the uniforms which used to handle the atlas rect
1994 // the four frames should be located inside atlas as follows: atlas size 100*100
2003 Renderer renderer = actor.GetRendererAt( 0u );
2004 DALI_TEST_CHECK( renderer );
2006 Property::Value atlasRectValue = renderer.GetProperty( renderer.GetPropertyIndex( "uAtlasRect" ) );
2007 // take into consideration the half pixel correction
2008 DALI_TEST_EQUALS( atlasRectValue.Get<Vector4>(), Vector4(0.5f, 0.5f, 49.5f, 49.5f)/100.f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2010 // waiting for the resource uploading
2011 application.SendNotification();
2012 application.Render();
2014 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
2016 // Force the timer used by the animatedImageVisual to tick,
2017 Dali::Timer timer = Timer::New( 0 );
2018 timer.MockEmitSignal();
2019 application.SendNotification();
2020 application.Render();
2021 atlasRectValue = renderer.GetProperty( renderer.GetPropertyIndex( "uAtlasRect" ) );
2022 // take into consideration the half pixel correction
2023 DALI_TEST_EQUALS( atlasRectValue.Get<Vector4>(), Vector4(50.5f, 0.5f, 99.5f, 49.5f)/100.f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2025 // Force the timer used by the animatedImageVisual to tick,
2026 timer.MockEmitSignal();
2027 application.SendNotification();
2028 application.Render();
2029 atlasRectValue = renderer.GetProperty( renderer.GetPropertyIndex( "uAtlasRect" ) );
2030 // take into consideration the half pixel correction
2031 DALI_TEST_EQUALS( atlasRectValue.Get<Vector4>(), Vector4(0.5f, 50.5f, 49.5f, 99.5f)/100.f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2033 // Force the timer used by the animatedImageVisual to tick,
2034 timer.MockEmitSignal();
2035 application.SendNotification();
2036 application.Render();
2037 atlasRectValue = renderer.GetProperty( renderer.GetPropertyIndex( "uAtlasRect" ) );
2038 // take into consideration the half pixel correction
2039 DALI_TEST_EQUALS( atlasRectValue.Get<Vector4>(), Vector4(50.5f, 50.5f, 99.5f, 99.5f)/100.f, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2041 // Test SetOffStage().
2043 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
2048 int UtcDaliVisualFactoryGetAnimatedImageVisual2(void)
2050 ToolkitTestApplication application;
2051 tet_infoline( "UtcDaliVisualFactoryGetAnimatedImageVisual2: Request animated image visual with a Property::Map, test custom wrap mode and pixel area" );
2053 const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
2054 Property::Map propertyMap;
2055 propertyMap.Add( Visual::Property::TYPE, Visual::IMAGE )
2056 .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
2057 .Add( ImageVisual::Property::PIXEL_AREA, pixelArea )
2058 .Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT )
2059 .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT );
2061 Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
2062 DALI_TEST_CHECK( visual );
2064 TestGlAbstraction& gl = application.GetGlAbstraction();
2065 TraceCallStack& textureTrace = gl.GetTextureTrace();
2066 textureTrace.Enable(true);
2067 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
2068 texParameterTrace.Enable( true );
2070 DummyControl actor = DummyControl::New();
2071 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2072 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
2073 actor.SetSize( 200.0f, 200.0f );
2074 Stage::GetCurrent().Add( actor );
2076 application.SendNotification();
2077 application.Render();
2079 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
2081 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
2083 // For animated image visual, the wrapping is handled manually in shader, so the following gl function should not be called
2084 std::stringstream out;
2085 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
2086 DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
2088 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
2089 DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
2091 // test the uniforms which used to handle the wrap mode
2092 Renderer renderer = actor.GetRendererAt( 0u );
2093 DALI_TEST_CHECK( renderer );
2095 Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
2096 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION );
2097 Vector4 pixelAreaUniform;
2098 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
2099 DALI_TEST_EQUALS( pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2101 Property::Value wrapModeValue = renderer.GetProperty( renderer.GetPropertyIndex( "wrapMode" ) );
2102 Vector2 wrapMode( WrapMode::MIRRORED_REPEAT-1, WrapMode::REPEAT-1 );
2103 DALI_TEST_EQUALS( wrapModeValue.Get<Vector2>(), wrapMode, TEST_LOCATION );
2104 Vector2 wrapModeUniform;
2105 DALI_TEST_CHECK( gl.GetUniformValue<Vector2>( "wrapMode", wrapModeUniform ) );
2106 DALI_TEST_EQUALS( wrapMode, wrapModeUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
2109 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );