Skip to content

Instantly share code, notes, and snippets.

@LethalMaus
Created May 7, 2026 19:50
Show Gist options
  • Select an option

  • Save LethalMaus/9396753e4fe7846c7e8cf3553c3984ee to your computer and use it in GitHub Desktop.

Select an option

Save LethalMaus/9396753e4fe7846c7e8cf3553c3984ee to your computer and use it in GitHub Desktop.
Dejavu minimal rule fix for article
package dejavu
import androidx.activity.ComponentActivity
import androidx.compose.ui.test.junit4.ComposeContentTestRule
import androidx.compose.ui.test.junit4.ComposeTestRule
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.test.ext.junit.rules.ActivityScenarioRule
import org.junit.runner.Description
import org.junit.runners.model.Statement
public class DejavuComposeTestRule<A : ComponentActivity>(
private val delegate: AndroidComposeTestRule<ActivityScenarioRule<A>, A>
) : ComposeContentTestRule by delegate {
public val activity: A get() = delegate.activity
override fun apply(base: Statement, description: Description): Statement {
return delegate.apply(object : Statement() {
override fun evaluate() {
Dejavu.enable(delegate.activity.application)
dejavu.internal.Runtime.setActiveActivity(delegate.activity)
delegate.waitForIdle()
DejavuTest.resetCounts()
base.evaluate()
}
}, description)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment