Update interface to sync with dali-core change.
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-ControlWrapper.cpp
index 32076f1..e60505d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 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.
 #include <dali-toolkit-test-suite-utils.h>
 
 #include <dali.h>
+#include <dali/public-api/dali-core.h>
+#include <dali/devel-api/actors/custom-actor-devel.h>
+#include <dali/devel-api/object/csharp-type-registry.h>
 #include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
 #include <dali-toolkit/devel-api/controls/control-wrapper.h>
 #include <dali-toolkit/devel-api/controls/control-wrapper-impl.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
@@ -47,17 +51,27 @@ void utc_dali_toolkit_control_wrapper_cleanup(void)
 namespace
 {
 bool gOnRelayout = false;
+
+static bool gKeyInputFocusCallBackCalled;
+
+static void TestKeyInputFocusCallback( Control control )
+{
+  tet_infoline(" TestKeyInputFocusCallback");
+
+  gKeyInputFocusCallBackCalled = true;
+}
 } // namespace
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
+
 namespace Impl
 {
 struct TestCustomControl : public Toolkit::Internal::ControlWrapper
 {
   /**
-  * Constructor
-  */
+   * Constructor
+   */
   TestCustomControl()  : Toolkit::Internal::ControlWrapper( CustomControlBehaviour( Toolkit::Internal::ControlWrapper::DISABLE_STYLE_CHANGE_SIGNALS |
           Toolkit::Internal::ControlWrapper::REQUIRES_KEYBOARD_NAVIGATION_SUPPORT )) ,
           mDaliProperty( Property::INVALID_INDEX ),
@@ -73,9 +87,11 @@ struct TestCustomControl : public Toolkit::Internal::ControlWrapper
           mDaliProperty( Property::INVALID_INDEX ),
           mSizeSet( Vector3::ZERO ),
           mTargetSize( Vector3::ZERO ),
-          mNego( nego )
+          mNego( nego ),
+          mDepth( 0u )
   {
   }
+
   /**
    * Destructor
    */
@@ -90,36 +106,40 @@ struct TestCustomControl : public Toolkit::Internal::ControlWrapper
     OnInitialize( name );
   }
 
+  using Control::OnInitialize; ///< To tell the compiler that we really do want to overload OnInitialize in this class & were not trying to override it
   virtual void OnInitialize( const char* name ) {}
 
   // From Toolkit::Internal::ControlWrapper
-  virtual void OnStageConnection( int depth )
+  virtual void OnSceneConnection( int depth )
   {
     mDepth = depth;
+    Control::OnSceneConnection(depth);
   }
-  virtual void OnStageDisconnection()
+  virtual void OnSceneDisconnection()
   {
+    Control::OnSceneDisconnection();
   }
   virtual void OnChildAdd( Actor& child )
   {
+    Control::OnChildAdd(child);
   }
   virtual void OnChildRemove( Actor& child )
   {
+    Control::OnChildRemove(child);
   }
-  virtual void OnPropertySet( Property::Index index, Property::Value propertyValue )
+  virtual void OnPropertySet( Property::Index index, const Property::Value& propertyValue )
   {
+    Control::OnPropertySet(index, propertyValue);
   }
   virtual void OnSizeSet( const Vector3& targetSize )
   {
     mSizeSet = targetSize;
+    Control::OnSizeSet( targetSize );
   }
   virtual void OnSizeAnimation( Animation& animation, const Vector3& targetSize )
   {
     mTargetSize = targetSize;
-  }
-  virtual bool OnTouchEvent( const TouchEvent& event )
-  {
-    return true;
+    Control::OnSizeAnimation( animation, targetSize );
   }
   virtual bool OnHoverEvent( const HoverEvent& event )
   {
@@ -154,9 +174,27 @@ struct TestCustomControl : public Toolkit::Internal::ControlWrapper
     return 0.0f;
   }
 
+  void TestRegisterVisual( Property::Index index, Toolkit::Visual::Base visual )
+  {
+    ControlWrapper::RegisterVisual( index, visual );
+
+    VisualIndices::iterator iter = std::find( mRegisteredVisualIndices.begin(), mRegisteredVisualIndices.end(), index );
+    if( iter == mRegisteredVisualIndices.end() )
+    {
+      mRegisteredVisualIndices.push_back(index);
+    }
+  }
+
   virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
   {
     gOnRelayout = true;
+
+    for( VisualIndices::iterator iter = mRegisteredVisualIndices.begin(); iter != mRegisteredVisualIndices.end() ; ++iter )
+    {
+      Visual::Base visual = GetVisual(*iter);
+      Property::Map map; // empty map enforces defaults
+      visual.SetTransformAndSize( map, size );
+    }
   }
 
   virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
@@ -215,9 +253,19 @@ struct TestCustomControl : public Toolkit::Internal::ControlWrapper
   Vector3 mTargetSize;
   bool mNego;
   unsigned int mDepth;
+
+  typedef std::vector<Property::Index> VisualIndices;
+  VisualIndices mRegisteredVisualIndices;
 };
