/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-#include <iostream>
#include <stdlib.h>
-#include <dali-toolkit-test-suite-utils.h>
-#include <toolkit-bitmap-loader.h>
+#include <iostream>
+
#include <toolkit-event-thread-callback.h>
-#include <dali/public-api/rendering/renderer.h>
-#include <dali/public-api/rendering/texture-set.h>
-#include <dali/public-api/rendering/shader.h>
-#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <toolkit-timer.h>
+#include "dummy-control.h"
+
+#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/utility/npatch-utilities.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
+#include <dali-toolkit/internal/visuals/npatch-loader.h>
+#include <dali/devel-api/adaptor-framework/image-loading.h>
+#include <dali/integration-api/debug.h>
+#include <dali/integration-api/adaptor-framework/shader-precompiler.h>
using namespace Dali;
using namespace Dali::Toolkit;
namespace
{
-typedef NinePatchImage::StretchRanges StretchRanges;
+typedef Toolkit::NPatchUtility::StretchRanges StretchRanges;
-const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
-const char* TEST_NPATCH_FILE_NAME = "gallery_image_01.9.png";
-const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
-const char* TEST_OBJ_FILE_NAME = TEST_RESOURCE_DIR "/Cube.obj";
-const char* TEST_MTL_FILE_NAME = TEST_RESOURCE_DIR "/ToyRobot-Metal.mtl";
+const char* TEST_9_PATCH_FILE_NAME = TEST_RESOURCE_DIR "/demo-tile-texture-focused.9.png";
+const char* TEST_NPATCH_FILE_NAME = TEST_RESOURCE_DIR "/heartsframe.9.png";
+const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
+const char* TEST_OBJ_FILE_NAME = TEST_RESOURCE_DIR "/Cube.obj";
+const char* TEST_MTL_FILE_NAME = TEST_RESOURCE_DIR "/ToyRobot-Metal.mtl";
const char* TEST_SIMPLE_OBJ_FILE_NAME = TEST_RESOURCE_DIR "/Cube-Points-Only.obj";
const char* TEST_SIMPLE_MTL_FILE_NAME = TEST_RESOURCE_DIR "/ToyRobot-Metal-Simple.mtl";
+const char* TEST_AUX_IMAGE = TEST_RESOURCE_DIR "/folder_appicon_empty_bg.png";
+const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
+
+// resolution: 50*50, frame count: 4, frame delay: 0.2 second for each frame
+const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
// resolution: 34*34, pixel format: RGBA8888
static const char* gImage_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png";
-// resolution: 600*600, pixel format: RGB888
-static const char* gImage_600_RGB = TEST_RESOURCE_DIR "/test-image-600.jpg";
-
-Integration::Bitmap* CreateBitmap( unsigned int imageWidth, unsigned int imageHeight, unsigned int initialColor, Pixel::Format pixelFormat )
-{
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
- Integration::PixelBuffer* pixbuffer = bitmap->GetPackedPixelsProfile()->ReserveBuffer( pixelFormat, imageWidth, imageHeight, imageWidth, imageHeight );
- unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
-
- memset( pixbuffer, initialColor, imageHeight * imageWidth * bytesPerPixel );
-
- return bitmap;
-}
-
-void InitialiseRegionsToZeroAlpha( Integration::Bitmap* image, unsigned int imageWidth, unsigned int imageHeight, Pixel::Format pixelFormat )
-{
- PixelBuffer* pixbuffer = image->GetBuffer();
- unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
-
- for( unsigned int row = 0; row < imageWidth; ++row )
- {
- unsigned int pixelOffset = row * bytesPerPixel;
- pixbuffer[ pixelOffset + 3 ] = 0x00;
- pixelOffset += ( imageHeight - 1 ) * imageWidth * bytesPerPixel;
- pixbuffer[ pixelOffset + 3 ] = 0x00;
- }
-
- for ( unsigned int column = 0; column < imageHeight; ++column )
- {
- unsigned int pixelOffset = column * imageWidth * bytesPerPixel;
- pixbuffer[ pixelOffset + 3 ] = 0x00;
- pixelOffset += ( imageWidth -1 ) * bytesPerPixel;
- pixbuffer[ pixelOffset + 3 ] = 0x00;
- }
-}
-
-void AddStretchRegionsToImage( Integration::Bitmap* image, unsigned int imageWidth, unsigned int imageHeight, const StretchRanges& stretchRangesX, const StretchRanges& stretchRangesY, Pixel::Format pixelFormat )
-{
- PixelBuffer* pixbuffer = image->GetBuffer();
- unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
-
- for(StretchRanges::ConstIterator it = stretchRangesX.Begin(); it != stretchRangesX.End(); ++it)
- {
- const Uint16Pair& range = *it;
- //since the stretch range is in the cropped image space, we need to offset by 1 to get it to the uncropped image space
- for( unsigned int column = range.GetX() + 1u; column < range.GetY() + 1u; ++column )
- {
- unsigned int pixelOffset = column * bytesPerPixel;
- pixbuffer[ pixelOffset ] = 0x00;
- pixbuffer[ pixelOffset + 1 ] = 0x00;
- pixbuffer[ pixelOffset + 2 ] = 0x00;
- pixbuffer[ pixelOffset + 3 ] = 0xFF;
- }
- }
-
-
- for(StretchRanges::ConstIterator it = stretchRangesY.Begin(); it != stretchRangesY.End(); ++it)
- {
- const Uint16Pair& range = *it;
- //since the stretch range is in the cropped image space, we need to offset by 1 to get it to the uncropped image space
- for( unsigned int row = range.GetX() + 1u; row < range.GetY() + 1u; ++row )
- {
- unsigned int pixelOffset = row * imageWidth * bytesPerPixel;
- pixbuffer[ pixelOffset ] = 0x00;
- pixbuffer[ pixelOffset + 1 ] = 0x00;
- pixbuffer[ pixelOffset + 2 ] = 0x00;
- pixbuffer[ pixelOffset + 3 ] = 0xFF;
- }
- }
-}
-void AddChildRegionsToImage( Integration::Bitmap* image, unsigned int imageWidth, unsigned int imageHeight, const Vector4& requiredChildRegion, Pixel::Format pixelFormat )
+Property::Map DefaultTransform()
{
- PixelBuffer* pixbuffer = image->GetBuffer();
- unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
-
- Integration::Bitmap::PackedPixelsProfile* srcProfile = image->GetPackedPixelsProfile();
- unsigned int bufferStride = srcProfile->GetBufferStride();
-
- // Add bottom child region
- for( unsigned int column = requiredChildRegion.x; column < imageWidth - requiredChildRegion.z; ++column )
- {
- unsigned int pixelOffset = column * bytesPerPixel;
- pixelOffset += ( imageHeight - 1 ) * bufferStride;
- pixbuffer[ pixelOffset ] = 0x00;
- pixbuffer[ pixelOffset + 1 ] = 0x00;
- pixbuffer[ pixelOffset + 2 ] = 0x00;
- pixbuffer[ pixelOffset + 3 ] = 0xFF;
- }
-
- // Add right child region
- for ( unsigned int row = requiredChildRegion.y; row < imageHeight - requiredChildRegion.w; ++row )
- {
- unsigned int pixelOffset = row * bufferStride + ( imageWidth - 1 ) * bytesPerPixel;
- pixbuffer[ pixelOffset ] = 0x00;
- pixbuffer[ pixelOffset + 1 ] = 0x00;
- pixbuffer[ pixelOffset + 2 ] = 0x00;
- pixbuffer[ pixelOffset + 3 ] = 0xFF;
- }
+ Property::Map transformMap;
+ transformMap
+ .Add(Toolkit::Visual::Transform::Property::OFFSET, Vector2(0.0f, 0.0f))
+ .Add(Toolkit::Visual::Transform::Property::SIZE, Vector2(1.0f, 1.0f))
+ .Add(Toolkit::Visual::Transform::Property::ORIGIN, Toolkit::Align::CENTER)
+ .Add(Toolkit::Visual::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER)
+ .Add(Toolkit::Visual::Transform::Property::OFFSET_POLICY, Vector2(Toolkit::Visual::Transform::Policy::RELATIVE, Toolkit::Visual::Transform::Policy::RELATIVE))
+ .Add(Toolkit::Visual::Transform::Property::SIZE_POLICY, Vector2(Toolkit::Visual::Transform::Policy::RELATIVE, Toolkit::Visual::Transform::Policy::RELATIVE));
+ return transformMap;
}
-Integration::ResourcePointer CustomizeNinePatch( TestApplication& application,
- unsigned int ninePatchImageWidth,
- unsigned int ninePatchImageHeight,
- const StretchRanges& stretchRangesX,
- const StretchRanges& stretchRangesY,
- bool addChildRegion = false,
- Vector4 requiredChildRegion = Vector4::ZERO )
+void TestVisualRender(ToolkitTestApplication& application,
+ DummyControl& actor,
+ Visual::Base& visual)
{
- TestPlatformAbstraction& platform = application.GetPlatform();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
- Pixel::Format pixelFormat = Pixel::RGBA8888;
+ actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
- tet_infoline("Create Bitmap");
- platform.SetClosestImageSize(Vector2( ninePatchImageWidth, ninePatchImageHeight));
- Integration::Bitmap* bitmap = CreateBitmap( ninePatchImageWidth, ninePatchImageHeight, 0xFF, pixelFormat );
+ application.GetScene().Add(actor);
- tet_infoline("Clear border regions");
- InitialiseRegionsToZeroAlpha( bitmap, ninePatchImageWidth, ninePatchImageHeight, pixelFormat );
-
- tet_infoline("Add Stretch regions to Bitmap");
- AddStretchRegionsToImage( bitmap, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY, pixelFormat );
-
- if( addChildRegion )
- {
- tet_infoline("Add Child regions to Bitmap");
- AddChildRegionsToImage( bitmap, ninePatchImageWidth, ninePatchImageHeight, requiredChildRegion, pixelFormat );
- }
+ application.SendNotification();
+ application.Render();
- tet_infoline("Getting resource");
- Integration::ResourcePointer resourcePtr(bitmap);
- //platform.SetResourceLoaded( 0, Dali::Integration::ResourceBitmap, resourcePtr );
- platform.SetSynchronouslyLoadedResource( resourcePtr);
+ application.Render();
+ application.SendNotification();
- return resourcePtr;
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
}
-void TestVisualRender( ToolkitTestApplication& application,
- Actor& actor,
- Visual::Base& visual,
- std::size_t expectedSamplers = 0,
- ImageDimensions imageDimensions = ImageDimensions(),
- Integration::ResourcePointer resourcePtr = Integration::ResourcePointer())
+void TestVisualAsynchronousRender(ToolkitTestApplication& application,
+ DummyControl& actor,
+ Visual::Base& visual)
{
- if( resourcePtr )
- {
- // set the image size, for test case, this needs to be set before loading started
- application.GetPlatform().SetClosestImageSize( Vector2(imageDimensions.GetWidth(), imageDimensions.GetHeight()) );
- }
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
- actor.SetSize( 200.f, 200.f );
- Stage::GetCurrent().Add( actor );
- visual.SetSize( Vector2(200.f, 200.f) );
- visual.SetOnStage( actor );
+ actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ application.GetScene().Add(actor);
application.SendNotification();
application.Render();
- if( resourcePtr )
- {
- Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
- if(request)
- {
- application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resourcePtr );
- }
- }
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
- application.Render();
application.SendNotification();
+ application.Render();
- if( resourcePtr )
- {
- DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ||
- application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceSynchronouslyFunc ));
- }
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
+}
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+int gResourceReadySignalCounter;
+void OnResourceReadySignal(Control control)
+{
+ gResourceReadySignalCounter++;
}
} // namespace
-
void dali_visual_factory_startup(void)
{
test_return_value = TET_UNDEF;
int UtcDaliVisualFactoryGet(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactory" );
+ tet_infoline("UtcDaliVisualFactory");
//Register type
TypeInfo type;
- type = TypeRegistry::Get().GetTypeInfo( "VisualFactory" );
- DALI_TEST_CHECK( type );
+ type = TypeRegistry::Get().GetTypeInfo("VisualFactory");
+ DALI_TEST_CHECK(type);
BaseHandle handle = type.CreateInstance();
- DALI_TEST_CHECK( handle );
+ DALI_TEST_CHECK(handle);
VisualFactory factory;
factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
+ DALI_TEST_CHECK(factory);
VisualFactory newFactory = VisualFactory::Get();
- DALI_TEST_CHECK( newFactory );
+ DALI_TEST_CHECK(newFactory);
// Check that visual factory is a singleton
DALI_TEST_CHECK(factory == newFactory);
int UtcDaliVisualFactoryCopyAndAssignment(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryCopyAndAssignment" );
+ tet_infoline("UtcDaliVisualFactoryCopyAndAssignment");
VisualFactory factory = VisualFactory::Get();
- VisualFactory factoryCopy( factory );
+ VisualFactory factoryCopy(factory);
DALI_TEST_CHECK(factory == factoryCopy);
VisualFactory emptyFactory;
- VisualFactory emptyFactoryCopy( emptyFactory );
+ VisualFactory emptyFactoryCopy(emptyFactory);
DALI_TEST_CHECK(emptyFactory == emptyFactoryCopy);
VisualFactory factoryEquals;
VisualFactory emptyFactoryEquals;
emptyFactoryEquals = emptyFactory;
- DALI_TEST_CHECK( emptyFactory == emptyFactoryEquals );
+ DALI_TEST_CHECK(emptyFactory == emptyFactoryEquals);
//self assignment
factory = factory;
- DALI_TEST_CHECK( factory = factoryCopy );
+ DALI_TEST_CHECK(factory = factoryCopy);
END_TEST;
}
int UtcDaliVisualFactoryGetColorVisual1(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetColorVisual1: Request color visual with a Property::Map" );
+ tet_infoline("UtcDaliVisualFactoryGetColorVisual1: Request color visual with a Property::Map");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("mixColor", Property::Type::VECTOR3),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
+ DALI_TEST_CHECK(factory);
Property::Map propertyMap;
- Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
- propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
- propertyMap.Insert(ColorVisual::Property::MIX_COLOR, testColor);
+ Vector4 testColor(1.f, 0.5f, 0.3f, 0.2f);
+ propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
+ propertyMap.Insert(ColorVisual::Property::MIX_COLOR, testColor);
Visual::Base visual = factory.CreateVisual(propertyMap);
- DALI_TEST_CHECK( visual );
+ DALI_TEST_CHECK(visual);
- Actor actor = Actor::New();
- TestVisualRender( application, actor, visual );
+ DummyControl actor = DummyControl::New(true);
+ TestVisualRender(application, actor, visual);
- Vector4 actualValue(Vector4::ZERO);
+ Vector3 actualValue(Vector4::ZERO);
+ Vector4 actualColor(Vector4::ZERO);
TestGlAbstraction& gl = application.GetGlAbstraction();
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "mixColor", actualValue ) );
- DALI_TEST_EQUALS( actualValue, testColor, TEST_LOCATION );
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector3>("mixColor", actualValue));
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uColor", actualColor));
+ DALI_TEST_EQUALS(actualValue, Vector3(testColor), TEST_LOCATION);
+ DALI_TEST_EQUALS(actualColor.a, testColor.a, TEST_LOCATION);
END_TEST;
}
int UtcDaliVisualFactoryGetColorVisual2(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetColorVisual2: Request color visual with a Vector4" );
+ tet_infoline("UtcDaliVisualFactoryGetColorVisual2: Request color visual with a Vector4");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("mixColor", Property::Type::VECTOR3),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
+ DALI_TEST_CHECK(factory);
- Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
+ Vector4 testColor(1.f, 0.5f, 0.3f, 0.2f);
Dali::Property::Map map;
- map[ Visual::Property::TYPE ] = Visual::COLOR;
- map[ ColorVisual::Property::MIX_COLOR ] = testColor;
- Visual::Base visual = factory.CreateVisual( map );
- DALI_TEST_CHECK( visual );
+ map[Toolkit::Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = testColor;
+ Visual::Base visual = factory.CreateVisual(map);
+ DALI_TEST_CHECK(visual);
- Actor actor = Actor::New();
- TestVisualRender( application, actor, visual );
+ DummyControl actor = DummyControl::New(true);
+ TestVisualRender(application, actor, visual);
- Vector4 actualValue(Vector4::ZERO);
+ Vector3 actualValue;
+ Vector4 actualColor;
TestGlAbstraction& gl = application.GetGlAbstraction();
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "mixColor", actualValue ) );
- DALI_TEST_EQUALS( actualValue, testColor, TEST_LOCATION );
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector3>("mixColor", actualValue));
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uColor", actualColor));
+ DALI_TEST_EQUALS(actualValue, Vector3(testColor), TEST_LOCATION);
+ DALI_TEST_EQUALS(actualColor.a, testColor.a, TEST_LOCATION);
- visual.SetOffStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+ application.GetScene().Remove(actor);
+ DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
END_TEST;
}
int UtcDaliVisualFactoryGetBorderVisual1(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetBorderVisual1: Request border visual with a Property::Map" );
+ tet_infoline("UtcDaliVisualFactoryGetBorderVisual1: Request border visual with a Property::Map");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("borderColor", Property::Type::VECTOR4),
+ UniformData("borderSize", Property::Type::FLOAT),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
+ DALI_TEST_CHECK(factory);
Property::Map propertyMap;
- Vector4 testColor( 1.f, 0.5f, 0.3f, 0.2f );
- float testSize = 5.f;
- propertyMap.Insert(Visual::Property::TYPE, Visual::BORDER);
- propertyMap.Insert(BorderVisual::Property::COLOR, testColor);
- propertyMap.Insert(BorderVisual::Property::SIZE, testSize);
+ Vector4 testColor(1.f, 0.5f, 0.3f, 0.2f);
+ float testSize = 5.f;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::BORDER);
+ propertyMap.Insert(BorderVisual::Property::COLOR, testColor);
+ propertyMap.Insert(BorderVisual::Property::SIZE, testSize);
Visual::Base visual = factory.CreateVisual(propertyMap);
- DALI_TEST_CHECK( visual );
+ DALI_TEST_CHECK(visual);
- Actor actor = Actor::New();
- actor.SetSize(200.f, 200.f);
- Stage::GetCurrent().Add( actor );
- visual.SetSize(Vector2(200.f, 200.f));
- visual.SetOnStage( actor );
+ DummyControl actor = DummyControl::New(true);
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+ actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ application.GetScene().Add(actor);
+ visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f));
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
- int blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLEND_MODE );
- DALI_TEST_EQUALS( static_cast<BlendingMode::Type>(blendMode), BlendingMode::ON, TEST_LOCATION );
+ DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
+ int blendMode = actor.GetRendererAt(0u).GetProperty<int>(Renderer::Property::BLEND_MODE);
+ DALI_TEST_EQUALS(static_cast<BlendMode::Type>(blendMode), BlendMode::ON, TEST_LOCATION);
TestGlAbstraction& gl = application.GetGlAbstraction();
application.Render(0);
Vector4 actualColor(Vector4::ZERO);
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "borderColor", actualColor ) );
- DALI_TEST_EQUALS( actualColor, testColor, TEST_LOCATION );
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("borderColor", actualColor));
+ DALI_TEST_EQUALS(actualColor, testColor, TEST_LOCATION);
float actualSize = 0.f;
- DALI_TEST_CHECK( gl.GetUniformValue<float>( "borderSize", actualSize ) );
- DALI_TEST_EQUALS( actualSize, testSize, TEST_LOCATION );
+ DALI_TEST_CHECK(gl.GetUniformValue<float>("borderSize", actualSize));
+ DALI_TEST_EQUALS(actualSize, testSize, TEST_LOCATION);
- visual.SetOffStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+ actor.Unparent();
+ DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
END_TEST;
}
int UtcDaliVisualFactoryGetBorderVisual2(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetBorderVisual2: Request border visual with a borderSize and a borderColor" );
+ tet_infoline("UtcDaliVisualFactoryGetBorderVisual2: Request border visual with a borderSize and a borderColor");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("borderColor", Property::Type::VECTOR4),
+ UniformData("borderSize", Property::Type::FLOAT),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
+ DALI_TEST_CHECK(factory);
- Vector4 testColor( 1.f, 0.5f, 0.3f, 1.f );
- float testSize = 5.f;
+ Vector4 testColor(1.f, 0.5f, 0.3f, 1.f);
+ float testSize = 5.f;
Dali::Property::Map propertyMap;
- propertyMap[ Visual::Property::TYPE ] = Visual::BORDER;
- propertyMap[ BorderVisual::Property::COLOR ] = testColor;
- propertyMap[ BorderVisual::Property::SIZE ] = testSize;
- Visual::Base visual = factory.CreateVisual( propertyMap );
- DALI_TEST_CHECK( visual );
+ propertyMap[Toolkit::Visual::Property::TYPE] = Visual::BORDER;
+ propertyMap[BorderVisual::Property::COLOR] = testColor;
+ propertyMap[BorderVisual::Property::SIZE] = testSize;
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
- Actor actor = Actor::New();
- actor.SetSize(200.f, 200.f);
- Stage::GetCurrent().Add( actor );
- visual.SetSize(Vector2(200.f, 200.f));
- visual.SetOnStage( actor );
+ DummyControl actor = DummyControl::New(true);
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+ actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ application.GetScene().Add(actor);
+ visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f));
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
TestGlAbstraction& gl = application.GetGlAbstraction();
application.SendNotification();
application.Render(0);
- int blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLEND_MODE );
- DALI_TEST_EQUALS( static_cast<BlendingMode::Type>(blendMode), BlendingMode::AUTO, TEST_LOCATION );
+ int blendMode = actor.GetRendererAt(0u).GetProperty<int>(Renderer::Property::BLEND_MODE);
+ DALI_TEST_EQUALS(static_cast<BlendMode::Type>(blendMode), BlendMode::AUTO, TEST_LOCATION);
Vector4 actualColor(Vector4::ZERO);
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "borderColor", actualColor ) );
- DALI_TEST_EQUALS( actualColor, testColor, TEST_LOCATION );
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("borderColor", actualColor));
+ DALI_TEST_EQUALS(actualColor, testColor, TEST_LOCATION);
float actualSize = 0.f;
- DALI_TEST_CHECK( gl.GetUniformValue<float>( "borderSize", actualSize ) );
- DALI_TEST_EQUALS( actualSize, testSize, TEST_LOCATION );
+ DALI_TEST_CHECK(gl.GetUniformValue<float>("borderSize", actualSize));
+ DALI_TEST_EQUALS(actualSize, testSize, TEST_LOCATION);
- visual.SetOffStage( actor );
+ actor.Unparent();
// enable the anti-aliasing
Dali::Property::Map map;
- map[ Visual::Property::TYPE ] = Visual::BORDER;
- map[ BorderVisual::Property::COLOR ] = testColor;
- map[ BorderVisual::Property::SIZE ] = testSize;
- map[ BorderVisual::Property::ANTI_ALIASING ] = true;
- visual = factory.CreateVisual( map );
- visual.SetOnStage( actor );
+ map[Toolkit::Visual::Property::TYPE] = Visual::BORDER;
+ map[BorderVisual::Property::COLOR] = testColor;
+ map[BorderVisual::Property::SIZE] = testSize;
+ map[BorderVisual::Property::ANTI_ALIASING] = true;
+ visual = factory.CreateVisual(map);
- application.SendNotification();
- application.Render(0);
- blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLEND_MODE );
- DALI_TEST_EQUALS( static_cast<BlendingMode::Type>(blendMode), BlendingMode::ON, TEST_LOCATION );
+ dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
+ application.GetScene().Add(actor);
+
+ blendMode = actor.GetRendererAt(0u).GetProperty<int>(Renderer::Property::BLEND_MODE);
+ DALI_TEST_EQUALS(static_cast<BlendMode::Type>(blendMode), BlendMode::ON, TEST_LOCATION);
END_TEST;
}
ToolkitTestApplication application;
tet_infoline("UtcDaliVisualFactoryGetRadialGradientVisual");
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uAlignmentMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
+ DALI_TEST_CHECK(factory);
Property::Map propertyMap;
- propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
+ propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
Vector2 start(-1.f, -1.f);
Vector2 end(1.f, 1.f);
propertyMap.Insert(GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT);
Property::Array stopOffsets;
- stopOffsets.PushBack( 0.2f );
- stopOffsets.PushBack( 0.8f );
+ stopOffsets.PushBack(0.2f);
+ stopOffsets.PushBack(0.8f);
propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, stopOffsets);
Property::Array stopColors;
- stopColors.PushBack( Color::RED );
- stopColors.PushBack( Color::GREEN );
+ stopColors.PushBack(Color::RED);
+ stopColors.PushBack(Color::GREEN);
propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
Visual::Base visual = factory.CreateVisual(propertyMap);
- DALI_TEST_CHECK( visual );
+ DALI_TEST_CHECK(visual);
// A lookup texture is generated and pass to shader as sampler
- Actor actor = Actor::New();
- TestVisualRender( application, actor, visual, 1u );
-
- visual.SetOffStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+ DummyControl actor = DummyControl::New(true);
+ TestVisualRender(application, actor, visual);
END_TEST;
}
ToolkitTestApplication application;
tet_infoline("UtcDaliVisualFactoryGetRadialGradientVisual");
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uAlignmentMatrix", Property::Type::MATRIX3),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
+ DALI_TEST_CHECK(factory);
Property::Map propertyMap;
- propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
+ propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
Vector2 center(100.f, 100.f);
- float radius = 100.f;
- propertyMap.Insert(GradientVisual::Property::UNITS, GradientVisual::Units::USER_SPACE);
- propertyMap.Insert(GradientVisual::Property::CENTER, center);
- propertyMap.Insert(GradientVisual::Property::RADIUS, radius);
+ float radius = 100.f;
+ propertyMap.Insert(GradientVisual::Property::UNITS, GradientVisual::Units::USER_SPACE);
+ propertyMap.Insert(GradientVisual::Property::CENTER, center);
+ propertyMap.Insert(GradientVisual::Property::RADIUS, radius);
Property::Array stopOffsets;
- stopOffsets.PushBack( 0.0f );
- stopOffsets.PushBack( 1.f );
- propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, stopOffsets);
+ stopOffsets.PushBack(0.0f);
+ stopOffsets.PushBack(1.f);
+ propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, stopOffsets);
Property::Array stopColors;
- stopColors.PushBack( Color::RED );
- stopColors.PushBack( Color::GREEN );
- propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
+ stopColors.PushBack(Color::RED);
+ stopColors.PushBack(Color::GREEN);
+ propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
Visual::Base visual = factory.CreateVisual(propertyMap);
- DALI_TEST_CHECK( visual );
+ DALI_TEST_CHECK(visual);
// A lookup texture is generated and pass to shader as sampler
- Actor actor = Actor::New();
- TestVisualRender( application, actor, visual, 1u );
+ DummyControl actor = DummyControl::New(true);
+ TestVisualRender(application, actor, visual);
- Matrix3 alignMatrix( radius, 0.f, 0.f, 0.f, radius, 0.f, center.x, center.y, 1.f );
+ Matrix3 alignMatrix(radius, 0.f, 0.f, 0.f, radius, 0.f, center.x, center.y, 1.f);
alignMatrix.Invert();
- Matrix3 actualValue( Matrix3::IDENTITY );
+ Matrix3 actualValue(Matrix3::IDENTITY);
TestGlAbstraction& gl = application.GetGlAbstraction();
- DALI_TEST_CHECK( gl.GetUniformValue<Matrix3>( "uAlignmentMatrix", actualValue ) );
- DALI_TEST_EQUALS( actualValue, alignMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+ DALI_TEST_CHECK(gl.GetUniformValue<Matrix3>("uAlignmentMatrix", actualValue));
+ DALI_TEST_EQUALS(actualValue, alignMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION);
END_TEST;
}
tet_infoline("UtcDaliVisualFactoryGetRadialGradientVisual");
VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
+ DALI_TEST_CHECK(factory);
Property::Map propertyMap;
- propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
+ propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
Vector2 start(-1.f, -1.f);
Vector2 end(1.f, 1.f);
propertyMap.Insert(GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT);
Property::Array stopColors;
- stopColors.PushBack( Color::RED );
- stopColors.PushBack( Color::GREEN );
+ stopColors.PushBack(Color::RED);
+ stopColors.PushBack(Color::GREEN);
propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
Visual::Base visual = factory.CreateVisual(propertyMap);
- DALI_TEST_CHECK( visual );
+ DALI_TEST_CHECK(visual);
// A lookup texture is generated and pass to shader as sampler
- Actor actor = Actor::New();
- TestVisualRender( application, actor, visual, 1u );
+ DummyControl actor = DummyControl::New(true);
+ TestVisualRender(application, actor, visual);
- visual.SetOffStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+ application.GetScene().Remove(actor);
+ DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
END_TEST;
}
-int UtcDaliVisualFactoryGetImageVisual1(void)
+int UtcDaliVisualFactoryGetNPatchVisualSynchronousLoad1(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetImageVisual1: Request image visual with a Property::Map" );
+ tet_infoline("UtcDaliVisualFactoryGetNPatchVisualSynchronousLoad1: Request 9-patch visual with a Property::Map");
VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
+ DALI_TEST_CHECK(factory);
+
+ // Get actual size of test image
+ ImageDimensions imageSize = Dali::GetClosestImageSize(TEST_9_PATCH_FILE_NAME);
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
- propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::N_PATCH);
+ propertyMap.Insert(ImageVisual::Property::URL, TEST_9_PATCH_FILE_NAME);
+ propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
+ {
+ tet_infoline("whole grid");
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
- Visual::Base visual = factory.CreateVisual( propertyMap );
- DALI_TEST_CHECK( visual );
+ DummyControl actor = DummyControl::New(true);
+ TestVisualRender(application, actor, visual);
- Actor actor = Actor::New();
- // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
- // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
- const int width=512;
- const int height=513;
- TestGlAbstraction& gl = application.GetGlAbstraction();
- TraceCallStack& textureTrace = gl.GetTextureTrace();
- textureTrace.Enable(true);
+ Vector2 naturalSize(0.0f, 0.0f);
+ visual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(imageSize.GetWidth() - 2.0f, imageSize.GetHeight() - 2.0f), TEST_LOCATION);
+ }
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
- bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, width, height,width, height );
+ propertyMap.Insert(ImageVisual::Property::BORDER_ONLY, true);
+ {
+ tet_infoline("border only");
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
- TestVisualRender( application, actor, visual, 1u,
- ImageDimensions(width, height),
- Integration::ResourcePointer( bitmap ) );
+ DummyControl actor = DummyControl::New(true);
+ TestVisualRender(application, actor, visual);
- DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
- visual.SetOffStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+ Vector2 naturalSize(0.0f, 0.0f);
+ visual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(imageSize.GetWidth() - 2.0f, imageSize.GetHeight() - 2.0f), TEST_LOCATION);
+ }
END_TEST;
}
-int UtcDaliVisualFactoryGetImageVisual2(void)
+int UtcDaliVisualFactoryGetNPatchVisualSynchronousLoad2(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetImageVisual2: Request image visual with an image handle" );
+ tet_infoline("UtcDaliVisualFactoryGetNPatchVisualSynchronousLoad2: Request 9-patch visual with a Property::Map including border");
VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
+ DALI_TEST_CHECK(factory);
- Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME);
- Visual::Base visual = factory.CreateVisual( image );
+ // Get actual size of test image
+ ImageDimensions imageSize = Dali::GetClosestImageSize(gImage_34_RGBA);
- Actor actor = Actor::New();
- // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
- // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::N_PATCH);
+ propertyMap.Insert(ImageVisual::Property::URL, gImage_34_RGBA);
+ propertyMap.Insert(ImageVisual::Property::BORDER, Rect<int>(2, 2, 2, 2));
+ propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
+ {
+ tet_infoline("whole grid");
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
- const int width=512;
- const int height=513;
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
- bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, width, height,width, height );
+ DummyControl actor = DummyControl::New(true);
+ TestVisualRender(application, actor, visual);
- TestGlAbstraction& gl = application.GetGlAbstraction();
- TraceCallStack& textureTrace = gl.GetTextureTrace();
- textureTrace.Enable(true);
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
+
+ Vector2 naturalSize(0.0f, 0.0f);
+ visual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(imageSize.GetWidth(), imageSize.GetHeight()), TEST_LOCATION);
+ }
+
+ propertyMap.Insert(ImageVisual::Property::BORDER_ONLY, true);
+ {
+ tet_infoline("border only");
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ DummyControl actor = DummyControl::New(true);
+ TestVisualRender(application, actor, visual);
- TestVisualRender( application, actor, visual, 1u,
- ImageDimensions(width, height),
- Integration::ResourcePointer(bitmap) );
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
- DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+ Vector2 naturalSize(0.0f, 0.0f);
+ visual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(imageSize.GetWidth(), imageSize.GetHeight()), TEST_LOCATION);
+ }
+
+ propertyMap.Clear();
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::N_PATCH);
+ propertyMap.Insert(ImageVisual::Property::URL, gImage_34_RGBA);
+ propertyMap.Insert(ImageVisual::Property::BORDER, Rect<int>(1, 1, 1, 1));
+ propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
+ {
+ tet_infoline("whole grid");
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ DummyControl actor = DummyControl::New(true);
+ TestVisualRender(application, actor, visual);
+
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
+
+ Vector2 naturalSize(0.0f, 0.0f);
+ visual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(imageSize.GetWidth(), imageSize.GetHeight()), TEST_LOCATION);
+ }
END_TEST;
}
-int UtcDaliVisualFactoryGetImageVisual3(void)
+int UtcDaliVisualFactoryGetNPatchVisual1(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetImageVisual3: Request image visual with a Property::Map, test custom wrap mode and pixel area with atlasing" );
+ tet_infoline("UtcDaliVisualFactoryGetNPatchVisual1: Request 9-patch visual with a Property::Map");
VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
+ DALI_TEST_CHECK(factory);
- // Test wrap mode with atlasing. Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
- const int width=34;
- const int height=34;
- const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
+ // Get actual size of test image
+ ImageDimensions imageSize = Dali::GetClosestImageSize(TEST_9_PATCH_FILE_NAME);
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
- propertyMap.Insert( ImageVisual::Property::URL, gImage_34_RGBA );
- propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, width );
- propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, height );
- propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true );
- propertyMap.Insert( ImageVisual::Property::PIXEL_AREA, pixelArea );
- propertyMap.Insert( ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT );
- propertyMap.Insert( ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT );
-
- Visual::Base visual = factory.CreateVisual( propertyMap );
- DALI_TEST_CHECK( visual );
-
- Actor actor = Actor::New();
- TestGlAbstraction& gl = application.GetGlAbstraction();
- TraceCallStack& textureTrace = gl.GetTextureTrace();
- textureTrace.Enable(true);
- TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
- texParameterTrace.Enable( true );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::N_PATCH);
+ propertyMap.Insert(ImageVisual::Property::URL, TEST_9_PATCH_FILE_NAME);
+ propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
+ {
+ tet_infoline("whole grid");
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
- actor.SetSize( 200.f, 200.f );
- Stage::GetCurrent().Add( actor );
- visual.SetOnStage( actor );
+ Vector2 naturalSize(0.0f, 0.0f);
+ visual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(imageSize.GetWidth(), imageSize.GetHeight()), TEST_LOCATION);
- // loading started
- application.SendNotification();
- application.Render();
- application.Render();
- application.SendNotification();
- BitmapLoader loader = BitmapLoader::GetLatestCreated();
- DALI_TEST_CHECK( loader );
- loader.WaitForLoading();// waiting until the image to be loaded
- DALI_TEST_CHECK( loader.IsLoaded() );
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ DummyControl actor = DummyControl::New(true);
+ TestVisualAsynchronousRender(application, actor, visual);
- DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
- // WITH atlasing, the wrapping is handled manually in shader, so the following gl function should not be called
- std::stringstream out;
- out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
- DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
- out.str("");
- out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
- DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
+ visual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(imageSize.GetWidth() - 2.0f, imageSize.GetHeight() - 2.0f), TEST_LOCATION);
+ }
- // test the uniforms which used to handle the wrap mode
- Renderer renderer = actor.GetRendererAt( 0u );
- DALI_TEST_CHECK( renderer );
+ propertyMap.Insert(ImageVisual::Property::BORDER_ONLY, true);
+ {
+ tet_infoline("border only");
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
- Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
- DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION );
- Vector4 pixelAreaUniform;
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
- DALI_TEST_EQUALS( pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
- Property::Value wrapModeValue = renderer.GetProperty( renderer.GetPropertyIndex( "wrapMode" ) );
- Vector2 wrapMode( WrapMode::MIRRORED_REPEAT-1, WrapMode::REPEAT-1 );
- DALI_TEST_EQUALS( wrapModeValue.Get<Vector2>(), wrapMode, TEST_LOCATION );
- Vector2 wrapModeUniform;
- DALI_TEST_CHECK( gl.GetUniformValue<Vector2>( "wrapMode", wrapModeUniform ) );
- DALI_TEST_EQUALS( wrapMode, wrapModeUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+ DummyControl actor = DummyControl::New(true);
+ TestVisualRender(application, actor, visual);
- visual.SetOffStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
+
+ Vector2 naturalSize(0.0f, 0.0f);
+ visual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(imageSize.GetWidth() - 2.0f, imageSize.GetHeight() - 2.0f), TEST_LOCATION);
+ }
END_TEST;
}
-int UtcDaliVisualFactoryGetImageVisual4(void)
+int UtcDaliVisualFactoryGetNPatchVisual2(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetImageVisual4: Request image visual with a Property::Map, test custom wrap mode and pixel area without atlasing" );
+ tet_infoline("UtcDaliVisualFactoryGetNPatchVisual2: Request 9-patch visual with a Property::Map including border");
VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
+ DALI_TEST_CHECK(factory);
- // Test wrap mode without atlasing. Image with a size bigger than 512*512 will NOT be uploaded as a part of the atlas.
- const int width=600;
- const int height=600;
- const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
+ // Get actual size of test image
+ ImageDimensions imageSize = Dali::GetClosestImageSize(gImage_34_RGBA);
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
- propertyMap.Insert( ImageVisual::Property::URL, gImage_600_RGB );
- propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, width );
- propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, height );
- propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true );
- propertyMap.Insert( ImageVisual::Property::PIXEL_AREA, pixelArea );
- propertyMap.Insert( ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT );
- propertyMap.Insert( ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT );
-
- Visual::Base visual = factory.CreateVisual( propertyMap );
- DALI_TEST_CHECK( visual );
-
- Actor actor = Actor::New();
- TestGlAbstraction& gl = application.GetGlAbstraction();
- TraceCallStack& textureTrace = gl.GetTextureTrace();
- textureTrace.Enable(true);
- TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
- texParameterTrace.Enable( true );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::N_PATCH);
+ propertyMap.Insert(ImageVisual::Property::URL, gImage_34_RGBA);
+ propertyMap.Insert(ImageVisual::Property::BORDER, Rect<int>(2, 2, 2, 2));
+ {
+ tet_infoline("whole grid (2,2,2,2) async");
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
- actor.SetSize( 200.f, 200.f );
- Stage::GetCurrent().Add( actor );
- visual.SetOnStage( actor );
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
- // loading started
- application.SendNotification();
- application.Render();
- application.Render();
- application.SendNotification();
- BitmapLoader loader = BitmapLoader::GetLatestCreated();
- DALI_TEST_CHECK( loader );
- loader.WaitForLoading();// waiting until the image to be loaded
- DALI_TEST_CHECK( loader.IsLoaded() );
+ DummyControl actor = DummyControl::New(true);
+ TestVisualAsynchronousRender(application, actor, visual);
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
- DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+ Vector2 naturalSize(0.0f, 0.0f);
+ visual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(imageSize.GetWidth(), imageSize.GetHeight()), TEST_LOCATION);
+ }
- // WITHOUT atlasing, the wrapping is handled by setting gl texture parameters
- std::stringstream out;
- out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
- DALI_TEST_CHECK( texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
- out.str("");
- out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
- DALI_TEST_CHECK( texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
+ propertyMap.Insert(ImageVisual::Property::BORDER_ONLY, true);
+ {
+ tet_infoline("border only");
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
- // test the uniforms which used to handle the wrap mode
- Renderer renderer = actor.GetRendererAt( 0u );
- DALI_TEST_CHECK( renderer );
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
- Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
- DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION );
- Vector4 pixelAreaUniform;
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
- DALI_TEST_EQUALS( pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+ DummyControl actor = DummyControl::New(true);
+ TestVisualRender(application, actor, visual);
- Property::Index wrapModeIndex = renderer.GetPropertyIndex( "wrapMode" );
- DALI_TEST_CHECK(wrapModeIndex == Property::INVALID_INDEX);
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
- visual.SetOffStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+ Vector2 naturalSize(0.0f, 0.0f);
+ visual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(imageSize.GetWidth(), imageSize.GetHeight()), TEST_LOCATION);
+ }
- END_TEST;
-}
+ propertyMap.Clear();
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::N_PATCH);
+ propertyMap.Insert(ImageVisual::Property::URL, gImage_34_RGBA);
+ propertyMap.Insert(ImageVisual::Property::BORDER, Rect<int>(2, 2, 2, 2));
+ propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
+ {
+ tet_infoline("whole grid (2,2,2,2) sync");
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
-int UtcDaliVisualFactoryGetNPatchVisual1(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual1: Request 9-patch visual with a Property::Map" );
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
- VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
+ DummyControl actor = DummyControl::New(true);
+ TestVisualRender(application, actor, visual);
- const unsigned int ninePatchImageHeight = 18;
- const unsigned int ninePatchImageWidth = 28;
- StretchRanges stretchRangesX;
- stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
- StretchRanges stretchRangesY;
- stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
- Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
- Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
- propertyMap.Insert( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME );
- {
- tet_infoline( "whole grid" );
- Visual::Base visual = factory.CreateVisual( propertyMap );
- DALI_TEST_CHECK( visual );
+ Vector2 naturalSize(0.0f, 0.0f);
+ visual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(imageSize.GetWidth(), imageSize.GetHeight()), TEST_LOCATION);
+ }
- Actor actor = Actor::New();
+ propertyMap.Clear();
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::N_PATCH);
+ propertyMap.Insert(ImageVisual::Property::URL, gImage_34_RGBA);
+ propertyMap.Insert(ImageVisual::Property::BORDER, Rect<int>(1, 1, 1, 1));
+ propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
+ {
+ tet_infoline("whole grid (1,1,1,1) sync : for testing same image, different border");
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
- TestGlAbstraction& gl = application.GetGlAbstraction();
- TraceCallStack& textureTrace = gl.GetTextureTrace();
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
textureTrace.Enable(true);
- TestVisualRender( application, actor, visual, 1u,
- ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
- ninePatchResource );
+ DummyControl actor = DummyControl::New(true);
+ TestVisualRender(application, actor, visual);
+
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
- DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+ Vector2 naturalSize(0.0f, 0.0f);
+ visual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(imageSize.GetWidth(), imageSize.GetHeight()), TEST_LOCATION);
}
- propertyMap.Insert( ImageVisual::Property::BORDER_ONLY, true );
+ propertyMap.Clear();
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::N_PATCH);
+ propertyMap.Insert(ImageVisual::Property::URL, gImage_34_RGBA);
+ propertyMap.Insert(ImageVisual::Property::BORDER, Rect<int>(1, 1, 1, 1));
{
- tet_infoline( "border only" );
- Visual::Base visual = factory.CreateVisual( propertyMap );
- DALI_TEST_CHECK( visual );
+ tet_infoline("whole grid (1,1,1,1) async");
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ DummyControl actor = DummyControl::New(true);
+ TestVisualRender(application, actor, visual);
+
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
+
+ Vector2 naturalSize(0.0f, 0.0f);
+ visual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(imageSize.GetWidth(), imageSize.GetHeight()), TEST_LOCATION);
+ }
- Actor actor = Actor::New();
+ propertyMap.Clear();
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::N_PATCH);
+ propertyMap.Insert(ImageVisual::Property::URL, gImage_34_RGBA);
+ propertyMap.Insert(ImageVisual::Property::BORDER, Rect<int>(3, 3, 3, 3));
+ {
+ tet_infoline("whole grid (3,3,3,3) async");
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
- TestGlAbstraction& gl = application.GetGlAbstraction();
- TraceCallStack& textureTrace = gl.GetTextureTrace();
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
textureTrace.Enable(true);
- TestVisualRender( application, actor, visual, 1u,
- ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
- ninePatchResource );
+ DummyControl actor = DummyControl::New(true);
+ TestVisualRender(application, actor, visual);
+
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
- DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+ Vector2 naturalSize(0.0f, 0.0f);
+ visual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(imageSize.GetWidth(), imageSize.GetHeight()), TEST_LOCATION);
}
END_TEST;
}
-int UtcDaliVisualFactoryGetNPatchVisual2(void)
+int UtcDaliVisualFactoryGetNPatchVisual3(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual2: Request n-patch visual with a Property::Map" );
+ tet_infoline("UtcDaliVisualFactoryGetNPatchVisual3: Request n-patch visual with a Property::Map");
VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
-
- const unsigned int ninePatchImageWidth = 18;
- const unsigned int ninePatchImageHeight = 28;
- StretchRanges stretchRangesX;
- stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
- stretchRangesX.PushBack( Uint16Pair( 5, 7 ) );
- stretchRangesX.PushBack( Uint16Pair( 12, 15 ) );
- StretchRanges stretchRangesY;
- stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
- stretchRangesY.PushBack( Uint16Pair( 8, 12 ) );
- stretchRangesY.PushBack( Uint16Pair( 15, 16 ) );
- stretchRangesY.PushBack( Uint16Pair( 25, 27 ) );
- Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
+ DALI_TEST_CHECK(factory);
+
+ // Get actual size of test image
+ ImageDimensions imageSize = Dali::GetClosestImageSize(TEST_NPATCH_FILE_NAME);
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
- propertyMap.Insert( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::N_PATCH);
+ propertyMap.Insert(ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME);
{
- Visual::Base visual = factory.CreateVisual( propertyMap );
- DALI_TEST_CHECK( visual );
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
- Actor actor = Actor::New();
- TestGlAbstraction& gl = application.GetGlAbstraction();
- TraceCallStack& textureTrace = gl.GetTextureTrace();
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
textureTrace.Enable(true);
- TestVisualRender( application, actor, visual, 1u,
- ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
- ninePatchResource );
-
+ DummyControl actor = DummyControl::New(true);
+ TestVisualAsynchronousRender(application, actor, visual);
- DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
- visual.SetOffStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+ Vector2 naturalSize(0.0f, 0.0f);
+ visual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(imageSize.GetWidth() - 2.0f, imageSize.GetHeight() - 2.0f), TEST_LOCATION);
}
- propertyMap.Insert( ImageVisual::Property::BORDER_ONLY, true );
+ propertyMap.Insert(ImageVisual::Property::BORDER_ONLY, true);
{
- tet_infoline( "border only" );
- Visual::Base visual = factory.CreateVisual( propertyMap );
- DALI_TEST_CHECK( visual );
+ tet_infoline("border only");
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
- TestGlAbstraction& gl = application.GetGlAbstraction();
- TraceCallStack& textureTrace = gl.GetTextureTrace();
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
textureTrace.Enable(true);
- Actor actor = Actor::New();
- TestVisualRender( application, actor, visual, 1u,
- ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
- ninePatchResource );
+ DummyControl actor = DummyControl::New(true);
+ TestVisualRender(application, actor, visual);
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
- DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+ Vector2 naturalSize(0.0f, 0.0f);
+ visual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(imageSize.GetWidth() - 2.0f, imageSize.GetHeight() - 2.0f), TEST_LOCATION);
- visual.SetOffStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+ application.GetScene().Remove(actor);
+ DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
}
END_TEST;
}
-int UtcDaliVisualFactoryGetNPatchVisual3(void)
+int UtcDaliVisualFactoryGetNPatchVisual4(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual3: Request 9-patch visual with an image url" );
+ tet_infoline("UtcDaliVisualFactoryGetNPatchVisual4: Request 9-patch visual with an image url");
- VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
-
- const unsigned int ninePatchImageHeight = 18;
- const unsigned int ninePatchImageWidth = 28;
- StretchRanges stretchRangesX;
- stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
- StretchRanges stretchRangesY;
- stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
- Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
+ // Get actual size of test image
+ ImageDimensions imageSize = Dali::GetClosestImageSize(TEST_9_PATCH_FILE_NAME);
- Visual::Base visual = factory.CreateVisual( TEST_NPATCH_FILE_NAME, ImageDimensions() );
- DALI_TEST_CHECK( visual );
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK(factory);
- Actor actor = Actor::New();
+ Visual::Base visual = factory.CreateVisual(TEST_9_PATCH_FILE_NAME, ImageDimensions());
+ DALI_TEST_CHECK(visual);
- TestGlAbstraction& gl = application.GetGlAbstraction();
- TraceCallStack& textureTrace = gl.GetTextureTrace();
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
textureTrace.Enable(true);
+ DummyControl actor = DummyControl::New(true);
+ TestVisualAsynchronousRender(application, actor, visual);
- TestVisualRender( application, actor, visual, 1u,
- ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
- ninePatchResource );
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
- DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+ Vector2 naturalSize(0.0f, 0.0f);
+ visual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(imageSize.GetWidth() - 2.0f, imageSize.GetHeight() - 2.0f), TEST_LOCATION);
+
+ textureTrace.Reset();
END_TEST;
}
-int UtcDaliVisualFactoryGetNPatchVisual4(void)
+int UtcDaliVisualFactoryGetNPatchVisual5(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetNPatchVisual4: Request n-patch visual with an image url" );
+ tet_infoline("UtcDaliVisualFactoryGetNPatchVisual5: Request n-patch visual with an image url");
+
+ // Get actual size of test image
+ ImageDimensions imageSize = Dali::GetClosestImageSize(TEST_NPATCH_FILE_NAME);
VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
-
- const unsigned int ninePatchImageHeight = 18;
- const unsigned int ninePatchImageWidth = 28;
- StretchRanges stretchRangesX;
- stretchRangesX.PushBack( Uint16Pair( 2, 3 ) );
- stretchRangesX.PushBack( Uint16Pair( 5, 7 ) );
- stretchRangesX.PushBack( Uint16Pair( 12, 15 ) );
- StretchRanges stretchRangesY;
- stretchRangesY.PushBack( Uint16Pair( 4, 5 ) );
- stretchRangesY.PushBack( Uint16Pair( 8, 12 ) );
- stretchRangesY.PushBack( Uint16Pair( 15, 16 ) );
- stretchRangesY.PushBack( Uint16Pair( 25, 27 ) );
- Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, stretchRangesX, stretchRangesY );
-
- Visual::Base visual = factory.CreateVisual( TEST_NPATCH_FILE_NAME, ImageDimensions() );
- DALI_TEST_CHECK( visual );
-
- Actor actor = Actor::New();
+ DALI_TEST_CHECK(factory);
- TestGlAbstraction& gl = application.GetGlAbstraction();
- TraceCallStack& textureTrace = gl.GetTextureTrace();
+ Visual::Base visual = factory.CreateVisual(TEST_NPATCH_FILE_NAME, ImageDimensions());
+ DALI_TEST_CHECK(visual);
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
textureTrace.Enable(true);
- TestVisualRender( application, actor, visual, 1u,
- ImageDimensions(ninePatchImageWidth, ninePatchImageHeight),
- ninePatchResource );
+ DummyControl actor = DummyControl::New(true);
+ TestVisualAsynchronousRender(application, actor, visual);
+
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
- DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+ Vector2 naturalSize(0.0f, 0.0f);
+ visual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(imageSize.GetWidth() - 2.0f, imageSize.GetHeight() - 2.0f), TEST_LOCATION);
END_TEST;
}
-int UtcDaliVisualFactoryGetNPatchVisualN1(void)
+int UtcDaliVisualFactoryGetNPatchVisual6(void)
{
- //This should still load but display an error image
-
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid image url" );
+ tet_infoline("UtcDaliVisualFactoryGetNPatchVisual6: Request n-patch visual with a general image");
VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
-
- Visual::Base visual = factory.CreateVisual( "ERROR.9.jpg", ImageDimensions() );
- DALI_TEST_CHECK( visual );
+ DALI_TEST_CHECK(factory);
- Actor actor = Actor::New();
+ {
+ // Get actual size of test image
+ ImageDimensions imageSize = Dali::GetClosestImageSize(gImage_34_RGBA);
- //The testkit still has to load a bitmap for the broken renderer image
- Integration::Bitmap* bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
- bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 100, 100, 100, 100 );
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::N_PATCH);
+ propertyMap.Insert(ImageVisual::Property::URL, gImage_34_RGBA);
- TestGlAbstraction& gl = application.GetGlAbstraction();
- TraceCallStack& textureTrace = gl.GetTextureTrace();
- textureTrace.Enable(true);
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
- TestVisualRender( application, actor, visual, 1u,
- ImageDimensions(),
- Integration::ResourcePointer(bitmap) );
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
- DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+ DummyControl actor = DummyControl::New(true);
+ TestVisualAsynchronousRender(application, actor, visual);
- END_TEST;
-}
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
-int UtcDaliVisualFactoryGetNPatchVisualN2(void)
-{
- //This should still load but display an error image
+ Vector2 naturalSize(0.0f, 0.0f);
+ visual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(imageSize.GetWidth() - 2.0f, imageSize.GetHeight() - 2.0f), TEST_LOCATION);
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid URL" );
+ application.GetScene().Remove(actor);
+ DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
+ }
- VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
+ {
+ // Get actual size of test image
+ ImageDimensions imageSize = Dali::GetClosestImageSize(TEST_IMAGE_FILE_NAME);
- Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
- propertyMap.Insert( ImageVisual::Property::URL, "ERROR.9.jpg" );
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::N_PATCH);
+ propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
- Visual::Base visual = factory.CreateVisual( propertyMap );
- DALI_TEST_CHECK( visual );
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
- Actor actor = Actor::New();
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
- //The testkit still has to load a bitmap for the broken renderer image
- Integration::Bitmap* bitmap = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD);
- bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 100, 100, 100, 100 );
+ DummyControl actor = DummyControl::New(true);
+ TestVisualAsynchronousRender(application, actor, visual);
- TestGlAbstraction& gl = application.GetGlAbstraction();
- TraceCallStack& textureTrace = gl.GetTextureTrace();
- textureTrace.Enable(true);
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
- TestVisualRender( application, actor, visual, 1u,
- ImageDimensions(),
- Integration::ResourcePointer(bitmap) );
+ Vector2 naturalSize(0.0f, 0.0f);
+ visual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(imageSize.GetWidth() - 2.0f, imageSize.GetHeight() - 2.0f), TEST_LOCATION);
- DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+ application.GetScene().Remove(actor);
+ DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
+ }
END_TEST;
}
-int UtcDaliVisualFactoryGetNPatchVisualN3(void)
+int UtcDaliVisualFactoryGetNPatchVisual7(void)
{
- // Passing in an invalid visual type so we should not get a visual
-
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid visual type" );
+ tet_infoline("UtcDaliVisualFactoryGetNPatchVisual7: Add 9-patch visual on stage and instantly remove it.");
VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
-
- Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, 111 );
- propertyMap.Insert( ImageVisual::Property::URL, "ERROR.9.jpg" );
+ DALI_TEST_CHECK(factory);
- Visual::Base visual = factory.CreateVisual( propertyMap );
- DALI_TEST_CHECK( !visual );
+ // Get actual size of test image
+ ImageDimensions imageSize = Dali::GetClosestImageSize(TEST_9_PATCH_FILE_NAME);
- END_TEST;
-}
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::N_PATCH);
+ propertyMap.Insert(ImageVisual::Property::URL, TEST_9_PATCH_FILE_NAME);
+ propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
+ {
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
-int UtcDaliVisualFactoryGetSvgVisual(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetSvgVisual: Request svg visual with a svg url" );
+ Vector2 naturalSize(0.0f, 0.0f);
+ visual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(imageSize.GetWidth(), imageSize.GetHeight()), TEST_LOCATION);
- VisualFactory factory = VisualFactory::Get();
- Visual::Base visual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions() );
- DALI_TEST_CHECK( visual );
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
- TestGlAbstraction& gl = application.GetGlAbstraction();
- TraceCallStack& textureTrace = gl.GetTextureTrace();
- textureTrace.Enable(true);
+ DummyControl actor = DummyControl::New(true);
- Actor actor = Actor::New();
- actor.SetSize( 200.f, 200.f );
- Stage::GetCurrent().Add( actor );
- visual.SetSize( Vector2(200.f, 200.f) );
- visual.SetOnStage( actor );
- application.SendNotification();
- application.Render();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
- EventThreadCallback* eventTrigger = EventThreadCallback::Get();
- CallbackBase* callback = eventTrigger->GetCallback();
+ application.GetScene().Add(actor);
+ actor.Unparent();
- eventTrigger->WaitingForTrigger( 1 );// waiting until the svg image is rasterized.
- CallbackBase::Execute( *callback );
+ application.SendNotification();
+ application.Render();
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
- // waiting for the resource uploading
- application.SendNotification();
- application.Render();
+ application.SendNotification();
+ application.Render();
- DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
+ }
END_TEST;
}
-//Creates a mesh visual from the given propertyMap and tries to load it on stage in the given application.
-//This is expected to succeed, which will then pass the test.
-void MeshVisualLoadsCorrectlyTest( Property::Map& propertyMap, ToolkitTestApplication& application )
+int UtcDaliVisualFactoryGetNPatchVisual8(void)
{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliVisualFactoryGetNPatchVisual8: Add 9-patch visual on stage, instantly remove it and add new 9-patch visual with same propertyMap");
+
VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
+ DALI_TEST_CHECK(factory);
- //Create a mesh visual.
- Visual::Base visual = factory.CreateVisual( propertyMap );
- DALI_TEST_CHECK( visual );
+ // Get actual size of test image
+ ImageDimensions imageSize = Dali::GetClosestImageSize(TEST_9_PATCH_FILE_NAME);
- //Create an actor on stage to house the visual.
- Actor actor = Actor::New();
- actor.SetSize( 200.f, 200.f );
- Stage::GetCurrent().Add( actor );
- visual.SetSize( Vector2( 200.f, 200.f ) );
- visual.SetOnStage( actor );
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::N_PATCH);
+ propertyMap.Insert(ImageVisual::Property::URL, TEST_9_PATCH_FILE_NAME);
+ propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
+ {
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
- //Ensure set on stage.
- DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
+ Vector2 naturalSize(0.0f, 0.0f);
+ visual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(imageSize.GetWidth(), imageSize.GetHeight()), TEST_LOCATION);
- //Attempt to render to queue resource load requests.
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ DummyControl actor = DummyControl::New(true);
+
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+
+ actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
+
+ application.GetScene().Add(actor);
+ actor.Unparent();
+
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
+
+ visual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(imageSize.GetWidth(), imageSize.GetHeight()), TEST_LOCATION);
+
+ actor = DummyControl::New(true);
+
+ DummyControlImpl& dummyImpl2 = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+
+ actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
+
+ application.GetScene().Add(actor);
+
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ Renderer renderer = actor.GetRendererAt(0);
+ auto textures = renderer.GetTextures();
+
+ DALI_TEST_EQUALS(textures.GetTextureCount(), 1, TEST_LOCATION);
+ }
+
+ END_TEST;
+}
+
+int UtcDaliVisualFactoryGetNPatchVisual9(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliVisualFactoryGetNPatchVisual9: Request n-patch visual sync during another n-patch visual load image asynchronously");
+
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK(factory);
+
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::N_PATCH);
+ propertyMap.Insert(ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME);
+ propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ DummyControl actor = DummyControl::New(true);
+
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+
+ actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
+
+ application.GetScene().Add(actor);
+
+ propertyMap.Clear();
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::N_PATCH);
+ propertyMap.Insert(ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME);
+ propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
+ Visual::Base visual2 = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual2);
+
+ DummyControl actor2 = DummyControl::New(true);
+
+ DummyControlImpl& dummyImpl2 = static_cast<DummyControlImpl&>(actor2.GetImplementation());
+ dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual2);
+
+ actor2.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ DALI_TEST_EQUALS(actor2.GetRendererCount(), 0u, TEST_LOCATION);
+
+ application.GetScene().Add(actor2);
+ application.Render();
+
+ // Async loading is not finished yet.
+ {
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
+ }
+ // Sync loading is finished.
+ {
+ Renderer renderer = actor2.GetRendererAt(0);
+ auto textures = renderer.GetTextures();
+
+ DALI_TEST_EQUALS(textures.GetTextureCount(), 1, TEST_LOCATION);
+ }
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+ // Async loading is finished.
+ {
+ Renderer renderer = actor.GetRendererAt(0);
+ auto textures = renderer.GetTextures();
+
+ DALI_TEST_EQUALS(textures.GetTextureCount(), 1, TEST_LOCATION);
+ }
+
+ END_TEST;
+}
+
+int UtcDaliVisualFactoryGetNPatchVisual10(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliVisualFactoryGetNPatchVisual10: Request same 9-patch visual with a different border");
+
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK(factory);
+
+ // Get actual size of test image
+ ImageDimensions imageSize = Dali::GetClosestImageSize(gImage_34_RGBA);
+
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::N_PATCH);
+ propertyMap.Insert(ImageVisual::Property::URL, gImage_34_RGBA);
+ propertyMap.Insert(ImageVisual::Property::BORDER, Rect<int>(2, 2, 2, 2));
+ {
+ tet_infoline("whole grid (2,2,2,2) async");
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ DummyControl actor = DummyControl::New(true);
+ TestVisualAsynchronousRender(application, actor, visual);
+
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
+
+ Vector2 naturalSize(0.0f, 0.0f);
+ visual.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS(naturalSize, Vector2(imageSize.GetWidth(), imageSize.GetHeight()), TEST_LOCATION);
+ }
+
+ propertyMap.Clear();
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::N_PATCH);
+ propertyMap.Insert(ImageVisual::Property::URL, gImage_34_RGBA);
+ propertyMap.Insert(ImageVisual::Property::BORDER, Rect<int>(1, 1, 1, 1));
+ {
+ tet_infoline("whole grid (1,1,1,1) async. Check whether we use cached texture");
+ // We don't use dummyControl here
+
+ const int expectResourceReadySignalCounter = 10;
+ gResourceReadySignalCounter = 0;
+
+ for(int i = 0; i < expectResourceReadySignalCounter; i++)
+ {
+ ImageView imageView = ImageView::New();
+ imageView[Toolkit::ImageView::Property::IMAGE] = propertyMap;
+ imageView.ResourceReadySignal().Connect(&OnResourceReadySignal);
+ application.GetScene().Add(imageView);
+ }
+
+ // Dont wait for loading. All border use cached texture.
+
+ DALI_TEST_EQUALS(gResourceReadySignalCounter, expectResourceReadySignalCounter, TEST_LOCATION);
+ }
+
+ propertyMap.Clear();
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::N_PATCH);
+ propertyMap.Insert(ImageVisual::Property::URL, gImage_34_RGBA);
+ propertyMap.Insert(ImageVisual::Property::BORDER, Rect<int>(1, 2, 1, 2));
+ {
+ tet_infoline("whole grid (1,2,1,2) async. Check whether we use cached texture");
+ // We don't use dummyControl here
+
+ const int expectResourceReadySignalCounter = 10;
+ gResourceReadySignalCounter = 0;
+
+ for(int i = 0; i < expectResourceReadySignalCounter; i++)
+ {
+ ImageView imageView = ImageView::New();
+ imageView[Toolkit::ImageView::Property::IMAGE] = propertyMap;
+ imageView.ResourceReadySignal().Connect(&OnResourceReadySignal);
+ application.GetScene().Add(imageView);
+ }
+
+ // Dont wait for loading. All border use cached texture.
+
+ DALI_TEST_EQUALS(gResourceReadySignalCounter, expectResourceReadySignalCounter, TEST_LOCATION);
+ }
+
+ END_TEST;
+}
+
+int UtcDaliNPatchVisualAuxiliaryImage01(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("NPatchVisual with aux image");
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map properties;
+ Property::Map shader;
+
+ Property::Map transformMap;
+ transformMap["size"] = Vector2(0.5f, 0.5f);
+ transformMap["offset"] = Vector2(20.0f, 0.0f);
+ transformMap["offsetPolicy"] = Vector2(Visual::Transform::Policy::ABSOLUTE, Visual::Transform::Policy::ABSOLUTE);
+ transformMap["anchorPoint"] = Align::CENTER;
+ transformMap["origin"] = Align::CENTER;
+ properties[Visual::Property::TRANSFORM] = transformMap;
+
+ properties[Visual::Property::TYPE] = Visual::IMAGE;
+ properties[Visual::Property::MIX_COLOR] = Color::BLUE;
+ properties[Visual::Property::SHADER] = shader;
+ properties[ImageVisual::Property::URL] = TEST_9_PATCH_FILE_NAME;
+ properties[DevelImageVisual::Property::AUXILIARY_IMAGE] = TEST_AUX_IMAGE;
+ properties[DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA] = 0.9f;
+
+ Visual::Base visual = factory.CreateVisual(properties);
+
+ // trigger creation through setting on stage
+ DummyControl dummy = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+ dummyImpl.SetLayout(DummyControl::Property::TEST_VISUAL, transformMap);
+ dummy.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
+ dummy.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+ application.GetScene().Add(dummy);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ Renderer renderer = dummy.GetRendererAt(0);
+ auto textures = renderer.GetTextures();
+ DALI_TEST_EQUALS(textures.GetTextureCount(), 2, TEST_LOCATION);
+ UnparentAndReset(dummy);
+
+ END_TEST;
+}
+
+int UtcDaliNPatchVisualAuxiliaryImage02(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("Multiple NPatchVisual with aux image coincidentally");
+
+ const Property::Value NPATCH_TEST{
+ {ImageVisual::Property::URL, TEST_9_PATCH_FILE_NAME},
+ {DevelImageVisual::Property::AUXILIARY_IMAGE, TEST_AUX_IMAGE}};
+
+ ImageView imageView1 = ImageView::New();
+ imageView1[ImageView::Property::IMAGE] = NPATCH_TEST;
+ application.GetScene().Add(imageView1);
+
+ ImageView imageView2 = ImageView::New();
+ imageView2[ImageView::Property::IMAGE] = NPATCH_TEST;
+ application.GetScene().Add(imageView2);
+
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ Renderer renderer1 = imageView1.GetRendererAt(0);
+ auto textureSet1 = renderer1.GetTextures();
+
+ Renderer renderer2 = imageView2.GetRendererAt(0);
+ auto textureSet2 = renderer2.GetTextures();
+ DALI_TEST_EQUALS(textureSet1 != textureSet2, true, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliVisualFactoryGetNPatchVisualN1(void)
+{
+ //This should still load but display an error image
+
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid image url");
+
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK(factory);
+
+ Visual::Base visual = factory.CreateVisual("ERROR.9.jpg", ImageDimensions());
+ DALI_TEST_CHECK(visual);
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ {
+ DummyControl actor = DummyControl::New(true);
+ TestVisualAsynchronousRender(application, actor, visual);
+
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
+ UnparentAndReset(actor);
+ }
+
+ END_TEST;
+}
+
+int UtcDaliVisualFactoryGetNPatchVisualN2(void)
+{
+ //This should still load but display an error image
+
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid URL");
+
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK(factory);
+
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::N_PATCH);
+ propertyMap.Insert(ImageVisual::Property::URL, "ERROR.9.jpg");
+
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+ TraceCallStack& drawTrace = gl.GetDrawTrace();
+ drawTrace.Enable(true);
+
+ DummyControl actor = DummyControl::New(true);
+ TestVisualAsynchronousRender(application, actor, visual);
+
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliVisualFactoryGetNPatchVisualN3(void)
+{
+ // Passing in an invalid visual type so we should not get a visual
+
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid visual type");
+
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK(factory);
+
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, 111);
+ propertyMap.Insert(ImageVisual::Property::URL, "ERROR.9.jpg");
+
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(!visual);
+
+ END_TEST;
+}
+
+int UtcDaliVisualFactoryGetSvgVisual(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliVisualFactoryGetSvgVisual: Request svg visual with a svg url");
+
+ VisualFactory factory = VisualFactory::Get();
+ Visual::Base visual = factory.CreateVisual(TEST_SVG_FILE_NAME, ImageDimensions());
+ DALI_TEST_CHECK(visual);
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ DummyControl actor = DummyControl::New(true);
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+ actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ application.GetScene().Add(actor);
+ visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f));
+
+ // Either application.SendNotification() or the trigger can now complete the task.
+ application.SendNotification();
+ application.Render();
+
+ // Wait for loading & rasterization
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
+
+ // renderer is added to actor
+ DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
+
+ // waiting for the resource uploading
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliVisualFactoryGetSvgVisualLarge(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliVisualFactoryGetSvgVisual: Request svg visual with a svg url");
+
+ VisualFactory factory = VisualFactory::Get();
+ Visual::Base visual = factory.CreateVisual(TEST_SVG_FILE_NAME, ImageDimensions(2000, 2000));
+ DALI_TEST_CHECK(visual);
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ DummyControl actor = DummyControl::New(true);
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); // Only rasterizes when it knows control size.
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+ application.GetScene().Add(actor);
+
+ // Either application.SendNotification() or the trigger can now complete the task.
+ application.SendNotification();
+ application.Render();
+
+ // Wait for loading & rasterization
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
+
+ // renderer is added to actor
+ DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
+
+ // waiting for the resource uploading
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliVisualFactoryGetSvgVisualAtlas(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliVisualFactoryGetSvgVisual: Request svg visual with enabled atlas");
+
+ VisualFactory factory = VisualFactory::Get();
+
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::SVG);
+ propertyMap.Insert(ImageVisual::Property::URL, TEST_SVG_FILE_NAME);
+ propertyMap.Insert(ImageVisual::Property::ATLASING, true);
+
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ DummyControl actor = DummyControl::New(true);
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+ actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ application.GetScene().Add(actor);
+ visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f));
+
+ // Either application.SendNotification() or the trigger can now complete the task.
+ DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
+ application.SendNotification();
+ application.Render();
+
+ // Wait for loading & rasterization
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
+
+ // renderer is added to actor
+ DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
+
+ // waiting for the resource uploading
application.SendNotification();
- application.Render( 0 );
+ application.Render();
+
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
+
+ END_TEST;
+}
+
+//Creates a mesh visual from the given propertyMap and tries to load it on stage in the given application.
+//This is expected to succeed, which will then pass the test.
+void MeshVisualLoadsCorrectlyTest(Property::Map& propertyMap, ToolkitTestApplication& application)
+{
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK(factory);
+
+ //Create a mesh visual.
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
- //Tell the platform abstraction that the required resources have been loaded.
- TestPlatformAbstraction& platform = application.GetPlatform();
- platform.SetAllResourceRequestsAsLoaded();
+ //Create an actor on stage to house the visual.
+ DummyControl actor = DummyControl::New(true);
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+ actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ application.GetScene().Add(actor);
+ visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f));
+
+ //Ensure set on stage.
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
+
+ //Attempt to render to queue resource load requests.
+ application.SendNotification();
+ application.Render(0);
//Render again to upload the now-loaded textures.
application.SendNotification();
- application.Render( 0 );
+ application.Render(0);
Matrix testScaleMatrix;
- testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
+ testScaleMatrix.SetIdentityAndScale(Vector3(1.0, -1.0, 1.0));
Matrix actualScaleMatrix;
//Test to see if the object has been successfully loaded.
- DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
- DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+ DALI_TEST_CHECK(application.GetGlAbstraction().GetUniformValue<Matrix>("uObjectMatrix", actualScaleMatrix));
+ DALI_TEST_EQUALS(actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION);
//Finish by setting off stage, and ensuring this was successful.
- visual.SetOffStage( actor );
- DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+ actor.Unparent();
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
}
//Creates a mesh visual from the given propertyMap and tries to load it on stage in the given application.
//This is expected to fail, which will then pass the test.
-void MeshVisualDoesNotLoadCorrectlyTest( Property::Map& propertyMap, ToolkitTestApplication& application )
+void MeshVisualDoesNotLoadCorrectlyTest(Property::Map& propertyMap, ToolkitTestApplication& application)
{
VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
+ DALI_TEST_CHECK(factory);
//Create a mesh visual.
- Visual::Base visual = factory.CreateVisual( propertyMap );
- DALI_TEST_CHECK( visual );
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
//Create an actor on stage to house the visual.
- Actor actor = Actor::New();
- actor.SetSize( 200.f, 200.f );
- Stage::GetCurrent().Add( actor );
- visual.SetSize( Vector2( 200.f, 200.f ) );
- visual.SetOnStage( actor );
+ DummyControl actor = DummyControl::New(true);
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+ actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ application.GetScene().Add(actor);
+ visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f));
//Ensure set on stage.
- DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
//Attempt to render to queue resource load requests.
application.SendNotification();
- application.Render( 0 );
+ application.Render(0);
+
+ //Render again to upload the now-loaded textures.
+ application.SendNotification();
+ application.Render(0);
+
+ //Test to see if the object has not been loaded, as expected.
+ Matrix scaleMatrix;
+ DALI_TEST_CHECK(!application.GetGlAbstraction().GetUniformValue<Matrix>("uObjectMatrix", scaleMatrix));
+
+ //Finish by setting off stage, and ensuring this was successful.
+ actor.Unparent();
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
+}
+
+//Test if mesh loads correctly when supplied with only the bare minimum requirements, an object file.
+int UtcDaliVisualFactoryGetMeshVisual1(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline("UtcDaliVisualFactoryGetMeshVisual1: Request mesh visual with a valid object file only");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::MESH);
+ propertyMap.Insert(MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME);
+
+ //Test to see if mesh loads correctly.
+ MeshVisualLoadsCorrectlyTest(propertyMap, application);
+
+ END_TEST;
+}
+
+//Test if mesh loads correctly when supplied with an object file as well as a blank material file and images directory.
+int UtcDaliVisualFactoryGetMeshVisual2(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline("UtcDaliVisualFactoryGetMeshVisual2: Request mesh visual with blank material file and images directory");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::MESH);
+ propertyMap.Insert(MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME);
+ propertyMap.Insert(MeshVisual::Property::MATERIAL_URL, "");
+ propertyMap.Insert(MeshVisual::Property::TEXTURES_PATH, "");
+
+ //Test to see if mesh loads correctly.
+ MeshVisualLoadsCorrectlyTest(propertyMap, application);
+
+ END_TEST;
+}
+
+//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
+int UtcDaliVisualFactoryGetMeshVisual3b(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline("UtcDaliVisualFactoryGetMeshVisual3: Request mesh visual with all parameters correct");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::MESH);
+ propertyMap.Insert(MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME);
+ propertyMap.Insert(MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME);
+ propertyMap.Insert(MeshVisual::Property::USE_MIPMAPPING, Color::GREEN); // Test that wrong property types don't prevent the object load
+ propertyMap.Insert(MeshVisual::Property::USE_SOFT_NORMALS, 1.0f);
+ propertyMap.Insert(MeshVisual::Property::LIGHT_POSITION, 1.0f);
+ propertyMap.Insert(MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/");
+
+ //Test to see if mesh loads correctly.
+ MeshVisualLoadsCorrectlyTest(propertyMap, application);
+
+ END_TEST;
+}
+
+//Test if mesh loads correctly when supplied with all main parameters, an object file, a material file and a directory location.
+int UtcDaliVisualFactoryGetMeshVisual3(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline("UtcDaliVisualFactoryGetMeshVisual3: Request mesh visual with all parameters correct");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::MESH);
+ propertyMap.Insert(MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME);
+ propertyMap.Insert(MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME);
+ propertyMap.Insert(MeshVisual::Property::USE_MIPMAPPING, false);
+ propertyMap.Insert(MeshVisual::Property::USE_SOFT_NORMALS, false);
+ propertyMap.Insert(MeshVisual::Property::LIGHT_POSITION, Vector3::XAXIS);
+ propertyMap.Insert(MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/");
+
+ //Test to see if mesh loads correctly.
+ MeshVisualLoadsCorrectlyTest(propertyMap, application);
+
+ END_TEST;
+}
+
+//Test if mesh visual can load a correctly supplied mesh without a normal map or gloss map in the material file.
+int UtcDaliVisualFactoryGetMeshVisual4(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline("UtcDaliVisualFactoryGetMeshVisual4: Request mesh visual with diffuse texture but not normal or gloss.");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::MESH);
+ propertyMap.Insert(MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME);
+ propertyMap.Insert(MeshVisual::Property::MATERIAL_URL, TEST_SIMPLE_MTL_FILE_NAME);
+ propertyMap.Insert(MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/");
+
+ //Test to see if mesh loads correctly.
+ MeshVisualLoadsCorrectlyTest(propertyMap, application);
+
+ END_TEST;
+}
+
+//Test if mesh visual can load when made to use diffuse textures only.
+int UtcDaliVisualFactoryGetMeshVisual5(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline("UtcDaliVisualFactoryGetMeshVisual5: Request mesh visual and make it only use diffuse textures.");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::MESH);
+ propertyMap.Insert("objectUrl", TEST_OBJ_FILE_NAME);
+ propertyMap.Insert("materialUrl", TEST_MTL_FILE_NAME);
+ propertyMap.Insert("texturesPath", TEST_RESOURCE_DIR "/");
+ propertyMap.Insert("useMipmapping", false);
+ propertyMap.Insert("useSoftNormals", false);
+ propertyMap.Insert("lightPosition", Vector3::ZAXIS);
+ propertyMap.Insert("shadingMode", MeshVisual::ShadingMode::TEXTURED_WITH_SPECULAR_LIGHTING);
+
+ //Test to see if mesh loads correctly.
+ MeshVisualLoadsCorrectlyTest(propertyMap, application);
+
+ END_TEST;
+}
+
+//Test if mesh visual can load when made to not use the supplied textures.
+int UtcDaliVisualFactoryGetMeshVisual6(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline("UtcDaliVisualFactoryGetMeshVisual6: Request mesh visual and make it not use any textures.");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::MESH);
+ propertyMap.Insert(MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME);
+ propertyMap.Insert(MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME);
+ propertyMap.Insert(MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/");
+ propertyMap.Insert(MeshVisual::Property::SHADING_MODE, MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING);
+
+ //Test to see if mesh loads correctly.
+ MeshVisualLoadsCorrectlyTest(propertyMap, application);
+
+ END_TEST;
+}
+//Test if mesh visual loads correctly when light position is manually set.
+int UtcDaliVisualFactoryGetMeshVisual7(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline("UtcDaliVisualFactoryGetMeshVisual7: Request mesh visual with custom light position.");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::MESH);
+ propertyMap.Insert(MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME);
+ propertyMap.Insert(MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME);
+ propertyMap.Insert(MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/");
+ propertyMap.Insert(MeshVisual::Property::LIGHT_POSITION, Vector3(0.0, 1.0, 2.0));
+
+ //Test to see if mesh loads correctly.
+ MeshVisualLoadsCorrectlyTest(propertyMap, application);
+
+ END_TEST;
+}
+
+//Test if mesh visual loads correctly when supplied an object file without face normals or texture points.
+//Note that this notably tests object loader functionality.
+int UtcDaliVisualFactoryGetMeshVisual8(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline("UtcDaliVisualFactoryGetMeshVisual5: Request mesh visual with normal-less object file.");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::MESH);
+ propertyMap.Insert(MeshVisual::Property::OBJECT_URL, TEST_SIMPLE_OBJ_FILE_NAME);
+ propertyMap.Insert(MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME);
+ propertyMap.Insert(MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/");
+
+ //Test to see if mesh loads correctly.
+ MeshVisualLoadsCorrectlyTest(propertyMap, application);
+
+ END_TEST;
+}
+
+//Test if mesh visual handles the case of lacking an object file.
+int UtcDaliVisualFactoryGetMeshVisualN1(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
- //Tell the platform abstraction that the required resources have been loaded.
- TestPlatformAbstraction& platform = application.GetPlatform();
- platform.SetAllResourceRequestsAsLoaded();
+ tet_infoline("UtcDaliVisualFactoryGetMeshVisualN1: Request mesh visual without object file");
- //Render again to upload the now-loaded textures.
- application.SendNotification();
- application.Render( 0 );
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::MESH);
+ propertyMap.Insert(MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME);
+ propertyMap.Insert(MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/");
- //Test to see if the object has not been loaded, as expected.
- Matrix scaleMatrix;
- DALI_TEST_CHECK( !application.GetGlAbstraction().GetUniformValue<Matrix>( "uObjectMatrix", scaleMatrix ) );
+ //Test to see if mesh doesn't load with these properties, as expected.
+ MeshVisualDoesNotLoadCorrectlyTest(propertyMap, application);
- //Finish by setting off stage, and ensuring this was successful.
- visual.SetOffStage( actor );
- DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+ END_TEST;
}
-//Test if mesh loads correctly when supplied with only the bare minimum requirements, an object file.
-int UtcDaliVisualFactoryGetMeshVisual1(void)
+//Test if mesh visual handles the case of being passed invalid material and images urls.
+int UtcDaliVisualFactoryGetMeshVisualN2(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetMeshVisual1: Request mesh visual with a valid object file only" );
-
+ tet_infoline("UtcDaliVisualFactoryGetMeshVisualN2: Request mesh visual with invalid material and images urls");
//Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
- propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::MESH);
+ propertyMap.Insert(MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME);
+ propertyMap.Insert(MeshVisual::Property::MATERIAL_URL, "invalid");
+ propertyMap.Insert(MeshVisual::Property::TEXTURES_PATH, "also invalid");
- //Test to see if mesh loads correctly.
- MeshVisualLoadsCorrectlyTest( propertyMap, application );
+ //Test to see if mesh doesn't load with these properties, as expected.
+ MeshVisualDoesNotLoadCorrectlyTest(propertyMap, application);
END_TEST;
}
-
-//Test if mesh loads correctly when supplied with an object file as well as a blank material file and images directory.
-int UtcDaliVisualFactoryGetMeshVisual2(void)
+//Test if mesh visual handles the case of being passed an invalid object url
+int UtcDaliVisualFactoryGetMeshVisualN3(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
-
- tet_infoline( "UtcDaliVisualFactoryGetMeshVisual2: Request mesh visual with blank material file and images directory" );
+ tet_infoline("UtcDaliVisualFactoryGetMeshVisualN3: Request mesh visual with invalid object url");
//Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
- propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
- propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, "" );
- propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, "" );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::MESH);
+ propertyMap.Insert(MeshVisual::Property::OBJECT_URL, "invalid");
+ propertyMap.Insert(MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME);
+ propertyMap.Insert(MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/");
- //Test to see if mesh loads correctly.
- MeshVisualLoadsCorrectlyTest( propertyMap, application );
+ //Test to see if mesh doesn't load with these properties, as expected.
+ MeshVisualDoesNotLoadCorrectlyTest(propertyMap, application);
END_TEST;
}
-//Test if mesh loads correctly when supplied with all main parameters, an object file, a material file and a directory location.
-int UtcDaliVisualFactoryGetMeshVisual3(void)
+//Creates a primitive visual with the given property map and tests to see if it correctly loads in the given application.
+void TestPrimitiveVisualWithProperties(Property::Map& propertyMap, ToolkitTestApplication& application)
+{
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK(factory);
+
+ //Create a primitive visual.
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
+
+ //Create an actor on stage to house the visual.
+ DummyControl actor = DummyControl::New(true);
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+
+ actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ application.GetScene().Add(actor);
+ visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f));
+
+ //Ensure set on stage.
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
+
+ //Tell test application to load the visual.
+ application.SendNotification();
+ application.Render(0);
+
+ Matrix testScaleMatrix;
+ testScaleMatrix.SetIdentityAndScale(Vector3(1.0, -1.0, 1.0));
+ Matrix actualScaleMatrix;
+
+ //Test to see if the object has been successfully loaded.
+ DALI_TEST_CHECK(application.GetGlAbstraction().GetUniformValue<Matrix>("uObjectMatrix", actualScaleMatrix));
+ DALI_TEST_EQUALS(actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION);
+
+ //Finish by setting off stage, and ensuring this was successful.
+ actor.Unparent();
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
+}
+
+//Test if primitive shape loads correctly when supplied with only the bare minimum requirements, the shape to use.
+int UtcDaliVisualFactoryGetPrimitiveVisual1(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetMeshVisual3: Request mesh visual with all parameters correct" );
+ tet_infoline("UtcDaliVisualFactoryGetPrimitiveVisual1: Request primitive visual with a shape only");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
//Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
- propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
- propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
- propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE);
+ propertyMap.Insert(PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE);
- //Test to see if mesh loads correctly.
- MeshVisualLoadsCorrectlyTest( propertyMap, application );
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties(propertyMap, application);
END_TEST;
}
-//Test if mesh visual can load a correctly supplied mesh without a normal map or gloss map in the material file.
-int UtcDaliVisualFactoryGetMeshVisual4(void)
+//Test if primitive shape loads correctly when supplied with all possible parameters
+int UtcDaliVisualFactoryGetPrimitiveVisual2(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetMeshVisual4: Request mesh visual with diffuse texture but not normal or gloss." );
+ tet_infoline("UtcDaliVisualFactoryGetPrimitiveVisual2: Request primitive visual with everything");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
//Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
- propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
- propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_SIMPLE_MTL_FILE_NAME );
- propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
-
- //Test to see if mesh loads correctly.
- MeshVisualLoadsCorrectlyTest( propertyMap, application );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE);
+ propertyMap.Insert(PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE);
+ propertyMap.Insert(PrimitiveVisual::Property::MIX_COLOR, Vector4(0.5, 0.5, 0.5, 1.0));
+ propertyMap.Insert(PrimitiveVisual::Property::SLICES, 10);
+ propertyMap.Insert(PrimitiveVisual::Property::STACKS, 20);
+ propertyMap.Insert(PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f);
+ propertyMap.Insert(PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f);
+ propertyMap.Insert(PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f);
+ propertyMap.Insert(PrimitiveVisual::Property::SCALE_RADIUS, 60.0f);
+ propertyMap.Insert(PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.7f);
+ propertyMap.Insert(PrimitiveVisual::Property::BEVEL_SMOOTHNESS, 0.8f);
+ propertyMap.Insert(MeshVisual::Property::LIGHT_POSITION, Vector3(0.9, 1.0, 1.1));
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties(propertyMap, application);
END_TEST;
}
-//Test if mesh visual can load when made to use diffuse textures only.
-int UtcDaliVisualFactoryGetMeshVisual5(void)
+//Test if primitive shape loads a sphere correctly.
+int UtcDaliVisualFactoryGetPrimitiveVisual3(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetMeshVisual5: Request mesh visual and make it only use diffuse textures." );
+ tet_infoline("UtcDaliVisualFactoryGetPrimitiveVisual3: Request primitive visual to display a sphere");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
//Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
- propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
- propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
- propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
- propertyMap.Insert( MeshVisual::Property::SHADING_MODE, MeshVisual::ShadingMode::TEXTURED_WITH_SPECULAR_LIGHTING );
-
- //Test to see if mesh loads correctly.
- MeshVisualLoadsCorrectlyTest( propertyMap, application );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE);
+ propertyMap.Insert(PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE);
+ propertyMap.Insert(PrimitiveVisual::Property::MIX_COLOR, Vector4(0.5, 0.5, 0.5, 1.0));
+ propertyMap.Insert(PrimitiveVisual::Property::SLICES, 10);
+ propertyMap.Insert(PrimitiveVisual::Property::STACKS, 20);
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties(propertyMap, application);
END_TEST;
}
-//Test if mesh visual can load when made to not use the supplied textures.
-int UtcDaliVisualFactoryGetMeshVisual6(void)
+//Test if primitive shape loads a conic section correctly.
+int UtcDaliVisualFactoryGetPrimitiveVisual4(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetMeshVisual6: Request mesh visual and make it not use any textures." );
+ tet_infoline("UtcDaliVisualFactoryGetPrimitiveVisual4: Request primitive visual to display a conic section");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
//Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
- propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
- propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
- propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
- propertyMap.Insert( MeshVisual::Property::SHADING_MODE, MeshVisual::ShadingMode::TEXTURELESS_WITH_DIFFUSE_LIGHTING );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE);
+ propertyMap.Insert(PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONICAL_FRUSTUM);
+ propertyMap.Insert(PrimitiveVisual::Property::MIX_COLOR, Vector4(0.5, 0.5, 0.5, 1.0));
+ propertyMap.Insert(PrimitiveVisual::Property::SLICES, 10);
+ propertyMap.Insert(PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f);
+ propertyMap.Insert(PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f);
+ propertyMap.Insert(PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f);
- //Test to see if mesh loads correctly.
- MeshVisualLoadsCorrectlyTest( propertyMap, application );
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties(propertyMap, application);
END_TEST;
}
-//Test if mesh visual loads correctly when light position is manually set.
-int UtcDaliVisualFactoryGetMeshVisual7(void)
+
+//Test if primitive shape loads a bevelled cube correctly.
+int UtcDaliVisualFactoryGetPrimitiveVisual5(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
+ tet_infoline("UtcDaliVisualFactoryGetPrimitiveVisual5: Request primitive visual to display a bevelled cube");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
- tet_infoline( "UtcDaliVisualFactoryGetMeshVisual7: Request mesh visual with custom light position." );
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
//Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
- propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
- propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
- propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
- propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.0, 1.0, 2.0 ) );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE);
+ propertyMap.Insert(PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::BEVELLED_CUBE);
+ propertyMap.Insert(PrimitiveVisual::Property::MIX_COLOR, Vector4(0.5, 0.5, 0.5, 1.0));
+ propertyMap.Insert(PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.7f);
- //Test to see if mesh loads correctly.
- MeshVisualLoadsCorrectlyTest( propertyMap, application );
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties(propertyMap, application);
END_TEST;
}
-//Test if mesh visual loads correctly when supplied an object file without face normals or texture points.
-//Note that this notably tests object loader functionality.
-int UtcDaliVisualFactoryGetMeshVisual8(void)
+//Test if primitive shape loads an octahedron correctly.
+int UtcDaliVisualFactoryGetPrimitiveVisual6(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetMeshVisual5: Request mesh visual with normal-less object file." );
+ tet_infoline("UtcDaliVisualFactoryGetPrimitiveVisual6: Request primitive visual to display an octahedron");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
//Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
- propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_SIMPLE_OBJ_FILE_NAME );
- propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
- propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE);
+ propertyMap.Insert(PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::OCTAHEDRON);
+ propertyMap.Insert(PrimitiveVisual::Property::MIX_COLOR, Vector4(0.5, 0.5, 0.5, 1.0));
- //Test to see if mesh loads correctly.
- MeshVisualLoadsCorrectlyTest( propertyMap, application );
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties(propertyMap, application);
END_TEST;
}
-//Test if mesh visual handles the case of lacking an object file.
-int UtcDaliVisualFactoryGetMeshVisualN1(void)
+//Test if primitive shape loads a cone correctly.
+int UtcDaliVisualFactoryGetPrimitiveVisual7(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN1: Request mesh visual without object file" );
+ tet_infoline("UtcDaliVisualFactoryGetPrimitiveVisual7: Request primitive visual to display a cone");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
//Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
- propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
- propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
-
- //Test to see if mesh doesn't load with these properties, as expected.
- MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE);
+ propertyMap.Insert(PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONE);
+ propertyMap.Insert(PrimitiveVisual::Property::MIX_COLOR, Vector4(0.5, 0.5, 0.5, 1.0));
+ propertyMap.Insert(PrimitiveVisual::Property::SLICES, 10);
+ propertyMap.Insert(PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f);
+ propertyMap.Insert(PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f);
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties(propertyMap, application);
END_TEST;
}
-//Test if mesh visual handles the case of being passed invalid material and images urls.
-int UtcDaliVisualFactoryGetMeshVisualN2(void)
+//Test if primitive shape loads correctly when light position is manually set.
+int UtcDaliVisualFactoryGetPrimitiveVisual8(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN2: Request mesh visual with invalid material and images urls" );
+ tet_infoline("UtcDaliVisualFactoryGetPrimitiveVisual8: Request primitive visual with set light position");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
//Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
- propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
- propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, "invalid" );
- propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, "also invalid" );
-
- //Test to see if mesh doesn't load with these properties, as expected.
- MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE);
+ propertyMap.Insert(PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE);
+ propertyMap.Insert(PrimitiveVisual::Property::MIX_COLOR, Vector4(0.5, 0.5, 0.5, 1.0));
+ propertyMap.Insert(MeshVisual::Property::LIGHT_POSITION, Vector3(0.0, 1.0, 2.0));
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties(propertyMap, application);
END_TEST;
}
-//Test if mesh visual handles the case of being passed an invalid object url
-int UtcDaliVisualFactoryGetMeshVisualN3(void)
+//Test if primitive shape loads correctly when told to use too many slices.
+int UtcDaliVisualFactoryGetPrimitiveVisual9(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN3: Request mesh visual with invalid object url" );
+ tet_infoline("UtcDaliVisualFactoryGetPrimitiveVisual9: Request primitive visual with above-cap slices.");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
//Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::MESH );
- propertyMap.Insert( MeshVisual::Property::OBJECT_URL, "invalid" );
- propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
- propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE);
+ propertyMap.Insert(PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE);
+ propertyMap.Insert(PrimitiveVisual::Property::SLICES, Property::Value(1000000));
- //Test to see if mesh doesn't load with these properties, as expected.
- MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties(propertyMap, application);
END_TEST;
}
-//Creates a primitive visual with the given property map and tests to see if it correctly loads in the given application.
-void TestPrimitiveVisualWithProperties( Property::Map& propertyMap, ToolkitTestApplication& application )
+//Test if primitive shape loads correctly when told to use too few slices. (2 slices or less.)
+int UtcDaliVisualFactoryGetPrimitiveVisual10(void)
{
- VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
-
- //Create a primitive visual.
- Visual::Base visual = factory.CreateVisual( propertyMap );
- DALI_TEST_CHECK( visual );
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
- //Create an actor on stage to house the visual.
- Actor actor = Actor::New();
- actor.SetSize( 200.f, 200.f );
- Stage::GetCurrent().Add( actor );
- visual.SetSize( Vector2( 200.f, 200.f ) );
- visual.SetOnStage( actor );
+ tet_infoline("UtcDaliVisualFactoryGetPrimitiveVisual10: Request primitive visual with too few slices.");
- //Ensure set on stage.
- DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
- //Tell test application to load the visual.
- application.SendNotification();
- application.Render(0);
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
- Matrix testScaleMatrix;
- testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
- Matrix actualScaleMatrix;
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE);
+ propertyMap.Insert(PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE);
+ propertyMap.Insert(PrimitiveVisual::Property::SLICES, Property::Value(2));
- //Test to see if the object has been successfully loaded.
- DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
- DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties(propertyMap, application);
- //Finish by setting off stage, and ensuring this was successful.
- visual.SetOffStage( actor );
- DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+ END_TEST;
}
-//Test if primitive shape loads correctly when supplied with only the bare minimum requirements, the shape to use.
-int UtcDaliVisualFactoryGetPrimitiveVisual1(void)
+//Test if primitive shape loads correctly when told to use too many stacks.
+int UtcDaliVisualFactoryGetPrimitiveVisual11(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual1: Request primitive visual with a shape only" );
+ tet_infoline("UtcDaliVisualFactoryGetPrimitiveVisual11: Request primitive visual with too many stacks.");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
//Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
- propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE);
+ propertyMap.Insert(PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE);
+ propertyMap.Insert(PrimitiveVisual::Property::STACKS, Property::Value(1000000));
//Test to see if shape loads correctly.
- TestPrimitiveVisualWithProperties( propertyMap, application );
+ TestPrimitiveVisualWithProperties(propertyMap, application);
END_TEST;
}
-//Test if primitive shape loads correctly when supplied with all possible parameters
-int UtcDaliVisualFactoryGetPrimitiveVisual2(void)
+//Test if primitive shape loads correctly when told to use too few stacks. (1 stack or less.)
+int UtcDaliVisualFactoryGetPrimitiveVisual12(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual2: Request primitive visual with everything" );
+ tet_infoline("UtcDaliVisualFactoryGetPrimitiveVisual12: Request primitive visual with too few stacks.");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
//Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
- propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
- propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
- propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
- propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
- propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
- propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f );
- propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
- propertyMap.Insert( PrimitiveVisual::Property::SCALE_RADIUS, 60.0f );
- propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.7f );
- propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, 0.8f );
- propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.9, 1.0, 1.1 ) );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE);
+ propertyMap.Insert(PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE);
+ propertyMap.Insert(PrimitiveVisual::Property::STACKS, Property::Value(1));
//Test to see if shape loads correctly.
- TestPrimitiveVisualWithProperties( propertyMap, application );
+ TestPrimitiveVisualWithProperties(propertyMap, application);
END_TEST;
}
-//Test if primitive shape loads a sphere correctly.
-int UtcDaliVisualFactoryGetPrimitiveVisual3(void)
+//Test if primitive shape loads correctly when told to use invalid (zero or negative) dimensions.
+int UtcDaliVisualFactoryGetPrimitiveVisual13(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual3: Request primitive visual to display a sphere" );
+ tet_infoline("UtcDaliVisualFactoryGetPrimitiveVisual13: Request primitive visual with invalid scale dimensions.");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
//Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
- propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
- propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
- propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
- propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE);
+ propertyMap.Insert(PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE);
+ propertyMap.Insert(PrimitiveVisual::Property::SCALE_DIMENSIONS, Vector3::ZERO);
//Test to see if shape loads correctly.
- TestPrimitiveVisualWithProperties( propertyMap, application );
+ TestPrimitiveVisualWithProperties(propertyMap, application);
END_TEST;
}
-//Test if primitive shape loads a conic section correctly.
-int UtcDaliVisualFactoryGetPrimitiveVisual4(void)
+//Test if primitive shape loads correctly when told to use too low a bevel percentage.
+int UtcDaliVisualFactoryGetPrimitiveVisual14(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual4: Request primitive visual to display a conic section" );
+ tet_infoline("UtcDaliVisualFactoryGetPrimitiveVisual14: Request primitive visual with too low a bevel percentage.");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
//Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
- propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONICAL_FRUSTRUM );
- propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
- propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
- propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
- propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f );
- propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE);
+ propertyMap.Insert(PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE);
+ propertyMap.Insert(PrimitiveVisual::Property::BEVEL_PERCENTAGE, Property::Value(-1.0f));
//Test to see if shape loads correctly.
- TestPrimitiveVisualWithProperties( propertyMap, application );
+ TestPrimitiveVisualWithProperties(propertyMap, application);
END_TEST;
}
-//Test if primitive shape loads a bevelled cube correctly.
-int UtcDaliVisualFactoryGetPrimitiveVisual5(void)
+//Test if primitive shape loads correctly when told to use too high a bevel percentage.
+int UtcDaliVisualFactoryGetPrimitiveVisual15(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual5: Request primitive visual to display a bevelled cube" );
+ tet_infoline("UtcDaliVisualFactoryGetPrimitiveVisual15: Request primitive visual with too high a bevel percentage.");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
//Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
- propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::BEVELLED_CUBE );
- propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
- propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.7f );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE);
+ propertyMap.Insert(PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE);
+ propertyMap.Insert(PrimitiveVisual::Property::BEVEL_PERCENTAGE, Property::Value(2.0f));
//Test to see if shape loads correctly.
- TestPrimitiveVisualWithProperties( propertyMap, application );
+ TestPrimitiveVisualWithProperties(propertyMap, application);
END_TEST;
}
-//Test if primitive shape loads an octahedron correctly.
-int UtcDaliVisualFactoryGetPrimitiveVisual6(void)
+//Test if primitive shape loads correctly when told to use too low a bevel smoothness.
+int UtcDaliVisualFactoryGetPrimitiveVisual16(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual6: Request primitive visual to display an octahedron" );
+ tet_infoline("UtcDaliVisualFactoryGetPrimitiveVisual16: Request primitive visual with too low a bevel smoothness.");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
//Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
- propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::OCTAHEDRON );
- propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE);
+ propertyMap.Insert(PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE);
+ propertyMap.Insert(PrimitiveVisual::Property::BEVEL_SMOOTHNESS, Property::Value(-1.0f));
//Test to see if shape loads correctly.
- TestPrimitiveVisualWithProperties( propertyMap, application );
+ TestPrimitiveVisualWithProperties(propertyMap, application);
END_TEST;
}
-//Test if primitive shape loads a cone correctly.
-int UtcDaliVisualFactoryGetPrimitiveVisual7(void)
+//Test if primitive shape loads correctly when told to use too high a bevel smoothness.
+int UtcDaliVisualFactoryGetPrimitiveVisual17(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual7: Request primitive visual to display a cone" );
+ tet_infoline("UtcDaliVisualFactoryGetPrimitiveVisual17: Request primitive visual with too high a bevel smoothness.");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
//Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
- propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONE );
- propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
- propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
- propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
- propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE);
+ propertyMap.Insert(PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE);
+ propertyMap.Insert(PrimitiveVisual::Property::BEVEL_SMOOTHNESS, Property::Value(2.0f));
//Test to see if shape loads correctly.
- TestPrimitiveVisualWithProperties( propertyMap, application );
+ TestPrimitiveVisualWithProperties(propertyMap, application);
END_TEST;
}
-//Test if primitive shape loads correctly when light position is manually set.
-int UtcDaliVisualFactoryGetPrimitiveVisual8(void)
+//Test if primitive shape loads a conic section correctly.
+int UtcDaliVisualFactoryGetPrimitiveVisual18(void)
{
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual8: Request primitive visual with set light position" );
+ tet_infoline("UtcDaliVisualFactoryGetPrimitiveVisual18: Request primitive visual to display a conic section");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
//Set up visual properties.
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
- propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
- propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
- propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.0, 1.0, 2.0 ) );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE);
+ propertyMap.Insert(PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONICAL_FRUSTUM);
+ propertyMap.Insert(PrimitiveVisual::Property::MIX_COLOR, Vector4(0.5, 0.5, 0.5, 1.0));
+ propertyMap.Insert(PrimitiveVisual::Property::SLICES, 10);
+ propertyMap.Insert(PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f);
+ propertyMap.Insert(PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f);
+ propertyMap.Insert(PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f);
//Test to see if shape loads correctly.
- TestPrimitiveVisualWithProperties( propertyMap, application );
+ TestPrimitiveVisualWithProperties(propertyMap, application);
END_TEST;
}
//Set up test application first, so everything else can be handled.
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisualN1: Request primitive visual without shape" );
+ tet_infoline("UtcDaliVisualFactoryGetPrimitiveVisualN1: Request primitive visual without shape");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
//Set up visual properties, without supplying shape.
Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE);
//Test to see if shape loads regardless of missing input.
- TestPrimitiveVisualWithProperties( propertyMap, application );
+ TestPrimitiveVisualWithProperties(propertyMap, application);
END_TEST;
}
-int UtcDaliVisualFactoryGetBatchImageVisual1(void)
+int UtcDaliVisualFactoryGetAnimatedImageVisual1(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetBatchImageVisual1: Request a Batch Image visual with a Property::Map" );
+ tet_infoline("UtcDaliVisualFactoryGetAnimatedImageVisual1: Request animated image visual with a gif url");
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
+ Visual::Base visual = factory.CreateVisual(TEST_GIF_FILE_NAME, ImageDimensions());
+ DALI_TEST_CHECK(visual);
- Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
- propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
- propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
+ DummyControl actor = DummyControl::New(true);
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+ actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ application.GetScene().Add(actor);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ // renderer is added to actor
+ DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
+ Renderer renderer = actor.GetRendererAt(0u);
+ DALI_TEST_CHECK(renderer);
+
+ DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
+ textureTrace.Reset();
+
+ // Force the timer used by the animatedImageVisual to tick,
+ Dali::Timer timer = Timer::New(0);
+ timer.MockEmitSignal();
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
+ textureTrace.Reset();
+
+ // Force the timer used by the animatedImageVisual to tick,
+ timer.MockEmitSignal();
+ application.SendNotification();
+ application.Render();
- Visual::Base visual = factory.CreateVisual( propertyMap );
- DALI_TEST_CHECK( visual );
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
- Actor actor = Actor::New();
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
+ textureTrace.Reset();
- actor.SetSize( 200.0f, 200.0f );
- Stage::GetCurrent().Add( actor );
- visual.SetSize( Vector2( 200.0f, 200.0f ) );
+ // Force the timer used by the animatedImageVisual to tick,
+ timer.MockEmitSignal();
+ application.SendNotification();
+ application.Render();
- // Test SetOnStage().
- visual.SetOnStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
application.SendNotification();
application.Render();
+ DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
+ textureTrace.Reset();
- // Test SetOffStage().
- visual.SetOffStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+ // Test SetOffScene().
+ actor.Unparent();
+ DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
END_TEST;
}
-int UtcDaliVisualFactoryGetBatchImageVisual2(void)
+int UtcDaliVisualFactoryGetAnimatedImageVisual2(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetBatchImageVisual2: Request Batch Image visual from an Image Visual with batchingEnabled set" );
-
- VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
+ tet_infoline("UtcDaliVisualFactoryGetAnimatedImageVisual2: Request animated image visual with a Property::Map, test custom wrap mode and pixel area");
- Property::Map propertyMap;
- // Create a normal Image Visual.
- propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
- // Instruct the factory to change Image Visuals to Batch-Image Visuals.
- propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("pixelArea", Property::Type::VECTOR4),
+ UniformData("wrapMode", Property::Type::VECTOR2),
+ };
- // Properties for the Batch-Image Visual.
- propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
- Visual::Base visual = factory.CreateVisual( propertyMap );
- DALI_TEST_CHECK( visual );
+ const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
+ Property::Map propertyMap;
+ propertyMap.Add(Toolkit::Visual::Property::TYPE, Visual::IMAGE)
+ .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME)
+ .Add(ImageVisual::Property::PIXEL_AREA, pixelArea)
+ .Add(ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT)
+ .Add(ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT);
- // Check that a Batch-Image visual was created instead of an Image visual.
- Property::Map resultMap;
- visual.CreatePropertyMap( resultMap );
+ Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
- Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<int>(), (int)Visual::IMAGE, TEST_LOCATION );
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+ TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
+ texParameterTrace.Enable(true);
- Actor actor = Actor::New();
+ DummyControl actor = DummyControl::New(true);
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
+ actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ application.GetScene().Add(actor);
- actor.SetSize( 200.0f, 200.0f );
- Stage::GetCurrent().Add( actor );
- visual.SetSize( Vector2( 200.0f, 200.0f ) );
+ application.SendNotification();
+ application.Render();
- // Test SetOnStage().
- visual.SetOnStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
application.SendNotification();
application.Render();
- // Test SetOffStage().
- visual.SetOffStage( actor );
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+ DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
+
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
+
+ // For animated image visual, the wrapping is handled manually in shader, so the following gl function should not be called
+ std::stringstream out;
+ out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
+ DALI_TEST_CHECK(!texParameterTrace.FindMethodAndParams("TexParameteri", out.str()));
+ out.str("");
+ out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
+ DALI_TEST_CHECK(!texParameterTrace.FindMethodAndParams("TexParameteri", out.str()));
+
+ // test the uniforms which used to handle the wrap mode
+ Renderer renderer = actor.GetRendererAt(0u);
+ DALI_TEST_CHECK(renderer);
+
+ Property::Value pixelAreaValue = renderer.GetProperty(renderer.GetPropertyIndex("pixelArea"));
+ DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION);
+ Vector4 pixelAreaUniform;
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
+ DALI_TEST_EQUALS(pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
+
+ Property::Value wrapModeValue = renderer.GetProperty(renderer.GetPropertyIndex("wrapMode"));
+ Vector2 wrapMode(WrapMode::MIRRORED_REPEAT - 1, WrapMode::REPEAT - 1);
+ DALI_TEST_EQUALS(wrapModeValue.Get<Vector2>(), wrapMode, TEST_LOCATION);
+ Vector2 wrapModeUniform;
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector2>("wrapMode", wrapModeUniform));
+ DALI_TEST_EQUALS(wrapMode, wrapModeUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
+
+ actor.Unparent();
+ DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
END_TEST;
}
-int UtcDaliVisualFactoryGetBatchImageVisual3(void)
+
+int UtcDaliVisualFactoryGetPreCompiler(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualFactoryGetBatchImageVisual3: Create an ImageView that uses a batched visual internally" );
+ tet_infoline("UtcDaliVisualFactoryGetAnimatedImageVisual2: Request animated image visual with a Property::Map, test custom wrap mode and pixel area");
+
+
+ std::vector<RawShaderData> precompiledShaderList;
+ DALI_TEST_CHECK(precompiledShaderList.size() == 0u); // before Get Shader
+ ShaderPreCompiler::Get().GetPreCompileShaderList(precompiledShaderList);
+ DALI_TEST_CHECK(precompiledShaderList.size() == 0u); // after Get Shader
VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
+ DALI_TEST_CHECK(factory);
+
+ factory.UsePreCompiledShader();
+
+ ShaderPreCompiler::Get().GetPreCompileShaderList(precompiledShaderList);
+ DALI_TEST_CHECK(precompiledShaderList.size() != 0u); // after Get Shader
- // Create a property-map that enables batching.
Property::Map propertyMap;
- propertyMap.Insert( Dali::Toolkit::ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
- propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
+ propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
- // Create an ImageView, passing the property-map in to instruct it to use batching.
- Toolkit::ImageView imageView = Toolkit::ImageView::New();
- imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, propertyMap );
+ DummyControl actor = DummyControl::New(true);
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
+ actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ application.GetScene().Add(actor);
- imageView.SetSize( 200.0f, 200.0f );
- Stage::GetCurrent().Add( imageView );
+ application.SendNotification();
+ application.Render();
END_TEST;
}