Search in sources :

Example 51 with SWTBotShell

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project egit by eclipse.

the class SynchronizeViewRemoteAwareChangeSetModelTest method shouldShowRemoteFilesInSynchronization.

/**
 * Make sure that files that are not part of the logical model because of
 * remote file content will be taken into account in the comparison.
 *
 * @throws Exception
 */
@Test
public void shouldShowRemoteFilesInSynchronization() throws Exception {
    // given
    createMockLogicalRepository();
    // when comparing file 'index.mocklogical' with branch 'stable'
    String compareWithBranchActionLabel = util.getPluginLocalizedValue("ReplaceWithRefAction_label");
    clickCompareWith(compareWithBranchActionLabel);
    SWTBotShell compareShell = bot.shell("Compare");
    SWTBotTree tree = compareShell.bot().tree();
    for (SWTBotTreeItem item : tree.getTreeItem("Local").getItems()) {
        if (item.getText().contains("stable")) {
            tree.select(item);
            break;
        }
    }
    bot.button("Compare").click();
    // then
    SWTBotTree syncViewTree = bot.viewById(ISynchronizeView.VIEW_ID).bot().tree();
    SWTBotTreeItem mockLogicalProjectItem = waitForNodeWithText(syncViewTree, MOCK_LOGICAL_PROJECT);
    SWTBotTreeItem[] items = mockLogicalProjectItem.getItems();
    assertEquals(4, items.length);
    SWTBotTreeItem fileTree = items[0];
    assertEquals("file1.txt", fileTree.getText());
    fileTree = items[1];
    assertEquals("file2.txt", fileTree.getText());
    fileTree = items[2];
    assertEquals("file3.txt", fileTree.getText());
    fileTree = items[3];
    assertEquals("index.mocklogical", fileTree.getText());
}
Also used : SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Test(org.junit.Test)

Example 52 with SWTBotShell

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project egit by eclipse.

the class ReplaceActionsTest method testReplaceWithPrevious.

@Test
public void testReplaceWithPrevious() throws Exception {
    touchAndSubmit(null);
    String initialContent = getTestFileContent();
    String menuLabel = util.getPluginLocalizedValue("ReplaceWithPreviousVersionAction.label");
    clickReplaceWith(menuLabel);
    SWTBotShell confirm = bot.shell(UIText.DiscardChangesAction_confirmActionTitle);
    executeReplace(confirm, UIText.DiscardChangesAction_discardChangesButtonText);
    String replacedContent = getTestFileContent();
    assertThat(replacedContent, not(initialContent));
}
Also used : SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Test(org.junit.Test)

Example 53 with SWTBotShell

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project egit by eclipse.

the class ReplaceActionsTest method testReplaceWithPreviousWithMerge.

@Test
public void testReplaceWithPreviousWithMerge() throws Exception {
    Repository repo = lookupRepository(repositoryFile);
    try (Git git = new Git(repo)) {
        Calendar cal = Calendar.getInstance();
        long time = cal.getTime().getTime();
        PersonIdent sideCommitter = new PersonIdent("Side Committer", "side@example.org", time, 0);
        // Make sure commit time stamps are different, otherwise the order
        // in the dialog is not stable
        time += 5000;
        PersonIdent masterCommitter = new PersonIdent("Master Committer", "master@example.org", time, 0);
        git.checkout().setCreateBranch(true).setName("side").call();
        touch(PROJ1, "folder/test.txt", "side");
        RevCommit sideCommit = git.commit().setAll(true).setMessage("Side commit").setCommitter(sideCommitter).call();
        git.checkout().setName("master").call();
        touch(PROJ1, "folder/test2.txt", "master");
        git.commit().setAll(true).setMessage("Master commit").setCommitter(masterCommitter).call();
        git.merge().include(sideCommit).call();
    }
    TestUtil.waitForJobs(100, 5000);
    String contentAfterMerge = getTestFileContent();
    assertEquals("side", contentAfterMerge);
    String menuLabel = util.getPluginLocalizedValue("ReplaceWithPreviousVersionAction.label");
    clickReplaceWith(menuLabel);
    bot.shell(UIText.DiscardChangesAction_confirmActionTitle).bot().button(UIText.DiscardChangesAction_discardChangesButtonText).click();
    SWTBotShell selectDialog = bot.shell(UIText.CommitSelectDialog_WindowTitle);
    assertEquals(2, selectDialog.bot().table().rowCount());
    selectDialog.close();
    TestUtil.processUIEvents();
    // we have closed, so nothing should have changed
    String contentAfterClose = getTestFileContent();
    assertEquals(contentAfterMerge, contentAfterClose);
    clickReplaceWith(menuLabel);
    bot.shell(UIText.DiscardChangesAction_confirmActionTitle).bot().button(UIText.DiscardChangesAction_discardChangesButtonText).click();
    TestUtil.waitForJobs(100, 5000);
    selectDialog = bot.shell(UIText.CommitSelectDialog_WindowTitle);
    // Select first parent, which should be the master commit
    SWTBotTable table = selectDialog.bot().table();
    assertEquals("Master commit", table.cell(0, 1));
    table.select(0);
    executeReplace(selectDialog, IDialogConstants.OK_LABEL);
    TestUtil.waitForJobs(100, 5000);
    String replacedContent = getTestFileContent();
    assertThat(replacedContent, not(contentAfterMerge));
}
Also used : Repository(org.eclipse.jgit.lib.Repository) Git(org.eclipse.jgit.api.Git) PersonIdent(org.eclipse.jgit.lib.PersonIdent) Calendar(java.util.Calendar) SWTBotTable(org.eclipse.swtbot.swt.finder.widgets.SWTBotTable) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Example 54 with SWTBotShell

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project egit by eclipse.

