/*
- * Copyright (c) 2019 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.
ToolkitTestApplication application;
// Ensure the object is registered after creation
- ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
+ ObjectRegistry registry = application.GetCore().GetObjectRegistry();
DALI_TEST_CHECK( registry );
gObjectCreatedCallBackCalled = false;
END_TEST;
}
+int UtcDaliControlMoveConstructor(void)
+{
+ ToolkitTestApplication application;
+
+ Control control = Control::New();
+ DALI_TEST_EQUALS( 1, control.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+ control.SetProperty( Actor::Property::SENSITIVE, false );
+ DALI_TEST_CHECK( false == control.GetProperty< bool >( Actor::Property::SENSITIVE ) );
+
+ Control moved = std::move( control );
+ DALI_TEST_CHECK( moved );
+ DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+ DALI_TEST_CHECK( false == moved.GetProperty< bool >( Actor::Property::SENSITIVE ) );
+ DALI_TEST_CHECK( !control );
+
+ END_TEST;
+}
+
+int UtcDaliControlMoveAssignment(void)
+{
+ ToolkitTestApplication application;
+
+ Control control = Control::New();
+ DALI_TEST_EQUALS( 1, control.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+ control.SetProperty( Actor::Property::SENSITIVE, false );
+ DALI_TEST_CHECK( false == control.GetProperty< bool >( Actor::Property::SENSITIVE ) );
+
+ Control moved;
+ moved = std::move( control );
+ DALI_TEST_CHECK( moved );
+ DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+ DALI_TEST_CHECK( false == moved.GetProperty< bool >( Actor::Property::SENSITIVE ) );
+ DALI_TEST_CHECK( !control );
+
+ END_TEST;
+}
+
int UtcDaliControlDownCast(void)
{
ToolkitTestApplication application;
ToolkitTestApplication application;
Control control = Control::New();
- Stage::GetCurrent().Add( control );
+ application.GetScene().Add( control );
DALI_TEST_EQUALS( -1, control.GetProperty( DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
DALI_TEST_EQUALS( -1, control.GetProperty( DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
int UtcDaliControlKeyInputFocus(void)
{
ToolkitTestApplication application;
- Stage stage = Stage::GetCurrent();
+ Integration::Scene stage = application.GetScene();
DummyControl control;
DummyControl dummy = DummyControlImpl::New();
Actor actor = Actor::New();
- DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.OnSceneSignal().GetConnectionCount(), 0u, TEST_LOCATION );
Toolkit::Internal::Control& control = Toolkit::Internal::GetImplementation( dummy );
DummyControlImpl* dummyImpl = dynamic_cast<DummyControlImpl*>(&control);
END_TEST;
}
- actor.OnStageSignal().Connect( dummyImpl, &DummyControlImpl::CustomSlot1 );
- DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 1u, TEST_LOCATION );
+ actor.OnSceneSignal().Connect( dummyImpl, &DummyControlImpl::CustomSlot1 );
+ DALI_TEST_EQUALS( actor.OnSceneSignal().GetConnectionCount(), 1u, TEST_LOCATION );
DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, false, TEST_LOCATION );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, true, TEST_LOCATION );
dummyImpl->mCustomSlot1Called = false;
- actor.OnStageSignal().Disconnect( dummyImpl, &DummyControlImpl::CustomSlot1 );
- DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 0u, TEST_LOCATION );
- Stage::GetCurrent().Remove( actor );
- Stage::GetCurrent().Add( actor );
+ actor.OnSceneSignal().Disconnect( dummyImpl, &DummyControlImpl::CustomSlot1 );
+ DALI_TEST_EQUALS( actor.OnSceneSignal().GetConnectionCount(), 0u, TEST_LOCATION );
+ application.GetScene().Remove( actor );
+ application.GetScene().Add( actor );
DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, false, TEST_LOCATION );
}
END_TEST;
END_TEST;
}
- actor.OnStageSignal().Connect( dummyImpl, &DummyControlImpl::CustomSlot1 );
- DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 1u, TEST_LOCATION );
+ actor.OnSceneSignal().Connect( dummyImpl, &DummyControlImpl::CustomSlot1 );
+ DALI_TEST_EQUALS( actor.OnSceneSignal().GetConnectionCount(), 1u, TEST_LOCATION );
DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, false, TEST_LOCATION );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, true, TEST_LOCATION );
- Stage::GetCurrent().Remove( actor );
+ application.GetScene().Remove( actor );
}
// dummyControl automatically disconnects
- DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.OnSceneSignal().GetConnectionCount(), 0u, TEST_LOCATION );
const Vector3 ignoredSize( 20, 20, 0 );
actor.SetProperty( Actor::Property::SIZE, ignoredSize );
test.SetProperty( Actor::Property::SIZE, Vector3( 0.7f, 0.7f, 0.7f ) );
- Stage::GetCurrent().Add( test );
+ application.GetScene().Add( test );
application.SendNotification();
application.Render();
ToolkitTestApplication application;
Control control = Control::New();
- Stage::GetCurrent().Add( control );
-
- tet_infoline( "Set transparent, no renderers should be created" );
- control.SetBackgroundColor( Color::TRANSPARENT );
- application.SendNotification();
- application.Render();
- DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION );
-
- tet_infoline( "Set transparent alpha with positive RGB values, no renderers should be created, but returned color should reflect what we set" );
- const Vector4 alphaZero( 1.0f, 0.5f, 0.25f, 0.0f );
- control.SetBackgroundColor( alphaZero );
- application.SendNotification();
- application.Render();
- DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( GetControlBackgroundColor( control ), alphaZero, TEST_LOCATION );
+ control[Actor::Property::SIZE] = Vector2(100.0f, 100.0f);
+ application.GetScene().Add( control );
tet_infoline( "Set semi transparent alpha with positive RGB values, 1 renderer should be created, but returned color should reflect what we set" );
const Vector4 semiTransparent( 1.0f, 0.75f, 0.5f, 0.5f );
DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
DALI_TEST_EQUALS( GetControlBackgroundColor( control ), semiTransparent, TEST_LOCATION );
- tet_infoline( "Set transparent, ensure no renderers are created" );
+ Renderer renderer = control.GetRendererAt( 0 );
+ DALI_TEST_CHECK( renderer );
+
+ tet_infoline( "Set semi transparent alpha with positive RGB values, renderer should not be changed" );
+ const Vector4 newColor( 1.0f, 1.0f, 0.5f, 0.5f );
+ control.SetBackgroundColor( newColor );
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetControlBackgroundColor( control ), newColor, TEST_LOCATION );
+ DALI_TEST_EQUALS( renderer, control.GetRendererAt( 0 ), TEST_LOCATION );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& drawTrace = gl.GetDrawTrace();
+ drawTrace.Enable(true);
+
+ tet_infoline( "Set transparent, 1 renderer should be created, but ensure nothing is drawn" );
control.SetBackgroundColor( Color::TRANSPARENT );
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION );
+ DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), false, TEST_LOCATION);
+
+ drawTrace.Reset();
tet_infoline( "Set control to clip its children, a renderer should be created which will be transparent" );
control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
application.SendNotification();
application.Render();
+
DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION );
+ DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION);
tet_infoline( "Set a color, only 1 renderer should exist" );
control.SetBackgroundColor( Color::RED );
DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION );
- tet_infoline( "Disable clipping, no renderers" );
+ drawTrace.Reset();
+
+ tet_infoline( "Disable clipping, render nothing" );
control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED );
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( control.GetRendererCount(), 0u, TEST_LOCATION );
+
DALI_TEST_EQUALS( GetControlBackgroundColor( control ), Color::TRANSPARENT, TEST_LOCATION );
+ DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), false, TEST_LOCATION);
END_TEST;
}
ToolkitTestApplication application;
Control control = Control::New();
- Stage::GetCurrent().Add( control );
+ application.GetScene().Add( control );
DALI_TEST_EQUALS( control.HasKeyInputFocus(), control.GetProperty( Control::Property::KEY_INPUT_FOCUS ).Get< bool >(), TEST_LOCATION );
ToolkitTestApplication application;
Control control = Control::New();
- Stage::GetCurrent().Add( control );
+ application.GetScene().Add( control );
gKeyInputFocusCallBackCalled = false;
control.KeyInputFocusGainedSignal().Connect(&TestKeyInputFocusCallback);
ToolkitTestApplication application;
Control control = Control::New();
- Stage::GetCurrent().Add( control );
+ application.GetScene().Add( control );
gKeyInputFocusCallBackCalled = false;
control.KeyInputFocusLostSignal().Connect(&TestKeyInputFocusCallback);
control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
- Stage::GetCurrent().Add( control );
+ application.GetScene().Add( control );
application.SendNotification();
application.Render();
control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
- Stage::GetCurrent().Add( control );
+ application.GetScene().Add( control );
application.SendNotification();
application.Render();
DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
- Stage::GetCurrent().Add( control );
+ application.GetScene().Add( control );
application.SendNotification();
application.Render();
DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
- Stage::GetCurrent().Add( control );
+ application.GetScene().Add( control );
application.SendNotification();
application.Render();
tet_infoline( "Test to ensure that the control background transform does not get overwritten when adding to the stage" );
- Stage::GetCurrent().Add( control );
+ application.GetScene().Add( control );
application.SendNotification();
application.Render();
DALI_TEST_EQUALS( actor.IsResourceReady(), false, TEST_LOCATION );
DALI_TEST_EQUALS( static_cast<int>(resourceStatus), static_cast<int>(Toolkit::Visual::ResourceStatus::PREPARING), TEST_LOCATION );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
application.SendNotification();
application.Render();
propertyMap.Insert( ImageVisual::Property::URL, "invalid.jpg" );
control.SetProperty( Control::Property::BACKGROUND, propertyMap );
- Stage::GetCurrent().Add( control );
+ application.GetScene().Add( control );
application.SendNotification();
application.Render();
control.SetProperty( Control::Property::MARGIN, Extents( 20, 10, 0, 0 ) );
- Stage::GetCurrent().Add( control );
+ application.GetScene().Add( control );
application.SendNotification();
application.Render();
control.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
- Stage::GetCurrent().Add( control );
+ application.GetScene().Add( control );
application.SendNotification();
application.Render();
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual );
dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
- Stage::GetCurrent().Add( dummyControl );
+ application.GetScene().Add( dummyControl );
DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
tet_infoline( "Adding control to stage will in turn add the visual to the stage" );
- Stage::GetCurrent().Add( dummyControl );
+ application.GetScene().Add( dummyControl );
application.SendNotification();
application.Render();
tet_infoline( "No change in textures could occurs as already loaded and cached texture will be used" );