diff options
author | Xin Li <delphij@google.com> | 2021-10-06 22:53:50 +0000 |
---|---|---|
committer | Xin Li <delphij@google.com> | 2021-10-06 22:53:50 +0000 |
commit | 520b214c1a1a14ce2503dbeb42c07cf8843da4d0 (patch) | |
tree | 6d90760f071b9230e90177d5e53dceb15ac357a8 /tests/ui/src/com/android/car/calendar/CarCalendarUiTest.java | |
parent | 9cd37af2c842129edc9e51253801700c3aa1c806 (diff) | |
parent | a6bf94fd77caac579d4689d7db3898876fa5e927 (diff) | |
download | Calendar-520b214c1a1a14ce2503dbeb42c07cf8843da4d0.tar.gz |
Merge Android 12android-s-v2-preview-2android-s-v2-preview-1android-s-v2-beta-2android-s-v2-preview-1
Bug: 202323961
Merged-In: I9033d54980699de66edac9ba4b524a9c5ecd1c65
Change-Id: I1ef0152509e98609ae8fa5b7fa6d234c6572ee11
Diffstat (limited to 'tests/ui/src/com/android/car/calendar/CarCalendarUiTest.java')
-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())); } } |