Commit be517ca4 authored by gangwu's avatar gangwu Committed by Commit bot

No two error messages at same time.

BUG=628161

When set one of TextEdit, which are mEnterPassphrase and
mConfirmPassphrase, to have an error message, set another one
to empty.

Review-Url: https://codereview.chromium.org/2179093002
Cr-Commit-Position: refs/heads/master@{#407669}
parent 69820f8d
...@@ -107,10 +107,12 @@ public class PassphraseCreationDialogFragment extends DialogFragment { ...@@ -107,10 +107,12 @@ public class PassphraseCreationDialogFragment extends DialogFragment {
String confirmPassphrase = mConfirmPassphrase.getText().toString(); String confirmPassphrase = mConfirmPassphrase.getText().toString();
if (!passphrase.equals(confirmPassphrase)) { if (!passphrase.equals(confirmPassphrase)) {
mEnterPassphrase.setError(null);
mConfirmPassphrase.setError(getString(R.string.sync_passphrases_do_not_match)); mConfirmPassphrase.setError(getString(R.string.sync_passphrases_do_not_match));
mConfirmPassphrase.requestFocus(); mConfirmPassphrase.requestFocus();
return; return;
} else if (passphrase.isEmpty()) { } else if (passphrase.isEmpty()) {
mConfirmPassphrase.setError(null);
mEnterPassphrase.setError(getString(R.string.sync_passphrase_cannot_be_blank)); mEnterPassphrase.setError(getString(R.string.sync_passphrase_cannot_be_blank));
mEnterPassphrase.requestFocus(); mEnterPassphrase.requestFocus();
return; return;
......
...@@ -548,32 +548,42 @@ public class SyncCustomizationFragmentTest extends SyncTestBase { ...@@ -548,32 +548,42 @@ public class SyncCustomizationFragmentTest extends SyncTestBase {
clickButton(okButton); clickButton(okButton);
assertTrue(pcdf.isResumed()); assertTrue(pcdf.isResumed());
assertNotNull(enterPassphrase.getError()); assertNotNull(enterPassphrase.getError());
assertNull(confirmPassphrase.getError());
// Error if you try to submit with only the first box filled. // Error if you try to submit with only the first box filled.
clearError(confirmPassphrase); clearError(confirmPassphrase);
setText(enterPassphrase, "foo"); setText(enterPassphrase, "foo");
clickButton(okButton); clickButton(okButton);
assertTrue(pcdf.isResumed()); assertTrue(pcdf.isResumed());
assertNull(enterPassphrase.getError());
assertNotNull(confirmPassphrase.getError()); assertNotNull(confirmPassphrase.getError());
// Error if you try to submit with only the second box filled. // Remove first box should only show empty error message
setText(enterPassphrase, ""); setText(enterPassphrase, "");
clickButton(okButton);
assertNotNull(enterPassphrase.getError());
assertNull(confirmPassphrase.getError());
// Error if you try to submit with only the second box filled.
clearError(confirmPassphrase); clearError(confirmPassphrase);
setText(confirmPassphrase, "foo"); setText(confirmPassphrase, "foo");
clickButton(okButton); clickButton(okButton);
assertTrue(pcdf.isResumed()); assertTrue(pcdf.isResumed());
assertNull(enterPassphrase.getError());
assertNotNull(confirmPassphrase.getError()); assertNotNull(confirmPassphrase.getError());
// No error if text doesn't match without button press. // No error if text doesn't match without button press.
setText(enterPassphrase, "foo"); setText(enterPassphrase, "foo");
clearError(confirmPassphrase); clearError(confirmPassphrase);
setText(confirmPassphrase, "bar"); setText(confirmPassphrase, "bar");
assertNull(enterPassphrase.getError());
assertNull(confirmPassphrase.getError()); assertNull(confirmPassphrase.getError());
// Error if you try to submit unmatching text. // Error if you try to submit unmatching text.
clearError(confirmPassphrase); clearError(confirmPassphrase);
clickButton(okButton); clickButton(okButton);
assertTrue(pcdf.isResumed()); assertTrue(pcdf.isResumed());
assertNull(enterPassphrase.getError());
assertNotNull(confirmPassphrase.getError()); assertNotNull(confirmPassphrase.getError());
// Success if text matches. // Success if text matches.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment