Merge "Fix WhenToDreamPickerTest and re-enable." into tm-dev am: 9ceec097b1
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/17123847
Change-Id: Ia1d5a6a6c3331366505d471ce00fa730c98a6490
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);
}