1 19 package org.openide; 20 21 22 import javax.swing.*; 23 import org.netbeans.junit.*; 24 25 29 public class NotifyDescriptorTest extends NbTestCase { 30 31 32 public NotifyDescriptorTest (String name) { 33 super(name); 34 } 35 36 public static void main(String [] args) { 37 junit.textui.TestRunner.run (new NbTestSuite (NotifyDescriptorTest.class)); 38 System.exit (0); 39 } 40 41 protected final void setUp () { 42 } 43 44 public void testDefaultValue () { 45 JButton defaultButton = new JButton ("Default"); 46 JButton customButton = new JButton ("Custom action"); 47 JButton [] options = new JButton [] {defaultButton, customButton}; 48 DialogDescriptor dd = new DialogDescriptor ("Test", "Test dialog", false, options, defaultButton, NotifyDescriptor.PLAIN_MESSAGE, null, null); 49 assertEquals ("Test descriptor has defaultButton as defaultValue", defaultButton, dd.getValue ()); 50 dd.setClosingOptions (null); 51 52 DialogDisplayer.getDefault ().createDialog (dd).setVisible (true); 53 customButton.doClick (); 54 55 assertEquals ("Test dialog closed by CustomButton", customButton, dd.getValue ()); 56 assertEquals ("Test dialog has the same default value as before", defaultButton, dd.getDefaultValue ()); 57 } 58 } 59 | Popular Tags |