--- /dev/null 2014-07-28 16:11:16.120781410 +0400 +++ new/test/java/awt/reliability/TaskRequestFocusOwner.java 2014-07-28 16:22:06.068769509 +0400 @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2004, 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. + * + * 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. + */ + +import java.awt.*; + +/* + * @test + * @summary Try to request focus to a component in a top level window which + * is not focused and check whether the component is becoming the + * focus owner.Check for the FOCUS_GAINED event and the keyevents by + * making the component focusable and non focusable. + * @author Aruna Samji + * @library ../../../lib/testlibrary + * @build ExtendedRobot + * @run main TaskRequestFocusOwner + */ + +public class TaskRequestFocusOwner extends Task { + + public static void main (String[] args) throws Exception { + new TaskRequestFocusOwner(new GUIMerlinFocus(), new ExtendedRobot()).runTask(); + } + + TaskRequestFocusOwner(GUIMerlinFocus gui, ExtendedRobot robot) { + super(gui, robot); + } + + public void task() throws Exception { + gui.testframe3.setVisible(true); + robot.waitForIdle(1000); + + Point button14Center = gui.button14.getLocationOnScreen(); + button14Center.translate(gui.button14.getWidth()/2, gui.button14.getHeight()/2); + robot.glide(gui.button14.getLocationOnScreen(), button14Center); + robot.click(); + robot.waitForIdle(1000); + + //Make the checkbox Disabled using the setVisible(false) and check + //whether the checkbox is getting the Focus + gui.checkbox14.setEnabled(false); + gui.checkbox14.setVisible(false); + robot.waitForIdle(1000); + + gui.checkbox14.requestFocusInWindow(); + robot.waitForIdle(1000); + if(gui.checkbox14.isFocusOwner()) + throw new RuntimeException("The checkbox has got the Focus when made " + + "setEnable(false) and setVisible(false)."); + + gui.checkbox14.setEnabled(true); + gui.checkbox14.setVisible(true); + robot.waitForIdle(1000); + gui.checkbox14.requestFocusInWindow(); + robot.waitForIdle(1000); + if(!gui.checkbox14.isFocusOwner()) + throw new RuntimeException("The Checkbox did get the focus when made " + + "setEnable(true) and setVisible(true)."); + + //Checking whether the TextArea has gained the Focus after making + //setFocusable as false + gui.textarea14.setFocusable(false); + gui.textarea14.requestFocusInWindow(); + robot.waitForIdle(1000); + if(gui.textarea14.isFocusOwner()) + throw new RuntimeException("The Focus is transferred to Non-Focusable " + + "TextArea."); + + gui.textarea14.setFocusable(true); + robot.waitForIdle(1000); + gui.textarea14.requestFocusInWindow(); + robot.waitForIdle(1000); + if(!gui.textarea14.isFocusOwner()) + throw new RuntimeException("The Focus is not transferred to Focusable " + + "TextArea"); + } +}