001    /*
002     * Created on Dec 7, 2007
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 @2007-2010 the original author or authors.
015     */
016    package org.fest.swing.fixture;
017    
018    import java.awt.Component;
019    
020    import org.fest.swing.exception.ActionFailedException;
021    import org.fest.swing.exception.ComponentLookupException;
022    
023    /**
024     * Understands functional testing of GUI component items (e.g. a cell in a <code>JTable</code> or a row in a
025     * <code>JList</code>):
026     * <ul>
027     * <li>user input simulation</li>
028     * <li>property value query</li>
029     * </ul>
030     * Understands simulation of user events on an item belonging to a fixture's <code>{@link Component}</code>.
031     *
032     * @author Yvonne Wang
033     * @author Alex Ruiz
034     */
035    public interface ItemFixture extends MouseInputSimulationFixture {
036    
037      /**
038       * Simulates a user selecting this fixture's item.
039       * @return this fixture.
040       * @throws IllegalStateException if the component containing this fixture's item is disabled.
041       * @throws IllegalStateException if the component containing this fixture's item is not showing on the screen.
042       */
043      ItemFixture select();
044    
045      /**
046       * Returns the <code>String</code> representation of this fixture's item, or <code>null</code> if one can not be
047       * obtained.
048       * @return the <code>String</code> representation of this fixture's item.
049       */
050      String value();
051    
052      /**
053       * Simulates a user dragging this fixture's item.
054       * @return this fixture.
055       * @throws IllegalStateException if the component containing this fixture's item is disabled.
056       * @throws IllegalStateException if the component containing this fixture's item is not showing on the screen.
057       */
058      ItemFixture drag();
059    
060      /**
061       * Simulates a user dropping into this fixture's item.
062       * @return this fixture.
063       * @throws IllegalStateException if the component containing this fixture's item is disabled.
064       * @throws IllegalStateException if the component containing this fixture's item is not showing on the screen.
065       * @throws ActionFailedException if there is no drag action in effect.
066       */
067      ItemFixture drop();
068    
069      /**
070       * Shows a pop-up menu using this fixture's item as the invoker of the pop-up menu.
071       * @return a fixture that handles functional testing of the displayed pop-up menu.
072       * @throws IllegalStateException if the component containing this fixture's item is disabled.
073       * @throws IllegalStateException if the component containing this fixture's item is not showing on the screen.
074       * @throws ComponentLookupException if a pop-up menu cannot be found.
075       */
076      JPopupMenuFixture showPopupMenu();
077    }