mirror of
https://github.com/openharmony/arkXtest.git
synced 2026-07-01 07:47:14 -04:00
!268 dumpLayout 修复bug,同一层级的节点信息若排在前面的节点被过滤,后面的节点将不会被打印
Merge pull request !268 from 周柯/master
This commit is contained in:
@@ -311,7 +311,8 @@ namespace OHOS::uitest {
|
||||
widgetsConstructed_ = true;
|
||||
}
|
||||
|
||||
static void DfsMarshalWidget(const WidgetTree& tree, const Widget& root, nlohmann::json& dom)
|
||||
static void DfsMarshalWidget(const WidgetTree& tree, const Widget& root, nlohmann::json& dom,
|
||||
const std::map<string, size_t> widgetChildCountMap)
|
||||
{
|
||||
auto attributesData = json();
|
||||
// "< UiAttr::HIERARCHY" : do not expose inner used attributes
|
||||
@@ -326,14 +327,21 @@ namespace OHOS::uitest {
|
||||
attributesData[ATTR_NAMES[UiAttr::BOUNDS].data()] = stream.str();
|
||||
|
||||
auto childrenData = json::array();
|
||||
uint32_t childIndex = 0;
|
||||
auto child = tree.GetChildWidget(root, childIndex);
|
||||
while (child != nullptr) {
|
||||
auto childData = json();
|
||||
DfsMarshalWidget(tree, *child, childData);
|
||||
childrenData.emplace_back(childData);
|
||||
uint32_t childIndex = 0, childCount = 0, visitCount = 0;
|
||||
auto hierarchy = root.GetHierarchy();
|
||||
if (widgetChildCountMap.find(hierarchy) != widgetChildCountMap.end()) {
|
||||
childCount = widgetChildCountMap.find(hierarchy)->second;
|
||||
}
|
||||
while (visitCount < childCount) {
|
||||
auto child = tree.GetChildWidget(root, childIndex);
|
||||
childIndex++;
|
||||
child = tree.GetChildWidget(root, childIndex);
|
||||
if (child == nullptr) {
|
||||
continue;
|
||||
}
|
||||
auto childData = json();
|
||||
DfsMarshalWidget(tree, *child, childData, widgetChildCountMap);
|
||||
childrenData.emplace_back(childData);
|
||||
visitCount++;
|
||||
}
|
||||
|
||||
dom["attributes"] = attributesData;
|
||||
@@ -344,8 +352,20 @@ namespace OHOS::uitest {
|
||||
{
|
||||
DCHECK(widgetsConstructed_);
|
||||
auto root = GetRootWidget();
|
||||
std::map<string, size_t> widgetChildCountMap;
|
||||
for (auto &hierarchy : widgetHierarchyIdDfsOrder_) {
|
||||
if (hierarchy == ROOT_HIERARCHY) {
|
||||
continue;
|
||||
}
|
||||
auto parentHierarchy = WidgetHierarchyBuilder::GetParentWidgetHierarchy(hierarchy);
|
||||
if (widgetChildCountMap.find(parentHierarchy) == widgetChildCountMap.end()) {
|
||||
widgetChildCountMap[parentHierarchy] = 1;
|
||||
} else {
|
||||
widgetChildCountMap[parentHierarchy] = widgetChildCountMap[parentHierarchy] + 1;
|
||||
}
|
||||
}
|
||||
if (root != nullptr) {
|
||||
DfsMarshalWidget(*this, *root, dom);
|
||||
DfsMarshalWidget(*this, *root, dom, widgetChildCountMap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -210,6 +210,7 @@ namespace OHOS::uitest {
|
||||
child = child2;
|
||||
}
|
||||
if (!child.IsVisible()) {
|
||||
LOG_I("invisible node drop, id: %{public}d", child.GetAccessibilityId());
|
||||
continue;
|
||||
}
|
||||
auto parcel = json();
|
||||
|
||||
Reference in New Issue
Block a user