Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2018-07-24 21:19:12 +0000
committerThomas Wolf2018-08-06 19:53:27 +0000
commit6ee58057c2dc1ab8498651e1ab91955289f7e981 (patch)
treea96324ec43af9989bd54840e7ddebe3d63e9f421 /org.eclipse.egit.ui.test
parentf83e6aeca768531f345f9092afd384bf763ff7ae (diff)
downloadegit-6ee58057c2dc1ab8498651e1ab91955289f7e981.tar.gz
egit-6ee58057c2dc1ab8498651e1ab91955289f7e981.tar.xz
egit-6ee58057c2dc1ab8498651e1ab91955289f7e981.zip
Use an asynchronous lightweight decorator in the repositories view
In the previous implementation, the label provider produced styled labels that included the decorations. But label providers run in the UI thread, and expensive decorations like a branch state (N commits ahead, M behind) could thus lead to UI blocks. Newly, leverage Eclipse's built-in support. Use a lightweight decorator for RepositoryTreeNode and register it in plugin.xml. Separate out getting labels into a WorkbenchAdapter and adapt the GitAdapterFactory accordingly. (We already created a WorkbenchAdapter there, but first we always created a new one, and second, it always created a RepositoriesViewLabelProvider just to get the label text. That's terribly inefficient and the logic is completely backwards.) Also use ImageDescriptors instead of Images where possible. Factor out the handling of LabelProviderChangedEvent from GitLightweightDecorator into GitDecorator and re-use it in the new decorator for RepositoryTreeNodes. Make the RepositoriesViewLabelProvider a decorating label provider based on a WorkbenchLabelProvider, which uses the singleton RepositoryTreeNodeWorkbenchAdapter to get labels and images. Change the other uses of RepositoriesViewLabelProvider in dialogs to work with the new setup. Adapt git repositories view tests. These often use the label provider to determine expected node labels, and then try to find a node with a matching label. Decorations are now asynchronous, and thus the label returned from the label provider may or may not contain the decoration. Even with waiting for decoration jobs we may end up with the label being determined in the test and the one in the UI being different. The latter may or may not contain the decoration, which makes finding expected nodes a bit difficult. For now, use the TestUtil navigation methods, which just check for containment. This works well, but because some decorations include the repo directory path which in turn includes the test method name, some test methods and even some test repo names had to be changed to avoid false "duplicate nodes" failures. User-visible UI changes from all that: next to none. Three differences I noticed in the default theme on OS X: 1. Decorations all use the default decoration style (light brown), with the exception of the directory paths shown on repository nodes and on working tree nodes. Those are handled specially and use the qualifier style. 2. Decorations in the "File->Import...->Projects from Git->Existing git repositories" page now actually work. 3. Image decorations briefly flicker on a refresh because of the way asynchronous lightweight decorators work. The flickering is due to the repository view being wholly refreshed frequently. On such a refresh, the viewer tries to get a new decorated label, but the decoration isn't available yet. Once it is available, an event is fired, and the viewer updates the label again. For text labels, the new RepositoriesViewLabelProvider contains a work-around, but for images, that method won't work. The only image decorations (so far) are the check markers for the currently checked-out ref. Otherwise, I notice much faster Eclipse startup with the repositories view open and containing some repositories. Bug: 536814 Change-Id: Ifa8279dd6755c57696b8b64e96bc41a1f948aa59 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.egit.ui.test')
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java23
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java15
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CompareActionsTest.java11
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/FetchAndMergeActionTest.java13
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewBranchHandlingTest.java2
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewFetchAndPushTest.java7
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRemoteHandlingTest.java10
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRepoDeletionTest.java19
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTagHandlingTest.java11
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java18
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTestBase.java25
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTestUtils.java69
12 files changed, 117 insertions, 106 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java
index 425c29d4d7..63ef60e079 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java
@@ -238,6 +238,7 @@ public abstract class LocalRepositoryTestCase extends EGitTestCase {
TestUtil.processUIEvents();
// close all editors/dialogs
new Eclipse().reset();
+ clearAllConfiguredRepositories();
closeGitViews();
TestUtil.processUIEvents();
// cleanup
@@ -284,11 +285,7 @@ public abstract class LocalRepositoryTestCase extends EGitTestCase {
testUtils.deleteTempDirs();
}
- protected static void shutDownRepositories() throws Exception {
- RepositoryCache cache = Activator.getDefault().getRepositoryCache();
- for(Repository repository:cache.getAllRepositories())
- repository.close();
- cache.clear();
+ protected void clearAllConfiguredRepositories() throws Exception {
IEclipsePreferences prefs = Activator.getDefault().getRepositoryUtil()
.getPreferences();
synchronized (prefs) {
@@ -298,6 +295,14 @@ public abstract class LocalRepositoryTestCase extends EGitTestCase {
}
}
+ protected static void shutDownRepositories() throws Exception {
+ RepositoryCache cache = Activator.getDefault().getRepositoryCache();
+ for (Repository repository : cache.getAllRepositories()) {
+ repository.close();
+ }
+ cache.clear();
+ }
+
protected static void deleteAllProjects() throws Exception {
for (IProject prj : ResourcesPlugin.getWorkspace().getRoot()
.getProjects()) {
@@ -381,7 +386,7 @@ public abstract class LocalRepositoryTestCase extends EGitTestCase {
} else {
commitables = new IFile[] { dotProject, textFile, textFile2 };
}
- ArrayList<IFile> untracked = new ArrayList<IFile>();
+ ArrayList<IFile> untracked = new ArrayList<>();
untracked.addAll(Arrays.asList(commitables));
// commit to stable
CommitOperation op = new CommitOperation(commitables,
@@ -662,7 +667,7 @@ public abstract class LocalRepositoryTestCase extends EGitTestCase {
IFile file = touch(newContent);
IFile[] commitables = new IFile[] { file };
- ArrayList<IFile> untracked = new ArrayList<IFile>();
+ ArrayList<IFile> untracked = new ArrayList<>();
untracked.addAll(Arrays.asList(commitables));
String message = commitMessage;
if (message == null)
@@ -716,7 +721,7 @@ public abstract class LocalRepositoryTestCase extends EGitTestCase {
}
protected static void stage(IFile file) throws Exception {
- ArrayList<IFile> unstaged = new ArrayList<IFile>();
+ ArrayList<IFile> unstaged = new ArrayList<>();
unstaged.addAll(Arrays.asList(new IFile[] { file }));
AddToIndexOperation op = new AddToIndexOperation(unstaged);
op.execute(null);
@@ -728,7 +733,7 @@ public abstract class LocalRepositoryTestCase extends EGitTestCase {
if (!prj.isAccessible())
throw new IllegalStateException("No project to touch");
IFile[] commitables = new IFile[] { file };
- ArrayList<IFile> untracked = new ArrayList<IFile>();
+ ArrayList<IFile> untracked = new ArrayList<>();
untracked.addAll(Arrays.asList(commitables));
CommitOperation op = new CommitOperation(commitables,
untracked, TestUtil.TESTAUTHOR, TestUtil.TESTCOMMITTER,
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java
index 12063befa2..13315742c3 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java
@@ -40,13 +40,8 @@ import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.common.LocalRepositoryTestCase;
import org.eclipse.egit.ui.internal.UIText;
-import org.eclipse.egit.ui.internal.repository.RepositoriesViewLabelProvider;
-import org.eclipse.egit.ui.internal.repository.tree.LocalNode;
-import org.eclipse.egit.ui.internal.repository.tree.RepositoryNode;
-import org.eclipse.egit.ui.internal.repository.tree.TagsNode;
import org.eclipse.egit.ui.test.ContextMenuHelper;
import org.eclipse.egit.ui.test.TestUtil;
-import org.eclipse.egit.ui.view.repositories.GitRepositoriesViewTestUtils;
import org.eclipse.jface.bindings.keys.KeyStroke;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jgit.lib.Constants;
@@ -100,12 +95,8 @@ public class BranchAndResetActionTest extends LocalRepositoryTestCase {
top.execute(null);
touchAndSubmit(null);
- RepositoriesViewLabelProvider provider = GitRepositoriesViewTestUtils
- .createLabelProvider();
- LOCAL_BRANCHES = provider.getText(new LocalNode(new RepositoryNode(
- null, repo), repo));
- TAGS = provider.getText(new TagsNode(new RepositoryNode(null, repo),
- repo));
+ LOCAL_BRANCHES = UIText.RepositoriesViewLabelProvider_LocalNodetext;
+ TAGS = UIText.RepositoriesViewLabelProvider_TagsNodeText;
}
@Test
@@ -171,7 +162,7 @@ public class BranchAndResetActionTest extends LocalRepositoryTestCase {
.getProject(PROJ1).getFolder(FOLDER).getFile("ToBeDeleted");
toBeDeleted.create(new ByteArrayInputStream(new byte[0]), false, null);
- ArrayList<IFile> untracked = new ArrayList<IFile>();
+ ArrayList<IFile> untracked = new ArrayList<>();
untracked.add(toBeDeleted);
// commit to stable
CommitOperation op = new CommitOperation(new IFile[] { toBeDeleted },
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CompareActionsTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CompareActionsTest.java
index bf7514156c..4724595ed7 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CompareActionsTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CompareActionsTest.java
@@ -35,13 +35,9 @@ import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.common.LocalRepositoryTestCase;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.internal.dialogs.CompareTreeView;
-import org.eclipse.egit.ui.internal.repository.RepositoriesViewLabelProvider;
-import org.eclipse.egit.ui.internal.repository.tree.RepositoryNode;
-import org.eclipse.egit.ui.internal.repository.tree.TagsNode;
import org.eclipse.egit.ui.test.ContextMenuHelper;
import org.eclipse.egit.ui.test.JobJoiner;
import org.eclipse.egit.ui.test.TestUtil;
-import org.eclipse.egit.ui.view.repositories.GitRepositoriesViewTestUtils;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.ResetCommand.ResetType;
@@ -96,12 +92,7 @@ public class CompareActionsTest extends LocalRepositoryTestCase {
top.execute(null);
touchAndSubmit(null);
- RepositoriesViewLabelProvider provider = GitRepositoriesViewTestUtils
- .createLabelProvider();
- // LOCAL_BRANCHES = provider.getText(new LocalNode(new RepositoryNode(
- // null, repo), repo));
- TAGS = provider.getText(new TagsNode(new RepositoryNode(null, repo),
- repo));
+ TAGS = UIText.RepositoriesViewLabelProvider_TagsNodeText;
}
private static void setEnabledModelProvider(String modelProviderId) {
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/FetchAndMergeActionTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/FetchAndMergeActionTest.java
index 7f2464bb1d..b74ebb3656 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/FetchAndMergeActionTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/FetchAndMergeActionTest.java
@@ -22,14 +22,9 @@ import java.util.concurrent.TimeUnit;
import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.common.LocalRepositoryTestCase;
import org.eclipse.egit.ui.internal.UIText;
-import org.eclipse.egit.ui.internal.repository.RepositoriesViewLabelProvider;
-import org.eclipse.egit.ui.internal.repository.tree.LocalNode;
-import org.eclipse.egit.ui.internal.repository.tree.RemoteTrackingNode;
-import org.eclipse.egit.ui.internal.repository.tree.RepositoryNode;
import org.eclipse.egit.ui.test.ContextMenuHelper;
import org.eclipse.egit.ui.test.JobJoiner;
import org.eclipse.egit.ui.test.TestUtil;
-import org.eclipse.egit.ui.view.repositories.GitRepositoriesViewTestUtils;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
@@ -65,13 +60,9 @@ public class FetchAndMergeActionTest extends LocalRepositoryTestCase {
public void setup() throws Exception {
repositoryFile = createProjectAndCommitToRepository();
childRepositoryFile = createChildRepository(repositoryFile);
- RepositoriesViewLabelProvider provider = GitRepositoriesViewTestUtils
- .createLabelProvider();
Repository repo = lookupRepository(childRepositoryFile);
- REMOTE_BRANCHES = provider.getText(new RemoteTrackingNode(
- new RepositoryNode(null, repo), repo));
- LOCAL_BRANCHES = provider.getText(new LocalNode(new RepositoryNode(
- null, repo), repo));
+ REMOTE_BRANCHES = UIText.RepositoriesViewLabelProvider_RemoteTrackingNodetext;
+ LOCAL_BRANCHES = UIText.RepositoriesViewLabelProvider_LocalNodetext;
ObjectId id = repo.resolve(repo.getFullBranch());
initialCommitId = id.name();
}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewBranchHandlingTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewBranchHandlingTest.java
index 9e86473d8f..7b7df801cf 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewBranchHandlingTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewBranchHandlingTest.java
@@ -219,7 +219,7 @@ public class GitRepositoriesViewBranchHandlingTest extends
}
@Test
- public void testClonedRepository() throws Exception {
+ public void testBranchCreateInClone() throws Exception {
SWTBotTree tree = getOrOpenView().bot().tree();
SWTBotTreeItem item = TestUtil.expandAndWait(myRepoViewUtil
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewFetchAndPushTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewFetchAndPushTest.java
index fd8da96b1e..cada79cb45 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewFetchAndPushTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewFetchAndPushTest.java
@@ -74,7 +74,7 @@ public class GitRepositoriesViewFetchAndPushTest extends
// now let's clone the remote repository
uri = new URIish(remoteRepositoryFile.getPath());
- workdir = new File(getTestDirectory(), "ClonedRepo2");
+ workdir = new File(getTestDirectory(), "RepoClone2");
op = new CloneOperation(uri, true, null, workdir, "refs/heads/master",
"origin", 0);
@@ -118,6 +118,7 @@ public class GitRepositoriesViewFetchAndPushTest extends
}
Job.getJobManager().join(JobFamilies.REPO_VIEW_REFRESH, null);
+ TestUtil.waitForDecorations();
SWTBotTree tree = repoView.bot().tree();
tree.select(0);
@@ -295,8 +296,8 @@ public class GitRepositoriesViewFetchAndPushTest extends
throws Exception {
SWTBotTreeItem remotesNode = myRepoViewUtil.getRemotesItem(tree,
clonedRepositoryFile);
- SWTBotTreeItem originNode = TestUtil.expandAndWait(remotesNode)
- .getNode("origin");
+ SWTBotTreeItem originNode = TestUtil
+ .getChildNode(TestUtil.expandAndWait(remotesNode), "origin");
if (useRemote) {
originNode.select();
} else {
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRemoteHandlingTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRemoteHandlingTest.java
index 8a3a3f08ba..befc5bbcb7 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRemoteHandlingTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRemoteHandlingTest.java
@@ -69,7 +69,7 @@ public class GitRepositoriesViewRemoteHandlingTest extends
* @throws Exception
*/
@Test
- public void testExpandRemotes() throws Exception {
+ public void testExpandRemoteNodes() throws Exception {
removeRemotesConfig(repositoryFile);
refreshAndWait();
SWTBotTree tree = getOrOpenView().bot().tree();
@@ -80,8 +80,8 @@ public class GitRepositoriesViewRemoteHandlingTest extends
StoredConfig cfg = lookupRepository(repositoryFile).getConfig();
String remoteUri = "file:///" + remoteRepositoryFile.getPath();
- cfg.setString("remote", "test", "url", remoteUri);
- cfg.setString("remote", "test", "fetch", "somejunk");
+ cfg.setString("remote", "test1", "url", remoteUri);
+ cfg.setString("remote", "test1", "fetch", "somejunk");
cfg.setString("remote", "test2", "url", remoteUri);
cfg.setString("remote", "test2", "fetch", "somejunk");
cfg.setString("remote", "test2", "pushurl", remoteUri);
@@ -97,7 +97,7 @@ public class GitRepositoriesViewRemoteHandlingTest extends
.size());
List<String> testnodes = TestUtil
- .expandAndWait(remotesItem.getNode("test")).getNodes();
+ .expandAndWait(remotesItem.getNode("test1")).getNodes();
assertEquals(2, testnodes.size());
List<String> test2nodes = TestUtil
.expandAndWait(remotesItem.getNode("test2")).getNodes();
@@ -107,7 +107,7 @@ public class GitRepositoriesViewRemoteHandlingTest extends
.getNodes().size());
// test the properties view on remote
- remotesItem.getNode("test").select();
+ remotesItem.getNode("test1").select();
ContextMenuHelper.clickContextMenuSync(tree,
myUtil.getPluginLocalizedValue("ShowIn"),
"Properties");
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRepoDeletionTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRepoDeletionTest.java
index eff6504f9d..6776ee900a 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRepoDeletionTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRepoDeletionTest.java
@@ -243,10 +243,13 @@ public class GitRepositoriesViewRepoDeletionTest extends
Thread.currentThread().interrupt();
return Status.CANCEL_STATUS;
}
+ // Make sure the label provider is disposed. We don't need it
+ // anymore.
+ myRepoViewUtil.dispose();
// Finally... Java does not give any guarantees about when
// exactly an only weakly reachable object is finalized and
// garbage collected.
- waitForFinalization(5000);
+ waitForFinalization(10000);
// Experience shows that an explicit garbage collection run very
// often does reclaim only weakly reachable objects and set the
// weak references' referents to null, but not even that can be
@@ -340,15 +343,23 @@ public class GitRepositoriesViewRepoDeletionTest extends
private void waitForFinalization(int maxMillis) {
long stop = System.currentTimeMillis() + maxMillis;
MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean();
- do {
+ for (;;) {
System.gc();
try {
Thread.sleep(100);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
+ System.out.println("Garbage collection interrupted");
break;
}
- } while (System.currentTimeMillis() < stop
- && memoryBean.getObjectPendingFinalizationCount() > 0);
+ if (memoryBean.getObjectPendingFinalizationCount() == 0) {
+ break;
+ }
+ if (System.currentTimeMillis() > stop) {
+ System.out.println(
+ "Garbage collection timed out; not all objects collected.");
+ break;
+ }
+ }
}
}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTagHandlingTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTagHandlingTest.java
index f0b74cf41d..8c6696f546 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTagHandlingTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTagHandlingTest.java
@@ -20,7 +20,6 @@ import java.io.File;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
@@ -67,7 +66,7 @@ public class GitRepositoriesViewTagHandlingTest extends
}
@Test
- public void testCreateTags() throws Exception {
+ public void testCreateTagMultiple() throws Exception {
SWTBotTree tree = getOrOpenView().bot().tree();
int initialCount = myRepoViewUtil.getTagsItem(tree, repositoryFile)
.expand().rowCount();
@@ -90,7 +89,7 @@ public class GitRepositoriesViewTagHandlingTest extends
}
@Test
- public void testDeleteTag() throws Exception {
+ public void testTagDeletionSingle() throws Exception {
SWTBotTree tree = getOrOpenView().bot().tree();
int initialCount = myRepoViewUtil.getTagsItem(tree, repositoryFile)
.expand().rowCount();
@@ -114,11 +113,7 @@ public class GitRepositoriesViewTagHandlingTest extends
}
@Test
- public void testDeleteTags() throws Exception {
- //TODO Remove once bug355200 has been fixed
- if (Platform.OS_MACOSX.equals(Platform.getOS()))
- return;
-
+ public void testTagDeletionMultiple() throws Exception {
SWTBotTree tree = getOrOpenView().bot().tree();
int initialCount = myRepoViewUtil.getTagsItem(tree, repositoryFile)
.expand().rowCount();
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java
index 47fd897813..bee72f3e0b 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTest.java
@@ -270,11 +270,13 @@ public class GitRepositoriesViewTest extends GitRepositoriesViewTestBase {
SWTBotShell shell = bot.shell(wizardTitle);
bot.radio(UIText.GitSelectWizardPage_ImportExistingButton).click();
TableCollection selected = shell.bot().tree().selection();
- String wizardNode = selected.get(0, 0);
+ String wizardNodeText = selected.get(0, 0);
// wizard directory should be working dir
- assertEquals(
- myRepoViewUtil.getWorkdirItem(tree, repositoryFile).getText(),
- wizardNode);
+ String expected = myRepoViewUtil.getWorkdirItem(tree, repositoryFile)
+ .getText();
+ // One or the other or both or none might contain decorations
+ assertTrue(expected.contains(wizardNodeText)
+ || wizardNodeText.contains(expected));
shell.close();
tree = getOrOpenView().bot().tree();
// start wizard from .git
@@ -285,9 +287,9 @@ public class GitRepositoriesViewTest extends GitRepositoriesViewTestBase {
myUtil.getPluginLocalizedValue("ImportProjectsCommand"));
shell = bot.shell(wizardTitle);
selected = shell.bot().tree().selection();
- wizardNode = selected.get(0, 0);
+ wizardNodeText = selected.get(0, 0);
// wizard directory should be .git
- assertEquals(Constants.DOT_GIT, wizardNode);
+ assertEquals(Constants.DOT_GIT, wizardNodeText);
shell.bot().button(IDialogConstants.NEXT_LABEL).click();
shell.bot().label("Import Projects"); // wait for import projects page
assertEquals(0, shell.bot().tree().getAllItems().length);
@@ -330,7 +332,7 @@ public class GitRepositoriesViewTest extends GitRepositoriesViewTestBase {
private static IWizardDescriptor[] getAllWizards(
IWizardCategory[] categories) {
- List<IWizardDescriptor> results = new ArrayList<IWizardDescriptor>();
+ List<IWizardDescriptor> results = new ArrayList<>();
for (IWizardCategory wizardCategory : categories) {
results.addAll(Arrays.asList(wizardCategory.getWizards()));
results.addAll(Arrays
@@ -658,7 +660,7 @@ public class GitRepositoriesViewTest extends GitRepositoriesViewTestBase {
}
@Test
- public void testDeleteMultipleBranches() throws Exception {
+ public void testDeleteBranchMultiple() throws Exception {
// expand first level
SWTBotTree tree = getOrOpenView().bot().tree();
refreshAndWait();
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTestBase.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTestBase.java
index dfe19ee6c0..a11abfb6b9 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTestBase.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTestBase.java
@@ -45,6 +45,8 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
+import org.junit.After;
+import org.junit.Before;
/**
* Collection of utility methods for Git Repositories View tests
@@ -59,7 +61,21 @@ public abstract class GitRepositoriesViewTestBase extends
protected final static String viewName = myUtil
.getPluginLocalizedValue("GitRepositoriesView_name");
- protected static final GitRepositoriesViewTestUtils myRepoViewUtil = new GitRepositoriesViewTestUtils();
+ protected static GitRepositoriesViewTestUtils myRepoViewUtil;
+
+ @Before
+ public void setup() {
+ setTestUtils();
+ }
+
+ private static void setTestUtils() {
+ myRepoViewUtil = new GitRepositoriesViewTestUtils();
+ }
+
+ @After
+ public void teardown() {
+ myRepoViewUtil.dispose();
+ }
/**
* remove all configured repositories from the view
@@ -130,6 +146,13 @@ public abstract class GitRepositoriesViewTestBase extends
fail("Refresh took longer 60 seconds");
}
TestUtil.processUIEvents();
+ TestUtil.waitForDecorations();
+ }
+
+ @Override
+ protected void clearAllConfiguredRepositories() throws Exception {
+ super.clearAllConfiguredRepositories();
+ refreshAndWait();
}
@Override
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTestUtils.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTestUtils.java
index 62a901d94c..fb19b945c6 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTestUtils.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewTestUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2012 SAP AG and others.
+ * Copyright (c) 2010, 2018 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -38,7 +38,7 @@ public class GitRepositoriesViewTestUtils {
* @return label provider
*/
public static RepositoriesViewLabelProvider createLabelProvider() {
- final AtomicReference<RepositoriesViewLabelProvider> providerRef = new AtomicReference<RepositoriesViewLabelProvider>();
+ final AtomicReference<RepositoriesViewLabelProvider> providerRef = new AtomicReference<>();
Display.getDefault().syncExec(new Runnable() {
@Override
@@ -61,6 +61,10 @@ public class GitRepositoriesViewTestUtils {
labelProvider = createLabelProvider();
}
+ public void dispose() {
+ Display.getDefault().syncExec(() -> labelProvider.dispose());
+ }
+
public SWTBotTreeItem getLocalBranchesItem(SWTBotTree tree, File repo)
throws Exception {
Repository repository = lookupRepository(repo);
@@ -69,12 +73,11 @@ public class GitRepositoriesViewTestUtils {
LocalNode localBranches = new LocalNode(branches,
repository);
- String rootText = labelProvider.getStyledText(root).getString();
- SWTBotTreeItem rootItem = tree.getTreeItem(rootText);
- SWTBotTreeItem branchesItem = TestUtil.expandAndWait(rootItem)
- .getNode(labelProvider.getStyledText(branches).getString());
- SWTBotTreeItem localItem = TestUtil.expandAndWait(branchesItem).getNode(
- labelProvider.getStyledText(localBranches).getString());
+ String rootText = labelProvider.getText(root);
+ String branchesText = labelProvider.getText(branches);
+ String localText = labelProvider.getText(localBranches);
+ SWTBotTreeItem localItem = TestUtil.navigateTo(tree, rootText,
+ branchesText, localText);
return localItem;
}
@@ -84,10 +87,9 @@ public class GitRepositoriesViewTestUtils {
RepositoryNode root = new RepositoryNode(null, repository);
TagsNode tags = new TagsNode(root, repository);
- String rootText = labelProvider.getStyledText(root).getString();
- SWTBotTreeItem rootItem = tree.getTreeItem(rootText);
- SWTBotTreeItem tagsItem = TestUtil.expandAndWait(rootItem)
- .getNode(labelProvider.getStyledText(tags).getString());
+ String rootText = labelProvider.getText(root);
+ String tagsText = labelProvider.getText(tags);
+ SWTBotTreeItem tagsItem = TestUtil.navigateTo(tree, rootText, tagsText);
return tagsItem;
}
@@ -99,13 +101,11 @@ public class GitRepositoriesViewTestUtils {
RemoteTrackingNode remoteBranches = new RemoteTrackingNode(branches,
repository);
- String rootText = labelProvider.getStyledText(root).getString();
- SWTBotTreeItem rootItem = tree.getTreeItem(rootText);
- SWTBotTreeItem branchesItem = TestUtil.expandAndWait(rootItem)
- .getNode(labelProvider.getStyledText(branches).getString());
- SWTBotTreeItem remoteItem = TestUtil.expandAndWait(branchesItem)
- .getNode(labelProvider.getStyledText(remoteBranches)
- .getString());
+ String rootText = labelProvider.getText(root);
+ String branchesText = labelProvider.getText(branches);
+ String remoteText = labelProvider.getText(remoteBranches);
+ SWTBotTreeItem remoteItem = TestUtil.navigateTo(tree, rootText,
+ branchesText, remoteText);
return remoteItem;
}
@@ -113,13 +113,12 @@ public class GitRepositoriesViewTestUtils {
throws Exception {
Repository repository = lookupRepository(repositoryFile);
RepositoryNode root = new RepositoryNode(null, repository);
-
WorkingDirNode workdir = new WorkingDirNode(root, repository);
- String rootText = labelProvider.getStyledText(root).getString();
- SWTBotTreeItem rootItem = tree.getTreeItem(rootText);
- SWTBotTreeItem workdirItem = TestUtil.expandAndWait(rootItem)
- .getNode(labelProvider.getStyledText(workdir).getString());
+ String rootText = labelProvider.getText(root);
+ String workDirText = labelProvider.getText(workdir);
+ SWTBotTreeItem workdirItem = TestUtil.navigateTo(tree, rootText,
+ workDirText);
return workdirItem;
}
@@ -127,8 +126,9 @@ public class GitRepositoriesViewTestUtils {
throws Exception {
Repository repository = lookupRepository(repositoryFile);
RepositoryNode root = new RepositoryNode(null, repository);
- String rootText = labelProvider.getStyledText(root).getString();
- SWTBotTreeItem rootItem = tree.getTreeItem(rootText);
+
+ String rootText = labelProvider.getText(root);
+ SWTBotTreeItem rootItem = TestUtil.navigateTo(tree, rootText);
return rootItem;
}
@@ -137,10 +137,11 @@ public class GitRepositoriesViewTestUtils {
Repository repository = lookupRepository(repositoryFile);
RepositoryNode root = new RepositoryNode(null, repository);
AdditionalRefsNode symrefsnode = new AdditionalRefsNode(root, repository);
- SWTBotTreeItem rootItem = tree
- .getTreeItem(labelProvider.getStyledText(root).getString());
- SWTBotTreeItem symrefsitem = TestUtil.expandAndWait(rootItem)
- .getNode(labelProvider.getStyledText(symrefsnode).getString());
+
+ String rootText = labelProvider.getText(root);
+ String symrefsText = labelProvider.getText(symrefsnode);
+ SWTBotTreeItem symrefsitem = TestUtil.navigateTo(tree, rootText,
+ symrefsText);
return symrefsitem;
}
@@ -150,10 +151,10 @@ public class GitRepositoriesViewTestUtils {
RepositoryNode root = new RepositoryNode(null, repository);
RemotesNode remotes = new RemotesNode(root, repository);
- String rootText = labelProvider.getStyledText(root).getString();
- SWTBotTreeItem rootItem = tree.getTreeItem(rootText);
- SWTBotTreeItem remotesItem = TestUtil.expandAndWait(rootItem)
- .getNode(labelProvider.getStyledText(remotes).getString());
+ String rootText = labelProvider.getText(root);
+ String remotesText = labelProvider.getText(remotes);
+ SWTBotTreeItem remotesItem = TestUtil.navigateTo(tree, rootText,
+ remotesText);
return remotesItem;
}

Back to the top