This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sometimes you may need access to the root view in a test when working with compose. | |
// This is particularly useful for screenshot tests with popups/dialog where the root view | |
// will be in a separate window, rather than the activity | |
// This snippet shows how this can be used | |
val view = composeTestRule.onNode(isDialog()).fetchRootView() | |
private fun SemanticsNodeInteraction.fetchRootView(): View { | |
val node = fetchSemanticsNode() | |
return (node.root as ViewRootForTest).view |