Merge remote-tracking branch 'origin/GP-0-dragonmacher-test-fixes-9-24-21'

This commit is contained in:
ghidra1 2021-09-24 17:35:12 -04:00
commit f64a7dce0f
3 changed files with 21 additions and 29 deletions

View File

@ -46,7 +46,7 @@ import ghidra.util.*;
import ghidra.util.exception.*;
import ghidra.util.task.TaskMonitor;
class StackEditorModel extends CompositeEditorModel {
public class StackEditorModel extends CompositeEditorModel {
private static final long serialVersionUID = 1L;
public static final int OFFSET = 0;

View File

@ -38,6 +38,7 @@ import docking.widgets.fieldpanel.support.FieldRange;
import docking.widgets.fieldpanel.support.FieldSelection;
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
import ghidra.app.plugin.core.datamgr.util.DataTypeChooserDialog;
import ghidra.app.plugin.core.stackeditor.StackEditorModel;
import ghidra.app.plugin.core.stackeditor.StackFrameDataType;
import ghidra.app.services.DataTypeManagerService;
import ghidra.app.util.datatype.DataTypeSelectionEditor;
@ -444,6 +445,14 @@ public abstract class AbstractEditorTest extends AbstractGhidraHeadedIntegration
waitForSwing();
}
protected DataType getDataTypeAtRow(int row) {
return runSwing(() -> {
DataTypeInstance instance =
(DataTypeInstance) model.getValueAt(row, StackEditorModel.DATATYPE);
return instance.getDataType();
});
}
/**
* Types the indicated string
*

View File

@ -367,43 +367,26 @@ public class StackEditorDnDTest extends AbstractStackEditorTest {
}
}
// public void testDragNDropConsumeAll() throws Exception {
// try {
// DataType dt;
// model.clearComponents(new int[] {1,2,3});
//
// assertEquals(12, model.getNumComponents());
// assertEquals(29, model.getLength());
//
// dt = programDTM.findDataType("/double");
// assertNotNull(dt);
// addAtPoint(dt,0,0);
// assertEquals(5, model.getNumComponents());
// assertEquals(29, model.getLength());
// assertTrue(getDataType(0).isEquivalent(dt));
// assertEquals(dt.getLength(), model.getComponent(0).getLength());
// }
// finally {
// cleanup();
// }
// }
//
@Test
public void testDragNDropAddLargerNoFit() throws Exception {
try {
DataType dt;
assertEquals(20, model.getNumComponents());
assertEquals(0x1e, model.getLength());
dt = programDTM.getDataType("/double");
DataType dt1 = getDataType(1);
assertNotNull(dt);
addAtPoint(dt, 1, 0);
DataType newType = programDTM.getDataType("/double");
assertNotNull(newType);
DataType existingStackType = getDataType(1);
DataType tableType = getDataTypeAtRow(1);
assertTrue(existingStackType.isEquivalent(tableType));
addAtPoint(newType, 1, 0);
assertEquals(20, model.getNumComponents());
assertTrue(getDataType(1).isEquivalent(dt1));
assertEquals(dt1.getLength(), model.getComponent(1).getLength());
assertEquals(0x1e, model.getLength());
DataType newStackType = getDataType(1);
assertSame("Type should not have been replaced", existingStackType, newStackType);
assertEquals("double doesn't fit within 4 bytes, need 8 bytes", model.getStatus());
}
finally {