org.uispec4j
Class TextBox

java.lang.Object
  extended by org.uispec4j.AbstractUIComponent
      extended by org.uispec4j.AbstractSwingUIComponent
          extended by org.uispec4j.TextBox
All Implemented Interfaces:
TooltipComponent, UIComponent

public class TextBox
extends AbstractSwingUIComponent

Wrapper for JTextComponent/JLabel components.


Field Summary
static java.lang.Class[] SWING_CLASSES
           
static java.lang.String TYPE_NAME
           
 
Constructor Summary
TextBox(javax.swing.JLabel label)
           
TextBox(javax.swing.text.JTextComponent textComponent)
           
 
Method Summary
 void appendText(java.lang.String text)
          Inserts text at the given position without pressing Enter.
 void clear()
          Clears the text without validating.
 void clickOnHyperlink(java.lang.String link)
          Simulates a click on an hyperlink given a part of the link text.
 void focusLost()
          Simulates losing the focus., by calling directly the focus listeners of the component without going through the focus mechanim.
 javax.swing.JComponent getAwtComponent()
          Returns the Java GUI component represented by this object.
 java.lang.String getDescriptionTypeName()
          Returns the name of the component as it will appear in the XML representation returned by UIComponent.getDescription().
 java.lang.String getText()
           
 Assertion htmlEquals(java.lang.String html)
          Checks the displayed text in cases where HTML text is used.
 Assertion iconEquals(javax.swing.Icon icon)
          Checks the icon displayed by the component.
 void insertText(java.lang.String text, int position)
          Inserts text at the given position without pressing Enter.
 Assertion isEditable()
           
 void setText(java.lang.String text)
          Replaces the text box contents and simulates pressing the Enter key.
 void setText(java.lang.String text, boolean pressEnter)
          Replaces the text box contents and simulates pressing Enter if pressEnter is set to true.
 Assertion textContains(java.lang.String... orderedTexts)
          Checks that the text box contains a number of substrings, in a given order.
 Assertion textContains(java.lang.String text)
           
 Assertion textDoesNotContain(java.lang.String text)
           
 Assertion textEquals(java.lang.String text)
           
 Assertion textIsEmpty()
           
 Trigger triggerClickOnHyperlink(java.lang.String name)
           
 
Methods inherited from class org.uispec4j.AbstractSwingUIComponent
tooltipContains, tooltipEquals
 
Methods inherited from class org.uispec4j.AbstractUIComponent
addAttributes, backgroundEquals, backgroundNear, foregroundEquals, foregroundNear, getContainer, getContainer, getDescription, getDescription, getLabel, getName, getSubDescription, isEnabled, isVisible, pressKey, releaseKey, typeKey
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_NAME

public static final java.lang.String TYPE_NAME
See Also:
Constant Field Values

SWING_CLASSES

public static final java.lang.Class[] SWING_CLASSES
Constructor Detail

TextBox

public TextBox(javax.swing.text.JTextComponent textComponent)

TextBox

public TextBox(javax.swing.JLabel label)
Method Detail

getDescriptionTypeName

public java.lang.String getDescriptionTypeName()
Description copied from interface: UIComponent
Returns the name of the component as it will appear in the XML representation returned by UIComponent.getDescription().


getAwtComponent

public javax.swing.JComponent getAwtComponent()
Description copied from interface: UIComponent
Returns the Java GUI component represented by this object.

Specified by:
getAwtComponent in interface UIComponent
Specified by:
getAwtComponent in class AbstractSwingUIComponent

setText

public void setText(java.lang.String text)
Replaces the text box contents and simulates pressing the Enter key.


setText

public void setText(java.lang.String text,
                    boolean pressEnter)
Replaces the text box contents and simulates pressing Enter if pressEnter is set to true.


insertText

public void insertText(java.lang.String text,
                       int position)
Inserts text at the given position without pressing Enter.


appendText

public void appendText(java.lang.String text)
Inserts text at the given position without pressing Enter.


clear

public void clear()
Clears the text without validating. Use setText("") to achieve the same effect with validation.


getText

public java.lang.String getText()

textIsEmpty

public Assertion textIsEmpty()

htmlEquals

public Assertion htmlEquals(java.lang.String html)
Checks the displayed text in cases where HTML text is used. This is different from textEquals(String) in that whitespaces, carriage return and other formatting adjustments are ignored.


textContains

public Assertion textContains(java.lang.String... orderedTexts)
Checks that the text box contains a number of substrings, in a given order. This method is useful for checking key information in the displayed string, without being too dependent on the actual wording.


textEquals

public Assertion textEquals(java.lang.String text)

textContains

public Assertion textContains(java.lang.String text)

textDoesNotContain

public Assertion textDoesNotContain(java.lang.String text)

isEditable

public Assertion isEditable()

iconEquals

public Assertion iconEquals(javax.swing.Icon icon)
Checks the icon displayed by the component. Please note that equals() not being defined for Icon implementations, you will have to provide a pointer to the actual Icon instance that is used in the production code. This make this method mostly suited to unit testing.


clickOnHyperlink

public void clickOnHyperlink(java.lang.String link)
Simulates a click on an hyperlink given a part of the link text. An exception will be thrown if zero or more than one hyperlinks are found with this text.


triggerClickOnHyperlink

public Trigger triggerClickOnHyperlink(java.lang.String name)
See Also:
clickOnHyperlink(String)

focusLost

public void focusLost()
Simulates losing the focus., by calling directly the focus listeners of the component without going through the focus mechanim.



Copyright © 2004-2010. All Rights Reserved.