Merge "Remove duplicate strings."

This commit is contained in:
TreeHugger Robot
2022-08-26 17:52:54 +00:00
committed by Android (Google) Code Review
73 changed files with 118 additions and 246 deletions

View File

@@ -187,7 +187,7 @@ public class AccessibilitySettingsTest {
mServiceInfo, SERVICE_ENABLED);
assertThat(summary).isEqualTo(
mContext.getString(R.string.accessibility_summary_state_enabled));
mContext.getString(R.string.on));
}
@Test
@@ -198,13 +198,13 @@ public class AccessibilitySettingsTest {
mServiceInfo, SERVICE_DISABLED);
assertThat(summary).isEqualTo(
mContext.getString(R.string.accessibility_summary_state_disabled));
mContext.getString(R.string.off));
}
@Test
public void getServiceSummary_enableServiceAndHasSummary_showsEnabledSummary() {
final String service_enabled = mContext.getString(
R.string.accessibility_summary_state_enabled);
R.string.on);
doReturn(DEFAULT_SUMMARY).when(mServiceInfo).loadSummary(any());
final CharSequence summary = AccessibilitySettings.getServiceSummary(mContext,
@@ -218,7 +218,7 @@ public class AccessibilitySettingsTest {
@Test
public void getServiceSummary_disableServiceAndHasSummary_showsCombineDisabledSummary() {
final String service_disabled = mContext.getString(
R.string.accessibility_summary_state_disabled);
R.string.off);
doReturn(DEFAULT_SUMMARY).when(mServiceInfo).loadSummary(any());
final CharSequence summary = AccessibilitySettings.getServiceSummary(mContext,

View File

@@ -80,7 +80,7 @@ public final class AccessibilityUtilTest {
final CharSequence result = AccessibilityUtil.getSummary(mContext, SECURE_TEST_KEY);
assertThat(result)
.isEqualTo(mContext.getText(R.string.accessibility_feature_state_on));
.isEqualTo(mContext.getText(R.string.on));
}
@Test
@@ -90,7 +90,7 @@ public final class AccessibilityUtilTest {
final CharSequence result = AccessibilityUtil.getSummary(mContext, SECURE_TEST_KEY);
assertThat(result)
.isEqualTo(mContext.getText(R.string.accessibility_feature_state_off));
.isEqualTo(mContext.getText(R.string.off));
}
@Test
@@ -98,7 +98,7 @@ public final class AccessibilityUtilTest {
final CharSequence result = AccessibilityUtil.getSummary(mContext, SECURE_TEST_KEY);
assertThat(result)
.isEqualTo(mContext.getText(R.string.accessibility_feature_state_off));
.isEqualTo(mContext.getText(R.string.off));
}
@Test

View File

@@ -55,7 +55,7 @@ public class AutoclickPreferenceControllerTest {
Settings.Secure.ACCESSIBILITY_AUTOCLICK_ENABLED, 0);
assertThat(mController.getSummary())
.isEqualTo(mContext.getText(R.string.accessibility_feature_state_off));
.isEqualTo(mContext.getText(R.string.off));
}
@Test

View File

@@ -58,7 +58,7 @@ public class CaptioningPreferenceControllerTest {
Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, ON);
assertThat(mController.getSummary()).isEqualTo(
mContext.getText(R.string.accessibility_feature_state_on));
mContext.getText(R.string.on));
}
@Test
@@ -67,6 +67,6 @@ public class CaptioningPreferenceControllerTest {
Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
assertThat(mController.getSummary()).isEqualTo(
mContext.getText(R.string.accessibility_feature_state_off));
mContext.getText(R.string.off));
}
}

View File

@@ -52,7 +52,7 @@ public class ColorInversionPreferenceControllerTest {
DISPLAY_INVERSION_ENABLED, State.ON);
assertThat(mController.getSummary().toString().contains(
mContext.getText(R.string.accessibility_feature_state_on))).isTrue();
mContext.getText(R.string.on))).isTrue();
}
@Test
@@ -61,7 +61,7 @@ public class ColorInversionPreferenceControllerTest {
DISPLAY_INVERSION_ENABLED, State.OFF);
assertThat(mController.getSummary().toString().contains(
mContext.getText(R.string.accessibility_feature_state_off))).isTrue();
mContext.getText(R.string.off))).isTrue();
}
@Retention(RetentionPolicy.SOURCE)

View File

@@ -50,7 +50,7 @@ public class DaltonizerPreferenceControllerTest {
Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, ON);
assertThat(mController.getSummary().toString().contains(
mContext.getText(R.string.accessibility_feature_state_on))).isTrue();
mContext.getText(R.string.on))).isTrue();
}
@Test
@@ -59,6 +59,6 @@ public class DaltonizerPreferenceControllerTest {
Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, OFF);
assertThat(mController.getSummary().toString().contains(
mContext.getText(R.string.accessibility_feature_state_off))).isTrue();
mContext.getText(R.string.off))).isTrue();
}
}

