[AT-SPI] Improving utc coverage 78/245078/22
authorLukasz Oleksak <l.oleksak@samsung.com>
Wed, 30 Sep 2020 16:15:02 +0000 (18:15 +0200)
committerArtur Świgoń <a.swigon@samsung.com>
Fri, 23 Oct 2020 13:07:01 +0000 (15:07 +0200)
Change-Id: Ie4b0335de832968988524f7c219fb41bbe342349

automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Controls-BridgeUp.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Value.cpp
dali-toolkit/internal/controls/control/control-data-impl.cpp
dali-toolkit/internal/controls/control/control-data-impl.h

index fe443eb..a50c9a9 100644 (file)
@@ -89,6 +89,7 @@ int UtcDaliControlAccessibilityName(void)
 
   DALI_TEST_EQUALS( "Accessibility_Name_With_Callback" , TestGetName( q->GetAddress()), TEST_LOCATION );
 
+  //TODO test emission of name change signal
   Dali::Accessibility::TestEnableSC( false );
 
   END_TEST;
@@ -120,6 +121,7 @@ int UtcDaliControlAccessibilityDescription(void)
 
   DALI_TEST_EQUALS( "Accessibility_Description_With_Callback" , TestGetDescription( q->GetAddress()), TEST_LOCATION );
 
+  //TODO test emission of description change signal
   Dali::Accessibility::TestEnableSC( false );
 
   END_TEST;
@@ -202,6 +204,11 @@ int UtcDaliControlAccessibilityHighlightable(void)
   auto noneset = control.GetProperty( DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE );
   DALI_TEST_EQUALS( Property::NONE, noneset.GetType(), TEST_LOCATION );
 
+   // negative testcase - trying to set unconvertible value
+  control.SetProperty( DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE, "deadbeef" );
+  noneset = control.GetProperty( DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE );
+  DALI_TEST_EQUALS( Property::NONE, noneset.GetType(), TEST_LOCATION );
+
   auto q = Dali::Accessibility::Accessible::Get( control );
 
   Dali::Accessibility::TestEnableSC( true );
@@ -234,6 +241,7 @@ int UtcDaliControlAccessibilityHighlightBridgeUp(void)
 
   auto controla = Control::New();
   auto controlb = Control::New();
+  controla.Add(controlb);
 
   controla.SetProperty( DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE, true );
   controlb.SetProperty( DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE, true );
@@ -763,6 +771,9 @@ int UtcDaliAccessibilityDoAction(void)
   DALI_TEST_CHECK( b -> DoAction( actions[4] ) ); // ReadingStopped
   DALI_TEST_CHECK( b -> DoAction( actions[4] ) ); // ReadingStopped
 
+  // Negative test of calling action with not defined name
+  DALI_TEST_CHECK( !b -> DoAction( "undefined" ) );
+
   DevelControl::AccessibilityReadingSkippedSignal(control).Connect( [] () {
     actions_done[ 1 ] = true;
   } );
@@ -823,3 +834,28 @@ int UtcDaliAccessibilityDoAction(void)
 
   END_TEST;
 }
+
+void TestVoidCallback()
+{
+}
+
+int UtcDaliAccessibilitySignals(void)
+{
+  ToolkitTestApplication application;
+  ConnectionTracker connectionTracker;
+  Control control = Control::New();
+
+  DALI_TEST_CHECK( DevelControl::AccessibilityGetNameSignal(control).Empty() );
+  control.ConnectSignal( &connectionTracker, "getName", &TestVoidCallback );
+  DALI_TEST_CHECK( !DevelControl::AccessibilityGetNameSignal(control).Empty() );
+
+  DALI_TEST_CHECK( DevelControl::AccessibilityGetDescriptionSignal(control).Empty() );
+  control.ConnectSignal( &connectionTracker, "getDescription", &TestVoidCallback );
+  DALI_TEST_CHECK( !DevelControl::AccessibilityGetDescriptionSignal(control).Empty() );
+
+  DALI_TEST_CHECK( DevelControl::AccessibilityDoGestureSignal(control).Empty() );
+  control.ConnectSignal( &connectionTracker, "doGesture", &TestVoidCallback );
+  DALI_TEST_CHECK( !DevelControl::AccessibilityDoGestureSignal(control).Empty() );
+
+  END_TEST;
+}
index b33f84e..af4739b 100644 (file)
@@ -246,5 +246,23 @@ int utcDaliAccessibilitySliderGetSetCurrent(void)
   DALI_TEST_EQUALS( x->SetCurrent( 0.25 ), true, TEST_LOCATION );
   DALI_TEST_EQUALS( x->GetCurrent(), 0.25, TEST_LOCATION );
 
