diff --git a/pom.xml b/pom.xml index ec9144e..9ff5865 100644 --- a/pom.xml +++ b/pom.xml @@ -207,8 +207,8 @@ maven-compiler-plugin 3.8.1 - 1.8 - 1.8 + 11 + 11 @@ -260,7 +260,7 @@ org.robotframework robotframework-maven-plugin - 1.7.1 + 2.1.0 acceptance tests @@ -367,6 +367,39 @@ + + org.openjfx + javafx-graphics + 11 + win + + + org.openjfx + javafx-graphics + 11 + linux + + + org.openjfx + javafx-graphics + 11 + mac + + + org.openjfx + javafx-controls + 11 + + + org.openjfx + javafx-swing + 11 + + + org.openjfx + javafx-fxml + 11 + org.apache.maven maven-model @@ -391,7 +424,7 @@ org.testfx openjfx-monocle - 8u76-b04 + jdk-12.0.1+2 org.robotframework diff --git a/src/main/java/JavaFXLibrary.java b/src/main/java/JavaFXLibrary.java index 2b54eb9..20f4b64 100644 --- a/src/main/java/JavaFXLibrary.java +++ b/src/main/java/JavaFXLibrary.java @@ -128,6 +128,8 @@ public JavaFXLibrary(boolean headless) { if (headless) { System.setProperty("testfx.robot", "glass"); System.setProperty("testfx.headless", "true"); + System.setProperty("glass.platform", "Monocle"); + System.setProperty("monocle.platform", "Headless"); System.setProperty("prism.order", "sw"); System.setProperty("prism.text", "t2k"); TestFxAdapter.isHeadless = true; diff --git a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java index 57cc01f..3bf711e 100644 --- a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java +++ b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java @@ -112,14 +112,12 @@ private Class getMainClass(String appName) { } private void addPathToClassPath(String path) { - URLClassLoader classLoader = (URLClassLoader) ClassLoader.getSystemClassLoader(); RobotLog.info("Setting following path to classpath: " + path); try { - Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); - method.setAccessible(true); - method.invoke(classLoader, (new File(path)).toURI().toURL()); + URL[] urls = new URL[]{new File(path).toURI().toURL()}; + URLClassLoader classLoader = new URLClassLoader(urls, ClassLoader.getSystemClassLoader()); } catch (Exception e) { throw new JavaFXLibraryFatalException("Problem setting the classpath: " + path, e); @@ -176,11 +174,11 @@ public void setToClasspath(String path, boolean failIfNotFound) { @RobotKeyword("Logs current classpath content") public void logApplicationClasspath() { try { - ClassLoader cl = ClassLoader.getSystemClassLoader(); - URL[] urls = ((URLClassLoader) cl).getURLs(); RobotLog.info("Printing out classpaths: \n"); - for (URL url : urls) { - RobotLog.info(url.getFile()); + + String classpathStr = System.getProperty("java.class.path"); + for (String classpathItem : classpathStr.split(System.getProperty("path.separator"))) { + RobotLog.info(classpathItem); } } catch (Exception e) { throw new JavaFXLibraryNonFatalException("Unable to log application classpaths", e); diff --git a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java index 531cc7d..306d217 100644 --- a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java +++ b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java @@ -17,8 +17,8 @@ package javafxlibrary.keywords.AdditionalKeywords; -import com.sun.javafx.scene.control.skin.TableViewSkin; -import com.sun.javafx.scene.control.skin.VirtualFlow; +import javafx.scene.control.skin.TableViewSkin; +import javafx.scene.control.skin.VirtualFlow; import javafx.collections.ObservableList; import javafx.css.PseudoClass; import javafx.geometry.BoundingBox; @@ -279,7 +279,7 @@ public String getNodeText(Object locator) { @RobotKeyword("Returns image name and path of the node. \n\n" + "``locator`` is either a _query_ or _Object_ for a node whose getHeight method will be called, see " + "`3. Locating JavaFX Nodes`. \n\n" - + "Returns full image path by subsequently calling impl_getUrl -method. \n\n" + + "Returns full image path by subsequently calling getUrl -method. \n\n" + "Note, impl_getUrl -method is deprecated! Support for this method will be removed from Java in the future.") @ArgumentNames({"node"}) public String getNodeImageUrl(Object locator) { @@ -294,8 +294,7 @@ public String getNodeImageUrl(Object locator) { try { Object result = m.invoke(node, (Object) null); Image image = (Image) result; - RobotLog.trace("Calling deprecated method impl_getUrl() for image: \"" + image + "\""); - return image.impl_getUrl(); + return image.getUrl(); } catch (Exception e) { throw new JavaFXLibraryNonFatalException("Problem calling method: .getImage(): " + e.getMessage(), e); } @@ -480,13 +479,17 @@ public List getTableColumnCells(Object locator, int column) { RobotLog.info("Getting table \"" + locator + "\" cells from column \"" + column + "\"."); TableView table = (TableView) objectToNode(locator); List columnCells = new ArrayList<>(); - VirtualFlow vf = (VirtualFlow) ((TableViewSkin) table.getSkin()).getChildren().get(1); - - for (int i = vf.getFirstVisibleCell().getIndex(); i < vf.getLastVisibleCell().getIndex() + 1; i++) { - RobotLog.info("Index number: " + i); - columnCells.add(mapObject(vf.getCell(i).getChildrenUnmodifiable().get(column))); + Optional vf = table.getChildrenUnmodifiable().stream().filter(node -> node instanceof VirtualFlow).map(VirtualFlow.class::cast).findFirst(); + if (vf.isPresent()) { + VirtualFlow virtualFlow = vf.get(); + for (int i = virtualFlow.getFirstVisibleCell().getIndex(); i < virtualFlow.getLastVisibleCell().getIndex() + 1; i++) { + RobotLog.info("Index number: " + i); + columnCells.add(mapObject(virtualFlow.getCell(i).getChildrenUnmodifiable().get(column))); + } + return mapObjects(columnCells); + } else { + throw new JavaFXLibraryNonFatalException("Could not find VirtualFlow from Tableview!"); } - return mapObjects(columnCells); } catch (ClassCastException cce) { throw new JavaFXLibraryNonFatalException("Unable to handle argument as TableView!"); } diff --git a/src/test/java/javafxlibrary/TestFxAdapterTest.java b/src/test/java/javafxlibrary/TestFxAdapterTest.java index e701f64..ab7f9f2 100644 --- a/src/test/java/javafxlibrary/TestFxAdapterTest.java +++ b/src/test/java/javafxlibrary/TestFxAdapterTest.java @@ -37,6 +37,8 @@ public FxRobotInterface getRobot() { public static void setupTests() { System.setProperty("testfx.robot", "glass"); System.setProperty("testfx.headless", "true"); + System.setProperty("glass.platform", "Monocle"); + System.setProperty("monocle.platform", "Headless"); System.setProperty("prism.order", "sw"); System.setProperty("prism.text", "t2k"); try { diff --git a/src/test/java/javafxlibrary/testapps/controllers/TestKeyboardRobotController.java b/src/test/java/javafxlibrary/testapps/controllers/TestKeyboardRobotController.java index 5b34556..a0a939f 100644 --- a/src/test/java/javafxlibrary/testapps/controllers/TestKeyboardRobotController.java +++ b/src/test/java/javafxlibrary/testapps/controllers/TestKeyboardRobotController.java @@ -17,7 +17,7 @@ package javafxlibrary.testapps.controllers; -import com.sun.javafx.scene.control.skin.TextAreaSkin; +import javafx.scene.control.skin.TextAreaSkin; import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.fxml.Initializable; @@ -52,15 +52,9 @@ public void initialize(URL location, ResourceBundle resources) { @Override public void handle(KeyEvent event) { if (event.getCode().equals(KeyCode.TAB)) { - if (event.isShiftDown()) { - textArea.setText(textArea.getText() + " "); - textArea.positionCaret(textArea.getText().length()); - event.consume(); - } else { - TextAreaSkin skin = (TextAreaSkin) textArea.getSkin(); - skin.getBehavior().traverseNext(); - event.consume(); - } + textArea.setText(textArea.getText() + " "); + textArea.positionCaret(textArea.getText().length()); + event.consume(); } } }); diff --git a/src/test/java/javafxlibrary/utils/HelperFunctionsTests/GetMouseButtonsTest.java b/src/test/java/javafxlibrary/utils/HelperFunctionsTests/GetMouseButtonsTest.java index 6c4b434..ce86636 100644 --- a/src/test/java/javafxlibrary/utils/HelperFunctionsTests/GetMouseButtonsTest.java +++ b/src/test/java/javafxlibrary/utils/HelperFunctionsTests/GetMouseButtonsTest.java @@ -3,6 +3,9 @@ import javafx.scene.input.MouseButton; import javafxlibrary.exceptions.JavaFXLibraryNonFatalException; import javafxlibrary.utils.HelperFunctions; + +import java.util.Arrays; + import org.junit.Assert; import org.junit.Rule; import org.junit.Test; @@ -50,7 +53,7 @@ public void getMouseButtons_MultipleValues() { public void getMouseButtons_InvalidValue() { thrown.expect(JavaFXLibraryNonFatalException.class); // thrown.expect(IllegalArgumentException.class); - thrown.expectMessage("\"HUGE_RED_ONE\" is not a valid MouseButton. Accepted values are: [NONE, PRIMARY, MIDDLE, SECONDARY]"); + thrown.expectMessage("\"HUGE_RED_ONE\" is not a valid MouseButton. Accepted values are: " + Arrays.asList(MouseButton.values())); HelperFunctions.getMouseButtons(new String[]{"HUGE_RED_ONE"}); } diff --git a/src/test/java/javafxlibrary/utils/HelperFunctionsTests/MapObjectsTest.java b/src/test/java/javafxlibrary/utils/HelperFunctionsTests/MapObjectsTest.java index 68ad01a..a00ae18 100644 --- a/src/test/java/javafxlibrary/utils/HelperFunctionsTests/MapObjectsTest.java +++ b/src/test/java/javafxlibrary/utils/HelperFunctionsTests/MapObjectsTest.java @@ -47,7 +47,7 @@ public void mapObjects_FromSet() { @Test public void mapObjects_FromQueue() { - Queue