OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 | 4 |
5 import inspect | 5 import inspect |
6 import logging | 6 import logging |
7 import re | 7 import re |
8 import unittest | 8 import unittest |
9 | 9 |
10 from py_utils import cloud_storage | 10 from py_utils import cloud_storage |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 archive_path: Path to the WPR file. If there is a corresponding sha1 file, | 84 archive_path: Path to the WPR file. If there is a corresponding sha1 file, |
85 this archive will be automatically downloaded from Google Storage. | 85 this archive will be automatically downloaded from Google Storage. |
86 archive_bucket: The bucket to look for the WPR archive. | 86 archive_bucket: The bucket to look for the WPR archive. |
87 """ | 87 """ |
88 assert cls._browser_options, ( | 88 assert cls._browser_options, ( |
89 'Browser options must be set with |SetBrowserOptions| prior to ' | 89 'Browser options must be set with |SetBrowserOptions| prior to ' |
90 'starting WPR') | 90 'starting WPR') |
91 assert not cls.browser, 'WPR must be started prior to browser being started' | 91 assert not cls.browser, 'WPR must be started prior to browser being started' |
92 | 92 |
93 cloud_storage.GetIfChanged(archive_path, archive_bucket) | 93 cloud_storage.GetIfChanged(archive_path, archive_bucket) |
94 use_wpr_go = archive_path.endswith('.wprgo') | 94 cls.platform.network_controller.Open(wpr_modes.WPR_REPLAY, []) |
95 cls.platform.network_controller.Open(wpr_modes.WPR_REPLAY, [], | |
96 use_wpr_go=use_wpr_go) | |
97 cls.platform.network_controller.StartReplay(archive_path=archive_path) | 95 cls.platform.network_controller.StartReplay(archive_path=archive_path) |
98 | 96 |
99 @classmethod | 97 @classmethod |
100 def StopWPRServer(cls): | 98 def StopWPRServer(cls): |
101 cls.platform.network_controller.StopReplay() | 99 cls.platform.network_controller.StopReplay() |
102 | 100 |
103 @classmethod | 101 @classmethod |
104 def StartBrowser(cls): | 102 def StartBrowser(cls): |
105 assert cls._browser_options, ( | 103 assert cls._browser_options, ( |
106 'Browser options must be set with |SetBrowserOptions| prior to ' | 104 'Browser options must be set with |SetBrowserOptions| prior to ' |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 assert hasattr(test_class, based_method_name), ( | 219 assert hasattr(test_class, based_method_name), ( |
222 '%s is specified but based method %s does not exist' % | 220 '%s is specified but based method %s does not exist' % |
223 (name, based_method_name)) | 221 (name, based_method_name)) |
224 based_method = getattr(test_class, based_method_name) | 222 based_method = getattr(test_class, based_method_name) |
225 for generated_test_name, args in method(finder_options): | 223 for generated_test_name, args in method(finder_options): |
226 _ValidateTestMethodname(generated_test_name) | 224 _ValidateTestMethodname(generated_test_name) |
227 setattr(test_class, generated_test_name, _GenerateTestMethod( | 225 setattr(test_class, generated_test_name, _GenerateTestMethod( |
228 based_method, args)) | 226 based_method, args)) |
229 test_cases.append(test_class(generated_test_name)) | 227 test_cases.append(test_class(generated_test_name)) |
230 return test_cases | 228 return test_cases |
OLD | NEW |