#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-toolkit/devel-api/utility/npatch-utilities.h>
#include "dummy-control.h"
#include <dali/integration-api/debug.h>
namespace
{
-typedef Toolkit::Internal::NPatchLoader::StretchRanges StretchRanges;
+typedef Toolkit::NPatchUtility::StretchRanges StretchRanges;
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";
actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
application.SendNotification();
application.Render();
actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
application.SendNotification();
application.Render();
DALI_TEST_EQUALS( actualValue, Vector3(testColor), TEST_LOCATION );
DALI_TEST_EQUALS( actualColor.a, testColor.a, TEST_LOCATION );
- Stage::GetCurrent().Remove(actor);
+ application.GetScene().Remove(actor);
DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
END_TEST;
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f));
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f));
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
visual = factory.CreateVisual( map );
dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
- Stage::GetCurrent().Add( actor );
+ 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 );
DummyControl actor = DummyControl::New(true);
TestVisualRender( application, actor, visual );
- Stage::GetCurrent().Remove( actor );
+ application.GetScene().Remove( actor );
DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
END_TEST;
DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
- Stage::GetCurrent().Remove( actor );
+ application.GetScene().Remove( 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 );
- Stage::GetCurrent().Remove( actor );
+ application.GetScene().Remove( actor );
DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
}
textureTrace.Reset();
- ResourceImage image = ResourceImage::New( TEST_9_PATCH_FILE_NAME );
- Visual::Base nPatchVisual = factory.CreateVisual( image );
-
- DummyControl actor1 = DummyControl::New(true);
- TestVisualRender( application, actor1, nPatchVisual );
-
- DALI_TEST_EQUALS( textureTrace.CountMethod("BindTexture"), 0, TEST_LOCATION ); // The same texture should be used with the first visual.
-
- naturalSize = Vector2( 0.0f, 0.0f );
- nPatchVisual.GetNaturalSize( naturalSize );
- DALI_TEST_EQUALS( naturalSize, Vector2( imageSize.GetWidth() - 2.0f, imageSize.GetHeight() - 2.0f ), TEST_LOCATION );
-
END_TEST;
}
visual.GetNaturalSize( naturalSize );
DALI_TEST_EQUALS( naturalSize, Vector2( imageSize.GetWidth() - 2.0f, imageSize.GetHeight() - 2.0f ), TEST_LOCATION );
- Stage::GetCurrent().Remove( actor );
+ application.GetScene().Remove( actor );
DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
}
visual.GetNaturalSize( naturalSize );
DALI_TEST_EQUALS( naturalSize, Vector2( imageSize.GetWidth() - 2.0f, imageSize.GetHeight() - 2.0f ), TEST_LOCATION );
- Stage::GetCurrent().Remove( actor );
+ application.GetScene().Remove( actor );
DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
}
actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
actor.Unparent();
application.SendNotification();
dummyImpl.SetLayout( DummyControl::Property::TEST_VISUAL, transformMap );
dummy.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
dummy.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
- Stage::GetCurrent().Add(dummy);
+ application.GetScene().Add(dummy);
application.SendNotification();
application.Render();
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
- Stage::GetCurrent().Add( actor );
+ 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();
-
- // renderer is not added to actor until the rasterization is completed.
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
-
DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
// renderer is added to actor
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 );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
+ // Either application.SendNotification() or the trigger can now complete the task.
application.SendNotification();
application.Render();
-
- // renderer is not added to actor until the rasterization is completed.
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
-
DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
// renderer is added to actor
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
- Stage::GetCurrent().Add( actor );
+ 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();
-
- // renderer is not added to actor until the rasterization is completed.
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
-
DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
// renderer is added to actor
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.f, 200.f ) );
//Ensure set on stage.
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.f, 200.f ) );
//Ensure set on stage.
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.f, 200.f ) );
//Ensure set on stage.
//Set up visual properties.
Property::Map propertyMap;
propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
- propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONICAL_FRUSTRUM );
+ 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 );
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
application.SendNotification();
application.Render();
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();
+
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
textureTrace.Reset();
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();
- // Test SetOffStage().
+ // Test SetOffScene().
actor.Unparent();
DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
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 ) );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
application.SendNotification();
application.Render();