[ATSPI] Fix for DefaultLabel 23/267323/8
authorLukasz Oleksak <l.oleksak@samsung.com>
Wed, 1 Dec 2021 11:51:36 +0000 (12:51 +0100)
committerLukasz Oleksak <l.oleksak@samsung.com>
Wed, 15 Dec 2021 11:13:48 +0000 (11:13 +0000)
This patch:

* replaces usage of existing API AddPopup()/RemovePopup() by RegisterDefaultLabel()/UnregisterDefaultLabel() which has wider applicability (not only for popups)
* extends test utils to allow write tests that emit window:activate / window:deactivate events

Related patches:
https://review.tizen.org/gerrit/#/c/platform/core/uifw/dali-adaptor/+/267321/

Change-Id: Ibae793c10d2f29fdd4af32fc69d518e247b54633

automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/accessibility-test-utils.cpp
dali-toolkit/internal/controls/popup/popup-impl.cpp

index b654d52..2747582 100644 (file)
@@ -80,6 +80,15 @@ namespace Accessibility
           gMoveOutedCalled = true;
           return wr->newReplyMessage(m);
       };
           gMoveOutedCalled = true;
           return wr->newReplyMessage(m);
       };
+
+      wr->testMethods[std::tuple<std::string, std::string, std::string, MethodType>{"/org/a11y/atspi/accessible", "org.a11y.atspi.Event.Window", "Activate", MethodType::Method}] =
+      [wr](const MessagePtr &m) -> MessagePtr {
+          return wr->newReplyMessage(m);
+      };
+      wr->testMethods[std::tuple<std::string, std::string, std::string, MethodType>{"/org/a11y/atspi/accessible", "org.a11y.atspi.Event.Window", "Deactivate", MethodType::Method}] =
+      [wr](const MessagePtr &m) -> MessagePtr {
+          return wr->newReplyMessage(m);
+      };
     }
     auto wr = static_cast<TestDBusWrapper*>(DBusWrapper::Installed());
     wr->fromTestChangeProperty("/org/a11y/bus", "org.a11y.Status", "ScreenReaderEnabled", b);
     }
     auto wr = static_cast<TestDBusWrapper*>(DBusWrapper::Installed());
     wr->fromTestChangeProperty("/org/a11y/bus", "org.a11y.Status", "ScreenReaderEnabled", b);
index cc65de9..9abcfe0 100644 (file)
@@ -726,25 +726,16 @@ void Popup::SetDisplayState(Toolkit::Popup::DisplayState displayState)
     return;
   }
 
     return;
   }
 
-  auto* accessible = Dali::Accessibility::Accessible::Get(Self());
-  if(display)
-  {
-    Dali::Accessibility::Bridge::GetCurrentBridge()->AddPopup(accessible);
-    accessible->EmitStateChanged(Dali::Accessibility::State::SHOWING, 1, 0);
-  }
-  else
-  {
-    accessible->EmitStateChanged(Dali::Accessibility::State::SHOWING, 0, 0);
-    Dali::Accessibility::Bridge::GetCurrentBridge()->RemovePopup(accessible);
-  }
-
   // Convert the bool state to the actual display state to use.
   // Convert the bool state to the actual display state to use.
-  mDisplayState = display ? Toolkit::Popup::SHOWING : Toolkit::Popup::HIDING;
+  mDisplayState    = display ? Toolkit::Popup::SHOWING : Toolkit::Popup::HIDING;
+  auto* accessible = Dali::Accessibility::Accessible::Get(Self());
 
   if(display)
   {
     // Update the state to indicate the current intent.
     mDisplayState = Toolkit::Popup::SHOWING;
 
   if(display)
   {
     // Update the state to indicate the current intent.
     mDisplayState = Toolkit::Popup::SHOWING;
+    Dali::Accessibility::Bridge::GetCurrentBridge()->RegisterDefaultLabel(accessible);
+    accessible->EmitShowing(true);
 
     // We want the popup to have key input focus when it is displayed
     SetKeyInputFocus();
 
     // We want the popup to have key input focus when it is displayed
     SetKeyInputFocus();
@@ -798,8 +789,9 @@ void Popup::SetDisplayState(Toolkit::Popup::DisplayState displayState)
   else // Not visible.
   {
     mDisplayState = Toolkit::Popup::HIDING;
   else // Not visible.
   {
     mDisplayState = Toolkit::Popup::HIDING;
+    Dali::Accessibility::Bridge::GetCurrentBridge()->UnregisterDefaultLabel(accessible);
     ClearKeyInputFocus();
     ClearKeyInputFocus();
-
+    accessible->EmitShowing(false);
     // Restore the keyboard focus when popup is hidden.
     if(mPreviousFocusedActor && mPreviousFocusedActor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE))
     {
     // Restore the keyboard focus when popup is hidden.
     if(mPreviousFocusedActor && mPreviousFocusedActor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE))
     {