diff options
author | Matthias Sohn | 2014-09-30 21:54:45 +0000 |
---|---|---|
committer | Matthias Sohn | 2014-09-30 21:55:06 +0000 |
commit | c32855d0938ef4cea8f265bb60f64bbf83ba0f05 (patch) | |
tree | 256387a66e8cc69195af0ded577d7c5928abfd66 /org.eclipse.egit.ui.test | |
parent | fe9238c6fefcc6866f0d92bec85e81c7fc0187cc (diff) | |
parent | 11830c822afb7e316beb1343826f21301b152e30 (diff) | |
download | egit-c32855d0938ef4cea8f265bb60f64bbf83ba0f05.tar.gz egit-c32855d0938ef4cea8f265bb60f64bbf83ba0f05.tar.xz egit-c32855d0938ef4cea8f265bb60f64bbf83ba0f05.zip |
Merge branch 'stable-3.5'
* stable-3.5:
Fix "Stashes" menu not being shown in Team menu
Change-Id: I27a86d1d218cf9101d19e70d14d3cda8ad2c1866
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.ui.test')
-rw-r--r-- | org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/actions/StashesMenuTest.java | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/actions/StashesMenuTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/actions/StashesMenuTest.java new file mode 100644 index 0000000000..f006a8fa9f --- /dev/null +++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/actions/StashesMenuTest.java @@ -0,0 +1,91 @@ +/******************************************************************************* + * Copyright (c) 2014 Robin Stocker <robin@nibor.org> and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.egit.ui.internal.actions; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.text.MessageFormat; + +import org.eclipse.egit.ui.common.LocalRepositoryTestCase; +import org.eclipse.egit.ui.internal.UIText; +import org.eclipse.egit.ui.test.ContextMenuHelper; +import org.eclipse.egit.ui.test.TestUtil; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; +import org.junit.Before; +import org.junit.Test; + +/** + * Test for Team > Stashes menu. + */ +public class StashesMenuTest extends LocalRepositoryTestCase { + + private static final String STASHES = util + .getPluginLocalizedValue("StashesMenu.label"); + + @Before + public void createRepository() throws Exception { + createProjectAndCommitToRepository(); + } + + @Test + public void menuWithoutStashes() { + SWTBotTree tree = selectProject(); + assertTrue(ContextMenuHelper.isContextMenuItemEnabled(tree, "Team", + STASHES)); + assertFalse(ContextMenuHelper.isContextMenuItemEnabled(tree, "Team", + STASHES, UIText.StashesMenu_NoStashedChangesText)); + } + + @Test + public void stashAndApplyChanges() throws Exception { + String originalContent = getTestFileContent(); + + String modifiedContent = "changes to stash"; + touch(modifiedContent); + assertEquals(modifiedContent, getTestFileContent()); + + ContextMenuHelper.clickContextMenu(selectProject(), "Team", STASHES, + UIText.StashesMenu_StashChangesActionText); + + SWTBotShell createDialog = bot + .shell(UIText.StashCreateCommand_titleEnterCommitMessage); + SWTBotText enterMessageText = createDialog.bot().text(0); + String stashMessage = "stash message"; + enterMessageText.setText(stashMessage); + createDialog.bot().button(IDialogConstants.OK_LABEL).click(); + + assertEquals(originalContent, getTestFileContent()); + + ContextMenuHelper.clickContextMenu(selectProject(), "Team", STASHES, + MessageFormat.format(UIText.StashesMenu_StashItemText, + Integer.valueOf(0), stashMessage)); + + SWTBotEditor stashEditor = bot.activeEditor(); + // Check if text with message is there + stashEditor.bot().styledText(stashMessage); + + stashEditor.bot() + .toolbarButtonWithTooltip( + util.getPluginLocalizedValue("StashApplyCommand.label")) + .click(); + + assertEquals(modifiedContent, getTestFileContent()); + } + + private SWTBotTree selectProject() { + SWTBotTree tree = TestUtil.getExplorerTree(); + TestUtil.getNode(tree.getAllItems(), PROJ1).select(); + return tree; + } +} |