|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| JTextComponentFixture | Line # 38 | 69 | 0% | 37 | 0 | 100% |
1.0
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| No Tests | |||
| 1 | /* | |
| 2 | * Created on Oct 20, 2006 | |
| 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 @2006-2010 the original author or authors. | |
| 15 | */ | |
| 16 | package org.fest.swing.fixture; | |
| 17 | ||
| 18 | import java.awt.Point; | |
| 19 | import java.util.regex.Pattern; | |
| 20 | ||
| 21 | import javax.swing.text.JTextComponent; | |
| 22 | ||
| 23 | import org.fest.swing.core.*; | |
| 24 | import org.fest.swing.driver.JTextComponentDriver; | |
| 25 | import org.fest.swing.exception.*; | |
| 26 | import org.fest.swing.timing.Timeout; | |
| 27 | ||
| 28 | /** | |
| 29 | * Understands functional testing of <code>{@link JTextComponent}</code>s: | |
| 30 | * <ul> | |
| 31 | * <li>user input simulation</li> | |
| 32 | * <li>state verification</li> | |
| 33 | * <li>property value query</li> | |
| 34 | * </ul> | |
| 35 | * | |
| 36 | * @author Alex Ruiz | |
| 37 | */ | |
| 38 | public class JTextComponentFixture extends ComponentFixture<JTextComponent> | |
| 39 | implements CommonComponentFixture, JComponentFixture, JPopupMenuInvokerFixture, TextInputFixture { | |
| 40 | ||
| 41 | private JTextComponentDriver driver; | |
| 42 | ||
| 43 | /** | |
| 44 | * Creates a new <code>{@link JTextComponentFixture}</code>. | |
| 45 | * @param robot performs simulation of user events on the given <code>JTextComponent</code>. | |
| 46 | * @param target the <code>JTextComponent</code> to be managed by this fixture. | |
| 47 | * @throws NullPointerException if <code>robot</code> is <code>null</code>. | |
| 48 | * @throws NullPointerException if <code>target</code> is <code>null</code>. | |
| 49 | */ | |
| 50 | 39 |
public JTextComponentFixture(Robot robot, JTextComponent target) { |
| 51 | 39 | super(robot, target); |
| 52 | 39 | createDriver(); |
| 53 | } | |
| 54 | ||
| 55 | /** | |
| 56 | * Creates a new <code>{@link JTextComponentFixture}</code>. | |
| 57 | * @param robot performs simulation of user events on a <code>JTextComponent</code>. | |
| 58 | * @param textComponentName the name of the <code>JTextComponent</code> to find using the given <code>Robot</code>. | |
| 59 | * @throws NullPointerException if <code>robot</code> is <code>null</code>. | |
| 60 | * @throws ComponentLookupException if a matching <code>JTextComponent</code> could not be found. | |
| 61 | * @throws ComponentLookupException if more than one matching <code>JTextComponent</code> is found. | |
| 62 | */ | |
| 63 | 3 |
public JTextComponentFixture(Robot robot, String textComponentName) { |
| 64 | 3 | super(robot, textComponentName, JTextComponent.class); |
| 65 | 3 | createDriver(); |
| 66 | } | |
| 67 | ||
| 68 | 42 |
private void createDriver() { |
| 69 | 42 | driver(new JTextComponentDriver(robot)); |
| 70 | } | |
| 71 | ||
| 72 | /** | |
| 73 | * Sets the <code>{@link JTextComponentDriver}</code> to be used by this fixture. | |
| 74 | * @param newDriver the new <code>JTextComponentDriver</code>. | |
| 75 | * @throws NullPointerException if the given driver is <code>null</code>. | |
| 76 | */ | |
| 77 | 76 |
protected final void driver(JTextComponentDriver newDriver) { |
| 78 | 76 | validateNotNull(newDriver); |
| 79 | 75 | driver = newDriver; |
| 80 | } | |
| 81 | ||
| 82 | /** | |
| 83 | * Returns the text of this fixture's <code>{@link JTextComponent}</code>. | |
| 84 | * @return the text of this fixture's <code>JTextComponent</code>. | |
| 85 | */ | |
| 86 | 1 |
public String text() { |
| 87 | 1 | return driver.textOf(target); |
| 88 | } | |
| 89 | ||
| 90 | /** | |
| 91 | * Simulates a user selecting the given text contained in this fixture's <code>{@link JTextComponent}</code>. | |
| 92 | * @param text the text to select. | |
| 93 | * @return this fixture. | |
| 94 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is disabled. | |
| 95 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is not showing on the screen. | |
| 96 | * @throws IllegalArgumentException if this fixture's <code>JTextComponent</code> does not contain the given text to | |
| 97 | * select. | |
| 98 | * @throws ActionFailedException if the selecting the text in the given range fails. | |
| 99 | */ | |
| 100 | 1 |
public JTextComponentFixture select(String text) { |
| 101 | 1 | driver.selectText(target, text); |
| 102 | 1 | return this; |
| 103 | } | |
| 104 | ||
| 105 | /** | |
| 106 | * Simulates a user selecting a portion of the text contained in this fixture's <code>{@link JTextComponent}</code>. | |
| 107 | * @param start index where selection should start. | |
| 108 | * @param end index where selection should end. | |
| 109 | * @return this fixture. | |
| 110 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is disabled. | |
| 111 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is not showing on the screen. | |
| 112 | * @throws ActionFailedException if the selecting the text in the given range fails. | |
| 113 | */ | |
| 114 | 1 |
public JTextComponentFixture selectText(int start, int end) { |
| 115 | 1 | driver.selectText(target, start, end); |
| 116 | 1 | return this; |
| 117 | } | |
| 118 | ||
| 119 | /** | |
| 120 | * Simulates a user selecting all the text contained in this fixture's <code>{@link JTextComponent}</code>. | |
| 121 | * @return this fixture. | |
| 122 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is disabled. | |
| 123 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is not showing on the screen. | |
| 124 | */ | |
| 125 | 1 |
public JTextComponentFixture selectAll() { |
| 126 | 1 | driver.selectAll(target); |
| 127 | 1 | return this; |
| 128 | } | |
| 129 | ||
| 130 | /** | |
| 131 | * Simulates a user clicking this fixture's <code>{@link JTextComponent}</code>. | |
| 132 | * @return this fixture. | |
| 133 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is disabled. | |
| 134 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is not showing on the screen. | |
| 135 | */ | |
| 136 | 1 |
public JTextComponentFixture click() { |
| 137 | 1 | driver.click(target); |
| 138 | 1 | return this; |
| 139 | } | |
| 140 | ||
| 141 | /** | |
| 142 | * Simulates a user clicking this fixture's <code>{@link JTextComponent}</code>. | |
| 143 | * @param button the button to click. | |
| 144 | * @return this fixture. | |
| 145 | * @throws NullPointerException if the given <code>MouseButton</code> is <code>null</code>. | |
| 146 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is disabled. | |
| 147 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is not showing on the screen. | |
| 148 | */ | |
| 149 | 1 |
public JTextComponentFixture click(MouseButton button) { |
| 150 | 1 | driver.click(target, button); |
| 151 | 1 | return this; |
| 152 | } | |
| 153 | ||
| 154 | /** | |
| 155 | * Simulates a user clicking this fixture's <code>{@link JTextComponent}</code>. | |
| 156 | * @param mouseClickInfo specifies the button to click and the times the button should be clicked. | |
| 157 | * @return this fixture. | |
| 158 | * @throws NullPointerException if the given <code>MouseClickInfo</code> is <code>null</code>. | |
| 159 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is disabled. | |
| 160 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is not showing on the screen. | |
| 161 | */ | |
| 162 | 1 |
public JTextComponentFixture click(MouseClickInfo mouseClickInfo) { |
| 163 | 1 | driver.click(target, mouseClickInfo); |
| 164 | 1 | return this; |
| 165 | } | |
| 166 | ||
| 167 | /** | |
| 168 | * Simulates a user double-clicking this fixture's <code>{@link JTextComponent}</code>. | |
| 169 | * @return this fixture. | |
| 170 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is disabled. | |
| 171 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is not showing on the screen. | |
| 172 | */ | |
| 173 | 1 |
public JTextComponentFixture doubleClick() { |
| 174 | 1 | driver.doubleClick(target); |
| 175 | 1 | return this; |
| 176 | } | |
| 177 | ||
| 178 | /** | |
| 179 | * Simulates a user right-clicking this fixture's <code>{@link JTextComponent}</code>. | |
| 180 | * @return this fixture. | |
| 181 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is disabled. | |
| 182 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is not showing on the screen. | |
| 183 | */ | |
| 184 | 1 |
public JTextComponentFixture rightClick() { |
| 185 | 1 | driver.rightClick(target); |
| 186 | 1 | return this; |
| 187 | } | |
| 188 | ||
| 189 | /** | |
| 190 | * Simulates a user deleting all the text in this fixture's <code>{@link JTextComponent}</code>. | |
| 191 | * @return this fixture. | |
| 192 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is disabled. | |
| 193 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is not showing on the screen. | |
| 194 | */ | |
| 195 | 1 |
public JTextComponentFixture deleteText() { |
| 196 | 1 | driver.deleteText(target); |
| 197 | 1 | return this; |
| 198 | } | |
| 199 | ||
| 200 | /** | |
| 201 | * Simulates a user entering the given text in this fixture's <code>{@link JTextComponent}</code>. | |
| 202 | * @param text the text to enter. | |
| 203 | * @return this fixture. | |
| 204 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is disabled. | |
| 205 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is not showing on the screen. | |
| 206 | */ | |
| 207 | 1 |
public JTextComponentFixture enterText(String text) { |
| 208 | 1 | driver.enterText(target, text); |
| 209 | 1 | return this; |
| 210 | } | |
| 211 | ||
| 212 | /** | |
| 213 | * Sets the text in this fixture's <code>{@link JTextComponent}</code>. Unlike | |
| 214 | * <code>{@link #enterText(String)}</code>, this method bypasses the event system and allows immediate updating on the | |
| 215 | * underlying document model. | |
| 216 | * <p> | |
| 217 | * Primarily desired for speeding up tests when precise user event fidelity isn't necessary. | |
| 218 | * </p> | |
| 219 | * @param text the text to set. | |
| 220 | * @return this fixture. | |
| 221 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is disabled. | |
| 222 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is not showing on the screen. | |
| 223 | */ | |
| 224 | 1 |
public JTextComponentFixture setText(String text) { |
| 225 | 1 | driver.setText(target, text); |
| 226 | 1 | return this; |
| 227 | } | |
| 228 | ||
| 229 | /** | |
| 230 | * Gives input focus to this fixture's <code>{@link JTextComponent}</code>. | |
| 231 | * @return this fixture. | |
| 232 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is disabled. | |
| 233 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is not showing on the screen. | |
| 234 | */ | |
| 235 | 1 |
public JTextComponentFixture focus() { |
| 236 | 1 | driver.focus(target); |
| 237 | 1 | return this; |
| 238 | } | |
| 239 | ||
| 240 | /** | |
| 241 | * Simulates a user pressing given key with the given modifiers on this fixture's <code>{@link JTextComponent}</code>. | |
| 242 | * Modifiers is a mask from the available <code>{@link java.awt.event.InputEvent}</code> masks. | |
| 243 | * @param keyPressInfo specifies the key and modifiers to press. | |
| 244 | * @return this fixture. | |
| 245 | * @throws NullPointerException if the given <code>KeyPressInfo</code> is <code>null</code>. | |
| 246 | * @throws IllegalArgumentException if the given code is not a valid key code. | |
| 247 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is disabled. | |
| 248 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is not showing on the screen. | |
| 249 | * @see KeyPressInfo | |
| 250 | */ | |
| 251 | 1 |
public JTextComponentFixture pressAndReleaseKey(KeyPressInfo keyPressInfo) { |
| 252 | 1 | driver.pressAndReleaseKey(target, keyPressInfo); |
| 253 | 1 | return this; |
| 254 | } | |
| 255 | ||
| 256 | /** | |
| 257 | * Simulates a user pressing and releasing the given keys in this fixture's <code>{@link JTextComponent}</code>. This | |
| 258 | * method does not affect the current focus. | |
| 259 | * @param keyCodes the codes of the keys to press. | |
| 260 | * @return this fixture. | |
| 261 | * @throws NullPointerException if the given array of codes is <code>null</code>. | |
| 262 | * @throws IllegalArgumentException if any of the given code is not a valid key code. | |
| 263 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is disabled. | |
| 264 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is not showing on the screen. | |
| 265 | * @see java.awt.event.KeyEvent | |
| 266 | */ | |
| 267 | 1 |
public JTextComponentFixture pressAndReleaseKeys(int...keyCodes) { |
| 268 | 1 | driver.pressAndReleaseKeys(target, keyCodes); |
| 269 | 1 | return this; |
| 270 | } | |
| 271 | ||
| 272 | /** | |
| 273 | * Simulates a user pressing the given key on this fixture's <code>{@link JTextComponent}</code>. | |
| 274 | * @param keyCode the code of the key to press. | |
| 275 | * @return this fixture. | |
| 276 | * @throws IllegalArgumentException if any of the given code is not a valid key code. | |
| 277 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is disabled. | |
| 278 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is not showing on the screen. | |
| 279 | * @see java.awt.event.KeyEvent | |
| 280 | */ | |
| 281 | 1 |
public JTextComponentFixture pressKey(int keyCode) { |
| 282 | 1 | driver.pressKey(target, keyCode); |
| 283 | 1 | return this; |
| 284 | } | |
| 285 | ||
| 286 | /** | |
| 287 | * Simulates a user releasing the given key on this fixture's <code>{@link JTextComponent}</code>. | |
| 288 | * @param keyCode the code of the key to release. | |
| 289 | * @return this fixture. | |
| 290 | * @throws IllegalArgumentException if any of the given code is not a valid key code. | |
| 291 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is disabled. | |
| 292 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is not showing on the screen. | |
| 293 | * @see java.awt.event.KeyEvent | |
| 294 | */ | |
| 295 | 1 |
public JTextComponentFixture releaseKey(int keyCode) { |
| 296 | 1 | driver.releaseKey(target, keyCode); |
| 297 | 1 | return this; |
| 298 | } | |
| 299 | ||
| 300 | /** | |
| 301 | * Asserts that the text of this fixture's <code>{@link JTextComponent}</code> is equal to the specified value. | |
| 302 | * @param expected the text to match. It can be a regular expression pattern. | |
| 303 | * @return this fixture. | |
| 304 | * @throws AssertionError if the text of this fixture's <code>JTextComponent</code> is not equal to the given one. | |
| 305 | */ | |
| 306 | 2 |
public JTextComponentFixture requireText(String expected) { |
| 307 | 2 | driver.requireText(target, expected); |
| 308 | 2 | return this; |
| 309 | } | |
| 310 | ||
| 311 | /** | |
| 312 | * Asserts that the text of this fixture's <code>{@link JTextComponent}</code> matches the given regular expression | |
| 313 | * pattern. | |
| 314 | * @param pattern the regular expression pattern to match. | |
| 315 | * @return this fixture. | |
| 316 | * @throws NullPointerException if the given regular expression pattern is <code>null</code>. | |
| 317 | * @throws AssertionError if the text of this fixture's <code>JTextComponent</code> is not eual to the given one. | |
| 318 | * @since 1.2 | |
| 319 | */ | |
| 320 | 1 |
public JTextComponentFixture requireText(Pattern pattern) { |
| 321 | 1 | driver.requireText(target, pattern); |
| 322 | 1 | return this; |
| 323 | } | |
| 324 | ||
| 325 | /** | |
| 326 | * Asserts that the target text component does not contain any text. | |
| 327 | * @return this fixture. | |
| 328 | * @throws AssertionError if the target text component is not empty. | |
| 329 | */ | |
| 330 | 1 |
public JTextComponentFixture requireEmpty() { |
| 331 | 1 | driver.requireEmpty(target); |
| 332 | 1 | return this; |
| 333 | } | |
| 334 | ||
| 335 | /** | |
| 336 | * Asserts that this fixture's <code>{@link JTextComponent}</code> has input focus. | |
| 337 | * @return this fixture. | |
| 338 | * @throws AssertionError if this fixture's <code>JTextComponent</code> does not have input focus. | |
| 339 | */ | |
| 340 | 1 |
public JTextComponentFixture requireFocused() { |
| 341 | 1 | driver.requireFocused(target); |
| 342 | 1 | return this; |
| 343 | } | |
| 344 | ||
| 345 | /** | |
| 346 | * Asserts that this fixture's <code>{@link JTextComponent}</code> is enabled. | |
| 347 | * @return this fixture. | |
| 348 | * @throws AssertionError if this fixture's <code>JTextComponent</code> is disabled. | |
| 349 | */ | |
| 350 | 1 |
public JTextComponentFixture requireEnabled() { |
| 351 | 1 | driver.requireEnabled(target); |
| 352 | 1 | return this; |
| 353 | } | |
| 354 | ||
| 355 | /** | |
| 356 | * Asserts that this fixture's <code>{@link JTextComponent}</code> is enabled. | |
| 357 | * @param timeout the time this fixture will wait for the component to be enabled. | |
| 358 | * @return this fixture. | |
| 359 | * @throws WaitTimedOutError if this fixture's <code>JTextComponent</code> is never enabled. | |
| 360 | */ | |
| 361 | 1 |
public JTextComponentFixture requireEnabled(Timeout timeout) { |
| 362 | 1 | driver.requireEnabled(target, timeout); |
| 363 | 1 | return this; |
| 364 | } | |
| 365 | ||
| 366 | /** | |
| 367 | * Asserts that this fixture's <code>{@link JTextComponent}</code> is disabled. | |
| 368 | * @return this fixture. | |
| 369 | * @throws AssertionError if this fixture's <code>JTextComponent</code> is enabled. | |
| 370 | */ | |
| 371 | 1 |
public JTextComponentFixture requireDisabled() { |
| 372 | 1 | driver.requireDisabled(target); |
| 373 | 1 | return this; |
| 374 | } | |
| 375 | ||
| 376 | /** | |
| 377 | * Asserts that this fixture's <code>{@link JTextComponent}</code> is visible. | |
| 378 | * @return this fixture. | |
| 379 | * @throws AssertionError if this fixture's <code>JTextComponent</code> is not visible. | |
| 380 | */ | |
| 381 | 1 |
public JTextComponentFixture requireVisible() { |
| 382 | 1 | driver.requireVisible(target); |
| 383 | 1 | return this; |
| 384 | } | |
| 385 | ||
| 386 | /** | |
| 387 | * Asserts that this fixture's <code>{@link JTextComponent}</code> is not visible. | |
| 388 | * @return this fixture. | |
| 389 | * @throws AssertionError if this fixture's <code>JTextComponent</code> is visible. | |
| 390 | */ | |
| 391 | 1 |
public JTextComponentFixture requireNotVisible() { |
| 392 | 1 | driver.requireNotVisible(target); |
| 393 | 1 | return this; |
| 394 | } | |
| 395 | ||
| 396 | /** | |
| 397 | * Asserts that this fixture's <code>{@link JTextComponent}</code> is editable. | |
| 398 | * @throws AssertionError if this fixture's <code>JTextComponent</code> is not editable. | |
| 399 | * @return this fixture. | |
| 400 | */ | |
| 401 | 1 |
public JTextComponentFixture requireEditable() { |
| 402 | 1 | driver.requireEditable(target); |
| 403 | 1 | return this; |
| 404 | } | |
| 405 | ||
| 406 | /** | |
| 407 | * Asserts that this fixture's <code>{@link JTextComponent}</code> is not editable. | |
| 408 | * @throws AssertionError if this fixture's <code>JTextComponent</code> is editable. | |
| 409 | * @return this fixture. | |
| 410 | */ | |
| 411 | 1 |
public JTextComponentFixture requireNotEditable() { |
| 412 | 1 | driver.requireNotEditable(target); |
| 413 | 1 | return this; |
| 414 | } | |
| 415 | ||
| 416 | /** | |
| 417 | * Asserts that the toolTip in this fixture's <code>{@link JTextComponent}</code> matches the given value. | |
| 418 | * @param expected the given value. It can be a regular expression. | |
| 419 | * @return this fixture. | |
| 420 | * @throws AssertionError if the toolTip in this fixture's <code>JTextComponent</code> does not match the given | |
| 421 | * value. | |
| 422 | * @since 1.2 | |
| 423 | */ | |
| 424 | 1 |
public JTextComponentFixture requireToolTip(String expected) { |
| 425 | 1 | driver.requireToolTip(target, expected); |
| 426 | 1 | return this; |
| 427 | } | |
| 428 | ||
| 429 | /** | |
| 430 | * Asserts that the toolTip in this fixture's <code>{@link JTextComponent}</code> matches the given regular expression | |
| 431 | * pattern. | |
| 432 | * @param pattern the regular expression pattern to match. | |
| 433 | * @return this fixture. | |
| 434 | * @throws NullPointerException if the given regular expression pattern is <code>null</code>. | |
| 435 | * @throws AssertionError if the toolTip in this fixture's <code>JTextComponent</code> does not match the given | |
| 436 | * regular expression pattern. | |
| 437 | * @since 1.2 | |
| 438 | */ | |
| 439 | 1 |
public JTextComponentFixture requireToolTip(Pattern pattern) { |
| 440 | 1 | driver.requireToolTip(target, pattern); |
| 441 | 1 | return this; |
| 442 | } | |
| 443 | ||
| 444 | ||
| 445 | /** | |
| 446 | * Returns the client property stored in this fixture's <code>{@link JTextComponent}</code>, under the given key. | |
| 447 | * @param key the key to use to retrieve the client property. | |
| 448 | * @return the value of the client property stored under the given key, or <code>null</code> if the property was | |
| 449 | * not found. | |
| 450 | * @throws NullPointerException if the given key is <code>null</code>. | |
| 451 | * @since 1.2 | |
| 452 | */ | |
| 453 | 1 |
public Object clientProperty(Object key) { |
| 454 | 1 | return driver.clientProperty(target, key); |
| 455 | } | |
| 456 | ||
| 457 | /** | |
| 458 | * Shows a pop-up menu using this fixture's <code>{@link JTextComponent}</code> as the invoker of the pop-up menu. | |
| 459 | * @return a fixture that manages the displayed pop-up menu. | |
| 460 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is disabled. | |
| 461 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is not showing on the screen. | |
| 462 | * @throws ComponentLookupException if a pop-up menu cannot be found. | |
| 463 | */ | |
| 464 | 3 |
public JPopupMenuFixture showPopupMenu() { |
| 465 | 3 | return new JPopupMenuFixture(robot, driver.invokePopupMenu(target)); |
| 466 | } | |
| 467 | ||
| 468 | /** | |
| 469 | * Shows a pop-up menu at the given point using this fixture's <code>{@link JTextComponent}</code> as the invoker of | |
| 470 | * the pop-up menu. | |
| 471 | * @param p the given point where to show the pop-up menu. | |
| 472 | * @return a fixture that manages the displayed pop-up menu. | |
| 473 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is disabled. | |
| 474 | * @throws IllegalStateException if this fixture's <code>JTextComponent</code> is not showing on the screen. | |
| 475 | * @throws ComponentLookupException if a pop-up menu cannot be found. | |
| 476 | */ | |
| 477 | 1 |
public JPopupMenuFixture showPopupMenuAt(Point p) { |
| 478 | 1 | return new JPopupMenuFixture(robot, driver.invokePopupMenu(target, p)); |
| 479 | } | |
| 480 | } | |
|
||||||||||||