From 2aa42c15d53f546aa2c21385e79cab2d4a1e5259 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 19 Sep 2014 13:05:41 +0400 Subject: [PATCH] run startup activities in tests --- .../daemon/quickFix/OrderEntryTest.java | 5 ++++- .../navigation/GotoImplementationTest.java | 17 +++++++++++++++++ .../intellij/psi/search/UpdateCacheTest.java | 5 ++++- .../psi/impl/PsiDocumentManagerImplTest.java | 4 ++-- .../testFramework/LightPlatformTestCase.java | 4 +++- .../MavenNotManagedProjectInspectionsTest.java | 6 ++++-- 6 files changed, 34 insertions(+), 7 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/OrderEntryTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/OrderEntryTest.java index d2e17d81fc0f..12eaddc9e040 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/OrderEntryTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/OrderEntryTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -34,6 +34,7 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.testFramework.PsiTestUtil; +import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; import java.util.Collection; @@ -56,6 +57,8 @@ public class OrderEntryTest extends DaemonAnalyzerTestCase { myProject = ProjectManagerEx.getInstanceEx().loadProject(projectFile.getPath()); ProjectManagerEx.getInstanceEx().openTestProject(myProject); + UIUtil.dispatchAllInvocationEvents(); // startup activities + ModuleManagerImpl mm = (ModuleManagerImpl)ModuleManager.getInstance(myProject); mm.projectOpened(); setUpJdk(); diff --git a/java/java-tests/testSrc/com/intellij/navigation/GotoImplementationTest.java b/java/java-tests/testSrc/com/intellij/navigation/GotoImplementationTest.java index cba853e5a66f..37eac2578997 100644 --- a/java/java-tests/testSrc/com/intellij/navigation/GotoImplementationTest.java +++ b/java/java-tests/testSrc/com/intellij/navigation/GotoImplementationTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 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. + */ package com.intellij.navigation; import com.intellij.JavaTestUtil; @@ -16,6 +31,7 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiMethod; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.util.CommonProcessors; +import com.intellij.util.ui.UIUtil; import java.util.Arrays; import java.util.Collection; @@ -44,6 +60,7 @@ public class GotoImplementationTest extends CodeInsightTestCase { simulateProjectOpen(); ProjectManagerEx.getInstanceEx().openTestProject(myProject); + UIUtil.dispatchAllInvocationEvents(); // startup activities } @Override diff --git a/java/java-tests/testSrc/com/intellij/psi/search/UpdateCacheTest.java b/java/java-tests/testSrc/com/intellij/psi/search/UpdateCacheTest.java index d08c536b95be..3a4f928505e7 100644 --- a/java/java-tests/testSrc/com/intellij/psi/search/UpdateCacheTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/search/UpdateCacheTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -45,6 +45,7 @@ import com.intellij.testFramework.PsiTestUtil; import com.intellij.util.ArrayUtil; import com.intellij.util.Processor; import com.intellij.util.indexing.FileBasedIndex; +import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; import java.io.File; @@ -180,6 +181,8 @@ public class UpdateCacheTest extends PsiTestCase{ setUpModule(); setUpJdk(); ProjectManagerEx.getInstanceEx().openTestProject(myProject); + UIUtil.dispatchAllInvocationEvents(); // startup activities + runStartupActivities(); PsiTestUtil.addSourceContentToRoots(getModule(), content); diff --git a/platform/platform-tests/testSrc/com/intellij/psi/impl/PsiDocumentManagerImplTest.java b/platform/platform-tests/testSrc/com/intellij/psi/impl/PsiDocumentManagerImplTest.java index 717d64c2517c..52fd902d3b79 100644 --- a/platform/platform-tests/testSrc/com/intellij/psi/impl/PsiDocumentManagerImplTest.java +++ b/platform/platform-tests/testSrc/com/intellij/psi/impl/PsiDocumentManagerImplTest.java @@ -199,7 +199,7 @@ public class PsiDocumentManagerImplTest extends PlatformLangTestCase { final Project alienProject = createProject(new File(temp, "alien.ipr"), DebugUtil.currentStackTrace()); boolean succ2 = ProjectManagerEx.getInstanceEx().openProject(alienProject); assertTrue(succ2); - + UIUtil.dispatchAllInvocationEvents(); // startup activities try { PsiManager alienManager = PsiManager.getInstance(alienProject); @@ -342,7 +342,7 @@ public class PsiDocumentManagerImplTest extends PlatformLangTestCase { final Project alienProject = createProject(new File(temp, "alien.ipr"), DebugUtil.currentStackTrace()); boolean succ2 = ProjectManagerEx.getInstanceEx().openProject(alienProject); assertTrue(succ2); - + UIUtil.dispatchAllInvocationEvents(); // startup activities try { PsiManager alienManager = PsiManager.getInstance(alienProject); diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java index 8dbfe4f79b81..3e1c2a5f8e27 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java @@ -373,7 +373,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da @NotNull final Map availableInspectionTools) throws Exception { assertNull("Previous test " + ourTestCase + " hasn't called tearDown(). Probably overridden without super call.", ourTestCase); IdeaLogger.ourErrorsOccurred = null; - + ApplicationManager.getApplication().assertIsDispatchThread(); if (ourProject == null || ourProjectDescriptor == null || !ourProjectDescriptor.equals(descriptor)) { initProject(descriptor); } @@ -461,6 +461,8 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da assertEmpty("There are unsaved documents", Arrays.asList(unsavedDocuments)); } + UIUtil.dispatchAllInvocationEvents(); // startup activities + ((FileTypeManagerImpl)FileTypeManager.getInstance()).drainReDetectQueue(); } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenNotManagedProjectInspectionsTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenNotManagedProjectInspectionsTest.java index 5727ff47960c..6731613860dd 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenNotManagedProjectInspectionsTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenNotManagedProjectInspectionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -18,6 +18,7 @@ package org.jetbrains.idea.maven.dom; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.ex.ProjectManagerEx; import com.intellij.testFramework.PsiTestUtil; +import com.intellij.util.ui.UIUtil; import java.io.File; @@ -58,7 +59,8 @@ public class MavenNotManagedProjectInspectionsTest extends MavenDomTestCase { // relies on ProjectManager.isProjectOpen. In tests the project is never being opened. ProjectManagerEx.getInstanceEx().openProject(myProject); - + UIUtil.dispatchAllInvocationEvents(); // startup activities + Module m = createModule("module"); PsiTestUtil.addContentRoot(m, myProjectRoot);