android / android/android-test

Espresso example doesn't work with Chinese Pinyin IME

Open
#1,105 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.2k
Forks
342
Avg merge
11h 29m
Merged PRs (30d)
2

Description

When run the following unit tests code from android-testing sample project:

```
public static final String STRING_TO_BE_TYPED = "Espresso";

/**
* A JUnit {@link Rule @Rule} to launch your activity under test. This is a replacement
* for {@link ActivityInstrumentationTestCase2}.
*


* Rules are interceptors which are executed for each test method and will run before
* any of your setup code in the {@link Before @Before} method.
*


* {@link ActivityTestRule} will create and launch of the activity for you and also expose
* the activity under test. To get a reference to the activity you can use
* the {@link ActivityTestRule#getActivity()} method.
*/
@Rule
public ActivityTestRule mActivityRule = new ActivityTestRule<>(
MainActivity.class);

@Test
public void changeText_sameActivity() {
// Type text and then press the button.
onView(withId(R.id.editTextUserInput))
.perform(typeText(STRING_TO_BE_TYPED), closeSoftKeyboard());
onView(withId(R.id.changeTextBt)).perform(click());

// Check that the text was changed.
onView(withId(R.id.textToBeChanged)).check(matches(withText(STRING_TO_BE_TYPED)));
}
```

But, i found that text typed on the TextView is "E", not "Espresso" that i expected, so the test failed.

I think that this issue is related to the keyboard & input methods i has chose.My choice is Chinese Pinyin.
When using that keyboard & input method, the ViewAction typeText only typed the first uppercase "E", the following lowercase alphabets were not typed on the TextView.

Copied from https://issuetracker.google.com/issues/37079903

Contributor guide

Open the contributing guide

Research direction

Start with the Espresso sample test shown in the issue and reproduce changeText_sameActivity using the Chinese Pinyin IME. Trace the typeText action and input-method behavior to determine why only the initial uppercase character reaches the TextView. Done means the sample types the full "Espresso" string and its existing assertion passes with that IME.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.