added a cache to the IdentityManager, changed its signature, modified when and where the author is stored

made the author creation single-threaded again in the LifecycleManager, removed redundant code
This commit is contained in:
Ernir Erlingsson
2016-10-13 11:01:25 +02:00
parent 47d6fc526f
commit eaa393a7ed
45 changed files with 299 additions and 552 deletions

View File

@@ -114,7 +114,6 @@ public class ChangePasswordActivityTest {
@Test
public void testChangePasswordUI() {
PasswordController mockedPasswordController = this.passwordController;
SetupController mockedSetupController = this.setupController;
changePasswordActivity.setPasswordController(mockedPasswordController);
@@ -135,7 +134,7 @@ public class ChangePasswordActivityTest {
verify(mockedPasswordController, times(1))
.changePassword(eq(curPass), eq(safePass),
resultCaptor.capture());
// execute the callback
// execute the callbacks
resultCaptor.getValue().onResult(true);
assertEquals(changePasswordActivity.isFinishing(), true);
}
@@ -147,12 +146,14 @@ public class ChangePasswordActivityTest {
SetupController setupController =
changePasswordActivity.getSetupController();
// mock a resulthandler
ResultHandler<Long> resultHandler =
(ResultHandler<Long>) mock(ResultHandler.class);
setupController.createIdentity("nick", "some.old.pass", resultHandler);
ResultHandler<Void> resultHandler =
(ResultHandler<Void>) mock(ResultHandler.class);
setupController
.storeAuthorInfo("nick", "some.old.pass", resultHandler);
// blocking verification call with timeout that waits until the mocked
// result gets called with handle 0L, the expected value
verify(resultHandler, timeout(2000).times(1)).onResult(0L);
verify(resultHandler, timeout(2000).times(1))
.onResult(null);
SharedPreferences prefs =
changePasswordActivity
.getSharedPreferences("db", Context.MODE_PRIVATE);

View File

@@ -63,7 +63,7 @@ public class SetupActivityTest {
@Mock
private SetupController setupController;
@Captor
private ArgumentCaptor<ResultHandler<Long>> resultCaptor;
private ArgumentCaptor<ResultHandler<Void>> authorCaptor;
@Before
public void setUp() {
@@ -114,7 +114,6 @@ public class SetupActivityTest {
@Test
public void testCreateAccountUI() {
SetupController mockedController = this.setupController;
setupActivity.setController(mockedController);
// Mock strong password strength answer
@@ -131,9 +130,10 @@ public class SetupActivityTest {
// Verify that the controller's method was called with the correct
// params and get the callback
verify(mockedController, times(1))
.createIdentity(eq(nick), eq(safePass), resultCaptor.capture());
.storeAuthorInfo(eq(safePass), eq(nick),
authorCaptor.capture());
authorCaptor.getValue().onResult(null);
// execute the callback
resultCaptor.getValue().onResult(1L);
assertEquals(setupActivity.isFinishing(), true);
// Confirm that the correct Activity has been started
ShadowActivity shadowActivity = shadowOf(setupActivity);
@@ -158,13 +158,13 @@ public class SetupActivityTest {
public void testAccountCreation() {
SetupController controller = setupActivity.getController();
// mock a resulthandler
ResultHandler<Long> resultHandler =
(ResultHandler<Long>) mock(ResultHandler.class);
ResultHandler<Void> resultHandler =
(ResultHandler<Void>) mock(ResultHandler.class);
controller
.createIdentity("nick", "some.strong.pass", resultHandler);
.storeAuthorInfo("nick", "some.strong.pass", resultHandler);
// blocking verification call with timeout that waits until the mocked
// result gets called with handle 0L, the expected value
verify(resultHandler, timeout(2000).times(1)).onResult(0L);
verify(resultHandler, timeout(2000).times(1)).onResult(null);
SharedPreferences prefs =
setupActivity.getSharedPreferences("db", Context.MODE_PRIVATE);
// Confirm database key