# HG changeset patch # User alexsch # Date 1442242444 -14400 # Node ID 600f0e7f6dd5cd1aa7c9541f9d51e2a1bc2fa05c # Parent 79d93ad73030f5fbd92d741771a7fc4f39d5e72b 8039467: [TEST_BUG] Test java/awt/Choice/UnfocusableToplevel/UnfocusableToplevel.java lefts keystrokes in a keyboard buffer on Windows Reviewed-by: serb, alexsch Contributed-by: Ambarish Rapte diff -r 79d93ad73030 -r 600f0e7f6dd5 test/java/awt/Choice/UnfocusableToplevel/UnfocusableToplevel.java --- a/test/java/awt/Choice/UnfocusableToplevel/UnfocusableToplevel.java Fri Sep 11 17:58:31 2015 +0300 +++ b/test/java/awt/Choice/UnfocusableToplevel/UnfocusableToplevel.java Mon Sep 14 18:54:04 2015 +0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2015 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 @@ -23,7 +23,7 @@ /* @test - @bug 6566434 + @bug 6566434 8039467 @library ../../regtesthelpers @build Util Sysout AbstractTest @summary Choice in unfocusable window responds to keyboard @@ -63,6 +63,18 @@ w.setLayout(new FlowLayout()); w.setSize(200, 200); + // Note that Window w is non focusable. Key press events will not be + // consumed by w, but by any previously focused window & this can + // disturb the environment. So creating tempFrameToHoldFocus frame, + // to consume key press events. + Frame tempFrameToHoldFocus = new Frame(); + tempFrameToHoldFocus.setVisible(true); + Util.waitForIdle(robot); + + tempFrameToHoldFocus.requestFocus(); + Util.clickOnComp(tempFrameToHoldFocus, robot); + Util.waitForIdle(robot); + ch.addKeyListener(new KeyAdapter(){ public void keyTyped(KeyEvent e){ traceEvent("keytyped", e); @@ -94,6 +106,10 @@ testKeys(); Util.waitForIdle(robot); + + tempFrameToHoldFocus.dispose(); + w.dispose(); + f.dispose(); } private static void testKeys(){