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
11   53   4   5.5
4   25   0.36   2
2     2  
1    
 
  MultipleSelectionTemplate       Line # 28 11 0% 4 0 100% 1.0
 
No Tests
 
1    /*
2    * Created on May 8, 2008
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 @2008-2010 the original author or authors.
15    */
16    package org.fest.swing.driver;
17   
18    import static org.fest.swing.util.Platform.controlOrCommandKey;
19   
20    import org.fest.swing.annotation.RunsInEDT;
21    import org.fest.swing.core.Robot;
22   
23    /**
24    * Understands a template for simulating multiple selection on a GUI component.
25    *
26    * @author Yvonne Wang
27    */
 
28    abstract class MultipleSelectionTemplate {
29   
30    private final Robot robot;
31   
 
32  39 toggle MultipleSelectionTemplate(Robot robot) {
33  39 this.robot = robot;
34    }
35   
36    abstract int elementCount();
37   
 
38  39 toggle @RunsInEDT
39    final void multiSelect() {
40  39 int elementCount = elementCount();
41  39 selectElement(0);
42  4 if (elementCount == 1) return;
43  14 int key = controlOrCommandKey();
44  14 robot.pressKey(key);
45  14 try {
46  15 for (int i = 1; i < elementCount; i++) selectElement(i);
47    } finally {
48  14 robot.releaseKey(key);
49    }
50    }
51   
52    abstract void selectElement(int index);
53    }