Search in sources :

Example 6 with Reviewer

use of com.ichi2.anki.Reviewer in project AnkiChinaAndroid by ankichinateam.

the class ReviewerTest method jsTime4ShouldBeBlankIfButtonUnavailable.

@Test
public void jsTime4ShouldBeBlankIfButtonUnavailable() {
    // #6623 - easy should be blank when displaying a card with 3 buttons (after displaying a review)
    Note firstNote = addNoteUsingBasicModel("Hello", "World");
    moveToReviewQueue(firstNote.firstCard());
    addNoteUsingBasicModel("Hello", "World2");
    Reviewer reviewer = startReviewer();
    JavaScriptFunction javaScriptFunction = reviewer.javaScriptFunction();
    // The answer needs to be displayed to be able to get the time.
    displayAnswer(reviewer);
    assertThat("4 buttons should be displayed", reviewer.getAnswerButtonCount(), is(4));
    String nextTime = javaScriptFunction.ankiGetNextTime4();
    assertThat(nextTime, not(isEmptyString()));
    // Display the next answer
    reviewer.answerCard(EASE_4);
    displayAnswer(reviewer);
    if (schedVersion == 1) {
        assertThat("The 4th button should not be visible", reviewer.getAnswerButtonCount(), is(3));
        String learnTime = javaScriptFunction.ankiGetNextTime4();
        assertThat("If the 4th button is not visible, there should be no time4 in JS", learnTime, isEmptyString());
    }
}
Also used : Note(com.ichi2.libanki.Note) JavaScriptFunction(com.ichi2.anki.AbstractFlashcardViewer.JavaScriptFunction) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) Test(org.junit.Test)

Example 7 with Reviewer

use of com.ichi2.anki.Reviewer in project AnkiChinaAndroid by ankichinateam.

the class ReviewerTest method baseDeckName.

@Test
public void baseDeckName() {
    Collection col = getCol();
    Models models = col.getModels();
    Decks decks = col.getDecks();
    Long didAb = decks.id("A::B");
    Model basic = models.byName(AnkiDroidApp.getAppResources().getString(R.string.basic_model_name));
    basic.put("did", didAb);
    addNoteUsingBasicModel("foo", "bar");
    Long didA = decks.id("A");
    decks.select(didA);
    Reviewer reviewer = startReviewer();
    waitForAsyncTasksToComplete();
    assertThat(reviewer.getSupportActionBar().getTitle(), is("B"));
}
Also used : Decks(com.ichi2.libanki.Decks) Model(com.ichi2.libanki.Model) Collection(com.ichi2.libanki.Collection) Models(com.ichi2.libanki.Models) Test(org.junit.Test)

Example 8 with Reviewer

use of com.ichi2.anki.Reviewer in project AnkiChinaAndroid by ankichinateam.

the class ReviewerTest method startReviewer.

private <T extends Reviewer> T startReviewer(Class<T> clazz) {
    T reviewer = super.startActivityNormallyOpenCollectionWithIntent(clazz, new Intent());
    waitForAsyncTasksToComplete();
    return reviewer;
}
Also used : RESULT_DEFAULT(com.ichi2.anki.AbstractFlashcardViewer.RESULT_DEFAULT) Intent(android.content.Intent)

Example 9 with Reviewer

use of com.ichi2.anki.Reviewer in project AnkiChinaAndroid by ankichinateam.

the class ReviewerTest method assertCounts.

private void assertCounts(Reviewer r, int newCount, int stepCount, int revCount) {
    List<String> countList = new ArrayList<>();
    JavaScriptFunction jsApi = r.javaScriptFunction();
    countList.add(jsApi.ankiGetNewCardCount());
    countList.add(jsApi.ankiGetLrnCardCount());
    countList.add(jsApi.ankiGetRevCardCount());
    List<Integer> expexted = new ArrayList<>();
    expexted.add(newCount);
    expexted.add(stepCount);
    expexted.add(revCount);
    // We use toString as hamcrest does not print the whole array and stops at [0].
    assertThat(countList.toString(), is(expexted.toString()));
}
Also used : JavaScriptFunction(com.ichi2.anki.AbstractFlashcardViewer.JavaScriptFunction) ArrayList(java.util.ArrayList) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString)

Example 10 with Reviewer

use of com.ichi2.anki.Reviewer in project Anki-Android by ankidroid.

the class SchedV2 method currentCardIsInQueueWithDeck.

protected boolean currentCardIsInQueueWithDeck(@Consts.CARD_QUEUE int queue, long did) {
    // mCurrentCard may be set to null when the reviewer gets closed. So we copy it to be sure to avoid NullPointerException
    Card currentCard = mCurrentCard;
    List<Long> currentCardParentsDid = mCurrentCardParentsDid;
    return currentCard != null && currentCard.getQueue() == queue && currentCardParentsDid != null && currentCardParentsDid.contains(did);
}
Also used : Card(com.ichi2.libanki.Card)

Aggregations

Test (org.junit.Test)11 Collection (com.ichi2.libanki.Collection)10 Card (com.ichi2.libanki.Card)8 JSONObject (com.ichi2.utils.JSONObject)5 Intent (android.content.Intent)4 NonNull (androidx.annotation.NonNull)4 Nullable (androidx.annotation.Nullable)4 Model (com.ichi2.libanki.Model)4 Note (com.ichi2.libanki.Note)4 JSONArray (com.ichi2.utils.JSONArray)4 Resources (android.content.res.Resources)3 View (android.view.View)3 WindowManager (android.view.WindowManager)3 VisibleForTesting (androidx.annotation.VisibleForTesting)3 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)3 TaskData (com.ichi2.async.TaskData)3 ArrayList (java.util.ArrayList)3 Context (android.content.Context)2 SharedPreferences (android.content.SharedPreferences)2 Uri (android.net.Uri)2