From ff5d9b9cf29e221f646ffebfa337c3bb38f46d52 Mon Sep 17 00:00:00 2001 From: Pedro de Oliveira Guedes Date: Wed, 26 Jan 2022 17:51:16 -0300 Subject: [PATCH] Adding tests to display methods. --- api/wingui/features/steps/steps.py | 51 +++++++++++++++++++++++++++++- api/wingui/features/wingui.feature | 12 ++++++- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/api/wingui/features/steps/steps.py b/api/wingui/features/steps/steps.py index 2094839..7f11caf 100644 --- a/api/wingui/features/steps/steps.py +++ b/api/wingui/features/steps/steps.py @@ -153,4 +153,53 @@ def step_impl(context): # @then(u'the returned value from window_activehwnd must be equal to the hwnd previously obtained') # def step_impl(context): -# assert context.paint_win_hwnd == context.paint_hwnd, "The Hwnd obtained is not from Paint" \ No newline at end of file +# assert context.paint_win_hwnd == context.paint_hwnd, "The Hwnd obtained is not from Paint" + + + +# ======================================== Display methods ======================================== +@given(u'the current resolution of the display') +def step_impl(context): + context.sys_info = context.client.display_res() + + context.prev_width = context.sys_info["DmPelsWidth"] + context.prev_height = context.sys_info["DmPelsHeight"] + +@when(u'the display_setres method is called to set the display resolution in 800x600') +def step_impl(context): + context.new_sys_info = context.sys_info + context.new_sys_info["DmPelsWidth"] = 800 + context.new_sys_info["DmPelsHeight"] = 600 + + try: + context.client.display_setres(context.new_sys_info) + sleep(5) + except: + raise "Your system configuration does not support 800x600 resolution" + +@then(u'the new display resolution must be 800x600') +def step_impl(context): + context.new_sys_info = context.client.display_res() + + assert context.new_sys_info["DmPelsWidth"] == 800 and \ + context.new_sys_info["DmPelsHeight"] == 600, \ + \ + "Something went wrong setting your system resolution to 800x600.\n\nCheck if this resolution is available in your configurations, if so, please disregard this message." + +@then(u'the methods must be able to set your resolution to the previous one') +def step_impl(context): + context.new_sys_info["DmPelsWidth"] = context.prev_width + context.new_sys_info["DmPelsHeight"] = context.prev_height + + try: + context.client.display_setres(context.new_sys_info) + sleep(5) + except: + raise "Error!" + + context.curr_sys_info = context.client.display_res() + + assert context.curr_sys_info["DmPelsWidth"] == context.prev_width and \ + context.curr_sys_info["DmPelsHeight"] == context.prev_height, \ + \ + "Sorry for the inconvenience, but something went wrong resetting your resolution to the previous one.\n\nPlease go to your system configurations to do this step manually." \ No newline at end of file diff --git a/api/wingui/features/wingui.feature b/api/wingui/features/wingui.feature index e9c627a..b658e56 100644 --- a/api/wingui/features/wingui.feature +++ b/api/wingui/features/wingui.feature @@ -60,4 +60,14 @@ Feature: The winGUI API client # And the methods window_activetitle and window_activehwnd are called # Then the returned value from window_activetitle must contain the substring "Paint" - # And the returned value from window_activehwnd must be equal to the hwnd previously obtained \ No newline at end of file + # And the returned value from window_activehwnd must be equal to the hwnd previously obtained + + + Scenario: Testing the display methods + Given a winGUI client + And the current resolution of the display + + When the display_setres method is called to set the display resolution in 800x600 + + Then the new display resolution must be 800x600 + And the methods must be able to set your resolution to the previous one \ No newline at end of file