/*
- * 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-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali/integration-api/events/key-event-integ.h>
#include <dali/integration-api/events/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/touch-event-integ.h>
#include <dali/integration-api/events/hover-event-integ.h>
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);
+
+ TestGeneratePinch(application);
+
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 );
- 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 );
+ TestGenerateMiniPan(application);
- 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.panCalled == true );
- // Ensure full code coverage
- {
- DummyControl dummy = DummyControl::New();
- dummy.SetSize( Vector2( 100.0f, 100.0f ) );
+ DALI_TEST_CHECK( dummyImpl.tapCalled == false );
- dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add(dummy);
+ TestGenerateTap(application);
- // Render and notify a couple of times
- application.SendNotification();
- application.Render();
- application.SendNotification();
- application.Render();
+ DALI_TEST_CHECK( dummyImpl.tapCalled == true );
- DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
- dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
+ DALI_TEST_CHECK( dummyImpl.longPressCalled == 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);
+ TestGenerateLongPress(application);
- // Render and notify a couple of times
- application.SendNotification();
- application.Render();
- application.SendNotification();
- application.Render();
- DALI_TEST_CHECK( dummy.GetCurrentScale().x == 10.0f );
-
- 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);
-
- 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);
-
- 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();
{
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();
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();
{
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();
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();
{
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.IsKeyboardNavigationSupported();
dummyImpl.IsKeyboardFocusGroup();
{
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.WheelEventSignal().Connect(&WheelEventCallback);
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.WheelEventSignal().Connect(&WheelEventCallback);
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);
dummy.SetStyleName("TestStyle");
// 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;
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;
+}