aboutsummaryrefslogtreecommitdiffstats
path: root/tests/netx/unit/net/sourceforge/jnlp
diff options
context:
space:
mode:
authorJiri Vanek <[email protected]>2012-08-13 15:52:03 +0200
committerJiri Vanek <[email protected]>2012-08-13 15:52:03 +0200
commit94049c8dd94caec6f2178e729893b2ba8cafbe74 (patch)
tree1f20174c59f6bd0e98d6549f07857afab19e7a19 /tests/netx/unit/net/sourceforge/jnlp
parenta0e3685615521759e08246d348dc6fbf58f8a6bc (diff)
Added splashscreen implementation
Diffstat (limited to 'tests/netx/unit/net/sourceforge/jnlp')
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/splashscreen/ErrorSplashScreenTest.java167
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/splashscreen/ErrorSplashUtilsTest.java213
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/splashscreen/SplashScreenTest.java185
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/splashscreen/SplashUtilsTest.java253
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainterTest.java108
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/ControlCurveTest.java307
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/CubicTest.java57
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/ErrorPainterTest.java113
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/MovingTextTest.java151
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/NatCubicClosedTest.java264
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/NatCubicTest.java264
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/SplinesDefsTest.java91
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/TextOutlineRendererTest.java127
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/TextWithWaterLevelTest.java131
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/BasicComponentErrorSplashScreenTest.java127
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/BasicComponentSplashScreenTest.java118
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/DescriptionInfoItemTest.java138
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/InfoItemTest.java111
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/InformationElementTest.java279
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialogTest.java190
20 files changed, 3394 insertions, 0 deletions
diff --git a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/ErrorSplashScreenTest.java b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/ErrorSplashScreenTest.java
new file mode 100644
index 0000000..7772237
--- /dev/null
+++ b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/ErrorSplashScreenTest.java
@@ -0,0 +1,167 @@
+/* SplashScreenTest.java
+Copyright (C) 2012 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; either version 2, or (at your option)
+any later version.
+
+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. */
+package net.sourceforge.jnlp.splashscreen;
+
+import java.awt.BorderLayout;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.image.BufferedImage;
+import javax.swing.JDialog;
+
+import net.sourceforge.jnlp.JNLPSplashScreen;
+import net.sourceforge.jnlp.splashscreen.parts.InfoItem;
+import net.sourceforge.jnlp.splashscreen.parts.InformationElement;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ErrorSplashScreenTest extends JDialog {
+
+ static int width = JNLPSplashScreen.DEF_WIDTH;
+ static int height = JNLPSplashScreen.DEF_HEIGHT;
+ static SplashErrorPanel panel;
+
+ public ErrorSplashScreenTest() {
+
+ setSize(width - getInsets().left - getInsets().right, height - getInsets().bottom - getInsets().top);
+// Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
+// int x = (int) ((dimension.getWidth() - getWidth()) / 2);
+// int y = (int) ((dimension.getHeight() - getHeight()) / 2);
+ //setLocation(x, y);
+ setLocationRelativeTo(null);
+ this.pack();
+ Exception ex = new Exception("Hi there");
+ panel = SplashUtils.getErrorSplashScreen(width, height, SplashUtils.SplashReason.JAVAWS, ex);
+ InformationElement ie = new InformationElement();
+ ie.setHomepage("http://someones.org/amazing?page");
+ ie.setTitle("Testing information title");
+ ie.setvendor("IcedTea-Web team");
+ ie.addDescription("Testing null description");
+ ie.addDescription("tsting twoline des ...break\ncription of kind short", InfoItem.descriptionKindShort);
+ panel.setInformationElement(ie);
+ panel.setVersion("1.2-re45fdg");
+ setLayout(new BorderLayout());
+ getContentPane().add(panel.getSplashComponent(), BorderLayout.CENTER);
+ addComponentListener(new ComponentListener() {
+
+ @Override
+ public void componentShown(ComponentEvent e) {
+ }
+
+ @Override
+ public void componentResized(ComponentEvent e) {
+ //panel.getSplashComponent().setSize(getWidth(), getHeight());
+ //panel.adjustForSize(getWidth(), getHeight());
+ }
+
+ @Override
+ public void componentMoved(ComponentEvent e) {
+ }
+
+ @Override
+ public void componentHidden(ComponentEvent e) {
+ }
+ });
+ }
+
+ @Test
+ public void splashScreenTestsExists() {
+ //to silence junit,and test is that thsi class was instantiated ;)
+ Assert.assertTrue(true);
+ }
+
+ @Test
+ public void splashScreenTestsPaint0() {
+ //to silence junit,and test is that thsi class was instantiated ;)
+ panel.setSplashWidth(width);
+ panel.setSplashHeight(height);
+ panel.adjustForSize();
+ BufferedImage buf = new BufferedImage(panel.getSplashWidth(), panel.getSplashHeight(), BufferedImage.TYPE_INT_ARGB);
+ panel.setPercentage(0);
+ panel.paintTo(buf.createGraphics());
+ //ImageFontCutterTest.save(buf,"e0");
+ }
+
+ @Test
+ public void splashScreenTestsPaint50() {
+ //to silence junit,and test is that thsi class was instantiated ;)
+ panel.setSplashWidth(width);
+ panel.setSplashHeight(height);
+ panel.adjustForSize();
+ BufferedImage buf = new BufferedImage(panel.getSplashWidth(), panel.getSplashHeight(), BufferedImage.TYPE_INT_ARGB);
+ panel.setPercentage(50);
+ panel.paintTo(buf.createGraphics());
+ // ImageFontCutterTest.save(buf,"e50");
+ }
+
+ @Test
+ public void splashScreenTestsPaint100() {
+ //to silence junit,and test is that thsi class was instantiated ;)
+ panel.setSplashWidth(width);
+ panel.setSplashHeight(height);
+ panel.adjustForSize();
+ BufferedImage buf = new BufferedImage(panel.getSplashWidth(), panel.getSplashHeight(), BufferedImage.TYPE_INT_ARGB);
+ panel.setPercentage(100);
+ panel.paintTo(buf.createGraphics());
+ // ImageFontCutterTest.save(buf,"e100");
+ }
+
+ public static void main(String args[]) {
+ ErrorSplashScreenTest app = new ErrorSplashScreenTest();
+ app.setVisible(true);
+ app.addWindowListener(
+ new WindowAdapter() {
+
+ @Override
+ public void windowClosing(WindowEvent e) {
+ System.exit(0);
+ }
+ });
+ panel.setPercentage(30);
+ //panel.startAnimation();
+
+ try {
+ Thread.sleep(10000);
+ } catch (Exception e) {
+ }
+
+ panel.stopAnimation();
+
+
+ }
+}
diff --git a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/ErrorSplashUtilsTest.java b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/ErrorSplashUtilsTest.java
new file mode 100644
index 0000000..650fd32
--- /dev/null
+++ b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/ErrorSplashUtilsTest.java
@@ -0,0 +1,213 @@
+/* SplashUtils.java
+Copyright (C) 2012 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; either version 2, or (at your option)
+any later version.
+
+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. */
+package net.sourceforge.jnlp.splashscreen;
+
+import java.util.HashMap;
+import java.util.Map;
+import net.sourceforge.jnlp.splashscreen.impls.*;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ErrorSplashUtilsTest {
+
+ private void fakeEnvironment(Map original) throws Exception {
+ SplashUtilsTest.fakeEnvironment(original);
+ }
+
+ private Map getEnvironment() throws Exception {
+ return SplashUtilsTest.getEnvironment();
+ }
+
+ @Test
+ public void determineCallerTest() {
+ SplashUtilsTest.modifyRuntime(false);
+ SplashPanel p1 = SplashUtils.getErrorSplashScreen(100, 100,null);
+ Assert.assertEquals(SplashUtils.SplashReason.APPLET, p1.getSplashReason());
+ SplashUtilsTest.modifyRuntime(true);
+ SplashPanel p2 = SplashUtils.getErrorSplashScreen(100, 100,null);
+ Assert.assertEquals(SplashUtils.SplashReason.JAVAWS, p2.getSplashReason());
+ }
+
+ @Test
+ public void testgetErrorSplashScreen1() throws Exception {
+ Map fake1 = new HashMap();
+ Map original = getEnvironment();
+ Assert.assertNotNull(original);
+ try {
+ fakeEnvironment(fake1);
+ SplashPanel sa = SplashUtils.getErrorSplashScreen(100, 100, SplashUtils.SplashReason.APPLET, null);
+ Assert.assertTrue(sa instanceof DefaultErrorSplashScreen2012);
+ Assert.assertTrue(sa.getSplashReason() == SplashUtils.SplashReason.APPLET);
+ SplashPanel sw = SplashUtils.getErrorSplashScreen(100, 100, SplashUtils.SplashReason.JAVAWS, new Exception("oj"));
+ Assert.assertTrue(sw instanceof DefaultErrorSplashScreen2012);
+ Assert.assertTrue(sw.getSplashReason() == SplashUtils.SplashReason.JAVAWS);
+ } finally {
+ fakeEnvironment(original);
+ }
+
+
+
+ }
+
+ @Test
+ public void testgetErrorSplashScreen2() throws Exception {
+ Map fake1 = new HashMap();
+ fake1.put(SplashUtils.ICEDTEA_WEB_SPLASH, SplashUtils.DEFAULT);
+ fake1.put(SplashUtils.ICEDTEA_WEB_PLUGIN_SPLASH, SplashUtils.DEFAULT);
+ Map original = getEnvironment();
+ Assert.assertNotNull(original);
+ try {
+ fakeEnvironment(fake1);
+ SplashPanel sa = SplashUtils.getErrorSplashScreen(100, 100, SplashUtils.SplashReason.APPLET, new Exception("oj"));
+ Assert.assertTrue(sa instanceof DefaultErrorSplashScreen2012);
+ Assert.assertTrue(sa.getSplashReason() == SplashUtils.SplashReason.APPLET);
+ SplashPanel sw = SplashUtils.getErrorSplashScreen(100, 100, SplashUtils.SplashReason.JAVAWS, null);
+ Assert.assertTrue(sw instanceof DefaultErrorSplashScreen2012);
+ Assert.assertTrue(sw.getSplashReason() == SplashUtils.SplashReason.JAVAWS);
+ } finally {
+ fakeEnvironment(original);
+ }
+
+
+ }
+
+ @Test
+ public void testgetErrorSplashScreen3() throws Exception {
+ Map fake1 = new HashMap();
+ fake1.put(SplashUtils.ICEDTEA_WEB_SPLASH, SplashUtils.NONE);
+ fake1.put(SplashUtils.ICEDTEA_WEB_PLUGIN_SPLASH, SplashUtils.DEFAULT);
+ Map original = getEnvironment();
+ Assert.assertNotNull(original);
+ try {
+ fakeEnvironment(fake1);
+ SplashPanel sa = SplashUtils.getErrorSplashScreen(100, 100, SplashUtils.SplashReason.APPLET, null);
+ Assert.assertTrue(sa instanceof DefaultErrorSplashScreen2012);
+ Assert.assertTrue(sa.getSplashReason() == SplashUtils.SplashReason.APPLET);
+ SplashPanel sw = SplashUtils.getErrorSplashScreen(100, 100, SplashUtils.SplashReason.JAVAWS, new Exception("oj"));
+ Assert.assertTrue(sw == null);
+ } finally {
+ fakeEnvironment(original);
+ }
+
+
+
+ }
+
+ @Test
+ public void testgetErrorSplashScreen4() throws Exception {
+ Map fake1 = new HashMap();
+ fake1.put(SplashUtils.ICEDTEA_WEB_SPLASH, SplashUtils.DEFAULT);
+ fake1.put(SplashUtils.ICEDTEA_WEB_PLUGIN_SPLASH, SplashUtils.NONE);
+ Map original = getEnvironment();
+ Assert.assertNotNull(original);
+ try {
+ fakeEnvironment(fake1);
+ SplashPanel sa = SplashUtils.getErrorSplashScreen(100, 100, SplashUtils.SplashReason.APPLET, new Exception("oj"));
+ Assert.assertTrue(sa == null);
+ SplashPanel sw = SplashUtils.getErrorSplashScreen(100, 100, SplashUtils.SplashReason.JAVAWS, new Exception("oj"));
+ Assert.assertTrue(sw instanceof DefaultErrorSplashScreen2012);
+ Assert.assertTrue(sw.getSplashReason() == SplashUtils.SplashReason.JAVAWS);
+ } finally {
+ fakeEnvironment(original);
+ }
+
+
+
+ }
+
+ @Test
+ public void testgetErrorSplashScreen5() throws Exception {
+ Map fake1 = new HashMap();
+ fake1.put(SplashUtils.ICEDTEA_WEB_SPLASH, SplashUtils.NONE);
+ fake1.put(SplashUtils.ICEDTEA_WEB_PLUGIN_SPLASH, SplashUtils.NONE);
+ Map original = getEnvironment();
+ Assert.assertNotNull(original);
+ try {
+ fakeEnvironment(fake1);
+ SplashPanel sa = SplashUtils.getErrorSplashScreen(100, 100, SplashUtils.SplashReason.APPLET, null);
+ Assert.assertTrue(sa == null);
+ SplashPanel sw = SplashUtils.getErrorSplashScreen(100, 100, SplashUtils.SplashReason.JAVAWS, null);
+ Assert.assertTrue(sw == null);
+ } finally {
+ fakeEnvironment(original);
+ }
+
+ }
+
+ @Test
+ public void testgetErrorSplashScreen6() throws Exception {
+ Map fake1 = new HashMap();
+ fake1.put(SplashUtils.ICEDTEA_WEB_SPLASH, SplashUtils.DEFAULT);
+ fake1.put(SplashUtils.ICEDTEA_WEB_PLUGIN_SPLASH, "fgdthyfjtuk");
+ Map original = getEnvironment();
+ Assert.assertNotNull(original);
+ try {
+ fakeEnvironment(fake1);
+ SplashPanel sa = SplashUtils.getErrorSplashScreen(100, 100, SplashUtils.SplashReason.APPLET, new Exception("oj"));
+ Assert.assertTrue(sa instanceof DefaultErrorSplashScreen2012);
+ Assert.assertTrue(sa.getSplashReason() == SplashUtils.SplashReason.APPLET);
+ SplashPanel sw = SplashUtils.getErrorSplashScreen(100, 100, SplashUtils.SplashReason.JAVAWS, new Exception("oj"));
+ Assert.assertTrue(sw instanceof DefaultErrorSplashScreen2012);
+ Assert.assertTrue(sw.getSplashReason() == SplashUtils.SplashReason.JAVAWS);
+ } finally {
+ fakeEnvironment(original);
+ }
+
+
+ }
+
+ @Test
+ public void testgetErrorSplashScreen7() throws Exception {
+ Map fake1 = new HashMap();
+ fake1.put(SplashUtils.ICEDTEA_WEB_SPLASH, "egtrutkyukl");
+ Map original = getEnvironment();
+ Assert.assertNotNull(original);
+ try {
+ fakeEnvironment(fake1);
+ SplashPanel sa = SplashUtils.getErrorSplashScreen(100, 100, SplashUtils.SplashReason.APPLET, null);
+ Assert.assertTrue(sa instanceof DefaultErrorSplashScreen2012);
+ Assert.assertTrue(sa.getSplashReason() == SplashUtils.SplashReason.APPLET);
+ SplashPanel sw = SplashUtils.getErrorSplashScreen(100, 100, SplashUtils.SplashReason.JAVAWS, null);
+ Assert.assertTrue(sw instanceof DefaultErrorSplashScreen2012);
+ Assert.assertTrue(sw.getSplashReason() == SplashUtils.SplashReason.JAVAWS);
+ } finally {
+ fakeEnvironment(original);
+ }
+
+
+ }
+}
diff --git a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/SplashScreenTest.java b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/SplashScreenTest.java
new file mode 100644
index 0000000..138ce58
--- /dev/null
+++ b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/SplashScreenTest.java
@@ -0,0 +1,185 @@
+/* SplashScreenTest.java
+Copyright (C) 2012 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; either version 2, or (at your option)
+any later version.
+
+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. */
+package net.sourceforge.jnlp.splashscreen;
+
+import java.awt.BorderLayout;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.image.BufferedImage;
+import javax.swing.JDialog;
+
+import net.sourceforge.jnlp.JNLPSplashScreen;
+import net.sourceforge.jnlp.splashscreen.impls.defaultsplashscreen2012.TextOutlineRendererTest;
+import net.sourceforge.jnlp.splashscreen.parts.InfoItem;
+import net.sourceforge.jnlp.splashscreen.parts.InformationElement;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class SplashScreenTest extends JDialog {
+
+ static int width = JNLPSplashScreen.DEF_WIDTH;
+ static int height = JNLPSplashScreen.DEF_HEIGHT;
+ static SplashPanel panel;
+ private static boolean swap = true;
+
+ public SplashScreenTest() {
+
+ setSize(width - getInsets().left - getInsets().right, height - getInsets().bottom - getInsets().top);
+// Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
+// int x = (int) ((dimension.getWidth() - getWidth()) / 2);
+// int y = (int) ((dimension.getHeight() - getHeight()) / 2);
+ //setLocation(x, y);
+ setLocationRelativeTo(null);
+ this.pack();
+ panel = SplashUtils.getSplashScreen(width, height, SplashUtils.SplashReason.JAVAWS);
+ InformationElement ie = new InformationElement();
+ ie.setHomepage("http://someones.org/amazing?page");
+ ie.setTitle("Testing information title");
+ ie.setvendor("IcedTea-Web team");
+ ie.addDescription("Testing null description");
+ ie.addDescription("tsting twoline des ...break\ncription of kind short", InfoItem.descriptionKindShort);
+ //panel.setInformationElement(ie);
+ //panel.setVersion("1.2-re45fdg");
+ setLayout(new BorderLayout());
+ getContentPane().add(panel.getSplashComponent(), BorderLayout.CENTER);
+
+ addComponentListener(new ComponentListener() {
+
+ @Override
+ public void componentShown(ComponentEvent e) {
+ }
+
+ @Override
+ public void componentResized(ComponentEvent e) {
+ //panel.getSplashComponent().setSize(getWidth(), getHeight());
+ //panel.adjustForSize(getWidth(), getHeight());
+ }
+
+ @Override
+ public void componentMoved(ComponentEvent e) {
+ }
+
+ @Override
+ public void componentHidden(ComponentEvent e) {
+ }
+ });
+ }
+
+ @Test
+ public void splashScreenTestsExists() {
+ //to silence junit,and test is that thsi class was instantiated ;)
+ Assert.assertTrue(true);
+ }
+
+ @Test
+ public void splashScreenTestsPaint0() {
+ //to silence junit,and test is that thsi class was instantiated ;)
+ panel.setSplashWidth(width);
+ panel.setSplashHeight(height);
+ panel.adjustForSize();
+ BufferedImage buf = new BufferedImage(panel.getSplashWidth(), panel.getSplashHeight(), BufferedImage.TYPE_INT_ARGB);
+ panel.setPercentage(0);
+ panel.paintTo(buf.createGraphics());
+ // TextOutlineRendererTest.save(buf,"s0");
+ }
+
+ @Test
+ public void splashScreenTestsPaint50() {
+ //to silence junit,and test is that thsi class was instantiated ;)
+ panel.setSplashWidth(width);
+ panel.setSplashHeight(height);
+ panel.adjustForSize();
+ BufferedImage buf = new BufferedImage(panel.getSplashWidth(), panel.getSplashHeight(), BufferedImage.TYPE_INT_ARGB);
+ panel.setPercentage(50);
+ panel.paintTo(buf.createGraphics());
+ // TextOutlineRendererTest.save(buf,"s50");
+ }
+
+ @Test
+ public void splashScreenTestsPaint100() {
+ //to silence junit,and test is that thsi class was instantiated ;)
+ panel.setSplashWidth(width);
+ panel.setSplashHeight(height);
+ panel.adjustForSize();
+ BufferedImage buf = new BufferedImage(panel.getSplashWidth(), panel.getSplashHeight(), BufferedImage.TYPE_INT_ARGB);
+ panel.setPercentage(100);
+ panel.paintTo(buf.createGraphics());
+ // TextOutlineRendererTest.save(buf,"s100");
+ }
+
+ public static void main(String args[]) {
+ SplashScreenTest app = new SplashScreenTest();
+ app.setVisible(true);
+
+ app.addWindowListener(
+ new WindowAdapter() {
+
+ @Override
+ public void windowClosing(WindowEvent e) {
+ System.exit(0);
+ }
+ });
+
+ panel.startAnimation();
+
+ try {
+ Thread.sleep(5000);
+ } catch (Exception e) {
+ }
+ //not needed
+ //panel.stopAnimation();
+ if (swap) {
+ SplashErrorPanel r = SplashUtils.getErrorSplashScreen(panel.getSplashWidth(), panel.getSplashHeight(), SplashUtils.SplashReason.JAVAWS, null);
+ app.remove(panel.getSplashComponent());
+ r.setPercentage(panel.getPercentage());
+ r.adjustForSize();
+ panel = r;
+ app.add(panel.getSplashComponent());
+ app.validateTree();
+ //app.pack();
+ //app.setVisible(true);
+ try {
+ Thread.sleep(10000);
+ } catch (Exception e) {
+ }
+ }
+
+
+ }
+}
diff --git a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/SplashUtilsTest.java b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/SplashUtilsTest.java
new file mode 100644
index 0000000..4d783d7
--- /dev/null
+++ b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/SplashUtilsTest.java
@@ -0,0 +1,253 @@
+/* SplashUtils.java
+Copyright (C) 2012 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; either version 2, or (at your option)
+any later version.
+
+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. */
+package net.sourceforge.jnlp.splashscreen;
+
+import java.lang.reflect.Field;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import net.sourceforge.jnlp.runtime.JNLPRuntime;
+import net.sourceforge.jnlp.splashscreen.impls.*;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class SplashUtilsTest {
+
+
+
+ @Test
+ public void determineCallerTest() {
+ modifyRuntime(false);
+ SplashPanel p1 = SplashUtils.getSplashScreen(100, 100);
+ Assert.assertEquals(SplashUtils.SplashReason.APPLET, p1.getSplashReason());
+ modifyRuntime(true);
+ SplashPanel p2 = SplashUtils.getSplashScreen(100, 100);
+ Assert.assertEquals(SplashUtils.SplashReason.JAVAWS, p2.getSplashReason());
+ }
+
+ public static Map<String, String> getEnvironment() throws Exception {
+ Class[] classes = Collections.class.getDeclaredClasses();
+ Map<String, String> env = System.getenv();
+ for (Class cl : classes) {
+ if ("java.util.Collections$UnmodifiableMap".equals(cl.getName())) {
+ Field field = cl.getDeclaredField("m");
+ field.setAccessible(true);
+ Object obj = field.get(env);
+ Map<String, String> map = (Map<String, String>) obj;
+ return map;
+ }
+ }
+ return null;
+ }
+
+ public static void fakeEnvironment(Map<String, String> newenv) throws Exception {
+ Class[] classes = Collections.class.getDeclaredClasses();
+ Map<String, String> env = System.getenv();
+ for (Class cl : classes) {
+ if ("java.util.Collections$UnmodifiableMap".equals(cl.getName())) {
+ Field field = cl.getDeclaredField("m");
+ field.setAccessible(true);
+ Object obj = field.get(env);
+ Map<String, String> map = (Map<String, String>) obj;
+ map.clear();
+ map.putAll(newenv);
+ }
+ }
+ }
+
+ @Test
+ public void testGetSplashScreen1() throws Exception {
+ Map fake1 = new HashMap();
+ Map original = getEnvironment();
+ Assert.assertNotNull(original);
+ try {
+ fakeEnvironment(fake1);
+ SplashPanel sa = SplashUtils.getSplashScreen(100, 100, SplashUtils.SplashReason.APPLET);
+ Assert.assertTrue(sa instanceof DefaultSplashScreen2012);
+ Assert.assertTrue(sa.getSplashReason() == SplashUtils.SplashReason.APPLET);
+ SplashPanel sw = SplashUtils.getSplashScreen(100, 100, SplashUtils.SplashReason.JAVAWS);
+ Assert.assertTrue(sw instanceof DefaultSplashScreen2012);
+ Assert.assertTrue(sw.getSplashReason() == SplashUtils.SplashReason.JAVAWS);
+ } finally {
+ fakeEnvironment(original);
+ }
+
+
+
+ }
+
+ @Test
+ public void testGetSplashScreen2() throws Exception {
+ Map fake1 = new HashMap();
+ fake1.put(SplashUtils.ICEDTEA_WEB_SPLASH, SplashUtils.DEFAULT);
+ fake1.put(SplashUtils.ICEDTEA_WEB_PLUGIN_SPLASH, SplashUtils.DEFAULT);
+ Map original = getEnvironment();
+ Assert.assertNotNull(original);
+ try {
+ fakeEnvironment(fake1);
+ SplashPanel sa = SplashUtils.getSplashScreen(100, 100, SplashUtils.SplashReason.APPLET);
+ Assert.assertTrue(sa instanceof DefaultSplashScreen2012);
+ Assert.assertTrue(sa.getSplashReason() == SplashUtils.SplashReason.APPLET);
+ SplashPanel sw = SplashUtils.getSplashScreen(100, 100, SplashUtils.SplashReason.JAVAWS);
+ Assert.assertTrue(sw instanceof DefaultSplashScreen2012);
+ Assert.assertTrue(sw.getSplashReason() == SplashUtils.SplashReason.JAVAWS);
+ } finally {
+ fakeEnvironment(original);
+ }
+
+
+ }
+
+ @Test
+ public void testGetSplashScreen3() throws Exception {
+ Map fake1 = new HashMap();
+ fake1.put(SplashUtils.ICEDTEA_WEB_SPLASH, SplashUtils.NONE);
+ fake1.put(SplashUtils.ICEDTEA_WEB_PLUGIN_SPLASH, SplashUtils.DEFAULT);
+ Map original = getEnvironment();
+ Assert.assertNotNull(original);
+ try {
+ fakeEnvironment(fake1);
+ SplashPanel sa = SplashUtils.getSplashScreen(100, 100, SplashUtils.SplashReason.APPLET);
+ Assert.assertTrue(sa instanceof DefaultSplashScreen2012);
+ Assert.assertTrue(sa.getSplashReason() == SplashUtils.SplashReason.APPLET);
+ SplashPanel sw = SplashUtils.getSplashScreen(100, 100, SplashUtils.SplashReason.JAVAWS);
+ Assert.assertTrue(sw == null);
+ } finally {
+ fakeEnvironment(original);
+ }
+
+
+
+ }
+
+ @Test
+ public void testGetSplashScreen4() throws Exception {
+ Map fake1 = new HashMap();
+ fake1.put(SplashUtils.ICEDTEA_WEB_SPLASH, SplashUtils.DEFAULT);
+ fake1.put(SplashUtils.ICEDTEA_WEB_PLUGIN_SPLASH, SplashUtils.NONE);
+ Map original = getEnvironment();
+ Assert.assertNotNull(original);
+ try {
+ fakeEnvironment(fake1);
+ SplashPanel sa = SplashUtils.getSplashScreen(100, 100, SplashUtils.SplashReason.APPLET);
+ Assert.assertTrue(sa == null);
+ SplashPanel sw = SplashUtils.getSplashScreen(100, 100, SplashUtils.SplashReason.JAVAWS);
+ Assert.assertTrue(sw instanceof DefaultSplashScreen2012);
+ Assert.assertTrue(sw.getSplashReason() == SplashUtils.SplashReason.JAVAWS);
+ } finally {
+ fakeEnvironment(original);
+ }
+
+
+
+ }
+
+ @Test
+ public void testGetSplashScreen5() throws Exception {
+ Map fake1 = new HashMap();
+ fake1.put(SplashUtils.ICEDTEA_WEB_SPLASH, SplashUtils.NONE);
+ fake1.put(SplashUtils.ICEDTEA_WEB_PLUGIN_SPLASH, SplashUtils.NONE);
+ Map original = getEnvironment();
+ Assert.assertNotNull(original);
+ try {
+ fakeEnvironment(fake1);
+ SplashPanel sa = SplashUtils.getSplashScreen(100, 100, SplashUtils.SplashReason.APPLET);
+ Assert.assertTrue(sa == null);
+ SplashPanel sw = SplashUtils.getSplashScreen(100, 100, SplashUtils.SplashReason.JAVAWS);
+ Assert.assertTrue(sw == null);
+ } finally {
+ fakeEnvironment(original);
+ }
+
+ }
+
+ @Test
+ public void testGetSplashScreen6() throws Exception {
+ Map fake1 = new HashMap();
+ fake1.put(SplashUtils.ICEDTEA_WEB_SPLASH, SplashUtils.DEFAULT);
+ fake1.put(SplashUtils.ICEDTEA_WEB_PLUGIN_SPLASH, "fgdthyfjtuk");
+ Map original = getEnvironment();
+ Assert.assertNotNull(original);
+ try {
+ fakeEnvironment(fake1);
+ SplashPanel sa = SplashUtils.getSplashScreen(100, 100, SplashUtils.SplashReason.APPLET);
+ Assert.assertTrue(sa instanceof DefaultSplashScreen2012);
+ Assert.assertTrue(sa.getSplashReason() == SplashUtils.SplashReason.APPLET);
+ SplashPanel sw = SplashUtils.getSplashScreen(100, 100, SplashUtils.SplashReason.JAVAWS);
+ Assert.assertTrue(sw instanceof DefaultSplashScreen2012);
+ Assert.assertTrue(sw.getSplashReason() == SplashUtils.SplashReason.JAVAWS);
+ } finally {
+ fakeEnvironment(original);
+ }
+
+
+ }
+
+ @Test
+ public void testGetSplashScreen7() throws Exception {
+ Map fake1 = new HashMap();
+ fake1.put(SplashUtils.ICEDTEA_WEB_SPLASH, "egtrutkyukl");
+ Map original = getEnvironment();
+ Assert.assertNotNull(original);
+ try {
+ fakeEnvironment(fake1);
+ SplashPanel sa = SplashUtils.getSplashScreen(100, 100, SplashUtils.SplashReason.APPLET);
+ Assert.assertTrue(sa instanceof DefaultSplashScreen2012);
+ Assert.assertTrue(sa.getSplashReason() == SplashUtils.SplashReason.APPLET);
+ SplashPanel sw = SplashUtils.getSplashScreen(100, 100, SplashUtils.SplashReason.JAVAWS);
+ Assert.assertTrue(sw instanceof DefaultSplashScreen2012);
+ Assert.assertTrue(sw.getSplashReason() == SplashUtils.SplashReason.JAVAWS);
+ } finally {
+ fakeEnvironment(original);
+ }
+
+
+ }
+
+ static void modifyRuntime(boolean b) {
+ try{
+ setStatic(JNLPRuntime.class.getDeclaredField("isWebstartApplication"), b);
+ }catch(Exception ex){
+ throw new RuntimeException(ex);
+ }
+ }
+ static void setStatic(Field field, Object newValue) throws Exception {
+ field.setAccessible(true);
+ field.set(null, newValue);
+ }
+
+}
diff --git a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainterTest.java b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainterTest.java
new file mode 100644
index 0000000..53d499a
--- /dev/null
+++ b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/BasePainterTest.java
@@ -0,0 +1,108 @@
+/* BasePainterTest.java
+Copyright (C) 2012 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; either version 2, or (at your option)
+any later version.
+
+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. */
+package net.sourceforge.jnlp.splashscreen.impls.defaultsplashscreen2012;
+
+import net.sourceforge.jnlp.splashscreen.impls.defaultsplashscreen2012.BasePainter;
+import java.awt.image.BufferedImage;
+import net.sourceforge.jnlp.splashscreen.SplashUtils.SplashReason;
+import net.sourceforge.jnlp.splashscreen.impls.DefaultSplashScreen2012;
+import org.junit.Assert;
+
+
+import org.junit.Test;
+
+public class BasePainterTest {
+
+ @Test
+ public void scaleTest() {
+ Assert.assertEquals(10, BasePainter.scale(2, 4, 5), 0.1d);
+ Assert.assertEquals(4, BasePainter.scale(4, 2, 8), 0.1d);
+ }
+
+ @Test
+ public void getRatioTest() {
+ Assert.assertEquals(2, BasePainter.getRatio(2, 4), 0.1d);
+ Assert.assertEquals(0.5, BasePainter.getRatio(4, 2), 0.1d);
+ }
+
+ @Test
+ public void incLevel2Test() {
+ BasePainter bp = new BasePainter(new DefaultSplashScreen2012(100, 100, SplashReason.APPLET));
+ int l1 = bp.getWaterLevel();
+ int l2 = bp.getAnimationsPosition();
+ bp.increaseAnimationPosition();
+ Assert.assertFalse(l2 == bp.getAnimationsPosition());
+ Assert.assertTrue(l1 == bp.getWaterLevel());
+ }
+
+ @Test
+ public void adjustForSizeTest() {
+ BasePainter bp = new BasePainter(new DefaultSplashScreen2012(100, 100, SplashReason.APPLET));
+ bp.adjustForSize(100, 100);
+ Assert.assertNotNull(bp.prerenderedStuff);
+ BufferedImage i1 = bp.prerenderStill();
+ Assert.assertEquals(100, i1.getWidth());
+ Assert.assertEquals(100, i1.getHeight());
+ bp.adjustForSize(20, 20);
+ Assert.assertNotNull(bp.prerenderedStuff);
+ Assert.assertEquals(20, bp.prerenderedStuff.getWidth());
+ Assert.assertEquals(20, bp.prerenderedStuff.getHeight());
+ Assert.assertFalse(i1.getWidth() == bp.prerenderedStuff.getWidth());
+ Assert.assertFalse(i1.getHeight() == bp.prerenderedStuff.getHeight());
+
+
+ }
+
+ @Test
+ public void adjustForSizeTest2() {
+ BasePainter bp = new BasePainter(new DefaultSplashScreen2012(0, 0, SplashReason.APPLET), false);
+ Assert.assertNull(bp.prerenderedStuff);
+ bp.master.setSplashHeight(10);
+ bp.master.setSplashWidth(10);
+ BufferedImage i1 = bp.prerenderStill();
+ Assert.assertEquals(10, i1.getWidth());
+ Assert.assertEquals(10, i1.getHeight());
+ bp.adjustForSize(20, 20);
+ Assert.assertNotNull(bp.prerenderedStuff);
+ Assert.assertEquals(20, bp.prerenderedStuff.getWidth());
+ Assert.assertEquals(20, bp.prerenderedStuff.getHeight());
+ Assert.assertFalse(i1.getWidth() == bp.prerenderedStuff.getWidth());
+ Assert.assertFalse(i1.getHeight() == bp.prerenderedStuff.getHeight());
+
+
+ }
+}
diff --git a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/ControlCurveTest.java b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/ControlCurveTest.java
new file mode 100644
index 0000000..4d673d4
--- /dev/null
+++ b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/ControlCurveTest.java
@@ -0,0 +1,307 @@
+/* ControlCurveTest.java
+Copyright (C) 2012 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; either version 2, or (at your option)
+any later version.
+
+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. */
+package net.sourceforge.jnlp.splashscreen.impls.defaultsplashscreen2012;
+
+/** This class represents a curve defined by a sequence of control points */
+/* Part of NatCubic implementation, inspire by http://www.cse.unsw.edu.au/~lambert/*/
+import net.sourceforge.jnlp.splashscreen.impls.defaultsplashscreen2012.ControlCurve;
+import java.awt.*;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ControlCurveTest {
+
+ @Test
+ public void setGetTests() {
+ Polygon p1 = new Polygon();
+ Polygon p2 = new Polygon();
+ Polygon p3 = new Polygon();
+ ControlCurve cc = new ControlCurve();
+ Assert.assertNotNull(cc.getSourcePolygon());
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNull(cc.getResult());
+ Assert.assertTrue(cc.isWithPoints());
+ cc.setSourcePolygon(p1);
+ Assert.assertNotNull(cc.getSourcePolygon());
+ Assert.assertEquals(p1, cc.getSourcePolygon());
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNull(cc.getResult());
+ Assert.assertTrue(cc.isWithPoints());
+ cc.setWithPoints(false);
+ Assert.assertFalse(cc.isWithPoints());
+
+ cc = new ControlCurve(p2);
+ Assert.assertNotNull(cc.getSourcePolygon());
+ Assert.assertEquals(p2, cc.getSourcePolygon());
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNull(cc.getResult());
+ cc.setWithPoints(false);
+ Assert.assertFalse(cc.isWithPoints());
+ cc.setSourcePolygon(p3);
+ Assert.assertNotNull(cc.getSourcePolygon());
+ Assert.assertEquals(p3, cc.getSourcePolygon());
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNull(cc.getResult());
+ cc.setWithPoints(false);
+ Assert.assertFalse(cc.isWithPoints());
+ cc.setWithPoints(true);
+ Assert.assertTrue(cc.isWithPoints());
+
+ }
+
+ @Test
+ public void sqrTest() {
+ Assert.assertEquals(25, ControlCurve.sqr(5));
+ }
+ static int[] xs = {0, 100, 100, 0};
+ static int[] ys = {0, 0, 100, 1000};
+
+ static ControlCurve getTestInstance() {
+ ControlCurve cc = new ControlCurve();
+ cc.addPoint(xs[0], ys[0]);
+ cc.addPoint(xs[1], ys[1]);
+ cc.addPoint(xs[2], ys[2]);
+ cc.addPoint(xs[3], ys[3]);
+ return cc;
+
+ }
+
+ @Test
+ public void selectPointTest() {
+ ControlCurve cc = getTestInstance();
+ int i = cc.selectPoint(-50, -50);
+ Assert.assertEquals(-1, i);
+ i = cc.selectPoint(-3, 3);
+ Assert.assertEquals(0, i);
+ i = cc.selectPoint(97, 97);
+ Assert.assertEquals(2, i);
+ i = cc.selectPoint(100, 50);
+ Assert.assertEquals(-1, i);
+ }
+
+ @Test
+ public void addPoint() {
+ ControlCurve cc = new ControlCurve();
+ Assert.assertEquals(0, cc.getSourcePolygon().npoints);
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNull(cc.getResult());
+ cc.addPoint(10, 10);
+ Assert.assertEquals(1, cc.getSourcePolygon().npoints);
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNull(cc.getResult());
+ cc.addPoint(10, 10);
+ Assert.assertEquals(2, cc.getSourcePolygon().npoints);
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNull(cc.getResult());
+ cc.addPoint(100, 100);
+ Assert.assertEquals(3, cc.getSourcePolygon().npoints);
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNull(cc.getResult());
+ }
+
+ @Test
+ public void setPointTest1() {
+ ControlCurve cc = getTestInstance();
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNull(cc.getResult());
+ cc.setSelection(-1);
+ cc.setPoint(10, 10);
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.setSelection(4);
+ cc.setPoint(10, 10);
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.setSelection(3);
+ cc.setPoint(10, 20);
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 3; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNull(cc.getResult());
+ Assert.assertEquals(20, cc.getSourcePolygon().ypoints[3]);
+ Assert.assertEquals(10, cc.getSourcePolygon().xpoints[3]);
+ }
+
+ @Test
+ public void setPointTest2() {
+ ControlCurve cc = getTestInstance();
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNull(cc.getResult());
+ cc.setPoint(-1, 10, 10);
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.setPoint(4, 10, 10);
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.setPoint(3, 10, 20);
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 3; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNull(cc.getResult());
+ Assert.assertEquals(20, cc.getSourcePolygon().ypoints[3]);
+ Assert.assertEquals(10, cc.getSourcePolygon().xpoints[3]);
+
+ }
+
+ @Test
+ public void removePoint2() {
+ ControlCurve cc = getTestInstance();
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNull(cc.getResult());
+ cc.removePoint(-1);
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNull(cc.getResult());
+ cc.removePoint(4);
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNull(cc.getResult());
+ cc.removePoint(3);
+ Assert.assertEquals(3, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 3; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNull(cc.getResult());
+
+ }
+
+ public void removePoint1() {
+ ControlCurve cc = getTestInstance();
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNull(cc.getResult());
+ cc.setSelection(-1);
+ cc.removePoint();
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNull(cc.getResult());
+ cc.setSelection(4);
+ cc.removePoint();
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNull(cc.getResult());
+ cc.setSelection(0);
+ cc.removePoint();
+ Assert.assertEquals(3, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 3; i++) {
+ Assert.assertEquals(ys[i + 1], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i + 1], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNull(cc.getResult());
+
+ }
+}
diff --git a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/CubicTest.java b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/CubicTest.java
new file mode 100644
index 0000000..5d4916f
--- /dev/null
+++ b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/CubicTest.java
@@ -0,0 +1,57 @@
+/* CubicTest.java
+Copyright (C) 2012 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; either version 2, or (at your option)
+any later version.
+
+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. */
+package net.sourceforge.jnlp.splashscreen.impls.defaultsplashscreen2012;
+
+import net.sourceforge.jnlp.splashscreen.impls.defaultsplashscreen2012.Cubic;
+import org.junit.Assert;
+import org.junit.Test;
+
+/** this class represents a cubic polynomial */
+/* Part of NatCubic implementation, inspire by http://www.cse.unsw.edu.au/~lambert/*/
+public class CubicTest {
+
+ @Test
+ public void cubicTest() {
+ Cubic c1 = new Cubic(1, 2, 3, 4);
+ Assert.assertTrue(new Float(1).equals(c1.a));
+ Assert.assertTrue(new Float(2).equals(c1.b));
+ Assert.assertTrue(new Float(3).equals(c1.c));
+ Assert.assertTrue(new Float(4).equals(c1.d));
+ Assert.assertTrue(new Float(586).equals(c1.eval(5)));
+
+ }
+}
diff --git a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/ErrorPainterTest.java b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/ErrorPainterTest.java
new file mode 100644
index 0000000..a96b2d4
--- /dev/null
+++ b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/ErrorPainterTest.java
@@ -0,0 +1,113 @@
+/* ErrorPainterTest.java
+Copyright (C) 2012 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; either version 2, or (at your option)
+any later version.
+
+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. */
+package net.sourceforge.jnlp.splashscreen.impls.defaultsplashscreen2012;
+
+import net.sourceforge.jnlp.splashscreen.impls.defaultsplashscreen2012.ErrorPainter;
+import java.awt.Color;
+import java.awt.image.BufferedImage;
+import net.sourceforge.jnlp.splashscreen.SplashUtils.SplashReason;
+import net.sourceforge.jnlp.splashscreen.impls.DefaultSplashScreen2012;
+import org.junit.Assert;
+import org.junit.Test;
+
+public final class ErrorPainterTest {
+
+ @Test
+ public void interpolTest() {
+ Assert.assertEquals(15, ErrorPainter.interpol(4, 2, 10, 20), 0.1d);
+ Assert.assertEquals(-15, ErrorPainter.interpol(4, 2, -20, -10), 0.1d);
+ Assert.assertEquals(30, ErrorPainter.interpol(2, 4, 10, 20), 0.1d);
+ }
+
+ @Test
+ public void interpolColorTest() {
+ Color c1 = new Color(0, 0, 0);
+ Color c2 = new Color(200, 200, 200);
+ Color c3 = new Color(100, 100, 100);
+ Color c4 = ErrorPainter.interpolateColor(4, 2, c1, c2);
+ Assert.assertEquals(c3, c4);
+
+ }
+
+// public static void main(String[] a) {
+// Color c1 = new Color(250, 50, 0, 50);
+// Color c2 = new Color(0, 0, 250, 100);
+// for (int i = 0; i < 21; i++) {
+// Color q = ErrorPainter.interpolateColor(20, i, c1, c2);
+// System.out.println(q.toString());
+// System.out.println(q.getAlpha());
+// }
+// }
+ @Test
+ public void adjustForSizeTest() {
+ ErrorPainter bp = new ErrorPainter(new DefaultSplashScreen2012(100, 100, SplashReason.APPLET));
+ bp.master.setSplashHeight(100);
+ bp.master.setSplashWidth(100);
+ bp.adjustForSize(100, 100);
+ Assert.assertNotNull(bp.prerenderedStuff);
+ BufferedImage i1 = bp.prerenderStill();
+ Assert.assertEquals(100, i1.getWidth());
+ Assert.assertEquals(100, i1.getHeight());
+ bp.adjustForSize(20, 20);
+ Assert.assertNotNull(bp.prerenderedStuff);
+ Assert.assertEquals(20, bp.prerenderedStuff.getWidth());
+ Assert.assertEquals(20, bp.prerenderedStuff.getHeight());
+ Assert.assertFalse(i1.getWidth() == bp.prerenderedStuff.getWidth());
+ Assert.assertFalse(i1.getHeight() == bp.prerenderedStuff.getHeight());
+
+
+ }
+
+ @Test
+ public void adjustForSizeTest2() {
+ ErrorPainter bp = new ErrorPainter(new DefaultSplashScreen2012(0, 0, SplashReason.APPLET), false);
+ Assert.assertNull(bp.prerenderedStuff);
+ bp.master.setSplashHeight(10);
+ bp.master.setSplashWidth(10);
+ BufferedImage i1 = bp.prerenderStill();
+ Assert.assertEquals(10, i1.getWidth());
+ Assert.assertEquals(10, i1.getHeight());
+ bp.adjustForSize(20, 20);
+ Assert.assertNotNull(bp.prerenderedStuff);
+ Assert.assertEquals(20, bp.prerenderedStuff.getWidth());
+ Assert.assertEquals(20, bp.prerenderedStuff.getHeight());
+ Assert.assertFalse(i1.getWidth() == bp.prerenderedStuff.getWidth());
+ Assert.assertFalse(i1.getHeight() == bp.prerenderedStuff.getHeight());
+
+
+ }
+}
diff --git a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/MovingTextTest.java b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/MovingTextTest.java
new file mode 100644
index 0000000..636bbed
--- /dev/null
+++ b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/MovingTextTest.java
@@ -0,0 +1,151 @@
+/* MovingTextTest.java
+Copyright (C) 2012 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; either version 2, or (at your option)
+any later version.
+
+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. */
+package net.sourceforge.jnlp.splashscreen.impls.defaultsplashscreen2012;
+
+import net.sourceforge.jnlp.splashscreen.impls.defaultsplashscreen2012.MovingText;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class MovingTextTest {
+
+ @Test
+ public void setGetTest() {
+ BufferedImage bi = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g2d = bi.createGraphics();
+ Font f1 = g2d.getFont().deriveFont(Font.ITALIC);
+ Font f2 = g2d.getFont().deriveFont(Font.BOLD);
+ String s = "Watter";
+ MovingText tw = new MovingText(s, f1);
+ Assert.assertEquals(-1, tw.getHeight());
+ Assert.assertEquals(-1, tw.getWidth());
+ Assert.assertEquals(f1, tw.getFont());
+ Assert.assertNull(tw.getImg());
+ Assert.assertEquals(s, tw.getText());
+ Assert.assertEquals(Color.BLACK, tw.getTextOutline());
+ Assert.assertEquals(Color.blue, tw.getWaterColor());
+ Assert.assertEquals(Color.white, tw.getBgColor());
+ Assert.assertEquals(0, tw.getPercentageOfWater());
+ tw.setBgColor(Color.yellow);
+ tw.setWaterColor(Color.orange);
+ tw.setPercentageOfWater(20);
+ Assert.assertEquals(Color.orange, tw.getWaterColor());
+ Assert.assertEquals(Color.yellow, tw.getBgColor());
+ Assert.assertEquals(20, tw.getPercentageOfWater());
+
+ }
+
+ private static int getAvgColor(Color c) {
+ Assert.assertEquals(c.getRed(), c.getBlue());
+ Assert.assertEquals(c.getRed(), c.getGreen());
+ return c.getRed();
+ }
+
+ private static int getAvgColor(int i) {
+ return getAvgColor(new Color(i));
+ }
+
+ private static int getAvgColor(BufferedImage m, int x, int y) {
+ return getAvgColor(m.getRGB(x, y));
+ }
+
+ @Test
+ public void getBackground() {
+ MovingText ifc = getInstance();
+ BufferedImage bic = ifc.getBackground();
+ int w = bic.getWidth();
+ int h = bic.getHeight();
+ ifc.setPercentageOfWater(0);
+ bic = ifc.getBackground();
+ Assert.assertTrue(getAvgColor(bic, 3 * w / 4, h / 2) > getAvgColor(bic, 2 * w / 4, h / 2));
+ Assert.assertTrue(getAvgColor(bic, w / 4, h / 2) < getAvgColor(bic, 2 * w / 4, h / 2));
+ Assert.assertEquals(new Color(bic.getRGB(w - w / 4, 2 * h / 3)), new Color(bic.getRGB(w - w / 4, h / 3)));
+ ifc.setPercentageOfWater(w / 2);
+ bic = ifc.getBackground();
+ Assert.assertTrue(getAvgColor(bic, 3 * w / 4, h / 2) > getAvgColor(bic, 2 * w / 4, h / 2));
+ Assert.assertTrue(getAvgColor(bic, w / 4, h / 2) > getAvgColor(bic, 2 * w / 4, h / 2));
+ Assert.assertEquals(new Color(bic.getRGB(w - w / 3, 2 * h / 3)), new Color(bic.getRGB(w - w / 3, h / 3)));
+ ifc.setPercentageOfWater(w);
+ bic = ifc.getBackground();
+ Assert.assertTrue(getAvgColor(bic, 3 * w / 4, h / 2) < getAvgColor(bic, 2 * w / 4, h / 2));
+ Assert.assertTrue(getAvgColor(bic, w / 4, h / 2) > getAvgColor(bic, 2 * w / 4, h / 2));
+ Assert.assertEquals(new Color(bic.getRGB(w - w / 4, h / 3)), new Color(bic.getRGB(w - w / 4, h / 2)));
+
+
+
+ }
+
+ private MovingText getInstance() {
+ BufferedImage bi1 = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
+ Font f = bi1.createGraphics().getFont().deriveFont(Font.BOLD, 130);
+ MovingText ifc = new MovingText("O O", f);
+ return ifc;
+ }
+
+ private static void assertNotEquals(Object o1, Object o2) {
+ Assert.assertFalse(o1.equals(o2));
+
+ }
+
+ @Test
+ public void cutToTest() {
+ MovingText ifc = getInstance();
+ BufferedImage bic = ifc.getBackground();
+ int w = bic.getWidth();
+ int h = bic.getHeight();
+ bic = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
+ ifc.cutTo(bic.createGraphics(), 0, h);
+ Color cc = new Color(0, 0, 0);
+ assertNotEquals(cc, new Color(bic.getRGB(52, 142)));
+ assertNotEquals(cc, new Color(bic.getRGB(170, 110)));
+ assertNotEquals(cc, new Color(bic.getRGB(52, 62)));
+ assertNotEquals(cc, new Color(bic.getRGB(245, 85)));
+
+ //well this should be acctually rgba 0,0,0,0 but somehow this was no passig
+ //you can confirm with:
+ //ImageFontCutterTest.save(bic, "halfFiledOus")
+ Assert.assertEquals(cc, new Color(bic.getRGB(137, 127)));
+ Assert.assertEquals(cc, new Color(bic.getRGB(137, 2)));
+
+
+
+
+ }
+}
diff --git a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/NatCubicClosedTest.java b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/NatCubicClosedTest.java
new file mode 100644
index 0000000..0c5520c
--- /dev/null
+++ b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/NatCubicClosedTest.java
@@ -0,0 +1,264 @@
+/* NatCubicClosedTest.java
+Copyright (C) 2012 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; either version 2, or (at your option)
+any later version.
+
+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. */
+package net.sourceforge.jnlp.splashscreen.impls.defaultsplashscreen2012;
+
+import net.sourceforge.jnlp.splashscreen.impls.defaultsplashscreen2012.NatCubicClosed;
+import java.awt.Polygon;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class NatCubicClosedTest {
+
+ @Test
+ public void setGetTests() {
+ Polygon p1 = new Polygon();
+ p1.addPoint(10, 23);
+ p1.addPoint(12, -31);
+ NatCubicClosed cc = new NatCubicClosed();
+ Assert.assertNotNull(cc.getSourcePolygon());
+ Assert.assertNull(cc.getResult());
+ Exception ex = null;
+ try {
+ cc.calcualteAndSaveResult();
+ } catch (Exception eex) {
+ ex = eex;
+ }
+ Assert.assertNotNull(ex);
+ Assert.assertNull(cc.getResult());
+ Assert.assertTrue(cc.isWithPoints());
+ cc.setSourcePolygon(p1);
+ Assert.assertNotNull(cc.getSourcePolygon());
+ Assert.assertEquals(p1, cc.getSourcePolygon());
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+ Assert.assertTrue(cc.isWithPoints());
+ cc.setWithPoints(false);
+ Assert.assertFalse(cc.isWithPoints());
+ cc.resetResult();
+ Assert.assertNull(cc.getResult());
+
+
+
+ }
+ static int[] xs = {0, 100, 100, 0};
+ static int[] ys = {0, 0, 100, 1000};
+
+ static NatCubicClosed getTestInstance() {
+ NatCubicClosed cc = new NatCubicClosed();
+ cc.addPoint(xs[0], ys[0]);
+ cc.addPoint(xs[1], ys[1]);
+ cc.addPoint(xs[2], ys[2]);
+ cc.addPoint(xs[3], ys[3]);
+ return cc;
+
+ }
+
+ @Test
+ public void basicComputation() {
+ NatCubicClosed b = new NatCubicClosed();
+ b.addPoint(10, 10);
+ b.addPoint(50, 20);
+ b.addPoint(-10, -10);
+ b.calcualteAndSaveResult();
+ Assert.assertTrue(b.pts.npoints < b.result.npoints / 5);
+ Assert.assertEquals(b.result.xpoints[0], b.result.xpoints[b.result.npoints - 1]);
+ Assert.assertEquals(b.result.ypoints[0], b.result.ypoints[b.result.npoints - 1]);
+
+ }
+
+ @Test
+ public void addPoint() {
+ NatCubicClosed cc = new NatCubicClosed();
+ Assert.assertEquals(0, cc.getSourcePolygon().npoints);
+ Assert.assertNull(cc.getResult());
+ Exception ex = null;
+ try {
+ cc.calcualteAndSaveResult();
+ } catch (Exception eex) {
+ ex = eex;
+ }
+ Assert.assertNotNull(ex);
+ Assert.assertNull(cc.getResult());
+ cc.addPoint(10, 10);
+ Assert.assertEquals(1, cc.getSourcePolygon().npoints);
+ Assert.assertNull(cc.getResult());
+ ex = null;
+ try {
+ cc.calcualteAndSaveResult();
+ } catch (Exception eex) {
+ ex = eex;
+ }
+ Assert.assertNotNull(ex);
+ Assert.assertNull(cc.getResult());
+ cc.addPoint(10, 10);
+ Assert.assertEquals(2, cc.getSourcePolygon().npoints);
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+ cc.addPoint(100, 100);
+ Assert.assertEquals(3, cc.getSourcePolygon().npoints);
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+ }
+
+ @Test
+ public void setPointTest1() {
+ NatCubicClosed cc = getTestInstance();
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+ cc.setSelection(-1);
+ cc.setPoint(10, 10);
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNotNull(cc.getResult());
+ cc.setSelection(4);
+ cc.setPoint(10, 10);
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNotNull(cc.getResult());
+ cc.setSelection(3);
+ cc.setPoint(10, 20);
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 3; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+ Assert.assertEquals(20, cc.getSourcePolygon().ypoints[3]);
+ Assert.assertEquals(10, cc.getSourcePolygon().xpoints[3]);
+ }
+
+ @Test
+ public void removePoint2() {
+ NatCubicClosed cc = getTestInstance();
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+ cc.removePoint(-1);
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNotNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+ cc.removePoint(4);
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNotNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+ cc.removePoint(3);
+ Assert.assertEquals(3, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 3; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+
+ }
+
+ public void removePoint1() {
+ NatCubicClosed cc = getTestInstance();
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+ cc.setSelection(-1);
+ cc.removePoint();
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNotNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+ cc.setSelection(4);
+ cc.removePoint();
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNotNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+ cc.setSelection(0);
+ cc.removePoint();
+ Assert.assertEquals(3, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 3; i++) {
+ Assert.assertEquals(ys[i + 1], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i + 1], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+
+ }
+}
diff --git a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/NatCubicTest.java b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/NatCubicTest.java
new file mode 100644
index 0000000..52b9eaf
--- /dev/null
+++ b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/NatCubicTest.java
@@ -0,0 +1,264 @@
+/* NatCubicTest.java
+Copyright (C) 2012 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; either version 2, or (at your option)
+any later version.
+
+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. */
+package net.sourceforge.jnlp.splashscreen.impls.defaultsplashscreen2012;
+
+import net.sourceforge.jnlp.splashscreen.impls.defaultsplashscreen2012.NatCubic;
+import java.awt.Polygon;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class NatCubicTest {
+
+ @Test
+ public void setGetTests() {
+ Polygon p1 = new Polygon();
+ p1.addPoint(10, 23);
+ p1.addPoint(12, -31);
+ NatCubic cc = new NatCubic();
+ Assert.assertNotNull(cc.getSourcePolygon());
+ Assert.assertNull(cc.getResult());
+ Exception ex = null;
+ try {
+ cc.calcualteAndSaveResult();
+ } catch (Exception eex) {
+ ex = eex;
+ }
+ Assert.assertNotNull(ex);
+ Assert.assertNull(cc.getResult());
+ Assert.assertTrue(cc.isWithPoints());
+ cc.setSourcePolygon(p1);
+ Assert.assertNotNull(cc.getSourcePolygon());
+ Assert.assertEquals(p1, cc.getSourcePolygon());
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+ Assert.assertTrue(cc.isWithPoints());
+ cc.setWithPoints(false);
+ Assert.assertFalse(cc.isWithPoints());
+ cc.resetResult();
+ Assert.assertNull(cc.getResult());
+
+
+
+ }
+ static int[] xs = {0, 100, 100, 0};
+ static int[] ys = {0, 0, 100, 1000};
+
+ static NatCubic getTestInstance() {
+ NatCubic cc = new NatCubic();
+ cc.addPoint(xs[0], ys[0]);
+ cc.addPoint(xs[1], ys[1]);
+ cc.addPoint(xs[2], ys[2]);
+ cc.addPoint(xs[3], ys[3]);
+ return cc;
+
+ }
+
+ @Test
+ public void basicComputation() {
+ NatCubic b = new NatCubic();
+ b.addPoint(10, 10);
+ b.addPoint(50, 20);
+ b.addPoint(-10, -10);
+ b.calcualteAndSaveResult();
+ Assert.assertTrue(b.pts.npoints < b.result.npoints / 5);
+ Assert.assertFalse(b.result.xpoints[0] == b.result.xpoints[b.result.npoints - 1]);
+ Assert.assertFalse(b.result.ypoints[0] == b.result.ypoints[b.result.npoints - 1]);
+
+ }
+
+ @Test
+ public void addPoint() {
+ NatCubic cc = new NatCubic();
+ Assert.assertEquals(0, cc.getSourcePolygon().npoints);
+ Assert.assertNull(cc.getResult());
+ Exception ex = null;
+ try {
+ cc.calcualteAndSaveResult();
+ } catch (Exception eex) {
+ ex = eex;
+ }
+ Assert.assertNotNull(ex);
+ Assert.assertNull(cc.getResult());
+ cc.addPoint(10, 10);
+ Assert.assertEquals(1, cc.getSourcePolygon().npoints);
+ Assert.assertNull(cc.getResult());
+ ex = null;
+ try {
+ cc.calcualteAndSaveResult();
+ } catch (Exception eex) {
+ ex = eex;
+ }
+ Assert.assertNotNull(ex);
+ Assert.assertNull(cc.getResult());
+ cc.addPoint(10, 10);
+ Assert.assertEquals(2, cc.getSourcePolygon().npoints);
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+ cc.addPoint(100, 100);
+ Assert.assertEquals(3, cc.getSourcePolygon().npoints);
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+ }
+
+ @Test
+ public void setPointTest1() {
+ NatCubic cc = getTestInstance();
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+ cc.setSelection(-1);
+ cc.setPoint(10, 10);
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNotNull(cc.getResult());
+ cc.setSelection(4);
+ cc.setPoint(10, 10);
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNotNull(cc.getResult());
+ cc.setSelection(3);
+ cc.setPoint(10, 20);
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 3; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+ Assert.assertEquals(20, cc.getSourcePolygon().ypoints[3]);
+ Assert.assertEquals(10, cc.getSourcePolygon().xpoints[3]);
+ }
+
+ @Test
+ public void removePoint2() {
+ NatCubic cc = getTestInstance();
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+ cc.removePoint(-1);
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNotNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+ cc.removePoint(4);
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNotNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+ cc.removePoint(3);
+ Assert.assertEquals(3, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 3; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+
+ }
+
+ public void removePoint1() {
+ NatCubic cc = getTestInstance();
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+ cc.setSelection(-1);
+ cc.removePoint();
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNotNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+ cc.setSelection(4);
+ cc.removePoint();
+ Assert.assertEquals(4, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 4; i++) {
+ Assert.assertEquals(ys[i], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNotNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+ cc.setSelection(0);
+ cc.removePoint();
+ Assert.assertEquals(3, cc.getSourcePolygon().npoints);
+ for (int i = 0; i < 3; i++) {
+ Assert.assertEquals(ys[i + 1], cc.getSourcePolygon().ypoints[i]);
+ Assert.assertEquals(xs[i + 1], cc.getSourcePolygon().xpoints[i]);
+ }
+ Assert.assertNull(cc.getResult());
+ cc.calcualteAndSaveResult();
+ Assert.assertNotNull(cc.getResult());
+
+ }
+}
diff --git a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/SplinesDefsTest.java b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/SplinesDefsTest.java
new file mode 100644
index 0000000..3537a70
--- /dev/null
+++ b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/SplinesDefsTest.java
@@ -0,0 +1,91 @@
+/* SplinesDefsTest.java
+Copyright (C) 2012 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; either version 2, or (at your option)
+any later version.
+
+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. */
+package net.sourceforge.jnlp.splashscreen.impls.defaultsplashscreen2012;
+
+import net.sourceforge.jnlp.splashscreen.impls.defaultsplashscreen2012.SplinesDefs;
+import java.awt.Point;
+import java.awt.Polygon;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class SplinesDefsTest {
+
+ private static Point[] testArray = {
+ new Point(0, 0),
+ new Point(100, 0),
+ new Point(100, 100),
+ new Point(0, 100)
+ };
+
+ @Test
+ public void polygonizeControlPointsTest() {
+
+ Polygon p = SplinesDefs.polygonizeControlPoints(testArray, 1d, 1d);
+ Assert.assertTrue(p.contains(50, 50));
+ Assert.assertFalse(p.contains(150, 150));
+ Assert.assertFalse(p.contains(-50, -50));
+ p = SplinesDefs.polygonizeControlPoints(testArray, 0.5d, 0.5d);
+ Assert.assertTrue(p.contains(20, 20));
+ Assert.assertFalse(p.contains(75, 75));
+ Assert.assertFalse(p.contains(-25, -25));
+ p = SplinesDefs.polygonizeControlPoints(testArray, 2d, 2d);
+ Assert.assertTrue(p.contains(150, 150));
+ Assert.assertFalse(p.contains(250, 250));
+ Assert.assertFalse(p.contains(-50, -50));
+
+
+ }
+
+ @Test
+ public void testApi() {
+ double x = 1d;
+ Polygon[] p = {SplinesDefs.getMainLeaf(x, x),
+ SplinesDefs.getMainLeafCurve(x, x),
+ SplinesDefs.getMainLeafStalk(x, x),
+ SplinesDefs.getMainLeafStalkCurve(x, x),
+ SplinesDefs.getSecondLeaf(x, x),
+ SplinesDefs.getSecondLeafCurve(x, x),
+ SplinesDefs.getSecondLeafStalk(x, x),
+ SplinesDefs.getSecondLeafStalkCurve(x, x)};
+ for (Polygon polygon : p) {
+ Assert.assertNotNull(polygon);
+ Assert.assertTrue(polygon.npoints > 5);
+
+ }
+
+ }
+}
diff --git a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/TextOutlineRendererTest.java b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/TextOutlineRendererTest.java
new file mode 100644
index 0000000..c774835
--- /dev/null
+++ b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/TextOutlineRendererTest.java
@@ -0,0 +1,127 @@
+/* TextOutlineRendererTest.java
+Copyright (C) 2012 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; either version 2, or (at your option)
+any later version.
+
+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. */
+package net.sourceforge.jnlp.splashscreen.impls.defaultsplashscreen2012;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import javax.imageio.ImageIO;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TextOutlineRendererTest {
+
+ @Test
+ public void getSetTest() {
+ BufferedImage bi = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g2d = bi.createGraphics();
+ Font f1 = g2d.getFont().deriveFont(Font.ITALIC);
+ Font f2 = g2d.getFont().deriveFont(Font.BOLD);
+ String s = "Hello";
+ TextOutlineRenderer ifc = new TextOutlineRenderer(f1, s);
+ Assert.assertEquals(-1, ifc.getHeight());
+ Assert.assertEquals(-1, ifc.getWidth());
+ Assert.assertEquals(f1, ifc.getFont());
+ Assert.assertNull(ifc.getImg());
+ Assert.assertEquals(s, ifc.getText());
+ Assert.assertEquals(Color.BLACK, ifc.getTextOutline());
+ ifc.setImg(bi);
+ Assert.assertEquals(100, ifc.getHeight());
+ Assert.assertEquals(100, ifc.getWidth());
+ Assert.assertEquals(f1, ifc.getFont());
+ Assert.assertEquals(bi, ifc.getImg());
+ Assert.assertEquals(s, ifc.getText());
+ Assert.assertEquals(Color.BLACK, ifc.getTextOutline());
+
+ TextOutlineRenderer xfc = new TextOutlineRenderer(f1, s, Color.red);
+ xfc.setImg(bi);
+ xfc.setFont(f2);
+ String ss = "HelloHello";
+ Assert.assertEquals(100, xfc.getHeight());
+ Assert.assertEquals(100, xfc.getWidth());
+ Assert.assertEquals(f2, xfc.getFont());
+ Assert.assertEquals(bi, xfc.getImg());
+ Assert.assertEquals(s, xfc.getText());
+ Assert.assertEquals(Color.red, xfc.getTextOutline());
+ xfc.setTextOutline(Color.white);
+ Assert.assertEquals(Color.white, xfc.getTextOutline());
+
+ }
+
+ @Test
+ public void cutToTest() {
+ BufferedImage bi1 = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g2d1 = bi1.createGraphics();
+ g2d1.setColor(Color.red);
+ g2d1.fillRect(0, 0, 100, 100);
+
+
+ BufferedImage bi2 = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g2d2 = bi2.createGraphics();
+ g2d2.setColor(Color.blue);
+ g2d2.fillRect(0, 0, 100, 100);
+ TextOutlineRenderer ifc = new TextOutlineRenderer(g2d1.getFont().deriveFont(Font.BOLD, 130), "O");
+ ifc.setImg(bi1);
+ ifc.cutTo(g2d2, -5, 100);
+ Color c1 = new Color(bi2.getRGB(1, 1));
+ Assert.assertEquals(Color.blue, c1);
+ Color c2 = new Color(bi2.getRGB(50, 50));
+ Assert.assertEquals(Color.blue, c2);
+ Color c3 = new Color(bi2.getRGB(30, 30));
+ Assert.assertEquals(Color.red, c3);
+ Color c4 = new Color(bi2.getRGB(70, 70));
+ Assert.assertEquals(Color.red, c4);
+ Color c5 = new Color(bi2.getRGB(26, 52));
+ Assert.assertEquals(Color.black, c5);
+
+
+ }
+
+ public static void save(BufferedImage bi1, String string) {
+ try {
+ String name = string;
+ if (name == null || name.trim().length() <= 0) {
+ name = "testImage";
+ }
+ ImageIO.write(bi1, "png", new File(System.getProperty("user.home") + "/Desktop/" + name + ".png"));
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+}
diff --git a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/TextWithWaterLevelTest.java b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/TextWithWaterLevelTest.java
new file mode 100644
index 0000000..8705273
--- /dev/null
+++ b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/impls/defaultsplashscreen2012/TextWithWaterLevelTest.java
@@ -0,0 +1,131 @@
+/* TextWithWaterLevelTest.java
+Copyright (C) 2012 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; either version 2, or (at your option)
+any later version.
+
+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. */
+package net.sourceforge.jnlp.splashscreen.impls.defaultsplashscreen2012;
+
+import net.sourceforge.jnlp.splashscreen.impls.defaultsplashscreen2012.TextWithWaterLevel;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TextWithWaterLevelTest {
+
+ @Test
+ public void setGetTest() {
+ BufferedImage bi = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g2d = bi.createGraphics();
+ Font f1 = g2d.getFont().deriveFont(Font.ITALIC);
+ Font f2 = g2d.getFont().deriveFont(Font.BOLD);
+ String s = "Watter";
+ TextWithWaterLevel tw = new TextWithWaterLevel(s, f1);
+ Assert.assertEquals(-1, tw.getHeight());
+ Assert.assertEquals(-1, tw.getWidth());
+ Assert.assertEquals(f1, tw.getFont());
+ Assert.assertNull(tw.getImg());
+ Assert.assertEquals(s, tw.getText());
+ Assert.assertEquals(Color.BLACK, tw.getTextOutline());
+ Assert.assertEquals(Color.blue, tw.getWaterColor());
+ Assert.assertEquals(Color.white, tw.getBgColor());
+ Assert.assertEquals(0, tw.getPercentageOfWater());
+ tw.setBgColor(Color.yellow);
+ tw.setWaterColor(Color.orange);
+ tw.setPercentageOfWater(20);
+ Assert.assertEquals(Color.orange, tw.getWaterColor());
+ Assert.assertEquals(Color.yellow, tw.getBgColor());
+ Assert.assertEquals(20, tw.getPercentageOfWater());
+
+ }
+
+ @Test
+ public void getBackground() {
+ TextWithWaterLevel ifc = getInstance();
+ ifc.setCachedPolygon(null);
+ ifc.setPercentageOfWater(50);
+ BufferedImage bic = ifc.getBackground();
+ int w = bic.getWidth();
+ int h = bic.getHeight();
+ Assert.assertEquals(Color.blue, new Color(bic.getRGB(w / 2, 2 * h / 3)));
+ Assert.assertEquals(Color.white, new Color(bic.getRGB(w / 2, h / 3)));
+ ifc.setCachedPolygon(null);
+ ifc.setPercentageOfWater(5);
+ bic = ifc.getBackground();
+ Assert.assertEquals(Color.white, new Color(bic.getRGB(w / 2, 2 * h / 3)));
+ Assert.assertEquals(Color.white, new Color(bic.getRGB(w / 2, h / 3)));
+ ifc.setCachedPolygon(null);
+ ifc.setPercentageOfWater(95);
+ bic = ifc.getBackground();
+ Assert.assertEquals(Color.blue, new Color(bic.getRGB(w / 2, 2 * h / 3)));
+ Assert.assertEquals(Color.blue, new Color(bic.getRGB(w / 2, h / 3)));
+
+
+
+ }
+
+ private TextWithWaterLevel getInstance() {
+ BufferedImage bi1 = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
+ Font f = bi1.createGraphics().getFont().deriveFont(Font.BOLD, 130);
+ TextWithWaterLevel ifc = new TextWithWaterLevel("O O", f);
+ return ifc;
+ }
+
+ @Test
+ public void cutToTest() {
+ TextWithWaterLevel ifc = getInstance();
+ ifc.setPercentageOfWater(50);
+ BufferedImage bic = ifc.getBackground();
+ int w = bic.getWidth();
+ int h = bic.getHeight();
+ bic = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
+ ifc.cutTo(bic.createGraphics(), 0, h);
+ Assert.assertEquals(Color.blue, new Color(bic.getRGB(52, 142)));
+ Assert.assertEquals(Color.blue, new Color(bic.getRGB(170, 110)));
+ Assert.assertEquals(Color.white, new Color(bic.getRGB(52, 62)));
+ Assert.assertEquals(Color.white, new Color(bic.getRGB(245, 85)));
+
+ //well this should be acctually rgba 0,0,0,0 but somehow this was no passig
+ //you can confirm with:
+ //ImageFontCutterTest.save(bic, "halfFiledOus")
+ Assert.assertEquals(new Color(0, 0, 0), new Color(bic.getRGB(137, 127)));
+ Assert.assertEquals(new Color(0, 0, 0), new Color(bic.getRGB(137, 2)));
+
+
+
+
+ }
+}
diff --git a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/BasicComponentErrorSplashScreenTest.java b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/BasicComponentErrorSplashScreenTest.java
new file mode 100644
index 0000000..0ee39df
--- /dev/null
+++ b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/BasicComponentErrorSplashScreenTest.java
@@ -0,0 +1,127 @@
+/* BasicComponentSplashScreenTest.java
+Copyright (C) 2012 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; either version 2, or (at your option)
+any later version.
+
+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. */
+package net.sourceforge.jnlp.splashscreen.parts;
+
+import java.awt.Graphics;
+import net.sourceforge.jnlp.splashscreen.SplashUtils.SplashReason;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class BasicComponentErrorSplashScreenTest {
+
+ @Test
+ public void createAditionalInfoTest() {
+ BasicComponentSplashScreenImpl tested = new BasicComponentSplashScreenImpl();
+ String v = "2.118x08";
+ tested.setVersion(v);
+ tested.setSplashReason(SplashReason.APPLET);
+ String s1 = tested.createAditionalInfoTest();
+ Assert.assertNotNull("Not null input must result to something", s1);
+ Assert.assertTrue("Not null input must have version value", s1.contains(v));
+ Assert.assertTrue("Not null input must have version string", s1.contains("version"));
+ Assert.assertTrue("Not null input must have version string", s1.contains(SplashReason.APPLET.toString()));
+ tested.setVersion(null);
+ tested.setSplashReason(null);
+ String s2 = tested.createAditionalInfoTest();
+ Assert.assertNull("Not null input must result to something", s2);
+ tested.setSplashReason(null);
+ tested.setVersion(v);
+ Exception ex = null;
+ try {
+ String s3 = tested.createAditionalInfoTest();
+ } catch (Exception exx) {
+ ex = exx;
+ }
+ Assert.assertNotNull("Null reason vith set version must causes exception", ex);
+
+
+ }
+
+ @Test
+ public void setGetError() {
+ BasicComponentSplashScreenImpl tested = new BasicComponentSplashScreenImpl();
+ Exception ex = new Exception("ujuj");
+ tested.setLoadingException(ex);
+ Assert.assertEquals(ex, tested.getLoadingException());
+
+ }
+
+ private class BasicComponentSplashScreenImpl extends BasicComponentErrorSplashScreen {
+
+ public BasicComponentSplashScreenImpl() {
+ }
+
+ @Override
+ public void paintComponent(Graphics g) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void paintTo(Graphics g) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void adjustForSize() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void startAnimation() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void stopAnimation() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public String createAditionalInfoTest() {
+ return super.createAditionalInfo();
+ }
+
+ @Override
+ public void setPercentage(int done) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getPercentage() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+ }
+}
diff --git a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/BasicComponentSplashScreenTest.java b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/BasicComponentSplashScreenTest.java
new file mode 100644
index 0000000..2386500
--- /dev/null
+++ b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/BasicComponentSplashScreenTest.java
@@ -0,0 +1,118 @@
+/* BasicComponentSplashScreenTest.java
+Copyright (C) 2012 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; either version 2, or (at your option)
+any later version.
+
+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. */
+package net.sourceforge.jnlp.splashscreen.parts;
+
+import java.awt.Graphics;
+import net.sourceforge.jnlp.splashscreen.SplashUtils.SplashReason;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class BasicComponentSplashScreenTest {
+
+ @Test
+ public void createAditionalInfoTest() {
+ BasicComponentSplashScreenImpl tested = new BasicComponentSplashScreenImpl();
+ String v = "2.118x08";
+ tested.setVersion(v);
+ tested.setSplashReason(SplashReason.APPLET);
+ String s1 = tested.createAditionalInfoTest();
+ Assert.assertNotNull("Not null input must result to something", s1);
+ Assert.assertTrue("Not null input must have version value", s1.contains(v));
+ Assert.assertTrue("Not null input must have version string", s1.contains("version"));
+ Assert.assertTrue("Not null input must have version string", s1.contains(SplashReason.APPLET.toString()));
+ tested.setVersion(null);
+ tested.setSplashReason(null);
+ String s2 = tested.createAditionalInfoTest();
+ Assert.assertNull("Not null input must result to something", s2);
+ tested.setSplashReason(null);
+ tested.setVersion(v);
+ Exception ex = null;
+ try {
+ String s3 = tested.createAditionalInfoTest();
+ } catch (Exception exx) {
+ ex = exx;
+ }
+ Assert.assertNotNull("Null reason vith set version must causes exception", ex);
+
+
+ }
+
+ private class BasicComponentSplashScreenImpl extends BasicComponentSplashScreen {
+
+ public BasicComponentSplashScreenImpl() {
+ }
+
+ @Override
+ public void paintComponent(Graphics g) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void paintTo(Graphics g) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void adjustForSize() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void startAnimation() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void stopAnimation() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public String createAditionalInfoTest() {
+ return super.createAditionalInfo();
+ }
+
+ @Override
+ public void setPercentage(int done) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getPercentage() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+ }
+}
diff --git a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/DescriptionInfoItemTest.java b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/DescriptionInfoItemTest.java
new file mode 100644
index 0000000..abce413
--- /dev/null
+++ b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/DescriptionInfoItemTest.java
@@ -0,0 +1,138 @@
+/* DescriptionInfoItemTest.java
+Copyright (C) 2012 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; either version 2, or (at your option)
+any later version.
+
+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. */
+package net.sourceforge.jnlp.splashscreen.parts;
+
+import junit.framework.Assert;
+import net.sourceforge.jnlp.ServerAccess;
+import org.junit.Test;
+
+public class DescriptionInfoItemTest {
+
+ private static final DescriptionInfoItem[] d = {new DescriptionInfoItem("Firm 1", null),
+ new DescriptionInfoItem("Firm 2", null),
+ new DescriptionInfoItem("Firm 3", "k1"),
+ new DescriptionInfoItem("Firm 4", "k2"),
+ new DescriptionInfoItem("Firm 6", "k1")};
+
+ @Test
+ public void setGetTest() {
+ DescriptionInfoItem di = new DescriptionInfoItem("a", "b");
+ Assert.assertEquals("a", di.getValue());
+ Assert.assertEquals("b", di.getKind());
+ Assert.assertEquals(InfoItem.description, di.getType());
+ di.setKind("q");
+ Assert.assertEquals("q", di.getKind());
+
+ }
+
+ @Test
+ public void isOfSameKindTests() {
+ boolean[] results = new boolean[]{true, true, false, false, false, true, true, false, false, false, false, false, true, false, true, false, false, false, true, false, false, false, true, false, true};
+ int x = -1;
+ for (int i = 0; i < d.length; i++) {
+ DescriptionInfoItem d1 = d[i];
+ for (int j = 0; j < d.length; j++) {
+ x++;
+ DescriptionInfoItem d2 = d[j];
+ ServerAccess.logOutputReprint(x + ": " + i + "x" + j + " " + d1.toString() + "x" + d2.toString() + "- same kind - " + d1.isOfSameKind(d2));
+ Assert.assertEquals(results[x], d1.isOfSameKind(d2));
+ }
+
+ }
+ }
+
+ @Test
+ public void isSameTest() {
+ boolean[] results = new boolean[]{true, true, false, false, false, true, true, false, false, false, false, false, true, false, true, false, false, false, true, false, false, false, true, false, true
+ };
+ int x = -1;
+ for (int i = 0; i < d.length; i++) {
+ DescriptionInfoItem d1 = d[i];
+ for (int j = 0; j < d.length; j++) {
+ x++;
+ DescriptionInfoItem d2 = d[j];
+ ServerAccess.logOutputReprint(x + ": " + i + "x" + j + " " + d1.toString() + "x" + d2.toString() + "- same - " + d1.isSame(d2));
+ Assert.assertEquals(results[x], d1.isSame(d2));
+ }
+
+ }
+
+ }
+
+ @Test
+ public void equalsTest() {
+ boolean[] results = new boolean[]{true, false, false, false, false, false, true, false, false, false, false, false, true, false, false, false, false, false, true, false, false, false, false, false, true
+ };
+ int x = -1;
+ for (int i = 0; i < d.length; i++) {
+ DescriptionInfoItem d1 = d[i];
+ for (int j = 0; j < d.length; j++) {
+ x++;
+ DescriptionInfoItem d2 = d[j];
+ ServerAccess.logOutputReprint(x + ": " + i + "x" + j + ", " + d1.toString() + " x " + d2.toString() + "- equals - " + d1.equals(d2));
+ Assert.assertEquals(results[x], d1.equals(d2));
+ }
+
+ }
+
+
+ }
+
+ @Test
+ public void toStringTest() {
+ DescriptionInfoItem d1 = new DescriptionInfoItem("Firm 3", null);
+ Assert.assertTrue(d1.toString().contains(d1.getValue()));
+ Assert.assertTrue(d1.toString().contains(d1.getType()));
+ Assert.assertTrue(d1.toString().contains("null"));
+ DescriptionInfoItem dd = new DescriptionInfoItem("Firm 3", "k1");
+ Assert.assertTrue(dd.toString().contains(dd.getValue()));
+ Assert.assertTrue(dd.toString().contains(dd.getType()));
+ Assert.assertTrue(dd.toString().contains(dd.getKind()));
+
+ }
+
+ @Test
+ public void toNiceStringTest() {
+ DescriptionInfoItem d1 = new DescriptionInfoItem("Firm 3", null);
+ Assert.assertTrue(d1.toNiceString().contains(d1.getValue()));
+ Assert.assertTrue(d1.toNiceString().contains(InfoItem.SPLASH + d1.getType()) || !d1.toNiceString().contains(InfoItem.SPLASH));
+ DescriptionInfoItem dd = new DescriptionInfoItem("Firm 3", "k1");
+ Assert.assertTrue(dd.toNiceString().contains(dd.getValue()));
+ Assert.assertTrue(dd.toNiceString().contains(InfoItem.SPLASH + dd.getType()) || !d1.toNiceString().contains(InfoItem.SPLASH));
+
+ }
+}
diff --git a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/InfoItemTest.java b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/InfoItemTest.java
new file mode 100644
index 0000000..5e35c8b
--- /dev/null
+++ b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/InfoItemTest.java
@@ -0,0 +1,111 @@
+/* InfoItemTest.java
+Copyright (C) 2012 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; either version 2, or (at your option)
+any later version.
+
+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. */
+package net.sourceforge.jnlp.splashscreen.parts;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *The optional kind="splash" attribute may be used in an icon element to indicate that the image is to be used as a "splash" screen during the launch of an application. If the JNLP file does not contain an icon element with kind="splash" attribute, Java Web Start will construct a splash screen using other items from the information Element.
+ *If the JNLP file does not contain any icon images, the splash image will consist of the application's title and vendor, as taken from the JNLP file.
+ *
+ * items not used inside
+ */
+public class InfoItemTest {
+
+ @Test
+ public void testGettersSetters() {
+ InfoItem ii = new InfoItem("a", "b");
+ Assert.assertEquals("a", ii.getType());
+ Assert.assertEquals("b", ii.getValue());
+ ii.setType("c");
+ Assert.assertEquals("c", ii.getType());
+ ii.setValue("d");
+ Assert.assertEquals("d", ii.getValue());
+
+ }
+
+ @Test
+ public void TestIsOfSameType() {
+ InfoItem i1 = new InfoItem("a", "b");
+ InfoItem i2 = new InfoItem("a", "c");
+ InfoItem i3 = new InfoItem("b", "a");
+ Assert.assertTrue(i1.isofSameType(i2));
+ Assert.assertFalse(i1.isofSameType(i3));
+ Assert.assertFalse(i2.isofSameType(i3));
+
+ DescriptionInfoItem d1 = new DescriptionInfoItem("a", InfoItem.descriptionKindToolTip);
+ InfoItem id1 = new InfoItem(InfoItem.description, "a");
+ Assert.assertTrue(id1.isofSameType(d1));
+
+ }
+
+ @Test
+ public void testEquals() {
+ InfoItem i1 = new InfoItem("a", "b");
+ InfoItem i11 = new InfoItem("a", "b");
+ InfoItem i2 = new InfoItem("a", "c");
+ InfoItem i3 = new InfoItem("b", "a");
+ Assert.assertFalse(i1.equals(i2));
+ Assert.assertFalse(i1.equals(i3));
+ Assert.assertFalse(i2.equals(i3));
+ Assert.assertTrue(i1.equals(i11));
+ DescriptionInfoItem d1 = new DescriptionInfoItem("a", InfoItem.descriptionKindToolTip);
+ InfoItem id1 = new InfoItem(InfoItem.description, "a");
+ Assert.assertTrue(id1.equals(d1));
+
+
+ }
+
+ @Test
+ public void toStringTest() {
+ InfoItem i1 = new InfoItem("aa", "bb");
+ Assert.assertTrue(i1.toString().contains("aa"));
+ Assert.assertTrue(i1.toString().contains("bb"));
+ Assert.assertTrue(i1.toString().length() > 4);
+
+ }
+
+ @Test
+ public void toNiceString() {
+ InfoItem i1 = new InfoItem("aaa", "bbb");
+ Assert.assertTrue(i1.toNiceString().contains(InfoItem.SPLASH + "aaa") || !i1.toNiceString().contains(InfoItem.SPLASH));
+ Assert.assertTrue(i1.toNiceString().contains("bbb"));
+ Assert.assertFalse(i1.toNiceString().equals(i1.toString()));
+ }
+
+}
diff --git a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/InformationElementTest.java b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/InformationElementTest.java
new file mode 100644
index 0000000..e02f5e5
--- /dev/null
+++ b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/InformationElementTest.java
@@ -0,0 +1,279 @@
+/* InformationElementTest.java
+Copyright (C) 2012 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; either version 2, or (at your option)
+any later version.
+
+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. */
+/**
+http://docs.oracle.com/javase/6/docs/technotes/guides/javaws/developersguide/syntax.html
+ */
+package net.sourceforge.jnlp.splashscreen.parts;
+
+import java.io.ByteArrayInputStream;
+import java.io.UnsupportedEncodingException;
+import net.sourceforge.jnlp.JNLPFile;
+import net.sourceforge.jnlp.ParseException;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class InformationElementTest {
+
+ private static class TestDescriptionInfoItem extends DescriptionInfoItem {
+
+ public TestDescriptionInfoItem(String value, String kind) {
+ super(value, kind);
+ }
+
+ public String toXml() {
+ if (kind == null) {
+ return new TestInfoItem(type, value).toXml();
+ }
+ return "<" + type + " kind=\"" + kind + "\">" + value + "</" + type + ">";
+ }
+ }
+
+ private static class TestInfoItem extends InfoItem {
+
+ public TestInfoItem(String type, String value) {
+ super(type, value);
+ }
+
+ public String toXml() {
+ if (type.equals(homepage)) {
+ return "<" + type + " " + homepageHref + "=\"" + value + "\"/>";
+ }
+ return "<" + type + ">" + value + "</" + type + ">";
+ }
+ }
+ private final static TestInfoItem title = new TestInfoItem(InfoItem.title, "title exp");
+ private final static TestInfoItem vendor = new TestInfoItem(InfoItem.vendor, "vendor exp");
+ private final static TestInfoItem homepage = new TestInfoItem(InfoItem.homepage, "http://homepage.exp");
+ private final static TestDescriptionInfoItem oneLineD = new TestDescriptionInfoItem("One Line", DescriptionInfoItem.descriptionKindOneLine);
+ private final static TestDescriptionInfoItem toolTipD = new TestDescriptionInfoItem("Tooltip", DescriptionInfoItem.descriptionKindToolTip);
+ private final static TestDescriptionInfoItem short1D = new TestDescriptionInfoItem("short1", DescriptionInfoItem.descriptionKindShort);
+ private final static TestDescriptionInfoItem short2D = new TestDescriptionInfoItem("short2", DescriptionInfoItem.descriptionKindShort);
+ private final static TestDescriptionInfoItem noKindD = new TestDescriptionInfoItem("noKind", null);
+ private static final String testJnlpheader =
+ "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
+ + "<jnlp spec=\"1.0\" href=\"http://somehref.jnlp\" codebase=\"http://some.code.base\">\n"
+ + " <information>\n";
+ private static final String testJnlpFooter = " <offline/>\n"
+ + " </information>\n"
+ + " <resources>\n"
+ + " <j2se version=\"1.6+\"/>\n"
+ + " <jar href=\"somejar\"/>\n"
+ + " </resources>\n"
+ + " <application-desc main-class=\"someMainClass\">\n"
+ + " </application-desc>\n"
+ + "</jnlp>";
+
+ @Test
+ public void testSetGetTitle() {
+
+ InformationElement ie = new InformationElement();
+ Assert.assertNull("After creation value must be null", ie.getTitle());
+ ie.setTitle(title.getValue());
+ Assert.assertNotNull("After assigmentvalue must NOT be null", ie.getTitle());
+ Assert.assertTrue("After assigment value must be included in output", ie.getTitle().contains(title.getValue()));
+ }
+
+ @Test
+ public void testSetGetvendor() {
+ InformationElement ie = new InformationElement();
+ Assert.assertNull("After creation value must be null", ie.getVendor());
+ ie.setvendor(vendor.getValue());
+ Assert.assertNotNull("After assigmentvalue must NOT be null", ie.getVendor());
+ Assert.assertTrue("After assigment value must be included in output", ie.getVendor().contains(vendor.getValue()));
+ }
+
+ @Test
+ public void testSetGetHomepage() {
+ InformationElement ie = new InformationElement();
+ Assert.assertNull("After creation value must be null", ie.getHomepage());
+ ie.setHomepage(homepage.getValue());
+ Assert.assertNotNull("After assigmentvalue must NOT be null", ie.getHomepage());
+ Assert.assertTrue("After assigment value must be included in output", ie.getHomepage().contains(homepage.getValue()));
+ }
+
+ @Test
+ public void addDescriptionTest() {
+ InformationElement ie = new InformationElement();
+ Assert.assertNotNull("Descriptions should never be null", ie.getDescriptions());
+ Assert.assertEquals("Descriptions should be empty", 0, ie.getDescriptions().size());
+ ie.addDescription(toolTipD.getValue(), toolTipD.getKind());
+ Assert.assertNotNull("Descriptions should never be null", ie.getDescriptions());
+ Assert.assertEquals("Descriptions should be empty", 1, ie.getDescriptions().size());
+ ie.addDescription(short1D.getValue(), short1D.getKind());
+ Assert.assertNotNull("Descriptions should never be null", ie.getDescriptions());
+ Assert.assertEquals("Descriptions should be empty", 2, ie.getDescriptions().size());
+ ie.addDescription(short2D.getValue(), short2D.getKind());
+ Assert.assertNotNull("Descriptions should never be null", ie.getDescriptions());
+ Assert.assertEquals("Descriptions should reamin same", 2, ie.getDescriptions().size());
+ ie.addDescription(oneLineD.getValue(), oneLineD.getKind());
+ Assert.assertNotNull("Descriptions should never be null", ie.getDescriptions());
+ Assert.assertEquals("Descriptions should be ", 3, ie.getDescriptions().size());
+ ie.addDescription(noKindD.getValue(), noKindD.getKind());
+ Assert.assertNotNull("Descriptions should never be null", ie.getDescriptions());
+ Assert.assertEquals("Descriptions should be ", 4, ie.getDescriptions().size());
+
+
+ }
+
+ public void getBestMatchingDescriptionForSplashTest() {
+ InformationElement ie = new InformationElement();
+ Assert.assertNull(ie.getBestMatchingDescriptionForSplash());
+ ie.addDescription(toolTipD.getValue(), toolTipD.getKind());
+ Assert.assertNull(ie.getBestMatchingDescriptionForSplash());
+ ie.addDescription(short1D.getValue(), short1D.getKind());
+ Assert.assertNull(ie.getBestMatchingDescriptionForSplash());
+ ie.addDescription(noKindD.getValue(), noKindD.getKind());
+ Assert.assertNotNull(ie.getBestMatchingDescriptionForSplash());
+ Assert.assertEquals(ie.getBestMatchingDescriptionForSplash().getValue(), (noKindD.getValue()));
+ ie.addDescription(oneLineD.getValue(), oneLineD.getKind());
+ Assert.assertNotNull(ie.getBestMatchingDescriptionForSplash());
+ Assert.assertEquals(ie.getBestMatchingDescriptionForSplash().getValue(), (oneLineD.getValue()));
+ ie.addDescription(short2D.getValue(), short2D.getKind());
+ Assert.assertNotNull(ie.getBestMatchingDescriptionForSplash());
+ Assert.assertEquals(ie.getBestMatchingDescriptionForSplash().getValue(), (oneLineD.getValue()));
+
+
+ }
+
+ public void getLongestDescriptionForSplashTest() {
+ InformationElement ie = new InformationElement();
+ Assert.assertNull(ie.getLongestDescriptionForSplash());
+ ie.addDescription(toolTipD.getValue(), toolTipD.getKind());
+ Assert.assertNotNull(ie.getLongestDescriptionForSplash());
+ Assert.assertEquals(ie.getLongestDescriptionForSplash().getValue(), (toolTipD.getValue()));
+ ie.addDescription(oneLineD.getValue(), oneLineD.getKind());
+ Assert.assertNotNull(ie.getLongestDescriptionForSplash());
+ Assert.assertEquals(ie.getLongestDescriptionForSplash().getValue(), (oneLineD.getValue()));
+ ie.addDescription(noKindD.getValue(), noKindD.getKind());
+ ie.addDescription(oneLineD.getValue(), oneLineD.getKind());//disturb
+ Assert.assertNotNull(ie.getLongestDescriptionForSplash());
+ Assert.assertEquals(ie.getLongestDescriptionForSplash().getValue(), (noKindD.getValue()));
+ ie.addDescription(short1D.getValue(), short1D.getKind());
+ ie.addDescription(toolTipD.getValue(), toolTipD.getKind());//disturb
+ Assert.assertNotNull(ie.getLongestDescriptionForSplash());
+ Assert.assertEquals(ie.getLongestDescriptionForSplash().getValue(), (short1D.getValue()));
+
+ }
+
+ @Test
+ public void getDescriptionTest() {
+ getBestMatchingDescriptionForSplashTest();
+
+ }
+
+ @Test
+ public void getHeaderTest() {
+ InformationElement ie = new InformationElement();
+ Assert.assertNotNull("Header should never be null", ie.getHeader());
+ Assert.assertEquals(0, ie.getHeader().size());
+ ie.setvendor(vendor.getValue());
+ Assert.assertEquals(1, ie.getHeader().size());
+ ie.setTitle(title.getValue());
+ Assert.assertEquals(2, ie.getHeader().size());
+ ie.setHomepage(homepage.getValue());
+ Assert.assertEquals(3, ie.getHeader().size());
+ ie.setTitle(homepage.getValue());
+ Assert.assertEquals(3, ie.getHeader().size());
+ ie.addDescription(toolTipD.getValue());
+ Assert.assertEquals(3, ie.getHeader().size());
+ ie.addDescription(oneLineD.getValue());
+ Assert.assertEquals(3, ie.getHeader().size());
+ }
+
+ @Test
+ public void createFromJNLP() throws UnsupportedEncodingException, ParseException {
+ JNLPFile jnlpFile0 = null;
+ InformationElement ie0 = InformationElement.createFromJNLP(jnlpFile0);
+ Assert.assertNull(ie0);
+ String exJnlp1 = "<jnlp>this is invalid jnlp<jnlp>";
+ Exception ex = null;
+ JNLPFile jnlpFile1 = null;
+ try {
+ jnlpFile1 = new JNLPFile(new ByteArrayInputStream(exJnlp1.getBytes("utf-8")), true);
+ } catch (Exception eex) {
+ ex = eex;
+ }
+ Assert.assertNotNull(ex);
+ InformationElement ie1 = InformationElement.createFromJNLP(jnlpFile1);
+ Assert.assertNull(ie1);
+
+ //title, vendor and homepage are obligatory.. not so much to test
+ String exJnlp2 = testJnlpheader + title.toXml() + "\n" + homepage.toXml() + "\n" + vendor.toXml() + "\n" + testJnlpFooter;
+ JNLPFile jnlpFile2 = new JNLPFile(new ByteArrayInputStream(exJnlp2.getBytes("utf-8")), true);
+ InformationElement ie2 = InformationElement.createFromJNLP(jnlpFile2);
+ Assert.assertNotNull(ie2);
+ Assert.assertEquals(3, ie2.getHeader().size());
+ Assert.assertEquals(0, ie2.getDescriptions().size());
+
+ String exJnlp3 = testJnlpheader + title.toXml() + "\n" + homepage.toXml() + "\n" + vendor.toXml() + "\n" + toolTipD.toXml() + "\n" + testJnlpFooter;
+ JNLPFile jnlpFile3 = new JNLPFile(new ByteArrayInputStream(exJnlp3.getBytes("utf-8")), true);
+ InformationElement ie3 = InformationElement.createFromJNLP(jnlpFile3);
+ Assert.assertNotNull(ie3);
+ Assert.assertEquals(3, ie3.getHeader().size());
+ Assert.assertEquals(1, ie3.getDescriptions().size());
+
+ String exJnlp4 = testJnlpheader + title.toXml() + "\n" + homepage.toXml() + "\n" + vendor.toXml() + "\n" + noKindD.toXml() + "\n" + testJnlpFooter;
+ JNLPFile jnlpFile4 = new JNLPFile(new ByteArrayInputStream(exJnlp4.getBytes("utf-8")), true);
+ InformationElement ie4 = InformationElement.createFromJNLP(jnlpFile4);
+ Assert.assertNotNull(ie4);
+ Assert.assertEquals(3, ie4.getHeader().size());
+ Assert.assertEquals(1, ie4.getDescriptions().size());
+
+ String exJnlp5 = testJnlpheader + title.toXml() + "\n" + homepage.toXml() + "\n" + vendor.toXml() + "\n" + noKindD.toXml() + "\n" + toolTipD.toXml() + "\n" + testJnlpFooter;
+ JNLPFile jnlpFile5 = new JNLPFile(new ByteArrayInputStream(exJnlp5.getBytes("utf-8")), true);
+ InformationElement ie5 = InformationElement.createFromJNLP(jnlpFile5);
+ Assert.assertNotNull(ie5);
+ Assert.assertEquals(3, ie5.getHeader().size());
+ Assert.assertEquals(2, ie5.getDescriptions().size());
+
+
+ }
+
+
+ @Test
+ public void toXml() {
+ TestInfoItem i1 = new TestInfoItem("aa", "bb");
+ Assert.assertTrue(i1.toXml().contains("aa"));
+ Assert.assertTrue(i1.toXml().contains("bb"));
+ Assert.assertTrue(i1.toXml().length() > 4);
+ JEditorPaneBasedExceptionDialogTest.assertMarkup(i1.toXml());
+
+ }
+}
diff --git a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialogTest.java b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialogTest.java
new file mode 100644
index 0000000..9372ff7
--- /dev/null
+++ b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialogTest.java
@@ -0,0 +1,190 @@
+/* JeditorPaneBasedExceptionDialog.java
+Copyright (C) 2012 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; either version 2, or (at your option)
+any later version.
+
+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. */
+package net.sourceforge.jnlp.splashscreen.parts;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import net.sourceforge.jnlp.runtime.Translator;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JEditorPaneBasedExceptionDialogTest {
+
+ private static RuntimeException eex = new RuntimeException("ex2");
+ private static Exception ex = new Exception("ex1", eex);
+ private static String ai = "Another info";
+ private static InformationElement ec = new InformationElement();
+ private static List<String> l = new ArrayList<String>(3);
+
+ @BeforeClass
+ public static void fillLists() {
+ ec.setHomepage("item 1");
+ ec.setTitle("item 2");
+ ec.setvendor("item 3");
+ ec.addDescription("item 4");
+ l = JEditorPaneBasedExceptionDialog.infoElementToList(ec);
+
+ }
+
+ static void assertHtml(String s) {
+ Assert.assertTrue("result of getText must be marked html", s.contains("html"));
+ Assert.assertTrue("result of getText must be marked html", s.contains("body"));
+ assertMarkup(s);
+ }
+
+ static void assertMarkup(String s) {
+ Assert.assertTrue("result of getText must be marked in by html markup", s.contains("<") && s.contains(">"));
+ Assert.assertTrue("result of getText must be marked in by html markup", s.contains("</") || s.contains("/>"));
+ }
+
+ private void assertAI(String s, boolean b) {
+ if (b) {
+ Assert.assertTrue("result of getText must contains annother info", s.contains(ai));
+ } else {
+ Assert.assertFalse("result of getText must NOT contains annother info", s.contains(ai));
+ }
+ }
+
+ private void assertLL(String s, boolean b) {
+ for (String i : l) {
+
+ if (b) {
+ Assert.assertTrue("result of getText must contains info list", s.contains(i));
+ } else {
+ Assert.assertFalse("result of getText must NOT contains info list", s.contains(i));
+ }
+ }
+ }
+
+ private void assertFullException(String s, boolean b) {
+ if (b) {
+ Assert.assertTrue("result of getText must contains complete exception", s.contains(ex.getMessage()));
+ Assert.assertTrue("result of getText must contains complete exception", s.contains(eex.getMessage()));
+ } else {
+ Assert.assertFalse("result of getText must contains not complete exception", s.contains(ex.getMessage()));
+ Assert.assertFalse("result of getText must contains not complete exception", s.contains(eex.getMessage()));
+
+ }
+ }
+
+ @Test
+ public void getTextTest() {
+ String s1 = JEditorPaneBasedExceptionDialog.getText(ex, l, ai);
+ String s2 = JEditorPaneBasedExceptionDialog.getText(ex, l, null);
+ String s3 = JEditorPaneBasedExceptionDialog.getText(ex, null, ai);
+ String s4 = JEditorPaneBasedExceptionDialog.getText(null, l, ai);
+ assertHtml(s1);
+ assertHtml(s2);
+ assertHtml(s3);
+ assertHtml(s4);
+ assertAI(s1, true);
+ assertAI(s2, false);
+ assertAI(s3, true);
+ assertAI(s4, true);
+ assertLL(s1, true);
+ assertLL(s2, true);
+ assertLL(s3, false);
+ assertLL(s4, true);
+ assertFullException(s1, true);
+ assertFullException(s2, true);
+ assertFullException(s3, true);
+ assertFullException(s4, false);
+ JEditorPaneBasedExceptionDialog d1 = new JEditorPaneBasedExceptionDialog(null, false, ex, ec, ai);
+ JEditorPaneBasedExceptionDialog d2 = new JEditorPaneBasedExceptionDialog(null, false, ex, ec, null);
+ JEditorPaneBasedExceptionDialog d3 = new JEditorPaneBasedExceptionDialog(null, false, ex, null, ai);
+ JEditorPaneBasedExceptionDialog d4 = new JEditorPaneBasedExceptionDialog(null, false, null, ec, ai);
+ Assert.assertTrue("message from dialog mus be same as pattern", d1.getMessage().equals(s1));
+ Assert.assertTrue("message from dialog mus be same as pattern", d2.getMessage().equals(s2));
+ Assert.assertTrue("message from dialog mus be same as pattern", d3.getMessage().equals(s3));
+ Assert.assertTrue("message from dialog mus be same as pattern", d4.getMessage().equals(s4));
+
+ }
+
+ @Test
+ public void getExceptionStackTraceAsString() {
+ String t1 = JEditorPaneBasedExceptionDialog.getExceptionStackTraceAsString(ex);
+ assertFullException(t1, true);
+ String t2 = JEditorPaneBasedExceptionDialog.getExceptionStackTraceAsString(null);
+ Assert.assertNotNull("For null empty result must not be null", t2);
+ Assert.assertEquals("null input must result to empty string", "", t2);
+ }
+
+ @Test
+ public void getExceptionStackTraceAsStrings() {
+ String[] t1 = JEditorPaneBasedExceptionDialog.getExceptionStackTraceAsStrings(ex);
+ assertFullException(Arrays.toString(t1), true);
+ String[] t2 = JEditorPaneBasedExceptionDialog.getExceptionStackTraceAsStrings(null);
+ Assert.assertNotNull("For null empty result must not be null", t2);
+ Assert.assertArrayEquals("null input must result to empty array", new String[0], t2);
+ }
+
+ @Test
+ public void formatListInfoList() {
+ String t1 = JEditorPaneBasedExceptionDialog.formatListInfoList(l);
+ assertMarkup(t1);
+ assertLL(t1, true);
+ String t2 = JEditorPaneBasedExceptionDialog.formatInfo(null);
+ Assert.assertNotNull("For null empty result must not be null", t2);
+ Assert.assertEquals("null input must result to empty string", "", t2);
+ }
+
+ @Test
+ public void formatInfo() {
+ String s = "SOME STRING";
+ String t1 = JEditorPaneBasedExceptionDialog.formatInfo(s);
+ assertMarkup(t1);
+ Assert.assertTrue("Marked text must contains source", t1.contains(s));
+ String t2 = JEditorPaneBasedExceptionDialog.formatInfo(null);
+ Assert.assertNotNull("For null empty result must not be null", t2);
+ Assert.assertEquals("null input must result to empty string", "", t2);
+
+ }
+
+ @Test
+ public void infoElementToListTets() {
+
+ List<String> tl = JEditorPaneBasedExceptionDialog.infoElementToList(ec);
+ Assert.assertTrue("Transformed elemetn must contains all items ", tl.contains(l.get(0)));
+ Assert.assertTrue("Transformed elemetn must contains all items ", tl.contains(l.get(1)));
+ Assert.assertTrue("Transformed elemetn must contains all items ", tl.contains(l.get(2)));
+ Assert.assertTrue("Transformed elemetn must contains all items ", tl.contains(l.get(3)));
+ }
+}