-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
EspressoWithPausedLooperTest.java
41 lines (34 loc) · 1.31 KB
/
EspressoWithPausedLooperTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package org.robolectric.integrationtests.axt;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static org.robolectric.shadows.ShadowLooper.shadowMainLooper;
import androidx.test.core.app.ActivityScenario;
import androidx.test.espresso.Espresso;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.robolectric.integration.axt.R;
/** Verify Espresso usage with paused looper */
@RunWith(AndroidJUnit4.class)
public final class EspressoWithPausedLooperTest {
@Before
public void setUp() {
shadowMainLooper().pause();
ActivityScenario.launch(EspressoActivity.class);
}
@Test
public void launchActivity() {}
@Test
public void onIdle_doesnt_block() throws Exception {
Espresso.onIdle();
}
/** Perform the equivalent of launchActivityAndFindView_ById except using espresso APIs */
@Test
public void launchActivityAndFindView_espresso() throws Exception {
onView(withId(R.id.edit_text)).check(matches(isCompletelyDisplayed()));
}
}