aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJana Fabrikova <[email protected]>2013-05-02 11:16:36 +0200
committerJana Fabrikova <[email protected]>2013-05-02 11:16:36 +0200
commit9beec9281b15401fff46cbc9c86b3c6ceb16fd2c (patch)
tree6a291120c87fbc12810724cf50715e13ca7fcda0
parent7e9ddc51fd10a68aff93eee5cd7173992bec1522 (diff)
modifying makefile for awtframework default icon
-rw-r--r--ChangeLog34
-rw-r--r--Makefile.am10
-rw-r--r--tests/netx/unit/net/sourceforge/jnlp/awt/imagesearch/ComponentFinderTest.java56
-rw-r--r--tests/reproducers/simple/AWTCommonResourcesOnly/resources/marker.pngbin0 -> 180 bytes
-rw-r--r--tests/reproducers/simple/JavawsAWTRobotUsageSample/resources/javaws-awtrobot-usage-sample.jnlp57
-rw-r--r--tests/reproducers/simple/JavawsAWTRobotUsageSample/srcs/JavawsAWTRobotUsageSample.java176
-rw-r--r--tests/reproducers/simple/JavawsAWTRobotUsageSample/testcases/JavawsAWTRobotUsageSampleTest.java248
-rw-r--r--tests/test-extensions-tests/net/sourceforge/jnlp/awt/imagesearch/ComponentFinderTest.java56
-rw-r--r--tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java10
-rw-r--r--tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/ComponentFinder.java11
-rw-r--r--tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/marker.pngbin0 -> 180 bytes
11 files changed, 647 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 0152409..89d86e4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,37 @@
+2013-05-02 Jana Fabrikova <[email protected]>
+
+ * Makefile.am:
+ the directory $(TEST_EXTENSIONS_SRCDIR) (i.e. test/test-extensions)
+ added on classpath for running reproducers, unit tests, and test code
+ coverage for reproducers and unittests using emma and jacoco, that is
+ for the following 6 targets:
+ (stamps/run-netx-dist-tests.stamp)
+ (stamps/run-netx-unit-tests.stamp)
+ (stamps/run-unit-test-code-coverage.stamp) with EMMA
+ (stamps/run-unit-test-code-coverage-jacoco.stamp)
+ (stamps/run-reproducers-test-code-coverage.stamp) with EMMA
+ (stamps/run-reproducers-test-code-coverage-jacoco.stamp)
+ * tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java:
+ modifying the constructor, the default icon is taken from
+ ComponentFinder instead of loading from file
+ * tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/ComponentFinder.java:
+ added a block of initialization code - the default icon
+ * tests/netx/unit/net/sourceforge/jnlp/awt/imagesearch/ComponentFinderTest.java:
+ unit test for the initialization code in ComponentFinder
+ * tests/reproducers/simple/AWTCommonResourcesOnly/resources/marker.png:
+ second copy of the default icon in a reproducer with resources only
+ * tests/reproducers/simple/JavawsAWTRobotUsageSample/resources/javaws-awtrobot-usage-sample.jnlp:
+ jnlp file for displaying the applet
+ * tests/reproducers/simple/JavawsAWTRobotUsageSample/srcs/JavawsAWTRobotUsageSample.java:
+ the applet
+ * tests/reproducers/simple/JavawsAWTRobotUsageSample/testcases/JavawsAWTRobotUsageSampleTest.java:
+ adding 6 testcases testing clicking with different mouse
+ buttons on the applet
+ * tests/test-extensions-tests/net/sourceforge/jnlp/awt/imagesearch/ComponentFinderTest.java:
+ unit test for the initialization code in ComponentFinder
+ * tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/marker.png:
+ first copy of the default icon, will be on classpath
+
2013-04-30 Adam Domurad <[email protected]>
* tests/netx/unit/sun/applet/MethodOverloadResolverTest.java: Add missing
diff --git a/Makefile.am b/Makefile.am
index cf9e1e8..93e79e7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -843,7 +843,7 @@ stamps/run-netx-dist-tests.stamp: stamps/netx-dist.stamp extra-lib/about.jar sta
$(TESTS_DIR)/$(REPORT_STYLES_DIRNAME) $(REPRODUCERS_CLASS_NAMES) stamps/process-custom-reproducers.stamp
cd $(TEST_EXTENSIONS_DIR) ; \
class_names=`cat $(REPRODUCERS_CLASS_NAMES)` ; \
- CLASSPATH=$(NETX_DIR)/lib/classes.jar:$(JUNIT_JAR):$(JUNIT_RUNNER_JAR):.:$(TEST_EXTENSIONS_TESTS_DIR) \
+ CLASSPATH=$(NETX_DIR)/lib/classes.jar:$(JUNIT_JAR):$(JUNIT_RUNNER_JAR):.:$(TEST_EXTENSIONS_TESTS_DIR):$(TEST_EXTENSIONS_SRCDIR) \
$(BOOT_DIR)/bin/java $(REPRODUCERS_DPARAMETERS) \
-Xbootclasspath:$(RUNTIME) CommandLine $$class_names
if WITH_XSLTPROC
@@ -1021,7 +1021,7 @@ stamps/run-netx-unit-tests.stamp: stamps/netx-unit-tests-compile.stamp $(JUNIT_R
done ; \
cd $(NETX_UNIT_TEST_DIR) ; \
class_names=`cat $(UNIT_CLASS_NAMES)` ; \
- CLASSPATH=$(NETX_DIR)/lib/classes.jar:$(abs_top_builddir)/liveconnect/lib/classes.jar:$(JUNIT_JAR):$(JUNIT_RUNNER_JAR):$(TEST_EXTENSIONS_DIR):. \
+ CLASSPATH=$(NETX_DIR)/lib/classes.jar:$(abs_top_builddir)/liveconnect/lib/classes.jar:$(JUNIT_JAR):$(JUNIT_RUNNER_JAR):$(TEST_EXTENSIONS_DIR):.:$(TEST_EXTENSIONS_SRCDIR) \
$(BOOT_DIR)/bin/java -Xbootclasspath:$(RUNTIME) CommandLine $$class_names
if WITH_XSLTPROC
-$(XSLTPROC) --stringparam logs logs_unit.html $(TESTS_SRCDIR)/$(REPORT_STYLES_DIRNAME)/jreport.xsl $(NETX_UNIT_TEST_DIR)/tests-output.xml > $(TESTS_DIR)/index_unit.html
@@ -1057,6 +1057,7 @@ if WITH_EMMA
-cp $(BOOT_DIR)/jre/lib/resources.jar \
-cp $(RHINO_RUNTIME) \
-cp $(TEST_EXTENSIONS_DIR) \
+ -cp $(TEST_EXTENSIONS_SRCDIR) \
-cp . \
-ix "-org.junit.*" \
-ix "-junit.*" \
@@ -1101,7 +1102,7 @@ if WITH_JACOCO
mv $(NETX_UNIT_TEST_DIR)/$$file $(NETX_UNIT_TEST_DIR)/"$$file""$(EMMA_BACKUP_SUFFIX)" ; \
done ;\
class_names=`cat $(UNIT_CLASS_NAMES)` ; \
- CLASSPATH=$(NETX_DIR)/lib/classes.jar:$(abs_top_builddir)/liveconnect/lib/classes.jar:$(JUNIT_JAR):$(JUNIT_RUNNER_JAR):$(TEST_EXTENSIONS_DIR):$(JACOCO_CLASSPATH):. \
+ CLASSPATH=$(NETX_DIR)/lib/classes.jar:$(abs_top_builddir)/liveconnect/lib/classes.jar:$(JUNIT_JAR):$(JUNIT_RUNNER_JAR):$(TEST_EXTENSIONS_DIR):$(JACOCO_CLASSPATH):.:$(TEST_EXTENSIONS_SRCDIR) \
$(BOOT_DIR)/bin/java $(JACOCO_AGENT_SWITCH) -Xbootclasspath:$(RUNTIME) CommandLine $$class_names ; \
for file in $(EMMA_MODIFIED_FILES) ; do \
mv $(NETX_UNIT_TEST_DIR)/$$file $(NETX_UNIT_TEST_DIR)/"$$file""$(EMMA_SUFFIX)" ; \
@@ -1171,6 +1172,7 @@ if WITH_EMMA
-cp $(BOOT_DIR)/jre/lib/resources.jar \
-cp $(RHINO_RUNTIME) \
-cp . \
+ -cp $(TEST_EXTENSIONS_SRCDIR) \
-cp $(TEST_EXTENSIONS_TESTS_DIR) \
-ix "-org.junit.*" \
-ix "-junit.*" \
@@ -1274,7 +1276,7 @@ if WITH_JACOCO
done ; \
cd $(TEST_EXTENSIONS_DIR) ; \
class_names=`cat $(REPRODUCERS_CLASS_NAMES)` ; \
- CLASSPATH=$(NETX_DIR)/lib/classes.jar:$(JUNIT_JAR):$(JUNIT_RUNNER_JAR):.:$(TEST_EXTENSIONS_DIR):$(JACOCO_CLASSPATH):$(TEST_EXTENSIONS_TESTS_DIR) \
+ CLASSPATH=$(NETX_DIR)/lib/classes.jar:$(JUNIT_JAR):$(JUNIT_RUNNER_JAR):.:$(TEST_EXTENSIONS_DIR):$(JACOCO_CLASSPATH):$(TEST_EXTENSIONS_TESTS_DIR):$(TEST_EXTENSIONS_SRCDIR) \
$(BOOT_DIR)/bin/java $(JACOCO_AGENT_SWITCH) $(REPRODUCERS_DPARAMETERS) \
-Xbootclasspath:$(RUNTIME) CommandLine $$class_names ; \
if [ -f $(JACOCO_JAVAWS_RESULTS) ] ; then \
diff --git a/tests/netx/unit/net/sourceforge/jnlp/awt/imagesearch/ComponentFinderTest.java b/tests/netx/unit/net/sourceforge/jnlp/awt/imagesearch/ComponentFinderTest.java
new file mode 100644
index 0000000..b813abf
--- /dev/null
+++ b/tests/netx/unit/net/sourceforge/jnlp/awt/imagesearch/ComponentFinderTest.java
@@ -0,0 +1,56 @@
+/* ComponentFinderTest.java
+Copyright (C) 2013 Red Hat, Inc.
+
+This file is part of IcedTea.
+
+IcedTea is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License as published by
+the Free Software Foundation, version 2.
+
+IcedTea is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with IcedTea; see the file COPYING. If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version.
+ */
+package net.sourceforge.jnlp.awt.imagesearch;
+
+import java.awt.image.BufferedImage;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * This class is a part of AWTFramework, contains component finding
+ * by searching for icons.
+ *
+ */
+public class ComponentFinderTest {
+
+ @Test
+ public void initialiseDefaultIcon() {
+ BufferedImage icon = ComponentFinder.defaultIcon;
+ Assert.assertNotNull("The default icon marker.png was not initialized.", icon);
+ }
+}
diff --git a/tests/reproducers/simple/AWTCommonResourcesOnly/resources/marker.png b/tests/reproducers/simple/AWTCommonResourcesOnly/resources/marker.png
new file mode 100644
index 0000000..4392bea
--- /dev/null
+++ b/tests/reproducers/simple/AWTCommonResourcesOnly/resources/marker.png
Binary files differ
diff --git a/tests/reproducers/simple/JavawsAWTRobotUsageSample/resources/javaws-awtrobot-usage-sample.jnlp b/tests/reproducers/simple/JavawsAWTRobotUsageSample/resources/javaws-awtrobot-usage-sample.jnlp
new file mode 100644
index 0000000..beca571
--- /dev/null
+++ b/tests/reproducers/simple/JavawsAWTRobotUsageSample/resources/javaws-awtrobot-usage-sample.jnlp
@@ -0,0 +1,57 @@
+<!--
+
+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.
+
+ -->
+<?xml version="1.0" encoding="UTF-8"?>
+<jnlp spec="1.0+" codebase="." href="javaws-awtrobot-usage-sample.jnlp">
+ <information>
+ <title>AWTRobot usage sample</title>
+ <vendor>IcedTea</vendor>
+ <homepage href="http://icedtea.classpath.org/wiki/IcedTea-Web#Testing_IcedTea-Web"/>
+ <description>AWTRobot usage sample</description>
+ </information>
+ <resources>
+ <!-- Application Resources -->
+ <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
+ <jar href="JavawsAWTRobotUsageSample.jar" main="true" />
+ </resources>
+ <applet-desc
+ name="AWTRobot usage sample"
+ main-class="JavawsAWTRobotUsageSample"
+ width="400"
+ height="400">
+ </applet-desc>
+</jnlp>
diff --git a/tests/reproducers/simple/JavawsAWTRobotUsageSample/srcs/JavawsAWTRobotUsageSample.java b/tests/reproducers/simple/JavawsAWTRobotUsageSample/srcs/JavawsAWTRobotUsageSample.java
new file mode 100644
index 0000000..7ffe392
--- /dev/null
+++ b/tests/reproducers/simple/JavawsAWTRobotUsageSample/srcs/JavawsAWTRobotUsageSample.java
@@ -0,0 +1,176 @@
+/* JavawsAWTRobotUsageSample.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, version 2.
+
+IcedTea is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with IcedTea; see the file COPYING. If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version.
+ */
+
+import java.applet.Applet;
+import java.awt.Graphics;
+import java.awt.Color;
+import java.awt.Image;
+import java.awt.Panel;
+import java.awt.Button;
+import java.awt.Dimension;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+
+public class JavawsAWTRobotUsageSample extends Applet {
+
+ private static final String initStr = "JavawsAWTRobotUsageSample is ready for awt tests!";
+ public static final String iconFile = "marker.png";
+
+ public static final Color APPLET_COLOR = new Color(230, 230, 250); // lavender
+ public static final Color BUTTON_COLOR1 = new Color(32, 178, 170); // light sea green
+
+ public Image img;
+ public Panel panel;
+
+ public void init(){
+ img = getImage(getCodeBase(), iconFile);
+
+ createGUI();
+
+ writeAppletInitialized();
+ }
+
+ //this method should be called by the extending applet
+ //when the whole gui is ready
+ public void writeAppletInitialized(){
+ System.out.println(initStr);
+ }
+
+ //paint the icon in upper left corner
+ @Override public void paint(Graphics g){
+ int width = 32;
+ int height = 32;
+ int x = 0;
+ int y = 0;
+ g.drawImage(img, x, y, width, height, this);
+ super.paint(g);
+ }
+
+ private Button createButton(String label, Color color) {
+ Button b = new Button(label);
+ b.setBackground(color);
+ b.setPreferredSize(new Dimension(100, 50));
+ return b;
+ }
+
+ // sets background of the applet and adds the panel with one button
+ private void createGUI() {
+ setBackground(APPLET_COLOR);
+
+ panel = new Panel();
+ panel.setBounds(33,33,267,267);
+
+ Button b = createButton("", BUTTON_COLOR1);
+
+ b.addMouseMotionListener(new MouseMotionListener() {
+ public void mouseDragged(MouseEvent e) {
+ System.out.println("mouseDragged");
+ }
+
+ public void mouseMoved(MouseEvent e) {
+ System.out.println("mouseMoved");
+ }
+ });
+
+ b.addMouseListener(new MouseListener() {
+
+ public void mouseClicked(MouseEvent e) {
+ // figure out which mouse button is pressed
+ switch (e.getButton()) {
+ case MouseEvent.BUTTON1:
+ System.out.println("mouseClickedButton1");
+ break;
+ case MouseEvent.BUTTON2:
+ System.out.println("mouseClickedButton2");
+ break;
+ case MouseEvent.BUTTON3:
+ System.out.println("mouseClickedButton3");
+ break;
+ default:
+ break;
+ }
+ }
+
+ public void mouseEntered(MouseEvent e) {
+ System.out.println("mouseEntered");
+ }
+
+ public void mouseExited(MouseEvent e) {
+ System.out.println("mouseExited");
+ }
+
+ public void mousePressed(MouseEvent e) {
+ // figure out which mouse button is pressed
+ switch (e.getButton()) {
+ case MouseEvent.BUTTON1:
+ System.out.println("mousePressedButton1");
+ break;
+ case MouseEvent.BUTTON2:
+ System.out.println("mousePressedButton2");
+ break;
+ case MouseEvent.BUTTON3:
+ System.out.println("mousePressedButton3");
+ break;
+ default:
+ break;
+ }
+ }
+
+ public void mouseReleased(MouseEvent e) {
+ // figure out which mouse button was pressed
+ switch (e.getButton()) {
+ case MouseEvent.BUTTON1:
+ System.out.println("mouseReleasedButton1");
+ break;
+ case MouseEvent.BUTTON2:
+ System.out.println("mouseReleasedButton2");
+ break;
+ case MouseEvent.BUTTON3:
+ System.out.println("mouseReleasedButton3");
+ break;
+ default:
+ break;
+ }
+ }
+ });
+
+ panel.add(b);
+
+ this.add(panel);
+ }
+}
diff --git a/tests/reproducers/simple/JavawsAWTRobotUsageSample/testcases/JavawsAWTRobotUsageSampleTest.java b/tests/reproducers/simple/JavawsAWTRobotUsageSample/testcases/JavawsAWTRobotUsageSampleTest.java
new file mode 100644
index 0000000..1d5c764
--- /dev/null
+++ b/tests/reproducers/simple/JavawsAWTRobotUsageSample/testcases/JavawsAWTRobotUsageSampleTest.java
@@ -0,0 +1,248 @@
+/* JavawsAWTRobotUsageSampleTest.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, version 2.
+
+IcedTea is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with IcedTea; see the file COPYING. If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version.
+ */
+
+import java.awt.Color;
+import java.awt.event.InputEvent;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+
+import net.sourceforge.jnlp.ProcessResult;
+import net.sourceforge.jnlp.ServerAccess;
+import net.sourceforge.jnlp.annotations.NeedsDisplay;
+import net.sourceforge.jnlp.awt.AWTFrameworkException;
+import net.sourceforge.jnlp.awt.AWTHelper;
+import net.sourceforge.jnlp.awt.imagesearch.ComponentNotFoundException;
+import net.sourceforge.jnlp.browsertesting.BrowserTest;
+import net.sourceforge.jnlp.closinglisteners.Rule;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class JavawsAWTRobotUsageSampleTest extends BrowserTest {
+
+ private final String initStr = "JavawsAWTRobotUsageSample is ready for awt tests!";
+
+ private static final Color APPLET_COLOR = new Color(230, 230, 250); // lavender
+ private static final Color BUTTON_COLOR1 = new Color(32, 178, 170); // light sea green
+
+ private abstract class AWTHelperImpl extends AWTHelper{
+
+ public AWTHelperImpl() {
+ super(initStr, 400, 400);
+
+ this.setAppletColor(APPLET_COLOR);
+ }
+
+ }
+
+ private class AWTHelperImpl_EnterExit extends AWTHelperImpl {
+
+ @Override
+ public void run() {
+ // move mouse into the button area and out
+ try {
+ moveToMiddleOfColoredRectangle(BUTTON_COLOR1);
+ moveOutsideColoredRectangle(BUTTON_COLOR1);
+ } catch (ComponentNotFoundException e) {
+ Assert.fail("Button not found: "+e.getMessage());
+ } catch (AWTFrameworkException e2){
+ Assert.fail("AWTFrameworkException: "+e2.getMessage());
+ }
+ }
+ }
+
+ private class AWTHelperImpl_MouseClick1 extends AWTHelperImpl{
+
+ @Override
+ public void run() {
+ // click in the middle of the button
+
+ try {
+ clickOnColoredRectangle(BUTTON_COLOR1, InputEvent.BUTTON1_MASK);
+ } catch (ComponentNotFoundException e) {
+ Assert.fail("Button not found: "+e.getMessage());
+ } catch (AWTFrameworkException e2){
+ Assert.fail("AWTFrameworkException: "+e2.getMessage());
+ }
+ }
+ }
+
+ private class AWTHelperImpl_MouseClick2 extends AWTHelperImpl{
+ @Override
+ public void run() {
+ // move mouse in the middle of the button and click 2nd
+ // button
+ try {
+ clickOnColoredRectangle(BUTTON_COLOR1, InputEvent.BUTTON2_MASK);
+ } catch (ComponentNotFoundException e) {
+ Assert.fail("Button not found: "+e.getMessage());
+ } catch (AWTFrameworkException e2){
+ Assert.fail("AWTFrameworkException: "+e2.getMessage());
+ }
+ }
+ }
+
+ private class AWTHelperImpl_MouseClick3 extends AWTHelperImpl{
+ @Override
+ public void run() {
+ // move mouse in the middle of the button and click 3rd
+ // button
+ try {
+ clickOnColoredRectangle(BUTTON_COLOR1, InputEvent.BUTTON3_MASK);
+ } catch (ComponentNotFoundException e) {
+ Assert.fail("Button not found: "+e.getMessage());
+ } catch (AWTFrameworkException e2){
+ Assert.fail("AWTFrameworkException: "+e2.getMessage());
+ }
+ }
+ }
+
+ private class AWTHelperImpl_MouseDrag extends AWTHelperImpl{
+ @Override
+ public void run() {
+ // move into the rectangle, press 1st button, drag out
+ try {
+ dragFromColoredRectangle(BUTTON_COLOR1);
+ } catch (ComponentNotFoundException e) {
+ Assert.fail("Button not found: "+e.getMessage());
+ } catch (AWTFrameworkException e2){
+ Assert.fail("AWTFrameworkException: "+e2.getMessage());
+ }
+ }
+ }
+
+ private class AWTHelperImpl_MouseMove extends AWTHelperImpl{
+ @Override
+ public void run() {
+ clickInTheMiddleOfApplet();
+ try {
+ moveInsideColoredRectangle(BUTTON_COLOR1);
+ } catch (ComponentNotFoundException e) {
+ Assert.fail("Button not found: "+e.getMessage());
+ } catch (AWTFrameworkException e2){
+ Assert.fail("AWTFrameworkException: "+e2.getMessage());
+ }
+ }
+ }
+
+
+ private void evaluateStdoutContents(ProcessResult pr, AWTHelper helper) {
+
+ // Assert that the applet was initialized.
+ Rule i = helper.getInitStrAsRule();
+ Assert.assertTrue(i.toPassingString(), i.evaluate(initStr));
+
+ // Assert there are all the test messages from applet
+ for (Rule r : helper.getRules() ) {
+ Assert.assertTrue(r.toPassingString(), r.evaluate(pr.stdout));
+ }
+
+ }
+
+
+ private void appletAWTMouseTest(String url, AWTHelper helper)
+ throws Exception {
+
+ String strURL = "/" + url;
+
+ try {
+ ServerAccess.PROCESS_TIMEOUT = 40 * 1000;// ms
+ ProcessResult pr = server.executeJavaws(strURL, helper, helper);
+ evaluateStdoutContents(pr, helper);
+ } finally {
+ ServerAccess.PROCESS_TIMEOUT = 20 * 1000;// ms
+ }
+ }
+
+ @Test
+ @NeedsDisplay
+ public void AppletAWTMouse_EnterAndExit_Test() throws Exception {
+ // display the page, activate applet, move over the button
+ AWTHelper helper = new AWTHelperImpl_EnterExit();
+ helper.addClosingRulesFromStringArray(new String[] { "mouseEntered", "mouseExited"});
+ appletAWTMouseTest("javaws-awtrobot-usage-sample.jnlp", helper);
+ }
+
+ @Test
+ @NeedsDisplay
+ public void AppletAWTMouse_ClickButton1_Test() throws Exception {
+ // display the page, activate applet, click on button
+ AWTHelper helper = new AWTHelperImpl_MouseClick1();
+ helper.addClosingRulesFromStringArray(new String[] { "mousePressedButton1", "mouseReleasedButton1", "mouseClickedButton1" });
+ appletAWTMouseTest("javaws-awtrobot-usage-sample.jnlp", helper);
+ }
+
+ @Test
+ @NeedsDisplay
+ public void AppletAWTMouse_ClickButton2_Test() throws Exception {
+ // display the page, activate applet, click on button
+ AWTHelper helper = new AWTHelperImpl_MouseClick2();
+ helper.addClosingRulesFromStringArray(new String[] { "mousePressedButton2", "mouseReleasedButton2", "mouseClickedButton2" });
+ appletAWTMouseTest("javaws-awtrobot-usage-sample.jnlp", helper);
+ }
+
+ @Test
+ @NeedsDisplay
+ public void AppletAWTMouse_ClickButton3_Test() throws Exception {
+ // display the page, activate applet, click on button
+ AWTHelper helper = new AWTHelperImpl_MouseClick3();
+ helper.addClosingRulesFromStringArray(new String[] { "mousePressedButton3", "mouseReleasedButton3", "mouseClickedButton3" });
+ appletAWTMouseTest("javaws-awtrobot-usage-sample.jnlp", helper);
+ }
+
+ @Test
+ @NeedsDisplay
+ public void AppletAWTMouse_Drag_Test() throws Exception {
+
+ // display the page, activate applet, click on button
+ AWTHelper helper = new AWTHelperImpl_MouseDrag();
+ helper.addClosingRulesFromStringArray(new String[] { "mouseDragged" });
+ appletAWTMouseTest("javaws-awtrobot-usage-sample.jnlp", helper);
+ }
+
+ @Test
+ @NeedsDisplay
+ public void AppletAWTMouse_Move_Test() throws Exception {
+ // display the page, activate applet, click on button
+ AWTHelper helper = new AWTHelperImpl_MouseMove();
+ helper.addClosingRulesFromStringArray(new String[] { "mouseMoved" });
+ appletAWTMouseTest("javaws-awtrobot-usage-sample.jnlp", helper);
+ }
+}
diff --git a/tests/test-extensions-tests/net/sourceforge/jnlp/awt/imagesearch/ComponentFinderTest.java b/tests/test-extensions-tests/net/sourceforge/jnlp/awt/imagesearch/ComponentFinderTest.java
new file mode 100644
index 0000000..b813abf
--- /dev/null
+++ b/tests/test-extensions-tests/net/sourceforge/jnlp/awt/imagesearch/ComponentFinderTest.java
@@ -0,0 +1,56 @@
+/* ComponentFinderTest.java
+Copyright (C) 2013 Red Hat, Inc.
+
+This file is part of IcedTea.
+
+IcedTea is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License as published by
+the Free Software Foundation, version 2.
+
+IcedTea is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with IcedTea; see the file COPYING. If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version.
+ */
+package net.sourceforge.jnlp.awt.imagesearch;
+
+import java.awt.image.BufferedImage;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * This class is a part of AWTFramework, contains component finding
+ * by searching for icons.
+ *
+ */
+public class ComponentFinderTest {
+
+ @Test
+ public void initialiseDefaultIcon() {
+ BufferedImage icon = ComponentFinder.defaultIcon;
+ Assert.assertNotNull("The default icon marker.png was not initialized.", icon);
+ }
+}
diff --git a/tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java b/tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java
index faced3a..e33d35c 100644
--- a/tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java
+++ b/tests/test-extensions/net/sourceforge/jnlp/awt/AWTHelper.java
@@ -164,13 +164,9 @@ public abstract class AWTHelper extends RulesFolowingClosingListener implements
String test_server_dir_path = System.getProperty("test.server.dir");
- try {
- this.marker = ImageIO.read(new File(test_server_dir_path + "/marker.png"));
- this.markerPosition = new Point(0,0);
- this.markerGiven = true;
- } catch (IOException e) {
- throw new RuntimeException("AWTHelper could not read marker.png.",e);
- }
+ this.marker = ComponentFinder.defaultIcon;
+ this.markerPosition = new Point(0,0);
+ this.markerGiven = true;
this.appletWidth = appletWidth;
this.appletHeight = appletHeight;
diff --git a/tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/ComponentFinder.java b/tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/ComponentFinder.java
index 5d3a25e..95e0e37 100644
--- a/tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/ComponentFinder.java
+++ b/tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/ComponentFinder.java
@@ -42,8 +42,19 @@ import java.awt.Color;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
+import java.io.IOException;
+import javax.imageio.ImageIO;
public class ComponentFinder {
+ public static final BufferedImage defaultIcon;
+
+ static{
+ try {
+ defaultIcon = ImageIO.read(ComponentFinder.class.getClassLoader().getResource("net/sourceforge/jnlp/awt/imagesearch/marker.png"));
+ } catch (IOException e) {
+ throw new RuntimeException("ComponentFinder - problem initializing defaultIcon",e);
+ }
+ }
/**
* method findColoredRectangle determines coordinates of a rectangle colored
diff --git a/tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/marker.png b/tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/marker.png
new file mode 100644
index 0000000..4392bea
--- /dev/null
+++ b/tests/test-extensions/net/sourceforge/jnlp/awt/imagesearch/marker.png
Binary files differ