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

Introduce rendering matching espresso rule #741

Open
rjrjr opened this issue Apr 26, 2022 · 0 comments
Open

Introduce rendering matching espresso rule #741

rjrjr opened this issue Apr 26, 2022 · 0 comments
Labels
ui Related to UI integration

Comments

@rjrjr
Copy link
Contributor

rjrjr commented Apr 26, 2022

Find a home for this. Ideally the same place that we share whatever idling resource cleverness that we've been hoarding.

/**
 * Base class for matchers that examine the workflow [Screen] [shown][View.getScreen]
 * by a [View].
 */
abstract class WorkflowScreenMatcher : TypeSafeMatcher<View>() {

  final override fun matchesSafely(item: View): Boolean {
    return item.getScreen()?.let { matchesScreen(it) } == true
  }

  protected abstract fun matchesScreen(rendering: Screen): Boolean
}
/**
 * Matches [View]s showing workflow [Screen]s that have [compatibility keys][Compatible.keyFor]
 * that include [string].
 */
fun withScreenWithKeyContaining(string: String): Matcher<View> {
  return withScreenWithKey(containsString(string))
}

/**
 * Matches [View]s showing workflow [Screen]s that have [compatibility keys][Compatible.keyFor]
 * that match [stringMatcher].
 */
fun withScreenWithKey(stringMatcher: Matcher<String>): Matcher<View> {
  return WorkflowScreenWithKeyMatcher(stringMatcher)
}

private class WorkflowScreenWithKeyMatcher(
  private val stringMatcher: Matcher<String>
) : WorkflowScreenMatcher() {
  override fun describeTo(description: Description) {
    description.appendText("with Screen with compatibility key: ")
    stringMatcher.describeTo(description)
  }

  override fun matchesScreen(rendering: Screen): Boolean {
    return stringMatcher.matches(Compatible.keyFor(rendering))
  }
}
@rjrjr rjrjr added the ui Related to UI integration label Apr 26, 2022
rjrjr added a commit that referenced this issue Apr 26, 2022
I'd like to bring back the ability to peek at a View and see if/how workflow-ui created it, even though we no longer need that ability at runtime. I don't see how we can preserve our Radiography support without it, and it's also handy for espresso testing (#741).
rjrjr added a commit that referenced this issue Apr 26, 2022
I'd like to bring back the ability to peek at a View and see if/how workflow-ui created it, even though we no longer need that ability at runtime. I don't see how we can preserve our Radiography support without it, and it's also handy for espresso testing (#741).
rjrjr added a commit that referenced this issue Apr 26, 2022
I'd like to bring back the ability to peek at a View and see if/how workflow-ui created it, even though we no longer need that ability at runtime. I don't see how we can preserve our Radiography support without it, and it's also handy for espresso testing (#741).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ui Related to UI integration
Projects
None yet
Development

No branches or pull requests

1 participant