1 // Tags: JDK1.2 |
|
2 |
|
3 // Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com> |
|
4 |
|
5 // This file is part of Mauve. |
|
6 |
|
7 // Mauve is free software; you can redistribute it and/or modify |
|
8 // it under the terms of the GNU General Public License as published by |
|
9 // the Free Software Foundation; either version 2, or (at your option) |
|
10 // any later version. |
|
11 |
|
12 // Mauve is distributed in the hope that it will be useful, |
|
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 // GNU General Public License for more details. |
|
16 |
|
17 // You should have received a copy of the GNU General Public License |
|
18 // along with Mauve; see the file COPYING. If not, write to |
|
19 // the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
20 // Boston, MA 02110-1301 USA. |
|
21 |
|
22 package gnu.testlet.java.text.AttributedCharacterIterator; |
|
23 |
|
24 import gnu.testlet.TestHarness; |
|
25 import gnu.testlet.Testlet; |
|
26 |
|
27 import java.awt.Color; |
|
28 import java.awt.font.TextAttribute; |
|
29 import java.text.AttributedCharacterIterator; |
|
30 import java.text.AttributedString; |
|
31 import java.util.Set; |
|
32 |
|
33 /** |
|
34 * Some checks for the getRunStart() methods in the |
|
35 * {@link AttributedCharacterIterator} interface. |
|
36 */ |
|
37 public class getRunStart implements Testlet |
|
38 { |
|
39 |
|
40 /** |
|
41 * Runs the test using the specified harness. |
|
42 * |
|
43 * @param harness the test harness (<code>null</code> not allowed). |
|
44 */ |
|
45 public void test(TestHarness harness) |
|
46 { |
|
47 test1(harness); |
|
48 test2(harness); |
|
49 test3(harness); |
|
50 } |
|
51 |
|
52 private void test1(TestHarness harness) |
|
53 { |
|
54 harness.checkPoint("getRunStart();"); |
|
55 AttributedString as = new AttributedString("ABCDEFG"); |
|
56 as.addAttribute(TextAttribute.LANGUAGE, "English"); |
|
57 as.addAttribute(TextAttribute.FOREGROUND, Color.red, 2, 4); |
|
58 AttributedCharacterIterator aci = as.getIterator(); |
|
59 harness.check(aci.getRunStart(), 0); |
|
60 aci.setIndex(3); |
|
61 harness.check(aci.getRunStart(), 2); |
|
62 } |
|
63 |
|
64 private void test2(TestHarness harness) |
|
65 { |
|
66 harness.checkPoint("getRunStart(AttributedCharacterIterator.Attribute);"); |
|
67 AttributedString as = new AttributedString("ABCDEFG"); |
|
68 as.addAttribute(TextAttribute.LANGUAGE, "English"); |
|
69 as.addAttribute(TextAttribute.FOREGROUND, Color.red, 2, 4); |
|
70 AttributedCharacterIterator aci = as.getIterator(); |
|
71 harness.check(aci.getRunStart(TextAttribute.LANGUAGE), 0); |
|
72 aci.setIndex(3); |
|
73 harness.check(aci.getRunStart(TextAttribute.FOREGROUND), 2); |
|
74 } |
|
75 |
|
76 private void test3(TestHarness harness) |
|
77 { |
|
78 harness.checkPoint("getRunStart(Set);"); |
|
79 AttributedString as = new AttributedString("ABCDEFG"); |
|
80 as.addAttribute(TextAttribute.LANGUAGE, "English"); |
|
81 AttributedCharacterIterator aci = as.getIterator(); |
|
82 |
|
83 // try null set |
|
84 harness.check(aci.getRunStart((Set) null), 0); |
|
85 |
|
86 AttributedCharacterIterator aci2 = as.getIterator(null, 4, 7); |
|
87 harness.check(aci2.getRunStart((Set) null), 4); |
|
88 } |
|
89 |
|
90 } |
|