OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """PyAuto: Python Interface to Chromium's Automation Proxy. | 6 """PyAuto: Python Interface to Chromium's Automation Proxy. |
7 | 7 |
8 PyAuto uses swig to expose Automation Proxy interfaces to Python. | 8 PyAuto uses swig to expose Automation Proxy interfaces to Python. |
9 For complete documentation on the functionality available, | 9 For complete documentation on the functionality available, |
10 run pydoc on this file. | 10 run pydoc on this file. |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 def GetHttpURLForDataPath(*relative_path): | 601 def GetHttpURLForDataPath(*relative_path): |
602 """Get http:// url for the given path in the data dir. | 602 """Get http:// url for the given path in the data dir. |
603 | 603 |
604 The URL will be usable only after starting the http server. | 604 The URL will be usable only after starting the http server. |
605 """ | 605 """ |
606 global _HTTP_SERVER | 606 global _HTTP_SERVER |
607 assert _HTTP_SERVER, 'HTTP Server not yet started' | 607 assert _HTTP_SERVER, 'HTTP Server not yet started' |
608 return _HTTP_SERVER.GetURL(os.path.join('files', *relative_path)).spec() | 608 return _HTTP_SERVER.GetURL(os.path.join('files', *relative_path)).spec() |
609 | 609 |
610 @staticmethod | 610 @staticmethod |
| 611 def ContentDataDir(): |
| 612 """Get path to content/test/data.""" |
| 613 return os.path.join(PyUITest.DataDir(), os.pardir, os.pardir, os.pardir, |
| 614 'content', 'test', 'data') |
| 615 |
| 616 @staticmethod |
| 617 def GetFileURLForContentDataPath(*relative_path): |
| 618 """Get file:// url for the given path relative to content test data dir. |
| 619 |
| 620 Also quotes the url using urllib.quote(). |
| 621 |
| 622 Args: |
| 623 relative_path: Variable number of strings that can be joined. |
| 624 """ |
| 625 return PyUITest.GetFileURLForPath(PyUITest.ContentDataDir(), *relative_path) |
| 626 |
| 627 @staticmethod |
611 def GetFtpURLForDataPath(ftp_server, *relative_path): | 628 def GetFtpURLForDataPath(ftp_server, *relative_path): |
612 """Get ftp:// url for the given path in the data dir. | 629 """Get ftp:// url for the given path in the data dir. |
613 | 630 |
614 Args: | 631 Args: |
615 ftp_server: handle to ftp server, an instance of TestServer | 632 ftp_server: handle to ftp server, an instance of TestServer |
616 relative_path: any number of path elements | 633 relative_path: any number of path elements |
617 | 634 |
618 The URL will be usable only after starting the ftp server. | 635 The URL will be usable only after starting the ftp server. |
619 """ | 636 """ |
620 assert ftp_server, 'FTP Server not yet started' | 637 assert ftp_server, 'FTP Server not yet started' |
(...skipping 5721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6342 successful = result.wasSuccessful() | 6359 successful = result.wasSuccessful() |
6343 if not successful: | 6360 if not successful: |
6344 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) | 6361 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) |
6345 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ | 6362 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ |
6346 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) | 6363 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) |
6347 sys.exit(not successful) | 6364 sys.exit(not successful) |
6348 | 6365 |
6349 | 6366 |
6350 if __name__ == '__main__': | 6367 if __name__ == '__main__': |
6351 Main() | 6368 Main() |
OLD | NEW |