From e18f0be3149347b79ced76583c76108d8aaedc06 Mon Sep 17 00:00:00 2001 From: "Anastasia.Katsman" Date: Wed, 10 Sep 2025 12:31:44 +0200 Subject: [PATCH] [rdct-tests] do not throw error on modal window on test shudown, it does more harm than good GitOrigin-RevId: 129e248da31b1ef7ea3081f740c77ce7209ccf3b --- .../DistributedTestModel.Generated.kt | 10 +++++----- .../modelSources/DistributedTestModel.kt | 2 +- .../tests/impl/DistributedTestHost.kt | 18 ++++++++---------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/platform/remoteDev-util/modelGenerated/DistributedTestModel.Generated.kt b/platform/remoteDev-util/modelGenerated/DistributedTestModel.Generated.kt index 93ef5eba1804..c779a06ef2e0 100644 --- a/platform/remoteDev-util/modelGenerated/DistributedTestModel.Generated.kt +++ b/platform/remoteDev-util/modelGenerated/DistributedTestModel.Generated.kt @@ -61,7 +61,7 @@ class DistributedTestModel private constructor( private val __RdTestSessionNullableSerializer = RdTestSession.nullable() - const val serializationHash = -2661619799941496807L + const val serializationHash = -8976769733834761447L } override val serializersOwner: ISerializersOwner get() = DistributedTestModel @@ -662,7 +662,7 @@ class RdTestSession private constructor( private val _stopAllureStep: RdSignal, private val _exitApp: RdSignal, private val _showNotification: RdSignal, - private val _forceLeaveAllModals: RdCall, + private val _forceLeaveAllModals: RdCall, private val _closeAllOpenedProjects: RdCall, private val _runNextAction: RdCall, private val _requestFocus: RdCall, @@ -694,7 +694,7 @@ class RdTestSession private constructor( val _stopAllureStep = RdSignal.read(ctx, buffer, RdAllureStopStepInfo) val _exitApp = RdSignal.read(ctx, buffer, FrameworkMarshallers.Void) val _showNotification = RdSignal.read(ctx, buffer, FrameworkMarshallers.String) - val _forceLeaveAllModals = RdCall.read(ctx, buffer, FrameworkMarshallers.Bool, FrameworkMarshallers.Void) + val _forceLeaveAllModals = RdCall.read(ctx, buffer, FrameworkMarshallers.Void, FrameworkMarshallers.Bool) val _closeAllOpenedProjects = RdCall.read(ctx, buffer, FrameworkMarshallers.Void, FrameworkMarshallers.Bool) val _runNextAction = RdCall.read(ctx, buffer, RdTestActionParameters, __StringNullableSerializer) val _requestFocus = RdCall.read(ctx, buffer, FrameworkMarshallers.Bool, FrameworkMarshallers.Bool) @@ -747,7 +747,7 @@ class RdTestSession private constructor( val stopAllureStep: IAsyncSignal get() = _stopAllureStep val exitApp: IAsyncSignal get() = _exitApp val showNotification: ISignal get() = _showNotification - val forceLeaveAllModals: RdCall get() = _forceLeaveAllModals + val forceLeaveAllModals: RdCall get() = _forceLeaveAllModals val closeAllOpenedProjects: RdCall get() = _closeAllOpenedProjects val runNextAction: RdCall get() = _runNextAction val requestFocus: RdCall get() = _requestFocus @@ -822,7 +822,7 @@ class RdTestSession private constructor( RdSignal(RdAllureStopStepInfo), RdSignal(FrameworkMarshallers.Void), RdSignal(FrameworkMarshallers.String), - RdCall(FrameworkMarshallers.Bool, FrameworkMarshallers.Void), + RdCall(FrameworkMarshallers.Void, FrameworkMarshallers.Bool), RdCall(FrameworkMarshallers.Void, FrameworkMarshallers.Bool), RdCall(RdTestActionParameters, __StringNullableSerializer), RdCall(FrameworkMarshallers.Bool, FrameworkMarshallers.Bool), diff --git a/platform/remoteDev-util/modelSources/DistributedTestModel.kt b/platform/remoteDev-util/modelSources/DistributedTestModel.kt index bbfe9492c3e7..24001cd68b56 100644 --- a/platform/remoteDev-util/modelSources/DistributedTestModel.kt +++ b/platform/remoteDev-util/modelSources/DistributedTestModel.kt @@ -93,7 +93,7 @@ object DistributedTestModel : Ext(TestRoot) { signal("stopAllureStep", RdAllureStopStepInfo).async signal("exitApp", void).async signal("showNotification", string) - call("forceLeaveAllModals", bool, void).async + call("forceLeaveAllModals", void, bool).async call("closeAllOpenedProjects", void, bool).async call("runNextAction", RdTestActionParameters, string.nullable).async call("requestFocus", bool, bool).async diff --git a/platform/remoteDev-util/src/com/intellij/remoteDev/tests/impl/DistributedTestHost.kt b/platform/remoteDev-util/src/com/intellij/remoteDev/tests/impl/DistributedTestHost.kt index 1e4da1b37aa7..9b4368e1a284 100644 --- a/platform/remoteDev-util/src/com/intellij/remoteDev/tests/impl/DistributedTestHost.kt +++ b/platform/remoteDev-util/src/com/intellij/remoteDev/tests/impl/DistributedTestHost.kt @@ -266,35 +266,33 @@ open class DistributedTestHost(coroutineScope: CoroutineScope) { } } - suspend fun leaveAllModals(throwErrorIfModal: Boolean) { + suspend fun makeSureNoModals(): Boolean = withContext(Dispatchers.EDT + ModalityState.any().asContextElement() + NonCancellable) { repeat(10) { if (ModalityState.current() == ModalityState.nonModal()) { - return@withContext + return@withContext true } delay(1.seconds) } - if (throwErrorIfModal) { - LOG.error("Unexpected modality: " + ModalityState.current()) - } + LOG.warn("Unexpected modality: " + ModalityState.current()) LaterInvocator.forceLeaveAllModals("DistributedTestHost - leaveAllModals") repeat(10) { if (ModalityState.current() == ModalityState.nonModal()) { - return@withContext + return@withContext true } delay(1.seconds) } LOG.error("Failed to close modal dialog: " + ModalityState.current()) + return@withContext false } - } - session.forceLeaveAllModals.setSuspend(sessionBgtDispatcher) { _, throwErrorIfModal -> - leaveAllModals(throwErrorIfModal) + session.forceLeaveAllModals.setSuspend(sessionBgtDispatcher) { _, _ -> + makeSureNoModals() } session.closeAllOpenedProjects.setSuspend(sessionBgtDispatcher) { _, _ -> try { - leaveAllModals(throwErrorIfModal = true) + makeSureNoModals() ProjectManagerEx.getOpenProjects().forEach { waitProjectInitialisedOrDisposed(it) } withContext(Dispatchers.EDT + NonCancellable) {