From 8e59d346b5ff2a019e3c5dc29f93cd3e2d367855 Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Fri, 10 Nov 2017 14:38:15 +0300 Subject: [PATCH] try to fix BlackListMethodIntentionTest failures on build server make the test more reliable - test only terminal state, after all transient operations are complete --- .../completion/CompletionHintsTest.java | 7 +++--- .../daemon/inlays/IntentionTest.kt | 24 ++++--------------- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/completion/CompletionHintsTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/completion/CompletionHintsTest.java index 3013e12e2a6b..0c13d0e2966c 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/completion/CompletionHintsTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/completion/CompletionHintsTest.java @@ -14,6 +14,7 @@ import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.LookupElementPresentation; import com.intellij.ide.highlighter.JavaFileType; import com.intellij.openapi.actionSystem.IdeActions; +import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.ex.EditorSettingsExternalizable; import com.intellij.psi.JavaCodeFragmentFactory; import com.intellij.psi.PsiExpressionCodeFragment; @@ -859,9 +860,9 @@ public class CompletionHintsTest extends LightFixtureCompletionTestCase { selectItem(element); } - private void waitTillAnimationCompletes() { + public static void waitTillAnimationCompletes(Editor editor) { long deadline = System.currentTimeMillis() + 60_000; - while (ParameterHintsPresentationManager.getInstance().isAnimationInProgress(getEditor())) { + while (ParameterHintsPresentationManager.getInstance().isAnimationInProgress(editor)) { if (System.currentTimeMillis() > deadline) fail("Too long waiting for animation to finish"); LockSupport.parkNanos(10_000_000); UIUtil.dispatchAllInvocationEvents(); @@ -875,7 +876,7 @@ public class CompletionHintsTest extends LightFixtureCompletionTestCase { private void waitForAllAsyncStuff() throws TimeoutException { waitForParameterInfoUpdate(); myFixture.doHighlighting(); - waitTillAnimationCompletes(); + waitTillAnimationCompletes(getEditor()); waitForAutoPopup(); } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/inlays/IntentionTest.kt b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/inlays/IntentionTest.kt index 581438a2e180..cc8dfdc8ae40 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/inlays/IntentionTest.kt +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/inlays/IntentionTest.kt @@ -1,22 +1,8 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.java.codeInsight.daemon.inlays -import com.intellij.codeInsight.daemon.impl.ParameterHintsPresentationManager import com.intellij.codeInsight.hints.settings.ParameterNameHintsSettings +import com.intellij.java.codeInsight.completion.CompletionHintsTest import com.intellij.openapi.editor.ex.EditorSettingsExternalizable import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase import org.assertj.core.api.Assertions.assertThat @@ -81,12 +67,10 @@ class ParamHintsTest { val intention = myFixture.getAvailableIntention("Do not show hints for current method") myFixture.launchAction(intention!!) myFixture.doHighlighting() + CompletionHintsTest.waitTillAnimationCompletes(editor) val after = editor.inlayModel.getInlineElementsInRange(caretOffset, caretOffset) - assertThat(after).hasSize(1) - - val text = ParameterHintsPresentationManager.getInstance().getHintText(after[0]) - assertThat(text).isNull() + assertThat(after).isEmpty() } } \ No newline at end of file