All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.assertj.swing.finder.WindowFinder Maven / Gradle / Ivy

There is a newer version: 3.17.1
Show newest version
/*
 * Created on Jul 30, 2007
 * 
 * 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 @2007-2013 the original author or authors.
 */
package org.assertj.swing.finder;

import java.awt.Dialog;
import java.awt.Frame;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import org.assertj.swing.core.GenericTypeMatcher;

/**
 * 

* Looks up {@code Frame}s and {@code Dialog}s. Lookups are performed till the window of interest is found, or until the * given time to perform the lookup is over. The default lookup time is 5 seconds. *

* *

* {@link WindowFinder} is the "entry point" of a fluent interface to look up frames and dialogs. This example * illustrates finding a {@code Frame} by name, using the default lookup time (5 seconds): * *

 * FrameFixture frame = WindowFinder.findFrame("someFrame").using(robot);
 * 
* *

* *

* Where {@code robot} is an instance of {@link org.assertj.swing.core.Robot}. *

* *

* This example shows how to find a {@code Dialog} by type using a lookup time of 10 seconds: * *

 * DialogFixture dialog = WindowFinder.findDialog(MyDialog.class).withTimeout(10000).using(robot);
 * 
* * We can also specify the time unit: * *
 * DialogFixture dialog = WindowFinder.findDialog(MyDialog.class).withTimeout(10, {@link java.util.concurrent.TimeUnit#SECONDS SECONDS}).using(robot);
 * 
* *

* *

* This example shows how to use a {@link GenericTypeMatcher} to find a {@code Frame} with title "Hello": * *

 * GenericTypeMatcher<JFrame> matcher = new GenericTypeMatcher<JFrame>() {
 *   protected boolean isMatching(JFrame frame) {
 *     return "hello".equals(frame.getTitle());
 *   }
 * };
 * FrameFixture frame = WindowFinder.findFrame(matcher).using(robot);
 * 
* *

* * @author Alex Ruiz * @author Yvonne Wang */ public final class WindowFinder { private WindowFinder() { } /** * Creates a new {@link FrameFinder} capable of looking up a {@code Frame} by name. * * @param frameName the name of the frame to find. * @return the created finder. */ public static @Nonnull FrameFinder findFrame(@Nullable String frameName) { return new FrameFinder(frameName); } /** * Creates a new {@link FrameFinder} capable of looking up a {@code Frame} by type. * * @param frameType the type of the frame to find. * @return the created finder. */ public static @Nonnull FrameFinder findFrame(@Nonnull Class frameType) { return new FrameFinder(frameType); } /** * Creates a new {@link FrameFinder} capable of looking up a {@code Frame} using the provided matcher. * * @param matcher the matcher to use to find a frame. * @return the created finder. */ public static @Nonnull FrameFinder findFrame(@Nonnull GenericTypeMatcher matcher) { return new FrameFinder(matcher); } /** * Creates a new {@link DialogFinder} capable of looking up a {@code Dialog} by name. * * @param dialogName the name of the dialog to find. * @return the created finder. */ public static @Nonnull DialogFinder findDialog(@Nullable String dialogName) { return new DialogFinder(dialogName); } /** * Creates a new {@link DialogFinder} capable of looking up a {@code Dialog} by type. * * @param dialogType the type of the dialog to find. * @return the created finder. */ public static @Nonnull DialogFinder findDialog(@Nonnull Class dialogType) { return new DialogFinder(dialogType); } /** * Creates a new {@link DialogFinder} capable of looking up a {@code Dialog} using the provided matcher. * * @param matcher the matcher to use to find a dialog. * @return the created finder. */ public static @Nonnull DialogFinder findDialog(@Nonnull GenericTypeMatcher matcher) { return new DialogFinder(matcher); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy