use of com.ichi2.anki.CardBrowser in project Anki-Android by ankidroid.
the class CardBrowserTest method checkSearchString.
/**
* 8027
*/
@Test
public void checkSearchString() {
addNoteUsingBasicModel("Hello", "John");
long deck = addDeck("Deck 1");
getCol().getDecks().select(deck);
Card c2 = addNoteUsingBasicModel("New", "world").firstCard();
c2.setDid(deck);
c2.flush();
CardBrowser cardBrowser = getBrowserWithNoNewCards();
cardBrowser.searchCards("world or hello");
advanceRobolectricLooperWithSleep();
assertThat("Cardbrowser has Deck 1 as selected deck", cardBrowser.getSelectedDeckNameForUi(), is("Deck 1"));
assertThat("Results should only be from the selected deck", cardBrowser.getCardCount(), is(1));
}
use of com.ichi2.anki.CardBrowser 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"));
}
use of com.ichi2.anki.CardBrowser in project Anki-Android by ankidroid.
the class CardBrowserTest method flagValueIsShownOnCard.
@Test
public void flagValueIsShownOnCard() {
Note n = addNoteUsingBasicModel("1", "back");
flagCardForNote(n, 1);
long cardId = n.cids().get(0);
CardBrowser b = getBrowserWithNoNewCards();
int actualFlag = getCardFlagAfterFlagChangeDone(b, cardId);
assertThat("The card flag value should be reflected in the UI", actualFlag, is(1));
}
use of com.ichi2.anki.CardBrowser in project Anki-Android by ankidroid.
the class CardBrowserTest method tagWithBracketsDisplaysProperly.
@Test
public void tagWithBracketsDisplaysProperly() {
Note n = addNoteUsingBasicModel("Hello", "World");
n.addTag("sketchy::(1)");
n.flush();
CardBrowser b = getBrowserWithNoNewCards();
b.filterByTag("sketchy::(1)");
advanceRobolectricLooperWithSleep();
assertThat("tagged card should be returned", b.getCardCount(), is(1));
}
use of com.ichi2.anki.CardBrowser in project Anki-Android by ankidroid.
the class CardBrowserTest method flagsAreShownInBigDecksTest.
@Test
public void flagsAreShownInBigDecksTest() {
int numberOfNotes = 75;
CardBrowser cardBrowser = getBrowserWithNotes(numberOfNotes);
// select a random card
Random random = new Random(1);
int cardPosition = random.nextInt(numberOfNotes);
assumeThat("card position to select is 60", cardPosition, is(60));
cardBrowser.checkCardsAtPositions(cardPosition);
assumeTrue("card at position 60 is selected", cardBrowser.hasCheckedCardAtPosition(cardPosition));
// flag the selected card with flag = 1
final int flag = 1;
cardBrowser.flagTask(flag);
advanceRobolectricLooperWithSleep();
// check if card flag turned to flag = 1
assertThat("Card should be flagged", getCheckedCard(cardBrowser).getCard().userFlag(), is(flag));
// unflag the selected card with flag = 0
final int unflagFlag = 0;
cardBrowser.flagTask(unflagFlag);
advanceRobolectricLooperWithSleep();
// check if card flag actually changed from flag = 1
assertThat("Card flag should be removed", getCheckedCard(cardBrowser).getCard().userFlag(), not(flag));
// deselect and select all cards
cardBrowser.onSelectNone();
cardBrowser.onSelectAll();
// flag all the cards with flag = 3
final int flagForAll = 3;
cardBrowser.flagTask(flagForAll);
advanceRobolectricLooperWithSleep();
// check if all card flags turned to flag = 3
assertThat("All cards should be flagged", stream(cardBrowser.getCardIds()).map(cardId -> getCardFlagAfterFlagChangeDone(cardBrowser, cardId)).noneMatch(flag1 -> flag1 != flagForAll));
}
Aggregations