changeset 1490:adb6dfe2b231

Added test for javafx
author Jiri Vanek <jvanek@redhat.com>
date Tue, 06 Feb 2018 18:54:24 +0100
parents d4bf1eaafa50
children e9d1156e0e54
files ChangeLog tests/reproducers/custom/JavaFx/resources/JavaFx.jar tests/reproducers/custom/JavaFx/resources/JavaFx.jnlp tests/reproducers/custom/JavaFx/srcs/Controller.java tests/reproducers/custom/JavaFx/srcs/Main.java tests/reproducers/custom/JavaFx/srcs/Makefile tests/reproducers/custom/JavaFx/srcs/helloworld.fxml tests/reproducers/custom/JavaFx/testcases/JavaFxTest.java
diffstat 8 files changed, 170 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Feb 06 17:11:25 2018 +0100
+++ b/ChangeLog	Tue Feb 06 18:54:24 2018 +0100
@@ -1,3 +1,16 @@
+2018-02-06  Jiri Vanek <jvanek@redhat.com>
+
+	Added test for javafx-desc
+	* tests/reproducers/custom/JavaFx/resources/JavaFx.jar
+	* tests/reproducers/custom/JavaFx/resources/JavaFx.jnlp
+	* tests/reproducers/custom/JavaFx/srcs/Controller.class
+	* tests/reproducers/custom/JavaFx/srcs/Controller.java
+	* tests/reproducers/custom/JavaFx/srcs/Main.class
+	* tests/reproducers/custom/JavaFx/srcs/Main.java
+	* tests/reproducers/custom/JavaFx/srcs/Makefile
+	* tests/reproducers/custom/JavaFx/srcs/helloworld.fxml
+	* tests/reproducers/custom/JavaFx/testcases/JavaFxTest.java
+
 2018-02-05  Jiri Vanek <jvanek@redhat.com>
 
 	Fixed news for latest changes
