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-event-thread-callback.h>
21 #include <dali/public-api/rendering/renderer.h>
22 #include <dali/public-api/rendering/texture-set.h>
23 #include <dali/public-api/rendering/shader.h>
24 #include <dali/devel-api/images/nine-patch-image.h>
25 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
26 #include <dali-toolkit/dali-toolkit.h>
29 using namespace Dali::Toolkit;
33 typedef NinePatchImage::StretchRanges StretchRanges;
35 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
36 const char* TEST_NPATCH_FILE_NAME = "gallery_image_01.9.png";
38 const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
39 const char* TEST_OBJ_FILE_NAME = TEST_RESOURCE_DIR "/Cube.obj";
40 const char* TEST_MTL_FILE_NAME = TEST_RESOURCE_DIR "/ToyRobot-Metal.mtl";
41 const char* TEST_SIMPLE_OBJ_FILE_NAME = TEST_RESOURCE_DIR "/Cube-Points-Only.obj";
42 const char* TEST_SIMPLE_MTL_FILE_NAME = TEST_RESOURCE_DIR "/ToyRobot-Metal-Simple.mtl";
44 Integration::Bitmap* CreateBitmap( unsigned int imageWidth, unsigned int imageHeight, unsigned int initialColor, Pixel::Format pixelFormat )
46 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
47 Integration::PixelBuffer* pixbuffer = bitmap->GetPackedPixelsProfile()->ReserveBuffer( pixelFormat, imageWidth, imageHeight, imageWidth, imageHeight );
48 unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
50 memset( pixbuffer, initialColor, imageHeight * imageWidth * bytesPerPixel );
55 void InitialiseRegionsToZeroAlpha( Integration::Bitmap* image, unsigned int imageWidth, unsigned int imageHeight, Pixel::Format pixelFormat )
57 PixelBuffer* pixbuffer = image->GetBuffer();
58 unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
60 for( unsigned int row = 0; row < imageWidth; ++row )
62 unsigned int pixelOffset = row * bytesPerPixel;
63 pixbuffer[ pixelOffset + 3 ] = 0x00;
64 pixelOffset += ( imageHeight - 1 ) * imageWidth * bytesPerPixel;
65 pixbuffer[ pixelOffset + 3 ] = 0x00;
68 for ( unsigned int column = 0; column < imageHeight; ++column )
70 unsigned int pixelOffset = column * imageWidth * bytesPerPixel;
71 pixbuffer[ pixelOffset + 3 ] = 0x00;
72 pixelOffset += ( imageWidth -1 ) * bytesPerPixel;
73 pixbuffer[ pixelOffset + 3 ] = 0x00;
77 void AddStretchRegionsToImage( Integration::Bitmap* image, unsigned int imageWidth, unsigned int imageHeight, const StretchRanges& stretchRangesX, const StretchRanges& stretchRangesY, Pixel::Format pixelFormat )
79 PixelBuffer* pixbuffer = image->GetBuffer();
80 unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
82 for(StretchRanges::ConstIterator it = stretchRangesX.Begin(); it != stretchRangesX.End(); ++it)
84 const Uint16Pair& range = *it;
85 //since the stretch range is in the cropped image space, we need to offset by 1 to get it to the uncropped image space
86 for( unsigned int column = range.GetX() + 1u; column < range.GetY() + 1u; ++column )
88 unsigned int pixelOffset = column * bytesPerPixel;
89 pixbuffer[ pixelOffset ] = 0x00;
90 pixbuffer[ pixelOffset + 1 ] = 0x00;
91 pixbuffer[ pixelOffset + 2 ] = 0x00;
92 pixbuffer[ pixelOffset + 3 ] = 0xFF;
97 for(StretchRanges::ConstIterator it = stretchRangesY.Begin(); it != stretchRangesY.End(); ++it)
99 const Uint16Pair& range = *it;
100 //since the stretch range is in the cropped image space, we need to offset by 1 to get it to the uncropped image space
101 for( unsigned int row = range.GetX() + 1u; row < range.GetY() + 1u; ++row )
103 unsigned int pixelOffset = row * imageWidth * bytesPerPixel;
104 pixbuffer[ pixelOffset ] = 0x00;
105 pixbuffer[ pixelOffset + 1 ] = 0x00;
106 pixbuffer[ pixelOffset + 2 ] = 0x00;
107 pixbuffer[ pixelOffset + 3 ] = 0xFF;
112 void AddChildRegionsToImage( Integration::Bitmap* image, unsigned int imageWidth, unsigned int imageHeight, const Vector4& requiredChildRegion, Pixel::Format pixelFormat )
114 PixelBuffer* pixbuffer = image->GetBuffer();
115 unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
117 Integration::Bitmap::PackedPixelsProfile* srcProfile = image->GetPackedPixelsProfile();
118 unsigned int bufferStride = srcProfile->GetBufferStride();
120 // Add bottom child region
121 for( unsigned int column = requiredChildRegion.x; column < imageWidth - requiredChildRegion.z; ++column )
123 unsigned int pixelOffset = column * bytesPerPixel;
124 pixelOffset += ( imageHeight - 1 ) * bufferStride;
125 pixbuffer[ pixelOffset ] = 0x00;
126 pixbuffer[ pixelOffset + 1 ] = 0x00;
127 pixbuffer[ pixelOffset + 2 ] = 0x00;
128 pixbuffer[ pixelOffset + 3 ] = 0xFF;
131 // Add right child region
132 for ( unsigned int row = requiredChildRegion.y; row < imageHeight - requiredChildRegion.w; ++row )
134 unsigned int pixelOffset = row * bufferStride + ( imageWidth - 1 ) * bytesPerPixel;
135 pixbuffer[ pixelOffset ] = 0x00;
136 pixbuffer[ pixelOffset + 1 ] = 0x00;
137 pixbuffer[ pixelOffset + 2 ] = 0x00;
138 pixbuffer[ pixelOffset + 3 ] = 0xFF;
142 Integration::ResourcePointer CustomizeNinePatch( TestApplication& application,
143 unsigned int ninePatchImageWidth,
144 unsigned int ninePatchImageHeight,
145 const StretchRanges& stretchRangesX,
146 const StretchRanges& stretchRangesY,
147 bool addChildRegion = false,
148 Vector4 requiredChildRegion = Vector4::ZERO )
150 TestPlatformAbstraction& platform = application.GetPlatform();
152 Pixel::Format pixelFormat = Pixel::RGBA8888;
154 tet_infoline("Create Bitmap");
155 platform.SetClosestImageSize(Vector2( ninePatchImageWidth, ninePatchImageHeight));
156 Integration::Bitmap* bitmap = CreateBitmap( ninePatchImageWidth, ninePatchImageHeight, 0xFF, pixelFormat );
158 tet_infoline("Clear border regions");
159 InitialiseRegionsToZeroAlpha( bitmap, ninePatchImageWidth, ninePatchImageHeight, pixelFormat );
161 tet_infoline("Add Stretch regions to Bitmap");
162 AddStretchRegionsToImage( bitmap, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY, pixelFormat );
166 tet_infoline("Add Child regions to Bitmap");
167 AddChildRegionsToImage( bitmap, ninePatchImageWidth, ninePatchImageHeight, requiredChildRegion, pixelFormat );
170 tet_infoline("Getting resource");
171 Integration::ResourcePointer resourcePtr(bitmap);
172 //platform.SetResourceLoaded( 0, Dali::Integration::ResourceBitmap, resourcePtr );
173 platform.SetSynchronouslyLoadedResource( resourcePtr);
178 void TestVisualRender( ToolkitTestApplication& application,
180 Visual::Base& visual,
181 std::size_t expectedSamplers = 0,
182 ImageDimensions imageDimensions = ImageDimensions(),
183 Integration::ResourcePointer resourcePtr = Integration::ResourcePointer())
187 // set the image size, for test case, this needs to be set before loading started
188 application.GetPlatform().SetClosestImageSize( Vector2(imageDimensions.GetWidth(), imageDimensions.GetHeight()) );
191 actor.SetSize( 200.f, 200.f );
192 Stage::GetCurrent().Add( actor );
193 visual.SetSize( Vector2(200.f, 200.f) );
194 visual.SetOnStage( actor );
196 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
198 application.SendNotification();
199 application.Render();
203 Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
206 application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resourcePtr );
210 application.Render();
211 application.SendNotification();
215 DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ||
216 application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceSynchronouslyFunc ));
219 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
226 void dali_visual_factory_startup(void)
228 test_return_value = TET_UNDEF;
231 void dali_visual_factory_cleanup(void)
233 test_return_value = TET_PASS;
236 int UtcDaliVisualFactoryGet(void)
238 ToolkitTestApplication application;
239 tet_infoline( "UtcDaliVisualFactory" );
243 type = TypeRegistry::Get().GetTypeInfo( "VisualFactory" );
244 DALI_TEST_CHECK( type );
245 BaseHandle handle = type.CreateInstance();
246 DALI_TEST_CHECK( handle );
248 VisualFactory factory;
249 factory = VisualFactory::Get();
250 DALI_TEST_CHECK( factory );
252 VisualFactory newFactory = VisualFactory::Get();
253 DALI_TEST_CHECK( newFactory );
255 // Check that renderer factory is a singleton
256 DALI_TEST_CHECK(factory == newFactory);
261 int UtcDaliVisualFactoryCopyAndAssignment(void)
263 ToolkitTestApplication application;
264 tet_infoline( "UtcDaliVisualFactoryCopyAndAssignment" );
265 VisualFactory factory = VisualFactory::Get();
267 VisualFactory factoryCopy( factory );
268 DALI_TEST_CHECK(factory == factoryCopy);
270 VisualFactory emptyFactory;
271 VisualFactory emptyFactoryCopy( emptyFactory );
272 DALI_TEST_CHECK(emptyFactory == emptyFactoryCopy);
274 VisualFactory factoryEquals;
275 factoryEquals = factory;
276 DALI_TEST_CHECK(factory == factoryEquals);
278 VisualFactory emptyFactoryEquals;
279 emptyFactoryEquals = emptyFactory;
280 DALI_TEST_CHECK( emptyFactory == emptyFactoryEquals );
284 DALI_TEST_CHECK( factory = factoryCopy );
289 int UtcDaliVisualFactoryGetColorVisual1(void)
291 ToolkitTestApplication application;
292 tet_infoline( "UtcDaliVisualFactoryGetColorVisual1: Request color visual with a Property::Map" );
294 VisualFactory factory = VisualFactory::Get();
295 DALI_TEST_CHECK( factory );
297 Property::Map propertyMap;
298 Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
299 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
300 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, testColor);
302 Visual::Base visual = factory.CreateVisual(propertyMap);
303 DALI_TEST_CHECK( visual );
305 Actor actor = Actor::New();
306 TestVisualRender( application, actor, visual );
308 Vector4 actualValue(Vector4::ZERO);
309 TestGlAbstraction& gl = application.GetGlAbstraction();
310 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "mixColor", actualValue ) );
311 DALI_TEST_EQUALS( actualValue, testColor, TEST_LOCATION );
316 int UtcDaliVisualFactoryGetColorVisual2(void)
318 ToolkitTestApplication application;
319 tet_infoline( "UtcDaliVisualFactoryGetColorVisual2: Request color visual with a Vector4" );
321 VisualFactory factory = VisualFactory::Get();
322 DALI_TEST_CHECK( factory );
324 Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
325 Dali::Property::Map map;
326 map[ Visual::Property::TYPE ] = Visual::COLOR;
327 map[ ColorVisual::Property::MIX_COLOR ] = testColor;
328 Visual::Base visual = factory.CreateVisual( map );
329 DALI_TEST_CHECK( visual );
331 Actor actor = Actor::New();
332 TestVisualRender( application, actor, visual );
334 Vector4 actualValue(Vector4::ZERO);
335 TestGlAbstraction& gl = application.GetGlAbstraction();
336 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "mixColor", actualValue ) );
337 DALI_TEST_EQUALS( actualValue, testColor, TEST_LOCATION );
339 visual.SetOffStage( actor );
340 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
345 int UtcDaliVisualFactoryGetBorderVisual1(void)
347 ToolkitTestApplication application;
348 tet_infoline( "UtcDaliVisualFactoryGetBorderVisual1: Request border visual with a Property::Map" );
350 VisualFactory factory = VisualFactory::Get();
351 DALI_TEST_CHECK( factory );
353 Property::Map propertyMap;
354 Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
355 float testSize = 5.f;
356 propertyMap.Insert(Visual::Property::TYPE, Visual::BORDER);
357 propertyMap.Insert(BorderVisual::Property::COLOR, testColor);
358 propertyMap.Insert(BorderVisual::Property::SIZE, testSize);
360 Visual::Base visual = factory.CreateVisual(propertyMap);
361 DALI_TEST_CHECK( visual );
363 Actor actor = Actor::New();
364 actor.SetSize(200.f, 200.f);
365 Stage::GetCurrent().Add( actor );
366 visual.SetSize(Vector2(200.f, 200.f));
367 visual.SetOnStage( actor );
369 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
370 int blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLEND_MODE );
371 DALI_TEST_EQUALS( static_cast<BlendMode::Type>(blendMode), BlendMode::ON, TEST_LOCATION );
373 TestGlAbstraction& gl = application.GetGlAbstraction();
375 application.SendNotification();
376 application.Render(0);
378 Vector4 actualColor(Vector4::ZERO);
379 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "borderColor", actualColor ) );
380 DALI_TEST_EQUALS( actualColor, testColor, TEST_LOCATION );
382 float actualSize = 0.f;
383 DALI_TEST_CHECK( gl.GetUniformValue<float>( "borderSize", actualSize ) );
384 DALI_TEST_EQUALS( actualSize, testSize, TEST_LOCATION );
386 visual.SetOffStage( actor );
387 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
392 int UtcDaliVisualFactoryGetBorderVisual2(void)
394 ToolkitTestApplication application;
395 tet_infoline( "UtcDaliVisualFactoryGetBorderVisual2: Request border visual with a borderSize and a borderColor" );
397 VisualFactory factory = VisualFactory::Get();
398 DALI_TEST_CHECK( factory );
400 Vector4 testColor( 1.f, 0.5f, 0.3f, 1.f );
401 float testSize = 5.f;
403 Dali::Property::Map propertyMap;
404 propertyMap[ Visual::Property::TYPE ] = Visual::BORDER;
405 propertyMap[ BorderVisual::Property::COLOR ] = testColor;
406 propertyMap[ BorderVisual::Property::SIZE ] = testSize;
407 Visual::Base visual = factory.CreateVisual( propertyMap );
408 DALI_TEST_CHECK( visual );
410 Actor actor = Actor::New();
411 actor.SetSize(200.f, 200.f);
412 Stage::GetCurrent().Add( actor );
413 visual.SetSize(Vector2(200.f, 200.f));
414 visual.SetOnStage( actor );
416 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
418 TestGlAbstraction& gl = application.GetGlAbstraction();
420 application.SendNotification();
421 application.Render(0);
423 int blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLEND_MODE );
424 DALI_TEST_EQUALS( static_cast<BlendMode::Type>(blendMode), BlendMode::AUTO, TEST_LOCATION );
426 Vector4 actualColor(Vector4::ZERO);
427 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "borderColor", actualColor ) );
428 DALI_TEST_EQUALS( actualColor, testColor, TEST_LOCATION );
430 float actualSize = 0.f;
431 DALI_TEST_CHECK( gl.GetUniformValue<float>( "borderSize", actualSize ) );
432 DALI_TEST_EQUALS( actualSize, testSize, TEST_LOCATION );
434 visual.SetOffStage( actor );
436 // enable the anti-aliasing
437 Dali::Property::Map map;
438 map[ Visual::Property::TYPE ] = Visual::BORDER;
439 map[ BorderVisual::Property::COLOR ] = testColor;
440 map[ BorderVisual::Property::SIZE ] = testSize;
441 map[ BorderVisual::Property::ANTI_ALIASING ] = true;
442 visual = factory.CreateVisual( map );
443 visual.SetOnStage( actor );
445 application.SendNotification();
446 application.Render(0);
447 blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLEND_MODE );
448 DALI_TEST_EQUALS( static_cast<BlendMode::Type>(blendMode), BlendMode::ON, TEST_LOCATION );
453 int UtcDaliVisualFactoryGetLinearGradientVisual(void)
455 ToolkitTestApplication application;
456 tet_infoline("UtcDaliVisualFactoryGetRadialGradientVisual");
458 VisualFactory factory = VisualFactory::Get();
459 DALI_TEST_CHECK( factory );
461 Property::Map propertyMap;
462 propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
464 Vector2 start(-1.f, -1.f);
465 Vector2 end(1.f, 1.f);
466 propertyMap.Insert(GradientVisual::Property::START_POSITION, start);
467 propertyMap.Insert(GradientVisual::Property::END_POSITION, end);
468 propertyMap.Insert(GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT);
470 Property::Array stopOffsets;
471 stopOffsets.PushBack( 0.2f );
472 stopOffsets.PushBack( 0.8f );
473 propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, stopOffsets);
475 Property::Array stopColors;
476 stopColors.PushBack( Color::RED );
477 stopColors.PushBack( Color::GREEN );
478 propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
480 Visual::Base visual = factory.CreateVisual(propertyMap);
481 DALI_TEST_CHECK( visual );
483 // A lookup texture is generated and pass to shader as sampler
484 Actor actor = Actor::New();
485 TestVisualRender( application, actor, visual, 1u );
487 visual.SetOffStage( actor );
488 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
493 int UtcDaliVisualFactoryGetRadialGradientVisual(void)
495 ToolkitTestApplication application;
496 tet_infoline("UtcDaliVisualFactoryGetRadialGradientVisual");
498 VisualFactory factory = VisualFactory::Get();
499 DALI_TEST_CHECK( factory );
501 Property::Map propertyMap;
502 propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
504 Vector2 center(100.f, 100.f);
505 float radius = 100.f;
506 propertyMap.Insert(GradientVisual::Property::UNITS, GradientVisual::Units::USER_SPACE);
507 propertyMap.Insert(GradientVisual::Property::CENTER, center);
508 propertyMap.Insert(GradientVisual::Property::RADIUS, radius);
510 Property::Array stopOffsets;
511 stopOffsets.PushBack( 0.0f );
512 stopOffsets.PushBack( 1.f );
513 propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, stopOffsets);
515 Property::Array stopColors;
516 stopColors.PushBack( Color::RED );
517 stopColors.PushBack( Color::GREEN );
518 propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
520 Visual::Base visual = factory.CreateVisual(propertyMap);
521 DALI_TEST_CHECK( visual );
523 // A lookup texture is generated and pass to shader as sampler
524 Actor actor = Actor::New();
525 TestVisualRender( application, actor, visual, 1u );
527 Matrix3 alignMatrix( radius, 0.f, 0.f, 0.f, radius, 0.f, center.x, center.y, 1.f );
528 alignMatrix.Invert();
530 Matrix3 actualValue( Matrix3::IDENTITY );
531 TestGlAbstraction& gl = application.GetGlAbstraction();
532 DALI_TEST_CHECK( gl.GetUniformValue<Matrix3>( "uAlignmentMatrix", actualValue ) );
533 DALI_TEST_EQUALS( actualValue, alignMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
538 int UtcDaliVisualFactoryDefaultOffsetsGradientVisual(void)
540 ToolkitTestApplication application;
541 tet_infoline("UtcDaliVisualFactoryGetRadialGradientVisual");
543 VisualFactory factory = VisualFactory::Get();
544 DALI_TEST_CHECK( factory );
546 Property::Map propertyMap;
547 propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
549 Vector2 start(-1.f, -1.f);
550 Vector2 end(1.f, 1.f);
551 propertyMap.Insert(GradientVisual::Property::START_POSITION, start);
552 propertyMap.Insert(GradientVisual::Property::END_POSITION, end);
553 propertyMap.Insert(GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT);
555 Property::Array stopColors;
556 stopColors.PushBack( Color::RED );
557 stopColors.PushBack( Color::GREEN );
558 propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
560 Visual::Base visual = factory.CreateVisual(propertyMap);
561 DALI_TEST_CHECK( visual );
563 // A lookup texture is generated and pass to shader as sampler
564 Actor actor = Actor::New();
565 TestVisualRender( application, actor, visual, 1u );
567 visual.SetOffStage( actor );
568 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
573 int UtcDaliVisualFactoryGetImageVisual1(void)
575 ToolkitTestApplication application;
576 tet_infoline( "UtcDaliVisualFactoryGetImageVisual1: Request image renderer with a Property::Map" );
578 VisualFactory factory = VisualFactory::Get();
579 DALI_TEST_CHECK( factory );
581 Property::Map propertyMap;
582 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
583 propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
585 Visual::Base visual = factory.CreateVisual( propertyMap );
586 DALI_TEST_CHECK( visual );
588 Actor actor = Actor::New();
589 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
590 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
593 const int height=513;
594 TestGlAbstraction& gl = application.GetGlAbstraction();
595 TraceCallStack& textureTrace = gl.GetTextureTrace();
596 textureTrace.Enable(true);
598 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
599 bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, width, height,width, height );
601 TestVisualRender( application, actor, visual, 1u,
602 ImageDimensions(width, height),
603 Integration::ResourcePointer( bitmap ) );
605 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
607 visual.SetOffStage( actor );
608 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
613 int UtcDaliVisualFactoryGetImageVisual2(void)
615 ToolkitTestApplication application;
616 tet_infoline( "UtcDaliVisualFactoryGetImageVisual2: Request image renderer with an image handle" );
618 VisualFactory factory = VisualFactory::Get();
619 DALI_TEST_CHECK( factory );
621 Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME);
622 Visual::Base visual = factory.CreateVisual( image );
624 Actor actor = Actor::New();
625 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
626 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
629 const int height=513;
631 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
632 bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, width, height,width, height );
634 TestGlAbstraction& gl = application.GetGlAbstraction();
635 TraceCallStack& textureTrace = gl.GetTextureTrace();
636 textureTrace.Enable(true);
638 TestVisualRender( application, actor, visual, 1u,
639 ImageDimensions(width, height),
640 Integration::ResourcePointer(bitmap) );
642 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
647 int UtcDaliVisualFactoryGetNPatchVisual1(void)
649 ToolkitTestApplication application;
650 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual1: Request 9-patch renderer with a Property::Map" );
652 VisualFactory factory = VisualFactory::Get();
653 DALI_TEST_CHECK( factory );
655 const unsigned int ninePatchImageHeight = 18;
656 const unsigned int ninePatchImageWidth = 28;
657 StretchRanges stretchRangesX;
658 stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
659 StretchRanges stretchRangesY;
660 stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
661 Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
663 Property::Map propertyMap;
664 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
665 propertyMap.Insert( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME );
667 tet_infoline( "whole grid" );
668 Visual::Base visual = factory.CreateVisual( propertyMap );
669 DALI_TEST_CHECK( visual );
671 Actor actor = Actor::New();
673 TestGlAbstraction& gl = application.GetGlAbstraction();
674 TraceCallStack& textureTrace = gl.GetTextureTrace();
675 textureTrace.Enable(true);
677 TestVisualRender( application, actor, visual, 1u,
678 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
681 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
684 propertyMap.Insert( ImageVisual::Property::BORDER_ONLY, true );
686 tet_infoline( "border only" );
687 Visual::Base visual = factory.CreateVisual( propertyMap );
688 DALI_TEST_CHECK( visual );
690 Actor actor = Actor::New();
692 TestGlAbstraction& gl = application.GetGlAbstraction();
693 TraceCallStack& textureTrace = gl.GetTextureTrace();
694 textureTrace.Enable(true);
696 TestVisualRender( application, actor, visual, 1u,
697 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
700 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
706 int UtcDaliVisualFactoryGetNPatchVisual2(void)
708 ToolkitTestApplication application;
709 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual2: Request n-patch renderer with a Property::Map" );
711 VisualFactory factory = VisualFactory::Get();
712 DALI_TEST_CHECK( factory );
714 const unsigned int ninePatchImageWidth = 18;
715 const unsigned int ninePatchImageHeight = 28;
716 StretchRanges stretchRangesX;
717 stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
718 stretchRangesX.PushBack( Uint16Pair( 5, 7 ) );
719 stretchRangesX.PushBack( Uint16Pair( 12, 15 ) );
720 StretchRanges stretchRangesY;
721 stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
722 stretchRangesY.PushBack( Uint16Pair( 8, 12 ) );
723 stretchRangesY.PushBack( Uint16Pair( 15, 16 ) );
724 stretchRangesY.PushBack( Uint16Pair( 25, 27 ) );
725 Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
727 Property::Map propertyMap;
728 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
729 propertyMap.Insert( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME );
731 Visual::Base visual = factory.CreateVisual( propertyMap );
732 DALI_TEST_CHECK( visual );
734 Actor actor = Actor::New();
735 TestGlAbstraction& gl = application.GetGlAbstraction();
736 TraceCallStack& textureTrace = gl.GetTextureTrace();
737 textureTrace.Enable(true);
739 TestVisualRender( application, actor, visual, 1u,
740 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
744 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
746 visual.SetOffStage( actor );
747 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
750 propertyMap.Insert( ImageVisual::Property::BORDER_ONLY, true );
752 tet_infoline( "border only" );
753 Visual::Base visual = factory.CreateVisual( propertyMap );
754 DALI_TEST_CHECK( visual );
756 TestGlAbstraction& gl = application.GetGlAbstraction();
757 TraceCallStack& textureTrace = gl.GetTextureTrace();
758 textureTrace.Enable(true);
759 Actor actor = Actor::New();
760 TestVisualRender( application, actor, visual, 1u,
761 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
765 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
767 visual.SetOffStage( actor );
768 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
774 int UtcDaliVisualFactoryGetNPatchVisual3(void)
776 ToolkitTestApplication application;
777 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual3: Request 9-patch renderer with an image url" );
779 VisualFactory factory = VisualFactory::Get();
780 DALI_TEST_CHECK( factory );
782 const unsigned int ninePatchImageHeight = 18;
783 const unsigned int ninePatchImageWidth = 28;
784 StretchRanges stretchRangesX;
785 stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
786 StretchRanges stretchRangesY;
787 stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
788 Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
790 Visual::Base visual = factory.CreateVisual( TEST_NPATCH_FILE_NAME, ImageDimensions() );
791 DALI_TEST_CHECK( visual );
793 Actor actor = Actor::New();
795 TestGlAbstraction& gl = application.GetGlAbstraction();
796 TraceCallStack& textureTrace = gl.GetTextureTrace();
797 textureTrace.Enable(true);
799 TestVisualRender( application, actor, visual, 1u,
800 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
803 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
808 int UtcDaliVisualFactoryGetNPatchVisual4(void)
810 ToolkitTestApplication application;
811 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual4: Request n-patch visual with an image url" );
813 VisualFactory factory = VisualFactory::Get();
814 DALI_TEST_CHECK( factory );
816 const unsigned int ninePatchImageHeight = 18;
817 const unsigned int ninePatchImageWidth = 28;
818 StretchRanges stretchRangesX;
819 stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
820 stretchRangesX.PushBack( Uint16Pair( 5, 7 ) );
821 stretchRangesX.PushBack( Uint16Pair( 12, 15 ) );
822 StretchRanges stretchRangesY;
823 stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
824 stretchRangesY.PushBack( Uint16Pair( 8, 12 ) );
825 stretchRangesY.PushBack( Uint16Pair( 15, 16 ) );
826 stretchRangesY.PushBack( Uint16Pair( 25, 27 ) );
827 Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
829 Visual::Base visual = factory.CreateVisual( TEST_NPATCH_FILE_NAME, ImageDimensions() );
830 DALI_TEST_CHECK( visual );
832 Actor actor = Actor::New();
834 TestGlAbstraction& gl = application.GetGlAbstraction();
835 TraceCallStack& textureTrace = gl.GetTextureTrace();
836 textureTrace.Enable(true);
838 TestVisualRender( application, actor, visual, 1u,
839 ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
842 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
847 int UtcDaliVisualFactoryGetNPatchVisualN1(void)
849 //This should still load but display an error image
851 ToolkitTestApplication application;
852 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid image url" );
854 VisualFactory factory = VisualFactory::Get();
855 DALI_TEST_CHECK( factory );
857 Visual::Base visual = factory.CreateVisual( "ERROR.9.jpg", ImageDimensions() );
858 DALI_TEST_CHECK( visual );
860 Actor actor = Actor::New();
862 //The testkit still has to load a bitmap for the broken renderer image
863 Integration::Bitmap* bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
864 bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 100, 100, 100, 100 );
866 TestGlAbstraction& gl = application.GetGlAbstraction();
867 TraceCallStack& textureTrace = gl.GetTextureTrace();
868 textureTrace.Enable(true);
870 TestVisualRender( application, actor, visual, 1u,
872 Integration::ResourcePointer(bitmap) );
874 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
879 int UtcDaliVisualFactoryGetNPatchVisualN2(void)
881 //This should still load but display an error image
883 ToolkitTestApplication application;
884 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid URL" );
886 VisualFactory factory = VisualFactory::Get();
887 DALI_TEST_CHECK( factory );
889 Property::Map propertyMap;
890 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
891 propertyMap.Insert( ImageVisual::Property::URL, "ERROR.9.jpg" );
893 Visual::Base visual = factory.CreateVisual( propertyMap );
894 DALI_TEST_CHECK( visual );
896 Actor actor = Actor::New();
898 //The testkit still has to load a bitmap for the broken renderer image
899 Integration::Bitmap* bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
900 bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 100, 100, 100, 100 );
902 TestGlAbstraction& gl = application.GetGlAbstraction();
903 TraceCallStack& textureTrace = gl.GetTextureTrace();
904 textureTrace.Enable(true);
906 TestVisualRender( application, actor, visual, 1u,
908 Integration::ResourcePointer(bitmap) );
910 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
915 int UtcDaliVisualFactoryGetNPatchVisualN3(void)
917 // Passing in an invalid visual type so we should not get a visual
919 ToolkitTestApplication application;
920 tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid visual type" );
922 VisualFactory factory = VisualFactory::Get();
923 DALI_TEST_CHECK( factory );
925 Property::Map propertyMap;
926 propertyMap.Insert( Visual::Property::TYPE, 111 );
927 propertyMap.Insert( ImageVisual::Property::URL, "ERROR.9.jpg" );
929 Visual::Base visual = factory.CreateVisual( propertyMap );
930 DALI_TEST_CHECK( !visual );
935 int UtcDaliVisualFactoryGetSvgVisual(void)
937 ToolkitTestApplication application;
938 tet_infoline( "UtcDaliVisualFactoryGetSvgVisual: Request svg visual with a svg url" );
940 VisualFactory factory = VisualFactory::Get();
941 Visual::Base visual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions() );
942 DALI_TEST_CHECK( visual );
944 TestGlAbstraction& gl = application.GetGlAbstraction();
945 TraceCallStack& textureTrace = gl.GetTextureTrace();
946 textureTrace.Enable(true);
948 Actor actor = Actor::New();
949 actor.SetSize( 200.f, 200.f );
950 Stage::GetCurrent().Add( actor );
951 visual.SetSize( Vector2(200.f, 200.f) );
952 visual.SetOnStage( actor );
953 application.SendNotification();
954 application.Render();
956 // renderer is not added to actor until the rasterization is completed.
957 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
959 EventThreadCallback* eventTrigger = EventThreadCallback::Get();
960 CallbackBase* callback = eventTrigger->GetCallback();
962 eventTrigger->WaitingForTrigger( 1 );// waiting until the svg image is rasterized.
963 CallbackBase::Execute( *callback );
965 // renderer is added to actor
966 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
968 // waiting for the resource uploading
969 application.SendNotification();
970 application.Render();
972 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
977 //Creates a mesh renderer from the given propertyMap and tries to load it on stage in the given application.
978 //This is expected to succeed, which will then pass the test.
979 void MeshVisualLoadsCorrectlyTest( Property::Map& propertyMap, ToolkitTestApplication& application )
981 VisualFactory factory = VisualFactory::Get();
982 DALI_TEST_CHECK( factory );
984 //Create a mesh visual.
985 Visual::Base visual = factory.CreateVisual( propertyMap );
986 DALI_TEST_CHECK( visual );
988 //Create an actor on stage to house the visual.
989 Actor actor = Actor::New();
990 actor.SetSize( 200.f, 200.f );
991 Stage::GetCurrent().Add( actor );
992 visual.SetSize( Vector2( 200.f, 200.f ) );
993 visual.SetOnStage( actor );
995 //Ensure set on stage.
996 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
998 //Attempt to render to queue resource load requests.
999 application.SendNotification();
1000 application.Render( 0 );
1002 //Tell the platform abstraction that the required resources have been loaded.
1003 TestPlatformAbstraction& platform = application.GetPlatform();
1004 platform.SetAllResourceRequestsAsLoaded();
1006 //Render again to upload the now-loaded textures.
1007 application.SendNotification();
1008 application.Render( 0 );
1010 Matrix testScaleMatrix;
1011 testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
1012 Matrix actualScaleMatrix;
1014 //Test to see if the object has been successfully loaded.
1015 DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
1016 DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1018 //Finish by setting off stage, and ensuring this was successful.
1019 visual.SetOffStage( actor );
1020 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1023 //Creates a mesh visual from the given propertyMap and tries to load it on stage in the given application.
1024 //This is expected to fail, which will then pass the test.
1025 void MeshVisualDoesNotLoadCorrectlyTest( Property::Map& propertyMap, ToolkitTestApplication& application )
1027 VisualFactory factory = VisualFactory::Get();
1028 DALI_TEST_CHECK( factory );
1030 //Create a mesh visual.
1031 Visual::Base visual = factory.CreateVisual( propertyMap );
1032 DALI_TEST_CHECK( visual );
1034 //Create an actor on stage to house the visual.
1035 Actor actor = Actor::New();
1036 actor.SetSize( 200.f, 200.f );
1037 Stage::GetCurrent().Add( actor );
1038 visual.SetSize( Vector2( 200.f, 200.f ) );
1039 visual.SetOnStage( actor );
1041 //Ensure set on stage.
1042 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1044 //Attempt to render to queue resource load requests.
1045 application.SendNotification();
1046 application.Render( 0 );
1048 //Tell the platform abstraction that the required resources have been loaded.
1049 TestPlatformAbstraction& platform = application.GetPlatform();
1050 platform.SetAllResourceRequestsAsLoaded();
1052 //Render again to upload the now-loaded textures.
1053 application.SendNotification();
1054 application.Render( 0 );
1056 //Test to see if the object has not been loaded, as expected.
1058 DALI_TEST_CHECK( !application.GetGlAbstraction().GetUniformValue<Matrix>( "uObjectMatrix", scaleMatrix ) );
1060 //Finish by setting off stage, and ensuring this was successful.
1061 visual.SetOffStage( actor );
1062 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1065 //Test if mesh loads correctly when supplied with only the bare minimum requirements, an object file.
1066 int UtcDaliVisualFactoryGetMeshVisual1(void)
1068 //Set up test application first, so everything else can be handled.
1069 ToolkitTestApplication application;
1071 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual1: Request mesh visual with a valid object file only" );
1074 //Set up visual properties.
1075 Property::Map propertyMap;
1076 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1077 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1079 //Test to see if mesh loads correctly.
1080 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1086 //Test if mesh loads correctly when supplied with an object file as well as a blank material file and images directory.
1087 int UtcDaliVisualFactoryGetMeshVisual2(void)
1089 //Set up test application first, so everything else can be handled.
1090 ToolkitTestApplication application;
1092 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual2: Request mesh visual with blank material file and images directory" );
1094 //Set up visual properties.
1095 Property::Map propertyMap;
1096 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1097 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1098 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, "" );
1099 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, "" );
1101 //Test to see if mesh loads correctly.
1102 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1107 //Test if mesh loads correctly when supplied with all main parameters, an object file, a material file and a directory location.
1108 int UtcDaliVisualFactoryGetMeshVisual3(void)
1110 //Set up test application first, so everything else can be handled.
1111 ToolkitTestApplication application;
1113 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual3: Request mesh visual with all parameters correct" );
1115 //Set up visual properties.
1116 Property::Map propertyMap;
1117 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1118 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1119 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1120 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1122 //Test to see if mesh loads correctly.
1123 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1128 //Test if mesh visual can load a correctly supplied mesh without a normal map or gloss map in the material file.
1129 int UtcDaliVisualFactoryGetMeshVisual4(void)
1131 //Set up test application first, so everything else can be handled.
1132 ToolkitTestApplication application;
1134 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual4: Request mesh visual with diffuse texture but not normal or gloss." );
1137 //Set up visual properties.
1138 Property::Map propertyMap;
1139 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1140 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1141 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_SIMPLE_MTL_FILE_NAME );
1142 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1144 //Test to see if mesh loads correctly.
1145 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1151 //Test if mesh visual can load when made to use diffuse textures only.
1152 int UtcDaliVisualFactoryGetMeshVisual5(void)
1154 //Set up test application first, so everything else can be handled.
1155 ToolkitTestApplication application;
1157 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual5: Request mesh visual and make it only use diffuse textures." );
1159 //Set up visual properties.
1160 Property::Map propertyMap;
1161 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1162 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1163 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1164 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1165 propertyMap.Insert( MeshVisual::Property::SHADING_MODE, MeshVisual::ShadingMode::TEXTURED_WITH_SPECULAR_LIGHTING );
1167 //Test to see if mesh loads correctly.
1168 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1174 //Test if mesh visual can load when made to not use the supplied textures.
1175 int UtcDaliVisualFactoryGetMeshVisual6(void)
1177 //Set up test application first, so everything else can be handled.
1178 ToolkitTestApplication application;
1180 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual6: Request mesh visual and make it not use any textures." );
1182 //Set up visual properties.
1183 Property::Map propertyMap;
1184 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1185 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1186 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1187 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1188 propertyMap.Insert( MeshVisual::Property::SHADING_MODE, MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING );
1190 //Test to see if mesh loads correctly.
1191 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1195 //Test if mesh visual loads correctly when light position is manually set.
1196 int UtcDaliVisualFactoryGetMeshVisual7(void)
1198 //Set up test application first, so everything else can be handled.
1199 ToolkitTestApplication application;
1202 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual7: Request mesh visual with custom light position." );
1204 //Set up visual properties.
1205 Property::Map propertyMap;
1206 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1207 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1208 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1209 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1210 propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.0, 1.0, 2.0 ) );
1212 //Test to see if mesh loads correctly.
1213 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1218 //Test if mesh visual loads correctly when supplied an object file without face normals or texture points.
1219 //Note that this notably tests object loader functionality.
1220 int UtcDaliVisualFactoryGetMeshVisual8(void)
1222 //Set up test application first, so everything else can be handled.
1223 ToolkitTestApplication application;
1225 tet_infoline( "UtcDaliVisualFactoryGetMeshVisual5: Request mesh visual with normal-less object file." );
1227 //Set up visual properties.
1228 Property::Map propertyMap;
1229 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1230 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_SIMPLE_OBJ_FILE_NAME );
1231 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1232 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1234 //Test to see if mesh loads correctly.
1235 MeshVisualLoadsCorrectlyTest( propertyMap, application );
1240 //Test if mesh visual handles the case of lacking an object file.
1241 int UtcDaliVisualFactoryGetMeshVisualN1(void)
1243 //Set up test application first, so everything else can be handled.
1244 ToolkitTestApplication application;
1246 tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN1: Request mesh visual without object file" );
1248 //Set up visual properties.
1249 Property::Map propertyMap;
1250 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1251 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1252 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1254 //Test to see if mesh doesn't load with these properties, as expected.
1255 MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
1261 //Test if mesh visual handles the case of being passed invalid material and images urls.
1262 int UtcDaliVisualFactoryGetMeshVisualN2(void)
1264 //Set up test application first, so everything else can be handled.
1265 ToolkitTestApplication application;
1267 tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN2: Request mesh visual with invalid material and images urls" );
1269 //Set up visual properties.
1270 Property::Map propertyMap;
1271 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1272 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
1273 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, "invalid" );
1274 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, "also invalid" );
1276 //Test to see if mesh doesn't load with these properties, as expected.
1277 MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
1283 //Test if mesh visual handles the case of being passed an invalid object url
1284 int UtcDaliVisualFactoryGetMeshVisualN3(void)
1286 //Set up test application first, so everything else can be handled.
1287 ToolkitTestApplication application;
1288 tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN3: Request mesh visual with invalid object url" );
1291 //Set up visual properties.
1292 Property::Map propertyMap;
1293 propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
1294 propertyMap.Insert( MeshVisual::Property::OBJECT_URL, "invalid" );
1295 propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
1296 propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
1298 //Test to see if mesh doesn't load with these properties, as expected.
1299 MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
1304 //Creates a primitive visual with the given property map and tests to see if it correctly loads in the given application.
1305 void TestPrimitiveVisualWithProperties( Property::Map& propertyMap, ToolkitTestApplication& application )
1307 VisualFactory factory = VisualFactory::Get();
1308 DALI_TEST_CHECK( factory );
1310 //Create a primitive visual.
1311 Visual::Base visual = factory.CreateVisual( propertyMap );
1312 DALI_TEST_CHECK( visual );
1314 //Create an actor on stage to house the visual.
1315 Actor actor = Actor::New();
1316 actor.SetSize( 200.f, 200.f );
1317 Stage::GetCurrent().Add( actor );
1318 visual.SetSize( Vector2( 200.f, 200.f ) );
1319 visual.SetOnStage( actor );
1321 //Ensure set on stage.
1322 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1324 //Tell test application to load the visual.
1325 application.SendNotification();
1326 application.Render(0);
1328 Matrix testScaleMatrix;
1329 testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
1330 Matrix actualScaleMatrix;
1332 //Test to see if the object has been successfully loaded.
1333 DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
1334 DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
1336 //Finish by setting off stage, and ensuring this was successful.
1337 visual.SetOffStage( actor );
1338 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1341 //Test if primitive shape loads correctly when supplied with only the bare minimum requirements, the shape to use.
1342 int UtcDaliVisualFactoryGetPrimitiveVisual1(void)
1344 //Set up test application first, so everything else can be handled.
1345 ToolkitTestApplication application;
1347 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual1: Request primitive visual with a shape only" );
1349 //Set up visual properties.
1350 Property::Map propertyMap;
1351 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1352 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
1354 //Test to see if shape loads correctly.
1355 TestPrimitiveVisualWithProperties( propertyMap, application );
1360 //Test if primitive shape loads correctly when supplied with all possible parameters
1361 int UtcDaliVisualFactoryGetPrimitiveVisual2(void)
1363 //Set up test application first, so everything else can be handled.
1364 ToolkitTestApplication application;
1366 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual2: Request primitive visual with everything" );
1368 //Set up visual properties.
1369 Property::Map propertyMap;
1370 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1371 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
1372 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1373 propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1374 propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
1375 propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
1376 propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f );
1377 propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
1378 propertyMap.Insert( PrimitiveVisual::Property::SCALE_RADIUS, 60.0f );
1379 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.7f );
1380 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, 0.8f );
1381 propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.9, 1.0, 1.1 ) );
1383 //Test to see if shape loads correctly.
1384 TestPrimitiveVisualWithProperties( propertyMap, application );
1389 //Test if primitive shape loads a sphere correctly.
1390 int UtcDaliVisualFactoryGetPrimitiveVisual3(void)
1392 //Set up test application first, so everything else can be handled.
1393 ToolkitTestApplication application;
1395 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual3: Request primitive visual to display a sphere" );
1397 //Set up visual properties.
1398 Property::Map propertyMap;
1399 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1400 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1401 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1402 propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1403 propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
1405 //Test to see if shape loads correctly.
1406 TestPrimitiveVisualWithProperties( propertyMap, application );
1411 //Test if primitive shape loads a conic section correctly.
1412 int UtcDaliVisualFactoryGetPrimitiveVisual4(void)
1414 //Set up test application first, so everything else can be handled.
1415 ToolkitTestApplication application;
1417 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual4: Request primitive visual to display a conic section" );
1419 //Set up visual properties.
1420 Property::Map propertyMap;
1421 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1422 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONICAL_FRUSTRUM );
1423 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1424 propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1425 propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
1426 propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f );
1427 propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
1429 //Test to see if shape loads correctly.
1430 TestPrimitiveVisualWithProperties( propertyMap, application );
1435 //Test if primitive shape loads a bevelled cube correctly.
1436 int UtcDaliVisualFactoryGetPrimitiveVisual5(void)
1438 //Set up test application first, so everything else can be handled.
1439 ToolkitTestApplication application;
1441 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual5: Request primitive visual to display a bevelled cube" );
1443 //Set up visual properties.
1444 Property::Map propertyMap;
1445 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1446 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::BEVELLED_CUBE );
1447 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1448 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.7f );
1450 //Test to see if shape loads correctly.
1451 TestPrimitiveVisualWithProperties( propertyMap, application );
1456 //Test if primitive shape loads an octahedron correctly.
1457 int UtcDaliVisualFactoryGetPrimitiveVisual6(void)
1459 //Set up test application first, so everything else can be handled.
1460 ToolkitTestApplication application;
1462 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual6: Request primitive visual to display an octahedron" );
1464 //Set up visual properties.
1465 Property::Map propertyMap;
1466 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1467 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::OCTAHEDRON );
1468 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1470 //Test to see if shape loads correctly.
1471 TestPrimitiveVisualWithProperties( propertyMap, application );
1476 //Test if primitive shape loads a cone correctly.
1477 int UtcDaliVisualFactoryGetPrimitiveVisual7(void)
1479 //Set up test application first, so everything else can be handled.
1480 ToolkitTestApplication application;
1482 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual7: Request primitive visual to display a cone" );
1484 //Set up visual properties.
1485 Property::Map propertyMap;
1486 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1487 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONE );
1488 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1489 propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
1490 propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
1491 propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
1493 //Test to see if shape loads correctly.
1494 TestPrimitiveVisualWithProperties( propertyMap, application );
1499 //Test if primitive shape loads correctly when light position is manually set.
1500 int UtcDaliVisualFactoryGetPrimitiveVisual8(void)
1502 //Set up test application first, so everything else can be handled.
1503 ToolkitTestApplication application;
1505 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual8: Request primitive visual with set light position" );
1507 //Set up visual properties.
1508 Property::Map propertyMap;
1509 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1510 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1511 propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
1512 propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.0, 1.0, 2.0 ) );
1514 //Test to see if shape loads correctly.
1515 TestPrimitiveVisualWithProperties( propertyMap, application );
1520 //Test if primitive shape loads correctly when told to use too many slices.
1521 int UtcDaliVisualFactoryGetPrimitiveVisual9(void)
1523 //Set up test application first, so everything else can be handled.
1524 ToolkitTestApplication application;
1526 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual9: Request primitive visual with above-cap slices." );
1528 //Set up visual properties.
1529 Property::Map propertyMap;
1530 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1531 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1532 propertyMap.Insert( PrimitiveVisual::Property::SLICES, Property::Value( 1000000 ) );
1534 //Test to see if shape loads correctly.
1535 TestPrimitiveVisualWithProperties( propertyMap, application );
1540 //Test if primitive shape loads correctly when told to use too few slices. (2 slices or less.)
1541 int UtcDaliVisualFactoryGetPrimitiveVisual10(void)
1543 //Set up test application first, so everything else can be handled.
1544 ToolkitTestApplication application;
1546 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual10: Request primitive visual with too few slices." );
1548 //Set up visual properties.
1549 Property::Map propertyMap;
1550 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1551 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1552 propertyMap.Insert( PrimitiveVisual::Property::SLICES, Property::Value( 2 ) );
1554 //Test to see if shape loads correctly.
1555 TestPrimitiveVisualWithProperties( propertyMap, application );
1560 //Test if primitive shape loads correctly when told to use too many stacks.
1561 int UtcDaliVisualFactoryGetPrimitiveVisual11(void)
1563 //Set up test application first, so everything else can be handled.
1564 ToolkitTestApplication application;
1566 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual11: Request primitive visual with too many stacks." );
1568 //Set up visual properties.
1569 Property::Map propertyMap;
1570 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1571 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1572 propertyMap.Insert( PrimitiveVisual::Property::STACKS, Property::Value( 1000000 ) );
1574 //Test to see if shape loads correctly.
1575 TestPrimitiveVisualWithProperties( propertyMap, application );
1580 //Test if primitive shape loads correctly when told to use too few stacks. (1 stack or less.)
1581 int UtcDaliVisualFactoryGetPrimitiveVisual12(void)
1583 //Set up test application first, so everything else can be handled.
1584 ToolkitTestApplication application;
1586 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual12: Request primitive visual with too few stacks." );
1588 //Set up visual properties.
1589 Property::Map propertyMap;
1590 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1591 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1592 propertyMap.Insert( PrimitiveVisual::Property::STACKS, Property::Value( 1 ) );
1594 //Test to see if shape loads correctly.
1595 TestPrimitiveVisualWithProperties( propertyMap, application );
1600 //Test if primitive shape loads correctly when told to use invalid (zero or negative) dimensions.
1601 int UtcDaliVisualFactoryGetPrimitiveVisual13(void)
1603 //Set up test application first, so everything else can be handled.
1604 ToolkitTestApplication application;
1606 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual13: Request primitive visual with invalid scale dimensions." );
1608 //Set up visual properties.
1609 Property::Map propertyMap;
1610 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1611 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1612 propertyMap.Insert( PrimitiveVisual::Property::SCALE_DIMENSIONS, Vector3::ZERO );
1614 //Test to see if shape loads correctly.
1615 TestPrimitiveVisualWithProperties( propertyMap, application );
1620 //Test if primitive shape loads correctly when told to use too low a bevel percentage.
1621 int UtcDaliVisualFactoryGetPrimitiveVisual14(void)
1623 //Set up test application first, so everything else can be handled.
1624 ToolkitTestApplication application;
1626 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual14: Request primitive visual with too low a bevel percentage." );
1628 //Set up visual properties.
1629 Property::Map propertyMap;
1630 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1631 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1632 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, Property::Value( -1.0f ) );
1634 //Test to see if shape loads correctly.
1635 TestPrimitiveVisualWithProperties( propertyMap, application );
1640 //Test if primitive shape loads correctly when told to use too high a bevel percentage.
1641 int UtcDaliVisualFactoryGetPrimitiveVisual15(void)
1643 //Set up test application first, so everything else can be handled.
1644 ToolkitTestApplication application;
1646 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual15: Request primitive visual with too high a bevel percentage." );
1648 //Set up visual properties.
1649 Property::Map propertyMap;
1650 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1651 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1652 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, Property::Value( 2.0f ) );
1654 //Test to see if shape loads correctly.
1655 TestPrimitiveVisualWithProperties( propertyMap, application );
1660 //Test if primitive shape loads correctly when told to use too low a bevel smoothness.
1661 int UtcDaliVisualFactoryGetPrimitiveVisual16(void)
1663 //Set up test application first, so everything else can be handled.
1664 ToolkitTestApplication application;
1666 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual16: Request primitive visual with too low a bevel smoothness." );
1668 //Set up visual properties.
1669 Property::Map propertyMap;
1670 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1671 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1672 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, Property::Value( -1.0f ) );
1674 //Test to see if shape loads correctly.
1675 TestPrimitiveVisualWithProperties( propertyMap, application );
1680 //Test if primitive shape loads correctly when told to use too high a bevel smoothness.
1681 int UtcDaliVisualFactoryGetPrimitiveVisual17(void)
1683 //Set up test application first, so everything else can be handled.
1684 ToolkitTestApplication application;
1686 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual17: Request primitive visual with too high a bevel smoothness." );
1688 //Set up visual properties.
1689 Property::Map propertyMap;
1690 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1691 propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
1692 propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, Property::Value( 2.0f ) );
1694 //Test to see if shape loads correctly.
1695 TestPrimitiveVisualWithProperties( propertyMap, application );
1700 //Test if primitive shape renderer handles the case of not being passed a specific shape to use.
1701 int UtcDaliVisualFactoryGetPrimitiveVisualN1(void)
1703 //Set up test application first, so everything else can be handled.
1704 ToolkitTestApplication application;
1706 tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisualN1: Request primitive visual without shape" );
1708 //Set up visual properties, without supplying shape.
1709 Property::Map propertyMap;
1710 propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
1712 //Test to see if shape loads regardless of missing input.
1713 TestPrimitiveVisualWithProperties( propertyMap, application );