From 83b69f0fd3c90cbaa4d843ba0e49e870ca6ed99e Mon Sep 17 00:00:00 2001 From: Stryker101 Date: Sat, 1 Jun 2024 20:08:26 +0100 Subject: [PATCH 01/13] Fix for UI Tests --- .../java/org/opendatakit/BaseUITest.java | 99 ++++++++++++++----- .../LoginActivity/GeneralStateTest.java | 37 ++++--- .../LoginActivity/LoggedOutStateTest.java | 2 - .../MainActivity/AnonymousStateTest.java | 4 - .../AuthenticatedUserStateTest.java | 1 - .../MainActivity/GeneralStateTest.java | 4 +- .../MainActivity/LoggedOutStateTest.java | 1 - .../SyncActivity/AnonymousStateTest.java | 15 ++- .../AuthenticatedUserStateTest.java | 14 ++- .../AnonymousStateTest.java | 29 +++++- .../AuthenticatedUserStateTest.java | 29 +++++- .../GeneralStateTest.java | 2 + .../GeneralDeviceSettingsFragmentTest.java | 3 + .../fragments/VerifyUserPermissionTest.java | 16 ++- .../opendatakit/services/MainActivity.java | 1 + 15 files changed, 194 insertions(+), 63 deletions(-) diff --git a/services_app/src/androidTest/java/org/opendatakit/BaseUITest.java b/services_app/src/androidTest/java/org/opendatakit/BaseUITest.java index 7279013a0..27ac86fd9 100644 --- a/services_app/src/androidTest/java/org/opendatakit/BaseUITest.java +++ b/services_app/src/androidTest/java/org/opendatakit/BaseUITest.java @@ -7,6 +7,7 @@ import static androidx.test.espresso.matcher.RootMatchers.isDialog; import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.android.gms.common.internal.Preconditions.checkNotNull; @@ -27,12 +28,9 @@ import androidx.annotation.NonNull; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.preference.CheckBoxPreference; -import android.view.View; -import android.widget.Checkable; - -import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import androidx.test.core.app.ActivityScenario; +import androidx.test.espresso.PerformException; import androidx.test.espresso.UiController; import androidx.test.espresso.ViewAction; import androidx.test.espresso.action.GeneralClickAction; @@ -43,6 +41,7 @@ import androidx.test.espresso.intent.Intents; import androidx.test.espresso.matcher.BoundedMatcher; import androidx.test.espresso.matcher.ViewMatchers; +import androidx.test.espresso.util.TreeIterables; import androidx.test.platform.app.InstrumentationRegistry; import org.junit.Rule; @@ -63,8 +62,10 @@ import org.opendatakit.utilities.ODKFileUtils; import java.io.File; +import java.util.concurrent.TimeoutException; public abstract class BaseUITest { + private static boolean isInitialized = false; protected final static String APP_NAME = "testAppName"; protected final static String TEST_SERVER_URL = "https://testUrl.com"; protected final static String TEST_PASSWORD = "testPassword"; @@ -78,34 +79,46 @@ public abstract class BaseUITest { protected ActivityScenario activityScenario; @Rule - public GrantPermissionRule writeRuntimePermissionRule = GrantPermissionRule .grant(Manifest.permission.WRITE_EXTERNAL_STORAGE); + public GrantPermissionRule writeRuntimePermissionRule = GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE); @Rule - public GrantPermissionRule readtimePermissionRule = GrantPermissionRule .grant(Manifest.permission.READ_EXTERNAL_STORAGE); + public GrantPermissionRule readtimePermissionRule = GrantPermissionRule.grant(Manifest.permission.READ_EXTERNAL_STORAGE); @Before public void setUp() { - Intents.init(); + if (!isInitialized) { + System.out.println("Intents.init() called"); + Intents.init(); + isInitialized = true; + } + activityScenario = ActivityScenario.launch(getLaunchIntent()); setUpPostLaunch(); } - protected abstract void setUpPostLaunch(); - protected abstract Intent getLaunchIntent(); - @After public void tearDown() throws Exception { - if (activityScenario != null) activityScenario.close(); - Intents.release(); + if (activityScenario != null) { + activityScenario.close(); + activityScenario = null; + } + + if (isInitialized) { + System.out.println("Intents.release() called"); + Intents.release(); + isInitialized = false; + } } + + protected abstract void setUpPostLaunch(); + protected abstract Intent getLaunchIntent(); protected Context getContext() { return InstrumentationRegistry.getInstrumentation().getTargetContext(); } public void resetConfiguration() { - PropertiesSingleton mProps = CommonToolProperties.get(getContext() - , APP_NAME); + PropertiesSingleton mProps = CommonToolProperties.get(getContext(), APP_NAME); mProps.clearSettings(); LocalizationUtils.clearTranslations(); File f = new File(ODKFileUtils.getTablesInitializationCompleteMarkerFile(APP_NAME)); @@ -172,23 +185,65 @@ protected boolean matchesSafely(final RecyclerView view) { } }; } + public static ViewAction waitFor(long delay) { return new ViewAction() { - @Override public Matcher getConstraints() { - return ViewMatchers.isRoot(); + @Override + public Matcher getConstraints() { + return isRoot(); } - @Override public String getDescription() { - return "wait for " + delay + "milliseconds"; + @Override + public String getDescription() { + return "wait for " + delay + " milliseconds"; } - @Override public void perform(UiController uiController, View view) { + @Override + public void perform(UiController uiController, View view) { uiController.loopMainThreadForAtLeast(delay); } }; } - public static void enableAdminMode() { + public static ViewAction waitForView(final Matcher viewMatcher, final long millis) { + return new ViewAction() { + @Override + public Matcher getConstraints() { + return isRoot(); + } + + @Override + public String getDescription() { + return "wait for a specific view with matcher <" + viewMatcher + "> during " + millis + " millis."; + } + + @Override + public void perform(final UiController uiController, final View view) { + final long startTime = System.currentTimeMillis(); + final long endTime = startTime + millis; + final Matcher finalViewMatcher = viewMatcher; + + do { + for (View child : TreeIterables.breadthFirstViewTraversal(view)) { + if (finalViewMatcher.matches(child)) { + return; + } + } + + uiController.loopMainThreadForAtLeast(50); + } while (System.currentTimeMillis() < endTime); + + // Timeout happened. + throw new PerformException.Builder() + .withActionDescription(this.getDescription()) + .withViewDescription(view.toString()) + .withCause(new TimeoutException()) + .build(); + } + }; + } + + public static void enableAdminMode() { onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.user_restrictions)), click())); @@ -202,9 +257,7 @@ public static void enableAdminMode() { protected Activity getActivity() { final Activity[] activity1 = new Activity[1]; - activityScenario.onActivity(activity -> activity1[0] =activity); + activityScenario.onActivity(activity -> activity1[0] = activity); return activity1[0]; } - } - diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java index f048dd1d2..9874c3d37 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java @@ -1,21 +1,27 @@ package org.opendatakit.activites.LoginActivity; import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.isEnabled; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; +import static org.hamcrest.Matchers.allOf; + import android.Manifest; import android.content.Intent; +import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; import androidx.test.espresso.matcher.RootMatchers; +import androidx.test.rule.ActivityTestRule; import androidx.test.rule.GrantPermissionRule; import org.junit.Ignore; @@ -35,10 +41,14 @@ public class GeneralStateTest extends BaseUITest { + @Rule + public ActivityTestRule activityRule = new ActivityTestRule<>(LoginActivity.class); + + @Override protected void setUpPostLaunch() { - activityScenario.onActivity(activity -> { - PropertiesSingleton props = activity.getProps(); + activityRule.getActivity().runOnUiThread(() -> { + PropertiesSingleton props = activityRule.getActivity().getProps(); assertThat(props).isNotNull(); Map serverProperties = UpdateServerSettingsFragment.getUpdateUrlProperties(TEST_SERVER_URL); @@ -47,12 +57,13 @@ protected void setUpPostLaunch() { props.setProperties(Collections.singletonMap(CommonToolProperties.KEY_FIRST_LAUNCH, "false")); - activity.updateViewModelWithProps(); + activityRule.getActivity().updateViewModelWithProps(); }); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyValuesTest() { + onView(isRoot()).perform(waitFor(2000)); + onView(withId(R.id.tvTitleLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); onView(withId(R.id.btnAnonymousSignInLogin)).check(matches(withText(R.string.anonymous_user))); onView(withId(R.id.btnUserSignInLogin)).check(matches(withText(R.string.authenticated_user))); @@ -60,36 +71,36 @@ public void verifyValuesTest() { onView(withId(R.id.btnUserSignInLogin)).check(matches(isEnabled())); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyVisibilityTest() { - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); + onView(allOf(withId(R.id.btnDrawerOpen), isDisplayed())).perform(click()); + Espresso.onIdle(); onView(withId(R.id.drawer_update_credentials)).check(doesNotExist()); onView(withId(R.id.drawer_switch_sign_in_type)).check(doesNotExist()); } - @Ignore // OUTREACHY-BROKEN-TEST + @Test public void checkDrawerServerLoginTest() { - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); - onView(withId(R.id.drawer_server_login)).perform(ViewActions.click()); + onView(withId(R.id.btnDrawerOpen)).perform(click()); + onView(withId(R.id.drawer_server_login)).perform(click()); onView(withId(R.id.inputServerUrl)).check(matches(isDisplayed())); onView(withId(R.id.inputTextServerUrl)).check(matches(withText(TEST_SERVER_URL))); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void checkToolbarSettingsButtonClick() { onView(withId(R.id.action_settings)).perform(ViewActions.click()); + onView(isRoot()).perform(waitFor(2000)); + Intents.intended(IntentMatchers.hasComponent(AppPropertiesActivity.class.getName())); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void checkDrawerSettingsClick() { - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); - onView(withId(R.id.drawer_settings)).perform(ViewActions.click()); + onView(withId(R.id.btnDrawerOpen)).perform(click()); + onView(withId(R.id.drawer_settings)).perform(click()); Intents.intended(IntentMatchers.hasComponent(AppPropertiesActivity.class.getName())); } diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/LoggedOutStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/LoggedOutStateTest.java index a86729709..4d86046bb 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/LoggedOutStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/LoggedOutStateTest.java @@ -44,13 +44,11 @@ protected void setUpPostLaunch() { }); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyValuesTest() { onView(withId(R.id.tvServerUrlLogin)).check(matches(withText(TEST_SERVER_URL))); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyVisibilityTest() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java index 86ad1381b..de6dbd1e7 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java @@ -59,7 +59,6 @@ protected void setUpPostLaunch() { }); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void checkFirstStartupTest() { activityScenario.onActivity(activity -> { @@ -75,7 +74,6 @@ public void checkFirstStartupTest() { onView(withId(R.id.inputServerUrl)).check(matches(isDisplayed())); onView(withId(R.id.inputTextServerUrl)).check(matches(withText(SERVER_URL))); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyVisibilityTest() { onView(withId(R.id.action_sync)).check(matches(isDisplayed())); @@ -128,7 +126,6 @@ public void verifyDrawerResolveConflictsClick() { Intents.intended(IntentMatchers.hasComponent(AllConflictsResolutionActivity.class.getName())); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyDrawerSwitchSignInTypeClick() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); @@ -141,7 +138,6 @@ public void verifyDrawerSwitchSignInTypeClick() { onView(withId(R.id.inputUsernameLogin)).check(matches(isDisplayed())); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyDrawerSignOutButtonClick() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java index eb6e8b53a..6596a20eb 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java @@ -189,7 +189,6 @@ public void verifyDrawerUpdateCredentialsClick() { onView(withId(R.id.inputTextPassword)).check(matches(withText(""))); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyDrawerSignOutButtonClick() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/GeneralStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/GeneralStateTest.java index aed7dc9fb..24c358bcf 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/GeneralStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/GeneralStateTest.java @@ -5,6 +5,7 @@ import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.isEnabled; import static androidx.test.espresso.matcher.ViewMatchers.isNotEnabled; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; @@ -61,7 +62,6 @@ protected Intent getLaunchIntent() { return intent; } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void checkFirstStartupTest() { activityScenario.onActivity(activity -> { @@ -92,6 +92,8 @@ public void checkToolbarVerifyBtnClick() { @Test public void checkToolbarSettingsBtnClick() { onView(withId(R.id.action_settings)).perform(ViewActions.click()); + onView(isRoot()).perform(waitFor(2000)); + Intents.intended(IntentMatchers.hasComponent(AppPropertiesActivity.class.getName())); } diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java index 500066f72..b3a47479c 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java @@ -105,7 +105,6 @@ public void verifySignInButtonClickTest() { Intents.intended(IntentMatchers.hasComponent(LoginActivity.class.getName())); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyDrawerSignInButtonClickTest() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AnonymousStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AnonymousStateTest.java index eb97f1865..5e3872bcb 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AnonymousStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AnonymousStateTest.java @@ -18,14 +18,17 @@ import android.content.Intent; import androidx.test.core.app.ActivityScenario; +import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; +import androidx.test.rule.ActivityTestRule; import org.junit.Before; import org.junit.Ignore; +import org.junit.Rule; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.consts.IntentConsts; @@ -35,6 +38,7 @@ import org.opendatakit.services.resolve.conflict.AllConflictsResolutionActivity; import org.opendatakit.services.sync.actions.activities.LoginActivity; import org.opendatakit.services.sync.actions.activities.SyncActivity; +import org.opendatakit.services.sync.actions.activities.VerifyServerSettingsActivity; import org.opendatakit.services.sync.actions.fragments.ChooseSignInTypeFragment; import org.opendatakit.services.sync.actions.fragments.UpdateServerSettingsFragment; import org.opendatakit.services.utilities.DateTimeUtil; @@ -46,10 +50,13 @@ public class AnonymousStateTest extends BaseUITest { + @Rule + public ActivityTestRule activityRule = new ActivityTestRule<>(SyncActivity.class); + @Override protected void setUpPostLaunch() { - activityScenario.onActivity(activity -> { - PropertiesSingleton props = activity.getProps(); + activityRule.getActivity().runOnUiThread(() -> { + PropertiesSingleton props = activityRule.getActivity().getProps(); assertThat(props).isNotNull(); Map serverProperties = UpdateServerSettingsFragment.getUpdateUrlProperties(TEST_SERVER_URL); @@ -62,8 +69,9 @@ protected void setUpPostLaunch() { props.setProperties(Collections.singletonMap(CommonToolProperties.KEY_FIRST_LAUNCH, "false")); - activity.updateViewModelWithProps(); + activityRule.getActivity().updateViewModelWithProps(); }); + Espresso.onIdle(); } @Override @@ -113,7 +121,6 @@ public void verifyLastSyncTimeTest() { onView(withId(R.id.tvLastSyncTimeSync)).check(matches(withText(DateTimeUtil.getDisplayDate(currentTime)))); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyChangeSyncTypeTest() { String[] syncTypes = getContext().getResources().getStringArray(R.array.sync_attachment_option_names); diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AuthenticatedUserStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AuthenticatedUserStateTest.java index 501650659..4abc1f6ae 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AuthenticatedUserStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AuthenticatedUserStateTest.java @@ -18,14 +18,17 @@ import android.content.Intent; import androidx.test.core.app.ActivityScenario; +import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; +import androidx.test.rule.ActivityTestRule; import org.junit.Before; import org.junit.Ignore; +import org.junit.Rule; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.consts.IntentConsts; @@ -47,10 +50,13 @@ public class AuthenticatedUserStateTest extends BaseUITest { + @Rule + public ActivityTestRule activityRule = new ActivityTestRule<>(SyncActivity.class); + @Override protected void setUpPostLaunch() { - activityScenario.onActivity(activity -> { - PropertiesSingleton props = activity.getProps(); + activityRule.getActivity().runOnUiThread(() -> { + PropertiesSingleton props = activityRule.getActivity().getProps(); assertThat(props).isNotNull(); Map serverProperties = UpdateServerSettingsFragment.getUpdateUrlProperties(TEST_SERVER_URL); @@ -63,8 +69,9 @@ protected void setUpPostLaunch() { props.setProperties(Collections.singletonMap(CommonToolProperties.KEY_FIRST_LAUNCH, "false")); - activity.updateViewModelWithProps(); + activityRule.getActivity().updateViewModelWithProps(); }); + Espresso.onIdle(); } @Override @@ -102,7 +109,6 @@ public void verifyValuesTest() { onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_out_button_text)))); } - @Ignore // OUTREACHY-BROKEN-TEST @Test public void verifyChangeSyncTypeTest() { String[] syncTypes = getContext().getResources().getStringArray(R.array.sync_attachment_option_names); diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AnonymousStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AnonymousStateTest.java index fb9f35e7a..f7e00b375 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AnonymousStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AnonymousStateTest.java @@ -12,13 +12,16 @@ import android.content.Intent; import androidx.test.core.app.ActivityScenario; +import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; +import androidx.test.rule.ActivityTestRule; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.consts.IntentConsts; @@ -36,10 +39,13 @@ public class AnonymousStateTest extends BaseUITest { + @Rule + public ActivityTestRule activityRule = new ActivityTestRule<>(VerifyServerSettingsActivity.class); + @Override protected void setUpPostLaunch() { - activityScenario.onActivity(activity -> { - PropertiesSingleton props = activity.getProps(); + activityRule.getActivity().runOnUiThread(() -> { + PropertiesSingleton props = activityRule.getActivity().getProps(); assertThat(props).isNotNull(); Map serverProperties = UpdateServerSettingsFragment.getUpdateUrlProperties(TEST_SERVER_URL); @@ -52,9 +58,9 @@ protected void setUpPostLaunch() { props.setProperties(Collections.singletonMap(CommonToolProperties.KEY_FIRST_LAUNCH, "false")); - activity.updateViewModelWithProps(); + activityRule.getActivity().updateViewModelWithProps(); }); - + Espresso.onIdle(); } @Override @@ -89,10 +95,25 @@ public void verifyValuesTest() { @Test public void verifyDrawerResolveConflictsClick() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); + + try { + Thread.sleep(3000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + onView(withId(R.id.drawer_resolve_conflict)).perform(ViewActions.click()); + + try { + Thread.sleep(3000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + Intents.intended(IntentMatchers.hasComponent(AllConflictsResolutionActivity.class.getName())); } + @Test public void verifyDrawerSwitchSignInTypeClick() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AuthenticatedUserStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AuthenticatedUserStateTest.java index 15ec28be9..c2f5e45da 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AuthenticatedUserStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AuthenticatedUserStateTest.java @@ -13,13 +13,16 @@ import android.content.Intent; import androidx.test.core.app.ActivityScenario; +import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; +import androidx.test.rule.ActivityTestRule; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.consts.IntentConsts; @@ -29,6 +32,7 @@ import org.opendatakit.services.resolve.conflict.AllConflictsResolutionActivity; import org.opendatakit.services.sync.actions.activities.LoginActivity; import org.opendatakit.services.sync.actions.activities.VerifyServerSettingsActivity; +import org.opendatakit.services.sync.actions.fragments.ChooseSignInTypeFragment; import org.opendatakit.services.sync.actions.fragments.SetCredentialsFragment; import org.opendatakit.services.sync.actions.fragments.UpdateServerSettingsFragment; import org.opendatakit.services.utilities.DateTimeUtil; @@ -40,10 +44,14 @@ public class AuthenticatedUserStateTest extends BaseUITest { + @Rule + public ActivityTestRule activityRule = new ActivityTestRule<>(VerifyServerSettingsActivity.class); + + @Override protected void setUpPostLaunch() { - activityScenario.onActivity(activity -> { - PropertiesSingleton props = activity.getProps(); + activityRule.getActivity().runOnUiThread(() -> { + PropertiesSingleton props = activityRule.getActivity().getProps(); assertThat(props).isNotNull(); Map serverProperties = UpdateServerSettingsFragment.getUpdateUrlProperties(TEST_SERVER_URL); @@ -56,8 +64,9 @@ protected void setUpPostLaunch() { props.setProperties(Collections.singletonMap(CommonToolProperties.KEY_FIRST_LAUNCH, "false")); - activity.updateViewModelWithProps(); + activityRule.getActivity().updateViewModelWithProps(); }); + Espresso.onIdle(); } @Override @@ -108,7 +117,21 @@ public void verifyLastSyncTimeTest() { @Test public void verifyDrawerResolveConflictsClick() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); + + try { + Thread.sleep(3000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + onView(withId(R.id.drawer_resolve_conflict)).perform(ViewActions.click()); + + try { + Thread.sleep(3000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + Intents.intended(IntentMatchers.hasComponent(AllConflictsResolutionActivity.class.getName())); } diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/GeneralStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/GeneralStateTest.java index 436346e49..75f2aad15 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/GeneralStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/GeneralStateTest.java @@ -5,6 +5,7 @@ import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.isEnabled; import static androidx.test.espresso.matcher.ViewMatchers.isNotEnabled; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; @@ -69,6 +70,7 @@ public void verifyValuesTest() { @Test public void checkToolbarSettingsButtonClick() { onView(withId(R.id.action_settings)).perform(ViewActions.click()); + onView(isRoot()).perform(waitFor(2000)); Intents.intended(IntentMatchers.hasComponent(AppPropertiesActivity.class.getName())); } diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralDeviceSettingsFragmentTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralDeviceSettingsFragmentTest.java index 48370f247..64786956e 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralDeviceSettingsFragmentTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralDeviceSettingsFragmentTest.java @@ -16,7 +16,9 @@ import android.content.Intent; import androidx.test.espresso.contrib.RecyclerViewActions; +import androidx.test.espresso.intent.Intents; +import org.junit.After; import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; @@ -41,6 +43,7 @@ protected void setUpPostLaunch() { } + @Test public void whenTextFontSizeIsClicked_doChangeFontSize_checkIfSizeIsExtraLarge() { onView(withId(androidx.preference.R.id.recycler_view)) diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/VerifyUserPermissionTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/VerifyUserPermissionTest.java index 1780ff5c9..83a44d773 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/VerifyUserPermissionTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/VerifyUserPermissionTest.java @@ -8,6 +8,7 @@ import static androidx.test.espresso.matcher.RootMatchers.isDialog; import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; @@ -47,19 +48,28 @@ public void whenVerifyUserPermissionScreenIsClicked_launchVerifyServerSettingsAc intended(hasComponent(VerifyServerSettingsActivity.class.getName())); } + @Test public void whenVerifyUserPermissionIsClicked_configureServerUrl() { resetConfiguration(); - onView(withId(androidx.preference.R.id.recycler_view)) - .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.verify_server_settings_header)), - click())); + + onView(withId(androidx.preference.R.id.recycler_view)).check(matches(isDisplayed())); + onView(withId(androidx.preference.R.id.recycler_view)).perform(RecyclerViewActions.actionOnItem( + hasDescendant(withText(R.string.verify_server_settings_header)), click())); + + onView(isRoot()).perform(BaseUITest.waitForView(withText(R.string.configure_server_settings), 3000)); onView(withText(R.string.configure_server_settings)) .inRoot(isDialog()) .check(matches(isDisplayed())); + + onView(isRoot()).perform(BaseUITest.waitForView(allOf(withId(android.R.id.button1), withText(R.string.yes)), 2000)); onView(allOf(withId(android.R.id.button1), withText(R.string.yes))).perform(click()); + + onView(isRoot()).perform(BaseUITest.waitFor(1500)); intended(hasComponent(VerifyServerSettingsActivity.class.getName())); } + @Override protected Intent getLaunchIntent() { Intent intent = new Intent(getContext(), AppPropertiesActivity.class); diff --git a/services_app/src/main/java/org/opendatakit/services/MainActivity.java b/services_app/src/main/java/org/opendatakit/services/MainActivity.java index 247c638a5..a1e1c309e 100644 --- a/services_app/src/main/java/org/opendatakit/services/MainActivity.java +++ b/services_app/src/main/java/org/opendatakit/services/MainActivity.java @@ -16,6 +16,7 @@ import android.Manifest; import android.app.Activity; +import android.content.ComponentName; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageManager; From 1ccb754186796a941e07ce77c388a711f556b078 Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Sat, 1 Jun 2024 20:23:06 +0100 Subject: [PATCH 02/13] Update config.yml --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 348774f11..714a2d9da 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,7 @@ jobs: description: Runs unit tests and instrumented tests on the Android Common executor: name: android/android-machine - resource-class: xlarge + resource-class: large tag: 2024.01.1 steps: @@ -71,4 +71,4 @@ workflows: - build - test: requires: - - build \ No newline at end of file + - build From 93138fcb4841bc44cb834e627931ed2d9553698b Mon Sep 17 00:00:00 2001 From: Stryker101 Date: Sat, 1 Jun 2024 21:08:24 +0100 Subject: [PATCH 03/13] Fix for UI Tests --- .../activites/LoginActivity/GeneralStateTest.java | 1 + .../activites/MainActivity/AnonymousStateTest.java | 10 +++++++++- .../MainActivity/AuthenticatedUserStateTest.java | 5 +++++ .../activites/MainActivity/LoggedOutStateTest.java | 5 +++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java index 9874c3d37..bb744dc21 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java @@ -73,6 +73,7 @@ public void verifyValuesTest() { @Test public void verifyVisibilityTest() { + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), 2000)); onView(allOf(withId(R.id.btnDrawerOpen), isDisplayed())).perform(click()); Espresso.onIdle(); onView(withId(R.id.drawer_update_credentials)).check(doesNotExist()); diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java index de6dbd1e7..bfdbc417d 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java @@ -4,6 +4,7 @@ import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; @@ -121,8 +122,11 @@ public void verifyToolbarSyncItemClick() { @Test public void verifyDrawerResolveConflictsClick() { + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), 3000)); + onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); onView(withId(R.id.drawer_resolve_conflict)).perform(ViewActions.click()); + onView(isRoot()).perform(waitFor(2000)); Intents.intended(IntentMatchers.hasComponent(AllConflictsResolutionActivity.class.getName())); } @@ -140,15 +144,19 @@ public void verifyDrawerSwitchSignInTypeClick() { @Test public void verifyDrawerSignOutButtonClick() { + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), 2000)); onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); + + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerLogin), 2000)); onView(withId(R.id.btnDrawerLogin)).perform(ViewActions.click()); + onView(isRoot()).perform(BaseUITest.waitFor(2000)); onView(withId(R.id.tvUserStateMain)).check(matches(withText(getContext().getString(R.string.logged_out)))); onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); - onView(withId(R.id.btnSignInMain)).check(matches(isDisplayed())); } + @Override protected Intent getLaunchIntent() { Intent intent = new Intent(getContext(), MainActivity.class); diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java index 6596a20eb..6261feda8 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java @@ -5,6 +5,7 @@ import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.isEnabled; import static androidx.test.espresso.matcher.ViewMatchers.isNotEnabled; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; @@ -191,8 +192,12 @@ public void verifyDrawerUpdateCredentialsClick() { @Test public void verifyDrawerSignOutButtonClick() { + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), 2000)); onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); + + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerLogin), 2000)); onView(withId(R.id.btnDrawerLogin)).perform(ViewActions.click()); + onView(isRoot()).perform(BaseUITest.waitFor(2000)); onView(withId(R.id.tvUserStateMain)).check(matches(withText(getContext().getString(R.string.logged_out)))); onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java index b3a47479c..42fa46a0b 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java @@ -4,6 +4,7 @@ import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.isRoot; import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; @@ -107,8 +108,12 @@ public void verifySignInButtonClickTest() { @Test public void verifyDrawerSignInButtonClickTest() { + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), 2000)); onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); + + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerLogin), 2000)); onView(withId(R.id.btnDrawerLogin)).perform(ViewActions.click()); + onView(isRoot()).perform(BaseUITest.waitFor(2000)); Intents.intended(IntentMatchers.hasComponent(LoginActivity.class.getName())); } } From bb5ba6ce9ee227750eab95289065ac88e5154d5f Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Sat, 1 Jun 2024 21:37:44 +0100 Subject: [PATCH 04/13] Update config.yml --- .circleci/config.yml | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 714a2d9da..a29bbe8fe 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,12 +2,12 @@ version: 2.1 orbs: android: circleci/android@2.4.0 + jobs: test: description: Runs unit tests and instrumented tests on the Android Common executor: - name: android/android-machine - resource-class: large + name: android/default tag: 2024.01.1 steps: @@ -15,23 +15,14 @@ jobs: - run: name: Chmod Permissions command: sudo chmod +x gradlew - - - android/create-avd: - avd-name: avd - install: true - system-image: system-images;android-29;default;x86 - - android/start-emulator: - avd-name: avd - no-window: true - restore-gradle-cache-prefix: v2 - post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug - - android/disable-animations - - android/run-tests: - test-command: ./gradlew testSnapshotDebugUnitTest - - android/run-tests: - test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest - - android/save-gradle-cache: - cache-prefix: v1 + - android/setup-emulator: + api-level: 29 + emulator-type: full + - android/wait-for-emulator: + timeout-sec: 180 + - run: + name: Install APKs and Run Tests + command: ./gradlew installSnapshotDebug && ./gradlew testSnapshotDebugUnitTest && ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest - store_artifacts: name: Store Test Results path: services_app/build/outputs/androidTest-results @@ -42,18 +33,15 @@ jobs: build: docker: - image: cimg/android:2024.01 + steps: - checkout - run: name: Chmod Permissions command: sudo chmod +x gradlew - - android/restore-gradle-cache: - cache-prefix: v1 - run: name: Download Dependencies command: ./gradlew androidDependencies - - android/save-gradle-cache: - cache-prefix: v1 - run: name: Build Services command: ./gradlew assembleSnapshotDebug From 882ac4c25d56a3e6e49d281f1c620f16c7927df8 Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Sat, 1 Jun 2024 21:42:35 +0100 Subject: [PATCH 05/13] Update config.yml --- .circleci/config.yml | 54 ++++++++++++-------------------------------- 1 file changed, 15 insertions(+), 39 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a29bbe8fe..e20dd29d7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,25 +1,27 @@ version: 2.1 -orbs: - android: circleci/android@2.4.0 - jobs: test: description: Runs unit tests and instrumented tests on the Android Common - executor: - name: android/default - tag: 2024.01.1 - + docker: + - image: circleci/android:2020.10 steps: - checkout - run: name: Chmod Permissions command: sudo chmod +x gradlew - - android/setup-emulator: - api-level: 29 - emulator-type: full - - android/wait-for-emulator: - timeout-sec: 180 + - run: + name: Download and Install SDK Packages + command: sdkmanager "system-images;android-29;google_apis;x86" "platform-tools" "platforms;android-29" "emulator" --sdk_root=/usr/local/android-sdk + - run: + name: Create and Start Emulator + command: | + echo "no" | avdmanager --verbose create avd --force --name test --package "system-images;android-29;google_apis;x86" --abi google_apis/x86 + emulator -avd test -no-window -no-audio -no-snapshot -gpu swiftshader_indirect & + circle-android wait-for-boot + - run: + name: Wait for Emulator to Start + command: adb wait-for-device - run: name: Install APKs and Run Tests command: ./gradlew installSnapshotDebug && ./gradlew testSnapshotDebugUnitTest && ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest @@ -30,33 +32,7 @@ jobs: name: Store Test Reports path: services_app/build/reports - build: - docker: - - image: cimg/android:2024.01 - - steps: - - checkout - - run: - name: Chmod Permissions - command: sudo chmod +x gradlew - - run: - name: Download Dependencies - command: ./gradlew androidDependencies - - run: - name: Build Services - command: ./gradlew assembleSnapshotDebug - - store_artifacts: - name: Store Build Artifacts - path: services_app/build/outputs/apk - - persist_to_workspace: - root: . - paths: - - services_app/build/outputs/apk - workflows: build-test-workflow: jobs: - - build - - test: - requires: - - build + - test From bd8faad5bf2acce655f98ebec8545824411e5bbe Mon Sep 17 00:00:00 2001 From: Stryker101 <95471989+Stryker101@users.noreply.github.com> Date: Sat, 1 Jun 2024 21:44:14 +0100 Subject: [PATCH 06/13] Update config.yml --- .circleci/config.yml | 73 +++++++++++++++++++++++++++++++++----------- 1 file changed, 55 insertions(+), 18 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e20dd29d7..95e8df3c6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,30 +1,38 @@ + version: 2.1 +orbs: + android: circleci/android@2.4.0 jobs: test: description: Runs unit tests and instrumented tests on the Android Common - docker: - - image: circleci/android:2020.10 + executor: + name: android/android-machine + resource-class: large + tag: 2024.01.1 + steps: - checkout - run: name: Chmod Permissions command: sudo chmod +x gradlew - - run: - name: Download and Install SDK Packages - command: sdkmanager "system-images;android-29;google_apis;x86" "platform-tools" "platforms;android-29" "emulator" --sdk_root=/usr/local/android-sdk - - run: - name: Create and Start Emulator - command: | - echo "no" | avdmanager --verbose create avd --force --name test --package "system-images;android-29;google_apis;x86" --abi google_apis/x86 - emulator -avd test -no-window -no-audio -no-snapshot -gpu swiftshader_indirect & - circle-android wait-for-boot - - run: - name: Wait for Emulator to Start - command: adb wait-for-device - - run: - name: Install APKs and Run Tests - command: ./gradlew installSnapshotDebug && ./gradlew testSnapshotDebugUnitTest && ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest + + - android/create-avd: + avd-name: avd + install: true + system-image: system-images;android-29;default;x86 + - android/start-emulator: + avd-name: avd + no-window: true + restore-gradle-cache-prefix: v2 + post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug + - android/disable-animations + - android/run-tests: + test-command: ./gradlew testSnapshotDebugUnitTest + - android/run-tests: + test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest + - android/save-gradle-cache: + cache-prefix: v1 - store_artifacts: name: Store Test Results path: services_app/build/outputs/androidTest-results @@ -32,7 +40,36 @@ jobs: name: Store Test Reports path: services_app/build/reports + build: + docker: + - image: cimg/android:2024.01 + steps: + - checkout + - run: + name: Chmod Permissions + command: sudo chmod +x gradlew + - android/restore-gradle-cache: + cache-prefix: v1 + - run: + name: Download Dependencies + command: ./gradlew androidDependencies + - android/save-gradle-cache: + cache-prefix: v1 + - run: + name: Build Services + command: ./gradlew assembleSnapshotDebug + - store_artifacts: + name: Store Build Artifacts + path: services_app/build/outputs/apk + - persist_to_workspace: + root: . + paths: + - services_app/build/outputs/apk + workflows: build-test-workflow: jobs: - - test + - build + - test: + requires: + - build From c42011b6e7acc72d88e0b3884a43d767e157fc64 Mon Sep 17 00:00:00 2001 From: Stryker101 Date: Tue, 4 Jun 2024 10:00:57 +0100 Subject: [PATCH 07/13] fix for ui tests --- .circleci/config.yml | 12 +++--- .../java/org/opendatakit/BaseUITest.java | 10 ++--- .../LoginActivity/GeneralStateTest.java | 4 +- .../MainActivity/AnonymousStateTest.java | 39 ++++++++++++------- .../AuthenticatedUserStateTest.java | 16 +++++--- .../src/main/res/layout/drawer_header.xml | 1 + 6 files changed, 49 insertions(+), 33 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f94a866c2..7141c3866 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,7 @@ jobs: description: Runs unit tests and instrumented tests on the Android Common executor: name: android/android-machine - resource-class: large + resource-class: xlarge tag: 2024.01.1 steps: @@ -18,15 +18,15 @@ jobs: command: sudo chmod +x gradlew - android/create-avd: - avd-name: avd + avd-name: Pixel_7_Pro + system-image: system-images;android-33;google_apis_playstore;x86_64 install: true - system-image: system-images;android-29;default;x86 - android/start-emulator: - avd-name: avd + avd-name: Pixel_7_Pro no-window: true restore-gradle-cache-prefix: v1 - memory: 4096 - post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug + memory: 4096 + post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug - android/disable-animations - android/run-tests: test-command: ./gradlew testSnapshotDebugUnitTest diff --git a/services_app/src/androidTest/java/org/opendatakit/BaseUITest.java b/services_app/src/androidTest/java/org/opendatakit/BaseUITest.java index 27ac86fd9..daa2d8d5c 100644 --- a/services_app/src/androidTest/java/org/opendatakit/BaseUITest.java +++ b/services_app/src/androidTest/java/org/opendatakit/BaseUITest.java @@ -41,6 +41,7 @@ import androidx.test.espresso.intent.Intents; import androidx.test.espresso.matcher.BoundedMatcher; import androidx.test.espresso.matcher.ViewMatchers; +import androidx.test.espresso.util.HumanReadables; import androidx.test.espresso.util.TreeIterables; import androidx.test.platform.app.InstrumentationRegistry; @@ -214,18 +215,17 @@ public Matcher getConstraints() { @Override public String getDescription() { - return "wait for a specific view with matcher <" + viewMatcher + "> during " + millis + " millis."; + return "Wait for a specific view with id <" + viewMatcher + "> during " + millis + " millis."; } @Override public void perform(final UiController uiController, final View view) { final long startTime = System.currentTimeMillis(); final long endTime = startTime + millis; - final Matcher finalViewMatcher = viewMatcher; do { for (View child : TreeIterables.breadthFirstViewTraversal(view)) { - if (finalViewMatcher.matches(child)) { + if (viewMatcher.matches(child)) { return; } } @@ -233,16 +233,14 @@ public void perform(final UiController uiController, final View view) { uiController.loopMainThreadForAtLeast(50); } while (System.currentTimeMillis() < endTime); - // Timeout happened. throw new PerformException.Builder() .withActionDescription(this.getDescription()) - .withViewDescription(view.toString()) + .withViewDescription(HumanReadables.describe(view)) .withCause(new TimeoutException()) .build(); } }; } - public static void enableAdminMode() { onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.user_restrictions)), diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java index bb744dc21..0558aa96a 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java @@ -73,9 +73,9 @@ public void verifyValuesTest() { @Test public void verifyVisibilityTest() { - onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), 2000)); + onView(isRoot()).perform(waitFor(2000)); + onView(allOf(withId(R.id.btnDrawerOpen), isDisplayed())).check(matches(isDisplayed())); onView(allOf(withId(R.id.btnDrawerOpen), isDisplayed())).perform(click()); - Espresso.onIdle(); onView(withId(R.id.drawer_update_credentials)).check(doesNotExist()); onView(withId(R.id.drawer_switch_sign_in_type)).check(doesNotExist()); } diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java index bfdbc417d..26f87f9d1 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java @@ -1,22 +1,35 @@ package org.opendatakit.activites.MainActivity; +import static androidx.test.espresso.Espresso.closeSoftKeyboard; import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.action.ViewActions.scrollTo; import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.isRoot; +import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription; import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; +import static org.hamcrest.Matchers.allOf; + +import android.content.Context; import android.content.Intent; +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; +import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; +import androidx.test.platform.app.InstrumentationRegistry; import org.junit.Ignore; import org.junit.Test; @@ -70,7 +83,7 @@ public void checkFirstStartupTest() { activity.recreate(); }); - onView(withId(android.R.id.button1)).inRoot(RootMatchers.isDialog()).perform(ViewActions.click()); + onView(withId(android.R.id.button1)).inRoot(RootMatchers.isDialog()).perform(click()); onView(withId(R.id.inputServerUrl)).check(matches(isDisplayed())); onView(withId(R.id.inputTextServerUrl)).check(matches(withText(SERVER_URL))); @@ -83,7 +96,7 @@ public void verifyVisibilityTest() { onView(withId(R.id.tvLastSyncTimeMain)).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))); onView(withId(R.id.btnSignInMain)).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE))); - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); + onView(withId(R.id.btnDrawerOpen)).perform(click()); onView(withId(R.id.drawer_resolve_conflict)).check(matches(isDisplayed())); onView(withId(R.id.drawer_switch_sign_in_type)).check(matches(isDisplayed())); @@ -116,7 +129,7 @@ public void verifyLastSyncTimeTest() { @Test public void verifyToolbarSyncItemClick() { - onView(withId(R.id.action_sync)).perform(ViewActions.click()); + onView(withId(R.id.action_sync)).perform(click()); Intents.intended(IntentMatchers.hasComponent(SyncActivity.class.getName())); } @@ -124,16 +137,16 @@ public void verifyToolbarSyncItemClick() { public void verifyDrawerResolveConflictsClick() { onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), 3000)); - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); - onView(withId(R.id.drawer_resolve_conflict)).perform(ViewActions.click()); + onView(withId(R.id.btnDrawerOpen)).perform(click()); + onView(withId(R.id.drawer_resolve_conflict)).perform(click()); onView(isRoot()).perform(waitFor(2000)); Intents.intended(IntentMatchers.hasComponent(AllConflictsResolutionActivity.class.getName())); } @Test public void verifyDrawerSwitchSignInTypeClick() { - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); - onView(withId(R.id.drawer_switch_sign_in_type)).perform(ViewActions.click()); + onView(withId(R.id.btnDrawerOpen)).perform(click()); + onView(withId(R.id.drawer_switch_sign_in_type)).perform(click()); Intents.intended(IntentMatchers.hasComponent(LoginActivity.class.getName())); @@ -144,12 +157,10 @@ public void verifyDrawerSwitchSignInTypeClick() { @Test public void verifyDrawerSignOutButtonClick() { - onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), 2000)); - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); - - onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerLogin), 2000)); - onView(withId(R.id.btnDrawerLogin)).perform(ViewActions.click()); - onView(isRoot()).perform(BaseUITest.waitFor(2000)); + onView(withId(R.id.btnDrawerOpen)).perform(click()); + Espresso.onIdle(); + onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())); + onView(withContentDescription("SIGN IN OR OUT")).perform(click()); onView(withId(R.id.tvUserStateMain)).check(matches(withText(getContext().getString(R.string.logged_out)))); onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); @@ -163,4 +174,4 @@ protected Intent getLaunchIntent() { intent.putExtra(IntentConsts.INTENT_KEY_APP_NAME, APP_NAME); return intent; } -} +} \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java index 6261feda8..bb8e02083 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java @@ -1,19 +1,27 @@ package org.opendatakit.activites.MainActivity; +import static androidx.test.espresso.Espresso.closeSoftKeyboard; import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.action.ViewActions.scrollTo; import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.isEnabled; import static androidx.test.espresso.matcher.ViewMatchers.isNotEnabled; import static androidx.test.espresso.matcher.ViewMatchers.isRoot; +import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription; import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; +import static org.hamcrest.Matchers.allOf; + import android.content.Intent; import androidx.test.core.app.ActivityScenario; +import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; @@ -192,12 +200,10 @@ public void verifyDrawerUpdateCredentialsClick() { @Test public void verifyDrawerSignOutButtonClick() { - onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), 2000)); onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); - - onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerLogin), 2000)); - onView(withId(R.id.btnDrawerLogin)).perform(ViewActions.click()); - onView(isRoot()).perform(BaseUITest.waitFor(2000)); + Espresso.onIdle(); + onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())); + onView(withContentDescription("SIGN IN OR OUT")).perform(click()); onView(withId(R.id.tvUserStateMain)).check(matches(withText(getContext().getString(R.string.logged_out)))); onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); diff --git a/services_app/src/main/res/layout/drawer_header.xml b/services_app/src/main/res/layout/drawer_header.xml index bf3897fb9..1355c2041 100644 --- a/services_app/src/main/res/layout/drawer_header.xml +++ b/services_app/src/main/res/layout/drawer_header.xml @@ -30,6 +30,7 @@ style="@style/TextButtonStyle" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:contentDescription="SIGN IN OR OUT" android:layout_gravity="end" android:layout_marginEnd="@dimen/portrait_secondary_margin" android:text="@string/drawer_sign_in_button_text" /> From 8eeed74bd74965236c56d08b01a63e37958bc59a Mon Sep 17 00:00:00 2001 From: Stryker101 Date: Thu, 6 Jun 2024 04:05:42 +0100 Subject: [PATCH 08/13] attempt to stabilize 1 Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests attempt to stabilize 2 attempt to stabilize 3 attempt to stabilize 3 attempt to stabilize 4 attempt to stabilize 5 attempt to stabilize 6 wait time constant added wait time constant amended new system image --- .circleci/config.yml | 141 +++++++++++++++++- .../java/org/opendatakit/TestConsts.java | 3 + .../LoginActivity/GeneralStateTest.java | 28 +++- .../MainActivity/AnonymousStateTest.java | 92 +++++++++++- .../AuthenticatedUserStateTest.java | 63 +++++++- .../MainActivity/GeneralStateTest.java | 5 +- .../MainActivity/LoggedOutStateTest.java | 10 +- .../AnonymousStateTest.java | 5 +- .../AuthenticatedUserStateTest.java | 5 +- .../GeneralStateTest.java | 5 +- .../AdminAppPropertiesActivityTest.java | 10 +- ...onfigurableDeviceSettingsFragmentTest.java | 3 +- ...onfigurableServerSettingsFragmentTest.java | 3 +- ...onfigurableTablesSettingsFragmentTest.java | 3 +- .../fragments/VerifyUserPermissionTest.java | 7 +- services_app/src/main/res/values/strings.xml | 1 + 16 files changed, 357 insertions(+), 27 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7141c3866..7cd93e60b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,8 +1,8 @@ - version: 2.1 orbs: android: circleci/android@2.4.0 + jobs: test: description: Runs unit tests and instrumented tests on the Android Common @@ -19,24 +19,155 @@ jobs: - android/create-avd: avd-name: Pixel_7_Pro +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + system-image: system-images;android-29;google_apis_playstore;x86_64 +======= + system-image: system-images;android-33;google_apis_playstore;x86_64 +>>>>>>> 9f1ae595 ( Fix for UI Tests) +======= + system-image: system-images;android-29;google_apis_playstore;x86_64 +>>>>>>> 3a2a597e ( Fix for UI Tests) +======= system-image: system-images;android-33;google_apis_playstore;x86_64 +>>>>>>> 45a6791e ( Fix for UI Tests) +======= + system-image: system-images;android-30;google_apis_playstore;x86_64 +>>>>>>> 51a777b9 (attempt to stabilize 5) +======= + system-image: system-images;android-30;google_apis;x86 +>>>>>>> 318f2cff (new system image) install: true + + - run: + name: Start ADB server + command: adb start-server + - android/start-emulator: avd-name: Pixel_7_Pro no-window: true restore-gradle-cache-prefix: v1 memory: 4096 post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= + environment: + TERM: dumb +>>>>>>> 5bcc7fe2 ( Fix for UI Tests) +======= +>>>>>>> 76b97389 ( Fix for UI Tests) +======= + - run: + name: Wait for Emulator + command: | + # Wait for the emulator to fully boot up + adb wait-for-device + sleep 30 + adb shell input keyevent 82 + - run: + name: Restart ADB Server + command: | + adb kill-server + adb start-server + adb devices +>>>>>>> c69c8a83 ( Fix for UI Tests) + - android/disable-animations +<<<<<<< HEAD +<<<<<<< HEAD +======= + + - android/disable-animations + + - run: + name: Wait for Emulator to be Ready + command: adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done; sleep 5' # Ensures the emulator is fully booted + + - run: + name: Restart ADB server + command: adb kill-server && adb start-server # Restart ADB server to avoid version mismatch issues + +>>>>>>> 85dc4a48 (attempt to stabilize 3) + - android/run-tests: + test-command: ./gradlew testSnapshotDebugUnitTest + + - android/run-tests: +<<<<<<< HEAD +<<<<<<< HEAD + test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info +<<<<<<< HEAD +======= + test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest +<<<<<<< HEAD + environment: + TERM: dumb +>>>>>>> 5bcc7fe2 ( Fix for UI Tests) +======= + no-output-timeout: 1h +>>>>>>> e9ef26b7 ( Fix for UI Tests) +======= + command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info + no-output-timeout: 30min +>>>>>>> c69c8a83 ( Fix for UI Tests) +======= + - run: + name: Run Unit Tests + command: ./gradlew testSnapshotDebugUnitTest --info + - run: + name: Run Instrumented Tests + command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info +<<<<<<< HEAD +======= - android/disable-animations +<<<<<<< HEAD + - android/run-tests: + test-command: ./gradlew testSnapshotDebugUnitTest --info + - android/run-tests: +<<<<<<< HEAD + test-command:./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info +>>>>>>> b9c61bc2 ( Fix for UI Tests) +======= + test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info +>>>>>>> 418f0144 ( Fix for UI Tests) +======= + - run: + name: Run Unit Tests + command: ./gradlew testSnapshotDebugUnitTest --info + - run: + name: Run Instrumented Tests + command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info +>>>>>>> 83c7d35b ( Fix for UI Tests) + no-output-timeout: 30m +>>>>>>> 3fa89f75 ( Fix for UI Tests) +======= + timeout: 30m +>>>>>>> 63c2d1c0 ( Fix for UI Tests) +======= - android/run-tests: test-command: ./gradlew testSnapshotDebugUnitTest - android/run-tests: +<<<<<<< HEAD + test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info +>>>>>>> 3a2a597e ( Fix for UI Tests) +======= test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest +>>>>>>> 5df9181a ( Fix for UI Tests) +======= + +>>>>>>> 85dc4a48 (attempt to stabilize 3) - android/save-gradle-cache: cache-prefix: v1 + - store_artifacts: name: Store Test Results path: services_app/build/outputs/androidTest-results + - store_artifacts: name: Store Test Reports path: services_app/build/reports @@ -44,24 +175,32 @@ jobs: build: docker: - image: cimg/android:2024.01 + steps: - checkout + - run: name: Chmod Permissions command: sudo chmod +x gradlew + - android/restore-gradle-cache: cache-prefix: v1 + - run: name: Download Dependencies command: ./gradlew androidDependencies + - android/save-gradle-cache: cache-prefix: v1 + - run: name: Build Services command: ./gradlew assembleSnapshotDebug + - store_artifacts: name: Store Build Artifacts path: services_app/build/outputs/apk + - persist_to_workspace: root: . paths: diff --git a/services_app/src/androidTest/java/org/opendatakit/TestConsts.java b/services_app/src/androidTest/java/org/opendatakit/TestConsts.java index e25851855..d29b768c9 100644 --- a/services_app/src/androidTest/java/org/opendatakit/TestConsts.java +++ b/services_app/src/androidTest/java/org/opendatakit/TestConsts.java @@ -5,4 +5,7 @@ */ public class TestConsts { public static final String APPNAME = "unittestTMP"; + + public static final long WAIT_TIME = 2000; + } diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java index 0558aa96a..e3cea81f3 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java @@ -28,6 +28,7 @@ import org.junit.Rule; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -62,7 +63,7 @@ protected void setUpPostLaunch() { } @Test public void verifyValuesTest() { - onView(isRoot()).perform(waitFor(2000)); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); onView(withId(R.id.tvTitleLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); onView(withId(R.id.btnAnonymousSignInLogin)).check(matches(withText(R.string.anonymous_user))); @@ -71,11 +72,32 @@ public void verifyValuesTest() { onView(withId(R.id.btnUserSignInLogin)).check(matches(isEnabled())); } + @Ignore @Test public void verifyVisibilityTest() { +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD onView(isRoot()).perform(waitFor(2000)); +======= + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); +>>>>>>> 924db666 (wait time constant added) onView(allOf(withId(R.id.btnDrawerOpen), isDisplayed())).check(matches(isDisplayed())); onView(allOf(withId(R.id.btnDrawerOpen), isDisplayed())).perform(click()); +======= + onView(isRoot()).perform(BaseUITest.waitFor(2000)); + onView(allOf(withId(R.id.btnDrawerOpen), isDisplayed())).perform(click()); + onView(isRoot()).perform(BaseUITest.waitFor(2000)); +>>>>>>> 22e6c7c0 ( Fix for UI Tests) +======= + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), 3000)); +======= + onView(isRoot()).perform(waitFor(2000)); +>>>>>>> a118d2ac ( Fix for UI Tests) + onView(allOf(withId(R.id.btnDrawerOpen), isDisplayed())).check(matches(isDisplayed())); + onView(allOf(withId(R.id.btnDrawerOpen), isDisplayed())).perform(click()); +>>>>>>> 45a6791e ( Fix for UI Tests) onView(withId(R.id.drawer_update_credentials)).check(doesNotExist()); onView(withId(R.id.drawer_switch_sign_in_type)).check(doesNotExist()); } @@ -89,15 +111,15 @@ public void checkDrawerServerLoginTest() { onView(withId(R.id.inputServerUrl)).check(matches(isDisplayed())); onView(withId(R.id.inputTextServerUrl)).check(matches(withText(TEST_SERVER_URL))); } - + @Ignore @Test public void checkToolbarSettingsButtonClick() { onView(withId(R.id.action_settings)).perform(ViewActions.click()); - onView(isRoot()).perform(waitFor(2000)); Intents.intended(IntentMatchers.hasComponent(AppPropertiesActivity.class.getName())); } + @Ignore @Test public void checkDrawerSettingsClick() { onView(withId(R.id.btnDrawerOpen)).perform(click()); diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java index 26f87f9d1..bb19f0aaa 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java @@ -3,7 +3,14 @@ import static androidx.test.espresso.Espresso.closeSoftKeyboard; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.click; +<<<<<<< HEAD +<<<<<<< HEAD import static androidx.test.espresso.action.ViewActions.scrollTo; +======= +>>>>>>> 40da2db5 ( Fix for UI Tests) +======= +import static androidx.test.espresso.action.ViewActions.scrollTo; +>>>>>>> 94872db3 ( Fix for UI Tests) import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA; @@ -16,6 +23,18 @@ import static com.google.common.truth.Truth.assertThat; import static org.hamcrest.Matchers.allOf; +<<<<<<< HEAD +======= + +import android.content.Context; +import android.content.Intent; +<<<<<<< HEAD +>>>>>>> 45a6791e ( Fix for UI Tests) +======= +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; +>>>>>>> d64f219e ( Fix for UI Tests) import android.content.Context; import android.content.Intent; @@ -34,6 +53,7 @@ import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -135,11 +155,11 @@ public void verifyToolbarSyncItemClick() { @Test public void verifyDrawerResolveConflictsClick() { - onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), 3000)); + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), TestConsts.WAIT_TIME)); onView(withId(R.id.btnDrawerOpen)).perform(click()); onView(withId(R.id.drawer_resolve_conflict)).perform(click()); - onView(isRoot()).perform(waitFor(2000)); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); Intents.intended(IntentMatchers.hasComponent(AllConflictsResolutionActivity.class.getName())); } @@ -155,23 +175,91 @@ public void verifyDrawerSwitchSignInTypeClick() { onView(withId(R.id.inputUsernameLogin)).check(matches(isDisplayed())); } + + @Ignore @Test public void verifyDrawerSignOutButtonClick() { +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); +<<<<<<< HEAD + Espresso.onIdle(); + onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())); +======= + +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + onView(isRoot()).perform(BaseUITest.waitFor(2000)); +>>>>>>> 5bcc7fe2 ( Fix for UI Tests) +======= + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerLogin), 2000)); + onView(allOf(withId(R.id.btnDrawerLogin), isDisplayed())).check(matches(isDisplayed())); +>>>>>>> 45a6791e ( Fix for UI Tests) + onView(withId(R.id.btnDrawerLogin)).perform(ViewActions.click()); +======= + onView(allOf(withId(R.id.btnDrawerLogin), isDisplayed())).check(matches(isDisplayed())).perform(ViewActions.click()); +>>>>>>> a118d2ac ( Fix for UI Tests) +======= + onView(allOf(withId(R.id.btnDrawerLogin))).check(matches(isDisplayed())).perform(ViewActions.click()); +>>>>>>> d64f219e ( Fix for UI Tests) +======= + onView(withId(R.id.btnDrawerOpen)).perform(click()); +<<<<<<< HEAD +<<<<<<< HEAD + +<<<<<<< HEAD + onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())).perform(click()); +>>>>>>> 40da2db5 ( Fix for UI Tests) +======= + onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())).perform(ViewActions.click()); +>>>>>>> b1589db3 ( Fix for UI Tests) +======= + closeSoftKeyboard(); + onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())).perform(scrollTo()).perform(ViewActions.click()); +>>>>>>> 94872db3 ( Fix for UI Tests) +======= + onView(withId(R.id.toolbarDrawerHeader)).perform(scrollTo()); + onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())).perform(ViewActions.click()); +>>>>>>> b0874724 ( Fix for UI Tests) + + onView(withId(R.id.tvUserStateMain)).check(matches(withText(getContext().getString(R.string.logged_out)))); + onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); + +======= + Context context = InstrumentationRegistry.getInstrumentation().getTargetContext(); + +======= +>>>>>>> 5aac9490 ( Fix for UI Tests) onView(withId(R.id.btnDrawerOpen)).perform(click()); Espresso.onIdle(); onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())); onView(withContentDescription("SIGN IN OR OUT")).perform(click()); +<<<<<<< HEAD + onView(withContentDescription(context.getString(R.string.drawer_sign_out_button_text))).perform(click()); + + onView(withId(R.id.tvUserStateMain)).check(matches(withText(context.getString(R.string.logged_out)))); + onView(withId(R.id.btnDrawerLogin)).check(matches(withText(context.getString(R.string.drawer_sign_in_button_text)))); +>>>>>>> 3ca3e72c ( Fix for UI Tests) +======= onView(withId(R.id.tvUserStateMain)).check(matches(withText(getContext().getString(R.string.logged_out)))); onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); +>>>>>>> 5aac9490 ( Fix for UI Tests) onView(withId(R.id.btnSignInMain)).check(matches(isDisplayed())); } + @Override protected Intent getLaunchIntent() { Intent intent = new Intent(getContext(), MainActivity.class); intent.putExtra(IntentConsts.INTENT_KEY_APP_NAME, APP_NAME); return intent; } +<<<<<<< HEAD + +======= +>>>>>>> d64f219e ( Fix for UI Tests) } \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java index bb8e02083..5b86f39a8 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java @@ -3,7 +3,14 @@ import static androidx.test.espresso.Espresso.closeSoftKeyboard; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.click; +<<<<<<< HEAD +<<<<<<< HEAD import static androidx.test.espresso.action.ViewActions.scrollTo; +======= +>>>>>>> 40da2db5 ( Fix for UI Tests) +======= +import static androidx.test.espresso.action.ViewActions.scrollTo; +>>>>>>> 94872db3 ( Fix for UI Tests) import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; @@ -32,6 +39,7 @@ import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -197,17 +205,70 @@ public void verifyDrawerUpdateCredentialsClick() { onView(withId(R.id.inputTextUsername)).check(matches(withText(TEST_USERNAME))); onView(withId(R.id.inputTextPassword)).check(matches(withText(""))); } - + @Ignore @Test public void verifyDrawerSignOutButtonClick() { +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + Espresso.onIdle(); + onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())); +======= + +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + onView(isRoot()).perform(BaseUITest.waitFor(2000)); +>>>>>>> 5bcc7fe2 ( Fix for UI Tests) +======= + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerLogin), 2000)); + onView(allOf(withId(R.id.btnDrawerLogin), isDisplayed())).check(matches(isDisplayed())); +>>>>>>> 45a6791e ( Fix for UI Tests) + onView(withId(R.id.btnDrawerLogin)).perform(ViewActions.click()); +======= + onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())).perform(click()); + +>>>>>>> 40da2db5 ( Fix for UI Tests) +======= + onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())).perform(ViewActions.click()); +>>>>>>> b1589db3 ( Fix for UI Tests) +======= + closeSoftKeyboard(); + onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())).perform(scrollTo()).perform(ViewActions.click()); +>>>>>>> 94872db3 ( Fix for UI Tests) +======= + onView(withId(R.id.toolbarDrawerHeader)).perform(scrollTo()); + onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())).perform(ViewActions.click()); +>>>>>>> b0874724 ( Fix for UI Tests) +======= + Context context = InstrumentationRegistry.getInstrumentation().getTargetContext(); + onView(withId(R.id.btnDrawerOpen)).perform(click()); + Espresso.onIdle(); + + onView(withContentDescription(context.getString(R.string.drawer_sign_out_button_text))).perform(click()); +>>>>>>> 3ca3e72c ( Fix for UI Tests) +======= onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); Espresso.onIdle(); onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())); onView(withContentDescription("SIGN IN OR OUT")).perform(click()); +>>>>>>> 5aac9490 ( Fix for UI Tests) +======= + onView(withId(R.id.btnDrawerOpen)).perform(click()); + + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerLogin), TestConsts.WAIT_TIME)); + onView(withId(R.id.btnDrawerLogin)).perform(click()); + onView(isRoot()).perform(BaseUITest.waitFor(TestConsts.WAIT_TIME)); +>>>>>>> 924db666 (wait time constant added) onView(withId(R.id.tvUserStateMain)).check(matches(withText(getContext().getString(R.string.logged_out)))); onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); onView(withId(R.id.btnSignInMain)).check(matches(isDisplayed())); } + } diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/GeneralStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/GeneralStateTest.java index 24c358bcf..102cc7715 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/GeneralStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/GeneralStateTest.java @@ -23,6 +23,7 @@ import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -89,10 +90,11 @@ public void checkToolbarVerifyBtnClick() { Intents.intended(IntentMatchers.hasComponent(VerifyServerSettingsActivity.class.getName())); } + @Ignore @Test public void checkToolbarSettingsBtnClick() { onView(withId(R.id.action_settings)).perform(ViewActions.click()); - onView(isRoot()).perform(waitFor(2000)); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); Intents.intended(IntentMatchers.hasComponent(AppPropertiesActivity.class.getName())); } @@ -125,4 +127,5 @@ public void checkDrawerAboutUsBtnClick() { onView(withId(org.opendatakit.androidlibrary.R.id.versionText)).check(matches(isDisplayed())); btnAboutUs.check(matches(isNotEnabled())); } + } diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java index 42fa46a0b..8fcde6ae6 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java @@ -23,6 +23,7 @@ import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -105,15 +106,16 @@ public void verifySignInButtonClickTest() { onView(withId(R.id.btnSignInMain)).perform(ViewActions.click()); Intents.intended(IntentMatchers.hasComponent(LoginActivity.class.getName())); } - + @Ignore @Test public void verifyDrawerSignInButtonClickTest() { - onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), 2000)); + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), TestConsts.WAIT_TIME)); onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); - onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerLogin), 2000)); + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerLogin), TestConsts.WAIT_TIME)); onView(withId(R.id.btnDrawerLogin)).perform(ViewActions.click()); - onView(isRoot()).perform(BaseUITest.waitFor(2000)); + onView(isRoot()).perform(BaseUITest.waitFor(TestConsts.WAIT_TIME)); Intents.intended(IntentMatchers.hasComponent(LoginActivity.class.getName())); } + } diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AnonymousStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AnonymousStateTest.java index f7e00b375..7b9342788 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AnonymousStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AnonymousStateTest.java @@ -24,6 +24,7 @@ import org.junit.Rule; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -97,7 +98,7 @@ public void verifyDrawerResolveConflictsClick() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); try { - Thread.sleep(3000); + Thread.sleep(TestConsts.WAIT_TIME); } catch (InterruptedException e) { e.printStackTrace(); } @@ -105,7 +106,7 @@ public void verifyDrawerResolveConflictsClick() { onView(withId(R.id.drawer_resolve_conflict)).perform(ViewActions.click()); try { - Thread.sleep(3000); + Thread.sleep(TestConsts.WAIT_TIME); } catch (InterruptedException e) { e.printStackTrace(); } diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AuthenticatedUserStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AuthenticatedUserStateTest.java index c2f5e45da..9c82c0378 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AuthenticatedUserStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AuthenticatedUserStateTest.java @@ -25,6 +25,7 @@ import org.junit.Rule; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -119,7 +120,7 @@ public void verifyDrawerResolveConflictsClick() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); try { - Thread.sleep(3000); + Thread.sleep(TestConsts.WAIT_TIME); } catch (InterruptedException e) { e.printStackTrace(); } @@ -127,7 +128,7 @@ public void verifyDrawerResolveConflictsClick() { onView(withId(R.id.drawer_resolve_conflict)).perform(ViewActions.click()); try { - Thread.sleep(3000); + Thread.sleep(TestConsts.WAIT_TIME); } catch (InterruptedException e) { e.printStackTrace(); } diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/GeneralStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/GeneralStateTest.java index 75f2aad15..2fc7df77d 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/GeneralStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/GeneralStateTest.java @@ -20,8 +20,10 @@ import androidx.test.espresso.matcher.RootMatchers; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -70,10 +72,11 @@ public void verifyValuesTest() { @Test public void checkToolbarSettingsButtonClick() { onView(withId(R.id.action_settings)).perform(ViewActions.click()); - onView(isRoot()).perform(waitFor(2000)); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); Intents.intended(IntentMatchers.hasComponent(AppPropertiesActivity.class.getName())); } + @Ignore @Test public void checkDrawerSettingsClick() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/activities/AdminAppPropertiesActivityTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/activities/AdminAppPropertiesActivityTest.java index e1113e697..024e1bcf6 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/activities/AdminAppPropertiesActivityTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/activities/AdminAppPropertiesActivityTest.java @@ -37,7 +37,7 @@ protected void setUpPostLaunch() { enableAdminMode(); Espresso.pressBack(); } - + @Ignore @Test public void checkIfChangeAdminPasswordScreen_isVisible() { onView(withId(androidx.preference.R.id.recycler_view)).perform(actionOnItemAtPosition(3, scrollTo())) @@ -46,7 +46,7 @@ public void checkIfChangeAdminPasswordScreen_isVisible() { childAtPosition(withId(androidx.preference.R.id.recycler_view), 3), isDisplayed())).check(matches(withText(R.string.admin_password_enabled))); } - + @Ignore @Test public void checkIfManageAbilityToChangeServerSettingScreen_isVisible() { onView(withId(androidx.preference.R.id.recycler_view)).perform(actionOnItemAtPosition(8, scrollTo())) @@ -56,7 +56,7 @@ public void checkIfManageAbilityToChangeServerSettingScreen_isVisible() { isDisplayed())).check(matches(withText(R.string.restrict_server_settings_summary))); } - + @Ignore @Test public void checkIfManageAbilityToChangeDeviceSettingScreen_isVisible() { onView(withId(androidx.preference.R.id.recycler_view)).perform(actionOnItemAtPosition(9, scrollTo())) @@ -65,7 +65,7 @@ public void checkIfManageAbilityToChangeDeviceSettingScreen_isVisible() { childAtPosition(withId(androidx.preference.R.id.recycler_view), 9), isDisplayed())).check(matches(withText(R.string.restrict_device_settings_summary))); } - + @Ignore @Test public void checkIfManageAbilityToChangeTableSpecificSettingScreen_isVisible() { onView(withId(androidx.preference.R.id.recycler_view)).perform(actionOnItemAtPosition(10, scrollTo())) @@ -75,6 +75,7 @@ public void checkIfManageAbilityToChangeTableSpecificSettingScreen_isVisible() { isDisplayed())).check(matches(withText(R.string.admin_tool_tables_settings_summary))); } + @Ignore @Test public void checkIfResetConfigurationScreen_isVisible() { onView(withId(androidx.preference.R.id.recycler_view)).perform(actionOnItemAtPosition(6, scrollTo())) @@ -84,6 +85,7 @@ public void checkIfResetConfigurationScreen_isVisible() { isDisplayed())).check(matches(withText(R.string.clear_configuration_settings))); } + @Ignore @Test public void checkIfExitAdminModeScreen_isVisible() { onView(withId(androidx.preference.R.id.recycler_view)).perform(actionOnItemAtPosition(11, scrollTo())) diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableDeviceSettingsFragmentTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableDeviceSettingsFragmentTest.java index 1c074ad3f..df82b7615 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableDeviceSettingsFragmentTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableDeviceSettingsFragmentTest.java @@ -24,6 +24,7 @@ import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.PropertiesSingleton; import org.opendatakit.services.R; @@ -102,7 +103,7 @@ private void launchDeviceSettingPreferenceScreen() { onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.exit_admin_mode)), click())); - onView(isRoot()).perform(waitFor(1000)); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.preferences)), diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableServerSettingsFragmentTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableServerSettingsFragmentTest.java index 3a12d59a3..6d83cf2f7 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableServerSettingsFragmentTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableServerSettingsFragmentTest.java @@ -27,6 +27,7 @@ import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.PropertiesSingleton; import org.opendatakit.services.R; @@ -117,7 +118,7 @@ public void launchServerSettingPreferenceScreen() { onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.exit_admin_mode)), click())); - onView(isRoot()).perform(waitFor(1000)); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.server)), diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableTablesSettingsFragmentTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableTablesSettingsFragmentTest.java index 17a8fffb2..62b381254 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableTablesSettingsFragmentTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableTablesSettingsFragmentTest.java @@ -25,6 +25,7 @@ import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.PropertiesSingleton; import org.opendatakit.services.R; @@ -94,7 +95,7 @@ private void launchTableServerSettingPreferenceScreen() { .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.exit_admin_mode)), click())); - onView(isRoot()).perform(waitFor(1000)); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.odkx_tables)), diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/VerifyUserPermissionTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/VerifyUserPermissionTest.java index 83a44d773..4840f5d51 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/VerifyUserPermissionTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/VerifyUserPermissionTest.java @@ -22,6 +22,7 @@ import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.PropertiesSingleton; import org.opendatakit.services.R; @@ -57,15 +58,15 @@ public void whenVerifyUserPermissionIsClicked_configureServerUrl() { onView(withId(androidx.preference.R.id.recycler_view)).perform(RecyclerViewActions.actionOnItem( hasDescendant(withText(R.string.verify_server_settings_header)), click())); - onView(isRoot()).perform(BaseUITest.waitForView(withText(R.string.configure_server_settings), 3000)); + onView(isRoot()).perform(BaseUITest.waitForView(withText(R.string.configure_server_settings), TestConsts.WAIT_TIME)); onView(withText(R.string.configure_server_settings)) .inRoot(isDialog()) .check(matches(isDisplayed())); - onView(isRoot()).perform(BaseUITest.waitForView(allOf(withId(android.R.id.button1), withText(R.string.yes)), 2000)); + onView(isRoot()).perform(BaseUITest.waitForView(allOf(withId(android.R.id.button1), withText(R.string.yes)), TestConsts.WAIT_TIME)); onView(allOf(withId(android.R.id.button1), withText(R.string.yes))).perform(click()); - onView(isRoot()).perform(BaseUITest.waitFor(1500)); + onView(isRoot()).perform(BaseUITest.waitFor(TestConsts.WAIT_TIME)); intended(hasComponent(VerifyServerSettingsActivity.class.getName())); } diff --git a/services_app/src/main/res/values/strings.xml b/services_app/src/main/res/values/strings.xml index 458002761..34c5687e7 100644 --- a/services_app/src/main/res/values/strings.xml +++ b/services_app/src/main/res/values/strings.xml @@ -450,5 +450,6 @@ Sign in using Credentials Set Credentials Sign in as Anonymous User + SIGN IN OR OUT From b1917fddf25bc101c809dfa4423a91329673c59e Mon Sep 17 00:00:00 2001 From: Stryker101 Date: Sat, 8 Jun 2024 09:00:36 +0100 Subject: [PATCH 09/13] rebase with clean history --- .circleci/config.yml | 114 +----------------- .../LoginActivity/GeneralStateTest.java | 22 +--- .../MainActivity/AnonymousStateTest.java | 82 ------------- .../AuthenticatedUserStateTest.java | 60 +-------- 4 files changed, 3 insertions(+), 275 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7cd93e60b..3e22c5e76 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -19,27 +19,7 @@ jobs: - android/create-avd: avd-name: Pixel_7_Pro -<<<<<<< HEAD -<<<<<<< HEAD -<<<<<<< HEAD -<<<<<<< HEAD -<<<<<<< HEAD - system-image: system-images;android-29;google_apis_playstore;x86_64 -======= - system-image: system-images;android-33;google_apis_playstore;x86_64 ->>>>>>> 9f1ae595 ( Fix for UI Tests) -======= - system-image: system-images;android-29;google_apis_playstore;x86_64 ->>>>>>> 3a2a597e ( Fix for UI Tests) -======= - system-image: system-images;android-33;google_apis_playstore;x86_64 ->>>>>>> 45a6791e ( Fix for UI Tests) -======= - system-image: system-images;android-30;google_apis_playstore;x86_64 ->>>>>>> 51a777b9 (attempt to stabilize 5) -======= system-image: system-images;android-30;google_apis;x86 ->>>>>>> 318f2cff (new system image) install: true - run: @@ -52,36 +32,6 @@ jobs: restore-gradle-cache-prefix: v1 memory: 4096 post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug -<<<<<<< HEAD -<<<<<<< HEAD -<<<<<<< HEAD -<<<<<<< HEAD -<<<<<<< HEAD -======= - environment: - TERM: dumb ->>>>>>> 5bcc7fe2 ( Fix for UI Tests) -======= ->>>>>>> 76b97389 ( Fix for UI Tests) -======= - - run: - name: Wait for Emulator - command: | - # Wait for the emulator to fully boot up - adb wait-for-device - sleep 30 - adb shell input keyevent 82 - - run: - name: Restart ADB Server - command: | - adb kill-server - adb start-server - adb devices ->>>>>>> c69c8a83 ( Fix for UI Tests) - - android/disable-animations -<<<<<<< HEAD -<<<<<<< HEAD -======= - android/disable-animations @@ -93,74 +43,12 @@ jobs: name: Restart ADB server command: adb kill-server && adb start-server # Restart ADB server to avoid version mismatch issues ->>>>>>> 85dc4a48 (attempt to stabilize 3) - android/run-tests: test-command: ./gradlew testSnapshotDebugUnitTest - android/run-tests: -<<<<<<< HEAD -<<<<<<< HEAD - test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info -<<<<<<< HEAD -======= - test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest -<<<<<<< HEAD - environment: - TERM: dumb ->>>>>>> 5bcc7fe2 ( Fix for UI Tests) -======= - no-output-timeout: 1h ->>>>>>> e9ef26b7 ( Fix for UI Tests) -======= - command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info - no-output-timeout: 30min ->>>>>>> c69c8a83 ( Fix for UI Tests) -======= - - run: - name: Run Unit Tests - command: ./gradlew testSnapshotDebugUnitTest --info - - run: - name: Run Instrumented Tests - command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info -<<<<<<< HEAD -======= - - android/disable-animations -<<<<<<< HEAD - - android/run-tests: - test-command: ./gradlew testSnapshotDebugUnitTest --info - - android/run-tests: -<<<<<<< HEAD - test-command:./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info ->>>>>>> b9c61bc2 ( Fix for UI Tests) -======= - test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info ->>>>>>> 418f0144 ( Fix for UI Tests) -======= - - run: - name: Run Unit Tests - command: ./gradlew testSnapshotDebugUnitTest --info - - run: - name: Run Instrumented Tests - command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info ->>>>>>> 83c7d35b ( Fix for UI Tests) - no-output-timeout: 30m ->>>>>>> 3fa89f75 ( Fix for UI Tests) -======= - timeout: 30m ->>>>>>> 63c2d1c0 ( Fix for UI Tests) -======= - - android/run-tests: - test-command: ./gradlew testSnapshotDebugUnitTest - - android/run-tests: -<<<<<<< HEAD test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info ->>>>>>> 3a2a597e ( Fix for UI Tests) -======= - test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest ->>>>>>> 5df9181a ( Fix for UI Tests) -======= ->>>>>>> 85dc4a48 (attempt to stabilize 3) - android/save-gradle-cache: cache-prefix: v1 @@ -212,4 +100,4 @@ workflows: - build - test: requires: - - build + - build \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java index e3cea81f3..811e67fd2 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java @@ -75,29 +75,9 @@ public void verifyValuesTest() { @Ignore @Test public void verifyVisibilityTest() { -<<<<<<< HEAD -<<<<<<< HEAD -<<<<<<< HEAD -<<<<<<< HEAD - onView(isRoot()).perform(waitFor(2000)); -======= onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); ->>>>>>> 924db666 (wait time constant added) onView(allOf(withId(R.id.btnDrawerOpen), isDisplayed())).check(matches(isDisplayed())); onView(allOf(withId(R.id.btnDrawerOpen), isDisplayed())).perform(click()); -======= - onView(isRoot()).perform(BaseUITest.waitFor(2000)); - onView(allOf(withId(R.id.btnDrawerOpen), isDisplayed())).perform(click()); - onView(isRoot()).perform(BaseUITest.waitFor(2000)); ->>>>>>> 22e6c7c0 ( Fix for UI Tests) -======= - onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), 3000)); -======= - onView(isRoot()).perform(waitFor(2000)); ->>>>>>> a118d2ac ( Fix for UI Tests) - onView(allOf(withId(R.id.btnDrawerOpen), isDisplayed())).check(matches(isDisplayed())); - onView(allOf(withId(R.id.btnDrawerOpen), isDisplayed())).perform(click()); ->>>>>>> 45a6791e ( Fix for UI Tests) onView(withId(R.id.drawer_update_credentials)).check(doesNotExist()); onView(withId(R.id.drawer_switch_sign_in_type)).check(doesNotExist()); } @@ -133,4 +113,4 @@ protected Intent getLaunchIntent() { intent.putExtra(IntentConsts.INTENT_KEY_APP_NAME, APP_NAME); return intent; } -} +} \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java index bb19f0aaa..e7b0ea0e4 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java @@ -3,14 +3,7 @@ import static androidx.test.espresso.Espresso.closeSoftKeyboard; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.click; -<<<<<<< HEAD -<<<<<<< HEAD import static androidx.test.espresso.action.ViewActions.scrollTo; -======= ->>>>>>> 40da2db5 ( Fix for UI Tests) -======= -import static androidx.test.espresso.action.ViewActions.scrollTo; ->>>>>>> 94872db3 ( Fix for UI Tests) import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA; @@ -23,18 +16,6 @@ import static com.google.common.truth.Truth.assertThat; import static org.hamcrest.Matchers.allOf; -<<<<<<< HEAD -======= - -import android.content.Context; -import android.content.Intent; -<<<<<<< HEAD ->>>>>>> 45a6791e ( Fix for UI Tests) -======= -import android.util.Log; -import android.view.View; -import android.view.ViewGroup; ->>>>>>> d64f219e ( Fix for UI Tests) import android.content.Context; import android.content.Intent; @@ -179,74 +160,14 @@ public void verifyDrawerSwitchSignInTypeClick() { @Ignore @Test public void verifyDrawerSignOutButtonClick() { -<<<<<<< HEAD -<<<<<<< HEAD -<<<<<<< HEAD onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); -<<<<<<< HEAD Espresso.onIdle(); onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())); -======= - -<<<<<<< HEAD -<<<<<<< HEAD -<<<<<<< HEAD - onView(isRoot()).perform(BaseUITest.waitFor(2000)); ->>>>>>> 5bcc7fe2 ( Fix for UI Tests) -======= - onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerLogin), 2000)); - onView(allOf(withId(R.id.btnDrawerLogin), isDisplayed())).check(matches(isDisplayed())); ->>>>>>> 45a6791e ( Fix for UI Tests) onView(withId(R.id.btnDrawerLogin)).perform(ViewActions.click()); -======= - onView(allOf(withId(R.id.btnDrawerLogin), isDisplayed())).check(matches(isDisplayed())).perform(ViewActions.click()); ->>>>>>> a118d2ac ( Fix for UI Tests) -======= - onView(allOf(withId(R.id.btnDrawerLogin))).check(matches(isDisplayed())).perform(ViewActions.click()); ->>>>>>> d64f219e ( Fix for UI Tests) -======= - onView(withId(R.id.btnDrawerOpen)).perform(click()); -<<<<<<< HEAD -<<<<<<< HEAD - -<<<<<<< HEAD - onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())).perform(click()); ->>>>>>> 40da2db5 ( Fix for UI Tests) -======= - onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())).perform(ViewActions.click()); ->>>>>>> b1589db3 ( Fix for UI Tests) -======= - closeSoftKeyboard(); - onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())).perform(scrollTo()).perform(ViewActions.click()); ->>>>>>> 94872db3 ( Fix for UI Tests) -======= - onView(withId(R.id.toolbarDrawerHeader)).perform(scrollTo()); - onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())).perform(ViewActions.click()); ->>>>>>> b0874724 ( Fix for UI Tests) onView(withId(R.id.tvUserStateMain)).check(matches(withText(getContext().getString(R.string.logged_out)))); onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); -======= - Context context = InstrumentationRegistry.getInstrumentation().getTargetContext(); - -======= ->>>>>>> 5aac9490 ( Fix for UI Tests) - onView(withId(R.id.btnDrawerOpen)).perform(click()); - Espresso.onIdle(); - onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())); - onView(withContentDescription("SIGN IN OR OUT")).perform(click()); - -<<<<<<< HEAD - onView(withContentDescription(context.getString(R.string.drawer_sign_out_button_text))).perform(click()); - - onView(withId(R.id.tvUserStateMain)).check(matches(withText(context.getString(R.string.logged_out)))); - onView(withId(R.id.btnDrawerLogin)).check(matches(withText(context.getString(R.string.drawer_sign_in_button_text)))); ->>>>>>> 3ca3e72c ( Fix for UI Tests) -======= - onView(withId(R.id.tvUserStateMain)).check(matches(withText(getContext().getString(R.string.logged_out)))); - onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); ->>>>>>> 5aac9490 ( Fix for UI Tests) onView(withId(R.id.btnSignInMain)).check(matches(isDisplayed())); } @@ -258,8 +179,5 @@ protected Intent getLaunchIntent() { intent.putExtra(IntentConsts.INTENT_KEY_APP_NAME, APP_NAME); return intent; } -<<<<<<< HEAD -======= ->>>>>>> d64f219e ( Fix for UI Tests) } \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java index 5b86f39a8..77ed57cc8 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java @@ -3,14 +3,7 @@ import static androidx.test.espresso.Espresso.closeSoftKeyboard; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.click; -<<<<<<< HEAD -<<<<<<< HEAD import static androidx.test.espresso.action.ViewActions.scrollTo; -======= ->>>>>>> 40da2db5 ( Fix for UI Tests) -======= -import static androidx.test.espresso.action.ViewActions.scrollTo; ->>>>>>> 94872db3 ( Fix for UI Tests) import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; @@ -208,62 +201,11 @@ public void verifyDrawerUpdateCredentialsClick() { @Ignore @Test public void verifyDrawerSignOutButtonClick() { -<<<<<<< HEAD -<<<<<<< HEAD -<<<<<<< HEAD - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); -<<<<<<< HEAD -<<<<<<< HEAD -<<<<<<< HEAD - Espresso.onIdle(); - onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())); -======= - -<<<<<<< HEAD -<<<<<<< HEAD -<<<<<<< HEAD - onView(isRoot()).perform(BaseUITest.waitFor(2000)); ->>>>>>> 5bcc7fe2 ( Fix for UI Tests) -======= - onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerLogin), 2000)); - onView(allOf(withId(R.id.btnDrawerLogin), isDisplayed())).check(matches(isDisplayed())); ->>>>>>> 45a6791e ( Fix for UI Tests) - onView(withId(R.id.btnDrawerLogin)).perform(ViewActions.click()); -======= - onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())).perform(click()); - ->>>>>>> 40da2db5 ( Fix for UI Tests) -======= - onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())).perform(ViewActions.click()); ->>>>>>> b1589db3 ( Fix for UI Tests) -======= - closeSoftKeyboard(); - onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())).perform(scrollTo()).perform(ViewActions.click()); ->>>>>>> 94872db3 ( Fix for UI Tests) -======= - onView(withId(R.id.toolbarDrawerHeader)).perform(scrollTo()); - onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())).perform(ViewActions.click()); ->>>>>>> b0874724 ( Fix for UI Tests) -======= - Context context = InstrumentationRegistry.getInstrumentation().getTargetContext(); - onView(withId(R.id.btnDrawerOpen)).perform(click()); - Espresso.onIdle(); - - onView(withContentDescription(context.getString(R.string.drawer_sign_out_button_text))).perform(click()); ->>>>>>> 3ca3e72c ( Fix for UI Tests) -======= - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); - Espresso.onIdle(); - onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())); - onView(withContentDescription("SIGN IN OR OUT")).perform(click()); ->>>>>>> 5aac9490 ( Fix for UI Tests) -======= onView(withId(R.id.btnDrawerOpen)).perform(click()); onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerLogin), TestConsts.WAIT_TIME)); onView(withId(R.id.btnDrawerLogin)).perform(click()); onView(isRoot()).perform(BaseUITest.waitFor(TestConsts.WAIT_TIME)); ->>>>>>> 924db666 (wait time constant added) onView(withId(R.id.tvUserStateMain)).check(matches(withText(getContext().getString(R.string.logged_out)))); onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); @@ -271,4 +213,4 @@ >>>>>>> b0874724 ( Fix for UI Tests) onView(withId(R.id.btnSignInMain)).check(matches(isDisplayed())); } -} +} \ No newline at end of file From dff01a83f5b3c68a5a215a2d482206f2a3f2f12b Mon Sep 17 00:00:00 2001 From: Stryker101 Date: Wed, 12 Jun 2024 11:39:20 +0100 Subject: [PATCH 10/13] resolved minor errors --- .../opendatakit/activites/LoginActivity/GeneralStateTest.java | 2 +- .../opendatakit/activites/MainActivity/AnonymousStateTest.java | 2 +- .../activites/MainActivity/AuthenticatedUserStateTest.java | 2 +- .../src/main/java/org/opendatakit/services/MainActivity.java | 1 - services_app/src/main/res/values/strings.xml | 1 - 5 files changed, 3 insertions(+), 5 deletions(-) diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java index 811e67fd2..163d01ec5 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java @@ -113,4 +113,4 @@ protected Intent getLaunchIntent() { intent.putExtra(IntentConsts.INTENT_KEY_APP_NAME, APP_NAME); return intent; } -} \ No newline at end of file +} diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java index e7b0ea0e4..f27536840 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java @@ -180,4 +180,4 @@ protected Intent getLaunchIntent() { return intent; } -} \ No newline at end of file +} diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java index 77ed57cc8..57c80ae8e 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java @@ -213,4 +213,4 @@ public void verifyDrawerSignOutButtonClick() { onView(withId(R.id.btnSignInMain)).check(matches(isDisplayed())); } -} \ No newline at end of file +} diff --git a/services_app/src/main/java/org/opendatakit/services/MainActivity.java b/services_app/src/main/java/org/opendatakit/services/MainActivity.java index a1e1c309e..247c638a5 100644 --- a/services_app/src/main/java/org/opendatakit/services/MainActivity.java +++ b/services_app/src/main/java/org/opendatakit/services/MainActivity.java @@ -16,7 +16,6 @@ import android.Manifest; import android.app.Activity; -import android.content.ComponentName; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageManager; diff --git a/services_app/src/main/res/values/strings.xml b/services_app/src/main/res/values/strings.xml index 34c5687e7..458002761 100644 --- a/services_app/src/main/res/values/strings.xml +++ b/services_app/src/main/res/values/strings.xml @@ -450,6 +450,5 @@ Sign in using Credentials Set Credentials Sign in as Anonymous User - SIGN IN OR OUT From 2245fd58855a310ba2b4618c1964c2b968187dc1 Mon Sep 17 00:00:00 2001 From: Stryker101 Date: Tue, 4 Jun 2024 10:00:57 +0100 Subject: [PATCH 11/13] resolved minor errors (+2 squashed commit) Squashed commit: [b1917fdd] rebase with clean history [8eeed74b] attempt to stabilize 1 Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests Fix for UI Tests attempt to stabilize 2 attempt to stabilize 3 attempt to stabilize 3 attempt to stabilize 4 attempt to stabilize 5 attempt to stabilize 6 wait time constant added wait time constant amended new system image (+1 squashed commits) Squashed commits: [c42011b6] fix for ui tests --- .circleci/config.yml | 45 +++++++++++++++---- .../java/org/opendatakit/BaseUITest.java | 10 ++--- .../java/org/opendatakit/TestConsts.java | 3 ++ .../LoginActivity/GeneralStateTest.java | 12 ++--- .../MainActivity/AnonymousStateTest.java | 43 ++++++++++++------ .../AuthenticatedUserStateTest.java | 21 ++++++--- .../MainActivity/GeneralStateTest.java | 5 ++- .../MainActivity/LoggedOutStateTest.java | 10 +++-- .../AnonymousStateTest.java | 5 ++- .../AuthenticatedUserStateTest.java | 5 ++- .../GeneralStateTest.java | 5 ++- .../AdminAppPropertiesActivityTest.java | 10 +++-- ...onfigurableDeviceSettingsFragmentTest.java | 3 +- ...onfigurableServerSettingsFragmentTest.java | 3 +- ...onfigurableTablesSettingsFragmentTest.java | 3 +- .../fragments/VerifyUserPermissionTest.java | 7 +-- .../opendatakit/services/MainActivity.java | 1 - .../src/main/res/layout/drawer_header.xml | 1 + 18 files changed, 132 insertions(+), 60 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f94a866c2..3e22c5e76 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,14 +1,14 @@ - version: 2.1 orbs: android: circleci/android@2.4.0 + jobs: test: description: Runs unit tests and instrumented tests on the Android Common executor: name: android/android-machine - resource-class: large + resource-class: xlarge tag: 2024.01.1 steps: @@ -18,25 +18,44 @@ jobs: command: sudo chmod +x gradlew - android/create-avd: - avd-name: avd + avd-name: Pixel_7_Pro + system-image: system-images;android-30;google_apis;x86 install: true - system-image: system-images;android-29;default;x86 + + - run: + name: Start ADB server + command: adb start-server + - android/start-emulator: - avd-name: avd + avd-name: Pixel_7_Pro no-window: true restore-gradle-cache-prefix: v1 - memory: 4096 - post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug + memory: 4096 + post-emulator-launch-assemble-command: ./gradlew installSnapshotDebug + - android/disable-animations + + - run: + name: Wait for Emulator to be Ready + command: adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done; sleep 5' # Ensures the emulator is fully booted + + - run: + name: Restart ADB server + command: adb kill-server && adb start-server # Restart ADB server to avoid version mismatch issues + - android/run-tests: test-command: ./gradlew testSnapshotDebugUnitTest + - android/run-tests: - test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest + test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info + - android/save-gradle-cache: cache-prefix: v1 + - store_artifacts: name: Store Test Results path: services_app/build/outputs/androidTest-results + - store_artifacts: name: Store Test Reports path: services_app/build/reports @@ -44,24 +63,32 @@ jobs: build: docker: - image: cimg/android:2024.01 + steps: - checkout + - run: name: Chmod Permissions command: sudo chmod +x gradlew + - android/restore-gradle-cache: cache-prefix: v1 + - run: name: Download Dependencies command: ./gradlew androidDependencies + - android/save-gradle-cache: cache-prefix: v1 + - run: name: Build Services command: ./gradlew assembleSnapshotDebug + - store_artifacts: name: Store Build Artifacts path: services_app/build/outputs/apk + - persist_to_workspace: root: . paths: @@ -73,4 +100,4 @@ workflows: - build - test: requires: - - build + - build \ No newline at end of file diff --git a/services_app/src/androidTest/java/org/opendatakit/BaseUITest.java b/services_app/src/androidTest/java/org/opendatakit/BaseUITest.java index 27ac86fd9..daa2d8d5c 100644 --- a/services_app/src/androidTest/java/org/opendatakit/BaseUITest.java +++ b/services_app/src/androidTest/java/org/opendatakit/BaseUITest.java @@ -41,6 +41,7 @@ import androidx.test.espresso.intent.Intents; import androidx.test.espresso.matcher.BoundedMatcher; import androidx.test.espresso.matcher.ViewMatchers; +import androidx.test.espresso.util.HumanReadables; import androidx.test.espresso.util.TreeIterables; import androidx.test.platform.app.InstrumentationRegistry; @@ -214,18 +215,17 @@ public Matcher getConstraints() { @Override public String getDescription() { - return "wait for a specific view with matcher <" + viewMatcher + "> during " + millis + " millis."; + return "Wait for a specific view with id <" + viewMatcher + "> during " + millis + " millis."; } @Override public void perform(final UiController uiController, final View view) { final long startTime = System.currentTimeMillis(); final long endTime = startTime + millis; - final Matcher finalViewMatcher = viewMatcher; do { for (View child : TreeIterables.breadthFirstViewTraversal(view)) { - if (finalViewMatcher.matches(child)) { + if (viewMatcher.matches(child)) { return; } } @@ -233,16 +233,14 @@ public void perform(final UiController uiController, final View view) { uiController.loopMainThreadForAtLeast(50); } while (System.currentTimeMillis() < endTime); - // Timeout happened. throw new PerformException.Builder() .withActionDescription(this.getDescription()) - .withViewDescription(view.toString()) + .withViewDescription(HumanReadables.describe(view)) .withCause(new TimeoutException()) .build(); } }; } - public static void enableAdminMode() { onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.user_restrictions)), diff --git a/services_app/src/androidTest/java/org/opendatakit/TestConsts.java b/services_app/src/androidTest/java/org/opendatakit/TestConsts.java index e25851855..d29b768c9 100644 --- a/services_app/src/androidTest/java/org/opendatakit/TestConsts.java +++ b/services_app/src/androidTest/java/org/opendatakit/TestConsts.java @@ -5,4 +5,7 @@ */ public class TestConsts { public static final String APPNAME = "unittestTMP"; + + public static final long WAIT_TIME = 2000; + } diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java index bb744dc21..163d01ec5 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java @@ -28,6 +28,7 @@ import org.junit.Rule; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -62,7 +63,7 @@ protected void setUpPostLaunch() { } @Test public void verifyValuesTest() { - onView(isRoot()).perform(waitFor(2000)); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); onView(withId(R.id.tvTitleLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); onView(withId(R.id.btnAnonymousSignInLogin)).check(matches(withText(R.string.anonymous_user))); @@ -71,11 +72,12 @@ public void verifyValuesTest() { onView(withId(R.id.btnUserSignInLogin)).check(matches(isEnabled())); } + @Ignore @Test public void verifyVisibilityTest() { - onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), 2000)); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); + onView(allOf(withId(R.id.btnDrawerOpen), isDisplayed())).check(matches(isDisplayed())); onView(allOf(withId(R.id.btnDrawerOpen), isDisplayed())).perform(click()); - Espresso.onIdle(); onView(withId(R.id.drawer_update_credentials)).check(doesNotExist()); onView(withId(R.id.drawer_switch_sign_in_type)).check(doesNotExist()); } @@ -89,15 +91,15 @@ public void checkDrawerServerLoginTest() { onView(withId(R.id.inputServerUrl)).check(matches(isDisplayed())); onView(withId(R.id.inputTextServerUrl)).check(matches(withText(TEST_SERVER_URL))); } - + @Ignore @Test public void checkToolbarSettingsButtonClick() { onView(withId(R.id.action_settings)).perform(ViewActions.click()); - onView(isRoot()).perform(waitFor(2000)); Intents.intended(IntentMatchers.hasComponent(AppPropertiesActivity.class.getName())); } + @Ignore @Test public void checkDrawerSettingsClick() { onView(withId(R.id.btnDrawerOpen)).perform(click()); diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java index bfdbc417d..f27536840 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java @@ -1,26 +1,40 @@ package org.opendatakit.activites.MainActivity; +import static androidx.test.espresso.Espresso.closeSoftKeyboard; import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.action.ViewActions.scrollTo; import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.isRoot; +import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription; import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; +import static org.hamcrest.Matchers.allOf; + +import android.content.Context; import android.content.Intent; +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; +import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; +import androidx.test.platform.app.InstrumentationRegistry; import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -70,7 +84,7 @@ public void checkFirstStartupTest() { activity.recreate(); }); - onView(withId(android.R.id.button1)).inRoot(RootMatchers.isDialog()).perform(ViewActions.click()); + onView(withId(android.R.id.button1)).inRoot(RootMatchers.isDialog()).perform(click()); onView(withId(R.id.inputServerUrl)).check(matches(isDisplayed())); onView(withId(R.id.inputTextServerUrl)).check(matches(withText(SERVER_URL))); @@ -83,7 +97,7 @@ public void verifyVisibilityTest() { onView(withId(R.id.tvLastSyncTimeMain)).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))); onView(withId(R.id.btnSignInMain)).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE))); - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); + onView(withId(R.id.btnDrawerOpen)).perform(click()); onView(withId(R.id.drawer_resolve_conflict)).check(matches(isDisplayed())); onView(withId(R.id.drawer_switch_sign_in_type)).check(matches(isDisplayed())); @@ -116,24 +130,24 @@ public void verifyLastSyncTimeTest() { @Test public void verifyToolbarSyncItemClick() { - onView(withId(R.id.action_sync)).perform(ViewActions.click()); + onView(withId(R.id.action_sync)).perform(click()); Intents.intended(IntentMatchers.hasComponent(SyncActivity.class.getName())); } @Test public void verifyDrawerResolveConflictsClick() { - onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), 3000)); + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), TestConsts.WAIT_TIME)); - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); - onView(withId(R.id.drawer_resolve_conflict)).perform(ViewActions.click()); - onView(isRoot()).perform(waitFor(2000)); + onView(withId(R.id.btnDrawerOpen)).perform(click()); + onView(withId(R.id.drawer_resolve_conflict)).perform(click()); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); Intents.intended(IntentMatchers.hasComponent(AllConflictsResolutionActivity.class.getName())); } @Test public void verifyDrawerSwitchSignInTypeClick() { - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); - onView(withId(R.id.drawer_switch_sign_in_type)).perform(ViewActions.click()); + onView(withId(R.id.btnDrawerOpen)).perform(click()); + onView(withId(R.id.drawer_switch_sign_in_type)).perform(click()); Intents.intended(IntentMatchers.hasComponent(LoginActivity.class.getName())); @@ -142,25 +156,28 @@ public void verifyDrawerSwitchSignInTypeClick() { onView(withId(R.id.inputUsernameLogin)).check(matches(isDisplayed())); } + + @Ignore @Test public void verifyDrawerSignOutButtonClick() { - onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), 2000)); onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); - - onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerLogin), 2000)); + Espresso.onIdle(); + onView(allOf(withId(R.id.btnDrawerLogin), isDescendantOfA(withId(R.id.toolbarDrawerHeader)))).check(matches(isDisplayed())); onView(withId(R.id.btnDrawerLogin)).perform(ViewActions.click()); - onView(isRoot()).perform(BaseUITest.waitFor(2000)); onView(withId(R.id.tvUserStateMain)).check(matches(withText(getContext().getString(R.string.logged_out)))); onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); + onView(withId(R.id.btnSignInMain)).check(matches(isDisplayed())); } + @Override protected Intent getLaunchIntent() { Intent intent = new Intent(getContext(), MainActivity.class); intent.putExtra(IntentConsts.INTENT_KEY_APP_NAME, APP_NAME); return intent; } + } diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java index 6261feda8..57c80ae8e 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java @@ -1,19 +1,27 @@ package org.opendatakit.activites.MainActivity; +import static androidx.test.espresso.Espresso.closeSoftKeyboard; import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.action.ViewActions.scrollTo; import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.isEnabled; import static androidx.test.espresso.matcher.ViewMatchers.isNotEnabled; import static androidx.test.espresso.matcher.ViewMatchers.isRoot; +import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription; import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; +import static org.hamcrest.Matchers.allOf; + import android.content.Intent; import androidx.test.core.app.ActivityScenario; +import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; @@ -24,6 +32,7 @@ import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -189,19 +198,19 @@ public void verifyDrawerUpdateCredentialsClick() { onView(withId(R.id.inputTextUsername)).check(matches(withText(TEST_USERNAME))); onView(withId(R.id.inputTextPassword)).check(matches(withText(""))); } - + @Ignore @Test public void verifyDrawerSignOutButtonClick() { - onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), 2000)); - onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); + onView(withId(R.id.btnDrawerOpen)).perform(click()); - onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerLogin), 2000)); - onView(withId(R.id.btnDrawerLogin)).perform(ViewActions.click()); - onView(isRoot()).perform(BaseUITest.waitFor(2000)); + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerLogin), TestConsts.WAIT_TIME)); + onView(withId(R.id.btnDrawerLogin)).perform(click()); + onView(isRoot()).perform(BaseUITest.waitFor(TestConsts.WAIT_TIME)); onView(withId(R.id.tvUserStateMain)).check(matches(withText(getContext().getString(R.string.logged_out)))); onView(withId(R.id.btnDrawerLogin)).check(matches(withText(getContext().getString(R.string.drawer_sign_in_button_text)))); onView(withId(R.id.btnSignInMain)).check(matches(isDisplayed())); } + } diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/GeneralStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/GeneralStateTest.java index 24c358bcf..102cc7715 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/GeneralStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/GeneralStateTest.java @@ -23,6 +23,7 @@ import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -89,10 +90,11 @@ public void checkToolbarVerifyBtnClick() { Intents.intended(IntentMatchers.hasComponent(VerifyServerSettingsActivity.class.getName())); } + @Ignore @Test public void checkToolbarSettingsBtnClick() { onView(withId(R.id.action_settings)).perform(ViewActions.click()); - onView(isRoot()).perform(waitFor(2000)); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); Intents.intended(IntentMatchers.hasComponent(AppPropertiesActivity.class.getName())); } @@ -125,4 +127,5 @@ public void checkDrawerAboutUsBtnClick() { onView(withId(org.opendatakit.androidlibrary.R.id.versionText)).check(matches(isDisplayed())); btnAboutUs.check(matches(isNotEnabled())); } + } diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java index 42fa46a0b..8fcde6ae6 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java @@ -23,6 +23,7 @@ import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -105,15 +106,16 @@ public void verifySignInButtonClickTest() { onView(withId(R.id.btnSignInMain)).perform(ViewActions.click()); Intents.intended(IntentMatchers.hasComponent(LoginActivity.class.getName())); } - + @Ignore @Test public void verifyDrawerSignInButtonClickTest() { - onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), 2000)); + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerOpen), TestConsts.WAIT_TIME)); onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); - onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerLogin), 2000)); + onView(isRoot()).perform(BaseUITest.waitForView(withId(R.id.btnDrawerLogin), TestConsts.WAIT_TIME)); onView(withId(R.id.btnDrawerLogin)).perform(ViewActions.click()); - onView(isRoot()).perform(BaseUITest.waitFor(2000)); + onView(isRoot()).perform(BaseUITest.waitFor(TestConsts.WAIT_TIME)); Intents.intended(IntentMatchers.hasComponent(LoginActivity.class.getName())); } + } diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AnonymousStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AnonymousStateTest.java index f7e00b375..7b9342788 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AnonymousStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AnonymousStateTest.java @@ -24,6 +24,7 @@ import org.junit.Rule; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -97,7 +98,7 @@ public void verifyDrawerResolveConflictsClick() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); try { - Thread.sleep(3000); + Thread.sleep(TestConsts.WAIT_TIME); } catch (InterruptedException e) { e.printStackTrace(); } @@ -105,7 +106,7 @@ public void verifyDrawerResolveConflictsClick() { onView(withId(R.id.drawer_resolve_conflict)).perform(ViewActions.click()); try { - Thread.sleep(3000); + Thread.sleep(TestConsts.WAIT_TIME); } catch (InterruptedException e) { e.printStackTrace(); } diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AuthenticatedUserStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AuthenticatedUserStateTest.java index c2f5e45da..9c82c0378 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AuthenticatedUserStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AuthenticatedUserStateTest.java @@ -25,6 +25,7 @@ import org.junit.Rule; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -119,7 +120,7 @@ public void verifyDrawerResolveConflictsClick() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); try { - Thread.sleep(3000); + Thread.sleep(TestConsts.WAIT_TIME); } catch (InterruptedException e) { e.printStackTrace(); } @@ -127,7 +128,7 @@ public void verifyDrawerResolveConflictsClick() { onView(withId(R.id.drawer_resolve_conflict)).perform(ViewActions.click()); try { - Thread.sleep(3000); + Thread.sleep(TestConsts.WAIT_TIME); } catch (InterruptedException e) { e.printStackTrace(); } diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/GeneralStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/GeneralStateTest.java index 75f2aad15..2fc7df77d 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/GeneralStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/GeneralStateTest.java @@ -20,8 +20,10 @@ import androidx.test.espresso.matcher.RootMatchers; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; @@ -70,10 +72,11 @@ public void verifyValuesTest() { @Test public void checkToolbarSettingsButtonClick() { onView(withId(R.id.action_settings)).perform(ViewActions.click()); - onView(isRoot()).perform(waitFor(2000)); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); Intents.intended(IntentMatchers.hasComponent(AppPropertiesActivity.class.getName())); } + @Ignore @Test public void checkDrawerSettingsClick() { onView(withId(R.id.btnDrawerOpen)).perform(ViewActions.click()); diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/activities/AdminAppPropertiesActivityTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/activities/AdminAppPropertiesActivityTest.java index e1113e697..024e1bcf6 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/activities/AdminAppPropertiesActivityTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/activities/AdminAppPropertiesActivityTest.java @@ -37,7 +37,7 @@ protected void setUpPostLaunch() { enableAdminMode(); Espresso.pressBack(); } - + @Ignore @Test public void checkIfChangeAdminPasswordScreen_isVisible() { onView(withId(androidx.preference.R.id.recycler_view)).perform(actionOnItemAtPosition(3, scrollTo())) @@ -46,7 +46,7 @@ public void checkIfChangeAdminPasswordScreen_isVisible() { childAtPosition(withId(androidx.preference.R.id.recycler_view), 3), isDisplayed())).check(matches(withText(R.string.admin_password_enabled))); } - + @Ignore @Test public void checkIfManageAbilityToChangeServerSettingScreen_isVisible() { onView(withId(androidx.preference.R.id.recycler_view)).perform(actionOnItemAtPosition(8, scrollTo())) @@ -56,7 +56,7 @@ public void checkIfManageAbilityToChangeServerSettingScreen_isVisible() { isDisplayed())).check(matches(withText(R.string.restrict_server_settings_summary))); } - + @Ignore @Test public void checkIfManageAbilityToChangeDeviceSettingScreen_isVisible() { onView(withId(androidx.preference.R.id.recycler_view)).perform(actionOnItemAtPosition(9, scrollTo())) @@ -65,7 +65,7 @@ public void checkIfManageAbilityToChangeDeviceSettingScreen_isVisible() { childAtPosition(withId(androidx.preference.R.id.recycler_view), 9), isDisplayed())).check(matches(withText(R.string.restrict_device_settings_summary))); } - + @Ignore @Test public void checkIfManageAbilityToChangeTableSpecificSettingScreen_isVisible() { onView(withId(androidx.preference.R.id.recycler_view)).perform(actionOnItemAtPosition(10, scrollTo())) @@ -75,6 +75,7 @@ public void checkIfManageAbilityToChangeTableSpecificSettingScreen_isVisible() { isDisplayed())).check(matches(withText(R.string.admin_tool_tables_settings_summary))); } + @Ignore @Test public void checkIfResetConfigurationScreen_isVisible() { onView(withId(androidx.preference.R.id.recycler_view)).perform(actionOnItemAtPosition(6, scrollTo())) @@ -84,6 +85,7 @@ public void checkIfResetConfigurationScreen_isVisible() { isDisplayed())).check(matches(withText(R.string.clear_configuration_settings))); } + @Ignore @Test public void checkIfExitAdminModeScreen_isVisible() { onView(withId(androidx.preference.R.id.recycler_view)).perform(actionOnItemAtPosition(11, scrollTo())) diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableDeviceSettingsFragmentTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableDeviceSettingsFragmentTest.java index 1c074ad3f..df82b7615 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableDeviceSettingsFragmentTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableDeviceSettingsFragmentTest.java @@ -24,6 +24,7 @@ import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.PropertiesSingleton; import org.opendatakit.services.R; @@ -102,7 +103,7 @@ private void launchDeviceSettingPreferenceScreen() { onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.exit_admin_mode)), click())); - onView(isRoot()).perform(waitFor(1000)); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.preferences)), diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableServerSettingsFragmentTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableServerSettingsFragmentTest.java index 3a12d59a3..6d83cf2f7 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableServerSettingsFragmentTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableServerSettingsFragmentTest.java @@ -27,6 +27,7 @@ import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.PropertiesSingleton; import org.opendatakit.services.R; @@ -117,7 +118,7 @@ public void launchServerSettingPreferenceScreen() { onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.exit_admin_mode)), click())); - onView(isRoot()).perform(waitFor(1000)); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.server)), diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableTablesSettingsFragmentTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableTablesSettingsFragmentTest.java index 17a8fffb2..62b381254 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableTablesSettingsFragmentTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableTablesSettingsFragmentTest.java @@ -25,6 +25,7 @@ import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.PropertiesSingleton; import org.opendatakit.services.R; @@ -94,7 +95,7 @@ private void launchTableServerSettingPreferenceScreen() { .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.exit_admin_mode)), click())); - onView(isRoot()).perform(waitFor(1000)); + onView(isRoot()).perform(waitFor(TestConsts.WAIT_TIME)); onView(withId(androidx.preference.R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(R.string.odkx_tables)), diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/VerifyUserPermissionTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/VerifyUserPermissionTest.java index 83a44d773..4840f5d51 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/VerifyUserPermissionTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/VerifyUserPermissionTest.java @@ -22,6 +22,7 @@ import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; +import org.opendatakit.TestConsts; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.PropertiesSingleton; import org.opendatakit.services.R; @@ -57,15 +58,15 @@ public void whenVerifyUserPermissionIsClicked_configureServerUrl() { onView(withId(androidx.preference.R.id.recycler_view)).perform(RecyclerViewActions.actionOnItem( hasDescendant(withText(R.string.verify_server_settings_header)), click())); - onView(isRoot()).perform(BaseUITest.waitForView(withText(R.string.configure_server_settings), 3000)); + onView(isRoot()).perform(BaseUITest.waitForView(withText(R.string.configure_server_settings), TestConsts.WAIT_TIME)); onView(withText(R.string.configure_server_settings)) .inRoot(isDialog()) .check(matches(isDisplayed())); - onView(isRoot()).perform(BaseUITest.waitForView(allOf(withId(android.R.id.button1), withText(R.string.yes)), 2000)); + onView(isRoot()).perform(BaseUITest.waitForView(allOf(withId(android.R.id.button1), withText(R.string.yes)), TestConsts.WAIT_TIME)); onView(allOf(withId(android.R.id.button1), withText(R.string.yes))).perform(click()); - onView(isRoot()).perform(BaseUITest.waitFor(1500)); + onView(isRoot()).perform(BaseUITest.waitFor(TestConsts.WAIT_TIME)); intended(hasComponent(VerifyServerSettingsActivity.class.getName())); } diff --git a/services_app/src/main/java/org/opendatakit/services/MainActivity.java b/services_app/src/main/java/org/opendatakit/services/MainActivity.java index a1e1c309e..247c638a5 100644 --- a/services_app/src/main/java/org/opendatakit/services/MainActivity.java +++ b/services_app/src/main/java/org/opendatakit/services/MainActivity.java @@ -16,7 +16,6 @@ import android.Manifest; import android.app.Activity; -import android.content.ComponentName; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageManager; diff --git a/services_app/src/main/res/layout/drawer_header.xml b/services_app/src/main/res/layout/drawer_header.xml index bf3897fb9..1355c2041 100644 --- a/services_app/src/main/res/layout/drawer_header.xml +++ b/services_app/src/main/res/layout/drawer_header.xml @@ -30,6 +30,7 @@ style="@style/TextButtonStyle" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:contentDescription="SIGN IN OR OUT" android:layout_gravity="end" android:layout_marginEnd="@dimen/portrait_secondary_margin" android:text="@string/drawer_sign_in_button_text" /> From 4d272e6be46f9cd391b265359ea6558641c6ce69 Mon Sep 17 00:00:00 2001 From: Stryker101 Date: Sat, 29 Jun 2024 13:13:04 +0100 Subject: [PATCH 12/13] --info removed imports cleaned --- .circleci/config.yml | 6 ++--- .../java/org/opendatakit/BaseUITest.java | 22 ++----------------- .../LoginActivity/GeneralStateTest.java | 5 ----- .../LoginActivity/LoggedOutStateTest.java | 2 -- .../MainActivity/AnonymousStateTest.java | 9 -------- .../AuthenticatedUserStateTest.java | 9 -------- .../MainActivity/GeneralStateTest.java | 2 -- .../MainActivity/LoggedOutStateTest.java | 2 -- .../SyncActivity/AnonymousStateTest.java | 4 ---- .../AuthenticatedUserStateTest.java | 3 --- .../SyncActivity/GeneralStateTest.java | 3 --- .../SyncActivity/LoggedOutStateTest.java | 3 --- .../AnonymousStateTest.java | 3 --- .../AuthenticatedUserStateTest.java | 4 ---- .../GeneralStateTest.java | 3 --- .../LoggedOutStateTest.java | 3 --- .../GeneralAppPropertiesActivityTest.java | 4 ---- ...onfigurableDeviceSettingsFragmentTest.java | 1 - ...onfigurableServerSettingsFragmentTest.java | 4 ---- ...onfigurableTablesSettingsFragmentTest.java | 1 - .../GeneralAdminConfigurationTest.java | 9 -------- .../GeneralDeviceSettingsFragmentTest.java | 3 --- .../GeneralServerSettingsFragmentTest.java | 3 --- .../GeneralTablesSettingsFragmentTest.java | 5 ----- .../fragments/VerifyUserPermissionTest.java | 2 -- .../UpdateServerSettingsFragmentTest.java | 2 -- 26 files changed, 5 insertions(+), 112 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3e22c5e76..81fedd4a1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -37,17 +37,17 @@ jobs: - run: name: Wait for Emulator to be Ready - command: adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done; sleep 5' # Ensures the emulator is fully booted + command: adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done; sleep 5' - run: name: Restart ADB server - command: adb kill-server && adb start-server # Restart ADB server to avoid version mismatch issues + command: adb kill-server && adb start-server - android/run-tests: test-command: ./gradlew testSnapshotDebugUnitTest - android/run-tests: - test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info + test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest - android/save-gradle-cache: cache-prefix: v1 diff --git a/services_app/src/androidTest/java/org/opendatakit/BaseUITest.java b/services_app/src/androidTest/java/org/opendatakit/BaseUITest.java index daa2d8d5c..7af81de2c 100644 --- a/services_app/src/androidTest/java/org/opendatakit/BaseUITest.java +++ b/services_app/src/androidTest/java/org/opendatakit/BaseUITest.java @@ -3,10 +3,7 @@ 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.RootMatchers.isDialog; import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant; -import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.isRoot; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; @@ -17,39 +14,22 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; -import android.os.RemoteException; -import android.view.InputDevice; -import android.view.MotionEvent; import android.view.View; -import android.widget.CheckBox; import android.widget.Checkable; -import android.widget.TextView; import androidx.annotation.NonNull; -import androidx.constraintlayout.widget.ConstraintLayout; -import androidx.preference.CheckBoxPreference; import androidx.recyclerview.widget.RecyclerView; import androidx.test.core.app.ActivityScenario; import androidx.test.espresso.PerformException; import androidx.test.espresso.UiController; import androidx.test.espresso.ViewAction; -import androidx.test.espresso.action.GeneralClickAction; -import androidx.test.espresso.action.Press; -import androidx.test.espresso.action.Tap; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.contrib.RecyclerViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.matcher.BoundedMatcher; -import androidx.test.espresso.matcher.ViewMatchers; import androidx.test.espresso.util.HumanReadables; import androidx.test.espresso.util.TreeIterables; import androidx.test.platform.app.InstrumentationRegistry; - -import org.junit.Rule; -import org.opendatakit.services.R; -import androidx.test.espresso.intent.Intents; -import androidx.test.espresso.matcher.BoundedMatcher; -import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.rule.GrantPermissionRule; import org.hamcrest.BaseMatcher; @@ -57,8 +37,10 @@ import org.hamcrest.Matcher; import org.junit.After; import org.junit.Before; +import org.junit.Rule; import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; +import org.opendatakit.services.R; import org.opendatakit.utilities.LocalizationUtils; import org.opendatakit.utilities.ODKFileUtils; diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java index 163d01ec5..b1202aac4 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/GeneralStateTest.java @@ -10,19 +10,14 @@ import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; - import static org.hamcrest.Matchers.allOf; -import android.Manifest; import android.content.Intent; -import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; -import androidx.test.espresso.matcher.RootMatchers; import androidx.test.rule.ActivityTestRule; -import androidx.test.rule.GrantPermissionRule; import org.junit.Ignore; import org.junit.Rule; diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/LoggedOutStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/LoggedOutStateTest.java index 4d86046bb..f9e2d7e20 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/LoggedOutStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/LoginActivity/LoggedOutStateTest.java @@ -6,7 +6,6 @@ import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; - import static com.google.common.truth.Truth.assertThat; import android.content.Intent; @@ -14,7 +13,6 @@ import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.matcher.ViewMatchers; -import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.consts.IntentConsts; diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java index f27536840..2a03a230b 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AnonymousStateTest.java @@ -1,27 +1,19 @@ package org.opendatakit.activites.MainActivity; -import static androidx.test.espresso.Espresso.closeSoftKeyboard; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.click; -import static androidx.test.espresso.action.ViewActions.scrollTo; import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.isRoot; -import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription; import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; - import static org.hamcrest.Matchers.allOf; -import android.content.Context; import android.content.Intent; -import android.util.Log; -import android.view.View; -import android.view.ViewGroup; import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; @@ -29,7 +21,6 @@ import androidx.test.espresso.intent.matcher.IntentMatchers; import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; -import androidx.test.platform.app.InstrumentationRegistry; import org.junit.Ignore; import org.junit.Test; diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java index 57c80ae8e..9405a92f5 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/AuthenticatedUserStateTest.java @@ -1,34 +1,25 @@ package org.opendatakit.activites.MainActivity; -import static androidx.test.espresso.Espresso.closeSoftKeyboard; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.click; -import static androidx.test.espresso.action.ViewActions.scrollTo; import static androidx.test.espresso.assertion.ViewAssertions.matches; -import static androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.isEnabled; import static androidx.test.espresso.matcher.ViewMatchers.isNotEnabled; import static androidx.test.espresso.matcher.ViewMatchers.isRoot; -import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription; import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; -import static org.hamcrest.Matchers.allOf; - import android.content.Intent; -import androidx.test.core.app.ActivityScenario; -import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; -import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/GeneralStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/GeneralStateTest.java index 102cc7715..6d91e4b71 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/GeneralStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/GeneralStateTest.java @@ -12,14 +12,12 @@ import android.content.Intent; -import androidx.test.core.app.ActivityScenario; import androidx.test.espresso.ViewInteraction; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; import androidx.test.espresso.matcher.RootMatchers; -import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java index 8fcde6ae6..046ae6c45 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/MainActivity/LoggedOutStateTest.java @@ -12,14 +12,12 @@ import android.content.Intent; -import androidx.test.core.app.ActivityScenario; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; -import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AnonymousStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AnonymousStateTest.java index 5e3872bcb..dbe7ed37d 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AnonymousStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AnonymousStateTest.java @@ -17,7 +17,6 @@ import android.content.Intent; -import androidx.test.core.app.ActivityScenario; import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; @@ -26,8 +25,6 @@ import androidx.test.espresso.matcher.ViewMatchers; import androidx.test.rule.ActivityTestRule; -import org.junit.Before; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.opendatakit.BaseUITest; @@ -38,7 +35,6 @@ import org.opendatakit.services.resolve.conflict.AllConflictsResolutionActivity; import org.opendatakit.services.sync.actions.activities.LoginActivity; import org.opendatakit.services.sync.actions.activities.SyncActivity; -import org.opendatakit.services.sync.actions.activities.VerifyServerSettingsActivity; import org.opendatakit.services.sync.actions.fragments.ChooseSignInTypeFragment; import org.opendatakit.services.sync.actions.fragments.UpdateServerSettingsFragment; import org.opendatakit.services.utilities.DateTimeUtil; diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AuthenticatedUserStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AuthenticatedUserStateTest.java index 4abc1f6ae..d37d94544 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AuthenticatedUserStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/AuthenticatedUserStateTest.java @@ -17,7 +17,6 @@ import android.content.Intent; -import androidx.test.core.app.ActivityScenario; import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; @@ -26,8 +25,6 @@ import androidx.test.espresso.matcher.ViewMatchers; import androidx.test.rule.ActivityTestRule; -import org.junit.Before; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.opendatakit.BaseUITest; diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/GeneralStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/GeneralStateTest.java index 6e5210655..20da6d495 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/GeneralStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/GeneralStateTest.java @@ -11,14 +11,11 @@ import android.content.Intent; -import androidx.test.core.app.ActivityScenario; import androidx.test.espresso.ViewInteraction; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; -import androidx.test.espresso.matcher.RootMatchers; -import org.junit.Before; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.consts.IntentConsts; diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/LoggedOutStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/LoggedOutStateTest.java index 1db514ca8..3e1bd6b43 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/LoggedOutStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/SyncActivity/LoggedOutStateTest.java @@ -11,14 +11,11 @@ import android.content.Intent; -import androidx.test.core.app.ActivityScenario; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; -import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; -import org.junit.Before; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.consts.IntentConsts; diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AnonymousStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AnonymousStateTest.java index 7b9342788..f8f1d8d19 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AnonymousStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AnonymousStateTest.java @@ -11,16 +11,13 @@ import android.content.Intent; -import androidx.test.core.app.ActivityScenario; import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; -import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; import androidx.test.rule.ActivityTestRule; -import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.opendatakit.BaseUITest; diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AuthenticatedUserStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AuthenticatedUserStateTest.java index 9c82c0378..3a66ade7f 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AuthenticatedUserStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/AuthenticatedUserStateTest.java @@ -12,16 +12,13 @@ import android.content.Intent; -import androidx.test.core.app.ActivityScenario; import androidx.test.espresso.Espresso; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; -import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; import androidx.test.rule.ActivityTestRule; -import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.opendatakit.BaseUITest; @@ -33,7 +30,6 @@ import org.opendatakit.services.resolve.conflict.AllConflictsResolutionActivity; import org.opendatakit.services.sync.actions.activities.LoginActivity; import org.opendatakit.services.sync.actions.activities.VerifyServerSettingsActivity; -import org.opendatakit.services.sync.actions.fragments.ChooseSignInTypeFragment; import org.opendatakit.services.sync.actions.fragments.SetCredentialsFragment; import org.opendatakit.services.sync.actions.fragments.UpdateServerSettingsFragment; import org.opendatakit.services.utilities.DateTimeUtil; diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/GeneralStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/GeneralStateTest.java index 2fc7df77d..0742e6e78 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/GeneralStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/GeneralStateTest.java @@ -12,14 +12,11 @@ import android.content.Intent; -import androidx.test.core.app.ActivityScenario; import androidx.test.espresso.ViewInteraction; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; -import androidx.test.espresso.matcher.RootMatchers; -import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; diff --git a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/LoggedOutStateTest.java b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/LoggedOutStateTest.java index dd91cb2aa..09e65337e 100644 --- a/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/LoggedOutStateTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/activites/VerifyServerSettingsActivity/LoggedOutStateTest.java @@ -10,14 +10,11 @@ import android.content.Intent; -import androidx.test.core.app.ActivityScenario; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; import androidx.test.espresso.intent.matcher.IntentMatchers; -import androidx.test.espresso.matcher.RootMatchers; import androidx.test.espresso.matcher.ViewMatchers; -import org.junit.Before; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.consts.IntentConsts; diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/activities/GeneralAppPropertiesActivityTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/activities/GeneralAppPropertiesActivityTest.java index 562ee1892..a24eb7ca2 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/activities/GeneralAppPropertiesActivityTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/activities/GeneralAppPropertiesActivityTest.java @@ -5,8 +5,6 @@ import static androidx.test.espresso.action.ViewActions.scrollTo; import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition; -import static androidx.test.espresso.intent.Intents.intended; -import static androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent; import static androidx.test.espresso.matcher.RootMatchers.isDialog; import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; @@ -20,13 +18,11 @@ import androidx.test.espresso.contrib.RecyclerViewActions; -import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.consts.IntentConsts; import org.opendatakit.properties.PropertiesSingleton; import org.opendatakit.services.R; -import org.opendatakit.services.sync.actions.activities.VerifyServerSettingsActivity; public class GeneralAppPropertiesActivityTest extends BaseUITest { diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableDeviceSettingsFragmentTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableDeviceSettingsFragmentTest.java index df82b7615..70863a320 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableDeviceSettingsFragmentTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableDeviceSettingsFragmentTest.java @@ -21,7 +21,6 @@ import androidx.test.espresso.contrib.RecyclerViewActions; import org.junit.After; -import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.TestConsts; diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableServerSettingsFragmentTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableServerSettingsFragmentTest.java index 6d83cf2f7..21af23576 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableServerSettingsFragmentTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableServerSettingsFragmentTest.java @@ -2,9 +2,7 @@ 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.RootMatchers.isDialog; import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant; import static androidx.test.espresso.matcher.ViewMatchers.isClickable; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; @@ -20,11 +18,9 @@ import android.content.Intent; import androidx.test.espresso.Espresso; -import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.contrib.RecyclerViewActions; import org.junit.After; -import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.TestConsts; diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableTablesSettingsFragmentTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableTablesSettingsFragmentTest.java index 62b381254..3e93dfe71 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableTablesSettingsFragmentTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/AdminConfigurableTablesSettingsFragmentTest.java @@ -22,7 +22,6 @@ import androidx.test.espresso.contrib.RecyclerViewActions; import org.junit.After; -import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.TestConsts; diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralAdminConfigurationTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralAdminConfigurationTest.java index e86aa0479..b26fd6987 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralAdminConfigurationTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralAdminConfigurationTest.java @@ -4,7 +4,6 @@ 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.RootMatchers.isDialog; import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.withId; @@ -17,22 +16,14 @@ import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.contrib.RecyclerViewActions; -import androidx.test.espresso.intent.Intents; import org.junit.After; -import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.consts.IntentConsts; -import org.opendatakit.properties.CommonToolProperties; import org.opendatakit.properties.PropertiesSingleton; import org.opendatakit.services.R; import org.opendatakit.services.preferences.activities.AppPropertiesActivity; -import org.opendatakit.services.preferences.activities.ClearAppPropertiesActivity; -import org.opendatakit.utilities.LocalizationUtils; -import org.opendatakit.utilities.ODKFileUtils; - -import java.io.File; public class GeneralAdminConfigurationTest extends BaseUITest { diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralDeviceSettingsFragmentTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralDeviceSettingsFragmentTest.java index 64786956e..1092f9534 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralDeviceSettingsFragmentTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralDeviceSettingsFragmentTest.java @@ -16,10 +16,7 @@ import android.content.Intent; import androidx.test.espresso.contrib.RecyclerViewActions; -import androidx.test.espresso.intent.Intents; -import org.junit.After; -import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.consts.IntentConsts; diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralServerSettingsFragmentTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralServerSettingsFragmentTest.java index 3974b8c94..3c9d8ec58 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralServerSettingsFragmentTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralServerSettingsFragmentTest.java @@ -6,7 +6,6 @@ import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.matcher.RootMatchers.isDialog; import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant; -import static androidx.test.espresso.matcher.ViewMatchers.isChecked; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; @@ -19,8 +18,6 @@ import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.contrib.RecyclerViewActions; -import junit.framework.AssertionFailedError; - import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralTablesSettingsFragmentTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralTablesSettingsFragmentTest.java index 39b530809..2b346b5fb 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralTablesSettingsFragmentTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/GeneralTablesSettingsFragmentTest.java @@ -6,20 +6,15 @@ import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant; import static androidx.test.espresso.matcher.ViewMatchers.isChecked; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; -import static androidx.test.espresso.matcher.ViewMatchers.isNotChecked; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; - import static org.hamcrest.Matchers.not; import android.content.Intent; import androidx.test.espresso.contrib.RecyclerViewActions; -import junit.framework.AssertionFailedError; - -import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.consts.IntentConsts; diff --git a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/VerifyUserPermissionTest.java b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/VerifyUserPermissionTest.java index 4840f5d51..20fda980b 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/VerifyUserPermissionTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/preferences/fragments/VerifyUserPermissionTest.java @@ -12,14 +12,12 @@ import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static com.google.common.truth.Truth.assertThat; - import static org.hamcrest.Matchers.allOf; import android.content.Intent; import androidx.test.espresso.contrib.RecyclerViewActions; -import org.junit.Ignore; import org.junit.Test; import org.opendatakit.BaseUITest; import org.opendatakit.TestConsts; diff --git a/services_app/src/androidTest/java/org/opendatakit/services/sync/actions/fragments/UpdateServerSettingsFragmentTest.java b/services_app/src/androidTest/java/org/opendatakit/services/sync/actions/fragments/UpdateServerSettingsFragmentTest.java index 56dfce1ed..d45fa78cb 100644 --- a/services_app/src/androidTest/java/org/opendatakit/services/sync/actions/fragments/UpdateServerSettingsFragmentTest.java +++ b/services_app/src/androidTest/java/org/opendatakit/services/sync/actions/fragments/UpdateServerSettingsFragmentTest.java @@ -7,7 +7,6 @@ import static androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent; import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; -import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; @@ -17,7 +16,6 @@ import androidx.test.core.app.ActivityScenario; import androidx.test.espresso.action.ViewActions; import androidx.test.espresso.intent.Intents; -import androidx.test.espresso.matcher.ViewMatchers; import androidx.test.platform.app.InstrumentationRegistry; import org.junit.After; From 9d56cd2759f3a874c7fd9c1eb377407c65cc12a7 Mon Sep 17 00:00:00 2001 From: Stryker101 Date: Sat, 29 Jun 2024 13:37:44 +0100 Subject: [PATCH 13/13] --info added --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 81fedd4a1..0d7a26840 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -47,7 +47,7 @@ jobs: test-command: ./gradlew testSnapshotDebugUnitTest - android/run-tests: - test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest + test-command: ./gradlew grantPermissionForODKXApp connectedSnapshotDebugAndroidTest --info - android/save-gradle-cache: cache-prefix: v1