Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java 11 v19 #67

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Sakari Hoisko Dockerized linux env with X
Juho Lehtonen Optimized docker environment.
Juho Saarinen Package improvements, initial monocle support, screenshot bug fix
Turo Soisenniemi Initial java agent support
Jari Parviainen Latest Java 8 version changes
Jari Parviainen Latest changes to Java 8 and 11 versions
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

JavaFXLibrary works with both Jython (local and remote use) and Python (remote only) versions of Robot Framework. This means JavaFXLibrary can be used with Jython incompatible test libraries too by importing it as a remote library.

JavaFXLibrary is tested to work with Java 8 and Robot Framework 3.2.1 or later.
JavaFXLibrary is tested to work with Java (8 and 11) and Robot Framework 3.2.1 or later.

## Keyword documentation
See keyword [documentation](https://repo1.maven.org/maven2/org/robotframework/javafxlibrary/0.7.1/javafxlibrary-0.7.1.html).
Expand Down
71 changes: 64 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
<version>0.7.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jmockit.version>1.44</jmockit.version>
<jmockit.version>1.49</jmockit.version>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.release>11</maven.compiler.release>
</properties>

<name>${project.groupId}:${project.artifactId}</name>
Expand Down Expand Up @@ -210,12 +213,31 @@
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
<executions>
<execution>
<id>compile-java-8</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>8</release>
</configuration>
</execution>
<execution>
<id>compile-java-11</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>11</release>
<multiReleaseOutput>true</multiReleaseOutput>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -229,8 +251,10 @@
</manifest>
<manifestEntries>
<Premain-Class>JavaFXLibrary</Premain-Class>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
<finalName>${project.artifactId}-${project.version}</finalName>
</configuration>
<executions>
<execution>
Expand Down Expand Up @@ -376,6 +400,39 @@
</build>

<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>11</version>
<classifier>win</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>11</version>
<classifier>linux</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>11</version>
<classifier>mac</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
Expand Down Expand Up @@ -405,7 +462,7 @@
<dependency>
<groupId>org.testfx</groupId>
<artifactId>openjfx-monocle</artifactId>
<version>8u76-b04</version>
<version>jdk-12.0.1+2</version>
</dependency>
<dependency>
<groupId>org.robotframework</groupId>
Expand Down Expand Up @@ -435,7 +492,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.13.0</version>
<version>2.14.0</version>
</dependency>
</dependencies>
</project>
2 changes: 2 additions & 0 deletions src/main/java/JavaFXLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}
Expand Down Expand Up @@ -477,15 +476,18 @@ public List<Object> getTableColumnValues(Object locator, int column) {
public List<Object> getTableColumnCells(Object locator, int column) {
checkObjectArgumentNotNull(locator);
try {
List<Object> columnCells = new ArrayList<>();

RobotLog.info("Getting table \"" + locator + "\" cells from column \"" + column + "\".");
TableView table = (TableView) objectToNode(locator);
List<Object> 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)));
}

return mapObjects(columnCells);
} catch (ClassCastException cce) {
throw new JavaFXLibraryNonFatalException("Unable to handle argument as TableView!");
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/javafxlibrary/TestFxAdapterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void mapObjects_FromSet() {

@Test
public void mapObjects_FromQueue() {
Queue<Button> queue = new PriorityQueue<>();
Queue<Button> queue = new LinkedList<>();
queue.add(button);
List<Object> keys = HelperFunctions.mapObjects(queue);
Button b = (Button) TestFxAdapter.objectMap.get(keys.get(0));
Expand Down
2 changes: 1 addition & 1 deletion src/test/robotframework/acceptance/MiscTests.robot
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ Get Table Cell Value Using Index That Is Out Of Bounds
Set Test Application javafxlibrary.testapps.TestTableManagement
${TABLE} Find id=table
${MSG} Run Keyword And Expect Error * Get Table Cell Value ${TABLE} 0 40
Should Be Equal ${MSG} Out of table bounds: Index: 40, Size: 5
Should Be Equal ${MSG} Out of table bounds: Index 40 out of bounds for length 5

Get Object Property
[Tags] smoke
Expand Down