summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2015-03-30 18:45:12 +0200
committerParménides GV <parmegv@sdf.org>2015-03-30 18:45:12 +0200
commit45eecc4c3c3380b1f5ec416513ea36144463292d (patch)
treeadb038d4ace3a676b4ca173878654739018e174f
parent8cd10bcac50a7e76085d5d7384dc8910a80e44c6 (diff)
parent66673b5b60eb99d5682a440f6d90a08ccb1835b6 (diff)
Merge branch 'feature/Unit-tests-to-establish-VPN-with-every-provider-#6781' into develop
-rw-r--r--app/build.gradle2
-rw-r--r--app/src/androidTest/java/se/leap/bitmaskclient/test/testConfigurationWizard.java12
-rw-r--r--app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java72
3 files changed, 76 insertions, 10 deletions
diff --git a/app/build.gradle b/app/build.gradle
index 4d3c5b9c..4441cafa 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -39,7 +39,7 @@ android {
}
dependencies {
- androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.2.1'
+ androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.3.1'
compile 'com.jakewharton:butterknife:6.0.0+'
provided 'com.squareup.dagger:dagger-compiler:1.2.2+'
compile 'com.github.pedrovgs:renderers:1.3+'
diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/testConfigurationWizard.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/testConfigurationWizard.java
index 7a19409b..1fa4cf2f 100644
--- a/app/src/androidTest/java/se/leap/bitmaskclient/test/testConfigurationWizard.java
+++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/testConfigurationWizard.java
@@ -32,7 +32,7 @@ public class testConfigurationWizard extends ActivityInstrumentationTestCase2<Co
@Override
protected void tearDown() throws Exception {
- solo.finishOpenedActivities();
+
}
public void testListProviders() {
@@ -97,14 +97,18 @@ public class testConfigurationWizard extends ActivityInstrumentationTestCase2<Co
assertTrue("Provider details dialog did not appear", solo.waitForActivity(AboutActivity.class));
}
- protected void toDashboard(String provider) {
+ protected void toDashboardAnonymously(String provider) {
selectProvider(provider);
useAnonymously();
}
private void useAnonymously() {
String text = solo.getString(R.string.use_anonymously_button);
- solo.clickOnText(text);
- solo.waitForText(solo.getString(R.string.title_activity_dashboard));
+ clickAndWaitForDashboard(text);
+ }
+
+ private void clickAndWaitForDashboard(String click_text) {
+ solo.clickOnText(click_text);
+ assertTrue(solo.waitForActivity(Dashboard.class, 5000));
}
}
diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java
index ee1917e2..d2fb9901 100644
--- a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java
+++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java
@@ -2,6 +2,7 @@ package se.leap.bitmaskclient.test;
import android.content.*;
import android.test.*;
+import android.widget.*;
import com.robotium.solo.*;
@@ -27,7 +28,7 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2<D
ConnectionManager.setMobileDataEnabled(true, context);
solo.unlockScreen();
if (solo.searchText(solo.getString(R.string.configuration_wizard_title)))
- new testConfigurationWizard(solo).toDashboard("demo.bitmask.net");
+ new testConfigurationWizard(solo).toDashboardAnonymously("demo.bitmask.net");
}
@Override
@@ -108,6 +109,7 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2<D
public void testLogInAndOut() {
long milliseconds_to_log_in = 40 * 1000;
+ solo.clickOnActionBarItem(R.id.login_button);
logIn("parmegvtest1", " S_Zw3'-");
solo.waitForDialogToClose(milliseconds_to_log_in);
assertSuccessfulLogin();
@@ -116,7 +118,6 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2<D
}
private void logIn(String username, String password) {
- solo.clickOnActionBarItem(R.id.login_button);
solo.enterText(0, username);
solo.enterText(1, password);
solo.clickOnText("Log In");
@@ -124,8 +125,7 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2<D
}
private void assertSuccessfulLogin() {
- String message = solo.getString(R.string.succesful_authentication_message);
- assertTrue(solo.waitForText(message));
+ assertTrue(solo.waitForText("is logged in"));
}
private void logOut() {
@@ -149,11 +149,73 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2<D
}
public void testSwitchProvider() {
+ tapSwitchProvider();
+ solo.goBack();
+ }
+
+ private void tapSwitchProvider() {
solo.clickOnMenuItem(solo.getString(R.string.switch_provider_menu_option));
solo.waitForActivity(ConfigurationWizard.class);
- solo.goBack();
}
+ public void testEveryProvider() {
+ changeProvider("demo.bitmask.net");
+ connectVpn();
+ disconnectVpn();
+
+ changeProvider("riseup.net");
+ connectVpn();
+ disconnectVpn();
+
+ changeProvider("calyx.net");
+ connectVpn();
+ disconnectVpn();
+ }
+
+ private void changeProvider(String provider) {
+ tapSwitchProvider();
+ solo.clickOnText(provider);
+ useRegistered();
+ solo.waitForText("Downloading VPN certificate");
+ assertDisconnected();
+ }
+
+ private void connectVpn() {
+ Switch vpn_switch = (Switch)solo.getView(R.id.eipSwitch);
+ assertFalse(vpn_switch.isChecked());
+
+ solo.clickOnView(vpn_switch);
+ turningEipOn();
+ }
+
+ private void disconnectVpn() {
+ Switch vpn_switch = (Switch)solo.getView(R.id.eipSwitch);
+ assertTrue(vpn_switch.isChecked());
+
+ solo.clickOnView(vpn_switch);
+ solo.clickOnText("Yes");
+ turningEipOff();
+
+ }
+
+ private void useRegistered() {
+ String text = solo.getString(R.string.signup_or_login_button);
+ clickAndWaitForDashboard(text);
+ login();
+ }
+
+ private void clickAndWaitForDashboard(String click_text) {
+ solo.clickOnText(click_text);
+ assertTrue(solo.waitForActivity(Dashboard.class, 5000));
+ }
+
+ private void login() {
+ long milliseconds_to_log_in = 40 * 1000;
+ logIn("parmegvtest10", "holahola2");
+ solo.waitForDialogToClose(milliseconds_to_log_in);
+ assertSuccessfulLogin();
+ }
+
/*public void testReboot() {
runAdbCommand("shell am broadcast -a android.intent.action.BOOT_COMPLETED");
}*/