From: Marc-Andre Laperle Date: Wed, 29 Jun 2016 20:19:27 +0000 (-0400) Subject: tmf: Fix intermittent failure in ProjectExplorerTraceActionsTest X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=e9a570ab1c7b11d9633b618d9d2f0aeea7c6c957;hp=1c9b6343d7d3e72643d34f6cad400a4698824230;p=deliverable%2Ftracecompass.git tmf: Fix intermittent failure in ProjectExplorerTraceActionsTest To reproduce the issue: In TmfTraceElement.delete, add a Thread.sleep(5000); right after the syncExec that calls closeEditors. Run ProjectExplorerTraceActionsTest.test4_05Delete then test4_09BringToTop (you can create a new test method and call them in that order). The problem is that the delete test waits until the delete dialog and the editor are closed but there is no guarantee that the file will actually be deleted right away. While the file is still there, it is possible that the next test will start and begin the process of opening the same existing trace. But then the file gets deleted and the trace doesn't validate properly (or other exceptions depending on the timing of when the trace gets deleted). We should make sure that the file is deleted before proceeding. Bug: 497035 Change-Id: I33d0b45732bdde6061112736f2f1f7e46d55864e Signed-off-by: Marc-Andre Laperle Reviewed-on: https://git.eclipse.org/r/76249 Reviewed-by: Hudson CI Reviewed-by: Jean-Christian Kouame Tested-by: Jean-Christian Kouame --- diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/projectexplorer/ProjectExplorerTraceActionsTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/projectexplorer/ProjectExplorerTraceActionsTest.java index 9365b2fa26..5b2dec22cd 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/projectexplorer/ProjectExplorerTraceActionsTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/projectexplorer/ProjectExplorerTraceActionsTest.java @@ -24,6 +24,7 @@ import java.util.stream.Collectors; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Logger; import org.apache.log4j.SimpleLayout; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; import org.eclipse.jdt.annotation.NonNull; @@ -254,6 +255,7 @@ public class ProjectExplorerTraceActionsTest { shell.bot().button("Yes").click(); fBot.waitUntil(Conditions.shellCloses(shell)); fBot.waitWhile(new ConditionHelpers.ActiveEventsEditor(fBot, null)); + fBot.waitUntil(new TraceDeletedCondition()); } /** @@ -302,6 +304,7 @@ public class ProjectExplorerTraceActionsTest { shell.bot().button("Yes").click(); fBot.waitUntil(Conditions.shellCloses(shell)); fBot.waitWhile(new ConditionHelpers.ActiveEventsEditor(fBot, null)); + fBot.waitUntil(new TraceDeletedCondition()); } /** @@ -412,4 +415,16 @@ public class ProjectExplorerTraceActionsTest { assertTrue(view.bot().tree().hasItems()); view.bot().tree().cell(0, 1).equals(Long.toString(NB_EVENTS)); } + + private final class TraceDeletedCondition extends DefaultCondition { + @Override + public boolean test() throws Exception { + return ResourcesPlugin.getWorkspace().getRoot().getProject(TRACE_PROJECT_NAME).findMember(new Path("Traces/" + TRACE_NAME)) == null; + } + + @Override + public String getFailureMessage() { + return TRACE_NAME + " was not deleted successfully."; + } + } }