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