< prev index next >

test/java/awt/GridLayout/ComponentPreferredSize/ComponentPreferredSize.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 **** * Check if the compnents are correctly 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 ComponentPreferredSize * @run main ComponentPreferredSize -hg 20 -vg 20 */ public class ComponentPreferredSize { ! 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 ComponentPreferredSize(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, columns, hGap, vGap); frame.setLayout(layout); --- 31,65 ---- * Check if the compnents are correctly 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 ComponentPreferredSize * @run main ComponentPreferredSize -hg 20 -vg 20 */ public class ComponentPreferredSize { ! 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 ComponentPreferredSize(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, columns, hGap, vGap); frame.setLayout(layout);
*** 113,138 **** 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(); resizeFrame(); --- 112,141 ---- 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(); resizeFrame();
*** 144,153 **** --- 147,157 ---- 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 >