diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/stackeditor/StackEditorModel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/stackeditor/StackEditorModel.java index ed3a55eefb..ac91e7c6bd 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/stackeditor/StackEditorModel.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/stackeditor/StackEditorModel.java @@ -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; diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractEditorTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractEditorTest.java index 8223a73e07..8e7a4a308a 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractEditorTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractEditorTest.java @@ -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 * diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/stackeditor/StackEditorDnDTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/stackeditor/StackEditorDnDTest.java index 2631a85525..9cd140ecc0 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/stackeditor/StackEditorDnDTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/stackeditor/StackEditorDnDTest.java @@ -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 {