0
0
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:
Shridhar Goel 2021-06-02 09:32:34 +05:30 committed by GitHub
parent d0d1eddf60
commit 1bdd80e9b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View File

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

View File

@ -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);