View File

@@ -64,13 +64,13 @@ public class MagnificationGesturesPreferenceControllerTest {
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, ON);
mController.updateState(mPreference);
assertThat(mPreference.getSummary())
.isEqualTo(mContext.getString(R.string.accessibility_feature_state_on));
.isEqualTo(mContext.getString(R.string.on));
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, OFF);
mController.updateState(mPreference);
assertThat(mPreference.getSummary())
.isEqualTo(mContext.getString(R.string.accessibility_feature_state_off));
.isEqualTo(mContext.getString(R.string.off));
}
@Test

View File

@@ -89,13 +89,13 @@ public class MagnificationNavbarPreferenceControllerTest {
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, ON);
mController.updateState(mPreference);
assertThat(mPreference.getSummary())
.isEqualTo(mContext.getText(R.string.accessibility_feature_state_on));
.isEqualTo(mContext.getText(R.string.on));
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, OFF);
mController.updateState(mPreference);
assertThat(mPreference.getSummary())
.isEqualTo(mContext.getText(R.string.accessibility_feature_state_off));
.isEqualTo(mContext.getText(R.string.off));
}
@Test

View File

@@ -92,7 +92,7 @@ public class VibrationPreferenceControllerTest {
controller.updateState(mPreference);
assertThat(mPreference.getSummary().toString()).isEqualTo(
mContext.getString(R.string.accessibility_vibration_settings_state_on));
mContext.getString(R.string.on));
}
@Test
@@ -103,7 +103,7 @@ public class VibrationPreferenceControllerTest {
controller.updateState(mPreference);
assertThat(mPreference.getSummary().toString()).isEqualTo(
mContext.getString(R.string.accessibility_vibration_settings_state_on));
mContext.getString(R.string.on));
}
@Test
@@ -114,7 +114,7 @@ public class VibrationPreferenceControllerTest {
controller.updateState(mPreference);
assertThat(mPreference.getSummary().toString()).isEqualTo(
mContext.getString(R.string.accessibility_vibration_settings_state_off));
mContext.getString(R.string.off));
}
private VibrationPreferenceController createPreferenceController() {

View File

@@ -73,7 +73,7 @@ public class BackupDataPreferenceControllerTest {
mController.updateState(mPreference);
assertThat(mPreference.getSummary())
.isEqualTo(mContext.getString(R.string.accessibility_feature_state_on));
.isEqualTo(mContext.getString(R.string.on));
}
@Test
@@ -83,7 +83,7 @@ public class BackupDataPreferenceControllerTest {
mController.updateState(mPreference);
assertThat(mPreference.getSummary())
.isEqualTo(mContext.getString(R.string.accessibility_feature_state_off));
.isEqualTo(mContext.getString(R.string.off));
}
@Test

View File

@@ -90,7 +90,7 @@ public class BackupSettingsHelperTest {
String backupSummary = mBackupSettingsHelper.getSummary();
assertThat(backupSummary).isEqualTo(mContext.getString(R.string.backup_summary_state_on));
assertThat(backupSummary).isEqualTo(mContext.getString(R.string.on));
}
@Test
@@ -100,7 +100,7 @@ public class BackupSettingsHelperTest {
String backupSummary = mBackupSettingsHelper.getSummary();
assertThat(backupSummary).isEqualTo(mContext.getString(R.string.backup_summary_state_off));
assertThat(backupSummary).isEqualTo(mContext.getString(R.string.off));
}
@Test

View File

@@ -132,7 +132,7 @@ public class BluetoothSummaryUpdaterTest {
mSummaryUpdater.onBluetoothStateChanged(BluetoothAdapter.STATE_OFF);
verify(mListener).onSummaryChanged(mContext.getString(R.string.bluetooth_disabled));
verify(mListener).onSummaryChanged(mContext.getString(R.string.off));
}
@Test
@@ -197,12 +197,12 @@ public class BluetoothSummaryUpdaterTest {
mShadowBluetoothAdapter.setEnabled(false);
mSummaryUpdater.onBluetoothStateChanged(BluetoothAdapter.STATE_OFF);
verify(mListener).onSummaryChanged(mContext.getString(R.string.bluetooth_disabled));
verify(mListener).onSummaryChanged(mContext.getString(R.string.off));
// Turning ON means not enabled
mSummaryUpdater.onBluetoothStateChanged(BluetoothAdapter.STATE_TURNING_ON);
// There should still be only one invocation of disabled message
verify(mListener).onSummaryChanged(mContext.getString(R.string.bluetooth_disabled));
verify(mListener).onSummaryChanged(mContext.getString(R.string.off));
mShadowBluetoothAdapter.setEnabled(true);
mDeviceConnected[0] = false;

View File

@@ -92,13 +92,13 @@ public class NfcAndPaymentFragmentControllerTest {
public void getSummary_nfcOn_shouldProvideOnSummary() {
mShadowNfcAdapter.setEnabled(true);
assertThat(mController.getSummary().toString()).contains(
mContext.getString(R.string.switch_on_text));
mContext.getString(R.string.on));
}
@Test
public void getSummary_nfcOff_shouldProvideOffSummary() {
mShadowNfcAdapter.setEnabled(false);
assertThat(mController.getSummary().toString()).contains(
mContext.getString(R.string.switch_off_text));
mContext.getString(R.string.off));
}
}

