Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests/shell.py
blob: f78963a755cd639275204d1b27ad529d1bb55113 (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
47
48
49
50
51
52
53
54
55
from operator import attrgetter

from dogtail import tree
from dogtail import predicate

ACTIVITIES_WITH_OBJECT_CHOOSER = ["Read", "Image Viewer", "Jukebox"]

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

def get_activity_launchers(shell):
    # Make a list of activities by iterating the table
    activity_launchers = []

    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_launchers.sort(key=attrgetter("name"))

    return activity_launchers

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 == "Pippy":
        continue

    print "Launching %s" % activity_launcher.name 

    activity_launcher.icon.click()

    if activity_launcher.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")

    stop_button = activity.child(name="Stop", roleName="push button")
    stop_button.click()