diff --git a/app/src/androidTest/java/com/orgzly/android/espresso/AgendaFragmentTest.java b/app/src/androidTest/java/com/orgzly/android/espresso/AgendaFragmentTest.java index a3932e79b..ab3bfa39a 100644 --- a/app/src/androidTest/java/com/orgzly/android/espresso/AgendaFragmentTest.java +++ b/app/src/androidTest/java/com/orgzly/android/espresso/AgendaFragmentTest.java @@ -14,7 +14,7 @@ import static com.orgzly.android.espresso.util.EspressoUtils.onItemInAgenda; import static com.orgzly.android.espresso.util.EspressoUtils.onNotesInAgenda; import static com.orgzly.android.espresso.util.EspressoUtils.recyclerViewItemCount; -import static com.orgzly.android.espresso.util.EspressoUtils.searchForText; +import static com.orgzly.android.espresso.util.EspressoUtils.searchForTextCloseKeyboard; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.endsWith; import static org.hamcrest.Matchers.equalTo; @@ -74,7 +74,7 @@ public void tearDown() throws Exception { @Test public void testAgendaSavedSearch() { scenario = defaultSetUp(); - searchForText(".it.done ad.7"); + searchForTextCloseKeyboard(".it.done ad.7"); /* * 1 Overdue * 1 Note B @@ -90,16 +90,16 @@ public void testAgendaSavedSearch() { @Test public void testWithNoBook() { scenario = ActivityScenario.launch(MainActivity.class); - searchForText(".it.done (s.7d or d.7d) ad.7"); + searchForTextCloseKeyboard(".it.done (s.7d or d.7d) ad.7"); onNotesInAgenda().check(matches(recyclerViewItemCount(7))); - searchForText(".it.done (s.7d or d.7d) ad.3"); + searchForTextCloseKeyboard(".it.done (s.7d or d.7d) ad.3"); onNotesInAgenda().check(matches(recyclerViewItemCount(3))); } @Test public void testDayAgenda() { scenario = defaultSetUp(); - searchForText(".it.done (s.7d or d.7d) ad.1"); + searchForTextCloseKeyboard(".it.done (s.7d or d.7d) ad.1"); onNotesInAgenda().check(matches(recyclerViewItemCount(7))); onItemInAgenda(0, R.id.item_agenda_divider_text).check(matches(allOf(withText(R.string.overdue), isDisplayed()))); onItemInAgenda(1, R.id.item_head_title_view).check(matches(allOf(withText(endsWith("Note B")), isDisplayed()))); @@ -119,14 +119,14 @@ public void testAgendaRangeEvent() { "<" + start.toString() + ">--<" + end.toString() + ">\n"); scenario = ActivityScenario.launch(MainActivity.class); - searchForText("ad.5"); + searchForTextCloseKeyboard("ad.5"); onNotesInAgenda().check(matches(recyclerViewItemCount(10))); } @Test public void testOneTimeTaskMarkedDone() { scenario = defaultSetUp(); - searchForText(".it.done ad.7"); + searchForTextCloseKeyboard(".it.done ad.7"); /* * 1 Overdue * 1 Note B <- Mark as done @@ -144,7 +144,7 @@ public void testOneTimeTaskMarkedDone() { @Test public void testRepeaterTaskMarkedDone() { scenario = defaultSetUp(); - searchForText(".it.done ad.7"); + searchForTextCloseKeyboard(".it.done ad.7"); onItemInAgenda(2).perform(longClick()); onView(withId(R.id.toggle_state)).perform(click()); onNotesInAgenda().check(matches(recyclerViewItemCount(23))); @@ -153,7 +153,7 @@ public void testRepeaterTaskMarkedDone() { @Test public void testRangeTaskMarkedDone() { scenario = defaultSetUp(); - searchForText(".it.done ad.7"); + searchForTextCloseKeyboard(".it.done ad.7"); onItemInAgenda(3).perform(longClick()); onView(withId(R.id.toggle_state)).perform(click()); onNotesInAgenda().check(matches(recyclerViewItemCount(17))); @@ -163,7 +163,7 @@ public void testRangeTaskMarkedDone() { public void testMoveTaskWithRepeaterToTomorrow() { DateTime tomorrow = DateTime.now().withTimeAtStartOfDay().plusDays(1); scenario = defaultSetUp(); - searchForText(".it.done ad.7"); + searchForTextCloseKeyboard(".it.done ad.7"); onItemInAgenda(2).perform(longClick()); onView(withId(R.id.schedule)).perform(click()); onView(withId(R.id.date_picker_button)).perform(click()); @@ -181,7 +181,7 @@ public void testMoveTaskWithRepeaterToTomorrow() { public void testPersistedSpinnerSelection() { scenario = defaultSetUp(); - searchForText(".it.done ad.7"); + searchForTextCloseKeyboard(".it.done ad.7"); onNotesInAgenda().check(matches(recyclerViewItemCount(25))); scenario.onActivity(activity -> @@ -199,7 +199,7 @@ public void testDeselectRemovedNoteInAgenda() { scenario = ActivityScenario.launch(MainActivity.class); - searchForText("i.todo ad.3"); + searchForTextCloseKeyboard("i.todo ad.3"); onNotesInAgenda().check(matches(recyclerViewItemCount(12))); @@ -226,7 +226,7 @@ public void testPreselectedStateOfSelectedNote() { testUtils.setupBook("notebook", "* TODO Note A\nSCHEDULED: <2018-01-01 +1d>"); scenario = ActivityScenario.launch(MainActivity.class); - searchForText("ad.3"); + searchForTextCloseKeyboard("ad.3"); onItemInAgenda(1).perform(longClick()); onView(withId(R.id.state)).perform(click()); @@ -238,7 +238,7 @@ public void testPreselectedStateOfSelectedNote() { public void testSwipeDivider() { testUtils.setupBook("notebook", "* TODO Note A\nSCHEDULED: <2018-01-01 +1d>"); scenario = ActivityScenario.launch(MainActivity.class); - searchForText("ad.3"); + searchForTextCloseKeyboard("ad.3"); onItemInAgenda(0).perform(swipeLeft()); onItemInAgenda(2).perform(swipeLeft()); } @@ -249,7 +249,7 @@ public void testOpenCorrectNote() { testUtils.setupBook("notebook", "* TODO Note A\nSCHEDULED: <2018-01-01 +1d>"); scenario = ActivityScenario.launch(MainActivity.class); - searchForText("ad.3"); + searchForTextCloseKeyboard("ad.3"); onItemInAgenda(1).perform(click()); @@ -264,7 +264,7 @@ public void testChangeStateWithReverseNoteClick() { AppPreferences.isReverseNoteClickAction(context, false); scenario = ActivityScenario.launch(MainActivity.class); - searchForText(".it.done ad.7"); + searchForTextCloseKeyboard(".it.done ad.7"); onItemInAgenda(1).perform(longClick()); onView(withId(R.id.state)).perform(click()); onView(withText("NEXT")).perform(click()); @@ -274,7 +274,7 @@ public void testChangeStateWithReverseNoteClick() { public void testInactiveScheduled() { testUtils.setupBook("notebook-1", "* Note A\nSCHEDULED: [2020-07-01]\nDEADLINE: <2020-07-01>"); scenario = ActivityScenario.launch(MainActivity.class); - searchForText("ad.1"); + searchForTextCloseKeyboard("ad.1"); // Overdue, note (deadline), today onNotesInAgenda().check(matches(recyclerViewItemCount(3))); } @@ -283,7 +283,7 @@ public void testInactiveScheduled() { public void testInactiveDeadline() { testUtils.setupBook("notebook-1", "* Note A\nDEADLINE: [2020-07-01]\nSCHEDULED: <2020-07-01>"); scenario = ActivityScenario.launch(MainActivity.class); - searchForText("ad.1"); + searchForTextCloseKeyboard("ad.1"); // Overdue, note (scheduled), today onNotesInAgenda().check(matches(recyclerViewItemCount(3))); } @@ -292,7 +292,7 @@ public void testInactiveDeadline() { public void testInactiveScheduledAndDeadline() { testUtils.setupBook("notebook-1", "* Note A\nSCHEDULED: [2020-07-01]\nDEADLINE: [2020-07-01]"); scenario = ActivityScenario.launch(MainActivity.class); - searchForText("ad.1"); + searchForTextCloseKeyboard("ad.1"); // Today onNotesInAgenda().check(matches(recyclerViewItemCount(1))); } diff --git a/app/src/androidTest/java/com/orgzly/android/espresso/CreatedAtPropertyTest.java b/app/src/androidTest/java/com/orgzly/android/espresso/CreatedAtPropertyTest.java index 4274c4ced..2151f5bd4 100644 --- a/app/src/androidTest/java/com/orgzly/android/espresso/CreatedAtPropertyTest.java +++ b/app/src/androidTest/java/com/orgzly/android/espresso/CreatedAtPropertyTest.java @@ -26,7 +26,7 @@ import static com.orgzly.android.espresso.util.EspressoUtils.onNotesInSearch; import static com.orgzly.android.espresso.util.EspressoUtils.recyclerViewItemCount; import static com.orgzly.android.espresso.util.EspressoUtils.replaceTextCloseKeyboard; -import static com.orgzly.android.espresso.util.EspressoUtils.searchForText; +import static com.orgzly.android.espresso.util.EspressoUtils.searchForTextCloseKeyboard; import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.Matchers.allOf; @@ -68,7 +68,7 @@ public void tearDown() throws Exception { public void testCondition() { enableCreatedAt(); - searchForText("cr.le.today"); + searchForTextCloseKeyboard("cr.le.today"); onNotesInSearch().check(matches(recyclerViewItemCount(2))); // TODO: Search before/after 2018-01-03 expecting 1 note @@ -78,18 +78,18 @@ public void testCondition() { public void testSortOrder() { enableCreatedAt(); - searchForText("o.cr"); + searchForTextCloseKeyboard("o.cr"); onNoteInSearch(0, R.id.item_head_title_view) .check(matches(allOf(withText("Note [a-2]"), isDisplayed()))); - searchForText(".o.cr"); + searchForTextCloseKeyboard(".o.cr"); onNoteInSearch(0, R.id.item_head_title_view) .check(matches(allOf(withText("Note [a-1]"), isDisplayed()))); } @Test public void testChangeCreatedAtPropertyResultsShouldBeReordered() { - searchForText("o.cr"); + searchForTextCloseKeyboard("o.cr"); onNoteInSearch(0, R.id.item_head_title_view).check(matches(withText("Note [a-1]"))); onNoteInSearch(1, R.id.item_head_title_view).check(matches(withText("Note [a-2]"))); @@ -119,11 +119,11 @@ public void testNewNote() { onNoteInBook(3, R.id.item_head_title_view) .check(matches(allOf(withText("new note created by test"), isDisplayed()))); - searchForText("o.cr"); + searchForTextCloseKeyboard("o.cr"); onNoteInSearch(0, R.id.item_head_title_view) .check(matches(allOf(withText("Note [a-2]"), isDisplayed()))); - searchForText(".o.cr"); + searchForTextCloseKeyboard(".o.cr"); onNoteInSearch(0, R.id.item_head_title_view) .check(matches(allOf(withText("new note created by test"), isDisplayed()))); } diff --git a/app/src/androidTest/java/com/orgzly/android/espresso/MiscTest.java b/app/src/androidTest/java/com/orgzly/android/espresso/MiscTest.java index 1076fc20a..d90892e43 100644 --- a/app/src/androidTest/java/com/orgzly/android/espresso/MiscTest.java +++ b/app/src/androidTest/java/com/orgzly/android/espresso/MiscTest.java @@ -26,7 +26,7 @@ import static com.orgzly.android.espresso.util.EspressoUtils.onSavedSearch; import static com.orgzly.android.espresso.util.EspressoUtils.replaceTextCloseKeyboard; import static com.orgzly.android.espresso.util.EspressoUtils.scroll; -import static com.orgzly.android.espresso.util.EspressoUtils.searchForText; +import static com.orgzly.android.espresso.util.EspressoUtils.searchForTextCloseKeyboard; import static com.orgzly.android.espresso.util.EspressoUtils.settingsSetDoneKeywords; import static com.orgzly.android.espresso.util.EspressoUtils.settingsSetTodoKeywords; import static org.hamcrest.Matchers.allOf; @@ -465,7 +465,7 @@ public void testMainActivityFragments() { fragmentTest(activity, true, withId(R.id.fragment_query_search_view_flipper)); // Agenda - searchForText("t.tag3 ad.3"); + searchForTextCloseKeyboard("t.tag3 ad.3"); fragmentTest(activity, true, withId(R.id.fragment_query_agenda_view_flipper)); } } @@ -728,7 +728,7 @@ public void testActiveDrawerItemForSearchQuery() { try (ActivityScenario ignored = ActivityScenario.launch(MainActivity.class)) { onBook(0).perform(click()); - searchForText("note"); + searchForTextCloseKeyboard("note"); onView(withId(R.id.drawer_layout)).perform(open()); onView(allOf(withText("booky-one"), isDescendantOfA(withId(R.id.drawer_navigation_view)))) diff --git a/app/src/androidTest/java/com/orgzly/android/espresso/NoteEventsTest.kt b/app/src/androidTest/java/com/orgzly/android/espresso/NoteEventsTest.kt index 3e944cda3..f7ed47592 100644 --- a/app/src/androidTest/java/com/orgzly/android/espresso/NoteEventsTest.kt +++ b/app/src/androidTest/java/com/orgzly/android/espresso/NoteEventsTest.kt @@ -68,7 +68,7 @@ class NoteEventsTest : OrgzlyTest() { testUtils.setupBook("book-a", "* Note $now") scenario = ActivityScenario.launch(MainActivity::class.java) - searchForText("e.ge.today") + searchForTextCloseKeyboard("e.ge.today") onNotesInSearch().check(matches(recyclerViewItemCount(1))) } @@ -77,7 +77,7 @@ class NoteEventsTest : OrgzlyTest() { testUtils.setupBook("book-a", "* Note\n$now") scenario = ActivityScenario.launch(MainActivity::class.java) - searchForText("e.ge.today") + searchForTextCloseKeyboard("e.ge.today") onNotesInSearch().check(matches(recyclerViewItemCount(1))) } @@ -86,7 +86,7 @@ class NoteEventsTest : OrgzlyTest() { testUtils.setupBook("book-a", "* Note\n$now $now") scenario = ActivityScenario.launch(MainActivity::class.java) - searchForText("e.ge.today") + searchForTextCloseKeyboard("e.ge.today") onNotesInSearch().check(matches(recyclerViewItemCount(1))) } @@ -95,7 +95,7 @@ class NoteEventsTest : OrgzlyTest() { testUtils.setupBook("book-a", "* Note $now") scenario = ActivityScenario.launch(MainActivity::class.java) - searchForText("ad.1") + searchForTextCloseKeyboard("ad.1") onNotesInAgenda().check(matches(recyclerViewItemCount(2))) } @@ -104,7 +104,7 @@ class NoteEventsTest : OrgzlyTest() { testUtils.setupBook("book-a", "* Note $now $tomorrow") scenario = ActivityScenario.launch(MainActivity::class.java) - searchForText("ad.2") + searchForTextCloseKeyboard("ad.2") onNotesInAgenda().check(matches(recyclerViewItemCount(4))) } @@ -113,7 +113,7 @@ class NoteEventsTest : OrgzlyTest() { testUtils.setupBook("book-a", "* Note\n$now") scenario = ActivityScenario.launch(MainActivity::class.java) - searchForText("ad.1") + searchForTextCloseKeyboard("ad.1") onNotesInAgenda().check(matches(recyclerViewItemCount(2))) } @@ -122,7 +122,7 @@ class NoteEventsTest : OrgzlyTest() { testUtils.setupBook("book-a", "* Note\n$now $tomorrow") scenario = ActivityScenario.launch(MainActivity::class.java) - searchForText("ad.2") + searchForTextCloseKeyboard("ad.2") onNotesInAgenda().check(matches(recyclerViewItemCount(4))) } @@ -148,7 +148,7 @@ class NoteEventsTest : OrgzlyTest() { scenario = ActivityScenario.launch(MainActivity::class.java) - searchForText("ad.5") + searchForTextCloseKeyboard("ad.5") onNotesInAgenda().check(matches(recyclerViewItemCount(10))) @@ -192,7 +192,7 @@ class NoteEventsTest : OrgzlyTest() { scenario = ActivityScenario.launch(MainActivity::class.java) - searchForText("b.book-a") + searchForTextCloseKeyboard("b.book-a") onNotesInSearch().check(matches(recyclerViewItemCount(1))) @@ -208,7 +208,7 @@ class NoteEventsTest : OrgzlyTest() { "* Today $today\n* In few days $inFewDays\n* Today & In few days $today $inFewDays") scenario = ActivityScenario.launch(MainActivity::class.java) - searchForText("e.gt.1d") + searchForTextCloseKeyboard("e.gt.1d") onNotesInSearch().check(matches(recyclerViewItemCount(2))) } @@ -217,7 +217,7 @@ class NoteEventsTest : OrgzlyTest() { testUtils.setupBook("book-a", "* Few days ago\n$fewDaysAgo") scenario = ActivityScenario.launch(MainActivity::class.java) - searchForText("ad.2") + searchForTextCloseKeyboard("ad.2") onNotesInAgenda().check(matches(recyclerViewItemCount(2))) } @@ -226,7 +226,7 @@ class NoteEventsTest : OrgzlyTest() { testUtils.setupBook("book-a", "* $yesterday $fewDaysAgo\nSCHEDULED: $tomorrow") scenario = ActivityScenario.launch(MainActivity::class.java) - searchForText("e.lt.now ad.3") + searchForTextCloseKeyboard("e.lt.now ad.3") onNotesInAgenda().check(matches(recyclerViewItemCount(4))) } @@ -240,7 +240,7 @@ class NoteEventsTest : OrgzlyTest() { """.trimIndent()) scenario = ActivityScenario.launch(MainActivity::class.java) - searchForText("e.today") + searchForTextCloseKeyboard("e.today") onNotesInSearch().check(matches(recyclerViewItemCount(1))) onNoteInSearch(0, R.id.item_head_title_view).check(matches(withText(startsWith("Note A-01")))) } @@ -257,7 +257,7 @@ class NoteEventsTest : OrgzlyTest() { """.trimIndent()) scenario = ActivityScenario.launch(MainActivity::class.java) - searchForText("e.lt.now o.e") + searchForTextCloseKeyboard("e.lt.now o.e") onNotesInSearch().check(matches(recyclerViewItemCount(2))) onNoteInSearch(0, R.id.item_head_title_view).check(matches(withText(startsWith("Note A-01")))) onNoteInSearch(1, R.id.item_head_title_view).check(matches(withText(startsWith("Note A-02")))) @@ -275,7 +275,7 @@ class NoteEventsTest : OrgzlyTest() { """.trimIndent()) scenario = ActivityScenario.launch(MainActivity::class.java) - searchForText("e.lt.now .o.e") + searchForTextCloseKeyboard("e.lt.now .o.e") onNotesInSearch().check(matches(recyclerViewItemCount(2))) onNoteInSearch(0, R.id.item_head_title_view).check(matches(withText(startsWith("Note A-01")))) onNoteInSearch(1, R.id.item_head_title_view).check(matches(withText(startsWith("Note A-02")))) @@ -316,7 +316,7 @@ class NoteEventsTest : OrgzlyTest() { """.trimIndent()) scenario = ActivityScenario.launch(MainActivity::class.java) - searchForText(".it.done ad.7 o.e") + searchForTextCloseKeyboard(".it.done ad.7 o.e") onNotesInAgenda().check(matches(recyclerViewItemCount(8))) onItemInAgenda(2, R.id.item_head_title_view).check(matches(withText(startsWith("Note A-01")))) 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 d79a0d947..d15112107 100644 --- a/app/src/androidTest/java/com/orgzly/android/espresso/QueryFragmentTest.java +++ b/app/src/androidTest/java/com/orgzly/android/espresso/QueryFragmentTest.java @@ -23,7 +23,7 @@ import static com.orgzly.android.espresso.util.EspressoUtils.recyclerViewItemCount; import static com.orgzly.android.espresso.util.EspressoUtils.replaceTextCloseKeyboard; import static com.orgzly.android.espresso.util.EspressoUtils.scroll; -import static com.orgzly.android.espresso.util.EspressoUtils.searchForText; +import static com.orgzly.android.espresso.util.EspressoUtils.searchForTextCloseKeyboard; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.endsWith; @@ -117,7 +117,7 @@ public void testSearchFromBookOneResult() { defaultSetUp(); onView(allOf(withText("book-one"), isDisplayed())).perform(click()); - searchForText("b.book-one another note"); + searchForTextCloseKeyboard("b.book-one another note"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(1))); onNoteInSearch(0, R.id.item_head_title_view).check(matches(allOf(withText("Another note."), isDisplayed()))); @@ -128,7 +128,7 @@ public void testSearchFromBookMultipleResults() { defaultSetUp(); onView(allOf(withText("book-one"), isDisplayed())).perform(click()); - searchForText("b.book-one note"); + searchForTextCloseKeyboard("b.book-one note"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(7))); } @@ -137,10 +137,10 @@ public void testSearchFromBookMultipleResults() { public void testSearchTwice() { defaultSetUp(); - searchForText("different"); + searchForTextCloseKeyboard("different"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(2))); - searchForText("another"); + searchForTextCloseKeyboard("another"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(1))); } @@ -149,7 +149,7 @@ public void testSearchTwice() { public void testSearchExpressionTodo() { defaultSetUp(); - searchForText("i.todo"); + searchForTextCloseKeyboard("i.todo"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(3))); } @@ -158,7 +158,7 @@ public void testSearchExpressionTodo() { public void testSearchExpressionsToday() { defaultSetUp(); - searchForText("s.today"); + searchForTextCloseKeyboard("s.today"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(2))); } @@ -167,7 +167,7 @@ public void testSearchExpressionsToday() { public void testSearchExpressionsPriority() { defaultSetUp(); - searchForText("p.a"); + searchForTextCloseKeyboard("p.a"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(3))); @@ -181,7 +181,7 @@ public void testSearchExpressionsPriority() { public void testNotPriority() { defaultSetUp(); - searchForText(".p.b"); + searchForTextCloseKeyboard(".p.b"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(4))); @@ -197,7 +197,7 @@ public void testNotPriority() { public void testSearchInBook() { defaultSetUp(); - searchForText("b.book-one note"); + searchForTextCloseKeyboard("b.book-one note"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(7))); } @@ -223,7 +223,7 @@ public void testToggleState() { testUtils.setupBook("book-one", "* Note"); scenario = ActivityScenario.launch(MainActivity.class); - searchForText("Note"); + searchForTextCloseKeyboard("Note"); onNoteInSearch(0).perform(longClick()); onView(withId(R.id.toggle_state)).perform(click()); onNoteInSearch(0, R.id.item_head_title_view).check(matches(withText(startsWith("DONE")))); @@ -237,7 +237,7 @@ public void testClickingNote() { defaultSetUp(); onView(allOf(withText("book-two"), isDisplayed())).perform(click()); - searchForText("b.book-two Note"); + searchForTextCloseKeyboard("b.book-two Note"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(29))); onNoteInSearch(27).perform(click()); @@ -279,7 +279,7 @@ public void testSearchExpressionsDefaultPriority() { testUtils.setupBook("book-two", "* Note #1.\n"); scenario = ActivityScenario.launch(MainActivity.class); - searchForText("p.b"); + searchForTextCloseKeyboard("p.b"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(4))); @@ -303,7 +303,7 @@ public void testMultipleNotState() { ""); scenario = ActivityScenario.launch(MainActivity.class); - searchForText(".i.todo .i.done"); + searchForTextCloseKeyboard(".i.todo .i.done"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(5))); } @@ -318,7 +318,7 @@ public void testNotesWithSameScheduledTimeString() throws IOException { testUtils.setupBook("notebook-2", "* Note B\nSCHEDULED: <2014-01-01>"); scenario = ActivityScenario.launch(MainActivity.class); - searchForText("s.today"); + searchForTextCloseKeyboard("s.today"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(2))); } @@ -329,7 +329,7 @@ public void testNotesWithSameDeadlineTimeString() throws IOException { testUtils.setupBook("notebook-2", "* Note B\nDEADLINE: <2014-01-01>"); scenario = ActivityScenario.launch(MainActivity.class); - searchForText("d.today"); + searchForTextCloseKeyboard("d.today"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(2))); } @@ -339,7 +339,7 @@ public void testClosedTimeSearch() { testUtils.setupBook("notebook-1", "* Note A\nCLOSED: [2014-01-01]"); scenario = ActivityScenario.launch(MainActivity.class); - searchForText("c.ge.-2d"); + searchForTextCloseKeyboard("c.ge.-2d"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onView(withText(R.string.no_notes_found_after_search)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(0))); @@ -356,7 +356,7 @@ public void testInheritedTagSearchWhenMultipleAncestorsMatch() { scenario = ActivityScenario.launch(MainActivity.class); onView(allOf(withText("notebook-1"), isDisplayed())).perform(click()); - searchForText("t.tag"); + searchForTextCloseKeyboard("t.tag"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(4))); } @@ -372,7 +372,7 @@ public void testInheritedAndOwnTag() { scenario = ActivityScenario.launch(MainActivity.class); onView(allOf(withText("notebook-1"), isDisplayed())).perform(click()); - searchForText("t.tag1 t.tag2"); + searchForTextCloseKeyboard("t.tag1 t.tag2"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(3))); onNoteInSearch(0, R.id.item_head_title_view).check(matches(allOf(withText(startsWith("Note B")), isDisplayed()))); @@ -399,7 +399,7 @@ public void testInheritedTagsAfterMovingNote() { pressBack(); pressBack(); - searchForText("t.tag3"); + searchForTextCloseKeyboard("t.tag3"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(2))); onNoteInSearch(0, R.id.item_head_title_view) @@ -427,7 +427,7 @@ public void testInheritedTagsAfterDemotingSubtree() { pressBack(); pressBack(); - searchForText("t.tag3"); + searchForTextCloseKeyboard("t.tag3"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(2))); onNoteInSearch(0, R.id.item_head_title_view) @@ -458,7 +458,7 @@ public void testInheritedTagsAfterCutAndPasting() { onActionItemClick(R.id.paste, R.string.paste); onView(withText(R.string.heads_action_menu_item_paste_under)).perform(click()); - searchForText("t.tag3"); + searchForTextCloseKeyboard("t.tag3"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(2))); onNoteInSearch(0, R.id.item_head_title_view) @@ -480,7 +480,7 @@ public void testSearchOrderScheduled() { scenario = ActivityScenario.launch(MainActivity.class); onView(allOf(withText("notebook-1"), isDisplayed())).perform(click()); - searchForText("note o.scheduled"); + searchForTextCloseKeyboard("note o.scheduled"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNoteInSearch(0, R.id.item_head_title_view).check(matches(withText("Note B"))); onNoteInSearch(1, R.id.item_head_title_view).check(matches(withText("Note A"))); @@ -501,7 +501,7 @@ public void testOrderScheduledWithAndWithoutTimePart() { scenario = ActivityScenario.launch(MainActivity.class); onView(allOf(withText("notebook-1"), isDisplayed())).perform(click()); - searchForText("s.today .i.done o.s"); + searchForTextCloseKeyboard("s.today .i.done o.s"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNoteInSearch(0, R.id.item_head_title_view).check(matches(withText("Note A"))); onNoteInSearch(1, R.id.item_head_title_view).check(matches(withText("Note C"))); @@ -523,7 +523,7 @@ public void testOrderDeadlineWithAndWithoutTimePartDesc() { scenario = ActivityScenario.launch(MainActivity.class); onView(allOf(withText("notebook-1"), isDisplayed())).perform(click()); - searchForText("d.today .i.done .o.d"); + searchForTextCloseKeyboard("d.today .i.done .o.d"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNoteInSearch(0, R.id.item_head_title_view).check(matches(withText("Note B"))); onNoteInSearch(1, R.id.item_head_title_view).check(matches(withText("Note C"))); @@ -534,7 +534,7 @@ public void testOrderDeadlineWithAndWithoutTimePartDesc() { public void testOrderOfBooksAfterRenaming() { defaultSetUp(); - searchForText("note"); + searchForTextCloseKeyboard("note"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNoteInSearch(0, R.id.item_head_book_name_text).check(matches(withText("book-one"))); @@ -570,7 +570,7 @@ public void testSearchForNonExistentTagShouldReturnAllNotes() { scenario = ActivityScenario.launch(MainActivity.class); onView(allOf(withText("notebook"), isDisplayed())).perform(click()); - searchForText(".t.c"); + searchForTextCloseKeyboard(".t.c"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(4))); } @@ -585,7 +585,7 @@ public void testNotTagShouldReturnSomeNotes() { scenario = ActivityScenario.launch(MainActivity.class); onView(allOf(withText("notebook"), isDisplayed())).perform(click()); - searchForText(".t.b"); + searchForTextCloseKeyboard(".t.b"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(2))); onNoteInSearch(0, R.id.item_head_title_view).check(matches(allOf(withText("Note A a"), isDisplayed()))); @@ -602,7 +602,7 @@ public void testSearchForTagOrTag() { scenario = ActivityScenario.launch(MainActivity.class); onView(allOf(withText("notebook"), isDisplayed())).perform(click()); - searchForText("tn.a or tn.b"); + searchForTextCloseKeyboard("tn.a or tn.b"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(2))); onNoteInSearch(0, R.id.item_head_title_view).check(matches(allOf(withText(startsWith("Note A")), isDisplayed()))); @@ -619,7 +619,7 @@ public void testSortByPriority() { scenario = ActivityScenario.launch(MainActivity.class); onView(allOf(withText("notebook"), isDisplayed())).perform(click()); - searchForText("o.p"); + searchForTextCloseKeyboard("o.p"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNoteInSearch(0, R.id.item_head_title_view).check(matches(allOf(withText(containsString("Note B")), isDisplayed()))); onNoteInSearch(1, R.id.item_head_title_view).check(matches(allOf(withText(containsString("Note A")), isDisplayed()))); @@ -637,7 +637,7 @@ public void testSortByPriorityDesc() { scenario = ActivityScenario.launch(MainActivity.class); onView(allOf(withText("notebook"), isDisplayed())).perform(click()); - searchForText(".o.p"); + searchForTextCloseKeyboard(".o.p"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNoteInSearch(0, R.id.item_head_title_view).check(matches(allOf(withText(containsString("Note C")), isDisplayed()))); onNoteInSearch(1, R.id.item_head_title_view).check(matches(allOf(withText(containsString("Note D")), isDisplayed()))); @@ -656,7 +656,7 @@ public void testSearchNoteStateType() { scenario = ActivityScenario.launch(MainActivity.class); onView(allOf(withText("notebook"), isDisplayed())).perform(click()); - searchForText(".it.todo"); + searchForTextCloseKeyboard(".it.todo"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(2))); onNoteInSearch(0, R.id.item_head_title_view).check(matches(allOf(withText(containsString("Note C")), isDisplayed()))); @@ -674,7 +674,7 @@ public void testSearchStateType() { scenario = ActivityScenario.launch(MainActivity.class); onView(allOf(withText("notebook"), isDisplayed())).perform(click()); - searchForText("it.todo"); + searchForTextCloseKeyboard("it.todo"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(2))); onNoteInSearch(0, R.id.item_head_title_view).check(matches(allOf(withText(containsString("Note A")), isDisplayed()))); @@ -692,7 +692,7 @@ public void testSearchNoState() { scenario = ActivityScenario.launch(MainActivity.class); onView(allOf(withText("notebook"), isDisplayed())).perform(click()); - searchForText("it.none"); + searchForTextCloseKeyboard("it.none"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(1))); onNoteInSearch(0, R.id.item_head_title_view).check(matches(allOf(withText(containsString("Note D")), isDisplayed()))); @@ -709,7 +709,7 @@ public void testSearchWithState() { scenario = ActivityScenario.launch(MainActivity.class); onView(allOf(withText("notebook"), isDisplayed())).perform(click()); - searchForText(".it.none"); + searchForTextCloseKeyboard(".it.none"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(3))); onNoteInSearch(0, R.id.item_head_title_view).check(matches(allOf(withText(containsString("Note A")), isDisplayed()))); @@ -729,7 +729,7 @@ public void testContentOfFoldedNoteDisplayed() { onView(allOf(withText("notebook"), isDisplayed())).perform(click()); onNoteInBook(1, R.id.item_head_fold_button).perform(click()); - searchForText("note"); + searchForTextCloseKeyboard("note"); onView(withId(R.id.fragment_query_search_view_flipper)).check(matches(isDisplayed())); onNotesInSearch().check(matches(recyclerViewItemCount(3))); onNoteInSearch(1, R.id.item_head_title_view).check(matches(allOf(withText(containsString("Note B")), isDisplayed()))); @@ -741,7 +741,7 @@ public void testDeSelectRemovedNoteInSearch() { testUtils.setupBook("notebook", "* TODO Note A\n* TODO Note B"); scenario = ActivityScenario.launch(MainActivity.class); - searchForText("i.todo"); + searchForTextCloseKeyboard("i.todo"); onNoteInSearch(0).perform(longClick()); @@ -765,7 +765,7 @@ public void testDeSelectRemovedNoteInSearch() { @Test public void testNoNotesFoundMessageIsDisplayedInSearch() { scenario = ActivityScenario.launch(MainActivity.class); - searchForText("Note"); + searchForTextCloseKeyboard("Note"); onView(withText(R.string.no_notes_found_after_search)).check(matches(isDisplayed())); } @@ -775,7 +775,7 @@ public void testPreselectedStateOfSelectedNote() { testUtils.setupBook("notebook", "* TODO Note A\n* TODO Note B"); scenario = ActivityScenario.launch(MainActivity.class); - searchForText("i.todo"); + searchForTextCloseKeyboard("i.todo"); onNoteInSearch(1).perform(longClick()); @@ -788,7 +788,7 @@ public void testPreselectedStateOfSelectedNote() { public void testSearchAndClickOnNoteWithTwoDifferentEvents() { testUtils.setupBook("notebook", "* Note\n<2000-01-01>\n<2000-01-02>"); scenario = ActivityScenario.launch(MainActivity.class); - searchForText("e.lt.now"); + searchForTextCloseKeyboard("e.lt.now"); onNoteInSearch(0).perform(click()); } @@ -796,7 +796,7 @@ public void testSearchAndClickOnNoteWithTwoDifferentEvents() { public void testInactiveScheduled() { testUtils.setupBook("notebook-1", "* Note A\nSCHEDULED: [2020-07-01]"); scenario = ActivityScenario.launch(MainActivity.class); - searchForText("s.le.today"); + searchForTextCloseKeyboard("s.le.today"); onNotesInSearch().check(matches(recyclerViewItemCount(0))); } @@ -804,7 +804,7 @@ public void testInactiveScheduled() { public void testInactiveDeadline() { testUtils.setupBook("notebook-1", "* Note A\nDEADLINE: [2020-07-01]"); scenario = ActivityScenario.launch(MainActivity.class); - searchForText("d.le.today"); + searchForTextCloseKeyboard("d.le.today"); onNotesInSearch().check(matches(recyclerViewItemCount(0))); } @@ -831,7 +831,7 @@ public void testScheduledTimestamp() { onView(withText(R.string.set)).perform(click()); pressBack(); - searchForText("s.now"); + searchForTextCloseKeyboard("s.now"); onNotesInSearch().check(matches(recyclerViewItemCount(1))); } @@ -840,7 +840,7 @@ public void testScheduledTimestamp() { public void testNotScheduled() { testUtils.setupBook("notebook-1", "* Note A"); scenario = ActivityScenario.launch(MainActivity.class); - searchForText("s.no"); + searchForTextCloseKeyboard("s.no"); onNotesInSearch().check(matches(recyclerViewItemCount(1))); } } diff --git a/app/src/androidTest/java/com/orgzly/android/espresso/SettingsChangeTest.java b/app/src/androidTest/java/com/orgzly/android/espresso/SettingsChangeTest.java index 586c971c3..6ed707392 100644 --- a/app/src/androidTest/java/com/orgzly/android/espresso/SettingsChangeTest.java +++ b/app/src/androidTest/java/com/orgzly/android/espresso/SettingsChangeTest.java @@ -21,7 +21,7 @@ import static com.orgzly.android.espresso.util.EspressoUtils.onItemInAgenda; import static com.orgzly.android.espresso.util.EspressoUtils.onNoteInBook; import static com.orgzly.android.espresso.util.EspressoUtils.onNoteInSearch; -import static com.orgzly.android.espresso.util.EspressoUtils.searchForText; +import static com.orgzly.android.espresso.util.EspressoUtils.searchForTextCloseKeyboard; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.hasToString; @@ -46,7 +46,7 @@ public void setUp() throws Exception { @Test public void testChangeDefaultPrioritySearchResultsShouldBeReordered() { - searchForText("o.p"); + searchForTextCloseKeyboard("o.p"); onNoteInSearch(0, R.id.item_head_title_view) .check(matches(allOf(withText(containsString("#B Note [a-1]")), isDisplayed()))); @@ -63,7 +63,7 @@ public void testChangeDefaultPrioritySearchResultsShouldBeReordered() { @Test public void testChangeDefaultPriorityAgendaResultsShouldBeReordered() { - searchForText("o.p ad.2"); + searchForTextCloseKeyboard("o.p ad.2"); onItemInAgenda(1, R.id.item_head_title_view) .check(matches(allOf(withText(containsString("#B Note [a-1]")), isDisplayed()))); 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 243703a9d..b7542a0b3 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 @@ -327,9 +327,10 @@ public static ViewInteraction contextualToolbarOverflowMenu() { withClassName(endsWith("OverflowMenuButton")))); } - public static void searchForText(String str) { + public static void searchForTextCloseKeyboard(String str) { onView(allOf(withId(R.id.search_view), isDisplayed())).perform(click()); onView(withId(R.id.search_src_text)).perform(replaceText(str), pressKey(KeyEvent.KEYCODE_ENTER)); + closeSoftKeyboardWithDelay(); } public static ViewAction[] replaceTextCloseKeyboard(String str) {