From ffc2a0cbae78aa71e7ca5a64c76b75f1c5bba664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Wed, 24 Jun 2015 19:05:39 +0200 Subject: Tuned some times, refactoring tests --- .../leap/bitmaskclient/test/BaseTestDashboard.java | 61 --------------------- .../test/BaseTestDashboardFragment.java | 63 ++++++++++++++++++++++ .../se/leap/bitmaskclient/test/Screenshot.java | 3 +- .../leap/bitmaskclient/test/VpnTestController.java | 2 +- .../test/testConfigurationWizard.java | 5 ++ .../test/testDashboardIntegration.java | 12 +---- .../bitmaskclient/test/testUserStatusFragment.java | 5 +- .../leap/bitmaskclient/test/testVpnFragment.java | 11 +--- 8 files changed, 77 insertions(+), 85 deletions(-) delete mode 100644 app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboard.java create mode 100644 app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboardFragment.java (limited to 'app/src/androidTest/java') diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboard.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboard.java deleted file mode 100644 index 9a9131fd..00000000 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboard.java +++ /dev/null @@ -1,61 +0,0 @@ -package se.leap.bitmaskclient.test; - -import android.content.*; -import android.graphics.*; -import android.test.*; -import android.view.*; - -import com.robotium.solo.*; - -import se.leap.bitmaskclient.*; - -public abstract class BaseTestDashboard extends ActivityInstrumentationTestCase2 { - - Solo solo; - Context context; - UserStatusTestController user_status_controller; - VpnTestController vpn_controller; - - public BaseTestDashboard() { super(Dashboard.class); } - - @Override - protected void setUp() throws Exception { - super.setUp(); - context = getInstrumentation().getContext(); - solo = new Solo(getInstrumentation(), getActivity()); - 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))) - new testConfigurationWizard(solo).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(ConfigurationWizard.class); - } - - private void useRegistered() { - 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.clickOnText(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); - } -} diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboardFragment.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboardFragment.java new file mode 100644 index 00000000..aef968b8 --- /dev/null +++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboardFragment.java @@ -0,0 +1,63 @@ +package se.leap.bitmaskclient.test; + +import android.content.*; +import android.graphics.*; +import android.test.*; +import android.view.*; + +import com.robotium.solo.*; + +import se.leap.bitmaskclient.*; + +public abstract class BaseTestDashboardFragment extends ActivityInstrumentationTestCase2 { + + 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))) + new testConfigurationWizard(solo).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(ConfigurationWizard.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.clickOnText(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); + } +} diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/Screenshot.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/Screenshot.java index 91d51402..ade28b73 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/Screenshot.java +++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/Screenshot.java @@ -26,8 +26,7 @@ public class Screenshot { } public static void take() { - sleepBefore(); - solo.takeScreenshot(default_name + "_" + getTimeStamp()); + take(default_name + "_" + getTimeStamp()); } public static void takeWithSleep() { diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/VpnTestController.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/VpnTestController.java index 25d81da1..39ab37dd 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/VpnTestController.java +++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/VpnTestController.java @@ -79,7 +79,7 @@ public class VpnTestController { a = whole_icon != null ? (ProgressRingView) getVpnWholeIcon().findViewById(R.id.fabbutton_ring) : new ProgressRingView(solo.getCurrentActivity()); - BaseTestDashboard.isShownWithinConfinesOfVisibleScreen(a); + BaseTestDashboardFragment.isShownWithinConfinesOfVisibleScreen(a); } private boolean iconShowsConnected() { 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 931457ee..8b897b96 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/test/testConfigurationWizard.java +++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/testConfigurationWizard.java @@ -29,6 +29,7 @@ public class testConfigurationWizard extends ActivityInstrumentationTestCase2