X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Fdali-toolkit-test-utils%2Fdummy-control.cpp;h=a7ccfbaa37a7ac439aea057615b71ab5c00c52ce;hp=0d54096a2de2df05eaca94322404bce9b98cbd10;hb=01777a3489f027123010b281e58efbc9f0a93db7;hpb=30b39930a88d3d44cfea9a969c742d662666b149 diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp index 0d54096..a7ccfba 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -19,8 +19,6 @@ #include #include -#include -#include #include namespace Dali @@ -95,7 +93,7 @@ DummyControl DummyControlImpl::New() } DummyControlImpl::DummyControlImpl() -: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_HOVER_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ), +: Control( ControlBehaviour() ), mCustomSlot1Called(false) { } @@ -157,6 +155,12 @@ Animation DummyControlImpl::CreateTransition( const Toolkit::TransitionData& tra return DevelControl::CreateTransition( *this, transition ); } +void DummyControlImpl::DoAction( Dali::Property::Index index, Dali::Property::Index action, const Dali::Property::Value attributes ) +{ + DummyControl control( *this ); + DevelControl::DoAction( control, index, action, attributes); +} + void DummyControlImpl::SetProperty( BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value ) { Toolkit::DummyControl control = Toolkit::DummyControl::DownCast( Dali::BaseHandle( object ) ); @@ -184,10 +188,21 @@ void DummyControlImpl::SetProperty( BaseObject* object, Dali::Property::Index in Property::Value DummyControlImpl::GetProperty( BaseObject* object, Dali::Property::Index propertyIndex ) { - Dali::Property::Value value; + Toolkit::DummyControl control = Toolkit::DummyControl::DownCast( Dali::BaseHandle( object ) ); + DummyControlImpl& dummyImpl = static_cast( control.GetImplementation() ); + + Visual::Base visual = dummyImpl.GetVisual( propertyIndex ); + Property::Map map; + if( visual ) + { + visual.CreatePropertyMap( map ); + } + Dali::Property::Value value = map; + return value; } + Toolkit::DummyControl Impl::DummyControl::New() { IntrusivePtr< Toolkit::Impl::DummyControl > impl = new Toolkit::Impl::DummyControl; @@ -196,12 +211,13 @@ Toolkit::DummyControl Impl::DummyControl::New() return control; } +int Impl::DummyControl::constructorCount; +int Impl::DummyControl::destructorCount; Impl::DummyControl::DummyControl() : DummyControlImpl(), initializeCalled(false), activatedCalled(false), - onAccTouchedCalled(false), onAccValueChangeCalled(false), themeChangeCalled(false), fontChangeCalled(false), @@ -215,21 +231,22 @@ Impl::DummyControl::DummyControl() childRemoveCalled(false), sizeSetCalled(false), sizeAnimationCalled(false), - touchEventCalled(false), hoverEventCalled(false), wheelEventCalled(false), keyEventCalled(false), keyInputFocusGained(false), keyInputFocusLost(false) { + ++constructorCount; } -Impl::DummyControl::~DummyControl() { } - +Impl::DummyControl::~DummyControl() +{ + ++destructorCount; +} void Impl::DummyControl::OnInitialize() { initializeCalled = true; } bool Impl::DummyControl::OnAccessibilityActivated() { activatedCalled = true; return true; } -bool Impl::DummyControl::OnAccessibilityTouch(const TouchEvent& touchEvent) { onAccTouchedCalled = true; return true; } bool Impl::DummyControl::OnAccessibilityValueChange( bool isIncrease ) { onAccValueChangeCalled = true; return true; @@ -244,15 +261,12 @@ void Impl::DummyControl::OnPinch(const PinchGesture& pinch) { pinchCalled = true void Impl::DummyControl::OnPan(const PanGesture& pan) { panCalled = true; } void Impl::DummyControl::OnTap(const TapGesture& tap) { tapCalled = true; } void Impl::DummyControl::OnLongPress(const LongPressGesture& longPress) { longPressCalled = true; } -void Impl::DummyControl::OnStageConnection( int depth ) { Control::OnStageConnection( depth ); stageConnectionCalled = true; } -void Impl::DummyControl::OnStageDisconnection() { stageDisconnectionCalled = true; Control::OnStageDisconnection(); } +void Impl::DummyControl::OnSceneConnection( int depth ) { Control::OnSceneConnection( depth ); stageConnectionCalled = true; } +void Impl::DummyControl::OnSceneDisconnection() { stageDisconnectionCalled = true; Control::OnSceneDisconnection(); } void Impl::DummyControl::OnChildAdd(Actor& child) { childAddCalled = true; } void Impl::DummyControl::OnChildRemove(Actor& child) { childRemoveCalled = true; } void Impl::DummyControl::OnSizeSet(const Vector3& targetSize) { Control::OnSizeSet( targetSize ); sizeSetCalled = true; } void Impl::DummyControl::OnSizeAnimation(Animation& animation, const Vector3& targetSize) { Control::OnSizeAnimation( animation, targetSize ); sizeAnimationCalled = true; } -bool Impl::DummyControl::OnTouchEvent(const TouchEvent& event) { touchEventCalled = true; return false; } -bool Impl::DummyControl::OnHoverEvent(const HoverEvent& event) { hoverEventCalled = true; return false; } -bool Impl::DummyControl::OnWheelEvent(const WheelEvent& event) { wheelEventCalled = true; return false; } bool Impl::DummyControl::OnKeyEvent(const KeyEvent& event) { keyEventCalled = true; return false;} void Impl::DummyControl::OnKeyInputFocusGained() { keyInputFocusGained = true; } void Impl::DummyControl::OnKeyInputFocusLost() { keyInputFocusLost = true; } @@ -265,6 +279,11 @@ void Impl::DummyControl::SetLayout( Property::Index visualIndex, Property::Map& void Impl::DummyControl::OnRelayout( const Vector2& size, RelayoutContainer& container ) { + if ( mRelayoutCallback ) + { + mRelayoutCallback( size ); // Execute callback if set + } + Property::Map emptyMap; for( VisualIndices::iterator iter = mRegisteredVisualIndices.begin(); iter != mRegisteredVisualIndices.end() ; ++iter ) @@ -286,6 +305,29 @@ void Impl::DummyControl::OnRelayout( const Vector2& size, RelayoutContainer& con } } +void Impl::DummyControl::SetRelayoutCallback( RelayoutCallbackFunc callback ) +{ + mRelayoutCallback = callback; +} + +Vector3 Impl::DummyControl::GetNaturalSize() +{ + Vector2 currentSize; + + for( auto elem : mRegisteredVisualIndices ) + { + Vector2 naturalSize; + Visual::Base visual = GetVisual(elem); + visual.GetNaturalSize( naturalSize ); + currentSize.width = std::max( naturalSize.width, currentSize.width ); + currentSize.height = std::max( naturalSize.height, currentSize.height ); + } + + return Vector3( currentSize ); +} + + + DummyControl DummyControl::New( bool override ) { DummyControl control;