|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2006 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
| 8 |
* Contributors: |
| 9 |
* IBM Corporation - initial API and implementation |
| 10 |
*******************************************************************************/ |
| 11 |
|
| 12 |
package org.eclipse.draw2d.test; |
| 13 |
|
| 14 |
import junit.framework.TestCase; |
| 15 |
|
| 16 |
import org.eclipse.draw2d.geometry.Point; |
| 17 |
import org.eclipse.draw2d.geometry.Rectangle; |
| 18 |
|
| 19 |
public class RectangleTest extends TestCase { |
| 20 |
/** |
| 21 |
* @see TestCase#setUp() |
| 22 |
*/ |
| 23 |
protected void setUp() throws Exception { |
| 24 |
super.setUp(); |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* @see TestCase#tearDown() |
| 29 |
*/ |
| 30 |
protected void tearDown() throws Exception { |
| 31 |
super.tearDown(); |
| 32 |
} |
| 33 |
|
| 34 |
public void test_creationSymmetry() { |
| 35 |
Point topLeft = new Point(0, 0); |
| 36 |
Point topRight = new Point(10, 0); |
| 37 |
Point bottomLeft = new Point(0, 10); |
| 38 |
Point bottomRight = new Point(10, 10); |
| 39 |
Rectangle rect1 = new Rectangle(topLeft, bottomRight); |
| 40 |
Rectangle rect2 = new Rectangle(topRight, bottomLeft); |
| 41 |
|
| 42 |
assertTrue(rect1.equals(rect2)); |
| 43 |
} |
| 44 |
|
| 45 |
public void test_creationValues() { |
| 46 |
|
| 47 |
final Rectangle testRect = new Rectangle(10, 10, 10, 10); |
| 48 |
|
| 49 |
Point topLeft = new Point(10, 10); |
| 50 |
Point topRight = new Point(19, 10); |
| 51 |
Point bottomLeft = new Point(10, 19); |
| 52 |
Point bottomRight = new Point(19, 19); |
| 53 |
Rectangle rect1 = new Rectangle(topLeft, bottomRight); |
| 54 |
Rectangle rect2 = new Rectangle(topRight, bottomLeft); |
| 55 |
|
| 56 |
assertTrue(rect1.equals(testRect)); |
| 57 |
assertTrue(rect2.equals(testRect)); |
| 58 |
} |
| 59 |
|
| 60 |
public void test_sameBehavior() { |
| 61 |
|
| 62 |
Point p1 = new Point(0,0); |
| 63 |
Point p2 = new Point(10, 10); |
| 64 |
Rectangle origRect = new Rectangle(); |
| 65 |
origRect.setLocation(p1); |
| 66 |
origRect.union(p2); |
| 67 |
|
| 68 |
Rectangle newRect = new Rectangle(p1, p2); |
| 69 |
|
| 70 |
assertTrue(origRect.equals(newRect)); |
| 71 |
} |
| 72 |
|
| 73 |
} |