mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 20:59:54 +01:00
Increase test timeouts to avoid spurious failures.
This commit is contained in:
@@ -46,6 +46,8 @@ import static org.mockito.Mockito.when;
|
|||||||
application = TestBriarApplication.class)
|
application = TestBriarApplication.class)
|
||||||
public class ChangePasswordActivityTest {
|
public class ChangePasswordActivityTest {
|
||||||
|
|
||||||
|
private static final int TIMEOUT_MS = 10 * 1000;
|
||||||
|
|
||||||
private TestChangePasswordActivity changePasswordActivity;
|
private TestChangePasswordActivity changePasswordActivity;
|
||||||
private TextInputLayout passwordConfirmationWrapper;
|
private TextInputLayout passwordConfirmationWrapper;
|
||||||
private EditText currentPassword;
|
private EditText currentPassword;
|
||||||
@@ -68,21 +70,16 @@ public class ChangePasswordActivityTest {
|
|||||||
Robolectric.setupActivity(TestChangePasswordActivity.class);
|
Robolectric.setupActivity(TestChangePasswordActivity.class);
|
||||||
passwordConfirmationWrapper = (TextInputLayout) changePasswordActivity
|
passwordConfirmationWrapper = (TextInputLayout) changePasswordActivity
|
||||||
.findViewById(R.id.new_password_confirm_wrapper);
|
.findViewById(R.id.new_password_confirm_wrapper);
|
||||||
currentPassword =
|
currentPassword = (EditText) changePasswordActivity
|
||||||
(EditText) changePasswordActivity
|
.findViewById(R.id.current_password_entry);
|
||||||
.findViewById(R.id.current_password_entry);
|
newPassword = (EditText) changePasswordActivity
|
||||||
newPassword =
|
.findViewById(R.id.new_password_entry);
|
||||||
(EditText) changePasswordActivity
|
newPasswordConfirmation = (EditText) changePasswordActivity
|
||||||
.findViewById(R.id.new_password_entry);
|
.findViewById(R.id.new_password_confirm);
|
||||||
newPasswordConfirmation =
|
strengthMeter = (StrengthMeter) changePasswordActivity
|
||||||
(EditText) changePasswordActivity
|
.findViewById(R.id.strength_meter);
|
||||||
.findViewById(R.id.new_password_confirm);
|
changePasswordButton = (Button) changePasswordActivity
|
||||||
strengthMeter =
|
.findViewById(R.id.change_password);
|
||||||
(StrengthMeter) changePasswordActivity
|
|
||||||
.findViewById(R.id.strength_meter);
|
|
||||||
changePasswordButton =
|
|
||||||
(Button) changePasswordActivity
|
|
||||||
.findViewById(R.id.change_password);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testStrengthMeter(String pass, float strength, int color) {
|
private void testStrengthMeter(String pass, float strength, int color) {
|
||||||
@@ -148,27 +145,23 @@ public class ChangePasswordActivityTest {
|
|||||||
// mock a resulthandler
|
// mock a resulthandler
|
||||||
ResultHandler<Void> resultHandler =
|
ResultHandler<Void> resultHandler =
|
||||||
(ResultHandler<Void>) mock(ResultHandler.class);
|
(ResultHandler<Void>) mock(ResultHandler.class);
|
||||||
setupController
|
setupController.storeAuthorInfo("nick", "some.old.pass", resultHandler);
|
||||||
.storeAuthorInfo("nick", "some.old.pass", resultHandler);
|
|
||||||
// blocking verification call with timeout that waits until the mocked
|
// blocking verification call with timeout that waits until the mocked
|
||||||
// result gets called with handle 0L, the expected value
|
// result gets called with handle 0L, the expected value
|
||||||
verify(resultHandler, timeout(2000).times(1))
|
verify(resultHandler, timeout(TIMEOUT_MS).times(1)).onResult(null);
|
||||||
.onResult(null);
|
SharedPreferences prefs = changePasswordActivity
|
||||||
SharedPreferences prefs =
|
.getSharedPreferences("db", Context.MODE_PRIVATE);
|
||||||
changePasswordActivity
|
|
||||||
.getSharedPreferences("db", Context.MODE_PRIVATE);
|
|
||||||
// Confirm database key
|
// Confirm database key
|
||||||
assertTrue(prefs.contains("key"));
|
assertTrue(prefs.contains("key"));
|
||||||
String oldKey = prefs.getString("key", null);
|
String oldKey = prefs.getString("key", null);
|
||||||
// mock a resulthandler
|
// mock a resulthandler
|
||||||
ResultHandler<Boolean> resultHandler2 =
|
ResultHandler<Boolean> resultHandler2 =
|
||||||
(ResultHandler<Boolean>) mock(ResultHandler.class);
|
(ResultHandler<Boolean>) mock(ResultHandler.class);
|
||||||
passwordController
|
passwordController.changePassword("some.old.pass", "some.strong.pass",
|
||||||
.changePassword("some.old.pass", "some.strong.pass",
|
resultHandler2);
|
||||||
resultHandler2);
|
|
||||||
// blocking verification call with timeout that waits until the mocked
|
// blocking verification call with timeout that waits until the mocked
|
||||||
// result gets called with handle 0L, the expected value
|
// result gets called with handle 0L, the expected value
|
||||||
verify(resultHandler2, timeout(2000).times(1)).onResult(true);
|
verify(resultHandler2, timeout(TIMEOUT_MS).times(1)).onResult(true);
|
||||||
// Confirm database key
|
// Confirm database key
|
||||||
assertTrue(prefs.contains("key"));
|
assertTrue(prefs.contains("key"));
|
||||||
assertNotEquals(oldKey, prefs.getString("key", null));
|
assertNotEquals(oldKey, prefs.getString("key", null));
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ import static org.robolectric.Shadows.shadowOf;
|
|||||||
application = TestBriarApplication.class)
|
application = TestBriarApplication.class)
|
||||||
public class SetupActivityTest {
|
public class SetupActivityTest {
|
||||||
|
|
||||||
|
private static final int TIMEOUT_MS = 10 * 1000;
|
||||||
|
|
||||||
private TestSetupActivity setupActivity;
|
private TestSetupActivity setupActivity;
|
||||||
private TextInputLayout nicknameEntryWrapper;
|
private TextInputLayout nicknameEntryWrapper;
|
||||||
private TextInputLayout passwordConfirmationWrapper;
|
private TextInputLayout passwordConfirmationWrapper;
|
||||||
@@ -157,11 +159,10 @@ public class SetupActivityTest {
|
|||||||
// mock a resulthandler
|
// mock a resulthandler
|
||||||
ResultHandler<Void> resultHandler =
|
ResultHandler<Void> resultHandler =
|
||||||
(ResultHandler<Void>) mock(ResultHandler.class);
|
(ResultHandler<Void>) mock(ResultHandler.class);
|
||||||
controller
|
controller.storeAuthorInfo("nick", "some.strong.pass", resultHandler);
|
||||||
.storeAuthorInfo("nick", "some.strong.pass", resultHandler);
|
|
||||||
// blocking verification call with timeout that waits until the mocked
|
// blocking verification call with timeout that waits until the mocked
|
||||||
// result gets called with handle 0L, the expected value
|
// result gets called with handle 0L, the expected value
|
||||||
verify(resultHandler, timeout(2000).times(1)).onResult(null);
|
verify(resultHandler, timeout(TIMEOUT_MS).times(1)).onResult(null);
|
||||||
SharedPreferences prefs =
|
SharedPreferences prefs =
|
||||||
setupActivity.getSharedPreferences("db", Context.MODE_PRIVATE);
|
setupActivity.getSharedPreferences("db", Context.MODE_PRIVATE);
|
||||||
// Confirm database key
|
// Confirm database key
|
||||||
|
|||||||
Reference in New Issue
Block a user