Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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()
Ejemplo n.º 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()