+  const float MIN_BOUND = 0.0f;
+  const float MAX_BOUND = 1.0f;
+  const int NUM_MARKS = 5;
+  Property::Array marks;
+  for( int i = 0; i < NUM_MARKS; ++i )
+  {
+    marks.PushBack( MIN_BOUND + ( static_cast<float>(i) / ( NUM_MARKS - 1) ) * ( MAX_BOUND - MIN_BOUND ) );
+  }
+  slider.SetProperty( Toolkit::Slider::Property::MARKS, marks );
+  // when current value is not a mark, set new value to the closest mark
+  DALI_TEST_CHECK( x->SetCurrent( 0.1f ) );
+  slider.SetProperty( Toolkit::Slider::Property::SNAP_TO_MARKS, true );
+  DALI_TEST_CHECK( x->SetCurrent( 0.7f ) );
+  DALI_TEST_EQUALS( static_cast<float>( x->GetCurrent() ), marks[3].Get<float>(), TEST_LOCATION );
+  // when current value is a mark at index i set new value to the mark at index i +/- 1
+  // depending if the new value is greater/less than current value
+  DALI_TEST_CHECK( x->SetCurrent( 0.2f ) );
+  DALI_TEST_EQUALS( static_cast<float>( x->GetCurrent() ),  marks[2].Get<float>(), TEST_LOCATION );
   END_TEST;
 }
index 0a7d70e..d8b044c 100755 (executable)
@@ -198,54 +198,56 @@ const char* ACTION_ACCESSIBILITY_READING_STOPPED   = "ReadingStopped";
 
 static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
 {
-  if (!object)
-    return false;
+  bool ret = true;
 
-  Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
-  if ( !control )
-    return false;
+  Dali::BaseHandle handle( object );
+
+  Toolkit::Control control = Toolkit::Control::DownCast( handle );
+
+  DALI_ASSERT_ALWAYS( control );
 
   if( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_ACTIVATED ) ||
-        actionName == "activate" )
+     actionName == "activate" )
   {
     // if cast succeeds there is an implementation so no need to check
-    if (!DevelControl::AccessibilityActivateSignal( control ).Empty())
+    if( !DevelControl::AccessibilityActivateSignal( control ).Empty() )
       DevelControl::AccessibilityActivateSignal( control ).Emit();
-    else
-      return Internal::GetImplementation( control ).OnAccessibilityActivated();
+    else ret = Internal::GetImplementation( control ).OnAccessibilityActivated();
   }
   else if( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_SKIPPED ) )
   {
     // if cast succeeds there is an implementation so no need to check
-    if (!DevelControl::AccessibilityReadingSkippedSignal( control ).Empty())
+    if( !DevelControl::AccessibilityReadingSkippedSignal( control ).Empty() )
       DevelControl::AccessibilityReadingSkippedSignal( control ).Emit();
   }
-  else if( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_PAUSED) )
+  else if( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_PAUSED ) )
   {
     // if cast succeeds there is an implementation so no need to check
-    if (!DevelControl::AccessibilityReadingPausedSignal( control ).Empty())
+    if( !DevelControl::AccessibilityReadingPausedSignal( control ).Empty() )
       DevelControl::AccessibilityReadingPausedSignal( control ).Emit();
   }
   else if( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_RESUMED ) )
   {
     // if cast succeeds there is an implementation so no need to check
-    if (!DevelControl::AccessibilityReadingResumedSignal( control ).Empty())
+    if( !DevelControl::AccessibilityReadingResumedSignal( control ).Empty() )
       DevelControl::AccessibilityReadingResumedSignal( control ).Emit();
   }
   else if( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_CANCELLED ) )
   {
     // if cast succeeds there is an implementation so no need to check
-    if (!DevelControl::AccessibilityReadingCancelledSignal( control ).Empty())
+    if( !DevelControl::AccessibilityReadingCancelledSignal( control ).Empty() )
       DevelControl::AccessibilityReadingCancelledSignal( control ).Emit();
   }
   else if( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_STOPPED ) )
   {
     // if cast succeeds there is an implementation so no need to check
-    if (!DevelControl::AccessibilityReadingStoppedSignal( control ).Empty())
+    if(!DevelControl::AccessibilityReadingStoppedSignal( control ).Empty())
       DevelControl::AccessibilityReadingStoppedSignal( control ).Emit();
+  } else
+  {
+    ret = false;
   }
-
-  return true;
+  return ret;
 }
 
 /**
@@ -2151,11 +2153,6 @@ bool Control::Impl::AccessibleImpl::ClearHighlight()
   return false;
 }
 
-int Control::Impl::AccessibleImpl::GetHighlightIndex()
-{
-  return 0;
-}
-
 std::string Control::Impl::AccessibleImpl::GetActionName( size_t index )
 {
   if ( index >= GetActionCount() ) return "";
index 8d34435..aefb484 100755 (executable)
@@ -575,7 +575,6 @@ public:
     double GetAlpha() override;
     bool GrabHighlight() override;
     bool ClearHighlight() override;
-    int GetHighlightIndex() override;
 
     std::string GetActionName( size_t index ) override;
     std::string GetLocalizedActionName( size_t index ) override;