X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=tmf%2Forg.eclipse.tracecompass.tmf.ui.tests%2Fshared%2Forg%2Feclipse%2Ftracecompass%2Ftmf%2Fui%2Ftests%2Fshared%2FProjectModelTestData.java;h=ec61a61ac744811eea1780f802c549e18f881131;hb=6db82092b514421a6dd57645f9aadac8bac4a3e0;hp=a04f31d549f904631e1cc25c2b4baf72e7e0dfe8;hpb=7b51f722f1d4b2357e5a268f5f86796eeee39a67;p=deliverable%2Ftracecompass.git diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.tests/shared/org/eclipse/tracecompass/tmf/ui/tests/shared/ProjectModelTestData.java b/tmf/org.eclipse.tracecompass.tmf.ui.tests/shared/org/eclipse/tracecompass/tmf/ui/tests/shared/ProjectModelTestData.java index a04f31d549..ec61a61ac7 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.tests/shared/org/eclipse/tracecompass/tmf/ui/tests/shared/ProjectModelTestData.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.tests/shared/org/eclipse/tracecompass/tmf/ui/tests/shared/ProjectModelTestData.java @@ -14,7 +14,6 @@ package org.eclipse.tracecompass.tmf.ui.tests.shared; import java.io.File; import java.lang.reflect.InvocationTargetException; -import java.util.concurrent.TimeoutException; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; @@ -46,11 +45,6 @@ import org.eclipse.ui.actions.WorkspaceModifyOperation; */ public class ProjectModelTestData { - /* Maximum number of thread delays the main thread will do before timing out */ - private static final int DELAY_COUNTER = 1000; - /* Default delay time when having the main thread sleep. */ - private static final long DEFAULT_DELAY = 500; - /** Default test project name */ public static final String PROJECT_NAME = "Test_Project"; @@ -238,28 +232,28 @@ public class ProjectModelTestData { * longer delays in those cases, it is preferable to use the * {@link ProjectModelTestData#delayThread(long)} instead. * - * Timeout is DELAY_COUNTER * DEFAULT_DELAY ms - * * @param projectElement * The trace element we are waiting for. If the element if not of * type TmfTraceElement, the thread is delayed only once. - * @throws TimeoutException + * @throws WaitTimeoutException * If after the maximum number of delays the trace is still * null, we throw a timeout exception, the trace has not opened. */ - public static void delayUntilTraceOpened(final ITmfProjectModelElement projectElement) throws TimeoutException { + public static void delayUntilTraceOpened(final ITmfProjectModelElement projectElement) throws WaitTimeoutException { if (projectElement instanceof TmfCommonProjectElement) { TmfCommonProjectElement traceElement = (TmfCommonProjectElement) projectElement; - final long deadline = System.nanoTime() + (DELAY_COUNTER * DEFAULT_DELAY * 1000000L); - do { - delayThread(DEFAULT_DELAY); - if (traceElement.getTrace() != null) { - return; + WaitUtils.waitUntil(new IWaitCondition() { + @Override + public boolean test() throws Exception { + return traceElement.getTrace() != null; + } + + @Override + public String getFailureMessage() { + return "Timeout while waiting for " + traceElement; } - } while (System.nanoTime() < deadline); - throw new TimeoutException("Timeout while waiting for " + traceElement); + }); } - delayThread(DEFAULT_DELAY); - } + } }