Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/port80/eclipse/util/FontFactoryTest01.java


1   //
2   // Copyright(c) 2002, Chris Leung
3   //
4   
5   package com.port80.eclipse.util;
6   
7   import java.util.HashMap;
8   import java.util.Map;
9   
10  import junit.framework.Assert;
11  import junit.framework.TestCase;
12  import junit.framework.TestSuite;
13  
14  import com.port80.util.Debug;
15  import com.port80.util.Msg;
16  
17  /**
18   * Check Anneal() rank cost calculation methods.
19   * 
20   * @author chrisl
21   */
22  public class FontFactoryTest01 extends TestCase {
23  
24    ////////////////////////////////////////////////////////////////////////
25  
26    private static final String NAME = "FontFactoryTest01";
27    private static final boolean DEBUG = false;
28    private static boolean CHECK = true;
29    private static boolean VERBOSE = true; // Debug.isVerbose();
30  
31    private static Map opts = new HashMap();
32  
33    ////////////////////////////////////////////////////////////////////////
34  
35    ////////////////////////////////////////////////////////////////////////
36  
37    public FontFactoryTest01(String name) {
38      super(name);
39    }
40  
41    ////////////////////////////////////////////////////////////////////////
42  
43    public void testConvertFontSpecFormat() {
44      String PREFIX = NAME + ".testConvertFontSpecFormat(): ";
45      if (VERBOSE)
46        System.err.println("\n### " + PREFIX);
47      String from, expected, ret;
48      //
49      from="1|arial black|10|0|motif|1|-monotype-arial black-medium-r-normal--14-100-100-100-p-77-iso8859-15";
50      expected="monotype-arial black--10";
51      ret=FontFactory.convertFontSpecFormat(from);
52      if(VERBOSE)
53        System.err.println("expected=" + expected+ ", actual=" + ret);
54      if (CHECK)
55        Assert.assertTrue("expected=" + expected+ ", actual=" + ret, expected.equals(ret));
56      //
57      from="1|arial black|10|3|motif|1|-monotype-arial black-demi bold-i-normal--14-100-100-100-p-77-iso8859-15";
58      expected="monotype-arial black-bold italic-10";
59      ret=FontFactory.convertFontSpecFormat(from);
60      if(VERBOSE)
61        System.err.println("expected=" + expected+ ", actual=" + ret);
62      if (CHECK)
63        Assert.assertTrue("expected="+expected + ", actual=" + ret, expected.equals(ret));
64    }
65    
66    // Main ////////////////////////////////////////////////////////////////
67    //
68  
69    public static void main(String[] args) {
70      args = Msg.getArgs(opts, NAME, args, "- quiet=q nocheck=c");
71      if (opts.get("quiet") != null) {
72        Debug.enable("quiet");
73        VERBOSE = false;
74      }
75      if (opts.get("nocheck") != null) {
76        CHECK = false;
77      }
78      junit.textui.TestRunner.run(new TestSuite(FontFactoryTest01.class));
79      // junit.swingui.TestRunner.run(new TestVirtualGraph("TestVirtualGraph").getClass());
80    }
81  
82    ////////////////////////////////////////////////////////////////////////
83  }