use of com.ichi2.libanki.sched.SchedV2 in project Anki-Android by ankidroid.
the class Collection method createScheduler.
// This duplicates _loadScheduler (but returns the value and sets the report limit).
public AbstractSched createScheduler(int reportLimit) {
int ver = schedVer();
if (ver == 1) {
mSched = new Sched(this);
} else if (ver == 2) {
mSched = new SchedV2(this);
}
mSched.setReportLimit(reportLimit);
return mSched;
}
use of com.ichi2.libanki.sched.SchedV2 in project Anki-Android by ankidroid.
the class FinderTest method searchForBuriedReturnsManuallyAndSiblingBuried.
@Test
@Config(qualifiers = "en")
public void searchForBuriedReturnsManuallyAndSiblingBuried() throws ConfirmModSchemaException {
final String searchQuery = "is:buried";
// needs to be first
SchedV2 sched = upgradeToSchedV2();
enableBurySiblings();
super.addNoteUsingModelName("Basic (and reversed card)", "Front", "Back");
Card toAnswer = sched.getCard();
// act
Card siblingBuried = burySiblings(sched, toAnswer);
Card manuallyBuriedCard = buryManually(sched, toAnswer.getId());
// perform the search
List<Long> buriedCards = new Finder(getCol()).findCards(searchQuery, new SortOrder.NoOrdering());
// assert
assertThat("A manually buried card should be returned", buriedCards, hasItem(manuallyBuriedCard.getId()));
assertThat("A sibling buried card should be returned", buriedCards, hasItem(siblingBuried.getId()));
assertThat("sibling and manually buried should be the only cards returned", buriedCards, hasSize(2));
}
use of com.ichi2.libanki.sched.SchedV2 in project AnkiChinaAndroid by ankichinateam.
the class RobolectricTest method upgradeToSchedV2.
protected SchedV2 upgradeToSchedV2() {
getCol().getConf().put("schedVer", 2);
getCol().setMod();
CollectionHelper.getInstance().closeCollection(true, "upgradeToSchedV2");
AbstractSched sched = getCol().getSched();
// Sched inherits from schedv2...
assertThat("sched should be v2", !(sched instanceof Sched));
return (SchedV2) sched;
}
use of com.ichi2.libanki.sched.SchedV2 in project AnkiChinaAndroid by ankichinateam.
the class FinderTest method searchForBuriedReturnsManuallyAndSiblingBuried.
@Test
@Config(qualifiers = "en")
public void searchForBuriedReturnsManuallyAndSiblingBuried() {
final String searchQuery = "is:buried";
// needs to be first
SchedV2 sched = upgradeToSchedV2();
enableBurySiblings();
super.addNoteUsingModelName("Basic (and reversed card)", "Front", "Back");
Card toAnswer = sched.getCard();
// act
Card siblingBuried = burySiblings(sched, toAnswer);
Card manuallyBuriedCard = buryManually(sched, toAnswer.getId());
// perform the search
List<Long> buriedCards = new Finder(getCol()).findCards(searchQuery, false);
// assert
assertThat("A manually buried card should be returned", buriedCards, hasItem(manuallyBuriedCard.getId()));
assertThat("A sibling buried card should be returned", buriedCards, hasItem(siblingBuried.getId()));
assertThat("sibling and manually buried should be the only cards returned", buriedCards, hasSize(2));
}
use of com.ichi2.libanki.sched.SchedV2 in project AnkiChinaAndroid by ankichinateam.
the class AbstractSchedTest method testCardQueue.
@Test
public void testCardQueue() {
Collection col = getCol();
SchedV2 sched = (SchedV2) col.getSched();
SimpleCardQueue queue = new SimpleCardQueue(sched);
assertThat(queue.size(), is(0));
final int nbCard = 6;
long[] cids = new long[nbCard];
for (int i = 0; i < nbCard; i++) {
Note note = addNoteUsingBasicModel("foo", "bar");
Card card = note.firstCard();
long cid = card.getId();
cids[i] = cid;
queue.add(cid);
}
assertThat(queue.size(), is(nbCard));
assertEquals(cids[0], queue.removeFirstCard().getId());
assertThat(queue.size(), is(nbCard - 1));
queue.remove(cids[1]);
assertThat(queue.size(), is(nbCard - 2));
queue.remove(cids[3]);
assertThat(queue.size(), is(nbCard - 3));
assertEquals(cids[2], queue.removeFirstCard().getId());
assertThat(queue.size(), is(nbCard - 4));
assertEquals(cids[4], queue.removeFirstCard().getId());
assertThat(queue.size(), is(nbCard - 5));
}
Aggregations