*/
virtual std::vector<std::shared_ptr<AccessibleNode>> getMatchesInMatches(const std::shared_ptr<UiSelector> firstSelector, const std::shared_ptr<UiSelector> secondSelector, const bool ealryReturn) const = 0;
+ /**
+ * @brief dump current tree in json string
+ *
+ * @return string
+ */
+ virtual std::string dumpTree() const = 0;
+
/**
* @copydoc UiObject::next()
*/
*/
std::vector<std::shared_ptr<AccessibleNode>> getMatchesInMatches(const std::shared_ptr<UiSelector> firstSelector, const std::shared_ptr<UiSelector> secondSelector, const bool ealryReturn) const override;
+ /**
+ * @copydoc AccessibleNode::dumpTree()
+ */
+ std::string dumpTree() const override;
+
/**
* @copydoc UiObject::next()
*/
static AtspiAccessible *Atspi_accessible_get_neighbor(AtspiAccessible *root, AtspiAccessible *start, AtspiNeighborSearchDirection direction, GError **error);
static void Atspi_accessible_set_include_hidden(AtspiAccessible *obj, gboolean enabled, GError **error);
static gboolean Atspi_accessible_get_include_hidden(AtspiAccessible *obj, GError **error);
+ static gchar *Atspi_accessible_dump_tree(AtspiAccessible *obj, AtspiDumpDetailLevelType detail_level, GError **error);
private:
static std::recursive_mutex mMutex;
*/
std::vector<std::shared_ptr<AccessibleNode>> getMatchesInMatches(const std::shared_ptr<UiSelector> firstSelector, const std::shared_ptr<UiSelector> secondSelector, const bool ealryReturn) const override;
+ /**
+ * @copydoc AccessibleNode::dumpTree()
+ */
+ std::string dumpTree() const override;
+
/**
* @copydoc UiObject::next()
*/
return ret;
}
+std::string AtspiAccessibleNode::dumpTree() const
+{
+ if (!isValid()) {
+ return {};
+ }
+
+ gchar *c_result = AtspiWrapper::Atspi_accessible_dump_tree(mNode, ATSPI_DUMP_FULL_SHOWING_ONLY, NULL);
+ if (c_result) {
+ std::string result{c_result};
+ g_free(c_result);
+ return result;
+ }
+
+ return {};
+}
+
std::shared_ptr<AccessibleNode> AtspiAccessibleNode::next() const
{
if (!isValid()) {
std::unique_lock<std::recursive_mutex> lock(mMutex);
return atspi_accessible_get_include_hidden(obj, error);
}
+
+gchar *AtspiWrapper::Atspi_accessible_dump_tree(AtspiAccessible *obj, AtspiDumpDetailLevelType detail_level, GError **error)
+{
+ std::unique_lock<std::recursive_mutex> lock(mMutex);
+ return atspi_accessible_dump_tree(obj, detail_level, error);
+}
return ret;
}
+std::string MockAccessibleNode::dumpTree() const
+{
+ return {"{}"};
+}
void* MockAccessibleNode::getRawHandler(void) const
{
dumpResult += " : [";
for (const auto& root: windowRoots) {
- // TODO: implement dump logic
- // root->dump();
- dumpResult += "{},";
+ dumpResult += root->dumpTree();
+ dumpResult += ",";
}
// remove last comma if exists.