Search in sources :

Example 6 with SchedV2

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;
}
Also used : AbstractSched(com.ichi2.libanki.sched.AbstractSched) Sched(com.ichi2.libanki.sched.Sched) SuppressLint(android.annotation.SuppressLint) SchedV2(com.ichi2.libanki.sched.SchedV2)

Example 7 with SchedV2

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));
}
Also used : SchedV2(com.ichi2.libanki.sched.SchedV2) RobolectricTest(com.ichi2.anki.RobolectricTest) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 8 with SchedV2

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;
}
Also used : AbstractSched(com.ichi2.libanki.sched.AbstractSched) AbstractSched(com.ichi2.libanki.sched.AbstractSched) Sched(com.ichi2.libanki.sched.Sched) SchedV2(com.ichi2.libanki.sched.SchedV2)

Example 9 with SchedV2

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));
}
Also used : SchedV2(com.ichi2.libanki.sched.SchedV2) RobolectricTest(com.ichi2.anki.RobolectricTest) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 10 with SchedV2

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));
}
Also used : Note(com.ichi2.libanki.Note) Collection(com.ichi2.libanki.Collection) Card(com.ichi2.libanki.Card) RobolectricTest(com.ichi2.anki.RobolectricTest) Test(org.junit.Test)

Aggregations

RobolectricTest (com.ichi2.anki.RobolectricTest)7 SchedV2 (com.ichi2.libanki.sched.SchedV2)7 Test (org.junit.Test)7 Card (com.ichi2.libanki.Card)5 Collection (com.ichi2.libanki.Collection)5 SuppressLint (android.annotation.SuppressLint)4 Note (com.ichi2.libanki.Note)4 AbstractSched (com.ichi2.libanki.sched.AbstractSched)3 Sched (com.ichi2.libanki.sched.Sched)3 DeckConfig (com.ichi2.libanki.DeckConfig)2 JSONArray (com.ichi2.utils.JSONArray)2 JSONObject (com.ichi2.utils.JSONObject)2 Config (org.robolectric.annotation.Config)2 Time (com.ichi2.libanki.utils.Time)1