OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """PyAuto: Python Interface to Chromium's Automation Proxy. | 7 """PyAuto: Python Interface to Chromium's Automation Proxy. |
8 | 8 |
9 PyAuto uses swig to expose Automation Proxy interfaces to Python. | 9 PyAuto uses swig to expose Automation Proxy interfaces to Python. |
10 For complete documentation on the functionality available, | 10 For complete documentation on the functionality available, |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 if sys.platform == 'win32': | 172 if sys.platform == 'win32': |
173 # Don't quote the ':' in drive letter ( say, C: ) on win. | 173 # Don't quote the ':' in drive letter ( say, C: ) on win. |
174 # Also, replace '\' with '/' as expected in a file:/// url. | 174 # Also, replace '\' with '/' as expected in a file:/// url. |
175 drive, rest = os.path.splitdrive(abs_path) | 175 drive, rest = os.path.splitdrive(abs_path) |
176 quoted_path = drive.upper() + urllib.quote((rest.replace('\\', '/'))) | 176 quoted_path = drive.upper() + urllib.quote((rest.replace('\\', '/'))) |
177 return 'file:///' + quoted_path | 177 return 'file:///' + quoted_path |
178 else: | 178 else: |
179 quoted_path = urllib.quote(abs_path) | 179 quoted_path = urllib.quote(abs_path) |
180 return 'file://' + quoted_path | 180 return 'file://' + quoted_path |
181 | 181 |
| 182 @staticmethod |
| 183 def IsMac(): |
| 184 """Are we on Mac?""" |
| 185 return 'darwin' == sys.platform |
| 186 |
| 187 @staticmethod |
| 188 def IsLinux(): |
| 189 """Are we on Linux?""" |
| 190 return 'linux2' == sys.platform |
| 191 |
| 192 @staticmethod |
| 193 def IsWin(): |
| 194 """Are we on Win?""" |
| 195 return 'win32' == sys.platform |
| 196 |
| 197 @staticmethod |
| 198 def IsPosix(): |
| 199 """Are we on Mac/Linux?""" |
| 200 return PyUITest.IsMac() or PyUITest.IsLinux() |
| 201 |
182 def WaitUntil(self, function, timeout=-1, retry_sleep=0.25, args=[]): | 202 def WaitUntil(self, function, timeout=-1, retry_sleep=0.25, args=[]): |
183 """Poll on a condition until timeout. | 203 """Poll on a condition until timeout. |
184 | 204 |
185 Waits until the |function| evalues to True or until |timeout| secs, | 205 Waits until the |function| evalues to True or until |timeout| secs, |
186 whichever occurs earlier. | 206 whichever occurs earlier. |
187 | 207 |
188 This is better than using a sleep, since it waits (almost) only as much | 208 This is better than using a sleep, since it waits (almost) only as much |
189 as needed. | 209 as needed. |
190 | 210 |
191 WARNING: This method call should be avoided as far as possible in favor | 211 WARNING: This method call should be avoided as far as possible in favor |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 if self._options.verbose: | 704 if self._options.verbose: |
685 verbosity = 2 | 705 verbosity = 2 |
686 result = unittest.TextTestRunner(verbosity=verbosity).run(pyauto_suite) | 706 result = unittest.TextTestRunner(verbosity=verbosity).run(pyauto_suite) |
687 del loaded_tests # Need to destroy test cases before the suite | 707 del loaded_tests # Need to destroy test cases before the suite |
688 del pyauto_suite | 708 del pyauto_suite |
689 sys.exit(not result.wasSuccessful()) | 709 sys.exit(not result.wasSuccessful()) |
690 | 710 |
691 | 711 |
692 if __name__ == '__main__': | 712 if __name__ == '__main__': |
693 Main() | 713 Main() |
OLD | NEW |