Example #1
0
 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))])
Example #2
0
 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))]
                     )
Example #3
0
 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))])
Example #4
0
 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))]
                     )
Example #5
0
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