Test timing fixes

This commit is contained in:
dragonmacher 2022-09-22 12:07:19 -04:00
parent e79bd65944
commit b48fc9aad7
5 changed files with 530 additions and 674 deletions

View file

@ -15,7 +15,7 @@
*/
package generic.test;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.*;
import java.awt.*;
import java.awt.event.*;
@ -43,6 +43,7 @@ import org.junit.rules.*;
import org.junit.runner.Description;
import generic.jar.ResourceFile;
import generic.test.rule.Repeated;
import generic.test.rule.RepeatedTestRule;
import generic.util.WindowUtilities;
import ghidra.GhidraTestApplicationLayout;
@ -116,7 +117,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
/**
* This rule handles the {@link Repeated} annotation
*
*
* <p>
* During batch mode, this rule should never be needed. This rule is included here as a
* convenience, in case a developer wants to use the {@link Repeated} annotation to diagnose a
@ -169,7 +170,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
/**
* A method to update any {@link ApplicationLayout} values
*
*
* @param layout the layout to initialize
*/
protected void initializeLayout(ApplicationLayout layout) {
@ -223,7 +224,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
/**
* Determine if test failure occur (for use within tear down methods)
*
*
* @return true if test failure detected
*/
protected boolean hasTestFailed() {
@ -234,7 +235,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
* A callback for subclasses when a test has failed. This will be called
* <b>after</b> <code>tearDown()</code>. This means that any diagnostics will have to
* take into account items that have already been disposed.
*
*
* @param e the exception that happened when the test failed
*/
protected void testFailed(Throwable e) {
@ -264,8 +265,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
public static Set<Window> getAllWindows() {
Set<Window> set = new HashSet<>();
Frame sharedOwnerFrame = (Frame) AppContext.getAppContext()
.get(
new StringBuffer("SwingUtilities.sharedOwnerFrame"));
.get(new StringBuffer("SwingUtilities.sharedOwnerFrame"));
if (sharedOwnerFrame != null) {
set.addAll(getAllWindows(sharedOwnerFrame));
}
@ -306,7 +306,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
/**
* Load a text resource file into an ArrayList. Each line of the file is
* stored as an item in the list.
*
*
* @param cls class where resource exists
* @param name resource filename
* @return list of lines contained in file
@ -403,7 +403,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
/**
* Returns the data directory containing test programs and data
*
*
* @return the data directory containing test programs and data
*/
public static File getTestDataDirectory() {
@ -506,7 +506,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
* Get the first field object contained within object ownerInstance which
* has the type classType. This method is only really useful if it is known
* that only a single field of classType exists within the ownerInstance.
*
*
* @param <T> the type
* @param classType the class type of the desired field
* @param ownerInstance the object instance that owns the field
@ -647,7 +647,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
* Finds the button with the indicated TEXT that is a sub-component of the
* indicated container, and then programmatically presses the button. <BR>
* The following is a sample JUnit test use:
*
*
* <PRE>
* env.showTool();
* OptionDialog dialog = (OptionDialog) env.waitForDialog(OptionDialog.class, 1000);
@ -667,7 +667,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
/**
* Finds the button with the indicated TEXT that is a sub-component of the
* indicated container, and then programmatically presses the button.
*
*
* @param container the container to search. (Typically a dialog.)
* @param buttonText the text on the desired JButton.
* @param waitForCompletion if true wait for action to complete before
@ -695,7 +695,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
/**
* Finds the button with the indicated NAME that is a subcomponent of the
* indicated container, and then programmatically presses the button.
*
*
* @param container the container to search. (Typically a dialog)
* @param buttonName the name on the desired AbstractButton (see
* Component.setName())
@ -707,7 +707,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
/**
* Finds the button with the indicated NAME that is a subcomponent of the
* indicated container, and then programmatically presses the button.
*
*
* @param container the container to search. (Typically a dialog.)
* @param buttonName the name on the desired AbstractButton (see
* Component.setName()).
@ -733,7 +733,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
/**
* Programmatically presses the indicated button.
*
*
* @param button the button
*/
public static void pressButton(AbstractButton button) {
@ -745,7 +745,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
/**
* Programmatically presses the indicated button.
*
*
* @param button the button
* @param waitForCompletion if true wait for action to complete before
* returning, otherwise schedule action to be performed and
@ -854,7 +854,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
/**
* Searches the subcomponents of the the given container and returns the
* JButton that has the specified text.
*
*
* @param container the container to search
* @param text the button text
* @return the JButton, or null the button was not found
@ -954,7 +954,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
/**
* Simulates click the mouse button.
*
*
* @param comp the component to click on.
* @param button the mouse button (1, 2, or 3)
* @param x the x coordinate of the click location
@ -982,7 +982,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
/**
* Simulates click the mouse button.
*
*
* @param comp the component to click on.
* @param button the mouse button (1, 2, or 3)
* @param x the x coordinate of the click location
@ -998,7 +998,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
/**
* Simulates a mouse drag action
*
*
* @param comp the component to drag on.
* @param button the mouse button (1, 2, or 3)
* @param startX the x coordinate of the start drag location
@ -1022,7 +1022,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
/**
* Fire a mouse moved event for the given component.
*
*
* @param comp source of the event.
* @param x x position relative to the component
* @param y y position relative to the component
@ -1121,9 +1121,9 @@ public abstract class AbstractGenericTest extends AbstractGTest {
/**
* Run the given code snippet on the Swing thread later, not blocking the current thread. Use
* this if the code snippet causes a blocking operation.
*
*
* <P>This is a shortcut for <code>runSwing(r, false);</code>.
*
*
* @param r the runnable code snippet
*/
public void runSwingLater(Runnable r) {
@ -1133,7 +1133,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
/**
* Call this version of {@link #runSwing(Runnable)} when you expect your runnable <b>may</b>
* throw exceptions
*
*
* @param callback the runnable code snippet to call
* @throws Exception any exception that is thrown on the Swing thread
*/
@ -1360,7 +1360,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
/**
* Clicks a range of items in a list (simulates holding SHIFT and selecting
* each item in the range in-turn)
*
*
* @param list the list to select from
* @param row the initial index
* @param count the number of rows to select
@ -1378,7 +1378,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
/**
* Clicks a range of items in a table (simulates holding SHIFT and selecting
* each item in the range)
*
*
* @param table the table to select
* @param row the starting row index
* @param count the number of rows to select
@ -1411,7 +1411,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
/**
* Gets the rendered value for the specified table cell. The actual value at the cell may
* not be a String. This method will get the String display value, as created by the table.
*
*
* @param table the table to query
* @param row the row to query
* @param column the column to query
@ -1459,7 +1459,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
* Note: This method affects the expansion state of the tree. It will expand
* nodes starting at the root until a match is found or all of the tree is
* checked.
*
*
* @param tree the tree
* @param text the tree node's text
* @return the tree path
@ -1473,7 +1473,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
/**
* Performs a depth first search for the named tree node.
*
*
* @param tree the tree to search
* @param startTreePath path indicating node to begin searching from in the
* tree
@ -1505,7 +1505,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
/**
* Returns a string which is a printout of a stack trace for each thread
* running in the current JVM
*
*
* @return the stack trace string
*/
public static String createStackTraceForAllThreads() {
@ -1515,7 +1515,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
/**
* Prints the contents of the given collection by way of the
* {@link Object#toString()} method.
*
*
* @param collection The contents of which to print
* @return A string representation of the given collection
*/
@ -1841,7 +1841,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
* {@link Files#createTempDirectory(Path, String, java.nio.file.attribute.FileAttribute...)}.
* Any left-over test directories will be cleaned-up before creating the new
* directory.
*
*
* <p>
* Note: you should not call this method multiple times, as each call will
* cleanup the previously created directories.
@ -1875,7 +1875,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
* Creates a file path with a filename that is under the system temp
* directory. The path returned will not point to an existing file. The
* suffix of the file will be <code>.tmp</code>.
*
*
* @param name the filename
* @return a new file path
* @throws IOException if there is any problem ensuring that the created
@ -1892,7 +1892,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
* directory. The path returned will not point to an existing file. This
* method is the same as {@link #createTempFilePath(String)}, except that
* you must provide the extension.
*
*
* @param name the filename
* @param extension the file extension
* @return a new file path
@ -1911,7 +1911,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
* for the filename. This method calls {@link #createTempFile(String)},
* which will cleanup any pre-existing temp files whose name pattern matches
* this test name. This helps to avoid old temp files from accumulating.
*
*
* @return the new temp file
* @throws IOException if there is a problem creating the new file
*/
@ -1924,7 +1924,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
* for the filename. This method calls {@link #createTempFile(String)},
* which will cleanup any pre-existing temp files whose name pattern matches
* this test name. This helps to avoid old temp files from accumulating.
*
*
* @param suffix the suffix to provide for the temp file
* @return the new temp file
* @throws IOException if there is a problem creating the new file