aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2018-09-10 06:36:25 -0400
committerMatthias Sohn2018-09-10 15:47:22 -0400
commit1ed88470943a5b05033f0b4a9c42ab4ba11814ab (patch)
tree737579ccc575135b84eb6460645fab747710f3c9
parent7f37ec7cb9729db5ef8db83fdb2cf684c3155dcb (diff)
downloadegit-1ed88470943a5b05033f0b4a9c42ab4ba11814ab.tar.gz
egit-1ed88470943a5b05033f0b4a9c42ab4ba11814ab.tar.xz
egit-1ed88470943a5b05033f0b4a9c42ab4ba11814ab.zip
[releng] Fix unstable HistoryViewTest.testOpenOfDeletedFile()
The file diff viewer newly computes its content asynchronously. Give that background job a job family, and join on it in the test to ensure that the expected content is actually there. Change-Id: I80335bb7540ca8395a1bf10262d9de21bbd944ac Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java14
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiffContentProvider.java7
2 files changed, 19 insertions, 2 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java
index 4f637578a..911f91313 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java
@@ -50,6 +50,7 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarToggleButton;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.eclipse.team.ui.history.IHistoryView;
+import org.eclipse.ui.PlatformUI;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -265,6 +266,16 @@ public class HistoryViewTest extends LocalRepositoryTestCase {
return getHistoryViewBot().table();
}
+ private SWTBotTable getFileDiffTable() throws Exception {
+ Job.getJobManager().join(JobFamilies.HISTORY_DIFF, null);
+ // Wait a little bit to give the UiJob triggered a chance to run
+ Thread.sleep(100);
+ // Then join the UI update
+ PlatformUI.getWorkbench().getDisplay().asyncExec(() -> {
+ /* empty */ });
+ return getHistoryViewBot().table(1);
+ }
+
private SWTBot getHistoryViewBot() {
return TestUtil.showHistoryView().bot();
}
@@ -384,8 +395,7 @@ public class HistoryViewTest extends LocalRepositoryTestCase {
assertEquals(commitCount + 1, commitsTable.rowCount());
commitsTable.select(0);
- SWTBot viewBot = getHistoryViewBot();
- SWTBotTable fileDiffTable = viewBot.table(1);
+ SWTBotTable fileDiffTable = getFileDiffTable();
assertEquals(1, fileDiffTable.rowCount());
fileDiffTable.select(0);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiffContentProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiffContentProvider.java
index 9c7c26ed2..e00c7554b 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiffContentProvider.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiffContentProvider.java
@@ -25,6 +25,7 @@ import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.StructuredSelection;
@@ -170,6 +171,12 @@ public class FileDiffContentProvider implements IStructuredContentProvider {
public FileDiff[] getDiffs() {
return diffs;
}
+
+ @Override
+ public boolean belongsTo(Object family) {
+ return family == JobFamilies.HISTORY_DIFF
+ || super.belongsTo(family);
+ }
}
private class UpdateJob extends UIJob {