Skip to content

Commit e34f7b0

Browse files
authored
Merge pull request #2 from aalmiray/fxml-updates
Fxml updates + TestFX
2 parents 1174c20 + 3acf3cb commit e34f7b0

File tree

7 files changed

+210
-4
lines changed

7 files changed

+210
-4
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
/.nb-gradle/
1+
.nb-gradle/
2+
.idea/
3+
.gradle/
4+
out/
5+
build/

build.gradle

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
plugins {
2-
id "com.github.hierynomus.license" version "0.13.1"
2+
id 'com.github.hierynomus.license' version '0.13.1'
33
id 'maven-publish'
4-
id "net.nemerosa.versioning" version "2.4.0"
5-
id 'com.jfrog.bintray' version '1.7.1'
4+
id 'net.nemerosa.versioning' version '2.4.0'
5+
id 'com.jfrog.bintray' version '1.7.2'
6+
id 'com.github.ben-manes.versions' version '0.13.0'
67
}
78

89
apply plugin: 'java'
@@ -31,3 +32,12 @@ license {
3132
ext.year = '2016-2016'
3233
ext.author = 'Michael Hoffer <[email protected]>'
3334
}
35+
36+
repositories {
37+
jcenter()
38+
}
39+
40+
dependencies {
41+
testCompile 'org.testfx:testfx-core:4.0.4-alpha'
42+
testCompile 'org.testfx:testfx-junit:4.0.4-alpha'
43+
}

src/main/java/eu/mihosoft/scaledfx/ScalableContentPane.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
*/
2828
package eu.mihosoft.scaledfx;
2929