+
+
+
 }
 
+static std::string customControlTypeName = "MyTestCustomControl";
+static TypeRegistration customControl( customControlTypeName, typeid(Dali::Toolkit::Control), NULL );
+
+
 int UtcDaliControlWrapperConstructor(void)
 {
   ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
@@ -227,9 +275,15 @@ int UtcDaliControlWrapperConstructor(void)
 
   DALI_TEST_CHECK( !ControlWrapper::DownCast( controlWrapper ) );
 
-  controlWrapper = ControlWrapper::New( *controlWrapperImpl );
+  controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
 
   DALI_TEST_CHECK( ControlWrapper::DownCast( controlWrapper ) );
+
+  Dali::TypeInfo typeInfo = DevelCustomActor::GetTypeInfo( controlWrapper );
+
+  DALI_TEST_EQUALS( typeInfo.GetName(), customControlTypeName, TEST_LOCATION);
+
+
   END_TEST;
 }
 
@@ -237,7 +291,7 @@ int UtcDaliControlWrapperDestructor(void)
 {
   TestApplication application;
 
-  ControlWrapper control = ControlWrapper::New( *( new Toolkit::Internal::ControlWrapper( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT ) ) );
+  ControlWrapper control = ControlWrapper::New( customControlTypeName, *( new Toolkit::Internal::ControlWrapper( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT ) ) );
 
   ControlWrapper control2( control );
 
@@ -259,9 +313,9 @@ int UtcDaliControlWrapperRelayoutRequest(void)
   DALI_TEST_EQUALS( gOnRelayout, false, TEST_LOCATION );
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
-  ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl );
+  ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
 
-  Stage::GetCurrent().Add( controlWrapper );
+  application.GetScene().Add( controlWrapper );
 
   application.SendNotification();
   application.Render();
@@ -283,7 +337,7 @@ int UtcDaliControlWrapperImplGetHeightForWidthBase(void)
   TestApplication application;
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
-  ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl );
+  ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
 
   float width = 300.0f;
   float v = 0.0f;
@@ -303,7 +357,7 @@ int UtcDaliControlWrapperGetWidthForHeightBase(void)
   TestApplication application;
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
-  ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl );
+  ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
 
   float height = 300.0f;
   float v = 0.0f;
@@ -323,11 +377,11 @@ int UtcDaliControlWrapperCalculateChildSizeBase(void)
   TestApplication application;
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
-  ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl );
+  ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
 
   Actor child = Actor::New();
   child.SetResizePolicy( Dali::ResizePolicy::FIXED, Dali::Dimension::ALL_DIMENSIONS );
-  child.SetSize(150, 150);
+  child.SetProperty( Actor::Property::SIZE, Vector2(150, 150) );
 
   application.SendNotification();
   application.Render();
@@ -344,7 +398,7 @@ int UtcDaliControlWrapperRelayoutDependentOnChildrenBase(void)
   TestApplication application;
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
-  ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl );
+  ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
 
   bool v = false;
 
@@ -367,11 +421,11 @@ int UtcDaliControlWrapperRegisterVisualToSelf(void)
 {
   ToolkitTestApplication application;
 
-  Test::ObjectDestructionTracker objectDestructionTracker;
+  Test::ObjectDestructionTracker objectDestructionTracker( application.GetCore().GetObjectRegistry() );
 
   {
     Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
-    ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl );
+    ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
 
     objectDestructionTracker.Start( controlWrapper );
 
@@ -399,12 +453,49 @@ int UtcDaliControlWrapperRegisterVisualToSelf(void)
   END_TEST;
 }
 
+int UtcDaliControlWrapperRegisterVisualWithDepthIndexToSelf(void)
+{
+  ToolkitTestApplication application;
+
+  Test::ObjectDestructionTracker objectDestructionTracker( application.GetCore().GetObjectRegistry() );
+
+  {
+    Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
+    ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
+
+    objectDestructionTracker.Start( controlWrapper );
+
+    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
+    controlWrapperImpl->RegisterVisual( index, visual, 4 );
+
+    DALI_TEST_EQUALS( objectDestructionTracker.IsDestroyed(), false, TEST_LOCATION ); // Control not destroyed yet
+    DALI_TEST_EQUALS( controlWrapperImpl->GetVisual( index ), visual, TEST_LOCATION );
+    DALI_TEST_EQUALS( visual.GetDepthIndex(), 4, TEST_LOCATION );
+  }
+
+  DALI_TEST_EQUALS( objectDestructionTracker.IsDestroyed(), true, TEST_LOCATION ); // Should be destroyed
+
+  END_TEST;
+}
+
 int UtcDaliControlWrapperRegisterDisabledVisual(void)
 {
   ToolkitTestApplication application;
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
-  ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl );
+  ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
 
   Property::Index TEST_PROPERTY = 1;
 
