mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
Merge remote-tracking branch 'origin/GP-0-dragonmacher-test-fixes-11-18-25'
This commit is contained in:
@@ -604,13 +604,13 @@ public class SymbolTreeProvider extends ComponentProviderAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void readConfigState(SaveState saveState) {
|
void readConfigState(SaveState saveState) {
|
||||||
navigateIncomingAction.setSelected(saveState.getBoolean("NAVIGTE_INCOMING", false));
|
navigateIncomingAction.setSelected(saveState.getBoolean("NAVIGATE_INCOMING", false));
|
||||||
navigateOutgoingAction.setSelected(saveState.getBoolean("NAVIGTE_OUTGOING", true));
|
navigateOutgoingAction.setSelected(saveState.getBoolean("NAVIGATE_OUTGOING", true));
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeConfigState(SaveState saveState) {
|
void writeConfigState(SaveState saveState) {
|
||||||
saveState.putBoolean("NAVIGTE_INCOMING", navigateIncomingAction.isSelected());
|
saveState.putBoolean("NAVIGATE_INCOMING", navigateIncomingAction.isSelected());
|
||||||
saveState.putBoolean("NAVIGTE_OUTGOING", navigateOutgoingAction.isSelected());
|
saveState.putBoolean("NAVIGATE_OUTGOING", navigateOutgoingAction.isSelected());
|
||||||
}
|
}
|
||||||
|
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
|||||||
@@ -407,18 +407,25 @@ public class ConsolePluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||||||
|
|
||||||
private void next() {
|
private void next() {
|
||||||
pressButtonByText(findDialog, "Next");
|
pressButtonByText(findDialog, "Next");
|
||||||
waitForTasks();
|
waitForNotBusy();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void previous() {
|
private void previous() {
|
||||||
pressButtonByText(findDialog, "Previous");
|
pressButtonByText(findDialog, "Previous");
|
||||||
waitForTasks();
|
waitForNotBusy();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void findAll(String text) {
|
private void findAll(String text) {
|
||||||
runSwing(() -> findDialog.setSearchText(text));
|
runSwing(() -> findDialog.setSearchText(text));
|
||||||
pressButtonByText(findDialog, "Find All");
|
pressButtonByText(findDialog, "Find All");
|
||||||
waitForTasks();
|
waitForNotBusy();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void waitForNotBusy() {
|
||||||
|
TextComponentSearcher searcher = (TextComponentSearcher) findDialog.getSearcher();
|
||||||
|
waitForSwing();
|
||||||
|
waitFor(() -> !searcher.isBusy());
|
||||||
|
waitForSwing();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertSearchModelHasNoSearchResults() {
|
private void assertSearchModelHasNoSearchResults() {
|
||||||
@@ -489,6 +496,7 @@ public class ConsolePluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||||||
private void selectRow(FindDialogResultsProvider resultsProvider, int row) {
|
private void selectRow(FindDialogResultsProvider resultsProvider, int row) {
|
||||||
GTable table = resultsProvider.getTable();
|
GTable table = resultsProvider.getTable();
|
||||||
runSwing(() -> table.selectRow(row));
|
runSwing(() -> table.selectRow(row));
|
||||||
|
waitForSwing();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verfiyHighlightColor(List<TestTextMatch> matches)
|
private void verfiyHighlightColor(List<TestTextMatch> matches)
|
||||||
@@ -523,7 +531,6 @@ public class ConsolePluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<TestTextMatch> getExpectedMatches() {
|
private List<TestTextMatch> getExpectedMatches() {
|
||||||
|
|
||||||
String searchText = findDialog.getSearchText();
|
String searchText = findDialog.getSearchText();
|
||||||
assertFalse(searchText.isEmpty());
|
assertFalse(searchText.isEmpty());
|
||||||
return getExpectedMatches(searchText);
|
return getExpectedMatches(searchText);
|
||||||
@@ -541,7 +548,7 @@ public class ConsolePluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||||||
|
|
||||||
int index = text.indexOf(searchText);
|
int index = text.indexOf(searchText);
|
||||||
while (index != -1) {
|
while (index != -1) {
|
||||||
results.add(new TestTextMatch(index, index + searchText.length()));
|
results.add(new TestTextMatch(searchText, index, index + searchText.length()));
|
||||||
index = text.indexOf(searchText, index + 1);
|
index = text.indexOf(searchText, index + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -559,7 +566,7 @@ public class ConsolePluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||||||
return waitForDialogComponent(FindDialog.class);
|
return waitForDialogComponent(FindDialog.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private record TestTextMatch(int start, int end) {
|
private record TestTextMatch(String searchText, int start, int end) {
|
||||||
|
|
||||||
boolean contains(int caret) {
|
boolean contains(int caret) {
|
||||||
return start <= caret && caret <= end;
|
return start <= caret && caret <= end;
|
||||||
@@ -567,7 +574,7 @@ public class ConsolePluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[" + start + ',' + end + ']';
|
return searchText + ": [" + start + ',' + end + ']';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import javax.swing.tree.TreePath;
|
|||||||
|
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
|
|
||||||
|
import docking.DefaultActionContext;
|
||||||
import docking.action.DockingActionIf;
|
import docking.action.DockingActionIf;
|
||||||
import docking.action.ToggleDockingAction;
|
import docking.action.ToggleDockingAction;
|
||||||
import docking.widgets.tree.GTree;
|
import docking.widgets.tree.GTree;
|
||||||
@@ -334,15 +335,15 @@ public class SymbolTreePlugin3Test extends AbstractGhidraHeadedIntegrationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSaveState() throws Exception {
|
public void testSaveState() throws Exception {
|
||||||
final ToggleDockingAction navigateIncomingAction =
|
ToggleDockingAction navigateIncomingAction =
|
||||||
(ToggleDockingAction) getAction(plugin, NavigateOnIncomingAction.NAME);
|
(ToggleDockingAction) getAction(plugin, NavigateOnIncomingAction.NAME);
|
||||||
assertNotNull(navigateIncomingAction);
|
assertNotNull(navigateIncomingAction);
|
||||||
runSwing(() -> navigateIncomingAction.setSelected(true));
|
setToggleActionSelected(navigateIncomingAction, new DefaultActionContext(), true);
|
||||||
|
|
||||||
SaveState saveState = new SaveState("Test");
|
SaveState saveState = new SaveState("Test");
|
||||||
plugin.writeConfigState(saveState);
|
plugin.writeConfigState(saveState);
|
||||||
|
|
||||||
assertTrue(saveState.getBoolean("GO_TO_TOGGLE_STATE", false));
|
assertTrue(saveState.getBoolean("NAVIGATE_INCOMING", false));
|
||||||
|
|
||||||
runSwing(() -> {
|
runSwing(() -> {
|
||||||
tool.removePlugins(List.of(plugin));
|
tool.removePlugins(List.of(plugin));
|
||||||
@@ -357,13 +358,13 @@ public class SymbolTreePlugin3Test extends AbstractGhidraHeadedIntegrationTest {
|
|||||||
assertNotNull(plugin);
|
assertNotNull(plugin);
|
||||||
util.setPlugin(plugin);
|
util.setPlugin(plugin);
|
||||||
|
|
||||||
ToggleDockingAction goToToggleAction2 =
|
navigateIncomingAction =
|
||||||
(ToggleDockingAction) getAction(plugin, "Navigation");
|
(ToggleDockingAction) getAction(plugin, NavigateOnIncomingAction.NAME);
|
||||||
assertNotNull(goToToggleAction2);
|
assertNotNull(navigateIncomingAction);
|
||||||
assertFalse(goToToggleAction2.isSelected());
|
assertFalse(navigateIncomingAction.isSelected());
|
||||||
plugin.readConfigState(saveState);
|
plugin.readConfigState(saveState);
|
||||||
|
|
||||||
assertTrue(goToToggleAction2.isSelected());
|
assertTrue(navigateIncomingAction.isSelected());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -1405,7 +1405,7 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field
|
|||||||
Map<Integer, List<DecompilerSearchLocation>> locationsByLine =
|
Map<Integer, List<DecompilerSearchLocation>> locationsByLine =
|
||||||
currentSearchResults.getLocationsByLine();
|
currentSearchResults.getLocationsByLine();
|
||||||
List<DecompilerSearchLocation> locationsOnLine = locationsByLine.get(lineNumber);
|
List<DecompilerSearchLocation> locationsOnLine = locationsByLine.get(lineNumber);
|
||||||
if (locationsOnLine.isEmpty()) {
|
if (locationsOnLine == null) {
|
||||||
return new Highlight[0];
|
return new Highlight[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -152,6 +152,11 @@ public abstract class AbstractDecompilerTest extends AbstractProgramBasedTest {
|
|||||||
* @return the token under the cursor
|
* @return the token under the cursor
|
||||||
*/
|
*/
|
||||||
protected ClangToken getToken() {
|
protected ClangToken getToken() {
|
||||||
|
waitForDecompiler();
|
||||||
|
return getToken(provider);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ClangToken getCursorToken() {
|
||||||
return getToken(provider);
|
return getToken(provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,18 +23,19 @@ import org.junit.After;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import docking.action.DockingActionIf;
|
import docking.action.DockingActionIf;
|
||||||
|
import docking.widgets.FindDialogResultsProvider;
|
||||||
|
import docking.widgets.SearchLocation;
|
||||||
import docking.widgets.dialogs.InputDialog;
|
import docking.widgets.dialogs.InputDialog;
|
||||||
import docking.widgets.fieldpanel.support.FieldLocation;
|
import docking.widgets.fieldpanel.support.FieldLocation;
|
||||||
import docking.widgets.table.GTable;
|
import docking.widgets.table.GTable;
|
||||||
|
import docking.widgets.table.RowObjectFilterModel;
|
||||||
import ghidra.app.decompiler.ClangToken;
|
import ghidra.app.decompiler.ClangToken;
|
||||||
import ghidra.app.decompiler.component.DecompilerFindDialog;
|
import ghidra.app.decompiler.component.DecompilerFindDialog;
|
||||||
import ghidra.app.decompiler.component.DecompilerPanel;
|
import ghidra.app.decompiler.component.DecompilerPanel;
|
||||||
import ghidra.app.plugin.core.decompile.actions.DecompilerSearchLocation;
|
import ghidra.app.plugin.core.decompile.actions.DecompilerSearchLocation;
|
||||||
import ghidra.app.plugin.core.table.TableComponentProvider;
|
|
||||||
import ghidra.program.model.listing.Program;
|
import ghidra.program.model.listing.Program;
|
||||||
import ghidra.test.ClassicSampleX86ProgramBuilder;
|
import ghidra.test.ClassicSampleX86ProgramBuilder;
|
||||||
import ghidra.util.table.GhidraProgramTableModel;
|
import util.CollectionUtils;
|
||||||
import ghidra.util.table.GhidraThreadedTablePanel;
|
|
||||||
|
|
||||||
public class DecompilerFindDialogTest extends AbstractDecompilerTest {
|
public class DecompilerFindDialogTest extends AbstractDecompilerTest {
|
||||||
|
|
||||||
@@ -306,20 +307,16 @@ public class DecompilerFindDialogTest extends AbstractDecompilerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private GTable getResultsTable() {
|
private GTable getResultsTable() {
|
||||||
@SuppressWarnings("unchecked")
|
FindDialogResultsProvider tableProvider =
|
||||||
TableComponentProvider<DecompilerSearchLocation> tableProvider =
|
waitForComponentProvider(FindDialogResultsProvider.class);
|
||||||
waitForComponentProvider(TableComponentProvider.class);
|
return tableProvider.getTable();
|
||||||
GhidraThreadedTablePanel<DecompilerSearchLocation> panel =
|
|
||||||
tableProvider.getThreadedTablePanel();
|
|
||||||
return panel.getTable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private List<DecompilerSearchLocation> getResults(GTable table) {
|
private List<DecompilerSearchLocation> getResults(GTable table) {
|
||||||
@SuppressWarnings("unchecked")
|
RowObjectFilterModel<SearchLocation> model =
|
||||||
GhidraProgramTableModel<DecompilerSearchLocation> model =
|
(RowObjectFilterModel<SearchLocation>) table.getModel();
|
||||||
(GhidraProgramTableModel<DecompilerSearchLocation>) table.getModel();
|
return CollectionUtils.asList(model.getModelData(), DecompilerSearchLocation.class);
|
||||||
waitForTableModel(model);
|
|
||||||
return model.getModelData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void next() {
|
private void next() {
|
||||||
@@ -331,7 +328,7 @@ public class DecompilerFindDialogTest extends AbstractDecompilerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void searchAll() {
|
private void searchAll() {
|
||||||
pressButtonByText(findDialog, "Search All");
|
pressButtonByText(findDialog, "Find All");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertSearchHit(int line, int column, int length) {
|
private void assertSearchHit(int line, int column, int length) {
|
||||||
|
|||||||
@@ -74,6 +74,10 @@ public class TextComponentSearcher implements FindDialogSearcher {
|
|||||||
this.maxContextChars = max;
|
this.maxContextChars = max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isBusy() {
|
||||||
|
return worker.isBusy();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
|
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ public class TextComponentSearcherTest extends AbstractDockingTest {
|
|||||||
results.activate();
|
results.activate();
|
||||||
assertActive(results);
|
assertActive(results);
|
||||||
|
|
||||||
results.dispose();
|
runSwing(() -> results.dispose());
|
||||||
assertInactive(results);
|
assertInactive(results);
|
||||||
|
|
||||||
// make sure active() does not work once disposed
|
// make sure active() does not work once disposed
|
||||||
|
|||||||
Reference in New Issue
Block a user