diff options
author | Jonah Graham | 2019-05-22 18:10:44 +0000 |
---|---|---|
committer | Jonah Graham | 2019-05-22 18:14:15 +0000 |
commit | f98add0056d1764f6487a888c21b880453e216dd (patch) | |
tree | cef21f7519adbf386eb8e3b52210841c9f8d1ec2 | |
parent | 83d67dd07492f3d253a62e26a03a6cc95f5e6b63 (diff) | |
download | org.eclipse.cdt-f98add0056d1764f6487a888c21b880453e216dd.tar.gz org.eclipse.cdt-f98add0056d1764f6487a888c21b880453e216dd.tar.xz org.eclipse.cdt-f98add0056d1764f6487a888c21b880453e216dd.zip |
Fixes for Test Leaking Editor test
The testLeakingInstanceAfterClose test relied on some weird
behaviour of an earlier test (testScalabilityDialogNotDismissedInadvertently_417909)
which had the effect of opening the editor window without the
welcome screen. This change makes that explicit and adds a little
bit of logging to identify why the testLeakingInstanceAfterClose
test may sometimes fail.
I have also increased the maximum time allowed before the test timesout.
Change-Id: I3433ccf1fc02cff76eeb278d05fee082157ca49c
-rw-r--r-- | core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java index 16201e37244..7d190bef5df 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java @@ -65,6 +65,7 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorRegistry; import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; @@ -122,6 +123,7 @@ public class BasicCEditorTest extends BaseUITestCase { @Override protected void setUp() throws Exception { + closeWelcome(); super.setUp(); } @@ -442,6 +444,19 @@ public class BasicCEditorTest extends BaseUITestCase { assertTrue(part instanceof CEditor); } + public static void closeWelcome() { + try { + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + IWorkbenchPage activePage = window.getActivePage(); + IWorkbenchPart activePart = activePage.getActivePart(); + if (activePart.getTitle().equals("Welcome")) { + activePart.dispose(); + } + } catch (Exception e) { + // ignore + } + } + public void testLeakingInstanceAfterClose() throws Exception { final String file = "/ceditor/src/main.cpp"; fCProject = EditorTestHelper.createCProject("ceditor", "resources/ceditor", false, false); @@ -452,11 +467,13 @@ public class BasicCEditorTest extends BaseUITestCase { EditorTestHelper.closeEditor(fEditor); fEditor = null; fSourceViewer = null; - int ngc = 10; - while (ref.get() != null && ngc-- > 0) { + int ngc = 0; + while (ref.get() != null && ngc++ < 100) { System.gc(); EditorTestHelper.runEventQueue(200); } + System.out + .println("BasicCEditorTest.testLeakingInstanceAfterClose took " + ngc + " iterations of loop to exit"); assertNull("CEditor instance seems to be leaking after close", ref.get()); } |