Fix WhenToDreamPickerTest and re-enable.

The test was previously failing because it was passing a mock context
which didn't support all the operations of a real context.

Bug: 216036457
Test: make -j64 RunSettingsRoboTests ROBOTEST_FILTER="com.android.settings.dream.WhenToDreamPickerTest"
Change-Id: I2c769658dc687ef26d184b7ce9065c18ab8b9b8d
diff --git a/tests/robotests/src/com/android/settings/dream/WhenToDreamPickerTest.java b/tests/robotests/src/com/android/settings/dream/WhenToDreamPickerTest.java
index fd0cf5f..16f8599 100644
--- a/tests/robotests/src/com/android/settings/dream/WhenToDreamPickerTest.java
+++ b/tests/robotests/src/com/android/settings/dream/WhenToDreamPickerTest.java
@@ -18,18 +18,19 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import android.app.Activity;
 import android.content.Context;
 import android.os.UserManager;
 
+import androidx.test.core.app.ApplicationProvider;
+
 import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settingslib.dream.DreamBackend;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Answers;
@@ -39,25 +40,24 @@
 import org.robolectric.util.ReflectionHelpers;
 
 @RunWith(RobolectricTestRunner.class)
-@Ignore
 public class WhenToDreamPickerTest {
 
     private WhenToDreamPicker mPicker;
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
     private DreamBackend mBackend;
-    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
-    private Activity mActivity;
     @Mock
     private UserManager mUserManager;
 
     @Before
     public void setup() {
         MockitoAnnotations.initMocks(this);
-        when(mActivity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
+        final Context context = spy(ApplicationProvider.getApplicationContext());
+
+        when(context.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
         FakeFeatureFactory.setupForTest();
 
         mPicker = new WhenToDreamPicker();
-        mPicker.onAttach((Context) mActivity);
+        mPicker.onAttach(context);
 
         ReflectionHelpers.setField(mPicker, "mBackend", mBackend);
     }