diff options
author | John Patterson <jdp@google.com> | 2020-08-31 10:33:28 +0200 |
---|---|---|
committer | John Patterson <jdp@google.com> | 2020-10-13 07:47:24 +0000 |
commit | c8ca0af8da5e7f43264248a607109e6247e7ad7e (patch) | |
tree | 99176964f5806d2523f22b12af255f8f83cf176d | |
parent | 9c08312784ae07634761ea3be402d6478a57e385 (diff) | |
download | Calendar-c8ca0af8da5e7f43264248a607109e6247e7ad7e.tar.gz |
Add test for starting the calendar app without test dependencies.
Fixes: 163647860
Test: atest CarCalendarUiTests
Change-Id: I9ef5ee955ae889ad8bbe43e0699f47c2c7a7a623
-rw-r--r-- | tests/ui/src/com/android/car/calendar/CarCalendarUiTest.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/tests/ui/src/com/android/car/calendar/CarCalendarUiTest.java b/tests/ui/src/com/android/car/calendar/CarCalendarUiTest.java index 5c7883c..d3992f6 100644 --- a/tests/ui/src/com/android/car/calendar/CarCalendarUiTest.java +++ b/tests/ui/src/com/android/car/calendar/CarCalendarUiTest.java @@ -97,6 +97,9 @@ public class CarCalendarUiTest { private List<Object[]> mTestEventRows; + // If set to true fake dependencies will not be set and the real provider will be used. + private boolean mDoNotSetFakeDependencies; + // These can be set in the test thread and read on the main thread. private volatile CountDownLatch mEventChangesLatch; @@ -104,9 +107,12 @@ public class CarCalendarUiTest { public void setUp() { ActivityLifecycleMonitorRegistry.getInstance().addLifecycleCallback(mLifecycleCallback); mTestEventRows = new ArrayList<>(); + mDoNotSetFakeDependencies = false; } private void onActivityLifecycleChanged(Activity activity, Stage stage) { + if (mDoNotSetFakeDependencies) return; + if (stage.equals(Stage.PRE_ON_CREATE)) { setActivityDependencies((CarCalendarActivity) activity); } else if (stage.equals(Stage.CREATED)) { @@ -154,9 +160,18 @@ public class CarCalendarUiTest { } @Test - public void calendar_titleShows() { + public void withFakeDependencies_titleShows() { try (ActivityScenario<CarCalendarActivity> ignored = - ActivityScenario.launch(CarCalendarActivity.class)) { + ActivityScenario.launch(CarCalendarActivity.class)) { + onView(withText(R.string.app_name)).check(matches(isDisplayed())); + } + } + + @Test + public void withoutFakeDependencies_titleShows() { + mDoNotSetFakeDependencies = true; + try (ActivityScenario<CarCalendarActivity> ignored = + ActivityScenario.launch(CarCalendarActivity.class)) { onView(withText(R.string.app_name)).check(matches(isDisplayed())); } } |