def testWebViewGetDevtoolsRemotePortMultipleProcessesFailure(self):
    mock_device = mock.Mock()
    mock_device.GetPids.side_effect = [
        {'webview.package': ['1111', '2222']}
    ]

    settings = android_browser_backend_settings.WebviewBackendSettings(
        package='webview.package')
    with mock.patch('time.sleep', return_value=None):
      with self.assertRaises(Exception):
        settings.GetDevtoolsRemotePort(mock_device)
  def testWebViewGetDevtoolsRemotePortRetrySuccess(self):
    mock_device = mock.Mock()
    mock_device.GetPids.side_effect = [
        {},
        {},
        {'webview.package': ['1111']},
    ]

    settings = android_browser_backend_settings.WebviewBackendSettings(
        package='webview.package')
    with mock.patch('time.sleep', return_value=None):
      self.assertEquals(
          settings.GetDevtoolsRemotePort(mock_device),
          'localabstract:webview_devtools_remote_1111')
  def testWebViewGetDevtoolsRemotePortTimeoutFailure(self):
    mock_device = mock.Mock()
    mock_device.GetPids.side_effect = [
        {},
        {},
        {},
        {},
    ]

    settings = android_browser_backend_settings.WebviewBackendSettings(
        package='webview.package')
    with mock.patch('time.sleep', return_value=None) as time_mock:
      with self.assertRaises(Exception):
        settings.GetDevtoolsRemotePort(mock_device)
      time_mock.assert_has_calls(
          [mock.call(1), mock.call(2), mock.call(4), mock.call(8)])
Ejemplo n.º 4
0
    def Start(self):
        """Start an Android app and wait for it to finish launching.

    AppStory derivations can customize the wait-for-ready-state to wait
    for a more specific event if needed.
    """
        webview_startup_args = self.GetWebviewStartupArgs()
        backend_settings = android_browser_backend_settings.WebviewBackendSettings(
            'android-webview')
        with android_command_line_backend.SetUpCommandLineFlags(
                self._adb, backend_settings, webview_startup_args):
            # TODO(slamm): check if can use "blocking=True" instead of needing to
            # sleep. If "blocking=True" does not work, switch sleep to "ps" check.
            self._adb.device().StartActivity(self._start_intent,
                                             blocking=False)
            util.WaitFor(self._IsAppReady, timeout=60)
        self._is_running = True
Ejemplo n.º 5
0
  def Start(self):
    """Start an Android app and wait for it to finish launching.

    If the app has webviews, the app is launched with the suitable
    command line arguments.

    AppStory derivations can customize the wait-for-ready-state to wait
    for a more specific event if needed.
    """
    if self._app_has_webviews:
      webview_startup_args = self.GetWebviewStartupArgs()
      backend_settings = (
          android_browser_backend_settings.WebviewBackendSettings(
              'android-webview'))
      with android_command_line_backend.SetUpCommandLineFlags(
          self.device, backend_settings, webview_startup_args):
        self._LaunchAndWaitForApplication()
    else:
      self._LaunchAndWaitForApplication()
    self._is_running = True