def get(port_name=None, options=None):
    """Returns an object implementing the Port interface. If
    port_name is None, this routine attempts to guess at the most
    appropriate port on this platform."""
    port_to_use = port_name
    if port_to_use is None:
        if sys.platform == 'win32':
            port_to_use = 'chromium-win'
        elif sys.platform == 'linux2':
            port_to_use = 'chromium-linux'
        elif sys.platform == 'darwin':
            port_to_use = 'chromium-mac'

    if port_to_use == 'test':
        import test
        return test.TestPort(port_name, options)
    elif port_to_use.startswith('mac'):
        import mac
        return mac.MacPort(port_name, options)
    elif port_to_use.startswith('chromium-mac'):
        import chromium_mac
        return chromium_mac.ChromiumMacPort(port_name, options)
    elif port_to_use.startswith('chromium-linux'):
        import chromium_linux
        return chromium_linux.ChromiumLinuxPort(port_name, options)
    elif port_to_use.startswith('chromium-win'):
        import chromium_win
        return chromium_win.ChromiumWinPort(port_name, options)

    raise NotImplementedError('unsupported port: %s' % port_to_use)
Example #2
0
 def test_setup_environ_for_server(self):
     port = chromium_win.ChromiumWinPort()
     port._executive = mocktool.MockExecute(True)
     port.path_from_chromium_base = self._mock_path_from_chromium_base
     output = outputcapture.OutputCapture()
     orig_environ = os.environ.copy()
     env = output.assert_outputs(self, port.setup_environ_for_server)
     self.assertEqual(orig_environ["PATH"], os.environ["PATH"])
     self.assertNotEqual(env["PATH"], os.environ["PATH"])
Example #3
0
def get(port_name=None, options=None):
    """Returns an object implementing the Port interface. If
    port_name is None, this routine attempts to guess at the most
    appropriate port on this platform."""
    port_to_use = port_name
    if port_to_use is None:
        if sys.platform == 'win32' or sys.platform == 'cygwin':
            if options and hasattr(options, 'chromium') and options.chromium:
                port_to_use = 'chromium-win'
            else:
                port_to_use = 'win'
        elif sys.platform == 'linux2':
            port_to_use = 'chromium-linux'
        elif sys.platform == 'darwin':
            if options and hasattr(options, 'chromium') and options.chromium:
                port_to_use = 'chromium-mac'
            else:
                port_to_use = 'mac'

    if port_to_use is None:
        raise NotImplementedError('unknown port; sys.platform = "%s"' %
                                  sys.platform)

    if port_to_use == 'test':
        import test
        return test.TestPort(port_name, options)
    elif port_to_use.startswith('dryrun'):
        import dryrun
        return dryrun.DryRunPort(port_name, options)
    elif port_to_use.startswith('mac'):
        import mac
        return mac.MacPort(port_name, options)
    elif port_to_use.startswith('win'):
        import win
        return win.WinPort(port_name, options)
    elif port_to_use.startswith('gtk'):
        import gtk
        return gtk.GtkPort(port_name, options)
    elif port_to_use.startswith('qt'):
        import qt
        return qt.QtPort(port_name, options)
    elif port_to_use.startswith('chromium-mac'):
        import chromium_mac
        return chromium_mac.ChromiumMacPort(port_name, options)
    elif port_to_use.startswith('chromium-linux'):
        import chromium_linux
        return chromium_linux.ChromiumLinuxPort(port_name, options)
    elif port_to_use.startswith('chromium-win'):
        import chromium_win
        return chromium_win.ChromiumWinPort(port_name, options)
    elif port_to_use.startswith('google-chrome'):
        import google_chrome
        return google_chrome.GetGoogleChromePort(port_name, options)

    raise NotImplementedError('unsupported port: %s' % port_to_use)
Example #4
0
 def test_setup_environ_for_server_register_cygwin(self):
     sys.platform = "win32"
     port = chromium_win.ChromiumWinPort(
         options=ChromiumWinTest.RegisterCygwinOption())
     port._executive = mocktool.MockExecute(True)
     port.path_from_chromium_base = self._mock_path_from_chromium_base
     setup_mount = self._mock_path_from_chromium_base(
         "third_party", "cygwin", "setup_mount.bat")
     expected_stderr = "MOCK run_command: %s\n" % [setup_mount]
     output = outputcapture.OutputCapture()
     output.assert_outputs(self,
                           port.setup_environ_for_server,
                           expected_stderr=expected_stderr)