Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generify deck selection dialog, for use in Statistics #15248

Merged

Conversation

david-allison
Copy link
Member

@david-allison david-allison commented Jan 17, 2024

Purpose / Description

Fixes

Approach

  • Refactor
  • Switch AnkiActivity for AppCompatActivity
  • migrate some methods to withCol and the initialisation methods to accept a col

How Has This Been Tested?

Unit tests + physical test on API 33 emulator: add a note + Card Browser - switching decks

Testing found issues with calling initializeActionBarDeckSpinner inside a task, I added a @MainThread annotation and added an explicit col parameter to resolve this

Learning (optional, can help others)

  • initializeActionBarDeckSpinner

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

fromCollection - kotlin cleanup
allDeckIds/deckNames - kotlin cleanup
AnkiActivity was not necessary

This is in preparation for adding the control to Statistics

Issue 15247
This makes it possible to use DeckSpinnerSelection inside `Statistics`

Issue 15247
@BrayanDSO BrayanDSO added Needs Second Approval Has one approval, one more approval to merge and removed Needs Review labels Jan 29, 2024
Copy link
Member

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mikehardy mikehardy closed this Jan 31, 2024
@mikehardy mikehardy reopened this Jan 31, 2024
@mikehardy mikehardy added Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) and removed Needs Second Approval Has one approval, one more approval to merge labels Jan 31, 2024
@mikehardy mikehardy added this pull request to the merge queue Jan 31, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 31, 2024
@mikehardy
Copy link
Member

These tests are really flaky


ReviewerTest > testLrnQueueAfterUndo FAILED
    java.lang.AssertionError: 
    Expected: "2"
         but: was "1"
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
        at com.ichi2.anki.RobolectricTest.equalFirstField(RobolectricTest.kt:402)
        at com.ichi2.anki.ReviewerTest$testLrnQueueAfterUndo$1.invokeSuspend(ReviewerTest.kt:170)
        at com.ichi2.anki.ReviewerTest$testLrnQueueAfterUndo$1.invoke(ReviewerTest.kt)
        at com.ichi2.anki.ReviewerTest$testLrnQueueAfterUndo$1.invoke(ReviewerTest.kt)
        at com.ichi2.testutils.TestClass$runTest$1$1.invokeSuspend(TestClass.kt:220)
        at com.ichi2.testutils.TestClass$runTest$1$1.invoke(TestClass.kt)
        at com.ichi2.testutils.TestClass$runTest$1$1.invoke(TestClass.kt)
        at kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt$runTest$2$1$1.invokeSuspend(TestBuilders.kt:314)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
        at kotlinx.coroutines.test.TestDispatcher.processEvent$kotlinx_coroutines_test(TestDispatcher.kt:28)
        at kotlinx.coroutines.test.TestCoroutineScheduler.tryRunNextTaskUnless$kotlinx_coroutines_test(TestCoroutineScheduler.kt:103)
        at kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt$runTest$2$1$workRunner$1.invokeSuspend(TestBuilders.kt:320)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
        at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:280)
        at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
        at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
        at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
        at kotlinx.coroutines.test.TestBuildersJvmKt.createTestResult(TestBuildersJvm.kt:13)
        at kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt.runTest-8Mi8wO0(TestBuilders.kt:308)
        at kotlinx.coroutines.test.TestBuildersKt.runTest-8Mi8wO0(Unknown Source)
        at kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt.runTest-8Mi8wO0(TestBuilders.kt:166)
        at kotlinx.coroutines.test.TestBuildersKt.runTest-8Mi8wO0(Unknown Source)
        at com.ichi2.testutils.TestClass.runTest(TestClass.kt:218)
        at com.ichi2.testutils.TestClass.runTest$default(TestClass.kt:209)
        at com.ichi2.anki.ReviewerTest.testLrnQueueAfterUndo(ReviewerTest.kt:150)

ReviewerNoParamTest > drawerConflictsIfDown SKIPPED

ReviewerTest > testMultipleCards FAILED
    java.lang.AssertionError: Unexpected card ord
    Expected: <2>
         but: was <1>
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
        at com.ichi2.anki.ReviewerTest.assertCurrentOrdIs(ReviewerTest.kt:325)
        at com.ichi2.anki.ReviewerTest.answerCardOrdinalAsGood(ReviewerTest.kt:314)
        at com.ichi2.anki.ReviewerTest.access$answerCardOrdinalAsGood(ReviewerTest.kt:51)
        at com.ichi2.anki.ReviewerTest$testMultipleCards$1.invokeSuspend(ReviewerTest.kt:[137](https://github.com/ankidroid/Anki-Android/actions/runs/7725942907/job/21061230031#step:8:138))
        at com.ichi2.anki.ReviewerTest$testMultipleCards$1.invoke(ReviewerTest.kt)
        at com.ichi2.anki.ReviewerTest$testMultipleCards$1.invoke(ReviewerTest.kt)
        at com.ichi2.testutils.TestClass$runTest$1$1.invokeSuspend(TestClass.kt:220)
        at com.ichi2.testutils.TestClass$runTest$1$1.invoke(TestClass.kt)
        at com.ichi2.testutils.TestClass$runTest$1$1.invoke(TestClass.kt)
        at kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt$runTest$2$1$1.invokeSuspend(TestBuilders.kt:314)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
        at kotlinx.coroutines.test.TestDispatcher.processEvent$kotlinx_coroutines_test(TestDispatcher.kt:28)
        at kotlinx.coroutines.test.TestCoroutineScheduler.tryRunNextTaskUnless$kotlinx_coroutines_test(TestCoroutineScheduler.kt:103)
        at kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt$runTest$2$1$workRunner$1.invokeSuspend(TestBuilders.kt:320)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
        at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:280)
        at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
        at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
        at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
        at kotlinx.coroutines.test.TestBuildersJvmKt.createTestResult(TestBuildersJvm.kt:13)
        at kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt.runTest-8Mi8wO0(TestBuilders.kt:308)
        at kotlinx.coroutines.test.TestBuildersKt.runTest-8Mi8wO0(Unknown Source)
        at kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt.runTest-8Mi8wO0(TestBuilders.kt:[166](https://github.com/ankidroid/Anki-Android/actions/runs/7725942907/job/21061230031#step:8:167))
        at kotlinx.coroutines.test.TestBuildersKt.runTest-8Mi8wO0(Unknown Source)
        at com.ichi2.testutils.TestClass.runTest(TestClass.kt:218)
        at com.ichi2.testutils.TestClass.runTest$default(TestClass.kt:209)
        at com.ichi2.anki.ReviewerTest.testMultipleCards(ReviewerTest.kt:121)

@mikehardy mikehardy added this pull request to the merge queue Jan 31, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 31, 2024
@mikehardy mikehardy added this pull request to the merge queue Jan 31, 2024
Merged via the queue into ankidroid:main with commit fe3487d Jan 31, 2024
17 checks passed
@github-actions github-actions bot added this to the 2.17 release milestone Jan 31, 2024
@github-actions github-actions bot removed the Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) label Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants