001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Denis M. Kishenko
019: * @version $Revision$
020: */package java.awt.geom;
021:
022: import java.awt.Rectangle;
023: import java.awt.geom.Arc2D;
024:
025: public class Arc2DDoubleTest extends GeomTestCase {
026:
027: Arc2D.Double a;
028:
029: public Arc2DDoubleTest(String name) {
030: super (name);
031: }
032:
033: @Override
034: protected void setUp() throws Exception {
035: super .setUp();
036: a = new Arc2D.Double(1, 2, 3, 4, 5, 6, Arc2D.PIE);
037: }
038:
039: @Override
040: protected void tearDown() throws Exception {
041: a = null;
042: super .tearDown();
043: }
044:
045: public void testCreate1() {
046: assertEquals(new Arc2D.Double(0, 0, 0, 0, 0, 0, Arc2D.OPEN),
047: new Arc2D.Double());
048: }
049:
050: public void testCreate2() {
051: assertEquals(new Arc2D.Double(0, 0, 0, 0, 0, 0, Arc2D.CHORD),
052: new Arc2D.Double(Arc2D.CHORD));
053:
054: // Regression for HARMONY-1403
055: try {
056: // Invalid type
057: new Arc2D.Double(7);
058: fail("Expected IAE");
059: } catch (IllegalArgumentException e) {
060: // expected
061: }
062: }
063:
064: public void testCreate3() {
065: assertEquals(new Arc2D.Double(1, 2, 3, 4, 5, 6, Arc2D.CHORD),
066: new Arc2D.Double(new Rectangle(1, 2, 3, 4), 5, 6,
067: Arc2D.PIE));
068:
069: // Regression for HARMONY-1403
070: try {
071: // Invalid type
072: new Arc2D.Double(new Rectangle(1, 2, 3, 4), 5, 6, 4);
073: fail("Expected IAE");
074: } catch (IllegalArgumentException e) {
075: // expected
076: }
077: }
078:
079: public void testGetX() {
080: assertEquals(1.0, a.getX(), 0.0);
081: }
082:
083: public void testGetY() {
084: assertEquals(2.0, a.getY(), 0.0);
085: }
086:
087: public void testGetWidth() {
088: assertEquals(3.0, a.getWidth(), 0.0);
089: }
090:
091: public void testGetHeight() {
092: assertEquals(4.0, a.getHeight(), 0.0);
093: }
094:
095: public void testGetAngleStart() {
096: assertEquals(5.0, a.getAngleStart(), 0.0);
097: }
098:
099: public void testGetAngleExtent() {
100: assertEquals(6.0, a.getAngleExtent(), 0.0);
101: }
102:
103: public void testIsEmpty() {
104: assertFalse(a.isEmpty());
105: assertFalse(new Arc2D.Double(0, 0, 1, 1, 2, 3, Arc2D.CHORD)
106: .isEmpty());
107: assertTrue(new Arc2D.Double(0, 0, 0, 1, 2, 3, Arc2D.CHORD)
108: .isEmpty());
109: assertTrue(new Arc2D.Double(0, 0, 1, 0, 2, 3, Arc2D.CHORD)
110: .isEmpty());
111: assertTrue(new Arc2D.Double(0, 0, 0, 0, 2, 3, Arc2D.CHORD)
112: .isEmpty());
113: assertTrue(new Arc2D.Double(0, 0, -1, 0, 2, 3, Arc2D.CHORD)
114: .isEmpty());
115: assertTrue(new Arc2D.Double(0, 0, 0, -1, 2, 3, Arc2D.CHORD)
116: .isEmpty());
117: assertTrue(new Arc2D.Double(0, 0, -1, -1, 2, 3, Arc2D.CHORD)
118: .isEmpty());
119: }
120:
121: public void testSetArc() {
122: a.setArc(7, 8, 9, 10, 11, 12, Arc2D.CHORD);
123: assertEquals(
124: new Arc2D.Double(7, 8, 9, 10, 11, 12, Arc2D.CHORD), a);
125: }
126:
127: public void testAngleStart() {
128: a.setAngleStart(10);
129: assertEquals(10.0, a.getAngleStart(), 0.0);
130: }
131:
132: public void testAngleExtent() {
133: a.setAngleExtent(11);
134: assertEquals(11.0, a.getAngleExtent(), 0.0);
135: }
136:
137: public void testMakeBounds() {
138: assertEquals(new Rectangle2D.Double(1, 2, 3, 4), a.makeBounds(
139: 1, 2, 3, 4));
140: }
141:
142: public static void main(String[] args) {
143: junit.textui.TestRunner.run(Arc2DDoubleTest.class);
144: }
145:
146: }
|