Adding tests to proc methods.

master
Pedro de Oliveira Guedes 2022-01-26 15:42:27 -03:00
parent e34d748dca
commit af398aeccb
2 changed files with 81 additions and 2 deletions

View File

@ -34,4 +34,60 @@ def step_impl(context):
# =========================== Clip_read & Clip_write ===========================
# =========================== Proc_exec & Proc_all ===========================
@when(u'the proc_exec method is called with "mspaint"')
def step_impl(context):
context.client.proc_exec("mspaint")
@when(u'the proc_all method is called')
def step_impl(context):
context.procs = context.client.proc_all()
@then(u'there must be a process with the name "mspaint.exe" inside the list')
def step_impl(context):
for proc in context.procs:
if "mspaint.exe" in proc["Name"]:
context.client.proc_kill(proc["Pid"])
assert True
return
assert False, "Something went wrong executing Microsoft Paint."
# =========================== Proc_name ===========================
@given(u'the initialization of Microsoft Paint')
def step_impl(context):
context.client.proc_exec("mspaint")
@given(u'the "Name" and "Pid" infos about this process')
def step_impl(context):
context.procs = context.client.proc_all()
for proc in context.procs:
if "mspaint.exe" in proc["Name"]:
context.proc_name = proc["Name"]
context.proc_pid = proc["Pid"]
@when(u'the proc_name method is called with the "Pid" collected')
def step_impl(context):
context.name_return = context.client.proc_name(context.proc_pid)
@then(u'the return must be te same as the "Name" collected')
def step_impl(context):
assert context.name_return == context.proc_name, "Something went wrong with some of the proc methods."
context.client.proc_kill(context.proc_pid)
# =========================== Proc_pids ===========================
@when(u'the proc_pids is called')
def step_impl(context):
context.all_pids = context.client.proc_pids()
@then(u'the "Pid" info collected must be inside the array returned')
def step_impl(context):
assert context.proc_pid in context.all_pids, "Something went wrong catching all of the pids."
context.client.proc_kill(context.proc_pid)

View File

@ -14,3 +14,26 @@ Feature: The winGUI API client
# Please note that most of the other screen methods use image recognition and, because of that, it is not possible to test them on every computer, since there is no way to know wich images are being displayed on the screen.
# Also, the other methods wich do not use image recognition are simply too difficult to test.
Scenario: Testing proc_exec and proc_all methods
Given a winGUI client
When the proc_exec method is called with "mspaint"
And the proc_all method is called
Then there must be a process with the name "mspaint.exe" inside the list
Scenario: Testing proc_name method
Given a winGUI client
And the initialization of Microsoft Paint
And the "Name" and "Pid" infos about this process
When the proc_name method is called with the "Pid" collected
Then the return must be te same as the "Name" collected
Scenario: Testing proc_pids method
Given a winGUI client
And the initialization of Microsoft Paint
And the "Name" and "Pid" infos about this process
When the proc_pids is called
Then the "Pid" info collected must be inside the array returned