Removed REQUIRES_STYLE_CHANGE_SIGNALS
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / dummy-control.cpp
index d0a9d03..a7ccfba 100644 (file)
@@ -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 <dali-toolkit/dali-toolkit.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
-#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
-#include <dali-toolkit/devel-api/align-enums.h>
 #include <dali-toolkit/devel-api/controls/control-devel.h>
 
 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<DummyControlImpl&>( 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; }
@@ -296,6 +310,23 @@ 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 )
 {