diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/BitmaskTest.java b/app/src/androidTest/java/se/leap/bitmaskclient/BitmaskTest.java index 1ca0980a82b713852457ad8e4f7a19e69ca81954..66669842db9eb51e514e402eec682766eba1fac0 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/BitmaskTest.java +++ b/app/src/androidTest/java/se/leap/bitmaskclient/BitmaskTest.java @@ -66,23 +66,23 @@ public class BitmaskTest { public void test01_vpnStartTest() throws InterruptedException, UiObjectNotFoundException { startMainActivity(); - Screengrab.screenshot("VPN_connecting"); + Screengrab.screenshot("02_VPN_connecting"); ViewInteraction mainButtonStop = CustomInteractions.tryResolve( Espresso.onView(Matchers.allOf( ViewMatchers.withId(R.id.button), ViewMatchers.withTagValue(Matchers.is("button_circle_stop")))), ViewAssertions.matches(ViewMatchers.isDisplayed()), 20); - Screengrab.screenshot("VPN_connected"); + Screengrab.screenshot("01_VPN_connected"); mainButtonStop.perform(ViewActions.click()); - Screengrab.screenshot("VPN_ask_disconnect"); + Screengrab.screenshot("03_VPN_ask_disconnect"); Espresso.onView(ViewMatchers.withText(android.R.string.yes)) .inRoot(RootMatchers.isDialog()) .check(ViewAssertions.matches(ViewMatchers.isDisplayed())) .perform(ViewActions.click()); - Screengrab.screenshot("VPN_disconnected"); + Screengrab.screenshot("04_VPN_disconnected"); } @Test @@ -92,13 +92,13 @@ public class BitmaskTest { .check(ViewAssertions.matches(DrawerMatchers.isClosed(Gravity.LEFT))) // Left Drawer should be closed. .perform(DrawerActions.open()); // Open Drawer - Screengrab.screenshot("navigationDrawer"); + Screengrab.screenshot("05_navigationDrawer"); // Start the screen of your activity. Espresso.onView(ViewMatchers.withId(R.id.advancedSettings)) .perform(ViewActions.click()); - Screengrab.screenshot("settingsFragment"); + Screengrab.screenshot("06_settingsFragment"); } @Test @@ -111,7 +111,7 @@ public class BitmaskTest { Espresso.onView(ViewMatchers.withId(R.id.manualGatewaySelection)) .perform(ViewActions.click()); - Screengrab.screenshot("GatewaySelectionFragment"); + Screengrab.screenshot("07_GatewaySelectionFragment"); } @Test @@ -130,7 +130,7 @@ public class BitmaskTest { ViewAssertions.matches(ViewMatchers.isDisplayed()), 5); - Screengrab.screenshot("App_Exclusion_Fragment"); + Screengrab.screenshot("08_App_Exclusion_Fragment"); } private void startMainActivity() { diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/ProviderSetupFailureTest.java b/app/src/androidTest/java/se/leap/bitmaskclient/ProviderSetupFailureTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d133e432120a290e348e1335291bd2f3248e459c --- /dev/null +++ b/app/src/androidTest/java/se/leap/bitmaskclient/ProviderSetupFailureTest.java @@ -0,0 +1,102 @@ +package se.leap.bitmaskclient; + + +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.action.ViewActions.replaceText; +import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static androidx.test.espresso.matcher.ViewMatchers.withText; +import static org.junit.Assert.assertNotNull; +import static se.leap.bitmaskclient.base.models.Constants.SHARED_ENCRYPTED_PREFERENCES; +import static utils.CustomInteractions.tryResolve; + +import android.app.Activity; +import android.app.Instrumentation; +import android.content.Context; +import android.content.Intent; + +import androidx.test.espresso.ViewInteraction; +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.filters.LargeTest; +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.uiautomator.UiDevice; + +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; + +import se.leap.bitmaskclient.base.StartActivity; +import se.leap.bitmaskclient.base.models.Provider; +import se.leap.bitmaskclient.base.models.ProviderObservable; +import se.leap.bitmaskclient.providersetup.activities.SetupActivity; +import tools.fastlane.screengrab.Screengrab; +import tools.fastlane.screengrab.UiAutomatorScreenshotStrategy; +import tools.fastlane.screengrab.locale.LocaleTestRule; +import utils.ProviderSetupUtils; + +@LargeTest +@RunWith(AndroidJUnit4.class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class ProviderSetupFailureTest { + + @ClassRule + public static final LocaleTestRule localeTestRule = new LocaleTestRule(); + + // @Rule + // public ActivityScenarioRule<SetupActivity> mActivityScenarioRule = + // new ActivityScenarioRule<>(SetupActivity.class); + + UiDevice device; + + @Before + public void setup() { + Screengrab.setDefaultScreenshotStrategy(new UiAutomatorScreenshotStrategy()); + //PreferenceHelper.clear(); + Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); + device = UiDevice.getInstance(instrumentation); + instrumentation.getTargetContext().deleteSharedPreferences(SHARED_ENCRYPTED_PREFERENCES); + ProviderObservable.getInstance().updateProvider(new Provider()); + } + + @Test + public void test01_addManuallyNewProviderScreenshot() { + if (!"normal".equals(BuildConfig.FLAVOR_branding)) { + System.out.println("skipping custom provider url test"); + return; + } + startSetupActivity(); + Context context = InstrumentationRegistry.getInstrumentation().getTargetContext(); + + ViewInteraction radioButtonSelection = tryResolve(onView(withText(R.string.add_provider)), matches(isDisplayed())); + radioButtonSelection.perform(click()); + onView(withId(R.id.edit_customProvider)).perform(replaceText("https://leapvpn.myserver.org")); + tryResolve(onView(withId(R.id.edit_customProvider)), matches(withText("https://leapvpn.myserver.org"))); + Screengrab.screenshot("20_setup_custom_provider"); + onView(withId(R.id.setup_next_button)).perform(click()); + + onView(withText(context.getString(R.string.use_standard_vpn, context.getString(R.string.app_name)))).perform(click()); + onView(withId(R.id.setup_next_button)).perform(click()); + + tryResolve( + onView(withText(context.getString(R.string.malformed_url, context.getString(R.string.app_name)))), + matches(isDisplayed()), + 20); + Screengrab.screenshot("21_setup_provider_error_dialog"); + } + + private void startSetupActivity() { + Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); + Instrumentation.ActivityMonitor setupActivityMonitor = new Instrumentation.ActivityMonitor(SetupActivity.class.getName(), null, false); + instrumentation.addMonitor(setupActivityMonitor); + Intent intent = new Intent(instrumentation.getTargetContext(), StartActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + instrumentation.startActivitySync(intent); + Activity setupActivity = instrumentation.waitForMonitorWithTimeout(setupActivityMonitor, 1000L); + assertNotNull(setupActivity); + } +} diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/ProviderSetupTest.java b/app/src/androidTest/java/se/leap/bitmaskclient/ProviderSetupTest.java index dedb40d78f89bde87b72e11b89c420f9f3dc47b2..4e4e677e8c771304f4917801c1a6d9670b5a6282 100644 --- a/app/src/androidTest/java/se/leap/bitmaskclient/ProviderSetupTest.java +++ b/app/src/androidTest/java/se/leap/bitmaskclient/ProviderSetupTest.java @@ -78,7 +78,6 @@ public class ProviderSetupTest { startSetupActivity(); ProviderSetupUtils.runProviderSetup(device, true, true, InstrumentationRegistry.getInstrumentation().getTargetContext()); } - @Test public void test03_addManuallyNewProviderScreenshot() { if (!"normal".equals(BuildConfig.FLAVOR_branding)) { @@ -86,23 +85,12 @@ public class ProviderSetupTest { return; } startSetupActivity(); - Context context = InstrumentationRegistry.getInstrumentation().getTargetContext(); ViewInteraction radioButtonSelection = tryResolve(onView(withText(R.string.add_provider)), matches(isDisplayed())); radioButtonSelection.perform(click()); onView(withId(R.id.edit_customProvider)).perform(replaceText("https://leapvpn.myserver.org")); tryResolve(onView(withId(R.id.edit_customProvider)), matches(withText("https://leapvpn.myserver.org"))); - Screengrab.screenshot("setup_custom_provider"); - onView(withId(R.id.setup_next_button)).perform(click()); - - onView(withText(context.getString(R.string.use_standard_vpn, context.getString(R.string.app_name)))).perform(click()); - onView(withId(R.id.setup_next_button)).perform(click()); - - tryResolve( - onView(withText(context.getString(R.string.malformed_url, context.getString(R.string.app_name)))), - matches(isDisplayed()), - 20); - Screengrab.screenshot("setup_provider_error_dialog"); + Screengrab.screenshot("10_setup_custom_provider"); } private void startSetupActivity() { diff --git a/app/src/androidTest/java/utils/ProviderSetupUtils.java b/app/src/androidTest/java/utils/ProviderSetupUtils.java index 9b76ffbd306b261bd6cb52252b938162de02a45e..4cd25fdde69b92d7af6fdb942983d5f07a4d7a6f 100644 --- a/app/src/androidTest/java/utils/ProviderSetupUtils.java +++ b/app/src/androidTest/java/utils/ProviderSetupUtils.java @@ -35,7 +35,7 @@ public class ProviderSetupUtils { if ("normal".equals(BuildConfig.FLAVOR_branding)) { System.out.println("next: provider selection"); ViewInteraction radioButtonSelection = tryResolve(onView(withText("Riseup")), matches(isDisplayed())); - if (takeConfigurationScreenshots) Screengrab.screenshot("provider_selection"); + if (takeConfigurationScreenshots) Screengrab.screenshot("10_provider_selection"); radioButtonSelection.perform(click()); // next button click onView(withText(R.string.next)).perform(click()); @@ -48,7 +48,7 @@ public class ProviderSetupUtils { } else { onView(withText(targetContext.getString(R.string.use_standard_vpn, targetContext.getString(R.string.app_name)))).perform(click()); } - if (takeConfigurationScreenshots) Screengrab.screenshot("circumvention_selection"); + if (takeConfigurationScreenshots) Screengrab.screenshot("11_circumvention_selection"); // ------- CONFIGURATION PROGRESS -------------- System.out.println("next: configuring"); @@ -62,7 +62,7 @@ public class ProviderSetupUtils { ), matches(isDisplayed()) ); - if (takeConfigurationScreenshots) Screengrab.screenshot("configuring_provider"); + if (takeConfigurationScreenshots) Screengrab.screenshot("12_configuring_provider"); // ------- VPN PERMISSON DIALOG -------------- boolean showPermissionDialog = false; @@ -70,7 +70,7 @@ public class ProviderSetupUtils { showPermissionDialog = true; tryResolve(onView(withText(R.string.upcoming_connection_request_description)), matches(isDisplayed()), useCircumvention ? 180 : 20); System.out.println("next: next permission request"); - if (takeConfigurationScreenshots) Screengrab.screenshot("vpn_permission_rationale"); + if (takeConfigurationScreenshots) Screengrab.screenshot("13_vpn_permission_rationale"); onView(withText(R.string.next)).perform(click()); UiObject okButton = device.findObject(new UiSelector().packageName("com.android.vpndialogs").resourceId("android:id/button1")); okButton.waitForExists(30000); @@ -82,7 +82,7 @@ public class ProviderSetupUtils { System.out.println("next: perform click on VPN button"); ViewInteraction interaction = tryResolve(onView(withTagValue(Matchers.is("button_setup_circle_custom"))), matches(isDisplayed()), useCircumvention && !showPermissionDialog ? 180 : 20); if (takeConfigurationScreenshots) { - Screengrab.screenshot("all_set_start_vpn"); + Screengrab.screenshot("14_all_set_start_vpn"); } else { // we only want to start the VPN in case we're not running the ProviderSetupTest interaction.perform(click()); diff --git a/fastlane/Screengrabfile b/fastlane/Screengrabfile index 317583b017d3a89a6b4b0304bc0b689aa519fe4f..d17e73a7ae839712fbbb05c8ed4ee6c38ce5414c 100644 --- a/fastlane/Screengrabfile +++ b/fastlane/Screengrabfile @@ -6,9 +6,9 @@ use_timestamp_suffix(false) # all locales # locales(['ar', 'az', 'bg', 'bn', 'br', 'ca', 'cs', 'de', 'el', 'es', 'es-AR', 'et', 'eu', 'fa-IR', 'fi', 'fr', 'gl', 'he', 'hr', 'hu', 'id', 'it', 'ja', 'my', 'nl', 'no', 'pl', 'pt-BR', 'pt-PT', 'ro', 'ru', 'tr', 'ug', 'uk', 'vi', 'zh-CN', 'zh-TW']) # prioritized locales -# locales(['ar', 'bn', 'de', 'es', 'fa-IR', 'fr', 'he', 'hu', 'id', 'it', 'ja', 'my', 'nl', 'pt-BR', 'pt-PT', 'ru', 'tr', 'ug', 'uk', 'zh-CN', 'zh-TW']) +locales(['ru', 'de', 'el', 'lt', 'pt-BR', 'ar', 'es-CU', 'tr', 'nl', 'es', 'zh']) # development locales -locales(['ar', 'de', 'ru']) +# locales(['ar', 'de', 'ru']) # clear all previously generated screenshots in your local output directory before creating new ones clear_previous_screenshots(true)