View Javadoc

1   package org.xmlhammer.gui.dialog;
2   
3   import javax.swing.JFrame;
4   
5   import junit.framework.Test;
6   import junit.framework.TestCase;
7   import junit.framework.TestSuite;
8   
9   import org.xmlhammer.PreferencesHandler;
10  import org.xmlhammer.gui.preferences.PreferencesDialog;
11  
12  public class PreferencesDialogTest extends TestCase {
13      private static PreferencesDialog dialog = null;
14  
15      private PreferencesDialogTest(String test) {
16          super(test);
17      }
18  
19      public void openDialog() {
20          dialog = new PreferencesDialog(new JFrame());
21          dialog.setModal(false);
22          
23          assertEquals(PreferencesDialog.OK_OPTION, dialog.open());
24          assertTrue(dialog.isVisible());
25      }
26      
27      public void setPreferences() {
28          PreferencesHandler.getInstance().useDefaultPreferences();
29          dialog.update(PreferencesHandler.getInstance().getPreferences());
30  
31          dialog.setVisible(false);
32          dialog.dispose();
33          dialog = null;
34      }
35      
36      public static Test suite() {
37          TestSuite suite = new TestSuite("PreferencesDialog");
38          
39          suite.addTest(new PreferencesDialogTest("openDialog"));
40          suite.addTest(new PreferencesDialogTest("setPreferences"));
41          return suite;
42      }
43  }