the class TagActionTest method testChangeTagMessage.

@Test
public void testChangeTagMessage() throws Exception {
    SWTBotShell tagDialog = openTagDialog();
    assertFalse("Ok should be disabled", tagDialog.bot().button(UIText.CreateTagDialog_CreateTagButton).isEnabled());
    tagDialog.bot().textWithLabel(UIText.CreateTagDialog_tagName).setText("MessageChangeTag");
    assertFalse("Ok should be disabled", tagDialog.bot().button(UIText.CreateTagDialog_CreateTagButton).isEnabled());
    tagDialog.bot().styledTextWithLabel(UIText.CreateTagDialog_tagMessage).setText("Here's the first message");
    tagDialog.bot().button(UIText.CreateTagDialog_CreateTagButton).click();
    waitInUI();
    assertTrue(lookupRepository(repositoryFile).getTags().keySet().contains("MessageChangeTag"));
    tagDialog = openTagDialog();
    tagDialog.bot().tableWithLabel(UIText.CreateTagDialog_existingTags).getTableItem("MessageChangeTag").select();
    assertFalse("Ok should be disabled", tagDialog.bot().button(UIText.CreateTagDialog_CreateTagButton).isEnabled());
    String oldText = tagDialog.bot().styledTextWithLabel(UIText.CreateTagDialog_tagMessage).getText();
    assertEquals("Wrong message text", "Here's the first message", oldText);
    tagDialog.bot().checkBox(UIText.CreateTagDialog_overwriteTag).click();
    tagDialog.bot().styledTextWithLabel(UIText.CreateTagDialog_tagMessage).setText("New message");
    tagDialog.bot().button(UIText.CreateTagDialog_CreateTagButton).click();
    tagDialog = openTagDialog();
    tagDialog.bot().tableWithLabel(UIText.CreateTagDialog_existingTags).getTableItem("MessageChangeTag").select();
    String newText = tagDialog.bot().styledTextWithLabel(UIText.CreateTagDialog_tagMessage).getText();
    assertEquals("Wrong message text", "New message", newText);
    tagDialog.close();
}
Also used : SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Test(org.junit.Test)

Example 55 with SWTBotShell

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project egit by eclipse.

the class TagActionTest method testCreateTag.

@Test
public void testCreateTag() throws Exception {
    SWTBotShell tagDialog = openTagDialog();
    tagDialog.bot().textWithLabel(UIText.CreateTagDialog_tagName).setText("SomeTag");
    assertFalse("Ok should be disabled", tagDialog.bot().button(UIText.CreateTagDialog_CreateTagButton).isEnabled());
    tagDialog.bot().button(UIText.CreateTagDialog_clearButton).click();
    tagDialog.bot().textWithLabel(UIText.CreateTagDialog_tagName).setText("AnotherTag");
    assertFalse("Ok should be disabled", tagDialog.bot().button(UIText.CreateTagDialog_CreateTagButton).isEnabled());
    tagDialog.bot().styledTextWithLabel(UIText.CreateTagDialog_tagMessage).setText("Here's the message text");
    tagDialog.bot().button(UIText.CreateTagDialog_CreateTagButton).click();
    waitInUI();
    assertTrue(lookupRepository(repositoryFile).getTags().keySet().contains("AnotherTag"));
}
Also used : SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Test(org.junit.Test)

Aggregations

SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)158 Test (org.junit.Test)82 SWTBotTree (org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)46 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)40 Repository (org.eclipse.jgit.lib.Repository)18 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)11 SWTBotTable (org.eclipse.swtbot.swt.finder.widgets.SWTBotTable)11 File (java.io.File)10 SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)9 SWTBotText (org.eclipse.swtbot.swt.finder.widgets.SWTBotText)9 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)7 WidgetNotFoundException (org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)7 SWTBotCombo (org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo)7 Path (org.eclipse.core.runtime.Path)6 JobJoiner (org.eclipse.egit.ui.test.JobJoiner)6 Shell (org.eclipse.swt.widgets.Shell)6 SWTBotButton (org.eclipse.swtbot.swt.finder.widgets.SWTBotButton)6 IProject (org.eclipse.core.resources.IProject)5 SWTBotEclipseEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor)5 ICondition (org.eclipse.swtbot.swt.finder.waits.ICondition)5