Merge "Support getDynamicSummary in BasePreferenceController"

This commit is contained in:
TreeHugger Robot
2018-01-05 00:02:48 +00:00
committed by Android (Google) Code Review
14 changed files with 94 additions and 62 deletions

View File

@@ -96,8 +96,8 @@ public class DefaultAppShortcutPreferenceControllerBaseTest {
mController.isDefault = true;
mController.updateState(mPreference);
verify(mPreference).setSummary(R.string.yes);
String yesString = mContext.getString(R.string.yes);
verify(mPreference).setSummary(yesString);
}
@Test
@@ -106,7 +106,8 @@ public class DefaultAppShortcutPreferenceControllerBaseTest {
mController.updateState(mPreference);
verify(mPreference).setSummary(R.string.no);
String noString = mContext.getString(R.string.no);
verify(mPreference).setSummary(noString);
}
@Test

View File

@@ -77,8 +77,8 @@ public class BackupSettingsActivityPreferenceControllerTest {
mBackupEnabled = true;
mController.updateState(mBackupPreference);
verify(mBackupPreference).setSummary(R.string.accessibility_feature_state_on);
String summaryString = mContext.getString(R.string.accessibility_feature_state_on);
verify(mBackupPreference).setSummary(summaryString);
}
@Test
@@ -86,8 +86,8 @@ public class BackupSettingsActivityPreferenceControllerTest {
mBackupEnabled = false;
mController.updateState(mBackupPreference);
verify(mBackupPreference).setSummary(R.string.accessibility_feature_state_off);
String summaryString = mContext.getString(R.string.accessibility_feature_state_off);
verify(mBackupPreference).setSummary(summaryString);
}
@Test

View File

@@ -63,13 +63,14 @@ public class BluetoothDeviceNamePreferenceControllerTest {
doReturn(mContext).when(mPreferenceScreen).getContext();
mPreference = new Preference(mContext);
mPreference.setKey(BluetoothDeviceNamePreferenceController.KEY_DEVICE_NAME);
mController = new BluetoothDeviceNamePreferenceController(
mContext, mLocalAdapter);
mController = spy(new BluetoothDeviceNamePreferenceController(
mContext, mLocalAdapter));
doReturn(DEVICE_NAME).when(mController).getDeviceName();
}
@Test
public void testUpdateDeviceName_showSummaryWithDeviceName() {
mController.updateDeviceName(mPreference, DEVICE_NAME);
mController.updateDeviceName(mPreference);
final CharSequence summary = mPreference.getSummary();

View File

@@ -19,6 +19,7 @@ package com.android.settings.bluetooth;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -69,13 +70,14 @@ public class BluetoothDeviceRenamePreferenceControllerTest {
mPreference = new Preference(mContext);
mPreference.setKey(PREF_KEY);
mController = new BluetoothDeviceRenamePreferenceController(
mContext, PREF_KEY, mFragment, mLocalAdapter);
mController = spy(new BluetoothDeviceRenamePreferenceController(
mContext, PREF_KEY, mFragment, mLocalAdapter));
doReturn(DEVICE_NAME).when(mController).getDeviceName();
}
@Test
public void testUpdateDeviceName_showSummaryWithDeviceName() {
mController.updateDeviceName(mPreference, DEVICE_NAME);
mController.updateDeviceName(mPreference);
final CharSequence summary = mPreference.getSummary();