diff options
author | Andrey Loskutov | 2015-02-19 14:36:16 +0000 |
---|---|---|
committer | Andrey Loskutov | 2015-02-19 18:49:30 +0000 |
commit | 53c0bd27338c9cf53c44fdcf16f556917d8ea6b4 (patch) | |
tree | 94170f70eabd800c477b4f3a64bb8ab83e050cae /org.eclipse.egit.ui.test/src | |
parent | 2933611584f0d365d5b8f3aa736ab8b5fa94525d (diff) | |
download | egit-53c0bd27338c9cf53c44fdcf16f556917d8ea6b4.tar.gz egit-53c0bd27338c9cf53c44fdcf16f556917d8ea6b4.tar.xz egit-53c0bd27338c9cf53c44fdcf16f556917d8ea6b4.zip |
Fix test error in StagingViewTest.testCommitSingleFile
StagingView starts async tasks in UI now, so we need to proceed UI queue
after opening views in TestUtil.
Error Message
Tree item element containg text "GeneralProject/folder/test.txt" was not
found. Existing tree items:
ProjectWithoutDotProject/.project
Stacktrace
org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException: Tree
item element containg text "GeneralProject/folder/test.txt" was not
found. Existing tree items:
ProjectWithoutDotProject/.project
at org.eclipse.egit.ui.test.TestUtil.getNode(TestUtil.java:476)
at
org.eclipse.egit.ui.common.StagingViewTester.stageFile(StagingViewTester.java:64)
at
org.eclipse.egit.ui.test.stagview.StagingViewTest.testCommitSingleFile(StagingViewTest.java:70)
Change-Id: I068da330909b420d0570af607db91665533dfb6f
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'org.eclipse.egit.ui.test/src')
-rw-r--r-- | org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/StagingViewTester.java | 7 | ||||
-rw-r--r-- | org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java | 20 |
2 files changed, 27 insertions, 0 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/StagingViewTester.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/StagingViewTester.java index 35db1d2cfa..e7ce95c0d2 100644 --- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/StagingViewTester.java +++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/StagingViewTester.java @@ -40,6 +40,7 @@ public class StagingViewTester { SWTBotView view = TestUtil.showView(StagingView.VIEW_ID); TestUtil.joinJobs(org.eclipse.egit.core.JobFamilies.INDEX_DIFF_CACHE_UPDATE); + TestUtil.processUIEvents(); return new StagingViewTester(view); } @@ -61,13 +62,19 @@ public class StagingViewTester { public void stageFile(String path) { SWTBotTree unstagedTree = stagingView.bot().tree(0); + + TestUtil.waitUntilTreeHasNodeContainsText(stagingView.bot(), + unstagedTree, path, 10000); + TestUtil.getNode(unstagedTree.getAllItems(), path).select(); JobJoiner jobJoiner = JobJoiner.startListening( org.eclipse.egit.core.JobFamilies.INDEX_DIFF_CACHE_UPDATE, 30, TimeUnit.SECONDS); + ContextMenuHelper.clickContextMenu(unstagedTree, UIText.StagingView_StageItemMenuLabel); + jobJoiner.join(); } 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 b71c1da62f..36b5c27886 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,25 @@ public class TestUtil { } /** + * Process all queued UI events. If called from background thread, blocks + * until all pending events are processed in UI thread. + */ + public static void processUIEvents() { + if (Display.getCurrent() != null) { + while (Display.getCurrent().readAndDispatch()) { + // process queued ui events + } + } else { + // synchronously refresh UI + PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { + public void run() { + processUIEvents(); + } + }); + } + } + + /** * Appends content to given file. * * @param file @@ -569,6 +588,7 @@ public class TestUtil { IWorkbenchPage workbenchPage = workbenchWindow.getActivePage(); try { workbenchPage.showView(viewId); + processUIEvents(); } catch (PartInitException e) { throw new RuntimeException("Showing view with ID " + viewId + " failed.", e); |