<lambda>null1package leakcanary.tests 2 3 import androidx.test.ext.junit.rules.ActivityScenarioRule 4 import com.example.leakcanary.MainActivity 5 import leakcanary.DetectLeaksAfterTestSuccess 6 import org.junit.Rule 7 import org.junit.Test 8 import org.junit.rules.RuleChain 9 10 /** 11 * This UI test looks like it should succeed, but it will actually fail because 12 * it triggers a leak. 13 * 14 * Run this test with: 15 * 16 * ./gradlew leakcanary-android-sample:connectedCheck 17 * 18 * Why is this class named "TuPeuxPasTest"? 19 * 20 * This test fails, intentionally. In French, "Tu peux pas test" could mean "you cannot test" 21 * written with poor grammar. Except, that's not what it means. 22 * If you're curious, interested in French and have time to waste: 23 * https://www.youtube.com/watch?v=DZZpbmAc-0A 24 * https://www.youtube.com/watch?v=nHeAA6X-XUQ 25 */ 26 class TuPeuxPasTest { 27 28 private val activityRule = ActivityScenarioRule(MainActivity::class.java) 29 30 @get:Rule 31 val rules = RuleChain.outerRule(DetectLeaksAfterTestSuccess()).around(activityRule)!! 32 33 @Test 34 fun activityLeakingAfterTest() { 35 activityRule.scenario.onActivity { activity -> 36 leakedObjects += activity 37 } 38 } 39 40 companion object { 41 val leakedObjects = mutableListOf<Any>() 42 } 43 } 44