Class DialogFixture

All Implemented Interfaces:
CommonComponentFixture, ComponentContainerFixture, FocusableComponentFixture, JPopupMenuInvokerFixture, KeyboardInputSimulationFixture, MouseInputSimulationFixture, StateVerificationFixture, WindowLikeContainerFixture

public class DialogFixture extends WindowFixture<Dialog>
Understands functional testing of Dialogs:
  • user input simulation
  • state verification
  • property value query
  • Field Details

  • Constructor Details

  • Method Details

    • createDriver

      private void createDriver()
    • driver

      protected final void driver(DialogDriver newDriver)
      Sets the DialogDriver to be used by this fixture.
      Parameters:
      newDriver - the new DialogDriver.
      Throws:
      NullPointerException - if the given driver is null.
    • click

      public DialogFixture click()
      Simulates a user clicking this fixture's Dialog.
      Returns:
      this fixture.
    • click

      public DialogFixture click(MouseButton button)
      Simulates a user clicking this fixture's Dialog.
      Parameters:
      button - the button to click.
      Returns:
      this fixture.
    • click

      public DialogFixture click(MouseClickInfo mouseClickInfo)
      Simulates a user clicking this fixture's Dialog.
      Parameters:
      mouseClickInfo - specifies the button to click and the times the button should be clicked.
      Returns:
      this fixture.
      Throws:
      NullPointerException - if the given MouseClickInfo is null.
    • doubleClick

      public DialogFixture doubleClick()
      Simulates a user double-clicking this fixture's Dialog.
      Returns:
      this fixture.
    • focus

      public DialogFixture focus()
      Gives input focus to this fixture's Dialog.
      Returns:
      this fixture.
    • moveTo

      public DialogFixture moveTo(Point p)
      Simulates a user moving this fixture's Dialog to the given point.
      Parameters:
      p - the point to move this fixture's Dialog to.
      Returns:
      this fixture.
      Throws:
      ActionFailedException - if the Window is not movable.
      ActionFailedException - if the given Window is not showing on the screen.
    • moveToFront

      public DialogFixture moveToFront()
      If fixture's Dialog is visible, brings it to the front and may make it the focused one.
      Returns:
      this fixture.
    • moveToBack

      public DialogFixture moveToBack()
      If the given Dialog is visible, sends it to the back and may cause it to lose focus or activation if it is the focused or active.
      Returns:
      this fixture.
    • pressAndReleaseKey

      public DialogFixture pressAndReleaseKey(KeyPressInfo keyPressInfo)
      Simulates a user pressing given key with the given modifiers on this fixture's Dialog. Modifiers is a mask from the available InputEvent masks.
      Parameters:
      keyPressInfo - specifies the key and modifiers to press.
      Returns:
      this fixture.
      Throws:
      NullPointerException - if the given KeyPressInfo is null.
      IllegalArgumentException - if the given code is not a valid key code.
      See Also:
    • pressAndReleaseKeys

      public DialogFixture pressAndReleaseKeys(int... keyCodes)
      Simulates a user pressing and releasing the given keys on this fixture's Dialog.
      Parameters:
      keyCodes - one or more codes of the keys to press.
      Returns:
      this fixture.
      Throws:
      NullPointerException - if the given array of codes is null.
      IllegalArgumentException - if any of the given code is not a valid key code.
      See Also:
    • pressKey

      public DialogFixture pressKey(int keyCode)
      Simulates a user pressing the given key on this fixture's Dialog.
      Parameters:
      keyCode - the code of the key to press.
      Returns:
      this fixture.
      Throws:
      IllegalArgumentException - if the given code is not a valid key code.
      See Also:
    • releaseKey

      public DialogFixture releaseKey(int keyCode)
      Simulates a user releasing the given key on this fixture's Dialog.
      Parameters:
      keyCode - the code of the key to release.
      Returns:
      this fixture.
      Throws:
      IllegalArgumentException - if the given code is not a valid key code.
      See Also:
    • requireFocused

      public DialogFixture requireFocused()
      Asserts that this fixture's Dialog has input focus.
      Returns:
      this fixture.
      Throws:
      AssertionError - if this fixture's Dialog does not have input focus.
    • requireDisabled

      public DialogFixture requireDisabled()
      Asserts that this fixture's Dialog is disabled.
      Returns:
      this fixture.
      Throws:
      AssertionError - if this fixture's Dialog is enabled.
    • requireEnabled

      public DialogFixture requireEnabled()
      Asserts that this fixture's Dialog is enabled.
      Returns:
      this fixture.
      Throws:
      AssertionError - if this fixture's Dialog is disabled.
    • requireEnabled

      public DialogFixture requireEnabled(Timeout timeout)
      Asserts that this fixture's Dialog is enabled.
      Parameters:
      timeout - the time this fixture will wait for the component to be enabled.
      Returns:
      this fixture.
      Throws:
      WaitTimedOutError - if this fixture's Dialog is never enabled.
    • requireModal

      public DialogFixture requireModal()
      Asserts that this fixture's Dialog is modal.
      Returns:
      this fixture.
      Throws:
      AssertionError - if this fixture's Dialog is not modal.
    • requireNotVisible

      public DialogFixture requireNotVisible()
      Asserts that this fixture's Dialog is not visible.
      Returns:
      this fixture.
      Throws:
      AssertionError - if this fixture's Dialog is visible.
    • requireSize

      public DialogFixture requireSize(Dimension size)
      Asserts that the size of this fixture's Dialog is equal to given one.
      Parameters:
      size - the given size to match.
      Returns:
      this fixture.
      Throws:
      AssertionError - if the size of this fixture's Dialog is not equal to the given size.
    • requireVisible

      public DialogFixture requireVisible()
      Asserts that this fixture's Dialog is visible.
      Returns:
      this fixture.
      Throws:
      AssertionError - if this fixture's Dialog is not visible.
    • resizeHeightTo

      public DialogFixture resizeHeightTo(int height)
      Simulates a user resizing vertically this fixture's Dialog.
      Parameters:
      height - the height that this fixture's Dialog should have after being resized.
      Returns:
      this fixture.
      Throws:
      ActionFailedException - if the Window is not resizable.
    • resizeTo

      public DialogFixture resizeTo(Dimension size)
      Simulates a user resizing this fixture's Dialog.
      Parameters:
      size - the size that the target window should have after being resized.
      Returns:
      this fixture.
      Throws:
      ActionFailedException - if the Window is not resizable.
    • resizeWidthTo

      public DialogFixture resizeWidthTo(int width)
      Simulates a user resizing horizontally this fixture's Dialog.
      Parameters:
      width - the width that this fixture's Dialog should have after being resized.
      Returns:
      this fixture.
      Throws:
      ActionFailedException - if the Window is not resizable.
    • rightClick

      public DialogFixture rightClick()
      Simulates a user right-clicking this fixture's Dialog.
      Returns:
      this fixture.
    • show

      public DialogFixture show()
      Shows this fixture's Dialog.
      Specified by:
      show in class WindowFixture<Dialog>
      Returns:
      this fixture.
    • show

      public DialogFixture show(Dimension size)
      Shows this fixture's Dialog, resized to the given size.
      Specified by:
      show in class WindowFixture<Dialog>
      Parameters:
      size - the size to resize this fixture's Dialog to.
      Returns:
      this fixture.
    • showPopupMenu

      public JPopupMenuFixture showPopupMenu()
      Shows a pop-up menu using this fixture's Dialog as the invoker of the pop-up menu.
      Returns:
      a fixture that manages the displayed pop-up menu.
      Throws:
      IllegalStateException - if this fixture's Dialog is disabled.
      IllegalStateException - if this fixture's Dialog is not showing on the screen.
      ComponentLookupException - if a pop-up menu cannot be found.
    • showPopupMenuAt

      public JPopupMenuFixture showPopupMenuAt(Point p)
      Shows a pop-up menu at the given point using this fixture's Dialog as the invoker of the pop-up menu.
      Parameters:
      p - the given point where to show the pop-up menu.
      Returns:
      a fixture that manages the displayed pop-up menu.
      Throws:
      IllegalStateException - if this fixture's Dialog is disabled.
      IllegalStateException - if this fixture's Dialog is not showing on the screen.
      ComponentLookupException - if a pop-up menu cannot be found.
    • close

      public void close()
      Simulates a user closing this fixture's Dialog.