Search in sources :

Example 71 with DUE

use of com.ichi2.anki.CardBrowser.Column.DUE in project AnkiChinaAndroid by ankichinateam.

the class SchedV2Test method test_learn_collapsedV2.

@Test
public void test_learn_collapsedV2() throws Exception {
    Collection col = getColV2();
    // add 2 notes
    Note note = col.newNote();
    note.setItem("Front", "1");
    col.addNote(note);
    note = col.newNote();
    note.setItem("Front", "2");
    col.addNote(note);
    // set as a learn card and rebuild queues
    col.getDb().execute("update cards set queue=0, type=0");
    col.reset();
    // should get '1' first
    Card c = col.getSched().getCard();
    assertTrue(c.q().endsWith("1"));
    // pass it so it's due in 10 minutes
    col.getSched().answerCard(c, 3);
    // get the other card
    c = col.getSched().getCard();
    assertTrue(c.q().endsWith("2"));
    // fail it so it's due in 1 minute
    col.getSched().answerCard(c, 1);
    // we shouldn't get the same card again
    c = col.getSched().getCard();
    assertFalse(c.q().endsWith("2"));
}
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)

Example 72 with DUE

use of com.ichi2.anki.CardBrowser.Column.DUE in project AnkiChinaAndroid by ankichinateam.

the class SchedTest method test_button_spacingV1.

@Test
public void test_button_spacingV1() throws Exception {
    Collection col = getColV1();
    Note note = col.newNote();
    note.setItem("Front", "one");
    col.addNote(note);
    // 1 day ivl review card due now
    Card c = note.cards().get(0);
    c.setType(CARD_TYPE_REV);
    c.setQueue(QUEUE_TYPE_REV);
    c.setDue(col.getSched().getToday());
    c.setReps(1);
    c.setIvl(1);
    c.startTimer();
    c.flush();
    col.reset();
    // Upstream, there is no space in 2d
    assertEquals("2 d", without_unicode_isolation(col.getSched().nextIvlStr(getTargetContext(), c, 2)));
    assertEquals("3 d", without_unicode_isolation(col.getSched().nextIvlStr(getTargetContext(), c, 3)));
    assertEquals("4 d", without_unicode_isolation(col.getSched().nextIvlStr(getTargetContext(), c, 4)));
}
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)

Example 73 with DUE

use of com.ichi2.anki.CardBrowser.Column.DUE in project AnkiChinaAndroid by ankichinateam.

the class SchedTest method test_finishedV1.

@Test
public void test_finishedV1() throws Exception {
    Collection col = getColV1();
    // nothing due
    assertThat(col.getSched().finishedMsg(getTargetContext()).toString(), containsString("Congratulations"));
    assertThat(col.getSched().finishedMsg(getTargetContext()).toString(), not(containsString("limit")));
    Note note = col.newNote();
    note.setItem("Front", "one");
    note.setItem("Back", "two");
    col.addNote(note);
    // have a new card
    assertThat(col.getSched().finishedMsg(getTargetContext()).toString(), containsString("new cards available"));
    // turn it into a review
    col.reset();
    Card c = note.cards().get(0);
    c.startTimer();
    col.getSched().answerCard(c, 3);
    // nothing should be due tomorrow, as it's due in a week
    assertThat(col.getSched().finishedMsg(getTargetContext()).toString(), containsString("Congratulations"));
    assertThat(col.getSched().finishedMsg(getTargetContext()).toString(), not(containsString("limit")));
}
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)

Example 74 with DUE

use of com.ichi2.anki.CardBrowser.Column.DUE in project Anki-Android by ankidroid.

the class CardBrowserTest method resetDataTest.