View File

@@ -109,7 +109,7 @@ public class AutoBrightnessPreferenceControllerTest {
mController.setChecked(true);
assertThat(mController.getSummary())
.isEqualTo(mContext.getText(R.string.auto_brightness_summary_on));
.isEqualTo(mContext.getText(R.string.on));
}
@Test
@@ -117,7 +117,7 @@ public class AutoBrightnessPreferenceControllerTest {
mController.setChecked(false);
assertThat(mController.getSummary())
.isEqualTo(mContext.getText(R.string.auto_brightness_summary_off));
.isEqualTo(mContext.getText(R.string.off));
}
@Test

View File

@@ -83,9 +83,9 @@ public class SmartAutoRotatePreferenceControllerTest {
doReturn(PACKAGE_NAME).when(mPackageManager).getRotationResolverPackageName();
doReturn(PackageManager.PERMISSION_GRANTED).when(mPackageManager).checkPermission(
Manifest.permission.CAMERA, PACKAGE_NAME);
when(mContext.getString(R.string.auto_rotate_option_off))
when(mContext.getString(R.string.off))
.thenReturn("Off");
when(mContext.getString(R.string.auto_rotate_option_on))
when(mContext.getString(R.string.on))
.thenReturn("On");
when(mContext.getString(R.string.auto_rotate_option_face_based))
.thenReturn("On - Face-based");

View File

@@ -29,10 +29,10 @@ import com.android.settingslib.dream.DreamBackend.WhenToDream;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import java.util.Arrays;
import java.util.List;
import org.robolectric.RobolectricTestRunner;
@RunWith(RobolectricTestRunner.class)
public class DreamSettingsTest {
@@ -96,7 +96,7 @@ public class DreamSettingsTest {
when(mockBackend.isEnabled()).thenReturn(false);
assertThat(DreamSettings.getSummaryTextFromBackend(mockBackend, mockContext))
.isEqualTo(mockContext.getString(R.string.screensaver_settings_summary_off));
.isEqualTo(mockContext.getString(R.string.off));
}
@Test

View File

@@ -67,7 +67,7 @@ public class OneHandedEnablePreferenceControllerTest {
OneHandedSettingsUtils.setOneHandedModeEnabled(mContext, true);
assertThat(mController.getSummary())
.isEqualTo(mContext.getText(R.string.switch_on_text));
.isEqualTo(mContext.getText(R.string.on));
}
@Test
@@ -75,6 +75,6 @@ public class OneHandedEnablePreferenceControllerTest {
OneHandedSettingsUtils.setOneHandedModeEnabled(mContext, false);
assertThat(mController.getSummary())
.isEqualTo(mContext.getText(R.string.switch_off_text));
.isEqualTo(mContext.getText(R.string.off));
}
}

View File

@@ -137,7 +137,7 @@ public class PreventRingingParentPreferenceControllerTest {
VOLUME_HUSH_OFF);
mController.updateState(mPreference);
assertThat(mPreference.getSummary()).isEqualTo(mContext.getResources().getText(
R.string.switch_off_text));
R.string.off));
}
@Test

View File

@@ -97,7 +97,7 @@ public class SpellCheckerPreferenceControllerTest {
mController.updateState(mPreference);
assertThat(mPreference.getSummary())
.isEqualTo(mAppContext.getString(R.string.switch_off_text));
.isEqualTo(mAppContext.getString(R.string.off));
}
@Test

View File

