1   /*
2    *  XNap - A P2P framework and client.
3    *
4    *  See AUTHORS for copyright information.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation; either version 2 of the License, or
9    *  (at your option) any later version.
10   *
11   *  This program is distributed in the hope that it will be useful,
12   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   *  GNU General Public License for more details.
15   *
16   *  You should have received a copy of the GNU General Public License
17   *  along with this program; if not, write to the Free Software
18   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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  }