Merge "When BT is off hide rename preference" into pi-dev

This commit is contained in:
TreeHugger Robot
2018-05-22 17:48:31 +00:00
committed by Android (Google) Code Review
4 changed files with 34 additions and 13 deletions

View File

@@ -70,7 +70,7 @@ public class BluetoothDeviceNamePreferenceControllerTest {
@Test
public void testUpdateDeviceName_showSummaryWithDeviceName() {
mController.updateDeviceName(mPreference);
mController.updatePreferenceState(mPreference);
final CharSequence summary = mPreference.getSummary();

View File

@@ -71,11 +71,13 @@ public class BluetoothDeviceRenamePreferenceControllerTest {
PREF_KEY));
mController.setFragment(mFragment);
doReturn(DEVICE_NAME).when(mController).getDeviceName();
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
mController.displayPreference(mScreen);
}
@Test
public void testUpdateDeviceName_showSummaryWithDeviceName() {
mController.updateDeviceName(mPreference);
mController.updatePreferenceState(mPreference);
final CharSequence summary = mPreference.getSummary();
@@ -94,10 +96,24 @@ public class BluetoothDeviceRenamePreferenceControllerTest {
@Test
public void displayPreference_shouldFindPreferenceWithMatchingPrefKey() {
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
mController.displayPreference(mScreen);
assertThat(mController.mPreference.getKey()).isEqualTo(mController.getPreferenceKey());
}
@Test
public void updatePreferenceState_whenBTisOnPreferenceShouldBeVisible() {
when(mLocalAdapter.isEnabled()).thenReturn(true);
mController.updatePreferenceState(mPreference);
assertThat(mPreference.isVisible()).isTrue();
}
@Test
public void updatePreferenceState_whenBTisOffPreferenceShouldBeHide() {
when(mLocalAdapter.isEnabled()).thenReturn(false);
mController.updatePreferenceState(mPreference);
assertThat(mPreference.isVisible()).isFalse();
}
}