use of com.ichi2.libanki.sched.SchedV2 in project Anki-Android by ankidroid.
the class AbstractSchedTest method regression_7984.
@Test
public void regression_7984() {
Collection col = getCol();
SchedV2 sched = (SchedV2) col.getSched();
Time time = getCol().getTime();
Card[] cards = new Card[2];
for (int i = 0; i < 2; i++) {
cards[i] = addNoteUsingBasicModel(Integer.toString(i), "").cards().get(0);
cards[i].setQueue(Consts.QUEUE_TYPE_LRN);
cards[i].setType(Consts.CARD_TYPE_LRN);
cards[i].setDue(time.intTime() - 20 * 60 + i);
cards[i].flush();
}
col.reset();
// Regression test success non deterministically without the sleep
Card gotten = sched.getCard();
advanceRobolectricLooperWithSleep();
assertThat(gotten, is(cards[0]));
sched.answerCard(gotten, Consts.BUTTON_ONE);
gotten = sched.getCard();
assertThat(gotten, is(cards[1]));
sched.answerCard(gotten, Consts.BUTTON_ONE);
gotten = sched.getCard();
assertThat(gotten, is(cards[0]));
}
use of com.ichi2.libanki.sched.SchedV2 in project Anki-Android by ankidroid.
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