Button Upgrade to use Text Visual
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-RadioButton.cpp
index f6201e9..24b4964 100644 (file)
@@ -21,6 +21,8 @@
 #include <dali-toolkit/dali-toolkit.h>
 #include <dali/integration-api/events/touch-event-integ.h>
 
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
 
 using namespace Dali;
 using namespace Dali::Toolkit;
@@ -47,10 +49,45 @@ static void TestCallback(BaseHandle handle)
 
 }
 
-int UtcDaliRadioButtonNew(void)
+int UtcDaliRadioButtonConstructorP(void)
+{
+  TestApplication application;
+
+  RadioButton button;
+
+  DALI_TEST_CHECK( !button );
+  END_TEST;
+}
+
+int UtcDaliRadioButtonCopyConstructorP(void)
+{
+  TestApplication application;
+
+  // Initialize an object, ref count == 1
+  RadioButton button = RadioButton::New();
+
+  RadioButton copy( button );
+  DALI_TEST_CHECK( copy );
+  END_TEST;
+}
+
+int UtcDaliRadioButtonAssignmentOperatorP(void)
+{
+  TestApplication application;
+
+  RadioButton button = RadioButton::New();
+
+  RadioButton copy( button );
+  DALI_TEST_CHECK( copy );
+
+  DALI_TEST_CHECK( button == copy );
+  END_TEST;
+}
+
+int UtcDaliRadioButtonNewP(void)
 {
   ToolkitTestApplication application;
-  tet_infoline(" UtcDaliRadioButtonNew");
+  tet_infoline(" UtcDaliRadioButtonNewP");
 
   // Create the Slider actor
   RadioButton radioButton;
@@ -78,7 +115,7 @@ int UtcDaliRadioButtonNew(void)
   END_TEST;
 }
 
-int UtcDaliRadioButtonDestructor(void)
+int UtcDaliRadioButtonDestructorP(void)
 {
   ToolkitTestApplication application;
 
@@ -103,25 +140,35 @@ int UtcDaliRadioButtonDownCast(void)
 
 int UtcDaliRadioButtonLabelActor(void)
 {
-  // TODO
+  ToolkitTestApplication application;
+
+  std::string labelText = "test actor 1";
+
+  RadioButton radioButton = RadioButton::New();
+
+  radioButton.SetProperty( Toolkit::Button::Property::LABEL,
+                          Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
+                                         .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
+                        );
+
+  radioButton.SetLabelText( labelText );
+
+  DALI_TEST_EQUALS( radioButton.GetLabelText(), labelText, TEST_LOCATION );
+
+  std::string labelText2 = "test actor 2";
+  radioButton.SetLabelText( labelText2 );
+  DALI_TEST_EQUALS( radioButton.GetLabelText(), labelText2, TEST_LOCATION );
+
   END_TEST;
 }
 
-int UtcDaliRadioButtonActive(void)
+int UtcDaliRadioButtonSelected(void)
 {
   ToolkitTestApplication application;
 
   RadioButton radioButton = RadioButton::New();
 
-  // Default active
-  DALI_TEST_CHECK( radioButton.IsSelected() == false );
-
-  // False to true
-  radioButton.ToggleState();
-  DALI_TEST_CHECK( radioButton.IsSelected() == true );
-
-  // True to false
-  radioButton.ToggleState();
+  // Default selected
   DALI_TEST_CHECK( radioButton.IsSelected() == false );
 
   // False
@@ -139,10 +186,10 @@ int UtcDaliRadioButtonActive(void)
   END_TEST;
 }
 
-int UtcDaliRadioButtonActiveProperty(void)
+int UtcDaliRadioButtonSelectedProperty(void)
 {
   ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
-  tet_infoline(" UtcDaliRadioButtonActiveProperty");
+  tet_infoline(" UtcDaliRadioButtonSelectedProperty");
 
   // Create the RadioButton actor
   RadioButton radioButton = RadioButton::New();
@@ -151,20 +198,20 @@ int UtcDaliRadioButtonActiveProperty(void)
   radioButton.SetAnchorPoint(ParentOrigin::TOP_LEFT);
   radioButton.SetPosition( 0.0f, 0.0f );
 
-  // Default active
-  DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == false );
+  // Default selected
+  DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::Property::SELECTED ) == false );
 
-  // Setting false active
-  radioButton.SetProperty( Button::PROPERTY_TOGGLED, false );
-  DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == false );
+  // Setting false selected
+  radioButton.SetProperty( Button::Property::SELECTED, false );
+  DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::Property::SELECTED ) == false );
 
-  // Setting true active
-  radioButton.SetProperty( Button::PROPERTY_TOGGLED, true );
-  DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == true );
+  // Setting true selected
+  radioButton.SetProperty( Button::Property::SELECTED, true );
+  DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::Property::SELECTED ) == true );
 
   // Setting false again
-  radioButton.SetProperty( Button::PROPERTY_TOGGLED, false );
-  DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == false );
+  radioButton.SetProperty( Button::Property::SELECTED, false );
+  DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::Property::SELECTED ) == false );
 
   // Test selecting radio buttons
   RadioButton radioButton2 = RadioButton::New( "label" );
