--- /dev/null 2014-07-31 16:13:19.122792434 +0400 +++ new/test/java/awt/reliability/TaskProgrammaticTraversal.java 2014-07-31 17:27:54.934615052 +0400 @@ -0,0 +1,105 @@ +/* + * 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 traverse through all the Focusable Components + * programmatically and check whether the focus has been traversed + * or not + * @author Aruna Samji + * @library ../../../lib/testlibrary + * @build ExtendedRobot + * @run main TaskProgrammaticTraversal + */ + +public class TaskProgrammaticTraversal extends Task { + + public static void main (String[] args) throws Exception { + new TaskProgrammaticTraversal(GUIMerlinFocus.class, new ExtendedRobot()).runTask(); + } + + TaskProgrammaticTraversal(Class guiClass, ExtendedRobot robot) throws Exception { + super(guiClass, robot); + } + + public void task() throws Exception { + EventQueue.invokeAndWait(() -> + gui.testFrame2.setVisible(true) + ); + robot.waitForIdle(1000); + + Point button9Center = gui.button9.getLocationOnScreen(); + button9Center.translate(gui.button9.getWidth()/2, gui.button9.getHeight()/2); + robot.glide(gui.button9.getLocationOnScreen(), button9Center); + robot.waitForIdle(1000); + robot.click(); + + EventQueue.invokeAndWait(gui.manager2::focusNextComponent); + robot.waitForIdle(1000); + + if (gui.focusGained2 != gui.choice8) + throw new RuntimeException("KeyboardFocusManager.focusNextComponent() " + + "is not changing the focus owner."); + + EventQueue.invokeAndWait(gui.manager2::focusPreviousComponent); + robot.waitForIdle(1000); + + if (gui.focusGained2 != gui.button9) + throw new RuntimeException("KeyboardFocusManager.focusPreviousComponent() " + + "is not changing the focus owner."); + + EventQueue.invokeAndWait(() -> + gui.manager2.focusPreviousComponent(gui.checkbox8) + ); + robot.waitForIdle(1000); + + if (gui.focusGained2 != gui.textfield8) + throw new RuntimeException("KeyboardFocusManager.focusPreviousComponent(component) " + + "is not changing the focus owner."); + + EventQueue.invokeAndWait(() -> + gui.manager2.focusNextComponent(gui.textfield8) + ); + robot.waitForIdle(1000); + + if (gui.focusGained2 != gui.checkbox8) + throw new RuntimeException("KeyboardFocusManager.focusNextComponent(component) " + + "is not changing the focus owner."); + + EventQueue.invokeAndWait(gui.button8::transferFocus); + robot.waitForIdle(1000); + + if (gui.focusGained2 != gui.list8) + throw new RuntimeException("Component.transferFocus() is not changing " + + "the focus owner."); + + EventQueue.invokeAndWait(gui.list8::transferFocusBackward); + robot.waitForIdle(1000); + + if (gui.focusGained2 != gui.button8) + throw new RuntimeException("Component.transferFocusBackward() is not " + + "changing the focus owner."); + } +}