Tests - fixed tests for Version Control actions in the 'Find Checkouts'

dialog
This commit is contained in:
dragonmacher 2019-12-05 11:14:05 -05:00
parent ea4407f0e8
commit 725bdee15e
4 changed files with 33 additions and 42 deletions

View file

@ -152,7 +152,7 @@ public abstract class AbstractDockingTool implements DockingTool {
@Override @Override
public void showDialog(DialogComponentProvider dialogComponent) { public void showDialog(DialogComponentProvider dialogComponent) {
DockingWindowManager.showDialog(getToolFrame(), dialogComponent); DockingWindowManager.showDialog(null, dialogComponent);
} }
public JFrame getToolFrame() { public JFrame getToolFrame() {

View file

@ -75,7 +75,7 @@ public class VersionControlShowHistoryAction extends VersionControlAction {
} }
VersionHistoryDialog dialog = new VersionHistoryDialog(domainFiles.get(0)); VersionHistoryDialog dialog = new VersionHistoryDialog(domainFiles.get(0));
tool.showDialog(dialog, tool.getToolFrame()); tool.showDialog(dialog);
} }
} }

View file

@ -27,6 +27,7 @@ import javax.swing.*;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import docking.ActionContext;
import docking.DialogComponentProvider; import docking.DialogComponentProvider;
import docking.action.DockingActionIf; import docking.action.DockingActionIf;
import docking.widgets.table.*; import docking.widgets.table.*;
@ -212,16 +213,18 @@ public class VersionControlAction1Test extends AbstractVersionControlActionTest
waitForTasks(); waitForTasks();
// make some changes to check in // make some changes to check in
Program program = (Program) ((DomainFileNode) node).getDomainFile().getDomainObject(this, Program program = (Program) ((DomainFileNode) node).getDomainFile()
true, false, TaskMonitor.DUMMY); .getDomainObject(this,
true, false, TaskMonitor.DUMMY);
editProgram(program, (p) -> { editProgram(program, (p) -> {
SymbolTable symTable = p.getSymbolTable(); SymbolTable symTable = p.getSymbolTable();
symTable.createLabel(p.getMinAddress().getNewAddress(0x010001000), "fred", symTable.createLabel(p.getMinAddress().getNewAddress(0x010001000), "fred",
SourceType.USER_DEFINED); SourceType.USER_DEFINED);
}); });
program = (Program) ((DomainFileNode) xnode).getDomainFile().getDomainObject(this, true, program = (Program) ((DomainFileNode) xnode).getDomainFile()
false, TaskMonitor.DUMMY); .getDomainObject(this, true,
false, TaskMonitor.DUMMY);
editProgram(program, (p) -> { editProgram(program, (p) -> {
SymbolTable symTable = p.getSymbolTable(); SymbolTable symTable = p.getSymbolTable();
symTable.createLabel(p.getMinAddress(), "bob", SourceType.USER_DEFINED); symTable.createLabel(p.getMinAddress(), "bob", SourceType.USER_DEFINED);
@ -250,8 +253,9 @@ public class VersionControlAction1Test extends AbstractVersionControlActionTest
checkout(programNode); checkout(programNode);
Program program = Program program =
(Program) ((DomainFileNode) programNode).getDomainFile().getDomainObject(this, true, (Program) ((DomainFileNode) programNode).getDomainFile()
false, TaskMonitor.DUMMY); .getDomainObject(this, true,
false, TaskMonitor.DUMMY);
createHistoryEntry(program, "Symbol1"); createHistoryEntry(program, "Symbol1");
frontEnd.checkIn(programNode, "This is checkin 1"); frontEnd.checkIn(programNode, "This is checkin 1");
@ -559,25 +563,17 @@ public class VersionControlAction1Test extends AbstractVersionControlActionTest
FindCheckoutsTableModel model = (FindCheckoutsTableModel) table.getModel(); FindCheckoutsTableModel model = (FindCheckoutsTableModel) table.getModel();
assertEquals(2, model.getRowCount()); assertEquals(2, model.getRowCount());
assertEquals(4, model.getColumnCount()); assertEquals(4, model.getColumnCount());
JButton checkInButton = DockingActionIf undoCheckoutAction = getAction("UndoCheckOut");
findButtonByIcon(dialog, ResourceManager.loadImage("images/vcCheckIn.png")); DockingActionIf checkInAction = getAction("CheckIn");
assertFalse(checkInAction.isEnabledForContext(dialog.getActionContext(null)));
assertNotNull(checkInButton); assertFalse(undoCheckoutAction.isEnabledForContext(dialog.getActionContext(null)));
JButton undoCheckoutButton =
findButtonByIcon(dialog, ResourceManager.loadImage("images/vcUndoCheckOut.png"));
assertNotNull(undoCheckoutButton);
assertTrue(!checkInButton.isEnabled());
assertTrue(!undoCheckoutButton.isEnabled());
// make a selection in the table // make a selection in the table
selectInTable(table, node); selectInTable(table, node);
assertTrue(checkInButton.isEnabled()); assertFalse(checkInAction.isEnabledForContext(dialog.getActionContext(null)));
assertTrue(undoCheckoutButton.isEnabled()); assertTrue(undoCheckoutAction.isEnabledForContext(dialog.getActionContext(null)));
CheckoutInfo checkoutInfo = model.getRowObject(0); CheckoutInfo checkoutInfo = model.getRowObject(0);
DomainFile file = checkoutInfo.getFile(); DomainFile file = checkoutInfo.getFile();
@ -611,11 +607,9 @@ public class VersionControlAction1Test extends AbstractVersionControlActionTest
selectInTable(table, node); selectInTable(table, node);
JButton undoCheckoutButton = DockingActionIf undoCheckoutAction = getAction("UndoCheckOut");
findButtonByIcon(dialog, ResourceManager.loadImage("images/vcUndoCheckOut.png")); assertTrue(undoCheckoutAction.isEnabledForContext(dialog.getActionContext(null)));
assertNotNull(undoCheckoutButton); performAction(undoCheckoutAction);
assertTrue(undoCheckoutButton.isEnabled());
pressButton(undoCheckoutButton);
waitForBusyTable(table); waitForBusyTable(table);
assertEquals(1, model.getRowCount()); assertEquals(1, model.getRowCount());
@ -651,11 +645,10 @@ public class VersionControlAction1Test extends AbstractVersionControlActionTest
selectionModel.setSelectionInterval(0, 1); // both rows selectionModel.setSelectionInterval(0, 1); // both rows
}); });
JButton undoCheckoutButton = DockingActionIf undoCheckoutAction = getAction("UndoCheckOut");
findButtonByIcon(dialog, ResourceManager.loadImage("images/vcUndoCheckOut.png")); ActionContext context = dialog.getActionContext(null);
assertNotNull(undoCheckoutButton); assertTrue(undoCheckoutAction.isEnabledForContext(context));
assertTrue(undoCheckoutButton.isEnabled()); performAction(undoCheckoutAction, context, true);
pressButton(undoCheckoutButton);
waitForBusyTable(table); waitForBusyTable(table);
assertEquals(0, model.getRowCount()); assertEquals(0, model.getRowCount());

