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
16   69   6   3.2
2   37   0.38   5
5     1.2  
1    
 
  ChildrenFinder       Line # 35 16 0% 6 2 91.3% 0.9130435
 
No Tests
 
1    /*
2    * Created on Oct 24, 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.hierarchy;
17   
18    import static java.util.Collections.emptyList;
19    import static org.fest.swing.hierarchy.ContainerComponentsQuery.componentsOf;
20   
21    import java.awt.Component;
22    import java.awt.Container;
23    import java.util.*;
24   
25    import org.fest.swing.annotation.RunsInCurrentThread;
26    import org.fest.util.VisibleForTesting;
27   
28   
29    /**
30    * Understands how to find children components in a <code>{@link Container}</code>.
31    *
32    * @author Yvonne Wang
33    * @author Alex Ruiz
34    */
 
35    class ChildrenFinder {
36   
37    private static List<ChildrenFinderStrategy> strategies = new ArrayList<ChildrenFinderStrategy>();
38   
 
39  626 toggle static {
40  626 strategies.add(new JDesktopPaneChildrenFinder());
41  626 strategies.add(new JMenuChildrenFinder());
42  626 strategies.add(new WindowChildrenFinder());
43    }
44   
 
45  106838 toggle @RunsInCurrentThread
46    Collection<Component> childrenOf(Component c) {
47  106838 if (!(c instanceof Container)) return emptyList();
48  106838 Container container = (Container)c;
49  106838 Collection<Component> children = new ArrayList<Component>();
50  106838 children.addAll(componentsOf(container));
51  106838 children.addAll(nonExplicitChildrenOf(container));
52  106838 return children;
53    }
54   
 
55  106837 toggle private Collection<Component> nonExplicitChildrenOf(Container c) {
56  106836 Collection<Component> children = new ArrayList<Component>();
57  106837 for (ChildrenFinderStrategy s : strategies)
58  320508 children.addAll(s.nonExplicitChildrenOf(c));
59  106838 return children;
60    }
61   
 
62  2 toggle @VisibleForTesting
63  2 static List<ChildrenFinderStrategy> strategies() { return new ArrayList<ChildrenFinderStrategy>(strategies); }
64   
 
65  4 toggle @VisibleForTesting
66    static void replaceStrategiesWith(List<ChildrenFinderStrategy> newStrategies) {
67  4 strategies = new ArrayList<ChildrenFinderStrategy>(newStrategies);
68    }
69    }