/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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 <dali.h>
#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali/integration-api/events/key-event-integ.h>
-#include <dali/integration-api/events/mouse-wheel-event-integ.h>
-#include <dali/integration-api/events/long-press-gesture-event.h>
-#include <dali/integration-api/events/pinch-gesture-event.h>
-#include <dali/integration-api/events/pan-gesture-event.h>
-#include <dali/integration-api/events/tap-gesture-event.h>
+#include <dali/integration-api/events/wheel-event-integ.h>
#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/events/hover-event-integ.h>
+
#include "dummy-control.h"
TapGestureDetector tap = dummyImpl.GetTapGestureDetector();
LongPressGestureDetector longPress = dummyImpl.GetLongPressGestureDetector();
- DALI_TEST_EQUALS( pinch.GetAttachedActors().empty(), false, TEST_LOCATION );
- DALI_TEST_EQUALS( pan.GetAttachedActors().empty(), false, TEST_LOCATION );
- DALI_TEST_EQUALS( tap.GetAttachedActors().empty(), false, TEST_LOCATION );
- DALI_TEST_EQUALS( longPress.GetAttachedActors().empty(), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( 0 == pinch.GetAttachedActorCount(), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( 0 == pan.GetAttachedActorCount(), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( 0 == tap.GetAttachedActorCount(), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( 0 == longPress.GetAttachedActorCount(), false, TEST_LOCATION );
dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
- DALI_TEST_EQUALS( pinch.GetAttachedActors().empty(), true, TEST_LOCATION );
- DALI_TEST_EQUALS( pan.GetAttachedActors().empty(), true, TEST_LOCATION );
- DALI_TEST_EQUALS( tap.GetAttachedActors().empty(), true, TEST_LOCATION );
- DALI_TEST_EQUALS( longPress.GetAttachedActors().empty(), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( 0 == pinch.GetAttachedActorCount(), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( 0 == pan.GetAttachedActorCount(), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( 0 == tap.GetAttachedActorCount(), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( 0 == longPress.GetAttachedActorCount(), true, TEST_LOCATION );
}
END_TEST;
}
DummyControl dummy = DummyControl::New(true);
dummy.SetSize( Vector2(100.0f, 100.0f ) );
- dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ dummy.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
Stage::GetCurrent().Add(dummy);
// Render and notify a couple of times
application.SendNotification();
application.Render();
- DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
DALI_TEST_CHECK( dummyImpl.pinchCalled == false );
- Integration::PinchGestureEvent pinch(Gesture::Started);
- pinch.scale = 10.0f;
- pinch.speed = 50.0f;
- pinch.centerPoint = Vector2(20.0f, 20.0f);
- application.ProcessEvent(pinch);
- DALI_TEST_CHECK( dummyImpl.pinchCalled == true );
- DALI_TEST_CHECK( dummyImpl.panCalled == false );
- Integration::PanGestureEvent pan(Gesture::Possible);
- pan.previousPosition = Vector2(10.0f, 20.0f);
- pan.currentPosition = Vector2(20.0f, 20.0f);
- pan.timeDelta = 10;
- pan.numberOfTouches = 1u;
- application.ProcessEvent(pan);
- pan.state = Gesture::Started;
- application.ProcessEvent(pan);
- DALI_TEST_CHECK( dummyImpl.panCalled == true );
+ TestGeneratePinch(application);
- DALI_TEST_CHECK( dummyImpl.tapCalled == false );
- Integration::TapGestureEvent tap(Gesture::Possible);
- tap.numberOfTaps = 1u;
- tap.numberOfTouches = 1u;
- tap.point = Vector2(50.0f, 50.0f);
- application.ProcessEvent(tap);
- tap.state = Gesture::Started;
- application.ProcessEvent(tap);
- DALI_TEST_CHECK( dummyImpl.tapCalled == true );
-
- DALI_TEST_CHECK( dummyImpl.longPressCalled == false );
- Integration::LongPressGestureEvent longPress(Gesture::Possible);
- longPress.numberOfTouches = 1u;
- longPress.point = Vector2(50.0f, 50.0f);
- application.ProcessEvent(longPress);
- longPress.state = Gesture::Started;
- application.ProcessEvent(longPress);
- DALI_TEST_CHECK( dummyImpl.longPressCalled == true );
- longPress.state = Gesture::Finished;
- application.ProcessEvent(longPress);
-
- Stage::GetCurrent().Remove(dummy);
- }
+ DALI_TEST_CHECK( dummyImpl.pinchCalled == true );
- // Ensure full code coverage
- {
- DummyControl dummy = DummyControl::New();
- dummy.SetSize( Vector2( 100.0f, 100.0f ) );
+ DALI_TEST_CHECK( dummyImpl.panCalled == false );
- dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add(dummy);
+ TestGenerateMiniPan(application);
- // Render and notify a couple of times
- application.SendNotification();
- application.Render();
- application.SendNotification();
- application.Render();
+ DALI_TEST_CHECK( dummyImpl.panCalled == true );
- DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
- dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
+ DALI_TEST_CHECK( dummyImpl.tapCalled == false );
- DALI_TEST_CHECK( dummy.GetCurrentScale().x != 10.0f );
- Integration::PinchGestureEvent pinch(Gesture::Started);
- pinch.scale = 10.0f;
- pinch.speed = 50.0f;
- pinch.centerPoint = Vector2(20.0f, 20.0f);
- application.ProcessEvent(pinch);
+ TestGenerateTap(application);
- // Render and notify a couple of times
- application.SendNotification();
- application.Render();
- application.SendNotification();
- application.Render();
- DALI_TEST_CHECK( dummy.GetCurrentScale().x == 10.0f );
+ DALI_TEST_CHECK( dummyImpl.tapCalled == true );
- Integration::PanGestureEvent pan(Gesture::Possible);
- pan.previousPosition = Vector2(10.0f, 20.0f);
- pan.currentPosition = Vector2(20.0f, 20.0f);
- pan.timeDelta = 10;
- pan.numberOfTouches = 1u;
- application.ProcessEvent(pan);
- pan.state = Gesture::Started;
- application.ProcessEvent(pan);
+ DALI_TEST_CHECK( dummyImpl.longPressCalled == false );
- Integration::TapGestureEvent tap(Gesture::Possible);
- tap.numberOfTaps = 1u;
- tap.numberOfTouches = 1u;
- tap.point = Vector2(50.0f, 50.0f);
- application.ProcessEvent(tap);
- tap.state = Gesture::Started;
- application.ProcessEvent(tap);
+ TestGenerateLongPress(application);
- Integration::LongPressGestureEvent longPress(Gesture::Possible);
- longPress.numberOfTouches = 1u;
- longPress.point = Vector2(50.0f, 50.0f);
- application.ProcessEvent(longPress);
- longPress.state = Gesture::Started;
- application.ProcessEvent(longPress);
- longPress.state = Gesture::Finished;
- application.ProcessEvent(longPress);
+ DALI_TEST_CHECK( dummyImpl.longPressCalled == true );
Stage::GetCurrent().Remove(dummy);
}
+
END_TEST;
}
{
DummyControl dummy = DummyControl::New( true );
Stage::GetCurrent().Add(dummy);
- DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
application.Render();
application.SendNotification();
DALI_TEST_EQUALS( dummyImpl.childAddCalled, false, TEST_LOCATION );
DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
- Actor actor = RenderableActor::New();
+ Actor actor = Actor::New();
dummy.Add(actor);
DALI_TEST_EQUALS( dummyImpl.childAddCalled, true, TEST_LOCATION );
DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
application.SendNotification();
DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
- Actor actor = RenderableActor::New();
+ Actor actor = Actor::New();
dummy.Add(actor);
DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
{
DummyControl dummy = DummyControl::New( true );
- DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
DALI_TEST_EQUALS( dummyImpl.stageConnectionCalled, false, TEST_LOCATION );
Stage::GetCurrent().Add(dummy);
{
DummyControl dummy = DummyControl::New( true );
- DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
Stage::GetCurrent().Add(dummy);
application.Render();
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION );
+ DALI_TEST_EQUALS( size, dummy.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).GetVectorXY(), TEST_LOCATION );
DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION );
Stage::GetCurrent().Remove(dummy);
Stage::GetCurrent().Add(dummy);
Vector2 size(100.0f, 200.0f);
- DALI_TEST_CHECK( size != dummy.GetCurrentSize().GetVectorXY() );
+ DALI_TEST_CHECK( size != dummy.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).GetVectorXY() );
application.SendNotification();
application.Render();
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS(size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION);
+ DALI_TEST_EQUALS(size, dummy.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).GetVectorXY(), TEST_LOCATION);
Stage::GetCurrent().Remove(dummy);
}
{
DummyControl dummy = DummyControl::New( true );
- DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
Stage::GetCurrent().Add(dummy);
{
DummyControl dummy = DummyControl::New( true );
- DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
dummy.SetSize( Vector2( 100.0f, 100.0f ) );
- dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ dummy.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
Stage::GetCurrent().Add(dummy);
application.Render();
DALI_TEST_EQUALS( dummyImpl.touchEventCalled, false, TEST_LOCATION );
Integration::TouchEvent touchEvent(1);
- TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
+ Integration::Point point;
+ point.SetDeviceId( 1 );
+ point.SetState( PointState::DOWN );
+ point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
touchEvent.AddPoint(point);
application.ProcessEvent(touchEvent);
DALI_TEST_EQUALS( dummyImpl.touchEventCalled, true, TEST_LOCATION );
DummyControl dummy = DummyControl::New();
dummy.SetSize( Vector2( 100.0f, 100.0f ) );
- dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ dummy.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
Stage::GetCurrent().Add(dummy);
application.Render();
application.SendNotification();
Integration::TouchEvent touchEvent(1);
- TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
+ Integration::Point point;
+ point.SetDeviceId( 1 );
+ point.SetState( PointState::DOWN );
+ point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
touchEvent.AddPoint(point);
application.ProcessEvent(touchEvent);
END_TEST;
}
+int UtcDaliControlImplHoverEvent(void)
+{
+ ToolkitTestApplication application;
+
+ {
+ DummyControl dummy = DummyControl::New( true );
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
+
+ dummy.SetSize( Vector2( 100.0f, 100.0f ) );
+ dummy.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ Stage::GetCurrent().Add(dummy);
+
+ application.Render();
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+
+ DALI_TEST_EQUALS( dummyImpl.hoverEventCalled, false, TEST_LOCATION );
+ Integration::HoverEvent event(1);
+ Integration::Point point;
+ point.SetDeviceId( 1 );
+ point.SetState( PointState::MOTION );
+ point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
+ event.AddPoint(point);
+ application.ProcessEvent( event );
+ DALI_TEST_EQUALS( dummyImpl.hoverEventCalled, true, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove(dummy);
+ }
+
+ // Ensure full code coverage
+ {
+ DummyControl dummy = DummyControl::New();
+
+ dummy.SetSize( Vector2( 100.0f, 100.0f ) );
+ dummy.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ Stage::GetCurrent().Add(dummy);
+
+ application.Render();
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+
+ Integration::HoverEvent event(1);
+ Integration::Point point;
+ point.SetDeviceId( 1 );
+ point.SetState( PointState::MOTION );
+ point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
+ event.AddPoint(point);
+ application.ProcessEvent( event );
+
+ Stage::GetCurrent().Remove(dummy);
+ }
+ END_TEST;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////////
{
DummyControl dummy = DummyControl::New( true );
- DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
Stage::GetCurrent().Add(dummy);
dummy.SetKeyInputFocus();
{
DummyControl dummy = DummyControl::New( true );
- DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
Stage::GetCurrent().Add(dummy);
{
DummyControl dummy = DummyControl::New( true );
- DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
Stage::GetCurrent().Add(dummy);
dummy.SetKeyInputFocus();
dummy.ClearKeyInputFocus();
- DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
- dummyImpl.OnAccessibilityValueChange( true );
dummyImpl.IsKeyboardNavigationSupported();
dummyImpl.IsKeyboardFocusGroup();
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace
{
-static bool MouseWheelEventCallback(Actor actor, const MouseWheelEvent& event)
+static bool WheelEventCallback(Actor actor, const WheelEvent& event)
{
return false;
}
}
-int UtcDaliControlImplMouseWheelEvent(void)
+int UtcDaliControlImplWheelEvent(void)
{
ToolkitTestApplication application;
{
DummyControl dummy = DummyControl::New( true );
- DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
dummy.SetSize( Vector2( 100.0f, 100.0f ) );
- dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ dummy.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
Stage::GetCurrent().Add(dummy);
- dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback);
+ dummy.WheelEventSignal().Connect(&WheelEventCallback);
application.Render();
application.SendNotification();
application.Render();
application.SendNotification();
- DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( dummyImpl.wheelEventCalled, false, TEST_LOCATION );
- // simulate a mouse wheel event
+ // simulate a wheel event
Vector2 screenCoordinates( 10.0f, 10.0f );
- Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
- application.ProcessEvent(event);
- DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, true, TEST_LOCATION );
+ Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u );
+ application.ProcessEvent( event );
+ DALI_TEST_EQUALS( dummyImpl.wheelEventCalled, true, TEST_LOCATION );
Stage::GetCurrent().Remove(dummy);
}
DummyControl dummy = DummyControl::New();
dummy.SetSize( Vector2( 100.0f, 100.0f ) );
- dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ dummy.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
Stage::GetCurrent().Add(dummy);
- dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback);
+ dummy.WheelEventSignal().Connect(&WheelEventCallback);
application.Render();
application.SendNotification();
application.Render();
application.SendNotification();
- // simulate a mouse wheel event
+ // simulate a wheel event
Vector2 screenCoordinates( 20.0f, 20.0f );
- Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u);
- application.ProcessEvent(event);
+ Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u );
+ application.ProcessEvent( event );
Stage::GetCurrent().Remove(dummy);
}
END_TEST;
}
+
+int UtcDaliControlImplSetStyleName(void)
+{
+ ToolkitTestApplication application;
+
+ {
+ DummyControl dummy = DummyControl::New( true );
+
+ dummy.SetSize( Vector2( 100.0f, 100.0f ) );
+ dummy.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+ Stage::GetCurrent().Add(dummy);
+
+ dummy.SetStyleName("TestStyle");
+
+ DALI_TEST_CHECK( dummy.GetStyleName() == "TestStyle" );
+
+ Stage::GetCurrent().Remove(dummy);
+ }
+ END_TEST;
+}
+
+int UtcDaliControlImplOnStyleChangeN(void)
+{
+ ToolkitTestApplication application;
+ Control dummy = Control::New();
+ Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
+
+ // test that style manager is being used, passing an empty handle does nothing but does not crash either
+ Dali::Toolkit::StyleManager styleManager;
+ controlImpl.OnStyleChange( styleManager, StyleChange::THEME_CHANGE );
+ // no crash so test passes
+ tet_result(TET_PASS);
+
+ END_TEST;
+}
+
+
+int UtcDaliControlImplOnAccessibilityPanP(void)
+{
+ ToolkitTestApplication application;
+ Control dummy = Control::New();
+ Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
+
+ PanGesture pan;
+ DALI_TEST_EQUALS( false, controlImpl.OnAccessibilityPan( pan ), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliControlImplOnAccessibilityTouchP(void)
+{
+ ToolkitTestApplication application;
+ Control dummy = Control::New();
+ Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
+ TouchEvent touch;
+ DALI_TEST_EQUALS( false, controlImpl.OnAccessibilityTouch( touch ), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliControlImplOnAccessibilityActivatedP(void)
+{
+ ToolkitTestApplication application;
+
+ Control dummy = Control::New();
+ Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
+ DALI_TEST_EQUALS( false, controlImpl.OnAccessibilityActivated(), TEST_LOCATION );
+
+ // Invoke the control's activate action
+ TypeInfo type = TypeRegistry::Get().GetTypeInfo( "Control" );
+ DALI_TEST_CHECK( type );
+
+ BaseHandle handle = type.CreateInstance();
+ DALI_TEST_CHECK( handle );
+
+ Property::Map attributes;
+ DALI_TEST_EQUALS( false, handle.DoAction("accessibilityActivated", attributes), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliControlImplGetNextKeyboardFocusableActorP(void)
+{
+ ToolkitTestApplication application;
+ Control dummy = Control::New();
+ Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
+
+ Actor currentFocusedActor;
+ Actor result = controlImpl.GetNextKeyboardFocusableActor( currentFocusedActor, Control::KeyboardFocus::LEFT, false );
+
+ DALI_TEST_EQUALS( result, currentFocusedActor, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliControlImplRegisterThenReRegisterVisual(void)
+{
+ ToolkitTestApplication application;
+
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+
+ Property::Index index =1;
+
+ DALI_TEST_CHECK( !dummyImpl.GetVisual( index ) );
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+ visual = visualFactory.CreateVisual( map );
+ DALI_TEST_CHECK(visual);
+
+ // Register index with a color visual
+ dummyImpl.RegisterVisual( index, visual );
+
+ DALI_TEST_CHECK( dummyImpl.GetVisual( index ) == visual );
+
+ Property::Map newMap;
+ newMap[Visual::Property::TYPE] = Visual::COLOR;
+ newMap[ColorVisual::Property::MIX_COLOR] = Color::BLUE;
+
+ visual = visualFactory.CreateVisual( newMap );
+ DALI_TEST_CHECK(visual);
+
+ // ReRegister with altered color visual
+ dummyImpl.RegisterVisual( index, visual );
+
+ DALI_TEST_CHECK( dummyImpl.GetVisual( index ) == visual );
+
+ tet_result(TET_PASS);
+
+ END_TEST;
+}
+
+int UtcDaliControlImplRegisterVisaulThenReRegisterToSelf(void)
+{
+ ToolkitTestApplication application;
+
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+
+ Property::Index index =1;
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+ visual = visualFactory.CreateVisual( map );
+ DALI_TEST_CHECK(visual);
+
+ // Register index with a color visual
+ dummyImpl.RegisterVisual( index, visual );
+
+ DALI_TEST_CHECK( dummyImpl.GetVisual( index ) == visual );
+
+ // ReRegister to self
+ dummyImpl.RegisterVisual( index, visual );
+
+ DALI_TEST_CHECK( dummyImpl.GetVisual( index ) == visual );
+
+ END_TEST;
+}
+
+int UtcDaliControlImplRegisterVisualToSelf(void)
+{
+ ToolkitTestApplication application;
+
+ Test::ObjectDestructionTracker objectDestructionTracker;
+
+ {
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+ objectDestructionTracker.Start( dummy );
+
+ Property::Index index = 1;
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+ visual = visualFactory.CreateVisual( map );
+ DALI_TEST_CHECK(visual);
+
+ // Register to self
+ dummyImpl.RegisterVisual( index, visual );
+
+ DALI_TEST_EQUALS( objectDestructionTracker.IsDestroyed(), false, TEST_LOCATION ); // Control not destroyed yet
+ DALI_TEST_CHECK( dummyImpl.GetVisual( index ) == visual );
+ }
+
+ DALI_TEST_EQUALS( objectDestructionTracker.IsDestroyed(), true, TEST_LOCATION ); // Should be destroyed
+
+ END_TEST;
+}
+
+int UtcDaliControlImplRegisterTwoVisuals(void)
+{
+ ToolkitTestApplication application;
+
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+
+ Property::Index index =1;
+ Property::Index index2 =2;
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+ Toolkit::Visual::Base secondVisual;
+
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+ visual = visualFactory.CreateVisual( map );
+ DALI_TEST_CHECK(visual);
+
+ // Register index with a color visual
+ dummyImpl.RegisterVisual( index, visual );
+
+ Property::Map newMap;
+ newMap[Visual::Property::TYPE] = Visual::COLOR;
+ newMap[ColorVisual::Property::MIX_COLOR] = Color::BLUE;
+
+ secondVisual = visualFactory.CreateVisual( newMap );
+ DALI_TEST_CHECK( secondVisual );
+
+ // ReRegister with altered color visual
+ dummyImpl.RegisterVisual( index2, secondVisual );
+
+ DALI_TEST_CHECK( dummyImpl.GetVisual( index ) == visual );
+ DALI_TEST_CHECK( dummyImpl.GetVisual( index2 ) == secondVisual );
+
+ END_TEST;
+}
+
+int UtcDaliControlImplRegisterUnregisterVisual(void)
+{
+ ToolkitTestApplication application;
+
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+
+ Property::Index index =1;
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+ visual = visualFactory.CreateVisual( map );
+ DALI_TEST_CHECK(visual);
+
+ // Register index with a color visual
+ dummyImpl.RegisterVisual( index, visual );
+
+ tet_infoline( "Add control with visual to stage and check renderer count is 1" );
+ Stage::GetCurrent().Add( dummy );
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK( dummyImpl.GetVisual( index ) == visual );
+ DALI_TEST_EQUALS( dummy.GetRendererCount(), 1, TEST_LOCATION );
+
+ // Unregister visual
+ dummyImpl.UnregisterVisual( index );
+
+ tet_infoline( "Remove control with visual from stage and check renderer count is 0" );
+ Stage::GetCurrent().Remove( dummy );
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( dummy.GetRendererCount(), 0, TEST_LOCATION );
+ DALI_TEST_CHECK( !dummyImpl.GetVisual( index ) );
+
+ END_TEST;
+}
+
+int UtcDaliControlImplRegisterDisabledVisual(void)
+{
+ ToolkitTestApplication application;
+
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+
+ Property::Index TEST_PROPERTY =1;
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+ visual = visualFactory.CreateVisual( map );
+ DALI_TEST_CHECK(visual);
+
+ // Register index with a color visual
+ dummyImpl.RegisterVisual( TEST_PROPERTY, visual, false );
+
+ DALI_TEST_CHECK( dummyImpl.GetVisual( TEST_PROPERTY ) == visual );
+ DALI_TEST_CHECK( dummyImpl.IsVisualEnabled( TEST_PROPERTY ) == false );
+
+ Stage::GetCurrent().Add(dummy);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK( dummyImpl.IsVisualEnabled( TEST_PROPERTY ) == false );
+
+ DALI_TEST_CHECK( dummy.OnStage() == true );
+
+ dummyImpl.EnableVisual( TEST_PROPERTY, true );
+
+ DALI_TEST_CHECK( dummyImpl.IsVisualEnabled( TEST_PROPERTY ) == true );
+
+ END_TEST;
+}
+
+int UtcDaliControlImplDisableRegisteredVisual(void)
+{
+ ToolkitTestApplication application;
+
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+
+ Property::Index TEST_PROPERTY =1;
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+ visual = visualFactory.CreateVisual( map );
+ DALI_TEST_CHECK(visual);
+
+ // Register index with a color visual
+ dummyImpl.RegisterVisual( TEST_PROPERTY, visual );
+
+ Stage::GetCurrent().Add(dummy);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK( dummyImpl.IsVisualEnabled( TEST_PROPERTY ) == true);
+
+ DALI_TEST_CHECK( dummy.OnStage() == true );
+
+ dummyImpl.EnableVisual( TEST_PROPERTY, false );
+
+ DALI_TEST_CHECK( dummyImpl.IsVisualEnabled( TEST_PROPERTY ) == false );
+
+ END_TEST;
+}
+
+int UtcDaliControlImplEnabledVisualParentRemovedFromStage(void)
+{
+ // Visual enabled but then parent removed from stage, test ensures visual/renderer are also removed from stage.
+ // Then adding parent back to stage should automatically put visual/renderer back
+
+ ToolkitTestApplication application;
+
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+
+ Property::Index TEST_PROPERTY =1;
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+ visual = visualFactory.CreateVisual( map );
+ DALI_TEST_CHECK(visual);
+
+ // Register index with a color visual
+ dummyImpl.RegisterVisual( TEST_PROPERTY, visual, false );
+
+ Stage::GetCurrent().Add(dummy);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK( dummyImpl.IsVisualEnabled( TEST_PROPERTY ) == false );
+ DALI_TEST_CHECK( dummy.OnStage() == true );
+ dummyImpl.EnableVisual( TEST_PROPERTY, true );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_CHECK( dummy.GetRendererCount() == 1u );
+
+ // Remove control from stage, visual should be removed from stage too
+ Stage::GetCurrent().Remove(dummy);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_CHECK( dummy.GetRendererCount() == 0u );
+
+ Stage::GetCurrent().Add(dummy);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_CHECK( dummy.GetRendererCount() == 1u );
+
+ DALI_TEST_CHECK( dummyImpl.IsVisualEnabled( TEST_PROPERTY ) == true );
+
+ END_TEST;
+}
+
+int UtcDaliControlImplRegisterTwoVisualsAndEnableOnlyOne(void)
+{
+ // Register 2 visuals and enable by default
+ // Disable 1 visual
+ // Remove control from stage then put it back
+ // Check that only 1 visual/renderer is staged.
+
+ ToolkitTestApplication application;
+
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+
+ Property::Index TEST_PROPERTY1 =1;
+ Property::Index TEST_PROPERTY2 =2;
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual1;
+ Toolkit::Visual::Base visual2;
+
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+ Property::Map map2;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::BLUE;
+
+ visual1 = visualFactory.CreateVisual( map );
+ DALI_TEST_CHECK(visual1);
+
+ visual2 = visualFactory.CreateVisual( map );
+ DALI_TEST_CHECK(visual2);
+
+ // Register index with a color visual
+ dummyImpl.RegisterVisual( TEST_PROPERTY1, visual1 );
+ // Register second index with a color visual
+ dummyImpl.RegisterVisual( TEST_PROPERTY2, visual2 );
+
+ Stage::GetCurrent().Add(dummy);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK( dummy.GetRendererCount() == 2u );
+ DALI_TEST_CHECK( dummyImpl.IsVisualEnabled( TEST_PROPERTY1 ) == true );
+ DALI_TEST_CHECK( dummyImpl.IsVisualEnabled( TEST_PROPERTY1 ) == true);
+ DALI_TEST_CHECK( dummy.OnStage() == true );
+ dummyImpl.EnableVisual( TEST_PROPERTY2, false );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_CHECK( dummy.GetRendererCount() == 1u );
+
+ // Remove control from stage, visual should be removed from stage too
+ Stage::GetCurrent().Remove(dummy);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_CHECK( dummy.GetRendererCount() == 0u );
+
+ Stage::GetCurrent().Add(dummy);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_CHECK( dummy.GetRendererCount() == 1u );
+
+ DALI_TEST_CHECK( dummyImpl.IsVisualEnabled( TEST_PROPERTY1 ) == true );
+ DALI_TEST_CHECK( dummyImpl.IsVisualEnabled( TEST_PROPERTY2 ) == false );
+
+ END_TEST;
+}
+int UtcDaliControlImplAutoClippingWithVisuals(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline( "Test to ensure a renderer does NOT get added when we've already registered a visual which we haven't enabled" );
+
+ DummyControl control = DummyControl::New();
+ DummyControlImpl& controlImpl = static_cast<DummyControlImpl&>( control.GetImplementation() );
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+ visual = visualFactory.CreateVisual( map );
+ DALI_TEST_CHECK(visual);
+ controlImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual, false );
+
+ DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
+
+ control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
+
+ Stage::GetCurrent().Add( control );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliControlImplAutoClippingWithVisualsAlreadyOnStage(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline( "Test to ensure a renderer does NOT get added when we've already registered a visual which we haven't enabled and we're already on the stage" );
+
+ DummyControl control = DummyControl::New();
+ DummyControlImpl& controlImpl = static_cast<DummyControlImpl&>( control.GetImplementation() );
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+ visual = visualFactory.CreateVisual( map );
+ DALI_TEST_CHECK(visual);
+ controlImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual, false );
+
+ DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
+
+ Stage::GetCurrent().Add( control );
+
+ application.SendNotification();
+ application.Render();
+
+ control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
+
+ END_TEST;
+}