Пример #1
0
class TroubleReplayer(Replayer):
    """Replay finger trails with Heisenbug events injected in between
    """
    def __init__(self, dev):
        Replayer.__init__(self)
        self.device = dev
        self.wifiAgent = WifiAgent(self.device)
        self.cellularAgent = CellularAgent(self.device)

    def next(self, specialEvent):
        name = specialEvent.getName()
        lastTimeStamp = self.getTimestamp()
        if specialEvent.timestamp > lastTimeStamp:
            self.device.sleep(specialEvent.timestamp - lastTimeStamp)
        else:
            pass
        if name == 'wifi':
            print 'Injecting wifi event'
            self.wifiAgent.changeWifiStatus()
        elif name == 'cellular':
            self.cellularAgent.toggleCellularDataStatus()
            print 'Injecting cellular event'
        self.setTimestamp(specialEvent.timestamp)
        return PipelineParcel()

    def canAccept(self, replayEvent):
        return isinstance(replayEvent, SpecialEvent)
Пример #2
0
class TroubleReplayer(Replayer):
    """Replay finger trails with Heisenbug events injected in between
    """

    def __init__(self, dev):
        Replayer.__init__(self)
        self.device = dev
        self.wifiAgent = WifiAgent(self.device)
        self.cellularAgent = CellularAgent(self.device)

    def next(self, specialEvent):
        name = specialEvent.getName()
        lastTimeStamp = self.getTimestamp()
        if specialEvent.timestamp>lastTimeStamp:
            self.device.sleep(specialEvent.timestamp - lastTimeStamp)
        else:
            pass
        if name == 'wifi':
            print 'Injecting wifi event'
            self.wifiAgent.changeWifiStatus()
        elif name == 'cellular':
            self.cellularAgent.toggleCellularDataStatus()
            print 'Injecting cellular event'
        self.setTimestamp(specialEvent.timestamp)
        return PipelineParcel()
    
    def canAccept(self, replayEvent):
        return isinstance(replayEvent, SpecialEvent)
Пример #3
0
class TroubleReplayer(Replayer):

    """Replay finger trails with Heisenbug events injected in between
    """

    def __init__(self, dev):
        Replayer.__init__(self)
        self.device = dev
        self.wifiAgent = WifiAgent(self.device)
        self.cellularAgent = CellularAgent(self.device)
        self.screenAgent = ScreenAgent(self.device)
        self.keypressAgent = KeypressAgent(self.device)

    def next(self, specialEvent):
        if self.canAccept(specialEvent):
            name = specialEvent.getName()
            lastTimeStamp = self.getTimestamp()
            if specialEvent.timestamp > lastTimeStamp:
                print lastTimeStamp
                print specialEvent.timestamp
                self.device.sleep(specialEvent.timestamp - lastTimeStamp)
            else:
                pass
            self.unitReplay(name)
            self.setTimestamp(specialEvent.timestamp)
        elif isinstance(specialEvent,ReplayEvent):
            self.setTimestamp(specialEvent.timestamp)
            print self.getTimestamp()
        return PipelineParcel()

    def canAccept(self, replayEvent):
        return isinstance(replayEvent, SpecialEvent)

    def unitReplay(self, name):
        print 'Injecting ' + name + ' event'
        if name == 'wifi':
            self.wifiAgent.changeWifiStatus()
        elif name == 'cellular':
            self.cellularAgent.toggleCellularDataStatus()
        elif name == 'toggleScreen':
            self.screenAgent.toggleScreen()
            #toggle twice to get back to original screen state
            self.screenAgent.toggleScreen()
        elif name == 'rotateScreen':
            self.screenAgent.changeOrientation()
            #rotate twice to get back to original screen orientation
            self.device.sleep(2000)
            self.screenAgent.changeOrientation()
        elif name == 'pressBack':
            self.keypressAgent.pressBack()
        elif name == 'pressHome':
            self.keypressAgent.pressHome()
Пример #4
0
class TroubleReplayer(Replayer):
    """Replay finger trails with Heisenbug events injected in between
    """
    def __init__(self, dev):
        Replayer.__init__(self)
        self.device = dev
        self.wifiAgent = WifiAgent(self.device)
        self.cellularAgent = CellularAgent(self.device)
        self.screenAgent = ScreenAgent(self.device)
        self.keypressAgent = KeypressAgent(self.device)

    def next(self, specialEvent):
        if self.canAccept(specialEvent):
            name = specialEvent.getName()
            lastTimeStamp = self.getTimestamp()
            if specialEvent.timestamp > lastTimeStamp:
                print lastTimeStamp
                print specialEvent.timestamp
                self.device.sleep(specialEvent.timestamp - lastTimeStamp)
            else:
                pass
            self.unitReplay(name)
            self.setTimestamp(specialEvent.timestamp)
        elif isinstance(specialEvent, ReplayEvent):
            self.setTimestamp(specialEvent.timestamp)
            print self.getTimestamp()
        return PipelineParcel()

    def canAccept(self, replayEvent):
        return isinstance(replayEvent, SpecialEvent)

    def unitReplay(self, name):
        print 'Injecting ' + name + ' event'
        if name == 'wifi':
            self.wifiAgent.changeWifiStatus()
        elif name == 'cellular':
            self.cellularAgent.toggleCellularDataStatus()
        elif name == 'toggleScreen':
            self.screenAgent.toggleScreen()
            #toggle twice to get back to original screen state
            self.screenAgent.toggleScreen()
        elif name == 'rotateScreen':
            self.screenAgent.changeOrientation()
            #rotate twice to get back to original screen orientation
            self.device.sleep(2000)
            self.screenAgent.changeOrientation()
        elif name == 'pressBack':
            self.keypressAgent.pressBack()
        elif name == 'pressHome':
            self.keypressAgent.pressHome()
Пример #5
0
    ''' 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'))

from Agents import CellularAgent, ScreenAgent, SystemStatusAgent, WifiAgent
from MonkeyHelper import EMonkeyDevice
from time import sleep

device = EMonkeyDevice()
test = CellularAgent(device)
print 'current cellular data status', test.getCellularDataStatus()
print 'toggle cellular data status', test.toggleCellularDataStatus()
sleep(5)
print 'turn off cellular data status', test.turnOffCellularData()
sleep(5)
print 'turn on cellular data status', test.turnOnCellularData()

test = ScreenAgent(device)
print 'current screen rotation status', test.getScreenRotationStatus()
print 'current orientation', test.getOrientation()

test = SystemStatusAgent(device)
print 'current WIFI status', test.getWifiStatus()
print 'current battery level', test.getBatteryLevel()

test = WifiAgent(device)
print 'current WIFI status', test.getWiFiStatus()
Пример #6
0
    ''' 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'))

from Agents import CellularAgent, ScreenAgent, SystemStatusAgent, WifiAgent
from MonkeyHelper import EMonkeyDevice
from time import sleep

device = EMonkeyDevice()
test = CellularAgent(device)
print 'current cellular data status', test.getCellularDataStatus()
print 'toggle cellular data status', test.toggleCellularDataStatus()
sleep(5)
print 'turn off cellular data status', test.turnOffCellularData()
sleep(5)
print 'turn on cellular data status', test.turnOnCellularData()

test = ScreenAgent(device)
print 'current screen rotation status', test.getScreenRotationStatus()
print 'current orientation', test.getOrientation()

test = SystemStatusAgent(device)
print 'current WIFI status', test.getWifiStatus()
print 'current battery level', test.getBatteryLevel()

test = WifiAgent(device)
print 'current WIFI status', test.getWiFiStatus()