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
13   118   10   1.44
2   36   0.77   9
9     1.11  
1    
 
  MouseClickInfo       Line # 44 13 0% 10 0 100% 1.0
 
No Tests
 
1    /*
2    * Created on Sep 21, 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.core;
17   
18   
19    import static org.fest.swing.core.MouseButton.*;
20    import static org.fest.util.Strings.concat;
21   
22    /**
23    * Understands information about clicking a mouse button.
24    * <p>
25    * Examples:
26    * </p>
27    * <p>
28    * Specify that the right button should be clicked once:
29    * <pre>
30    * // import static org.fest.swing.fixture.MouseClickInfo.*;
31    * MouseClickInfo i = rightButton();
32    * </pre>
33    * </p>
34    * <p>
35    * Specify that the left button should be clicked two times (similar to double-click):
36    * <pre>
37    * // import static org.fest.swing.fixture.MouseClickInfo.*;
38    * MouseClickInfo i = leftButton().times(2);
39    * </pre>
40    * </p>
41    *
42    * @author Alex Ruiz
43    */
 
44    public final class MouseClickInfo {
45   
46    private final MouseButton button;
47    private int times;
48   
49    /**
50    * Specifies that the left button should be clicked once.
51    * @return the created click info.
52    */
 
53  14 toggle public static MouseClickInfo leftButton() {
54  14 return button(LEFT_BUTTON);
55    }
56   
57    /**
58    * Specifies that the middle button should be clicked once.
59    * @return the created click info.
60    */
 
61  24 toggle public static MouseClickInfo middleButton() {
62  24 return button(MIDDLE_BUTTON);
63    }
64   
65    /**
66    * Specifies that the right button should be clicked once.
67    * @return the created click info.
68    */
 
69  4 toggle public static MouseClickInfo rightButton() {
70  4 return button(RIGHT_BUTTON);
71    }
72   
73    /**
74    * Specifies that the given button should be clicked once.
75    * @param button the mouse button to click.
76    * @return the created click info.
77    * @throws NullPointerException if <code>button</code> is <code>null</code>.
78    */
 
79  43 toggle public static MouseClickInfo button(MouseButton button) {
80  43 return new MouseClickInfo(button, 1);
81    }
82   
 
83  43 toggle private MouseClickInfo(MouseButton button, int times) {
84  1 if (button == null) throw new NullPointerException("The MouseButton should not be null");
85  42 this.button = button;
86  42 this.times = times;
87    }
88   
89    /**
90    * Returns the button to click.
91    * @return the button to click.
92    */
 
93  21 toggle public MouseButton button() { return button; }
94   
95    /**
96    * Returns how many times the <code>{@link #button() mouse button}</code> should be clicked.
97    * @return how many times the <code>{@link #button() mouse button}</code> should be clicked.
98    */
 
99  21 toggle public int times() { return times; }
100   
101    /**
102    * Specifies how many times the mouse button should be clicked.
103    * @param newTimes the specified number of times to click the mouse button.
104    * @return this object.
105    */
 
106  32 toggle public MouseClickInfo times(int newTimes) {
107  32 times = newTimes;
108  32 return this;
109    }
110   
111    /** @see java.lang.Object#toString() */
 
112  1 toggle @Override public String toString() {
113  1 return concat(
114    getClass().getSimpleName(), "[",
115    "button=", button, ",",
116    "times=", String.valueOf(times), "]");
117    }
118    }