Add DevelControl::Property::AUTOMATION_ID 52/278352/3
authorArtur Świgoń <a.swigon@samsung.com>
Tue, 19 Jul 2022 10:28:36 +0000 (12:28 +0200)
committerArtur Świgoń <a.swigon@samsung.com>
Thu, 21 Jul 2022 08:10:54 +0000 (10:10 +0200)
This is a string identifier (compared to Actor::Property::ID which
is an integer).  It will also appear in the AT-SPI tree under the
key "automationId".

Change-Id: Id6abce5d43d6f5f3bfde60352033e4e399dfdff6

automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Accessible.cpp
dali-toolkit/devel-api/controls/control-accessible.cpp
dali-toolkit/devel-api/controls/control-devel.h
dali-toolkit/internal/controls/control/control-data-impl.cpp
dali-toolkit/internal/controls/control/control-data-impl.h

index 2bbdcc825ee2a6b4c8190756749a39c731990101..60e1892e5be3bac82438ec17966f5edcebd3a66b 100644 (file)
@@ -171,3 +171,38 @@ int utcDaliAccessibilityHidden(void)
 
   END_TEST;
 }
+
+int utcDaliAutomationId(void)
+{
+  ToolkitTestApplication application;
+  Dali::Property::Index  automationIdIndex = Toolkit::DevelControl::Property::AUTOMATION_ID;
+  std::string            automationIdKey   = "automationId";
+  std::string            automationIdValue = "test123";
+
+  auto  control           = Toolkit::Control::New();
+  auto* controlAccessible = Accessibility::Accessible::Get(control);
+
+  // Check that there is no automationId initially
+  DALI_TEST_CHECK(control.GetProperty<std::string>(automationIdIndex).empty());
+  auto attributes = controlAccessible->GetAttributes();
+  DALI_TEST_CHECK(attributes.find(automationIdKey) == attributes.end());
+
+  // Set automationId
+  control.SetProperty(automationIdIndex, automationIdValue);
+
+  // Check that automationId is set
+  DALI_TEST_EQUALS(control.GetProperty<std::string>(automationIdIndex), automationIdValue, TEST_LOCATION);
+  attributes = controlAccessible->GetAttributes();
+  DALI_TEST_CHECK(attributes.find(automationIdKey) != attributes.end());
+  DALI_TEST_EQUALS(attributes[automationIdKey], automationIdValue, TEST_LOCATION);
+
+  // Unset automationId
+  control.SetProperty(automationIdIndex, "");
+
+  // Check that there is no automationId
+  DALI_TEST_CHECK(control.GetProperty<std::string>(automationIdIndex).empty());
+  attributes = controlAccessible->GetAttributes();
+  DALI_TEST_CHECK(attributes.find(automationIdKey) == attributes.end());
+
+  END_TEST;
+}
index 85b3c6aae285d003758c52050b4fa8aa6fabc185..a24e59dd5fca901ce9eec9daec9d8745ee00e74a 100644 (file)
@@ -265,6 +265,12 @@ Dali::Accessibility::Attributes ControlAccessible::GetAttributes() const
     }
   }
 
+  auto automationId = control.GetProperty<std::string>(Dali::Toolkit::DevelControl::Property::AUTOMATION_ID);
+  if(!automationId.empty())
+  {
+    attributeMap.emplace("automationId", std::move(automationId));
+  }
+
   return attributeMap;
 }
 
index 34b733be4f147dcfb0317c2dd875b53c080916e2..3a94e1b6c58e2a64e30db035c114e9d050d3e7b3 100644 (file)
@@ -215,6 +215,14 @@ enum
    *
    */
   COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID,
+
+  /**
+   * @brief Identifier that allows the automation framework to find and interact with this element.
+   * @details Name "automationId", type Property::STRING.
+   * @note This is a string identifier (compared to @c Actor::Property::ID which is an integer).
+   * It will also appear in the AT-SPI tree under the key "automationId".
+   */
+  AUTOMATION_ID,
 };
 
 } // namespace Property
index d4de79a6f2e08c2094763ae9b2c9b963b6e8aacb..b967d14564a2e4bac14c797e148892d6450db81a 100644 (file)
@@ -485,6 +485,7 @@ const PropertyRegistration Control::Impl::PROPERTY_22(typeRegistration, "dispatc
 const PropertyRegistration Control::Impl::PROPERTY_23(typeRegistration, "accessibilityHidden",            Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN,             Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
 const PropertyRegistration Control::Impl::PROPERTY_24(typeRegistration, "clockwiseFocusableActorId",      Toolkit::DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID,     Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
 const PropertyRegistration Control::Impl::PROPERTY_25(typeRegistration, "counterClockwiseFocusableActorId", Toolkit::DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty);
+const PropertyRegistration Control::Impl::PROPERTY_26(typeRegistration, "automationId",                   Toolkit::DevelControl::Property::AUTOMATION_ID,                    Property::STRING,  &Control::Impl::SetProperty, &Control::Impl::GetProperty);
 
 // clang-format on
 
@@ -1394,6 +1395,16 @@ void Control::Impl::SetProperty(BaseObject* object, Property::Index index, const
         }
         break;
       }
+
+      case Toolkit::DevelControl::Property::AUTOMATION_ID:
+      {
+        std::string automationId;
+        if(value.Get(automationId))
+        {
+          controlImpl.mImpl->mAutomationId = automationId;
+        }
+        break;
+      }
     }
   }
 }
@@ -1566,6 +1577,12 @@ Property::Value Control::Impl::GetProperty(BaseObject* object, Property::Index i
         value = controlImpl.mImpl->mCounterClockwiseFocusableActorId;
         break;
       }
+
+      case Toolkit::DevelControl::Property::AUTOMATION_ID:
+      {
+        value = controlImpl.mImpl->mAutomationId;
+        break;
+      }
     }
   }
 
index 593ab7d4fc27f54154d3f4a633f863a63f0b9f95..793fc22c5f1a261faefbea94dc14a3415523ab14 100644 (file)
@@ -537,6 +537,7 @@ public:
   std::string mAccessibilityName;
   std::string mAccessibilityDescription;
   std::string mAccessibilityTranslationDomain;
+  std::string mAutomationId;
 
   bool mAccessibilityHighlightable = false;
   bool mAccessibilityHidden        = false;
@@ -593,6 +594,7 @@ public:
   static const PropertyRegistration PROPERTY_23;
   static const PropertyRegistration PROPERTY_24;
   static const PropertyRegistration PROPERTY_25;
+  static const PropertyRegistration PROPERTY_26;
 
 private:
   // Accessibility - notification for highlighted object to check if it is showing.