Compare commits

..
Author SHA1 Message Date
JMR-dev a0b6a3dde8 Merge branch 'main' into fix/probe-dispatcher-seam 2026-08-25 00:11:12 -05:00
Jason Ross ba27b8306b Merge pull request #91 from JMR-dev/test/media3engine-mime-tables
Check the MIME types Media3Engine hands Transformer, and the claim above them
2026-08-25 00:10:51 -05:00
JMR-devandClaude Opus 5 2063fe06aa Point the coroutines-test comments at the file that still uses it
Both the dependency declaration and its catalog entry named
EscapedCoroutineErrors.kt as the sole reason kotlinx-coroutines-test is on the
test classpath. That file is gone, and nothing in the gate -- not ktlint, not
detekt, not lint -- fails on prose naming a deleted file, so this would have
survived as a reference a reader could only resolve through git history.

The dependency itself stays, and for a reason worth restating where it is
declared: `runTest` is what registers the collector callback, so the one test
that deliberately lets an error escape is the scope that receives it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-24 23:17:14 -05:00
JMR-devandClaude Opus 5 4aba3bbd2e Stop swallowing coroutine errors nobody asserted on
`drainEscapedCoroutineErrors()` cleared the collector at rule-construction time
with `runCatching { runTest {} }`, and discarding what it found was the whole
mechanism: it could not tell the one known deposit from an escaped error nobody
had asserted on. That traded a loud, misleading failure for a silent one, which
was acceptable only while exactly one depositor existed and the seam to remove it
did not.

The seam exists now, so the depositor is gone: the OOM is consumed by the test
that raises it. Every Compose class takes the v2 `createComposeRule()` directly,
and a future escaped error fails a test again instead of disappearing.

The two findings the drain's KDoc carried that outlive it: the v2 rule and the
non-v2 `StateRestorationTester` do interoperate -- the note now sits at the two
declarations that pair them -- and a drain could never have been a `@Before`
(the rule's `runTest` wraps it) or a `@BeforeClass` (Robolectric runs that
outside the sandbox classloader, where the collector is a different object).

Full JVM suite run twice in a row with the drain deleted: 373 tests, 0 failures
both times.

Closes #66

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-24 23:10:04 -05:00
JMR-devandClaude Opus 5 dbba213c51 Give the pick a dispatcher, so an escaped error fails the test that caused it
`onInputPicked` hops to a hard-coded `Dispatchers.IO` inside a `launch` with no
exception handler -- deliberate, because a real OutOfMemoryError should reach the
thread's default handler and take the process down. On the JVM there is no such
handler: kotlinx-coroutines-test installs a process-wide collector, once per
classloader and never removed, which keeps the error and rethrows it at whichever
`runTest` starts next. Every Compose rule is a `runTest`, so the OOM raised by
`ConversionViewModelProbeFailureTest` failed some *other* Compose class, and which
one moved between runs of identical, green code.

Naming the dispatcher gives the throw somewhere to land. With the pick inline
inside a `runTest`, the collector's callback belongs to the test that caused the
error, so it is handed over and consumed rather than stored for a stranger.

Both hops of a pick rather than only the probe, which is where this differs from
the seam issue #66 sketched: leaving the metadata query on a real IO thread makes
the coroutine resume on a main looper Robolectric leaves paused, and that bounce
is exactly the asynchrony that made delivery unpredictable.

That buys the assertion the test could not make before -- the real OutOfMemoryError
instance, not an inference from a card that never filled in, which is also what a
probe returning null looks like. Reverting the hop to `Dispatchers.IO` turns it
red: "expected java.lang.OutOfMemoryError to be thrown, but nothing was thrown".

