コード例 #1
0
 def test_can_update_has_more_updates_left(self):
     runner = ota_runner.MultiUseOtaRunner(self.tool, self.device,
                                           ['first_pkg', 'second_pkg'],
                                           ['first_apk', 'second_apk'])
     with mock.patch.object(ota_runner.OtaRunner, '_update'):
         runner.update()
     self.assertEqual(True, runner.can_update())
コード例 #2
0
 def test_can_update_ran_out_of_updates(self):
     runner = ota_runner.MultiUseOtaRunner(self.tool, self.device,
                                           ['first_pkg', 'second_pkg'],
                                           ['first_apk', 'second_apk'])
     with mock.patch.object(ota_runner.OtaRunner, '_update'):
         runner.update()
         runner.update()
     self.assertEqual(False, runner.can_update())
コード例 #3
0
 def test_update_first_update_runs(self):
     runner = ota_runner.MultiUseOtaRunner(self.tool, self.device, [''],
                                           [''])
     try:
         with mock.patch.object(ota_runner.OtaRunner, '_update'):
             runner.update()
     except ota_runner.OtaError:
         self.fail('MultiUseOtaRunner threw an exception on the first '
                   'update call.')
コード例 #4
0
 def test_update_multiple_updates_run(self):
     runner = ota_runner.MultiUseOtaRunner(self.tool, self.device,
                                           ['first_pkg', 'second_pkg'],
                                           ['first_apk', 'second_apk'])
     with mock.patch.object(ota_runner.OtaRunner, '_update'):
         runner.update()
         try:
             runner.update()
         except ota_runner.OtaError:
             self.fail('MultiUseOtaRunner threw an exception before '
                       'running out of update packages.')
コード例 #5
0
 def test_update_too_many_update_calls_raises_error(self):
     runner = ota_runner.MultiUseOtaRunner(self.tool, self.device,
                                           ['first_pkg', 'second_pkg'],
                                           ['first_apk', 'second_apk'])
     with mock.patch.object(ota_runner.OtaRunner, '_update'):
         runner.update()
         runner.update()
         try:
             runner.update()
         except ota_runner.OtaError:
             return
     self.fail('MultiUseOtaRunner did not throw an exception after running '
               'out of update packages.')
コード例 #6
0
def create_from_package(ota_package,
                        ota_sl4a,
                        android_device,
                        ota_tool,
                        use_cached_runners=True):
    """
    Args:
        ota_package: A string or list of strings corresponding to the
            update.zip package location(s) for running an OTA update.
        ota_sl4a: A string or list of strings corresponding to the
            sl4a.apk package location(s) for running an OTA update.
        ota_tool: The OtaTool to be paired with the returned OtaRunner
        android_device: The AndroidDevice to run the OTA Update on.
        use_cached_runners: Whether or not to use runners cached by previous
            create calls.

    Returns:
        An OtaRunner with the given properties from the arguments.
    """
    if android_device in _bound_devices and use_cached_runners:
        logging.warning('Android device %s has already been assigned an '
                        'OtaRunner. Returning previously created runner.')
        return _bound_devices[android_device]

    if type(ota_package) != type(ota_sl4a):
        raise TypeError(
            'The ota_package and ota_sl4a must either both be strings, or '
            'both be lists. Device with serial "%s" has requested mismatched '
            'types.' % android_device.serial)

    if type(ota_package) is str:
        runner = ota_runner.SingleUseOtaRunner(ota_tool, android_device,
                                               ota_package, ota_sl4a)
    elif type(ota_package) is list:
        runner = ota_runner.MultiUseOtaRunner(ota_tool, android_device,
                                              ota_package, ota_sl4a)
    else:
        raise TypeError('The "ota_package" value in the acts config must be '
                        'either a list or a string.')

    _bound_devices[android_device] = runner
    return runner
コード例 #7
0
 def test_get_sl4a_apk(self):
     runner = ota_runner.MultiUseOtaRunner(self.tool, self.device,
                                           ['first_pkg', 'second_pkg'],
                                           ['first_apk', 'second_apk'])
     self.assertEqual(runner.get_sl4a_apk(), 'first_apk')
コード例 #8
0
 def test_can_update_no_updates_called(self):
     runner = ota_runner.MultiUseOtaRunner(self.tool, self.device,
                                           ['first_pkg', 'second_pkg'],
                                           ['first_apk', 'second_apk'])
     self.assertEqual(True, runner.can_update())