Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6fc8dca

Browse files
committed
Merge master into DockerizedEnv
# Conflicts: # README.md
2 parents e039595 + cb956fa commit 6fc8dca

File tree

5 files changed

+93
-33
lines changed

5 files changed

+93
-33
lines changed

README.md

-4
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,3 @@ java -cp "target/javafxlibrary-<version>.jar" org.robotframework.RobotFramework
9292
5. Execute tests: `robot --include smoke -d /robot/results /robot/acceptance`
9393
9494
Remote server and tests run in separate containers, and their GUIs are forwarded to the VNC container.
95-
96-
## Known issues
97-
98-
* If the remote library server and tests are running on the same machine, the server must be restarted between test executions. If the server is not restarted, test applications will launch behind other windows, causing tests to fail when robot is trying to interact with them.

pom.xml

+1-6
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.0</version>
24+
<version>0.5.0-SNAPSHOT</version>
2525
<properties>
2626
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2727
</properties>
@@ -343,11 +343,6 @@
343343
<artifactId>hamcrest-all</artifactId>
344344
<version>1.3</version>
345345
</dependency>
346-
<dependency>
347-
<groupId>org.awaitility</groupId>
348-
<artifactId>awaitility</artifactId>
349-
<version>3.0.0</version>
350-
</dependency>
351346
<dependency>
352347
<groupId>com.google.guava</groupId>
353348
<artifactId>guava</artifactId>

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ public Double getScrollBarValue(Object locator){
893893
+ "``locator`` is either a _query_ or _Object:Node_ for identifying the CheckBox element, see "
894894
+ "`3. Locating or specifying UI elements`. \n\n")
895895
@ArgumentNames({ "locator" })
896-
public static Boolean getCheckBoxSelection(Object locator) {
896+
public Boolean getCheckBoxSelection(Object locator) {
897897

898898
try {
899899
CheckBox box = (CheckBox) objectToNode(locator);
@@ -908,7 +908,7 @@ public static Boolean getCheckBoxSelection(Object locator) {
908908
+ "``locator`` is either a _query_ or _Object:Node_ for identifying the RadioButton element, see "
909909
+ "`3. Locating or specifying UI elements`. \n\n")
910910
@ArgumentNames({ "locator" })
911-
public static Object getSelectedRadioButton(Object locator) {
911+
public Object getSelectedRadioButton(Object locator) {
912912

913913
try{
914914
RadioButton rb = (RadioButton)objectToNode(locator);
@@ -1130,7 +1130,7 @@ public void selectContextMenuItem(String item){
11301130
+ "``locator`` is either a _query_ or _Object:Node_ for identifying the ToggleButton element, see "
11311131
+ " `3. Locating or specifying UI elements`. \n\n")
11321132
@ArgumentNames({ "locator" })
1133-
public static Object getProgressBarValue(Object locator) {
1133+
public Object getProgressBarValue(Object locator) {
11341134
try{
11351135
ProgressBar pb = (ProgressBar) objectToNode(locator);
11361136
return mapObject(pb.getProgress());
@@ -1144,7 +1144,7 @@ public static Object getProgressBarValue(Object locator) {
11441144
+ "``timeout`` is the maximum time in seconds that the events will be waited for. If the timeout is "
11451145
+ "exceeded the keyword will fail. Default timeout is 5 seconds.\n\n")
11461146
@ArgumentNames({ "timeout=" })
1147-
public static void waitForEventsInFxApplicationThread(int timeout) throws Throwable {
1147+
public void waitForEventsInFxApplicationThread(int timeout) {
11481148

11491149
final Throwable[] threadException = new JavaFXLibraryNonFatalException[1];
11501150
try {
@@ -1171,7 +1171,7 @@ public static void waitForEventsInFxApplicationThread(int timeout) throws Throwa
11711171
semaphore.acquire();
11721172

11731173
if (threadException[0] != null)
1174-
throw threadException[0];
1174+
throw new JavaFXLibraryNonFatalException(threadException[0].getMessage());
11751175

11761176
} catch (InterruptedException e) {
11771177
throw new JavaFXLibraryNonFatalException("Wait For Events in Fx Application Thread was interrupted: "
@@ -1180,7 +1180,7 @@ public static void waitForEventsInFxApplicationThread(int timeout) throws Throwa
11801180
}
11811181

11821182
@RobotKeywordOverload
1183-
public static void waitForEventsInFxApplicationThread() throws Throwable {
1183+
public void waitForEventsInFxApplicationThread() {
11841184
waitForEventsInFxApplicationThread(HelperFunctions.getWaitUntilTimeout());
11851185
}
11861186
}

src/test/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywordsTest.java renamed to src/test/java/javafxlibrary/keywords/AdditionalKeywordsTests/ConvenienceKeywords/DeprecatedFindKeywordsTest.java

+14-17
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,36 @@
1515
* limitations under the License.
1616
*/
1717

18-
package javafxlibrary.keywords.AdditionalKeywords;
18+
package javafxlibrary.keywords.AdditionalKeywordsTests.ConvenienceKeywords;
1919

2020
import java.util.List;
2121
import com.google.common.collect.ImmutableSet;
2222
import javafx.css.PseudoClass;
2323
import javafx.scene.control.Button;
2424
import javafxlibrary.TestFxAdapterTest;
25-
import javafxlibrary.exceptions.JavaFXLibraryNonFatalException;
25+
import javafxlibrary.keywords.AdditionalKeywords.ConvenienceKeywords;
2626
import javafxlibrary.utils.HelperFunctions;
2727
import mockit.Expectations;
2828
import mockit.Mocked;
2929
import org.junit.Assert;
3030
import org.junit.Before;
31+
import org.junit.BeforeClass;
3132
import org.junit.Test;
3233
import org.testfx.service.query.NodeQuery;
3334

34-
public class ConvenienceKeywordsTest extends TestFxAdapterTest {
35+
public class DeprecatedFindKeywordsTest extends TestFxAdapterTest {
3536

3637
@Mocked
3738
NodeQuery rootQuery;
3839

3940
private Button button;
4041
private Button button2;
41-
private ConvenienceKeywords keywords = new ConvenienceKeywords();
42+
private static ConvenienceKeywords keywords;
43+
44+
@BeforeClass
45+
public static void setupAllTests() {
46+
keywords = new ConvenienceKeywords();
47+
}
4248

4349
@Before
4450
public void setup() {
@@ -57,20 +63,15 @@ public void setup() {
5763
@Test
5864
public void findAllWithPseudoClass() {
5965
expectTwoButtonsFromNodeQuery();
60-
6166
List<Object> allWithPseudoClass = keywords.findAllWithPseudoClass("rootId", "selected");
6267
Assert.assertEquals(HelperFunctions.mapObject(button), allWithPseudoClass.get(0));
6368
}
6469

6570
@Test
6671
public void findNoPseudoClasses() {
6772
expectTwoButtonsFromNodeQuery();
68-
try {
69-
List<Object> hits = keywords.findAllWithPseudoClass("rootId", "something");
70-
Assert.assertEquals(0, hits.size());
71-
} catch (JavaFXLibraryNonFatalException e) {
72-
73-
}
73+
List<Object> hits = keywords.findAllWithPseudoClass("rootId", "something");
74+
Assert.assertEquals(0, hits.size());
7475
}
7576

7677
@Test
@@ -81,12 +82,8 @@ public void findNoNodes() {
8182
result = ImmutableSet.of();
8283
}
8384
};
84-
try {
85-
List<Object> hits = keywords.findAllWithPseudoClass("rootId", "something");
86-
Assert.assertEquals(0, hits.size());
87-
} catch (JavaFXLibraryNonFatalException e) {
88-
89-
}
85+
List<Object> hits = keywords.findAllWithPseudoClass("rootId", "something");
86+
Assert.assertEquals(0, hits.size());
9087
}
9188

9289
private void expectTwoButtonsFromNodeQuery() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright 2017-2018 Eficode Oy
3+
* Copyright 2018- Robot Framework Foundation
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package javafxlibrary.keywords.AdditionalKeywordsTests.ConvenienceKeywords;
19+
20+
import javafx.application.Platform;
21+
import javafx.scene.control.Button;
22+
import javafxlibrary.TestFxAdapterTest;
23+
import javafxlibrary.exceptions.JavaFXLibraryNonFatalException;
24+
import javafxlibrary.keywords.AdditionalKeywords.ConvenienceKeywords;
25+
import org.junit.Assert;
26+
import org.junit.BeforeClass;
27+
import org.junit.Rule;
28+
import org.junit.Test;
29+
import org.junit.rules.ExpectedException;
30+
31+
public class WaitForEventsInFxApplicationThreadTest extends TestFxAdapterTest {
32+
33+
@Rule
34+
public ExpectedException thrown = ExpectedException.none();
35+
36+
private static ConvenienceKeywords keywords;
37+
38+
@BeforeClass
39+
public static void setupTests() {
40+
keywords = new ConvenienceKeywords();
41+
}
42+
43+
@Test
44+
public void waitForEventsInFxApplicationThread() {
45+
Button b = createDelayedButton(2000);
46+
Platform.runLater(() -> b.fire());
47+
keywords.waitForEventsInFxApplicationThread(2);
48+
Assert.assertEquals("ChangedText", b.getText());
49+
}
50+
51+
@Test
52+
public void waitForEventsInFxApplicationThread_TimeoutExceeded() {
53+
thrown.expect(JavaFXLibraryNonFatalException.class);
54+
thrown.expectMessage("Events did not finish within the given timeout of 1 seconds.");
55+
Button b = createDelayedButton(3000);
56+
Platform.runLater(() -> b.fire());
57+
keywords.waitForEventsInFxApplicationThread(1);
58+
}
59+
60+
private Button createDelayedButton(int timeout) {
61+
Button b = new Button("OriginalText");
62+
b.setOnAction((e) -> {
63+
try {
64+
Thread.sleep(timeout);
65+
b.setText("ChangedText");
66+
} catch (InterruptedException ie) {
67+
ie.printStackTrace();
68+
}
69+
});
70+
return b;
71+
}
72+
}

0 commit comments

Comments
 (0)