コード例 #1
0
ファイル: devices.py プロジェクト: henrydeng/orangfuzz
 def getHomeKeyLongPress(self, rnd, count):
     '''Trigger a long press on the home key, defined as >= 2 seconds.'''
     return ' '.join(
         [countWithDesc(count, 'Home key long press') +
          actions.TAP_ACTION] + [str(x)
                                 for x in self.getHomeKeyLocation()] +
         ['1', str(rnd.randint(2000, 10000))])
コード例 #2
0
ファイル: devices.py プロジェクト: henrydeng/orangfuzz
 def getForceCloseApp(self, rnd, count):
     '''Force close an application.'''
     return ' '.join([countWithDesc(count, 'Force close an application')] +
                     [self.getHomeKeyLongPress(rnd, count) + ' ; '] +
                     [actions.getRandomSleep(rnd, count) + ' ; '] +
                     [actions.TAP_ACTION] +
                     [str(x)
                      for x in self.getAppSwitcherXButtonLocation()] +
                     ['1', str(rnd.randint(50, 1000))])
コード例 #3
0
ファイル: devices.py プロジェクト: MozillaSecurity/orangfuzz
 def getForceCloseApp(self, rnd, count):
     '''Force close an application.'''
     return ' '.join([countWithDesc(count, 'Force close an application')] +
                         [self.getHomeKeyLongPress(rnd, count) + ' ; '] +
                         [actions.getRandomSleep(rnd, count) + ' ; '] +
                         [actions.TAP_ACTION] +
                         [str(x) for x in self.getAppSwitcherXButtonLocation()] +
                         ['1', str(rnd.randint(50, 1000))]
                     )
コード例 #4
0
ファイル: devices.py プロジェクト: henrydeng/orangfuzz
 def getToggleAirplaneMode(self, rnd, count):
     '''Toggles airplane mode.'''
     return ' '.join(
         [countWithDesc(count, 'Toggle airplane mode')] +
         [self.getHomeKeyTap(rnd, count, 5) + ' ; '] +
         [actions.getRandomSleep(rnd, count) + ' ; '] +
         [actions.getDragToRightHomescreen(rnd, count) + ' ; '] +
         [actions.getRandomSleep(rnd, count) + ' ; '] +
         [actions.TAP_ACTION] +
         [str(x) for x in self.getSettingsDefaultLocationOnSecondScreen()] +
         ['1', str(rnd.randint(50, 1000)) + ' ; '] +
         [actions.getRandomSleep(rnd, count) + ' ; '] +
         [actions.TAP_ACTION] +
         [str(x) for x in self.getAirplaneModeLocationInSettingsApp()] +
         ['1', str(rnd.randint(50, 1000))])
コード例 #5
0
ファイル: devices.py プロジェクト: MozillaSecurity/orangfuzz
 def getToggleGeolocationMode(self, rnd, count):
     '''Toggles geolocation mode.'''
     return ' '.join([countWithDesc(count, 'Toggle geolocation mode')] +
                         [self.getHomeKeyTap(rnd, count, 5) + ' ; '] +
                         [actions.getRandomSleep(rnd, count) + ' ; '] +
                         [actions.getDragToRightHomescreen(rnd, count) + ' ; '] +
                         [actions.getRandomSleep(rnd, count) + ' ; '] +
                         [actions.TAP_ACTION] +
                         [str(x) for x in self.getSettingsDefaultLocationOnSecondScreen()] +
                         ['1', str(rnd.randint(50, 1000)) + ' ; '] +
                         [actions.getRandomSleep(rnd, count) + ' ; '] +
                         [actions.TAP_ACTION] +
                         [str(x) for x in self.getGeolocationModeLocationInSettingsApp()] +
                         ['1', str(rnd.randint(50, 1000))]
                     )
コード例 #6
0
ファイル: devices.py プロジェクト: henrydeng/orangfuzz
 def getHomeKeyTap(self, rnd, count, tapCounts):
     '''Trigger a tap on the home key.'''
     return ' '.join(
         [countWithDesc(count, 'Home key tap') + actions.TAP_ACTION] +
         [str(x) for x in self.getHomeKeyLocation()] +
         [str(tapCounts), str(rnd.randint(50, 1000))])
