use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView in project egit by eclipse.
the class GitRepositoriesViewBranchHandlingTest method testBranchConfiguration.
@Test
public void testBranchConfiguration() throws Exception {
Repository repo = lookupRepository(clonedRepositoryFile);
try (Git git = new Git(repo)) {
git.branchCreate().setName("configTest").setStartPoint("refs/remotes/origin/master").setUpstreamMode(SetupUpstreamMode.TRACK).call();
}
BranchRebaseMode rebase = repo.getConfig().getEnum(BranchRebaseMode.values(), ConfigConstants.CONFIG_BRANCH_SECTION, "configTest", ConfigConstants.CONFIG_KEY_REBASE, BranchRebaseMode.NONE);
assertEquals(BranchRebaseMode.NONE, rebase);
SWTBotView view = getOrOpenView();
SWTBotTreeItem localItem = myRepoViewUtil.getLocalBranchesItem(view.bot().tree(), clonedRepositoryFile);
TestUtil.expandAndWait(localItem).getNode("configTest").select();
ContextMenuHelper.clickContextMenuSync(view.bot().tree(), myUtil.getPluginLocalizedValue("ShowIn"), "Properties");
SWTBotView propsView = bot.viewById(IPageLayout.ID_PROP_SHEET);
SWTBotTreeItem rootItem = propsView.bot().tree().getTreeItem(UIText.BranchPropertySource_UpstreamConfigurationCategory);
SWTBotTreeItem rebaseItem = TestUtil.expandAndWait(rootItem).getNode(UIText.BranchPropertySource_RebaseDescriptor);
assertEquals(UIText.BranchPropertySource_ValueNotSet, rebaseItem.cell(1));
SWTBotTreeItem remoteItem = rootItem.getNode(UIText.BranchPropertySource_RemoteDescriptor);
assertEquals("origin", remoteItem.cell(1));
SWTBotTreeItem upstreamItem = rootItem.getNode(UIText.BranchPropertySource_UpstreamBranchDescriptor);
assertEquals("refs/heads/master", upstreamItem.cell(1));
view = getOrOpenView();
localItem = myRepoViewUtil.getLocalBranchesItem(view.bot().tree(), clonedRepositoryFile);
TestUtil.expandAndWait(localItem).getNode("configTest").select();
ContextMenuHelper.clickContextMenu(view.bot().tree(), myUtil.getPluginLocalizedValue("ConfigurBranchCommand.label"));
SWTBotShell configureBranchDialog = bot.shell(UIText.BranchConfigurationDialog_BranchConfigurationTitle);
assertEquals(MessageFormat.format(UIText.BranchConfigurationDialog_EditBranchConfigMessage, "configTest"), configureBranchDialog.bot().text().getText());
assertEquals("refs/heads/master", configureBranchDialog.bot().comboBoxWithLabel(UIText.BranchConfigurationDialog_UpstreamBranchLabel).getText());
assertEquals("origin", configureBranchDialog.bot().comboBoxWithLabel(UIText.BranchConfigurationDialog_RemoteLabel).getText());
assertEquals(UIText.BranchRebaseMode_None, configureBranchDialog.bot().comboBoxWithLabel(UIText.BranchRebaseModeCombo_RebaseModeLabel).getText());
configureBranchDialog.bot().comboBoxWithLabel(UIText.BranchRebaseModeCombo_RebaseModeLabel).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 = repo.getConfig().addChangeListener(listener);
// only now click ok
configureBranchDialog.bot().button("OK").click();
// cleanup behind ourselves
handle.remove();
if (!changed.get())
fail("We should have received a config change event");
// Repo view updates itself after config change.
refreshAndWait();
rebase = repo.getConfig().getEnum(BranchRebaseMode.values(), ConfigConstants.CONFIG_BRANCH_SECTION, "configTest", ConfigConstants.CONFIG_KEY_REBASE, BranchRebaseMode.NONE);
assertEquals(BranchRebaseMode.REBASE, rebase);
localItem = myRepoViewUtil.getLocalBranchesItem(view.bot().tree(), clonedRepositoryFile);
TestUtil.expandAndWait(localItem).getNode("configTest").select();
ContextMenuHelper.clickContextMenu(view.bot().tree(), myUtil.getPluginLocalizedValue("ShowIn"), "Properties");
propsView = bot.viewById(IPageLayout.ID_PROP_SHEET);
rootItem = propsView.bot().tree().getTreeItem(UIText.BranchPropertySource_UpstreamConfigurationCategory);
rebaseItem = TestUtil.expandAndWait(rootItem).getNode(UIText.BranchPropertySource_RebaseDescriptor);
assertEquals("true", rebaseItem.cell(1));
}
use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView in project egit by eclipse.
the class GitRepositoriesViewFetchAndPushTest method testPushToOrigin.
private void testPushToOrigin(boolean useRemote) throws Exception {
Activator.getDefault().getRepositoryUtil().addConfiguredRepository(clonedRepositoryFile);
shareProjects(clonedRepositoryFile);
Repository repository = lookupRepository(clonedRepositoryFile);
// add the configuration for push
repository.getConfig().setString("remote", "origin", "push", "refs/heads/*:refs/remotes/origin/*");
repository.getConfig().save();
// make sure to have a "new" branch name so that the
// dialog will return with a corresponding message
SWTBotView repoView = getOrOpenView();
String currentBranch = repository.getBranch();
try (Git git = new Git(repository)) {
git.branchRename().setOldName(currentBranch).setNewName("" + System.currentTimeMillis()).call();
}
Job.getJobManager().join(JobFamilies.REPO_VIEW_REFRESH, null);
SWTBotTree tree = repoView.bot().tree();
tree.select(0);
selectNode(tree, useRemote, false);
runPush(tree);
String destinationString = clonedRepositoryFile.getParentFile().getName() + " - " + "origin";
String dialogTitle = NLS.bind(UIText.PushResultDialog_title, destinationString);
// first time: expect new branch
bot.waitUntil(Conditions.shellIsActive(dialogTitle));
SWTBotShell confirmed = bot.shell(dialogTitle);
SWTBotTreeItem[] treeItems = confirmed.bot().tree().getAllItems();
boolean newBranch = false;
for (SWTBotTreeItem item : treeItems) {
newBranch = item.getText().contains(UIText.PushResultTable_statusOkNewBranch);
if (newBranch)
break;
}
confirmed.close();
assertTrue("New branch expected", newBranch);
// second time: expect up to date
selectNode(tree, useRemote, false);
runPush(tree);
bot.waitUntil(Conditions.shellIsActive(dialogTitle));
confirmed = bot.shell(dialogTitle);
treeItems = confirmed.bot().tree().getAllItems();
boolean uptodate = false;
for (SWTBotTreeItem item : treeItems) {
uptodate = item.getText().contains(UIText.PushResultTable_statusUpToDate);
if (uptodate)
break;
}
confirmed.close();
assertTrue("Up to date expected", uptodate);
// touch and run again: expect new branch
String objectIdBefore = repository.exactRef(repository.getFullBranch()).getLeaf().getObjectId().name();
objectIdBefore = objectIdBefore.substring(0, 7);
touchAndSubmit(null);
SWTBotTree updatedTree = getOrOpenView().bot().tree();
updatedTree.select(0);
selectNode(updatedTree, useRemote, false);
runPush(updatedTree);
bot.waitUntil(Conditions.shellIsActive(dialogTitle));
confirmed = bot.shell(dialogTitle);
treeItems = confirmed.bot().tree().getAllItems();
newBranch = false;
for (SWTBotTreeItem item : treeItems) {
newBranch = item.getText().contains(objectIdBefore);
if (newBranch)
break;
}
confirmed.close();
assertTrue("New branch expected", newBranch);
}
use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView in project egit by eclipse.
the class GitRepositoriesViewTest method testLinkWithSelectionEditor.
/**
* Link with editor, both ways
*
* @throws Exception
*/
@Test
@Ignore("'Link with Selection' does not activate editor on selection change (bug 409722).")
public void testLinkWithSelectionEditor() throws Exception {
deleteAllProjects();
shareProjects(repositoryFile);
SWTBotTree tree = getOrOpenView().bot().tree();
myRepoViewUtil.getRootItem(tree, repositoryFile).select();
// the selection should be root
assertTrue(tree.selection().get(0, 0).startsWith(REPO1));
SWTBotView view = TestUtil.showExplorerView();
SWTBotTree projectExplorerTree = view.bot().tree();
SWTBotTreeItem item = TestUtil.expandAndWait(getProjectItem(projectExplorerTree, PROJ1));
item = TestUtil.expandAndWait(item.getNode(FOLDER)).getNode(FILE1);
view.show();
item.doubleClick();
item = TestUtil.expandAndWait(getProjectItem(projectExplorerTree, PROJ1));
item = TestUtil.expandAndWait(item.getNode(FOLDER)).getNode(FILE2);
view.show();
item.doubleClick();
// now we should have two editors
// the selection should be still be root
assertTrue(tree.selection().get(0, 0).startsWith(REPO1));
// activate the link with selection
toggleLinkWithSelection();
bot.editorByTitle(FILE2).show();
// the selection should have changed to the latest editor
TestUtil.waitUntilTreeHasSelectedNodeWithText(bot, tree, FILE2, 10000);
bot.editorByTitle(FILE1).show();
// selection should have changed
TestUtil.waitUntilTreeHasSelectedNodeWithText(bot, tree, FILE1, 10000);
// deactivate the link with editor
toggleLinkWithSelection();
bot.editorByTitle(FILE2).show();
// the selection should be still be test.txt
TestUtil.waitUntilTreeHasSelectedNodeWithText(bot, tree, FILE1, 10000);
bot.editorByTitle(FILE1).show();
item = TestUtil.expandAndWait(myRepoViewUtil.getWorkdirItem(tree, repositoryFile));
item = TestUtil.expandAndWait(item.getNode(PROJ1));
item = TestUtil.expandAndWait(item.getNode(FOLDER));
item.getNode(FILE2).select();
// the editor should still be test.txt
assertEquals(FILE1, bot.activeEditor().getTitle());
// activate again
toggleLinkWithSelection();
// make sure focus is here
// tried to remove this waitInUI but failed.
// tried setting focus, waiting for focus, joining RepositoriesView
// refresh job
waitInUI();
item = TestUtil.expandAndWait(myRepoViewUtil.getWorkdirItem(tree, repositoryFile));
item = TestUtil.expandAndWait(item.getNode(PROJ1));
item = TestUtil.expandAndWait(item.getNode(FOLDER));
item.getNode(FILE2).select();
TestUtil.waitUntilEditorIsActive(bot, bot.editorByTitle(FILE2), 10000);
item = TestUtil.expandAndWait(myRepoViewUtil.getWorkdirItem(tree, repositoryFile));
item = TestUtil.expandAndWait(item.getNode(PROJ1));
item = TestUtil.expandAndWait(item.getNode(FOLDER));
item.getNode(FILE1).select();
TestUtil.waitUntilEditorIsActive(bot, bot.editorByTitle(FILE1), 10000);
// deactivate the link with editor
toggleLinkWithSelection();
item = TestUtil.expandAndWait(myRepoViewUtil.getWorkdirItem(tree, repositoryFile));
item = TestUtil.expandAndWait(item.getNode(PROJ1));
item = TestUtil.expandAndWait(item.getNode(FOLDER));
item.getNode(FILE2).select();
TestUtil.waitUntilEditorIsActive(bot, bot.editorByTitle(FILE1), 10000);
}
use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView in project egit by eclipse.
the class GitRepositoriesViewTest method testShowProperties.
/**
* Show properties
*
* @throws Exception
*/
@Test
public void testShowProperties() throws Exception {
SWTBotTree tree = getOrOpenView().bot().tree();
SWTBotTreeItem item = myRepoViewUtil.getRootItem(tree, repositoryFile);
item.select();
ContextMenuHelper.clickContextMenuSync(tree, myUtil.getPluginLocalizedValue("ShowIn"), "Properties");
SWTBotView propertieView = bot.viewById(IPageLayout.ID_PROP_SHEET);
assertTrue(propertieView.isActive());
}
use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView in project egit by eclipse.
the class GitRepositoriesViewTestBase method assertEmpty.
protected void assertEmpty() throws Exception {
final SWTBotView view = getOrOpenView();
view.bot().label(UIText.RepositoriesView_messsageEmpty);
}
Aggregations