diff options
-rw-r--r-- | tests/utils/safetycenter/java/com/android/safetycenter/testing/Coroutines.kt | 7 | ||||
-rw-r--r-- | tests/utils/safetycenter/java/com/android/safetycenter/testing/SafetyCenterFlags.kt | 5 |
2 files changed, 8 insertions, 4 deletions
diff --git a/tests/utils/safetycenter/java/com/android/safetycenter/testing/Coroutines.kt b/tests/utils/safetycenter/java/com/android/safetycenter/testing/Coroutines.kt index 6c6336da3..29d1c1f09 100644 --- a/tests/utils/safetycenter/java/com/android/safetycenter/testing/Coroutines.kt +++ b/tests/utils/safetycenter/java/com/android/safetycenter/testing/Coroutines.kt @@ -29,8 +29,11 @@ import kotlinx.coroutines.withTimeoutOrNull /** A class that facilitates interacting with coroutines. */ object Coroutines { - - private val TEST_TIMEOUT: Duration + /** + * The timeout of a test case, typically varies depending on whether the test is running + * locally, on pre-submit or post-submit. + */ + val TEST_TIMEOUT: Duration get() = Duration.ofMillis( InstrumentationRegistry.getArguments().getString("timeout_msec", "60000").toLong() diff --git a/tests/utils/safetycenter/java/com/android/safetycenter/testing/SafetyCenterFlags.kt b/tests/utils/safetycenter/java/com/android/safetycenter/testing/SafetyCenterFlags.kt index 46b7f5630..f7b5f486d 100644 --- a/tests/utils/safetycenter/java/com/android/safetycenter/testing/SafetyCenterFlags.kt +++ b/tests/utils/safetycenter/java/com/android/safetycenter/testing/SafetyCenterFlags.kt @@ -35,6 +35,7 @@ import android.safetycenter.SafetyCenterManager.REFRESH_REASON_PERIODIC import android.safetycenter.SafetyCenterManager.REFRESH_REASON_RESCAN_BUTTON_CLICK import android.safetycenter.SafetyCenterManager.REFRESH_REASON_SAFETY_CENTER_ENABLED import android.safetycenter.SafetySourceData +import com.android.safetycenter.testing.Coroutines.TEST_TIMEOUT import com.android.safetycenter.testing.Coroutines.TIMEOUT_LONG import com.android.safetycenter.testing.ShellPermissions.callWithShellPermissionIdentity import java.time.Duration @@ -117,7 +118,7 @@ object SafetyCenterFlags { * source to respond to a refresh request before timing out and marking the refresh as finished, * depending on the refresh reason. * - * Unlike the production code, this flag is set to [TIMEOUT_LONG] for all refresh reasons by + * Unlike the production code, this flag is set to [TEST_TIMEOUT] for all refresh reasons by * default for convenience. UI tests typically will set some data manually rather than going * through a full refresh, and we don't want to timeout the refresh and potentially end up with * error entries in this case (as it could lead to flakyness). @@ -125,7 +126,7 @@ object SafetyCenterFlags { private val refreshSourceTimeoutsFlag = Flag( "safety_center_refresh_sources_timeouts_millis", - defaultValue = getAllRefreshTimeoutsMap(TIMEOUT_LONG), + defaultValue = getAllRefreshTimeoutsMap(TEST_TIMEOUT), MapParser(IntParser(), DurationParser()) ) |