예제 #1
0
def main():
    # capture three samples and automatically scrolls five times
    SAMPLE_COUNT = 3
    REPEAT_COUNT = 5
    print "learning the pace of scrolling"
    pl = Pipeline()
    reader = LiveGeteventReader()
    pl.addStep(reader)
    pl.addStep(dtm.RawTraceParser())
    pl.addStep(dtm.MultiTouchTypeAParser())
    pl.addStep(dtm.RelativeTimingConverter())
    pl.addStep(dtm.FingerDecomposer())
    learner = AutoScrollingLearner(reader, SAMPLE_COUNT)
    pl.addStep(learner)
    pl.execute()
    (waitTime, xdelta, ydelta, duration, pointCount) = learner.getSpeedAndDelta()
    print "User scrolling parameters learned"
    device = EMonkeyDevice()
    (xmiddle, ymiddle) = (device.displayWidth / 2, device.displayHeight / 2)
    start = (xmiddle - xdelta / 2, ymiddle - ydelta / 2)
    end = (xmiddle + xdelta / 2, ymiddle + ydelta / 2)
    for _ in range(REPEAT_COUNT):
        device.sleep(waitTime)
        device.drag(start, end, duration, pointCount)
    print 'done'
예제 #2
0
def main():
    if len(sys.argv) <= 1:
        print "Usage: monkeyrunner DroidReplayer.py TRACE_PATH"
        print "The trace must be generated from getevent -lt [EVDEV]"
        return 1
    print "Replay started"
    pl = Pipeline()
    pl.addStep(dtm.TextFileLineReader(sys.argv[1]))
    pl.addStep(dtm.RawTraceParser())
    pl.addStep(dtm.MultiTouchTypeAParser())
    pl.addStep(dtm.RelativeTimingConverter())
    dev = EMonkeyDevice()
    pl.addStep(dtm.DeviceAdjuster(dev))
    pl.addStep(dtm.FingerDecomposer())
    pl.addStep(GestureReplayEventWrapper())
    # this step might be necessary for a tablet
    # pl.addStep(dtm.TrailScaler(0.8,0.8))
    # pl.addStep(dtm.TimeScaler(0.25))
    # trouble maker
    # pl.addStep(TroubleInjector())
    #replayers = [MonkeyHelperReplayer(dev), TroubleReplayer(dev)]
    #pl.addStep(CompositeReplayer(replayers))
    pl.addStep(MonkeyHelperReplayer(dev))
    pl.addStep(dtm.GenericPrinter())
    pl.execute()
    print "Replay finished"
예제 #3
0
def main():
    """ This example dumps all error messages in logcat and then clear it.
    After 5 seconds, it dumps all messages and finishes.
    Note that logcat encodes its output with utf-8
    """
    device = EMonkeyDevice()
    agent = LogcatAgent(device)
    print agent.dump(fmt=None, filterTuples=[('*', 'E')])
    agent.clear()
    print 'Waiting for 5 seconds...'
    time.sleep(5)
    print agent.dump()
예제 #4
0
def main():
    # capture three samples and automatically scrolls five times
    SAMPLE_COUNT = 3
    REPEAT_COUNT = 5
    print "learning the pace of scrolling"
    pl = Pipeline()
    reader = LiveGeteventReader()
    pl.addStep(reader)
    pl.addStep(dtm.RawTraceParser())
    pl.addStep(dtm.MultiTouchTypeAParser())
    pl.addStep(dtm.RelativeTimingConverter())
    pl.addStep(dtm.FingerDecomposer())
    learner = AutoScrollingLearner(reader, SAMPLE_COUNT)
    pl.addStep(learner)
    pl.execute()
    (waitTime, xdelta, ydelta, duration,
     pointCount) = learner.getSpeedAndDelta()
    print "User scrolling parameters learned"
    device = EMonkeyDevice()
    (xmiddle, ymiddle) = (device.displayWidth / 2, device.displayHeight / 2)
    start = (xmiddle - xdelta / 2, ymiddle - ydelta / 2)
    end = (xmiddle + xdelta / 2, ymiddle + ydelta / 2)
    for _ in range(REPEAT_COUNT):
        device.sleep(waitTime)
        device.drag(start, end, duration, pointCount)
    print 'done'
