Skip to content

Commit

Permalink
NF: Rearrange methods in ReviewerTest
Browse files Browse the repository at this point in the history
  • Loading branch information
david-allison authored and mikehardy committed Jan 28, 2021
1 parent 0956db3 commit 5ed7eb0
Showing 1 changed file with 38 additions and 40 deletions.
78 changes: 38 additions & 40 deletions AnkiDroid/src/test/java/com/ichi2/anki/ReviewerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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();
Expand Down Expand Up @@ -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<String> 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();
Expand Down Expand Up @@ -405,22 +421,4 @@ private List<String> 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"));
}

}

0 comments on commit 5ed7eb0

Please sign in to comment.