aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2018-08-07 04:01:38 -0400
committerThomas Wolf2018-08-07 04:01:38 -0400
commit6722dd695680ac4cd1e53007c38a788d704615d5 (patch)
tree0d8c52b4f48c4eadbc680c1b57d54ac23ddac7e6
parent9a2209c3b02a34e8fcd409ea897f9743905cc543 (diff)
downloadegit-6722dd695680ac4cd1e53007c38a788d704615d5.tar.gz
egit-6722dd695680ac4cd1e53007c38a788d704615d5.tar.xz
egit-6722dd695680ac4cd1e53007c38a788d704615d5.zip
[releng] Fix test failures
StagingViewTest also uses the git repositories view and therefore must use the same mechanisms as the other git repositories view tests to avoid leaking references to repository tree nodes across tests. Also fix an NPE during tests in FileDiffContentProvider: make sure the UI update doesn't run if the content provider has been disposed already. Change-Id: Ib08ce78e4f76207adfa0920b3cfa94d55186a706 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/AbstractStagingViewTestCase.java19
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiffContentProvider.java4
2 files changed, 8 insertions, 15 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/AbstractStagingViewTestCase.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/AbstractStagingViewTestCase.java
index 1bc05fa6d..4f00384fc 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/AbstractStagingViewTestCase.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/AbstractStagingViewTestCase.java
@@ -14,22 +14,16 @@ import java.io.File;
import org.eclipse.egit.core.JobFamilies;
import org.eclipse.egit.ui.Activator;
-import org.eclipse.egit.ui.common.LocalRepositoryTestCase;
-import org.eclipse.egit.ui.internal.repository.RepositoriesView;
-import org.eclipse.egit.ui.internal.staging.StagingView;
import org.eclipse.egit.ui.test.TestUtil;
-import org.eclipse.egit.ui.view.repositories.GitRepositoriesViewTestUtils;
+import org.eclipse.egit.ui.view.repositories.GitRepositoriesViewTestBase;
import org.eclipse.jgit.lib.Repository;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.junit.After;
import org.junit.Before;
public abstract class AbstractStagingViewTestCase
- extends LocalRepositoryTestCase {
-
- protected static final GitRepositoriesViewTestUtils repoViewUtil = new GitRepositoriesViewTestUtils();
+ extends GitRepositoriesViewTestBase {
protected File repositoryFile;
@@ -48,8 +42,7 @@ public abstract class AbstractStagingViewTestCase
@After
public void after() {
- TestUtil.hideView(RepositoriesView.VIEW_ID);
- TestUtil.hideView(StagingView.VIEW_ID);
+ repository = null;
Activator.getDefault().getRepositoryUtil().removeDir(repositoryFile);
}
@@ -59,11 +52,9 @@ public abstract class AbstractStagingViewTestCase
}
protected void selectRepositoryNode() throws Exception {
- SWTBotView repositoriesView = TestUtil
- .showView(RepositoriesView.VIEW_ID);
- SWTBotTree tree = repositoriesView.bot().tree();
+ SWTBotTree tree = getOrOpenView().bot().tree();
- SWTBotTreeItem repoNode = repoViewUtil.getRootItem(tree,
+ SWTBotTreeItem repoNode = myRepoViewUtil.getRootItem(tree,
repositoryFile);
repoNode.select();
}
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 1ed9ccf2b..9c7c26ed2 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
@@ -32,6 +32,7 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jgit.treewalk.TreeWalk;
import org.eclipse.jgit.treewalk.filter.PathFilterGroup;
import org.eclipse.jgit.treewalk.filter.TreeFilter;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.progress.UIJob;
/**
@@ -182,7 +183,8 @@ public class FileDiffContentProvider implements IStructuredContentProvider {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
- if (viewer.getControl().isDisposed() || loader != loadJob) {
+ Control control = viewer == null ? null : viewer.getControl();
+ if (control == null || control.isDisposed() || loader != loadJob) {
return Status.CANCEL_STATUS;
}
diff = loadJob.getDiffs();