< prev index next >
test/java/awt/GridLayout/ChangeGridSize/ChangeGridSize.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 31,66 ****
* grid layout and check the components are re-laid out.
* The strategy followed is to calculate the component location
* depending on the preferred sizes and gaps and click the cornors
* of the components to check if events are triggered
* @library ../../../../lib/testlibrary/
- * @build ExtendedRobot
* @run main ChangeGridSize
* @run main ChangeGridSize -hg 20 -vg 20
*/
public class ChangeGridSize {
! private int width = 200;
private int height = 200;
private final int hGap, vGap;
private final int rows = 3;
private final int columns = 2;
private final int componentCount = 6;
private Button[] buttons;
private Frame frame;
! private ExtendedRobot robot;
private GridLayout layout;
private volatile boolean actionPerformed = false;
public ChangeGridSize(int hGap, int vGap) throws Exception {
this.hGap = hGap;
this.vGap = vGap;
! robot = new ExtendedRobot();
EventQueue.invokeAndWait( () -> {
frame = new Frame("Test frame");
frame.setSize(width, height);
layout = new GridLayout(rows + 3, columns - 1, hGap, vGap);
frame.setLayout(layout);
--- 31,65 ----
* grid layout and check the components are re-laid out.
* The strategy followed is to calculate the component location
* depending on the preferred sizes and gaps and click the cornors
* of the components to check if events are triggered
* @library ../../../../lib/testlibrary/
* @run main ChangeGridSize
* @run main ChangeGridSize -hg 20 -vg 20
*/
public class ChangeGridSize {
! private int width = 300;
private int height = 200;
private final int hGap, vGap;
private final int rows = 3;
private final int columns = 2;
private final int componentCount = 6;
private Button[] buttons;
private Frame frame;
! private Robot robot;
private GridLayout layout;
private volatile boolean actionPerformed = false;
public ChangeGridSize(int hGap, int vGap) throws Exception {
this.hGap = hGap;
this.vGap = vGap;
! robot = new Robot();
EventQueue.invokeAndWait( () -> {
frame = new Frame("Test frame");
frame.setSize(width, height);
layout = new GridLayout(rows + 3, columns - 1, hGap, vGap);
frame.setLayout(layout);
*** 120,145 ****
robot.mouseMove(topLeftX, topLeftY);
robot.delay(500);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.delay(500);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
! robot.waitForIdle(3000);
! if(!actionPerformed)
throw new RuntimeException("Clicking on the left top of button did not trigger action event");
actionPerformed = false;
robot.mouseMove(bottomRightX, bottomRightY);
robot.delay(500);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.delay(500);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
! robot.waitForIdle(3000);
! if(!actionPerformed)
throw new RuntimeException("Clicking on the bottom right of button did not trigger action event");
}
private void doTest() throws Exception {
robot.waitForIdle();
changeGridSize();
resizeFrame();
--- 119,148 ----
robot.mouseMove(topLeftX, topLeftY);
robot.delay(500);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.delay(500);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
! robot.delay(3000);
! if (!actionPerformed) {
! frame.dispose();
throw new RuntimeException("Clicking on the left top of button did not trigger action event");
+ }
actionPerformed = false;
robot.mouseMove(bottomRightX, bottomRightY);
robot.delay(500);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.delay(500);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
! robot.delay(3000);
! if (!actionPerformed) {
! frame.dispose();
throw new RuntimeException("Clicking on the bottom right of button did not trigger action event");
}
+ }
private void doTest() throws Exception {
robot.waitForIdle();
changeGridSize();
resizeFrame();
*** 152,161 ****
--- 155,165 ----
int componentHeight = (availableHeight + vGap) / rows - vGap;
for (int i = 0; i < buttons.length; i++) {
if (buttons[i].getSize().width != componentWidth ||
buttons[i].getSize().height != componentHeight) {
+ frame.dispose();
throw new RuntimeException(
"FAIL: Button " + i + " not of proper size" +
"Expected: " + componentWidth + "*" + componentHeight +
"Actual: " + buttons[i].getSize().width + "*" + buttons[i].getSize().height);
}
< prev index next >