def main():
    """ This test launches a series of apps (with given package and main activity names)
    and repeats this for a given number of times. After that, the scripts dumps the error
    messages printed to logcat during the test.
    """
    # constants
    APP_HOME = 'com.android.launcher/com.android.launcher2.Launcher'
    APP_CLOCK = 'com.google.android.deskclock/com.android.deskclock.DeskClock'
    # configurations
    packages = [APP_CLOCK, APP_HOME]
    sleep_interval = 2
    repeats = 2
    app_tag = 'ActivityManager'
    device = EMonkeyDevice()
    agent = LogcatAgent(device)
    agent.clear()
    print 'Start launching stress test'
    for _ in range(repeats):
        for p in packages:
            device.startActivity(component=p)
            time.sleep(sleep_interval)
    err = agent.dump(fmt=None, filterTuples=[(app_tag, 'E'), ('*', 'S')])
    print 'Finishing test, dumping error messages:'
    print err
예제 #6
0
def main():
    """ This test launches a series of apps (with given package and main activity names)
    and repeats this for a given number of times. After that, the scripts dumps the error
    messages printed to logcat during the test.
    """
    # constants
    APP_HOME = 'com.android.launcher/com.android.launcher2.Launcher'
    APP_CLOCK = 'com.google.android.deskclock/com.android.deskclock.DeskClock'
    # configurations
    packages = [APP_CLOCK, APP_HOME]
    sleep_interval = 2
    repeats = 2
    app_tag = 'ActivityManager'
    device = EMonkeyDevice()
    agent = LogcatAgent(device)
    agent.clear()
    print 'Start launching stress test'
    for _ in range(repeats):
        for p in packages:
            device.startActivity(component=p)
            time.sleep(sleep_interval)
    err = agent.dump(fmt=None, filterTuples=[(app_tag, 'E'), ('*', 'S')])
    print 'Finishing test, dumping error messages:'
    print err
예제 #7
0
""" This script demonstrates the use of MonkeyHelper APIs
"""

import os, sys, inspect


def module_path():
    ''' returns the module path without the use of __file__.
    from http://stackoverflow.com/questions/729583/getting-file-path-of-imported-module'''
    return os.path.abspath(os.path.dirname(inspect.getsourcefile(module_path)))


sys.path.append(module_path())
sys.path.append(os.path.join(module_path(), '..', 'src'))

# The MonkeyHelper module is in the same folder but monkeyrunner launcher needs to know
from MonkeyHelper import EMonkeyDevice

# starting the application and test
print "Starting the demo"

# automatically connect to the current device
device = EMonkeyDevice()
print "Installed packages"
print device.getInstalledPackage()
device.wake().sleep(1).unlockScreen().sleep(1)
device.slideRight().sleep(2).slideLeft().sleep(1)
device.press('KEYCODE_MENU').sleep(1).touch(95, 400).sleep(1)

print "Finishing the demo"
예제 #8
0
""" This script demonstrates the use of MonkeyHelper APIs
"""

import os, sys, inspect


def module_path():
    ''' returns the module path without the use of __file__.
    from http://stackoverflow.com/questions/729583/getting-file-path-of-imported-module'''
    return os.path.abspath(os.path.dirname(inspect.getsourcefile(module_path)))


sys.path.append(module_path())
sys.path.append(os.path.join(module_path(), '..', 'src'))

# The MonkeyHelper module is in the same folder but monkeyrunner launcher needs to know
from MonkeyHelper import EMonkeyDevice

# starting the application and test
print "Starting the demo"

# automatically connect to the current device
device = EMonkeyDevice()
print "Installed packages"
print device.getInstalledPackage()
device.wake().sleep(1).unlockScreen().sleep(1)
device.slideRight().sleep(2).slideLeft().sleep(1)
device.press('KEYCODE_MENU').sleep(1).touch(95, 400).sleep(1)

print "Finishing the demo"
예제 #9
0
        log = self.logcat.dump(filterTuples=[('*', 'W')])
        log = log.split('\n')
        result = []
        for line in log:
            if self.package in line:
                result.append(line)
        return result
        #self.device.shell('logcat *:W | grep '+self.activity)

    def clearLog(self):
        return self.logcat.clear()

    def runner(self, mode='mix'):
        #log=open('HeissenbugTesterlog.txt', 'w')
        #logcat=subprocess.Popen(['adb','logcat', '*:W', '|', 'grep', self.package], stdout=log)
        self.clearLog()
        if mode == 'mix':
            result = self.runnerMixEvents()
        elif mode == 'special':
            result = self.runnerSpecialEvents()
        elif mode == 'simple':
            result = self.runnerSimpleEvents()
        return result, self.dumpLog()


if __name__ == '__main__':
    device = EMonkeyDevice()
    test = HeisenbugTester(device, package='com.android.gallery3d')
    result, log = test.runner()
    print log