OLD | NEW |
1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 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 | 4 |
5 from telemetry.page import test_expectations | 5 from telemetry.page import test_expectations |
6 from telemetry.page.actions import action_runner as action_runner_module | 6 from telemetry.page.actions import action_runner as action_runner_module |
7 | 7 |
8 | 8 |
9 class TestNotSupportedOnPlatformError(Exception): | 9 class TestNotSupportedOnPlatformError(Exception): |
10 """PageTest Exception raised when a required feature is unavailable. | 10 """PageTest Exception raised when a required feature is unavailable. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 self._is_action_name_to_run_optional = is_action_name_to_run_optional | 74 self._is_action_name_to_run_optional = is_action_name_to_run_optional |
75 # If the test overrides the TabForPage method, it is considered a multi-tab | 75 # If the test overrides the TabForPage method, it is considered a multi-tab |
76 # test. The main difference between this and a single-tab test is that we | 76 # test. The main difference between this and a single-tab test is that we |
77 # do not attempt recovery for the former if a tab or the browser crashes, | 77 # do not attempt recovery for the former if a tab or the browser crashes, |
78 # because we don't know the current state of tabs (how many are open, etc.) | 78 # because we don't know the current state of tabs (how many are open, etc.) |
79 self.is_multi_tab_test = (self.__class__ is not PageTest and | 79 self.is_multi_tab_test = (self.__class__ is not PageTest and |
80 self.TabForPage.__func__ is not | 80 self.TabForPage.__func__ is not |
81 self.__class__.__bases__[0].TabForPage.__func__) | 81 self.__class__.__bases__[0].TabForPage.__func__) |
82 # _exit_requested is set to true when the test requests an early exit. | 82 # _exit_requested is set to true when the test requests an early exit. |
83 self._exit_requested = False | 83 self._exit_requested = False |
| 84 self._needs_pywebsocket_server = False |
84 | 85 |
85 @property | 86 @property |
86 def discard_first_result(self): | 87 def discard_first_result(self): |
87 """When set to True, the first run of the test is discarded. This is | 88 """When set to True, the first run of the test is discarded. This is |
88 useful for cases where it's desirable to have some test resource cached so | 89 useful for cases where it's desirable to have some test resource cached so |
89 the first run of the test can warm things up. """ | 90 the first run of the test can warm things up. """ |
90 return self._discard_first_result | 91 return self._discard_first_result |
91 | 92 |
92 @discard_first_result.setter | 93 @discard_first_result.setter |
93 def discard_first_result(self, discard): | 94 def discard_first_result(self, discard): |
(...skipping 17 matching lines...) Expand all Loading... |
111 | 112 |
112 @property | 113 @property |
113 def max_failures(self): | 114 def max_failures(self): |
114 """Maximum number of failures allowed for the page set.""" | 115 """Maximum number of failures allowed for the page set.""" |
115 return self._max_failures | 116 return self._max_failures |
116 | 117 |
117 @max_failures.setter | 118 @max_failures.setter |
118 def max_failures(self, count): | 119 def max_failures(self, count): |
119 self._max_failures = count | 120 self._max_failures = count |
120 | 121 |
| 122 @property |
| 123 def needs_pywebsocket_server(self): |
| 124 """When set to True, a pywebsocket server is started.""" |
| 125 return self._needs_pywebsocket_server |
| 126 |
| 127 @needs_pywebsocket_server.setter |
| 128 def needs_pywebsocket_server(self, flag): |
| 129 self._needs_pywebsocket_server = flag |
| 130 |
| 131 def Run(self, args): |
| 132 # Define this method to avoid pylint errors. |
| 133 # TODO(dtu): Make this actually run the test with args.page_set. |
| 134 pass |
| 135 |
121 def RestartBrowserBeforeEachPage(self): | 136 def RestartBrowserBeforeEachPage(self): |
122 """ Should the browser be restarted for the page? | 137 """ Should the browser be restarted for the page? |
123 | 138 |
124 This returns true if the test needs to unconditionally restart the | 139 This returns true if the test needs to unconditionally restart the |
125 browser for each page. It may be called before the browser is started. | 140 browser for each page. It may be called before the browser is started. |
126 """ | 141 """ |
127 return self._needs_browser_restart_after_each_page | 142 return self._needs_browser_restart_after_each_page |
128 | 143 |
129 def StopBrowserAfterPage(self, browser, page): # pylint: disable=W0613 | 144 def StopBrowserAfterPage(self, browser, page): # pylint: disable=W0613 |
130 """Should the browser be stopped after the page is run? | 145 """Should the browser be stopped after the page is run? |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 280 |
266 def IsExiting(self): | 281 def IsExiting(self): |
267 return self._exit_requested | 282 return self._exit_requested |
268 | 283 |
269 def RequestExit(self): | 284 def RequestExit(self): |
270 self._exit_requested = True | 285 self._exit_requested = True |
271 | 286 |
272 @property | 287 @property |
273 def action_name_to_run(self): | 288 def action_name_to_run(self): |
274 return self._action_name_to_run | 289 return self._action_name_to_run |
OLD | NEW |