@@ -424,7 +515,7 @@ int UtcDaliControlWrapperRegisterDisabledVisual(void)
   DALI_TEST_EQUALS( controlWrapperImpl->GetVisual( TEST_PROPERTY ), visual, TEST_LOCATION );
   DALI_TEST_EQUALS( controlWrapperImpl->IsVisualEnabled( TEST_PROPERTY ), false, TEST_LOCATION );
 
-  Stage::GetCurrent().Add( controlWrapper );
+  application.GetScene().Add( controlWrapper );
 
   // Render and notify
   application.SendNotification();
@@ -432,7 +523,50 @@ int UtcDaliControlWrapperRegisterDisabledVisual(void)
 
   DALI_TEST_EQUALS( controlWrapperImpl->IsVisualEnabled( TEST_PROPERTY ), false, TEST_LOCATION );
 
-  DALI_TEST_EQUALS( controlWrapper.OnStage(), true, TEST_LOCATION );
+  DALI_TEST_EQUALS( controlWrapper.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ), true, TEST_LOCATION );
+
+  controlWrapperImpl->EnableVisual( TEST_PROPERTY, true );
+
+  DALI_TEST_EQUALS( controlWrapperImpl->IsVisualEnabled( TEST_PROPERTY ), true, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliControlWrapperRegisterDisabledVisualWithDepthIndex(void)
+{
+  ToolkitTestApplication application;
+
+  Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
+  ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
+
+  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
+  controlWrapperImpl->RegisterVisual( TEST_PROPERTY, visual, false, 10 );
+
+  DALI_TEST_EQUALS( controlWrapperImpl->GetVisual( TEST_PROPERTY ), visual, TEST_LOCATION );
+  DALI_TEST_EQUALS( controlWrapperImpl->IsVisualEnabled( TEST_PROPERTY ), false, TEST_LOCATION );
+  DALI_TEST_EQUALS( visual.GetDepthIndex(), 10, TEST_LOCATION );
+
+  application.GetScene().Add( controlWrapper );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( controlWrapperImpl->IsVisualEnabled( TEST_PROPERTY ), false, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( controlWrapper.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ), true, TEST_LOCATION );
 
   controlWrapperImpl->EnableVisual( TEST_PROPERTY, true );
 
@@ -446,7 +580,7 @@ int UtcDaliControlWrapperRegisterUnregisterVisual(void)
   ToolkitTestApplication application;
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
-  ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl );
+  ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
 
   Property::Index index = 1;
 
@@ -491,13 +625,13 @@ int UtcDaliControlWrapperTransitionDataMap1N(void)
   Dali::Toolkit::TransitionData transition = TransitionData::New( map );
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
-  ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl );
+  ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
 
   //DummyControl actor = DummyControl::New();
   controlWrapper.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
-  controlWrapper.SetName("Actor1");
-  controlWrapper.SetColor(Color::CYAN);
-  Stage::GetCurrent().Add(controlWrapper);
+  controlWrapper.SetProperty( Dali::Actor::Property::NAME,"Actor1");
+  controlWrapper.SetProperty( Actor::Property::COLOR,Color::CYAN);
+  application.GetScene().Add(controlWrapper);
 
   Animation anim = controlWrapperImpl->CreateTransition( transition );
   DALI_TEST_CHECK( ! anim );
@@ -544,10 +678,160 @@ int UtcDaliControlWrapperApplyThemeStyle(void)
   ToolkitTestApplication application;
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
-  ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl );
+  ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
 
   controlWrapperImpl->ApplyThemeStyle();
 
   DALI_TEST_CHECK( true );
   END_TEST;
 }
