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

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

Merge "Fix the problem that the "Turn off SIM" dialog will be displayed when...

Merge "Fix the problem that the "Turn off SIM" dialog will be displayed when the MobileNetwork page is slid to to top." into sc-dev
parents 1803aead 19056c22
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -82,15 +82,15 @@ public class SettingsMainSwitchPreference extends TwoStatePreference implements
        holder.setDividerAllowedAbove(false);
        holder.setDividerAllowedBelow(false);

        mMainSwitchBar = (SettingsMainSwitchBar) holder.findViewById(R.id.main_switch_bar);
        mMainSwitchBar.show();
        if (mRestrictedHelper != null) {
            mEnforcedAdmin = mRestrictedHelper.checkRestrictionEnforced();
        }
        mMainSwitchBar = (SettingsMainSwitchBar) holder.findViewById(R.id.main_switch_bar);
        if (mIsVisible) {
            mMainSwitchBar.show();
            updateStatus(isChecked());
            registerListenerToSwitchBar();

        if (!mIsVisible) {
        } else {
            mMainSwitchBar.hide();
        }
    }
+26 −0
Original line number Diff line number Diff line
@@ -24,6 +24,10 @@ import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import androidx.preference.PreferenceViewHolder;

import com.android.settings.R;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -39,6 +43,7 @@ public class SettingsMainSwitchPreferenceTest {
    @Mock
    private EnforcedAdmin mEnforcedAdmin;
    private SettingsMainSwitchPreference mPreference;
    private PreferenceViewHolder mHolder;

    @Before
    public void setUp() {
@@ -48,6 +53,9 @@ public class SettingsMainSwitchPreferenceTest {
        mPreference = new SettingsMainSwitchPreference(context);
        ReflectionHelpers.setField(mPreference, "mEnforcedAdmin", mEnforcedAdmin);
        ReflectionHelpers.setField(mPreference, "mMainSwitchBar", switchBar);
        final View rootView = View.inflate(context, R.layout.preference_widget_main_switch,
                null /* parent */);
        mHolder = PreferenceViewHolder.createInstanceForTests(rootView);
    }

    @Test
@@ -60,4 +68,22 @@ public class SettingsMainSwitchPreferenceTest {

        assertThat(restrictedIcon.getVisibility() == View.VISIBLE).isTrue();
    }

    @Test
    public void show_preferenceShouldDisplay() {
        mPreference.show();

        mPreference.onBindViewHolder(mHolder);

        assertThat(mPreference.isShowing()).isTrue();
    }

    @Test
    public void hide_preferenceShouldNotDisplay() {
        mPreference.hide();

        mPreference.onBindViewHolder(mHolder);

        assertThat(mPreference.isShowing()).isFalse();
    }
}