Skip to content

Commit 3e3e1ab

Browse files
committed
merge 0.5.2-development branch => release 0.5.2
- Merge pull request #9 from Hi-Fi/packageImprovements - Package improvements - Merge pull request #8 from Hi-Fi/shadeCommons - Prevent conflicts with Commons by shading it - Continuing to use awt robot with library - Moved test app to test code - Updated some dependencies - Testing what's delivered in containers - Surefire update because of https://issues.apache.org/jira/browse/SUREFIRE-1588 / https://stackoverflow.com/questions/53010200/maven-surefire-could-not-find-forkedbooter-class - Add keyword Launch Swing Application In Separate Thread - Prevent conflicts with Commons by shading it - Get FxRobotContext from the active sessionRobot in TestFxAdapter - Adjust readme - Add instructions for enabling accessibility features on MacOS Mojave
1 parent 7e50b03 commit 3e3e1ab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+134
-44
lines changed

AUTHORS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ Other contributors:
77
Tatu Lahtela Find All With Pseudo Class and Find Class keywords
88
Sakari Hoisko Dockerized linux env with X
99
Juho Lehtonen Optimized docker environment.
10+
Juho Saarinen Package improvements

Dockerfile_build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ RUN mvn package
1515

1616
FROM ubuntu:16.04
1717
COPY --from=builder /code/target/javafxlibrary-*-SNAPSHOT-jar-with-dependencies.jar /.
18+
COPY --from=builder /code/target/javafxlibrary-*-SNAPSHOT-tests.jar /.
1819
COPY entrypoint_build.sh /.
1920
RUN apt-get -qq update && apt-get dist-upgrade -y && apt-get install -qq --no-install-recommends --allow-unauthenticated -y \
2021
openjdk-8-jre \

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ Library Remote http://127.0.0.1:8270 WITH NAME JavaFXLibrary
3434
```
3535
4. Run your tests: `robot tests.robot`
3636

37+
## Using JavaFXLibrary on macOS Mojave
38+
MacOS Mojave introduced changes to security settings and disabled some of the features JavaFXLibrary uses by default.
39+
To use JavaFXLibrary on macOS Mojave you must enable the accessibility features for terminal in system preferences:
40+
- Navigate to `Apple menu > System Preferences > Security & Privacy > Privacy > Accessibility`
41+
- Click the lock and enter your password to change these settings
42+
- If terminal has requested accessibility features before it should show in the list
43+
- If not, add it by clicking :heavy_plus_sign: and selecting `Applications > Utilities > Terminal`
44+
- Enable accessibility features by checking the box: :white_check_mark: Terminal
45+
3746
## Identifying JavaFX UI objects
3847
[Scenic View](http://fxexperience.com/scenic-view/) is a tool that allows you to inspect the JavaFX application scenegraph. This can be useful especially when you do not have access to the source code.
3948

docker/robot-javafx-demo/test.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ function local() {
55
echo "**********************"
66
echo "INFO: Local execution:"
77
file=$(ls -1 /javafxbinary/javafxlibrary-*-jar-with-dependencies.jar)
8-
java -cp ${file} org.robotframework.RobotFramework -d /robot/results/local --include smoke $@ /robot/acceptance
8+
testJar=$(ls -1 /javafxbinary/javafxlibrary-*-tests.jar)
9+
java -cp ${file} org.robotframework.RobotFramework -d /robot/results/local --include smoke --variable appJar:${testJar} $@ /robot/acceptance
910
# $@ #just to testing script
1011
if [[ "$?" != "0" ]]; then
1112
EXIT_VALUE=$((EXIT_VALUE+1))
@@ -15,7 +16,8 @@ function local() {
1516
function remote() {
1617
echo "***********************"
1718
echo "INFO: Remote execution:"
18-
robot -d /robot/results/remote --include smoke $@ /robot/acceptance
19+
testJar=$(ls -1 /javafxbinary/javafxlibrary-*-tests.jar)
20+
robot -d /robot/results/remote --include smoke --variable appJar:${testJar} $@ /robot/acceptance
1921
# $@ #just to testing script
2022
if [[ "$?" != "0" ]]; then
2123
EXIT_VALUE=$((EXIT_VALUE+2))

entrypoint_build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env bash
22
rm -rvf /javafxbinary/*
33
cp -vf /javafxlibrary-*-jar-with-dependencies.jar /javafxbinary/.
4-
chmod 555 /javafxbinary/javafxlibrary-*-jar-with-dependencies.jar
4+
cp -vf /javafxlibrary-*-tests.jar /javafxbinary/.
5+
chmod 555 /javafxbinary/*
56
java -jar /javafxlibrary-*-jar-with-dependencies.jar

pom.xml

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<groupId>org.robotframework</groupId>
2222
<artifactId>javafxlibrary</artifactId>
2323
<packaging>jar</packaging>
24-
<version>0.5.2-SNAPSHOT</version>
24+
<version>0.5.2</version>
2525
<properties>
2626
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2727
</properties>
@@ -102,6 +102,33 @@
102102
</execution>
103103
</executions>
104104
</plugin>
105+
<!-- Upload also documentation -->
106+
<plugin>
107+
<groupId>org.codehaus.mojo</groupId>
108+
<artifactId>build-helper-maven-plugin</artifactId>
109+
<version>1.10</version>
110+
<executions>
111+
<execution>
112+
<id>attach-artifacts</id>
113+
<phase>package</phase>
114+
<goals>
115+
<goal>attach-artifact</goal>
116+
</goals>
117+
<configuration>
118+
<artifacts>
119+
<artifact>
120+
<file>${project.build.directory}/${project.artifactId}.html</file>
121+
<type>html</type>
122+
</artifact>
123+
<artifact>
124+
<file>${project.build.directory}/${project.artifactId}.xml</file>
125+
<type>xml</type>
126+
</artifact>
127+
</artifacts>
128+
</configuration>
129+
</execution>
130+
</executions>
131+
</plugin>
105132
<plugin>
106133
<groupId>org.apache.maven.plugins</groupId>
107134
<artifactId>maven-gpg-plugin</artifactId>
@@ -138,6 +165,11 @@
138165

139166
<build>
140167
<plugins>
168+
<plugin>
169+
<groupId>org.apache.maven.plugins</groupId>
170+
<artifactId>maven-surefire-plugin</artifactId>
171+
<version>3.0.0-M1</version>
172+
</plugin>
141173
<plugin>
142174
<groupId>org.sonatype.plugins</groupId>
143175
<artifactId>nexus-staging-maven-plugin</artifactId>
@@ -219,6 +251,9 @@
219251
</excludes>
220252
<logLevel>TRACE:INFO</logLevel>
221253
<dryrun>false</dryrun>
254+
<variables>
255+
<variable>appJar:${project.build.directory}/${project.artifactId}*tests.jar</variable>
256+
</variables>
222257
</configuration>
223258
</execution>
224259
<execution>
@@ -229,6 +264,7 @@
229264
</goals>
230265
<configuration>
231266
<libdoc>
267+
<outputDirectory>${project.build.directory}</outputDirectory>
232268
<outputFile>${project.artifactId}.html</outputFile>
233269
<libraryOrResourceFile>JavaFXLibrary</libraryOrResourceFile>
234270
<version>${project.version}</version>
@@ -243,6 +279,7 @@
243279
</goals>
244280
<configuration>
245281
<libdoc>
282+
<outputDirectory>${project.build.directory}</outputDirectory>
246283
<outputFile>${project.artifactId}.xml</outputFile>
247284
<libraryOrResourceFile>JavaFXLibrary</libraryOrResourceFile>
248285
<version>${project.version}</version>
@@ -272,6 +309,10 @@
272309
<pattern>com.google.common</pattern>
273310
<shadedPattern>shaded.com.google.common</shadedPattern>
274311
</relocation>
312+
<relocation>
313+
<pattern>org.apache.commons</pattern>
314+
<shadedPattern>shaded.org.apache.commons</shadedPattern>
315+
</relocation>
275316
</relocations>
276317
<artifactSet>
277318
<includes>
@@ -299,7 +340,7 @@
299340
<dependency>
300341
<groupId>org.apache.maven</groupId>
301342
<artifactId>maven-model</artifactId>
302-
<version>3.3.9</version>
343+
<version>3.6.0</version>
303344
</dependency>
304345
<dependency>
305346
<groupId>org.jmockit</groupId>
@@ -315,12 +356,7 @@
315356
<dependency>
316357
<groupId>org.testfx</groupId>
317358
<artifactId>testfx-core</artifactId>
318-
<version>4.0.14-alpha</version>
319-
</dependency>
320-
<dependency>
321-
<groupId>org.testfx</groupId>
322-
<artifactId>testfx-junit</artifactId>
323-
<version>4.0.14-alpha</version>
359+
<version>4.0.15-alpha</version>
324360
</dependency>
325361
<dependency>
326362
<groupId>org.testfx</groupId>
@@ -336,7 +372,7 @@
336372
<dependency>
337373
<groupId>org.robotframework</groupId>
338374
<artifactId>robotframework</artifactId>
339-
<version>3.0.2</version>
375+
<version>3.0.4</version>
340376
</dependency>
341377
<dependency>
342378
<groupId>org.hamcrest</groupId>
@@ -346,7 +382,7 @@
346382
<dependency>
347383
<groupId>com.google.guava</groupId>
348384
<artifactId>guava</artifactId>
349-
<version>23.0</version>
385+
<version>27.0.1-jre</version>
350386
</dependency>
351387
<dependency>
352388
<groupId>com.github.ombre42</groupId>

src/main/java/JavaFXLibrary.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ public class JavaFXLibrary extends AnnotationLibrary {
6060
public JavaFXLibrary() {
6161
super(includePatterns);
6262
deleteScreenshotsFrom("report-images/imagecomparison");
63+
//v4.0.15-alpha sets default robot as glass, which breaks rolling
64+
//Forcing usage of awt robot as previous versions
65+
System.setProperty("testfx.robot", "awt");
6366
}
6467

6568
@Autowired

src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.net.URLClassLoader;
3232
import java.util.*;
3333

34+
import static javafxlibrary.utils.HelperFunctions.createThreadedWrapperApplication;
3435
import static javafxlibrary.utils.HelperFunctions.createWrapperApplication;
3536
import static javafxlibrary.utils.HelperFunctions.getMainClassFromJarFile;
3637

@@ -66,21 +67,40 @@ public void launchJavafxApplication(String appName, String... appArgs) {
6667
@ArgumentNames({"appName", "*args"})
6768
public void launchSwingApplication(String appName, String... appArgs) {
6869
RobotLog.info("Starting application:" + appName);
69-
Class c;
70+
Class c = getMainClass(appName);
71+
Application app = createWrapperApplication(c, appArgs);
72+
createNewSession(app);
73+
RobotLog.info("Application: " + appName + " started.");
74+
}
75+
76+
@RobotKeyword("Creates a wrapper application the same way as in `Launch Swing Application`, but starts it in a new " +
77+
"thread. This is required when main method of the test application is blocked and execution does not " +
78+
"return after calling it until the application gets closed. Be sure to set the library timeout with " +
79+
"`Set Timeout` so that the test application will have enough time to load, as the test execution will " +
80+
"continue instantly after calling the main method.\n\n"
81+
+ "``appName`` is the name of the application to launch. \n\n"
82+
+ "``appArgs`` is a list of arguments to be passed for the application. \n\n"
83+
+ "Example:\n"
84+
+ "| Launch Swing Application In Separate Thread | _javafxlibrary.testapps.SwingApplication |\n"
85+
+ "| Launch Swing Application In Separate Thread | _TestApplication.jar_ |\n")
86+
@ArgumentNames({"appName", "*args"})
87+
public void launchSwingApplicationInSeparateThread(String appName, String... appArgs) {
88+
RobotLog.info("Starting application:" + appName);
89+
Class c = getMainClass(appName);
90+
Application app = createThreadedWrapperApplication(c, appArgs);
91+
createNewSession(app);
92+
RobotLog.info("Application: " + appName + " started.");
93+
}
7094

95+
private Class getMainClass(String appName) {
7196
try {
7297
if (appName.endsWith(".jar"))
73-
c = getMainClassFromJarFile(appName);
98+
return getMainClassFromJarFile(appName);
7499
else
75-
c = Class.forName(appName);
76-
100+
return Class.forName(appName);
77101
} catch (ClassNotFoundException e) {
78102
throw new JavaFXLibraryNonFatalException("Unable to launch application: " + appName, e);
79103
}
80-
81-
Application app = createWrapperApplication(c, appArgs);
82-
createNewSession(app);
83-
RobotLog.info("Application: " + appName + " started.");
84104
}
85105

86106
private void _addPathToClassPath(String path) {

src/main/java/javafxlibrary/keywords/AdditionalKeywords/Verifiers.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public void imagesShouldMatch(Image image1, Image image2, double percentage) {
252252
throw new JavaFXLibraryNonFatalException("Images must be same size to compare: Image1 is " + (int)image1.getWidth()
253253
+ "x" + (int)image1.getHeight() + " and Image2 is " + (int)image2.getWidth() + "x" + (int)image2.getHeight());
254254

255-
PixelMatcherResult result = robotContext.getCaptureSupport().matchImages(image1, image2, new PixelMatcherRgb());
255+
PixelMatcherResult result = robotContext().getCaptureSupport().matchImages(image1, image2, new PixelMatcherRgb());
256256
int sharedPixels = (int) (result.getMatchFactor() * 100);
257257
RobotLog.info("Matching pixels: " + sharedPixels + "%");
258258

@@ -280,7 +280,7 @@ public void imagesShouldNotMatch(Image image1, Image image2, double percentage)
280280
throw new JavaFXLibraryNonFatalException("Images must be same size to compare: Image1 is " + (int)image1.getWidth()
281281
+ "x" + (int)image1.getHeight() + " and Image2 is " + (int)image2.getWidth() + "x" + (int)image2.getHeight());
282282

283-
PixelMatcherResult result = robotContext.getCaptureSupport().matchImages(image1, image2, new PixelMatcherRgb());
283+
PixelMatcherResult result = robotContext().getCaptureSupport().matchImages(image1, image2, new PixelMatcherRgb());
284284
int nonSharedPixels = (int) (result.getNonMatchFactor() * 100);
285285
RobotLog.info("Matching pixels: " + nonSharedPixels + "%");
286286

src/main/java/javafxlibrary/keywords/Keywords/KeyboardRobot.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public void writeFast(String text) {
204204
+ "`3. Locating or specifying UI elements`. \n\n"
205205
+ "``text`` is the text characters to write\n"
206206
+ "\nExample: \n"
207-
+ "| Write | Robot Framework | \n")
207+
+ "| Write To | Robot Framework | \n")
208208
@ArgumentNames({ "locator", "text" })
209209
public FxRobotInterface writeTo(Object locator, String text) {
210210
RobotLog.info("Writing to " + locator);

0 commit comments

Comments
 (0)