diff options
Diffstat (limited to 'tests/ui/src/com')
-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 d342e3d..e591a80 100644 --- a/tests/ui/src/com/android/car/calendar/CarCalendarUiTest.java +++ b/tests/ui/src/com/android/car/calendar/CarCalendarUiTest.java @@ -98,6 +98,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; @@ -105,9 +108,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)) { @@ -156,9 +162,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())); } } |