Clover coverage report - clover
Coverage timestamp: Sat Oct 8 2005 22:54:17 EDT
file stats: LOC: 74   Methods: 5
NCLOC: 56   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
LookAndFeelPreserverTest.java 83.3% 93.8% 80% 90.7%
coverage coverage
 1   
 package abbot.editor;
 2   
 
 3   
 import java.awt.*;
 4   
 import javax.swing.*;
 5   
 import javax.swing.plaf.*;
 6   
 
 7   
 import junit.extensions.abbot.*;
 8   
 import abbot.script.*;
 9   
 import abbot.tester.*;
 10   
 
 11   
 /** Verify operation of LookAndFeelPreserver, and ScriptModel interactions. */
 12   
 
 13   
 public class LookAndFeelPreserverTest extends ComponentTestFixture {
 14   
 
 15   
     private String alternate;
 16   
 
 17  2
     protected void setUp() throws Exception {
 18  2
         LookAndFeel laf = UIManager.getLookAndFeel();
 19  2
         UIManager.LookAndFeelInfo[] infos =
 20   
             UIManager.getInstalledLookAndFeels();
 21  4
         for (int i=0;i < infos.length;i++) {
 22  4
             String cname = infos[i].getClassName();
 23  4
             if (!laf.getClass().getName().equals(cname)) {
 24  2
                 alternate = cname;
 25  2
                 return;
 26   
             }
 27   
         }
 28  0
         throw new RuntimeException("No alternate LAF available");
 29   
     }
 30   
 
 31  1
     public void testPreserveGlobalLAFChange() throws Exception {
 32  1
         JFrame f = new JFrame(getName());
 33  1
         LookAndFeelPreserver p = new LookAndFeelPreserver(f);
 34   
 
 35  1
         JLabel label = new JLabel(getName());
 36  1
         f.getContentPane().add(label);
 37  1
         LabelUI ui = label.getUI();
 38  1
         UIManager.setLookAndFeel(alternate);
 39  1
         Frame[] frames = Frame.getFrames();
 40  1
         for (int i=0;i < frames.length;i++) {
 41  3
             SwingUtilities.updateComponentTreeUI(frames[i]);
 42   
         }
 43  1
         getRobot().waitForIdle();
 44  1
         LabelUI ui2 = label.getUI();
 45  1
         assertEquals("UI should revert after attempt at global change",
 46   
                      ui, ui2);
 47   
     }
 48   
 
 49  1
     public void testPreserveWithinHierarchy() throws Exception {
 50  1
         JFrame f = new JFrame(getName());
 51  1
         LookAndFeelPreserver p = new LookAndFeelPreserver(f);
 52   
 
 53  1
         JLabel label = new JLabel("original LAF");
 54  1
         f.getContentPane().add(label);
 55  1
         LabelUI ui = label.getUI();
 56  1
         UIManager.setLookAndFeel(alternate);
 57   
 
 58  1
         JLabel label2 = new JLabel("LAF changed");
 59  1
         f.getContentPane().add(label2);
 60   
 
 61  1
         LabelUI ui2 = label2.getUI();
 62  1
         assertEquals("Should use original LAF for new hierarchy members",
 63   
                      ui, ui2);
 64   
     }
 65   
 
 66   
     /** Construct a test case with the given name. */
 67  2
     public LookAndFeelPreserverTest(String name) { super(name); }
 68   
 
 69   
     /** Run the default test suite. */
 70  0
     public static void main(String[] args) {
 71  0
         TestHelper.runTests(args, LookAndFeelPreserverTest.class);
 72   
     }
 73   
 }
 74