mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
Tests - fixed tests failing to bad test mouse clicking and focus
This commit is contained in:
parent
26cab55a64
commit
881dca75bf
5 changed files with 36 additions and 9 deletions
|
@ -215,10 +215,14 @@ public abstract class AbstractGhidraHeadedIntegrationTest
|
|||
}
|
||||
|
||||
protected void click(FieldPanel fp, int clickCount, boolean wait) {
|
||||
|
||||
Point cursor = fp.getCursorPoint();
|
||||
int x = cursor.x;
|
||||
int y = cursor.y;
|
||||
click(fp, cursor, clickCount, wait);
|
||||
}
|
||||
|
||||
protected void click(FieldPanel fp, Point p, int clickCount, boolean wait) {
|
||||
|
||||
int x = p.x;
|
||||
int y = p.y;
|
||||
MouseEvent ev = new MouseEvent(fp, 0, System.currentTimeMillis(), 0, x, y, clickCount,
|
||||
false, MouseEvent.BUTTON1);
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ package ghidra.app.plugin.core.decompile;
|
|||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.After;
|
||||
|
@ -76,10 +77,15 @@ public abstract class AbstractDecompilerTest extends AbstractProgramBasedTest {
|
|||
|
||||
protected void setDecompilerLocation(int line, int charPosition) {
|
||||
|
||||
runSwing(() -> provider.setCursorLocation(line, charPosition));
|
||||
DecompilerPanel panel = provider.getDecompilerPanel();
|
||||
FieldPanel fp = panel.getFieldPanel();
|
||||
click(fp, 1, true);
|
||||
FieldLocation loc = loc(line, charPosition);
|
||||
|
||||
// scroll to the field to make sure it has been built so that we can get its point
|
||||
fp.scrollTo(loc);
|
||||
Point p = fp.getPointForLocation(loc);
|
||||
|
||||
click(fp, p, 1, true);
|
||||
waitForSwing();
|
||||
}
|
||||
|
||||
|
|
|
@ -173,6 +173,7 @@ public class DecompilerNavigationTest extends AbstractDecompilerTest {
|
|||
assertToken("FUN_01002c93", line, character);
|
||||
setDecompilerLocation(line, character);
|
||||
|
||||
// this is the address within the function of the call to the function we clicked
|
||||
assertListingAddress(addr("01002d32"));
|
||||
}
|
||||
|
||||
|
@ -223,9 +224,8 @@ public class DecompilerNavigationTest extends AbstractDecompilerTest {
|
|||
}
|
||||
|
||||
private void assertListingAddress(Address expected) {
|
||||
ProgramLocation cbLocation = codeBrowser.getCurrentLocation();
|
||||
assertEquals("The Listing is not at the expected address", expected,
|
||||
cbLocation.getAddress());
|
||||
waitForCondition(() -> expected.equals(codeBrowser.getCurrentLocation().getAddress()),
|
||||
"The Listing is not at the expected address");
|
||||
}
|
||||
|
||||
private void assertExternalNavigationPerformed() {
|
||||
|
|
|
@ -1193,7 +1193,18 @@ public class FieldPanel extends JPanel
|
|||
cursorHandler.doCursorEnd(trigger);
|
||||
}
|
||||
|
||||
private FieldLocation getLocationForPoint(int x, int y) {
|
||||
public Point getPointForLocation(FieldLocation location) {
|
||||
|
||||
AnchoredLayout layout = findLayoutOnScreen(location.getIndex());
|
||||
if (layout == null) {
|
||||
return null;
|
||||
}
|
||||
Rectangle r =
|
||||
layout.getCursorRect(location.fieldNum, location.row, location.col);
|
||||
return r.getLocation();
|
||||
}
|
||||
|
||||
public FieldLocation getLocationForPoint(int x, int y) {
|
||||
FieldLocation location = new FieldLocation();
|
||||
// delegate to the appropriate layout to do the work
|
||||
Layout layout = findLayoutAt(y);
|
||||
|
|
|
@ -1724,6 +1724,12 @@ public class GhidraFileChooserTest extends AbstractDockingTest {
|
|||
@Test
|
||||
public void testFocus_FilesViewStaysFocusedAfterRefresh() throws Exception {
|
||||
|
||||
if (BATCH_MODE) {
|
||||
// I don't like this, but these seem to have a focus sensitivity that
|
||||
// does not work correctly in headless
|
||||
return;
|
||||
}
|
||||
|
||||
DirectoryList list = getListView();
|
||||
focus(list);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue