001 /*
002 * Created on Dec 20, 2009
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
005 * the License. You may obtain a copy of the License at
006 *
007 * http://www.apache.org/licenses/LICENSE-2.0
008 *
009 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
010 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
011 * specific language governing permissions and limitations under the License.
012 *
013 * Copyright @2009-2010 the original author or authors.
014 */
015 package org.fest.swing.driver;
016
017 import java.awt.Component;
018 import java.util.regex.Pattern;
019
020 /**
021 * Understands functional testing of a <code>{@link Component}</code> that displays text.
022 * @param <T> the type of <code>{@link Component}</code> this driver supports.
023 *
024 * @author Yvonne Wang
025 * @author Alex Ruiz
026 *
027 * @since 1.2
028 */
029 public interface TextDisplayDriver<T extends Component> {
030
031 /**
032 * Asserts that the text in the given component is equal to or matches the specified <code>String</code>.
033 * @param component the given component.
034 * @param expected the text to match. It can be a regular expression.
035 * @throws AssertionError if the text of the component is not equal to or does not match the given one.
036 */
037 void requireText(T component, String expected);
038
039 /**
040 * Asserts that the text in the given component matches the given regular expression pattern.
041 * @param component the given component.
042 * @param pattern the regular expression pattern to match.
043 * @throws NullPointerException if the given regular expression pattern is <code>null</code>.
044 * @throws AssertionError if the text of the component does not match the given regular expression pattern.
045 * @since 1.2
046 */
047 void requireText(T component, Pattern pattern);
048
049 /**
050 * Returns the text of the given component.
051 * @param component the given component.
052 * @return the text of the given component.
053 */
054 String textOf(T component);
055 }