/* * Copyright (c) 2012, 2020, 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. * * This code 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 * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
/* @test @key headful @bug 7124430 @summary Tests that SunToolkit.grab API works @author anton.tarasov@oracle.com: area=awt.toolkit @library ../../regtesthelpers @modules java.desktop/sun.awt @build Util @run main GrabTest
*/
// 1. Check that button press doesn't cause ungrab
Util.clickOnComp(b, robot);
Util.waitForIdle(robot);
checkAndThrow(buttonPressed, "Error: Button can not be pressed"); if (ungrabbed) {
passed = false;
tk.grab(w);
System.err.println("Failure: [1] Press inside of Window (on Button) caused ungrab");
}
// 2. Check that press on the window itself doesn't cause ungrab
Util.clickOnComp(w, robot);
Util.waitForIdle(robot);
checkAndThrow(windowPressed, "Error: Window can't be pressed"); if (ungrabbed) {
passed = false;
tk.grab(w);
System.err.println("Failure: [2] Press inside of Window caused ungrab");
}
// 3. Check that press on the frame causes ungrab, event must be dispatched
Util.clickOnComp(f, robot);
Util.waitForIdle(robot);
checkAndThrow(framePressed, "Error: Frame can't be pressed"); if (!ungrabbed) {
passed = false;
System.err.println("Failure: [3] Press inside of Frame didn't cause ungrab");
}
ungrabbed = false;
tk.grab(w);
// 4. Check that press on the frame's title causes ungrab
Util.clickOnTitle(f, robot);
Util.waitForIdle(robot); if (!ungrabbed) {
passed = false;
System.err.println("Failure: [4] Press inside of Frame's title didn't cause ungrab");
}
ungrabbed = false;
tk.grab(w);
// 5. Check that press on the other frame's title causes ungrab
f1.setVisible(true);
Util.waitForIdle(robot);
Util.clickOnTitle(f1, robot); if (!ungrabbed) {
passed = false;
System.err.println("Failure: [5] Press inside of other Frame's title didn't cause ungrab");
}
f.requestFocus(); // restore focus
Util.waitForIdle(robot); if (!f.hasFocus()) {
System.err.println("Error: Frame can't be focused");
}
ungrabbed = false;
tk.grab(w);
// 6. Check that press on the outside area causes ungrab
Point loc = f.getLocationOnScreen();
robot.mouseMove(loc.x + 100, loc.y + f.getSize().height + 10);
Util.waitForIdle(robot);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.delay(50);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
Util.waitForIdle(robot); if (!ungrabbed) {
passed = false;
System.err.println("Failure: [6] Press on the outside area didn't cause ungrab");
}
ungrabbed = false;
tk.grab(w);
// 7. Check that disposing the window causes ungrab
w.dispose();
Util.waitForIdle(robot); if (!ungrabbed) {
passed = false;
System.err.println("Failure: [7] Window disposal didn't cause ungrab");
}
ungrabbed = false;
// 8. Check that mouse click on subwindow does not cause ungrab
frame.setVisible(true);
window1.setVisible(true);
window2.setVisible(true);
Util.waitForIdle(robot);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.