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

Commit e95f07df authored by jackqdyulei's avatar jackqdyulei
Browse files

Still check the visibility of view

Since EAP has many sub type, which controls differnet view. We still need to check the
visibility to determine which type it is.

Bug: 116767176
Test: RunSettingsRoboTests
Change-Id: Iee04a50140ae1afacdf77eedf7743a465bae1f58
parent 092f66b2
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -123,7 +123,8 @@ public class WifiConfigController implements TextWatcher,
    private final ArrayAdapter<String> mPhase2FullAdapter;

    // e.g. AccessPoint.SECURITY_NONE
    private int mAccessPointSecurity;
    @VisibleForTesting
    int mAccessPointSecurity;
    private TextView mPasswordView;

    private String mUnspecifiedCertString;
@@ -465,7 +466,8 @@ public class WifiConfigController implements TextWatcher,
        } else {
            enabled = ipAndProxyFieldsAreValid();
        }
        if (mAccessPointSecurity == AccessPoint.SECURITY_EAP) {
        if (mAccessPointSecurity == AccessPoint.SECURITY_EAP && mEapCaCertSpinner != null
                && mView.findViewById(R.id.l_ca_cert).getVisibility() != View.GONE) {
            String caCertSelection = (String) mEapCaCertSpinner.getSelectedItem();
            if (caCertSelection.equals(mUnspecifiedCertString)) {
                // Disallow submit if the user has not selected a CA certificate for an EAP network
@@ -481,7 +483,8 @@ public class WifiConfigController implements TextWatcher,
                enabled = false;
            }
        }
        if (mAccessPointSecurity == AccessPoint.SECURITY_EAP
        if (mAccessPointSecurity == AccessPoint.SECURITY_EAP && mEapUserCertSpinner != null
                && mView.findViewById(R.id.l_user_cert).getVisibility() != View.GONE
                && mEapUserCertSpinner.getSelectedItem().equals(mUnspecifiedCertString)) {
            // Disallow submit if the user has not selected a user certificate for an EAP network
            // configuration.
+15 −2
Original line number Diff line number Diff line
@@ -57,11 +57,10 @@ public class WifiConfigControllerTest {
    @Mock
    private Context mContext;
    @Mock
    private View mView;
    @Mock
    private AccessPoint mAccessPoint;
    @Mock
    private KeyStore mKeyStore;
    private View mView;
    private Spinner mHiddenSettingsSpinner;

    public WifiConfigController mController;
@@ -74,6 +73,7 @@ public class WifiConfigControllerTest {
    private static final String SHORT_PSK = "abcdefg";
    // Valid PSK pass phrase
    private static final String GOOD_PSK = "abcdefghijklmnopqrstuvwxyz";
    private static final String GOOD_SSID = "abc";
    private static final int DHCP = 0;

    @Before
@@ -185,6 +185,9 @@ public class WifiConfigControllerTest {

    @Test
    public void isSubmittable_EapToPskWithValidPassword_shouldReturnTrue() {
        mController = new TestWifiConfigController(mConfigUiBase, mView, null,
                WifiConfigUiBase.MODE_CONNECT);
        final TextView ssid = mView.findViewById(R.id.ssid);
        final TextView password = mView.findViewById(R.id.password);
        final Spinner securitySpinner = mView.findViewById(R.id.security);
        assertThat(password).isNotNull();
@@ -195,6 +198,16 @@ public class WifiConfigControllerTest {
        mController.onItemSelected(securitySpinner, null, AccessPoint.SECURITY_EAP, 0);
        mController.onItemSelected(securitySpinner, null, AccessPoint.SECURITY_PSK, 0);
        password.setText(GOOD_PSK);
        ssid.setText(GOOD_SSID);

        assertThat(mController.isSubmittable()).isTrue();
    }

    @Test
    public void isSubmittable_EapWithAkaMethod_shouldReturnTrue() {
        when(mAccessPoint.isSaved()).thenReturn(true);
        mController.mAccessPointSecurity = AccessPoint.SECURITY_EAP;
        mView.findViewById(R.id.l_ca_cert).setVisibility(View.GONE);

        assertThat(mController.isSubmittable()).isTrue();
    }