| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 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 """End to end tests for ChromeDriver.""" | 6 """End to end tests for ChromeDriver.""" |
| 7 | 7 |
| 8 import base64 | 8 import base64 |
| 9 import json | 9 import json |
| 10 import optparse | 10 import optparse |
| (...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 parser.add_option( | 912 parser.add_option( |
| 913 '', '--filter', type='string', default='*', | 913 '', '--filter', type='string', default='*', |
| 914 help=('Filter for specifying what tests to run, "*" will run all. E.g., ' | 914 help=('Filter for specifying what tests to run, "*" will run all. E.g., ' |
| 915 '*testStartStop')) | 915 '*testStartStop')) |
| 916 parser.add_option( | 916 parser.add_option( |
| 917 '', '--android-package', | 917 '', '--android-package', |
| 918 help=('Android package key. Possible values: ' + | 918 help=('Android package key. Possible values: ' + |
| 919 str(_ANDROID_NEGATIVE_FILTER.keys()))) | 919 str(_ANDROID_NEGATIVE_FILTER.keys()))) |
| 920 options, args = parser.parse_args() | 920 options, args = parser.parse_args() |
| 921 | 921 |
| 922 options.chromedriver = util.GetAbsolutePathOfUserPath(options.chromedriver) |
| 922 if not options.chromedriver or not os.path.exists(options.chromedriver): | 923 if not options.chromedriver or not os.path.exists(options.chromedriver): |
| 923 parser.error('chromedriver is required or the given path is invalid.' + | 924 parser.error('chromedriver is required or the given path is invalid.' + |
| 924 'Please run "%s --help" for help' % __file__) | 925 'Please run "%s --help" for help' % __file__) |
| 925 | 926 |
| 926 global _CHROMEDRIVER_BINARY | 927 global _CHROMEDRIVER_BINARY |
| 927 _CHROMEDRIVER_BINARY = options.chromedriver | 928 _CHROMEDRIVER_BINARY = options.chromedriver |
| 928 | 929 |
| 929 if (options.android_package and | 930 if (options.android_package and |
| 930 options.android_package not in _ANDROID_NEGATIVE_FILTER): | 931 options.android_package not in _ANDROID_NEGATIVE_FILTER): |
| 931 parser.error('Invalid --android-package') | 932 parser.error('Invalid --android-package') |
| 932 | 933 |
| 933 chromedriver_server = server.Server(os.path.abspath(_CHROMEDRIVER_BINARY), | 934 chromedriver_server = server.Server(_CHROMEDRIVER_BINARY, options.log_path) |
| 934 options.log_path) | |
| 935 global _CHROMEDRIVER_SERVER_URL | 935 global _CHROMEDRIVER_SERVER_URL |
| 936 _CHROMEDRIVER_SERVER_URL = chromedriver_server.GetUrl() | 936 _CHROMEDRIVER_SERVER_URL = chromedriver_server.GetUrl() |
| 937 | 937 |
| 938 global _REFERENCE_CHROMEDRIVER | 938 global _REFERENCE_CHROMEDRIVER |
| 939 _REFERENCE_CHROMEDRIVER = options.reference_chromedriver | 939 _REFERENCE_CHROMEDRIVER = util.GetAbsolutePathOfUserPath( |
| 940 options.reference_chromedriver) |
| 940 | 941 |
| 941 global _CHROME_BINARY | 942 global _CHROME_BINARY |
| 942 if options.chrome: | 943 if options.chrome: |
| 943 _CHROME_BINARY = os.path.abspath(options.chrome) | 944 _CHROME_BINARY = util.GetAbsolutePathOfUserPath(options.chrome) |
| 944 else: | 945 else: |
| 945 _CHROME_BINARY = None | 946 _CHROME_BINARY = None |
| 946 | 947 |
| 947 global _ANDROID_PACKAGE_KEY | 948 global _ANDROID_PACKAGE_KEY |
| 948 _ANDROID_PACKAGE_KEY = options.android_package | 949 _ANDROID_PACKAGE_KEY = options.android_package |
| 949 | 950 |
| 950 if options.filter == '*': | 951 if options.filter == '*': |
| 951 if _ANDROID_PACKAGE_KEY: | 952 if _ANDROID_PACKAGE_KEY: |
| 952 negative_filter = _ANDROID_NEGATIVE_FILTER[_ANDROID_PACKAGE_KEY] | 953 negative_filter = _ANDROID_NEGATIVE_FILTER[_ANDROID_PACKAGE_KEY] |
| 953 else: | 954 else: |
| 954 negative_filter = _GetDesktopNegativeFilter(options.chrome_version) | 955 negative_filter = _GetDesktopNegativeFilter(options.chrome_version) |
| 955 options.filter = '*-' + ':__main__.'.join([''] + negative_filter) | 956 options.filter = '*-' + ':__main__.'.join([''] + negative_filter) |
| 956 | 957 |
| 957 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( | 958 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( |
| 958 sys.modules[__name__]) | 959 sys.modules[__name__]) |
| 959 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) | 960 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) |
| 960 ChromeDriverTest.GlobalSetUp() | 961 ChromeDriverTest.GlobalSetUp() |
| 961 result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests) | 962 result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests) |
| 962 ChromeDriverTest.GlobalTearDown() | 963 ChromeDriverTest.GlobalTearDown() |
| 963 sys.exit(len(result.failures) + len(result.errors)) | 964 sys.exit(len(result.failures) + len(result.errors)) |
| OLD | NEW |