mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
GP-5326 fixed junit tests and removed check for default field names
This commit is contained in:
parent
2f581d0ead
commit
9429fa0a8e
4 changed files with 7 additions and 22 deletions
|
@ -138,7 +138,7 @@ public class EditDataFieldDialog extends DialogComponentProvider {
|
|||
private void initializeFields() {
|
||||
String name = component.getFieldName();
|
||||
if (StringUtils.isBlank(name)) {
|
||||
name = component.getDefaultFieldName();
|
||||
name = "";
|
||||
}
|
||||
nameField.setText(name);
|
||||
commentField.setText(component.getComment());
|
||||
|
|
|
@ -123,7 +123,7 @@ public class EditFieldDialogTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
goTo(0x101);
|
||||
showFieldEditDialog();
|
||||
assertNull(structure.getComponent(1).getFieldName());
|
||||
assertEquals("field1_0x1", getNameText());
|
||||
assertEquals("", getNameText());
|
||||
|
||||
setNameText("abc");
|
||||
|
||||
|
@ -162,23 +162,6 @@ public class EditFieldDialogTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
assertEquals("byte", structure.getComponent(1).getDataType().getDisplayName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRenameToDuplicateNameError() {
|
||||
goTo(0x104);
|
||||
showFieldEditDialog();
|
||||
assertEquals("count", structure.getComponent(4).getFieldName());
|
||||
assertEquals("count", getNameText());
|
||||
|
||||
setNameText("color");
|
||||
|
||||
pressOk();
|
||||
waitForTasks();
|
||||
assertTrue(isDialogVisible());
|
||||
assertEquals("Duplicate field name", getDialogStatusText());
|
||||
|
||||
assertEquals("count", structure.getComponent(4).getFieldName());
|
||||
}
|
||||
|
||||
private boolean isDialogVisible() {
|
||||
return runSwing(() -> dialog.isVisible());
|
||||
}
|
||||
|
|
|
@ -117,8 +117,10 @@ public interface DataTypeComponent {
|
|||
*
|
||||
* @param fieldName the new field name for this component.
|
||||
*
|
||||
* @throws DuplicateNameException if another component of the parent has
|
||||
* the specified field name.
|
||||
* @throws DuplicateNameException This is actually never thrown anymore. All the other ways
|
||||
* of naming fields did not perform this check and it would cause quite a bit of churn to
|
||||
* add that exception to all the other methods that affect field names. So to be consistent,
|
||||
* we no longer do the check in this method.
|
||||
*/
|
||||
public void setFieldName(String fieldName) throws DuplicateNameException;
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ public interface InternalDataTypeComponent extends DataTypeComponent {
|
|||
public default String cleanupFieldName(String name) {
|
||||
// For now, silently convert whitespace to underscores
|
||||
String fieldName = StringUtilities.whitespaceToUnderscores(name);
|
||||
if (StringUtils.isBlank(fieldName) || fieldName.equals(getDefaultFieldName())) {
|
||||
if (StringUtils.isBlank(fieldName)) {
|
||||
fieldName = null;
|
||||
}
|
||||
return fieldName;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue