mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
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.
This commit is contained in:
parent
f57cf98f56
commit
5eed321004
35 changed files with 498 additions and 936 deletions
|
@ -471,26 +471,12 @@ 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());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void endTransaction(final boolean saveChanges) {
|
||||
runSwing(() -> {
|
||||
try {
|
||||
program.endTransaction(txId, saveChanges);
|
||||
}
|
||||
catch (Exception e) {
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected class RestoreListener implements DomainObjectListener {
|
||||
@Override
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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)) {
|
||||
// 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) {
|
||||
commit = false;
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
endTransaction(commit);
|
||||
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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
dt = dt.clone(dataTypeManager);
|
||||
}
|
||||
|
||||
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) {
|
||||
commit = false;
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
endTransaction(commit);
|
||||
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();
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
final Union unionDt = dt;
|
||||
runSwing(() -> {
|
||||
installProvider(new UnionEditorProvider(plugin, unionDt, showInHex));
|
||||
model = provider.getModel();
|
||||
});
|
||||
assertIsPackingEnabled(false);
|
||||
assertIsDefaultAligned();
|
||||
assertActualAlignment(1);
|
||||
startTransaction("Modify Program");
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
// Create overlapping trasnaction to handle all changes
|
||||
persistentTxId = program.startTransaction("Modify Program");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cleanup() {
|
||||
endTransaction(false);
|
||||
super.cleanup();
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
if (persistentTxId != 0) {
|
||||
program.endTransaction(persistentTxId, true);
|
||||
}
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init(Union dt, final Category cat, final boolean showInHex) {
|
||||
super.init(dt, cat, showInHex);
|
||||
assertIsPackingEnabled(false);
|
||||
assertIsDefaultAligned();
|
||||
assertActualAlignment(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -78,7 +64,6 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
|
||||
@Test
|
||||
public void testComponentDtCategoryMoved() throws Exception {
|
||||
try {
|
||||
init(complexUnion, pgmTestCat, false);
|
||||
|
||||
assertEquals("/aa/bb", getDataType(20).getCategoryPath().getPath());
|
||||
|
@ -86,27 +71,20 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
waitForSwing();
|
||||
assertEquals("/testCat/bb", getDataType(20).getCategoryPath().getPath());
|
||||
}
|
||||
finally {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@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(
|
||||
assertTrue(model.getOriginalCategoryPath()
|
||||
.getPath()
|
||||
.startsWith(
|
||||
pgmTestCat.getCategoryPathName()));
|
||||
assertEquals(pgmBbCat.getCategoryPathName(), model.getOriginalCategoryPath().getPath());
|
||||
}
|
||||
finally {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComponentDtCategoryRemoved() {
|
||||
|
@ -130,7 +108,6 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
endTransaction(true);
|
||||
}
|
||||
|
||||
try {
|
||||
init(complexUnion, tempCat, false);
|
||||
|
||||
int num = model.getNumComponents();
|
||||
|
@ -139,7 +116,8 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
DataType dt20 = getDataType(20).clone(programDTM);
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
programDTM.remove(complexUnion, TaskMonitor.DUMMY);
|
||||
programDTM.getCategory(pgmRootCat.getCategoryPath()).removeCategory("Temp",
|
||||
programDTM.getCategory(pgmRootCat.getCategoryPath())
|
||||
.removeCategory("Temp",
|
||||
TaskMonitor.DUMMY);
|
||||
});
|
||||
|
||||
|
@ -149,14 +127,9 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
assertTrue(dt18.isEquivalent(getDataType(18)));
|
||||
assertTrue(dt20.isEquivalent(getDataType(19)));
|
||||
}
|
||||
finally {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComponentDtCategoryRenamed() throws Exception {
|
||||
try {
|
||||
init(complexUnion, pgmTestCat, false);
|
||||
|
||||
assertEquals("/aa/bb", getDataType(20).getCategoryPath().getPath());
|
||||
|
@ -164,14 +137,9 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
waitForSwing();
|
||||
assertEquals("/aa/NewBB2", getDataType(20).getCategoryPath().getPath());
|
||||
}
|
||||
finally {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEditedDtCategoryRenamed() throws Exception {
|
||||
try {
|
||||
init(simpleUnion, pgmBbCat, false);
|
||||
model = provider.getModel();
|
||||
|
||||
|
@ -180,10 +148,6 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
waitForSwing();
|
||||
assertEquals("/aa/NewBB2", model.getOriginalCategoryPath().getPath());
|
||||
}
|
||||
finally {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDataTypeAdded() {
|
||||
|
@ -194,7 +158,6 @@ 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.
|
||||
|
@ -220,15 +183,10 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
assertEquals(len20, model.getComponent(20).getLength());
|
||||
assertEquals(len12, model.getLength());
|
||||
}
|
||||
finally {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModifiedEditedDataTypeChangedYes() throws Exception {
|
||||
Window dialog;
|
||||
try {
|
||||
|
||||
init(complexUnion, pgmTestCat, false);
|
||||
|
||||
runSwing(() -> {
|
||||
|
@ -246,7 +204,7 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
DataType origCopy = complexUnion.clone(null);
|
||||
|
||||
// Verify the Reload Union Editor? dialog is displayed.
|
||||
dialog = waitForWindow("Reload Union Editor?");
|
||||
Window dialog = waitForWindow("Reload Union Editor?");
|
||||
assertNotNull(dialog);
|
||||
pressButtonByText(dialog, "Yes");
|
||||
dialog.dispose();
|
||||
|
@ -256,16 +214,9 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
assertEquals(((Union) origCopy).getNumComponents(), model.getNumComponents());
|
||||
assertTrue(origCopy.isEquivalent(model.viewComposite));
|
||||
}
|
||||
finally {
|
||||
dialog = null;
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModifiedEditedDataTypeChangedNo() throws Exception {
|
||||
Window dialog;
|
||||
try {
|
||||
init(complexUnion, pgmTestCat, false);
|
||||
|
||||
runSwing(() -> {
|
||||
|
@ -283,7 +234,7 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
waitForSwing();
|
||||
|
||||
// Verify the Reload Union Editor? dialog is displayed.
|
||||
dialog = waitForWindow("Reload Union Editor?");
|
||||
Window dialog = waitForWindow("Reload Union Editor?");
|
||||
assertNotNull(dialog);
|
||||
pressButtonByText(dialog, "No");
|
||||
dialog.dispose();
|
||||
|
@ -292,29 +243,18 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
assertEquals(((Union) viewCopy).getNumComponents(), model.getNumComponents());
|
||||
assertTrue(viewCopy.isEquivalent(model.viewComposite));
|
||||
}
|
||||
finally {
|
||||
dialog = null;
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnmodifiedEditedDataTypeChanged() {
|
||||
try {
|
||||
init(complexUnion, pgmTestCat, false);
|
||||
|
||||
SwingUtilities.invokeLater(() -> complexUnion.add(new CharDataType()));
|
||||
waitForSwing();
|
||||
assertTrue(complexUnion.isEquivalent(model.viewComposite));
|
||||
}
|
||||
finally {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComponentDataTypeMoved() {
|
||||
try {
|
||||
init(complexUnion, pgmTestCat, false);
|
||||
|
||||
assertEquals(21, model.getNumComponents());
|
||||
|
@ -335,14 +275,9 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
assertEquals(simpleStructure.getCategoryPath().getPath(),
|
||||
pgmAaCat.getCategoryPath().getPath());
|
||||
}
|
||||
finally {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEditedDataTypeMoved() {
|
||||
try {
|
||||
init(complexUnion, pgmTestCat, false);
|
||||
|
||||
assertEquals(pgmTestCat.getCategoryPathName(),
|
||||
|
@ -358,30 +293,21 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
waitForSwing();
|
||||
assertEquals(pgmAaCat.getCategoryPathName(), model.getOriginalCategoryPath().getPath());
|
||||
}
|
||||
finally {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComponentDataTypeRemoved() {
|
||||
try {
|
||||
init(complexUnion, pgmTestCat, false);
|
||||
|
||||
assertEquals(21, model.getNumComponents());
|
||||
SwingUtilities.invokeLater(() -> complexUnion.getDataTypeManager().remove(
|
||||
SwingUtilities.invokeLater(() -> complexUnion.getDataTypeManager()
|
||||
.remove(
|
||||
simpleStructure, TaskMonitor.DUMMY));
|
||||
waitForSwing();
|
||||
assertEquals(15, model.getNumComponents());
|
||||
}
|
||||
finally {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnlyComponentDataTypeRemoved() throws Exception {
|
||||
try {
|
||||
init(emptyUnion, pgmTestCat, false);
|
||||
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
|
@ -395,19 +321,15 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
waitForSwing();
|
||||
assertTrue(simpleUnion.isEquivalent(getDataType(0)));
|
||||
|
||||
SwingUtilities.invokeLater(() -> simpleUnion.getDataTypeManager().remove(simpleUnion,
|
||||
SwingUtilities.invokeLater(() -> simpleUnion.getDataTypeManager()
|
||||
.remove(simpleUnion,
|
||||
TaskMonitor.DUMMY));
|
||||
waitForSwing();
|
||||
assertEquals(0, model.getNumComponents());
|
||||
}
|
||||
finally {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEditedDataTypeRemoved() {
|
||||
try {
|
||||
init(complexUnion, pgmTestCat, false);
|
||||
|
||||
int num = model.getNumComponents();
|
||||
|
@ -437,14 +359,9 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
num -= 3;
|
||||
assertEquals(num, model.getNumComponents());
|
||||
}
|
||||
finally {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComponentDataTypeRenamed() throws Exception {
|
||||
try {
|
||||
init(complexUnion, pgmTestCat, false);
|
||||
|
||||
assertTrue(simpleUnion.isEquivalent(getDataType(3)));
|
||||
|
@ -461,14 +378,9 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
assertTrue(simpleUnion.isEquivalent(getDataType(3)));
|
||||
assertEquals(simpleUnion.getPathName(), getDataType(3).getPathName());
|
||||
}
|
||||
finally {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOldNameEditedDataTypeRenamed() throws Exception {
|
||||
try {
|
||||
init(complexUnion, pgmTestCat, false);
|
||||
|
||||
assertEquals(complexUnion.getDataTypePath(), model.getOriginalDataTypePath());
|
||||
|
@ -486,14 +398,9 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
assertEquals(complexUnion.getPathName(), model.viewComposite.getPathName());
|
||||
assertEquals("NewComplexUnion", model.getCompositeName());
|
||||
}
|
||||
finally {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewNameEditedDataTypeRenamed() throws Exception {
|
||||
try {
|
||||
init(complexUnion, pgmTestCat, false);
|
||||
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
|
@ -521,14 +428,9 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
assertTrue(!complexUnion.getPathName().equals(model.viewComposite.getPathName()));
|
||||
assertEquals("EditedComplexUnion", model.getCompositeName());
|
||||
}
|
||||
finally {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComponentDataTypeReplaced() throws Exception {
|
||||
try {
|
||||
init(complexUnion, pgmTestCat, false);
|
||||
|
||||
int numComps = model.getNumComponents();
|
||||
|
@ -574,15 +476,9 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
assertEquals(56, model.getLength());
|
||||
assertEquals(numComps, model.getNumComponents());
|
||||
}
|
||||
finally {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModifiedEditedDataTypeReplacedYes() throws Exception {
|
||||
Window dialog;
|
||||
try {
|
||||
init(complexUnion, pgmTestCat, false);
|
||||
|
||||
runSwing(() -> {
|
||||
|
@ -605,7 +501,7 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
DataType origCopy = newComplexUnion.clone(null);
|
||||
|
||||
// Verify the Reload Union Editor? dialog is displayed.
|
||||
dialog = env.waitForWindow("Reload Union Editor?", 1000);
|
||||
Window dialog = waitForWindow("Reload Union Editor?");
|
||||
assertNotNull(dialog);
|
||||
pressButtonByText(dialog, "Yes");
|
||||
dialog.dispose();
|
||||
|
@ -614,16 +510,9 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
assertEquals(((Union) origCopy).getNumComponents(), model.getNumComponents());
|
||||
assertTrue(origCopy.isEquivalent(model.viewComposite));
|
||||
}
|
||||
finally {
|
||||
dialog = null;
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModifiedEditedDataTypeReplacedNo() throws Exception {
|
||||
Window dialog;
|
||||
try {
|
||||
init(complexUnion, pgmTestCat, false);
|
||||
|
||||
runSwing(() -> {
|
||||
|
@ -646,7 +535,7 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
waitForSwing();
|
||||
|
||||
// Verify the Reload Union Editor? dialog is displayed.
|
||||
dialog = env.waitForWindow("Reload Union Editor?", 1000);
|
||||
Window dialog = waitForWindow("Reload Union Editor?");
|
||||
assertNotNull(dialog);
|
||||
pressButtonByText(dialog, "No");
|
||||
dialog.dispose();
|
||||
|
@ -655,15 +544,9 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
assertEquals(((Union) viewCopy).getNumComponents(), model.getNumComponents());
|
||||
assertTrue(viewCopy.isEquivalent(model.viewComposite));
|
||||
}
|
||||
finally {
|
||||
dialog = null;
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnModifiedEditedDataTypeReplaced() throws Exception {
|
||||
try {
|
||||
init(complexUnion, pgmTestCat, false);
|
||||
|
||||
Union newComplexUnion =
|
||||
|
@ -676,9 +559,5 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
|||
waitForSwing();
|
||||
assertTrue(newComplexUnion.isEquivalent(model.viewComposite));
|
||||
}
|
||||
finally {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue