[AT-SPI] Squashed implementation
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-Button.cpp
index 73067bb..83ebfb6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 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.
@@ -139,13 +139,11 @@ Dali::Integration::Point GetPointUpOutside()
   return point;
 }
 
-static float ANIMATION_TIME( 0.5f );
-
 } // namespace
 
 int UtcDaliButtonConstructorP(void)
 {
-  TestApplication application;
+  ToolkitTestApplication application;
 
   Button button;
 
@@ -155,7 +153,7 @@ int UtcDaliButtonConstructorP(void)
 
 int UtcDaliButtonCopyConstructorP(void)
 {
-  TestApplication application;
+  ToolkitTestApplication application;
 
   // Initialize an object, ref count == 1
   Button button = PushButton::New();
@@ -165,9 +163,28 @@ int UtcDaliButtonCopyConstructorP(void)
   END_TEST;
 }
 
+int UtcDaliButtonMoveConstructor(void)
+{
+  ToolkitTestApplication application;
+
+  Button button = PushButton::New();
+  DALI_TEST_EQUALS( 1, button.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+  DALI_TEST_EQUALS( button.GetProperty<bool>( Button::Property::TOGGLABLE ), false , TEST_LOCATION );
+  button.SetProperty( Button::Property::TOGGLABLE, true );
+  DALI_TEST_EQUALS( button.GetProperty<bool>( Button::Property::TOGGLABLE ), true , TEST_LOCATION );
+
+  Button moved = std::move( button );
+  DALI_TEST_CHECK( moved );
+  DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+  DALI_TEST_EQUALS( moved.GetProperty<bool>( Button::Property::TOGGLABLE ), true , TEST_LOCATION );
+  DALI_TEST_CHECK( !button );
+
+  END_TEST;
+}
+
 int UtcDaliButtonAssignmentOperatorP(void)
 {
-  TestApplication application;
+  ToolkitTestApplication application;
 
   Button button = PushButton::New();
 
@@ -178,9 +195,29 @@ int UtcDaliButtonAssignmentOperatorP(void)
   END_TEST;
 }
 
+int UtcDaliButtonMoveAssignment(void)
+{
+  ToolkitTestApplication application;
+
+  Button button = PushButton::New();
+  DALI_TEST_EQUALS( 1, button.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+  DALI_TEST_EQUALS( button.GetProperty<bool>( Button::Property::TOGGLABLE ), false , TEST_LOCATION );
+  button.SetProperty( Button::Property::TOGGLABLE, true );
+  DALI_TEST_EQUALS( button.GetProperty<bool>( Button::Property::TOGGLABLE ), true , TEST_LOCATION );
+
+  Button moved;
+  moved = std::move( button );
+  DALI_TEST_CHECK( moved );
+  DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+  DALI_TEST_EQUALS( moved.GetProperty<bool>( Button::Property::TOGGLABLE ), true , TEST_LOCATION );
+  DALI_TEST_CHECK( !button );
+
+  END_TEST;
+}
+
 int UtcDaliButtonDownCastP(void)
 {
-  TestApplication application;
+  ToolkitTestApplication application;
 
   Button button = PushButton::New();
 
@@ -196,7 +233,7 @@ int UtcDaliButtonDownCastP(void)
 
 int UtcDaliButtonDownCastN(void)
 {
-  TestApplication application;
+  ToolkitTestApplication application;
 
   BaseHandle unInitializedObject;
 
@@ -277,7 +314,7 @@ int UtcDaliButtonSetDisabledWithDifferentStates02P(void)
   DALI_TEST_EQUALS( isSelected, SELECTED , TEST_LOCATION );
   tet_infoline("Set button to DISABLED = false whilst disabled and then set to unselected\n");
 
-  button.SetProperty( Button::Property::DISABLED, false );
+  button.SetProperty( Button::Property::DISABLED, false);
   button.SetProperty( Button::Property::SELECTED, !SELECTED );
 
   isSelected = button.GetProperty<bool>( Button::Property::SELECTED );
@@ -304,13 +341,13 @@ int UtcDaliButtonIsDisabledP(void)
 
   Button button = PushButton::New();
 
-  button.SetDisabled( true );
+  button.SetProperty( Button::Property::DISABLED, true);
 
-  DALI_TEST_CHECK( button.IsDisabled() );
+  DALI_TEST_EQUALS( button.GetProperty<bool>( Button::Property::DISABLED ), true, TEST_LOCATION );
 
-  button.SetDisabled( false );
+  button.SetProperty( Button::Property::DISABLED, false);
 
-  DALI_TEST_CHECK( !button.IsDisabled() );
+  DALI_TEST_EQUALS( button.GetProperty<bool>( Button::Property::DISABLED ), false, TEST_LOCATION );
   END_TEST;
 }
 
@@ -332,9 +369,6 @@ int UtcDaliButtonAutoRepeatingPropertyP(void)
 
   DALI_TEST_EQUALS( button.GetProperty<bool>( button.GetPropertyIndex("autoRepeating")), true, TEST_LOCATION );
 
-  button.SetAutoRepeating( false );
-
-  DALI_TEST_CHECK( !button.IsAutoRepeating() );
   END_TEST;
 }
 
@@ -344,13 +378,14 @@ int UtcDaliButtonIsAutoRepeatingP(void)
 
   Button button = PushButton::New();
 
-  button.SetAutoRepeating( true );
+  button.SetProperty( Button::Property::AUTO_REPEATING, true);
+
+  DALI_TEST_EQUALS( button.GetProperty<bool>( Button::Property::AUTO_REPEATING ), true, TEST_LOCATION );
 
-  DALI_TEST_CHECK( button.IsAutoRepeating() );
+  button.SetProperty( Button::Property::AUTO_REPEATING, false);
 
-  button.SetAutoRepeating( false );
+  DALI_TEST_EQUALS( button.GetProperty<bool>( Button::Property::AUTO_REPEATING ), false, TEST_LOCATION );
 
-  DALI_TEST_CHECK( !button.IsAutoRepeating() );
   END_TEST;
 }
 
@@ -362,11 +397,11 @@ int UtcDaliButtonAutoRepeatingP(void)
   const float AUTO_REPEATING_DELAY = 0.15f;
 
   Button button = PushButton::New();
-  button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-  button.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  button.SetPosition( 240, 400 );
-  button.SetSize( 100, 100 );
-  Stage::GetCurrent().Add( button );
+  button.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+  button.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  button.SetProperty( Actor::Property::POSITION, Vector2( 240, 400 ));
+  button.SetProperty( Actor::Property::SIZE, Vector2( 100, 100 ) );
+  application.GetScene().Add( button );
 
   application.SendNotification();
   application.Render();
@@ -480,19 +515,6 @@ int UtcDaliButtonSelectedPropertyP(void)
   END_TEST;
 }
 
-int UtcDaliButtonSetAnimationTimeP(void)
-{
-  ToolkitTestApplication application;
-  tet_infoline(" UtcDaliButtonSetAnimationTimeP");
-
-  Button button = PushButton::New();
-
-  button.SetAnimationTime( ANIMATION_TIME );
-
-  DALI_TEST_EQUALS( button.GetAnimationTime(), ANIMATION_TIME, TEST_LOCATION );
-  END_TEST;
-}
-
 int UtcDaliButtonSetLabelStringWithPropertyMapP(void)
 {
   ToolkitTestApplication application;
@@ -605,12 +627,12 @@ int UtcDaliButtonPressedSignalP(void)
   tet_infoline(" UtcDaliButtonPressedSignalP");
 
   Button button = PushButton::New();
-  button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-  button.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  button.SetPosition( 240, 400 );
-  button.SetSize( 100, 100 );
+  button.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+  button.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  button.SetProperty( Actor::Property::POSITION, Vector2( 240, 400 ));
+  button.SetProperty( Actor::Property::SIZE, Vector2( 100, 100 ) );
 
-  Stage::GetCurrent().Add( button );
+  application.GetScene().Add( button );
 
   application.SendNotification();
   application.Render();
@@ -712,12 +734,12 @@ int UtcDaliButtonClickedSignalP(void)
   tet_infoline(" UtcDaliButtonClickedSignalP");
 
   Button button = PushButton::New();
-  button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-  button.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  button.SetPosition( 240, 400 );
-  button.SetSize( 100, 100 );
+  button.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+  button.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  button.SetProperty( Actor::Property::POSITION, Vector2( 240, 400 ));
+  button.SetProperty( Actor::Property::SIZE, Vector2( 100, 100 ) );
 
-  Stage::GetCurrent().Add( button );
+  application.GetScene().Add( button );
 
   application.SendNotification();
   application.Render();
@@ -808,7 +830,7 @@ int UtcDaliButtonStateChangedSignalP(void)
 
   button.SetProperty( Button::Property::TOGGLABLE, true);
 
-  Stage::GetCurrent().Add( button );
+  application.GetScene().Add( button );
 
   application.SendNotification();
   application.Render();
@@ -851,121 +873,6 @@ int UtcDaliButtonSetProperty(void)
   END_TEST;
 }
 
-// Deprecated API Tests
-
-int UtcDaliButtonSetDisabledP(void)
-{
-  ToolkitTestApplication application;
-
-  Button button = PushButton::New();
-
-  button.SetDisabled( true );
-
-  DALI_TEST_CHECK( button.IsDisabled() );
-
-  button.SetDisabled( false );
-
-  DALI_TEST_CHECK( !button.IsDisabled() );
-
-  button.SetDisabled( true );
-
-  DALI_TEST_CHECK( button.IsDisabled() );
-
-  button.SetDisabled( false );
-
-  DALI_TEST_CHECK( !button.IsDisabled() );
-  END_TEST;
-}
-
-int UtcDaliButtonSetAutoRepeatingP(void)
-{
-  ToolkitTestApplication application;
-
-  Button button = PushButton::New();
-
-  button.SetAutoRepeating( true );
-
-  DALI_TEST_CHECK( button.IsAutoRepeating() );
-
-  button.SetAutoRepeating( false );
-
-  DALI_TEST_CHECK( !button.IsAutoRepeating() );
-
-  button.SetAutoRepeating( true );
-
-  DALI_TEST_CHECK( button.IsAutoRepeating() );
-
-  button.SetAutoRepeating( false );
-
-  DALI_TEST_CHECK( !button.IsAutoRepeating() );
-  END_TEST;
-}
-
-int UtcDaliButtonSetInitialAutoRepeatingDelayP(void)
-{
-  ToolkitTestApplication application;
-
-  Button button = PushButton::New();
-
-  button.SetInitialAutoRepeatingDelay( 0.5f );
-
-  DALI_TEST_EQUALS( button.GetInitialAutoRepeatingDelay(), 0.5f, TEST_LOCATION );
-
-  button.SetInitialAutoRepeatingDelay( 0.2f );
-
-  DALI_TEST_EQUALS( button.GetInitialAutoRepeatingDelay(), 0.2f, TEST_LOCATION );
-  END_TEST;
-}
-
-int UtcDaliButtonSetNextAutoRepeatingDelayP(void)
-{
-  ToolkitTestApplication application;
-
-  Button button = PushButton::New();
-
-  button.SetNextAutoRepeatingDelay( 0.5f );
-
-  DALI_TEST_EQUALS( button.GetNextAutoRepeatingDelay(), 0.5f, TEST_LOCATION );
-
-  button.SetProperty( Button::Property::NEXT_AUTO_REPEATING_DELAY, 0.2f );
-
-  DALI_TEST_EQUALS( button.GetNextAutoRepeatingDelay(), 0.2f, TEST_LOCATION );
-  END_TEST;
-}
-
-int UtcDaliButtonSetTogglableButtonP(void)
-{
-  ToolkitTestApplication application;
-
-  Button button = PushButton::New();
-
-  button.SetTogglableButton( true );
-
-  DALI_TEST_CHECK( button.IsTogglableButton() );
-
-  button.SetTogglableButton( false );
-
-  DALI_TEST_CHECK( !button.IsTogglableButton() );
-  END_TEST;
-}
-
-int UtcDaliButtonSetSelectedP(void)
-{
-  ToolkitTestApplication application;
-
-  Button button = PushButton::New();
-  button.SetTogglableButton( true );
-
-  button.SetSelected( true );
-
-  DALI_TEST_CHECK( button.IsSelected() );
-
-  button.SetSelected( false );
-
-  DALI_TEST_CHECK( !button.IsSelected() );
-  END_TEST;
-}
-
 int UtcDaliButtonEventConsumption(void)
 {
   /**
@@ -980,15 +887,15 @@ int UtcDaliButtonEventConsumption(void)
   ToolkitTestApplication application;
 
   Button parentButton = PushButton::New();
-  parentButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-  parentButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  parentButton.SetSize( 20, 20 );
-  Stage::GetCurrent().Add( parentButton );
+  parentButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+  parentButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  parentButton.SetProperty( Actor::Property::SIZE, Vector2( 20, 20 ) );
+  application.GetScene().Add( parentButton );
 
   Button childButton = PushButton::New();
-  childButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-  childButton.SetParentOrigin( ParentOrigin::BOTTOM_LEFT );
-  childButton.SetSize( 20, 20 );
+  childButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+  childButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT );
+  childButton.SetProperty( Actor::Property::SIZE, Vector2( 20, 20 ) );
   parentButton.Add( childButton );
 
   // Reset signal flags
@@ -1034,10 +941,10 @@ int UtcDaliButtonRelease(void)
   ToolkitTestApplication application;
 
   Button parentButton = PushButton::New();
-  parentButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-  parentButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  parentButton.SetSize( 20, 20 );
-  Stage::GetCurrent().Add( parentButton );
+  parentButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+  parentButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  parentButton.SetProperty( Actor::Property::SIZE, Vector2( 20, 20 ) );
+  application.GetScene().Add( parentButton );
   parentButton.ReleasedSignal().Connect( &ButtonCallback );
 
   // Reset signal flags
@@ -1079,10 +986,10 @@ int UtcDaliButtonMultiTouch(void)
   Button button = PushButton::New();
   button.SetProperty( Button::Property::TOGGLABLE, true);
 
-  button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-  button.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  button.SetSize( 20, 20 );
-  Stage::GetCurrent().Add( button );
+  button.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+  button.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  button.SetProperty( Actor::Property::SIZE, Vector2( 20, 20 ) );
+  application.GetScene().Add( button );
   button.ReleasedSignal().Connect( &ButtonCallback );
 
   // Reset signal flags