From: Artur Świgoń Date: Tue, 19 Jul 2022 10:28:36 +0000 (+0200) Subject: Add DevelControl::Property::AUTOMATION_ID X-Git-Tag: dali_2.1.32~2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=a44d1f25dfb55db30bb839e4b30ae1f85b541118;hp=fbb5f92e3b65c89f0b785087716d5eb2e5024efb Add DevelControl::Property::AUTOMATION_ID 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 --- diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Accessible.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Accessible.cpp index 2bbdcc8..60e1892 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Accessible.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Accessible.cpp @@ -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(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(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(automationIdIndex).empty()); + attributes = controlAccessible->GetAttributes(); + DALI_TEST_CHECK(attributes.find(automationIdKey) == attributes.end()); + + END_TEST; +} diff --git a/dali-toolkit/devel-api/controls/control-accessible.cpp b/dali-toolkit/devel-api/controls/control-accessible.cpp index 85b3c6a..a24e59d 100644 --- a/dali-toolkit/devel-api/controls/control-accessible.cpp +++ b/dali-toolkit/devel-api/controls/control-accessible.cpp @@ -265,6 +265,12 @@ Dali::Accessibility::Attributes ControlAccessible::GetAttributes() const } } + auto automationId = control.GetProperty(Dali::Toolkit::DevelControl::Property::AUTOMATION_ID); + if(!automationId.empty()) + { + attributeMap.emplace("automationId", std::move(automationId)); + } + return attributeMap; } diff --git a/dali-toolkit/devel-api/controls/control-devel.h b/dali-toolkit/devel-api/controls/control-devel.h index 34b733b..3a94e1b 100644 --- a/dali-toolkit/devel-api/controls/control-devel.h +++ b/dali-toolkit/devel-api/controls/control-devel.h @@ -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 diff --git a/dali-toolkit/internal/controls/control/control-data-impl.cpp b/dali-toolkit/internal/controls/control/control-data-impl.cpp index d4de79a..b967d14 100644 --- a/dali-toolkit/internal/controls/control/control-data-impl.cpp +++ b/dali-toolkit/internal/controls/control/control-data-impl.cpp @@ -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; + } } } diff --git a/dali-toolkit/internal/controls/control/control-data-impl.h b/dali-toolkit/internal/controls/control/control-data-impl.h index 593ab7d..793fc22 100644 --- a/dali-toolkit/internal/controls/control/control-data-impl.h +++ b/dali-toolkit/internal/controls/control/control-data-impl.h @@ -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.