Search in sources :

Example 41 with AbstractSched

use of com.ichi2.libanki.sched.AbstractSched in project Anki-Android by ankidroid.

the class AbstractSchedTest method regression_7066.

@Test
public void regression_7066() {
    Collection col = getCol();
    DeckConfig dconf = col.getDecks().getConf(1);
    dconf.getJSONObject("new").put("bury", true);
    AbstractSched sched = col.getSched();
    addNoteUsingBasicAndReversedModel("foo", "bar");
    addNoteUsingBasicModel("plop", "foo");
    col.reset();
    Card card = sched.getCard();
    sched.setCurrentCard(card);
    sched.preloadNextCard();
    sched.answerCard(card, Consts.BUTTON_THREE);
    card = sched.getCard();
    sched.setCurrentCard(card);
    AnkiAssert.assertDoesNotThrow(sched::preloadNextCard);
}
Also used : Collection(com.ichi2.libanki.Collection) DeckConfig(com.ichi2.libanki.DeckConfig) Card(com.ichi2.libanki.Card) RobolectricTest(com.ichi2.anki.RobolectricTest) Test(org.junit.Test)

Example 42 with AbstractSched

use of com.ichi2.libanki.sched.AbstractSched in project Anki-Android by ankidroid.

the class CollectionTask method nonTaskUndo.

@VisibleForTesting
public static Card nonTaskUndo(Collection col) {
    AbstractSched sched = col.getSched();
    Card card = col.undo();
    if (card == null) {
        /* multi-card action undone, no action to take here */
        Timber.d("Multi-select undo succeeded");
    } else {
        // cid is actually a card id.
        // a review was undone,
        /* card review undone, set up to review that card again */
        Timber.d("Single card review undo succeeded");
        card.startTimer();
        col.reset();
        sched.deferReset(card);
    }
    return card;
}
Also used : AbstractSched(com.ichi2.libanki.sched.AbstractSched) Card(com.ichi2.libanki.Card) VisibleForTesting(androidx.annotation.VisibleForTesting)

Aggregations

Card (com.ichi2.libanki.Card)28 Collection (com.ichi2.libanki.Collection)28 Test (org.junit.Test)23 AbstractSched (com.ichi2.libanki.sched.AbstractSched)19 RobolectricTest (com.ichi2.anki.RobolectricTest)18 Note (com.ichi2.libanki.Note)12 DeckConfig (com.ichi2.libanki.DeckConfig)9 JSONObject (com.ichi2.utils.JSONObject)9 Deck (com.ichi2.libanki.Deck)5 JSONArray (com.ichi2.utils.JSONArray)5 Cursor (android.database.Cursor)4 DB (com.ichi2.libanki.DB)4 Model (com.ichi2.libanki.Model)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 Models (com.ichi2.libanki.Models)3 Undoable (com.ichi2.libanki.Undoable)3 Sched (com.ichi2.libanki.sched.Sched)3 SchedV2 (com.ichi2.libanki.sched.SchedV2)3 JSONException (com.ichi2.utils.JSONException)3 SuppressLint (android.annotation.SuppressLint)2