Loading tests/unit/src/com/android/settings/network/telephony/satellite/SatelliteSettingFooterControllerTest.java +50 −41 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import static com.android.settings.network.telephony.satellite.SatelliteSettingF import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.Context; Loading @@ -40,9 +41,9 @@ import com.android.settings.testutils.ResourcesUtils; import com.android.settingslib.widget.FooterPreference; import org.junit.Before; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; Loading @@ -56,6 +57,8 @@ public class SatelliteSettingFooterControllerTest { @Mock private TelephonyManager mTelephonyManager; @Mock FooterPreference mFooterPreference; private Context mContext; private SatelliteSettingFooterController mController; Loading @@ -77,58 +80,64 @@ public class SatelliteSettingFooterControllerTest { @Test public void displayPreferenceScreen_updateContent_hasBasicContent() { PreferenceScreen screen = new PreferenceManager(mContext).createPreferenceScreen(mContext); FooterPreference preference = new FooterPreference(mContext); preference.setKey(KEY_FOOTER_PREFERENCE); screen.addPreference(preference); when(mFooterPreference.getKey()).thenReturn(KEY_FOOTER_PREFERENCE); screen.addPreference(mFooterPreference); mController.init(TEST_SUB_ID, mPersistableBundle); mController.displayPreference(screen); String summary = preference.getSummary().toString(); assertThat(summary.contains(ResourcesUtils.getResourcesString(mContext, ArgumentCaptor<CharSequence> summary = ArgumentCaptor.forClass(CharSequence.class); verify(mFooterPreference).setSummary(summary.capture()); assertThat( summary.getValue().toString().contains(ResourcesUtils.getResourcesString(mContext, "satellite_footer_content_section_0"))).isTrue(); assertThat(summary.contains(ResourcesUtils.getResourcesString(mContext, assertThat( summary.getValue().toString().contains(ResourcesUtils.getResourcesString(mContext, "satellite_footer_content_section_1"))).isTrue(); assertThat(summary.contains(ResourcesUtils.getResourcesString(mContext, assertThat( summary.getValue().toString().contains(ResourcesUtils.getResourcesString(mContext, "satellite_footer_content_section_2"))).isTrue(); assertThat(summary.contains(ResourcesUtils.getResourcesString(mContext, assertThat( summary.getValue().toString().contains(ResourcesUtils.getResourcesString(mContext, "satellite_footer_content_section_3"))).isTrue(); assertThat(summary.contains(ResourcesUtils.getResourcesString(mContext, assertThat( summary.getValue().toString().contains(ResourcesUtils.getResourcesString(mContext, "satellite_footer_content_section_4"))).isTrue(); assertThat(summary.contains(ResourcesUtils.getResourcesString(mContext, assertThat( summary.getValue().toString().contains(ResourcesUtils.getResourcesString(mContext, "satellite_footer_content_section_5"))).isTrue(); } @Test public void displayPreferenceScreen_noEmergencyMsgSupport_hasEmergencyContent() { mPersistableBundle.putBoolean(KEY_EMERGENCY_MESSAGING_SUPPORTED_BOOL, false); PreferenceScreen screen = new PreferenceManager(mContext).createPreferenceScreen(mContext); FooterPreference preference = new FooterPreference(mContext); preference.setKey(KEY_FOOTER_PREFERENCE); screen.addPreference(preference); when(mFooterPreference.getKey()).thenReturn(KEY_FOOTER_PREFERENCE); screen.addPreference(mFooterPreference); mController.init(TEST_SUB_ID, mPersistableBundle); mController.displayPreference(screen); String summary = preference.getSummary().toString(); assertThat(summary.contains(ResourcesUtils.getResourcesString(mContext, ArgumentCaptor<CharSequence> summary = ArgumentCaptor.forClass(CharSequence.class); verify(mFooterPreference).setSummary(summary.capture()); assertThat( summary.getValue().toString().contains(ResourcesUtils.getResourcesString(mContext, "satellite_footer_content_section_6"))).isTrue(); } @Test @Ignore("b/405279842") public void displayPreferenceScreen_emergencyMsgSupport_noEmergencyContent() { mPersistableBundle.putBoolean(KEY_EMERGENCY_MESSAGING_SUPPORTED_BOOL, true); PreferenceScreen screen = new PreferenceManager(mContext).createPreferenceScreen(mContext); FooterPreference preference = new FooterPreference(mContext); preference.setKey(KEY_FOOTER_PREFERENCE); screen.addPreference(preference); when(mFooterPreference.getKey()).thenReturn(KEY_FOOTER_PREFERENCE); screen.addPreference(mFooterPreference); mController.init(TEST_SUB_ID, mPersistableBundle); mController.displayPreference(screen); String summary = preference.getSummary().toString(); assertThat(summary.contains(ResourcesUtils.getResourcesString(mContext, ArgumentCaptor<CharSequence> summary = ArgumentCaptor.forClass(CharSequence.class); verify(mFooterPreference).setSummary(summary.capture()); assertThat(summary.toString().contains(ResourcesUtils.getResourcesString(mContext, "satellite_footer_content_section_6"))).isFalse(); } Loading @@ -136,29 +145,29 @@ public class SatelliteSettingFooterControllerTest { public void displayPreferenceScreen_entitlementSupport_hasEntitlementContent() { mPersistableBundle.putBoolean(KEY_SATELLITE_ENTITLEMENT_SUPPORTED_BOOL, true); PreferenceScreen screen = new PreferenceManager(mContext).createPreferenceScreen(mContext); FooterPreference preference = new FooterPreference(mContext); preference.setKey(KEY_FOOTER_PREFERENCE); screen.addPreference(preference); when(mFooterPreference.getKey()).thenReturn(KEY_FOOTER_PREFERENCE); screen.addPreference(mFooterPreference); mController.init(TEST_SUB_ID, mPersistableBundle); mController.displayPreference(screen); String summary = preference.getSummary().toString(); assertThat(summary.contains(TEST_OPERATOR_NAME)).isTrue(); ArgumentCaptor<CharSequence> summary = ArgumentCaptor.forClass(CharSequence.class); verify(mFooterPreference).setSummary(summary.capture()); assertThat(summary.getValue().toString().contains(TEST_OPERATOR_NAME)).isTrue(); } @Test public void displayPreferenceScreen_entitlementNotSupport_noEntitlementContent() { mPersistableBundle.putBoolean(KEY_SATELLITE_ENTITLEMENT_SUPPORTED_BOOL, false); PreferenceScreen screen = new PreferenceManager(mContext).createPreferenceScreen(mContext); FooterPreference preference = new FooterPreference(mContext); preference.setKey(KEY_FOOTER_PREFERENCE); screen.addPreference(preference); when(mFooterPreference.getKey()).thenReturn(KEY_FOOTER_PREFERENCE); screen.addPreference(mFooterPreference); mController.init(TEST_SUB_ID, mPersistableBundle); mController.displayPreference(screen); String summary = preference.getSummary().toString(); assertThat(summary.contains(TEST_OPERATOR_NAME)).isFalse(); ArgumentCaptor<CharSequence> summary = ArgumentCaptor.forClass(CharSequence.class); verify(mFooterPreference).setSummary(summary.capture()); assertThat(summary.getValue().toString().contains(TEST_OPERATOR_NAME)).isFalse(); } } Loading
tests/unit/src/com/android/settings/network/telephony/satellite/SatelliteSettingFooterControllerTest.java +50 −41 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import static com.android.settings.network.telephony.satellite.SatelliteSettingF import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.Context; Loading @@ -40,9 +41,9 @@ import com.android.settings.testutils.ResourcesUtils; import com.android.settingslib.widget.FooterPreference; import org.junit.Before; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; Loading @@ -56,6 +57,8 @@ public class SatelliteSettingFooterControllerTest { @Mock private TelephonyManager mTelephonyManager; @Mock FooterPreference mFooterPreference; private Context mContext; private SatelliteSettingFooterController mController; Loading @@ -77,58 +80,64 @@ public class SatelliteSettingFooterControllerTest { @Test public void displayPreferenceScreen_updateContent_hasBasicContent() { PreferenceScreen screen = new PreferenceManager(mContext).createPreferenceScreen(mContext); FooterPreference preference = new FooterPreference(mContext); preference.setKey(KEY_FOOTER_PREFERENCE); screen.addPreference(preference); when(mFooterPreference.getKey()).thenReturn(KEY_FOOTER_PREFERENCE); screen.addPreference(mFooterPreference); mController.init(TEST_SUB_ID, mPersistableBundle); mController.displayPreference(screen); String summary = preference.getSummary().toString(); assertThat(summary.contains(ResourcesUtils.getResourcesString(mContext, ArgumentCaptor<CharSequence> summary = ArgumentCaptor.forClass(CharSequence.class); verify(mFooterPreference).setSummary(summary.capture()); assertThat( summary.getValue().toString().contains(ResourcesUtils.getResourcesString(mContext, "satellite_footer_content_section_0"))).isTrue(); assertThat(summary.contains(ResourcesUtils.getResourcesString(mContext, assertThat( summary.getValue().toString().contains(ResourcesUtils.getResourcesString(mContext, "satellite_footer_content_section_1"))).isTrue(); assertThat(summary.contains(ResourcesUtils.getResourcesString(mContext, assertThat( summary.getValue().toString().contains(ResourcesUtils.getResourcesString(mContext, "satellite_footer_content_section_2"))).isTrue(); assertThat(summary.contains(ResourcesUtils.getResourcesString(mContext, assertThat( summary.getValue().toString().contains(ResourcesUtils.getResourcesString(mContext, "satellite_footer_content_section_3"))).isTrue(); assertThat(summary.contains(ResourcesUtils.getResourcesString(mContext, assertThat( summary.getValue().toString().contains(ResourcesUtils.getResourcesString(mContext, "satellite_footer_content_section_4"))).isTrue(); assertThat(summary.contains(ResourcesUtils.getResourcesString(mContext, assertThat( summary.getValue().toString().contains(ResourcesUtils.getResourcesString(mContext, "satellite_footer_content_section_5"))).isTrue(); } @Test public void displayPreferenceScreen_noEmergencyMsgSupport_hasEmergencyContent() { mPersistableBundle.putBoolean(KEY_EMERGENCY_MESSAGING_SUPPORTED_BOOL, false); PreferenceScreen screen = new PreferenceManager(mContext).createPreferenceScreen(mContext); FooterPreference preference = new FooterPreference(mContext); preference.setKey(KEY_FOOTER_PREFERENCE); screen.addPreference(preference); when(mFooterPreference.getKey()).thenReturn(KEY_FOOTER_PREFERENCE); screen.addPreference(mFooterPreference); mController.init(TEST_SUB_ID, mPersistableBundle); mController.displayPreference(screen); String summary = preference.getSummary().toString(); assertThat(summary.contains(ResourcesUtils.getResourcesString(mContext, ArgumentCaptor<CharSequence> summary = ArgumentCaptor.forClass(CharSequence.class); verify(mFooterPreference).setSummary(summary.capture()); assertThat( summary.getValue().toString().contains(ResourcesUtils.getResourcesString(mContext, "satellite_footer_content_section_6"))).isTrue(); } @Test @Ignore("b/405279842") public void displayPreferenceScreen_emergencyMsgSupport_noEmergencyContent() { mPersistableBundle.putBoolean(KEY_EMERGENCY_MESSAGING_SUPPORTED_BOOL, true); PreferenceScreen screen = new PreferenceManager(mContext).createPreferenceScreen(mContext); FooterPreference preference = new FooterPreference(mContext); preference.setKey(KEY_FOOTER_PREFERENCE); screen.addPreference(preference); when(mFooterPreference.getKey()).thenReturn(KEY_FOOTER_PREFERENCE); screen.addPreference(mFooterPreference); mController.init(TEST_SUB_ID, mPersistableBundle); mController.displayPreference(screen); String summary = preference.getSummary().toString(); assertThat(summary.contains(ResourcesUtils.getResourcesString(mContext, ArgumentCaptor<CharSequence> summary = ArgumentCaptor.forClass(CharSequence.class); verify(mFooterPreference).setSummary(summary.capture()); assertThat(summary.toString().contains(ResourcesUtils.getResourcesString(mContext, "satellite_footer_content_section_6"))).isFalse(); } Loading @@ -136,29 +145,29 @@ public class SatelliteSettingFooterControllerTest { public void displayPreferenceScreen_entitlementSupport_hasEntitlementContent() { mPersistableBundle.putBoolean(KEY_SATELLITE_ENTITLEMENT_SUPPORTED_BOOL, true); PreferenceScreen screen = new PreferenceManager(mContext).createPreferenceScreen(mContext); FooterPreference preference = new FooterPreference(mContext); preference.setKey(KEY_FOOTER_PREFERENCE); screen.addPreference(preference); when(mFooterPreference.getKey()).thenReturn(KEY_FOOTER_PREFERENCE); screen.addPreference(mFooterPreference); mController.init(TEST_SUB_ID, mPersistableBundle); mController.displayPreference(screen); String summary = preference.getSummary().toString(); assertThat(summary.contains(TEST_OPERATOR_NAME)).isTrue(); ArgumentCaptor<CharSequence> summary = ArgumentCaptor.forClass(CharSequence.class); verify(mFooterPreference).setSummary(summary.capture()); assertThat(summary.getValue().toString().contains(TEST_OPERATOR_NAME)).isTrue(); } @Test public void displayPreferenceScreen_entitlementNotSupport_noEntitlementContent() { mPersistableBundle.putBoolean(KEY_SATELLITE_ENTITLEMENT_SUPPORTED_BOOL, false); PreferenceScreen screen = new PreferenceManager(mContext).createPreferenceScreen(mContext); FooterPreference preference = new FooterPreference(mContext); preference.setKey(KEY_FOOTER_PREFERENCE); screen.addPreference(preference); when(mFooterPreference.getKey()).thenReturn(KEY_FOOTER_PREFERENCE); screen.addPreference(mFooterPreference); mController.init(TEST_SUB_ID, mPersistableBundle); mController.displayPreference(screen); String summary = preference.getSummary().toString(); assertThat(summary.contains(TEST_OPERATOR_NAME)).isFalse(); ArgumentCaptor<CharSequence> summary = ArgumentCaptor.forClass(CharSequence.class); verify(mFooterPreference).setSummary(summary.capture()); assertThat(summary.getValue().toString().contains(TEST_OPERATOR_NAME)).isFalse(); } }