# ---------------------------------------------------------------
# Framework Keywords
#
# This file contains keywords for control of the framework
# ---------------------------------------------------------------

from robot.api import logger
from accelarobotkeywords.config.seleniumsettings import SeleniumSettings
from accelarobotkeywords.config.displaysettings import DisplaySettings
from accelarobotkeywords.framework.framework import Framework


def setup_framework():
    """Main entry point method for the framework"""
    Framework.setup_output_directories()
    Framework.setup_display()


def close_framework():
    """Closes down the test framework"""
    Framework.close_display()


def set_selenium_implicit_wait(seconds):
    """Sets the selenium implicit wait"""
    SeleniumSettings.set_implicit_wait(float(seconds))
    logger.info("Set implicit wait to %s seconds" % str(seconds))


def set_selenium_explicit_wait(seconds):
    """Sets the selenium explicit wait"""
    SeleniumSettings.set_explicit_wait(float(seconds))
    logger.info("Set explicit wait to %s seconds" % str(seconds))


def set_selenium_script_wait(seconds):
    """Sets the selenium javascript wait"""
    SeleniumSettings.set_script_wait(float(seconds))
    logger.info("Set script wait to %s seconds" % str(seconds))


def set_page_load_wait(seconds):
    """Sets the wait time for a page load"""
    SeleniumSettings.set_page_load_wait(float(seconds))
    logger.info("Set page load wait to %s seconds" % str(seconds))


def set_selenium_small_wait(seconds):
    """Sets the number of seconds for the small wait keyword"""
    SeleniumSettings.set_small_wait(seconds)
    logger.info("Small wait set to %s seconds" % seconds)


def set_selenium_medium_wait(seconds):
    """Sets the number of seconds for the medium wait keyword"""
    SeleniumSettings.set_medium_wait(seconds)
    logger.info("Medium wait set to %s seconds" % seconds)


def set_selenium_long_wait(seconds):
    """Sets the number of seconds for the long wait keyword"""
    SeleniumSettings.set_long_wait(seconds)
    logger.info("Long wait set to %s seconds" % seconds)


def set_display_width(width):
    """Sets the width of the displayed browser. Note this needs to be set before the browser is opened"""
    DisplaySettings.set_width(width)
    logger.info("Display width set to: %s" % str(width))


def set_display_height(height):
    """Sets the height of the displayed browser. Note this needs to be set before the browser is opened"""
    DisplaySettings.set_height(height)
    logger.info("Display height set to: %s" % str(height))


def set_display_depth(depth):
    """Sets the color depth of the created display, this keyword is only applicable to docker/linux execution"""
    DisplaySettings.set_depth(depth)
    logger.info("Display depth set to: %s" % str(depth))
