diff --git a/guibot/guibot_proxy.py b/guibot/guibot_proxy.py index b1f44688..07d3429a 100644 --- a/guibot/guibot_proxy.py +++ b/guibot/guibot_proxy.py @@ -98,153 +98,150 @@ def _proxify(self, obj): self._pyroDaemon.register(obj) return obj - def nearby(self, rrange=50): + def nearby(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).nearby(rrange)) + return self._proxify(super(GuiBotProxy, self).nearby(*args, **kwargs)) - def above(self, rrange=0): + def above(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).above(rrange)) + return self._proxify(super(GuiBotProxy, self).above(*args, **kwargs)) - def below(self, rrange=0): + def below(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).below(rrange)) + return self._proxify(super(GuiBotProxy, self).below(*args, **kwargs)) - def left(self, rrange=0): + def left(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).left(rrange)) + return self._proxify(super(GuiBotProxy, self).left(*args, **kwargs)) - def right(self, rrange=0): + def right(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).right(rrange)) + return self._proxify(super(GuiBotProxy, self).right(*args, **kwargs)) - def find(self, target, timeout=10): + def find(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).find(target, timeout)) + return self._proxify(super(GuiBotProxy, self).find(*args, **kwargs)) - def find_all(self, target, timeout=10, allow_zero=False): + def find_all(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - matches = super(GuiBotProxy, self).find_all(target, timeout, allow_zero) + matches = super(GuiBotProxy, self).find_all(*args, **kwargs) proxified = [] for match in matches: proxified.append(self._proxify(match)) return proxified - def sample(self, target): + def sample(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).sample(target)) + return self._proxify(super(GuiBotProxy, self).sample(*args, **kwargs)) - def exists(self, target, timeout=0): + def exists(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).exists(target, timeout)) + return self._proxify(super(GuiBotProxy, self).exists(*args, **kwargs)) - def wait(self, target, timeout=30): + def wait(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).wait(target, timeout)) + return self._proxify(super(GuiBotProxy, self).wait(*args, **kwargs)) - def wait_vanish(self, target, timeout=30): + def wait_vanish(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).wait_vanish(target, timeout)) + return self._proxify(super(GuiBotProxy, self).wait_vanish(*args, **kwargs)) - def idle(self, timeout): + def idle(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).idle(timeout)) + return self._proxify(super(GuiBotProxy, self).idle(*args, **kwargs)) - def hover(self, target_or_location): + def hover(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).hover(target_or_location)) + return self._proxify(super(GuiBotProxy, self).hover(*args, **kwargs)) - def click(self, target_or_location, modifiers=None): + def click(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).click(target_or_location, modifiers)) + return self._proxify(super(GuiBotProxy, self).click(*args, **kwargs)) - def right_click(self, target_or_location, modifiers=None): + def right_click(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).right_click(target_or_location, modifiers)) + return self._proxify(super(GuiBotProxy, self).right_click(*args, **kwargs)) - def middle_click(self, target_or_location, modifiers=None): + def middle_click(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).middle_click(target_or_location, modifiers)) + return self._proxify(super(GuiBotProxy, self).middle_click(*args, **kwargs)) - def double_click(self, target_or_location, modifiers=None): + def double_click(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).double_click(target_or_location, modifiers)) + return self._proxify(super(GuiBotProxy, self).double_click(*args, **kwargs)) - def multi_click(self, target_or_location, count=3, modifiers=None): + def multi_click(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).multi_click(target_or_location, count, modifiers)) + return self._proxify(super(GuiBotProxy, self).multi_click(*args, **kwargs)) - def click_expect(self, click_image_or_location, expect_image_or_location=None, modifiers=None, timeout=60): + def click_expect(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).click_expect(click_image_or_location, - expect_image_or_location, modifiers, timeout)) + return self._proxify(super(GuiBotProxy, self).click_expect(*args, **kwargs)) - def click_vanish(self, click_image_or_location, expect_image_or_location=None, modifiers=None, timeout=60): + def click_vanish(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).click_vanish(click_image_or_location, - expect_image_or_location, modifiers, timeout)) + return self._proxify(super(GuiBotProxy, self).click_vanish(*args, **kwargs)) - def click_at_index(self, anchor, index=0, find_number=3, timeout=10): + def click_at_index(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).click_at_index(anchor, index, find_number, timeout)) + return self._proxify(super(GuiBotProxy, self).click_at_index(*args, **kwargs)) - def mouse_down(self, target_or_location, button=None): + def mouse_down(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).mouse_down(target_or_location, button)) + return self._proxify(super(GuiBotProxy, self).mouse_down(*args, **kwargs)) - def mouse_up(self, target_or_location, button=None): + def mouse_up(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).mouse_up(target_or_location, button)) + return self._proxify(super(GuiBotProxy, self).mouse_up(*args, **kwargs)) - def mouse_scroll(self, target_or_location, clicks=10, horizontal=False): + def mouse_scroll(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).mouse_scroll(target_or_location, clicks, horizontal)) + return self._proxify(super(GuiBotProxy, self).mouse_scroll(*args, **kwargs)) - def drag_drop(self, src_target_or_location, dst_target_or_location, modifiers=None): + def drag_drop(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).drag_drop(src_target_or_location, - dst_target_or_location, modifiers)) + return self._proxify(super(GuiBotProxy, self).drag_drop(*args, **kwargs)) - def drag_from(self, target_or_location, modifiers=None): + def drag_from(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).drag(target_or_location, modifiers)) + return self._proxify(super(GuiBotProxy, self).drag_from(*args, **kwargs)) - def drop_at(self, target_or_location, modifiers=None): + def drop_at(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).drop_at(target_or_location, modifiers)) + return self._proxify(super(GuiBotProxy, self).drop_at(*args, **kwargs)) - def press_keys(self, keys): + def press_keys(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).press(keys)) + return self._proxify(super(GuiBotProxy, self).press_keys(*args, **kwargs)) - def press_at(self, target_or_location=None, keys=None): + def press_at(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).press_at(target_or_location, keys)) + return self._proxify(super(GuiBotProxy, self).press_at(*args, **kwargs)) - def press_expect(self, keys, expect_target, modifiers=None, timeout=60, retries=3): + def press_expect(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).press_expect(keys, expect_target, modifiers=None, timeout=60, retries=3)) + return self._proxify(super(GuiBotProxy, self).press_expect(*args, **kwargs)) - def press_vanish(self, keys, expect_target, modifiers=None, timeout=60, retries=3): + def press_vanish(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).press_vanish(keys, expect_target, modifiers=None, timeout=60, retries=3)) + return self._proxify(super(GuiBotProxy, self).press_vanish(*args, **kwargs)) - def type_text(self, text, modifiers=None): + def type_text(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).type_text(text, modifiers)) + return self._proxify(super(GuiBotProxy, self).type_text(*args, **kwargs)) - def type_at(self, target_or_location=None, text='', modifiers=None): + def type_at(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).type_at(target_or_location, text, modifiers)) + return self._proxify(super(GuiBotProxy, self).type_at(*args, **kwargs)) - def click_at(self, anchor, dx, dy, count=1): + def click_at(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).click_at(anchor, dx, dy, count)) + return self._proxify(super(GuiBotProxy, self).click_at(*args, **kwargs)) - def fill_at(self, anchor, text, dx, dy, del_flag=True, esc_flag=True, mark_clicks=1): + def fill_at(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).fill_at(anchor, text, dx, dy, del_flag, esc_flag, mark_clicks)) + return self._proxify(super(GuiBotProxy, self).fill_at(*args, **kwargs)) - def select_at(self, anchor, image_or_index, dx, dy, dw=0, dh=0, ret_flag=True, mark_clicks=1): + def select_at(self, *args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" - return self._proxify(super(GuiBotProxy, self).select_at(anchor, image_or_index, dx, dy, dw, dh, ret_flag, mark_clicks)) + return self._proxify(super(GuiBotProxy, self).select_at(*args, **kwargs)) diff --git a/guibot/guibot_simple.py b/guibot/guibot_simple.py index a3c407ba..85315662 100644 --- a/guibot/guibot_simple.py +++ b/guibot/guibot_simple.py @@ -60,205 +60,205 @@ def check_initialized(): raise AssertionError("Guibot module not initialized - run initialize() before using the simple API") -def add_path(directory): +def add_path(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - guibot.add_path(directory) + guibot.add_path(*args, **kwargs) -def remove_path(directory): +def remove_path(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - guibot.remove_path(directory) + guibot.remove_path(*args, **kwargs) -def find(target, timeout=10): +def find(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.find(target, timeout) + return guibot.find(*args, **kwargs) -def find_all(target, timeout=10, allow_zero=False): +def find_all(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.find_all(target, timeout, allow_zero) + return guibot.find_all(*args, **kwargs) -def sample(target): +def sample(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.sample(target) + return guibot.sample(*args, **kwargs) -def exists(target, timeout=0): +def exists(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.exists(target, timeout) + return guibot.exists(*args, **kwargs) -def wait(target, timeout=30): +def wait(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.wait(target, timeout) + return guibot.wait(*args, **kwargs) -def wait_vanish(target, timeout=30): +def wait_vanish(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.wait_vanish(target, timeout) + return guibot.wait_vanish(*args, **kwargs) -def get_mouse_location(): +def get_mouse_location(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.get_mouse_location() + return guibot.get_mouse_location(*args, **kwargs) -def idle(timeout): +def idle(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.idle(timeout) + return guibot.idle(*args, **kwargs) -def hover(target_or_location): +def hover(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.hover(target_or_location) + return guibot.hover(*args, **kwargs) -def click(target_or_location, modifiers=None): +def click(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.click(target_or_location, modifiers) + return guibot.click(*args, **kwargs) -def right_click(target_or_location, modifiers=None): +def right_click(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.right_click(target_or_location, modifiers) + return guibot.right_click(*args, **kwargs) -def middle_click(target_or_location, modifiers=None): +def middle_click(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.middle_click(target_or_location, modifiers) + return guibot.middle_click(*args, **kwargs) -def double_click(target_or_location, modifiers=None): +def double_click(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.double_click(target_or_location, modifiers) + return guibot.double_click(*args, **kwargs) -def multi_click(target_or_location, count=3, modifiers=None): +def multi_click(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.multi_click(target_or_location, count, modifiers) + return guibot.multi_click(*args, **kwargs) -def click_expect(click_image_or_location, expect_image_or_location, modifiers=None, timeout=60): +def click_expect(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.click_expect(click_image_or_location, expect_image_or_location, modifiers, timeout) + return guibot.click_expect(*args, **kwargs) -def click_vanish(click_image_or_location, expect_image_or_location, modifiers=None, timeout=60): +def click_vanish(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.click_vanish(click_image_or_location, expect_image_or_location, modifiers, timeout) + return guibot.click_vanish(*args, **kwargs) -def click_at_index(anchor, index=0, find_number=3, timeout=10): +def click_at_index(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.click_at_index(anchor, index, find_number, timeout) + return guibot.click_at_index(*args, **kwargs) -def mouse_down(target_or_location, button=None): +def mouse_down(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.mouse_down(target_or_location, button) + return guibot.mouse_down(*args, **kwargs) -def mouse_up(target_or_location, button=None): +def mouse_up(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.mouse_up(target_or_location, button) + return guibot.mouse_up(*args, **kwargs) -def mouse_scroll(target_or_location, clicks=10, horizontal=False): +def mouse_scroll(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.mouse_scroll(target_or_location, clicks, horizontal) + return guibot.mouse_scroll(*args, **kwargs) -def drag_drop(src_target_or_location, dst_target_or_location, modifiers=None): +def drag_drop(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.drag_drop(src_target_or_location, dst_target_or_location, modifiers) + return guibot.drag_drop(*args, **kwargs) -def drag_from(target_or_location, modifiers=None): +def drag_from(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.drag(target_or_location, modifiers) + return guibot.drag_from(*args, **kwargs) -def drop_at(target_or_location, modifiers=None): +def drop_at(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.drop_at(target_or_location, modifiers) + return guibot.drop_at(*args, **kwargs) -def press_keys(keys): +def press_keys(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.press(keys) + return guibot.press_keys(*args, **kwargs) -def press_at(target_or_location=None, keys=None): +def press_at(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.press_at(target_or_location, keys) + return guibot.press_at(*args, **kwargs) -def press_expect(keys, expect_target, modifiers=None, timeout=60, retries=3): +def press_expect(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.press_expect(keys, expect_target=None, modifiers=None, timeout=60, retries=3) + return guibot.press_expect(*args, **kwargs) -def press_vanish(keys, expect_target, modifiers=None, timeout=60, retries=3): +def press_vanish(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.press_vanish(keys, expect_target, modifiers=None, timeout=60, retries=3) + return guibot.press_vanish(*args, **kwargs) -def type_text(text, modifiers=None): +def type_text(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.type_text(text, modifiers) + return guibot.type_text(*args, **kwargs) -def type_at(target_or_location=None, text='', modifiers=None): +def type_at(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.type_at(target_or_location, text, modifiers) + return guibot.type_at(*args, **kwargs) -def click_at(anchor, dx, dy, count=1): +def click_at(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.click_at(anchor, dx, dy, count) + return guibot.click_at(*args, **kwargs) -def fill_at(anchor, text, dx, dy, del_flag=True, esc_flag=True, mark_clicks=1): +def fill_at(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.fill_at(anchor, text, dx, dy, del_flag, esc_flag, mark_clicks) + return guibot.fill_at(*args, **kwargs) -def select_at(anchor, image_or_index, dx, dy, dw=0, dh=0, ret_flag=True, mark_clicks=1): +def select_at(*args, **kwargs): """See :py:class:`guibot.guibot.GuiBot` and its inherited :py:class:`guibot.region.Region` for details.""" check_initialized() - return guibot.select_at(anchor, image_or_index, dx, dy, dw, dh, ret_flag, mark_clicks) + return guibot.select_at(*args, **kwargs) diff --git a/tests/test_interfaces.py b/tests/test_interfaces.py new file mode 100644 index 00000000..66ea6266 --- /dev/null +++ b/tests/test_interfaces.py @@ -0,0 +1,110 @@ +#!/usr/bin/python3 +# Copyright 2013-2023 Intranet AG and contributors +# +# guibot is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# guibot is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with guibot. If not, see . + +import sys +import inspect +from unittest import main, mock, TestCase + +import common_test + + +class SimpleAPITest(TestCase): + + def setUp(self): + from guibot import guibot_simple as simple + simple.guibot = mock.MagicMock() + simple.check_initialized = mock.MagicMock() + self.interface = simple + + def test_call_delegations(self): + """Test that all calls from the interface to the actual object are valid.""" + args = [True, 1, 2.0, "test-args"] + kwargs = {"bool": False, "int": 0, "float": 3.0, "str": "test-kwargs"} + for funcname in dir(self.interface): + func = self.interface.__dict__[funcname] + if not inspect.isfunction(func): + continue + if funcname in ["initialize", "check_initialized", "namedtuple"]: + continue + + func(args, kwargs) + + self.interface.check_initialized.assert_called_once() + method_calls = self.interface.guibot.method_calls + self.assertEqual(len(method_calls), 1) + self.assertEqual(len(method_calls[0]), 3) + self.assertEqual(method_calls[0][0], funcname) + self.assertEqual(method_calls[0][1], (args, kwargs)) + self.interface.guibot.reset_mock() + self.interface.check_initialized.reset_mock() + + @mock.patch("guibot.guibot_simple.GuiBot") + def test_key_imports(self, mock_guibot): + """Test that all keys imported by the simple interface work.""" + self.interface.initialize() + mock_guibot.return_value.dc_backend.keymap.ESC = "esc" + mock_guibot.return_value.dc_backend.modmap.MOD_SHIFT = "" + mock_guibot.return_value.dc_backend.mousemap.LEFT_BUTTON = 1 + + buttons = self.interface.buttons + self.assertEqual(buttons.key.ESC, "esc") + self.assertEqual(buttons.mod.MOD_SHIFT, "") + self.assertEqual(buttons.mouse.LEFT_BUTTON, 1) + + +class ProxyAPITest(TestCase): + + def setUp(self): + # fake the remote objects dependency for this interface + sys.modules["Pyro4"] = mock.MagicMock() + from guibot import guibot_proxy as remote + self.interface = remote.GuiBotProxy(cv=None, dc=None) + self.interface._proxify = mock.MagicMock() + + def tearDown(self): + del sys.modules["Pyro4"] + + @mock.patch('guibot.guibot_proxy.super') + def test_call_delegations(self, mock_super): + """Test that all calls from the interface to the actual object are valid.""" + args = [True, 1, 2.0, "test-args"] + kwargs = {"bool": False, "int": 0, "float": 3.0, "str": "test-kwargs"} + for funcname in dir(self.interface): + # instance __dict__ will only include its attributes + dirdict = type(self.interface).__dict__ + if funcname not in dirdict: + continue + func = dirdict[funcname] + if not inspect.isfunction(func): + continue + if funcname in ["__init__", "_proxify"]: + continue + + func(self.interface, args, kwargs) + + if funcname != "find_all": + self.interface._proxify.assert_called_once() + method_calls = mock_super.return_value.method_calls + self.assertEqual(len(method_calls), 1) + self.assertEqual(len(method_calls[0]), 3) + self.assertEqual(method_calls[0][0], funcname) + self.assertEqual(method_calls[0][1], (args, kwargs)) + mock_super.reset_mock() + self.interface._proxify.reset_mock() + + +if __name__ == '__main__': + main()