use of com.oxygenxml.git.view.staging.ToolbarPanel in project oxygen-git-client-addon by oxygenxml.
the class StashVisualTests method testListStashesTableValues.
/**
* <p><b>Description:</b> Tests the "List stashes" table values</p>
* <p><b>Bug ID:</b> EXM-45983</p>
*
* @author Alex_Smarandache
*
* @throws Exception
*/
public void testListStashesTableValues() throws Exception {
// Make the first commit for the local repository
File file = new File(LOCAL_REPO, "local.txt");
file.createNewFile();
setFileContent(file, "local content");
gitAccess.add(new FileStatus(GitChangeType.ADD, "local.txt"));
gitAccess.commit("First local commit.");
// Make the first commit for the remote repository
gitAccess.setRepositorySynchronously(REMOTE_REPO);
file = new File(REMOTE_REPO, "remote1.txt");
file.createNewFile();
setFileContent(file, "remote content");
gitAccess.add(new FileStatus(GitChangeType.ADD, "remote1.txt"));
gitAccess.commit("First remote commit.");
// Switch back to local repo and create local branch
gitAccess.setRepositorySynchronously(LOCAL_REPO);
gitAccess.createBranch(LOCAL_BRANCH);
gitAccess.fetch();
JFrame frame = new JFrame();
try {
// Init UI
GitController gitCtrl = new GitController();
GitActionsManager gitActionsManager = new GitActionsManager(gitCtrl, null, null, refreshSupport);
stagingPanel = new StagingPanel(refreshSupport, gitCtrl, null, gitActionsManager);
ToolbarPanel toolbarPanel = stagingPanel.getToolbarPanel();
frame.getContentPane().add(stagingPanel);
frame.pack();
frame.setVisible(true);
flushAWT();
toolbarPanel.updateButtonsStates();
refreshSupport.call();
flushAWT();
SplitMenuButton stashButton = toolbarPanel.getStashButton();
initStashes(toolbarPanel);
List<RevCommit> stashes = new ArrayList<>(gitAccess.listStashes());
assertEquals(3, stashes.size());
JMenuItem[] listStashesItem = new JMenuItem[1];
listStashesItem[0] = stashButton.getItem(1);
SwingUtilities.invokeLater(() -> listStashesItem[0].getAction().actionPerformed(null));
ListStashesDialog listStashesDialog = (ListStashesDialog) findDialog(Tags.STASHES);
assertNotNull(listStashesDialog);
StashesTableModel model = (StashesTableModel) listStashesDialog.getStashesTable().getModel();
assertEquals(3, model.getRowCount());
assertEquals(stashes.get(0).getFullMessage(), model.getValueAt(0, StashesTableModel.STASH_DESCRIPTION_COLUMN));
assertEquals(stashes.get(1).getFullMessage(), model.getValueAt(1, StashesTableModel.STASH_DESCRIPTION_COLUMN));
assertEquals(stashes.get(2).getFullMessage(), model.getValueAt(2, StashesTableModel.STASH_DESCRIPTION_COLUMN));
assertEquals(stashes.get(0).getAuthorIdent().getWhen(), model.getValueAt(0, StashesTableModel.STASH_DATE_COLUMN));
assertEquals(stashes.get(1).getAuthorIdent().getWhen(), model.getValueAt(1, StashesTableModel.STASH_DATE_COLUMN));
assertEquals(stashes.get(2).getAuthorIdent().getWhen(), model.getValueAt(2, StashesTableModel.STASH_DATE_COLUMN));
JButton cancelButton = findFirstButton(listStashesDialog, Tags.CLOSE);
assertNotNull(cancelButton);
cancelButton.doClick();
} finally {
frame.setVisible(false);
frame.dispose();
}
}
use of com.oxygenxml.git.view.staging.ToolbarPanel in project oxygen-git-client-addon by oxygenxml.
the class StashVisualTests method testListStashDeleteAllAction.
/**
* <p><b>Description:</b> Tests the "List stashes" delete all action</p>
* <p><b>Bug ID:</b> EXM-45983</p>
*
* @author Alex_Smarandache
*
* @throws Exception
*/
public void testListStashDeleteAllAction() throws Exception {
// Make the first commit for the local repository
File file = new File(LOCAL_REPO, "local.txt");
file.createNewFile();
setFileContent(file, "local content");
gitAccess.add(new FileStatus(GitChangeType.ADD, "local.txt"));
gitAccess.commit("First local commit.");
// Make the first commit for the remote repository
gitAccess.setRepositorySynchronously(REMOTE_REPO);
file = new File(REMOTE_REPO, "remote1.txt");
file.createNewFile();
setFileContent(file, "remote content");
gitAccess.add(new FileStatus(GitChangeType.ADD, "remote1.txt"));
gitAccess.commit("First remote commit.");
// Switch back to local repo and create local branch
gitAccess.setRepositorySynchronously(LOCAL_REPO);
gitAccess.createBranch(LOCAL_BRANCH);
gitAccess.fetch();
JFrame frame = new JFrame();
try {
// Init UI
GitController gitCtrl = new GitController();
GitActionsManager gitActionsManager = new GitActionsManager(gitCtrl, null, null, refreshSupport);
stagingPanel = new StagingPanel(refreshSupport, gitCtrl, null, gitActionsManager);
ToolbarPanel toolbarPanel = stagingPanel.getToolbarPanel();
frame.getContentPane().add(stagingPanel);
frame.pack();
frame.setVisible(true);
flushAWT();
toolbarPanel.updateButtonsStates();
refreshSupport.call();
flushAWT();
SplitMenuButton stashButton = toolbarPanel.getStashButton();
initStashes(toolbarPanel);
List<RevCommit> stashes = new ArrayList<>(gitAccess.listStashes());
assertEquals(3, stashes.size());
JMenuItem[] listStashesItem = new JMenuItem[1];
listStashesItem[0] = stashButton.getItem(1);
SwingUtilities.invokeLater(() -> listStashesItem[0].getAction().actionPerformed(null));
ListStashesDialog listStashesDialog = (ListStashesDialog) findDialog(Tags.STASHES);
assertNotNull(listStashesDialog);
assertEquals(3, listStashesDialog.getStashesTable().getModel().getRowCount());
assertEquals(1, listStashesDialog.getAffectedFilesTable().getModel().getRowCount());
JButton[] deleteAllStashesButton = new JButton[1];
deleteAllStashesButton[0] = findFirstButton(listStashesDialog, Tags.DELETE_ALL);
assertNotNull(deleteAllStashesButton);
SwingUtilities.invokeLater(() -> deleteAllStashesButton[0].doClick());
flushAWT();
// Test the no button.
JDialog deleteAllStashesDialog = findDialog(Tags.DELETE_ALL_STASHES);
assertNotNull(deleteAllStashesDialog);
JButton[] noButton = new JButton[1];
flushAWT();
noButton[0] = findFirstButton(deleteAllStashesDialog, Tags.NO);
assertNotNull(noButton[0]);
SwingUtilities.invokeLater(() -> noButton[0].doClick());
flushAWT();
stashes = new ArrayList<>(gitAccess.listStashes());
assertEquals(3, stashes.size());
flushAWT();
JButton cancelButton = findFirstButton(listStashesDialog, Tags.CLOSE);
assertNotNull(cancelButton);
cancelButton.doClick();
listStashesItem[0] = stashButton.getItem(1);
SwingUtilities.invokeLater(() -> listStashesItem[0].getAction().actionPerformed(null));
flushAWT();
listStashesDialog = (ListStashesDialog) findDialog(Tags.STASHES);
assertNotNull(listStashesDialog);
deleteAllStashesButton[0] = findFirstButton(listStashesDialog, Tags.DELETE_ALL);
assertNotNull(deleteAllStashesButton);
SwingUtilities.invokeLater(() -> deleteAllStashesButton[0].doClick());
flushAWT();
// Test the yes button.
deleteAllStashesDialog = findDialog(Tags.DELETE_ALL_STASHES);
assertNotNull(deleteAllStashesDialog);
flushAWT();
JButton yesButton = findFirstButton(deleteAllStashesDialog, Tags.YES);
assertNotNull(yesButton);
SwingUtilities.invokeLater(yesButton::doClick);
flushAWT();
stashes = new ArrayList<>(gitAccess.listStashes());
assertEquals(0, stashes.size());
cancelButton = findFirstButton(listStashesDialog, Tags.CLOSE);
assertNotNull(cancelButton);
cancelButton.doClick();
} finally {
frame.setVisible(false);
frame.dispose();
}
}
Aggregations