From 8a627f258e2a20436fe5b7a6e0133ada215f3d0c Mon Sep 17 00:00:00 2001 From: Anna Koehler Date: Thu, 11 Jul 2024 18:07:16 +0200 Subject: [PATCH] [driver] Add KDoc about correct usage of waitForProjectOpen and waitForIndicators GitOrigin-RevId: fefc7acea0ac7b62f029120710d2c734f8781d58 --- .../src/com/intellij/driver/sdk/indicators.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/platform/remote-driver/test-sdk/src/com/intellij/driver/sdk/indicators.kt b/platform/remote-driver/test-sdk/src/com/intellij/driver/sdk/indicators.kt index 7f6bb1f60dc9..69691a6efa3d 100644 --- a/platform/remote-driver/test-sdk/src/com/intellij/driver/sdk/indicators.kt +++ b/platform/remote-driver/test-sdk/src/com/intellij/driver/sdk/indicators.kt @@ -20,20 +20,37 @@ fun Driver.areIndicatorsVisible(project: Project): Boolean { return getProgressIndicators(project).isNotEmpty() } +/** + * !!!ATTENTION!!! + * + * The only guarantee you have after this method is that reference to Project won't be null. + * The UI, Project View, services and everything else might not be yet initialized. + * Use [waitForIndicators] instead if you're not 100% sure otherwise you might get flaky test. + * Also, you can avoid calling this method before [waitForIndicators] since it also waits for open project. + */ fun Driver.waitForProjectOpen(timeout: Duration = 1.minutes) { waitFor("Project is opened", timeout) { isProjectOpened() } } +/** + * Method waits till project is opened and there are no indicators for 10 seconds. + */ fun Driver.waitForIndicators(project: Project, timeout: Duration) { waitForIndicators({ project }, timeout) } +/** + * Method waits till project is opened and there are no indicators for 10 seconds. + */ fun Driver.waitForIndicators(timeout: Duration) { waitForIndicators(::singleProject, timeout) } +/** + * Method waits till project is opened and there are no indicators for 10 seconds. + */ private fun Driver.waitForIndicators(projectGet: () -> Project, timeout: Duration) { var smartLongEnoughStart: Instant? = null