Adding tests to display methods.

master
Pedro de Oliveira Guedes 2022-01-26 17:51:16 -03:00
parent f0910457ff
commit ff5d9b9cf2
2 changed files with 61 additions and 2 deletions

View File

@ -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"
# 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."

View File

@ -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
# 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