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 junit.framework.TestCase;
033: import nextapp.echo2.app.Extent;
034: import nextapp.echo2.app.Font;
035:
036: /**
037: * Unit test(s) for the <code>nextapp.echo2.app.Font</code> property
038: * value object.
039: */
040: public class FontTest extends TestCase {
041:
042: /**
043: * Test equality.
044: */
045: public void testFontEquals() {
046: Font font1 = new Font(Font.SANS_SERIF, Font.PLAIN, new Extent(
047: 12, Extent.PT));
048: Font font2 = new Font(Font.SANS_SERIF, Font.PLAIN, new Extent(
049: 12, Extent.PT));
050: Font font3 = new Font(Font.SANS_SERIF, Font.BOLD, new Extent(
051: 12, Extent.PT));
052: Font font4 = new Font(Font.SANS_SERIF, Font.BOLD | Font.ITALIC,
053: new Extent(12, Extent.PT));
054: Font font5 = new Font(Font.SANS_SERIF, Font.PLAIN, new Extent(
055: 13, Extent.PT));
056: Font font6 = new Font(Font.SANS_SERIF, Font.PLAIN, new Extent(
057: 12, Extent.PX));
058:
059: assertEquals(true, font1.equals(font1));
060: assertEquals(true, font1.equals(font2));
061: assertEquals(false, font1.equals(font3));
062: assertEquals(false, font1.equals(font4));
063: assertEquals(false, font1.equals(font5));
064: assertEquals(false, font1.equals(font6));
065: assertEquals(false, font1.equals(null));
066: }
067:
068: /**
069: * Test <code>toString()</code> (debug).
070: */
071: public void testToString() {
072: Font font;
073:
074: font = new Font(Font.SANS_SERIF, Font.PLAIN, new Extent(12,
075: Extent.PT));
076: assertEquals(
077: "nextapp.echo2.app.Font (Sans-Serif / Plain / 12pt)",
078: font.toString());
079:
080: font = new Font(Font.VERDANA, Font.PLAIN, new Extent(12,
081: Extent.PT));
082: assertEquals(
083: "nextapp.echo2.app.Font (Verdana, Arial, Helvetica, Sans-Serif / Plain / 12pt)",
084: font.toString());
085:
086: font = new Font(Font.TIMES_NEW_ROMAN, Font.BOLD | Font.ITALIC
087: | Font.UNDERLINE, new Extent(24, Extent.PX));
088: assertEquals(
089: "nextapp.echo2.app.Font (Times New Roman, Times Roman, Times, Serif / Bold Italic Underline / 24px)",
090: font.toString());
091:
092: font = new Font(Font.SANS_SERIF, Font.BOLD | Font.ITALIC
093: | Font.LINE_THROUGH | Font.OVERLINE | Font.UNDERLINE,
094: new Extent(12, Extent.PT));
095: assertEquals(
096: "nextapp.echo2.app.Font (Sans-Serif / Bold Italic LineThrough Overline Underline / 12pt)",
097: font.toString());
098: }
099:
100: /**
101: * Test equality of <code>Font.TypeFace</code> objects.
102: */
103: public void testTypefaceEquals() {
104: assertEquals(false, Font.TIMES_NEW_ROMAN
105: .equals(Font.TIMES_ROMAN));
106: assertEquals(true, Font.TIMES_ROMAN.equals(Font.TIMES_ROMAN));
107: assertEquals(true, Font.HELVETICA.equals(new Font.Typeface(
108: "Helvetica", new Font.Typeface("Sans-Serif"))));
109: assertEquals(false, Font.HELVETICA.equals(new Font.Typeface(
110: "Helvetica", new Font.Typeface("Serif"))));
111: assertEquals(false, Font.HELVETICA.equals(null));
112: }
113: }
|