aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/com/android/car/calendar/CarCalendarActivity.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/com/android/car/calendar/CarCalendarActivity.java b/src/com/android/car/calendar/CarCalendarActivity.java
index ca27931..97e2031 100644
--- a/src/com/android/car/calendar/CarCalendarActivity.java
+++ b/src/com/android/car/calendar/CarCalendarActivity.java
@@ -48,14 +48,19 @@ public class CarCalendarActivity extends FragmentActivity {
private final Multimap<String, Runnable> mPermissionToCallbacks = HashMultimap.create();
// Allows tests to replace certain dependencies.
- @VisibleForTesting Dependencies mDependencies = new Dependencies(
- Locale.getDefault(), Clock.systemDefaultZone(), getContentResolver());
+ @VisibleForTesting Dependencies mDependencies;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
maybeEnableStrictMode();
+ // Tests can set fake dependencies before onCreate.
+ if (mDependencies == null) {
+ mDependencies = new Dependencies(
+ Locale.getDefault(), Clock.systemDefaultZone(), getContentResolver());
+ }
+
CarCalendarViewModel carCalendarViewModel =
new ViewModelProvider(
this,