use of com.ichi2.libanki.sched.AbstractSched in project AnkiChinaAndroid by ankichinateam.
the class AbstractSchedTest method regression_7066.
@Test
public void regression_7066() {
Collection col = getCol();
DeckConfig dconf = col.getDecks().getConf(1);
dconf.getJSONObject("new").put("bury", true);
AbstractSched sched = col.getSched();
addNoteUsingBasicAndReversedModel("foo", "bar");
addNoteUsingBasicModel("plop", "foo");
col.reset();
Card card = sched.getCard();
sched.setCurrentCard(card);
sched.preloadNextCard();
sched.answerCard(card, Consts.BUTTON_THREE);
card = sched.getCard();
sched.setCurrentCard(card);
AnkiAssert.assertDoesNotThrow(() -> sched.preloadNextCard());
}
use of com.ichi2.libanki.sched.AbstractSched in project AnkiChinaAndroid by ankichinateam.
the class AbstractSchedTest method ensureUndoCorrectCounts.
@Test
public void ensureUndoCorrectCounts() {
Collection col = getCol();
AbstractSched sched = col.getSched();
Deck deck = col.getDecks().get(1);
DeckConfig dconf = col.getDecks().getConf(1);
dconf.getJSONObject("new").put("perDay", 10);
JSONArray newCount = deck.getJSONArray("newToday");
for (int i = 0; i < 20; i++) {
Note note = col.newNote();
note.setField(0, "a");
col.addNote(note);
}
col.reset();
assertThat(col.cardCount(), is(20));
assertThat(sched.newCount(), is(10));
Card card = sched.getCard();
assertThat(sched.newCount(), is(9));
assertThat(sched.counts(card)[0], is(10));
sched.answerCard(card, sched.getGoodNewButton());
sched.getCard();
nonTaskUndo(col);
card.load();
assertThat(sched.newCount(), is(9));
assertThat(sched.counts(card)[0], is(10));
}
use of com.ichi2.libanki.sched.AbstractSched in project AnkiChinaAndroid by ankichinateam.
the class SchedV2Test method ensureDeckTree.
@Test
public void ensureDeckTree() throws Exception {
for (String deckName : TEST_DECKS) {
addDeck(deckName);
}
AbstractSched sched = getCol().getSched();
List<DeckDueTreeNode> tree = sched.deckDueTree();
Assert.assertEquals("Tree has not the expected structure", expectedTree(getCol(), true), tree);
}
use of com.ichi2.libanki.sched.AbstractSched in project AnkiChinaAndroid by ankichinateam.
the class SchedTest method ensureDeckTree.
@Test
public void ensureDeckTree() {
for (String deckName : TEST_DECKS) {
addDeck(deckName);
}
getCol().getSched().deckDueTree();
AbstractSched sched = getCol().getSched();
List<DeckDueTreeNode> tree = sched.deckDueTree();
Assert.assertEquals("Tree has not the expected structure", SchedV2Test.expectedTree(getCol(), false), tree);
}
use of com.ichi2.libanki.sched.AbstractSched in project Anki-Android by ankidroid.
the class SchedTest method test_ordcycleV1.
@Test
public void test_ordcycleV1() throws Exception {
Collection col = getColV1();
// add two more templates and set second active
Model m = col.getModels().current();
ModelManager mm = col.getModels();
JSONObject t = Models.newTemplate("Reverse");
t.put("qfmt", "{{Back}}");
t.put("afmt", "{{Front}}");
mm.addTemplateModChanged(m, t);
t = Models.newTemplate("f2");
t.put("qfmt", "{{Front}}");
t.put("afmt", "{{Back}}");
mm.addTemplateModChanged(m, t);
mm.save(m);
// create a new note; it should have 3 cards
Note note = col.newNote();
note.setItem("Front", "1");
note.setItem("Back", "1");
col.addNote(note);
assertEquals(3, col.cardCount());
col.reset();
// ordinals should arrive in order
AbstractSched sched = col.getSched();
Card c = sched.getCard();
// not upstream. But we are not expecting multiple getCard without review
sched.answerCard(c, sched.answerButtons(c) - 1);
waitForAsyncTasksToComplete();
assertEquals(0, c.getOrd());
c = sched.getCard();
// not upstream. But we are not expecting multiple getCard without review
sched.answerCard(c, sched.answerButtons(c) - 1);
waitForAsyncTasksToComplete();
assertEquals(1, c.getOrd());
c = sched.getCard();
// not upstream. But we are not expecting multiple getCard without review
sched.answerCard(c, sched.answerButtons(c) - 1);
assertEquals(2, c.getOrd());
}
Aggregations