use of com.oxygenxml.git.view.staging.WorkingCopySelectionPanel in project oxygen-git-client-addon by oxygenxml.
the class WorkingCopySelectorTest method testClearHistory.
/**
* <p><b>Description:</b> test the "Clear history..." action.</p>
* <p><b>Bug ID:</b> EXM-44205</p>
*
* @author sorin_carbunaru
*
* @throws Exception When failing.
*/
public void testClearHistory() throws Exception {
JFrame frame = new JFrame();
try {
GitControllerBase mock = Mockito.mock(GitControllerBase.class);
GitAccess instance = GitAccess.getInstance();
Mockito.when(mock.getGitAccess()).thenReturn(instance);
WorkingCopySelectionPanel wcPanel = new WorkingCopySelectionPanel(mock, true);
frame.getContentPane().add(wcPanel);
frame.pack();
// Showing the WC panel also initializes the combo
SwingUtilities.invokeAndWait(() -> frame.setVisible(true));
sleep(150);
JComboBox<String> workingCopyCombo = wcPanel.getWorkingCopyCombo();
ComboBoxModel<String> model = workingCopyCombo.getModel();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < model.getSize(); i++) {
sb.append(model.getElementAt(i)).append("\n");
}
assertEquals("D:/folder/WC1\n" + "D:/folder/WC2\n" + "D:/folder_doi/WC\n" + "CLEAR_HISTORY\n", sb.toString());
SwingUtilities.invokeAndWait(() -> workingCopyCombo.setSelectedItem("CLEAR_HISTORY"));
sleep(150);
sb = new StringBuilder();
for (int i = 0; i < model.getSize(); i++) {
sb.append(model.getElementAt(i)).append("\n");
}
assertEquals("D:/folder/WC1\n", sb.toString());
} finally {
frame.setVisible(false);
frame.dispose();
}
}
use of com.oxygenxml.git.view.staging.WorkingCopySelectionPanel in project oxygen-git-client-addon by oxygenxml.
the class WorkingCopySelector2Test method testRemoveStaleEntries.
/**
* <p><b>Description:</b> A non existing repository is removed from the combo.</p>
* <p><b>Bug ID:</b> EXM-44820</p>
*
* @author alex_jitianu
*
* @throws Exception When failing.
*/
@Test
public void testRemoveStaleEntries() throws Exception {
JFrame frame = new JFrame();
try {
WorkingCopySelectionPanel wcPanel = new WorkingCopySelectionPanel(new GitController(), true);
frame.getContentPane().add(wcPanel);
frame.pack();
// Showing the WC panel also initializes the combo
frame.setVisible(true);
JComboBox<String> workingCopyCombo = wcPanel.getWorkingCopyCombo();
ComboBoxModel<String> model = workingCopyCombo.getModel();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < model.getSize(); i++) {
sb.append(model.getElementAt(i)).append("\n");
}
assertEquals(wcTree.getAbsolutePath() + "\n" + badWcTree.getAbsolutePath() + "\n" + "CLEAR_HISTORY\n" + "", sb.toString());
// Select the bad WC.
workingCopyCombo.setSelectedItem(badWcTree.getAbsolutePath());
// Wait for the selection task to be completed by posting another task and waiting for its end.
ScheduledFuture<?> schedule = GitOperationScheduler.getInstance().schedule(() -> {
});
schedule.get();
sleep(300);
sb = new StringBuilder();
for (int i = 0; i < model.getSize(); i++) {
sb.append(model.getElementAt(i)).append("\n");
}
assertEquals(wcTree.getAbsolutePath() + "\n" + "CLEAR_HISTORY\n" + "", sb.toString());
assertEquals(wcTree.getAbsolutePath(), workingCopyCombo.getSelectedItem().toString());
assertEquals("[" + badWcTree.getAbsolutePath() + "]", removedRepositories.toString());
} finally {
frame.setVisible(false);
frame.dispose();
}
}
Aggregations