@@ -20,6 +20,7 @@ import androidx.benchmark.macro.StartupMode
20
20
import androidx.benchmark.macro.StartupTimingMetric
21
21
import androidx.benchmark.macro.junit4.MacrobenchmarkRule
22
22
import androidx.test.ext.junit.runners.AndroidJUnit4
23
+ import androidx.test.platform.app.InstrumentationRegistry
23
24
import org.junit.Rule
24
25
import org.junit.Test
25
26
import org.junit.runner.RunWith
@@ -31,12 +32,32 @@ class StartupBenchmark {
31
32
@Test
32
33
fun startup () =
33
34
benchmarkRule.measureRepeated(
34
- packageName = " com.google.firebase.testing.sessions " ,
35
+ packageName = PACKAGE_NAME ,
35
36
metrics = listOf (StartupTimingMetric ()),
36
37
iterations = 5 ,
37
38
startupMode = StartupMode .COLD ,
38
39
) {
39
40
pressHome()
40
41
startActivityAndWait()
41
42
}
43
+
44
+ @Test
45
+ fun startup_clearAppData () =
46
+ benchmarkRule.measureRepeated(
47
+ packageName = PACKAGE_NAME ,
48
+ metrics = listOf (StartupTimingMetric ()),
49
+ iterations = 5 ,
50
+ startupMode = StartupMode .COLD ,
51
+ ) {
52
+ pressHome()
53
+ InstrumentationRegistry .getInstrumentation()
54
+ .uiAutomation
55
+ .executeShellCommand(" pm clear $PACKAGE_NAME " )
56
+ .close()
57
+ startActivityAndWait()
58
+ }
59
+
60
+ private companion object {
61
+ const val PACKAGE_NAME = " com.google.firebase.testing.sessions"
62
+ }
42
63
}
0 commit comments