@@ -191,71 +238,107 @@ int UtcDaliRadioButtonActiveProperty(void)
   application.Render();
 
   // Simulate touch events
-  DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == false );
-  DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == false );
+  DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::Property::SELECTED ) == false );
+  DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::Property::SELECTED ) == false );
 
   // Select first radio
   {
-    Dali::Integration::TouchEvent event = Dali::Integration::TouchEvent();
+    Dali::Integration::TouchEvent event1 = Dali::Integration::TouchEvent();
+    Dali::Integration::TouchEvent event2 = Dali::Integration::TouchEvent();
+
+    Dali::Integration::Point pointDown;
+    pointDown.SetState( PointState::DOWN );
+    pointDown.SetScreenPosition( Vector2( 1.0f, 1.0f ) );
 
-    const Dali::TouchPoint pointUp( 0, TouchPoint::Up, 10.0f, 10.0f );
-    event.AddPoint( pointUp );
+    Dali::Integration::Point pointUp( pointDown );
+    pointUp.SetState( PointState::UP );
 
-    application.ProcessEvent( event );
+    event1.AddPoint( pointDown );
+    application.ProcessEvent( event1 );
+
+    event2.AddPoint( pointUp );
+    application.ProcessEvent( event2 );
 
     application.SendNotification();
     application.Render();
 
-    DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == true );
-    DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == false );
+    DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::Property::SELECTED ) == true );
+    DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::Property::SELECTED ) == false );
   }
 
   // Select an already selected radio
   {
-    Dali::Integration::TouchEvent event = Dali::Integration::TouchEvent();
+    Dali::Integration::TouchEvent event1 = Dali::Integration::TouchEvent();
+    Dali::Integration::TouchEvent event2 = Dali::Integration::TouchEvent();
+
+    Dali::Integration::Point pointDown;
+    pointDown.SetState( PointState::DOWN );
+    pointDown.SetScreenPosition( Vector2( 1.0f, 1.0f ) );
 
-    const Dali::TouchPoint pointDown( 0, TouchPoint::Up, 10.0f, 10.0f );
-    event.AddPoint( pointDown );
+    Dali::Integration::Point pointUp( pointDown );
+    pointUp.SetState( PointState::UP );
 
-    application.ProcessEvent( event );
+    event1.AddPoint( pointDown );
+    application.ProcessEvent( event1 );
+
+    event2.AddPoint( pointUp );
+    application.ProcessEvent( event2 );
 
     application.SendNotification();
     application.Render();
 
-    DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == true );
-    DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == false );
+    DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::Property::SELECTED ) == true );
+    DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::Property::SELECTED ) == false );
   }
 
   // Select second radio
   {
-    Dali::Integration::TouchEvent event = Dali::Integration::TouchEvent();
+    Dali::Integration::TouchEvent event1 = Dali::Integration::TouchEvent();
+    Dali::Integration::TouchEvent event2 = Dali::Integration::TouchEvent();
+
+    Dali::Integration::Point pointDown;
+    pointDown.SetState( PointState::DOWN );
+    pointDown.SetScreenPosition( Vector2( 1.0f, 41.0f ) );
+
+    Dali::Integration::Point pointUp( pointDown );
+    pointUp.SetState( PointState::UP );
 
-    const Dali::TouchPoint pointDown( 0, TouchPoint::Up, 10.0f, 50.0f );
-    event.AddPoint( pointDown );
+    event1.AddPoint( pointDown );
+    application.ProcessEvent( event1 );
 
-    application.ProcessEvent( event );
+    event2.AddPoint( pointUp );
+    application.ProcessEvent( event2 );
 
     application.SendNotification();
     application.Render();
 
-    DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == false );
-    DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == true );
+    DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::Property::SELECTED ) == false );
+    DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::Property::SELECTED ) == true );
   }
 
   // Select outside radio group
   {
-    Dali::Integration::TouchEvent event = Dali::Integration::TouchEvent();
+    Dali::Integration::TouchEvent event1 = Dali::Integration::TouchEvent();
+    Dali::Integration::TouchEvent event2 = Dali::Integration::TouchEvent();
+
+    Dali::Integration::Point pointDown;
+    pointDown.SetState( PointState::DOWN );
+    pointDown.SetScreenPosition( Vector2( 1.0f, 500.0f ) );
+
+    Dali::Integration::Point pointUp( pointDown );
+    pointUp.SetState( PointState::UP );
 
-    const Dali::TouchPoint pointDown( 0, TouchPoint::Up, 10.0f, 500.0f );
-    event.AddPoint( pointDown );
+    event1.AddPoint( pointDown );
+    application.ProcessEvent( event1 );
 
-    application.ProcessEvent( event );
+    event2.AddPoint( pointUp );
+    application.ProcessEvent( event2 );
 
     application.SendNotification();
     application.Render();
 
-    DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == false );
-    DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == true );
+    DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::Property::SELECTED ) == false );
+    DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::Property::SELECTED ) == true );
   }
 
   END_TEST;