/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <toolkit-event-thread-callback.h>
#include <dali-toolkit-test-suite-utils.h>
+#include <dali/devel-api/actors/actor-devel.h>
#include <dali/devel-api/object/handle-devel.h>
#include <dali/devel-api/text-abstraction/font-client.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
+#include <dali-toolkit/devel-api/text/rendering-backend.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali-toolkit/devel-api/visual-factory/transition-data.h>
#include <dali-toolkit/devel-api/visuals/color-visual-properties-devel.h>
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_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
const char* TEST_RESOURCE_LOCATION = TEST_RESOURCE_DIR "/";
return true;
}
-void PrepareResourceImage( ToolkitTestApplication& application, unsigned int imageWidth, unsigned int imageHeight, Pixel::Format pixelFormat )
-{
- TestPlatformAbstraction& platform = application.GetPlatform();
- platform.SetClosestImageSize(Vector2( imageWidth, imageHeight));
-
- 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 );
- unsigned int initialColor = 0xFF;
- memset( pixbuffer, initialColor, imageHeight*imageWidth*bytesPerPixel);
-
- Integration::ResourcePointer resourcePtr(bitmap);
- platform.SetSynchronouslyLoadedResource( resourcePtr );
-}
} //namespace
void dali_visual_startup(void)
Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
- dummyControl.SetSize(200.f, 200.f);
- Stage::GetCurrent().Add( dummyControl );
+ dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+ application.GetScene().Add( dummyControl );
int depthIndex = dummyControl.GetRendererAt(0u).GetProperty<int>( Renderer::Property::DEPTH_INDEX );
DALI_TEST_EQUALS( naturalSize, Vector2::ZERO, TEST_LOCATION );
// image visual
- PrepareResourceImage( application, 100u, 200u, Pixel::RGBA8888 );
- Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
- Visual::Base imageVisual = factory.CreateVisual( image );
+ map.Clear();
+ map[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE;
+ map[Toolkit::ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
+ map[Toolkit::ImageVisual::Property::DESIRED_WIDTH] = 100.0f;
+ map[Toolkit::ImageVisual::Property::DESIRED_HEIGHT] = 200.0f;
+ Visual::Base imageVisual = factory.CreateVisual( map );
imageVisual.SetTransformAndSize(DefaultTransform(), controlSize );
imageVisual.GetNaturalSize(naturalSize);
END_TEST;
}
-int UtcDaliVisualSetOnOffStage(void)
+int UtcDaliVisualSetOnOffScene(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualSetOnOffStage" );
+ tet_infoline( "UtcDaliVisualSetOnOffScene" );
VisualFactory factory = VisualFactory::Get();
Property::Map propertyMap;
Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
- actor.SetSize(200.f, 200.f);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
application.SendNotification();
application.Render(0);
DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
application.SendNotification();
application.Render(0);
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
- Stage::GetCurrent().Remove( actor );
+ application.GetScene().Remove( actor );
application.SendNotification();
application.Render(0);
END_TEST;
}
-int UtcDaliVisualSetOnOffStage2(void)
+int UtcDaliVisualSetOnOffScene2(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualSetOnOffStage2" );
+ tet_infoline( "UtcDaliVisualSetOnOffScene2" );
VisualFactory factory = VisualFactory::Get();
Property::Map propertyMap;
Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
- actor.SetSize(200.f, 200.f);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
application.SendNotification();
application.Render(0);
DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
// First on/off
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
application.SendNotification();
application.Render(0);
auto textures = renderer.GetTextures();
DALI_TEST_CHECK( textures.GetTextureCount() != 0u );
- Stage::GetCurrent().Remove( actor );
+ application.GetScene().Remove( actor );
application.SendNotification();
application.Render(0);
DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
// Second on/off
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
application.SendNotification();
application.Render(0);
textures = renderer.GetTextures();
DALI_TEST_CHECK( textures.GetTextureCount() != 0u );
- Stage::GetCurrent().Remove( actor );
+ application.GetScene().Remove( actor );
application.SendNotification();
application.Render(0);
propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
propertyMap.Insert(Visual::Property::MIX_COLOR, Color::BLUE);
propertyMap.Insert( DevelVisual::Property::CORNER_RADIUS, 10.0f );
+ propertyMap.Insert( DevelVisual::Property::CORNER_RADIUS_POLICY, Toolkit::Visual::Transform::Policy::RELATIVE );
propertyMap.Insert( DevelColorVisual::Property::BLUR_RADIUS, 20.0f );
Visual::Base colorVisual = factory.CreateVisual( propertyMap );
DALI_TEST_CHECK( colorValue );
DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::BLUE );
- Property::Value* cornerRadiusValue = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::FLOAT );
+ Property::Value* cornerRadiusValue = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4 );
DALI_TEST_CHECK( cornerRadiusValue );
- DALI_TEST_CHECK( cornerRadiusValue->Get< float >() == 10.0f );
+ DALI_TEST_CHECK( cornerRadiusValue->Get< Vector4 >() == Vector4(10.0f, 10.0f, 10.0f, 10.0f) );
+
+ Property::Value* cornerRadiusPolicyValue = resultMap.Find( DevelVisual::Property::CORNER_RADIUS_POLICY, Property::INTEGER );
+ DALI_TEST_CHECK( cornerRadiusPolicyValue );
+ DALI_TEST_CHECK( cornerRadiusPolicyValue->Get< int >() == Toolkit::Visual::Transform::Policy::RELATIVE );
Property::Value* blurRadiusValue = resultMap.Find( DevelColorVisual::Property::BLUR_RADIUS, Property::FLOAT );
DALI_TEST_CHECK( blurRadiusValue );
DummyControl dummyControl = DummyControl::New(true);
Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, borderVisual );
- Stage::GetCurrent().Add( dummyControl );
+ application.GetScene().Add( dummyControl );
DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 1, TEST_LOCATION );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<bool>() == true );
- // Get an image visual with an image handle, and test the default property values
- PrepareResourceImage( application, 100u, 200u, Pixel::RGBA8888 );
- Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
- imageVisual = factory.CreateVisual(image);
- imageVisual.CreatePropertyMap( resultMap );
-
- value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<int>() == Visual::IMAGE );
-
- value = resultMap.Find( ImageVisual::Property::URL, Property::STRING );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<std::string>() == TEST_IMAGE_FILE_NAME );
-
- value = resultMap.Find( ImageVisual::Property::FITTING_MODE, Property::INTEGER );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<int>() == FittingMode::DEFAULT );
-
- value = resultMap.Find( ImageVisual::Property::SAMPLING_MODE, Property::INTEGER );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<int>() == SamplingMode::BOX );
-
- value = resultMap.Find( ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<int>() == 100 );
-
- value = resultMap.Find( ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<int>() == 200 );
-
- value = resultMap.Find( ImageVisual::Property::PIXEL_AREA, Property::VECTOR4 );
- DALI_TEST_CHECK( value );
- DALI_TEST_EQUALS( value->Get<Vector4>(), Vector4( 0.f, 0.f, 1.f, 1.f ), Math::MACHINE_EPSILON_100, TEST_LOCATION );
-
- value = resultMap.Find( ImageVisual::Property::WRAP_MODE_U, Property::INTEGER );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<int>() == WrapMode::DEFAULT);
-
- value = resultMap.Find( ImageVisual::Property::WRAP_MODE_V, Property::INTEGER );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<int>() == WrapMode::DEFAULT);
-
- value = resultMap.Find( "synchronousLoading", Property::BOOLEAN );
- DALI_TEST_CHECK( value );
- DALI_TEST_CHECK( value->Get<bool>() == false );
-
END_TEST;
}
Property::Map propertyMap;
propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::TEXT );
propertyMap.Insert( Visual::Property::MIX_COLOR, Color::BLACK );
- propertyMap.Insert( "renderingBackend", static_cast<int>( Toolkit::Text::DEFAULT_RENDERING_BACKEND ) );
+ propertyMap.Insert( "renderingBackend", static_cast<int>( Toolkit::DevelText::DEFAULT_RENDERING_BACKEND ) );
propertyMap.Insert( "enableMarkup", false );
propertyMap.Insert( "text", "Hello world" );
propertyMap.Insert( "fontFamily", "TizenSans" );
ToolkitTestApplication application;
tet_infoline( "UtcDaliAnimateBorderVisual Color" );
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("borderColor", Property::Type::VECTOR4),
+ UniformData("mixColor", Property::Type::VECTOR3),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
VisualFactory factory = VisualFactory::Get();
Property::Map propertyMap;
propertyMap.Insert(Visual::Property::TYPE, Visual::BORDER);
DummyControl actor = DummyControl::New(true);
Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, borderVisual );
- actor.SetSize(2000, 2000);
- actor.SetParentOrigin(ParentOrigin::CENTER);
- Stage::GetCurrent().Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
+ application.GetScene().Add(actor);
DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
Renderer renderer = actor.GetRendererAt(0);
- Property::Index borderColorIndex = DevelHandle::GetPropertyIndex( renderer, BorderVisual::Property::COLOR );
- Property::Index mixColorIndex = DevelHandle::GetPropertyIndex( renderer, Visual::Property::MIX_COLOR );
+ Property::Index borderColorIndex = renderer.GetPropertyIndex( BorderVisual::Property::COLOR );
+ Property::Index mixColorIndex = renderer.GetPropertyIndex( Visual::Property::MIX_COLOR );
Animation animation = dummyImpl.CreateTransition( transition );
ToolkitTestApplication application;
tet_infoline( "UtcDaliAnimateBorderVisual Size" );
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("borderSize", Property::Type::FLOAT),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
VisualFactory factory = VisualFactory::Get();
Property::Map propertyMap;
propertyMap.Insert(Visual::Property::TYPE, Visual::BORDER);
DummyControl actor = DummyControl::New(true);
Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, borderVisual );
- actor.SetSize(2000, 2000);
- actor.SetParentOrigin(ParentOrigin::CENTER);
- Stage::GetCurrent().Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
+ application.GetScene().Add(actor);
DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
Renderer renderer = actor.GetRendererAt(0);
- Property::Index index = DevelHandle::GetPropertyIndex( renderer, BorderVisual::Property::SIZE );
+ Property::Index index = renderer.GetPropertyIndex( BorderVisual::Property::SIZE );
Animation animation = Animation::New(4.0f);
animation.AnimateTo( Property(renderer, index), 9.0f );
ToolkitTestApplication application;
tet_infoline( "UtcDaliAnimateColorVisual mixColor" );
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("mixColor", Property::Type::VECTOR3),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
VisualFactory factory = VisualFactory::Get();
Property::Map propertyMap;
propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
DummyControl actor = DummyControl::New(true);
Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, borderVisual );
- actor.SetSize(2000, 2000);
- actor.SetParentOrigin(ParentOrigin::CENTER);
- Stage::GetCurrent().Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
+ application.GetScene().Add(actor);
DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
Renderer renderer = actor.GetRendererAt(0);
- Property::Index mixColorIndex = DevelHandle::GetPropertyIndex( renderer, ColorVisual::Property::MIX_COLOR );
+ Property::Index mixColorIndex = renderer.GetPropertyIndex( ColorVisual::Property::MIX_COLOR );
Property::Value blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::AUTO, TEST_LOCATION );
ToolkitTestApplication application;
tet_infoline( "UtcDaliAnimatePrimitiveVisual color" );
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("mixColor", Property::Type::VECTOR3),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
{
VisualFactory factory = VisualFactory::Get();
Property::Map propertyMap;
DummyControl actor = DummyControl::New(true);
Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
- actor.SetSize(2000, 2000);
- actor.SetParentOrigin(ParentOrigin::CENTER);
- actor.SetColor(Color::BLACK);
- Stage::GetCurrent().Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
+ actor.SetProperty( Actor::Property::COLOR,Color::BLACK);
+ application.GetScene().Add(actor);
DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
Renderer renderer = actor.GetRendererAt(0);
- Property::Index index = DevelHandle::GetPropertyIndex( renderer, PrimitiveVisual::Property::MIX_COLOR );
+ Property::Index index = renderer.GetPropertyIndex( PrimitiveVisual::Property::MIX_COLOR );
tet_infoline("Test that the renderer has the Primitive mix color");
DALI_TEST_CHECK( index != Property::INVALID_INDEX );
Dali::Toolkit::TransitionData transition = TransitionData::New( map );
Animation animation = dummyImpl.CreateTransition( transition );
- Property::Value blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
- DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::ON, TEST_LOCATION );
-
animation.AnimateTo( Property(actor, Actor::Property::COLOR), Color::WHITE );
animation.Play();
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ glAbstraction.EnableEnableDisableCallTrace( true );
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
+ std::ostringstream blendStr;
+ blendStr << std::hex << GL_BLEND;
+
application.SendNotification();
application.Render(0);
application.Render(2000u); // halfway point
DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("uColor", Vector4(0.5f, 0.5f, 0.5f, halfwayColor.a )), true, TEST_LOCATION );
DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", Vector3(halfwayColor) ), true, TEST_LOCATION );
+ DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str() ) );
+
+ glEnableStack.Reset();
+
application.Render(2001u); // go past end
application.SendNotification(); // Trigger signals
- DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("uColor", Vector4( 1.0f, 1.0f, 1.0f, TARGET_MIX_COLOR.a ) ), true, TEST_LOCATION );
DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", Vector3(TARGET_MIX_COLOR) ), true, TEST_LOCATION );
- blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
- DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::AUTO, TEST_LOCATION );
+ DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Disable", blendStr.str() ) );
actor.Unparent();
}
ToolkitTestApplication application;
tet_infoline( "UtcDaliAnimatedGradientVisual with default" );
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("start_point", Property::Type::VECTOR2),
+ UniformData("end_point", Property::Type::VECTOR2),
+ UniformData("start_color", Property::Type::VECTOR4),
+ UniformData("end_color", Property::Type::VECTOR4),
+ UniformData("rotate_center", Property::Type::VECTOR2),
+ UniformData("rotate_angle", Property::Type::FLOAT),
+ UniformData("gradient_offset", Property::Type::FLOAT),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
{
VisualFactory factory = VisualFactory::Get();
Property::Map propertyMap;
DummyControl actor = DummyControl::New(true);
Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
- actor.SetSize(2000, 2000);
- actor.SetParentOrigin(ParentOrigin::CENTER);
- actor.SetColor(Color::BLACK);
- Stage::GetCurrent().Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
+ actor.SetProperty( Actor::Property::COLOR,Color::BLACK);
+ application.GetScene().Add(actor);
application.SendNotification();
application.Render(0);
ToolkitTestApplication application;
tet_infoline( "UtcDaliAnimatedGradientVisual with full-option" );
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("start_point", Property::Type::VECTOR2),
+ UniformData("end_point", Property::Type::VECTOR2),
+ UniformData("start_color", Property::Type::VECTOR4),
+ UniformData("end_color", Property::Type::VECTOR4),
+ UniformData("rotate_center", Property::Type::VECTOR2),
+ UniformData("rotate_angle", Property::Type::FLOAT),
+ UniformData("gradient_offset", Property::Type::FLOAT),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
{
float _delay[4] = {0.0f, -1.35f, 0.15f, -0.4f}; // fract(_delay) must NOT be 1/4, 2/4, 3/4. cause we don't know progress is 1.0f or 0.0f
int _direction[2] = {0, 1};
DummyControl actor = DummyControl::New( true );
Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>( actor.GetImplementation() );
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
- actor.SetSize( 2000, 2000 );
- actor.SetParentOrigin(ParentOrigin::CENTER);
- actor.SetColor(Color::BLACK);
- Stage::GetCurrent().Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
+ actor.SetProperty( Actor::Property::COLOR,Color::BLACK);
+ application.GetScene().Add(actor);
application.SendNotification();
application.Render( 0 );
ToolkitTestApplication application;
tet_infoline( "UtcDaliAnimatedGradientVisual with full-option use string key" );
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("start_point", Property::Type::VECTOR2),
+ UniformData("end_point", Property::Type::VECTOR2),
+ UniformData("start_color", Property::Type::VECTOR4),
+ UniformData("end_color", Property::Type::VECTOR4),
+ UniformData("rotate_center", Property::Type::VECTOR2),
+ UniformData("rotate_angle", Property::Type::FLOAT),
+ UniformData("gradient_offset", Property::Type::FLOAT),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
{
float _delay[4] = {0.0f, -1.35f, 0.15f, -0.4f}; // fract(_delay) must NOT be 1/4, 2/4, 3/4. cause we don't know progress is 1.0f or 0.0f
int _direction[2] = {0, 1};
DummyControl actor = DummyControl::New( true );
Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>( actor.GetImplementation() );
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
- actor.SetSize( 2000, 2000 );
- actor.SetParentOrigin(ParentOrigin::CENTER);
- actor.SetColor(Color::BLACK);
- Stage::GetCurrent().Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
+ actor.SetProperty( Actor::Property::COLOR,Color::BLACK);
+ application.GetScene().Add(actor);
application.SendNotification();
application.Render( 0 );
//Put the visual on the stage
DummyControl actor = DummyControl::New(true);
Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
- actor.SetSize(2000, 2000);
- actor.SetParentOrigin(ParentOrigin::CENTER);
- Stage::GetCurrent().Add(actor);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
+ actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
+ application.GetScene().Add(actor);
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
dummyImpl.SetLayout( DummyControl::Property::TEST_VISUAL, transform );
DALI_TEST_EQUALS( extraSize, Vector2(0.5f,0.5f), TEST_LOCATION );
}
+int UtcDaliVisualSetTransform01(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualSetTransform: ColorVisual" );
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
+ propertyMap.Insert(Visual::Property::OPACITY, 0.5f);
+ propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+ TestTransform( application, visual );
+ TestMixColor( visual, ColorVisual::Property::MIX_COLOR, Color::BLUE );
+
+ END_TEST;
+}
+
int UtcDaliVisualSetTransform0(void)
{
ToolkitTestApplication application;
int UtcDaliVisualSetTransform5(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualSetTransform: ImageVisual from Image" );
-
- VisualFactory factory = VisualFactory::Get();
- Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
- Visual::Base visual = factory.CreateVisual(image);
- TestTransform( application, visual );
- TestMixColor( visual, Visual::Property::MIX_COLOR, Color::WHITE );
-
- END_TEST;
-}
-
-int UtcDaliVisualSetTransform6(void)
-{
- ToolkitTestApplication application;
tet_infoline( "UtcDaliVisualSetTransform: ImageVisual for URL " );
VisualFactory factory = VisualFactory::Get();
END_TEST;
}
-int UtcDaliVisualSetTransform7(void)
+int UtcDaliVisualSetTransform6(void)
{
ToolkitTestApplication application;
tet_infoline( "UtcDaliVisualSetTransform: NPatch visual" );
Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
dummyImpl.SetLayout( DummyControl::Property::TEST_VISUAL, transformMap );
- dummy.SetSize(2000, 2000);
- dummy.SetParentOrigin(ParentOrigin::CENTER);
- Stage::GetCurrent().Add(dummy);
+ dummy.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
+ dummy.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
+ application.GetScene().Add(dummy);
application.SendNotification();
Renderer renderer = dummy.GetRendererAt( 0 );
DummyControl control = DummyControl::New(true);
control.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
- Stage::GetCurrent().Add( control );
+ application.GetScene().Add( control );
Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>( control.GetImplementation() );
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, opaqueGradientVisual );
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION );
- dummyControl.SetSize(200.f, 200.f);
+ dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
tet_infoline( "Add control with visual to stage and check renderer count is 1" );
- Stage::GetCurrent().Add( dummyControl );
+ application.GetScene().Add( dummyControl );
application.SendNotification();
application.Render();
DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 1, TEST_LOCATION );
tet_infoline( "Remove control with visual from stage and check renderer count is 0" );
- Stage::GetCurrent().Remove( dummyControl );
+ application.GetScene().Remove( dummyControl );
application.SendNotification();
application.Render();
tet_infoline( "Re-add control with visual to stage and check renderer count is still 1" );
- Stage::GetCurrent().Add( dummyControl );
+ application.GetScene().Add( dummyControl );
application.SendNotification();
application.Render();
Property::Map propertyMap;
propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::TEXT );
propertyMap.Insert( "mixColor", Color::WHITE );
- propertyMap.Insert( "renderingBackend", static_cast<int>( Toolkit::Text::DEFAULT_RENDERING_BACKEND ) );
+ propertyMap.Insert( "renderingBackend", static_cast<int>( Toolkit::DevelText::DEFAULT_RENDERING_BACKEND ) );
propertyMap.Insert( "enableMarkup", false );
propertyMap.Insert( "text", "Hello world" );
propertyMap.Insert( "fontFamily", "TizenSans" );
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, textVisual );
DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION );
- dummyControl.SetSize(200.f, 200.f);
- dummyControl.SetParentOrigin( ParentOrigin::CENTER );
+ dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+ dummyControl.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
- Stage::GetCurrent().Add( dummyControl );
+ application.GetScene().Add( dummyControl );
application.SendNotification();
application.Render();
textVisual.SetDepthIndex( 1 );
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, textVisual );
- dummyControl.SetSize( 720.f, 640.f );
+ dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 720.f, 640.f ) );
application.SendNotification(); // force process events to ensure text visual
// adds renderer to the dummy control in OnRelayout
Property::Map propertyMap;
propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::TEXT );
propertyMap.Insert( "mixColor", Color::WHITE );
- propertyMap.Insert( "renderingBackend", static_cast<int>( Toolkit::Text::DEFAULT_RENDERING_BACKEND ) );
+ propertyMap.Insert( "renderingBackend", static_cast<int>( Toolkit::DevelText::DEFAULT_RENDERING_BACKEND ) );
propertyMap.Insert( "enableMarkup", false );
propertyMap.Insert( "text", "Hello world" );
propertyMap.Insert( "fontFamily", "TizenSans" );
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, textVisual );
DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION );
- dummyControl.SetSize(200.f, 200.f);
- dummyControl.SetParentOrigin( ParentOrigin::CENTER );
+ dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+ dummyControl.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
- Stage::GetCurrent().Add( dummyControl );
+ application.GetScene().Add( dummyControl );
application.SendNotification();
application.Render();
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, anotherTestVisual2Replacement );
DALI_TEST_EQUALS( anotherTestVisual2Replacement.GetDepthIndex(), 2000, TEST_LOCATION );
- dummyControl.SetSize(200.f, 200.f);
- Stage::GetCurrent().Add( dummyControl );
+ dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+ application.GetScene().Add( dummyControl );
END_TEST;
}
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, testVisual2 );
DALI_TEST_CHECK( testVisual2.GetDepthIndex() > testVisual1.GetDepthIndex() );
- dummyControl.SetSize(200.f, 200.f);
- Stage::GetCurrent().Add( dummyControl );
+ dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+ application.GetScene().Add( dummyControl );
END_TEST;
}
DALI_TEST_EQUALS( testVisual3.GetDepthIndex(), 300, TEST_LOCATION );
DALI_TEST_EQUALS( DevelControl::IsVisualEnabled( dummyImpl, DummyControl::Property::TEST_VISUAL2 ), true, TEST_LOCATION );
- dummyControl.SetSize(200.f, 200.f);
- Stage::GetCurrent().Add( dummyControl );
-
- END_TEST;
-}
-
-int UtcDaliColorVisualRenderIfTransparentProperty(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "Test the renderIfTransparent property of ColorVisual" );
-
- VisualFactory factory = VisualFactory::Get();
- Property::Map propertyMap;
- propertyMap.Insert( Visual::Property::TYPE, Visual::COLOR );
- propertyMap.Insert( ColorVisual::Property::MIX_COLOR, Color::BLUE );
-
- tet_infoline( "Check default value" );
- {
- Visual::Base testVisual = factory.CreateVisual( propertyMap );
- Property::Map returnedMap;
- testVisual.CreatePropertyMap( returnedMap );
-
- Property::Value* renderIfTransparentProperty = returnedMap.Find( DevelColorVisual::Property::RENDER_IF_TRANSPARENT );
- DALI_TEST_CHECK( renderIfTransparentProperty );
- DALI_TEST_EQUALS( renderIfTransparentProperty->Get< bool >(), false, TEST_LOCATION );
- }
-
- propertyMap.Insert( DevelColorVisual::Property::RENDER_IF_TRANSPARENT, true );
-
- tet_infoline( "Ensure set to value required" );
- {
- Visual::Base testVisual = factory.CreateVisual( propertyMap );
- Property::Map returnedMap;
- testVisual.CreatePropertyMap( returnedMap );
-
- Property::Value* renderIfTransparentProperty = returnedMap.Find( DevelColorVisual::Property::RENDER_IF_TRANSPARENT );
- DALI_TEST_CHECK( renderIfTransparentProperty );
- DALI_TEST_EQUALS( renderIfTransparentProperty->Get< bool >(), true, TEST_LOCATION );
- }
-
- propertyMap[ DevelColorVisual::Property::RENDER_IF_TRANSPARENT ] = Color::BLUE;
-
- tet_infoline( "Ensure it returns default value if set to wrong type" );
- {
- Visual::Base testVisual = factory.CreateVisual( propertyMap );
- Property::Map returnedMap;
- testVisual.CreatePropertyMap( returnedMap );
-
- Property::Value* renderIfTransparentProperty = returnedMap.Find( DevelColorVisual::Property::RENDER_IF_TRANSPARENT );
- DALI_TEST_CHECK( renderIfTransparentProperty );
- DALI_TEST_EQUALS( renderIfTransparentProperty->Get< bool >(), false, TEST_LOCATION );
- }
+ dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+ application.GetScene().Add( dummyControl );
END_TEST;
}
Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
- dummy.SetSize( 200.f, 200.f );
- dummy.SetParentOrigin( ParentOrigin::CENTER );
- Stage::GetCurrent().Add( dummy );
+ dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+ dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+ application.GetScene().Add( dummy );
application.SendNotification();
application.Render();
int UtcDaliVisualRoundedCorner(void)
{
+#ifdef OLD_GRAPHICS_TEST
ToolkitTestApplication application;
tet_infoline( "UtcDaliVisualRoundedCorner" );
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("cornerRadius", Property::Type::VECTOR4),
+ UniformData("cornerRadiusPolicy", Property::Type::FLOAT),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
// image visual
{
VisualFactory factory = VisualFactory::Get();
Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
- dummy.SetSize( 200.f, 200.f );
- dummy.SetParentOrigin( ParentOrigin::CENTER );
- Stage::GetCurrent().Add( dummy );
+ dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+ dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+ application.GetScene().Add( dummy );
application.SendNotification();
application.Render();
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< Vector4 >( "cornerRadius", Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius) ), true, TEST_LOCATION );
+ // Default corner radius policy is absolute.
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION );
}
- // color visual
+ // color visual 1
{
VisualFactory factory = VisualFactory::Get();
Property::Map properties;
properties[Visual::Property::TYPE] = Visual::COLOR;
properties[ColorVisual::Property::MIX_COLOR] = Color::BLUE;
properties["cornerRadius"] = cornerRadius;
+ properties["cornerRadiusPolicy"] = Toolkit::Visual::Transform::Policy::ABSOLUTE;
+
+ 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 );
+
+ dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+ dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+ application.GetScene().Add( dummy );
+
+ application.SendNotification();
+ application.Render();
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< Vector4 >( "cornerRadius", Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius) ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION );
+ }
+
+ // color visual 2
+ {
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map properties;
+ Vector4 cornerRadius(0.5f, 0.5f, 0.5f, 0.3f);
+
+ properties[Visual::Property::TYPE] = Visual::COLOR;
+ properties[ColorVisual::Property::MIX_COLOR] = Color::BLUE;
+ properties[DevelVisual::Property::CORNER_RADIUS] = cornerRadius;
+ properties[DevelVisual::Property::CORNER_RADIUS_POLICY] = Toolkit::Visual::Transform::Policy::RELATIVE;
Visual::Base visual = factory.CreateVisual( properties );
Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
- dummy.SetSize( 200.f, 200.f );
- dummy.SetParentOrigin( ParentOrigin::CENTER );
- Stage::GetCurrent().Add( dummy );
+ dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+ dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+ application.GetScene().Add( dummy );
application.SendNotification();
application.Render();
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< Vector4 >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::RELATIVE ), true, TEST_LOCATION );
+ }
+
+ // color visual 3 - invalid value
+ {
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map properties;
+ Vector4 cornerRadius(30.0f, 30.0f, 30.0f, 20.0f);
+
+ properties[Visual::Property::TYPE] = Visual::COLOR;
+ properties[ColorVisual::Property::MIX_COLOR] = Color::BLUE;
+ properties[DevelVisual::Property::CORNER_RADIUS] = cornerRadius;
+ properties[DevelVisual::Property::CORNER_RADIUS_POLICY] = -1; // Set an invalid value
+
+ 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 );
+
+ dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+ dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+ application.GetScene().Add( dummy );
+
+ application.SendNotification();
+ application.Render();
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< Vector4 >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+ // Default corner radius policy is absolute.
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION );
}
// gradient visual
Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
- dummy.SetSize( 200.f, 200.f );
- dummy.SetParentOrigin( ParentOrigin::CENTER );
- Stage::GetCurrent().Add( dummy );
+ dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+ dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+ application.GetScene().Add( dummy );
application.SendNotification();
application.Render();
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< Vector4 >( "cornerRadius", Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius) ), true, TEST_LOCATION );
+ // Default corner radius policy is absolute.
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION );
}
+ // animated image visual
+ {
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map properties;
+ Vector4 cornerRadius(24.0f, 23.0f, 22.0f, 21.0f);
+
+ properties[Visual::Property::TYPE] = Visual::ANIMATED_IMAGE;
+ properties[ImageVisual::Property::URL] = TEST_GIF_FILE_NAME;
+ properties[DevelVisual::Property::CORNER_RADIUS] = cornerRadius.x + 10.0f; // Dummy Input
+ properties[DevelVisual::Property::CORNER_RADIUS] = cornerRadius;
+ properties["cornerRadiusPolicy"] = Toolkit::Visual::Transform::Policy::ABSOLUTE;
+
+ 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 );
+
+ dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+ dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+ application.GetScene().Add( dummy );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< Vector4 >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION );
+ }
+
+ // vector image visual
+ {
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map properties;
+ Vector4 cornerRadius(27.0f, 72.0f, 11.0f, 500.5f);
+
+ properties[Visual::Property::TYPE] = Visual::SVG;
+ properties[ImageVisual::Property::URL] = TEST_SVG_FILE_NAME;
+ properties[DevelVisual::Property::CORNER_RADIUS] = cornerRadius;
+
+ 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 );
+
+ dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+ dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+ application.GetScene().Add( dummy );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< Vector4 >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+ // Default corner radius policy is absolute.
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION );
+ }
+
+ // animated vector image visual
+ {
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map properties;
+ float cornerRadius = 1.3f;
+
+ properties[Visual::Property::TYPE] = DevelVisual::ANIMATED_VECTOR_IMAGE;
+ properties[ImageVisual::Property::URL] = TEST_VECTOR_IMAGE_FILE_NAME;
+ properties["cornerRadius"] = Vector4(1.0f, 100.0f, 10.0f, 0.1f); // Dummy Input
+ properties["cornerRadius"] = cornerRadius;
+ properties[DevelVisual::Property::CORNER_RADIUS_POLICY] = Toolkit::Visual::Transform::Policy::RELATIVE;
+
+ 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 );
+
+ dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+ dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+ application.GetScene().Add( dummy );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< Vector4 >( "cornerRadius", Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius) ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::RELATIVE ), true, TEST_LOCATION );
+ }
+#else
+ tet_result(TET_PASS);
+#endif
+
END_TEST;
}
ToolkitTestApplication application;
tet_infoline( "UtcDaliColorVisualBlurRadius" );
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("blurRadius", Property::Type::FLOAT),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
VisualFactory factory = VisualFactory::Get();
Property::Map properties;
float blurRadius = 20.0f;
Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
- dummy.SetSize( 200.f, 200.f );
- dummy.SetParentOrigin( ParentOrigin::CENTER );
- Stage::GetCurrent().Add( dummy );
+ dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+ dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+ application.GetScene().Add( dummy );
application.SendNotification();
application.Render();
END_TEST;
}
+
+int UtcDaliVisualGetType(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualGetType" );
+
+ VisualFactory factory = VisualFactory::Get();
+
+ {
+ Property::Map properties;
+ properties[Visual::Property::TYPE] = Visual::BORDER;
+ Visual::Base visual = factory.CreateVisual( properties );
+
+ DALI_TEST_CHECK( visual.GetType() == Visual::BORDER );
+ }
+
+ {
+ Property::Map properties;
+ properties[Visual::Property::TYPE] = Visual::COLOR;
+ Visual::Base visual = factory.CreateVisual( properties );
+
+ DALI_TEST_CHECK( visual.GetType() == Visual::COLOR );
+ }
+
+ {
+ Property::Map properties;
+ properties[Visual::Property::TYPE] = Visual::GRADIENT;
+ properties[GradientVisual::Property::START_POSITION] = Vector2( -1.f, -1.f );
+ properties[GradientVisual::Property::END_POSITION] = Vector2( 1.f, 1.f );
+ properties[GradientVisual::Property::STOP_OFFSET] = Vector2(0.f, 1.f);
+ // propertyMap.Insert( GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT) ;
+ Property::Array stopColors;
+ stopColors.PushBack( Color::RED );
+ stopColors.PushBack( Color::GREEN );
+ properties[GradientVisual::Property::STOP_COLOR] = stopColors;
+ Visual::Base visual = factory.CreateVisual( properties );
+
+ DALI_TEST_CHECK( visual.GetType() == Visual::GRADIENT );
+ }
+
+ {
+ Property::Map properties;
+ properties[Visual::Property::TYPE] = Visual::IMAGE;
+ properties.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
+ Visual::Base visual = factory.CreateVisual( properties );
+
+ DALI_TEST_CHECK( visual.GetType() == Visual::IMAGE );
+ }
+
+ {
+ Property::Map properties;
+ properties[Visual::Property::TYPE] = Visual::MESH;
+ Visual::Base visual = factory.CreateVisual( properties );
+
+ DALI_TEST_CHECK( visual.GetType() == Visual::MESH );
+ }
+
+ {
+ Property::Map properties;
+ properties[Visual::Property::TYPE] = Visual::PRIMITIVE;
+ properties[PrimitiveVisual::Property::SHAPE] = PrimitiveVisual::Shape::CUBE;
+ Visual::Base visual = factory.CreateVisual( properties );
+
+ DALI_TEST_CHECK( visual.GetType() == Visual::PRIMITIVE );
+ }
+
+ {
+ Property::Map properties;
+ properties[Visual::Property::TYPE] = Visual::WIREFRAME;
+ Visual::Base visual = factory.CreateVisual( properties );
+
+ DALI_TEST_CHECK( visual.GetType() == Visual::WIREFRAME );
+ }
+
+ {
+ Property::Map properties;
+ properties[Visual::Property::TYPE] = Visual::TEXT;
+ Visual::Base visual = factory.CreateVisual( properties );
+
+ DALI_TEST_CHECK( visual.GetType() == Visual::TEXT );
+ }
+
+ {
+ Property::Map properties;
+ properties[Visual::Property::TYPE] = Visual::N_PATCH;
+ properties[ImageVisual::Property::URL] = TEST_NPATCH_FILE_NAME;
+ Visual::Base visual = factory.CreateVisual( properties );
+
+ DALI_TEST_CHECK( visual.GetType() == Visual::N_PATCH );
+ }
+
+ {
+ Property::Map properties;
+ properties[Visual::Property::TYPE] = Visual::SVG;
+ properties[ImageVisual::Property::URL] = TEST_SVG_FILE_NAME;
+ Visual::Base visual = factory.CreateVisual( properties );
+
+ DALI_TEST_CHECK( visual.GetType() == Visual::SVG );
+ }
+
+ {
+ Property::Map properties;
+ properties[Visual::Property::TYPE] = Visual::ANIMATED_IMAGE;
+ properties[ImageVisual::Property::URL] = TEST_GIF_FILE_NAME;
+ Visual::Base visual = factory.CreateVisual( properties );
+
+ DALI_TEST_CHECK( visual.GetType() == Visual::ANIMATED_IMAGE );
+ }
+
+ {
+ Property::Map properties;
+ properties[Visual::Property::TYPE] = DevelVisual::ANIMATED_GRADIENT;
+ Visual::Base visual = factory.CreateVisual( properties );
+
+ DALI_TEST_CHECK( visual.GetType() == static_cast<Visual::Type>( DevelVisual::ANIMATED_GRADIENT ) );
+ }
+
+ {
+ Property::Map properties;
+ properties[Visual::Property::TYPE] = DevelVisual::ANIMATED_VECTOR_IMAGE;
+ properties[ImageVisual::Property::URL] = TEST_VECTOR_IMAGE_FILE_NAME;
+ Visual::Base visual = factory.CreateVisual( properties );
+
+ DALI_TEST_CHECK( visual.GetType() == static_cast<Visual::Type>( DevelVisual::ANIMATED_VECTOR_IMAGE ) );
+ }
+
+ {
+ Property::Map properties;
+ properties[Visual::Property::TYPE] = DevelVisual::ARC;
+ Visual::Base visual = factory.CreateVisual( properties );
+
+ DALI_TEST_CHECK( visual.GetType() == static_cast<Visual::Type>( DevelVisual::ARC ) );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliVisualGetVisualProperty01(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualGetVisualProperty01: Test animatable property, Visual::Base, ColorVisual" );
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("mixColor", Property::Type::VECTOR3),
+ UniformData("offset", Property::Type::VECTOR2),
+ UniformData("size", Property::Type::VECTOR2),
+ UniformData("cornerRadius", Property::Type::VECTOR4),
+ UniformData("blurRadius", Property::Type::FLOAT),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
+ propertyMap.Insert(Visual::Property::MIX_COLOR, Color::BLUE);
+ propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS, Vector4(10.0f, 0.0f, 2.0f, 4.0f));
+ propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS_POLICY, Toolkit::Visual::Transform::Policy::RELATIVE);
+ propertyMap.Insert(DevelColorVisual::Property::BLUR_RADIUS, 20.0f);
+ Visual::Base colorVisual = factory.CreateVisual(propertyMap);
+
+ DummyControl dummyControl = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, colorVisual);
+ dummyControl[Actor::Property::SIZE] = Vector2(200.f, 200.f);
+ application.GetScene().Add(dummyControl);
+
+ application.SendNotification();
+ application.Render();
+
+ Vector3 targetColor(1.0f, 1.0f, 1.0f);
+ Vector2 targetOffset(0.05f, 0.05f);
+ Vector2 targetSize(1.1f, 1.1f);
+ float targetOpacity = 0.5f;
+ Vector4 targetCornerRadius(0.0f, 0.0f, 0.0f, 0.0f);
+ float targetBlurRadius = 10.0f;
+
+ Animation animation = Animation::New(1.0f);
+ animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Property::MIX_COLOR), targetColor);
+ animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Property::OPACITY), targetOpacity);
+ animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Transform::Property::OFFSET), targetOffset);
+ animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Transform::Property::SIZE), targetSize);
+ animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, DevelVisual::Property::CORNER_RADIUS), targetCornerRadius);
+ animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, DevelColorVisual::Property::BLUR_RADIUS), targetBlurRadius);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render();
+ application.Render(1001u); // End of animation
+
+ Property::Map resultMap;
+ colorVisual.CreatePropertyMap( resultMap );
+
+ // Test property values: they should be updated
+ Property::Value* colorValue = resultMap.Find(ColorVisual::Property::MIX_COLOR, Property::VECTOR4);
+ DALI_TEST_CHECK(colorValue);
+ DALI_TEST_EQUALS(colorValue->Get<Vector4>(), Vector4(targetColor.r, targetColor.g, targetColor.b, targetOpacity), TEST_LOCATION);
+
+ Property::Value* transformValue = resultMap.Find(Dali::Toolkit::Visual::Property::TRANSFORM);
+ Dali::Property::Map* transformMap = transformValue->GetMap();
+ DALI_TEST_CHECK(transformMap);
+
+ Property::Value* offsetValue = transformMap->Find(Toolkit::Visual::Transform::Property::OFFSET);
+ DALI_TEST_CHECK(offsetValue);
+ DALI_TEST_EQUALS(offsetValue->Get<Vector2>(), targetOffset, TEST_LOCATION);
+
+ Property::Value* sizeValue = transformMap->Find(Toolkit::Visual::Transform::Property::SIZE);
+ DALI_TEST_CHECK(sizeValue);
+ DALI_TEST_EQUALS(sizeValue->Get<Vector2>(), targetSize, TEST_LOCATION);
+
+ Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
+ DALI_TEST_CHECK(cornerRadiusValue);
+ DALI_TEST_EQUALS(cornerRadiusValue->Get< Vector4 >(), targetCornerRadius, TEST_LOCATION);
+
+ Property::Value* blurRadiusValue = resultMap.Find(DevelColorVisual::Property::BLUR_RADIUS, Property::FLOAT);
+ DALI_TEST_CHECK(blurRadiusValue);
+ DALI_TEST_EQUALS(blurRadiusValue->Get< float >(), targetBlurRadius, TEST_LOCATION);
+
+ // Test uniform values
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", targetColor), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector2>("offset", targetOffset), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector2>("size", targetSize), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("cornerRadius", targetCornerRadius), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("blurRadius", targetBlurRadius), true, TEST_LOCATION);
+
+ // Test not-supported property
+ Property property1 = DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Property::PREMULTIPLIED_ALPHA);
+ DALI_TEST_CHECK(!property1.object);
+ DALI_TEST_CHECK(property1.propertyIndex == Property::INVALID_INDEX);
+
+ // Test unregistered visual
+ Property property3 = DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL2, Visual::Property::MIX_COLOR);
+ DALI_TEST_CHECK(!property3.object);
+ DALI_TEST_CHECK(property3.propertyIndex == Property::INVALID_INDEX);
+
+ END_TEST;
+}
+
+int UtcDaliVisualGetVisualProperty02(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualGetVisualProperty02: Test animatable property" );
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("mixColor", Property::Type::VECTOR3),
+ UniformData("offset", Property::Type::VECTOR2),
+ UniformData("size", Property::Type::VECTOR2),
+ UniformData("cornerRadius", Property::Type::VECTOR4),
+ UniformData("blurRadius", Property::Type::FLOAT),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
+ Visual::Base colorVisual = factory.CreateVisual(propertyMap);
+
+ DummyControl dummyControl = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, colorVisual);
+ dummyControl[Actor::Property::SIZE] = Vector2(200.f, 200.f);
+ application.GetScene().Add(dummyControl);
+
+ application.SendNotification();
+ application.Render();
+
+ Vector3 targetColor(1.0f, 1.0f, 1.0f);
+ Vector2 targetOffset(0.05f, 0.05f);
+ Vector2 targetSize(1.1f, 1.1f);
+ float targetOpacity = 0.5f;
+ Vector4 targetCornerRadius(20.0f, 0.0f, 20.0f, 0.0f);
+ float targetBlurRadius = 10.0f;
+
+ // Should work when the properties are not set before
+ Animation animation = Animation::New(1.0f);
+ animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "mixColor"), targetColor);
+ animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "opacity"), targetOpacity);
+ animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "offset"), targetOffset);
+ animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "size"), targetSize);
+ animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "cornerRadius"), targetCornerRadius);
+ animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "blurRadius"), targetBlurRadius);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render();
+ application.Render(1001u); // End of animation
+
+ Property::Map resultMap;
+ colorVisual.CreatePropertyMap(resultMap);
+
+ // Test property values: they should be updated
+ Property::Value* colorValue = resultMap.Find(ColorVisual::Property::MIX_COLOR, Property::VECTOR4);
+ DALI_TEST_CHECK(colorValue);
+ DALI_TEST_EQUALS(colorValue->Get<Vector4>(), Vector4(targetColor.r, targetColor.g, targetColor.b, targetOpacity), TEST_LOCATION);
+
+ Property::Value* transformValue = resultMap.Find(Dali::Toolkit::Visual::Property::TRANSFORM);
+ Dali::Property::Map* transformMap = transformValue->GetMap();
+ DALI_TEST_CHECK(transformMap);
+
+ Property::Value* offsetValue = transformMap->Find(Toolkit::Visual::Transform::Property::OFFSET);
+ DALI_TEST_CHECK(offsetValue);
+ DALI_TEST_EQUALS(offsetValue->Get<Vector2>(), targetOffset, TEST_LOCATION);
+
+ Property::Value* sizeValue = transformMap->Find(Toolkit::Visual::Transform::Property::SIZE);
+ DALI_TEST_CHECK(sizeValue);
+ DALI_TEST_EQUALS(sizeValue->Get<Vector2>(), targetSize, TEST_LOCATION);
+
+ Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
+ DALI_TEST_CHECK(cornerRadiusValue);
+ DALI_TEST_EQUALS(cornerRadiusValue->Get< Vector4 >(), targetCornerRadius, TEST_LOCATION);
+
+ Property::Value* blurRadiusValue = resultMap.Find(DevelColorVisual::Property::BLUR_RADIUS, Property::FLOAT);
+ DALI_TEST_CHECK(blurRadiusValue);
+ DALI_TEST_EQUALS(blurRadiusValue->Get< float >(), targetBlurRadius, TEST_LOCATION);
+
+#ifdef OLD_GRAPHICS_TEST
+ // Test uniform values
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", targetColor), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector2>("offset", targetOffset), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector2>("size", targetSize), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("cornerRadius", targetCornerRadius), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("blurRadius", targetBlurRadius), true, TEST_LOCATION);
+#endif
+
+ END_TEST;
+}
+
+int UtcDaliVisualGetVisualProperty03(void)
+{
+#ifdef OLD_GRAPHICS_TEST
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualGetVisualProperty01: Test animatable property, ImageVisual" );
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("cornerRadius", Property::Type::VECTOR4),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
+ propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
+ Visual::Base imageVisual = factory.CreateVisual(propertyMap);
+
+ DummyControl dummyControl = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual);
+ dummyControl[Actor::Property::SIZE] = Vector2(200.f, 200.f);
+ application.GetScene().Add(dummyControl);
+
+ // Wait for image loading
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ float targetOpacity = 0.5f;
+ Vector4 targetCornerRadius(20.0f, 20.0f, 0.0f, 0.0f);
+
+ Animation animation = Animation::New(1.0f);
+ animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Property::OPACITY), targetOpacity);
+ animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, DevelVisual::Property::CORNER_RADIUS), targetCornerRadius);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render();
+ application.Render(1001u); // End of animation
+
+ Property::Map resultMap;
+ imageVisual.CreatePropertyMap( resultMap );
+
+ // Test property values: they should be updated
+ Property::Value* colorValue = resultMap.Find(Visual::Property::MIX_COLOR, Property::VECTOR4);
+ DALI_TEST_CHECK(colorValue);
+ DALI_TEST_EQUALS(colorValue->Get<Vector4>(), Vector4(1.0f, 1.0f, 1.0f, targetOpacity), TEST_LOCATION);
+
+ Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
+ DALI_TEST_CHECK(cornerRadiusValue);
+ DALI_TEST_EQUALS(cornerRadiusValue->Get< Vector4 >(), targetCornerRadius, TEST_LOCATION);
+
+ // Test uniform value
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("cornerRadius", targetCornerRadius), true, TEST_LOCATION);
+#else
+ tet_result(TET_PASS);
+#endif
+
+ END_TEST;
+}
+
+int UtcDaliVisualGetVisualProperty04(void)
+{
+#ifdef OLD_GRAPHICS_TEST
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualGetVisualProperty01: Test animatable property, GradientVisual" );
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("cornerRadius", Property::Type::VECTOR4),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
+ Vector2 start(-1.f, -1.f);
+ Vector2 end(1.f, 1.f);
+ Property::Array stopColors;
+ stopColors.PushBack( Color::RED );
+ stopColors.PushBack( Color::GREEN );
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::GRADIENT);
+ propertyMap.Insert(GradientVisual::Property::START_POSITION, start);
+ propertyMap.Insert(GradientVisual::Property::END_POSITION, end);
+ propertyMap.Insert(GradientVisual::Property::STOP_OFFSET, Vector2(0.f, 1.f));
+ propertyMap.Insert(GradientVisual::Property::SPREAD_METHOD, GradientVisual::SpreadMethod::REPEAT);
+ propertyMap.Insert(GradientVisual::Property::STOP_COLOR, stopColors);
+ Visual::Base gradientVisual = factory.CreateVisual(propertyMap);
+
+ DummyControl dummyControl = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, gradientVisual);
+ dummyControl[Actor::Property::SIZE] = Vector2(200.f, 200.f);
+ application.GetScene().Add(dummyControl);
+
+ application.SendNotification();
+ application.Render();
+
+ float targetOpacity = 0.5f;
+ Vector4 targetCornerRadius(20.0f, 30.0f, 10.0f, 20.0f);
+
+ Animation animation = Animation::New(1.0f);
+ animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Property::OPACITY), targetOpacity);
+ animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, DevelVisual::Property::CORNER_RADIUS), targetCornerRadius);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render();
+ application.Render(1001u); // End of animation
+
+ Property::Map resultMap;
+ gradientVisual.CreatePropertyMap( resultMap );
+
+ // Test property values: they should be updated
+ Property::Value* colorValue = resultMap.Find(Visual::Property::MIX_COLOR, Property::VECTOR4);
+ DALI_TEST_CHECK(colorValue);
+ DALI_TEST_EQUALS(colorValue->Get<Vector4>(), Vector4(1.0f, 1.0f, 1.0f, targetOpacity), TEST_LOCATION);
+
+ Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
+ DALI_TEST_CHECK(cornerRadiusValue);
+ DALI_TEST_EQUALS(cornerRadiusValue->Get< Vector4 >(), targetCornerRadius, TEST_LOCATION);
+
+ // Test uniform value
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("cornerRadius", targetCornerRadius), true, TEST_LOCATION);
+#else
+ tet_result(TET_PASS);
+#endif
+
+ END_TEST;
+}