summaryrefslogtreecommitdiff
path: root/app/src/androidTest/legacy/BaseTestDashboardFragment.java
diff options
context:
space:
mode:
authorFup Duck <fupduck@sacknagel.com>2018-02-06 18:34:13 +0100
committerFup Duck <fupduck@sacknagel.com>2018-02-06 18:34:13 +0100
commitb4b18f1d52956cf067f87d75d8f3f06c9be48afe (patch)
tree9191273c611e39afe7aa3401408dfa0dbc67b544 /app/src/androidTest/legacy/BaseTestDashboardFragment.java
parent6be60844db062575055752b554dbf14941e8e185 (diff)
parentedd34192484f4eb618fdcc2a68b18168c155d63c (diff)
Merge branch 'leap_0.9.8' into 8828_memory_leap_eip
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");
+ }
+
+
+
+}