summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2014-07-10 20:55:55 +0200
committerParménides GV <parmegv@sdf.org>2014-07-24 16:50:48 +0200
commit623f81b5e52a5155549731e4afe35ca054f97a3f (patch)
treede1f591fb06c5a987396f016b7502ffd8bb1f80b /app/src
parent98f2fcedc3c645b38ecf168d57e28287c4a7a76e (diff)
network up & down 3 times: sometimes fails
I simulate removing the network at the end of the test. Sometimes, the test fails because a openvpn tries to close a bad file descriptor.
Diffstat (limited to 'app/src')
-rw-r--r--app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboard.java71
1 files changed, 53 insertions, 18 deletions
diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboard.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboard.java
index 66ef6565..fdf4f135 100644
--- a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboard.java
+++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboard.java
@@ -8,6 +8,8 @@ import android.provider.Settings;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
import com.robotium.solo.Solo;
+
+import de.blinkt.openvpn.activities.DisconnectVPN;
import se.leap.bitmaskclient.ConfigurationWizard;
import se.leap.bitmaskclient.Dashboard;
import se.leap.bitmaskclient.R;
@@ -38,25 +40,58 @@ public class testDashboard extends ActivityInstrumentationTestCase2<Dashboard> {
* I cannot automate that dialog.
*/
public void testOnOffOpenVpn() {
- solo.clickOnView(solo.getView(R.id.eipSwitch));
- if(!solo.waitForText(getActivity().getString(R.string.state_auth)))
- fail();
- if(!solo.waitForText(getActivity().getString(R.string.eip_state_connected), 1, 30*1000))
- fail();
-
- solo.clickOnView(solo.getView(R.id.eipSwitch));
- if(!solo.waitForText(getActivity().getString(R.string.eip_state_not_connected)))
- fail();
-
- ConnectionManager.setMobileDataEnabled(false, solo.getCurrentActivity().getApplicationContext());
-
- solo.clickOnView(solo.getView(R.id.eipSwitch));
- // if(!solo.waitForText(getActivity().getString(R.string.eip_status_start_pending)))
- // fail();
- if(!solo.waitForText(getActivity().getString(R.string.state_nonetwork)))
- fail();
+ solo.clickOnView(solo.getView(R.id.eipSwitch));
+ testEipTurningOn();
+
+ solo.clickOnView(solo.getView(R.id.eipSwitch));
+ testEipTurningOff();
+
+ solo.clickOnView(solo.getView(R.id.eipSwitch));
+ testEipTurningOn();
+
+ solo.clickOnView(solo.getView(R.id.eipSwitch));
+ testEipTurningOff();
+
+ solo.clickOnView(solo.getView(R.id.eipSwitch));
+ testEipTurningOn();
+
+ solo.clickOnView(solo.getView(R.id.eipSwitch));
+ testEipTurningOff();
+
+ solo.clickOnView(solo.getView(R.id.eipSwitch));
+ testEipTurningOn();
+
+ testEipIsOnNoNetwork();
+
}
-
+
+ private void testEipTurningOn() {
+ if(!solo.waitForText(getActivity().getString(R.string.state_auth)))
+ fail();
+ if(!solo.waitForText(getActivity().getString(R.string.eip_state_connected), 1, 30*1000))
+ fail();
+ solo.sleep(2*1000);
+ }
+
+ private void testEipTurningOff() {
+ sayOkToDisconnect();
+ if(!solo.waitForText(getActivity().getString(R.string.eip_state_not_connected)))
+ fail();
+ solo.sleep(2*1000);
+ }
+
+ private void sayOkToDisconnect() {
+ if(!solo.waitForActivity(DisconnectVPN.class))
+ fail();
+ solo.clickOnText(getActivity().getString(android.R.string.yes));
+ }
+
+ private void testEipIsOnNoNetwork() {
+ ConnectionManager.setMobileDataEnabled(false, solo.getCurrentActivity().getApplicationContext());
+ if(!solo.waitForText(getActivity().getString(R.string.eip_state_not_connected), 1, 15*1000))
+ fail();
+ }
+
public void testLogInAndOut() {
long miliseconds_to_log_in = 40 * 1000;
solo.clickOnActionBarItem(R.id.login_button);