Fix failing test cases in MobileNetworkSummaryControllerTest

- Remove obsolete test items

- Update the new callback interface

Bug: 280044539
Bug: 280044731
Test: Manual test
atest -c MobileNetworkSummaryControllerTest

Change-Id: I8460c620c62981dd5ee3b280c1a7467c43dbceb1
This commit is contained in:
Weng Su
2023-05-11 21:53:26 +08:00
parent 86f145d22a
commit e485615662

View File

@@ -133,18 +133,12 @@ public class MobileNetworkSummaryControllerTest {
assertThat(mController.isAvailable()).isFalse(); assertThat(mController.isAvailable()).isFalse();
} }
@Ignore
@Test @Test
public void getSummary_noSubscriptions_correctSummaryAndClickHandler() { public void getSummary_noSubscriptions_returnSummaryCorrectly() {
mController.displayPreference(mPreferenceScreen); mController.displayPreference(mPreferenceScreen);
mController.onResume(); mController.onResume();
assertThat(mController.getSummary()).isEqualTo("Add a network");
final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class); assertThat(mController.getSummary()).isEqualTo("Add a network");
doNothing().when(mContext).startActivity(intentCaptor.capture());
mPreference.getOnPreferenceClickListener().onPreferenceClick(mPreference);
assertThat(intentCaptor.getValue().getAction()).isEqualTo(
EuiccManager.ACTION_PROVISION_EMBEDDED_SUBSCRIPTION);
} }
@Test @Test
@@ -300,15 +294,13 @@ public class MobileNetworkSummaryControllerTest {
assertThat(captor.getValue()).isFalse(); assertThat(captor.getValue()).isFalse();
} }
@Ignore
@Test @Test
public void onResume_noSubscriptionEsimDisabled_isDisabled() { public void onAvailableSubInfoChanged_noSubscriptionEsimDisabled_isDisabled() {
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0); Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0);
SubscriptionUtil.setAvailableSubscriptionsForTesting(null);
when(mEuiccManager.isEnabled()).thenReturn(false); when(mEuiccManager.isEnabled()).thenReturn(false);
mController.displayPreference(mPreferenceScreen); mController.displayPreference(mPreferenceScreen);
mController.onResume(); mController.onAvailableSubInfoChanged(null);
assertThat(mPreference.isEnabled()).isFalse(); assertThat(mPreference.isEnabled()).isFalse();
} }