Merge "Still check the visibility of view"
This commit is contained in:
@@ -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.
|
||||
|
@@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user