< prev index next >

test/jdk/java/awt/event/MouseEvent/RobotLWTest/RobotLWTest.java

Print this page




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25   test

  26   @bug 4350402
  27   @summary Tests that mouse behavior on LW component


  28 */
  29 
  30 /**
  31  * RobotLWTest.java
  32  *
  33  * summary:
  34  */
  35 
  36 import java.applet.Applet;
  37 import java.awt.*;
  38 import java.awt.event.*;
  39 import test.java.awt.regtesthelpers.Util;
  40 
  41 public class RobotLWTest extends Applet
  42 {
  43     //Declare things used in the test, like buttons and labels here
  44 
  45     public void init()
  46     {
  47     }//End  init()

  48 
  49     public void start ()
  50     {
  51         Frame frame = new Frame();
  52         MyLWContainer c = new MyLWContainer();
  53         MyLWComponent b = new MyLWComponent();
  54         c.add(b);
  55         frame.add(c);
  56         frame.setSize(400,400);

  57         frame.setVisible(true);
  58 
  59         try {
  60             Robot robot = new Robot();
  61             robot.setAutoWaitForIdle(true);
  62             robot.setAutoDelay(100);
  63             robot.waitForIdle();
  64 
  65             Util.waitForIdle(robot);
  66 
  67             Point pt = frame.getLocationOnScreen();
  68             Point pt1 = b.getLocationOnScreen();
  69 
  70             //Testing capture with multiple buttons
  71             robot.mouseMove(pt1.x + b.getWidth()/2, pt1.y + b.getHeight()/2);
  72             robot.mousePress(InputEvent.BUTTON1_MASK);
  73             robot.mousePress(InputEvent.BUTTON2_MASK);
  74             robot.mouseMove(pt.x + frame.getWidth()+10, pt.y + frame.getHeight()+10);
  75             robot.mouseRelease(InputEvent.BUTTON2_MASK);
  76             Util.waitForIdle(robot);




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25   @test
  26   @key headful
  27   @bug 4350402
  28   @summary Tests that mouse behavior on LW component
  29   @compile ../../../regtesthelpers/Util.java
  30   @run main RobotLWTest
  31 */
  32 







  33 import java.awt.*;
  34 import java.awt.event.*;
  35 import test.java.awt.regtesthelpers.Util;
  36 
  37 public class RobotLWTest {


  38 
  39     public static void main(String[] args) {
  40         RobotLWTest app = new RobotLWTest();
  41         app.start();
  42     }
  43 
  44     public void start ()
  45     {
  46         Frame frame = new Frame();
  47         MyLWContainer c = new MyLWContainer();
  48         MyLWComponent b = new MyLWComponent();
  49         c.add(b);
  50         frame.add(c);
  51         frame.setSize(400,400);
  52         frame.setLocationRelativeTo(null);
  53         frame.setVisible(true);
  54 
  55         try {
  56             Robot robot = new Robot();
  57             robot.setAutoWaitForIdle(true);
  58             robot.setAutoDelay(100);
  59             robot.waitForIdle();
  60 
  61             Util.waitForIdle(robot);
  62 
  63             Point pt = frame.getLocationOnScreen();
  64             Point pt1 = b.getLocationOnScreen();
  65 
  66             //Testing capture with multiple buttons
  67             robot.mouseMove(pt1.x + b.getWidth()/2, pt1.y + b.getHeight()/2);
  68             robot.mousePress(InputEvent.BUTTON1_MASK);
  69             robot.mousePress(InputEvent.BUTTON2_MASK);
  70             robot.mouseMove(pt.x + frame.getWidth()+10, pt.y + frame.getHeight()+10);
  71             robot.mouseRelease(InputEvent.BUTTON2_MASK);
  72             Util.waitForIdle(robot);


< prev index next >