OSDN Git Service

899024c8d65fe3db6cef1fb316c7a78f75042b68
[mdc/BetaProject.git] / src / test / org / jent / checksmtp / ToListDialogTest.java
1 package test.org.jent.checksmtp;
2
3 import java.util.ArrayList;
4
5 import javax.swing.JDialog;
6
7 import junit.framework.TestCase;
8
9 import junit.swingui.TestRunner;
10
11 import org.jent.checksmtp.ResultNotify;
12 import org.jent.checksmtp.ToListDialog;
13
14 public class ToListDialogTest extends TestCase implements ResultNotify {
15
16   private final ArrayList arrayList = new ArrayList();
17   private JDialog toListDialog = null;
18   private boolean result = false;
19
20   public ToListDialogTest(String sTestName) {
21     super(sTestName);
22   }
23
24   public static void main(String args[]) {
25     String args2[] = {"-noloading", "test.org.jent.checksmtp.ToListDialogTest"};
26     TestRunner.main(args2);
27   }
28
29   protected void setUp() throws Exception {
30     super.setUp();
31
32   }
33
34   protected void tearDown() throws Exception {
35     super.tearDown();
36     toListDialog.dispose();
37   }
38   
39   private synchronized void notifyResult() {
40     notify();
41   }
42   public void sayOK() {
43     result = true;
44     notifyResult();
45   }
46   public void sayNG() {
47     result = false;
48     notifyResult();
49   }
50
51   private void pushTestSetup(String msg) {
52     arrayList.add(msg);
53     for (int i = 0; i < 100; i++) {
54       arrayList.add("NO" + i);
55     }
56     toListDialog = new ToListDialog(this, arrayList);
57     arrayList.clear();
58
59     try {
60       synchronized (this) {
61         wait(30 * 1000);
62         //Wait 30sec
63       }
64     } catch (InterruptedException e) {
65       fail("Dialg wait interrupted");
66     }
67   }
68
69   public void testPushOK() {
70     pushTestSetup("Please push OK button.");
71     assertTrue("Time out or push CANCEL", result);
72   }
73   
74   public void testPushCANCEL() {
75     pushTestSetup("Please push CANCEL button.");
76     assertTrue("Time out or push OK", !result);
77   }
78
79   public void testPushClose() {
80     pushTestSetup("Please close Window.");
81     assertTrue("Time out or push OK", !result);
82   }
83   
84 }