Skip to content

Commit 990594e

Browse files
committed
Switch to bottom app bar
1 parent 6c0608b commit 990594e

File tree

118 files changed

+2479
-2430
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+2479
-2430
lines changed

app/src/androidTest/java/com/orgzly/android/espresso/ActionModeTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ public void setUp() throws Exception {
6767

6868
@Test
6969
public void testQueryFragmentCabShouldBeOpenedOnNoteLongClick() {
70-
onView(allOf(withText("book-one"), isDisplayed())).perform(click());
71-
7270
onView(withId(R.id.drawer_layout)).perform(open());
7371
onView(allOf(withText("Scheduled"), isDescendantOfA(withId(R.id.drawer_navigation_view)))).perform(click());
7472

@@ -85,7 +83,7 @@ public void testCabStaysOpenOnRotation() {
8583
scenario.onActivity(activity ->
8684
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE));
8785

88-
onView(withId(R.id.book_cab_cut)).check(matches(isDisplayed()));
86+
onView(withId(R.id.toggle_state)).check(matches(isDisplayed()));
8987

9088
// TODO: Check *the same* note is selected.
9189
}
@@ -108,7 +106,7 @@ public void testCabStaysOpenOnRotationInQueryFragment() {
108106
scenario.onActivity(activity ->
109107
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT));
110108

111-
onView(withId(R.id.bottom_action_bar_done)).check(matches(isDisplayed()));
109+
onView(withId(R.id.toggle_state)).check(matches(isDisplayed()));
112110
}
113111

114112
@Test

app/src/androidTest/java/com/orgzly/android/espresso/AgendaFragmentTest.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import static org.hamcrest.Matchers.anyOf;
3535
import static org.hamcrest.Matchers.endsWith;
3636
import static org.hamcrest.Matchers.equalTo;
37+
import static org.hamcrest.Matchers.not;
3738

