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

Commit e1cbf9ac authored by SongFerng Wang's avatar SongFerng Wang Committed by Android (Google) Code Review
Browse files

Merge "Fix the logic error" into main

parents d368357c deff49b9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -514,7 +514,7 @@ public class InternetDialogDelegateLegacy implements
    }

    private void setMobileDataLayout(InternetContent internetContent) {
        if (!internetContent.mShouldUpdateMobileNetwork && mDialog == null) {
        if (!internetContent.mShouldUpdateMobileNetwork || mDialog == null) {
            return;
        }
        setMobileDataLayout(mDialog, internetContent);
+34 −0
Original line number Diff line number Diff line
@@ -832,6 +832,40 @@ public class InternetDialogDelegateLegacyTest extends SysuiTestCase {
                });
    }

    @Test
    public void updateDialog_shouldUpdateMobileNetworkTrue_updateMobileDataLayout() {
        when(mInternetDetailsContentController.isCarrierNetworkActive()).thenReturn(false);
        when(mInternetDetailsContentController.isAirplaneModeEnabled()).thenReturn(false);
        when(mInternetDetailsContentController.hasActiveSubIdOnDds()).thenReturn(true);
        when(mInternetDetailsContentController.activeNetworkIsCellular()).thenReturn(false);
        mMobileDataLayout.setVisibility(View.GONE);

        mInternetDialogDelegateLegacy.updateDialog(true);
        mBgExecutor.runAllReady();

        mInternetDialogDelegateLegacy.mDataInternetContent.observe(
                mInternetDialogDelegateLegacy.mLifecycleOwner, i -> {
                    assertThat(mMobileDataLayout.getVisibility()).isEqualTo(View.VISIBLE);
                });
    }

    @Test
    public void updateDialog_shouldUpdateMobileNetworkFalse_doNotUpdateMobileDataLayout() {
        when(mInternetDetailsContentController.isCarrierNetworkActive()).thenReturn(false);
        when(mInternetDetailsContentController.isAirplaneModeEnabled()).thenReturn(false);
        when(mInternetDetailsContentController.hasActiveSubIdOnDds()).thenReturn(true);
        when(mInternetDetailsContentController.activeNetworkIsCellular()).thenReturn(false);
        mMobileDataLayout.setVisibility(View.GONE);

        mInternetDialogDelegateLegacy.updateDialog(false);
        mBgExecutor.runAllReady();

        mInternetDialogDelegateLegacy.mDataInternetContent.observe(
                mInternetDialogDelegateLegacy.mLifecycleOwner, i -> {
                    assertThat(mMobileDataLayout.getVisibility()).isEqualTo(View.GONE);
                });
    }

    private void setNetworkVisible(boolean ethernetVisible, boolean mobileDataVisible,
            boolean connectedWifiVisible) {
        mEthernet.setVisibility(ethernetVisible ? View.VISIBLE : View.GONE);