Skip to content

Commit

Permalink
Merge pull request #2 from aalmiray/fxml-updates
Browse files Browse the repository at this point in the history
Fxml updates + TestFX
  • Loading branch information
miho authored Oct 17, 2016
2 parents 1174c20 + 3acf3cb commit e34f7b0
Show file tree
Hide file tree
Showing 7 changed files with 210 additions and 4 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
/.nb-gradle/
.nb-gradle/
.idea/
.gradle/
out/
build/
16 changes: 13 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
plugins {
id "com.github.hierynomus.license" version "0.13.1"
id 'com.github.hierynomus.license' version '0.13.1'
id 'maven-publish'
id "net.nemerosa.versioning" version "2.4.0"
id 'com.jfrog.bintray' version '1.7.1'
id 'net.nemerosa.versioning' version '2.4.0'
id 'com.jfrog.bintray' version '1.7.2'
id 'com.github.ben-manes.versions' version '0.13.0'
}

apply plugin: 'java'
Expand Down Expand Up @@ -31,3 +32,12 @@ license {
ext.year = '2016-2016'
ext.author = 'Michael Hoffer <[email protected]>'
}

repositories {
jcenter()
}

dependencies {
testCompile 'org.testfx:testfx-core:4.0.4-alpha'
testCompile 'org.testfx:testfx-junit:4.0.4-alpha'
}
2 changes: 2 additions & 0 deletions src/main/java/eu/mihosoft/scaledfx/ScalableContentPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
package eu.mihosoft.scaledfx;

import javafx.beans.DefaultProperty;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.ObjectProperty;
Expand All @@ -51,6 +52,7 @@
*
* @author Michael Hoffer &lt;[email protected]&gt;
*/
@DefaultProperty("content")
public class ScalableContentPane extends Region {

private Scale contentScaleTransform;
Expand Down
58 changes: 58 additions & 0 deletions src/test/java/eu/mihosoft/scaledfx/ExplicitContentTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright 2016-2016 Michael Hoffer <[email protected]>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY Michael Hoffer <[email protected]> "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Michael Hoffer <[email protected]> OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of Michael Hoffer <[email protected]>.
*/
package eu.mihosoft.scaledfx;

import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.junit.Test;
import org.testfx.framework.junit.ApplicationTest;

import java.net.URL;

import static org.testfx.api.FxAssert.verifyThat;
import static org.testfx.matcher.base.NodeMatchers.hasChildren;

/**
* @author Andres Almiray
*/
public class ExplicitContentTest extends ApplicationTest {
@Override
public void start(Stage stage) throws Exception {
URL location = getClass().getClassLoader().getResource("eu/mihosoft/scaledfx/explicit_content.fxml");
FXMLLoader fxml = new FXMLLoader(location);
stage.setScene(new Scene(fxml.load()));
stage.sizeToScene();
stage.show();
}

@Test
public void contentIsSet() {
verifyThat("#pane", hasChildren(1, "#button"));
}
}
58 changes: 58 additions & 0 deletions src/test/java/eu/mihosoft/scaledfx/ImplicitContentTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright 2016-2016 Michael Hoffer <[email protected]>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY Michael Hoffer <[email protected]> "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Michael Hoffer <[email protected]> OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of Michael Hoffer <[email protected]>.
*/
package eu.mihosoft.scaledfx;

import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.junit.Test;
import org.testfx.framework.junit.ApplicationTest;

import java.net.URL;

import static org.testfx.api.FxAssert.verifyThat;
import static org.testfx.matcher.base.NodeMatchers.hasChildren;

/**
* @author Andres Almiray
*/
public class ImplicitContentTest extends ApplicationTest {
@Override
public void start(Stage stage) throws Exception {
URL location = getClass().getClassLoader().getResource("eu/mihosoft/scaledfx/implicit_content.fxml");
FXMLLoader fxml = new FXMLLoader(location);
stage.setScene(new Scene(fxml.load()));
stage.sizeToScene();
stage.show();
}

@Test
public void contentIsSet() {
verifyThat("#pane", hasChildren(1, "#button"));
}
}
38 changes: 38 additions & 0 deletions src/test/resources/eu/mihosoft/scaledfx/explicit_content.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016-2016 Michael Hoffer <[email protected]>. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
THIS SOFTWARE IS PROVIDED BY Michael Hoffer <[email protected]> "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Michael Hoffer <[email protected]> OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those of the
authors and should not be interpreted as representing official policies, either expressed
or implied, of Michael Hoffer <[email protected]>.
-->

<?import eu.mihosoft.scaledfx.ScalableContentPane?>
<?import javafx.scene.control.Button?>
<ScalableContentPane fx:id="pane" xmlns:fx="http://javafx.com/fxml" prefWidth="100" prefHeight="60">
<content>
<Button fx:id="button" text="explicit"/>
</content>
</ScalableContentPane>
36 changes: 36 additions & 0 deletions src/test/resources/eu/mihosoft/scaledfx/implicit_content.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016-2016 Michael Hoffer <[email protected]>. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
THIS SOFTWARE IS PROVIDED BY Michael Hoffer <[email protected]> "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Michael Hoffer <[email protected]> OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those of the
authors and should not be interpreted as representing official policies, either expressed
or implied, of Michael Hoffer <[email protected]>.
-->

<?import eu.mihosoft.scaledfx.ScalableContentPane?>
<?import javafx.scene.control.Button?>
<ScalableContentPane fx:id="pane" xmlns:fx="http://javafx.com/fxml" prefWidth="100" prefHeight="60">
<Button fx:id="button" text="implicit"/>
</ScalableContentPane>

0 comments on commit e34f7b0

Please sign in to comment.