Merge "Hide "Phone number" from About page if not call enabled."

This commit is contained in:
TreeHugger Robot
2018-02-01 21:08:51 +00:00
committed by Android (Google) Code Review
2 changed files with 18 additions and 1 deletions

View File

@@ -58,7 +58,7 @@ public class PhoneNumberPreferenceController extends AbstractPreferenceControlle
@Override @Override
public boolean isAvailable() { public boolean isAvailable() {
return true; return mTelephonyManager.isVoiceCapable();
} }
@Override @Override

View File

@@ -16,6 +16,9 @@
package com.android.settings.deviceinfo; package com.android.settings.deviceinfo;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
@@ -73,6 +76,20 @@ public class PhoneNumberPreferenceControllerTest {
when(mPreference.isVisible()).thenReturn(true); when(mPreference.isVisible()).thenReturn(true);
} }
@Test
public void isAvailable_shouldBeTrueIfCallCapable() {
when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
assertTrue(mController.isAvailable());
}
@Test
public void isAvailable_shouldBeFalseIfNotCallCapable() {
when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
assertFalse(mController.isAvailable());
}
@Test @Test
public void displayPreference_multiSim_shouldAddSecondPreference() { public void displayPreference_multiSim_shouldAddSecondPreference() {
when(mTelephonyManager.getPhoneCount()).thenReturn(2); when(mTelephonyManager.getPhoneCount()).thenReturn(2);