| 
     1
 | 
        
 | 
       package junit.extensions.jfcunit.finder; 
 | 
 
 | 
     2
 | 
        
 | 
        
 | 
 
 | 
     3
 | 
        
 | 
       import junit.extensions.jfcunit.AbstractTestCase; 
 | 
 
 | 
     4
 | 
        
 | 
        
 | 
 
 | 
     5
 | 
        
 | 
       import javax.swing.JFrame; 
 | 
 
 | 
     6
 | 
        
 | 
       import javax.swing.JLabel; 
 | 
 
 | 
     7
 | 
        
 | 
        
 | 
 
 | 
     8
 | 
        
 | 
        
 | 
 
 | 
     9
 | 
        
 | 
        
 | 
 
 | 
     10
 | 
        
 | 
        
 | 
 
 | 
     11
 | 
        
 | 
        
 | 
 
 | 
     12
 | 
        
 | 
        
 | 
 
 | 
    13
 | 
        
 | 
       public class JLabelFinderT extends AbstractTestCase {
 | 
 
 | 
     14
 | 
        
 | 
            
 | 
 
 | 
     15
 | 
        
 | 
        
 | 
 
 | 
     16
 | 
        
 | 
        
 | 
 
 | 
     17
 | 
        
 | 
        
 | 
 
 | 
     18
 | 
        
 | 
        
 | 
 
 | 
     19
 | 
     8
 | 
        public JLabelFinderT(final String name) {
 | 
 
 | 
     20
 | 
     8
 | 
            super(name); 
 | 
 
 | 
     21
 | 
        
 | 
           } 
 | 
 
 | 
     22
 | 
        
 | 
        
 | 
 
 | 
     23
 | 
        
 | 
            
 | 
 
 | 
     24
 | 
        
 | 
        
 | 
 
 | 
     25
 | 
        
 | 
        
 | 
 
 | 
     26
 | 
        
 | 
        
 | 
 
 | 
     27
 | 
        
 | 
        
 | 
 
 | 
     28
 | 
     1
 | 
        public void testInvalidComponent() throws Exception {
 | 
 
 | 
     29
 | 
     1
 | 
            JLabelFinder finder = new JLabelFinder("Dum");
 | 
 
 | 
     30
 | 
     1
 | 
            JLabel label = new JLabel("Dummy");
 | 
 
 | 
     31
 | 
     1
 | 
            JFrame frame = createJFrame(getName()); 
 | 
 
 | 
     32
 | 
     1
 | 
            setWindow(frame); 
 | 
 
 | 
     33
 | 
     1
 | 
            frame.getContentPane().add(label); 
 | 
 
 | 
     34
 | 
     1
 | 
            packAndShow(frame); 
 | 
 
 | 
     35
 | 
     1
 | 
            assertFalse("Finder is not working", finder.testComponent(frame));
 | 
 
 | 
     36
 | 
        
 | 
           } 
 | 
 
 | 
     37
 | 
        
 | 
        
 | 
 
 | 
     38
 | 
        
 | 
            
 | 
 
 | 
     39
 | 
        
 | 
        
 | 
 
 | 
     40
 | 
        
 | 
        
 | 
 
 | 
     41
 | 
        
 | 
        
 | 
 
 | 
     42
 | 
        
 | 
        
 | 
 
 | 
     43
 | 
     1
 | 
        public void testNullLabel() throws Exception {
 | 
 
 | 
     44
 | 
     1
 | 
            JLabelFinder finder = new JLabelFinder(null); 
 | 
 
 | 
     45
 | 
     1
 | 
            JLabel label = new JLabel(); 
 | 
 
 | 
     46
 | 
     1
 | 
            JFrame frame = createJFrame(getName()); 
 | 
 
 | 
     47
 | 
     1
 | 
            setWindow(frame); 
 | 
 
 | 
     48
 | 
     1
 | 
            frame.getContentPane().add(label); 
 | 
 
 | 
     49
 | 
     1
 | 
            packAndShow(frame); 
 | 
 
 | 
     50
 | 
     1
 | 
            assertFalse("Finder is not working", finder.testComponent(label));
 | 
 
 | 
     51
 | 
        
 | 
           } 
 | 
 
 | 
     52
 | 
        
 | 
        
 | 
 
 | 
     53
 | 
        
 | 
            
 | 
 
 | 
     54
 | 
        
 | 
        
 | 
 
 | 
     55
 | 
        
 | 
        
 | 
 
 | 
     56
 | 
        
 | 
        
 | 
 
 | 
     57
 | 
        
 | 
        
 | 
 
 | 
     58
 | 
     1
 | 
        public void testEmptyLabel() throws Exception {
 | 
 
 | 
     59
 | 
     1
 | 
            JLabelFinder finder = new JLabelFinder("");
 | 
 
 | 
     60
 | 
     1
 | 
            JLabel label = new JLabel("Dummy");
 | 
 
 | 
     61
 | 
     1
 | 
            JFrame frame = createJFrame(getName()); 
 | 
 
 | 
     62
 | 
     1
 | 
            setWindow(frame); 
 | 
 
 | 
     63
 | 
     1
 | 
            frame.getContentPane().add(label); 
 | 
 
 | 
     64
 | 
     1
 | 
            packAndShow(frame); 
 | 
 
 | 
     65
 | 
     1
 | 
            assertTrue("Finder is not working", finder.testComponent(label));
 | 
 
 | 
     66
 | 
        
 | 
           } 
 | 
 
 | 
     67
 | 
        
 | 
        
 | 
 
 | 
     68
 | 
        
 | 
            
 | 
 
 | 
     69
 | 
        
 | 
        
 | 
 
 | 
     70
 | 
        
 | 
        
 | 
 
 | 
     71
 | 
        
 | 
        
 | 
 
 | 
     72
 | 
        
 | 
        
 | 
 
 | 
     73
 | 
     1
 | 
        public void testInvalidLabel() throws Exception {
 | 
 
 | 
     74
 | 
     1
 | 
            JLabelFinder finder = new JLabelFinder("Dummy");
 | 
 
 | 
     75
 | 
     1
 | 
            JLabel label = new JLabel("");
 | 
 
 | 
     76
 | 
     1
 | 
            JFrame frame = createJFrame(getName()); 
 | 
 
 | 
     77
 | 
     1
 | 
            setWindow(frame); 
 | 
 
 | 
     78
 | 
     1
 | 
            frame.getContentPane().add(label); 
 | 
 
 | 
     79
 | 
     1
 | 
            packAndShow(frame); 
 | 
 
 | 
     80
 | 
     1
 | 
            assertFalse("Finder is not working", finder.testComponent(label));
 | 
 
 | 
     81
 | 
        
 | 
           } 
 | 
 
 | 
     82
 | 
        
 | 
        
 | 
 
 | 
     83
 | 
        
 | 
            
 | 
 
 | 
     84
 | 
        
 | 
        
 | 
 
 | 
     85
 | 
        
 | 
        
 | 
 
 | 
     86
 | 
        
 | 
        
 | 
 
 | 
     87
 | 
        
 | 
        
 | 
 
 | 
     88
 | 
     1
 | 
        public void testValidLabel1CaseSensitive() throws Exception {
 | 
 
 | 
     89
 | 
     1
 | 
            JLabelFinder finder = new JLabelFinder("Dum");
 | 
 
 | 
     90
 | 
     1
 | 
            JLabel label = new JLabel("Dummy");
 | 
 
 | 
     91
 | 
     1
 | 
            JFrame frame = createJFrame(getName()); 
 | 
 
 | 
     92
 | 
     1
 | 
            setWindow(frame); 
 | 
 
 | 
     93
 | 
     1
 | 
            frame.getContentPane().add(label); 
 | 
 
 | 
     94
 | 
     1
 | 
            packAndShow(frame); 
 | 
 
 | 
     95
 | 
     1
 | 
            assertTrue("Finder is not working", finder.testComponent(label));
 | 
 
 | 
     96
 | 
        
 | 
           } 
 | 
 
 | 
     97
 | 
        
 | 
        
 | 
 
 | 
     98
 | 
        
 | 
            
 | 
 
 | 
     99
 | 
        
 | 
        
 | 
 
 | 
     100
 | 
        
 | 
        
 | 
 
 | 
     101
 | 
        
 | 
        
 | 
 
 | 
     102
 | 
        
 | 
        
 | 
 
 | 
     103
 | 
     1
 | 
        public void testValidLabel1CaseInsensitive() throws Exception {
 | 
 
 | 
     104
 | 
     1
 | 
            JLabelFinder finder = new JLabelFinder("dum", true);
 | 
 
 | 
     105
 | 
     1
 | 
            JLabel label = new JLabel("Dummy");
 | 
 
 | 
     106
 | 
     1
 | 
            JFrame frame = createJFrame(getName()); 
 | 
 
 | 
     107
 | 
     1
 | 
            setWindow(frame); 
 | 
 
 | 
     108
 | 
     1
 | 
            frame.getContentPane().add(label); 
 | 
 
 | 
     109
 | 
     1
 | 
            packAndShow(frame); 
 | 
 
 | 
     110
 | 
     1
 | 
            assertTrue("Finder is not working", finder.testComponent(label));
 | 
 
 | 
     111
 | 
        
 | 
           } 
 | 
 
 | 
     112
 | 
        
 | 
        
 | 
 
 | 
     113
 | 
        
 | 
            
 | 
 
 | 
     114
 | 
        
 | 
        
 | 
 
 | 
     115
 | 
        
 | 
        
 | 
 
 | 
     116
 | 
        
 | 
        
 | 
 
 | 
     117
 | 
        
 | 
        
 | 
 
 | 
     118
 | 
     1
 | 
        public void testValidLabel2() throws Exception {
 | 
 
 | 
     119
 | 
     1
 | 
            JLabelFinder finder = new JLabelFinder("");
 | 
 
 | 
     120
 | 
     1
 | 
            JLabel label = new JLabel("Dummy");
 | 
 
 | 
     121
 | 
     1
 | 
            JFrame frame = createJFrame(getName()); 
 | 
 
 | 
     122
 | 
     1
 | 
            setWindow(frame); 
 | 
 
 | 
     123
 | 
     1
 | 
            frame.getContentPane().add(label); 
 | 
 
 | 
     124
 | 
     1
 | 
            packAndShow(frame); 
 | 
 
 | 
     125
 | 
     1
 | 
            assertTrue("Finder is not working", finder.testComponent(label));
 | 
 
 | 
     126
 | 
        
 | 
           } 
 | 
 
 | 
     127
 | 
        
 | 
        
 | 
 
 | 
     128
 | 
        
 | 
            
 | 
 
 | 
     129
 | 
        
 | 
        
 | 
 
 | 
     130
 | 
        
 | 
        
 | 
 
 | 
     131
 | 
     1
 | 
        public void testText() {
 | 
 
 | 
     132
 | 
     1
 | 
            JLabelFinder finder = new JLabelFinder(null); 
 | 
 
 | 
     133
 | 
     1
 | 
            assertEquals(null, finder.getText()); 
 | 
 
 | 
     134
 | 
        
 | 
        
 | 
 
 | 
     135
 | 
     1
 | 
            finder.setText("ABC");
 | 
 
 | 
     136
 | 
     1
 | 
            assertEquals("ABC", finder.getText());
 | 
 
 | 
     137
 | 
        
 | 
           } 
 | 
 
 | 
     138
 | 
        
 | 
       } 
 | 
 
 | 
     139
 | 
        
 | 
        
 |