diff options
author | Thomas Wolf | 2019-12-14 16:07:06 +0000 |
---|---|---|
committer | Thomas Wolf | 2019-12-15 20:03:40 +0000 |
commit | efc4d4acc01e6ccbee512d065e714e6342fc645e (patch) | |
tree | ebd218a9b92896d47f8a4107570cf92d8f621675 /org.eclipse.egit.ui.test | |
parent | 9244bc84355894bc353ba374978f1f92d49d81de (diff) | |
download | egit-efc4d4acc01e6ccbee512d065e714e6342fc645e.tar.gz egit-efc4d4acc01e6ccbee512d065e714e6342fc645e.tar.xz egit-efc4d4acc01e6ccbee512d065e714e6342fc645e.zip |
[deco cache] Reset BranchStatus cache on ConfigChangedEvent
Otherwise labels are not updated when a branch is (re-)configured.
Bug: 558323
Change-Id: Ifa47c0edcaf4bc3b73682ac2f2ac33e976a95155
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/view/repositories/GitRepositoriesViewBranchHandlingTest.java | 59 |
1 files changed, 57 insertions, 2 deletions
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 27c32d70bc..7e181a2c07 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 @@ -86,6 +86,11 @@ public class GitRepositoriesViewBranchHandlingTest extends setVerboseBranchMode(false); repositoryFile = createProjectAndCommitToRepository(); remoteRepositoryFile = createRemoteRepository(repositoryFile); + // Create one more branch on HEAD^1 + try (Git git = new Git(lookupRepository(remoteRepositoryFile))) { + git.branchCreate().setName("initial").setStartPoint("HEAD^1") + .call(); + } // now let's clone the remote repository final URIish uri = new URIish(remoteRepositoryFile.getPath()); final File workdir = new File(getTestDirectory(), "Cloned"); @@ -233,7 +238,9 @@ public class GitRepositoriesViewBranchHandlingTest extends item = TestUtil.expandAndWait(myRepoViewUtil.getRemoteBranchesItem(tree, clonedRepositoryFile)); children = item.getNodes(); - assertEquals("Wrong number of children", 2, children.size()); + assertEquals("Wrong number of children", 3, children.size()); + assertTrue("Missing remote branch", + children.contains("origin/initial")); assertTrue("Missing remote branch", children.contains("origin/master")); assertTrue("Missing remote branch", children.contains("origin/stable")); item.getNode("origin/stable").select(); @@ -270,7 +277,7 @@ public class GitRepositoriesViewBranchHandlingTest extends item = TestUtil.expandAndWait(myRepoViewUtil.getRemoteBranchesItem(tree, clonedRepositoryFile)); List<String> children = item.getNodes(); - assertEquals("Wrong number of remote children", 2, children.size()); + assertEquals("Wrong number of remote children", 3, children.size()); item.getNode("origin/stable").select(); ContextMenuHelper.clickContextMenuSync(tree, @@ -537,4 +544,52 @@ public class GitRepositoriesViewBranchHandlingTest extends .getNode(UIText.BranchPropertySource_RebaseDescriptor); assertEquals("true", rebaseItem.cell(1)); } + + @Test + public void testBranchConfigurationDecoration() throws Exception { + SWTBotView view = getOrOpenView(); + + SWTBotTreeItem repoItem = myRepoViewUtil.getRootItem(view.bot().tree(), + clonedRepositoryFile); + TestUtil.waitForDecorations(); + String label = repoItem.getText(); + assertTrue("Expected branch decoration to be present: " + label, + label.contains("[master]")); + SWTBotTreeItem localItem = myRepoViewUtil + .getLocalBranchesItem(view.bot().tree(), clonedRepositoryFile); + TestUtil.expandAndWait(localItem).getNode("master").select(); + ContextMenuHelper.clickContextMenu(view.bot().tree(), + myUtil.getPluginLocalizedValue("ConfigurBranchCommand.label")); + + SWTBotShell configureBranchDialog = bot.shell( + UIText.BranchConfigurationDialog_BranchConfigurationTitle); + configureBranchDialog.bot() + .comboBoxWithLabel( + UIText.BranchConfigurationDialog_UpstreamBranchLabel) + .setSelection(0); + // add a listener to wait for the configuration changed event + final AtomicBoolean changed = new AtomicBoolean(); + ConfigChangedListener listener = new ConfigChangedListener() { + @Override + public void onConfigChanged(ConfigChangedEvent event) { + changed.set(true); + } + }; + ListenerHandle handle = lookupRepository(clonedRepositoryFile) + .getConfig().addChangeListener(listener); + // only now click ok + configureBranchDialog.bot() + .button(UIText.BranchConfigurationDialog_ButtonOK).click(); + bot.waitUntil(Conditions.shellCloses(configureBranchDialog)); + // cleanup behind ourselves + handle.remove(); + assertTrue("Expected a ConfigChangeEvent", changed.get()); + TestUtil.waitForJobs(100, 5000); + TestUtil.waitForDecorations(); + repoItem = myRepoViewUtil.getRootItem(view.bot().tree(), + clonedRepositoryFile); + label = repoItem.getText(); + assertTrue("Expected branch decoration to be updated: " + label, + label.contains("[master \u21911]")); + } } |