[dali_1.0.38] Merge branch 'tizen'
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-CustomActor.cpp
index aa10dd3..87dd3ca 100644 (file)
@@ -169,23 +169,45 @@ struct TestCustomActor : public CustomActorImpl
   {
     AddToCallStacks("OnKeyInputFocusLost");
   }
-  virtual Actor GetChildByAlias(const std::string& actorAlias)
+  virtual Vector3 GetNaturalSize()
   {
-    AddToCallStacks("GetChildByAlias");
+    return Vector3( 0.0f, 0.0f, 0.0f );
+  }
 
-    if ("found" == actorAlias)
-    {
-      return Actor::New();
-    }
-    else
-    {
-      return Actor();
-    }
+  virtual float GetHeightForWidth( float width )
+  {
+    return 0.0f;
   }
 
-  virtual Vector3 GetNaturalSize()
+  virtual float GetWidthForHeight( float height )
   {
-    return Vector3( 0.0f, 0.0f, 0.0f );
+    return 0.0f;
+  }
+
+  virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
+  {
+  }
+
+  virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
+  {
+  }
+
+  virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
+  {
+  }
+
+  virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
+  {
+    return 0.0f;
+  }
+
+  virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
+  {
+  }
+
+  virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
+  {
+    return false;
   }
 
   void SetDaliProperty(std::string s)
@@ -482,14 +504,45 @@ public:
   {
   }
 
-  virtual Actor GetChildByAlias(const std::string& actorAlias)
+  virtual Vector3 GetNaturalSize()
   {
-    return Actor();
+    return Vector3( 0.0f, 0.0f, 0.0f );
   }
 
-  virtual Vector3 GetNaturalSize()
+  virtual float GetHeightForWidth( float width )
+  {
+    return 0.0f;
+  }
+
+  virtual float GetWidthForHeight( float height )
+  {
+    return 0.0f;
+  }
+
+  virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
+  {
+  }
+
+  virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
   {
-    return Vector3( 0.0f, 0.0f, 0.0f );
+  }
+
+  virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
+  {
+  }
+
+  virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
+  {
+    return 0.0f;
+  }
+
+  virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
+  {
+  }
+
+  virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS )
+  {
+    return false;
   }
 };
 
@@ -635,6 +688,28 @@ public:
     return Vector3( 0.0f, 0.0f, 0.0f );
   }
 
+  virtual float GetHeightForWidth( float width )
+  {
+    return 0.0f;
+  }
+
+  virtual float GetWidthForHeight( float height )
+  {
+    return 0.0f;
+  }
+
+  virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
+  {
+  }
+
+  virtual void OnLayoutNegotiated( float size, Dimension::Type dimension )
+  {
+  }
+
+  virtual void OnCalculateRelayoutSize( Dimension::Type dimension )
+  {
+  }
+
 private:
 
   TestCustomActor( Impl::TestCustomActor& impl ) : CustomActor( impl )
@@ -643,11 +718,16 @@ private:
 };
 
 
+
+using namespace Dali;
+
 BaseHandle CreateActor()
 {
   return TestCustomActor::New();
 }
 
+Dali::TypeRegistration mType( typeid(TestCustomActor), typeid(Dali::CustomActor), CreateActor );
+
 } // anon namespace
 
 
@@ -1477,18 +1557,12 @@ int UtcDaliCustomActorOnSizeAnimation(void)
   DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
 
   Animation anim = Animation::New( 1.0f );
-  anim.Resize( custom, Vector3( 8.0f, 9.0f, 10.0f ) );
+  anim.AnimateTo( Property( custom, Actor::Property::SIZE ), Vector3( 8.0f, 9.0f, 10.0f ) );
   DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
   DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
   DALI_TEST_EQUALS( 8.0f, custom.GetTargetSize().width, TEST_LOCATION );
   DALI_TEST_EQUALS( 9.0f, custom.GetTargetSize().height, TEST_LOCATION );
   DALI_TEST_EQUALS( 10.0f, custom.GetTargetSize().depth, TEST_LOCATION );
-
-  anim.Resize( custom, 1.0f, 2.0f );
-  DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
-  DALI_TEST_EQUALS( "OnSizeAnimation", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
-  DALI_TEST_EQUALS( 1.0f, custom.GetTargetSize().width, TEST_LOCATION );
-  DALI_TEST_EQUALS( 2.0f, custom.GetTargetSize().height, TEST_LOCATION );
   END_TEST;
 }
 
@@ -1584,27 +1658,6 @@ int UtcDaliCustomActorOnMouseWheelEvent(void)
   END_TEST;
 }
 
-int UtcDaliCustomActorFindChildByAlias(void)
-{
-  TestApplication application;
-  tet_infoline("Testing Dali::CustomActor::GetChildByAlias()");
-
-  TestCustomActor custom = TestCustomActor::New();
-  DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
-
-  custom.Add(Actor::New());
-
-  DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
-
-  DALI_TEST_CHECK( !custom.FindChildByAlias("not-found") );
-
-  DALI_TEST_EQUALS( 2, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
-  DALI_TEST_EQUALS( "GetChildByAlias", custom.GetMethodsCalled()[ 1 ], TEST_LOCATION );
-
-  DALI_TEST_CHECK( custom.FindChildByAlias("found") );
-  END_TEST;
-}
-
 int UtcDaliCustomActorImplOnPropertySet(void)
 {
   TestApplication application;
@@ -1633,3 +1686,45 @@ int UtcDaliCustomActorGetImplementation(void)
   DALI_TEST_CHECK( true );
   END_TEST;
 }
+
+int UtcDaliCustomActorDoAction(void)
+{
+  TestApplication application;
+  tet_infoline("Testing Dali::CustomActor::DoAction()");
+
+  TestCustomActor custom = TestCustomActor::New();
+
+  BaseHandle customActorObject = custom;
+
+  DALI_TEST_CHECK(customActorObject);
+
+  std::vector<Property::Value> attributes;
+
+  // Check that an invalid command is not performed
+  DALI_TEST_CHECK(customActorObject.DoAction("invalidCommand", attributes) == false);
+
+  // Check that the custom actor is visible
+  custom.SetVisible(true);
+  DALI_TEST_CHECK(custom.IsVisible() == true);
+
+  // Check the custom actor performed an action to hide itself
+  DALI_TEST_CHECK(customActorObject.DoAction("hide", attributes) == true);
+
+  // flush the queue and render once
+  application.SendNotification();
+  application.Render();
+
+  // Check that the custom actor is now invisible
+  DALI_TEST_CHECK(custom.IsVisible() == false);
+
+  // Check the custom actor performed an action to show itself
+  DALI_TEST_CHECK(customActorObject.DoAction("show", attributes) == true);
+
+  // flush the queue and render once
+  application.SendNotification();
+  application.Render();
+
+  // Check that the custom actor is now visible
+  DALI_TEST_CHECK(custom.IsVisible() == true);
+  END_TEST;
+}