Clover Coverage Report - FEST Swing 1.2
Coverage timestamp: Tue Jun 1 2010 15:19:25 PDT
../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
6   133   6   1
0   25   1   6
6     1  
1    
7.7% of code in this file is excluded from these metrics.
 
  WindowFinder       Line # 74 6 7.7% 6 0 100% 1.0
 
No Tests
 
1    /*
2    * Created on Jul 30, 2007
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5    * in compliance with the License. You may obtain a copy of the License at
6    *
7    * http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software distributed under the License
10    * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11    * or implied. See the License for the specific language governing permissions and limitations under
12    * the License.
13    *
14    * Copyright @2007-2010 the original author or authors.
15    */
16    package org.fest.swing.finder;
17   
18    import java.awt.Dialog;
19    import java.awt.Frame;
20   
21    import org.fest.swing.core.GenericTypeMatcher;
22   
23    /**
24    * <p>
25    * Understands lookup of <code>{@link Frame}</code>s and <code>{@link Dialog}</code>s. Lookups are performed till
26    * the window of interest is found, or until the given time to perform the lookup is over. The default lookup time is 5
27    * seconds.
28    * </p>
29    * <p>
30    * <code>{@link WindowFinder}</code> is the &quot;entry point&quot; of a fluent interface to look up frames and
31    * dialogs. This example illustrates finding a <code>{@link Frame}</code> by name, using the default lookup time (5
32    * seconds):
33    *
34    * <pre>
35    * FrameFixture frame = WindowFinder.findFrame(&quot;someFrame&quot;).using(robot);
36    * </pre>
37    *
38    * </p>
39    * <p>
40    * Where <code>robot</code> is an instance of <code>{@link org.fest.swing.core.Robot}</code>.
41    * </p>
42    * <p>
43    * This example shows how to find a <code>{@link Dialog}</code> by type using a lookup time of 10 seconds:
44    *
45    * <pre>
46    * DialogFixture dialog = WindowFinder.findDialog(MyDialog.class).withTimeout(10000).using(robot);
47    * </pre>
48    *
49    * We can also specify the time unit:
50    *
51    * <pre>
52    * DialogFixture dialog = WindowFinder.findDialog(MyDialog.class).withTimeout(10, {@link java.util.concurrent.TimeUnit#SECONDS SECONDS}).using(robot);
53    * </pre>
54    *
55    * </p>
56    * <p>
57    * This example shows how to use a <code>{@link GenericTypeMatcher}</code> to find a <code>{@link Frame}</code> with
58    * title "Hello":
59    *
60    * <pre>
61    * GenericTypeMatcher&lt;JFrame&gt; matcher = new GenericTypeMatcher&lt;JFrame&gt;() {
62    * protected boolean isMatching(JFrame frame) {
63    * return &quot;hello&quot;.equals(frame.getTitle());
64    * }
65    * };
66    * FrameFixture frame = WindowFinder.findFrame(matcher).using(robot);
67    * </pre>
68    *
69    * </p>
70    *
71    * @author Alex Ruiz
72    * @author Yvonne Wang
73    */
 
74    public final class WindowFinder {
75   
 
76    toggle private WindowFinder() {}
77   
78    /**
79    * Creates a new <code>{@link FrameFinder}</code> capable of looking up a <code>{@link Frame}</code> by name.
80    * @param frameName the name of the frame to find.
81    * @return the created finder.
82    */
 
83  10 toggle public static FrameFinder findFrame(String frameName) {
84  10 return new FrameFinder(frameName);
85    }
86   
87    /**
88    * Creates a new <code>{@link FrameFinder}</code> capable of looking up a <code>{@link Frame}</code> by type.
89    * @param frameType the type of the frame to find.
90    * @return the created finder.
91    */
 
92  7 toggle public static FrameFinder findFrame(Class<? extends Frame> frameType) {
93  7 return new FrameFinder(frameType);
94    }
95   
96    /**
97    * Creates a new <code>{@link FrameFinder}</code> capable of looking up a <code>{@link Frame}</code> using the
98    * provided matcher.
99    * @param matcher the matcher to use to find a frame.
100    * @return the created finder.
101    */
 
102  10 toggle public static FrameFinder findFrame(GenericTypeMatcher<? extends Frame> matcher) {
103  10 return new FrameFinder(matcher);
104    }
105   
106    /**
107    * Creates a new <code>{@link DialogFinder}</code> capable of looking up a <code>{@link Dialog}</code> by name.
108    * @param dialogName the name of the dialog to find.
109    * @return the created finder.
110    */
 
111  8 toggle public static DialogFinder findDialog(String dialogName) {
112  8 return new DialogFinder(dialogName);
113    }
114   
115    /**
116    * Creates a new <code>{@link DialogFinder}</code> capable of looking up a <code>{@link Dialog}</code> by type.
117    * @param dialogType the type of the dialog to find.
118    * @return the created finder.
119    */
 
120  9 toggle public static DialogFinder findDialog(Class<? extends Dialog> dialogType) {
121  9 return new DialogFinder(dialogType);
122    }
123   
124    /**
125    * Creates a new <code>{@link DialogFinder}</code> capable of looking up a <code>{@link Dialog}</code> using the
126    * provided matcher.
127    * @param matcher the matcher to use to find a dialog.
128    * @return the created finder.
129    */
 
130  9 toggle public static DialogFinder findDialog(GenericTypeMatcher<? extends Dialog> matcher) {
131  9 return new DialogFinder(matcher);
132    }
133    }