use of com.ichi2.libanki.sched.Sched in project AnkiChinaAndroid by ankichinateam.
the class SchedTest method unburyWorksIfDeckIsNotSelected.
@Test
public void unburyWorksIfDeckIsNotSelected() {
// Issue 6200
Sched sched = new Sched(getCol());
Card buriedCard = createBuriedCardInDefaultDeck();
assertThat(buriedCard.getDid(), is(Consts.DEFAULT_DECK_ID));
assertThat("Card should be buried", getCardInDefaultDeck(sched), nullValue());
// We want to assert that we can unbury, even if the deck we're unburying from isn't selected
selectNewDeck();
sched.unburyCardsForDeck(Consts.DEFAULT_DECK_ID);
assertThat("Card should no longer be buried", getCardInDefaultDeck(sched), notNullValue());
}
use of com.ichi2.libanki.sched.Sched in project AnkiChinaAndroid by ankichinateam.
the class SchedV2Test method test_ordcycleV2.
@Test
public void test_ordcycleV2() throws Exception {
Collection col = getColV2();
// add two more templates and set second active
Model m = col.getModels().current();
Models mm = col.getModels();
JSONObject t = mm.newTemplate("Reverse");
t.put("qfmt", "{{Back}}");
t.put("afmt", "{{Front}}");
mm.addTemplateModChanged(m, t);
t = mm.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);
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);
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());
}
use of com.ichi2.libanki.sched.Sched in project AnkiChinaAndroid by ankichinateam.
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();
Models mm = col.getModels();
JSONObject t = mm.newTemplate("Reverse");
t.put("qfmt", "{{Back}}");
t.put("afmt", "{{Front}}");
mm.addTemplateModChanged(m, t);
t = mm.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);
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);
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());
}
use of com.ichi2.libanki.sched.Sched in project AnkiChinaAndroid by ankichinateam.
the class SchedTest method learnCardsAreNotFiltered.
@Test
public void learnCardsAreNotFiltered() {
// Replicates Anki commit: 13c54e02d8fd2b35f6c2f4b796fc44dec65043b8
addNoteUsingBasicModel("Hello", "World");
Sched sched = new Sched(getCol());
markNextCardAsGood(sched);
long dynDeck = addDynamicDeck("Hello");
// Act
sched.rebuildDyn(dynDeck);
// Assert
DeckDueTreeNode dynamicDeck = getCountsForDid(dynDeck);
assertThat("A learn card should not be moved into a dyn deck", dynamicDeck.getLrnCount(), is(0));
assertThat("A learn card should not be moved into a dyn deck", dynamicDeck.getNewCount(), is(0));
assertThat("A learn card should not be moved into a dyn deck", dynamicDeck.getRevCount(), is(0));
}
use of com.ichi2.libanki.sched.Sched in project Anki-Android by ankidroid.
the class SchedV2Test method test_ordcycleV2.
@Test
public void test_ordcycleV2() throws Exception {
Collection col = getColV2();
// 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();
advanceRobolectricLooperWithSleep();
// not upstream. But we are not expecting multiple getCard without review
sched.answerCard(c, sched.answerButtons(c) - 1);
assertEquals(0, c.getOrd());
c = sched.getCard();
advanceRobolectricLooperWithSleep();
// not upstream. But we are not expecting multiple getCard without review
sched.answerCard(c, sched.answerButtons(c) - 1);
assertEquals(1, c.getOrd());
c = sched.getCard();
advanceRobolectricLooperWithSleep();
// not upstream. But we are not expecting multiple getCard without review
sched.answerCard(c, sched.answerButtons(c) - 1);
advanceRobolectricLooperWithSleep();
assertEquals(2, c.getOrd());
}
Aggregations