summaryrefslogtreecommitdiff
path: root/tests/src/se/leap/bitmaskclient/test/testDashboard.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/se/leap/bitmaskclient/test/testDashboard.java')
-rw-r--r--tests/src/se/leap/bitmaskclient/test/testDashboard.java50
1 files changed, 10 insertions, 40 deletions
diff --git a/tests/src/se/leap/bitmaskclient/test/testDashboard.java b/tests/src/se/leap/bitmaskclient/test/testDashboard.java
index b6c23084..a1d1ffac 100644
--- a/tests/src/se/leap/bitmaskclient/test/testDashboard.java
+++ b/tests/src/se/leap/bitmaskclient/test/testDashboard.java
@@ -1,8 +1,5 @@
package se.leap.bitmaskclient.test;
-import se.leap.bitmaskclient.ConfigurationWizard;
-import se.leap.bitmaskclient.Dashboard;
-import se.leap.bitmaskclient.R;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -10,8 +7,12 @@ import android.content.IntentFilter;
import android.provider.Settings;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
-
import com.jayway.android.robotium.solo.Solo;
+import se.leap.bitmaskclient.ConfigurationWizard;
+import se.leap.bitmaskclient.Dashboard;
+import se.leap.bitmaskclient.R;
+import se.leap.bitmaskclient.test.ConnectionManager;
+import se.leap.openvpn.MainActivity;
public class testDashboard extends ActivityInstrumentationTestCase2<Dashboard> {
@@ -25,7 +26,7 @@ public class testDashboard extends ActivityInstrumentationTestCase2<Dashboard> {
protected void setUp() throws Exception {
super.setUp();
solo = new Solo(getInstrumentation(), getActivity());
- setAirplaneMode(false);
+ ConnectionManager.setMobileDataEnabled(true, solo.getCurrentActivity().getApplicationContext());
}
@Override
@@ -48,21 +49,18 @@ public class testDashboard extends ActivityInstrumentationTestCase2<Dashboard> {
solo.clickOnView(solo.getView(R.id.eipSwitch));
if(!solo.waitForText("Not running! Connection not secure"))
- fail();
- /* setAirplaneMode isn't working right now.
- setAirplaneMode(true);
- if(!solo.waitForLogMessage("Service state changed"))
- fail();
+ fail();
+
+ ConnectionManager.setMobileDataEnabled(false, solo.getCurrentActivity().getApplicationContext());
solo.clickOnView(solo.getView(R.id.eipSwitch));
if(!solo.waitForText("Initiating connection"))
fail();
if(!solo.waitForText("Waiting for usable network"))
fail();
- */
}
- public void testLogInAndOut() {
+ public void testLogInAndOut() {
long miliseconds_to_log_in = 40 * 1000;
solo.clickOnActionBarItem(R.id.login_button);
solo.enterText(0, "parmegvtest1");
@@ -96,34 +94,6 @@ public class testDashboard extends ActivityInstrumentationTestCase2<Dashboard> {
solo.clickOnMenuItem("Switch provider");
solo.waitForActivity(ConfigurationWizard.class);
solo.goBack();
-
- solo.clickOnMenuItem("Switch provider");
- solo.waitForActivity(ConfigurationWizard.class);
- solo.goBack();
}
-
- private void setAirplaneMode(boolean airplane_mode) {
- Context context = solo.getCurrentActivity().getApplicationContext();
- boolean isEnabled = Settings.System.getInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) == 1;
- Log.d("AirplaneMode", "Service state: " + isEnabled);
- Settings.System.putInt(context.getContentResolver(),Settings.System.AIRPLANE_MODE_ON, airplane_mode ? 1 : 0);
-
- // Post an intent to reload
- Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
- intent.putExtra("state", airplane_mode);
- Log.d("AirplaneMode", "New Service state: " + !isEnabled);
- solo.getCurrentActivity().sendBroadcast(intent);
-
- IntentFilter intentFilter = new IntentFilter("android.intent.action.SERVICE_STATE");
-
- BroadcastReceiver receiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- boolean isEnabled = Settings.System.getInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) == 1;
- Log.d("AirplaneMode", "Service state changed: " + isEnabled);
- }
- };
-
- context.registerReceiver(receiver, intentFilter);
}
}