diff --git a/briar-android/src/androidTest/java/org/briarproject/briar/android/settings/SettingsActivityScreenshotTest.java b/briar-android/src/androidTest/java/org/briarproject/briar/android/settings/SettingsActivityScreenshotTest.java index 192680bd70bc26412c8e5a29e68eebfc326ca070..34621c3941ed6ddd9c1214ba2c6b88b16c042dc3 100644 --- a/briar-android/src/androidTest/java/org/briarproject/briar/android/settings/SettingsActivityScreenshotTest.java +++ b/briar-android/src/androidTest/java/org/briarproject/briar/android/settings/SettingsActivityScreenshotTest.java @@ -3,6 +3,7 @@ package org.briarproject.briar.android.settings; import android.content.Intent; import android.support.test.espresso.contrib.DrawerActions; import android.support.test.runner.AndroidJUnit4; +import android.support.v7.widget.RecyclerView; import android.view.Gravity; import org.briarproject.briar.R; @@ -17,9 +18,16 @@ import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.action.ViewActions.click; import static android.support.test.espresso.assertion.ViewAssertions.matches; import static android.support.test.espresso.contrib.DrawerMatchers.isClosed; +import static android.support.test.espresso.contrib.RecyclerViewActions.scrollTo; +import static android.support.test.espresso.matcher.ViewMatchers.hasDescendant; import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.isEnabled; +import static android.support.test.espresso.matcher.ViewMatchers.withChild; +import static android.support.test.espresso.matcher.ViewMatchers.withClassName; import static android.support.test.espresso.matcher.ViewMatchers.withId; import static android.support.test.espresso.matcher.ViewMatchers.withText; +import static org.briarproject.briar.android.test.ViewActions.waitUntilMatches; +import static org.hamcrest.CoreMatchers.is; @RunWith(AndroidJUnit4.class) public class SettingsActivityScreenshotTest extends ScreenshotTest { @@ -48,23 +56,75 @@ public class SettingsActivityScreenshotTest extends ScreenshotTest { .check(matches(isDisplayed())) .perform(click()); + // open nav drawer and remove expiry warning + openNavDrawer(true); + + screenshot("manual_dark_theme_nav_drawer"); + } + + @Test + public void appLock() { + // 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())); + + // ensure app lock is displayed and enabled + onView(withText(R.string.pref_lock_title)) + .check(matches(isDisplayed())) + .check(matches(isEnabled())) + .perform(click()); + onView(withChild(withText(R.string.pref_lock_timeout_title))) + .check(matches(isDisplayed())) + .check(matches(isEnabled())); + + screenshot("manual_app_lock"); + + // no more expiry warning to remove, because sharedprefs cached? + openNavDrawer(false); + + screenshot("manual_app_lock_nav_drawer"); + } + + @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)))); + + // wait for settings to get loaded and enabled + onView(withText(R.string.tor_network_setting)) + .check(matches(isDisplayed())) + .perform(waitUntilMatches(isEnabled())); + + screenshot("manual_tor_settings"); + } + + private void openNavDrawer(boolean expiry) { // start main activity Intent i = new Intent(testRule.getActivity(), NavDrawerActivity.class); testRule.getActivity().startActivity(i); // close expiry warning - onView(withId(R.id.expiryWarningClose)) - .check(matches(isDisplayed())); - onView(withId(R.id.expiryWarningClose)) - .perform(click()); + if (expiry) { + onView(withId(R.id.expiryWarningClose)) + .check(matches(isDisplayed())); + onView(withId(R.id.expiryWarningClose)) + .perform(click()); + } // open navigation drawer onView(withId(R.id.drawer_layout)) .check(matches(isClosed(Gravity.START))) .perform(DrawerActions.open()); - - screenshot("manual_dark_theme_nav_drawer"); } }