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();
|
addCancelButton();
|
||||||
setHelpLocation(new HelpLocation("ExporterPlugin", "Exporter_Dialog"));
|
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
|
// need to initialize a few things
|
||||||
selectedFormatChanged();
|
selectedFormatChanged();
|
||||||
validate();
|
validate();
|
||||||
|
@ -503,7 +507,7 @@ public class ExporterDialog extends DialogComponentProvider implements AddressFa
|
||||||
|
|
||||||
Object tmpConsumer = new Object();
|
Object tmpConsumer = new Object();
|
||||||
obj.addConsumer(tmpConsumer);
|
obj.addConsumer(tmpConsumer);
|
||||||
SystemUtilities.runSwingLater(() -> {
|
Swing.runLater(() -> {
|
||||||
try {
|
try {
|
||||||
AboutDomainObjectUtils.displayInformation(tool, obj.getDomainFile(),
|
AboutDomainObjectUtils.displayInformation(tool, obj.getDomainFile(),
|
||||||
obj.getMetadata(), "Export Results Summary", resultsBuffer.toString(),
|
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() {
|
JCheckBox getSelectionCheckBox() {
|
||||||
return selectionCheckBox;
|
return selectionCheckBox;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,14 +16,14 @@
|
||||||
package ghidra.app.util.exporter;
|
package ghidra.app.util.exporter;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
|
||||||
import ghidra.util.Msg;
|
import ghidra.util.Msg;
|
||||||
|
|
||||||
public class Compare {
|
public class StringComparer {
|
||||||
public static void compare(ArrayList<String> expectedList, File actualFile) throws Exception {
|
public static void compareLines(List<String> expectedList, File actualFile) throws Exception {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
boolean hasFailure = false;
|
boolean hasFailure = false;
|
||||||
|
@ -46,26 +46,26 @@ public class Compare {
|
||||||
expectedLine = expectedLine.trim();
|
expectedLine = expectedLine.trim();
|
||||||
|
|
||||||
boolean match =
|
boolean match =
|
||||||
expectedLine.equals(actualLine) || actualLine.startsWith(expectedLine);
|
expectedLine.equals(actualLine) || actualLine.startsWith(expectedLine);
|
||||||
|
|
||||||
hasFailure |= !match;
|
hasFailure |= !match;
|
||||||
|
|
||||||
if (!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);
|
"): \nExpected: " + expectedLine + "\nActual: " + actualLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (excess > 0) {
|
if (excess > 0) {
|
||||||
String message = "Actual file contains " + excess + " more lines than expected";
|
String message = "Actual file contains " + excess + " more lines than expected";
|
||||||
Msg.debug(Compare.class, message);
|
Msg.debug(StringComparer.class, message);
|
||||||
Assert.fail(message);
|
Assert.fail(message);
|
||||||
}
|
}
|
||||||
else if (!hasFailure && index < expectedList.size()) {
|
else if (!hasFailure && index < expectedList.size()) {
|
||||||
int fewer = expectedList.size() - index;
|
int fewer = expectedList.size() - index;
|
||||||
String message = "Actual file contains " + fewer +
|
String message = "Actual file contains " + fewer +
|
||||||
" fewer lines than expected";
|
" fewer lines than expected";
|
||||||
Msg.debug(Compare.class, message);
|
Msg.debug(StringComparer.class, message);
|
||||||
Assert.fail(message);
|
Assert.fail(message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1854,20 +1854,16 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
|
||||||
// as message dialogs will too be closed
|
// as message dialogs will too be closed
|
||||||
DockingDialog d = (DockingDialog) activeWindow;
|
DockingDialog d = (DockingDialog) activeWindow;
|
||||||
Window ancestor = SwingUtilities.getWindowAncestor(d);
|
Window ancestor = SwingUtilities.getWindowAncestor(d);
|
||||||
if (!d.isShowing()) {
|
if (d.isShowing() && isNonTransientWindow(d)) {
|
||||||
if (!ancestor.isShowing()) {
|
return d;
|
||||||
return null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
// The active window is not a suitable parent; try its parent
|
||||||
|
if (ancestor.isShowing() && isNonTransientWindow(ancestor)) {
|
||||||
return ancestor;
|
return ancestor;
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogComponentProvider provider = d.getComponent();
|
return null;
|
||||||
if (provider.isTransient()) {
|
|
||||||
return ancestor;
|
|
||||||
}
|
|
||||||
|
|
||||||
return d;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ComponentProvider getActiveComponentProvider() {
|
public ComponentProvider getActiveComponentProvider() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue