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

Quick Search    Search Deep

Source code: com/port80/eclipse/util/widgets/InputWithHistoryDialog_Testcase1.java


1   /*
2    * Created on Apr 26, 2003
3    */
4   package com.port80.eclipse.util.widgets;
5   
6   import java.util.HashMap;
7   import java.util.Map;
8   
9   import junit.framework.TestCase;
10  import junit.framework.TestSuite;
11  
12  import org.eclipse.jface.window.Window;
13  import org.eclipse.swt.SWT;
14  import org.eclipse.swt.widgets.Display;
15  import org.eclipse.swt.widgets.Shell;
16  
17  import com.port80.eclipse.util.DefineVariableScanner;
18  import com.port80.util.Msg;
19  import com.port80.util.Sprint;
20  
21  /**
22   * @author chrisl
23   */
24  public class InputWithHistoryDialog_Testcase1 extends TestCase {
25  
26    ////////////////////////////////////////////////////////////////////////
27  
28    private static final String NAME = "InputWithHistoryDialog_Testcase1";
29    private static final boolean DEBUG = false;
30    private static boolean VERBOSE = false;
31    private static boolean CHECK = true;
32  
33    ////////////////////////////////////////////////////////////////////////
34  
35    public InputWithHistoryDialog_Testcase1(String arg0) {
36      super(arg0);
37    }
38  
39    // Main ////////////////////////////////////////////////////////////////
40  
41    public static void main(String[] args) {
42      Map opts = new HashMap();
43      args = Msg.getArgs(opts, NAME, args, "- verbose=v nocheck=c dialog");
44      if (opts.get("verbose") != null) {
45        VERBOSE = true;
46      }
47      if (opts.get("nocheck") != null) {
48        CHECK = false;
49      }
50      if (args.length > 0) {
51        int ret = 0;
52        ret |= test1(args);
53        System.err.println("exit=" + ret);
54      } else {
55        junit.textui.TestRunner.run(new TestSuite(InputWithHistoryDialog_Testcase1.class));
56      }
57    }
58  
59    ////////////////////////////////////////////////////////////////////////
60  
61    public static int test1(String[] args) {
62      Display display = new Display();
63      Shell top = new Shell(display, SWT.SHELL_TRIM);
64      top.open();
65      int ret = 0;
66      for (int i = 0; i < args.length; ++i) {
67        InputWithHistoryDialog dialog = new InputWithHistoryDialog(top, "Define variables", args, i);
68        if (dialog.open() != Window.OK) {
69          ++ret;
70          continue;
71        }
72        Map result = DefineVariableScanner.getDefines(dialog.getValue());
73        System.err.println(Sprint.sprintObject(result));
74      }
75      return 0;
76    }
77  
78    ////////////////////////////////////////////////////////////////////////
79  
80  }