1
/* ========================================================================
2
* JCommon : a free general purpose class library for the Java(tm) platform
3
* ========================================================================
5
* (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
7
* Project Info: http://www.jfree.org/jcommon/index.html
9
* This library is free software; you can redistribute it and/or modify it
10
* under the terms of the GNU Lesser General Public License as published by
11
* the Free Software Foundation; either version 2.1 of the License, or
12
* (at your option) any later version.
14
* This library is distributed in the hope that it will be useful, but
15
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17
* License for more details.
19
* You should have received a copy of the GNU Lesser General Public
20
* License along with this library; if not, write to the Free Software
21
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
24
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
25
* in the United States and other countries.]
30
* (C) Copyright 2003-2005, by Object Refinery Limited and Contributors.
32
* Original Author: David Gilbert (for Object Refinery Limited);
35
* $Id: PaintTests.java,v 1.3 2005/10/18 13:16:37 mungady Exp $
39
* 23-Oct-2003 : Version 1 (DG);
43
package org.jfree.junit;
45
import java.awt.Color;
46
import java.awt.GradientPaint;
47
import java.awt.Paint;
48
import java.awt.TexturePaint;
49
import java.awt.geom.Rectangle2D;
50
import java.awt.image.BufferedImage;
52
import junit.framework.Test;
53
import junit.framework.TestCase;
54
import junit.framework.TestSuite;
57
* Tests for the {@link Paint} interface and known subclasses.
59
public class PaintTests extends TestCase {
62
* Returns the tests as a test suite.
64
* @return the test suite.
66
public static Test suite() {
67
return new TestSuite(PaintTests.class);
71
* Constructs a new set of tests.
73
* @param name the name of the tests.
75
public PaintTests(final String name) {
80
* Check that the equals() method distinguishes all fields.
82
public void testColorEquals() {
83
final Paint p1 = new Color(0xFF, 0xEE, 0xDD);
84
final Paint p2 = new Color(0xFF, 0xEE, 0xDD);
89
* Two objects that are equal are required to return the same hashCode.
91
public void testColorHashcode() {
92
final Paint p1 = new Color(0xFF, 0xEE, 0xDD);
93
final Paint p2 = new Color(0xFF, 0xEE, 0xDD);
94
assertTrue(p1.equals(p2));
95
final int h1 = p1.hashCode();
96
final int h2 = p2.hashCode();
101
* Check that the equals() method distinguishes all fields.
103
public void testGradientPaintEquals() {
104
final Paint p1 = new GradientPaint(10.0f, 20.0f, Color.blue, 30.0f, 40.0f, Color.red);
105
final Paint p2 = new GradientPaint(10.0f, 20.0f, Color.blue, 30.0f, 40.0f, Color.red);
106
assertEquals(p1, p2);
110
* Check that the equals() method distinguishes all fields.
112
public void testTexturePaintEquals() {
113
final Paint p1 = new TexturePaint(
114
new BufferedImage(100, 200, BufferedImage.TYPE_INT_RGB), new Rectangle2D.Double()
116
final Paint p2 = new TexturePaint(
117
new BufferedImage(100, 200, BufferedImage.TYPE_INT_RGB), new Rectangle2D.Double()
119
assertEquals(p1, p2);