test/javax/swing/JPopupMenu/6827786/bug6827786.java

Print this page




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 6827786
  27  * @summary Tests duplicate mnemonics
  28  * @author Peter Zhelezniakov
  29  * @library ../../regtesthelpers


  30  * @build Util
  31  * @run main bug6827786
  32  */

  33 import java.awt.*;
  34 import java.awt.event.KeyEvent;
  35 import javax.swing.*;
  36 
  37 public class bug6827786 {
  38 
  39     private static JMenu menu;
  40     private static Component focusable;
  41 
  42     public static void main(String[] args) throws Exception {
  43         Robot robot = new Robot();
  44         robot.setAutoDelay(50);
  45 
  46         SwingUtilities.invokeAndWait(new Runnable() {
  47 
  48             public void run() {
  49                 createAndShowGUI();
  50             }
  51         });
  52 
  53         robot.waitForIdle();
  54 
  55         SwingUtilities.invokeAndWait(new Runnable() {
  56 
  57             public void run() {
  58                 focusable.requestFocus();
  59             }
  60         });
  61 
  62         robot.waitForIdle();
  63         checkfocus();
  64 
  65         // select menu
  66         if (sun.awt.OSInfo.getOSType() == sun.awt.OSInfo.OSType.MACOSX) {
  67             Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_F);
  68         } else {
  69             Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_F);
  70         }
  71         // select submenu
  72         Util.hitKeys(robot, KeyEvent.VK_S);
  73         robot.waitForIdle();
  74         // verify submenu is selected
  75         verify(1);
  76 
  77         Util.hitKeys(robot, KeyEvent.VK_S);
  78         robot.waitForIdle();
  79         // verify last item is selected
  80         verify(2);
  81 
  82         Util.hitKeys(robot, KeyEvent.VK_S);
  83         robot.waitForIdle();
  84         // selection should wrap to first item
  85         verify(0);
  86 




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 6827786
  27  * @summary Tests duplicate mnemonics
  28  * @author Peter Zhelezniakov
  29  * @library ../../regtesthelpers
  30  * @library ../../../../lib/testlibrary
  31  * @build jdk.testlibrary.OSInfo
  32  * @build Util
  33  * @run main bug6827786
  34  */
  35 import jdk.testlibrary.OSInfo;
  36 import java.awt.*;
  37 import java.awt.event.KeyEvent;
  38 import javax.swing.*;
  39 
  40 public class bug6827786 {
  41 
  42     private static JMenu menu;
  43     private static Component focusable;
  44 
  45     public static void main(String[] args) throws Exception {
  46         Robot robot = new Robot();
  47         robot.setAutoDelay(50);
  48 
  49         SwingUtilities.invokeAndWait(new Runnable() {
  50 
  51             public void run() {
  52                 createAndShowGUI();
  53             }
  54         });
  55 
  56         robot.waitForIdle();
  57 
  58         SwingUtilities.invokeAndWait(new Runnable() {
  59 
  60             public void run() {
  61                 focusable.requestFocus();
  62             }
  63         });
  64 
  65         robot.waitForIdle();
  66         checkfocus();
  67 
  68         // select menu
  69         if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
  70             Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_F);
  71         } else {
  72             Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_F);
  73         }
  74         // select submenu
  75         Util.hitKeys(robot, KeyEvent.VK_S);
  76         robot.waitForIdle();
  77         // verify submenu is selected
  78         verify(1);
  79 
  80         Util.hitKeys(robot, KeyEvent.VK_S);
  81         robot.waitForIdle();
  82         // verify last item is selected
  83         verify(2);
  84 
  85         Util.hitKeys(robot, KeyEvent.VK_S);
  86         robot.waitForIdle();
  87         // selection should wrap to first item
  88         verify(0);
  89