mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
Tests - fixed test failing to improper dialog parenting; updated dialog
parenting to avoid transient parents
This commit is contained in:
parent
cc6020736c
commit
22cc232210
3 changed files with 25 additions and 24 deletions
|
@ -116,6 +116,10 @@ public class ExporterDialog extends DialogComponentProvider implements AddressFa
|
|||
addCancelButton();
|
||||
setHelpLocation(new HelpLocation("ExporterPlugin", "Exporter_Dialog"));
|
||||
|
||||
// This dialog is temporary and will be closed when the task is finished. Mark
|
||||
// it transient so no other windows will be parented to this dialog.
|
||||
setTransient(true);
|
||||
|
||||
// need to initialize a few things
|
||||
selectedFormatChanged();
|
||||
validate();
|
||||
|
@ -503,7 +507,7 @@ public class ExporterDialog extends DialogComponentProvider implements AddressFa
|
|||
|
||||
Object tmpConsumer = new Object();
|
||||
obj.addConsumer(tmpConsumer);
|
||||
SystemUtilities.runSwingLater(() -> {
|
||||
Swing.runLater(() -> {
|
||||
try {
|
||||
AboutDomainObjectUtils.displayInformation(tool, obj.getDomainFile(),
|
||||
obj.getMetadata(), "Export Results Summary", resultsBuffer.toString(),
|
||||
|
@ -516,9 +520,10 @@ public class ExporterDialog extends DialogComponentProvider implements AddressFa
|
|||
|
||||
}
|
||||
|
||||
/**************************************************
|
||||
* Methods for testing
|
||||
**************************************************/
|
||||
//==================================================================================================
|
||||
// Methods for Testing
|
||||
//==================================================================================================
|
||||
|
||||
JCheckBox getSelectionCheckBox() {
|
||||
return selectionCheckBox;
|
||||
}
|
||||
|
|
|
@ -16,16 +16,16 @@
|
|||
package ghidra.app.util.exporter;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import ghidra.util.Msg;
|
||||
|
||||
public class Compare {
|
||||
public static void compare(ArrayList<String> expectedList, File actualFile) throws Exception {
|
||||
public class StringComparer {
|
||||
public static void compareLines(List<String> expectedList, File actualFile) throws Exception {
|
||||
int index = 0;
|
||||
|
||||
|
||||
boolean hasFailure = false;
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(actualFile))) {
|
||||
|
@ -35,7 +35,7 @@ public class Compare {
|
|||
if (actualLine == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (index >= expectedList.size()) {
|
||||
++excess;
|
||||
continue;
|
||||
|
@ -46,26 +46,26 @@ public class Compare {
|
|||
expectedLine = expectedLine.trim();
|
||||
|
||||
boolean match =
|
||||
expectedLine.equals(actualLine) || actualLine.startsWith(expectedLine);
|
||||
expectedLine.equals(actualLine) || actualLine.startsWith(expectedLine);
|
||||
|
||||
hasFailure |= !match;
|
||||
|
||||
if (!match) {
|
||||
Msg.debug(Compare.class, "Expected line does not match actual line (" + index +
|
||||
Msg.debug(StringComparer.class, "Expected line does not match actual line (" + index +
|
||||
"): \nExpected: " + expectedLine + "\nActual: " + actualLine);
|
||||
}
|
||||
}
|
||||
|
||||
if (excess > 0) {
|
||||
String message = "Actual file contains " + excess + " more lines than expected";
|
||||
Msg.debug(Compare.class, message);
|
||||
Msg.debug(StringComparer.class, message);
|
||||
Assert.fail(message);
|
||||
}
|
||||
else if (!hasFailure && index < expectedList.size()) {
|
||||
int fewer = expectedList.size() - index;
|
||||
String message = "Actual file contains " + fewer +
|
||||
" fewer lines than expected";
|
||||
Msg.debug(Compare.class, message);
|
||||
" fewer lines than expected";
|
||||
Msg.debug(StringComparer.class, message);
|
||||
Assert.fail(message);
|
||||
}
|
||||
|
|
@ -1854,20 +1854,16 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
|
|||
// as message dialogs will too be closed
|
||||
DockingDialog d = (DockingDialog) activeWindow;
|
||||
Window ancestor = SwingUtilities.getWindowAncestor(d);
|
||||
if (!d.isShowing()) {
|
||||
if (!ancestor.isShowing()) {
|
||||
return null;
|
||||
}
|
||||
if (d.isShowing() && isNonTransientWindow(d)) {
|
||||
return d;
|
||||
}
|
||||
|
||||
// The active window is not a suitable parent; try its parent
|
||||
if (ancestor.isShowing() && isNonTransientWindow(ancestor)) {
|
||||
return ancestor;
|
||||
}
|
||||
|
||||
DialogComponentProvider provider = d.getComponent();
|
||||
if (provider.isTransient()) {
|
||||
return ancestor;
|
||||
}
|
||||
|
||||
return d;
|
||||
return null;
|
||||
}
|
||||
|
||||
public ComponentProvider getActiveComponentProvider() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue