use of com.ichi2.anki.CardBrowser in project Anki-Android by ankidroid.
the class CardBrowserTest method canChangeDeckToRegularDeck.
@Test
public void canChangeDeckToRegularDeck() {
addDeck("Hello");
CardBrowser b = getBrowserWithNotes(5);
List<Deck> decks = b.getValidDecksForChangeDeck();
for (Deck d : decks) {
if (d.getString("name").equals("Hello")) {
return;
}
}
Assert.fail("Added deck was not found in the Card Browser");
}
use of com.ichi2.anki.CardBrowser in project Anki-Android by ankidroid.
the class CardBrowserTest method filterByFlagDisplaysProperly.
@Test
public void filterByFlagDisplaysProperly() {
Note cardWithRedFlag = addNoteUsingBasicModel("Card with red flag", "Reverse");
flagCardForNote(cardWithRedFlag, 1);
Note cardWithGreenFlag = addNoteUsingBasicModel("Card with green flag", "Reverse");
flagCardForNote(cardWithGreenFlag, 3);
Note anotherCardWithRedFlag = addNoteUsingBasicModel("Second card with red flag", "Reverse");
flagCardForNote(anotherCardWithRedFlag, 1);
CardBrowser b = getBrowserWithNoNewCards();
b.filterByFlag(1);
advanceRobolectricLooperWithSleep();
assertThat("Flagged cards should be returned", b.getCardCount(), is(2));
}
use of com.ichi2.anki.CardBrowser in project Anki-Android by ankidroid.
the class CardBrowserTest method changeDeckIntegrationTestDynamicAndNon.
@Test
public void changeDeckIntegrationTestDynamicAndNon() {
addDeck("Hello");
addDynamicDeck("World");
HashSet<String> validNames = new HashSet<>();
validNames.add("Default");
validNames.add("Hello");
CardBrowser b = getBrowserWithNotes(5);
List<Deck> decks = b.getValidDecksForChangeDeck();
for (Deck d : decks) {
assertThat(validNames, hasItem(d.getString("name")));
}
assertThat("Additional unexpected decks were present", decks.size(), is(2));
}
use of com.ichi2.anki.CardBrowser in project Anki-Android by ankidroid.
the class CardBrowserTest method cannotChangeDeckToDynamicDeck.
@Test
public void cannotChangeDeckToDynamicDeck() {
// 5932 - dynamic decks are meant to have cards added to them through "Rebuild".
addDynamicDeck("World");
CardBrowser b = getBrowserWithNotes(5);
List<Deck> decks = b.getValidDecksForChangeDeck();
for (Deck d : decks) {
if (d.getString("name").equals("World")) {
Assert.fail("Dynamic decks should not be transferred to by the browser.");
}
}
}
use of com.ichi2.anki.CardBrowser in project Anki-Android by Ramblurr.
the class CardBrowser method onActivityResult.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// FIXME:
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == DeckPicker.RESULT_DB_ERROR) {
closeCardBrowser(DeckPicker.RESULT_DB_ERROR);
}
// switching back to the multimedia card editor.
if (requestCode == EDIT_CARD && resultCode == MultimediaCardEditorActivity.RESULT_DELETED) {
deleteNote(sCardBrowserCard);
DeckTask.launchDeckTask(DeckTask.TASK_TYPE_DISMISS_NOTE, mDeleteNoteHandler, new DeckTask.TaskData(mCol.getSched(), sCardBrowserCard, 3));
} else if (requestCode == EDIT_CARD && resultCode != RESULT_CANCELED) {
// Log.i(AnkiDroidApp.TAG, "CardBrowser: Saving card...");
DeckTask.launchDeckTask(DeckTask.TASK_TYPE_UPDATE_FACT, mUpdateCardHandler, new DeckTask.TaskData(mCol.getSched(), sCardBrowserCard, false));
} else if (requestCode == ADD_NOTE && resultCode == RESULT_OK) {
mSearchTerms = mSearchEditText.getText().toString().toLowerCase();
searchCards();
}
}
Aggregations