KakaoCup / Kakao

Nice and simple DSL for Espresso in Kotlin
https://kakaocup.github.io/Kakao/
Apache License 2.0
325 stars 28 forks source link

Implement non-caching text matcher #76

Closed Nikitae57 closed 1 year ago

Nikitae57 commented 1 year ago

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:

Expected Results:

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 commented 1 year ago

I'll create a PR shortly