mirror of
https://github.com/ankidroid/Anki-Android.git
synced 2024-09-20 03:52:15 +02:00
Fix for empty search results and wrong card count (#8998)
* Fix for empty search results and wrong card count * Add test
This commit is contained in:
parent
d0d1eddf60
commit
1bdd80e9b1
@ -855,7 +855,9 @@ public class CardBrowser extends NavigationDrawerActivity implements
|
||||
@VisibleForTesting
|
||||
void selectAllDecks() {
|
||||
mDeckSpinnerSelection.selectDropDownItem(0);
|
||||
saveLastDeckId(Stats.ALL_DECKS_ID);
|
||||
mRestrictOnDeck = "";
|
||||
saveLastDeckId(ALL_DECKS_ID);
|
||||
searchCards();
|
||||
}
|
||||
|
||||
|
||||
|
@ -572,6 +572,26 @@ public class CardBrowserTest extends RobolectricTest {
|
||||
assertThat(browser.checkedCardCount(), is(18));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkIfSearchAllDecksWorks() {
|
||||
addNoteUsingBasicModel("Hello", "World");
|
||||
long deck = addDeck("Test Deck");
|
||||
getCol().getDecks().select(deck);
|
||||
Card c2 = addNoteUsingBasicModel("Front", "Back").firstCard();
|
||||
c2.setDid(deck);
|
||||
c2.flush();
|
||||
|
||||
CardBrowser cardBrowser = getBrowserWithNoNewCards();
|
||||
cardBrowser.searchCards("Hello");
|
||||
advanceRobolectricLooperWithSleep();
|
||||
assertThat("Card browser should have Test Deck as the selected deck", cardBrowser.getSelectedDeckNameForUi(), is("Test Deck"));
|
||||
assertThat("Result should be empty", cardBrowser.getCardCount(), is(0));
|
||||
|
||||
cardBrowser.searchAllDecks();
|
||||
advanceRobolectricLooperWithSleep();
|
||||
assertThat("Result should contain one card", cardBrowser.getCardCount(), is(1));
|
||||
}
|
||||
|
||||
protected void assertUndoDoesNotContain(CardBrowser browser, @StringRes int resId) {
|
||||
ShadowActivity shadowActivity = shadowOf(browser);
|
||||
MenuItem item = shadowActivity.getOptionsMenu().findItem(R.id.action_undo);
|
||||
|
Loading…
Reference in New Issue
Block a user