OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 """Basic pyauto performance tests. | 6 """Basic pyauto performance tests. |
7 | 7 |
8 For tests that need to be run for multiple iterations (e.g., so that average | 8 For tests that need to be run for multiple iterations (e.g., so that average |
9 and standard deviation values can be reported), the default number of iterations | 9 and standard deviation values can be reported), the default number of iterations |
10 run for each of these tests is specified by |_DEFAULT_NUM_ITERATIONS|. | 10 run for each of these tests is specified by |_DEFAULT_NUM_ITERATIONS|. |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 | 481 |
482 self._LoginToGoogleAccount() | 482 self._LoginToGoogleAccount() |
483 self._RunNewTabTest('NewTabGmail', _RunSingleGmailTabOpen) | 483 self._RunNewTabTest('NewTabGmail', _RunSingleGmailTabOpen) |
484 | 484 |
485 def testNewTabCalendar(self): | 485 def testNewTabCalendar(self): |
486 """Measures time to open a tab to a logged-in Calendar account. | 486 """Measures time to open a tab to a logged-in Calendar account. |
487 | 487 |
488 Timing starts right before the new tab is opened, and stops as soon as the | 488 Timing starts right before the new tab is opened, and stops as soon as the |
489 webpage displays the calendar print button (title 'Print my calendar'). | 489 webpage displays the calendar print button (title 'Print my calendar'). |
490 """ | 490 """ |
491 EXPECTED_SUBSTRING = 'Print my calendar' | 491 EXPECTED_SUBSTRING = 'Month' |
492 | 492 |
493 def _DivTitleStartsWith(): | 493 def _DivTitleStartsWith(): |
494 js = """ | 494 js = """ |
495 var divs = document.getElementsByTagName("div"); | 495 var divs = document.getElementsByTagName("div"); |
496 for (var i = 0; i < divs.length; ++i) { | 496 for (var i = 0; i < divs.length; ++i) { |
497 if (divs[i].hasOwnProperty("dataset") && | 497 if (divs[i].innerHTML == "%s") |
498 divs[i].dataset.hasOwnProperty("tooltip") && | |
499 divs[i].dataset.tooltip.indexOf("%s") == 0) | |
500 window.domAutomationController.send("true"); | 498 window.domAutomationController.send("true"); |
501 } | 499 } |
502 window.domAutomationController.send("false"); | 500 window.domAutomationController.send("false"); |
503 """ % EXPECTED_SUBSTRING | 501 """ % EXPECTED_SUBSTRING |
504 return self.ExecuteJavascript(js, tab_index=1) | 502 return self.ExecuteJavascript(js, tab_index=1) |
505 | 503 |
506 def _RunSingleCalendarTabOpen(): | 504 def _RunSingleCalendarTabOpen(): |
507 self._AppendTab('http://calendar.google.com') | 505 self._AppendTab('http://calendar.google.com') |
508 self.assertTrue(self.WaitUntil(_DivTitleStartsWith, timeout=120, | 506 self.assertTrue(self.WaitUntil(_DivTitleStartsWith, timeout=120, |
509 expect_retval='true', retry_sleep=0.10), | 507 expect_retval='true', retry_sleep=0.10), |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 # interactions: click the "Compose" button, enter some text into the "To" | 1059 # interactions: click the "Compose" button, enter some text into the "To" |
1062 # field, enter some text into the "Subject" field, then click the "Discard" | 1060 # field, enter some text into the "Subject" field, then click the "Discard" |
1063 # button to discard the message. | 1061 # button to discard the message. |
1064 num_iterations = 5 | 1062 num_iterations = 5 |
1065 for i in xrange(num_iterations): | 1063 for i in xrange(num_iterations): |
1066 logging.info('Chrome interaction iteration %d of %d.' % ( | 1064 logging.info('Chrome interaction iteration %d of %d.' % ( |
1067 i + 1, num_iterations)) | 1065 i + 1, num_iterations)) |
1068 | 1066 |
1069 compose_button = wait.until(lambda _: _GetElement( | 1067 compose_button = wait.until(lambda _: _GetElement( |
1070 driver.find_element_by_xpath, | 1068 driver.find_element_by_xpath, |
1071 '//div[text()="Compose mail"]')) | 1069 '//div[text()="COMPOSE"]')) |
1072 compose_button.click() | 1070 compose_button.click() |
1073 | 1071 |
1074 to_field = wait.until(lambda _: _GetElement( | 1072 to_field = wait.until(lambda _: _GetElement( |
1075 driver.find_element_by_name, 'to')) | 1073 driver.find_element_by_name, 'to')) |
1076 to_field.send_keys('nobody@nowhere.com') | 1074 to_field.send_keys('nobody@nowhere.com') |
1077 | 1075 |
1078 subject_field = wait.until(lambda _: _GetElement( | 1076 subject_field = wait.until(lambda _: _GetElement( |
1079 driver.find_element_by_name, 'subject')) | 1077 driver.find_element_by_name, 'subject')) |
1080 subject_field.send_keys('This message is about to be discarded') | 1078 subject_field.send_keys('This message is about to be discarded') |
1081 | 1079 |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1470 """Identifies the port number to which the server is currently bound. | 1468 """Identifies the port number to which the server is currently bound. |
1471 | 1469 |
1472 Returns: | 1470 Returns: |
1473 The numeric port number to which the server is currently bound. | 1471 The numeric port number to which the server is currently bound. |
1474 """ | 1472 """ |
1475 return self._server.server_address[1] | 1473 return self._server.server_address[1] |
1476 | 1474 |
1477 | 1475 |
1478 if __name__ == '__main__': | 1476 if __name__ == '__main__': |
1479 pyauto_functional.Main() | 1477 pyauto_functional.Main() |
OLD | NEW |