mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
interlude
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
-dontpreverify
|
||||
-dontobfuscate
|
||||
-verbose
|
||||
-useuniqueclassmembernames
|
||||
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
|
||||
# For comfortability in case we do obfuscate
|
||||
# -renamesourcefileattribute SourceFile
|
||||
@@ -48,9 +49,20 @@
|
||||
-keep class roboguice.** { *; }
|
||||
-keep class dagger.** { *; }
|
||||
-keep class com.google.** { *; }
|
||||
-keep class javax.** { *; }
|
||||
-keep class org.eclipse.** { *; }
|
||||
-keep class com.squareup.** { *; }
|
||||
|
||||
-dontwarn org.hamcrest.**
|
||||
-dontwarn com.squareup.**
|
||||
-dontwarn com.google.android.**
|
||||
|
||||
-keep class com.google.android.** {
|
||||
*;
|
||||
}
|
||||
-keep class com.google.common.** {
|
||||
*;
|
||||
}
|
||||
-keep class org.hamcrest.** {
|
||||
*;
|
||||
}
|
||||
|
||||
-dontwarn org.h2.**
|
||||
-dontnote org.h2.**
|
||||
|
||||
@@ -54,8 +54,9 @@ public class ActivityModule {
|
||||
|
||||
@ActivityScope
|
||||
@Provides
|
||||
protected SetupController provideSetupController() {
|
||||
return new SetupControllerImp();
|
||||
protected SetupController provideSetupController(
|
||||
SetupControllerImp setupControllerImp) {
|
||||
return setupControllerImp;
|
||||
}
|
||||
|
||||
@ActivityScope
|
||||
@@ -147,7 +148,8 @@ public class ActivityModule {
|
||||
@Provides
|
||||
@Named("IntroductionMessageFragment")
|
||||
IntroductionMessageFragment provideIntroductionMessageFragment() {
|
||||
IntroductionMessageFragment fragment = new IntroductionMessageFragment();
|
||||
IntroductionMessageFragment fragment =
|
||||
new IntroductionMessageFragment();
|
||||
fragment.setArguments(new Bundle());
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ import javax.inject.Inject;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
|
||||
import static android.view.View.INVISIBLE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static org.briarproject.android.TestingConstants.PREVENT_SCREENSHOTS;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
||||
import static org.briarproject.api.crypto.PasswordStrengthEstimator.WEAK;
|
||||
import static org.briarproject.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
|
||||
|
||||
@@ -64,7 +66,7 @@ public class SetupActivity extends BaseActivity implements OnClickListener,
|
||||
createAccountButton = (Button) findViewById(R.id.create_account);
|
||||
progress = (ProgressBar) findViewById(R.id.progress_wheel);
|
||||
|
||||
// if (PREVENT_SCREENSHOTS) getWindow().addFlags(FLAG_SECURE);
|
||||
if (PREVENT_SCREENSHOTS) getWindow().addFlags(FLAG_SECURE);
|
||||
|
||||
TextWatcher tw = new TextWatcher() {
|
||||
@Override
|
||||
|
||||
@@ -23,11 +23,11 @@ import static org.briarproject.api.crypto.PasswordStrengthEstimator.WEAK;
|
||||
public class StrengthMeter extends ProgressBar {
|
||||
|
||||
private static final int MAX = 100;
|
||||
private static final int RED = Color.rgb(255, 0, 0);
|
||||
private static final int ORANGE = Color.rgb(255, 160, 0);
|
||||
private static final int YELLOW = Color.rgb(255, 255, 0);
|
||||
private static final int LIME = Color.rgb(180, 255, 0);
|
||||
private static final int GREEN = Color.rgb(0, 255, 0);
|
||||
public static final int RED = Color.rgb(255, 0, 0);
|
||||
public static final int ORANGE = Color.rgb(255, 160, 0);
|
||||
public static final int YELLOW = Color.rgb(255, 255, 0);
|
||||
public static final int LIME = Color.rgb(180, 255, 0);
|
||||
public static final int GREEN = Color.rgb(0, 255, 0);
|
||||
|
||||
private final ShapeDrawable bar;
|
||||
|
||||
@@ -57,6 +57,10 @@ public class StrengthMeter extends ProgressBar {
|
||||
return MAX;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return bar.getPaint().getColor();
|
||||
}
|
||||
|
||||
public void setStrength(float strength) {
|
||||
if (strength < 0 || strength > 1) throw new IllegalArgumentException();
|
||||
int colour;
|
||||
|
||||
@@ -4,20 +4,29 @@ import android.support.design.widget.TextInputLayout;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import org.briarproject.BuildConfig;
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.ActivityModule;
|
||||
import org.briarproject.android.SetupActivity;
|
||||
import org.briarproject.android.controller.SetupController;
|
||||
import org.briarproject.android.controller.SetupControllerImp;
|
||||
import org.briarproject.android.util.StrengthMeter;
|
||||
import org.briarproject.api.crypto.PasswordStrengthEstimator;
|
||||
import org.briarproject.api.identity.AuthorConstants;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.robolectric.Robolectric;
|
||||
import org.robolectric.RobolectricGradleTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
@RunWith(RobolectricGradleTestRunner.class)
|
||||
@Config(constants = BuildConfig.class, sdk = 22)
|
||||
@Config(constants = BuildConfig.class, sdk = 21)
|
||||
public class SetupActivityTest {
|
||||
|
||||
private SetupActivity setupActivity;
|
||||
@@ -34,7 +43,22 @@ public class SetupActivityTest {
|
||||
|
||||
@Override
|
||||
protected ActivityModule getActivityModule() {
|
||||
return super.getActivityModule();
|
||||
return new ActivityModule(this) {
|
||||
|
||||
@Override
|
||||
protected SetupController provideSetupController(
|
||||
SetupControllerImp setupControllerImp) {
|
||||
SetupController setupController =
|
||||
Mockito.mock(SetupControllerImp.class);
|
||||
Mockito.when(
|
||||
setupController.estimatePasswordStrength("strong"))
|
||||
.thenReturn(PasswordStrengthEstimator.STRONG);
|
||||
// Mockito.when(
|
||||
// setupController.estimatePasswordStrength("qstrong"))
|
||||
// .thenReturn(PasswordStrengthEstimator.QUITE_STRONG);
|
||||
return setupController;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,13 +81,23 @@ public class SetupActivityTest {
|
||||
(StrengthMeter) setupActivity.findViewById(R.id.strength_meter);
|
||||
createAccountButton =
|
||||
(Button) setupActivity.findViewById(R.id.create_account);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
String longNick =
|
||||
Strings.padEnd("*", AuthorConstants.MAX_AUTHOR_NAME_LENGTH + 1,
|
||||
'*');
|
||||
nicknameEntry.setText(longNick);
|
||||
assertEquals(nicknameEntryWrapper.getError(),
|
||||
setupActivity.getString(R.string.name_too_long));
|
||||
|
||||
passwordEntry.setText("strong");
|
||||
assertEquals(strengthMeter.getProgress(),
|
||||
strengthMeter.getMax() * PasswordStrengthEstimator.STRONG);
|
||||
|
||||
|
||||
// passwordEntry.setText("strong");
|
||||
// assertEquals(StrengthMeter.GREEN, strengthMeter.getColor());
|
||||
// setupActivity.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package briarproject.activity;
|
||||
|
||||
import org.briarproject.android.ActivityModule;
|
||||
import org.briarproject.android.BaseActivity;
|
||||
|
||||
public class TestActivityModule extends ActivityModule {
|
||||
|
||||
public TestActivityModule(BaseActivity activity) {
|
||||
super(activity);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@Override
|
||||
protected SetupController provideSetupController(
|
||||
SetupControllerImp setupControllerImp) {
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -8,6 +8,8 @@ import javax.inject.Inject;
|
||||
|
||||
public class SetupControllerTest extends BriarTestCase {
|
||||
|
||||
|
||||
|
||||
@Inject
|
||||
SetupController setupController;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user