summaryrefslogtreecommitdiff
path: root/app/src/androidTest
diff options
context:
space:
mode:
authorcyberta <cyberta@riseup.net>2023-01-23 19:47:56 +0100
committercyberta <cyberta@riseup.net>2023-01-23 19:47:56 +0100
commit7d0a1f8d8057faa74035de0cee262a46c6fbbe00 (patch)
treebeb7ae926be396c9faff6978677d74c466d3e20f /app/src/androidTest
parenta800ef1e82c25207a842c197190b614e43739051 (diff)
setup fastlane to create screenshots for Bitmask and custom branded clients, refactor Tests accordingly and create a script and environment variables to run fastlane screenshotting without thinking
Diffstat (limited to 'app/src/androidTest')
-rw-r--r--app/src/androidTest/java/se/leap/bitmaskclient/base/ProviderBaseTest.java (renamed from app/src/androidTest/java/se/leap/bitmaskclient/base/VpnStartTest.java)31
-rw-r--r--app/src/androidTest/java/se/leap/bitmaskclient/base/ProviderSetupTest.java68
-rw-r--r--app/src/androidTest/java/se/leap/bitmaskclient/suite/ScreenshotTest.java19
-rw-r--r--app/src/androidTest/java/utils/CustomInteractions.java1
4 files changed, 7 insertions, 112 deletions
diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/base/VpnStartTest.java b/app/src/androidTest/java/se/leap/bitmaskclient/base/ProviderBaseTest.java
index 6c99b90e..bbfcdc8b 100644
--- a/app/src/androidTest/java/se/leap/bitmaskclient/base/VpnStartTest.java
+++ b/app/src/androidTest/java/se/leap/bitmaskclient/base/ProviderBaseTest.java
@@ -1,6 +1,5 @@
package se.leap.bitmaskclient.base;
-
import static android.content.Context.MODE_PRIVATE;
import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
import static androidx.test.espresso.Espresso.onData;
@@ -48,7 +47,7 @@ import tools.fastlane.screengrab.locale.LocaleTestRule;
@LargeTest
@RunWith(AndroidJUnit4.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class VpnStartTest {
+public abstract class ProviderBaseTest {
@ClassRule
public static final LocaleTestRule localeTestRule = new LocaleTestRule();
@@ -65,7 +64,7 @@ public class VpnStartTest {
}
@Test
- public void test01_vpnStartTest() {
+ public void test01_vpnStartTest() throws InterruptedException {
boolean configurationNeeded = configureProviderIfNeeded();
ViewInteraction mainButtonStop;
@@ -77,12 +76,7 @@ public class VpnStartTest {
);
mainButton.perform(click());
- tryResolve(
- onView(allOf(
- withId(R.id.button),
- withTagValue(is("button_circle_cancel")))),
- matches(isDisplayed()),
- 2);
+ Thread.sleep(50);
Screengrab.screenshot("VPN_connecting");
mainButtonStop = tryResolve(
@@ -97,8 +91,8 @@ public class VpnStartTest {
Screengrab.screenshot("VPN_connecting");
mainButtonStop = tryResolve(
onView(allOf(
- withId(R.id.button),
- withTagValue(is("button_circle_stop")))),
+ withId(R.id.button),
+ withTagValue(is("button_circle_stop")))),
matches(isDisplayed()),
20);
Screengrab.screenshot("VPN_connected");
@@ -159,18 +153,5 @@ public class VpnStartTest {
Screengrab.screenshot("App_Exclusion_Fragment");
}
- public boolean configureProviderIfNeeded() {
- try {
- DataInteraction linearLayout = tryResolve(onData(hasToString(containsString("riseup.net")))
- .inAdapterView(withId(R.id.provider_list)),
- 2);
- linearLayout.perform(click());
- return true;
- } catch (NoMatchingViewException e) {
- // it might be that the provider was already configured, so we print the stack
- // trace here and try to continue
- e.printStackTrace();
- }
- return false;
- }
+ public abstract boolean configureProviderIfNeeded();
}
diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/base/ProviderSetupTest.java b/app/src/androidTest/java/se/leap/bitmaskclient/base/ProviderSetupTest.java
deleted file mode 100644
index 23db8582..00000000
--- a/app/src/androidTest/java/se/leap/bitmaskclient/base/ProviderSetupTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package se.leap.bitmaskclient.base;
-
-
-import static android.content.Context.MODE_PRIVATE;
-import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
-import static androidx.test.espresso.Espresso.onData;
-import static androidx.test.espresso.action.ViewActions.click;
-import static androidx.test.espresso.matcher.ViewMatchers.withId;
-import static org.hamcrest.Matchers.anything;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.hasToString;
-import static se.leap.bitmaskclient.base.models.Constants.SHARED_PREFERENCES;
-import static utils.CustomInteractions.tryResolve;
-
-import android.content.SharedPreferences;
-
-import androidx.test.espresso.DataInteraction;
-import androidx.test.espresso.NoMatchingViewException;
-import androidx.test.ext.junit.rules.ActivityScenarioRule;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.filters.LargeTest;
-
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import se.leap.bitmaskclient.R;
-import se.leap.bitmaskclient.providersetup.ProviderListActivity;
-import tools.fastlane.screengrab.Screengrab;
-import tools.fastlane.screengrab.UiAutomatorScreenshotStrategy;
-import tools.fastlane.screengrab.locale.LocaleTestRule;
-
-@LargeTest
-@RunWith(AndroidJUnit4.class)
-public class ProviderSetupTest {
-
- @ClassRule
- public static final LocaleTestRule localeTestRule = new LocaleTestRule();
-
- @Rule
- public ActivityScenarioRule<ProviderListActivity> mActivityScenarioRule =
- new ActivityScenarioRule<>(ProviderListActivity.class);
-
- @Before
- public void setup() {
- Screengrab.setDefaultScreenshotStrategy(new UiAutomatorScreenshotStrategy());
- SharedPreferences preferences = getApplicationContext().getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
- preferences.edit().clear().commit();
- }
-
- @Test
- public void testConfigureRiseupVPNScreenshot() {
- DataInteraction linearLayout = tryResolve(onData(hasToString(containsString("riseup.net")))
- .inAdapterView(withId(R.id.provider_list)),
- 2);
- Screengrab.screenshot("ProviderListActivity");
- linearLayout.perform(click());
- Screengrab.screenshot("ProviderListActivity_configureRiseup");
- }
-
- @Test
- public void testaddManuallyNewProviderScreenshot() {
- onData(anything()).inAdapterView(withId(R.id.provider_list)).atPosition(3).perform(click());
- Screengrab.screenshot("ProviderListActivity_addManuallyNewProvider");
- }
-}
diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/suite/ScreenshotTest.java b/app/src/androidTest/java/se/leap/bitmaskclient/suite/ScreenshotTest.java
deleted file mode 100644
index 186a50d1..00000000
--- a/app/src/androidTest/java/se/leap/bitmaskclient/suite/ScreenshotTest.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package se.leap.bitmaskclient.suite;
-
-
-import androidx.test.filters.LargeTest;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-import se.leap.bitmaskclient.base.ProviderSetupTest;
-import se.leap.bitmaskclient.base.VpnStartTest;
-
-@LargeTest
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- ProviderSetupTest.class,
- VpnStartTest.class,
-})
-public class ScreenshotTest {
-}
diff --git a/app/src/androidTest/java/utils/CustomInteractions.java b/app/src/androidTest/java/utils/CustomInteractions.java
index 896e8d9b..9e3a8f9d 100644
--- a/app/src/androidTest/java/utils/CustomInteractions.java
+++ b/app/src/androidTest/java/utils/CustomInteractions.java
@@ -31,6 +31,7 @@ public class CustomInteractions {
hasFound = true;
} catch (NoMatchingViewException exception) {
System.out.println("NoMatchingViewException attempt: " + attempt);
+ exception.printStackTrace();
attempt++;
if (attempt == maxTries) {
throw exception;