Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 739b0eef authored by Daniel Nishi's avatar Daniel Nishi
Browse files

Move the Robolectric shadow config up.

In my testing, this reduces the runtime of the Robolectric Settings test
suite on my Z840 workstation from 440 seconds to 402 seconds on average.
By avoiding having a method-level Robolectric shadow import, we avoid
going down a code path which needs to add more shadows later in the
Robolectric execution.

Bug: 64808827
Test: Settings robotests still pass
Change-Id: I7b40d73b30306ae3f9759281afbd7f7266579e24
parent 682ff556
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -45,7 +45,11 @@ import org.robolectric.annotation.Config;
import java.util.List;

@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(
    manifest = TestConfig.MANIFEST_PATH,
    sdk = TestConfig.SDK_VERSION,
    shadows = ShadowUtils.class
)
public class DeviceInfoSettingsTest {

    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
@@ -83,7 +87,6 @@ public class DeviceInfoSettingsTest {
    }

    @Test
    @Config(shadows = ShadowUtils.class)
    public void testNonIndexableKeys_existInXmlLayout() {
        final Context context = RuntimeEnvironment.application;
        final List<String> niks = DeviceInfoSettings.SEARCH_INDEX_DATA_PROVIDER
+5 −4
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ import android.os.Bundle;
import android.provider.Settings;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.ScrollView;

@@ -46,12 +45,15 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowActivity;

@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(
    manifest = TestConfig.MANIFEST_PATH,
    sdk = TestConfig.SDK_VERSION,
    shadows = {ShadowUtils.class}
)
public class MasterClearTest {

    @Mock
@@ -144,7 +146,6 @@ public class MasterClearTest {
    }

    @Test
    @Config(shadows = { ShadowUtils.class })
    public void testInitiateMasterClear_inDemoMode_sendsIntent() {
        ShadowUtils.setIsDemoUser(true);

+5 −4
Original line number Diff line number Diff line
@@ -60,7 +60,11 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
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 = {ShadowLockPatternUtils.class}
)
public class SecuritySettingsTest {

    private static final String MOCK_SUMMARY = "summary";
@@ -181,9 +185,6 @@ public class SecuritySettingsTest {
    }

    @Test
    @Config (shadows = {
            ShadowLockPatternUtils.class,
    })
    public void testNonIndexableKeys_existInXmlLayout() {
        final Context context = spy(RuntimeEnvironment.application);
        UserManager manager = mock(UserManager.class);
+5 −2
Original line number Diff line number Diff line
@@ -50,7 +50,11 @@ import org.robolectric.annotation.Implements;


@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(
    manifest = TestConfig.MANIFEST_PATH,
    sdk = TestConfig.SDK_VERSION,
    shadows = AccountHeaderPreferenceControllerTest.ShadowAuthenticatorHelper.class
)
public class AccountHeaderPreferenceControllerTest {

    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
@@ -83,7 +87,6 @@ public class AccountHeaderPreferenceControllerTest {
    }

    @Test
    @Config(shadows = ShadowAuthenticatorHelper.class)
    public void onResume_shouldDisplayAccountInEntityHeader() {
        final Lifecycle lifecycle = new Lifecycle();
        final Account account = new Account("name1@abc.com", "com.abc");
+0 −13
Original line number Diff line number Diff line
@@ -111,7 +111,6 @@ public class AccountPreferenceControllerTest {
    }

    @Test
    @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
    public void onResume_linkedUser_shouldAddOneAccountCategory() {
        final UserInfo info = new UserInfo(1, "user 1", 0);
        when(mUserManager.isManagedProfile()).thenReturn(false);
@@ -124,7 +123,6 @@ public class AccountPreferenceControllerTest {
    }

    @Test
    @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
    public void onResume_oneProfile_shouldAddOneAccountCategory() {
        final List<UserInfo> infos = new ArrayList<>();
        infos.add(new UserInfo(1, "user 1", 0));
@@ -138,7 +136,6 @@ public class AccountPreferenceControllerTest {
    }

    @Test
    @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
    public void onResume_twoProfiles_shouldAddTwoAccountCategory() {
        final List<UserInfo> infos = new ArrayList<>();
        infos.add(new UserInfo(1, "user 1", 0));
@@ -153,7 +150,6 @@ public class AccountPreferenceControllerTest {
    }

    @Test
    @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
    public void onResume_noProfileChange_shouldNotAddOrRemoveAccountCategory() {
        final List<UserInfo> infos = new ArrayList<>();
        infos.add(new UserInfo(1, "user 1", 0));
@@ -171,7 +167,6 @@ public class AccountPreferenceControllerTest {
    }

    @Test
    @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
    public void onResume_oneNewProfile_shouldAddOneAccountCategory() {
        final List<UserInfo> infos = new ArrayList<>();
        infos.add(new UserInfo(1, "user 1", 0));
@@ -189,7 +184,6 @@ public class AccountPreferenceControllerTest {
    }

    @Test
    @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
    public void onResume_oneProfileRemoved_shouldRemoveOneAccountCategory() {
        final List<UserInfo> infos = new ArrayList<>();
        infos.add(new UserInfo(1, "user 1", 0));
@@ -207,7 +201,6 @@ public class AccountPreferenceControllerTest {
    }

    @Test
    @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
    public void onResume_oneProfile_shouldSetAccountTitleWithUserName() {
        final List<UserInfo> infos = new ArrayList<>();
        infos.add(new UserInfo(1, "user 1", UserInfo.FLAG_MANAGED_PROFILE));
@@ -226,7 +219,6 @@ public class AccountPreferenceControllerTest {
    }

    @Test
    @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
    public void onResume_noPreferenceScreen_shouldNotCrash() {
        final List<UserInfo> infos = new ArrayList<>();
        infos.add(new UserInfo(1, "user 1", 0));
@@ -244,7 +236,6 @@ public class AccountPreferenceControllerTest {
    }

    @Test
    @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
    public void onResume_noPreferenceManager_shouldNotCrash() {
        when(mFragment.getPreferenceManager()).thenReturn(null);
        final List<UserInfo> infos = new ArrayList<>();
@@ -337,7 +328,6 @@ public class AccountPreferenceControllerTest {
    }

    @Test
    @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
    public void onResume_twoAccountsOfSameType_shouldAddThreePreferences() {
        final List<UserInfo> infos = new ArrayList<>();
        infos.add(new UserInfo(1, "user 1", 0));
@@ -417,7 +407,6 @@ public class AccountPreferenceControllerTest {
    }

    @Test
    @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
    public void onResume_noAccountChange_shouldNotAddAccountPreference() {
        final List<UserInfo> infos = new ArrayList<>();
        infos.add(new UserInfo(1, "user 1", 0));
@@ -498,7 +487,6 @@ public class AccountPreferenceControllerTest {
    }

    @Test
    @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
    public void onResume_oneNewAccountType_shouldAddOneAccountPreference() {
        final List<UserInfo> infos = new ArrayList<>();
        infos.add(new UserInfo(1, "user 1", 0));
@@ -534,7 +522,6 @@ public class AccountPreferenceControllerTest {
    }

    @Test
    @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
    public void onResume_oneAccountRemoved_shouldRemoveOneAccountPreference() {
        final List<UserInfo> infos = new ArrayList<>();
        infos.add(new UserInfo(1, "user 1", 0));
Loading