1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.xnap.gui.pkg;
22
23 import java.util.Properties;
24
25 import junit.framework.TestCase;
26
27 import org.xnap.pkg.PackageInfo;
28
29 /***
30 * @author warper
31 *
32 * To change the template for this generated type comment go to
33 * Window>Preferences>Java>Code Generation>Code and Comments
34 */
35 public class PackageInstallerDialogTest extends TestCase {
36
37 PackageInstallerDialog dialog;
38 int value = 0;
39
40 public PackageInstallerDialogTest(String name)
41 {
42 super(name);
43 }
44
45 public void testDummy()
46 {
47 }
48
49 public void guiTestDialog()
50 {
51 Properties p = new Properties();
52 p.setProperty("Size", "1000000");
53
54 PackageInfo[] infos = new PackageInfo[1];
55 infos[0] = new PackageInfo(p);
56
57 dialog = new PackageInstallerDialog(infos);
58
59 dialog.setMinimum(0);
60 dialog.setValue(0);
61 dialog.setMaximum(1000000);
62
63 dialog.setModal(false);
64 dialog.show();
65
66 Thread t = new Thread(new ProgressRunner());
67 t.start();
68 try {
69 t.join();
70 }
71 catch (InterruptedException e) {
72 }
73 }
74
75 public class ProgressRunner implements Runnable
76 {
77 public void run()
78 {
79 for (int i = 0; i <= 1000000; i += 10000) {
80 dialog.setValue(i);
81 dialog.setTotalValue(i * 2);
82 try {
83 Thread.sleep(500);
84 }
85 catch (InterruptedException e) {
86 }
87 }
88 }
89 }
90
91 }