def CreatePlatformBackendForCurrentOS(): if sys.platform.startswith('linux'): return linux_platform_backend.LinuxPlatformBackend() elif sys.platform == 'darwin': return mac_platform_backend.MacPlatformBackend() elif sys.platform == 'win32': return win_platform_backend.WinPlatformBackend() else: raise NotImplementedError()
def testGetOSVersionNameSaucy(self): path = os.path.join(util.GetUnittestDataDir(), 'ubuntu-saucy-lsb-release') with open(path) as f: unbuntu_saucy_lsb_release_content = f.read() with mock.patch.object( linux_platform_backend.LinuxPlatformBackend, 'GetFileContents', return_value=unbuntu_saucy_lsb_release_content) as mock_method: backend = linux_platform_backend.LinuxPlatformBackend() self.assertEqual(backend.GetOSVersionName(), 'saucy') mock_method.assert_called_once_with('/etc/lsb-release')
def testGetOSVersionNameArch(self): path = os.path.join(util.GetUnittestDataDir(), 'arch-lsb-release') with open(path) as f: arch_lsb_release_content = f.read() with mock.patch.object( linux_platform_backend.LinuxPlatformBackend, 'GetFileContents', return_value=arch_lsb_release_content) as mock_method: backend = linux_platform_backend.LinuxPlatformBackend() # a distribution may not have a codename or a release number. We just # check that GetOSVersionName doesn't raise an exception backend.GetOSVersionName() mock_method.assert_called_once_with('/etc/lsb-release')
def Create(self): backend = desktop_browser_backend.DesktopBrowserBackend( self._options, self._local_executable, self._is_content_shell, self._use_login) if sys.platform.startswith('linux'): p = linux_platform_backend.LinuxPlatformBackend() elif sys.platform == 'darwin': p = mac_platform_backend.MacPlatformBackend() elif sys.platform == 'win32': p = win_platform_backend.WinPlatformBackend() else: raise NotImplementedError() b = browser.Browser(backend, p) backend.SetBrowser(b) return b
def _InitHostPlatformIfNeeded(): global _host_platform if _host_platform: return if sys.platform.startswith('linux'): from telemetry.core.platform import linux_platform_backend backend = linux_platform_backend.LinuxPlatformBackend() elif sys.platform == 'darwin': from telemetry.core.platform import mac_platform_backend backend = mac_platform_backend.MacPlatformBackend() elif sys.platform == 'win32': from telemetry.core.platform import win_platform_backend backend = win_platform_backend.WinPlatformBackend() else: raise NotImplementedError() _host_platform = Platform(backend)
def _CreateBrowserInternal(self, delete_profile_dir_after_run): backend = desktop_browser_backend.DesktopBrowserBackend( self._options, self._local_executable, self._is_content_shell, delete_profile_dir_after_run=delete_profile_dir_after_run) if sys.platform.startswith('linux'): p = linux_platform_backend.LinuxPlatformBackend() elif sys.platform == 'darwin': p = mac_platform_backend.MacPlatformBackend() elif sys.platform == 'win32': p = win_platform_backend.WinPlatformBackend() else: raise NotImplementedError() b = browser.Browser(backend, p) backend.SetBrowser(b) return (b, backend)