summaryrefslogtreecommitdiff
path: root/app/src/androidTest/legacy/BaseTestDashboardFragment.java
diff options
context:
space:
mode:
authorFup Duck <fupduck@sacknagel.com>2018-02-06 18:06:38 +0100
committerFup Duck <fupduck@sacknagel.com>2018-02-06 18:06:38 +0100
commit43fd861a1404293185bced6095410900c2417b65 (patch)
tree03326353b89b6327024ee0ee03b03b622e753279 /app/src/androidTest/legacy/BaseTestDashboardFragment.java
parent8bb96b0116994897ca75ad8eb1d6c412e7d3ce40 (diff)
parentedd34192484f4eb618fdcc2a68b18168c155d63c (diff)
8827 - remove UserStatus references
Diffstat (limited to 'app/src/androidTest/legacy/BaseTestDashboardFragment.java')
-rw-r--r--app/src/androidTest/legacy/BaseTestDashboardFragment.java94
1 files changed, 94 insertions, 0 deletions
diff --git a/app/src/androidTest/legacy/BaseTestDashboardFragment.java b/app/src/androidTest/legacy/BaseTestDashboardFragment.java
new file mode 100644
index 00000000..e187d424
--- /dev/null
+++ b/app/src/androidTest/legacy/BaseTestDashboardFragment.java
@@ -0,0 +1,94 @@
+package se.leap.bitmaskclient.test;
+
+import android.content.Context;
+import android.graphics.Rect;
+import android.test.ActivityInstrumentationTestCase2;
+import android.view.View;
+
+import com.robotium.solo.Solo;
+
+import se.leap.bitmaskclient.ProviderListActivity;
+import se.leap.bitmaskclient.Dashboard;
+import se.leap.bitmaskclient.R;
+
+public abstract class BaseTestDashboardFragment extends ActivityInstrumentationTestCase2<Dashboard> {
+
+ Solo solo;
+ Context context;
+ UserStatusTestController user_status_controller;
+ VpnTestController vpn_controller;
+
+ public BaseTestDashboardFragment() { super(Dashboard.class); }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ context = getInstrumentation().getContext();
+ solo = new Solo(getInstrumentation(), getActivity());
+ Screenshot.initialize(solo);
+ user_status_controller = new UserStatusTestController(solo);
+ vpn_controller = new VpnTestController(solo);
+ ConnectionManager.setMobileDataEnabled(true, context);
+ solo.unlockScreen();
+ if (solo.searchText(solo.getString(R.string.configuration_wizard_title))) {
+ toDashboardAnonymously("demo.bitmask.net");
+ }
+ }
+
+ void changeProviderAndLogIn(String provider) {
+ tapSwitchProvider();
+ solo.clickOnText(provider);
+ useRegistered();
+ }
+
+ void tapSwitchProvider() {
+ solo.clickOnMenuItem(solo.getString(R.string.switch_provider_menu_option));
+ solo.waitForActivity(ProviderListActivity.class);
+ }
+
+ private void useRegistered() {
+ solo.waitForFragmentById(R.id.provider_detail_fragment);
+ String text = solo.getString(R.string.signup_or_login_button);
+ clickAndWaitForDashboard(text);
+ user_status_controller.logIn("parmegvtest10", "holahola2");
+ }
+
+ private void clickAndWaitForDashboard(String click_text) {
+ solo.clickOnButton(click_text);
+ assertTrue(solo.waitForActivity(Dashboard.class, 80 * 1000));
+ }
+
+ static boolean isShownWithinConfinesOfVisibleScreen(View view) {
+ Rect scrollBounds = new Rect();
+ 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_title);
+ assertTrue("Provider details dialog did not appear", solo.waitForText(text, 1, 60*1000));
+ Screenshot.take("Provider details");
+ }
+
+
+
+}