Welcome to mirror list, hosted at ThFree Co, Russian Federation.

mapswithme.py « monkey « tests « android - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d9bd13a0f283ac207fd8b160e01a164c00497616 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# coding=utf-8
import time

from mutil import DeviceInfo
from com.android.monkeyrunner import MonkeyRunner

apkPath = '../MapsWithMeTest/bin/MapsWithMeTest-release.apk'
package = 'com.mapswithme.maps.pro'
activity = 'com.mapswithme.maps.DownloadResourcesActivity'
mapactivity = 'com.mapswithme.maps.MWMActivity'


def run_tasks(device, tasks):
    # wait for initialization
    MonkeyRunner.sleep(5)
    for t in tasks:
        t.send(device)


class MWMTask:
    def send(self, device):
        pass


class SearchTask(MWMTask):
    task = 'task_search'
    query = ''
    scope = 0

    def __init__(self, query, scope=0):
        self.query = query
        self.scope = scope


    def send(self, device):
        device.broadcastIntent(action='mwmtest',
                               extras={'task': self.task, 'search_query': str(self.query),
                                       'search_scope': str(self.scope)})
        print 'Sent', self
        MonkeyRunner.sleep(3)
        di = DeviceInfo(device)
        device.takeSnapshot().writeToFile(di.get_screenshot_path(self))


    def __str__(self):
        return 'search_%s_%s' % (self.query, str(self.scope))


class ShowGroupTask(MWMTask):
    task = 'task_bmk'
    name = ''
    duration = 0

    def __init__(self, name, duration):
        self.name = name
        self.duration = duration

    def send(self, device):
        di = DeviceInfo(device)
        # send intent
        device.broadcastIntent(action='mwmtest',
                               extras={'task': self.task, 'name': self.name})

        start = time.time()
        end = start + self.duration
        now = start
        print now, end, end - now
        while now < end:
            now = time.time()
            filename = di.get_screenshot_path('%s_%s' % (self, now))
            device.takeSnapshot().writeToFile(filename)
            print 'Captured', filename
            MonkeyRunner.sleep(0.7)


    def __str__(self):
        return 'group_show_%s_%s' % (self.name, str(self.duration))