Chromium Code Reviews| 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 """Performance tests for Chrome Endure (long-running perf tests on Chrome). | 6 """Performance tests for Chrome Endure (long-running perf tests on Chrome). |
| 7 | 7 |
| 8 This module accepts the following environment variable inputs: | 8 This module accepts the following environment variable inputs: |
| 9 TEST_LENGTH: The number of seconds in which to run each test. | 9 TEST_LENGTH: The number of seconds in which to run each test. |
| 10 PERF_STATS_INTERVAL: The number of seconds to wait in-between each sampling | 10 PERF_STATS_INTERVAL: The number of seconds to wait in-between each sampling |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 remaining_time = self._test_length_sec - ( | 281 remaining_time = self._test_length_sec - ( |
| 282 time.time() - self._test_start_time) | 282 time.time() - self._test_start_time) |
| 283 logging.info('Chrome interaction #%d. Time remaining in test: %d sec.' % | 283 logging.info('Chrome interaction #%d. Time remaining in test: %d sec.' % |
| 284 (iteration_num, remaining_time)) | 284 (iteration_num, remaining_time)) |
| 285 | 285 |
| 286 time.sleep(5) | 286 time.sleep(5) |
| 287 | 287 |
| 288 self._GetPerformanceStats(self._webapp_name, test_description, | 288 self._GetPerformanceStats(self._webapp_name, test_description, |
| 289 self._tab_title_substring) | 289 self._tab_title_substring) |
| 290 | 290 |
| 291 def testControlAttachDetachDOMTreeWebDriver(self): | |
|
frankf1
2012/03/10 02:57:17
There are a lot of duplication between this and pr
dennis_jeffrey
2012/03/12 18:48:07
Good point. Done. Also added a TODO to make the
| |
| 292 """Use WebDriver to attach and detach a DOM tree from a basic document.""" | |
| 293 test_description = 'AttachDetachDOMTreeWebDriver' | |
| 294 | |
| 295 url = self.GetHttpURLForDataPath('chrome_endure', | |
| 296 'endurance_control_webdriver.html') | |
| 297 self.NavigateToURL(url) | |
| 298 loaded_tab_title = self.GetActiveTabTitle() | |
| 299 self.assertTrue(self._tab_title_substring in loaded_tab_title, | |
| 300 msg='Loaded tab title does not contain "%s": "%s"' % | |
| 301 (self._tab_title_substring, loaded_tab_title)) | |
| 302 | |
| 303 driver = self.NewWebDriver() | |
| 304 wait = WebDriverWait(driver, timeout=60) | |
| 305 | |
| 306 # Interact with the control test webpage for the duration of the test. | |
| 307 # Here, we repeat the following sequence of interactions: click the | |
| 308 # "attach" button to attach a large DOM tree (with event listeners) to the | |
| 309 # document, wait half a second, click "detach" to detach the DOM tree from | |
| 310 # the document, wait half a second. | |
| 311 self._test_start_time = time.time() | |
| 312 last_perf_stats_time = time.time() | |
| 313 self._GetPerformanceStats(self._webapp_name, test_description, | |
| 314 self._tab_title_substring) | |
| 315 iteration_num = 0 | |
| 316 while time.time() - self._test_start_time < self._test_length_sec: | |
| 317 iteration_num += 1 | |
| 318 | |
| 319 if time.time() - last_perf_stats_time >= self._get_perf_stats_interval: | |
| 320 last_perf_stats_time = time.time() | |
| 321 self._GetPerformanceStats(self._webapp_name, test_description, | |
| 322 self._tab_title_substring) | |
| 323 | |
| 324 if iteration_num % 10 == 0: | |
| 325 remaining_time = self._test_length_sec - ( | |
| 326 time.time() - self._test_start_time) | |
|
frankf1
2012/03/10 02:57:17
alignment issue
dennis_jeffrey
2012/03/12 18:48:07
I indented this line 4 spaces underneath the right
| |
| 327 logging.info('Chrome interaction #%d. Time remaining in test: %d sec.' % | |
| 328 (iteration_num, remaining_time)) | |
| 329 | |
| 330 self._ClickElementByXpath(driver, wait, 'id("attach")') | |
| 331 time.sleep(0.5) | |
| 332 self._ClickElementByXpath(driver, wait, 'id("detach")') | |
| 333 time.sleep(0.5) | |
| 334 | |
| 335 self._GetPerformanceStats(self._webapp_name, test_description, | |
| 336 self._tab_title_substring) | |
| 337 | |
| 291 | 338 |
| 292 class ChromeEndureGmailTest(ChromeEndureBaseTest): | 339 class ChromeEndureGmailTest(ChromeEndureBaseTest): |
| 293 """Long-running performance tests for Chrome using Gmail.""" | 340 """Long-running performance tests for Chrome using Gmail.""" |
| 294 | 341 |
| 295 _webapp_name = 'Gmail' | 342 _webapp_name = 'Gmail' |
| 296 _tab_title_substring = 'Gmail' | 343 _tab_title_substring = 'Gmail' |
| 297 | 344 |
| 298 def setUp(self): | 345 def setUp(self): |
| 299 ChromeEndureBaseTest.setUp(self) | 346 ChromeEndureBaseTest.setUp(self) |
| 300 | 347 |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 799 driver, wait, '//div[text()="Acquaintances"]'): | 846 driver, wait, '//div[text()="Acquaintances"]'): |
| 800 num_errors += 1 | 847 num_errors += 1 |
| 801 time.sleep(1) | 848 time.sleep(1) |
| 802 | 849 |
| 803 self._GetPerformanceStats(self._webapp_name, test_description, | 850 self._GetPerformanceStats(self._webapp_name, test_description, |
| 804 self._tab_title_substring) | 851 self._tab_title_substring) |
| 805 | 852 |
| 806 | 853 |
| 807 if __name__ == '__main__': | 854 if __name__ == '__main__': |
| 808 pyauto_functional.Main() | 855 pyauto_functional.Main() |
| OLD | NEW |