Skip to content

Commit

Permalink
Remove "Edit preface" if book doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
nevenz committed Feb 8, 2017
1 parent 7db23a2 commit c9dcbe7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,21 @@ public void testReturnToNonExistentBookByPressingBack() {
onView(allOf(withText("This notebook does not exist any more."), isDisplayed())).check(doesNotExist());
}

@Test
public void testEnterPrefaceForNonExistentBook() {
onView(allOf(withText("book-one"), isDisplayed())).perform(click());
onView(withId(R.id.drawer_layout)).perform(open());
onView(withText("Notebooks")).perform(click());
onView(allOf(withText("book-one"), isDisplayed())).perform(longClick());
onData(hasToString(containsString("Delete"))).perform(click());
onView(withText(R.string.ok)).perform(click());
pressBack();
onView(withId(R.id.fragment_book_view_flipper)).check(matches(isDisplayed()));

openContextualActionModeOverflowMenu();
onView(withText(R.string.edit_book_preface)).check(doesNotExist());
}

@Test
public void testExport() {
onView(allOf(withText("book-one"), isDisplayed())).perform(longClick());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,17 @@ public void onPrepareOptionsMenu(Menu menu) {

MenuItem item;

/* Hide cycle-visibility item if book does not exist. */
item = menu.findItem(R.id.books_options_menu_item_cycle_visibility);
if (item != null && mBook == null) {
item.setVisible(false);
/* Hide some items if book doesn't exist. */
if (mBook == null) {
item = menu.findItem(R.id.books_options_menu_item_cycle_visibility);
if (item != null) {
item.setVisible(false);
}

item = menu.findItem(R.id.books_options_menu_book_preface);
if (item != null) {
item.setVisible(false);
}
}

// /* Toggle paste item visibility. */
Expand Down

0 comments on commit c9dcbe7

Please sign in to comment.