3839
public class AgendaFragmentTest extends OrgzlyTest {
3940
private ActivityScenario<MainActivity> defaultSetUp() {
@@ -113,7 +114,7 @@ public void testOneTimeTaskMarkedDone() {
113114
* 7 Note 2
114115
*/
115116
onItemInAgenda(1).perform(longClick());
116-
onView(withId(R.id.bottom_action_bar_done)).perform(click());
117+
onView(withId(R.id.toggle_state)).perform(click());
117118
onNotesInAgenda().check(matches(recyclerViewItemCount(24)));
118119
}
119120

@@ -122,7 +123,7 @@ public void testRepeaterTaskMarkedDone() {
122123
defaultSetUp();
123124
searchForText(".it.done ad.7");
124125
onItemInAgenda(2).perform(longClick());
125-
onView(withId(R.id.bottom_action_bar_done)).perform(click());
126+
onView(withId(R.id.toggle_state)).perform(click());
126127
onNotesInAgenda().check(matches(recyclerViewItemCount(23)));
127128
}
128129

@@ -131,7 +132,7 @@ public void testRangeTaskMarkedDone() {
131132
defaultSetUp();
132133
searchForText(".it.done ad.7");
133134
onItemInAgenda(3).perform(longClick());
134-
onView(withId(R.id.bottom_action_bar_done)).perform(click());
135+
onView(withId(R.id.toggle_state)).perform(click());
135136
onNotesInAgenda().check(matches(recyclerViewItemCount(17)));
136137
}
137138

@@ -142,7 +143,7 @@ public void testMoveTaskWithRepeaterToTomorrow() {
142143
defaultSetUp();
143144
searchForText(".it.done ad.7");
144145
onItemInAgenda(2).perform(longClick());
145-
onView(withId(R.id.bottom_action_bar_schedule)).perform(click());
146+
onView(withId(R.id.schedule)).perform(click());
146147
onView(withId(R.id.date_picker_button)).perform(click());
147148
onView(withClassName(equalTo(DatePicker.class.getName())))
148149
.perform(PickerActions.setDate(
@@ -181,14 +182,14 @@ public void testDeselectRemovedNoteInAgenda() {
181182
onItemInAgenda(1).perform(longClick());
182183

183184
onNotesInAgenda().check(matches(recyclerViewItemCount(12)));
184-
onView(withId(R.id.action_bar_title)).check(matches(withText("1")));
185+
onView(withId(R.id.bottomAppBarTitle)).check(matches(withText("1")));
185186

186187
// Remove state
187-
onView(withId(R.id.bottom_action_bar_state)).perform(click());
188+
onView(withId(R.id.state)).perform(click());
188189
onView(withText(R.string.clear)).perform(click());
189190

190191
onNotesInAgenda().check(matches(recyclerViewItemCount(8)));
191-
onView(withId(R.id.action_bar_title)).check(doesNotExist());
192+
onView(withId(R.id.bottomAppBarTitle)).check(matches(not(isDisplayed())));
192193
}
193194

194195
@Ignore("Not implemented yet")
@@ -200,7 +201,7 @@ public void testPreselectedStateOfSelectedNote() {
200201
searchForText("ad.3");
201202

202203
onItemInAgenda(1).perform(longClick());
203-
onView(withId(R.id.bottom_action_bar_state)).perform(click());
204+
onView(withId(R.id.state)).perform(click());
204205

205206
onView(withText("TODO")).check(matches(isChecked()));
206207
}
@@ -237,7 +238,7 @@ public void testChangeStateWithReverseNoteClick() {
237238

238239
searchForText(".it.done ad.7");
239240
onItemInAgenda(1).perform(longClick());
240-
onView(withId(R.id.bottom_action_bar_state)).perform(click());
241+
onView(withId(R.id.state)).perform(click());
241242
onView(withText("NEXT")).perform(click());
242243
}
243244

app/src/androidTest/java/com/orgzly/android/espresso/BookPrefaceTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.orgzly.android.espresso
22

3+
import android.os.SystemClock
34
import androidx.annotation.StringRes
45
import androidx.test.core.app.ActivityScenario
56
import androidx.test.espresso.Espresso.*
@@ -49,7 +50,7 @@ class BookPrefaceTest : OrgzlyTest() {
4950
fun testUpdatingBookPreface() {
5051
onPreface().perform(click())
5152
onView(withId(R.id.fragment_book_preface_content)).perform(*replaceTextCloseKeyboard("New content"))
52-
onView(withId(R.id.done)).perform(click())
53+
onView(withId(R.id.fab)).perform(click()) // Preface done
5354
onPreface().perform(click())
5455
onView(withId(R.id.fragment_book_preface_content)).check(matches(withText("New content")))
5556
}
@@ -59,10 +60,9 @@ class BookPrefaceTest : OrgzlyTest() {
5960
// Preface is displayed
6061
onPreface().check(matches(isDisplayed()))
6162

62-
// Enter and delete it
63+
// Open preface and delete it
6364
onPreface().perform(click())
64-
openContextualActionModeOverflowMenu()
65-
onView(withText(R.string.delete)).perform(click())
65+
onView(withId(R.id.delete)).perform(click())
6666

6767
// Preface is not displayed anymore
6868
onPreface().check(matches(not(isDisplayed())))

app/src/androidTest/java/com/orgzly/android/espresso/BookTest.java

Lines changed: 47 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import android.widget.DatePicker;
55

66
import androidx.test.core.app.ActivityScenario;
7-
import androidx.test.espresso.contrib.RecyclerViewActions;
87

98
import com.orgzly.R;
109
import com.orgzly.android.OrgzlyTest;
@@ -31,10 +30,9 @@
3130
import static androidx.test.espresso.matcher.ViewMatchers.withId;
3231
import static androidx.test.espresso.matcher.ViewMatchers.withText;
3332
import static com.orgzly.android.espresso.EspressoUtils.closeSoftKeyboardWithDelay;
33+
import static com.orgzly.android.espresso.EspressoUtils.contextualToolbarOverflowMenu;
3434
import static com.orgzly.android.espresso.EspressoUtils.onActionItemClick;
3535
import static com.orgzly.android.espresso.EspressoUtils.onNoteInBook;
36-
import static com.orgzly.android.espresso.EspressoUtils.onNotesInBook;
37-
import static com.orgzly.android.espresso.EspressoUtils.openContextualToolbarOverflowMenu;
3836
import static com.orgzly.android.espresso.EspressoUtils.replaceTextCloseKeyboard;
3937
import static org.hamcrest.Matchers.allOf;
4038
import static org.hamcrest.Matchers.anyOf;
@@ -101,6 +99,9 @@ public void setUp() throws Exception {
10199
"** Note #40.\n" +
102100
"");
103101

102+
// Empty book for tests that need to scroll down to a newly created note
103+
testUtils.setupBook("Book B", "");
104+
104105
scenario = ActivityScenario.launch(MainActivity.class);
105106

106107
onView(allOf(withText("book-name"), isDisplayed())).perform(click());
@@ -127,7 +128,7 @@ public void testScheduledNoteTimeStaysTheSameAfterSetting() {
127128
onNoteInBook(9, R.id.item_head_scheduled_text).check(matches(allOf(withText(userDateTime("<2014-05-26 Mon>")), isDisplayed())));
128129

129130
onNoteInBook(9).perform(longClick());
130-
onView(withId(R.id.bottom_action_bar_schedule)).perform(click());
131+
onView(withId(R.id.schedule)).perform(click());
131132
onView(withText(R.string.set)).perform(click());
132133

133134
onNoteInBook(9, R.id.item_head_scheduled_text).check(matches(allOf(withText(userDateTime("<2014-05-26 Mon>")), isDisplayed())));
@@ -141,7 +142,7 @@ public void testRemovingScheduledTimeFromMultipleNotes() {
141142
onNoteInBook(8).perform(longClick());
142143
onNoteInBook(9).perform(click());
143144

144-
onView(withId(R.id.bottom_action_bar_schedule)).perform(click());
145+
onView(withId(R.id.schedule)).perform(click());
145146
onView(withText(R.string.clear)).perform(click());
146147

147148
onNoteInBook(8, R.id.item_head_scheduled_text).check(matches(not(isDisplayed())));
@@ -156,7 +157,7 @@ public void testRemovingDoneState() {
156157
onNoteInBook(5).perform(longClick());
157158
onNoteInBook(8).perform(click());
158159

159-
onView(withId(R.id.bottom_action_bar_state)).perform(click());
160+
onView(withId(R.id.state)).perform(click());
160161
onView(withText("TODO")).perform(click());
161162

162163
onNoteInBook(5, R.id.item_head_title).check(matches(withText(startsWith("TODO"))));
@@ -168,7 +169,7 @@ public void testClearStateTitleUnchanged() {
168169
onNoteInBook(1, R.id.item_head_title).check(matches(withText("Note #1.")));
169170

170171
onNoteInBook(1).perform(longClick());
171-
onView(withId(R.id.bottom_action_bar_state)).perform(click());
172+
onView(withId(R.id.state)).perform(click());
172173
onView(withText(R.string.clear)).perform(click());
173174

174175
onNoteInBook(1, R.id.item_head_title).check(matches(withText("Note #1.")));
@@ -234,7 +235,8 @@ public void testBackFromSettingsShouldReturnToPreviousFragment() {
234235
public void testCutThenOpenNoteAtThePosition() {
235236
onNoteInBook(2).perform(longClick());
236237

237-
onView(withId(R.id.book_cab_cut)).perform(click());
238+
contextualToolbarOverflowMenu().perform(click());
239+
onView(withText(R.string.cut)).perform(click());
238240

239241
/* Open note at the same position as the cut one. */
240242
onNoteInBook(2).perform(click());
@@ -243,7 +245,7 @@ public void testCutThenOpenNoteAtThePosition() {
243245
@Test
244246
public void testCabForMovingNotesDisplayed() {
245247
onNoteInBook(1).perform(longClick());
246-
openContextualToolbarOverflowMenu();
248+
contextualToolbarOverflowMenu().perform(click());
247249
onView(withText(R.string.move)).perform(click());
248250
onView(withId(R.id.notes_action_move_down)).check(matches(isDisplayed()));
249251
}
@@ -252,7 +254,7 @@ public void testCabForMovingNotesDisplayed() {
252254
public void testOrderOfMovedNote() {
253255
onNoteInBook(3).perform(longClick());
254256

255-
openContextualToolbarOverflowMenu();
257+
contextualToolbarOverflowMenu().perform(click());
256258
onView(withText(R.string.move)).perform(click());
257259
onView(withId(R.id.notes_action_move_down)).perform(click());
258260

@@ -273,7 +275,7 @@ public void testActionModeMovingStaysOpenAfterRotation() {
273275

274276
onNoteInBook(2).perform(longClick());
275277

276-
openContextualToolbarOverflowMenu();
278+
contextualToolbarOverflowMenu().perform(click());
277279
onView(withText(R.string.move)).perform(click());
278280
onView(withId(R.id.notes_action_move_down)).check(matches(isDisplayed()));
279281

@@ -287,23 +289,24 @@ public void testActionModeMovingStaysOpenAfterRotation() {
287289
public void testPromoting() {
288290
onNoteInBook(2).perform(longClick());
289291

290-
openContextualToolbarOverflowMenu();
292+
contextualToolbarOverflowMenu().perform(click());
291293
onView(withText(R.string.move)).perform(click());
292294
onView(withId(R.id.notes_action_move_left)).perform(click());
293295
}
294296

295297
@Test
296298
public void testPasteAbove() {
297299
onNoteInBook(2).perform(longClick());
298-
299-
onView(withId(R.id.book_cab_cut)).perform(click());
300+
contextualToolbarOverflowMenu().perform(click());
301+
onView(withText(R.string.cut)).perform(click());
300302

301303
onNoteInBook(1, R.id.item_head_title).check(matches(withText(endsWith("Note #1."))));
302304
onNoteInBook(2, R.id.item_head_title).check(matches(withText(endsWith("Note #8."))));
303305
onNoteInBook(3, R.id.item_head_title).check(matches(withText(endsWith("Note #9."))));
304306

305307
onNoteInBook(1).perform(longClick());
306-
onView(withId(R.id.book_cab_paste)).perform(click());
308+
contextualToolbarOverflowMenu().perform(click());
309+
onView(withText(R.string.paste)).perform(click());
307310
onView(withText(R.string.heads_action_menu_item_paste_above)).perform(click());
308311

309312
onNoteInBook(1, R.id.item_head_title).check(matches(withText(endsWith("Note #2."))));
@@ -320,15 +323,16 @@ public void testPasteAbove() {
320323
@Test
321324
public void testPasteUnder() {
322325
onNoteInBook(2).perform(longClick());
323-
324-
onView(withId(R.id.book_cab_cut)).perform(click());
326+
contextualToolbarOverflowMenu().perform(click());
327+
onView(withText(R.string.cut)).perform(click());
325328

326329
onNoteInBook(1, R.id.item_head_title).check(matches(withText(endsWith("Note #1."))));
327330
onNoteInBook(2, R.id.item_head_title).check(matches(withText(endsWith("Note #8."))));
328331
onNoteInBook(3, R.id.item_head_title).check(matches(withText(endsWith("Note #9."))));
329332

330333
onNoteInBook(2).perform(longClick());
331-
onView(withId(R.id.book_cab_paste)).perform(click());
334+
contextualToolbarOverflowMenu().perform(click());
335+
onView(withText(R.string.paste)).perform(click());
332336
onView(withText(R.string.heads_action_menu_item_paste_under)).perform(click());
333337

334338
onNoteInBook(1, R.id.item_head_title).check(matches(withText(endsWith("Note #1."))));
@@ -342,11 +346,12 @@ public void testPasteUnder() {
342346
@Test
343347
public void testCopyBelow() {
344348
onNoteInBook(1).perform(longClick());
345-
346-
onView(withId(R.id.book_cab_copy)).perform(click());
349+
contextualToolbarOverflowMenu().perform(click());
350+
onView(withText(R.string.copy)).perform(click());
347351

348352
onNoteInBook(1).perform(longClick());
349-
onView(withId(R.id.book_cab_paste)).perform(click());
353+
contextualToolbarOverflowMenu().perform(click());
354+
onView(withText(R.string.paste)).perform(click());
350355
onView(withText(R.string.heads_action_menu_item_paste_below)).perform(click());
351356

352357
onNoteInBook(1, R.id.item_head_title).check(matches(withText(endsWith("Note #1."))));
@@ -370,10 +375,10 @@ public void testCreateNewNoteUnderFolded() {
370375

371376
/* Create new note under folded. */
372377
onNoteInBook(2).perform(longClick());
373-
onView(withId(R.id.bottom_action_bar_new)).perform(click());
378+
onView(withId(R.id.new_note)).perform(click());
374379
onView(withText(R.string.new_under)).perform(click());
375380
onView(withId(R.id.fragment_note_title)).perform(replaceTextCloseKeyboard("Created"));
376-
onView(withId(R.id.done)).perform(click());
381+
onView(withId(R.id.fab)).perform(click()); // Note done
377382

378383
/* New note should not be visible. */
379384
onNoteInBook(1, R.id.item_head_title).check(matches(withText(endsWith("Note #1."))));
@@ -384,11 +389,21 @@ public void testCreateNewNoteUnderFolded() {
384389
@Test
385390
public void testNewNoteHasCreatedAtPropertyAfterSaving() {
386391
AppPreferences.createdAt(context, true);
392+
393+
// Open an empty book
394+
pressBack();
395+
onView(allOf(withText("Book B"), isDisplayed())).perform(click());
396+
397+
// Create a new note
387398
onView(withId(R.id.fab)).perform(click());
388399
onView(withId(R.id.fragment_note_title)).perform(replaceTextCloseKeyboard("Title"));
389-
onView(withId(R.id.done)).perform(click());
390-
onNotesInBook().perform(RecyclerViewActions.actionOnItemAtPosition(41, click()));
400+
onView(withId(R.id.fab)).perform(click()); // Note done
401+
402+
// Enter note
403+
onNoteInBook(1).perform(click());
391404
onView(withId(R.id.fragment_note_container)).perform(swipeUp()); // For small screens
405+
406+
// Check properties
392407
onView(allOf(withId(R.id.name), withText(R.string.created_property_name))).check(matches(isDisplayed()));
393408
onView(allOf(withId(R.id.name), withText(""))).check(matches(isDisplayed()));
394409
}
@@ -404,7 +419,7 @@ public void testReturnToNonExistentNoteByPressingBack() {
404419

405420
// Delete notebook
406421
onView(allOf(withText("book-name"), withId(R.id.item_book_title))).perform(longClick());
407-
openContextualToolbarOverflowMenu();
422+
contextualToolbarOverflowMenu().perform(click());
408423
onView(withText(R.string.delete)).perform(click());
409424
onView(withText(R.string.delete)).perform(click());
410425

@@ -439,18 +454,18 @@ public void testSetDeadlineTimeForNewNote() {
439454
@Test
440455
public void testToggleState() {
441456
onNoteInBook(1).perform(longClick());
442-
onView(withId(R.id.bottom_action_bar_done)).perform(click());
457+
onView(withId(R.id.toggle_state)).perform(click());
443458
onNoteInBook(1, R.id.item_head_title).check(matches(withText(startsWith("DONE"))));
444459

445-
onView(withId(R.id.bottom_action_bar_done)).perform(click());
460+
onView(withId(R.id.toggle_state)).perform(click());
446461
onNoteInBook(1, R.id.item_head_title).check(matches(withText(startsWith("TODO"))));
447462
}
448463

449464
@Test
450465
public void testToggleStateForAllDone() {
451466
onNoteInBook(5).perform(longClick());
452467
onNoteInBook(8).perform(click());
453-
onView(withId(R.id.bottom_action_bar_done)).perform(click());
468+
onView(withId(R.id.toggle_state)).perform(click());
454469

455470
onNoteInBook(5, R.id.item_head_title).check(matches(withText(startsWith("TODO"))));
456471
onNoteInBook(8, R.id.item_head_title).check(matches(withText(startsWith("TODO"))));
@@ -460,7 +475,7 @@ public void testToggleStateForAllDone() {
460475
public void testToggleStateForAllTodo() {
461476
onNoteInBook(1).perform(longClick());
462477
onNoteInBook(2).perform(click());
463-
onView(withId(R.id.bottom_action_bar_done)).perform(click());
478+
onView(withId(R.id.toggle_state)).perform(click());
464479

465480
onNoteInBook(1, R.id.item_head_title).check(matches(withText(startsWith("DONE"))));
466481
onNoteInBook(2, R.id.item_head_title).check(matches(withText(startsWith("DONE"))));
@@ -470,7 +485,7 @@ public void testToggleStateForAllTodo() {
470485
public void testToggleStateForMixed() {
471486
onNoteInBook(1).perform(longClick());
472487
onNoteInBook(5).perform(click());
473-
onView(withId(R.id.bottom_action_bar_done)).perform(click());
488+
onView(withId(R.id.toggle_state)).perform(click());
474489

475490
onNoteInBook(1, R.id.item_head_title).check(matches(withText(startsWith("DONE"))));
476491
onNoteInBook(5, R.id.item_head_title).check(matches(withText(startsWith("DONE"))));
@@ -481,7 +496,7 @@ public void testToggleStateForMixed() {
481496
public void testPreselectedStateOfSelectedNote() {
482497
onNoteInBook(3).perform(longClick());
483498

484-
onView(withId(R.id.bottom_action_bar_state)).perform(click());
499+
onView(withId(R.id.state)).perform(click());
485500

486501
onView(withText("TODO")).check(matches(isChecked()));
487502
}

0 commit comments

Comments
 (0)