org.assertj.swing.finder.WindowFinderTemplate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of assertj-swing Show documentation
Show all versions of assertj-swing Show documentation
Assertj-Swing test framework
The newest version!
/*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* Copyright 2012-2018 the original author or authors.
*/
package org.assertj.swing.finder;
import java.awt.Window;
import java.util.concurrent.TimeUnit;
import org.assertj.swing.annotation.NonNegative;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.assertj.swing.core.GenericTypeMatcher;
import org.assertj.swing.core.Robot;
import org.assertj.swing.fixture.AbstractWindowFixture;
/**
* Template for {@code Window} finders.
*
* @param the type of {@code Window} this finder can search.
*
* @author Yvonne Wang
* @author Alex Ruiz
*/
public abstract class WindowFinderTemplate extends ComponentFinderTemplate {
/**
* Creates a new {@link WindowFinderTemplate}.
*
* @param windowName the name of the {@code Window} to find.
* @param windowType the type of the {@code Window} to find.
*/
protected WindowFinderTemplate(@Nullable String windowName, @NotNull Class extends T> windowType) {
super(windowName, windowType);
}
/**
* Creates a new {@link WindowFinderTemplate}.
*
* @param matcher specifies the search criteria to use when looking up a {@code Window}.
*/
protected WindowFinderTemplate(@NotNull GenericTypeMatcher extends T> matcher) {
super(matcher);
}
/**
* Creates a new {@link WindowFinderTemplate}.
*
* @param windowType the type of the {@code Window} to find.
*/
protected WindowFinderTemplate(@NotNull Class extends T> windowType) {
super(windowType);
}
/**
* Sets the timeout for this finder. The {@code Window} to find should be found within the given time period.
*
* @param timeout the number of milliseconds before stopping the search.
* @return this finder.
* @throws IllegalArgumentException if the timeout is a negative number.
*/
@Override
@NotNull
protected WindowFinderTemplate withTimeout(@NonNegative long timeout) {
super.withTimeout(timeout);
return this;
}
/**
* Sets the timeout for this finder. The {@code Window} to find should be found within the given time period.
*
* @param timeout the period of time the search should be performed.
* @param unit the time unit for {@code timeout}.
* @return this finder.
* @throws NullPointerException if the time unit is {@code null}.
* @throws IllegalArgumentException if the timeout is a negative number.
*/
@Override
protected WindowFinderTemplate withTimeout(@NonNegative long timeout, @NotNull TimeUnit unit) {
super.withTimeout(timeout, unit);
return this;
}
/**
* Finds a {@code Window} by name or type using the given robot.
*
* @param robot contains the underlying finding to delegate the search to.
* @return a fixture capable of managing the found {@code Window}.
* @throws org.assertj.swing.exception.WaitTimedOutError if a {@code Window} with the given name or of the given type
* could not be found.
*/
@Override
public abstract @NotNull AbstractWindowFixture, T, ?> using(@NotNull Robot robot);
}