Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: tools/chrome_remote_control/chrome_remote_control/desktop_browser_finder_unittest.py

Issue 10984018: [chrome_remote_control] Add pylint to PRESUMMIT and fix lint (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for landing Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 import os as real_os
5 import unittest 4 import unittest
6 5
7 from chrome_remote_control import browser_options 6 from chrome_remote_control import browser_options
8 from chrome_remote_control import desktop_browser_finder 7 from chrome_remote_control import desktop_browser_finder
9 from chrome_remote_control.system_stub import * 8 from chrome_remote_control.system_stub import (
9 OSModuleStub,
10 SysModuleStub
11 )
10 12
11 # This file verifies the logic for finding a browser instance on all platforms 13 # This file verifies the logic for finding a browser instance on all platforms
12 # at once. It does so by providing stubs for the OS/sys/subprocess primitives 14 # at once. It does so by providing stubs for the OS/sys/subprocess primitives
13 # that the underlying finding logic usually uses to locate a suitable browser. 15 # that the underlying finding logic usually uses to locate a suitable browser.
14 # We prefer this approach to having to run the same test on every platform on 16 # We prefer this approach to having to run the same test on every platform on
15 # which we want this code to work. 17 # which we want this code to work.
16 18
17 class StubSubprocess(object): 19 class StubSubprocess(object):
18 def __init__(self): 20 def __init__(self):
19 self.call_hook = None 21 self.call_hook = None
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 def setUp(self): 77 def setUp(self):
76 super(LinuxFindTest, self).setUp() 78 super(LinuxFindTest, self).setUp()
77 79
78 self._sys_stub.platform = 'linux2' 80 self._sys_stub.platform = 'linux2'
79 self._files.append('/foo/chrome') 81 self._files.append('/foo/chrome')
80 self._files.append('../../../out/Release/chrome') 82 self._files.append('../../../out/Release/chrome')
81 self._files.append('../../../out/Debug/chrome') 83 self._files.append('../../../out/Debug/chrome')
82 self._files.append('../../../out/Release/content_shell') 84 self._files.append('../../../out/Release/content_shell')
83 self._files.append('../../../out/Debug/content_shell') 85 self._files.append('../../../out/Debug/content_shell')
84 86
85 self._has_google_chrome_on_path = False 87 self.has_google_chrome_on_path = False
86 this = self 88 this = self
87 def call_hook(*args, **kwargs): 89 def call_hook(*args, **kwargs): # pylint: disable=W0613
88 if this._has_google_chrome_on_path: 90 if this.has_google_chrome_on_path:
89 return 0 91 return 0
90 raise OSError('Not found') 92 raise OSError('Not found')
91 self._subprocess_stub.call_hook = call_hook 93 self._subprocess_stub.call_hook = call_hook
92 94
93 def testFindAllWithExact(self): 95 def testFindAllWithExact(self):
94 types = self.DoFindAllTypes() 96 types = self.DoFindAllTypes()
95 self.assertEquals( 97 self.assertEquals(
96 set(types), 98 set(types),
97 set(['debug', 'release', 99 set(['debug', 'release',
98 'content-shell-debug', 'content-shell-release'])) 100 'content-shell-debug', 'content-shell-release']))
99 101
100 def testFindWithProvidedExecutable(self): 102 def testFindWithProvidedExecutable(self):
101 self._options.browser_executable = '/foo/chrome' 103 self._options.browser_executable = '/foo/chrome'
102 self.assertTrue('exact' in self.DoFindAllTypes()) 104 self.assertTrue('exact' in self.DoFindAllTypes())
103 105
104 def testFindUsingDefaults(self): 106 def testFindUsingDefaults(self):
105 self._has_google_chrome_on_path = True 107 self.has_google_chrome_on_path = True
106 self.assertTrue('release' in self.DoFindAllTypes()) 108 self.assertTrue('release' in self.DoFindAllTypes())
107 109
108 del self._files[1] 110 del self._files[1]
109 self._has_google_chrome_on_path = True 111 self.has_google_chrome_on_path = True
110 self.assertTrue('system' in self.DoFindAllTypes()) 112 self.assertTrue('system' in self.DoFindAllTypes())
111 113
112 self._has_google_chrome_on_path = False 114 self.has_google_chrome_on_path = False
113 del self._files[1] 115 del self._files[1]
114 self.assertEquals(['content-shell-debug', 'content-shell-release'], 116 self.assertEquals(['content-shell-debug', 'content-shell-release'],
115 self.DoFindAllTypes()) 117 self.DoFindAllTypes())
116 118
117 def testFindUsingRelease(self): 119 def testFindUsingRelease(self):
118 self.assertTrue('release' in self.DoFindAllTypes()) 120 self.assertTrue('release' in self.DoFindAllTypes())
119 121
120 122
121 class WinFindTest(FindTestBase): 123 class WinFindTest(FindTestBase):
122 def setUp(self): 124 def setUp(self):
(...skipping 20 matching lines...) Expand all
143 145
144 def testFindAllWithExact(self): 146 def testFindAllWithExact(self):
145 self._options.browser_executable = 'c:\\tmp\\chrome.exe' 147 self._options.browser_executable = 'c:\\tmp\\chrome.exe'
146 types = self.DoFindAllTypes() 148 types = self.DoFindAllTypes()
147 self.assertEquals( 149 self.assertEquals(
148 set(types), 150 set(types),
149 set(['exact', 151 set(['exact',
150 'debug', 'release', 152 'debug', 'release',
151 'content-shell-debug', 'content-shell-release', 153 'content-shell-debug', 'content-shell-release',
152 'system', 'canary'])) 154 'system', 'canary']))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698