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 15 matching lines...) Expand all Loading... | |
26 import time | 26 import time |
27 | 27 |
28 import perf | 28 import perf |
29 import pyauto_functional # Must be imported before pyauto. | 29 import pyauto_functional # Must be imported before pyauto. |
30 import pyauto | 30 import pyauto |
31 import pyauto_errors | 31 import pyauto_errors |
32 import pyauto_utils | 32 import pyauto_utils |
33 import remote_inspector_client | 33 import remote_inspector_client |
34 import selenium.common.exceptions | 34 import selenium.common.exceptions |
35 from selenium.webdriver.support.ui import WebDriverWait | 35 from selenium.webdriver.support.ui import WebDriverWait |
36 | 36 |
dennis_jeffrey
2012/08/15 01:21:17
add 1 more blank line here to separate the imports
fdeng1
2012/08/16 17:42:49
Done.
| |
37 | |
38 class NotSupportedEnvironmentError(RuntimeError): | 37 class NotSupportedEnvironmentError(RuntimeError): |
39 """Represent an error raised since the environment (OS) is not supported.""" | 38 """Represent an error raised since the environment (OS) is not supported.""" |
40 pass | 39 pass |
41 | 40 |
42 class ChromeEndureBaseTest(perf.BasePerfTest): | 41 class ChromeEndureBaseTest(perf.BasePerfTest): |
43 """Implements common functionality for all Chrome Endure tests. | 42 """Implements common functionality for all Chrome Endure tests. |
44 | 43 |
45 All Chrome Endure test classes should inherit from this class. | 44 All Chrome Endure test classes should inherit from this class. |
46 """ | 45 """ |
47 | 46 |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
595 | 594 |
596 _WEBAPP_NAME = 'Gmail' | 595 _WEBAPP_NAME = 'Gmail' |
597 _TAB_TITLE_SUBSTRING = 'Gmail' | 596 _TAB_TITLE_SUBSTRING = 'Gmail' |
598 _FRAME_XPATH = 'id("canvas_frame")' | 597 _FRAME_XPATH = 'id("canvas_frame")' |
599 | 598 |
600 def setUp(self): | 599 def setUp(self): |
601 ChromeEndureBaseTest.setUp(self) | 600 ChromeEndureBaseTest.setUp(self) |
602 | 601 |
603 # Log into a test Google account and open up Gmail. | 602 # Log into a test Google account and open up Gmail. |
604 self._LoginToGoogleAccount(account_key='test_google_account_gmail') | 603 self._LoginToGoogleAccount(account_key='test_google_account_gmail') |
605 self.NavigateToURL('http://www.gmail.com') | 604 self.NavigateToURL(self._GetConfig().get('gmail_url')) |
606 loaded_tab_title = self.GetActiveTabTitle() | 605 loaded_tab_title = self.GetActiveTabTitle() |
607 self.assertTrue(self._TAB_TITLE_SUBSTRING in loaded_tab_title, | 606 self.assertTrue(self._TAB_TITLE_SUBSTRING in loaded_tab_title, |
608 msg='Loaded tab title does not contain "%s": "%s"' % | 607 msg='Loaded tab title does not contain "%s": "%s"' % |
609 (self._TAB_TITLE_SUBSTRING, loaded_tab_title)) | 608 (self._TAB_TITLE_SUBSTRING, loaded_tab_title)) |
610 | 609 |
611 self._driver = self.NewWebDriver() | 610 self._driver = self.NewWebDriver() |
612 # Any call to wait.until() will raise an exception if the timeout is hit. | 611 # Any call to wait.until() will raise an exception if the timeout is hit. |
613 # TODO(dennisjeffrey): Remove the need for webdriver's wait using the new | 612 # TODO(dennisjeffrey): Remove the need for webdriver's wait using the new |
614 # DOM mutation observer mechanism. | 613 # DOM mutation observer mechanism. |
615 self._wait = WebDriverWait(self._driver, timeout=60) | 614 self._wait = WebDriverWait(self._driver, timeout=60) |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
933 """Long-running performance tests for Chrome using Google Docs.""" | 932 """Long-running performance tests for Chrome using Google Docs.""" |
934 | 933 |
935 _WEBAPP_NAME = 'Docs' | 934 _WEBAPP_NAME = 'Docs' |
936 _TAB_TITLE_SUBSTRING = 'Google Drive' | 935 _TAB_TITLE_SUBSTRING = 'Google Drive' |
937 | 936 |
938 def setUp(self): | 937 def setUp(self): |
939 ChromeEndureBaseTest.setUp(self) | 938 ChromeEndureBaseTest.setUp(self) |
940 | 939 |
941 # Log into a test Google account and open up Google Docs. | 940 # Log into a test Google account and open up Google Docs. |
942 self._LoginToGoogleAccount() | 941 self._LoginToGoogleAccount() |
943 self.NavigateToURL('http://docs.google.com') | 942 self.NavigateToURL(self._GetConfig().get('docs_url')) |
944 self.assertTrue( | 943 self.assertTrue( |
945 self.WaitUntil(lambda: self._TAB_TITLE_SUBSTRING in | 944 self.WaitUntil(lambda: self._TAB_TITLE_SUBSTRING in |
946 self.GetActiveTabTitle(), | 945 self.GetActiveTabTitle(), |
947 timeout=60, expect_retval=True, retry_sleep=1), | 946 timeout=60, expect_retval=True, retry_sleep=1), |
948 msg='Timed out waiting for Docs to load. Tab title is: %s' % | 947 msg='Timed out waiting for Docs to load. Tab title is: %s' % |
949 self.GetActiveTabTitle()) | 948 self.GetActiveTabTitle()) |
950 | 949 |
951 self._driver = self.NewWebDriver() | 950 self._driver = self.NewWebDriver() |
952 | 951 |
953 def testDocsAlternatelyClickLists(self): | 952 def testDocsAlternatelyClickLists(self): |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1005 """Long-running performance tests for Chrome using Google Plus.""" | 1004 """Long-running performance tests for Chrome using Google Plus.""" |
1006 | 1005 |
1007 _WEBAPP_NAME = 'Plus' | 1006 _WEBAPP_NAME = 'Plus' |
1008 _TAB_TITLE_SUBSTRING = 'Google+' | 1007 _TAB_TITLE_SUBSTRING = 'Google+' |
1009 | 1008 |
1010 def setUp(self): | 1009 def setUp(self): |
1011 ChromeEndureBaseTest.setUp(self) | 1010 ChromeEndureBaseTest.setUp(self) |
1012 | 1011 |
1013 # Log into a test Google account and open up Google Plus. | 1012 # Log into a test Google account and open up Google Plus. |
1014 self._LoginToGoogleAccount() | 1013 self._LoginToGoogleAccount() |
1015 self.NavigateToURL('http://plus.google.com') | 1014 self.NavigateToURL(self._GetConfig().get('plus_url')) |
1016 loaded_tab_title = self.GetActiveTabTitle() | 1015 loaded_tab_title = self.GetActiveTabTitle() |
1017 self.assertTrue(self._TAB_TITLE_SUBSTRING in loaded_tab_title, | 1016 self.assertTrue(self._TAB_TITLE_SUBSTRING in loaded_tab_title, |
1018 msg='Loaded tab title does not contain "%s": "%s"' % | 1017 msg='Loaded tab title does not contain "%s": "%s"' % |
1019 (self._TAB_TITLE_SUBSTRING, loaded_tab_title)) | 1018 (self._TAB_TITLE_SUBSTRING, loaded_tab_title)) |
1020 | 1019 |
1021 self._driver = self.NewWebDriver() | 1020 self._driver = self.NewWebDriver() |
1022 | 1021 |
1023 def testPlusAlternatelyClickStreams(self): | 1022 def testPlusAlternatelyClickStreams(self): |
1024 """Alternates between two different streams. | 1023 """Alternates between two different streams. |
1025 | 1024 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1118 self._num_errors += 1 | 1117 self._num_errors += 1 |
1119 | 1118 |
1120 time.sleep(1) | 1119 time.sleep(1) |
1121 | 1120 |
1122 self._RunEndureTest(self._WEBAPP_NAME, self._TAB_TITLE_SUBSTRING, | 1121 self._RunEndureTest(self._WEBAPP_NAME, self._TAB_TITLE_SUBSTRING, |
1123 test_description, scenario) | 1122 test_description, scenario) |
1124 | 1123 |
1125 | 1124 |
1126 if __name__ == '__main__': | 1125 if __name__ == '__main__': |
1127 pyauto_functional.Main() | 1126 pyauto_functional.Main() |
OLD | NEW |