Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Narvaez <dwnarvaez@gmail.com>2012-07-02 17:12:23 (GMT)
committer Daniel Narvaez <dwnarvaez@gmail.com>2012-07-02 17:12:23 (GMT)
commit2750b99855cbff8408add60d060547b8a80665db (patch)
tree69d2bc5bee3c3bb6b808bd60eae61c8893c9b9b1
parente18989256751f7cd1e94c3b23ea0e60532a79fd6 (diff)
Rewrite to avoid storing accessible objects
They seem to be short lived
-rw-r--r--tests/shell.py67
1 files changed, 38 insertions, 29 deletions
diff --git a/tests/shell.py b/tests/shell.py
index 9e3d8b4..7efc2fb 100644
--- a/tests/shell.py
+++ b/tests/shell.py
@@ -1,64 +1,73 @@
import sys
-from operator import attrgetter
from dogtail import tree
from dogtail import predicate
from dogtail import dump
ACTIVITIES_WITH_OBJECT_CHOOSER = ["Read", "Image Viewer", "Jukebox"]
+ACTIVITIES_TO_IGNORE = ["Pippy", "Write"]
-class ActivityLauncher:
- def __init__(self, name=None, icon=None):
- self.name = name
- self.icon = icon
+def build_activities_list():
+ shell = tree.root.child(name="sugar-session", roleName="application")
-def get_activity_launchers(shell):
- # Make a list of activities by iterating the table
- activity_launchers = []
+ activities = []
table = shell.child(name="", roleName="table")
pred = predicate.GenericPredicate(roleName="table cell")
cells = table.findChildren(pred)
for row in [cells[i:i+5] for i in range(0, len(cells), 5)]:
- launcher = ActivityLauncher(name=row[2].text, icon=row[1])
- activity_launchers.append(launcher)
+ activity_name = row[2].text
+ if activity_name not in ACTIVITIES_TO_IGNORE:
+ activities.append(activity_name)
+
+ activities.sort()
+
+ return activities
+
+def launch_and_stop_activity(activity_name):
+ shell = tree.root.child(name="sugar-session", roleName="application")
+
+ table = shell.child(name="", roleName="table")
+ pred = predicate.GenericPredicate(roleName="table cell")
+ cells = table.findChildren(pred)
- activity_launchers.sort(key=attrgetter("name"))
+ for row in [cells[i:i+5] for i in range(0, len(cells), 5)]:
+ name = row[2].name
+ icon = row[1]
- return activity_launchers
+ if name == activity_name:
+ print "Launching %s" % activity_name
-def launch_and_stop_activity(activity_launcher):
- print "Launching %s" % activity_launcher.name
+ icon.click()
- activity_launcher.icon.click()
+ print "Stopping %s" % activity_name
- if activity_launcher.name in ACTIVITIES_WITH_OBJECT_CHOOSER:
- close_button = shell.child(name="Close", roleName="push button")
- close_button.click()
+ if activity_name in ACTIVITIES_WITH_OBJECT_CHOOSER:
+ close_button = shell.child(name="Close",
+ roleName="push button")
+ close_button.click()
- activity = tree.root.child(name="sugar-activity", roleName="application")
+ activity = tree.root.child(name="sugar-activity",
+ roleName="application")
- stop_button = activity.child(name="Stop", roleName="push button")
- stop_button.click()
+ stop_button = activity.child(name="Stop", roleName="push button")
+ stop_button.click()
-def main():
+def go_to_list_view():
shell = tree.root.child(name="sugar-session", roleName="application")
- # Complete the intro screen
done_button = shell.child(name="Done", roleName="push button")
done_button.click()
- # Switch to the home list view
radio_button = shell.child(name="List view", roleName="radio button")
radio_button.click()
- # Launch and close all the activities
- for activity_launcher in get_activity_launchers(shell):
- if activity_launcher.name in ["Pippy", "Write"]:
- continue
+def main():
+ go_to_list_view()
- launch_and_stop_activity(activity_launcher)
+ for activity in build_activities_list():
+ launch_and_stop_activity(activity)
try:
main()