30+
import javafx.beans.DefaultProperty;
3031
import javafx.beans.property.BooleanProperty;
3132
import javafx.beans.property.DoubleProperty;
3233
import javafx.beans.property.ObjectProperty;
@@ -51,6 +52,7 @@
5152
*
5253
* @author Michael Hoffer &lt;[email protected]&gt;
5354
*/
55+
@DefaultProperty("content")
5456
public class ScalableContentPane extends Region {
5557

5658
private Scale contentScaleTransform;
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright 2016-2016 Michael Hoffer <[email protected]>. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without modification, are
5+
* permitted provided that the following conditions are met:
6+
*
7+
* 1. Redistributions of source code must retain the above copyright notice, this list of
8+
* conditions and the following disclaimer.
9+
*
10+
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
11+
* of conditions and the following disclaimer in the documentation and/or other materials
12+
* provided with the distribution.
13+
*
14+
* THIS SOFTWARE IS PROVIDED BY Michael Hoffer <[email protected]> "AS IS" AND ANY EXPRESS OR IMPLIED
15+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16+
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Michael Hoffer <[email protected]> OR
17+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20+
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22+
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23+
*
24+
* The views and conclusions contained in the software and documentation are those of the
25+
* authors and should not be interpreted as representing official policies, either expressed
26+
* or implied, of Michael Hoffer <[email protected]>.
27+
*/
28+
package eu.mihosoft.scaledfx;
29+
30+
import javafx.fxml.FXMLLoader;
31+
import javafx.scene.Scene;
32+
import javafx.stage.Stage;
33+
import org.junit.Test;
34+
import org.testfx.framework.junit.ApplicationTest;
35+
36+
import java.net.URL;
37+
38+
import static org.testfx.api.FxAssert.verifyThat;
39+
import static org.testfx.matcher.base.NodeMatchers.hasChildren;
40+
41+
/**
42+
* @author Andres Almiray
43+
*/
44+
public class ExplicitContentTest extends ApplicationTest {
45+
@Override
46+
public void start(Stage stage) throws Exception {
47+
URL location = getClass().getClassLoader().getResource("eu/mihosoft/scaledfx/explicit_content.fxml");
48+
FXMLLoader fxml = new FXMLLoader(location);
49+
stage.setScene(new Scene(fxml.load()));
50+
stage.sizeToScene();
51+
stage.show();
52+
}
53+
54+
@Test
55+
public void contentIsSet() {
56+
verifyThat("#pane", hasChildren(1, "#button"));
57+
}
58+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright 2016-2016 Michael Hoffer <[email protected]>. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without modification, are
5+
* permitted provided that the following conditions are met:
6+
*
7+
* 1. Redistributions of source code must retain the above copyright notice, this list of
8+
* conditions and the following disclaimer.
9+
*
10+
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
11+
* of conditions and the following disclaimer in the documentation and/or other materials
12+
* provided with the distribution.
13+
*
14+
* THIS SOFTWARE IS PROVIDED BY Michael Hoffer <[email protected]> "AS IS" AND ANY EXPRESS OR IMPLIED
15+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16+
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Michael Hoffer <[email protected]> OR
17+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20+
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22+
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23+
*
24+
* The views and conclusions contained in the software and documentation are those of the
25+
* authors and should not be interpreted as representing official policies, either expressed
26+
* or implied, of Michael Hoffer <[email protected]>.
27+
*/
28+
package eu.mihosoft.scaledfx;
29+
30+
import javafx.fxml.FXMLLoader;
31+
import javafx.scene.Scene;
32+
import javafx.stage.Stage;
33+
import org.junit.Test;
34+
import org.testfx.framework.junit.ApplicationTest;
35+
36+
import java.net.URL;
37+
38+
import static org.testfx.api.FxAssert.verifyThat;
39+
import static org.testfx.matcher.base.NodeMatchers.hasChildren;
40+
41+
/**
42+
* @author Andres Almiray
43+
*/
44+
public class ImplicitContentTest extends ApplicationTest {
45+
@Override
46+
public void start(Stage stage) throws Exception {
47+
URL location = getClass().getClassLoader().getResource("eu/mihosoft/scaledfx/implicit_content.fxml");
48+
FXMLLoader fxml = new FXMLLoader(location);
49+
stage.setScene(new Scene(fxml.load()));
50+
stage.sizeToScene();
51+
stage.show();
52+
}
53+
54+
@Test
55+
public void contentIsSet() {
56+
verifyThat("#pane", hasChildren(1, "#button"));
57+
}
58+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright 2016-2016 Michael Hoffer <[email protected]>. All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without modification, are
7+
permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this list of
10+
conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice, this list
13+
of conditions and the following disclaimer in the documentation and/or other materials
14+
provided with the distribution.
15+
16+
THIS SOFTWARE IS PROVIDED BY Michael Hoffer <[email protected]> "AS IS" AND ANY EXPRESS OR IMPLIED
17+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
18+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Michael Hoffer <[email protected]> OR
19+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
22+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25+
26+
The views and conclusions contained in the software and documentation are those of the
27+
authors and should not be interpreted as representing official policies, either expressed
28+
or implied, of Michael Hoffer <[email protected]>.
29+
30+
-->
31+
32+
<?import eu.mihosoft.scaledfx.ScalableContentPane?>
33+
<?import javafx.scene.control.Button?>
34+
<ScalableContentPane fx:id="pane" xmlns:fx="http://javafx.com/fxml" prefWidth="100" prefHeight="60">
35+
<content>
36+
<Button fx:id="button" text="explicit"/>
37+
</content>
38+
</ScalableContentPane>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright 2016-2016 Michael Hoffer <[email protected]>. All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without modification, are
7+
permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this list of
10+
conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice, this list
13+
of conditions and the following disclaimer in the documentation and/or other materials
14+
provided with the distribution.
15+
16+
THIS SOFTWARE IS PROVIDED BY Michael Hoffer <[email protected]> "AS IS" AND ANY EXPRESS OR IMPLIED
17+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
18+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Michael Hoffer <[email protected]> OR
19+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
22+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25+
26+
The views and conclusions contained in the software and documentation are those of the
27+
authors and should not be interpreted as representing official policies, either expressed
28+
or implied, of Michael Hoffer <[email protected]>.
29+
30+
-->
31+
32+
<?import eu.mihosoft.scaledfx.ScalableContentPane?>
33+
<?import javafx.scene.control.Button?>
34+
<ScalableContentPane fx:id="pane" xmlns:fx="http://javafx.com/fxml" prefWidth="100" prefHeight="60">
35+
<Button fx:id="button" text="implicit"/>
36+
</ScalableContentPane>

0 commit comments

Comments
 (0)