org.assertj.swing.driver
Class AbstractButtonDriver

java.lang.Object
  extended by org.assertj.swing.driver.ComponentDriver
      extended by org.assertj.swing.driver.ContainerDriver
          extended by org.assertj.swing.driver.JComponentDriver
              extended by org.assertj.swing.driver.AbstractButtonDriver
All Implemented Interfaces:
TextDisplayDriver<AbstractButton>

@InternalApi
public class AbstractButtonDriver
extends JComponentDriver
implements TextDisplayDriver<AbstractButton>

Supports functional testing of Swing AbstractButtons.

Note: This class is intended for internal use only. Please use the classes in the package org.assertj.swing.fixture in your tests.

Author:
Alex Ruiz, Yvonne Wang

Field Summary
 
Fields inherited from class org.assertj.swing.driver.ComponentDriver
robot
 
Constructor Summary
AbstractButtonDriver(Robot robot)
          Creates a new AbstractButtonDriver.
 
Method Summary
 void deselect(AbstractButton button)
          Deselects the given Swing AbstractBuffon only if it is selected.
 void requireNotSelected(AbstractButton button)
          Verifies that the AbstractBuffon is not selected.
 void requireSelected(AbstractButton button)
          Verifies that the Swing AbstractBuffon is selected.
 void requireText(AbstractButton button, Pattern pattern)
          Asserts that the text in the given Swing AbstractBuffon matches the given regular expression pattern.
 void requireText(AbstractButton button, String expected)
          Asserts that the text in the given Swing AbstractBuffon is equal to or matches the specified String .
 void select(AbstractButton button)
          Selects the given Swing AbstractBuffon only it is not already selected.
 String textOf(AbstractButton button)
          Returns the text of the given Swing AbstractBuffon.
 
Methods inherited from class org.assertj.swing.driver.JComponentDriver
clientProperty, invokeAction, isVisible, isVisible, requireToolTip, requireToolTip, scrollToVisible
 
Methods inherited from class org.assertj.swing.driver.ContainerDriver
doResizeHeight, doResizeWidth, isResizable, move, resize
 
Methods inherited from class org.assertj.swing.driver.ComponentDriver
backgroundOf, checkInEdtEnabledAndShowing, click, click, click, click, click, doubleClick, drag, dragOver, drop, focus, focusAndWaitForFocusGain, fontOf, foregroundOf, invokePopupMenu, invokePopupMenu, moveMouseIgnoringAnyError, moveMouseIgnoringAnyError, performAccessibleActionOf, pressAndReleaseKey, pressAndReleaseKey, pressAndReleaseKeys, pressKey, propertyName, releaseKey, requireDisabled, requireEnabled, requireEnabled, requireFocused, requireNotVisible, requireSize, requireVisible, rightClick, settings, waitForShowing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractButtonDriver

public AbstractButtonDriver(@Nonnull
                            Robot robot)
Creates a new AbstractButtonDriver.

Parameters:
robot - the robot to use to simulate user input.
Method Detail

requireText

@RunsInEDT
public void requireText(@Nonnull
                                  AbstractButton button,
                                  @Nullable
                                  String expected)
Asserts that the text in the given Swing AbstractBuffon is equal to or matches the specified String .

Specified by:
requireText in interface TextDisplayDriver<AbstractButton>
Parameters:
button - the given AbstractBuffon.
expected - the text to match. It can be a regular expression.
Throws:
AssertionError - if the text of the AbstractBuffon is not equal to or does not match the given one.

requireText

public void requireText(@Nonnull
                        AbstractButton button,
                        @Nonnull
                        Pattern pattern)
Asserts that the text in the given Swing AbstractBuffon matches the given regular expression pattern.

Specified by:
requireText in interface TextDisplayDriver<AbstractButton>
Parameters:
button - the given AbstractBuffon.
pattern - the regular expression pattern to match.
Throws:
NullPointerException - if the given regular expression pattern is null.
AssertionError - if the text of the AbstractBuffon does not match the given regular expression pattern.

textOf

@RunsInEDT
@Nonnull
public String textOf(@Nonnull
                                       AbstractButton button)
Returns the text of the given Swing AbstractBuffon.

Specified by:
textOf in interface TextDisplayDriver<AbstractButton>
Parameters:
button - the given AbstractBuffon.
Returns:
the text of the given AbstractBuffon.

select

@RunsInEDT
public void select(@Nonnull
                             AbstractButton button)
Selects the given Swing AbstractBuffon only it is not already selected.

Parameters:
button - the target AbstractBuffon.
Throws:
IllegalStateException - if the AbstractBuffon is disabled.
IllegalStateException - if the AbstractBuffon is not showing on the screen.

deselect

@RunsInEDT
public void deselect(@Nonnull
                               AbstractButton button)
Deselects the given Swing AbstractBuffon only if it is selected.

Parameters:
button - the target AbstractBuffon.
Throws:
IllegalStateException - if the AbstractBuffon is disabled.
IllegalStateException - if the AbstractBuffon is not showing on the screen.

requireSelected

@RunsInEDT
public void requireSelected(@Nonnull
                                      AbstractButton button)
Verifies that the Swing AbstractBuffon is selected.

Parameters:
button - the given AbstractBuffon.
Throws:
AssertionError - if the button is not selected.

requireNotSelected

@RunsInEDT
public void requireNotSelected(@Nonnull
                                         AbstractButton button)
Verifies that the AbstractBuffon is not selected.

Parameters:
button - the given AbstractBuffon.
Throws:
AssertionError - if the AbstractBuffon is selected.


Copyright © 2014–2015 AssertJ. All rights reserved.