View file

@ -213,8 +213,9 @@ public class VersionControlAction2Test extends AbstractVersionControlActionTest
waitForSwing(); waitForSwing();
waitForTasks(); waitForTasks();
Program program = (Program) ((DomainFileNode) node).getDomainFile().getDomainObject(this, Program program = (Program) ((DomainFileNode) node).getDomainFile()
true, false, TaskMonitor.DUMMY); .getDomainObject(this,
true, false, TaskMonitor.DUMMY);
int transactionID = program.startTransaction("test"); int transactionID = program.startTransaction("test");
try { try {
SymbolTable symTable = program.getSymbolTable(); SymbolTable symTable = program.getSymbolTable();
@ -410,7 +411,7 @@ public class VersionControlAction2Test extends AbstractVersionControlActionTest
assertNotNull(dialog); assertNotNull(dialog);
final GTable table = findComponent(dialog.getComponent(), GTable.class); GTable table = findComponent(dialog.getComponent(), GTable.class);
assertNotNull(table); assertNotNull(table);
waitForBusyTable(table); waitForBusyTable(table);
@ -419,14 +420,11 @@ public class VersionControlAction2Test extends AbstractVersionControlActionTest
selectInTable(table, node); selectInTable(table, node);
JButton checkInButton = DockingActionIf checkInAction = getAction("CheckIn");
findButtonByIcon(dialog, ResourceManager.loadImage("images/vcCheckIn.png")); ActionContext context = dialog.getActionContext(null);
assertTrue(checkInAction.isEnabledForContext(context));
assertNotNull(checkInButton); performAction(checkInAction, context, false);
assertTrue(checkInButton.isEnabled());
pressButton(checkInButton, false);
VersionControlDialog d = waitForDialogComponent(VersionControlDialog.class); VersionControlDialog d = waitForDialogComponent(VersionControlDialog.class);
assertNotNull(d);
pressButtonByText(d, "Cancel"); pressButtonByText(d, "Cancel");