Merge "(Vector) Support dynamic properties" into devel/master
authorHeeyong Song <heeyong.song@samsung.com>
Fri, 22 Jul 2022 01:00:29 +0000 (01:00 +0000)
committerGerrit Code Review <gerrit@review>
Fri, 22 Jul 2022 01:00:29 +0000 (01:00 +0000)
automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Accessible.cpp
dali-scene3d/public-api/loader/dli-loader.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 2bbdcc8..60e1892 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 b5382e3..96555f2 100644 (file)
@@ -407,83 +407,86 @@ void DliLoader::Impl::ParseScene(LoadParams& params)
 
   // get index of root node.
   auto docRoot = mParser.GetRoot();
-
-  // Process resources first - these are shared
-  if(auto environments = docRoot->GetChild("environment"))
+  if(docRoot)
   {
-    ParseEnvironments(environments, output.mResources); // NOTE: must precede parsing of materials
-  }
+    // Process resources first - these are shared
+    if(auto environments = docRoot->GetChild("environment"))
+    {
+      ParseEnvironments(environments, output.mResources); // NOTE: must precede parsing of materials
+    }
 
-  if(auto meshes = docRoot->GetChild("meshes"))
-  {
-    ParseMeshes(meshes, output.mResources);
-  }
+    if(auto meshes = docRoot->GetChild("meshes"))
+    {
+      ParseMeshes(meshes, output.mResources);
+    }
 
-  if(auto shaders = docRoot->GetChild("shaders"))
-  {
-    ParseShaders(shaders, output.mResources);
-  }
+    if(auto shaders = docRoot->GetChild("shaders"))
+    {
+      ParseShaders(shaders, output.mResources);
+    }
 
-  if(auto materials = docRoot->GetChild("materials"))
-  {
-    ParseMaterials(materials, input.mConvertColorCode, output.mResources);
-  }
+    if(auto materials = docRoot->GetChild("materials"))
+    {
+      ParseMaterials(materials, input.mConvertColorCode, output.mResources);
+    }
 
-  for(auto& c : input.mPreNodeCategoryProcessors)
-  {
-    if(auto node = docRoot->GetChild(c.first))
+    for(auto& c : input.mPreNodeCategoryProcessors)
     {
-      Property::Array array;
-      ParseProperties(*node, array);
-      c.second(std::move(array), mOnError);
+      if(auto node = docRoot->GetChild(c.first))
+      {
+        Property::Array array;
+        ParseProperties(*node, array);
+        c.second(std::move(array), mOnError);
+      }
     }
-  }
 
-  // Process scenes
-  Index iScene = 0; // default scene
-  ReadIndex(docRoot->GetChild("scene"), iScene);
+    // Process scenes
+    Index iScene = 0; // default scene
+    ReadIndex(docRoot->GetChild("scene"), iScene);
 
-  auto tnScenes = RequireChild(docRoot, "scenes");
-  auto tnNodes  = RequireChild(docRoot, "nodes");
-  ParseSceneInternal(iScene, tnScenes, tnNodes, params);
+    auto tnScenes = RequireChild(docRoot, "scenes");
+    auto tnNodes  = RequireChild(docRoot, "nodes");
+    ParseSceneInternal(iScene, tnScenes, tnNodes, params);
 
-  ParseSkeletons(docRoot->GetChild("skeletons"), output.mScene, output.mResources);
+    ParseSkeletons(docRoot->GetChild("skeletons"), output.mScene, output.mResources);
 
-  output.mScene.EnsureUniqueSkinningShaderInstances(output.mResources);
-  output.mScene.EnsureUniqueBlendShapeShaderInstances(output.mResources);
+    output.mScene.EnsureUniqueSkinningShaderInstances(output.mResources);
+    output.mScene.EnsureUniqueBlendShapeShaderInstances(output.mResources);
 
-  // Ger cameras and lights
-  GetCameraParameters(output.mCameraParameters);
-  GetLightParameters(output.mLightParameters);
+    // Ger cameras and lights
+    GetCameraParameters(output.mCameraParameters);
+    GetLightParameters(output.mLightParameters);
 
-  // Post-node processors and animations last
-  for(auto& c : input.mPostNodeCategoryProcessors)
-  {
-    if(auto node = docRoot->GetChild(c.first))
+    // Post-node processors and animations last
+    for(auto& c : input.mPostNodeCategoryProcessors)
     {
-      Property::Array array;
-      ParseProperties(*node, array);
-      c.second(std::move(array), mOnError);
+      if(auto node = docRoot->GetChild(c.first))
+      {
+        Property::Array array;
+        ParseProperties(*node, array);
+        c.second(std::move(array), mOnError);
+      }
     }
-  }
 
-  if(auto animations = docRoot->GetChild("animations"))
-  {
-    ParseAnimations(animations, params);
-  }
+    if(auto animations = docRoot->GetChild("animations"))
+    {
+      ParseAnimations(animations, params);
+    }
 
-  if(!output.mAnimationDefinitions.empty())
-  {
-    if(auto animationGroups = docRoot->GetChild("animationGroups"))
+    if(!output.mAnimationDefinitions.empty())
     {
-      ParseAnimationGroups(animationGroups, params);
+      if(auto animationGroups = docRoot->GetChild("animationGroups"))
+      {
+        ParseAnimationGroups(animationGroups, params);
+      }
     }
   }
 }
 
 void DliLoader::Impl::ParseSceneInternal(Index iScene, const Toolkit::TreeNode* tnScenes, const Toolkit::TreeNode* tnNodes, LoadParams& params)
 {
-  auto getSceneRootIdx = [tnScenes, tnNodes](Index iScene) {
+  auto getSceneRootIdx = [tnScenes, tnNodes](Index iScene)
+  {
     auto tn = GetNthChild(tnScenes, iScene); // now a "scene" object
     if(!tn)
     {
index 85b3c6a..a24e59d 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 abfba65..fe95c70 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 5b638e8..4c74704 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
 
@@ -1403,6 +1404,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;
+      }
     }
   }
 }
@@ -1575,6 +1586,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 f72d121..46cc97b 100644 (file)
@@ -542,6 +542,7 @@ public:
   std::string mAccessibilityName;
   std::string mAccessibilityDescription;
   std::string mAccessibilityTranslationDomain;
+  std::string mAutomationId;
 
   bool mAccessibilityHighlightable = false;
   bool mAccessibilityHidden        = false;
@@ -598,6 +599,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.