author | rchamyal |
Fri, 13 Nov 2015 18:46:16 +0400 | |
changeset 34396 | ab88d1b63a81 |
parent 29004 | 96b5dc94d927 |
child 40128 | e635645d2a8a |
permissions | -rw-r--r-- |
29004
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
1 |
/* |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
4 |
* |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
8 |
* |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
13 |
* accompanied this code). |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
14 |
* |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
18 |
* |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
21 |
* questions. |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
22 |
*/ |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
23 |
|
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
24 |
import java.awt.Graphics; |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
25 |
import java.awt.Graphics2D; |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
26 |
import java.awt.Robot; |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
27 |
import java.awt.image.BufferedImage; |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
28 |
import java.io.File; |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
29 |
|
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
30 |
import javax.imageio.ImageIO; |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
31 |
import javax.swing.JFrame; |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
32 |
import javax.swing.JLabel; |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
33 |
import javax.swing.SwingUtilities; |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
34 |
|
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
35 |
import static java.awt.image.BufferedImage.TYPE_INT_ARGB; |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
36 |
|
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
37 |
/** |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
38 |
* @test |
34396
ab88d1b63a81
8079253: Test javax/swing/SwingUtilities/TestBadBreak/TestBadBreak.java fails
rchamyal
parents:
29004
diff
changeset
|
39 |
* @bug 8015085 8079253 |
29004
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
40 |
* @summary Shortening via " ... " is broken for Strings containing a combining |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
41 |
* diaeresis. |
34396
ab88d1b63a81
8079253: Test javax/swing/SwingUtilities/TestBadBreak/TestBadBreak.java fails
rchamyal
parents:
29004
diff
changeset
|
42 |
* @run main TestBadBreak |
29004
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
43 |
*/ |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
44 |
public class TestBadBreak { |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
45 |
|
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
46 |
static JFrame frame; |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
47 |
static Robot robot; |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
48 |
static final String withCombiningDiaeresis = "123p://.aaaaaaaaaaaaaaaaaaaaaa.123/a\u0308" ; |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
49 |
static final String withoutCombiningDiaeresis = "123p://.aaaaaaaaaaaaaaaaaaaaaa.123/\u00E4" ; |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
50 |
|
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
51 |
public static void main(final String[] args) throws Exception { |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
52 |
robot = new Robot(); |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
53 |
final BufferedImage bi1 = new BufferedImage(200, 90, TYPE_INT_ARGB); |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
54 |
final BufferedImage bi2 = new BufferedImage(200, 90, TYPE_INT_ARGB); |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
55 |
test(withCombiningDiaeresis, bi1); |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
56 |
test(withoutCombiningDiaeresis, bi2); |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
57 |
for (int x = 0; x < bi1.getWidth(); ++x) { |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
58 |
for (int y = 0; y < bi1.getHeight(); ++y) { |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
59 |
if (bi1.getRGB(x, y) != bi2.getRGB(x, y)) { |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
60 |
ImageIO.write(bi1, "png", new File("image1.png")); |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
61 |
ImageIO.write(bi2, "png", new File("image2.png")); |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
62 |
throw new RuntimeException("Wrong color"); |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
63 |
} |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
64 |
} |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
65 |
} |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
66 |
} |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
67 |
|
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
68 |
private static void test(final String text, final BufferedImage i1) |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
69 |
throws Exception { |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
70 |
SwingUtilities.invokeAndWait(new Runnable() { |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
71 |
@Override |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
72 |
public void run() { |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
73 |
frame = new JFrame(); |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
74 |
final JLabel label = new JLabel(text) { |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
75 |
@Override |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
76 |
protected void paintComponent(Graphics g) { |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
77 |
Graphics2D g2d = i1.createGraphics(); |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
78 |
super.paintComponent(g2d); |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
79 |
g2d.dispose(); |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
80 |
} |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
81 |
}; |
34396
ab88d1b63a81
8079253: Test javax/swing/SwingUtilities/TestBadBreak/TestBadBreak.java fails
rchamyal
parents:
29004
diff
changeset
|
82 |
label.setOpaque(true); |
29004
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
83 |
frame.getContentPane().add(label); |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
84 |
frame.setBounds(200, 200, 200, 90); |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
85 |
} |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
86 |
}); |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
87 |
robot.waitForIdle(); |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
88 |
SwingUtilities.invokeAndWait(() -> frame.setVisible(true)); |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
89 |
robot.waitForIdle(); |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
90 |
SwingUtilities.invokeAndWait(frame::dispose); |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
91 |
robot.waitForIdle(); |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
92 |
} |
96b5dc94d927
8015085: [macosx] Label shortening via " ... " broken when String contains combining diaeresis
serb
parents:
diff
changeset
|
93 |
} |