1 //Tags: JDK1.4 |
|
2 |
|
3 //Copyright (C) 2005 Free Software Foundation, Inc. |
|
4 //Written by Wolfgang Baer (WBaer@gmx.de) |
|
5 |
|
6 //This file is part of Mauve. |
|
7 |
|
8 //Mauve is free software; you can redistribute it and/or modify |
|
9 //it under the terms of the GNU General Public License as published by |
|
10 //the Free Software Foundation; either version 2, or (at your option) |
|
11 //any later version. |
|
12 |
|
13 //Mauve is distributed in the hope that it will be useful, |
|
14 //but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 //GNU General Public License for more details. |
|
17 |
|
18 //You should have received a copy of the GNU General Public License |
|
19 //along with Mauve; see the file COPYING. If not, write to |
|
20 //the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
|
21 //Boston, MA, 02110-1301 USA. |
|
22 |
|
23 package gnu.testlet.javax.print.attribute.Size2DSyntax; |
|
24 |
|
25 import javax.print.attribute.Size2DSyntax; |
|
26 |
|
27 import gnu.testlet.TestHarness; |
|
28 import gnu.testlet.Testlet; |
|
29 |
|
30 /** |
|
31 * Tests all the correct unit conversions through |
|
32 * the toString methods. |
|
33 */ |
|
34 public class simple implements Testlet |
|
35 { |
|
36 // Test class making abstract class to test usable. |
|
37 public class TestSize2DSyntax extends Size2DSyntax |
|
38 { |
|
39 public TestSize2DSyntax(float x, float y, int units) |
|
40 { |
|
41 super(x, y, units); |
|
42 } |
|
43 |
|
44 public TestSize2DSyntax(int x, int y, int units) |
|
45 { |
|
46 super(x, y, units); |
|
47 } |
|
48 } |
|
49 |
|
50 public void test(TestHarness harness) |
|
51 { |
|
52 TestSize2DSyntax floatInch = |
|
53 new TestSize2DSyntax(55.6f, 232.1f, Size2DSyntax.INCH); |
|
54 TestSize2DSyntax intInch = new TestSize2DSyntax(8, 12, Size2DSyntax.INCH); |
|
55 TestSize2DSyntax floatMM = |
|
56 new TestSize2DSyntax(55.6f, 232.1f, Size2DSyntax.MM); |
|
57 TestSize2DSyntax intMM = new TestSize2DSyntax(210, 297, Size2DSyntax.MM); |
|
58 |
|
59 harness.checkPoint("units conversions/toString"); |
|
60 harness.check(floatInch.toString(), "1412240x5895340 um"); |
|
61 harness.check(intInch.toString(), "203200x304800 um"); |
|
62 harness.check(floatMM.toString(), "55600x232100 um"); |
|
63 harness.check(intMM.toString(), "210000x297000 um"); |
|
64 |
|
65 harness.check(floatInch.toString(Size2DSyntax.INCH, null), "55.6x232.1"); |
|
66 harness.check(intInch.toString(Size2DSyntax.INCH, null), "8.0x12.0"); |
|
67 harness.check(floatMM.toString(Size2DSyntax.INCH, null), |
|
68 "2.1889763x9.137795"); |
|
69 harness.check(intMM.toString(Size2DSyntax.INCH, null), |
|
70 "8.267716x11.692913"); |
|
71 |
|
72 harness.check(floatInch.toString(Size2DSyntax.MM, "mm"), |
|
73 "1412.24x5895.34 mm"); |
|
74 harness.check(intInch.toString(Size2DSyntax.MM, "mm"), "203.2x304.8 mm"); |
|
75 harness.check(floatMM.toString(Size2DSyntax.MM, "mm"), "55.6x232.1 mm"); |
|
76 harness.check(intMM.toString(Size2DSyntax.MM, "mm"), "210.0x297.0 mm"); |
|
77 } |
|
78 |
|
79 } |
|