Merge "Fix Svace issue" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-RadioButton.cpp
index ca1ac84..07f275e 100644 (file)
@@ -47,10 +47,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 +113,7 @@ int UtcDaliRadioButtonNew(void)
   END_TEST;
 }
 
-int UtcDaliRadioButtonDestructor(void)
+int UtcDaliRadioButtonDestructorP(void)
 {
   ToolkitTestApplication application;
 
@@ -103,7 +138,17 @@ int UtcDaliRadioButtonDownCast(void)
 
 int UtcDaliRadioButtonLabelActor(void)
 {
-  // TODO
+  ToolkitTestApplication application;
+
+  std::string labelText = "test actor 1";
+
+  RadioButton radioButton = RadioButton::New( 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;
 }
 
@@ -144,19 +189,19 @@ int UtcDaliRadioButtonSelectedProperty(void)
   radioButton.SetPosition( 0.0f, 0.0f );
 
   // Default selected
-  DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::PROPERTY_SELECTED ) == false );
+  DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::Property::SELECTED ) == false );
 
   // Setting false selected
-  radioButton.SetProperty( Button::PROPERTY_SELECTED, false );
-  DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::PROPERTY_SELECTED ) == false );
+  radioButton.SetProperty( Button::Property::SELECTED, false );
+  DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::Property::SELECTED ) == false );
 
   // Setting true selected
-  radioButton.SetProperty( Button::PROPERTY_SELECTED, true );
-  DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::PROPERTY_SELECTED ) == true );
+  radioButton.SetProperty( Button::Property::SELECTED, true );
+  DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::Property::SELECTED ) == true );
 
   // Setting false again
-  radioButton.SetProperty( Button::PROPERTY_SELECTED, false );
-  DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::PROPERTY_SELECTED ) == 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" );
@@ -183,16 +228,20 @@ int UtcDaliRadioButtonSelectedProperty(void)
   application.Render();
 
   // Simulate touch events
-  DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_SELECTED ) == false );
-  DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_SELECTED ) == 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 event1 = Dali::Integration::TouchEvent();
     Dali::Integration::TouchEvent event2 = Dali::Integration::TouchEvent();
 
-    const Dali::TouchPoint pointDown( 0, TouchPoint::Down, 10.0f, 10.0f );
-    const Dali::TouchPoint pointUp( 0, TouchPoint::Up, 10.0f, 10.0f );
+    Dali::Integration::Point pointDown;
+    pointDown.SetState( PointState::DOWN );
+    pointDown.SetScreenPosition( Vector2( 1.0f, 1.0f ) );
+
+    Dali::Integration::Point pointUp( pointDown );
+    pointUp.SetState( PointState::UP );
 
     event1.AddPoint( pointDown );
     application.ProcessEvent( event1 );
@@ -203,8 +252,8 @@ int UtcDaliRadioButtonSelectedProperty(void)
     application.SendNotification();
     application.Render();
 
-    DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_SELECTED ) == true );
-    DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_SELECTED ) == 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
@@ -212,8 +261,12 @@ int UtcDaliRadioButtonSelectedProperty(void)
     Dali::Integration::TouchEvent event1 = Dali::Integration::TouchEvent();
     Dali::Integration::TouchEvent event2 = Dali::Integration::TouchEvent();
 
-    const Dali::TouchPoint pointDown( 0, TouchPoint::Down, 10.0f, 10.0f );
-    const Dali::TouchPoint pointUp( 0, TouchPoint::Up, 10.0f, 10.0f );
+    Dali::Integration::Point pointDown;
+    pointDown.SetState( PointState::DOWN );
+    pointDown.SetScreenPosition( Vector2( 1.0f, 1.0f ) );
+
+    Dali::Integration::Point pointUp( pointDown );
+    pointUp.SetState( PointState::UP );
 
     event1.AddPoint( pointDown );
     application.ProcessEvent( event1 );
@@ -224,8 +277,8 @@ int UtcDaliRadioButtonSelectedProperty(void)
     application.SendNotification();
     application.Render();
 
-    DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_SELECTED ) == true );
-    DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_SELECTED ) == false );
+    DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::Property::SELECTED ) == true );
+    DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::Property::SELECTED ) == false );
   }
 
   // Select second radio
@@ -233,8 +286,12 @@ int UtcDaliRadioButtonSelectedProperty(void)
     Dali::Integration::TouchEvent event1 = Dali::Integration::TouchEvent();
     Dali::Integration::TouchEvent event2 = Dali::Integration::TouchEvent();
 
-    const Dali::TouchPoint pointDown( 0, TouchPoint::Down, 10.0f, 50.0f );
-    const Dali::TouchPoint pointUp( 0, TouchPoint::Up, 10.0f, 50.0f );
+    Dali::Integration::Point pointDown;
+    pointDown.SetState( PointState::DOWN );
+    pointDown.SetScreenPosition( Vector2( 1.0f, 41.0f ) );
+
+    Dali::Integration::Point pointUp( pointDown );
+    pointUp.SetState( PointState::UP );
 
     event1.AddPoint( pointDown );
     application.ProcessEvent( event1 );
@@ -245,8 +302,8 @@ int UtcDaliRadioButtonSelectedProperty(void)
     application.SendNotification();
     application.Render();
 
-    DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_SELECTED ) == false );
-    DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_SELECTED ) == 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
@@ -254,8 +311,12 @@ int UtcDaliRadioButtonSelectedProperty(void)
     Dali::Integration::TouchEvent event1 = Dali::Integration::TouchEvent();
     Dali::Integration::TouchEvent event2 = Dali::Integration::TouchEvent();
 
-    const Dali::TouchPoint pointDown( 0, TouchPoint::Down, 10.0f, 500.0f );
-    const Dali::TouchPoint pointUp( 0, TouchPoint::Up, 10.0f, 500.0f );
+    Dali::Integration::Point pointDown;
+    pointDown.SetState( PointState::DOWN );
+    pointDown.SetScreenPosition( Vector2( 1.0f, 500.0f ) );
+
+    Dali::Integration::Point pointUp( pointDown );
+    pointUp.SetState( PointState::UP );
 
     event1.AddPoint( pointDown );
     application.ProcessEvent( event1 );
@@ -266,8 +327,8 @@ int UtcDaliRadioButtonSelectedProperty(void)
     application.SendNotification();
     application.Render();
 
-    DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_SELECTED ) == false );
-    DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_SELECTED ) == true );
+    DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::Property::SELECTED ) == false );
+    DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::Property::SELECTED ) == true );
   }
 
   END_TEST;