Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-2236 Changed DataTypeDB clone implementations to return self if the specified datatype manager is unchanged. Makes consistent with javadoc and could improve resolve performance in some cases.

ghidra15eed32100438
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 b2e058b09e..723575d198 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
@@ -471,25 +471,11 @@ public abstract class AbstractEditorTest extends AbstractGhidraHeadedIntegration
}
protected void startTransaction(final String txDescription) {
- runSwing(() -> {
- try {
- txId = program.startTransaction(txDescription);
- }
- catch (Exception e) {
- Assert.fail(e.getMessage());
- }
- });
+ txId = program.startTransaction(txDescription);
}
protected void endTransaction(final boolean saveChanges) {
- runSwing(() -> {
- try {
- program.endTransaction(txId, saveChanges);
- }
- catch (Exception e) {
- Assert.fail(e.getMessage());
- }
- });
+ program.endTransaction(txId, saveChanges);
}
protected class RestoreListener implements DomainObjectListener {
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractStructureEditorLockedActionsTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractStructureEditorLockedActionsTest.java
deleted file mode 100644
index 582ef0a782..0000000000
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractStructureEditorLockedActionsTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/* ###
- * IP: GHIDRA
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package ghidra.app.plugin.core.compositeeditor;
-
-import org.junit.Assert;
-
-import ghidra.program.model.data.*;
-import ghidra.util.exception.DuplicateNameException;
-
-public abstract class AbstractStructureEditorLockedActionsTest extends AbstractStructureEditorTest {
-
- protected void init(Structure dt, final Category cat) {
- boolean commit = true;
- startTransaction("Structure Editor Test Initialization");
- try {
- DataTypeManager dataTypeManager = cat.getDataTypeManager();
- if (dt.getDataTypeManager() != dataTypeManager) {
- dt = dt.clone(dataTypeManager);
- }
- CategoryPath categoryPath = cat.getCategoryPath();
- if (!dt.getCategoryPath().equals(categoryPath)) {
- try {
- dt.setCategoryPath(categoryPath);
- }
- catch (DuplicateNameException e) {
- commit = false;
- Assert.fail(e.getMessage());
- }
- }
- }
- finally {
- endTransaction(commit);
- }
-
- Structure structureDt = dt;
- runSwing(() -> {
- installProvider(new StructureEditorProvider(plugin, structureDt, false));
- model = provider.getModel();
- });
- waitForSwing();
-
- getActions();
- }
-}
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractStructureEditorTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractStructureEditorTest.java
index 7f321ef597..6e42d84ee1 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractStructureEditorTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractStructureEditorTest.java
@@ -15,10 +15,9 @@
*/
package ghidra.app.plugin.core.compositeeditor;
-import static org.junit.Assert.*;
-
import javax.swing.JTextField;
+import org.junit.After;
import org.junit.Assert;
import ghidra.program.model.data.*;
@@ -47,50 +46,55 @@ public abstract class AbstractStructureEditorTest extends AbstractEditorTest {
InsertUndefinedAction insertUndefinedAction;
HexNumbersAction hexNumbersAction;
+ @After
+ public void tearDown() throws Exception {
+ clearActions();
+ structureModel = null;
+ super.tearDown();
+ }
+
StructureEditorModel getModel() {
- return (StructureEditorModel) model;
+ return structureModel;
+ }
+
+ protected void init(Structure dt, final Category cat) {
+ init(dt, cat, false);
}
protected void init(Structure dt, final Category cat, final boolean showInHex) {
- assertEquals("Category path mismatch", dt.getCategoryPath(), cat.getCategoryPath());
-
- boolean commit = true;
- startTransaction("Structure Editor Test Initialization");
- try {
- DataTypeManager dataTypeManager = cat.getDataTypeManager();
- if (dt.getDataTypeManager() != dataTypeManager) {
- dt = dt.clone(dataTypeManager);
- }
- CategoryPath categoryPath = cat.getCategoryPath();
- if (!dt.getCategoryPath().equals(categoryPath)) {
- try {
- dt.setCategoryPath(categoryPath);
- }
- catch (DuplicateNameException e) {
- commit = false;
- Assert.fail(e.getMessage());
- }
- }
+ DataTypeManager dataTypeManager = cat.getDataTypeManager();
+ if (dt.getDataTypeManager() != dataTypeManager) {
+ dt = dt.clone(dataTypeManager);
}
- finally {
- endTransaction(commit);
+
+ CategoryPath categoryPath = cat.getCategoryPath();
+ if (!dt.getCategoryPath().equals(categoryPath)) {
+ // dt may or may not be a DataTypeDB but create transaction to be safe
+ int dtmTxId =
+ dataTypeManager.startTransaction("Modify Datatype Category: " + dt.getName());
+ try {
+ dt.setCategoryPath(categoryPath);
+ }
+ catch (DuplicateNameException e) {
+ Assert.fail(e.getMessage());
+ }
+ finally {
+ dataTypeManager.endTransaction(dtmTxId, true);
+ }
}
+
final Structure structDt = dt;
runSwing(() -> {
installProvider(new StructureEditorProvider(plugin, structDt, showInHex));
model = provider.getModel();
});
waitForSwing();
+
getActions();
structureModel = (StructureEditorModel) model;
}
- protected void cleanup() {
- clearActions();
- runSwing(() -> provider.dispose());
- }
-
void clearActions() {
actions = null;
favorites.clear();
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractStructureEditorUnlockedActionsTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractStructureEditorUnlockedActionsTest.java
deleted file mode 100644
index fdebef3565..0000000000
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractStructureEditorUnlockedActionsTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/* ###
- * IP: GHIDRA
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package ghidra.app.plugin.core.compositeeditor;
-
-import org.junit.Assert;
-
-import ghidra.program.model.data.*;
-import ghidra.util.exception.DuplicateNameException;
-
-public abstract class AbstractStructureEditorUnlockedActionsTest
- extends AbstractStructureEditorTest {
-
- protected void init(Structure dt, final Category cat) {
- boolean commit = true;
- startTransaction("Structure Editor Test Initialization");
- try {
- DataTypeManager dataTypeManager = cat.getDataTypeManager();
- if (dt.getDataTypeManager() != dataTypeManager) {
- dt = (Structure) dt.clone(dataTypeManager);
- }
- CategoryPath categoryPath = cat.getCategoryPath();
- if (!dt.getCategoryPath().equals(categoryPath)) {
- try {
- dt.setCategoryPath(categoryPath);
- }
- catch (DuplicateNameException e) {
- commit = false;
- Assert.fail(e.getMessage());
- }
- }
- }
- finally {
- endTransaction(commit);
- }
-
- Structure structDt = dt;
- runSwing(() -> {
- installProvider(new StructureEditorProvider(plugin, structDt, false));
- model = provider.getModel();
- });
- waitForSwing();
-
- getActions();
- }
-
-}
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractStructureEditorUnlockedCellEditTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractStructureEditorUnlockedCellEditTest.java
deleted file mode 100644
index a8b8080611..0000000000
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractStructureEditorUnlockedCellEditTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/* ###
- * IP: GHIDRA
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package ghidra.app.plugin.core.compositeeditor;
-
-import org.junit.Assert;
-
-import ghidra.program.model.data.*;
-import ghidra.util.exception.DuplicateNameException;
-
-public abstract class AbstractStructureEditorUnlockedCellEditTest
- extends AbstractStructureEditorTest {
-
- protected void init(final Structure dt, final Category cat) {
- final DataType dtClone = dt.clone(programDTM);
- try {
- dtClone.setCategoryPath(cat.getCategoryPath());
- }
- catch (DuplicateNameException e) {
- Assert.fail(e.getMessage());
- }
- runSwing(() -> {
- installProvider(new StructureEditorProvider(plugin, (Structure) dtClone, false));
- model = provider.getModel();
- });
- waitForSwing();
-
- getActions();
- }
-}
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractUnionEditorTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractUnionEditorTest.java
index 95bbb2f446..de2e74e8c0 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractUnionEditorTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractUnionEditorTest.java
@@ -15,8 +15,7 @@
*/
package ghidra.app.plugin.core.compositeeditor;
-import static org.junit.Assert.assertEquals;
-
+import org.junit.After;
import org.junit.Assert;
import ghidra.program.model.data.*;
@@ -40,34 +39,39 @@ public abstract class AbstractUnionEditorTest extends AbstractEditorTest {
ShowComponentPathAction showComponentPathAction;
HexNumbersAction hexNumbersAction;
+ @Override
+ @After
+ public void tearDown() throws Exception {
+ clearActions();
+ unionModel = null;
+ super.tearDown();
+ }
+
UnionEditorModel getModel() {
- return (UnionEditorModel) model;
+ return unionModel;
}
protected void init(Union dt, final Category cat, final boolean showInHex) {
-
- assertEquals("Category path mismatch", dt.getCategoryPath(), cat.getCategoryPath());
-
- boolean commit = true;
- startTransaction("Union Editor Test Initialization");
- try {
- DataTypeManager dataTypeManager = cat.getDataTypeManager();
- if (dt.getDataTypeManager() != dataTypeManager) {
- dt = (Union) dt.clone(dataTypeManager);
- }
- CategoryPath categoryPath = cat.getCategoryPath();
- if (!dt.getCategoryPath().equals(categoryPath)) {
- try {
- dt.setCategoryPath(categoryPath);
- }
- catch (DuplicateNameException e) {
- commit = false;
- Assert.fail(e.getMessage());
- }
- }
+
+ DataTypeManager dataTypeManager = cat.getDataTypeManager();
+ if (dt.getDataTypeManager() != dataTypeManager) {
+ dt = dt.clone(dataTypeManager);
}
- finally {
- endTransaction(commit);
+
+ CategoryPath categoryPath = cat.getCategoryPath();
+ if (!dt.getCategoryPath().equals(categoryPath)) {
+ // dt may or may not be a DataTypeDB but create transaction to be safe
+ int dtmTxId =
+ dataTypeManager.startTransaction("Modify Datatype Category: " + dt.getName());
+ try {
+ dt.setCategoryPath(categoryPath);
+ }
+ catch (DuplicateNameException e) {
+ Assert.fail(e.getMessage());
+ }
+ finally {
+ dataTypeManager.endTransaction(dtmTxId, true);
+ }
}
Union unionDt = dt;
@@ -81,12 +85,6 @@ public abstract class AbstractUnionEditorTest extends AbstractEditorTest {
unionModel = (UnionEditorModel) model;
}
- protected void cleanup() {
- clearActions();
- runSwing(() -> provider.dispose());
- unionModel = null;
- }
-
void clearActions() {
actions = null;
favorites.clear();
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions1Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions1Test.java
index 9b1235f934..8e137e0011 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions1Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions1Test.java
@@ -22,7 +22,7 @@ import org.junit.Test;
import ghidra.program.model.data.*;
import ghidra.util.exception.UsrException;
-public class StructureEditorLockedActions1Test extends AbstractStructureEditorLockedActionsTest {
+public class StructureEditorLockedActions1Test extends AbstractStructureEditorTest {
@Test
public void testArrayOnSelection() throws Exception {
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions2Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions2Test.java
index ba00456f84..e0cc705d54 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions2Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions2Test.java
@@ -24,7 +24,7 @@ import org.junit.Test;
import docking.widgets.dialogs.NumberInputDialog;
import ghidra.program.model.data.*;
-public class StructureEditorLockedActions2Test extends AbstractStructureEditorLockedActionsTest {
+public class StructureEditorLockedActions2Test extends AbstractStructureEditorTest {
@Test
public void testCycleGroupByteSomeRoom() throws Exception {
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions3Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions3Test.java
index 8ae4c1ac90..bf073be1cf 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions3Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions3Test.java
@@ -27,7 +27,7 @@ import docking.widgets.dialogs.InputDialog;
import docking.widgets.dialogs.NumberInputDialog;
import ghidra.program.model.data.*;
-public class StructureEditorLockedActions3Test extends AbstractStructureEditorLockedActionsTest {
+public class StructureEditorLockedActions3Test extends AbstractStructureEditorTest {
/**
* Edit an existing structure and create a structure from a selection. Use the conflicting
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions4Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions4Test.java
index 6893ef3200..a42b8a1ee3 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions4Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions4Test.java
@@ -22,7 +22,7 @@ import org.junit.Test;
import docking.widgets.dialogs.NumberInputDialog;
import ghidra.program.model.data.*;
-public class StructureEditorLockedActions4Test extends AbstractStructureEditorLockedActionsTest {
+public class StructureEditorLockedActions4Test extends AbstractStructureEditorTest {
@Test
public void testArrayBeforeUndefineds() throws Exception {
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedCellEditTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedCellEditTest.java
index 99c7b744ea..35b3c0f5ca 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedCellEditTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedCellEditTest.java
@@ -23,7 +23,8 @@ import java.io.File;
import javax.swing.JTable;
-import org.junit.*;
+import org.junit.Before;
+import org.junit.Test;
import docking.widgets.dialogs.NumberInputDialog;
import ghidra.program.model.data.*;
@@ -31,7 +32,6 @@ import ghidra.program.model.listing.Function;
import ghidra.program.model.listing.Library;
import ghidra.program.model.symbol.ExternalLocation;
import ghidra.program.model.symbol.SourceType;
-import ghidra.util.exception.DuplicateNameException;
public class StructureEditorLockedCellEditTest extends AbstractStructureEditorTest {
@@ -43,42 +43,6 @@ public class StructureEditorLockedCellEditTest extends AbstractStructureEditorTe
dir.mkdirs();
}
- protected void init(Structure dt, final Category cat) {
-
- boolean commit = true;
- startTransaction("Structure Editor Test Initialization");
-
- try {
- DataTypeManager dataTypeManager = cat.getDataTypeManager();
- if (dt.getDataTypeManager() != dataTypeManager) {
- dt = dt.clone(dataTypeManager);
- }
-
- CategoryPath categoryPath = cat.getCategoryPath();
- if (!dt.getCategoryPath().equals(categoryPath)) {
- try {
- dt.setCategoryPath(categoryPath);
- }
- catch (DuplicateNameException e) {
- commit = false;
- Assert.fail(e.getMessage());
- }
- }
- }
- finally {
- endTransaction(commit);
- }
-
- final Structure structDt = dt;
- runSwing(() -> {
- installProvider(new StructureEditorProvider(plugin, structDt, false));
- model = provider.getModel();
- });
- waitForSwing();
-
- getActions();
- }
-
@Test
public void testF2EditKey() throws Exception {
init(simpleStructure, pgmBbCat);
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedDnDTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedDnDTest.java
index 69f753f223..df652f9894 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedDnDTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedDnDTest.java
@@ -26,14 +26,6 @@ import ghidra.program.model.data.*;
public class StructureEditorLockedDnDTest extends AbstractStructureEditorTest {
- protected void init(Structure dt, Category cat) {
- super.init(dt, cat, false);
- runSwing(() -> {
-// model.setLocked(true);
- });
-// assertTrue(model.isLocked());
- }
-
@Test
public void testDragNDropAddSameSize() throws Exception {
init(complexStructure, pgmTestCat);
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedEnablementTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedEnablementTest.java
index 00347d9e36..dd98883c7d 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedEnablementTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedEnablementTest.java
@@ -20,48 +20,13 @@ import static org.junit.Assert.*;
import org.junit.Assert;
import org.junit.Test;
-import ghidra.program.model.data.*;
+import ghidra.program.model.data.DataTypeManager;
+import ghidra.program.model.data.Structure;
import ghidra.util.exception.DuplicateNameException;
import ghidra.util.task.TaskMonitor;
public class StructureEditorLockedEnablementTest extends AbstractStructureEditorTest {
- @Override
- protected void init(Structure dt, final Category cat, boolean addIfNotThere) {
- boolean commit = true;
- startTransaction("Structure Editor Test Initialization");
- try {
- DataTypeManager dataTypeManager = cat.getDataTypeManager();
- if (dt.getDataTypeManager() != dataTypeManager) {
- dt = dt.clone(dataTypeManager);
- }
- CategoryPath categoryPath = cat.getCategoryPath();
- if (!dt.getCategoryPath().equals(categoryPath)) {
- try {
- dt.setCategoryPath(categoryPath);
- }
- catch (DuplicateNameException e) {
- commit = false;
- Assert.fail(e.getMessage());
- }
- }
- if (addIfNotThere && !dataTypeManager.contains(dt)) {
- dataTypeManager.addDataType(dt, null);
- }
- }
- finally {
- endTransaction(commit);
- }
- final Structure structDt = dt;
- runSwing(() -> {
- installProvider(new StructureEditorProvider(plugin, structDt, false));
- model = provider.getModel();
-// model.setLocked(true);
- });
-// assertTrue(model.isLocked());
- getActions();
- }
-
@Test
public void testEmptyStructureEditorState() {
DataTypeManager catDTM = pgmTestCat.getDataTypeManager();
@@ -81,7 +46,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor
program.endTransaction(txID, true);
}
- init(desiredEmptyStructure, pgmTestCat, false);
+ init(desiredEmptyStructure, pgmTestCat);
// assertTrue(!getModel().isLocked());
// assertTrue(getModel().isLockable());
@@ -133,7 +98,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor
@Test
public void testNonEmptyStructureEditorState() {
- init(simpleStructure, pgmBbCat, false);
+ init(simpleStructure, pgmBbCat);
// assertTrue(getModel().isLocked());
// assertTrue(getModel().isLockable());
@@ -184,7 +149,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor
@Test
public void testUndefinedFirstComponentSelectedEnablement() {
- init(simpleStructure, pgmBbCat, true);
+ init(simpleStructure, pgmBbCat);
// Check enablement on first component selected.
setSelection(new int[] { 0 });
@@ -215,7 +180,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor
@Test
public void testCentralComponentSelectedEnablement() {
- init(simpleStructure, pgmBbCat, true);
+ init(simpleStructure, pgmBbCat);
// Check enablement on central component selected.
setSelection(new int[] { 3 });
@@ -245,7 +210,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor
@Test
public void testLastComponentSelectedEnablement() {
- init(simpleStructure, pgmBbCat, true);
+ init(simpleStructure, pgmBbCat);
int last = getModel().getNumComponents() - 1;
@@ -275,7 +240,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor
@Test
public void testContiguousSelectionEnablement() {
- init(complexStructure, pgmTestCat, true);
+ init(complexStructure, pgmTestCat);
// Check enablement on a contiguous multi-component selection.
setSelection(new int[] { 2, 3, 4 });
@@ -304,7 +269,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor
@Test
public void testNonContiguousSelectionEnablement() {
- init(complexStructure, pgmTestCat, true);
+ init(complexStructure, pgmTestCat);
// Check enablement on a non-contiguous multi-component selection.
setSelection(new int[] { 2, 3, 6, 7 });
@@ -329,7 +294,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor
@Test
public void testMultiDupEnablement() throws Exception {
- init(complexStructure, pgmBbCat, true);
+ init(complexStructure, pgmBbCat);
model.clearComponents(new int[] { 3, 10 });
setSelection(new int[] { 0 });
@@ -376,7 +341,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor
@Test
public void testUnpackageEnablement() {
- init(complexStructure, pgmBbCat, true);
+ init(complexStructure, pgmBbCat);
setSelection(new int[] { 2 });
assertEquals("word", getDataType(2).getDisplayName());
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorNotifiedTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorNotifiedTest.java
index 2dcc62683f..67948baf38 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorNotifiedTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorNotifiedTest.java
@@ -19,8 +19,7 @@ import static org.junit.Assert.*;
import java.awt.Window;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.*;
import ghidra.program.model.data.*;
import ghidra.util.Swing;
@@ -29,42 +28,24 @@ import ghidra.util.task.TaskMonitor;
public class StructureEditorNotifiedTest extends AbstractStructureEditorTest {
- protected void init(Structure dt, final Category cat) {
- boolean commit = true;
- startTransaction("Structure Editor Test Initialization");
- try {
- DataTypeManager dataTypeManager = cat.getDataTypeManager();
- if (dt.getDataTypeManager() != dataTypeManager) {
- dt = dt.clone(dataTypeManager);
- }
- CategoryPath categoryPath = cat.getCategoryPath();
- if (!dt.getCategoryPath().equals(categoryPath)) {
- try {
- dt.setCategoryPath(categoryPath);
- }
- catch (DuplicateNameException e) {
- commit = false;
- Assert.fail(e.getMessage());
- }
- }
- }
- finally {
- endTransaction(commit);
- }
+ private int persistentTxId = 0;
- Structure structDt = dt;
- runSwing(() -> {
- installProvider(new StructureEditorProvider(plugin, structDt, false));
- });
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
- model = provider.getModel();
- startTransaction("Modify Program");
+ // Create overlapping trasnaction to handle all changes
+ persistentTxId = program.startTransaction("Modify Program");
}
@Override
- protected void cleanup() {
- endTransaction(false);
- provider.dispose();
+ @After
+ public void tearDown() throws Exception {
+ if (persistentTxId != 0) {
+ program.endTransaction(persistentTxId, true);
+ }
+ super.tearDown();
}
@Test
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions1Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions1Test.java
index 92c8f8205f..3b865bb036 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions1Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions1Test.java
@@ -23,7 +23,7 @@ import docking.widgets.dialogs.NumberInputDialog;
import ghidra.program.model.data.*;
public class StructureEditorUnlockedActions1Test
- extends AbstractStructureEditorUnlockedActionsTest {
+ extends AbstractStructureEditorTest {
@Test
public void testCycleGroupOnComponent() throws Exception {
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions2Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions2Test.java
index 482eb80345..8e69ee55e2 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions2Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions2Test.java
@@ -23,7 +23,7 @@ import docking.widgets.dialogs.NumberInputDialog;
import ghidra.program.model.data.*;
public class StructureEditorUnlockedActions2Test
- extends AbstractStructureEditorUnlockedActionsTest {
+ extends AbstractStructureEditorTest {
@Test
public void testCreatePointerOnStructPointer() {
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions3Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions3Test.java
index f87636a857..ee596b012c 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions3Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions3Test.java
@@ -29,7 +29,7 @@ import docking.widgets.dialogs.NumberInputDialog;
import ghidra.program.model.data.*;
public class StructureEditorUnlockedActions3Test
- extends AbstractStructureEditorUnlockedActionsTest {
+ extends AbstractStructureEditorTest {
@Test
public void testDuplicateMultipleAction() throws Exception {
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions4Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions4Test.java
index d939d73938..e7fbcb2cbf 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions4Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions4Test.java
@@ -28,7 +28,7 @@ import ghidra.program.model.data.*;
import ghidra.util.exception.UsrException;
public class StructureEditorUnlockedActions4Test
- extends AbstractStructureEditorUnlockedActionsTest {
+ extends AbstractStructureEditorTest {
@Test
public void testChangeSizeToZero() throws Exception {
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions5Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions5Test.java
index beda61d47f..242170cc3a 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions5Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions5Test.java
@@ -32,7 +32,7 @@ import ghidra.util.exception.DuplicateNameException;
import ghidra.util.exception.UsrException;
public class StructureEditorUnlockedActions5Test
- extends AbstractStructureEditorUnlockedActionsTest {
+ extends AbstractStructureEditorTest {
@Test
public void testApplyDuplicateName() throws Exception {
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions6Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions6Test.java
index 61989d7a89..a7d46dc76e 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions6Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions6Test.java
@@ -27,7 +27,7 @@ import docking.widgets.dialogs.NumberInputDialog;
import ghidra.program.model.data.*;
public class StructureEditorUnlockedActions6Test
- extends AbstractStructureEditorUnlockedActionsTest {
+ extends AbstractStructureEditorTest {
@Test
public void testArrayOnArray() throws Exception {
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedCellEdit1Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedCellEdit1Test.java
index a50c3f4c55..e0d80057e7 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedCellEdit1Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedCellEdit1Test.java
@@ -23,7 +23,7 @@ import docking.widgets.dialogs.NumberInputDialog;
import ghidra.program.model.data.DataType;
public class StructureEditorUnlockedCellEdit1Test
- extends AbstractStructureEditorUnlockedCellEditTest {
+ extends AbstractStructureEditorTest {
@Test
public void testEditDynamicDataTypeAtLastComponent() throws Exception {
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedCellEdit2Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedCellEdit2Test.java
index 270813b76a..82d4270b16 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedCellEdit2Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedCellEdit2Test.java
@@ -28,7 +28,7 @@ import generic.test.ConcurrentTestExceptionHandler;
import ghidra.program.model.data.*;
public class StructureEditorUnlockedCellEdit2Test
- extends AbstractStructureEditorUnlockedCellEditTest {
+ extends AbstractStructureEditorTest {
@Test
public void testF2EditKey() throws Exception {
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedDnD1Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedDnD1Test.java
index 84a087a4d1..9de01d0668 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedDnD1Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedDnD1Test.java
@@ -21,7 +21,7 @@ import org.junit.Before;
import org.junit.Test;
import docking.widgets.dialogs.NumberInputDialog;
-import ghidra.program.model.data.*;
+import ghidra.program.model.data.DataType;
public class StructureEditorUnlockedDnD1Test extends AbstractStructureEditorTest {
@@ -32,10 +32,6 @@ public class StructureEditorUnlockedDnD1Test extends AbstractStructureEditorTest
env.showTool();
}
- protected void init(Structure dt, Category cat) {
- super.init(dt, cat, false);
- }
-
@Test
public void testDragNDropCancelStringDrop() throws Exception {
NumberInputDialog dialog = null;
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedDnD2Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedDnD2Test.java
index 70b08c2e99..4d04963d57 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedDnD2Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedDnD2Test.java
@@ -25,9 +25,6 @@ import ghidra.program.model.data.*;
public class StructureEditorUnlockedDnD2Test extends AbstractStructureEditorTest {
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
@Override
@Before
public void setUp() throws Exception {
@@ -35,14 +32,6 @@ public class StructureEditorUnlockedDnD2Test extends AbstractStructureEditorTest
env.showTool();
}
- protected void init(Structure dt, Category cat) {
- super.init(dt, cat, false);
- runSwing(() -> {
-// model.setLocked(false);
- });
-// assertTrue(!model.isLocked());
- }
-
@Test
public void testDragNDropAddDifferentTypes() throws Exception {
NumberInputDialog dialog;
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedDnD3Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedDnD3Test.java
index 962ce16faf..3ef3e9db65 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedDnD3Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedDnD3Test.java
@@ -21,13 +21,10 @@ import org.junit.Before;
import org.junit.Test;
import docking.widgets.dialogs.NumberInputDialog;
-import ghidra.program.model.data.*;
+import ghidra.program.model.data.DataType;
public class StructureEditorUnlockedDnD3Test extends AbstractStructureEditorTest {
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
@Override
@Before
public void setUp() throws Exception {
@@ -35,14 +32,6 @@ public class StructureEditorUnlockedDnD3Test extends AbstractStructureEditorTest
env.showTool();
}
- protected void init(Structure dt, Category cat) {
- super.init(dt, cat, false);
- runSwing(() -> {
-// model.setLocked(false);
- });
-// assertTrue(!model.isLocked());
- }
-
@Test
public void testDragNDropInsertDifferentTypes() throws Exception {
NumberInputDialog dialog = null;
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedDnD4Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedDnD4Test.java
index 7cec7ffd34..197e3de763 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedDnD4Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedDnD4Test.java
@@ -24,9 +24,6 @@ import ghidra.program.model.data.*;
public class StructureEditorUnlockedDnD4Test extends AbstractStructureEditorTest {
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
@Override
@Before
public void setUp() throws Exception {
@@ -34,14 +31,6 @@ public class StructureEditorUnlockedDnD4Test extends AbstractStructureEditorTest
env.showTool();
}
- protected void init(Structure dt, Category cat) {
- super.init(dt, cat, false);
- runSwing(() -> {
-// model.setLocked(false);
- });
-// assertTrue(!model.isLocked());
- }
-
@Test
public void testDragNDropAddFirstMiddleLast() throws Exception {
init(complexStructure, pgmTestCat);
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedEnablementTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedEnablementTest.java
index 2b66f0bd8c..4364c8d974 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedEnablementTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedEnablementTest.java
@@ -17,47 +17,12 @@ package ghidra.app.plugin.core.compositeeditor;
import static org.junit.Assert.*;
-import org.junit.Assert;
import org.junit.Test;
import ghidra.program.model.data.*;
-import ghidra.util.exception.DuplicateNameException;
public class StructureEditorUnlockedEnablementTest extends AbstractStructureEditorTest {
- protected void init(Structure dt, final Category cat) {
- boolean commit = true;
- startTransaction("Structure Editor Test Initialization");
- try {
- DataTypeManager dataTypeManager = cat.getDataTypeManager();
- if (dt.getDataTypeManager() != dataTypeManager) {
- dt = dt.clone(dataTypeManager);
- }
- CategoryPath categoryPath = cat.getCategoryPath();
- if (!dt.getCategoryPath().equals(categoryPath)) {
- try {
- dt.setCategoryPath(categoryPath);
- }
- catch (DuplicateNameException e) {
- commit = false;
- Assert.fail(e.getMessage());
- }
- }
- }
- finally {
- endTransaction(commit);
- }
- final Structure structDt = dt;
- runSwing(() -> {
- installProvider(new StructureEditorProvider(plugin, structDt, false));
- model = provider.getModel();
- structureModel = (StructureEditorModel) model;
-// model.setLocked(false);
- });
-// assertTrue(!model.isLocked());
- getActions();
- }
-
@Test
public void testEmptyStructureEditorState() {
init(emptyStructure, pgmTestCat);
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/UnionEditorNotifiedTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/UnionEditorNotifiedTest.java
index 56759dde85..141d902c16 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/UnionEditorNotifiedTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/UnionEditorNotifiedTest.java
@@ -21,54 +21,40 @@ import java.awt.Window;
import javax.swing.SwingUtilities;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.*;
import ghidra.program.model.data.*;
-import ghidra.util.exception.DuplicateNameException;
import ghidra.util.exception.UsrException;
import ghidra.util.task.TaskMonitor;
public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
+ private int persistentTxId = 0;
+
@Override
- protected void init(Union dt, final Category cat, final boolean showInHex) {
- boolean commit = true;
- startTransaction("Union Editor Test Initialization");
- try {
- DataTypeManager dataTypeManager = cat.getDataTypeManager();
- if (dt.getDataTypeManager() != dataTypeManager) {
- dt = dt.clone(dataTypeManager);
- }
- CategoryPath categoryPath = cat.getCategoryPath();
- if (!dt.getCategoryPath().equals(categoryPath)) {
- try {
- dt.setCategoryPath(categoryPath);
- }
- catch (DuplicateNameException e) {
- commit = false;
- Assert.fail(e.getMessage());
- }
- }
- }
- finally {
- endTransaction(commit);
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+
+ // Create overlapping trasnaction to handle all changes
+ persistentTxId = program.startTransaction("Modify Program");
+ }
+
+ @Override
+ @After
+ public void tearDown() throws Exception {
+ if (persistentTxId != 0) {
+ program.endTransaction(persistentTxId, true);
}
- final Union unionDt = dt;
- runSwing(() -> {
- installProvider(new UnionEditorProvider(plugin, unionDt, showInHex));
- model = provider.getModel();
- });
- assertIsPackingEnabled(false);
- assertIsDefaultAligned();
- assertActualAlignment(1);
- startTransaction("Modify Program");
+ super.tearDown();
}
@Override
- protected void cleanup() {
- endTransaction(false);
- super.cleanup();
+ protected void init(Union dt, final Category cat, final boolean showInHex) {
+ super.init(dt, cat, showInHex);
+ assertIsPackingEnabled(false);
+ assertIsDefaultAligned();
+ assertActualAlignment(1);
}
@Test
@@ -78,34 +64,26 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
@Test
public void testComponentDtCategoryMoved() throws Exception {
- try {
- init(complexUnion, pgmTestCat, false);
+ init(complexUnion, pgmTestCat, false);
- assertEquals("/aa/bb", getDataType(20).getCategoryPath().getPath());
- pgmTestCat.moveCategory(pgmBbCat, TaskMonitor.DUMMY);
- waitForSwing();
- assertEquals("/testCat/bb", getDataType(20).getCategoryPath().getPath());
- }
- finally {
- cleanup();
- }
+ assertEquals("/aa/bb", getDataType(20).getCategoryPath().getPath());
+ pgmTestCat.moveCategory(pgmBbCat, TaskMonitor.DUMMY);
+ waitForSwing();
+ assertEquals("/testCat/bb", getDataType(20).getCategoryPath().getPath());
}
@Test
public void testEditedDtCategoryMoved() throws Exception {
- try {
- init(simpleUnion, pgmBbCat, false);
-
- assertEquals(pgmBbCat.getCategoryPathName(), model.getOriginalCategoryPath().getPath());
- pgmTestCat.moveCategory(pgmBbCat, TaskMonitor.DUMMY);
- waitForSwing();
- assertTrue(model.getOriginalCategoryPath().getPath().startsWith(
- pgmTestCat.getCategoryPathName()));
- assertEquals(pgmBbCat.getCategoryPathName(), model.getOriginalCategoryPath().getPath());
- }
- finally {
- cleanup();
- }
+ init(simpleUnion, pgmBbCat, false);
+
+ assertEquals(pgmBbCat.getCategoryPathName(), model.getOriginalCategoryPath().getPath());
+ pgmTestCat.moveCategory(pgmBbCat, TaskMonitor.DUMMY);
+ waitForSwing();
+ assertTrue(model.getOriginalCategoryPath()
+ .getPath()
+ .startsWith(
+ pgmTestCat.getCategoryPathName()));
+ assertEquals(pgmBbCat.getCategoryPathName(), model.getOriginalCategoryPath().getPath());
}
@Test
@@ -130,59 +108,45 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
endTransaction(true);
}
- try {
- init(complexUnion, tempCat, false);
-
- int num = model.getNumComponents();
- // Clone the data types we want to hold onto for comparison later, since reload can close the viewDTM.
- DataType dt18 = getDataType(18).clone(programDTM);
- DataType dt20 = getDataType(20).clone(programDTM);
- SwingUtilities.invokeLater(() -> {
- programDTM.remove(complexUnion, TaskMonitor.DUMMY);
- programDTM.getCategory(pgmRootCat.getCategoryPath()).removeCategory("Temp",
- TaskMonitor.DUMMY);
- });
-
- waitForSwing();
- // refUnion* gets removed
- assertEquals(num - 1, model.getNumComponents());
- assertTrue(dt18.isEquivalent(getDataType(18)));
- assertTrue(dt20.isEquivalent(getDataType(19)));
- }
- finally {
- cleanup();
- }
+ init(complexUnion, tempCat, false);
+
+ int num = model.getNumComponents();
+ // Clone the data types we want to hold onto for comparison later, since reload can close the viewDTM.
+ DataType dt18 = getDataType(18).clone(programDTM);
+ DataType dt20 = getDataType(20).clone(programDTM);
+ SwingUtilities.invokeLater(() -> {
+ programDTM.remove(complexUnion, TaskMonitor.DUMMY);
+ programDTM.getCategory(pgmRootCat.getCategoryPath())
+ .removeCategory("Temp",
+ TaskMonitor.DUMMY);
+ });
+
+ waitForSwing();
+ // refUnion* gets removed
+ assertEquals(num - 1, model.getNumComponents());
+ assertTrue(dt18.isEquivalent(getDataType(18)));
+ assertTrue(dt20.isEquivalent(getDataType(19)));
}
@Test
public void testComponentDtCategoryRenamed() throws Exception {
- try {
- init(complexUnion, pgmTestCat, false);
+ init(complexUnion, pgmTestCat, false);
- assertEquals("/aa/bb", getDataType(20).getCategoryPath().getPath());
- pgmBbCat.setName("NewBB2");// Was /aa/bb
- waitForSwing();
- assertEquals("/aa/NewBB2", getDataType(20).getCategoryPath().getPath());
- }
- finally {
- cleanup();
- }
+ assertEquals("/aa/bb", getDataType(20).getCategoryPath().getPath());
+ pgmBbCat.setName("NewBB2");// Was /aa/bb
+ waitForSwing();
+ assertEquals("/aa/NewBB2", getDataType(20).getCategoryPath().getPath());
}
@Test
public void testEditedDtCategoryRenamed() throws Exception {
- try {
- init(simpleUnion, pgmBbCat, false);
- model = provider.getModel();
+ init(simpleUnion, pgmBbCat, false);
+ model = provider.getModel();
- assertEquals(pgmBbCat.getCategoryPathName(), model.getOriginalCategoryPath().getPath());
- pgmBbCat.setName("NewBB2");// Was /aa/bb
- waitForSwing();
- assertEquals("/aa/NewBB2", model.getOriginalCategoryPath().getPath());
- }
- finally {
- cleanup();
- }
+ assertEquals(pgmBbCat.getCategoryPathName(), model.getOriginalCategoryPath().getPath());
+ pgmBbCat.setName("NewBB2");// Was /aa/bb
+ waitForSwing();
+ assertEquals("/aa/NewBB2", model.getOriginalCategoryPath().getPath());
}
@Test
@@ -194,491 +158,406 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
@Test
public void testComponentDataTypeChanged() {
- try {
- init(complexUnion, pgmTestCat, false);
-
- // Clone the data types we want to hold onto for comparison later, since reload can close the viewDTM.
- DataType dt12 = getDataType(12).clone(programDTM);// struct array
- DataType dt15 = getDataType(15).clone(programDTM);// struct typedef
- DataType dt20 = getDataType(20).clone(programDTM);// struct
- int len12 = dt12.getLength();
- int len15 = dt15.getLength();
- int len20 = dt20.getLength();
- // Change the struct. simpleStructure was 29 bytes.
- SwingUtilities.invokeLater(() -> simpleStructure.add(new DWordDataType()));
- waitForSwing();
- // Check that the viewer now has the modified struct.
- // Components 12, 15, & 21 all change size.
- len12 += (3 * 4);
- len15 += 4;
- len20 += 4;
- assertEquals(len12, getDataType(12).getLength());
- assertEquals(len15, getDataType(15).getLength());
- assertEquals(len20, getDataType(20).getLength());
- assertEquals(len12, model.getComponent(12).getLength());
- assertEquals(len15, model.getComponent(15).getLength());
- assertEquals(len20, model.getComponent(20).getLength());
- assertEquals(len12, model.getLength());
- }
- finally {
- cleanup();
- }
+ init(complexUnion, pgmTestCat, false);
+
+ // Clone the data types we want to hold onto for comparison later, since reload can close the viewDTM.
+ DataType dt12 = getDataType(12).clone(programDTM);// struct array
+ DataType dt15 = getDataType(15).clone(programDTM);// struct typedef
+ DataType dt20 = getDataType(20).clone(programDTM);// struct
+ int len12 = dt12.getLength();
+ int len15 = dt15.getLength();
+ int len20 = dt20.getLength();
+ // Change the struct. simpleStructure was 29 bytes.
+ SwingUtilities.invokeLater(() -> simpleStructure.add(new DWordDataType()));
+ waitForSwing();
+ // Check that the viewer now has the modified struct.
+ // Components 12, 15, & 21 all change size.
+ len12 += (3 * 4);
+ len15 += 4;
+ len20 += 4;
+ assertEquals(len12, getDataType(12).getLength());
+ assertEquals(len15, getDataType(15).getLength());
+ assertEquals(len20, getDataType(20).getLength());
+ assertEquals(len12, model.getComponent(12).getLength());
+ assertEquals(len15, model.getComponent(15).getLength());
+ assertEquals(len20, model.getComponent(20).getLength());
+ assertEquals(len12, model.getLength());
}
@Test
public void testModifiedEditedDataTypeChangedYes() throws Exception {
- Window dialog;
- try {
- init(complexUnion, pgmTestCat, false);
-
- runSwing(() -> {
- try {
- model.insert(model.getNumComponents(), new ByteDataType(), 1);
- model.insert(model.getNumComponents(), new PointerDataType(), 4);
- }
- catch (UsrException e) {
- Assert.fail(e.getMessage());
- }
- });
-
- SwingUtilities.invokeLater(() -> complexUnion.add(new CharDataType()));
- waitForSwing();
- DataType origCopy = complexUnion.clone(null);
-
- // Verify the Reload Union Editor? dialog is displayed.
- dialog = waitForWindow("Reload Union Editor?");
- assertNotNull(dialog);
- pressButtonByText(dialog, "Yes");
- dialog.dispose();
- dialog = null;
-
- waitForSwing();
- assertEquals(((Union) origCopy).getNumComponents(), model.getNumComponents());
- assertTrue(origCopy.isEquivalent(model.viewComposite));
- }
- finally {
- dialog = null;
- cleanup();
- }
+
+ init(complexUnion, pgmTestCat, false);
+
+ runSwing(() -> {
+ try {
+ model.insert(model.getNumComponents(), new ByteDataType(), 1);
+ model.insert(model.getNumComponents(), new PointerDataType(), 4);
+ }
+ catch (UsrException e) {
+ Assert.fail(e.getMessage());
+ }
+ });
+
+ SwingUtilities.invokeLater(() -> complexUnion.add(new CharDataType()));
+ waitForSwing();
+ DataType origCopy = complexUnion.clone(null);
+
+ // Verify the Reload Union Editor? dialog is displayed.
+ Window dialog = waitForWindow("Reload Union Editor?");
+ assertNotNull(dialog);
+ pressButtonByText(dialog, "Yes");
+ dialog.dispose();
+ dialog = null;
+
+ waitForSwing();
+ assertEquals(((Union) origCopy).getNumComponents(), model.getNumComponents());
+ assertTrue(origCopy.isEquivalent(model.viewComposite));
}
@Test
public void testModifiedEditedDataTypeChangedNo() throws Exception {
- Window dialog;
- try {
- init(complexUnion, pgmTestCat, false);
-
- runSwing(() -> {
- try {
- model.insert(model.getNumComponents(), new ByteDataType(), 1);
- model.insert(model.getNumComponents(), new PointerDataType(), 4);
- }
- catch (UsrException e) {
- Assert.fail(e.getMessage());
- }
- });
- DataType viewCopy = model.viewComposite.clone(null);
-
- SwingUtilities.invokeLater(() -> complexUnion.add(new CharDataType()));
- waitForSwing();
-
- // Verify the Reload Union Editor? dialog is displayed.
- dialog = waitForWindow("Reload Union Editor?");
- assertNotNull(dialog);
- pressButtonByText(dialog, "No");
- dialog.dispose();
- dialog = null;
-
- assertEquals(((Union) viewCopy).getNumComponents(), model.getNumComponents());
- assertTrue(viewCopy.isEquivalent(model.viewComposite));
- }
- finally {
- dialog = null;
- cleanup();
- }
+ init(complexUnion, pgmTestCat, false);
+
+ runSwing(() -> {
+ try {
+ model.insert(model.getNumComponents(), new ByteDataType(), 1);
+ model.insert(model.getNumComponents(), new PointerDataType(), 4);
+ }
+ catch (UsrException e) {
+ Assert.fail(e.getMessage());
+ }
+ });
+ DataType viewCopy = model.viewComposite.clone(null);
+
+ SwingUtilities.invokeLater(() -> complexUnion.add(new CharDataType()));
+ waitForSwing();
+
+ // Verify the Reload Union Editor? dialog is displayed.
+ Window dialog = waitForWindow("Reload Union Editor?");
+ assertNotNull(dialog);
+ pressButtonByText(dialog, "No");
+ dialog.dispose();
+ dialog = null;
+
+ assertEquals(((Union) viewCopy).getNumComponents(), model.getNumComponents());
+ assertTrue(viewCopy.isEquivalent(model.viewComposite));
}
@Test
public void testUnmodifiedEditedDataTypeChanged() {
- try {
- init(complexUnion, pgmTestCat, false);
+ init(complexUnion, pgmTestCat, false);
- SwingUtilities.invokeLater(() -> complexUnion.add(new CharDataType()));
- waitForSwing();
- assertTrue(complexUnion.isEquivalent(model.viewComposite));
- }
- finally {
- cleanup();
- }
+ SwingUtilities.invokeLater(() -> complexUnion.add(new CharDataType()));
+ waitForSwing();
+ assertTrue(complexUnion.isEquivalent(model.viewComposite));
}
@Test
public void testComponentDataTypeMoved() {
- try {
- init(complexUnion, pgmTestCat, false);
-
- assertEquals(21, model.getNumComponents());
- assertTrue(simpleStructure.isEquivalent(getDataType(20)));
- assertEquals(simpleStructure.getCategoryPath().getPath(),
- pgmBbCat.getCategoryPath().getPath());
- SwingUtilities.invokeLater(() -> {
- try {
- pgmAaCat.moveDataType(simpleStructure, DataTypeConflictHandler.DEFAULT_HANDLER);
- }
- catch (DataTypeDependencyException e) {
- // don't care
- }
- });
- waitForSwing();
- assertEquals(21, model.getNumComponents());
- assertTrue(simpleStructure.isEquivalent(getDataType(20)));
- assertEquals(simpleStructure.getCategoryPath().getPath(),
- pgmAaCat.getCategoryPath().getPath());
- }
- finally {
- cleanup();
- }
+ init(complexUnion, pgmTestCat, false);
+
+ assertEquals(21, model.getNumComponents());
+ assertTrue(simpleStructure.isEquivalent(getDataType(20)));
+ assertEquals(simpleStructure.getCategoryPath().getPath(),
+ pgmBbCat.getCategoryPath().getPath());
+ SwingUtilities.invokeLater(() -> {
+ try {
+ pgmAaCat.moveDataType(simpleStructure, DataTypeConflictHandler.DEFAULT_HANDLER);
+ }
+ catch (DataTypeDependencyException e) {
+ // don't care
+ }
+ });
+ waitForSwing();
+ assertEquals(21, model.getNumComponents());
+ assertTrue(simpleStructure.isEquivalent(getDataType(20)));
+ assertEquals(simpleStructure.getCategoryPath().getPath(),
+ pgmAaCat.getCategoryPath().getPath());
}
@Test
public void testEditedDataTypeMoved() {
- try {
- init(complexUnion, pgmTestCat, false);
-
- assertEquals(pgmTestCat.getCategoryPathName(),
- model.getOriginalCategoryPath().getPath());
- SwingUtilities.invokeLater(() -> {
- try {
- pgmAaCat.moveDataType(complexUnion, DataTypeConflictHandler.DEFAULT_HANDLER);
- }
- catch (DataTypeDependencyException e) {
- // don't care
- }
- });
- waitForSwing();
- assertEquals(pgmAaCat.getCategoryPathName(), model.getOriginalCategoryPath().getPath());
- }
- finally {
- cleanup();
- }
+ init(complexUnion, pgmTestCat, false);
+
+ assertEquals(pgmTestCat.getCategoryPathName(),
+ model.getOriginalCategoryPath().getPath());
+ SwingUtilities.invokeLater(() -> {
+ try {
+ pgmAaCat.moveDataType(complexUnion, DataTypeConflictHandler.DEFAULT_HANDLER);
+ }
+ catch (DataTypeDependencyException e) {
+ // don't care
+ }
+ });
+ waitForSwing();
+ assertEquals(pgmAaCat.getCategoryPathName(), model.getOriginalCategoryPath().getPath());
}
@Test
public void testComponentDataTypeRemoved() {
- try {
- init(complexUnion, pgmTestCat, false);
-
- assertEquals(21, model.getNumComponents());
- SwingUtilities.invokeLater(() -> complexUnion.getDataTypeManager().remove(
- simpleStructure, TaskMonitor.DUMMY));
- waitForSwing();
- assertEquals(15, model.getNumComponents());
- }
- finally {
- cleanup();
- }
+ init(complexUnion, pgmTestCat, false);
+
+ assertEquals(21, model.getNumComponents());
+ SwingUtilities.invokeLater(() -> complexUnion.getDataTypeManager()
+ .remove(
+ simpleStructure, TaskMonitor.DUMMY));
+ waitForSwing();
+ assertEquals(15, model.getNumComponents());
}
@Test
public void testOnlyComponentDataTypeRemoved() throws Exception {
- try {
- init(emptyUnion, pgmTestCat, false);
-
- SwingUtilities.invokeLater(() -> {
- try {
- model.add(simpleUnion);
- }
- catch (UsrException e) {
- Assert.fail();
- }
- });
- waitForSwing();
- assertTrue(simpleUnion.isEquivalent(getDataType(0)));
-
- SwingUtilities.invokeLater(() -> simpleUnion.getDataTypeManager().remove(simpleUnion,
- TaskMonitor.DUMMY));
- waitForSwing();
- assertEquals(0, model.getNumComponents());
- }
- finally {
- cleanup();
- }
+ init(emptyUnion, pgmTestCat, false);
+
+ SwingUtilities.invokeLater(() -> {
+ try {
+ model.add(simpleUnion);
+ }
+ catch (UsrException e) {
+ Assert.fail();
+ }
+ });
+ waitForSwing();
+ assertTrue(simpleUnion.isEquivalent(getDataType(0)));
+
+ SwingUtilities.invokeLater(() -> simpleUnion.getDataTypeManager()
+ .remove(simpleUnion,
+ TaskMonitor.DUMMY));
+ waitForSwing();
+ assertEquals(0, model.getNumComponents());
}
@Test
public void testEditedDataTypeRemoved() {
- try {
- init(complexUnion, pgmTestCat, false);
+ init(complexUnion, pgmTestCat, false);
- int num = model.getNumComponents();
+ int num = model.getNumComponents();
- // Clone the data types we want to hold onto for comparison later, since reload can close the viewDTM.
- DataType dt18 = getDataType(18).clone(programDTM);
- DataType dt20 = getDataType(20).clone(programDTM);
+ // Clone the data types we want to hold onto for comparison later, since reload can close the viewDTM.
+ DataType dt18 = getDataType(18).clone(programDTM);
+ DataType dt20 = getDataType(20).clone(programDTM);
- DataTypeManager dtm = complexUnion.getDataTypeManager();
- Union refUnion = (Union) dtm.getDataType("/testCat/refUnion");
- assertNotNull(refUnion);
+ DataTypeManager dtm = complexUnion.getDataTypeManager();
+ Union refUnion = (Union) dtm.getDataType("/testCat/refUnion");
+ assertNotNull(refUnion);
- SwingUtilities.invokeLater(() -> dtm.remove(refUnion, TaskMonitor.DUMMY)); // remove refUnion
- waitForSwing();
+ SwingUtilities.invokeLater(() -> dtm.remove(refUnion, TaskMonitor.DUMMY)); // remove refUnion
+ waitForSwing();
- // refUnion* gets removed (1 component)
- num -= 1;
- assertEquals(num, model.getNumComponents());
- assertTrue(dt18.isEquivalent(getDataType(18)));
- assertTrue(dt20.isEquivalent(getDataType(19)));
+ // refUnion* gets removed (1 component)
+ num -= 1;
+ assertEquals(num, model.getNumComponents());
+ assertTrue(dt18.isEquivalent(getDataType(18)));
+ assertTrue(dt20.isEquivalent(getDataType(19)));
- SwingUtilities.invokeLater(
- () -> simpleUnion.getDataTypeManager().remove(simpleUnion, TaskMonitor.DUMMY));
- waitForSwing();
+ SwingUtilities.invokeLater(
+ () -> simpleUnion.getDataTypeManager().remove(simpleUnion, TaskMonitor.DUMMY));
+ waitForSwing();
- // All components (3 total) which were dependent upon simpleUnion are removed
- num -= 3;
- assertEquals(num, model.getNumComponents());
- }
- finally {
- cleanup();
- }
+ // All components (3 total) which were dependent upon simpleUnion are removed
+ num -= 3;
+ assertEquals(num, model.getNumComponents());
}
@Test
public void testComponentDataTypeRenamed() throws Exception {
- try {
- init(complexUnion, pgmTestCat, false);
-
- assertTrue(simpleUnion.isEquivalent(getDataType(3)));
- assertEquals(simpleUnion.getPathName(), getDataType(3).getPathName());
- SwingUtilities.invokeLater(() -> {
- try {
- simpleUnion.setName("NewSimpleUnion");
- }
- catch (UsrException e) {
- Assert.fail();
- }
- });
- waitForSwing();
- assertTrue(simpleUnion.isEquivalent(getDataType(3)));
- assertEquals(simpleUnion.getPathName(), getDataType(3).getPathName());
- }
- finally {
- cleanup();
- }
+ init(complexUnion, pgmTestCat, false);
+
+ assertTrue(simpleUnion.isEquivalent(getDataType(3)));
+ assertEquals(simpleUnion.getPathName(), getDataType(3).getPathName());
+ SwingUtilities.invokeLater(() -> {
+ try {
+ simpleUnion.setName("NewSimpleUnion");
+ }
+ catch (UsrException e) {
+ Assert.fail();
+ }
+ });
+ waitForSwing();
+ assertTrue(simpleUnion.isEquivalent(getDataType(3)));
+ assertEquals(simpleUnion.getPathName(), getDataType(3).getPathName());
}
@Test
public void testOldNameEditedDataTypeRenamed() throws Exception {
- try {
- init(complexUnion, pgmTestCat, false);
-
- assertEquals(complexUnion.getDataTypePath(), model.getOriginalDataTypePath());
- assertEquals(complexUnion.getDataTypePath(), model.viewComposite.getDataTypePath());
- SwingUtilities.invokeLater(() -> {
- try {
- complexUnion.setName("NewComplexUnion");
- }
- catch (UsrException e) {
- Assert.fail();
- }
- });
- waitForSwing();
- assertEquals(complexUnion.getDataTypePath(), model.getOriginalDataTypePath());
- assertEquals(complexUnion.getPathName(), model.viewComposite.getPathName());
- assertEquals("NewComplexUnion", model.getCompositeName());
- }
- finally {
- cleanup();
- }
+ init(complexUnion, pgmTestCat, false);
+
+ assertEquals(complexUnion.getDataTypePath(), model.getOriginalDataTypePath());
+ assertEquals(complexUnion.getDataTypePath(), model.viewComposite.getDataTypePath());
+ SwingUtilities.invokeLater(() -> {
+ try {
+ complexUnion.setName("NewComplexUnion");
+ }
+ catch (UsrException e) {
+ Assert.fail();
+ }
+ });
+ waitForSwing();
+ assertEquals(complexUnion.getDataTypePath(), model.getOriginalDataTypePath());
+ assertEquals(complexUnion.getPathName(), model.viewComposite.getPathName());
+ assertEquals("NewComplexUnion", model.getCompositeName());
}
@Test
public void testNewNameEditedDataTypeRenamed() throws Exception {
- try {
- init(complexUnion, pgmTestCat, false);
-
- SwingUtilities.invokeLater(() -> {
- try {
- model.setName("EditedComplexUnion");
- }
- catch (UsrException e) {
- Assert.fail();
- }
- });
- waitForSwing();
- assertEquals(complexUnion.getDataTypePath(), model.getOriginalDataTypePath());
- assertTrue(!complexUnion.getPathName().equals(model.viewComposite.getPathName()));
-
- SwingUtilities.invokeLater(() -> {
- try {
- complexUnion.setName("NewComplexUnion");
- }
- catch (UsrException e) {
- Assert.fail();
- }
- });
- waitForSwing();
- assertEquals(complexUnion.getDataTypePath(), model.getOriginalDataTypePath());
- assertTrue(!complexUnion.getPathName().equals(model.viewComposite.getPathName()));
- assertEquals("EditedComplexUnion", model.getCompositeName());
- }
- finally {
- cleanup();
- }
+ init(complexUnion, pgmTestCat, false);
+
+ SwingUtilities.invokeLater(() -> {
+ try {
+ model.setName("EditedComplexUnion");
+ }
+ catch (UsrException e) {
+ Assert.fail();
+ }
+ });
+ waitForSwing();
+ assertEquals(complexUnion.getDataTypePath(), model.getOriginalDataTypePath());
+ assertTrue(!complexUnion.getPathName().equals(model.viewComposite.getPathName()));
+
+ SwingUtilities.invokeLater(() -> {
+ try {
+ complexUnion.setName("NewComplexUnion");
+ }
+ catch (UsrException e) {
+ Assert.fail();
+ }
+ });
+ waitForSwing();
+ assertEquals(complexUnion.getDataTypePath(), model.getOriginalDataTypePath());
+ assertTrue(!complexUnion.getPathName().equals(model.viewComposite.getPathName()));
+ assertEquals("EditedComplexUnion", model.getCompositeName());
}
@Test
public void testComponentDataTypeReplaced() throws Exception {
- try {
- init(complexUnion, pgmTestCat, false);
-
- int numComps = model.getNumComponents();
- assertEquals(87, complexUnion.getComponent(12).getDataType().getLength());
- assertEquals(29, complexUnion.getComponent(15).getDataType().getLength());
- assertEquals(29, complexUnion.getComponent(20).getDataType().getLength());
- assertEquals(87, complexUnion.getComponent(12).getLength());
- assertEquals(29, complexUnion.getComponent(15).getLength());
- assertEquals(29, complexUnion.getComponent(20).getLength());
- assertEquals(87, complexUnion.getLength());
- assertEquals(21, complexUnion.getNumComponents());
- assertEquals(87, getDataType(12).getLength());
- assertEquals(29, getDataType(15).getLength());
- assertEquals(29, getDataType(20).getLength());
- assertEquals(87, model.getComponent(12).getLength());
- assertEquals(29, model.getComponent(15).getLength());
- assertEquals(29, model.getComponent(20).getLength());
- assertEquals(87, model.getLength());
-
- final Structure newSimpleStructure =
- new StructureDataType(new CategoryPath("/aa/bb"), "simpleStructure", 10);
- newSimpleStructure.add(new PointerDataType(), 8);
- newSimpleStructure.replace(2, new CharDataType(), 1);
-
- // Change the struct. simpleStructure was 29 bytes.
- programDTM.replaceDataType(simpleStructure, newSimpleStructure, true);
- waitForSwing();
-
- // Check that the viewer now has the modified struct.
- // Components 12, 15, & 21 all change size.
- assertEquals(54, complexUnion.getComponent(12).getDataType().getLength());
- assertEquals(18, complexUnion.getComponent(15).getDataType().getLength());
- assertEquals(18, complexUnion.getComponent(20).getDataType().getLength());
- assertEquals(54, complexUnion.getComponent(12).getLength());
- assertEquals(18, complexUnion.getComponent(15).getLength());
- assertEquals(18, complexUnion.getComponent(20).getLength());
- assertEquals(54, getDataType(12).getLength());
- assertEquals(18, getDataType(15).getLength());
- assertEquals(18, getDataType(20).getLength());
- assertEquals(54, model.getComponent(12).getLength());
- assertEquals(18, model.getComponent(15).getLength());
- assertEquals(18, model.getComponent(20).getLength());
- assertEquals(56, model.getLength());
- assertEquals(numComps, model.getNumComponents());
- }
- finally {
- cleanup();
- }
+ init(complexUnion, pgmTestCat, false);
+
+ int numComps = model.getNumComponents();
+ assertEquals(87, complexUnion.getComponent(12).getDataType().getLength());
+ assertEquals(29, complexUnion.getComponent(15).getDataType().getLength());
+ assertEquals(29, complexUnion.getComponent(20).getDataType().getLength());
+ assertEquals(87, complexUnion.getComponent(12).getLength());
+ assertEquals(29, complexUnion.getComponent(15).getLength());
+ assertEquals(29, complexUnion.getComponent(20).getLength());
+ assertEquals(87, complexUnion.getLength());
+ assertEquals(21, complexUnion.getNumComponents());
+ assertEquals(87, getDataType(12).getLength());
+ assertEquals(29, getDataType(15).getLength());
+ assertEquals(29, getDataType(20).getLength());
+ assertEquals(87, model.getComponent(12).getLength());
+ assertEquals(29, model.getComponent(15).getLength());
+ assertEquals(29, model.getComponent(20).getLength());
+ assertEquals(87, model.getLength());
+
+ final Structure newSimpleStructure =
+ new StructureDataType(new CategoryPath("/aa/bb"), "simpleStructure", 10);
+ newSimpleStructure.add(new PointerDataType(), 8);
+ newSimpleStructure.replace(2, new CharDataType(), 1);
+
+ // Change the struct. simpleStructure was 29 bytes.
+ programDTM.replaceDataType(simpleStructure, newSimpleStructure, true);
+ waitForSwing();
+
+ // Check that the viewer now has the modified struct.
+ // Components 12, 15, & 21 all change size.
+ assertEquals(54, complexUnion.getComponent(12).getDataType().getLength());
+ assertEquals(18, complexUnion.getComponent(15).getDataType().getLength());
+ assertEquals(18, complexUnion.getComponent(20).getDataType().getLength());
+ assertEquals(54, complexUnion.getComponent(12).getLength());
+ assertEquals(18, complexUnion.getComponent(15).getLength());
+ assertEquals(18, complexUnion.getComponent(20).getLength());
+ assertEquals(54, getDataType(12).getLength());
+ assertEquals(18, getDataType(15).getLength());
+ assertEquals(18, getDataType(20).getLength());
+ assertEquals(54, model.getComponent(12).getLength());
+ assertEquals(18, model.getComponent(15).getLength());
+ assertEquals(18, model.getComponent(20).getLength());
+ assertEquals(56, model.getLength());
+ assertEquals(numComps, model.getNumComponents());
}
@Test
public void testModifiedEditedDataTypeReplacedYes() throws Exception {
- Window dialog;
- try {
- init(complexUnion, pgmTestCat, false);
-
- runSwing(() -> {
- try {
- model.insert(model.getNumComponents(), new ByteDataType(), 1);
- model.insert(model.getNumComponents(), new PointerDataType(), 4);
- }
- catch (UsrException e) {
- Assert.fail(e.getMessage());
- }
- });
-
- final Union newComplexUnion =
- new UnionDataType(pgmTestCat.getCategoryPath(), complexUnion.getName());
- newComplexUnion.add(new PointerDataType(), 8);
- newComplexUnion.add(new CharDataType(), 1);
-
- programDTM.replaceDataType(complexUnion, newComplexUnion, true);
- waitForSwing();
- DataType origCopy = newComplexUnion.clone(null);
-
- // Verify the Reload Union Editor? dialog is displayed.
- dialog = env.waitForWindow("Reload Union Editor?", 1000);
- assertNotNull(dialog);
- pressButtonByText(dialog, "Yes");
- dialog.dispose();
- dialog = null;
-
- assertEquals(((Union) origCopy).getNumComponents(), model.getNumComponents());
- assertTrue(origCopy.isEquivalent(model.viewComposite));
- }
- finally {
- dialog = null;
- cleanup();
- }
+ init(complexUnion, pgmTestCat, false);
+
+ runSwing(() -> {
+ try {
+ model.insert(model.getNumComponents(), new ByteDataType(), 1);
+ model.insert(model.getNumComponents(), new PointerDataType(), 4);
+ }
+ catch (UsrException e) {
+ Assert.fail(e.getMessage());
+ }
+ });
+
+ final Union newComplexUnion =
+ new UnionDataType(pgmTestCat.getCategoryPath(), complexUnion.getName());
+ newComplexUnion.add(new PointerDataType(), 8);
+ newComplexUnion.add(new CharDataType(), 1);
+
+ programDTM.replaceDataType(complexUnion, newComplexUnion, true);
+ waitForSwing();
+ DataType origCopy = newComplexUnion.clone(null);
+
+ // Verify the Reload Union Editor? dialog is displayed.
+ Window dialog = waitForWindow("Reload Union Editor?");
+ assertNotNull(dialog);
+ pressButtonByText(dialog, "Yes");
+ dialog.dispose();
+ dialog = null;
+
+ assertEquals(((Union) origCopy).getNumComponents(), model.getNumComponents());
+ assertTrue(origCopy.isEquivalent(model.viewComposite));
}
@Test
public void testModifiedEditedDataTypeReplacedNo() throws Exception {
- Window dialog;
- try {
- init(complexUnion, pgmTestCat, false);
-
- runSwing(() -> {
- try {
- model.insert(model.getNumComponents(), new ByteDataType(), 1);
- model.insert(model.getNumComponents(), new PointerDataType(), 4);
- }
- catch (UsrException e) {
- Assert.fail(e.getMessage());
- }
- });
- DataType viewCopy = model.viewComposite.clone(null);
-
- final Union newComplexUnion =
- new UnionDataType(pgmTestCat.getCategoryPath(), complexUnion.getName());
- newComplexUnion.add(new PointerDataType(), 8);
- newComplexUnion.add(new CharDataType(), 1);
-
- programDTM.replaceDataType(complexUnion, newComplexUnion, true);
- waitForSwing();
-
- // Verify the Reload Union Editor? dialog is displayed.
- dialog = env.waitForWindow("Reload Union Editor?", 1000);
- assertNotNull(dialog);
- pressButtonByText(dialog, "No");
- dialog.dispose();
- dialog = null;
-
- assertEquals(((Union) viewCopy).getNumComponents(), model.getNumComponents());
- assertTrue(viewCopy.isEquivalent(model.viewComposite));
- }
- finally {
- dialog = null;
- cleanup();
- }
+ init(complexUnion, pgmTestCat, false);
+
+ runSwing(() -> {
+ try {
+ model.insert(model.getNumComponents(), new ByteDataType(), 1);
+ model.insert(model.getNumComponents(), new PointerDataType(), 4);
+ }
+ catch (UsrException e) {
+ Assert.fail(e.getMessage());
+ }
+ });
+ DataType viewCopy = model.viewComposite.clone(null);
+
+ final Union newComplexUnion =
+ new UnionDataType(pgmTestCat.getCategoryPath(), complexUnion.getName());
+ newComplexUnion.add(new PointerDataType(), 8);
+ newComplexUnion.add(new CharDataType(), 1);
+
+ programDTM.replaceDataType(complexUnion, newComplexUnion, true);
+ waitForSwing();
+
+ // Verify the Reload Union Editor? dialog is displayed.
+ Window dialog = waitForWindow("Reload Union Editor?");
+ assertNotNull(dialog);
+ pressButtonByText(dialog, "No");
+ dialog.dispose();
+ dialog = null;
+
+ assertEquals(((Union) viewCopy).getNumComponents(), model.getNumComponents());
+ assertTrue(viewCopy.isEquivalent(model.viewComposite));
}
@Test
public void testUnModifiedEditedDataTypeReplaced() throws Exception {
- try {
- init(complexUnion, pgmTestCat, false);
+ init(complexUnion, pgmTestCat, false);
- Union newComplexUnion =
- new UnionDataType(pgmTestCat.getCategoryPath(), complexUnion.getName());
- newComplexUnion.add(new PointerDataType(), 8);
- newComplexUnion.add(new CharDataType(), 1);
+ Union newComplexUnion =
+ new UnionDataType(pgmTestCat.getCategoryPath(), complexUnion.getName());
+ newComplexUnion.add(new PointerDataType(), 8);
+ newComplexUnion.add(new CharDataType(), 1);
- assertTrue(complexUnion.isEquivalent(model.viewComposite));
- programDTM.replaceDataType(complexUnion, newComplexUnion, true);
- waitForSwing();
- assertTrue(newComplexUnion.isEquivalent(model.viewComposite));
- }
- finally {
- cleanup();
- }
+ assertTrue(complexUnion.isEquivalent(model.viewComposite));
+ programDTM.replaceDataType(complexUnion, newComplexUnion, true);
+ waitForSwing();
+ assertTrue(newComplexUnion.isEquivalent(model.viewComposite));
}
}
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/UnionEditorProviderTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/UnionEditorProviderTest.java
index c74796ed28..df0c79785f 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/UnionEditorProviderTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/UnionEditorProviderTest.java
@@ -135,7 +135,6 @@ public class UnionEditorProviderTest extends AbstractUnionEditorTest {
finally {
dialog = null;
program.removeListener(restoreListener);
- cleanup();
}
}
@@ -175,7 +174,6 @@ public class UnionEditorProviderTest extends AbstractUnionEditorTest {
}
finally {
program.removeListener(restoreListener);
- cleanup();
}
}
diff --git a/Ghidra/Framework/Generic/src/main/java/generic/test/AbstractGenericTest.java b/Ghidra/Framework/Generic/src/main/java/generic/test/AbstractGenericTest.java
index 32bd901970..09fd222752 100644
--- a/Ghidra/Framework/Generic/src/main/java/generic/test/AbstractGenericTest.java
+++ b/Ghidra/Framework/Generic/src/main/java/generic/test/AbstractGenericTest.java
@@ -1384,7 +1384,10 @@ public abstract class AbstractGenericTest extends AbstractGTest {
public static TableCellEditor editCell(final JTable table, final int row, final int col) {
waitForSwing();
+
runSwing(() -> table.setRowSelectionInterval(row, row));
+ waitForSwing();
+
runSwing(() -> table.editCellAt(row, col));
waitForSwing();
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeDB.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeDB.java
index 4a021155d3..930c028bcf 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeDB.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeDB.java
@@ -300,16 +300,19 @@ abstract class DataTypeDB extends DatabaseObject implements DataType {
}
@Override
- public void setName(String name) throws InvalidNameException, DuplicateNameException {
+ public void setName(String newName) throws InvalidNameException, DuplicateNameException {
lock.acquire();
try {
checkDeleted();
+ if (getName().equals(newName)) {
+ return;
+ }
CategoryPath categoryPath = getCategoryPath();
- if (dataMgr.getDataType(categoryPath, name) != null) {
- throw new DuplicateNameException("DataType named " + name +
+ if (dataMgr.getDataType(categoryPath, newName) != null) {
+ throw new DuplicateNameException("DataType named " + newName +
" already exists in category " + categoryPath.getPath());
}
- doSetName(name);
+ doSetName(newName);
}
finally {
lock.release();
@@ -338,9 +341,12 @@ abstract class DataTypeDB extends DatabaseObject implements DataType {
lock.acquire();
try {
checkDeleted();
- DataType type = dataMgr.getDataType(path, getName());
- if (type != null) {
- throw new DuplicateNameException("DataType named " + getDisplayName() +
+ if (getCategoryPath().equals(path)) {
+ return;
+ }
+ String currentName = getName();
+ if (dataMgr.getDataType(path, currentName) != null) {
+ throw new DuplicateNameException("DataType named " + currentName +
" already exists in category " + path.getPath());
}
doSetCategoryPath(path);
@@ -374,7 +380,11 @@ abstract class DataTypeDB extends DatabaseObject implements DataType {
lock.acquire();
try {
checkDeleted();
- if (dataMgr.getDataType(path, name) != null) {
+ DataType dt = dataMgr.getDataType(path, name);
+ if (dt != null) {
+ if (dt == this) {
+ return; // unchanged
+ }
throw new DuplicateNameException(
"DataType named " + name + " already exists in category " + path.getPath());
}
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/EnumDB.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/EnumDB.java
index 66bbfc2333..93d9a0d5a3 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/EnumDB.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/EnumDB.java
@@ -393,6 +393,9 @@ class EnumDB extends DataTypeDB implements Enum {
@Override
public DataType clone(DataTypeManager dtm) {
+ if (dtm == getDataTypeManager()) {
+ return this;
+ }
EnumDataType enumDataType =
new EnumDataType(getCategoryPath(), getName(), getLength(), getUniversalID(),
getSourceArchive(), getLastChangeTime(), getLastChangeTimeInSourceArchive(), dtm);
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/FunctionDefinitionDB.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/FunctionDefinitionDB.java
index e93c951d56..b0fdce3a9b 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/FunctionDefinitionDB.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/FunctionDefinitionDB.java
@@ -223,6 +223,9 @@ class FunctionDefinitionDB extends DataTypeDB implements FunctionDefinition {
@Override
public DataType clone(DataTypeManager dtm) {
+ if (dtm == getDataTypeManager()) {
+ return this;
+ }
return new FunctionDefinitionDataType(getCategoryPath(), getName(), this, getUniversalID(),
getSourceArchive(), getLastChangeTime(), getLastChangeTimeInSourceArchive(), dtm);
}
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/StructureDB.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/StructureDB.java
index 90ad808a11..5acef9ca97 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/StructureDB.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/StructureDB.java
@@ -806,6 +806,9 @@ class StructureDB extends CompositeDB implements StructureInternal {
*/
@Override
public Structure clone(DataTypeManager dtm) {
+ if (dtm == getDataTypeManager()) {
+ return this;
+ }
StructureDataType struct =
new StructureDataType(getCategoryPath(), getName(), structLength, getUniversalID(),
getSourceArchive(), getLastChangeTime(), getLastChangeTimeInSourceArchive(), dtm);
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/UnionDB.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/UnionDB.java
index 95c99b23ac..0334ac0ba2 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/UnionDB.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/UnionDB.java
@@ -440,6 +440,9 @@ class UnionDB extends CompositeDB implements UnionInternal {
@Override
public Union clone(DataTypeManager dtm) {
+ if (dtm == getDataTypeManager()) {
+ return this;
+ }
UnionDataType union = new UnionDataType(getCategoryPath(), getName(), getUniversalID(),
getSourceArchive(), getLastChangeTime(), getLastChangeTimeInSourceArchive(), dtm);
union.setDescription(getDescription());