Update layout and strings for DO Disclosures
This CL updates the DO Disclosures page (aka "Enterprise Privacy") to incorporate UI layout and string changes proposed since implementation began. There are no logic changes. Test: make RunSettingsRoboTests Bug: 32692748 Change-Id: I6ae972e77bd90eb9c61d6a516046a6eb09981ad3
This commit is contained in:
@@ -59,12 +59,12 @@ public abstract class AdminActionPreferenceControllerTestBase {
|
||||
@Test
|
||||
public void testUpdateState() {
|
||||
final Preference preference = new Preference(mContext, null, 0, 0);
|
||||
when(mContext.getString(R.string.enterprise_privacy_never)).thenReturn("Never");
|
||||
when(mContext.getString(R.string.enterprise_privacy_none)).thenReturn("None");
|
||||
Settings.System.putString(mContext.getContentResolver(), Settings.System.TIME_12_24, "24");
|
||||
|
||||
setDate(null);
|
||||
mController.updateState(preference);
|
||||
assertThat(preference.getSummary()).isEqualTo("Never");
|
||||
assertThat(preference.getSummary()).isEqualTo("None");
|
||||
|
||||
final Date date = new GregorianCalendar(2011 /* year */, 10 /* month */, 9 /* dayOfMonth */,
|
||||
8 /* hourOfDay */, 7 /* minute */, 6 /* second */).getTime();
|
||||
|
@@ -18,7 +18,6 @@ package com.android.settings.enterprise;
|
||||
|
||||
import android.Manifest;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -34,8 +33,7 @@ public final class AdminGrantedCameraPermissionPreferenceControllerTest extends
|
||||
|
||||
public AdminGrantedCameraPermissionPreferenceControllerTest() {
|
||||
super("enterprise_privacy_number_camera_access_packages",
|
||||
new String[] {Manifest.permission.CAMERA},
|
||||
R.plurals.enterprise_privacy_number_camera_access_packages);
|
||||
new String[] {Manifest.permission.CAMERA});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -18,7 +18,6 @@ package com.android.settings.enterprise;
|
||||
|
||||
import android.Manifest;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -35,8 +34,7 @@ public final class AdminGrantedLocationPermissionsPreferenceControllerTest exten
|
||||
public AdminGrantedLocationPermissionsPreferenceControllerTest() {
|
||||
super("enterprise_privacy_number_location_access_packages",
|
||||
new String[] {Manifest.permission.ACCESS_COARSE_LOCATION,
|
||||
Manifest.permission.ACCESS_FINE_LOCATION},
|
||||
R.plurals.enterprise_privacy_number_location_access_packages);
|
||||
Manifest.permission.ACCESS_FINE_LOCATION});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -18,7 +18,6 @@ package com.android.settings.enterprise;
|
||||
|
||||
import android.Manifest;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -34,8 +33,7 @@ public final class AdminGrantedMicrophonePermissionPreferenceControllerTest exte
|
||||
|
||||
public AdminGrantedMicrophonePermissionPreferenceControllerTest() {
|
||||
super("enterprise_privacy_number_microphone_access_packages",
|
||||
new String[] {Manifest.permission.RECORD_AUDIO},
|
||||
R.plurals.enterprise_privacy_number_microphone_access_packages);
|
||||
new String[] {Manifest.permission.RECORD_AUDIO});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -30,7 +30,7 @@ public final class AdminGrantedPermissionsPreferenceControllerBaseTest extends
|
||||
AdminGrantedPermissionsPreferenceControllerTestBase {
|
||||
|
||||
public AdminGrantedPermissionsPreferenceControllerBaseTest() {
|
||||
super(null, new String[] {"some.permission"}, 123 /* resourceStringId */);
|
||||
super(null, new String[] {"some.permission"});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,8 +43,7 @@ public final class AdminGrantedPermissionsPreferenceControllerBaseTest extends
|
||||
AdminGrantedPermissionsPreferenceControllerBase {
|
||||
|
||||
AdminGrantedPermissionsPreferenceControllerBaseTestable() {
|
||||
super(AdminGrantedPermissionsPreferenceControllerBaseTest.this.mContext, mPermissions,
|
||||
mStringResourceId);
|
||||
super(AdminGrantedPermissionsPreferenceControllerBaseTest.this.mContext, mPermissions);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -20,6 +20,7 @@ import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
|
||||
@@ -44,7 +45,6 @@ public abstract class AdminGrantedPermissionsPreferenceControllerTestBase {
|
||||
|
||||
protected final String mKey;
|
||||
protected final String[] mPermissions;
|
||||
protected final int mStringResourceId;
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
protected Context mContext;
|
||||
@@ -52,11 +52,9 @@ public abstract class AdminGrantedPermissionsPreferenceControllerTestBase {
|
||||
|
||||
protected AdminGrantedPermissionsPreferenceControllerBase mController;
|
||||
|
||||
public AdminGrantedPermissionsPreferenceControllerTestBase(String key, String[] permissions,
|
||||
int stringResourceId) {
|
||||
public AdminGrantedPermissionsPreferenceControllerTestBase(String key, String[] permissions) {
|
||||
mKey = key;
|
||||
mPermissions = permissions;
|
||||
mStringResourceId = stringResourceId;
|
||||
}
|
||||
|
||||
@Before
|
||||
@@ -83,10 +81,10 @@ public abstract class AdminGrantedPermissionsPreferenceControllerTestBase {
|
||||
preference.setVisible(false);
|
||||
|
||||
setNumberOfPackagesWithAdminGrantedPermissions(20);
|
||||
when(mContext.getResources().getQuantityString(mStringResourceId, 20, 20))
|
||||
.thenReturn("20 packages");
|
||||
when(mContext.getResources().getQuantityString(R.plurals.enterprise_privacy_number_packages,
|
||||
20, 20)).thenReturn("20 packages");
|
||||
mController.updateState(preference);
|
||||
assertThat(preference.getTitle()).isEqualTo("20 packages");
|
||||
assertThat(preference.getSummary()).isEqualTo("20 packages");
|
||||
assertThat(preference.isVisible()).isTrue();
|
||||
|
||||
setNumberOfPackagesWithAdminGrantedPermissions(0);
|
||||
|
@@ -43,8 +43,12 @@ import static org.mockito.Mockito.when;
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public final class CaCertsCurrentUserPreferenceControllerTest {
|
||||
|
||||
private final String INSTALLED_CERTS_USER = "10 certs installed";
|
||||
private final String INSTALLED_CERTS_PERSONAL = "10 certs installed in personal profile";
|
||||
private final String INSTALLED_CERTS_USER_1 = "cert installed";
|
||||
private final String INSTALLED_CERTS_USER_10 = "certs installed";
|
||||
private final String INSTALLED_CERTS_PERSONAL_1 = "cert installed in personal profile";
|
||||
private final String INSTALLED_CERTS_PERSONAL_10 = "certs installed in personal profile";
|
||||
private final String NUMBER_INSTALLED_CERTS_1 = "1 cert";
|
||||
private final String NUMBER_INSTALLED_CERTS_10 = "10 certs";
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private Context mContext;
|
||||
@@ -58,12 +62,21 @@ public final class CaCertsCurrentUserPreferenceControllerTest {
|
||||
FakeFeatureFactory.setupForTest(mContext);
|
||||
mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
|
||||
mController = new CaCertsCurrentUserPreferenceController(mContext);
|
||||
|
||||
when(mContext.getResources().getQuantityString(R.plurals.enterprise_privacy_ca_certs_user,
|
||||
1)).thenReturn(INSTALLED_CERTS_USER_1);
|
||||
when(mContext.getResources().getQuantityString(R.plurals.enterprise_privacy_ca_certs_user,
|
||||
10)).thenReturn(INSTALLED_CERTS_USER_10);
|
||||
when(mContext.getResources().getQuantityString(
|
||||
R.plurals.enterprise_privacy_ca_certs_user, 10, 10))
|
||||
.thenReturn(INSTALLED_CERTS_USER);
|
||||
R.plurals.enterprise_privacy_ca_certs_personal, 1))
|
||||
.thenReturn(INSTALLED_CERTS_PERSONAL_1);
|
||||
when(mContext.getResources().getQuantityString(
|
||||
R.plurals.enterprise_privacy_ca_certs_personal, 10, 10))
|
||||
.thenReturn(INSTALLED_CERTS_PERSONAL);
|
||||
R.plurals.enterprise_privacy_ca_certs_personal, 10))
|
||||
.thenReturn(INSTALLED_CERTS_PERSONAL_10);
|
||||
when(mContext.getResources().getQuantityString(R.plurals.enterprise_privacy_number_ca_certs,
|
||||
1, 1)).thenReturn(NUMBER_INSTALLED_CERTS_1);
|
||||
when(mContext.getResources().getQuantityString(R.plurals.enterprise_privacy_number_ca_certs,
|
||||
10, 10)).thenReturn(NUMBER_INSTALLED_CERTS_10);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,11 +91,20 @@ public final class CaCertsCurrentUserPreferenceControllerTest {
|
||||
mController.updateState(preference);
|
||||
assertThat(preference.isVisible()).isFalse();
|
||||
|
||||
when(mFeatureFactory.enterprisePrivacyFeatureProvider
|
||||
.getNumberOfOwnerInstalledCaCertsInCurrentUser()).thenReturn(1);
|
||||
mController.updateState(preference);
|
||||
assertThat(preference.isVisible()).isTrue();
|
||||
assertThat(preference.getTitle()).isEqualTo(INSTALLED_CERTS_USER_1);
|
||||
assertThat(preference.getSummary()).isEqualTo(NUMBER_INSTALLED_CERTS_1);
|
||||
|
||||
preference.setVisible(false);
|
||||
when(mFeatureFactory.enterprisePrivacyFeatureProvider
|
||||
.getNumberOfOwnerInstalledCaCertsInCurrentUser()).thenReturn(10);
|
||||
mController.updateState(preference);
|
||||
assertThat(preference.isVisible()).isTrue();
|
||||
assertThat(preference.getTitle()).isEqualTo(INSTALLED_CERTS_USER);
|
||||
assertThat(preference.getTitle()).isEqualTo(INSTALLED_CERTS_USER_10);
|
||||
assertThat(preference.getSummary()).isEqualTo(NUMBER_INSTALLED_CERTS_10);
|
||||
|
||||
when(mFeatureFactory.enterprisePrivacyFeatureProvider.isInCompMode()).thenReturn(true);
|
||||
|
||||
@@ -91,11 +113,20 @@ public final class CaCertsCurrentUserPreferenceControllerTest {
|
||||
mController.updateState(preference);
|
||||
assertThat(preference.isVisible()).isFalse();
|
||||
|
||||
when(mFeatureFactory.enterprisePrivacyFeatureProvider
|
||||
.getNumberOfOwnerInstalledCaCertsInCurrentUser()).thenReturn(1);
|
||||
mController.updateState(preference);
|
||||
assertThat(preference.isVisible()).isTrue();
|
||||
assertThat(preference.getTitle()).isEqualTo(INSTALLED_CERTS_PERSONAL_1);
|
||||
assertThat(preference.getSummary()).isEqualTo(NUMBER_INSTALLED_CERTS_1);
|
||||
|
||||
preference.setVisible(false);
|
||||
when(mFeatureFactory.enterprisePrivacyFeatureProvider
|
||||
.getNumberOfOwnerInstalledCaCertsInCurrentUser()).thenReturn(10);
|
||||
mController.updateState(preference);
|
||||
assertThat(preference.isVisible()).isTrue();
|
||||
assertThat(preference.getTitle()).isEqualTo(INSTALLED_CERTS_PERSONAL);
|
||||
assertThat(preference.getTitle()).isEqualTo(INSTALLED_CERTS_PERSONAL_10);
|
||||
assertThat(preference.getSummary()).isEqualTo(NUMBER_INSTALLED_CERTS_10);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -43,7 +43,10 @@ import static org.mockito.Mockito.when;
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public final class CaCertsManagedProfilePreferenceControllerTest {
|
||||
|
||||
private final String INSTALLED_CERTS = "10 certs installed";
|
||||
private final String INSTALLED_CERTS_1 = "cert installed";
|
||||
private final String INSTALLED_CERTS_10 = "certs installed";
|
||||
private final String NUMBER_INSTALLED_CERTS_1 = "1 cert";
|
||||
private final String NUMBER_INSTALLED_CERTS_10 = "10 certs";
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private Context mContext;
|
||||
@@ -57,8 +60,15 @@ public final class CaCertsManagedProfilePreferenceControllerTest {
|
||||
FakeFeatureFactory.setupForTest(mContext);
|
||||
mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
|
||||
mController = new CaCertsManagedProfilePreferenceController(mContext);
|
||||
when(mContext.getResources().getQuantityString(
|
||||
R.plurals.enterprise_privacy_ca_certs_work, 10, 10)).thenReturn(INSTALLED_CERTS);
|
||||
|
||||
when(mContext.getResources().getQuantityString(R.plurals.enterprise_privacy_ca_certs_work,
|
||||
1)).thenReturn(INSTALLED_CERTS_1);
|
||||
when(mContext.getResources().getQuantityString(R.plurals.enterprise_privacy_ca_certs_work,
|
||||
10)).thenReturn(INSTALLED_CERTS_10);
|
||||
when(mContext.getResources().getQuantityString(R.plurals.enterprise_privacy_number_ca_certs,
|
||||
1, 1)).thenReturn(NUMBER_INSTALLED_CERTS_1);
|
||||
when(mContext.getResources().getQuantityString(R.plurals.enterprise_privacy_number_ca_certs,
|
||||
10, 10)).thenReturn(NUMBER_INSTALLED_CERTS_10);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -71,11 +81,20 @@ public final class CaCertsManagedProfilePreferenceControllerTest {
|
||||
mController.updateState(preference);
|
||||
assertThat(preference.isVisible()).isFalse();
|
||||
|
||||
when(mFeatureFactory.enterprisePrivacyFeatureProvider
|
||||
.getNumberOfOwnerInstalledCaCertsInManagedProfile()).thenReturn(1);
|
||||
mController.updateState(preference);
|
||||
assertThat(preference.isVisible()).isTrue();
|
||||
assertThat(preference.getTitle()).isEqualTo(INSTALLED_CERTS_1);
|
||||
assertThat(preference.getSummary()).isEqualTo(NUMBER_INSTALLED_CERTS_1);
|
||||
|
||||
preference.setVisible(false);
|
||||
when(mFeatureFactory.enterprisePrivacyFeatureProvider
|
||||
.getNumberOfOwnerInstalledCaCertsInManagedProfile()).thenReturn(10);
|
||||
mController.updateState(preference);
|
||||
assertThat(preference.isVisible()).isTrue();
|
||||
assertThat(preference.getTitle()).isEqualTo(INSTALLED_CERTS);
|
||||
assertThat(preference.getTitle()).isEqualTo(INSTALLED_CERTS_10);
|
||||
assertThat(preference.getSummary()).isEqualTo(NUMBER_INSTALLED_CERTS_10);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -86,11 +86,10 @@ public final class EnterpriseInstalledPackagesPreferenceControllerTest {
|
||||
assertThat(preference.isVisible()).isFalse();
|
||||
|
||||
setNumberOfEnterpriseInstalledPackages(20);
|
||||
when(mContext.getResources().getQuantityString(
|
||||
R.plurals.enterprise_privacy_number_enterprise_installed_packages, 20, 20))
|
||||
.thenReturn("20 packages");
|
||||
when(mContext.getResources().getQuantityString(R.plurals.enterprise_privacy_number_packages,
|
||||
20, 20)).thenReturn("20 packages");
|
||||
mController.updateState(preference);
|
||||
assertThat(preference.getTitle()).isEqualTo("20 packages");
|
||||
assertThat(preference.getSummary()).isEqualTo("20 packages");
|
||||
assertThat(preference.isVisible()).isTrue();
|
||||
}
|
||||
|
||||
|
@@ -118,11 +118,10 @@ public final class EnterpriseSetDefaultAppsPreferenceControllerTest {
|
||||
ContactsContract.Contacts.CONTENT_TYPE)}, 32);
|
||||
setEnterpriseSetDefaultApps(new Intent[] {new Intent(Intent.ACTION_DIAL),
|
||||
new Intent(Intent.ACTION_CALL)}, 64);
|
||||
when(mContext.getResources().getQuantityString(
|
||||
R.plurals.enterprise_privacy_number_enterprise_set_default_apps, 127, 127))
|
||||
.thenReturn("127 apps");
|
||||
when(mContext.getResources().getQuantityString(R.plurals.enterprise_privacy_number_packages,
|
||||
127, 127)).thenReturn("127 apps");
|
||||
mController.updateState(preference);
|
||||
assertThat(preference.getTitle()).isEqualTo("127 apps");
|
||||
assertThat(preference.getSummary()).isEqualTo("127 apps");
|
||||
assertThat(preference.isVisible()).isTrue();
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,6 @@ package com.android.settings.enterprise;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
|
||||
@@ -38,8 +37,7 @@ public final class FailedPasswordWipeManagedProfilePreferenceControllerTest exte
|
||||
private int mMaximumFailedPasswordsBeforeWipe = 0;
|
||||
|
||||
public FailedPasswordWipeManagedProfilePreferenceControllerTest() {
|
||||
super("failed_password_wipe_managed_profile",
|
||||
R.plurals.enterprise_privacy_failed_password_wipe_work);
|
||||
super("failed_password_wipe_managed_profile");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -33,7 +33,7 @@ public final class FailedPasswordWipePreferenceControllerBaseTest extends
|
||||
private int mMaximumFailedPasswordsBeforeWipe = 0;
|
||||
|
||||
public FailedPasswordWipePreferenceControllerBaseTest() {
|
||||
super(null, 123 /* stringResourceId */);
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -50,7 +50,7 @@ public final class FailedPasswordWipePreferenceControllerBaseTest extends
|
||||
private class FailedPasswordWipePreferenceControllerBaseTestable extends
|
||||
FailedPasswordWipePreferenceControllerBase {
|
||||
FailedPasswordWipePreferenceControllerBaseTestable() {
|
||||
super(FailedPasswordWipePreferenceControllerBaseTest.this.mContext, mStringResourceId);
|
||||
super(FailedPasswordWipePreferenceControllerBaseTest.this.mContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -20,6 +20,7 @@ import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -37,7 +38,6 @@ import static org.mockito.Mockito.when;
|
||||
public abstract class FailedPasswordWipePreferenceControllerTestBase {
|
||||
|
||||
protected final String mKey;
|
||||
protected final int mStringResourceId;
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
protected Context mContext;
|
||||
@@ -45,9 +45,8 @@ public abstract class FailedPasswordWipePreferenceControllerTestBase {
|
||||
|
||||
protected FailedPasswordWipePreferenceControllerBase mController;
|
||||
|
||||
public FailedPasswordWipePreferenceControllerTestBase(String key, int stringResourceId) {
|
||||
public FailedPasswordWipePreferenceControllerTestBase(String key) {
|
||||
mKey = key;
|
||||
mStringResourceId = stringResourceId;
|
||||
}
|
||||
|
||||
@Before
|
||||
@@ -65,11 +64,11 @@ public abstract class FailedPasswordWipePreferenceControllerTestBase {
|
||||
preference.setVisible(false);
|
||||
|
||||
setMaximumFailedPasswordsBeforeWipe(10);
|
||||
when(mContext.getResources().getQuantityString(mStringResourceId, 10, 10))
|
||||
when(mContext.getResources().getQuantityString(
|
||||
R.plurals.enterprise_privacy_number_failed_password_wipe, 10, 10))
|
||||
.thenReturn("10 attempts");
|
||||
mController.updateState(preference);
|
||||
assertThat(preference.getTitle()).isEqualTo("10 attempts");
|
||||
assertThat(preference.isVisible()).isTrue();
|
||||
assertThat(preference.getSummary()).isEqualTo("10 attempts");
|
||||
|
||||
setMaximumFailedPasswordsBeforeWipe(0);
|
||||
mController.updateState(preference);
|
||||
|
@@ -18,7 +18,6 @@ package com.android.settings.enterprise;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
|
||||
@@ -38,8 +37,7 @@ public final class FailedPasswordWipePrimaryUserPreferenceControllerTest extends
|
||||
private int mMaximumFailedPasswordsBeforeWipe = 0;
|
||||
|
||||
public FailedPasswordWipePrimaryUserPreferenceControllerTest() {
|
||||
super("failed_password_wipe_primary_user",
|
||||
R.plurals.enterprise_privacy_failed_password_wipe_device);
|
||||
super("failed_password_wipe_primary_user");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -44,7 +44,7 @@ import static org.mockito.Mockito.when;
|
||||
public final class ImePreferenceControllerTest {
|
||||
|
||||
private final String DEFAULT_IME_LABEL = "Test IME";
|
||||
private final String DEFAULT_IME_TEXT = "IME set to Test IME";
|
||||
private final String DEFAULT_IME_TEXT = "Set to Test IME";
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private Context mContext;
|
||||
@@ -58,7 +58,7 @@ public final class ImePreferenceControllerTest {
|
||||
FakeFeatureFactory.setupForTest(mContext);
|
||||
mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
|
||||
mController = new ImePreferenceController(mContext);
|
||||
when(mContext.getResources().getString(R.string.enterprise_privacy_input_method,
|
||||
when(mContext.getResources().getString(R.string.enterprise_privacy_input_method_name,
|
||||
DEFAULT_IME_LABEL)).thenReturn(DEFAULT_IME_TEXT);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public final class ImePreferenceControllerTest {
|
||||
.thenReturn(DEFAULT_IME_LABEL);
|
||||
mController.updateState(preference);
|
||||
assertThat(preference.isVisible()).isTrue();
|
||||
assertThat(preference.getTitle()).isEqualTo(DEFAULT_IME_TEXT);
|
||||
assertThat(preference.getSummary()).isEqualTo(DEFAULT_IME_TEXT);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -64,22 +64,30 @@ public final class InstalledPackagesPreferenceControllerTest {
|
||||
mController = new InstalledPackagesPreferenceController(mContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateState() {
|
||||
final Preference preference = new Preference(mContext, null, 0, 0);
|
||||
private void setNumberOfInstalledPackages(int number) {
|
||||
doAnswer(new Answer() {
|
||||
public Object answer(InvocationOnMock invocation) {
|
||||
((ApplicationFeatureProvider.NumberOfAppsCallback)
|
||||
invocation.getArguments()[1]).onNumberOfAppsResult(20);
|
||||
invocation.getArguments()[1]).onNumberOfAppsResult(number);
|
||||
return null;
|
||||
}}).when(mFeatureFactory.applicationFeatureProvider)
|
||||
.calculateNumberOfInstalledApps(
|
||||
eq(ApplicationFeatureProvider.IGNORE_INSTALL_REASON), anyObject());
|
||||
when(mContext.getResources().getQuantityString(
|
||||
R.plurals.enterprise_privacy_number_installed_packages, 20, 20))
|
||||
.thenReturn("20 packages");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateState() {
|
||||
final Preference preference = new Preference(mContext, null, 0, 0);
|
||||
|
||||
setNumberOfInstalledPackages(0);
|
||||
mController.updateState(preference);
|
||||
assertThat(preference.getTitle()).isEqualTo("20 packages");
|
||||
assertThat(preference.getSummary()).isEqualTo("");
|
||||
|
||||
setNumberOfInstalledPackages(20);
|
||||
when(mContext.getResources().getQuantityString(R.plurals.enterprise_privacy_number_packages,
|
||||
20, 20)).thenReturn("20 packages");
|
||||
mController.updateState(preference);
|
||||
assertThat(preference.getSummary()).isEqualTo("20 packages");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -95,6 +103,6 @@ public final class InstalledPackagesPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void testGetPreferenceKey() {
|
||||
assertThat(mController.getPreferenceKey()).isEqualTo("number_installed_packages");
|
||||
assertThat(mController.getPreferenceKey()).isEqualTo("installed_packages");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user