@@ -97,7 +97,7 @@ public class LocationForWorkPreferenceControllerTest {
verify(mUserManager)
.setUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, false, mUserHandle);
verify(mPreference).setSummary(R.string.switch_on_text);
verify(mPreference).setSummary(R.string.on);
}
@Test
@@ -109,7 +109,7 @@ public class LocationForWorkPreferenceControllerTest {
verify(mUserManager)
.setUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, true, mUserHandle);
verify(mPreference).setSummary(R.string.switch_off_text);
verify(mPreference).setSummary(R.string.off);
}
@Test
@@ -147,7 +147,7 @@ public class LocationForWorkPreferenceControllerTest {
mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, false);
verify(mPreference).setEnabled(true);
verify(mPreference).setSummary(R.string.switch_on_text);
verify(mPreference).setSummary(R.string.on);
}
@Test

View File

@@ -52,7 +52,7 @@ public class TopLevelLocationPreferenceControllerTest {
public void getSummary_whenLocationIsOff_shouldReturnStringForOff() {
mLocationManager.setLocationEnabledForUser(false, android.os.Process.myUserHandle());
assertThat(mController.getSummary()).isEqualTo(
mContext.getString(R.string.location_settings_summary_location_off));
mContext.getString(R.string.off));
}
@Test

View File

@@ -74,7 +74,7 @@ public class AdaptiveConnectivityPreferenceControllerTest {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.ADAPTIVE_CONNECTIVITY_ENABLED, 1);
assertThat(mController.getSummary()).isEqualTo(mContext.getString(R.string.switch_on_text));
assertThat(mController.getSummary()).isEqualTo(mContext.getString(R.string.on));
}
@Test
@@ -83,6 +83,6 @@ public class AdaptiveConnectivityPreferenceControllerTest {
Settings.Secure.ADAPTIVE_CONNECTIVITY_ENABLED, 0);
assertThat(mController.getSummary())
.isEqualTo(mContext.getString(R.string.switch_off_text));
.isEqualTo(mContext.getString(R.string.off));
}
}

View File

@@ -224,7 +224,7 @@ public class PrivateDnsPreferenceControllerTest {
when(lp.getValidatedPrivateDnsServers()).thenReturn(NON_EMPTY_ADDRESS_LIST);
updateLinkProperties(lp);
mController.updateState(mPreference);
verify(mPreference).setSummary(getResourceString(R.string.private_dns_mode_on));
verify(mPreference).setSummary(getResourceString(R.string.on));
reset(mPreference);
lp = mock(LinkProperties.class);

View File

@@ -139,7 +139,7 @@ public class TetherPreferenceControllerTest {
when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{"456"});
mController.updateSummary();
verify(mPreference).setSummary(R.string.switch_off_text);
verify(mPreference).setSummary(R.string.off);
}
@Test
@@ -169,7 +169,7 @@ public class TetherPreferenceControllerTest {
ReflectionHelpers.getField(mController, "mAirplaneModeObserver");
observer.onChange(true, Settings.Global.getUriFor(Settings.Global.AIRPLANE_MODE_ON));
verify(mPreference).setSummary(R.string.switch_off_text);
verify(mPreference).setSummary(R.string.off);
}
@Test

View File

@@ -144,7 +144,7 @@ public class PrintSettingsPreferenceControllerTest {
mController.updateState(mPreference);
assertThat(mPreference.getSummary())
.isEqualTo(mContext.getString(R.string.print_settings_summary_no_service));
.isEqualTo(mContext.getString(R.string.off));
}
@Test

View File

@@ -76,7 +76,7 @@ public class ScreenPinningPreferenceControllerTest {
mController.updateState(mPreference);
assertThat(mPreference.getSummary())
.isEqualTo(mContext.getString(R.string.switch_off_text));
.isEqualTo(mContext.getString(R.string.off));
}
@Test
@@ -87,7 +87,7 @@ public class ScreenPinningPreferenceControllerTest {
mController.updateState(mPreference);
assertThat(mPreference.getSummary())
.isEqualTo(mContext.getString(R.string.switch_on_text));
.isEqualTo(mContext.getString(R.string.on));
}
@Test

View File

@@ -55,8 +55,8 @@ public class SwitchBarTest {
@Test
public void cycleChecked_defaultLabel_shouldUpdateTextAndBackground() {
final int defaultOnText = R.string.switch_on_text;
final int defaultOffText = R.string.switch_off_text;
final int defaultOnText = R.string.on;
final int defaultOffText = R.string.off;
assertThat(((TextView) mBar.findViewById(R.id.switch_text)).getText())
.isEqualTo(mContext.getString(defaultOffText));

View File

@@ -110,7 +110,7 @@ public class WifiSummaryUpdaterTest {
mWifiTracker.enabled = false;
assertThat(mSummaryUpdater.getSummary())
.isEqualTo(mContext.getString(R.string.switch_off_text));
.isEqualTo(mContext.getString(R.string.off));
}
@Test