diff options
author | cyBerta <cyberta@riseup.net> | 2018-01-29 16:12:02 +0100 |
---|---|---|
committer | cyBerta <cyberta@riseup.net> | 2018-01-29 16:12:02 +0100 |
commit | 5c158ea0b57c116744b33392fcd5ebcac21f8fe0 (patch) | |
tree | 9fa11d892e5b419b5381e6f555c0c879e3c36cf6 /app/src/androidTest/legacy/BaseTestDashboardFragment.java | |
parent | a22a22d8fffb312b0d6dfdf545ff6fe6f05dbcee (diff) |
#8818 keep legacy ui tests in seperate foler until tests are reimplemented
Diffstat (limited to 'app/src/androidTest/legacy/BaseTestDashboardFragment.java')
-rw-r--r-- | app/src/androidTest/legacy/BaseTestDashboardFragment.java | 94 |
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"); + } + + + +} |