| Index: tools/chrome_remote_control/chrome_remote_control/desktop_browser_finder_unittest.py
|
| diff --git a/tools/chrome_remote_control/chrome_remote_control/desktop_browser_finder_unittest.py b/tools/chrome_remote_control/chrome_remote_control/desktop_browser_finder_unittest.py
|
| index c75ab02450beedef0aa7dfe6c87918474a7ed101..2ec9392853e1205ef4b693d04f2c3a805503ad8e 100644
|
| --- a/tools/chrome_remote_control/chrome_remote_control/desktop_browser_finder_unittest.py
|
| +++ b/tools/chrome_remote_control/chrome_remote_control/desktop_browser_finder_unittest.py
|
| @@ -5,10 +5,7 @@ import unittest
|
|
|
| from chrome_remote_control import browser_options
|
| from chrome_remote_control import desktop_browser_finder
|
| -from chrome_remote_control.system_stub import (
|
| - OSModuleStub,
|
| - SysModuleStub
|
| - )
|
| +from chrome_remote_control import system_stub
|
|
|
| # This file verifies the logic for finding a browser instance on all platforms
|
| # at once. It does so by providing stubs for the OS/sys/subprocess primitives
|
| @@ -16,29 +13,22 @@ from chrome_remote_control.system_stub import (
|
| # We prefer this approach to having to run the same test on every platform on
|
| # which we want this code to work.
|
|
|
| -class StubSubprocess(object):
|
| - def __init__(self):
|
| - self.call_hook = None
|
| -
|
| - def call(self, *args, **kwargs):
|
| - assert self.call_hook
|
| - return self.call_hook(*args, **kwargs)
|
| -
|
| class FindTestBase(unittest.TestCase):
|
| def setUp(self):
|
| self._options = browser_options.BrowserOptions()
|
| self._options.chrome_root = '../../../'
|
| - self._sys_stub = SysModuleStub()
|
| - self._os_stub = OSModuleStub(self._sys_stub)
|
| - self._subprocess_stub = StubSubprocess()
|
| + self._stubs = system_stub.Override(desktop_browser_finder,
|
| + ['os', 'subprocess', 'sys'])
|
| +
|
| + def tearDown(self):
|
| + self._stubs.Restore()
|
|
|
| @property
|
| def _files(self):
|
| - return self._os_stub.files
|
| + return self._stubs.os.path.files
|
|
|
| def DoFindAll(self):
|
| - return desktop_browser_finder.FindAllAvailableBrowsers(self._options,
|
| - self._os_stub, self._sys_stub, self._subprocess_stub)
|
| + return desktop_browser_finder.FindAllAvailableBrowsers(self._options)
|
|
|
| def DoFindAllTypes(self):
|
| browsers = self.DoFindAll()
|
| @@ -50,7 +40,7 @@ def has_type(array, browser_type):
|
| class OSXFindTest(FindTestBase):
|
| def setUp(self):
|
| super(OSXFindTest, self).setUp()
|
| - self._sys_stub.platform = 'darwin'
|
| + self._stubs.sys.platform = 'darwin'
|
| self._files.append('/Applications/Google Chrome Canary.app/'
|
| 'Contents/MacOS/Google Chrome Canary')
|
| self._files.append('/Applications/Google Chrome.app/' +
|
| @@ -77,7 +67,7 @@ class LinuxFindTest(FindTestBase):
|
| def setUp(self):
|
| super(LinuxFindTest, self).setUp()
|
|
|
| - self._sys_stub.platform = 'linux2'
|
| + self._stubs.sys.platform = 'linux2'
|
| self._files.append('/foo/chrome')
|
| self._files.append('../../../out/Release/chrome')
|
| self._files.append('../../../out/Debug/chrome')
|
| @@ -90,7 +80,7 @@ class LinuxFindTest(FindTestBase):
|
| if this.has_google_chrome_on_path:
|
| return 0
|
| raise OSError('Not found')
|
| - self._subprocess_stub.call_hook = call_hook
|
| + self._stubs.subprocess.call = call_hook
|
|
|
| def testFindAllWithExact(self):
|
| types = self.DoFindAllTypes()
|
| @@ -124,16 +114,16 @@ class WinFindTest(FindTestBase):
|
| def setUp(self):
|
| super(WinFindTest, self).setUp()
|
|
|
| - self._sys_stub.platform = 'win32'
|
| - self._os_stub.local_app_data = 'c:\\Users\\Someone\\AppData\\Local'
|
| + self._stubs.sys.platform = 'win32'
|
| + self._stubs.os.local_app_data = 'c:\\Users\\Someone\\AppData\\Local'
|
| self._files.append('c:\\tmp\\chrome.exe')
|
| self._files.append('..\\..\\..\\build\\Release\\chrome.exe')
|
| self._files.append('..\\..\\..\\build\\Debug\\chrome.exe')
|
| self._files.append('..\\..\\..\\build\\Release\\content_shell.exe')
|
| self._files.append('..\\..\\..\\build\\Debug\\content_shell.exe')
|
| - self._files.append(self._os_stub.local_app_data + '\\' +
|
| + self._files.append(self._stubs.os.local_app_data + '\\' +
|
| 'Google\\Chrome\\Application\\chrome.exe')
|
| - self._files.append(self._os_stub.local_app_data + '\\' +
|
| + self._files.append(self._stubs.os.local_app_data + '\\' +
|
| 'Google\\Chrome SxS\\Application\\chrome.exe')
|
|
|
| def testFindAllGivenDefaults(self):
|
|
|