+
+int UtcDaliControlWrapperTestControlProperties(void)
+{
+  ToolkitTestApplication application;
+
+  Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
+  ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
+
+  application.GetScene().Add( controlWrapper );
+
+  // "background" property
+  Property::Map rendererMap;
+  rendererMap[Visual::Property::TYPE] = Visual::COLOR;
+  rendererMap[ColorVisual::Property::MIX_COLOR] = Color::RED;
+  controlWrapper.SetProperty( Control::Property::BACKGROUND, rendererMap );
+  Property::Value propertyValue = controlWrapper.GetProperty( Control::Property::BACKGROUND );
+  Property::Map* resultMap = propertyValue.GetMap();
+  DALI_TEST_CHECK( resultMap->Find( Toolkit::Visual::Property::TYPE ) );
+  DALI_TEST_EQUALS( resultMap->Find( Toolkit::Visual::Property::TYPE )->Get<int>(), (int)Visual::COLOR, TEST_LOCATION );
+  DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
+  DALI_TEST_EQUALS( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>(), Color::RED, TEST_LOCATION );
+
+  // "keyInputFocus" property
+  controlWrapper.SetProperty( Control::Property::KEY_INPUT_FOCUS, true );
+  DALI_TEST_EQUALS( true, controlWrapper.GetProperty( Control::Property::KEY_INPUT_FOCUS ).Get< bool >(), TEST_LOCATION );
+
+  // "styleName" property
+  controlWrapper.SetProperty( Control::Property::STYLE_NAME, "MyCustomStyle" );
+  DALI_TEST_EQUALS( "MyCustomStyle", controlWrapper.GetProperty( Control::Property::STYLE_NAME ).Get< std::string >(), TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliControlWrapperTypeRegistryCreation(void)
+{
+  ToolkitTestApplication application;
+
+  TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "ControlWrapper" );
+  DALI_TEST_CHECK( typeInfo )
+
+  // Check that we can't create a ControlWrapper instance
+  BaseHandle baseHandle = typeInfo.CreateInstance();
+  DALI_TEST_CHECK( !baseHandle )
+
+  END_TEST;
+}
+
+void SetProperty(BaseObject* object, const char* const name, Property::Value* value)
+{
+}
+Property::Value* GetProperty(BaseObject* object, const char* const name )
+{
+  return NULL;
+}
+
+int UtcDaliControlWrapperAnimateVisual(void)
+{
+  tet_infoline("Test that the control wrapper's visuals can be animated by name when registered");
+
+  ToolkitTestApplication application;
+  Test::ObjectDestructionTracker objectDestructionTracker( application.GetCore().GetObjectRegistry() );
+
+  {
+    Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
+    ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
+
+    Property::Index index = Control::CONTROL_PROPERTY_END_INDEX+1;
+    std::string visualName("colorVisual");
+    CSharpTypeRegistry::RegisterProperty( customControlTypeName, visualName, index, Property::VECTOR4, SetProperty, GetProperty );
+
+    objectDestructionTracker.Start( controlWrapper );
+
+    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
+    controlWrapperImpl->TestRegisterVisual( index, visual );
+
+    application.GetScene().Add( controlWrapper );
+    controlWrapper.SetProperty( Actor::Property::SIZE, Vector2( 100, 100 ) );
+    application.SendNotification();
+    application.Render(0); // Trigger animation start
+
+    Property::Map transition;
+    transition["target"] = visualName;
+    transition["property"] = "mixColor";
+    transition["targetValue"] = Color::GREEN;
+    Property::Map animator;
+    animator["alphaFunction"] = "LINEAR";
+    animator["duration"] = 1.0f;
+    animator["delay"] = 0.0f;
+    transition["animator"] = animator;
+
+    TransitionData transitionData = TransitionData::New(transition);
+    Animation anim = DevelControl::CreateTransition( *controlWrapperImpl, transitionData );
+    anim.Play();
+
+    application.SendNotification();
+    application.Render(0); // Trigger animation start
+
+    application.Render(1000); // animation end
+    application.Render(  10);
+
+    Property::Map visualMap;
+    visual.CreatePropertyMap( visualMap );
+    Property::Value* value = visualMap.Find(ColorVisual::Property::MIX_COLOR, "mixColor");
+    DALI_TEST_CHECK( value != NULL );
+    if( value )
+    {
+      Vector4 testColor = value->Get<Vector4>();
+      DALI_TEST_EQUALS( testColor, Color::GREEN, 0.001f, TEST_LOCATION );
+    }
+
+    DALI_TEST_EQUALS( objectDestructionTracker.IsDestroyed(), false, TEST_LOCATION ); // Control not destroyed yet
+    DALI_TEST_EQUALS( controlWrapperImpl->GetVisual( index ), visual, TEST_LOCATION );
+
+    application.GetScene().Remove( controlWrapper );
+  }
+
+  DALI_TEST_EQUALS( objectDestructionTracker.IsDestroyed(), true, TEST_LOCATION ); // Should be destroyed
+
+  END_TEST;
+}
+
+int UtcDaliControlWrapperEmitKeyFocusSignal(void)
+{
+  ToolkitTestApplication application;
+
+  Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
+  ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
+
+  gKeyInputFocusCallBackCalled = false;
+  controlWrapper.KeyInputFocusGainedSignal().Connect(&TestKeyInputFocusCallback);
+
+  application.SendNotification();
+  application.Render();
+
+  controlWrapperImpl->EmitKeyInputFocusSignal( true );
+
+  DALI_TEST_CHECK( gKeyInputFocusCallBackCalled );
+
+  END_TEST;
+}