Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(device): refactor and enhance view hierarchy XML generation. #4565

Merged
merged 33 commits into from
Sep 1, 2024

Conversation

asafkorem
Copy link
Contributor

  • Extended getViewHierarchyXml ability to inject test-IDs while traversing the tree. This injection is a side-effect of the generation process to optimize performance.
  • Renamed getViewHierarchyXml to generateViewHierarchyXml(shouldInjectTestIds = false) to accurately represent the method's functionality.
  • Removed redundant and empty attributes from the generated XML.
  • Updated the output to return the XML directly instead of JSON-wrapped XML.
  • Implemented a new snapshot-test method utilizing the existing snapshot utility. Using Jest snapshots with dynamic snapshot name (env-based) caused us issues.
  • Updated the device markdown documentation with the new API.

@asafkorem asafkorem self-assigned this Aug 29, 2024
@asafkorem asafkorem marked this pull request as ready for review August 29, 2024 16:29
@asafkorem asafkorem merged commit 289e623 into master Sep 1, 2024
6 of 7 checks passed
@asafkorem asafkorem deleted the feat/inject-test-id branch September 1, 2024 08:45
@asafkorem asafkorem linked an issue Sep 1, 2024 that may be closed by this pull request
endDocument()
}

writer.toString()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that flush is not needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, it does has flush() method since it inherits from Write (flush is abstract), but it means nothing this case since it immediately writes to an in-memory resource (the string), so there's nothing to flush

serializer.endTag("", view.javaClass.simpleName)
}

private fun serializeViewAttributes(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow. Great utilization of kotlin syntax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add device API for view-hierarchy dump
2 participants