From 5ed7eb06688db282384555f2941d0d56488d313e Mon Sep 17 00:00:00 2001 From: David Allison <62114487+david-allison-1@users.noreply.github.com> Date: Thu, 28 Jan 2021 09:57:25 +0000 Subject: [PATCH] NF: Rearrange methods in ReviewerTest --- .../java/com/ichi2/anki/ReviewerTest.java | 78 +++++++++---------- 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/AnkiDroid/src/test/java/com/ichi2/anki/ReviewerTest.java b/AnkiDroid/src/test/java/com/ichi2/anki/ReviewerTest.java index ded5f0badf0e..78d686617aae 100644 --- a/AnkiDroid/src/test/java/com/ichi2/anki/ReviewerTest.java +++ b/AnkiDroid/src/test/java/com/ichi2/anki/ReviewerTest.java @@ -158,28 +158,6 @@ public void onlyDisableWhiteboardAppearsInAppBarIfAllAppBarButtonsAreDisabledWit assertThat("No menu items should be visible if all are disabled in Settings - Reviewer - App Bar Buttons", visibleButtons, empty()); } - - private void toggleWhiteboard(ReviewerForMenuItems reviewer) { - reviewer.toggleWhiteboard(); - - assumeTrue("Whiteboard should now be enabled", reviewer.mPrefWhiteboard); - - advanceRobolectricLooperWithSleep(); - } - - - private void disableAllReviewerAppBarButtons() { - Set keys = PreferenceUtils.getAllCustomButtonKeys(getTargetContext()); - - SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getTargetContext()); - - SharedPreferences.Editor e = preferences.edit(); - for (String k : keys) { - e.putString(k, Integer.toString(ActionButtonStatus.MENU_DISABLED)); - } - e.apply(); - } - @Test public synchronized void testMultipleCards() throws ConfirmModSchemaException { addNoteWithThreeCards(); @@ -253,6 +231,44 @@ public void testLrnQueueAfterUndo() { equalFirstField(cards[0], reviewer.mCurrentCard); // This failed in #6898 because this card was not in the queue } + @Test + public void baseDeckName() { + Collection col = getCol(); + Models models = col.getModels(); + + Decks decks = col.getDecks(); + Long didAb = decks.id("A::B"); + Model basic = models.byName(AnkiDroidApp.getAppResources().getString(R.string.basic_model_name)); + basic.put("did", didAb); + addNoteUsingBasicModel("foo", "bar"); + Long didA = decks.id("A"); + decks.select(didA); + Reviewer reviewer = startReviewer(); + waitForAsyncTasksToComplete(); + assertThat(reviewer.getSupportActionBar().getTitle(), is("B")); + } + + + private void toggleWhiteboard(ReviewerForMenuItems reviewer) { + reviewer.toggleWhiteboard(); + + assumeTrue("Whiteboard should now be enabled", reviewer.mPrefWhiteboard); + + advanceRobolectricLooperWithSleep(); + } + + + private void disableAllReviewerAppBarButtons() { + Set keys = PreferenceUtils.getAllCustomButtonKeys(getTargetContext()); + + SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getTargetContext()); + + SharedPreferences.Editor e = preferences.edit(); + for (String k : keys) { + e.putString(k, Integer.toString(ActionButtonStatus.MENU_DISABLED)); + } + e.apply(); + } private void assertCurrentOrdIsNot(Reviewer r, int i) { waitForAsyncTasksToComplete(); @@ -405,22 +421,4 @@ private List getVisibleButtonNamesExcept(Integer... doNotReturn) { return visibleButtons; } } - - @Test - public void baseDeckName() { - Collection col = getCol(); - Models models = col.getModels(); - - Decks decks = col.getDecks(); - Long didAb = decks.id("A::B"); - Model basic = models.byName(AnkiDroidApp.getAppResources().getString(R.string.basic_model_name)); - basic.put("did", didAb); - addNoteUsingBasicModel("foo", "bar"); - Long didA = decks.id("A"); - decks.select(didA); - Reviewer reviewer = startReviewer(); - waitForAsyncTasksToComplete(); - assertThat(reviewer.getSupportActionBar().getTitle(), is("B")); - } - }