0N/A/*
2362N/A * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A @test
0N/A @bug 6566434
0N/A @library ../../regtesthelpers
0N/A @build Util Sysout AbstractTest
0N/A @summary Choice in unfocusable window responds to keyboard
0N/A @author Andrei Dmitriev: area=awt-choice
0N/A @run main UnfocusableToplevel
0N/A*/
0N/A
0N/A/**
0N/A * UnfocusableToplevel.java
0N/A *
0N/A * summary:
0N/A */
0N/A
0N/Aimport java.awt.*;
0N/Aimport java.awt.event.*;
0N/Aimport test.java.awt.regtesthelpers.AbstractTest;
0N/Aimport test.java.awt.regtesthelpers.Sysout;
0N/Aimport test.java.awt.regtesthelpers.Util;
0N/A
0N/Apublic class UnfocusableToplevel {
0N/A
0N/A final static Robot robot = Util.createRobot();
0N/A final static int REASONABLE_PATH_TIME = 5000;
0N/A
0N/A public static void main(String []s)
0N/A {
0N/A Frame f = new Frame();
0N/A Window w = new Window(f);
0N/A final Choice ch = new Choice();
0N/A
0N/A ch.add("item 1");
0N/A ch.add("item 2");
0N/A ch.add("item 3");
0N/A ch.add("item 4");
0N/A ch.add("item 5");
0N/A w.add(ch);
0N/A w.setLayout(new FlowLayout());
0N/A w.setSize(200, 200);
0N/A
0N/A ch.addKeyListener(new KeyAdapter(){
0N/A public void keyTyped(KeyEvent e){
0N/A traceEvent("keytyped", e);
0N/A }
0N/A public void keyPressed(KeyEvent e){
0N/A traceEvent("keypress", e);
0N/A }
0N/A public void keyReleased(KeyEvent e){
0N/A traceEvent("keyrelease", e);
0N/A }
0N/A });
0N/A
0N/A ch.addItemListener(new ItemListener(){
0N/A public void itemStateChanged(ItemEvent ie){
0N/A traceEvent("stateChanged", ie);
0N/A }
0N/A });
0N/A
0N/A w.setVisible(true);
0N/A
0N/A Util.waitForIdle(robot);
0N/A
0N/A Util.clickOnComp(ch, robot);
0N/A Util.waitForIdle(robot);
0N/A
0N/A // will not test if the dropdown become opened as there is no reliable
0N/A // technique to accomplish that rather then checking color of dropdown
0N/A // Will suppose that the dropdown appears
0N/A
0N/A testKeys();
0N/A Util.waitForIdle(robot);
0N/A }
0N/A
0N/A private static void testKeys(){
0N/A typeKey(KeyEvent.VK_UP);
0N/A typeKey(KeyEvent.VK_DOWN);
0N/A typeKey(KeyEvent.VK_K);
0N/A typeKey(KeyEvent.VK_PAGE_UP);
0N/A typeKey(KeyEvent.VK_PAGE_DOWN);
0N/A }
0N/A
0N/A private static void typeKey(int keyChar){
0N/A try {
0N/A robot.keyPress(keyChar);
0N/A robot.delay(5);
0N/A } finally {
0N/A robot.keyRelease(keyChar);
0N/A }
0N/A robot.delay(100);
0N/A }
0N/A
0N/A private static void traceEvent(String message, AWTEvent e){
0N/A AbstractTest.fail(message + " " + e.toString());
0N/A }
0N/A}