Binary file tests/reproducers/custom/JavaFx/resources/JavaFx.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/custom/JavaFx/resources/JavaFx.jnlp	Tue Feb 06 18:54:24 2018 +0100
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<jnlp spec="1.0" xmlns:jfx="http://javafx.com" >
+  <information>
+    <title>JavaFx</title>
+    <vendor>ITW</vendor>
+    <description>JavaFx</description>
+    <offline-allowed/>
+  </information>
+  <resources>
+    <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
+    <jar href="JavaFx.jar" size="2102" download="eager" />
+  </resources>
+  <jfx:javafx-desc  width="600" height="400" main-class="Main"  name="JavaFXApp" />
+  <update check="background"/>
+</jnlp>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/custom/JavaFx/srcs/Controller.java	Tue Feb 06 18:54:24 2018 +0100
@@ -0,0 +1,11 @@
+import javafx.fxml.FXML;
+import javafx.scene.text.Text;
+
+public class Controller {
+    @FXML private Text text;
+
+    @FXML
+    public void onPressButton() {
+        text.setVisible(true);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/custom/JavaFx/srcs/Main.java	Tue Feb 06 18:54:24 2018 +0100
@@ -0,0 +1,23 @@
+import javafx.application.Application;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Parent;
+import javafx.scene.Scene;
+import javafx.stage.Stage;
+
+public class Main extends Application {
+
+    @Override
+    public void start(Stage primaryStage) throws Exception {
+        Parent root = FXMLLoader.load(getClass().getResource("helloworld.fxml"));
+        primaryStage.setTitle("Hello World");
+        primaryStage.setScene(new Scene(root, 500, 200));
+        primaryStage.show();
+        System.out.println("jnlp-javafx started");
+        System.out.println("jnlp-javafx can be terminated");
+    }
+
+
+    public static void main(String[] args) {
+        launch(args);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/custom/JavaFx/srcs/Makefile	Tue Feb 06 18:54:24 2018 +0100
@@ -0,0 +1,25 @@
+TESTNAME=JavaFx
+
+JAVAC_CLASSPATH=$(TEST_EXTENSIONS_DIR):$(NETX_DIR)/lib/classes.jar
+JAVAC=$(EXPORTED_JAVAC)
+JAR=$(EXPORTED_JAR)
+JARSIGNER=$(EXPORTED_JARSIGNER)
+
+TMPDIR:=$(shell mktemp -d)
+
+prepare-reproducer:
+	echo PREPARING REPRODUCER $(TESTNAME)
+	#this test contains prebuild binary, as javafx, when installed on computer, preven ITW from building
+	#due to JSObject differennt implementation
+	#$(JAVAC) -d $(TMPDIR) -classpath $(JAVAC_CLASSPATH) Controller.java Main.java; \
+	#cp helloworld.fxml $(TMPDIR) ; \
+	#pushd $(TMPDIR); \
+	#$(JAR) cf $(TESTNAME).jar *.class *.fxml; \
+	#popd
+	#cp $(TMPDIR)/$(TESTNAME).jar $(REPRODUCERS_TESTS_SERVER_DEPLOYDIR); \
+	cp ../resources/* $(REPRODUCERS_TESTS_SERVER_DEPLOYDIR); \
+	rm -rf $(TMPDIR); \
+	echo PREPARED REPRODUCER $(TESTNAME); \
+
+clean-reproducer:
+	echo NOTHING TO CLEAN FOR $(TESTNAME)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/custom/JavaFx/srcs/helloworld.fxml	Tue Feb 06 18:54:24 2018 +0100
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<?import javafx.scene.layout.GridPane?>
+<?import javafx.scene.text.Text?>
+<?import javafx.scene.control.Button?>
+<GridPane fx:controller="Controller"
+          xmlns:fx="http://javafx.com/fxml"
+          alignment="CENTER">
+    <Text text="Hello"
+          GridPane.columnIndex="0" GridPane.rowIndex="0" GridPane.halignment="CENTER"/>
+    <Button fx:id="button" text="press if you're brave enough"
+            GridPane.columnIndex="0" GridPane.rowIndex="1" GridPane.halignment="CENTER"
+            onAction="#onPressButton"/>
+    <Text fx:id="text" text="BAF!" style="-fx-text-fill: red; -fx-font-size: 50; -fx-fill: red;"
+          GridPane.rowIndex="2" GridPane.columnIndex="0" GridPane.halignment="CENTER"
+          visible="false"/>
+</GridPane>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/custom/JavaFx/testcases/JavaFxTest.java	Tue Feb 06 18:54:24 2018 +0100
@@ -0,0 +1,66 @@
+/* 
+Copyright (C) 2014 Red Hat, Inc.
+
+This file is part of IcedTea.
+
+IcedTea is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License as published by
+the Free Software Foundation, version 2.
+
+IcedTea is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with IcedTea; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version.
+ */
+
+import java.util.Arrays;
+import net.sourceforge.jnlp.OptionsDefinitions;
+import org.junit.Assert;
+import org.junit.Test;
+
+import net.sourceforge.jnlp.ProcessResult;
+import net.sourceforge.jnlp.ServerAccess;
+import net.sourceforge.jnlp.annotations.NeedsDisplay;
+import net.sourceforge.jnlp.closinglisteners.StringBasedClosingListener;
+
+public class JavaFxTest {
+
+    private static final String correct = "jnlp-javafx started";
+    private static final String done = "jnlp-javafx can be terminated";
+    public static final ServerAccess server = new ServerAccess();
+
+    @Test
+    @NeedsDisplay
+    public void testJavawsJNLP() throws Exception {
+        ProcessResult pr = server.executeJavaws(
+                Arrays.asList(new String[]{OptionsDefinitions.OPTIONS.NOSEC.option}),
+                "/JavaFx.jnlp",
+                new StringBasedClosingListener(done),
+                new StringBasedClosingListener("xceptionxception"));
+        /System.out.println(pr.stdout);
+        /System.out.println(pr.stderr);
+        Assert.assertTrue("stdout should contain " + correct + ", but it didnt.", pr.stdout.contains(correct));
+    }
+}