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

Implement non-caching text matcher #76

Closed
Nikitae57 opened this issue May 12, 2023 · 1 comment · Fixed by #77
Closed

Implement non-caching text matcher #76

Nikitae57 opened this issue May 12, 2023 · 1 comment · Fixed by #77

Comments

@Nikitae57
Copy link
Contributor

Steps to reproduce:

  1. Define a KTextView using the withText(resId: Int) matcher and preform a check on it
  2. Change locale mid-test (using kaspresso SystemLanguage)
  3. Perform a check on the same KTextView again

Observed Results:

  • View not found

Expected Results:

  • View found

Relevant Code:

androidx.test.espresso.matcher.ViewMatchers.WithCharSequenceMatcher#matchesSafely caches text

@Override
  protected boolean matchesSafely(TextView textView, Description mismatchDescription) {
    if (null == expectedText) {
      try {
        expectedText = textView.getResources().getString(resourceId);
      } catch (Resources.NotFoundException ignored) {
        /* view could be from a context unaware of the resource id. */
      }
      resourceName = safeGetResourceEntryName(textView.getResources(), resourceId);
    }
    ...
  }
@Nikitae57
Copy link
Contributor Author

I'll create a PR shortly

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 a pull request may close this issue.

1 participant