mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
Tests - fixed tests for Version Control actions in the 'Find Checkouts'
dialog
This commit is contained in:
parent
ea4407f0e8
commit
725bdee15e
4 changed files with 33 additions and 42 deletions
|
@ -152,7 +152,7 @@ public abstract class AbstractDockingTool implements DockingTool {
|
|||
|
||||
@Override
|
||||
public void showDialog(DialogComponentProvider dialogComponent) {
|
||||
DockingWindowManager.showDialog(getToolFrame(), dialogComponent);
|
||||
DockingWindowManager.showDialog(null, dialogComponent);
|
||||
}
|
||||
|
||||
public JFrame getToolFrame() {
|
||||
|
|
|
@ -75,7 +75,7 @@ public class VersionControlShowHistoryAction extends VersionControlAction {
|
|||
}
|
||||
|
||||
VersionHistoryDialog dialog = new VersionHistoryDialog(domainFiles.get(0));
|
||||
tool.showDialog(dialog, tool.getToolFrame());
|
||||
tool.showDialog(dialog);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import javax.swing.*;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.action.DockingActionIf;
|
||||
import docking.widgets.table.*;
|
||||
|
@ -212,16 +213,18 @@ public class VersionControlAction1Test extends AbstractVersionControlActionTest
|
|||
waitForTasks();
|
||||
|
||||
// make some changes to check in
|
||||
Program program = (Program) ((DomainFileNode) node).getDomainFile().getDomainObject(this,
|
||||
true, false, TaskMonitor.DUMMY);
|
||||
Program program = (Program) ((DomainFileNode) node).getDomainFile()
|
||||
.getDomainObject(this,
|
||||
true, false, TaskMonitor.DUMMY);
|
||||
editProgram(program, (p) -> {
|
||||
SymbolTable symTable = p.getSymbolTable();
|
||||
symTable.createLabel(p.getMinAddress().getNewAddress(0x010001000), "fred",
|
||||
SourceType.USER_DEFINED);
|
||||
});
|
||||
|
||||
program = (Program) ((DomainFileNode) xnode).getDomainFile().getDomainObject(this, true,
|
||||
false, TaskMonitor.DUMMY);
|
||||
program = (Program) ((DomainFileNode) xnode).getDomainFile()
|
||||
.getDomainObject(this, true,
|
||||
false, TaskMonitor.DUMMY);
|
||||
editProgram(program, (p) -> {
|
||||
SymbolTable symTable = p.getSymbolTable();
|
||||
symTable.createLabel(p.getMinAddress(), "bob", SourceType.USER_DEFINED);
|
||||
|
@ -250,8 +253,9 @@ public class VersionControlAction1Test extends AbstractVersionControlActionTest
|
|||
checkout(programNode);
|
||||
|
||||
Program program =
|
||||
(Program) ((DomainFileNode) programNode).getDomainFile().getDomainObject(this, true,
|
||||
false, TaskMonitor.DUMMY);
|
||||
(Program) ((DomainFileNode) programNode).getDomainFile()
|
||||
.getDomainObject(this, true,
|
||||
false, TaskMonitor.DUMMY);
|
||||
|
||||
createHistoryEntry(program, "Symbol1");
|
||||
frontEnd.checkIn(programNode, "This is checkin 1");
|
||||
|
@ -559,25 +563,17 @@ public class VersionControlAction1Test extends AbstractVersionControlActionTest
|
|||
FindCheckoutsTableModel model = (FindCheckoutsTableModel) table.getModel();
|
||||
|
||||
assertEquals(2, model.getRowCount());
|
||||
|
||||
assertEquals(4, model.getColumnCount());
|
||||
|
||||
JButton checkInButton =
|
||||
findButtonByIcon(dialog, ResourceManager.loadImage("images/vcCheckIn.png"));
|
||||
|
||||
assertNotNull(checkInButton);
|
||||
|
||||
JButton undoCheckoutButton =
|
||||
findButtonByIcon(dialog, ResourceManager.loadImage("images/vcUndoCheckOut.png"));
|
||||
assertNotNull(undoCheckoutButton);
|
||||
|
||||
assertTrue(!checkInButton.isEnabled());
|
||||
assertTrue(!undoCheckoutButton.isEnabled());
|
||||
DockingActionIf undoCheckoutAction = getAction("UndoCheckOut");
|
||||
DockingActionIf checkInAction = getAction("CheckIn");
|
||||
assertFalse(checkInAction.isEnabledForContext(dialog.getActionContext(null)));
|
||||
assertFalse(undoCheckoutAction.isEnabledForContext(dialog.getActionContext(null)));
|
||||
|
||||
// make a selection in the table
|
||||
selectInTable(table, node);
|
||||
assertTrue(checkInButton.isEnabled());
|
||||
assertTrue(undoCheckoutButton.isEnabled());
|
||||
assertFalse(checkInAction.isEnabledForContext(dialog.getActionContext(null)));
|
||||
assertTrue(undoCheckoutAction.isEnabledForContext(dialog.getActionContext(null)));
|
||||
|
||||
CheckoutInfo checkoutInfo = model.getRowObject(0);
|
||||
DomainFile file = checkoutInfo.getFile();
|
||||
|
@ -611,11 +607,9 @@ public class VersionControlAction1Test extends AbstractVersionControlActionTest
|
|||
|
||||
selectInTable(table, node);
|
||||
|
||||
JButton undoCheckoutButton =
|
||||
findButtonByIcon(dialog, ResourceManager.loadImage("images/vcUndoCheckOut.png"));
|
||||
assertNotNull(undoCheckoutButton);
|
||||
assertTrue(undoCheckoutButton.isEnabled());
|
||||
pressButton(undoCheckoutButton);
|
||||
DockingActionIf undoCheckoutAction = getAction("UndoCheckOut");
|
||||
assertTrue(undoCheckoutAction.isEnabledForContext(dialog.getActionContext(null)));
|
||||
performAction(undoCheckoutAction);
|
||||
|
||||
waitForBusyTable(table);
|
||||
assertEquals(1, model.getRowCount());
|
||||
|
@ -651,11 +645,10 @@ public class VersionControlAction1Test extends AbstractVersionControlActionTest
|
|||
selectionModel.setSelectionInterval(0, 1); // both rows
|
||||
});
|
||||
|
||||
JButton undoCheckoutButton =
|
||||
findButtonByIcon(dialog, ResourceManager.loadImage("images/vcUndoCheckOut.png"));
|
||||
assertNotNull(undoCheckoutButton);
|
||||
assertTrue(undoCheckoutButton.isEnabled());
|
||||
pressButton(undoCheckoutButton);
|
||||
DockingActionIf undoCheckoutAction = getAction("UndoCheckOut");
|
||||
ActionContext context = dialog.getActionContext(null);
|
||||
assertTrue(undoCheckoutAction.isEnabledForContext(context));
|
||||
performAction(undoCheckoutAction, context, true);
|
||||
|
||||
waitForBusyTable(table);
|
||||
assertEquals(0, model.getRowCount());
|
||||
|
|
|
@ -213,8 +213,9 @@ public class VersionControlAction2Test extends AbstractVersionControlActionTest
|
|||
waitForSwing();
|
||||
waitForTasks();
|
||||
|
||||
Program program = (Program) ((DomainFileNode) node).getDomainFile().getDomainObject(this,
|
||||
true, false, TaskMonitor.DUMMY);
|
||||
Program program = (Program) ((DomainFileNode) node).getDomainFile()
|
||||
.getDomainObject(this,
|
||||
true, false, TaskMonitor.DUMMY);
|
||||
int transactionID = program.startTransaction("test");
|
||||
try {
|
||||
SymbolTable symTable = program.getSymbolTable();
|
||||
|
@ -410,7 +411,7 @@ public class VersionControlAction2Test extends AbstractVersionControlActionTest
|
|||
|
||||
assertNotNull(dialog);
|
||||
|
||||
final GTable table = findComponent(dialog.getComponent(), GTable.class);
|
||||
GTable table = findComponent(dialog.getComponent(), GTable.class);
|
||||
assertNotNull(table);
|
||||
waitForBusyTable(table);
|
||||
|
||||
|
@ -419,14 +420,11 @@ public class VersionControlAction2Test extends AbstractVersionControlActionTest
|
|||
|
||||
selectInTable(table, node);
|
||||
|
||||
JButton checkInButton =
|
||||
findButtonByIcon(dialog, ResourceManager.loadImage("images/vcCheckIn.png"));
|
||||
|
||||
assertNotNull(checkInButton);
|
||||
assertTrue(checkInButton.isEnabled());
|
||||
pressButton(checkInButton, false);
|
||||
DockingActionIf checkInAction = getAction("CheckIn");
|
||||
ActionContext context = dialog.getActionContext(null);
|
||||
assertTrue(checkInAction.isEnabledForContext(context));
|
||||
performAction(checkInAction, context, false);
|
||||
VersionControlDialog d = waitForDialogComponent(VersionControlDialog.class);
|
||||
assertNotNull(d);
|
||||
|
||||
pressButtonByText(d, "Cancel");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue