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 <ambarish.rapte@oracle.com>
--- a/jdk/test/java/awt/Choice/UnfocusableToplevel/UnfocusableToplevel.java Fri Sep 11 17:58:31 2015 +0300
+++ b/jdk/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(){