Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests/shell.py
blob: 2c9b3f5a471503137d4b238b111ff80036ae28b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from operator import attrgetter

from dogtail import tree
from dogtail import predicate

class Activity:
    def __init__(self, name=None, icon=None):
        self.name = name
        self.icon = icon

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()

# Make a list of activities by iterating the table
activities = []

table = shell.child(name="", roleName="table")
cells = table.findChildren(predicate.GenericPredicate(roleName="table cell"))
for row in [cells[i:i+5] for i in range(0, len(cells), 5)]:
    activities.append(Activity(name=row[2].text, icon=row[1]))

activities.sort(key=attrgetter("name"))

# Launch and close all the activities
for activity in activities:
    print "Launching %s" % activity.name 

    activity.icon.click()

    # Some activities displays an object chooser, let's close it
    if activity.name in ["Read", "Image Viewer", "Jukebox"]:
        close_button = shell.child(name="Close", roleName="push button")
        close_button.click()

    activity = tree.root.child(name="sugar-activity", roleName="application")

    pred = predicate.GenericPredicate(name="Stop", roleName="push button")
    stop_buttons = activity.findChildren(pred)
    stop_buttons[-1].click()