Beispiel #1
0
 def testNoAdbReturnsNone(self, warning_mock):
     finder_options = browser_options.BrowserFinderOptions()
     with (mock.patch('os.path.isabs',
                      return_value=True)), (mock.patch('os.path.exists',
                                                       return_value=False)):
         self.assertEquals(warning_mock.call_count, 0)
         self.assertIsNone(android_device.GetDevice(finder_options))
Beispiel #2
0
    def __init__(self, test, finder_options, story_set):
        """This method is styled on unittest.TestCase.setUpClass.

    Args:
      test: a web_perf.TimelineBasedMeasurement instance.
      options: a BrowserFinderOptions instance with command line options.
      story_set: a story.StorySet instance.
    """
        super(SharedAndroidState, self).__init__(test, finder_options,
                                                 story_set)
        if not isinstance(test,
                          timeline_based_measurement.TimelineBasedMeasurement):
            raise ValueError(
                'SharedAndroidState only accepts TimelineBasedMeasurement tests'
                ' (not %s).' % test.__class__)
        self._test = test
        self._finder_options = finder_options
        self._android_app = None
        self._current_story = None
        device = android_device.GetDevice(finder_options)
        assert device, 'Android device required.'
        self._android_platform = platform.GetPlatformForDevice(
            device, finder_options)
        assert self._android_platform, 'Unable to create android platform.'
        assert isinstance(self._android_platform,
                          android_platform.AndroidPlatform)
 def testNoAdbReturnsNone(self):
     finder_options = browser_options.BrowserFinderOptions()
     with (mock.patch('os.path.isabs',
                      return_value=True)), (mock.patch('os.path.exists',
                                                       return_value=False)):
         self.assertEquals([], self._android_device_stub.logging.warnings)
         self.assertIsNone(android_device.GetDevice(finder_options))
 def testAdbOneDeviceReturnsDeviceInstance(self):
   finder_options = browser_options.BrowserFinderOptions()
   with mock.patch('os.path.isabs', return_value=False):
     self._healthy_device_mock.return_value = [
         self._GetMockDeviceUtils('015d14fec128220c')]
     device = android_device.GetDevice(finder_options)
     self.assertEquals([], self._android_device_stub.logging.warnings)
     self.assertEquals('015d14fec128220c', device.device_id)
 def testAdbPickOneDeviceReturnsDeviceInstance(self):
   finder_options = browser_options.BrowserFinderOptions()
   platform_options = remote_platform_options.AndroidPlatformOptions(
       device='555d14fecddddddd')  # pick one
   finder_options.remote_platform_options = platform_options
   with mock.patch('os.path.isabs', return_value=False):
     self._healthy_device_mock.return_value = [
         self._GetMockDeviceUtils('015d14fec128220c'),
         self._GetMockDeviceUtils('555d14fecddddddd')]
     device = android_device.GetDevice(finder_options)
     self.assertEquals([], self._android_device_stub.logging.warnings)
     self.assertEquals('555d14fecddddddd', device.device_id)
Beispiel #6
0
 def testAdbTwoDevicesReturnsNone(self, warning_mock):
     finder_options = browser_options.BrowserFinderOptions()
     with mock.patch('os.path.isabs', return_value=False):
         self._healthy_device_mock.return_value = [
             self._GetMockDeviceUtils('015d14fec128220c'),
             self._GetMockDeviceUtils('015d14fec128220d')
         ]
         device = android_device.GetDevice(finder_options)
         warning_mock.assert_called_with(
             'Multiple devices attached. Please specify one of the following:\n'
             '  --device=015d14fec128220c\n'
             '  --device=015d14fec128220d')
         self.assertIsNone(device)
    def __init__(self, test, finder_options, story_set):
        # TODO(bsheedy): See about making this a cross-platform SharedVrPageState -
        # Seems like we should be able to use SharedPageState's default platform
        # property instead of specifying AndroidPlatform, and then just perform
        # different setup based off the platform type
        device = android_device.GetDevice(finder_options)
        assert device, 'Android device is required for this story'
        self._platform = platform.GetPlatformForDevice(device, finder_options)
        assert self._platform, 'Unable to create Android platform'
        assert isinstance(self._platform, android_platform.AndroidPlatform)

        super(SharedAndroidVrPageState, self).__init__(test, finder_options,
                                                       story_set)
        self._PerformAndroidVrSetup()
Beispiel #8
0
 def testAdbTwoDevicesReturnsNone(self):
     finder_options = browser_options.BrowserFinderOptions()
     with mock.patch('os.path.isabs', return_value=False):
         self._healthy_device_mock.return_value = [
             self._GetMockDeviceUtils('015d14fec128220c'),
             self._GetMockDeviceUtils('015d14fec128220d')
         ]
         presentation.device = android_device.GetDevice(finder_options)
         self.assertEquals([
             'Multiple devices attached. Please specify one of the following:\n'
             '  --presentation.device=015d14fec128220c\n'
             '  --presentation.device=015d14fec128220d'
         ], self._android_device_stub.logging.warnings)
         self.assertIsNone(presentation.device)
Beispiel #9
0
 def testAdbNoDevicesReturnsNone(self, warning_mock):
     finder_options = browser_options.BrowserFinderOptions()
     with mock.patch('os.path.isabs', return_value=False):
         self._healthy_device_mock.return_value = []
         self.assertEquals(warning_mock.call_count, 0)
         self.assertIsNone(android_device.GetDevice(finder_options))
 def testAdbNoDevicesReturnsNone(self):
     finder_options = browser_options.BrowserFinderOptions()
     with mock.patch('os.path.isabs', return_value=False):
         self._healthy_device_mock.return_value = []
         self.assertEquals([], self._android_device_stub.logging.warnings)
         self.assertIsNone(android_device.GetDevice(finder_options))
 def setUp(self):
     self._options = options_for_unittests.GetCopy()
     self._device = android_device.GetDevice(self._options)