This commit is contained in:
Lana Steuck 2012-05-25 16:32:02 -07:00
commit cc0d0b06ff
156 changed files with 2992 additions and 1736 deletions

View file

@ -0,0 +1,60 @@
/*
* Copyright (c) 2012, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.awt.Dialog;
import java.awt.Frame;
import java.util.Timer;
import java.util.TimerTask;
/*
@test
@bug 7080109
@summary Dialog.show() lacks doPrivileged() to access system event queue.
@author sergey.bylokhov@oracle.com: area=awt.dialog
@run main/othervm/policy=java.policy -Djava.security.manager ModalDialogPermission
*/
public final class ModalDialogPermission {
public static void main(final String[] args) {
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(final Thread t, final Throwable e) {
throw new RuntimeException(e);
}
});
final Frame frame = new Frame();
final Dialog dialog = new Dialog(frame, "ModalDialog", true);
final Timer t = new Timer();
t.schedule(new TimerTask() {
@Override
public void run() {
dialog.setVisible(false);
dialog.dispose();
}
}, 3000L);
dialog.show();
frame.dispose();
t.cancel();
}
}

View file

@ -0,0 +1,3 @@
grant {
permission java.lang.RuntimePermission "setDefaultUncaughtExceptionHandler";
};

View file

@ -0,0 +1,26 @@
/*
@test
@bug 7125044
@summary Tests defaut focus traversal policy in AWT & Swing toplevel windows.
@author anton.tarasov@sun.com: area=awt.focus
@run main InitialFTP_AWT
@run main InitialFTP_Swing
*/
import java.awt.FocusTraversalPolicy;
import java.awt.Window;
public class InitialFTP {
public static void test(Window win, Class<? extends FocusTraversalPolicy> expectedPolicy) {
FocusTraversalPolicy ftp = win.getFocusTraversalPolicy();
System.out.println("==============" + "\n" +
"Tested window: " + win + "\n" +
"Expected policy: " + expectedPolicy + "\n" +
"Effective policy: " + ftp.getClass());
if (!expectedPolicy.equals(ftp.getClass())) {
throw new RuntimeException("Test failed: wrong effective focus policy");
}
}
}

View file

@ -0,0 +1,50 @@
/*
@bug 7125044
@summary Tests default focus traversal policy in AWT toplevel windows.
@author anton.tarasov@sun.com: area=awt.focus
*/
import java.awt.Button;
import java.awt.DefaultFocusTraversalPolicy;
import java.awt.FlowLayout;
import java.awt.FocusTraversalPolicy;
import java.awt.Frame;
import java.awt.List;
import java.awt.TextArea;
import java.awt.Window;
public class InitialFTP_AWT {
public static void main(String[] args) {
AWTFrame f0 = new AWTFrame("frame0");
f0.setVisible(true);
InitialFTP.test(f0, DefaultFocusTraversalPolicy.class);
AWTFrame f1 = new AWTFrame("frame1");
f1.setVisible(true);
InitialFTP.test(f1, DefaultFocusTraversalPolicy.class);
System.out.println("Test passed.");
}
}
class AWTFrame extends Frame {
Button button = new Button("button");
TextArea text = new TextArea("qwerty");
List list = new List();
public AWTFrame(String title) {
super(title);
list.add("one");
list.add("two");
list.add("three");
this.setLayout(new FlowLayout());
this.add(button);
this.add(text);
this.add(list);
this.pack();
}
}

View file

@ -0,0 +1,46 @@
/*
@bug 7125044
@summary Tests default focus traversal policy in Swing toplevel windows.
@author anton.tarasov@sun.com: area=awt.focus
*/
import java.awt.FlowLayout;
import java.awt.FocusTraversalPolicy;
import java.awt.Window;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JTextArea;
import javax.swing.LayoutFocusTraversalPolicy;
public class InitialFTP_Swing {
public static void main(String[] args) {
SwingFrame f0 = new SwingFrame("frame0");
f0.setVisible(true);
InitialFTP.test(f0, LayoutFocusTraversalPolicy.class);
SwingFrame f1 = new SwingFrame("frame1");
f1.setVisible(true);
InitialFTP.test(f1, LayoutFocusTraversalPolicy.class);
System.out.println("Test passed.");
}
}
class SwingFrame extends JFrame {
JButton button = new JButton("button");
JTextArea text = new JTextArea("qwerty");
JList list = new JList(new String[] {"one", "two", "three"});
public SwingFrame(String title) {
super(title);
this.setLayout(new FlowLayout());
this.add(button);
this.add(text);
this.add(list);
this.pack();
}
}

View file

@ -23,7 +23,7 @@
/*
* @test
* @bug 6822057
* @bug 6822057 7124400
*
* @summary Test verifies that list of supported graphics configurations
* can not be changed via modification of elements of an array

View file

@ -0,0 +1,100 @@
/*
* Copyright (c) 2012, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
@test
@bug 7154072
@summary Tests that key events with modifiers are not swallowed.
@author anton.tarasov: area=awt.focus
@library ../../../regtesthelpers
@build Util
@run main SwallowKeyEvents
*/
import java.awt.AWTException;
import java.awt.Frame;
import java.awt.Robot;
import java.awt.TextField;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import test.java.awt.regtesthelpers.Util;
public class SwallowKeyEvents {
static final int PRESS_COUNT = 10;
static int keyPressedCount = 0;
static Frame f = new Frame("Frame");
static TextField t = new TextField("text");
static Robot r;
public static void main(String[] args) {
f.add(t);
f.pack();
f.setVisible(true);
t.requestFocus();
try {
r = new Robot();
} catch (AWTException ex) {
throw new RuntimeException(ex);
}
Util.waitForIdle(r);
t.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent ke) {
System.out.println(ke);
if (ke.getKeyCode() == KeyEvent.VK_M) {
keyPressedCount++;
}
}
});
test();
System.out.println("key_pressed count: " + keyPressedCount);
if (keyPressedCount != PRESS_COUNT) {
throw new RuntimeException("Test failed!");
} else {
System.out.println("Test passed.");
}
}
public static void test() {
r.keyPress(KeyEvent.VK_SHIFT);
r.keyPress(KeyEvent.VK_META);
for (int i=0; i<PRESS_COUNT; i++) {
r.delay(100);
r.keyPress(KeyEvent.VK_M);
r.delay(100);
r.keyRelease(KeyEvent.VK_M);
}
r.keyRelease(KeyEvent.VK_META);
r.keyRelease(KeyEvent.VK_SHIFT);
}
}