org.fest.swing.core.matcher
Class FrameMatcher

java.lang.Object
  extended by org.fest.swing.core.AbstractComponentMatcher
      extended by org.fest.swing.core.GenericTypeMatcher<T>
          extended by org.fest.swing.core.matcher.NamedComponentMatcherTemplate<Frame>
              extended by org.fest.swing.core.matcher.FrameMatcher
All Implemented Interfaces:
ComponentMatcher, ResettableComponentMatcher

public final class FrameMatcher
extends NamedComponentMatcherTemplate<Frame>

Understands matching a Frame by type, name or title.

Author:
Alex Ruiz

Field Summary
 
Fields inherited from class org.fest.swing.core.matcher.NamedComponentMatcherTemplate
ANY, name
 
Method Summary
 FrameMatcher andShowing()
          Indicates that the Frame to match should be showing on the screen.
 FrameMatcher andTitle(Pattern titlePattern)
          Specifies the title to match.
 FrameMatcher andTitle(String newTitle)
          Specifies the title to match.
static FrameMatcher any()
          Creates a new FrameMatcher that matches any Frame.
protected  boolean isMatching(Frame frame)
          Indicates whether the title of the given Frame is equal to the title in this matcher.
 String toString()
           
static FrameMatcher withName(String name)
          Creates a new FrameMatcher that matches a Frame that: has a matching name (optionally) has matching title (optionally) is showing on the screen
static FrameMatcher withTitle(Pattern titlePattern)
          Creates a new FrameMatcher that matches a Frame by its title.
static FrameMatcher withTitle(String title)
          Creates a new FrameMatcher that matches a Frame by its title.
 
Methods inherited from class org.fest.swing.core.matcher.NamedComponentMatcherTemplate
arePropertyValuesMatching, isNameMatching, quoted, quotedName
 
Methods inherited from class org.fest.swing.core.GenericTypeMatcher
matches, supportedType
 
Methods inherited from class org.fest.swing.core.AbstractComponentMatcher
requireShowing, requireShowing, requireShowingMatches, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

withName

public static FrameMatcher withName(String name)
Creates a new FrameMatcher that matches a Frame that:
  1. has a matching name
  2. (optionally) has matching title
  3. (optionally) is showing on the screen
  4. The following code listing shows how to match a Frame by name and title:

     FrameMatcher m = withName("myApp").andTitle("My App");
     

    The following code listing shows how to match a Frame, that should be showing on the screen, by name and title:

     FrameMatcher m = withName("myApp").andTitle("My App").andShowing();
     

    Parameters:
    name - the id to match.
    Returns:
    the created matcher.

withTitle

public static FrameMatcher withTitle(String title)
Creates a new FrameMatcher that matches a Frame by its title.

The following code listing shows how to match a Frame by title:

 FrameMatcher m = withTitle("My App");
 

The following code listing shows how to match a Frame, that should be showing on the screen, by title:

 FrameMatcher m = withTitle("My App").andShowing();
 

Parameters:
title - the title to match. It can be a regular expression.
Returns:
the created matcher.

withTitle

public static FrameMatcher withTitle(Pattern titlePattern)
Creates a new FrameMatcher that matches a Frame by its title.

The following code listing shows how to match a Frame by title, using a regular expression matcher:

 FrameMatcher m = withTitle(Pattern.compile("My.*"));
 

The following code listing shows how to match a Frame, that should be showing on the screen, by title:

 FrameMatcher m = withTitle(Pattern.compile("My.*")).andShowing();
 

Parameters:
titlePattern - the title to match.
Returns:
the created matcher.
Since:
1.2

any

public static FrameMatcher any()
Creates a new FrameMatcher that matches any Frame.

Returns:
the created matcher.

andTitle

public FrameMatcher andTitle(String newTitle)
Specifies the title to match. If this matcher was created using withTitle(String) or withTitle(Pattern), this method will simply update the title to match.

Parameters:
newTitle - the new title to match. It can be a regular expression.
Returns:
this matcher.

andTitle

public FrameMatcher andTitle(Pattern titlePattern)
Specifies the title to match. If this matcher was created using withTitle(String) or withTitle(Pattern), this method will simply update the title to match.

Parameters:
titlePattern - the regular expression pattern to match.
Returns:
this matcher.
Since:
1.2

andShowing

public FrameMatcher andShowing()
Indicates that the Frame to match should be showing on the screen.

Returns:
this matcher.

isMatching

@RunsInCurrentThread
protected boolean isMatching(Frame frame)
Indicates whether the title of the given Frame is equal to the title in this matcher.

Note: This method is not guaranteed to be executed in the event dispatch thread (EDT.) Clients are responsible for calling this method from the EDT.

Specified by:
isMatching in class GenericTypeMatcher<Frame>
Parameters:
frame - the Frame to match.
Returns:
true if the title in the Frame is equal to the title in this matcher, false otherwise.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2007-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.