node->updateRoleName();
node->updateAttributes();
node->updateToolkitName();
- node->updateApplication();
std::string name;
if (node->getType().empty())
else
name = node->getType();
- if (!name.compare("application")) name = node->getPkg();
+ if (!name.compare("application")) {
+ node->updateApplication();
+ name = node->getPkg();
+ }
// Remove white spaces.
name.erase(remove(name.begin(), name.end(), ' '), name.end());
mXNodeMap[node->getId()] = node;
auto children = node->getChildren();
- for (auto &child : children)
+ for (const auto &child : children)
{
if (child->getRawHandler() == nullptr) continue;
mDoc->remove_children();
xml_node element = mDoc->append_child("");
-
+
traverse(element, mRoot);
return true;
if (xmlNode) {
auto children = node->getChildren();
- for (auto &child : children) {
+ for (const auto &child : children) {
if (child->getRawHandler() == nullptr) continue;
xml_node childElement = xmlNode.append_child("");
return "NotSupported";
}
-void AurumXML::findObjects(std::vector<std::shared_ptr<AccessibleNode>> &ret,
+void AurumXML::findXNodes(std::vector<std::shared_ptr<AccessibleNode>> &ret,
std::string xpath, bool earlyReturn)
{
- createXMLtree();
-
- LOGI("xpath %s earlyReturn %d", xpath.c_str(), earlyReturn);
- try {
- if (earlyReturn) {
- xml_node node = mDoc->select_node(xpath.c_str()).node();
- const std::string id(node.attribute("id").value());
- if (mXNodeMap.count(id) > 0) ret.push_back(mXNodeMap[id]);
+ if (earlyReturn) {
+ xml_node node = mDoc->select_node(xpath.c_str()).node();
+ const std::string id(node.attribute("id").value());
+ if (mXNodeMap.count(id) > 0) ret.push_back(mXNodeMap[id]);
+ } else {
+ const auto nodes = mDoc->select_nodes(xpath.c_str());
- } else {
- const auto nodes = mDoc->select_nodes(xpath.c_str());
+ for (const auto& no : nodes) {
+ const std::string id(no.node().attribute("id").value());
- for (const auto& no : nodes) {
- const std::string id(no.node().attribute("id").value());
+ if (mXNodeMap.count(id) > 0) ret.push_back(mXNodeMap[id]);
+ }
+ }
+}
- if (mXNodeMap.count(id) > 0) ret.push_back(mXNodeMap[id]);
- }
+void AurumXML::findObjects(std::vector<std::shared_ptr<AccessibleNode>> &ret,
+ std::string xpath, bool earlyReturn)
+{
+ LOGI("xpath %s earlyReturn %d", xpath.c_str(), earlyReturn);
+ try {
+ findXNodes(ret, xpath, earlyReturn);
+ if (ret.size() == 0) {
+ createXMLtree();
+ findXNodes(ret, xpath, earlyReturn);
}
} catch (const xpath_exception &e) {
LOGI("findObjects Error: %s", e.what());