mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 05:39:53 +01:00
Fix UI tests for settings activity.
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
package org.briarproject.briar.android.settings;
|
package org.briarproject.briar.android.settings;
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
|
|
||||||
import org.briarproject.briar.R;
|
import org.briarproject.briar.R;
|
||||||
@@ -16,6 +15,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|||||||
|
|
||||||
import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
|
import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
|
||||||
import static androidx.test.espresso.Espresso.onView;
|
import static androidx.test.espresso.Espresso.onView;
|
||||||
|
import static androidx.test.espresso.Espresso.pressBack;
|
||||||
import static androidx.test.espresso.action.ViewActions.click;
|
import static androidx.test.espresso.action.ViewActions.click;
|
||||||
import static androidx.test.espresso.assertion.ViewAssertions.matches;
|
import static androidx.test.espresso.assertion.ViewAssertions.matches;
|
||||||
import static androidx.test.espresso.contrib.DrawerMatchers.isClosed;
|
import static androidx.test.espresso.contrib.DrawerMatchers.isClosed;
|
||||||
@@ -31,9 +31,11 @@ import static org.junit.Assume.assumeTrue;
|
|||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public class SettingsActivityScreenshotTest extends ScreenshotTest {
|
public class SettingsActivityScreenshotTest extends ScreenshotTest {
|
||||||
|
|
||||||
|
// Start from the nav drawer activity so we can go back to it and take
|
||||||
|
// screenshots showing the effects of changing settings
|
||||||
@Rule
|
@Rule
|
||||||
public CleanAccountTestRule<SettingsActivity> testRule =
|
public CleanAccountTestRule<NavDrawerActivity> testRule =
|
||||||
new CleanAccountTestRule<>(SettingsActivity.class);
|
new CleanAccountTestRule<>(NavDrawerActivity.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void inject(BriarUiTestComponent component) {
|
protected void inject(BriarUiTestComponent component) {
|
||||||
@@ -42,8 +44,10 @@ public class SettingsActivityScreenshotTest extends ScreenshotTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void changeTheme() {
|
public void changeTheme() {
|
||||||
|
openNavDrawer();
|
||||||
onView(withText(R.string.settings_button))
|
onView(withText(R.string.settings_button))
|
||||||
.check(matches(isDisplayed()));
|
.check(matches(isDisplayed()))
|
||||||
|
.perform(click());
|
||||||
|
|
||||||
onView(withText(R.string.display_settings_title))
|
onView(withText(R.string.display_settings_title))
|
||||||
.perform(waitUntilMatches(isDisplayed()))
|
.perform(waitUntilMatches(isDisplayed()))
|
||||||
@@ -59,6 +63,8 @@ public class SettingsActivityScreenshotTest extends ScreenshotTest {
|
|||||||
.check(matches(isDisplayed()))
|
.check(matches(isDisplayed()))
|
||||||
.perform(click());
|
.perform(click());
|
||||||
|
|
||||||
|
pressBack();
|
||||||
|
pressBack();
|
||||||
openNavDrawer();
|
openNavDrawer();
|
||||||
|
|
||||||
screenshot("manual_dark_theme_nav_drawer", testRule.getActivity());
|
screenshot("manual_dark_theme_nav_drawer", testRule.getActivity());
|
||||||
@@ -68,8 +74,8 @@ public class SettingsActivityScreenshotTest extends ScreenshotTest {
|
|||||||
.check(matches(isDisplayed()))
|
.check(matches(isDisplayed()))
|
||||||
.perform(click());
|
.perform(click());
|
||||||
onView(withText(R.string.display_settings_title))
|
onView(withText(R.string.display_settings_title))
|
||||||
.check(matches(isDisplayed()))
|
.perform(waitUntilMatches(isDisplayed()))
|
||||||
.perform(click());
|
.perform(click(), click());
|
||||||
onView(withText(R.string.pref_theme_title))
|
onView(withText(R.string.pref_theme_title))
|
||||||
.check(matches(isDisplayed()))
|
.check(matches(isDisplayed()))
|
||||||
.perform(click());
|
.perform(click());
|
||||||
@@ -83,6 +89,11 @@ public class SettingsActivityScreenshotTest extends ScreenshotTest {
|
|||||||
assumeTrue("device has no screen lock",
|
assumeTrue("device has no screen lock",
|
||||||
hasScreenLock(getApplicationContext()));
|
hasScreenLock(getApplicationContext()));
|
||||||
|
|
||||||
|
openNavDrawer();
|
||||||
|
onView(withText(R.string.settings_button))
|
||||||
|
.check(matches(isDisplayed()))
|
||||||
|
.perform(click());
|
||||||
|
|
||||||
onView(withText(R.string.security_settings_title))
|
onView(withText(R.string.security_settings_title))
|
||||||
.perform(waitUntilMatches(isDisplayed()))
|
.perform(waitUntilMatches(isDisplayed()))
|
||||||
.perform(click(), click());
|
.perform(click(), click());
|
||||||
@@ -98,6 +109,8 @@ public class SettingsActivityScreenshotTest extends ScreenshotTest {
|
|||||||
|
|
||||||
screenshot("manual_app_lock", testRule.getActivity());
|
screenshot("manual_app_lock", testRule.getActivity());
|
||||||
|
|
||||||
|
pressBack();
|
||||||
|
pressBack();
|
||||||
openNavDrawer();
|
openNavDrawer();
|
||||||
|
|
||||||
screenshot("manual_app_lock_nav_drawer", testRule.getActivity());
|
screenshot("manual_app_lock_nav_drawer", testRule.getActivity());
|
||||||
@@ -105,6 +118,11 @@ public class SettingsActivityScreenshotTest extends ScreenshotTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void torSettings() {
|
public void torSettings() {
|
||||||
|
openNavDrawer();
|
||||||
|
onView(withText(R.string.settings_button))
|
||||||
|
.check(matches(isDisplayed()))
|
||||||
|
.perform(click());
|
||||||
|
|
||||||
// click network/connections settings
|
// click network/connections settings
|
||||||
onView(withText(R.string.network_settings_title))
|
onView(withText(R.string.network_settings_title))
|
||||||
.perform(waitUntilMatches(isDisplayed()))
|
.perform(waitUntilMatches(isDisplayed()))
|
||||||
@@ -119,15 +137,8 @@ public class SettingsActivityScreenshotTest extends ScreenshotTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void openNavDrawer() {
|
private void openNavDrawer() {
|
||||||
// start main activity
|
|
||||||
Intent i =
|
|
||||||
new Intent(testRule.getActivity(), NavDrawerActivity.class);
|
|
||||||
testRule.getActivity().startActivity(i);
|
|
||||||
|
|
||||||
// open navigation drawer
|
|
||||||
onView(withId(R.id.drawer_layout))
|
onView(withId(R.id.drawer_layout))
|
||||||
.check(matches(isClosed(Gravity.START)))
|
.check(matches(isClosed(Gravity.START)))
|
||||||
.perform(DrawerActions.open());
|
.perform(DrawerActions.open());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user