[gnome-weather/wip/christopherdavis/fix-tests] tests: Modernize testing setup
- From: Christopher Davis <christopherdavis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-weather/wip/christopherdavis/fix-tests] tests: Modernize testing setup
- Date: Fri, 22 Feb 2019 00:11:24 +0000 (UTC)
commit 681396332963a222e933b293e665d8eabc1c37aa
Author: Christopher Davis <brainblasted disroot org>
Date: Thu Feb 21 19:08:46 2019 -0500
tests: Modernize testing setup
The tests were telling dogtail to look for things that don't
exist. Now we test for some different views. In order to make testing consistent automatic location has
been turned
off during the testing phase.
Related to https://gitlab.gnome.org/GNOME/gnome-weather/issues/17
tests/testutil.py | 17 +++++++---
tests/world_view.py | 91 ++++++++++++++---------------------------------------
2 files changed, 36 insertions(+), 72 deletions(-)
---
diff --git a/tests/testutil.py b/tests/testutil.py
index 1d2e57e..25233ad 100644
--- a/tests/testutil.py
+++ b/tests/testutil.py
@@ -59,22 +59,31 @@ def start():
return app
+
def reset_settings():
- # need to go through the parser because pygobject does not handle maybe types
+ # need to go through the parser because pygobject
+ # does not handle maybe types
parsed = GLib.Variant.parse(GLib.VariantType.new('av'),
"[<(uint32 1, <('Linate Airport', 'LIML', "
"false, @m(dd) (0.79296125100499293, "
- "0.16202472640904275), @m(dd) (0.79354303905785273, "
+ "0.16202472640904275), @m(dd) "
+ "(0.79354303905785273, "
"0.16057029118347829))>)>]")
settings.set_value("locations", parsed)
+ settings.set_value("automatic-location", GLib.Variant.new_boolean(False))
+
def init():
- global settings, _previous_locations
+ global settings, _previous_locations, _automatic_location
settings = Gio.Settings("org.gnome.Weather")
_previous_locations = settings.get_value("locations")
+ _automatic_location = settings.get_value("automatic-location")
reset_settings()
+
def fini():
settings.set_value("locations", _previous_locations)
- _do_bus_call("ActivateAction", GLib.Variant('(sava{sv})', ('quit', [], [])))
+ settings.set_value("automatic-location", _automatic_location)
+ _do_bus_call("ActivateAction",
+ GLib.Variant('(sava{sv})', ('quit', [], [])))
diff --git a/tests/world_view.py b/tests/world_view.py
index 473b572..f281baa 100755
--- a/tests/world_view.py
+++ b/tests/world_view.py
@@ -10,89 +10,44 @@ from dogtail import tree
from dogtail import utils
from dogtail.procedural import *
+
def active(widget):
return widget.getState().contains(pyatspi.STATE_ARMED)
+
+
def visible(widget):
return widget.getState().contains(pyatspi.STATE_VISIBLE)
+
init()
try:
app = start()
- new_button = app.child('New')
- back_button = app.child('Back')
- delete_button = app.child('Delete')
- select_button = app.child('Select')
- done_button = app.child('Cancel')
+ places_button = app.child('Places')
+ refresh_button = app.child('Refresh')
world_view = app.child('World view')
city_view = app.child('City view')
- content_view = app.child('Cities')
- milan_icon = content_view.findChild(IsTextEqual('Milan'))
+
+ current_conditions = app.child('Current conditions')
+ weekly_forecast = app.child('Weekly Forecast')
+ forecast = app.child('Forecast')
# basic state
- assert new_button.showing
- assert not back_button.showing
- assert not delete_button.showing
- assert select_button.showing
- assert not done_button.showing
- assert world_view.showing
- assert content_view.showing
- assert not city_view.showing
-
- # selection mode
- select_button.click()
- assert not new_button.showing
- assert not back_button.showing
- assert delete_button.showing
- assert not delete_button.sensitive
- assert not select_button.showing
- assert done_button.showing
- assert world_view.showing
- assert content_view.showing
- assert not city_view.showing
-
- # select one
- milan_icon.click()
- assert delete_button.sensitive
- # unselect it
- milan_icon.click()
- assert not delete_button.sensitive
-
- # back from selection mode
- done_button.click()
- assert new_button.showing
- assert not back_button.showing
- assert not delete_button.showing
- assert select_button.showing
- assert not done_button.showing
- assert world_view.showing
- assert content_view.showing
- assert not city_view.showing
-
- # back into selection mode, delete the only item
- select_button.click()
- milan_icon.click()
- delete_button.click()
- assert milan_icon.dead
- placeholder = app.child('Add locations').parent
- assert placeholder.showing
- assert select_button.showing
- assert not select_button.sensitive
-
- # reset
- reset_settings()
- utils.doDelay(1)
- milan_icon = content_view.findChild(IsTextEqual('Milan'))
- assert not milan_icon.dead
- # these two should be equivalend to milan_icon.showing,
- # but for some reason they aren't
- assert visible(milan_icon)
- assert milan_icon.parent.showing
+ assert places_button.showing
+ assert refresh_button.showing
+ assert not world_view.showing
+ assert city_view.showing
+
+ # forecast
+ assert current_conditions.showing
+ assert weekly_forecast.showing
+ assert forecast.showing
+
finally:
fini()
-#type("gimp\n")
-#doDelay(2)
-#keyCombo("Escape")
+# type("gimp\n")
+# doDelay(2)
+# keyCombo("Escape")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]