diff options
author | Andrey Loskutov | 2015-06-28 18:25:55 +0000 |
---|---|---|
committer | Andrey Loskutov | 2015-06-28 18:25:55 +0000 |
commit | 4830faad99e65a6b5a495d5da6b560645658a88c (patch) | |
tree | e4c61ad32c213295a809719a274e83135eae3fce /org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test | |
parent | d537234a7bf30e7f1f4fbe643080354b5cc02162 (diff) | |
download | egit-4830faad99e65a6b5a495d5da6b560645658a88c.tar.gz egit-4830faad99e65a6b5a495d5da6b560645658a88c.tar.xz egit-4830faad99e65a6b5a495d5da6b560645658a88c.zip |
Introduced waitForJobs() after resetWorkspace and project operations
To be more stable, unit tests should wait for jobs which might be
triggered after resource operations.
Change-Id: Iab28f65bc163b82a8f3573611d329eedc0412580
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test')
-rw-r--r-- | org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java index 1bf1e586df..a684388e7b 100644 --- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java +++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java @@ -167,6 +167,32 @@ public class TestUtil { } /** + * Utility for waiting until the execution of jobs of any family has + * finished or timeout is reached. If no jobs are running, the method waits + * given minimum wait time. While this method is waiting for jobs, UI events + * are processed. + * + * @param minTimeMs + * minimum wait time in milliseconds + * @param maxTimeMs + * maximum wait time in milliseconds + */ + public static void waitForJobs(long minTimeMs, long maxTimeMs) { + if (maxTimeMs < minTimeMs) { + throw new IllegalArgumentException( + "Max time is smaller as min time!"); + } + final long start = System.currentTimeMillis(); + while (System.currentTimeMillis() - start < minTimeMs) { + processUIEvents(); + } + while (!Job.getJobManager().isIdle() + && System.currentTimeMillis() - start < maxTimeMs) { + processUIEvents(); + } + } + + /** * Process all queued UI events. If called from background thread, blocks * until all pending events are processed in UI thread. */ |