Fix robolectric test failure
Default UserManager caches instance across entire test suite, so
test becomes flakey depending on the order they are run. Using a
a ShadowUserManager without the cache ensures each test class gets
a UserManager with clean state.
Change-Id: Ia54f6a3259859add5a1e5d0101829497fb985ab1
Fix: 38393235
Test: make RunSettingsRoboTests
diff --git a/tests/robotests/src/com/android/settings/system/SystemDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/system/SystemDashboardFragmentTest.java
index 65b39e6..483dee7 100644
--- a/tests/robotests/src/com/android/settings/system/SystemDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/system/SystemDashboardFragmentTest.java
@@ -17,11 +17,13 @@
package com.android.settings.system;
import android.content.Context;
-
import android.os.UserManager;
+
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.testutils.XmlTestUtils;
+import com.android.settings.testutils.shadow.ShadowUserManager;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment;
@@ -36,7 +38,10 @@
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+ shadows = {
+ ShadowUserManager.class
+ })
public class SystemDashboardFragmentTest {
@Test