# Path: applitools/selenium/eyes_selenium_utils.py
# _NATIVE_APP = 'NATIVE_APP'
# _JS_GET_VIEWPORT_SIZE = """
#     var height = undefined;
#     var width = undefined;
#     if (window.innerHeight) {
#         height = window.innerHeight;
#     } else if (document.documentElement && document.documentElement.clientHeight) {
#         height = document.documentElement.clientHeight;
#     } else {
#             var b = document.getElementsByTagName('body')[0];
#             if (b.clientHeight) {height = b.clientHeight;}
#         }
#     if (window.innerWidth) {
#         width = window.innerWidth;
#     } else if (document.documentElement && document.documentElement.clientWidth) {
#         width = document.documentElement.clientWidth;
#     } else {
#         var b = document.getElementsByTagName('body')[0];
#     if (b.clientWidth) {
#         width = b.clientWidth;}
#     }
#     return [width, height];"""
# _JS_GET_CURRENT_SCROLL_POSITION = """
#     var doc = document.documentElement;
#     var x = window.scrollX || ((window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0));
#     var y = window.scrollY || ((window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0));
#     return [x, y]"""
# _JS_GET_CONTENT_ENTIRE_SIZE = """
#     var scrollWidth = document.documentElement.scrollWidth;
#     var bodyScrollWidth = document.body.scrollWidth;
#     var totalWidth = Math.max(scrollWidth, bodyScrollWidth);
#     var clientHeight = document.documentElement.clientHeight;
#     var bodyClientHeight = document.body.clientHeight;
#     var scrollHeight = document.documentElement.scrollHeight;
#     var bodyScrollHeight = document.body.scrollHeight;
#     var maxDocElementHeight = Math.max(clientHeight, scrollHeight);
#     var maxBodyHeight = Math.max(bodyClientHeight, bodyScrollHeight);
#     var totalHeight = Math.max(maxDocElementHeight, maxBodyHeight);
#     return [totalWidth, totalHeight];";
# """
# _JS_SET_OVERFLOW = """
#   return (function() {
#     var origOF = document.documentElement.style.overflow;
#     document.documentElement.style.overflow = '{overflow}';
#     return origOF;
#   }());
# """
# _JS_DATA_APPLITOOLS_SCROLL = "arguments[0].setAttribute('data-applitools-scroll', 'true');"
# _JS_DATA_APPLITOOLS_ORIGINAL_OVERFLOW = "arguments[0].setAttribute('data-applitools-original-overflow', '%s');"
# _JS_TRANSFORM_KEYS = ("transform", "-webkit-transform")
# _OVERFLOW_HIDDEN = 'hidden'
# _MAX_DIFF = 3
# _SLEEP = 1  # sec
# _RETRIES = 3
# def is_mobile_device(driver):
# def get_underlying_driver(driver):
# def get_underlying_webelement(element):
# def get_current_frame_content_entire_size(driver):
# def get_device_pixel_ratio(driver):
# def get_viewport_size(driver):
# def get_window_size(driver):
# def set_window_size(driver, size):
# def set_browser_size(driver, required_size):
# def set_browser_size_by_viewport_size(driver, actual_viewport_size, required_size):
# def set_viewport_size(driver, required_size):
# def hide_scrollbars(driver):
# def set_overflow(driver, overflow):
# def add_data_overflow_to_element(driver, element, overflow):
# def add_data_scroll_to_element(driver, element):
# def timeout(timeout):
# def is_landscape_orientation(driver):
# def get_viewport_size_or_display_size(driver):


import pytest
import mock
from selenium.common.exceptions import WebDriverException
from applitools.selenium import eyes_selenium_utils



@pytest.fixture
def driver_mock():
    driver = mock.Mock()
    driver.desired_capabilities = {'platformName': ''}
    # need to configure below
    driver.execute_script = mock.MagicMock(side_effect=WebDriverException())
    return driver


@pytest.mark.parametrize('platform_name',
                         ['Android', 'android', ' Android', 'androId ', 'android 6',
                          'iOs', 'ios', 'IOS', 'ios 11'])
def test_different_mobile_platform_names(driver_mock, platform_name):
    driver_mock.desired_capabilities['platformName'] = platform_name
    assert eyes_selenium_utils.is_mobile_device(driver_mock)


@pytest.mark.parametrize('platform_name',
                         ['Windows', 'Winmo', 'Linux', 'macOs'])
def test_different_not_mobile_platform_names(driver_mock, platform_name):
    driver_mock.desired_capabilities['platformName'] = platform_name

