Finished unit tests for SetupActivity and its Controller

This commit is contained in:
Ernir Erlingsson
2016-05-04 21:48:13 +02:00
parent 80f79d9ee0
commit f855c9ea28
9 changed files with 176 additions and 154 deletions

View File

@@ -36,7 +36,7 @@ public class SetupActivity extends BaseActivity implements OnClickListener,
OnEditorActionListener {
@Inject
SetupController setupController;
protected SetupController setupController;
TextInputLayout nicknameEntryWrapper;
TextInputLayout passwordEntryWrapper;

View File

@@ -84,15 +84,23 @@ public class SetupControllerImp implements SetupController {
@Override
public void createIdentity(final String nickname, final String password,
final ResultHandler<Long> resultHandler) {
LOG.info("createIdentity called");
cryptoExecutor.execute(new Runnable() {
public void run() {
LOG.info("createIdentity running");
SecretKey key = crypto.generateSecretKey();
LOG.info("createIdentity 1");
databaseConfig.setEncryptionKey(key);
LOG.info("createIdentity 2");
String hex = encryptDatabaseKey(key, password);
LOG.info("createIdentity 3");
storeEncryptedDatabaseKey(hex);
LOG.info("createIdentity 4");
final LocalAuthor localAuthor = createLocalAuthor(nickname);
LOG.info("createIdentity 5");
long handle = referenceManager.putReference(localAuthor,
LocalAuthor.class);
LOG.info("createIdentity 6");
resultHandler.onResult(handle);
}
});

View File

@@ -34,7 +34,10 @@ class AndroidSeedProvider extends LinuxSeedProvider {
if (Build.FINGERPRINT != null) out.writeUTF(Build.FINGERPRINT);
if (Build.SERIAL != null) out.writeUTF(Build.SERIAL);
ContentResolver contentResolver = appContext.getContentResolver();
out.writeUTF(Settings.Secure.getString(contentResolver, ANDROID_ID));
super.writeToEntropyPool(out);
String str = Settings.Secure.getString(contentResolver, ANDROID_ID);
if (str != null) {
out.writeUTF(str);
super.writeToEntropyPool(out);
}
}
}