Merge "Policy transparency dialog should be shown when SwitchBar is restricted." into pi-dev

This commit is contained in:
Yueming Wang
2018-05-02 14:58:47 +00:00
committed by Android (Google) Code Review
2 changed files with 36 additions and 2 deletions

View File

@@ -26,6 +26,7 @@ import android.widget.TextView;
import com.android.settings.R;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -82,4 +83,16 @@ public class SwitchBarTest {
assertThat(((TextView) mBar.findViewById(R.id.switch_text)).getText())
.isEqualTo(mContext.getString(onText));
}
@Test
public void disabledByAdmin_shouldDelegateToRestrictedIcon() {
mBar.setDisabledByAdmin(new EnforcedAdmin());
assertThat(mBar.getDelegatingView().getId()).isEqualTo(R.id.restricted_icon);
}
@Test
public void notDisabledByAdmin_shouldDelegateToSwitch() {
mBar.setDisabledByAdmin(null);
assertThat(mBar.getDelegatingView().getId()).isEqualTo(R.id.switch_widget);
}
}