changeset 722:d1b601fe784c

change to the Makefile.am, all icons from reproducers
author Jana Fabrikova <jfabriko@redhat.com>
date Thu, 02 May 2013 17:28:46 +0200
parents c90e2e706130
children 2131a590d645
files ChangeLog Makefile.am netx-dist-tests-whitelist tests/reproducers/simple/JavawsAWTRobotFindsButton/resources/javaws-awtrobot-finds-button.jnlp tests/reproducers/simple/JavawsAWTRobotFindsButton/srcs/JavawsAWTRobotFindsButton.java tests/reproducers/simple/JavawsAWTRobotFindsButton/testcases/JavawsAWTRobotFindsButtonTest.java tests/reproducers/simple/JavawsAWTRobotFindsButton/testcases/buttonA.png tests/reproducers/simple/JavawsAWTRobotUsageSample/testcases/JavawsAWTRobotUsageSampleTest.java
diffstat 8 files changed, 393 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu May 02 17:16:18 2013 +0200
+++ b/ChangeLog	Thu May 02 17:28:46 2013 +0200
@@ -1,3 +1,22 @@
+2013-05-02  Jana Fabrikova  <jfabriko@redhat.com>
+
+	* Makefile.am:
+	Change in processing the goal
+	(stamps/compile-reproducers-testcases.stamp)
+	All .java files from reproducers testcases directory are
+	compiled, all non-java files are copied into the
+	TEST_EXTENSIONS_TESTS_DIR, i.e.
+	tests.build/test-extensions-tests directory
+	* tests/reproducers/simple/JavawsAWTRobotFindsButton/resources/javaws-awtrobot-finds-button.jnlp:
+	jnlp file for displaying the applet
+	* tests/reproducers/simple/JavawsAWTRobotFindsButton/srcs/JavawsAWTRobotFindsButton.java:
+	the applet used in the reproducer
+	* tests/reproducers/simple/JavawsAWTRobotFindsButton/testcases/JavawsAWTRobotFindsButtonTest.java:
+	adding 2 tests: that an icon is loaded, and that the button is
+	identified from the given icon and clicked by awt robot
+	* tests/reproducers/simple/JavawsAWTRobotFindsButton/testcases/buttonA.png:
+	the icon of the wanted button
+
 2013-04-26  Jiri Vanek  <jvanek@redhat.com>
             Jacob Wisor  <gitne@excite.co.jp>
 
--- a/Makefile.am	Thu May 02 17:16:18 2013 +0200
+++ b/Makefile.am	Thu May 02 17:28:46 2013 +0200
@@ -788,7 +788,15 @@
 	    $(BOOT_DIR)/bin/javac $(IT_JAVACFLAGS) \
 	      -d $(TEST_EXTENSIONS_TESTS_DIR) \
 	      -classpath $(JUNIT_JAR):$(NETX_DIR)/lib/classes.jar:$(TEST_EXTENSIONS_DIR) \
-	    "$(REPRODUCERS_TESTS_SRCDIR)/$$which/$$dir/testcases/"* ; \
+	    "$(REPRODUCERS_TESTS_SRCDIR)/$$which/$$dir/testcases/"*.java ; \
+	    if [ -d "$(REPRODUCERS_TESTS_SRCDIR)/$$which/$$dir/testcases" ]; then \
+	        pushd "$(REPRODUCERS_TESTS_SRCDIR)/$$which/$$dir/testcases" ; \
+	        NONJAVA_RESOURCES=`ls | grep -v ".*\\.java$$"` ; \
+	        if [ -n "$$NONJAVA_RESOURCES" ]; then \
+	            cp $$NONJAVA_RESOURCES $(TEST_EXTENSIONS_TESTS_DIR)/ ; \
+	        fi ; \
+	        popd ; \
+	    fi ; \
 	  done ; \
 	done ; \
 	mkdir -p stamps && \
