aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/ui/src/com/android/car/calendar/CarCalendarUiTest.java19
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()));
}
}