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());
}
}
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"));
}
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;
}
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()));
}
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);
}
Aggregations