From acc6e6d967796a677ccde38a707ae9f6c54a10b4 Mon Sep 17 00:00:00 2001 From: Victor Andreasson Date: Sun, 9 Jun 2024 19:19:08 +0200 Subject: [PATCH] Add a few more sleeps to flaky Espresso tests --- .../androidTest/java/com/orgzly/android/espresso/BookTest.java | 1 + .../java/com/orgzly/android/espresso/QueryFragmentTest.java | 2 ++ .../java/com/orgzly/android/espresso/util/EspressoUtils.java | 1 - 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/androidTest/java/com/orgzly/android/espresso/BookTest.java b/app/src/androidTest/java/com/orgzly/android/espresso/BookTest.java index e94588c37..532959c55 100644 --- a/app/src/androidTest/java/com/orgzly/android/espresso/BookTest.java +++ b/app/src/androidTest/java/com/orgzly/android/espresso/BookTest.java @@ -444,6 +444,7 @@ public void testSetDeadlineTimeForNewNote() { onView(withId(R.id.date_picker_button)).perform(click()); onView(withClassName(equalTo(DatePicker.class.getName()))).perform(setDate(2014, 4, 1)); onView(withText(android.R.string.ok)).perform(click()); + SystemClock.sleep(100); onView(withText(R.string.set)).perform(click()); onView(withId(R.id.deadline_button)).check(matches(withText(userDateTime("<2014-04-01 Tue>")))); } diff --git a/app/src/androidTest/java/com/orgzly/android/espresso/QueryFragmentTest.java b/app/src/androidTest/java/com/orgzly/android/espresso/QueryFragmentTest.java index ccb0f7e98..b7b2c299a 100644 --- a/app/src/androidTest/java/com/orgzly/android/espresso/QueryFragmentTest.java +++ b/app/src/androidTest/java/com/orgzly/android/espresso/QueryFragmentTest.java @@ -246,6 +246,7 @@ public void testClickingNote() { defaultSetUp(); onView(allOf(withText("book-two"), isDisplayed())).perform(click()); + SystemClock.sleep(200); searchForTextCloseKeyboard("b.book-two Note"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(29))); @@ -615,6 +616,7 @@ public void testSearchForTagOrTag() { scenario = ActivityScenario.launch(MainActivity.class); onView(allOf(withText("notebook"), isDisplayed())).perform(click()); + SystemClock.sleep(200); searchForTextCloseKeyboard("tn.a or tn.b"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(2))); diff --git a/app/src/androidTest/java/com/orgzly/android/espresso/util/EspressoUtils.java b/app/src/androidTest/java/com/orgzly/android/espresso/util/EspressoUtils.java index d2e8aa1f3..66141e453 100644 --- a/app/src/androidTest/java/com/orgzly/android/espresso/util/EspressoUtils.java +++ b/app/src/androidTest/java/com/orgzly/android/espresso/util/EspressoUtils.java @@ -339,7 +339,6 @@ public static ViewInteraction contextualToolbarOverflowMenu() { } public static void searchForTextCloseKeyboard(String str) { - SystemClock.sleep(100); onView(isRoot()).perform(waitId(R.id.search_view, 5000)); onView(allOf(withId(R.id.search_view), isDisplayed())).perform(click()); onView(isRoot()).perform(waitId(R.id.search_src_text, 5000));