001    /*
002     * Created on Feb 29, 2008
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
005     * in compliance with 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
010     * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
011     * or implied. See the License for the specific language governing permissions and limitations under
012     * the License.
013     *
014     * Copyright @2008-2010 the original author or authors.
015     */
016    package org.fest.swing.driver;
017    
018    import static org.fest.assertions.Assertions.assertThat;
019    import static org.fest.swing.driver.DialogModalQuery.isModal;
020    
021    import java.awt.Dialog;
022    
023    import org.fest.swing.annotation.RunsInEDT;
024    import org.fest.swing.core.Robot;
025    
026    /**
027     * Understands functional testing of <code>{@link Dialog}</code>s:
028     * <ul>
029     * <li>user input simulation</li>
030     * <li>state verification</li>
031     * <li>property value query</li>
032     * </ul>
033     * This class is intended for internal use only. Please use the classes in the package
034     * <code>{@link org.fest.swing.fixture}</code> in your tests.
035     *
036     * @author Alex Ruiz
037     */
038    public class DialogDriver extends WindowDriver {
039    
040      /**
041       * Creates a new </code>{@link DialogDriver}</code>.
042       * @param robot the robot to use to simulate user input.
043       */
044      public DialogDriver(Robot robot) {
045        super(robot);
046      }
047    
048      /**
049       * Asserts that the<code>{@link Dialog}</code> is modal.
050       * @param dialog the target <code>Dialog</code>.
051       * @throws AssertionError if this fixture's <code>Dialog</code> is not modal.
052       */
053      @RunsInEDT
054      public void requireModal(Dialog dialog) {
055        assertThat(isModal(dialog)).as(propertyName(dialog, "modal")).isTrue();
056      }
057    }