use of com.ichi2.anki.Reviewer in project Anki-Android by ankidroid.
the class ReviewerTest method testMultipleCards.
@Test
public synchronized void testMultipleCards() throws ConfirmModSchemaException {
addNoteWithThreeCards();
Collection col = getCol();
JSONObject nw = col.getDecks().confForDid(1).getJSONObject("new");
MockTime time = getCollectionTime();
nw.put("delays", new JSONArray(new int[] { 1, 10, 60, 120 }));
waitForAsyncTasksToComplete();
Reviewer reviewer = startReviewer();
waitForAsyncTasksToComplete();
assertCounts(reviewer, 3, 0, 0);
// card 1 is shown
answerCardOrdinalAsGood(reviewer, 1);
// card get scheduler in [10, 12.5] minutes
time.addM(3);
// We wait 3 minutes to ensure card 2 is scheduled after card 1
// card 2 is shown
answerCardOrdinalAsGood(reviewer, 2);
// Same as above
time.addM(3);
// card 3 is shown
answerCardOrdinalAsGood(reviewer, 3);
undo(reviewer);
assertCurrentOrdIs(reviewer, 3);
// card 3 is shown
answerCardOrdinalAsGood(reviewer, 3);
// Anki Desktop shows "1"
assertCurrentOrdIsNot(reviewer, 3);
}
use of com.ichi2.anki.Reviewer in project Anki-Android by ankidroid.
the class ReviewerTest method jsAnkiGetDeckName.
@Test
public void jsAnkiGetDeckName() {
Collection col = getCol();
ModelManager models = col.getModels();
DeckManager decks = col.getDecks();
Long didAb = addDeck("A::B");
Model basic = models.byName(AnkiDroidApp.getAppResources().getString(R.string.basic_model_name));
basic.put("did", didAb);
addNoteUsingBasicModel("foo", "bar");
Long didA = addDeck("A");
decks.select(didA);
Reviewer reviewer = startReviewer();
AnkiDroidJsAPI javaScriptFunction = reviewer.javaScriptFunction();
waitForAsyncTasksToComplete();
assertThat(javaScriptFunction.ankiGetDeckName(), is("B"));
}
use of com.ichi2.anki.Reviewer in project Anki-Android by ankidroid.
the class ReviewerTest method jsTime4ShouldBeBlankIfButtonUnavailable.
@Test
public void jsTime4ShouldBeBlankIfButtonUnavailable() {
// #6623 - easy should be blank when displaying a card with 3 buttons (after displaying a review)
Note firstNote = addNoteUsingBasicModel("Hello", "World");
moveToReviewQueue(firstNote.firstCard());
addNoteUsingBasicModel("Hello", "World2");
Reviewer reviewer = startReviewer();
AnkiDroidJsAPI javaScriptFunction = reviewer.javaScriptFunction();
// The answer needs to be displayed to be able to get the time.
displayAnswer(reviewer);
assertThat("4 buttons should be displayed", reviewer.getAnswerButtonCount(), is(4));
String nextTime = javaScriptFunction.ankiGetNextTime4();
assertThat(nextTime, not(emptyString()));
// Display the next answer
reviewer.answerCard(Consts.BUTTON_FOUR);
displayAnswer(reviewer);
if (schedVersion == 1) {
assertThat("The 4th button should not be visible", reviewer.getAnswerButtonCount(), is(3));
String learnTime = javaScriptFunction.ankiGetNextTime4();
assertThat("If the 4th button is not visible, there should be no time4 in JS", learnTime, emptyString());
}
}
use of com.ichi2.anki.Reviewer in project Anki-Android by ankidroid.
the class PreviewerTest method previewerShouldNotAccessScheduler.
@Test
public void previewerShouldNotAccessScheduler() {
Card cardToPreview = addNoteUsingBasicModel("Hello", "World").firstCard();
Previewer previewer = getPreviewerPreviewing(cardToPreview);
assertThat("Previewer is not a reviewer", previewer.canAccessScheduler(), is(false));
}
use of com.ichi2.anki.Reviewer in project Anki-Android by ankidroid.
the class AbstractSchedTest method siblingCorrectlyBuried.
@Test
public void siblingCorrectlyBuried() {
// #6903
Collection col = getCol();
AbstractSched sched = col.getSched();
DeckConfig dconf = col.getDecks().getConf(1);
assertThat(dconf, notNullValue());
dconf.getJSONObject("new").put("bury", true);
getCol().getDecks().save(dconf);
final int nbNote = 2;
Note[] notes = new Note[nbNote];
for (int i = 0; i < nbNote; i++) {
Note note = addNoteUsingBasicAndReversedModel("front", "back");
notes[i] = note;
}
col.reset();
for (int i = 0; i < nbNote; i++) {
Card card = sched.getCard();
Counts counts = sched.counts(card);
// imitate what the reviewer does
sched.setCurrentCard(card);
// Actual number of new card.
assertThat(counts.getNew(), is(greaterThan(nbNote - i)));
// Maximal number potentially shown,
assertThat(counts.getNew(), is(lessThanOrEqualTo(nbNote * 2 - i)));
// because decrementing does not consider burying sibling
assertEquals(0, counts.getLrn());
assertEquals(0, counts.getRev());
assertEquals(notes[i].firstCard().getId(), card.getId());
assertEquals(Consts.QUEUE_TYPE_NEW, card.getQueue());
sched.answerCard(card, sched.answerButtons(card));
}
Card card = sched.getCard();
assertNull(card);
}
Aggregations