From c5b2185119650224933681b1bcf9ce461001a5ae Mon Sep 17 00:00:00 2001 From: Michael Comella Date: Tue, 7 Sep 2021 10:18:06 -0700 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/21138: change EXPECTED_RUNBLOCKING to range. Compared with my local runs, CI sees +1 runBlockingIncrement calls so seems to take other code paths. As such, we search for a range of rather than a single value. The main downside I can think of is this could make the test trickier to debug but we can wait and see if that's a problem in practice before taking action on it. --- .../mozilla/fenix/perf/StartupExcessiveResourceUseTest.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/perf/StartupExcessiveResourceUseTest.kt b/app/src/androidTest/java/org/mozilla/fenix/perf/StartupExcessiveResourceUseTest.kt index 65f23a811a..7746e867d9 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/perf/StartupExcessiveResourceUseTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/perf/StartupExcessiveResourceUseTest.kt @@ -14,6 +14,7 @@ import androidx.recyclerview.widget.RecyclerView import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.UiDevice import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue import org.junit.Rule import org.junit.Test import org.mozilla.fenix.R @@ -22,7 +23,8 @@ import org.mozilla.fenix.helpers.HomeActivityTestRule // BEFORE INCREASING THESE VALUES, PLEASE CONSULT WITH THE PERF TEAM. private const val EXPECTED_SUPPRESSION_COUNT = 19 -private const val EXPECTED_RUNBLOCKING_COUNT = 0 +@Suppress("TopLevelPropertyNaming") // it's silly this would have a different naming convention b/c no const +private val EXPECTED_RUNBLOCKING_RANGE = 0..1 // CI has +1 counts compared to local runs: increment these together private const val EXPECTED_COMPONENT_INIT_COUNT = 50 private const val EXPECTED_VIEW_HIERARCHY_DEPTH = 12 private const val EXPECTED_RECYCLER_VIEW_CONSTRAINT_LAYOUT_CHILDREN = 4 @@ -100,7 +102,7 @@ class StartupExcessiveResourceUseTest { val actualNumberOfInflations = InflationCounter.inflationCount.get() assertEquals(failureMsgStrictMode, EXPECTED_SUPPRESSION_COUNT, actualSuppresionCount) - assertEquals(failureMsgRunBlocking, EXPECTED_RUNBLOCKING_COUNT, actualRunBlocking) + assertTrue(failureMsgRunBlocking + "actual: $actualRunBlocking", actualRunBlocking in EXPECTED_RUNBLOCKING_RANGE) assertEquals(failureMsgComponentInit, EXPECTED_COMPONENT_INIT_COUNT, actualComponentInitCount) assertEquals(failureMsgViewHierarchyDepth, EXPECTED_VIEW_HIERARCHY_DEPTH, actualViewHierarchyDepth) assertEquals(