7132383: [macosx] bug6596966.java should be adapted for Mac
Reviewed-by: serb, alexsch
This commit is contained in:
parent
30a25e41d2
commit
dfdd79f3ee
jdk/test/javax/swing
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2013, 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
|
||||
@ -24,16 +24,17 @@
|
||||
/* @test
|
||||
@bug 6596966
|
||||
@summary Some JFileChooser mnemonics do not work with sticky keys
|
||||
@library ../../regtesthelpers
|
||||
@build Util
|
||||
@run main bug6596966
|
||||
@author Pavel Porvatov
|
||||
*/
|
||||
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.ArrayList;
|
||||
import javax.swing.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class bug6596966 {
|
||||
private static JFrame frame;
|
||||
@ -71,11 +72,14 @@ public class bug6596966 {
|
||||
|
||||
toolkit.realSync();
|
||||
|
||||
robot.keyPress(KeyEvent.VK_ALT);
|
||||
ArrayList<Integer> keys = Util.getSystemMnemonicKeyCodes();
|
||||
for (int i = 0; i < keys.size(); ++i) {
|
||||
robot.keyPress(keys.get(i));
|
||||
}
|
||||
|
||||
robot.keyPress(KeyEvent.VK_L);
|
||||
|
||||
toolkit.realSync();
|
||||
|
||||
toolkit.getSystemEventQueue().postEvent(new KeyEvent(label, KeyEvent.KEY_RELEASED,
|
||||
EventQueue.getMostRecentEventTime(), 0, KeyEvent.VK_L, 'L'));
|
||||
|
||||
@ -90,7 +94,11 @@ public class bug6596966 {
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
robot.keyRelease(KeyEvent.VK_ALT);
|
||||
robot.keyRelease(KeyEvent.VK_L);
|
||||
for (int i = 0; i < keys.size(); ++i) {
|
||||
robot.keyRelease(keys.get(i));
|
||||
}
|
||||
toolkit.realSync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2013, 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,11 +23,13 @@
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import sun.swing.*;
|
||||
|
||||
/**
|
||||
* <p>This class contains utilities useful for regression testing.
|
||||
@ -212,4 +214,33 @@ public class Util {
|
||||
|
||||
return result.get(0);
|
||||
}
|
||||
/**
|
||||
* Gets key codes from system mnemonic key mask
|
||||
* @return key codes list
|
||||
*/
|
||||
public static ArrayList<Integer> getSystemMnemonicKeyCodes() {
|
||||
return Util.getKeyCodesFromKeyMask(SwingUtilities2.getSystemMnemonicKeyMask());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the key codes list from modifiers
|
||||
* @param modifiers an integer combination of the modifier constants
|
||||
* @return key codes list
|
||||
*/
|
||||
public static ArrayList<Integer> getKeyCodesFromKeyMask(int modifiers) {
|
||||
ArrayList<Integer> result = new ArrayList<>();
|
||||
if ((modifiers & InputEvent.CTRL_MASK) != 0) {
|
||||
result.add(KeyEvent.VK_CONTROL);
|
||||
}
|
||||
if ((modifiers & InputEvent.ALT_MASK) != 0) {
|
||||
result.add(KeyEvent.VK_ALT);
|
||||
}
|
||||
if ((modifiers & InputEvent.SHIFT_MASK) != 0) {
|
||||
result.add(KeyEvent.VK_SHIFT);
|
||||
}
|
||||
if ((modifiers & InputEvent.META_MASK) != 0) {
|
||||
result.add(KeyEvent.VK_META);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user