From f18586021373e07162808f7a1d69587302358b28 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Wed, 14 Apr 2021 10:57:49 -0300 Subject: [PATCH 1/2] Allow emulator tests to run also on a schedule Also do 1 retry in case of failure --- .gitlab-ci.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9fd196c5a..b2755a66b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -46,9 +46,17 @@ android test: - screenshots expire_in: 3 days when: on_failure - when: manual - except: - - tags + rules: + - if: '$CI_PIPELINE_SOURCE == "schedule"' + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' + changes: + - briar-android/**/* + when: manual + allow_failure: true + retry: + max: 1 + when: + - script_failure tags: - kvm From 2fc0fd17a2e3a7d181c7a41368ce76f9dea7308d Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Wed, 14 Apr 2021 11:43:31 -0300 Subject: [PATCH 2/2] Fix SettingsActivityScreenshotTest --- .../SettingsActivityScreenshotTest.java | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/briar-android/src/androidTestScreenshot/java/org/briarproject/briar/android/settings/SettingsActivityScreenshotTest.java b/briar-android/src/androidTestScreenshot/java/org/briarproject/briar/android/settings/SettingsActivityScreenshotTest.java index c396a835a..d42b2a82f 100644 --- a/briar-android/src/androidTestScreenshot/java/org/briarproject/briar/android/settings/SettingsActivityScreenshotTest.java +++ b/briar-android/src/androidTestScreenshot/java/org/briarproject/briar/android/settings/SettingsActivityScreenshotTest.java @@ -11,7 +11,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import androidx.recyclerview.widget.RecyclerView; import androidx.test.espresso.contrib.DrawerActions; import androidx.test.ext.junit.runners.AndroidJUnit4; @@ -20,17 +19,13 @@ import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.click; import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.contrib.DrawerMatchers.isClosed; -import static androidx.test.espresso.contrib.RecyclerViewActions.scrollTo; -import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.isEnabled; import static androidx.test.espresso.matcher.ViewMatchers.withChild; -import static androidx.test.espresso.matcher.ViewMatchers.withClassName; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static org.briarproject.briar.android.ViewActions.waitUntilMatches; import static org.briarproject.briar.android.util.UiUtils.hasScreenLock; -import static org.hamcrest.CoreMatchers.is; import static org.junit.Assume.assumeTrue; @RunWith(AndroidJUnit4.class) @@ -50,6 +45,10 @@ public class SettingsActivityScreenshotTest extends ScreenshotTest { onView(withText(R.string.settings_button)) .check(matches(isDisplayed())); + onView(withText(R.string.display_settings_title)) + .perform(waitUntilMatches(isDisplayed())) + .perform(click(), click()); + screenshot("manual_dark_theme_settings", testRule.getActivity()); // switch to dark theme @@ -68,6 +67,9 @@ public class SettingsActivityScreenshotTest extends ScreenshotTest { onView(withText(R.string.settings_button)) .check(matches(isDisplayed())) .perform(click()); + onView(withText(R.string.display_settings_title)) + .check(matches(isDisplayed())) + .perform(click()); onView(withText(R.string.pref_theme_title)) .check(matches(isDisplayed())) .perform(click()); @@ -80,20 +82,15 @@ public class SettingsActivityScreenshotTest extends ScreenshotTest { public void appLock() { assumeTrue("device has no screen lock", hasScreenLock(getApplicationContext())); - // scroll down - onView(withClassName(is(RecyclerView.class.getName()))) - .perform(scrollTo(hasDescendant( - // scroll down a bit more to have settings in the middle - withText(R.string.panic_setting)))); - // wait for settings to get loaded and enabled - onView(withText(R.string.tor_mobile_data_title)) - .perform(waitUntilMatches(isEnabled())); + onView(withText(R.string.security_settings_title)) + .perform(waitUntilMatches(isDisplayed())) + .perform(click(), click()); // ensure app lock is displayed and enabled onView(withText(R.string.pref_lock_title)) .check(matches(isDisplayed())) - .check(matches(isEnabled())) + .perform(waitUntilMatches(isEnabled())) .perform(click()); onView(withChild(withText(R.string.pref_lock_timeout_title))) .check(matches(isDisplayed())) @@ -108,11 +105,10 @@ public class SettingsActivityScreenshotTest extends ScreenshotTest { @Test public void torSettings() { - // scroll down - onView(withClassName(is(RecyclerView.class.getName()))) - .perform(scrollTo(hasDescendant( - // scroll down a bit more to have settings in the middle - withText(R.string.pref_lock_timeout_title)))); + // click network/connections settings + onView(withText(R.string.network_settings_title)) + .perform(waitUntilMatches(isDisplayed())) + .perform(click(), click()); // wait for settings to get loaded and enabled onView(withText(R.string.tor_network_setting))