Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 18985e08 authored by Jason Monk's avatar Jason Monk
Browse files

Fix SysUI tests to pass.

Most were fixed by including the correct subscription id in the
broadcast.

The last was testing based on SIM card state which is not something
the MobileSignalControllers track anymore so I just pulled it out
completely.

Change-Id: Ie52068a3c8f8652f1b0641e6376696aeddda26a2
parent ef15d3cf
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -57,7 +57,6 @@ public class MobileSignalController extends SignalController<
    // Since some pieces of the phone state are interdependent we store it locally,
    // this could potentially become part of MobileState for simplification/complication
    // of code.
    private IccCardConstants.State mSimState = IccCardConstants.State.READY;
    private int mDataNetType = TelephonyManager.NETWORK_TYPE_UNKNOWN;
    private int mDataState = TelephonyManager.DATA_DISCONNECTED;
    private ServiceState mServiceState;
@@ -146,11 +145,6 @@ public class MobileSignalController extends SignalController<
        return getIcons().mDataContentDescription;
    }

    @VisibleForTesting
    protected IccCardConstants.State getSimState() {
        return mSimState;
    }

    public void setAirplaneMode(boolean airplaneMode) {
        mCurrentState.airplaneMode = airplaneMode;
        notifyListenersIfNecessary();
+5 −7
Original line number Diff line number Diff line
@@ -69,6 +69,8 @@ public class NetworkControllerBaseTest extends AndroidTestCase {
    protected TelephonyManager mMockTm;
    protected Config mConfig;

    protected int mSubId;

    private NetworkCapabilities mNetCapabilities;

    @Override
@@ -100,13 +102,13 @@ public class NetworkControllerBaseTest extends AndroidTestCase {

    protected void setupNetworkController() {
        // For now just pretend to be the data sim, so we can test that too.
        final int subId = SubscriptionManager.getDefaultDataSubId();
        mSubId = SubscriptionManager.getDefaultDataSubId();
        SubscriptionInfo subscription = mock(SubscriptionInfo.class);
        List<SubscriptionInfo> subs = new ArrayList<SubscriptionInfo>();
        when(subscription.getSubscriptionId()).thenReturn(subId);
        when(subscription.getSubscriptionId()).thenReturn(mSubId);
        subs.add(subscription);
        mNetworkController.setCurrentSubscriptions(subs);
        mMobileSignalController = mNetworkController.mMobileSignalControllers.get(subId);
        mMobileSignalController = mNetworkController.mMobileSignalControllers.get(mSubId);
        mPhoneStateListener = mMobileSignalController.mPhoneStateListener;
        mSignalCluster = mock(SignalCluster.class);
        mNetworkSignalChangedCallback = mock(NetworkSignalChangedCallback.class);
@@ -291,10 +293,6 @@ public class NetworkControllerBaseTest extends AndroidTestCase {
        assertEquals("Visibility in status bar", visible, (boolean) visibleArg.getValue());
    }

   protected void assertSimStateEquals(IccCardConstants.State expected) {
       assertEquals("Sim state", expected, mMobileSignalController.getSimState());
   }

   protected void assertNetworkNameEquals(String expected) {
       assertEquals("Network name", expected, mNetworkController.getMobileNetworkName());
   }
+2 −10
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.telephony.SubscriptionInfo;
import android.telephony.TelephonyManager;

import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.systemui.R;

@@ -254,16 +255,6 @@ public class NetworkControllerSignalTest extends NetworkControllerBaseTest {
        setCdmaRoaming(false);
    }

    public void testOnReceive_updateSimState_noSim() {
        Intent intent = new Intent();
        intent.setAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
        intent.putExtra(IccCardConstants.INTENT_KEY_ICC_STATE, IccCardConstants.INTENT_VALUE_ICC_ABSENT);

        mNetworkController.onReceive(mContext, intent);

        assertSimStateEquals(IccCardConstants.State.ABSENT);
    }

    public void testOnReceive_stringsUpdatedAction_spn() {
        String expectedMNetworkName = "Test";
        Intent intent = createStringsUpdatedIntent(true /* showSpn */,
@@ -344,6 +335,7 @@ public class NetworkControllerSignalTest extends NetworkControllerBaseTest {

        intent.putExtra(TelephonyIntents.EXTRA_SHOW_PLMN, showPlmn);
        intent.putExtra(TelephonyIntents.EXTRA_PLMN, plmn);
        intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, mSubId);

        return intent;
    }