コード例 #1
0
 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)
コード例 #2
0
 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)
コード例 #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
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()
print 'toggle WIFI status', test.changeWifiStatus()
sleep(5)
print 'turn off cellular data status', test.turnOffWifi()
sleep(5)
print 'turn on cellular data status', test.turnOnWifi()