Refs #66

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-24 23:07:38 -05:00
16 changed files with 84 additions and 116 deletions
+3 -3
View File
@@ -333,9 +333,9 @@ dependencies {
// the tests stay green.
testImplementation(platform(libs.compose.bom))
testImplementation(libs.compose.ui.test.junit4)
// For `runTest` alone, in EscapedCoroutineErrors.kt. It arrives transitively with the
// rule above anyway; declared because a test file imports it directly, and an import of
// something nobody asked for breaks the day the library that pulled it in stops.
// For `runTest` alone, in ConversionViewModelProbeFailureTest. It arrives transitively
// with the rule above anyway; declared because a test file imports it directly, and an
// import of something nobody asked for breaks the day the library that pulled it in stops.
testImplementation(libs.kotlinx.coroutines.test)
androidTestImplementation(platform(libs.compose.bom))
@@ -120,6 +120,29 @@ class ConversionViewModel @JvmOverloads constructor(
* the first screen.
*/
private val cleanupDispatcher: CoroutineDispatcher = Dispatchers.IO,
/**
* Where the two blocking hops behind a pick run — the metadata query and the probe.
*
* A seam for the probe above all, because that is the one call in this class that throws
* on purpose. [probeOrUnreadable] rethrows anything that is not a native load failure, and
* the `launch` it runs in has no exception handler by design: on a device the error reaches
* the thread's default handler and takes the process down, which is what an
* [OutOfMemoryError] should do.
*
* On the JVM there is no such handler. kotlinx-coroutines-test installs a process-wide
* collector, once and for the life of the classloader, that keeps an escaped error and
* hands it to whichever `runTest` starts next — so it failed a Compose test class that had
* nothing to do with it, and *which* class moved between runs of identical code. Naming the
* dispatcher is what lets a test keep the throw inside its own window, where it fails the
* test that caused it and is consumed rather than collected.
*
* Both hops rather than the probe alone, which is where this differs from the seam issue #66
* proposed: leaving the metadata query on a real [Dispatchers.IO] makes the coroutine resume
* on a main looper that Robolectric leaves paused, and that bounce is precisely the
* asynchrony that made delivery unpredictable. One dispatcher covers a whole pick, and
* leaves nothing about it to timing.
*/
private val pickDispatcher: CoroutineDispatcher = Dispatchers.IO,
) : AndroidViewModel(app) {
private val workManager = WorkManager.getInstance(app)
@@ -241,13 +264,13 @@ class ConversionViewModel @JvmOverloads constructor(
viewModelScope.launch {
// Both the metadata query and the probe touch disk, and the probe spawns FFprobe.
// Neither belongs on the main thread.
val file = withContext(Dispatchers.IO) { InputQuery.describe(getApplication(), uri) }
val file = withContext(pickDispatcher) { InputQuery.describe(getApplication(), uri) }
// Show the file as soon as its name and size are known. Probing now runs FFprobe on
// every pick, which is a native process spawn, and making the whole screen wait on it
// would read as the app having ignored the tap.
_state.value = ConversionState.Ready(file)
val probe = withContext(Dispatchers.IO) { probeOrUnreadable(uri) }
val probe = withContext(pickDispatcher) { probeOrUnreadable(uri) }
// Only fill in the probe if the user has not moved on in the meantime.
_state.update { current ->
if (current is ConversionState.Ready && current.input.uri == uri) {
@@ -8,6 +8,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.assertIsSelected
import androidx.compose.ui.test.junit4.StateRestorationTester
import androidx.compose.ui.test.junit4.v2.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
@@ -44,11 +45,11 @@ import org.robolectric.RobolectricTestRunner
@RunWith(RobolectricTestRunner::class)
class AppRootRestorationTest {
// Not `createComposeRule()` directly: see [drainEscapedCoroutineErrors]. Every Compose test
// class in this source set starts there, whether or not it is the one that happens to be
// running when another test's escaped coroutine error is delivered.
// The rule is the **v2** one (`androidx.compose.ui.test.junit4.v2`) while
// [StateRestorationTester], which takes it below, is not. The mismatched imports are
// deliberate: the v2 package has no tester of its own and the two do interoperate.
@get:Rule
val composeRule = createDrainedComposeRule()
val composeRule = createComposeRule()
private val restoration = StateRestorationTester(composeRule)
@@ -1,53 +0,0 @@
package org.libremediaconverter
import androidx.compose.ui.test.junit4.v2.createComposeRule
import kotlinx.coroutines.test.runTest
/**
* Clears coroutine errors this module's tests deliberately let escape, so they land on the test
* that caused them instead of on the next one to start.
*
* **Every Compose test class in `src/test` has to start here.** `createComposeRule` runs the
* composition inside `runTest`, and `runTest` opens by throwing `UncaughtExceptionsBeforeTest` for
* anything already sitting in kotlinx-coroutines-test's collector -- a process-wide
* `CoroutineExceptionHandler` it installs once and never removes.
*
* There is one deposit into that collector here, and it is not a mistake:
* `ConversionViewModelProbeFailureTest.an OutOfMemoryError is not swallowed` proves an OOM raised
* inside the probe is rethrown rather than reported as an unreadable file. `onInputPicked` runs it
* in `viewModelScope.launch`, which has no exception handler by design -- the ViewModel's own KDoc
* says a real OOM should reach the thread's handler and take the process down. On the JVM the
* collector takes it instead, holds it, and hands it to whichever `runTest` starts next.
*
* It surfaced as two *different* Compose test classes failing on two consecutive runs of the same,
* green, code, with a message naming neither the test nor the error's origin. Which class catches
* it moves because the throw happens on a real `Dispatchers.IO` thread, after the state assertion
* that ends the test that caused it -- so it can be delivered long after that class is done.
*
* A `@Before` method cannot do this: the compose rule's `runTest` wraps the statement that calls
* `@Before`, so it has already thrown. `@BeforeClass` cannot either -- Robolectric runs it outside
* the sandbox classloader, where the collector is a different object. Draining while the rule is
* being *constructed* is early enough, because JUnit builds a fresh test-class instance, and with
* it every `@get:Rule` field, before evaluating any rule.
*
* The real fix is a seam: give the probe hop an injectable dispatcher the way
* `ConversionViewModel`'s constructor already does for `cleanupDispatcher`, and the error would
* have somewhere to land. That is a production change, so it belongs in its own commit.
*/
fun drainEscapedCoroutineErrors() {
// Entering a test scope is what flushes the collector; the flush is reported as this
// throwing, and there is nothing to assert about an error another test already asserted on.
runCatching { runTest {} }
}
/**
* [createComposeRule], with [drainEscapedCoroutineErrors] run first. Use this rather than
* `createComposeRule` directly in `src/test`.
*
* It also keeps the one mixed import in one place: the rule comes from the **v2** package
* (`androidx.compose.ui.test.junit4.v2`) while `StateRestorationTester`, which takes it, does not.
*/
fun createDrainedComposeRule() = run {
drainEscapedCoroutineErrors()
createComposeRule()
}
@@ -7,6 +7,7 @@ import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.saveable.LocalSaveableStateRegistry
import androidx.compose.runtime.saveable.SaveableStateRegistry
import androidx.compose.ui.test.junit4.v2.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
import androidx.media3.common.util.UnstableApi
@@ -15,7 +16,6 @@ import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.libremediaconverter.createDrainedComposeRule
import org.libremediaconverter.model.AudioCodec
import org.libremediaconverter.model.Container
import org.libremediaconverter.model.OutputSpec
@@ -57,9 +57,8 @@ import org.robolectric.RobolectricTestRunner
@RunWith(RobolectricTestRunner::class)
class AdvancedPanelSavedStateTest {
// Not `createComposeRule()` directly: see [drainEscapedCoroutineErrors].
@get:Rule
val composeRule = createDrainedComposeRule()
val composeRule = createComposeRule()
/**
* `canBeSaved = { true }` deliberately.
@@ -6,6 +6,7 @@ import androidx.compose.ui.test.hasAnyAncestor
import androidx.compose.ui.test.hasTestTag
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.junit4.StateRestorationTester
import androidx.compose.ui.test.junit4.v2.createComposeRule
import androidx.compose.ui.test.onAllNodesWithTag
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
@@ -16,7 +17,6 @@ import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.libremediaconverter.createDrainedComposeRule
import org.libremediaconverter.model.AudioCodec
import org.libremediaconverter.model.Container
import org.libremediaconverter.model.ContainerCapabilities
@@ -61,9 +61,11 @@ import org.robolectric.RobolectricTestRunner
@RunWith(RobolectricTestRunner::class)
class AdvancedPickerTest {
// Not `createComposeRule()` directly: see [drainEscapedCoroutineErrors].
// The rule is the **v2** one (`androidx.compose.ui.test.junit4.v2`) while
// [StateRestorationTester], which takes it below, is not. The mismatched imports are
// deliberate: the v2 package has no tester of its own and the two do interoperate.
@get:Rule
val composeRule = createDrainedComposeRule()
val composeRule = createComposeRule()
private val restoration = StateRestorationTester(composeRule)
@@ -2,14 +2,15 @@ package org.libremediaconverter.convert
import android.app.Application
import android.net.Uri
import android.os.Looper
import androidx.media3.common.util.UnstableApi
import androidx.work.workDataOf
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.test.runTest
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertThrows
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -18,8 +19,6 @@ import org.libremediaconverter.model.InputProbe
import org.libremediaconverter.work.ConversionWorker
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.Shadows.shadowOf
import java.util.concurrent.TimeUnit
/**
* That a probe which throws leaves a screen the user can act on, not a dead coroutine.
@@ -87,19 +86,35 @@ class ConversionViewModelProbeFailureTest {
* is out of memory" into "this video looks unreadable" and let the app carry on in a
* state it cannot honour — which is the regression a blanket `catch (Throwable)` would
* have introduced, and the reason this defect was left open rather than fixed carelessly.
*
* **The error itself is what is asserted here, and that is what the `pickDispatcher` seam
* bought.** With the hop hard-coded to `Dispatchers.IO` this was impossible: the throw
* happened on a pool thread some time after this method had returned, so all a test could do
* was infer it from a card that never filled in — which is also what a probe returning null
* would look like. Worse, the escaped error went into kotlinx-coroutines-test's process-wide
* collector and was rethrown at whichever `runTest` started next, which is a *different*
* Compose class between runs of identical code. Putting the pick on [Dispatchers.Unconfined]
* runs it inline, inside a `runTest` whose scope owns the collector's callback: the error is
* handed to this test and consumed, rather than stored for a stranger.
*
* Note where it surfaces — at the end of `runTest`, not inside `onInputPicked`. `launch`
* gives an escaped error to the handler chain and never to its caller, so nothing can catch
* it at the call itself. This is as close as the coroutine machinery allows, and unlike the
* old assertion it is the real [OutOfMemoryError] instance.
*/
@Test
fun `an OutOfMemoryError is not swallowed`() {
ConversionDependencies.probe = { _, _ -> throw OutOfMemoryError("Failed to allocate 512 MB") }
// Unconfined for the pick, so the whole of onInputPicked runs inline on this thread and
// has thrown before runTest can leave the scope that has to receive the error.
val viewModel = ConversionViewModel(app, Dispatchers.Unconfined, Dispatchers.Unconfined)
val viewModel = ConversionViewModel(app, Dispatchers.Unconfined)
viewModel.onInputPicked(INPUT)
val escaped = assertThrows(OutOfMemoryError::class.java) { runTest { viewModel.onInputPicked(INPUT) } }
// The observable difference, and the reason this is asserted on state rather than on a
// caught throwable: the probe hop is on Dispatchers.IO, so an error that escapes lands
// on that thread's handler rather than at this call. What must not happen is the card
// filling in with an "unreadable" verdict the app would then act on.
val settled = settle(viewModel)
assertEquals("Failed to allocate 512 MB", escaped.message)
// The other half of the contract, unchanged: an OOM is about the process, so the card is
// left as it was rather than filled in with a verdict the app would then act on.
val settled = viewModel.state.value
// `sizeBytes = null`, not `0L`: no provider is registered for this authority, so the
// metadata query returns nothing and the descriptor cannot be opened either. That is the
// unknown, and it stopped being spelled the same way as "empty" -- see [InputQuery].
@@ -132,23 +147,7 @@ class ConversionViewModelProbeFailureTest {
return (ready as ConversionState.Ready).input.probe
}
/**
* Pumps the looper the way [awaitState] does, but for a fixed span and without requiring
* anything to happen — here "the pick never came back" is the expected outcome, so there
* is no predicate to wait on.
*/
private fun settle(viewModel: ConversionViewModel): ConversionState {
val deadline = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(SETTLE_MS)
while (System.nanoTime() < deadline) {
shadowOf(Looper.getMainLooper()).idle()
Thread.sleep(POLL_MS)
}
return viewModel.state.value
}
private companion object {
val INPUT: Uri = Uri.parse("content://test/holiday.mp4")
const val SETTLE_MS = 500L
const val POLL_MS = 5L
}
}
@@ -2,6 +2,7 @@ package org.libremediaconverter.convert
import android.net.Uri
import androidx.compose.ui.test.assertCountEquals
import androidx.compose.ui.test.junit4.v2.createComposeRule
import androidx.compose.ui.test.onAllNodesWithTag
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
@@ -9,7 +10,6 @@ import androidx.media3.common.util.UnstableApi
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.libremediaconverter.createDrainedComposeRule
import org.libremediaconverter.model.AudioCodec
import org.libremediaconverter.model.Container
import org.libremediaconverter.model.EnginePreference
@@ -47,7 +47,7 @@ import org.robolectric.RobolectricTestRunner
class ConverterLeafTagsTest {
@get:Rule
val composeRule = createDrainedComposeRule()
val composeRule = createComposeRule()
private fun assertResolvesToOneNode(tag: String) {
composeRule.onAllNodesWithTag(tag).assertCountEquals(1)
@@ -6,6 +6,7 @@ import androidx.compose.ui.test.assertIsSelected
import androidx.compose.ui.test.hasAnyAncestor
import androidx.compose.ui.test.hasTestTag
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.junit4.v2.createComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.media3.common.util.UnstableApi
@@ -13,7 +14,6 @@ import org.junit.Assert.assertEquals
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.libremediaconverter.createDrainedComposeRule
import org.libremediaconverter.model.EnginePreference
import org.libremediaconverter.model.OutputFormat
import org.libremediaconverter.model.QualityTier
@@ -48,7 +48,7 @@ import org.robolectric.RobolectricTestRunner
class ConverterPickerSelectionTest {
@get:Rule
val composeRule = createDrainedComposeRule()
val composeRule = createComposeRule()
/**
* The chip carrying [label] inside the row tagged [rowTag].
@@ -1,6 +1,7 @@
package org.libremediaconverter.convert
import android.net.Uri
import androidx.compose.ui.test.junit4.v2.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performScrollTo
@@ -9,7 +10,6 @@ import org.junit.Assert.assertEquals
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.libremediaconverter.createDrainedComposeRule
import org.libremediaconverter.model.Validation
import org.libremediaconverter.ui.TestTags
import org.robolectric.RobolectricTestRunner
@@ -39,9 +39,8 @@ import java.io.File
@RunWith(RobolectricTestRunner::class)
class ConverterScreenContentTest {
// Not `createComposeRule()` directly: see [org.libremediaconverter.drainEscapedCoroutineErrors].
@get:Rule
val composeRule = createDrainedComposeRule()
val composeRule = createComposeRule()
/** What the screen asked to save, in the order it asked. Empty until Save is tapped. */
private val savedAs = mutableListOf<String>()
@@ -6,6 +6,7 @@ import androidx.compose.ui.test.assertIsEnabled
import androidx.compose.ui.test.assertIsNotEnabled
import androidx.compose.ui.test.assertRangeInfoEquals
import androidx.compose.ui.test.assertTextEquals
import androidx.compose.ui.test.junit4.v2.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
@@ -15,7 +16,6 @@ import org.junit.Assert.assertEquals
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.libremediaconverter.createDrainedComposeRule
import org.libremediaconverter.model.AudioCodec
import org.libremediaconverter.model.Container
import org.libremediaconverter.model.OutputSpec
@@ -72,9 +72,8 @@ import java.io.File
@RunWith(RobolectricTestRunner::class)
class ConverterStateAffordancesTest {
// Not `createComposeRule()` directly: see [org.libremediaconverter.drainEscapedCoroutineErrors].
@get:Rule
val composeRule = createDrainedComposeRule()
val composeRule = createComposeRule()
/**
* Every callback the screen fired, in order, tagged with the value it carried.
@@ -3,13 +3,13 @@ package org.libremediaconverter.convert
import android.net.Uri
import androidx.compose.ui.test.assertCountEquals
import androidx.compose.ui.test.assertTextEquals
import androidx.compose.ui.test.junit4.v2.createComposeRule
import androidx.compose.ui.test.onChildren
import androidx.compose.ui.test.onNodeWithTag
import androidx.media3.common.util.UnstableApi
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.libremediaconverter.createDrainedComposeRule
import org.libremediaconverter.model.AudioCodec
import org.libremediaconverter.model.Container
import org.libremediaconverter.model.InputKind
@@ -56,7 +56,7 @@ import org.robolectric.RobolectricTestRunner
class FileCardTest {
@get:Rule
val composeRule = createDrainedComposeRule()
val composeRule = createComposeRule()
@Test
fun `a file no provider could measure says so in words rather than showing a zero`() {
@@ -2,13 +2,13 @@ package org.libremediaconverter.join
import android.net.Uri
import androidx.compose.ui.test.assertCountEquals
import androidx.compose.ui.test.junit4.v2.createComposeRule
import androidx.compose.ui.test.onAllNodesWithTag
import androidx.media3.common.util.UnstableApi
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.libremediaconverter.convert.InputFile
import org.libremediaconverter.createDrainedComposeRule
import org.libremediaconverter.ui.TestTags
import org.robolectric.RobolectricTestRunner
@@ -32,7 +32,7 @@ import org.robolectric.RobolectricTestRunner
class JoinLeafTagsTest {
@get:Rule
val composeRule = createDrainedComposeRule()
val composeRule = createComposeRule()
private fun input(displayName: String) = InputFile(
uri = Uri.parse("content://test/$displayName"),
@@ -1,5 +1,6 @@
package org.libremediaconverter.join
import androidx.compose.ui.test.junit4.v2.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performScrollTo
@@ -8,7 +9,6 @@ import org.junit.Assert.assertEquals
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.libremediaconverter.createDrainedComposeRule
import org.libremediaconverter.model.ConcatStrategy
import org.libremediaconverter.ui.TestTags
import org.robolectric.RobolectricTestRunner
@@ -35,9 +35,8 @@ import java.io.File
@RunWith(RobolectricTestRunner::class)
class JoinScreenContentTest {
// Not `createComposeRule()` directly: see [org.libremediaconverter.drainEscapedCoroutineErrors].
@get:Rule
val composeRule = createDrainedComposeRule()
val composeRule = createComposeRule()
/** What the screen asked to save, in the order it asked. Empty until Save is tapped. */
private val savedAs = mutableListOf<String>()
@@ -7,6 +7,7 @@ import androidx.compose.ui.semantics.getOrNull
import androidx.compose.ui.test.SemanticsMatcher
import androidx.compose.ui.test.assertRangeInfoEquals
import androidx.compose.ui.test.assertTextEquals
import androidx.compose.ui.test.junit4.v2.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
@@ -17,7 +18,6 @@ import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.libremediaconverter.convert.InputFile
import org.libremediaconverter.createDrainedComposeRule
import org.libremediaconverter.model.ConcatStrategy
import org.libremediaconverter.ui.TestTags
import org.robolectric.RobolectricTestRunner
@@ -60,9 +60,8 @@ import java.io.File
@RunWith(RobolectricTestRunner::class)
class JoinStateAffordancesTest {
// Not `createComposeRule()` directly: see [org.libremediaconverter.drainEscapedCoroutineErrors].
@get:Rule
val composeRule = createDrainedComposeRule()
val composeRule = createComposeRule()
/** Which callback the screen invoked, in order, with what it passed. Empty until one fires. */
private val events = mutableListOf<String>()
+3 -2
View File
@@ -162,8 +162,9 @@ androidx-uiautomator = { group = "androidx.test.uiautomator", name = "uiautomato
# a TDD loop anyone here can execute.
robolectric = { group = "org.robolectric", name = "robolectric", version.ref = "robolectric" }
# Only for its `runTest`, and only to drain the collector kotlinx-coroutines-test installs
# process-wide. See EscapedCoroutineErrors.kt in the JVM test source set.
# Only for its `runTest`, and only so the one test that deliberately lets a coroutine error
# escape owns the collector callback while it does -- otherwise the error is kept process-wide
# and rethrown at whichever `runTest` starts next. See ConversionViewModelProbeFailureTest.
kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "coroutinesTest" }
[plugins]