Skip to content

Ghidra is a software reverse engineering (SRE) framework

Test fixes

dragonmacherb7973cd2c54d
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/CodeBrowserSelectionPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/CodeBrowserSelectionPlugin.java
index 50807a6300..f9e332dd81 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/CodeBrowserSelectionPlugin.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/CodeBrowserSelectionPlugin.java
@@ -65,8 +65,7 @@ public class CodeBrowserSelectionPlugin extends Plugin {
"Minimum Length of Address Range in Range Table";
static final long MIN_RANGE_SIZE_DEFAULT = 1;
- static final String CREATE_ADDRESS_RANGE_TABLE_ACTION_NAME =
- "Create Table From Ranges";
+ static final String CREATE_ADDRESS_RANGE_TABLE_ACTION_NAME = "Create Table From Ranges";
static final String OPTION_CATEGORY_NAME = "Selection Tables";
@@ -78,45 +77,45 @@ public class CodeBrowserSelectionPlugin extends Plugin {
private void createActions() {
new ActionBuilder("Select All", getName())
- .menuPath(ToolConstants.MENU_SELECTION, "&All in View")
- .menuGroup(SELECT_GROUP, "a")
- .keyBinding("ctrl A")
- .helpLocation(new HelpLocation(HelpTopics.SELECTION, "Select All"))
- .withContext(CodeViewerActionContext.class, true)
- .inWindow(ActionBuilder.When.CONTEXT_MATCHES)
- .onAction(c -> ((CodeViewerProvider) c.getComponentProvider()).selectAll())
- .buildAndInstall(tool);
+ .menuPath(ToolConstants.MENU_SELECTION, "&All in View")
+ .menuGroup(SELECT_GROUP, "a")
+ .keyBinding("ctrl A")
+ .helpLocation(new HelpLocation(HelpTopics.SELECTION, "Select All"))
+ .withContext(CodeViewerActionContext.class, true)
+ .inWindow(ActionBuilder.When.CONTEXT_MATCHES)
+ .onAction(c -> ((CodeViewerProvider) c.getComponentProvider()).selectAll())
+ .buildAndInstall(tool);
new ActionBuilder("Clear Selection", getName())
- .menuPath(ToolConstants.MENU_SELECTION, "&Clear Selection")
- .menuGroup(SELECT_GROUP, "b")
- .helpLocation(new HelpLocation(HelpTopics.SELECTION, "Clear Selection"))
- .withContext(CodeViewerActionContext.class, true)
- .inWindow(ActionBuilder.When.CONTEXT_MATCHES)
- .onAction(c -> ((CodeViewerProvider) c.getComponentProvider())
- .setSelection(new ProgramSelection()))
- .buildAndInstall(tool);
+ .menuPath(ToolConstants.MENU_SELECTION, "&Clear Selection")
+ .menuGroup(SELECT_GROUP, "b")
+ .helpLocation(new HelpLocation(HelpTopics.SELECTION, "Clear Selection"))
+ .withContext(CodeViewerActionContext.class, true)
+ .inWindow(ActionBuilder.When.CONTEXT_MATCHES)
+ .onAction(c -> ((CodeViewerProvider) c.getComponentProvider())
+ .setSelection(new ProgramSelection()))
+ .buildAndInstall(tool);
new ActionBuilder("Select Complement", getName())
- .menuPath(ToolConstants.MENU_SELECTION, "&Complement")
- .menuGroup(SELECT_GROUP, "c")
- .helpLocation(new HelpLocation(HelpTopics.SELECTION, "Select Complement"))
- .withContext(CodeViewerActionContext.class, true)
- .inWindow(ActionBuilder.When.CONTEXT_MATCHES)
- .onAction(c -> ((CodeViewerProvider) c.getComponentProvider()).selectComplement())
- .buildAndInstall(tool);
+ .menuPath(ToolConstants.MENU_SELECTION, "&Complement")
+ .menuGroup(SELECT_GROUP, "c")
+ .helpLocation(new HelpLocation(HelpTopics.SELECTION, "Select Complement"))
+ .withContext(CodeViewerActionContext.class, true)
+ .inWindow(ActionBuilder.When.CONTEXT_MATCHES)
+ .onAction(c -> ((CodeViewerProvider) c.getComponentProvider()).selectComplement())
+ .buildAndInstall(tool);
tool.addAction(new MarkAndSelectionAction(getName(), SELECT_GROUP, "d"));
new ActionBuilder("Create Table From Selection", getName())
- .menuPath(ToolConstants.MENU_SELECTION, "Create Table From Selection")
- .menuGroup("SelectUtils")
+ .menuPath(ToolConstants.MENU_SELECTION, "Create Table From Selection")
+ .menuGroup("SelectUtils")
.helpLocation(new HelpLocation(HelpTopics.CODE_BROWSER, "Selection_Tables"))
- .withContext(CodeViewerActionContext.class, true)
- .inWindow(ActionBuilder.When.CONTEXT_MATCHES)
- .onAction(c -> createTable((CodeViewerProvider) c.getComponentProvider()))
- .buildAndInstall(tool);
-
+ .withContext(CodeViewerActionContext.class, true)
+ .inWindow(ActionBuilder.When.CONTEXT_MATCHES)
+ .onAction(c -> createTable((CodeViewerProvider) c.getComponentProvider()))
+ .buildAndInstall(tool);
+
new ActionBuilder(CREATE_ADDRESS_RANGE_TABLE_ACTION_NAME, getName())
.menuPath(ToolConstants.MENU_SELECTION, CREATE_ADDRESS_RANGE_TABLE_ACTION_NAME)
.menuGroup("SelectUtils")
@@ -177,8 +176,7 @@ public class CodeBrowserSelectionPlugin extends Plugin {
ProgramSelection selection = componentProvider.getSelection();
CodeUnitIterator codeUnits = listing.getCodeUnits(selection, true);
if (!codeUnits.hasNext()) {
- tool.setStatusInfo(
- "Unable to create table from selection: no code units in selection");
+ tool.setStatusInfo("Unable to create table from selection: no code units in selection");
return;
}
@@ -186,8 +184,8 @@ public class CodeBrowserSelectionPlugin extends Plugin {
String title = "Selection Table";
Icon markerIcon = new GIcon("icon.plugin.codebrowser.cursor.marker");
TableComponentProvider<Address> tableProvider =
- tableService.showTableWithMarkers(title + " " + model.getName(), "Selection",
- model, SearchConstants.SEARCH_HIGHLIGHT_COLOR, markerIcon, title, null);
+ tableService.showTableWithMarkers(title + " " + model.getName(), "Selection", model,
+ SearchConstants.SEARCH_HIGHLIGHT_COLOR, markerIcon, title, null);
tableProvider.installRemoveItemsAction();
}
@@ -226,9 +224,7 @@ public class CodeBrowserSelectionPlugin extends Plugin {
Msg.showWarn(this, null, "Results Truncated",
"Results are limited to " + resultsLimit + " code units.\n" +
"This limit can be changed by the tool option \"" +
- OPTION_CATEGORY_NAME + " -> " +
- SELECTION_LIMIT_OPTION_NAME +
- "\".");
+ OPTION_CATEGORY_NAME + " -> " + SELECTION_LIMIT_OPTION_NAME + "\".");
break;
}
monitor.checkCancelled();
@@ -241,13 +237,14 @@ public class CodeBrowserSelectionPlugin extends Plugin {
private void initializeOptions() {
Options opt = tool.getOptions(OPTION_CATEGORY_NAME);
- opt.registerOption(SELECTION_LIMIT_OPTION_NAME, SELECTION_LIMIT_DEFAULT, null,
+ HelpLocation help = new HelpLocation(HelpTopics.CODE_BROWSER, "Selection_Tables");
+ opt.registerOption(SELECTION_LIMIT_OPTION_NAME, SELECTION_LIMIT_DEFAULT, help,
"Maximum number of entries in selection table");
- opt.registerOption(RANGES_LIMIT_OPTION_NAME, RANGES_LIMIT_DEFAULT, null,
+ opt.registerOption(RANGES_LIMIT_OPTION_NAME, RANGES_LIMIT_DEFAULT, help,
"Maximum number of entries in an address range table");
- opt.registerOption(MIN_RANGE_SIZE_OPTION_NAME, MIN_RANGE_SIZE_DEFAULT, null,
+ opt.registerOption(MIN_RANGE_SIZE_OPTION_NAME, MIN_RANGE_SIZE_DEFAULT, help,
"Minimum length of an address range in address range table");
}
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/EolComments.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/EolComments.java
index 87f66792d2..3fadd068ec 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/EolComments.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/EolComments.java
@@ -33,13 +33,13 @@ import ghidra.util.StringUtilities;
import util.CollectionUtils;
/**
- * Utility class with methods to get comment information that can be displayed in the end of line
- * comment field. Each instance of this class is associated with a code unit. This class uses the
- * provided options to decide how to load and filter existing comments.
- *
- * <p>Comment types that can be shown include the End of Line comment for the code unit, the
- * Repeatable comment for the code unit, any repeatable comments for the code units that this code
- * unit has references to, and possibly a comment indicating the data at a code unit that is
+ * Utility class with methods to get comment information that can be displayed in the end of line
+ * comment field. Each instance of this class is associated with a code unit. This class uses the
+ * provided options to decide how to load and filter existing comments.
+ *
+ * <p>Comment types that can be shown include the End of Line comment for the code unit, the
+ * Repeatable comment for the code unit, any repeatable comments for the code units that this code
+ * unit has references to, and possibly a comment indicating the data at a code unit that is
* referenced by this code unit.
*/
public class EolComments {
@@ -91,7 +91,7 @@ public class EolComments {
}
/**
- * Returns the number of comments that can be added before reaching the maximum number of
+ * Returns the number of comments that can be added before reaching the maximum number of
* comments
* @return the number of comments
*/
@@ -490,9 +490,11 @@ public class EolComments {
return null;
}
- Address potentialAddr = codeUnitAddress.getNewAddress(offset);
- if (memory.contains(potentialAddr)) {
- return "? -> " + potentialAddr.toString();
+ if (offset != 0) {
+ Address potentialAddr = codeUnitAddress.getNewAddress(offset);
+ if (memory.contains(potentialAddr)) {
+ return "? -> " + potentialAddr.toString();
+ }
}
}
catch (MemoryAccessException | AddressOutOfBoundsException e) {
@@ -511,8 +513,8 @@ public class EolComments {
private String getFunctionSignature(Program program, Address a) {
- // Note: Users have complained the 'undefined' return type clutters the display. Update
- // signature to omit return type if it is undefined.
+ // Note: Users have complained the 'undefined' return type clutters the display. Update
+ // signature to omit return type if it is undefined.
Function f = program.getFunctionManager().getFunctionAt(a);
if (f != null) {
return f.getPrototypeString(false, false);
@@ -757,8 +759,8 @@ public class EolComments {
cpath = ((Data) codeUnit).getComponentPath();
}
if (eolRow < beforeRepeatable) {
- return new EolCommentFieldLocation(program, minAddress, cpath,
- getCommentsArray(), eolRow, eolColumn, eolRow);
+ return new EolCommentFieldLocation(program, minAddress, cpath, getCommentsArray(),
+ eolRow, eolColumn, eolRow);
}
if (eolRow < beforeRefRepeats) {
@@ -768,14 +770,14 @@ public class EolComments {
if (eolRow < beforeAutomatic) {
int rowInAllRefRepeats = eolRow - beforeRefRepeats;
- return new RefRepeatCommentFieldLocation(program, minAddress, cpath,
- getCommentsArray(), eolRow, eolColumn, getRefRepeatRow(rowInAllRefRepeats),
+ return new RefRepeatCommentFieldLocation(program, minAddress, cpath, getCommentsArray(),
+ eolRow, eolColumn, getRefRepeatRow(rowInAllRefRepeats),
getRefRepeatAddress(rowInAllRefRepeats));
}
if (eolRow < numTotal) {
- return new AutomaticCommentFieldLocation(program, minAddress, cpath,
- getCommentsArray(), eolRow, eolColumn, eolRow - beforeAutomatic);
+ return new AutomaticCommentFieldLocation(program, minAddress, cpath, getCommentsArray(),
+ eolRow, eolColumn, eolRow - beforeAutomatic);
}
return null;
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/EolCommentFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/EolCommentFieldFactory.java
index f295289175..b457ea1841 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/EolCommentFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/EolCommentFieldFactory.java
@@ -69,8 +69,8 @@ public class EolCommentFieldFactory extends FieldFactory {
private EolExtraCommentsOption extraCommentsOption = new EolExtraCommentsOption();
private PropertyEditor extraCommmentsEditor = new EolExtraCommentsPropertyEditor();
- // The codeUnitFormatOptions is used to monitor "follow pointer..." option to avoid duplication
- // of data within auto-comment. We don't bother adding a listener to kick the model since this
+ // The codeUnitFormatOptions is used to monitor "follow pointer..." option to avoid duplication
+ // of data within auto-comment. We don't bother adding a listener to kick the model since this
// is done by the operand field.
private BrowserCodeUnitFormatOptions codeUnitFormatOptions;
@@ -131,8 +131,7 @@ public class EolCommentFieldFactory extends FieldFactory {
if (!(customOption instanceof EolExtraCommentsOption)) {
throw new AssertException("Someone set an option for " + EXTRA_COMMENT_KEY +
- " that is not the expected " +
- EolExtraCommentsOption.class.getName() + " type.");
+ " that is not the expected " + EolExtraCommentsOption.class.getName() + " type.");
}
extraCommentsOption = (EolExtraCommentsOption) customOption;
@@ -257,19 +256,18 @@ public class EolCommentFieldFactory extends FieldFactory {
}
}
- EolComments comments =
- new EolComments(cu, codeUnitFormatOptions.followReferencedPointers(),
- maxDisplayLines, extraCommentsOption);
+ EolComments comments = new EolComments(cu, codeUnitFormatOptions.followReferencedPointers(),
+ maxDisplayLines, extraCommentsOption);
// This Code Unit's End of Line Comment
List<FieldElement> elementList = new ArrayList<>();
- AttributedString prefix = createPrefix(style);
+ AttributedString prefix = createPrefix(CommentStyle.EOL);
List<String> eols = comments.getEOLComments();
List<FieldElement> eolElements = convertToFieldElements(program, eols, prefix, 0);
elementList.addAll(eolElements);
if (comments.isShowingRepeatables()) {
- prefix = createPrefix(repeatableCommentStyle);
+ prefix = createPrefix(CommentStyle.REPEATABLE);
int row = getNextRow(elementList);
List<String> repeatables = comments.getRepeatableComments();
List<FieldElement> elements = convertToFieldElements(program, repeatables, prefix, row);
@@ -277,20 +275,19 @@ public class EolCommentFieldFactory extends FieldFactory {
}
if (comments.isShowingRefRepeatables()) {
- prefix = createPrefix(refRepeatableCommentStyle);
- List<RefRepeatComment> refRepeatables =
- comments.getReferencedRepeatableComments();
+ prefix = createPrefix(CommentStyle.REF_REPEATABLE);
+ List<RefRepeatComment> refRepeatables = comments.getReferencedRepeatableComments();
for (RefRepeatComment comment : refRepeatables) {
int row = getNextRow(elementList);
String[] lines = comment.getCommentLines();
- List<FieldElement> elements = convertToRefFieldElements(
- lines, program, prefix, comment.getAddress(), row);
+ List<FieldElement> elements =
+ convertToRefFieldElements(lines, program, prefix, comment.getAddress(), row);
elementList.addAll(elements);
}
}
if (comments.isShowingAutoComments()) {
- prefix = createPrefix(automaticCommentStyle);
+ prefix = createPrefix(CommentStyle.AUTO);
int row = getNextRow(elementList);
List<String> autos = comments.getAutomaticComment();
List<FieldElement> elements = convertToFieldElements(program, autos, prefix, row);
@@ -305,27 +302,30 @@ public class EolCommentFieldFactory extends FieldFactory {
maxDisplayLines, hlProvider);
}
- private AttributedString createPrefix(int commentStyle) {
- if (commentStyle == style) {
+ private AttributedString createPrefix(CommentStyle commentStyle) {
+ if (commentStyle == CommentStyle.EOL) {
return new AttributedString(SEMICOLON_PREFIX, CommentColors.EOL, getMetrics(style),
- false,
- null);
+ false, null);
}
- if (commentStyle == repeatableCommentStyle) {
- return new AttributedString(SEMICOLON_PREFIX,
- CommentColors.REPEATABLE, getMetrics(repeatableCommentStyle), false, null);
+ if (commentStyle == CommentStyle.REPEATABLE) {
+ return new AttributedString(SEMICOLON_PREFIX, CommentColors.REPEATABLE,
+ getMetrics(repeatableCommentStyle), false, null);
}
- if (commentStyle == refRepeatableCommentStyle) {
- return new AttributedString(SEMICOLON_PREFIX,
- CommentColors.REF_REPEATABLE, getMetrics(refRepeatableCommentStyle), false, null);
+ if (commentStyle == CommentStyle.REF_REPEATABLE) {
+ return new AttributedString(SEMICOLON_PREFIX, CommentColors.REF_REPEATABLE,
+ getMetrics(refRepeatableCommentStyle), false, null);
}
- if (commentStyle == automaticCommentStyle) {
- return new AttributedString(SEMICOLON_PREFIX,
- CommentColors.AUTO, getMetrics(automaticCommentStyle), false, null);
+ if (commentStyle == CommentStyle.AUTO) {
+ return new AttributedString(SEMICOLON_PREFIX, CommentColors.AUTO,
+ getMetrics(automaticCommentStyle), false, null);
}
throw new AssertException("Unexected comment style: " + commentStyle);
}
+ private enum CommentStyle {
+ EOL, REPEATABLE, REF_REPEATABLE, AUTO;
+ }
+
private int getNextRow(List<FieldElement> elementList) {
int elementIndex = elementList.size() - 1;
if (elementIndex >= 0) {
@@ -339,20 +339,21 @@ public class EolCommentFieldFactory extends FieldFactory {
}
private List<FieldElement> convertToFieldElements(Program program, List<String> comments,
- AttributedString currentPrefixString, int nextRow) {
+ AttributedString prefix, int row) {
List<FieldElement> fieldElements = new ArrayList<>();
if (comments.isEmpty()) {
return fieldElements;
}
- for (int rowIndex = 0; rowIndex < comments.size(); rowIndex++) {
- int encodedRow = nextRow + rowIndex;
- fieldElements.add(CommentUtils.parseTextForAnnotations(comments.get(rowIndex), program,
- currentPrefixString, encodedRow));
+
+ for (int commentRow = 0; commentRow < comments.size(); commentRow++) {
+ int offsetRow = row + commentRow;
+ fieldElements.add(CommentUtils.parseTextForAnnotations(comments.get(commentRow),
+ program, prefix, offsetRow));
}
if (isWordWrap) {
- int lineWidth = showSemicolon ? width - currentPrefixString.getStringWidth() : width;
+ int lineWidth = showSemicolon ? width - prefix.getStringWidth() : width;
fieldElements = FieldUtils.wrap(fieldElements, lineWidth);
}
@@ -362,10 +363,9 @@ public class EolCommentFieldFactory extends FieldFactory {
fieldElements.get(i).getDataLocationForCharacterIndex(0);
int encodedRow = startRowCol.row();
int encodedCol = startRowCol.col();
- FieldElement prefix =
- new TextFieldElement(currentPrefixString, encodedRow, encodedCol);
+ FieldElement prefixElement = new TextFieldElement(prefix, encodedRow, encodedCol);
fieldElements.set(i,
- new CompositeFieldElement(new FieldElement[] { prefix, fieldElements.get(i) }));
+ new CompositeFieldElement(List.of(prefixElement, fieldElements.get(i))));
}
}
return fieldElements;
@@ -435,9 +435,8 @@ public class EolCommentFieldFactory extends FieldFactory {
return null;
}
CodeUnit cu = (CodeUnit) obj;
- EolComments displayableEol =
- new EolComments(cu, codeUnitFormatOptions.followReferencedPointers(),
- maxDisplayLines, extraCommentsOption);
+ EolComments displayableEol = new EolComments(cu,
+ codeUnitFormatOptions.followReferencedPointers(), maxDisplayLines, extraCommentsOption);
// Hold position in connected tool if navigating within semicolon.
int numLeadColumns = 0;
@@ -472,9 +471,8 @@ public class EolCommentFieldFactory extends FieldFactory {
return null;
}
- EolComments displayableEol =
- new EolComments((CodeUnit) obj, codeUnitFormatOptions.followReferencedPointers(),
- maxDisplayLines, extraCommentsOption);
+ EolComments displayableEol = new EolComments((CodeUnit) obj,
+ codeUnitFormatOptions.followReferencedPointers(), maxDisplayLines, extraCommentsOption);
ListingTextField btf = (ListingTextField) bf;
RowColLocation eolRowCol = displayableEol.getRowCol((CommentFieldLocation) loc);
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/codebrowser/CodeBrowserTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/codebrowser/CodeBrowserTest.java
index 4c6abdef45..708e3d5bd6 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/codebrowser/CodeBrowserTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/codebrowser/CodeBrowserTest.java
@@ -32,7 +32,6 @@ import docking.widgets.fieldpanel.*;
import docking.widgets.fieldpanel.field.Field;
import docking.widgets.fieldpanel.support.*;
import docking.widgets.table.GTable;
-import generic.test.TestUtils;
import ghidra.app.cmd.data.CreateDataCmd;
import ghidra.app.events.ProgramSelectionPluginEvent;
import ghidra.app.plugin.core.codebrowser.SelectEndpointsAction.RangeEndpoint;
@@ -52,6 +51,7 @@ import ghidra.test.AbstractGhidraHeadedIntegrationTest;
import ghidra.test.TestEnv;
import ghidra.util.exception.CancelledException;
import ghidra.util.table.AddressPreviewTableModel;
+import ghidra.util.table.GhidraProgramTableModel;
import ghidra.util.task.TaskMonitor;
public class CodeBrowserTest extends AbstractGhidraHeadedIntegrationTest {
@@ -165,12 +165,13 @@ public class CodeBrowserTest extends AbstractGhidraHeadedIntegrationTest {
performAction(createTableAction, true);
TableComponentProvider<?> tableProvider =
- waitForComponentProvider(tool.getToolFrame(), TableComponentProvider.class, 2000);
- Object threadedPanel = TestUtils.getInstanceField("threadedPanel", tableProvider);
- GTable table = (GTable) TestUtils.getInstanceField("table", threadedPanel);
- ListSelectionModel selectionModel = table.getSelectionModel();
+ waitForComponentProvider(TableComponentProvider.class);
+ GhidraProgramTableModel<?> model = tableProvider.getModel();
+ waitForTableModel(model);
+ GTable table = tableProvider.getThreadedTablePanel().getTable();
// select all the rows
+ ListSelectionModel selectionModel = table.getSelectionModel();
runSwing(() -> selectionModel.setSelectionInterval(0, table.getRowCount() - 1));
AddressPreviewTableModel addressModel = (AddressPreviewTableModel) tableProvider.getModel();
@@ -188,19 +189,21 @@ public class CodeBrowserTest extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testAddressRangeTableFromSelection() throws CancelledException {
AddressSet undefined = new AddressSet(program.getListing()
- .getUndefinedRanges(program.getMemory().getAllInitializedAddressSet(), true,
+ .getUndefinedRanges(program.getMemory().getAllInitializedAddressSet(), true,
TaskMonitor.DUMMY));
setSelection(undefined);
DockingActionIf createTableAction =
getAction(tool, CodeBrowserSelectionPlugin.CREATE_ADDRESS_RANGE_TABLE_ACTION_NAME);
performAction(createTableAction, true);
TableComponentProvider<?> tableProvider =
- waitForComponentProvider(tool.getToolFrame(), TableComponentProvider.class, 2000);
- Object threadedPanel = TestUtils.getInstanceField("threadedPanel", tableProvider);
- GTable table = (GTable) TestUtils.getInstanceField("table", threadedPanel);
+ waitForComponentProvider(TableComponentProvider.class);
+ GhidraProgramTableModel<?> model = tableProvider.getModel();
+ waitForTableModel(model);
+ GTable table = tableProvider.getThreadedTablePanel().getTable();
assertEquals(7, table.getRowCount());
- ListSelectionModel selectionModel = table.getSelectionModel();
+
// select all the rows
+ ListSelectionModel selectionModel = table.getSelectionModel();
runSwing(() -> selectionModel.setSelectionInterval(0, table.getRowCount() - 1));
AddressRangeTableModel addressModel = (AddressRangeTableModel) tableProvider.getModel();
@@ -212,8 +215,7 @@ public class CodeBrowserTest extends AbstractGhidraHeadedIntegrationTest {
tableProgramSelection.getAddressRanges().forEach(r -> fromTable.add(r));
assertEquals(fromTable, undefined);
- DockingActionIf selectMinsAction =
- getAction(tool, "Select " + RangeEndpoint.MIN.name());
+ DockingActionIf selectMinsAction = getAction(tool, "Select " + RangeEndpoint.MIN.name());
assertNotNull(selectMinsAction);
performAction(selectMinsAction, true);
ProgramSelection minSelect = getCurrentSelection();
@@ -222,8 +224,7 @@ public class CodeBrowserTest extends AbstractGhidraHeadedIntegrationTest {
assertTrue(minSelect.contains(range.getMinAddress()));
}
- DockingActionIf selectMaxesAction =
- getAction(tool, "Select " + RangeEndpoint.MAX.name());
+ DockingActionIf selectMaxesAction = getAction(tool, "Select " + RangeEndpoint.MAX.name());
assertNotNull(selectMaxesAction);
performAction(selectMaxesAction, true);
ProgramSelection maxSelect = getCurrentSelection();
@@ -331,7 +332,7 @@ public class CodeBrowserTest extends AbstractGhidraHeadedIntegrationTest {
clickMouse(fp, 1, p2.x, p2.y, 1, DockingUtils.CONTROL_KEY_MODIFIER_MASK);
-// TODO
+// TODO
ProgramSelection ps = getCurrentSelection();
assertEquals(26, ps.getNumAddresses());
// assertEquals(2, ps.getNumAddressRanges());