# Path: applitools/selenium/eyes_selenium_utils.py
# _NATIVE_APP = 'NATIVE_APP'
# _JS_GET_VIEWPORT_SIZE = """
#     var height = undefined;
#     var width = undefined;
#     if (window.innerHeight) {
#         height = window.innerHeight;
#     } else if (document.documentElement && document.documentElement.clientHeight) {
#         height = document.documentElement.clientHeight;
#     } else {
#             var b = document.getElementsByTagName('body')[0];
#             if (b.clientHeight) {height = b.clientHeight;}
#         }
#     if (window.innerWidth) {
#         width = window.innerWidth;
#     } else if (document.documentElement && document.documentElement.clientWidth) {
#         width = document.documentElement.clientWidth;
#     } else {
#         var b = document.getElementsByTagName('body')[0];
#     if (b.clientWidth) {
#         width = b.clientWidth;}
#     }
#     return [width, height];"""
# _JS_GET_CURRENT_SCROLL_POSITION = """
#     var doc = document.documentElement;
#     var x = window.scrollX || ((window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0));
#     var y = window.scrollY || ((window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0));
#     return [x, y]"""
# _JS_GET_CONTENT_ENTIRE_SIZE = """
#     var scrollWidth = document.documentElement.scrollWidth;
#     var bodyScrollWidth = document.body.scrollWidth;
#     var totalWidth = Math.max(scrollWidth, bodyScrollWidth);
#     var clientHeight = document.documentElement.clientHeight;
#     var bodyClientHeight = document.body.clientHeight;
#     var scrollHeight = document.documentElement.scrollHeight;
#     var bodyScrollHeight = document.body.scrollHeight;
#     var maxDocElementHeight = Math.max(clientHeight, scrollHeight);
#     var maxBodyHeight = Math.max(bodyClientHeight, bodyScrollHeight);
#     var totalHeight = Math.max(maxDocElementHeight, maxBodyHeight);
#     return [totalWidth, totalHeight];";
# """
# _JS_SET_OVERFLOW = """
#   return (function() {
#     var origOF = document.documentElement.style.overflow;
#     document.documentElement.style.overflow = '{overflow}';
#     return origOF;
#   }());
# """
# _JS_DATA_APPLITOOLS_SCROLL = "arguments[0].setAttribute('data-applitools-scroll', 'true');"
# _JS_DATA_APPLITOOLS_ORIGINAL_OVERFLOW = "arguments[0].setAttribute('data-applitools-original-overflow', '%s');"
# _JS_TRANSFORM_KEYS = ("transform", "-webkit-transform")
# _OVERFLOW_HIDDEN = 'hidden'
# _MAX_DIFF = 3
# _SLEEP = 1  # sec
# _RETRIES = 3
# def is_mobile_device(driver):
# def get_underlying_driver(driver):
# def get_underlying_webelement(element):
# def get_current_frame_content_entire_size(driver):
# def get_device_pixel_ratio(driver):
# def get_viewport_size(driver):
# def get_window_size(driver):
# def set_window_size(driver, size):
# def set_browser_size(driver, required_size):
# def set_browser_size_by_viewport_size(driver, actual_viewport_size, required_size):
# def set_viewport_size(driver, required_size):
# def hide_scrollbars(driver):
# def set_overflow(driver, overflow):
# def add_data_overflow_to_element(driver, element, overflow):
# def add_data_scroll_to_element(driver, element):
# def timeout(timeout):
# def is_landscape_orientation(driver):
# def get_viewport_size_or_display_size(driver):


# Path: tests/selenium/test_eyes_selenium_utils.py
import pytest
import mock
from selenium.common.exceptions import WebDriverException
from applitools.selenium import eyes_selenium_utils




@pytest.fixture
def driver_mock():
    driver = mock.Mock()
    driver.desired_capabilities = {'platformName': ''}
    # need to configure below
    driver.execute_script = mock.MagicMock(side_effect=WebDriverException())
    return driver


@pytest.mark.parametrize('platform_name',
                         ['Android', 'android', ' Android', 'androId ', 'android 6',
                          'iOs', 'ios', 'IOS', 'ios 11'])
def test_different_mobile_platform_names(driver_mock, platform_name):
    driver_mock.desired_capabilities['platformName'] = platform_name
    assert eyes_selenium_utils.is_mobile_device(driver_mock)


@pytest.mark.parametrize('platform_name',
                         ['Windows', 'Winmo', 'Linux', 'macOs'])
def test_different_not_mobile_platform_names(driver_mock, platform_name):
    driver_mock.desired_capabilities['platformName'] = platform_name

    assert not eyes_selenium_utils.is_mobile_device(driver_mock)