8130125: [TEST_BUG] add @modules to the several client tests unaffected by the automated bulk update
Reviewed-by: serb, alexsch
This commit is contained in:
parent
5941f4ad52
commit
a26c73956c
@ -27,18 +27,17 @@
|
||||
@author Semyon Sadetsky
|
||||
*/
|
||||
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class bug6980209 implements ActionListener {
|
||||
private final static PlatformLogger log =
|
||||
PlatformLogger.getLogger("java.awt.event.WaitDispatchSupport");
|
||||
private final static Logger log =
|
||||
Logger.getLogger("java.awt.event.WaitDispatchSupport");
|
||||
public static final int ATTEMPTS = 100;
|
||||
public static final int EVENTS = 5;
|
||||
|
||||
@ -52,8 +51,8 @@ public class bug6980209 implements ActionListener {
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println(
|
||||
"PLEASE DO NOT TOUCH KEYBOARD AND MOUSE DURING THE TEST RUN!");
|
||||
// log.setLevel(PlatformLogger.Level.FINE);
|
||||
// log.setLevel(PlatformLogger.Level.FINEST);
|
||||
// log.setLevel(java.util.logging.Level.FINE);
|
||||
// log.setLevel(java.util.logging.Level.FINEST);
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
|
@ -25,6 +25,7 @@
|
||||
@bug 8017487
|
||||
@summary filechooser in Windows-Libraries folder: columns are mixed up
|
||||
@author Semyon Sadetsky
|
||||
@modules java.desktop/sun.awt.shell
|
||||
@library /lib/testlibrary
|
||||
@build jdk.testlibrary.OSInfo
|
||||
@run main bug8017487
|
||||
|
@ -28,13 +28,11 @@
|
||||
* @compile AWTFocusTransitionTest.java
|
||||
* @run main/othervm AWTFocusTransitionTest
|
||||
*/
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
public class AWTFocusTransitionTest {
|
||||
private static SunToolkit toolkit;
|
||||
private static Robot robot;
|
||||
|
||||
private static Frame frame;
|
||||
@ -42,20 +40,19 @@ public class AWTFocusTransitionTest {
|
||||
private static Button button;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
toolkit = (SunToolkit)Toolkit.getDefaultToolkit();
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
try {
|
||||
createAndShowGUI();
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
checkFocusOwner(textField);
|
||||
|
||||
robot.keyPress(KeyEvent.VK_TAB);
|
||||
robot.keyRelease(KeyEvent.VK_TAB);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
checkFocusOwner(button);
|
||||
|
||||
@ -63,7 +60,7 @@ public class AWTFocusTransitionTest {
|
||||
robot.keyPress(KeyEvent.VK_TAB);
|
||||
robot.keyRelease(KeyEvent.VK_TAB);
|
||||
robot.keyRelease(KeyEvent.VK_SHIFT);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
checkFocusOwner(textField);
|
||||
|
||||
@ -71,7 +68,7 @@ public class AWTFocusTransitionTest {
|
||||
robot.keyPress(KeyEvent.VK_TAB);
|
||||
robot.keyRelease(KeyEvent.VK_TAB);
|
||||
robot.keyRelease(KeyEvent.VK_SHIFT);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
checkFocusOwner(button);
|
||||
} finally {
|
||||
|
@ -28,14 +28,12 @@
|
||||
* @compile SwingFocusTransitionTest.java
|
||||
* @run main/othervm SwingFocusTransitionTest
|
||||
*/
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
public class SwingFocusTransitionTest {
|
||||
private static SunToolkit toolkit;
|
||||
private static Robot robot;
|
||||
|
||||
private static JFrame frame;
|
||||
@ -43,7 +41,6 @@ public class SwingFocusTransitionTest {
|
||||
private static JButton button;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
toolkit = (SunToolkit)Toolkit.getDefaultToolkit();
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
|
||||
@ -55,13 +52,13 @@ public class SwingFocusTransitionTest {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
checkFocusOwner(textField);
|
||||
|
||||
robot.keyPress(KeyEvent.VK_TAB);
|
||||
robot.keyRelease(KeyEvent.VK_TAB);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
checkFocusOwner(button);
|
||||
|
||||
@ -69,7 +66,7 @@ public class SwingFocusTransitionTest {
|
||||
robot.keyPress(KeyEvent.VK_TAB);
|
||||
robot.keyRelease(KeyEvent.VK_TAB);
|
||||
robot.keyRelease(KeyEvent.VK_SHIFT);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
checkFocusOwner(textField);
|
||||
|
||||
@ -77,7 +74,7 @@ public class SwingFocusTransitionTest {
|
||||
robot.keyPress(KeyEvent.VK_TAB);
|
||||
robot.keyRelease(KeyEvent.VK_TAB);
|
||||
robot.keyRelease(KeyEvent.VK_SHIFT);
|
||||
toolkit.realSync();
|
||||
robot.waitForIdle();
|
||||
|
||||
checkFocusOwner(button);
|
||||
} finally {
|
||||
|
@ -26,6 +26,8 @@
|
||||
@bug 6516675
|
||||
@summary Tests that EmbeddedFrame can be focused.
|
||||
@author anton.tarasov: area=awt-focus
|
||||
@modules java.desktop/java.awt.peer
|
||||
java.desktop/sun.awt
|
||||
@library ../../regtesthelpers
|
||||
@build Util UtilInternal
|
||||
@run main FocusEmbeddedFrameTest
|
||||
|
@ -0,0 +1,44 @@
|
||||
<html>
|
||||
<!--
|
||||
Copyright (c) 2003, 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
|
||||
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 4828019
|
||||
@summary Frame/Window deadlock
|
||||
@author yan@sparc.spb.su: area=
|
||||
@run applet/timeout=9999 NonEDT_GUI_Deadlock.html
|
||||
-->
|
||||
<head>
|
||||
<title> </title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>NonEDT_GUI_Deadlock<br>Bug ID: 4828019</h1>
|
||||
|
||||
<p> This is an AUTOMATIC test, simply wait for completion </p>
|
||||
|
||||
<APPLET CODE="NonEDT_GUI_Deadlock.class" WIDTH=200 HEIGHT=200></APPLET>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -0,0 +1,323 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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
|
||||
* 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 4828019
|
||||
@summary Frame/Window deadlock
|
||||
@author yan@sparc.spb.su: area=
|
||||
@run applet NonEDT_GUI_Deadlock.html
|
||||
*/
|
||||
|
||||
// Note there is no @ in front of test above. This is so that the
|
||||
// harness will not mistake this file as a test file. It should
|
||||
// only see the html file as a test file. (the harness runs all
|
||||
// valid test files, so it would run this test twice if this file
|
||||
// were valid as well as the html file.)
|
||||
// Also, note the area= after Your Name in the author tag. Here, you
|
||||
// should put which functional area the test falls in. See the
|
||||
// AWT-core home page -> test areas and/or -> AWT team for a list of
|
||||
// areas.
|
||||
// Note also the 'AutomaticAppletTest.html' in the run tag. This should
|
||||
// be changed to the name of the test.
|
||||
|
||||
|
||||
/**
|
||||
* NonEDT_GUI_Deadlock.java
|
||||
*
|
||||
* summary:
|
||||
*/
|
||||
|
||||
import java.applet.Applet;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.net.*;
|
||||
import java.io.*;
|
||||
|
||||
|
||||
//Automated tests should run as applet tests if possible because they
|
||||
// get their environments cleaned up, including AWT threads, any
|
||||
// test created threads, and any system resources used by the test
|
||||
// such as file descriptors. (This is normally not a problem as
|
||||
// main tests usually run in a separate VM, however on some platforms
|
||||
// such as the Mac, separate VMs are not possible and non-applet
|
||||
// tests will cause problems). Also, you don't have to worry about
|
||||
// synchronisation stuff in Applet tests they way you do in main
|
||||
// tests...
|
||||
|
||||
|
||||
public class NonEDT_GUI_Deadlock extends Applet
|
||||
{
|
||||
//Declare things used in the test, like buttons and labels here
|
||||
boolean bOK = false;
|
||||
Thread badThread = null;
|
||||
|
||||
public void init()
|
||||
{
|
||||
//Create instructions for the user here, as well as set up
|
||||
// the environment -- set the layout manager, add buttons,
|
||||
// etc.
|
||||
|
||||
|
||||
String[] instructions =
|
||||
{
|
||||
"This is an AUTOMATIC test",
|
||||
"simply wait until it is done"
|
||||
};
|
||||
Sysout.createDialog( );
|
||||
Sysout.printInstructions( instructions );
|
||||
|
||||
}//End init()
|
||||
|
||||
public void start ()
|
||||
{
|
||||
//Get things going. Request focus, set size, et cetera
|
||||
|
||||
setSize (200,300);
|
||||
setVisible(true);
|
||||
validate();
|
||||
|
||||
final Frame theFrame = new Frame("Window test");
|
||||
theFrame.setSize(240, 200);
|
||||
|
||||
Thread thKiller = new Thread() {
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep( 9000 );
|
||||
}catch( Exception ex ) {
|
||||
}
|
||||
if( !bOK ) {
|
||||
// oops,
|
||||
//Sysout.println("Deadlock!");
|
||||
Runtime.getRuntime().halt(0);
|
||||
}else{
|
||||
//Sysout.println("Passed ok.");
|
||||
}
|
||||
}
|
||||
};
|
||||
thKiller.setName("Killer thread");
|
||||
thKiller.start();
|
||||
Window w = new TestWindow(theFrame);
|
||||
theFrame.toBack();
|
||||
theFrame.setVisible(true);
|
||||
|
||||
theFrame.setLayout(new FlowLayout(FlowLayout.CENTER));
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
bOK = true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}// start()
|
||||
class TestWindow extends Window implements Runnable {
|
||||
|
||||
TestWindow(Frame f) {
|
||||
super(f);
|
||||
|
||||
//setSize(240, 75);
|
||||
setLocation(0, 75);
|
||||
|
||||
show();
|
||||
toFront();
|
||||
|
||||
badThread = new Thread(this);
|
||||
badThread.setName("Bad Thread");
|
||||
badThread.start();
|
||||
|
||||
}
|
||||
|
||||
public void paint(Graphics g) {
|
||||
g.drawString("Deadlock or no deadlock?",20,80);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
|
||||
long ts = System.currentTimeMillis();
|
||||
|
||||
while (true) {
|
||||
if ((System.currentTimeMillis()-ts)>3000) {
|
||||
this.setVisible( false );
|
||||
dispose();
|
||||
break;
|
||||
}
|
||||
|
||||
toFront();
|
||||
try {
|
||||
Thread.sleep(80);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void main(String args[]) {
|
||||
NonEDT_GUI_Deadlock imt = new NonEDT_GUI_Deadlock();
|
||||
imt.init();
|
||||
imt.start();
|
||||
}
|
||||
|
||||
|
||||
}// class NonEDT_GUI_Deadlock
|
||||
|
||||
|
||||
/****************************************************
|
||||
Standard Test Machinery
|
||||
DO NOT modify anything below -- it's a standard
|
||||
chunk of code whose purpose is to make user
|
||||
interaction uniform, and thereby make it simpler
|
||||
to read and understand someone else's test.
|
||||
****************************************************/
|
||||
|
||||
/**
|
||||
This is part of the standard test machinery.
|
||||
It creates a dialog (with the instructions), and is the interface
|
||||
for sending text messages to the user.
|
||||
To print the instructions, send an array of strings to Sysout.createDialog
|
||||
WithInstructions method. Put one line of instructions per array entry.
|
||||
To display a message for the tester to see, simply call Sysout.println
|
||||
with the string to be displayed.
|
||||
This mimics System.out.println but works within the test harness as well
|
||||
as standalone.
|
||||
*/
|
||||
|
||||
class Sysout
|
||||
{
|
||||
private static TestDialog dialog;
|
||||
|
||||
public static void createDialogWithInstructions( String[] instructions )
|
||||
{
|
||||
dialog = new TestDialog( new Frame(), "Instructions" );
|
||||
dialog.printInstructions( instructions );
|
||||
dialog.setVisible(true);
|
||||
println( "Any messages for the tester will display here." );
|
||||
}
|
||||
|
||||
public static void createDialog( )
|
||||
{
|
||||
dialog = new TestDialog( new Frame(), "Instructions" );
|
||||
String[] defInstr = { "Instructions will appear here. ", "" } ;
|
||||
dialog.printInstructions( defInstr );
|
||||
dialog.setVisible(true);
|
||||
println( "Any messages for the tester will display here." );
|
||||
}
|
||||
|
||||
|
||||
public static void printInstructions( String[] instructions )
|
||||
{
|
||||
dialog.printInstructions( instructions );
|
||||
}
|
||||
|
||||
|
||||
public static void println( String messageIn )
|
||||
{
|
||||
dialog.displayMessage( messageIn );
|
||||
}
|
||||
|
||||
}// Sysout class
|
||||
|
||||
/**
|
||||
This is part of the standard test machinery. It provides a place for the
|
||||
test instructions to be displayed, and a place for interactive messages
|
||||
to the user to be displayed.
|
||||
To have the test instructions displayed, see Sysout.
|
||||
To have a message to the user be displayed, see Sysout.
|
||||
Do not call anything in this dialog directly.
|
||||
*/
|
||||
class TestDialog extends Dialog
|
||||
{
|
||||
|
||||
TextArea instructionsText;
|
||||
TextArea messageText;
|
||||
int maxStringLength = 80;
|
||||
|
||||
//DO NOT call this directly, go through Sysout
|
||||
public TestDialog( Frame frame, String name )
|
||||
{
|
||||
super( frame, name );
|
||||
int scrollBoth = TextArea.SCROLLBARS_BOTH;
|
||||
instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
|
||||
add( "North", instructionsText );
|
||||
|
||||
messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
|
||||
add("Center", messageText);
|
||||
|
||||
pack();
|
||||
|
||||
show();
|
||||
}// TestDialog()
|
||||
|
||||
//DO NOT call this directly, go through Sysout
|
||||
public void printInstructions( String[] instructions )
|
||||
{
|
||||
//Clear out any current instructions
|
||||
instructionsText.setText( "" );
|
||||
|
||||
//Go down array of instruction strings
|
||||
|
||||
String printStr, remainingStr;
|
||||
for( int i=0; i < instructions.length; i++ )
|
||||
{
|
||||
//chop up each into pieces maxSringLength long
|
||||
remainingStr = instructions[ i ];
|
||||
while( remainingStr.length() > 0 )
|
||||
{
|
||||
//if longer than max then chop off first max chars to print
|
||||
if( remainingStr.length() >= maxStringLength )
|
||||
{
|
||||
//Try to chop on a word boundary
|
||||
int posOfSpace = remainingStr.
|
||||
lastIndexOf( ' ', maxStringLength - 1 );
|
||||
|
||||
if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
|
||||
|
||||
printStr = remainingStr.substring( 0, posOfSpace + 1 );
|
||||
remainingStr = remainingStr.substring( posOfSpace + 1 );
|
||||
}
|
||||
//else just print
|
||||
else
|
||||
{
|
||||
printStr = remainingStr;
|
||||
remainingStr = "";
|
||||
}
|
||||
|
||||
instructionsText.append( printStr + "\n" );
|
||||
|
||||
}// while
|
||||
|
||||
}// for
|
||||
|
||||
}//printInstructions()
|
||||
|
||||
//DO NOT call this directly, go through Sysout
|
||||
public void displayMessage( String messageIn )
|
||||
{
|
||||
messageText.append( messageIn + "\n" );
|
||||
System.out.println(messageIn);
|
||||
}
|
||||
|
||||
}// TestDialog class
|
@ -129,7 +129,7 @@ case `uname -m` in
|
||||
esac
|
||||
|
||||
echo "OS-ARCH is" ${SYST}-${ARCH}
|
||||
${TESTJAVA}${FS}jre${FS}bin${FS}java -fullversion 2>&1
|
||||
${TESTJAVA}${FS}bin${FS}java -fullversion 2>&1
|
||||
|
||||
which ${MAKE} >${NULL} 2>&1
|
||||
if [ "$?" -ne '0' ]
|
||||
@ -156,7 +156,7 @@ esac
|
||||
|
||||
cp ${TESTSRC}${FS}${MAKEFILE} .
|
||||
|
||||
JAVA=${TESTJAVA}${FS}jre${FS}bin${FS}java
|
||||
JAVA=${TESTJAVA}${FS}bin${FS}java
|
||||
JAVAC=${TESTJAVA}${FS}bin${FS}javac
|
||||
JAVAH=${TESTJAVA}${FS}bin${FS}javah
|
||||
|
||||
|
@ -32,7 +32,7 @@ LINK = ld
|
||||
|
||||
J_INC = $(TESTJAVA)/include
|
||||
INCLUDES = -I$(J_INC) -I$(J_INC)/$(SYST) -I.
|
||||
LIBS = -L$(TESTJAVA)/jre/lib/$(ARCH) -ljawt -lX11
|
||||
LIBS = -L$(TESTJAVA)/lib/$(ARCH) -ljawt -lX11
|
||||
|
||||
all: $(CLASSES) libmylib.so
|
||||
|
||||
|
@ -34,6 +34,7 @@ import javax.swing.*;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JButtonInGlassPaneOverlapping
|
||||
*/
|
||||
|
@ -34,6 +34,7 @@ import javax.swing.*;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JButtonOverlapping
|
||||
*/
|
||||
|
@ -33,6 +33,7 @@ import javax.swing.*;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JColorChooserOverlapping
|
||||
*/
|
||||
|
@ -44,6 +44,7 @@ import test.java.awt.regtesthelpers.Util;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JComboBoxOverlapping
|
||||
*/
|
||||
|
@ -35,6 +35,7 @@ import javax.swing.*;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JEditorPaneInGlassPaneOverlapping
|
||||
*/
|
||||
|
@ -33,6 +33,7 @@ import javax.swing.*;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JEditorPaneOverlapping
|
||||
*/
|
||||
|
@ -46,6 +46,7 @@ import test.java.awt.regtesthelpers.Util;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JGlassPaneInternalFrameOverlapping
|
||||
*/
|
||||
|
@ -47,6 +47,7 @@ import test.java.awt.regtesthelpers.Util;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JGlassPaneMoveOverlapping
|
||||
*/
|
||||
|
@ -43,6 +43,7 @@ import test.java.awt.regtesthelpers.Util;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JInternalFrameMoveOverlapping
|
||||
*/
|
||||
|
@ -42,6 +42,7 @@ import test.java.awt.regtesthelpers.Util;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JInternalFrameOverlapping
|
||||
*/
|
||||
|
@ -35,6 +35,7 @@ import javax.swing.*;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JLabelInGlassPaneOverlapping
|
||||
*/
|
||||
|
@ -34,6 +34,7 @@ import javax.swing.*;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JLabelOverlapping
|
||||
*/
|
||||
|
@ -34,6 +34,7 @@ import javax.swing.*;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JListInGlassPaneOverlapping
|
||||
*/
|
||||
|
@ -33,6 +33,7 @@ import javax.swing.*;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JListOverlapping
|
||||
*/
|
||||
|
@ -49,6 +49,7 @@ import test.java.awt.regtesthelpers.Util;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JMenuBarOverlapping
|
||||
*/
|
||||
|
@ -35,6 +35,7 @@ import javax.swing.*;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JPanelInGlassPaneOverlapping
|
||||
*/
|
||||
|
@ -34,6 +34,7 @@ import javax.swing.*;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JPanelOverlapping
|
||||
*/
|
||||
|
@ -46,6 +46,7 @@ import test.java.awt.regtesthelpers.Util;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JPopupMenuOverlapping
|
||||
*/
|
||||
|
@ -35,6 +35,7 @@ import javax.swing.*;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JProgressBarInGlassPaneOverlapping
|
||||
*/
|
||||
|
@ -34,6 +34,7 @@ import javax.swing.*;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JProgressBarOverlapping
|
||||
*/
|
||||
|
@ -38,6 +38,7 @@ import javax.swing.*;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JScrollBarInGlassPaneOverlapping
|
||||
*/
|
||||
|
@ -37,6 +37,7 @@ import javax.swing.*;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JScrollBarOverlapping
|
||||
*/
|
||||
|
@ -44,6 +44,7 @@ import test.java.awt.regtesthelpers.Util;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JScrollPaneOverlapping
|
||||
*/
|
||||
|
@ -35,6 +35,7 @@ import javax.swing.*;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JSliderInGlassPaneOverlapping
|
||||
*/
|
||||
|
@ -34,6 +34,7 @@ import javax.swing.*;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JSliderOverlapping
|
||||
*/
|
||||
|
@ -37,6 +37,7 @@ import javax.swing.event.ChangeListener;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JSpinnerInGlassPaneOverlapping
|
||||
*/
|
||||
|
@ -36,6 +36,7 @@ import javax.swing.event.ChangeListener;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JSpinnerOverlapping
|
||||
*/
|
||||
|
@ -40,7 +40,8 @@ import test.java.awt.regtesthelpers.Util;
|
||||
|
||||
/**
|
||||
* AWT/Swing overlapping test for {@link javax.swing.JSplitPane } component.
|
||||
* <p>This test creates puts heavyweight and lightweight components into different panels and test if splitter image and components itself are drawn correctly.
|
||||
* <p>This test puts heavyweight and lightweight components into different
|
||||
* panels and test if splitter image and components itself are drawn correctly.
|
||||
* <p>See base class for test info.
|
||||
*/
|
||||
/*
|
||||
@ -50,6 +51,7 @@ import test.java.awt.regtesthelpers.Util;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JSplitPaneOverlapping
|
||||
*/
|
||||
|
@ -37,6 +37,7 @@ import javax.swing.event.TableModelListener;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JTableInGlassPaneOverlapping
|
||||
*/
|
||||
|
@ -33,6 +33,7 @@ import javax.swing.*;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JTableOverlapping
|
||||
*/
|
||||
|
@ -35,6 +35,7 @@ import javax.swing.*;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JTextAreaInGlassPaneOverlapping
|
||||
*/
|
||||
|
@ -34,6 +34,7 @@ import javax.swing.*;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JTextAreaOverlapping
|
||||
*/
|
||||
|
@ -35,6 +35,7 @@ import javax.swing.*;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JTextFieldInGlassPaneOverlapping
|
||||
*/
|
||||
|
@ -34,6 +34,7 @@ import javax.swing.*;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JTextFieldOverlapping
|
||||
*/
|
||||
|
@ -34,6 +34,7 @@ import javax.swing.*;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JToggleButtonInGlassPaneOverlapping
|
||||
*/
|
||||
|
@ -33,6 +33,7 @@ import javax.swing.*;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main JToggleButtonOverlapping
|
||||
*/
|
||||
|
@ -43,6 +43,7 @@ import test.java.awt.regtesthelpers.Util;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main MixingFrameResizing
|
||||
*/
|
||||
|
@ -47,6 +47,7 @@ import test.java.awt.regtesthelpers.Util;
|
||||
@summary Opaque overlapping test for each AWT component
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/com.sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
java.desktop/sun.awt
|
||||
@build Util
|
||||
@run main OpaqueOverlapping
|
||||
|
@ -33,6 +33,7 @@
|
||||
@summary Opaque overlapping test for Choice AWT component
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/com.sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
java.desktop/sun.awt
|
||||
@build Util
|
||||
@run main OpaqueOverlappingChoice
|
||||
|
@ -52,6 +52,7 @@ import test.java.awt.regtesthelpers.Util;
|
||||
@author sergey.grinev@oracle.com: area=awt.mixing
|
||||
@library ../../regtesthelpers
|
||||
@modules java.desktop/sun.awt
|
||||
java.desktop/java.awt.peer
|
||||
@build Util
|
||||
@run main ViewportOverlapping
|
||||
*/
|
||||
|
@ -29,6 +29,8 @@
|
||||
/* @test
|
||||
* @bug 7129742
|
||||
* @summary Focus in non-editable TextArea is not shown on Linux.
|
||||
* @modules java.desktop/sun.awt
|
||||
* java.desktop/java.awt.peer
|
||||
* @author Sean Chou
|
||||
*/
|
||||
|
||||
|
@ -36,6 +36,8 @@ import static java.awt.event.InputEvent.BUTTON1_DOWN_MASK;
|
||||
* @author Hendrik Schreiber
|
||||
* @summary [macosx] Drag image of TransferHandler does not honor
|
||||
* MultiResolutionImage
|
||||
* @modules java.desktop/sun.awt.image
|
||||
* java.desktop/sun.java2d
|
||||
* @run main MultiResolutionDragImageTest TEST_DRAG
|
||||
*/
|
||||
public class MultiResolutionDragImageTest {
|
||||
@ -169,4 +171,4 @@ public class MultiResolutionDragImageTest {
|
||||
graphics.dispose();
|
||||
return image;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
209
jdk/test/java/awt/font/GlyphVector/TestLayoutFlags.java
Normal file
209
jdk/test/java/awt/font/GlyphVector/TestLayoutFlags.java
Normal file
@ -0,0 +1,209 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 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
|
||||
* 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 4328745 5090704
|
||||
@summary exercise getLayoutFlags, getGlyphCharIndex, getGlyphCharIndices
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.font.*;
|
||||
import java.awt.geom.*;
|
||||
|
||||
public class TestLayoutFlags {
|
||||
|
||||
static public void main(String[] args) {
|
||||
new TestLayoutFlags().runTest();
|
||||
}
|
||||
|
||||
void runTest() {
|
||||
|
||||
Font font = new Font("Lucida Sans", Font.PLAIN, 24);
|
||||
|
||||
String latin1 = "This is a latin1 string"; // none
|
||||
String hebrew = "\u05d0\u05d1\u05d2\u05d3"; // rtl
|
||||
String arabic = "\u0646\u0644\u0622\u0646"; // rtl + mc/g
|
||||
String hindi = "\u0939\u093f\u0923\u094d\u0921\u0940"; // ltr + reorder
|
||||
// String tamil = "\u0b9c\u0bcb"; // ltr + mg/c + split
|
||||
|
||||
FontRenderContext frc = new FontRenderContext(null, true, true);
|
||||
|
||||
// get glyph char indices needs to initializes layoutFlags before use (5090704)
|
||||
{
|
||||
GlyphVector gv = font.createGlyphVector(frc, "abcde");
|
||||
int ix = gv.getGlyphCharIndex(0);
|
||||
if (ix != 0) {
|
||||
throw new Error("glyph 0 incorrectly mapped to char " + ix);
|
||||
}
|
||||
int[] ixs = gv.getGlyphCharIndices(0, gv.getNumGlyphs(), null);
|
||||
for (int i = 0; i < ixs.length; ++i) {
|
||||
if (ixs[i] != i) {
|
||||
throw new Error("glyph " + i + " incorrectly mapped to char " + ixs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GlyphVector latinGV = makeGlyphVector("Lucida Sans", frc, latin1, false, 1 /* ScriptRun.LATIN */);
|
||||
GlyphVector hebrewGV = makeGlyphVector("Lucida Sans", frc, hebrew, true, 5 /* ScriptRun.HEBREW */);
|
||||
GlyphVector arabicGV = makeGlyphVector("Lucida Sans", frc, arabic, true, 6 /* ScriptRun.ARABIC */);
|
||||
GlyphVector hindiGV = makeGlyphVector("Lucida Sans", frc, hindi, false, 7 /* ScriptRun.DEVANAGARI */);
|
||||
// GlyphVector tamilGV = makeGlyphVector("Devanagari MT for IBM", frc, tamil, false, 12 /* ScriptRun.TAMIL */);
|
||||
|
||||
GlyphVector latinPos = font.createGlyphVector(frc, latin1);
|
||||
Point2D pt = latinPos.getGlyphPosition(0);
|
||||
pt.setLocation(pt.getX(), pt.getY() + 1.0);
|
||||
latinPos.setGlyphPosition(0, pt);
|
||||
|
||||
GlyphVector latinTrans = font.createGlyphVector(frc, latin1);
|
||||
latinTrans.setGlyphTransform(0, AffineTransform.getRotateInstance(.15));
|
||||
|
||||
test("latin", latinGV, GlyphVector.FLAG_HAS_POSITION_ADJUSTMENTS);
|
||||
test("hebrew", hebrewGV, GlyphVector.FLAG_RUN_RTL |
|
||||
GlyphVector.FLAG_HAS_POSITION_ADJUSTMENTS);
|
||||
test("arabic", arabicGV, GlyphVector.FLAG_RUN_RTL |
|
||||
GlyphVector.FLAG_HAS_POSITION_ADJUSTMENTS);
|
||||
test("hindi", hindiGV, GlyphVector.FLAG_COMPLEX_GLYPHS |
|
||||
GlyphVector.FLAG_HAS_POSITION_ADJUSTMENTS);
|
||||
// test("tamil", tamilGV, GlyphVector.FLAG_COMPLEX_GLYPHS);
|
||||
test("pos", latinPos, GlyphVector.FLAG_HAS_POSITION_ADJUSTMENTS);
|
||||
test("trans", latinTrans, GlyphVector.FLAG_HAS_TRANSFORMS);
|
||||
}
|
||||
|
||||
GlyphVector makeGlyphVector(String fontname, FontRenderContext frc, String text, boolean rtl, int script) {
|
||||
Font font = new Font(fontname, Font.PLAIN, 14);
|
||||
System.out.println("asking for " + fontname + " and got " + font.getFontName());
|
||||
int flags = rtl ? 1 : 0;
|
||||
return font.layoutGlyphVector(frc, text.toCharArray(), 0, text.length(), flags);
|
||||
}
|
||||
|
||||
void test(String name, GlyphVector gv, int expectedFlags) {
|
||||
expectedFlags &= gv.FLAG_MASK;
|
||||
int computedFlags = computeFlags(gv) & gv.FLAG_MASK;
|
||||
int actualFlags = gv.getLayoutFlags() & gv.FLAG_MASK;
|
||||
|
||||
System.out.println("\n*** " + name + " ***");
|
||||
System.out.println(" test flags");
|
||||
System.out.print("expected ");
|
||||
printFlags(expectedFlags);
|
||||
System.out.print("computed ");
|
||||
printFlags(computedFlags);
|
||||
System.out.print(" actual ");
|
||||
printFlags(actualFlags);
|
||||
|
||||
if (expectedFlags != actualFlags) {
|
||||
throw new Error("layout flags in test: " + name +
|
||||
" expected: " + Integer.toHexString(expectedFlags) +
|
||||
" but got: " + Integer.toHexString(actualFlags));
|
||||
}
|
||||
}
|
||||
|
||||
static public void printFlags(int flags) {
|
||||
System.out.print("flags:");
|
||||
if ((flags & GlyphVector.FLAG_HAS_POSITION_ADJUSTMENTS) != 0) {
|
||||
System.out.print(" pos");
|
||||
}
|
||||
if ((flags & GlyphVector.FLAG_HAS_TRANSFORMS) != 0) {
|
||||
System.out.print(" trans");
|
||||
}
|
||||
if ((flags & GlyphVector.FLAG_RUN_RTL) != 0) {
|
||||
System.out.print(" rtl");
|
||||
}
|
||||
if ((flags & GlyphVector.FLAG_COMPLEX_GLYPHS) != 0) {
|
||||
System.out.print(" complex");
|
||||
}
|
||||
if ((flags & GlyphVector.FLAG_MASK) == 0) {
|
||||
System.out.print(" none");
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
int computeFlags(GlyphVector gv) {
|
||||
validateCharIndexMethods(gv);
|
||||
|
||||
int result = 0;
|
||||
if (glyphsAreRTL(gv)) {
|
||||
result |= GlyphVector.FLAG_RUN_RTL;
|
||||
}
|
||||
if (hasComplexGlyphs(gv)) {
|
||||
result |= GlyphVector.FLAG_COMPLEX_GLYPHS;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* throw an exception if getGlyphCharIndices returns a different result than
|
||||
* you get from iterating through getGlyphCharIndex one at a time.
|
||||
*/
|
||||
void validateCharIndexMethods(GlyphVector gv) {
|
||||
int[] indices = gv.getGlyphCharIndices(0, gv.getNumGlyphs(), null);
|
||||
for (int i = 0; i < gv.getNumGlyphs(); ++i) {
|
||||
if (gv.getGlyphCharIndex(i) != indices[i]) {
|
||||
throw new Error("glyph index mismatch at " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the glyph indices are pure ltr
|
||||
*/
|
||||
boolean glyphsAreLTR(GlyphVector gv) {
|
||||
int[] indices = gv.getGlyphCharIndices(0, gv.getNumGlyphs(), null);
|
||||
for (int i = 0; i < indices.length; ++i) {
|
||||
if (indices[i] != i) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the glyph indices are pure rtl
|
||||
*/
|
||||
boolean glyphsAreRTL(GlyphVector gv) {
|
||||
int[] indices = gv.getGlyphCharIndices(0, gv.getNumGlyphs(), null);
|
||||
for (int i = 0; i < indices.length; ++i) {
|
||||
if (indices[i] != indices.length - i - 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if there is a local reordering (the run is not ltr or rtl).
|
||||
* !!! We can't have mixed bidi runs in the glyphs.
|
||||
*/
|
||||
boolean hasComplexGlyphs(GlyphVector gv) {
|
||||
return !glyphsAreLTR(gv) && !glyphsAreRTL(gv);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
rect getPixelBounds(frc, x, y)
|
||||
rect getGlyphPixelBounds(frc, int, x, y)
|
||||
getGlyphOutline(int index, x, y)
|
||||
getGlyphInfo()
|
||||
*/
|
160
jdk/test/java/awt/font/Underline/UnderlineTest.java
Normal file
160
jdk/test/java/awt/font/Underline/UnderlineTest.java
Normal file
@ -0,0 +1,160 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 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
|
||||
* 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 6216010
|
||||
* @summary check to see that underline thickness scales.
|
||||
* @run main UnderlineTest
|
||||
*/
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.font.FontRenderContext;
|
||||
import java.awt.font.LineMetrics;
|
||||
import java.awt.font.TextAttribute;
|
||||
import java.awt.font.TextLayout;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.util.HashMap;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
public class UnderlineTest {
|
||||
static class FontsPanel extends Container {
|
||||
FontsPanel(Font[] fonts) {
|
||||
setLayout(new GridLayout(0, 1));
|
||||
for (int i = 0; i < fonts.length; ++i) {
|
||||
add(new FontPanel(fonts[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static String fps = "Stellar glyphs";
|
||||
static Dimension fpd = new Dimension(600, 120);
|
||||
static class FontPanel extends JComponent {
|
||||
Font f;
|
||||
FontPanel(Font f) {
|
||||
this.f = f;
|
||||
setPreferredSize(fpd);
|
||||
setMinimumSize(fpd);
|
||||
setMaximumSize(fpd);
|
||||
setSize(fpd);
|
||||
}
|
||||
|
||||
public void paintComponent(Graphics g) {
|
||||
g.setColor(Color.WHITE);
|
||||
g.fillRect(0, 0, fpd.width, fpd.height);
|
||||
|
||||
g.setColor(Color.RED);
|
||||
FontRenderContext frc = ((Graphics2D)g).getFontRenderContext();
|
||||
LineMetrics lm = f.getLineMetrics(fps, frc);
|
||||
int h = (int)(fpd.height - 20 - lm.getAscent());
|
||||
g.drawLine(20, h, fpd.width - 20, h);
|
||||
h = fpd.height - 20;
|
||||
g.drawLine(20, h, fpd.width - 20, h);
|
||||
h = (int)(fpd.height - 20 + lm.getDescent());
|
||||
g.drawLine(20, h, fpd.width - 20, h);
|
||||
|
||||
g.setColor(Color.BLACK);
|
||||
g.setFont(f);
|
||||
g.drawString(fps, 50, fpd.height - 20);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
String fontName = "Lucida Sans";
|
||||
if (args.length > 0) {
|
||||
fontName = args[0];
|
||||
}
|
||||
FontRenderContext frc = new FontRenderContext(null, false, false);
|
||||
FontRenderContext frc2 = new FontRenderContext(AffineTransform.getScaleInstance(1.5, 1.5), false, false);
|
||||
|
||||
Font font0 = new Font(fontName, 0, 20);
|
||||
HashMap map = new HashMap();
|
||||
map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
|
||||
map.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON);
|
||||
Font font = font0.deriveFont(map);
|
||||
|
||||
System.out.println("Using font: " + font);
|
||||
|
||||
double rot = -Math.PI/4;
|
||||
AffineTransform scrtx = AffineTransform.getRotateInstance(rot);
|
||||
scrtx.scale(1, 2);
|
||||
|
||||
Font[] fonts = {
|
||||
font.deriveFont(1f),
|
||||
font.deriveFont(20f),
|
||||
font.deriveFont(40f),
|
||||
font.deriveFont(80f),
|
||||
font.deriveFont(AffineTransform.getRotateInstance(rot)),
|
||||
font.deriveFont(AffineTransform.getScaleInstance(1, 2)),
|
||||
font.deriveFont(AffineTransform.getScaleInstance(2, 4)),
|
||||
font.deriveFont(scrtx),
|
||||
};
|
||||
|
||||
LineMetrics[] metrics = new LineMetrics[fonts.length * 2];
|
||||
for (int i = 0; i < metrics.length; ++i) {
|
||||
Font f = fonts[i % fonts.length];
|
||||
FontRenderContext frcx = i < fonts.length ? frc : frc2;
|
||||
metrics[i] = f.getLineMetrics("X", frcx);
|
||||
// dumpMetrics("Metrics for " + f.getSize2D() + " pt. font,\n tx: " +
|
||||
// f.getTransform() + ",\n frctx: " + frcx.getTransform(), metrics[i]);
|
||||
}
|
||||
|
||||
// test for linear scale
|
||||
// this seems to work, might need to get fancy to deal with last-significant-bit issues?
|
||||
double ds1 = metrics[2].getStrikethroughOffset() - metrics[1].getStrikethroughOffset();
|
||||
double du1 = metrics[2].getUnderlineThickness() - metrics[1].getUnderlineThickness();
|
||||
double ds2 = metrics[3].getStrikethroughOffset() - metrics[2].getStrikethroughOffset();
|
||||
double du2 = metrics[3].getUnderlineThickness() - metrics[2].getUnderlineThickness();
|
||||
if (ds2 != ds1 * 2 || du2 != du1 * 2) {
|
||||
throw new IllegalStateException("non-linear scale: " + ds1 + " / " + ds2 + ", " +
|
||||
du1 + " / " + du2);
|
||||
}
|
||||
|
||||
JFrame jf = new JFrame("Fonts");
|
||||
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
jf.add(new JScrollPane(new FontsPanel(fonts)));
|
||||
jf.pack();
|
||||
jf.setVisible(true);
|
||||
}
|
||||
|
||||
static void dumpMetrics(String header, LineMetrics lm) {
|
||||
if (header != null) {
|
||||
System.out.println(header);
|
||||
}
|
||||
System.out.println("asc: " + lm.getAscent());
|
||||
System.out.println("dsc: " + lm.getDescent());
|
||||
System.out.println("ulo: " + lm.getUnderlineOffset());
|
||||
System.out.println("ult: " + lm.getUnderlineThickness());
|
||||
System.out.println("sto: " + lm.getStrikethroughOffset());
|
||||
System.out.println("stt: " + lm.getStrikethroughThickness());
|
||||
}
|
||||
}
|
@ -26,6 +26,8 @@
|
||||
@bug 6359129
|
||||
@summary REGRESSION: Popup menus dont respond to selections when extend outside Applet
|
||||
@author oleg.sukhodolsky area=awt.grab
|
||||
@modules java.desktop/java.awt.peer
|
||||
java.desktop/sun.awt
|
||||
@library ../../regtesthelpers
|
||||
@build Util UtilInternal
|
||||
@run main EmbeddedFrameTest1
|
||||
|
@ -27,6 +27,8 @@ import javax.swing.*;
|
||||
import java.io.*;
|
||||
import java.util.logging.*;
|
||||
import sun.awt.WindowIDProvider;
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.AWTAccessor.ComponentAccessor;
|
||||
import java.awt.dnd.*;
|
||||
import java.awt.datatransfer.*;
|
||||
|
||||
@ -182,7 +184,8 @@ public abstract class TestXEmbedServer {
|
||||
client.setBackground(new Color(30, 220, 40));
|
||||
clientCont.add(client);
|
||||
clientCont.validate();
|
||||
WindowIDProvider pid = (WindowIDProvider)client.getPeer();
|
||||
final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
|
||||
WindowIDProvider pid = (WindowIDProvider)acc.getPeer(client);
|
||||
log.fine("Added XEmbed server(Canvas) with X window ID " + pid.getWindow());
|
||||
Rectangle toFocusBounds = toFocus.getBounds();
|
||||
toFocusBounds.setLocation(toFocus.getLocationOnScreen());
|
||||
|
@ -33,6 +33,7 @@ import sun.swing.SwingUtilities2;
|
||||
* @bug 8080628
|
||||
* @summary No mnemonics on Open and Save buttons in JFileChooser.
|
||||
* @author Alexey Ivanov
|
||||
* @modules java.desktop/sun.swing
|
||||
* @run main bug8080628
|
||||
*/
|
||||
public class bug8080628 {
|
||||
|
@ -25,6 +25,7 @@
|
||||
*
|
||||
* @bug 6608456
|
||||
* @author Igor Kushnirskiy
|
||||
* @modules java.desktop/com.sun.java.swing
|
||||
* @summary tests if delegate RepaintManager gets invoked.
|
||||
*/
|
||||
|
||||
|
@ -34,6 +34,7 @@ import sun.java2d.SunGraphicsEnvironment;
|
||||
/**
|
||||
* @test
|
||||
* @bug 8041654
|
||||
* @modules java.desktop/sun.java2d
|
||||
* @run main/othervm -Xmx80m DisplayListenerLeak
|
||||
*/
|
||||
public final class DisplayListenerLeak {
|
||||
@ -79,4 +80,4 @@ public final class DisplayListenerLeak {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
* @summary verify the existence of the method
|
||||
* SunGraphicsEnvironment.useAlternateFontforJALocales
|
||||
*
|
||||
* @modules java.desktop/sun.java2d
|
||||
* @run main/othervm TestSGEuseAlternateFontforJALocales
|
||||
* @run main/othervm -Dfile.encoding=windows-31j -Duser.language=ja -Duser.country=JA TestSGEuseAlternateFontforJALocales
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user