Android's Window system allows multiple view hierarchies to layer on top of each other.
A real world analogy would be an overhead projector with multiple transparencies placed on top of each other. Each Window is a transparency, and what is drawn on top of this transparency is the view hierarchy.
By default Espresso uses a heuristic to guess which Window you intend to interact with. This heuristic is normally 'good enough' however if you want to interact with a Window that it does not select then you'll have to swap in your own root window matcher. Initially there's only one window, but typing into the auto-complete text view creates another window that will be layered on top of the screen. Espresso ignores this layer because it is not connected to the keyboard/ime.
Espresso provides the ability to switch the default window matcher used in both onView and onData interactions.
This project uses the Gradle build system. You don't need an IDE to build and execute it but Android Studio is recommended.
git clone
../build.gradle
file.src/main/java
src/androidTest/java
android.support.test.runner.AndroidJUnitRunner
android.support.test.runner.AndroidJUnitRunner
The application will be started on the device/emulator and a series of actions will be performed automatically.
If you are using Android Studio, the Run window will show the test results.
compileSdkVersion 26
applicationId "com.example.android.testing.espresso.MultiWindowSample"
minSdkVersion 9
targetSdkVersion 26
versionCode 1
versionName "1.0"
compile 'com.android.support:support-annotations:' + rootProject.supportLibVersion;
compile 'com.google.guava:guava:18.0'
package com.example.android.testing.espresso.MultiWindowSample
An {@link android.app.Activity} that shows an editable text and gives suggestions to the user.
Creates an adapter and sets it to an {@link AutoCompleteTextView} to enable suggestions.