(Touch) Updated programming guide, Automated Tests & KeyboardFocusManager to use...
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-internal / utc-Dali-PushButton.cpp
index 05ced5a..edaf7fd 100644 (file)
@@ -38,13 +38,38 @@ bool PushButtonSelected( Button button, bool selected )
 }
 
 
-const Dali::TouchPoint pointDownInside( 0, TouchPoint::Down, 240, 400 );
-const Dali::TouchPoint pointUpInside( 0, TouchPoint::Up, 240, 400 );
-const Dali::TouchPoint pointLeave( 0, TouchPoint::Leave, 240, 400 );
-const Dali::TouchPoint pointEnter( 0, TouchPoint::Motion, 240, 400 );
-const Dali::TouchPoint pointMotionOut( 0, TouchPoint::Motion, 10, 10 );
-const Dali::TouchPoint pointDownOutside( 0, TouchPoint::Down, 10, 10 );
-const Dali::TouchPoint pointUpOutside( 0, TouchPoint::Up, 10, 10 );
+Dali::Integration::Point GetPointDownInside()
+{
+  Dali::Integration::Point point;
+  point.SetState( PointState::DOWN );
+  point.SetScreenPosition( Vector2( 240, 400 ) );
+  return point;
+}
+
+Dali::Integration::Point GetPointUpInside()
+{
+  Dali::Integration::Point point;
+  point.SetState( PointState::UP );
+  point.SetScreenPosition( Vector2( 240, 400 ) );
+  return point;
+}
+
+Dali::Integration::Point GetPointMotionOut()
+{
+  Dali::Integration::Point point;
+  point.SetState( PointState::MOTION );
+  point.SetScreenPosition( Vector2( 10, 10 ) );
+  return point;
+}
+
+Dali::Integration::Point GetPointUpOutside()
+{
+  Dali::Integration::Point point;
+  point.SetState( PointState::UP );
+  point.SetScreenPosition( Vector2( 10, 10 ) );
+  return point;
+}
+
 } // namespace
 
 
@@ -304,7 +329,7 @@ public:
   Test mTest;
 };
 
-static bool TestCallback(Actor actor, const TouchEvent& event)
+static bool TestCallback(Actor actor, const TouchData& event)
 {
   return true;
 }
@@ -313,6 +338,22 @@ static bool TestCallback(Actor actor, const TouchEvent& event)
 
 //////////////////////////////////////////////////////////
 
