From e34d748dcacb8c07a3daf684eb2a0476458b61b7 Mon Sep 17 00:00:00 2001 From: Pedro de Oliveira Guedes Date: Tue, 25 Jan 2022 11:05:59 -0300 Subject: [PATCH] Adding tests to winGUI methods. --- api/wingui/features/steps/steps.py | 37 ++++++++++++++++++++++++++++++ api/wingui/features/wingui.feature | 16 +++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 api/wingui/features/steps/steps.py create mode 100644 api/wingui/features/wingui.feature diff --git a/api/wingui/features/steps/steps.py b/api/wingui/features/steps/steps.py new file mode 100644 index 0000000..9cd0b50 --- /dev/null +++ b/api/wingui/features/steps/steps.py @@ -0,0 +1,37 @@ +from behave import * +from cli import Wingui + +# =========================== Clip_read & Clip_write =========================== +@given(u'a winGUI client') +def step_impl(context): + context.client = Wingui () + +@when(u'the clip_write method is called to store the text "There is a light that never goes out"') +def step_impl(context): + context.client.clip_write("There is a light that never goes out") + +@then(u'when the clip_read method is called, it must return the same text') +def step_impl(context): + assert context.client.clip_read() == "There is a light that never goes out", "Something went wrong with the clipboard." + + + +# =========================== Screen_scale & Screen_size =========================== +@when(u'the screen_scale method is called') +def step_impl(context): + context.scale = context.client.screen_scale() + +@when(u'the screen_size method is also called') +def step_impl(context): + context.size = context.client.screen_size() + +@then(u'the returns of both must be equal') +def step_impl(context): + assert context.scale == context.size, "Something went wrong while getting the screen dimensions." + +# 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. + + + +# =========================== Clip_read & Clip_write =========================== \ No newline at end of file diff --git a/api/wingui/features/wingui.feature b/api/wingui/features/wingui.feature new file mode 100644 index 0000000..f634107 --- /dev/null +++ b/api/wingui/features/wingui.feature @@ -0,0 +1,16 @@ +Feature: The winGUI API client + + Scenario: Testing the clip_read and clip_write methods + Given a winGUI client + When the clip_write method is called to store the text "There is a light that never goes out" + Then when the clip_read method is called, it must return the same text + + + Scenario: Testing the screen_scale and screen_size methods + Given a winGUI client + When the screen_scale method is called + And the screen_size method is also called + Then the returns of both must be equal + + # 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. \ No newline at end of file