package com.enactor.pos.swing;

import com.enactor.core.automation.AUT.AutomationException;
import com.enactor.core.automation.AUT.IAUTControllerClient;
import com.enactor.core.automation.component.IComponentAccessor;

import java.util.List;

/**
 * This is an interface to provide general actions required to automate Swing Application
 */
public interface ISwingAppStepsProvider {

    /**
     * Setter method for IAUTControllerClient
     * @param controller
     */
    public void setController(IAUTControllerClient controller);

    /**
     * Waits till window with given window id appears during the timeout duration
     *
     * @param windowId
     * @param timeout
     * @throws AutomationException
     */
    void waitForWindow(String windowId, long timeout) throws AutomationException;

    /**
     * Waits till component accessible in given window id
     *
     * @param componentId
     * @param windowId
     * @param timeout
     * @throws AutomationException
     */
    IComponentAccessor waitsForComponent(String componentId, String windowId, long timeout) throws AutomationException;

    /**
     * Return ths text inside the component with the given component id
     *
     * @param componentId
     * @param windowId
     * @return
     * @throws AutomationException
     */
    String getComponentText(String componentId, String windowId) throws AutomationException;

    /**
     * Press on button with the given button label
     *
     * @param buttonLabel
     * @param windowId
     * @param possibleComponentIds
     * @param timeout
     * @throws AutomationException
     */
    void pressButtonWithLabel(
            String buttonLabel, String windowId,
            List<String> possibleComponentIds, long timeout) throws AutomationException;

    /**
     * Press on the button with given component id
     *
     * @param componentId
     * @param windowId
     * @throws AutomationException
     */
    void pressButtonByComponentId(String componentId, String windowId) throws AutomationException;

    /**
     * Press on the button with given component id if its available during the specified timeout duration
     *
     * @param componentId
     * @param windowId
     * @throws AutomationException
     */
    void pressButtonByComponentId(String componentId, String windowId, long timeout) throws AutomationException;

    /**
     * Assert whether button with given label is not displayed within the timeout
     *
     * @param buttonLabel
     * @param windowId
     * @param possibleComponentIds
     * @param timeout
     * @throws AutomationException
     */
    void assertButtonWithLabelNotDisplayed(
            String buttonLabel, String windowId,
            List<String> possibleComponentIds, long timeout) throws AutomationException;

    /**
     * Enter the text inside the given component
     *
     * @param text
     * @param componentId
     * @param windowId
     * @throws AutomationException
     */
    void enterText(String text, String componentId, String windowId) throws AutomationException;

    /**
     * Asserts whether text inside the component is as same as the text provided
     *
     * @param text
     * @param componentId
     * @param windowId
     * @throws AutomationException
     */
    void assertTextFieldHasEqualContent(String text, String componentId, String windowId) throws AutomationException;

    /**
     * Assert whether text inside the text contains the given text
     *
     * @param text
     * @param componentId
     * @param windowId
     * @throws AutomationException
     */
    void assertTextFieldContainsValue(String text, String componentId, String windowId) throws AutomationException;

    /**
     * Asserts whether text inside the component is not empty
     *
     * @param componentId
     * @param windowId
     * @throws AutomationException
     */
    void assertTextFieldIsNotEmpty(String componentId, String windowId) throws AutomationException;

    /**
     * Asserts whether text inside the label is as same as the text provided
     *
     * @param text
     * @param componentId
     * @param windowId
     * @throws AutomationException
     */
    void assertLabelHasEqualContent(String text, String componentId, String windowId) throws AutomationException;

    /**
     * Select the item from list
     *
     * @param item
     * @param listComponentId
     * @param windowId
     * @throws AutomationException
     */
    void selectListItem(String item, String listComponentId, String windowId) throws AutomationException;

    /**
     * Select the item from a combobox
     *
     * @param item
     * @param componentId
     * @param windowId
     * @throws AutomationException
     */
    void selectComboboxItem(String item, String componentId, String windowId) throws AutomationException;

    /**
     * Asserts whether text inside the panel is as same as the text provided
     *
     * @param text
     * @param panelComponentId
     * @param windowId
     * @throws AutomationException
     */
    void assertPanelHasEqualContent(String text, String panelComponentId, String windowId) throws AutomationException;
}