コード例 #7
0
ファイル: devices.py プロジェクト: MozillaSecurity/orangfuzz
 def getHomeKeyLongPress(self, rnd, count):
     '''Trigger a long press on the home key, defined as >= 2 seconds.'''
     return ' '.join([countWithDesc(count, 'Home key long press') + actions.TAP_ACTION] +
                         [str(x) for x in self.getHomeKeyLocation()] +
                         ['1', str(rnd.randint(2000, 10000))]
                     )
コード例 #8
0
ファイル: devices.py プロジェクト: MozillaSecurity/orangfuzz
 def getHomeKeyTap(self, rnd, count, tapCounts):
     '''Trigger a tap on the home key.'''
     return ' '.join([countWithDesc(count, 'Home key tap') + actions.TAP_ACTION] +
                         [str(x) for x in self.getHomeKeyLocation()] +
                         [str(tapCounts), str(rnd.randint(50, 1000))]
                     )
コード例 #9
0
ファイル: orangfuzz.py プロジェクト: henrydeng/orangfuzz
def generateLines(args, dvc, rnd, outputLines):
    '''Get orangfuzz to generate lines.'''
    count = 1
    sleepAllowed = True

    while (count <= args.lines):
        # Tap the home key once, not necessarily back to the home screen.
        if count % rnd.randint(1, 500) == 0:
            outputLines.append(dvc.getHomeKeyTap(rnd, count, rnd.randint(1, 2)))
            sleepAllowed = True
            count += 1
            continue

        # Tap the home key back to the home screen.
        if count % rnd.randint(1, 1000) == 0:
            outputLines.append(dvc.getHomeKeyTap(rnd, count, 5))
            sleepAllowed = True
            count += 1
            continue

        # Brings up the list of applications with a long press of the home key.
        if count % rnd.randint(1, 1000) == 0:
            outputLines.append(dvc.getHomeKeyLongPress(rnd, count))
            sleepAllowed = True
            count += 1
            continue

        # Force quits current application.
        if count % rnd.randint(1, 1000) == 0:
            outputLines.append(dvc.getForceCloseApp(rnd, count))
            sleepAllowed = True
            count += 1
            continue

        # Toggles airplane mode.
        if count % rnd.randint(1, 1000) == 0:
            outputLines.append(dvc.getToggleAirplaneMode(rnd, count))
            sleepAllowed = True
            count += 1
            continue

        # Toggles geolocation mode.
        if count % rnd.randint(1, 1000) == 0:
            outputLines.append(dvc.getToggleGeolocationMode(rnd, count))
            sleepAllowed = True
            count += 1
            continue

        actionNow = rnd.choice(ACTION_CHOICES)
        if actionNow == TAP_ACTION:
            outputLines.append(' '.join(str(x) for x in [
                countWithDesc(count, 'Tap action') + TAP_ACTION,
                rnd.randint(1, dvc.getMaxHorizPixels()), rnd.randint(1, dvc.getMaxVertPixels()),
                rnd.randint(1, 3),
                rnd.randint(50, 1000)
            ]))
            sleepAllowed = True
            count += 1
        elif actionNow == SLEEP_ACTION:
            if sleepAllowed:
                outputLines.append(getRandomSleep(rnd, count))
                sleepAllowed = False
                count += 1
        elif actionNow == DRAG_ACTION:
            outputLines.append(' '.join(str(x) for x in [
                countWithDesc(count, 'Drag action') + DRAG_ACTION,
                # Starting co-ordinates
                rnd.randint(1, dvc.getMaxHorizPixels()), rnd.randint(1, dvc.getMaxVertPixels()),
                # Ending co-ordinates
                rnd.randint(1, dvc.getMaxHorizPixels()), rnd.randint(1, dvc.getMaxVertPixels()),
                rnd.randint(10, 20),
                rnd.randint(10, 350)
            ]))
            sleepAllowed = True
            count += 1
        else:
            raise Exception('Unknown action: ' + actionNow)

    return outputLines
コード例 #10
0
def getDragToRightHomescreen(rnd, count):
    '''Returns a drag action to the homescreen on the right side.'''
    # Fixed to Unagi for the moment.
    return ' '.join(str(x) for x in [countWithDesc(count, 'Drag action') + DRAG_ACTION, 118, 53, 36, 108, 12, 99])