author | jjg |
Thu, 14 Dec 2017 13:16:33 -0800 | |
changeset 48340 | 959f2f7cbaa6 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
10089
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
1 |
/* |
40679
5378433ac23f
8164859: Fix module dependences in java/text tests
shurailine
parents:
10089
diff
changeset
|
2 |
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. |
10089
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
4 |
* |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
8 |
* |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
13 |
* accompanied this code). |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
14 |
* |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
18 |
* |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
21 |
* questions. |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
22 |
*/ |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
23 |
|
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
24 |
/* |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
25 |
* @test |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
26 |
* @bug 7042148 |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
27 |
* @summary verify that Bidi.baseIsLeftToRight() returns the correct value even if an incorrect position is set in the given AttributedCharacterIterator. |
40679
5378433ac23f
8164859: Fix module dependences in java/text tests
shurailine
parents:
10089
diff
changeset
|
28 |
* @modules java.desktop |
10089
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
29 |
*/ |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
30 |
import java.awt.font.*; |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
31 |
import java.text.*; |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
32 |
import java.util.*; |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
33 |
|
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
34 |
public class Bug7042148 { |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
35 |
|
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
36 |
private static boolean err = false; |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
37 |
|
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
38 |
public static void main(String[] args) { |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
39 |
testDirection(); |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
40 |
|
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
41 |
if (err) { |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
42 |
throw new RuntimeException("Failed"); |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
43 |
} else { |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
44 |
System.out.println("Passed."); |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
45 |
} |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
46 |
} |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
47 |
|
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
48 |
private static void testDirection() { |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
49 |
Map attrLTR = new HashMap(); |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
50 |
attrLTR.put(TextAttribute.RUN_DIRECTION, |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
51 |
TextAttribute.RUN_DIRECTION_LTR); |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
52 |
Map attrRTL = new HashMap(); |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
53 |
attrRTL.put(TextAttribute.RUN_DIRECTION, |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
54 |
TextAttribute.RUN_DIRECTION_RTL); |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
55 |
|
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
56 |
String str1 = "A\u05e0"; |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
57 |
String str2 = "\u05e0B"; |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
58 |
|
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
59 |
test(str1, attrLTR, Bidi.DIRECTION_LEFT_TO_RIGHT); |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
60 |
test(str1, attrRTL, Bidi.DIRECTION_RIGHT_TO_LEFT); |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
61 |
test(str2, attrLTR, Bidi.DIRECTION_LEFT_TO_RIGHT); |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
62 |
test(str2, attrRTL, Bidi.DIRECTION_RIGHT_TO_LEFT); |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
63 |
} |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
64 |
|
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
65 |
private static void test(String text, Map attr, int dirFlag) { |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
66 |
boolean expected = (dirFlag == Bidi.DIRECTION_LEFT_TO_RIGHT); |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
67 |
|
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
68 |
Bidi bidi = new Bidi(text, dirFlag); |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
69 |
boolean got = bidi.baseIsLeftToRight(); |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
70 |
if (got != expected) { |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
71 |
err = true; |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
72 |
System.err.println("wrong Bidi(String, int).baseIsLeftToRight() value: " + |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
73 |
"\n\ttext=" + text + |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
74 |
"\n\tExpected=" + expected + |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
75 |
"\n\tGot=" + got); |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
76 |
} |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
77 |
|
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
78 |
AttributedString as = new AttributedString(text, attr); |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
79 |
AttributedCharacterIterator itr = as.getIterator(); |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
80 |
itr.last(); |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
81 |
itr.next(); |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
82 |
bidi = new Bidi(itr); |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
83 |
got = bidi.baseIsLeftToRight(); |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
84 |
if (got != expected) { |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
85 |
err = true; |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
86 |
System.err.println("Wrong Bidi(AttributedCharacterIterator).baseIsLeftToRight() value: " + |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
87 |
"\n\ttext=" + text + |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
88 |
"\n\tExpected=" + expected + |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
89 |
"\n\tGot=" + got); |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
90 |
} |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
91 |
} |
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
92 |
|
297652d14d44
7042148: closed/java/awt/font/TextLayout/CheckLayoutLTR.java failed
peytoia
parents:
diff
changeset
|
93 |
} |