Clover coverage report - clover
Coverage timestamp: Sat Oct 8 2005 22:54:17 EDT
file stats: LOC: 142   Methods: 9
NCLOC: 115   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
PropertyCallEditorTest.java - 97.7% 88.9% 96.2%
coverage coverage
 1   
 package abbot.editor.editors;
 2   
 
 3   
 
 4   
 import java.awt.Component;
 5   
 import javax.swing.*;
 6   
 import java.util.*;
 7   
 
 8   
 import junit.extensions.abbot.*;
 9   
 import abbot.finder.matchers.*;
 10   
 import abbot.script.*;
 11   
 import abbot.editor.widgets.*;
 12   
 import abbot.tester.*;
 13   
 
 14   
 /** Verify PropertyCallEditor operation. */
 15   
 
 16   
 public class PropertyCallEditorTest extends ComponentTestFixture {
 17   
 
 18   
     private PropertyCall call;
 19   
     private PropertyCallEditor editor;
 20   
     private JComboBoxTester comboTester;
 21   
 
 22   
     private JComboBox id;
 23   
     private JComboBox methods;
 24   
     private JTextField cname;
 25   
     private ArrayEditor args;
 26   
 
 27  2
     private JComboBox getComponentID(PropertyCallEditor editor)
 28   
         throws Exception {
 29  2
         return (JComboBox)getFinder().
 30   
             find(editor, new NameMatcher(XMLConstants.TAG_COMPONENT));
 31   
     }
 32   
 
 33  2
     private JTextField getTargetClass(PropertyCallEditor editor) 
 34   
         throws Exception {
 35  2
         return (JTextField)getFinder().
 36   
             find(editor, new NameMatcher(XMLConstants.TAG_CLASS));
 37   
     }
 38   
 
 39  2
     private JComboBox getMethod(PropertyCallEditor editor) 
 40   
         throws Exception {
 41  2
         return (JComboBox)getFinder().
 42   
             find(editor, new NameMatcher(XMLConstants.TAG_METHOD));
 43   
     }
 44   
 
 45  2
     private ArrayEditor getArguments(PropertyCallEditor editor) 
 46   
         throws Exception {
 47  2
         return (ArrayEditor)getFinder().
 48   
             find(editor, new NameMatcher(XMLConstants.TAG_ARGS));
 49   
     }
 50   
 
 51  2
     protected void setUp() throws Exception {
 52  2
         call = new PropertyCall(getResolver(), null,
 53   
                                          "java.lang.Object", "wait",
 54   
                                          new String[] { "5000" }) { };
 55  2
         editor = new PropertyCallEditor(call) { };
 56  2
         comboTester = new JComboBoxTester();
 57   
 
 58  2
         id = getComponentID(editor);
 59  2
         methods = getMethod(editor);
 60  2
         cname = getTargetClass(editor);
 61  2
         args = getArguments(editor);
 62   
     }
 63   
 
 64  1
     public void testSynchWithComponentID() throws Exception {
 65  1
         HashMap map = new HashMap();
 66  1
         ComponentReference ref =
 67   
             new ComponentReference(getResolver(), Component.class, map);
 68   
 
 69  1
         showFrame(editor);
 70  1
         int count = methods.getItemCount();
 71   
 
 72  1
         comboTester.actionSelectItem(id, ref.getID());
 73  1
         assertEquals("Call target class name not changed",
 74   
                      Component.class.getName(), call.getTargetClassName());
 75  1
         assertEquals("Target class name not updated",
 76   
                      Component.class.getName(), cname.getText());
 77  1
         assertTrue("Method list should have updated",
 78   
                    count != methods.getItemCount());
 79  1
         assertEquals("Argument list not cleared",
 80   
                      0, call.getArguments().length);
 81  1
         assertEquals("Arguments editor not cleared",
 82   
                      0, args.getValues().length);
 83   
     }
 84   
 
 85  1
     public void testSynchWithTesterMethod() {
 86  1
         HashMap map = new HashMap();
 87  1
         ComponentReference ref =
 88   
             new ComponentReference(getResolver(), JTabbedPane.class, map);
 89  1
         showFrame(editor);
 90   
 
 91  1
         comboTester.actionSelectItem(id, ref.getID());
 92  1
         int count = methods.getItemCount();
 93   
         // select a pseudo-property method
 94  1
         comboTester.actionSelectItem(methods, "getTabs");
 95  1
         assertEquals("Call target class not updated to match tester method",
 96   
                      JTabbedPaneTester.class.getName(),
 97   
                      call.getTargetClassName());
 98  1
         assertEquals("Class field not updated to match tester method",
 99   
                      JTabbedPaneTester.class.getName(),
 100   
                      cname.getText());
 101  1
         assertEquals("Argument list not updated to include component target",
 102   
                      1, call.getArguments().length);
 103  1
         assertEquals("Arguments editor not updated to include component target",
 104   
                      1, args.getValues().length);
 105  1
         assertEquals("Component ID should be cleared",
 106   
                      null, call.getComponentID());
 107  1
         assertEquals("Component ID editor should have no selection",
 108   
                      null, id.getSelectedItem());
 109  1
         assertEquals("Method list should be unchanged",
 110   
                      count, methods.getItemCount());
 111   
 
 112   
         // select a real property method
 113  1
         comboTester.actionSelectItem(methods, "getName");
 114  1
         assertEquals("Call target class should be the target component class",
 115   
                      JTabbedPane.class.getName(),
 116   
                      call.getTargetClassName());
 117  1
         assertEquals("Class field should hold the component class name",
 118   
                      JTabbedPane.class.getName(),
 119   
                      cname.getText());
 120  1
         assertEquals("Argument list not updated",
 121   
                      0, call.getArguments().length);
 122  1
         assertEquals("Arguments editor not updated",
 123   
                      0, args.getValues().length);
 124  1
         assertEquals("Component ID should be set",
 125   
                      ref.getID(), call.getComponentID());
 126  1
         assertEquals("Component ID editor should have no selection",
 127   
                      ref.getID(), id.getSelectedItem());
 128  1
         assertEquals("Method list should be unchanged",
 129   
                      count, methods.getItemCount());
 130   
     }
 131   
 
 132   
     /** Construct a test case with the given name. */
 133  2
     public PropertyCallEditorTest(String name) {
 134  2
         super(name);
 135   
     }
 136   
 
 137   
     /** Run the default test suite. */
 138  0
     public static void main(String[] args) {
 139  0
         TestHelper.runTests(args, PropertyCallEditorTest.class);
 140   
     }
 141   
 }
 142