test/java/awt/Mixing/AWT_Mixing/ViewportOverlapping.java

Print this page




  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 
  25 import java.awt.BorderLayout;
  26 import java.awt.Dimension;
  27 import java.awt.GridLayout;
  28 import java.awt.Point;
  29 import java.awt.Robot;
  30 import java.awt.event.InputEvent;
  31 import java.awt.event.MouseAdapter;
  32 import java.awt.event.MouseEvent;
  33 import javax.swing.BorderFactory;
  34 import javax.swing.JButton;
  35 import javax.swing.JComponent;
  36 import javax.swing.JFrame;
  37 import javax.swing.JPanel;
  38 import javax.swing.JScrollPane;
  39 import javax.swing.SwingUtilities;

  40 
  41 /**
  42  * AWT/Swing overlapping test for viewport
  43  * <p>This test verify if AWT components are drawn correctly being partially shown through viewport
  44  * <p>See <a href="http://monaco.sfbay.sun.com/detail.jsf?cr=6778882">CR6778882</a> for details
  45  * <p>See base class for test info.
  46  */
  47 /*
  48 @test
  49 @bug 6778882
  50 @summary Viewport overlapping test for each AWT component
  51 @author sergey.grinev@oracle.com: area=awt.mixing


  52 @run main ViewportOverlapping
  53  */
  54 public class ViewportOverlapping extends OverlappingTestBase {
  55 
  56     private volatile int frameClicked;
  57     private Point hLoc;
  58     private Point vLoc;
  59     private Point testLoc;
  60     private Point resizeLoc;
  61 
  62     private JFrame f;
  63     private JPanel p;
  64     private JButton b;
  65     private JScrollPane scrollPane;
  66 
  67     protected void prepareControls() {
  68         p = new JPanel(new GridLayout(0, 1));
  69         propagateAWTControls(p);
  70         b = new JButton("Space extender");
  71         p.add(b);


  99 
 100                     b.requestFocus();
 101 
 102                     scrollPane.getHorizontalScrollBar().setUnitIncrement(40);
 103                     scrollPane.getVerticalScrollBar().setUnitIncrement(40);
 104 
 105                     hLoc = scrollPane.getHorizontalScrollBar().getLocationOnScreen();
 106                     hLoc.translate(scrollPane.getHorizontalScrollBar().getWidth() - 3, 3);
 107                     vLoc = scrollPane.getVerticalScrollBar().getLocationOnScreen();
 108                     vLoc.translate(3, scrollPane.getVerticalScrollBar().getHeight() - 3);
 109 
 110                     testLoc = p.getLocationOnScreen();
 111                     testLoc.translate(-3, -3);
 112 
 113                     resizeLoc = f.getLocationOnScreen();
 114                     resizeLoc.translate(f.getWidth() - 1, f.getHeight() - 1);
 115                 }
 116             });
 117         } catch (Exception e) {
 118             e.printStackTrace();
 119             System.exit(1);
 120         }
 121         // run robot
 122         Robot robot = Util.createRobot();
 123         robot.setAutoDelay(ROBOT_DELAY);
 124 
 125         robot.mouseMove(hLoc.x, hLoc.y);
 126         robot.mousePress(InputEvent.BUTTON1_MASK);
 127         robot.mouseRelease(InputEvent.BUTTON1_MASK);
 128         Util.waitForIdle(robot);
 129 
 130         robot.mouseMove(vLoc.x, vLoc.y);
 131         robot.mousePress(InputEvent.BUTTON1_MASK);
 132         robot.mouseRelease(InputEvent.BUTTON1_MASK);
 133         Util.waitForIdle(robot);
 134 
 135         clickAndBlink(robot, testLoc, false);
 136         robot.mouseMove(resizeLoc.x, resizeLoc.y);
 137         robot.mousePress(InputEvent.BUTTON1_MASK);
 138         robot.mouseMove(resizeLoc.x + 5, resizeLoc.y + 5);
 139         robot.mouseRelease(InputEvent.BUTTON1_MASK);


  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 
  25 import java.awt.BorderLayout;
  26 import java.awt.Dimension;
  27 import java.awt.GridLayout;
  28 import java.awt.Point;
  29 import java.awt.Robot;
  30 import java.awt.event.InputEvent;
  31 import java.awt.event.MouseAdapter;
  32 import java.awt.event.MouseEvent;
  33 import javax.swing.BorderFactory;
  34 import javax.swing.JButton;
  35 import javax.swing.JComponent;
  36 import javax.swing.JFrame;
  37 import javax.swing.JPanel;
  38 import javax.swing.JScrollPane;
  39 import javax.swing.SwingUtilities;
  40 import test.java.awt.regtesthelpers.Util;
  41 
  42 /**
  43  * AWT/Swing overlapping test for viewport
  44  * <p>This test verify if AWT components are drawn correctly being partially shown through viewport
  45  * <p>See <a href="http://monaco.sfbay.sun.com/detail.jsf?cr=6778882">CR6778882</a> for details
  46  * <p>See base class for test info.
  47  */
  48 /*
  49 @test
  50 @bug 6778882
  51 @summary Viewport overlapping test for each AWT component
  52 @author sergey.grinev@oracle.com: area=awt.mixing
  53 @library ../../regtesthelpers
  54 @build Util
  55 @run main ViewportOverlapping
  56  */
  57 public class ViewportOverlapping extends OverlappingTestBase {
  58 
  59     private volatile int frameClicked;
  60     private Point hLoc;
  61     private Point vLoc;
  62     private Point testLoc;
  63     private Point resizeLoc;
  64 
  65     private JFrame f;
  66     private JPanel p;
  67     private JButton b;
  68     private JScrollPane scrollPane;
  69 
  70     protected void prepareControls() {
  71         p = new JPanel(new GridLayout(0, 1));
  72         propagateAWTControls(p);
  73         b = new JButton("Space extender");
  74         p.add(b);


 102 
 103                     b.requestFocus();
 104 
 105                     scrollPane.getHorizontalScrollBar().setUnitIncrement(40);
 106                     scrollPane.getVerticalScrollBar().setUnitIncrement(40);
 107 
 108                     hLoc = scrollPane.getHorizontalScrollBar().getLocationOnScreen();
 109                     hLoc.translate(scrollPane.getHorizontalScrollBar().getWidth() - 3, 3);
 110                     vLoc = scrollPane.getVerticalScrollBar().getLocationOnScreen();
 111                     vLoc.translate(3, scrollPane.getVerticalScrollBar().getHeight() - 3);
 112 
 113                     testLoc = p.getLocationOnScreen();
 114                     testLoc.translate(-3, -3);
 115 
 116                     resizeLoc = f.getLocationOnScreen();
 117                     resizeLoc.translate(f.getWidth() - 1, f.getHeight() - 1);
 118                 }
 119             });
 120         } catch (Exception e) {
 121             e.printStackTrace();
 122             throw new RuntimeException("Problem preparing test GUI.");
 123         }
 124         // run robot
 125         Robot robot = Util.createRobot();
 126         robot.setAutoDelay(ROBOT_DELAY);
 127 
 128         robot.mouseMove(hLoc.x, hLoc.y);
 129         robot.mousePress(InputEvent.BUTTON1_MASK);
 130         robot.mouseRelease(InputEvent.BUTTON1_MASK);
 131         Util.waitForIdle(robot);
 132 
 133         robot.mouseMove(vLoc.x, vLoc.y);
 134         robot.mousePress(InputEvent.BUTTON1_MASK);
 135         robot.mouseRelease(InputEvent.BUTTON1_MASK);
 136         Util.waitForIdle(robot);
 137 
 138         clickAndBlink(robot, testLoc, false);
 139         robot.mouseMove(resizeLoc.x, resizeLoc.y);
 140         robot.mousePress(InputEvent.BUTTON1_MASK);
 141         robot.mouseMove(resizeLoc.x + 5, resizeLoc.y + 5);
 142         robot.mouseRelease(InputEvent.BUTTON1_MASK);