Adding tests to window methods.

master
Pedro de Oliveira Guedes 2022-01-26 17:14:31 -03:00
parent af398aeccb
commit f0910457ff
2 changed files with 89 additions and 2 deletions

View File

@ -1,3 +1,4 @@
from time import sleep
from behave import *
from cli import Wingui
@ -91,3 +92,65 @@ 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)
# =========================== Window_list and Window_hwnd ===========================
@when(u'the window_hwnd method is called with the parameter "mspaint.exe"')
def step_impl(context):
sleep(0.5)
context.paint_hwnd = context.client.window_hwnd("mspaint.exe")
@when(u'the window_list method is called')
def step_impl(context):
context.windows = context.client.window_list()
@then(u'the return of window_hwnd must be the value of one of the "Hwnd" keys returned in window_list')
def step_impl(context):
for window in context.windows:
if context.paint_hwnd[0] == window["Hwnd"]:
assert True
sleep(0.5)
context.client.proc_kill(context.proc_pid)
return
assert False, "Something went wrong catching the Paint window."
# # =================== Window_activate, Window_activetitle and Window_activehwnd ===================
# @given(u'the window hwnd obtained from the "Name" info')
# def step_impl(context):
# context.paint_hwnd = context.client.window_hwnd(context.proc_name)
# @when(u'the window_activate method is called with the Paint Hwnd obtained')
# def step_impl(context):
# sleep(0.5)
# context.client.window_activate (context.paint_hwnd[0])
# sleep(0.5)
# @when(u'the methods window_activetitle and window_activehwnd are called')
# def step_impl(context):
# context.paint_title = context.client.window_activetitle()
# context.paint_win_hwnd = context.client.window_activehwnd()
# context.client.window_close(context.paint_hwnd[0])
# @then(u'the returned value from window_activetitle must contain the substring "Paint"')
# def step_impl(context):
# assert "Paint" in context.paint_title, f"The active title obtained is not from Paint.\nActive Title: {context.paint_title}"
# for window in context.client.window_list():
# if context.paint_hwnd == window["Hwnd"]:
# print(f"""
# ---------------------------
# Hwnd associated title: {window["Title"]}
# ---------------------------
# """)
# @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"

View File

@ -37,3 +37,27 @@ Feature: The winGUI API client
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
Scenario: Testing the window_list and window_hwnd methods
Given a winGUI client
And the initialization of Microsoft Paint
And the "Name" and "Pid" infos about this process
When the window_hwnd method is called with the parameter "mspaint.exe"
And the window_list method is called
Then the return of window_hwnd must be the value of one of the "Hwnd" keys returned in window_list
# Scenario: Testing window_activate, window_activetitle and window_activehwnd
# Given a winGUI client
# And the initialization of Microsoft Paint
# And the "Name" and "Pid" infos about this process
# And the window hwnd obtained from the "Name" info
# When the window_activate method is called with the Paint Hwnd obtained
# 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