1 7 8 package org.jdesktop.swing; 9 10 import java.awt.GraphicsEnvironment ; 11 12 import java.net.URL ; 13 14 import javax.swing.Icon ; 15 import javax.swing.JButton ; 16 import javax.swing.JFrame ; 17 18 import junit.framework.TestCase; 19 20 24 public class ApplicationTest extends TestCase { 25 26 public void testGetIcon() { 27 assertNull(Application.getIcon("images/foo.gif", this)); 29 assertNotNull(Application.getIcon("/toolbarButtonGraphics/general/Find16.gif", this)); 30 } 31 32 public void testGetInstance() { 33 assertNotNull(Application.getInstance()); 34 assertNotNull(Application.getInstance(this)); 35 assertNotSame(Application.getInstance(), Application.getInstance(this)); 36 } 37 38 public void testGetApp() { 39 JButton button = new JButton ("foo"); 41 assertNull(Application.getApp(button)); 42 43 if (GraphicsEnvironment.isHeadless()) { 45 return; 46 } 47 48 JFrame frame = new JFrame (); 50 frame.getContentPane().add(button); 51 Application app = Application.getInstance(frame); 52 app.registerWindow(frame); 53 54 assertNotNull(Application.getApp(button)); 55 56 JFrame frame2 = new JFrame (); 57 JButton button2 = new JButton ("foo"); 58 frame2.getContentPane().add(button2); 59 assertNotNull(Application.getApp(button2)); 60 } 61 62 public void testEnvironment() { 63 Application app = Application.getInstance(); 64 65 assertTrue(app.isStandAlone()); 66 assertFalse(app.isRunningApplet()); 67 assertFalse(app.isRunningInSandbox()); 68 assertFalse(app.isRunningWebStart()); 69 } 70 71 80 } 81 | Popular Tags |