Clover coverage report - clover
Coverage timestamp: Sat Oct 8 2005 22:54:17 EDT
file stats: LOC: 61   Methods: 4
NCLOC: 38   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
LabeledListTest.java - 0% 0% 0%
coverage
 1   
 package example;
 2   
 
 3   
 import java.awt.*;
 4   
 import javax.swing.*;
 5   
 
 6   
 import junit.extensions.abbot.ComponentTestFixture;
 7   
 import junit.extensions.abbot.TestHelper;
 8   
 
 9   
 import abbot.finder.Matcher;
 10   
 import abbot.finder.matchers.ClassMatcher;
 11   
 import abbot.script.ComponentReference;
 12   
 import abbot.tester.JListTester;
 13   
 import abbot.tester.JListLocation;
 14   
 
 15   
 /** Source test code for Tutorial 2, test fixture for the LabeledList. */
 16   
 
 17   
 public class LabeledListTest extends ComponentTestFixture {
 18   
 
 19  0
     public void testLabelChangedOnSelectionChange() throws Throwable {
 20  0
         String[] contents = { "one", "two", "three" };
 21  0
         final LabeledList labeledList = new LabeledList(contents);
 22  0
         showFrame(labeledList);
 23   
 
 24   
         // The interface abbot.finder.Matcher allows you to define whatever
 25   
         // matching specification you'd like.  We know there's only one
 26   
         // JList in the hierarchy we're searching, so we can look up by
 27   
         // class with an instance of ClassMatcher.
 28  0
         Component list = getFinder().find(new ClassMatcher(JList.class));
 29  0
         JListTester tester = new JListTester();
 30   
 
 31   
         // We could also use an instance of ClassMatcher, but this shows
 32   
         // how you can put more conditions into the Matcher.
 33  0
         JLabel label = (JLabel)getFinder().find(labeledList, new Matcher() {
 34  0
             public boolean matches(Component c) {
 35  0
                 return c.getClass().equals(JLabel.class)
 36   
                     && c.getParent() == labeledList;
 37   
             }
 38   
         });
 39   
 
 40   
         // Select by row index or by value
 41  0
         tester.actionSelectRow(list, new JListLocation(1)); 
 42   
         // tester.actionSelect(list, new JListLocation("two"));
 43  0
         assertEquals("Wrong label after selection",
 44   
                      "Selected: two", label.getText());
 45   
 
 46  0
         tester.actionSelectRow(list, new JListLocation(2));
 47  0
         assertEquals("Wrong label after selection",
 48   
                      "Selected: three", label.getText());
 49   
 
 50  0
         tester.actionSelectRow(list, new JListLocation(0));
 51  0
         assertEquals("Wrong label after selection",
 52   
                      "Selected: one", label.getText());
 53   
     }
 54   
 
 55  0
     public LabeledListTest(String name) { super(name); }
 56   
 
 57  0
     public static void main(String[] args) {
 58  0
         TestHelper.runTests(args, LabeledListTest.class);
 59   
     }
 60   
 }
 61