Introduce Mock IME for device-side test
This CL introduces a mock IME, with which we can fully control how
the IME behaves during tests. This mock IME also allows us to write
expectation rules regarding when and in which order the IME is
receiving related callbacks from the system.
At high level, you can use Mock IME via MockImeSession class.
It takes care of lifecycle of the Mock IME including clean up tasks.
try(MockImeSession imeSession = MockImeSession.create(
InstrumentationRegistry.getContext(),
InstrumentationRegistry.getInstrumentation()
.getUiAutomation()) {
// Mock IME is enabled and selected here.
}
// Mock IME is de-selected and disabled here.
To use Mock IME, you have to include Mock IME into your test APK as
follows:
<service
android:name="com.android.cts.mockime.MockIme"
android:label="Mock IME"
android:permission="android.permission.BIND_INPUT_METHOD"
android:process=":mockime">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
<meta-data
android:name="android.view.im"
android:resource="@xml/method" />
</service>
Once our build system supports building *.aar, then we can simply
link to Mock IME aar and let manifest merger to do the above task,
but for each test APK that uses Mock IME needs to write the above
configuration with XML resource for IME.
Note that this CL only adds the mock IME build target and lets
CtsInputMethodTestCases.apk to include that mock IME within its APK.
Other than that, there should be no behavior change as far as CTS
tests are concerned.
Bug: 69845539
Test: atest CtsInputMethodTestCases
Change-Id: I2dedbad5d6276ec5bd20b0f31b05825b0c4a28d9
9 files changed