Ghidra is a software reverse engineering (SRE) framework
Merge remote-tracking branch 'origin/GP-1914-dragonmacher-dtm-search-actions'
ghidra1662e3415ee42
diff --cc Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPluginTest.javaindex ceae705122,0d2e289fe6..1974e904d1--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPluginTest.java+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPluginTest.java@@@ -63,8 -61,9 +63,9 @@@ import ghidra.program.database.ProgramBimport ghidra.program.database.ProgramDB;import ghidra.program.database.data.ProgramDataTypeManager;import ghidra.program.model.data.*;+ import ghidra.program.model.data.Enum;-import ghidra.test.AbstractGhidraHeadedIntegrationTest;-import ghidra.test.TestEnv;+import ghidra.program.model.listing.Program;+import ghidra.test.*;import util.CollectionUtils;import utilities.util.FileUtilities;@@@ -685,84 -685,6 +686,82 @@@ public class DataTypeManagerPluginTestcheckNodesCollapsed(rootNode);}+ @Test+ public void testTreeRemembersSelectionWhenSwitchingPrograms() throws Exception {++ env.open(new ClassicSampleX86ProgramBuilder().getProgram());++ String p1 = "Program1";+ String p2 = "sample";++ // Open and select a path in the current program,+ selectPath(p2, "CoolUnion");++ // Now select a path in the first program+ switchTo(p1);+ selectPath(p1, "MISC", "ArrayStruct");++ // Switch back and forth and the selected paths should be restored+ switchTo(p2);+ assertSelectedPath(p2, "CoolUnion");++ switchTo(p1);+ assertSelectedPath(p1, "MISC", "ArrayStruct");++ switchTo(p2);+ assertSelectedPath(p2, "CoolUnion");+ }++ private void assertSelectedPath(String... expectedPath) {++ String[] fullExpectedPath = new String[expectedPath.length + 1];+ fullExpectedPath[0] = "Data Types";+ System.arraycopy(expectedPath, 0, fullExpectedPath, 1, expectedPath.length);++ waitForTree();+ TreePath treePath = runSwing(() -> tree.getSelectionPath());+ assertNotNull("No tree path selected", treePath);+ Object[] treePathElements = treePath.getPath();+ List<String> actualNamesList =- Arrays.stream(treePathElements)- .map(o -> o.toString())- .collect(Collectors.toList());++ Arrays.stream(treePathElements).map(o -> o.toString()).collect(Collectors.toList());+ String[] actualPath = actualNamesList.toArray(String[]::new);+ assertArraysEqualOrdered("Tree path not seleced", fullExpectedPath, actualPath);+ }++ private void switchTo(String programName) {++ ProgramManagerPlugin pm = getPlugin(tool, ProgramManagerPlugin.class);+ Program[] programs = pm.getAllOpenPrograms();+ for (Program p : programs) {+ String name = p.getName();+ if (name.equals(programName)) {+ pm.setCurrentProgram(p);+ waitForBusyTool(tool);+ return;+ }+ }+ fail("Could not switch to program '%s'".formatted(programName));+ }++ private void selectPath(String... names) {++ GTreeNode root = tree.getModelRoot();+ GTreeNode node = root;+ for (String name : names) {+ GTreeNode child = node.getChild(name);+ String message = "Could not find '%s' in '%s'".formatted(name, Arrays.toString(names));+ assertNotNull(message, child);++ tree.expandPath(node);+ waitForTree();++ node = child;+ }++ tree.setSelectedNode(node);+ waitForTree();+ }+@Testpublic void testDataTypePreviewCopyHtmlText() throws Exception {@@@ -1132,8 -1074,8 +1151,7 @@@Collection<DataTypeNode> values = nodesByName.values();for (DataTypeNode node : values) {DataType dt = node.getDataType();-- assertTrue("Found an array in '%s'".formatted(dtm.getName()),-- !(dt instanceof Array));++ assertTrue("Found an array in '%s'".formatted(dtm.getName()), !(dt instanceof Array));}}