+int UtcDaliPushButtonDownCast(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliPushButtonDownCast");
+
+  TETButton tetButton= Toolkit::TETButton::New();
+
+  BaseHandle object(tetButton);
+
+  TETButton tetButton2 = TETButton::DownCast( object );
+  DALI_TEST_CHECK(tetButton2);
+
+  TETButton tetButton3 = DownCast< TETButton >(object);
+  DALI_TEST_CHECK(tetButton3);
+  END_TEST;
+}
 
 int UtcDaliPushButtonInterruptEventWhenInsensitive(void)
 {
@@ -343,7 +384,7 @@ int UtcDaliPushButtonInterruptEventWhenInsensitive(void)
 
   // * Actor's touch event is connected to a callback function
   //   and this callback function consumes the event.
-  actor.TouchedSignal().Connect( &TestCallback );
+  actor.TouchSignal().Connect( &TestCallback );
 
   // * Button's pressed signal is connected to a callback function
   //   which also consumes the event.
@@ -369,7 +410,7 @@ int UtcDaliPushButtonInterruptEventWhenInsensitive(void)
   // A down event is sent inside the button's boundary.
 
   event = Dali::Integration::TouchEvent();
-  event.AddPoint( pointDownInside );
+  event.AddPoint( GetPointDownInside() );
 
   // flush the queue and render once
   application.SendNotification();
@@ -379,7 +420,7 @@ int UtcDaliPushButtonInterruptEventWhenInsensitive(void)
   // An up event is sent outside the button's boundary but inside the actor's one.
 
   event = Dali::Integration::TouchEvent();
-  event.AddPoint( pointUpOutside );
+  event.AddPoint( GetPointUpOutside() );
 
   // flush the queue and render once
   application.SendNotification();
@@ -403,7 +444,7 @@ int UtcDaliPushButtonInterruptEventWhenInsensitive(void)
   // A down event is sent inside the button's boundary.
 
   event = Dali::Integration::TouchEvent();
-  event.AddPoint( pointDownInside );
+  event.AddPoint( GetPointDownInside() );
 
   // flush the queue and render once
   application.SendNotification();
@@ -413,7 +454,7 @@ int UtcDaliPushButtonInterruptEventWhenInsensitive(void)
   // A motion event is sent outside the button's boundary but inside the actor's one.
 
   event = Dali::Integration::TouchEvent();
-  event.AddPoint( pointMotionOut );
+  event.AddPoint( GetPointMotionOut() );
 
   // flush the queue and render once
   application.SendNotification();
@@ -433,7 +474,7 @@ int UtcDaliPushButtonInterruptEventWhenInsensitive(void)
   // A down event is sent inside the button's boundary.
 
   event = Dali::Integration::TouchEvent();
-  event.AddPoint( pointDownInside );
+  event.AddPoint( GetPointDownInside() );
 
   // flush the queue and render once
   application.SendNotification();
@@ -444,7 +485,7 @@ int UtcDaliPushButtonInterruptEventWhenInsensitive(void)
   // An up event is sent inside the button's boundary.
 
   event = Dali::Integration::TouchEvent();
-  event.AddPoint( pointUpInside );
+  event.AddPoint( GetPointUpInside() );
 
   // flush the queue and render once
   application.SendNotification();
@@ -486,7 +527,7 @@ int UtcDaliPushButtonInterruptEventWhenNonVisible(void)
 
   // * Actor's touch event is connected to a callback function
   //   and this callback function consumes the event.
-  actor.TouchedSignal().Connect( &TestCallback );
+  actor.TouchSignal().Connect( &TestCallback );
 
   // * Button's pressed signal is connected to a callback function
   //   which also consumes the event.
@@ -512,7 +553,7 @@ int UtcDaliPushButtonInterruptEventWhenNonVisible(void)
   // A down event is sent inside the button's boundary.
 
   event = Dali::Integration::TouchEvent();
-  event.AddPoint( pointDownInside );
+  event.AddPoint( GetPointDownInside() );
 
   // flush the queue and render once
   application.SendNotification();
@@ -530,7 +571,7 @@ int UtcDaliPushButtonInterruptEventWhenNonVisible(void)
   // An up event is sent outside the button's boundary but inside the actor's one.
 
   event = Dali::Integration::TouchEvent();
-  event.AddPoint( pointUpOutside );
+  event.AddPoint( GetPointUpOutside() );
 
   // flush the queue and render once
   application.SendNotification();
@@ -557,7 +598,7 @@ int UtcDaliPushButtonInterruptEventWhenNonVisible(void)
   // A down event is sent inside the button's boundary.
 
   event = Dali::Integration::TouchEvent();
-  event.AddPoint( pointDownInside );
+  event.AddPoint( GetPointDownInside() );
 
   // flush the queue and render once
   application.SendNotification();
@@ -575,7 +616,7 @@ int UtcDaliPushButtonInterruptEventWhenNonVisible(void)
   // A motion event is sent outside the button's boundary but inside the actor's one.
 
   event = Dali::Integration::TouchEvent();
-  event.AddPoint( pointMotionOut );
+  event.AddPoint( GetPointMotionOut() );
 
   // flush the queue and render once
   application.SendNotification();
@@ -601,7 +642,7 @@ int UtcDaliPushButtonInterruptEventWhenNonVisible(void)
   // A down event is sent inside the button's boundary.
 
   event = Dali::Integration::TouchEvent();
-  event.AddPoint( pointDownInside );
+  event.AddPoint( GetPointDownInside() );
 
   // flush the queue and render once
   application.SendNotification();
@@ -620,7 +661,7 @@ int UtcDaliPushButtonInterruptEventWhenNonVisible(void)
   // An up event is sent inside the button's boundary.
 
   event = Dali::Integration::TouchEvent();
-  event.AddPoint( pointUpInside );
+  event.AddPoint( GetPointUpInside() );
 
   // flush the queue and render once
   application.SendNotification();
@@ -673,53 +714,5 @@ int UtcDaliPushButtonProperties(void)
   DALI_TEST_CHECK( button.IsSelected() ) ;
   DALI_TEST_CHECK( button.GetProperty< bool >( Button::Property::SELECTED ) );
 
-  //  Button::PROPERTY_NORMAL_STATE_ACTOR
-  {
-    button.SetButtonImage( ResourceImage::New( "IMAGE_PATH_1") );
-    DALI_TEST_EQUALS( "IMAGE_PATH_1", button.GetProperty( Button::Property::NORMAL_STATE_ACTOR ).GetValue( "image" ).GetValue( "filename" ).Get< std::string >(), TEST_LOCATION );
-
-    Property::Map map;
-    map[ "type" ] = "ImageActor";
-
-    button.SetProperty( Button::Property::NORMAL_STATE_ACTOR, map );
-    DALI_TEST_EQUALS( "ImageActor", button.GetProperty( Button::Property::NORMAL_STATE_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION );
-  }
-
-  //  Button::PROPERTY_SELECTED_STATE_ACTOR
-  {
-    button.SetSelectedImage( ResourceImage::New( "IMAGE_PATH_2") );
-    DALI_TEST_EQUALS( "IMAGE_PATH_2", button.GetProperty( Button::Property::SELECTED_STATE_ACTOR ).GetValue( "image" ).GetValue( "filename" ).Get< std::string >(), TEST_LOCATION );
-
-    Property::Map map;
-    map[ "type" ] = "Actor";
-
-    button.SetProperty( Button::Property::SELECTED_STATE_ACTOR, map );
-    DALI_TEST_EQUALS( "Actor", button.GetProperty( Button::Property::SELECTED_STATE_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION );
-    DALI_TEST_CHECK( "ImageActor" != button.GetProperty( Button::Property::SELECTED_STATE_ACTOR ).GetValue( "type" ).Get< std::string >() );
-  }
-
-  //  Button::PROPERTY_DISABLED_STATE_ACTOR
-  {
-    button.SetDisabledImage( ResourceImage::New( "IMAGE_PATH_3") );
-    DALI_TEST_EQUALS( "IMAGE_PATH_3", button.GetProperty( Button::Property::DISABLED_STATE_ACTOR ).GetValue( "image" ).GetValue( "filename" ).Get< std::string >(), TEST_LOCATION );
-
-    Property::Map map;
-    map[ "type" ] = "Actor";
-
-    button.SetProperty( Button::Property::DISABLED_STATE_ACTOR, map );
-    DALI_TEST_EQUALS( "Actor", button.GetProperty( Button::Property::DISABLED_STATE_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION );
-  }
-
-  //  Button::PROPERTY_LABEL_ACTOR
-  {
-    button.SetLabel( "LABEL_TEXT_CUSTOM" );
-    DALI_TEST_EQUALS( "TextView", button.GetProperty( Button::Property::LABEL_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION );
-
-    Property::Map map;
-    map[ "type" ] = "Actor";
-
-    button.SetProperty( Button::Property::LABEL_ACTOR, map );
-    DALI_TEST_EQUALS( "Actor", button.GetProperty( Button::Property::LABEL_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION );
-  }
   END_TEST;
 }