001: /*
002: * This file is part of the Echo Web Application Framework (hereinafter "Echo").
003: * Copyright (C) 2002-2005 NextApp, Inc.
004: *
005: * Version: MPL 1.1/GPL 2.0/LGPL 2.1
006: *
007: * The contents of this file are subject to the Mozilla Public License Version
008: * 1.1 (the "License"); you may not use this file except in compliance with
009: * the License. You may obtain a copy of the License at
010: * http://www.mozilla.org/MPL/
011: *
012: * Software distributed under the License is distributed on an "AS IS" basis,
013: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
014: * for the specific language governing rights and limitations under the
015: * License.
016: *
017: * Alternatively, the contents of this file may be used under the terms of
018: * either the GNU General Public License Version 2 or later (the "GPL"), or
019: * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
020: * in which case the provisions of the GPL or the LGPL are applicable instead
021: * of those above. If you wish to allow use of your version of this file only
022: * under the terms of either the GPL or the LGPL, and not to allow others to
023: * use your version of this file under the terms of the MPL, indicate your
024: * decision by deleting the provisions above and replace them with the notice
025: * and other provisions required by the GPL or the LGPL. If you do not delete
026: * the provisions above, a recipient may use your version of this file under
027: * the terms of any one of the MPL, the GPL or the LGPL.
028: */
029:
030: package nextapp.echo2.app.test;
031:
032: import nextapp.echo2.app.Color;
033: import nextapp.echo2.app.FillImage;
034: import nextapp.echo2.app.FillImageBorder;
035: import nextapp.echo2.app.Insets;
036: import nextapp.echo2.app.ResourceImageReference;
037: import junit.framework.TestCase;
038:
039: /**
040: * Unit test for <code>nextapp.echo2.app.FillImageBorder</code> property.
041: */
042: public class FillImageBorderTest extends TestCase {
043:
044: public void testEquals() {
045: assertTrue(new FillImageBorder().equals(new FillImageBorder()));
046: assertTrue(new FillImageBorder(Color.RED, new Insets(10),
047: new Insets(20)).equals(new FillImageBorder(Color.RED,
048: new Insets(10), new Insets(20))));
049: assertFalse(new FillImageBorder(Color.RED, new Insets(10),
050: new Insets(10)).equals(new FillImageBorder(Color.RED,
051: new Insets(10), new Insets(20))));
052:
053: FillImageBorder fib1 = new FillImageBorder();
054: fib1.setFillImage(FillImageBorder.TOP_LEFT, new FillImage(
055: new ResourceImageReference("topleft.gif")));
056: fib1.setFillImage(FillImageBorder.TOP, new FillImage(
057: new ResourceImageReference("top.gif")));
058: fib1.setFillImage(FillImageBorder.TOP_RIGHT, new FillImage(
059: new ResourceImageReference("topright.gif")));
060: fib1.setFillImage(FillImageBorder.LEFT, new FillImage(
061: new ResourceImageReference("left.gif")));
062: fib1.setFillImage(FillImageBorder.RIGHT, new FillImage(
063: new ResourceImageReference("right.gif")));
064: fib1.setFillImage(FillImageBorder.BOTTOM_LEFT, new FillImage(
065: new ResourceImageReference("bottomleft.gif")));
066: fib1.setFillImage(FillImageBorder.BOTTOM, new FillImage(
067: new ResourceImageReference("bottom.gif")));
068: fib1.setFillImage(FillImageBorder.BOTTOM_RIGHT, new FillImage(
069: new ResourceImageReference("bottomright.gif")));
070: FillImageBorder fib2 = new FillImageBorder();
071: fib2.setFillImage(FillImageBorder.TOP_LEFT, new FillImage(
072: new ResourceImageReference("topleft.gif")));
073: fib2.setFillImage(FillImageBorder.TOP, new FillImage(
074: new ResourceImageReference("top.gif")));
075: fib2.setFillImage(FillImageBorder.TOP_RIGHT, new FillImage(
076: new ResourceImageReference("topright.gif")));
077: fib2.setFillImage(FillImageBorder.LEFT, new FillImage(
078: new ResourceImageReference("left.gif")));
079: fib2.setFillImage(FillImageBorder.RIGHT, new FillImage(
080: new ResourceImageReference("right.gif")));
081: fib2.setFillImage(FillImageBorder.BOTTOM_LEFT, new FillImage(
082: new ResourceImageReference("bottomleft.gif")));
083: fib2.setFillImage(FillImageBorder.BOTTOM, new FillImage(
084: new ResourceImageReference("bottom.gif")));
085: fib2.setFillImage(FillImageBorder.BOTTOM_RIGHT, new FillImage(
086: new ResourceImageReference("bottomright2.gif")));
087: assertFalse(fib1.equals(fib2));
088:
089: fib2.setFillImage(FillImageBorder.BOTTOM_RIGHT, new FillImage(
090: new ResourceImageReference("bottomright.gif")));
091: assertTrue(fib1.equals(fib2));
092:
093: fib1.setBorderInsets(new Insets(20));
094: assertFalse(fib1.equals(fib2));
095: fib2.setBorderInsets(new Insets(20));
096: assertTrue(fib1.equals(fib2));
097:
098: fib1.setContentInsets(new Insets(30));
099: assertFalse(fib1.equals(fib2));
100: fib2.setContentInsets(new Insets(30));
101: assertTrue(fib1.equals(fib2));
102:
103: fib1.setColor(Color.RED);
104: assertFalse(fib1.equals(fib2));
105: fib2.setColor(Color.RED);
106: assertTrue(fib1.equals(fib2));
107: }
108: }
|