@Test
@Config(qualifiers = "en")
public void resetDataTest() {
    Card c = addNoteUsingBasicModel("Hello", "World").firstCard();
    c.setDue(5);
    c.setQueue(Consts.QUEUE_TYPE_REV);
    c.setType(Consts.CARD_TYPE_REV);
    c.flush();
    CardBrowser b = getBrowserWithNoNewCards();
    b.checkCardsAtPositions(0);
    CardBrowser.CardCache card = getCheckedCard(b);
    assertThat("Initial due of checked card", card.getColumnHeaderText(CardBrowser.Column.DUE), is("8/12/20"));
    b.resetProgressNoConfirm(Collections.singletonList(card.getId()));
    advanceRobolectricLooperWithSleep();
    assertThat("Position of checked card after reset", card.getColumnHeaderText(CardBrowser.Column.DUE), is("1"));
}
Also used : Card(com.ichi2.libanki.Card) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 75 with DUE

use of com.ichi2.anki.CardBrowser.Column.DUE in project Anki-Android by ankidroid.

the class SchedV2Test method test_moveVersions.

@Test
public void test_moveVersions() throws Exception {
    Collection col = getColV2();
    col.changeSchedulerVer(1);
    Note n = col.newNote();
    n.setItem("Front", "one");
    col.addNote(n);
    // make it a learning card
    col.reset();
    Card c = getCard();
    col.getSched().answerCard(c, BUTTON_ONE);
    // the move to v2 should reset it to new
    col.changeSchedulerVer(2);
    c.load();
    assertEquals(QUEUE_TYPE_NEW, c.getQueue());
    assertEquals(CARD_TYPE_NEW, c.getType());
    // fail it again, and manually bury it
    col.reset();
    c = getCard();
    col.getSched().answerCard(c, BUTTON_ONE);
    col.getSched().buryCards(new long[] { c.getId() });
    c.load();
    assertEquals(QUEUE_TYPE_MANUALLY_BURIED, c.getQueue());
    // revert to version 1
    col.changeSchedulerVer(1);
    // card should have moved queues
    c.load();
    assertEquals(QUEUE_TYPE_SIBLING_BURIED, c.getQueue());
    // and it should be new again when unburied
    col.getSched().unburyCards();
    c.load();
    assertEquals(CARD_TYPE_NEW, c.getQueue());
    assertEquals(QUEUE_TYPE_NEW, c.getType());
    // make sure relearning cards transition correctly to v1
    col.changeSchedulerVer(2);
    // card with 100 day interval, answering again
    col.getSched().reschedCards(Collections.singletonList(c.getId()), 100, 100);
    c.load();
    c.setDue(0);
    c.flush();
    DeckConfig conf = col.getSched()._cardConf(c);
    conf.getJSONObject("lapse").put("mult", 0.5);
    col.getDecks().save(conf);
    col.reset();
    c = getCard();
    col.getSched().answerCard(c, BUTTON_ONE);
    c.load();
    assertEquals(50, c.getIvl());
    // due should be correctly set when removed from learning early
    col.changeSchedulerVer(1);
    c.load();
    assertEquals(QUEUE_TYPE_REV, c.getQueue());
    assertEquals(CARD_TYPE_REV, c.getType());
    assertEquals(50, c.getDue());
}
Also used : Note(com.ichi2.libanki.Note) Collection(com.ichi2.libanki.Collection) DeckConfig(com.ichi2.libanki.DeckConfig) Card(com.ichi2.libanki.Card) RobolectricTest(com.ichi2.anki.RobolectricTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)58 Collection (com.ichi2.libanki.Collection)57 Card (com.ichi2.libanki.Card)55 Note (com.ichi2.libanki.Note)52 RobolectricTest (com.ichi2.anki.RobolectricTest)51 JSONObject (com.ichi2.utils.JSONObject)25 DeckConfig (com.ichi2.libanki.DeckConfig)20 JSONArray (com.ichi2.utils.JSONArray)16 ArrayList (java.util.ArrayList)16 Cursor (android.database.Cursor)14 Deck (com.ichi2.libanki.Deck)10 ContentResolver (android.content.ContentResolver)6 ContentValues (android.content.ContentValues)6 Uri (android.net.Uri)6 IOException (java.io.IOException)6 HashMap (java.util.HashMap)6 SuppressLint (android.annotation.SuppressLint)5 FileNotFoundException (java.io.FileNotFoundException)5 Activity (android.app.Activity)4 WebView (android.webkit.WebView)4