--- a/netx-dist-tests-whitelist	Thu May 02 17:16:18 2013 +0200
+++ b/netx-dist-tests-whitelist	Thu May 02 17:28:46 2013 +0200
@@ -1,1 +1,1 @@
-.*
+.*JavawsAWTRobot.*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/simple/JavawsAWTRobotFindsButton/resources/javaws-awtrobot-finds-button.jnlp	Thu May 02 17:28:46 2013 +0200
@@ -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-finds-button.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="JavawsAWTRobotFindsButton.jar" main="true" />
+    </resources>
+    <applet-desc 
+         name="AWTRobot usage sample"
+         main-class="JavawsAWTRobotFindsButton"
+         width="400"
+         height="400">
+     </applet-desc>
+</jnlp>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/simple/JavawsAWTRobotFindsButton/srcs/JavawsAWTRobotFindsButton.java	Thu May 02 17:28:46 2013 +0200
@@ -0,0 +1,166 @@
+/* JavawsAWTRobotFindsButton.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;
+
+public class JavawsAWTRobotFindsButton extends Applet {
+
+    private static final String initStr = "JavawsAWTRobotFindsButton 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 2 buttons
+    private void createGUI() {
+        setBackground(APPLET_COLOR);
+
+        panel = new Panel();
+        panel.setBounds(33,33,267,267);
+
+        Button bA = createButton("Button A", BUTTON_COLOR1);
+
+
+        bA.addMouseListener(new MouseListener() {
+
+            public void mouseClicked(MouseEvent e) {
+                System.out.println("Mouse clicked button A.");
+            }
+
+            @Override
+            public void mouseEntered(MouseEvent arg0) {
+                
+            }
+
+            @Override
+            public void mouseExited(MouseEvent arg0) {
+                
+            }
+
+            @Override
+            public void mousePressed(MouseEvent arg0) {
+            
+            }
+
+            @Override
+            public void mouseReleased(MouseEvent arg0) {
+            
+            }
+            
+        });
+
+        panel.add(bA);
+
+
+        Button bB = createButton("Button B", BUTTON_COLOR1);
+
+
+        bB.addMouseListener(new MouseListener() {
+
+            public void mouseClicked(MouseEvent e) {
+                System.out.println("Mouse clicked button B.");
+            }
+
+            @Override
+            public void mouseEntered(MouseEvent e) {
+                
+            }
+
+            @Override
+            public void mouseExited(MouseEvent e) {
+                
+            }
+
+            @Override
+            public void mousePressed(MouseEvent e) {
+                
+            }
+
+            @Override
+            public void mouseReleased(MouseEvent e) {
+                
+            }
+        });
+
+        panel.add(bB);
+
+        this.add(panel);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/reproducers/simple/JavawsAWTRobotFindsButton/testcases/JavawsAWTRobotFindsButtonTest.java	Thu May 02 17:28:46 2013 +0200
@@ -0,0 +1,138 @@
+/* JavawsAWTRobotFindsButtonTest.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.ComponentFinder;
+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 JavawsAWTRobotFindsButtonTest {
+
+    public static final ServerAccess server = new ServerAccess();
+
+    private final String initStr = "JavawsAWTRobotFindsButton 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 static final BufferedImage buttonIcon;
+
+    static{
+        try {
+            buttonIcon = ImageIO.read(JavawsAWTRobotFindsButtonTest.class.getClassLoader().getResource("buttonA.png"));
+        } catch (IOException e) {
+            throw new RuntimeException("Problem initializing buttonIcon",e);
+        }
+    }
+    
+    private class AWTHelperImpl_ClickButtonIcon extends AWTHelper{
+        
+        public AWTHelperImpl_ClickButtonIcon() {
+            super(initStr, 400, 400);
+            
+            this.setAppletColor(APPLET_COLOR);
+        }
+        
+        @Override
+        public void run() {
+            // move mouse into the button area and out
+            try {
+                clickOnIconExact(buttonIcon, InputEvent.BUTTON1_MASK);
+            } catch (ComponentNotFoundException e) {
+                Assert.fail("Button icon not found: "+e.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 findAndClickButtonByIcon_Test() throws Exception {
+        // display the page, activate applet, click on button
+        AWTHelper helper = new AWTHelperImpl_ClickButtonIcon();
+        helper.addClosingRulesFromStringArray(new String[] { "Mouse clicked button A." });
+        appletAWTMouseTest("javaws-awtrobot-finds-button.jnlp", helper);
+    }
+
+    @Test
+    public void iconFileLoaded_Test() throws IOException {
+        Assert.assertNotNull("buttonIcon should not be null", buttonIcon);
+    }
+
+}
Binary file tests/reproducers/simple/JavawsAWTRobotFindsButton/testcases/buttonA.png has changed
--- a/tests/reproducers/simple/JavawsAWTRobotUsageSample/testcases/JavawsAWTRobotUsageSampleTest.java	Thu May 02 17:16:18 2013 +0200
+++ b/tests/reproducers/simple/JavawsAWTRobotUsageSample/testcases/JavawsAWTRobotUsageSampleTest.java	Thu May 02 17:28:46 2013 +0200
@@ -55,10 +55,11 @@
 import org.junit.Assert;
 import org.junit.Test;
 
-public class JavawsAWTRobotUsageSampleTest extends BrowserTest {
+public class JavawsAWTRobotUsageSampleTest {
+
+    public static final ServerAccess server = new ServerAccess();
 
     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