diff options
author | cyBerta <cyberta@riseup.net> | 2017-09-14 17:36:09 +0200 |
---|---|---|
committer | cyBerta <cyberta@riseup.net> | 2017-09-14 17:36:09 +0200 |
commit | 15a093d0f4df45bf8e80e09d14f5a1f57f0fa1ff (patch) | |
tree | 9a1eaa7e341b971a3a511ad87c715019e1aea794 /app/src/androidTest/java/se | |
parent | 7cbf75518603ba4f5bc47cc5bf5cbd9fac289a41 (diff) |
avoid dependencies between different test classes extending ActivityInstrumentationTestCase2
Diffstat (limited to 'app/src/androidTest/java/se')
-rw-r--r-- | app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboardFragment.java | 47 | ||||
-rw-r--r-- | app/src/androidTest/java/se/leap/bitmaskclient/test/TestConfigurationWizard.java | 41 |
2 files changed, 49 insertions, 39 deletions
diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboardFragment.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboardFragment.java index aef968b8..3e572c31 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboardFragment.java +++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboardFragment.java @@ -1,13 +1,15 @@ package se.leap.bitmaskclient.test; -import android.content.*; -import android.graphics.*; -import android.test.*; -import android.view.*; +import android.content.Context; +import android.graphics.Rect; +import android.test.ActivityInstrumentationTestCase2; +import android.view.View; -import com.robotium.solo.*; +import com.robotium.solo.Solo; -import se.leap.bitmaskclient.*; +import se.leap.bitmaskclient.ConfigurationWizard; +import se.leap.bitmaskclient.Dashboard; +import se.leap.bitmaskclient.R; public abstract class BaseTestDashboardFragment extends ActivityInstrumentationTestCase2<Dashboard> { @@ -28,8 +30,9 @@ public abstract class BaseTestDashboardFragment extends ActivityInstrumentationT vpn_controller = new VpnTestController(solo); ConnectionManager.setMobileDataEnabled(true, context); solo.unlockScreen(); - if (solo.searchText(solo.getString(R.string.configuration_wizard_title))) - new testConfigurationWizard(solo).toDashboardAnonymously("demo.bitmask.net"); + if (solo.searchText(solo.getString(R.string.configuration_wizard_title))) { + toDashboardAnonymously("demo.bitmask.net"); + } } void changeProviderAndLogIn(String provider) { @@ -60,4 +63,32 @@ public abstract class BaseTestDashboardFragment extends ActivityInstrumentationT view.getHitRect(scrollBounds); return view.getLocalVisibleRect(scrollBounds); } + + + private void toDashboardAnonymously(String provider) { + selectProvider(provider); + useAnonymously(); + } + + private void useAnonymously() { + String text = solo.getString(R.string.use_anonymously_button); + clickAndWaitForDashboard(text); + } + + + private void selectProvider(String provider) { + solo.clickOnText(provider); + Screenshot.setTimeToSleep(1); + Screenshot.take("Configuring provider"); + waitForProviderDetails(); + } + + private void waitForProviderDetails() { + String text = solo.getString(R.string.provider_details_fragment_title); + assertTrue("Provider details dialog did not appear", solo.waitForText(text, 1, 60*1000)); + Screenshot.take("Provider details"); + } + + + } 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 1e1dbe4b..90b8b839 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/TestConfigurationWizard.java +++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/TestConfigurationWizard.java @@ -1,43 +1,36 @@ package se.leap.bitmaskclient.test; -import android.os.Build; -import android.test.*; -import android.widget.*; +import android.test.ActivityInstrumentationTestCase2; +import android.widget.ListView; -import com.robotium.solo.*; +import com.robotium.solo.Solo; -import java.io.*; +import java.io.IOException; -import se.leap.bitmaskclient.*; +import se.leap.bitmaskclient.AboutActivity; +import se.leap.bitmaskclient.ConfigurationWizard; +import se.leap.bitmaskclient.R; -public class testConfigurationWizard extends ActivityInstrumentationTestCase2<ConfigurationWizard> { +public class TestConfigurationWizard extends ActivityInstrumentationTestCase2<ConfigurationWizard> { private Solo solo; private static int added_providers; - private boolean executing_from_dashboard = false; - public testConfigurationWizard() { + public TestConfigurationWizard() { super(ConfigurationWizard.class); } - public testConfigurationWizard(Solo solo) { - super(ConfigurationWizard.class); - this.solo = solo; - executing_from_dashboard = true; - } @Override protected void setUp() throws Exception { super.setUp(); solo = new Solo(getInstrumentation(), getActivity()); Screenshot.initialize(solo); - //ConnectionManager.setMobileDataEnabled(true, solo.getCurrentActivity().getApplicationContext()); } @Override protected void tearDown() throws Exception { - if(!executing_from_dashboard) - solo.finishOpenedActivities(); + solo.finishOpenedActivities(); super.tearDown(); } @@ -111,18 +104,4 @@ public class testConfigurationWizard extends ActivityInstrumentationTestCase2<Co assertTrue("Provider details dialog did not appear", solo.waitForActivity(AboutActivity.class)); } - protected void toDashboardAnonymously(String provider) { - selectProvider(provider); - useAnonymously(); - } - - private void useAnonymously() { - String text = solo.getString(R.string.use_anonymously_button); - clickAndWaitForDashboard(text); - } - - private void clickAndWaitForDashboard(String click_text) { - solo.clickOnText(click_text); - assertTrue(solo.waitForActivity(Dashboard.class, 5000)); - } } |