diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index a5ce239..d668c64 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -125,4 +125,4 @@ enforcement ladder](https://github.com/mozilla/diversity). For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at -https://www.contributor-covenant.org/translations. \ No newline at end of file +https://www.contributor-covenant.org/translations. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..526e93b --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,107 @@ +# Contributing to WindowTester + +First off β€” thanks for taking the time to contribute! πŸŽ‰ +The following guidelines will help you set up the project locally, follow our coding standards, and +submit high-quality contributions. + +--- + +## πŸ“‹ Before You Start + +- Read our [Code of Conduct](CODE_OF_CONDUCT.md) β€” we take respectful collaboration seriously. +- Check existing [Issues](issues) and [Pull Requests](pulls) to avoid duplication. +- For large changes, please open a discussion or issue first. + +--- + +## πŸ›  Local Development Setup + +1. **Fork & Clone** + + ```bash + git clone https://github.com/r4fterman/windowtester.git + cd windowtester + ``` +2. Run the project + + ```bash + mvn clean verify + ``` +3. Run the tests + + ```bash + mvn clean test + ``` + +## πŸ§‘β€πŸ’» Coding Guidelines + +- Follow the code style enforced by our linter (npm run lint). +- Use descriptive commit messages (e.g., fix: correct typo in readme). +- Keep pull requests focused β€” one feature or bugfix per PR. + +## Code Style + +Thank you for following the style guide and helping us keep the codebase consistent! + +### Formatting + +- We follow the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html). +- Code formatting is fully automated: + - The project is configured with [spotless-maven-plugin](https://github.com/diffplug/spotless). + - A local `pre-commit` hook runs Spotless automatically. See `scripts/git-hooks/pre-commit` +- You do **not** need to manually format your code or run additional commands. +- When you run `git commit`, Spotless will reformat staged Java files if needed. +- If formatting changes were applied, they are automatically added to the commit before it is + finalized. + +**Developer Notes** + +- Always commit your changes as usual: `git add ... && git commit -m "message"`. +- If your IDE shows formatting differences, don’t worry – the hook will fix them during commit. +- Pull requests will only be accepted if they are properly formatted (this is enforced by CI as + well). + +### Import Rules + +- Wildcard imports (e.g., `import java.util.*;`) are **not allowed**. +- Each class must be imported explicitly, for example: + + ```java + // βœ… Allowed + import java.util.List; + import java.util.Map; + + // ❌ Not allowed + import java.util.*; + ``` +- This rule is enforced via Checkstyle. + If wildcard imports are present, the build will fail. + +## πŸ”„ Pull Request Process + +1. Create a new branch for your work: + + ```bash + git checkout -b feature/my-new-feature + ``` +2. Commit your changes with a clear message. +3. Push your branch to your fork: + + ```bash + git push origin feature/my-new-feature + ``` +4. Open a Pull Request against the main branch. + +## 🐞 Reporting Bugs + +- Use the GitHub Issue Tracker and create a new entry there. +- Include steps to reproduce, expected behavior, and screenshots if possible. + +## πŸ’‘ Suggesting Features + +- Use the β€œFeature Request” issue template. +- Clearly explain why the feature is needed and how it should work. + +--- + +Thanks again for contributing to WindowTester β€” you help make it better for everyone! πŸš€ diff --git a/CONTRIBUTION.md b/CONTRIBUTION.md deleted file mode 100644 index 7f5ad19..0000000 --- a/CONTRIBUTION.md +++ /dev/null @@ -1,74 +0,0 @@ -# Contributing to WindowTester - -First off β€” thanks for taking the time to contribute! πŸŽ‰ -The following guidelines will help you set up the project locally, follow our coding standards, and -submit high-quality contributions. - ---- - -## πŸ“‹ Before You Start - -- Read our [Code of Conduct](CODE_OF_CONDUCT.md) β€” we take respectful collaboration seriously. -- Check existing [Issues](issues) and [Pull Requests](pulls) to avoid duplication. -- For large changes, please open a discussion or issue first. - ---- - -## πŸ›  Local Development Setup - -1. **Fork & Clone** - - ```bash - git clone https://github.com/r4fterman/windowtester.git - cd windowtester - ``` - -2. Run the project - - ```bash - mvn clean verify - ``` - -3. Run the tests - - ```bash - mvn clean test - ``` - -## πŸ§‘β€πŸ’» Coding Guidelines - -β€’ Follow the code style enforced by our linter (npm run lint). -β€’ Use descriptive commit messages (e.g., fix: correct typo in readme). -β€’ Keep pull requests focused β€” one feature or bugfix per PR. - -## πŸ”„ Pull Request Process - -1. Create a new branch for your work: - - ```bash - git checkout -b feature/my-new-feature - ``` - -2. Commit your changes with a clear message. - -3. Push your branch to your fork: - - ```bash - git push origin feature/my-new-feature - ``` - -4. Open a Pull Request against the main branch. - -## 🐞 Reporting Bugs - -β€’ Use the GitHub Issue Tracker and create a new entry there. -β€’ Include steps to reproduce, expected behavior, and screenshots if possible. - -## πŸ’‘ Suggesting Features - -β€’ Use the β€œFeature Request” issue template. -β€’ Clearly explain why the feature is needed and how it should work. - ---- - -Thanks again for contributing to WindowTester β€” you help make it better for everyone! πŸš€ \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md index 1473ef2..97d8ac1 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,5 +1,5 @@ Eclipse Public License - v 1.0 -============================= +============================== THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS @@ -12,14 +12,14 @@ AGREEMENT. * **a)** in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and * **b)** in the case of each subsequent Contributor: - * **i)** changes to the Program, and - * **ii)** additions to the Program; - where such changes and/or additions to the Program originate from and are distributed by that - particular Contributor. A Contribution 'originates' from a Contributor if it was added to the - Program by such Contributor itself or anyone acting on such Contributor's behalf. - Contributions do not include additions to the Program which: **(i)** are separate modules of - software distributed in conjunction with the Program under their own license agreement, and * - *(ii)** are not derivative works of the Program. + * **i)** changes to the Program, and + * **ii)** additions to the Program; + where such changes and/or additions to the Program originate from and are distributed by that + particular Contributor. A Contribution 'originates' from a Contributor if it was added to the + Program by such Contributor itself or anyone acting on such Contributor's behalf. + Contributions do not include additions to the Program which: **(i)** are separate modules of + software distributed in conjunction with the Program under their own license agreement, and * + *(ii)** are not derivative works of the Program. "Contributor" means any person or entity that distributes the Program. @@ -66,17 +66,17 @@ agreement, provided that: * **a)** it complies with the terms and conditions of this Agreement; and * **b)** its license agreement: - * **i)** effectively disclaims on behalf of all Contributors all warranties and conditions, - express and implied, including warranties or conditions of title and non-infringement, and - implied warranties or conditions of merchantability and fitness for a particular purpose; - * **ii)** effectively excludes on behalf of all Contributors all liability for damages, - including direct, indirect, special, incidental and consequential damages, such as lost - profits; - * **iii)** states that any provisions which differ from this Agreement are offered by that - Contributor alone and not by any other party; and - * **iv)** states that source code for the Program is available from such Contributor, and - informs licensees how to obtain it in a reasonable manner on or through a medium customarily - used for software exchange. + * **i)** effectively disclaims on behalf of all Contributors all warranties and conditions, + express and implied, including warranties or conditions of title and non-infringement, and + implied warranties or conditions of merchantability and fitness for a particular purpose; + * **ii)** effectively excludes on behalf of all Contributors all liability for damages, + including direct, indirect, special, incidental and consequential damages, such as lost + profits; + * **iii)** states that any provisions which differ from this Agreement are offered by that + Contributor alone and not by any other party; and + * **iv)** states that source code for the Program is available from such Contributor, and + informs licensees how to obtain it in a reasonable manner on or through a medium customarily + used for software exchange. When the Program is made available in source code form: diff --git a/README.md b/README.md index e5ed4b5..f1874c0 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ ![Static Badge](https://img.shields.io/badge/Java-v17-blue) ![Static Badge](https://img.shields.io/badge/Maven-v3.5.4-blue) [![License](https://img.shields.io/badge/License-EPL--1.0-green.svg)](LICENSE.md) -[![Build WindowTester](https://github.com/r4fterman/windowtester/actions/workflows/maven.yml/badge.svg)]( https://github.com/r4fterman/windowtester/actions/workflows/maven.yml) +[![Build WindowTester](https://github.com/r4fterman/windowtester/actions/workflows/maven.yml/badge.svg)](https://github.com/r4fterman/windowtester/actions/workflows/maven.yml) +[![codecov](https://codecov.io/gh/r4fterman/windowtester/graph/badge.svg?token=fEDTM853bU)](https://codecov.io/gh/r4fterman/windowtester) ## Disclaimer @@ -24,7 +25,6 @@ Using `WindowTester Pro`, developers can easily create tests for every GUI they The tests generated by `WindowTester Pro` are standard [JUnit](http://junit.org/) tests thus they can be run within your IDE, or they can be automated to run using [Maven](http://maven.apache.org/). - ## Features - Write automated UI checks as code in JUnit style @@ -35,7 +35,7 @@ can be run within your IDE, or they can be automated to run using [Maven](http:/ - JDK 21 - JUnit 5 - + Supported platforms: - Windows @@ -50,7 +50,7 @@ The runtime library provides base functionality so WindowTester can operate on a io.github.r4fterman com.windowtester.runtime - 5.13.4 + 6.0.0 ``` @@ -60,7 +60,7 @@ The runtime library provides base functionality so WindowTester can operate on J io.github.r4fterman com.windowtester.swing.runtime - 5.13.4 + 6.0.0 ``` @@ -70,7 +70,7 @@ Abbot provides robot functionality to interact with the UI: io.github.r4fterman abbot - 5.13.4 + 6.0.0 ``` @@ -80,10 +80,17 @@ The recorder library provides functionality to record a manual UI interaction an io.github.r4fterman com.windowtester.swing.recorder - 5.13.4 + 6.0.0 ``` +## Code Style + +This project uses the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html). +Code formatting is automatically applied via [spotless-maven-plugin](https://github.com/diffplug/spotless) in a local `pre-commit` hook. + +➑️ Contributors don’t need to run anything manually – whenever you commit, your code will be formatted automatically before being pushed. + ## License -This project is licensed under the [Eclipse License v1.0](LICENSE.md). \ No newline at end of file +This project is licensed under the [Eclipse License v1.0](LICENSE.md). diff --git a/SECURITY.md b/SECURITY.md index 08472d7..d991ee5 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -4,8 +4,8 @@ Here is an overview of the released version and their support status. -| Version | Supported | End of Life | -| ------- | ------------------ |---------------------| +| Version | Supported | End of Life | +|---------|--------------------|---------------------| | 3.x | :white_check_mark: | Security support | | 4.x | :white_check_mark: | Security support | | 5.x | :white_check_mark: | Maintenance support | diff --git a/abbot/pom.xml b/abbot/pom.xml index 05849ba..3c46cf3 100644 --- a/abbot/pom.xml +++ b/abbot/pom.xml @@ -5,7 +5,7 @@ io.github.r4fterman com.windowtester - 6.0.0-SNAPSHOT + 6.0.1-SNAPSHOT abbot @@ -23,7 +23,6 @@ org.junit.platform junit-platform-suite - 1.10.1 @@ -58,6 +57,13 @@ + + dev.dimlight + shellcheck-maven-plugin + + true + + diff --git a/abbot/src/main/java/abbot/AssertionFailedError.java b/abbot/src/main/java/abbot/AssertionFailedError.java index f3a2551..8a7c40b 100644 --- a/abbot/src/main/java/abbot/AssertionFailedError.java +++ b/abbot/src/main/java/abbot/AssertionFailedError.java @@ -13,8 +13,7 @@ public class AssertionFailedError extends RuntimeException { private File file; private int line; - public AssertionFailedError() { - } + public AssertionFailedError() {} public AssertionFailedError(String msg) { super(msg); @@ -41,6 +40,6 @@ private static String getMessage(String msg, Step step) { } File file = Script.getFile(step); - return Strings.get("step.failure", new Object[]{msg, file, line}); + return Strings.get("step.failure", new Object[] {msg, file, line}); } } diff --git a/abbot/src/main/java/abbot/Log.java b/abbot/src/main/java/abbot/Log.java index c4c1c15..8ec75c3 100644 --- a/abbot/src/main/java/abbot/Log.java +++ b/abbot/src/main/java/abbot/Log.java @@ -55,8 +55,7 @@ public final class Log { /** * No instantiations. */ - private Log() { - } + private Log() {} /** * Global final to determine whether debugging code is generated. This should be changed to false @@ -79,9 +78,7 @@ private Log() { * static final int WARNING = 0x0002; public static final int DEBUG = 0x0004; public static * final int INFO = 0x0008; */ - private static class LogSynchronizer extends Object { - - } + private static class LogSynchronizer extends Object {} /** * Synchronize message output. @@ -197,8 +194,7 @@ public static String[] init(String[] args) { new PrintStream( new OutputStream() { @Override - public void write(int b) { - } + public void write(int b) {} }); System.setErr(nullStream); System.setOut(nullStream); diff --git a/abbot/src/main/java/abbot/editor/ComponentBrowser.java b/abbot/src/main/java/abbot/editor/ComponentBrowser.java index 163ea06..746d3e0 100644 --- a/abbot/src/main/java/abbot/editor/ComponentBrowser.java +++ b/abbot/src/main/java/abbot/editor/ComponentBrowser.java @@ -658,8 +658,8 @@ public Collection getComponents(Component component) { } public boolean contains(Component component) { - return (isCompact() ? super.contains(component) : raw.contains(component)) && !filtered.containsKey( - component); + return (isCompact() ? super.contains(component) : raw.contains(component)) + && !filtered.containsKey(component); } public void filter(Component c) { diff --git a/abbot/src/main/java/abbot/editor/LogoLabel.java b/abbot/src/main/java/abbot/editor/LogoLabel.java index 2545f32..030acf5 100644 --- a/abbot/src/main/java/abbot/editor/LogoLabel.java +++ b/abbot/src/main/java/abbot/editor/LogoLabel.java @@ -3,7 +3,6 @@ /** * Provides the abbot/costello logo. */ - import abbot.i18n.Strings; import javax.swing.ImageIcon; import javax.swing.JLabel; diff --git a/abbot/src/main/java/abbot/editor/recorder/ComponentRecorder.java b/abbot/src/main/java/abbot/editor/recorder/ComponentRecorder.java index 9b00689..318e14b 100644 --- a/abbot/src/main/java/abbot/editor/recorder/ComponentRecorder.java +++ b/abbot/src/main/java/abbot/editor/recorder/ComponentRecorder.java @@ -462,7 +462,8 @@ protected boolean parseKeyEvent(AWTEvent e) { // the generated characters are not accepted as text input. // Add others if you encounter them, but err on the side of // accepting input that can later be removed. - if ((modifiers & Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()) == Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx() + if ((modifiers & Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()) + == Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx() || (modifiers & InputEvent.ALT_DOWN_MASK) == InputEvent.ALT_DOWN_MASK) { Log.debug("Ignoring modifiers: " + modifiers); setRecordingType(SE_NONE); diff --git a/abbot/src/main/java/abbot/editor/recorder/EventRecorder.java b/abbot/src/main/java/abbot/editor/recorder/EventRecorder.java index e970d35..64b4cdd 100644 --- a/abbot/src/main/java/abbot/editor/recorder/EventRecorder.java +++ b/abbot/src/main/java/abbot/editor/recorder/EventRecorder.java @@ -543,7 +543,7 @@ private void captureRawEvent(AWTEvent event) { break; case MouseEvent.MOUSE_ENTERED: case MouseEvent.MOUSE_EXITED: - // case MouseEvent.MOUSE_MOVED: + // case MouseEvent.MOUSE_MOVED: case MouseEvent.MOUSE_DRAGGED: capture = captureMotion; break; @@ -628,8 +628,10 @@ protected SemanticRecorder getSemanticRecorder(Class cls) { sr.addActionListener(getListener()); } catch (InvocationTargetException e) { Log.warn(e); - } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | - ClassNotFoundException e) { + } catch (NoSuchMethodException + | InstantiationException + | IllegalAccessException + | ClassNotFoundException e) { sr = getSemanticRecorder(cls.getSuperclass()); } // Cache the results for future reference diff --git a/abbot/src/main/java/abbot/editor/recorder/SemanticRecorder.java b/abbot/src/main/java/abbot/editor/recorder/SemanticRecorder.java index 394b124..0539402 100644 --- a/abbot/src/main/java/abbot/editor/recorder/SemanticRecorder.java +++ b/abbot/src/main/java/abbot/editor/recorder/SemanticRecorder.java @@ -152,5 +152,4 @@ protected void setStatus(String msg) { al.actionPerformed(event); } } - } diff --git a/abbot/src/main/java/abbot/finder/AWTHierarchy.java b/abbot/src/main/java/abbot/finder/AWTHierarchy.java index f48fc1f..b09d215 100644 --- a/abbot/src/main/java/abbot/finder/AWTHierarchy.java +++ b/abbot/src/main/java/abbot/finder/AWTHierarchy.java @@ -49,8 +49,7 @@ public void dispose(Window window) { Log.debug("Dispose " + window); - Arrays.stream(window.getOwnedWindows()) - .forEach(this::dispose); + Arrays.stream(window.getOwnedWindows()).forEach(this::dispose); if (AWT.isSharedInvisibleFrame(window)) { // Don't dispose, or any child windows which may be currently @@ -62,31 +61,32 @@ public void dispose(Window window) { // exceptions. If Window.dispose is called from a non-Swing thread, // it will invoke the dispose action on the Swing thread but in that // case we have no control over exceptions. - Runnable action = () -> { - try { - // Distinguish between the abbot framework disposing a - // window and anyone else doing so. - System.setProperty("abbot.finder.disposal", "true"); - window.dispose(); - System.setProperty("abbot.finder.disposal", "false"); - } catch (NullPointerException npe) { - // Catch bug in AWT 1.3.1 when generating hierarchy - // events - Log.log(npe); - } catch (ExitException e) { - // Some apps might call System.exit on WINDOW_CLOSED - Log.log("Ignoring SUT exit: " + e); - } catch (Throwable e) { - // Don't allow other exceptions to interfere with - // disposal. - Log.warn(e); - Log.warn( - "An exception was thrown when disposing " - + " the window " - + Robot.toString(window) - + ". The exception is ignored"); - } - }; + Runnable action = + () -> { + try { + // Distinguish between the abbot framework disposing a + // window and anyone else doing so. + System.setProperty("abbot.finder.disposal", "true"); + window.dispose(); + System.setProperty("abbot.finder.disposal", "false"); + } catch (NullPointerException npe) { + // Catch bug in AWT 1.3.1 when generating hierarchy + // events + Log.log(npe); + } catch (ExitException e) { + // Some apps might call System.exit on WINDOW_CLOSED + Log.log("Ignoring SUT exit: " + e); + } catch (Throwable e) { + // Don't allow other exceptions to interfere with + // disposal. + Log.warn(e); + Log.warn( + "An exception was thrown when disposing " + + " the window " + + Robot.toString(window) + + ". The exception is ignored"); + } + }; if (SwingUtilities.isEventDispatchThread()) { action.run(); @@ -110,8 +110,8 @@ public Collection getComponents(Component component) { return EMPTY; } - ArrayList list = new ArrayList<>( - Arrays.asList(((Container) component).getComponents())); + ArrayList list = + new ArrayList<>(Arrays.asList(((Container) component).getComponents())); // Add other components which are not explicitly children, but // that are conceptually descendents if (component instanceof JMenu menu) { diff --git a/abbot/src/main/java/abbot/finder/BasicFinder.java b/abbot/src/main/java/abbot/finder/BasicFinder.java index f345009..0969328 100644 --- a/abbot/src/main/java/abbot/finder/BasicFinder.java +++ b/abbot/src/main/java/abbot/finder/BasicFinder.java @@ -52,8 +52,7 @@ public Container getParent(Component component) { @Override public boolean contains(Component component) { - return getHierarchy().contains(component) - && SwingUtilities.isDescendingFrom(component, root); + return getHierarchy().contains(component) && SwingUtilities.isDescendingFrom(component, root); } @Override @@ -101,12 +100,12 @@ protected Component find(Hierarchy hierarchy, Matcher matcher) } if (found.isEmpty()) { - var msg = Strings.get("finder.not_found", new Object[]{matcher.toString()}); + var msg = Strings.get("finder.not_found", new Object[] {matcher.toString()}); throw new ComponentNotFoundException(msg); } else if (found.size() > 1) { var list = found.toArray(new Component[0]); if (!(matcher instanceof MultiMatcher)) { - var msg = Strings.get("finder.multiple_found", new Object[]{matcher.toString()}); + var msg = Strings.get("finder.multiple_found", new Object[] {matcher.toString()}); throw new MultipleComponentsFoundException(msg, list); } return ((MultiMatcher) matcher).bestMatch(list); @@ -115,10 +114,7 @@ protected Component find(Hierarchy hierarchy, Matcher matcher) } protected void findMatches( - Hierarchy hierarchy, - Matcher matcher, - Component component, - Set found) { + Hierarchy hierarchy, Matcher matcher, Component component, Set found) { if (found.size() == 1 && !(matcher instanceof MultiMatcher)) { return; } diff --git a/abbot/src/main/java/abbot/finder/TestHierarchy.java b/abbot/src/main/java/abbot/finder/TestHierarchy.java index d0b559c..51c6827 100644 --- a/abbot/src/main/java/abbot/finder/TestHierarchy.java +++ b/abbot/src/main/java/abbot/finder/TestHierarchy.java @@ -64,9 +64,7 @@ public void ignoreExisting() { @Override public Collection getRoots() { var components = super.getRoots(); - return components.stream() - .filter(key -> !filtered.containsKey(key)) - .toList(); + return components.stream().filter(key -> !filtered.containsKey(key)).toList(); } @Override @@ -75,9 +73,7 @@ public Collection getComponents(Component component) { var components = super.getComponents(component); // NOTE: this only removes those components which are directly // filtered, not necessarily those which have a filtered ancestor. - return components.stream() - .filter(key -> !filtered.containsKey(key)) - .toList(); + return components.stream().filter(key -> !filtered.containsKey(key)).toList(); } return EMPTY; } @@ -115,8 +111,7 @@ private void setFiltered(Component component, boolean filter) { if (component instanceof Window window) { var windows = window.getOwnedWindows(); - Arrays.stream(windows) - .forEach(w -> setFiltered(w, filter)); + Arrays.stream(windows).forEach(w -> setFiltered(w, filter)); } } diff --git a/abbot/src/main/java/abbot/finder/matchers/ClassMatcher.java b/abbot/src/main/java/abbot/finder/matchers/ClassMatcher.java index 03fc330..cf4535d 100644 --- a/abbot/src/main/java/abbot/finder/matchers/ClassMatcher.java +++ b/abbot/src/main/java/abbot/finder/matchers/ClassMatcher.java @@ -21,8 +21,7 @@ public ClassMatcher(Class cls, boolean mustBeShowing) { @Override public boolean matches(Component component) { - return cls.isAssignableFrom(component.getClass()) - && (!mustBeShowing || component.isShowing()); + return cls.isAssignableFrom(component.getClass()) && (!mustBeShowing || component.isShowing()); } @Override diff --git a/abbot/src/main/java/abbot/finder/matchers/WindowMatcher.java b/abbot/src/main/java/abbot/finder/matchers/WindowMatcher.java index b9be8da..3dff9dc 100644 --- a/abbot/src/main/java/abbot/finder/matchers/WindowMatcher.java +++ b/abbot/src/main/java/abbot/finder/matchers/WindowMatcher.java @@ -28,8 +28,8 @@ public boolean matches(Component component) { return super.matches(component) && (component.isShowing() || !mustBeShowing) && (stringsMatch(id, component.getName()) - || (component instanceof Frame frame && stringsMatch(id, frame.getTitle())) - || (component instanceof Dialog dialog && stringsMatch(id, dialog.getTitle()))); + || (component instanceof Frame frame && stringsMatch(id, frame.getTitle())) + || (component instanceof Dialog dialog && stringsMatch(id, dialog.getTitle()))); } @Override diff --git a/abbot/src/main/java/abbot/i18n/Strings.java b/abbot/src/main/java/abbot/i18n/Strings.java index 98bbc72..f45029a 100644 --- a/abbot/src/main/java/abbot/i18n/Strings.java +++ b/abbot/src/main/java/abbot/i18n/Strings.java @@ -31,8 +31,7 @@ public class Strings { addBundle(BUNDLE); } - private Strings() { - } + private Strings() {} public static void addBundle(String bundle) { var locale = Locale.getDefault(); @@ -64,8 +63,7 @@ public static String get(String key, boolean optional) { } } - if (value == null - && !optional) { + if (value == null && !optional) { Log.log("Missing resource '" + key + "'"); value = defaultValue; } diff --git a/abbot/src/main/java/abbot/script/Annotation.java b/abbot/src/main/java/abbot/script/Annotation.java index 9973301..4633d35 100644 --- a/abbot/src/main/java/abbot/script/Annotation.java +++ b/abbot/src/main/java/abbot/script/Annotation.java @@ -67,9 +67,7 @@ public class Annotation extends Step { private int width = -1; private int height = -1; - class WindowLock { - - } + class WindowLock {} private final transient Object WINDOW_LOCK = new WindowLock(); private transient volatile Frame frame; @@ -164,8 +162,7 @@ public void showAnnotation() { } else { try { SwingUtilities.invokeAndWait((Runnable) this::showAnnotationWindow); - SwingUtilities.invokeAndWait((Runnable) () -> { - }); + SwingUtilities.invokeAndWait((Runnable) () -> {}); } catch (Exception e) { Log.warn(e); } @@ -224,8 +221,8 @@ private AnnotationWindow createWindow() { w = (parent instanceof Dialog) ? (title != null - ? new AnnotationWindow((Dialog) parent, title) - : new AnnotationWindow((Dialog) parent)) + ? new AnnotationWindow((Dialog) parent, title) + : new AnnotationWindow((Dialog) parent)) : (title != null ? new AnnotationWindow((Frame) parent, title) : new AnnotationWindow((Frame) parent)); diff --git a/abbot/src/main/java/abbot/script/Call.java b/abbot/src/main/java/abbot/script/Call.java index 6cf2afd..84df8c6 100644 --- a/abbot/src/main/java/abbot/script/Call.java +++ b/abbot/src/main/java/abbot/script/Call.java @@ -265,11 +265,11 @@ protected Method[] resolveMethods(String name, Class cls, Class returnType) throw new NoSuchMethodException( Strings.get( "call.no_matching_method", - new Object[]{ - name, - (returnType == null ? "*" : returnType.toString()), - String.valueOf(args.length), - cls + new Object[] { + name, + (returnType == null ? "*" : returnType.toString()), + String.valueOf(args.length), + cls })); } @@ -312,7 +312,7 @@ protected Method disambiguateMethod(Method[] methods) { String msg = Strings.get( "call.multiple_methods", - new Object[]{methods[0].getName(), methods[0].getDeclaringClass()}); + new Object[] {methods[0].getName(), methods[0].getDeclaringClass()}); throw new IllegalArgumentException(msg); } } diff --git a/abbot/src/main/java/abbot/script/ComponentReference.java b/abbot/src/main/java/abbot/script/ComponentReference.java index f721677..4e5657e 100644 --- a/abbot/src/main/java/abbot/script/ComponentReference.java +++ b/abbot/src/main/java/abbot/script/ComponentReference.java @@ -17,8 +17,6 @@ import java.awt.Frame; import java.awt.Label; import java.awt.Window; -import java.io.IOException; -import java.io.StringReader; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Arrays; @@ -448,9 +446,7 @@ private void validate(Component comp, Map newReferen String msg = Strings.get( "component.creation_mismatch", - new Object[]{ - toXMLString(), comp.toString(), wt, exact - }); + new Object[] {toXMLString(), comp.toString(), wt, exact}); throw new Error(msg); } } else { @@ -493,8 +489,7 @@ public static String getDescriptiveName(Component c) { if ((name = getTitle(c)) == null) { if ((name = getText(c)) == null) { if ((name = getLabel(c)) == null) { - if ((name = getIconName(c)) == null) { - } + if ((name = getIconName(c)) == null) {} } } } @@ -506,7 +501,7 @@ public String getDescriptiveName() { String id = getAttribute(TAG_ID); if (id == null) { String[] attributes = { - TAG_NAME, TAG_TITLE, TAG_TEXT, TAG_LABEL, TAG_ICON, + TAG_NAME, TAG_TITLE, TAG_TEXT, TAG_LABEL, TAG_ICON, }; for (String attribute : attributes) { String att = getAttribute(attribute); @@ -674,7 +669,7 @@ public String toEditableString() { public boolean equals(Object obj) { return this == obj || (obj instanceof ComponentReference) - && toXMLString().equals(((ComponentReference) obj).toXMLString()); + && toXMLString().equals(((ComponentReference) obj).toXMLString()); } public String toString() { @@ -798,8 +793,8 @@ static String getOrder(Component original, Component[] matchList, boolean horizo * that the ordering attributes can only be evaluated when looking at several otherwise identical * components. */ - private void disambiguate(Component original, Component[] matches, - Map newReferences) + private void disambiguate( + Component original, Component[] matches, Map newReferences) throws ComponentNotFoundException, MultipleComponentsFoundException { Log.debug("Attempting to disambiguate multiple matches"); Container parent = resolver.getHierarchy().getParent(original); @@ -1166,8 +1161,8 @@ public static ComponentReference getReference( return ref; } - public static ComponentReference matchExisting(final Component comp, - Collection existing) { + public static ComponentReference matchExisting( + final Component comp, Collection existing) { Log.debug("Matching " + Robot.toString(comp) + " against existing refs"); @@ -1182,8 +1177,11 @@ public static ComponentReference matchExisting(final Component comp, Iterator iter = existing.iterator(); // Sort such that the best match comes first Map matches = - new TreeMap<>((Comparator) (o1, o2) -> ((ComponentReference) o2).getMatchWeight(comp) - - ((ComponentReference) o1).getMatchWeight(comp)); + new TreeMap<>( + (Comparator) + (o1, o2) -> + ((ComponentReference) o2).getMatchWeight(comp) + - ((ComponentReference) o1).getMatchWeight(comp)); Map empty = new HashMap<>(); while (iter.hasNext()) { ComponentReference ref = iter.next(); diff --git a/abbot/src/main/java/abbot/script/ForkedStepRunner.java b/abbot/src/main/java/abbot/script/ForkedStepRunner.java index a311fe0..1fb696a 100644 --- a/abbot/src/main/java/abbot/script/ForkedStepRunner.java +++ b/abbot/src/main/java/abbot/script/ForkedStepRunner.java @@ -28,8 +28,10 @@ */ public class ForkedStepRunner extends StepRunner { - private static final int LAUNCH_TIMEOUT = Properties.getProperty("abbot.runner.launch_delay", 60000, 0, 300000); - private static final int TERMINATE_TIMEOUT = Properties.getProperty("abbot.runner.terminate_delay", 30000, 0, 300000); + private static final int LAUNCH_TIMEOUT = + Properties.getProperty("abbot.runner.launch_delay", 60000, 0, 300000); + private static final int TERMINATE_TIMEOUT = + Properties.getProperty("abbot.runner.terminate_delay", 30000, 0, 300000); private static ServerSocket serverSocket = null; private Process process = null; diff --git a/abbot/src/main/java/abbot/script/Launch.java b/abbot/src/main/java/abbot/script/Launch.java index 7ab26bd..0b9df25 100644 --- a/abbot/src/main/java/abbot/script/Launch.java +++ b/abbot/src/main/java/abbot/script/Launch.java @@ -276,8 +276,8 @@ public String getDefaultDescription() { String desc = Strings.get( "launch.desc", - new Object[]{ - getTargetClassName() + "." + getMethodName() + "(" + getEncodedArguments() + ")" + new Object[] { + getTargetClassName() + "." + getMethodName() + "(" + getEncodedArguments() + ")" }); return desc; } diff --git a/abbot/src/main/java/abbot/script/Script.java b/abbot/src/main/java/abbot/script/Script.java index adde956..eddf9b1 100644 --- a/abbot/src/main/java/abbot/script/Script.java +++ b/abbot/src/main/java/abbot/script/Script.java @@ -160,11 +160,8 @@ public Script(Resolver parent, Map attributes) { * Since we allow ComponentReference IDs to be changed, make sure our map is always up-to-date. */ private synchronized void synchReferenceIDs() { - Map map = refs.values().stream() - .collect(toMap( - ComponentReference::getID, - value -> value - )); + Map map = + refs.values().stream().collect(toMap(ComponentReference::getID, value -> value)); if (!refs.equals(map)) { // atomic update of references map @@ -316,12 +313,12 @@ private synchronized void verify() throws InvalidScriptException { for (ComponentReference ref : refs.values()) { String id = ref.getAttribute(TAG_PARENT); if (id != null && refs.get(id) == null) { - String msg = Strings.get("script.parent_missing", new Object[]{id}); + String msg = Strings.get("script.parent_missing", new Object[] {id}); throw new InvalidScriptException(msg); } id = ref.getAttribute(TAG_WINDOW); if (id != null && refs.get(id) == null) { - String msg = Strings.get("script.window_missing", new Object[]{id}); + String msg = Strings.get("script.window_missing", new Object[] {id}); throw new InvalidScriptException(msg); } } @@ -555,7 +552,7 @@ public String getUsage() { @Override public String getDefaultDescription() { String ext = fork ? " &" : ""; - String desc = Strings.get("script.desc", new Object[]{getFilename(), ext}); + String desc = Strings.get("script.desc", new Object[] {getFilename(), ext}); return desc.contains(UNTITLED_FILE) ? UNTITLED : desc; } @@ -689,7 +686,7 @@ private ComponentReference addComponentReference(Element el) throws InvalidScrip public ComponentReference getComponentReference(Component comp) { if (!getHierarchy().contains(comp)) { - String msg = Strings.get("script.not_in_hierarchy", new Object[]{comp.toString()}); + String msg = Strings.get("script.not_in_hierarchy", new Object[] {comp.toString()}); throw new IllegalArgumentException(msg); } synchReferenceIDs(); diff --git a/abbot/src/main/java/abbot/script/Sequence.java b/abbot/src/main/java/abbot/script/Sequence.java index 28d2a3e..8b5019d 100644 --- a/abbot/src/main/java/abbot/script/Sequence.java +++ b/abbot/src/main/java/abbot/script/Sequence.java @@ -69,7 +69,7 @@ protected void parseChildren(Element el) throws InvalidScriptException { } public String getDefaultDescription() { - return Strings.get("sequence.desc", new Object[]{String.valueOf(size())}); + return Strings.get("sequence.desc", new Object[] {String.valueOf(size())}); } public String getXMLTag() { diff --git a/abbot/src/main/java/abbot/script/Step.java b/abbot/src/main/java/abbot/script/Step.java index ee0b3e6..c54d185 100644 --- a/abbot/src/main/java/abbot/script/Step.java +++ b/abbot/src/main/java/abbot/script/Step.java @@ -26,6 +26,7 @@ import org.dom4j.DocumentException; import org.dom4j.DocumentHelper; import org.dom4j.Element; + /** * Provides access to one step (line) from a script. A Step is the basic unit of execution. * Custom Step classes

@@ -133,7 +134,7 @@ protected void usage() { protected void usage(String details) { String msg = getUsage(); if (details != null) { - msg = Strings.get("step.usage", new Object[]{msg, details}); + msg = Strings.get("step.usage", new Object[] {msg, details}); } setScriptError(new InvalidScriptException(msg)); } @@ -157,13 +158,14 @@ protected Element addContent(Element el) { protected Element addAttributes(Element el) { // Use a TreeMap to keep the attributes sorted on output new TreeMap<>(getAttributes()) - .forEach((key, value) -> { - if (value == null) { - Log.warn("Attribute '" + key + "' value was null in step " + getXMLTag()); - value = ""; - } - el.addAttribute(key, value); - }); + .forEach( + (key, value) -> { + if (value == null) { + Log.warn("Attribute '" + key + "' value was null in step " + getXMLTag()); + value = ""; + } + el.addAttribute(key, value); + }); return el; } @@ -204,11 +206,7 @@ public static Step createStep(Resolver resolver, String str) protected static Map createAttributeMap(Element el) { Log.debug("Creating attribute map for " + el); - return el.attributes().stream() - .collect(toMap( - Attribute::getName, - Attribute::getValue - )); + return el.attributes().stream().collect(toMap(Attribute::getName, Attribute::getValue)); } public static Step createStep(Resolver resolver, Element el) throws InvalidScriptException { @@ -217,15 +215,11 @@ public static Step createStep(Resolver resolver, Element el) throws InvalidScrip Map attributes; if (tag.equals(TAG_WAIT)) { - attributes = Stream - .concat( - createAttributeMap(el).entrySet().stream(), - Map.of(TAG_WAIT, "true").entrySet().stream()) - .collect( - Collectors.toMap( - Entry::getKey, - Entry::getValue - )); + attributes = + Stream.concat( + createAttributeMap(el).entrySet().stream(), + Map.of(TAG_WAIT, "true").entrySet().stream()) + .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); name = "Assert"; } else { attributes = createAttributeMap(el); @@ -236,17 +230,17 @@ public static Step createStep(Resolver resolver, Element el) throws InvalidScrip Class cls = Class.forName(name); try { // Steps with contents require access to the XML element - Class[] argTypes = new Class[]{Resolver.class, Element.class, Map.class}; + Class[] argTypes = new Class[] {Resolver.class, Element.class, Map.class}; Constructor ctor = cls.getConstructor(argTypes); return (Step) ctor.newInstance(resolver, el, attributes); } catch (NoSuchMethodException nsm) { // All steps must support this ctor - Class[] argTypes = new Class[]{Resolver.class, Map.class}; + Class[] argTypes = new Class[] {Resolver.class, Map.class}; Constructor ctor = cls.getConstructor(argTypes); return (Step) ctor.newInstance(resolver, attributes); } } catch (ClassNotFoundException cnf) { - String msg = Strings.get("step.unknown_tag", new Object[]{tag}); + String msg = Strings.get("step.unknown_tag", new Object[] {tag}); throw new InvalidScriptException(msg); } catch (InvocationTargetException ite) { Log.warn(ite); diff --git a/abbot/src/main/java/abbot/script/StepRunner.java b/abbot/src/main/java/abbot/script/StepRunner.java index 8203749..16832c2 100644 --- a/abbot/src/main/java/abbot/script/StepRunner.java +++ b/abbot/src/main/java/abbot/script/StepRunner.java @@ -9,7 +9,6 @@ import abbot.i18n.Strings; import abbot.util.AWTFixtureHelper; import abbot.util.EDTExceptionCatcher; -import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -207,8 +206,7 @@ public void run(Step step) throws Throwable { Log.debug("App tried to exit"); terminate(); } finally { - if (step instanceof Script - && (stopped() && terminateOnStop)) { + if (step instanceof Script && (stopped() && terminateOnStop)) { terminate(); } removeSecurityManager(); @@ -236,9 +234,10 @@ protected void clearErrors() { protected void checkFile(Script script) throws InvalidScriptException { var file = script.getFile(); if (!file.exists() && !file.getName().startsWith(Script.UNTITLED_FILE)) { - var msg = String.format( - "The script '%s' does not exist at the expected location '%s'", script.getFilename(), - file.getAbsolutePath()); + var msg = + String.format( + "The script '%s' does not exist at the expected location '%s'", + script.getFilename(), file.getAbsolutePath()); throw new InvalidScriptException(msg); } } diff --git a/abbot/src/main/java/abbot/tester/ComponentTester.java b/abbot/src/main/java/abbot/tester/ComponentTester.java index d1090b9..8a87b47 100644 --- a/abbot/src/main/java/abbot/tester/ComponentTester.java +++ b/abbot/src/main/java/abbot/tester/ComponentTester.java @@ -324,7 +324,7 @@ protected String deriveAccessibleTag(AccessibleContext context) { * be useful in a custom component if the method is supported. */ private static final String[] tagMethods = { - "getLabel", "getTitle", "getText", + "getLabel", "getTitle", "getText", }; public static String getTag(Component component) { @@ -347,7 +347,7 @@ public String deriveTag(Component comp) { for (String tagMethod : tagMethods) { // Don't use getText on text components if (((comp instanceof javax.swing.text.JTextComponent) - || (comp instanceof java.awt.TextComponent)) + || (comp instanceof java.awt.TextComponent)) && "getText".equals(tagMethod)) { continue; } @@ -474,8 +474,8 @@ public void actionSelectPopupMenuItem(Component invoker, String path) { actionSelectPopupMenuItem(invoker, invoker.getWidth() / 2, invoker.getHeight() / 2, path); } - public void actionSelectPopupMenuItem(Component invoker, ComponentLocation location, - String path) { + public void actionSelectPopupMenuItem( + Component invoker, ComponentLocation location, String path) { selectPopupMenuItem(invoker, location, path); waitForIdle(); } @@ -740,7 +740,7 @@ public boolean test() { } public String toString() { - return Strings.get("tester.Component.show_wait", new Object[]{identifier}); + return Strings.get("tester.Component.show_wait", new Object[] {identifier}); } }, componentDelay); @@ -763,7 +763,7 @@ public boolean test() { } public String toString() { - return Strings.get("tester.Component.show_wait", new Object[]{ref}); + return Strings.get("tester.Component.show_wait", new Object[] {ref}); } }, componentDelay); @@ -792,8 +792,8 @@ private Method[] getMethods(String prefix, Class returnType, boolean componen Class[] params = method.getParameterTypes(); if ((returnType == null || returnType.equals(method.getReturnType())) && ((params.length == 0 && !componentArgument) - || (params.length > 0 - && (Component.class.isAssignableFrom(params[0]) == componentArgument)))) { + || (params.length > 0 + && (Component.class.isAssignableFrom(params[0]) == componentArgument)))) { methods.add(method); names.add(name); } diff --git a/abbot/src/main/java/abbot/tester/JComboBoxTester.java b/abbot/src/main/java/abbot/tester/JComboBoxTester.java index d5f73ca..42c7880 100644 --- a/abbot/src/main/java/abbot/tester/JComboBoxTester.java +++ b/abbot/src/main/java/abbot/tester/JComboBoxTester.java @@ -90,7 +90,8 @@ public String getValueAsString(JComboBox combo, JList list, Object item, i // If the value is the default Object.toString method (which // returns @), try to find something better. if (value.startsWith(item.getClass().getName() + "@")) { - ListCellRenderer renderer = (ListCellRenderer) combo.getRenderer(); + ListCellRenderer renderer = + (ListCellRenderer) combo.getRenderer(); Component c = renderer.getListCellRendererComponent(list, item, index, true, true); if (c instanceof javax.swing.JLabel) { return ((javax.swing.JLabel) c).getText(); @@ -130,6 +131,6 @@ public void actionSelectItem(Component comp, String item) { } contents.append("]"); throw new ActionFailedException( - Strings.get("tester.JComboBox.item_not_found", new Object[]{item, contents.toString()})); + Strings.get("tester.JComboBox.item_not_found", new Object[] {item, contents.toString()})); } } diff --git a/abbot/src/main/java/abbot/tester/JListTester.java b/abbot/src/main/java/abbot/tester/JListTester.java index f47e2a4..83d68e0 100644 --- a/abbot/src/main/java/abbot/tester/JListTester.java +++ b/abbot/src/main/java/abbot/tester/JListTester.java @@ -37,9 +37,10 @@ public class JListTester extends JComponentTester { */ static String valueToString(JList list, int index) { Object value = list.getModel().getElementAt(index); - ListCellRenderer cellRenderer = (ListCellRenderer) list.getCellRenderer(); - Component renderedListComponent = cellRenderer - .getListCellRendererComponent(list, value, index, false, false); + ListCellRenderer cellRenderer = + (ListCellRenderer) list.getCellRenderer(); + Component renderedListComponent = + cellRenderer.getListCellRendererComponent(list, value, index, false, false); return convertToString(renderedListComponent, value); } @@ -47,13 +48,14 @@ static String valueToString(JList list, int index) { private static String convertToString(Component renderedListComponent, Object value) { return convertListValueIntoString(renderedListComponent) .filter(v -> !v.isEmpty() && !ArgumentParser.isDefaultToString(v)) - .orElseGet(() -> { - String string = ArgumentParser.toString(value); - if (Objects.equals(string, ArgumentParser.DEFAULT_TOSTRING)) { - return null; - } - return string; - }); + .orElseGet( + () -> { + String string = ArgumentParser.toString(value); + if (Objects.equals(string, ArgumentParser.DEFAULT_TOSTRING)) { + return null; + } + return string; + }); } private static Optional convertListValueIntoString(Component renderedListComponent) { @@ -123,7 +125,7 @@ public void actionSelectRow(JList list, JListLocation location) { int index = location.getIndex(list); if (index < 0 || index >= list.getModel().getSize()) { - String msg = Strings.get("tester.JList.invalid_index", new Object[]{index}); + String msg = Strings.get("tester.JList.invalid_index", new Object[] {index}); throw new ActionFailedException(msg); } diff --git a/abbot/src/main/java/abbot/tester/JTreeTester.java b/abbot/src/main/java/abbot/tester/JTreeTester.java index 70dfc5e..8746cac 100644 --- a/abbot/src/main/java/abbot/tester/JTreeTester.java +++ b/abbot/src/main/java/abbot/tester/JTreeTester.java @@ -39,8 +39,7 @@ public static boolean isLocationInExpandControl(JTree tree, int x, int y) { row = tree.getClosestRowForLocation(x, y); if (row != -1) { Rectangle rect = tree.getRowBounds(row); - if (row == tree.getRowCount() - 1 - && y >= rect.y + rect.height) { + if (row == tree.getRowCount() - 1 && y >= rect.y + rect.height) { return false; } // An approximation: use a square area to the left of the row @@ -160,7 +159,7 @@ public void actionSelectRow(Component component, ComponentLocation componentLoca if (componentLocation instanceof JTreeLocation treeLocation) { TreePath path = treeLocation.getPath((JTree) component); if (path == null) { - String msg = Strings.get("tester.JTree.path_not_found", new Object[]{componentLocation}); + String msg = Strings.get("tester.JTree.path_not_found", new Object[] {componentLocation}); throw new LocationUnavailableException(msg); } makeVisible(component, path); @@ -251,7 +250,7 @@ public boolean test() { @Override public String toString() { - return Strings.get("tester.Component.show_wait", new Object[]{path.toString()}); + return Strings.get("tester.Component.show_wait", new Object[] {path.toString()}); } }, componentDelay); @@ -298,8 +297,8 @@ public void actionToggleRow(Component component, ComponentLocation componentLoca // Alternatively, we can reflect into the UI and do a single click // on the appropriate expand location, but this is safer. if (tree.getToggleClickCount() != 0) { - actionClick(tree, componentLocation, InputEvent.BUTTON1_DOWN_MASK, - tree.getToggleClickCount()); + actionClick( + tree, componentLocation, InputEvent.BUTTON1_DOWN_MASK, tree.getToggleClickCount()); } else { // BasicTreeUI provides this method; punt if we can't find it if (!(tree.getUI() instanceof BasicTreeUI)) { diff --git a/abbot/src/main/java/abbot/tester/Robot.java b/abbot/src/main/java/abbot/tester/Robot.java index b4f3e69..3cb77ea 100644 --- a/abbot/src/main/java/abbot/tester/Robot.java +++ b/abbot/src/main/java/abbot/tester/Robot.java @@ -119,7 +119,7 @@ protected static final boolean useScreenMenuBar() { // property is read once at startup and ignored thereafter. return Platform.isOSX() && (Boolean.getBoolean("com.apple.macos.useScreenMenuBar") - || Boolean.getBoolean("apple.laf.useScreenMenuBar")); + || Boolean.getBoolean("apple.laf.useScreenMenuBar")); } /** @@ -395,7 +395,7 @@ public void run() { long start = System.currentTimeMillis(); while (!fw.focused) { if (System.currentTimeMillis() - start > componentDelay) { - String msg = Strings.get("tester.Robot.focus_failed", new Object[]{toString(comp)}); + String msg = Strings.get("tester.Robot.focus_failed", new Object[] {toString(comp)}); throw new ActionFailedException(msg); } sleep(); @@ -528,8 +528,7 @@ public void delay(int ms) { private static final Runnable EMPTY_RUNNABLE = new Runnable() { @Override - public void run() { - } + public void run() {} }; /** @@ -542,9 +541,7 @@ protected boolean queueBlocked() { } protected boolean postInvocationEvent(EventQueue eq, Toolkit toolkit, long timeout) { - class RobotIdleLock { - - } + class RobotIdleLock {} Object lock = new RobotIdleLock(); synchronized (lock) { eq.postEvent(new InvocationEvent(toolkit, EMPTY_RUNNABLE, lock, true)); @@ -1101,13 +1098,14 @@ public final void click(Component comp, int x, int y, int mask) { } public void click(Component comp, int x, int y, int mask, int count) { - var message = "Click at (" - + x - + "," - + y - + ") on " - + toString(comp) - + (count > 1 ? (" count=" + count) : ""); + var message = + "Click at (" + + x + + "," + + y + + ") on " + + toString(comp) + + (count > 1 ? (" count=" + count) : ""); Log.debug(message); int keyModifiers = mask & ~AWTConstants.BUTTON_DOWN_MASK; @@ -1148,12 +1146,12 @@ public void selectAWTMenuItemByLabel(Frame frame, String path) { public void selectAWTMenuItem(Frame frame, String path) { MenuBar mb = frame.getMenuBar(); if (mb == null) { - String msg = Strings.get("tester.Robot.no_menu_bar", new Object[]{toString(frame)}); + String msg = Strings.get("tester.Robot.no_menu_bar", new Object[] {toString(frame)}); throw new ActionFailedException(msg); } MenuItem[] items = AWT.findAWTMenuItems(frame, path); if (items.length == 0) { - String msg = Strings.get("tester.Robot.no_menu_item", new Object[]{path, toString(frame)}); + String msg = Strings.get("tester.Robot.no_menu_item", new Object[] {path, toString(frame)}); throw new ActionFailedException(msg); } if (items.length > 1) { @@ -1185,18 +1183,17 @@ public void selectAWTPopupMenuItem(Component invoker, String path) { return; } else if (items.length == 0) { String msg = - Strings.get("tester.Robot.no_popup_menu_item", new Object[]{path, toString(invoker)}); + Strings.get("tester.Robot.no_popup_menu_item", new Object[] {path, toString(invoker)}); throw new ActionFailedException(msg); } - String msg = Strings.get("tester.Robot.multiple_menu_items", new Object[]{path}); + String msg = Strings.get("tester.Robot.multiple_menu_items", new Object[] {path}); throw new ActionFailedException(msg); } finally { AWT.dismissAWTPopup(); } } - protected void fireAccessibleAction( - Component context, AccessibleAction action, String name) { + protected void fireAccessibleAction(Component context, AccessibleAction action, String name) { if (action != null && action.getAccessibleActionCount() > 0) { invokeLater( context, @@ -1207,7 +1204,7 @@ public void run() { } }); } else { - String msg = Strings.get("tester.Robot.no_accessible_action", new String[]{name}); + String msg = Strings.get("tester.Robot.no_accessible_action", new String[] {name}); throw new ActionFailedException(msg); } } @@ -1596,7 +1593,7 @@ public void run() { (Boolean) Toolkit.class .getMethod("isFrameStateSupported", int.class) - .invoke(toolkit, new Object[]{new Integer(MAXIMIZED_BOTH)}); + .invoke(toolkit, new Object[] {new Integer(MAXIMIZED_BOTH)}); if (b.booleanValue() && !serviceMode) { Frame.class .getMethod("setExtendedState", int.class) @@ -1892,8 +1889,7 @@ public static String getDescriptiveName(Component c) { if ((name = getTitle(c)) == null) { if ((name = getText(c)) == null) { if ((name = getLabel(c)) == null) { - if ((name = getIconName(c)) == null) { - } + if ((name = getIconName(c)) == null) {} } } } diff --git a/abbot/src/main/java/abbot/util/AWT.java b/abbot/src/main/java/abbot/util/AWT.java index c620c69..dfe7657 100644 --- a/abbot/src/main/java/abbot/util/AWT.java +++ b/abbot/src/main/java/abbot/util/AWT.java @@ -917,7 +917,9 @@ private static String getModifiers(int flags, boolean isMouse) { // On a mac, ALT+BUTTON1 means BUTTON2; META+BUTTON1 means BUTTON3 int macModifiers = - getDefaultToolkit().getMenuShortcutKeyMaskEx() | InputEvent.ALT_DOWN_MASK | InputEvent.META_DOWN_MASK; + getDefaultToolkit().getMenuShortcutKeyMaskEx() + | InputEvent.ALT_DOWN_MASK + | InputEvent.META_DOWN_MASK; boolean isMacButton = isMouse && Platform.isMacintosh() && (flags & macModifiers) != 0; String mods = ""; String or = ""; @@ -996,8 +998,12 @@ public static int getKeyCode(String code) { public static boolean isModifier(int keycode) { return switch (keycode) { - case KeyEvent.VK_META, KeyEvent.VK_ALT, KeyEvent.VK_ALT_GRAPH, KeyEvent.VK_CONTROL, - KeyEvent.VK_SHIFT -> true; + case KeyEvent.VK_META, + KeyEvent.VK_ALT, + KeyEvent.VK_ALT_GRAPH, + KeyEvent.VK_CONTROL, + KeyEvent.VK_SHIFT -> + true; default -> false; }; } diff --git a/abbot/src/main/java/abbot/util/AbbotTimerTask.java b/abbot/src/main/java/abbot/util/AbbotTimerTask.java index 0b7e1e8..8a78828 100644 --- a/abbot/src/main/java/abbot/util/AbbotTimerTask.java +++ b/abbot/src/main/java/abbot/util/AbbotTimerTask.java @@ -44,8 +44,7 @@ public abstract class AbbotTimerTask extends TimerTask { /** * Creates a new timer task. */ - protected AbbotTimerTask() { - } + protected AbbotTimerTask() {} /** * The action to be performed by this timer task. @@ -65,5 +64,4 @@ public boolean cancel() { public boolean isCanceled() { return state == CANCELLED; } - } diff --git a/abbot/src/main/java/abbot/util/EventDispatchExceptionHandler.java b/abbot/src/main/java/abbot/util/EventDispatchExceptionHandler.java index 421d98d..81b77a1 100644 --- a/abbot/src/main/java/abbot/util/EventDispatchExceptionHandler.java +++ b/abbot/src/main/java/abbot/util/EventDispatchExceptionHandler.java @@ -89,8 +89,7 @@ public void run() { // Does nothing but wait for the previous invocation to finish AWT.invokeAndWait( new Runnable() { - public void run() { - } + public void run() {} }); System.setProperties(holder.properties); String oldHandler = System.getProperty(PROP_NAME); diff --git a/com.windowtester.junit5/pom.xml b/com.windowtester.junit5/pom.xml index b0f20c2..a400dab 100644 --- a/com.windowtester.junit5/pom.xml +++ b/com.windowtester.junit5/pom.xml @@ -6,7 +6,7 @@ io.github.r4fterman com.windowtester - 6.0.0-SNAPSHOT + 6.0.1-SNAPSHOT com.windowtester.junit5 @@ -32,4 +32,16 @@ junit-jupiter-api + + + + + dev.dimlight + shellcheck-maven-plugin + + true + + + + \ No newline at end of file diff --git a/com.windowtester.junit5/src/main/java/com/windowtester/junit5/SwingUIContext.java b/com.windowtester.junit5/src/main/java/com/windowtester/junit5/SwingUIContext.java index e967280..3708183 100644 --- a/com.windowtester.junit5/src/main/java/com/windowtester/junit5/SwingUIContext.java +++ b/com.windowtester.junit5/src/main/java/com/windowtester/junit5/SwingUIContext.java @@ -11,6 +11,4 @@ @Target({FIELD, PARAMETER}) @Retention(RUNTIME) @Documented -public @interface SwingUIContext { - -} +public @interface SwingUIContext {} diff --git a/com.windowtester.junit5/src/main/java/com/windowtester/junit5/UIParent.java b/com.windowtester.junit5/src/main/java/com/windowtester/junit5/UIParent.java index 1b337b8..6868d7e 100644 --- a/com.windowtester.junit5/src/main/java/com/windowtester/junit5/UIParent.java +++ b/com.windowtester.junit5/src/main/java/com/windowtester/junit5/UIParent.java @@ -15,6 +15,4 @@ @Target({FIELD, METHOD}) @Retention(RUNTIME) @Documented -public @interface UIParent { - -} +public @interface UIParent {} diff --git a/com.windowtester.junit5/src/main/java/com/windowtester/junit5/resolver/AnnotationResolver.java b/com.windowtester.junit5/src/main/java/com/windowtester/junit5/resolver/AnnotationResolver.java index e1c0f0a..510ee9b 100644 --- a/com.windowtester.junit5/src/main/java/com/windowtester/junit5/resolver/AnnotationResolver.java +++ b/com.windowtester.junit5/src/main/java/com/windowtester/junit5/resolver/AnnotationResolver.java @@ -22,14 +22,16 @@ public AnnotationResolver(ExtensionContext context) { } public Optional tryToFindAnnotatedField(Class annotationType) { - var annotatedFieldList = context.getTestInstance() - .map(testInstance -> AnnotationSupport.findAnnotatedFields(testInstance.getClass(), - annotationType - ).stream() - .map(field -> fieldToFieldInfo(testInstance, field, annotationType)) - .toList() - ) - .orElse(Collections.emptyList()); + var annotatedFieldList = + context + .getTestInstance() + .map( + testInstance -> + AnnotationSupport.findAnnotatedFields(testInstance.getClass(), annotationType) + .stream() + .map(field -> fieldToFieldInfo(testInstance, field, annotationType)) + .toList()) + .orElse(Collections.emptyList()); if (annotatedFieldList.size() > 1) { throw new JUnitException("Only one instance must be annotated with @UIUnderTest."); @@ -43,12 +45,10 @@ public Optional tryToFindAnnotatedField(Class a } private FieldInfo fieldToFieldInfo( - Object testInstance, - Field field, - Class annotationType) { + Object testInstance, Field field, Class annotationType) { try { var title = getTitle(field, annotationType); - var dimension = getDimension(field, annotationType); + var dimension = getDimension(field, annotationType); field.setAccessible(true); var value = field.get(testInstance); if (value == null) { @@ -59,9 +59,10 @@ private FieldInfo fieldToFieldInfo( } return new FieldInfo(title, dimension, value); } catch (IllegalAccessException e) { - var message = String.format( - "Unable to access annotation field [%s]. Make sure it has public accessibility.", - field.getName()); + var message = + String.format( + "Unable to access annotation field [%s]. Make sure it has public accessibility.", + field.getName()); throw new JUnitException(message, e); } } @@ -81,5 +82,4 @@ private String getTitle(Field field, Class annotationType) } return ""; } - } diff --git a/com.windowtester.junit5/src/main/java/com/windowtester/junit5/resolver/FieldInfo.java b/com.windowtester.junit5/src/main/java/com/windowtester/junit5/resolver/FieldInfo.java index 7f4a5dd..80f6789 100644 --- a/com.windowtester.junit5/src/main/java/com/windowtester/junit5/resolver/FieldInfo.java +++ b/com.windowtester.junit5/src/main/java/com/windowtester/junit5/resolver/FieldInfo.java @@ -14,5 +14,4 @@ public boolean equals(Object o) { } return false; } - } diff --git a/com.windowtester.junit5/src/main/java/com/windowtester/junit5/resolver/SwingUIContextParameterResolver.java b/com.windowtester.junit5/src/main/java/com/windowtester/junit5/resolver/SwingUIContextParameterResolver.java index d6a6397..d2253e0 100644 --- a/com.windowtester.junit5/src/main/java/com/windowtester/junit5/resolver/SwingUIContextParameterResolver.java +++ b/com.windowtester.junit5/src/main/java/com/windowtester/junit5/resolver/SwingUIContextParameterResolver.java @@ -10,16 +10,15 @@ public class SwingUIContextParameterResolver implements ParameterResolver { @Override - public boolean supportsParameter(ParameterContext parameterContext, - ExtensionContext extensionContext) { + public boolean supportsParameter( + ParameterContext parameterContext, ExtensionContext extensionContext) { return parameterContext.getParameter().isAnnotationPresent(SwingUIContext.class); } @Override - public Object resolveParameter(ParameterContext parameterContext, - ExtensionContext extensionContext) { - return getStorage(extensionContext) - .saveUIContext(UIContextSwingFactory.createContext()); + public Object resolveParameter( + ParameterContext parameterContext, ExtensionContext extensionContext) { + return getStorage(extensionContext).saveUIContext(UIContextSwingFactory.createContext()); } private WindowtesterExecutionStorage getStorage(ExtensionContext extensionContext) { diff --git a/com.windowtester.junit5/src/test/java/context2/testcases/DialogSampleTest.java b/com.windowtester.junit5/src/test/java/context2/testcases/DialogSampleTest.java index bad324b..beea619 100644 --- a/com.windowtester.junit5/src/test/java/context2/testcases/DialogSampleTest.java +++ b/com.windowtester.junit5/src/test/java/context2/testcases/DialogSampleTest.java @@ -26,12 +26,11 @@ @ExtendWith(WindowtesterExtension.class) class DialogSampleTest { - @UIUnderTest - private DialogSample dialog; + @UIUnderTest private DialogSample dialog; @BeforeEach void setUp() { - dialog = new DialogSample(new JFrame("Question"), ""); + dialog = new DialogSample(new JFrame("Question"), ""); } @Test diff --git a/com.windowtester.junit5/src/test/java/context2/testcases/JComboBoxTest.java b/com.windowtester.junit5/src/test/java/context2/testcases/JComboBoxTest.java index bce66e4..9407198 100644 --- a/com.windowtester.junit5/src/test/java/context2/testcases/JComboBoxTest.java +++ b/com.windowtester.junit5/src/test/java/context2/testcases/JComboBoxTest.java @@ -40,15 +40,17 @@ class JComboBoxTest { void testComboClicks(@SwingUIContext IUIContext ui) throws Exception { ui.wait(new WindowShowingCondition("Swing Combo Boxes"), 1_000); - IWidgetLocator locator = ui.click(new JComboBoxLocator("Cat", new - SwingWidgetLocator(Box.class, 0, new - SwingWidgetLocator(ComboBoxes.class)))); + IWidgetLocator locator = + ui.click( + new JComboBoxLocator( + "Cat", + new SwingWidgetLocator(Box.class, 0, new SwingWidgetLocator(ComboBoxes.class)))); JComboBox cBox = (JComboBox) ((IWidgetReference) locator).getWidget(); assertEquals("Cat", cBox.getSelectedItem()); - JComboBoxLocator comboBoxLocator = new JComboBoxLocator("Rabbit", new - NamedWidgetLocator("pets")); + JComboBoxLocator comboBoxLocator = + new JComboBoxLocator("Rabbit", new NamedWidgetLocator("pets")); ui.assertThat(comboBoxLocator.isEnabled()); @@ -56,9 +58,14 @@ void testComboClicks(@SwingUIContext IUIContext ui) throws Exception { assertEquals("Rabbit", cBox.getSelectedItem()); - locator = ui.click(new JComboBoxLocator("yellow", new - com.windowtester.runtime.swing.SwingWidgetLocator(javax.swing.Box.class, 1, new - com.windowtester.runtime.swing.SwingWidgetLocator(ComboBoxes.class)))); + locator = + ui.click( + new JComboBoxLocator( + "yellow", + new com.windowtester.runtime.swing.SwingWidgetLocator( + javax.swing.Box.class, + 1, + new com.windowtester.runtime.swing.SwingWidgetLocator(ComboBoxes.class)))); cBox = (JComboBox) ((IWidgetReference) locator).getWidget(); assertEquals("yellow", cBox.getSelectedItem()); } @@ -80,7 +87,7 @@ void testComboEnterTextFails(@SwingUIContext IUIContext ui) throws Exception { IWidgetLocator locator = ui.click(colorsComboBoxLocator); JComboBox cBox = (JComboBox) ((IWidgetReference) locator).getWidget(); - ((JTextField)cBox.getEditor().getEditorComponent()).setText(""); + ((JTextField) cBox.getEditor().getEditorComponent()).setText(""); ui.enterText("pink\n"); diff --git a/com.windowtester.junit5/src/test/java/context2/testcases/JListTest.java b/com.windowtester.junit5/src/test/java/context2/testcases/JListTest.java index 16d63ec..53ca9f1 100644 --- a/com.windowtester.junit5/src/test/java/context2/testcases/JListTest.java +++ b/com.windowtester.junit5/src/test/java/context2/testcases/JListTest.java @@ -102,8 +102,7 @@ void testCtrlClicks(@SwingUIContext IUIContext ui) throws Exception { "seven", new SwingWidgetLocator( JViewport.class, - new SwingWidgetLocator( - JScrollPane.class, 1, new SwingWidgetLocator(Box.class)))), + new SwingWidgetLocator(JScrollPane.class, 1, new SwingWidgetLocator(Box.class)))), InputEvent.BUTTON1_DOWN_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()); IWidgetLocator locator = diff --git a/com.windowtester.junit5/src/test/java/context2/testcases/JTableTest.java b/com.windowtester.junit5/src/test/java/context2/testcases/JTableTest.java index fa0c45a..f996e17 100644 --- a/com.windowtester.junit5/src/test/java/context2/testcases/JTableTest.java +++ b/com.windowtester.junit5/src/test/java/context2/testcases/JTableTest.java @@ -54,11 +54,9 @@ void selectConsecutiveTableRows(@SwingUIContext IUIContext ui) throws WidgetSear var table00 = selectTableItem(new Point(0, 0), ui); assertEquals(1, table00.getSelectedRowCount()); - var table20 = selectTableItem( - new Point(2, 0), - InputEvent.BUTTON1_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK, - ui - ); + var table20 = + selectTableItem( + new Point(2, 0), InputEvent.BUTTON1_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK, ui); assertEquals(3, table20.getSelectedRowCount()); ui.assertThat(new JTableItemLocator(new Point(2, 0)).isSelected()); @@ -68,14 +66,13 @@ void selectConsecutiveTableRows(@SwingUIContext IUIContext ui) throws WidgetSear @Test void testCtrlClicks(@SwingUIContext IUIContext ui) throws WidgetSearchException { - var table = selectTableItem(new Point(0,0), ui); + var table = selectTableItem(new Point(0, 0), ui); assertEquals(1, table.getSelectedRowCount()); selectTableItem( - new Point(2,0), + new Point(2, 0), InputEvent.BUTTON1_DOWN_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), - ui - ); + ui); assertEquals(2, table.getSelectedRowCount()); ui.assertThat(new JTableItemLocator(new Point(2, 0)).isSelected()); @@ -85,7 +82,7 @@ void testCtrlClicks(@SwingUIContext IUIContext ui) throws WidgetSearchException @Test void testTableRowClicks(@SwingUIContext IUIContext ui) throws WidgetSearchException { - var table = selectTableItem(new Point(0,1), ui); + var table = selectTableItem(new Point(0, 1), ui); var model = table.getModel(); assertEquals("two", model.getValueAt(table.getSelectedRow(), table.getSelectedColumn())); diff --git a/com.windowtester.junit5/src/test/java/context2/testcases/JTableTest2.java b/com.windowtester.junit5/src/test/java/context2/testcases/JTableTest2.java index 4d139e6..d0f5def 100644 --- a/com.windowtester.junit5/src/test/java/context2/testcases/JTableTest2.java +++ b/com.windowtester.junit5/src/test/java/context2/testcases/JTableTest2.java @@ -29,13 +29,12 @@ @ExtendWith(WindowtesterExtension.class) class JTableTest2 { - @UIUnderTest - private SimpleTable panel = new SimpleTable(); + @UIUnderTest private SimpleTable panel = new SimpleTable(); @Test void testDoubleClicks(@SwingUIContext IUIContext ui) throws Exception { - IWidgetReference locator = (IWidgetReference) ui.click(2, - new JTableItemLocator(new Point(1, 0))); + IWidgetReference locator = + (IWidgetReference) ui.click(2, new JTableItemLocator(new Point(1, 0))); JTable table = (JTable) locator.getWidget(); TableModel model = table.getModel(); @@ -52,6 +51,5 @@ void testContextMenuSelection(@SwingUIContext IUIContext ui) throws Exception { ui.contextClick(new JTableItemLocator(new Point(2, 1)), new JMenuItemLocator("choice3")); ui.contextClick(new JTableItemLocator(new Point(0, 2)), new JMenuItemLocator("choice1")); - } } diff --git a/com.windowtester.junit5/src/test/java/context2/testcases/JTreeTest.java b/com.windowtester.junit5/src/test/java/context2/testcases/JTreeTest.java index 779b1b8..e7339de 100644 --- a/com.windowtester.junit5/src/test/java/context2/testcases/JTreeTest.java +++ b/com.windowtester.junit5/src/test/java/context2/testcases/JTreeTest.java @@ -34,8 +34,7 @@ @ExtendWith(WindowtesterExtension.class) class JTreeTest { - @UIUnderTest - private SwingTree panel; + @UIUnderTest private SwingTree panel; @BeforeEach void setUp() { @@ -46,17 +45,13 @@ void setUp() { void testTreeSelections(@SwingUIContext IUIContext ui) throws WidgetSearchException { ui.wait(new WindowShowingCondition("Swing Tree Example"), 1_000); - var firstClickTree = doTreeClick( - 1, - "Root/Parent1/Child10/grandChild102", - "tree1", - InputEvent.BUTTON1_DOWN_MASK, - ui - ); + var firstClickTree = + doTreeClick( + 1, "Root/Parent1/Child10/grandChild102", "tree1", InputEvent.BUTTON1_DOWN_MASK, ui); assertEquals(1, firstClickTree.getSelectionRows().length); - assertEquals("grandChild102", - firstClickTree.getSelectionPath().getLastPathComponent().toString()); + assertEquals( + "grandChild102", firstClickTree.getSelectionPath().getLastPathComponent().toString()); var secondClickTree = doTreeClick(1, "Root/Parent3/Child30", "tree1", ui); @@ -68,36 +63,25 @@ void testTreeSelections(@SwingUIContext IUIContext ui) throws WidgetSearchExcept void testTreeShiftSelections(@SwingUIContext IUIContext ui) throws Exception { ui.wait(new WindowShowingCondition("Swing Tree Example"), 1_000); - var firstClickTree = doTreeClick( - 1, - "Root/Item 0/Node 01", - "tree2", - ui); + var firstClickTree = doTreeClick(1, "Root/Item 0/Node 01", "tree2", ui); doTreeClick( 1, "Root/Item 1/Node 10", "tree2", InputEvent.BUTTON1_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK, - ui - ); + ui); assertEquals(3, firstClickTree.getSelectionPaths().length); - var tree = doTreeClick( - 1, - "Root/Item 0/Node 01", - "tree2", - ui - ); + var tree = doTreeClick(1, "Root/Item 0/Node 01", "tree2", ui); doTreeClick( 1, "Root/Item 1/Node 10", "tree2", InputEvent.BUTTON1_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK, - ui - ); + ui); assertEquals(3, tree.getSelectionPaths().length); } @@ -107,21 +91,15 @@ void testTreeCtrlSelections(@SwingUIContext IUIContext ui) throws WidgetSearchEx ui.wait(new WindowShowingCondition("Swing Tree Example"), 1_000); // test ctrl clicks - doTreeClick( - 1, - "Root/Parent1/Child10/grandChild100", - "tree1", - InputEvent.BUTTON1_DOWN_MASK, - ui - ); + doTreeClick(1, "Root/Parent1/Child10/grandChild100", "tree1", InputEvent.BUTTON1_DOWN_MASK, ui); - var secondClickTree = doTreeClick( - 1, - "Root/Parent1/Child10/grandChild102", - "tree1", - InputEvent.BUTTON1_DOWN_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), - ui - ); + var secondClickTree = + doTreeClick( + 1, + "Root/Parent1/Child10/grandChild102", + "tree1", + InputEvent.BUTTON1_DOWN_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(), + ui); assertEquals(2, secondClickTree.getSelectionPaths().length); } @@ -132,17 +110,13 @@ void testContextMenuSelection(@SwingUIContext IUIContext ui) throws WidgetSearch assertFalse(panel.isChoice1()); ui.contextClick( - new JTreeItemLocator("Root/Item 1/Node 11", "tree2"), - new JMenuItemLocator("choice1") - ); + new JTreeItemLocator("Root/Item 1/Node 11", "tree2"), new JMenuItemLocator("choice1")); assertTrue(panel.isChoice1()); assertFalse(panel.isChoice2()); ui.contextClick( - new JTreeItemLocator("Root/Item 2/Node 21", "tree2"), - new JMenuItemLocator("choice2") - ); + new JTreeItemLocator("Root/Item 2/Node 21", "tree2"), new JMenuItemLocator("choice2")); assertTrue(panel.isChoice2()); } diff --git a/com.windowtester.junit5/src/test/java/context2/testcases/NamedListTest.java b/com.windowtester.junit5/src/test/java/context2/testcases/NamedListTest.java index d9a00ff..d6d736f 100644 --- a/com.windowtester.junit5/src/test/java/context2/testcases/NamedListTest.java +++ b/com.windowtester.junit5/src/test/java/context2/testcases/NamedListTest.java @@ -30,31 +30,31 @@ import swing.samples.SwingList; @ExtendWith(WindowtesterExtension.class) - class NamedListTest { +class NamedListTest { @UIUnderTest(title = "Swing List Demo") private SwingList panel = new SwingList(); @Test - void testNamedLists(@SwingUIContext IUIContext ui) throws WidgetSearchException { + void testNamedLists(@SwingUIContext IUIContext ui) throws WidgetSearchException { ui.wait(new WindowShowingCondition("Swing List Demo"), 1_000); // named locator - IWidgetLocator locator = ui.click(new JListLocator("one", new NamedWidgetLocator("list1"))); + IWidgetLocator locator = ui.click(new JListLocator("one", new NamedWidgetLocator("list1"))); JList jlist = (JList) ((IWidgetReference) locator).getWidget(); - assertContainsExactly(jlist.getSelectedValues(), new String[]{"one"}); + assertContainsExactly(jlist.getSelectedValues(), new String[] {"one"}); locator = ui.click(new JListLocator("four", new NamedWidgetLocator("list2"))); jlist = (JList) ((IWidgetReference) locator).getWidget(); - assertContainsExactly(jlist.getSelectedValues(), new String[]{"four"}); + assertContainsExactly(jlist.getSelectedValues(), new String[] {"four"}); locator = ui.click(new JListLocator("seven", new NamedWidgetLocator("list3"))); jlist = (JList) ((IWidgetReference) locator).getWidget(); - assertContainsExactly(jlist.getSelectedValues(), new String[]{"seven"}); + assertContainsExactly(jlist.getSelectedValues(), new String[] {"seven"}); locator = ui.click(new JListLocator("five", new NamedWidgetLocator("list1"))); jlist = (JList) ((IWidgetReference) locator).getWidget(); - assertContainsExactly(jlist.getSelectedValues(), new String[]{"five"}); + assertContainsExactly(jlist.getSelectedValues(), new String[] {"five"}); } //////////////////////////////////////////////////////////////////////// diff --git a/com.windowtester.junit5/src/test/java/context2/testcases/NamedWidgetLocatorTest.java b/com.windowtester.junit5/src/test/java/context2/testcases/NamedWidgetLocatorTest.java index a36c8a2..f3e22d2 100644 --- a/com.windowtester.junit5/src/test/java/context2/testcases/NamedWidgetLocatorTest.java +++ b/com.windowtester.junit5/src/test/java/context2/testcases/NamedWidgetLocatorTest.java @@ -44,6 +44,5 @@ void testTextEntry(@SwingUIContext IUIContext ui) throws Exception { ui.click(new JButtonLocator("Set address")); ui.click(new NamedWidgetLocator("clear")); - } } diff --git a/com.windowtester.junit5/src/test/java/context2/testcases/SwingMenuTest.java b/com.windowtester.junit5/src/test/java/context2/testcases/SwingMenuTest.java index 4da3b4e..a8629d7 100644 --- a/com.windowtester.junit5/src/test/java/context2/testcases/SwingMenuTest.java +++ b/com.windowtester.junit5/src/test/java/context2/testcases/SwingMenuTest.java @@ -34,8 +34,7 @@ @ExtendWith(WindowtesterExtension.class) class SwingMenuTest { - @UIUnderTest - private SwingMenus panel = new SwingMenus("Swing Menus Example"); + @UIUnderTest private SwingMenus panel = new SwingMenus("Swing Menus Example"); @Test void testSelection(@SwingUIContext IUIContext ui) throws Exception { @@ -54,19 +53,20 @@ void testSelection(@SwingUIContext IUIContext ui) throws Exception { menuItem.setEnabled(true); ui.assertThat(new JMenuItemLocator("parent/child 1").isEnabled()); - JRadioButtonMenuItemLocator radioButtonMenuItemLocator = new - JRadioButtonMenuItemLocator("parent/child 2"); + JRadioButtonMenuItemLocator radioButtonMenuItemLocator = + new JRadioButtonMenuItemLocator("parent/child 2"); ui.assertThat(radioButtonMenuItemLocator.isEnabled(false)); locator = ui.find(radioButtonMenuItemLocator); - JRadioButtonMenuItem radioButtonMenuItem = (JRadioButtonMenuItem) ((IWidgetReference) locator).getWidget(); + JRadioButtonMenuItem radioButtonMenuItem = + (JRadioButtonMenuItem) ((IWidgetReference) locator).getWidget(); radioButtonMenuItem.setEnabled(true); ui.assertThat(radioButtonMenuItemLocator.isEnabled()); ui.click(radioButtonMenuItemLocator); ui.assertThat(radioButtonMenuItemLocator.isSelected()); - JCheckBoxMenuItemLocator checkBoxMenuItemLocator = new - JCheckBoxMenuItemLocator("parent/child 3"); + JCheckBoxMenuItemLocator checkBoxMenuItemLocator = + new JCheckBoxMenuItemLocator("parent/child 3"); ui.assertThat(checkBoxMenuItemLocator.isEnabled()); locator = ui.click(checkBoxMenuItemLocator); @@ -108,7 +108,7 @@ void testFailedSelections(@SwingUIContext IUIContext ui) throws Exception { ui.click(new JMenuItemLocator("child 2/nonexistent")); fail("should have thrown CME ex"); } catch (WidgetSearchException e) { - //pass + // pass } // //2 @@ -116,16 +116,15 @@ void testFailedSelections(@SwingUIContext IUIContext ui) throws Exception { ui.click(new JMenuItemLocator("bogus")); fail("should have thrown CME ex"); } catch (WidgetSearchException e) { - //pass + // pass } - //3 + // 3 try { ui.click(new JMenuItemLocator("bogus/really")); fail("should have thrown CME ex"); } catch (WidgetSearchException e) { - //pass + // pass } - } } diff --git a/com.windowtester.junit5/src/test/java/context2/testcases/SwingTextTest.java b/com.windowtester.junit5/src/test/java/context2/testcases/SwingTextTest.java index 3347a15..a760b27 100644 --- a/com.windowtester.junit5/src/test/java/context2/testcases/SwingTextTest.java +++ b/com.windowtester.junit5/src/test/java/context2/testcases/SwingTextTest.java @@ -47,15 +47,15 @@ void testTextEntry(@SwingUIContext IUIContext ui) throws Exception { ui.assertThat(new LabeledTextLocator("Name").hasText("Jane Smith")); // context clicks - ui.contextClick(new JTextComponentLocator(JTextField.class, 0, null), new - JMenuItemLocator("choice2")); + ui.contextClick( + new JTextComponentLocator(JTextField.class, 0, null), new JMenuItemLocator("choice2")); - ui.contextClick(new JTextComponentLocator(JTextField.class, 0, null), new - JMenuItemLocator("choice1")); + ui.contextClick( + new JTextComponentLocator(JTextField.class, 0, null), new JMenuItemLocator("choice1")); try { - ui.contextClick(new JTextComponentLocator(JTextField.class, 0, null), new JMenuItemLocator( - "bogus")); + ui.contextClick( + new JTextComponentLocator(JTextField.class, 0, null), new JMenuItemLocator("bogus")); fail("should have thrown a CNF exception"); } catch (ActionFailedException e) { fail("should not have thrown " + e); diff --git a/com.windowtester.junit5/src/test/java/context2/testcases/SwingTreeTest.java b/com.windowtester.junit5/src/test/java/context2/testcases/SwingTreeTest.java index d1cc184..c925335 100644 --- a/com.windowtester.junit5/src/test/java/context2/testcases/SwingTreeTest.java +++ b/com.windowtester.junit5/src/test/java/context2/testcases/SwingTreeTest.java @@ -33,31 +33,45 @@ class SwingTreeTest { void testMain(@SwingUIContext IUIContext ui) throws Exception { ui.wait(new WindowShowingCondition("Swing Tree Demo"), 1_000); - JTreeItemLocator treeItemLocator = new JTreeItemLocator("Root/Parent4", new - SwingWidgetLocator( - JViewport.class, new SwingWidgetLocator(JScrollPane.class, "scrollPane1"))); + JTreeItemLocator treeItemLocator = + new JTreeItemLocator( + "Root/Parent4", + new SwingWidgetLocator( + JViewport.class, new SwingWidgetLocator(JScrollPane.class, "scrollPane1"))); ui.click(2, treeItemLocator); ui.assertThat(treeItemLocator.isSelected()); - ui.click(2, new JTreeItemLocator("Root/Parent4/Child41", - new SwingWidgetLocator(JViewport.class, new SwingWidgetLocator( - JScrollPane.class, "scrollPane1")))); + ui.click( + 2, + new JTreeItemLocator( + "Root/Parent4/Child41", + new SwingWidgetLocator( + JViewport.class, new SwingWidgetLocator(JScrollPane.class, "scrollPane1")))); - JTreeItemLocator locator2 = new JTreeItemLocator("Root/Parent4/Child41/grandChild411", - new SwingWidgetLocator(JViewport.class, new SwingWidgetLocator( - JScrollPane.class, "scrollPane1"))); + JTreeItemLocator locator2 = + new JTreeItemLocator( + "Root/Parent4/Child41/grandChild411", + new SwingWidgetLocator( + JViewport.class, new SwingWidgetLocator(JScrollPane.class, "scrollPane1"))); ui.click(locator2); ui.assertThat(locator2.isSelected()); - ui.click(new JTreeItemLocator("Root/Item 4", new SwingWidgetLocator( - JViewport.class, new SwingWidgetLocator(JScrollPane.class, - "scrollPane2")))); - ui.click(2, new JTreeItemLocator("Root/Item 0", new SwingWidgetLocator( - JViewport.class, new SwingWidgetLocator(JScrollPane.class, - "scrollPane2")))); + ui.click( + new JTreeItemLocator( + "Root/Item 4", + new SwingWidgetLocator( + JViewport.class, new SwingWidgetLocator(JScrollPane.class, "scrollPane2")))); + ui.click( + 2, + new JTreeItemLocator( + "Root/Item 0", + new SwingWidgetLocator( + JViewport.class, new SwingWidgetLocator(JScrollPane.class, "scrollPane2")))); - JTreeItemLocator locator3 = new JTreeItemLocator("Root/Item 0/Node 01", new - SwingWidgetLocator( - JViewport.class, new SwingWidgetLocator(JScrollPane.class, "scrollPane2"))); + JTreeItemLocator locator3 = + new JTreeItemLocator( + "Root/Item 0/Node 01", + new SwingWidgetLocator( + JViewport.class, new SwingWidgetLocator(JScrollPane.class, "scrollPane2"))); ui.click(locator3); ui.assertThat(locator3.isSelected()); } diff --git a/com.windowtester.junit5/src/test/java/context2/testcases/SwingTreeTest2.java b/com.windowtester.junit5/src/test/java/context2/testcases/SwingTreeTest2.java index a532c92..ff029fe 100644 --- a/com.windowtester.junit5/src/test/java/context2/testcases/SwingTreeTest2.java +++ b/com.windowtester.junit5/src/test/java/context2/testcases/SwingTreeTest2.java @@ -29,45 +29,57 @@ @ExtendWith(WindowtesterExtension.class) class SwingTreeTest2 { - @UIUnderTest - private SwingTree panel = new SwingTree("Swing Tree Demo"); + @UIUnderTest private SwingTree panel = new SwingTree("Swing Tree Demo"); @Test void testMain(@SwingUIContext IUIContext ui) throws Exception { ui.wait(new WindowShowingCondition("Swing Tree Demo"), 1_000); - JTreeItemLocator treeItemLocator = new JTreeItemLocator("Root/Item 2", new - SwingWidgetLocator( - JViewport.class, new SwingWidgetLocator(JScrollPane.class, "scrollPane2"))); + JTreeItemLocator treeItemLocator = + new JTreeItemLocator( + "Root/Item 2", + new SwingWidgetLocator( + JViewport.class, new SwingWidgetLocator(JScrollPane.class, "scrollPane2"))); ui.click(2, treeItemLocator, InputEvent.BUTTON1_DOWN_MASK); - JTreeItemLocator treeItemLocator2 = new JTreeItemLocator("Root/Item 3", new - SwingWidgetLocator( - JViewport.class, new SwingWidgetLocator(JScrollPane.class, "scrollPane2"))); + JTreeItemLocator treeItemLocator2 = + new JTreeItemLocator( + "Root/Item 3", + new SwingWidgetLocator( + JViewport.class, new SwingWidgetLocator(JScrollPane.class, "scrollPane2"))); ui.click(1, treeItemLocator2, InputEvent.BUTTON1_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK); ui.assertThat(treeItemLocator2.isSelected()); ui.assertThat(treeItemLocator.isSelected()); - ui.click(2, new JTreeItemLocator("Root/Parent1", - new SwingWidgetLocator(JViewport.class, new SwingWidgetLocator( - JScrollPane.class, "scrollPane1"))), + ui.click( + 2, + new JTreeItemLocator( + "Root/Parent1", + new SwingWidgetLocator( + JViewport.class, new SwingWidgetLocator(JScrollPane.class, "scrollPane1"))), InputEvent.BUTTON1_DOWN_MASK); - JTreeItemLocator treeItemLocator3 = new JTreeItemLocator("Root/Parent1/Child10", - new SwingWidgetLocator(JViewport.class, new SwingWidgetLocator( - JScrollPane.class, "scrollPane1"))); + JTreeItemLocator treeItemLocator3 = + new JTreeItemLocator( + "Root/Parent1/Child10", + new SwingWidgetLocator( + JViewport.class, new SwingWidgetLocator(JScrollPane.class, "scrollPane1"))); ui.assertThat(treeItemLocator3.isVisible()); ui.click(2, treeItemLocator3, InputEvent.BUTTON1_DOWN_MASK); - JTreeItemLocator treeItemLocator4 = new - JTreeItemLocator("Root/Parent1/Child10/grandChild100", - new SwingWidgetLocator(JViewport.class, new SwingWidgetLocator( - JScrollPane.class, "scrollPane1"))); + JTreeItemLocator treeItemLocator4 = + new JTreeItemLocator( + "Root/Parent1/Child10/grandChild100", + new SwingWidgetLocator( + JViewport.class, new SwingWidgetLocator(JScrollPane.class, "scrollPane1"))); ui.assertThat(treeItemLocator4.isVisible()); ui.click(treeItemLocator4); - ui.click(1, new JTreeItemLocator("Root/Parent1/Child10/grandChild102", - new SwingWidgetLocator(JViewport.class, new SwingWidgetLocator( - JScrollPane.class, "scrollPane1"))), + ui.click( + 1, + new JTreeItemLocator( + "Root/Parent1/Child10/grandChild102", + new SwingWidgetLocator( + JViewport.class, new SwingWidgetLocator(JScrollPane.class, "scrollPane1"))), InputEvent.BUTTON1_DOWN_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()); ui.wait(new WindowDisposedCondition("Swing Tree Example")); } diff --git a/com.windowtester.junit5/src/test/java/context2/testcases/TreeDnDTest.java b/com.windowtester.junit5/src/test/java/context2/testcases/TreeDnDTest.java index 91b930a..6c028a1 100644 --- a/com.windowtester.junit5/src/test/java/context2/testcases/TreeDnDTest.java +++ b/com.windowtester.junit5/src/test/java/context2/testcases/TreeDnDTest.java @@ -25,12 +25,12 @@ @ExtendWith(WindowtesterExtension.class) class TreeDnDTest { - @UIUnderTest - private TreeDnD panel = new TreeDnD(); + @UIUnderTest private TreeDnD panel = new TreeDnD(); @Test void testTreeDnD(@SwingUIContext IUIContext ui) throws WidgetSearchException { - ui.click(new JTreeItemLocator("JTree/colors/blue", new NamedWidgetLocator(JTree.class, "tree1"))); + ui.click( + new JTreeItemLocator("JTree/colors/blue", new NamedWidgetLocator(JTree.class, "tree1"))); ui.dragTo(new JTreeItemLocator("JTree/sports", new NamedWidgetLocator(JTree.class, "tree2"))); ui.click(new JTreeItemLocator("JTree/food/hot dogs", new NamedWidgetLocator("tree2"))); diff --git a/com.windowtester.junit5/src/test/java/example/ArrowButtonTest.java b/com.windowtester.junit5/src/test/java/example/ArrowButtonTest.java index fc52a69..8fbb167 100644 --- a/com.windowtester.junit5/src/test/java/example/ArrowButtonTest.java +++ b/com.windowtester.junit5/src/test/java/example/ArrowButtonTest.java @@ -25,8 +25,7 @@ class ArrowButtonTest { private ArrowButton up; private ArrowButton down; - @UIUnderTest - private JPanel panel = createPanel(); + @UIUnderTest private JPanel panel = createPanel(); @BeforeEach protected void setUp() { @@ -85,5 +84,4 @@ private JPanel createPanel() { pane.add(left); return pane; } - } diff --git a/com.windowtester.junit5/src/test/java/example/LabeledListTest.java b/com.windowtester.junit5/src/test/java/example/LabeledListTest.java index 24c7206..2684dce 100644 --- a/com.windowtester.junit5/src/test/java/example/LabeledListTest.java +++ b/com.windowtester.junit5/src/test/java/example/LabeledListTest.java @@ -24,8 +24,7 @@ @ExtendWith(WindowtesterExtension.class) class LabeledListTest { - @UIUnderTest - private LabeledList labeledList; + @UIUnderTest private LabeledList labeledList; private ComponentFinder finder; @BeforeEach @@ -49,10 +48,9 @@ void testLabelChangedOnSelectionChange() throws Throwable { // how you can put more conditions into the Matcher. JLabel label = (JLabel) - finder - .find( - labeledList, - c -> c.getClass().equals(JLabel.class) && c.getParent() == labeledList); + finder.find( + labeledList, + c -> c.getClass().equals(JLabel.class) && c.getParent() == labeledList); JListTester tester = new JListTester(); @@ -60,12 +58,10 @@ void testLabelChangedOnSelectionChange() throws Throwable { tester.actionSelectRow((JList) list, new JListLocation(1)); assertEquals("Selected: two", label.getText(), () -> "Wrong label after selection"); - tester.actionSelectRow((JList) list, new JListLocation(2)); assertEquals("Selected: three", label.getText(), () -> "Wrong label after selection"); tester.actionSelectRow((JList) list, new JListLocation(0)); assertEquals("Selected: one", label.getText(), () -> "Wrong label after selection"); } - } diff --git a/com.windowtester.junit5/src/test/java/example/MyCodeStressTest.java b/com.windowtester.junit5/src/test/java/example/MyCodeStressTest.java index 571dbf4..ef5ee17 100644 --- a/com.windowtester.junit5/src/test/java/example/MyCodeStressTest.java +++ b/com.windowtester.junit5/src/test/java/example/MyCodeStressTest.java @@ -26,5 +26,4 @@ private File getFile() throws URISyntaxException { assertNotNull(url, () -> "File not found: " + filename); return new File(url.toURI()); } - } diff --git a/com.windowtester.junit5/src/test/java/example/MyCodeTest.java b/com.windowtester.junit5/src/test/java/example/MyCodeTest.java index ea9c313..f8e819c 100644 --- a/com.windowtester.junit5/src/test/java/example/MyCodeTest.java +++ b/com.windowtester.junit5/src/test/java/example/MyCodeTest.java @@ -35,5 +35,4 @@ private File getFile(String filename) throws URISyntaxException { assertNotNull(url, () -> "File not found: " + filename); return new File(url.toURI()); } - } diff --git a/com.windowtester.junit5/src/test/java/example/RepeatedArrowButtonTest.java b/com.windowtester.junit5/src/test/java/example/RepeatedArrowButtonTest.java index ef4c9b3..a8a12ad 100644 --- a/com.windowtester.junit5/src/test/java/example/RepeatedArrowButtonTest.java +++ b/com.windowtester.junit5/src/test/java/example/RepeatedArrowButtonTest.java @@ -18,8 +18,7 @@ class RepeatedArrowButtonTest { private ComponentTester tester; - @UIUnderTest - private final ArrowButton arrow = new ArrowButton(ArrowButton.LEFT); + @UIUnderTest private final ArrowButton arrow = new ArrowButton(ArrowButton.LEFT); private int count = 0; @@ -39,5 +38,4 @@ void testRepeatedFire() { assertTrue(count > 1, () -> "Didn't get any repeated events"); } - } diff --git a/com.windowtester.junit5/src/test/java/swing/samples/AppletDemo.java b/com.windowtester.junit5/src/test/java/swing/samples/AppletDemo.java index 9fa4674..3859cf1 100644 --- a/com.windowtester.junit5/src/test/java/swing/samples/AppletDemo.java +++ b/com.windowtester.junit5/src/test/java/swing/samples/AppletDemo.java @@ -34,14 +34,14 @@ public class AppletDemo extends JApplet { private final String[] flavors = { - "Chocolate", - "Strawberry", - "Vanilla Fudge Swirl", - "Mint Chip", - "Mocha Almond Fudge", - "Rum Raisin", - "Praline Cream", - "Mud Pie" + "Chocolate", + "Strawberry", + "Vanilla Fudge Swirl", + "Mint Chip", + "Mocha Almond Fudge", + "Rum Raisin", + "Praline Cream", + "Mud Pie" }; private final DefaultListModel lItems = new DefaultListModel<>(); @@ -64,18 +64,18 @@ public void actionPerformed(ActionEvent e) { } }; - private final ListSelectionListener ll = e -> { - if (e.getValueIsAdjusting()) { - return; - } - t.setText(""); - - List items = lst.getSelectedValuesList(); - for (String item : items) { - t.append(item + "\n"); - } - }; + private final ListSelectionListener ll = + e -> { + if (e.getValueIsAdjusting()) { + return; + } + t.setText(""); + List items = lst.getSelectedValuesList(); + for (String item : items) { + t.append(item + "\n"); + } + }; public void init() { Container cp = getContentPane(); diff --git a/com.windowtester.junit5/src/test/java/swing/samples/ArrayListTransferHandler.java b/com.windowtester.junit5/src/test/java/swing/samples/ArrayListTransferHandler.java index 14ed113..d1aff7b 100644 --- a/com.windowtester.junit5/src/test/java/swing/samples/ArrayListTransferHandler.java +++ b/com.windowtester.junit5/src/test/java/swing/samples/ArrayListTransferHandler.java @@ -208,7 +208,7 @@ public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorExcepti @Override public DataFlavor[] getTransferDataFlavors() { - return new DataFlavor[]{localListFlavor, serialListFlavor}; + return new DataFlavor[] {localListFlavor, serialListFlavor}; } @Override diff --git a/com.windowtester.junit5/src/test/java/swing/samples/ComboBoxes.java b/com.windowtester.junit5/src/test/java/swing/samples/ComboBoxes.java index 7070992..4b8f51d 100644 --- a/com.windowtester.junit5/src/test/java/swing/samples/ComboBoxes.java +++ b/com.windowtester.junit5/src/test/java/swing/samples/ComboBoxes.java @@ -48,5 +48,4 @@ public JComboBox getComboBox1() { public JComboBox getComboBox2() { return colorsList; } - } diff --git a/com.windowtester.junit5/src/test/java/swing/samples/CustomDialog.java b/com.windowtester.junit5/src/test/java/swing/samples/CustomDialog.java index 8ef33e2..15f7b18 100644 --- a/com.windowtester.junit5/src/test/java/swing/samples/CustomDialog.java +++ b/com.windowtester.junit5/src/test/java/swing/samples/CustomDialog.java @@ -121,7 +121,7 @@ public void propertyChange(PropertyChangeEvent e) { if (isVisible() && (e.getSource() == optionPane) && (JOptionPane.VALUE_PROPERTY.equals(prop) - || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) { + || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) { Object value = optionPane.getValue(); if (value == JOptionPane.UNINITIALIZED_VALUE) { diff --git a/com.windowtester.junit5/src/test/java/swing/samples/DialogDemo.java b/com.windowtester.junit5/src/test/java/swing/samples/DialogDemo.java index 4f19a61..dea60d6 100644 --- a/com.windowtester.junit5/src/test/java/swing/samples/DialogDemo.java +++ b/com.windowtester.junit5/src/test/java/swing/samples/DialogDemo.java @@ -571,5 +571,4 @@ public void windowClosing(WindowEvent we) { return createPane(moreDialogDesc + ":", radioButtons, showItButton); } - } diff --git a/com.windowtester.junit5/src/test/java/swing/samples/DialogSample.java b/com.windowtester.junit5/src/test/java/swing/samples/DialogSample.java index aad5d78..43efda9 100644 --- a/com.windowtester.junit5/src/test/java/swing/samples/DialogSample.java +++ b/com.windowtester.junit5/src/test/java/swing/samples/DialogSample.java @@ -68,5 +68,4 @@ public DialogSample(JFrame frame, String myMessage) { pack(); setVisible(true); } - } diff --git a/com.windowtester.junit5/src/test/java/swing/samples/DragListDemo.java b/com.windowtester.junit5/src/test/java/swing/samples/DragListDemo.java index e17a561..c36a66d 100644 --- a/com.windowtester.junit5/src/test/java/swing/samples/DragListDemo.java +++ b/com.windowtester.junit5/src/test/java/swing/samples/DragListDemo.java @@ -73,5 +73,4 @@ public DragListDemo() { add(panel2, BorderLayout.LINE_END); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); } - } diff --git a/com.windowtester.junit5/src/test/java/swing/samples/JListRendererDemo.java b/com.windowtester.junit5/src/test/java/swing/samples/JListRendererDemo.java index 20a87b8..3acf86a 100644 --- a/com.windowtester.junit5/src/test/java/swing/samples/JListRendererDemo.java +++ b/com.windowtester.junit5/src/test/java/swing/samples/JListRendererDemo.java @@ -25,10 +25,10 @@ public static void main(String[] args) { frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); DataItem[] items = { - new DataItem("EN 1", "DE 1"), - new DataItem("EN 2", "DE 2"), - new DataItem("EN 3", "DE 3"), - new DataItem("EN 4", "DE 4") + new DataItem("EN 1", "DE 1"), + new DataItem("EN 2", "DE 2"), + new DataItem("EN 3", "DE 3"), + new DataItem("EN 4", "DE 4") }; JList list = new JList<>(items); list.setName("JList1"); @@ -53,11 +53,7 @@ public JListCellRenderer(Locale userLocale) { @Override public Component getListCellRendererComponent( - JList list, - Object value, - int index, - boolean isSelected, - boolean cellHasFocus) { + JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel renderer = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); @@ -99,11 +95,7 @@ public String getNameDE() { @Override public String toString() { - return "DataItem [nameEN=" - + nameEN - + ", nameDE=" - + nameDE - + "]"; + return "DataItem [nameEN=" + nameEN + ", nameDE=" + nameDE + "]"; } } } diff --git a/com.windowtester.junit5/src/test/java/swing/samples/SampleDialog.java b/com.windowtester.junit5/src/test/java/swing/samples/SampleDialog.java index eb8c3eb..99779da 100644 --- a/com.windowtester.junit5/src/test/java/swing/samples/SampleDialog.java +++ b/com.windowtester.junit5/src/test/java/swing/samples/SampleDialog.java @@ -46,20 +46,21 @@ public SampleDialog(JFrame frame, String myMessage) { yesButton = new JButton("Yes"); // setVisible(false); // setVisible(false); - ActionListener actionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - if (yesButton == e.getSource()) { - System.err.println("User chose yes."); - answer = true; - // setVisible(false); - } else if (noButton == e.getSource()) { - System.err.println("User chose no."); - answer = false; - // setVisible(false); - } - } - }; + ActionListener actionListener = + new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (yesButton == e.getSource()) { + System.err.println("User chose yes."); + answer = true; + // setVisible(false); + } else if (noButton == e.getSource()) { + System.err.println("User chose no."); + answer = false; + // setVisible(false); + } + } + }; yesButton.addActionListener(actionListener); myPanel.add(yesButton); noButton = new JButton("No"); @@ -69,5 +70,4 @@ public void actionPerformed(ActionEvent e) { pack(); setVisible(true); } - } diff --git a/com.windowtester.junit5/src/test/java/swing/samples/SimpleTable.java b/com.windowtester.junit5/src/test/java/swing/samples/SimpleTable.java index ff336bd..d190bd0 100644 --- a/com.windowtester.junit5/src/test/java/swing/samples/SimpleTable.java +++ b/com.windowtester.junit5/src/test/java/swing/samples/SimpleTable.java @@ -60,12 +60,12 @@ public void mousePressed(MouseEvent e) { private static class DataModel extends AbstractTableModel { private Object[][] data = { - {"one", "two", "three", "four"}, - {"five", "six", "seven", "eight"}, - {"nine", "ten", "one", "twelve"}, - {"thirteen", "fourteen", "fifteen", "sixteen"}, - {"seventeen", "eighteen", "ninteen", "twenty"}, - {"twenty-one", "twenty-two", "twenty-three", "twenty-four"} + {"one", "two", "three", "four"}, + {"five", "six", "seven", "eight"}, + {"nine", "ten", "one", "twelve"}, + {"thirteen", "fourteen", "fifteen", "sixteen"}, + {"seventeen", "eighteen", "ninteen", "twenty"}, + {"twenty-one", "twenty-two", "twenty-three", "twenty-four"} }; public DataModel() { @@ -128,5 +128,4 @@ public SimpleTable() { // Add the scroll pane to this panel. add(scrollPane); } - } diff --git a/com.windowtester.junit5/src/test/java/swing/samples/SwingButton.java b/com.windowtester.junit5/src/test/java/swing/samples/SwingButton.java index 445c597..6388508 100644 --- a/com.windowtester.junit5/src/test/java/swing/samples/SwingButton.java +++ b/com.windowtester.junit5/src/test/java/swing/samples/SwingButton.java @@ -30,35 +30,39 @@ public SwingButton() { super(); JButton button = new JButton(); - button.addActionListener(e -> { - System.out.println("button clicked"); - buttonClicked = true; - }); + button.addActionListener( + e -> { + System.out.println("button clicked"); + buttonClicked = true; + }); button.setText("Test Button"); add(button); JCheckBox checkbox = new JCheckBox("CheckBox", false); - checkbox.addActionListener(e -> { - System.out.println("checkbox clicked"); - checkboxClicked = true; - }); + checkbox.addActionListener( + e -> { + System.out.println("checkbox clicked"); + checkboxClicked = true; + }); add(checkbox); JRadioButton radioButton = new JRadioButton("RadioButton", false); - radioButton.addActionListener(e -> { - System.out.println("radio button clicked"); - radioButtonClicked = true; - }); + radioButton.addActionListener( + e -> { + System.out.println("radio button clicked"); + radioButtonClicked = true; + }); add(radioButton); JToggleButton toggleButton = new JToggleButton("ToggleButton", false); - toggleButton.addActionListener(e -> { - System.out.println("toggle button clicked"); - toggleButtonClicked = true; - }); + toggleButton.addActionListener( + e -> { + System.out.println("toggle button clicked"); + toggleButtonClicked = true; + }); add(toggleButton); } @@ -78,5 +82,4 @@ private boolean getRadioButtonClicked() { private boolean getToggleButtonClicked() { return toggleButtonClicked; } - } diff --git a/com.windowtester.junit5/src/test/java/swing/samples/SwingList.java b/com.windowtester.junit5/src/test/java/swing/samples/SwingList.java index b826311..f7b8a0b 100644 --- a/com.windowtester.junit5/src/test/java/swing/samples/SwingList.java +++ b/com.windowtester.junit5/src/test/java/swing/samples/SwingList.java @@ -72,5 +72,4 @@ private ListModel createListModel() { listModel.addElement("seven"); return listModel; } - } diff --git a/com.windowtester.junit5/src/test/java/swing/samples/SwingMenus.java b/com.windowtester.junit5/src/test/java/swing/samples/SwingMenus.java index 29d3b41..aba9828 100644 --- a/com.windowtester.junit5/src/test/java/swing/samples/SwingMenus.java +++ b/com.windowtester.junit5/src/test/java/swing/samples/SwingMenus.java @@ -76,5 +76,4 @@ public void mousePressed(MouseEvent e) { submenu2.add(item2); setJMenuBar(menuBar); } - } diff --git a/com.windowtester.junit5/src/test/java/swing/samples/SwingTables.java b/com.windowtester.junit5/src/test/java/swing/samples/SwingTables.java index aa343ac..d8947d8 100644 --- a/com.windowtester.junit5/src/test/java/swing/samples/SwingTables.java +++ b/com.windowtester.junit5/src/test/java/swing/samples/SwingTables.java @@ -58,10 +58,10 @@ public void mousePressed(MouseEvent e) { private static class DataModel extends AbstractTableModel { private final Object[][] data = { - {"one", "two", "three", "four"}, - {"five", "six", "seven", "eight"}, - {"nine", "ten", "one", "twelve"}, - {"thirteen", "fourteen", "fifteen", "sixteen"} + {"one", "two", "three", "four"}, + {"five", "six", "seven", "eight"}, + {"nine", "ten", "one", "twelve"}, + {"thirteen", "fourteen", "fifteen", "sixteen"} }; public DataModel() { @@ -135,5 +135,4 @@ public void actionPerformed(ActionEvent e) { JScrollPane scrollPane2 = new JScrollPane(table2); add(scrollPane2); } - } diff --git a/com.windowtester.junit5/src/test/java/swing/samples/SwingTree.java b/com.windowtester.junit5/src/test/java/swing/samples/SwingTree.java index cbea0ec..199287d 100644 --- a/com.windowtester.junit5/src/test/java/swing/samples/SwingTree.java +++ b/com.windowtester.junit5/src/test/java/swing/samples/SwingTree.java @@ -138,5 +138,4 @@ public boolean isChoice1() { public boolean isChoice2() { return choice2; } - } diff --git a/com.windowtester.junit5/src/test/java/swing/samples/TestTree.java b/com.windowtester.junit5/src/test/java/swing/samples/TestTree.java index eed245a..9eb1229 100644 --- a/com.windowtester.junit5/src/test/java/swing/samples/TestTree.java +++ b/com.windowtester.junit5/src/test/java/swing/samples/TestTree.java @@ -65,5 +65,4 @@ public TestTree() { getContentPane().add(pane, BorderLayout.CENTER); } - } diff --git a/com.windowtester.junit5/src/test/java/swing/samples/TextComponentDemo.java b/com.windowtester.junit5/src/test/java/swing/samples/TextComponentDemo.java index fefc605..0f651e3 100644 --- a/com.windowtester.junit5/src/test/java/swing/samples/TextComponentDemo.java +++ b/com.windowtester.junit5/src/test/java/swing/samples/TextComponentDemo.java @@ -228,19 +228,27 @@ protected void addBindings() { InputMap inputMap = textPane.getInputMap(); // Ctrl-b to go backward one character - KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_B, Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()); + KeyStroke key = + KeyStroke.getKeyStroke( + KeyEvent.VK_B, Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()); inputMap.put(key, DefaultEditorKit.backwardAction); // Ctrl-f to go forward one character - key = KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()); + key = + KeyStroke.getKeyStroke( + KeyEvent.VK_F, Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()); inputMap.put(key, DefaultEditorKit.forwardAction); // Ctrl-p to go up one line - key = KeyStroke.getKeyStroke(KeyEvent.VK_P, Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()); + key = + KeyStroke.getKeyStroke( + KeyEvent.VK_P, Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()); inputMap.put(key, DefaultEditorKit.upAction); // Ctrl-n to go down one line - key = KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()); + key = + KeyStroke.getKeyStroke( + KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()); inputMap.put(key, DefaultEditorKit.downAction); } @@ -308,12 +316,12 @@ protected JMenu createStyleMenu() { protected void initDocument() { String[] initString = { - "Use the mouse to place the caret.", - "Use the edit menu to cut, copy, paste, and select text.", - "Also to undo and redo changes.", - "Use the style menu to change the style of the text.", - "Use these emacs key bindings to move the caret:", - "ctrl-f, ctrl-b, ctrl-n, ctrl-p." + "Use the mouse to place the caret.", + "Use the edit menu to cut, copy, paste, and select text.", + "Also to undo and redo changes.", + "Use the style menu to change the style of the text.", + "Use these emacs key bindings to move the caret:", + "ctrl-f, ctrl-b, ctrl-n, ctrl-p." }; SimpleAttributeSet[] attrs = initAttributes(initString.length); @@ -425,5 +433,4 @@ protected void updateRedoState() { } } } - } diff --git a/com.windowtester.junit5/src/test/java/swing/samples/TextInputDemo.java b/com.windowtester.junit5/src/test/java/swing/samples/TextInputDemo.java index 73abec7..3574327 100644 --- a/com.windowtester.junit5/src/test/java/swing/samples/TextInputDemo.java +++ b/com.windowtester.junit5/src/test/java/swing/samples/TextInputDemo.java @@ -215,8 +215,7 @@ public void run() { // Needed for FocusListener interface. @Override - public void focusLost(FocusEvent e) { - } // ignore + public void focusLost(FocusEvent e) {} // ignore protected JComponent createEntryFields() { JPanel panel = new JPanel(new SpringLayout()); @@ -275,58 +274,58 @@ protected JComponent createEntryFields() { } public String[] getStateStrings() { - return new String[]{ - "Alabama (AL)", - "Alaska (AK)", - "Arizona (AZ)", - "Arkansas (AR)", - "California (CA)", - "Colorado (CO)", - "Connecticut (CT)", - "Delaware (DE)", - "District of Columbia (DC)", - "Florida (FL)", - "Georgia (GA)", - "Hawaii (HI)", - "Idaho (ID)", - "Illinois (IL)", - "Indiana (IN)", - "Iowa (IA)", - "Kansas (KS)", - "Kentucky (KY)", - "Louisiana (LA)", - "Maine (ME)", - "Maryland (MD)", - "Massachusetts (MA)", - "Michigan (MI)", - "Minnesota (MN)", - "Mississippi (MS)", - "Missouri (MO)", - "Montana (MT)", - "Nebraska (NE)", - "Nevada (NV)", - "New Hampshire (NH)", - "New Jersey (NJ)", - "New Mexico (NM)", - "New York (NY)", - "North Carolina (NC)", - "North Dakota (ND)", - "Ohio (OH)", - "Oklahoma (OK)", - "Oregon (OR)", - "Pennsylvania (PA)", - "Rhode Island (RI)", - "South Carolina (SC)", - "South Dakota (SD)", - "Tennessee (TN)", - "Texas (TX)", - "Utah (UT)", - "Vermont (VT)", - "Virginia (VA)", - "Washington (WA)", - "West Virginia (WV)", - "Wisconsin (WI)", - "Wyoming (WY)" + return new String[] { + "Alabama (AL)", + "Alaska (AK)", + "Arizona (AZ)", + "Arkansas (AR)", + "California (CA)", + "Colorado (CO)", + "Connecticut (CT)", + "Delaware (DE)", + "District of Columbia (DC)", + "Florida (FL)", + "Georgia (GA)", + "Hawaii (HI)", + "Idaho (ID)", + "Illinois (IL)", + "Indiana (IN)", + "Iowa (IA)", + "Kansas (KS)", + "Kentucky (KY)", + "Louisiana (LA)", + "Maine (ME)", + "Maryland (MD)", + "Massachusetts (MA)", + "Michigan (MI)", + "Minnesota (MN)", + "Mississippi (MS)", + "Missouri (MO)", + "Montana (MT)", + "Nebraska (NE)", + "Nevada (NV)", + "New Hampshire (NH)", + "New Jersey (NJ)", + "New Mexico (NM)", + "New York (NY)", + "North Carolina (NC)", + "North Dakota (ND)", + "Ohio (OH)", + "Oklahoma (OK)", + "Oregon (OR)", + "Pennsylvania (PA)", + "Rhode Island (RI)", + "South Carolina (SC)", + "South Dakota (SD)", + "Tennessee (TN)", + "Texas (TX)", + "Utah (UT)", + "Vermont (VT)", + "Virginia (VA)", + "Washington (WA)", + "West Virginia (WV)", + "Wisconsin (WI)", + "Wyoming (WY)" }; } @@ -342,5 +341,4 @@ public JFormattedTextField getTextField(JSpinner spinner) { + " isn't a descendant of DefaultEditor"); return null; } - } diff --git a/com.windowtester.junit5/src/test/java/swing/samples/TreeDnD.java b/com.windowtester.junit5/src/test/java/swing/samples/TreeDnD.java index 0cc7796..cd7c2e1 100644 --- a/com.windowtester.junit5/src/test/java/swing/samples/TreeDnD.java +++ b/com.windowtester.junit5/src/test/java/swing/samples/TreeDnD.java @@ -56,7 +56,7 @@ ISBN: 1-893115-78-X Publisher: APress */ -public class TreeDnD extends JFrame { +public class TreeDnD extends JFrame { public TreeDnD() { setTitle("Tree Dragging Tester"); @@ -149,14 +149,11 @@ public void dragEnter(DropTargetDragEvent dropTargetDragEvent) { insets = new Insets(top + 10, 0, bottom - 10, getWidth()); } - public void dragExit(DropTargetEvent dropTargetEvent) { - } + public void dragExit(DropTargetEvent dropTargetEvent) {} - public void dragOver(DropTargetDragEvent dropTargetDragEvent) { - } + public void dragOver(DropTargetDragEvent dropTargetDragEvent) {} - public void dropActionChanged(DropTargetDragEvent dropTargetDragEvent) { - } + public void dropActionChanged(DropTargetDragEvent dropTargetDragEvent) {} public synchronized void drop(DropTargetDropEvent dropTargetDropEvent) { // Only support dropping over nodes that aren't leafs @@ -247,14 +244,11 @@ public void dragEnter(DragSourceDragEvent dragSourceDragEvent) { } } - public void dragExit(DragSourceEvent dragSourceEvent) { - } + public void dragExit(DragSourceEvent dragSourceEvent) {} - public void dragOver(DragSourceDragEvent dragSourceDragEvent) { - } + public void dragOver(DragSourceDragEvent dragSourceDragEvent) {} - public void dropActionChanged(DragSourceDragEvent dragSourceDragEvent) { - } + public void dropActionChanged(DragSourceDragEvent dragSourceDragEvent) {} } private static class TransferableTreeNode extends DefaultMutableTreeNode implements Transferable { @@ -267,7 +261,7 @@ private static class TransferableTreeNode extends DefaultMutableTreeNode impleme new DataFlavor(DefaultMutableTreeNode.class, "Default Mutable Tree Node"); static DataFlavor[] flavors = { - DEFAULT_MUTABLE_TREENODE_FLAVOR, DataFlavor.stringFlavor, DataFlavor.plainTextFlavor + DEFAULT_MUTABLE_TREENODE_FLAVOR, DataFlavor.stringFlavor, DataFlavor.plainTextFlavor }; private final DefaultMutableTreeNode data; diff --git a/com.windowtester.junit5/src/test/java/swing/samples/UseTheSampleDialog.java b/com.windowtester.junit5/src/test/java/swing/samples/UseTheSampleDialog.java index b47f4a3..f65358f 100644 --- a/com.windowtester.junit5/src/test/java/swing/samples/UseTheSampleDialog.java +++ b/com.windowtester.junit5/src/test/java/swing/samples/UseTheSampleDialog.java @@ -62,5 +62,4 @@ public void actionPerformed(ActionEvent e) { } } } - } diff --git a/com.windowtester.junit5/src/test/java/w2/testcases/JButtonTest.java b/com.windowtester.junit5/src/test/java/w2/testcases/JButtonTest.java index 76eacf3..e7f83b8 100644 --- a/com.windowtester.junit5/src/test/java/w2/testcases/JButtonTest.java +++ b/com.windowtester.junit5/src/test/java/w2/testcases/JButtonTest.java @@ -21,7 +21,7 @@ public class JButtonTest private IUIContext ui; public JButtonTest() { - // super(SwingButton.class); + // super(SwingButton.class); } protected void setUp() throws Exception { diff --git a/com.windowtester.junit5/src/test/java/w2/testcases/JComboBoxTest.java b/com.windowtester.junit5/src/test/java/w2/testcases/JComboBoxTest.java index 296f3c3..e6413b2 100644 --- a/com.windowtester.junit5/src/test/java/w2/testcases/JComboBoxTest.java +++ b/com.windowtester.junit5/src/test/java/w2/testcases/JComboBoxTest.java @@ -24,7 +24,7 @@ public class JComboBoxTest private IUIContext ui; public JComboBoxTest() { - // super(ComboBoxes.class); + // super(ComboBoxes.class); } protected void setUp() throws Exception { diff --git a/com.windowtester.runtime/pom.xml b/com.windowtester.runtime/pom.xml index dcf5242..d45fa66 100644 --- a/com.windowtester.runtime/pom.xml +++ b/com.windowtester.runtime/pom.xml @@ -5,7 +5,7 @@ io.github.r4fterman com.windowtester - 6.0.0-SNAPSHOT + 6.0.1-SNAPSHOT com.windowtester.runtime @@ -55,6 +55,13 @@ + + dev.dimlight + shellcheck-maven-plugin + + true + + diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/internal/debug/Logger.java b/com.windowtester.runtime/src/main/java/com/windowtester/internal/debug/Logger.java index ac104d1..6c2a17f 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/internal/debug/Logger.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/internal/debug/Logger.java @@ -34,8 +34,7 @@ public void close() { /** * Disallow the creation of instances of this class. */ - private Logger() { - } + private Logger() {} /** * Log the specified exception. @@ -144,7 +143,7 @@ public static IStatus createLogStatus(String message, Object detail, String defa } if (detail instanceof IStatus) { return new MultiStatus( - PRODUCT_ID, Status.OK, new IStatus[]{(IStatus) detail}, message, null); + PRODUCT_ID, Status.OK, new IStatus[] {(IStatus) detail}, message, null); } if (detail == null) { return new Status(Status.INFO, PRODUCT_ID, Status.OK, text, null); diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/internal/debug/MultiStatus.java b/com.windowtester.runtime/src/main/java/com/windowtester/internal/debug/MultiStatus.java index 2011a5c..5f95578 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/internal/debug/MultiStatus.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/internal/debug/MultiStatus.java @@ -9,11 +9,7 @@ public class MultiStatus implements IStatus { private final Throwable throwable; public MultiStatus( - String productId, - int ok, - IStatus[] children, - String message, - Throwable throwable) { + String productId, int ok, IStatus[] children, String message, Throwable throwable) { this.productId = productId; this.ok = ok; this.children = children; diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/internal/debug/Status.java b/com.windowtester.runtime/src/main/java/com/windowtester/internal/debug/Status.java index 04a001e..3819153 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/internal/debug/Status.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/internal/debug/Status.java @@ -12,12 +12,7 @@ public class Status implements IStatus { private final String message; private final Throwable throwable; - public Status( - int status, - String productId, - int ok, - String message, - Throwable throwable) { + public Status(int status, String productId, int ok, String message, Throwable throwable) { this.status = status; this.productId = productId; this.ok = ok; diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/internal/debug/ThreadUtil.java b/com.windowtester.runtime/src/main/java/com/windowtester/internal/debug/ThreadUtil.java index c5df3a6..a723b1e 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/internal/debug/ThreadUtil.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/internal/debug/ThreadUtil.java @@ -94,9 +94,7 @@ public static void printStackTraces(PrintWriter writer) { } private static void printStackTrace( - PrintWriter writer, - Thread thread, - StackTraceElement[] trace) { + PrintWriter writer, Thread thread, StackTraceElement[] trace) { try { writer.println(thread.toString() + ":"); for (StackTraceElement stackTraceElement : trace) { diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/ClassReference.java b/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/ClassReference.java index 19dc232..9d1e536 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/ClassReference.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/ClassReference.java @@ -35,12 +35,9 @@ public static ClassReference forName(String className) { * A class that is used as a sentinel when class resolution in * {@link ClassReference#getClassForName()} fails. */ - public static final class UnresolvableClass { + public static final class UnresolvableClass {} - } - - @Serial - private static final long serialVersionUID = -5522094418456665521L; + @Serial private static final long serialVersionUID = -5522094418456665521L; /** * name of the class diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/ICodeGenerator.java b/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/ICodeGenerator.java index dd6f7a6..f02d594 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/ICodeGenerator.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/ICodeGenerator.java @@ -12,9 +12,7 @@ public interface ICodeGenerator { - class JavaVersion { - - } + class JavaVersion {} JavaVersion JAVA5 = new JavaVersion(); JavaVersion JAVA4 = new JavaVersion(); diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/PropertySet.java b/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/PropertySet.java index 9b40b33..2a4660f 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/PropertySet.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/PropertySet.java @@ -33,14 +33,12 @@ public class PropertySet implements Serializable { - @Serial - private static final long serialVersionUID = 1L; + @Serial private static final long serialVersionUID = 1L; // for testing public static class TestStub extends PropertySet { - @Serial - private static final long serialVersionUID = 1L; + @Serial private static final long serialVersionUID = 1L; public TestStub() { super(null, null); @@ -54,8 +52,7 @@ public interface IPropertyProvider { public static class PropertyMapping implements Serializable { - @Serial - private static final long serialVersionUID = 1L; + @Serial private static final long serialVersionUID = 1L; public static final PropertyMapping ENABLED = PropertyMapping.withKey("isEnabled").withName("Is Enabled"); diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/UIContextCommon.java b/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/UIContextCommon.java index c33d4cf..c074570 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/UIContextCommon.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/UIContextCommon.java @@ -42,31 +42,28 @@ public abstract class UIContextCommon implements IUIContext { // dump system information static { StringBuilder sb = new StringBuilder(); - sb - .append(NEW_LINE) + sb.append(NEW_LINE) .append("*************************************************") .append(NEW_LINE) .append("WindowTester Runtime " + ProductInfo.build) .append(NEW_LINE); - echoSystemProperties("OS:", new String[]{"os.name", "os.arch", "os.version"}, sb); - echoSystemProperties("Java:", new String[]{"java.vendor", "java.version"}, sb); + echoSystemProperties("OS:", new String[] {"os.name", "os.arch", "os.version"}, sb); + echoSystemProperties("Java:", new String[] {"java.vendor", "java.version"}, sb); echoSystemProperties( "Spec:", - new String[]{ - "java.specification.name", "java.specification.vendor", "java.specification.version" + new String[] { + "java.specification.name", "java.specification.vendor", "java.specification.version" }, sb); echoSystemProperties( "VM:", - new String[]{ - "java.vm.specification.name", - "java.vm.specification.vendor", - "java.vm.specification.version" + new String[] { + "java.vm.specification.name", + "java.vm.specification.vendor", + "java.vm.specification.version" }, sb); - sb - .append("*************************************************") - .append(NEW_LINE); + sb.append("*************************************************").append(NEW_LINE); LogHandler.log(sb.toString()); } diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/finder/ISearchScope.java b/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/finder/ISearchScope.java index 8a8d6c8..c8ea0bf 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/finder/ISearchScope.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/finder/ISearchScope.java @@ -13,6 +13,4 @@ /** * A marker interface for classes that can be used to scope searches. */ -public interface ISearchScope { - -} +public interface ISearchScope {} diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/junit/core/launcher/LauncherFactory.java b/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/junit/core/launcher/LauncherFactory.java index d8ed95f..3f4c1d4 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/junit/core/launcher/LauncherFactory.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/junit/core/launcher/LauncherFactory.java @@ -99,20 +99,21 @@ public void launch() { static class MainRunner extends SeparateThreadLauncher { public MainRunner(Class launchClass, String[] launchArgs) { - super(() -> { - var nullArgs = new String[0]; - var main = launchClass.getMethod("main", String[].class); - - Object[] realArgs; - // instead pass null string - if (launchArgs == null) { - realArgs = new Object[]{nullArgs}; - } else { - realArgs = new Object[]{launchArgs}; - } - - main.invoke(null, realArgs); - }); + super( + () -> { + var nullArgs = new String[0]; + var main = launchClass.getMethod("main", String[].class); + + Object[] realArgs; + // instead pass null string + if (launchArgs == null) { + realArgs = new Object[] {nullArgs}; + } else { + realArgs = new Object[] {launchArgs}; + } + + main.invoke(null, realArgs); + }); } } diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/locator/IdentifierAdapter.java b/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/locator/IdentifierAdapter.java index 42fd40c..5abb588 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/locator/IdentifierAdapter.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/locator/IdentifierAdapter.java @@ -22,8 +22,7 @@ */ public class IdentifierAdapter implements IWidgetIdentifier, IAdaptable, ILocator, Serializable { - @Serial - private static final long serialVersionUID = -2449531209586204515L; + @Serial private static final long serialVersionUID = -2449531209586204515L; private final transient ILocator locator; diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/matcher/ExactClassMatcher.java b/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/matcher/ExactClassMatcher.java index 0d902d9..ab1ec27 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/matcher/ExactClassMatcher.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/matcher/ExactClassMatcher.java @@ -45,8 +45,7 @@ public boolean matches(Object widget) { } private boolean classMatches(Object widget) { - return cls.isAssignableFrom(widget.getClass()) - && widget.getClass().isAssignableFrom(cls); + return cls.isAssignableFrom(widget.getClass()) && widget.getClass().isAssignableFrom(cls); } @Override diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/monitor/UIThreadMonitorCommon.java b/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/monitor/UIThreadMonitorCommon.java index 8d61c45..f5b1183 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/monitor/UIThreadMonitorCommon.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/monitor/UIThreadMonitorCommon.java @@ -458,9 +458,7 @@ protected void trace(String message, Object value) { .append(" ") .append(message); if (value != null) { - buf - .append(" ") - .append(value); + buf.append(" ").append(value); } if (traceMode == TRACE_CONSOLE) { System.out.println(buf); diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/selector/ClickHelper.java b/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/selector/ClickHelper.java index 23f7228..dfd23dc 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/selector/ClickHelper.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/selector/ClickHelper.java @@ -40,10 +40,8 @@ public ClickHelper(IUIContext ui) { } @Override - public IWidgetLocator click( - int clickCount, - ILocator locator, - int buttonMask) throws WidgetSearchException { + public IWidgetLocator click(int clickCount, ILocator locator, int buttonMask) + throws WidgetSearchException { var widgetLocator = getWidgetLocator(locator); IWidgetReference widget = null; if (!(widgetLocator instanceof IItemLocator)) { @@ -121,9 +119,7 @@ public static IWidgetLocator getWidgetLocator(ILocator locator) { } private IClickDescription createClickDescription( - int clickCount, - ILocator locator, - int buttonMask) { + int clickCount, ILocator locator, int buttonMask) { // TODO properly handle nested XYLocators return ClickDescription.create(clickCount, locator, buttonMask); } @@ -138,13 +134,11 @@ public void addClickListener(Listener listener) { } private void informClick(IClickDescription click, IWidgetLocator widgetLocator) { - getListeners() - .forEach(listener -> listener.clicked(click, widgetLocator)); + getListeners().forEach(listener -> listener.clicked(click, widgetLocator)); } private void informContextClick(IClickDescription click, IWidgetLocator widgetLocator) { - getListeners() - .forEach(listener -> listener.contextClicked(click, widgetLocator)); + getListeners().forEach(listener -> listener.contextClicked(click, widgetLocator)); } private List getListeners() { @@ -155,9 +149,8 @@ private List getListeners() { } private IWidgetLocator doClick( - IWidgetReference widget, - IClickDescription click, - IUISelector selector) throws WidgetSearchException { + IWidgetReference widget, IClickDescription click, IUISelector selector) + throws WidgetSearchException { return selector.click(getUIContext(), widget, click); } diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/util/ReflectionUtils.java b/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/util/ReflectionUtils.java index 671874d..aef6034 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/util/ReflectionUtils.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/internal/runtime/util/ReflectionUtils.java @@ -22,11 +22,11 @@ public class ReflectionUtils { @SuppressWarnings("unchecked") public static T newInstance(T obj) throws IllegalArgumentException, - SecurityException, - InstantiationException, - IllegalAccessException, - InvocationTargetException, - NoSuchMethodException { + SecurityException, + InstantiationException, + IllegalAccessException, + InvocationTargetException, + NoSuchMethodException { var newObj = obj.getClass().getConstructor().newInstance(); return (T) newObj; } @@ -34,11 +34,11 @@ public static T newInstance(T obj) @SuppressWarnings("unchecked") public static T newInstance(T obj, Class argType, Object arg) throws IllegalArgumentException, - SecurityException, - InstantiationException, - IllegalAccessException, - InvocationTargetException, - NoSuchMethodException { + SecurityException, + InstantiationException, + IllegalAccessException, + InvocationTargetException, + NoSuchMethodException { var newObj = obj.getClass().getConstructor(argType).newInstance(arg); return (T) newObj; } @@ -46,11 +46,11 @@ public static T newInstance(T obj, Class argType, Object arg) @SuppressWarnings("unchecked") public static T newInstance(Class instanceClass, Class argType, Object arg) throws IllegalArgumentException, - SecurityException, - InstantiationException, - IllegalAccessException, - InvocationTargetException, - NoSuchMethodException { + SecurityException, + InstantiationException, + IllegalAccessException, + InvocationTargetException, + NoSuchMethodException { var newObj = instanceClass.getConstructor(argType).newInstance(arg); return (T) newObj; } diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/InaccessibleWidgetException.java b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/InaccessibleWidgetException.java index cd099f2..e92e5bc 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/InaccessibleWidgetException.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/InaccessibleWidgetException.java @@ -19,8 +19,7 @@ */ public class InaccessibleWidgetException extends WidgetSearchException { - @Serial - private static final long serialVersionUID = 3035842156651482281L; + @Serial private static final long serialVersionUID = 3035842156651482281L; public InaccessibleWidgetException() { super(); diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/IncompatibleTypeException.java b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/IncompatibleTypeException.java index 0b9c188..99345d0 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/IncompatibleTypeException.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/IncompatibleTypeException.java @@ -23,8 +23,7 @@ */ public class IncompatibleTypeException extends IllegalStateException { - @Serial - private static final long serialVersionUID = -1675440415583239600L; + @Serial private static final long serialVersionUID = -1675440415583239600L; /** * Constructs an IncompatibleTypeException with no detail message. A detail message is a String diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/MultipleWidgetsFoundException.java b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/MultipleWidgetsFoundException.java index a1f05b5..72f9eac 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/MultipleWidgetsFoundException.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/MultipleWidgetsFoundException.java @@ -57,5 +57,4 @@ private static String getName(WidgetReference ref) { } return component.getName(); } - } diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/WaitTimedOutException.java b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/WaitTimedOutException.java index 16fa6c3..215d5a5 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/WaitTimedOutException.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/WaitTimedOutException.java @@ -17,8 +17,7 @@ */ public class WaitTimedOutException extends RuntimeException { - @Serial - private static final long serialVersionUID = -8129128536949106306L; + @Serial private static final long serialVersionUID = -8129128536949106306L; public WaitTimedOutException(String msg) { super(msg); diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/WidgetLocator.java b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/WidgetLocator.java index 965afbe..f5bb300 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/WidgetLocator.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/WidgetLocator.java @@ -41,8 +41,7 @@ public class WidgetLocator implements Serializable, IWidgetIdentifier, IAdaptabl * This should _not_ be a problem (hierarchies are not too deep); still, we * could consider a custom serialization scheme. */ - @Serial - private static final long serialVersionUID = 7772528976750829834L; + @Serial private static final long serialVersionUID = 7772528976750829834L; /** * A sentinel value, indicating an unassigned index @@ -88,10 +87,7 @@ protected WidgetLocator() { * @since 3.8.1 */ protected WidgetLocator( - ClassReference classRef, - String nameOrLabel, - int index, - WidgetLocator parentInfo) { + ClassReference classRef, String nameOrLabel, int index, WidgetLocator parentInfo) { this.classRef = classRef; this.nameOrLabel = nameOrLabel; this.index = index; @@ -106,11 +102,7 @@ protected WidgetLocator( * @param index - the target's index relative to its parent * @param parentInfo - the target's parent info */ - public WidgetLocator( - Class cls, - String nameOrLabel, - int index, - WidgetLocator parentInfo) { + public WidgetLocator(Class cls, String nameOrLabel, int index, WidgetLocator parentInfo) { this(ClassReference.forClass(cls), nameOrLabel, index, parentInfo); } @@ -285,19 +277,14 @@ public String toString() { if (name != null) { builder.append(name).append("("); } else { - builder - .append("WidgetLocator(") - .append(classRef.getName()); + builder.append("WidgetLocator(").append(classRef.getName()); if (getNameOrLabel() != null) { builder.append(", "); } } if (getNameOrLabel() != null) { - builder - .append('\"') - .append(getNameOrLabel()) - .append('\"'); + builder.append('\"').append(getNameOrLabel()).append('\"'); if (getIndex() != UNASSIGNED || getParentInfo() != null) { builder.append(", "); } diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/WidgetNotFoundException.java b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/WidgetNotFoundException.java index 76c5594..9263d34 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/WidgetNotFoundException.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/WidgetNotFoundException.java @@ -17,8 +17,7 @@ */ public class WidgetNotFoundException extends WidgetSearchException { - @Serial - private static final long serialVersionUID = -7232101203251666634L; + @Serial private static final long serialVersionUID = -7232101203251666634L; /** * Create an instance with no specified detail message. diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/WidgetSearchException.java b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/WidgetSearchException.java index 6e43b40..2a1ac8f 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/WidgetSearchException.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/WidgetSearchException.java @@ -17,8 +17,7 @@ */ public class WidgetSearchException extends Exception { - @Serial - private static final long serialVersionUID = 450468979445524082L; + @Serial private static final long serialVersionUID = 450468979445524082L; /** * Create an instance with the specified detail message. diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/condition/IConditionHandler.java b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/condition/IConditionHandler.java index af03b01..8f396cb 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/condition/IConditionHandler.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/condition/IConditionHandler.java @@ -17,6 +17,4 @@ * @see com.windowtester.runtime.condition.IHandler * @see com.windowtester.runtime.condition.IConditionMonitor */ -public interface IConditionHandler extends ICondition, IHandler { - -} +public interface IConditionHandler extends ICondition, IHandler {} diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/condition/IUIConditionHandler.java b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/condition/IUIConditionHandler.java index 90689c8..34fd2cd 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/condition/IUIConditionHandler.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/condition/IUIConditionHandler.java @@ -25,6 +25,4 @@ * * @see IConditionHandler */ -public interface IUIConditionHandler extends IConditionHandler, IUICondition { - -} +public interface IUIConditionHandler extends IConditionHandler, IUICondition {} diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/internal/KeyStrokeDecoder.java b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/internal/KeyStrokeDecoder.java index 4761fe7..cd44f17 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/internal/KeyStrokeDecoder.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/internal/KeyStrokeDecoder.java @@ -81,8 +81,6 @@ private static void addKeys(int compositeKey, List keys) { } private static int[] toIntArray(List keys) { - return keys.stream() - .mapToInt(Integer::intValue) - .toArray(); + return keys.stream().mapToInt(Integer::intValue).toArray(); } } diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/internal/application/IApplicationContextActionProvider.java b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/internal/application/IApplicationContextActionProvider.java index 378e30d..22189b8 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/internal/application/IApplicationContextActionProvider.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/internal/application/IApplicationContextActionProvider.java @@ -13,6 +13,4 @@ /** * Provides implementations of context-specific behavior. */ -public interface IApplicationContextActionProvider { - -} +public interface IApplicationContextActionProvider {} diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/internal/factory/WTRuntimeManager.java b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/internal/factory/WTRuntimeManager.java index b6c8bcf..2e64c56 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/internal/factory/WTRuntimeManager.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/internal/factory/WTRuntimeManager.java @@ -88,17 +88,12 @@ private IWidgetReference createReference(Object widget) { return widgetRef; } } - var errMsg = new StringBuilder( - "Failed to create widget reference for instance of " + widget.getClass().getName()); - errMsg - .append(StringUtils.NEW_LINE) - .append(" ") - .append(getPlatformDebugInfo()); + var errMsg = + new StringBuilder( + "Failed to create widget reference for instance of " + widget.getClass().getName()); + errMsg.append(StringUtils.NEW_LINE).append(" ").append(getPlatformDebugInfo()); for (WTRuntimeFactoryReference factoryRef : factoryReferences) { - errMsg - .append(StringUtils.NEW_LINE) - .append(" factory: ") - .append(factoryRef.getFactory()); + errMsg.append(StringUtils.NEW_LINE).append(" factory: ").append(factoryRef.getFactory()); } throw new RuntimeException(errMsg.toString()); } diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/locator/ILocator.java b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/locator/ILocator.java index 2001804..7bf9053 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/locator/ILocator.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/locator/ILocator.java @@ -13,6 +13,4 @@ /** * Locators are used to identify widgets, menus, items within a menu, submenu or tree, etc. */ -public interface ILocator { - -} +public interface ILocator {} diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/locator/WidgetReference.java b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/locator/WidgetReference.java index 27c5dd6..cba2582 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/locator/WidgetReference.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/locator/WidgetReference.java @@ -66,7 +66,7 @@ public WidgetReference(T widget) { @Override public IWidgetLocator[] findAll(IUIContext ui) { - return new IWidgetLocator[]{this}; + return new IWidgetLocator[] {this}; } @Override diff --git a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/locator/XYLocator.java b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/locator/XYLocator.java index 2a64ad6..934d03e 100644 --- a/com.windowtester.runtime/src/main/java/com/windowtester/runtime/locator/XYLocator.java +++ b/com.windowtester.runtime/src/main/java/com/windowtester/runtime/locator/XYLocator.java @@ -34,8 +34,7 @@ public class XYLocator implements IXYLocator, Serializable { * to the specified area. If locator resolves to an instance of IXYLocator * rather than IAreaLocator, then the relative flags are ignored. */ - @Serial - private static final long serialVersionUID = -916067593367432955L; + @Serial private static final long serialVersionUID = -916067593367432955L; /** * A locator to which the x,y coordinates are relative. diff --git a/com.windowtester.swing.recorder/pom.xml b/com.windowtester.swing.recorder/pom.xml index 6d4690d..3a531b7 100644 --- a/com.windowtester.swing.recorder/pom.xml +++ b/com.windowtester.swing.recorder/pom.xml @@ -5,7 +5,7 @@ io.github.r4fterman com.windowtester - 6.0.0-SNAPSHOT + 6.0.1-SNAPSHOT com.windowtester.swing.recorder @@ -38,4 +38,16 @@ test + + + + + dev.dimlight + shellcheck-maven-plugin + + true + + + + diff --git a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/event/recorder/EventCachingListener.java b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/event/recorder/EventCachingListener.java index e6e35e0..974bc2e 100644 --- a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/event/recorder/EventCachingListener.java +++ b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/event/recorder/EventCachingListener.java @@ -42,40 +42,31 @@ public void notifyAssertionHookAdded(String hookName) { } @Override - public void notifyStart() { - } + public void notifyStart() {} @Override - public void notifyStop() { - } + public void notifyStop() {} @Override - public void notifyWrite() { - } + public void notifyWrite() {} @Override - public void notifyPause() { - } + public void notifyPause() {} @Override - public void notifyDispose() { - } + public void notifyDispose() {} @Override - public void notifyRestart() { - } + public void notifyRestart() {} @Override - public void notifyError(RecorderErrorEvent event) { - } + public void notifyError(RecorderErrorEvent event) {} @Override - public void notifyTrace(RecorderTraceEvent event) { - } + public void notifyTrace(RecorderTraceEvent event) {} @Override - public void notifySpyModeToggle() { - } + public void notifySpyModeToggle() {} public ISemanticEvent[] getEvents() { if (events.isEmpty()) { @@ -85,12 +76,8 @@ public ISemanticEvent[] getEvents() { } @Override - public void notifyControllerStart(int port) { - - } + public void notifyControllerStart(int port) {} @Override - public void notifyDisplayNotFound() { - - } + public void notifyDisplayNotFound() {} } diff --git a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/event/spy/SpyEventHandler.java b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/event/spy/SpyEventHandler.java index 1191826..2932be4 100644 --- a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/event/spy/SpyEventHandler.java +++ b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/event/spy/SpyEventHandler.java @@ -53,10 +53,9 @@ private UISemanticEvent createInspectionEvent(AWTEvent event) { component = getMostSpecificWidgetForEvent(component, event); EventInfo info = extractInfo(event, component); - return - new SemanticWidgetInspectionEvent(info, UIContextSwingFactory.createContext()) - .withWidgetHash(component.hashCode()) - .atHoverPoint(getCursorPosition()); + return new SemanticWidgetInspectionEvent(info, UIContextSwingFactory.createContext()) + .withWidgetHash(component.hashCode()) + .atHoverPoint(getCursorPosition()); } private Point getCursorPosition() { @@ -89,5 +88,4 @@ private IWidgetIdentifier sanityCheck(IWidgetIdentifier id, AWTEvent event) { static Component getMostSpecificWidgetForEvent(Component w, AWTEvent event) { return w; } - } diff --git a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/event/spy/SpyEventListener.java b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/event/spy/SpyEventListener.java index 607e35e..96e77ee 100644 --- a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/event/spy/SpyEventListener.java +++ b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/event/spy/SpyEventListener.java @@ -18,44 +18,28 @@ public class SpyEventListener implements ISemanticEventListener { @Override - public void notify(IUISemanticEvent event) { - - } + public void notify(IUISemanticEvent event) {} @Override - public void notifyAssertionHookAdded(String hookName) { - - } + public void notifyAssertionHookAdded(String hookName) {} @Override - public void notifyControllerStart(int port) { - - } + public void notifyControllerStart(int port) {} @Override - public void notifyDisplayNotFound() { - - } + public void notifyDisplayNotFound() {} @Override - public void notifyDispose() { - - } + public void notifyDispose() {} @Override - public void notifyError(RecorderErrorEvent event) { - - } + public void notifyError(RecorderErrorEvent event) {} @Override - public void notifyPause() { - - } + public void notifyPause() {} @Override - public void notifyRestart() { - - } + public void notifyRestart() {} @Override public void notifySpyModeToggle() { @@ -63,22 +47,14 @@ public void notifySpyModeToggle() { } @Override - public void notifyStart() { - - } + public void notifyStart() {} @Override - public void notifyStop() { - - } + public void notifyStop() {} @Override - public void notifyTrace(RecorderTraceEvent event) { - - } + public void notifyTrace(RecorderTraceEvent event) {} @Override - public void notifyWrite() { - - } + public void notifyWrite() {} } diff --git a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/AbstractButtonRecorder.java b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/AbstractButtonRecorder.java index 4af9f73..09e039b 100644 --- a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/AbstractButtonRecorder.java +++ b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/AbstractButtonRecorder.java @@ -59,7 +59,7 @@ protected Step createClick(Component target, int x, int y, int mods, int count) getResolver(), null, "actionClick", - new String[]{cr.getID()}, + new String[] {cr.getID()}, javax.swing.AbstractButton.class); } return null; diff --git a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/AbstractInternalFrameWatcher.java b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/AbstractInternalFrameWatcher.java index c4bcbff..5307ddf 100644 --- a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/AbstractInternalFrameWatcher.java +++ b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/AbstractInternalFrameWatcher.java @@ -53,14 +53,11 @@ public void internalFrameDeiconified(InternalFrameEvent e) { } @Override - public void componentShown(ComponentEvent e) { - } + public void componentShown(ComponentEvent e) {} @Override - public void componentResized(ComponentEvent e) { - } + public void componentResized(ComponentEvent e) {} @Override - public void componentMoved(ComponentEvent e) { - } + public void componentMoved(ComponentEvent e) {} } diff --git a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/ButtonRecorder.java b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/ButtonRecorder.java index b0f1300..f5c859e 100644 --- a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/ButtonRecorder.java +++ b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/ButtonRecorder.java @@ -35,6 +35,6 @@ protected Step createClick(Component target, int x, int y, int mods, int count) notify(semanticEvent); ComponentReference cr = getResolver().addComponent(target); - return new Action(getResolver(), null, "actionClick", new String[]{cr.getID()}); + return new Action(getResolver(), null, "actionClick", new String[] {cr.getID()}); } } diff --git a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/CheckboxRecorder.java b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/CheckboxRecorder.java index b040a88..105c815 100644 --- a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/CheckboxRecorder.java +++ b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/CheckboxRecorder.java @@ -37,6 +37,6 @@ protected Step createClick(Component target, int x, int y, int mods, int count) notify(semanticEvent); ComponentReference cr = getResolver().addComponent(target); - return new Action(getResolver(), null, "actionClick", new String[]{cr.getID()}); + return new Action(getResolver(), null, "actionClick", new String[] {cr.getID()}); } } diff --git a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/ChoiceRecorder.java b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/ChoiceRecorder.java index f67ae3d..7c22164 100644 --- a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/ChoiceRecorder.java +++ b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/ChoiceRecorder.java @@ -90,7 +90,7 @@ public void itemStateChanged(ItemEvent ev) { } } else if (event.getID() == KeyEvent.KEY_RELEASED && (((KeyEvent) event).getKeyCode() == KeyEvent.VK_SPACE - || ((KeyEvent) event).getKeyCode() == KeyEvent.VK_ENTER)) { + || ((KeyEvent) event).getKeyCode() == KeyEvent.VK_ENTER)) { Log.debug("enter"); setFinished(true); } else if (event.getID() == KeyEvent.KEY_RELEASED @@ -131,7 +131,7 @@ protected Step createSelection(Choice target, String selection) { getResolver(), null, "actionSelectItem", - new String[]{cr.getID(), selection}, + new String[] {cr.getID(), selection}, java.awt.Choice.class); } } diff --git a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/DialogRecorder.java b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/DialogRecorder.java index b072964..18b7a3e 100644 --- a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/DialogRecorder.java +++ b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/DialogRecorder.java @@ -37,8 +37,8 @@ protected Step createResize(Window window, Dimension size) { getResolver(), null, "actionResize", - new String[]{ - ref.getID(), String.valueOf(size.width), String.valueOf(size.height), + new String[] { + ref.getID(), String.valueOf(size.width), String.valueOf(size.height), }, Dialog.class); } diff --git a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/FileDialogRecorder.java b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/FileDialogRecorder.java index ad949d2..4949072 100644 --- a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/FileDialogRecorder.java +++ b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/FileDialogRecorder.java @@ -99,20 +99,20 @@ protected Step createFileDialogEvents(FileDialog d, String oldDir, String oldFil getResolver(), null, "actionSetDirectory", - new String[]{ref.getID(), dir}, + new String[] {ref.getID(), dir}, FileDialog.class)); } if (accepted) { Step accept = new Action( - getResolver(), null, "actionAccept", new String[]{ref.getID()}, FileDialog.class); + getResolver(), null, "actionAccept", new String[] {ref.getID()}, FileDialog.class); if (fileChanged) { seq.addStep( new Action( getResolver(), null, "actionSetFile", - new String[]{ref.getID(), file}, + new String[] {ref.getID(), file}, FileDialog.class)); seq.addStep(accept); } else { @@ -121,7 +121,7 @@ protected Step createFileDialogEvents(FileDialog d, String oldDir, String oldFil } else { Step cancel = new Action( - getResolver(), null, "actionCancel", new String[]{ref.getID()}, FileDialog.class); + getResolver(), null, "actionCancel", new String[] {ref.getID()}, FileDialog.class); if (dirChanged) { seq.addStep(cancel); } else { diff --git a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/FrameRecorder.java b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/FrameRecorder.java index 0e8ea20..4e07367 100644 --- a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/FrameRecorder.java +++ b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/FrameRecorder.java @@ -78,7 +78,7 @@ protected Step createFrameStateChange(Frame frame, int newState) { getResolver(), null, newState == Frame.NORMAL ? "actionNormalize" : "actionMaximize", - new String[]{ref.getID()}, + new String[] {ref.getID()}, Frame.class); } @@ -92,8 +92,8 @@ protected Step createResize(Window window, Dimension size) { getResolver(), null, "actionResize", - new String[]{ - ref.getID(), String.valueOf(size.width), String.valueOf(size.height), + new String[] { + ref.getID(), String.valueOf(size.width), String.valueOf(size.height), }, Frame.class); } @@ -102,8 +102,7 @@ protected Step createResize(Window window, Dimension size) { protected int getExtendedState(Frame frame) { try { - Integer state = - (Integer) Frame.class.getMethod("getExtendedState").invoke(frame); + Integer state = (Integer) Frame.class.getMethod("getExtendedState").invoke(frame); Log.debug("State is " + state); return state; } catch (Exception e) { diff --git a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JComboBoxRecorder.java b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JComboBoxRecorder.java index 9842013..faa1a6b 100644 --- a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JComboBoxRecorder.java +++ b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JComboBoxRecorder.java @@ -96,18 +96,19 @@ protected boolean parseClick(AWTEvent event) { boolean consumed = true; if (combo == null) { combo = getComboBox(event); - listener = ev -> { - index = combo.getSelectedIndex(); - if (!combo.isPopupVisible()) { - combo.removeActionListener(listener); - setFinished(true); - } - }; + listener = + ev -> { + index = combo.getSelectedIndex(); + if (!combo.isPopupVisible()) { + combo.removeActionListener(listener); + setFinished(true); + } + }; combo.addActionListener(listener); setStatus("Waiting for selection"); } else if (event.getID() == KeyEvent.KEY_RELEASED && (((KeyEvent) event).getKeyCode() == KeyEvent.VK_SPACE - || ((KeyEvent) event).getKeyCode() == KeyEvent.VK_ENTER)) { + || ((KeyEvent) event).getKeyCode() == KeyEvent.VK_ENTER)) { index = combo.getSelectedIndex(); setFinished(true); } @@ -161,7 +162,7 @@ protected Step createSelection(JComboBox combo, int index) { getResolver(), null, "actionSelectIndex", - new String[]{cr.getID(), String.valueOf(index)}, + new String[] {cr.getID(), String.valueOf(index)}, javax.swing.JComboBox.class); } else { step = @@ -169,7 +170,7 @@ protected Step createSelection(JComboBox combo, int index) { getResolver(), null, "actionSelectItem", - new String[]{cr.getID(), value}, + new String[] {cr.getID(), value}, javax.swing.JComboBox.class); // Create semantic event IUISemanticEvent semanticEvent = diff --git a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JComponentRecorder.java b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JComponentRecorder.java index b22f5a0..02d9fe8 100644 --- a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JComponentRecorder.java +++ b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JComponentRecorder.java @@ -136,7 +136,7 @@ protected Step createActionMap(JComponent target, String actionKey) { getResolver(), null, "actionActionMap", - new String[]{cr.getID(), actionKey}, + new String[] {cr.getID(), actionKey}, JComponent.class); } } diff --git a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JInternalFrameRecorder.java b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JInternalFrameRecorder.java index 9279460..c47a418 100644 --- a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JInternalFrameRecorder.java +++ b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JInternalFrameRecorder.java @@ -164,7 +164,7 @@ protected Step createInternalFrameAction(JInternalFrame target, String type) { null, ComponentTester.class.getName(), "assertComponentShowing", - new String[]{ref.getID()}, + new String[] {ref.getID()}, "true", Objects.equals(type, HIDE)); step.setWait(true); @@ -175,7 +175,7 @@ protected Step createInternalFrameAction(JInternalFrame target, String type) { getResolver(), null, "actionMove", - new String[]{ref.getID(), String.valueOf(loc.x), String.valueOf(loc.y)}, + new String[] {ref.getID(), String.valueOf(loc.x), String.valueOf(loc.y)}, JInternalFrame.class); } else if (Objects.equals(type, RESIZE)) { Dimension size = target.getSize(); @@ -183,7 +183,7 @@ protected Step createInternalFrameAction(JInternalFrame target, String type) { getResolver(), null, "actionResize", - new String[]{ref.getID(), String.valueOf(size.width), String.valueOf(size.height)}, + new String[] {ref.getID(), String.valueOf(size.width), String.valueOf(size.height)}, JInternalFrame.class); } else { String action; @@ -197,7 +197,7 @@ protected Step createInternalFrameAction(JInternalFrame target, String type) { } } return new Action( - getResolver(), null, action, new String[]{ref.getID()}, JInternalFrame.class); + getResolver(), null, action, new String[] {ref.getID()}, JInternalFrame.class); } } } diff --git a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JListRecorder.java b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JListRecorder.java index e310291..f5a7691 100644 --- a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JListRecorder.java +++ b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JListRecorder.java @@ -63,10 +63,6 @@ protected Step createClick(Component target, int x, int y, int mods, int count) } } return new Action( - getResolver(), - null, - methodName, - args.toArray(new String[0]), - javax.swing.JList.class); + getResolver(), null, methodName, args.toArray(new String[0]), javax.swing.JList.class); } } diff --git a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JTabbedPaneRecorder.java b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JTabbedPaneRecorder.java index 1728299..b36db5a 100644 --- a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JTabbedPaneRecorder.java +++ b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JTabbedPaneRecorder.java @@ -87,12 +87,12 @@ protected Step createMenuSelection(Component menuItem) { ComponentReference ref = getResolver().addComponent(tabbedPane); ComponentLocation loc = new JTabbedPaneLocation(((JMenuItem) menuItem).getText()); return new Action( - getResolver(), - null, - "actionSelectTab", - new String[]{ - ref.getID(), loc.toString(), - }); + getResolver(), + null, + "actionSelectTab", + new String[] { + ref.getID(), loc.toString(), + }); } @Override @@ -115,8 +115,8 @@ protected Step createClick(Component target, int x, int y, int mods, int count) getResolver(), null, "actionSelectTab", - new String[]{ - cr.getID(), getLocationArgument(tp, x, y), + new String[] { + cr.getID(), getLocationArgument(tp, x, y), }, javax.swing.JTabbedPane.class); } diff --git a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JTableRecorder.java b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JTableRecorder.java index 5dc365b..eb259c8 100644 --- a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JTableRecorder.java +++ b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JTableRecorder.java @@ -87,10 +87,6 @@ protected Step createClick(Component target, int x, int y, int mods, int count) notify(semanticEvent); return new Action( - getResolver(), - null, - methodName, - args.toArray(new String[0]), - javax.swing.JTable.class); + getResolver(), null, methodName, args.toArray(new String[0]), javax.swing.JTable.class); } } diff --git a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JTextComponentRecorder.java b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JTextComponentRecorder.java index cc3b06c..9a64db7 100644 --- a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JTextComponentRecorder.java +++ b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JTextComponentRecorder.java @@ -118,8 +118,8 @@ protected Step createClick(Component comp, int x, int y, int mods, int count) { getResolver(), null, "actionClick", - new String[]{ - cr.getID(), String.valueOf(index), + new String[] { + cr.getID(), String.valueOf(index), }, JTextComponent.class); } else { @@ -134,7 +134,7 @@ protected Step createDrop(Component comp, int start, int end) { getResolver(), null, "actionSelectText", - new String[]{cr.getID(), String.valueOf(start), String.valueOf(end)}, + new String[] {cr.getID(), String.valueOf(start), String.valueOf(end)}, JTextComponent.class); } } diff --git a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JTreeRecorder.java b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JTreeRecorder.java index 07a9acb..57c2297 100644 --- a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JTreeRecorder.java +++ b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/JTreeRecorder.java @@ -77,11 +77,7 @@ protected Step createClick(Component target, int x, int y, int mods, int count) } return new Action( - getResolver(), - null, - methodName, - args.toArray(new String[0]), - javax.swing.JTree.class); + getResolver(), null, methodName, args.toArray(new String[0]), javax.swing.JTree.class); } @Override diff --git a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/WindowRecorder.java b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/WindowRecorder.java index a331324..02dcea4 100644 --- a/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/WindowRecorder.java +++ b/com.windowtester.swing.recorder/src/main/java/com/windowtester/swing/recorder/WindowRecorder.java @@ -48,12 +48,12 @@ protected void init(int recordingType) { @Override protected boolean isWindowEvent(AWTEvent event) { return (event.getSource() instanceof Window - // Checking for window ready avoids picking up - // spurious resize events on first window show - && ((Window) event.getSource()).isShowing() - && WindowTracker.getTracker().isWindowReady((Window) event.getSource()) - && (event.getID() == ComponentEvent.COMPONENT_MOVED - || event.getID() == ComponentEvent.COMPONENT_RESIZED)) + // Checking for window ready avoids picking up + // spurious resize events on first window show + && ((Window) event.getSource()).isShowing() + && WindowTracker.getTracker().isWindowReady((Window) event.getSource()) + && (event.getID() == ComponentEvent.COMPONENT_MOVED + || event.getID() == ComponentEvent.COMPONENT_RESIZED)) || event.getID() == WindowEvent.WINDOW_CLOSING || super.isWindowEvent(event); } @@ -102,7 +102,7 @@ protected Step createClose(Window window) { IUISemanticEvent semanticEvent = UISemanticEventFactory.createShellDisposedEvent(window); notify(semanticEvent); - return new Action(getResolver(), null, "actionClose", new String[]{ref.getID()}, Window.class); + return new Action(getResolver(), null, "actionClose", new String[] {ref.getID()}, Window.class); } protected Step createMove(Window window, Point where) { @@ -116,7 +116,7 @@ protected Step createMove(Window window, Point where) { getResolver(), null, "actionMove", - new String[]{ref.getID(), String.valueOf(where.x), String.valueOf(where.y)}, + new String[] {ref.getID(), String.valueOf(where.x), String.valueOf(where.y)}, Window.class); } @@ -131,8 +131,8 @@ protected Step createResize(Window window, Dimension size) { getResolver(), null, "actionResize", - new String[]{ - ref.getID(), String.valueOf(size.width), String.valueOf(size.height), + new String[] { + ref.getID(), String.valueOf(size.width), String.valueOf(size.height), }, Window.class); } diff --git a/com.windowtester.swing.recorder/src/test/java/util/SwingEventRecordingJig.java b/com.windowtester.swing.recorder/src/test/java/util/SwingEventRecordingJig.java index 910bbef..869d1c6 100644 --- a/com.windowtester.swing.recorder/src/test/java/util/SwingEventRecordingJig.java +++ b/com.windowtester.swing.recorder/src/test/java/util/SwingEventRecordingJig.java @@ -54,32 +54,32 @@ public void windowClosing(WindowEvent w) { } }; -// public SwingEventRecordingJig() { + // public SwingEventRecordingJig() { - // super(DialogDemo.class); - // super(ContactManagerSwing.class); - // super(EditorSample.class); + // super(DialogDemo.class); + // super(ContactManagerSwing.class); + // super(EditorSample.class); - // super(swing.samples.SwingText.class); - // super(swing.samples.SwingMenus.class); - // super(swing.samples.TestTree.class); + // super(swing.samples.SwingText.class); + // super(swing.samples.SwingMenus.class); + // super(swing.samples.TestTree.class); - // super(swing.samples.DialogDemo.class); //test dialogs <-- TabPanes... - // super(TextInputDemo.class); - // DONE: - // super(swing.samples.SwingTree.class); //test trees - // super(swing.samples.SwingList.class); //test lists - // super(swing.samples.ComboBoxes.class); //test combos - // super(swing.samples.SimpleTable.class); //test tables - // super(swing.samples.SwingTables.class); - // super(DatePickerSample.class); - // super(DateFieldSample.class); - // super(swing.samples.TextComponentDemo.class); - // super(TextComponentDemo.class); - // super(swing.samples.UseTheSampleDialog.class); - // super(swing.samples.JListRendererDemo.class); -// System.out.println("Application opened"); -// } + // super(swing.samples.DialogDemo.class); //test dialogs <-- TabPanes... + // super(TextInputDemo.class); + // DONE: + // super(swing.samples.SwingTree.class); //test trees + // super(swing.samples.SwingList.class); //test lists + // super(swing.samples.ComboBoxes.class); //test combos + // super(swing.samples.SimpleTable.class); //test tables + // super(swing.samples.SwingTables.class); + // super(DatePickerSample.class); + // super(DateFieldSample.class); + // super(swing.samples.TextComponentDemo.class); + // super(TextComponentDemo.class); + // super(swing.samples.UseTheSampleDialog.class); + // super(swing.samples.JListRendererDemo.class); + // System.out.println("Application opened"); + // } @Test public void testDrive() throws WidgetSearchException { diff --git a/com.windowtester.swing.runtime/pom.xml b/com.windowtester.swing.runtime/pom.xml index 7fd089d..b8cf867 100644 --- a/com.windowtester.swing.runtime/pom.xml +++ b/com.windowtester.swing.runtime/pom.xml @@ -5,7 +5,7 @@ io.github.r4fterman com.windowtester - 6.0.0-SNAPSHOT + 6.0.1-SNAPSHOT com.windowtester.swing.runtime @@ -39,4 +39,16 @@ test + + + + + dev.dimlight + shellcheck-maven-plugin + + true + + + + diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/finder/matchers/swing/HierarchyMatcher.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/finder/matchers/swing/HierarchyMatcher.java index 8561474..6e11ec4 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/finder/matchers/swing/HierarchyMatcher.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/finder/matchers/swing/HierarchyMatcher.java @@ -130,8 +130,9 @@ public HierarchyMatcher(Class cls, String nameOrLabel, Matcher parentMatcher) */ public HierarchyMatcher(Class cls, String nameOrLabel, int index, Matcher parentMatcher) { this( - index, new CompositeMatcher( - new Matcher[]{new ClassMatcher(cls), new NameOrLabelMatcher(nameOrLabel)}), + index, + new CompositeMatcher( + new Matcher[] {new ClassMatcher(cls), new NameOrLabelMatcher(nameOrLabel)}), parentMatcher); } @@ -160,7 +161,8 @@ public HierarchyMatcher(Class cls, int index, Matcher parentMatcher) { // // Matching // - /// //////////////////////////////////////////////////////////////////////////////////////////////// + /// + // //////////////////////////////////////////////////////////////////////////////////////////////// @Override public boolean matches(Component component) { @@ -182,8 +184,10 @@ public boolean matches(Component component) { matches = matcher.matches(component); } - if (parent != null && matcher.matches(component) - && parentMatcher != null && parentMatcher.matches(parent)) { + if (parent != null + && matcher.matches(component) + && parentMatcher != null + && parentMatcher.matches(parent)) { int indexRelativeToParent = infoService.getIndex(component, parent); matches = indexRelativeToParent == index; } diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/finder/matchers/swing/TreePathMatcher.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/finder/matchers/swing/TreePathMatcher.java index 1074fd7..0b7473e 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/finder/matchers/swing/TreePathMatcher.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/finder/matchers/swing/TreePathMatcher.java @@ -30,8 +30,7 @@ public boolean matches(Component component) { } private boolean searchTreeNode( - List treeNodes, - Iterator searchIterator) { + List treeNodes, Iterator searchIterator) { var nodeName = searchIterator.next(); for (DefaultMutableTreeNode treeNode : treeNodes) { if (treeNode.toString().equalsIgnoreCase(nodeName)) { diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/finder/swing/SwingWidgetFinder.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/finder/swing/SwingWidgetFinder.java index a17215a..185c30b 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/finder/swing/SwingWidgetFinder.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/finder/swing/SwingWidgetFinder.java @@ -83,13 +83,11 @@ private boolean isMatchingWindow(Window window) { } // check to see whether (ALL) frame owns any windows - return Arrays.stream(window.getOwnedWindows()) - .anyMatch(this::isMatchingWindow); + return Arrays.stream(window.getOwnedWindows()).anyMatch(this::isMatchingWindow); } private void findMatches(Matcher matcher, Component component, Set found) { - hierarchy.getComponents(component) - .forEach(comp -> findMatches(matcher, comp, found)); + hierarchy.getComponents(component).forEach(comp -> findMatches(matcher, comp, found)); if (matcher.matches(component)) { found.add(component); diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/DelayUIDriverSwing.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/DelayUIDriverSwing.java index fb16767..1bd7083 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/DelayUIDriverSwing.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/DelayUIDriverSwing.java @@ -32,12 +32,7 @@ public DelayUIDriverSwing() { } @Override - public Component click( - int clickCount, - Component component, - int x, - int y, - int mask) { + public Component click(int clickCount, Component component, int x, int y, int mask) { // first move the mouse to the point of interest: mouseMove(component); return super.click(clickCount, component, x, y, mask); @@ -61,11 +56,7 @@ public Component clickListItem(int clickCount, JList list, String labelOrPath @Override public Component clickTable( - int clickCount, - JTable table, - int rowIndex, - int columnIndex, - int mask) { + int clickCount, JTable table, int rowIndex, int columnIndex, int mask) { mouseMove(table); return super.clickTable(clickCount, table, rowIndex, columnIndex, mask); } diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/UIContextSwing.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/UIContextSwing.java index d4b9f80..6d03e86 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/UIContextSwing.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/UIContextSwing.java @@ -55,44 +55,36 @@ public class UIContextSwing extends UIContextCommon { private IUIThreadMonitor threadMonitor; @Override - public IWidgetLocator click( - int clickCount, - ILocator locator, - int buttonMask) throws WidgetSearchException { + public IWidgetLocator click(int clickCount, ILocator locator, int buttonMask) + throws WidgetSearchException { handleConditions(); return super.click(clickCount, locator, buttonMask); } @Override - public IWidgetLocator contextClick( - ILocator locator, - IMenuItemLocator menuItem, - int modifierMask) throws WidgetSearchException { + public IWidgetLocator contextClick(ILocator locator, IMenuItemLocator menuItem, int modifierMask) + throws WidgetSearchException { handleConditions(); return super.contextClick(locator, menuItem, modifierMask); } @Override - public IWidgetLocator contextClick( - ILocator locator, - IMenuItemLocator menuItem) throws WidgetSearchException { + public IWidgetLocator contextClick(ILocator locator, IMenuItemLocator menuItem) + throws WidgetSearchException { handleConditions(); return super.contextClick(locator, menuItem); } @Override - public IWidgetLocator contextClick( - ILocator locator, - String menuItem, - int modifierMask) throws WidgetSearchException { + public IWidgetLocator contextClick(ILocator locator, String menuItem, int modifierMask) + throws WidgetSearchException { handleConditions(); return super.contextClick(locator, menuItem, modifierMask); } @Override - public IWidgetLocator contextClick( - ILocator locator, - String menuItem) throws WidgetSearchException { + public IWidgetLocator contextClick(ILocator locator, String menuItem) + throws WidgetSearchException { handleConditions(); return super.contextClick(locator, menuItem); } @@ -122,8 +114,8 @@ private Point findPoint(ILocator locator, Component component) { return getDriver().getLocation(component, path); } if (locator instanceof JTableItemLocator tableItemLocator) { - return getDriver().getLocation(component, tableItemLocator.getRow(), - tableItemLocator.getColumn()); + return getDriver() + .getLocation(component, tableItemLocator.getRow(), tableItemLocator.getColumn()); } if (locator instanceof JTextComponentLocator textComponentLocator) { return getDriver().getLocation(component, textComponentLocator.getCaretPosition()); @@ -132,9 +124,7 @@ private Point findPoint(ILocator locator, Component component) { } @Override - public IWidgetLocator dragTo( - ILocator locator, - int buttonMask) throws WidgetSearchException { + public IWidgetLocator dragTo(ILocator locator, int buttonMask) throws WidgetSearchException { try { getDriver().mouseDown(buttonMask); return dragTo(locator); @@ -169,10 +159,11 @@ public void keyClick(int ctrl, char c) { @Override public void close(IWidgetLocator locator) { - var window = getWidgetReference(locator) - .filter(widgetReference -> widgetReference.getWidget() instanceof Window) - .map(widgetReference -> (Window) widgetReference.getWidget()) - .orElseThrow(UnsupportedOperationException::new); + var window = + getWidgetReference(locator) + .filter(widgetReference -> widgetReference.getWidget() instanceof Window) + .map(widgetReference -> (Window) widgetReference.getWidget()) + .orElseThrow(UnsupportedOperationException::new); getDriver().close(window); } @@ -198,10 +189,7 @@ public void wait(ICondition condition, long timeout) throws WaitTimedOutExceptio } @Override - public void wait( - ICondition condition, - long timeout, - int interval) throws WaitTimedOutException { + public void wait(ICondition condition, long timeout, int interval) throws WaitTimedOutException { if (threadMonitor != null) { threadMonitor.expectDelay(timeout); } @@ -275,18 +263,17 @@ private void takeScreenShot() { * @return a abbot.script.Condition */ private Condition getAbbotCondition(ICondition condition) { - return - new Condition() { - @Override - public boolean test() { - return ConditionMonitor.test(UIContextSwing.this, condition); - } - - @Override - public String toString() { - return condition.toString(); - } - }; + return new Condition() { + @Override + public boolean test() { + return ConditionMonitor.test(UIContextSwing.this, condition); + } + + @Override + public String toString() { + return condition.toString(); + } + }; } public UIDriverSwing getDriver() { diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/UIDriverSwing.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/UIDriverSwing.java index 39aef99..334f323 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/UIDriverSwing.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/UIDriverSwing.java @@ -87,12 +87,7 @@ public UIDriverSwing() { ComponentTester.setTester(JTable.class, new JTableTester()); } - public Component click( - int clickCount, - Component component, - int x, - int y, - int mask) { + public Component click(int clickCount, Component component, int x, int y, int mask) { var tester = ComponentTester.getTester(component); dragSource = component; dragSrcX = x; @@ -102,9 +97,7 @@ public Component click( return component; } - public Component click( - Component component, - String labelOrPath) throws ActionFailedException { + public Component click(Component component, String labelOrPath) throws ActionFailedException { // not checking for awt.MenuItem, not a subclass of Component var tester = ComponentTester.getTester(component); dragSource = component; @@ -167,11 +160,8 @@ public Component clickMenuItem(JMenuItem owner) { return owner; } - public Component clickListItem( - int clickCount, - JList list, - String labelOrPath, - int mask) throws ActionFailedException { + public Component clickListItem(int clickCount, JList list, String labelOrPath, int mask) + throws ActionFailedException { var tester = ComponentTester.getTester(list); dragSource = list; var location = new JListLocation(labelOrPath); @@ -182,16 +172,14 @@ public Component clickListItem( return list; } - public Component clickComboBox( - JComboBox combobox, - String labelOrPath, - int clickCount) throws ActionFailedException { + public Component clickComboBox(JComboBox combobox, String labelOrPath, int clickCount) + throws ActionFailedException { var tester = ComponentTester.getTester(combobox); if (labelOrPath != null) { ((JComboBoxTester) tester).actionSelectItem(combobox, labelOrPath); } else { - tester.actionClick(combobox, new ComponentLocation(), InputEvent.BUTTON1_DOWN_MASK, - clickCount); + tester.actionClick( + combobox, new ComponentLocation(), InputEvent.BUTTON1_DOWN_MASK, clickCount); } return combobox; } @@ -270,11 +258,7 @@ public Component contextClickTree(JTree tree, String itemPath, String menuPath) * @throws ComponentMissingException in case of error * @throws ActionFailedException in case of error */ - public Component contextClickTable( - JTable table, - int rowIndex, - int columnIndex, - String menuPath) + public Component contextClickTable(JTable table, int rowIndex, int columnIndex, String menuPath) throws ComponentMissingException, ActionFailedException { var tester = ComponentTester.getTester(table); var location = new JTableLocation(rowIndex, columnIndex); @@ -465,12 +449,10 @@ public String toString() { private boolean assertComponentShowing(String title) { var components = collectComponents(); for (Component component : components) { - if (component instanceof Frame frame - && isFrameShowing(title, frame)) { + if (component instanceof Frame frame && isFrameShowing(title, frame)) { return true; } - if (component instanceof Dialog dialog - && isDialogShowing(title, dialog)) { + if (component instanceof Dialog dialog && isDialogShowing(title, dialog)) { return true; } } @@ -487,10 +469,7 @@ private boolean isFrameShowing(String expectedTitle, Frame window) { return isComponentShowing(expectedTitle, actualTitle, window); } - private boolean isComponentShowing( - String expectedTitle, - String actualTitle, - Window window) { + private boolean isComponentShowing(String expectedTitle, String actualTitle, Window window) { return StringComparator.matches(actualTitle, expectedTitle) && window.isDisplayable() && window.isVisible() @@ -499,16 +478,13 @@ private boolean isComponentShowing( private List collectComponents() { var hierarchy = new AWTHierarchy(); - var components = hierarchy.getRoots().stream() - .map(hierarchy::getComponents) - .flatMap(Collection::stream) - .toList(); - - return Stream - .concat( - components.stream(), - hierarchy.getRoots().stream()) - .toList(); + var components = + hierarchy.getRoots().stream() + .map(hierarchy::getComponents) + .flatMap(Collection::stream) + .toList(); + + return Stream.concat(components.stream(), hierarchy.getRoots().stream()).toList(); } public void pause(int ms) { diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/WidgetLocatorService.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/WidgetLocatorService.java index c8abe6c..8bc0e5c 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/WidgetLocatorService.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/WidgetLocatorService.java @@ -38,8 +38,7 @@ public class WidgetLocatorService { // a list of keys which we want to propagate to locators private static final String[] INTERESTING_KEYS = {}; - private final IWidgetIdentifierStrategy widgetIdentifier = - new ScopedComponentIdentifierBuilder(); + private final IWidgetIdentifierStrategy widgetIdentifier = new ScopedComponentIdentifierBuilder(); /** * Generate a Matcher that can be used to identify the widget described by this WidgetLocator @@ -149,8 +148,7 @@ private void addCheck(Collection dest, Collection src) { * @return the widget's text */ public String getWidgetText(Component component) { - if (component instanceof AbstractButton button - && !(component instanceof JMenuItem)) { + if (component instanceof AbstractButton button && !(component instanceof JMenuItem)) { return button.getText(); } if (component instanceof JLabel label) { @@ -197,8 +195,7 @@ private SwingWidgetLocator getInfo(Component component) { } private static SwingWidgetLocator getSwingWidgetLocator( - String text, - Class cls) { + String text, Class cls) { if (text != null) { return new SwingWidgetLocator(cls, text); } diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/locator/BasicFinder2.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/locator/BasicFinder2.java index e232e47..72357d1 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/locator/BasicFinder2.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/locator/BasicFinder2.java @@ -64,8 +64,7 @@ public Container getParent(Component component) { } public boolean contains(Component component) { - return getHierarchy().contains(component) - && SwingUtilities.isDescendingFrom(component, root); + return getHierarchy().contains(component) && SwingUtilities.isDescendingFrom(component, root); } public void dispose(Window window) { @@ -92,9 +91,7 @@ protected Hierarchy getHierarchy() { @Override public Component find(Container root, Matcher matcher) throws ComponentNotFoundException, MultipleComponentsFoundException { - var hierarchy = root != null - ? new SingleComponentHierarchy(root) - : getHierarchy(); + var hierarchy = root != null ? new SingleComponentHierarchy(root) : getHierarchy(); return find(hierarchy, matcher); } @@ -128,10 +125,7 @@ protected Component find(Hierarchy hierarchy, Matcher matcher) } protected void findMatches( - Hierarchy hierarchy, - Matcher matcher, - Component component, - Set found) { + Hierarchy hierarchy, Matcher matcher, Component component, Set found) { if (found.size() == 1 && !(matcher instanceof MultiMatcher)) { return; } @@ -171,10 +165,7 @@ protected int findAll(Hierarchy hierarchy, Matcher matcher) { } protected void findMatchesAll( - Hierarchy hierarchy, - Matcher matcher, - Component component, - Set found) { + Hierarchy hierarchy, Matcher matcher, Component component, Set found) { for (Component comp : hierarchy.getComponents(component)) { findMatchesAll(hierarchy, matcher, comp, found); } diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/locator/MatcherFactory.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/locator/MatcherFactory.java index 98b40fe..4f74318 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/locator/MatcherFactory.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/locator/MatcherFactory.java @@ -83,20 +83,15 @@ private static Matcher getTargetMatcher(WidgetLocator locator) { return new ClassMatcher(cls); } return new CompositeMatcher( - new Matcher[]{ - new ClassMatcher(cls), - new NameOrLabelMatcher(nameOrLabel) - } - ); + new Matcher[] {new ClassMatcher(cls), new NameOrLabelMatcher(nameOrLabel)}); } if (nameOrLabel == null) { return new IndexMatcher(new ClassMatcher(cls), index); } return new CompositeMatcher( - new Matcher[]{ - new ClassMatcher(cls), - new IndexMatcher(new NameOrLabelMatcher(nameOrLabel), index) + new Matcher[] { + new ClassMatcher(cls), new IndexMatcher(new NameOrLabelMatcher(nameOrLabel), index) }); } diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/locator/WidgetLocatorFactory.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/locator/WidgetLocatorFactory.java index 1d3b951..5b718fc 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/locator/WidgetLocatorFactory.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/locator/WidgetLocatorFactory.java @@ -106,8 +106,7 @@ private Optional getLabeledText(Component component) { } private boolean isCorrectComponent(JLabel label, Component component) { - return label.getClass().equals(component.getClass()) - && label == component; + return label.getClass().equals(component.getClass()) && label == component; } private SwingWidgetLocator createDefaultLocator(Component component) { diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/matcher/HierarchyMatcher.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/matcher/HierarchyMatcher.java index 307e547..25a5038 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/matcher/HierarchyMatcher.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/matcher/HierarchyMatcher.java @@ -23,27 +23,21 @@ private HierarchyMatcher() { } public static IWidgetMatcher create( - IWidgetMatcher targetMatcher, - IWidgetMatcher parentMatcher) { + IWidgetMatcher targetMatcher, IWidgetMatcher parentMatcher) { return new AdapterFactory() .adapt( new com.windowtester.internal.finder.matchers.swing.HierarchyMatcher( new AdapterFactory().adapt(targetMatcher), - new AdapterFactory().adapt(parentMatcher) - ) - ); + new AdapterFactory().adapt(parentMatcher))); } public static IWidgetMatcher create( - IWidgetMatcher targetMatcher, - IWidgetMatcher parentMatcher, - int index) { + IWidgetMatcher targetMatcher, IWidgetMatcher parentMatcher, int index) { return new AdapterFactory() .adapt( new com.windowtester.internal.finder.matchers.swing.HierarchyMatcher( - index, new AdapterFactory().adapt(targetMatcher), - new AdapterFactory().adapt(parentMatcher) - ) - ); + index, + new AdapterFactory().adapt(targetMatcher), + new AdapterFactory().adapt(parentMatcher))); } } diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/util/ComponentAccessor.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/util/ComponentAccessor.java index 6b4b03f..73da29d 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/util/ComponentAccessor.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/util/ComponentAccessor.java @@ -30,8 +30,8 @@ public class ComponentAccessor { private static final Hierarchy HIERARCHY = AWTHierarchy.getDefault(); - private static final ComponentTester COMPONENT_TESTER = ComponentTester.getTester( - JMenuItem.class); + private static final ComponentTester COMPONENT_TESTER = + ComponentTester.getTester(JMenuItem.class); /** * Find the topmost parent menu item. @@ -45,8 +45,7 @@ public static JMenu getRootMenu(JMenuItem child) { parent = AWT.getInvoker(popup); } - while (parent instanceof JMenu menu - && !menu.isTopLevelMenu()) { + while (parent instanceof JMenu menu && !menu.isTopLevelMenu()) { popup = parent.getParent(); if (popup instanceof JPopupMenu) { parent = AWT.getInvoker(popup); @@ -182,9 +181,7 @@ public static String[] parseTreePath(String input) { public static String assemblePath(String[] nodeNames) { var path = new StringBuilder(); for (int i = 0; i < nodeNames.length - 1; i++) { - path - .append(nodeNames[i]) - .append("/"); + path.append(nodeNames[i]).append("/"); } path.append(nodeNames[nodeNames.length - 1]); return path.toString(); diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/util/KeyStrokeDecoder.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/util/KeyStrokeDecoder.java index da01114..7ef24f6 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/util/KeyStrokeDecoder.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/util/KeyStrokeDecoder.java @@ -54,11 +54,15 @@ public class KeyStrokeDecoder { }; private static final int[] KEY_MODS = { - InputEvent.ALT_DOWN_MASK, InputEvent.SHIFT_DOWN_MASK, Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx() + InputEvent.ALT_DOWN_MASK, + InputEvent.SHIFT_DOWN_MASK, + Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx() }; private static final int MODIFIER_MASK = - InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(); + InputEvent.ALT_DOWN_MASK + | InputEvent.SHIFT_DOWN_MASK + | Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx(); public static int extractModifiers(int compositeKey) { int modifiers = 0; @@ -83,9 +87,7 @@ public static int[] extractKeys(int compositeKey) { } private static int[] toIntArray(List keys) { - return keys.stream() - .mapToInt(i -> i) - .toArray(); + return keys.stream().mapToInt(i -> i).toArray(); } private KeyStrokeDecoder() { diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/util/TextUtils.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/util/TextUtils.java index 8cf91d6..533dc1c 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/util/TextUtils.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/swing/util/TextUtils.java @@ -41,5 +41,4 @@ public static String fixTabs(String text) { public static String escapeSlashes(String text) { return text.replace("/", "\\\\\\\\/"); } - } diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/tester/swing/JListTester.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/tester/swing/JListTester.java index 1184fd8..a28adb2 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/tester/swing/JListTester.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/tester/swing/JListTester.java @@ -46,7 +46,7 @@ public void actionSelectRow(Component component, JListLocation location, int but var list = (JList) component; var index = location.getIndex(list); if (index < 0 || index >= list.getModel().getSize()) { - var msg = Strings.get("tester.JList.invalid_index", new Object[]{index}); + var msg = Strings.get("tester.JList.invalid_index", new Object[] {index}); throw new ActionFailedException(msg); } @@ -66,11 +66,7 @@ public void actionMultipleClick(Component component, int clickCount, String item /** * click with mask specified */ - public void actionMultipleClick( - Component component, - int clickCount, - String item, - int mask) { + public void actionMultipleClick(Component component, int clickCount, String item, int mask) { actionSelectRow(component, clickCount, new JListLocation(item), mask); } @@ -78,14 +74,11 @@ public void actionMultipleClick( * click on the given row, with the given clickCount */ public void actionSelectRow( - Component component, - int clickCount, - JListLocation location, - int mask) { + Component component, int clickCount, JListLocation location, int mask) { var list = (JList) component; var index = location.getIndex(list); if (index < 0 || index >= list.getModel().getSize()) { - var msg = Strings.get("tester.JList.invalid_index", new Object[]{index}); + var msg = Strings.get("tester.JList.invalid_index", new Object[] {index}); throw new ActionFailedException(msg); } diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/tester/swing/JTableTester.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/tester/swing/JTableTester.java index 7e94e3b..948d40a 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/tester/swing/JTableTester.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/tester/swing/JTableTester.java @@ -45,11 +45,7 @@ public void actionSelectCell(Component component, JTableLocation location, int m /** * double-click the given cell, if not already. */ - public void actionSelectCell( - int count, - Component component, - JTableLocation location, - int mask) { + public void actionSelectCell(int count, Component component, JTableLocation location, int mask) { var table = (JTable) component; var cell = location.getCell(table); if (table.isRowSelected(cell.row) @@ -64,11 +60,7 @@ public void actionSelectCell( * Select the given cell, if not already. Equivalent to actionSelectCell(component, new * JTableLocation(rowIndex, columnIndex)). */ - public void actionSelectCell( - Component component, - int rowIndex, - int columnIndex, - int mask) { + public void actionSelectCell(Component component, int rowIndex, int columnIndex, int mask) { actionSelectCell(component, new JTableLocation(rowIndex, columnIndex), mask); } } diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/tester/swing/JTreeTester.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/tester/swing/JTreeTester.java index 7c1966b..50873ad 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/tester/swing/JTreeTester.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/internal/tester/swing/JTreeTester.java @@ -27,11 +27,7 @@ public class JTreeTester extends abbot.tester.JTreeTester { /** * Select the given path, expanding parent nodes if necessary. */ - public void actionSelectPath( - int clickCount, - Component component, - TreePath path, - int buttons) { + public void actionSelectPath(int clickCount, Component component, TreePath path, int buttons) { actionSelectRow(clickCount, component, new JTreeLocation(path), buttons); } @@ -39,15 +35,12 @@ public void actionSelectPath( * Select the given row. If the row is already selected, does nothing. */ public void actionSelectRow( - int clickCount, - Component component, - ComponentLocation location, - int buttons) { + int clickCount, Component component, ComponentLocation location, int buttons) { var tree = (JTree) component; if (location instanceof JTreeLocation jTreeLocation) { var path = jTreeLocation.getPath((JTree) component); if (path == null) { - var msg = Strings.get("tester.JTree.path_not_found", new Object[]{location}); + var msg = Strings.get("tester.JTree.path_not_found", new Object[] {location}); throw new LocationUnavailableException(msg); } makeVisible(component, path); diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/SwingWidgetLocator.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/SwingWidgetLocator.java index edf33fd..788b6a5 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/SwingWidgetLocator.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/SwingWidgetLocator.java @@ -62,8 +62,8 @@ * A class that captures Swing hierarchy (containment) relationships between widgets for use in * widget identification. */ -public class SwingWidgetLocator extends com.windowtester.runtime.WidgetLocator implements - IUISelector, IDiagnosticParticipant, IsVisible { +public class SwingWidgetLocator extends com.windowtester.runtime.WidgetLocator + implements IUISelector, IDiagnosticParticipant, IsVisible { /* * NOTE: this class is serializable and uses the default serialization scheme. @@ -76,8 +76,7 @@ public class SwingWidgetLocator extends com.windowtester.runtime.WidgetLocator i * for use in codegen. That said, we might remedy this in the future by, * for instance, making the matcher lazily initialized. */ - @Serial - private static final long serialVersionUID = -6896731161658482507L; + @Serial private static final long serialVersionUID = -6896731161658482507L; /** * Delegate matcher NOTICE: the matcher is transient. @@ -199,10 +198,7 @@ public SwingWidgetLocator(Class cls, String nameOrLabel, SwingWidgetLocator p * @param parent - the target's parent info */ public SwingWidgetLocator( - Class cls, - String nameOrLabel, - int index, - SwingWidgetLocator parent) { + Class cls, String nameOrLabel, int index, SwingWidgetLocator parent) { super(cls, nameOrLabel, index, parent); // create the matcher // components such as buttons, lists and tables are matched by whether they are @@ -211,10 +207,7 @@ public SwingWidgetLocator( } private IWidgetMatcher createMatcher( - Class cls, - String nameOrLabel, - int index, - SwingWidgetLocator parent) { + Class cls, String nameOrLabel, int index, SwingWidgetLocator parent) { IWidgetMatcher matcher = null; if (cls != null) { matcher = getClassMatcher(cls); @@ -239,8 +232,9 @@ private IWidgetMatcher createMatcher( return matcher; } - var msg = String.format("Unable to create matcher for class=%s, index=%d, parent=%s", - cls, index, parent); + var msg = + String.format( + "Unable to create matcher for class=%s, index=%d, parent=%s", cls, index, parent); throw new IllegalArgumentException(msg); } @@ -293,10 +287,8 @@ protected Component findComponent(IUIContext ui) throws WidgetSearchException { } @Override - public IWidgetLocator click( - IUIContext ui, - IWidgetReference widget, - IClickDescription click) throws WidgetSearchException { + public IWidgetLocator click(IUIContext ui, IWidgetReference widget, IClickDescription click) + throws WidgetSearchException { var component = (Component) widget.getWidget(); var offset = getXYOffset(component, click); var clicked = doClick(ui, click.clicks(), component, offset, click.modifierMask()); @@ -312,21 +304,16 @@ public IWidgetLocator click( * @return the clicked widget */ protected Component doClick( - IUIContext ui, - int clicks, - Component component, - Point offset, - int modifierMask) { - return ((UIContextSwing) ui).getDriver() + IUIContext ui, int clicks, Component component, Point offset, int modifierMask) { + return ((UIContextSwing) ui) + .getDriver() .click(clicks, component, offset.x, offset.y, modifierMask); } @Override public IWidgetLocator contextClick( - IUIContext ui, - IWidgetReference widget, - IClickDescription click, - String menuItemPath) throws WidgetSearchException { + IUIContext ui, IWidgetReference widget, IClickDescription click, String menuItemPath) + throws WidgetSearchException { var component = (Component) widget.getWidget(); // TODO: hook up xys var clicked = ((UIContextSwing) ui).getDriver().contextClick(component, menuItemPath); @@ -359,21 +346,21 @@ protected boolean unspecifiedXY(IClickDescription click) { @Override public void diagnose(IDiagnostic diagnostic) { var hierarchy = AWTHierarchy.getDefault(); - hierarchy.getRoots().forEach(component -> { - if (((Window) component).isActive()) { - getAllChildren(component, hierarchy, diagnostic); - } else { - diagnoseAllChildren(component, hierarchy, diagnostic); - } - }); + hierarchy + .getRoots() + .forEach( + component -> { + if (((Window) component).isActive()) { + getAllChildren(component, hierarchy, diagnostic); + } else { + diagnoseAllChildren(component, hierarchy, diagnostic); + } + }); } private void diagnoseAllChildren( - Component component, - Hierarchy hierarchy, - IDiagnostic diagnostic) { - if (!component.getClass().getName() - .equals("javax.swing.SwingUtilities$SharedOwnerFrame")) { + Component component, Hierarchy hierarchy, IDiagnostic diagnostic) { + if (!component.getClass().getName().equals("javax.swing.SwingUtilities$SharedOwnerFrame")) { return; } @@ -383,12 +370,8 @@ private void diagnoseAllChildren( .forEach(window -> getAllChildren(window, hierarchy, diagnostic)); } - private void getAllChildren( - Component component, - Hierarchy hierarchy, - IDiagnostic diagnostic) { - hierarchy.getComponents(component) - .forEach(c -> getAllChildren(c, hierarchy, diagnostic)); + private void getAllChildren(Component component, Hierarchy hierarchy, IDiagnostic diagnostic) { + hierarchy.getComponents(component).forEach(c -> getAllChildren(c, hierarchy, diagnostic)); if (component instanceof Frame || component instanceof Dialog) { diagnostic.attribute("class", component.getClass().toString()); diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/condition/WindowDisposedCondition.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/condition/WindowDisposedCondition.java index f690b37..efe5bd6 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/condition/WindowDisposedCondition.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/condition/WindowDisposedCondition.java @@ -88,15 +88,12 @@ private boolean isMatchingFrame(String title, Component component) { private List collectComponents() { var hierarchy = new AWTHierarchy(); - var components = hierarchy.getRoots().stream() - .map(hierarchy::getComponents) - .flatMap(Collection::stream) - .toList(); + var components = + hierarchy.getRoots().stream() + .map(hierarchy::getComponents) + .flatMap(Collection::stream) + .toList(); - return Stream - .concat( - components.stream(), - hierarchy.getRoots().stream()) - .toList(); + return Stream.concat(components.stream(), hierarchy.getRoots().stream()).toList(); } } diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/internal/junit/SwingExecutionMonitor.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/internal/junit/SwingExecutionMonitor.java index f8c2808..3c13117 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/internal/junit/SwingExecutionMonitor.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/internal/junit/SwingExecutionMonitor.java @@ -72,8 +72,7 @@ public void testStarting(ITestIdentifier identifier) { } @Override - protected void doWaitForFinish() { - } + protected void doWaitForFinish() {} @Override protected boolean terminateWaitForFinish() { diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/AbstractPathLocator.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/AbstractPathLocator.java index 44f1ebe..ebb0d5b 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/AbstractPathLocator.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/AbstractPathLocator.java @@ -36,8 +36,7 @@ */ public abstract class AbstractPathLocator extends SwingWidgetLocator implements IPathLocator { - @Serial - private static final long serialVersionUID = 4463096378279721331L; + @Serial private static final long serialVersionUID = 4463096378279721331L; private String path; @@ -53,8 +52,8 @@ public AbstractPathLocator(Class cls, String path, SwingWidgetLocator parentI this(cls, getLabel(path), path, parentInfo); } - public AbstractPathLocator(Class cls, String itemText, String path, - SwingWidgetLocator parentInfo) { + public AbstractPathLocator( + Class cls, String itemText, String path, SwingWidgetLocator parentInfo) { this(cls, itemText, path, UNASSIGNED, parentInfo); } @@ -62,17 +61,14 @@ public AbstractPathLocator(Class cls, String path, int index, SwingWidgetLoca this(cls, getLabel(path), path, index, parentInfo); } - public AbstractPathLocator(Class cls, String itemText, String path, int index, - SwingWidgetLocator parentInfo) { + public AbstractPathLocator( + Class cls, String itemText, String path, int index, SwingWidgetLocator parentInfo) { super(cls, itemText, index, parentInfo); this.path = path; this.matcher = createMatcher(cls, index, parentInfo); } - private IWidgetMatcher createMatcher( - Class cls, - int index, - SwingWidgetLocator parent) { + private IWidgetMatcher createMatcher(Class cls, int index, SwingWidgetLocator parent) { IWidgetMatcher matcher = null; if (this instanceof JListLocator || this instanceof JTreeItemLocator) { matcher = ClassMatcher.create(cls); @@ -107,8 +103,9 @@ private IWidgetMatcher createMatcher( return matcher; } - var msg = String.format("Unable to create matcher for class=%s, index=%d, parent=%s", - cls, index, parent); + var msg = + String.format( + "Unable to create matcher for class=%s, index=%d, parent=%s", cls, index, parent); throw new IllegalArgumentException(msg); } @@ -147,10 +144,8 @@ public void setPath(String pathString) { */ @Override public IWidgetLocator contextClick( - IUIContext ui, - IWidgetReference widget, - IClickDescription click, - String menuItemPath) throws WidgetSearchException { + IUIContext ui, IWidgetReference widget, IClickDescription click, String menuItemPath) + throws WidgetSearchException { var component = (Component) widget.getWidget(); var clicked = ((UIContextSwing) ui).getDriver().contextClick(component, menuItemPath); return WidgetReference.create(clicked, this); diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JCheckBoxLocator.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JCheckBoxLocator.java index 70d6de4..28d5053 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JCheckBoxLocator.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JCheckBoxLocator.java @@ -31,8 +31,7 @@ */ public class JCheckBoxLocator extends SwingWidgetLocator implements HasText, IsEnabled, IsSelected { - @Serial - private static final long serialVersionUID = -4566469282934199114L; + @Serial private static final long serialVersionUID = -4566469282934199114L; /** * Create an instance of a locator that locates a JCheckBox by its text or name diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JCheckBoxMenuItemLocator.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JCheckBoxMenuItemLocator.java index 84a02df..4865e1b 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JCheckBoxMenuItemLocator.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JCheckBoxMenuItemLocator.java @@ -25,8 +25,7 @@ */ public class JCheckBoxMenuItemLocator extends JMenuItemLocator implements IsSelected { - @Serial - private static final long serialVersionUID = 4036431358452057857L; + @Serial private static final long serialVersionUID = 4036431358452057857L; /** * Creates an instance of a JCheckBoxMenuItem locator with the menu path indicated by a string diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JComboBoxLocator.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JComboBoxLocator.java index 615bae1..74645ca 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JComboBoxLocator.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JComboBoxLocator.java @@ -27,8 +27,7 @@ */ public class JComboBoxLocator extends AbstractPathLocator implements IsEnabled, HasFocus { - @Serial - private static final long serialVersionUID = -1258270010418601192L; + @Serial private static final long serialVersionUID = -1258270010418601192L; /** * Creates a locator for a JComboBox with the specified selection @@ -79,22 +78,15 @@ public JComboBoxLocator(String itemText, int index, SwingWidgetLocator parent) { * @param index the relative index * @param parent locator for the parent */ - public JComboBoxLocator( - Class cls, - String itemText, - int index, - SwingWidgetLocator parent) { + public JComboBoxLocator(Class cls, String itemText, int index, SwingWidgetLocator parent) { super(cls, itemText, index, parent); } @Override protected Component doClick( - IUIContext ui, - int clicks, - Component component, - Point offset, - int modifierMask) { - return ((UIContextSwing) ui).getDriver() + IUIContext ui, int clicks, Component component, Point offset, int modifierMask) { + return ((UIContextSwing) ui) + .getDriver() .clickComboBox((JComboBox) component, getItemText(), clicks); } diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JListLocator.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JListLocator.java index 75cd7ec..629b0cb 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JListLocator.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JListLocator.java @@ -23,8 +23,7 @@ */ public class JListLocator extends AbstractPathLocator { - @Serial - private static final long serialVersionUID = -1258270010418601192L; + @Serial private static final long serialVersionUID = -1258270010418601192L; /** * Create an instance of a locator for JList with the text for the selected item @@ -67,21 +66,13 @@ public JListLocator(String itemText, int index, SwingWidgetLocator parent) { * @param index the relative index to it's parent * @param parent the parent locator */ - public JListLocator( - Class cls, - String itemText, - int index, - SwingWidgetLocator parent) { + public JListLocator(Class cls, String itemText, int index, SwingWidgetLocator parent) { super(cls, itemText, index, parent); } @Override protected Component doClick( - IUIContext ui, - int clicks, - Component component, - Point offset, - int modifierMask) { + IUIContext ui, int clicks, Component component, Point offset, int modifierMask) { return ((UIContextSwing) ui) .getDriver() .clickListItem(clicks, (JList) component, getItemText(), modifierMask); diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JMenuItemLocator.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JMenuItemLocator.java index 8251a3a..4b17514 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JMenuItemLocator.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JMenuItemLocator.java @@ -27,8 +27,7 @@ */ public class JMenuItemLocator extends AbstractPathLocator implements IMenuItemLocator, IsEnabled { - @Serial - private static final long serialVersionUID = -5514291727454535792L; + @Serial private static final long serialVersionUID = -5514291727454535792L; /** * Creates an instance of a JMenuItem locator with the menu path indicated by a string such as @@ -81,11 +80,7 @@ protected String getWidgetLocatorStringName() { @Override protected Component doClick( - IUIContext ui, - int clicks, - Component component, - Point offset, - int modifierMask) { + IUIContext ui, int clicks, Component component, Point offset, int modifierMask) { ((UIContextSwing) ui).getDriver().clickMenuItem((JMenuItem) component); return component; } diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JMenuLocator.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JMenuLocator.java index 8610836..f170b93 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JMenuLocator.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JMenuLocator.java @@ -19,8 +19,7 @@ */ public class JMenuLocator extends JMenuItemLocator { - @Serial - private static final long serialVersionUID = 1369029475541129631L; + @Serial private static final long serialVersionUID = 1369029475541129631L; /** * Creates an instance of a JMenuLocator diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JRadioButtonLocator.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JRadioButtonLocator.java index b8b78a1..6225e86 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JRadioButtonLocator.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JRadioButtonLocator.java @@ -29,11 +29,10 @@ /** * A locator for JRadioButtons. */ -public class JRadioButtonLocator extends SwingWidgetLocator implements HasText, IsEnabled, - IsSelected { +public class JRadioButtonLocator extends SwingWidgetLocator + implements HasText, IsEnabled, IsSelected { - @Serial - private static final long serialVersionUID = -3878160309614329887L; + @Serial private static final long serialVersionUID = -3878160309614329887L; /** * Creates an instance of a locator for a JRadioButton diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JRadioButtonMenuItemLocator.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JRadioButtonMenuItemLocator.java index 99bf0e2..505f0c8 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JRadioButtonMenuItemLocator.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JRadioButtonMenuItemLocator.java @@ -25,8 +25,7 @@ */ public class JRadioButtonMenuItemLocator extends JMenuItemLocator implements IsSelected { - @Serial - private static final long serialVersionUID = -4750442290023311100L; + @Serial private static final long serialVersionUID = -4750442290023311100L; /** * Creates an instance of a JRadioButtonMenuItem locator with the menu path indicated by a string diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JTabbedPaneLocator.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JTabbedPaneLocator.java index b8d1aee..474d3bd 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JTabbedPaneLocator.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JTabbedPaneLocator.java @@ -29,8 +29,7 @@ */ public class JTabbedPaneLocator extends SwingWidgetLocator { - @Serial - private static final long serialVersionUID = 2471285225375825938L; + @Serial private static final long serialVersionUID = 2471285225375825938L; /** * Creates an instance of a locator for a JTabbedPane @@ -91,11 +90,7 @@ private IWidgetMatcher createMatcher(Class cls, int index, SwingWidgetLoca @Override protected Component doClick( - IUIContext ui, - int clicks, - Component component, - Point offset, - int modifierMask) { + IUIContext ui, int clicks, Component component, Point offset, int modifierMask) { return ((UIContextSwing) ui).getDriver().click(component, getNameOrLabel()); } } diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JTableItemLocator.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JTableItemLocator.java index a5f8776..e4b6436 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JTableItemLocator.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JTableItemLocator.java @@ -38,8 +38,7 @@ */ public class JTableItemLocator extends SwingWidgetLocator implements IsSelected { - @Serial - private static final long serialVersionUID = 7291989565140551064L; + @Serial private static final long serialVersionUID = 7291989565140551064L; private final Point rowColumn; @@ -96,14 +95,15 @@ public JTableItemLocator(Point rowCol, String tableName, int index, SwingWidgetL * @param index the index of the JTable relative to the parent * @param parent locator of the parent */ - public JTableItemLocator(Class cls, Point rowColum, String tableName, int index, - SwingWidgetLocator parent) { + public JTableItemLocator( + Class cls, Point rowColum, String tableName, int index, SwingWidgetLocator parent) { super(cls, tableName, index, parent); rowColumn = rowColum; matcher = createMatcher(cls, tableName, index, parent); } - private IWidgetMatcher createMatcher(Class cls, String tableName, int index, SwingWidgetLocator parent) { + private IWidgetMatcher createMatcher( + Class cls, String tableName, int index, SwingWidgetLocator parent) { IWidgetMatcher matcher = null; if (cls != null) { matcher = new ExactClassMatcher(cls); @@ -126,8 +126,9 @@ private IWidgetMatcher createMatcher(Class cls, String tableName, int inde return matcher; } - var msg = String.format("Unable to create matcher for class=%s, index=%d, parent=%s", - cls, index, parent); + var msg = + String.format( + "Unable to create matcher for class=%s, index=%d, parent=%s", cls, index, parent); throw new IllegalArgumentException(msg); } @@ -149,10 +150,7 @@ protected Component doClick( @Override public IWidgetLocator contextClick( - IUIContext ui, - IWidgetReference widget, - IClickDescription click, - String menuItemPath) { + IUIContext ui, IWidgetReference widget, IClickDescription click, String menuItemPath) { var component = (Component) widget.getWidget(); var clicked = ((UIContextSwing) ui) diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JTextComponentLocator.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JTextComponentLocator.java index e3425cf..f5e9e27 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JTextComponentLocator.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JTextComponentLocator.java @@ -31,8 +31,7 @@ public class JTextComponentLocator extends SwingWidgetLocator implements HasText, IsEnabled, HasFocus { - @Serial - private static final long serialVersionUID = -4186840479034195183L; + @Serial private static final long serialVersionUID = -4186840479034195183L; /** * the position index in case of a text pane @@ -93,10 +92,7 @@ public JTextComponentLocator(Class cls, int index, SwingWidgetLocator parent) * @param parent the locator for the parent of the JTextComponent */ public JTextComponentLocator( - Class cls, - String nameOrLabel, - int index, - SwingWidgetLocator parent) { + Class cls, String nameOrLabel, int index, SwingWidgetLocator parent) { super(cls, nameOrLabel, index, parent); } @@ -130,11 +126,7 @@ protected String getWidgetText(Component widget) { @Override protected Component doClick( - IUIContext ui, - int clicks, - Component component, - Point offset, - int modifierMask) { + IUIContext ui, int clicks, Component component, Point offset, int modifierMask) { if (caretPosition == UNASSIGNED) { return super.doClick(ui, clicks, component, offset, modifierMask); } diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JToggleButtonLocator.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JToggleButtonLocator.java index 09c00cf..7be83b4 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JToggleButtonLocator.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JToggleButtonLocator.java @@ -29,11 +29,10 @@ /** * A locator for JToggleButtons. */ -public class JToggleButtonLocator extends SwingWidgetLocator implements HasText, IsEnabled, - IsSelected { +public class JToggleButtonLocator extends SwingWidgetLocator + implements HasText, IsEnabled, IsSelected { - @Serial - private static final long serialVersionUID = 6685889878580688192L; + @Serial private static final long serialVersionUID = 6685889878580688192L; /** * Create an instance of a locator for a JToggleButton @@ -61,10 +60,7 @@ public JToggleButtonLocator(String nameOrLabel, SwingWidgetLocator parent) { * @param index the index relative to the parent * @param parent the locator for the parent of the button */ - public JToggleButtonLocator( - String nameOrLabel, - int index, - SwingWidgetLocator parent) { + public JToggleButtonLocator(String nameOrLabel, int index, SwingWidgetLocator parent) { super(JToggleButton.class, nameOrLabel, index, parent); } diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JTreeItemLocator.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JTreeItemLocator.java index 73237f5..27bedf5 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JTreeItemLocator.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/JTreeItemLocator.java @@ -35,8 +35,7 @@ */ public class JTreeItemLocator extends AbstractPathLocator implements IsSelected { - @Serial - private static final long serialVersionUID = -5514291727454535792L; + @Serial private static final long serialVersionUID = -5514291727454535792L; /** * Creates an instance of a locator to a node in a JTree @@ -117,8 +116,8 @@ public JTreeItemLocator(String path, String treeName, int index, SwingWidgetLoca * @param index index of the tree relative to it's parent * @param parent locator to the parent */ - public JTreeItemLocator(Class cls, String path, String treeName, int index, - SwingWidgetLocator parent) { + public JTreeItemLocator( + Class cls, String path, String treeName, int index, SwingWidgetLocator parent) { super(cls, path, index, parent); if (treeName != null && !treeName.isEmpty()) { matcher = new CompoundMatcher(matcher, NameOrTextMatcher.create(treeName)); @@ -132,11 +131,7 @@ protected String getWidgetLocatorStringName() { @Override protected Component doClick( - IUIContext ui, - int clicks, - Component component, - Point offset, - int modifierMask) { + IUIContext ui, int clicks, Component component, Point offset, int modifierMask) { if (clicks > 2) { throw new UnsupportedOperationException(); } @@ -146,10 +141,7 @@ protected Component doClick( @Override public IWidgetLocator contextClick( - IUIContext ui, - IWidgetReference widget, - IClickDescription click, - String menuItemPath) { + IUIContext ui, IWidgetReference widget, IClickDescription click, String menuItemPath) { var component = (Component) widget.getWidget(); var clicked = ((UIContextSwing) ui) diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/LabeledTextLocator.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/LabeledTextLocator.java index a2c364c..90ae080 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/LabeledTextLocator.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/LabeledTextLocator.java @@ -33,8 +33,7 @@ */ public class LabeledTextLocator extends JTextComponentLocator { - @Serial - private static final long serialVersionUID = -4186840479034195183L; + @Serial private static final long serialVersionUID = -4186840479034195183L; /** * Create an instance that locates a Text component of class JTextField preceded by a Label diff --git a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/NamedWidgetLocator.java b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/NamedWidgetLocator.java index 69d67ef..abd9425 100644 --- a/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/NamedWidgetLocator.java +++ b/com.windowtester.swing.runtime/src/main/java/com/windowtester/runtime/swing/locator/NamedWidgetLocator.java @@ -46,8 +46,7 @@ */ public class NamedWidgetLocator extends SwingWidgetLocator implements HasText, IsEnabled { - @Serial - private static final long serialVersionUID = -6974445702753299953L; + @Serial private static final long serialVersionUID = -6974445702753299953L; /** * Create a locator instance. diff --git a/com.windowtester.swing.runtime/src/test/java/com/windowtester/internal/swing/util/PathStringTokenizerUtilTest.java b/com.windowtester.swing.runtime/src/test/java/com/windowtester/internal/swing/util/PathStringTokenizerUtilTest.java index fb81de6..b9d8cba 100644 --- a/com.windowtester.swing.runtime/src/test/java/com/windowtester/internal/swing/util/PathStringTokenizerUtilTest.java +++ b/com.windowtester.swing.runtime/src/test/java/com/windowtester/internal/swing/util/PathStringTokenizerUtilTest.java @@ -17,4 +17,4 @@ void tokenize_should_split_path_at_slash_character() { assertEquals("d", tokenized[3]); assertEquals("E", tokenized[4]); } -} \ No newline at end of file +} diff --git a/com.windowtester.swing.runtime/src/test/java/com/windowtester/runtime/swing/locator/JMenuItemLocatorTest.java b/com.windowtester.swing.runtime/src/test/java/com/windowtester/runtime/swing/locator/JMenuItemLocatorTest.java index cac1da2..549538a 100644 --- a/com.windowtester.swing.runtime/src/test/java/com/windowtester/runtime/swing/locator/JMenuItemLocatorTest.java +++ b/com.windowtester.swing.runtime/src/test/java/com/windowtester/runtime/swing/locator/JMenuItemLocatorTest.java @@ -12,10 +12,11 @@ void path_should_be_returned() { assertEquals("File/Exit", locator.getPath()); } + @Test void path_should_be_parsed_into_name_and_label() { var locator = new JMenuItemLocator("File/Exit"); assertEquals("Exit", locator.getNameOrLabel()); } -} \ No newline at end of file +} diff --git a/conf/checkstyle/checkstyle.xml b/conf/checkstyle/checkstyle.xml new file mode 100644 index 0000000..b1c1f0a --- /dev/null +++ b/conf/checkstyle/checkstyle.xml @@ -0,0 +1,19 @@ + + + + + + + + + diff --git a/pom.xml b/pom.xml index e62bc72..cb40fc6 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.r4fterman com.windowtester - 6.0.0-SNAPSHOT + 6.0.1-SNAPSHOT pom WindowTester @@ -53,7 +53,7 @@ UTF-8 21 - 3.9.3 + 3.9.9 ${java.version} ${java.version} @@ -63,7 +63,7 @@ org.junit junit-bom - 5.13.4 + 6.0.0 pom import @@ -71,6 +71,15 @@ + + + + dev.dimlight + shellcheck-maven-plugin + 0.5.1 + + + maven-compiler-plugin @@ -115,16 +124,36 @@ com.diffplug.spotless spotless-maven-plugin - 2.46.0 + 2.46.1 - 1.19.2 + 1.28.0 true false + + + + + + src/**/*.json + + + 4 + false + false + 2.13.1 + + + + + **/*.md + + + @@ -161,6 +190,83 @@ bom + + dev.dimlight + shellcheck-maven-plugin + + + shell-script-linter + verify + + check + + + + + ${project.basedir}/scripts + + *.sh + git-hooks/* + + + + + -a + -s + bash + --format=tty + --norc + + true + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 3.6.0 + + + com.puppycrawl.tools + checkstyle + 12.0.1 + + + + conf/checkstyle/checkstyle.xml + true + warning + true + true + true + + + + validate + + check + + + + + + com.rudikershaw.gitbuildhook + git-build-hook-maven-plugin + 3.5.0 + + + scripts/git-hooks/ + + + + + + configure + + + + diff --git a/scripts/git-hooks/pre-commit b/scripts/git-hooks/pre-commit new file mode 100755 index 0000000..01e4dd6 --- /dev/null +++ b/scripts/git-hooks/pre-commit @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +set -euo pipefail + +extensions=( + "java" + "json" + "md" +) +ext_regex="\\.($(IFS='|'; echo "${extensions[*]}"))$" + +# command taken from https://github.com/JLLeitschuh/ktlint-gradle task addKtlintFormatGitPreCommitHook +# Identify modified files that are not deleted and match the specified extensions +filesToFormat=$(git --no-pager diff --name-status --no-color --cached \ + | awk -v regex="$ext_regex" '$1 != "D" && $2 ~ regex { print $NF }') + + +if [ -z "$filesToFormat" ]; then + exit 0 +fi + +mvn spotless:apply + +for fileToFormat in $filesToFormat +do + git add "$fileToFormat" +done; \ No newline at end of file