Clover Coverage Report - FEST Swing 1.2
Coverage timestamp: Tue Jun 1 2010 15:19:25 PDT
../../../../img/srcFileCovDistChart9.png 85% of files have more coverage
16   67   11   4
6   33   0.69   4
4     2.75  
1    
3.7% of code in this file is excluded from these metrics.
 
  GUITestFinder       Line # 26 16 3.7% 11 4 84.6% 0.84615386
 
No Tests
 
1    /*
2    * Created on May 27, 2007
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5    * 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 is distributed on
10    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11    * specific language governing permissions and limitations under the License.
12    *
13    * Copyright @2007-2010 the original author or authors.
14    */
15    package org.fest.swing.annotation;
16   
17    import java.lang.reflect.AnnotatedElement;
18    import java.lang.reflect.Method;
19   
20    /**
21    * Understands utility methods related to GUI tests. A GUI test is a class or method annotated with
22    * <code>{@link org.fest.swing.annotation.GUITest}</code>.
23    *
24    * @author Alex Ruiz
25    */
 
26    public final class GUITestFinder {
27   
28    /**
29    * Returns <code>true</code> if the given class and/or method are annotated with <code>{@link GUITest}</code>. This
30    * method also searches in super-classes and overridden methods.
31    * @param type the class to check.
32    * @param method the method to check.
33    * @return <code>true</code> if the given class and/or method are annotated with <code>{@link GUITest}</code>.
34    */
 
35  5 toggle public static boolean isGUITest(Class<?> type, Method method) {
36  5 return isGUITest(type) || isGUITest(method) || isSuperClassGUITest(type, method);
37    }
38   
 
39  2 toggle private static boolean isSuperClassGUITest(Class<?> type, Method method) {
40  2 Class<?> superclass = type.getSuperclass();
41  3 while (superclass != null) {
42  2 if (isGUITest(superclass)) return true;
43  2 Method overriden = method(superclass, method.getName(), method.getParameterTypes());
44  1 if (overriden != null && isGUITest(overriden)) return true;
45  1 superclass = superclass.getSuperclass();
46    }
47  1 return false;
48    }
49   
 
50  2 toggle private static Method method(Class<?> type, String methodName, Class<?>[] parameterTypes) {
51  2 try {
52  2 return type.getDeclaredMethod(methodName, parameterTypes);
53    } catch (SecurityException e) {
54  0 return null;
55    } catch (NoSuchMethodException e) {
56  1 return null;
57    } catch (RuntimeException e) {
58  0 return null;
59    }
60    }
61   
 
62  11 toggle private static boolean isGUITest(AnnotatedElement annotatedElement) {
63  11 return annotatedElement.isAnnotationPresent(GUITest.class);
64    }
65   
 
66    toggle private GUITestFinder() {}
67    }