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)
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()
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()